diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-15 03:11:22 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-15 03:11:22 +0100 |
| commit | 343f2a8a6148b8004d6f4d74fb779b4f30c9686a (patch) | |
| tree | 2ea1ddab346565309da644517c3478d2a9096e55 /scripts | |
| parent | M0: streaming provider, SSE decoder, mock provider, i686 build gate (diff) | |
| download | agent686-343f2a8a6148b8004d6f4d74fb779b4f30c9686a.tar.gz agent686-343f2a8a6148b8004d6f4d74fb779b4f30c9686a.zip | |
M1-M5: sessions, six tools, approvals, prompt, Ctrl-C, target gate
- append-only JSONL sessions with --continue/--session; reasoning stored, stripped on replay
- read/write/edit/grep/glob + bash with timeout and capped output
- diff-preview approval for the first edit of a session, per-call approval for bash
- system prompt frozen per session with AGENTS.md snapshot and change warning
- SIGINT aborts the turn, second Ctrl-C exits
- glibc gate ignores weak symbols; verified in linux/386 debian:12
- acceptance test (calculator in C) passes on both x86-64 and i386
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/check-glibc.sh | 24 | ||||
| -rwxr-xr-x | scripts/mock-provider.py | 18 |
2 files changed, 36 insertions, 6 deletions
diff --git a/scripts/check-glibc.sh b/scripts/check-glibc.sh index bb9052f..b02cd75 100755 --- a/scripts/check-glibc.sh +++ b/scripts/check-glibc.sh | |||
| @@ -4,6 +4,10 @@ | |||
| 4 | # The dev host's 32-bit glibc is newer than Debian 12's, so a dependency can | 4 | # The dev host's 32-bit glibc is newer than Debian 12's, so a dependency can |
| 5 | # silently raise the required symbol version. Without this check the failure | 5 | # silently raise the required symbol version. Without this check the failure |
| 6 | # only shows up as "version `GLIBC_2.38' not found" on the target machine. | 6 | # only shows up as "version `GLIBC_2.38' not found" on the target machine. |
| 7 | # | ||
| 8 | # Weak undefined symbols are ignored: they resolve to NULL on older libc and the | ||
| 9 | # code paths using them fall back. Rust's std does this for glibc 2.39's | ||
| 10 | # pidfd_spawnp/pidfd_getpid, for example. | ||
| 7 | set -euo pipefail | 11 | set -euo pipefail |
| 8 | 12 | ||
| 9 | binary=${1:?usage: check-glibc.sh <binary> [ceiling, default 2.36]} | 13 | binary=${1:?usage: check-glibc.sh <binary> [ceiling, default 2.36]} |
| @@ -14,21 +18,31 @@ if [ ! -f "$binary" ]; then | |||
| 14 | exit 2 | 18 | exit 2 |
| 15 | fi | 19 | fi |
| 16 | 20 | ||
| 17 | max=$(readelf -V "$binary" 2>/dev/null \ | 21 | required=$(readelf --dyn-syms --wide "$binary" 2>/dev/null \ |
| 22 | | awk '$5 != "WEAK" { print }' \ | ||
| 23 | | grep -oE 'GLIBC_[0-9]+\.[0-9]+' \ | ||
| 24 | | sed 's/^GLIBC_//' \ | ||
| 25 | | sort -Vu \ | ||
| 26 | | tail -1 || true) | ||
| 27 | weak=$(readelf --dyn-syms --wide "$binary" 2>/dev/null \ | ||
| 28 | | awk '$5 == "WEAK" { print }' \ | ||
| 18 | | grep -oE 'GLIBC_[0-9]+\.[0-9]+' \ | 29 | | grep -oE 'GLIBC_[0-9]+\.[0-9]+' \ |
| 19 | | sed 's/^GLIBC_//' \ | 30 | | sed 's/^GLIBC_//' \ |
| 20 | | sort -Vu \ | 31 | | sort -Vu \ |
| 21 | | tail -1 || true) | 32 | | tail -1 || true) |
| 22 | 33 | ||
| 23 | if [ -z "${max:-}" ]; then | 34 | if [ -z "${required:-}" ]; then |
| 24 | echo "check-glibc: no versioned symbols (statically linked?) — nothing to check" | 35 | echo "check-glibc: no versioned symbols (statically linked?) — nothing to check" |
| 25 | exit 0 | 36 | exit 0 |
| 26 | fi | 37 | fi |
| 27 | 38 | ||
| 28 | echo "check-glibc: max symbol version GLIBC_$max, ceiling GLIBC_$ceiling" | 39 | echo "check-glibc: required GLIBC_$required, ceiling GLIBC_$ceiling" |
| 40 | if [ -n "${weak:-}" ] && [ "$weak" != "$required" ]; then | ||
| 41 | echo "check-glibc: weak GLIBC_$weak (optional, resolves to NULL on older libc)" | ||
| 42 | fi | ||
| 29 | 43 | ||
| 30 | if [ "$(printf '%s\n%s\n' "$ceiling" "$max" | sort -V | tail -1)" != "$ceiling" ]; then | 44 | if [ "$(printf '%s\n%s\n' "$ceiling" "$required" | sort -V | tail -1)" != "$ceiling" ]; then |
| 31 | echo "check-glibc: FAIL — binary needs GLIBC_$max, target has GLIBC_$ceiling" >&2 | 45 | echo "check-glibc: FAIL — binary needs GLIBC_$required, target has GLIBC_$ceiling" >&2 |
| 32 | exit 1 | 46 | exit 1 |
| 33 | fi | 47 | fi |
| 34 | 48 | ||
diff --git a/scripts/mock-provider.py b/scripts/mock-provider.py index 4d11349..fb15662 100755 --- a/scripts/mock-provider.py +++ b/scripts/mock-provider.py | |||
| @@ -14,6 +14,14 @@ import time | |||
| 14 | from http.server import BaseHTTPRequestHandler, HTTPServer | 14 | from http.server import BaseHTTPRequestHandler, HTTPServer |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | def tool_frames(path, content): | ||
| 18 | yield {"choices": [{"delta": {"tool_calls": [{ | ||
| 19 | "index": 0, | ||
| 20 | "id": "call_mock_1", | ||
| 21 | "function": {"name": "write", "arguments": json.dumps({"path": path, "content": content})}, | ||
| 22 | }]}, "finish_reason": "tool_calls"}]} | ||
| 23 | |||
| 24 | |||
| 17 | def frames(answer: str): | 25 | def frames(answer: str): |
| 18 | yield {"choices": [{"delta": {"reasoning_content": "The user said hi. "}}]} | 26 | yield {"choices": [{"delta": {"reasoning_content": "The user said hi. "}}]} |
| 19 | yield {"choices": [{"delta": {"reasoning_content": "A short greeting is enough."}}]} | 27 | yield {"choices": [{"delta": {"reasoning_content": "A short greeting is enough."}}]} |
| @@ -46,12 +54,17 @@ class Handler(BaseHTTPRequestHandler): | |||
| 46 | self.wfile.write(body) | 54 | self.wfile.write(body) |
| 47 | return | 55 | return |
| 48 | 56 | ||
| 57 | self.server.requests += 1 | ||
| 49 | self.send_response(200) | 58 | self.send_response(200) |
| 50 | self.send_header("Content-Type", "text/event-stream") | 59 | self.send_header("Content-Type", "text/event-stream") |
| 51 | self.send_header("Cache-Control", "no-cache") | 60 | self.send_header("Cache-Control", "no-cache") |
| 52 | self.end_headers() | 61 | self.end_headers() |
| 53 | 62 | ||
| 54 | for frame in frames(self.server.answer): | 63 | if self.server.tool_write and self.server.requests == 1: |
| 64 | stream = tool_frames(self.server.tool_write, "written by the mock\n") | ||
| 65 | else: | ||
| 66 | stream = frames(self.server.answer) | ||
| 67 | for frame in stream: | ||
| 55 | if self.server.delay: | 68 | if self.server.delay: |
| 56 | time.sleep(self.server.delay) | 69 | time.sleep(self.server.delay) |
| 57 | self.wfile.write(f"data: {json.dumps(frame)}\n\n".encode()) | 70 | self.wfile.write(f"data: {json.dumps(frame)}\n\n".encode()) |
| @@ -70,6 +83,7 @@ def main(): | |||
| 70 | parser.add_argument("--delay", type=float, default=0.05, help="seconds between frames") | 83 | parser.add_argument("--delay", type=float, default=0.05, help="seconds between frames") |
| 71 | parser.add_argument("--status", type=int, default=200, help="return this HTTP status") | 84 | parser.add_argument("--status", type=int, default=200, help="return this HTTP status") |
| 72 | parser.add_argument("--answer", default="Hello from the mock provider.") | 85 | parser.add_argument("--answer", default="Hello from the mock provider.") |
| 86 | parser.add_argument("--tool-write", metavar="PATH", help="first response asks to write PATH") | ||
| 73 | parser.add_argument("--quiet", action="store_true") | 87 | parser.add_argument("--quiet", action="store_true") |
| 74 | args = parser.parse_args() | 88 | args = parser.parse_args() |
| 75 | 89 | ||
| @@ -78,6 +92,8 @@ def main(): | |||
| 78 | server.delay = args.delay | 92 | server.delay = args.delay |
| 79 | server.status = args.status | 93 | server.status = args.status |
| 80 | server.quiet = args.quiet | 94 | server.quiet = args.quiet |
| 95 | server.tool_write = args.tool_write | ||
| 96 | server.requests = 0 | ||
| 81 | print(f"mock provider on http://127.0.0.1:{args.port}/v1", flush=True) | 97 | print(f"mock provider on http://127.0.0.1:{args.port}/v1", flush=True) |
| 82 | server.serve_forever() | 98 | server.serve_forever() |
| 83 | 99 | ||
