@parcha/agentrun-serve 0.1.0-beta.36 → 0.1.0-beta.38
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 +452 -0
- package/README.md +311 -142
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +39 -14
- package/dist/answer-json.d.ts +34 -1
- package/dist/answer-json.js +91 -9
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- 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/browser-cost.d.ts +1 -1
- package/dist/browser-cost.js +52 -93
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/cap.d.ts +0 -407
- package/dist/cap.js +4 -1028
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +4 -34
- package/dist/cli.js +13 -4
- package/dist/composio-preset.d.ts +53 -0
- package/dist/composio-preset.js +221 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +60 -0
- package/dist/computer-calls.js +209 -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 +165 -0
- package/dist/computer-live.js +655 -0
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +14 -0
- package/dist/computer-view.js +51 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +311 -0
- package/dist/computers.d.ts +37 -8
- package/dist/computers.js +62 -14
- package/dist/console/assets/index-CjqQirbo.css +1 -0
- package/dist/console/assets/index-b6-XY5A9.js +576 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +3 -0
- package/dist/decisions.js +4 -0
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +56 -26
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/graph-view.d.ts +1 -1
- package/dist/harness-opencode/adapter.js +7 -3
- package/dist/harness-opencode/facts.js +0 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -5
- package/dist/harness-opencode/host/policy.js +8 -32
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +0 -2
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +35 -1
- package/dist/host-tools.d.ts +2 -6
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +5 -6
- package/dist/hosted-search.js +2 -28
- 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/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +10 -2
- package/dist/learn/check.js +13 -5
- package/dist/learn/commit.d.ts +14 -2
- package/dist/learn/commit.js +23 -9
- package/dist/learn/compile.d.ts +243 -0
- package/dist/learn/compile.js +471 -0
- package/dist/learn/folder.d.ts +6 -0
- package/dist/learn/folder.js +4 -1
- package/dist/learn/general.d.ts +69 -0
- package/dist/learn/general.js +75 -0
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +29 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +253 -0
- package/dist/learn/promote.js +428 -0
- package/dist/learn/refit.d.ts +39 -0
- package/dist/learn/refit.js +236 -0
- package/dist/learn/reflect.d.ts +9 -20
- package/dist/learn/reflect.js +18 -125
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +50 -14
- package/dist/learn/skills.js +183 -47
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +50 -2
- package/dist/learned-nodes.js +41 -2
- package/dist/learned-workflow.d.ts +43 -3
- package/dist/learned-workflow.js +170 -28
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-cost.d.ts +18 -6
- package/dist/learning-cost.js +15 -7
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +37 -2
- package/dist/learning-routes.js +52 -8
- package/dist/learning-words.d.ts +13 -0
- package/dist/learning-words.js +13 -0
- package/dist/learning.d.ts +55 -17
- package/dist/learning.js +91 -48
- 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/llm.js +0 -3
- package/dist/mcp-gateway.d.ts +21 -20
- package/dist/mcp-gateway.js +76 -55
- package/dist/mcp-oauth.d.ts +62 -7
- package/dist/mcp-oauth.js +134 -19
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +107 -0
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +27 -11
- package/dist/mcp-probe.js +60 -42
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +115 -25
- package/dist/mcp-servers-store.js +241 -43
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +21 -4
- package/dist/mcp-store.js +33 -8
- package/dist/mcp-wire.d.ts +22 -0
- package/dist/mcp-wire.js +36 -0
- package/dist/mcp.js +3 -3
- package/dist/meta-tool-names.d.ts +1 -0
- package/dist/meta-tool-names.js +3 -0
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.d.ts +13 -0
- package/dist/model.js +69 -25
- package/dist/monid.d.ts +51 -25
- package/dist/monid.js +226 -140
- package/dist/openapi.js +694 -59
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +26 -29
- package/dist/paid-calls.js +46 -102
- package/dist/place-offers.d.ts +2 -3
- package/dist/place-offers.js +3 -7
- package/dist/place.js +1 -2
- package/dist/print.d.ts +15 -1
- package/dist/print.js +14 -3
- package/dist/propose.d.ts +10 -1
- package/dist/propose.js +30 -10
- package/dist/provider.js +12 -4
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +3 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +27 -2
- package/dist/run-launch.js +15 -4
- package/dist/run-learning-served.d.ts +13 -2
- package/dist/run-manifest.d.ts +5 -0
- package/dist/run-manifest.js +20 -0
- 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 +2 -3
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +5 -2
- package/dist/run-view.d.ts +19 -8
- package/dist/run-view.js +62 -26
- package/dist/runnable.d.ts +0 -3
- package/dist/runnable.js +37 -29
- package/dist/runner/adapter-loop.d.ts +47 -17
- package/dist/runner/adapter-loop.js +1427 -303
- package/dist/runner/adapter-run-spec.d.ts +23 -9
- package/dist/runner/adapter-run-spec.js +162 -56
- package/dist/runner/adapters/pi-computer.d.ts +9 -0
- package/dist/runner/adapters/pi-computer.js +51 -0
- package/dist/runner/adapters/pi.d.ts +25 -11
- package/dist/runner/adapters/pi.js +168 -45
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +21 -11
- 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 +20 -3
- package/dist/runner/cli-run-spec.js +174 -64
- package/dist/runner/commands.d.ts +3 -1
- package/dist/runner/commands.js +28 -3
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +62 -0
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +224 -17
- package/dist/runner/conformance/subject.d.ts +12 -5
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +23 -12
- package/dist/runner/end-of-run.js +41 -16
- package/dist/runner/feedback-round.d.ts +52 -0
- package/dist/runner/feedback-round.js +79 -0
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +4 -2
- package/dist/runner/harness-loops.js +15 -1
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +44 -7
- package/dist/runner/journal-kinds.js +29 -0
- 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 +69 -13
- package/dist/runner/learning-end.js +340 -87
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +11 -5
- package/dist/runner/learning-loop.d.ts +86 -8
- package/dist/runner/learning-loop.js +178 -23
- package/dist/runner/learning-seed.d.ts +11 -0
- package/dist/runner/learning-seed.js +27 -0
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +26 -3
- package/dist/runner/loop.d.ts +21 -2
- package/dist/runner/loop.js +23 -2
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +27 -5
- package/dist/runner/mcp-claim.d.ts +15 -8
- package/dist/runner/mcp-claim.js +176 -71
- package/dist/runner/mcp-github.js +1 -1
- package/dist/runner/mcp-run.d.ts +21 -57
- package/dist/runner/mcp-run.js +25 -85
- package/dist/runner/meta-tools.d.ts +37 -0
- package/dist/runner/meta-tools.js +268 -0
- package/dist/runner/metrics.d.ts +11 -2
- package/dist/runner/metrics.js +26 -5
- package/dist/runner/model-route.js +12 -3
- package/dist/runner/monid-run.d.ts +16 -0
- package/dist/runner/monid-run.js +96 -0
- package/dist/runner/pr-checkout.d.ts +1 -0
- package/dist/runner/pr-checkout.js +1 -1
- package/dist/runner/promotion.d.ts +80 -0
- package/dist/runner/promotion.js +562 -0
- package/dist/runner/reflect-hook.d.ts +46 -13
- package/dist/runner/reflect-hook.js +149 -48
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +208 -17
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +9 -4
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-port.d.ts +4 -2
- package/dist/runner/store-secrets.js +4 -3
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +10 -13
- package/dist/runner/workflow-first.d.ts +216 -0
- package/dist/runner/workflow-first.js +303 -0
- package/dist/runner/workflow-host.d.ts +6 -1
- package/dist/runner/workflow-host.js +1 -1
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +15 -2
- package/dist/runner/workflow-spec.js +63 -23
- package/dist/runs-over-store.d.ts +17 -3
- package/dist/runs-over-store.js +59 -20
- 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/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 +119 -18
- package/dist/server.js +841 -202
- package/dist/settings-wake.d.ts +23 -0
- package/dist/settings-wake.js +65 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/command-wake.d.ts +13 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +13 -5
- package/dist/store/postgres/connection.js +3 -1
- package/dist/store/postgres/dialect.js +4 -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/postgres/migrations/0010_imported_templates.sql +18 -0
- package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
- package/dist/store/schema.d.ts +10 -1
- package/dist/store/schema.js +104 -15
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.d.ts +7 -5
- package/dist/store/sqlite/run-patch.js +45 -18
- package/dist/store/sqlite/store.js +331 -72
- package/dist/store/store.d.ts +312 -21
- package/dist/store/store.js +12 -1
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +8 -1
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +1 -1
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +30 -5
- package/dist/store-reads/journal.js +128 -56
- package/dist/store-reads/learning.d.ts +114 -12
- package/dist/store-reads/learning.js +238 -48
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +1 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +6 -0
- package/dist/store-view.js +59 -26
- package/dist/template-eval.d.ts +18 -9
- package/dist/template-eval.js +95 -68
- package/dist/template-github-permissions.d.ts +24 -10
- package/dist/template-github-permissions.js +36 -15
- package/dist/template-import.d.ts +31 -0
- package/dist/template-import.js +121 -0
- package/dist/template-source.d.ts +51 -0
- package/dist/template-source.js +371 -0
- package/dist/templates.d.ts +218 -46
- package/dist/templates.js +493 -181
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +4 -3
- package/dist/timeline/index.js +4 -3
- package/dist/timeline/labels.d.ts +6 -2
- package/dist/timeline/labels.js +93 -2
- package/dist/timeline/origin.d.ts +19 -5
- package/dist/timeline/origin.js +11 -4
- package/dist/timeline/timeline.d.ts +22 -1
- package/dist/timeline/timeline.js +34 -18
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-gate.d.ts +84 -50
- package/dist/tool-gate.js +179 -101
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +26 -0
- package/dist/tool-list.js +43 -0
- package/dist/tool-names.d.ts +71 -0
- package/dist/tool-names.js +99 -0
- package/dist/tool-plane.d.ts +33 -27
- package/dist/tool-plane.js +72 -39
- package/dist/tools.d.ts +32 -7
- package/dist/tools.js +37 -24
- 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 +25 -6
- package/dist/trigger-signatures.js +41 -7
- 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 +7 -3
- package/dist/triggers.js +35 -5
- package/dist/turns.js +16 -1
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +102 -45
- package/dist/web-fetch.d.ts +2 -8
- package/dist/web-fetch.js +2 -22
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +145 -102
- package/dist/webhooks.js +559 -322
- package/dist/workflow/decisions.d.ts +1 -1
- package/dist/workflow/node-runner.d.ts +2 -1
- package/dist/workflow/node.d.ts +2 -1
- package/dist/workflow/node.js +3 -1
- package/dist/workflow/pi-versions.d.ts +23 -0
- package/dist/workflow/pi-versions.js +57 -0
- package/dist/workflow/record-tool.d.ts +2 -1
- package/dist/workflow/store.d.ts +1 -1
- package/dist/workflow/task.js +3 -2
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +19 -9
- package/dist/workspace/computer-deps.js +24 -9
- package/dist/workspace/computer-for-claim.d.ts +23 -8
- package/dist/workspace/computer-for-claim.js +92 -33
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +41 -55
- package/dist/workspace/computer-ledger.d.ts +3 -1
- package/dist/workspace/computer-ledger.js +4 -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 +53 -0
- package/dist/workspace/computer-script.js +172 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +4 -2
- package/dist/workspace/index.js +3 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +132 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +104 -85
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +24 -1
- package/dist/workspace/resolve-computer.js +40 -16
- package/dist/workspace/run-tools.d.ts +56 -21
- package/dist/workspace/run-tools.js +55 -34
- package/dist/wrap-up.d.ts +21 -0
- package/dist/wrap-up.js +21 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +19 -16
- package/templates/README.md +111 -45
- package/templates/code-review/agent.md +30 -14
- package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
- package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
- package/templates/code-review/evals/injection/case.yaml +2 -1
- package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
- package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
- package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
- package/templates/code-review/evals/never-flag/case.yaml +2 -1
- package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
- package/templates/code-review/evals/null-name/case.yaml +2 -1
- package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/case.yaml +2 -1
- package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/case.yaml +16 -0
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
- package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/code-review/evals/other-repo/prompt.md +10 -0
- package/templates/code-review/evals/re-review/case.yaml +2 -1
- package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
- package/templates/code-review/evals/re-review-open/case.yaml +2 -1
- package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
- package/templates/code-review/evals/repo-rule/case.yaml +2 -1
- package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
- package/templates/code-review/evals/two-defects/case.yaml +2 -1
- package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
- package/templates/code-review/rules/CODEREVIEW.md +1 -1
- package/templates/code-review/skills/review/DEEP.md +3 -2
- package/templates/code-review/skills/review/REVIEWER.md +3 -2
- package/templates/code-review/skills/review/SKILL.md +4 -3
- package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
- package/templates/inbound-lead/agent.md +26 -16
- package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
- package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
- package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
- package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
- package/templates/kyb/agent.md +15 -5
- package/templates/kyb/evals/adverse-media/prompt.md +2 -7
- package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
- package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
- package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
- package/templates/kyb/evals/name-collision/prompt.md +2 -6
- package/templates/kyb/evals/no-invention/prompt.md +2 -6
- package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
- package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
- package/templates/kyb/kyb.schema.json +8 -7
- package/templates/kyb/skills/kyb/SKILL.md +9 -6
- package/templates/market-monitor/agent.md +19 -12
- package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +32 -10
- package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/learned-style/case.yaml +2 -1
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
- package/templates/release-notes/evals/other-repo/case.yaml +24 -0
- package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
- package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
- package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/release-notes/evals/other-repo/prompt.md +32 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
- package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
- package/templates/release-notes/notes.schema.json +1 -1
- package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
- package/dist/console/assets/index-BI4Byidu.js +0 -550
- package/dist/console/assets/index-C19gUF2n.css +0 -1
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -26
- package/dist/tool-budget.js +0 -56
- package/dist/workflow/readers.d.ts +0 -36
- package/dist/workflow/readers.js +0 -145
- package/dist/workflow/wal.d.ts +0 -11
- package/dist/workflow/wal.js +0 -106
- package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
- package/templates/code-review/evals/injection/graders/schema.md +0 -5
- package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
- package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
- package/templates/code-review/evals/null-name/graders/schema.md +0 -5
- package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
- package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
- package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
- package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
- package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
- package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
- package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
- package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
- package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
- package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
- package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
|
@@ -73,7 +73,12 @@ export async function learnedDecisionKeys(deps, workflows, allowed) {
|
|
|
73
73
|
for (const id of providersNamed(nodes))
|
|
74
74
|
named.add(id);
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
return hostDecisionKeys(deps, [...named].filter((id) => allowed(id)));
|
|
77
|
+
}
|
|
78
|
+
/** The host's keys of the decision providers `providers` (bare ids), read as claimSecrets reads its keys and scoped by
|
|
79
|
+
* decisionKeysFor; none for none. learnedDecisionKeys hands them to a run; a learning end (LS-07) builds its check's
|
|
80
|
+
* providers on them, host-side, never handed to the run. A fresh object per call. */
|
|
81
|
+
export async function hostDecisionKeys(deps, providers) {
|
|
77
82
|
if (!providers.length)
|
|
78
83
|
return {};
|
|
79
84
|
return decisionKeysFor(await workingEnv(deps), { providers, parallelWeb: false });
|
|
@@ -9,6 +9,18 @@ export type { ClaimComputer, ClaimDeps, ClaimLaunch, ComputerForClaim } from "./
|
|
|
9
9
|
export type CliSpecDeps = AdapterSpecDeps;
|
|
10
10
|
/** What a CLI harness refuses of an agent's computer, in words: a browser, which only pi's browser tool drives. */
|
|
11
11
|
export declare const cliRefusesKind: (kind: string) => string | undefined;
|
|
12
|
+
/** A CLI run's environment: the runner's run environment (`env`, runner/main.ts runEnv), built from it itself and never
|
|
13
|
+
* a spread of it, with the model keys the claim opened (`claimed`, withModelKeys) and the server's data directory named
|
|
14
|
+
* (DATA_ENV). The run environment's secrets, and the keys added, are readable by name and never enumerable: the
|
|
15
|
+
* harness's model route finds the key its requests carry (model.ts, `env[row.field]`) while a program spawned with this
|
|
16
|
+
* environment carries none. A spread would drop every secret the launcher handed the runner, and the route would send no
|
|
17
|
+
* key. The data directory is a plain variable, which a spawn carries. So is the run's resolved tool plane (`plane`,
|
|
18
|
+
* TOOL_PLANE_ENV, not a secret), as main hands its per-run process: the adapter reads web_search's there (adapters.ts
|
|
19
|
+
* nativeOptions: claude-agent's WebSearch, codex's live search, admitted by its proxy's policy and priced with it), so a
|
|
20
|
+
* run whose plane resolves it to native gets the harness's own search (#2458), this run's alone; whatever the runner's
|
|
21
|
+
* own environment says of a plane is never the run's. Whether each search runs is the tool's setting at that search
|
|
22
|
+
* (SessionIO.permission, the gate), never this plane, which is frozen when the run is made. */
|
|
23
|
+
export declare function cliRunEnv(env: NodeJS.ProcessEnv | undefined, data: string, claimed?: NodeJS.ProcessEnv, plane?: RunLaunch["plane"]): NodeJS.ProcessEnv;
|
|
12
24
|
/** `tools` in the order the agent grants them (`granted`, catalog names; a tool is listed by its catalog name's wire
|
|
13
25
|
* name), as main listed a CLI run's tools to its harness: each granted tool where its grant is, and a tool the grant
|
|
14
26
|
* does not name (one a granted tool or the run's computer brings beside it) right after the tool listed before it. Ties
|
|
@@ -16,9 +28,14 @@ export declare const cliRefusesKind: (kind: string) => string | undefined;
|
|
|
16
28
|
export declare function inGrantOrder<T extends {
|
|
17
29
|
readonly name: string;
|
|
18
30
|
}>(tools: readonly T[], granted: readonly string[]): T[];
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
|
|
31
|
+
/** Every earlier claim's private folder of the run (`<harnesses>/<n>`, n below `epoch`) removed: what a claim whose runner
|
|
32
|
+
* 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
|
|
33
|
+
* next claim's while this one lets go late) is never touched. Each removal is whole or is finished by the next sweep. */
|
|
34
|
+
export declare function sweepEarlier(harnesses: string, epoch: number): Promise<void>;
|
|
35
|
+
/** A claim's end: every earlier claim's folder of the run (sweepEarlier) and the claim's own (`<harnesses>/<epoch>`)
|
|
36
|
+
* removed, then each of `parents` in order while it is empty: one another claim of the run has laid things in since (a
|
|
37
|
+
* follow-up's) stays, with what is in it. Run again over what a cut-off sweep left, it finishes it. */
|
|
38
|
+
export declare function sweepScratch(harnesses: string, epoch: number, parents: readonly string[]): Promise<void>;
|
|
22
39
|
/**
|
|
23
40
|
* One claimed CLI run's AdapterRunSpec, built from its launch record and its revision.
|
|
24
41
|
*
|
|
@@ -13,8 +13,8 @@
|
|
|
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";
|
|
@@ -22,45 +22,55 @@ import { confineOf, noNewPrivsPrefix, standsIn, thinkingFor } from "../adapters.
|
|
|
22
22
|
import { claimSettled, installDirOf, installForClaim, installingWords } from "../harness-install.js";
|
|
23
23
|
import { HarnessUnavailable } from "../provider.js";
|
|
24
24
|
import { effortGuidance } from "../effort-guidance.js";
|
|
25
|
+
import { outputContract } from "../answer-json.js";
|
|
25
26
|
import { wireName } from "../catalog.js";
|
|
26
27
|
import { environmentLine } from "../environment.js";
|
|
27
28
|
import { harnessOf } from "../harness-table.js";
|
|
28
29
|
import { laidLearned, learningFolderOf, secretsShown } from "../learning.js";
|
|
29
30
|
import { laidOf, layLearningSeed } from "./learning-seed.js";
|
|
30
31
|
import { learningWorkspace } from "../learn/folder.js";
|
|
31
|
-
import { learningEndOfRun } from "./learning-end.js";
|
|
32
|
+
import { learningEndOfRun, spentBesideOf } from "./learning-end.js";
|
|
32
33
|
import { providerModels, runModels } from "../model.js";
|
|
33
|
-
import { firstMessage } from "../run-manifest.js";
|
|
34
|
+
import { firstMessage, inputMessage } from "../run-manifest.js";
|
|
34
35
|
import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
35
36
|
import { readsFiles, systemOf } from "../skills.js";
|
|
36
37
|
import { DATA_ENV } from "../server-fs.js";
|
|
37
38
|
import { copyRunFiles } from "../uploads.js";
|
|
38
|
-
import { isObject } from "../validate.js";
|
|
39
39
|
import { runFolder, scratchFolder } from "../workspace/paths.js";
|
|
40
40
|
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
41
41
|
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 { computerReadyWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
45
|
+
import { computerReadyWords, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
46
46
|
import { hostLifecycle } from "./adapter-loop.js";
|
|
47
|
-
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, modelAskOf, PI_WIRES, webHostTools
|
|
47
|
+
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, modelAskOf, PI_WIRES, webHostTools } from "./adapter-run-spec.js";
|
|
48
48
|
import { openTierProxies } from "./adapters/pi.js";
|
|
49
49
|
import { signInReads } from "../sign-ins-store.js";
|
|
50
50
|
import { mcpServersOf } from "../tool-gate.js";
|
|
51
|
-
import {
|
|
51
|
+
import { isWebHostTool } from "../tool-list.js";
|
|
52
|
+
import { hostToolOf } from "../host-tools.js";
|
|
53
|
+
import { ASK_TOOL, askPerson } from "../tools.js";
|
|
54
|
+
import { claimSecrets, hostDecisionKeys, learnedDecisionKeys, tierModelKeys, withModelKeys } from "./claim-secrets.js";
|
|
52
55
|
import { mcpForClaim } from "./mcp-run.js";
|
|
53
|
-
import { TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
56
|
+
import { DECISION_PROVIDER_KEYS, TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
57
|
+
import { decisionProvidersIn } from "../decisions.js";
|
|
54
58
|
import { resolveHarness } from "./adapters/index.js";
|
|
55
59
|
import { entriesOf } from "./loop.js";
|
|
56
|
-
import { bookedSpend, cliModelWorked, cliRunMetrics } from "./metrics.js";
|
|
60
|
+
import { bookedSpend, cliModelWorked, cliRunMetrics, runEndCost } from "./metrics.js";
|
|
57
61
|
import { journalEntries } from "./journal-reader.js";
|
|
62
|
+
import { claimPromotion, promotionGate, replayCallsFor, replayClaimed, replayLaid } from "./promotion.js";
|
|
63
|
+
import { laidFor, pathMetrics, workflowFirstOf } from "./workflow-first.js";
|
|
64
|
+
import { pastRunsOverStore, runPathOverStore } from "../store-reads/learning.js";
|
|
58
65
|
import { specBuilt } from "./spec-holds.js";
|
|
59
66
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
67
|
+
import { heldSpecOf } from "./held-run.js";
|
|
68
|
+
import { loopComputerOf } from "./computer-channel.js";
|
|
60
69
|
import { githubAppAccess } from "./github-app.js";
|
|
61
70
|
import { prCheckoutForClaim } from "./pr-checkout.js";
|
|
62
71
|
import { holdStored, storeSecrets } from "./store-secrets.js";
|
|
63
72
|
import { bashPolicyOf } from "../bash-read-only.js";
|
|
73
|
+
import { monidForClaim, withMonid } from "./monid-run.js";
|
|
64
74
|
/** What a CLI harness refuses of an agent's computer, in words: a browser, which only pi's browser tool drives. */
|
|
65
75
|
export const cliRefusesKind = (kind) => kind === "browser" ? "This agent's computer is a browser, which only the pi harness drives here: pick pi for this agent, or another kind of computer in Settings → Computers." : undefined;
|
|
66
76
|
/** The run's model and the catalog that prices it, as main chooses a CLI run's (app.ts wireModels and runModels): on the
|
|
@@ -101,10 +111,18 @@ function capModelOf(id, wire, listed, unpriced) {
|
|
|
101
111
|
* (DATA_ENV). The run environment's secrets, and the keys added, are readable by name and never enumerable: the
|
|
102
112
|
* harness's model route finds the key its requests carry (model.ts, `env[row.field]`) while a program spawned with this
|
|
103
113
|
* environment carries none. A spread would drop every secret the launcher handed the runner, and the route would send no
|
|
104
|
-
* key. The data directory is a plain variable, which a spawn carries.
|
|
105
|
-
|
|
114
|
+
* key. The data directory is a plain variable, which a spawn carries. So is the run's resolved tool plane (`plane`,
|
|
115
|
+
* TOOL_PLANE_ENV, not a secret), as main hands its per-run process: the adapter reads web_search's there (adapters.ts
|
|
116
|
+
* nativeOptions: claude-agent's WebSearch, codex's live search, admitted by its proxy's policy and priced with it), so a
|
|
117
|
+
* run whose plane resolves it to native gets the harness's own search (#2458), this run's alone; whatever the runner's
|
|
118
|
+
* own environment says of a plane is never the run's. Whether each search runs is the tool's setting at that search
|
|
119
|
+
* (SessionIO.permission, the gate), never this plane, which is frozen when the run is made. */
|
|
120
|
+
export function cliRunEnv(env, data, claimed = {}, plane) {
|
|
106
121
|
const out = withModelKeys(env ?? {}, claimed);
|
|
107
122
|
Object.defineProperty(out, DATA_ENV, { value: data, enumerable: true, writable: true, configurable: true });
|
|
123
|
+
delete out[TOOL_PLANE_ENV];
|
|
124
|
+
if (plane && Object.keys(plane).length)
|
|
125
|
+
Object.defineProperty(out, TOOL_PLANE_ENV, { value: JSON.stringify(plane), enumerable: true, writable: true, configurable: true });
|
|
108
126
|
return out;
|
|
109
127
|
}
|
|
110
128
|
/** `tools` in the order the agent grants them (`granted`, catalog names; a tool is listed by its catalog name's wire
|
|
@@ -122,19 +140,54 @@ export function inGrantOrder(tools, granted) {
|
|
|
122
140
|
});
|
|
123
141
|
return keyed.sort((a, b) => a.key - b.key || a.given - b.given).map(({ tool }) => tool);
|
|
124
142
|
}
|
|
125
|
-
/**
|
|
126
|
-
*
|
|
127
|
-
|
|
128
|
-
|
|
143
|
+
/** Every earlier claim's private folder of the run (`<harnesses>/<n>`, n below `epoch`) removed: what a claim whose runner
|
|
144
|
+
* 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
|
|
145
|
+
* next claim's while this one lets go late) is never touched. Each removal is whole or is finished by the next sweep. */
|
|
146
|
+
export async function sweepEarlier(harnesses, epoch) {
|
|
147
|
+
let names;
|
|
148
|
+
try {
|
|
149
|
+
names = await readdir(harnesses);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
if (error.code === "ENOENT")
|
|
153
|
+
return;
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
for (const name of names) {
|
|
157
|
+
if (/^\d+$/.test(name) && Number(name) < epoch)
|
|
158
|
+
await rm(join(harnesses, name), { recursive: true, force: true });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/** A claim's end: every earlier claim's folder of the run (sweepEarlier) and the claim's own (`<harnesses>/<epoch>`)
|
|
162
|
+
* removed, then each of `parents` in order while it is empty: one another claim of the run has laid things in since (a
|
|
163
|
+
* follow-up's) stays, with what is in it. Run again over what a cut-off sweep left, it finishes it. */
|
|
164
|
+
export async function sweepScratch(harnesses, epoch, parents) {
|
|
165
|
+
// An earlier folder that cannot be swept never keeps this claim's own folder: its removal is attempted anyway, and the
|
|
166
|
+
// earlier failure is thrown after it (with this one's, when both fail).
|
|
167
|
+
const failures = [];
|
|
168
|
+
await sweepEarlier(harnesses, epoch).catch((error) => { failures.push(error); });
|
|
169
|
+
await rm(join(harnesses, String(epoch)), { recursive: true, force: true }).catch((error) => { failures.push(error); });
|
|
170
|
+
if (failures.length === 0)
|
|
171
|
+
await rmEmptyParents(parents);
|
|
172
|
+
else
|
|
173
|
+
await rmEmptyParents(parents).catch((error) => { failures.push(error); });
|
|
174
|
+
if (failures.length === 1)
|
|
175
|
+
throw failures[0];
|
|
176
|
+
if (failures.length > 1)
|
|
177
|
+
throw new AggregateError(failures, failures.map((error) => error?.message ?? String(error)).join("; "));
|
|
178
|
+
}
|
|
179
|
+
async function rmEmptyParents(parents) {
|
|
129
180
|
for (const parent of parents) {
|
|
130
181
|
try {
|
|
131
182
|
await rmdir(parent);
|
|
132
183
|
}
|
|
133
184
|
catch (error) {
|
|
134
185
|
const code = error.code;
|
|
135
|
-
if (code === "ENOTEMPTY" || code === "EEXIST"
|
|
186
|
+
if (code === "ENOTEMPTY" || code === "EEXIST")
|
|
136
187
|
return;
|
|
137
|
-
|
|
188
|
+
// Already gone (a sweep cut off after it, or never made): the folder above it may still be left empty.
|
|
189
|
+
if (code !== "ENOENT")
|
|
190
|
+
throw error;
|
|
138
191
|
}
|
|
139
192
|
}
|
|
140
193
|
}
|
|
@@ -160,6 +213,18 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
160
213
|
const runRow = await deps.store.runs.get(claim.runId);
|
|
161
214
|
if (!runRow)
|
|
162
215
|
throw new Error(`run ${claim.runId}: its row is gone from the store`);
|
|
216
|
+
// The claim's private folder is swept at the spec's release, the claim's end, then the scratch folder if nothing else is
|
|
217
|
+
// in it, then the agent's: the next claim, here or on another runner, lays its own, its harness's session coming back from
|
|
218
|
+
// the run's journal. Its own per claim (by the claim's epoch), so a run reopened while this claim still lets go (its
|
|
219
|
+
// release follows the run's end commit) never has the next claim's folder swept from under it. A claim whose runner died
|
|
220
|
+
// never ran its release: every claim sweeps the earlier claims' folders of its run at its start and again at its end, so
|
|
221
|
+
// a killed CLI's home and session state never outlive the run. Held here, before any step that can fail (the install, the
|
|
222
|
+
// MCP claim, the computer): a claim that fails in its setup still sweeps what the earlier claims left, as specBuilt lets
|
|
223
|
+
// go what was held when the build throws.
|
|
224
|
+
const scratch = scratchFolder(deps.data, runRow.agentId, claim.runId);
|
|
225
|
+
const harnesses = join(scratch, "harness");
|
|
226
|
+
const dir = join(harnesses, String(claim.epoch));
|
|
227
|
+
holds.hold({ scratch: { sweep: () => sweepScratch(harnesses, claim.epoch, [harnesses, scratch, dirname(scratch)]) } });
|
|
163
228
|
// Every secret the server keeps sealed (store-secrets.ts) held by the runner's one redactor (the loop's) and this spec's
|
|
164
229
|
// log cut, before any of the run's text is written: a run's text may quote one it was never handed.
|
|
165
230
|
for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
@@ -216,13 +281,13 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
216
281
|
});
|
|
217
282
|
}
|
|
218
283
|
}
|
|
219
|
-
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin
|
|
284
|
+
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
|
|
220
285
|
// credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
|
|
221
|
-
// Before the session opens: a refusal (a pin
|
|
222
|
-
// A credential the claim opens mid-run (a GitHub App token, a per_run server's
|
|
286
|
+
// Before the session opens: a refusal (a granted tool its pin does not hold, a pinned meta tool) ends the run in its words.
|
|
287
|
+
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
|
|
223
288
|
const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
224
289
|
redact.hold(values); };
|
|
225
|
-
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 }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}) });
|
|
290
|
+
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 } : {}) });
|
|
226
291
|
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
227
292
|
holds.hold({ passed: mcp });
|
|
228
293
|
// The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
|
|
@@ -253,32 +318,32 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
253
318
|
await copyRunFiles(deps.data, claim.runId, ws.workspace, launch.files);
|
|
254
319
|
// The run's computer, from the one shared claim-time function (the pi spec takes the same): none for a runner place.
|
|
255
320
|
// It throws computer_unavailable (nothing made) when the computer cannot be had: the run fails in its words.
|
|
256
|
-
const computer = await deps.computerForClaim({ runId: claim.runId, epoch: claim.epoch, agentId: runRow.agentId, revisionId: runRow.revisionId, place: launch.place, ...(launch.computer !== undefined ? { computer: launch.computer } : {}) }, deps.store,
|
|
321
|
+
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,
|
|
257
322
|
// revokeMount removes the run's Archil mount credential at the computer's release (and if a start fails after a mint); the
|
|
258
323
|
// run's end revokes it too, so it goes on every outcome even with no computer. Idempotent. As the pi spec does, with
|
|
259
324
|
// what became of the agent's own computer said on the run's timeline.
|
|
260
325
|
// A browser computer is driven by the browser tool, which runs on pi's native route alone: a CLI's run of an agent
|
|
261
326
|
// whose computer is a browser is refused in words at its claim, before anything is made.
|
|
262
|
-
{ ...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) } : {}) });
|
|
327
|
+
{ ...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)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
|
|
263
328
|
holds.hold({ computer });
|
|
329
|
+
const loopComputer = loopComputerOf(computer.computer, computer.held);
|
|
330
|
+
const heldComputer = heldSpecOf(launch, loopComputer);
|
|
264
331
|
// The CLI works in the run's scratch folder on this machine (its working directory), its own files (home, state, the
|
|
265
332
|
// 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
|
|
266
333
|
// 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
|
|
267
334
|
// any other absolute path is refused (workspace/paths.ts portPath).
|
|
268
|
-
//
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
281
|
-
});
|
|
335
|
+
// Made again if a parent went as it was made (another claim's sweep removing the then empty scratch or agent folder).
|
|
336
|
+
for (let tries = 1;; tries += 1) {
|
|
337
|
+
try {
|
|
338
|
+
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
catch (error) {
|
|
342
|
+
if (error.code !== "ENOENT" || tries === 3)
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
await sweepEarlier(harnesses, claim.epoch).catch((error) => log(`an earlier claim's scratch folder could not be swept: ${error?.message ?? String(error)}`));
|
|
282
347
|
// The run's shell is its computer's (600 s) where one mounts its folder; with none, Archil's serverless exec in Mode 2
|
|
283
348
|
// (295 s), and in Mode 1 none at all: no bash family, its folder being one of this server's own (run-tools.ts).
|
|
284
349
|
// 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.
|
|
@@ -289,24 +354,28 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
289
354
|
// The system prompt, as main's harness branch builds it: the environment line, the instructions with what the agent
|
|
290
355
|
// learned laid in (learning.ts laidLearned, from the launch's learning start, so the runner reads no learning folder), its
|
|
291
356
|
// own skills through systemOf with the harness's own check (a harness that loads skills itself keeps in the prompt only
|
|
292
|
-
// those it would refuse, and is handed the rest),
|
|
357
|
+
// those it would refuse, and is handed the rest), the output schema it answers in (answer-json.ts outputContract, as the
|
|
358
|
+
// pi spec gives it), then the effort guidance.
|
|
293
359
|
const start = learningStartOf(launch);
|
|
294
360
|
// A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
|
|
295
|
-
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section) : (body.instructions ?? "");
|
|
361
|
+
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section, start.use === true) : (body.instructions ?? "");
|
|
296
362
|
const check = await entry.skillCheck?.();
|
|
297
363
|
// The revision's own skills laid before they are read, as the pi spec lays them (adapter-run-spec.ts).
|
|
298
364
|
await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: launch.computer?.kind });
|
|
299
365
|
// A learning run's seed laid as the pi spec lays it (runner/learning-seed.ts), its learned skills then in the skill list
|
|
300
366
|
// the harness is handed (its native skills, or the prompt's), its learned workflows the ones learned_workflow runs.
|
|
367
|
+
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
368
|
+
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
301
369
|
const seedLaid = start && !seedFailed(start)
|
|
302
370
|
? await layLearningSeed({
|
|
303
371
|
work: ws.workspace,
|
|
304
372
|
seed: start.seed,
|
|
305
|
-
folder:
|
|
373
|
+
folder: learningFolder,
|
|
306
374
|
own: Object.keys(revisionRow.skills ?? {}),
|
|
307
|
-
shown
|
|
375
|
+
shown,
|
|
308
376
|
log,
|
|
309
377
|
...(start.notesOnly ? { workflows: false } : {}),
|
|
378
|
+
...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
|
|
310
379
|
})
|
|
311
380
|
: undefined;
|
|
312
381
|
const { system: instructions, native } = await systemOf(laid, [...Object.keys(body.skills ?? {}), ...(seedLaid?.skills ?? [])], ws.workspace, check, { onDemand: readsFiles(granted) });
|
|
@@ -321,7 +390,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
321
390
|
const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, revisionRow, launch);
|
|
322
391
|
for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
323
392
|
holdClaimed(redact, claimed);
|
|
324
|
-
const env = cliRunEnv(deps.env, deps.data, claimed);
|
|
393
|
+
const env = cliRunEnv(deps.env, deps.data, claimed, launch.plane);
|
|
325
394
|
const chosen = await modelsOf(entry, env, modelAskOf(launch.model, body.model));
|
|
326
395
|
// The CLI's own process (the Claude CLI, Codex, OpenCode) starts under the no_new_privs pi's commands start under
|
|
327
396
|
// (adapters.ts' noNewPrivsPrefix): on Linux, setpriv --no-new-privs, so a setuid program or file capability it
|
|
@@ -378,6 +447,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
378
447
|
// The run's one cap, as the loop's runCap reads it (adapter-loop.ts RunCapConfig): the launch's cap figure (undefined
|
|
379
448
|
// uncapped), the model that bills this CLI run priced WITH tiers, strict where the launch says. The loop builds the
|
|
380
449
|
// kernel runCap from these over the run's own sessions; the spec carries no beforeRequest of its own.
|
|
450
|
+
const besideOf = spentBesideOf(launch, deps.store, claim.runId);
|
|
381
451
|
const runCap = {
|
|
382
452
|
capUsd: () => launch.maxCostUsd,
|
|
383
453
|
// One model per CLI session: every request it sends is the run's model, whatever id its provider names it by. A
|
|
@@ -390,6 +460,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
390
460
|
return tierRoute && tierRoute.model === id ? capModelOfRoute(tierRoute) : undefined;
|
|
391
461
|
},
|
|
392
462
|
...(launch.capMode === "strict" ? { mode: "strict" } : {}),
|
|
463
|
+
// What its learning runs' grades took beside it, read by every gate with its own sessions (none: it queues none).
|
|
464
|
+
...(besideOf ? { beside: besideOf } : {}),
|
|
393
465
|
};
|
|
394
466
|
const cap = capUsd === undefined
|
|
395
467
|
? undefined
|
|
@@ -404,7 +476,11 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
404
476
|
// store at each decide — adapterRunGate (RunGate.decide: deny with its words, a pin, allow, ask). The end-of-run turn's
|
|
405
477
|
// refusal of writes under .learning/ is the adapter loop's own (it knows the turn), never a file's. The run's MCP servers
|
|
406
478
|
// (mcpServersOf its grants) hold a harness's own name for an MCP tool to that tool's settings.
|
|
407
|
-
|
|
479
|
+
// A pinned MCP tool is held to the arguments its listing in the run's pin declares (mcp.argumentsOf).
|
|
480
|
+
const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, mcpServersOf(granted), mcp ? { effectOf: (name) => mcp.effectOf(name), argumentsOf: (name) => mcp.argumentsOf(name) } : {});
|
|
481
|
+
// What a script's shell and files are held to: this gate's settings, decided as on the run's computer (gate.script), so a
|
|
482
|
+
// denied bash or write holds inside computer_script too.
|
|
483
|
+
tools.computer?.guard.install(gate.script);
|
|
408
484
|
// The run's tools: the kernel registry's hands on its Workspace (and computer); the web host tools it is granted
|
|
409
485
|
// (web_fetch, web_search, monid), bound by the binding the pi spec uses (webHostTools) on the ToolHost the pi spec builds
|
|
410
486
|
// (buildToolHost); and the learned_workflow tool when the run has it (learnsWorkflows: its revision is agentic and the
|
|
@@ -419,14 +495,34 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
419
495
|
// The runner's one redactor (the loop's), else this spec's log cut: the claim's keys join it, and the answers of the tools
|
|
420
496
|
// that run on them pass it.
|
|
421
497
|
const held = run.redact ? heldRedactor(run.redact) : cut;
|
|
422
|
-
|
|
498
|
+
// The run's monid endpoints (monid-run.ts), one host tool each from its revision's pin, on the claim's keys and beside
|
|
499
|
+
// its MCP tools in the loop's one catalog seam; their answers pass the redactors as the web tools' do.
|
|
500
|
+
const monid = monidForClaim(body.monidPin, { ...claimed }, () => ws.workspace, claim.runId);
|
|
501
|
+
const catalog = withMonid(mcp, monid && { ...monid, tools: monid.tools.map((tool) => answersCut(tool, held)) });
|
|
502
|
+
const webNames = granted.filter(isWebHostTool);
|
|
423
503
|
let learnedTool;
|
|
424
504
|
let webTools = [];
|
|
425
505
|
let life;
|
|
426
506
|
// The keys the claim hands the run (its web tools and its learned workflow's call nodes run on them): never learned
|
|
427
507
|
// (learningEndOfRun).
|
|
428
508
|
let handedKeys = [];
|
|
429
|
-
|
|
509
|
+
// A replay run lays the workflow it replays record-only (runner/promotion.ts replayLaid).
|
|
510
|
+
const laidFlows = replayLaid(launch, seedLaid?.workflows ?? []);
|
|
511
|
+
// The learned workflow the run starts on, before its agent's first turn, when one fits its input (workflow-first.ts),
|
|
512
|
+
// chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
|
|
513
|
+
// serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
|
|
514
|
+
// five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
|
|
515
|
+
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the run asks for its revision.
|
|
516
|
+
const firstChoice = learnsWorkflows(revision.kind, laidFlows) ? await workflowFirstOf(revision.kind, laidFlows, launch, log, () => pastRunsOverStore(deps.store, runRow.agentId), promotionGate(claimPromotion({
|
|
517
|
+
store: deps.store, agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, launch, context, log, folder: learningFolder, shown, sealKey: deps.sealKey,
|
|
518
|
+
})), revision.body.outputSchema) : {};
|
|
519
|
+
// A replay run runs only its revision, while it still replays: else its claim is refused (the run ends failed, no agent).
|
|
520
|
+
await replayClaimed(deps.store, runRow.agentId, launch, firstChoice);
|
|
521
|
+
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
522
|
+
// answered from that recording (runner/promotion.ts replayCallsFor, learn/replay-calls.ts).
|
|
523
|
+
const replay = await replayCallsFor(deps.store, claim.runId, launch, context);
|
|
524
|
+
const { serve: workflowFirst, revise: workflowRevise } = firstChoice;
|
|
525
|
+
const workflows = laidFor(laidFlows, firstChoice);
|
|
430
526
|
const learns = learnsWorkflows(revision.kind, workflows);
|
|
431
527
|
if (webNames.length || learns) {
|
|
432
528
|
// The claim's keys (above, already held by the redactors), a copy of its own for the tools' plane below.
|
|
@@ -471,25 +567,30 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
471
567
|
// The gate asks a learned_workflow call about its workflow's MCP nodes (adapterRunGate); they run through the run's
|
|
472
568
|
// 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.
|
|
473
569
|
gate.learn(workflows);
|
|
474
|
-
learnedTool = await learnedWorkflowHostTool({ run, kind: revision.kind, granted, plane: launch.plane, env: toolEnv, work: root, workflows, permissions: gate.permissions, ctx, tiers, ...(
|
|
570
|
+
learnedTool = await learnedWorkflowHostTool({ run, kind: revision.kind, granted, plane: launch.plane, env: toolEnv, work: root, workflows, permissions: gate.permissions, ctx, tiers, ...(catalog ? { mcp: catalog } : {}), workspace: ws.workspace, modelName: () => chosen.model.modelId, ...(replay ? { replay } : {}) });
|
|
475
571
|
}
|
|
476
572
|
}
|
|
573
|
+
// ask_person, when granted: pi's own tool (tools.ts askPerson), bound as a host tool the way the web tools are. Its call
|
|
574
|
+
// answers what pi's does; the loop then cuts the CLI's turn at the question (adapter-loop.ts, turn-ending host tools),
|
|
575
|
+
// so the run parks on the person or waits for them in its claim exactly as a pi run does.
|
|
576
|
+
const askTool = granted.includes(ASK_TOOL) ? hostToolOf(ASK_TOOL, askPerson, ctx) : undefined;
|
|
477
577
|
const session = {
|
|
478
578
|
key: `run:${claim.runId}`,
|
|
479
579
|
label: runRow.agentId,
|
|
480
|
-
system: [environmentLine(), checkout?.note, instructions, guidance].filter((line) => Boolean(line)),
|
|
580
|
+
system: [environmentLine(), checkout?.note, instructions, outputContract(body.outputSchema), guidance].filter((line) => Boolean(line)),
|
|
481
581
|
// The web tools and the learned workflow's call nodes run on the claim's keys: their answers pass the runner's one
|
|
482
582
|
// redactor, as pi's do. Listed in the order the agent grants them, as main lists a CLI run's tools.
|
|
483
|
-
tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), results), ...[...webTools, ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
|
|
583
|
+
tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), results), ...[...webTools, ...(askTool ? [askTool] : []), ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
|
|
484
584
|
context: "fresh",
|
|
485
585
|
...(thinking ? { thinking } : {}),
|
|
486
586
|
};
|
|
487
|
-
|
|
488
|
-
const input = await firstMessage(
|
|
587
|
+
// A typed input's other fields follow its content as one json block (inputMessage).
|
|
588
|
+
const input = await firstMessage(inputMessage(launch.input), ws.workspace);
|
|
489
589
|
// The run's end-of-run step, when it learns, the same as the pi spec's: the reflect-and-propose turn over the run's
|
|
490
590
|
// store, its learning folder where the run's place keeps it — Mode 1 under the data directory, Mode 2 on this claim's
|
|
491
591
|
// Archil disk — so the proposal is checked against the seed in the run's own Workspace, never this machine's local path.
|
|
492
|
-
|
|
592
|
+
// A replay run asks nothing at its end: it is the promotion's, never the agent's to learn from.
|
|
593
|
+
const endOfRun = launch.replay ? undefined : learningEndOfRun(launch, {
|
|
493
594
|
store: deps.store,
|
|
494
595
|
data: deps.data,
|
|
495
596
|
...(deps.env ? { env: deps.env } : {}),
|
|
@@ -499,6 +600,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
499
600
|
signIns: signInReads(deps.store, deps.sealKey),
|
|
500
601
|
handed: handedKeys,
|
|
501
602
|
stored: () => storeSecrets(deps.store, deps.sealKey, deps.data),
|
|
603
|
+
log,
|
|
604
|
+
// A workflow draft's decision nodes are checked against the host's decision providers, on its keys (LS-07).
|
|
605
|
+
decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, DECISION_PROVIDER_KEYS)) }),
|
|
502
606
|
learningFolder: archil === undefined
|
|
503
607
|
? (agentId) => learningFolderOf(deps.data, agentId)
|
|
504
608
|
: (agentId) => learningWorkspace({ mode: "archil", agentId, archil }),
|
|
@@ -512,17 +616,22 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
512
616
|
...(runner.record ? { record: runner.record } : {}),
|
|
513
617
|
gate,
|
|
514
618
|
runCap,
|
|
619
|
+
// The answer's schema: a miss is asked again once (adapter-loop.ts, the output contract's retry), as on pi.
|
|
620
|
+
...(body.outputSchema !== undefined ? { outputSchema: body.outputSchema } : {}),
|
|
515
621
|
...(cap ? { cap } : {}),
|
|
516
|
-
// The run's MCP for a harness with its own client (mcp-run.ts),
|
|
517
|
-
|
|
622
|
+
// The run's MCP for a harness with its own client (mcp-run.ts), with its monid endpoints beside it (monid-run.ts):
|
|
623
|
+
// the catalog tools the session mounts; absent when none.
|
|
624
|
+
...(catalog ? { mcp: catalog } : {}),
|
|
518
625
|
// The run's end-of-run step, when it learns (the spec's, preferred over the loop's deps': adapter-loop.ts stepOf).
|
|
519
626
|
...(endOfRun ? { endOfRun } : {}),
|
|
520
627
|
...(start ? { learningLaid: laidOf(seedLaid) } : {}),
|
|
628
|
+
...(workflowFirst ? { workflowFirst } : {}),
|
|
629
|
+
...(workflowRevise ? { workflowRevise } : {}),
|
|
521
630
|
// The web tools' install lifecycle, run by the adapter loop, as the pi spec's (they register none today).
|
|
522
631
|
...(life ? { lifecycle: life } : {}),
|
|
523
632
|
agentId: runRow.agentId,
|
|
524
|
-
// The run's
|
|
525
|
-
...(
|
|
633
|
+
// 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).
|
|
634
|
+
...(loopComputer ? { computer: loopComputer } : {}),
|
|
526
635
|
workRoot: root,
|
|
527
636
|
// Where the CLI works (its working directory, the run's folder to its file tools): what its absolute paths are read
|
|
528
637
|
// against on the run's rows.
|
|
@@ -533,23 +642,24 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
533
642
|
// session of its journal), as a pi run's are at its answers' costs and tokens.
|
|
534
643
|
endPatch: async () => {
|
|
535
644
|
const entries = await entriesOf(deps.journal(claim), ROOT_CONVERSATION_ID, context);
|
|
536
|
-
// Its tokens and model requests, and its model requests' cost, from one read of its booking (cliRunMetrics)
|
|
537
|
-
// decisions (a learned workflow's) at what they were booked at
|
|
645
|
+
// Its tokens and model requests, and its model requests' cost, from one read of its booking (cliRunMetrics). Its
|
|
646
|
+
// model requests and its decisions (a learned workflow's, LS-07) at what they were booked at (bookedSpend), and its
|
|
647
|
+
// paid tool calls (a Parallel extract or search, a monid call), booked on the run's one ledger in their own session,
|
|
648
|
+
// are the run's cost (runEndCost: unknown when any part is), as the pi spec's.
|
|
538
649
|
const all = (await journalEntries(deps.journal(claim), context));
|
|
539
650
|
const booked = bookedSpend(all, "model");
|
|
540
651
|
const metrics = cliRunMetrics(entries, booked, { ...(thinking ? { effort: thinking } : {}), model: `${chosen.model.provider}/${chosen.model.modelId}` });
|
|
541
652
|
// A run whose model answered or called a tool with no request booked (its requests went past its model proxy) spent
|
|
542
653
|
// what no booking read: unknown, never the $0 an empty booking sums to.
|
|
543
654
|
const model = booked.requests === 0 && cliModelWorked(entries) ? null : booked.usd;
|
|
544
|
-
const decisions = bookedSpend(all, "decisions").usd;
|
|
545
|
-
const costUsd = model === null || decisions === null ? null : model + decisions;
|
|
546
655
|
// Its paid tool calls (a Parallel extract or search, a monid call), booked on the run's one ledger in their own
|
|
547
|
-
// session, are the run's cost too, as the pi spec's.
|
|
548
|
-
const
|
|
549
|
-
const total = costUsd === null || paid === null ? null : costUsd + paid;
|
|
656
|
+
// session, and its decisions (a learned workflow's decision nodes) are the run's cost too, as the pi spec's.
|
|
657
|
+
const total = runEndCost({ model, paid: run.ledger?.paid ? run.ledger.paid.spentUsd() : 0, decisions: bookedSpend(all, "decisions").usd });
|
|
550
658
|
// An unknown cost is written as null, never left out: a follow-up's end clears the cost an earlier end stored.
|
|
551
|
-
return { costUsd: total, metrics };
|
|
659
|
+
return { costUsd: total, metrics: { ...metrics, ...pathMetrics(launch, launch.learning ? await runPathOverStore(deps.store, claim.runId, launch.learning, run.redact) : undefined, entries) } };
|
|
552
660
|
},
|
|
661
|
+
// A run started with hold: true holds its computer for its owner (computer-held.ts), as the pi spec's.
|
|
662
|
+
...(heldComputer ? { held: heldComputer } : {}),
|
|
553
663
|
// The run's Archil mount credential is revoked at its end on every outcome, even with no computer (idempotent with
|
|
554
664
|
// the computer's release). A run that minted none revokes nothing.
|
|
555
665
|
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;
|
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) {
|
|
@@ -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;
|