@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.36
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 +263 -0
- package/README.md +339 -179
- package/dist/adapters.d.ts +15 -2
- package/dist/adapters.js +34 -2
- package/dist/agent-rows.d.ts +3 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +25 -5
- package/dist/api-only.d.ts +2 -1
- package/dist/api-only.js +3 -1
- package/dist/archil-routes.d.ts +40 -7
- package/dist/archil-routes.js +167 -54
- package/dist/archil-settings.d.ts +90 -8
- package/dist/archil-settings.js +150 -14
- package/dist/attach-images.d.ts +15 -0
- package/dist/attach-images.js +59 -0
- package/dist/background.d.ts +0 -6
- package/dist/background.js +0 -28
- package/dist/bash-read-only.d.ts +13 -0
- package/dist/bash-read-only.js +77 -0
- package/dist/box-image.d.ts +1 -97
- package/dist/box-image.js +4 -284
- package/dist/box-paths.d.ts +2 -7
- package/dist/box-paths.js +7 -13
- package/dist/box-settings.d.ts +0 -11
- package/dist/box-settings.js +4 -29
- package/dist/browser-commands.js +1 -1
- package/dist/browser-computer.d.ts +47 -3
- package/dist/browser-computer.js +286 -18
- package/dist/browser-cost.d.ts +2 -2
- package/dist/browser-cost.js +6 -4
- package/dist/browser-person.d.ts +19 -2
- package/dist/browser-person.js +55 -6
- package/dist/browser-wait-ended.d.ts +23 -0
- package/dist/browser-wait-ended.js +42 -0
- package/dist/cap.d.ts +19 -44
- package/dist/cap.js +31 -77
- package/dist/cli.js +36 -27
- package/dist/computer-keys.d.ts +20 -10
- package/dist/computer-keys.js +36 -57
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +8 -5
- package/dist/computer-setting.js +91 -26
- package/dist/computer-view.d.ts +11 -2
- package/dist/computer-view.js +2 -1
- package/dist/computers.d.ts +54 -8
- package/dist/computers.js +101 -22
- package/dist/console/assets/index-BI4Byidu.js +550 -0
- package/dist/console/assets/index-C19gUF2n.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-cap.d.ts +7 -29
- package/dist/decision-cap.js +3 -94
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +8 -5
- package/dist/explain.js +3 -1
- package/dist/faux-computers.js +4 -0
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github-connection.js +25 -7
- package/dist/github-faux.d.ts +26 -0
- package/dist/github-faux.js +76 -0
- package/dist/github.d.ts +28 -4
- package/dist/github.js +46 -10
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-served.d.ts +5 -3
- package/dist/graph-served.js +14 -6
- package/dist/graph-view.d.ts +2 -0
- package/dist/graph-view.js +29 -2
- package/dist/handed-values.d.ts +1 -1
- package/dist/handed-values.js +1 -1
- package/dist/harness-install.d.ts +60 -3
- package/dist/harness-install.js +322 -34
- package/dist/harness-opencode/harness.js +0 -1
- package/dist/harness-opencode/host/policy.js +2 -2
- package/dist/harness.js +1 -1
- package/dist/host-tools.d.ts +8 -9
- package/dist/host-tools.js +7 -7
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +10 -2
- package/dist/learn/check.js +126 -8
- package/dist/learn/commit.d.ts +40 -6
- package/dist/learn/commit.js +164 -20
- package/dist/learn/folder.d.ts +11 -3
- package/dist/learn/folder.js +40 -16
- package/dist/learn/grade.d.ts +22 -2
- package/dist/learn/grade.js +127 -19
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/learning.sh +11 -13
- package/dist/learn/notes.d.ts +17 -3
- package/dist/learn/notes.js +19 -6
- package/dist/learn/reflect.d.ts +5 -2
- package/dist/learn/reflect.js +48 -32
- package/dist/learn/skills.d.ts +52 -5
- package/dist/learn/skills.js +104 -21
- package/dist/learned-nodes.d.ts +18 -0
- package/dist/learned-nodes.js +8 -0
- package/dist/learned-workflow.d.ts +27 -13
- package/dist/learned-workflow.js +110 -38
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-routes.d.ts +48 -2
- package/dist/learning-routes.js +99 -28
- package/dist/learning-run.d.ts +7 -5
- package/dist/learning-run.js +9 -6
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +6 -2
- package/dist/learning.d.ts +13 -28
- package/dist/learning.js +4 -18
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +4 -2
- package/dist/mcp-gateway.d.ts +6 -0
- package/dist/mcp-gateway.js +11 -1
- package/dist/mcp-probe.d.ts +8 -1
- package/dist/mcp-probe.js +62 -20
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +12 -12
- package/dist/mcp-servers-store.js +8 -3
- package/dist/model.d.ts +8 -5
- package/dist/model.js +14 -6
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +236 -55
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/pause.d.ts +2 -19
- package/dist/pause.js +5 -74
- package/dist/place-offers.d.ts +97 -0
- package/dist/place-offers.js +206 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +22 -32
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +31 -9
- package/dist/print.d.ts +1 -8
- package/dist/print.js +1 -14
- package/dist/propose.d.ts +3 -0
- package/dist/propose.js +25 -19
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-db.js +3 -3
- package/dist/run-launch.d.ts +18 -3
- package/dist/run-launch.js +11 -5
- package/dist/run-learning-served.d.ts +12 -1
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-reads-over-store.d.ts +4 -2
- package/dist/run-reads-over-store.js +10 -8
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.js +60 -38
- package/dist/run-view.d.ts +35 -16
- package/dist/run-view.js +64 -35
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +20 -4
- package/dist/runner/adapter-loop.d.ts +46 -5
- package/dist/runner/adapter-loop.js +381 -56
- package/dist/runner/adapter-run-spec.d.ts +46 -4
- package/dist/runner/adapter-run-spec.js +200 -45
- package/dist/runner/adapters/pi.d.ts +39 -3
- package/dist/runner/adapters/pi.js +124 -29
- package/dist/runner/beside.d.ts +8 -0
- package/dist/runner/beside.js +24 -2
- package/dist/runner/claim-secrets.d.ts +6 -0
- package/dist/runner/claim-secrets.js +15 -1
- package/dist/runner/cli-run-spec.d.ts +10 -0
- package/dist/runner/cli-run-spec.js +207 -64
- package/dist/runner/commands.d.ts +5 -1
- package/dist/runner/commands.js +3 -3
- package/dist/runner/conformance/harness.d.ts +1 -1
- package/dist/runner/conformance/harness.js +13 -10
- package/dist/runner/github-app.d.ts +7 -2
- package/dist/runner/github-app.js +46 -15
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +24 -1
- package/dist/runner/journal-kinds.d.ts +53 -7
- package/dist/runner/journal-kinds.js +29 -1
- package/dist/runner/learning-end.d.ts +15 -0
- package/dist/runner/learning-end.js +113 -20
- package/dist/runner/learning-factory.js +6 -2
- package/dist/runner/learning-loop.d.ts +75 -1
- package/dist/runner/learning-loop.js +215 -22
- package/dist/runner/learning-seed.d.ts +8 -0
- package/dist/runner/learning-seed.js +7 -1
- package/dist/runner/loop-contract.d.ts +12 -0
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +5 -1
- package/dist/runner/loop.js +20 -0
- package/dist/runner/main.d.ts +9 -4
- package/dist/runner/main.js +38 -13
- package/dist/runner/mcp-claim.d.ts +7 -0
- package/dist/runner/mcp-claim.js +35 -2
- package/dist/runner/mcp-github.d.ts +15 -4
- package/dist/runner/mcp-github.js +55 -11
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +2 -0
- package/dist/runner/metrics.d.ts +18 -1
- package/dist/runner/metrics.js +81 -1
- package/dist/runner/model-route.d.ts +6 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +59 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +1 -0
- package/dist/runner/reflect-hook.js +3 -3
- package/dist/runner/runner.js +136 -19
- package/dist/runner/spec-holds.d.ts +13 -3
- package/dist/runner/spec-holds.js +13 -10
- package/dist/runner/store-port.d.ts +4 -1
- package/dist/runner/store-secrets.js +17 -1
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +188 -0
- package/dist/runner/workflow-host.d.ts +25 -4
- package/dist/runner/workflow-host.js +26 -4
- package/dist/runner/workflow-loop.d.ts +9 -3
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +28 -13
- package/dist/runner/workflow-spec.js +247 -102
- package/dist/runs-over-store.d.ts +18 -7
- package/dist/runs-over-store.js +149 -31
- package/dist/seal-key.d.ts +0 -2
- package/dist/seal-key.js +0 -2
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/server-lock.js +4 -5
- package/dist/server.d.ts +49 -63
- package/dist/server.js +429 -230
- package/dist/stop-signals.d.ts +4 -2
- package/dist/stop-signals.js +5 -3
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +22 -8
- package/dist/store/deadline.d.ts +18 -0
- package/dist/store/deadline.js +49 -0
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/connection.d.ts +4 -0
- package/dist/store/postgres/connection.js +64 -13
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +11 -8
- package/dist/store/seal.d.ts +13 -0
- package/dist/store/seal.js +19 -0
- package/dist/store/sqlite/connection.d.ts +5 -0
- package/dist/store/sqlite/connection.js +88 -82
- package/dist/store/sqlite/run-patch.d.ts +18 -2
- package/dist/store/sqlite/run-patch.js +31 -2
- package/dist/store/sqlite/store.js +65 -11
- package/dist/store/store.d.ts +62 -12
- package/dist/store/store.js +22 -1
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +1 -3
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/journal.js +83 -15
- package/dist/store-reads/learning.d.ts +73 -3
- package/dist/store-reads/learning.js +232 -9
- package/dist/store-reads/runs.d.ts +6 -4
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-view.d.ts +15 -1
- package/dist/store-view.js +88 -29
- package/dist/template-eval.js +2 -1
- package/dist/templates.d.ts +73 -4
- package/dist/templates.js +113 -23
- package/dist/timeline/timeline.d.ts +11 -1
- package/dist/timeline/timeline.js +19 -4
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +26 -0
- package/dist/tool-budget.js +56 -0
- package/dist/tool-gate.d.ts +13 -3
- package/dist/tool-gate.js +15 -7
- package/dist/tool-plane.d.ts +42 -29
- package/dist/tool-plane.js +64 -27
- package/dist/tools.d.ts +53 -39
- package/dist/tools.js +174 -79
- package/dist/trigger-signatures.d.ts +1 -0
- package/dist/trigger-signatures.js +3 -1
- package/dist/triggers.d.ts +3 -3
- package/dist/triggers.js +2 -2
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/uploads.d.ts +28 -5
- package/dist/uploads.js +82 -9
- package/dist/usage-lines.d.ts +1 -1
- package/dist/usage.d.ts +1 -47
- package/dist/usage.js +3 -82
- package/dist/validate.d.ts +8 -0
- package/dist/validate.js +40 -3
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -2
- package/dist/workflow/decision-recovery.d.ts +23 -0
- package/dist/workflow/decision-recovery.js +80 -0
- package/dist/workflow/decisions.d.ts +134 -0
- package/dist/workflow/decisions.js +46 -0
- package/dist/workflow/host-session.d.ts +5 -0
- package/dist/workflow/host-session.js +85 -0
- package/dist/workflow/host-tools.d.ts +3 -0
- package/dist/workflow/host-tools.js +3 -0
- package/dist/workflow/node-runner.d.ts +112 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +88 -0
- package/dist/workflow/node.js +99 -0
- package/dist/workflow/operator-error.d.ts +4 -0
- package/dist/workflow/operator-error.js +4 -0
- package/dist/workflow/pi-versions.d.ts +9 -0
- package/dist/workflow/pi-versions.js +8 -0
- package/dist/workflow/readers.d.ts +36 -0
- package/dist/workflow/readers.js +145 -0
- package/dist/workflow/record-file.d.ts +10 -0
- package/dist/workflow/record-file.js +56 -0
- package/dist/workflow/record-tool.d.ts +76 -0
- package/dist/workflow/record-tool.js +126 -0
- package/dist/workflow/record.d.ts +151 -0
- package/dist/workflow/record.js +401 -0
- package/dist/workflow/run-error.d.ts +16 -0
- package/dist/workflow/run-error.js +26 -0
- package/dist/workflow/runner.d.ts +6 -0
- package/dist/workflow/runner.js +240 -0
- package/dist/workflow/store.d.ts +23 -0
- package/dist/workflow/store.js +242 -0
- package/dist/workflow/task.d.ts +133 -0
- package/dist/workflow/task.js +411 -0
- package/dist/workflow/thinking.d.ts +3 -0
- package/dist/workflow/thinking.js +7 -0
- package/dist/workflow/tool-context.d.ts +21 -0
- package/dist/workflow/tool-context.js +13 -0
- package/dist/workflow/types.d.ts +126 -0
- package/dist/workflow/types.js +1 -0
- package/dist/workflow/wal.d.ts +11 -0
- package/dist/workflow/wal.js +106 -0
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +13 -2
- package/dist/workspace/archil-claim.js +22 -13
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +4 -0
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.d.ts +12 -2
- package/dist/workspace/archil-exec.js +18 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/archil.d.ts +2 -2
- package/dist/workspace/archil.js +25 -5
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/computer-deps.d.ts +18 -11
- package/dist/workspace/computer-deps.js +64 -40
- package/dist/workspace/computer-for-claim.d.ts +47 -9
- package/dist/workspace/computer-for-claim.js +236 -24
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +3 -8
- package/dist/workspace/computer-ledger.js +7 -3
- package/dist/workspace/computer-providers.d.ts +5 -3
- package/dist/workspace/computer-providers.js +11 -9
- package/dist/workspace/hands.d.ts +5 -2
- package/dist/workspace/hands.js +4 -3
- package/dist/workspace/index.d.ts +5 -4
- package/dist/workspace/index.js +2 -1
- package/dist/workspace/local.d.ts +3 -0
- package/dist/workspace/local.js +9 -0
- package/dist/workspace/paths.js +3 -2
- package/dist/workspace/pi-env.d.ts +4 -0
- package/dist/workspace/pi-env.js +3 -2
- package/dist/workspace/resolve-computer.d.ts +48 -12
- package/dist/workspace/resolve-computer.js +88 -19
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +6 -4
- package/dist/workspace/run-tools.js +17 -9
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace/workspace.d.ts +5 -0
- package/dist/workspace.d.ts +0 -3
- package/dist/workspace.js +2 -15
- package/package.json +11 -16
- package/skills/agentrun-serve/SKILL.md +1 -1
- package/templates/README.md +11 -8
- package/templates/code-review/agent.md +27 -11
- package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
- package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
- package/templates/code-review/evals/injection/graders/ignores.md +1 -1
- package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
- package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
- package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
- package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
- package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
- package/templates/code-review/evals/never-flag/case.yaml +3 -0
- package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
- package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
- package/templates/code-review/evals/never-flag/prompt.md +30 -0
- package/templates/code-review/evals/null-name/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
- package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
- package/templates/code-review/evals/re-review/prompt.md +1 -1
- package/templates/code-review/evals/re-review-open/case.yaml +3 -0
- package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
- package/templates/code-review/evals/re-review-open/prompt.md +27 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
- package/templates/code-review/evals/two-defects/case.yaml +3 -0
- package/templates/code-review/evals/two-defects/graders/both.md +4 -0
- package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
- package/templates/code-review/evals/two-defects/prompt.md +25 -0
- package/templates/code-review/findings.schema.json +131 -27
- package/templates/code-review/rules/CODEREVIEW.md +76 -0
- package/templates/code-review/skills/review/DEEP.md +130 -0
- package/templates/code-review/skills/review/REVIEWER.md +116 -0
- package/templates/code-review/skills/review/SKILL.md +104 -154
- package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
- package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
- package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
- package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
- package/templates/release-notes/agent.md +11 -0
- package/dist/box/record.d.ts +0 -6
- package/dist/box/record.js +0 -41
- package/dist/box/sweep.d.ts +0 -53
- package/dist/box/sweep.js +0 -193
- package/dist/box-egress-vm.d.ts +0 -118
- package/dist/box-egress-vm.js +0 -354
- package/dist/box-egress.d.ts +0 -105
- package/dist/box-egress.js +0 -256
- package/dist/box-relay-vm.d.ts +0 -84
- package/dist/box-relay-vm.js +0 -437
- package/dist/box-relay.d.ts +0 -36
- package/dist/box-relay.js +0 -207
- package/dist/boxes.d.ts +0 -109
- package/dist/boxes.js +0 -249
- package/dist/budget.d.ts +0 -76
- package/dist/budget.js +0 -204
- package/dist/console/assets/index-RPHGlXmM.js +0 -540
- package/dist/console/assets/index-opTN5Naq.css +0 -1
- package/dist/daytona-api.d.ts +0 -10
- package/dist/daytona-api.js +0 -20
- package/dist/egress-proxy.d.ts +0 -45
- package/dist/egress-proxy.js +0 -416
- package/dist/egress-table.d.ts +0 -24
- package/dist/egress-table.js +0 -165
- package/templates/code-review/rules/REVIEW.md +0 -41
package/dist/computers.d.ts
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import { type GpuCapability } from "@parcha/agentrun-computer";
|
|
1
|
+
import { type ComputerProvider, type GpuCapability } from "@parcha/agentrun-computer";
|
|
2
2
|
import { type KeyTable, type OptionsAnswer, type ProviderFactories, type ProviderSettings } from "./computer-keys.js";
|
|
3
3
|
import { type ComputerKind, type ComputerSetting } from "./computer-setting.js";
|
|
4
4
|
import { type DockerDaemon } from "./docker-daemon.js";
|
|
5
5
|
import { type KeyEnv, type KeyMeta } from "./key-meta.js";
|
|
6
6
|
import type { Store } from "./store/index.js";
|
|
7
|
+
import { type ShellPlace } from "./workspace/resolve-computer.js";
|
|
7
8
|
/** A setting kind as the kind registry's SETTING_KINDS gives it. */
|
|
8
9
|
export interface SettingKindSpec {
|
|
9
10
|
readonly machineKinds: readonly string[];
|
|
10
11
|
readonly required: readonly string[];
|
|
11
12
|
readonly optional: readonly string[];
|
|
12
13
|
}
|
|
13
|
-
/** A provider configuration's machine kind and groups,
|
|
14
|
-
*
|
|
14
|
+
/** A provider configuration's machine kind and groups, the GPUs it gives where it declares them, whether it keeps an
|
|
15
|
+
* agent's own computer between runs (persistence), and the image a setting selects it by, where it names one, as the
|
|
16
|
+
* kind registry gives them. */
|
|
15
17
|
export type KindCapabilities = {
|
|
16
18
|
readonly kind: string;
|
|
17
19
|
readonly groups: readonly string[];
|
|
18
20
|
readonly gpu?: GpuCapability;
|
|
21
|
+
readonly persistence?: unknown;
|
|
22
|
+
readonly image?: string;
|
|
23
|
+
readonly options?: Readonly<Record<string, unknown>>;
|
|
19
24
|
};
|
|
20
25
|
/** A provider as the kind registry's PROVIDERS gives it. */
|
|
21
26
|
export interface ProviderEntry {
|
|
@@ -28,12 +33,31 @@ export interface ProviderEntry {
|
|
|
28
33
|
}[];
|
|
29
34
|
/** The mounts its computers take; none means it cannot mount the run's folder. */
|
|
30
35
|
readonly mounts: readonly string[];
|
|
31
|
-
/** The network forms its computers make ("none", "open", "allow"), as its
|
|
36
|
+
/** The network forms its computers make ("none", "open", "allow"), as its descriptor declares them. Absent (a
|
|
32
37
|
* test's fixture): nothing is said of its network. */
|
|
33
38
|
readonly network?: readonly string[];
|
|
34
39
|
readonly metered: boolean;
|
|
35
40
|
readonly capabilities: readonly KindCapabilities[];
|
|
41
|
+
/** The image a computer of each kind starts from when its setting names none. */
|
|
42
|
+
readonly defaultImage?: Partial<Record<ComputerKind, string>>;
|
|
43
|
+
/** A program its computers need on this machine's PATH, what installs it, and the machines it is built for
|
|
44
|
+
* (`${platform}-${arch}`; absent, every one), as its descriptor declares it: the phone's adb. Absent: none. */
|
|
45
|
+
readonly hostCommand?: HostCommand;
|
|
36
46
|
}
|
|
47
|
+
/** A provider's host command, as the kind registry's entry names it. */
|
|
48
|
+
export type HostCommand = {
|
|
49
|
+
readonly command: string;
|
|
50
|
+
readonly from: string;
|
|
51
|
+
readonly builds?: readonly string[];
|
|
52
|
+
};
|
|
53
|
+
/** Why a provider whose host command is not on this machine's PATH cannot run here, in words that say how to fix it,
|
|
54
|
+
* as the server says Docker's (docker-daemon.ts). On a machine the command has no build for (adb on arm64 Linux: AgentRun's
|
|
55
|
+
* arm64 image has none either), they say which machine it needs, not how to install it. */
|
|
56
|
+
export declare function hostCommandWhy(label: string, { command, from, builds }: HostCommand, platform?: string, arch?: string): string;
|
|
57
|
+
/** Each provider whose host command is not on `path` (the server's PATH at its start), by its id, with hostCommandWhy's
|
|
58
|
+
* words: what Settings → Computers, a run's start and the claim say for it. A command is there when a folder of `path`
|
|
59
|
+
* holds an executable file of its name. */
|
|
60
|
+
export declare function hostCommandRefusals(providers: readonly Pick<ProviderEntry, "id" | "label" | "hostCommand">[], path: string | undefined, platform?: string, arch?: string): Readonly<Record<string, string>>;
|
|
37
61
|
/** The kind registry, by its own names: the computer package's module (SETTING_KINDS, PROVIDERS, servingRefusals). */
|
|
38
62
|
export interface KindRegistry {
|
|
39
63
|
readonly SETTING_KINDS: Readonly<Record<ComputerKind, SettingKindSpec>>;
|
|
@@ -56,9 +80,12 @@ export interface ComputerRoutesOptions {
|
|
|
56
80
|
readonly keyTable?: KeyTable;
|
|
57
81
|
/** The model-visible tools a kind brings (the kernel registry's capabilityToolDefs), by name. */
|
|
58
82
|
readonly tools: (kind: ComputerKind) => readonly string[];
|
|
59
|
-
/** This server's folder mode, or how to read it at each call (folderModeOf: the Archil settings row), so turning
|
|
83
|
+
/** This server's folder mode, or how to read it at each call (folderModeOf: the Archil settings, the environment's or the saved row), so turning
|
|
60
84
|
* Archil on or off takes effect without building the routes again. */
|
|
61
85
|
readonly mode: FolderMode | (() => FolderMode | Promise<FolderMode>);
|
|
86
|
+
/** Why this machine cannot run a provider's computers, by its id (hostCommandRefusals at the server's start): the
|
|
87
|
+
* provider is not ready, and a claim of it is refused, in these words. Absent: every provider can run here. */
|
|
88
|
+
readonly hostWhy?: Readonly<Record<string, string>>;
|
|
62
89
|
/** The server's environment: a variable named as a provider's key overrides the saved one (source "env"). */
|
|
63
90
|
readonly env?: KeyEnv;
|
|
64
91
|
/** Whether a provider that binds a folder of this machine (Docker) answers here now, or why not (the server's daemon
|
|
@@ -67,7 +94,10 @@ export interface ComputerRoutesOptions {
|
|
|
67
94
|
}
|
|
68
95
|
/** A provider as Settings shows it: `metered` straight from the kind registry (its computers are billed by the vendor);
|
|
69
96
|
* its keys as SecretMeta under `secrets`, each named "computer:<provider>:<KEY>", and `required`, the names of the ones
|
|
70
|
-
* it needs. `network`: what this server's allow-list means for a vendor-hosted computer, in words (networkWords).
|
|
97
|
+
* it needs. `network`: what this server's allow-list means for a vendor-hosted computer, in words (networkWords).
|
|
98
|
+
* `images`: the images it offers for the kind, by name, where it offers any to choose. `persistent`: present where an
|
|
99
|
+
* agent's computer of this kind can be kept between its runs (computer.persistent: true), with the images that keep one
|
|
100
|
+
* where it offers images to choose. */
|
|
71
101
|
export type ProviderView = {
|
|
72
102
|
id: string;
|
|
73
103
|
name: string;
|
|
@@ -77,7 +107,18 @@ export type ProviderView = {
|
|
|
77
107
|
ready: boolean;
|
|
78
108
|
why?: string;
|
|
79
109
|
network?: string;
|
|
110
|
+
images?: string[];
|
|
111
|
+
persistent?: {
|
|
112
|
+
images?: string[];
|
|
113
|
+
};
|
|
80
114
|
gpu?: GpuView;
|
|
115
|
+
} & ShellChoice;
|
|
116
|
+
/** A choice's shell (workspace runShellOf, in this server's mode), the host tools it gives (the kernel registry's
|
|
117
|
+
* hostToolDefs for that shell) and what it leaves out in words (absent on a computer that mounts the folder). */
|
|
118
|
+
export type ShellChoice = {
|
|
119
|
+
shell: ShellPlace;
|
|
120
|
+
host_tools: string[];
|
|
121
|
+
shell_note?: string;
|
|
81
122
|
};
|
|
82
123
|
/** A sandbox provider's GPUs as Settings shows them: what its configuration declares (the types an agent's
|
|
83
124
|
* `computer.gpu.type` names, the most one computer gets, and the limits it states), and why a run here cannot have
|
|
@@ -91,10 +132,14 @@ export declare const NO_NETWORK_WORDS = "no network, so this server's allow-list
|
|
|
91
132
|
export declare const VENDOR_NETWORK_WORDS = "the vendor's own network; this server's allow-list doesn't apply";
|
|
92
133
|
/** A browser behind its own egress proxy (Local Chrome): every public host, unless the operator set a list. */
|
|
93
134
|
export declare const OPERATOR_LIST_WORDS = "open unless this server sets AGENTRUN_BOX_ALLOW; then only those hosts";
|
|
135
|
+
/** A computer that needs a network where this server's AGENTRUN_BOX_ALLOW is none: a run of it is refused at its start
|
|
136
|
+
* and at its claim (resolve-computer.ts noNetworkRefusal), so Settings says so and never offers it. */
|
|
137
|
+
export declare const NETWORK_REFUSED_WORDS = "needs a network, which this server refuses: its AGENTRUN_BOX_ALLOW is none";
|
|
94
138
|
/** What this server's allow-list means for a provider's computers, by the network forms it declares: words for one that
|
|
95
139
|
* makes "none" alone, "open" alone, or "open" and "allow" but no "none" (a browser behind its own proxy); none where
|
|
96
140
|
* the allow-list applies as it is (Docker), or nothing is declared. */
|
|
97
141
|
export declare function networkWords(network: readonly string[] | undefined): string | undefined;
|
|
142
|
+
/** A kind; kind none, the one "no computer" choice, carries its ShellChoice itself (it has no providers). */
|
|
98
143
|
export type KindView = {
|
|
99
144
|
kind: ComputerKind;
|
|
100
145
|
offered: boolean;
|
|
@@ -102,7 +147,7 @@ export type KindView = {
|
|
|
102
147
|
groups: string[];
|
|
103
148
|
tools: string[];
|
|
104
149
|
providers: ProviderView[];
|
|
105
|
-
}
|
|
150
|
+
} & Partial<ShellChoice>;
|
|
106
151
|
export type TestView = {
|
|
107
152
|
ok: true;
|
|
108
153
|
detail: string;
|
|
@@ -141,13 +186,14 @@ export declare function createComputerRoutes(options: ComputerRoutesOptions): {
|
|
|
141
186
|
test: (providerId: string, signal?: AbortSignal) => Promise<TestView | undefined>;
|
|
142
187
|
claimRefusal: (computer: ComputerSetting) => Promise<string | undefined>;
|
|
143
188
|
claimOptions: (computer: ComputerSetting) => Promise<OptionsAnswer | undefined>;
|
|
189
|
+
providerFor: (providerId: string, image: string | undefined) => Promise<Pick<ComputerProvider, "release">>;
|
|
144
190
|
};
|
|
145
191
|
export type ComputerRoutes = ReturnType<typeof createComputerRoutes>;
|
|
146
192
|
/** This server's folder mode, read from the store at each call: "disk" (Mode 2) while the Archil settings row is saved
|
|
147
193
|
* (PUT /v2/workspace/archil), else "local" (Mode 1). createComputerRoutes' `mode`. */
|
|
148
194
|
export declare const folderModeOf: (store: {
|
|
149
195
|
settings: Pick<Store["settings"], "get">;
|
|
150
|
-
}) => () => Promise<FolderMode>;
|
|
196
|
+
}, env?: KeyEnv) => () => Promise<FolderMode>;
|
|
151
197
|
/** Settings → Computers' routes, by their operation names: GET /v2/computers, PUT /v2/computers/{provider}/keys and POST
|
|
152
198
|
* /v2/computers/{provider}/test. */
|
|
153
199
|
export declare const COMPUTER_SETTINGS_ROUTES: ReadonlySet<string>;
|
package/dist/computers.js
CHANGED
|
@@ -6,27 +6,67 @@
|
|
|
6
6
|
// their names only: a provider declares them, Settings takes only those, and the store keeps each sealed under the
|
|
7
7
|
// server's seal key (server-keys.ts); a provider is handed its keys only at the claim, or for its test, both through
|
|
8
8
|
// computer-keys.ts (providerOptions, testConnection), which maps a key's name onto the option it fills.
|
|
9
|
-
import {
|
|
9
|
+
import { accessSync, constants, statSync } from "node:fs";
|
|
10
|
+
import { delimiter, join } from "node:path";
|
|
11
|
+
import { imagesOf } from "@parcha/agentrun-computer";
|
|
12
|
+
import { BOX_ALLOW_ENV, boxAllowOf } from "./box-settings.js";
|
|
10
13
|
import { KEY_TABLE, providerOptions, testConnection } from "./computer-keys.js";
|
|
11
14
|
import { COMPUTER_KINDS, gpuOf } from "./computer-setting.js";
|
|
12
15
|
import { inArchilMode } from "./archil-settings.js";
|
|
13
16
|
import { daemonUp, noDockerWords } from "./docker-daemon.js";
|
|
14
17
|
import { ApiError, invalid } from "./errors.js";
|
|
18
|
+
import { gpuRefused } from "./gpu-words.js";
|
|
15
19
|
import { redacted } from "./key-refusal.js";
|
|
16
20
|
import { keyMetaOf, envValue } from "./key-meta.js";
|
|
17
21
|
import { registerNotSecretWrite, registerSecretWrite, secretName } from "./secret-writes.js";
|
|
18
22
|
import { getSealedKey, putSealedKey, removeSealedKey, sealedKeyNames } from "./server-keys.js";
|
|
23
|
+
import { needsNetwork, shellChoiceOf } from "./workspace/resolve-computer.js";
|
|
19
24
|
// Every request to a computer's keys is a secret write (secret-writes.ts), whatever its body (a value, a null, an empty
|
|
20
25
|
// body or none), as saveToolKey's is: the server's one dispatch check keeps it to the owner's session before any provider
|
|
21
26
|
// is looked up, so a token learns nothing of which providers exist. The view and the connection test write none.
|
|
22
27
|
registerSecretWrite("saveComputerKeys", () => true);
|
|
23
28
|
registerNotSecretWrite("testComputer", "A connection test reads the saved keys and writes none.");
|
|
29
|
+
const ARCH_NAMES = { x64: "x86-64", arm64: "arm64" };
|
|
30
|
+
const PLATFORM_NAMES = { linux: "Linux", darwin: "macOS", win32: "Windows" };
|
|
31
|
+
/** Why a provider whose host command is not on this machine's PATH cannot run here, in words that say how to fix it,
|
|
32
|
+
* as the server says Docker's (docker-daemon.ts). On a machine the command has no build for (adb on arm64 Linux: AgentRun's
|
|
33
|
+
* arm64 image has none either), they say which machine it needs, not how to install it. */
|
|
34
|
+
export function hostCommandWhy(label, { command, from, builds }, platform = process.platform, arch = process.arch) {
|
|
35
|
+
if (!builds || builds.includes(`${platform}-${arch}`))
|
|
36
|
+
return `${command} isn't installed on this server (no ${command} command on PATH): install ${from}, then restart AgentRun`;
|
|
37
|
+
const name = (one) => ARCH_NAMES[one] ?? one;
|
|
38
|
+
const others = builds.filter((one) => one.startsWith(`${platform}-`)).map((one) => name(one.slice(platform.length + 1)));
|
|
39
|
+
const needs = others.length ? `an ${others.join(" or ")} server` : `a server where ${from} runs (${builds.join(", ")})`;
|
|
40
|
+
return `this server's image has no ${command} for ${name(arch)} (${from} has no ${PLATFORM_NAMES[platform] ?? platform} build for ${name(arch)}): ${label} needs ${needs}`;
|
|
41
|
+
}
|
|
42
|
+
/** Each provider whose host command is not on `path` (the server's PATH at its start), by its id, with hostCommandWhy's
|
|
43
|
+
* words: what Settings → Computers, a run's start and the claim say for it. A command is there when a folder of `path`
|
|
44
|
+
* holds an executable file of its name. */
|
|
45
|
+
export function hostCommandRefusals(providers, path, platform = process.platform, arch = process.arch) {
|
|
46
|
+
// On Windows a program is its name with an executable extension (platform-tools installs adb.exe).
|
|
47
|
+
const named = (command) => (platform === "win32" ? [command, ...[".exe", ".cmd", ".bat"].map((extension) => `${command}${extension}`)] : [command]);
|
|
48
|
+
const found = (command) => (path ?? "").split(delimiter).some((folder) => folder !== "" && named(command).some((file) => {
|
|
49
|
+
try {
|
|
50
|
+
accessSync(join(folder, file), constants.X_OK);
|
|
51
|
+
return statSync(join(folder, file)).isFile();
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
return Object.fromEntries(providers.flatMap((provider) => (provider.hostCommand && !found(provider.hostCommand.command) ? [[provider.id, hostCommandWhy(provider.label, provider.hostCommand, platform, arch)]] : [])));
|
|
58
|
+
}
|
|
24
59
|
/** A computer with no network: its programs run in a network of their own, so a run's allow-list is never offered it. */
|
|
25
60
|
export const NO_NETWORK_WORDS = "no network, so this server's allow-list isn't offered";
|
|
26
61
|
/** A computer on the vendor's own network: open, which this server's allow-list doesn't reach. */
|
|
27
62
|
export const VENDOR_NETWORK_WORDS = "the vendor's own network; this server's allow-list doesn't apply";
|
|
28
63
|
/** A browser behind its own egress proxy (Local Chrome): every public host, unless the operator set a list. */
|
|
29
64
|
export const OPERATOR_LIST_WORDS = "open unless this server sets AGENTRUN_BOX_ALLOW; then only those hosts";
|
|
65
|
+
/** A computer that needs a network where this server's AGENTRUN_BOX_ALLOW is none: a run of it is refused at its start
|
|
66
|
+
* and at its claim (resolve-computer.ts noNetworkRefusal), so Settings says so and never offers it. */
|
|
67
|
+
export const NETWORK_REFUSED_WORDS = `needs a network, which this server refuses: its ${BOX_ALLOW_ENV} is none`;
|
|
68
|
+
/** Why a provider whose computers can't run with no network is not ready where this server has none. */
|
|
69
|
+
const noNetworkWhy = (provider) => `${provider.label} needs a network, and this server's ${BOX_ALLOW_ENV} is none (no network): pick a computer that runs with no network, or set ${BOX_ALLOW_ENV} to a host list`;
|
|
30
70
|
/** What this server's allow-list means for a provider's computers, by the network forms it declares: words for one that
|
|
31
71
|
* makes "none" alone, "open" alone, or "open" and "allow" but no "none" (a browser behind its own proxy); none where
|
|
32
72
|
* the allow-list applies as it is (Docker), or nothing is declared. */
|
|
@@ -68,21 +108,25 @@ export function modeRefusal(kind, provider, mode) {
|
|
|
68
108
|
const sandboxGpu = (kinds, provider) => provider.capabilities.find((one) => one.gpu !== undefined && kinds.servingRefusals(one, "sandbox").length === 0)?.gpu;
|
|
69
109
|
/** The mount a sandbox takes in `mode`: the run's folder, a bind of this machine or the owner's Archil disk. */
|
|
70
110
|
const folderMount = (mode) => ({ kind: mode === "local" ? "bind" : "archil" });
|
|
71
|
-
/** A sandbox provider's GPUs as Settings shows them, with why a run here cannot have them (
|
|
72
|
-
* smallest ask, one of its first type, with this mode's mount).
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
111
|
+
/** A sandbox provider's GPUs as Settings shows them, with why a run here cannot have them (gpuRefused's words for its
|
|
112
|
+
* smallest ask, one of its first type, with this mode's mount). Its reason for taking no mount is in `why`, not a
|
|
113
|
+
* field of its own. */
|
|
114
|
+
function gpuView(gpu, label, mode) {
|
|
115
|
+
const refused = gpu.types.length ? gpuRefused({ type: gpu.types[0], count: 1 }, gpu, folderMount(mode), label) : undefined;
|
|
116
|
+
const shown = structuredClone(gpu);
|
|
117
|
+
delete shown.unmounted;
|
|
118
|
+
return { ...shown, ...(refused ? { why: refused.words } : {}) };
|
|
76
119
|
}
|
|
77
|
-
/** Why `computer`'s GPUs cannot be had on `provider` in `mode`, in
|
|
78
|
-
* for none (only a sandbox does). */
|
|
120
|
+
/** Why `computer`'s GPUs cannot be had on `provider` in `mode`, in gpuRefused's words; undefined when they can, or it
|
|
121
|
+
* asks for none (only a sandbox does). */
|
|
79
122
|
function gpuRefusal(kinds, computer, provider, mode) {
|
|
80
123
|
const asked = gpuOf(computer);
|
|
81
124
|
if (!asked)
|
|
82
125
|
return undefined;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
126
|
+
const refused = gpuRefused(asked, sandboxGpu(kinds, provider), folderMount(mode), provider.label);
|
|
127
|
+
if (!refused)
|
|
128
|
+
return undefined;
|
|
129
|
+
return refused.folder ? `${refused.words} (Settings → Computers)` : `${provider.label} can't give this agent's computer its GPUs: ${refused.words} (Settings → Computers)`;
|
|
86
130
|
}
|
|
87
131
|
/** The required keys `provider` has no saved value for, by name. */
|
|
88
132
|
const missingKeys = (provider, saved) => provider.keys.filter((key) => key.required && !saved.has(key.name)).map((key) => key.name);
|
|
@@ -94,8 +138,9 @@ const local = (provider) => provider.mounts.includes("bind");
|
|
|
94
138
|
/** The routes' work over the server's store: GET /v2/computers (view), PUT /v2/computers/{provider}/keys (saveKeys), POST
|
|
95
139
|
* /v2/computers/{provider}/test (test), and the claim's refusal (claimRefusal). */
|
|
96
140
|
export function createComputerRoutes(options) {
|
|
97
|
-
const { store, sealKey, kinds, factories, settings = {}, keyTable = KEY_TABLE, tools, env = {}, answers = daemonUp } = options;
|
|
141
|
+
const { store, sealKey, kinds, factories, settings = {}, keyTable = KEY_TABLE, tools, env = {}, answers = daemonUp, hostWhy = {} } = options;
|
|
98
142
|
const providerOf = (id) => kinds.PROVIDERS.find((one) => one.id === id);
|
|
143
|
+
const hostOf = (provider) => (Object.hasOwn(hostWhy, provider.id) ? hostWhy[provider.id] : undefined);
|
|
99
144
|
const modeNow = async () => (typeof options.mode === "function" ? options.mode() : options.mode);
|
|
100
145
|
/** Why a computer of `kind` on `provider` can't be had for its daemon (a provider that binds a folder of this machine,
|
|
101
146
|
* `said` its answer, in folder `mode`): none answering is the one wording (docker-daemon.ts noDockerWords); else its
|
|
@@ -105,11 +150,16 @@ export function createComputerRoutes(options) {
|
|
|
105
150
|
* that serves it, with its keys (saved or not, never a value) and whether a run could have it now. */
|
|
106
151
|
async function view() {
|
|
107
152
|
const mode = await modeNow();
|
|
153
|
+
const choice = (setting) => shellChoiceOf(setting, mode === "disk" ? 2 : 1, kinds);
|
|
108
154
|
// Every provider's keys in one read: each a SecretMeta named for its provider, set by the environment or the store row
|
|
109
155
|
// of its key's name.
|
|
110
156
|
const slots = kinds.PROVIDERS.flatMap((provider) => provider.keys.map((key) => ({ secret: secretName("computer", provider.id, key.name), env: key.name, row: key.name })));
|
|
111
157
|
const metas = new Map((await keyMetaOf(store, slots, env)).map((meta) => [meta.name, meta]));
|
|
112
158
|
const saved = new Set(slots.filter((slot) => metas.get(slot.secret).set).map((slot) => slot.env));
|
|
159
|
+
// Under this server's AGENTRUN_BOX_ALLOW none, a computer that needs a network is refused at a
|
|
160
|
+
// run's start and its claim (resolve-computer.ts noNetworkRefusal), so it is never ready here, whatever its keys.
|
|
161
|
+
const refusedOpen = (provider) => boxAllowOf(env) === "none" && needsNetwork(provider.network);
|
|
162
|
+
const unusable = (kind, provider) => modeRefusal(kind, provider, mode) ?? (refusedOpen(provider) ? noNetworkWhy(provider) : undefined);
|
|
113
163
|
// Each provider that binds a folder of this machine asked once for the view: its daemon answers, or why not.
|
|
114
164
|
const daemons = new Map(await Promise.all(kinds.PROVIDERS.filter(local).map(async (provider) => [provider.id, await answers(provider.id)])));
|
|
115
165
|
return {
|
|
@@ -119,15 +169,24 @@ export function createComputerRoutes(options) {
|
|
|
119
169
|
const providers = serving.map((provider) => {
|
|
120
170
|
const missing = missingKeys(provider, saved);
|
|
121
171
|
const daemon = daemons.get(provider.id);
|
|
122
|
-
const why =
|
|
123
|
-
|
|
172
|
+
const why = unusable(kind, provider) ?? (daemon ? daemonWhy(kind, daemon, mode) : undefined) ?? hostOf(provider) ?? (missing.length ? keysWhy(provider, missing) : undefined);
|
|
173
|
+
// The images an agent's computer.image may name for this kind: those of its configurations that serve it.
|
|
174
|
+
const serving = provider.capabilities.filter((one) => kinds.servingRefusals(one, kind).length === 0);
|
|
175
|
+
const images = imagesOf(serving, provider.defaultImage?.[kind]);
|
|
176
|
+
const network = refusedOpen(provider) ? NETWORK_REFUSED_WORDS : networkWords(provider.network);
|
|
124
177
|
// A sandbox's GPUs: only a sandbox takes them (computer-setting.ts computerIssues).
|
|
125
178
|
const gpu = kind === "sandbox" ? sandboxGpu(kinds, provider) : undefined;
|
|
126
|
-
|
|
179
|
+
// The configurations of this kind that keep an agent's own computer (computer-setting.ts persistenceIssues).
|
|
180
|
+
const keeping = serving.filter((one) => one.persistence !== undefined);
|
|
181
|
+
const keptImages = images.filter((image) => keeping.some((one) => (one.image ?? provider.defaultImage?.[kind]) === image));
|
|
182
|
+
const persistent = keeping.length === 0 ? undefined : images.length > 0 ? { images: keptImages } : {};
|
|
183
|
+
return { id: provider.id, name: provider.label, metered: provider.metered, secrets: provider.keys.map((key) => metas.get(secretName("computer", provider.id, key.name))), required: provider.keys.filter((key) => key.required).map((key) => secretName("computer", provider.id, key.name)), ready: why === undefined, ...(why ? { why } : {}), ...(network ? { network } : {}), ...(images.length > 0 ? { images } : {}), ...(persistent ? { persistent } : {}), ...(gpu ? { gpu: gpuView(gpu, provider.label, mode) } : {}), ...choice({ kind, provider: provider.id }) };
|
|
127
184
|
});
|
|
128
|
-
const offered = kind === "none" || serving.some((provider) =>
|
|
129
|
-
const why = offered ? undefined
|
|
130
|
-
|
|
185
|
+
const offered = kind === "none" || serving.some((provider) => unusable(kind, provider) === undefined);
|
|
186
|
+
const why = offered ? undefined
|
|
187
|
+
: serving.length && serving.every(refusedOpen) ? `every provider of a ${kind} computer needs a network, and this server's ${BOX_ALLOW_ENV} is none (no network)`
|
|
188
|
+
: serving.length ? `no provider of a ${kind} computer can reach this server's run folders` : `no provider serves a ${kind} computer`;
|
|
189
|
+
return { kind, offered, ...(why ? { why } : {}), groups: [...spec.required, ...spec.optional], tools: [...tools(kind)], providers, ...(kind === "none" ? choice({ kind: "none" }) : {}) };
|
|
131
190
|
}),
|
|
132
191
|
};
|
|
133
192
|
}
|
|
@@ -181,7 +240,8 @@ export function createComputerRoutes(options) {
|
|
|
181
240
|
/** Why a run of an agent whose computer is `computer` cannot have it here, in words naming the setting to fill;
|
|
182
241
|
* undefined when it can. Checked at the claim: the provider must serve the kind (servingRefusals' words), fit this
|
|
183
242
|
* server's folder mode, give a sandbox the GPUs it asks for (checkGpu's words), have its daemon answer where it binds
|
|
184
|
-
* a folder of this machine (Docker),
|
|
243
|
+
* a folder of this machine (Docker), find what it runs on this machine (hostWhy's words), and have every required key
|
|
244
|
+
* saved; a key refusal names the route that saves them. */
|
|
185
245
|
async function claimRefusal(computer) {
|
|
186
246
|
if (computer.kind === "none")
|
|
187
247
|
return undefined;
|
|
@@ -193,7 +253,7 @@ export function createComputerRoutes(options) {
|
|
|
193
253
|
return `${provider.label} does not serve a ${computer.kind} computer${words.length ? ` (${words.join("; ")})` : ""}: set this agent's computer to one it serves (Settings → Computers)`;
|
|
194
254
|
}
|
|
195
255
|
const mode = await modeNow();
|
|
196
|
-
const refused = modeRefusal(computer.kind, provider, mode) ?? gpuRefusal(kinds, computer, provider, mode) ?? (local(provider) ? daemonWhy(computer.kind, await answers(provider.id), mode) : undefined);
|
|
256
|
+
const refused = modeRefusal(computer.kind, provider, mode) ?? gpuRefusal(kinds, computer, provider, mode) ?? (local(provider) ? daemonWhy(computer.kind, await answers(provider.id), mode) : undefined) ?? hostOf(provider);
|
|
197
257
|
if (refused)
|
|
198
258
|
return refused;
|
|
199
259
|
const missing = missingKeys(provider, new Set([...(await sealedKeyNames(store)), ...provider.keys.filter((key) => envValue(env, key.name) !== undefined).map((key) => key.name)]));
|
|
@@ -210,11 +270,30 @@ export function createComputerRoutes(options) {
|
|
|
210
270
|
return { ok: false, error: { code: COMPUTER_UNAVAILABLE, message: why } };
|
|
211
271
|
return providerOptions(computer.provider, await keysOf(providerOf(computer.provider)), settings, keyTable);
|
|
212
272
|
}
|
|
213
|
-
|
|
273
|
+
/** The provider an agent's own computer lives on (workspace/agent-computer.ts reconcileAgentComputer deletes it
|
|
274
|
+
* through it): made from its saved keys and the server's settings, with the create() options of the configuration
|
|
275
|
+
* `image` selects, and the store's ledger (the factories'). Throws, in words, when it cannot be made here. */
|
|
276
|
+
async function providerFor(providerId, image) {
|
|
277
|
+
const entry = providerOf(providerId);
|
|
278
|
+
if (!entry)
|
|
279
|
+
throw new Error(`this server has no computer provider ${JSON.stringify(providerId)}`);
|
|
280
|
+
const options = providerOptions(providerId, await keysOf(entry), settings, keyTable);
|
|
281
|
+
if (!options.ok)
|
|
282
|
+
throw new Error(options.error.message);
|
|
283
|
+
const make = Object.hasOwn(factories, providerId) ? factories[providerId] : undefined;
|
|
284
|
+
if (typeof make !== "function")
|
|
285
|
+
throw new Error(`this server cannot make a ${entry.label} provider`);
|
|
286
|
+
const configuration = image === undefined ? undefined : entry.capabilities.find((one) => one.image === image);
|
|
287
|
+
const made = (await make({ ...options.options, ...(configuration?.options ?? {}) }));
|
|
288
|
+
if (typeof made.release !== "function")
|
|
289
|
+
throw new Error(`this server's ${entry.label} provider cannot release a computer`);
|
|
290
|
+
return made;
|
|
291
|
+
}
|
|
292
|
+
return { view, saveKeys, test, claimRefusal, claimOptions, providerFor };
|
|
214
293
|
}
|
|
215
294
|
/** This server's folder mode, read from the store at each call: "disk" (Mode 2) while the Archil settings row is saved
|
|
216
295
|
* (PUT /v2/workspace/archil), else "local" (Mode 1). createComputerRoutes' `mode`. */
|
|
217
|
-
export const folderModeOf = (store) => async () => ((await inArchilMode(store)) ? "disk" : "local");
|
|
296
|
+
export const folderModeOf = (store, env = {}) => async () => ((await inArchilMode(store, env)) ? "disk" : "local");
|
|
218
297
|
/** Settings → Computers' routes, by their operation names: GET /v2/computers, PUT /v2/computers/{provider}/keys and POST
|
|
219
298
|
* /v2/computers/{provider}/test. */
|
|
220
299
|
export const COMPUTER_SETTINGS_ROUTES = new Set(["listComputers", "saveComputerKeys", "testComputer"]);
|