@parcha/agentrun-serve 0.1.0-beta.36 → 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 +452 -0
- package/README.md +311 -142
- 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/attach-conformance-cli.d.ts +1 -0
- package/dist/attach-conformance-cli.js +18 -0
- package/dist/attach-conformance.d.ts +25 -0
- package/dist/attach-conformance.js +343 -0
- package/dist/browser-cost.d.ts +1 -1
- package/dist/browser-cost.js +52 -93
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/cap.d.ts +0 -407
- package/dist/cap.js +4 -1028
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +4 -34
- package/dist/cli.js +13 -4
- package/dist/composio-preset.d.ts +53 -0
- package/dist/composio-preset.js +221 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +60 -0
- package/dist/computer-calls.js +209 -0
- package/dist/computer-channel.d.ts +57 -0
- package/dist/computer-channel.js +115 -0
- package/dist/computer-commands.d.ts +1 -1
- package/dist/computer-held-routes.d.ts +35 -0
- package/dist/computer-held-routes.js +106 -0
- package/dist/computer-held.d.ts +48 -0
- package/dist/computer-held.js +87 -0
- package/dist/computer-keys.d.ts +21 -1
- package/dist/computer-keys.js +53 -11
- package/dist/computer-live.d.ts +165 -0
- package/dist/computer-live.js +655 -0
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +14 -0
- package/dist/computer-view.js +51 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +311 -0
- package/dist/computers.d.ts +37 -8
- package/dist/computers.js +62 -14
- 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.d.ts +9 -20
- package/dist/faux-computers.js +56 -26
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/graph-view.d.ts +1 -1
- 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/harness.d.ts +1 -0
- package/dist/harness.js +35 -1
- package/dist/host-tools.d.ts +2 -6
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +5 -6
- package/dist/hosted-search.js +2 -28
- package/dist/import-sources.d.ts +10 -0
- package/dist/import-sources.js +44 -2
- package/dist/import.d.ts +3 -3
- package/dist/import.js +37 -6
- package/dist/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +10 -2
- package/dist/learn/check.js +13 -5
- package/dist/learn/commit.d.ts +14 -2
- package/dist/learn/commit.js +23 -9
- package/dist/learn/compile.d.ts +243 -0
- package/dist/learn/compile.js +471 -0
- package/dist/learn/folder.d.ts +6 -0
- package/dist/learn/folder.js +4 -1
- package/dist/learn/general.d.ts +69 -0
- package/dist/learn/general.js +75 -0
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +29 -7
- 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 +9 -20
- package/dist/learn/reflect.js +18 -125
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +50 -14
- package/dist/learn/skills.js +183 -47
- 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 +43 -3
- package/dist/learned-workflow.js +170 -28
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-cost.d.ts +18 -6
- package/dist/learning-cost.js +15 -7
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +37 -2
- package/dist/learning-routes.js +52 -8
- package/dist/learning-words.d.ts +13 -0
- package/dist/learning-words.js +13 -0
- package/dist/learning.d.ts +55 -17
- package/dist/learning.js +91 -48
- package/dist/live/stream.js +6 -3
- package/dist/live/translate.d.ts +4 -3
- package/dist/live/translate.js +8 -4
- package/dist/live-reach.d.ts +37 -0
- package/dist/live-reach.js +62 -0
- package/dist/llm.js +0 -3
- package/dist/mcp-gateway.d.ts +21 -20
- package/dist/mcp-gateway.js +76 -55
- package/dist/mcp-oauth.d.ts +62 -7
- package/dist/mcp-oauth.js +134 -19
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +107 -0
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +27 -11
- package/dist/mcp-probe.js +60 -42
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +115 -25
- package/dist/mcp-servers-store.js +241 -43
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +21 -4
- package/dist/mcp-store.js +33 -8
- package/dist/mcp-wire.d.ts +22 -0
- package/dist/mcp-wire.js +36 -0
- package/dist/mcp.js +3 -3
- package/dist/meta-tool-names.d.ts +1 -0
- package/dist/meta-tool-names.js +3 -0
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.d.ts +13 -0
- package/dist/model.js +69 -25
- package/dist/monid.d.ts +51 -25
- package/dist/monid.js +226 -140
- package/dist/openapi.js +694 -59
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +26 -29
- package/dist/paid-calls.js +46 -102
- package/dist/place-offers.d.ts +2 -3
- package/dist/place-offers.js +3 -7
- package/dist/place.js +1 -2
- package/dist/print.d.ts +15 -1
- package/dist/print.js +14 -3
- package/dist/propose.d.ts +10 -1
- package/dist/propose.js +30 -10
- package/dist/provider.js +12 -4
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +3 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +27 -2
- package/dist/run-launch.js +15 -4
- 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-reads-over-store.d.ts +1 -1
- package/dist/run-repo.d.ts +20 -0
- package/dist/run-repo.js +63 -0
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +5 -2
- package/dist/run-view.d.ts +19 -8
- package/dist/run-view.js +62 -26
- package/dist/runnable.d.ts +0 -3
- package/dist/runnable.js +37 -29
- package/dist/runner/adapter-loop.d.ts +47 -17
- package/dist/runner/adapter-loop.js +1427 -303
- package/dist/runner/adapter-run-spec.d.ts +23 -9
- package/dist/runner/adapter-run-spec.js +162 -56
- package/dist/runner/adapters/pi-computer.d.ts +9 -0
- package/dist/runner/adapters/pi-computer.js +51 -0
- package/dist/runner/adapters/pi.d.ts +25 -11
- package/dist/runner/adapters/pi.js +168 -45
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +21 -11
- package/dist/runner/claim-secrets.d.ts +4 -0
- package/dist/runner/claim-secrets.js +6 -1
- package/dist/runner/cli-run-spec.d.ts +20 -3
- package/dist/runner/cli-run-spec.js +174 -64
- package/dist/runner/commands.d.ts +3 -1
- package/dist/runner/commands.js +28 -3
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +62 -0
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +224 -17
- package/dist/runner/conformance/subject.d.ts +12 -5
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +23 -12
- package/dist/runner/end-of-run.js +41 -16
- package/dist/runner/feedback-round.d.ts +52 -0
- package/dist/runner/feedback-round.js +79 -0
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +4 -2
- package/dist/runner/harness-loops.js +15 -1
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +44 -7
- package/dist/runner/journal-kinds.js +29 -0
- package/dist/runner/journal-reader.d.ts +5 -4
- package/dist/runner/journal-reader.js +12 -10
- package/dist/runner/learning-ask.d.ts +7 -1
- package/dist/runner/learning-ask.js +21 -6
- package/dist/runner/learning-dispatch.d.ts +22 -0
- package/dist/runner/learning-dispatch.js +77 -10
- package/dist/runner/learning-end.d.ts +69 -13
- package/dist/runner/learning-end.js +340 -87
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +11 -5
- package/dist/runner/learning-loop.d.ts +86 -8
- package/dist/runner/learning-loop.js +178 -23
- package/dist/runner/learning-seed.d.ts +11 -0
- package/dist/runner/learning-seed.js +27 -0
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +26 -3
- package/dist/runner/loop.d.ts +21 -2
- package/dist/runner/loop.js +23 -2
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +27 -5
- package/dist/runner/mcp-claim.d.ts +15 -8
- package/dist/runner/mcp-claim.js +176 -71
- package/dist/runner/mcp-github.js +1 -1
- package/dist/runner/mcp-run.d.ts +21 -57
- package/dist/runner/mcp-run.js +25 -85
- package/dist/runner/meta-tools.d.ts +37 -0
- package/dist/runner/meta-tools.js +268 -0
- package/dist/runner/metrics.d.ts +11 -2
- package/dist/runner/metrics.js +26 -5
- 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/pr-checkout.d.ts +1 -0
- package/dist/runner/pr-checkout.js +1 -1
- package/dist/runner/promotion.d.ts +80 -0
- package/dist/runner/promotion.js +562 -0
- package/dist/runner/reflect-hook.d.ts +46 -13
- package/dist/runner/reflect-hook.js +149 -48
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +208 -17
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +9 -4
- 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/store-port.d.ts +4 -2
- package/dist/runner/store-secrets.js +4 -3
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +10 -13
- package/dist/runner/workflow-first.d.ts +216 -0
- package/dist/runner/workflow-first.js +303 -0
- package/dist/runner/workflow-host.d.ts +6 -1
- package/dist/runner/workflow-host.js +1 -1
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +15 -2
- package/dist/runner/workflow-spec.js +63 -23
- package/dist/runs-over-store.d.ts +17 -3
- package/dist/runs-over-store.js +59 -20
- package/dist/seal-key.js +3 -3
- package/dist/sealed-settings-store.d.ts +5 -2
- package/dist/sealed-settings-store.js +10 -4
- package/dist/secret-writes.d.ts +5 -4
- package/dist/secret-writes.js +5 -4
- package/dist/server-secrets-store.d.ts +4 -3
- package/dist/server-secrets-store.js +15 -9
- package/dist/server-secrets.js +3 -2
- package/dist/server.d.ts +119 -18
- package/dist/server.js +841 -202
- package/dist/settings-wake.d.ts +23 -0
- package/dist/settings-wake.js +65 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/command-wake.d.ts +13 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +13 -5
- package/dist/store/postgres/connection.js +3 -1
- package/dist/store/postgres/dialect.js +4 -0
- package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
- package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
- package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
- package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
- package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
- 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 +10 -1
- package/dist/store/schema.js +104 -15
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.d.ts +7 -5
- package/dist/store/sqlite/run-patch.js +45 -18
- package/dist/store/sqlite/store.js +331 -72
- package/dist/store/store.d.ts +312 -21
- package/dist/store/store.js +12 -1
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +8 -1
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +1 -1
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +30 -5
- package/dist/store-reads/journal.js +128 -56
- package/dist/store-reads/learning.d.ts +114 -12
- package/dist/store-reads/learning.js +238 -48
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +1 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +6 -0
- package/dist/store-view.js +59 -26
- package/dist/template-eval.d.ts +18 -9
- package/dist/template-eval.js +95 -68
- package/dist/template-github-permissions.d.ts +24 -10
- package/dist/template-github-permissions.js +36 -15
- 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 +22 -1
- package/dist/timeline/timeline.js +34 -18
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-gate.d.ts +84 -50
- package/dist/tool-gate.js +179 -101
- 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 +33 -27
- package/dist/tool-plane.js +72 -39
- package/dist/tools.d.ts +32 -7
- package/dist/tools.js +37 -24
- package/dist/trigger-adapter.d.ts +4 -0
- package/dist/trigger-secrets-shown.d.ts +2 -2
- package/dist/trigger-secrets-shown.js +1 -1
- package/dist/trigger-signatures.d.ts +25 -6
- package/dist/trigger-signatures.js +41 -7
- package/dist/trigger-targets.d.ts +2 -0
- package/dist/trigger-targets.js +1 -0
- package/dist/trigger-webhook.js +5 -2
- package/dist/triggers.d.ts +7 -3
- package/dist/triggers.js +35 -5
- package/dist/turns.js +16 -1
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +102 -45
- package/dist/web-fetch.d.ts +2 -8
- package/dist/web-fetch.js +2 -22
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +145 -102
- package/dist/webhooks.js +559 -322
- package/dist/workflow/decisions.d.ts +1 -1
- package/dist/workflow/node-runner.d.ts +2 -1
- package/dist/workflow/node.d.ts +2 -1
- package/dist/workflow/node.js +3 -1
- package/dist/workflow/pi-versions.d.ts +23 -0
- package/dist/workflow/pi-versions.js +57 -0
- package/dist/workflow/record-tool.d.ts +2 -1
- package/dist/workflow/store.d.ts +1 -1
- package/dist/workflow/task.js +3 -2
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +19 -9
- package/dist/workspace/computer-deps.js +24 -9
- package/dist/workspace/computer-for-claim.d.ts +23 -8
- package/dist/workspace/computer-for-claim.js +92 -33
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +41 -55
- package/dist/workspace/computer-ledger.d.ts +3 -1
- package/dist/workspace/computer-ledger.js +4 -0
- package/dist/workspace/computer-mcp.d.ts +25 -0
- package/dist/workspace/computer-mcp.js +41 -0
- package/dist/workspace/computer-ports.d.ts +4 -13
- package/dist/workspace/computer-ports.js +4 -107
- package/dist/workspace/computer-script.d.ts +53 -0
- package/dist/workspace/computer-script.js +172 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +4 -2
- package/dist/workspace/index.js +3 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +132 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +104 -85
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +24 -1
- package/dist/workspace/resolve-computer.js +40 -16
- package/dist/workspace/run-tools.d.ts +56 -21
- package/dist/workspace/run-tools.js +55 -34
- package/dist/wrap-up.d.ts +21 -0
- package/dist/wrap-up.js +21 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +19 -16
- 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-BI4Byidu.js +0 -550
- package/dist/console/assets/index-C19gUF2n.css +0 -1
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -26
- package/dist/tool-budget.js +0 -56
- package/dist/workflow/readers.d.ts +0 -36
- package/dist/workflow/readers.js +0 -145
- package/dist/workflow/wal.d.ts +0 -11
- package/dist/workflow/wal.js +0 -106
- 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/tool-gate.js
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
// host tools on claude-agent, codex and OpenCode, and the MCP gateway's calls alike.
|
|
5
5
|
//
|
|
6
6
|
// An MCP tool's setting may also carry a pin (pinRefusal): top-level arguments its calls must carry, each a JSON scalar
|
|
7
|
-
// or one of a list
|
|
7
|
+
// or one of a list, or an object argument's keys (`{keys: [...]}`: given, it holds those keys alone, any values). A
|
|
8
|
+
// pinned tool takes only the arguments its listing in the run's pin declares, beside its pinned ones, so no alias the
|
|
9
|
+
// server takes for a pinned argument goes around it.
|
|
10
|
+
// A pin adds to a setting and is never a permission: the gate checks it after a deny and before an
|
|
8
11
|
// allow or an ask, so an allowed call not as pinned is refused unsent, and one under ask is refused before anyone is
|
|
9
12
|
// asked; an approved call is checked again before it runs. The agent's pin and the server's both hold.
|
|
10
13
|
//
|
|
@@ -13,43 +16,48 @@
|
|
|
13
16
|
// run's folder, after a deny and a pin and before an allow or an ask, so approvals "never" lifts none of it; an approved
|
|
14
17
|
// call is decided again before it runs.
|
|
15
18
|
//
|
|
16
|
-
// An ask has one way to wait, every tool's alike (the owner's ruling of 11-04): it PARKS. The runner's loop
|
|
17
|
-
// call
|
|
18
|
-
//
|
|
19
|
-
// call (resumeText). One call waits at a time: another asked meanwhile is refused.
|
|
19
|
+
// An ask has one way to wait, every tool's alike (the owner's ruling of 11-04): it PARKS. The runner's loop holds the
|
|
20
|
+
// call and the run goes needs_input with the pending approval. On an answer the loop runs the approved call once, through
|
|
21
|
+
// the journal, and the session goes on with its result. One call waits at a time: another asked meanwhile is refused.
|
|
20
22
|
//
|
|
21
23
|
// The answer: POST /v2/runs/{id}/approvals/{approval_id} { decision: "allow" | "deny", note? } -> 204. The first answer
|
|
22
24
|
// wins; the same answer again is 204, a conflicting one 409. Only the owner's password session answers (server.ts), never
|
|
23
25
|
// a token. A cancel marks pending approvals canceled. Where no one can approve (accounts off), an ask is refused at once
|
|
24
26
|
// in words, never parked.
|
|
25
|
-
import {
|
|
27
|
+
import { CODEMODE_TOOL_NAME } from "@earendil-works/pi-durable/codemode";
|
|
28
|
+
import { computerToolDefs, defaultPermissionOf } from "@parcha/agentrun-kernel/kernel";
|
|
26
29
|
import { READ_SKILL_FILE } from "@parcha/agentrun-kernel";
|
|
27
30
|
import { LEARNED_DIR } from "./learning.js";
|
|
28
31
|
import { COMPUTER_ROOT, portPath } from "./workspace/paths.js";
|
|
29
32
|
import { builtinHarness } from "./harness-table.js";
|
|
33
|
+
import { META_TOOLS } from "./meta-tool-names.js";
|
|
30
34
|
import { DEFAULT_HARNESS } from "./harness.js";
|
|
31
35
|
import { SHELL_TOOLS } from "./background.js";
|
|
32
|
-
import {
|
|
36
|
+
import { DECISION_PROVIDER_KEYS, KIND_KEYS, SERVE_OWN_TOOLS } from "./tool-plane.js";
|
|
37
|
+
import { isToolRow, tableTools } from "./tool-list.js";
|
|
33
38
|
import { deniedText, NOT_RUN, RAN_UNKNOWN } from "./refusal-words.js";
|
|
34
39
|
import { approvalsOf } from "./approvals.js";
|
|
35
40
|
import { BASH_POLICIES, readOnlyReason, readOnlyText } from "./bash-read-only.js";
|
|
41
|
+
import { formatToolName, isCatalogName, mcpNameOf, mcpServerOf, mcpToolName, monidNameOf } from "./tool-names.js";
|
|
36
42
|
/** What the gate does with a tool's calls. */
|
|
37
43
|
export const PERMISSIONS = ["allow", "ask", "deny"];
|
|
38
|
-
|
|
39
|
-
export
|
|
40
|
-
/** Whether `name` is an MCP tool's gate name. */
|
|
41
|
-
export const isMcpTool = (name) => /^mcp:[^/]+\/.+$/.test(name);
|
|
44
|
+
// An MCP tool's gate name is its catalog name, `mcp:<server>/<tool>` (tool-names.ts).
|
|
45
|
+
export { mcpToolName };
|
|
42
46
|
/** The MCP servers a revision grants tools of, by their catalog names (`mcp:<server>/<tool>`, a server's wildcard too), each
|
|
43
47
|
* once: what a harness that names a session's MCP tool its own way (its facts' toolAlias: OpenCode's `<server>_<tool>`) is
|
|
44
48
|
* matched against, so its call is held to that tool's settings and never to a table tool's of the same shape. */
|
|
45
|
-
export const mcpServersOf = (granted) => [...new Set(granted.flatMap((name) =>
|
|
46
|
-
/** A third-party catalog tool, by its name:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
export const mcpServersOf = (granted) => [...new Set(granted.flatMap((name) => mcpServerOf(name) ?? []))];
|
|
50
|
+
/** A third-party catalog tool, by its name: any in MCP's namespace (`mcp:<server>/<tool>`) or monid's
|
|
51
|
+
* (`monid:<provider>/<endpoint>`), a group's wildcard too; one that does not parse too, so the default for it is a
|
|
52
|
+
* catalog tool's ask. */
|
|
53
|
+
export const isCatalogTool = isCatalogName;
|
|
54
|
+
const isBuiltin = (name) => isToolRow(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || DECISION_PROVIDER_KEYS.includes(name);
|
|
55
|
+
/** The owner's defaults: a built-in of this server (a row of the tool list, its own tools, a computer kind's key, a
|
|
56
|
+
* decision provider's) allows; anything else asks, so a new source never defaults to allow. On a run with no computer,
|
|
49
57
|
* the kernel's ruled rule (defaultPermissionOf): bash asks first, and the background tools, which need a computer, are
|
|
50
58
|
* refused. */
|
|
51
59
|
export const defaultPermission = (name, where = {}) => {
|
|
52
|
-
if (isCatalogTool(name))
|
|
60
|
+
if (isCatalogTool(name) || !isBuiltin(name))
|
|
53
61
|
return "ask";
|
|
54
62
|
return where.computer === false ? defaultPermissionOf(name, { computer: false }) : "allow";
|
|
55
63
|
};
|
|
@@ -70,11 +78,13 @@ export const SHELL_WATCHERS = new Set(["bash_output", "bash_list", "bash_signal"
|
|
|
70
78
|
/** Shell tool `name`'s permission, given bash's: a watcher's ask is allow; any other keeps bash's. */
|
|
71
79
|
const shellPermission = (name, bash) => (bash === "ask" && SHELL_WATCHERS.has(name) ? "allow" : bash);
|
|
72
80
|
/** The settings keys that may set `name`'s permission, most specific first: the tool's own name, then, for an MCP
|
|
73
|
-
* tool, its server's wildcard `mcp:<server>/*`. */
|
|
81
|
+
* tool, its server's wildcard `mcp:<server>/*`, and for a monid endpoint, its provider's `monid:<provider>/*`. */
|
|
74
82
|
export function permissionKeys(name) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
const mcp = mcpNameOf(name);
|
|
84
|
+
if (mcp)
|
|
85
|
+
return [name, formatToolName({ kind: "mcp-server", server: mcp.server })];
|
|
86
|
+
const monid = monidNameOf(name);
|
|
87
|
+
return monid ? [name, formatToolName({ kind: "monid-provider", provider: monid.provider })] : [name];
|
|
78
88
|
}
|
|
79
89
|
/** The browser's registrations on pi (pi-browser's BROWSER_TOOL_NAMES, which a test holds this list to): each is a call
|
|
80
90
|
* of the table's `browser`. */
|
|
@@ -83,63 +93,68 @@ const BROWSER_REGISTRATIONS = ["snapshot", "run", "screenshot", "browser_read",
|
|
|
83
93
|
* registry's own definitions say it (their settingsKey), so a tool a kind gains is held to its key with no line here. */
|
|
84
94
|
const KIND_TOOLS = (() => {
|
|
85
95
|
const keys = new Map();
|
|
86
|
-
for (const def of [...
|
|
96
|
+
for (const def of [...computerToolDefs("desktop", []), ...computerToolDefs("phone", [])])
|
|
87
97
|
keys.set(def.name, [...new Set([...(keys.get(def.name) ?? []), def.settingsKey])]);
|
|
98
|
+
// pi's code mode, offered only beside a desktop's or a phone's tools (runner/adapters/pi-computer.ts): its scripts
|
|
99
|
+
// reach the computer as computer_script's do, so it is held to the same keys. Its nested tool calls pass the gate each.
|
|
100
|
+
keys.set(CODEMODE_TOOL_NAME, keys.get("computer_script") ?? []);
|
|
88
101
|
return keys;
|
|
89
102
|
})();
|
|
90
103
|
const STRICTNESS = { allow: 0, ask: 1, deny: 2 };
|
|
91
104
|
/** The MCP server through which claude-agent calls the kernel's host tools (`mcp__hands__<wire name>`). */
|
|
92
105
|
const HOST_TOOLS_SERVER = "hands";
|
|
93
|
-
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
/** Every name a session on `harness` (with MCP servers `mcpServers`) gives its tools, to the settings key each is held to:
|
|
107
|
+
* the shell family (bash's), table, own and decision tools, read_skill_file (`read`, unless the harness's alias makes it a
|
|
108
|
+
* configured server's tool), the kinds' tools (a shared one by its first kind), nativeTools, the browser's registrations;
|
|
109
|
+
* each also as claude-agent's `mcp__hands__<name>`. The first named wins. */
|
|
110
|
+
export function nameMapOf(harness, mcpServers = []) {
|
|
111
|
+
const facts = builtinHarness(harness)?.facts;
|
|
112
|
+
const names = new Map();
|
|
113
|
+
const name = (own, key) => void (names.has(own) || names.set(own, key));
|
|
114
|
+
for (const [own, key] of Object.entries(SHELL_FAMILY))
|
|
115
|
+
name(own, key);
|
|
116
|
+
// pi's code mode (`codemode`) is the computer kind's (KIND_TOOLS); the host's own is read by its own key (RunGate.hostMeta).
|
|
117
|
+
for (const own of [...tableTools(), ...SERVE_OWN_TOOLS.filter((one) => one !== CODEMODE_TOOL_NAME), ...DECISION_PROVIDER_KEYS])
|
|
118
|
+
name(own, own);
|
|
119
|
+
const alias = facts?.toolAlias?.exec(READ_SKILL_FILE) ?? null;
|
|
120
|
+
name(READ_SKILL_FILE, alias && mcpServers.includes(alias[1]) ? mcpToolName(alias[1], alias[2]) : "read");
|
|
121
|
+
for (const [own, keys] of KIND_TOOLS)
|
|
122
|
+
name(own, keys[0]);
|
|
123
|
+
for (const [own, key] of Object.entries(facts?.nativeTools ?? {}))
|
|
124
|
+
if (key)
|
|
125
|
+
name(own, key);
|
|
126
|
+
for (const own of BROWSER_REGISTRATIONS)
|
|
127
|
+
name(own, "browser");
|
|
128
|
+
for (const [own, key] of [...names])
|
|
129
|
+
name(`mcp__${HOST_TOOLS_SERVER}__${own}`, key);
|
|
130
|
+
return names;
|
|
131
|
+
}
|
|
132
|
+
/** The settings key a call named `name` on `harness` is held to: a lookup in the session's names (`names`), then the open
|
|
133
|
+
* families no list holds (a catalog name, `mcp:<server>/<tool>` or `monid:<provider>/<endpoint>`, `mcp__<server>__<tool>`,
|
|
134
|
+
* and a harness's own `<server>_<tool>` for a server of `mcpServers` only). Undefined: nothing maps it, and the gate asks
|
|
135
|
+
* (a monid endpoint's wire name is read back by the loop, ClaimMcp.catalogOf, before the gate is asked). */
|
|
136
|
+
export function settingsKeyOf(harness, name, mcpServers = [], names = nameMapOf(harness, mcpServers)) {
|
|
137
|
+
const own = names.get(name);
|
|
138
|
+
if (own !== undefined)
|
|
139
|
+
return own;
|
|
140
|
+
if (isCatalogTool(name))
|
|
106
141
|
return name;
|
|
107
|
-
// An adapter's own read of a skill's file (codex's and OpenCode's read_skill_file, from the session's copy of the run's
|
|
108
|
-
// skills) is a read: held to read's key, so a server's read deny refuses it and the default allows it, on every harness.
|
|
109
|
-
// Unless the name is an agent's MCP tool on this harness (OpenCode's <server>_<tool>: a configured server `read` with a
|
|
110
|
-
// tool `skill_file`): that tool keeps its own key, so read's setting never stands in for it.
|
|
111
|
-
if (name === READ_SKILL_FILE) {
|
|
112
|
-
const alias = builtinHarness(harness)?.facts?.toolAlias?.exec(name) ?? null;
|
|
113
|
-
return alias && mcpServers.includes(alias[1]) ? mcpToolName(alias[1], alias[2]) : "read";
|
|
114
|
-
}
|
|
115
|
-
// A desktop's or a phone's tool is its kind's key, as the browser's registrations are `browser`; one both kinds have
|
|
116
|
-
// (the hand-over) is named by the first, its permission the stricter of both (RunGate's setting).
|
|
117
|
-
const kind = KIND_TOOLS.get(name);
|
|
118
|
-
if (kind !== undefined)
|
|
119
|
-
return kind[0];
|
|
120
|
-
// A CLI's own tool, the table's tool it is (its facts' nativeTools), by an own name only.
|
|
121
|
-
const nativeTools = builtinHarness(harness)?.facts?.nativeTools;
|
|
122
|
-
const native = nativeTools && Object.hasOwn(nativeTools, name) ? nativeTools[name] : undefined;
|
|
123
|
-
if (native)
|
|
124
|
-
return native;
|
|
125
142
|
const mcp = /^mcp__([a-z][a-z0-9-]*)__(.+)$/.exec(name);
|
|
126
143
|
if (mcp)
|
|
127
|
-
return mcp[1] === HOST_TOOLS_SERVER ? settingsKeyOf(harness, mcp[2], mcpServers) : mcpToolName(mcp[1], mcp[2]);
|
|
128
|
-
const monid = /^monid_([a-z]+)$/.exec(name);
|
|
129
|
-
if (monid)
|
|
130
|
-
return `monid.${monid[1]}`;
|
|
131
|
-
if (BROWSER_REGISTRATIONS.includes(name))
|
|
132
|
-
return "browser";
|
|
133
|
-
// A harness whose client names a session's MCP tool another way too (its facts' toolAlias: OpenCode's `<server>_<tool>`).
|
|
144
|
+
return mcp[1] === HOST_TOOLS_SERVER ? settingsKeyOf(harness, mcp[2], mcpServers, names) : mcpToolName(mcp[1], mcp[2]);
|
|
134
145
|
const alias = builtinHarness(harness)?.facts?.toolAlias?.exec(name) ?? null;
|
|
135
146
|
return alias && mcpServers.includes(alias[1]) ? mcpToolName(alias[1], alias[2]) : undefined;
|
|
136
147
|
}
|
|
148
|
+
/** Whether a pin's value is a keys pin: the one form that is an object. */
|
|
149
|
+
export const isPinKeys = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
137
150
|
/** The most arguments one setting pins, and the most values a one-of list holds. */
|
|
138
151
|
export const MAX_PIN_ARGS = 8;
|
|
139
152
|
export const MAX_PIN_CHOICES = 16;
|
|
140
|
-
/** A one-of list in its one form: each value once, null first, then by its JSON text;
|
|
141
|
-
* same meaning is the same text (a revision's id) and the same words (a refusal). */
|
|
153
|
+
/** A one-of list in its one form: each value once, null first, then by its JSON text; a keys pin's keys each once,
|
|
154
|
+
* sorted; a scalar as it is. The same meaning is the same text (a revision's id) and the same words (a refusal). */
|
|
142
155
|
export const canonicalChoices = (value) => {
|
|
156
|
+
if (isPinKeys(value))
|
|
157
|
+
return { keys: [...new Set(value.keys)].sort() };
|
|
143
158
|
if (!Array.isArray(value))
|
|
144
159
|
return value;
|
|
145
160
|
const texts = [...new Set(value.filter((one) => one !== null).map((one) => JSON.stringify(one)))].sort();
|
|
@@ -150,18 +165,36 @@ export const canonicalPin = (pin) => Object.fromEntries(Object.keys(pin).sort().
|
|
|
150
165
|
/** Whether a call's argument `given` is the pinned scalar `one`: the same JSON scalar (strict equality), or, for null,
|
|
151
166
|
* left out or null. */
|
|
152
167
|
const isOne = (given, one) => (one === null ? given === undefined || given === null : given === one);
|
|
153
|
-
/** Whether `given` holds
|
|
154
|
-
|
|
168
|
+
/** Whether a call's argument `given` holds a keys pin's `keys`: left out, null, or an object (never a list) whose own keys
|
|
169
|
+
* are all among them. */
|
|
170
|
+
const keysHold = (given, keys) => given === undefined || given === null || (typeof given === "object" && !Array.isArray(given) && Object.keys(given).every((key) => keys.includes(key)));
|
|
171
|
+
/** Whether `given` holds pinned `value`: its scalar, one of its list, or its keys. */
|
|
172
|
+
const holds = (given, value) => (isPinKeys(value) ? keysHold(given, value.keys) : Array.isArray(value) ? value.some((one) => isOne(given, one)) : isOne(given, value));
|
|
155
173
|
/** A scalar in a refusal's words: text as it is, null as `absent`, any other as JSON. */
|
|
156
174
|
const scalarWords = (one) => (one === null ? "absent" : typeof one === "string" ? one : JSON.stringify(one));
|
|
157
175
|
/** A pin in words, as the refusal says it, in its one form (canonicalPin): `channel_id = C0123`, `cc absent` for a null,
|
|
158
|
-
* `event in (absent | COMMENT)` for a list. */
|
|
159
|
-
export const pinWords = (pin) => Object.entries(canonicalPin(pin)).map(([arg, value]) => (Array.isArray(value) ? `${arg} in (${value.map(scalarWords).join(" | ")})` : value === null ? `${arg} absent` : `${arg} = ${scalarWords(value)}`)).join(", ");
|
|
176
|
+
* `event in (absent | COMMENT)` for a list, `properties keys in (hs_lead_score)` for a keys pin. */
|
|
177
|
+
export const pinWords = (pin) => Object.entries(canonicalPin(pin)).map(([arg, value]) => (isPinKeys(value) ? `${arg} keys in (${value.keys.join(" | ")})` : Array.isArray(value) ? `${arg} in (${value.map(scalarWords).join(" | ")})` : value === null ? `${arg} absent` : `${arg} = ${scalarWords(value)}`)).join(", ");
|
|
178
|
+
/** Names in words: `a`, `a and b`, `a, b and c`. */
|
|
179
|
+
const listWords = (names) => (names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`);
|
|
180
|
+
/** The arguments a call of `tool` carries that its listing does not declare, in words: "`to` is not an argument of X". */
|
|
181
|
+
const undeclaredWords = (args, tool) => `${listWords(args.map((arg) => `\`${arg}\``))} ${args.length === 1 ? "is not an argument" : "are not arguments"} of ${tool}`;
|
|
160
182
|
/** What holds both of two layers' pins of one argument (`own`, the agent's, and `theirs`, the server's): a scalar where
|
|
161
|
-
* either is one and the other holds it, else the agent's list kept to the server's, in the agent's order;
|
|
162
|
-
*
|
|
183
|
+
* either is one and the other holds it, else the agent's list kept to the server's, in the agent's order; two keys pins,
|
|
184
|
+
* the agent's keys the server's has too; a keys pin and a scalar or list, what of the scalars the keys pin holds (null:
|
|
185
|
+
* left out). Undefined when nothing holds both, two keys pins with no key in both among them: no call writes a field
|
|
186
|
+
* each layer means. */
|
|
163
187
|
function bothOf(own, theirs) {
|
|
164
188
|
const list = (value) => (Array.isArray(value) ? value : [value]);
|
|
189
|
+
if (isPinKeys(own) && isPinKeys(theirs)) {
|
|
190
|
+
const kept = own.keys.filter((key) => theirs.keys.includes(key));
|
|
191
|
+
return kept.length ? { keys: kept } : undefined;
|
|
192
|
+
}
|
|
193
|
+
if (isPinKeys(own) || isPinKeys(theirs)) {
|
|
194
|
+
const [keys, other] = isPinKeys(own) ? [own, theirs] : [theirs, own];
|
|
195
|
+
const kept = list(other).filter((one) => holds(one, keys));
|
|
196
|
+
return !kept.length ? undefined : Array.isArray(other) ? kept : kept[0];
|
|
197
|
+
}
|
|
165
198
|
if (!Array.isArray(own))
|
|
166
199
|
return list(theirs).some((one) => one === own) ? own : undefined;
|
|
167
200
|
if (!Array.isArray(theirs))
|
|
@@ -171,11 +204,16 @@ function bothOf(own, theirs) {
|
|
|
171
204
|
}
|
|
172
205
|
/** Why the call of MCP tool `name` with `args` is refused by a pin, or undefined when no pin refuses it. A pin is an
|
|
173
206
|
* addition to a setting, never a permission: each layer's pin on the tool's own key holds (the agent's and the
|
|
174
|
-
* server's both, whatever the permission), and a call must carry every pinned argument as pinned: its value,
|
|
175
|
-
* its list
|
|
176
|
-
*
|
|
177
|
-
|
|
178
|
-
|
|
207
|
+
* server's both, whatever the permission), and a call must carry every pinned argument as pinned: its value, one of
|
|
208
|
+
* its list, or (a keys pin) an object of its keys alone, null or the argument left out. An argument both layers pin
|
|
209
|
+
* takes what holds both; where nothing does, every call is refused. `declared`: the top-level arguments the tool's
|
|
210
|
+
* listing in the run's pin declares (its inputSchema's `properties`): a pinned tool takes only those and its pinned
|
|
211
|
+
* ones, so an alias the server takes beside a pinned argument (`to` beside `recipient_email`) is refused, with no
|
|
212
|
+
* table of aliases; undefined (a listing with no `properties` object, or none known), no argument is closed. `ran`:
|
|
213
|
+
* whether an earlier attempt of the call may have been sent (deniedText's). `mismatched`: the arguments that do not
|
|
214
|
+
* hold, for the gate's log line. */
|
|
215
|
+
export function pinRefusal(name, args, server, agent = {}, ran = "no", declared) {
|
|
216
|
+
if (!mcpNameOf(name))
|
|
179
217
|
return undefined;
|
|
180
218
|
const what = ran === "no" ? NOT_RUN : RAN_UNKNOWN;
|
|
181
219
|
if (server[name]?.brokenPin)
|
|
@@ -188,6 +226,9 @@ export function pinRefusal(name, args, server, agent = {}, ran = "no") {
|
|
|
188
226
|
return { text: `${name} can't be called: this agent's settings fix ${pinWords(Object.fromEntries(clash.map((arg) => [arg, own[arg]])))} and this server's fix ${pinWords(Object.fromEntries(clash.map((arg) => [arg, theirs[arg]])))}, so no call can satisfy both. ${what} Don't retry it: the owner makes the two agree.`, mismatched: clash };
|
|
189
227
|
const pin = { ...theirs, ...Object.fromEntries(Object.entries(own).map(([arg, value]) => [arg, Object.hasOwn(theirs, arg) ? bothOf(value, theirs[arg]) : value])) };
|
|
190
228
|
const given = typeof args === "object" && args !== null && !Array.isArray(args) ? args : {};
|
|
229
|
+
const undeclared = declared && Object.keys(pin).length ? Object.keys(given).filter((arg) => !declared.has(arg) && !Object.hasOwn(pin, arg)) : [];
|
|
230
|
+
if (undeclared.length)
|
|
231
|
+
return { text: `${undeclaredWords(undeclared, mcpNameOf(name).tool)}; a pinned tool takes only its listed arguments (${listWords(Object.keys(pin).sort())} ${Object.keys(pin).length === 1 ? "is" : "are"} pinned). ${what}`, mismatched: undeclared };
|
|
191
232
|
const mismatched = Object.keys(pin).filter((arg) => !holds(Object.hasOwn(given, arg) ? given[arg] : undefined, pin[arg]));
|
|
192
233
|
if (!mismatched.length)
|
|
193
234
|
return undefined;
|
|
@@ -203,12 +244,42 @@ export function pinRefusal(name, args, server, agent = {}, ran = "no") {
|
|
|
203
244
|
* layer, nor an ask that stands in for a setting that does not read. Nor is anything RunGate.enter refuses before it
|
|
204
245
|
* decides between running and parking ever lifted (a template's pin, among them). Without never, the answer is as it
|
|
205
246
|
* always was. */
|
|
206
|
-
export function permissionFrom(name, server, agent = {}, approvals = "ask", where = {}) {
|
|
247
|
+
export function permissionFrom(name, server, agent = {}, approvals = "ask", where = {}, effect) {
|
|
207
248
|
const { permission, from } = settingOf(name, server, agent, where);
|
|
249
|
+
if (permission === "ask" && effect === "read" && readsLift(name, server, agent, from))
|
|
250
|
+
return { permission: "allow", from: "server" };
|
|
208
251
|
if (approvals !== "never" || permission !== "ask" || standsBehind(name, server, agent))
|
|
209
252
|
return { permission, from };
|
|
210
253
|
return { permission: "allow", from: "unattended" };
|
|
211
254
|
}
|
|
255
|
+
export function toolEffect(annotations) {
|
|
256
|
+
const hints = typeof annotations === "object" && annotations !== null ? annotations : {};
|
|
257
|
+
if (hints.readOnlyHint === true)
|
|
258
|
+
return "read";
|
|
259
|
+
return hints.destructiveHint === true ? "destructive" : "write";
|
|
260
|
+
}
|
|
261
|
+
/** MCP tool `name`'s (`mcp:<server>/<tool>`) effect as a run's pin holds it (its annotations then, toolEffect): what the
|
|
262
|
+
* run's gate (ClaimMcp.effectOf) and a settings save's wake (settings-wake.ts) read, never a live listing. Undefined for a
|
|
263
|
+
* tool the pin does not hold. */
|
|
264
|
+
export function pinnedEffect(pin, name) {
|
|
265
|
+
const parsed = /^mcp:([^/]+)\/(.+)$/.exec(name);
|
|
266
|
+
const pinned = parsed && Object.hasOwn(pin, parsed[1]) ? pin[parsed[1]] : undefined;
|
|
267
|
+
const tool = pinned?.tools.find((one) => one.name === parsed[2]);
|
|
268
|
+
return tool ? toolEffect(tool.annotations) : undefined;
|
|
269
|
+
}
|
|
270
|
+
/** Whether "allow reads" lifts the ask of MCP tool `name`, one its run's pin marks read-only (permissionFrom's `effect`):
|
|
271
|
+
* its server's wildcard in this server's settings carries `allow_reads`, the ask came from the server's settings or
|
|
272
|
+
* the default (an agent's own ask holds), the tool's own key sets no permission on this server (an explicit setting
|
|
273
|
+
* beats the rule), and nothing stands behind the ask (standsBehind: a deny in any layer, a value that does not read,
|
|
274
|
+
* settings unread). A pin's refusal is RunGate.decide's, after this, so the rule never lifts one. */
|
|
275
|
+
function readsLift(name, server, agent, from) {
|
|
276
|
+
if (!mcpNameOf(name) || from === "agent")
|
|
277
|
+
return false;
|
|
278
|
+
const [own, wildcard] = permissionKeys(name);
|
|
279
|
+
if (server[own]?.permission !== undefined || server[wildcard]?.allow_reads !== true)
|
|
280
|
+
return false;
|
|
281
|
+
return !standsBehind(name, server, agent);
|
|
282
|
+
}
|
|
212
283
|
/** Marks the server's settings map when its stored value does not read (tool-plane.ts loadToolSettings): every
|
|
213
284
|
* tool then takes its defaults, and a deny it may hold can't be seen, so nothing lifts an ask over it. A symbol:
|
|
214
285
|
* carried by a spread, never by JSON (it is never served) nor by Object.entries (no reader takes it for a tool). */
|
|
@@ -271,14 +342,12 @@ function settingFrom(name, server, agent, where = {}) {
|
|
|
271
342
|
}
|
|
272
343
|
/** `name`'s permission in force (permissionFrom): the one rule every path reads, the gate's, the tool plane's and a
|
|
273
344
|
* workflow's call nodes'. */
|
|
274
|
-
export const permissionOf = (name, server, agent = {}, approvals = "ask") => permissionFrom(name, server, agent, approvals).permission;
|
|
345
|
+
export const permissionOf = (name, server, agent = {}, approvals = "ask", effect) => permissionFrom(name, server, agent, approvals, {}, effect).permission;
|
|
275
346
|
// The refusal words (SettingFrom, DenyFrom, NOT_RUN, RAN_UNKNOWN, denyPlace, deniedText, refusedText) live in
|
|
276
347
|
// refusal-words.ts, shared with the runner's loops.
|
|
277
348
|
export { deniedText, denyPlace, NOT_RUN, RAN_UNKNOWN, refusedText } from "./refusal-words.js";
|
|
278
349
|
/** The refusal of an ask where no one can approve it: a server with accounts off, whose answer route takes no token. */
|
|
279
350
|
export const noApproverText = (tool, ran = "no") => `Permission denied: ${tool} needs the owner's approval, and this server has accounts off (AGENTRUN_ACCOUNTS=0), so no one can give it: set the tool to allow or deny in the agent's Tools. ${ran === "no" ? NOT_RUN : RAN_UNKNOWN}`;
|
|
280
|
-
/** A parked call's answer: the run pauses here. */
|
|
281
|
-
export const waitingText = (tool) => `This ${tool} call waits for a person's approval; the run pauses here and continues with the result when they answer.`;
|
|
282
351
|
/** The Timeline row of a call that waits for an approval. */
|
|
283
352
|
export const APPROVAL_ROW = "tool_approval_requested";
|
|
284
353
|
/** A call's arguments shown on its approval, at most this many bytes. */
|
|
@@ -302,30 +371,13 @@ export function previewOf(text) {
|
|
|
302
371
|
const bytes = Buffer.from(text, "utf8");
|
|
303
372
|
return bytes.length <= ARGS_PREVIEW_BYTES ? bytes.toString("utf8") : `${bytes.subarray(0, ARGS_PREVIEW_BYTES - 3).toString("utf8").replace(/\uFFFD+$/, "")}…`;
|
|
304
373
|
}
|
|
305
|
-
/** `args` as JSON, at most ARGS_PREVIEW_BYTES: the request's own record of them, never shown as it is. */
|
|
306
|
-
export const argsPreview = (args) => previewOf(JSON.stringify(args ?? {}) ?? "");
|
|
307
|
-
/** How the gate's resume message starts: the server knows its row by it, and redacts the row whole (runs.ts). */
|
|
308
|
-
export const RESUME_PREFIX = "[tool approval] ";
|
|
309
|
-
/** The one message that resumes a session once a person answered: it names the call it answers (its tool, call id and
|
|
310
|
-
* arguments), so the model tells it from a person's new input, and carries the call's result, or the refusal. */
|
|
311
|
-
/** The head of the gate's resume message: the call it answers, its arguments as shown (`shown`, redacted whole then cut,
|
|
312
|
-
* runs.ts) cut again at 300 characters, and the words that say it is not the person's. The one source of it: the resume
|
|
313
|
-
* writes it, and the Timeline strips exactly it from the row a person opens (runs.ts resumeShows). */
|
|
314
|
-
export function resumeHead(request, shown) {
|
|
315
|
-
const args = shown.length > 300 ? `${shown.slice(0, 299)}…` : shown;
|
|
316
|
-
return `${RESUME_PREFIX}This answers your ${request.tool} call ${request.call_id} (arguments ${args}), which waited for a person's approval; it is not a new message from them.`;
|
|
317
|
-
}
|
|
318
|
-
export function resumeText(request, shown, decision, result) {
|
|
319
|
-
const head = resumeHead(request, shown);
|
|
320
|
-
return decision === "allow" ? `${head} They allowed it, and it ran${result.isError ? " and failed" : ""}. Its result:\n${result.text}` : `${head}\n${result.text}`;
|
|
321
|
-
}
|
|
322
374
|
/** The gate of the run `runId` whose folder is `where`, on its pinned revision. `serverSettings`: the server's tool
|
|
323
375
|
* settings as the runner read them from the one store at the claim (tool-plane.ts loadToolSettings), read at each call as
|
|
324
376
|
* the gate reads them. `approvers`: whether anyone can answer an ask here, the store's (server-approvers.ts, read at each
|
|
325
377
|
* claim). The gate reads nothing of the run's own files: they are the agent's to write. `mcpServers`: the run's MCP
|
|
326
378
|
* servers (mcpServersOf its grants), so a harness's own name for an MCP tool is held to that tool's settings. */
|
|
327
379
|
export function runGate(where, runId, revision, serverSettings, approvers) {
|
|
328
|
-
return new RunGate({ root: where.root, work: where.work, runId, harness: revision.body.harness ?? DEFAULT_HARNESS, ...(where.computer === undefined ? {} : { computer: where.computer }), ...(where.mcpServers ? { mcpServers: where.mcpServers } : {}) }, serverSettings, (revision.body.toolSettings ?? {}), approvers, approvalsOf(revision.body.approvals));
|
|
380
|
+
return new RunGate({ root: where.root, work: where.work, runId, harness: revision.body.harness ?? DEFAULT_HARNESS, ...(where.computer === undefined ? {} : { computer: where.computer }), ...(where.mcpServers ? { mcpServers: where.mcpServers } : {}), ...(where.computerCodemode ? { computerCodemode: true } : {}), ...(where.effectOf ? { effectOf: where.effectOf } : {}), ...(where.argumentsOf ? { argumentsOf: where.argumentsOf } : {}) }, serverSettings, (revision.body.toolSettings ?? {}), approvers, approvalsOf(revision.body.approvals));
|
|
329
381
|
}
|
|
330
382
|
/** A run's tool gate on the runner: its policy, asked before each call's intent (decide). */
|
|
331
383
|
export class RunGate {
|
|
@@ -337,6 +389,8 @@ export class RunGate {
|
|
|
337
389
|
/** `readServerSettings`: the server's tool settings, read at each call; `overrides`: the pinned revision's own;
|
|
338
390
|
* `approvers`: whether anyone can answer an ask here (the owner's password session: accounts on); `approvals`: the
|
|
339
391
|
* pinned revision's (definition.approvals): "never" runs the agent unattended, an ask allowed (permissionFrom). */
|
|
392
|
+
/** `where.effectOf`: an MCP tool's effect as the run's pin marks it (ClaimMcp.effectOf), what "allow reads" reads;
|
|
393
|
+
* never a live listing, so a server can't widen a run's access mid-run. */
|
|
340
394
|
constructor(where, readServerSettings, overrides = {}, approvers = true, approvals = "ask") {
|
|
341
395
|
this.where = where;
|
|
342
396
|
this.readServerSettings = readServerSettings;
|
|
@@ -344,6 +398,7 @@ export class RunGate {
|
|
|
344
398
|
this.approvers = approvers;
|
|
345
399
|
this.approvals = approvals;
|
|
346
400
|
}
|
|
401
|
+
names;
|
|
347
402
|
/** A tool's permission now (permissionOf): the revision's own over the server's setting, read at each call, so a change
|
|
348
403
|
* reaches a live run at its next call; under approvals "never", an ask is an allow. */
|
|
349
404
|
policy = (tool) => this.setting(tool).permission;
|
|
@@ -356,7 +411,17 @@ export class RunGate {
|
|
|
356
411
|
* the call is run again after an earlier attempt that may have been sent (a replay-safe call rerun after a crash), so a
|
|
357
412
|
* refusal says whether it took effect is not known, never that nothing was sent. */
|
|
358
413
|
async decide(name, args, options = {}) {
|
|
359
|
-
|
|
414
|
+
// tools_search, tools_call and the host's codemode (runner/meta-tools.ts) run: each call they make is asked about here
|
|
415
|
+
// as its own tool, by its own name. pi's code mode on a run with a desktop or a phone is not the host's: its scripts
|
|
416
|
+
// reach the computer themselves, so it is held to the kind's setting (KIND_TOOLS).
|
|
417
|
+
const own = name.replace(/^mcp__hands__/, "");
|
|
418
|
+
// Each has a settings key of its own (allow unless an owner sets deny: a denied one is not offered, and a call to it is
|
|
419
|
+
// refused here).
|
|
420
|
+
if (this.hostMeta(own)) {
|
|
421
|
+
const setting = this.setting(name);
|
|
422
|
+
return setting.permission === "deny" ? { deny: deniedText(own, own, setting.from, options.replayed ? "unknown" : "no") } : "allow";
|
|
423
|
+
}
|
|
424
|
+
const key = this.keyOf(name) ?? name;
|
|
360
425
|
const tool = this.askedAs(name);
|
|
361
426
|
const ran = options.replayed ? "unknown" : "no";
|
|
362
427
|
const verdict = this.policy(name);
|
|
@@ -372,22 +437,34 @@ export class RunGate {
|
|
|
372
437
|
return "allow";
|
|
373
438
|
return this.approvers ? "ask" : { deny: noApproverText(tool, ran) };
|
|
374
439
|
}
|
|
440
|
+
keyOf(name) {
|
|
441
|
+
const harness = this.where.harness ?? DEFAULT_HARNESS;
|
|
442
|
+
return settingsKeyOf(harness, name, this.where.mcpServers, (this.names ??= nameMapOf(harness, this.where.mcpServers)));
|
|
443
|
+
}
|
|
375
444
|
/** The name a call is asked about by, as main's request names it (enter's `tool`): its settings key, a shell tool its
|
|
376
445
|
* own name; a name nothing maps, as it came. */
|
|
377
446
|
askedAs(name) {
|
|
378
|
-
return shellToolOf(name) ??
|
|
447
|
+
return shellToolOf(name) ?? this.keyOf(name) ?? name;
|
|
379
448
|
}
|
|
380
449
|
/** Where the permission `policy` gives `tool` was set: the agent's own tool settings, the server's, or the default; or
|
|
381
450
|
* "unattended", an ask the agent's approvals allowed. */
|
|
382
451
|
denyFrom = (tool) => this.setting(tool).from;
|
|
452
|
+
/** Whether `bare` (a name without claude-agent's `mcp__hands__`) is one of the host's three, not pi's own code mode on a
|
|
453
|
+
* desktop or a phone (which is held to the kind's keys). */
|
|
454
|
+
hostMeta(bare) {
|
|
455
|
+
return META_TOOLS.has(bare) && !(bare === CODEMODE_TOOL_NAME && this.where.computerCodemode);
|
|
456
|
+
}
|
|
383
457
|
setting(tool) {
|
|
384
|
-
|
|
458
|
+
const bare = tool.replace(/^mcp__hands__/, "");
|
|
459
|
+
if (this.hostMeta(bare))
|
|
460
|
+
return this.settingOf(tool, bare);
|
|
461
|
+
// A tool the desktop and the phone both have (every computer tool): the gate knows not the run's kind, so it is held to the
|
|
385
462
|
// stricter of both keys' settings, never more permissive than the run's own kind's.
|
|
386
463
|
const shared = KIND_TOOLS.get(tool.replace(/^mcp__hands__/, ""));
|
|
387
464
|
if (shared && shared.length > 1) {
|
|
388
465
|
return shared.map((key) => this.settingOf(tool, key)).reduce((strictest, one) => (STRICTNESS[one.permission] > STRICTNESS[strictest.permission] ? one : strictest));
|
|
389
466
|
}
|
|
390
|
-
return this.settingOf(tool,
|
|
467
|
+
return this.settingOf(tool, this.keyOf(tool));
|
|
391
468
|
}
|
|
392
469
|
/** `tool`'s permission under its settings key `key`, and where it was set. */
|
|
393
470
|
settingOf(tool, key) {
|
|
@@ -406,12 +483,13 @@ export class RunGate {
|
|
|
406
483
|
}
|
|
407
484
|
// A shell tool under every harness's name for it is read as its own name, by bash's key (permissionFrom): a watcher's
|
|
408
485
|
// ask is allow only where bash's ask is set as written. Its default is where the run's shell is (defaultPermission).
|
|
409
|
-
return permissionFrom(shellToolOf(tool) ?? key, server, this.overrides, this.approvals, where);
|
|
486
|
+
return permissionFrom(shellToolOf(tool) ?? key, server, this.overrides, this.approvals, where, mcpNameOf(key) ? this.where.effectOf?.(key) : undefined);
|
|
410
487
|
}
|
|
411
488
|
/** Why a pin refuses the call of `key` with `args` now (pinRefusal): the revision's own pins and the server's, read at
|
|
412
|
-
* each call as its permission is, so a pin set or changed reaches a live run at its next call
|
|
489
|
+
* each call as its permission is, so a pin set or changed reaches a live run at its next call; a pinned tool held to
|
|
490
|
+
* the arguments its listing in the run's pin declares (where.argumentsOf). */
|
|
413
491
|
pinned(key, args, ran = "no") {
|
|
414
|
-
return pinRefusal(key, args, this.serverSettings() ?? {}, this.overrides, ran);
|
|
492
|
+
return pinRefusal(key, args, this.serverSettings() ?? {}, this.overrides, ran, this.where.argumentsOf?.(key));
|
|
415
493
|
}
|
|
416
494
|
/** Why bash's policy refuses the call `name` (held to `key`) with `args` now, or undefined: the revision's own setting
|
|
417
495
|
* (an agent's tool_settings.bash.policy), so every shell tool under every harness's name for it is held to it. A policy
|
package/dist/tool-keys.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const TOOL_KEYS: readonly [{
|
|
|
18
18
|
readonly kind: "tool";
|
|
19
19
|
readonly label: "Monid";
|
|
20
20
|
readonly fields: readonly ["MONID_API_KEY"];
|
|
21
|
-
readonly unlocks: readonly ["monid
|
|
21
|
+
readonly unlocks: readonly ["monid:*"];
|
|
22
22
|
}, {
|
|
23
23
|
readonly id: "browserbase";
|
|
24
24
|
readonly kind: "tool";
|
|
@@ -79,6 +79,9 @@ export declare function rowUnlocks(row: {
|
|
|
79
79
|
unlocks: string[];
|
|
80
80
|
harnesses: ("opencode" | "codex" | "pi" | "claude-agent")[];
|
|
81
81
|
};
|
|
82
|
+
/** Whether a key row's `unlock` unlocks the tool `name`: by its name, or `<source>:*` for every tool of a catalog source
|
|
83
|
+
* (`monid:*`: `monid:apollo/people/match`, `monid:apollo/*`). */
|
|
84
|
+
export declare const unlocksTool: (unlock: string, name: string) => boolean;
|
|
82
85
|
/** The key that unlocks the tool `name` (capabilities' `tools[].key`, so a page links "needs the X key" to it), if any. */
|
|
83
86
|
export declare const keyOf: (name: string) => string | undefined;
|
|
84
87
|
/** Why a stored value does not open, in the order a re-entry names one: sealed under another key than the server's, or
|
package/dist/tool-keys.js
CHANGED
|
@@ -32,9 +32,11 @@ export const TOOL_FIELDS = TOOL_KEYS.filter((row) => row.kind === "tool").flatMa
|
|
|
32
32
|
* that run those tools. A name neither holds is left out; a key that unlocks none of its names lists nothing. */
|
|
33
33
|
export function unlockedBy(candidates, tools, providers) {
|
|
34
34
|
const bound = new Set([...tools.map((tool) => tool.name), ...providers.map((provider) => `decisions.${provider.id}`)]);
|
|
35
|
-
|
|
35
|
+
// A catalog source's tools (`monid:*`) are granted by name, never listed: the source is shown as it is, and its tools are
|
|
36
|
+
// host tools, run on every harness.
|
|
37
|
+
const unlocks = candidates.filter((name) => bound.has(name) || name.endsWith(":*"));
|
|
36
38
|
const run = new Set(tools.filter((tool) => unlocks.includes(tool.name)).flatMap((tool) => tool.harnesses));
|
|
37
|
-
return { unlocks, harnesses: HARNESSES.filter((harness) => run.has(harness)) };
|
|
39
|
+
return { unlocks, harnesses: HARNESSES.filter((harness) => run.has(harness) || unlocks.some((name) => name.endsWith(":*"))) };
|
|
38
40
|
}
|
|
39
41
|
/** What a row unlocks here: a `tool` row's, its tools and providers as capabilities bind them (unlockedBy); any other
|
|
40
42
|
* kind's (a model's), no tool, on those that run on it (its `harnesses`, when it names them) that this server runs
|
|
@@ -51,8 +53,11 @@ export function rowUnlocks(row, tools, providers, offers) {
|
|
|
51
53
|
const runs = (harness) => offers.some((offer) => offer.id === harness && (offer.keys ? key !== undefined && offer.keys.includes(key) : offer.available));
|
|
52
54
|
return { unlocks: [], harnesses: HARNESSES.filter((harness) => (row.harnesses ?? HARNESSES).includes(harness) && runs(harness)) };
|
|
53
55
|
}
|
|
56
|
+
/** Whether a key row's `unlock` unlocks the tool `name`: by its name, or `<source>:*` for every tool of a catalog source
|
|
57
|
+
* (`monid:*`: `monid:apollo/people/match`, `monid:apollo/*`). */
|
|
58
|
+
export const unlocksTool = (unlock, name) => unlock === name || (unlock.endsWith(":*") && name.startsWith(unlock.slice(0, -1)));
|
|
54
59
|
/** The key that unlocks the tool `name` (capabilities' `tools[].key`, so a page links "needs the X key" to it), if any. */
|
|
55
|
-
export const keyOf = (name) => TOOL_KEYS.find((row) => row.unlocks.
|
|
60
|
+
export const keyOf = (name) => TOOL_KEYS.find((row) => row.unlocks.some((unlock) => unlocksTool(unlock, name)))?.id;
|
|
56
61
|
/** Why a stored value does not open, in the order a re-entry names one: sealed under another key than the server's, or
|
|
57
62
|
* its row damaged. */
|
|
58
63
|
export const UNREADABLE = ["seal_key_changed", "file_unreadable"];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type ToolRow = {
|
|
2
|
+
readonly table?: true;
|
|
3
|
+
readonly askable?: true;
|
|
4
|
+
readonly replay?: "safe" | "never";
|
|
5
|
+
readonly blurb?: string;
|
|
6
|
+
readonly host?: true;
|
|
7
|
+
};
|
|
8
|
+
export declare const TOOL_LIST: Readonly<Record<string, ToolRow>>;
|
|
9
|
+
/** Every tool of serve's table (tools.ts), by name: a test holds this and the table as one. */
|
|
10
|
+
export declare const tableTools: () => string[];
|
|
11
|
+
/** Whether `name` has a row: a built-in this server registers (table tool, background tool, learned workflow). */
|
|
12
|
+
export declare const isToolRow: (name: string) => boolean;
|
|
13
|
+
/** Whether `name` is a tool of the table. */
|
|
14
|
+
export declare const isTableTool: (name: string) => boolean;
|
|
15
|
+
/** Whether ask is offered for `name`: the kernel runs its approved call itself. */
|
|
16
|
+
export declare const isAskable: (name: string) => boolean;
|
|
17
|
+
/** Whether a host runs `name` on a harness other than pi: it has a replay class. */
|
|
18
|
+
export declare const isHostTool: (name: string) => boolean;
|
|
19
|
+
/** `name`'s replay class as a host runs it, or none. */
|
|
20
|
+
export declare const replayOf: (name: string) => "safe" | "never" | undefined;
|
|
21
|
+
/** The tools a host runs on a harness other than pi, by name. */
|
|
22
|
+
export declare const hostToolNames: () => string[];
|
|
23
|
+
/** Whether `name` is a web tool every harness binds as a host tool (web_fetch, web_search). */
|
|
24
|
+
export declare const isWebHostTool: (name: string) => boolean;
|
|
25
|
+
/** `name`'s blurb, or none (an MCP server's tool, a name this server does not register). */
|
|
26
|
+
export declare const blurbOf: (name: string) => string | undefined;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const TOOL_LIST = Object.freeze({
|
|
2
|
+
read: { table: true, askable: true, replay: "safe", blurb: "Read files in the run's folder" },
|
|
3
|
+
write: { table: true, askable: true, replay: "never", blurb: "Write files in the run's folder" },
|
|
4
|
+
edit: { table: true, askable: true, replay: "never", blurb: "Edit files in the run's folder" },
|
|
5
|
+
bash: { table: true, askable: true, replay: "never", blurb: "Run shell commands in the sandbox" },
|
|
6
|
+
ask_person: { table: true, replay: "safe", blurb: "Ask you a question mid-run" },
|
|
7
|
+
web_fetch: { table: true, askable: true, replay: "safe", host: true, blurb: "Read a public web page" },
|
|
8
|
+
web_search: { table: true, askable: true, replay: "safe", host: true, blurb: "Search the web" },
|
|
9
|
+
browser: { table: true, blurb: "Browse websites in a hosted browser" },
|
|
10
|
+
subagent: { table: true, blurb: "Run a task in a fresh helper conversation" },
|
|
11
|
+
pdf_pages: { table: true, blurb: "Turn a PDF's pages into images" },
|
|
12
|
+
llm: { table: true, blurb: "Ask the model once, with no tools" },
|
|
13
|
+
bash_background: { replay: "never", blurb: "Start a long-running command in the sandbox" },
|
|
14
|
+
bash_output: { replay: "safe", blurb: "Read a background command's output" },
|
|
15
|
+
bash_input: { replay: "never", blurb: "Send input to a background command" },
|
|
16
|
+
bash_signal: { replay: "never", blurb: "Stop a background command" },
|
|
17
|
+
bash_list: { replay: "safe", blurb: "List the background commands" },
|
|
18
|
+
learned_workflow: { askable: true, replay: "never", blurb: "Run a workflow this agent learned" },
|
|
19
|
+
// The host tools over a run's own tools (runner/meta-tools.ts): no table entry and never granted, a settings key each.
|
|
20
|
+
tools_search: { blurb: "Find a tool by what it does, in a long list" },
|
|
21
|
+
tools_call: { blurb: "Call a tool the run does not list" },
|
|
22
|
+
codemode: { blurb: "Run a script that calls the run's tools" },
|
|
23
|
+
});
|
|
24
|
+
const rowOf = (name) => (Object.hasOwn(TOOL_LIST, name) ? TOOL_LIST[name] : undefined);
|
|
25
|
+
const namesWith = (field) => Object.keys(TOOL_LIST).filter((name) => TOOL_LIST[name][field] !== undefined);
|
|
26
|
+
/** Every tool of serve's table (tools.ts), by name: a test holds this and the table as one. */
|
|
27
|
+
export const tableTools = () => namesWith("table");
|
|
28
|
+
/** Whether `name` has a row: a built-in this server registers (table tool, background tool, learned workflow). */
|
|
29
|
+
export const isToolRow = (name) => rowOf(name) !== undefined;
|
|
30
|
+
/** Whether `name` is a tool of the table. */
|
|
31
|
+
export const isTableTool = (name) => rowOf(name)?.table === true;
|
|
32
|
+
/** Whether ask is offered for `name`: the kernel runs its approved call itself. */
|
|
33
|
+
export const isAskable = (name) => rowOf(name)?.askable === true;
|
|
34
|
+
/** Whether a host runs `name` on a harness other than pi: it has a replay class. */
|
|
35
|
+
export const isHostTool = (name) => rowOf(name)?.replay !== undefined;
|
|
36
|
+
/** `name`'s replay class as a host runs it, or none. */
|
|
37
|
+
export const replayOf = (name) => rowOf(name)?.replay;
|
|
38
|
+
/** The tools a host runs on a harness other than pi, by name. */
|
|
39
|
+
export const hostToolNames = () => namesWith("replay");
|
|
40
|
+
/** Whether `name` is a web tool every harness binds as a host tool (web_fetch, web_search). */
|
|
41
|
+
export const isWebHostTool = (name) => rowOf(name)?.host === true;
|
|
42
|
+
/** `name`'s blurb, or none (an MCP server's tool, a name this server does not register). */
|
|
43
|
+
export const blurbOf = (name) => rowOf(name)?.blurb;
|