@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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import { type CapModel } from "@parcha/agentrun-kernel/kernel/cap";
|
|
3
3
|
import type { HostTool, Wire } from "@parcha/agentrun-kernel";
|
|
4
4
|
import type { Approvals } from "../approvals.js";
|
|
5
|
-
import type { installSettled } from "../harness-install.js";
|
|
5
|
+
import type { installForClaim, installSettled } from "../harness-install.js";
|
|
6
6
|
import type { LiveHandover, LiveViewerStore } from "../browser-live.js";
|
|
7
7
|
import { type PinnedModel, type Tier } from "../model.js";
|
|
8
8
|
import { type RunLaunch } from "../run-launch.js";
|
|
@@ -14,19 +14,22 @@ import { type HostToolCtx } from "../host-tools.js";
|
|
|
14
14
|
import { type LearnedWorkflow } from "../learning.js";
|
|
15
15
|
import { type ToolResults } from "../workspace/run-tools.js";
|
|
16
16
|
import { type ClaimMcp } from "./mcp-run.js";
|
|
17
|
-
import { type AdapterRun, type AdapterRunSpec, hostLifecycle } from "./adapter-loop.js";
|
|
17
|
+
import { type AdapterLoopOptions, type AdapterRun, type AdapterRunSpec, hostLifecycle } from "./adapter-loop.js";
|
|
18
18
|
import { type Claim, type Journal } from "./loop-contract.js";
|
|
19
19
|
import type { ModelRoute } from "./model-route.js";
|
|
20
20
|
import { type ArchilClaimOptions } from "../workspace/archil-claim.js";
|
|
21
21
|
import { type claimComputer, type ComputerDeps } from "../workspace/computer-deps.js";
|
|
22
22
|
import type { RunComputer } from "../workspace/run-tools.js";
|
|
23
|
+
import type { RunComputerHold } from "./computer-journal.js";
|
|
23
24
|
import type { ShellPlace } from "../workspace/resolve-computer.js";
|
|
24
25
|
import type { Workspace } from "../workspace/workspace.js";
|
|
25
26
|
import { type HeldRedact } from "./redact.js";
|
|
26
|
-
/** What a claim gives the shared computerForClaim: the run, its epoch,
|
|
27
|
+
/** What a claim gives the shared computerForClaim: the run, its epoch, the claim itself (a live view's row is fenced on it
|
|
28
|
+
* and names its runner), its revision, its place and any computer choice. */
|
|
27
29
|
export interface ClaimLaunch {
|
|
28
30
|
readonly runId: string;
|
|
29
31
|
readonly epoch: number;
|
|
32
|
+
readonly claim?: unknown;
|
|
30
33
|
readonly revisionId: string;
|
|
31
34
|
readonly place?: unknown;
|
|
32
35
|
readonly computer?: unknown;
|
|
@@ -44,6 +47,8 @@ export interface ClaimDeps {
|
|
|
44
47
|
export interface ClaimComputer {
|
|
45
48
|
readonly computer?: RunComputer;
|
|
46
49
|
readonly hold?: unknown;
|
|
50
|
+
/** The run's desktop or phone and the person's hold on it: the spec's `computer` (AdapterRunSpec.computer). */
|
|
51
|
+
readonly held?: RunComputerHold;
|
|
47
52
|
release(): Promise<void>;
|
|
48
53
|
}
|
|
49
54
|
/** The one shared claim-time computer every spec takes (computer-for-claim.ts), passed in by the runner: the composer's
|
|
@@ -96,12 +101,31 @@ export interface AdapterSpecDeps {
|
|
|
96
101
|
/** How a CLI run's claim waits for its harness's first-use install (harness-install.ts installSettled); a test wraps it
|
|
97
102
|
* to see the claim reach the wait. Absent, installSettled itself. */
|
|
98
103
|
readonly installSettled?: typeof installSettled;
|
|
104
|
+
/** How a CLI run's claim installs its harness when nothing installs it (harness-install.ts installForClaim); a test gives
|
|
105
|
+
* its own, so none reaches npm. Absent, installForClaim itself. */
|
|
106
|
+
readonly installForClaim?: typeof installForClaim;
|
|
107
|
+
/** For tests only: the lock a claim's first-use install of each harness installs by (harness-install.ts installForClaim),
|
|
108
|
+
* by harness, as the server's own option of that name gives its installs. The CLI's runner never sets it, and no
|
|
109
|
+
* environment variable, flag or setting maps onto it; absent, the lock AgentRun ships. */
|
|
110
|
+
readonly harnessLocks?: Readonly<Record<string, string>>;
|
|
99
111
|
/** A test runner's fake GitHub API, where the GitHub App's installation tokens are minted (runner/github-app.ts). Absent,
|
|
100
112
|
* https://api.github.com: the CLI's runner never sets it, and no environment variable, flag or setting maps onto it. */
|
|
101
113
|
readonly githubApi?: string;
|
|
114
|
+
/** A test runner's GitHub site, where a run's pull request is checked out from (pr-checkout.ts): a folder of bare
|
|
115
|
+
* repositories, or a git server on loopback. Absent, https://github.com; nothing kept, no environment variable and no
|
|
116
|
+
* flag reaches it. */
|
|
117
|
+
readonly githubWeb?: string;
|
|
102
118
|
/** A test runner's fake GitHub MCP origin, the one a github_app server may be at (mcp-claim.ts githubMcpOrigin):
|
|
103
119
|
* for tests only: no environment variable, flag or setting maps onto it; absent, GitHub's hosted MCP (github.ts GITHUB_MCP_ORIGIN). Only a test's in-process runner sets it; the CLI's runner never does. */
|
|
104
120
|
readonly githubMcpOrigin?: string;
|
|
121
|
+
/** Whether this runner's runs may reach an MCP server whose URL is on loopback: only a runner beside a local-install
|
|
122
|
+
* server (runner/beside.ts, Serve.localInstall) is told so, by that server in its own process. Absent, never: a hosted
|
|
123
|
+
* or standalone runner's loopback is its host's other services. */
|
|
124
|
+
readonly mcpLoopback?: boolean;
|
|
125
|
+
/** For tests only: the adapter loop's model retry (adapter-loop.ts retry and stream), so a test whose provider fails a run
|
|
126
|
+
* on purpose does not wait out MODEL_RETRY's two and a half minutes. No environment variable, flag or setting maps onto
|
|
127
|
+
* it; absent, MODEL_RETRY and MODEL_STREAM. */
|
|
128
|
+
readonly modelRetry?: Pick<AdapterLoopOptions, "retry" | "stream">;
|
|
105
129
|
}
|
|
106
130
|
/** A model as the cap prices it, from the route's catalog cost: its price WITH TIERS (the money rule — a request past a
|
|
107
131
|
* model's tier is held and booked at the tier, as main's calculateCost does). `api` is the proxy's shape, for the
|
|
@@ -157,7 +181,7 @@ export declare function adapterRunGate(store: Pick<Store, "settings">, claim: Pi
|
|
|
157
181
|
approvals?: Approvals;
|
|
158
182
|
maxToolCalls?: number;
|
|
159
183
|
};
|
|
160
|
-
}, root: RunFiles, shell?: ShellPlace): Promise<NonNullable<AdapterRunSpec["gate"]> & {
|
|
184
|
+
}, root: RunFiles, shell?: ShellPlace, mcpServers?: readonly string[]): Promise<NonNullable<AdapterRunSpec["gate"]> & {
|
|
161
185
|
readonly permissions: RunPermissions;
|
|
162
186
|
readonly learn: (flows: readonly LearnedWorkflow[]) => void;
|
|
163
187
|
}>;
|
|
@@ -168,7 +192,7 @@ export declare function storeSettings(store: Pick<Store, "settings">): Promise<A
|
|
|
168
192
|
* tools) is held until the spec's release; a build that throws part-way lets go what it made by then (spec-holds.ts). */
|
|
169
193
|
export declare function adapterRunSpecFromLaunch(launch: RunLaunch, run: AdapterRun, deps: AdapterSpecDeps, claim: Claim): Promise<AdapterRunSpec>;
|
|
170
194
|
/** The host-tool ctx a non-hand tool is wrapped with (host-tools.ts hostToolOf): the run's own Harness (its commit,
|
|
171
|
-
* snapshot
|
|
195
|
+
* snapshot and task reads), the results map, and the run's folder as the api env's cwd (a tool reads no
|
|
172
196
|
* file environment, so an error names a path relative to it). Shared by the pi spec's bindNonHandTools and the CLI spec's
|
|
173
197
|
* learned_workflow. */
|
|
174
198
|
export declare function hostToolCtxOf(run: AdapterRun, context: Context, results: ToolResults, root: string): HostToolCtx;
|
|
@@ -217,12 +241,17 @@ export declare function learnedWorkflowHostTool(opts: {
|
|
|
217
241
|
/** The claim's MCP (mcp-run.ts mcpForClaim), when its revision grants an MCP tool: its call nodes may name its tools by
|
|
218
242
|
* catalog name, each run through the run's own MCP as the loop wraps it. */
|
|
219
243
|
readonly mcp?: Pick<ClaimMcp, "tools" | "catalogOf">;
|
|
244
|
+
/** The run's own Workspace (Mode 2: its folder on the run's disk): a decision node's images are read through it. */
|
|
245
|
+
readonly workspace?: Workspace;
|
|
246
|
+
/** The model a node on the session's own port runs on (a node of no tier, or of a tier not in `tiers`), as the run's
|
|
247
|
+
* route names it: what its trace says it ran on. A node of a tier in `tiers` names that tier's model. */
|
|
248
|
+
readonly modelName?: (tier: string | undefined) => string | undefined;
|
|
220
249
|
}): Promise<HostTool | undefined>;
|
|
221
250
|
/** The run's non-hand tools as HostTool[], bound through the ToolHost seam and wrapped as the hands are (host-tools.ts
|
|
222
251
|
* hostToolOf): web_fetch, web_search and monid, each by its catalog name under the adapter loop's one gate (`spec.gate`;
|
|
223
252
|
* `gated` is undefined here, as for the hands). Their paid requests are booked by the adapter loop on the run's one ledger
|
|
224
253
|
* (bookedIn), as main books them, so they run. The browser (through host.liveViewers), MCP (the MCP claim step's
|
|
225
|
-
* mcpForClaim(claim, store, sealKey, pin) -> { sessionMcp,
|
|
254
|
+
* mcpForClaim(claim, store, sealKey, pin) -> { sessionMcp, release }), the learned workflow and decisions are
|
|
226
255
|
* each a named todo, added as their seams land. */
|
|
227
256
|
/** The run's live-viewer writers over the store (browser-live.ts): a session's hand-over written sealed, and gone. Its
|
|
228
257
|
* viewer token, minted in the run, is held by `cut`, the run's one redactor, as it is handed over, before it is written. */
|
|
@@ -2,13 +2,15 @@ import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
|
2
2
|
import { defineExtension, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
3
3
|
import { checkRaise, followUpOf, parkOf } from "@parcha/agentrun-kernel/kernel/cap";
|
|
4
4
|
import { inspectWorkflow } from "@parcha/agentrun-dsl";
|
|
5
|
+
import { decisionProvidersIn } from "../decisions.js";
|
|
5
6
|
import { dropLiveViewer, putLiveViewer } from "../browser-live.js";
|
|
7
|
+
import { runnerLiveOf } from "../live-reach.js";
|
|
6
8
|
import { llmTiers, nodeTiers, thinkingLevel, TIERS, tierModelOf, workflowNodes } from "../model.js";
|
|
7
9
|
import { firstMessage } from "../run-manifest.js";
|
|
8
10
|
import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
9
11
|
import { isObject } from "../validate.js";
|
|
10
|
-
import { deniedText, noApproverText, runGate } from "../tool-gate.js";
|
|
11
|
-
import { loadToolSettings, recheckPlane, TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
12
|
+
import { deniedText, mcpServersOf, noApproverText, runGate } from "../tool-gate.js";
|
|
13
|
+
import { DECISION_PROVIDER_KEYS, loadToolSettings, recheckPlane, TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
12
14
|
import { readApprovers } from "../server-approvers.js";
|
|
13
15
|
import { ASK_TOOL, askPerson, toolOf } from "../tools.js";
|
|
14
16
|
import { hostToolOf } from "../host-tools.js";
|
|
@@ -19,7 +21,7 @@ import { effortGuidance } from "../effort-guidance.js";
|
|
|
19
21
|
import { laidLearned, learningFolderOf, secretsShown } from "../learning.js";
|
|
20
22
|
import { laidOf, layLearningSeed } from "./learning-seed.js";
|
|
21
23
|
import { learningWorkspace } from "../learn/folder.js";
|
|
22
|
-
import { learningEndOfRun } from "./learning-end.js";
|
|
24
|
+
import { learningEndOfRun, spentBesideOf } from "./learning-end.js";
|
|
23
25
|
import { learnedAskFits, learnedAskShown, LEARNED_WORKFLOW_TOOL, learnedMcpTools, learnedWorkflowTool } from "../learned-workflow.js";
|
|
24
26
|
import { PORT_PROVIDER, tieredModels, tierProvider } from "../port-models.js";
|
|
25
27
|
import { promptOf, readsFiles } from "../skills.js";
|
|
@@ -30,19 +32,27 @@ import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
|
30
32
|
import { copyRunFiles } from "../uploads.js";
|
|
31
33
|
import { handedSignInReadsBack, signInReads } from "../sign-ins-store.js";
|
|
32
34
|
import { UNREADABLE_SIGN_IN } from "../run-view.js";
|
|
33
|
-
import {
|
|
35
|
+
import { durableWait } from "../workflow/pi-versions.js";
|
|
36
|
+
import { claimSecrets, hostDecisionKeys, learnedDecisionKeys, savedModelKeys, tierModelKeys, withModelKeys } from "./claim-secrets.js";
|
|
34
37
|
import { mcpForClaim } from "./mcp-run.js";
|
|
35
38
|
import { hostLifecycle } from "./adapter-loop.js";
|
|
36
39
|
import { piAdapter } from "./adapters/pi.js";
|
|
37
|
-
import {
|
|
40
|
+
import { computerCodemode } from "./adapters/pi-computer.js";
|
|
41
|
+
import { agentEntriesOf } from "./loop.js";
|
|
42
|
+
import { SUBAGENT_TIERS, SUBAGENT_TOOL, subagentTool } from "./subagent.js";
|
|
43
|
+
import { wireName } from "../catalog.js";
|
|
38
44
|
import { ClaimRefused } from "./loop-contract.js";
|
|
39
|
-
import { runMetrics } from "./metrics.js";
|
|
45
|
+
import { bookedSpend, runEndCost, runMetrics } from "./metrics.js";
|
|
46
|
+
import { journalEntries } from "./journal-reader.js";
|
|
40
47
|
import { specBuilt } from "./spec-holds.js";
|
|
41
48
|
import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
42
49
|
import { loadArchilSettings } from "../archil-settings.js";
|
|
43
|
-
import { imageWaitWords } from "../workspace/computer-deps.js";
|
|
50
|
+
import { computerReadyWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
44
51
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
52
|
+
import { heldSpecOf } from "./held-run.js";
|
|
53
|
+
import { loopComputerOf } from "./computer-channel.js";
|
|
45
54
|
import { githubAppAccess } from "./github-app.js";
|
|
55
|
+
import { prCheckoutForClaim } from "./pr-checkout.js";
|
|
46
56
|
import { holdStored, storeSecrets } from "./store-secrets.js";
|
|
47
57
|
import { bashPolicyOf } from "../bash-read-only.js";
|
|
48
58
|
/** The wires pi speaks on the runner: main's pi's (provider.ts), Anthropic's Messages and OpenAI's Responses. */
|
|
@@ -60,7 +70,8 @@ export const browserListed = (host, granted) => BROWSER_ON_RUNNER && host.ledger
|
|
|
60
70
|
* model's tier is held and booked at the tier, as main's calculateCost does). `api` is the proxy's shape, for the
|
|
61
71
|
* overhead its provider adds; the output ceiling is the route's when it carries one, else none. */
|
|
62
72
|
export function capModelOf(route) {
|
|
63
|
-
|
|
73
|
+
// A model serve has no price for carries placeholder zeros: the cap reads it as unknown (null), never as $0.
|
|
74
|
+
const cost = route.unpriced ? undefined : route.cost;
|
|
64
75
|
const price = cost
|
|
65
76
|
? {
|
|
66
77
|
input: cost.input,
|
|
@@ -73,6 +84,11 @@ export function capModelOf(route) {
|
|
|
73
84
|
// The cap reads a request's provider overhead by the route's own wire (providerInputOverhead).
|
|
74
85
|
return { id: route.model, api: route.provider.api, price, outputCeiling: route.outputCeiling ?? null };
|
|
75
86
|
}
|
|
87
|
+
/** The key of a subagent tier's route in a run's tier routes and proxies (a key of its own, never a learned workflow's
|
|
88
|
+
* tier: those nodes keep their own route and fallback). */
|
|
89
|
+
const SUBAGENT_ROUTE = "subagent-";
|
|
90
|
+
const subagentRoute = (tier) => `${SUBAGENT_ROUTE}${tier}`;
|
|
91
|
+
const isSubagentRoute = (key) => key.startsWith(SUBAGENT_ROUTE);
|
|
76
92
|
/** What the runner routes a claimed run on: the launch's model as its start pinned it, sent as pinned, with the
|
|
77
93
|
* revision's own ref beside it (main prices a gateway's id by the provider that ref names); the revision's ref alone
|
|
78
94
|
* when the start pinned none. Never the pin's provider and id joined into a ref: a gateway refuses the joined id, and
|
|
@@ -80,14 +96,16 @@ export function capModelOf(route) {
|
|
|
80
96
|
export function modelAskOf(pinned, ref) {
|
|
81
97
|
return pinned ? { pinned, ...(ref ? { ref } : {}) } : ref;
|
|
82
98
|
}
|
|
83
|
-
export async function adapterRunGate(store, claim, revision, root, shell) {
|
|
99
|
+
export async function adapterRunGate(store, claim, revision, root, shell, mcpServers = []) {
|
|
84
100
|
let current = await storeSettings(store);
|
|
85
101
|
const approvers = await readApprovers(store.settings);
|
|
86
102
|
// A Workspace's paths are in the run's folder: its folder named as a computer names it, for the gate's path checks.
|
|
87
103
|
const folder = typeof root === "string" ? root : COMPUTER_ROOT;
|
|
88
104
|
// Where the run's shell is (run-tools.ts shell): with no computer, a tool no setting names takes the kernel's ruled
|
|
89
|
-
// default (tool-gate.ts defaultPermission): bash asks first, the background tools are refused.
|
|
90
|
-
|
|
105
|
+
// default (tool-gate.ts defaultPermission): bash asks first, the background tools are refused. The run's MCP servers
|
|
106
|
+
// (mcpServersOf its grants), so a harness naming an MCP tool its own way (OpenCode's `<server>_<tool>`) is held to that
|
|
107
|
+
// tool's settings, never to a table tool's of the same shape.
|
|
108
|
+
const gate = runGate({ root: folder, work: folder, ...(shell === undefined ? {} : { computer: shell === "computer" }), mcpServers }, claim.runId, revision, () => current, approvers);
|
|
91
109
|
// The run's learned workflows, once its spec has read them (learn): a learned_workflow call is asked about its MCP nodes.
|
|
92
110
|
let learned = [];
|
|
93
111
|
const decide = async (call, options = {}) => {
|
|
@@ -134,7 +152,14 @@ export async function adapterRunGate(store, claim, revision, root, shell) {
|
|
|
134
152
|
};
|
|
135
153
|
// The revision's tool-call budget (tool-budget.ts), which the adapter loop holds each conversation's calls to.
|
|
136
154
|
const toolCalls = revision.body.maxToolCalls;
|
|
137
|
-
|
|
155
|
+
// A tool's setting now, read from the store as each call's is (SessionIO.permission: Codex's live search, which runs
|
|
156
|
+
// inside a model request, is offered only while it says allow). A read that fails is a deny, never the last good read's
|
|
157
|
+
// allow: a deny saved since may be in what did not read, and no call reaches the gate to say otherwise.
|
|
158
|
+
const permission = async (tool) => {
|
|
159
|
+
current = await storeSettings(store);
|
|
160
|
+
return current.unreadable ? "deny" : gate.policy(tool);
|
|
161
|
+
};
|
|
162
|
+
return Object.assign(decide, { askedAs: (tool) => gate.askedAs(tool), askedFor, permissions, permission, learn: (flows) => void (learned = flows), ...(toolCalls === undefined ? {} : { toolCalls }) });
|
|
138
163
|
}
|
|
139
164
|
/** The server's tool settings from the store now; a read that throws is unread (no value of it said). A workflow's call
|
|
140
165
|
* and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
|
|
@@ -175,7 +200,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
175
200
|
// 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
201
|
// on the claim's Archil disk (archil-claim.ts: its keys from the store's sealed rows, under the runner's seal key, in this
|
|
177
202
|
// claim's memory only); else Mode 1, the run's local folder. The same for the pi and the CLI spec.
|
|
178
|
-
const archilSettings = await loadArchilSettings(deps.store);
|
|
203
|
+
const archilSettings = await loadArchilSettings(deps.store, deps.env);
|
|
179
204
|
const mode = archilSettings === undefined ? 1 : 2;
|
|
180
205
|
const archil = archilSettings === undefined
|
|
181
206
|
? undefined
|
|
@@ -186,7 +211,8 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
186
211
|
// The mint is lazy (archil-claim.ts token(), k2's run-tools.ts): only a mounting computer asks for it, so a Mode 2 run
|
|
187
212
|
// with no computer makes no control-plane call. mountControl (a test's loopback control-plane fake) is spread into the
|
|
188
213
|
// mount, so no test reaches the real control plane. MOUNT_TTL_MS is the credential's safety net (its computer's 24 h bound), not its lifetime.
|
|
189
|
-
|
|
214
|
+
// 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.
|
|
215
|
+
: 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 } : {}) });
|
|
190
216
|
// Each resource is held the moment it exists (spec-holds.ts): a throw after it lets it go.
|
|
191
217
|
holds.hold({ archil });
|
|
192
218
|
// The run's Workspace at the claim: Mode 1 the run's local folder (made here, the server's start made it before); Mode 2
|
|
@@ -199,25 +225,36 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
199
225
|
// per run (uploads.ts copyRunFiles); a copy that fails ends the run failed, saying why.
|
|
200
226
|
if (launch.files?.length)
|
|
201
227
|
await copyRunFiles(deps.data, claim.runId, ws.workspace, launch.files);
|
|
228
|
+
// The pull request's checkout, when the revision asks for one (pr-checkout.ts): the server's own fetch before the first
|
|
229
|
+
// turn, with the GitHub App's read-only token for that one repository (or none); the run is told what it holds, or why
|
|
230
|
+
// there is none. Held from the fetch's start, so the release (after the tools' end) removes it however the claim ends; a
|
|
231
|
+
// person's stop ends the fetch at once (run.stopped).
|
|
232
|
+
const checkout = body.checkout === "pull_request" ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part })) : undefined;
|
|
233
|
+
holds.hold({ checkout });
|
|
202
234
|
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin made at the first claim or read as written, its
|
|
203
235
|
// credentials opened under the server's seal key into this claim's memory, one gateway for the claim. First, before
|
|
204
236
|
// anything the spec would have to let go: a refusal (a pin that cannot be made, a pinned meta tool) ends the run in its
|
|
205
237
|
// words before the session opens. The seal key is the runner's own (deps.sealKey), not re-read from the environment.
|
|
206
|
-
|
|
238
|
+
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor.
|
|
239
|
+
const hold = (values) => cut.hold(values);
|
|
240
|
+
const mcp = await mcpForClaim({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => ws.workspace, 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 } : {}) });
|
|
207
241
|
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
208
242
|
holds.hold({ passed: mcp });
|
|
209
243
|
// The run's computer, from the one shared claim-time function (the CLI spec takes the same): none for a runner place, a
|
|
210
244
|
// Docker container for a sandbox, under the claim's epoch (the one fence). It throws computer_unavailable (nothing made)
|
|
211
245
|
// when the computer cannot be had: the run fails in its words.
|
|
212
|
-
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,
|
|
246
|
+
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,
|
|
213
247
|
// revokeMount removes the run's Archil mount credential when the computer is released (and if a start fails after a mint);
|
|
214
|
-
// the run's end revokes it too (below), so it goes on every outcome even when no computer is made. Idempotent.
|
|
215
|
-
|
|
248
|
+
// the run's end revokes it too (below), so it goes on every outcome even when no computer is made. Idempotent. What
|
|
249
|
+
// became of the agent's own computer (a persistent setting) is said on the run's timeline.
|
|
250
|
+
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, ...(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) } : {}) });
|
|
216
251
|
// The run's shell is its computer's (600 s) where one mounts its folder; with none, Archil's serverless exec in Mode 2
|
|
217
252
|
// (295 s), and in Mode 1 none at all: no bash family, its folder being one of this server's own (run-tools.ts).
|
|
218
253
|
// A desktop's or a phone's hold (the person's take-over) wraps its ports: a call made while the person holds it waits,
|
|
219
254
|
// and the agent's hand-over (computer_request_handoff) asks the person through it.
|
|
220
255
|
holds.hold({ computer });
|
|
256
|
+
const loopComputer = loopComputerOf(computer.computer, computer.held);
|
|
257
|
+
const heldComputer = heldSpecOf(launch, loopComputer);
|
|
221
258
|
// Under the agent's bash policy, its shell's environment is the policy's too (bash-read-only.ts policyEnv).
|
|
222
259
|
const bashPolicy = bashPolicyOf(body.toolSettings);
|
|
223
260
|
const tools = await runTools(ws.workspace, computer.computer, { mode, context, ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }) });
|
|
@@ -248,17 +285,52 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
248
285
|
// (adapter-loop waitInClaim, the browser's personWait below). It stays out of the session's host tools and REPLAY, so a CLI harness still
|
|
249
286
|
// refuses it (runnable.ts). pi only.
|
|
250
287
|
// - the browser's durable extension, when the run gets one (bindNonHandTools, below, before the session opens).
|
|
251
|
-
|
|
288
|
+
// - pi's code mode, with a desktop or a phone (pi-computer.ts): the `codemode` tool beside the run's own, its scripts
|
|
289
|
+
// with `computer` bound on the run's held port.
|
|
290
|
+
const native = [...(granted.includes(ASK_TOOL) ? [defineExtension({ name: "ask_person", tools: [askPerson] })] : []), ...(tools.computer ? [computerCodemode(tools.computer)] : [])];
|
|
291
|
+
// pi-native tools in the session's own extension (PiAdapterOptions.tools): the subagent tool, pushed below.
|
|
292
|
+
const piTools = [];
|
|
293
|
+
// A run granted subagent (runner/subagent.ts): the model of each of its tiers, the revision's own (modelTiers) else the
|
|
294
|
+
// host's for the tier (AGENT_MODEL_FAST, AGENT_MODEL_STRONG), each on a route of its own (its proxy on the session's
|
|
295
|
+
// booking, adapters/pi.ts tiers). A tier with neither is the agent's own model, as a learned workflow's node of it runs
|
|
296
|
+
// on the run's. A tier no route can be made for here is no failure of the run: a call on it answers why. A tier's model may be another
|
|
297
|
+
// provider's than the run's own, whose key claimSecrets never opened (it scopes the claim's keys to the run's model): so
|
|
298
|
+
// its route reads every model key the server holds (savedModelKeys). Those reach the tier's proxy alone, as its
|
|
299
|
+
// credential, never the run's tools (toolEnv).
|
|
300
|
+
// Each is in tierRoutes under its own key (subagentRoute: never a learned workflow's tier, whose nodes keep their own
|
|
301
|
+
// routes and fallback), on a proxy of its own that names that key on each request, so the cap prices a child's
|
|
302
|
+
// requests as that route books them.
|
|
303
|
+
const tierWhy = new Map();
|
|
304
|
+
if (revision.kind === "agentic" && granted.includes(SUBAGENT_TOOL)) {
|
|
305
|
+
const savedKeys = await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env });
|
|
306
|
+
holdClaimed(cut, savedKeys);
|
|
307
|
+
const tierEnv = withModelKeys(deps.env, { ...savedKeys, ...toolEnv });
|
|
308
|
+
for (const tier of SUBAGENT_TIERS) {
|
|
309
|
+
if (body.modelTiers?.[tier] === undefined && tierModelOf(tierEnv, tier) === undefined)
|
|
310
|
+
continue;
|
|
311
|
+
try {
|
|
312
|
+
tierRoutes.set(subagentRoute(tier), await deps.routeOf(body.modelTiers?.[tier], tierEnv, tier, PI_WIRES, undefined, cut));
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
tierWhy.set(tier, cut(error instanceof Error ? error.message : String(error)));
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
252
319
|
const adapter = piAdapter({
|
|
253
320
|
run,
|
|
254
321
|
// Read when the session opens (pi.ts), so the browser's extension pushed by bindNonHandTools below is in it.
|
|
255
322
|
extensions: native,
|
|
323
|
+
tools: piTools,
|
|
256
324
|
model: route.model,
|
|
257
325
|
provider: route.provider,
|
|
258
326
|
redact: cut,
|
|
259
327
|
...(route.like ? { like: route.like } : {}),
|
|
260
328
|
...(route.price ? { price: route.price } : {}),
|
|
261
329
|
...(route.fetch ? { fetch: route.fetch } : {}),
|
|
330
|
+
// The run's web_search is its provider's hosted search (the launch's plane, as its start resolved it): the session's
|
|
331
|
+
// proxy admits that search's one request (it goes through the session's port: buildToolHost's `search`) and books it
|
|
332
|
+
// with each search it ran.
|
|
333
|
+
...(launch.plane?.web_search === "native" ? { webSearch: true } : {}),
|
|
262
334
|
tiers: tierRoutes,
|
|
263
335
|
});
|
|
264
336
|
// The gate before a call's intent: the run's revision's tool settings through runGate (approvals "never" turns the one
|
|
@@ -267,7 +339,12 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
267
339
|
const root = runFolder(deps.data, runRow.agentId, claim.runId);
|
|
268
340
|
// The gate names the run's folder by its Workspace (Mode 2: its folder on the run's disk, never this machine's folder at
|
|
269
341
|
// the same path), for its path checks; it reads nothing in it.
|
|
270
|
-
const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell);
|
|
342
|
+
const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, mcpServersOf(granted));
|
|
343
|
+
// What a script's shell and files are held to: this gate, so a denied bash or write holds inside computer_script and codemode.
|
|
344
|
+
tools.computer?.guard.install(async (tool, args) => {
|
|
345
|
+
await gate.permissions.refresh();
|
|
346
|
+
return gate.permissions.decide(tool, args);
|
|
347
|
+
});
|
|
271
348
|
// The run's one cap, as the loop's runCap reads it (adapter-loop.ts RunCapConfig): the launch's cap figure (undefined
|
|
272
349
|
// uncapped — every paid request still books through the one cap), the run's model priced WITH tiers, strict where the
|
|
273
350
|
// launch says. The loop builds the kernel runCap from these over the run's own sessions (its model requests, its paid
|
|
@@ -276,6 +353,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
276
353
|
const capModel = capModelOf(route);
|
|
277
354
|
// And each tier's model (tierRoutes, filled below), by the route its request names (its tier's proxy, ModelRequest.route),
|
|
278
355
|
// priced as that route books it: one id the run's model and a tier share is priced apart, never at the other's price.
|
|
356
|
+
const besideOf = spentBesideOf(launch, deps.store, claim.runId);
|
|
279
357
|
const runCap = {
|
|
280
358
|
capUsd: () => launch.maxCostUsd,
|
|
281
359
|
modelOf: (id, by) => {
|
|
@@ -285,6 +363,8 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
285
363
|
return tierRoute && tierRoute.model === id ? capModelOf(tierRoute) : undefined;
|
|
286
364
|
},
|
|
287
365
|
...(launch.capMode === "strict" ? { mode: "strict" } : {}),
|
|
366
|
+
// What its learning runs' grades took beside it, read by every gate with its own sessions (none: it queues none).
|
|
367
|
+
...(besideOf ? { beside: besideOf } : {}),
|
|
288
368
|
};
|
|
289
369
|
// The run's cap figure and what a refusal does to it (parkOf, with the kernel's raise rule): present only when the run
|
|
290
370
|
// has a cap. A park names the cap the loop holds the run to then (a raise's, else this one).
|
|
@@ -323,6 +403,8 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
323
403
|
own: Object.keys(revisionRow.skills ?? {}),
|
|
324
404
|
shown: async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true }),
|
|
325
405
|
log,
|
|
406
|
+
...(start.notesOnly ? { workflows: false } : {}),
|
|
407
|
+
...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
|
|
326
408
|
})
|
|
327
409
|
: undefined;
|
|
328
410
|
// The decision keys its learned workflows' typed questions need (claim-secrets.ts learnedDecisionKeys), read once the lay
|
|
@@ -365,10 +447,10 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
365
447
|
const handTools = tools.hostTools(withKindTools(granted, tools), results);
|
|
366
448
|
// The non-hand tools run on the claim's keys (host.env), so a vendor's error may echo one: each answer, and a throw's
|
|
367
449
|
// words, pass the run's one redactor before the harness, the model or the record has them.
|
|
368
|
-
const tiers = new Map([...[...tierRoutes].map(([tier, { model }]) => [tier, { model }]), ...[...tierUnreachable].map(([tier, why]) => [tier, { why }])]);
|
|
450
|
+
const tiers = new Map([...[...tierRoutes].filter(([tier]) => !isSubagentRoute(tier)).map(([tier, { model }]) => [tier, { model }]), ...[...tierUnreachable].map(([tier, why]) => [tier, { why }])]);
|
|
369
451
|
// The gate asks a learned_workflow call about its workflow's MCP nodes (adapterRunGate).
|
|
370
452
|
gate.learn(workflows);
|
|
371
|
-
const nonHandTools = (await bindNonHandTools(host, revision.kind, granted, run, context, results, root, launch.plane, workflows, native, gate.permissions, tiers, mcp)).map((tool) => answersCut(tool, cut));
|
|
453
|
+
const nonHandTools = (await bindNonHandTools(host, revision.kind, granted, run, context, results, root, launch.plane, workflows, native, gate.permissions, tiers, mcp, () => route.model)).map((tool) => answersCut(tool, cut));
|
|
372
454
|
const sessionTools = [...handTools, ...nonHandTools];
|
|
373
455
|
// The run's system prompt, as main's per-run process builds it (app.ts): the environment line first (environment.ts, as
|
|
374
456
|
// pi installs it before every other section), then the revision's instructions with what the agent learned laid in
|
|
@@ -376,10 +458,35 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
376
458
|
// reads no learning folder), its own skills through skills.ts promptOf, then the effort guidance (the launch's effort,
|
|
377
459
|
// never this process's environment). The one path for every harness.
|
|
378
460
|
// A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
|
|
379
|
-
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section) : (body.instructions ?? "");
|
|
461
|
+
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section, start.use === true) : (body.instructions ?? "");
|
|
380
462
|
const instructions = await promptOf(laid, [...Object.keys(body.skills ?? {}), ...(seedLaid?.skills ?? [])], ws.workspace, { onDemand: readsFiles(granted) });
|
|
381
463
|
const guidance = effortGuidance(launch.effort);
|
|
382
|
-
const system = [environmentLine(), instructions, guidance].filter((line) => Boolean(line));
|
|
464
|
+
const system = [environmentLine(), checkout?.note, instructions, guidance].filter((line) => Boolean(line));
|
|
465
|
+
// The subagent tool, one of the session's own tools (no extension of its own): a child's tools are a subset of the
|
|
466
|
+
// revision's grants (each by its session name: an MCP tool's wire name, the browser's registrations), its model the
|
|
467
|
+
// agent's own or one of the tiers resolved above.
|
|
468
|
+
if (revision.kind === "agentic" && granted.includes(SUBAGENT_TOOL)) {
|
|
469
|
+
const browserNames = native.filter((extension) => extension.name !== "ask_person").flatMap((extension) => (extension.tools ?? []).map((tool) => tool.name));
|
|
470
|
+
piTools.push(subagentTool({
|
|
471
|
+
granted,
|
|
472
|
+
sessionNames: (catalog) => (catalog === BROWSER_TOOL ? browserNames : [wireName(catalog)]),
|
|
473
|
+
tier: (tier) => {
|
|
474
|
+
const why = tierWhy.get(tier);
|
|
475
|
+
if (why !== undefined)
|
|
476
|
+
return { why };
|
|
477
|
+
// A tier with no model of its own (no model_tiers, no AGENT_MODEL_<TIER>): the agent's own model.
|
|
478
|
+
const at = tierRoutes.get(subagentRoute(tier));
|
|
479
|
+
if (!at)
|
|
480
|
+
return { ref: { provider: PORT_PROVIDER, modelId: route.model } };
|
|
481
|
+
// A capped run never sends a request it cannot price: an unpriced tier refuses the call, and the run goes on.
|
|
482
|
+
if (at.unpriced && launch.maxCostUsd !== undefined)
|
|
483
|
+
return { why: `${at.model} has no known price here, so this run's cost cap cannot hold its requests.` };
|
|
484
|
+
return { ref: { provider: tierProvider(subagentRoute(tier)), modelId: at.model } };
|
|
485
|
+
},
|
|
486
|
+
preamble: environmentLine(),
|
|
487
|
+
...(revision.body.maxToolCalls !== undefined ? { toolCalls: revision.body.maxToolCalls } : {}),
|
|
488
|
+
}));
|
|
489
|
+
}
|
|
383
490
|
// The level pi thinks at: the launch's effort (the run's own, else its revision's, else the host's), every level pi's
|
|
384
491
|
// agent takes; none, pi's default.
|
|
385
492
|
const thinking = thinkingLevel(launch.effort);
|
|
@@ -410,6 +517,8 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
410
517
|
signIns: signInReads(deps.store, deps.sealKey),
|
|
411
518
|
handed: runnerSecrets(toolEnv),
|
|
412
519
|
stored: () => storeSecrets(deps.store, deps.sealKey, deps.data),
|
|
520
|
+
// A workflow draft's decision nodes are checked against the host's decision providers, on its keys (LS-07).
|
|
521
|
+
decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, DECISION_PROVIDER_KEYS)) }),
|
|
413
522
|
learningFolder: archil === undefined
|
|
414
523
|
? (agentId) => learningFolderOf(deps.data, agentId)
|
|
415
524
|
: (agentId) => learningWorkspace({ mode: "archil", agentId, archil }),
|
|
@@ -433,18 +542,31 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
433
542
|
// The tool host's install lifecycle (its bindings' onConversation/beforeResume/beforeRelease), run by the adapter loop.
|
|
434
543
|
lifecycle: life,
|
|
435
544
|
agentId: runRow.agentId,
|
|
545
|
+
// The run's computer as the claim made it, with the person's hold on a desktop or phone: the loop shows the hold up,
|
|
546
|
+
// applies a take-over and a hand-back to it, and answers the computer call channel's rows on it.
|
|
547
|
+
...(loopComputer ? { computer: loopComputer } : {}),
|
|
436
548
|
workRoot: root,
|
|
437
549
|
// The end's metrics and cost, from the run's journal, as the old per-run end path read them (metrics.ts runMetrics =
|
|
438
550
|
// runs.ts storedMetrics/costOf). A pi run adds its effort, no model (metrics.ts).
|
|
439
551
|
endPatch: async () => {
|
|
440
|
-
|
|
441
|
-
const
|
|
552
|
+
// The root's entries and every conversation a task of the run owns (a subagent's): a child's requests are the run's.
|
|
553
|
+
const entries = await agentEntriesOf(deps.journal(claim), context);
|
|
554
|
+
const { metrics } = runMetrics(entries, { ...(launch.effort !== undefined ? { effort: launch.effort } : {}) });
|
|
555
|
+
// Its cost is its booking's, as a CLI run's is (metrics.ts bookedSpend, the one reader): every model request its
|
|
556
|
+
// session's proxy booked, pi's own answers and its side calls (a learned workflow's nodes, web_search's hosted search
|
|
557
|
+
// with its fee) alike, and its decisions (a learned workflow's decision nodes, LS-07; one that reported none is
|
|
558
|
+
// unknown, never the cap's hold for it). A request a cancel or a stop cut while it streamed is booked at no known cost
|
|
559
|
+
// (the provider may bill what it streamed), so the run's cost is unknown, never the $0 its cut answer carries.
|
|
560
|
+
const all = (await journalEntries(deps.journal(claim), context));
|
|
442
561
|
// Its paid tool calls (a Parallel search's, a monid call's, a person's browser time), booked on the run's one ledger
|
|
443
|
-
// (
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
return {
|
|
562
|
+
// (each on its cap, in its own session, not on the root), are the run's cost too; any part unknown leaves the run's unknown.
|
|
563
|
+
const total = runEndCost({ model: bookedSpend(all, "model").usd, paid: run.ledger?.paid ? run.ledger.paid.spentUsd() : 0, decisions: bookedSpend(all, "decisions").usd });
|
|
564
|
+
// An unknown cost is written as null, never left out: a follow-up's end clears the cost an earlier end stored.
|
|
565
|
+
return { costUsd: total, metrics };
|
|
447
566
|
},
|
|
567
|
+
// A run started with hold: true holds its computer for its owner (computer-held.ts): the loop waits for their start
|
|
568
|
+
// and release, and runs their calls on it.
|
|
569
|
+
...(heldComputer ? { held: heldComputer } : {}),
|
|
448
570
|
// The pass's resources go once the loop writes nothing more through them: its tools' end (background processes ended,
|
|
449
571
|
// scratch swept), its computer let go, then its Workspace's end (Mode 2 sweeps the exec spill).
|
|
450
572
|
// The run's Archil mount credential is revoked at its end on every outcome, even with no computer (the computer's
|
|
@@ -453,7 +575,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
453
575
|
};
|
|
454
576
|
}
|
|
455
577
|
/** The host-tool ctx a non-hand tool is wrapped with (host-tools.ts hostToolOf): the run's own Harness (its commit,
|
|
456
|
-
* snapshot
|
|
578
|
+
* snapshot and task reads), the results map, and the run's folder as the api env's cwd (a tool reads no
|
|
457
579
|
* file environment, so an error names a path relative to it). Shared by the pi spec's bindNonHandTools and the CLI spec's
|
|
458
580
|
* learned_workflow. */
|
|
459
581
|
export function hostToolCtxOf(run, context, results, root) {
|
|
@@ -463,8 +585,8 @@ export function hostToolCtxOf(run, context, results, root) {
|
|
|
463
585
|
env: async () => ({ cwd: root }),
|
|
464
586
|
commit: (change, at, options) => run.harness.commit(change, at, options),
|
|
465
587
|
snapshot: ((...args) => Reflect.apply(run.harness.snapshot, run.harness, args)),
|
|
466
|
-
|
|
467
|
-
waitForTask: (id, at) => run.harness.waitForTask(id, at),
|
|
588
|
+
// Never on the call's signal (durableWait): an abort while it registers rejects this wait, never one unhandled.
|
|
589
|
+
waitForTask: (id, at) => durableWait((bare) => run.harness.waitForTask(id, bare), at),
|
|
468
590
|
agent: async (at) => {
|
|
469
591
|
const conversation = await run.harness.conversation(ROOT_CONVERSATION_ID, at);
|
|
470
592
|
if (!conversation)
|
|
@@ -537,14 +659,20 @@ export async function learnedWorkflowHostTool(opts) {
|
|
|
537
659
|
throw new Error(`the run's ${tier} model could not be reached: ${model.why}`);
|
|
538
660
|
return { provider: tierProvider(tier), modelId: model.model };
|
|
539
661
|
};
|
|
540
|
-
|
|
662
|
+
// Its decision nodes (LS-07) on the decision providers the run's keys give (decisions.ts decisionProvidersIn over `env`,
|
|
663
|
+
// the claim's own), each booked on the run's one cap (ledger.decisions) and a refusal of it pausing the run
|
|
664
|
+
// (ledger.pause). A run whose keys give none runs no decision node: the check refuses it before any node runs.
|
|
665
|
+
const providers = await decisionProvidersIn(opts.env);
|
|
666
|
+
const decisions = providers ? { decisions: { providers, book: opts.run.ledger.decisions, pause: (refusal) => opts.run.ledger.pause(refusal) } } : {};
|
|
667
|
+
// A call node's native web_search goes through the session's port too, labelled web_search, as the run's own does.
|
|
668
|
+
const tool = learnedWorkflowTool({ workflows: flows, granted: opts.granted, ...(opts.plane ? { plane: opts.plane } : {}), env: opts.env, work: opts.work, models: tieredModels(byProvider), modelOf, search: () => opts.run.ledger.models(WEB_SEARCH_TOOL), policy: opts.permissions.policy, denyFrom: opts.permissions.denyFrom, refresh: opts.permissions.refresh, decide: opts.permissions.decide, mcpTools, ...decisions, ...(opts.workspace ? { workspace: opts.workspace } : {}), ...(opts.modelName ? { modelName: opts.modelName } : {}) });
|
|
541
669
|
return hostToolOf(LEARNED_WORKFLOW_TOOL, tool, opts.ctx) ?? undefined;
|
|
542
670
|
}
|
|
543
671
|
/** The run's non-hand tools as HostTool[], bound through the ToolHost seam and wrapped as the hands are (host-tools.ts
|
|
544
672
|
* hostToolOf): web_fetch, web_search and monid, each by its catalog name under the adapter loop's one gate (`spec.gate`;
|
|
545
673
|
* `gated` is undefined here, as for the hands). Their paid requests are booked by the adapter loop on the run's one ledger
|
|
546
674
|
* (bookedIn), as main books them, so they run. The browser (through host.liveViewers), MCP (the MCP claim step's
|
|
547
|
-
* mcpForClaim(claim, store, sealKey, pin) -> { sessionMcp,
|
|
675
|
+
* mcpForClaim(claim, store, sealKey, pin) -> { sessionMcp, release }), the learned workflow and decisions are
|
|
548
676
|
* each a named todo, added as their seams land. */
|
|
549
677
|
/** The run's live-viewer writers over the store (browser-live.ts): a session's hand-over written sealed, and gone. Its
|
|
550
678
|
* viewer token, minted in the run, is held by `cut`, the run's one redactor, as it is handed over, before it is written. */
|
|
@@ -585,6 +713,7 @@ export function answersCut(tool, cut) {
|
|
|
585
713
|
* session's viewer over through (the store, never files), and the run's own Workspace (`workspace`: in Mode 2 its folder
|
|
586
714
|
* on the run's disk), where a tool files what the run's read finds later. */
|
|
587
715
|
export function buildToolHost(opts) {
|
|
716
|
+
const liveAt = runnerLiveOf(opts.env, opts.sealKey);
|
|
588
717
|
const { root, claim, run, life } = opts;
|
|
589
718
|
return {
|
|
590
719
|
// The run's directory and its per-claim environment: the hands come from runTools, so the non-hand tools get the run's
|
|
@@ -605,9 +734,14 @@ export function buildToolHost(opts) {
|
|
|
605
734
|
// browser holds and settles its calls here (host.ledger.paid), never on this process's own spend, and a refusal at the
|
|
606
735
|
// cap parks the run (pause). browserListed reads it to fail closed.
|
|
607
736
|
ledger: run.ledger,
|
|
737
|
+
// A native web_search's models: the session's port under a side key labelled web_search, so the search request goes
|
|
738
|
+
// through the run's one route (its proxy, policy, key, price and cap), this run's alone (#2458).
|
|
739
|
+
search: () => run.ledger.models(WEB_SEARCH_TOOL),
|
|
608
740
|
// The run's one redactor: the browser's answers pass it inside their call, before pi stores them (tools.ts).
|
|
609
741
|
redact: opts.redact,
|
|
610
742
|
liveViewers: liveViewersOf(opts.store, opts.sealKey, claim, opts.redact),
|
|
743
|
+
// A runner on another host than its server (AGENTRUN_RUNNER_LIVE_HOST): its browser's viewer answers there.
|
|
744
|
+
...(liveAt ? { liveAt } : {}),
|
|
611
745
|
// What a tool files for the run's read (monid's whole answer past the model's cut) goes in the run's own Workspace, the
|
|
612
746
|
// one its hands read: in Mode 2 its folder on the run's disk, never the local folder at `root`.
|
|
613
747
|
workspace: opts.workspace,
|
|
@@ -634,7 +768,7 @@ export async function webHostTools(host, granted, ctx) {
|
|
|
634
768
|
}
|
|
635
769
|
return tools;
|
|
636
770
|
}
|
|
637
|
-
async function bindNonHandTools(host, kind, granted, run, context, results, root, plane, workflows, native, permissions, tiers, mcp) {
|
|
771
|
+
async function bindNonHandTools(host, kind, granted, run, context, results, root, plane, workflows, native, permissions, tiers, mcp, modelName) {
|
|
638
772
|
// Fail closed (browserListed): the browser binds only on the native route (BROWSER_ON_RUNNER) and with the claim's
|
|
639
773
|
// one-ledger booking on its ToolHost (host.ledger.paid); otherwise its extension is not installed. learned_workflow
|
|
640
774
|
// binds below with no web tool, so a learned run with no web tool still lists it.
|
|
@@ -647,7 +781,7 @@ async function bindNonHandTools(host, kind, granted, run, context, results, root
|
|
|
647
781
|
// the session's tools the harness is told of: its model nodes run on the session's proxied models (run.ledger.models),
|
|
648
782
|
// each a request on the run's one route labelled learned_workflow. The agent's scoped keys (host.env) are its call
|
|
649
783
|
// nodes'.
|
|
650
|
-
const learned = await learnedWorkflowHostTool({ run, kind, granted, plane, env: host.env, work: root, workflows, permissions, ctx, tiers, ...(mcp ? { mcp } : {}) });
|
|
784
|
+
const learned = await learnedWorkflowHostTool({ run, kind, granted, plane, env: host.env, work: root, workflows, permissions, ctx, tiers, ...(mcp ? { mcp } : {}), ...(host.workspace ? { workspace: host.workspace } : {}), ...(modelName ? { modelName } : {}) });
|
|
651
785
|
if (learned)
|
|
652
786
|
tools.push(learned);
|
|
653
787
|
// The browser (tl-browser), on pi's native route: tools.ts's own binding on this run's ToolHost (its store, claim and seal
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Extension } from "@earendil-works/pi-durable";
|
|
2
|
+
import { type ScriptComputer } from "../../workspace/index.js";
|
|
3
|
+
/** The code mode tool's name, as the model calls it and the gate reads it. */
|
|
4
|
+
export declare const PI_CODEMODE_TOOL = "codemode";
|
|
5
|
+
/** pi's code mode extension with `computer` bound to `computer`'s surface: install it among the run's pi-native
|
|
6
|
+
* extensions (PiAdapterOptions.extensions). No `models.*` in scripts: a script's paid work is the run's own tools. */
|
|
7
|
+
export declare function computerCodemode(computer: ScriptComputer): Extension;
|