@parcha/agentrun-serve 0.1.0-beta.38 → 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 +418 -0
- package/README.md +325 -124
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +0 -2
- package/dist/agents-store.d.ts +5 -5
- package/dist/agents-store.js +14 -14
- package/dist/bash-read-only.js +2 -1
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -10
- package/dist/cap.js +2 -5
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +1 -5
- 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 +8 -0
- package/dist/composio-preset.js +8 -7
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.js +2 -2
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +7 -2
- package/dist/computer-live.js +9 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +3 -3
- package/dist/computer-setting.js +5 -5
- package/dist/computer-view.d.ts +15 -0
- package/dist/computer-view.js +16 -2
- package/dist/computer-viewer.js +14 -1
- package/dist/computers.d.ts +5 -2
- package/dist/computers.js +9 -5
- 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.js +3 -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/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/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 -26
- package/dist/harness-opencode/facts.js +5 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -0
- package/dist/harness-opencode/host/policy.js +10 -5
- 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.js +8 -5
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/hosted-search.d.ts +3 -1
- package/dist/hosted-search.js +51 -11
- 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/learn/check.d.ts +18 -3
- package/dist/learn/check.js +328 -3
- package/dist/learn/compile.d.ts +9 -2
- package/dist/learn/compile.js +52 -16
- package/dist/learn/grade.d.ts +4 -0
- package/dist/learn/grade.js +4 -1
- package/dist/learn/promote.d.ts +106 -51
- package/dist/learn/promote.js +82 -189
- package/dist/learn/refit.d.ts +21 -12
- package/dist/learn/refit.js +51 -23
- package/dist/learn/replay-calls.js +1 -1
- package/dist/learn/skills.d.ts +2 -7
- package/dist/learn/skills.js +28 -14
- package/dist/learned-nodes.d.ts +15 -7
- package/dist/learned-nodes.js +29 -5
- package/dist/learned-workflow.d.ts +41 -31
- package/dist/learned-workflow.js +122 -63
- package/dist/learning-batch.js +3 -3
- package/dist/learning-cost.d.ts +26 -8
- package/dist/learning-cost.js +17 -7
- package/dist/learning-routes.d.ts +2 -4
- package/dist/learning-routes.js +20 -3
- package/dist/learning-words.d.ts +1 -1
- package/dist/learning-words.js +4 -1
- package/dist/learning.d.ts +5 -5
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-pin-first.js +6 -0
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +25 -16
- package/dist/mcp-servers-store.js +23 -3
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +26 -6
- package/dist/model.js +126 -18
- package/dist/monid.d.ts +26 -31
- package/dist/monid.js +84 -79
- 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 +394 -85
- package/dist/paid-calls.d.ts +8 -3
- package/dist/paid-calls.js +6 -2
- 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 +1 -2
- package/dist/propose.js +10 -1
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +8 -0
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/run-launch.d.ts +10 -1
- package/dist/run-launch.js +11 -4
- package/dist/run-learning-served.d.ts +75 -2
- package/dist/run-manifest.d.ts +3 -0
- package/dist/run-manifest.js +13 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +8 -9
- package/dist/run-view.d.ts +42 -35
- package/dist/run-view.js +79 -44
- package/dist/runnable.d.ts +13 -5
- package/dist/runnable.js +69 -60
- package/dist/runner/adapter-loop.d.ts +42 -11
- package/dist/runner/adapter-loop.js +651 -247
- package/dist/runner/adapter-run-spec.d.ts +37 -12
- package/dist/runner/adapter-run-spec.js +139 -106
- package/dist/runner/adapters/pi.d.ts +24 -0
- package/dist/runner/adapters/pi.js +59 -9
- 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 +94 -50
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +3 -2
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.js +6 -3
- package/dist/runner/end-of-run.d.ts +2 -0
- package/dist/runner/end-of-run.js +3 -1
- package/dist/runner/feedback-round.d.ts +40 -13
- package/dist/runner/feedback-round.js +64 -16
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +37 -13
- package/dist/runner/journal-kinds.js +9 -5
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +4 -0
- package/dist/runner/learning-end.js +64 -36
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +2 -0
- package/dist/runner/learning-loop.js +19 -4
- package/dist/runner/loop.d.ts +18 -0
- package/dist/runner/loop.js +34 -0
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-run.d.ts +4 -1
- package/dist/runner/mcp-run.js +11 -5
- package/dist/runner/meta-tools.d.ts +10 -3
- package/dist/runner/meta-tools.js +112 -36
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +114 -39
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +139 -18
- package/dist/runner/monid-run.d.ts +8 -6
- package/dist/runner/monid-run.js +117 -43
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +74 -8
- package/dist/runner/promotion.js +365 -124
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.js +9 -0
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +8 -4
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/workflow-first.d.ts +30 -20
- package/dist/runner/workflow-first.js +22 -32
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +18 -12
- package/dist/runner/workflow-spec.d.ts +4 -1
- package/dist/runner/workflow-spec.js +56 -45
- package/dist/runs-over-store.d.ts +30 -2
- package/dist/runs-over-store.js +46 -14
- 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 +48 -32
- package/dist/server.js +554 -130
- 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 +12 -8
- package/dist/store/agent-body.js +9 -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/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 +7 -0
- package/dist/store/schema.js +20 -1
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +14 -3
- package/dist/store/sqlite/store.js +133 -18
- package/dist/store/store.d.ts +52 -7
- 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 +5 -0
- package/dist/store-reads/journal.js +85 -41
- package/dist/store-reads/learning.d.ts +85 -5
- package/dist/store-reads/learning.js +45 -17
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.js +75 -21
- package/dist/template-eval.d.ts +73 -11
- package/dist/template-eval.js +535 -75
- package/dist/templates.d.ts +70 -20
- package/dist/templates.js +191 -34
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/index.d.ts +3 -2
- package/dist/timeline/index.js +3 -2
- package/dist/timeline/labels.d.ts +5 -2
- package/dist/timeline/labels.js +29 -6
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +66 -4
- package/dist/timeline/timeline.js +160 -30
- 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 +42 -42
- package/dist/tool-gate.js +97 -91
- package/dist/tool-list.d.ts +4 -1
- package/dist/tool-list.js +8 -1
- package/dist/tool-names.d.ts +18 -13
- package/dist/tool-names.js +19 -17
- package/dist/tool-plane.d.ts +17 -13
- package/dist/tool-plane.js +12 -5
- package/dist/tools.d.ts +44 -16
- package/dist/tools.js +28 -28
- 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.js +1 -7
- 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 +5 -1
- package/dist/web-fetch.js +8 -31
- 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 +22 -9
- package/dist/workspace/computer-deps.js +78 -37
- package/dist/workspace/computer-for-claim.d.ts +54 -4
- package/dist/workspace/computer-for-claim.js +179 -39
- 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 +1 -2
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +25 -18
- package/dist/workspace/kind-skills/phone/SKILL.md +28 -17
- package/dist/workspace/resolve-computer.d.ts +15 -3
- package/dist/workspace/resolve-computer.js +10 -7
- 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 +28 -29
- package/dist/workspace/run-tools.js +29 -30
- package/dist/wrap-up.d.ts +19 -5
- package/dist/wrap-up.js +31 -4
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +117 -23
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +18 -4
- package/templates/code-review/evals/mentions-defused/case.yaml +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +1 -1
- 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/skills/review/DEEP.md +2 -2
- package/templates/code-review/skills/review/REVIEWER.md +2 -2
- package/templates/code-review/skills/review/SKILL.md +7 -3
- package/templates/release-notes/evals/draft-not-publish/case.yaml +1 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +1 -1
- package/templates/release-notes/evals/late-arrival/case.yaml +1 -1
- package/templates/release-notes/evals/other-repo/case.yaml +1 -1
- package/dist/console/assets/index-CjqQirbo.css +0 -1
- package/dist/console/assets/index-b6-XY5A9.js +0 -576
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -9
- package/dist/runner/adapters/pi-computer.js +0 -51
- package/dist/workspace/computer-script.d.ts +0 -53
- package/dist/workspace/computer-script.js +0 -172
package/dist/tool-gate.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SHELL_FAMILY, SHELL_WATCHERS, shellToolOf } from "@parcha/agentrun-kernel/kernel";
|
|
1
2
|
import type { Workspace } from "./workspace/workspace.js";
|
|
2
3
|
import { type ToolSettingsRead } from "./tool-plane.js";
|
|
3
4
|
import { type SettingFrom } from "./refusal-words.js";
|
|
@@ -7,14 +8,6 @@ import { mcpToolName } from "./tool-names.js";
|
|
|
7
8
|
export declare const PERMISSIONS: readonly ["allow", "ask", "deny"];
|
|
8
9
|
export type Permission = (typeof PERMISSIONS)[number];
|
|
9
10
|
export { mcpToolName };
|
|
10
|
-
/** The MCP servers a revision grants tools of, by their catalog names (`mcp:<server>/<tool>`, a server's wildcard too), each
|
|
11
|
-
* once: what a harness that names a session's MCP tool its own way (its facts' toolAlias: OpenCode's `<server>_<tool>`) is
|
|
12
|
-
* matched against, so its call is held to that tool's settings and never to a table tool's of the same shape. */
|
|
13
|
-
export declare const mcpServersOf: (granted: readonly string[]) => string[];
|
|
14
|
-
/** A third-party catalog tool, by its name: any in MCP's namespace (`mcp:<server>/<tool>`) or monid's
|
|
15
|
-
* (`monid:<provider>/<endpoint>`), a group's wildcard too; one that does not parse too, so the default for it is a
|
|
16
|
-
* catalog tool's ask. */
|
|
17
|
-
export declare const isCatalogTool: (name: string) => boolean;
|
|
18
11
|
/** Where a run's shell is, as its default permissions read it: `computer` false for a run with no computer (its bash, where
|
|
19
12
|
* it has one, runs on the run's folder's own exec: Archil's in Mode 2); undefined where no run is in view (the server's
|
|
20
13
|
* settings page, capabilities), which reads the computer's defaults. */
|
|
@@ -26,32 +19,29 @@ export type ShellWhere = {
|
|
|
26
19
|
* the kernel's ruled rule (defaultPermissionOf): bash asks first, and the background tools, which need a computer, are
|
|
27
20
|
* refused. */
|
|
28
21
|
export declare const defaultPermission: (name: string, where?: ShellWhere) => Permission;
|
|
29
|
-
|
|
30
|
-
* refuses bash_background as it refuses bash, and none of them is a settings key of its own. Under bash: ask the
|
|
31
|
-
* watchers (SHELL_WATCHERS) run unasked. */
|
|
32
|
-
export declare const SHELL_FAMILY: Readonly<Record<string, string>>;
|
|
33
|
-
/** The shell tool a call named `name` is, under claude-agent's host-tool name too (`mcp__hands__bash_background`), when
|
|
34
|
-
* it is one held to another's setting: its own name, which its request, its refusal and its approved call keep. */
|
|
35
|
-
export declare const shellToolOf: (name: string) => string | undefined;
|
|
36
|
-
/** The shell tools that only watch or end a process the run already started, by its own id (background.ts: an id is
|
|
37
|
-
* digits under the run's own work/background/, and another's is "no background process"): under bash: ask they run
|
|
38
|
-
* unasked, so watching an approved process costs no approval per page. bash: deny still refuses them. */
|
|
39
|
-
export declare const SHELL_WATCHERS: ReadonlySet<string>;
|
|
22
|
+
export { SHELL_FAMILY, SHELL_WATCHERS, shellToolOf };
|
|
40
23
|
/** The settings keys that may set `name`'s permission, most specific first: the tool's own name, then, for an MCP
|
|
41
24
|
* tool, its server's wildcard `mcp:<server>/*`, and for a monid endpoint, its provider's `monid:<provider>/*`. */
|
|
42
25
|
export declare function permissionKeys(name: string): string[];
|
|
26
|
+
/** 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:
|
|
27
|
+
* 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.
|
|
28
|
+
* Undefined for any other call. */
|
|
29
|
+
export declare function heldAs(name: string, args: unknown): {
|
|
30
|
+
readonly tool: string;
|
|
31
|
+
readonly args: unknown;
|
|
32
|
+
} | undefined;
|
|
43
33
|
/** A session's `{name -> settings key}` map (nameMapOf). */
|
|
44
34
|
export type NameMap = ReadonlyMap<string, string>;
|
|
45
|
-
/** Every name a session on `harness`
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
export declare function nameMapOf(harness: string
|
|
35
|
+
/** Every name a session on `harness` gives its tools, to the settings key each is held to: the shell family (bash's),
|
|
36
|
+
* table, own and decision tools, read_skill_file (`read`), the kinds' tools (a shared one by its first kind), nativeTools,
|
|
37
|
+
* the browser's registrations. The names are the host's own: each adapter maps its CLI's names to them (its facts'
|
|
38
|
+
* hostName). The first named wins. */
|
|
39
|
+
export declare function nameMapOf(harness: string): NameMap;
|
|
50
40
|
/** The settings key a call named `name` on `harness` is held to: a lookup in the session's names (`names`), then the open
|
|
51
|
-
*
|
|
52
|
-
* and
|
|
53
|
-
*
|
|
54
|
-
export declare function settingsKeyOf(harness: string, name: string,
|
|
41
|
+
* open family no list holds (a catalog name, `mcp:<server>/<tool>` or `monid:<provider>/<endpoint>`). Undefined: nothing
|
|
42
|
+
* maps it, and the gate asks (an MCP tool's or monid endpoint's wire name is read back by the loop, ClaimMcp.catalogOf,
|
|
43
|
+
* before the gate is asked). */
|
|
44
|
+
export declare function settingsKeyOf(harness: string, name: string, names?: NameMap): string | undefined;
|
|
55
45
|
/** A pinned argument's scalar: `null` holds for a call that leaves the argument out (or gives null). */
|
|
56
46
|
export type PinScalar = string | number | boolean | null;
|
|
57
47
|
/** A pinned object argument's keys: the argument, when given (not left out, nor null), is an object whose keys are among
|
|
@@ -137,8 +127,10 @@ export declare const SETTINGS_UNREAD: unique symbol;
|
|
|
137
127
|
* workflow's call nodes'. */
|
|
138
128
|
export declare const permissionOf: (name: string, server: PermissionSettings, agent?: PermissionSettings, approvals?: Approvals, effect?: ToolEffect) => Permission;
|
|
139
129
|
/** An approval's price for the person who answers it: USD where the tool declares one (booked through the spend cap's
|
|
140
|
-
* paidCall), else "not metered" (an unpriced MCP call, the owner's ruling of 11-04)
|
|
141
|
-
|
|
130
|
+
* paidCall), else "not metered" (an unpriced MCP call, the owner's ruling of 11-04), or "priced by usage" for a monid
|
|
131
|
+
* endpoint priced by usage: monid estimates its cost only when the call runs, after the person's allow, and its charge
|
|
132
|
+
* can pass that estimate (runner/monid-run.ts). */
|
|
133
|
+
export type ApprovalPrice = number | "not metered" | "priced by usage";
|
|
142
134
|
/** One pending approval, as the run's view shows it (`pending`) and the console's approval card reads it. */
|
|
143
135
|
export type PendingApproval = {
|
|
144
136
|
kind: "approval";
|
|
@@ -148,6 +140,9 @@ export type PendingApproval = {
|
|
|
148
140
|
call_id: string;
|
|
149
141
|
/** The call's arguments as text, at most ARGS_PREVIEW_BYTES. */
|
|
150
142
|
args_preview: string;
|
|
143
|
+
/** What the call does in words, where its tool says (email_send: "Send email to <to>, cc <cc>: <subject>" and the
|
|
144
|
+
* text's first 300 characters), redacted as its arguments are. */
|
|
145
|
+
summary?: string;
|
|
151
146
|
requested_at: string;
|
|
152
147
|
price?: ApprovalPrice;
|
|
153
148
|
/** Present, true, when the run's pin marks the tool destructive (toolEffect): an allow of it needs confirm_destructive. */
|
|
@@ -185,14 +180,11 @@ export declare function previewOf(text: string): string;
|
|
|
185
180
|
/** The gate of the run `runId` whose folder is `where`, on its pinned revision. `serverSettings`: the server's tool
|
|
186
181
|
* settings as the runner read them from the one store at the claim (tool-plane.ts loadToolSettings), read at each call as
|
|
187
182
|
* the gate reads them. `approvers`: whether anyone can answer an ask here, the store's (server-approvers.ts, read at each
|
|
188
|
-
* claim). The gate reads nothing of the run's own files: they are the agent's to write.
|
|
189
|
-
* servers (mcpServersOf its grants), so a harness's own name for an MCP tool is held to that tool's settings. */
|
|
183
|
+
* claim). The gate reads nothing of the run's own files: they are the agent's to write. */
|
|
190
184
|
export declare function runGate(where: {
|
|
191
185
|
root: string;
|
|
192
186
|
work: string;
|
|
193
187
|
computer?: boolean;
|
|
194
|
-
mcpServers?: readonly string[];
|
|
195
|
-
computerCodemode?: boolean;
|
|
196
188
|
effectOf?: (name: string) => ToolEffect | undefined;
|
|
197
189
|
argumentsOf?: ArgumentsOf;
|
|
198
190
|
}, runId: string, revision: {
|
|
@@ -201,6 +193,8 @@ export declare function runGate(where: {
|
|
|
201
193
|
toolSettings?: unknown;
|
|
202
194
|
harness?: string;
|
|
203
195
|
approvals?: Approvals;
|
|
196
|
+
computer?: unknown;
|
|
197
|
+
place?: unknown;
|
|
204
198
|
};
|
|
205
199
|
}, serverSettings: () => ToolSettingsRead, approvers: boolean): RunGate;
|
|
206
200
|
/** The top-level arguments the listing of the MCP tool `name` (`mcp:<server>/<tool>`) in the run's pin declares under
|
|
@@ -227,9 +221,8 @@ export declare class RunGate {
|
|
|
227
221
|
work: string;
|
|
228
222
|
runId: string;
|
|
229
223
|
harness?: string;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
computerCodemode?: boolean;
|
|
224
|
+
computer?: boolean; /** The run's computer kind (its revision's setting): the key a computer tool's refusal and ask name on a tie (kindSetting). */
|
|
225
|
+
kind?: string;
|
|
233
226
|
effectOf?: (name: string) => ToolEffect | undefined; /** The arguments each MCP tool's listing in the run's pin declares (ClaimMcp.argumentsOf), for a pinned tool's closure (pinRefusal). */
|
|
234
227
|
argumentsOf?: ArgumentsOf;
|
|
235
228
|
}, readServerSettings: () => ToolSettingsRead, overrides?: PermissionSettings, approvers?: boolean, approvals?: Approvals);
|
|
@@ -250,16 +243,23 @@ export declare class RunGate {
|
|
|
250
243
|
}): Promise<"allow" | "ask" | {
|
|
251
244
|
deny: string;
|
|
252
245
|
}>;
|
|
246
|
+
/** 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
|
|
247
|
+
* whose setting decides it (kindSetting), any other's its session's name map. */
|
|
253
248
|
private keyOf;
|
|
249
|
+
/** A computer tool's settings keys (KIND_TOOLS), the run's own kind first (where.kind); undefined for any other tool. */
|
|
250
|
+
private kindKeysOf;
|
|
251
|
+
/** A computer tool's permission: the stricter of its kinds' settings (a desktop's and a phone's keys both hold it), and
|
|
252
|
+
* the key that decided it, the run's own kind on a tie, so a phone run's refusal and ask say phone. */
|
|
253
|
+
private kindSetting;
|
|
254
254
|
/** The name a call is asked about by, as main's request names it (enter's `tool`): its settings key, a shell tool its
|
|
255
|
-
* own name; a name nothing maps, as it came. */
|
|
256
|
-
askedAs(name: string): string;
|
|
255
|
+
* own name; a script's computer op with `args` by the tool it is held to (heldAs); a name nothing maps, as it came. */
|
|
256
|
+
askedAs(name: string, args?: unknown): string;
|
|
257
|
+
private computerGate?;
|
|
258
|
+
/** This gate as on a computer: where a script's computer op runs (heldAs), whatever the run's own shell is. */
|
|
259
|
+
private onComputer;
|
|
257
260
|
/** Where the permission `policy` gives `tool` was set: the agent's own tool settings, the server's, or the default; or
|
|
258
261
|
* "unattended", an ask the agent's approvals allowed. */
|
|
259
262
|
readonly denyFrom: (tool: string) => SettingFrom;
|
|
260
|
-
/** 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
|
|
261
|
-
* desktop or a phone (which is held to the kind's keys). */
|
|
262
|
-
private hostMeta;
|
|
263
263
|
private setting;
|
|
264
264
|
/** `tool`'s permission under its settings key `key`, and where it was set. */
|
|
265
265
|
private settingOf;
|
package/dist/tool-gate.js
CHANGED
|
@@ -24,59 +24,37 @@
|
|
|
24
24
|
// wins; the same answer again is 204, a conflicting one 409. Only the owner's password session answers (server.ts), never
|
|
25
25
|
// a token. A cancel marks pending approvals canceled. Where no one can approve (accounts off), an ask is refused at once
|
|
26
26
|
// in words, never parked.
|
|
27
|
-
import {
|
|
28
|
-
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";
|
|
29
28
|
import { READ_SKILL_FILE } from "@parcha/agentrun-kernel";
|
|
30
29
|
import { LEARNED_DIR } from "./learning.js";
|
|
31
30
|
import { COMPUTER_ROOT, portPath } from "./workspace/paths.js";
|
|
32
31
|
import { builtinHarness } from "./harness-table.js";
|
|
33
32
|
import { META_TOOLS } from "./meta-tool-names.js";
|
|
34
33
|
import { DEFAULT_HARNESS } from "./harness.js";
|
|
35
|
-
import { SHELL_TOOLS } from "./background.js";
|
|
36
34
|
import { DECISION_PROVIDER_KEYS, KIND_KEYS, SERVE_OWN_TOOLS } from "./tool-plane.js";
|
|
37
|
-
import { isToolRow, tableTools } from "./tool-list.js";
|
|
38
|
-
import { deniedText, NOT_RUN, RAN_UNKNOWN } from "./refusal-words.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";
|
|
39
37
|
import { approvalsOf } from "./approvals.js";
|
|
38
|
+
import { settingOfDefinition } from "./computer-setting.js";
|
|
40
39
|
import { BASH_POLICIES, readOnlyReason, readOnlyText } from "./bash-read-only.js";
|
|
41
|
-
import { formatToolName, isCatalogName, mcpNameOf,
|
|
40
|
+
import { formatToolName, isCatalogName, mcpNameOf, mcpToolName, monidNameOf } from "./tool-names.js";
|
|
42
41
|
/** What the gate does with a tool's calls. */
|
|
43
42
|
export const PERMISSIONS = ["allow", "ask", "deny"];
|
|
44
43
|
// An MCP tool's gate name is its catalog name, `mcp:<server>/<tool>` (tool-names.ts).
|
|
45
44
|
export { mcpToolName };
|
|
46
|
-
/** The MCP servers a revision grants tools of, by their catalog names (`mcp:<server>/<tool>`, a server's wildcard too), each
|
|
47
|
-
* once: what a harness that names a session's MCP tool its own way (its facts' toolAlias: OpenCode's `<server>_<tool>`) is
|
|
48
|
-
* matched against, so its call is held to that tool's settings and never to a table tool's of the same shape. */
|
|
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
45
|
const isBuiltin = (name) => isToolRow(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || DECISION_PROVIDER_KEYS.includes(name);
|
|
55
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
|
|
56
47
|
* decision provider's) allows; anything else asks, so a new source never defaults to allow. On a run with no computer,
|
|
57
48
|
* the kernel's ruled rule (defaultPermissionOf): bash asks first, and the background tools, which need a computer, are
|
|
58
49
|
* refused. */
|
|
59
50
|
export const defaultPermission = (name, where = {}) => {
|
|
60
|
-
if (
|
|
51
|
+
if (isCatalogName(name) || !isBuiltin(name) || asksByDefault(name))
|
|
61
52
|
return "ask";
|
|
62
53
|
return where.computer === false ? defaultPermissionOf(name, { computer: false }) : "allow";
|
|
63
54
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
export const SHELL_FAMILY = Object.freeze(Object.fromEntries(SHELL_TOOLS.map((name) => [name, "bash"])));
|
|
68
|
-
/** The shell tool a call named `name` is, under claude-agent's host-tool name too (`mcp__hands__bash_background`), when
|
|
69
|
-
* it is one held to another's setting: its own name, which its request, its refusal and its approved call keep. */
|
|
70
|
-
export const shellToolOf = (name) => {
|
|
71
|
-
const own = name.replace(/^mcp__hands__/, "");
|
|
72
|
-
return Object.hasOwn(SHELL_FAMILY, own) && SHELL_FAMILY[own] !== own ? own : undefined;
|
|
73
|
-
};
|
|
74
|
-
/** The shell tools that only watch or end a process the run already started, by its own id (background.ts: an id is
|
|
75
|
-
* digits under the run's own work/background/, and another's is "no background process"): under bash: ask they run
|
|
76
|
-
* unasked, so watching an approved process costs no approval per page. bash: deny still refuses them. */
|
|
77
|
-
export const SHELL_WATCHERS = new Set(["bash_output", "bash_list", "bash_signal"]);
|
|
78
|
-
/** Shell tool `name`'s permission, given bash's: a watcher's ask is allow; any other keeps bash's. */
|
|
79
|
-
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 };
|
|
80
58
|
/** The settings keys that may set `name`'s permission, most specific first: the tool's own name, then, for an MCP
|
|
81
59
|
* tool, its server's wildcard `mcp:<server>/*`, and for a monid endpoint, its provider's `monid:<provider>/*`. */
|
|
82
60
|
export function permissionKeys(name) {
|
|
@@ -95,29 +73,42 @@ const KIND_TOOLS = (() => {
|
|
|
95
73
|
const keys = new Map();
|
|
96
74
|
for (const def of [...computerToolDefs("desktop", []), ...computerToolDefs("phone", [])])
|
|
97
75
|
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") ?? []);
|
|
101
76
|
return keys;
|
|
102
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
|
+
}
|
|
103
98
|
const STRICTNESS = { allow: 0, ask: 1, deny: 2 };
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
*
|
|
108
|
-
|
|
109
|
-
* each also as claude-agent's `mcp__hands__<name>`. The first named wins. */
|
|
110
|
-
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) {
|
|
111
104
|
const facts = builtinHarness(harness)?.facts;
|
|
112
105
|
const names = new Map();
|
|
113
106
|
const name = (own, key) => void (names.has(own) || names.set(own, key));
|
|
114
107
|
for (const [own, key] of Object.entries(SHELL_FAMILY))
|
|
115
108
|
name(own, key);
|
|
116
|
-
|
|
117
|
-
for (const own of [...tableTools(), ...SERVE_OWN_TOOLS.filter((one) => one !== CODEMODE_TOOL_NAME), ...DECISION_PROVIDER_KEYS])
|
|
109
|
+
for (const own of [...tableTools(), ...SERVE_OWN_TOOLS, ...DECISION_PROVIDER_KEYS])
|
|
118
110
|
name(own, own);
|
|
119
|
-
|
|
120
|
-
name(READ_SKILL_FILE, alias && mcpServers.includes(alias[1]) ? mcpToolName(alias[1], alias[2]) : "read");
|
|
111
|
+
name(READ_SKILL_FILE, "read");
|
|
121
112
|
for (const [own, keys] of KIND_TOOLS)
|
|
122
113
|
name(own, keys[0]);
|
|
123
114
|
for (const [own, key] of Object.entries(facts?.nativeTools ?? {}))
|
|
@@ -125,25 +116,17 @@ export function nameMapOf(harness, mcpServers = []) {
|
|
|
125
116
|
name(own, key);
|
|
126
117
|
for (const own of BROWSER_REGISTRATIONS)
|
|
127
118
|
name(own, "browser");
|
|
128
|
-
for (const [own, key] of [...names])
|
|
129
|
-
name(`mcp__${HOST_TOOLS_SERVER}__${own}`, key);
|
|
130
119
|
return names;
|
|
131
120
|
}
|
|
132
121
|
/** The settings key a call named `name` on `harness` is held to: a lookup in the session's names (`names`), then the open
|
|
133
|
-
*
|
|
134
|
-
* and
|
|
135
|
-
*
|
|
136
|
-
export function settingsKeyOf(harness, name,
|
|
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)) {
|
|
137
126
|
const own = names.get(name);
|
|
138
127
|
if (own !== undefined)
|
|
139
128
|
return own;
|
|
140
|
-
|
|
141
|
-
return name;
|
|
142
|
-
const mcp = /^mcp__([a-z][a-z0-9-]*)__(.+)$/.exec(name);
|
|
143
|
-
if (mcp)
|
|
144
|
-
return mcp[1] === HOST_TOOLS_SERVER ? settingsKeyOf(harness, mcp[2], mcpServers, names) : mcpToolName(mcp[1], mcp[2]);
|
|
145
|
-
const alias = builtinHarness(harness)?.facts?.toolAlias?.exec(name) ?? null;
|
|
146
|
-
return alias && mcpServers.includes(alias[1]) ? mcpToolName(alias[1], alias[2]) : undefined;
|
|
129
|
+
return isCatalogName(name) ? name : undefined;
|
|
147
130
|
}
|
|
148
131
|
/** Whether a pin's value is a keys pin: the one form that is an object. */
|
|
149
132
|
export const isPinKeys = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -217,13 +200,13 @@ export function pinRefusal(name, args, server, agent = {}, ran = "no", declared)
|
|
|
217
200
|
return undefined;
|
|
218
201
|
const what = ran === "no" ? NOT_RUN : RAN_UNKNOWN;
|
|
219
202
|
if (server[name]?.brokenPin)
|
|
220
|
-
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: [] };
|
|
221
204
|
const own = agent[name]?.pin ?? {};
|
|
222
205
|
const theirs = server[name]?.pin ?? {};
|
|
223
206
|
// Both layers hold: an argument both pin takes what holds both (bothOf), and one where nothing does refuses every call.
|
|
224
207
|
const clash = Object.keys(own).filter((arg) => Object.hasOwn(theirs, arg) && bothOf(own[arg], theirs[arg]) === undefined);
|
|
225
208
|
if (clash.length)
|
|
226
|
-
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 };
|
|
227
210
|
const pin = { ...theirs, ...Object.fromEntries(Object.entries(own).map(([arg, value]) => [arg, Object.hasOwn(theirs, arg) ? bothOf(value, theirs[arg]) : value])) };
|
|
228
211
|
const given = typeof args === "object" && args !== null && !Array.isArray(args) ? args : {};
|
|
229
212
|
const undeclared = declared && Object.keys(pin).length ? Object.keys(given).filter((arg) => !declared.has(arg) && !Object.hasOwn(pin, arg)) : [];
|
|
@@ -262,9 +245,9 @@ export function toolEffect(annotations) {
|
|
|
262
245
|
* run's gate (ClaimMcp.effectOf) and a settings save's wake (settings-wake.ts) read, never a live listing. Undefined for a
|
|
263
246
|
* tool the pin does not hold. */
|
|
264
247
|
export function pinnedEffect(pin, name) {
|
|
265
|
-
const parsed =
|
|
266
|
-
const pinned = parsed && Object.hasOwn(pin, parsed
|
|
267
|
-
const tool = pinned?.tools.find((one) => one.name === parsed
|
|
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);
|
|
268
251
|
return tool ? toolEffect(tool.annotations) : undefined;
|
|
269
252
|
}
|
|
270
253
|
/** Whether "allow reads" lifts the ask of MCP tool `name`, one its run's pin marks read-only (permissionFrom's `effect`):
|
|
@@ -347,7 +330,7 @@ export const permissionOf = (name, server, agent = {}, approvals = "ask", effect
|
|
|
347
330
|
// refusal-words.ts, shared with the runner's loops.
|
|
348
331
|
export { deniedText, denyPlace, NOT_RUN, RAN_UNKNOWN, refusedText } from "./refusal-words.js";
|
|
349
332
|
/** The refusal of an ask where no one can approve it: a server with accounts off, whose answer route takes no token. */
|
|
350
|
-
export const noApproverText = (tool, ran = "no") =>
|
|
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}`;
|
|
351
334
|
/** The Timeline row of a call that waits for an approval. */
|
|
352
335
|
export const APPROVAL_ROW = "tool_approval_requested";
|
|
353
336
|
/** A call's arguments shown on its approval, at most this many bytes. */
|
|
@@ -374,10 +357,11 @@ export function previewOf(text) {
|
|
|
374
357
|
/** The gate of the run `runId` whose folder is `where`, on its pinned revision. `serverSettings`: the server's tool
|
|
375
358
|
* settings as the runner read them from the one store at the claim (tool-plane.ts loadToolSettings), read at each call as
|
|
376
359
|
* the gate reads them. `approvers`: whether anyone can answer an ask here, the store's (server-approvers.ts, read at each
|
|
377
|
-
* claim). The gate reads nothing of the run's own files: they are the agent's to write.
|
|
378
|
-
* 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. */
|
|
379
361
|
export function runGate(where, runId, revision, serverSettings, approvers) {
|
|
380
|
-
|
|
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));
|
|
381
365
|
}
|
|
382
366
|
/** A run's tool gate on the runner: its policy, asked before each call's intent (decide). */
|
|
383
367
|
export class RunGate {
|
|
@@ -412,15 +396,20 @@ export class RunGate {
|
|
|
412
396
|
* refusal says whether it took effect is not known, never that nothing was sent. */
|
|
413
397
|
async decide(name, args, options = {}) {
|
|
414
398
|
// 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
|
|
416
|
-
// reach the computer themselves, so it is held to the kind's setting (KIND_TOOLS).
|
|
417
|
-
const own = name.replace(/^mcp__hands__/, "");
|
|
399
|
+
// as its own tool, by its own name (a computer's tool by its kind's setting, KIND_TOOLS).
|
|
418
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
|
|
419
401
|
// refused here).
|
|
420
|
-
if (
|
|
402
|
+
if (META_TOOLS.has(name)) {
|
|
421
403
|
const setting = this.setting(name);
|
|
422
|
-
return setting.permission === "deny" ? { deny: deniedText(
|
|
404
|
+
return setting.permission === "deny" ? { deny: deniedText(name, name, setting.from, options.replayed ? "unknown" : "no") } : "allow";
|
|
423
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);
|
|
424
413
|
const key = this.keyOf(name) ?? name;
|
|
425
414
|
const tool = this.askedAs(name);
|
|
426
415
|
const ran = options.replayed ? "unknown" : "no";
|
|
@@ -437,33 +426,50 @@ export class RunGate {
|
|
|
437
426
|
return "allow";
|
|
438
427
|
return this.approvers ? "ask" : { deny: noApproverText(tool, ran) };
|
|
439
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. */
|
|
440
431
|
keyOf(name) {
|
|
432
|
+
const kinds = this.kindKeysOf(name);
|
|
433
|
+
if (kinds)
|
|
434
|
+
return this.kindSetting(name, kinds).key;
|
|
441
435
|
const harness = this.where.harness ?? DEFAULT_HARNESS;
|
|
442
|
-
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));
|
|
443
448
|
}
|
|
444
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
|
|
445
|
-
* own name; a name nothing maps, as it came. */
|
|
446
|
-
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);
|
|
447
455
|
return shellToolOf(name) ?? this.keyOf(name) ?? name;
|
|
448
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
|
+
}
|
|
449
462
|
/** Where the permission `policy` gives `tool` was set: the agent's own tool settings, the server's, or the default; or
|
|
450
463
|
* "unattended", an ask the agent's approvals allowed. */
|
|
451
464
|
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
|
-
}
|
|
457
465
|
setting(tool) {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
//
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
return shared.map((key) => this.settingOf(tool, key)).reduce((strictest, one) => (STRICTNESS[one.permission] > STRICTNESS[strictest.permission] ? one : strictest));
|
|
466
|
-
}
|
|
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);
|
|
467
473
|
return this.settingOf(tool, this.keyOf(tool));
|
|
468
474
|
}
|
|
469
475
|
/** `tool`'s permission under its settings key `key`, and where it was set. */
|
|
@@ -500,11 +506,11 @@ export class RunGate {
|
|
|
500
506
|
const policy = this.overrides.bash?.policy;
|
|
501
507
|
if (policy === undefined)
|
|
502
508
|
return undefined;
|
|
503
|
-
// Its own name for a background tool (bash_background
|
|
509
|
+
// Its own name for a background tool (bash_background);bash for bash and
|
|
504
510
|
// a CLI's own shell (codex's shell, claude-agent's Bash).
|
|
505
511
|
const tool = shellToolOf(name) ?? "bash";
|
|
506
512
|
if (!BASH_POLICIES.includes(policy))
|
|
507
|
-
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}`;
|
|
508
514
|
const reason = readOnlyReason(tool, args, [this.where.work, COMPUTER_ROOT]);
|
|
509
515
|
return reason === undefined ? undefined : readOnlyText(tool, reason, NOT_RUN);
|
|
510
516
|
}
|
package/dist/tool-list.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type ToolRow = {
|
|
|
4
4
|
readonly replay?: "safe" | "never";
|
|
5
5
|
readonly blurb?: string;
|
|
6
6
|
readonly host?: true;
|
|
7
|
+
readonly asks?: true;
|
|
7
8
|
};
|
|
8
9
|
export declare const TOOL_LIST: Readonly<Record<string, ToolRow>>;
|
|
9
10
|
/** Every tool of serve's table (tools.ts), by name: a test holds this and the table as one. */
|
|
@@ -20,7 +21,9 @@ export declare const isHostTool: (name: string) => boolean;
|
|
|
20
21
|
export declare const replayOf: (name: string) => "safe" | "never" | undefined;
|
|
21
22
|
/** The tools a host runs on a harness other than pi, by name. */
|
|
22
23
|
export declare const hostToolNames: () => string[];
|
|
23
|
-
/** Whether `name` is a
|
|
24
|
+
/** Whether `name` is a tool every harness binds as a host tool (web_fetch, web_search, the email tools). */
|
|
24
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;
|
|
25
28
|
/** `name`'s blurb, or none (an MCP server's tool, a name this server does not register). */
|
|
26
29
|
export declare const blurbOf: (name: string) => string | undefined;
|
package/dist/tool-list.js
CHANGED
|
@@ -6,6 +6,11 @@ export const TOOL_LIST = Object.freeze({
|
|
|
6
6
|
ask_person: { table: true, replay: "safe", blurb: "Ask you a question mid-run" },
|
|
7
7
|
web_fetch: { table: true, askable: true, replay: "safe", host: true, blurb: "Read a public web page" },
|
|
8
8
|
web_search: { table: true, askable: true, replay: "safe", host: true, blurb: "Search the web" },
|
|
9
|
+
email_search: { table: true, askable: true, replay: "safe", host: true, blurb: "Search the email account's mail" },
|
|
10
|
+
email_read: { table: true, askable: true, replay: "safe", host: true, blurb: "Read an email or its thread" },
|
|
11
|
+
email_draft: { table: true, askable: true, replay: "never", host: true, blurb: "Save an email draft" },
|
|
12
|
+
email_send: { table: true, askable: true, replay: "never", host: true, asks: true, blurb: "Send an email" },
|
|
13
|
+
email_file: { table: true, askable: true, replay: "never", host: true, blurb: "File an email under a folder or label" },
|
|
9
14
|
browser: { table: true, blurb: "Browse websites in a hosted browser" },
|
|
10
15
|
subagent: { table: true, blurb: "Run a task in a fresh helper conversation" },
|
|
11
16
|
pdf_pages: { table: true, blurb: "Turn a PDF's pages into images" },
|
|
@@ -37,7 +42,9 @@ export const isHostTool = (name) => rowOf(name)?.replay !== undefined;
|
|
|
37
42
|
export const replayOf = (name) => rowOf(name)?.replay;
|
|
38
43
|
/** The tools a host runs on a harness other than pi, by name. */
|
|
39
44
|
export const hostToolNames = () => namesWith("replay");
|
|
40
|
-
/** Whether `name` is a
|
|
45
|
+
/** Whether `name` is a tool every harness binds as a host tool (web_fetch, web_search, the email tools). */
|
|
41
46
|
export const isWebHostTool = (name) => rowOf(name)?.host === true;
|
|
47
|
+
/** Whether `name`'s default permission is ask (email_send). */
|
|
48
|
+
export const asksByDefault = (name) => rowOf(name)?.asks === true;
|
|
42
49
|
/** `name`'s blurb, or none (an MCP server's tool, a name this server does not register). */
|
|
43
50
|
export const blurbOf = (name) => rowOf(name)?.blurb;
|
package/dist/tool-names.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/** A wire name: at most 52 characters, not the adapter's 64. One CLI gives the model the name with a 12-character
|
|
2
|
+
* `mcp__hands__` prefix, and the model API's 64-character limit is on the name the model sees, so 52 is the budget that
|
|
3
|
+
* holds on every harness. The identity branch reads it: a plain 53-64 character name of valid characters must not skip
|
|
4
|
+
* the mapping and come out over budget. An MCP tool whose `mcp__<server>__<tool>` is past it (Composio's 58-character
|
|
5
|
+
* `mcp__slack__SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION`) is granted and called by its hashed name. */
|
|
6
|
+
export declare const WIRE_NAME: RegExp;
|
|
1
7
|
/** An MCP server's name. */
|
|
2
8
|
export declare const MCP_SERVER_NAME: RegExp;
|
|
3
9
|
/** An MCP tool's own name, as its server lists it. */
|
|
@@ -5,6 +11,8 @@ export declare const MCP_TOOL_NAME: RegExp;
|
|
|
5
11
|
/** A catalog tool's name, as a JSON Schema pattern (openapi.ts): `mcp:<server>/<tool>`, `monid:<provider>/<endpoint>`,
|
|
6
12
|
* or either's wildcard. */
|
|
7
13
|
export declare const CATALOG_KEY_PATTERN = "^(?:mcp:[a-z][a-z0-9-]{0,31}/(?:\\*|[A-Za-z0-9_-]{1,64})|monid:[a-z0-9][a-z0-9.-]{0,63}/(?:\\*|[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}))$";
|
|
14
|
+
/** One MCP tool's catalog key, without a server wildcard: the same server/tool grammar as mcpNameOf. */
|
|
15
|
+
export declare const MCP_TOOL_KEY_PATTERN = "^mcp:[a-z][a-z0-9-]{0,31}/[A-Za-z0-9_-]{1,64}$";
|
|
8
16
|
/** A catalog name, read: a plain tool's, one MCP tool's or one monid endpoint's, or a group's wildcard (an MCP server's
|
|
9
17
|
* tools, a monid provider's endpoints). */
|
|
10
18
|
export type ToolName = {
|
|
@@ -52,20 +60,17 @@ export declare function mcpNameOf(name: string): {
|
|
|
52
60
|
} | undefined;
|
|
53
61
|
/** The MCP server `name` names, one of its tools or its wildcard; undefined for any other name. */
|
|
54
62
|
export declare function mcpServerOf(name: string): string | undefined;
|
|
55
|
-
/** Whether `name` is an MCP server's wildcard, `mcp:<server>/*`. */
|
|
56
|
-
export declare const isMcpWildcard: (name: string) => boolean;
|
|
57
63
|
/** Why a grant of an MCP server's tool is refused by its name alone, said after the grant (`mcp:<server>/<tool> ...`): the
|
|
58
64
|
* one place the console's picker and the save's blockers (runnable.ts) both read it. `hands` is the harnesses' own tools'
|
|
59
65
|
* server. */
|
|
60
66
|
export declare const MCP_HANDS_WORDS = "names the MCP server hands, a name the harnesses keep for their own tools: save the server under another name.";
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export declare const monidDroppedWords: (tool: string, harness: string, dropped: string) => string;
|
|
67
|
+
/** MCP_HANDS_WORDS when the grant names the server `hands`; undefined otherwise. A name's length refuses nothing: one whose
|
|
68
|
+
* `mcp__<server>__<tool>` is past the budget every harness's names share is called by its hashed wire name (catalog.ts
|
|
69
|
+
* wireName), and read back by lookup. */
|
|
70
|
+
export declare const mcpGrantNameProblem: (server: string, _tool: string) => string | undefined;
|
|
71
|
+
/** Why two granted catalog tools can't both be granted: the harnesses call both by one wire name (`wire`, catalog.ts
|
|
72
|
+
* wireName), so neither could be told apart. Said after the later grant. */
|
|
73
|
+
export declare const sameWireWords: (tool: string, other: string, wire: string) => string;
|
|
74
|
+
/** Why `harness` drops or retypes the input of the catalog tool `tool` (its facts' schemaProblems, `dropped` the first,
|
|
75
|
+
* said under the tool's wire name): the words a save's blocker and a saved MCP server's read both say. */
|
|
76
|
+
export declare const droppedWords: (tool: string, harness: string, dropped: string) => string;
|