@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
|
@@ -13,22 +13,22 @@
|
|
|
13
13
|
// Shared with the pi spec: the run's Workspace and its uploaded files, a sandbox run's computer, the kernel registry's
|
|
14
14
|
// hands on them (runTools), the gate from the store's tool settings, the system prompt (environment line, instructions
|
|
15
15
|
// with what the agent learned and its skills, effort guidance), the first message, the end's metrics and the release.
|
|
16
|
-
import { mkdir, rm, rmdir } from "node:fs/promises";
|
|
17
|
-
import { join } from "node:path";
|
|
16
|
+
import { mkdir, readdir, rm, rmdir } from "node:fs/promises";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
18
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
19
19
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
20
20
|
import { checkRaise, followUpOf, parkOf } from "@parcha/agentrun-kernel/kernel/cap";
|
|
21
|
-
import { noNewPrivsPrefix } from "
|
|
22
|
-
import {
|
|
23
|
-
import { installDirOf, installingWords, installSettled } from "../harness-install.js";
|
|
21
|
+
import { confineOf, noNewPrivsPrefix, standsIn, thinkingFor } from "../adapters.js";
|
|
22
|
+
import { claimSettled, installDirOf, installForClaim, installingWords } from "../harness-install.js";
|
|
24
23
|
import { HarnessUnavailable } from "../provider.js";
|
|
25
24
|
import { effortGuidance } from "../effort-guidance.js";
|
|
25
|
+
import { wireName } from "../catalog.js";
|
|
26
26
|
import { environmentLine } from "../environment.js";
|
|
27
27
|
import { harnessOf } from "../harness-table.js";
|
|
28
28
|
import { laidLearned, learningFolderOf, secretsShown } from "../learning.js";
|
|
29
29
|
import { laidOf, layLearningSeed } from "./learning-seed.js";
|
|
30
30
|
import { learningWorkspace } from "../learn/folder.js";
|
|
31
|
-
import { learningEndOfRun } from "./learning-end.js";
|
|
31
|
+
import { learningEndOfRun, spentBesideOf } from "./learning-end.js";
|
|
32
32
|
import { providerModels, runModels } from "../model.js";
|
|
33
33
|
import { firstMessage } from "../run-manifest.js";
|
|
34
34
|
import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
@@ -42,21 +42,26 @@ import { layOwnSkills } from "../workspace/revision-skills.js";
|
|
|
42
42
|
import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
43
43
|
import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
44
44
|
import { loadArchilSettings } from "../archil-settings.js";
|
|
45
|
-
import { imageWaitWords } from "../workspace/computer-deps.js";
|
|
45
|
+
import { computerReadyWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
46
46
|
import { hostLifecycle } from "./adapter-loop.js";
|
|
47
47
|
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, modelAskOf, PI_WIRES, webHostTools, webToolNames } from "./adapter-run-spec.js";
|
|
48
48
|
import { openTierProxies } from "./adapters/pi.js";
|
|
49
49
|
import { signInReads } from "../sign-ins-store.js";
|
|
50
|
-
import {
|
|
50
|
+
import { mcpServersOf } from "../tool-gate.js";
|
|
51
|
+
import { claimSecrets, hostDecisionKeys, learnedDecisionKeys, tierModelKeys, withModelKeys } from "./claim-secrets.js";
|
|
51
52
|
import { mcpForClaim } from "./mcp-run.js";
|
|
52
|
-
import { TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
53
|
+
import { DECISION_PROVIDER_KEYS, TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
54
|
+
import { decisionProvidersIn } from "../decisions.js";
|
|
53
55
|
import { resolveHarness } from "./adapters/index.js";
|
|
54
56
|
import { entriesOf } from "./loop.js";
|
|
55
|
-
import { bookedSpend, cliRunMetrics } from "./metrics.js";
|
|
57
|
+
import { bookedSpend, cliModelWorked, cliRunMetrics, runEndCost } from "./metrics.js";
|
|
56
58
|
import { journalEntries } from "./journal-reader.js";
|
|
57
59
|
import { specBuilt } from "./spec-holds.js";
|
|
58
60
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
61
|
+
import { heldSpecOf } from "./held-run.js";
|
|
62
|
+
import { loopComputerOf } from "./computer-channel.js";
|
|
59
63
|
import { githubAppAccess } from "./github-app.js";
|
|
64
|
+
import { prCheckoutForClaim } from "./pr-checkout.js";
|
|
60
65
|
import { holdStored, storeSecrets } from "./store-secrets.js";
|
|
61
66
|
import { bashPolicyOf } from "../bash-read-only.js";
|
|
62
67
|
/** What a CLI harness refuses of an agent's computer, in words: a browser, which only pi's browser tool drives. */
|
|
@@ -99,25 +104,83 @@ function capModelOf(id, wire, listed, unpriced) {
|
|
|
99
104
|
* (DATA_ENV). The run environment's secrets, and the keys added, are readable by name and never enumerable: the
|
|
100
105
|
* harness's model route finds the key its requests carry (model.ts, `env[row.field]`) while a program spawned with this
|
|
101
106
|
* environment carries none. A spread would drop every secret the launcher handed the runner, and the route would send no
|
|
102
|
-
* key. The data directory is a plain variable, which a spawn carries.
|
|
103
|
-
|
|
107
|
+
* key. The data directory is a plain variable, which a spawn carries. So is the run's resolved tool plane (`plane`,
|
|
108
|
+
* TOOL_PLANE_ENV, not a secret), as main hands its per-run process: the adapter reads web_search's there (adapters.ts
|
|
109
|
+
* nativeOptions: claude-agent's WebSearch, codex's live search, admitted by its proxy's policy and priced with it), so a
|
|
110
|
+
* run whose plane resolves it to native gets the harness's own search (#2458), this run's alone; whatever the runner's
|
|
111
|
+
* own environment says of a plane is never the run's. Whether each search runs is the tool's setting at that search
|
|
112
|
+
* (SessionIO.permission, the gate), never this plane, which is frozen when the run is made. */
|
|
113
|
+
export function cliRunEnv(env, data, claimed = {}, plane) {
|
|
104
114
|
const out = withModelKeys(env ?? {}, claimed);
|
|
105
115
|
Object.defineProperty(out, DATA_ENV, { value: data, enumerable: true, writable: true, configurable: true });
|
|
116
|
+
delete out[TOOL_PLANE_ENV];
|
|
117
|
+
if (plane && Object.keys(plane).length)
|
|
118
|
+
Object.defineProperty(out, TOOL_PLANE_ENV, { value: JSON.stringify(plane), enumerable: true, writable: true, configurable: true });
|
|
106
119
|
return out;
|
|
107
120
|
}
|
|
108
|
-
/**
|
|
109
|
-
*
|
|
110
|
-
|
|
111
|
-
|
|
121
|
+
/** `tools` in the order the agent grants them (`granted`, catalog names; a tool is listed by its catalog name's wire
|
|
122
|
+
* name), as main listed a CLI run's tools to its harness: each granted tool where its grant is, and a tool the grant
|
|
123
|
+
* does not name (one a granted tool or the run's computer brings beside it) right after the tool listed before it. Ties
|
|
124
|
+
* keep the order given. */
|
|
125
|
+
export function inGrantOrder(tools, granted) {
|
|
126
|
+
const at = new Map(granted.map((name, index) => [wireName(name), index]));
|
|
127
|
+
let last = -1;
|
|
128
|
+
const keyed = tools.map((tool, given) => {
|
|
129
|
+
const index = at.get(tool.name);
|
|
130
|
+
if (index !== undefined)
|
|
131
|
+
last = index;
|
|
132
|
+
return { tool, key: index ?? last + 0.5, given };
|
|
133
|
+
});
|
|
134
|
+
return keyed.sort((a, b) => a.key - b.key || a.given - b.given).map(({ tool }) => tool);
|
|
135
|
+
}
|
|
136
|
+
/** Every earlier claim's private folder of the run (`<harnesses>/<n>`, n below `epoch`) removed: what a claim whose runner
|
|
137
|
+
* died left (its release never ran), or a sweep of its own cut off partway. A claim at `epoch` or later (a live one, or a
|
|
138
|
+
* next claim's while this one lets go late) is never touched. Each removal is whole or is finished by the next sweep. */
|
|
139
|
+
export async function sweepEarlier(harnesses, epoch) {
|
|
140
|
+
let names;
|
|
141
|
+
try {
|
|
142
|
+
names = await readdir(harnesses);
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
if (error.code === "ENOENT")
|
|
146
|
+
return;
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
for (const name of names) {
|
|
150
|
+
if (/^\d+$/.test(name) && Number(name) < epoch)
|
|
151
|
+
await rm(join(harnesses, name), { recursive: true, force: true });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** A claim's end: every earlier claim's folder of the run (sweepEarlier) and the claim's own (`<harnesses>/<epoch>`)
|
|
155
|
+
* removed, then each of `parents` in order while it is empty: one another claim of the run has laid things in since (a
|
|
156
|
+
* follow-up's) stays, with what is in it. Run again over what a cut-off sweep left, it finishes it. */
|
|
157
|
+
export async function sweepScratch(harnesses, epoch, parents) {
|
|
158
|
+
// An earlier folder that cannot be swept never keeps this claim's own folder: its removal is attempted anyway, and the
|
|
159
|
+
// earlier failure is thrown after it (with this one's, when both fail).
|
|
160
|
+
const failures = [];
|
|
161
|
+
await sweepEarlier(harnesses, epoch).catch((error) => { failures.push(error); });
|
|
162
|
+
await rm(join(harnesses, String(epoch)), { recursive: true, force: true }).catch((error) => { failures.push(error); });
|
|
163
|
+
if (failures.length === 0)
|
|
164
|
+
await rmEmptyParents(parents);
|
|
165
|
+
else
|
|
166
|
+
await rmEmptyParents(parents).catch((error) => { failures.push(error); });
|
|
167
|
+
if (failures.length === 1)
|
|
168
|
+
throw failures[0];
|
|
169
|
+
if (failures.length > 1)
|
|
170
|
+
throw new AggregateError(failures, failures.map((error) => error?.message ?? String(error)).join("; "));
|
|
171
|
+
}
|
|
172
|
+
async function rmEmptyParents(parents) {
|
|
112
173
|
for (const parent of parents) {
|
|
113
174
|
try {
|
|
114
175
|
await rmdir(parent);
|
|
115
176
|
}
|
|
116
177
|
catch (error) {
|
|
117
178
|
const code = error.code;
|
|
118
|
-
if (code === "ENOTEMPTY" || code === "EEXIST"
|
|
179
|
+
if (code === "ENOTEMPTY" || code === "EEXIST")
|
|
119
180
|
return;
|
|
120
|
-
|
|
181
|
+
// Already gone (a sweep cut off after it, or never made): the folder above it may still be left empty.
|
|
182
|
+
if (code !== "ENOENT")
|
|
183
|
+
throw error;
|
|
121
184
|
}
|
|
122
185
|
}
|
|
123
186
|
}
|
|
@@ -143,6 +206,18 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
143
206
|
const runRow = await deps.store.runs.get(claim.runId);
|
|
144
207
|
if (!runRow)
|
|
145
208
|
throw new Error(`run ${claim.runId}: its row is gone from the store`);
|
|
209
|
+
// The claim's private folder is swept at the spec's release, the claim's end, then the scratch folder if nothing else is
|
|
210
|
+
// in it, then the agent's: the next claim, here or on another runner, lays its own, its harness's session coming back from
|
|
211
|
+
// the run's journal. Its own per claim (by the claim's epoch), so a run reopened while this claim still lets go (its
|
|
212
|
+
// release follows the run's end commit) never has the next claim's folder swept from under it. A claim whose runner died
|
|
213
|
+
// never ran its release: every claim sweeps the earlier claims' folders of its run at its start and again at its end, so
|
|
214
|
+
// a killed CLI's home and session state never outlive the run. Held here, before any step that can fail (the install, the
|
|
215
|
+
// MCP claim, the computer): a claim that fails in its setup still sweeps what the earlier claims left, as specBuilt lets
|
|
216
|
+
// go what was held when the build throws.
|
|
217
|
+
const scratch = scratchFolder(deps.data, runRow.agentId, claim.runId);
|
|
218
|
+
const harnesses = join(scratch, "harness");
|
|
219
|
+
const dir = join(harnesses, String(claim.epoch));
|
|
220
|
+
holds.hold({ scratch: { sweep: () => sweepScratch(harnesses, claim.epoch, [harnesses, scratch, dirname(scratch)]) } });
|
|
146
221
|
// Every secret the server keeps sealed (store-secrets.ts) held by the runner's one redactor (the loop's) and this spec's
|
|
147
222
|
// log cut, before any of the run's text is written: a run's text may quote one it was never handed.
|
|
148
223
|
for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
@@ -153,13 +228,6 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
153
228
|
const body = (revisionRow.body ?? {});
|
|
154
229
|
const revision = { kind: revisionRow.kind, body };
|
|
155
230
|
const granted = body.tools ?? [];
|
|
156
|
-
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin made at the first claim or read as written, its
|
|
157
|
-
// credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
|
|
158
|
-
// First, before the session opens: a refusal (a pin that cannot be made, a pinned meta tool) ends the run in its words.
|
|
159
|
-
const mcp = await mcpForClaim({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold: (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
160
|
-
redact.hold(values); } }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}) });
|
|
161
|
-
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
162
|
-
holds.hold({ passed: mcp });
|
|
163
231
|
// The harness: the launch's, else the revision's. Its table entry (facts, model choice, adapter, skill check), read from
|
|
164
232
|
// the run's environment table as main does (harnessOf: the built-in entries, a test's module merged over them under a
|
|
165
233
|
// test runner; anywhere else it is the built-ins), and the runner's record mode for it.
|
|
@@ -172,10 +240,53 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
172
240
|
// The level the harness thinks at: the run's effort, else above its highest (codex stops at xhigh) its highest. The
|
|
173
241
|
// run's metrics name this level, the one it ran at, never a level the harness has not.
|
|
174
242
|
const thinking = launch.effort ? thinkingFor(facts, launch.effort) : undefined;
|
|
243
|
+
// A harness that installs on first use (claude-agent, codex) and is not installed whole in this server's data: the claim
|
|
244
|
+
// waits for the install running now (the server starts one at an agent's save), or, with none running (none started, or
|
|
245
|
+
// one cut short or failed before this claim), installs it itself. One install at a time on this data, which every claim
|
|
246
|
+
// that needs it waits for (harness-install.ts installForClaim), bounded by the install's own limit. The wait is said on
|
|
247
|
+
// the run's timeline as it starts, its root made first (a CLI run's root is its record's, which the loop would make once
|
|
248
|
+
// the session opens), so the row shows while it waits. First, before the run's MCP claim: its OAuth tokens are read
|
|
249
|
+
// after a wait that may outlive them. A stop of the run ends its wait at once; an install that fails fails the run in the
|
|
250
|
+
// install's own words. A test's stand-in that runs in place of the CLI (adapters.ts standsIn) loads nothing installed:
|
|
251
|
+
// its claim waits for an install that runs, as any claim does, but starts none of its own.
|
|
252
|
+
if (entry.installs && entry.pins) {
|
|
253
|
+
const installs = entry.installs;
|
|
254
|
+
const pins = entry.pins;
|
|
255
|
+
const dir = installDirOf(deps.data, name);
|
|
256
|
+
const waitOn = run.stopped ?? run.signal;
|
|
257
|
+
let saying;
|
|
258
|
+
const say = () => (saying ??= (async () => {
|
|
259
|
+
await run.harness.root(context);
|
|
260
|
+
run.phase?.(installingWords(installs.label));
|
|
261
|
+
})().catch((error) => log(`the run's install wait was not said on its timeline: ${error?.message ?? String(error)}`)));
|
|
262
|
+
let waited = false;
|
|
263
|
+
const settled = await (deps.installSettled ?? claimSettled)(installs, dir, await pins(), { ...(waitOn ? { signal: waitOn } : {}), onWait: () => void ((waited = true), say()) });
|
|
264
|
+
// The install it waited for failed: the run fails in its words. An earlier one that failed before this claim is tried again.
|
|
265
|
+
if (typeof settled === "object" && waited)
|
|
266
|
+
throw new HarnessUnavailable(settled.failed, "install");
|
|
267
|
+
if (settled !== "installed" && !standsIn(name, deps.env ?? {})) {
|
|
268
|
+
await say();
|
|
269
|
+
const lock = deps.harnessLocks?.[name];
|
|
270
|
+
await (deps.installForClaim ?? installForClaim)(installs, dir, pins, { ...(lock ? { lock } : {}), ...(waitOn ? { signal: waitOn } : {}) }).catch((error) => {
|
|
271
|
+
if (waitOn?.aborted)
|
|
272
|
+
throw error;
|
|
273
|
+
throw new HarnessUnavailable(error.message, "install");
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin made at the first claim or read as written, its
|
|
278
|
+
// credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
|
|
279
|
+
// Before the session opens: a refusal (a pin that cannot be made, a pinned meta tool) ends the run in its words.
|
|
280
|
+
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
|
|
281
|
+
const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
282
|
+
redact.hold(values); };
|
|
283
|
+
const mcp = await mcpForClaim({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.mcpLoopback ? { loopback: true } : {}) });
|
|
284
|
+
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
285
|
+
holds.hold({ passed: mcp });
|
|
175
286
|
// The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
|
|
176
287
|
// on the claim's Archil disk (archil-claim.ts: its keys from the store's sealed rows, under the runner's seal key, in
|
|
177
288
|
// this claim's memory only, dropped at the release); else Mode 1, the run's local folder.
|
|
178
|
-
const archilSettings = await loadArchilSettings(deps.store);
|
|
289
|
+
const archilSettings = await loadArchilSettings(deps.store, deps.env);
|
|
179
290
|
const mode = archilSettings === undefined ? 1 : 2;
|
|
180
291
|
const archil = archilSettings === undefined
|
|
181
292
|
? undefined
|
|
@@ -183,7 +294,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
183
294
|
// named for the run and this claim's epoch; revoke at the run's end (below). mountControl (a test's loopback control-plane
|
|
184
295
|
// fake) is spread into the mount, so no test reaches the real control plane. TODO(k2 lazy mint): the mint moves into
|
|
185
296
|
// computerForClaim (a mounting computer only), with the ttl the run's lifetime bound (not this fixed figure). As pi does.
|
|
186
|
-
|
|
297
|
+
// The disk is the run's (run-disk.ts): its launch record's, else its agent's, made on its first run that needs one.
|
|
298
|
+
: await archilClaim({ settings: archilSettings, keys: deps.store.sealedKeys, sealKey: deps.sealKey, signal: run.signal ?? new AbortController().signal, env: deps.env, mount: { runId: claim.runId, epoch: claim.epoch, ttlMs: MOUNT_TTL_MS, ...(deps.mountControl ?? {}) }, run: { agentId: runRow.agentId, ...(launch.archilDisk ? { launch: launch.archilDisk } : {}), store: deps.store }, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) });
|
|
187
299
|
// Each resource is held the moment it exists (spec-holds.ts): a throw after it lets it go. The claim's Archil keys go
|
|
188
300
|
// from memory last, once nothing more reads the disk.
|
|
189
301
|
holds.hold({ archil, keys: archil });
|
|
@@ -192,35 +304,39 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
192
304
|
? await openRunWorkspace({ mode: 1, agentId: runRow.agentId, runId: claim.runId, data: deps.data, log })
|
|
193
305
|
: await openRunWorkspace({ mode: 2, agentId: runRow.agentId, runId: claim.runId, archil, log });
|
|
194
306
|
holds.hold({ ws });
|
|
307
|
+
// The pull request's checkout, when the revision asks for one, as the pi spec makes it (pr-checkout.ts).
|
|
308
|
+
const checkout = body.checkout === "pull_request" ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part })) : undefined;
|
|
309
|
+
holds.hold({ checkout });
|
|
195
310
|
if (launch.files?.length)
|
|
196
311
|
await copyRunFiles(deps.data, claim.runId, ws.workspace, launch.files);
|
|
197
312
|
// The run's computer, from the one shared claim-time function (the pi spec takes the same): none for a runner place.
|
|
198
313
|
// It throws computer_unavailable (nothing made) when the computer cannot be had: the run fails in its words.
|
|
199
|
-
const computer = await deps.computerForClaim({ runId: claim.runId, epoch: claim.epoch, revisionId: runRow.revisionId, place: launch.place, ...(launch.computer !== undefined ? { computer: launch.computer } : {}) }, deps.store,
|
|
314
|
+
const computer = await deps.computerForClaim({ runId: claim.runId, epoch: claim.epoch, claim, agentId: runRow.agentId, revisionId: runRow.revisionId, place: launch.place, ...(launch.computer !== undefined ? { computer: launch.computer } : {}) }, deps.store,
|
|
200
315
|
// revokeMount removes the run's Archil mount credential at the computer's release (and if a start fails after a mint); the
|
|
201
|
-
// run's end revokes it too, so it goes on every outcome even with no computer. Idempotent. As the pi spec does
|
|
316
|
+
// run's end revokes it too, so it goes on every outcome even with no computer. Idempotent. As the pi spec does, with
|
|
317
|
+
// what became of the agent's own computer said on the run's timeline.
|
|
202
318
|
// A browser computer is driven by the browser tool, which runs on pi's native route alone: a CLI's run of an agent
|
|
203
319
|
// whose computer is a browser is refused in words at its claim, before anything is made.
|
|
204
|
-
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, ...(archil ? { revokeMount: () => archil.revoke() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)) } : {}) });
|
|
320
|
+
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, ...(archil ? { revokeMount: () => archil.revoke() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
|
|
205
321
|
holds.hold({ computer });
|
|
322
|
+
const loopComputer = loopComputerOf(computer.computer, computer.held);
|
|
323
|
+
const heldComputer = heldSpecOf(launch, loopComputer);
|
|
206
324
|
// The CLI works in the run's scratch folder on this machine (its working directory), its own files (home, state, the
|
|
207
325
|
// skills laid for it) in this claim's private folder inside it, never on the run's disk. The scratch is an alias of the
|
|
208
326
|
// run's folder for the run's file tools: a path the CLI builds from its working directory lands in the run's folder, and
|
|
209
327
|
// any other absolute path is refused (workspace/paths.ts portPath).
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
223
|
-
});
|
|
328
|
+
// Made again if a parent went as it was made (another claim's sweep removing the then empty scratch or agent folder).
|
|
329
|
+
for (let tries = 1;; tries += 1) {
|
|
330
|
+
try {
|
|
331
|
+
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
if (error.code !== "ENOENT" || tries === 3)
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
await sweepEarlier(harnesses, claim.epoch).catch((error) => log(`an earlier claim's scratch folder could not be swept: ${error?.message ?? String(error)}`));
|
|
224
340
|
// The run's shell is its computer's (600 s) where one mounts its folder; with none, Archil's serverless exec in Mode 2
|
|
225
341
|
// (295 s), and in Mode 1 none at all: no bash family, its folder being one of this server's own (run-tools.ts).
|
|
226
342
|
// Under the agent's bash policy, its shell's environment is the policy's too (bash-read-only.ts policyEnv), as the pi spec does.
|
|
@@ -234,7 +350,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
234
350
|
// those it would refuse, and is handed the rest), then the effort guidance.
|
|
235
351
|
const start = learningStartOf(launch);
|
|
236
352
|
// A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
|
|
237
|
-
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section) : (body.instructions ?? "");
|
|
353
|
+
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section, start.use === true) : (body.instructions ?? "");
|
|
238
354
|
const check = await entry.skillCheck?.();
|
|
239
355
|
// The revision's own skills laid before they are read, as the pi spec lays them (adapter-run-spec.ts).
|
|
240
356
|
await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: launch.computer?.kind });
|
|
@@ -248,6 +364,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
248
364
|
own: Object.keys(revisionRow.skills ?? {}),
|
|
249
365
|
shown: async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true }),
|
|
250
366
|
log,
|
|
367
|
+
...(start.notesOnly ? { workflows: false } : {}),
|
|
368
|
+
...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
|
|
251
369
|
})
|
|
252
370
|
: undefined;
|
|
253
371
|
const { system: instructions, native } = await systemOf(laid, [...Object.keys(body.skills ?? {}), ...(seedLaid?.skills ?? [])], ws.workspace, check, { onDemand: readsFiles(granted) });
|
|
@@ -262,21 +380,10 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
262
380
|
const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, revisionRow, launch);
|
|
263
381
|
for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
264
382
|
holdClaimed(redact, claimed);
|
|
265
|
-
const env = cliRunEnv(deps.env, deps.data, claimed);
|
|
383
|
+
const env = cliRunEnv(deps.env, deps.data, claimed, launch.plane);
|
|
266
384
|
const chosen = await modelsOf(entry, env, modelAskOf(launch.model, body.model));
|
|
267
|
-
// A harness that installs on first use, whose install is running now (the server started it at an agent's save, or a
|
|
268
|
-
// run's start): the claim waits for it, bounded by the install's own limit, saying so on the run's timeline, and runs on
|
|
269
|
-
// it. A stop of the run ends the wait at once (the install goes on). An install that failed fails the run in its own
|
|
270
|
-
// words; with none running, the adapter says what is missing, as before.
|
|
271
|
-
if (entry.installs && entry.pins) {
|
|
272
|
-
const installs = entry.installs;
|
|
273
|
-
const waitOn = run.stopped ?? run.signal;
|
|
274
|
-
const settled = await (deps.installSettled ?? installSettled)(installs, installDirOf(deps.data, name), await entry.pins(), { ...(waitOn ? { signal: waitOn } : {}), onWait: () => run.phase?.(installingWords(installs.label)) });
|
|
275
|
-
if (typeof settled === "object")
|
|
276
|
-
throw new HarnessUnavailable(settled.failed, "install");
|
|
277
|
-
}
|
|
278
385
|
// The CLI's own process (the Claude CLI, Codex, OpenCode) starts under the no_new_privs pi's commands start under
|
|
279
|
-
// (
|
|
386
|
+
// (adapters.ts' noNewPrivsPrefix): on Linux, setpriv --no-new-privs, so a setuid program or file capability it
|
|
280
387
|
// or a command it runs reaches grants nothing; none on macOS. Where setpriv is not usable the run is refused, in pi's words.
|
|
281
388
|
const confine = confineOf(noNewPrivsPrefix());
|
|
282
389
|
const built = await entry.adapter(env, { model: chosen.model, models: chosen.models, unpriced: chosen.unpriced, ...(confine ? { confine } : {}), ...(native.length ? { skills: native } : {}) });
|
|
@@ -330,6 +437,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
330
437
|
// The run's one cap, as the loop's runCap reads it (adapter-loop.ts RunCapConfig): the launch's cap figure (undefined
|
|
331
438
|
// uncapped), the model that bills this CLI run priced WITH tiers, strict where the launch says. The loop builds the
|
|
332
439
|
// kernel runCap from these over the run's own sessions; the spec carries no beforeRequest of its own.
|
|
440
|
+
const besideOf = spentBesideOf(launch, deps.store, claim.runId);
|
|
333
441
|
const runCap = {
|
|
334
442
|
capUsd: () => launch.maxCostUsd,
|
|
335
443
|
// One model per CLI session: every request it sends is the run's model, whatever id its provider names it by. A
|
|
@@ -342,6 +450,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
342
450
|
return tierRoute && tierRoute.model === id ? capModelOfRoute(tierRoute) : undefined;
|
|
343
451
|
},
|
|
344
452
|
...(launch.capMode === "strict" ? { mode: "strict" } : {}),
|
|
453
|
+
// What its learning runs' grades took beside it, read by every gate with its own sessions (none: it queues none).
|
|
454
|
+
...(besideOf ? { beside: besideOf } : {}),
|
|
345
455
|
};
|
|
346
456
|
const cap = capUsd === undefined
|
|
347
457
|
? undefined
|
|
@@ -354,8 +464,14 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
354
464
|
};
|
|
355
465
|
// The gate before a call's intent, the same as the pi spec: the revision's tool settings over the store's, read from the
|
|
356
466
|
// store at each decide — adapterRunGate (RunGate.decide: deny with its words, a pin, allow, ask). The end-of-run turn's
|
|
357
|
-
// refusal of writes under .learning/ is the adapter loop's own (it knows the turn), never a file's.
|
|
358
|
-
|
|
467
|
+
// refusal of writes under .learning/ is the adapter loop's own (it knows the turn), never a file's. The run's MCP servers
|
|
468
|
+
// (mcpServersOf its grants) hold a harness's own name for an MCP tool to that tool's settings.
|
|
469
|
+
const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, mcpServersOf(granted));
|
|
470
|
+
// What a script's shell and files are held to: this gate, so a denied bash or write holds inside computer_script too.
|
|
471
|
+
tools.computer?.guard.install(async (tool, args) => {
|
|
472
|
+
await gate.permissions.refresh();
|
|
473
|
+
return gate.permissions.decide(tool, args);
|
|
474
|
+
});
|
|
359
475
|
// The run's tools: the kernel registry's hands on its Workspace (and computer); the web host tools it is granted
|
|
360
476
|
// (web_fetch, web_search, monid), bound by the binding the pi spec uses (webHostTools) on the ToolHost the pi spec builds
|
|
361
477
|
// (buildToolHost); and the learned_workflow tool when the run has it (learnsWorkflows: its revision is agentic and the
|
|
@@ -420,18 +536,18 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
420
536
|
}
|
|
421
537
|
}
|
|
422
538
|
// The gate asks a learned_workflow call about its workflow's MCP nodes (adapterRunGate); they run through the run's
|
|
423
|
-
// own MCP as the loop wraps it.
|
|
539
|
+
// own MCP as the loop wraps it. Its model nodes run on the session's one model: what each node's trace says it ran on.
|
|
424
540
|
gate.learn(workflows);
|
|
425
|
-
learnedTool = await learnedWorkflowHostTool({ run, kind: revision.kind, granted, plane: launch.plane, env: toolEnv, work: root, workflows, permissions: gate.permissions, ctx, tiers, ...(mcp ? { mcp } : {}) });
|
|
541
|
+
learnedTool = await learnedWorkflowHostTool({ run, kind: revision.kind, granted, plane: launch.plane, env: toolEnv, work: root, workflows, permissions: gate.permissions, ctx, tiers, ...(mcp ? { mcp } : {}), workspace: ws.workspace, modelName: () => chosen.model.modelId });
|
|
426
542
|
}
|
|
427
543
|
}
|
|
428
544
|
const session = {
|
|
429
545
|
key: `run:${claim.runId}`,
|
|
430
546
|
label: runRow.agentId,
|
|
431
|
-
system: [environmentLine(), instructions, guidance].filter((line) => Boolean(line)),
|
|
547
|
+
system: [environmentLine(), checkout?.note, instructions, guidance].filter((line) => Boolean(line)),
|
|
432
548
|
// The web tools and the learned workflow's call nodes run on the claim's keys: their answers pass the runner's one
|
|
433
|
-
// redactor, as pi's do.
|
|
434
|
-
tools: [...tools.hostTools(withKindTools(granted, tools), results), ...[...webTools, ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))],
|
|
549
|
+
// redactor, as pi's do. Listed in the order the agent grants them, as main lists a CLI run's tools.
|
|
550
|
+
tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), results), ...[...webTools, ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
|
|
435
551
|
context: "fresh",
|
|
436
552
|
...(thinking ? { thinking } : {}),
|
|
437
553
|
};
|
|
@@ -450,6 +566,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
450
566
|
signIns: signInReads(deps.store, deps.sealKey),
|
|
451
567
|
handed: handedKeys,
|
|
452
568
|
stored: () => storeSecrets(deps.store, deps.sealKey, deps.data),
|
|
569
|
+
// A workflow draft's decision nodes are checked against the host's decision providers, on its keys (LS-07).
|
|
570
|
+
decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, DECISION_PROVIDER_KEYS)) }),
|
|
453
571
|
learningFolder: archil === undefined
|
|
454
572
|
? (agentId) => learningFolderOf(deps.data, agentId)
|
|
455
573
|
: (agentId) => learningWorkspace({ mode: "archil", agentId, archil }),
|
|
@@ -472,6 +590,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
472
590
|
// The web tools' install lifecycle, run by the adapter loop, as the pi spec's (they register none today).
|
|
473
591
|
...(life ? { lifecycle: life } : {}),
|
|
474
592
|
agentId: runRow.agentId,
|
|
593
|
+
// The run's computer and the person's hold on a desktop or phone, as the claim made them (as the pi spec gives them).
|
|
594
|
+
...(loopComputer ? { computer: loopComputer } : {}),
|
|
475
595
|
workRoot: root,
|
|
476
596
|
// Where the CLI works (its working directory, the run's folder to its file tools): what its absolute paths are read
|
|
477
597
|
// against on the run's rows.
|
|
@@ -482,20 +602,24 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
482
602
|
// session of its journal), as a pi run's are at its answers' costs and tokens.
|
|
483
603
|
endPatch: async () => {
|
|
484
604
|
const entries = await entriesOf(deps.journal(claim), ROOT_CONVERSATION_ID, context);
|
|
485
|
-
// Its tokens and model requests, and its model requests' cost, from one read of its booking (cliRunMetrics)
|
|
486
|
-
// decisions (a learned workflow's) at what they were booked at
|
|
605
|
+
// Its tokens and model requests, and its model requests' cost, from one read of its booking (cliRunMetrics). Its
|
|
606
|
+
// model requests and its decisions (a learned workflow's, LS-07) at what they were booked at (bookedSpend), and its
|
|
607
|
+
// paid tool calls (a Parallel extract or search, a monid call), booked on the run's one ledger in their own session,
|
|
608
|
+
// are the run's cost (runEndCost: unknown when any part is), as the pi spec's.
|
|
487
609
|
const all = (await journalEntries(deps.journal(claim), context));
|
|
488
610
|
const booked = bookedSpend(all, "model");
|
|
489
611
|
const metrics = cliRunMetrics(entries, booked, { ...(thinking ? { effort: thinking } : {}), model: `${chosen.model.provider}/${chosen.model.modelId}` });
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
const
|
|
612
|
+
// A run whose model answered or called a tool with no request booked (its requests went past its model proxy) spent
|
|
613
|
+
// what no booking read: unknown, never the $0 an empty booking sums to.
|
|
614
|
+
const model = booked.requests === 0 && cliModelWorked(entries) ? null : booked.usd;
|
|
493
615
|
// Its paid tool calls (a Parallel extract or search, a monid call), booked on the run's one ledger in their own
|
|
494
|
-
// session, are the run's cost too, as the pi spec's.
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
return {
|
|
616
|
+
// session, and its decisions (a learned workflow's decision nodes) are the run's cost too, as the pi spec's.
|
|
617
|
+
const total = runEndCost({ model, paid: run.ledger?.paid ? run.ledger.paid.spentUsd() : 0, decisions: bookedSpend(all, "decisions").usd });
|
|
618
|
+
// An unknown cost is written as null, never left out: a follow-up's end clears the cost an earlier end stored.
|
|
619
|
+
return { costUsd: total, metrics };
|
|
498
620
|
},
|
|
621
|
+
// A run started with hold: true holds its computer for its owner (computer-held.ts), as the pi spec's.
|
|
622
|
+
...(heldComputer ? { held: heldComputer } : {}),
|
|
499
623
|
// The run's Archil mount credential is revoked at its end on every outcome, even with no computer (idempotent with
|
|
500
624
|
// the computer's release). A run that minted none revokes nothing.
|
|
501
625
|
release: () => holds.release(),
|
|
@@ -2,7 +2,9 @@ import type { Command } from "./loop-contract.js";
|
|
|
2
2
|
/** stop and cancel both end the run, stopped: a cancel's end says it was cancelled, as main's cancel ends a run for good.
|
|
3
3
|
* browser_hand_back is a person's answer to the agent's browser hand-over (runner/hand-back.ts). computer_take_over and
|
|
4
4
|
* computer_hand_back are a person's turn with the run's desktop or phone (computer-commands.ts, runner/computer-journal.ts).
|
|
5
|
-
*
|
|
5
|
+
* computer_call is the computer call channel's: one protocol call on the run's computer (computer-channel.ts,
|
|
6
|
+
* runner/computer-channel.ts). computer_start and computer_release are the owner's, for a computer the run holds
|
|
7
|
+
* (computer-held.ts, runner/held-run.ts). pause and resume are a workflow run's (runs.ts pause). */
|
|
6
8
|
export declare const COMMAND_KINDS: ReadonlySet<string>;
|
|
7
9
|
export interface CommandInput {
|
|
8
10
|
readonly kind: string;
|
|
@@ -13,11 +15,15 @@ export interface CommandSink {
|
|
|
13
15
|
command(runId: string, command: {
|
|
14
16
|
kind: string;
|
|
15
17
|
body: Record<string, unknown>;
|
|
18
|
+
}, options?: {
|
|
19
|
+
launchSealed?: Uint8Array;
|
|
16
20
|
}): Promise<Command>;
|
|
17
21
|
}
|
|
18
22
|
/** Inserts a command row for a run, after checking its kind and body. Rejects RunFinal (from the store) when the run is
|
|
19
23
|
* final, and a TypeError for a kind or body no runner would take. */
|
|
20
|
-
export declare function sendCommand(store: CommandSink, runId: string, input: CommandInput
|
|
24
|
+
export declare function sendCommand(store: CommandSink, runId: string, input: CommandInput, options?: {
|
|
25
|
+
launchSealed?: Uint8Array;
|
|
26
|
+
}): Promise<Command>;
|
|
21
27
|
/** The reason a command still untaken when its run ended is refused with: the store's own words (the write that makes a
|
|
22
28
|
* run final refuses such rows itself). */
|
|
23
29
|
export { endedReason } from "../store/store.js";
|
package/dist/runner/commands.js
CHANGED
|
@@ -5,9 +5,23 @@ import { originOf } from "../timeline/index.js";
|
|
|
5
5
|
/** stop and cancel both end the run, stopped: a cancel's end says it was cancelled, as main's cancel ends a run for good.
|
|
6
6
|
* browser_hand_back is a person's answer to the agent's browser hand-over (runner/hand-back.ts). computer_take_over and
|
|
7
7
|
* computer_hand_back are a person's turn with the run's desktop or phone (computer-commands.ts, runner/computer-journal.ts).
|
|
8
|
-
*
|
|
9
|
-
|
|
8
|
+
* computer_call is the computer call channel's: one protocol call on the run's computer (computer-channel.ts,
|
|
9
|
+
* runner/computer-channel.ts). computer_start and computer_release are the owner's, for a computer the run holds
|
|
10
|
+
* (computer-held.ts, runner/held-run.ts). pause and resume are a workflow run's (runs.ts pause). */
|
|
11
|
+
export const COMMAND_KINDS = new Set(["stop", "cancel", "steer", "approve", "deny", "raise", "browser_hand_back", "computer_take_over", "computer_hand_back", "computer_start", "computer_call", "computer_release", "pause", "resume"]);
|
|
10
12
|
const text = (value) => typeof value === "string" && value.trim() !== "";
|
|
13
|
+
/** Whether `value` is the JSON text of an object (not an array, not null). */
|
|
14
|
+
const objectText = (value) => {
|
|
15
|
+
if (typeof value !== "string")
|
|
16
|
+
return false;
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(value);
|
|
19
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
11
25
|
/** Why a command's body is wrong for its kind, or undefined when it is right. */
|
|
12
26
|
function bodyProblem(kind, body) {
|
|
13
27
|
switch (kind) {
|
|
@@ -17,7 +31,7 @@ function bodyProblem(kind, body) {
|
|
|
17
31
|
case "steer":
|
|
18
32
|
if (!text(body.text))
|
|
19
33
|
return "a steer needs its text";
|
|
20
|
-
// A trigger's message names who wrote it, as the Timeline shows it
|
|
34
|
+
// A trigger's message names who wrote it, as the Timeline shows it: never a person's.
|
|
21
35
|
return body.origin === undefined || originOf(body.origin) !== undefined ? undefined : "a steer's origin is a message origin (a trigger's, or the server's)";
|
|
22
36
|
case "approve":
|
|
23
37
|
case "deny":
|
|
@@ -42,9 +56,20 @@ function bodyProblem(kind, body) {
|
|
|
42
56
|
if (!text(body.ask))
|
|
43
57
|
return "a computer hand-back names the take it ends (take) or the ask it answers (ask)";
|
|
44
58
|
return body.outcome === "done" || body.outcome === "cancelled" ? undefined : "a computer hand-back's outcome is done or cancelled";
|
|
59
|
+
case "computer_call":
|
|
60
|
+
if (!text(body.method))
|
|
61
|
+
return "a computer call names its protocol method";
|
|
62
|
+
// A call answers no park (answers: false), so a row written as its run parks never wakes it.
|
|
63
|
+
if (body.answers !== false)
|
|
64
|
+
return "a computer call answers no park (answers: false)";
|
|
65
|
+
// Its params as one JSON text (computer-channel.ts callComputer), so a settle's jsonb never decodes what was typed.
|
|
66
|
+
return body.params === undefined || objectText(body.params) ? undefined : "a computer call's params are a JSON object's text";
|
|
67
|
+
case "computer_start":
|
|
68
|
+
case "computer_release":
|
|
45
69
|
case "pause":
|
|
46
70
|
case "resume":
|
|
47
|
-
// A
|
|
71
|
+
// A held run's start or release (POST /runs/{id}/start, /computer/release), or a workflow run's pause or resume
|
|
72
|
+
// (POST /runs/{id}/pause, /resume): the run's runner takes it; it carries nothing.
|
|
48
73
|
return Object.keys(body).length === 0 ? undefined : `a ${kind} carries nothing`;
|
|
49
74
|
default:
|
|
50
75
|
return undefined;
|
|
@@ -52,7 +77,7 @@ function bodyProblem(kind, body) {
|
|
|
52
77
|
}
|
|
53
78
|
/** Inserts a command row for a run, after checking its kind and body. Rejects RunFinal (from the store) when the run is
|
|
54
79
|
* final, and a TypeError for a kind or body no runner would take. */
|
|
55
|
-
export async function sendCommand(store, runId, input) {
|
|
80
|
+
export async function sendCommand(store, runId, input, options) {
|
|
56
81
|
if (!COMMAND_KINDS.has(input.kind)) {
|
|
57
82
|
throw new TypeError(`a command's kind is one of ${[...COMMAND_KINDS].join(", ")}, not ${JSON.stringify(input.kind)}`);
|
|
58
83
|
}
|
|
@@ -60,7 +85,7 @@ export async function sendCommand(store, runId, input) {
|
|
|
60
85
|
const problem = bodyProblem(input.kind, body);
|
|
61
86
|
if (problem)
|
|
62
87
|
throw new TypeError(problem);
|
|
63
|
-
return store.command(runId, { kind: input.kind, body });
|
|
88
|
+
return store.command(runId, { kind: input.kind, body }, ...(options ? [options] : []));
|
|
64
89
|
}
|
|
65
90
|
/** The reason a command still untaken when its run ended is refused with: the store's own words (the write that makes a
|
|
66
91
|
* run final refuses such rows itself). */
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ComputerClient, HelloResult } from "@parcha/agentrun-computer";
|
|
2
|
+
import { type ComputerCallRecord } from "../computer-calls.js";
|
|
3
|
+
import { type ComputerAnswer, type ComputerCall } from "../computer-channel.js";
|
|
4
|
+
import type { ComputerHold, HeldComputer } from "../workspace/computer-hold.js";
|
|
5
|
+
import type { RunComputer } from "../workspace/run-tools.js";
|
|
6
|
+
import type { Command } from "./loop-contract.js";
|
|
7
|
+
/** The run's computer as the loop drives it: its kind, the client of the computer its claim made and the hello it
|
|
8
|
+
* connected with, and, on a desktop or a phone, the person's hold on it (workspace/computer-hold.ts). A browser is none:
|
|
9
|
+
* it speaks CDP, not the protocol. */
|
|
10
|
+
export type LoopComputer = {
|
|
11
|
+
readonly kind: "sandbox" | "desktop" | "phone";
|
|
12
|
+
readonly client: ComputerClient;
|
|
13
|
+
readonly hello?: HelloResult;
|
|
14
|
+
readonly hold?: ComputerHold;
|
|
15
|
+
};
|
|
16
|
+
/** The loop's computer for a claim's (computerForClaim's `computer` and `held`): none for no computer or a browser. */
|
|
17
|
+
export declare function loopComputerOf(computer: RunComputer | undefined, held: HeldComputer | undefined): LoopComputer | undefined;
|
|
18
|
+
/** A computer_call row's call, or why it is refused (a row the server wrote is always one; a hand-made one may not be). */
|
|
19
|
+
export declare function channelCallOf(command: Pick<Command, "body">): ComputerCall | {
|
|
20
|
+
readonly refused: string;
|
|
21
|
+
};
|
|
22
|
+
/** What one call came to: the computer's answer, the call's record, and when it ended (ms). */
|
|
23
|
+
export type ChannelAnswer = {
|
|
24
|
+
readonly answer: ComputerAnswer;
|
|
25
|
+
readonly record: ComputerCallRecord;
|
|
26
|
+
readonly at: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Runs `call` on `computer` and answers what came of it; never throws. While a person holds the computer the call waits,
|
|
30
|
+
* as the agent's calls do, and counts as in flight once it runs, so a take asked meanwhile waits for it. `signal` bounds
|
|
31
|
+
* the whole of it (the loop's: CALL_MS, and the claim's): a wait or a call it cuts answers `timeout`, a call whose client
|
|
32
|
+
* failed answers `gone`. The call is no tool call's, so it is recorded on none.
|
|
33
|
+
*/
|
|
34
|
+
export declare function runChannelCall(computer: LoopComputer, call: ComputerCall, signal: AbortSignal, now?: () => number): Promise<ChannelAnswer>;
|