@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
package/dist/tools.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// nothing here: a run's runner binds them from its workspace's registry (workspace/run-tools.ts), each call made on the
|
|
5
5
|
// run's folder or its computer. `bash` and the background tools may be named only by an agent whose place is a box
|
|
6
6
|
// (runnable.ts).
|
|
7
|
-
import { blurbOf } from "./tool-
|
|
8
|
-
import {
|
|
7
|
+
import { blurbOf, isHostTool } from "./tool-list.js";
|
|
8
|
+
import { mcpNameOf, mcpToolName, parseToolName } from "./tool-names.js";
|
|
9
9
|
import { appendFileSync } from "node:fs";
|
|
10
10
|
import { pathToFileURL } from "node:url";
|
|
11
11
|
import { defineExtension, defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
@@ -14,11 +14,10 @@ import { BACKGROUND_LOG_BYTES, BACKGROUND_MAX, BACKGROUND_PAGE_BYTES } from "./b
|
|
|
14
14
|
import { isWorkspaceError, localWorkspace } from "./workspace/index.js";
|
|
15
15
|
import { fetchOptions, HTML_READ_CHARS, TEXT_CAP } from "./web-fetch-direct.js";
|
|
16
16
|
import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
|
|
17
|
-
import {
|
|
17
|
+
import { META_TOOLS } from "./meta-tool-names.js";
|
|
18
18
|
import { localFolderOf } from "./workspace/local.js";
|
|
19
19
|
import { LLM_TOOL } from "./llm.js";
|
|
20
20
|
import { DOCUMENTS_ENV, PDF_PAGES_TOOL, pdfPages } from "./pdf-pages.js";
|
|
21
|
-
import { monidTool } from "./monid.js";
|
|
22
21
|
import { FAUX_ENV, workflowNodes } from "./model.js";
|
|
23
22
|
import { bookedIn, booking } from "./paid-calls.js";
|
|
24
23
|
import { hostToolDefs } from "@parcha/agentrun-kernel/kernel";
|
|
@@ -410,7 +409,7 @@ const browserTool = {
|
|
|
410
409
|
const providerName = parts.provider?.name ?? vendor;
|
|
411
410
|
const price = browserPrice(providerName, host.env);
|
|
412
411
|
// On the runner, the run's ledger (host.ledger): each call held and settled on its booking, and a session's release one
|
|
413
|
-
// more request there
|
|
412
|
+
// more request there. With none, every browser call is refused unsent (browserSpend).
|
|
414
413
|
const spend = browserSpend(providerName, price, DEFAULT_BROWSER_POLICY.idleReleaseS, (conversation, at) => browser.release(conversation, "close", at), undefined, { paid: host.ledger?.paid, pause: host.ledger?.pause, flush: host.ledger?.flush });
|
|
415
414
|
// The run's own Workspace, the one its read opens (on the runner: Mode 1's local folder, Mode 2's folder on the run's
|
|
416
415
|
// disk): the browser files its evidence there, and browser_upload chooses from it.
|
|
@@ -583,14 +582,10 @@ export const TOOLS = Object.freeze({
|
|
|
583
582
|
effect: async (args, run) => bookedIn(run.ledger, () => searchFor(run.env, args, run.signal, run.search)),
|
|
584
583
|
},
|
|
585
584
|
browser: browserTool,
|
|
586
|
-
// monid's catalog on one key (monid.ts): every harness calls each by its wire name, `monid_discover` and the rest.
|
|
587
|
-
"monid.discover": monidTool("discover"),
|
|
588
|
-
"monid.inspect": monidTool("inspect"),
|
|
589
|
-
"monid.run": monidTool("run"),
|
|
590
585
|
// A pi run's subagent (runner/subagent.ts): a native tool of the run's root agent, bound by the runner's pi spec
|
|
591
|
-
// (adapter-run-spec.ts), never by this table; not a host tool (
|
|
586
|
+
// (adapter-run-spec.ts), never by this table; not a host tool (tool-list.ts `replay`), so another harness refuses it.
|
|
592
587
|
subagent: {
|
|
593
|
-
summary: "Run a subagent: a fresh conversation with only the call's prompt, on the agent's own model (or one of its model tiers, fast or strong, when the call names one), with a subset of the agent's own tools (bash among them, under the agent's bash policy), under the run's permissions and cap; answers with its final text. A call may
|
|
588
|
+
summary: "Run a subagent: a fresh conversation with only the call's prompt, on the agent's own model (or one of its model tiers, fast or strong, when the call names one), with a subset of the agent's own tools (bash among them, under the agent's bash policy), under the run's permissions and cap; answers with its final text. A call may set its child's effort (low, medium, high). Several calls in a turn run at once, at most 4 at a time; a subagent starts none of its own. pi only.",
|
|
594
589
|
needs: [],
|
|
595
590
|
nodes: false,
|
|
596
591
|
bind: async () => ({ tools: [], extensions: [] }),
|
|
@@ -610,10 +605,10 @@ export const CALL_TOOLS = Object.keys(TOOLS).filter((name) => TOOLS[name].effect
|
|
|
610
605
|
export const allows = (allowed, name) => allowed.includes(name);
|
|
611
606
|
/** The tools a run's learned workflow may name (learn/check.ts at learn time, learned-workflow.ts at a call): those of the
|
|
612
607
|
* agent's `granted` tools a workflow's call node runs here (CALL_TOOLS, and each MCP tool granted by its own name,
|
|
613
|
-
*
|
|
608
|
+
* tool-names.ts mcpNameOf: a wildcard is read against its server's listing first, mcpGrantsListed), and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name does not run either). A
|
|
614
609
|
* learned model node runs without tools (learn/skills.ts MODEL_NODE_TOOLS), and a harness's own tool (Bash,
|
|
615
610
|
* exec_command, apply_patch) is never one, so the DSL refuses a draft that names it. */
|
|
616
|
-
export const learnedWorkflowTools = (granted, plane, options = {}) => [...new Set(granted.filter((name) => (options.mcp === true &&
|
|
611
|
+
export const learnedWorkflowTools = (granted, plane, options = {}) => [...new Set(granted.filter((name) => (options.mcp === true && mcpNameOf(name) !== undefined) || (allows(CALL_TOOLS, name) && !isUnavailable(plane?.[name]))))];
|
|
617
612
|
/** `granted` with each MCP server's wildcard (`mcp:<server>/*`) read as the tools its server lists now (`listed`, by the
|
|
618
613
|
* server's name: none for a server not saved), each `mcp:<server>/<tool>`, in place; every other name as it is, each
|
|
619
614
|
* once. What a revision grants under a wildcard is every tool of its server, so a learned draft may name each one
|
|
@@ -623,12 +618,12 @@ export const learnedWorkflowTools = (granted, plane, options = {}) => [...new Se
|
|
|
623
618
|
export function mcpGrantsListed(granted, listed) {
|
|
624
619
|
const out = new Set();
|
|
625
620
|
for (const name of granted) {
|
|
626
|
-
const
|
|
627
|
-
if (
|
|
621
|
+
const parsed = parseToolName(name);
|
|
622
|
+
if (parsed?.kind !== "mcp-server")
|
|
628
623
|
out.add(name);
|
|
629
624
|
else
|
|
630
|
-
for (const tool of listed(
|
|
631
|
-
out.add(
|
|
625
|
+
for (const tool of listed(parsed.server))
|
|
626
|
+
out.add(mcpToolName(parsed.server, tool));
|
|
632
627
|
}
|
|
633
628
|
return [...out];
|
|
634
629
|
}
|
|
@@ -647,7 +642,7 @@ export const learnedDraftTools = (granted, permission, plane, from, options = {}
|
|
|
647
642
|
// tools, before any node runs (#2424). A table tool set to ask is not: its call node can't wait for an approval.
|
|
648
643
|
if (setting === "allow")
|
|
649
644
|
return true;
|
|
650
|
-
if (setting === "ask" && options.approvers === true &&
|
|
645
|
+
if (setting === "ask" && options.approvers === true && mcpNameOf(name) !== undefined)
|
|
651
646
|
return (asked.push(name), true);
|
|
652
647
|
gated[name] = setting;
|
|
653
648
|
// A deny comes from a layer or the default, never from approvals, which only ever allows.
|
|
@@ -708,7 +703,7 @@ export const missingEnv = (entry, env) => entry.needs.filter((name) => !env[name
|
|
|
708
703
|
export const toolsView = (env, settings = {}, noBox, refused = {}, runnerShell = new Set()) => {
|
|
709
704
|
const views = explainsView(env, settings);
|
|
710
705
|
const picked = withDefaults(settings);
|
|
711
|
-
|
|
706
|
+
const table = Object.entries(TOOLS).map(([name, entry]) => {
|
|
712
707
|
const view = PICKABLE.includes(name) ? views[name] : undefined;
|
|
713
708
|
const plane = view?.resolves;
|
|
714
709
|
const missing = plane && Object.values(plane).includes(NO_PARALLEL_KEY) ? [PARALLEL_KEY_ENV] : missingEnv(entry, env);
|
|
@@ -721,9 +716,18 @@ export const toolsView = (env, settings = {}, noBox, refused = {}, runnerShell =
|
|
|
721
716
|
// Unavailable says why: a sandbox-only tool no box here can run, why none can (`noBox`); on a tool a user picks a
|
|
722
717
|
// provider for, the resolutions' own words (`web_search is turned off in settings`); else the variables it needs.
|
|
723
718
|
const reason = available ? undefined : refusal ?? boxless ?? (plane ? [...new Set(Object.values(plane).filter(isUnavailable).map(whyUnavailable))].join("; ") : `Needs ${keyNeeded(missing)}`);
|
|
724
|
-
return { name, summary: entry.summary, ...(blurbOf(name) ? { blurb: blurbOf(name) } : {}), nodes: entry.nodes, calls: entry.effect !== undefined, ...(entry.callOnly ? { call_only: true } : {}), ...(entry.sandboxOnly ? { sandbox_only: true } : {}), available, ...(reason ? { reason } : {}), ...(missing.length ? { missing } : {}), harnesses: name
|
|
719
|
+
return { name, summary: entry.summary, ...(blurbOf(name) ? { blurb: blurbOf(name) } : {}), nodes: entry.nodes, calls: entry.effect !== undefined, ...(entry.callOnly ? { call_only: true } : {}), ...(entry.sandboxOnly ? { sandbox_only: true } : {}), available, ...(reason ? { reason } : {}), ...(missing.length ? { missing } : {}), harnesses: isHostTool(name) ? [...HARNESSES] : [DEFAULT_HARNESS], ...serverGate(name, settings), ...(plane ? { providers: [...PROVIDERS[name]], provider: picked[name].provider, default_provider: PROVIDERS[name][0], resolves: plane, why: view.why } : {}) };
|
|
725
720
|
});
|
|
721
|
+
// The host tools over a run's own tools (META_TOOLS): not in the table, never granted or named by a node (`meta`), listed
|
|
722
|
+
// so the owner sees them and their setting (allow or deny; a deny is not offered at all).
|
|
723
|
+
const meta = [...META_TOOLS].map((name) => ({ name, summary: META_SUMMARY[name], blurb: blurbOf(name), nodes: false, calls: false, meta: true, available: true, harnesses: [...HARNESSES], ...serverGate(name, settings) }));
|
|
724
|
+
return [...table, ...meta];
|
|
726
725
|
};
|
|
726
|
+
const META_SUMMARY = Object.freeze({
|
|
727
|
+
tools_search: "Finds one of the run's tools by what it does, when the run lists only some of them.",
|
|
728
|
+
tools_call: "Calls one of the run's tools by its name, one the run does not list.",
|
|
729
|
+
codemode: "Runs a script that calls the run's tools.",
|
|
730
|
+
});
|
|
727
731
|
/** Tests only (--faux, with the fake browser's $FAUX_BROWSER_LOG): each model call that starts waiting for the person to
|
|
728
732
|
* hand the browser back is logged (`{"op":"model_waits"}`) as it starts to wait, so a test hands back once the agent's call
|
|
729
733
|
* waits, never before it got there. The gates are the registry's own (one per session, the same object each time), each
|
package/dist/validate.d.ts
CHANGED
|
@@ -13,12 +13,10 @@ export declare const DEFINITION_FIELDS: string[];
|
|
|
13
13
|
* (runner/pr-checkout.ts): `pull_request`, the pull request the run's GitHub event names, at its head, read-only, in
|
|
14
14
|
* `repo/`; `none` clears it on an edit. */
|
|
15
15
|
export declare const CHECKOUTS: readonly ["pull_request", "none"];
|
|
16
|
-
/** Why a field a definition may have elsewhere has no place in an agent store's revision. */
|
|
17
|
-
export declare const NOT_KEPT: Record<string, string>;
|
|
18
|
-
/** The most tool calls an agent's budget (max_tool_calls, tool-budget.ts) may name. */
|
|
19
|
-
export declare const MAX_TOOL_CALLS = 1000;
|
|
20
16
|
/** The most bytes an agent's output_schema takes, as JSON. */
|
|
21
17
|
export declare const MAX_OUTPUT_SCHEMA_BYTES: number;
|
|
18
|
+
/** The most bytes an agent's input_schema takes, as JSON. */
|
|
19
|
+
export declare const MAX_INPUT_SCHEMA_BYTES: number;
|
|
22
20
|
/** The tiers an agentic revision may name a model for (`model_tiers`): those a subagent runs on (runner/subagent.ts). */
|
|
23
21
|
export declare const MODEL_TIER_NAMES: readonly ["fast", "strong"];
|
|
24
22
|
/** `provider/model-id`. */
|
|
@@ -65,9 +63,19 @@ export declare const DEFAULT_INPUT_SCHEMA: {
|
|
|
65
63
|
};
|
|
66
64
|
};
|
|
67
65
|
};
|
|
66
|
+
/** What is wrong with an agentic definition's `input_schema`: an object schema (`type: object` at its top), at most
|
|
67
|
+
* MAX_INPUT_SCHEMA_BYTES as JSON, that compiles (the compiler output_schema uses), and that names `content`, if at all,
|
|
68
|
+
* as text: content is the run's message, its follow-ups' and a trigger's line. */
|
|
69
|
+
export declare function inputSchemaIssues(schema: unknown, at?: string): InputIssue[];
|
|
68
70
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
71
|
+
* The input schema in force for an agentic revision whose definition has `schema` (none: DEFAULT_INPUT_SCHEMA). `content`
|
|
72
|
+
* is always taken, as text: a run's message, which a follow-up and a trigger's line add to. It stays required when the
|
|
73
|
+
* schema requires nothing else, as an agent with no schema requires it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function inputSchemaOf(schema: unknown): Json;
|
|
76
|
+
/**
|
|
77
|
+
* A run's input against the schema in force (inputSchemaOf), with the full compiler: every keyword, at every depth. Each
|
|
78
|
+
* problem is an issue at its own path under `at` (`input.company`, `input.topics.1`), a required property missing at
|
|
79
|
+
* its own name and a property a closed object does not take at its own, as a 422 names a field.
|
|
72
80
|
*/
|
|
73
81
|
export declare function inputIssues(input: Json, schema: Json, at?: string): InputIssue[];
|
package/dist/validate.js
CHANGED
|
@@ -18,19 +18,15 @@ export const isObject = (value) => typeof value === "object" && value !== null &
|
|
|
18
18
|
/** How long an Idempotency-Key answers with its first answer (capabilities' limits.idempotency_ttl_s). */
|
|
19
19
|
export const IDEMPOTENCY_TTL_S = 86_400;
|
|
20
20
|
export const stable = (value) => Array.isArray(value) ? `[${value.map(stable).join(",")}]` : isObject(value) ? `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${stable(value[k])}`).join(",")}}` : JSON.stringify(value);
|
|
21
|
-
export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "model_tiers", "thinking", "harness", "place", "computer", "learning", "skills", "tools", "tool_settings", "approvals", "max_cost_usd", "cap_mode", "
|
|
21
|
+
export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "model_tiers", "thinking", "harness", "place", "computer", "learning", "skills", "tools", "tool_settings", "approvals", "max_cost_usd", "cap_mode", "input_schema", "output_schema", "checkout"];
|
|
22
22
|
/** What an agentic definition may ask the server to check out in each run's folder before its first turn
|
|
23
23
|
* (runner/pr-checkout.ts): `pull_request`, the pull request the run's GitHub event names, at its head, read-only, in
|
|
24
24
|
* `repo/`; `none` clears it on an edit. */
|
|
25
25
|
export const CHECKOUTS = ["pull_request", "none"];
|
|
26
|
-
/** Why a field a definition may have elsewhere has no place in an agent store's revision. */
|
|
27
|
-
export const NOT_KEPT = {
|
|
28
|
-
input_schema: "The agent store keeps no input_schema: an agentic run takes {content}, and a workflow checks its input against its own schema.",
|
|
29
|
-
};
|
|
30
|
-
/** The most tool calls an agent's budget (max_tool_calls, tool-budget.ts) may name. */
|
|
31
|
-
export const MAX_TOOL_CALLS = 1_000;
|
|
32
26
|
/** The most bytes an agent's output_schema takes, as JSON. */
|
|
33
27
|
export const MAX_OUTPUT_SCHEMA_BYTES = 64 * 1024;
|
|
28
|
+
/** The most bytes an agent's input_schema takes, as JSON. */
|
|
29
|
+
export const MAX_INPUT_SCHEMA_BYTES = 64 * 1024;
|
|
34
30
|
/** The tiers an agentic revision may name a model for (`model_tiers`): those a subagent runs on (runner/subagent.ts). */
|
|
35
31
|
export const MODEL_TIER_NAMES = ["fast", "strong"];
|
|
36
32
|
/** `provider/model-id`. */
|
|
@@ -68,7 +64,7 @@ export function definitionIssues(definition, { at = "definition", creating = tru
|
|
|
68
64
|
const out = [];
|
|
69
65
|
for (const key of Object.keys(definition)) {
|
|
70
66
|
if (!DEFINITION_FIELDS.includes(key))
|
|
71
|
-
out.push(issue(`${at}.${key}`, "not_allowed",
|
|
67
|
+
out.push(issue(`${at}.${key}`, "not_allowed", `The definition keeps no field ${key}.`, `Remove ${at}.${key}.`));
|
|
72
68
|
}
|
|
73
69
|
const d = definition;
|
|
74
70
|
if (creating && d.name === undefined)
|
|
@@ -142,6 +138,14 @@ export function definitionIssues(definition, { at = "definition", creating = tru
|
|
|
142
138
|
out.push(issue(`${at}.output_schema`, "bad_format", `${at}.output_schema ${compiled.why}`));
|
|
143
139
|
}
|
|
144
140
|
}
|
|
141
|
+
// An agentic revision's typed input: the JSON Schema each run's input meets (inputSchemaOf, the schema in force). A
|
|
142
|
+
// workflow's input is its workflow's own schema.
|
|
143
|
+
if (d.input_schema !== undefined) {
|
|
144
|
+
if (d.workflow !== undefined)
|
|
145
|
+
out.push(issue(`${at}.input_schema`, "not_allowed", "A workflow revision keeps no input_schema: its runs' input is its workflow's own input schema.", `Remove ${at}.input_schema.`));
|
|
146
|
+
else
|
|
147
|
+
out.push(...inputSchemaIssues(d.input_schema, `${at}.input_schema`));
|
|
148
|
+
}
|
|
145
149
|
if (d.skills !== undefined)
|
|
146
150
|
names(d.skills, `${at}.skills`, out);
|
|
147
151
|
if (d.tools !== undefined)
|
|
@@ -169,14 +173,6 @@ export function definitionIssues(definition, { at = "definition", creating = tru
|
|
|
169
173
|
else if (!CHECKOUTS.includes(d.checkout))
|
|
170
174
|
out.push(issue(`${at}.checkout`, "not_an_option", `${at}.checkout is one of ${CHECKOUTS.join(", ")}: pull_request checks out the pull request the run's GitHub event names, at its head, in repo/ before the first turn; none clears it`));
|
|
171
175
|
}
|
|
172
|
-
// The tool calls each conversation of an agentic run may make (tool-budget.ts): above 0 sets the budget, 0 clears it, and
|
|
173
|
-
// an edit that leaves it out keeps the agent's, as the default cap is kept.
|
|
174
|
-
if (d.max_tool_calls !== undefined) {
|
|
175
|
-
if (d.workflow !== undefined)
|
|
176
|
-
out.push(issue(`${at}.max_tool_calls`, "not_allowed", "A workflow revision keeps no tool-call budget: its nodes are its steps.", `Remove ${at}.max_tool_calls.`));
|
|
177
|
-
else if (!(Number.isSafeInteger(d.max_tool_calls) && d.max_tool_calls >= 0 && d.max_tool_calls <= MAX_TOOL_CALLS))
|
|
178
|
-
out.push(issue(`${at}.max_tool_calls`, "wrong_type", `${at}.max_tool_calls is a whole number from 0 to ${MAX_TOOL_CALLS}: above 0, the tool calls each conversation of a run may make before every further call is refused with words that say to answer now; 0 clears it`));
|
|
179
|
-
}
|
|
180
176
|
// How a run's cap prices its requests (cap.ts CapMode): kept, as the default cap is, by an edit that leaves it out.
|
|
181
177
|
if (d.cap_mode !== undefined) {
|
|
182
178
|
if (!CAP_MODES.includes(d.cap_mode))
|
|
@@ -230,41 +226,92 @@ export function checkDefinitionBody(body, { creating = true } = {}) {
|
|
|
230
226
|
throw invalid(out);
|
|
231
227
|
return { definition: body.definition, ...(body.skills !== undefined || creating ? { skills: (body.skills ?? {}) } : {}), ...(typeof body.note === "string" ? { note: body.note } : {}) };
|
|
232
228
|
}
|
|
233
|
-
const TYPE_CHECK = {
|
|
234
|
-
string: (v) => typeof v === "string",
|
|
235
|
-
number: (v) => typeof v === "number" && Number.isFinite(v),
|
|
236
|
-
integer: (v) => Number.isSafeInteger(v),
|
|
237
|
-
boolean: (v) => typeof v === "boolean",
|
|
238
|
-
object: isObject,
|
|
239
|
-
array: Array.isArray,
|
|
240
|
-
null: (v) => v === null,
|
|
241
|
-
};
|
|
242
229
|
/** The default input schema: `{content: string}`. */
|
|
243
230
|
export const DEFAULT_INPUT_SCHEMA = { type: "object", required: ["content"], properties: { content: { type: "string" } } };
|
|
231
|
+
/** What is wrong with an agentic definition's `input_schema`: an object schema (`type: object` at its top), at most
|
|
232
|
+
* MAX_INPUT_SCHEMA_BYTES as JSON, that compiles (the compiler output_schema uses), and that names `content`, if at all,
|
|
233
|
+
* as text: content is the run's message, its follow-ups' and a trigger's line. */
|
|
234
|
+
export function inputSchemaIssues(schema, at = "definition.input_schema") {
|
|
235
|
+
if (!isObject(schema))
|
|
236
|
+
return [issue(at, "wrong_type", `${at} is a JSON Schema object`)];
|
|
237
|
+
if (Buffer.byteLength(JSON.stringify(schema)) > MAX_INPUT_SCHEMA_BYTES)
|
|
238
|
+
return [issue(at, "too_long", `${at} is over ${MAX_INPUT_SCHEMA_BYTES} bytes as JSON`)];
|
|
239
|
+
if (schema.type !== "object")
|
|
240
|
+
return [issue(at, "bad_format", `${at} is an object schema: its type is "object", as a run's input is an object`)];
|
|
241
|
+
const content = isObject(schema.properties) ? schema.properties.content : undefined;
|
|
242
|
+
if (content !== undefined && !(isObject(content) && content.type === "string"))
|
|
243
|
+
return [issue(`${at}.properties.content`, "bad_format", `${at}.properties.content is {type: "string"}: content is reserved for the run's message`)];
|
|
244
|
+
const compiled = schemaCheck(schema);
|
|
245
|
+
return "why" in compiled ? [issue(at, "bad_format", `${at} ${compiled.why}`)] : [];
|
|
246
|
+
}
|
|
244
247
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
+
* The input schema in force for an agentic revision whose definition has `schema` (none: DEFAULT_INPUT_SCHEMA). `content`
|
|
249
|
+
* is always taken, as text: a run's message, which a follow-up and a trigger's line add to. It stays required when the
|
|
250
|
+
* schema requires nothing else, as an agent with no schema requires it.
|
|
251
|
+
*/
|
|
252
|
+
export function inputSchemaOf(schema) {
|
|
253
|
+
if (!isObject(schema))
|
|
254
|
+
return DEFAULT_INPUT_SCHEMA;
|
|
255
|
+
const properties = isObject(schema.properties) ? schema.properties : {};
|
|
256
|
+
const required = Array.isArray(schema.required) ? schema.required.filter((key) => typeof key === "string") : [];
|
|
257
|
+
return {
|
|
258
|
+
...schema,
|
|
259
|
+
properties: { ...properties, content: properties.content ?? { type: "string" } },
|
|
260
|
+
required: required.some((key) => key !== "content") ? required : [...new Set([...required, "content"])],
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/** Each JSON Schema keyword's issue reason (InputIssue.reason): a keyword not named here is `invalid`. */
|
|
264
|
+
const KEYWORD_REASON = {
|
|
265
|
+
type: "wrong_type", enum: "not_an_option", const: "not_an_option", pattern: "bad_format", format: "bad_format",
|
|
266
|
+
minLength: "too_short", maxLength: "too_long", minItems: "too_few", maxItems: "too_many", minProperties: "too_few", maxProperties: "too_many", uniqueItems: "duplicate",
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* A run's input against the schema in force (inputSchemaOf), with the full compiler: every keyword, at every depth. Each
|
|
270
|
+
* problem is an issue at its own path under `at` (`input.company`, `input.topics.1`), a required property missing at
|
|
271
|
+
* its own name and a property a closed object does not take at its own, as a 422 names a field.
|
|
248
272
|
*/
|
|
249
273
|
export function inputIssues(input, schema, at = "input") {
|
|
250
274
|
const out = [];
|
|
251
|
-
const
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
275
|
+
const seen = new Set();
|
|
276
|
+
const add = (path, reason, message, fix) => {
|
|
277
|
+
if (seen.has(`${path}\n${reason}`))
|
|
278
|
+
return;
|
|
279
|
+
seen.add(`${path}\n${reason}`);
|
|
280
|
+
out.push(issue(path, reason, message, fix));
|
|
281
|
+
};
|
|
282
|
+
// The schema in force compiles: a save checks it (inputSchemaIssues).
|
|
283
|
+
const compiled = schemaCheck(schema);
|
|
284
|
+
if ("why" in compiled)
|
|
285
|
+
throw new Error(`the input schema ${compiled.why}`);
|
|
286
|
+
for (const error of compiled.validator.Errors(input)[1]) {
|
|
287
|
+
const where = [at, ...error.instancePath.split("/").slice(1).map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"))].join(".");
|
|
288
|
+
const params = error.params;
|
|
289
|
+
if (error.keyword === "required")
|
|
290
|
+
for (const key of params.requiredProperties ?? [])
|
|
291
|
+
add(`${where}.${key}`, "missing", `${where}.${key} is required`);
|
|
292
|
+
else if (error.keyword === "additionalProperties")
|
|
293
|
+
for (const key of params.additionalProperties ?? [])
|
|
294
|
+
add(`${where}.${key}`, "not_allowed", `${where} keeps no field ${key}`, `Remove ${where}.${key}.`);
|
|
295
|
+
// A closed object's own refusal of each extra property, said once above by its name.
|
|
296
|
+
else if (error.keyword === "boolean" && error.schemaPath.endsWith("/additionalProperties"))
|
|
261
297
|
continue;
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
out.push(issue(`${at}.${key}`, "not_an_option", `${at}.${key} is not one of the options`));
|
|
298
|
+
// A required text sent empty is one left blank (a form sends it so): said as a missing one is, never as its length.
|
|
299
|
+
else if (error.keyword === "minLength" && emptyRequired(input, schema, error.instancePath, error.schemaPath))
|
|
300
|
+
add(where, "missing", `${where} is required`);
|
|
301
|
+
else
|
|
302
|
+
add(where, KEYWORD_REASON[error.keyword] ?? "invalid", `${where} ${error.message}`);
|
|
268
303
|
}
|
|
269
304
|
return out;
|
|
270
305
|
}
|
|
306
|
+
/** The parts of a JSON Pointer as the compiler writes it (`/topics/0`, `#/properties/company`). */
|
|
307
|
+
const pointerParts = (pointer) => pointer.replace(/^#/, "").split("/").slice(1).map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
308
|
+
/** What `parts` name in `root`, or undefined. */
|
|
309
|
+
const pointed = (root, parts) => parts.reduce((x, part) => (isObject(x) || Array.isArray(x) ? x[part] : undefined), root);
|
|
310
|
+
/** Whether the value at `instancePath` is "" and its object schema (`schemaPath` is `…/properties/<name>`) requires it. */
|
|
311
|
+
function emptyRequired(input, schema, instancePath, schemaPath) {
|
|
312
|
+
const at = pointerParts(schemaPath);
|
|
313
|
+
if (pointed(input, pointerParts(instancePath)) !== "" || at.at(-2) !== "properties")
|
|
314
|
+
return false;
|
|
315
|
+
const parent = pointed(schema, at.slice(0, -2));
|
|
316
|
+
return isObject(parent) && Array.isArray(parent.required) && parent.required.includes(at.at(-1));
|
|
317
|
+
}
|
package/dist/web-fetch.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { JsonValue } from "@earendil-works/chord/json";
|
|
|
2
2
|
import type { TSchema } from "typebox";
|
|
3
3
|
import { type ToolRegistration } from "@earendil-works/pi-durable";
|
|
4
4
|
import type { PublicFetchOptions } from "@parcha/pi-browser";
|
|
5
|
-
import { type CapRefusal } from "./cap.js";
|
|
6
5
|
import { type Page, type Part, type Read, type Unread } from "./web-fetch-direct.js";
|
|
7
6
|
export declare const WEB_FETCH_TOOL = "web_fetch";
|
|
8
7
|
export declare const PARALLEL_EXTRACT_URL = "https://api.parallel.ai/v1/extract";
|
|
@@ -16,12 +15,7 @@ export type WebPage = Page & {
|
|
|
16
15
|
/** A page web_fetch read, and how (WebPage's `via` and `parallel`). */
|
|
17
16
|
export type WebRead = Read & Pick<WebPage, "via" | "parallel">;
|
|
18
17
|
/** A page web_fetch could not read, and how it tried. */
|
|
19
|
-
|
|
20
|
-
* that shares it is told and held, not only the one that started it (webFetch). Never serialized: a symbol key. */
|
|
21
|
-
declare const HELD: unique symbol;
|
|
22
|
-
type WebUnread = Unread & Pick<WebPage, "via" | "parallel"> & {
|
|
23
|
-
readonly [HELD]?: CapRefusal;
|
|
24
|
-
};
|
|
18
|
+
type WebUnread = Unread & Pick<WebPage, "via" | "parallel">;
|
|
25
19
|
/** The pages a run reads, by the URL asked for, each from its read's start (so calls at once share it), the last used
|
|
26
20
|
* last: at most PAGES_HELD of them. */
|
|
27
21
|
export type Pages = Map<string, Promise<WebRead | WebUnread>>;
|
package/dist/web-fetch.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defineTool } from "@earendil-works/pi-durable";
|
|
2
|
-
import { capRefusals } from "./cap.js";
|
|
3
2
|
import { FAUX_PARALLEL_ENV, fauxFetch, parallelKeyOf } from "./decisions.js";
|
|
4
3
|
import { clip, fetchOptions, HTML_READ_CHARS, linksWithin, MAX_CHARS_MIN, PAGE_CHARS, PAGE_READ_MAX_CHARS, partOfRead, partProblem, readDirect, TEXT_CAP, TIMEOUT_MS, TITLE_CAP, textOf, URL_MAX, URL_PARAMETERS } from "./web-fetch-direct.js";
|
|
5
4
|
import { FAUX_ENV } from "./model.js";
|
|
@@ -12,10 +11,6 @@ const PARALLEL_TIMEOUT_MS = 60_000;
|
|
|
12
11
|
const PORTS = new Set(["", "80", "443"]);
|
|
13
12
|
/** How many pages a run keeps what it read of (Pages): each at most PAGE_READ_MAX_CHARS characters of text. */
|
|
14
13
|
export const PAGES_HELD = 8;
|
|
15
|
-
/** A page web_fetch could not read, and how it tried. */
|
|
16
|
-
/** On a read the cap refused in a call node (readOnce): the refusal, carried with the shared read, so every call node
|
|
17
|
-
* that shares it is told and held, not only the one that started it (webFetch). Never serialized: a symbol key. */
|
|
18
|
-
const HELD = Symbol("the cap's refusal of a shared read");
|
|
19
14
|
/** The absolute http(s) URLs a markdown text links to (`[text](url)`), each once and without its fragment, in order, as
|
|
20
15
|
* they are read (linksWithin keeps those within the caps and counts the rest). A URL ends at whitespace or at the ")"
|
|
21
16
|
* that closes the link, so parentheses it holds in pairs (a wiki title's) stay. */
|
|
@@ -109,9 +104,7 @@ async function passes(url, options, ms) {
|
|
|
109
104
|
/** The page at `url` read once: through `parallel` when it is given and live and the guard passes the URL within
|
|
110
105
|
* `checkMs` (default the guarded fetch's 30 s), else (or when it answers no page) through the guarded fetch. A page
|
|
111
106
|
* fetched directly where `parallel` was given says why Parallel gave none (`parallel`): a picked provider that fails is
|
|
112
|
-
* never a silent fallback.
|
|
113
|
-
* cap refuses is the call's held refusal: no page, no direct fetch in its place, and nothing the run keeps, so the call
|
|
114
|
-
* run again after a raise reads through Parallel. */
|
|
107
|
+
* never a silent fallback. */
|
|
115
108
|
async function readOnce(url, parallel, checkMs, options) {
|
|
116
109
|
let why;
|
|
117
110
|
if (parallel && !parallel.live())
|
|
@@ -119,15 +112,9 @@ async function readOnce(url, parallel, checkMs, options) {
|
|
|
119
112
|
else if (parallel && !(typeof url === "string" && (await passes(url, options, checkMs))))
|
|
120
113
|
why = "not tried: the URL did not pass the public-host guard";
|
|
121
114
|
else if (parallel) {
|
|
122
|
-
const
|
|
123
|
-
let held;
|
|
124
|
-
const read = told
|
|
125
|
-
? await capRefusals.run((refusal) => ((held ??= refusal), told(refusal)), () => parallel.read(url, options.signal))
|
|
126
|
-
: await parallel.read(url, options.signal);
|
|
115
|
+
const read = await parallel.read(url, options.signal);
|
|
127
116
|
if (typeof read !== "string")
|
|
128
117
|
return { ...read, via: "parallel" };
|
|
129
|
-
if (held)
|
|
130
|
-
return { ok: false, url: clip(url, URL_MAX), status: 0, title: "", text: "", links: [], error: read, via: "parallel", parallel: read, [HELD]: held };
|
|
131
118
|
why = read;
|
|
132
119
|
}
|
|
133
120
|
return { ...(await readDirect(url, options)), via: "direct", ...(why ? { parallel: why } : {}) };
|
|
@@ -173,8 +160,6 @@ function untilStopped(url, reading, signal) {
|
|
|
173
160
|
export async function webFetch(url, { parallel, pages, checkMs = TIMEOUT_MS, offset, maxChars, signal, ...options } = {}) {
|
|
174
161
|
const named = typeof url === "string" ? url : undefined;
|
|
175
162
|
let reading = named === undefined ? undefined : pages?.get(named);
|
|
176
|
-
/** The run's read under way for this URL, taken by this call: its refusal at the cap is this call's too (HELD). */
|
|
177
|
-
const shared = reading !== undefined;
|
|
178
163
|
if (!reading) {
|
|
179
164
|
const started = readOnce(url, parallel, checkMs, options);
|
|
180
165
|
if (pages && named !== undefined) {
|
|
@@ -192,11 +177,6 @@ export async function webFetch(url, { parallel, pages, checkMs = TIMEOUT_MS, off
|
|
|
192
177
|
trim(pages);
|
|
193
178
|
}
|
|
194
179
|
const read = await untilStopped(url, reading, signal);
|
|
195
|
-
// A shared read the cap refused holds this call node as it held the one that started it (told there, in readOnce):
|
|
196
|
-
// the same refusal, told here, so this call waits for a raise too instead of taking the unread page as its answer.
|
|
197
|
-
const refusal = shared && !read.ok ? read[HELD] : undefined;
|
|
198
|
-
if (refusal)
|
|
199
|
-
capRefusals.getStore()?.(refusal);
|
|
200
180
|
if (!read.ok)
|
|
201
181
|
return read;
|
|
202
182
|
const { via, parallel: why, ...page } = read;
|
|
@@ -98,6 +98,9 @@ export declare function computerSpecOf(env: KeyEnv): ComputerForClaimDeps["spec"
|
|
|
98
98
|
/** The run's timeline phase while its claim waits on its computer's image (computerForClaim's onImageWait): main's box
|
|
99
99
|
* image row, the computer's noun for the box's. */
|
|
100
100
|
export declare const imageWaitWords: (making: "build" | "pull", image: string) => string;
|
|
101
|
+
/** The run's timeline phase as its claim starts making its computer (computerForClaim's onStarting): a phone takes
|
|
102
|
+
* tens of seconds to boot, and until it is up the run's timeline has nothing else to say. */
|
|
103
|
+
export declare const computerStartingWords: ({ provider, kind }: Pick<ComputerSaid, "provider" | "kind">) => string;
|
|
101
104
|
/** The run's timeline phase once its claim's computer is connected (computerForClaim's onConnected): what it says it
|
|
102
105
|
* is, in its hello's own facts, such as "The phone is ready: Android 15 (arm64), from Phone harness." */
|
|
103
106
|
export declare const computerReadyWords: ({ provider, kind, hello }: ComputerSaid) => string;
|
|
@@ -29,7 +29,7 @@ import { readLaunchBody } from "../run-launch.js";
|
|
|
29
29
|
import { computerForClaim } from "./computer-for-claim.js";
|
|
30
30
|
import { storeLedger } from "./computer-ledger.js";
|
|
31
31
|
import { computerProviderFactories, computerProviderMakers } from "./computer-providers.js";
|
|
32
|
-
import { needsNetwork, noNetworkRefusal, vendorNetworkOnly } from "./resolve-computer.js";
|
|
32
|
+
import { aLabel, needsNetwork, noNetworkRefusal, vendorNetworkOnly } from "./resolve-computer.js";
|
|
33
33
|
/** How long a run's computer lives whatever happens to the server: a bound on a leaked one, never its clean end (the old
|
|
34
34
|
* box's lifetime). The clean end is the run's release. */
|
|
35
35
|
export const COMPUTER_LIFETIME_MS = 24 * 60 * 60_000;
|
|
@@ -137,7 +137,7 @@ export function computerSpecOf(env) {
|
|
|
137
137
|
if (image !== undefined)
|
|
138
138
|
return image;
|
|
139
139
|
if (entry.prepareImage && kind === "desktop")
|
|
140
|
-
throw refused(
|
|
140
|
+
throw refused(`${aLabel(entry.label, true)} desktop needs an image with an X server; set one for desktops.`);
|
|
141
141
|
throw refused(`${entry.label} has no image for a ${kind} computer here: pick another provider for this agent's computer in Settings → Computers.`);
|
|
142
142
|
};
|
|
143
143
|
const limits = dockerLimitsOf(env);
|
|
@@ -182,6 +182,9 @@ function networkOf(entry, kind, run, current, currentSet) {
|
|
|
182
182
|
export const imageWaitWords = (making, image) => making === "build" ? `Preparing the computer's image: building it (${DOCKER_RECIPE_HAS})…` : `Preparing the computer's image: pulling ${image}…`;
|
|
183
183
|
/** An OS as people write its name. */
|
|
184
184
|
const OS_NAMES = { linux: "Linux", windows: "Windows", macos: "macOS", android: "Android", ios: "iOS" };
|
|
185
|
+
/** The run's timeline phase as its claim starts making its computer (computerForClaim's onStarting): a phone takes
|
|
186
|
+
* tens of seconds to boot, and until it is up the run's timeline has nothing else to say. */
|
|
187
|
+
export const computerStartingWords = ({ provider, kind }) => `Starting a ${kind} from ${provider}…`;
|
|
185
188
|
/** The run's timeline phase once its claim's computer is connected (computerForClaim's onConnected): what it says it
|
|
186
189
|
* is, in its hello's own facts, such as "The phone is ready: Android 15 (arm64), from Phone harness." */
|
|
187
190
|
export const computerReadyWords = ({ provider, kind, hello }) => `The ${kind} is ready: ${[OS_NAMES[hello.os] ?? hello.os, hello.osVersion].filter(Boolean).join(" ")} (${hello.arch}), from ${provider}.`;
|
|
@@ -64,6 +64,8 @@ export type OpenComputerView = (args: {
|
|
|
64
64
|
readonly watch: WatchOf;
|
|
65
65
|
/** The run's hold (computer-hold.ts ComputerHold). */
|
|
66
66
|
readonly hold: unknown;
|
|
67
|
+
/** Whether the computer is gone now, its provider no longer having it (goneOf): asked when its watch ends gone. */
|
|
68
|
+
readonly gone?: () => Promise<boolean>;
|
|
67
69
|
}) => Promise<{
|
|
68
70
|
readonly ok: true;
|
|
69
71
|
readonly view: {
|
|
@@ -115,6 +117,10 @@ export interface ComputerForClaimDeps {
|
|
|
115
117
|
* the OS's version and its architecture): the run's caller says it on the run's timeline. A browser session, made
|
|
116
118
|
* by the run's tool, is never told. Absent: nothing is said. */
|
|
117
119
|
readonly onConnected?: (said: ComputerSaid) => void;
|
|
120
|
+
/** Told once, as the claim asks its provider for a new computer (never for a browser, or an agent's own computer,
|
|
121
|
+
* whose claim says what became of it in onComputerNote): the run's caller says it on the run's timeline, which
|
|
122
|
+
* otherwise shows nothing while a phone boots. Absent: nothing is said. */
|
|
123
|
+
readonly onStarting?: (said: Pick<ComputerSaid, "provider" | "kind">) => void;
|
|
118
124
|
/** Why this machine cannot run a provider's computers, by its provider id (computers.ts hostCommandRefusals: the
|
|
119
125
|
* phone's adb not on PATH), in words that say how to fix it, or undefined: refused with code computer_unavailable
|
|
120
126
|
* before anything is rented. Absent: not asked. */
|
|
@@ -35,9 +35,20 @@ const unavailable = (words) => Object.assign(new Error(words), { code: "computer
|
|
|
35
35
|
/** The claim was lost (its live view's registration was fenced): the run's process holds it no more. */
|
|
36
36
|
const claimLost = (words) => Object.assign(new Error(words), { code: "claim_lost" });
|
|
37
37
|
const noop = async () => { };
|
|
38
|
-
/** The agent's computer setting: the launch's, else its revision's (computer, else place), else the launch's place. */
|
|
39
38
|
/** A claim's create request: the run and its claim epoch, so a retry of the claim's create finds the computer it made. */
|
|
40
39
|
const claimRequestId = (claim) => `${claim.runId}#${claim.epoch}`;
|
|
40
|
+
/** The run's computers of a lower claim epoch released (the janitor's releaseOlder: one claim's computer at a time), its
|
|
41
|
+
* failure thrown in its words. A run's first claim is epoch 1 (a queued run is epoch 0; each claim and release moves it
|
|
42
|
+
* up one): no claim came before it to leave a computer, so the provider is not asked (its list is a vendor round trip
|
|
43
|
+
* before the create). */
|
|
44
|
+
async function releaseOlderClaims(provider, claim, signal) {
|
|
45
|
+
if (claim.epoch <= 1)
|
|
46
|
+
return;
|
|
47
|
+
const older = await releaseOlder(provider, claim.runId, claim.epoch, signal ? { signal } : {});
|
|
48
|
+
if (!older.ok)
|
|
49
|
+
throw new Error(older.error.message);
|
|
50
|
+
}
|
|
51
|
+
/** The agent's computer setting: the launch's, else its revision's (computer, else place), else the launch's place. */
|
|
41
52
|
async function settingOf(launch, store) {
|
|
42
53
|
if (launch.computer)
|
|
43
54
|
return launch.computer;
|
|
@@ -71,6 +82,15 @@ async function readyImage(entry, provider, signal, onWait) {
|
|
|
71
82
|
}
|
|
72
83
|
/** The provider's watch of a computer's screen on `ref` (ComputerProvider.watch), where it has one. */
|
|
73
84
|
const watchOf = (provider, ref) => typeof provider.watch === "function" ? (handlers, options) => provider.watch(ref, handlers, options) : undefined;
|
|
85
|
+
/** Whether the computer `id` is gone now: its provider's listing under `labels` (the run's, or its owner's for the
|
|
86
|
+
* agent's own) no longer shows it, deleted under the run (by the vendor's own API, say) or going. The listing is the
|
|
87
|
+
* janitor's read: it starts nothing and leaves out a machine on its way out. A listing that failed is not gone. A
|
|
88
|
+
* desktop listed stopped is still there. A phone is never stopped and kept (a phone provider has no stop), so one
|
|
89
|
+
* listed stopped is ending (the phone harness lists a closing or errored session so) and counts as gone. */
|
|
90
|
+
const goneOf = (provider, id, labels, kind) => async () => {
|
|
91
|
+
const listed = await provider.list(labels);
|
|
92
|
+
return listed.ok && !listed.value.some((info) => info.ref.id === id && (kind === "desktop" || info.state === "running"));
|
|
93
|
+
};
|
|
74
94
|
/** The browser computer `ref`'s CDP URL now: the provider's connect (its signed URL), its words and code when the session
|
|
75
95
|
* has ended. The connection itself is let go once read. */
|
|
76
96
|
async function cdpUrlOf(provider, ref) {
|
|
@@ -161,13 +181,11 @@ export function claimBrowser(provider, spec) {
|
|
|
161
181
|
},
|
|
162
182
|
};
|
|
163
183
|
}
|
|
164
|
-
/** `entry`'s computer started through its provider: the run's computers of a lower claim epoch released first
|
|
165
|
-
*
|
|
184
|
+
/** `entry`'s computer started through its provider: the run's computers of a lower claim epoch released first
|
|
185
|
+
* (releaseOlderClaims; none at a run's first claim), then made with the run's labels (and the run's folder, when
|
|
166
186
|
* it mounts), connected, its groups from its hello; its read-back is the provider's own; its release deletes it. */
|
|
167
187
|
async function providerLaunch(provider, claim, spec, signal) {
|
|
168
|
-
|
|
169
|
-
if (!older.ok)
|
|
170
|
-
throw new Error(older.error.message);
|
|
188
|
+
await releaseOlderClaims(provider, claim, signal);
|
|
171
189
|
// The claim is the request: a retry of this launch under the same epoch gets the computer it made, never a second.
|
|
172
190
|
const created = await provider.create(spec, { requestId: claimRequestId(claim), ...(signal ? { signal } : {}) });
|
|
173
191
|
if (!created.ok)
|
|
@@ -246,9 +264,7 @@ async function ownedLaunch(provider, claim, spec, context, signal) {
|
|
|
246
264
|
async function ownedStart(provider, claim, spec, context, hold, signal) {
|
|
247
265
|
const call = signal ? { signal } : {};
|
|
248
266
|
const { store, agentId, note } = context;
|
|
249
|
-
|
|
250
|
-
if (!older.ok)
|
|
251
|
-
throw new Error(older.error.message);
|
|
267
|
+
await releaseOlderClaims(provider, claim, signal);
|
|
252
268
|
const listed = await provider.list(ownerFilter(context.owner), call);
|
|
253
269
|
if (!listed.ok)
|
|
254
270
|
throw new Error(listed.error.message);
|
|
@@ -410,17 +426,18 @@ store, deps) {
|
|
|
410
426
|
// booked) only while the tool holds it.
|
|
411
427
|
if (kind === "browser") {
|
|
412
428
|
// The run's sessions of a lower claim epoch go first, as a computer's do (the janitor's releaseOlder).
|
|
413
|
-
|
|
414
|
-
if (!older.ok)
|
|
415
|
-
throw new Error(older.error.message);
|
|
429
|
+
await releaseOlderClaims(provider, launch, signal);
|
|
416
430
|
const opened = claimBrowser(provider, spec);
|
|
417
431
|
madeBy = entry;
|
|
418
432
|
return { id: entry.id, groups: ["cdp"], browser: opened.browser, release: opened.release };
|
|
419
433
|
}
|
|
420
434
|
let launched;
|
|
435
|
+
/** The labels the provider lists this computer under: its owner's for the agent's own, else the run's. */
|
|
436
|
+
let listedUnder = spec.labels ?? {};
|
|
421
437
|
if (persistent) {
|
|
422
438
|
// The agent's own: its owner (this server and the agent), and no run deadline (it outlives the run).
|
|
423
439
|
const owner = { agent: launch.agentId, server: await serverIdOf({ settings: store.settings }) };
|
|
440
|
+
listedUnder = ownerFilter(owner);
|
|
424
441
|
const { lifetimeMs: _, ...owned } = spec;
|
|
425
442
|
launched = await ownedLaunch(provider, launch, { ...owned, owner }, {
|
|
426
443
|
store: { settings: store.settings, agents: store.agents, ...(store.runs ? { runs: store.runs } : {}) },
|
|
@@ -432,9 +449,10 @@ store, deps) {
|
|
|
432
449
|
}, signal);
|
|
433
450
|
}
|
|
434
451
|
else {
|
|
452
|
+
deps.onStarting?.({ provider: entry.label, kind: kind });
|
|
435
453
|
launched = await providerLaunch(provider, launch, spec, signal);
|
|
436
454
|
}
|
|
437
|
-
made = { id: launched.id, machine: launched.machine, ...(launched.watch ? { watch: launched.watch } : {}) };
|
|
455
|
+
made = { id: launched.id, machine: launched.machine, ...(launched.watch ? { watch: launched.watch, ...(kind === "desktop" || kind === "phone" ? { gone: goneOf(provider, launched.id, listedUnder, kind) } : {}) } : {}) };
|
|
438
456
|
madeBy = entry;
|
|
439
457
|
const { os, osVersion, arch } = launched.hello;
|
|
440
458
|
deps.onConnected?.({ provider: entry.label, kind: kind, hello: { os, ...(osVersion ? { osVersion } : {}), arch } });
|
|
@@ -477,7 +495,7 @@ store, deps) {
|
|
|
477
495
|
if (deps.openComputerView && made?.watch) {
|
|
478
496
|
const watch = made.watch;
|
|
479
497
|
const input = computer.kind === "desktop" ? "desktop" : phonePlatform(made.machine, madeBy);
|
|
480
|
-
const opened = await deps.openComputerView({ store, sealKey: deps.sealKey, claim: launch.claim ?? { runId: launch.runId, epoch: launch.epoch }, kind: computer.kind, input, tag: made.id, watch, hold: theHold });
|
|
498
|
+
const opened = await deps.openComputerView({ store, sealKey: deps.sealKey, claim: launch.claim ?? { runId: launch.runId, epoch: launch.epoch }, kind: computer.kind, input, tag: made.id, watch, hold: theHold, ...(made.gone ? { gone: made.gone } : {}) });
|
|
481
499
|
if (!opened.ok) {
|
|
482
500
|
await started.release().catch(() => undefined);
|
|
483
501
|
await revoke().catch(() => undefined);
|