@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.37
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 +298 -0
- package/README.md +417 -219
- package/dist/adapters.d.ts +12 -2
- package/dist/adapters.js +27 -2
- package/dist/agent-rows.d.ts +2 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +9 -4
- 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 +79 -7
- package/dist/archil-settings.js +140 -14
- package/dist/attach-conformance-cli.d.ts +1 -0
- package/dist/attach-conformance-cli.js +18 -0
- package/dist/attach-conformance.d.ts +25 -0
- package/dist/attach-conformance.js +343 -0
- 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/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 +1 -1
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- 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 +12 -57
- package/dist/cap.js +20 -160
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +3 -33
- package/dist/cli.js +17 -26
- package/dist/composio-preset.d.ts +36 -0
- package/dist/composio-preset.js +179 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +48 -0
- package/dist/computer-calls.js +126 -0
- package/dist/computer-channel.d.ts +57 -0
- package/dist/computer-channel.js +115 -0
- package/dist/computer-commands.d.ts +1 -1
- package/dist/computer-held-routes.d.ts +35 -0
- package/dist/computer-held-routes.js +106 -0
- package/dist/computer-held.d.ts +48 -0
- package/dist/computer-held.js +87 -0
- package/dist/computer-keys.d.ts +21 -1
- package/dist/computer-keys.js +53 -11
- package/dist/computer-live.d.ts +160 -0
- package/dist/computer-live.js +643 -0
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +38 -1
- package/dist/computer-view.d.ts +24 -2
- package/dist/computer-view.js +51 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +297 -0
- package/dist/computers.d.ts +79 -12
- package/dist/computers.js +147 -28
- package/dist/console/assets/index-Cn6JX1uH.js +563 -0
- package/dist/console/assets/index-DRN62V5v.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.js +5 -5
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +56 -24
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/github.d.ts +22 -2
- package/dist/github.js +42 -8
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-view.d.ts +3 -1
- package/dist/graph-view.js +25 -1
- 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.d.ts +1 -0
- package/dist/harness.js +36 -2
- package/dist/host-tools.d.ts +9 -10
- package/dist/host-tools.js +7 -7
- package/dist/hosted-search.d.ts +5 -4
- package/dist/hosted-search.js +2 -7
- package/dist/import-sources.d.ts +10 -0
- package/dist/import-sources.js +44 -2
- package/dist/import.d.ts +3 -3
- package/dist/import.js +37 -6
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +11 -2
- package/dist/learn/check.js +124 -6
- package/dist/learn/commit.d.ts +43 -7
- package/dist/learn/commit.js +166 -22
- package/dist/learn/folder.d.ts +11 -0
- package/dist/learn/folder.js +37 -1
- package/dist/learn/general.d.ts +66 -0
- package/dist/learn/general.js +73 -0
- package/dist/learn/grade.d.ts +22 -1
- package/dist/learn/grade.js +107 -16
- package/dist/learn/index.d.ts +1 -1
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning.sh +12 -1
- package/dist/learn/notes.d.ts +3 -0
- package/dist/learn/notes.js +3 -0
- package/dist/learn/reflect.d.ts +14 -2
- package/dist/learn/reflect.js +54 -30
- package/dist/learn/skills.d.ts +37 -5
- package/dist/learn/skills.js +60 -7
- package/dist/learned-nodes.d.ts +6 -2
- package/dist/learned-workflow.d.ts +43 -9
- package/dist/learned-workflow.js +128 -37
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +32 -4
- package/dist/learning-routes.js +48 -12
- package/dist/learning-words.d.ts +9 -0
- package/dist/learning-words.js +12 -2
- package/dist/learning.d.ts +39 -19
- package/dist/learning.js +88 -46
- package/dist/live/stream.js +6 -3
- package/dist/live/translate.d.ts +4 -3
- package/dist/live/translate.js +8 -4
- package/dist/live-reach.d.ts +37 -0
- package/dist/live-reach.js +62 -0
- package/dist/mcp-gateway.d.ts +9 -0
- package/dist/mcp-gateway.js +60 -11
- package/dist/mcp-oauth.d.ts +57 -7
- package/dist/mcp-oauth.js +133 -18
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +27 -3
- package/dist/mcp-probe.js +106 -29
- package/dist/mcp-secret-writes.js +8 -0
- package/dist/mcp-servers-store.d.ts +38 -15
- package/dist/mcp-servers-store.js +120 -23
- package/dist/mcp-store.d.ts +10 -4
- package/dist/mcp-store.js +17 -6
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.d.ts +5 -5
- package/dist/model.js +29 -16
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +586 -64
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +1 -1
- package/dist/paid-calls.js +1 -1
- package/dist/place-offers.d.ts +96 -0
- package/dist/place-offers.js +202 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +21 -32
- package/dist/port-models.d.ts +2 -1
- package/dist/port-models.js +5 -3
- package/dist/print.d.ts +16 -9
- package/dist/print.js +15 -17
- package/dist/propose.d.ts +4 -0
- package/dist/propose.js +34 -11
- package/dist/provider.js +3 -2
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +1 -1
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-launch.d.ts +28 -3
- package/dist/run-launch.js +14 -4
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-repo.d.ts +20 -0
- package/dist/run-repo.js +63 -0
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +56 -44
- package/dist/run-view.d.ts +8 -5
- package/dist/run-view.js +18 -10
- package/dist/runnable.d.ts +2 -2
- package/dist/runnable.js +6 -2
- package/dist/runner/adapter-loop.d.ts +39 -8
- package/dist/runner/adapter-loop.js +770 -83
- package/dist/runner/adapter-run-spec.d.ts +36 -7
- package/dist/runner/adapter-run-spec.js +171 -37
- package/dist/runner/adapters/pi-computer.d.ts +7 -0
- package/dist/runner/adapters/pi-computer.js +43 -0
- package/dist/runner/adapters/pi.d.ts +20 -7
- package/dist/runner/adapters/pi.js +111 -26
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +26 -12
- package/dist/runner/claim-secrets.d.ts +4 -0
- package/dist/runner/claim-secrets.js +6 -1
- package/dist/runner/cli-run-spec.d.ts +27 -3
- package/dist/runner/cli-run-spec.js +198 -74
- package/dist/runner/commands.d.ts +8 -2
- package/dist/runner/commands.js +31 -6
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +61 -0
- package/dist/runner/conformance/harness.d.ts +0 -1
- package/dist/runner/conformance/harness.js +87 -18
- package/dist/runner/conformance/subject.d.ts +1 -1
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +22 -12
- package/dist/runner/end-of-run.js +38 -16
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +6 -4
- package/dist/runner/harness-loops.js +16 -2
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +35 -6
- package/dist/runner/journal-kinds.js +20 -1
- package/dist/runner/journal-reader.d.ts +5 -4
- package/dist/runner/journal-reader.js +12 -10
- package/dist/runner/learning-ask.d.ts +7 -1
- package/dist/runner/learning-ask.js +21 -6
- package/dist/runner/learning-dispatch.d.ts +22 -0
- package/dist/runner/learning-dispatch.js +77 -10
- package/dist/runner/learning-end.d.ts +37 -1
- package/dist/runner/learning-end.js +115 -14
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +15 -5
- package/dist/runner/learning-loop.d.ts +139 -7
- package/dist/runner/learning-loop.js +369 -32
- package/dist/runner/learning-seed.d.ts +9 -0
- package/dist/runner/learning-seed.js +14 -1
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +16 -1
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +10 -2
- package/dist/runner/loop.js +22 -1
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +38 -6
- package/dist/runner/mcp-claim.d.ts +11 -4
- package/dist/runner/mcp-claim.js +140 -23
- package/dist/runner/mcp-github.d.ts +4 -2
- package/dist/runner/mcp-github.js +1 -8
- package/dist/runner/mcp-run.d.ts +6 -4
- package/dist/runner/mcp-run.js +16 -3
- package/dist/runner/metrics.d.ts +15 -2
- package/dist/runner/metrics.js +21 -2
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +60 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +19 -0
- package/dist/runner/reflect-hook.js +20 -8
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +231 -27
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +1 -1
- package/dist/runner/spec-holds.d.ts +8 -3
- package/dist/runner/spec-holds.js +12 -10
- package/dist/runner/store-port.d.ts +7 -2
- package/dist/runner/store-secrets.js +21 -4
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +190 -0
- package/dist/runner/workflow-host.d.ts +24 -3
- package/dist/runner/workflow-host.js +24 -4
- package/dist/runner/workflow-loop.d.ts +6 -3
- package/dist/runner/workflow-loop.js +9 -8
- package/dist/runner/workflow-spec.d.ts +39 -15
- package/dist/runner/workflow-spec.js +143 -40
- package/dist/runs-over-store.d.ts +16 -6
- package/dist/runs-over-store.js +145 -29
- package/dist/seal-key.js +3 -3
- package/dist/sealed-settings-store.d.ts +5 -2
- package/dist/sealed-settings-store.js +10 -4
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-writes.d.ts +5 -4
- package/dist/secret-writes.js +5 -4
- package/dist/server-secrets-store.d.ts +4 -3
- package/dist/server-secrets-store.js +15 -9
- package/dist/server-secrets.js +3 -2
- package/dist/server.d.ts +75 -63
- package/dist/server.js +712 -316
- package/dist/settings-wake.d.ts +21 -0
- package/dist/settings-wake.js +59 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/agent-body.d.ts +9 -2
- package/dist/store/agent-body.js +16 -8
- package/dist/store/command-wake.d.ts +12 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/deadline.js +9 -5
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +4 -4
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +15 -6
- package/dist/store/postgres/connection.js +9 -4
- package/dist/store/postgres/dialect.js +4 -0
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
- package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
- package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
- package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
- package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +85 -13
- 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 -47
- package/dist/store/sqlite/run-patch.d.ts +25 -7
- package/dist/store/sqlite/run-patch.js +58 -14
- package/dist/store/sqlite/store.js +331 -59
- package/dist/store/store.d.ts +330 -21
- package/dist/store/store.js +34 -2
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +2 -4
- package/dist/store-reads/cap.js +16 -7
- package/dist/store-reads/decisions.d.ts +3 -3
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +5 -4
- package/dist/store-reads/journal.js +118 -27
- package/dist/store-reads/learning.d.ts +34 -4
- package/dist/store-reads/learning.js +137 -23
- package/dist/store-reads/runs.d.ts +7 -5
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +70 -29
- package/dist/template-eval.js +8 -5
- package/dist/template-github-permissions.d.ts +22 -8
- package/dist/template-github-permissions.js +35 -15
- package/dist/templates.d.ts +64 -0
- package/dist/templates.js +101 -16
- package/dist/timeline/timeline.d.ts +30 -1
- package/dist/timeline/timeline.js +29 -13
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +27 -7
- package/dist/tool-budget.js +21 -9
- package/dist/tool-gate.d.ts +23 -10
- package/dist/tool-gate.js +60 -44
- package/dist/tool-plane.d.ts +46 -28
- package/dist/tool-plane.js +73 -31
- package/dist/tools.d.ts +31 -38
- package/dist/tools.js +117 -74
- package/dist/trigger-adapter.d.ts +4 -0
- package/dist/trigger-secrets-shown.d.ts +2 -2
- package/dist/trigger-secrets-shown.js +1 -1
- package/dist/trigger-signatures.d.ts +26 -6
- package/dist/trigger-signatures.js +44 -8
- package/dist/trigger-targets.d.ts +2 -0
- package/dist/trigger-targets.js +1 -0
- package/dist/trigger-webhook.js +5 -2
- package/dist/triggers.d.ts +10 -6
- package/dist/triggers.js +37 -7
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/turns.js +16 -1
- package/dist/usage-lines.d.ts +1 -1
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +41 -4
- package/dist/web-fetch.d.ts +1 -1
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +147 -103
- package/dist/webhooks.js +564 -324
- 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 +113 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +89 -0
- package/dist/workflow/node.js +101 -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 +32 -0
- package/dist/workflow/pi-versions.js +65 -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 +77 -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 +412 -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-run.d.ts +2 -2
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +11 -0
- package/dist/workspace/archil-claim.js +18 -10
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.js +2 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +32 -17
- package/dist/workspace/computer-deps.js +37 -14
- package/dist/workspace/computer-for-claim.d.ts +58 -13
- package/dist/workspace/computer-for-claim.js +267 -26
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +36 -56
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +5 -1
- package/dist/workspace/computer-ledger.js +11 -0
- package/dist/workspace/computer-mcp.d.ts +25 -0
- package/dist/workspace/computer-mcp.js +41 -0
- package/dist/workspace/computer-ports.d.ts +4 -13
- package/dist/workspace/computer-ports.js +4 -107
- package/dist/workspace/computer-script.d.ts +37 -0
- package/dist/workspace/computer-script.js +138 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +7 -4
- package/dist/workspace/index.js +4 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
- package/dist/workspace/resolve-computer.d.ts +45 -11
- package/dist/workspace/resolve-computer.js +72 -14
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +35 -18
- package/dist/workspace/run-tools.js +24 -29
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace.js +1 -1
- package/package.json +19 -21
- package/templates/README.md +9 -6
- 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/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/market-monitor/agent.md +1 -1
- 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 -71
- package/dist/budget.js +0 -199
- package/dist/console/assets/index-B7NKTU8E.css +0 -1
- package/dist/console/assets/index-CXZMgJE7.js +0 -550
- 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/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- 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/page.d.ts
CHANGED
|
@@ -4,6 +4,22 @@ import type { Owner } from "./owner.js";
|
|
|
4
4
|
* once opens the address over https only, for a year. None over http or with no public address (a browser would pin
|
|
5
5
|
* the loopback address to https and lose the console). */
|
|
6
6
|
export declare function hstsHeaders(publicUrl: string | undefined): Record<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* The console's sessions on a server with no accounts. Each start makes a launch code at random and prints its link
|
|
9
|
+
* (`/?launch=<code>`, Serve's `consoleUrl`); a browser that opens it gets a session: an id made at random, kept here, in
|
|
10
|
+
* memory, as its cookie. Neither the code nor an id is derived from the API token, so the token, whoever holds it, never
|
|
11
|
+
* computes or fetches a session: its own link (`/?token=`) signs no browser in. A restart forgets them, and the new
|
|
12
|
+
* start prints its own link.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ConsoleSessions {
|
|
15
|
+
readonly code: string;
|
|
16
|
+
/** The sessions, by the hash of their id (a lookup that reads no id), oldest first. */
|
|
17
|
+
private readonly ids;
|
|
18
|
+
/** A new session's id when `code` is this start's, else undefined. */
|
|
19
|
+
open(code: string): string | undefined;
|
|
20
|
+
/** Whether `value` is a session this server made. */
|
|
21
|
+
holds(value: string): boolean;
|
|
22
|
+
}
|
|
7
23
|
export declare const overHttps: (req: IncomingMessage) => boolean;
|
|
8
24
|
export declare const ownOrigin: (req: IncomingMessage) => string;
|
|
9
25
|
export declare const isJson: (req: IncomingMessage) => boolean;
|
|
@@ -19,10 +35,12 @@ export declare const signedIn: (req: IncomingMessage, owner: Owner) => boolean;
|
|
|
19
35
|
export declare const sendHostRefused: (req: IncomingMessage, res: ServerResponse) => void;
|
|
20
36
|
/** `takesBytes`: whether a request of `method` to `path` (under /v2) goes to a route whose body is bytes (server.ts). */
|
|
21
37
|
/** `publicUrl`: the address people open (AGENTRUN_PUBLIC_URL); an https one adds HSTS to every page answer (hstsHeaders). */
|
|
38
|
+
/** `sessions`: the console's sessions on a server with no accounts (ConsoleSessions); with `owner`, none. */
|
|
22
39
|
type PageServer = {
|
|
23
40
|
token: string;
|
|
24
41
|
authFailed?: (route: string, reason: string) => void;
|
|
25
42
|
owner?: Owner;
|
|
43
|
+
sessions?: ConsoleSessions;
|
|
26
44
|
console?: string | undefined;
|
|
27
45
|
takesBytes?: (method: string | undefined, path: string) => boolean;
|
|
28
46
|
publicUrl?: string;
|
package/dist/page.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// The console at "/" (apps/console, which this package's build copies into dist/console): its index.html and Vite's
|
|
2
2
|
// hashed assets under /assets/, public, under one strict CSP. The console signs a person in itself. With accounts it
|
|
3
|
-
// takes the owner's session cookie (owner.ts); without,
|
|
4
|
-
// sets
|
|
3
|
+
// takes the owner's session cookie (owner.ts); without, a console session the link this start prints (`/?launch=<code>`)
|
|
4
|
+
// sets (ConsoleSessions): made at random, kept by the server, never computable from the API token, and the token's own
|
|
5
|
+
// link signs no browser in. Either stands in for the Bearer header on /v2, and for a write only from this origin with a JSON body, or
|
|
5
6
|
// with any body on a route that takes bytes (a PUT or POST marked `raw` in server.ts).
|
|
6
|
-
import { createHash,
|
|
7
|
+
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
7
8
|
import { readFile, realpath, stat } from "node:fs/promises";
|
|
8
9
|
import { extname, join, sep } from "node:path";
|
|
9
10
|
import { fileURLToPath } from "node:url";
|
|
@@ -36,8 +37,34 @@ const CONSOLE_SEGMENT = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;
|
|
|
36
37
|
const MOVED = new Set(["/console", "/console/", "/setup", "/sign-in"]);
|
|
37
38
|
const digest = (text) => createHash("sha256").update(text).digest();
|
|
38
39
|
const same = (given, expected) => timingSafeEqual(digest(given), digest(expected));
|
|
39
|
-
/** The
|
|
40
|
-
const
|
|
40
|
+
/** The most console sessions a server keeps at once; past it, the oldest is forgotten (its browser opens the link again). */
|
|
41
|
+
const CONSOLE_SESSIONS = 64;
|
|
42
|
+
/**
|
|
43
|
+
* The console's sessions on a server with no accounts. Each start makes a launch code at random and prints its link
|
|
44
|
+
* (`/?launch=<code>`, Serve's `consoleUrl`); a browser that opens it gets a session: an id made at random, kept here, in
|
|
45
|
+
* memory, as its cookie. Neither the code nor an id is derived from the API token, so the token, whoever holds it, never
|
|
46
|
+
* computes or fetches a session: its own link (`/?token=`) signs no browser in. A restart forgets them, and the new
|
|
47
|
+
* start prints its own link.
|
|
48
|
+
*/
|
|
49
|
+
export class ConsoleSessions {
|
|
50
|
+
code = randomBytes(24).toString("base64url");
|
|
51
|
+
/** The sessions, by the hash of their id (a lookup that reads no id), oldest first. */
|
|
52
|
+
ids = new Set();
|
|
53
|
+
/** A new session's id when `code` is this start's, else undefined. */
|
|
54
|
+
open(code) {
|
|
55
|
+
if (!same(code, this.code))
|
|
56
|
+
return undefined;
|
|
57
|
+
const id = randomBytes(32).toString("base64url");
|
|
58
|
+
this.ids.add(digest(id).toString("hex"));
|
|
59
|
+
if (this.ids.size > CONSOLE_SESSIONS)
|
|
60
|
+
this.ids.delete(this.ids.values().next().value);
|
|
61
|
+
return id;
|
|
62
|
+
}
|
|
63
|
+
/** Whether `value` is a session this server made. */
|
|
64
|
+
holds(value) {
|
|
65
|
+
return this.ids.has(digest(value).toString("hex"));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
41
68
|
/** One name per port: cookies are kept per host, not per port, and another server on this machine has another token. */
|
|
42
69
|
const cookieName = (req) => `agentrun-${req.socket.localPort}`;
|
|
43
70
|
const cookiesOf = (req, name) => String(req.headers.cookie ?? "").split(";").map((part) => part.trim()).filter((part) => part.startsWith(`${name}=`)).map((part) => part.slice(name.length + 1));
|
|
@@ -85,30 +112,31 @@ async function answer(req, res, raw, server) {
|
|
|
85
112
|
return redirect(res, `/${(req.url ?? "").slice(raw.length)}`);
|
|
86
113
|
if (raw !== "/")
|
|
87
114
|
return file(req, res, raw, dir, raw.slice(1));
|
|
88
|
-
// Without accounts, the printed link's
|
|
89
|
-
//
|
|
115
|
+
// Without accounts, the printed link's launch code gives this browser a console session (ConsoleSessions). The token
|
|
116
|
+
// is for scripts and the CLI: a token in the address signs nothing in, here or with an owner, and leaves it (the same
|
|
117
|
+
// address without it, no cookie). With an owner the console is the owner's session alone.
|
|
90
118
|
const url = new URL(req.url ?? "/", "http://serve");
|
|
91
|
-
const without = () => (url.searchParams.delete("token"), `/${url.searchParams.size ? `?${url.searchParams}` : ""}`);
|
|
92
|
-
|
|
93
|
-
if (
|
|
119
|
+
const without = () => (url.searchParams.delete("token"), url.searchParams.delete("launch"), `/${url.searchParams.size ? `?${url.searchParams}` : ""}`);
|
|
120
|
+
const given = url.searchParams.get("launch");
|
|
121
|
+
if (url.searchParams.has("token") || (server.owner && given !== null))
|
|
94
122
|
return redirect(res, without());
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
return redirect(res, without(), { "set-cookie": `${cookieName(req)}=${
|
|
99
|
-
}
|
|
123
|
+
// A code holds no "+", but a space in the link is one that was not encoded all the same.
|
|
124
|
+
const id = given === null ? undefined : server.sessions?.open(given) ?? server.sessions?.open(given.replaceAll(" ", "+"));
|
|
125
|
+
if (id !== undefined)
|
|
126
|
+
return redirect(res, without(), { "set-cookie": `${cookieName(req)}=${id}; HttpOnly; SameSite=Strict; Path=/${overHttps(req) ? "; Secure" : ""}` });
|
|
100
127
|
if (given !== null)
|
|
101
|
-
server.authFailed?.(raw, "
|
|
128
|
+
server.authFailed?.(raw, "wrong_launch_code");
|
|
102
129
|
return file(req, res, raw, dir, "index.html", given === null ? 200 : 401);
|
|
103
130
|
}
|
|
104
131
|
/** The requests the owner's password session sends from the page (a write only from this server's own origin, with a
|
|
105
|
-
* JSON body), never under
|
|
132
|
+
* JSON body), never under an accounts-off console session. */
|
|
106
133
|
const ownerSessions = new WeakSet();
|
|
107
134
|
/** Whether `req` came from the owner's page under their password session (answerPage). A token, whoever holds it, never
|
|
108
135
|
* did. */
|
|
109
136
|
export const byOwnerSession = (req) => ownerSessions.has(req);
|
|
110
|
-
/** The requests the console sends under
|
|
111
|
-
* own origin and a JSON body as every page write is: a fact
|
|
137
|
+
/** The requests the console sends under an accounts-off console session (ConsoleSessions: the launch link's, made at
|
|
138
|
+
* random, never from the token), held to this server's own origin and a JSON body as every page write is: a fact
|
|
139
|
+
* secret-writes.ts reads (mayWriteSecrets), never an owner. */
|
|
112
140
|
const consoleSessions = new WeakSet();
|
|
113
141
|
/** Whether `req` came from the accounts-off console's page session (answerPage). */
|
|
114
142
|
export const byConsoleSession = (req) => consoleSessions.has(req);
|
|
@@ -119,7 +147,7 @@ export const byConsoleSession = (req) => consoleSessions.has(req);
|
|
|
119
147
|
* content type.
|
|
120
148
|
*/
|
|
121
149
|
export function answerPage(req, res, raw, server) {
|
|
122
|
-
const held = server.owner ? signedIn(req, server.owner) : cookiesOf(req, cookieName(req)).some((value) =>
|
|
150
|
+
const held = server.owner ? signedIn(req, server.owner) : cookiesOf(req, cookieName(req)).some((value) => server.sessions?.holds(value) === true);
|
|
123
151
|
if (raw.startsWith("/v2/")) {
|
|
124
152
|
const safe = req.method === "GET" || req.method === "HEAD";
|
|
125
153
|
const bytes = (req.method === "PUT" || req.method === "POST") && server.takesBytes?.(req.method, raw.slice(3)) === true;
|
package/dist/paid-calls.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { Refusal } from "@parcha/agentrun-kernel";
|
|
3
3
|
import { type ToolExecutionApi, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
4
4
|
/** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
|
package/dist/paid-calls.js
CHANGED
|
@@ -175,7 +175,7 @@ export async function paidStep(paid, call, fee, run, chargeOf, pause) {
|
|
|
175
175
|
async function paidOn(paid, call, fee, send, chargeOf) {
|
|
176
176
|
const id = `${call}#${(paidSeq += 1)}`;
|
|
177
177
|
try {
|
|
178
|
-
await paid.admit({ id, name: fee.name,
|
|
178
|
+
await paid.admit({ id, name: fee.name, holdUsd: fee.usd, basis: fee.basis, call, chargedBy: fee.by });
|
|
179
179
|
}
|
|
180
180
|
catch (error) {
|
|
181
181
|
await pauseOn(error);
|
|
@@ -0,0 +1,96 @@
|
|
|
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 ["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): a box AGENTRUN_BOXES does not list is not enabled; docker by its probe (or `fauxDocker`); daytona
|
|
85
|
+
* 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. */
|
|
86
|
+
export declare function placeOffers(env: NodeJS.ProcessEnv, options?: PlaceOffersOptions): Promise<BoxOffer[]>;
|
|
87
|
+
/** What each available box reaches, from the server's host list (`allow`, box-settings.ts boxAllowOf): Docker's
|
|
88
|
+
* computers through their egress proxy (an allowlist), with the Docker host's own addresses it refuses when the server
|
|
89
|
+
* runs in a container (`hostAddresses`), or unavailable where `dockerRefused` says Docker can't run a computer here
|
|
90
|
+
* (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's none
|
|
91
|
+
* (remoteNoList). With `allow` none, none has a network. */
|
|
92
|
+
export declare function withNetworks(offers: readonly BoxOffer[], allow: readonly string[] | "none", docker?: {
|
|
93
|
+
refused?: string;
|
|
94
|
+
hostAddresses?: readonly string[];
|
|
95
|
+
faux?: boolean;
|
|
96
|
+
}): BoxOffer[];
|
|
@@ -0,0 +1,202 @@
|
|
|
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.
|
|
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 = ["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): a box AGENTRUN_BOXES does not list is not enabled; docker by its probe (or `fauxDocker`); daytona
|
|
165
|
+
* 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. */
|
|
166
|
+
export async function placeOffers(env, options = {}) {
|
|
167
|
+
const enabled = enabledBoxes(env);
|
|
168
|
+
const keyOf = options.keyOf ?? (async (name) => env[name] || undefined);
|
|
169
|
+
return Promise.all(BOX_IDS.map(async (id) => {
|
|
170
|
+
// The tests' faux docker stands in whatever AGENTRUN_BOXES lists, as the old faux box did.
|
|
171
|
+
if (id === "docker" && options.fauxDocker)
|
|
172
|
+
return { id, available: true, reason: "a faux docker (tests)" };
|
|
173
|
+
if (!enabled.has(id))
|
|
174
|
+
return { id, available: false, reason: notEnabled(id, enabled) };
|
|
175
|
+
if (id === "docker")
|
|
176
|
+
return probeDocker(env, options.timeoutMs ?? PROBE_TIMEOUT_MS, options.groups ?? ownGroups());
|
|
177
|
+
return remoteOffer(id, keyOf);
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
/** What each available box reaches, from the server's host list (`allow`, box-settings.ts boxAllowOf): Docker's
|
|
181
|
+
* computers through their egress proxy (an allowlist), with the Docker host's own addresses it refuses when the server
|
|
182
|
+
* runs in a container (`hostAddresses`), or unavailable where `dockerRefused` says Docker can't run a computer here
|
|
183
|
+
* (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's none
|
|
184
|
+
* (remoteNoList). With `allow` none, none has a network. */
|
|
185
|
+
export function withNetworks(offers, allow, docker = {}) {
|
|
186
|
+
return offers.map((offer) => {
|
|
187
|
+
if (!offer.available)
|
|
188
|
+
return offer;
|
|
189
|
+
if (offer.id === "docker") {
|
|
190
|
+
if (docker.refused !== undefined)
|
|
191
|
+
return { id: offer.id, available: false, state: "unavailable", reason: docker.refused };
|
|
192
|
+
if (docker.faux)
|
|
193
|
+
return { ...offer, network: "none", network_reason: "a faux docker (tests)" };
|
|
194
|
+
if (allow === "none")
|
|
195
|
+
return { ...offer, network: "none", network_reason: "AGENTRUN_BOX_ALLOW is none" };
|
|
196
|
+
return { ...offer, network: "allowlist", ...(docker.hostAddresses?.length ? { host_addresses: [...docker.hostAddresses] } : {}) };
|
|
197
|
+
}
|
|
198
|
+
if (allow === "none" || (offer.id !== "daytona" && offer.id !== "modal"))
|
|
199
|
+
return { ...offer, network: "none" };
|
|
200
|
+
return { ...offer, network: "none", network_reason: remoteNoList(offer.id) };
|
|
201
|
+
});
|
|
202
|
+
}
|
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,
|