@parcha/agentrun-serve 0.1.0-beta.37 → 0.1.0-beta.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +282 -0
- package/README.md +155 -92
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +39 -14
- package/dist/answer-json.d.ts +34 -1
- package/dist/answer-json.js +91 -9
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/browser-cost.js +52 -93
- package/dist/cap.d.ts +0 -390
- package/dist/cap.js +4 -937
- package/dist/catalog.js +1 -1
- package/dist/composio-preset.d.ts +17 -0
- package/dist/composio-preset.js +43 -1
- package/dist/computer-calls.d.ts +36 -24
- package/dist/computer-calls.js +110 -27
- package/dist/computer-live.d.ts +5 -0
- package/dist/computer-live.js +12 -0
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +3 -2
- package/dist/computer-view.js +5 -4
- package/dist/computer-viewer.js +26 -12
- package/dist/computers.d.ts +4 -1
- package/dist/computers.js +12 -6
- package/dist/console/assets/index-CjqQirbo.css +1 -0
- package/dist/console/assets/index-b6-XY5A9.js +576 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +3 -0
- package/dist/decisions.js +4 -0
- package/dist/faux-computers.js +4 -2
- package/dist/harness-opencode/adapter.js +7 -3
- package/dist/harness-opencode/facts.js +0 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -5
- package/dist/harness-opencode/host/policy.js +8 -32
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +0 -2
- package/dist/host-tools.d.ts +1 -5
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +0 -2
- package/dist/hosted-search.js +0 -21
- package/dist/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +6 -1
- package/dist/learn/check.js +12 -4
- package/dist/learn/commit.d.ts +10 -0
- package/dist/learn/commit.js +18 -4
- package/dist/learn/compile.d.ts +243 -0
- package/dist/learn/compile.js +471 -0
- package/dist/learn/general.d.ts +3 -0
- package/dist/learn/general.js +4 -2
- package/dist/learn/grade.d.ts +1 -1
- package/dist/learn/grade.js +7 -6
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +253 -0
- package/dist/learn/promote.js +428 -0
- package/dist/learn/refit.d.ts +39 -0
- package/dist/learn/refit.js +236 -0
- package/dist/learn/reflect.d.ts +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 +17 -9
- package/dist/learn/skills.js +132 -42
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +50 -2
- package/dist/learned-nodes.js +41 -2
- package/dist/learned-workflow.d.ts +19 -3
- package/dist/learned-workflow.js +105 -26
- package/dist/learning-batch.d.ts +2 -2
- package/dist/learning-batch.js +1 -1
- package/dist/learning-cost.d.ts +18 -6
- package/dist/learning-cost.js +15 -7
- package/dist/learning-routes.d.ts +14 -2
- package/dist/learning-routes.js +14 -3
- package/dist/learning-words.d.ts +7 -0
- package/dist/learning-words.js +7 -0
- package/dist/learning.d.ts +31 -6
- package/dist/learning.js +7 -4
- package/dist/llm.js +0 -3
- 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 +107 -0
- package/dist/mcp-probe.d.ts +8 -9
- package/dist/mcp-probe.js +16 -33
- package/dist/mcp-servers-store.d.ts +89 -22
- package/dist/mcp-servers-store.js +131 -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.d.ts +13 -0
- package/dist/model.js +46 -15
- package/dist/monid.d.ts +51 -25
- package/dist/monid.js +226 -140
- package/dist/openapi.js +336 -66
- package/dist/paid-calls.d.ts +26 -29
- package/dist/paid-calls.js +46 -102
- package/dist/propose.d.ts +7 -1
- package/dist/propose.js +18 -6
- package/dist/provider.js +9 -2
- package/dist/reflect-range.js +2 -1
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +13 -0
- package/dist/run-launch.js +6 -0
- package/dist/run-learning-served.d.ts +13 -2
- package/dist/run-manifest.d.ts +5 -0
- package/dist/run-manifest.js +20 -0
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.js +5 -2
- package/dist/run-view.d.ts +17 -6
- package/dist/run-view.js +51 -22
- package/dist/runnable.d.ts +0 -3
- package/dist/runnable.js +37 -29
- package/dist/runner/adapter-loop.d.ts +24 -10
- package/dist/runner/adapter-loop.js +852 -314
- package/dist/runner/adapter-run-spec.d.ts +12 -6
- package/dist/runner/adapter-run-spec.js +97 -46
- package/dist/runner/adapters/pi-computer.d.ts +3 -1
- package/dist/runner/adapters/pi-computer.js +13 -5
- package/dist/runner/adapters/pi.d.ts +16 -7
- package/dist/runner/adapters/pi.js +94 -33
- package/dist/runner/cli-run-spec.js +67 -27
- package/dist/runner/computer-channel.js +2 -1
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +145 -4
- package/dist/runner/conformance/subject.d.ts +11 -4
- package/dist/runner/end-of-run.d.ts +6 -5
- package/dist/runner/end-of-run.js +9 -6
- package/dist/runner/feedback-round.d.ts +52 -0
- package/dist/runner/feedback-round.js +79 -0
- package/dist/runner/journal-kinds.d.ts +24 -6
- package/dist/runner/journal-kinds.js +15 -0
- package/dist/runner/learning-end.d.ts +54 -19
- package/dist/runner/learning-end.js +272 -99
- package/dist/runner/learning-loop.d.ts +19 -1
- package/dist/runner/learning-loop.js +5 -2
- 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 +16 -1
- package/dist/runner/loop.js +21 -1
- package/dist/runner/mcp-claim.d.ts +5 -1
- package/dist/runner/mcp-claim.js +66 -50
- package/dist/runner/mcp-run.d.ts +16 -52
- package/dist/runner/mcp-run.js +12 -84
- package/dist/runner/meta-tools.d.ts +37 -0
- package/dist/runner/meta-tools.js +268 -0
- package/dist/runner/metrics.js +14 -3
- package/dist/runner/model-route.js +12 -3
- package/dist/runner/monid-run.d.ts +16 -0
- package/dist/runner/monid-run.js +96 -0
- package/dist/runner/promotion.d.ts +80 -0
- package/dist/runner/promotion.js +562 -0
- package/dist/runner/reflect-hook.d.ts +36 -21
- package/dist/runner/reflect-hook.js +138 -49
- package/dist/runner/runner.js +26 -4
- package/dist/runner/sessions.d.ts +8 -3
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +7 -12
- package/dist/runner/workflow-first.d.ts +216 -0
- package/dist/runner/workflow-first.js +303 -0
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +1 -0
- package/dist/runner/workflow-spec.js +7 -3
- package/dist/runs-over-store.d.ts +11 -2
- package/dist/runs-over-store.js +21 -11
- package/dist/server.d.ts +88 -16
- package/dist/server.js +380 -87
- package/dist/settings-wake.d.ts +8 -6
- package/dist/settings-wake.js +13 -7
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/command-wake.d.ts +3 -2
- package/dist/store/command-wake.js +4 -4
- 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/schema.d.ts +9 -0
- package/dist/store/schema.js +28 -8
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.js +19 -7
- package/dist/store/sqlite/store.js +59 -18
- package/dist/store/store.d.ts +46 -14
- package/dist/store-reads/journal.d.ts +25 -1
- package/dist/store-reads/journal.js +63 -49
- package/dist/store-reads/learning.d.ts +101 -15
- package/dist/store-reads/learning.js +195 -61
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-view.d.ts +3 -2
- package/dist/store-view.js +35 -17
- package/dist/template-eval.d.ts +18 -9
- package/dist/template-eval.js +91 -66
- 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 +218 -46
- package/dist/templates.js +493 -181
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +4 -3
- package/dist/timeline/index.js +4 -3
- package/dist/timeline/labels.d.ts +6 -2
- package/dist/timeline/labels.js +93 -2
- package/dist/timeline/origin.d.ts +19 -5
- package/dist/timeline/origin.js +11 -4
- package/dist/timeline/timeline.d.ts +11 -17
- package/dist/timeline/timeline.js +24 -9
- package/dist/tool-gate.d.ts +73 -46
- package/dist/tool-gate.js +133 -66
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +26 -0
- package/dist/tool-list.js +43 -0
- package/dist/tool-names.d.ts +71 -0
- package/dist/tool-names.js +99 -0
- package/dist/tool-plane.d.ts +29 -27
- package/dist/tool-plane.js +65 -37
- package/dist/tools.d.ts +22 -6
- package/dist/tools.js +24 -20
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +91 -44
- package/dist/web-fetch.d.ts +1 -7
- package/dist/web-fetch.js +2 -22
- package/dist/workspace/computer-deps.d.ts +3 -0
- package/dist/workspace/computer-deps.js +5 -2
- package/dist/workspace/computer-for-claim.d.ts +6 -0
- package/dist/workspace/computer-for-claim.js +32 -14
- package/dist/workspace/computer-hold.js +7 -1
- package/dist/workspace/computer-script.d.ts +23 -7
- package/dist/workspace/computer-script.js +48 -14
- package/dist/workspace/index.d.ts +2 -2
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +13 -0
- package/dist/workspace/kind-skills/phone/SKILL.md +4 -0
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +21 -1
- package/dist/workspace/resolve-computer.js +32 -14
- package/dist/workspace/run-tools.d.ts +28 -10
- package/dist/workspace/run-tools.js +39 -11
- package/dist/{tool-budget.d.ts → wrap-up.d.ts} +1 -18
- package/dist/wrap-up.js +21 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +9 -9
- package/templates/README.md +111 -45
- package/templates/code-review/agent.md +30 -14
- package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
- package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
- package/templates/code-review/evals/injection/case.yaml +2 -1
- package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
- package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
- package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
- package/templates/code-review/evals/never-flag/case.yaml +2 -1
- package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
- package/templates/code-review/evals/null-name/case.yaml +2 -1
- package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/case.yaml +2 -1
- package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/case.yaml +16 -0
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
- package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/code-review/evals/other-repo/prompt.md +10 -0
- package/templates/code-review/evals/re-review/case.yaml +2 -1
- package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
- package/templates/code-review/evals/re-review-open/case.yaml +2 -1
- package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
- package/templates/code-review/evals/repo-rule/case.yaml +2 -1
- package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
- package/templates/code-review/evals/two-defects/case.yaml +2 -1
- package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
- package/templates/code-review/rules/CODEREVIEW.md +1 -1
- package/templates/code-review/skills/review/DEEP.md +3 -2
- package/templates/code-review/skills/review/REVIEWER.md +3 -2
- package/templates/code-review/skills/review/SKILL.md +4 -3
- package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
- package/templates/inbound-lead/agent.md +26 -16
- package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
- package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
- package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
- package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
- package/templates/kyb/agent.md +15 -5
- package/templates/kyb/evals/adverse-media/prompt.md +2 -7
- package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
- package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
- package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
- package/templates/kyb/evals/name-collision/prompt.md +2 -6
- package/templates/kyb/evals/no-invention/prompt.md +2 -6
- package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
- package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
- package/templates/kyb/kyb.schema.json +8 -7
- package/templates/kyb/skills/kyb/SKILL.md +9 -6
- package/templates/market-monitor/agent.md +19 -12
- package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +32 -10
- package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/learned-style/case.yaml +2 -1
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
- package/templates/release-notes/evals/other-repo/case.yaml +24 -0
- package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
- package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
- package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/release-notes/evals/other-repo/prompt.md +32 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
- package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
- package/templates/release-notes/notes.schema.json +1 -1
- package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
- package/dist/console/assets/index-Cn6JX1uH.js +0 -563
- package/dist/console/assets/index-DRN62V5v.css +0 -1
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.js +0 -62
- 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
|
@@ -7,7 +7,7 @@ import type { LiveHandover, LiveViewerStore } from "../browser-live.js";
|
|
|
7
7
|
import { type PinnedModel, type Tier } from "../model.js";
|
|
8
8
|
import { type RunLaunch } from "../run-launch.js";
|
|
9
9
|
import type { Store } from "../store/store.js";
|
|
10
|
-
import { type Permission, type RunFiles, type SettingFrom } from "../tool-gate.js";
|
|
10
|
+
import { type ArgumentsOf, type Permission, type RunFiles, type SettingFrom, type ToolEffect } from "../tool-gate.js";
|
|
11
11
|
import { loadToolSettings } from "../tool-plane.js";
|
|
12
12
|
import { type ToolHost } from "../tools.js";
|
|
13
13
|
import { type HostToolCtx } from "../host-tools.js";
|
|
@@ -16,10 +16,12 @@ import { type ToolResults } from "../workspace/run-tools.js";
|
|
|
16
16
|
import { type ClaimMcp } from "./mcp-run.js";
|
|
17
17
|
import { type AdapterLoopOptions, type AdapterRun, type AdapterRunSpec, hostLifecycle } from "./adapter-loop.js";
|
|
18
18
|
import { type Claim, type Journal } from "./loop-contract.js";
|
|
19
|
+
import type { ReplayCalls } from "../learn/replay-calls.js";
|
|
19
20
|
import type { ModelRoute } from "./model-route.js";
|
|
20
21
|
import { type ArchilClaimOptions } from "../workspace/archil-claim.js";
|
|
21
22
|
import { type claimComputer, type ComputerDeps } from "../workspace/computer-deps.js";
|
|
22
23
|
import type { RunComputer } from "../workspace/run-tools.js";
|
|
24
|
+
import type { ScriptDecide } from "../workspace/computer-script.js";
|
|
23
25
|
import type { RunComputerHold } from "./computer-journal.js";
|
|
24
26
|
import type { ShellPlace } from "../workspace/resolve-computer.js";
|
|
25
27
|
import type { Workspace } from "../workspace/workspace.js";
|
|
@@ -179,10 +181,14 @@ export declare function adapterRunGate(store: Pick<Store, "settings">, claim: Pi
|
|
|
179
181
|
toolSettings?: unknown;
|
|
180
182
|
harness?: string;
|
|
181
183
|
approvals?: Approvals;
|
|
182
|
-
maxToolCalls?: number;
|
|
183
184
|
};
|
|
184
|
-
}, root: RunFiles, shell?: ShellPlace, mcpServers?: readonly string[]
|
|
185
|
+
}, root: RunFiles, shell?: ShellPlace, mcpServers?: readonly string[], options?: {
|
|
186
|
+
readonly computerCodemode?: boolean;
|
|
187
|
+
readonly effectOf?: (name: string) => ToolEffect | undefined;
|
|
188
|
+
readonly argumentsOf?: ArgumentsOf;
|
|
189
|
+
}): Promise<NonNullable<AdapterRunSpec["gate"]> & {
|
|
185
190
|
readonly permissions: RunPermissions;
|
|
191
|
+
readonly script: ScriptDecide;
|
|
186
192
|
readonly learn: (flows: readonly LearnedWorkflow[]) => void;
|
|
187
193
|
}>;
|
|
188
194
|
/** The server's tool settings from the store now; a read that throws is unread (no value of it said). A workflow's call
|
|
@@ -246,6 +252,8 @@ export declare function learnedWorkflowHostTool(opts: {
|
|
|
246
252
|
/** The model a node on the session's own port runs on (a node of no tier, or of a tier not in `tiers`), as the run's
|
|
247
253
|
* route names it: what its trace says it ran on. A node of a tier in `tiers` names that tier's model. */
|
|
248
254
|
readonly modelName?: (tier: string | undefined) => string | undefined;
|
|
255
|
+
/** A replay run's call nodes (runner/promotion.ts replayCallsFor): never a write run, reads cached. Absent: live. */
|
|
256
|
+
readonly replay?: ReplayCalls;
|
|
249
257
|
}): Promise<HostTool | undefined>;
|
|
250
258
|
/** The run's non-hand tools as HostTool[], bound through the ToolHost seam and wrapped as the hands are (host-tools.ts
|
|
251
259
|
* hostToolOf): web_fetch, web_search and monid, each by its catalog name under the adapter loop's one gate (`spec.gate`;
|
|
@@ -278,9 +286,7 @@ export declare function buildToolHost(opts: {
|
|
|
278
286
|
readonly life: ReturnType<typeof hostLifecycle>;
|
|
279
287
|
readonly redact: HeldRedact;
|
|
280
288
|
}): ToolHost;
|
|
281
|
-
/** The
|
|
282
|
-
export declare const webToolNames: (granted: readonly string[]) => string[];
|
|
283
|
-
/** The run's web host tools (webToolNames: web_fetch, web_search, monid) as HostTool[], each bound through `host` by its
|
|
289
|
+
/** The run's web host tools (tool-list.ts `host` rows: web_fetch, web_search, monid) as HostTool[], each bound through `host` by its
|
|
284
290
|
* catalog name and wrapped as the hands are (host-tools.ts hostToolOf, with `ctx`), the one binding the pi spec and the
|
|
285
291
|
* CLI spec share. Each runs under the adapter loop's one gate (spec.gate) on the claim's keys (host.env), and books its
|
|
286
292
|
* paid requests on the run's one ledger itself (bookedIn): they carry no settle of their own. */
|
|
@@ -6,18 +6,18 @@ 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 } from "../run-manifest.js";
|
|
10
10
|
import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
11
|
-
import {
|
|
11
|
+
import { isWebHostTool } from "../tool-list.js";
|
|
12
12
|
import { deniedText, mcpServersOf, 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
18
|
import { environmentLine } from "../environment.js";
|
|
20
19
|
import { effortGuidance } from "../effort-guidance.js";
|
|
20
|
+
import { outputContract } from "../answer-json.js";
|
|
21
21
|
import { laidLearned, learningFolderOf, secretsShown } from "../learning.js";
|
|
22
22
|
import { laidOf, layLearningSeed } from "./learning-seed.js";
|
|
23
23
|
import { learningWorkspace } from "../learn/folder.js";
|
|
@@ -42,12 +42,16 @@ import { agentEntriesOf } from "./loop.js";
|
|
|
42
42
|
import { SUBAGENT_TIERS, SUBAGENT_TOOL, subagentTool } from "./subagent.js";
|
|
43
43
|
import { wireName } from "../catalog.js";
|
|
44
44
|
import { ClaimRefused } from "./loop-contract.js";
|
|
45
|
-
import { bookedSpend, runEndCost, runMetrics } from "./metrics.js";
|
|
45
|
+
import { bookedSpend, cliRunMetrics, runEndCost, runMetrics } from "./metrics.js";
|
|
46
46
|
import { journalEntries } from "./journal-reader.js";
|
|
47
|
+
import { piShaped } from "../store-reads/journal.js";
|
|
48
|
+
import { claimPromotion, promotionGate, replayCallsFor, replayClaimed, replayLaid } from "./promotion.js";
|
|
49
|
+
import { laidFor, pathMetrics, servedOf, workflowFirstOf } from "./workflow-first.js";
|
|
50
|
+
import { pastRunsOverStore, runPathOverStore } from "../store-reads/learning.js";
|
|
47
51
|
import { specBuilt } from "./spec-holds.js";
|
|
48
52
|
import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
49
53
|
import { loadArchilSettings } from "../archil-settings.js";
|
|
50
|
-
import { computerReadyWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
54
|
+
import { computerReadyWords, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
51
55
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
52
56
|
import { heldSpecOf } from "./held-run.js";
|
|
53
57
|
import { loopComputerOf } from "./computer-channel.js";
|
|
@@ -55,6 +59,7 @@ import { githubAppAccess } from "./github-app.js";
|
|
|
55
59
|
import { prCheckoutForClaim } from "./pr-checkout.js";
|
|
56
60
|
import { holdStored, storeSecrets } from "./store-secrets.js";
|
|
57
61
|
import { bashPolicyOf } from "../bash-read-only.js";
|
|
62
|
+
import { monidForClaim, monidSessionNames, withMonid } from "./monid-run.js";
|
|
58
63
|
/** The wires pi speaks on the runner: main's pi's (provider.ts), Anthropic's Messages and OpenAI's Responses. */
|
|
59
64
|
export const PI_WIRES = Object.freeze(["anthropic-messages", "openai-responses"]);
|
|
60
65
|
/** The browser's catalog name (tools.ts TOOLS.browser). */
|
|
@@ -96,7 +101,7 @@ const isSubagentRoute = (key) => key.startsWith(SUBAGENT_ROUTE);
|
|
|
96
101
|
export function modelAskOf(pinned, ref) {
|
|
97
102
|
return pinned ? { pinned, ...(ref ? { ref } : {}) } : ref;
|
|
98
103
|
}
|
|
99
|
-
export async function adapterRunGate(store, claim, revision, root, shell, mcpServers = []) {
|
|
104
|
+
export async function adapterRunGate(store, claim, revision, root, shell, mcpServers = [], options = {}) {
|
|
100
105
|
let current = await storeSettings(store);
|
|
101
106
|
const approvers = await readApprovers(store.settings);
|
|
102
107
|
// A Workspace's paths are in the run's folder: its folder named as a computer names it, for the gate's path checks.
|
|
@@ -105,7 +110,14 @@ export async function adapterRunGate(store, claim, revision, root, shell, mcpSer
|
|
|
105
110
|
// default (tool-gate.ts defaultPermission): bash asks first, the background tools are refused. The run's MCP servers
|
|
106
111
|
// (mcpServersOf its grants), so a harness naming an MCP tool its own way (OpenCode's `<server>_<tool>`) is held to that
|
|
107
112
|
// tool's settings, never to a table tool's of the same shape.
|
|
108
|
-
|
|
113
|
+
// An MCP tool's effect as the run's pin marks it (ClaimMcp.effectOf): what "allow reads" lifts an ask by.
|
|
114
|
+
// pi's code mode on a desktop or a phone (pi-computer.ts) owns the name `codemode` there: held to the kind's setting.
|
|
115
|
+
const where = { root: folder, work: folder, mcpServers, ...(options.computerCodemode ? { computerCodemode: true } : {}), ...(options.effectOf ? { effectOf: options.effectOf } : {}), ...(options.argumentsOf ? { argumentsOf: options.argumentsOf } : {}) };
|
|
116
|
+
const gate = runGate({ ...where, ...(shell === undefined ? {} : { computer: shell === "computer" }) }, claim.runId, revision, () => current, approvers);
|
|
117
|
+
// A script's computer calls (computer_script, pi's code mode) run on the run's computer, a desktop that mounts no folder
|
|
118
|
+
// too: decided as on a computer, so its shell.run and processes.start follow bash's one setting alike. The run's own
|
|
119
|
+
// host tools keep `gate`, where its bash is (Archil's exec, or none).
|
|
120
|
+
const onComputer = runGate({ ...where, computer: true }, claim.runId, revision, () => current, approvers);
|
|
109
121
|
// The run's learned workflows, once its spec has read them (learn): a learned_workflow call is asked about its MCP nodes.
|
|
110
122
|
let learned = [];
|
|
111
123
|
const decide = async (call, options = {}) => {
|
|
@@ -150,8 +162,6 @@ export async function adapterRunGate(store, claim, revision, root, shell, mcpSer
|
|
|
150
162
|
const asks = (await mcpOf(args)).filter((one) => gate.policy(one) === "ask");
|
|
151
163
|
return asks.length ? learnedAskShown(asks) : undefined;
|
|
152
164
|
};
|
|
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;
|
|
155
165
|
// A tool's setting now, read from the store as each call's is (SessionIO.permission: Codex's live search, which runs
|
|
156
166
|
// 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
167
|
// allow: a deny saved since may be in what did not read, and no call reaches the gate to say otherwise.
|
|
@@ -159,7 +169,12 @@ export async function adapterRunGate(store, claim, revision, root, shell, mcpSer
|
|
|
159
169
|
current = await storeSettings(store);
|
|
160
170
|
return current.unreadable ? "deny" : gate.policy(tool);
|
|
161
171
|
};
|
|
162
|
-
|
|
172
|
+
// A script's computer call, held as the tool it is (computer-script.ts HELD_AS), with the settings read from the store now.
|
|
173
|
+
const script = async (tool, args) => {
|
|
174
|
+
current = await storeSettings(store);
|
|
175
|
+
return onComputer.decide(tool, args);
|
|
176
|
+
};
|
|
177
|
+
return Object.assign(decide, { askedAs: (tool) => gate.askedAs(tool), askedFor, permissions, permission, script, learn: (flows) => void (learned = flows) });
|
|
163
178
|
}
|
|
164
179
|
/** 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
180
|
* and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
|
|
@@ -231,9 +246,9 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
231
246
|
// person's stop ends the fetch at once (run.stopped).
|
|
232
247
|
const checkout = body.checkout === "pull_request" ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part })) : undefined;
|
|
233
248
|
holds.hold({ checkout });
|
|
234
|
-
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin
|
|
249
|
+
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
|
|
235
250
|
// 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
|
|
251
|
+
// 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
252
|
// words before the session opens. The seal key is the runner's own (deps.sealKey), not re-read from the environment.
|
|
238
253
|
// A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor.
|
|
239
254
|
const hold = (values) => cut.hold(values);
|
|
@@ -247,7 +262,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
247
262
|
// revokeMount removes the run's Archil mount credential when the computer is released (and if a start fails after a mint);
|
|
248
263
|
// the run's end revokes it too (below), so it goes on every outcome even when no computer is made. Idempotent. What
|
|
249
264
|
// became of the agent's own computer (a persistent setting) is said on the run's timeline.
|
|
250
|
-
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, ...(archil ? { revokeMount: () => archil.revoke() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
|
|
265
|
+
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, ...(archil ? { revokeMount: () => archil.revoke() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
|
|
251
266
|
// 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
267
|
// (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
268
|
// 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,
|
|
@@ -257,7 +272,9 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
257
272
|
const heldComputer = heldSpecOf(launch, loopComputer);
|
|
258
273
|
// Under the agent's bash policy, its shell's environment is the policy's too (bash-read-only.ts policyEnv).
|
|
259
274
|
const bashPolicy = bashPolicyOf(body.toolSettings);
|
|
260
|
-
|
|
275
|
+
// pi's codemode is its script tool (codeMode): a code-only computer lists no computer_script beside it, and a
|
|
276
|
+
// tools-only one gets no codemode (tools.computer is absent then).
|
|
277
|
+
const tools = await runTools(ws.workspace, computer.computer, { mode, context, codeMode: true, ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }) });
|
|
261
278
|
holds.hold({ tools });
|
|
262
279
|
// The run's model route: its model through routeOf (NEVER re-resolved — the launch's model, pinned at start), the catalog
|
|
263
280
|
// price with tiers for the cap, and the proxy's price (pi-ai calculateCost, tiered).
|
|
@@ -282,8 +299,8 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
282
299
|
// - 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
300
|
// task under the session's gate and keeps its control.terminate — the turn ends on the person's question and the loop
|
|
284
301
|
// 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
|
-
//
|
|
302
|
+
// (adapter-loop waitInClaim, the browser's personWait below). It stays out of this session's host tools: a CLI
|
|
303
|
+
// harness gets the same tool as a host tool (cli-run-spec.ts), whose turn the loop cuts at the question.
|
|
287
304
|
// - the browser's durable extension, when the run gets one (bindNonHandTools, below, before the session opens).
|
|
288
305
|
// - pi's code mode, with a desktop or a phone (pi-computer.ts): the `codemode` tool beside the run's own, its scripts
|
|
289
306
|
// with `computer` bound on the run's held port.
|
|
@@ -339,12 +356,11 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
339
356
|
const root = runFolder(deps.data, runRow.agentId, claim.runId);
|
|
340
357
|
// 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
358
|
// the same path), for its path checks; it reads nothing in it.
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
});
|
|
359
|
+
// A pinned MCP tool is held to the arguments its listing in the run's pin declares (mcp.argumentsOf).
|
|
360
|
+
const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, mcpServersOf(granted), { computerCodemode: Boolean(tools.computer), ...(mcp ? { effectOf: (name) => mcp.effectOf(name), argumentsOf: (name) => mcp.argumentsOf(name) } : {}) });
|
|
361
|
+
// What a script's shell and files are held to: this gate's settings, decided as on the run's computer (gate.script), so a
|
|
362
|
+
// denied bash or write holds inside computer_script and codemode.
|
|
363
|
+
tools.computer?.guard.install(gate.script);
|
|
348
364
|
// The run's one cap, as the loop's runCap reads it (adapter-loop.ts RunCapConfig): the launch's cap figure (undefined
|
|
349
365
|
// uncapped — every paid request still books through the one cap), the run's model priced WITH tiers, strict where the
|
|
350
366
|
// launch says. The loop builds the kernel runCap from these over the run's own sessions (its model requests, its paid
|
|
@@ -395,13 +411,15 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
395
411
|
// and its learned skills beside the revision's own (runner/learning-seed.ts), cut of the server's secrets, the learned
|
|
396
412
|
// skills then in the skill list the prompt names, its learned workflows the ones its learned_workflow tool runs. Laid
|
|
397
413
|
// before the run's tools are bound. A learning fault, or a seed that failed (seedFailed), lays nothing.
|
|
414
|
+
const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
|
|
415
|
+
const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
|
|
398
416
|
const seedLaid = start && !seedFailed(start)
|
|
399
417
|
? await layLearningSeed({
|
|
400
418
|
work: ws.workspace,
|
|
401
419
|
seed: start.seed,
|
|
402
|
-
folder:
|
|
420
|
+
folder: learningFolder,
|
|
403
421
|
own: Object.keys(revisionRow.skills ?? {}),
|
|
404
|
-
shown
|
|
422
|
+
shown,
|
|
405
423
|
log,
|
|
406
424
|
...(start.notesOnly ? { workflows: false } : {}),
|
|
407
425
|
...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
|
|
@@ -411,7 +429,23 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
411
429
|
// 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
430
|
// onto the tools' environment alone. The model's route was built on the revision's keys above, so a decision key never
|
|
413
431
|
// becomes its model's.
|
|
414
|
-
|
|
432
|
+
// A replay run lays the workflow it replays record-only (runner/promotion.ts replayLaid).
|
|
433
|
+
const laidFlows = replayLaid(launch, seedLaid?.workflows ?? []);
|
|
434
|
+
// The learned workflow the run starts on, before its agent's first turn, when one fits its input (workflow-first.ts),
|
|
435
|
+
// chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
|
|
436
|
+
// serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
|
|
437
|
+
// five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
|
|
438
|
+
// (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the run asks for its revision.
|
|
439
|
+
const firstChoice = learnsWorkflows(revision.kind, laidFlows) ? await workflowFirstOf(revision.kind, laidFlows, launch, log, () => pastRunsOverStore(deps.store, runRow.agentId), promotionGate(claimPromotion({
|
|
440
|
+
store: deps.store, agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, launch, context, log, folder: learningFolder, shown, sealKey: deps.sealKey,
|
|
441
|
+
})), revision.body.outputSchema) : {};
|
|
442
|
+
// A replay run runs only its revision, while it still replays: else its claim is refused (the run ends failed, no agent).
|
|
443
|
+
await replayClaimed(deps.store, runRow.agentId, launch, firstChoice);
|
|
444
|
+
// A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
|
|
445
|
+
// answered from that recording (runner/promotion.ts replayCallsFor, learn/replay-calls.ts).
|
|
446
|
+
const replay = await replayCallsFor(deps.store, claim.runId, launch, context);
|
|
447
|
+
const { serve: workflowFirst, revise: workflowRevise } = firstChoice;
|
|
448
|
+
const workflows = laidFor(laidFlows, firstChoice);
|
|
415
449
|
// 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
450
|
// node fails in those words (learnedWorkflowHostTool), never on another model.
|
|
417
451
|
const tierUnreachable = new Map();
|
|
@@ -450,18 +484,23 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
450
484
|
const tiers = new Map([...[...tierRoutes].filter(([tier]) => !isSubagentRoute(tier)).map(([tier, { model }]) => [tier, { model }]), ...[...tierUnreachable].map(([tier, why]) => [tier, { why }])]);
|
|
451
485
|
// The gate asks a learned_workflow call about its workflow's MCP nodes (adapterRunGate).
|
|
452
486
|
gate.learn(workflows);
|
|
453
|
-
|
|
487
|
+
// The run's monid endpoints (monid-run.ts), one host tool each from its revision's pin, on the claim's keys and beside
|
|
488
|
+
// its MCP tools in the loop's one catalog seam; their answers pass the run's one redactor as the other non-hand tools'.
|
|
489
|
+
const monid = monidForClaim(body.monidPin, toolEnv, () => ws.workspace, claim.runId);
|
|
490
|
+
const catalog = withMonid(mcp, monid && { ...monid, tools: monid.tools.map((tool) => answersCut(tool, cut)) });
|
|
491
|
+
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
492
|
const sessionTools = [...handTools, ...nonHandTools];
|
|
455
493
|
// The run's system prompt, as main's per-run process builds it (app.ts): the environment line first (environment.ts, as
|
|
456
494
|
// pi installs it before every other section), then the revision's instructions with what the agent learned laid in
|
|
457
495
|
// (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
|
-
//
|
|
496
|
+
// reads no learning folder), its own skills through skills.ts promptOf, the output schema it answers in (answer-json.ts
|
|
497
|
+
// outputContract, the CLI spec's too), then the effort guidance (the launch's effort, never this process's environment).
|
|
498
|
+
// The one path for every harness.
|
|
460
499
|
// A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
|
|
461
500
|
const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section, start.use === true) : (body.instructions ?? "");
|
|
462
501
|
const instructions = await promptOf(laid, [...Object.keys(body.skills ?? {}), ...(seedLaid?.skills ?? [])], ws.workspace, { onDemand: readsFiles(granted) });
|
|
463
502
|
const guidance = effortGuidance(launch.effort);
|
|
464
|
-
const system = [environmentLine(), checkout?.note, instructions, guidance].filter((line) => Boolean(line));
|
|
503
|
+
const system = [environmentLine(), checkout?.note, instructions, outputContract(body.outputSchema), guidance].filter((line) => Boolean(line));
|
|
465
504
|
// 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
505
|
// revision's grants (each by its session name: an MCP tool's wire name, the browser's registrations), its model the
|
|
467
506
|
// agent's own or one of the tiers resolved above.
|
|
@@ -469,7 +508,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
469
508
|
const browserNames = native.filter((extension) => extension.name !== "ask_person").flatMap((extension) => (extension.tools ?? []).map((tool) => tool.name));
|
|
470
509
|
piTools.push(subagentTool({
|
|
471
510
|
granted,
|
|
472
|
-
sessionNames: (catalog) => (catalog === BROWSER_TOOL ? browserNames : [wireName(catalog)]),
|
|
511
|
+
sessionNames: (catalog) => (catalog === BROWSER_TOOL ? browserNames : monidSessionNames(catalog, body.monidPin) ?? [wireName(catalog)]),
|
|
473
512
|
tier: (tier) => {
|
|
474
513
|
const why = tierWhy.get(tier);
|
|
475
514
|
if (why !== undefined)
|
|
@@ -484,7 +523,6 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
484
523
|
return { ref: { provider: tierProvider(subagentRoute(tier)), modelId: at.model } };
|
|
485
524
|
},
|
|
486
525
|
preamble: environmentLine(),
|
|
487
|
-
...(revision.body.maxToolCalls !== undefined ? { toolCalls: revision.body.maxToolCalls } : {}),
|
|
488
526
|
}));
|
|
489
527
|
}
|
|
490
528
|
// 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 +538,15 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
500
538
|
};
|
|
501
539
|
// The person's first message: the start body's content, with the run's file manifest beside it (run-manifest.ts), read
|
|
502
540
|
// through the run's Workspace (Mode 2: its inputs/ on the disk, never a folder of this machine).
|
|
503
|
-
|
|
504
|
-
const input = await firstMessage(
|
|
541
|
+
// A typed input's other fields follow its content as one json block (inputMessage).
|
|
542
|
+
const input = await firstMessage(inputMessage(launch.input), ws.workspace);
|
|
505
543
|
// The run's end-of-run step, when it learns (learningEndOfRun from the launch's learning start; none otherwise): the
|
|
506
544
|
// reflect-and-propose turn over the run's store, asked in the end turn while the claim is held (adapter-loop.ts stepOf).
|
|
507
545
|
// 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
546
|
// agent's folder on THIS claim's Archil disk (the proposal is checked against the seed on the disk, never this machine's
|
|
509
547
|
// local path) — so the end-of-run step reads the run's own Workspace, the one the run worked in.
|
|
510
|
-
|
|
548
|
+
// A replay run asks nothing at its end: it is the promotion's, never the agent's to learn from.
|
|
549
|
+
const endOfRun = launch.replay ? undefined : learningEndOfRun(launch, {
|
|
511
550
|
store: deps.store,
|
|
512
551
|
data: deps.data,
|
|
513
552
|
...(deps.env ? { env: deps.env } : {}),
|
|
@@ -517,6 +556,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
517
556
|
signIns: signInReads(deps.store, deps.sealKey),
|
|
518
557
|
handed: runnerSecrets(toolEnv),
|
|
519
558
|
stored: () => storeSecrets(deps.store, deps.sealKey, deps.data),
|
|
559
|
+
log,
|
|
520
560
|
// A workflow draft's decision nodes are checked against the host's decision providers, on its keys (LS-07).
|
|
521
561
|
decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, DECISION_PROVIDER_KEYS)) }),
|
|
522
562
|
learningFolder: archil === undefined
|
|
@@ -533,12 +573,17 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
533
573
|
// sent or charged, and a pinned MCP tool's call outside its pin is refused before it is asked or sent.
|
|
534
574
|
gate,
|
|
535
575
|
runCap,
|
|
576
|
+
// The answer's schema: a miss is asked again once (adapter-loop.ts, the output contract's retry).
|
|
577
|
+
...(body.outputSchema !== undefined ? { outputSchema: body.outputSchema } : {}),
|
|
536
578
|
...(cap ? { cap } : {}),
|
|
537
|
-
// The run's MCP for a harness with its own client (mcp-run.ts),
|
|
538
|
-
|
|
579
|
+
// The run's MCP for a harness with its own client (mcp-run.ts), with its monid endpoints beside it (monid-run.ts):
|
|
580
|
+
// the catalog tools the session mounts; absent when none.
|
|
581
|
+
...(catalog ? { mcp: catalog } : {}),
|
|
539
582
|
// 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
583
|
...(endOfRun ? { endOfRun } : {}),
|
|
541
584
|
...(start ? { learningLaid: laidOf(seedLaid) } : {}),
|
|
585
|
+
...(workflowFirst ? { workflowFirst } : {}),
|
|
586
|
+
...(workflowRevise ? { workflowRevise } : {}),
|
|
542
587
|
// The tool host's install lifecycle (its bindings' onConversation/beforeResume/beforeRelease), run by the adapter loop.
|
|
543
588
|
lifecycle: life,
|
|
544
589
|
agentId: runRow.agentId,
|
|
@@ -551,18 +596,26 @@ async function adapterSpec(launch, run, deps, claim, holds) {
|
|
|
551
596
|
endPatch: async () => {
|
|
552
597
|
// 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
598
|
const entries = await agentEntriesOf(deps.journal(claim), context);
|
|
554
|
-
|
|
599
|
+
// The path it took and the learned revision it ran on, for a run that learns (workflow-first.ts pathMetrics), by the
|
|
600
|
+
// one classifier the cost per run reads back (runPathOverStore).
|
|
601
|
+
const path = pathMetrics(launch, launch.learning ? await runPathOverStore(deps.store, claim.runId, launch.learning, run.redact) : undefined, entries);
|
|
555
602
|
// Its cost is its booking's, as a CLI run's is (metrics.ts bookedSpend, the one reader): every model request its
|
|
556
603
|
// session's proxy booked, pi's own answers and its side calls (a learned workflow's nodes, web_search's hosted search
|
|
557
604
|
// with its fee) alike, and its decisions (a learned workflow's decision nodes, LS-07; one that reported none is
|
|
558
605
|
// unknown, never the cap's hold for it). A request a cancel or a stop cut while it streamed is booked at no known cost
|
|
559
606
|
// (the provider may bill what it streamed), so the run's cost is unknown, never the $0 its cut answer carries.
|
|
560
607
|
const all = (await journalEntries(deps.journal(claim), context));
|
|
608
|
+
const booked = bookedSpend(all, "model");
|
|
561
609
|
// Its paid tool calls (a Parallel search's, a monid call's, a person's browser time), booked on the run's one ledger
|
|
562
610
|
// (each on its cap, in its own session, not on the root), are the run's cost too; any part unknown leaves the run's unknown.
|
|
563
|
-
const total = runEndCost({ model:
|
|
611
|
+
const total = runEndCost({ model: booked.usd, paid: run.ledger?.paid ? run.ledger.paid.spentUsd() : 0, decisions: bookedSpend(all, "decisions").usd });
|
|
612
|
+
// A run its learned workflow served first: that call is on the loop's record (no pi answer carries its tokens), so its
|
|
613
|
+
// 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.
|
|
614
|
+
const { metrics } = servedOf(entries)
|
|
615
|
+
? { metrics: cliRunMetrics(piShaped(entries), booked, { ...(launch.effort !== undefined ? { effort: launch.effort } : {}), model: launch.model ? `${launch.model.provider}/${launch.model.modelId}` : route.model }) }
|
|
616
|
+
: runMetrics(entries, { ...(launch.effort !== undefined ? { effort: launch.effort } : {}) });
|
|
564
617
|
// An unknown cost is written as null, never left out: a follow-up's end clears the cost an earlier end stored.
|
|
565
|
-
return { costUsd: total, metrics };
|
|
618
|
+
return { costUsd: total, metrics: { ...metrics, ...path } };
|
|
566
619
|
},
|
|
567
620
|
// A run started with hold: true holds its computer for its owner (computer-held.ts): the loop waits for their start
|
|
568
621
|
// and release, and runs their calls on it.
|
|
@@ -665,7 +718,7 @@ export async function learnedWorkflowHostTool(opts) {
|
|
|
665
718
|
const providers = await decisionProvidersIn(opts.env);
|
|
666
719
|
const decisions = providers ? { decisions: { providers, book: opts.run.ledger.decisions, pause: (refusal) => opts.run.ledger.pause(refusal) } } : {};
|
|
667
720
|
// A call node's native web_search goes through the session's port too, labelled web_search, as the run's own does.
|
|
668
|
-
const tool = learnedWorkflowTool({ workflows: flows, granted: opts.granted, ...(opts.plane ? { plane: opts.plane } : {}), env: opts.env, work: opts.work, models: tieredModels(byProvider), modelOf, search: () => opts.run.ledger.models(WEB_SEARCH_TOOL), policy: opts.permissions.policy, denyFrom: opts.permissions.denyFrom, refresh: opts.permissions.refresh, decide: opts.permissions.decide, mcpTools, ...decisions, ...(opts.workspace ? { workspace: opts.workspace } : {}), ...(opts.modelName ? { modelName: opts.modelName } : {}) });
|
|
721
|
+
const tool = learnedWorkflowTool({ workflows: flows, granted: opts.granted, ...(opts.plane ? { plane: opts.plane } : {}), env: opts.env, work: opts.work, models: tieredModels(byProvider), modelOf, search: () => opts.run.ledger.models(WEB_SEARCH_TOOL), policy: opts.permissions.policy, denyFrom: opts.permissions.denyFrom, refresh: opts.permissions.refresh, decide: opts.permissions.decide, mcpTools, ...decisions, ...(opts.workspace ? { workspace: opts.workspace } : {}), ...(opts.modelName ? { modelName: opts.modelName } : {}), ...(opts.replay ? { replay: opts.replay } : {}) });
|
|
669
722
|
return hostToolOf(LEARNED_WORKFLOW_TOOL, tool, opts.ctx) ?? undefined;
|
|
670
723
|
}
|
|
671
724
|
/** The run's non-hand tools as HostTool[], bound through the ToolHost seam and wrapped as the hands are (host-tools.ts
|
|
@@ -747,15 +800,13 @@ export function buildToolHost(opts) {
|
|
|
747
800
|
workspace: opts.workspace,
|
|
748
801
|
};
|
|
749
802
|
}
|
|
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
|
|
803
|
+
/** 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
804
|
* catalog name and wrapped as the hands are (host-tools.ts hostToolOf, with `ctx`), the one binding the pi spec and the
|
|
754
805
|
* 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
806
|
* paid requests on the run's one ledger itself (bookedIn): they carry no settle of their own. */
|
|
756
807
|
export async function webHostTools(host, granted, ctx) {
|
|
757
808
|
const tools = [];
|
|
758
|
-
for (const name of
|
|
809
|
+
for (const name of granted.filter(isWebHostTool)) {
|
|
759
810
|
const entry = toolOf(name);
|
|
760
811
|
if (!entry)
|
|
761
812
|
continue;
|
|
@@ -768,7 +819,7 @@ export async function webHostTools(host, granted, ctx) {
|
|
|
768
819
|
}
|
|
769
820
|
return tools;
|
|
770
821
|
}
|
|
771
|
-
async function bindNonHandTools(host, kind, granted, run, context, results, root, plane, workflows, native, permissions, tiers, mcp, modelName) {
|
|
822
|
+
async function bindNonHandTools(host, kind, granted, run, context, results, root, plane, workflows, native, permissions, tiers, mcp, modelName, replay) {
|
|
772
823
|
// Fail closed (browserListed): the browser binds only on the native route (BROWSER_ON_RUNNER) and with the claim's
|
|
773
824
|
// one-ledger booking on its ToolHost (host.ledger.paid); otherwise its extension is not installed. learned_workflow
|
|
774
825
|
// binds below with no web tool, so a learned run with no web tool still lists it.
|
|
@@ -781,7 +832,7 @@ async function bindNonHandTools(host, kind, granted, run, context, results, root
|
|
|
781
832
|
// the session's tools the harness is told of: its model nodes run on the session's proxied models (run.ledger.models),
|
|
782
833
|
// each a request on the run's one route labelled learned_workflow. The agent's scoped keys (host.env) are its call
|
|
783
834
|
// 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 } : {}) });
|
|
835
|
+
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
836
|
if (learned)
|
|
786
837
|
tools.push(learned);
|
|
787
838
|
// The browser (tl-browser), on pi's native route: tools.ts's own binding on this run's ToolHost (its store, claim and seal
|
|
@@ -3,5 +3,7 @@ import { type ScriptComputer } from "../../workspace/index.js";
|
|
|
3
3
|
/** The code mode tool's name, as the model calls it and the gate reads it. */
|
|
4
4
|
export declare const PI_CODEMODE_TOOL = "codemode";
|
|
5
5
|
/** pi's code mode extension with `computer` bound to `computer`'s surface: install it among the run's pi-native
|
|
6
|
-
* extensions (PiAdapterOptions.extensions). No `models.*` in scripts: a script's paid work is the run's own tools.
|
|
6
|
+
* extensions (PiAdapterOptions.extensions). No `models.*` in scripts: a script's paid work is the run's own tools.
|
|
7
|
+
* Where no computer_script is listed (a code-only computer: `computer.declare`), the codemode tool's description
|
|
8
|
+
* declares `computer` as computer_script's would; otherwise computer_script's declares it once. */
|
|
7
9
|
export declare function computerCodemode(computer: ScriptComputer): Extension;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CodemodeSandbox } from "@earendil-works/pi-codemode";
|
|
2
2
|
import { CODEMODE_TOOL_NAME, createCodemodeExtension } from "@earendil-works/pi-durable/codemode";
|
|
3
|
-
import { COMPUTER_CALL_GLOBAL
|
|
3
|
+
import { COMPUTER_CALL_GLOBAL } from "@parcha/agentrun-computer/surface";
|
|
4
|
+
import { computerDeclarations } from "@parcha/agentrun-kernel/kernel";
|
|
4
5
|
import { SCRIPT_MAX_MS } from "../../workspace/index.js";
|
|
5
6
|
/** The code mode tool's name, as the model calls it and the gate reads it. */
|
|
6
7
|
export const PI_CODEMODE_TOOL = CODEMODE_TOOL_NAME;
|
|
@@ -21,14 +22,17 @@ class PreludedSandbox extends CodemodeSandbox {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
/** pi's code mode extension with `computer` bound to `computer`'s surface: install it among the run's pi-native
|
|
24
|
-
* extensions (PiAdapterOptions.extensions). No `models.*` in scripts: a script's paid work is the run's own tools.
|
|
25
|
+
* extensions (PiAdapterOptions.extensions). No `models.*` in scripts: a script's paid work is the run's own tools.
|
|
26
|
+
* Where no computer_script is listed (a code-only computer: `computer.declare`), the codemode tool's description
|
|
27
|
+
* declares `computer` as computer_script's would; otherwise computer_script's declares it once. */
|
|
25
28
|
export function computerCodemode(computer) {
|
|
26
|
-
const sandbox = new PreludedSandbox(
|
|
27
|
-
|
|
29
|
+
const sandbox = new PreludedSandbox(computer.prelude, { timeoutMs: SCRIPT_MAX_MS, memoryLimitBytes: MEMORY_BYTES });
|
|
30
|
+
const extension = createCodemodeExtension({
|
|
28
31
|
sandbox,
|
|
29
32
|
models: false,
|
|
30
33
|
// No tool listed again in the system prompt's codemode section: every tool is offered as itself (code mode "on"),
|
|
31
|
-
// computer_script's description declares `computer` once
|
|
34
|
+
// computer_script's description declares `computer` once (where none is listed, this tool's own, below), and a
|
|
35
|
+
// script finds any other with searchTools().
|
|
32
36
|
inlineBudget: 0,
|
|
33
37
|
globals: [{
|
|
34
38
|
name: COMPUTER_CALL_GLOBAL,
|
|
@@ -40,4 +44,8 @@ export function computerCodemode(computer) {
|
|
|
40
44
|
},
|
|
41
45
|
}],
|
|
42
46
|
});
|
|
47
|
+
if (!computer.declare)
|
|
48
|
+
return extension;
|
|
49
|
+
const declared = `\n\nScripts have \`computer\` bound, the run's computer: many steps in one call. A refused step throws.\n\`\`\`ts\n${computerDeclarations(computer.card.groups)}\n\`\`\``;
|
|
50
|
+
return { ...extension, tools: (extension.tools ?? []).map((tool) => (tool.name === CODEMODE_TOOL_NAME ? { ...tool, description: `${tool.description}${declared}` } : tool)) };
|
|
43
51
|
}
|
|
@@ -3,7 +3,9 @@ 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 CallStatus } from "../journal-kinds.js";
|
|
6
7
|
import { CALL_REFUSED } from "../../timeline/index.js";
|
|
8
|
+
import { type ComputerCallRecord } from "../../computer-calls.js";
|
|
7
9
|
/** What the adapter loop lends pi for one claim: the run's Harness, its registry, and where pi's models go. */
|
|
8
10
|
export interface PiRun {
|
|
9
11
|
readonly harness: Harness;
|
|
@@ -19,13 +21,8 @@ export interface PreIntentCall {
|
|
|
19
21
|
/** An earlier attempt of the call may have been sent (a CLI's kernel bridge, asking about a replay-safe call a crash
|
|
20
22
|
* cut: GateCall's `replayed`), so a refusal never says nothing was. */
|
|
21
23
|
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
24
|
/** 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 (
|
|
25
|
+
* one (wrap-up.ts), so a tool in flight is never cut short. */
|
|
29
26
|
readonly nested?: true;
|
|
30
27
|
}
|
|
31
28
|
/** 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 +37,13 @@ export type PiSessionIO = SessionIO & {
|
|
|
40
37
|
/** What the request that just answered cost, as the runner's booking wrote it (the session's ledger): its figure, null
|
|
41
38
|
* when unknown, undefined when none was booked. pi's own price for the model is none (the adapter does not know it). */
|
|
42
39
|
bookedCost?: () => Promise<number | null | undefined>;
|
|
40
|
+
/** 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'
|
|
41
|
+
* are kept): each run's pi-native tool (code mode's script among them) runs inside recordingCalls with it, so its row
|
|
42
|
+
* carries the calls it made as a host tool's does. */
|
|
43
|
+
keepCalls?: (call: string, calls: readonly ComputerCallRecord[], dropped: number) => Promise<void>;
|
|
44
|
+
/** 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
|
|
45
|
+
* from its record: the host keeps it beside the call's start, which its gate wrote, so the call's rows show its result. */
|
|
46
|
+
nestedEnded?: (callId: string, status: CallStatus, output: string) => Promise<void>;
|
|
43
47
|
};
|
|
44
48
|
export interface PiAdapterOptions {
|
|
45
49
|
readonly run: PiRun;
|
|
@@ -130,7 +134,7 @@ export declare function refusalWords(): {
|
|
|
130
134
|
readonly diagnostics?: readonly {
|
|
131
135
|
readonly code?: string;
|
|
132
136
|
}[];
|
|
133
|
-
}): {
|
|
137
|
+
}, nested?: boolean): {
|
|
134
138
|
output: {
|
|
135
139
|
type: "text";
|
|
136
140
|
text: string;
|
|
@@ -139,6 +143,11 @@ export declare function refusalWords(): {
|
|
|
139
143
|
details: {
|
|
140
144
|
[CALL_REFUSED]: true;
|
|
141
145
|
};
|
|
146
|
+
diagnostics?: {
|
|
147
|
+
severity: "error";
|
|
148
|
+
code: "blocked";
|
|
149
|
+
message: string;
|
|
150
|
+
}[];
|
|
142
151
|
} | undefined;
|
|
143
152
|
readonly held: number;
|
|
144
153
|
};
|