@parcha/agentrun-serve 0.1.0-beta.37 → 0.1.0-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +700 -0
- package/README.md +441 -177
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +1 -3
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +48 -23
- package/dist/answer-json.d.ts +34 -1
- package/dist/answer-json.js +91 -9
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/bash-read-only.js +2 -1
- package/dist/browser-cost.js +52 -93
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -400
- package/dist/cap.js +6 -942
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +2 -6
- package/dist/chatgpt-plan.d.ts +163 -0
- package/dist/chatgpt-plan.js +549 -0
- package/dist/cli.js +26 -6
- package/dist/composio-preset.d.ts +25 -0
- package/dist/composio-preset.js +51 -8
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.d.ts +36 -24
- package/dist/computer-calls.js +110 -27
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +12 -2
- package/dist/computer-live.js +21 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +18 -2
- package/dist/computer-view.js +21 -6
- package/dist/computer-viewer.js +40 -13
- package/dist/computers.d.ts +8 -2
- package/dist/computers.js +18 -8
- package/dist/console/assets/index-BNhZs-jp.css +1 -0
- package/dist/console/assets/index-BQv5aOGB.js +700 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +6 -3
- package/dist/decision-cap.d.ts +2 -5
- package/dist/decision-cap.js +3 -6
- package/dist/decision-rows.js +11 -11
- package/dist/decisions.js +4 -0
- package/dist/email/account.d.ts +84 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +10 -0
- package/dist/email/answer.js +182 -0
- package/dist/email/email-faux.d.ts +95 -0
- package/dist/email/email-faux.js +849 -0
- package/dist/email/labels.d.ts +1 -0
- package/dist/email/labels.js +84 -0
- package/dist/email/mail.d.ts +186 -0
- package/dist/email/mail.js +380 -0
- package/dist/email/names.d.ts +20 -0
- package/dist/email/names.js +40 -0
- package/dist/email/routes.d.ts +9 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +20 -0
- package/dist/email/tools.js +517 -0
- package/dist/environment.d.ts +17 -2
- package/dist/environment.js +36 -8
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +12 -0
- package/dist/eval-mailbox.d.ts +103 -0
- package/dist/eval-mailbox.js +236 -0
- package/dist/faux-computers.js +4 -2
- package/dist/graph-view.d.ts +9 -2
- package/dist/graph-view.js +6 -2
- package/dist/harness-install.d.ts +28 -2
- package/dist/harness-install.js +147 -59
- package/dist/harness-opencode/adapter.js +2 -22
- package/dist/harness-opencode/facts.js +5 -4
- package/dist/harness-opencode/host/policy.d.ts +4 -5
- package/dist/harness-opencode/host/policy.js +14 -33
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/versions.d.ts +6 -0
- package/dist/harness-opencode/versions.js +6 -0
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +8 -7
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/host-tools.d.ts +1 -5
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +3 -3
- package/dist/hosted-search.js +51 -32
- package/dist/import-sources.d.ts +1 -1
- package/dist/import-sources.js +3 -3
- package/dist/import.d.ts +21 -0
- package/dist/import.js +186 -1
- package/dist/key-check.d.ts +0 -2
- package/dist/key-check.js +3 -4
- package/dist/key-refusal.d.ts +8 -2
- package/dist/key-refusal.js +16 -13
- package/dist/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +24 -4
- package/dist/learn/check.js +340 -7
- package/dist/learn/commit.d.ts +10 -0
- package/dist/learn/commit.js +18 -4
- package/dist/learn/compile.d.ts +250 -0
- package/dist/learn/compile.js +507 -0
- package/dist/learn/general.d.ts +3 -0
- package/dist/learn/general.js +4 -2
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +11 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +308 -0
- package/dist/learn/promote.js +321 -0
- package/dist/learn/refit.d.ts +48 -0
- package/dist/learn/refit.js +264 -0
- package/dist/learn/reflect.d.ts +5 -25
- package/dist/learn/reflect.js +14 -131
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +19 -16
- package/dist/learn/skills.js +157 -53
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +58 -2
- package/dist/learned-nodes.js +68 -5
- package/dist/learned-workflow.d.ts +58 -32
- package/dist/learned-workflow.js +215 -77
- package/dist/learning-batch.d.ts +2 -2
- package/dist/learning-batch.js +4 -4
- package/dist/learning-cost.d.ts +41 -11
- package/dist/learning-cost.js +31 -13
- package/dist/learning-routes.d.ts +12 -2
- package/dist/learning-routes.js +34 -6
- package/dist/learning-words.d.ts +8 -1
- package/dist/learning-words.js +11 -1
- package/dist/learning.d.ts +26 -1
- package/dist/learning.js +7 -4
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/llm.js +0 -3
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-gateway.d.ts +12 -20
- package/dist/mcp-gateway.js +16 -44
- package/dist/mcp-oauth.d.ts +5 -0
- package/dist/mcp-oauth.js +1 -1
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +113 -0
- package/dist/mcp-probe.d.ts +8 -9
- package/dist/mcp-probe.js +16 -33
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +102 -26
- package/dist/mcp-servers-store.js +151 -25
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +11 -0
- package/dist/mcp-store.js +16 -2
- package/dist/mcp-wire.d.ts +22 -0
- package/dist/mcp-wire.js +36 -0
- package/dist/mcp.js +3 -3
- package/dist/meta-tool-names.d.ts +1 -0
- package/dist/meta-tool-names.js +3 -0
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +39 -6
- package/dist/model.js +171 -32
- package/dist/monid.d.ts +50 -29
- package/dist/monid.js +234 -143
- package/dist/native/binding.d.ts +13 -0
- package/dist/native/binding.js +57 -0
- package/dist/native/cli.d.ts +2 -0
- package/dist/native/cli.js +48 -0
- package/dist/native/connection.d.ts +8 -0
- package/dist/native/connection.js +94 -0
- package/dist/native/context.d.ts +6 -0
- package/dist/native/context.js +22 -0
- package/dist/native/discovery.d.ts +27 -0
- package/dist/native/discovery.js +404 -0
- package/dist/native/environment.d.ts +4 -0
- package/dist/native/environment.js +18 -0
- package/dist/native/history.d.ts +20 -0
- package/dist/native/history.js +147 -0
- package/dist/native/instructions.d.ts +21 -0
- package/dist/native/instructions.js +173 -0
- package/dist/native/remote-worker-bridge.d.ts +3 -0
- package/dist/native/remote-worker-bridge.js +278 -0
- package/dist/native/remote.d.ts +187 -0
- package/dist/native/remote.js +492 -0
- package/dist/native/runtime.d.ts +17 -0
- package/dist/native/runtime.js +316 -0
- package/dist/native/runtimes.d.ts +66 -0
- package/dist/native/runtimes.js +41 -0
- package/dist/native/schema.d.ts +46 -0
- package/dist/native/schema.js +41 -0
- package/dist/native/types.d.ts +87 -0
- package/dist/native/types.js +1 -0
- package/dist/observation/http.d.ts +4 -0
- package/dist/observation/http.js +140 -0
- package/dist/observation/observer.d.ts +301 -0
- package/dist/observation/observer.js +919 -0
- package/dist/observation/schema.d.ts +52 -0
- package/dist/observation/schema.js +154 -0
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +705 -126
- package/dist/paid-calls.d.ts +34 -32
- package/dist/paid-calls.js +52 -104
- package/dist/place-offers.d.ts +4 -8
- package/dist/place-offers.js +4 -9
- package/dist/port-models.d.ts +7 -2
- package/dist/port-models.js +5 -2
- package/dist/print.d.ts +4 -2
- package/dist/print.js +4 -3
- package/dist/propose.d.ts +8 -3
- package/dist/propose.js +28 -7
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +17 -2
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/reflect-range.js +2 -1
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +23 -1
- package/dist/run-launch.js +17 -4
- package/dist/run-learning-served.d.ts +84 -0
- package/dist/run-manifest.d.ts +8 -0
- package/dist/run-manifest.js +33 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +12 -10
- package/dist/run-view.d.ts +59 -41
- package/dist/run-view.js +128 -64
- package/dist/runnable.d.ts +13 -8
- package/dist/runnable.js +77 -60
- package/dist/runner/adapter-loop.d.ts +60 -15
- package/dist/runner/adapter-loop.js +1406 -464
- package/dist/runner/adapter-run-spec.d.ts +45 -14
- package/dist/runner/adapter-run-spec.js +200 -116
- package/dist/runner/adapters/pi.d.ts +40 -7
- package/dist/runner/adapters/pi.js +149 -38
- package/dist/runner/beside.d.ts +3 -1
- package/dist/runner/beside.js +24 -8
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +28 -4
- package/dist/runner/cli-run-spec.d.ts +30 -0
- package/dist/runner/cli-run-spec.js +150 -66
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +5 -3
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +149 -5
- package/dist/runner/conformance/subject.d.ts +11 -4
- package/dist/runner/end-of-run.d.ts +8 -5
- package/dist/runner/end-of-run.js +11 -6
- package/dist/runner/feedback-round.d.ts +79 -0
- package/dist/runner/feedback-round.js +127 -0
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +55 -13
- package/dist/runner/journal-kinds.js +19 -0
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +58 -19
- package/dist/runner/learning-end.js +316 -115
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +21 -1
- package/dist/runner/learning-loop.js +24 -6
- package/dist/runner/learning-seed.d.ts +4 -0
- package/dist/runner/learning-seed.js +14 -0
- package/dist/runner/loop-contract.d.ts +19 -3
- package/dist/runner/loop.d.ts +34 -1
- package/dist/runner/loop.js +55 -1
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-claim.d.ts +5 -1
- package/dist/runner/mcp-claim.js +66 -50
- package/dist/runner/mcp-run.d.ts +20 -53
- package/dist/runner/mcp-run.js +22 -88
- package/dist/runner/meta-tools.d.ts +44 -0
- package/dist/runner/meta-tools.js +344 -0
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +128 -42
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +149 -19
- package/dist/runner/monid-run.d.ts +18 -0
- package/dist/runner/monid-run.js +170 -0
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +146 -0
- package/dist/runner/promotion.js +803 -0
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.d.ts +36 -21
- package/dist/runner/reflect-hook.js +147 -49
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +34 -8
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/sessions.d.ts +8 -3
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +7 -12
- package/dist/runner/workflow-first.d.ts +226 -0
- package/dist/runner/workflow-first.js +293 -0
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +32 -19
- package/dist/runner/workflow-spec.d.ts +5 -1
- package/dist/runner/workflow-spec.js +63 -48
- package/dist/runs-over-store.d.ts +41 -4
- package/dist/runs-over-store.js +64 -22
- package/dist/sdk/runs.d.ts +115 -0
- package/dist/sdk/runs.js +422 -0
- package/dist/sdk/schema.d.ts +175 -0
- package/dist/sdk/schema.js +138 -0
- package/dist/sdk/workflows.d.ts +22 -0
- package/dist/sdk/workflows.js +39 -0
- package/dist/secrets.d.ts +2 -0
- package/dist/secrets.js +19 -1
- package/dist/server.d.ts +108 -20
- package/dist/server.js +874 -157
- package/dist/settings-wake.d.ts +8 -6
- package/dist/settings-wake.js +13 -7
- package/dist/skill-route.d.ts +3 -0
- package/dist/skill-route.js +16 -0
- package/dist/skills/agentrun-serve/SKILL.md +368 -0
- package/dist/stats.d.ts +10 -10
- package/dist/store/agent-body.d.ts +22 -7
- package/dist/store/agent-body.js +23 -14
- package/dist/store/command-wake.d.ts +3 -2
- package/dist/store/command-wake.js +4 -4
- package/dist/store/index.d.ts +1 -1
- package/dist/store/native-command-owner.d.ts +10 -0
- package/dist/store/native-command-owner.js +47 -0
- package/dist/store/postgres/connection.js +3 -1
- package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
- package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
- package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
- package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
- package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
- package/dist/store/postgres/store.js +3 -0
- package/dist/store/schema.d.ts +16 -0
- package/dist/store/schema.js +47 -8
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +33 -10
- package/dist/store/sqlite/store.js +184 -28
- package/dist/store/store.d.ts +98 -21
- package/dist/store-reads/analytics.d.ts +7 -7
- package/dist/store-reads/analytics.js +23 -5
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/journal.d.ts +30 -1
- package/dist/store-reads/journal.js +141 -83
- package/dist/store-reads/learning.d.ts +179 -13
- package/dist/store-reads/learning.js +230 -68
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +3 -2
- package/dist/store-view.js +109 -37
- package/dist/template-eval.d.ts +87 -16
- package/dist/template-eval.js +605 -120
- package/dist/template-github-permissions.d.ts +2 -2
- package/dist/template-github-permissions.js +2 -1
- package/dist/template-import.d.ts +31 -0
- package/dist/template-import.js +121 -0
- package/dist/template-source.d.ts +51 -0
- package/dist/template-source.js +371 -0
- package/dist/templates.d.ts +274 -52
- package/dist/templates.js +670 -201
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +7 -5
- package/dist/timeline/index.js +7 -5
- package/dist/timeline/labels.d.ts +11 -4
- package/dist/timeline/labels.js +122 -8
- package/dist/timeline/origin.d.ts +20 -6
- package/dist/timeline/origin.js +13 -6
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +76 -20
- package/dist/timeline/timeline.js +184 -39
- package/dist/timeline/util.d.ts +5 -0
- package/dist/timeline/util.js +44 -8
- package/dist/timeline/web-calls.d.ts +17 -0
- package/dist/timeline/web-calls.js +106 -0
- package/dist/tool-gate.d.ts +103 -76
- package/dist/tool-gate.js +200 -127
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +29 -0
- package/dist/tool-list.js +50 -0
- package/dist/tool-names.d.ts +76 -0
- package/dist/tool-names.js +101 -0
- package/dist/tool-plane.d.ts +34 -28
- package/dist/tool-plane.js +72 -37
- package/dist/tools.d.ts +59 -15
- package/dist/tools.js +46 -42
- package/dist/trigger-adapter.d.ts +85 -5
- package/dist/trigger-adapter.js +6 -0
- package/dist/trigger-adapters.js +3 -1
- package/dist/trigger-composio.d.ts +10 -0
- package/dist/trigger-composio.js +122 -0
- package/dist/trigger-email.d.ts +4 -0
- package/dist/trigger-email.js +228 -0
- package/dist/trigger-signatures.d.ts +6 -10
- package/dist/trigger-signatures.js +16 -16
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +4 -3
- package/dist/trigger-webhook.js +6 -4
- package/dist/triggers.d.ts +94 -9
- package/dist/triggers.js +263 -62
- package/dist/uploads.d.ts +9 -0
- package/dist/uploads.js +27 -0
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +91 -50
- package/dist/web-fake.d.ts +56 -0
- package/dist/web-fake.js +102 -0
- package/dist/web-fetch-direct.d.ts +3 -0
- package/dist/web-fetch-direct.js +4 -1
- package/dist/web-fetch.d.ts +6 -8
- package/dist/web-fetch.js +10 -53
- package/dist/web-search.d.ts +51 -2
- package/dist/web-search.js +116 -18
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -1
- package/dist/workflow/node-runner.js +10 -2
- package/dist/workspace/archil-claim.d.ts +3 -0
- package/dist/workspace/archil-claim.js +9 -2
- package/dist/workspace/computer-deps.d.ts +25 -9
- package/dist/workspace/computer-deps.js +82 -38
- package/dist/workspace/computer-for-claim.d.ts +60 -4
- package/dist/workspace/computer-for-claim.js +203 -45
- package/dist/workspace/computer-hold.js +7 -1
- package/dist/workspace/computer-janitor.d.ts +10 -3
- package/dist/workspace/computer-janitor.js +96 -29
- package/dist/workspace/computer-kept.d.ts +82 -0
- package/dist/workspace/computer-kept.js +147 -0
- package/dist/workspace/computer-mcp.js +4 -3
- package/dist/workspace/computer-ports.d.ts +23 -3
- package/dist/workspace/computer-ports.js +115 -5
- package/dist/workspace/index.d.ts +2 -3
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +31 -11
- package/dist/workspace/kind-skills/phone/SKILL.md +29 -14
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +33 -1
- package/dist/workspace/resolve-computer.js +37 -16
- package/dist/workspace/revision-skills.d.ts +6 -2
- package/dist/workspace/revision-skills.js +12 -5
- package/dist/workspace/run-end-computers.d.ts +30 -0
- package/dist/workspace/run-end-computers.js +137 -0
- package/dist/workspace/run-tools.d.ts +40 -23
- package/dist/workspace/run-tools.js +46 -19
- package/dist/wrap-up.d.ts +35 -0
- package/dist/wrap-up.js +48 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +220 -60
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +46 -16
- package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
- package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
- package/templates/code-review/evals/injection/case.yaml +2 -1
- package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
- package/templates/code-review/evals/mentions-defused/case.yaml +3 -3
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
- package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
- package/templates/code-review/evals/never-flag/case.yaml +2 -1
- package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
- package/templates/code-review/evals/null-name/case.yaml +2 -1
- package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/case.yaml +2 -1
- package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +16 -0
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
- package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/code-review/evals/other-repo/prompt.md +10 -0
- package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
- package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
- package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
- package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
- package/templates/code-review/evals/re-review/case.yaml +2 -1
- package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
- package/templates/code-review/evals/re-review-open/case.yaml +2 -1
- package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
- package/templates/code-review/evals/repo-rule/case.yaml +2 -1
- package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
- package/templates/code-review/evals/two-defects/case.yaml +2 -1
- package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
- package/templates/code-review/rules/CODEREVIEW.md +1 -1
- package/templates/code-review/skills/review/DEEP.md +5 -4
- package/templates/code-review/skills/review/REVIEWER.md +5 -4
- package/templates/code-review/skills/review/SKILL.md +11 -6
- package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
- package/templates/inbound-lead/agent.md +26 -16
- package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
- package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
- package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
- package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
- package/templates/kyb/agent.md +15 -5
- package/templates/kyb/evals/adverse-media/prompt.md +2 -7
- package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
- package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
- package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
- package/templates/kyb/evals/name-collision/prompt.md +2 -6
- package/templates/kyb/evals/no-invention/prompt.md +2 -6
- package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
- package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
- package/templates/kyb/kyb.schema.json +8 -7
- package/templates/kyb/skills/kyb/SKILL.md +9 -6
- package/templates/market-monitor/agent.md +19 -12
- package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +32 -10
- package/templates/release-notes/evals/draft-not-publish/case.yaml +5 -4
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +5 -4
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/learned-style/case.yaml +2 -1
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
- package/templates/release-notes/evals/other-repo/case.yaml +24 -0
- package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
- package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
- package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/release-notes/evals/other-repo/prompt.md +32 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
- package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
- package/templates/release-notes/notes.schema.json +1 -1
- package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
- package/dist/console/assets/index-Cn6JX1uH.js +0 -563
- package/dist/console/assets/index-DRN62V5v.css +0 -1
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -7
- package/dist/runner/adapters/pi-computer.js +0 -43
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -38
- package/dist/tool-budget.js +0 -62
- package/dist/workspace/computer-script.d.ts +0 -37
- package/dist/workspace/computer-script.js +0 -138
- package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
- package/templates/code-review/evals/injection/graders/schema.md +0 -5
- package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
- package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
- package/templates/code-review/evals/null-name/graders/schema.md +0 -5
- package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
- package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
- package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
- package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
- package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
- package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
- package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
- package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
- package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
- package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
- package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
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,69 +16,53 @@
|
|
|
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 {
|
|
26
|
-
import { computerToolDefs, defaultPermissionOf } from "@parcha/agentrun-kernel/kernel";
|
|
27
|
+
import { COMPUTER_OP_TOOL, computerToolDefs, defaultPermissionOf, SHELL_FAMILY, SHELL_WATCHERS, shellPermission, shellToolOf } from "@parcha/agentrun-kernel/kernel";
|
|
27
28
|
import { READ_SKILL_FILE } from "@parcha/agentrun-kernel";
|
|
28
29
|
import { LEARNED_DIR } from "./learning.js";
|
|
29
30
|
import { COMPUTER_ROOT, portPath } from "./workspace/paths.js";
|
|
30
31
|
import { builtinHarness } from "./harness-table.js";
|
|
32
|
+
import { META_TOOLS } from "./meta-tool-names.js";
|
|
31
33
|
import { DEFAULT_HARNESS } from "./harness.js";
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import { deniedText, NOT_RUN, RAN_UNKNOWN } from "./refusal-words.js";
|
|
34
|
+
import { DECISION_PROVIDER_KEYS, KIND_KEYS, SERVE_OWN_TOOLS } from "./tool-plane.js";
|
|
35
|
+
import { asksByDefault, isToolRow, tableTools } from "./tool-list.js";
|
|
36
|
+
import { CANT_BE_CALLED, DENIED_OPENING, deniedText, NOT_RUN, RAN_UNKNOWN } from "./refusal-words.js";
|
|
35
37
|
import { approvalsOf } from "./approvals.js";
|
|
38
|
+
import { settingOfDefinition } from "./computer-setting.js";
|
|
36
39
|
import { BASH_POLICIES, readOnlyReason, readOnlyText } from "./bash-read-only.js";
|
|
40
|
+
import { formatToolName, isCatalogName, mcpNameOf, mcpToolName, monidNameOf } from "./tool-names.js";
|
|
37
41
|
/** What the gate does with a tool's calls. */
|
|
38
42
|
export const PERMISSIONS = ["allow", "ask", "deny"];
|
|
39
|
-
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* once: what a harness that names a session's MCP tool its own way (its facts' toolAlias: OpenCode's `<server>_<tool>`) is
|
|
45
|
-
* matched against, so its call is held to that tool's settings and never to a table tool's of the same shape. */
|
|
46
|
-
export const mcpServersOf = (granted) => [...new Set(granted.flatMap((name) => /^mcp:([^/]+)\//.exec(name)?.[1] ?? []))];
|
|
47
|
-
/** A third-party catalog tool, by its name: monid's (`monid.<tool>`) or an MCP server's (`mcp:<server>/<tool>`). */
|
|
48
|
-
export const isCatalogTool = (name) => name.startsWith("monid.") || isMcpTool(name);
|
|
49
|
-
/** The owner's defaults (11-01): a built-in kernel tool allow; a third-party catalog tool ask. On a run with no computer,
|
|
43
|
+
// An MCP tool's gate name is its catalog name, `mcp:<server>/<tool>` (tool-names.ts).
|
|
44
|
+
export { mcpToolName };
|
|
45
|
+
const isBuiltin = (name) => isToolRow(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || DECISION_PROVIDER_KEYS.includes(name);
|
|
46
|
+
/** 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
|
|
47
|
+
* decision provider's) allows; anything else asks, so a new source never defaults to allow. On a run with no computer,
|
|
50
48
|
* the kernel's ruled rule (defaultPermissionOf): bash asks first, and the background tools, which need a computer, are
|
|
51
49
|
* refused. */
|
|
52
50
|
export const defaultPermission = (name, where = {}) => {
|
|
53
|
-
if (
|
|
51
|
+
if (isCatalogName(name) || !isBuiltin(name) || asksByDefault(name))
|
|
54
52
|
return "ask";
|
|
55
53
|
return where.computer === false ? defaultPermissionOf(name, { computer: false }) : "allow";
|
|
56
54
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
export const SHELL_FAMILY = Object.freeze(Object.fromEntries(SHELL_TOOLS.map((name) => [name, "bash"])));
|
|
61
|
-
/** The shell tool a call named `name` is, under claude-agent's host-tool name too (`mcp__hands__bash_background`), when
|
|
62
|
-
* it is one held to another's setting: its own name, which its request, its refusal and its approved call keep. */
|
|
63
|
-
export const shellToolOf = (name) => {
|
|
64
|
-
const own = name.replace(/^mcp__hands__/, "");
|
|
65
|
-
return Object.hasOwn(SHELL_FAMILY, own) && SHELL_FAMILY[own] !== own ? own : undefined;
|
|
66
|
-
};
|
|
67
|
-
/** The shell tools that only watch or end a process the run already started, by its own id (background.ts: an id is
|
|
68
|
-
* digits under the run's own work/background/, and another's is "no background process"): under bash: ask they run
|
|
69
|
-
* unasked, so watching an approved process costs no approval per page. bash: deny still refuses them. */
|
|
70
|
-
export const SHELL_WATCHERS = new Set(["bash_output", "bash_list", "bash_signal"]);
|
|
71
|
-
/** Shell tool `name`'s permission, given bash's: a watcher's ask is allow; any other keeps bash's. */
|
|
72
|
-
const shellPermission = (name, bash) => (bash === "ask" && SHELL_WATCHERS.has(name) ? "allow" : bash);
|
|
55
|
+
// The shell family (bash and the background tools, each held to bash's setting; its watchers run unasked under bash: ask)
|
|
56
|
+
// is the kernel registry's, read here.
|
|
57
|
+
export { SHELL_FAMILY, SHELL_WATCHERS, shellToolOf };
|
|
73
58
|
/** The settings keys that may set `name`'s permission, most specific first: the tool's own name, then, for an MCP
|
|
74
|
-
* tool, its server's wildcard `mcp:<server>/*`. */
|
|
59
|
+
* tool, its server's wildcard `mcp:<server>/*`, and for a monid endpoint, its provider's `monid:<provider>/*`. */
|
|
75
60
|
export function permissionKeys(name) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
const mcp = mcpNameOf(name);
|
|
62
|
+
if (mcp)
|
|
63
|
+
return [name, formatToolName({ kind: "mcp-server", server: mcp.server })];
|
|
64
|
+
const monid = monidNameOf(name);
|
|
65
|
+
return monid ? [name, formatToolName({ kind: "monid-provider", provider: monid.provider })] : [name];
|
|
79
66
|
}
|
|
80
67
|
/** The browser's registrations on pi (pi-browser's BROWSER_TOOL_NAMES, which a test holds this list to): each is a call
|
|
81
68
|
* of the table's `browser`. */
|
|
@@ -86,28 +73,42 @@ const KIND_TOOLS = (() => {
|
|
|
86
73
|
const keys = new Map();
|
|
87
74
|
for (const def of [...computerToolDefs("desktop", []), ...computerToolDefs("phone", [])])
|
|
88
75
|
keys.set(def.name, [...new Set([...(keys.get(def.name) ?? []), def.settingsKey])]);
|
|
89
|
-
// pi's code mode, offered only beside a desktop's or a phone's tools (runner/adapters/pi-computer.ts): its scripts
|
|
90
|
-
// reach the computer as computer_script's do, so it is held to the same keys. Its nested tool calls pass the gate each.
|
|
91
|
-
keys.set(CODEMODE_TOOL_NAME, keys.get("computer_script") ?? []);
|
|
92
76
|
return keys;
|
|
93
77
|
})();
|
|
78
|
+
/** A script's computer op (computer_op's `op`) that runs on the computer what one of the run's own tools runs, held to
|
|
79
|
+
* that tool's setting: the shell is bash's, a program started to run on (processes.start) bash_background's (bash's
|
|
80
|
+
* setting, and a read-only bash policy refuses it), a file's write is write's, a file's read, listing or stat is
|
|
81
|
+
* read's. The other ops (apps, raw input) are the computer kind's, computer_op's own key (KIND_TOOLS). */
|
|
82
|
+
const OP_HELD_AS = Object.freeze({ "shell.run": "bash", "processes.start": "bash_background", "files.write": "write", "files.read": "read", "files.list": "read", "files.stat": "read" });
|
|
83
|
+
/** The ops whose command runs in the computer's shell. */
|
|
84
|
+
const SHELL_OPS = new Set(["shell.run", "processes.start"]);
|
|
85
|
+
/** The tool a call of `name` with `args` is held to, with the arguments that tool's gate reads, where it is not its own:
|
|
86
|
+
* a computer_op whose op runs what one of the run's own tools runs (OP_HELD_AS), with its command and cwd, or its path.
|
|
87
|
+
* Undefined for any other call. */
|
|
88
|
+
export function heldAs(name, args) {
|
|
89
|
+
if (name !== COMPUTER_OP_TOOL)
|
|
90
|
+
return undefined;
|
|
91
|
+
const { op, args: given } = (args ?? {});
|
|
92
|
+
const tool = typeof op === "string" && Object.hasOwn(OP_HELD_AS, op) ? OP_HELD_AS[op] : undefined;
|
|
93
|
+
if (tool === undefined)
|
|
94
|
+
return undefined;
|
|
95
|
+
const fields = (given !== null && typeof given === "object" ? given : {});
|
|
96
|
+
return { tool, args: SHELL_OPS.has(op) ? { command: fields.command, ...(fields.cwd !== undefined ? { cwd: fields.cwd } : {}) } : { path: fields.path } };
|
|
97
|
+
}
|
|
94
98
|
const STRICTNESS = { allow: 0, ask: 1, deny: 2 };
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
* each also as claude-agent's `mcp__hands__<name>`. The first named wins. */
|
|
101
|
-
export function nameMapOf(harness, mcpServers = []) {
|
|
99
|
+
/** Every name a session on `harness` gives its tools, to the settings key each is held to: the shell family (bash's),
|
|
100
|
+
* table, own and decision tools, read_skill_file (`read`), the kinds' tools (a shared one by its first kind), nativeTools,
|
|
101
|
+
* the browser's registrations. The names are the host's own: each adapter maps its CLI's names to them (its facts'
|
|
102
|
+
* hostName). The first named wins. */
|
|
103
|
+
export function nameMapOf(harness) {
|
|
102
104
|
const facts = builtinHarness(harness)?.facts;
|
|
103
105
|
const names = new Map();
|
|
104
106
|
const name = (own, key) => void (names.has(own) || names.set(own, key));
|
|
105
107
|
for (const [own, key] of Object.entries(SHELL_FAMILY))
|
|
106
108
|
name(own, key);
|
|
107
|
-
for (const own of [...
|
|
109
|
+
for (const own of [...tableTools(), ...SERVE_OWN_TOOLS, ...DECISION_PROVIDER_KEYS])
|
|
108
110
|
name(own, own);
|
|
109
|
-
|
|
110
|
-
name(READ_SKILL_FILE, alias && mcpServers.includes(alias[1]) ? mcpToolName(alias[1], alias[2]) : "read");
|
|
111
|
+
name(READ_SKILL_FILE, "read");
|
|
111
112
|
for (const [own, keys] of KIND_TOOLS)
|
|
112
113
|
name(own, keys[0]);
|
|
113
114
|
for (const [own, key] of Object.entries(facts?.nativeTools ?? {}))
|
|
@@ -115,34 +116,28 @@ export function nameMapOf(harness, mcpServers = []) {
|
|
|
115
116
|
name(own, key);
|
|
116
117
|
for (const own of BROWSER_REGISTRATIONS)
|
|
117
118
|
name(own, "browser");
|
|
118
|
-
for (const [own, key] of [...names])
|
|
119
|
-
name(`mcp__${HOST_TOOLS_SERVER}__${own}`, key);
|
|
120
119
|
return names;
|
|
121
120
|
}
|
|
122
121
|
/** The settings key a call named `name` on `harness` is held to: a lookup in the session's names (`names`), then the open
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
|
|
122
|
+
* open family no list holds (a catalog name, `mcp:<server>/<tool>` or `monid:<provider>/<endpoint>`). Undefined: nothing
|
|
123
|
+
* maps it, and the gate asks (an MCP tool's or monid endpoint's wire name is read back by the loop, ClaimMcp.catalogOf,
|
|
124
|
+
* before the gate is asked). */
|
|
125
|
+
export function settingsKeyOf(harness, name, names = nameMapOf(harness)) {
|
|
126
126
|
const own = names.get(name);
|
|
127
127
|
if (own !== undefined)
|
|
128
128
|
return own;
|
|
129
|
-
|
|
130
|
-
return name;
|
|
131
|
-
const mcp = /^mcp__([a-z][a-z0-9-]*)__(.+)$/.exec(name);
|
|
132
|
-
if (mcp)
|
|
133
|
-
return mcp[1] === HOST_TOOLS_SERVER ? settingsKeyOf(harness, mcp[2], mcpServers, names) : mcpToolName(mcp[1], mcp[2]);
|
|
134
|
-
const monid = /^monid_([a-z]+)$/.exec(name);
|
|
135
|
-
if (monid)
|
|
136
|
-
return `monid.${monid[1]}`;
|
|
137
|
-
const alias = builtinHarness(harness)?.facts?.toolAlias?.exec(name) ?? null;
|
|
138
|
-
return alias && mcpServers.includes(alias[1]) ? mcpToolName(alias[1], alias[2]) : undefined;
|
|
129
|
+
return isCatalogName(name) ? name : undefined;
|
|
139
130
|
}
|
|
131
|
+
/** Whether a pin's value is a keys pin: the one form that is an object. */
|
|
132
|
+
export const isPinKeys = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
140
133
|
/** The most arguments one setting pins, and the most values a one-of list holds. */
|
|
141
134
|
export const MAX_PIN_ARGS = 8;
|
|
142
135
|
export const MAX_PIN_CHOICES = 16;
|
|
143
|
-
/** A one-of list in its one form: each value once, null first, then by its JSON text;
|
|
144
|
-
* same meaning is the same text (a revision's id) and the same words (a refusal). */
|
|
136
|
+
/** 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,
|
|
137
|
+
* sorted; a scalar as it is. The same meaning is the same text (a revision's id) and the same words (a refusal). */
|
|
145
138
|
export const canonicalChoices = (value) => {
|
|
139
|
+
if (isPinKeys(value))
|
|
140
|
+
return { keys: [...new Set(value.keys)].sort() };
|
|
146
141
|
if (!Array.isArray(value))
|
|
147
142
|
return value;
|
|
148
143
|
const texts = [...new Set(value.filter((one) => one !== null).map((one) => JSON.stringify(one)))].sort();
|
|
@@ -153,18 +148,36 @@ export const canonicalPin = (pin) => Object.fromEntries(Object.keys(pin).sort().
|
|
|
153
148
|
/** Whether a call's argument `given` is the pinned scalar `one`: the same JSON scalar (strict equality), or, for null,
|
|
154
149
|
* left out or null. */
|
|
155
150
|
const isOne = (given, one) => (one === null ? given === undefined || given === null : given === one);
|
|
156
|
-
/** Whether `given` holds
|
|
157
|
-
|
|
151
|
+
/** Whether a call's argument `given` holds a keys pin's `keys`: left out, null, or an object (never a list) whose own keys
|
|
152
|
+
* are all among them. */
|
|
153
|
+
const keysHold = (given, keys) => given === undefined || given === null || (typeof given === "object" && !Array.isArray(given) && Object.keys(given).every((key) => keys.includes(key)));
|
|
154
|
+
/** Whether `given` holds pinned `value`: its scalar, one of its list, or its keys. */
|
|
155
|
+
const holds = (given, value) => (isPinKeys(value) ? keysHold(given, value.keys) : Array.isArray(value) ? value.some((one) => isOne(given, one)) : isOne(given, value));
|
|
158
156
|
/** A scalar in a refusal's words: text as it is, null as `absent`, any other as JSON. */
|
|
159
157
|
const scalarWords = (one) => (one === null ? "absent" : typeof one === "string" ? one : JSON.stringify(one));
|
|
160
158
|
/** A pin in words, as the refusal says it, in its one form (canonicalPin): `channel_id = C0123`, `cc absent` for a null,
|
|
161
|
-
* `event in (absent | COMMENT)` for a list. */
|
|
162
|
-
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(", ");
|
|
159
|
+
* `event in (absent | COMMENT)` for a list, `properties keys in (hs_lead_score)` for a keys pin. */
|
|
160
|
+
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(", ");
|
|
161
|
+
/** Names in words: `a`, `a and b`, `a, b and c`. */
|
|
162
|
+
const listWords = (names) => (names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`);
|
|
163
|
+
/** The arguments a call of `tool` carries that its listing does not declare, in words: "`to` is not an argument of X". */
|
|
164
|
+
const undeclaredWords = (args, tool) => `${listWords(args.map((arg) => `\`${arg}\``))} ${args.length === 1 ? "is not an argument" : "are not arguments"} of ${tool}`;
|
|
163
165
|
/** What holds both of two layers' pins of one argument (`own`, the agent's, and `theirs`, the server's): a scalar where
|
|
164
|
-
* either is one and the other holds it, else the agent's list kept to the server's, in the agent's order;
|
|
165
|
-
*
|
|
166
|
+
* 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,
|
|
167
|
+
* 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:
|
|
168
|
+
* left out). Undefined when nothing holds both, two keys pins with no key in both among them: no call writes a field
|
|
169
|
+
* each layer means. */
|
|
166
170
|
function bothOf(own, theirs) {
|
|
167
171
|
const list = (value) => (Array.isArray(value) ? value : [value]);
|
|
172
|
+
if (isPinKeys(own) && isPinKeys(theirs)) {
|
|
173
|
+
const kept = own.keys.filter((key) => theirs.keys.includes(key));
|
|
174
|
+
return kept.length ? { keys: kept } : undefined;
|
|
175
|
+
}
|
|
176
|
+
if (isPinKeys(own) || isPinKeys(theirs)) {
|
|
177
|
+
const [keys, other] = isPinKeys(own) ? [own, theirs] : [theirs, own];
|
|
178
|
+
const kept = list(other).filter((one) => holds(one, keys));
|
|
179
|
+
return !kept.length ? undefined : Array.isArray(other) ? kept : kept[0];
|
|
180
|
+
}
|
|
168
181
|
if (!Array.isArray(own))
|
|
169
182
|
return list(theirs).some((one) => one === own) ? own : undefined;
|
|
170
183
|
if (!Array.isArray(theirs))
|
|
@@ -174,23 +187,31 @@ function bothOf(own, theirs) {
|
|
|
174
187
|
}
|
|
175
188
|
/** 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
|
|
176
189
|
* addition to a setting, never a permission: each layer's pin on the tool's own key holds (the agent's and the
|
|
177
|
-
* server's both, whatever the permission), and a call must carry every pinned argument as pinned: its value,
|
|
178
|
-
* its list
|
|
179
|
-
*
|
|
180
|
-
|
|
181
|
-
|
|
190
|
+
* server's both, whatever the permission), and a call must carry every pinned argument as pinned: its value, one of
|
|
191
|
+
* its list, or (a keys pin) an object of its keys alone, null or the argument left out. An argument both layers pin
|
|
192
|
+
* takes what holds both; where nothing does, every call is refused. `declared`: the top-level arguments the tool's
|
|
193
|
+
* listing in the run's pin declares (its inputSchema's `properties`): a pinned tool takes only those and its pinned
|
|
194
|
+
* ones, so an alias the server takes beside a pinned argument (`to` beside `recipient_email`) is refused, with no
|
|
195
|
+
* table of aliases; undefined (a listing with no `properties` object, or none known), no argument is closed. `ran`:
|
|
196
|
+
* whether an earlier attempt of the call may have been sent (deniedText's). `mismatched`: the arguments that do not
|
|
197
|
+
* hold, for the gate's log line. */
|
|
198
|
+
export function pinRefusal(name, args, server, agent = {}, ran = "no", declared) {
|
|
199
|
+
if (!mcpNameOf(name))
|
|
182
200
|
return undefined;
|
|
183
201
|
const what = ran === "no" ? NOT_RUN : RAN_UNKNOWN;
|
|
184
202
|
if (server[name]?.brokenPin)
|
|
185
|
-
return { text: `${name}
|
|
203
|
+
return { text: `${name}${CANT_BE_CALLED}its pin in this server's tool settings does not read, so no call is let through until the owner sets it again (Settings → Tools). ${what}`, mismatched: [] };
|
|
186
204
|
const own = agent[name]?.pin ?? {};
|
|
187
205
|
const theirs = server[name]?.pin ?? {};
|
|
188
206
|
// Both layers hold: an argument both pin takes what holds both (bothOf), and one where nothing does refuses every call.
|
|
189
207
|
const clash = Object.keys(own).filter((arg) => Object.hasOwn(theirs, arg) && bothOf(own[arg], theirs[arg]) === undefined);
|
|
190
208
|
if (clash.length)
|
|
191
|
-
return { text: `${name}
|
|
209
|
+
return { text: `${name}${CANT_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 };
|
|
192
210
|
const pin = { ...theirs, ...Object.fromEntries(Object.entries(own).map(([arg, value]) => [arg, Object.hasOwn(theirs, arg) ? bothOf(value, theirs[arg]) : value])) };
|
|
193
211
|
const given = typeof args === "object" && args !== null && !Array.isArray(args) ? args : {};
|
|
212
|
+
const undeclared = declared && Object.keys(pin).length ? Object.keys(given).filter((arg) => !declared.has(arg) && !Object.hasOwn(pin, arg)) : [];
|
|
213
|
+
if (undeclared.length)
|
|
214
|
+
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 };
|
|
194
215
|
const mismatched = Object.keys(pin).filter((arg) => !holds(Object.hasOwn(given, arg) ? given[arg] : undefined, pin[arg]));
|
|
195
216
|
if (!mismatched.length)
|
|
196
217
|
return undefined;
|
|
@@ -206,12 +227,42 @@ export function pinRefusal(name, args, server, agent = {}, ran = "no") {
|
|
|
206
227
|
* layer, nor an ask that stands in for a setting that does not read. Nor is anything RunGate.enter refuses before it
|
|
207
228
|
* decides between running and parking ever lifted (a template's pin, among them). Without never, the answer is as it
|
|
208
229
|
* always was. */
|
|
209
|
-
export function permissionFrom(name, server, agent = {}, approvals = "ask", where = {}) {
|
|
230
|
+
export function permissionFrom(name, server, agent = {}, approvals = "ask", where = {}, effect) {
|
|
210
231
|
const { permission, from } = settingOf(name, server, agent, where);
|
|
232
|
+
if (permission === "ask" && effect === "read" && readsLift(name, server, agent, from))
|
|
233
|
+
return { permission: "allow", from: "server" };
|
|
211
234
|
if (approvals !== "never" || permission !== "ask" || standsBehind(name, server, agent))
|
|
212
235
|
return { permission, from };
|
|
213
236
|
return { permission: "allow", from: "unattended" };
|
|
214
237
|
}
|
|
238
|
+
export function toolEffect(annotations) {
|
|
239
|
+
const hints = typeof annotations === "object" && annotations !== null ? annotations : {};
|
|
240
|
+
if (hints.readOnlyHint === true)
|
|
241
|
+
return "read";
|
|
242
|
+
return hints.destructiveHint === true ? "destructive" : "write";
|
|
243
|
+
}
|
|
244
|
+
/** MCP tool `name`'s (`mcp:<server>/<tool>`) effect as a run's pin holds it (its annotations then, toolEffect): what the
|
|
245
|
+
* run's gate (ClaimMcp.effectOf) and a settings save's wake (settings-wake.ts) read, never a live listing. Undefined for a
|
|
246
|
+
* tool the pin does not hold. */
|
|
247
|
+
export function pinnedEffect(pin, name) {
|
|
248
|
+
const parsed = mcpNameOf(name);
|
|
249
|
+
const pinned = parsed && Object.hasOwn(pin, parsed.server) ? pin[parsed.server] : undefined;
|
|
250
|
+
const tool = pinned?.tools.find((one) => one.name === parsed.tool);
|
|
251
|
+
return tool ? toolEffect(tool.annotations) : undefined;
|
|
252
|
+
}
|
|
253
|
+
/** Whether "allow reads" lifts the ask of MCP tool `name`, one its run's pin marks read-only (permissionFrom's `effect`):
|
|
254
|
+
* its server's wildcard in this server's settings carries `allow_reads`, the ask came from the server's settings or
|
|
255
|
+
* the default (an agent's own ask holds), the tool's own key sets no permission on this server (an explicit setting
|
|
256
|
+
* beats the rule), and nothing stands behind the ask (standsBehind: a deny in any layer, a value that does not read,
|
|
257
|
+
* settings unread). A pin's refusal is RunGate.decide's, after this, so the rule never lifts one. */
|
|
258
|
+
function readsLift(name, server, agent, from) {
|
|
259
|
+
if (!mcpNameOf(name) || from === "agent")
|
|
260
|
+
return false;
|
|
261
|
+
const [own, wildcard] = permissionKeys(name);
|
|
262
|
+
if (server[own]?.permission !== undefined || server[wildcard]?.allow_reads !== true)
|
|
263
|
+
return false;
|
|
264
|
+
return !standsBehind(name, server, agent);
|
|
265
|
+
}
|
|
215
266
|
/** Marks the server's settings map when its stored value does not read (tool-plane.ts loadToolSettings): every
|
|
216
267
|
* tool then takes its defaults, and a deny it may hold can't be seen, so nothing lifts an ask over it. A symbol:
|
|
217
268
|
* carried by a spread, never by JSON (it is never served) nor by Object.entries (no reader takes it for a tool). */
|
|
@@ -274,14 +325,12 @@ function settingFrom(name, server, agent, where = {}) {
|
|
|
274
325
|
}
|
|
275
326
|
/** `name`'s permission in force (permissionFrom): the one rule every path reads, the gate's, the tool plane's and a
|
|
276
327
|
* workflow's call nodes'. */
|
|
277
|
-
export const permissionOf = (name, server, agent = {}, approvals = "ask") => permissionFrom(name, server, agent, approvals).permission;
|
|
328
|
+
export const permissionOf = (name, server, agent = {}, approvals = "ask", effect) => permissionFrom(name, server, agent, approvals, {}, effect).permission;
|
|
278
329
|
// The refusal words (SettingFrom, DenyFrom, NOT_RUN, RAN_UNKNOWN, denyPlace, deniedText, refusedText) live in
|
|
279
330
|
// refusal-words.ts, shared with the runner's loops.
|
|
280
331
|
export { deniedText, denyPlace, NOT_RUN, RAN_UNKNOWN, refusedText } from "./refusal-words.js";
|
|
281
332
|
/** The refusal of an ask where no one can approve it: a server with accounts off, whose answer route takes no token. */
|
|
282
|
-
export const noApproverText = (tool, ran = "no") =>
|
|
283
|
-
/** A parked call's answer: the run pauses here. */
|
|
284
|
-
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.`;
|
|
333
|
+
export const noApproverText = (tool, ran = "no") => `${DENIED_OPENING}${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}`;
|
|
285
334
|
/** The Timeline row of a call that waits for an approval. */
|
|
286
335
|
export const APPROVAL_ROW = "tool_approval_requested";
|
|
287
336
|
/** A call's arguments shown on its approval, at most this many bytes. */
|
|
@@ -305,33 +354,14 @@ export function previewOf(text) {
|
|
|
305
354
|
const bytes = Buffer.from(text, "utf8");
|
|
306
355
|
return bytes.length <= ARGS_PREVIEW_BYTES ? bytes.toString("utf8") : `${bytes.subarray(0, ARGS_PREVIEW_BYTES - 3).toString("utf8").replace(/\uFFFD+$/, "")}…`;
|
|
307
356
|
}
|
|
308
|
-
/** `args` as JSON, at most ARGS_PREVIEW_BYTES: the request's own record of them, never shown as it is. */
|
|
309
|
-
export const argsPreview = (args) => previewOf(JSON.stringify(args ?? {}) ?? "");
|
|
310
|
-
/** How the gate's resume message starts: the server knows its row by it, and redacts the row whole (runs.ts). */
|
|
311
|
-
export const RESUME_PREFIX = "[tool approval] ";
|
|
312
|
-
/** The one message that resumes a session once a person answered: it names the call it answers (its tool, call id and
|
|
313
|
-
* arguments), so the model tells it from a person's new input, and carries the call's result, or the refusal. */
|
|
314
|
-
/** The head of the gate's resume message: the call it answers, its arguments as shown (`shown`, redacted whole then cut,
|
|
315
|
-
* 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
|
|
316
|
-
* writes it, and the Timeline strips exactly it from the row a person opens (runs.ts resumeShows). */
|
|
317
|
-
export function resumeHead(request, shown) {
|
|
318
|
-
const args = shown.length > 300 ? `${shown.slice(0, 299)}…` : shown;
|
|
319
|
-
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.`;
|
|
320
|
-
}
|
|
321
|
-
/** The last line of a CLI's resume message (one, after every call it answers): the message arrives as a new turn, and a
|
|
322
|
-
* model that reads only results there answers about the approval, not the person's request (Claude Code, live). */
|
|
323
|
-
export const RESUME_GO_ON = "Go on with the person's request from where you stopped, using these results; don't call these tools again for them.";
|
|
324
|
-
export function resumeText(request, shown, decision, result) {
|
|
325
|
-
const head = resumeHead(request, shown);
|
|
326
|
-
return decision === "allow" ? `${head} They allowed it, and it ran${result.isError ? " and failed" : ""}. Its result:\n${result.text}` : `${head}\n${result.text}`;
|
|
327
|
-
}
|
|
328
357
|
/** The gate of the run `runId` whose folder is `where`, on its pinned revision. `serverSettings`: the server's tool
|
|
329
358
|
* settings as the runner read them from the one store at the claim (tool-plane.ts loadToolSettings), read at each call as
|
|
330
359
|
* the gate reads them. `approvers`: whether anyone can answer an ask here, the store's (server-approvers.ts, read at each
|
|
331
|
-
* claim). The gate reads nothing of the run's own files: they are the agent's to write.
|
|
332
|
-
* servers (mcpServersOf its grants), so a harness's own name for an MCP tool is held to that tool's settings. */
|
|
360
|
+
* claim). The gate reads nothing of the run's own files: they are the agent's to write. */
|
|
333
361
|
export function runGate(where, runId, revision, serverSettings, approvers) {
|
|
334
|
-
|
|
362
|
+
// The run's computer kind, from its revision's setting (as the claim starts it): a computer tool's words name it.
|
|
363
|
+
const kind = settingOfDefinition(revision.body)?.computer.kind;
|
|
364
|
+
return new RunGate({ root: where.root, work: where.work, runId, harness: revision.body.harness ?? DEFAULT_HARNESS, ...(where.computer === undefined ? {} : { computer: where.computer }), ...(kind !== undefined ? { kind } : {}), ...(where.effectOf ? { effectOf: where.effectOf } : {}), ...(where.argumentsOf ? { argumentsOf: where.argumentsOf } : {}) }, serverSettings, (revision.body.toolSettings ?? {}), approvers, approvalsOf(revision.body.approvals));
|
|
335
365
|
}
|
|
336
366
|
/** A run's tool gate on the runner: its policy, asked before each call's intent (decide). */
|
|
337
367
|
export class RunGate {
|
|
@@ -343,6 +373,8 @@ export class RunGate {
|
|
|
343
373
|
/** `readServerSettings`: the server's tool settings, read at each call; `overrides`: the pinned revision's own;
|
|
344
374
|
* `approvers`: whether anyone can answer an ask here (the owner's password session: accounts on); `approvals`: the
|
|
345
375
|
* pinned revision's (definition.approvals): "never" runs the agent unattended, an ask allowed (permissionFrom). */
|
|
376
|
+
/** `where.effectOf`: an MCP tool's effect as the run's pin marks it (ClaimMcp.effectOf), what "allow reads" reads;
|
|
377
|
+
* never a live listing, so a server can't widen a run's access mid-run. */
|
|
346
378
|
constructor(where, readServerSettings, overrides = {}, approvers = true, approvals = "ask") {
|
|
347
379
|
this.where = where;
|
|
348
380
|
this.readServerSettings = readServerSettings;
|
|
@@ -363,6 +395,21 @@ export class RunGate {
|
|
|
363
395
|
* the call is run again after an earlier attempt that may have been sent (a replay-safe call rerun after a crash), so a
|
|
364
396
|
* refusal says whether it took effect is not known, never that nothing was sent. */
|
|
365
397
|
async decide(name, args, options = {}) {
|
|
398
|
+
// tools_search, tools_call and the host's codemode (runner/meta-tools.ts) run: each call they make is asked about here
|
|
399
|
+
// as its own tool, by its own name (a computer's tool by its kind's setting, KIND_TOOLS).
|
|
400
|
+
// 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
|
|
401
|
+
// refused here).
|
|
402
|
+
if (META_TOOLS.has(name)) {
|
|
403
|
+
const setting = this.setting(name);
|
|
404
|
+
return setting.permission === "deny" ? { deny: deniedText(name, name, setting.from, options.replayed ? "unknown" : "no") } : "allow";
|
|
405
|
+
}
|
|
406
|
+
// A script's computer op that runs what one of the run's own tools runs (heldAs: its shell, its files) is that tool's
|
|
407
|
+
// call, decided as on a computer, where it runs: a desktop that mounts no folder has a computer to run a command on,
|
|
408
|
+
// so shell.run and processes.start follow bash's one setting alike, as the run's own tools on a computer do. It is a
|
|
409
|
+
// computer tool too: the kind's deny (desktop or phone set to deny) refuses it first, in the kind's words, below.
|
|
410
|
+
const held = heldAs(name, args);
|
|
411
|
+
if (held && this.policy(name) !== "deny")
|
|
412
|
+
return this.onComputer().decide(held.tool, held.args, options);
|
|
366
413
|
const key = this.keyOf(name) ?? name;
|
|
367
414
|
const tool = this.askedAs(name);
|
|
368
415
|
const ran = options.replayed ? "unknown" : "no";
|
|
@@ -379,25 +426,50 @@ export class RunGate {
|
|
|
379
426
|
return "allow";
|
|
380
427
|
return this.approvers ? "ask" : { deny: noApproverText(tool, ran) };
|
|
381
428
|
}
|
|
429
|
+
/** The settings key a call of `name` is held to, the one its refusal and its ask name: a computer tool's is the kind
|
|
430
|
+
* whose setting decides it (kindSetting), any other's its session's name map. */
|
|
382
431
|
keyOf(name) {
|
|
432
|
+
const kinds = this.kindKeysOf(name);
|
|
433
|
+
if (kinds)
|
|
434
|
+
return this.kindSetting(name, kinds).key;
|
|
383
435
|
const harness = this.where.harness ?? DEFAULT_HARNESS;
|
|
384
|
-
return settingsKeyOf(harness, name,
|
|
436
|
+
return settingsKeyOf(harness, name, (this.names ??= nameMapOf(harness)));
|
|
437
|
+
}
|
|
438
|
+
/** A computer tool's settings keys (KIND_TOOLS), the run's own kind first (where.kind); undefined for any other tool. */
|
|
439
|
+
kindKeysOf(tool) {
|
|
440
|
+
const keys = KIND_TOOLS.get(tool);
|
|
441
|
+
const kind = this.where.kind;
|
|
442
|
+
return keys && kind !== undefined && keys.includes(kind) ? [kind, ...keys.filter((key) => key !== kind)] : keys;
|
|
443
|
+
}
|
|
444
|
+
/** A computer tool's permission: the stricter of its kinds' settings (a desktop's and a phone's keys both hold it), and
|
|
445
|
+
* the key that decided it, the run's own kind on a tie, so a phone run's refusal and ask say phone. */
|
|
446
|
+
kindSetting(tool, kinds) {
|
|
447
|
+
return kinds.map((key) => ({ ...this.settingOf(tool, key), key })).reduce((strictest, one) => (STRICTNESS[one.permission] > STRICTNESS[strictest.permission] ? one : strictest));
|
|
385
448
|
}
|
|
386
449
|
/** The name a call is asked about by, as main's request names it (enter's `tool`): its settings key, a shell tool its
|
|
387
|
-
* own name; a name nothing maps, as it came. */
|
|
388
|
-
askedAs(name) {
|
|
450
|
+
* own name; a script's computer op with `args` by the tool it is held to (heldAs); a name nothing maps, as it came. */
|
|
451
|
+
askedAs(name, args) {
|
|
452
|
+
const held = heldAs(name, args);
|
|
453
|
+
if (held)
|
|
454
|
+
return this.askedAs(held.tool);
|
|
389
455
|
return shellToolOf(name) ?? this.keyOf(name) ?? name;
|
|
390
456
|
}
|
|
457
|
+
computerGate;
|
|
458
|
+
/** This gate as on a computer: where a script's computer op runs (heldAs), whatever the run's own shell is. */
|
|
459
|
+
onComputer() {
|
|
460
|
+
return (this.computerGate ??= new RunGate({ ...this.where, computer: true }, this.readServerSettings, this.overrides, this.approvers, this.approvals));
|
|
461
|
+
}
|
|
391
462
|
/** Where the permission `policy` gives `tool` was set: the agent's own tool settings, the server's, or the default; or
|
|
392
463
|
* "unattended", an ask the agent's approvals allowed. */
|
|
393
464
|
denyFrom = (tool) => this.setting(tool).from;
|
|
394
465
|
setting(tool) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
466
|
+
if (META_TOOLS.has(tool))
|
|
467
|
+
return this.settingOf(tool, tool);
|
|
468
|
+
// A tool the desktop and the phone both have (every computer tool) is held to the stricter of both keys' settings,
|
|
469
|
+
// never more permissive than the run's own kind's.
|
|
470
|
+
const kinds = this.kindKeysOf(tool);
|
|
471
|
+
if (kinds)
|
|
472
|
+
return this.kindSetting(tool, kinds);
|
|
401
473
|
return this.settingOf(tool, this.keyOf(tool));
|
|
402
474
|
}
|
|
403
475
|
/** `tool`'s permission under its settings key `key`, and where it was set. */
|
|
@@ -417,12 +489,13 @@ export class RunGate {
|
|
|
417
489
|
}
|
|
418
490
|
// A shell tool under every harness's name for it is read as its own name, by bash's key (permissionFrom): a watcher's
|
|
419
491
|
// ask is allow only where bash's ask is set as written. Its default is where the run's shell is (defaultPermission).
|
|
420
|
-
return permissionFrom(shellToolOf(tool) ?? key, server, this.overrides, this.approvals, where);
|
|
492
|
+
return permissionFrom(shellToolOf(tool) ?? key, server, this.overrides, this.approvals, where, mcpNameOf(key) ? this.where.effectOf?.(key) : undefined);
|
|
421
493
|
}
|
|
422
494
|
/** Why a pin refuses the call of `key` with `args` now (pinRefusal): the revision's own pins and the server's, read at
|
|
423
|
-
* each call as its permission is, so a pin set or changed reaches a live run at its next call
|
|
495
|
+
* 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
|
|
496
|
+
* the arguments its listing in the run's pin declares (where.argumentsOf). */
|
|
424
497
|
pinned(key, args, ran = "no") {
|
|
425
|
-
return pinRefusal(key, args, this.serverSettings() ?? {}, this.overrides, ran);
|
|
498
|
+
return pinRefusal(key, args, this.serverSettings() ?? {}, this.overrides, ran, this.where.argumentsOf?.(key));
|
|
426
499
|
}
|
|
427
500
|
/** Why bash's policy refuses the call `name` (held to `key`) with `args` now, or undefined: the revision's own setting
|
|
428
501
|
* (an agent's tool_settings.bash.policy), so every shell tool under every harness's name for it is held to it. A policy
|
|
@@ -433,11 +506,11 @@ export class RunGate {
|
|
|
433
506
|
const policy = this.overrides.bash?.policy;
|
|
434
507
|
if (policy === undefined)
|
|
435
508
|
return undefined;
|
|
436
|
-
// Its own name for a background tool (bash_background
|
|
509
|
+
// Its own name for a background tool (bash_background);bash for bash and
|
|
437
510
|
// a CLI's own shell (codex's shell, claude-agent's Bash).
|
|
438
511
|
const tool = shellToolOf(name) ?? "bash";
|
|
439
512
|
if (!BASH_POLICIES.includes(policy))
|
|
440
|
-
return `${tool}
|
|
513
|
+
return `${tool}${CANT_BE_CALLED}this agent's bash policy ${JSON.stringify(policy).slice(0, 60)} is not one this server knows (${BASH_POLICIES.join(", ")}), so no command is let through until its tool_settings name one. ${NOT_RUN}`;
|
|
441
514
|
const reason = readOnlyReason(tool, args, [this.where.work, COMPUTER_ROOT]);
|
|
442
515
|
return reason === undefined ? undefined : readOnlyText(tool, reason, NOT_RUN);
|
|
443
516
|
}
|
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,29 @@
|
|
|
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
|
+
readonly asks?: true;
|
|
8
|
+
};
|
|
9
|
+
export declare const TOOL_LIST: Readonly<Record<string, ToolRow>>;
|
|
10
|
+
/** Every tool of serve's table (tools.ts), by name: a test holds this and the table as one. */
|
|
11
|
+
export declare const tableTools: () => string[];
|
|
12
|
+
/** Whether `name` has a row: a built-in this server registers (table tool, background tool, learned workflow). */
|
|
13
|
+
export declare const isToolRow: (name: string) => boolean;
|
|
14
|
+
/** Whether `name` is a tool of the table. */
|
|
15
|
+
export declare const isTableTool: (name: string) => boolean;
|
|
16
|
+
/** Whether ask is offered for `name`: the kernel runs its approved call itself. */
|
|
17
|
+
export declare const isAskable: (name: string) => boolean;
|
|
18
|
+
/** Whether a host runs `name` on a harness other than pi: it has a replay class. */
|
|
19
|
+
export declare const isHostTool: (name: string) => boolean;
|
|
20
|
+
/** `name`'s replay class as a host runs it, or none. */
|
|
21
|
+
export declare const replayOf: (name: string) => "safe" | "never" | undefined;
|
|
22
|
+
/** The tools a host runs on a harness other than pi, by name. */
|
|
23
|
+
export declare const hostToolNames: () => string[];
|
|
24
|
+
/** Whether `name` is a tool every harness binds as a host tool (web_fetch, web_search, the email tools). */
|
|
25
|
+
export declare const isWebHostTool: (name: string) => boolean;
|
|
26
|
+
/** Whether `name`'s default permission is ask (email_send). */
|
|
27
|
+
export declare const asksByDefault: (name: string) => boolean;
|
|
28
|
+
/** `name`'s blurb, or none (an MCP server's tool, a name this server does not register). */
|
|
29
|
+
export declare const blurbOf: (name: string) => string | undefined;
|