@parcha/agentrun-serve 0.1.0-beta.31 → 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 +422 -0
- package/NOTICE +18 -0
- package/README.md +887 -241
- 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 +5 -3
- package/dist/agents.js +37 -17
- package/dist/app.d.ts +2 -4
- package/dist/app.js +207 -92
- 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.js +28 -9
- package/dist/bounds.d.ts +26 -0
- package/dist/bounds.js +137 -0
- package/dist/box-egress-vm.d.ts +2 -1
- package/dist/box-egress-vm.js +20 -6
- package/dist/box-egress.d.ts +16 -6
- 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.js +28 -1
- package/dist/box-relay.d.ts +2 -0
- package/dist/box-relay.js +2 -2
- package/dist/boxes.d.ts +13 -1
- package/dist/boxes.js +37 -3
- 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 +272 -62
- package/dist/cap.js +599 -189
- package/dist/cli.js +201 -17
- 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 +28 -1
- package/dist/decisions.js +63 -6
- 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 -35
- package/dist/files.js +9 -120
- 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 +9 -42
- package/dist/grade.js +42 -228
- 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 +530 -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 +4 -3
- package/dist/host-check.js +5 -4
- 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/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 +22 -9
- package/dist/learn/grade.js +95 -49
- 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 +70 -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 +5 -1
- package/dist/learn/skills.js +5 -4
- package/dist/learned-workflow.d.ts +12 -2
- package/dist/learned-workflow.js +9 -5
- package/dist/learning-routes.d.ts +88 -41
- package/dist/learning-routes.js +340 -539
- package/dist/learning-run.d.ts +60 -53
- package/dist/learning-run.js +181 -224
- package/dist/learning-words.d.ts +3 -5
- package/dist/learning-words.js +3 -5
- package/dist/learning.d.ts +177 -112
- package/dist/learning.js +289 -380
- 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 +46 -13
- package/dist/mcp-gateway.js +145 -45
- package/dist/mcp-meta.d.ts +3 -0
- package/dist/mcp-meta.js +14 -2
- 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 +180 -50
- package/dist/mcp-servers.js +284 -321
- 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 +919 -108
- package/dist/owner.d.ts +46 -10
- package/dist/owner.js +123 -43
- package/dist/page.d.ts +10 -0
- package/dist/page.js +27 -4
- 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 +15 -13
- package/dist/place.js +25 -15
- package/dist/port-models.d.ts +53 -0
- package/dist/port-models.js +93 -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 +78 -17
- 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 +30 -5
- package/dist/runnable.js +149 -72
- 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 +351 -220
- package/dist/runs.js +1570 -540
- 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 +7 -0
- package/dist/secrets.js +17 -2
- 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 +142 -73
- package/dist/server.js +1683 -596
- 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 +166 -35
- package/dist/tool-gate.js +411 -91
- package/dist/tool-keys-store.d.ts +110 -0
- package/dist/tool-keys-store.js +291 -0
- package/dist/tool-keys.d.ts +25 -12
- package/dist/tool-keys.js +20 -2
- package/dist/tool-plane.d.ts +113 -27
- package/dist/tool-plane.js +229 -76
- 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 +337 -61
- 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 +53 -18
- 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 -21
- 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-CnJBf7Lc.js +0 -486
- 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,218 @@
|
|
|
1
|
+
// Workspace exec on an Archil disk: one serverless exec call (archil-disk.ts) that mounts the workspace's folder and
|
|
2
|
+
// its exec spill folder, and nothing else of the disk. Taken from pi-transport's box/archil-exec.ts, which has no
|
|
3
|
+
// caller: the call, its 300 s cut, the hold on the folder with a queue, and the mapping of the exit and of the deadline.
|
|
4
|
+
// The rest (boxes, records, sweeps) is not.
|
|
5
|
+
//
|
|
6
|
+
// Archil runs one shell line in a fresh container with two folders of the disk, each a mount's `subdirectory`, held for
|
|
7
|
+
// the line (no other client writes in them meanwhile; a second one waits up to queueMs):
|
|
8
|
+
// - /mnt/archil/work: the workspace's folder, where the program runs;
|
|
9
|
+
// - /mnt/archil/out: its spill folder, BESIDE it and never inside it (archil.ts spillFolderOf), which holds this call's
|
|
10
|
+
// stdin and output files. The workspace's file calls are rooted at the folder, so they never meet them.
|
|
11
|
+
// The rest of the owner's disk (other runs, the learning folders) is not in the container at all. Archil answers once
|
|
12
|
+
// the line ended, stdout and stderr as text, and cuts that answer somewhere below 14 MB (measured live), so the
|
|
13
|
+
// program's output never rides in it: the line spills it to files that are read back through the file API.
|
|
14
|
+
// The Workspace port wants argv, the whole environment, binary stdin and stdout, a deadline that kills everything the
|
|
15
|
+
// program started, and capped output, so the line this module writes:
|
|
16
|
+
// - walks to the cwd one folder at a time from the mount, refusing a symbolic link on the way (only an exec can make
|
|
17
|
+
// one; the file API makes none);
|
|
18
|
+
// - takes stdin from <out>/<name>.in, which the caller put there, because a call's command line has a length limit and
|
|
19
|
+
// stdin has none;
|
|
20
|
+
// - runs the program as `env -i -- NAME=value… argv…` under GNU timeout, so nothing of the container's environment
|
|
21
|
+
// leaks in, in timeout's process group, which is killed when the program ends or at its deadline;
|
|
22
|
+
// - drains stdout and stderr through FIFOs into <out>/<name>.out and <name>.err, keeping one byte past the cap of each
|
|
23
|
+
// (so a cut is seen) and discarding the rest as it comes, so a noisy program never fills the disk;
|
|
24
|
+
// - runs the program from a few lines of perl (perl-base is in every Debian-family image) that write its raw wait
|
|
25
|
+
// status, because through timeout a program killed by a signal and one that exits 128+n look the same;
|
|
26
|
+
// - answers, in stdout, ONE status line carrying a marker made for this call. Whatever else is in the call's stdout or
|
|
27
|
+
// stderr (a platform's message) is not read.
|
|
28
|
+
// Then the output files are read back with ranged GETs, up to the cap; the caller deletes all three files on every path
|
|
29
|
+
// (archil.ts), and sweep() clears what a killed exec left.
|
|
30
|
+
// A backend without streaming: onOutput gets each stream once, whole, when the line has ended.
|
|
31
|
+
//
|
|
32
|
+
// Limit, stated (not measured): whether the wait for the folders' hold counts toward Archil's 300 s (a 290 s command
|
|
33
|
+
// was not cut, measured live).
|
|
34
|
+
import { randomBytes } from "node:crypto";
|
|
35
|
+
import { WorkspaceError } from "./workspace.js";
|
|
36
|
+
/** Archil cuts an exec call at 300 s. */
|
|
37
|
+
export const MAX_EXEC_MS = 300_000;
|
|
38
|
+
/** The longest deadline a command may ask for: 5 s of the 300 are the line's own (its walk, its drains, its answer).
|
|
39
|
+
* Anything longer is refused, not cut. */
|
|
40
|
+
export const COMMAND_MAX_MS = 295_000;
|
|
41
|
+
/** Where the folder is mounted in the container: /mnt/archil/<EXEC_MOUNT>. */
|
|
42
|
+
export const EXEC_MOUNT = "work";
|
|
43
|
+
/** Where the spill folder is mounted in the container: /mnt/archil/<SPILL_MOUNT>. */
|
|
44
|
+
export const SPILL_MOUNT = "out";
|
|
45
|
+
/** How long an exec waits for another client's hold on the folders. */
|
|
46
|
+
export const DEFAULT_QUEUE_MS = 60_000;
|
|
47
|
+
/** How long after the program's deadline this side stops waiting for a call that never answers (boot and mount
|
|
48
|
+
* included). */
|
|
49
|
+
const CALL_GRACE_MS = 60_000;
|
|
50
|
+
const MOUNT_DIR = `/mnt/archil/${EXEC_MOUNT}`;
|
|
51
|
+
const SPILL_DIR = `/mnt/archil/${SPILL_MOUNT}`;
|
|
52
|
+
/** `text` in single quotes, for the shell. */
|
|
53
|
+
export const quote = (text) => `'${text.replace(/'/g, `'\\''`)}'`;
|
|
54
|
+
/** A name for one exec's files in the spill folder: <name>.in, <name>.out, <name>.err. */
|
|
55
|
+
export const spillName = () => `x${randomBytes(8).toString("hex")}`;
|
|
56
|
+
/** The keys of one exec's files, in spill folder `folder`. */
|
|
57
|
+
export const spillKeys = (folder, name) => ({ in: `${folder}/${name}.in`, out: `${folder}/${name}.out`, err: `${folder}/${name}.err` });
|
|
58
|
+
/** The program's runner: stderr to the file in its first argument, the program run, its raw wait status written to the
|
|
59
|
+
* file in its second, and the same exit a shell would give. No single quote in it: it rides in one. */
|
|
60
|
+
const RUNNER = [
|
|
61
|
+
`open(STDERR, ">", shift) or exit 126;`,
|
|
62
|
+
`my $s = shift;`,
|
|
63
|
+
`system { $ARGV[0] } @ARGV;`,
|
|
64
|
+
`my $w = $? == -1 ? 127 << 8 : $?;`,
|
|
65
|
+
`if (open(my $f, ">", $s)) { print $f $w; close $f; }`,
|
|
66
|
+
`exit($w & 127 ? 128 + ($w & 127) : $w >> 8);`,
|
|
67
|
+
].join(" ");
|
|
68
|
+
/** The shell line one exec call runs (POSIX sh; GNU timeout, perl, mkfifo, head and mktemp in the image). `mark` is
|
|
69
|
+
* this call's marker: the line's answer is found by it, whatever else the call's stdout holds. */
|
|
70
|
+
export function execLine(job, mark) {
|
|
71
|
+
const cap = job.maxOutput + 1;
|
|
72
|
+
// At least a millisecond: timeout reads 0 as no deadline at all.
|
|
73
|
+
const seconds = (Math.max(1, Math.ceil(Math.min(job.timeoutMs, COMMAND_MAX_MS))) / 1000).toFixed(3);
|
|
74
|
+
const out = quote(`${SPILL_DIR}/${job.name}.out`);
|
|
75
|
+
const err = quote(`${SPILL_DIR}/${job.name}.err`);
|
|
76
|
+
const lines = [
|
|
77
|
+
`d=$(mktemp -d 2>/dev/null) || { echo '${mark} notmp'; exit 0; }`,
|
|
78
|
+
`s() { echo "${mark} $1"; rm -rf -- "$d"; exit 0; }`,
|
|
79
|
+
`{ command -v timeout && command -v perl && command -v mkfifo && command -v head; } >/dev/null 2>&1 || s notools`,
|
|
80
|
+
`[ -d ${quote(SPILL_DIR)} ] || s noroot`,
|
|
81
|
+
`cd -- ${quote(MOUNT_DIR)} 2>/dev/null || s noroot`,
|
|
82
|
+
];
|
|
83
|
+
for (const segment of job.cwd) {
|
|
84
|
+
const name = quote(segment);
|
|
85
|
+
lines.push(`[ -L ${name} ] && s link`, `[ -d ${name} ] || { [ -e ${name} ] && s notdir; s nocwd; }`, `cd -- ${name} 2>/dev/null || s nocwd`);
|
|
86
|
+
}
|
|
87
|
+
let input = "/dev/null";
|
|
88
|
+
if (job.stdin) {
|
|
89
|
+
input = quote(`${SPILL_DIR}/${job.name}.in`);
|
|
90
|
+
lines.push(`[ -f ${input} ] || s nostdin`);
|
|
91
|
+
}
|
|
92
|
+
const path = job.env.PATH;
|
|
93
|
+
lines.push(`( ${path === undefined ? "unset PATH" : `PATH=${quote(path)}`}; command -v -- ${quote(job.argv[0])} ) >/dev/null 2>&1 || s noprog`);
|
|
94
|
+
const assignments = Object.entries(job.env).map(([name, value]) => quote(`${name}=${value}`));
|
|
95
|
+
// The drains first: each keeps cap+1 bytes in its spill file and reads the rest away. timeout leads its own process
|
|
96
|
+
// group; the runner sends the program's stderr to its FIFO, so timeout's notice that it sent a signal ("why") tells a
|
|
97
|
+
// deadline from a program that exits 124 by itself, and the raw status ("status") tells a signal from an exit of 128+n.
|
|
98
|
+
lines.push(`mkfifo "$d/o" "$d/e" 2>/dev/null || s notmp`, `{ head -c ${cap} >${out}; cat >/dev/null; } <"$d/o" & r1=$!`, `{ head -c ${cap} >${err}; cat >/dev/null; } <"$d/e" & r2=$!`, `LC_ALL=C timeout --verbose -k 1 ${seconds} perl -e '${RUNNER}' "$d/e" "$d/status" env -i -- ${[...assignments, ...job.argv.map(quote)].join(" ")} <${input} >"$d/o" 2>"$d/why" &`, `p=$!`, `wait "$p"; c=$?`, `kill -s KILL -- "-$p" 2>/dev/null`,
|
|
99
|
+
// A drain still open after 2 s is held by something that left the group, or by a runner that never opened its FIFO.
|
|
100
|
+
`( sleep 2; kill -s KILL $r1 $r2 ) >/dev/null 2>&1 & k=$!`, `wait $r1 $r2 2>/dev/null; kill -s KILL $k 2>/dev/null`, `t=0; grep -q 'sending signal' "$d/why" 2>/dev/null && t=1`, `w=-; [ -s "$d/status" ] && w=$(cat "$d/status")`, `echo "${mark} ran $c $t $w"`, `rm -rf -- "$d"`);
|
|
101
|
+
return lines.join("\n");
|
|
102
|
+
}
|
|
103
|
+
/** Linux's signal names by number (the container's numbering, whatever this machine's is). */
|
|
104
|
+
const LINUX_SIGNALS = {
|
|
105
|
+
1: "SIGHUP", 2: "SIGINT", 3: "SIGQUIT", 4: "SIGILL", 5: "SIGTRAP", 6: "SIGABRT", 7: "SIGBUS", 8: "SIGFPE", 9: "SIGKILL",
|
|
106
|
+
10: "SIGUSR1", 11: "SIGSEGV", 12: "SIGUSR2", 13: "SIGPIPE", 14: "SIGALRM", 15: "SIGTERM", 16: "SIGSTKFLT", 17: "SIGCHLD",
|
|
107
|
+
18: "SIGCONT", 19: "SIGSTOP", 20: "SIGTSTP", 21: "SIGTTIN", 22: "SIGTTOU", 23: "SIGURG", 24: "SIGXCPU", 25: "SIGXFSZ",
|
|
108
|
+
26: "SIGVTALRM", 27: "SIGPROF", 28: "SIGWINCH", 29: "SIGIO", 30: "SIGPWR", 31: "SIGSYS",
|
|
109
|
+
};
|
|
110
|
+
/** What the line answered: the LAST line carrying `mark` in the call's stdout (the line answers last, so a line the
|
|
111
|
+
* program printed before it cannot stand in for it), or undefined when there is none. */
|
|
112
|
+
export function parseExec(stdout, mark) {
|
|
113
|
+
const line = stdout.split("\n").findLast((candidate) => candidate.startsWith(`${mark} `));
|
|
114
|
+
if (line === undefined)
|
|
115
|
+
return undefined;
|
|
116
|
+
const head = new RegExp(`^${mark} (ran|noroot|link|notdir|nocwd|nostdin|noprog|notmp|notools)(?: (\\d+) ([01]) (-|\\d+))?$`).exec(line);
|
|
117
|
+
if (head === null)
|
|
118
|
+
return undefined;
|
|
119
|
+
const status = head[1];
|
|
120
|
+
if (status !== "ran")
|
|
121
|
+
return { status };
|
|
122
|
+
if (head[2] === undefined)
|
|
123
|
+
return undefined;
|
|
124
|
+
const raw = head[4] === "-" ? undefined : Number(head[4]);
|
|
125
|
+
const signal = raw !== undefined && (raw & 127) !== 0 ? LINUX_SIGNALS[raw & 127] ?? `signal ${raw & 127}` : undefined;
|
|
126
|
+
return { status, code: Number(head[2]), timedOut: head[3] === "1", signal };
|
|
127
|
+
}
|
|
128
|
+
const show = (segments) => JSON.stringify(segments.length === 0 ? "." : segments.join("/"));
|
|
129
|
+
const describe = (error) => String(error?.message ?? error).replace(/\s+/g, " ").slice(0, 300);
|
|
130
|
+
/** Spill file `key` read back, at most `cap` + 1 bytes (one past the cap, so a cut is seen); empty when it is not
|
|
131
|
+
* there or holds nothing. */
|
|
132
|
+
async function readSpill(disk, key, cap) {
|
|
133
|
+
try {
|
|
134
|
+
const answer = await disk.getRange(key, `bytes=0-${cap}`);
|
|
135
|
+
if (answer.status === 416)
|
|
136
|
+
return new Uint8Array(0);
|
|
137
|
+
return answer.body;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
if (error?.status === 404)
|
|
141
|
+
return new Uint8Array(0);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/** `job` run by one exec call on `disk`. A nonzero exit is a result; what kept the program from running is an error.
|
|
146
|
+
* The spill files are the caller's to delete (on every path). */
|
|
147
|
+
export async function archilExec(disk, job) {
|
|
148
|
+
const path = job.cwd.join("/");
|
|
149
|
+
const mark = `agentrun-exec-${randomBytes(6).toString("hex")}`;
|
|
150
|
+
let timer;
|
|
151
|
+
const deadline = Math.min(job.timeoutMs, COMMAND_MAX_MS) + CALL_GRACE_MS;
|
|
152
|
+
const gaveUp = new Promise((_, reject) => {
|
|
153
|
+
timer = setTimeout(() => reject(new WorkspaceError("TIMEOUT", `the Archil exec did not answer in ${deadline} ms (it may still be running, holding the folder)`, { path })), deadline);
|
|
154
|
+
});
|
|
155
|
+
let answer;
|
|
156
|
+
const started = Date.now();
|
|
157
|
+
try {
|
|
158
|
+
const request = {
|
|
159
|
+
mounts: { [EXEC_MOUNT]: job.root, [SPILL_MOUNT]: job.spill }, queueMs: job.queueMs, command: execLine(job, mark),
|
|
160
|
+
...(job.image === undefined ? {} : { image: job.image }),
|
|
161
|
+
};
|
|
162
|
+
answer = await Promise.race([disk.exec(request), gaveUp]);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
if (error instanceof WorkspaceError)
|
|
166
|
+
throw error;
|
|
167
|
+
const status = error?.status;
|
|
168
|
+
// A 400 is a mount Archil refused (a folder missing, or held by another client past the queue's wait): its own
|
|
169
|
+
// words say which.
|
|
170
|
+
const why = status === 400 ? "Archil refused to mount the exec's folders"
|
|
171
|
+
: status === 401 || status === 403 ? "Archil refused the key, or the account's exec allowance is spent"
|
|
172
|
+
: "the Archil exec failed";
|
|
173
|
+
throw new WorkspaceError("UNAVAILABLE", `${why}: ${describe(error)}`, { path, cause: error });
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
clearTimeout(timer);
|
|
177
|
+
}
|
|
178
|
+
// The status line is the program's own word as much as the line's (it runs as the same user), but not the clock: a
|
|
179
|
+
// deadline is believed only if the call lasted that long.
|
|
180
|
+
const lasted = Date.now() - started;
|
|
181
|
+
const parsed = parseExec(answer.stdout, mark);
|
|
182
|
+
if (parsed === undefined) {
|
|
183
|
+
throw new WorkspaceError("UNAVAILABLE", `the Archil exec's answer does not hold its line's (exit ${answer.exitCode}): ${describe(answer.stderr || answer.stdout)}`, { path });
|
|
184
|
+
}
|
|
185
|
+
switch (parsed.status) {
|
|
186
|
+
case "ran": {
|
|
187
|
+
const keys = spillKeys(job.spill, job.name);
|
|
188
|
+
let out;
|
|
189
|
+
let err;
|
|
190
|
+
try {
|
|
191
|
+
[out, err] = await Promise.all([readSpill(disk, keys.out, job.maxOutput), readSpill(disk, keys.err, job.maxOutput)]);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
throw new WorkspaceError("UNAVAILABLE", `the Archil exec ran, but its output could not be read back: ${describe(error)}`, { path, cause: error });
|
|
195
|
+
}
|
|
196
|
+
const truncated = out.length > job.maxOutput || err.length > job.maxOutput;
|
|
197
|
+
const timedOut = parsed.timedOut && lasted >= Math.min(job.timeoutMs, COMMAND_MAX_MS);
|
|
198
|
+
return {
|
|
199
|
+
stdout: out.subarray(0, job.maxOutput),
|
|
200
|
+
stderr: Buffer.from(err.subarray(0, job.maxOutput)).toString("utf8"),
|
|
201
|
+
// null whenever a signal ended it: its own, or the deadline's kill. The signal is said in Node's naming
|
|
202
|
+
// ("SIGSEGV"), null when it exited on its own; at the deadline, whatever signal ended it.
|
|
203
|
+
code: timedOut || parsed.signal !== undefined ? null : parsed.code,
|
|
204
|
+
signal: parsed.signal ?? null,
|
|
205
|
+
timedOut,
|
|
206
|
+
truncated,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
case "link": throw new WorkspaceError("ESCAPE", `${show(job.cwd)} has a symbolic link on the way, and a workspace follows none`, { path });
|
|
210
|
+
case "nocwd": throw new WorkspaceError("NOT_FOUND", `${show(job.cwd)} is not there`, { path });
|
|
211
|
+
case "notdir": throw new WorkspaceError("REFUSED", `${show(job.cwd)} is not a directory`, { path });
|
|
212
|
+
case "noprog": throw new WorkspaceError("NOT_FOUND", `${JSON.stringify(job.argv[0])} is not a program here (PATH ${JSON.stringify(job.env.PATH ?? "")})`, { path });
|
|
213
|
+
case "noroot": throw new WorkspaceError("UNAVAILABLE", `the workspace's folder ${job.root} or its spill folder was not mounted`, { path });
|
|
214
|
+
case "nostdin": throw new WorkspaceError("UNAVAILABLE", "the exec's stdin did not reach the container", { path });
|
|
215
|
+
case "notmp": throw new WorkspaceError("UNAVAILABLE", "the exec's container has no temporary folder", { path });
|
|
216
|
+
case "notools": throw new WorkspaceError("UNAVAILABLE", "the exec's image lacks timeout, perl, mkfifo or head", { path });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { KeyEnv } from "../key-meta.js";
|
|
2
|
+
import type { SealedKeys } from "../store/store.js";
|
|
3
|
+
/** The environment variable that sets the account key. */
|
|
4
|
+
export declare const ARCHIL_API_KEY_ENV = "ARCHIL_API_KEY";
|
|
5
|
+
export interface ArchilKeyOptions {
|
|
6
|
+
/** The server's environment. */
|
|
7
|
+
readonly env?: KeyEnv;
|
|
8
|
+
/** The store's sealed_keys rows. */
|
|
9
|
+
readonly keys: Pick<SealedKeys, "get">;
|
|
10
|
+
/** The server's seal key; undefined when it was started without one. */
|
|
11
|
+
readonly sealKey: Buffer | undefined;
|
|
12
|
+
}
|
|
13
|
+
/** The account key and where it came from. */
|
|
14
|
+
export declare function archilApiKey(options: ArchilKeyOptions): Promise<{
|
|
15
|
+
value: string;
|
|
16
|
+
source: "env" | "console";
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The Archil account key, resolved one way for every reader: the Archil routes' test, the server's read-only view of a
|
|
2
|
+
// run's folder (server-run-workspace.ts) and the claim with its per-run mount credential (archil-claim.ts). The server's
|
|
3
|
+
// environment first: an ARCHIL_API_KEY variable, not empty, wins (source "env", the secrets plan's rule 4). Else the
|
|
4
|
+
// sealed "archil.api_key" row, opened with the seal key (source "console"). A key that cannot be had is refused in words
|
|
5
|
+
// naming what to save, never a value. The environment is passed in: process.env is never read here.
|
|
6
|
+
import { ARCHIL_API_KEY_ROW } from "../archil-settings.js";
|
|
7
|
+
import { envValue } from "../key-meta.js";
|
|
8
|
+
import { sealedAt, unsealColumn } from "../store/seal.js";
|
|
9
|
+
import { ArchilClaimRefused } from "./archil-claim.js";
|
|
10
|
+
/** The environment variable that sets the account key. */
|
|
11
|
+
export const ARCHIL_API_KEY_ENV = "ARCHIL_API_KEY";
|
|
12
|
+
/** The account key and where it came from. */
|
|
13
|
+
export async function archilApiKey(options) {
|
|
14
|
+
const fromEnv = envValue(options.env ?? {}, ARCHIL_API_KEY_ENV);
|
|
15
|
+
if (fromEnv !== undefined)
|
|
16
|
+
return { value: fromEnv.trim(), source: "env" };
|
|
17
|
+
const { sealKey } = options;
|
|
18
|
+
if (sealKey === undefined) {
|
|
19
|
+
throw new ArchilClaimRefused(`This server was started without its seal key, so it can't open the saved ${ARCHIL_API_KEY_ROW} key: start it with the key it keeps, or set ${ARCHIL_API_KEY_ENV}.`);
|
|
20
|
+
}
|
|
21
|
+
const sealed = await options.keys.get(ARCHIL_API_KEY_ROW);
|
|
22
|
+
if (sealed === undefined)
|
|
23
|
+
throw new ArchilClaimRefused(`no ${ARCHIL_API_KEY_ROW} key is saved on this server: save ${ARCHIL_API_KEY_ENV} in the server's Archil settings (PUT /v2/workspace/archil), or set it in the server's environment.`);
|
|
24
|
+
try {
|
|
25
|
+
return { value: unsealColumn(sealKey, sealedAt.sealedKey(ARCHIL_API_KEY_ROW), sealed).toString("utf8").trim(), source: "console" };
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
throw new ArchilClaimRefused(`the saved ${ARCHIL_API_KEY_ROW} key does not open under this server's seal key (it was saved under another key, or for another row): save it again.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** The control plane of each Archil region, as Archil's SDK (`disk` 1.12.0, src/regions.ts) names them. */
|
|
2
|
+
export declare const ARCHIL_CONTROL_URLS: Readonly<Record<string, string>>;
|
|
3
|
+
export interface ArchilMountCredentialOptions {
|
|
4
|
+
/** The disk's id, dsk-<16 hex digits>. */
|
|
5
|
+
readonly disk: string;
|
|
6
|
+
/** Its region: it names the control plane. */
|
|
7
|
+
readonly region: string;
|
|
8
|
+
/** The account API key, asked for on each call. */
|
|
9
|
+
readonly key: () => string | Promise<string>;
|
|
10
|
+
/** Another control plane than the region's: a test's loopback one (plain http only there). */
|
|
11
|
+
readonly baseUrl?: string;
|
|
12
|
+
/** The fetch to call it with (default the global one). */
|
|
13
|
+
readonly fetch?: typeof fetch;
|
|
14
|
+
}
|
|
15
|
+
/** A minted mount credential: the token a computer's mount takes, and the identifier it is removed by. */
|
|
16
|
+
export interface MountCredential {
|
|
17
|
+
readonly token: string;
|
|
18
|
+
readonly identifier: string;
|
|
19
|
+
}
|
|
20
|
+
/** Why the control plane refused, in words: its status and Archil's own message, with no secret in them. */
|
|
21
|
+
export declare class ArchilMountCredentialError extends Error {
|
|
22
|
+
name: string;
|
|
23
|
+
readonly status: number | undefined;
|
|
24
|
+
constructor(message: string, status?: number);
|
|
25
|
+
}
|
|
26
|
+
/** A ttl as Archil reads it (a Go duration): whole seconds, at least one, at most Archil's 365 days. */
|
|
27
|
+
export declare const ttlOf: (ms: number) => string;
|
|
28
|
+
/** The nickname of run `run`'s token user under claim epoch `epoch`: the run and the epoch, so a later claim finds an
|
|
29
|
+
* earlier one's (its runner died before removing it). */
|
|
30
|
+
export declare const nicknameOf: (run: string, epoch: number) => string;
|
|
31
|
+
/** Mints the run's mount credential on the disk: a token user named `nickname`, which Archil ends after `ttlMs`. */
|
|
32
|
+
export declare function mintMountToken(options: ArchilMountCredentialOptions, run: {
|
|
33
|
+
readonly nickname: string;
|
|
34
|
+
readonly ttlMs: number;
|
|
35
|
+
readonly signal?: AbortSignal;
|
|
36
|
+
}): Promise<MountCredential>;
|
|
37
|
+
/** The disk's token users, by nickname and identifier (GET {control}/api/disks/{disk}: its authorized users). */
|
|
38
|
+
export declare function listTokenUsers(options: ArchilMountCredentialOptions, context?: {
|
|
39
|
+
readonly signal?: AbortSignal;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
readonly nickname?: string;
|
|
42
|
+
readonly identifier: string;
|
|
43
|
+
}[]>;
|
|
44
|
+
/** Removes run `run`'s token users of a claim epoch below `epoch` (a runner that died before removing its own), the way
|
|
45
|
+
* the janitor's releaseOlder does for computers, and answers their identifiers. Others' users are left alone. */
|
|
46
|
+
export declare function removeOlderMountTokens(options: ArchilMountCredentialOptions, run: string, epoch: number, context?: {
|
|
47
|
+
readonly signal?: AbortSignal;
|
|
48
|
+
}): Promise<string[]>;
|
|
49
|
+
/** Removes run `run`'s token users of claim epoch `epoch` and below, by their names: at a claim's revoke, a mint whose
|
|
50
|
+
* answer was lost (Archil made the user; the claim never heard of it) is one of them, as is an earlier claim's. */
|
|
51
|
+
export declare function removeRunMountTokens(options: ArchilMountCredentialOptions, run: string, epoch: number, context?: {
|
|
52
|
+
readonly signal?: AbortSignal;
|
|
53
|
+
}): Promise<string[]>;
|
|
54
|
+
/** Removes the run's mount credential by its identifier. Idempotent: one already gone (404) is removed. */
|
|
55
|
+
export declare function removeMountToken(options: ArchilMountCredentialOptions, identifier: string, context?: {
|
|
56
|
+
readonly signal?: AbortSignal;
|
|
57
|
+
readonly token?: string;
|
|
58
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// The Archil mount credential, one per run: minted at the claim, held in memory only, and removed at the computer's
|
|
2
|
+
// release and the run's end. No long-lived disk token is stored anywhere. Archil's control API (the control plane its
|
|
3
|
+
// SDK calls for a disk, archil-disk.ts), with the account API key as `Authorization: Bearer <key>`:
|
|
4
|
+
// - mint: POST {control}/api/disks/{disk}/users {"type":"token","nickname":<run label>,"ttl":<duration>}
|
|
5
|
+
// answers (in its `data` envelope) the token and its identifier. The ttl is the safety net if a remove never
|
|
6
|
+
// comes: the run's lifetime bound, as a duration ("86400s").
|
|
7
|
+
// - remove: DELETE {control}/api/disks/{disk}/users/token?identifier=<identifier>, idempotent: a 404 is already gone.
|
|
8
|
+
// - list: GET {control}/api/disks/{disk}, its authorized users: a reclaim removes the run's token users of an earlier
|
|
9
|
+
// claim epoch (nickname "agentrun:<run>:<epoch>") before it mints, as the janitor's releaseOlder does computers.
|
|
10
|
+
// The control plane is the region's (the SDK's own table), or a loopback one given for a test. Neither the token nor the
|
|
11
|
+
// key is ever in the environment, an argument, a file, a log line or an error: an error carries the status and Archil's
|
|
12
|
+
// own words, scrubbed of both.
|
|
13
|
+
/** The control plane of each Archil region, as Archil's SDK (`disk` 1.12.0, src/regions.ts) names them. */
|
|
14
|
+
export const ARCHIL_CONTROL_URLS = Object.freeze({
|
|
15
|
+
"aws-us-east-1": "https://control.green.us-east-1.aws.prod.archil.com",
|
|
16
|
+
"aws-us-west-2": "https://control.green.us-west-2.aws.prod.archil.com",
|
|
17
|
+
"aws-eu-west-1": "https://control.green.eu-west-1.aws.prod.archil.com",
|
|
18
|
+
"gcp-us-central1": "https://control.blue.us-central1.gcp.prod.archil.com",
|
|
19
|
+
});
|
|
20
|
+
const LOOPBACK = /^(?:127\.\d+\.\d+\.\d+|localhost|\[::1\])$/; // key-gate: loopback-rule names loopback hosts to allow plain http only to them, in tests
|
|
21
|
+
/** Why the control plane refused, in words: its status and Archil's own message, with no secret in them. */
|
|
22
|
+
export class ArchilMountCredentialError extends Error {
|
|
23
|
+
name = "ArchilMountCredentialError";
|
|
24
|
+
status;
|
|
25
|
+
constructor(message, status) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.status = status;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** The control plane's base URL: the region's, or the loopback one given. */
|
|
31
|
+
function controlOf(options) {
|
|
32
|
+
if (options.baseUrl !== undefined) {
|
|
33
|
+
const url = new URL(options.baseUrl);
|
|
34
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && LOOPBACK.test(url.hostname)))
|
|
35
|
+
throw new ArchilMountCredentialError("the Archil control plane must be https (plain http only to this machine's loopback, in tests)");
|
|
36
|
+
return url.href.replace(/\/$/, "");
|
|
37
|
+
}
|
|
38
|
+
const url = Object.hasOwn(ARCHIL_CONTROL_URLS, options.region) ? ARCHIL_CONTROL_URLS[options.region] : undefined;
|
|
39
|
+
if (url === undefined)
|
|
40
|
+
throw new ArchilMountCredentialError(`Archil has no control plane for region ${JSON.stringify(options.region)}: one of ${Object.keys(ARCHIL_CONTROL_URLS).join(", ")}`);
|
|
41
|
+
return url;
|
|
42
|
+
}
|
|
43
|
+
/** Archil's longest ttl, 365 days, in seconds. */
|
|
44
|
+
const MAX_TTL_S = 8760 * 3600;
|
|
45
|
+
/** A ttl as Archil reads it (a Go duration): whole seconds, at least one, at most Archil's 365 days. */
|
|
46
|
+
export const ttlOf = (ms) => `${Math.min(MAX_TTL_S, Math.max(1, Math.ceil(ms / 1000)))}s`;
|
|
47
|
+
/** The nickname of run `run`'s token user under claim epoch `epoch`: the run and the epoch, so a later claim finds an
|
|
48
|
+
* earlier one's (its runner died before removing it). */
|
|
49
|
+
export const nicknameOf = (run, epoch) => `agentrun:${run}:${epoch}`;
|
|
50
|
+
/** The run and epoch a nickname names, when it is one of nicknameOf's. */
|
|
51
|
+
function claimOfNickname(nickname) {
|
|
52
|
+
if (typeof nickname !== "string")
|
|
53
|
+
return undefined;
|
|
54
|
+
const match = /^agentrun:(.+):(0|[1-9][0-9]*)$/.exec(nickname);
|
|
55
|
+
return match ? { run: match[1], epoch: Number(match[2]) } : undefined;
|
|
56
|
+
}
|
|
57
|
+
/** `text` with each secret replaced. */
|
|
58
|
+
const scrub = (text, secrets) => secrets.filter((one) => one.length >= 4).reduce((out, one) => out.split(one).join("[redacted]"), text);
|
|
59
|
+
/** Archil's words for a failed call, from its error envelope ({error, code}), cut short and scrubbed. */
|
|
60
|
+
async function wordsOf(response, secrets) {
|
|
61
|
+
const text = await response.text().catch(() => "");
|
|
62
|
+
let said = text;
|
|
63
|
+
try {
|
|
64
|
+
const body = JSON.parse(text);
|
|
65
|
+
said = typeof body.error === "string" ? body.error : typeof body.message === "string" ? body.message : text;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// not JSON: its text
|
|
69
|
+
}
|
|
70
|
+
return scrub(said.trim().slice(0, 300), secrets);
|
|
71
|
+
}
|
|
72
|
+
/** Mints the run's mount credential on the disk: a token user named `nickname`, which Archil ends after `ttlMs`. */
|
|
73
|
+
export async function mintMountToken(options, run) {
|
|
74
|
+
const key = await options.key();
|
|
75
|
+
const url = `${controlOf(options)}/api/disks/${encodeURIComponent(options.disk)}/users`;
|
|
76
|
+
let response;
|
|
77
|
+
try {
|
|
78
|
+
response = await (options.fetch ?? fetch)(url, {
|
|
79
|
+
method: "POST",
|
|
80
|
+
headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
|
|
81
|
+
body: JSON.stringify({ type: "token", nickname: run.nickname, ttl: ttlOf(run.ttlMs) }),
|
|
82
|
+
redirect: "error",
|
|
83
|
+
...(run.signal ? { signal: run.signal } : {}),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw new ArchilMountCredentialError(`Archil's control plane could not be reached to mint the run's mount credential: ${scrub(error instanceof Error ? error.message : String(error), [key])}`);
|
|
88
|
+
}
|
|
89
|
+
if (!response.ok)
|
|
90
|
+
throw new ArchilMountCredentialError(`Archil refused to mint the run's mount credential (${response.status}): ${await wordsOf(response, [key])}`, response.status);
|
|
91
|
+
const body = (await response.json().catch(() => undefined));
|
|
92
|
+
const user = body?.data ?? body;
|
|
93
|
+
if (typeof user?.token !== "string" || user.token === "" || typeof user.identifier !== "string" || user.identifier === "") {
|
|
94
|
+
throw new ArchilMountCredentialError("Archil answered the mint of the run's mount credential with no token or no identifier");
|
|
95
|
+
}
|
|
96
|
+
return { token: user.token, identifier: user.identifier };
|
|
97
|
+
}
|
|
98
|
+
/** The disk's token users, by nickname and identifier (GET {control}/api/disks/{disk}: its authorized users). */
|
|
99
|
+
export async function listTokenUsers(options, context = {}) {
|
|
100
|
+
const key = await options.key();
|
|
101
|
+
const url = `${controlOf(options)}/api/disks/${encodeURIComponent(options.disk)}`;
|
|
102
|
+
let response;
|
|
103
|
+
try {
|
|
104
|
+
response = await (options.fetch ?? fetch)(url, { method: "GET", headers: { Authorization: `Bearer ${key}` }, redirect: "error", ...(context.signal ? { signal: context.signal } : {}) });
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
throw new ArchilMountCredentialError(`Archil's control plane could not be reached to list the disk's token users: ${scrub(error instanceof Error ? error.message : String(error), [key])}`);
|
|
108
|
+
}
|
|
109
|
+
if (!response.ok)
|
|
110
|
+
throw new ArchilMountCredentialError(`Archil refused to list the disk's token users (${response.status}): ${await wordsOf(response, [key])}`, response.status);
|
|
111
|
+
const body = (await response.json().catch(() => undefined));
|
|
112
|
+
const users = Array.isArray(body?.data?.authorizedUsers) ? body.data.authorizedUsers : [];
|
|
113
|
+
return users
|
|
114
|
+
.filter((user) => user?.type === "token" && typeof user.identifier === "string")
|
|
115
|
+
.map((user) => ({ identifier: user.identifier, ...(typeof user.nickname === "string" ? { nickname: user.nickname } : {}) }));
|
|
116
|
+
}
|
|
117
|
+
/** Removes run `run`'s token users of a claim epoch below `epoch` (a runner that died before removing its own), the way
|
|
118
|
+
* the janitor's releaseOlder does for computers, and answers their identifiers. Others' users are left alone. */
|
|
119
|
+
export function removeOlderMountTokens(options, run, epoch, context = {}) {
|
|
120
|
+
return removeRunTokens(options, run, (claimed) => claimed < epoch, context);
|
|
121
|
+
}
|
|
122
|
+
/** Removes run `run`'s token users of claim epoch `epoch` and below, by their names: at a claim's revoke, a mint whose
|
|
123
|
+
* answer was lost (Archil made the user; the claim never heard of it) is one of them, as is an earlier claim's. */
|
|
124
|
+
export function removeRunMountTokens(options, run, epoch, context = {}) {
|
|
125
|
+
return removeRunTokens(options, run, (claimed) => claimed <= epoch, context);
|
|
126
|
+
}
|
|
127
|
+
/** Each of the run's users `which` takes is tried, whatever an earlier one's remove did: one that fails (a network blip)
|
|
128
|
+
* leaves none after it standing. Their identifiers removed, or, when any failed, one error naming each that did. */
|
|
129
|
+
async function removeRunTokens(options, run, which, context) {
|
|
130
|
+
const removed = [];
|
|
131
|
+
const failed = [];
|
|
132
|
+
for (const user of await listTokenUsers(options, context)) {
|
|
133
|
+
const claim = claimOfNickname(user.nickname);
|
|
134
|
+
if (claim === undefined || claim.run !== run || !which(claim.epoch))
|
|
135
|
+
continue;
|
|
136
|
+
try {
|
|
137
|
+
await removeMountToken(options, user.identifier, context);
|
|
138
|
+
removed.push(user.identifier);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
failed.push(`${user.identifier} (${error?.message ?? String(error)})`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (failed.length > 0)
|
|
145
|
+
throw new ArchilMountCredentialError(`run ${run}'s token users ${failed.join(", ")} were not removed; ${removed.length} others were`);
|
|
146
|
+
return removed;
|
|
147
|
+
}
|
|
148
|
+
/** Removes the run's mount credential by its identifier. Idempotent: one already gone (404) is removed. */
|
|
149
|
+
export async function removeMountToken(options, identifier, context = {}) {
|
|
150
|
+
const key = await options.key();
|
|
151
|
+
const secrets = [key, ...(context.token ? [context.token] : [])];
|
|
152
|
+
const url = `${controlOf(options)}/api/disks/${encodeURIComponent(options.disk)}/users/token?identifier=${encodeURIComponent(identifier)}`;
|
|
153
|
+
let response;
|
|
154
|
+
try {
|
|
155
|
+
response = await (options.fetch ?? fetch)(url, { method: "DELETE", headers: { Authorization: `Bearer ${key}` }, redirect: "error", ...(context.signal ? { signal: context.signal } : {}) });
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
throw new ArchilMountCredentialError(`Archil's control plane could not be reached to remove the run's mount credential: ${scrub(error instanceof Error ? error.message : String(error), secrets)}`);
|
|
159
|
+
}
|
|
160
|
+
if (response.ok || response.status === 404) {
|
|
161
|
+
await response.body?.cancel().catch(() => undefined);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
throw new ArchilMountCredentialError(`Archil refused to remove the run's mount credential (${response.status}): ${await wordsOf(response, secrets)}`, response.status);
|
|
165
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { MountSpec } from "@parcha/agentrun-computer";
|
|
2
|
+
import { type ArchilDisk, type ArchilImage } from "./archil-disk.js";
|
|
3
|
+
import { type AttachableComputer, type MountCheck } from "./attach.js";
|
|
4
|
+
import { type Entry, type ExecOptions, type ExecResult, type GrepOptions, type GrepResult, type Stat, type Workspace } from "./workspace.js";
|
|
5
|
+
/** The most bytes one append call takes. */
|
|
6
|
+
export declare const APPEND_MAX: number;
|
|
7
|
+
export type ArchilWorkspaceOptions = {
|
|
8
|
+
/** How long a call waits for another client's hold on the folder (default 60 s). */
|
|
9
|
+
readonly queueMs?: number;
|
|
10
|
+
/** The image every exec runs in, the same for every workspace serve makes (a run's or a learning folder's), pinned by
|
|
11
|
+
* digest (an image given without one is refused): a public image `<name>@sha256:…`, or one built through Archil's
|
|
12
|
+
* images API with its digest. With none, Archil's default exec image, whose git (2.34.1, measured) is older than
|
|
13
|
+
* learning's floor. */
|
|
14
|
+
readonly image?: ArchilImage;
|
|
15
|
+
/** Told when an exec's cleanup leaves spill files behind (a failed delete, tried twice), with the keys and why; the
|
|
16
|
+
* exec's own result stands. Default: a process warning. */
|
|
17
|
+
readonly onCleanupFailed?: (message: string) => void;
|
|
18
|
+
/** The disk's region (the server's Archil settings): a computer's mount names it. */
|
|
19
|
+
readonly region?: string;
|
|
20
|
+
/** The disk token a computer's mount takes, asked for when a mount is made (the claim's, archil-claim.ts). */
|
|
21
|
+
readonly mountToken?: () => string | Promise<string>;
|
|
22
|
+
};
|
|
23
|
+
/** A workspace's exec spill folder: beside its root, never inside it, so the workspace's own calls never meet it. A
|
|
24
|
+
* run's ".../runs/<run>/work" spills to ".../runs/<run>/exec-out"; any other root to "<root>.exec-out". */
|
|
25
|
+
export declare const spillFolderOf: (root: string) => string;
|
|
26
|
+
declare class ArchilWorkspace implements Workspace {
|
|
27
|
+
#private;
|
|
28
|
+
constructor(disk: ArchilDisk, root: string, options?: ArchilWorkspaceOptions);
|
|
29
|
+
read(path: string, range?: {
|
|
30
|
+
readonly offset?: number;
|
|
31
|
+
readonly length?: number;
|
|
32
|
+
}): Promise<Uint8Array>;
|
|
33
|
+
write(path: string, data: Uint8Array | string): Promise<void>;
|
|
34
|
+
append(path: string, data: Uint8Array | string): Promise<void>;
|
|
35
|
+
/** What is at `path`, from its folder's listing: a file (its size, and its time when the listing gives one, else 0),
|
|
36
|
+
* a directory, or nothing (a file in the place of a folder on the way included). The file API cannot tell a link
|
|
37
|
+
* from a file (the named limit): a link an exec made is a "file" here, never "link". */
|
|
38
|
+
stat(path: string): Promise<Stat | undefined>;
|
|
39
|
+
list(dir: string): Promise<Entry[]>;
|
|
40
|
+
mkdir(dir: string): Promise<void>;
|
|
41
|
+
grep(pattern: string, options?: GrepOptions): Promise<GrepResult>;
|
|
42
|
+
remove(path: string, options?: {
|
|
43
|
+
readonly recursive?: boolean;
|
|
44
|
+
readonly force?: boolean;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
exec(argv: readonly string[], options: ExecOptions): Promise<ExecResult>;
|
|
47
|
+
/** What a killed exec, a crash or a failed cleanup left in the spill folder, removed, its folders included: for the
|
|
48
|
+
* run's start and its end. It takes its turn in this workspace's exec queue (after the execs before it, before those
|
|
49
|
+
* after it), touches nothing in the workspace's folder, and fails, naming what stayed, if it cannot clear it. */
|
|
50
|
+
sweep(): Promise<void>;
|
|
51
|
+
/** No computer: every background call is REFUSED, cause no-computer. */
|
|
52
|
+
readonly process: import("./attach.js").Processes;
|
|
53
|
+
/** The Archil mount a computer makes of this folder: the disk, its region, the root as the folder, and the token. */
|
|
54
|
+
mountSpec(): Promise<MountSpec>;
|
|
55
|
+
attach(computer: AttachableComputer, check: MountCheck): Promise<Workspace>;
|
|
56
|
+
}
|
|
57
|
+
/** A Workspace on folder `root` of Archil disk `disk` (a relative key, e.g. agents/<agent>/runs/<run>/work). */
|
|
58
|
+
export declare const archilWorkspace: (disk: ArchilDisk, root: string, options?: ArchilWorkspaceOptions) => ArchilWorkspace;
|
|
59
|
+
export type { ArchilWorkspace };
|