@parcha/agentrun-serve 0.1.0-beta.37 → 0.1.0-beta.39
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 +700 -0
- package/README.md +441 -177
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +1 -3
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +48 -23
- 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/bash-read-only.js +2 -1
- package/dist/browser-cost.js +52 -93
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -400
- package/dist/cap.js +6 -942
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +2 -6
- package/dist/chatgpt-plan.d.ts +163 -0
- package/dist/chatgpt-plan.js +549 -0
- package/dist/cli.js +26 -6
- package/dist/composio-preset.d.ts +25 -0
- package/dist/composio-preset.js +51 -8
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.d.ts +36 -24
- package/dist/computer-calls.js +110 -27
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +12 -2
- package/dist/computer-live.js +21 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +18 -2
- package/dist/computer-view.js +21 -6
- package/dist/computer-viewer.js +40 -13
- package/dist/computers.d.ts +8 -2
- package/dist/computers.js +18 -8
- package/dist/console/assets/index-BNhZs-jp.css +1 -0
- package/dist/console/assets/index-BQv5aOGB.js +700 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +6 -3
- package/dist/decision-cap.d.ts +2 -5
- package/dist/decision-cap.js +3 -6
- package/dist/decision-rows.js +11 -11
- package/dist/decisions.js +4 -0
- package/dist/email/account.d.ts +84 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +10 -0
- package/dist/email/answer.js +182 -0
- package/dist/email/email-faux.d.ts +95 -0
- package/dist/email/email-faux.js +849 -0
- package/dist/email/labels.d.ts +1 -0
- package/dist/email/labels.js +84 -0
- package/dist/email/mail.d.ts +186 -0
- package/dist/email/mail.js +380 -0
- package/dist/email/names.d.ts +20 -0
- package/dist/email/names.js +40 -0
- package/dist/email/routes.d.ts +9 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +20 -0
- package/dist/email/tools.js +517 -0
- package/dist/environment.d.ts +17 -2
- package/dist/environment.js +36 -8
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +12 -0
- package/dist/eval-mailbox.d.ts +103 -0
- package/dist/eval-mailbox.js +236 -0
- package/dist/faux-computers.js +4 -2
- package/dist/graph-view.d.ts +9 -2
- package/dist/graph-view.js +6 -2
- package/dist/harness-install.d.ts +28 -2
- package/dist/harness-install.js +147 -59
- package/dist/harness-opencode/adapter.js +2 -22
- package/dist/harness-opencode/facts.js +5 -4
- package/dist/harness-opencode/host/policy.d.ts +4 -5
- package/dist/harness-opencode/host/policy.js +14 -33
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/versions.d.ts +6 -0
- package/dist/harness-opencode/versions.js +6 -0
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +8 -7
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/host-tools.d.ts +1 -5
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +3 -3
- package/dist/hosted-search.js +51 -32
- package/dist/import-sources.d.ts +1 -1
- package/dist/import-sources.js +3 -3
- package/dist/import.d.ts +21 -0
- package/dist/import.js +186 -1
- package/dist/key-check.d.ts +0 -2
- package/dist/key-check.js +3 -4
- package/dist/key-refusal.d.ts +8 -2
- package/dist/key-refusal.js +16 -13
- package/dist/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +24 -4
- package/dist/learn/check.js +340 -7
- package/dist/learn/commit.d.ts +10 -0
- package/dist/learn/commit.js +18 -4
- package/dist/learn/compile.d.ts +250 -0
- package/dist/learn/compile.js +507 -0
- package/dist/learn/general.d.ts +3 -0
- package/dist/learn/general.js +4 -2
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +11 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +308 -0
- package/dist/learn/promote.js +321 -0
- package/dist/learn/refit.d.ts +48 -0
- package/dist/learn/refit.js +264 -0
- package/dist/learn/reflect.d.ts +5 -25
- package/dist/learn/reflect.js +14 -131
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +19 -16
- package/dist/learn/skills.js +157 -53
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +58 -2
- package/dist/learned-nodes.js +68 -5
- package/dist/learned-workflow.d.ts +58 -32
- package/dist/learned-workflow.js +215 -77
- package/dist/learning-batch.d.ts +2 -2
- package/dist/learning-batch.js +4 -4
- package/dist/learning-cost.d.ts +41 -11
- package/dist/learning-cost.js +31 -13
- package/dist/learning-routes.d.ts +12 -2
- package/dist/learning-routes.js +34 -6
- package/dist/learning-words.d.ts +8 -1
- package/dist/learning-words.js +11 -1
- package/dist/learning.d.ts +26 -1
- package/dist/learning.js +7 -4
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/llm.js +0 -3
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-gateway.d.ts +12 -20
- package/dist/mcp-gateway.js +16 -44
- package/dist/mcp-oauth.d.ts +5 -0
- package/dist/mcp-oauth.js +1 -1
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +113 -0
- package/dist/mcp-probe.d.ts +8 -9
- package/dist/mcp-probe.js +16 -33
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +102 -26
- package/dist/mcp-servers-store.js +151 -25
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +11 -0
- package/dist/mcp-store.js +16 -2
- 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 +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +39 -6
- package/dist/model.js +171 -32
- package/dist/monid.d.ts +50 -29
- package/dist/monid.js +234 -143
- package/dist/native/binding.d.ts +13 -0
- package/dist/native/binding.js +57 -0
- package/dist/native/cli.d.ts +2 -0
- package/dist/native/cli.js +48 -0
- package/dist/native/connection.d.ts +8 -0
- package/dist/native/connection.js +94 -0
- package/dist/native/context.d.ts +6 -0
- package/dist/native/context.js +22 -0
- package/dist/native/discovery.d.ts +27 -0
- package/dist/native/discovery.js +404 -0
- package/dist/native/environment.d.ts +4 -0
- package/dist/native/environment.js +18 -0
- package/dist/native/history.d.ts +20 -0
- package/dist/native/history.js +147 -0
- package/dist/native/instructions.d.ts +21 -0
- package/dist/native/instructions.js +173 -0
- package/dist/native/remote-worker-bridge.d.ts +3 -0
- package/dist/native/remote-worker-bridge.js +278 -0
- package/dist/native/remote.d.ts +187 -0
- package/dist/native/remote.js +492 -0
- package/dist/native/runtime.d.ts +17 -0
- package/dist/native/runtime.js +316 -0
- package/dist/native/runtimes.d.ts +66 -0
- package/dist/native/runtimes.js +41 -0
- package/dist/native/schema.d.ts +46 -0
- package/dist/native/schema.js +41 -0
- package/dist/native/types.d.ts +87 -0
- package/dist/native/types.js +1 -0
- package/dist/observation/http.d.ts +4 -0
- package/dist/observation/http.js +140 -0
- package/dist/observation/observer.d.ts +301 -0
- package/dist/observation/observer.js +919 -0
- package/dist/observation/schema.d.ts +52 -0
- package/dist/observation/schema.js +154 -0
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +705 -126
- package/dist/paid-calls.d.ts +34 -32
- package/dist/paid-calls.js +52 -104
- package/dist/place-offers.d.ts +4 -8
- package/dist/place-offers.js +4 -9
- package/dist/port-models.d.ts +7 -2
- package/dist/port-models.js +5 -2
- package/dist/print.d.ts +4 -2
- package/dist/print.js +4 -3
- package/dist/propose.d.ts +8 -3
- package/dist/propose.js +28 -7
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +17 -2
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/reflect-range.js +2 -1
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +23 -1
- package/dist/run-launch.js +17 -4
- package/dist/run-learning-served.d.ts +84 -0
- package/dist/run-manifest.d.ts +8 -0
- package/dist/run-manifest.js +33 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +12 -10
- package/dist/run-view.d.ts +59 -41
- package/dist/run-view.js +128 -64
- package/dist/runnable.d.ts +13 -8
- package/dist/runnable.js +77 -60
- package/dist/runner/adapter-loop.d.ts +60 -15
- package/dist/runner/adapter-loop.js +1406 -464
- package/dist/runner/adapter-run-spec.d.ts +45 -14
- package/dist/runner/adapter-run-spec.js +200 -116
- package/dist/runner/adapters/pi.d.ts +40 -7
- package/dist/runner/adapters/pi.js +149 -38
- package/dist/runner/beside.d.ts +3 -1
- package/dist/runner/beside.js +24 -8
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +28 -4
- package/dist/runner/cli-run-spec.d.ts +30 -0
- package/dist/runner/cli-run-spec.js +150 -66
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +5 -3
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +149 -5
- package/dist/runner/conformance/subject.d.ts +11 -4
- package/dist/runner/end-of-run.d.ts +8 -5
- package/dist/runner/end-of-run.js +11 -6
- package/dist/runner/feedback-round.d.ts +79 -0
- package/dist/runner/feedback-round.js +127 -0
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +55 -13
- package/dist/runner/journal-kinds.js +19 -0
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +58 -19
- package/dist/runner/learning-end.js +316 -115
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +21 -1
- package/dist/runner/learning-loop.js +24 -6
- package/dist/runner/learning-seed.d.ts +4 -0
- package/dist/runner/learning-seed.js +14 -0
- package/dist/runner/loop-contract.d.ts +19 -3
- package/dist/runner/loop.d.ts +34 -1
- package/dist/runner/loop.js +55 -1
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-claim.d.ts +5 -1
- package/dist/runner/mcp-claim.js +66 -50
- package/dist/runner/mcp-run.d.ts +20 -53
- package/dist/runner/mcp-run.js +22 -88
- package/dist/runner/meta-tools.d.ts +44 -0
- package/dist/runner/meta-tools.js +344 -0
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +128 -42
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +149 -19
- package/dist/runner/monid-run.d.ts +18 -0
- package/dist/runner/monid-run.js +170 -0
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +146 -0
- package/dist/runner/promotion.js +803 -0
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.d.ts +36 -21
- package/dist/runner/reflect-hook.js +147 -49
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +34 -8
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/sessions.d.ts +8 -3
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +7 -12
- package/dist/runner/workflow-first.d.ts +226 -0
- package/dist/runner/workflow-first.js +293 -0
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +32 -19
- package/dist/runner/workflow-spec.d.ts +5 -1
- package/dist/runner/workflow-spec.js +63 -48
- package/dist/runs-over-store.d.ts +41 -4
- package/dist/runs-over-store.js +64 -22
- package/dist/sdk/runs.d.ts +115 -0
- package/dist/sdk/runs.js +422 -0
- package/dist/sdk/schema.d.ts +175 -0
- package/dist/sdk/schema.js +138 -0
- package/dist/sdk/workflows.d.ts +22 -0
- package/dist/sdk/workflows.js +39 -0
- package/dist/secrets.d.ts +2 -0
- package/dist/secrets.js +19 -1
- package/dist/server.d.ts +108 -20
- package/dist/server.js +874 -157
- package/dist/settings-wake.d.ts +8 -6
- package/dist/settings-wake.js +13 -7
- package/dist/skill-route.d.ts +3 -0
- package/dist/skill-route.js +16 -0
- package/dist/skills/agentrun-serve/SKILL.md +368 -0
- package/dist/stats.d.ts +10 -10
- package/dist/store/agent-body.d.ts +22 -7
- package/dist/store/agent-body.js +23 -14
- package/dist/store/command-wake.d.ts +3 -2
- package/dist/store/command-wake.js +4 -4
- package/dist/store/index.d.ts +1 -1
- package/dist/store/native-command-owner.d.ts +10 -0
- package/dist/store/native-command-owner.js +47 -0
- package/dist/store/postgres/connection.js +3 -1
- 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/postgres/migrations/0012_revision_monid_pin.sql +4 -0
- package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
- package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
- package/dist/store/postgres/store.js +3 -0
- package/dist/store/schema.d.ts +16 -0
- package/dist/store/schema.js +47 -8
- 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 +8 -1
- package/dist/store/sqlite/run-patch.js +33 -10
- package/dist/store/sqlite/store.js +184 -28
- package/dist/store/store.d.ts +98 -21
- package/dist/store-reads/analytics.d.ts +7 -7
- package/dist/store-reads/analytics.js +23 -5
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/journal.d.ts +30 -1
- package/dist/store-reads/journal.js +141 -83
- package/dist/store-reads/learning.d.ts +179 -13
- package/dist/store-reads/learning.js +230 -68
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +3 -2
- package/dist/store-view.js +109 -37
- package/dist/template-eval.d.ts +87 -16
- package/dist/template-eval.js +605 -120
- package/dist/template-github-permissions.d.ts +2 -2
- package/dist/template-github-permissions.js +2 -1
- 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 +274 -52
- package/dist/templates.js +670 -201
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +7 -5
- package/dist/timeline/index.js +7 -5
- package/dist/timeline/labels.d.ts +11 -4
- package/dist/timeline/labels.js +122 -8
- package/dist/timeline/origin.d.ts +20 -6
- package/dist/timeline/origin.js +13 -6
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +76 -20
- package/dist/timeline/timeline.js +184 -39
- package/dist/timeline/util.d.ts +5 -0
- package/dist/timeline/util.js +44 -8
- package/dist/timeline/web-calls.d.ts +17 -0
- package/dist/timeline/web-calls.js +106 -0
- package/dist/tool-gate.d.ts +103 -76
- package/dist/tool-gate.js +200 -127
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +29 -0
- package/dist/tool-list.js +50 -0
- package/dist/tool-names.d.ts +76 -0
- package/dist/tool-names.js +101 -0
- package/dist/tool-plane.d.ts +34 -28
- package/dist/tool-plane.js +72 -37
- package/dist/tools.d.ts +59 -15
- package/dist/tools.js +46 -42
- package/dist/trigger-adapter.d.ts +85 -5
- package/dist/trigger-adapter.js +6 -0
- package/dist/trigger-adapters.js +3 -1
- package/dist/trigger-composio.d.ts +10 -0
- package/dist/trigger-composio.js +122 -0
- package/dist/trigger-email.d.ts +4 -0
- package/dist/trigger-email.js +228 -0
- package/dist/trigger-signatures.d.ts +6 -10
- package/dist/trigger-signatures.js +16 -16
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +4 -3
- package/dist/trigger-webhook.js +6 -4
- package/dist/triggers.d.ts +94 -9
- package/dist/triggers.js +263 -62
- package/dist/uploads.d.ts +9 -0
- package/dist/uploads.js +27 -0
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +91 -50
- package/dist/web-fake.d.ts +56 -0
- package/dist/web-fake.js +102 -0
- package/dist/web-fetch-direct.d.ts +3 -0
- package/dist/web-fetch-direct.js +4 -1
- package/dist/web-fetch.d.ts +6 -8
- package/dist/web-fetch.js +10 -53
- package/dist/web-search.d.ts +51 -2
- package/dist/web-search.js +116 -18
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -1
- package/dist/workflow/node-runner.js +10 -2
- package/dist/workspace/archil-claim.d.ts +3 -0
- package/dist/workspace/archil-claim.js +9 -2
- package/dist/workspace/computer-deps.d.ts +25 -9
- package/dist/workspace/computer-deps.js +82 -38
- package/dist/workspace/computer-for-claim.d.ts +60 -4
- package/dist/workspace/computer-for-claim.js +203 -45
- package/dist/workspace/computer-hold.js +7 -1
- package/dist/workspace/computer-janitor.d.ts +10 -3
- package/dist/workspace/computer-janitor.js +96 -29
- package/dist/workspace/computer-kept.d.ts +82 -0
- package/dist/workspace/computer-kept.js +147 -0
- package/dist/workspace/computer-mcp.js +4 -3
- package/dist/workspace/computer-ports.d.ts +23 -3
- package/dist/workspace/computer-ports.js +115 -5
- package/dist/workspace/index.d.ts +2 -3
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +31 -11
- package/dist/workspace/kind-skills/phone/SKILL.md +29 -14
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +33 -1
- package/dist/workspace/resolve-computer.js +37 -16
- package/dist/workspace/revision-skills.d.ts +6 -2
- package/dist/workspace/revision-skills.js +12 -5
- package/dist/workspace/run-end-computers.d.ts +30 -0
- package/dist/workspace/run-end-computers.js +137 -0
- package/dist/workspace/run-tools.d.ts +40 -23
- package/dist/workspace/run-tools.js +46 -19
- package/dist/wrap-up.d.ts +35 -0
- package/dist/wrap-up.js +48 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +220 -60
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +46 -16
- 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 +3 -3
- 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/off-by-one/graders/no-repo-reads.md +2 -1
- 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/pasted-by-reference/case.yaml +5 -0
- package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
- package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
- package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -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 +5 -4
- package/templates/code-review/skills/review/REVIEWER.md +5 -4
- package/templates/code-review/skills/review/SKILL.md +11 -6
- 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 +5 -4
- 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 +5 -4
- 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-Cn6JX1uH.js +0 -563
- package/dist/console/assets/index-DRN62V5v.css +0 -1
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -7
- package/dist/runner/adapters/pi-computer.js +0 -43
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -38
- package/dist/tool-budget.js +0 -62
- package/dist/workspace/computer-script.d.ts +0 -37
- package/dist/workspace/computer-script.js +0 -138
- 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
|
@@ -1,60 +1,67 @@
|
|
|
1
1
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
2
2
|
import { defineExtension, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
3
|
-
import { checkRaise, followUpOf, parkOf } from "@parcha/agentrun-kernel/kernel/cap";
|
|
3
|
+
import { checkRaise, followUpOf, freeModelRequestsOf, parkOf, planCapModel } from "@parcha/agentrun-kernel/kernel/cap";
|
|
4
4
|
import { inspectWorkflow } from "@parcha/agentrun-dsl";
|
|
5
5
|
import { decisionProvidersIn } from "../decisions.js";
|
|
6
6
|
import { dropLiveViewer, putLiveViewer } from "../browser-live.js";
|
|
7
7
|
import { runnerLiveOf } from "../live-reach.js";
|
|
8
8
|
import { llmTiers, nodeTiers, thinkingLevel, TIERS, tierModelOf, workflowNodes } from "../model.js";
|
|
9
|
-
import { firstMessage } from "../run-manifest.js";
|
|
9
|
+
import { firstMessage, inputMessage, messageText } from "../run-manifest.js";
|
|
10
10
|
import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
11
|
-
import {
|
|
12
|
-
import { deniedText,
|
|
11
|
+
import { isWebHostTool } from "../tool-list.js";
|
|
12
|
+
import { deniedText, noApproverText, runGate } from "../tool-gate.js";
|
|
13
13
|
import { DECISION_PROVIDER_KEYS, loadToolSettings, recheckPlane, TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
14
14
|
import { readApprovers } from "../server-approvers.js";
|
|
15
15
|
import { ASK_TOOL, askPerson, toolOf } from "../tools.js";
|
|
16
16
|
import { hostToolOf } from "../host-tools.js";
|
|
17
|
-
import { WEB_FETCH_TOOL } from "../web-fetch.js";
|
|
18
17
|
import { WEB_SEARCH_TOOL } from "../web-search.js";
|
|
19
|
-
import {
|
|
18
|
+
import { webCut } from "../timeline/web-calls.js";
|
|
19
|
+
import { environmentLine, runZone } from "../environment.js";
|
|
20
20
|
import { effortGuidance } from "../effort-guidance.js";
|
|
21
|
+
import { outputContract } from "../answer-json.js";
|
|
21
22
|
import { laidLearned, learningFolderOf, secretsShown } from "../learning.js";
|
|
22
23
|
import { laidOf, layLearningSeed } from "./learning-seed.js";
|
|
23
24
|
import { learningWorkspace } from "../learn/folder.js";
|
|
24
25
|
import { learningEndOfRun, spentBesideOf } from "./learning-end.js";
|
|
25
|
-
import {
|
|
26
|
+
import { learnedAskShown, LEARNED_WORKFLOW_TOOL, learnedMcpCalls, learnedWorkflowTool } from "../learned-workflow.js";
|
|
26
27
|
import { PORT_PROVIDER, tieredModels, tierProvider } from "../port-models.js";
|
|
27
28
|
import { promptOf, readsFiles } from "../skills.js";
|
|
28
29
|
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
29
30
|
import { layOwnSkills } from "../workspace/revision-skills.js";
|
|
30
31
|
import { COMPUTER_ROOT, runFolder } from "../workspace/paths.js";
|
|
31
32
|
import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
32
|
-
import {
|
|
33
|
+
import { placeRunInputs } from "../uploads.js";
|
|
33
34
|
import { handedSignInReadsBack, signInReads } from "../sign-ins-store.js";
|
|
34
35
|
import { UNREADABLE_SIGN_IN } from "../run-view.js";
|
|
35
36
|
import { durableWait } from "../workflow/pi-versions.js";
|
|
36
37
|
import { claimSecrets, hostDecisionKeys, learnedDecisionKeys, savedModelKeys, tierModelKeys, withModelKeys } from "./claim-secrets.js";
|
|
37
|
-
import { mcpForClaim } from "./mcp-run.js";
|
|
38
|
+
import { catalogSessionNames, mcpForClaim } from "./mcp-run.js";
|
|
38
39
|
import { hostLifecycle } from "./adapter-loop.js";
|
|
39
40
|
import { piAdapter } from "./adapters/pi.js";
|
|
40
|
-
import { computerCodemode } from "./adapters/pi-computer.js";
|
|
41
41
|
import { agentEntriesOf } from "./loop.js";
|
|
42
42
|
import { SUBAGENT_TIERS, SUBAGENT_TOOL, subagentTool } from "./subagent.js";
|
|
43
|
-
import { wireName } from "../catalog.js";
|
|
44
43
|
import { ClaimRefused } from "./loop-contract.js";
|
|
45
|
-
import { bookedSpend,
|
|
44
|
+
import { bookedSpend, cliRunMetrics, endCostOf, runCostOf, runMetrics } from "./metrics.js";
|
|
46
45
|
import { journalEntries } from "./journal-reader.js";
|
|
46
|
+
import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
|
|
47
|
+
import { claimPromotion, promotionGate, replayCallsFor, replayClaimed, replayLaid } from "./promotion.js";
|
|
48
|
+
import { laidFor, pathMetrics, servedOf, workflowFirstOf } from "./workflow-first.js";
|
|
49
|
+
import { pastRunsOverStore, runPathOverStore } from "../store-reads/learning.js";
|
|
47
50
|
import { specBuilt } from "./spec-holds.js";
|
|
48
51
|
import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
49
52
|
import { loadArchilSettings } from "../archil-settings.js";
|
|
50
|
-
import {
|
|
53
|
+
import { settingOfDefinition } from "../computer-setting.js";
|
|
54
|
+
import { computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
55
|
+
import { hadComputer } from "./computer-journal.js";
|
|
51
56
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
57
|
+
import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
|
|
52
58
|
import { heldSpecOf } from "./held-run.js";
|
|
53
59
|
import { loopComputerOf } from "./computer-channel.js";
|
|
54
60
|
import { githubAppAccess } from "./github-app.js";
|
|
55
61
|
import { prCheckoutForClaim } from "./pr-checkout.js";
|
|
56
62
|
import { holdStored, storeSecrets } from "./store-secrets.js";
|
|
57
63
|
import { bashPolicyOf } from "../bash-read-only.js";
|
|
64
|
+
import { monidForClaim, withMonid } from "./monid-run.js";
|
|
58
65
|
/** The wires pi speaks on the runner: main's pi's (provider.ts), Anthropic's Messages and OpenAI's Responses. */
|
|
59
66
|
export const PI_WIRES = Object.freeze(["anthropic-messages", "openai-responses"]);
|
|
60
67
|
/** The browser's catalog name (tools.ts TOOLS.browser). */
|
|
@@ -70,6 +77,9 @@ export const browserListed = (host, granted) => BROWSER_ON_RUNNER && host.ledger
|
|
|
70
77
|
* model's tier is held and booked at the tier, as main's calculateCost does). `api` is the proxy's shape, for the
|
|
71
78
|
* overhead its provider adds; the output ceiling is the route's when it carries one, else none. */
|
|
72
79
|
export function capModelOf(route) {
|
|
80
|
+
// A ChatGPT plan's route is billed to the plan: the one plan rule (planCapModel), a CLI's plan model's too.
|
|
81
|
+
if (route.provider.plan)
|
|
82
|
+
return planCapModel(route.model, route.provider.api, route.outputCeiling ?? null);
|
|
73
83
|
// A model serve has no price for carries placeholder zeros: the cap reads it as unknown (null), never as $0.
|
|
74
84
|
const cost = route.unpriced ? undefined : route.cost;
|
|
75
85
|
const price = cost
|
|
@@ -96,62 +106,48 @@ const isSubagentRoute = (key) => key.startsWith(SUBAGENT_ROUTE);
|
|
|
96
106
|
export function modelAskOf(pinned, ref) {
|
|
97
107
|
return pinned ? { pinned, ...(ref ? { ref } : {}) } : ref;
|
|
98
108
|
}
|
|
99
|
-
export async function adapterRunGate(store, claim, revision, root, shell,
|
|
109
|
+
export async function adapterRunGate(store, claim, revision, root, shell, options = {}) {
|
|
100
110
|
let current = await storeSettings(store);
|
|
101
111
|
const approvers = await readApprovers(store.settings);
|
|
102
112
|
// A Workspace's paths are in the run's folder: its folder named as a computer names it, for the gate's path checks.
|
|
103
113
|
const folder = typeof root === "string" ? root : COMPUTER_ROOT;
|
|
104
114
|
// Where the run's shell is (run-tools.ts shell): with no computer, a tool no setting names takes the kernel's ruled
|
|
105
|
-
// default (tool-gate.ts defaultPermission): bash asks first, the background tools are refused.
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
const gate = runGate({
|
|
115
|
+
// default (tool-gate.ts defaultPermission): bash asks first, the background tools are refused.
|
|
116
|
+
// An MCP tool's effect as the run's pin marks it (ClaimMcp.effectOf): what "allow reads" lifts an ask by.
|
|
117
|
+
const where = { root: folder, work: folder, ...(options.effectOf ? { effectOf: options.effectOf } : {}), ...(options.argumentsOf ? { argumentsOf: options.argumentsOf } : {}) };
|
|
118
|
+
const gate = runGate({ ...where, ...(shell === undefined ? {} : { computer: shell === "computer" }) }, claim.runId, revision, () => current, approvers);
|
|
109
119
|
// The run's learned workflows, once its spec has read them (learn): a learned_workflow call is asked about its MCP nodes.
|
|
110
120
|
let learned = [];
|
|
111
121
|
const decide = async (call, options = {}) => {
|
|
112
122
|
current = await storeSettings(store);
|
|
113
123
|
const decision = await gate.decide(call.tool, call.args, options);
|
|
114
|
-
// A learned workflow's MCP nodes are the run's own MCP calls, held to the same settings
|
|
115
|
-
// before any node runs,
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
// person.
|
|
124
|
+
// A learned workflow's MCP nodes are the run's own MCP calls, held to the same settings: one set to deny refuses the
|
|
125
|
+
// whole call in the gate's words before any node runs, nothing sent; the actions set to ask are put to a person on the
|
|
126
|
+
// call's one card, up front, each with its arguments' shape (learnedAskShown), and the person's allow passes the
|
|
127
|
+
// calls nested in this one of the tools that card named (adapter-loop.ts preIntentGate), and no other. Each MCP call
|
|
128
|
+
// is still asked at the gate as itself as it runs (its pins, a deny set since). Checked whether the learned_workflow
|
|
129
|
+
// call is itself allowed or asked: a workflow that can't run is never put to a person.
|
|
120
130
|
if (call.tool !== LEARNED_WORKFLOW_TOOL || typeof decision === "object")
|
|
121
131
|
return decision;
|
|
122
|
-
const
|
|
132
|
+
const actions = await mcpOf(call.args);
|
|
123
133
|
const refused = (why) => ({ deny: `The learned workflow ${String(call.args.name)} was not run: ${why}` });
|
|
124
|
-
const denied =
|
|
134
|
+
const denied = actions.find(({ tool }) => gate.policy(tool) === "deny");
|
|
125
135
|
if (denied)
|
|
126
|
-
return refused(deniedText(denied, undefined, gate.denyFrom(denied)));
|
|
127
|
-
const asks =
|
|
136
|
+
return refused(deniedText(denied.tool, undefined, gate.denyFrom(denied.tool)));
|
|
137
|
+
const asks = actions.filter(({ tool }) => gate.policy(tool) === "ask");
|
|
128
138
|
// An ask no one can answer (the server's accounts off) is refused at once in the gate's words, never parked.
|
|
129
139
|
if (asks.length && !approvers)
|
|
130
|
-
return refused(noApproverText(asks[0], "no"));
|
|
131
|
-
|
|
132
|
-
// call is refused, so no allow covers a tool its approver did not see.
|
|
133
|
-
if (asks.length && !learnedAskFits(asks))
|
|
134
|
-
return refused(`its approval card can't name all ${asks.length} MCP tools it would call that are set to ask: set some of them to allow or deny for this agent.`);
|
|
135
|
-
return asks.length ? "ask" : decision;
|
|
140
|
+
return refused(noApproverText(asks[0].tool, "no"));
|
|
141
|
+
return asks.length ? { ask: learnedAskShown(asks) } : decision;
|
|
136
142
|
};
|
|
137
|
-
/** The MCP
|
|
143
|
+
/** The MCP actions the learned workflow a learned_workflow call names can call; none for another call or workflow. */
|
|
138
144
|
const mcpOf = async (args) => {
|
|
139
145
|
const flow = learned.find((one) => one.name === args?.name);
|
|
140
|
-
return flow ?
|
|
146
|
+
return flow ? learnedMcpCalls(flow.workflow) : [];
|
|
141
147
|
};
|
|
142
148
|
// An ask is named as main's pending approval is (RunGate.askedAs: its settings key), beside the decision, which is
|
|
143
149
|
// unchanged. The permissions are the learned workflow's (main's toolGate.policy and denyFrom), over the same settings.
|
|
144
|
-
const permissions = { policy: (tool) => gate.policy(tool), denyFrom: (tool) => gate.denyFrom(tool), refresh: async () => { current = await storeSettings(store); }
|
|
145
|
-
// What a learned_workflow call's card shows beside its own input: every MCP tool set to ask that the workflow can call,
|
|
146
|
-
// and that their arguments are decided while it runs, so the person sees what they approve.
|
|
147
|
-
const askedFor = async (tool, args) => {
|
|
148
|
-
if (tool !== LEARNED_WORKFLOW_TOOL)
|
|
149
|
-
return undefined;
|
|
150
|
-
const asks = (await mcpOf(args)).filter((one) => gate.policy(one) === "ask");
|
|
151
|
-
return asks.length ? learnedAskShown(asks) : undefined;
|
|
152
|
-
};
|
|
153
|
-
// The revision's tool-call budget (tool-budget.ts), which the adapter loop holds each conversation's calls to.
|
|
154
|
-
const toolCalls = revision.body.maxToolCalls;
|
|
150
|
+
const permissions = { policy: (tool) => gate.policy(tool), denyFrom: (tool) => gate.denyFrom(tool), refresh: async () => { current = await storeSettings(store); } };
|
|
155
151
|
// A tool's setting now, read from the store as each call's is (SessionIO.permission: Codex's live search, which runs
|
|
156
152
|
// 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
153
|
// allow: a deny saved since may be in what did not read, and no call reaches the gate to say otherwise.
|
|
@@ -159,7 +155,7 @@ export async function adapterRunGate(store, claim, revision, root, shell, mcpSer
|
|
|
159
155
|
current = await storeSettings(store);
|
|
160
156
|
return current.unreadable ? "deny" : gate.policy(tool);
|
|
161
157
|
};
|
|
162
|
-
return Object.assign(decide, { askedAs: (tool) => gate.askedAs(tool
|
|
158
|
+
return Object.assign(decide, { askedAs: (tool, args) => gate.askedAs(tool, args), permissions, permission, learn: (flows) => void (learned = flows) });
|
|
163
159
|
}
|
|
164
160
|
/** The server's tool settings from the store now; a read that throws is unread (no value of it said). A workflow's call
|
|
165
161
|
* and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
|
|
@@ -222,18 +218,18 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
222
218
|
: await openRunWorkspace({ mode: 2, agentId: runRow.agentId, runId: claim.runId, archil, log });
|
|
223
219
|
holds.hold({ ws });
|
|
224
220
|
// The run's uploaded files, copied into its work/inputs/ before the first turn, from what its start held for it, once
|
|
225
|
-
// per run (uploads.ts copyRunFiles)
|
|
226
|
-
|
|
227
|
-
|
|
221
|
+
// per run (uploads.ts copyRunFiles), and its opening message saved beside them as inputs/message.md (placeRunInputs);
|
|
222
|
+
// a copy that fails ends the run failed, saying why.
|
|
223
|
+
await placeRunInputs(deps.data, claim.runId, ws.workspace, launch.files ?? [], messageText(launch.input));
|
|
228
224
|
// The pull request's checkout, when the revision asks for one (pr-checkout.ts): the server's own fetch before the first
|
|
229
225
|
// 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
226
|
// there is none. Held from the fetch's start, so the release (after the tools' end) removes it however the claim ends; a
|
|
231
227
|
// person's stop ends the fetch at once (run.stopped).
|
|
232
228
|
const checkout = body.checkout === "pull_request" ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part })) : undefined;
|
|
233
229
|
holds.hold({ checkout });
|
|
234
|
-
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin
|
|
230
|
+
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
|
|
235
231
|
// credentials opened under the server's seal key into this claim's memory, one gateway for the claim. First, before
|
|
236
|
-
// anything the spec would have to let go: a refusal (a pin
|
|
232
|
+
// anything the spec would have to let go: a refusal (a granted tool its pin does not hold, a pinned meta tool) ends the run in its
|
|
237
233
|
// words before the session opens. The seal key is the runner's own (deps.sealKey), not re-read from the environment.
|
|
238
234
|
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor.
|
|
239
235
|
const hold = (values) => cut.hold(values);
|
|
@@ -243,21 +239,29 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
243
239
|
// The run's computer, from the one shared claim-time function (the CLI spec takes the same): none for a runner place, a
|
|
244
240
|
// Docker container for a sandbox, under the claim's epoch (the one fence). It throws computer_unavailable (nothing made)
|
|
245
241
|
// when the computer cannot be had: the run fails in its words.
|
|
246
|
-
const
|
|
242
|
+
const claimSignal = run.stopped ?? run.signal;
|
|
243
|
+
const computer = await deps.computerForClaim({ runId: claim.runId, epoch: claim.epoch, claim, agentId: runRow.agentId, revisionId: runRow.revisionId, place: launch.place }, deps.store,
|
|
247
244
|
// revokeMount removes the run's Archil mount credential when the computer is released (and if a start fails after a mint);
|
|
248
245
|
// the run's end revokes it too (below), so it goes on every outcome even when no computer is made. Idempotent. What
|
|
249
246
|
// became of the agent's own computer (a persistent setting) is said on the run's timeline.
|
|
250
|
-
|
|
247
|
+
// A person's stop ends the claim's waits at once: a first image pull or registration (Agent37's runs minutes) among them.
|
|
248
|
+
// Whether an earlier claim made the run a computer of its own is the run's journal's to say (hadComputer): a later
|
|
249
|
+
// claim's is a new one whatever ended the earlier claim (a lost runner, a server's stop, a park past its keep). The
|
|
250
|
+
// computer a park kept, attached again, brings its mount credential with it (inheritMount): none is minted.
|
|
251
|
+
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, hadComputer: () => hadComputer(deps.journal(claim), context), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(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) } : {}) });
|
|
251
252
|
// The run's shell is its computer's (600 s) where one mounts its folder; with none, Archil's serverless exec in Mode 2
|
|
252
253
|
// (295 s), and in Mode 1 none at all: no bash family, its folder being one of this server's own (run-tools.ts).
|
|
253
254
|
// 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,
|
|
254
255
|
// and the agent's hand-over (computer_request_handoff) asks the person through it.
|
|
255
256
|
holds.hold({ computer });
|
|
256
|
-
const loopComputer = loopComputerOf(computer.computer, computer.held);
|
|
257
|
+
const loopComputer = loopComputerOf(computer.computer, computer.held, computer.made);
|
|
257
258
|
const heldComputer = heldSpecOf(launch, loopComputer);
|
|
258
259
|
// Under the agent's bash policy, its shell's environment is the policy's too (bash-read-only.ts policyEnv).
|
|
259
260
|
const bashPolicy = bashPolicyOf(body.toolSettings);
|
|
260
|
-
|
|
261
|
+
// The computer's tools are the run's own host tools, as on every harness: the host's codemode (meta-tools.ts) calls them
|
|
262
|
+
// as `tools.<name>`, each a nested call, gated and recorded as the model's own call is. A computer that replaced an
|
|
263
|
+
// earlier claim's holds its acts to what it showed.
|
|
264
|
+
const tools = await runTools(ws.workspace, computer.computer, { mode, context, ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }), ...(computer.replaced ? { replaced: true } : {}) });
|
|
261
265
|
holds.hold({ tools });
|
|
262
266
|
// The run's model route: its model through routeOf (NEVER re-resolved — the launch's model, pinned at start), the catalog
|
|
263
267
|
// price with tiers for the cap, and the proxy's price (pi-ai calculateCost, tiered).
|
|
@@ -274,6 +278,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
274
278
|
// saved in Settings → Model keys runs the next run with no restart (withModelKeys).
|
|
275
279
|
const modelEnv = withModelKeys(deps.env, toolEnv);
|
|
276
280
|
const route = await deps.routeOf(modelAskOf(launch.model, body.model), modelEnv, "default", PI_WIRES, undefined, cut);
|
|
281
|
+
await planBeforeRun(modelEnv, route.provider.plan ? { provider: PLAN_PROVIDER } : undefined);
|
|
277
282
|
// The run's models of other tiers, for its learned workflows' nodes of a tier (learnedTierRoutes, filled once the seed's
|
|
278
283
|
// lay chose the workflows, below): read when the session opens (pi.ts options.tiers), each on a proxy of its own.
|
|
279
284
|
const tierRoutes = new Map();
|
|
@@ -282,12 +287,10 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
282
287
|
// - ask_person is pi's own tool (tools.ts): a run granted it carries its native extension, so pi runs it as its own tool
|
|
283
288
|
// task under the session's gate and keeps its control.terminate — the turn ends on the person's question and the loop
|
|
284
289
|
// parks the run (endedOnTurnEndingTool), or, with the browser's session open, waits for the answer in its claim
|
|
285
|
-
// (adapter-loop waitInClaim, the browser's personWait below). It stays out of
|
|
286
|
-
//
|
|
290
|
+
// (adapter-loop waitInClaim, the browser's personWait below). It stays out of this session's host tools: a CLI
|
|
291
|
+
// harness gets the same tool as a host tool (cli-run-spec.ts), whose turn the loop cuts at the question.
|
|
287
292
|
// - the browser's durable extension, when the run gets one (bindNonHandTools, below, before the session opens).
|
|
288
|
-
|
|
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)] : [])];
|
|
293
|
+
const native = granted.includes(ASK_TOOL) ? [defineExtension({ name: "ask_person", tools: [askPerson] })] : [];
|
|
291
294
|
// pi-native tools in the session's own extension (PiAdapterOptions.tools): the subagent tool, pushed below.
|
|
292
295
|
const piTools = [];
|
|
293
296
|
// A run granted subagent (runner/subagent.ts): the model of each of its tiers, the revision's own (modelTiers) else the
|
|
@@ -339,12 +342,8 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
339
342
|
const root = runFolder(deps.data, runRow.agentId, claim.runId);
|
|
340
343
|
// 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
|
|
341
344
|
// the same path), for its path checks; it reads nothing in it.
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
tools.computer?.guard.install(async (tool, args) => {
|
|
345
|
-
await gate.permissions.refresh();
|
|
346
|
-
return gate.permissions.decide(tool, args);
|
|
347
|
-
});
|
|
345
|
+
// A pinned MCP tool is held to the arguments its listing in the run's pin declares (mcp.argumentsOf).
|
|
346
|
+
const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, mcp ? { effectOf: (name) => mcp.effectOf(name), argumentsOf: (name) => mcp.argumentsOf(name) } : {});
|
|
348
347
|
// The run's one cap, as the loop's runCap reads it (adapter-loop.ts RunCapConfig): the launch's cap figure (undefined
|
|
349
348
|
// uncapped — every paid request still books through the one cap), the run's model priced WITH tiers, strict where the
|
|
350
349
|
// launch says. The loop builds the kernel runCap from these over the run's own sessions (its model requests, its paid
|
|
@@ -362,9 +361,10 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
362
361
|
const tierRoute = tierRoutes.get(by);
|
|
363
362
|
return tierRoute && tierRoute.model === id ? capModelOf(tierRoute) : undefined;
|
|
364
363
|
},
|
|
365
|
-
...(launch.capMode === "strict" ? { mode: "strict" } : {}),
|
|
366
364
|
// What its learning runs' grades took beside it, read by every gate with its own sessions (none: it queues none).
|
|
367
365
|
...(besideOf ? { beside: besideOf } : {}),
|
|
366
|
+
// The most requests on free models it makes, capped or not (AGENTRUN_FREE_MODEL_REQUESTS).
|
|
367
|
+
freeRequests: freeModelRequestsOf(deps.env),
|
|
368
368
|
};
|
|
369
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
|
|
370
370
|
// has a cap. A park names the cap the loop holds the run to then (a raise's, else this one).
|
|
@@ -389,19 +389,22 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
389
389
|
const start = learningStartOf(launch);
|
|
390
390
|
// The revision's own skills are laid in the run's .agents/skills/ before they are read (main's server start laid them;
|
|
391
391
|
// on the one store the claim does), from the revision row's texts (the body keeps only each file's SHA-256): each
|
|
392
|
-
// folder not there yet, never over a learned skill or an earlier claim's.
|
|
393
|
-
|
|
392
|
+
// folder not there yet, never over a learned skill or an earlier claim's. A desktop or a phone (the revision's computer
|
|
393
|
+
// setting, the one computerForClaim starts) brings its kind's skill, named in the prompt beside the revision's own.
|
|
394
|
+
const kindSkills = await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: settingOfDefinition(body)?.computer.kind });
|
|
394
395
|
// A learning run's seed, read once from its learning folder where the run's place keeps it: its notes in .learning/
|
|
395
396
|
// and its learned skills beside the revision's own (runner/learning-seed.ts), cut of the server's secrets, the learned
|
|
396
397
|
// skills then in the skill list the prompt names, its learned workflows the ones its learned_workflow tool runs. Laid
|
|
397
398
|
// before the run's tools are bound. A learning fault, or a seed that failed (seedFailed), lays nothing.
|
|
399
|
+
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
400
|
+
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
398
401
|
const seedLaid = start && !seedFailed(start)
|
|
399
402
|
? await layLearningSeed({
|
|
400
403
|
work: ws.workspace,
|
|
401
404
|
seed: start.seed,
|
|
402
|
-
folder:
|
|
405
|
+
folder: learningFolder,
|
|
403
406
|
own: Object.keys(revisionRow.skills ?? {}),
|
|
404
|
-
shown
|
|
407
|
+
shown,
|
|
405
408
|
log,
|
|
406
409
|
...(start.notesOnly ? { workflows: false } : {}),
|
|
407
410
|
...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
|
|
@@ -411,7 +414,23 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
411
414
|
// chose them, scoped as the revision's own: each provider the run's gate does not deny, held by the run's one redactor,
|
|
412
415
|
// onto the tools' environment alone. The model's route was built on the revision's keys above, so a decision key never
|
|
413
416
|
// becomes its model's.
|
|
414
|
-
|
|
417
|
+
// A replay run lays the workflow it replays record-only (runner/promotion.ts replayLaid).
|
|
418
|
+
const laidFlows = replayLaid(launch, seedLaid?.workflows ?? []);
|
|
419
|
+
// The learned workflow the run starts on, before its agent's first turn, when one fits its input (workflow-first.ts),
|
|
420
|
+
// chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
|
|
421
|
+
// serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
|
|
422
|
+
// five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
|
|
423
|
+
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the run asks for its revision.
|
|
424
|
+
const firstChoice = learnsWorkflows(revision.kind, laidFlows) ? await workflowFirstOf(revision.kind, laidFlows, launch, log, () => pastRunsOverStore(deps.store, runRow.agentId), promotionGate(claimPromotion({
|
|
425
|
+
store: deps.store, agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, launch, context, log, folder: learningFolder, shown, sealKey: deps.sealKey,
|
|
426
|
+
})), revision.body.outputSchema) : {};
|
|
427
|
+
// A replay run runs only its revision, while it still replays: else its claim is refused (the run ends failed, no agent).
|
|
428
|
+
await replayClaimed(deps.store, runRow.agentId, claim.runId, launch, firstChoice);
|
|
429
|
+
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
430
|
+
// answered from that recording (runner/promotion.ts replayCallsFor, learn/replay-calls.ts).
|
|
431
|
+
const replay = await replayCallsFor(deps.store, claim.runId, launch, context);
|
|
432
|
+
const { serve: workflowFirst, revise: workflowRevise } = firstChoice;
|
|
433
|
+
const workflows = laidFor(laidFlows, firstChoice);
|
|
415
434
|
// A tier a learned workflow's node names and the host has a model of: none can't be reached is left as `why`, and its
|
|
416
435
|
// node fails in those words (learnedWorkflowHostTool), never on another model.
|
|
417
436
|
const tierUnreachable = new Map();
|
|
@@ -440,7 +459,8 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
440
459
|
// spec builds too), on the claim's keys and the run's one ledger and redactor.
|
|
441
460
|
// An agent whose computer is a browser the claim started gets the browser tool on that one session (tools.ts).
|
|
442
461
|
const claimBrowser = computer.computer?.kind === "browser" ? computer.computer.browser : undefined;
|
|
443
|
-
const
|
|
462
|
+
const fakes = deps.evalFakes?.(runRow.agentId);
|
|
463
|
+
const host = { ...buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: cut, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}) }), ...(claimBrowser ? { browserComputer: claimBrowser } : {}) };
|
|
444
464
|
// The run's tools. The hands (read/write/edit/bash and the background tools) are the kernel registry's over the run's
|
|
445
465
|
// Workspace and computer (runTools.hostTools); the gate is the adapter loop's own (spec.gate), so they run as asked.
|
|
446
466
|
const results = new Map();
|
|
@@ -450,18 +470,26 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
450
470
|
const tiers = new Map([...[...tierRoutes].filter(([tier]) => !isSubagentRoute(tier)).map(([tier, { model }]) => [tier, { model }]), ...[...tierUnreachable].map(([tier, why]) => [tier, { why }])]);
|
|
451
471
|
// The gate asks a learned_workflow call about its workflow's MCP nodes (adapterRunGate).
|
|
452
472
|
gate.learn(workflows);
|
|
453
|
-
|
|
473
|
+
// The run's monid endpoints (monid-run.ts), one host tool each from its revision's pin, on the claim's keys and beside
|
|
474
|
+
// its MCP tools in the loop's one catalog seam; their answers pass the run's one redactor as the other non-hand tools'.
|
|
475
|
+
const monid = monidForClaim(revisionRow.monidPin ?? undefined, toolEnv, () => ws.workspace, claim.runId, () => launch.maxCostUsd !== undefined, fakes?.monid);
|
|
476
|
+
const catalog = withMonid(mcp, monid && { ...monid, tools: monid.tools.map((tool) => answersCut(tool, cut)) });
|
|
477
|
+
const nonHandTools = (await bindNonHandTools(host, revision.kind, granted, run, context, results, root, launch.plane, workflows, native, gate.permissions, tiers, catalog, () => route.model, replay)).map((tool) => answersCut(tool, cut));
|
|
454
478
|
const sessionTools = [...handTools, ...nonHandTools];
|
|
455
479
|
// The run's system prompt, as main's per-run process builds it (app.ts): the environment line first (environment.ts, as
|
|
456
480
|
// pi installs it before every other section), then the revision's instructions with what the agent learned laid in
|
|
457
481
|
// (learning.ts laidLearned, from the launch's learning start — the # Learned section decided once at launch, so the runner
|
|
458
|
-
// reads no learning folder), its own skills through skills.ts promptOf,
|
|
459
|
-
//
|
|
482
|
+
// reads no learning folder), its own skills through skills.ts promptOf, the output schema it answers in (answer-json.ts
|
|
483
|
+
// outputContract, the CLI spec's too), then the effort guidance (the launch's effort, never this process's environment).
|
|
484
|
+
// The one path for every harness.
|
|
460
485
|
// A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
|
|
461
486
|
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section, start.use === true) : (body.instructions ?? "");
|
|
462
|
-
const instructions = await promptOf(laid, [...Object.keys(body.skills ?? {}), ...(seedLaid?.skills ?? [])], ws.workspace, { onDemand: readsFiles(granted) });
|
|
487
|
+
const instructions = await promptOf(laid, [...Object.keys(body.skills ?? {}), ...kindSkills, ...(seedLaid?.skills ?? [])], ws.workspace, { onDemand: readsFiles(granted) });
|
|
463
488
|
const guidance = effortGuidance(launch.effort);
|
|
464
|
-
|
|
489
|
+
// The run's clock: a template eval case's (EvalFakes.now), else the real one.
|
|
490
|
+
const now = fakes?.now;
|
|
491
|
+
const zone = await runZone(deps.store, launch.inputOrigin);
|
|
492
|
+
const system = [environmentLine(now, zone), checkout?.note, instructions, outputContract(body.outputSchema), guidance].filter((line) => Boolean(line));
|
|
465
493
|
// 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
494
|
// revision's grants (each by its session name: an MCP tool's wire name, the browser's registrations), its model the
|
|
467
495
|
// agent's own or one of the tiers resolved above.
|
|
@@ -469,7 +497,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
469
497
|
const browserNames = native.filter((extension) => extension.name !== "ask_person").flatMap((extension) => (extension.tools ?? []).map((tool) => tool.name));
|
|
470
498
|
piTools.push(subagentTool({
|
|
471
499
|
granted,
|
|
472
|
-
sessionNames: (
|
|
500
|
+
sessionNames: (grant) => (grant === BROWSER_TOOL ? browserNames : catalogSessionNames(catalog, grant)),
|
|
473
501
|
tier: (tier) => {
|
|
474
502
|
const why = tierWhy.get(tier);
|
|
475
503
|
if (why !== undefined)
|
|
@@ -478,13 +506,13 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
478
506
|
const at = tierRoutes.get(subagentRoute(tier));
|
|
479
507
|
if (!at)
|
|
480
508
|
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
|
-
|
|
509
|
+
// A capped run never sends a request it cannot price: an unpriced tier refuses the call, and the run goes on. A
|
|
510
|
+
// ChatGPT plan's tier is not unpriced: it costs the run no dollars (capModelOf).
|
|
511
|
+
if (at.unpriced && !at.provider.plan && launch.maxCostUsd !== undefined)
|
|
483
512
|
return { why: `${at.model} has no known price here, so this run's cost cap cannot hold its requests.` };
|
|
484
513
|
return { ref: { provider: tierProvider(subagentRoute(tier)), modelId: at.model } };
|
|
485
514
|
},
|
|
486
|
-
preamble: environmentLine(),
|
|
487
|
-
...(revision.body.maxToolCalls !== undefined ? { toolCalls: revision.body.maxToolCalls } : {}),
|
|
515
|
+
preamble: environmentLine(now, zone),
|
|
488
516
|
}));
|
|
489
517
|
}
|
|
490
518
|
// 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
|
|
@@ -500,14 +528,15 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
500
528
|
};
|
|
501
529
|
// The person's first message: the start body's content, with the run's file manifest beside it (run-manifest.ts), read
|
|
502
530
|
// through the run's Workspace (Mode 2: its inputs/ on the disk, never a folder of this machine).
|
|
503
|
-
|
|
504
|
-
const input = await firstMessage(
|
|
531
|
+
// A typed input's other fields follow its content as one json block (inputMessage).
|
|
532
|
+
const input = await firstMessage(inputMessage(launch.input), ws.workspace);
|
|
505
533
|
// The run's end-of-run step, when it learns (learningEndOfRun from the launch's learning start; none otherwise): the
|
|
506
534
|
// reflect-and-propose turn over the run's store, asked in the end turn while the claim is held (adapter-loop.ts stepOf).
|
|
507
535
|
// Its learning folder is where the run's place keeps it — Mode 1 the agent's folder under the data directory, Mode 2 the
|
|
508
536
|
// agent's folder on THIS claim's Archil disk (the proposal is checked against the seed on the disk, never this machine's
|
|
509
537
|
// local path) — so the end-of-run step reads the run's own Workspace, the one the run worked in.
|
|
510
|
-
|
|
538
|
+
// A replay run asks nothing at its end: it is the promotion's, never the agent's to learn from.
|
|
539
|
+
const endOfRun = launch.replay ? undefined : learningEndOfRun(launch, {
|
|
511
540
|
store: deps.store,
|
|
512
541
|
data: deps.data,
|
|
513
542
|
...(deps.env ? { env: deps.env } : {}),
|
|
@@ -517,6 +546,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
517
546
|
signIns: signInReads(deps.store, deps.sealKey),
|
|
518
547
|
handed: runnerSecrets(toolEnv),
|
|
519
548
|
stored: () => storeSecrets(deps.store, deps.sealKey, deps.data),
|
|
549
|
+
log,
|
|
520
550
|
// A workflow draft's decision nodes are checked against the host's decision providers, on its keys (LS-07).
|
|
521
551
|
decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, DECISION_PROVIDER_KEYS)) }),
|
|
522
552
|
learningFolder: archil === undefined
|
|
@@ -533,36 +563,54 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
533
563
|
// sent or charged, and a pinned MCP tool's call outside its pin is refused before it is asked or sent.
|
|
534
564
|
gate,
|
|
535
565
|
runCap,
|
|
566
|
+
// The answer's schema: a miss is asked again once (adapter-loop.ts, the output contract's retry).
|
|
567
|
+
...(body.outputSchema !== undefined ? { outputSchema: body.outputSchema } : {}),
|
|
536
568
|
...(cap ? { cap } : {}),
|
|
537
|
-
// The run's MCP for a harness with its own client (mcp-run.ts),
|
|
538
|
-
|
|
569
|
+
// The run's MCP for a harness with its own client (mcp-run.ts), with its monid endpoints beside it (monid-run.ts):
|
|
570
|
+
// the catalog tools the session mounts; absent when none.
|
|
571
|
+
...(catalog ? { mcp: catalog } : {}),
|
|
539
572
|
// The run's end-of-run step, when it learns (the spec's, which the loop prefers over its deps': adapter-loop.ts stepOf).
|
|
540
573
|
...(endOfRun ? { endOfRun } : {}),
|
|
541
574
|
...(start ? { learningLaid: laidOf(seedLaid) } : {}),
|
|
575
|
+
...(workflowFirst ? { workflowFirst } : {}),
|
|
576
|
+
...(workflowRevise ? { workflowRevise } : {}),
|
|
542
577
|
// The tool host's install lifecycle (its bindings' onConversation/beforeResume/beforeRelease), run by the adapter loop.
|
|
543
578
|
lifecycle: life,
|
|
544
579
|
agentId: runRow.agentId,
|
|
545
580
|
// 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
581
|
// applies a take-over and a hand-back to it, and answers the computer call channel's rows on it.
|
|
547
582
|
...(loopComputer ? { computer: loopComputer } : {}),
|
|
583
|
+
// A desktop or a phone as a codemode script gets it: the script's `computer`, over the run's computer tools.
|
|
584
|
+
...(tools.computer ? { scriptComputer: tools.computer } : {}),
|
|
585
|
+
// A computer that replaced an earlier claim's: the model is told once, on its next request (the loop's computer note).
|
|
586
|
+
...(computer.replaced ? { computerNote: computerReplacedNote(computer.replaced) } : {}),
|
|
548
587
|
workRoot: root,
|
|
549
|
-
// The end's
|
|
550
|
-
//
|
|
588
|
+
// The end's cost: its booking's, by the one rule every reader of an ended run's cost takes (metrics.ts runCostOf):
|
|
589
|
+
// every model request its session's proxy booked (pi's own answers and its side calls: a learned workflow's nodes,
|
|
590
|
+
// web_search's hosted search with its fee), its paid tool calls (a Parallel search's, a monid call's, a person's
|
|
591
|
+
// browser time, each booked in its own session) and its decisions (a learned workflow's decision nodes, LS-07; one
|
|
592
|
+
// that reported none is unknown, never the cap's hold for it). A request a cancel or a stop cut while it streamed is
|
|
593
|
+
// booked at no known cost (the provider may bill what it streamed), so the run's cost is unknown, never the $0 its cut
|
|
594
|
+
// answer carries. One cheap read, apart from the metrics below, so metrics that run late never take the cost with them.
|
|
595
|
+
endCost: async () => endCostOf(runCostOf((await journalEntries(deps.journal(claim), context)))),
|
|
596
|
+
// The end's metrics, from the run's journal, as the old per-run end path read them (metrics.ts runMetrics =
|
|
597
|
+
// runs.ts storedMetrics). A pi run adds its effort, no model (metrics.ts).
|
|
551
598
|
endPatch: async () => {
|
|
552
599
|
// 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
600
|
const entries = await agentEntriesOf(deps.journal(claim), context);
|
|
554
|
-
|
|
555
|
-
//
|
|
556
|
-
|
|
557
|
-
//
|
|
558
|
-
//
|
|
559
|
-
//
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
//
|
|
565
|
-
|
|
601
|
+
// The path it took and the learned revision it ran on, for a run that learns (workflow-first.ts pathMetrics), by the
|
|
602
|
+
// one classifier the cost per run reads back (runPathOverStore).
|
|
603
|
+
const path = pathMetrics(launch, launch.learning ? await runPathOverStore(deps.store, claim.runId, launch.learning, run.redact) : undefined, entries);
|
|
604
|
+
// A run its learned workflow served first: that call is on the loop's record (no pi answer carries its tokens), so its
|
|
605
|
+
// metrics are its booking's, as a CLI harness's run reads them: the workflow's nodes and the agent's own after a handback.
|
|
606
|
+
// An MCP tool called by a hashed wire name is counted under its catalog name, as its timeline names it.
|
|
607
|
+
const catalog = await hashedMcpOf(deps.store, claim.runId);
|
|
608
|
+
const { metrics } = servedOf(entries)
|
|
609
|
+
? { metrics: cliRunMetrics(piShaped(entries), bookedSpend((await journalEntries(deps.journal(claim), context)), "model"), { ...(launch.effort !== undefined ? { effort: launch.effort } : {}), model: launch.model ? `${launch.model.provider}/${launch.model.modelId}` : route.model, catalog }) }
|
|
610
|
+
: runMetrics(entries, { ...(launch.effort !== undefined ? { effort: launch.effort } : {}), catalog });
|
|
611
|
+
// Its cost is endCost's, read apart (an unknown one written as null, never left out: a follow-up's end clears the
|
|
612
|
+
// cost an earlier end stored).
|
|
613
|
+
return { metrics: { ...metrics, ...path } };
|
|
566
614
|
},
|
|
567
615
|
// A run started with hold: true holds its computer for its owner (computer-held.ts): the loop waits for their start
|
|
568
616
|
// and release, and runs their calls on it.
|
|
@@ -571,7 +619,11 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
571
619
|
// scratch swept), its computer let go, then its Workspace's end (Mode 2 sweeps the exec spill).
|
|
572
620
|
// The run's Archil mount credential is revoked at its end on every outcome, even with no computer (the computer's
|
|
573
621
|
// release revokes it too; revoke is idempotent, so a second call is a no-op). A run that minted none revokes nothing.
|
|
574
|
-
|
|
622
|
+
// At a park, a desktop or a phone is kept for the resume instead (spec-holds.ts SpecHolds.release `parked`), its mount
|
|
623
|
+
// credential with it, and the run's timeline is told so.
|
|
624
|
+
...(computer.keeps ? { keptWords: computerKeptWords(computer.keeps) } : {}),
|
|
625
|
+
release: (how) => holds.release(how),
|
|
626
|
+
endCheckout: () => holds.endCheckout(),
|
|
575
627
|
};
|
|
576
628
|
}
|
|
577
629
|
/** The host-tool ctx a non-hand tool is wrapped with (host-tools.ts hostToolOf): the run's own Harness (its commit,
|
|
@@ -646,7 +698,12 @@ export async function learnedWorkflowHostTool(opts) {
|
|
|
646
698
|
return undefined;
|
|
647
699
|
const flows = opts.workflows;
|
|
648
700
|
const tiers = opts.tiers ?? new Map();
|
|
649
|
-
|
|
701
|
+
// Each MCP tool of the run by its catalog name, to the name the session's tools hold it by: what an MCP node calls,
|
|
702
|
+
// nested in the workflow's call.
|
|
703
|
+
const mcpTools = new Map((opts.mcp?.tools ?? []).flatMap((one) => {
|
|
704
|
+
const catalog = opts.mcp.catalogOf(one.name);
|
|
705
|
+
return typeof catalog === "string" ? [[catalog, one.name]] : [];
|
|
706
|
+
}));
|
|
650
707
|
const byProvider = new Map([[PORT_PROVIDER, await opts.run.ledger.models(LEARNED_WORKFLOW_TOOL)]]);
|
|
651
708
|
for (const [tier, model] of tiers)
|
|
652
709
|
if ("model" in model)
|
|
@@ -665,8 +722,28 @@ export async function learnedWorkflowHostTool(opts) {
|
|
|
665
722
|
const providers = await decisionProvidersIn(opts.env);
|
|
666
723
|
const decisions = providers ? { decisions: { providers, book: opts.run.ledger.decisions, pause: (refusal) => opts.run.ledger.pause(refusal) } } : {};
|
|
667
724
|
// 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,
|
|
669
|
-
|
|
725
|
+
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, mcpTools, nestedOf: (callId) => nestedBy.get(callId), ...decisions, ...(opts.workspace ? { workspace: opts.workspace } : {}), ...(opts.modelName ? { modelName: opts.modelName } : {}), ...(opts.replay ? { replay: opts.replay } : {}) });
|
|
726
|
+
const host = hostToolOf(LEARNED_WORKFLOW_TOOL, tool, opts.ctx);
|
|
727
|
+
if (!host)
|
|
728
|
+
return undefined;
|
|
729
|
+
// The tool nests calls (HostTool.nests): its MCP nodes are the session's tools called nested in it, which the harness
|
|
730
|
+
// hands each call (`nested`), each asked at the gate and recorded as its own; it runs again whole after a park or a
|
|
731
|
+
// crash, each node answered as it was the first time.
|
|
732
|
+
const nestedBy = new Map();
|
|
733
|
+
return {
|
|
734
|
+
...host,
|
|
735
|
+
nests: true,
|
|
736
|
+
async call(args, context) {
|
|
737
|
+
if (context.nested)
|
|
738
|
+
nestedBy.set(context.callId, context.nested);
|
|
739
|
+
try {
|
|
740
|
+
return await host.call(args, context);
|
|
741
|
+
}
|
|
742
|
+
finally {
|
|
743
|
+
nestedBy.delete(context.callId);
|
|
744
|
+
}
|
|
745
|
+
},
|
|
746
|
+
};
|
|
670
747
|
}
|
|
671
748
|
/** The run's non-hand tools as HostTool[], bound through the ToolHost seam and wrapped as the hands are (host-tools.ts
|
|
672
749
|
* hostToolOf): web_fetch, web_search and monid, each by its catalog name under the adapter loop's one gate (`spec.gate`;
|
|
@@ -685,14 +762,16 @@ export function liveViewersOf(store, sealKey, claim, cut) {
|
|
|
685
762
|
drop: (tag) => dropLiveViewer(store, claim, tag),
|
|
686
763
|
};
|
|
687
764
|
}
|
|
688
|
-
/** `tool` with its answer's text, and a throw's message, cut by `cut` (the run's one redactor).
|
|
765
|
+
/** `tool` with its answer's text, and a throw's message, cut by `cut` (the run's one redactor). A web call's answer is cut
|
|
766
|
+
* string by string inside its JSON (timeline/web-calls.ts webCut), so what the harness stores still parses and keeps
|
|
767
|
+
* its links whole for a grader's link check. */
|
|
689
768
|
export function answersCut(tool, cut) {
|
|
690
769
|
return {
|
|
691
770
|
...tool,
|
|
692
771
|
call: async (args, context) => {
|
|
693
772
|
try {
|
|
694
773
|
const answer = await tool.call(args, context);
|
|
695
|
-
return { ...answer, text: cut(answer.text) };
|
|
774
|
+
return { ...answer, text: webCut(tool.name, answer.text, cut) ?? cut(answer.text) };
|
|
696
775
|
}
|
|
697
776
|
catch (error) {
|
|
698
777
|
if (error instanceof Error) {
|
|
@@ -715,7 +794,11 @@ export function answersCut(tool, cut) {
|
|
|
715
794
|
export function buildToolHost(opts) {
|
|
716
795
|
const liveAt = runnerLiveOf(opts.env, opts.sealKey);
|
|
717
796
|
const { root, claim, run, life } = opts;
|
|
797
|
+
const { web, now, email } = opts.fakes ?? {};
|
|
718
798
|
return {
|
|
799
|
+
...(web ? { web } : {}),
|
|
800
|
+
...(now ? { now } : {}),
|
|
801
|
+
...(email ? { emailFake: email } : {}),
|
|
719
802
|
// The run's directory and its per-claim environment: the hands come from runTools, so the non-hand tools get the run's
|
|
720
803
|
// environment only.
|
|
721
804
|
where: { root, work: root, ref: { id: claim.runId } },
|
|
@@ -745,17 +828,18 @@ export function buildToolHost(opts) {
|
|
|
745
828
|
// 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
|
|
746
829
|
// one its hands read: in Mode 2 its folder on the run's disk, never the local folder at `root`.
|
|
747
830
|
workspace: opts.workspace,
|
|
831
|
+
// The trigger that started the run, and the agent's own settings: an email's run reads its thread alone (email/tools.ts).
|
|
832
|
+
...(opts.launch?.trigger && opts.launch.inputOrigin?.kind === "trigger" ? { startedBy: { trigger: opts.launch.trigger, source: opts.launch.inputOrigin.source } } : {}),
|
|
833
|
+
...(opts.toolSettings !== undefined ? { toolSettings: opts.toolSettings } : {}),
|
|
748
834
|
};
|
|
749
835
|
}
|
|
750
|
-
/** The
|
|
751
|
-
export const webToolNames = (granted) => granted.filter((name) => name === WEB_FETCH_TOOL || name === WEB_SEARCH_TOOL || name.startsWith("monid."));
|
|
752
|
-
/** The run's web host tools (webToolNames: web_fetch, web_search, monid) as HostTool[], each bound through `host` by its
|
|
836
|
+
/** The run's web host tools (tool-list.ts `host` rows: web_fetch, web_search, monid) as HostTool[], each bound through `host` by its
|
|
753
837
|
* catalog name and wrapped as the hands are (host-tools.ts hostToolOf, with `ctx`), the one binding the pi spec and the
|
|
754
838
|
* CLI spec share. Each runs under the adapter loop's one gate (spec.gate) on the claim's keys (host.env), and books its
|
|
755
839
|
* paid requests on the run's one ledger itself (bookedIn): they carry no settle of their own. */
|
|
756
840
|
export async function webHostTools(host, granted, ctx) {
|
|
757
841
|
const tools = [];
|
|
758
|
-
for (const name of
|
|
842
|
+
for (const name of granted.filter(isWebHostTool)) {
|
|
759
843
|
const entry = toolOf(name);
|
|
760
844
|
if (!entry)
|
|
761
845
|
continue;
|
|
@@ -768,7 +852,7 @@ export async function webHostTools(host, granted, ctx) {
|
|
|
768
852
|
}
|
|
769
853
|
return tools;
|
|
770
854
|
}
|
|
771
|
-
async function bindNonHandTools(host, kind, granted, run, context, results, root, plane, workflows, native, permissions, tiers, mcp, modelName) {
|
|
855
|
+
async function bindNonHandTools(host, kind, granted, run, context, results, root, plane, workflows, native, permissions, tiers, mcp, modelName, replay) {
|
|
772
856
|
// Fail closed (browserListed): the browser binds only on the native route (BROWSER_ON_RUNNER) and with the claim's
|
|
773
857
|
// one-ledger booking on its ToolHost (host.ledger.paid); otherwise its extension is not installed. learned_workflow
|
|
774
858
|
// binds below with no web tool, so a learned run with no web tool still lists it.
|
|
@@ -781,7 +865,7 @@ async function bindNonHandTools(host, kind, granted, run, context, results, root
|
|
|
781
865
|
// the session's tools the harness is told of: its model nodes run on the session's proxied models (run.ledger.models),
|
|
782
866
|
// each a request on the run's one route labelled learned_workflow. The agent's scoped keys (host.env) are its call
|
|
783
867
|
// nodes'.
|
|
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 } : {}) });
|
|
868
|
+
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 } : {}), ...(replay ? { replay } : {}) });
|
|
785
869
|
if (learned)
|
|
786
870
|
tools.push(learned);
|
|
787
871
|
// The browser (tl-browser), on pi's native route: tools.ts's own binding on this run's ToolHost (its store, claim and seal
|