@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/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import { startedWith } from "./adapters.js";
|
|
|
14
14
|
import { REPEAT_MS, stopOnSignals } from "./stop-signals.js";
|
|
15
15
|
import { canOpen } from "./host.js";
|
|
16
16
|
import { resetPassword } from "./owner.js";
|
|
17
|
-
import { banner
|
|
17
|
+
import { banner } from "./print.js";
|
|
18
18
|
import { DEFAULT_PORT, fauxEnvOf, startServe } from "./server.js";
|
|
19
19
|
import { besideRunnerOptions, besideStopping, runnerBeside } from "./runner/beside.js";
|
|
20
20
|
import { apiOnlyFrom } from "./api-only.js";
|
|
@@ -22,7 +22,7 @@ import { surviveClosedPipes } from "./closed-pipes.js";
|
|
|
22
22
|
// A stdout or stderr its reader closed loses the lines written after, never the process (closed-pipes.ts): for every
|
|
23
23
|
// command, the server and the runner alike.
|
|
24
24
|
surviveClosedPipes();
|
|
25
|
-
const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--open] [--faux MODULE] [--faux-browser MODULE] [--allow-host NAME ...] [--max-runs N] [--drain-timeout D] [--documents DIR] [--allow-code-nodes] [--learning on|off] [--learning-budget BYTES] [--grade-model MODEL] [--no-runner]
|
|
25
|
+
const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--open] [--faux MODULE] [--faux-browser MODULE] [--faux-github] [--allow-host NAME ...] [--max-runs N] [--drain-timeout D] [--documents DIR] [--allow-code-nodes] [--learning on|off] [--learning-budget BYTES] [--grade-model MODEL] [--no-runner]
|
|
26
26
|
agentrun-serve reset-password [--data DIR]
|
|
27
27
|
agentrun-serve validate-template DIR
|
|
28
28
|
agentrun-serve eval-template DIR [--case NAME ...] [--runs N] [--server URL] [--grader-model PROVIDER/MODEL] [--report FILE] [--faux MODULE]
|
|
@@ -40,6 +40,9 @@ const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--
|
|
|
40
40
|
--faux-browser MODULE
|
|
41
41
|
with --faux only: the browser tool's provider and driver from MODULE's default export (a fake
|
|
42
42
|
browser, no vendor, no key), for the console's real-browser tests
|
|
43
|
+
--faux-github with --faux only: a fake GitHub App, connected at the start and answered in this process, so
|
|
44
|
+
GitHub triggers run with nothing sent to GitHub; its webhook secret is in DIR/faux-github.json.
|
|
45
|
+
On a scratch data directory: refused where another GitHub App is connected
|
|
43
46
|
--allow-host NAME another Host name to accept (repeatable)
|
|
44
47
|
--max-runs N the most runs the runner beside the server holds at once, the rest waiting queued (default
|
|
45
48
|
AGENTRUN_MAX_RUNS, else as many pi runs as this host's memory holds); the capabilities'
|
|
@@ -73,8 +76,9 @@ published port, or a proxy's URL), and the link printed uses it; with none, Rend
|
|
|
73
76
|
end, and per refused credential; AGENTRUN_LOG=quiet leaves out the request lines.
|
|
74
77
|
|
|
75
78
|
AGENTRUN_API_ONLY=1 serves the run routes alone, for a server behind its caller's backend: a run's launch, read, list,
|
|
76
|
-
timeline, messages, stop, cancel, kill and cap raise, its files and uploads,
|
|
77
|
-
address (the page, sign-in, setup, settings, MCP, triggers and their hooks,
|
|
79
|
+
timeline, messages, stop, cancel, kill and cap raise, its files and uploads, an agent's Archil disk, capabilities, health
|
|
80
|
+
and usage. Every other address (the page, sign-in, setup, settings, MCP, triggers and their hooks, the rest of agents)
|
|
81
|
+
is a 404, and there are no accounts.
|
|
78
82
|
|
|
79
83
|
The page is for one person, who signs in with a password (AGENTRUN_ACCOUNTS=0 turns this off; the token works for
|
|
80
84
|
scripts and the CLI either way). With no AGENTRUN_PUBLIC_URL, listening on loopback, the first visit to the page sets the
|
|
@@ -249,6 +253,7 @@ try {
|
|
|
249
253
|
open: { type: "boolean", default: false },
|
|
250
254
|
faux: { type: "string" },
|
|
251
255
|
"faux-browser": { type: "string" },
|
|
256
|
+
"faux-github": { type: "boolean", default: false },
|
|
252
257
|
"allow-host": { type: "string", multiple: true, default: [] },
|
|
253
258
|
"max-runs": { type: "string" },
|
|
254
259
|
"drain-timeout": { type: "string" },
|
|
@@ -291,6 +296,10 @@ if (values["faux-browser"] && !values.faux) {
|
|
|
291
296
|
console.error(`--faux-browser goes with --faux\n\n${USAGE}`);
|
|
292
297
|
process.exit(2);
|
|
293
298
|
}
|
|
299
|
+
if (values["faux-github"] && !values.faux) {
|
|
300
|
+
console.error(`--faux-github goes with --faux\n\n${USAGE}`);
|
|
301
|
+
process.exit(2);
|
|
302
|
+
}
|
|
294
303
|
const budget = values["learning-budget"];
|
|
295
304
|
if (budget !== undefined && !/^\d+$/.test(budget)) {
|
|
296
305
|
console.error(`--learning-budget takes a whole number of bytes\n\n${USAGE}`);
|
|
@@ -298,6 +307,22 @@ if (budget !== undefined && !/^\d+$/.test(budget)) {
|
|
|
298
307
|
}
|
|
299
308
|
const data = values.data ?? defaultData();
|
|
300
309
|
const given = secret("AGENTRUN_TOKEN") || undefined;
|
|
310
|
+
// The stop is listened for before anything starts: a SIGTERM or SIGINT during the start (a platform's redeploy, the
|
|
311
|
+
// moment the banner shows) is kept, never the default end by signal that cuts what the start began. Once the start has
|
|
312
|
+
// what a stop closes, the stop below takes over (stopOnSignals), and a stop asked meanwhile runs it, through the same
|
|
313
|
+
// drain. A second signal a while after the first, still during the start, is a person who wants out now: exit 130.
|
|
314
|
+
let stopping;
|
|
315
|
+
let askedAt;
|
|
316
|
+
const signalled = () => {
|
|
317
|
+
if (stopping)
|
|
318
|
+
return stopping();
|
|
319
|
+
if (askedAt === undefined)
|
|
320
|
+
askedAt = Date.now();
|
|
321
|
+
else if (Date.now() - askedAt >= REPEAT_MS)
|
|
322
|
+
process.exit(130);
|
|
323
|
+
};
|
|
324
|
+
process.on("SIGINT", signalled);
|
|
325
|
+
process.on("SIGTERM", signalled);
|
|
301
326
|
// AGENTRUN_API_ONLY=1: the run routes alone (api-only.ts), and no owner; a value that is neither on nor off stops here.
|
|
302
327
|
let apiOnly;
|
|
303
328
|
try {
|
|
@@ -308,21 +333,6 @@ catch (error) {
|
|
|
308
333
|
process.exit(2);
|
|
309
334
|
}
|
|
310
335
|
const accounts = !apiOnly && process.env.AGENTRUN_ACCOUNTS !== "0";
|
|
311
|
-
// The Docker box image's first build said in words, as it starts and as it ends (print.ts boxImageLine); a line told
|
|
312
|
-
// before the banner is printed waits for it.
|
|
313
|
-
let imageSaid = false;
|
|
314
|
-
let bannered = false;
|
|
315
|
-
const early = [];
|
|
316
|
-
const onBoxImage = (state) => {
|
|
317
|
-
const line = boxImageLine(state, imageSaid);
|
|
318
|
-
if (line === undefined)
|
|
319
|
-
return;
|
|
320
|
-
imageSaid = true;
|
|
321
|
-
if (bannered)
|
|
322
|
-
console.log(line);
|
|
323
|
-
else
|
|
324
|
-
early.push(line);
|
|
325
|
-
};
|
|
326
336
|
// How it was started, for the hints that start it again (adapters.ts npxLine): itself and its runs read it.
|
|
327
337
|
Object.assign(process.env, startedWith({ ...(values.port !== undefined ? { port: values.port } : {}), open: values.open === true }));
|
|
328
338
|
let serve;
|
|
@@ -330,14 +340,13 @@ let serveOptions;
|
|
|
330
340
|
const trustedProxies = (process.env.AGENTRUN_TRUSTED_PROXIES ?? "").split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
331
341
|
try {
|
|
332
342
|
serve = await startServe(serveOptions = {
|
|
333
|
-
onBoxImage,
|
|
334
343
|
// The owner lock on a Postgres store lost for good: this server can serve nothing more, so it exits non-zero and its
|
|
335
344
|
// platform starts it again, rather than answer 503 for as long as it runs.
|
|
336
345
|
onStoreLost: (error) => {
|
|
337
346
|
console.error(`agentrun-serve: ${error.message}`);
|
|
338
347
|
process.exit(1);
|
|
339
348
|
},
|
|
340
|
-
data, port, ...(values.port === undefined ? { nextFreePort: true } : {}), ...(values.listen ? { host: values.listen } : {}), ...(given ? { token: given } : {}), ...(values.faux ? { faux: values.faux } : {}), ...(values["faux-browser"] ? { fauxBrowser: values["faux-browser"] } : {}), allowHosts: values["allow-host"],
|
|
349
|
+
data, port, ...(values.port === undefined ? { nextFreePort: true } : {}), ...(values.listen ? { host: values.listen } : {}), ...(given ? { token: given } : {}), ...(values.faux ? { faux: values.faux } : {}), ...(values["faux-browser"] ? { fauxBrowser: values["faux-browser"] } : {}), ...(values["faux-github"] ? { fauxGitHub: true } : {}), allowHosts: values["allow-host"],
|
|
341
350
|
...(values["max-runs"] !== undefined ? { maxRuns: Number(values["max-runs"]) } : {}),
|
|
342
351
|
...(values["drain-timeout"] ? { drainTimeout: values["drain-timeout"] } : {}), ...(values.documents ? { documents: values.documents } : {}), ...(values["allow-code-nodes"] ? { allowCodeNodes: true } : {}), ...(values.learning !== undefined ? { learning: values.learning } : {}), ...(values["grade-model"] ? { gradeModel: values["grade-model"] } : {}), ...(budget !== undefined ? { learningBudget: Number(budget) } : {}), log: (line) => void process.stdout.write(`${line}\n`),
|
|
343
352
|
// The public address is the server's with accounts on or off: the Host names it serves, the webhook URLs it gives.
|
|
@@ -358,7 +367,8 @@ catch (error) {
|
|
|
358
367
|
// its turn for up to --drain-timeout.
|
|
359
368
|
let runnerProc;
|
|
360
369
|
const { loops, drainMs } = besideRunnerOptions(serveOptions, process.env);
|
|
361
|
-
|
|
370
|
+
// A stop asked during the server's start starts no runner: nothing is claimed for the stop to cut.
|
|
371
|
+
if (!values["no-runner"] && askedAt === undefined) {
|
|
362
372
|
try {
|
|
363
373
|
// The beside-runner sees the server's test switches (server.ts fauxEnvOf: --faux and its modules), which the CLI hands
|
|
364
374
|
// the server as options, never through this process's environment: without them a --faux start's runner looks its faux
|
|
@@ -382,9 +392,6 @@ for (const line of banner({ url: serve.url, baseUrl: serve.baseUrl, data, token:
|
|
|
382
392
|
// setup link with its code as the code was made (owner.ts).
|
|
383
393
|
if (serve.setupUrl && serve.setupOpen)
|
|
384
394
|
console.log(`Set your password: ${serve.setupUrl} (the first visit sets it)`);
|
|
385
|
-
bannered = true;
|
|
386
|
-
for (const line of early.splice(0))
|
|
387
|
-
console.log(line);
|
|
388
395
|
// The console's page, once the server listens: never its sign-in link, whose token would sit in the opener's arguments
|
|
389
396
|
// and the browser's history.
|
|
390
397
|
// API-only: there is no console, so nothing to open.
|
|
@@ -410,9 +417,11 @@ const stop = stopOnSignals({
|
|
|
410
417
|
done: (code) => (removeOwnRecord(record), process.exit(code)),
|
|
411
418
|
say: (line) => console.error(line),
|
|
412
419
|
});
|
|
413
|
-
|
|
414
|
-
process.on("SIGTERM", stop);
|
|
420
|
+
stopping = stop;
|
|
415
421
|
// Written whole under a name of its own, then renamed into place: a reader in another process (the npx command, a test
|
|
416
422
|
// waiting for this server) that finds the record reads all of it, never a file made but not yet filled.
|
|
417
423
|
writeDurableSync(record, `${JSON.stringify({ base_url: serve.baseUrl, pid: process.pid, ...(serve.tokenFile ? { token_file: serve.tokenFile } : {}) })}\n`);
|
|
418
424
|
chmodSync(record, 0o600);
|
|
425
|
+
// A stop asked during the start runs now, as one asked from here on would.
|
|
426
|
+
if (askedAt !== undefined)
|
|
427
|
+
stop(askedAt);
|
package/dist/computer-keys.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ProviderEntry } from "@parcha/agentrun-computer";
|
|
2
|
+
/** One key a provider takes: its name in its descriptor, the create() option it fills, and whether it is needed. */
|
|
2
3
|
export interface ProviderKey {
|
|
3
4
|
readonly name: string;
|
|
4
5
|
readonly option: string;
|
|
5
6
|
readonly required: boolean;
|
|
6
7
|
}
|
|
7
|
-
/**
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export interface ProviderSettings {
|
|
13
|
-
readonly modalApp?: string;
|
|
8
|
+
/** A setting that is no key but fills a create() option: its name in the server's settings, and its default. */
|
|
9
|
+
export interface ProviderSetting {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly option: string;
|
|
12
|
+
readonly default?: string;
|
|
14
13
|
}
|
|
14
|
+
/** The server's settings that are no key, by their names in the descriptors (modalApp): what fills each setting. */
|
|
15
|
+
export type ProviderSettings = Readonly<Record<string, string | undefined>>;
|
|
15
16
|
/** An answer in the registry's shape: a value, or an error with its code and words. */
|
|
16
17
|
export type KeyResult<T> = {
|
|
17
18
|
ok: true;
|
|
@@ -48,13 +49,22 @@ export interface TestableProvider {
|
|
|
48
49
|
}
|
|
49
50
|
/** A provider module's create(), by provider id: the computer package's, or a test's stand-in. */
|
|
50
51
|
export type ProviderFactories = Readonly<Partial<Record<string, (options: Record<string, string>) => TestableProvider | Promise<TestableProvider>>>>;
|
|
51
|
-
/** The table the map reads: each provider's keys and
|
|
52
|
+
/** The table the map reads: each provider's keys, settings and name in words, by id. Serve's own (KEY_TABLE, the
|
|
53
|
+
* computer package's descriptors), or --faux's (keyTableOf its entries). */
|
|
52
54
|
export interface KeyTable {
|
|
53
55
|
readonly keys: Readonly<Record<string, readonly ProviderKey[]>>;
|
|
54
56
|
readonly labels: Readonly<Record<string, string>>;
|
|
57
|
+
readonly settings?: Readonly<Record<string, readonly ProviderSetting[]>>;
|
|
55
58
|
}
|
|
59
|
+
/** The key table of `entries` (the kind registry's PROVIDERS, each from its descriptor). */
|
|
60
|
+
export declare function keyTableOf(entries: readonly Pick<ProviderEntry, "id" | "label" | "keys" | "settings">[]): KeyTable;
|
|
61
|
+
/** Serve's table: every provider the computer package declares. */
|
|
56
62
|
export declare const KEY_TABLE: KeyTable;
|
|
57
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Provider `providerId`'s create() options from its saved keys (by its descriptor's names) and the server's settings
|
|
65
|
+
* (each of its descriptor's settings, by name, else its default). An id the table does not list is refused, naming the
|
|
66
|
+
* providers it does.
|
|
67
|
+
*/
|
|
58
68
|
export declare function providerOptions(providerId: string, keys: Readonly<Record<string, string>>, settings?: ProviderSettings, table?: KeyTable): OptionsAnswer;
|
|
59
69
|
/**
|
|
60
70
|
* Settings' "test connection" for `providerId` (the kind registry's TestConnection, and serve's ComputerRegistry.test):
|
package/dist/computer-keys.js
CHANGED
|
@@ -1,57 +1,36 @@
|
|
|
1
|
-
// Settings → Computers' keys, serve side: a provider's saved keys, by the names
|
|
2
|
-
//
|
|
3
|
-
// (the registry's TestConnection: one account-level read that never makes a computer), its coded
|
|
1
|
+
// Settings → Computers' keys, serve side: a provider's saved keys, by the names its descriptor declares (the computer
|
|
2
|
+
// package's PROVIDERS, derived from each provider's descriptor), as that provider's create() options, and Settings' "test
|
|
3
|
+
// connection" over them (the registry's TestConnection: one account-level read that never makes a computer), its coded
|
|
4
|
+
// errors in plain words.
|
|
4
5
|
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// on; an empty optional key is left out; a required one not saved refuses in
|
|
8
|
-
// is made. The provider modules themselves (each one's create()) are passed
|
|
9
|
-
// computer package's; a test gives stand-ins): a provider with no module
|
|
10
|
-
// No key is ever in an answer: each value is scrubbed from the provider's
|
|
11
|
-
// only by their names.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{ name
|
|
17
|
-
|
|
18
|
-
{ name:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
],
|
|
24
|
-
e2b: [{ name: "E2B_API_KEY", option: "apiKey", required: true }],
|
|
25
|
-
orgo: [{ name: "ORGO_API_KEY", option: "apiKey", required: true }],
|
|
26
|
-
"phone-harness": [{ name: "PHONE_HARNESS_API_KEY", option: "apiKey", required: true }],
|
|
27
|
-
browserbase: [
|
|
28
|
-
{ name: "BROWSERBASE_API_KEY", option: "apiKey", required: true },
|
|
29
|
-
{ name: "BROWSERBASE_PROJECT_ID", option: "projectId", required: true },
|
|
30
|
-
],
|
|
31
|
-
kernel: [{ name: "KERNEL_API_KEY", option: "apiKey", required: true }],
|
|
32
|
-
// This machine's Chrome: no key.
|
|
33
|
-
local: [],
|
|
34
|
-
};
|
|
35
|
-
/** Each provider's name in words (the registry's labels). */
|
|
36
|
-
const LABELS = {
|
|
37
|
-
docker: "Docker",
|
|
38
|
-
daytona: "Daytona",
|
|
39
|
-
modal: "Modal",
|
|
40
|
-
e2b: "E2B",
|
|
41
|
-
orgo: "Orgo",
|
|
42
|
-
"phone-harness": "Phone harness",
|
|
43
|
-
browserbase: "Browserbase",
|
|
44
|
-
kernel: "Kernel",
|
|
45
|
-
local: "Local Chrome",
|
|
46
|
-
};
|
|
47
|
-
/** The Modal app a server's computers live in when its settings name none (serve's box app until now). */
|
|
48
|
-
export const DEFAULT_MODAL_APP = "agentrun";
|
|
49
|
-
export const KEY_TABLE = { keys: PROVIDER_KEYS, labels: LABELS };
|
|
6
|
+
// Serve knows no vendor here: each key's name and the option it fills, each setting that is no key (its name in the
|
|
7
|
+
// server's settings, its option and its default), and each provider's label all come from the descriptor. A name a
|
|
8
|
+
// provider does not declare is never passed on; an empty optional key is left out; a required one not saved refuses in
|
|
9
|
+
// words naming what to save, before anything is made. The provider modules themselves (each one's create()) are passed
|
|
10
|
+
// in (workspace/computer-providers.ts makes the computer package's; a test gives stand-ins): a provider with no module
|
|
11
|
+
// here answers that its test is not available. No key is ever in an answer: each value is scrubbed from the provider's
|
|
12
|
+
// words, and the words this module adds name keys only by their names.
|
|
13
|
+
import { PROVIDERS } from "@parcha/agentrun-computer";
|
|
14
|
+
/** The key table of `entries` (the kind registry's PROVIDERS, each from its descriptor). */
|
|
15
|
+
export function keyTableOf(entries) {
|
|
16
|
+
return {
|
|
17
|
+
keys: Object.fromEntries(entries.map((entry) => [entry.id, entry.keys.map(({ name, option, required }) => ({ name, option, required }))])),
|
|
18
|
+
labels: Object.fromEntries(entries.map((entry) => [entry.id, entry.label])),
|
|
19
|
+
settings: Object.fromEntries(entries.map((entry) => [entry.id, (entry.settings ?? []).map(({ name, option, default: fallback }) => ({ name, option, ...(fallback === undefined ? {} : { default: fallback }) }))])),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** Serve's table: every provider the computer package declares. */
|
|
23
|
+
export const KEY_TABLE = keyTableOf(PROVIDERS);
|
|
50
24
|
const has = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
|
|
51
25
|
const labelOf = (providerId, table) => (has(table.labels, providerId) ? table.labels[providerId] : providerId);
|
|
52
26
|
const refused = (code, message) => ({ ok: false, error: { code, message } });
|
|
53
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Provider `providerId`'s create() options from its saved keys (by its descriptor's names) and the server's settings
|
|
29
|
+
* (each of its descriptor's settings, by name, else its default). An id the table does not list is refused, naming the
|
|
30
|
+
* providers it does.
|
|
31
|
+
*/
|
|
54
32
|
export function providerOptions(providerId, keys, settings = {}, table = KEY_TABLE) {
|
|
33
|
+
// The table is every descriptor's (keyTableOf(PROVIDERS)), so an id it does not list is no provider at all.
|
|
55
34
|
if (!has(table.keys, providerId))
|
|
56
35
|
return refused("unsupported", `${providerId} is not a computer provider: ${Object.keys(table.keys).join(", ")}`);
|
|
57
36
|
const label = labelOf(providerId, table);
|
|
@@ -67,8 +46,12 @@ export function providerOptions(providerId, keys, settings = {}, table = KEY_TAB
|
|
|
67
46
|
if (missing.length > 0) {
|
|
68
47
|
return refused("missing_key", `${label} needs ${missing.join(" and ")} saved: save ${missing.length > 1 ? "them" : "it"} in Settings → Computers (PUT /v2/computers/${providerId}/keys)`);
|
|
69
48
|
}
|
|
70
|
-
|
|
71
|
-
|
|
49
|
+
for (const setting of table.settings && has(table.settings, providerId) ? table.settings[providerId] : []) {
|
|
50
|
+
const given = has(settings, setting.name) ? settings[setting.name]?.trim() : undefined;
|
|
51
|
+
const value = given || setting.default;
|
|
52
|
+
if (value !== undefined && value !== "")
|
|
53
|
+
options[setting.option] = value;
|
|
54
|
+
}
|
|
72
55
|
return { ok: true, options };
|
|
73
56
|
}
|
|
74
57
|
/** `text` with every key value in `values` replaced by "[the key]". */
|
|
@@ -101,12 +84,8 @@ function wordsFor(code, providerId, said, table) {
|
|
|
101
84
|
return `${label}'s settings are not valid.${vendor}`;
|
|
102
85
|
case "unsupported":
|
|
103
86
|
return `${label} can't be tested here.${vendor}`;
|
|
104
|
-
|
|
105
|
-
case "
|
|
106
|
-
case "modal":
|
|
107
|
-
case "e2b":
|
|
108
|
-
case "orgo":
|
|
109
|
-
case "phone":
|
|
87
|
+
// The computer package's one code for a vendor's own failure (ComputerErrorCode "vendor"), whatever the vendor.
|
|
88
|
+
case "vendor":
|
|
110
89
|
return `${label} answered with an error.${vendor}`;
|
|
111
90
|
default:
|
|
112
91
|
return `The test of ${label} failed.${vendor}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ComputerHoldAnswer, type ComputerCallOptions, type ComputerCallStore, computerAsk, computerHoldOf, handBackComputer,
|
|
1
|
+
import { type ComputerHoldAnswer, type ComputerCallOptions, type ComputerCallStore, computerAsk, computerHoldOf, handBackComputer, runViewedKind, takeOverComputer, type ViewedKind } from "./computer-commands.js";
|
|
2
2
|
import { type HoldState } from "./workspace/computer-hold.js";
|
|
3
3
|
export type { ViewedKind } from "./computer-commands.js";
|
|
4
4
|
export { computerAsk, computerHoldOf, handBackComputer, runViewedKind, takeOverComputer };
|
|
@@ -18,9 +18,6 @@ export declare const COMPUTER_ROUTES: ReadonlySet<string>;
|
|
|
18
18
|
export declare const TAKE_OVER_MINUTES: number;
|
|
19
19
|
/** Run `runId`'s desktop or phone, from the store: its kind, whether it is up, and who drives it. */
|
|
20
20
|
export declare function computerViewOf(store: ComputerCallStore, runId: string, options?: ComputerCallOptions): Promise<ComputerViewRead>;
|
|
21
|
-
/** Whether the run's computer is taken over now, for the run read's computer field (run-computer.ts ComputerStateOf):
|
|
22
|
-
* from the run's journal and its rows. */
|
|
23
|
-
export declare const takenOverIn: (entries: readonly JournalEntry[], commands: Parameters<typeof holdShown>[1]) => boolean;
|
|
24
21
|
/** How a request to one of the routes came: by the owner's signed-in page, or with a token; whether this server has
|
|
25
22
|
* accounts (for the refusal's words); its body. */
|
|
26
23
|
export type ComputerRequest = {
|
package/dist/computer-routes.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// A run's desktop or phone, as its owner takes it: POST /v2/runs/{id}/computer/take-over and POST .../computer/hand-back
|
|
2
2
|
// (the hand-back for every kind: a browser's answers its agent's ask, as POST .../browser/hand-back does). Owner-only, as
|
|
3
|
-
// a run's browser is: the owner's password session in the console, never a token. GET /v2/runs/{id}/computer
|
|
4
|
-
//
|
|
3
|
+
// a run's browser is: the owner's password session in the console, never a token. GET /v2/runs/{id}/computer is answered by
|
|
4
|
+
// server.ts from computerView (computer-view.ts) over computerHoldOf; computerViewOf is the store-backed read of the run's
|
|
5
|
+
// computer the take-over tests check against.
|
|
5
6
|
//
|
|
6
7
|
// Everything is read from the one store (computer-commands.ts): the run's computer is up, and who drives it, as the run's
|
|
7
8
|
// runner committed them to the run's journal; a take-over or hand-back is a command row the runner applies to the run's
|
|
@@ -26,9 +27,6 @@ export async function computerViewOf(store, runId, options = {}) {
|
|
|
26
27
|
return { kind, state: "none", hold: "agent", why: `this run's ${kind} is not up now` };
|
|
27
28
|
return { kind, state: "live", hold: holdShown(hold, await store.commands(runId, 0)).state };
|
|
28
29
|
}
|
|
29
|
-
/** Whether the run's computer is taken over now, for the run read's computer field (run-computer.ts ComputerStateOf):
|
|
30
|
-
* from the run's journal and its rows. */
|
|
31
|
-
export const takenOverIn = (entries, commands) => holdShown(holdIn(entries), commands).state === "person";
|
|
32
30
|
/**
|
|
33
31
|
* One of our routes (COMPUTER_ROUTES, by its name in serve's route table) for run `runId`: { hold, outcome? }, or an
|
|
34
32
|
* ApiError. A token is refused (forbidden): a take-over drives the computer, so it takes the owner's signed-in page, as a
|
|
@@ -7,16 +7,21 @@ export type GpuSetting = {
|
|
|
7
7
|
readonly type: string;
|
|
8
8
|
readonly count: number;
|
|
9
9
|
};
|
|
10
|
-
/** The setting as a revision keeps it.
|
|
10
|
+
/** The setting as a revision keeps it. `image`: one the provider's descriptor offers for the kind (Orgo's `windows`);
|
|
11
|
+
* absent, the kind's default. A sandbox may ask for GPUs; whether its provider gives them is the claim's check. */
|
|
11
12
|
export type ComputerSetting = {
|
|
12
13
|
readonly kind: "none";
|
|
13
14
|
} | {
|
|
14
15
|
readonly kind: "sandbox";
|
|
15
16
|
readonly provider: string;
|
|
17
|
+
readonly image?: string;
|
|
16
18
|
readonly gpu?: GpuSetting;
|
|
19
|
+
readonly persistent?: boolean;
|
|
17
20
|
} | {
|
|
18
21
|
readonly kind: Exclude<ComputerKind, "none" | "sandbox">;
|
|
19
22
|
readonly provider: string;
|
|
23
|
+
readonly image?: string;
|
|
24
|
+
readonly persistent?: boolean;
|
|
20
25
|
};
|
|
21
26
|
/** The GPUs a setting asks for, or undefined. */
|
|
22
27
|
export declare const gpuOf: (computer: {
|
|
@@ -34,11 +39,9 @@ export type PlaceView = {
|
|
|
34
39
|
export declare const placeOfComputer: (computer: ComputerSetting) => PlaceView;
|
|
35
40
|
/** The setting a place says: runner is no computer, a sandbox place a sandbox on its box. */
|
|
36
41
|
export declare const computerOfPlace: (place: PlaceView) => ComputerSetting;
|
|
37
|
-
/** Whether two settings are the one setting: the kind and
|
|
42
|
+
/** Whether two settings are the one setting: the same kind and provider, and the same of each optional field. */
|
|
38
43
|
export declare const sameComputer: (a: ComputerSetting, b: ComputerSetting) => boolean;
|
|
39
|
-
/** What is wrong with `value` as a computer setting, at `field`: its shape only (the providers are the server's).
|
|
40
|
-
* sandbox's gpu is { type, count } in the words the computer package's checkGpu uses; whether its provider offers that
|
|
41
|
-
* type and count is the readiness check's and the claim's (resolve-computer.ts), in checkGpu's own words. */
|
|
44
|
+
/** What is wrong with `value` as a computer setting, at `field`: its shape only (the providers are the server's). */
|
|
42
45
|
export declare function computerIssues(value: unknown, field: string): InputIssue[];
|
|
43
46
|
/** The setting and its place a definition says, from `computer` or `place` (both: they must agree), or undefined when
|
|
44
47
|
* it says neither. Each is checked already (computerIssues, placeIssues). */
|
package/dist/computer-setting.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// An agent's computer, its one setting for where its tools run (Settings → Computers): `computer: { kind, provider?,
|
|
2
|
+
// image?, gpu?, persistent? }` on its revision. kind is none, sandbox, desktop, phone or browser; provider names one of
|
|
3
|
+
// the computer providers (the computer package's kind registry), and is absent for none; image names one the provider
|
|
4
|
+
// offers for the kind, and absent is the kind's default; a sandbox's gpu is { type, count }; persistent: true keeps the
|
|
5
|
+
// agent's own computer between its runs, where the configuration declares persistence. The v2 API's `place` is this
|
|
6
|
+
// setting's view, one to one where it can say it: {mode: "runner"} is {kind: "none"}, and {mode: "sandbox", box: X} is
|
|
7
|
+
// {kind: "sandbox", provider: X}. Writing either sets both. A desktop, phone or browser computer leaves the run's folder
|
|
8
|
+
// on the runner, so its place reads runner.
|
|
9
|
+
import { configurationOf, PROVIDERS, serves } from "@parcha/agentrun-computer";
|
|
1
10
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2
11
|
/** The kinds of computer an agent can be given. */
|
|
3
12
|
export const COMPUTER_KINDS = ["none", "sandbox", "desktop", "phone", "browser"];
|
|
@@ -6,42 +15,96 @@ export const COMPUTER_KINDS = ["none", "sandbox", "desktop", "phone", "browser"]
|
|
|
6
15
|
const GPU_TYPE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
7
16
|
/** The GPUs a setting asks for, or undefined. */
|
|
8
17
|
export const gpuOf = (computer) => (computer.kind === "sandbox" ? computer.gpu : undefined);
|
|
18
|
+
/**
|
|
19
|
+
* What a computer of a kind other than none may say beside its kind and provider: the kinds that take it (absent: any),
|
|
20
|
+
* and its own rule, the issues of a value that is wrong at `field`. The providers' offers are the server's, so only the
|
|
21
|
+
* shape is checked here. A sandbox's gpu is { type, count } in the words the computer package's checkGpu uses; whether
|
|
22
|
+
* its provider offers that type and count is the readiness check's and the claim's (resolve-computer.ts).
|
|
23
|
+
*/
|
|
24
|
+
const OPTIONAL = {
|
|
25
|
+
image: {
|
|
26
|
+
check: (value, field) => (typeof value === "string" && value.trim() !== "" && value === value.trim() ? [] : [{ field, reason: "invalid", message: `${field} is the name of an image the provider offers for the kind (GET /computers lists them), with no spaces around it` }]),
|
|
27
|
+
},
|
|
28
|
+
// An agent's own computer, kept between its runs (workspace/agent-computer.ts): true asks for it, where the provider's
|
|
29
|
+
// configuration keeps one (persistenceIssues); false or absent is a fresh computer for each run.
|
|
30
|
+
persistent: {
|
|
31
|
+
check: (value, field) => (typeof value === "boolean" ? [] : [{ field, reason: "wrong_type", message: `${field} is true (this agent keeps its own computer between runs) or false (a fresh one for each run)` }]),
|
|
32
|
+
},
|
|
33
|
+
gpu: {
|
|
34
|
+
kinds: ["sandbox"],
|
|
35
|
+
check: (gpu, field) => {
|
|
36
|
+
if (!isObject(gpu) || Object.keys(gpu).some((key) => key !== "type" && key !== "count"))
|
|
37
|
+
return [{ field, reason: "wrong_type", message: "gpu is { type, count }: a GPU type this provider declares, and how many" }];
|
|
38
|
+
if (typeof gpu.type !== "string" || gpu.type === "")
|
|
39
|
+
return [{ field: `${field}.type`, reason: "missing", message: "gpu.type is a GPU type the provider declares (GET /v2/computers lists each provider's)" }];
|
|
40
|
+
if (!GPU_TYPE.test(gpu.type))
|
|
41
|
+
return [{ field: `${field}.type`, reason: "wrong_type", message: `gpu.type ${JSON.stringify(gpu.type)} is not a GPU type name: letters, digits, dots, underscores and dashes, as GET /v2/computers lists each provider's` }];
|
|
42
|
+
if (!Number.isSafeInteger(gpu.count) || gpu.count < 1)
|
|
43
|
+
return [{ field: `${field}.count`, reason: "wrong_type", message: `gpu.count ${JSON.stringify(gpu.count)} is not a whole number from 1` }];
|
|
44
|
+
return [];
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
9
48
|
/** The place the setting reads as: sandbox on its provider, else the runner (no computer holds the run's folder). */
|
|
10
49
|
export const placeOfComputer = (computer) => (computer.kind === "sandbox" ? { mode: "sandbox", box: computer.provider } : { mode: "runner" });
|
|
11
50
|
/** The setting a place says: runner is no computer, a sandbox place a sandbox on its box. */
|
|
12
51
|
export const computerOfPlace = (place) => (place.mode === "sandbox" ? { kind: "sandbox", provider: place.box } : { kind: "none" });
|
|
13
|
-
/** Whether two settings are the one setting: the kind and
|
|
14
|
-
export const sameComputer = (a, b) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
52
|
+
/** Whether two settings are the one setting: the same kind and provider, and the same of each optional field. */
|
|
53
|
+
export const sameComputer = (a, b) => {
|
|
54
|
+
if (a.kind !== b.kind)
|
|
55
|
+
return false;
|
|
56
|
+
if (a.kind === "none" || b.kind === "none")
|
|
57
|
+
return true;
|
|
58
|
+
const one = a;
|
|
59
|
+
const other = b;
|
|
60
|
+
return a.provider === b.provider && Object.keys(OPTIONAL).every((key) => JSON.stringify(one[key]) === JSON.stringify(other[key]));
|
|
61
|
+
};
|
|
62
|
+
/** What is wrong with `value` as a computer setting, at `field`: its shape only (the providers are the server's). */
|
|
18
63
|
export function computerIssues(value, field) {
|
|
19
64
|
const bad = (reason, message, fix) => [{ field, reason, message, ...(fix ? { fix } : {}) }];
|
|
65
|
+
const keeps = ["kind", "provider", ...Object.keys(OPTIONAL)];
|
|
20
66
|
if (!isObject(value))
|
|
21
|
-
return bad("wrong_type", `${field} is an object: {kind}, or {kind, provider}, and
|
|
22
|
-
const extra = Object.keys(value).filter((key) => key
|
|
67
|
+
return bad("wrong_type", `${field} is an object: {kind}, or {kind, provider}, with ${Object.keys(OPTIONAL).join(" and ")} where its kind takes them`);
|
|
68
|
+
const extra = Object.keys(value).filter((key) => !keeps.includes(key));
|
|
23
69
|
if (extra.length)
|
|
24
|
-
return bad("not_allowed", `${field} keeps only
|
|
70
|
+
return bad("not_allowed", `${field} keeps only ${keeps.join(", ")}, not ${extra.join(" or ")}`, `Remove ${extra.map((key) => `${field}.${key}`).join(" and ")}.`);
|
|
25
71
|
if (typeof value.kind !== "string" || !COMPUTER_KINDS.includes(value.kind))
|
|
26
72
|
return bad(value.kind === undefined ? "missing" : "not_an_option", `${field}.kind is one of ${COMPUTER_KINDS.join(", ")}`);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!isObject(gpu) || Object.keys(gpu).some((key) => key !== "type" && key !== "count"))
|
|
36
|
-
return [{ field: `${field}.gpu`, reason: "wrong_type", message: "gpu is { type, count }: a GPU type this provider declares, and how many" }];
|
|
37
|
-
if (typeof gpu.type !== "string" || gpu.type === "")
|
|
38
|
-
return [{ field: `${field}.gpu.type`, reason: "missing", message: "gpu.type is a GPU type the provider declares (GET /v2/computers lists each provider's)" }];
|
|
39
|
-
if (!GPU_TYPE.test(gpu.type))
|
|
40
|
-
return [{ field: `${field}.gpu.type`, reason: "wrong_type", message: `gpu.type ${JSON.stringify(gpu.type)} is not a GPU type name: letters, digits, dots, underscores and dashes, as GET /v2/computers lists each provider's` }];
|
|
41
|
-
if (!Number.isSafeInteger(gpu.count) || gpu.count < 1)
|
|
42
|
-
return [{ field: `${field}.gpu.count`, reason: "wrong_type", message: `gpu.count ${JSON.stringify(gpu.count)} is not a whole number from 1` }];
|
|
73
|
+
const kind = value.kind;
|
|
74
|
+
for (const [key, { kinds }] of Object.entries(OPTIONAL)) {
|
|
75
|
+
if (value[key] !== undefined && kinds !== undefined && !kinds.includes(kind))
|
|
76
|
+
return bad("not_allowed", `only a ${kinds.join(" or ")} computer takes a ${key}, not a ${kind} one`, `Remove ${field}.${key}.`);
|
|
77
|
+
}
|
|
78
|
+
if (kind === "none") {
|
|
79
|
+
const named = keeps.filter((key) => key !== "kind" && value[key] !== undefined);
|
|
80
|
+
return named.length === 0 ? [] : bad("not_allowed", `no computer names no ${named.join(" or ")}`, `Remove ${named.map((key) => `${field}.${key}`).join(" and ")}.`);
|
|
43
81
|
}
|
|
44
|
-
|
|
82
|
+
if (typeof value.provider !== "string" || value.provider === "")
|
|
83
|
+
return bad("missing", `a ${kind} computer names its provider (Settings → Computers lists them)`);
|
|
84
|
+
const issues = Object.entries(OPTIONAL).flatMap(([key, { check }]) => (value[key] === undefined ? [] : check(value[key], `${field}.${key}`)));
|
|
85
|
+
if (issues.length > 0 || value.persistent !== true)
|
|
86
|
+
return issues;
|
|
87
|
+
return persistenceIssues(kind, value.provider, typeof value.image === "string" ? value.image : undefined, `${field}.persistent`);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Why `persistent: true` is refused, at `field`: the configuration the setting selects keeps no computer for an agent.
|
|
91
|
+
* Read from the computer package's registry, each configuration's declared persistence (kinds.test holds it equal to the
|
|
92
|
+
* built provider's), so a save needs no vendor call. A provider the registry does not list (a --faux one, or one the
|
|
93
|
+
* readiness check names as unknown) is left to the claim's refusal.
|
|
94
|
+
*/
|
|
95
|
+
function persistenceIssues(kind, provider, image, field) {
|
|
96
|
+
const entry = PROVIDERS.find((one) => one.id === provider);
|
|
97
|
+
if (!entry)
|
|
98
|
+
return [];
|
|
99
|
+
const configuration = configurationOf(entry.capabilities.filter((one) => serves(one, kind)), image, entry.defaultImage?.[kind]);
|
|
100
|
+
if (!configuration || configuration.persistence !== undefined)
|
|
101
|
+
return [];
|
|
102
|
+
return [{
|
|
103
|
+
field,
|
|
104
|
+
reason: "not_allowed",
|
|
105
|
+
message: `${entry.label}'s ${image === undefined ? "default" : JSON.stringify(image)} ${kind} keeps no computer for an agent between runs: it declares no persistence`,
|
|
106
|
+
fix: `Remove ${field}, or pick a computer that keeps one (GET /v2/computers shows which do).`,
|
|
107
|
+
}];
|
|
45
108
|
}
|
|
46
109
|
/** The setting and its place a definition says, from `computer` or `place` (both: they must agree), or undefined when
|
|
47
110
|
* it says neither. Each is checked already (computerIssues, placeIssues). */
|
|
@@ -60,8 +123,10 @@ export function settingOfDefinition(definition) {
|
|
|
60
123
|
export function settingConflict(computer, place, field) {
|
|
61
124
|
if (!isObject(computer) || !isObject(place) || computerIssues(computer, `${field}.computer`).length)
|
|
62
125
|
return [];
|
|
126
|
+
// A place says a kind and a provider only: a computer's image or GPUs are not ones it can contradict.
|
|
63
127
|
const said = computerOfPlace(place);
|
|
64
|
-
|
|
128
|
+
const { kind, provider } = computer;
|
|
129
|
+
if (sameComputer((kind === "none" ? { kind } : { kind, provider }), said))
|
|
65
130
|
return [];
|
|
66
131
|
return [{ field: `${field}.place`, reason: "invalid", message: "computer and place say two settings: give one (place is computer's v2 view)", fix: `Remove ${field}.place, or make it ${JSON.stringify(placeOfComputer(computer))}.` }];
|
|
67
132
|
}
|
package/dist/computer-view.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ export type ComputerAnswer = {
|
|
|
18
18
|
state: "none";
|
|
19
19
|
kind: ComputerKind;
|
|
20
20
|
hold: ComputerHold;
|
|
21
|
+
ended?: {
|
|
22
|
+
at: string;
|
|
23
|
+
why: string;
|
|
24
|
+
};
|
|
21
25
|
} | {
|
|
22
26
|
state: "live";
|
|
23
27
|
kind: ComputerKind;
|
|
@@ -32,7 +36,12 @@ export declare function computerView(deps: {
|
|
|
32
36
|
} | undefined>;
|
|
33
37
|
/** The run's computer, read only when no viewer is open. */
|
|
34
38
|
computer(): ComputerOf;
|
|
35
|
-
/** Who drives now.
|
|
36
|
-
* drives, as no seam answers. */
|
|
39
|
+
/** Who drives now. */
|
|
37
40
|
hold?(): ComputerHold;
|
|
41
|
+
/** Why the run's browser is not up, read only for a `none` browser: let go while the run waited for its person, and none
|
|
42
|
+
* opened since (browser-wait-ended.ts), with when; undefined otherwise. */
|
|
43
|
+
ended?(): Promise<{
|
|
44
|
+
at: string;
|
|
45
|
+
why: string;
|
|
46
|
+
} | undefined>;
|
|
38
47
|
}): Promise<ComputerAnswer>;
|
package/dist/computer-view.js
CHANGED
|
@@ -10,5 +10,6 @@ export async function computerView(deps) {
|
|
|
10
10
|
const computer = deps.computer();
|
|
11
11
|
if ("off" in computer)
|
|
12
12
|
return { state: "off", hold: "agent", why: computer.off };
|
|
13
|
-
|
|
13
|
+
const ended = computer.kind === "browser" ? await deps.ended?.() : undefined;
|
|
14
|
+
return ended ? { state: "none", kind: computer.kind, hold, ended } : { state: "none", kind: computer.kind, hold };
|
|
14
15
|
}
|