@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,172 @@
|
|
|
1
|
+
import { capabilityToolDefs, createRegistry, endBackground } from "@parcha/agentrun-kernel/kernel";
|
|
2
|
+
import { inputOf, phoneOf, screenOf } from "./computer-ports.js";
|
|
3
|
+
import { answerText, piExecutor } from "./executors.js";
|
|
4
|
+
import { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, shellEnv } from "./hands.js";
|
|
5
|
+
import { COMPUTER_ROOT, realOf, workspaceRelative } from "./paths.js";
|
|
6
|
+
import { bashTool, fileTools, OUTPUT_DIR, piEnv, readAnywhereInComputer } from "./pi-env.js";
|
|
7
|
+
import { shellPlaceOf } from "./resolve-computer.js";
|
|
8
|
+
/** The computer the run's folder is attached to, with its check: a sandbox, or a desktop with files and exec whose
|
|
9
|
+
* provider mounts the folder; none for any other. */
|
|
10
|
+
function mountedIn(computer) {
|
|
11
|
+
if (computer?.kind === "sandbox")
|
|
12
|
+
return computer;
|
|
13
|
+
if (computer?.kind === "desktop" && computer.check && computer.groups.includes("files") && computer.groups.includes("exec"))
|
|
14
|
+
return { computer: computer.computer, check: computer.check };
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
/** The kind's ports, as the computer's groups offer them, the kinds whose tools the run gets (a desktop's with a screen
|
|
18
|
+
* and input, a phone's with a screen and touch, a browser's always), and the kind's tools its groups do not offer: a
|
|
19
|
+
* phone's tree without apps.ui_tree, its keys without input.keys (an iPhone's today). */
|
|
20
|
+
function portsOf(computer) {
|
|
21
|
+
if (computer?.kind === "desktop") {
|
|
22
|
+
const { client } = computer.computer;
|
|
23
|
+
const screen = computer.groups.includes("screen");
|
|
24
|
+
const input = computer.groups.includes("input.pointer") || computer.groups.includes("input.keys");
|
|
25
|
+
return screen && input ? { ports: { screen: screenOf(client), input: inputOf(client) }, kinds: ["desktop"], without: [] } : { ports: {}, kinds: [], without: [] };
|
|
26
|
+
}
|
|
27
|
+
if (computer?.kind === "phone") {
|
|
28
|
+
if (!computer.groups.includes("screen") || !computer.groups.includes("input.touch"))
|
|
29
|
+
return { ports: {}, kinds: [], without: [] };
|
|
30
|
+
const tree = computer.groups.includes("apps.ui_tree");
|
|
31
|
+
const keys = computer.groups.includes("input.keys");
|
|
32
|
+
return { ports: { phone: phoneOf(computer.computer.client, { tree, keys }) }, kinds: ["phone"], without: [...(tree ? [] : ["phone_tree"]), ...(keys ? [] : ["phone_key"])] };
|
|
33
|
+
}
|
|
34
|
+
if (computer?.kind === "browser")
|
|
35
|
+
return { ports: { browser: { connect: computer.connect } }, kinds: ["browser"], without: [] };
|
|
36
|
+
return { ports: {}, kinds: [], without: [] };
|
|
37
|
+
}
|
|
38
|
+
/** The run's scratch in its own folder: bash's TMPDIR. */
|
|
39
|
+
export const TMP_DIR = ".agentrun/tmp";
|
|
40
|
+
/** The run's hands and host executors on `workspace`, attached to `computer` when its kind and provider mount the folder,
|
|
41
|
+
* with its kind's ports. `aliases`: other absolute names of the run's folder a tool call may give (the harness's
|
|
42
|
+
* scratch folder), taken as the folder. `hold`: a person's hold on the computer (its take-over), given a desktop's or a
|
|
43
|
+
* phone's ports and answering them wrapped, so a call made while the person holds it waits, and an action then is
|
|
44
|
+
* refused; never the shell's, the files' or a browser's (its take-over is pi-browser's own). */
|
|
45
|
+
export async function runHands(workspace, computer, options) {
|
|
46
|
+
// The folder's own path on this machine, Mode 1's bind. A Mode 2 folder (Archil) has none, and asking its mount would
|
|
47
|
+
// mint the run's mount credential: only a computer that mounts the folder asks it (attach, below).
|
|
48
|
+
const spec = options.mode === 1 ? await workspace.mountSpec() : undefined;
|
|
49
|
+
const here = spec?.kind === "bind" ? spec.path : undefined;
|
|
50
|
+
const mounted = mountedIn(computer);
|
|
51
|
+
const shell = shellPlaceOf(mounted !== undefined, options.mode);
|
|
52
|
+
const attached = mounted === undefined ? workspace : await workspace.attach(mounted.computer, mounted.check);
|
|
53
|
+
// The folder's name: /workspace in a computer (and on Archil's exec, which has no path of this machine), its own path here.
|
|
54
|
+
const cwd = mounted === undefined && here !== undefined ? here : COMPUTER_ROOT;
|
|
55
|
+
const names = [cwd, ...(here !== undefined && here !== cwd ? [here] : []), ...(options.aliases ?? [])];
|
|
56
|
+
const maxExecS = mounted === undefined && options.mode === 2 ? ARCHIL_MAX_EXEC_S : MAX_EXEC_S;
|
|
57
|
+
await attached.mkdir(TMP_DIR);
|
|
58
|
+
const env = shellEnv({ tmpdir: `${cwd}/${TMP_DIR}`, ...(mounted === undefined ? { home: cwd } : {}) });
|
|
59
|
+
const fileEnv = piEnv(attached, { cwd, aliases: names.slice(1), env, defaultTimeoutS: maxExecS });
|
|
60
|
+
const tools = Object.fromEntries([...fileTools(), bashTool()].map((tool) => [tool.name, tool]));
|
|
61
|
+
const read = mounted === undefined ? tools.read : readAnywhereInComputer(tools.read, attached, names, env);
|
|
62
|
+
const executor = (tool) => piExecutor(tool, fileEnv, options.context);
|
|
63
|
+
const own = portsOf(computer);
|
|
64
|
+
const held = options.hold !== undefined && (computer?.kind === "desktop" || computer?.kind === "phone") && own.kinds.length > 0;
|
|
65
|
+
const { ports, kinds, without } = held ? { ...own, ports: options.hold(own.ports) } : own;
|
|
66
|
+
return {
|
|
67
|
+
workspace: attached,
|
|
68
|
+
// The computer's processes, for the five background tools: the attached Workspace's own; none when the folder is not
|
|
69
|
+
// attached. The kind's ports beside them.
|
|
70
|
+
hands: { ...handsOf(attached, { maxExecS, env, ...(mounted === undefined ? {} : { processes: attached.process }) }), ...ports },
|
|
71
|
+
shell,
|
|
72
|
+
kinds,
|
|
73
|
+
without,
|
|
74
|
+
maxExecS,
|
|
75
|
+
cwd,
|
|
76
|
+
names,
|
|
77
|
+
executors: { read: executor(read), write: executor(tools.write), edit: executor(tools.edit), ...(shell === "none" ? {} : { bash: executor(tools.bash) }) },
|
|
78
|
+
async sweep() {
|
|
79
|
+
// Through the run's own Workspace, not the computer's: the sweep holds whether or not the computer still answers.
|
|
80
|
+
for (const dir of [OUTPUT_DIR, TMP_DIR])
|
|
81
|
+
await workspace.remove(dir, { recursive: true, force: true });
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** The tools whose answer is pi's own words about a path (`Successfully wrote to <path>`), never a file's text. */
|
|
86
|
+
const SAYS_PATH = new Set(["write", "edit"]);
|
|
87
|
+
/**
|
|
88
|
+
* `registry`'s tools that `names` names, in that order, bound to `run`: each as the kernel's HostTool, which an adapter's
|
|
89
|
+
* session takes. A call passes the run's gate first (`gated`: the gate and the park it takes; none for the gate's own
|
|
90
|
+
* run of an approved call): a refused one runs nothing, a parked one says it waits. Then the registry runs it on the
|
|
91
|
+
* run's hands, and its answer is the text a model reads (executors.ts answerText): the output, the failure's words, the
|
|
92
|
+
* diagnostics; in a failure, a write's or an edit's answer a path in the run's folder is named relative to it. A
|
|
93
|
+
* failure the registry throws is the answer's text. `results` keeps each answer by its call id.
|
|
94
|
+
*/
|
|
95
|
+
export function bindTools(run, registry, names, options = {}) {
|
|
96
|
+
const defs = new Map(registry.list().map((def) => [def.name, def]));
|
|
97
|
+
const works = [...new Set(run.names.flatMap((name) => [name, realOf(name)]))];
|
|
98
|
+
return names.flatMap((name) => {
|
|
99
|
+
const def = defs.get(name);
|
|
100
|
+
if (!def)
|
|
101
|
+
return [];
|
|
102
|
+
return [{
|
|
103
|
+
name: def.name,
|
|
104
|
+
description: def.description,
|
|
105
|
+
inputSchema: def.parameters,
|
|
106
|
+
replay: def.replaySafe ? "safe" : "never",
|
|
107
|
+
async call(args, { callId, signal, attempt, model, output }) {
|
|
108
|
+
// A replay (the kernel's attempt above 0) may follow an attempt that was sent: the gate's refusal then says so.
|
|
109
|
+
const refused = await options.gated?.gate.enter(name, args, callId, options.gated.park, (attempt ?? 0) > 0 ? { replayed: true } : {});
|
|
110
|
+
if (refused) {
|
|
111
|
+
const answer = { text: refused.text, isError: refused.isError === true };
|
|
112
|
+
options.results?.set(callId, answer);
|
|
113
|
+
return refused.parked ? { ...answer, parked: true } : answer;
|
|
114
|
+
}
|
|
115
|
+
let given;
|
|
116
|
+
try {
|
|
117
|
+
// The calling model and the call's output stream, as the session gave them: pi's read sizes an image by the
|
|
118
|
+
// model, and a running tool's output reaches the run's live view.
|
|
119
|
+
given = await registry.invoke(name, args, { hands: run.hands, signal, ...(model !== undefined ? { model } : {}), ...(output ? { output } : {}) });
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
given = { text: "", isError: true, error: error?.message ?? String(error) };
|
|
123
|
+
}
|
|
124
|
+
const said = answerText(given);
|
|
125
|
+
// A failure is an answer with its words in `error` (the kernel's answerOf sets no isError): an error either way.
|
|
126
|
+
const isError = given.isError === true || given.error !== undefined;
|
|
127
|
+
const answer = { text: isError || SAYS_PATH.has(name) ? workspaceRelative(said, works) : said, isError };
|
|
128
|
+
options.results?.set(callId, answer);
|
|
129
|
+
return given.images?.length ? { ...answer, images: given.images } : answer;
|
|
130
|
+
},
|
|
131
|
+
}];
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* A run's tools on `workspace`, attached to `computer` when its kind has files and exec and its provider mounts the
|
|
136
|
+
* folder (RunComputer). `computer.check` is the mount check attach runs (attach.ts MountCheck: `{ readBackOf, epoch }`),
|
|
137
|
+
* which the caller builds with the claim's epoch, so a read-back under another epoch is refused. `options.mode`: 1, or 2
|
|
138
|
+
* (the run's folder on Archil); `options.aliases`: other absolute names of the run's folder a tool call may give (the
|
|
139
|
+
* harness's scratch folder); `options.browser`: a browser computer's runs and offers. The tools' definitions, words and
|
|
140
|
+
* limits come only from the kernel's registry, and a browser's from pi-browser's BROWSER_TOOLS; this binds their
|
|
141
|
+
* executors to the run.
|
|
142
|
+
*/
|
|
143
|
+
export async function runTools(workspace, computer, options) {
|
|
144
|
+
const run = await runHands(workspace, computer, options);
|
|
145
|
+
// pi-browser's contracts, listed for what this browser offers; with no browser, all of them, so a browser tool called
|
|
146
|
+
// in another run is refused in words that name the setting.
|
|
147
|
+
const { BROWSER_TOOLS, listedFor } = await import("@parcha/pi-browser");
|
|
148
|
+
const offers = options.browser?.offers;
|
|
149
|
+
const browserTools = run.kinds.includes("browser") ? BROWSER_TOOLS.filter((contract) => listedFor(contract, offers ?? { downloads: false, upload: false, handoff: false })) : BROWSER_TOOLS;
|
|
150
|
+
const registry = createRegistry({
|
|
151
|
+
maxExecS: run.maxExecS, shell: run.shell, kinds: run.kinds, browserTools, without: run.without,
|
|
152
|
+
executors: { ...run.executors, ...(options.browser ? { browser: options.browser.executors } : {}) },
|
|
153
|
+
});
|
|
154
|
+
const brought = new Set(run.kinds.filter((kind) => kind !== "browser").flatMap((kind) => capabilityToolDefs(kind).map((def) => def.name)));
|
|
155
|
+
return {
|
|
156
|
+
workspace: run.workspace,
|
|
157
|
+
registry,
|
|
158
|
+
hands: run.hands,
|
|
159
|
+
kindTools: registry.list().map((def) => def.name).filter((name) => brought.has(name)),
|
|
160
|
+
hostTools: (names, gated, results) => bindTools(run, registry, names, { ...(gated ? { gated } : {}), ...(results ? { results } : {}) }),
|
|
161
|
+
async end() {
|
|
162
|
+
await endBackground(run.hands);
|
|
163
|
+
await run.sweep();
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/** The names a run binds as host tools: what it was granted, then the tools its claimed computer brings by its kind
|
|
168
|
+
* (RunTools.kindTools), each once. Each goes through the run's one gate under its own settings key (a desktop's under
|
|
169
|
+
* `desktop`, a phone's under `phone`), so a deny or an ask on the kind holds them. */
|
|
170
|
+
export function withKindTools(granted, tools) {
|
|
171
|
+
return [...new Set([...granted, ...tools.kindTools])];
|
|
172
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ArchilClaim } from "./archil-claim.js";
|
|
2
|
+
import type { Workspace } from "./workspace.js";
|
|
3
|
+
export type RunWorkspaceOptions = {
|
|
4
|
+
readonly agentId: string;
|
|
5
|
+
readonly runId: string;
|
|
6
|
+
/** The run's log: what the run's Workspace has to say that is not a failure of the run. */
|
|
7
|
+
readonly log: (message: string) => void;
|
|
8
|
+
} & ({
|
|
9
|
+
readonly mode: 1; /** The data directory. */
|
|
10
|
+
readonly data: string;
|
|
11
|
+
} | {
|
|
12
|
+
readonly mode: 2;
|
|
13
|
+
/** The claim's Archil step. */
|
|
14
|
+
readonly archil?: ArchilClaim;
|
|
15
|
+
/** The run's mount credential, minted per run from the account key when a computer's mount asks for it: by default
|
|
16
|
+
* the claim's own (its token(), minted once and removed by its revoke()). No disk token is kept. */
|
|
17
|
+
readonly mountToken?: () => Promise<string>;
|
|
18
|
+
});
|
|
19
|
+
export interface RunWorkspace {
|
|
20
|
+
readonly workspace: Workspace;
|
|
21
|
+
/** What the run's end does to its Workspace: Mode 2 sweeps the exec spill folder. Once; later calls do nothing. */
|
|
22
|
+
end(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/** The Workspace of run `runId` of agent `agentId` for this claim: Mode 2's spill folder swept first. */
|
|
25
|
+
export declare function openRunWorkspace(options: RunWorkspaceOptions): Promise<RunWorkspace>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// A run's Workspace as the runner's claim opens it, and what its end does. The runner calls openRunWorkspace when a
|
|
2
|
+
// claim's run starts (before its tools are built over the Workspace) and end() when the claim's loop ends, after the
|
|
3
|
+
// tools' own end.
|
|
4
|
+
//
|
|
5
|
+
// Mode 2: the run's folder on the claim's Archil disk (archil-claim.ts), at runKey, in the image the server's Archil
|
|
6
|
+
// settings name. Its exec spill folder is swept when the run starts (what a killed exec, a crash or a failed cleanup left)
|
|
7
|
+
// and again at its end. A cleanup that leaves spill files (onCleanupFailed), or a sweep that fails, goes to the run's
|
|
8
|
+
// log in words and never fails the run: the next sweep takes what is left.
|
|
9
|
+
// Mode 1: the run's local folder (runFolder). Its end does nothing here; the tools' end clears what they keep in it.
|
|
10
|
+
import { mkdir } from "node:fs/promises";
|
|
11
|
+
import { archilWorkspace } from "./archil.js";
|
|
12
|
+
import { localWorkspace } from "./local.js";
|
|
13
|
+
import { runFolder, runKey } from "./paths.js";
|
|
14
|
+
/** The Workspace of run `runId` of agent `agentId` for this claim: Mode 2's spill folder swept first. */
|
|
15
|
+
export async function openRunWorkspace(options) {
|
|
16
|
+
const { agentId, runId, log } = options;
|
|
17
|
+
if (options.mode === 1) {
|
|
18
|
+
// The run's folder, made here at the claim (the server's start made it before the per-run process ran): a fresh run has
|
|
19
|
+
// none yet, and its Workspace, its tools and its first turn all open over it. Recursive and private, left as it is when
|
|
20
|
+
// it is already there (a resumed claim).
|
|
21
|
+
const folder = runFolder(options.data, agentId, runId);
|
|
22
|
+
await mkdir(folder, { recursive: true, mode: 0o700 });
|
|
23
|
+
return { workspace: localWorkspace(folder), end: async () => { } };
|
|
24
|
+
}
|
|
25
|
+
const claim = options.archil;
|
|
26
|
+
if (claim === undefined)
|
|
27
|
+
throw new TypeError("a Mode 2 run's Workspace is opened with its claim's Archil claim (archilClaim)");
|
|
28
|
+
const say = (message) => {
|
|
29
|
+
try {
|
|
30
|
+
log(message);
|
|
31
|
+
}
|
|
32
|
+
catch { /* the caller's log */ }
|
|
33
|
+
};
|
|
34
|
+
const workspace = archilWorkspace(claim.disk, runKey(agentId, runId), {
|
|
35
|
+
...(claim.image === undefined ? {} : { image: claim.image }),
|
|
36
|
+
onCleanupFailed: say,
|
|
37
|
+
// A computer's mount of the run's folder: the disk's region, and the run's minted mount credential when a mount asks.
|
|
38
|
+
region: claim.region,
|
|
39
|
+
// The claim's own mint (archil-claim.ts token(), revoked by its revoke()) unless the caller hands another.
|
|
40
|
+
...(options.mountToken ? { mountToken: options.mountToken } : typeof claim.token === "function" ? { mountToken: () => claim.token() } : {}),
|
|
41
|
+
});
|
|
42
|
+
const sweep = async (when) => {
|
|
43
|
+
try {
|
|
44
|
+
await workspace.sweep();
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
say(`the run's exec spill folder could not be swept at the run's ${when} (the next sweep takes what is left): ${error?.message ?? error}`);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
// The run's folder on the disk (its run key), ensured at the claim as Mode 1's is: a fresh run has none yet. A write would
|
|
51
|
+
// make its prefix anyway, so a failure here never fails the run; it is the next write's.
|
|
52
|
+
await workspace.mkdir("").catch((error) => say(`the run's folder could not be made on the disk (a write will make it): ${error?.message ?? error}`));
|
|
53
|
+
await sweep("start");
|
|
54
|
+
let ended;
|
|
55
|
+
return { workspace, end: () => (ended ??= sweep("end")) };
|
|
56
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Store } from "../store/index.js";
|
|
2
|
+
import type { KeyEnv } from "../key-meta.js";
|
|
3
|
+
import { type ArchilDisk, type ArchilDiskOptions } from "./archil-disk.js";
|
|
4
|
+
import { type Workspace } from "./workspace.js";
|
|
5
|
+
/** Why a write is refused on the server's view of a run's folder. */
|
|
6
|
+
export declare const SERVER_READS_ONLY = "the server reads a run's files; only its runner writes them";
|
|
7
|
+
export interface ServerRunWorkspaceOptions {
|
|
8
|
+
/** The server's data directory (Mode 1's run folders are under it). */
|
|
9
|
+
readonly data: string;
|
|
10
|
+
/** The server's seal key, which opens the Archil account key in Mode 2; undefined when it was started without one. */
|
|
11
|
+
readonly sealKey: Buffer | undefined;
|
|
12
|
+
/** Makes the Archil disk (default archilDisk): a test's fake. */
|
|
13
|
+
readonly makeDisk?: (options: ArchilDiskOptions) => ArchilDisk;
|
|
14
|
+
/** The server's environment: an ARCHIL_API_KEY there is the account key, over a saved one. */
|
|
15
|
+
readonly env?: KeyEnv;
|
|
16
|
+
}
|
|
17
|
+
/** `workspace` with its reads only: read, list, stat and grep pass through; everything else is refused. */
|
|
18
|
+
export declare function readOnlyWorkspace(workspace: Workspace): Workspace;
|
|
19
|
+
/**
|
|
20
|
+
* Run `runId`'s folder as the server reads it, read-only; null when there is no such run, or its folder is not there yet.
|
|
21
|
+
* In Mode 2, an Archil account key that is not saved, or a server with no seal key, is UNAVAILABLE in words that name
|
|
22
|
+
* what to save, never a value.
|
|
23
|
+
*/
|
|
24
|
+
export declare function serverRunWorkspace(store: Pick<Store, "runs" | "settings" | "sealedKeys">, runId: string, options: ServerRunWorkspaceOptions): Promise<Workspace | null>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// The server's read-only view of a run's folder: what the server reads a run's files through (its file routes), with no
|
|
2
|
+
// runner claim. Mode 1: the run's local folder (runFolder). Mode 2 (the server's Archil settings present): the run's
|
|
3
|
+
// folder on the server's Archil disk (runKey), its account key by the one resolver (archil-key.ts: the server's
|
|
4
|
+
// ARCHIL_API_KEY, else the sealed row), with no claim around it: no exec, no spill sweep, no mount credential, no mount.
|
|
5
|
+
//
|
|
6
|
+
// Read-only: read, list, stat and grep work as the run's own Workspace answers them (a link is never followed). Every
|
|
7
|
+
// call that would change the folder, run something in it, or put it in a computer is refused with REFUSED in plain words:
|
|
8
|
+
// only the run's runner writes its folder.
|
|
9
|
+
import { lstat } from "node:fs/promises";
|
|
10
|
+
import { loadArchilSettings } from "../archil-settings.js";
|
|
11
|
+
import { ArchilClaimRefused } from "./archil-claim.js";
|
|
12
|
+
import { archilDisk } from "./archil-disk.js";
|
|
13
|
+
import { archilApiKey } from "./archil-key.js";
|
|
14
|
+
import { archilWorkspace } from "./archil.js";
|
|
15
|
+
import { localWorkspace } from "./local.js";
|
|
16
|
+
import { runFolder, runKey } from "./paths.js";
|
|
17
|
+
import { WorkspaceError } from "./workspace.js";
|
|
18
|
+
/** Why a write is refused on the server's view of a run's folder. */
|
|
19
|
+
export const SERVER_READS_ONLY = "the server reads a run's files; only its runner writes them";
|
|
20
|
+
const refuse = async () => {
|
|
21
|
+
throw new WorkspaceError("REFUSED", SERVER_READS_ONLY);
|
|
22
|
+
};
|
|
23
|
+
const refusedProcesses = { start: refuse, read: refuse, write: refuse, signal: refuse, wait: refuse, list: refuse };
|
|
24
|
+
/** `workspace` with its reads only: read, list, stat and grep pass through; everything else is refused. */
|
|
25
|
+
export function readOnlyWorkspace(workspace) {
|
|
26
|
+
return {
|
|
27
|
+
read: (path, range) => workspace.read(path, range),
|
|
28
|
+
list: (dir) => workspace.list(dir),
|
|
29
|
+
stat: (path) => workspace.stat(path),
|
|
30
|
+
grep: (pattern, options) => workspace.grep(pattern, options),
|
|
31
|
+
write: refuse,
|
|
32
|
+
append: refuse,
|
|
33
|
+
mkdir: refuse,
|
|
34
|
+
remove: refuse,
|
|
35
|
+
exec: refuse,
|
|
36
|
+
process: refusedProcesses,
|
|
37
|
+
mountSpec: refuse,
|
|
38
|
+
attach: refuse,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Run `runId`'s folder as the server reads it, read-only; null when there is no such run, or its folder is not there yet.
|
|
43
|
+
* In Mode 2, an Archil account key that is not saved, or a server with no seal key, is UNAVAILABLE in words that name
|
|
44
|
+
* what to save, never a value.
|
|
45
|
+
*/
|
|
46
|
+
export async function serverRunWorkspace(store, runId, options) {
|
|
47
|
+
const run = await store.runs.get(runId);
|
|
48
|
+
if (run === undefined)
|
|
49
|
+
return null;
|
|
50
|
+
const settings = await loadArchilSettings(store);
|
|
51
|
+
let workspace;
|
|
52
|
+
if (settings === undefined) {
|
|
53
|
+
const folder = runFolder(options.data, run.agentId, runId);
|
|
54
|
+
const there = await lstat(folder).catch((error) => {
|
|
55
|
+
if (error?.code === "ENOENT" || error?.code === "ENOTDIR")
|
|
56
|
+
return undefined;
|
|
57
|
+
throw new WorkspaceError("UNAVAILABLE", `the server can't read this run's folder: ${error?.message ?? error}`, { cause: error });
|
|
58
|
+
});
|
|
59
|
+
if (!there?.isDirectory())
|
|
60
|
+
return null;
|
|
61
|
+
workspace = localWorkspace(folder);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// The account key by the one resolver, and the disk made with it as the claim makes it; no exec image, since the
|
|
65
|
+
// server's view runs nothing.
|
|
66
|
+
let disk;
|
|
67
|
+
try {
|
|
68
|
+
const { value } = await archilApiKey({ env: options.env ?? {}, keys: store.sealedKeys, sealKey: options.sealKey });
|
|
69
|
+
disk = (options.makeDisk ?? archilDisk)({ disk: settings.diskId, region: settings.region, s3BaseUrl: settings.s3Url, key: () => value });
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error instanceof ArchilClaimRefused)
|
|
73
|
+
throw new WorkspaceError("UNAVAILABLE", `the server can't read this run's files: ${error.message}`, { cause: error });
|
|
74
|
+
throw new WorkspaceError("UNAVAILABLE", `the server can't make this server's Archil disk: ${error?.message ?? error}`, { cause: error });
|
|
75
|
+
}
|
|
76
|
+
// A folder of the file API is there when its parent lists it (the root itself always stats as a folder).
|
|
77
|
+
const key = runKey(run.agentId, runId);
|
|
78
|
+
const cut = key.lastIndexOf("/");
|
|
79
|
+
if ((await archilWorkspace(disk, key.slice(0, cut)).stat(key.slice(cut + 1)))?.kind !== "dir")
|
|
80
|
+
return null;
|
|
81
|
+
workspace = archilWorkspace(disk, key);
|
|
82
|
+
}
|
|
83
|
+
return readOnlyWorkspace(workspace);
|
|
84
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { MountSpec } from "@parcha/agentrun-computer";
|
|
2
|
+
import type { AttachableComputer, MountCheck, Processes } from "./attach.js";
|
|
3
|
+
/** Why a workspace call failed. */
|
|
4
|
+
export type WorkspaceErrorCode =
|
|
5
|
+
/** The path, or the program exec was asked to run, is not there. */
|
|
6
|
+
"NOT_FOUND"
|
|
7
|
+
/** The path would leave the root: absolute, "..", a bad segment, or a symbolic link on the way. Nothing was touched. */
|
|
8
|
+
| "ESCAPE"
|
|
9
|
+
/** More than the call allows (a read past READ_MAX). */
|
|
10
|
+
| "TOO_LARGE"
|
|
11
|
+
/** The call ran past its deadline. exec reports its own deadline as `timedOut`, not as this. */
|
|
12
|
+
| "TIMEOUT"
|
|
13
|
+
/** The backend cannot answer: the root is gone, the disk is full or read-only, an I/O error. */
|
|
14
|
+
| "UNAVAILABLE"
|
|
15
|
+
/** The call is not allowed on what is there: a directory read as a file, a non-empty directory removed without
|
|
16
|
+
* `recursive`, a bad regex, or a method this backend does not have yet. */
|
|
17
|
+
| "REFUSED"
|
|
18
|
+
/** Something is in the way: a file where a directory has to be made. */
|
|
19
|
+
| "EXISTS";
|
|
20
|
+
export declare class WorkspaceError extends Error {
|
|
21
|
+
readonly code: WorkspaceErrorCode;
|
|
22
|
+
/** The relative path the call was about, when there is one. */
|
|
23
|
+
readonly path: string | undefined;
|
|
24
|
+
constructor(code: WorkspaceErrorCode, message: string, options?: {
|
|
25
|
+
path?: string;
|
|
26
|
+
cause?: unknown;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** What an exec whose signal aborted rejects with: the signal's reason, or an AbortError. */
|
|
30
|
+
export declare const abortError: (signal: AbortSignal | undefined) => unknown;
|
|
31
|
+
export declare const isWorkspaceError: (error: unknown, code?: WorkspaceErrorCode) => error is WorkspaceError;
|
|
32
|
+
/** Each code's one line, as the code's own words above say it, naming no path: what a person or a model reads after
|
|
33
|
+
* the code (workspaceErrorWords). */
|
|
34
|
+
export declare const WORKSPACE_ERRORS: Readonly<Record<WorkspaceErrorCode, string>>;
|
|
35
|
+
/** A failed call as words that name no path: a WorkspaceError's code and its line ("ESCAPE: the path would leave the
|
|
36
|
+
* root: …"), else undefined. */
|
|
37
|
+
export declare const workspaceErrorWords: (error: unknown) => string | undefined;
|
|
38
|
+
/** One entry of a directory. Only files and directories are listed: a pipe or a socket is left out. A symbolic link is
|
|
39
|
+
* left out by a backend that can tell (Local); a backend that can't tell a link from a file (Archil's file API) lists
|
|
40
|
+
* it as a file, and reading it fails UNAVAILABLE. `mtimeMs`: when it last changed, in milliseconds since the epoch, as
|
|
41
|
+
* Stat's. `unreadable`: a file this backend sees but cannot read (another user on this machine made it private), so a
|
|
42
|
+
* read of it is REFUSED; a backend with no such files (Archil's) never sets it. */
|
|
43
|
+
export type Entry = {
|
|
44
|
+
readonly name: string;
|
|
45
|
+
readonly kind: "file" | "dir";
|
|
46
|
+
readonly size: number;
|
|
47
|
+
readonly mtimeMs: number;
|
|
48
|
+
readonly unreadable?: true;
|
|
49
|
+
};
|
|
50
|
+
/** What is at a path, never following it: a symbolic link is "link"; a pipe, a socket or a device is "other". A
|
|
51
|
+
* folder's size is 0, as list says. A backend that cannot tell a link from a file (a disk's file API) says "file". */
|
|
52
|
+
export type Stat = {
|
|
53
|
+
readonly kind: "file" | "dir" | "link" | "other";
|
|
54
|
+
readonly size: number;
|
|
55
|
+
readonly mtimeMs: number;
|
|
56
|
+
};
|
|
57
|
+
/** One line grep found. `line` counts from 1; `text` is the line, cut at GREP_LINE_MAX characters. */
|
|
58
|
+
export type GrepMatch = {
|
|
59
|
+
readonly path: string;
|
|
60
|
+
readonly line: number;
|
|
61
|
+
readonly text: string;
|
|
62
|
+
};
|
|
63
|
+
/** What grep found, and whether it stopped early: at `max` matches, or at its time cap. */
|
|
64
|
+
export type GrepResult = {
|
|
65
|
+
readonly matches: readonly GrepMatch[];
|
|
66
|
+
readonly truncated: false | "max" | "time";
|
|
67
|
+
};
|
|
68
|
+
export type GrepOptions = {
|
|
69
|
+
/** The file or directory searched, relative to the root (default: the whole root). */
|
|
70
|
+
readonly path?: string;
|
|
71
|
+
/** Only files whose path matches: `*`, `**` and `?`. A glob with no "/" is matched against the file's name, one with
|
|
72
|
+
* a "/" against its path from the root. */
|
|
73
|
+
readonly glob?: string;
|
|
74
|
+
/** The most matches returned (default and ceiling GREP_MAX). */
|
|
75
|
+
readonly max?: number;
|
|
76
|
+
/** How long it searches before it stops and returns what it has, truncated "time" (default and ceiling
|
|
77
|
+
* GREP_TIME_MS). The deadline holds whatever the regex does: the search is stopped, not asked. */
|
|
78
|
+
readonly timeMs?: number;
|
|
79
|
+
};
|
|
80
|
+
export type ExecOptions = {
|
|
81
|
+
/** The directory it runs in, relative to the root (default: the root). Checked as every path is. */
|
|
82
|
+
readonly cwd?: string;
|
|
83
|
+
/** The whole environment: nothing is inherited, so no HOME and no PATH unless they are here. */
|
|
84
|
+
readonly env: Readonly<Record<string, string>>;
|
|
85
|
+
/** Bytes for its stdin (default: none, stdin at end of file). */
|
|
86
|
+
readonly stdin?: Uint8Array;
|
|
87
|
+
/** The deadline. At it, the whole process group is killed and `timedOut` is true. */
|
|
88
|
+
readonly timeoutMs: number;
|
|
89
|
+
/** The most bytes kept of stdout, and of stderr, each (default EXEC_OUTPUT_MAX). Past it the rest is read and
|
|
90
|
+
* dropped, and `truncated` is true. */
|
|
91
|
+
readonly maxOutput?: number;
|
|
92
|
+
/** Each piece of output as it comes, ALL of it, past maxOutput too (a caller can keep the end of a long output from
|
|
93
|
+
* it): the first maxOutput bytes of what it is given, joined per stream, are the result's stdout and stderr. A
|
|
94
|
+
* backend that cannot stream calls it once per stream, at the end, with everything. An error it throws is ignored. */
|
|
95
|
+
readonly onOutput?: (chunk: {
|
|
96
|
+
readonly stream: "stdout" | "stderr";
|
|
97
|
+
readonly data: Uint8Array;
|
|
98
|
+
}) => void;
|
|
99
|
+
/** Ends the call: the whole process group is killed, and exec rejects with the signal's reason (an AbortError). A
|
|
100
|
+
* signal already aborted runs nothing. */
|
|
101
|
+
readonly signal?: AbortSignal;
|
|
102
|
+
};
|
|
103
|
+
export type ExecResult = {
|
|
104
|
+
readonly stdout: Uint8Array;
|
|
105
|
+
readonly stderr: string;
|
|
106
|
+
/** Its exit code, or null when a signal ended it (the deadline's kill included). */
|
|
107
|
+
readonly code: number | null;
|
|
108
|
+
/** The signal that ended it, in Node's naming ("SIGTERM", "SIGSEGV"), or null when it exited on its own. At the
|
|
109
|
+
* deadline (`timedOut`) it is whatever signal ended the program. */
|
|
110
|
+
readonly signal: string | null;
|
|
111
|
+
readonly timedOut: boolean;
|
|
112
|
+
/** stdout or stderr went past `maxOutput`, and was cut. */
|
|
113
|
+
readonly truncated: boolean;
|
|
114
|
+
};
|
|
115
|
+
/** The most bytes one read returns (a read asking for more, or of a bigger file with no `length`, is TOO_LARGE). */
|
|
116
|
+
export declare const READ_MAX: number;
|
|
117
|
+
/** grep's default and its ceiling on matches. */
|
|
118
|
+
export declare const GREP_MAX = 1000;
|
|
119
|
+
/** How long one grep searches before it returns what it has (truncated "time"). */
|
|
120
|
+
export declare const GREP_TIME_MS = 10000;
|
|
121
|
+
/** A file bigger than this is skipped by grep. */
|
|
122
|
+
export declare const GREP_FILE_MAX: number;
|
|
123
|
+
/** The most characters of one matching line grep returns. */
|
|
124
|
+
export declare const GREP_LINE_MAX = 500;
|
|
125
|
+
/** exec's default cap on stdout, and on stderr, each. */
|
|
126
|
+
export declare const EXEC_OUTPUT_MAX: number;
|
|
127
|
+
/** A run's folder, or an agent's learning folder: every path is relative to its root. */
|
|
128
|
+
export interface Workspace {
|
|
129
|
+
/** The bytes of file `path`, or `length` of them from `offset` (a range past the end gives what is there). */
|
|
130
|
+
read(path: string, range?: {
|
|
131
|
+
readonly offset?: number;
|
|
132
|
+
readonly length?: number;
|
|
133
|
+
}): Promise<Uint8Array>;
|
|
134
|
+
/** File `path` replaced by `data` (a string is UTF-8), atomically and durably; its parent directories made. An
|
|
135
|
+
* existing file keeps its mode. */
|
|
136
|
+
write(path: string, data: Uint8Array | string): Promise<void>;
|
|
137
|
+
/** `data` added at the end of file `path`, durably; the file and its parents made when absent. A backend may split
|
|
138
|
+
* a large append into several (a disk API that takes a bounded size per call), so a reader during it can see part
|
|
139
|
+
* of `data` at the end; once it returns, all of it is there, in order. */
|
|
140
|
+
append(path: string, data: Uint8Array | string): Promise<void>;
|
|
141
|
+
/** What is at `path`, never following it (a link as its last part is "link"; one on the way is ESCAPE), or undefined
|
|
142
|
+
* when nothing is there (a folder on the way not there, or a file in its place, included). "" is the root. */
|
|
143
|
+
stat(path: string): Promise<Stat | undefined>;
|
|
144
|
+
/** The files and directories in directory `dir` ("" or "." for the root), sorted by name. */
|
|
145
|
+
list(dir: string): Promise<Entry[]>;
|
|
146
|
+
/** Directory `dir` made, with its parents (mkdir -p); one already there is fine. */
|
|
147
|
+
mkdir(dir: string): Promise<void>;
|
|
148
|
+
/** Lines matching the regex `pattern` (JavaScript syntax), in files under `options.path`, binary files skipped. */
|
|
149
|
+
grep(pattern: string, options?: GrepOptions): Promise<GrepResult>;
|
|
150
|
+
/** `path` removed: a file, an empty directory, or with `recursive` a whole tree (a link inside it is removed, never
|
|
151
|
+
* followed). Absent is NOT_FOUND unless `force`. The root itself is never removed. */
|
|
152
|
+
remove(path: string, options?: {
|
|
153
|
+
readonly recursive?: boolean;
|
|
154
|
+
readonly force?: boolean;
|
|
155
|
+
}): Promise<void>;
|
|
156
|
+
/** `argv` run (a program and its arguments, not a shell line: bash is ["bash", "-lc", line]) in its own process
|
|
157
|
+
* group, stdin and stdout as bytes. Nothing it starts outlives it: when it exits, or at the deadline, the group is
|
|
158
|
+
* killed. A nonzero exit is a result, not an error; a program that is not there is NOT_FOUND. */
|
|
159
|
+
exec(argv: readonly string[], options: ExecOptions): Promise<ExecResult>;
|
|
160
|
+
/** Background programs: the computer's process calls, which the background tools make through the Workspace. With
|
|
161
|
+
* no computer attached, every call is REFUSED with cause "no-computer" (attach.ts NO_COMPUTER); the words a person
|
|
162
|
+
* reads are the background tool's. */
|
|
163
|
+
readonly process: Processes;
|
|
164
|
+
/** What a computer mounts at /workspace to hold this Workspace's folder: the caller puts it in the computer's spec. */
|
|
165
|
+
mountSpec(): Promise<MountSpec>;
|
|
166
|
+
/** This Workspace inside `computer`, once the computer's read-back shows it mounts mountSpec() at /workspace: file
|
|
167
|
+
* calls and exec go to its computerd client, and `process` is the computer's (attach.ts). */
|
|
168
|
+
attach(computer: AttachableComputer, check: MountCheck): Promise<Workspace>;
|
|
169
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// The Workspace: the one way serve touches a run's files, or an agent's learning folder. One Workspace is scoped to ONE
|
|
2
|
+
// root folder and takes paths relative to it only (paths.ts). Two backends answer it: Local (a folder on this machine,
|
|
3
|
+
// local.ts) and, next, Archil (the owner's disk through its file API and serverless exec). Nothing on main uses it yet:
|
|
4
|
+
// the writers move onto it in one cutover.
|
|
5
|
+
//
|
|
6
|
+
// Rules every backend keeps:
|
|
7
|
+
// - Every write is durable on return: write, append, mkdir and remove return only once what they did would survive a
|
|
8
|
+
// crash of the machine. write is atomic too: a reader, or a crash, sees the old file or the new one, never half.
|
|
9
|
+
// - A path is relative, normalized, and never leaves the root: an absolute path, "..", ".", an empty segment, a NUL or a
|
|
10
|
+
// backslash is ESCAPE, and so is a symbolic link anywhere on the way, the last part included. Nothing is followed.
|
|
11
|
+
// - The port does not serialize. Two calls on one path race as two processes would; callers own their ordering (the
|
|
12
|
+
// learning queue keeps one per agent, with git's update-ref compare-and-swap as its fence). A backend serializes only
|
|
13
|
+
// what its service requires (Archil: an exec's checkout of the folder blocks writes, so execs run one at a time and
|
|
14
|
+
// writes wait for them); callers' queues still own their own ordering.
|
|
15
|
+
export class WorkspaceError extends Error {
|
|
16
|
+
code;
|
|
17
|
+
/** The relative path the call was about, when there is one. */
|
|
18
|
+
path;
|
|
19
|
+
constructor(code, message, options) {
|
|
20
|
+
super(message, options?.cause === undefined ? undefined : { cause: options.cause });
|
|
21
|
+
this.name = "WorkspaceError";
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.path = options?.path;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** What an exec whose signal aborted rejects with: the signal's reason, or an AbortError. */
|
|
27
|
+
export const abortError = (signal) => signal?.reason ?? new DOMException("This operation was aborted", "AbortError");
|
|
28
|
+
export const isWorkspaceError = (error, code) => error instanceof WorkspaceError && (code === undefined || error.code === code);
|
|
29
|
+
/** Each code's one line, as the code's own words above say it, naming no path: what a person or a model reads after
|
|
30
|
+
* the code (workspaceErrorWords). */
|
|
31
|
+
export const WORKSPACE_ERRORS = {
|
|
32
|
+
NOT_FOUND: "the path is not there",
|
|
33
|
+
ESCAPE: "the path would leave the root: absolute, \"..\", a bad segment, or a symbolic link on the way",
|
|
34
|
+
TOO_LARGE: "more than the call allows",
|
|
35
|
+
TIMEOUT: "the call ran past its deadline",
|
|
36
|
+
UNAVAILABLE: "the backend cannot answer: the root is gone, the disk is full or read-only, an I/O error",
|
|
37
|
+
REFUSED: "the call is not allowed on what is there",
|
|
38
|
+
EXISTS: "something is in the way: a file where a directory has to be made",
|
|
39
|
+
};
|
|
40
|
+
/** A failed call as words that name no path: a WorkspaceError's code and its line ("ESCAPE: the path would leave the
|
|
41
|
+
* root: …"), else undefined. */
|
|
42
|
+
export const workspaceErrorWords = (error) => isWorkspaceError(error) ? `${error.code}: ${WORKSPACE_ERRORS[error.code]}` : undefined;
|
|
43
|
+
/** The most bytes one read returns (a read asking for more, or of a bigger file with no `length`, is TOO_LARGE). */
|
|
44
|
+
export const READ_MAX = 64 * 1024 * 1024;
|
|
45
|
+
/** grep's default and its ceiling on matches. */
|
|
46
|
+
export const GREP_MAX = 1000;
|
|
47
|
+
/** How long one grep searches before it returns what it has (truncated "time"). */
|
|
48
|
+
export const GREP_TIME_MS = 10_000;
|
|
49
|
+
/** A file bigger than this is skipped by grep. */
|
|
50
|
+
export const GREP_FILE_MAX = 8 * 1024 * 1024;
|
|
51
|
+
/** The most characters of one matching line grep returns. */
|
|
52
|
+
export const GREP_LINE_MAX = 500;
|
|
53
|
+
/** exec's default cap on stdout, and on stderr, each. */
|
|
54
|
+
export const EXEC_OUTPUT_MAX = 16 * 1024 * 1024;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import type { ToolRegistration } from "@earendil-works/pi-durable";
|
|
2
|
-
|
|
3
|
-
* `text` with the workspace's absolute path taken out: `<work>/notes/a.md` reads `notes/a.md`, the workspace itself `.`,
|
|
4
|
-
* a path beside it `../x` (pi's tools resolve a relative path before they refuse it), and pi's refusal ("<path>: outside
|
|
5
|
-
* the workspace <work>") names no directory. `works` is the workspace as the environment names it and as the kernel
|
|
6
|
-
* resolves it (they differ under a symlinked directory). For a refusal, an error, and a write's or edit's result; a
|
|
7
|
-
* read's result is the file's own text and is never changed.
|
|
8
|
-
*/
|
|
9
|
-
export declare function workspaceRelative(text: string, works: readonly string[]): string;
|
|
2
|
+
export { realOf, workspaceRelative } from "./workspace/paths.js";
|
|
10
3
|
/**
|
|
11
4
|
* Refuses `given`, a path a call gave that leaves the workspace, in the one words every refusal uses:
|
|
12
5
|
* `<given>: outside the workspace`, and no other path (not the workspace, a box's work dir, or where it resolves). It is
|
|
@@ -23,8 +16,6 @@ export declare function refuseOutsideWorkspace(given: string): never;
|
|
|
23
16
|
* already named (`refuseOutsideWorkspace`), every other error, and every result are the tool's own.
|
|
24
17
|
*/
|
|
25
18
|
export declare function asGivenRefusals(tools: readonly ToolRegistration[]): ToolRegistration[];
|
|
26
|
-
/** `path` as the kernel resolves it, or itself when it cannot be resolved. */
|
|
27
|
-
export declare const realOf: (path: string) => string;
|
|
28
19
|
/** How a run's rows name a file path, a whole path (never a text): one in the run's directory relative to its workspace
|
|
29
20
|
* (`<run>/work`: `hello.md`, `.`, `../work 2024/a.md`, `..`), and any other path, or one that is not absolute, exactly
|
|
30
21
|
* as given. Checked against the workspace as serve names it and as the kernel resolves it (a harness's CLI sends the
|