@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/owner.d.ts
CHANGED
package/dist/owner.js
CHANGED
|
@@ -114,7 +114,6 @@ export class SignInLimit {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
export class Owner {
|
|
117
|
-
dir;
|
|
118
117
|
openSetup;
|
|
119
118
|
say;
|
|
120
119
|
file;
|
|
@@ -127,7 +126,6 @@ export class Owner {
|
|
|
127
126
|
settingUp = false;
|
|
128
127
|
/** `openSetup`: no setup code; the first visit sets the password (no public address). `say` prints a setup code. */
|
|
129
128
|
constructor(dir, openSetup, say = () => { }, addresses = SIGN_IN_PEERS) {
|
|
130
|
-
this.dir = dir;
|
|
131
129
|
this.openSetup = openSetup;
|
|
132
130
|
this.say = say;
|
|
133
131
|
this.signIns = new SignInLimit(addresses);
|
package/dist/pause.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const LIVE_VIEW = "live.json";
|
|
4
|
-
export declare const pausedIn: (root: string) => boolean;
|
|
5
|
-
/** `fn`, waiting before each call while the run at `root` is paused. A cancel, or the call's own signal aborting, lets
|
|
6
|
-
* the call go to meet its abort. */
|
|
7
|
-
export declare function gated<P, R>(root: string, fn: (params: P) => Promise<R>): (params: P) => Promise<R>;
|
|
8
|
-
/** One line of the node log. `path` is the execution path; `item` the map item's index, null outside a map. */
|
|
1
|
+
/** One line of the node log (the runner's KINDS.nodeEffect entries). `path` is the execution path; `item` the map item's
|
|
2
|
+
* index, null outside a map. */
|
|
9
3
|
export type NodeLine = {
|
|
10
4
|
t: "node.start" | "node.end";
|
|
11
5
|
path: string;
|
|
@@ -34,8 +28,6 @@ export type NodeLine = {
|
|
|
34
28
|
error_truncated?: boolean;
|
|
35
29
|
at: string;
|
|
36
30
|
};
|
|
37
|
-
/** The node log of the run at `root`, in order; a torn last line is left out. */
|
|
38
|
-
export declare function readNodeLog(root: string): Promise<NodeLine[]>;
|
|
39
31
|
/** The llm calls the node log says answered, in order: a run's `llmRead` counts them, and its cost reads the rest. */
|
|
40
32
|
export declare const llmAnswers: (lines: readonly NodeLine[]) => {
|
|
41
33
|
t: "effect.end";
|
|
@@ -55,14 +47,5 @@ export type LiveView = {
|
|
|
55
47
|
pin: Record<string, unknown>;
|
|
56
48
|
receipts: Array<Record<string, unknown>>;
|
|
57
49
|
};
|
|
58
|
-
/** The run's live view writer: `receipts` are the ones earlier processes recorded; `driver` is handed over once the
|
|
59
|
-
* workflow's driver is open. It rewrites `live.json` every 300 ms while something changed, and once more at `stop`. */
|
|
60
|
-
export declare function liveView(root: string, receipts: Array<Record<string, unknown>>): {
|
|
61
|
-
driver(next: {
|
|
62
|
-
pinJson(): string;
|
|
63
|
-
}): void;
|
|
64
|
-
receipt(receipt: Record<string, unknown>): void;
|
|
65
|
-
stop(): void;
|
|
66
|
-
};
|
|
67
50
|
/** The live view of the run at `root`; undefined when its process wrote none, or it does not parse. */
|
|
68
51
|
export declare function readLiveView(root: string): Promise<LiveView | undefined>;
|
package/dist/pause.js
CHANGED
|
@@ -1,82 +1,13 @@
|
|
|
1
|
-
// A workflow run's
|
|
1
|
+
// A workflow run's node log and live view, as the graph reads them.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// The gate sits before the durable admission of a call and before a call node's deadline is armed, so a node waiting at
|
|
6
|
-
// it was never booked and a kill while paused interrupts nothing. Being a file, a pause outlives the server and the run's
|
|
7
|
-
// process.
|
|
3
|
+
// Node log: one line per node start and end and per call's start and end with its input and output (the runner's
|
|
4
|
+
// KINDS.nodeEffect entries), so GET /v2/runs/{id}/graph shows timings and call I/O while the run goes.
|
|
8
5
|
//
|
|
9
|
-
//
|
|
10
|
-
// appended by the run's process as they happen, so GET /v2/runs/{id}/graph shows timings and call I/O while the run goes.
|
|
11
|
-
//
|
|
12
|
-
// Live view: `live.json`, the driver's frame and the run's decision receipts, rewritten whole by the run's process when
|
|
13
|
-
// they change. The run's process holds its store exclusively (pi-durable-disk's exclusive profile: no other connection
|
|
14
|
-
// reads it until the process exits), so this file is what GET /v2/runs/{id}/graph reads while the run goes.
|
|
15
|
-
import { existsSync, renameSync, writeFileSync } from "node:fs";
|
|
6
|
+
// Live view: `live.json`, the driver's frame and the run's decision receipts, as GET /v2/runs/{id}/graph reads it.
|
|
16
7
|
import { join } from "node:path";
|
|
17
|
-
|
|
18
|
-
export const RUN_PAUSED = "paused";
|
|
19
|
-
export const NODE_LOG = "nodes.jsonl";
|
|
20
|
-
export const LIVE_VIEW = "live.json";
|
|
21
|
-
const LIVE_MS = 300;
|
|
22
|
-
const POLL_MS = 250;
|
|
23
|
-
export const pausedIn = (root) => existsSync(join(root, RUN_PAUSED));
|
|
24
|
-
/** `fn`, waiting before each call while the run at `root` is paused. A cancel, or the call's own signal aborting, lets
|
|
25
|
-
* the call go to meet its abort. */
|
|
26
|
-
export function gated(root, fn) {
|
|
27
|
-
return async (params) => {
|
|
28
|
-
const signal = params?.signal instanceof AbortSignal ? params.signal : undefined;
|
|
29
|
-
while (pausedIn(root) && !existsSync(join(root, RUN_CANCELLED)) && !signal?.aborted)
|
|
30
|
-
await new Promise((resolve) => setTimeout(resolve, POLL_MS));
|
|
31
|
-
return fn(params);
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
/** The node log of the run at `root`, in order; a torn last line is left out. */
|
|
35
|
-
export async function readNodeLog(root) {
|
|
36
|
-
const { readFile } = await import("node:fs/promises");
|
|
37
|
-
const text = await readFile(join(root, NODE_LOG), "utf8").catch(() => "");
|
|
38
|
-
const out = [];
|
|
39
|
-
for (const line of text.split("\n")) {
|
|
40
|
-
if (!line)
|
|
41
|
-
continue;
|
|
42
|
-
try {
|
|
43
|
-
out.push(JSON.parse(line));
|
|
44
|
-
}
|
|
45
|
-
catch { }
|
|
46
|
-
}
|
|
47
|
-
return out;
|
|
48
|
-
}
|
|
8
|
+
const LIVE_VIEW = "live.json";
|
|
49
9
|
/** The llm calls the node log says answered, in order: a run's `llmRead` counts them, and its cost reads the rest. */
|
|
50
10
|
export const llmAnswers = (lines) => lines.filter((line) => line.t === "effect.end" && line.tool === "llm" && line.status === "done");
|
|
51
|
-
/** The run's live view writer: `receipts` are the ones earlier processes recorded; `driver` is handed over once the
|
|
52
|
-
* workflow's driver is open. It rewrites `live.json` every 300 ms while something changed, and once more at `stop`. */
|
|
53
|
-
export function liveView(root, receipts) {
|
|
54
|
-
let driver;
|
|
55
|
-
let last = "";
|
|
56
|
-
const file = join(root, LIVE_VIEW);
|
|
57
|
-
const write = () => {
|
|
58
|
-
if (!driver)
|
|
59
|
-
return;
|
|
60
|
-
try {
|
|
61
|
-
const text = `{"at":${JSON.stringify(new Date().toISOString())},"receipts":${JSON.stringify(receipts)},"pin":${driver.pinJson()}}`;
|
|
62
|
-
// The time is left out of the comparison: an unchanged view is not written again.
|
|
63
|
-
const same = text.slice(text.indexOf(',"receipts":'));
|
|
64
|
-
if (same === last)
|
|
65
|
-
return;
|
|
66
|
-
writeFileSync(`${file}.tmp`, text, { mode: 0o600 });
|
|
67
|
-
renameSync(`${file}.tmp`, file);
|
|
68
|
-
last = same;
|
|
69
|
-
}
|
|
70
|
-
catch { }
|
|
71
|
-
};
|
|
72
|
-
const timer = setInterval(write, LIVE_MS);
|
|
73
|
-
timer.unref();
|
|
74
|
-
return {
|
|
75
|
-
driver(next) { driver = next; write(); },
|
|
76
|
-
receipt(receipt) { receipts.push(receipt); },
|
|
77
|
-
stop() { clearInterval(timer); write(); },
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
11
|
/** The live view of the run at `root`; undefined when its process wrote none, or it does not parse. */
|
|
81
12
|
export async function readLiveView(root) {
|
|
82
13
|
const { readFile } = await import("node:fs/promises");
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** Why a remote box (Daytona's, Modal's) has no network, said in capabilities whenever the server's host list is set:
|
|
2
|
+
* its computer is made with no network (Daytona) or no network or an open one (Modal), never with a host list, so a
|
|
3
|
+
* list is narrowed to none (workspace/computer-deps.ts networkOf). */
|
|
4
|
+
export declare const remoteNoList: (id: "daytona" | "modal") => string;
|
|
5
|
+
/** Every box a place may name, in the order capabilities lists them. */
|
|
6
|
+
export declare const BOX_IDS: readonly ["bwrap", "docker", "modal", "daytona"];
|
|
7
|
+
export type BoxId = (typeof BOX_IDS)[number];
|
|
8
|
+
/** A box as capabilities show it: whether this server has it, and why when not (or how it was checked); `state`, which
|
|
9
|
+
* capabilities derive from it (place.ts stated). `network`: what an available box reaches (BOX_NETWORKS), with
|
|
10
|
+
* `network_reason` when it is available and has none for a cause of its own (a daemon elsewhere; a remote box, whose
|
|
11
|
+
* computer is never made with a host list). `host_addresses`: for Docker from a container (compose.yaml), the Docker host's own addresses
|
|
12
|
+
* its computers' egress proxy refuses as the host's (docker-host-addresses.ts: the read through the socket and
|
|
13
|
+
* AGENTRUN_DOCKER_HOST_ADDRESSES). */
|
|
14
|
+
export type BoxOffer = {
|
|
15
|
+
id: BoxId;
|
|
16
|
+
available: boolean;
|
|
17
|
+
state?: BoxState;
|
|
18
|
+
reason?: string;
|
|
19
|
+
network?: BoxNetwork;
|
|
20
|
+
network_reason?: string;
|
|
21
|
+
host_addresses?: string[];
|
|
22
|
+
};
|
|
23
|
+
/** What an available box reaches: the hosts of `places.allow` (`allowlist`), or nothing (`none`). */
|
|
24
|
+
export declare const BOX_NETWORKS: readonly ["allowlist", "none"];
|
|
25
|
+
export type BoxNetwork = (typeof BOX_NETWORKS)[number];
|
|
26
|
+
/** A box's state in capabilities: ready (available) or unavailable. */
|
|
27
|
+
export declare const BOX_STATES: readonly ["ready", "unavailable"];
|
|
28
|
+
export type BoxState = (typeof BOX_STATES)[number];
|
|
29
|
+
/** The remote boxes' keys: secrets the server holds and its computer providers read, which no run is handed
|
|
30
|
+
* (run-secrets.ts SERVER_ONLY). */
|
|
31
|
+
export declare const BOX_KEYS: readonly string[];
|
|
32
|
+
/** The setting that lists the boxes to set up: a comma list of box ids, empty or `none` for no box. */
|
|
33
|
+
export declare const BOXES_ENV = "AGENTRUN_BOXES";
|
|
34
|
+
/** The boxes a server sets up when AGENTRUN_BOXES is not set at all: Docker, probed as if listed. */
|
|
35
|
+
export declare const DEFAULT_BOXES: readonly BoxId[];
|
|
36
|
+
/** Whether `env` leaves the boxes to this server's default (DEFAULT_BOXES): AGENTRUN_BOXES is not set at all. */
|
|
37
|
+
export declare const boxesByDefault: (env: NodeJS.ProcessEnv) => boolean;
|
|
38
|
+
/** The boxes `env` lists in AGENTRUN_BOXES, DEFAULT_BOXES when it is not set, none when it is empty or `none`; a name
|
|
39
|
+
* that is no box throws, naming it, and so does `none` with another. */
|
|
40
|
+
export declare function enabledBoxes(env: NodeJS.ProcessEnv): Set<BoxId>;
|
|
41
|
+
/** The start's log line: the boxes available, the rest, and why each box AGENTRUN_BOXES lists (`listed`) is not available. */
|
|
42
|
+
export declare function boxesLog(offers: readonly BoxOffer[], listed: ReadonlySet<BoxId>): Record<string, string>;
|
|
43
|
+
/** Why docker is unavailable when its daemon refuses this server's process its socket (EACCES on /var/run/docker.sock)
|
|
44
|
+
* and the group file lists this user in the docker group: this process started before the user joined it (a systemd
|
|
45
|
+
* user manager that has run since, kept by linger), so a restart of that manager, or a new login, gives it the group. */
|
|
46
|
+
export declare const DOCKER_NOT_IN_GROUP = "This server's process isn't in the docker group: restart your user manager with `sudo systemctl restart user@$(id -u)`, or log in again if linger is off";
|
|
47
|
+
/** The same, when the group file does not list this user in the docker group (or cannot say): joining comes first. */
|
|
48
|
+
export declare const DOCKER_JOIN_GROUP = "This server's process isn't in the docker group: add this user to it with `sudo usermod -aG docker $USER`, then restart your user manager with `sudo systemctl restart user@$(id -u)`, or log in again if linger is off";
|
|
49
|
+
/** How long Docker's probe may take. */
|
|
50
|
+
export declare const PROBE_TIMEOUT_MS = 5000;
|
|
51
|
+
/** What `docker version` says of this machine's Docker daemon: it answers (`up`), or why not. `absent`: no daemon
|
|
52
|
+
* answers this process (no docker command, a call that fails, or one that names no daemon); not absent: one is there,
|
|
53
|
+
* and its socket refuses this process (the group it lacks). */
|
|
54
|
+
export type DockerDaemon = {
|
|
55
|
+
readonly up: true;
|
|
56
|
+
} | {
|
|
57
|
+
readonly up: false;
|
|
58
|
+
readonly absent: boolean;
|
|
59
|
+
readonly reason: string;
|
|
60
|
+
};
|
|
61
|
+
/** Asks this machine's Docker daemon its version (`docker version`), as the Docker computer's check (docker-daemon.ts)
|
|
62
|
+
* does: the CLI is on PATH and its daemon answers this user. `signal` bounds it. */
|
|
63
|
+
export declare function askDockerDaemon(env: NodeJS.ProcessEnv, signal: AbortSignal, groups?: {
|
|
64
|
+
file: string;
|
|
65
|
+
user: string;
|
|
66
|
+
ids: readonly number[];
|
|
67
|
+
}): Promise<DockerDaemon>;
|
|
68
|
+
/** What placeOffers takes beyond the environment. */
|
|
69
|
+
export type PlaceOffersOptions = {
|
|
70
|
+
/** A provider key's value as a run's claim reads it (key-meta.ts keyReader); default `env`'s alone. */
|
|
71
|
+
keyOf?: (name: string) => Promise<string | undefined>;
|
|
72
|
+
/** Docker's probe's bound (PROBE_TIMEOUT_MS). */
|
|
73
|
+
timeoutMs?: number;
|
|
74
|
+
/** The group file and this process's user and groups, which say whether a refused docker socket is a membership
|
|
75
|
+
* granted since this process started; default the system's. */
|
|
76
|
+
groups?: {
|
|
77
|
+
file: string;
|
|
78
|
+
user: string;
|
|
79
|
+
ids: readonly number[];
|
|
80
|
+
};
|
|
81
|
+
/** Under --faux only: Docker answers, whatever AGENTRUN_BOXES lists, and nothing asks it. */
|
|
82
|
+
fauxDocker?: boolean;
|
|
83
|
+
};
|
|
84
|
+
/** Every box, in BOX_IDS order, as this server has it at its start (`env`: its environment, its secrets readable): bwrap
|
|
85
|
+
* is in no release; a box AGENTRUN_BOXES does not list is not enabled; docker by its probe (or `fauxDocker`); daytona
|
|
86
|
+
* and modal by their keys. Rejects only for a name in AGENTRUN_BOXES that is no box. No reason holds a key or an answer's body. */
|
|
87
|
+
export declare function placeOffers(env: NodeJS.ProcessEnv, options?: PlaceOffersOptions): Promise<BoxOffer[]>;
|
|
88
|
+
/** What each available box reaches, from the server's host list (`allow`, box-settings.ts boxAllowOf): Docker's
|
|
89
|
+
* computers through their egress proxy (an allowlist), with the Docker host's own addresses it refuses when the server
|
|
90
|
+
* runs in a container (`hostAddresses`), or unavailable where `dockerRefused` says Docker can't run a computer here
|
|
91
|
+
* (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's none
|
|
92
|
+
* (remoteNoList). With `allow` none, none has a network. */
|
|
93
|
+
export declare function withNetworks(offers: readonly BoxOffer[], allow: readonly string[] | "none", docker?: {
|
|
94
|
+
refused?: string;
|
|
95
|
+
hostAddresses?: readonly string[];
|
|
96
|
+
faux?: boolean;
|
|
97
|
+
}): BoxOffer[];
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// The boxes a place may name, as capabilities show them (places.boxes), read from the computers runs execute on: a
|
|
2
|
+
// sandbox place on box X is a sandbox computer on provider X (computer-setting.ts computerOfPlace), which a run's claim
|
|
3
|
+
// starts (workspace/). Read once, at the server's start: each fix takes a restart.
|
|
4
|
+
//
|
|
5
|
+
// AGENTRUN_BOXES lists the boxes to set up. Not set at all, it is docker alone (DEFAULT_BOXES): a plain start probes
|
|
6
|
+
// Docker and offers it when Docker answers, so a new agent lands in its box (place.ts); every other box is the operator's
|
|
7
|
+
// to list. Set, it wins: a box it does not list is never probed and is unavailable, its reason naming the setting that
|
|
8
|
+
// lists it, an empty value or `none` sets up no box, and a name in it that is no box refuses the start. Every reason says
|
|
9
|
+
// what to do next. Docker is probed (`docker version`); Daytona and Modal are offered when the keys their computer
|
|
10
|
+
// provider requires are set (the server's environment, else saved in Settings → Computers), and are not asked anything
|
|
11
|
+
// at the start: a key the vendor refuses fails the run's computer start, in the vendor's words. bwrap is in no release.
|
|
12
|
+
import { execFile } from "node:child_process";
|
|
13
|
+
import { readFile } from "node:fs/promises";
|
|
14
|
+
import { userInfo } from "node:os";
|
|
15
|
+
import { PROVIDERS } from "@parcha/agentrun-computer";
|
|
16
|
+
import { withoutSecrets } from "./secrets.js";
|
|
17
|
+
/** Why a remote box (Daytona's, Modal's) has no network, said in capabilities whenever the server's host list is set:
|
|
18
|
+
* its computer is made with no network (Daytona) or no network or an open one (Modal), never with a host list, so a
|
|
19
|
+
* list is narrowed to none (workspace/computer-deps.ts networkOf). */
|
|
20
|
+
export const remoteNoList = (id) => `a ${id === "daytona" ? "Daytona" : "Modal"} computer is never made with a host list, so a ${id} box has no network`;
|
|
21
|
+
/** Every box a place may name, in the order capabilities lists them. */
|
|
22
|
+
export const BOX_IDS = ["bwrap", "docker", "modal", "daytona"];
|
|
23
|
+
/** What an available box reaches: the hosts of `places.allow` (`allowlist`), or nothing (`none`). */
|
|
24
|
+
export const BOX_NETWORKS = ["allowlist", "none"];
|
|
25
|
+
/** A box's state in capabilities: ready (available) or unavailable. */
|
|
26
|
+
export const BOX_STATES = ["ready", "unavailable"];
|
|
27
|
+
/** The remote boxes' keys: secrets the server holds and its computer providers read, which no run is handed
|
|
28
|
+
* (run-secrets.ts SERVER_ONLY). */
|
|
29
|
+
export const BOX_KEYS = ["DAYTONA_API_KEY", "MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"];
|
|
30
|
+
/** The setting that lists the boxes to set up: a comma list of box ids, empty or `none` for no box. */
|
|
31
|
+
export const BOXES_ENV = "AGENTRUN_BOXES";
|
|
32
|
+
/** The boxes a server sets up when AGENTRUN_BOXES is not set at all: Docker, probed as if listed. */
|
|
33
|
+
export const DEFAULT_BOXES = ["docker"];
|
|
34
|
+
/** The AGENTRUN_BOXES that sets up no box, as an empty one does. */
|
|
35
|
+
const NO_BOXES = "none";
|
|
36
|
+
/** Whether `env` leaves the boxes to this server's default (DEFAULT_BOXES): AGENTRUN_BOXES is not set at all. */
|
|
37
|
+
export const boxesByDefault = (env) => env[BOXES_ENV] === undefined;
|
|
38
|
+
/** The boxes `env` lists in AGENTRUN_BOXES, DEFAULT_BOXES when it is not set, none when it is empty or `none`; a name
|
|
39
|
+
* that is no box throws, naming it, and so does `none` with another. */
|
|
40
|
+
export function enabledBoxes(env) {
|
|
41
|
+
if (boxesByDefault(env))
|
|
42
|
+
return new Set(DEFAULT_BOXES);
|
|
43
|
+
const names = env[BOXES_ENV].split(",").map((name) => name.trim()).filter(Boolean);
|
|
44
|
+
if (names.includes(NO_BOXES)) {
|
|
45
|
+
if (names.length > 1)
|
|
46
|
+
throw new Error(`${BOXES_ENV}=${NO_BOXES} sets up no box, so it names no other: list the boxes to set up, or ${NO_BOXES} alone`);
|
|
47
|
+
return new Set();
|
|
48
|
+
}
|
|
49
|
+
const unknown = names.filter((name) => !BOX_IDS.includes(name));
|
|
50
|
+
if (unknown.length)
|
|
51
|
+
throw new Error(`${BOXES_ENV} names ${unknown.join(", ")}, which ${unknown.length === 1 ? "is not a box" : "are not boxes"}: list any of ${BOX_IDS.join(", ")}`);
|
|
52
|
+
return new Set(names);
|
|
53
|
+
}
|
|
54
|
+
/** Why box `id` is unavailable when AGENTRUN_BOXES does not list it: the setting that does, keeping what it lists now. */
|
|
55
|
+
const notEnabled = (id, enabled) => `not enabled on this server: start AgentRun with ${BOXES_ENV}=${BOX_IDS.filter((box) => box === id || enabled.has(box)).join(",")}`;
|
|
56
|
+
/** The start's log line: the boxes available, the rest, and why each box AGENTRUN_BOXES lists (`listed`) is not available. */
|
|
57
|
+
export function boxesLog(offers, listed) {
|
|
58
|
+
const ids = (yes) => offers.filter((offer) => offer.available === yes).map((offer) => offer.id).join(",") || "none";
|
|
59
|
+
const why = offers.filter((offer) => !offer.available && listed.has(offer.id));
|
|
60
|
+
return { available: ids(true), unavailable: ids(false), ...Object.fromEntries(why.map((offer) => [offer.id, offer.reason ?? ""])) };
|
|
61
|
+
}
|
|
62
|
+
/** Why docker is unavailable when its daemon refuses this server's process its socket (EACCES on /var/run/docker.sock)
|
|
63
|
+
* and the group file lists this user in the docker group: this process started before the user joined it (a systemd
|
|
64
|
+
* user manager that has run since, kept by linger), so a restart of that manager, or a new login, gives it the group. */
|
|
65
|
+
export const DOCKER_NOT_IN_GROUP = "This server's process isn't in the docker group: restart your user manager with `sudo systemctl restart user@$(id -u)`, or log in again if linger is off";
|
|
66
|
+
/** The same, when the group file does not list this user in the docker group (or cannot say): joining comes first. */
|
|
67
|
+
export const DOCKER_JOIN_GROUP = "This server's process isn't in the docker group: add this user to it with `sudo usermod -aG docker $USER`, then restart your user manager with `sudo systemctl restart user@$(id -u)`, or log in again if linger is off";
|
|
68
|
+
/** Whether the group file lists `user` in the docker group while this process's groups (`ids`) lack that group: a
|
|
69
|
+
* membership granted after this process started. False when it cannot say (no file, no docker group, users listed
|
|
70
|
+
* elsewhere, as a directory service lists them). */
|
|
71
|
+
async function joinedSince(groups) {
|
|
72
|
+
const line = (await readFile(groups.file, "utf8").catch(() => "")).split("\n").find((entry) => entry.startsWith("docker:"));
|
|
73
|
+
if (!line)
|
|
74
|
+
return false;
|
|
75
|
+
const [, , gid, members = ""] = line.split(":");
|
|
76
|
+
return groups.user !== "" && members.split(",").map((name) => name.trim()).includes(groups.user) && !groups.ids.includes(Number(gid));
|
|
77
|
+
}
|
|
78
|
+
/** This process's user and groups, read from the system's group file: the probe's default for `groups`. A user with no
|
|
79
|
+
* name (a numeric uid with no passwd entry, as in a container) is none: membership cannot be checked, so joining is said. */
|
|
80
|
+
const ownGroups = () => {
|
|
81
|
+
let user = "";
|
|
82
|
+
try {
|
|
83
|
+
user = userInfo().username;
|
|
84
|
+
}
|
|
85
|
+
catch { }
|
|
86
|
+
return { file: "/etc/group", user, ids: process.getgroups?.() ?? [] };
|
|
87
|
+
};
|
|
88
|
+
/** docker's own words for a socket that refused this process (the CLI's, or the connect's EACCES). Matched, never shown. */
|
|
89
|
+
const SOCKET_DENIED = /permission denied while trying to connect to the docker daemon socket|docker\.sock: connect: permission denied/i;
|
|
90
|
+
/** How long Docker's probe may take. */
|
|
91
|
+
export const PROBE_TIMEOUT_MS = 5_000;
|
|
92
|
+
/** What kind of error, never its message: a message can hold an answer's body, a path or a key. */
|
|
93
|
+
function errorName(error) {
|
|
94
|
+
const code = error?.code;
|
|
95
|
+
if (typeof code === "string" && /^[A-Z][A-Z0-9_]*$/.test(code))
|
|
96
|
+
return code;
|
|
97
|
+
return error instanceof Error ? error.name : "not an error";
|
|
98
|
+
}
|
|
99
|
+
/** Asks this machine's Docker daemon its version (`docker version`), as the Docker computer's check (docker-daemon.ts)
|
|
100
|
+
* does: the CLI is on PATH and its daemon answers this user. `signal` bounds it. */
|
|
101
|
+
export async function askDockerDaemon(env, signal, groups = ownGroups()) {
|
|
102
|
+
// Its environment is the server's through the cut a run's takes (withoutSecrets): no box key, no other secret, no
|
|
103
|
+
// name shaped like a key.
|
|
104
|
+
const dockerEnv = withoutSecrets(env);
|
|
105
|
+
const answer = await new Promise((resolve) => execFile("docker", ["version", "--format", "{{.Server.Version}}"], { env: dockerEnv, signal, maxBuffer: 64 * 1024 }, (error, stdout, stderr) => {
|
|
106
|
+
const code = error?.code;
|
|
107
|
+
resolve({ ...(error ? { failed: typeof code === "number" ? `exit ${code}` : errorName(error), ...(SOCKET_DENIED.test(String(stderr)) ? { denied: true } : {}) } : {}), out: String(stdout) });
|
|
108
|
+
}));
|
|
109
|
+
const absent = (reason) => ({ up: false, absent: true, reason });
|
|
110
|
+
// The box's probe runs once, at the start: each fix takes a restart. Docker is on by default, so its reason is often a
|
|
111
|
+
// first-time user's first read: what is wrong in plain words, what the probe saw, then what to do.
|
|
112
|
+
if (answer.failed === "ENOENT")
|
|
113
|
+
return absent("Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart AgentRun");
|
|
114
|
+
// Its socket refused this process: the group it lacks, and how to get it without a reboot (the words, never docker's):
|
|
115
|
+
// a restart alone where the group file already lists this user, else joining it first.
|
|
116
|
+
if (answer.denied)
|
|
117
|
+
return { up: false, absent: false, reason: (await joinedSince(groups)) ? DOCKER_NOT_IN_GROUP : DOCKER_JOIN_GROUP };
|
|
118
|
+
if (answer.failed)
|
|
119
|
+
return absent(`Docker isn't running on this machine, or this user may not use it (docker version failed: ${answer.failed}): start Docker, or add this user to the docker group, then restart AgentRun`);
|
|
120
|
+
if (!answer.out.trim())
|
|
121
|
+
return absent("Docker isn't running on this machine (docker version named no daemon): start Docker, then restart AgentRun");
|
|
122
|
+
return { up: true };
|
|
123
|
+
}
|
|
124
|
+
/** Docker's offer: `docker version` names the daemon's version, so the CLI is on PATH and its daemon answers this user.
|
|
125
|
+
* Bounded by `timeoutMs`; never rejects. */
|
|
126
|
+
async function probeDocker(env, timeoutMs, groups) {
|
|
127
|
+
const no = (reason) => ({ id: "docker", available: false, reason });
|
|
128
|
+
// Its environment is the server's through the cut a run's takes (withoutSecrets): no box key, no other secret, no
|
|
129
|
+
// name shaped like a key.
|
|
130
|
+
const dockerEnv = withoutSecrets(env);
|
|
131
|
+
const answer = await new Promise((resolve) => execFile("docker", ["version", "--format", "{{.Server.Version}}"], { env: dockerEnv, timeout: timeoutMs, killSignal: "SIGKILL", maxBuffer: 64 * 1024 }, (error, stdout, stderr) => {
|
|
132
|
+
const failed = error;
|
|
133
|
+
const code = failed?.code;
|
|
134
|
+
resolve({ ...(failed ? { failed: typeof code === "number" ? `exit ${code}` : errorName(failed), ...(failed.killed ? { late: true } : {}), ...(SOCKET_DENIED.test(String(stderr)) ? { denied: true } : {}) } : {}), out: String(stdout) });
|
|
135
|
+
}));
|
|
136
|
+
// Docker is on by default, so its reason is often a first-time user's first read: what is wrong in plain words, what
|
|
137
|
+
// the probe saw, then what to do.
|
|
138
|
+
if (answer.late)
|
|
139
|
+
return no(`Docker isn't answering on this machine (docker version took over ${timeoutMs} ms): start Docker, then restart AgentRun`);
|
|
140
|
+
if (answer.failed === "ENOENT")
|
|
141
|
+
return no("Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart AgentRun");
|
|
142
|
+
// Its socket refused this process: the group it lacks, and how to get it without a reboot (the words, never docker's):
|
|
143
|
+
// a restart alone where the group file already lists this user, else joining it first.
|
|
144
|
+
if (answer.denied)
|
|
145
|
+
return no((await joinedSince(groups)) ? DOCKER_NOT_IN_GROUP : DOCKER_JOIN_GROUP);
|
|
146
|
+
if (answer.failed)
|
|
147
|
+
return no(`Docker isn't running on this machine, or this user may not use it (docker version failed: ${answer.failed}): start Docker, or add this user to the docker group, then restart AgentRun`);
|
|
148
|
+
if (!answer.out.trim())
|
|
149
|
+
return no("Docker isn't running on this machine (docker version named no daemon): start Docker, then restart AgentRun");
|
|
150
|
+
return { id: "docker", available: true };
|
|
151
|
+
}
|
|
152
|
+
/** A remote box's offer: available when every key its computer provider requires is set, read as a run's claim reads
|
|
153
|
+
* it (`keyOf`: the server's environment, else the key saved in Settings → Computers); nothing is asked of the vendor. */
|
|
154
|
+
async function remoteOffer(id, keyOf) {
|
|
155
|
+
const required = (PROVIDERS.find((entry) => entry.id === id)?.keys ?? []).filter((key) => key.required).map((key) => key.name);
|
|
156
|
+
const missing = [];
|
|
157
|
+
for (const name of required)
|
|
158
|
+
if ((await keyOf(name)) === undefined)
|
|
159
|
+
missing.push(name);
|
|
160
|
+
if (missing.length)
|
|
161
|
+
return { id, available: false, reason: `needs ${missing.join(" and ")}` };
|
|
162
|
+
return { id, available: true, reason: "configured; not probed at start" };
|
|
163
|
+
}
|
|
164
|
+
/** Every box, in BOX_IDS order, as this server has it at its start (`env`: its environment, its secrets readable): bwrap
|
|
165
|
+
* is in no release; a box AGENTRUN_BOXES does not list is not enabled; docker by its probe (or `fauxDocker`); daytona
|
|
166
|
+
* and modal by their keys. Rejects only for a name in AGENTRUN_BOXES that is no box. No reason holds a key or an answer's body. */
|
|
167
|
+
export async function placeOffers(env, options = {}) {
|
|
168
|
+
const enabled = enabledBoxes(env);
|
|
169
|
+
const keyOf = options.keyOf ?? (async (name) => env[name] || undefined);
|
|
170
|
+
return Promise.all(BOX_IDS.map(async (id) => {
|
|
171
|
+
if (id === "bwrap")
|
|
172
|
+
return { id, available: false, reason: NOT_YET };
|
|
173
|
+
// The tests' faux docker stands in whatever AGENTRUN_BOXES lists, as the old faux box did.
|
|
174
|
+
if (id === "docker" && options.fauxDocker)
|
|
175
|
+
return { id, available: true, reason: "a faux docker (tests)" };
|
|
176
|
+
if (!enabled.has(id))
|
|
177
|
+
return { id, available: false, reason: notEnabled(id, enabled) };
|
|
178
|
+
if (id === "docker")
|
|
179
|
+
return probeDocker(env, options.timeoutMs ?? PROBE_TIMEOUT_MS, options.groups ?? ownGroups());
|
|
180
|
+
return remoteOffer(id, keyOf);
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
const NOT_YET = "the bwrap box is not in this release yet: use the docker box";
|
|
184
|
+
/** What each available box reaches, from the server's host list (`allow`, box-settings.ts boxAllowOf): Docker's
|
|
185
|
+
* computers through their egress proxy (an allowlist), with the Docker host's own addresses it refuses when the server
|
|
186
|
+
* runs in a container (`hostAddresses`), or unavailable where `dockerRefused` says Docker can't run a computer here
|
|
187
|
+
* (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's none
|
|
188
|
+
* (remoteNoList). With `allow` none, none has a network. */
|
|
189
|
+
export function withNetworks(offers, allow, docker = {}) {
|
|
190
|
+
return offers.map((offer) => {
|
|
191
|
+
if (!offer.available)
|
|
192
|
+
return offer;
|
|
193
|
+
if (offer.id === "docker") {
|
|
194
|
+
if (docker.refused !== undefined)
|
|
195
|
+
return { id: offer.id, available: false, state: "unavailable", reason: docker.refused };
|
|
196
|
+
if (docker.faux)
|
|
197
|
+
return { ...offer, network: "none", network_reason: "a faux docker (tests)" };
|
|
198
|
+
if (allow === "none")
|
|
199
|
+
return { ...offer, network: "none", network_reason: "AGENTRUN_BOX_ALLOW is none" };
|
|
200
|
+
return { ...offer, network: "allowlist", ...(docker.hostAddresses?.length ? { host_addresses: [...docker.hostAddresses] } : {}) };
|
|
201
|
+
}
|
|
202
|
+
if (allow === "none" || (offer.id !== "daytona" && offer.id !== "modal"))
|
|
203
|
+
return { ...offer, network: "none" };
|
|
204
|
+
return { ...offer, network: "none", network_reason: remoteNoList(offer.id) };
|
|
205
|
+
});
|
|
206
|
+
}
|
package/dist/place.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BoxId, type BoxOffer } from "./
|
|
1
|
+
import { type BoxId, type BoxOffer } from "./place-offers.js";
|
|
2
2
|
import { type InputIssue } from "./errors.js";
|
|
3
3
|
export declare const PLACE_MODES: readonly ["runner", "sandbox"];
|
|
4
4
|
export type PlaceMode = (typeof PLACE_MODES)[number];
|
|
@@ -8,18 +8,18 @@ export type Place = {
|
|
|
8
8
|
mode: "sandbox";
|
|
9
9
|
box: BoxId;
|
|
10
10
|
};
|
|
11
|
-
/** The boxes runs execute in
|
|
11
|
+
/** The boxes runs execute in: the sandbox computers of Docker, Daytona and Modal. */
|
|
12
12
|
export declare const RUN_BOXES: readonly BoxId[];
|
|
13
|
-
/** The boxes this server gives runs, from what
|
|
14
|
-
*
|
|
13
|
+
/** The boxes this server gives runs, from what it found at its start (place-offers.ts): a box runs execute in that it
|
|
14
|
+
* has, and no other. */
|
|
15
15
|
export declare function boxAvailability(registry: readonly BoxOffer[]): BoxOffer[];
|
|
16
|
-
/** The place a new agentic definition that names none is saved with: the Docker box where this server has it,
|
|
17
|
-
* preparing (its first run waits for the image); else none, so the agent runs on the runner as it did before, with
|
|
16
|
+
/** The place a new agentic definition that names none is saved with: the Docker box where this server has it; else none, so the agent runs on the runner as it did before, with
|
|
18
17
|
* `reason` saying why, in docker's own words. A workflow is never given one. */
|
|
19
18
|
export declare function newAgentPlace(registry: readonly BoxOffer[]): {
|
|
20
19
|
place: Place;
|
|
21
20
|
} | {
|
|
22
21
|
reason: string;
|
|
22
|
+
why: string;
|
|
23
23
|
};
|
|
24
24
|
/** The place a revision that names none resolves to, at its create and at each run alike: this server's default place
|
|
25
25
|
* (newAgentPlace) for an agentic revision; the runner for a workflow, which is never given a box, and for one that names
|
|
@@ -33,14 +33,13 @@ export declare const NEW_AGENT_TOOLS: readonly string[];
|
|
|
33
33
|
/** Why a sandbox-only tool (bash) cannot run on this server: no box runs execute in is available, each with its reason.
|
|
34
34
|
* Undefined when one is. */
|
|
35
35
|
export declare function noBoxReason(registry: readonly BoxOffer[]): string | undefined;
|
|
36
|
-
/** The start banner's words on the boxes: which are ready for a sandbox agent's tools,
|
|
37
|
-
*
|
|
38
|
-
* AGENTRUN_BOXES lists (`listed`), or, when none is ready or preparing, each box runs execute in, with what to do.
|
|
36
|
+
/** The start banner's words on the boxes: which are ready for a sandbox agent's tools, then why each box is not that
|
|
37
|
+
* AGENTRUN_BOXES lists (`listed`), or, when none is ready, each box runs execute in, with what to do.
|
|
39
38
|
* `byDefault`, with AGENTRUN_BOXES not set at all: short, docker alone, said to be on by default, or why it is not. */
|
|
40
39
|
export declare function boxesLine(registry: readonly BoxOffer[], listed: ReadonlySet<BoxId>, allow?: readonly string[] | "none", byDefault?: boolean): string;
|
|
41
40
|
/** `places` in capabilities: the modes a revision may name, the place a new agent is saved with and a revision that
|
|
42
41
|
* names none runs in (`default_place`, with `default_reason` when it is the runner), each box, and the hosts a box whose
|
|
43
|
-
* `network` is `allowlist` reaches (`allow`,
|
|
42
|
+
* `network` is `allowlist` reaches (`allow`, box-settings.ts boxAllowOf; empty for `none`). */
|
|
44
43
|
export declare const placesOf: (registry: readonly BoxOffer[], allow?: readonly string[] | "none") => {
|
|
45
44
|
boxes: BoxOffer[];
|
|
46
45
|
allow: string[];
|
|
@@ -57,9 +56,6 @@ export declare const placesOf: (registry: readonly BoxOffer[], allow?: readonly
|
|
|
57
56
|
export declare const resolvePlace: (revision: Place | undefined, fallback: Place) => Place;
|
|
58
57
|
/** Where a box has the run's work/ (bound, or seeded), and where its tools start: the same in every box. */
|
|
59
58
|
export declare const BOX_WORK = "/workspace";
|
|
60
|
-
/** The boxes that cannot bind a run's work/, being on another machine: its work/ is seeded at the box's making and
|
|
61
|
-
* pulled back (run-box.ts). */
|
|
62
|
-
export declare const REMOTE_BOXES: readonly BoxId[];
|
|
63
59
|
/** `place` as a definition writes it, to copy: `"place": {"mode": "sandbox", "box": "docker"}`. */
|
|
64
60
|
export declare const placeFix: (place: Place) => string;
|
|
65
61
|
/** What is wrong with `place` as a definition gives it, as issues at `field`. Each names its fix: the field to remove,
|