@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
|
@@ -3,7 +3,10 @@ import type { Models } from "@earendil-works/pi-ai";
|
|
|
3
3
|
import { type Extension, type Harness, type Registry, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
4
4
|
import { type AgentAdapter, type SessionIO, type SessionPort, type Wire } from "@parcha/agentrun-kernel";
|
|
5
5
|
import { type ModelProxy, type ProviderPolicy } from "@parcha/agentrun-kernel/host";
|
|
6
|
+
import { type ThinkingLevelMap } from "../../port-models.js";
|
|
7
|
+
import { type CallStatus } from "../journal-kinds.js";
|
|
6
8
|
import { CALL_REFUSED } from "../../timeline/index.js";
|
|
9
|
+
import { type ComputerCallRecord } from "../../computer-calls.js";
|
|
7
10
|
/** What the adapter loop lends pi for one claim: the run's Harness, its registry, and where pi's models go. */
|
|
8
11
|
export interface PiRun {
|
|
9
12
|
readonly harness: Harness;
|
|
@@ -19,13 +22,8 @@ export interface PreIntentCall {
|
|
|
19
22
|
/** An earlier attempt of the call may have been sent (a CLI's kernel bridge, asking about a replay-safe call a crash
|
|
20
23
|
* cut: GateCall's `replayed`), so a refusal never says nothing was. */
|
|
21
24
|
readonly replayed?: true;
|
|
22
|
-
/** The tool calls the call's conversation made before it, at most `upTo`, read from its committed entries (tool-budget.ts
|
|
23
|
-
* countCalls), for the gate's tool-call budget: pi's model-issued calls only, never a nested call or a CLI's. */
|
|
24
|
-
readonly callsBefore?: (upTo: number) => Promise<number>;
|
|
25
|
-
/** The call's conversation's own tool-call budget (tool-budget.ts ConversationToolBudget, a subagent's), if it has one. */
|
|
26
|
-
readonly ownBudget?: () => Promise<number | undefined>;
|
|
27
25
|
/** A call a running tool made (pi's nested call), part of a call already let through: the cap's wrap-up never refuses
|
|
28
|
-
* one (
|
|
26
|
+
* one (wrap-up.ts), so a tool in flight is never cut short. */
|
|
29
27
|
readonly nested?: true;
|
|
30
28
|
}
|
|
31
29
|
/** The host's answer before a call's intent: run it, refuse it, or park the run on it (the call never moves on here). */
|
|
@@ -40,6 +38,13 @@ export type PiSessionIO = SessionIO & {
|
|
|
40
38
|
/** What the request that just answered cost, as the runner's booking wrote it (the session's ledger): its figure, null
|
|
41
39
|
* when unknown, undefined when none was booked. pi's own price for the model is none (the adapter does not know it). */
|
|
42
40
|
bookedCost?: () => Promise<number | null | undefined>;
|
|
41
|
+
/** Keeps a tool call's computer calls beside it on the run's root, by the call's id (the loop's, as its host tools'
|
|
42
|
+
* are kept): each run's pi-native tool (code mode's script among them) runs inside recordingCalls with it, so its row
|
|
43
|
+
* carries the calls it made as a host tool's does. */
|
|
44
|
+
keepCalls?: (call: string, calls: readonly ComputerCallRecord[], dropped: number) => Promise<void>;
|
|
45
|
+
/** A nested call's end (a script's or tools_call's, its id `<callId>/<key>`), once pi has its outcome, run now or read
|
|
46
|
+
* from its record: the host keeps it beside the call's start, which its gate wrote, so the call's rows show its result. */
|
|
47
|
+
nestedEnded?: (callId: string, status: CallStatus, output: string) => Promise<void>;
|
|
43
48
|
};
|
|
44
49
|
export interface PiAdapterOptions {
|
|
45
50
|
readonly run: PiRun;
|
|
@@ -53,6 +58,8 @@ export interface PiAdapterOptions {
|
|
|
53
58
|
readonly credential: () => string | Promise<string>;
|
|
54
59
|
readonly headers?: Readonly<Record<string, string>>;
|
|
55
60
|
readonly auth?: "bearer" | "x-api-key";
|
|
61
|
+
readonly plan?: boolean;
|
|
62
|
+
readonly refused?: (credential: string) => Promise<void>;
|
|
56
63
|
};
|
|
57
64
|
/** The model pi asks for. */
|
|
58
65
|
readonly model: string;
|
|
@@ -63,6 +70,8 @@ export interface PiAdapterOptions {
|
|
|
63
70
|
readonly maxTokens?: number;
|
|
64
71
|
readonly input?: readonly string[];
|
|
65
72
|
readonly inputLimits?: unknown;
|
|
73
|
+
readonly developerRole?: boolean;
|
|
74
|
+
readonly thinkingLevelMap?: ThinkingLevelMap;
|
|
66
75
|
};
|
|
67
76
|
/** The price of a request's usage, for the proxy's booking. */
|
|
68
77
|
readonly price?: (model: string, usage: never) => number | null;
|
|
@@ -91,6 +100,13 @@ export interface PiAdapterOptions {
|
|
|
91
100
|
* requests are the run's, under its one cap, each priced at its own model. Reached through `port(label, tier)`. */
|
|
92
101
|
readonly tiers?: ReadonlyMap<string, TierModel>;
|
|
93
102
|
}
|
|
103
|
+
/** The input tokens pi (the @earendil-works/pi-* 1.5.2 packages serve pins) sends in a run's first model request before
|
|
104
|
+
* the agent's own prompt: pi writes no system prompt of its own, so it is serve's (the environment line and the wrapper
|
|
105
|
+
* around the agent's instructions) and the host's code mode tool, which every run is offered, with no tool granted.
|
|
106
|
+
* Counted with o200k_base on the first request a run sent through its spec to a scripted provider on gpt-6.1-sol, 286
|
|
107
|
+
* tokens, stated at 280 so its date line never puts it over (test/cap-save-warning.test.mjs keeps it at or under that
|
|
108
|
+
* count). A save under a cap prices a least step on it (cap-short.ts). */
|
|
109
|
+
export declare const PI_BASE_INPUT_TOKENS = 280;
|
|
94
110
|
/** pi as an AgentAdapter for one claim's run. */
|
|
95
111
|
export declare function piAdapter(options: PiAdapterOptions): AgentAdapter;
|
|
96
112
|
/** A tier's model as its proxy takes it: its route's provider, model, catalog entry, price and fetch (model-route.ts). */
|
|
@@ -121,6 +137,18 @@ export declare function piPolicy(model: string, tools: readonly string[], auth?:
|
|
|
121
137
|
* request. `webSearch`: the run's web_search is the provider's hosted search, whose one tool each wire's policy admits
|
|
122
138
|
* as its CLI's own search (claude-agent's on Messages, codex's live search on Responses). */
|
|
123
139
|
export declare function policyFor(provider: PiAdapterOptions["provider"], model: string, tools: readonly string[], webSearch?: boolean): Promise<ProviderPolicy>;
|
|
140
|
+
/** The reasoning settings of the first request a pi session on `route` sends at thinking `level` (the run's effort; none,
|
|
141
|
+
* pi's default): on Messages its `thinking` block (budgeted where the session's model reasons, which puts Claude's
|
|
142
|
+
* thinking minimum in its least output) and any `output_config`, on Responses its `reasoning`. Read from the body pi-ai
|
|
143
|
+
* builds for the session's own model (sessionOn's, at the same level), which is never sent: its payload hook stops it
|
|
144
|
+
* before any request. A save under a cap prices its least output on these (cap-short.ts). */
|
|
145
|
+
export declare function piReasoningOf(route: {
|
|
146
|
+
readonly provider: {
|
|
147
|
+
readonly api: Wire;
|
|
148
|
+
};
|
|
149
|
+
readonly model: string;
|
|
150
|
+
readonly like?: PiAdapterOptions["like"];
|
|
151
|
+
}, level: string | undefined): Promise<Record<string, unknown>>;
|
|
124
152
|
/** A refused call's words by call (the gate's deny, main's words), held from the refusal (beforeTool's block) to the
|
|
125
153
|
* call's result (afterTool): a blocked result becomes those words alone, an error, as main gives a refused call's
|
|
126
154
|
* result, never pi's framing of a blocked call. Every other result is pi's own. `held`: the words still held. */
|
|
@@ -130,7 +158,7 @@ export declare function refusalWords(): {
|
|
|
130
158
|
readonly diagnostics?: readonly {
|
|
131
159
|
readonly code?: string;
|
|
132
160
|
}[];
|
|
133
|
-
}): {
|
|
161
|
+
}, nested?: boolean): {
|
|
134
162
|
output: {
|
|
135
163
|
type: "text";
|
|
136
164
|
text: string;
|
|
@@ -139,6 +167,11 @@ export declare function refusalWords(): {
|
|
|
139
167
|
details: {
|
|
140
168
|
[CALL_REFUSED]: true;
|
|
141
169
|
};
|
|
170
|
+
diagnostics?: {
|
|
171
|
+
severity: "error";
|
|
172
|
+
code: "blocked";
|
|
173
|
+
message: string;
|
|
174
|
+
}[];
|
|
142
175
|
} | undefined;
|
|
143
176
|
readonly held: number;
|
|
144
177
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BACKGROUND_CONTEXT, withAbortSignal } from "@earendil-works/chord/context";
|
|
2
|
-
import { createModels } from "@earendil-works/pi-ai/models";
|
|
2
|
+
import { clampThinkingLevel, createModels, getSupportedThinkingLevels } from "@earendil-works/pi-ai/models";
|
|
3
3
|
import { defineExtension, defineTool, GenerationTask, hook, ToolTask } from "@earendil-works/pi-durable";
|
|
4
|
-
import { anthropicPolicy,
|
|
4
|
+
import { anthropicPolicy, withWebSearches } from "@parcha/agentrun-harness-claude";
|
|
5
5
|
import { HOST_RESULT_MAX_CHARS } from "@parcha/agentrun-kernel";
|
|
6
|
-
import { startModelProxy } from "@parcha/agentrun-kernel/host";
|
|
6
|
+
import { NATIVE_SEARCH_USD, startModelProxy } from "@parcha/agentrun-kernel/host";
|
|
7
|
+
import { INTERRUPTED_TEXT } from "@parcha/agentrun-kernel/kernel";
|
|
7
8
|
import { randomBytes } from "node:crypto";
|
|
8
9
|
import { DEFAULT_HARNESS } from "../../harness.js";
|
|
9
10
|
import { durableWait } from "../../workflow/pi-versions.js";
|
|
@@ -11,15 +12,42 @@ import { HOSTED_SEARCH_ALLOWANCE_TOKENS } from "../../hosted-search.js";
|
|
|
11
12
|
import { sessionProvider, tierProvider } from "../../port-models.js";
|
|
12
13
|
import { KINDS } from "../journal-kinds.js";
|
|
13
14
|
import { CALL_REFUSED } from "../../timeline/index.js";
|
|
14
|
-
import {
|
|
15
|
+
import { recordingCalls } from "../../computer-calls.js";
|
|
16
|
+
/** `extension` with each of its tools run inside recordingCalls, its calls kept by `keep` under the call's id. A call pi
|
|
17
|
+
* runs again after a restart keeps what that attempt makes: a code mode script's replay hands back the results of the
|
|
18
|
+
* calls its earlier attempt made, never making them again, so none is kept twice. The earlier attempt's own record goes
|
|
19
|
+
* with it, as a host tool's cut attempt's does: the shutdown seals the journal before its call ends. */
|
|
20
|
+
function recordingExtension(extension, keep) {
|
|
21
|
+
if (!extension.tools?.length)
|
|
22
|
+
return extension;
|
|
23
|
+
return {
|
|
24
|
+
...extension,
|
|
25
|
+
tools: extension.tools.map((tool) => ({
|
|
26
|
+
...tool,
|
|
27
|
+
execute: (args, api, context) => recordingCalls(async () => tool.execute(args, api, context), (calls, dropped) => keep(api.callId, calls, dropped)),
|
|
28
|
+
})),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
15
31
|
const PROVIDER = "agentrun-session";
|
|
32
|
+
/** The input tokens pi (the @earendil-works/pi-* 1.5.2 packages serve pins) sends in a run's first model request before
|
|
33
|
+
* the agent's own prompt: pi writes no system prompt of its own, so it is serve's (the environment line and the wrapper
|
|
34
|
+
* around the agent's instructions) and the host's code mode tool, which every run is offered, with no tool granted.
|
|
35
|
+
* Counted with o200k_base on the first request a run sent through its spec to a scripted provider on gpt-6.1-sol, 286
|
|
36
|
+
* tokens, stated at 280 so its date line never puts it over (test/cap-save-warning.test.mjs keeps it at or under that
|
|
37
|
+
* count). A save under a cap prices a least step on it (cap-short.ts). */
|
|
38
|
+
export const PI_BASE_INPUT_TOKENS = 280;
|
|
39
|
+
/** A host tool's value (HostTool's `structured`) in its pi result's details, which the model never reads: what a call
|
|
40
|
+
* nested in tools_call or a script reads (piNested). */
|
|
41
|
+
const HOST_VALUE = "agentrun.value";
|
|
16
42
|
const INPUT_REQUEST = "agentrun:input";
|
|
17
43
|
/** pi as an AgentAdapter for one claim's run. */
|
|
18
44
|
export function piAdapter(options) {
|
|
19
45
|
return {
|
|
20
46
|
// pi is the default harness: its id is the harness table's, never a literal of its own.
|
|
21
47
|
id: DEFAULT_HARNESS,
|
|
22
|
-
|
|
48
|
+
// Its native tools (the subagent tool, the browser's): the host's tools_search lists them, and tools_call or a script
|
|
49
|
+
// calls one as pi's own nested tool task (piNested).
|
|
50
|
+
ownTools: [...(options.extensions ?? []).flatMap((extension) => extension.tools ?? []), ...(options.tools ?? [])].map((tool) => ({ name: tool.name, description: tool.description, inputSchema: tool.parameters })),
|
|
23
51
|
check: () => [],
|
|
24
52
|
open: (spec, io) => openPi(options, spec, io),
|
|
25
53
|
};
|
|
@@ -62,6 +90,7 @@ async function routeProxy(route, hooks, tools, redact, tier, webSearch = false)
|
|
|
62
90
|
model: route.model,
|
|
63
91
|
origin: route.provider.origin,
|
|
64
92
|
credential: async () => (await route.provider.credential()) ?? "",
|
|
93
|
+
...(route.provider.refused ? { credentialRefused: route.provider.refused } : {}),
|
|
65
94
|
...(price ? { price: price } : {}),
|
|
66
95
|
...(route.provider.headers ? { headers: route.provider.headers } : {}),
|
|
67
96
|
...(route.fetch ? { fetch: route.fetch } : {}),
|
|
@@ -108,7 +137,7 @@ export function piPolicy(model, tools, auth, webSearch = false) {
|
|
|
108
137
|
return policy;
|
|
109
138
|
// The hosted search's fees held with its tokens: each use its tool's max_uses allows, at the search's fee. One with no
|
|
110
139
|
// max_uses has no bound, and its worst case is unknown (the proxy's feeMaxUsd).
|
|
111
|
-
return { ...policy, feeMaxUsd: (body) => searchesAllowed(body, (tool) => typeof tool.type === "string" && tool.type.startsWith("web_search_"), "max_uses") *
|
|
140
|
+
return { ...policy, feeMaxUsd: (body) => searchesAllowed(body, (tool) => typeof tool.type === "string" && tool.type.startsWith("web_search_"), "max_uses") * NATIVE_SEARCH_USD };
|
|
112
141
|
}
|
|
113
142
|
/** The most searches `body` allows its hosted search tool (the one `isSearch` picks): its `limit` (the tool's own key, or
|
|
114
143
|
* the body's on Responses), Infinity when it states none, 0 when the body offers no search. */
|
|
@@ -129,9 +158,11 @@ export async function policyFor(provider, model, tools, webSearch = false) {
|
|
|
129
158
|
return piPolicy(model, tools, provider.auth, webSearch);
|
|
130
159
|
// Loaded when a session of its wire opens, as the runner loads the codex harness.
|
|
131
160
|
const { codexPolicy, webSearchUsd } = (await import("@parcha/agentrun-harness-codex"));
|
|
161
|
+
// A ChatGPT plan's route keeps the plan's rules (codexPolicy's `plan`).
|
|
162
|
+
const plan = provider.plan ? { plan: true } : {};
|
|
132
163
|
if (!webSearch)
|
|
133
|
-
return codexPolicy({ model, tools });
|
|
134
|
-
return searchOnce(codexPolicy({ model, tools, webSearch: "live" }), codexPolicy({ model, tools }), webSearchUsd(model));
|
|
164
|
+
return codexPolicy({ model, tools, ...plan });
|
|
165
|
+
return searchOnce(codexPolicy({ model, tools, webSearch: "live", ...plan }), codexPolicy({ model, tools, ...plan }), webSearchUsd(model));
|
|
135
166
|
}
|
|
136
167
|
/** Codex's live-search policy (`live`) as pi's session takes it. The Codex CLI offers its search on every request; pi
|
|
137
168
|
* offers it on one request alone, its web_search's hosted search (hosted-search.ts), so two of its rules are pi's here:
|
|
@@ -171,6 +202,36 @@ async function withSearches(api, price) {
|
|
|
171
202
|
const codex = (await import("@parcha/agentrun-harness-codex"));
|
|
172
203
|
return codex.withWebSearches(price);
|
|
173
204
|
}
|
|
205
|
+
/** The session's thinking level: the one asked (the run's effort), except that a model whose catalog says it can't stop
|
|
206
|
+
* reasoning (its thinkingLevelMap's `off` is null: Claude Sonnet 5.5) is never left at off, pi's default. OpenRouter
|
|
207
|
+
* refuses such a request ("Reasoning is mandatory"), so with none asked, or off, it thinks at its lowest supported level.
|
|
208
|
+
* A model that can stop keeps none (pi's off). */
|
|
209
|
+
function mandatoryThinking(own, asked) {
|
|
210
|
+
if ((asked && asked !== "off") || !own || getSupportedThinkingLevels(own).includes("off"))
|
|
211
|
+
return asked;
|
|
212
|
+
return clampThinkingLevel(own, "off");
|
|
213
|
+
}
|
|
214
|
+
/** The reasoning settings of the first request a pi session on `route` sends at thinking `level` (the run's effort; none,
|
|
215
|
+
* pi's default): on Messages its `thinking` block (budgeted where the session's model reasons, which puts Claude's
|
|
216
|
+
* thinking minimum in its least output) and any `output_config`, on Responses its `reasoning`. Read from the body pi-ai
|
|
217
|
+
* builds for the session's own model (sessionOn's, at the same level), which is never sent: its payload hook stops it
|
|
218
|
+
* before any request. A save under a cap prices its least output on these (cap-short.ts). */
|
|
219
|
+
export async function piReasoningOf(route, level) {
|
|
220
|
+
const models = createModels();
|
|
221
|
+
models.setProvider(sessionProvider(route.provider.api, { url: "https://pi-reasoning.invalid", key: "unsent" }, route.model, { provider: PROVIDER, keyName: "AGENTRUN_SESSION_KEY", ...(route.like ? { like: route.like } : {}), reasoning: false }));
|
|
222
|
+
const model = models.getModel(PROVIDER, route.model);
|
|
223
|
+
if (!model)
|
|
224
|
+
throw new Error(`no session model ${route.model}`);
|
|
225
|
+
// A run's spec carries its level as the session's thinking (adapter-run-spec.ts), as here.
|
|
226
|
+
const thinking = mandatoryThinking(model, level);
|
|
227
|
+
let built;
|
|
228
|
+
const unsent = new Error("built, never sent");
|
|
229
|
+
const options = { ...(thinking && thinking !== "off" ? { reasoning: thinking } : {}), onPayload: (payload) => { built = payload; throw unsent; } };
|
|
230
|
+
await models.completeSimple(model, { messages: [{ role: "user", content: "", timestamp: 0 }] }, options).catch(() => undefined);
|
|
231
|
+
if (!built)
|
|
232
|
+
throw new Error(`pi-ai built no request for ${route.model}`);
|
|
233
|
+
return Object.fromEntries(["thinking", "output_config", "reasoning"].filter((key) => built[key] !== undefined).map((key) => [key, built[key]]));
|
|
234
|
+
}
|
|
174
235
|
/** The session on its proxy: pi's models through it, the host's tools and the gate as pi's extension, the root's state. */
|
|
175
236
|
async function sessionOn(proxy, options, spec, io, context, tiers) {
|
|
176
237
|
const { run, model, like } = options;
|
|
@@ -203,7 +264,12 @@ async function sessionOn(proxy, options, spec, io, context, tiers) {
|
|
|
203
264
|
// intent: a call it runs with no pass here is one it reruns after a crash (a replay-safe call whose intent an earlier
|
|
204
265
|
// attempt stored), told to the host tool as an attempt above 0, so the loop asks the gate about it again.
|
|
205
266
|
const passed = new Set();
|
|
206
|
-
|
|
267
|
+
// The calls asked at the gate or run in this session: a nested call among them is fresh (NestedResult), not one its
|
|
268
|
+
// record answered.
|
|
269
|
+
const touched = new Set();
|
|
270
|
+
// A refused nested call's words, by its id (pi's nested result keeps none of a refused call's output).
|
|
271
|
+
const nestedRefusals = new Map();
|
|
272
|
+
const tools = [...spec.tools.filter((tool) => !owned.has(tool.name)).map((tool) => piTool(tool, io, (callId) => (io.gate ? (passed.has(callId) ? 0 : 1) : undefined), touched, nestedRefusals)), ...(options.tools ?? [])];
|
|
207
273
|
// A refused call's words (the gate's deny, main's), by call: its result is those words alone, as main gives them.
|
|
208
274
|
const refusals = refusalWords();
|
|
209
275
|
const extension = defineExtension({
|
|
@@ -212,18 +278,20 @@ async function sessionOn(proxy, options, spec, io, context, tiers) {
|
|
|
212
278
|
hooks: [
|
|
213
279
|
hook(ToolTask, {
|
|
214
280
|
beforeTool: async (call, api, hookContext) => {
|
|
281
|
+
touched.add(call.id);
|
|
215
282
|
if (!io.gate)
|
|
216
283
|
return undefined;
|
|
217
|
-
// A
|
|
218
|
-
|
|
219
|
-
const counted = call.parent === undefined ? { callsBefore: (upTo) => callsBefore(api, call.id, upTo, hookContext), ownBudget: async () => (await api.snapshot(ConversationToolBudget, api.conversationId, hookContext))?.toolCalls } : { nested: true };
|
|
220
|
-
const answer = await io.gate({ callId: call.id, tool: call.name, args: (call.arguments ?? {}), ...counted }, hookContext);
|
|
284
|
+
// A nested call (one a tool made) is marked so: the cap's wrap-up lets it through, as its parent's part.
|
|
285
|
+
const answer = await io.gate({ callId: call.id, tool: call.name, args: (call.arguments ?? {}), ...(call.parent === undefined ? {} : { nested: true }) }, hookContext);
|
|
221
286
|
if (answer === "allow") {
|
|
222
287
|
passed.add(call.id);
|
|
223
288
|
return undefined;
|
|
224
289
|
}
|
|
225
290
|
if ("deny" in answer) {
|
|
226
291
|
refusals.refuse(call.id, answer.deny);
|
|
292
|
+
// A nested call's words for the tool that made it: pi keeps no output of a refused nested call.
|
|
293
|
+
if (call.parent !== undefined)
|
|
294
|
+
nestedRefusals.set(call.id, answer.deny);
|
|
227
295
|
return { block: answer.deny };
|
|
228
296
|
}
|
|
229
297
|
// Parked: held until pi closes the Session, so the call never reaches its intent in this process.
|
|
@@ -236,7 +304,7 @@ async function sessionOn(proxy, options, spec, io, context, tiers) {
|
|
|
236
304
|
},
|
|
237
305
|
// A call the gate refused: its result is main's words alone, an error, never pi's framing of a blocked call (its
|
|
238
306
|
// diagnostic, which the model reads as "<harness>[error] Tool call blocked: ..."). Every other result is pi's.
|
|
239
|
-
afterTool: async (call, result) => refusals.resultOf(call.id, result),
|
|
307
|
+
afterTool: async (call, result) => refusals.resultOf(call.id, result, call.parent !== undefined),
|
|
240
308
|
}),
|
|
241
309
|
// An answer's cost is the runner's booking of its request, never pi's $0 for a model it has no price for: set on
|
|
242
310
|
// the answer before pi stores it, so the answer, pi.usage and the live timeline carry it; unknown stays unknown.
|
|
@@ -255,8 +323,9 @@ async function sessionOn(proxy, options, spec, io, context, tiers) {
|
|
|
255
323
|
],
|
|
256
324
|
});
|
|
257
325
|
run.registry.install(extension);
|
|
258
|
-
// The run's pi-native extensions (options.extensions), in the claim's registry beside the session's
|
|
259
|
-
|
|
326
|
+
// The run's pi-native extensions (options.extensions), in the claim's registry beside the session's: each tool's computer
|
|
327
|
+
// calls recorded on its row (io.keepCalls), as the loop records its host tools'.
|
|
328
|
+
const native = (options.extensions ?? []).map((each) => (io.keepCalls ? recordingExtension(each, io.keepCalls) : each));
|
|
260
329
|
for (const each of native)
|
|
261
330
|
run.registry.install(each);
|
|
262
331
|
// The root conversation may exist already (the loop's session records live beside it, under it): its agent is set here,
|
|
@@ -264,8 +333,9 @@ async function sessionOn(proxy, options, spec, io, context, tiers) {
|
|
|
264
333
|
// session's tools and the run's native extensions, on every open. A conversation a native tool opens takes this agent's
|
|
265
334
|
// model (pi copies its owner's), so its requests go through this session's proxy.
|
|
266
335
|
const instructions = spec.system.join("\n\n");
|
|
267
|
-
// Its thinking level, the session's (the run's effort), on every open; none leaves pi's default.
|
|
268
|
-
const
|
|
336
|
+
// Its thinking level, the session's (the run's effort), on every open; none leaves pi's default (off).
|
|
337
|
+
const thinking = mandatoryThinking(models.getModel(PROVIDER, model), spec.thinking);
|
|
338
|
+
const agent = { model: { provider: PROVIDER, modelId: model }, extensions: [extension, ...native], ...(instructions ? { instructions } : {}), ...(thinking ? { thinkingLevel: thinking } : {}) };
|
|
269
339
|
const root = await run.harness.root(context, { agent });
|
|
270
340
|
await root.configure(agent, context);
|
|
271
341
|
// The run's input submission, if one was placed: its state says where the session is. Answered: idle. Open, or settled
|
|
@@ -363,7 +433,7 @@ export function refusalWords() {
|
|
|
363
433
|
refuse(callId, text) {
|
|
364
434
|
words.set(callId, text);
|
|
365
435
|
},
|
|
366
|
-
resultOf(callId, result) {
|
|
436
|
+
resultOf(callId, result, nested = false) {
|
|
367
437
|
const text = words.get(callId);
|
|
368
438
|
// Let go on every result: the call has its one result now, whatever it is.
|
|
369
439
|
words.delete(callId);
|
|
@@ -371,28 +441,15 @@ export function refusalWords() {
|
|
|
371
441
|
if (text === undefined || !blocked)
|
|
372
442
|
return undefined;
|
|
373
443
|
// Marked refused in its details (which the model never reads): its Timeline rows say it was refused, never that it
|
|
374
|
-
// ran and failed.
|
|
375
|
-
|
|
444
|
+
// ran and failed. A nested call's words ride its error diagnostic too, which a script's failed call reads (pi's code
|
|
445
|
+
// mode throws its message): never "Tool <name> failed".
|
|
446
|
+
return { output: [{ type: "text", text }], isError: true, details: { [CALL_REFUSED]: true }, ...(nested ? { diagnostics: [{ severity: "error", code: "blocked", message: text }] } : {}) };
|
|
376
447
|
},
|
|
377
448
|
get held() {
|
|
378
449
|
return words.size;
|
|
379
450
|
},
|
|
380
451
|
};
|
|
381
452
|
}
|
|
382
|
-
/** The tool calls a hook's conversation made before `callId`, at most `upTo`: its committed entries read oldest first, a
|
|
383
|
-
* page at a time, only as far as the count needs (tool-budget.ts countCalls). */
|
|
384
|
-
async function callsBefore(api, callId, upTo, context) {
|
|
385
|
-
let counted = { count: 0, done: upTo <= 0 };
|
|
386
|
-
let cursor;
|
|
387
|
-
while (!counted.done) {
|
|
388
|
-
const page = await api.entries({ order: "ascending" }, 100, cursor, context);
|
|
389
|
-
counted = countCalls(page.items, callId, upTo, counted.count);
|
|
390
|
-
cursor = page.next;
|
|
391
|
-
if (cursor === undefined)
|
|
392
|
-
break;
|
|
393
|
-
}
|
|
394
|
-
return counted.count;
|
|
395
|
-
}
|
|
396
453
|
/** pi's output limits for a host tool, from the host's result bound: a result within it holds at most that many
|
|
397
454
|
* characters (UTF-16 units), so at most that many lines plus one, and three bytes of UTF-8 to a character. pi's own
|
|
398
455
|
* default (50 KB or 2,000 lines, its head kept) would cut the end off a host tool's answer, where the answer says how to
|
|
@@ -400,19 +457,69 @@ async function callsBefore(api, callId, upTo, context) {
|
|
|
400
457
|
* continue". Each CLI adapter is told the same bound (harness-opencode/config.ts TOOL_OUTPUT, Claude's maxResultSizeChars,
|
|
401
458
|
* Codex's tool_output_token_limit); each host tool keeps its own answer within it (test/host-bounds.test.mjs). */
|
|
402
459
|
export const HOST_TOOL_OUTPUT = Object.freeze({ maxLines: HOST_RESULT_MAX_CHARS + 1, maxBytes: HOST_RESULT_MAX_CHARS * 3 });
|
|
460
|
+
/** pi's nested calls as a host tool's (NestedCalls): each the session's tool by its name, run as pi's own nested tool task
|
|
461
|
+
* (`executeTool`, its call id `<callId>/<key>`), whose ToolTask hooks ask the gate as the tool itself (`nested`), and
|
|
462
|
+
* whose rerun by the same key gets the recorded call back, finished or still running, never a second one. Fresh: asked
|
|
463
|
+
* at the gate or run in this session (`touched`). A refused one is the gate's words (CALL_REFUSED, from refusalWords).
|
|
464
|
+
* Each one's end goes to the host (`ended`: PiSessionIO.nestedEnded), which keeps it on the run's record. */
|
|
465
|
+
function piNested(api, context, touched, refusals, ended) {
|
|
466
|
+
return {
|
|
467
|
+
async call(name, args, key, signal) {
|
|
468
|
+
const result = await api.executeTool(name, args, signal ? withAbortSignal(signal, context) : context, { key });
|
|
469
|
+
const callId = `${api.callId}/${key}`;
|
|
470
|
+
const codes = result.diagnostics.map((one) => one.code);
|
|
471
|
+
const refused = result.details?.[CALL_REFUSED] === true || codes.includes("blocked") || codes.includes("tool_unavailable");
|
|
472
|
+
const interrupted = codes.some((code) => code === "interrupted" || code === "abandoned" || code === "restart_limit");
|
|
473
|
+
// A schema-less tool's output for programs is its output parts: its text, and the images it shows.
|
|
474
|
+
const value = result.structuredOutput;
|
|
475
|
+
const parts = Array.isArray(value) ? value : [];
|
|
476
|
+
const said = typeof value === "string" ? value : parts.map((part) => (part && typeof part === "object" && "text" in part ? String(part.text) : "")).join("");
|
|
477
|
+
const images = parts.flatMap((part) => (part?.type === "image" && typeof part.data === "string" && typeof part.mimeType === "string" ? [{ data: part.data, mimeType: part.mimeType }] : []));
|
|
478
|
+
// A host tool's value rides its result's details (piTool), recorded with it: a script's call is answered it.
|
|
479
|
+
const structured = result.details?.[HOST_VALUE];
|
|
480
|
+
// A refusal in the gate's words (this session's), or, answered from an earlier session's record, said so.
|
|
481
|
+
const words = refused ? (refusals.get(callId) ?? `${name} was refused (the run's tool settings or a person's answer), and it did not run.`) : undefined;
|
|
482
|
+
// A call a crash cut off reads in the kernel's words for an outcome not known (INTERRUPTED_TEXT), as a CLI's call cut
|
|
483
|
+
// off does on every other harness, never pi's own "Tool <name> was interrupted and may have partially run".
|
|
484
|
+
const text = words ?? (interrupted ? INTERRUPTED_TEXT : said || result.diagnostics.map((one) => one.message).join("\n"));
|
|
485
|
+
await ended?.(callId, refused ? "refused" : interrupted ? "interrupted" : result.isError ? "failed" : "done", text);
|
|
486
|
+
return {
|
|
487
|
+
text,
|
|
488
|
+
...(result.isError ? { isError: true } : {}),
|
|
489
|
+
...(!refused && images.length ? { images } : {}),
|
|
490
|
+
...(!refused && structured !== undefined ? { structured } : {}),
|
|
491
|
+
...(refused ? { refused: true } : {}),
|
|
492
|
+
...(interrupted ? { interrupted: true } : {}),
|
|
493
|
+
fresh: touched.has(callId),
|
|
494
|
+
};
|
|
495
|
+
},
|
|
496
|
+
// A value given as a function is called only while the task holds none for `key`, so a rerun never calls it again.
|
|
497
|
+
async memo(key, value) {
|
|
498
|
+
if (typeof value !== "function")
|
|
499
|
+
return api.memo(`nested:${key}`, value, context);
|
|
500
|
+
const held = await api.memo(`nested:${key}`, context);
|
|
501
|
+
return (held !== undefined ? held : await api.memo(`nested:${key}`, await value(), context));
|
|
502
|
+
},
|
|
503
|
+
};
|
|
504
|
+
}
|
|
403
505
|
/** A host tool as a pi tool: replay-safe or at most once, its answer the host's text and any images it shows, passed
|
|
404
506
|
* whole within the host's bound (HOST_TOOL_OUTPUT). Each call gets what pi's own tool task gives a tool: the calling
|
|
405
507
|
* agent's model, resolved in the session's models (its input and input limits, which a file read sizes an image by),
|
|
406
508
|
* and pi's output stream (the running tool's live slot); and its attempt (`attemptOf`: above 0 for a call the gate did
|
|
407
509
|
* not pass in this session, pi's rerun after a crash). */
|
|
408
|
-
function piTool(tool, io, attemptOf = () => undefined) {
|
|
510
|
+
function piTool(tool, io, attemptOf = () => undefined, touched = new Set(), nestedRefusals = new Map()) {
|
|
409
511
|
return defineTool({
|
|
410
512
|
name: tool.name,
|
|
411
513
|
description: tool.description,
|
|
412
514
|
parameters: tool.inputSchema,
|
|
413
|
-
|
|
515
|
+
// A tool that nests calls runs again after a crash: its nested calls are pi's own tool tasks, each answered from its
|
|
516
|
+
// record by its key (executeTool), never run twice.
|
|
517
|
+
replay: tool.replay === "safe" || tool.nests ? "safe" : "unsafe",
|
|
414
518
|
outputLimits: HOST_TOOL_OUTPUT,
|
|
519
|
+
// A catalog tool the run defers: pi never offers it, and a nested call (tools_call, a script) runs it by its name.
|
|
520
|
+
...(tool.deferred ? { deferred: true } : {}),
|
|
415
521
|
execute: async (args, api, toolContext) => {
|
|
522
|
+
touched.add(api.callId);
|
|
416
523
|
io.onEvent({ type: "tool_start", callId: api.callId, name: tool.name, args });
|
|
417
524
|
const attempt = attemptOf(api.callId);
|
|
418
525
|
const ref = (await api.agent(toolContext)).model;
|
|
@@ -422,10 +529,14 @@ function piTool(tool, io, attemptOf = () => undefined) {
|
|
|
422
529
|
...(model ? { model } : {}),
|
|
423
530
|
output: (chunk) => api.output(chunk),
|
|
424
531
|
...(attempt === undefined ? {} : { attempt }),
|
|
532
|
+
...(tool.nests ? { nested: piNested(api, toolContext, touched, nestedRefusals, io.nestedEnded) } : {}),
|
|
425
533
|
});
|
|
426
534
|
io.onEvent({ type: "tool_end", callId: api.callId, name: tool.name, isError: Boolean(answer.isError), result: answer.text });
|
|
427
535
|
const images = (answer.images ?? []).map((image) => ({ type: "image", data: image.data, mimeType: image.mimeType }));
|
|
428
|
-
|
|
536
|
+
// A nested call's (its id `<callId>/<key>`) value in the result's details (which the model never reads), recorded
|
|
537
|
+
// with it: what tools_call or a script reads (piNested). A call the model made itself keeps its result as it was.
|
|
538
|
+
const value = answer.structured !== undefined && api.callId.includes("/") ? { details: { [HOST_VALUE]: answer.structured } } : {};
|
|
539
|
+
return { output: [{ type: "text", text: answer.text }, ...images], ...(answer.isError ? { isError: true } : {}), ...value };
|
|
429
540
|
},
|
|
430
541
|
});
|
|
431
542
|
}
|
package/dist/runner/beside.d.ts
CHANGED
|
@@ -29,13 +29,15 @@ export declare function besideStopping(server: {
|
|
|
29
29
|
* too (workspace/computer-janitor.ts), as the CLI's start asks. `hub`: the server's AttachHub (Serve.attachHub), which
|
|
30
30
|
* holds each paired computer's socket in this process, so a run here takes one. Returns the runner and a close() that
|
|
31
31
|
* stops both and closes its store. */
|
|
32
|
-
export declare function runnerBeside(dataDir: string, { loops, drainMs, env, janitor, hub, mcpLoopback, onLine }?: {
|
|
32
|
+
export declare function runnerBeside(dataDir: string, { loops, drainMs, env, janitor, hub, mcpLoopback, evalFakes, harnessInstall, onLine }?: {
|
|
33
33
|
loops?: number;
|
|
34
34
|
drainMs?: number;
|
|
35
35
|
env?: NodeJS.ProcessEnv;
|
|
36
36
|
janitor?: boolean;
|
|
37
37
|
hub?: import("@parcha/agentrun-computer").AttachHub;
|
|
38
38
|
mcpLoopback?: boolean;
|
|
39
|
+
evalFakes?: (agentId: string) => import("./adapter-run-spec.js").EvalFakes | undefined;
|
|
40
|
+
harnessInstall?: import("../harness-install.js").HarnessInstaller;
|
|
39
41
|
onLine?: (line: string) => void;
|
|
40
42
|
}): Promise<{
|
|
41
43
|
runner: Awaited<ReturnType<typeof import("./runner.js")["startRunner"]>>;
|
package/dist/runner/beside.js
CHANGED
|
@@ -30,11 +30,11 @@ export function besideStopping(server, held, drainMs) {
|
|
|
30
30
|
* too (workspace/computer-janitor.ts), as the CLI's start asks. `hub`: the server's AttachHub (Serve.attachHub), which
|
|
31
31
|
* holds each paired computer's socket in this process, so a run here takes one. Returns the runner and a close() that
|
|
32
32
|
* stops both and closes its store. */
|
|
33
|
-
export async function runnerBeside(dataDir, { loops, drainMs, env, janitor, hub, mcpLoopback, onLine } = {}) {
|
|
34
|
-
const { startRunner } = await import("./runner.js");
|
|
33
|
+
export async function runnerBeside(dataDir, { loops, drainMs, env, janitor, hub, mcpLoopback, evalFakes, harnessInstall, onLine } = {}) {
|
|
34
|
+
const { runnerName, startRunner } = await import("./runner.js");
|
|
35
35
|
const { dispatchRunner } = await import("./harness-loops.js");
|
|
36
36
|
const { routeOf } = await import("./model-route.js");
|
|
37
|
-
const { openRunnerStore, runEnv, runnerComputers } = await import("./main.js");
|
|
37
|
+
const { openRunnerStore, runEnv, runnerComputers, troubleLine } = await import("./main.js");
|
|
38
38
|
// The server's store, the runner's one way in (main.ts openRunnerStore, store/open.ts): Postgres when this process's
|
|
39
39
|
// AGENTRUN_STORE_URL secret names one, else SQLite in the data directory; a schema it does not know is RunnerRefused.
|
|
40
40
|
const { store } = await openRunnerStore(dataDir, process.env, (message) => void process.stderr.write(`agentrun-serve runner: ${message}\n`), undefined);
|
|
@@ -63,18 +63,34 @@ export async function runnerBeside(dataDir, { loops, drainMs, env, janitor, hub,
|
|
|
63
63
|
const computers = runnerComputers(store, runs, seal.key, { dockerPaths: () => dockerPathsForRuns(runs, dataDir), hostAddresses: () => hostAddressesOnce(runs), hostWhy: hostCommandRefusals(PROVIDERS, process.env.PATH), ...(hub ? { hub } : {}) });
|
|
64
64
|
// `mcpLoopback`: the server beside it is a local install (Serve.localInstall), so its runs may reach an MCP server on
|
|
65
65
|
// loopback; any other runner's runs never do. A run's log lines (a learning run's skipped generality check) go to
|
|
66
|
-
// stderr with the runner's other lines.
|
|
67
|
-
|
|
66
|
+
// stderr with the runner's other lines. `evalFakes`: the template eval's fakes (EvalFakes: a case's web, now, monid and
|
|
67
|
+
// email), by the agent each of its runs is of; only the eval, in its own process, hands them. `harnessInstall`: what a
|
|
68
|
+
// claim's first-use install installs with (the eval's sharedInstaller, which the server beside it takes too).
|
|
69
|
+
const { installForClaim } = await import("../harness-install.js");
|
|
70
|
+
const createLoop = dispatchRunner({ env: runs, data: dataDir, journal: (claim) => store.journal(claim), store, sealKey: seal.key, routeOf, computerForClaim: computers.computerForClaim, computerDeps: computers.computerDeps, ...(mcpLoopback ? { mcpLoopback: true } : {}), ...(evalFakes ? { evalFakes } : {}), ...(harnessInstall ? { installForClaim: (entry, dir, pins, given) => installForClaim(entry, dir, pins, { ...given, install: harnessInstall }) } : {}), log: (line) => console.error(`agentrun-serve runner: ${line}`) });
|
|
68
71
|
// It claims by the host's memory as well as by --max-runs (memory-claim.ts): a heavy harness's run waits queued for room.
|
|
69
72
|
const { runnerMemory } = await import("./memory-claim.js");
|
|
70
73
|
// Before it claims: the scratch folders of runs that ended after their runner died (scratch-sweep.ts).
|
|
71
74
|
const { sweepEndedScratch } = await import("./scratch-sweep.js");
|
|
72
75
|
await sweepEndedScratch(store, dataDir, { log: (line) => console.error(`agentrun-serve runner: ${line}`) });
|
|
73
76
|
// Its run start and end lines go where the server's lines do (print.ts runLine), the one stdout; `onLine` is where a
|
|
74
|
-
// launcher in this process (a test) reads them instead.
|
|
77
|
+
// launcher in this process (a test) reads them instead. A claim it lost and an error (a renew or a stop that failed)
|
|
78
|
+
// are said in its name as the runner subcommand says them (main.ts troubleLine: a lost claim on stdout, an error on
|
|
79
|
+
// stderr), so a lapse of its claims shows its cause.
|
|
75
80
|
const { runLine } = await import("../print.js");
|
|
76
|
-
const
|
|
77
|
-
|
|
81
|
+
const name = runnerName();
|
|
82
|
+
const said = (event) => {
|
|
83
|
+
const trouble = troubleLine(name, event);
|
|
84
|
+
if (trouble)
|
|
85
|
+
return void (onLine ?? (event.type === "error" ? console.error : console.log))(trouble);
|
|
86
|
+
const line = runLine(event);
|
|
87
|
+
if (line)
|
|
88
|
+
(onLine ?? console.log)(line);
|
|
89
|
+
};
|
|
90
|
+
// A run's end lets go of what its earlier claims' computers left, with the same computers (run-end-computers.ts).
|
|
91
|
+
const { runEndComputers } = await import("../workspace/run-end-computers.js");
|
|
92
|
+
const runEnded = runEndComputers({ store, computers: computers.computerDeps, log: (line) => console.error(`agentrun-serve runner: ${line}`) });
|
|
93
|
+
const runner = startRunner({ store, name, createLoop, memory: runnerMemory(store), onEvent: said, runEnded, ...(loops !== undefined ? { loops } : {}), ...(drainMs !== undefined ? { drainMs } : {}) });
|
|
78
94
|
// The computer janitor over the same computers, when the start asks for it: never under --faux. Its lines are the
|
|
79
95
|
// runner's, on stderr (a stderr whose reader closed loses them, never the process: cli.ts).
|
|
80
96
|
const { startJanitor } = await import("../workspace/computer-janitor.js");
|
|
@@ -6,8 +6,10 @@ import type { Revision } from "../agent-rows.js";
|
|
|
6
6
|
/** What claimSecrets reads the keys from: the one store (its sealed keys) and the runner's seal key, and the runner's base
|
|
7
7
|
* environment (its own, with no server secret in it: those are the store's). */
|
|
8
8
|
export interface ClaimSecretsDeps {
|
|
9
|
+
/** `put`, `replaceIf`, `removeIf` and `clock` for the ChatGPT sign-in alone, which a run renews and seals again under a
|
|
10
|
+
* lease on the store's clock (chatgpt-plan.ts). */
|
|
9
11
|
readonly store: {
|
|
10
|
-
readonly sealedKeys: Pick<SealedKeys, "get">;
|
|
12
|
+
readonly sealedKeys: Pick<SealedKeys, "get" | "put" | "replaceIf" | "removeIf" | "clock">;
|
|
11
13
|
};
|
|
12
14
|
/** The runner's seal key: with none, no saved key is opened, and only the environment's values are read. */
|
|
13
15
|
readonly sealKey: Buffer | undefined;
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
// one runner never see each other's keys: each claim reads its own, into its own environment. (MCP credentials are the
|
|
8
8
|
// other per-claim secret; they come through mcp-claim.ts, which already opens them from the store under the claim.)
|
|
9
9
|
import { decisionKeysFor, providersNamed } from "../decisions.js";
|
|
10
|
-
import { GATEWAY_KEY_ENV, modelKeys, PROVIDER_KEYS, workflowNodes } from "../model.js";
|
|
10
|
+
import { GATEWAY_KEY_ENV, hostModel, modelKeys, PROVIDER_KEYS, tierModelOf, TIERS, workflowNodes } from "../model.js";
|
|
11
11
|
import { keysFor, needsOf, RUN_SECRETS } from "../run-secrets.js";
|
|
12
12
|
import { DECISION_KEYS, withoutSecrets } from "../secrets.js";
|
|
13
13
|
import { getSealedKey } from "../server-keys.js";
|
|
14
|
+
import { PLAN_PROVIDER, planOf, planReaderOf, withPlan } from "../chatgpt-plan.js";
|
|
14
15
|
import { handsParallel } from "../tool-plane.js";
|
|
15
16
|
/** Every server secret a run might be handed (runs.ts RUN_SECRETS is the tool and model keys; the decision keys go beside
|
|
16
17
|
* them). Read from the store into a working environment, then scoped to the run below. */
|
|
@@ -33,7 +34,25 @@ export async function claimSecrets(deps, revision, launch) {
|
|
|
33
34
|
const decision = decisionKeysFor(working, { providers: needs.decisionProviders, parallelWeb: launch.plane ? handsParallel(launch.plane) : false });
|
|
34
35
|
for (const [name, value] of Object.entries(decision))
|
|
35
36
|
env[name] = value;
|
|
36
|
-
|
|
37
|
+
// The server's ChatGPT sign-in, read from the store for this claim: its token is asked at each request the run's model
|
|
38
|
+
// proxy sends (chatgpt-plan.ts), never put on the environment its tools run under (a symbol no spawn copies). Only for
|
|
39
|
+
// a run that can reach a plan model: one pinned to a key's model (and its tiers on keys) never holds the sign-in, which
|
|
40
|
+
// renews and spends the person's plan for any process that holds it.
|
|
41
|
+
const plan = await planReaderOf(deps.store, deps.sealKey);
|
|
42
|
+
return plan && reachesPlan(withPlan({ ...working }, plan), scoped, revision) ? withPlan(env, plan) : env;
|
|
43
|
+
}
|
|
44
|
+
const onPlan = (model) => model?.startsWith(`${PLAN_PROVIDER}/`) === true;
|
|
45
|
+
/** Whether a run of `revision`, with `needs` scoped to its chosen model, can reach a model on the ChatGPT plan, by `env`
|
|
46
|
+
* (the claim's working environment carrying the sign-in's reader, so the host's defaults read as they would on the
|
|
47
|
+
* run): its own model (pinned, chosen at its start, or the host's default for its harness), a workflow's tiers' host
|
|
48
|
+
* models, or an agentic run's subagent tiers (its modelTiers, else the host's tier variables). A learned workflow's
|
|
49
|
+
* tiers are read once its seed chose them (tierModelKeys). */
|
|
50
|
+
function reachesPlan(env, needs, revision) {
|
|
51
|
+
const own = needs.tiers ? needs.tiers.map((tier) => hostModel(env, tier)) : [needs.model ?? hostModel(env, "default", needs.harness)];
|
|
52
|
+
// The claim's revision row carries the stored body whole (store/agent-body.ts AgenticBody), modelTiers with it.
|
|
53
|
+
const named = revision.kind === "agentic" ? Object.values(revision.body.modelTiers ?? {}) : [];
|
|
54
|
+
const tiers = revision.kind === "agentic" ? [...named, ...TIERS.map((tier) => tierModelOf(env, tier))] : [];
|
|
55
|
+
return [...own, ...tiers].some((model) => onPlan(typeof model === "string" ? model : undefined));
|
|
37
56
|
}
|
|
38
57
|
/** Every candidate secret in a working environment over the runner's base, read for one claim and scoped by its caller, so
|
|
39
58
|
* a key the run does not need is never put on the environment its tools run under. The server process's own environment
|
|
@@ -95,7 +114,11 @@ export async function tierModelKeys(deps, tiers) {
|
|
|
95
114
|
for (const name of modelKeys(working, undefined, tiers))
|
|
96
115
|
if (working[name] !== undefined)
|
|
97
116
|
out[name] = working[name];
|
|
98
|
-
|
|
117
|
+
// The ChatGPT sign-in, when a host model of those tiers is on the plan (claimSecrets gives it only to a run whose own
|
|
118
|
+
// models reach it), as a symbol withModelKeys reads, never a key.
|
|
119
|
+
const plan = await planReaderOf(deps.store, deps.sealKey);
|
|
120
|
+
const probe = withPlan({ ...working }, plan);
|
|
121
|
+
return plan && tiers.some((tier) => onPlan(hostModel(probe, tier))) ? withPlan(out, plan) : out;
|
|
99
122
|
}
|
|
100
123
|
/** Every model key a model route reads by name: each of pi-ai's providers' (model.ts PROVIDER_KEYS) and the gateway's. */
|
|
101
124
|
export const MODEL_KEY_NAMES = [...new Set([...Object.values(PROVIDER_KEYS).flat(), GATEWAY_KEY_ENV])];
|
|
@@ -128,7 +151,8 @@ export function withModelKeys(env, opened) {
|
|
|
128
151
|
}
|
|
129
152
|
for (const [name, value] of fill)
|
|
130
153
|
Object.defineProperty(out, name, { value, enumerable: false, writable: false, configurable: false });
|
|
131
|
-
|
|
154
|
+
// The claim's ChatGPT sign-in (claimSecrets), else the runner's own.
|
|
155
|
+
return withPlan(out, planOf(opened) ?? planOf(env));
|
|
132
156
|
}
|
|
133
157
|
/** Every model key the server holds, for a model route with no revision to scope it by (a learning run's grade): each
|
|
134
158
|
* by its name from `deps.env` first, then the store's sealed value, as claimSecrets reads them. */
|