@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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// A tool's catalog name, read and written in one place: the grammar every place that takes one holds it to (an agent's
|
|
2
|
+
// grant, the tool settings, a learned workflow, a template's manifest and evals, the API's schemas). A catalog name is
|
|
3
|
+
// <tool> a tool of this server (`read`, `web_fetch`, `decisions.jev`)
|
|
4
|
+
// <source>:<group>/<action> one tool of a source: `mcp:<server>/<tool>`, `monid:<provider>/<endpoint>`
|
|
5
|
+
// <source>:<group>/* every tool of a group (a settings key, and a grant read against its listing)
|
|
6
|
+
// An MCP server's name is lowercase letters, digits and `-`, starting with a letter, at most 32 (no `_`, so
|
|
7
|
+
// `mcp__<server>__<tool>` splits one way). An MCP tool's own name is letters, digits, `_` and `-`, at most 64: the
|
|
8
|
+
// characters the model APIs take in a tool's name, so there is one charset, and a name one place takes no other refuses.
|
|
9
|
+
// A monid provider's slug and an endpoint's path are monid's own (its listing, GET /v1/endpoints): a slug is lowercase
|
|
10
|
+
// letters, digits, `.` and `-` (`apollo`, `api.strale.io`); an endpoint is its path less the leading `/`, in letters,
|
|
11
|
+
// digits and `-._:{}/` (`people/match`, `people/{id}`). Its wire name is catalog.ts wireName's, hashed when long.
|
|
12
|
+
import { WIRE_NAME } from "./catalog.js";
|
|
13
|
+
const SERVER = "[a-z][a-z0-9-]{0,31}";
|
|
14
|
+
const TOOL = "[A-Za-z0-9_-]{1,64}";
|
|
15
|
+
const PROVIDER = "[a-z0-9][a-z0-9.-]{0,63}";
|
|
16
|
+
const ENDPOINT = "[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}";
|
|
17
|
+
const PLAIN = `[a-z][a-z0-9_-]{0,63}(?:\\.${TOOL})?`;
|
|
18
|
+
const MCP_PREFIX = "mcp:";
|
|
19
|
+
const MONID_PREFIX = "monid:";
|
|
20
|
+
const ALL = "*";
|
|
21
|
+
/** An MCP server's name. */
|
|
22
|
+
export const MCP_SERVER_NAME = new RegExp(`^${SERVER}$`);
|
|
23
|
+
/** An MCP tool's own name, as its server lists it. */
|
|
24
|
+
export const MCP_TOOL_NAME = new RegExp(`^${TOOL}$`);
|
|
25
|
+
/** A catalog tool's name, as a JSON Schema pattern (openapi.ts): `mcp:<server>/<tool>`, `monid:<provider>/<endpoint>`,
|
|
26
|
+
* or either's wildcard. */
|
|
27
|
+
export const CATALOG_KEY_PATTERN = `^(?:mcp:${SERVER}/(?:\\*|${TOOL})|monid:${PROVIDER}/(?:\\*|${ENDPOINT}))$`;
|
|
28
|
+
const MCP_NAME = new RegExp(`^mcp:(${SERVER})/(\\*|${TOOL})$`);
|
|
29
|
+
const MONID_NAME = new RegExp(`^monid:(${PROVIDER})/(\\*|${ENDPOINT})$`);
|
|
30
|
+
const PLAIN_NAME = new RegExp(`^${PLAIN}$`);
|
|
31
|
+
/** Catalog name `name` read, or undefined for one outside the grammar. */
|
|
32
|
+
export function parseToolName(name) {
|
|
33
|
+
if (isMonidName(name)) {
|
|
34
|
+
const match = MONID_NAME.exec(name);
|
|
35
|
+
if (!match)
|
|
36
|
+
return undefined;
|
|
37
|
+
return match[2] === ALL ? { kind: "monid-provider", provider: match[1] } : { kind: "monid", provider: match[1], endpoint: match[2] };
|
|
38
|
+
}
|
|
39
|
+
if (!isMcpName(name))
|
|
40
|
+
return PLAIN_NAME.test(name) ? { kind: "plain", name } : undefined;
|
|
41
|
+
const match = MCP_NAME.exec(name);
|
|
42
|
+
if (!match)
|
|
43
|
+
return undefined;
|
|
44
|
+
return match[2] === ALL ? { kind: "mcp-server", server: match[1] } : { kind: "mcp", server: match[1], tool: match[2] };
|
|
45
|
+
}
|
|
46
|
+
/** The catalog name of `name`: parseToolName's inverse. */
|
|
47
|
+
export function formatToolName(name) {
|
|
48
|
+
if (name.kind === "plain")
|
|
49
|
+
return name.name;
|
|
50
|
+
if (name.kind === "monid" || name.kind === "monid-provider")
|
|
51
|
+
return `${MONID_PREFIX}${name.provider}/${name.kind === "monid" ? name.endpoint : ALL}`;
|
|
52
|
+
return `${MCP_PREFIX}${name.server}/${name.kind === "mcp" ? name.tool : ALL}`;
|
|
53
|
+
}
|
|
54
|
+
/** Whether `name` is in monid's namespace (`monid:`), well formed or not, as isMcpName is for MCP's. */
|
|
55
|
+
export const isMonidName = (name) => name.startsWith(MONID_PREFIX);
|
|
56
|
+
/** Whether `name` is a third-party catalog's (MCP's or monid's), well formed or not: its default is ask. */
|
|
57
|
+
export const isCatalogName = (name) => isMcpName(name) || isMonidName(name);
|
|
58
|
+
/** Why `name`, in monid's namespace, is refused as a grant by its name alone. */
|
|
59
|
+
export const MONID_NAME_WORDS = (name) => `${name} is not a monid endpoint's name: monid:<provider>/<endpoint> or monid:<provider>/*, the provider's slug (lowercase letters, digits, . and -) and the endpoint's path without its first / (letters, digits and -._:{}/), as monid lists them.`;
|
|
60
|
+
/** One monid endpoint's catalog name read (`monid:<provider>/<endpoint>`), or undefined for any other name. */
|
|
61
|
+
export function monidNameOf(name) {
|
|
62
|
+
const parsed = parseToolName(name);
|
|
63
|
+
return parsed?.kind === "monid" ? { provider: parsed.provider, endpoint: parsed.endpoint } : undefined;
|
|
64
|
+
}
|
|
65
|
+
/** One MCP tool's catalog name, `mcp:<server>/<tool>`: what the gate, the pin and the timeline key its calls by. */
|
|
66
|
+
export const mcpToolName = (server, tool) => formatToolName({ kind: "mcp", server, tool });
|
|
67
|
+
/** Whether `name` is in MCP's namespace (`mcp:`), well formed or not: a name MCP's checks answer for, so one that does
|
|
68
|
+
* not parse is refused in MCP's words, and the gate's default for it is MCP's (ask), never a built-in's. */
|
|
69
|
+
export const isMcpName = (name) => name.startsWith(MCP_PREFIX);
|
|
70
|
+
/** One MCP tool's catalog name read (`mcp:<server>/<tool>`), or undefined for any other name, a server's wildcard too. */
|
|
71
|
+
export function mcpNameOf(name) {
|
|
72
|
+
const parsed = parseToolName(name);
|
|
73
|
+
return parsed?.kind === "mcp" ? { server: parsed.server, tool: parsed.tool } : undefined;
|
|
74
|
+
}
|
|
75
|
+
/** The MCP server `name` names, one of its tools or its wildcard; undefined for any other name. */
|
|
76
|
+
export function mcpServerOf(name) {
|
|
77
|
+
const parsed = parseToolName(name);
|
|
78
|
+
return parsed?.kind === "mcp" || parsed?.kind === "mcp-server" ? parsed.server : undefined;
|
|
79
|
+
}
|
|
80
|
+
/** Whether `name` is an MCP server's wildcard, `mcp:<server>/*`. */
|
|
81
|
+
export const isMcpWildcard = (name) => parseToolName(name)?.kind === "mcp-server";
|
|
82
|
+
/** Why a grant of an MCP server's tool is refused by its name alone, said after the grant (`mcp:<server>/<tool> ...`): the
|
|
83
|
+
* one place the console's picker and the save's blockers (runnable.ts) both read it. `hands` is the harnesses' own tools'
|
|
84
|
+
* server. */
|
|
85
|
+
export const MCP_HANDS_WORDS = "names the MCP server hands, a name the harnesses keep for their own tools: save the server under another name.";
|
|
86
|
+
/** Why `mcp__<server>__<tool>`, the name every harness calls the tool by, is not within the budget their names share
|
|
87
|
+
* (52 characters of letters, digits, `_` and `-`), or undefined when it is. */
|
|
88
|
+
export function mcpWireProblem(server, tool) {
|
|
89
|
+
const wire = `mcp__${server}__${tool}`;
|
|
90
|
+
return WIRE_NAME.test(wire) ? undefined : `is too long: ${wire} must be at most 52 characters, the budget every harness's tool names share.`;
|
|
91
|
+
}
|
|
92
|
+
/** MCP_HANDS_WORDS or mcpWireProblem's, whichever refuses the name; undefined when neither does. */
|
|
93
|
+
export const mcpGrantNameProblem = (server, tool) => (server === "hands" ? MCP_HANDS_WORDS : mcpWireProblem(server, tool));
|
|
94
|
+
/** Why a harness's own MCP client drops or retypes `tool` of `server` (its facts' schemaProblems, `dropped` the first):
|
|
95
|
+
* the words a save's blocker and a saved server's read both say. */
|
|
96
|
+
export const mcpDroppedWords = (server, tool, harness, dropped) => `The MCP server ${server}'s tool ${tool} cannot be offered on ${harness}: ${dropped.replace(/^mcp__\S+: /, "")}.`;
|
|
97
|
+
/** Why the harness drops or retypes the pinned monid endpoint `tool`'s input (its facts' schemaProblems, `dropped` the
|
|
98
|
+
* first, under the endpoint's wire name): the words a save refuses its grant with. */
|
|
99
|
+
export const monidDroppedWords = (tool, harness, dropped) => `The monid endpoint ${tool} cannot be offered on ${harness}: ${dropped.replace(/^monid__\S+: /, "")}. Grant its provider's other endpoints by name, or pick another harness.`;
|
package/dist/tool-plane.d.ts
CHANGED
|
@@ -2,13 +2,14 @@ import type { InputIssue } from "./errors.js";
|
|
|
2
2
|
import type { Settings } from "./store/index.js";
|
|
3
3
|
import { type HarnessId } from "./harness.js";
|
|
4
4
|
import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
|
|
5
|
-
import { type Permission, type Pin } from "./tool-gate.js";
|
|
5
|
+
import { type Permission, type Pin, type ToolEffect } from "./tool-gate.js";
|
|
6
6
|
import { type BashPolicy } from "./bash-read-only.js";
|
|
7
7
|
/**
|
|
8
8
|
* The capabilities a pack or a revision may grant, by name: the tools the kernel gives a run, bound from serve's closed
|
|
9
9
|
* table (tools.ts) and named the same on every harness that runs them. `web_search` and `web_fetch` resolve to a
|
|
10
10
|
* provider (PROVIDERS); the rest are the kernel's own. Not capabilities: the workflow call nodes' `pdf_pages` and `llm` (a workflow's call node names them, a grant
|
|
11
|
-
* never does), and a catalog's tools (`
|
|
11
|
+
* never does), and a catalog's tools (`mcp:<server>/<tool>`, `monid:<provider>/<endpoint>`: catalog tools, which their
|
|
12
|
+
* catalog grants).
|
|
12
13
|
*/
|
|
13
14
|
export declare const CAPABILITIES: readonly ["read", "write", "edit", "web_search", "web_fetch", "browser", "ask_person"];
|
|
14
15
|
/** The providers a user may pick for each capability that has a choice, its default first: `auto`, the native search
|
|
@@ -27,24 +28,23 @@ export declare const PROVIDERS: Readonly<{
|
|
|
27
28
|
}>;
|
|
28
29
|
export type Pickable = keyof typeof PROVIDERS;
|
|
29
30
|
export declare const PICKABLE: Pickable[];
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* offered for these and for catalog tools. Any other (browser, ask_person, the call-only ones) is allow or deny. The
|
|
34
|
-
* run's learned_workflow is one (tool-gate.ts runs an approved call of it on the run's own tools). */
|
|
35
|
-
export declare const ASKABLE: readonly string[];
|
|
36
|
-
/** The permissions `name` may be set to. */
|
|
31
|
+
/** The permissions `name` may be set to: ask is offered for the tools whose approved call the kernel runs itself, outside
|
|
32
|
+
* the model's turn (tool-list.ts `askable`) and for catalog tools. Any other (browser, ask_person, the call-only ones) is
|
|
33
|
+
* allow or deny. */
|
|
37
34
|
export declare const permissionsOf: (name: string) => readonly Permission[];
|
|
38
35
|
/** A tool's permission as this server applies it to an agent that sets none, as capabilities and an MCP server's read
|
|
39
36
|
* give it: the one in force under the server's settings (`permission`), the owner's default (`default_permission`) and
|
|
40
37
|
* those it may be set to. An agent's read gives the same, the agent's own layer over it (agentTools). */
|
|
41
|
-
export declare const serverGate: (name: string, settings: ToolSettingsMap) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
export declare const serverGate: (name: string, settings: ToolSettingsMap, effect?: ToolEffect) => {
|
|
39
|
+
default_permission: "ask" | "deny" | "allow";
|
|
40
|
+
permissions: ("ask" | "deny" | "allow")[];
|
|
41
|
+
fallback_allow_reads?: true | undefined;
|
|
42
|
+
allow_reads?: true | undefined;
|
|
43
|
+
permission: "ask" | "deny" | "allow";
|
|
45
44
|
};
|
|
46
45
|
/** The run's own tools beyond the table, each its own settings key, allowed by default like a table tool: the learned
|
|
47
|
-
* workflow a run's pin names runs as `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL)
|
|
46
|
+
* workflow a run's pin names runs as `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL), and the host's
|
|
47
|
+
* `tools_search`, `tools_call` and `codemode` (runner/meta-tools.ts): set to deny, one is not offered to a run. */
|
|
48
48
|
export declare const SERVE_OWN_TOOLS: readonly string[];
|
|
49
49
|
/** A computer kind's tools, one settings key per kind, as `browser` holds the browser's family: every desktop tool is
|
|
50
50
|
* held to `desktop`, every phone tool to `phone` (the kernel registry's definitions name the key; tool-gate.ts
|
|
@@ -59,7 +59,8 @@ export declare const DECISION_PROVIDER_KEYS: readonly string[];
|
|
|
59
59
|
export type ToolSetting = {
|
|
60
60
|
provider?: string;
|
|
61
61
|
permission?: Permission;
|
|
62
|
-
pin?: Pin; /**
|
|
62
|
+
pin?: Pin; /** On an MCP server's wildcard (`mcp:<server>/*`) in the server's settings only: the tools its server marks read-only run with no approval (tool-gate.ts readsLift). Kept only when true. */
|
|
63
|
+
allow_reads?: true; /** bash's policy, an agent's own only (bash-read-only.ts). */
|
|
63
64
|
policy?: BashPolicy; /** Read as a stand-in for a value not offered (checkToolSettings); never shown or written. */
|
|
64
65
|
fallback?: true; /** The stand-in's value as written in the file, which a save that keeps the stand-in writes back (ToolSettings.put). Never shown. */
|
|
65
66
|
raw?: unknown; /** A pin in the file that does not read (readToolSettings): the gate refuses every call of the tool, and a save keeps it (ToolSettings.put) until the owner sets a valid pin or removes the tool's setting. Served as `pin_broken: true`. */
|
|
@@ -71,8 +72,9 @@ export declare const MAX_PIN_TEXT = 1024;
|
|
|
71
72
|
/** The one check of a pin, every place that takes one calls it (the server's settings, an agent's, a template's mcp
|
|
72
73
|
* entry, the store's revision bodies at the cutover): `pin` under `at`, an object of 1 to MAX_PIN_ARGS of a tool's
|
|
73
74
|
* top-level arguments (PIN_ARG), each to a JSON scalar (a string of at most MAX_PIN_TEXT characters, a finite number,
|
|
74
|
-
* true or false, or null: left out) or a list of 1 to MAX_PIN_CHOICES of them, the argument one of the list
|
|
75
|
-
*
|
|
75
|
+
* true or false, or null: left out) or a list of 1 to MAX_PIN_CHOICES of them, the argument one of the list, or
|
|
76
|
+
* `{keys: [...]}`, 1 to MAX_PIN_CHOICES key names (text of 1 to MAX_PIN_TEXT characters) an object argument may hold,
|
|
77
|
+
* nothing else in it (sortedPin is its one form). With
|
|
76
78
|
* `key`, the settings key it is set on, which is one MCP tool's own (`mcp:<server>/<tool>`), never a server's wildcard,
|
|
77
79
|
* whose tools take other arguments, nor any other tool's. */
|
|
78
80
|
export declare function pinIssues(pin: unknown, at: string, key?: string): InputIssue[];
|
|
@@ -277,19 +279,19 @@ export declare function shellUnavailable(name: string, shell: ShellPlace): Resol
|
|
|
277
279
|
* provider choice the provider in force and where it came from, the one that applies when the agent sets none, and what
|
|
278
280
|
* it resolves to on the agent's harness and model. `shell`: where a run of the agent has its shell (runShellOf on its
|
|
279
281
|
* computer setting); a tool of bash's family that leaves out resolves unavailable, saying why (shellUnavailable). */
|
|
280
|
-
export declare function agentTools(env: NodeJS.ProcessEnv, settings: ToolSettingsMap, agent: Tooling, order: readonly string[], shell?: ShellPlace): ({
|
|
282
|
+
export declare function agentTools(env: NodeJS.ProcessEnv, settings: ToolSettingsMap, agent: Tooling, order: readonly string[], shell?: ShellPlace, effectOf?: (name: string) => ToolEffect | undefined): ({
|
|
281
283
|
resolved: Resolution;
|
|
282
|
-
permission: "
|
|
284
|
+
permission: "ask" | "deny" | "allow";
|
|
283
285
|
permission_from: import("./refusal-words.js").SettingFrom;
|
|
284
|
-
default_permission: "
|
|
285
|
-
permissions: ("
|
|
286
|
+
default_permission: "ask" | "deny" | "allow";
|
|
287
|
+
permissions: ("ask" | "deny" | "allow")[];
|
|
286
288
|
blurb?: string | undefined;
|
|
287
289
|
name: string;
|
|
288
290
|
} | {
|
|
289
|
-
permission: "
|
|
291
|
+
permission: "ask" | "deny" | "allow";
|
|
290
292
|
permission_from: import("./refusal-words.js").SettingFrom;
|
|
291
|
-
default_permission: "
|
|
292
|
-
permissions: ("
|
|
293
|
+
default_permission: "ask" | "deny" | "allow";
|
|
294
|
+
permissions: ("ask" | "deny" | "allow")[];
|
|
293
295
|
blurb?: string | undefined;
|
|
294
296
|
name: string;
|
|
295
297
|
} | {
|
|
@@ -297,10 +299,10 @@ export declare function agentTools(env: NodeJS.ProcessEnv, settings: ToolSetting
|
|
|
297
299
|
provider_from: string;
|
|
298
300
|
default_provider: string;
|
|
299
301
|
resolved: Resolution;
|
|
300
|
-
permission: "
|
|
302
|
+
permission: "ask" | "deny" | "allow";
|
|
301
303
|
permission_from: import("./refusal-words.js").SettingFrom;
|
|
302
|
-
default_permission: "
|
|
303
|
-
permissions: ("
|
|
304
|
+
default_permission: "ask" | "deny" | "allow";
|
|
305
|
+
permissions: ("ask" | "deny" | "allow")[];
|
|
304
306
|
blurb?: string | undefined;
|
|
305
307
|
name: string;
|
|
306
308
|
})[];
|
package/dist/tool-plane.js
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
// harness's own search (inside its CLI, where no call can wait for a person) gives way to the kernel's. A run is never
|
|
20
20
|
// told a deny: its Plane resolves a denied capability as under ask, and the gate, which reads the permission at each
|
|
21
21
|
// call, is the one place that refuses it, so a deny lifted mid-run is lifted at the next call.
|
|
22
|
-
import {
|
|
22
|
+
import { META_TOOLS } from "./meta-tool-names.js";
|
|
23
|
+
import { blurbOf, isAskable, isTableTool, tableTools } from "./tool-list.js";
|
|
23
24
|
import { PROVIDERS as COMPUTER_PROVIDERS } from "@parcha/agentrun-computer";
|
|
24
25
|
import { decisionKeysOf, PARALLEL_KEY_ENV } from "./decisions.js";
|
|
25
26
|
import { keyNeeded } from "./key-words.js";
|
|
@@ -29,13 +30,15 @@ import { viaOpenRouter, WIRES } from "./provider.js";
|
|
|
29
30
|
import { savedIn } from "./secrets.js";
|
|
30
31
|
import { hostModel } from "./model.js";
|
|
31
32
|
import { NEEDS_A_COMPUTER, NO_SHELL } from "@parcha/agentrun-kernel/kernel";
|
|
32
|
-
import { canonicalPin, defaultPermission, isCatalogTool,
|
|
33
|
+
import { canonicalPin, defaultPermission, isCatalogTool, isPinKeys, MAX_PIN_ARGS, MAX_PIN_CHOICES, PERMISSIONS, permissionFrom, permissionOf, SETTINGS_UNREAD, SHELL_FAMILY } from "./tool-gate.js";
|
|
33
34
|
import { BASH_POLICIES } from "./bash-read-only.js";
|
|
35
|
+
import { isMcpName, mcpNameOf, parseToolName } from "./tool-names.js";
|
|
34
36
|
/**
|
|
35
37
|
* The capabilities a pack or a revision may grant, by name: the tools the kernel gives a run, bound from serve's closed
|
|
36
38
|
* table (tools.ts) and named the same on every harness that runs them. `web_search` and `web_fetch` resolve to a
|
|
37
39
|
* provider (PROVIDERS); the rest are the kernel's own. Not capabilities: the workflow call nodes' `pdf_pages` and `llm` (a workflow's call node names them, a grant
|
|
38
|
-
* never does), and a catalog's tools (`
|
|
40
|
+
* never does), and a catalog's tools (`mcp:<server>/<tool>`, `monid:<provider>/<endpoint>`: catalog tools, which their
|
|
41
|
+
* catalog grants).
|
|
39
42
|
*/
|
|
40
43
|
export const CAPABILITIES = ["read", "write", "edit", "web_search", "web_fetch", "browser", "ask_person"];
|
|
41
44
|
/** The providers a user may pick for each capability that has a choice, its default first: `auto`, the native search
|
|
@@ -49,21 +52,36 @@ export const CAPABILITIES = ["read", "write", "edit", "web_search", "web_fetch",
|
|
|
49
52
|
* (browserBy). */
|
|
50
53
|
export const PROVIDERS = Object.freeze({ web_search: ["auto", "native", "exa-keyless", "parallel", "off"], web_fetch: ["kernel", "parallel"], browser: Object.freeze(["auto", ...browserProviderIds(), "chrome"]) });
|
|
51
54
|
export const PICKABLE = Object.keys(PROVIDERS);
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* run's learned_workflow is one (tool-gate.ts runs an approved call of it on the run's own tools). */
|
|
57
|
-
export const ASKABLE = ["read", "write", "edit", "bash", "web_fetch", "web_search", "learned_workflow"];
|
|
58
|
-
/** The permissions `name` may be set to. */
|
|
59
|
-
export const permissionsOf = (name) => (Object.hasOwn(SHELL_FAMILY, name) && SHELL_FAMILY[name] !== name ? permissionsOf(SHELL_FAMILY[name]) : ASKABLE.includes(name) || isCatalogTool(name) ? PERMISSIONS : ["allow", "deny"]);
|
|
55
|
+
/** The permissions `name` may be set to: ask is offered for the tools whose approved call the kernel runs itself, outside
|
|
56
|
+
* the model's turn (tool-list.ts `askable`) and for catalog tools. Any other (browser, ask_person, the call-only ones) is
|
|
57
|
+
* allow or deny. */
|
|
58
|
+
export const permissionsOf = (name) => (Object.hasOwn(SHELL_FAMILY, name) && SHELL_FAMILY[name] !== name ? permissionsOf(SHELL_FAMILY[name]) : isAskable(name) || isCatalogTool(name) ? PERMISSIONS : ["allow", "deny"]);
|
|
60
59
|
/** A tool's permission as this server applies it to an agent that sets none, as capabilities and an MCP server's read
|
|
61
60
|
* give it: the one in force under the server's settings (`permission`), the owner's default (`default_permission`) and
|
|
62
61
|
* those it may be set to. An agent's read gives the same, the agent's own layer over it (agentTools). */
|
|
63
|
-
export const serverGate = (name, settings) =>
|
|
62
|
+
export const serverGate = (name, settings, effect) => {
|
|
63
|
+
const permission = permissionOf(name, settings, {}, "ask", effect);
|
|
64
|
+
// `allow_reads`: the allow is its server's "allow reads" (a read-only tool's ask lifted), not a setting or a default.
|
|
65
|
+
const lifted = effect === "read" && permission === "allow" && permissionOf(name, settings) === "ask";
|
|
66
|
+
// `fallback_allow_reads`: with no permission on the tool's own key, its server's "allow reads" would lift its ask, so
|
|
67
|
+
// allow is what applies once that setting goes, whatever the setting says now (the console's "allow reads" fallback).
|
|
68
|
+
const unset = effect === "read" ? withoutOwnPermission(name, settings) : undefined;
|
|
69
|
+
const falls = unset !== undefined && permissionOf(name, unset, {}, "ask", effect) === "allow" && permissionOf(name, unset) === "ask";
|
|
70
|
+
return { permission, ...(lifted ? { allow_reads: true } : {}), ...(falls ? { fallback_allow_reads: true } : {}), default_permission: defaultPermission(name), permissions: [...permissionsOf(name)] };
|
|
71
|
+
};
|
|
72
|
+
/** `settings` with no permission on `name`'s own key (its other fields kept), a copy that keeps the map's marks
|
|
73
|
+
* (SETTINGS_UNREAD, carried by the spread). */
|
|
74
|
+
const withoutOwnPermission = (name, settings) => {
|
|
75
|
+
const own = settings[name];
|
|
76
|
+
if (own?.permission === undefined)
|
|
77
|
+
return settings;
|
|
78
|
+
const { permission: _gone, ...kept } = own;
|
|
79
|
+
return { ...settings, [name]: kept };
|
|
80
|
+
};
|
|
64
81
|
/** The run's own tools beyond the table, each its own settings key, allowed by default like a table tool: the learned
|
|
65
|
-
* workflow a run's pin names runs as `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL)
|
|
66
|
-
|
|
82
|
+
* workflow a run's pin names runs as `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL), and the host's
|
|
83
|
+
* `tools_search`, `tools_call` and `codemode` (runner/meta-tools.ts): set to deny, one is not offered to a run. */
|
|
84
|
+
export const SERVE_OWN_TOOLS = ["learned_workflow", ...META_TOOLS];
|
|
67
85
|
/** A computer kind's tools, one settings key per kind, as `browser` holds the browser's family: every desktop tool is
|
|
68
86
|
* held to `desktop`, every phone tool to `phone` (the kernel registry's definitions name the key; tool-gate.ts
|
|
69
87
|
* settingsKeyOf reads it there). Allowed by default like a table tool; allow or deny. */
|
|
@@ -74,13 +92,9 @@ export const KIND_KEYS = ["desktop", "phone"];
|
|
|
74
92
|
export const DECISION_PROVIDER_KEYS = ["jev", "parallel", "openrouter"];
|
|
75
93
|
/** A settings key: a tool of the table, one of the run's own tools (SERVE_OWN_TOOLS), a computer kind's (KIND_KEYS), a
|
|
76
94
|
* decision provider's (DECISION_PROVIDER_KEYS), a
|
|
77
|
-
* catalog tool (`
|
|
78
|
-
* of its tools. */
|
|
79
|
-
|
|
80
|
-
* server's tool (`mcp:<server>/<tool>`) or its wildcard (`mcp:<server>/*`). */
|
|
81
|
-
const TOOL_KEY = /^(?:[a-z][a-z0-9_-]{0,63}(?:\.[A-Za-z0-9_-]{1,64})?|mcp:[A-Za-z0-9_.-]{1,64}\/(?:\*|[A-Za-z0-9_.-]{1,128}))$/;
|
|
82
|
-
const isToolSettingsKey = (name) => TOOL_KEY.test(name);
|
|
83
|
-
const isSettingsKey = (name) => isToolSettingsKey(name) && (TABLE_TOOLS.includes(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || DECISION_PROVIDER_KEYS.includes(name) || isCatalogTool(name) || /^mcp:[^/]+\/\*$/.test(name));
|
|
95
|
+
* catalog tool (`mcp:<server>/<tool>`, `monid:<provider>/<endpoint>`), or a group's wildcard (`mcp:<server>/*`,
|
|
96
|
+
* `monid:<provider>/*`), which sets each of its tools. */
|
|
97
|
+
const isSettingsKey = (name) => parseToolName(name) !== undefined && (isTableTool(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || DECISION_PROVIDER_KEYS.includes(name) || isCatalogTool(name));
|
|
84
98
|
/** The longest pinned string. */
|
|
85
99
|
export const MAX_PIN_TEXT = 1024;
|
|
86
100
|
/** A pinned argument's name: a top-level argument of the tool, as MCP tools name theirs. */
|
|
@@ -88,12 +102,13 @@ const PIN_ARG = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;
|
|
|
88
102
|
/** The one check of a pin, every place that takes one calls it (the server's settings, an agent's, a template's mcp
|
|
89
103
|
* entry, the store's revision bodies at the cutover): `pin` under `at`, an object of 1 to MAX_PIN_ARGS of a tool's
|
|
90
104
|
* top-level arguments (PIN_ARG), each to a JSON scalar (a string of at most MAX_PIN_TEXT characters, a finite number,
|
|
91
|
-
* true or false, or null: left out) or a list of 1 to MAX_PIN_CHOICES of them, the argument one of the list
|
|
92
|
-
*
|
|
105
|
+
* true or false, or null: left out) or a list of 1 to MAX_PIN_CHOICES of them, the argument one of the list, or
|
|
106
|
+
* `{keys: [...]}`, 1 to MAX_PIN_CHOICES key names (text of 1 to MAX_PIN_TEXT characters) an object argument may hold,
|
|
107
|
+
* nothing else in it (sortedPin is its one form). With
|
|
93
108
|
* `key`, the settings key it is set on, which is one MCP tool's own (`mcp:<server>/<tool>`), never a server's wildcard,
|
|
94
109
|
* whose tools take other arguments, nor any other tool's. */
|
|
95
110
|
export function pinIssues(pin, at, key) {
|
|
96
|
-
if (key !== undefined &&
|
|
111
|
+
if (key !== undefined && !mcpNameOf(key))
|
|
97
112
|
return [{ field: at, reason: "not_allowed", message: `A pin is set on one MCP tool's own key (mcp:<server>/<tool>), never on ${key}.` }];
|
|
98
113
|
const entries = typeof pin === "object" && pin !== null && !Array.isArray(pin) ? Object.entries(pin) : undefined;
|
|
99
114
|
if (!entries || !entries.length || entries.length > MAX_PIN_ARGS)
|
|
@@ -102,10 +117,15 @@ export function pinIssues(pin, at, key) {
|
|
|
102
117
|
return entries.flatMap(([arg, value]) => {
|
|
103
118
|
if (!PIN_ARG.test(arg))
|
|
104
119
|
return [{ field: `${at}.${arg}`, reason: "bad_format", message: `${at} names a top-level argument of the tool (${PIN_ARG.source}); ${JSON.stringify(arg).slice(0, 60)} is none` }];
|
|
105
|
-
const held = Array.isArray(value) ? value.length >= 1 && value.length <= MAX_PIN_CHOICES && value.every(scalar) : scalar(value);
|
|
106
|
-
return held ? [] : [{ field: `${at}.${arg}`, reason: "wrong_type", message: `${at}.${arg} is a JSON scalar (a string of at most ${MAX_PIN_TEXT} characters, a number, true or false, or null: the argument left out) or a list of 1 to ${MAX_PIN_CHOICES} of them, the argument one of the list` }];
|
|
120
|
+
const held = Array.isArray(value) ? value.length >= 1 && value.length <= MAX_PIN_CHOICES && value.every(scalar) : isPinKeys(value) ? keysRead(value) : scalar(value);
|
|
121
|
+
return held ? [] : [{ field: `${at}.${arg}`, reason: "wrong_type", message: `${at}.${arg} is a JSON scalar (a string of at most ${MAX_PIN_TEXT} characters, a number, true or false, or null: the argument left out) or a list of 1 to ${MAX_PIN_CHOICES} of them, the argument one of the list; or {keys: [<key>, ...]}: 1 to ${MAX_PIN_CHOICES} names (each text of 1 to ${MAX_PIN_TEXT} characters) of the keys an object argument may hold, any values, nothing else beside keys` }];
|
|
107
122
|
});
|
|
108
123
|
}
|
|
124
|
+
/** Whether a keys pin's object reads: `keys` alone, a list of 1 to MAX_PIN_CHOICES non-empty texts of at most MAX_PIN_TEXT. */
|
|
125
|
+
const keysRead = (value) => {
|
|
126
|
+
const { keys, ...rest } = value;
|
|
127
|
+
return !Object.keys(rest).length && Array.isArray(keys) && keys.length >= 1 && keys.length <= MAX_PIN_CHOICES && keys.every((key) => typeof key === "string" && key.length >= 1 && key.length <= MAX_PIN_TEXT);
|
|
128
|
+
};
|
|
109
129
|
/** `pin` in the one form a revision's body keeps (tool-gate.ts canonicalPin): its arguments sorted, each one-of list
|
|
110
130
|
* de-duplicated and sorted, null first, then by each value's JSON text. Equal meanings are one text, so one revision. */
|
|
111
131
|
export const sortedPin = (pin) => canonicalPin(pin);
|
|
@@ -374,9 +394,9 @@ export function settingsIssues(value, at = "", layer = "server") {
|
|
|
374
394
|
return Object.entries(value).flatMap(([name, setting]) => {
|
|
375
395
|
const pickable = Object.hasOwn(PROVIDERS, name);
|
|
376
396
|
if (!isSettingsKey(name))
|
|
377
|
-
return [{ field: field(name), reason: "not_allowed", message: `Tool settings are kept for this server's tools (${[...
|
|
397
|
+
return [{ field: field(name), reason: "not_allowed", message: `Tool settings are kept for this server's tools (${[...tableTools(), ...SERVE_OWN_TOOLS, ...KIND_KEYS, ...DECISION_PROVIDER_KEYS].join(", ")}), catalog tools (mcp:<server>/<tool>, monid:<provider>/<endpoint>) and a group's tools (mcp:<server>/*, monid:<provider>/*); ${name} is none of them.` }];
|
|
378
398
|
if (!isPlain(setting))
|
|
379
|
-
return [{ field: field(name), reason: "wrong_type", message: `${field(name)} is an object, {${pickable ? "provider, " : ""}permission${
|
|
399
|
+
return [{ field: field(name), reason: "wrong_type", message: `${field(name)} is an object, {${pickable ? "provider, " : ""}permission${isMcpName(name) ? ", pin" : ""}${layer === "agent" && name === "bash" ? ", policy" : ""}}` }];
|
|
380
400
|
return Object.entries(setting).flatMap(([key, given]) => {
|
|
381
401
|
if (key === "pin")
|
|
382
402
|
return pinIssues(given, field(name, key), name);
|
|
@@ -389,10 +409,16 @@ export function settingsIssues(value, at = "", layer = "server") {
|
|
|
389
409
|
// The server's own mark of a pin in its file that does not read (withDefaults serves it), which a whole-map save
|
|
390
410
|
// sends back: it keeps the broken pin, and nothing else. Never an agent's.
|
|
391
411
|
if (key === "pin_broken") {
|
|
392
|
-
if (layer === "agent" || !
|
|
412
|
+
if (layer === "agent" || !mcpNameOf(name))
|
|
393
413
|
return [{ field: field(name, key), reason: "not_allowed", message: `pin_broken is the server's mark of a pin in its tool settings that does not read, on an MCP tool's own key; ${field(name)} keeps no such field.` }];
|
|
394
414
|
return given === true ? [] : [{ field: field(name, key), reason: "not_an_option", message: `${field(name, key)} is true, as the server serves it: it keeps the broken pin until a valid pin replaces it` }];
|
|
395
415
|
}
|
|
416
|
+
// "Allow reads" (tool-gate.ts readsLift): the server's, on an MCP server's wildcard only; false clears it.
|
|
417
|
+
if (key === "allow_reads") {
|
|
418
|
+
if (layer === "agent" || !/^mcp:[^/]+\/\*$/.test(name))
|
|
419
|
+
return [{ field: field(name, key), reason: "not_allowed", message: `allow_reads is set on an MCP server's wildcard (mcp:<server>/*) in this server's tool settings, never ${layer === "agent" ? "in an agent's own" : `on ${name}`}.` }];
|
|
420
|
+
return typeof given === "boolean" ? [] : [{ field: field(name, key), reason: "wrong_type", message: `${field(name, key)} is true (its read-only tools run with no approval) or false` }];
|
|
421
|
+
}
|
|
396
422
|
if (key === "permission") {
|
|
397
423
|
// A wildcard sets each tool of its server's: a catalog tool's permissions.
|
|
398
424
|
const offered = permissionsOf(name);
|
|
@@ -414,14 +440,14 @@ export function canonicalToolSettings(map) {
|
|
|
414
440
|
return sorted(Object.fromEntries(Object.entries(map).flatMap(([name, setting]) => {
|
|
415
441
|
if (!setting)
|
|
416
442
|
return [];
|
|
417
|
-
const kept = sorted({ ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.pin ? { pin: sortedPin(setting.pin) } : {}), ...(setting.policy ? { policy: setting.policy } : {}), ...(setting.provider ? { provider: setting.provider } : {}) });
|
|
443
|
+
const kept = sorted({ ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.allow_reads === true ? { allow_reads: true } : {}), ...(setting.pin ? { pin: sortedPin(setting.pin) } : {}), ...(setting.policy ? { policy: setting.policy } : {}), ...(setting.provider ? { provider: setting.provider } : {}) });
|
|
418
444
|
return Object.keys(kept).length ? [[name, kept]] : [];
|
|
419
445
|
})));
|
|
420
446
|
}
|
|
421
447
|
/** `map` with each capability's provider, its default where none is picked; a permission where one is set. */
|
|
422
448
|
export const withDefaults = (map) => ({
|
|
423
449
|
// As served: what is in force, never the internal mark of a stand-in.
|
|
424
|
-
...Object.fromEntries(Object.entries(map).map(([name, setting]) => [name, setting && { ...(setting.provider ? { provider: setting.provider } : {}), ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.pin ? { pin: setting.pin } : {}), ...(setting.brokenPin ? { pin_broken: true } : {}) }])),
|
|
450
|
+
...Object.fromEntries(Object.entries(map).map(([name, setting]) => [name, setting && { ...(setting.provider ? { provider: setting.provider } : {}), ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.allow_reads === true ? { allow_reads: true } : {}), ...(setting.pin ? { pin: setting.pin } : {}), ...(setting.brokenPin ? { pin_broken: true } : {}) }])),
|
|
425
451
|
...Object.fromEntries(PICKABLE.map((name) => [name, { provider: map[name]?.provider ?? PROVIDERS[name][0], ...(map[name]?.permission ? { permission: map[name].permission } : {}) }])),
|
|
426
452
|
});
|
|
427
453
|
/** An empty settings map marked as standing for settings that do not read (SETTINGS_UNREAD, tool-gate.ts): every reader
|
|
@@ -500,7 +526,7 @@ export async function loadToolSettings(store) {
|
|
|
500
526
|
* SHELL_WATCHERS). A different permission is a choice, written as given. */
|
|
501
527
|
export function keptSettings(map, current) {
|
|
502
528
|
const kept = Object.fromEntries(Object.entries(map).flatMap(([name, setting]) => {
|
|
503
|
-
const set = { ...(setting?.provider ? { provider: setting.provider } : {}), ...(setting?.permission ? { permission: setting.permission } : {}), ...(setting?.pin ? { pin: setting.pin } : {}) };
|
|
529
|
+
const set = { ...(setting?.provider ? { provider: setting.provider } : {}), ...(setting?.permission ? { permission: setting.permission } : {}), ...(setting?.allow_reads === true ? { allow_reads: true } : {}), ...(setting?.pin ? { pin: setting.pin } : {}) };
|
|
504
530
|
const before = current[name];
|
|
505
531
|
if (before?.fallback && set.permission === before.permission)
|
|
506
532
|
Object.assign(set, { fallback: true, raw: before.raw });
|
|
@@ -508,7 +534,7 @@ export function keptSettings(map, current) {
|
|
|
508
534
|
Object.assign(set, { brokenPin: true, rawPin: before.rawPin });
|
|
509
535
|
return Object.keys(set).length ? [[name, set]] : [];
|
|
510
536
|
}));
|
|
511
|
-
const written = Object.fromEntries(Object.entries(kept).map(([name, setting]) => [name, { ...(setting.provider ? { provider: setting.provider } : {}), ...(setting.fallback ? { permission: setting.raw } : setting.permission ? { permission: setting.permission } : {}), ...(setting.pin ? { pin: setting.pin } : setting.brokenPin ? { pin: setting.rawPin } : {}) }]));
|
|
537
|
+
const written = Object.fromEntries(Object.entries(kept).map(([name, setting]) => [name, { ...(setting.provider ? { provider: setting.provider } : {}), ...(setting.fallback ? { permission: setting.raw } : setting.permission ? { permission: setting.permission } : {}), ...(setting.allow_reads ? { allow_reads: true } : {}), ...(setting.pin ? { pin: setting.pin } : setting.brokenPin ? { pin: setting.rawPin } : {}) }]));
|
|
512
538
|
return { kept, written };
|
|
513
539
|
}
|
|
514
540
|
/** Replaces the server's tool settings in the one store, by keptSettings's rule: a tool `map` leaves out takes its
|
|
@@ -538,13 +564,15 @@ export function shellUnavailable(name, shell) {
|
|
|
538
564
|
* provider choice the provider in force and where it came from, the one that applies when the agent sets none, and what
|
|
539
565
|
* it resolves to on the agent's harness and model. `shell`: where a run of the agent has its shell (runShellOf on its
|
|
540
566
|
* computer setting); a tool of bash's family that leaves out resolves unavailable, saying why (shellUnavailable). */
|
|
541
|
-
export function agentTools(env, settings, agent, order, shell = "computer") {
|
|
567
|
+
export function agentTools(env, settings, agent, order, shell = "computer", effectOf = () => undefined) {
|
|
542
568
|
const plane = planeFor(env, agent, settings);
|
|
543
569
|
const rank = (name) => order.indexOf(name);
|
|
544
570
|
return [...new Set(agent.tools)].sort((a, b) => rank(a) - rank(b)).map((name) => {
|
|
545
|
-
|
|
546
|
-
const
|
|
547
|
-
|
|
571
|
+
// An MCP tool's effect as its saved server lists it now (what a run started now pins): "allow reads" reads it.
|
|
572
|
+
const effect = effectOf(name);
|
|
573
|
+
const { permission, from } = permissionFrom(name, settings, (agent.overrides ?? {}), agent.approvals ?? "ask", {}, effect);
|
|
574
|
+
const gate = { permission, permission_from: from, default_permission: permissionOf(name, settings, {}, "ask", effect), permissions: [...permissionsOf(name)] };
|
|
575
|
+
// One short line for people (tool-list.ts), as capabilities serves it.
|
|
548
576
|
const blurb = blurbOf(name);
|
|
549
577
|
const shown = { name, ...(blurb ? { blurb } : {}) };
|
|
550
578
|
// A tool of bash's family the agent's computer gives no shell for: unavailable, in the words its run's call gets.
|
package/dist/tools.d.ts
CHANGED
|
@@ -222,7 +222,7 @@ export declare const CALL_TOOLS: readonly string[];
|
|
|
222
222
|
export declare const allows: (allowed: readonly string[], name: string) => boolean;
|
|
223
223
|
/** The tools a run's learned workflow may name (learn/check.ts at learn time, learned-workflow.ts at a call): those of the
|
|
224
224
|
* agent's `granted` tools a workflow's call node runs here (CALL_TOOLS, and each MCP tool granted by its own name,
|
|
225
|
-
*
|
|
225
|
+
* 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
|
|
226
226
|
* learned model node runs without tools (learn/skills.ts MODEL_NODE_TOOLS), and a harness's own tool (Bash,
|
|
227
227
|
* exec_command, apply_patch) is never one, so the DSL refuses a draft that names it. */
|
|
228
228
|
export declare const learnedWorkflowTools: (granted: readonly string[], plane?: Plane, options?: LearnedMcp) => string[];
|
|
@@ -285,15 +285,17 @@ export declare const missingEnv: (entry: ToolEntry, env: NodeJS.ProcessEnv) => s
|
|
|
285
285
|
* that their provider refused at the start (tool-keys-store.ts refused), each with why: a tool that needs one is unavailable,
|
|
286
286
|
* saying that. Each tool also gives its permission under the server's settings (tool-gate.ts), the owner's default
|
|
287
287
|
* and the permissions it may be set to. */
|
|
288
|
-
export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettingsMap, noBox?: string, refused?: Readonly<Record<string, string>>, runnerShell?: ReadonlySet<string>) => {
|
|
288
|
+
export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettingsMap, noBox?: string, refused?: Readonly<Record<string, string>>, runnerShell?: ReadonlySet<string>) => ({
|
|
289
289
|
providers?: string[] | undefined;
|
|
290
290
|
provider?: string | undefined;
|
|
291
291
|
default_provider?: string | undefined;
|
|
292
292
|
resolves?: Record<"opencode" | "codex" | "pi" | "claude-agent", Resolution> | undefined;
|
|
293
293
|
why?: Record<"opencode" | "codex" | "pi" | "claude-agent", string> | undefined;
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
294
|
+
default_permission: "ask" | "deny" | "allow";
|
|
295
|
+
permissions: ("ask" | "deny" | "allow")[];
|
|
296
|
+
fallback_allow_reads?: true | undefined;
|
|
297
|
+
allow_reads?: true | undefined;
|
|
298
|
+
permission: "ask" | "deny" | "allow";
|
|
297
299
|
harnesses: ("opencode" | "codex" | "pi" | "claude-agent")[];
|
|
298
300
|
missing?: string[] | undefined;
|
|
299
301
|
reason?: string | undefined;
|
|
@@ -305,4 +307,18 @@ export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettings
|
|
|
305
307
|
blurb?: string | undefined;
|
|
306
308
|
name: string;
|
|
307
309
|
summary: string;
|
|
308
|
-
}
|
|
310
|
+
} | {
|
|
311
|
+
default_permission: "ask" | "deny" | "allow";
|
|
312
|
+
permissions: ("ask" | "deny" | "allow")[];
|
|
313
|
+
fallback_allow_reads?: true | undefined;
|
|
314
|
+
allow_reads?: true | undefined;
|
|
315
|
+
permission: "ask" | "deny" | "allow";
|
|
316
|
+
name: string;
|
|
317
|
+
summary: string;
|
|
318
|
+
blurb: string;
|
|
319
|
+
nodes: boolean;
|
|
320
|
+
calls: boolean;
|
|
321
|
+
meta: true;
|
|
322
|
+
available: boolean;
|
|
323
|
+
harnesses: ("opencode" | "codex" | "pi" | "claude-agent")[];
|
|
324
|
+
})[];
|