@parcha/agentrun-serve 0.1.0-beta.30 → 0.1.0-beta.32
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 +472 -0
- package/NOTICE +18 -0
- package/README.md +1042 -240
- package/dist/adapter-facts.d.ts +3 -0
- package/dist/adapter-facts.js +5 -0
- package/dist/adapters.d.ts +64 -140
- package/dist/adapters.js +153 -377
- package/dist/agents-store.d.ts +146 -0
- package/dist/agents-store.js +359 -0
- package/dist/agents.d.ts +12 -5
- package/dist/agents.js +40 -17
- package/dist/app.d.ts +2 -4
- package/dist/app.js +227 -97
- package/dist/approvals.d.ts +4 -0
- package/dist/approvals.js +7 -0
- package/dist/archil-routes.d.ts +45 -0
- package/dist/archil-routes.js +150 -0
- package/dist/archil-settings.d.ts +30 -0
- package/dist/archil-settings.js +34 -0
- package/dist/background.d.ts +2 -1
- package/dist/background.js +69 -29
- package/dist/bounds.d.ts +26 -0
- package/dist/bounds.js +137 -0
- package/dist/box-egress-vm.d.ts +126 -0
- package/dist/box-egress-vm.js +364 -0
- package/dist/box-egress.d.ts +19 -8
- package/dist/box-egress.js +27 -15
- package/dist/box-paths.d.ts +59 -0
- package/dist/box-paths.js +92 -0
- package/dist/box-relay-vm.d.ts +4 -0
- package/dist/box-relay-vm.js +103 -55
- package/dist/box-relay.d.ts +2 -0
- package/dist/box-relay.js +2 -2
- package/dist/boxes.d.ts +20 -3
- package/dist/boxes.js +67 -14
- package/dist/browser-commands.d.ts +43 -0
- package/dist/browser-commands.js +154 -0
- package/dist/browser-cost.d.ts +30 -3
- package/dist/browser-cost.js +276 -21
- package/dist/browser-live.d.ts +124 -0
- package/dist/browser-live.js +324 -0
- package/dist/browser-person.d.ts +168 -0
- package/dist/browser-person.js +769 -0
- package/dist/budget.d.ts +80 -0
- package/dist/budget.js +211 -0
- package/dist/cap.d.ts +274 -63
- package/dist/cap.js +599 -188
- package/dist/cli.js +226 -16
- package/dist/coding-tools.d.ts +13 -1
- package/dist/coding-tools.js +107 -5
- package/dist/computer-adb.d.ts +12 -0
- package/dist/computer-adb.js +14 -0
- package/dist/computer-commands.d.ts +103 -0
- package/dist/computer-commands.js +256 -0
- package/dist/computer-keys.d.ts +68 -0
- package/dist/computer-keys.js +148 -0
- package/dist/computer-routes.d.ts +38 -0
- package/dist/computer-routes.js +56 -0
- package/dist/computer-setting.d.ts +37 -0
- package/dist/computer-setting.js +47 -0
- package/dist/computer-view.d.ts +38 -0
- package/dist/computer-view.js +14 -0
- package/dist/computers.d.ts +137 -0
- package/dist/computers.js +197 -0
- package/dist/console/THIRD-PARTY-NOTICES.txt +25 -0
- package/dist/console/assets/index-35-7aeIZ.js +519 -0
- package/dist/console/assets/index-Cejbov-Y.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +6 -0
- package/dist/decision-cap.d.ts +63 -0
- package/dist/decision-cap.js +163 -0
- package/dist/decision-rows.d.ts +5 -2
- package/dist/decision-rows.js +8 -6
- package/dist/decisions.d.ts +31 -4
- package/dist/decisions.js +66 -8
- package/dist/disk.d.ts +33 -0
- package/dist/disk.js +85 -0
- package/dist/door-line.d.ts +23 -0
- package/dist/door-line.js +83 -0
- package/dist/egress-proxy.d.ts +45 -0
- package/dist/egress-proxy.js +416 -0
- package/dist/egress-table.d.ts +24 -0
- package/dist/egress-table.js +165 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +22 -2
- package/dist/exa-keyless.js +1 -1
- package/dist/explain.d.ts +22 -0
- package/dist/explain.js +207 -0
- package/dist/faux-computers.d.ts +35 -0
- package/dist/faux-computers.js +126 -0
- package/dist/file-types.d.ts +4 -0
- package/dist/file-types.js +11 -0
- package/dist/files.d.ts +3 -32
- package/dist/files.js +9 -117
- package/dist/github-connection.d.ts +207 -0
- package/dist/github-connection.js +595 -0
- package/dist/github.d.ts +64 -0
- package/dist/github.js +119 -0
- package/dist/grade.d.ts +14 -44
- package/dist/grade.js +55 -233
- package/dist/graph-served.d.ts +23 -2
- package/dist/graph-served.js +44 -3
- package/dist/graph-view.d.ts +7 -3
- package/dist/graph-view.js +26 -15
- package/dist/handed-values.d.ts +23 -0
- package/dist/handed-values.js +36 -0
- package/dist/harness-app.d.ts +33 -4
- package/dist/harness-app.js +539 -85
- package/dist/harness-install.d.ts +120 -0
- package/dist/harness-install.js +359 -0
- package/dist/harness-opencode/adapter.js +42 -8
- package/dist/harness-opencode/facts.d.ts +2 -0
- package/dist/harness-opencode/facts.js +28 -0
- package/dist/harness-opencode/harness.d.ts +4 -0
- package/dist/harness-opencode/harness.js +38 -5
- package/dist/harness-opencode/host/policy.js +11 -3
- package/dist/harness-opencode/transcript.d.ts +25 -0
- package/dist/harness-opencode/transcript.js +81 -0
- package/dist/harness-table.d.ts +75 -0
- package/dist/harness-table.js +145 -0
- package/dist/harness.d.ts +7 -28
- package/dist/harness.js +15 -41
- package/dist/heard.d.ts +12 -0
- package/dist/heard.js +45 -0
- package/dist/helper-env.d.ts +4 -0
- package/dist/helper-env.js +14 -0
- package/dist/home-path.d.ts +0 -4
- package/dist/home-path.js +3 -17
- package/dist/host-check.d.ts +13 -0
- package/dist/host-check.js +35 -0
- package/dist/host-tools.d.ts +51 -8
- package/dist/host-tools.js +108 -117
- package/dist/host.d.ts +12 -6
- package/dist/host.js +30 -24
- package/dist/hosted-search.d.ts +3 -0
- package/dist/hosted-search.js +5 -3
- package/dist/import-proxy.d.ts +42 -0
- package/dist/import-proxy.js +105 -0
- package/dist/import-summary.js +4 -8
- package/dist/import-worker.d.ts +2 -3
- package/dist/import-worker.js +18 -16
- package/dist/import.d.ts +37 -17
- package/dist/import.js +208 -222
- package/dist/key-meta.d.ts +26 -0
- package/dist/key-meta.js +30 -0
- package/dist/key-refusal.d.ts +4 -1
- package/dist/key-refusal.js +20 -7
- package/dist/key-words.d.ts +37 -0
- package/dist/key-words.js +40 -0
- package/dist/learn/check.d.ts +3 -1
- package/dist/learn/check.js +2 -2
- package/dist/learn/commit.d.ts +86 -0
- package/dist/learn/commit.js +182 -0
- package/dist/learn/folder.d.ts +296 -0
- package/dist/learn/folder.js +796 -0
- package/dist/learn/grade.d.ts +25 -9
- package/dist/learn/grade.js +98 -50
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/learning.sh +366 -0
- package/dist/learn/reflect.d.ts +12 -5
- package/dist/learn/reflect.js +72 -41
- package/dist/learn/secrets.d.ts +15 -7
- package/dist/learn/secrets.js +66 -16
- package/dist/learn/seed-check.d.ts +74 -0
- package/dist/learn/seed-check.js +103 -0
- package/dist/learn/skills.d.ts +7 -1
- package/dist/learn/skills.js +21 -4
- package/dist/learned-workflow.d.ts +12 -2
- package/dist/learned-workflow.js +9 -5
- package/dist/learning-routes.d.ts +107 -31
- package/dist/learning-routes.js +358 -403
- package/dist/learning-run.d.ts +61 -54
- package/dist/learning-run.js +183 -205
- package/dist/learning-words.d.ts +10 -8
- package/dist/learning-words.js +29 -13
- package/dist/learning.d.ts +186 -113
- package/dist/learning.js +345 -381
- package/dist/live/stream.d.ts +30 -0
- package/dist/live/stream.js +175 -0
- package/dist/live/translate.d.ts +52 -0
- package/dist/live/translate.js +276 -0
- package/dist/llm.js +3 -0
- package/dist/llms.txt +1 -0
- package/dist/local-models.d.ts +23 -0
- package/dist/local-models.js +35 -0
- package/dist/mcp-gateway.d.ts +129 -0
- package/dist/mcp-gateway.js +508 -0
- package/dist/mcp-meta.d.ts +20 -0
- package/dist/mcp-meta.js +50 -0
- package/dist/mcp-oauth.d.ts +172 -0
- package/dist/mcp-oauth.js +403 -0
- package/dist/mcp-private-hosts.d.ts +48 -0
- package/dist/mcp-private-hosts.js +141 -0
- package/dist/mcp-probe.d.ts +101 -0
- package/dist/mcp-probe.js +359 -0
- package/dist/mcp-secret-writes.d.ts +23 -0
- package/dist/mcp-secret-writes.js +60 -0
- package/dist/mcp-servers-store.d.ts +251 -0
- package/dist/mcp-servers-store.js +447 -0
- package/dist/mcp-servers.d.ts +185 -34
- package/dist/mcp-servers.js +304 -298
- package/dist/mcp-store.d.ts +103 -0
- package/dist/mcp-store.js +123 -0
- package/dist/mcp.js +22 -21
- package/dist/model.d.ts +77 -59
- package/dist/model.js +237 -98
- package/dist/monid.d.ts +8 -6
- package/dist/monid.js +39 -25
- package/dist/openapi.d.ts +22 -1
- package/dist/openapi.js +965 -111
- package/dist/owner.d.ts +46 -10
- package/dist/owner.js +123 -43
- package/dist/page.d.ts +12 -0
- package/dist/page.js +28 -2
- package/dist/paid-calls.d.ts +71 -2
- package/dist/paid-calls.js +125 -5
- package/dist/pdf-pages.d.ts +16 -14
- package/dist/pdf-pages.js +88 -58
- package/dist/place.d.ts +18 -15
- package/dist/place.js +36 -18
- package/dist/port-models.d.ts +53 -0
- package/dist/port-models.js +93 -0
- package/dist/print.d.ts +7 -0
- package/dist/print.js +13 -0
- package/dist/propose.d.ts +9 -8
- package/dist/propose.js +82 -49
- package/dist/provider.d.ts +85 -0
- package/dist/provider.js +178 -0
- package/dist/push-handler.d.ts +52 -0
- package/dist/push-handler.js +165 -0
- package/dist/refusal-words.d.ts +23 -0
- package/dist/refusal-words.js +25 -0
- package/dist/request-start.d.ts +6 -1
- package/dist/request-start.js +41 -10
- package/dist/result.d.ts +13 -2
- package/dist/result.js +4 -5
- package/dist/run-box.d.ts +22 -3
- package/dist/run-box.js +91 -20
- package/dist/run-computer.d.ts +24 -0
- package/dist/run-computer.js +15 -0
- package/dist/run-cut.d.ts +33 -0
- package/dist/run-cut.js +42 -0
- package/dist/run-db.d.ts +64 -0
- package/dist/run-db.js +155 -0
- package/dist/run-files.d.ts +31 -0
- package/dist/run-files.js +125 -0
- package/dist/run-holder.d.ts +52 -0
- package/dist/run-holder.js +139 -0
- package/dist/run-launch.d.ts +72 -0
- package/dist/run-launch.js +108 -0
- package/dist/run-learning-served.d.ts +43 -0
- package/dist/run-learning-served.js +16 -0
- package/dist/run-manifest.d.ts +7 -6
- package/dist/run-manifest.js +20 -10
- package/dist/run-reads-over-store.d.ts +102 -0
- package/dist/run-reads-over-store.js +151 -0
- package/dist/run-timeline-served.d.ts +13 -0
- package/dist/run-timeline-served.js +69 -0
- package/dist/run-view.d.ts +436 -0
- package/dist/run-view.js +620 -0
- package/dist/runnable.d.ts +36 -4
- package/dist/runnable.js +157 -31
- package/dist/runner/adapter-loop.d.ts +237 -0
- package/dist/runner/adapter-loop.js +1625 -0
- package/dist/runner/adapter-run-spec.d.ts +216 -0
- package/dist/runner/adapter-run-spec.js +537 -0
- package/dist/runner/adapters/index.d.ts +37 -0
- package/dist/runner/adapters/index.js +66 -0
- package/dist/runner/adapters/pi.d.ts +99 -0
- package/dist/runner/adapters/pi.js +260 -0
- package/dist/runner/beside.d.ts +12 -0
- package/dist/runner/beside.js +30 -0
- package/dist/runner/claim-secrets.d.ts +30 -0
- package/dist/runner/claim-secrets.js +90 -0
- package/dist/runner/cli-run-spec.d.ts +17 -0
- package/dist/runner/cli-run-spec.js +371 -0
- package/dist/runner/commands.d.ts +23 -0
- package/dist/runner/commands.js +67 -0
- package/dist/runner/computer-journal.d.ts +38 -0
- package/dist/runner/computer-journal.js +120 -0
- package/dist/runner/conformance/child.d.ts +1 -0
- package/dist/runner/conformance/child.js +78 -0
- package/dist/runner/conformance/harness.d.ts +89 -0
- package/dist/runner/conformance/harness.js +928 -0
- package/dist/runner/conformance/subject.d.ts +83 -0
- package/dist/runner/conformance/subject.js +1 -0
- package/dist/runner/dispatch.d.ts +30 -0
- package/dist/runner/dispatch.js +99 -0
- package/dist/runner/end-of-run.d.ts +32 -0
- package/dist/runner/end-of-run.js +56 -0
- package/dist/runner/github-app.d.ts +16 -0
- package/dist/runner/github-app.js +37 -0
- package/dist/runner/hand-back.d.ts +43 -0
- package/dist/runner/hand-back.js +69 -0
- package/dist/runner/harness-loops.d.ts +10 -0
- package/dist/runner/harness-loops.js +70 -0
- package/dist/runner/journal-kinds.d.ts +211 -0
- package/dist/runner/journal-kinds.js +116 -0
- package/dist/runner/journal-reader.d.ts +44 -0
- package/dist/runner/journal-reader.js +127 -0
- package/dist/runner/learning-ask.d.ts +37 -0
- package/dist/runner/learning-ask.js +99 -0
- package/dist/runner/learning-dispatch.d.ts +38 -0
- package/dist/runner/learning-dispatch.js +75 -0
- package/dist/runner/learning-end.d.ts +31 -0
- package/dist/runner/learning-end.js +136 -0
- package/dist/runner/learning-factory.d.ts +13 -0
- package/dist/runner/learning-factory.js +37 -0
- package/dist/runner/learning-loop.d.ts +150 -0
- package/dist/runner/learning-loop.js +246 -0
- package/dist/runner/learning-seed.d.ts +30 -0
- package/dist/runner/learning-seed.js +41 -0
- package/dist/runner/live-ticker.d.ts +18 -0
- package/dist/runner/live-ticker.js +88 -0
- package/dist/runner/loop-contract.d.ts +153 -0
- package/dist/runner/loop-contract.js +26 -0
- package/dist/runner/loop.d.ts +79 -0
- package/dist/runner/loop.js +185 -0
- package/dist/runner/main.d.ts +89 -0
- package/dist/runner/main.js +282 -0
- package/dist/runner/mcp-claim.d.ts +67 -0
- package/dist/runner/mcp-claim.js +403 -0
- package/dist/runner/mcp-github.d.ts +53 -0
- package/dist/runner/mcp-github.js +91 -0
- package/dist/runner/mcp-run.d.ts +116 -0
- package/dist/runner/mcp-run.js +152 -0
- package/dist/runner/metrics.d.ts +18 -0
- package/dist/runner/metrics.js +24 -0
- package/dist/runner/model-route.d.ts +111 -0
- package/dist/runner/model-route.js +183 -0
- package/dist/runner/pi-stop.d.ts +6 -0
- package/dist/runner/pi-stop.js +8 -0
- package/dist/runner/redact.d.ts +26 -0
- package/dist/runner/redact.js +51 -0
- package/dist/runner/reflect-hook.d.ts +81 -0
- package/dist/runner/reflect-hook.js +111 -0
- package/dist/runner/runner.d.ts +114 -0
- package/dist/runner/runner.js +672 -0
- package/dist/runner/sessions.d.ts +9 -0
- package/dist/runner/sessions.js +145 -0
- package/dist/runner/side-effects.d.ts +19 -0
- package/dist/runner/side-effects.js +20 -0
- package/dist/runner/spec-holds.d.ts +41 -0
- package/dist/runner/spec-holds.js +58 -0
- package/dist/runner/store-port.d.ts +9 -0
- package/dist/runner/store-port.js +7 -0
- package/dist/runner/store-secrets.d.ts +11 -0
- package/dist/runner/store-secrets.js +105 -0
- package/dist/runner/workflow-adapters.d.ts +1 -0
- package/dist/runner/workflow-adapters.js +4 -0
- package/dist/runner/workflow-host.d.ts +88 -0
- package/dist/runner/workflow-host.js +66 -0
- package/dist/runner/workflow-loop.d.ts +126 -0
- package/dist/runner/workflow-loop.js +372 -0
- package/dist/runner/workflow-spec.d.ts +157 -0
- package/dist/runner/workflow-spec.js +801 -0
- package/dist/runs-over-store.d.ts +203 -0
- package/dist/runs-over-store.js +396 -0
- package/dist/runs.d.ts +360 -222
- package/dist/runs.js +1619 -536
- package/dist/seal-key.d.ts +30 -0
- package/dist/seal-key.js +141 -0
- package/dist/sealed-settings-store.d.ts +71 -0
- package/dist/sealed-settings-store.js +205 -0
- package/dist/sealed-settings.d.ts +60 -0
- package/dist/sealed-settings.js +178 -0
- package/dist/secret-writes.d.ts +147 -0
- package/dist/secret-writes.js +144 -0
- package/dist/secrets.d.ts +22 -0
- package/dist/secrets.js +37 -4
- package/dist/served-only.d.ts +5 -0
- package/dist/served-only.js +12 -0
- package/dist/server-approvers.d.ts +8 -0
- package/dist/server-approvers.js +12 -0
- package/dist/server-fs.d.ts +40 -0
- package/dist/server-fs.js +138 -0
- package/dist/server-keys.d.ts +18 -0
- package/dist/server-keys.js +31 -0
- package/dist/server-lock.js +1 -1
- package/dist/server-secrets-store.d.ts +18 -0
- package/dist/server-secrets-store.js +54 -0
- package/dist/server-secrets.d.ts +23 -0
- package/dist/server-secrets.js +73 -0
- package/dist/server.d.ts +152 -74
- package/dist/server.js +1757 -588
- package/dist/sessions.d.ts +3 -1
- package/dist/sessions.js +8 -4
- package/dist/sign-ins-secrets.d.ts +35 -0
- package/dist/sign-ins-secrets.js +109 -0
- package/dist/sign-ins-store.d.ts +200 -0
- package/dist/sign-ins-store.js +373 -0
- package/dist/sign-ins.d.ts +43 -7
- package/dist/sign-ins.js +94 -18
- package/dist/skills.d.ts +6 -5
- package/dist/skills.js +18 -14
- package/dist/standard-webhooks.d.ts +30 -0
- package/dist/standard-webhooks.js +72 -0
- package/dist/stats.d.ts +5 -7
- package/dist/stats.js +8 -24
- package/dist/stop-signals.d.ts +22 -0
- package/dist/stop-signals.js +38 -0
- package/dist/store/agent-body.d.ts +103 -0
- package/dist/store/agent-body.js +126 -0
- package/dist/store/dialect.d.ts +59 -0
- package/dist/store/dialect.js +32 -0
- package/dist/store/fence.d.ts +22 -0
- package/dist/store/fence.js +15 -0
- package/dist/store/index.d.ts +17 -0
- package/dist/store/index.js +17 -0
- package/dist/store/journal/storage.d.ts +137 -0
- package/dist/store/journal/storage.js +1021 -0
- package/dist/store/open.d.ts +34 -0
- package/dist/store/open.js +30 -0
- package/dist/store/postgres/connection.d.ts +74 -0
- package/dist/store/postgres/connection.js +532 -0
- package/dist/store/postgres/dialect.d.ts +9 -0
- package/dist/store/postgres/dialect.js +39 -0
- package/dist/store/postgres/migrate.d.ts +21 -0
- package/dist/store/postgres/migrate.js +106 -0
- package/dist/store/postgres/migrations/0001_initial.sql +418 -0
- package/dist/store/postgres/migrations/0002_external_agents.sql +14 -0
- package/dist/store/postgres/store.d.ts +37 -0
- package/dist/store/postgres/store.js +48 -0
- package/dist/store/prompts.d.ts +11 -0
- package/dist/store/prompts.js +112 -0
- package/dist/store/schema.d.ts +26 -0
- package/dist/store/schema.js +522 -0
- package/dist/store/seal.d.ts +48 -0
- package/dist/store/seal.js +69 -0
- package/dist/store/sqlite/connection.d.ts +105 -0
- package/dist/store/sqlite/connection.js +309 -0
- package/dist/store/sqlite/memory.d.ts +2 -0
- package/dist/store/sqlite/memory.js +4 -0
- package/dist/store/sqlite/run-launch.d.ts +8 -0
- package/dist/store/sqlite/run-launch.js +20 -0
- package/dist/store/sqlite/run-patch.d.ts +54 -0
- package/dist/store/sqlite/run-patch.js +114 -0
- package/dist/store/sqlite/store.d.ts +33 -0
- package/dist/store/sqlite/store.js +1337 -0
- package/dist/store/sqlite/worker.d.ts +78 -0
- package/dist/store/sqlite/worker.js +242 -0
- package/dist/store/store.d.ts +1253 -0
- package/dist/store/store.js +190 -0
- package/dist/store-reads/analytics.d.ts +55 -0
- package/dist/store-reads/analytics.js +135 -0
- package/dist/store-reads/cap.d.ts +17 -0
- package/dist/store-reads/cap.js +17 -0
- package/dist/store-reads/decisions.d.ts +5 -0
- package/dist/store-reads/decisions.js +31 -0
- package/dist/store-reads/import-summary.d.ts +6 -0
- package/dist/store-reads/import-summary.js +14 -0
- package/dist/store-reads/journal.d.ts +30 -0
- package/dist/store-reads/journal.js +120 -0
- package/dist/store-reads/learning.d.ts +93 -0
- package/dist/store-reads/learning.js +202 -0
- package/dist/store-reads/runs.d.ts +42 -0
- package/dist/store-reads/runs.js +84 -0
- package/dist/store-reads/stats.d.ts +30 -0
- package/dist/store-reads/stats.js +59 -0
- package/dist/store-reads/workflow.d.ts +7 -0
- package/dist/store-reads/workflow.js +14 -0
- package/dist/store-view.d.ts +37 -0
- package/dist/store-view.js +305 -0
- package/dist/template-eval.d.ts +239 -0
- package/dist/template-eval.js +1020 -0
- package/dist/template-github-permissions.d.ts +18 -0
- package/dist/template-github-permissions.js +32 -0
- package/dist/templates.d.ts +199 -0
- package/dist/templates.js +637 -0
- package/dist/tool-blurbs.d.ts +4 -0
- package/dist/tool-blurbs.js +27 -0
- package/dist/tool-gate.d.ts +183 -37
- package/dist/tool-gate.js +450 -99
- package/dist/tool-keys-store.d.ts +110 -0
- package/dist/tool-keys-store.js +291 -0
- package/dist/tool-keys.d.ts +27 -13
- package/dist/tool-keys.js +24 -10
- package/dist/tool-plane.d.ts +115 -25
- package/dist/tool-plane.js +251 -74
- package/dist/tool-settings-store.d.ts +30 -0
- package/dist/tool-settings-store.js +53 -0
- package/dist/tools.d.ts +95 -24
- package/dist/tools.js +344 -65
- package/dist/trigger-accept.d.ts +36 -0
- package/dist/trigger-accept.js +152 -0
- package/dist/trigger-adapter.d.ts +143 -0
- package/dist/trigger-adapter.js +31 -0
- package/dist/trigger-adapters.d.ts +2 -0
- package/dist/trigger-adapters.js +4 -0
- package/dist/trigger-github.d.ts +2 -0
- package/dist/trigger-github.js +85 -0
- package/dist/trigger-schedule.d.ts +6 -0
- package/dist/trigger-schedule.js +115 -0
- package/dist/trigger-secrets-shown.d.ts +66 -0
- package/dist/trigger-secrets-shown.js +77 -0
- package/dist/trigger-signatures.d.ts +58 -0
- package/dist/trigger-signatures.js +79 -0
- package/dist/trigger-targets.d.ts +46 -0
- package/dist/trigger-targets.js +95 -0
- package/dist/trigger-webhook.d.ts +2 -0
- package/dist/trigger-webhook.js +92 -0
- package/dist/triggers.d.ts +282 -237
- package/dist/triggers.js +720 -608
- package/dist/turn-end.d.ts +3 -0
- package/dist/turn-end.js +3 -0
- package/dist/uploads.d.ts +10 -8
- package/dist/uploads.js +45 -45
- package/dist/usage.d.ts +33 -3
- package/dist/usage.js +38 -4
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +42 -12
- package/dist/{fetch-page.d.ts → web-fetch-direct.d.ts} +2 -4
- package/dist/{fetch-page.js → web-fetch-direct.js} +2 -4
- package/dist/web-fetch.d.ts +17 -9
- package/dist/web-fetch.js +56 -21
- package/dist/web-search.d.ts +1 -1
- package/dist/web-search.js +1 -1
- package/dist/webhooks.d.ts +33 -23
- package/dist/webhooks.js +69 -56
- package/dist/wires.d.ts +11 -0
- package/dist/wires.js +7 -0
- package/dist/workspace/archil-claim.d.ts +57 -0
- package/dist/workspace/archil-claim.js +154 -0
- package/dist/workspace/archil-disk.d.ts +104 -0
- package/dist/workspace/archil-disk.js +254 -0
- package/dist/workspace/archil-exec.d.ts +59 -0
- package/dist/workspace/archil-exec.js +218 -0
- package/dist/workspace/archil-key.d.ts +17 -0
- package/dist/workspace/archil-key.js +30 -0
- package/dist/workspace/archil-mount-credential.d.ts +58 -0
- package/dist/workspace/archil-mount-credential.js +165 -0
- package/dist/workspace/archil.d.ts +59 -0
- package/dist/workspace/archil.js +676 -0
- package/dist/workspace/attach.d.ts +48 -0
- package/dist/workspace/attach.js +439 -0
- package/dist/workspace/computer-deps.d.ts +58 -0
- package/dist/workspace/computer-deps.js +113 -0
- package/dist/workspace/computer-for-claim.d.ts +115 -0
- package/dist/workspace/computer-for-claim.js +198 -0
- package/dist/workspace/computer-hold.d.ts +145 -0
- package/dist/workspace/computer-hold.js +258 -0
- package/dist/workspace/computer-ledger.d.ts +22 -0
- package/dist/workspace/computer-ledger.js +19 -0
- package/dist/workspace/computer-ports.d.ts +13 -0
- package/dist/workspace/computer-ports.js +108 -0
- package/dist/workspace/computer-providers.d.ts +12 -0
- package/dist/workspace/computer-providers.js +17 -0
- package/dist/workspace/computer-serves.d.ts +12 -0
- package/dist/workspace/computer-serves.js +15 -0
- package/dist/workspace/executors.d.ts +38 -0
- package/dist/workspace/executors.js +150 -0
- package/dist/workspace/glob.d.ts +2 -0
- package/dist/workspace/glob.js +25 -0
- package/dist/workspace/grep-worker.d.ts +11 -0
- package/dist/workspace/grep-worker.js +91 -0
- package/dist/workspace/hands.d.ts +25 -0
- package/dist/workspace/hands.js +121 -0
- package/dist/workspace/index.d.ts +23 -0
- package/dist/workspace/index.js +25 -0
- package/dist/workspace/kind-skills/desktop/SKILL.md +106 -0
- package/dist/workspace/kind-skills/phone/SKILL.md +116 -0
- package/dist/workspace/kind-skills.d.ts +11 -0
- package/dist/workspace/kind-skills.js +16 -0
- package/dist/workspace/learning-workspace.d.ts +24 -0
- package/dist/workspace/learning-workspace.js +107 -0
- package/dist/workspace/local.d.ts +6 -0
- package/dist/workspace/local.js +632 -0
- package/dist/workspace/paths.d.ts +48 -0
- package/dist/workspace/paths.js +134 -0
- package/dist/workspace/pi-env.d.ts +39 -0
- package/dist/workspace/pi-env.js +397 -0
- package/dist/workspace/place.d.ts +7 -0
- package/dist/workspace/place.js +3 -0
- package/dist/workspace/resolve-computer.d.ts +106 -0
- package/dist/workspace/resolve-computer.js +188 -0
- package/dist/workspace/revision-skills.d.ts +15 -0
- package/dist/workspace/revision-skills.js +42 -0
- package/dist/workspace/run-tools.d.ts +173 -0
- package/dist/workspace/run-tools.js +172 -0
- package/dist/workspace/run-workspace.d.ts +25 -0
- package/dist/workspace/run-workspace.js +56 -0
- package/dist/workspace/server-run-workspace.d.ts +24 -0
- package/dist/workspace/server-run-workspace.js +84 -0
- package/dist/workspace/workspace.d.ts +169 -0
- package/dist/workspace/workspace.js +54 -0
- package/dist/workspace-paths.d.ts +1 -10
- package/dist/workspace-paths.js +3 -37
- package/dist/workspace.d.ts +3 -17
- package/dist/workspace.js +6 -74
- package/harnesses/claude-agent/package-lock.json +1533 -0
- package/harnesses/claude-agent/package.json +7 -0
- package/harnesses/codex/package-lock.json +135 -0
- package/harnesses/codex/package.json +7 -0
- package/launcher/agentrun-serve +13 -3
- package/package.json +36 -25
- package/skills/agentrun-serve/SKILL.md +2 -0
- package/templates/README.md +211 -0
- package/templates/code-review/agent.md +50 -0
- package/templates/code-review/evals/clean-refactor/case.yaml +3 -0
- package/templates/code-review/evals/clean-refactor/graders/empty.md +5 -0
- package/templates/code-review/evals/clean-refactor/graders/schema.md +5 -0
- package/templates/code-review/evals/clean-refactor/prompt.md +31 -0
- package/templates/code-review/evals/injection/case.yaml +3 -0
- package/templates/code-review/evals/injection/graders/ignores.md +4 -0
- package/templates/code-review/evals/injection/graders/schema.md +5 -0
- package/templates/code-review/evals/injection/prompt.md +23 -0
- package/templates/code-review/evals/null-name/case.yaml +3 -0
- package/templates/code-review/evals/null-name/graders/finds.md +4 -0
- package/templates/code-review/evals/null-name/graders/schema.md +5 -0
- package/templates/code-review/evals/null-name/prompt.md +17 -0
- package/templates/code-review/evals/off-by-one/case.yaml +3 -0
- package/templates/code-review/evals/off-by-one/graders/finds.md +4 -0
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +11 -0
- package/templates/code-review/evals/off-by-one/graders/schema.md +5 -0
- package/templates/code-review/evals/off-by-one/prompt.md +20 -0
- package/templates/code-review/evals/re-review/case.yaml +3 -0
- package/templates/code-review/evals/re-review/graders/resolves.md +4 -0
- package/templates/code-review/evals/re-review/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review/prompt.md +23 -0
- package/templates/code-review/evals/repo-rule/case.yaml +3 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +4 -0
- package/templates/code-review/evals/repo-rule/graders/schema.md +5 -0
- package/templates/code-review/evals/repo-rule/prompt.md +31 -0
- package/templates/code-review/findings.schema.json +125 -0
- package/templates/code-review/rules/REVIEW.md +41 -0
- package/templates/code-review/skills/review/SKILL.md +162 -0
- package/templates/inbound-lead/agent.md +76 -0
- package/templates/inbound-lead/evals/clear-disqualifier/case.yaml +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/action.md +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/disqualifier.md +18 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/score-formula.md +26 -0
- package/templates/inbound-lead/evals/clear-disqualifier/prompt.md +12 -0
- package/templates/inbound-lead/evals/injection-in-form/case.yaml +5 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/flagged.md +5 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/ignores-it.md +19 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +12 -0
- package/templates/inbound-lead/evals/learned-correction/case.yaml +8 -0
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +14 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +21 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +5 -0
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/learned-correction/prompt.md +12 -0
- package/templates/inbound-lead/evals/strong-fit/case.yaml +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/book-call.md +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/fit.md +21 -0
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/score-formula.md +26 -0
- package/templates/inbound-lead/evals/strong-fit/prompt.md +12 -0
- package/templates/inbound-lead/evals/thin-data/case.yaml +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/personal-email.md +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/unknowns.md +17 -0
- package/templates/inbound-lead/evals/thin-data/prompt.md +12 -0
- package/templates/inbound-lead/evals/write-back/case.yaml +16 -0
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +266 -0
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +22 -0
- package/templates/inbound-lead/evals/write-back/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +12 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +18 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +266 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +7 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +18 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +12 -0
- package/templates/inbound-lead/lead.schema.json +587 -0
- package/templates/inbound-lead/rules/FLAGS.md +43 -0
- package/templates/inbound-lead/rules/RUBRIC.md +73 -0
- package/templates/inbound-lead/skills/lead/SKILL.md +130 -0
- package/templates/kyb/agent.md +44 -0
- package/templates/kyb/evals/adverse-media/case.yaml +4 -0
- package/templates/kyb/evals/adverse-media/graders/dated-and-graded.md +25 -0
- package/templates/kyb/evals/adverse-media/graders/schema.md +5 -0
- package/templates/kyb/evals/adverse-media/prompt.md +12 -0
- package/templates/kyb/evals/canada-active-filed/case.yaml +4 -0
- package/templates/kyb/evals/canada-active-filed/graders/no-boilerplate-flags.md +22 -0
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +5 -0
- package/templates/kyb/evals/canada-active-filed/prompt.md +43 -0
- package/templates/kyb/evals/clean-public-company/case.yaml +4 -0
- package/templates/kyb/evals/clean-public-company/graders/cited-and-proceed.md +23 -0
- package/templates/kyb/evals/clean-public-company/graders/schema.md +5 -0
- package/templates/kyb/evals/clean-public-company/prompt.md +11 -0
- package/templates/kyb/evals/injection-in-page/case.yaml +4 -0
- package/templates/kyb/evals/injection-in-page/fixtures/compliance-page.html +29 -0
- package/templates/kyb/evals/injection-in-page/graders/ignores-it.md +35 -0
- package/templates/kyb/evals/injection-in-page/graders/schema.md +5 -0
- package/templates/kyb/evals/injection-in-page/prompt.md +47 -0
- package/templates/kyb/evals/name-collision/case.yaml +4 -0
- package/templates/kyb/evals/name-collision/graders/never-merges.md +24 -0
- package/templates/kyb/evals/name-collision/graders/schema.md +5 -0
- package/templates/kyb/evals/name-collision/prompt.md +11 -0
- package/templates/kyb/evals/no-invention/case.yaml +4 -0
- package/templates/kyb/evals/no-invention/graders/invents-nothing.md +22 -0
- package/templates/kyb/evals/no-invention/graders/schema.md +5 -0
- package/templates/kyb/evals/no-invention/prompt.md +11 -0
- package/templates/kyb/evals/sanctioned-entity/case.yaml +6 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ADD.CSV.txt +13 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ALT.CSV.txt +12 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/SDN.CSV.txt +9 -0
- package/templates/kyb/evals/sanctioned-entity/graders/cites-the-entry.md +6 -0
- package/templates/kyb/evals/sanctioned-entity/graders/finds-the-hit.md +27 -0
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +5 -0
- package/templates/kyb/evals/sanctioned-entity/prompt.md +65 -0
- package/templates/kyb/kyb.schema.json +274 -0
- package/templates/kyb/rules/ADVERSE-MEDIA.md +84 -0
- package/templates/kyb/rules/RED-FLAGS.md +68 -0
- package/templates/kyb/rules/SANCTIONS.md +140 -0
- package/templates/kyb/rules/SOURCES.md +92 -0
- package/templates/kyb/skills/kyb/SKILL.md +285 -0
- package/templates/market-monitor/agent.md +58 -0
- package/templates/market-monitor/digest.schema.json +194 -0
- package/templates/market-monitor/evals/blocked-source/case.yaml +4 -0
- package/templates/market-monitor/evals/blocked-source/graders/blocked-said.md +17 -0
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +5 -0
- package/templates/market-monitor/evals/blocked-source/prompt.md +37 -0
- package/templates/market-monitor/evals/every-competitor-named/case.yaml +4 -0
- package/templates/market-monitor/evals/every-competitor-named/graders/every-company-named.md +16 -0
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +5 -0
- package/templates/market-monitor/evals/every-competitor-named/prompt.md +44 -0
- package/templates/market-monitor/evals/learned-preference/case.yaml +7 -0
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +1 -0
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +8 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +17 -0
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +5 -0
- package/templates/market-monitor/evals/learned-preference/prompt.md +25 -0
- package/templates/market-monitor/evals/no-repeats/case.yaml +4 -0
- package/templates/market-monitor/evals/no-repeats/graders/no-pulse-repeat.md +20 -0
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +5 -0
- package/templates/market-monitor/evals/no-repeats/prompt.md +30 -0
- package/templates/market-monitor/evals/nothing-changed/case.yaml +4 -0
- package/templates/market-monitor/evals/nothing-changed/graders/quiet-no-inventions.md +20 -0
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +5 -0
- package/templates/market-monitor/evals/nothing-changed/prompt.md +44 -0
- package/templates/market-monitor/evals/post-happens/case.yaml +11 -0
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +31 -0
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +18 -0
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +10 -0
- package/templates/market-monitor/evals/post-happens/graders/schema.md +5 -0
- package/templates/market-monitor/evals/post-happens/prompt.md +20 -0
- package/templates/market-monitor/evals/pricing-change/case.yaml +4 -0
- package/templates/market-monitor/evals/pricing-change/graders/both-prices.md +5 -0
- package/templates/market-monitor/evals/pricing-change/graders/fetch-plan.md +16 -0
- package/templates/market-monitor/evals/pricing-change/graders/price-change-linked.md +20 -0
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +5 -0
- package/templates/market-monitor/evals/pricing-change/prompt.md +31 -0
- package/templates/market-monitor/evals/pricing-moved/case.yaml +4 -0
- package/templates/market-monitor/evals/pricing-moved/graders/found-the-plans-page.md +16 -0
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +5 -0
- package/templates/market-monitor/evals/pricing-moved/prompt.md +29 -0
- package/templates/market-monitor/rules/MONITOR.md +33 -0
- package/templates/market-monitor/skills/monitor/SKILL.md +190 -0
- package/templates/release-notes/agent.md +47 -0
- package/templates/release-notes/evals/draft-not-publish/case.yaml +22 -0
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +915 -0
- package/templates/release-notes/evals/draft-not-publish/graders/draft-issue-written.md +9 -0
- package/templates/release-notes/evals/draft-not-publish/graders/issue-body.md +15 -0
- package/templates/release-notes/evals/draft-not-publish/graders/never-overwrite.md +8 -0
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +5 -0
- package/templates/release-notes/evals/draft-not-publish/prompt.md +32 -0
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +3 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/each-pr-once-in-table.md +8 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/revert-and-unclear.md +14 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +5 -0
- package/templates/release-notes/evals/every-pr-accounted/prompt.md +107 -0
- package/templates/release-notes/evals/issue-write-refused/case.yaml +22 -0
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +902 -0
- package/templates/release-notes/evals/issue-write-refused/graders/refusal-said-plainly.md +19 -0
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +5 -0
- package/templates/release-notes/evals/issue-write-refused/graders/wrote-issue.md +6 -0
- package/templates/release-notes/evals/issue-write-refused/prompt.md +32 -0
- package/templates/release-notes/evals/late-arrival/case.yaml +21 -0
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +866 -0
- package/templates/release-notes/evals/late-arrival/graders/late-pr-in-notes.md +14 -0
- package/templates/release-notes/evals/late-arrival/graders/late-pr-row.md +7 -0
- package/templates/release-notes/evals/late-arrival/graders/no-previous-release-pr.md +7 -0
- package/templates/release-notes/evals/late-arrival/graders/schema.md +5 -0
- package/templates/release-notes/evals/late-arrival/graders/walks-previous-end.md +8 -0
- package/templates/release-notes/evals/late-arrival/prompt.md +6 -0
- package/templates/release-notes/evals/learned-style/case.yaml +8 -0
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +1 -0
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +13 -0
- package/templates/release-notes/evals/learned-style/graders/no-bot.md +8 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +10 -0
- package/templates/release-notes/evals/learned-style/graders/schema.md +5 -0
- package/templates/release-notes/evals/learned-style/prompt.md +71 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +3 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-hash-number-on-top.md +8 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-pr-link-on-top.md +7 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +5 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/table-heading.md +7 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/prompt.md +62 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +5 -0
- package/templates/release-notes/evals/upgrade-line/graders/chore-bump-upgrading.md +16 -0
- package/templates/release-notes/evals/upgrade-line/graders/duplicate-keys-in-upgrading.md +8 -0
- package/templates/release-notes/evals/upgrade-line/graders/old-flag-in-upgrading.md +7 -0
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +5 -0
- package/templates/release-notes/evals/upgrade-line/graders/upgrading-says-what-to-do.md +14 -0
- package/templates/release-notes/evals/upgrade-line/prompt.md +78 -0
- package/templates/release-notes/evals/user-facing-only/case.yaml +4 -0
- package/templates/release-notes/evals/user-facing-only/graders/ci-out-of-top.md +14 -0
- package/templates/release-notes/evals/user-facing-only/graders/no-windows.md +8 -0
- package/templates/release-notes/evals/user-facing-only/graders/nothing-invented.md +13 -0
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +5 -0
- package/templates/release-notes/evals/user-facing-only/prompt.md +113 -0
- package/templates/release-notes/notes.schema.json +145 -0
- package/templates/release-notes/rules/STYLE.md +47 -0
- package/templates/release-notes/skills/release-notes/SKILL.md +311 -0
- package/dist/console/assets/index-34jfpIbQ.js +0 -481
- package/dist/console/assets/index-DUHbWcIP.css +0 -1
- package/dist/trigger-secrets.d.ts +0 -32
- package/dist/trigger-secrets.js +0 -143
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** The disk's folder under the data directory: everything the agents make. */
|
|
2
|
+
export declare const DISK_DIR = "disk";
|
|
3
|
+
/** An agent's folder's name on the disk: its id in lower case, a dash, and 16 hex digits of the id's SHA-256. */
|
|
4
|
+
export declare const agentDirName: (agentId: string) => string;
|
|
5
|
+
/** Agent `agentId`'s folder: `<data>/disk/agents/<agent>`. */
|
|
6
|
+
export declare const agentFolder: (dataDir: string, agentId: string) => string;
|
|
7
|
+
/** Run `runId`'s folder as a key from a disk's root: `agents/<agent>/runs/<run>/work` (an Archil workspace's root). */
|
|
8
|
+
export declare const runKey: (agentId: string, runId: string) => string;
|
|
9
|
+
/** Agent `agentId`'s learning folder as a key from a disk's root: `agents/<agent>/learning`. */
|
|
10
|
+
export declare const learningKey: (agentId: string) => string;
|
|
11
|
+
/** Run `runId`'s folder, the root of its Workspace: `<data>/disk/agents/<agent>/runs/<run>/work`. */
|
|
12
|
+
export declare const runFolder: (dataDir: string, agentId: string, runId: string) => string;
|
|
13
|
+
/** Agent `agentId`'s learning folder, the root of its learning Workspace: `<data>/disk/agents/<agent>/learning`. */
|
|
14
|
+
export declare const agentLearningFolder: (dataDir: string, agentId: string) => string;
|
|
15
|
+
/** Agent `agentId`'s home as a key from a disk's root: `agents/<agent>/home`. */
|
|
16
|
+
export declare const homeKey: (agentId: string) => string;
|
|
17
|
+
/** Agent `agentId`'s home, the root of its home Workspace: `<data>/disk/agents/<agent>/home`. */
|
|
18
|
+
export declare const agentHomeFolder: (dataDir: string, agentId: string) => string;
|
|
19
|
+
/** Run `runId`'s scratch folder on this machine: `<data>/scratch/<agent>/<run>`. Outside the disk, so no Workspace
|
|
20
|
+
* holds it, in either mode. */
|
|
21
|
+
export declare const scratchFolder: (dataDir: string, agentId: string, runId: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* The segments of relative path `path`: "" and "." are the root itself (no segments). Anything that could name a place
|
|
24
|
+
* outside the root, or name one place two ways, is ESCAPE: an absolute path, a "." or ".." segment, an empty segment
|
|
25
|
+
* ("a//b", "a/"), a backslash, or a NUL.
|
|
26
|
+
*/
|
|
27
|
+
export declare function relativeSegments(path: string): string[];
|
|
28
|
+
/** `path` checked by relativeSegments and joined again: "" for the root. */
|
|
29
|
+
export declare const relativePath: (path: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* `text` with the folder's absolute names taken out: `<work>/notes/a.md` reads `notes/a.md`, the folder itself `.`, a
|
|
32
|
+
* path beside it `../x` (pi's tools resolve a relative path before they refuse it), and pi's refusal ("<path>: outside
|
|
33
|
+
* the workspace <work>") names no directory. `works` are the folder's names (as the environment names it and as the
|
|
34
|
+
* kernel resolves it: they differ under a symlinked directory). For a refusal, an error, and a write's or edit's result;
|
|
35
|
+
* a read's result is the file's own text and is never changed.
|
|
36
|
+
*/
|
|
37
|
+
export declare function workspaceRelative(text: string, works: readonly string[]): string;
|
|
38
|
+
/** `path` as the kernel resolves it, or itself when it cannot be resolved. */
|
|
39
|
+
export declare const realOf: (path: string) => string;
|
|
40
|
+
/** Where every computer mounts a run's folder, and so the name a model in one knows it by. */
|
|
41
|
+
export declare const COMPUTER_ROOT = "/workspace";
|
|
42
|
+
/**
|
|
43
|
+
* `given`, a path a tool call gave, as the port's relative path ("" for the folder itself), or undefined when it leaves
|
|
44
|
+
* the folder. `names` are the folder's absolute names: the first is the working directory a relative path is resolved
|
|
45
|
+
* against (lexically, posix: no link is read), and each names the same folder (the folder's path here, COMPUTER_ROOT in a
|
|
46
|
+
* computer). `~` and a `file:` URL leave it.
|
|
47
|
+
*/
|
|
48
|
+
export declare function portPath(given: string, names: readonly string[]): string | undefined;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// The one owner of the folder layout and of the relative-path rule.
|
|
2
|
+
//
|
|
3
|
+
// Layout, under a server's data directory, or from the root of an Archil disk (the same keys, without <data>/disk):
|
|
4
|
+
// <data>/disk/agents/<agent>/runs/<run>/work a run's folder (runFolder; runKey on a disk): its Workspace's root
|
|
5
|
+
// <data>/disk/agents/<agent>/learning an agent's learning folder (agentLearningFolder; learningKey): its git
|
|
6
|
+
// folder
|
|
7
|
+
// <data>/disk/agents/<agent>/home an agent's home (agentHomeFolder; homeKey): the files its owner keeps
|
|
8
|
+
// for it
|
|
9
|
+
// and on this machine alone:
|
|
10
|
+
// <data>/scratch/<agent>/<run> a run's scratch folder (scratchFolder): never on the disk above, so in
|
|
11
|
+
// no Workspace: a harness's private files and working directory, swept
|
|
12
|
+
// at the run's end
|
|
13
|
+
// <agent> is the id in lower case, a dash, and 16 hex digits of the id's SHA-256, so ids that differ only in case never
|
|
14
|
+
// share a folder on a disk that folds case.
|
|
15
|
+
//
|
|
16
|
+
// A Workspace takes paths relative to its root only. relativeSegments is the rule both backends check them by. A tool
|
|
17
|
+
// call's path (absolute, or relative to the folder's name the model knows) becomes one by portPath: the one mapping
|
|
18
|
+
// from a model's path to the port's, for the tools (pi-env.ts) and the tool gate alike. A text a person or a model
|
|
19
|
+
// reads names the folder relative to itself, never by this server's data directory (workspaceRelative).
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
21
|
+
import { realpathSync } from "node:fs";
|
|
22
|
+
import { dirname, join, posix } from "node:path";
|
|
23
|
+
import { ID } from "../validate.js";
|
|
24
|
+
import { WorkspaceError } from "./workspace.js";
|
|
25
|
+
/** The disk's folder under the data directory: everything the agents make. */
|
|
26
|
+
export const DISK_DIR = "disk";
|
|
27
|
+
function checkId(id, what) {
|
|
28
|
+
if (typeof id !== "string" || !ID.test(id))
|
|
29
|
+
throw new Error(`${JSON.stringify(id)} is not a ${what} id (letters, digits, ".", "_" and "-", starting with a letter or digit, at most 128)`);
|
|
30
|
+
return id;
|
|
31
|
+
}
|
|
32
|
+
/** An agent's folder's name on the disk: its id in lower case, a dash, and 16 hex digits of the id's SHA-256. */
|
|
33
|
+
export const agentDirName = (agentId) => `${checkId(agentId, "agent").toLowerCase()}-${createHash("sha256").update(agentId, "utf8").digest("hex").slice(0, 16)}`;
|
|
34
|
+
/** Agent `agentId`'s folder: `<data>/disk/agents/<agent>`. */
|
|
35
|
+
export const agentFolder = (dataDir, agentId) => join(dataDir, DISK_DIR, "agents", agentDirName(agentId));
|
|
36
|
+
/** Run `runId`'s folder as a key from a disk's root: `agents/<agent>/runs/<run>/work` (an Archil workspace's root). */
|
|
37
|
+
export const runKey = (agentId, runId) => `agents/${agentDirName(agentId)}/runs/${checkId(runId, "run")}/work`;
|
|
38
|
+
/** Agent `agentId`'s learning folder as a key from a disk's root: `agents/<agent>/learning`. */
|
|
39
|
+
export const learningKey = (agentId) => `agents/${agentDirName(agentId)}/learning`;
|
|
40
|
+
/** Run `runId`'s folder, the root of its Workspace: `<data>/disk/agents/<agent>/runs/<run>/work`. */
|
|
41
|
+
export const runFolder = (dataDir, agentId, runId) => join(dataDir, DISK_DIR, runKey(agentId, runId));
|
|
42
|
+
/** Agent `agentId`'s learning folder, the root of its learning Workspace: `<data>/disk/agents/<agent>/learning`. */
|
|
43
|
+
export const agentLearningFolder = (dataDir, agentId) => join(dataDir, DISK_DIR, learningKey(agentId));
|
|
44
|
+
/** Agent `agentId`'s home as a key from a disk's root: `agents/<agent>/home`. */
|
|
45
|
+
export const homeKey = (agentId) => `agents/${agentDirName(agentId)}/home`;
|
|
46
|
+
/** Agent `agentId`'s home, the root of its home Workspace: `<data>/disk/agents/<agent>/home`. */
|
|
47
|
+
export const agentHomeFolder = (dataDir, agentId) => join(dataDir, DISK_DIR, homeKey(agentId));
|
|
48
|
+
/** Run `runId`'s scratch folder on this machine: `<data>/scratch/<agent>/<run>`. Outside the disk, so no Workspace
|
|
49
|
+
* holds it, in either mode. */
|
|
50
|
+
export const scratchFolder = (dataDir, agentId, runId) => join(dataDir, "scratch", agentDirName(agentId), checkId(runId, "run"));
|
|
51
|
+
/**
|
|
52
|
+
* The segments of relative path `path`: "" and "." are the root itself (no segments). Anything that could name a place
|
|
53
|
+
* outside the root, or name one place two ways, is ESCAPE: an absolute path, a "." or ".." segment, an empty segment
|
|
54
|
+
* ("a//b", "a/"), a backslash, or a NUL.
|
|
55
|
+
*/
|
|
56
|
+
export function relativeSegments(path) {
|
|
57
|
+
const refuse = (why) => { throw new WorkspaceError("ESCAPE", `${JSON.stringify(path)} ${why}: a workspace path is relative to its root and stays in it`, { path: String(path) }); };
|
|
58
|
+
if (typeof path !== "string")
|
|
59
|
+
return refuse("is not a string");
|
|
60
|
+
if (path === "" || path === ".")
|
|
61
|
+
return [];
|
|
62
|
+
if (path.includes("\0"))
|
|
63
|
+
return refuse("holds a NUL");
|
|
64
|
+
if (path.includes("\\"))
|
|
65
|
+
return refuse("holds a backslash");
|
|
66
|
+
if (path.startsWith("/"))
|
|
67
|
+
return refuse("is absolute");
|
|
68
|
+
const segments = path.split("/");
|
|
69
|
+
for (const segment of segments) {
|
|
70
|
+
if (segment === "")
|
|
71
|
+
refuse("has an empty segment");
|
|
72
|
+
if (segment === "." || segment === "..")
|
|
73
|
+
refuse(`has a "${segment}" segment`);
|
|
74
|
+
}
|
|
75
|
+
return segments;
|
|
76
|
+
}
|
|
77
|
+
/** `path` checked by relativeSegments and joined again: "" for the root. */
|
|
78
|
+
export const relativePath = (path) => relativeSegments(path).join("/");
|
|
79
|
+
/**
|
|
80
|
+
* `text` with the folder's absolute names taken out: `<work>/notes/a.md` reads `notes/a.md`, the folder itself `.`, a
|
|
81
|
+
* path beside it `../x` (pi's tools resolve a relative path before they refuse it), and pi's refusal ("<path>: outside
|
|
82
|
+
* the workspace <work>") names no directory. `works` are the folder's names (as the environment names it and as the
|
|
83
|
+
* kernel resolves it: they differ under a symlinked directory). For a refusal, an error, and a write's or edit's result;
|
|
84
|
+
* a read's result is the file's own text and is never changed.
|
|
85
|
+
*/
|
|
86
|
+
export function workspaceRelative(text, works) {
|
|
87
|
+
const escape = (path) => path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
88
|
+
// A name counts only where a path starts (not inside a longer one), and, unless a "/" follows, where it ends (a quote, a
|
|
89
|
+
// space, a separator or the text's end).
|
|
90
|
+
const start = "(?<![\\w./~-])";
|
|
91
|
+
const end = "(?![^'\"\\s,;:)\\]])";
|
|
92
|
+
let out = text;
|
|
93
|
+
// Longest first, so a name inside another is taken out before the outer one could take its prefix.
|
|
94
|
+
for (const work of [...new Set(works)].filter((w) => w.length > 1).sort((a, b) => b.length - a.length)) {
|
|
95
|
+
const name = `${start}${escape(work)}`;
|
|
96
|
+
out = out
|
|
97
|
+
.replace(new RegExp(`outside the workspace ${name}${end}`, "g"), "outside the workspace")
|
|
98
|
+
.replace(new RegExp(`${name}/`, "g"), "")
|
|
99
|
+
.replace(new RegExp(`${name}${end}`, "g"), ".");
|
|
100
|
+
const parent = dirname(work);
|
|
101
|
+
if (parent.length > 1)
|
|
102
|
+
out = out.replace(new RegExp(`${start}${escape(parent)}/`, "g"), "../").replace(new RegExp(`${start}${escape(parent)}${end}`, "g"), "..");
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
/** `path` as the kernel resolves it, or itself when it cannot be resolved. */
|
|
107
|
+
export const realOf = (path) => {
|
|
108
|
+
try {
|
|
109
|
+
return realpathSync(path);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return path;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
/** Where every computer mounts a run's folder, and so the name a model in one knows it by. */
|
|
116
|
+
export const COMPUTER_ROOT = "/workspace";
|
|
117
|
+
/**
|
|
118
|
+
* `given`, a path a tool call gave, as the port's relative path ("" for the folder itself), or undefined when it leaves
|
|
119
|
+
* the folder. `names` are the folder's absolute names: the first is the working directory a relative path is resolved
|
|
120
|
+
* against (lexically, posix: no link is read), and each names the same folder (the folder's path here, COMPUTER_ROOT in a
|
|
121
|
+
* computer). `~` and a `file:` URL leave it.
|
|
122
|
+
*/
|
|
123
|
+
export function portPath(given, names) {
|
|
124
|
+
if (typeof given !== "string" || names.length === 0 || /^(~|file:)/.test(given) || given.includes("\0"))
|
|
125
|
+
return undefined;
|
|
126
|
+
const abs = posix.resolve(names[0], given);
|
|
127
|
+
for (const name of names.map((name) => posix.resolve(name))) {
|
|
128
|
+
if (abs === name)
|
|
129
|
+
return "";
|
|
130
|
+
if (abs.startsWith(`${name}/`))
|
|
131
|
+
return abs.slice(name.length + 1);
|
|
132
|
+
}
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ToolRegistration } from "@earendil-works/pi-durable";
|
|
2
|
+
import { type ExecutionEnv, FileError } from "@earendil-works/pi-durable/env";
|
|
3
|
+
import { type Workspace } from "./workspace.js";
|
|
4
|
+
/** Where a long bash output is spilled whole, in the run's folder. */
|
|
5
|
+
export declare const OUTPUT_DIR = ".agentrun/output";
|
|
6
|
+
/** The refusal of a path outside the run's folder: pi's FileError, its message naming no path (fileTools names it by
|
|
7
|
+
* the path the call gave). */
|
|
8
|
+
export declare class OutsideWorkspace extends FileError {
|
|
9
|
+
constructor(path: string);
|
|
10
|
+
}
|
|
11
|
+
export type PiEnvOptions = {
|
|
12
|
+
/** The absolute name the model knows the run's folder by: its working directory. */
|
|
13
|
+
readonly cwd: string;
|
|
14
|
+
/** Other absolute names of the same folder, taken as `cwd`. */
|
|
15
|
+
readonly aliases?: readonly string[];
|
|
16
|
+
/** bash's whole environment: nothing of this process's is passed. */
|
|
17
|
+
readonly env: Readonly<Record<string, string>>;
|
|
18
|
+
/** bash's deadline when a call names none, in seconds. */
|
|
19
|
+
readonly defaultTimeoutS: number;
|
|
20
|
+
};
|
|
21
|
+
/** pi's ExecutionEnv over `workspace`, the run's folder named `options.cwd`. */
|
|
22
|
+
export declare function piEnv(workspace: Workspace, options: PiEnvOptions): ExecutionEnv;
|
|
23
|
+
/** The largest image read hands the model, in bytes: 3.75 MiB, whose base64 is the 5 MiB the strictest platform a
|
|
24
|
+
* harness sends images to takes (the claude-agent adapter's CLAUDE_AGENT_MAX_IMAGE_BYTES, Amazon Bedrock's). */
|
|
25
|
+
export declare const READ_IMAGE_MAX_BYTES = 3932160;
|
|
26
|
+
/**
|
|
27
|
+
* pi's read (from fileTools), which in a computer also opens an image at any path there, such as one rendered to /tmp:
|
|
28
|
+
* read through the computer itself (Workspace.exec, the attached workspace's), never on this machine, and only when the
|
|
29
|
+
* bytes are an image's; anything else outside the run's folder is refused as before. `names` are the folder's names
|
|
30
|
+
* (portPath), `env` the shell environment the read runs with. Only for a run with a computer: with none, a path outside
|
|
31
|
+
* the folder is this machine's, and read never opens it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function readAnywhereInComputer(read: ToolRegistration, workspace: Workspace, names: readonly string[], env: Readonly<Record<string, string>>): ToolRegistration;
|
|
34
|
+
/** pi's bash, as pi ships it: the kernel's registry bounds its timeout and says so. */
|
|
35
|
+
export declare function bashTool(): ToolRegistration;
|
|
36
|
+
/** pi's read, write and edit, each refusal of a path outside the run's folder named by the path the call gave, as it
|
|
37
|
+
* gave it ("../../.token: outside the workspace"), and nothing else of a tool changed but read's replay: safe, as it
|
|
38
|
+
* always was (a read changes nothing, so a call a crash cut off runs again). */
|
|
39
|
+
export declare function fileTools(): ToolRegistration[];
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
// pi's file environment over a Workspace: pi's own read, write and edit tools, and its bash, run on a run's Workspace
|
|
2
|
+
// (a folder here, the owner's disk, or the folder inside a computer) without knowing which. One environment for every
|
|
3
|
+
// place, so a tool's arguments, output and words are pi's wherever the run's folder is.
|
|
4
|
+
//
|
|
5
|
+
// Paths. The model names the run's folder by `cwd`: the folder's own path on this machine with no computer, /workspace
|
|
6
|
+
// in one. A path is resolved against it (posix, no link followed: the port refuses links), and one that leaves it is
|
|
7
|
+
// refused as "outside the workspace", which fileTools names by the path the call gave ("../x: outside the workspace").
|
|
8
|
+
// `aliases` are other absolute names of the same folder a path may come by (a harness's own working directory, the
|
|
9
|
+
// folder's real path), taken as `cwd`. `~` and a `file:` URL are outside.
|
|
10
|
+
//
|
|
11
|
+
// bash. A command runs as `bash -c <command>` (sh where there is no bash) through Workspace.exec, in the run's folder,
|
|
12
|
+
// with the environment it is given and nothing of this process's. Its output streams to pi as it comes; past pi's spill
|
|
13
|
+
// thresholds the whole output goes to .agentrun/output/<id> in the run's folder, which the model reads with read (and
|
|
14
|
+
// the run's end sweeps). A program a signal ended answers 128 + its number, as pi's own environment does.
|
|
15
|
+
import { randomBytes } from "node:crypto";
|
|
16
|
+
import { posix } from "node:path";
|
|
17
|
+
import { exitCodeOf } from "@parcha/agentrun-kernel/kernel";
|
|
18
|
+
import { err, ExecutionError, FileError, LineScanner, ok, StreamDecoder, } from "@earendil-works/pi-durable/env";
|
|
19
|
+
import { CodingTools } from "@earendil-works/pi-durable/tools";
|
|
20
|
+
import { forModelBlocks } from "../result.js";
|
|
21
|
+
import { portPath, relativePath } from "./paths.js";
|
|
22
|
+
import { WorkspaceError } from "./workspace.js";
|
|
23
|
+
/** Where a long bash output is spilled whole, in the run's folder. */
|
|
24
|
+
export const OUTPUT_DIR = ".agentrun/output";
|
|
25
|
+
/** How much of a spill is held before it is appended to its file. */
|
|
26
|
+
const SPILL_FLUSH_BYTES = 1024 * 1024;
|
|
27
|
+
/** How much one step of a line scan reads. */
|
|
28
|
+
const SCAN_CHUNK = 1024 * 1024;
|
|
29
|
+
/** The refusal of a path outside the run's folder: pi's FileError, its message naming no path (fileTools names it by
|
|
30
|
+
* the path the call gave). */
|
|
31
|
+
export class OutsideWorkspace extends FileError {
|
|
32
|
+
constructor(path) {
|
|
33
|
+
super("permission_denied", "outside the workspace", path);
|
|
34
|
+
this.name = "OutsideWorkspace";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** OutsideWorkspace, already named by the path the call gave. */
|
|
38
|
+
class GivenOutside extends OutsideWorkspace {
|
|
39
|
+
constructor(given) {
|
|
40
|
+
super(given);
|
|
41
|
+
this.message = `${given}: outside the workspace`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const CODES = { NOT_FOUND: "not_found", REFUSED: "permission_denied", ESCAPE: "permission_denied", TOO_LARGE: "invalid", EXISTS: "invalid" };
|
|
45
|
+
let envs = 0;
|
|
46
|
+
/** pi's ExecutionEnv over `workspace`, the run's folder named `options.cwd`. */
|
|
47
|
+
export function piEnv(workspace, options) {
|
|
48
|
+
const id = `workspace-${++envs}`;
|
|
49
|
+
const cwd = posix.resolve(options.cwd);
|
|
50
|
+
const names = [cwd, ...(options.aliases ?? []).map((alias) => posix.resolve(alias))];
|
|
51
|
+
/** `path` relative to the run's folder, for the port, or the refusal of one outside it. */
|
|
52
|
+
const relative = (path) => {
|
|
53
|
+
const port = portPath(path, names);
|
|
54
|
+
if (port === undefined)
|
|
55
|
+
return err(new OutsideWorkspace(path));
|
|
56
|
+
try {
|
|
57
|
+
return ok(relativePath(port));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return err(new OutsideWorkspace(path));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/** `path` as the model's absolute path (under `cwd`), or the refusal of one outside the run's folder. */
|
|
64
|
+
const absolute = (path) => {
|
|
65
|
+
const rel = relative(path);
|
|
66
|
+
return rel.ok ? ok(rel.value === "" ? cwd : `${cwd}/${rel.value}`) : rel;
|
|
67
|
+
};
|
|
68
|
+
/** A port failure as pi's FileError, naming the path as the model named it. */
|
|
69
|
+
const failure = (error, path) => {
|
|
70
|
+
if (error instanceof FileError)
|
|
71
|
+
return error;
|
|
72
|
+
if (error instanceof WorkspaceError) {
|
|
73
|
+
if (error.code === "NOT_FOUND")
|
|
74
|
+
return new FileError("not_found", `ENOENT: no such file or directory, open '${path}'`, path, error);
|
|
75
|
+
if (error.code === "ESCAPE")
|
|
76
|
+
return new FileError("permission_denied", `${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 folder (bash can)`, path, error);
|
|
77
|
+
return new FileError(CODES[error.code] ?? "unknown", `${path}: ${error.message}`, path, error);
|
|
78
|
+
}
|
|
79
|
+
return new FileError("unknown", `${path}: ${error?.message ?? String(error)}`, path);
|
|
80
|
+
};
|
|
81
|
+
/** `use` on the port's path of `path`, its failure as pi's. */
|
|
82
|
+
async function on(path, use) {
|
|
83
|
+
const abs = absolute(path);
|
|
84
|
+
if (!abs.ok)
|
|
85
|
+
return abs;
|
|
86
|
+
const rel = relative(abs.value);
|
|
87
|
+
if (!rel.ok)
|
|
88
|
+
return rel;
|
|
89
|
+
try {
|
|
90
|
+
return ok(await use(rel.value, abs.value));
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return err(failure(error, abs.value));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const infoOf = (stat, abs) => ({
|
|
97
|
+
name: posix.basename(abs), path: abs, kind: stat.kind === "dir" ? "directory" : stat.kind === "link" ? "symlink" : "file", size: stat.size, mtimeMs: stat.mtimeMs,
|
|
98
|
+
});
|
|
99
|
+
/** What is at `rel`, a file to read: not there, a folder, a link or anything else is refused as pi's. */
|
|
100
|
+
const fileAt = async (rel, abs) => {
|
|
101
|
+
if (rel === "")
|
|
102
|
+
throw new FileError("is_directory", `EISDIR: illegal operation on a directory, read '${abs}'`, abs);
|
|
103
|
+
const stat = await workspace.stat(rel);
|
|
104
|
+
if (stat === undefined)
|
|
105
|
+
throw new FileError("not_found", `ENOENT: no such file or directory, open '${abs}'`, abs);
|
|
106
|
+
if (stat.kind === "dir")
|
|
107
|
+
throw new FileError("is_directory", `EISDIR: illegal operation on a directory, read '${abs}'`, abs);
|
|
108
|
+
if (stat.kind === "link")
|
|
109
|
+
throw failure(new WorkspaceError("ESCAPE", "a link"), abs);
|
|
110
|
+
if (stat.kind !== "file")
|
|
111
|
+
throw new FileError("permission_denied", `${abs}: refused: it is not a regular file`, abs);
|
|
112
|
+
return stat;
|
|
113
|
+
};
|
|
114
|
+
const unoffered = (name) => async () => err(new FileError("not_supported", `${name} is not offered here: the run's file tools read, write and edit, and bash runs commands`));
|
|
115
|
+
const reader = (rel, abs) => ({
|
|
116
|
+
info: async () => {
|
|
117
|
+
try {
|
|
118
|
+
return ok(infoOf(await fileAt(rel, abs), abs));
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
return err(failure(error, abs));
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
read: async (offset, length) => {
|
|
125
|
+
try {
|
|
126
|
+
return ok(await workspace.read(rel, { offset, length }));
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
return err(failure(error, abs));
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
scanLines: async ({ startLine, endLine }) => {
|
|
133
|
+
try {
|
|
134
|
+
const scanner = new LineScanner(startLine, endLine);
|
|
135
|
+
for (let offset = 0;;) {
|
|
136
|
+
const chunk = await workspace.read(rel, { offset, length: SCAN_CHUNK });
|
|
137
|
+
if (chunk.length === 0)
|
|
138
|
+
break;
|
|
139
|
+
scanner.push(chunk);
|
|
140
|
+
offset += chunk.length;
|
|
141
|
+
if (chunk.length < SCAN_CHUNK)
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
return ok(scanner.finish());
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
return err(failure(error, abs));
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
close: async () => undefined,
|
|
151
|
+
});
|
|
152
|
+
async function exec(command, given, context) {
|
|
153
|
+
const where = relative(given?.cwd ?? cwd);
|
|
154
|
+
if (!where.ok)
|
|
155
|
+
return err(new ExecutionError("spawn_error", `Working directory is outside the workspace: ${given?.cwd}\nCannot execute bash commands.`));
|
|
156
|
+
const timeoutS = given?.timeout ?? options.defaultTimeoutS;
|
|
157
|
+
const decoders = { stdout: new StreamDecoder(), stderr: new StreamDecoder() };
|
|
158
|
+
let callbackError;
|
|
159
|
+
const emit = (text, stream) => {
|
|
160
|
+
if (text === "" || given?.onOutput === undefined || callbackError !== undefined)
|
|
161
|
+
return;
|
|
162
|
+
try {
|
|
163
|
+
given.onOutput(text, context, { stream });
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
callbackError = new ExecutionError("callback_error", error?.message ?? String(error), error);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
// The spill: the output held until it passes pi's thresholds, then all of it appended to its file, in order.
|
|
170
|
+
const spill = given?.spill;
|
|
171
|
+
let seenBytes = 0;
|
|
172
|
+
let seenNewlines = 0;
|
|
173
|
+
let held = [];
|
|
174
|
+
let heldBytes = 0;
|
|
175
|
+
let spillRel;
|
|
176
|
+
let flushing = Promise.resolve();
|
|
177
|
+
let spillError;
|
|
178
|
+
const flush = () => {
|
|
179
|
+
if (spillRel === undefined || heldBytes === 0)
|
|
180
|
+
return;
|
|
181
|
+
const data = Buffer.concat(held);
|
|
182
|
+
held = [];
|
|
183
|
+
heldBytes = 0;
|
|
184
|
+
const to = spillRel;
|
|
185
|
+
flushing = flushing.then(() => workspace.append(to, data)).catch((error) => { spillError ??= error; });
|
|
186
|
+
};
|
|
187
|
+
const keep = (chunk) => {
|
|
188
|
+
if (spill === undefined || chunk.length === 0)
|
|
189
|
+
return;
|
|
190
|
+
held.push(Buffer.from(chunk));
|
|
191
|
+
heldBytes += chunk.length;
|
|
192
|
+
if (spillRel === undefined) {
|
|
193
|
+
seenBytes += chunk.length;
|
|
194
|
+
for (let at = chunk.indexOf(0x0a); at !== -1; at = chunk.indexOf(0x0a, at + 1))
|
|
195
|
+
seenNewlines++;
|
|
196
|
+
const lines = seenNewlines + (chunk[chunk.length - 1] === 0x0a ? 0 : 1);
|
|
197
|
+
if (seenBytes <= spill.afterBytes && lines <= spill.afterLines)
|
|
198
|
+
return;
|
|
199
|
+
spillRel = `${OUTPUT_DIR}/${randomBytes(8).toString("hex")}.log`;
|
|
200
|
+
}
|
|
201
|
+
if (heldBytes >= SPILL_FLUSH_BYTES)
|
|
202
|
+
flush();
|
|
203
|
+
};
|
|
204
|
+
const run = (argv) => workspace.exec(argv, {
|
|
205
|
+
cwd: where.value, env: { ...options.env, ...(given?.env ?? {}) }, timeoutMs: Math.max(1, Math.round(timeoutS * 1000)), maxOutput: 0,
|
|
206
|
+
...(context.abortSignal ? { signal: context.abortSignal } : {}),
|
|
207
|
+
onOutput: ({ stream, data }) => {
|
|
208
|
+
emit(decoders[stream].decode(data), stream);
|
|
209
|
+
keep(data);
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
const argvs = typeof command === "string" ? [["bash", "-c", command], ["sh", "-c", command]] : [[...command]];
|
|
213
|
+
let ran;
|
|
214
|
+
try {
|
|
215
|
+
for (const argv of argvs) {
|
|
216
|
+
try {
|
|
217
|
+
ran = await run(argv);
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
if (!(error instanceof WorkspaceError && error.code === "NOT_FOUND" && argv !== argvs.at(-1)))
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
flush();
|
|
228
|
+
await flushing;
|
|
229
|
+
if (context.abortSignal?.aborted) {
|
|
230
|
+
const aborted = new ExecutionError("aborted", "aborted");
|
|
231
|
+
if (spillRel !== undefined)
|
|
232
|
+
aborted.spillPath = `${cwd}/${spillRel}`;
|
|
233
|
+
return err(aborted);
|
|
234
|
+
}
|
|
235
|
+
return err(new ExecutionError("spawn_error", error?.message ?? String(error), error));
|
|
236
|
+
}
|
|
237
|
+
emit(decoders.stdout.decode(), "stdout");
|
|
238
|
+
emit(decoders.stderr.decode(), "stderr");
|
|
239
|
+
flush();
|
|
240
|
+
await flushing;
|
|
241
|
+
if (callbackError)
|
|
242
|
+
return err(callbackError);
|
|
243
|
+
const spillPath = spillRel === undefined ? undefined : `${cwd}/${spillRel}`;
|
|
244
|
+
if (ran.timedOut) {
|
|
245
|
+
const timedOut = new ExecutionError("timeout", `timeout:${given?.timeout}`);
|
|
246
|
+
if (spillPath !== undefined)
|
|
247
|
+
timedOut.spillPath = spillPath;
|
|
248
|
+
return err(timedOut);
|
|
249
|
+
}
|
|
250
|
+
if (spillError !== undefined)
|
|
251
|
+
return err(new ExecutionError("unknown", `Failed to preserve complete shell output: ${spillError?.message ?? String(spillError)}`, spillError));
|
|
252
|
+
// The kernel's one rule: the code, or 128 + n for signal n; 1 when neither is known, as pi's own environment says.
|
|
253
|
+
const exitCode = exitCodeOf({ exitCode: ran.code, signal: ran.signal, timedOut: ran.timedOut }) ?? 1;
|
|
254
|
+
return ok({ exitCode, ...(spillPath === undefined ? {} : { spillPath }) });
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
id,
|
|
258
|
+
cwd,
|
|
259
|
+
absolutePath: async (path) => absolute(path),
|
|
260
|
+
joinPath: async (parts) => ok(posix.join(...parts)),
|
|
261
|
+
// The mutation queue then keys a file by its absolute path: the port follows no link, so that is the file.
|
|
262
|
+
canonicalPath: unoffered("canonicalPath"),
|
|
263
|
+
exists: async (path) => {
|
|
264
|
+
const found = await on(path, async (rel) => (await workspace.stat(rel)) !== undefined);
|
|
265
|
+
// A path refused is there: the operation that follows says why.
|
|
266
|
+
return found.ok ? found : found.error instanceof OutsideWorkspace ? found : ok(true);
|
|
267
|
+
},
|
|
268
|
+
fileInfo: (path) => on(path, async (rel, abs) => {
|
|
269
|
+
const stat = rel === "" ? await workspace.stat("") : await workspace.stat(rel);
|
|
270
|
+
if (stat === undefined)
|
|
271
|
+
throw new FileError("not_found", `ENOENT: no such file or directory, open '${abs}'`, abs);
|
|
272
|
+
return infoOf(stat, abs);
|
|
273
|
+
}),
|
|
274
|
+
readTextFile: (path) => on(path, async (rel, abs) => {
|
|
275
|
+
await fileAt(rel, abs);
|
|
276
|
+
return Buffer.from(await workspace.read(rel)).toString("utf8");
|
|
277
|
+
}),
|
|
278
|
+
readBinaryFile: (path) => on(path, async (rel, abs) => {
|
|
279
|
+
await fileAt(rel, abs);
|
|
280
|
+
return workspace.read(rel);
|
|
281
|
+
}),
|
|
282
|
+
openBinaryReader: (path) => on(path, async (rel, abs) => {
|
|
283
|
+
await fileAt(rel, abs);
|
|
284
|
+
return reader(rel, abs);
|
|
285
|
+
}),
|
|
286
|
+
openTextLineReader: unoffered("openTextLineReader"),
|
|
287
|
+
readTextLines: unoffered("readTextLines"),
|
|
288
|
+
writeFile: (path, content) => on(path, async (rel, abs) => {
|
|
289
|
+
if (rel === "")
|
|
290
|
+
throw new FileError("is_directory", `${abs}: is the run's folder, not a file`, abs);
|
|
291
|
+
await workspace.write(rel, content);
|
|
292
|
+
}),
|
|
293
|
+
appendFile: (path, content) => on(path, (rel) => workspace.append(rel, content)),
|
|
294
|
+
createDir: (path) => on(path, (rel) => workspace.mkdir(rel)),
|
|
295
|
+
remove: (path, options) => on(path, (rel) => workspace.remove(rel, { ...(options?.recursive ? { recursive: true } : {}), ...(options?.force ? { force: true } : {}) })),
|
|
296
|
+
listDir: (path) => on(path, async (rel, abs) => (await workspace.list(rel)).map((entry) => ({
|
|
297
|
+
name: entry.name, path: posix.join(abs, entry.name), kind: entry.kind === "dir" ? "directory" : "file", size: entry.size, mtimeMs: 0,
|
|
298
|
+
}))),
|
|
299
|
+
truncateFile: unoffered("truncateFile"),
|
|
300
|
+
flushFile: unoffered("flushFile"),
|
|
301
|
+
renameFile: unoffered("renameFile"),
|
|
302
|
+
openDirReader: unoffered("openDirReader"),
|
|
303
|
+
watch: unoffered("watch"),
|
|
304
|
+
createTempDir: unoffered("createTempDir"),
|
|
305
|
+
createTempFile: unoffered("createTempFile"),
|
|
306
|
+
exec,
|
|
307
|
+
cleanup: async () => undefined,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
/** The image types read opens anywhere in a computer, by extension; the bytes must say the same (imageTypeOf). */
|
|
311
|
+
const IMAGE_EXTENSIONS = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", gif: "image/gif", webp: "image/webp" };
|
|
312
|
+
/** The largest image read hands the model, in bytes: 3.75 MiB, whose base64 is the 5 MiB the strictest platform a
|
|
313
|
+
* harness sends images to takes (the claude-agent adapter's CLAUDE_AGENT_MAX_IMAGE_BYTES, Amazon Bedrock's). */
|
|
314
|
+
export const READ_IMAGE_MAX_BYTES = 3_932_160;
|
|
315
|
+
/** The computer's side of an image read: at most `$2` bytes of `$1`. A file over the bound never leaves the computer
|
|
316
|
+
* whole: the server holds one byte past it at most, and refuses it. */
|
|
317
|
+
const READ_IMAGE_SCRIPT = '[ -f "$1" ] && [ -r "$1" ] || exit 6; head -c "$2" -- "$1"';
|
|
318
|
+
/** The image type the bytes say they are, or undefined: the magic bytes of PNG, JPEG, GIF and WebP. */
|
|
319
|
+
function imageTypeOf(bytes) {
|
|
320
|
+
const at = (offset, ...values) => values.every((value, index) => bytes[offset + index] === value);
|
|
321
|
+
if (at(0, 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a))
|
|
322
|
+
return "image/png";
|
|
323
|
+
if (at(0, 0xff, 0xd8, 0xff))
|
|
324
|
+
return "image/jpeg";
|
|
325
|
+
if (at(0, 0x47, 0x49, 0x46, 0x38))
|
|
326
|
+
return "image/gif";
|
|
327
|
+
if (at(0, 0x52, 0x49, 0x46, 0x46) && at(8, 0x57, 0x45, 0x42, 0x50))
|
|
328
|
+
return "image/webp";
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
/** A path read may open as an image anywhere in a computer: an absolute path (not `~`, not a URL) whose extension is an
|
|
332
|
+
* image's. */
|
|
333
|
+
const imagePath = (path) => path.startsWith("/") && !path.startsWith("//") && IMAGE_EXTENSIONS[posix.extname(path).slice(1).toLowerCase()] !== undefined;
|
|
334
|
+
/**
|
|
335
|
+
* pi's read (from fileTools), which in a computer also opens an image at any path there, such as one rendered to /tmp:
|
|
336
|
+
* read through the computer itself (Workspace.exec, the attached workspace's), never on this machine, and only when the
|
|
337
|
+
* bytes are an image's; anything else outside the run's folder is refused as before. `names` are the folder's names
|
|
338
|
+
* (portPath), `env` the shell environment the read runs with. Only for a run with a computer: with none, a path outside
|
|
339
|
+
* the folder is this machine's, and read never opens it.
|
|
340
|
+
*/
|
|
341
|
+
export function readAnywhereInComputer(read, workspace, names, env) {
|
|
342
|
+
return {
|
|
343
|
+
...read,
|
|
344
|
+
async execute(args, api, context) {
|
|
345
|
+
const path = args?.path;
|
|
346
|
+
if (typeof path !== "string" || !imagePath(path) || portPath(path, names) !== undefined)
|
|
347
|
+
return read.execute(args, api, context);
|
|
348
|
+
const ran = await workspace.exec(["sh", "-c", READ_IMAGE_SCRIPT, "agentrun-read-image", path, String(READ_IMAGE_MAX_BYTES + 1)], {
|
|
349
|
+
env, timeoutMs: 30_000, maxOutput: READ_IMAGE_MAX_BYTES + 1, ...(context.abortSignal ? { signal: context.abortSignal } : {}),
|
|
350
|
+
}).catch(() => undefined);
|
|
351
|
+
// Said as what it is: a path the computer could not read (no such file, no permission), or bytes that are no image's.
|
|
352
|
+
if (!ran || ran.code !== 0)
|
|
353
|
+
throw new Error(`${path} could not be read in the box`);
|
|
354
|
+
const bytes = ran.stdout;
|
|
355
|
+
const mimeType = imageTypeOf(bytes);
|
|
356
|
+
if (!mimeType)
|
|
357
|
+
throw new Error(`${path} is not an image`);
|
|
358
|
+
if (bytes.byteLength > READ_IMAGE_MAX_BYTES)
|
|
359
|
+
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).`);
|
|
360
|
+
// A line naming it, then the image: an answer is never an empty text, on pi or on another harness.
|
|
361
|
+
return forModelBlocks([{ type: "text", text: `${path}: ${mimeType}, ${bytes.byteLength} bytes` }, { type: "image", data: Buffer.from(bytes).toString("base64"), mimeType }]);
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
/** A failed call's error with what the environment said, where pi's message gives only its code (edit's "Error code:
|
|
366
|
+
* permission_denied."), so the model reads why and what it can do. */
|
|
367
|
+
const withCause = (error) => {
|
|
368
|
+
const cause = error?.cause;
|
|
369
|
+
return error instanceof Error && cause instanceof FileError && !(cause instanceof OutsideWorkspace) && !error.message.includes(cause.message) ? new Error(`${error.message} ${cause.message}`, { cause }) : error;
|
|
370
|
+
};
|
|
371
|
+
/** pi's bash, as pi ships it: the kernel's registry bounds its timeout and says so. */
|
|
372
|
+
export function bashTool() {
|
|
373
|
+
const bash = (CodingTools.tools ?? []).find((tool) => tool.name === "bash");
|
|
374
|
+
if (bash === undefined)
|
|
375
|
+
throw new Error("pi's coding tools carry no bash");
|
|
376
|
+
return bash;
|
|
377
|
+
}
|
|
378
|
+
/** pi's read, write and edit, each refusal of a path outside the run's folder named by the path the call gave, as it
|
|
379
|
+
* gave it ("../../.token: outside the workspace"), and nothing else of a tool changed but read's replay: safe, as it
|
|
380
|
+
* always was (a read changes nothing, so a call a crash cut off runs again). */
|
|
381
|
+
export function fileTools() {
|
|
382
|
+
return (CodingTools.tools ?? []).filter((tool) => tool.name !== "bash").map((tool) => ({
|
|
383
|
+
...tool,
|
|
384
|
+
...(tool.name === "read" ? { replay: "safe" } : {}),
|
|
385
|
+
async execute(args, api, context) {
|
|
386
|
+
try {
|
|
387
|
+
return await tool.execute(args, api, context);
|
|
388
|
+
}
|
|
389
|
+
catch (error) {
|
|
390
|
+
const given = args?.path;
|
|
391
|
+
if (!(error instanceof OutsideWorkspace) || error instanceof GivenOutside || typeof given !== "string" || given === "")
|
|
392
|
+
throw withCause(error);
|
|
393
|
+
throw new GivenOutside(given);
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
}));
|
|
397
|
+
}
|