@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +368 -0
- package/README.md +341 -208
- package/dist/adapters.d.ts +3 -4
- package/dist/adapters.js +18 -15
- package/dist/agent-rows.d.ts +99 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +75 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/archil-settings.d.ts +11 -1
- package/dist/archil-settings.js +10 -0
- package/dist/bash-read-only.d.ts +35 -0
- package/dist/bash-read-only.js +778 -0
- package/dist/box-settings.d.ts +3 -23
- package/dist/box-settings.js +7 -51
- package/dist/boxes.d.ts +17 -0
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +95 -51
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -51
- package/dist/browser-person.js +94 -277
- package/dist/budget.d.ts +0 -5
- package/dist/budget.js +0 -5
- package/dist/cap.d.ts +14 -8
- package/dist/cap.js +19 -9
- package/dist/cli.js +71 -18
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.d.ts +20 -10
- package/dist/computer-keys.js +36 -54
- package/dist/computer-setting.d.ts +20 -3
- package/dist/computer-setting.js +58 -10
- package/dist/computers.d.ts +35 -2
- package/dist/computers.js +72 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-B7NKTU8E.css +1 -0
- package/dist/console/assets/index-CXZMgJE7.js +550 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-cap.d.ts +7 -29
- package/dist/decision-cap.js +3 -94
- package/dist/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +1 -2
- package/dist/errors.js +9 -9
- package/dist/explain.js +3 -1
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -3
- package/dist/files.js +2 -4
- package/dist/github-connection.d.ts +1 -1
- package/dist/github-connection.js +25 -7
- package/dist/github-faux.d.ts +26 -0
- package/dist/github-faux.js +76 -0
- package/dist/github.d.ts +6 -2
- package/dist/github.js +5 -3
- package/dist/graph-served.d.ts +5 -3
- package/dist/graph-served.js +14 -6
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +9 -16
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +1 -7
- package/dist/harness-install.js +1 -18
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/harness.js +0 -1
- package/dist/harness-opencode/host/policy.js +2 -2
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +14 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +8 -2
- package/dist/learn/check.js +85 -31
- package/dist/learn/folder.d.ts +11 -4
- package/dist/learn/folder.js +17 -19
- package/dist/learn/grade.d.ts +18 -1
- package/dist/learn/grade.js +108 -14
- package/dist/learn/index.d.ts +5 -5
- package/dist/learn/index.js +5 -5
- package/dist/learn/learning.sh +1 -14
- package/dist/learn/notes.d.ts +14 -3
- package/dist/learn/notes.js +16 -6
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +83 -6
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +7 -1
- package/dist/learn/secrets.js +86 -19
- package/dist/learn/skills.d.ts +159 -18
- package/dist/learn/skills.js +644 -64
- package/dist/learned-nodes.d.ts +14 -0
- package/dist/learned-nodes.js +8 -0
- package/dist/learned-workflow.d.ts +41 -6
- package/dist/learned-workflow.js +153 -18
- package/dist/learning-routes.d.ts +49 -4
- package/dist/learning-routes.js +113 -31
- package/dist/learning-run.d.ts +16 -31
- package/dist/learning-run.js +31 -38
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +91 -97
- package/dist/learning.js +176 -320
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +12 -2
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +4 -2
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +17 -49
- package/dist/mcp-gateway.js +55 -136
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +18 -18
- package/dist/mcp-servers-store.js +12 -14
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +9 -7
- package/dist/model.js +51 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +156 -58
- package/dist/page.d.ts +1 -3
- package/dist/page.js +6 -18
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +26 -61
- package/dist/pause.d.ts +2 -19
- package/dist/pause.js +5 -74
- package/dist/port-models.d.ts +10 -3
- package/dist/port-models.js +26 -6
- package/dist/propose.d.ts +2 -0
- package/dist/propose.js +80 -45
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -11
- package/dist/run-db.js +2 -37
- package/dist/run-launch.d.ts +21 -2
- package/dist/run-launch.js +14 -5
- package/dist/run-learning-served.d.ts +21 -4
- package/dist/run-learning-served.js +23 -13
- package/dist/run-reads-over-store.d.ts +5 -3
- package/dist/run-reads-over-store.js +25 -14
- package/dist/run-secrets.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +27 -6
- package/dist/run-view.d.ts +37 -22
- package/dist/run-view.js +85 -38
- package/dist/runnable.d.ts +21 -10
- package/dist/runnable.js +35 -12
- package/dist/runner/adapter-loop.d.ts +36 -5
- package/dist/runner/adapter-loop.js +663 -69
- package/dist/runner/adapter-run-spec.d.ts +42 -8
- package/dist/runner/adapter-run-spec.js +186 -52
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +40 -2
- package/dist/runner/adapters/pi.js +110 -27
- package/dist/runner/beside.d.ts +38 -3
- package/dist/runner/beside.js +54 -5
- package/dist/runner/claim-secrets.d.ts +16 -1
- package/dist/runner/claim-secrets.js +62 -14
- package/dist/runner/cli-run-spec.d.ts +5 -0
- package/dist/runner/cli-run-spec.js +159 -41
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.d.ts +1 -0
- package/dist/runner/conformance/harness.js +123 -13
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.d.ts +7 -2
- package/dist/runner/github-app.js +47 -16
- package/dist/runner/harness-loops.d.ts +15 -2
- package/dist/runner/harness-loops.js +38 -2
- package/dist/runner/journal-kinds.d.ts +60 -6
- package/dist/runner/journal-kinds.js +43 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +194 -20
- package/dist/runner/learning-loop.d.ts +7 -0
- package/dist/runner/learning-loop.js +36 -8
- package/dist/runner/learning-seed.d.ts +6 -0
- package/dist/runner/learning-seed.js +6 -0
- package/dist/runner/loop-contract.d.ts +4 -0
- package/dist/runner/main.d.ts +61 -9
- package/dist/runner/main.js +144 -20
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +7 -3
- package/dist/runner/mcp-github.d.ts +11 -2
- package/dist/runner/mcp-github.js +55 -4
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +16 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +46 -1
- package/dist/runner/metrics.js +156 -1
- package/dist/runner/model-route.d.ts +16 -0
- package/dist/runner/model-route.js +134 -10
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +146 -18
- package/dist/runner/spec-holds.d.ts +7 -2
- package/dist/runner/spec-holds.js +4 -3
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-host.d.ts +7 -2
- package/dist/runner/workflow-host.js +3 -1
- package/dist/runner/workflow-loop.d.ts +10 -1
- package/dist/runner/workflow-loop.js +14 -6
- package/dist/runner/workflow-spec.d.ts +21 -0
- package/dist/runner/workflow-spec.js +217 -93
- package/dist/runs-over-store.d.ts +14 -3
- package/dist/runs-over-store.js +100 -23
- package/dist/seal-key.d.ts +0 -2
- package/dist/seal-key.js +5 -45
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +5 -85
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +9 -31
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -36
- package/dist/server.d.ts +37 -56
- package/dist/server.js +322 -134
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/stop-signals.d.ts +4 -2
- package/dist/stop-signals.js +5 -3
- package/dist/store/agent-body.d.ts +12 -2
- package/dist/store/agent-body.js +22 -4
- package/dist/store/deadline.d.ts +18 -0
- package/dist/store/deadline.js +45 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +2 -2
- package/dist/store/open.d.ts +6 -3
- package/dist/store/open.js +2 -2
- package/dist/store/postgres/connection.d.ts +22 -2
- package/dist/store/postgres/connection.js +211 -41
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +9 -2
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +14 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +41 -12
- package/dist/store/store.d.ts +35 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +9 -6
- package/dist/store-reads/journal.js +129 -18
- package/dist/store-reads/learning.d.ts +82 -8
- package/dist/store-reads/learning.js +184 -11
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +19 -1
- package/dist/store-view.js +95 -27
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +33 -14
- package/dist/templates.js +82 -46
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +282 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-budget.d.ts +18 -0
- package/dist/tool-budget.js +50 -0
- package/dist/tool-gate.d.ts +47 -218
- package/dist/tool-gate.js +87 -545
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +5 -101
- package/dist/tool-keys.js +8 -267
- package/dist/tool-plane.d.ts +23 -52
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +67 -25
- package/dist/tools.js +170 -119
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.d.ts +28 -5
- package/dist/uploads.js +83 -10
- package/dist/usage.d.ts +1 -49
- package/dist/usage.js +3 -84
- package/dist/validate.d.ts +4 -0
- package/dist/validate.js +33 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/archil-claim.d.ts +2 -2
- package/dist/workspace/archil-claim.js +4 -3
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +4 -0
- package/dist/workspace/archil-exec.d.ts +12 -2
- package/dist/workspace/archil-exec.js +16 -0
- package/dist/workspace/archil.d.ts +2 -2
- package/dist/workspace/archil.js +25 -5
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +26 -9
- package/dist/workspace/computer-deps.js +144 -43
- package/dist/workspace/computer-for-claim.d.ts +17 -14
- package/dist/workspace/computer-for-claim.js +99 -26
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/computer-ledger.d.ts +1 -8
- package/dist/workspace/computer-ledger.js +0 -3
- package/dist/workspace/computer-providers.d.ts +5 -3
- package/dist/workspace/computer-providers.js +11 -9
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/hands.d.ts +5 -2
- package/dist/workspace/hands.js +4 -3
- package/dist/workspace/index.d.ts +6 -5
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/local.d.ts +14 -2
- package/dist/workspace/local.js +170 -43
- package/dist/workspace/paths.js +3 -2
- package/dist/workspace/pi-env.d.ts +4 -0
- package/dist/workspace/pi-env.js +3 -2
- package/dist/workspace/resolve-computer.d.ts +55 -10
- package/dist/workspace/resolve-computer.js +66 -14
- package/dist/workspace/run-tools.d.ts +15 -31
- package/dist/workspace/run-tools.js +19 -30
- package/dist/workspace/workspace.d.ts +5 -0
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -17
- package/dist/workspace.js +4 -110
- package/package.json +14 -14
- package/skills/agentrun-serve/SKILL.md +1 -1
- package/templates/README.md +11 -5
- package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
- package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
- package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
- package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
- package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
- package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
- package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
- package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
- package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +11 -0
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-Dn0ngwG9.js +0 -535
- package/dist/console/assets/index-DvW6Aled.css +0 -1
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -171
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
package/dist/bound-files.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
// The file tools of a run whose box binds its work/ from this machine (Docker here): read, write and edit run on this
|
|
2
|
-
// machine, on the bind's source, and not as commands in the box, which cost one `docker exec` or more each (half a second
|
|
3
|
-
// and up on real Docker). bash stays in the box. This holds only where the confinement walks held directory handles
|
|
4
|
-
// (workspace.ts writesHeld: Linux's /proc/self/fd): a command in the box runs beside these tools and can plant a link, a
|
|
5
|
-
// hard link or a swapped directory at any moment, and only a walk on held handles refuses a swap between the check and
|
|
6
|
-
// the use. Elsewhere (macOS, a box that binds nothing, Daytona's) all four stay in the box (coding-tools.ts).
|
|
7
|
-
//
|
|
8
|
-
// Nothing a box's command makes in work/ is followed or taken. Every path is work/ joined with its own names, and a link
|
|
9
|
-
// anywhere on the way is refused, even one pointing inside work/. Only a regular file with one hard link is read or
|
|
10
|
-
// written. A write goes through a temporary file renamed over the old one, keeping its mode (workspace.ts
|
|
11
|
-
// writeWorkFile). work/ itself must be its own canonical path: the directory the box was given (run-box.ts
|
|
12
|
-
// mountSource). The model names the box's paths (BOX_WORK), mapped one for one onto the bind's source; every path and
|
|
13
|
-
// message it gets back names the box's, never this machine's.
|
|
14
|
-
import { realpathSync } from "node:fs";
|
|
15
|
-
import { posix } from "node:path";
|
|
16
|
-
import { err, ExecutionError, FileError, ok } from "@earendil-works/pi-durable/env";
|
|
17
|
-
import { NodeExecutionEnv } from "@earendil-works/pi-durable/env/node";
|
|
18
|
-
import { PathOutsideWorkError } from "@parcha/pi-durable-disk";
|
|
19
|
-
import { BOX_WORK } from "./place.js";
|
|
20
|
-
import { openWorkFile, WorkRefused, writeWorkFile } from "./workspace.js";
|
|
21
|
-
/** What a refusal tells the model, by the path it named: what is wrong, and that bash, in the box, can still reach it. */
|
|
22
|
-
const REFUSED = {
|
|
23
|
-
link: (path) => `${path}: refused: a link is on the way to it, or it is one, and read, write and edit follow no link in this run's work/ (bash, in the box, can)`,
|
|
24
|
-
hard_link: (path) => `${path}: refused: it has another hard link, and read, write and edit take only a file with one (bash, in the box, can)`,
|
|
25
|
-
not_regular: (path) => `${path}: refused: it is not a regular file`,
|
|
26
|
-
unreadable: (path) => `${path}: refused: this server may not read it (a command in the box made it private)`,
|
|
27
|
-
over_cap: (path) => `${path}: refused: it is too large`,
|
|
28
|
-
unheld: (path) => `${path}: refused: this host reaches the run's directories by path`,
|
|
29
|
-
};
|
|
30
|
-
const NODE_CODES = { ENOENT: "not_found", EACCES: "permission_denied", EPERM: "permission_denied", ENOTDIR: "not_directory", EISDIR: "is_directory", ELOOP: "invalid" };
|
|
31
|
-
/** A box run's read, write and edit environment on this machine's `hostWork` (canonical: the bind's source), naming the
|
|
32
|
-
* box's paths. Its shell runs nothing, and only the operations those tools make are offered. */
|
|
33
|
-
export function boundFiles(hostWork) {
|
|
34
|
-
// pi's own implementation, only ever handed a checked handle's /proc/self/fd entry, which names that inode and no path.
|
|
35
|
-
const node = new NodeExecutionEnv({ cwd: hostWork });
|
|
36
|
-
/** `text` with this machine's work/ named as the box names it. */
|
|
37
|
-
const boxed = (text) => text.split(`${hostWork}/`).join(`${BOX_WORK}/`).split(hostWork).join(BOX_WORK);
|
|
38
|
-
// The confinement's typed refusal, its message naming no path: the tools name it by the path the call gave
|
|
39
|
-
// (workspace-paths.ts asGivenRefusals). It crosses from pi-durable-disk's pi-durable as a value, typed on this side.
|
|
40
|
-
const outside = (path) => new PathOutsideWorkError(path, "outside_work", "outside the workspace");
|
|
41
|
-
/** `path` as an absolute path of the box, or the refusal of one outside its work/. */
|
|
42
|
-
const absolute = (path) => {
|
|
43
|
-
const abs = posix.resolve(BOX_WORK, path);
|
|
44
|
-
return abs === BOX_WORK || abs.startsWith(`${BOX_WORK}/`) ? ok(abs) : err(outside(path));
|
|
45
|
-
};
|
|
46
|
-
const failure = (error, path) => {
|
|
47
|
-
if (error instanceof WorkRefused) {
|
|
48
|
-
if (error.reason === "missing")
|
|
49
|
-
return new FileError("not_found", `ENOENT: no such file or directory, open '${path}'`, path);
|
|
50
|
-
return new FileError("permission_denied", REFUSED[error.reason](path), path);
|
|
51
|
-
}
|
|
52
|
-
if (error instanceof FileError)
|
|
53
|
-
return new FileError(error.code, boxed(error.message), path, error);
|
|
54
|
-
const code = error?.code;
|
|
55
|
-
return new FileError((code && NODE_CODES[code]) || "unknown", boxed(error?.message ?? String(error)), path);
|
|
56
|
-
};
|
|
57
|
-
/** The work/ the box was given: refused when it is no longer its own canonical path (swapped for a link). */
|
|
58
|
-
const root = () => {
|
|
59
|
-
if (realpathSync(hostWork) !== hostWork)
|
|
60
|
-
throw new WorkRefused(".", "link");
|
|
61
|
-
};
|
|
62
|
-
/** `use` on the file at `path`, opened held: a regular file with one link, reached through no link. */
|
|
63
|
-
async function opened(path, use) {
|
|
64
|
-
const abs = absolute(path);
|
|
65
|
-
if (!abs.ok)
|
|
66
|
-
return abs;
|
|
67
|
-
const rel = posix.relative(BOX_WORK, abs.value);
|
|
68
|
-
if (rel === "")
|
|
69
|
-
return err(new FileError("is_directory", `${abs.value}: is the run's work directory, not a file`, abs.value));
|
|
70
|
-
try {
|
|
71
|
-
root();
|
|
72
|
-
const { handle, stats } = await openWorkFile(hostWork, rel);
|
|
73
|
-
try {
|
|
74
|
-
return ok(await use(handle, stats, abs.value));
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
77
|
-
await handle.close().catch(() => undefined);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
return err(failure(error, abs.value));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/** pi's reader of a checked handle, its info naming the box's path. */
|
|
85
|
-
const reader = async (handle, abs, context) => {
|
|
86
|
-
const made = await node.openBinaryReader(`/proc/self/fd/${handle.fd}`, undefined, context);
|
|
87
|
-
if (!made.ok)
|
|
88
|
-
throw made.error;
|
|
89
|
-
const inner = made.value;
|
|
90
|
-
return {
|
|
91
|
-
info: async (at) => {
|
|
92
|
-
const info = await inner.info(at);
|
|
93
|
-
return info.ok ? ok({ ...info.value, name: posix.basename(abs), path: abs }) : err(failure(info.error, abs));
|
|
94
|
-
},
|
|
95
|
-
read: (offset, length, at) => inner.read(offset, length, at),
|
|
96
|
-
scanLines: (options, at) => inner.scanLines(options, at),
|
|
97
|
-
close: (at) => inner.close(at),
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
/** An operation read, write and edit never make: refused, so nothing else of this machine is reached through it. */
|
|
101
|
-
const unoffered = (name) => async () => err(new FileError("not_supported", `${name} is not offered here: a box run's file tools on this machine read, write and edit, and bash runs in the box`));
|
|
102
|
-
return {
|
|
103
|
-
id: `bound-work:${hostWork}`,
|
|
104
|
-
cwd: BOX_WORK,
|
|
105
|
-
absolutePath: async (path) => absolute(path),
|
|
106
|
-
joinPath: async (parts) => ok(posix.join(...parts)),
|
|
107
|
-
// The mutation queue then keys a file by its absolute path: a link is never followed here, so that is the file.
|
|
108
|
-
canonicalPath: unoffered("canonicalPath"),
|
|
109
|
-
exists: async (path) => {
|
|
110
|
-
const abs = absolute(path);
|
|
111
|
-
if (!abs.ok)
|
|
112
|
-
return abs;
|
|
113
|
-
const found = await opened(abs.value, async () => true);
|
|
114
|
-
// A file refused is there: the operation that follows says why.
|
|
115
|
-
return found.ok || found.error.code !== "not_found" ? ok(true) : ok(false);
|
|
116
|
-
},
|
|
117
|
-
fileInfo: (path) => opened(path, async (_handle, info, abs) => ({ name: posix.basename(abs), path: abs, kind: "file", size: info.size, mtimeMs: info.mtimeMs })),
|
|
118
|
-
readTextFile: (path, context) => opened(path, (handle) => handle.readFile({ encoding: "utf8", ...(context.abortSignal ? { signal: context.abortSignal } : {}) })),
|
|
119
|
-
readBinaryFile: (path, context) => opened(path, async (handle) => new Uint8Array(await handle.readFile(context.abortSignal ? { signal: context.abortSignal } : {}))),
|
|
120
|
-
openBinaryReader: (path, _options, context) => opened(path, (handle, _info, abs) => reader(handle, abs, context)),
|
|
121
|
-
openTextLineReader: (path, context) => opened(path, async (handle, _info, abs) => {
|
|
122
|
-
const made = await node.openTextLineReader(`/proc/self/fd/${handle.fd}`, context);
|
|
123
|
-
if (!made.ok)
|
|
124
|
-
throw failure(made.error, abs);
|
|
125
|
-
return made.value;
|
|
126
|
-
}),
|
|
127
|
-
readTextLines: (path, options, context) => opened(path, async (handle, _info, abs) => {
|
|
128
|
-
const read = await node.readTextLines(`/proc/self/fd/${handle.fd}`, options, context);
|
|
129
|
-
if (!read.ok)
|
|
130
|
-
throw failure(read.error, abs);
|
|
131
|
-
return read.value;
|
|
132
|
-
}),
|
|
133
|
-
writeFile: async (path, content) => {
|
|
134
|
-
const abs = absolute(path);
|
|
135
|
-
if (!abs.ok)
|
|
136
|
-
return abs;
|
|
137
|
-
const rel = posix.relative(BOX_WORK, abs.value);
|
|
138
|
-
if (rel === "")
|
|
139
|
-
return err(new FileError("is_directory", `${abs.value}: is the run's work directory, not a file`, abs.value));
|
|
140
|
-
try {
|
|
141
|
-
root();
|
|
142
|
-
// A new file as a box's command would make it (0644); one already there keeps its mode.
|
|
143
|
-
await writeWorkFile(hostWork, rel, typeof content === "string" ? Buffer.from(content) : content, 0o644, true);
|
|
144
|
-
return ok(undefined);
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
return err(failure(error, abs.value));
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
appendFile: unoffered("appendFile"),
|
|
151
|
-
truncateFile: unoffered("truncateFile"),
|
|
152
|
-
flushFile: unoffered("flushFile"),
|
|
153
|
-
renameFile: unoffered("renameFile"),
|
|
154
|
-
listDir: unoffered("listDir"),
|
|
155
|
-
openDirReader: unoffered("openDirReader"),
|
|
156
|
-
watch: unoffered("watch"),
|
|
157
|
-
createDir: unoffered("createDir"),
|
|
158
|
-
remove: unoffered("remove"),
|
|
159
|
-
createTempDir: unoffered("createTempDir"),
|
|
160
|
-
createTempFile: unoffered("createTempFile"),
|
|
161
|
-
exec: async () => err(new ExecutionError("shell_unavailable", "this environment runs no command: bash runs in the box")),
|
|
162
|
-
cleanup: async () => undefined,
|
|
163
|
-
};
|
|
164
|
-
}
|
package/dist/coding-tools.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
2
|
-
import { type Extension, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
|
-
import { SHELL_TOOLS } from "./background.js";
|
|
4
|
-
import { type Place } from "./place.js";
|
|
5
|
-
/** pi's coding tools on the runner, without bash, each refusal of a path outside the workspace named by the path the
|
|
6
|
-
* call gave (`asGivenRefusals`): the model reads that refusal, and the run's timeline shows it. */
|
|
7
|
-
export declare const CodingTools: Extension;
|
|
8
|
-
/** The tools that run a command in the box, never on this machine: bash, and the background tools (background.ts). */
|
|
9
|
-
export { SHELL_TOOLS };
|
|
10
|
-
/** The tools a box runs, by name: pi's four and the background tools. */
|
|
11
|
-
export declare const BOXED_TOOLS: readonly string[];
|
|
12
|
-
/** A run's coding tools and the extension a conversation selects for them. */
|
|
13
|
-
export type CodingSource = {
|
|
14
|
-
readonly extension: Extension;
|
|
15
|
-
readonly tools: readonly ToolRegistration[];
|
|
16
|
-
};
|
|
17
|
-
/** The environment a boxed tool's call runs on: the run's box's (run-box.ts). `note` writes a row on the run's timeline
|
|
18
|
-
* while the box is being had (its image still coming). `hostWork`: the run's own work/ on this machine, the source the
|
|
19
|
-
* box binds at BOX_WORK; `bound`, whether the box's provider binds it there (Docker does). */
|
|
20
|
-
export type BoxedEnv = {
|
|
21
|
-
env(context: Context, note?: (summary: string) => Promise<void>): Promise<unknown>;
|
|
22
|
-
hostWork?: string;
|
|
23
|
-
bound?(): Promise<boolean>;
|
|
24
|
-
leftEnded?(context: Context): Promise<void>; /** Once, what the model is told of a box this process made in place of an earlier one's (run-box.ts BOX_REPLACED_NOTE). */
|
|
25
|
-
replaced?(): string | undefined;
|
|
26
|
-
};
|
|
27
|
-
/** A call's answer with what `box` has to tell the model first, once (its box replaced since the run's last process),
|
|
28
|
-
* asked once the box is had: its first line, in the output an answer with no content of its own is made of, and a text
|
|
29
|
-
* part before the answer's `output` blocks. */
|
|
30
|
-
export declare function withBoxNote<T>(box: Pick<BoxedEnv, "replaced">, output: (chunk: string) => void, call: () => Promise<T>): Promise<T>;
|
|
31
|
-
/** A boxed file tool's path as the box names it, or undefined when it leaves the box's work dir (`~` and `file:`
|
|
32
|
-
* included). A path under the run's own host work dir (another harness's cwd can name one) is the same file at
|
|
33
|
-
* BOX_WORK, the bind renamed one for one; every other host path (the data root, another run) is never taken for a box
|
|
34
|
-
* path. */
|
|
35
|
-
export declare function boxPath(path: string, hostWork?: string): string | undefined;
|
|
36
|
-
/** bash's timeout, in seconds: the default when a call names none, and the most any call gets (Claude Code's own 120 s
|
|
37
|
-
* and 600 s). A command that needs longer is a background process (bash_background). */
|
|
38
|
-
export declare const BASH_DEFAULT_TIMEOUT_S = 120;
|
|
39
|
-
export declare const BASH_MAX_TIMEOUT_S = 600;
|
|
40
|
-
/** The largest image read hands the model, in bytes: 3.75 MiB, whose base64 is the 5 MiB the strictest platform a
|
|
41
|
-
* harness sends images to takes (the claude-agent adapter's CLAUDE_AGENT_MAX_IMAGE_BYTES, Amazon Bedrock's). */
|
|
42
|
-
export declare const READ_IMAGE_MAX_BYTES = 3932160;
|
|
43
|
-
/** A run's coding tools by its place: on the runner, CodingTools (no bash); in a box, pi's read, write, edit and bash,
|
|
44
|
-
* each with its arguments, output and replay as pi ships it and its environment the box's, and the background tools
|
|
45
|
-
* (background.ts), each call a command in the box. A file tool's path stays in the box's work dir; bash's command is
|
|
46
|
-
* the box's own. */
|
|
47
|
-
export declare function codingSource(place: Place, box?: BoxedEnv): CodingSource;
|
package/dist/coding-tools.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
// The coding tools a run's process registers: pi's (ArchilCodingTools, `read` declared replay-safe) without `bash`. A
|
|
2
|
-
// run gets no shell on this machine, so this is the only coding-tools extension serve installs (app.ts, tools.ts) and
|
|
3
|
-
// the only one its host tools are taken from (host-tools.ts). The tools left are pi's own, with only their execute
|
|
4
|
-
// wrapped so a refusal names the path the call gave (asGivenRefusals), and the extension keeps everything else pi's
|
|
5
|
-
// carries (its name, so a conversation selects it as before).
|
|
6
|
-
//
|
|
7
|
-
// A run whose place is a box gets codingSource's instead: pi's own read, write, edit and bash, and the background tools
|
|
8
|
-
// (background.ts), each call made on the box's environment (run-box.ts), so the shell exists only in the box. One source feeds pi's tool table (tools.ts,
|
|
9
|
-
// app.ts) and another harness's host tools (host-tools.ts).
|
|
10
|
-
//
|
|
11
|
-
// Where the box binds the run's work/ from this machine and the confinement holds directory handles (Docker on Linux),
|
|
12
|
-
// read, write and edit run on this machine instead, on the bind's source (bound-files.ts): a command in the box costs
|
|
13
|
-
// far more than a file read. bash and the background tools always run in the box, and every tool of any other box (or of
|
|
14
|
-
// any host that reaches directories by path) does too.
|
|
15
|
-
import { posix } from "node:path";
|
|
16
|
-
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
17
|
-
import { FileError } from "@earendil-works/pi-durable/env";
|
|
18
|
-
import { HOST_PHASE } from "@parcha/pi-durable-agent/timeline";
|
|
19
|
-
import { ArchilCodingTools } from "@parcha/pi-durable-disk";
|
|
20
|
-
import { BACKGROUND_TOOLS, backgroundTools, SHELL_TOOLS } from "./background.js";
|
|
21
|
-
import { boundFiles } from "./bound-files.js";
|
|
22
|
-
import { BOX_WORK } from "./place.js";
|
|
23
|
-
import { forModelBlocks } from "./result.js";
|
|
24
|
-
import { asGivenRefusals, refuseOutsideWorkspace } from "./workspace-paths.js";
|
|
25
|
-
import { writesHeld } from "./workspace.js";
|
|
26
|
-
const pis = ArchilCodingTools;
|
|
27
|
-
/** pi's coding tools on the runner, without bash, each refusal of a path outside the workspace named by the path the
|
|
28
|
-
* call gave (`asGivenRefusals`): the model reads that refusal, and the run's timeline shows it. */
|
|
29
|
-
export const CodingTools = { ...pis, tools: asGivenRefusals((pis.tools ?? []).filter((tool) => tool.name !== "bash")) };
|
|
30
|
-
/** pi's tools a box runs, by name. */
|
|
31
|
-
const PI_BOXED = ["read", "write", "edit", "bash"];
|
|
32
|
-
/** The tools that run a command in the box, never on this machine: bash, and the background tools (background.ts). */
|
|
33
|
-
export { SHELL_TOOLS };
|
|
34
|
-
/** The tools a box runs, by name: pi's four and the background tools. */
|
|
35
|
-
export const BOXED_TOOLS = [...PI_BOXED, ...BACKGROUND_TOOLS];
|
|
36
|
-
/** A call's answer with what `box` has to tell the model first, once (its box replaced since the run's last process),
|
|
37
|
-
* asked once the box is had: its first line, in the output an answer with no content of its own is made of, and a text
|
|
38
|
-
* part before the answer's `output` blocks. */
|
|
39
|
-
export async function withBoxNote(box, output, call) {
|
|
40
|
-
const note = box.replaced?.();
|
|
41
|
-
if (!note)
|
|
42
|
-
return call();
|
|
43
|
-
output(`${note}\n`);
|
|
44
|
-
const result = await call();
|
|
45
|
-
// Before the answer's model blocks, under `output` (pi's result key).
|
|
46
|
-
const fields = result;
|
|
47
|
-
return fields && Array.isArray(fields.output) ? { ...result, output: [{ type: "text", text: note }, ...fields.output] } : result;
|
|
48
|
-
}
|
|
49
|
-
/** A failed call's error with what the file environment said, where pi's message gives only its code (edit's "Error
|
|
50
|
-
* code: permission_denied."), so the model reads why and what it can do. */
|
|
51
|
-
const withCause = (error) => {
|
|
52
|
-
const cause = error?.cause;
|
|
53
|
-
return error instanceof Error && cause instanceof FileError && !error.message.includes(cause.message) ? new Error(`${error.message} ${cause.message}`, { cause }) : error;
|
|
54
|
-
};
|
|
55
|
-
/** A boxed file tool's path as the box names it, or undefined when it leaves the box's work dir (`~` and `file:`
|
|
56
|
-
* included). A path under the run's own host work dir (another harness's cwd can name one) is the same file at
|
|
57
|
-
* BOX_WORK, the bind renamed one for one; every other host path (the data root, another run) is never taken for a box
|
|
58
|
-
* path. */
|
|
59
|
-
export function boxPath(path, hostWork) {
|
|
60
|
-
if (/^(~|file:)/.test(path))
|
|
61
|
-
return undefined;
|
|
62
|
-
const named = hostWork && (path === hostWork || path.startsWith(`${hostWork}/`)) ? `${BOX_WORK}${path.slice(hostWork.length)}` : path;
|
|
63
|
-
const at = posix.resolve(BOX_WORK, named);
|
|
64
|
-
return at === BOX_WORK || at.startsWith(`${BOX_WORK}/`) ? named : undefined;
|
|
65
|
-
}
|
|
66
|
-
/** bash's timeout, in seconds: the default when a call names none, and the most any call gets (Claude Code's own 120 s
|
|
67
|
-
* and 600 s). A command that needs longer is a background process (bash_background). */
|
|
68
|
-
export const BASH_DEFAULT_TIMEOUT_S = 120;
|
|
69
|
-
export const BASH_MAX_TIMEOUT_S = 600;
|
|
70
|
-
const BASH_TIMEOUT_WORDS = `Timeout in seconds: ${BASH_DEFAULT_TIMEOUT_S} s by default, at most ${BASH_MAX_TIMEOUT_S} s; for longer work use bash_background.`;
|
|
71
|
-
const BASH_TIMEOUT_SENTENCE = ` Each command is stopped after ${BASH_DEFAULT_TIMEOUT_S} s by default, at most ${BASH_MAX_TIMEOUT_S} s; for longer work use bash_background.`;
|
|
72
|
-
const capWords = (asked) => `bash runs a command for at most ${BASH_MAX_TIMEOUT_S} s: this one ran with ${BASH_MAX_TIMEOUT_S} s, not the ${asked} s asked. For longer work use bash_background.`;
|
|
73
|
-
/** pi's bash with its timeout said and kept: the description and the timeout's own words name the default and the
|
|
74
|
-
* ceiling, a call with none runs at the default, and one asking for more runs at the ceiling and says so (a diagnostic
|
|
75
|
-
* when it ends, its error when it times out). Its schema's shape is pi's; only words change. */
|
|
76
|
-
function boundedBash(tool) {
|
|
77
|
-
const parameters = tool.parameters;
|
|
78
|
-
const timeout = parameters.properties?.timeout;
|
|
79
|
-
return {
|
|
80
|
-
...tool,
|
|
81
|
-
description: `${tool.description}${BASH_TIMEOUT_SENTENCE}`,
|
|
82
|
-
parameters: (timeout ? { ...parameters, properties: { ...parameters.properties, timeout: { ...timeout, description: BASH_TIMEOUT_WORDS } } } : parameters),
|
|
83
|
-
execute: async (args, api, context) => {
|
|
84
|
-
const asked = args?.timeout;
|
|
85
|
-
const capped = typeof asked === "number" && asked > BASH_MAX_TIMEOUT_S;
|
|
86
|
-
const timeoutS = typeof asked === "number" ? Math.min(asked, BASH_MAX_TIMEOUT_S) : BASH_DEFAULT_TIMEOUT_S;
|
|
87
|
-
try {
|
|
88
|
-
const result = await tool.execute({ ...args, timeout: timeoutS }, api, context);
|
|
89
|
-
return capped ? { ...result, diagnostics: [...(result.diagnostics ?? []), { severity: "warn", code: "timeout_capped", message: capWords(asked) }] } : result;
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
if (capped && error instanceof Error && /timed out/i.test(error.message))
|
|
93
|
-
throw new Error(`${error.message}. ${capWords(asked)}`, { cause: error });
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
/** The image types read opens, by extension; the bytes must say the same (imageTypeOf). */
|
|
100
|
-
const IMAGE_EXTENSIONS = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", gif: "image/gif", webp: "image/webp" };
|
|
101
|
-
/** The largest image read hands the model, in bytes: 3.75 MiB, whose base64 is the 5 MiB the strictest platform a
|
|
102
|
-
* harness sends images to takes (the claude-agent adapter's CLAUDE_AGENT_MAX_IMAGE_BYTES, Amazon Bedrock's). */
|
|
103
|
-
export const READ_IMAGE_MAX_BYTES = 3_932_160;
|
|
104
|
-
/** The box's side of an image read: at most `$2` bytes of `$1`, as base64 (env.exec answers in text). A file over the
|
|
105
|
-
* bound never leaves the box whole: the server holds one byte past it at most, and refuses it. */
|
|
106
|
-
const READ_IMAGE_SCRIPT = '[ -f "$1" ] && [ -r "$1" ] || exit 6; head -c "$2" -- "$1" | base64';
|
|
107
|
-
/** At most `limit` bytes of the box's `path`, read in the box, or undefined when it can't be read there. */
|
|
108
|
-
async function boxBytes(env, path, limit, context) {
|
|
109
|
-
let out = "";
|
|
110
|
-
const ran = await env.exec(["sh", "-c", READ_IMAGE_SCRIPT, "agentrun-read-image", path, String(limit)], {
|
|
111
|
-
timeout: 30,
|
|
112
|
-
onOutput: (text, _context, info) => {
|
|
113
|
-
if (info.stream === "stdout")
|
|
114
|
-
out += text;
|
|
115
|
-
},
|
|
116
|
-
}, context);
|
|
117
|
-
if (!ran.ok || ran.value.exitCode !== 0)
|
|
118
|
-
return undefined;
|
|
119
|
-
return new Uint8Array(Buffer.from(out.replace(/\s+/g, ""), "base64"));
|
|
120
|
-
}
|
|
121
|
-
const READ_IMAGE_SENTENCE = " It also opens an image (png, jpg, gif, webp) at any path in the run's box, such as one rendered to /tmp, and returns it as an image; any other file only inside work/.";
|
|
122
|
-
/** The image type the bytes say they are, or undefined: the magic bytes of PNG, JPEG, GIF and WebP. */
|
|
123
|
-
function imageTypeOf(bytes) {
|
|
124
|
-
const at = (offset, ...values) => values.every((value, index) => bytes[offset + index] === value);
|
|
125
|
-
if (at(0, 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a))
|
|
126
|
-
return "image/png";
|
|
127
|
-
if (at(0, 0xff, 0xd8, 0xff))
|
|
128
|
-
return "image/jpeg";
|
|
129
|
-
if (at(0, 0x47, 0x49, 0x46, 0x38))
|
|
130
|
-
return "image/gif";
|
|
131
|
-
if (at(0, 0x52, 0x49, 0x46, 0x46) && at(8, 0x57, 0x45, 0x42, 0x50))
|
|
132
|
-
return "image/webp";
|
|
133
|
-
return undefined;
|
|
134
|
-
}
|
|
135
|
-
/** A path read may open as an image anywhere in the box: an absolute box path (not `~`, not a URL) whose extension is an
|
|
136
|
-
* image's. */
|
|
137
|
-
const boxImagePath = (path) => path.startsWith("/") && !path.startsWith("//") && IMAGE_EXTENSIONS[posix.extname(path).slice(1).toLowerCase()] !== undefined;
|
|
138
|
-
/** A run's coding tools by its place: on the runner, CodingTools (no bash); in a box, pi's read, write, edit and bash,
|
|
139
|
-
* each with its arguments, output and replay as pi ships it and its environment the box's, and the background tools
|
|
140
|
-
* (background.ts), each call a command in the box. A file tool's path stays in the box's work dir; bash's command is
|
|
141
|
-
* the box's own. */
|
|
142
|
-
export function codingSource(place, box) {
|
|
143
|
-
if (place.mode === "runner")
|
|
144
|
-
return { extension: CodingTools, tools: CodingTools.tools ?? [] };
|
|
145
|
-
if (!box)
|
|
146
|
-
throw new Error("a run whose place is a box needs its box for its coding tools");
|
|
147
|
-
const here = box.hostWork && writesHeld() ? boundFiles(box.hostWork) : undefined;
|
|
148
|
-
const boxed = (pis.tools ?? []).filter((tool) => PI_BOXED.includes(tool.name)).map((tool) => (tool.name === "bash" ? boundedBash(tool) : tool.name === "read" ? { ...tool, description: `${tool.description}${READ_IMAGE_SENTENCE}` } : tool));
|
|
149
|
-
const tools = asGivenRefusals([...boxed, ...backgroundTools()].map((tool) => ({
|
|
150
|
-
...tool,
|
|
151
|
-
execute: async (args, api, context) => {
|
|
152
|
-
// A file tool's path in the box's words, or refused as the confined tools refuse (refuseOutsideWorkspace): named
|
|
153
|
-
// by the path the call gave and no other, the box's work dir included.
|
|
154
|
-
const path = args?.path;
|
|
155
|
-
const inBox = typeof path === "string" ? boxPath(path, box.hostWork) : undefined;
|
|
156
|
-
// read opens an image anywhere in the box (a render in /tmp): read through the box itself, never on this machine,
|
|
157
|
-
// and only when the bytes are an image's; anything else outside work/ is refused as before.
|
|
158
|
-
if (tool.name === "read" && typeof path === "string" && inBox === undefined && boxImagePath(path)) {
|
|
159
|
-
const note = (summary) => api.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind: HOST_PHASE, data: { summary } })), context);
|
|
160
|
-
const bytes = await boxBytes((await box.env(context, note)), path, READ_IMAGE_MAX_BYTES + 1, context);
|
|
161
|
-
// Said as what it is: a path the box could not read (no such file, no permission), or bytes that are no image's.
|
|
162
|
-
if (!bytes)
|
|
163
|
-
throw new Error(`${path} could not be read in the box`);
|
|
164
|
-
const mimeType = imageTypeOf(bytes);
|
|
165
|
-
if (!mimeType)
|
|
166
|
-
throw new Error(`${path} is not an image`);
|
|
167
|
-
if (bytes.byteLength > READ_IMAGE_MAX_BYTES)
|
|
168
|
-
throw new Error(`${path} is an image over read's ${READ_IMAGE_MAX_BYTES} bytes: scale it down first (for example with ffmpeg in bash).`);
|
|
169
|
-
// A line naming it, then the image: an answer is never an empty text, on pi or on another harness (host-tools.ts).
|
|
170
|
-
return forModelBlocks([{ type: "text", text: `${path}: ${mimeType}, ${bytes.byteLength} bytes` }, { type: "image", data: Buffer.from(bytes).toString("base64"), mimeType }]);
|
|
171
|
-
}
|
|
172
|
-
if (typeof path === "string" && inBox === undefined)
|
|
173
|
-
refuseOutsideWorkspace(path);
|
|
174
|
-
const given = inBox === undefined ? args : { ...args, path: inBox };
|
|
175
|
-
// read, write and edit on this machine's work/, where the box binds it; no box is made for them. A box an earlier
|
|
176
|
-
// process left has its left commands killed first, so none of them changes work/ under these tools.
|
|
177
|
-
if (here && !SHELL_TOOLS.includes(tool.name) && (await box.bound?.()) === true) {
|
|
178
|
-
await box.leftEnded?.(context);
|
|
179
|
-
return withBoxNote(box, api.output, () => tool.execute(given, { ...api, env: here }, context).catch((error) => Promise.reject(withCause(error))));
|
|
180
|
-
}
|
|
181
|
-
// A row the box's wait writes goes on the run's root, as a host's phase (pi-durable-agent's timeline shows it).
|
|
182
|
-
const note = (summary) => api.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind: HOST_PHASE, data: { summary } })), context);
|
|
183
|
-
const env = await box.env(context, note);
|
|
184
|
-
return withBoxNote(box, api.output, () => tool.execute(given, { ...api, env: env }, context));
|
|
185
|
-
},
|
|
186
|
-
})));
|
|
187
|
-
// The permission gate (allow, ask, deny) wraps this source: the one call it takes, whichever of the two lands second.
|
|
188
|
-
return { extension: { ...pis, tools }, tools };
|
|
189
|
-
}
|
package/dist/computer-adb.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** adb's env: the host bash's PATH, and a HOME and a TMPDIR (paths only). Nothing else, whatever this process holds. */
|
|
2
|
-
export declare function adbEnv(dirs?: {
|
|
3
|
-
readonly home?: string;
|
|
4
|
-
readonly tmpdir?: string;
|
|
5
|
-
}): Readonly<Record<string, string>>;
|
|
6
|
-
/** The phone provider's adb: the computer library's adbCli at `path`, spawned from adbEnv() alone. */
|
|
7
|
-
export declare function phoneAdb<A>(adbCli: (path: string, options: {
|
|
8
|
-
readonly env: Readonly<Record<string, string>>;
|
|
9
|
-
}) => A, path: string, dirs?: {
|
|
10
|
-
readonly home?: string;
|
|
11
|
-
readonly tmpdir?: string;
|
|
12
|
-
}): A;
|
package/dist/computer-adb.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// The phone provider's adb, wherever serve builds that provider (the claim's computerForClaim and Settings → Computers'
|
|
2
|
-
// test): one helper both use. The computer library spawns adb from the env it is given, so adb is given a fixed, minimal
|
|
3
|
-
// env (PATH, HOME, TMPDIR), never this process's: no vendor key and no seal key reaches adb, as none reaches the host's
|
|
4
|
-
// bash (workspace/hands.ts shellEnv).
|
|
5
|
-
import { homedir, tmpdir } from "node:os";
|
|
6
|
-
import { shellEnv } from "./workspace/hands.js";
|
|
7
|
-
/** adb's env: the host bash's PATH, and a HOME and a TMPDIR (paths only). Nothing else, whatever this process holds. */
|
|
8
|
-
export function adbEnv(dirs = {}) {
|
|
9
|
-
return Object.freeze({ PATH: shellEnv().PATH, HOME: dirs.home ?? homedir(), TMPDIR: dirs.tmpdir ?? tmpdir() });
|
|
10
|
-
}
|
|
11
|
-
/** The phone provider's adb: the computer library's adbCli at `path`, spawned from adbEnv() alone. */
|
|
12
|
-
export function phoneAdb(adbCli, path, dirs = {}) {
|
|
13
|
-
return adbCli(path, { env: adbEnv(dirs) });
|
|
14
|
-
}
|