@parcha/agentrun-serve 0.1.0-beta.32 → 0.1.0-beta.34
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 +270 -0
- package/README.md +343 -246
- package/dist/adapters.d.ts +0 -7
- package/dist/adapters.js +11 -22
- package/dist/agent-rows.d.ts +98 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +60 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +14 -0
- package/dist/api-only.js +33 -0
- package/dist/archil-routes.d.ts +1 -1
- package/dist/bash-read-only.d.ts +22 -0
- package/dist/bash-read-only.js +701 -0
- package/dist/box-egress-vm.d.ts +0 -8
- package/dist/box-egress-vm.js +0 -10
- package/dist/box-egress.d.ts +0 -4
- package/dist/box-egress.js +1 -16
- package/dist/box-paths.d.ts +25 -2
- package/dist/box-paths.js +79 -11
- package/dist/box-relay.d.ts +0 -11
- package/dist/box-relay.js +0 -20
- package/dist/box-settings.d.ts +26 -0
- package/dist/box-settings.js +63 -0
- package/dist/boxes.d.ts +21 -1
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +94 -51
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -53
- package/dist/browser-person.js +94 -279
- package/dist/budget.d.ts +0 -4
- package/dist/budget.js +0 -7
- package/dist/cap.d.ts +8 -12
- package/dist/cap.js +12 -27
- package/dist/cli.js +61 -20
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.js +5 -2
- package/dist/computer-setting.d.ts +20 -4
- package/dist/computer-setting.js +25 -5
- package/dist/computers.d.ts +31 -3
- package/dist/computers.js +70 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-RPHGlXmM.js +540 -0
- package/dist/console/assets/index-opTN5Naq.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/daytona-api.d.ts +0 -11
- package/dist/daytona-api.js +1 -82
- package/dist/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/docker-host-addresses.d.ts +37 -0
- package/dist/docker-host-addresses.js +110 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +0 -2
- package/dist/errors.js +6 -9
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -11
- package/dist/files.js +2 -21
- package/dist/github-connection.d.ts +2 -2
- package/dist/github-connection.js +1 -1
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +4 -14
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +22 -5
- package/dist/harness-install.js +98 -20
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/harness.d.ts +4 -3
- package/dist/harness.js +16 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +62 -24
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +6 -2
- package/dist/learn/check.js +83 -29
- package/dist/learn/folder.d.ts +5 -1
- package/dist/learn/folder.js +10 -3
- package/dist/learn/grade.d.ts +14 -0
- package/dist/learn/grade.js +68 -12
- package/dist/learn/index.d.ts +4 -4
- package/dist/learn/index.js +4 -4
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +79 -4
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +8 -1
- package/dist/learn/secrets.js +95 -15
- package/dist/learn/skills.d.ts +112 -14
- package/dist/learn/skills.js +556 -52
- package/dist/learned-workflow.d.ts +37 -5
- package/dist/learned-workflow.js +106 -12
- package/dist/learning-routes.d.ts +16 -49
- package/dist/learning-routes.js +46 -36
- package/dist/learning-run.d.ts +6 -250
- package/dist/learning-run.js +11 -665
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +93 -77
- package/dist/learning.js +176 -304
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +13 -3
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +11 -52
- package/dist/mcp-gateway.js +44 -148
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +6 -6
- package/dist/mcp-servers-store.js +13 -15
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +6 -7
- package/dist/model.js +43 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +124 -50
- package/dist/page.d.ts +1 -3
- package/dist/page.js +9 -19
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +28 -62
- package/dist/pause.d.ts +0 -2
- package/dist/pause.js +1 -8
- package/dist/place.d.ts +0 -5
- package/dist/place.js +0 -10
- package/dist/print.d.ts +2 -1
- package/dist/print.js +4 -2
- package/dist/propose.js +83 -39
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -13
- package/dist/run-db.js +2 -41
- package/dist/run-launch.d.ts +19 -2
- package/dist/run-launch.js +13 -5
- package/dist/run-learning-served.d.ts +46 -2
- package/dist/run-learning-served.js +26 -7
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-reads-over-store.js +15 -6
- package/dist/run-secrets.d.ts +33 -0
- package/dist/run-secrets.js +53 -0
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +19 -5
- package/dist/run-view.d.ts +12 -17
- package/dist/run-view.js +29 -28
- package/dist/runnable.d.ts +18 -10
- package/dist/runnable.js +21 -10
- package/dist/runner/adapter-loop.d.ts +14 -3
- package/dist/runner/adapter-loop.js +464 -62
- package/dist/runner/adapter-run-spec.d.ts +29 -8
- package/dist/runner/adapter-run-spec.js +96 -37
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +15 -1
- package/dist/runner/adapters/pi.js +19 -5
- package/dist/runner/beside.d.ts +30 -3
- package/dist/runner/beside.js +54 -12
- package/dist/runner/claim-secrets.d.ts +10 -1
- package/dist/runner/claim-secrets.js +49 -15
- package/dist/runner/cli-run-spec.d.ts +2 -0
- package/dist/runner/cli-run-spec.js +60 -17
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.js +118 -8
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.js +1 -1
- package/dist/runner/harness-loops.d.ts +9 -1
- package/dist/runner/harness-loops.js +15 -2
- package/dist/runner/journal-kinds.d.ts +30 -6
- package/dist/runner/journal-kinds.js +20 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +113 -11
- package/dist/runner/learning-loop.d.ts +5 -0
- package/dist/runner/learning-loop.js +26 -6
- package/dist/runner/live-ticker.d.ts +1 -1
- package/dist/runner/live-ticker.js +28 -4
- package/dist/runner/loop-contract.d.ts +3 -2
- package/dist/runner/main.d.ts +64 -10
- package/dist/runner/main.js +165 -27
- package/dist/runner/mcp-claim.d.ts +1 -1
- package/dist/runner/mcp-claim.js +2 -3
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +15 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +33 -1
- package/dist/runner/metrics.js +85 -1
- package/dist/runner/model-route.d.ts +13 -0
- package/dist/runner/model-route.js +154 -11
- package/dist/runner/redact.d.ts +8 -2
- package/dist/runner/redact.js +11 -2
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +56 -10
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-loop.d.ts +6 -0
- package/dist/runner/workflow-loop.js +6 -4
- package/dist/runner/workflow-spec.d.ts +18 -0
- package/dist/runner/workflow-spec.js +68 -26
- package/dist/runs-over-store.d.ts +8 -3
- package/dist/runs-over-store.js +76 -19
- package/dist/seal-key.d.ts +54 -15
- package/dist/seal-key.js +232 -82
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/secrets.d.ts +2 -10
- package/dist/secrets.js +21 -17
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +1 -80
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +10 -32
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -33
- package/dist/server.d.ts +26 -44
- package/dist/server.js +229 -142
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.d.ts +8 -2
- package/dist/store/agent-body.js +16 -4
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +3 -3
- package/dist/store/open.d.ts +18 -5
- package/dist/store/open.js +23 -3
- package/dist/store/postgres/connection.d.ts +18 -2
- package/dist/store/postgres/connection.js +156 -32
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +27 -3
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +49 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +64 -20
- package/dist/store/store.d.ts +38 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +25 -6
- package/dist/store-reads/journal.js +173 -21
- package/dist/store-reads/learning.d.ts +26 -8
- package/dist/store-reads/learning.js +12 -4
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +5 -1
- package/dist/store-view.js +91 -23
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +24 -10
- package/dist/templates.js +69 -38
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +274 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-gate.d.ts +41 -216
- package/dist/tool-gate.js +79 -540
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +9 -104
- package/dist/tool-keys.js +15 -271
- package/dist/tool-plane.d.ts +14 -42
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +31 -19
- package/dist/tools.js +101 -108
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-schedule.js +2 -1
- package/dist/trigger-secrets-shown.js +5 -1
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.js +1 -1
- package/dist/usage.d.ts +0 -2
- package/dist/usage.js +0 -2
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +23 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +52 -5
- package/dist/workspace/computer-deps.js +154 -19
- package/dist/workspace/computer-for-claim.d.ts +19 -14
- package/dist/workspace/computer-for-claim.js +77 -16
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/computer-providers.d.ts +6 -2
- package/dist/workspace/computer-providers.js +1 -1
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/index.d.ts +4 -3
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/local.d.ts +11 -2
- package/dist/workspace/local.js +161 -43
- package/dist/workspace/resolve-computer.d.ts +50 -10
- package/dist/workspace/resolve-computer.js +46 -11
- package/dist/workspace/run-tools.d.ts +13 -31
- package/dist/workspace/run-tools.js +10 -27
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -17
- package/dist/workspace.js +3 -99
- package/launcher/agentrun-serve +6 -33
- package/package.json +14 -14
- package/templates/README.md +9 -3
- package/templates/inbound-lead/agent.md +1 -1
- package/templates/kyb/agent.md +1 -1
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/dist/app.d.ts +0 -5
- package/dist/app.js +0 -514
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/bounds.d.ts +0 -26
- package/dist/bounds.js +0 -137
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-35-7aeIZ.js +0 -519
- package/dist/console/assets/index-Cejbov-Y.css +0 -1
- package/dist/content-filter.d.ts +0 -7
- package/dist/content-filter.js +0 -23
- package/dist/disk.d.ts +0 -33
- package/dist/disk.js +0 -85
- package/dist/door-line.d.ts +0 -23
- package/dist/door-line.js +0 -83
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/harness-app.d.ts +0 -69
- package/dist/harness-app.js +0 -1162
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/request-start.d.ts +0 -27
- package/dist/request-start.js +0 -381
- package/dist/run-box.d.ts +0 -205
- package/dist/run-box.js +0 -661
- package/dist/run-holder.d.ts +0 -52
- package/dist/run-holder.js +0 -139
- package/dist/runs.d.ts +0 -1200
- package/dist/runs.js +0 -4103
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -178
- package/dist/served-only.d.ts +0 -5
- package/dist/served-only.js +0 -12
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type Obj = Record<string, unknown>;
|
|
2
|
+
export declare const obj: (value: unknown) => Obj | undefined;
|
|
3
|
+
export declare const str: (value: unknown) => string | undefined;
|
|
4
|
+
export declare const cut: (text: string, max: number) => string;
|
|
5
|
+
export declare const firstLine: (text: string) => string;
|
|
6
|
+
export declare const firstSentence: (text: string) => string;
|
|
7
|
+
export declare function utf8Bytes(text: string): number;
|
|
8
|
+
export declare function json(text: string): Obj | undefined;
|
|
9
|
+
/** `host/path` of a URL: no scheme, no credentials, no query, no fragment. */
|
|
10
|
+
export declare function where(url: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Every http(s) URL in `text` keeps its origin, its path and its query keys. Query values, the fragment and the
|
|
13
|
+
* userinfo are dropped, the rule pi-browser applies to the URLs a model sees.
|
|
14
|
+
*/
|
|
15
|
+
export declare function scrubUrls(text: string): string;
|
|
16
|
+
/** `a, b, +2 more`. */
|
|
17
|
+
export declare const list: (items: readonly string[]) => string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export const obj = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
|
|
2
|
+
export const str = (value) => (typeof value === "string" ? value : undefined);
|
|
3
|
+
export const cut = (text, max) => (text.length > max ? `${text.slice(0, max - 3)}...` : text);
|
|
4
|
+
export const firstLine = (text) => text.split("\n").map((line) => line.trim()).find(Boolean) ?? "";
|
|
5
|
+
export const firstSentence = (text) => {
|
|
6
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
7
|
+
return /^.*?[.!?](?=\s|$)/.exec(flat)?.[0] ?? flat;
|
|
8
|
+
};
|
|
9
|
+
export function utf8Bytes(text) {
|
|
10
|
+
let bytes = 0;
|
|
11
|
+
for (const char of text) {
|
|
12
|
+
const code = char.codePointAt(0);
|
|
13
|
+
bytes += code < 0x80 ? 1 : code < 0x800 ? 2 : code < 0x10000 ? 3 : 4;
|
|
14
|
+
}
|
|
15
|
+
return bytes;
|
|
16
|
+
}
|
|
17
|
+
export function json(text) {
|
|
18
|
+
try {
|
|
19
|
+
return obj(JSON.parse(text));
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const URL_SHAPE = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;
|
|
26
|
+
/** `host/path` of a URL: no scheme, no credentials, no query, no fragment. */
|
|
27
|
+
export function where(url) {
|
|
28
|
+
const parts = URL_SHAPE.exec(url.trim());
|
|
29
|
+
return cut(parts ? `${parts[1]}${parts[2] === "/" ? "" : parts[2]}` : (url.split(/[?#]/)[0] ?? ""), 80);
|
|
30
|
+
}
|
|
31
|
+
const ELIDED = "\u2026";
|
|
32
|
+
const TEXT_URL = /https?:\/\/[^\s"'`<>\\]+/gi;
|
|
33
|
+
const URL_PARTS = /^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i;
|
|
34
|
+
/**
|
|
35
|
+
* Every http(s) URL in `text` keeps its origin, its path and its query keys. Query values, the fragment and the
|
|
36
|
+
* userinfo are dropped, the rule pi-browser applies to the URLs a model sees.
|
|
37
|
+
*/
|
|
38
|
+
export function scrubUrls(text) {
|
|
39
|
+
return text.replace(TEXT_URL, (raw) => {
|
|
40
|
+
const tail = /[.,;:!?)\]}]+$/.exec(raw)?.[0] ?? "";
|
|
41
|
+
const parts = URL_PARTS.exec(raw.slice(0, raw.length - tail.length));
|
|
42
|
+
if (!parts)
|
|
43
|
+
return raw;
|
|
44
|
+
const keys = [...new Set((parts[4] ?? "").split("&").map((pair) => pair.split("=")[0]).filter(Boolean))];
|
|
45
|
+
return `${parts[1]}${parts[2]}${parts[3]}${keys.length ? `?${keys.map((key) => `${key}=${ELIDED}`).join("&")}` : ""}${tail}`;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** `a, b, +2 more`. */
|
|
49
|
+
export const list = (items) => items.length > 2 ? `${items.slice(0, 2).join(", ")}, +${items.length - 2} more` : items.join(", ");
|
package/dist/tool-gate.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
2
|
-
import { type Extension, type Harness, type ToolRegistration, type Tx } from "@earendil-works/pi-durable";
|
|
3
|
-
import { type DurableRun, type SyncTarget } from "@parcha/pi-durable-disk";
|
|
4
|
-
import type { TurnOrigin } from "./learning-run.js";
|
|
5
1
|
import type { Workspace } from "./workspace/workspace.js";
|
|
6
|
-
import {
|
|
2
|
+
import { type ToolSettingsRead } from "./tool-plane.js";
|
|
7
3
|
import { type SettingFrom } from "./refusal-words.js";
|
|
8
4
|
import { type Approvals } from "./approvals.js";
|
|
9
5
|
/** What the gate does with a tool's calls. */
|
|
@@ -15,8 +11,16 @@ export declare const mcpToolName: (server: string, tool: string) => string;
|
|
|
15
11
|
export declare const isMcpTool: (name: string) => boolean;
|
|
16
12
|
/** A third-party catalog tool, by its name: monid's (`monid.<tool>`) or an MCP server's (`mcp:<server>/<tool>`). */
|
|
17
13
|
export declare const isCatalogTool: (name: string) => boolean;
|
|
18
|
-
/**
|
|
19
|
-
|
|
14
|
+
/** Where a run's shell is, as its default permissions read it: `computer` false for a run with no computer (its bash, where
|
|
15
|
+
* 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
|
|
16
|
+
* settings page, capabilities), which reads the computer's defaults. */
|
|
17
|
+
export type ShellWhere = {
|
|
18
|
+
readonly computer?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** The owner's defaults (11-01): a built-in kernel tool allow; a third-party catalog tool ask. On a run with no computer,
|
|
21
|
+
* the kernel's ruled rule (defaultPermissionOf): bash asks first, and the background tools, which need a computer, are
|
|
22
|
+
* refused. */
|
|
23
|
+
export declare const defaultPermission: (name: string, where?: ShellWhere) => Permission;
|
|
20
24
|
/** The tools that run a command in the run's box (background.ts SHELL_TOOLS), each held to bash's setting: bash: deny
|
|
21
25
|
* refuses bash_background as it refuses bash, and none of them is a settings key of its own. Under bash: ask the
|
|
22
26
|
* watchers (SHELL_WATCHERS) run unasked. */
|
|
@@ -37,8 +41,8 @@ export declare function permissionKeys(name: string): string[];
|
|
|
37
41
|
* wire name) and a harness's own (its facts' toolAlias: OpenCode's `<server>_<tool>`), is `mcp:<server>/<tool>`; a catalog's wire name (`monid_run`) is its
|
|
38
42
|
* catalog name; the browser's registrations are `browser`; an adapter's read_skill_file is `read` (but an agent's MCP tool of that name is its own). OpenCode's `<server>_<tool>` maps only for a server of
|
|
39
43
|
* `mcpServers` (the run's configured MCP servers), never by its shape, since a host tool's name has the same shape.
|
|
40
|
-
* Undefined: nothing maps it, and the gate asks. The key only:
|
|
41
|
-
*
|
|
44
|
+
* Undefined: nothing maps it, and the gate asks. The key only: the runner's adapter loop asks the gate once per call,
|
|
45
|
+
* before its intent (RunGate.decide). */
|
|
42
46
|
export declare function settingsKeyOf(harness: string, name: string, mcpServers?: readonly string[]): string | undefined;
|
|
43
47
|
/** A pinned argument's scalar: `null` holds for a call that leaves the argument out (or gives null). */
|
|
44
48
|
export type PinScalar = string | number | boolean | null;
|
|
@@ -53,10 +57,11 @@ export declare const MAX_PIN_CHOICES = 16;
|
|
|
53
57
|
/** A layer of tool settings (the server's, PUT /v2/settings/tools, or an agent's own, definition.tool_settings) as the
|
|
54
58
|
* gate reads it: a permission by settings key, and an MCP tool's pin. */
|
|
55
59
|
export type PermissionSettings = Readonly<Record<string, {
|
|
56
|
-
permission?: Permission; /** Not as written: a value not offered, read as its fail-closed stand-in (tool-plane.ts
|
|
60
|
+
permission?: Permission; /** Not as written: a value not offered, read as its fail-closed stand-in (tool-plane.ts checkToolSettings). Never shown. */
|
|
57
61
|
fallback?: true;
|
|
58
|
-
pin?: Pin; /** A pin in the server's
|
|
59
|
-
brokenPin?: true;
|
|
62
|
+
pin?: Pin; /** A pin in the server's settings that does not read (tool-plane.ts checkToolSettings): every call of the tool is refused. Never shown. */
|
|
63
|
+
brokenPin?: true; /** bash's policy, in an agent's own settings only (bash-read-only.ts): what its commands may do. */
|
|
64
|
+
policy?: string;
|
|
60
65
|
} | undefined>>;
|
|
61
66
|
/** A one-of list in its one form: each value once, null first, then by its JSON text; any other value as it is. The
|
|
62
67
|
* same meaning is the same text (a revision's id) and the same words (a refusal). */
|
|
@@ -84,12 +89,12 @@ export declare function pinRefusal(name: string, args: unknown, server: Permissi
|
|
|
84
89
|
* layer, nor an ask that stands in for a setting that does not read. Nor is anything RunGate.enter refuses before it
|
|
85
90
|
* decides between running and parking ever lifted (a template's pin, among them). Without never, the answer is as it
|
|
86
91
|
* always was. */
|
|
87
|
-
export declare function permissionFrom(name: string, server: PermissionSettings, agent?: PermissionSettings, approvals?: Approvals): {
|
|
92
|
+
export declare function permissionFrom(name: string, server: PermissionSettings, agent?: PermissionSettings, approvals?: Approvals, where?: ShellWhere): {
|
|
88
93
|
permission: Permission;
|
|
89
94
|
from: SettingFrom;
|
|
90
95
|
};
|
|
91
|
-
/** Marks the server's settings map when its
|
|
92
|
-
* tool then takes its defaults, and
|
|
96
|
+
/** Marks the server's settings map when its stored value does not read (tool-plane.ts loadToolSettings): every
|
|
97
|
+
* tool then takes its defaults, and a deny it may hold can't be seen, so nothing lifts an ask over it. A symbol:
|
|
93
98
|
* carried by a spread, never by JSON (it is never served) nor by Object.entries (no reader takes it for a tool). */
|
|
94
99
|
export declare const SETTINGS_UNREAD: unique symbol;
|
|
95
100
|
/** `name`'s permission in force (permissionFrom): the one rule every path reads, the gate's, the tool plane's and a
|
|
@@ -115,80 +120,15 @@ export type PendingApproval = {
|
|
|
115
120
|
requested_at: string;
|
|
116
121
|
price?: ApprovalPrice;
|
|
117
122
|
};
|
|
118
|
-
/** The run's journal commit for the call, which makes the request durable before the gate answers, and who is told it
|
|
119
|
-
* parked, so its turn ends (harness-app.ts endsTurn): by the call's id, or, where the caller cannot name it, by its tool
|
|
120
|
-
* and its arguments' digest. */
|
|
121
|
-
export type Park = {
|
|
122
|
-
commit<T>(change: (tx: unknown) => Promise<T>): Promise<T>;
|
|
123
|
-
parked?(callId: string): void;
|
|
124
|
-
parkedBy?(match: {
|
|
125
|
-
tool: string;
|
|
126
|
-
argsDigest: string;
|
|
127
|
-
}): void; /** The message the turn running the call took (harness-app's), kept with its request. */
|
|
128
|
-
turn?(): string | undefined;
|
|
129
|
-
};
|
|
130
|
-
/** What a call's ask carries beyond the call. */
|
|
131
|
-
export type EnterOptions = {
|
|
132
|
-
/** What the approval card shows the call costs. */
|
|
133
|
-
price?: ApprovalPrice;
|
|
134
|
-
/** The call is a replay: a crash cut an earlier attempt that may have been sent (the kernel's attempt above 0). A
|
|
135
|
-
* refusal then never says nothing was sent or charged. */
|
|
136
|
-
replayed?: true;
|
|
137
|
-
};
|
|
138
|
-
/** enter's answer. `undefined`: run the call. Otherwise the answer the model reads instead: a refusal
|
|
139
|
-
* (`isError: true`), or the waiting text with `parked: true`, after which the caller ends the turn. */
|
|
140
|
-
export type Entered = undefined | (ToolAnswer & {
|
|
141
|
-
parked?: true;
|
|
142
|
-
});
|
|
143
|
-
/** Runs an APPROVED parked call of a tool family the gate does not own (the MCP gateway's), exactly once. It owns the
|
|
144
|
-
* call's deadline: the gate puts no wall-clock bound on it (only a stop or a cancel cuts it, through `signal`), so an
|
|
145
|
-
* executor bounds its own work and answers a timeout as an error result (`isError: true`), never by waiting on. */
|
|
146
|
-
export type Executor = (tool: string, args: unknown, callId: string, signal: AbortSignal) => Promise<ToolAnswer>;
|
|
147
|
-
/** The mark a tool registration carries when its calls are gated by whoever registered it (the MCP gateway, which marks
|
|
148
|
-
* its registrations only when it holds this run's gate and park, and enters the gate in each call): RunGate.extension
|
|
149
|
-
* does not wrap it again. A private symbol, never `Symbol.for`: a global-registry key could be recreated by any code
|
|
150
|
-
* with the string alone. Only code that imports this export can set it (mcp-gateway.ts does). */
|
|
151
|
-
export declare const GATED_BY_GATEWAY: unique symbol;
|
|
152
|
-
/** A registration that may carry GATED_BY_GATEWAY. */
|
|
153
|
-
export type GatewayMarked = ToolRegistration & {
|
|
154
|
-
[GATED_BY_GATEWAY]?: true;
|
|
155
|
-
};
|
|
156
|
-
/** The gate of one run, in the run's process. */
|
|
157
|
-
export interface Gate {
|
|
158
|
-
/** One model-initiated call at the gate: allow, deny, or ask, which parks (see the header). */
|
|
159
|
-
enter(tool: string, args: unknown, callId: string, park: Park, options?: EnterOptions): Promise<Entered>;
|
|
160
|
-
/** Registers how an approved parked call of tools named `prefix…` (e.g. "mcp:") runs; one per prefix and run. */
|
|
161
|
-
executor(prefix: string, run: Executor): void;
|
|
162
|
-
/** A call's result text as the model gets it: as it is, a host tool's result already cut by HOST_RESULT_MAX_CHARS. */
|
|
163
|
-
spill(callId: string, text: string): string;
|
|
164
|
-
}
|
|
165
123
|
export { type DenyFrom, deniedText, denyPlace, NOT_RUN, RAN_UNKNOWN, refusedText, type SettingFrom } from "./refusal-words.js";
|
|
166
124
|
/** The refusal of an ask where no one can approve it: a server with accounts off, whose answer route takes no token. */
|
|
167
125
|
export declare const noApproverText: (tool: string, ran?: "no" | "unknown") => string;
|
|
168
|
-
/** Set by the server in a run's environment when no one can approve here (accounts off): the gate refuses each ask. */
|
|
169
|
-
export declare const NO_APPROVER_ENV = "AGENTRUN_SERVE_NO_APPROVER";
|
|
170
126
|
/** A parked call's answer: the run pauses here. */
|
|
171
127
|
export declare const waitingText: (tool: string) => string;
|
|
172
128
|
/** The Timeline row of a call that waits for an approval. */
|
|
173
129
|
export declare const APPROVAL_ROW: "tool_approval_requested";
|
|
174
130
|
/** A call's arguments shown on its approval, at most this many bytes. */
|
|
175
131
|
export declare const ARGS_PREVIEW_BYTES = 2048;
|
|
176
|
-
/** A gate of `policy` (the run's permission of a tool now) with no run behind it: allow and deny are enforced and
|
|
177
|
-
* executors are kept; an ask throws, since nothing here can park a call (a run's is RunGate), and spill returns
|
|
178
|
-
* the text as it is. */
|
|
179
|
-
export declare function gateOf(policy: (tool: string) => Permission): Gate;
|
|
180
|
-
/** The file in a run's directory that names the origin of the turn it runs now: written by the server alone, as it sends
|
|
181
|
-
* the learning lane's reflect turn (runs.ts's toLiveDoor), and gone before a person's turn is sent (runs.ts's personsTurn).
|
|
182
|
-
* The gate refuses that turn's writes under work/.learning/ (NOTE_ONLY_TEXT). */
|
|
183
|
-
export declare const TURN_ORIGIN_FILE = "turn-origin.json";
|
|
184
|
-
/** The run's store's record of a call that waits for approval (`phase: "requested"`), and of its answer acted on
|
|
185
|
-
* (`phase: "resolved"`), on its root conversation. */
|
|
186
|
-
export declare const APPROVAL_ENTRY = "agentrun.tool_approval";
|
|
187
|
-
/** The run's store's record that the gate let a replay-safe pi call that can bill through (`{ callId }`), written before
|
|
188
|
-
* the tool runs. pi-durable reruns a cut replay-safe call with the same call id and no sign that it is a rerun: this mark
|
|
189
|
-
* is how the gate knows an earlier attempt may have been sent, so a deny of the rerun never says nothing was charged.
|
|
190
|
-
* Outside `agentrun.tool_`, the tool ledger's kinds (paid-calls.ts), which readers of a run's charges take by prefix. */
|
|
191
|
-
export declare const GATE_PASSED_ENTRY = "agentrun.gate_passed";
|
|
192
132
|
/** The refusal of the end-of-run turn's write or edit under work/.learning/: its notes are kept only from its answer's
|
|
193
133
|
* note blocks (learn/reflect.ts parseReflection), which the host merges in its own store; a file there is never kept. */
|
|
194
134
|
export declare const NOTE_ONLY_TEXT = "A note is kept only from your answer: write it in a ```note block, not to a file.";
|
|
@@ -208,19 +148,6 @@ export type ApprovalRequest = {
|
|
|
208
148
|
price?: ApprovalPrice; /** Parked on a replay: a crash cut an earlier attempt that may have been sent, so a refusal never says nothing was charged. Kept in the store, so a restart keeps it. */
|
|
209
149
|
replayed?: true;
|
|
210
150
|
};
|
|
211
|
-
/** Resumes the session with `content` as one message of its own (`approval-<id>`), writing `mark` with it or after it. */
|
|
212
|
-
export type Resume = (id: string, content: string, mark: (tx: Tx) => Promise<unknown>, origin?: ResumeOrigin) => Promise<void>;
|
|
213
|
-
/** Who wrote a resume, for the Timeline (pi-durable-agent's MessageOrigin): the server, carrying an answer, so it never
|
|
214
|
-
* shows as the person's message. A person's message that declined the call: `said`, their words, which the Timeline
|
|
215
|
-
* shows as theirs beside the server's row. */
|
|
216
|
-
export type ResumeOrigin = {
|
|
217
|
-
kind: "server";
|
|
218
|
-
reason: "approval";
|
|
219
|
-
} | {
|
|
220
|
-
kind: "server";
|
|
221
|
-
reason: "approval_declined";
|
|
222
|
-
said: string;
|
|
223
|
-
};
|
|
224
151
|
/** `text` cut to at most ARGS_PREVIEW_BYTES. What is shown of a call's arguments is the whole of them redacted first, then
|
|
225
152
|
* cut (runs.ts), so a cut never leaves the head of a key no redaction recognizes. */
|
|
226
153
|
export declare function previewOf(text: string): string;
|
|
@@ -235,15 +162,14 @@ export declare const RESUME_PREFIX = "[tool approval] ";
|
|
|
235
162
|
* writes it, and the Timeline strips exactly it from the row a person opens (runs.ts resumeShows). */
|
|
236
163
|
export declare function resumeHead(request: Pick<ApprovalRequest, "tool" | "call_id">, shown: string): string;
|
|
237
164
|
export declare function resumeText(request: Pick<ApprovalRequest, "tool" | "call_id">, shown: string, decision: "allow" | "deny", result: ToolAnswer): string;
|
|
238
|
-
/** The gate of the run `runId`
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* `approvers`: whether anyone can answer an ask here. The runner gives the store's (server-approvers.ts, read at each
|
|
243
|
-
* claim); absent, the old per-run process's environment says (NO_APPROVER_ENV, set for it by runs.ts). */
|
|
165
|
+
/** The gate of the run `runId` whose folder is `where`, on its pinned revision. `serverSettings`: the server's tool
|
|
166
|
+
* settings as the runner read them from the one store at the claim (tool-plane.ts loadToolSettings), read at each call as
|
|
167
|
+
* the gate reads them. `approvers`: whether anyone can answer an ask here, the store's (server-approvers.ts, read at each
|
|
168
|
+
* claim). The gate reads nothing of the run's own files: they are the agent's to write. */
|
|
244
169
|
export declare function runGate(where: {
|
|
245
170
|
root: string;
|
|
246
171
|
work: string;
|
|
172
|
+
computer?: boolean;
|
|
247
173
|
}, runId: string, revision: {
|
|
248
174
|
kind: string;
|
|
249
175
|
body: {
|
|
@@ -251,57 +177,35 @@ export declare function runGate(where: {
|
|
|
251
177
|
harness?: string;
|
|
252
178
|
approvals?: Approvals;
|
|
253
179
|
};
|
|
254
|
-
}, serverSettings
|
|
255
|
-
/**
|
|
256
|
-
*
|
|
180
|
+
}, serverSettings: () => ToolSettingsRead, approvers: boolean): RunGate;
|
|
181
|
+
/** A run's folder as its spec names it: the run's Workspace (Mode 2: its folder on the run's disk, never a folder of this
|
|
182
|
+
* machine), or the local folder's path. The gate checks paths against it and reads nothing in it. */
|
|
257
183
|
export type RunFiles = Pick<Workspace, "read"> | string;
|
|
258
|
-
/**
|
|
184
|
+
/** A run's tool gate on the runner: its policy, asked before each call's intent (decide). */
|
|
259
185
|
export declare class RunGate {
|
|
260
186
|
private readonly where;
|
|
187
|
+
private readonly readServerSettings;
|
|
261
188
|
private readonly overrides;
|
|
262
|
-
private readonly parks;
|
|
263
189
|
private readonly approvers;
|
|
264
190
|
private readonly approvals;
|
|
265
|
-
|
|
266
|
-
private readonly files;
|
|
267
|
-
private readonly requests;
|
|
268
|
-
/** The replay-safe pi calls the gate let through (GATE_PASSED_ENTRY), by call id: a rerun of one is a replay. */
|
|
269
|
-
private readonly passed;
|
|
270
|
-
private durable?;
|
|
271
|
-
/** The run's store, for the barrier before a call that is not replay-safe: from `prime` (before the resume) or `load`. */
|
|
272
|
-
private syncTarget?;
|
|
273
|
-
private context?;
|
|
274
|
-
private coding?;
|
|
275
|
-
/** The run's own tools beyond the table (its learned_workflow), on which an approved call of one runs. */
|
|
276
|
-
private extra;
|
|
277
|
-
private resume?;
|
|
278
|
-
/** Told just before an allowed call runs (harness-app's): the run is un-parked, so the call's own model requests (a
|
|
279
|
-
* learned workflow's node) go out; the harness is idle then, as the park ended its turn. */
|
|
280
|
-
private unpark?;
|
|
281
|
-
private drive?;
|
|
282
|
-
private timer?;
|
|
283
|
-
private settling;
|
|
284
|
-
private readonly stop;
|
|
285
|
-
/** `where.data`: the server's data directory, its tool settings beside the store; `overrides`: the pinned revision's
|
|
286
|
-
* own; `parks`: whether an asked call parks the run (an agentic run's), which a workflow's model node cannot;
|
|
191
|
+
/** `readServerSettings`: the server's tool settings, read at each call; `overrides`: the pinned revision's own;
|
|
287
192
|
* `approvers`: whether anyone can answer an ask here (the owner's password session: accounts on); `approvals`: the
|
|
288
|
-
* pinned revision's (definition.approvals): "never" runs the agent unattended, an ask allowed (permissionFrom)
|
|
289
|
-
* `files`: where the run's own files are read (RunFiles), the run's folder `where.root` when absent. */
|
|
193
|
+
* pinned revision's (definition.approvals): "never" runs the agent unattended, an ask allowed (permissionFrom). */
|
|
290
194
|
constructor(where: {
|
|
291
195
|
root: string;
|
|
292
196
|
work: string;
|
|
293
|
-
data: string;
|
|
294
197
|
runId: string;
|
|
295
198
|
harness?: string;
|
|
296
199
|
mcpServers?: readonly string[];
|
|
297
|
-
|
|
200
|
+
computer?: boolean;
|
|
201
|
+
}, readServerSettings: () => ToolSettingsRead, overrides?: PermissionSettings, approvers?: boolean, approvals?: Approvals);
|
|
298
202
|
/** A tool's permission now (permissionOf): the revision's own over the server's setting, read at each call, so a change
|
|
299
203
|
* reaches a live run at its next call; under approvals "never", an ask is an allow. */
|
|
300
204
|
readonly policy: (tool: string) => Permission;
|
|
301
205
|
/** The gate's answer for one call before its intent, for a loop that parks and answers asks itself (the runner's adapter
|
|
302
|
-
* loops, pi's and the CLI harnesses'): run it, ask a person, or refuse it with the words the model reads.
|
|
303
|
-
*
|
|
304
|
-
*
|
|
206
|
+
* loops, pi's and the CLI harnesses'): run it, ask a person, or refuse it with the words the model reads. The order:
|
|
207
|
+
* the deny (with where it was set, and that nothing was sent or charged), a pin, bash's policy (policyRefusal), then
|
|
208
|
+
* the allow, then the ask, so an allow that approvals "never" made is decided
|
|
305
209
|
* only after every refusal. Where no one can approve (accounts off: the store's approvers row a runner reads at each
|
|
306
210
|
* claim, server-approvers.ts), the ask is refused at once in words, never parked, as `enter` refuses it. */
|
|
307
211
|
decide(name: string, args: unknown): Promise<"allow" | "ask" | {
|
|
@@ -319,6 +223,10 @@ export declare class RunGate {
|
|
|
319
223
|
/** Why a pin refuses the call of `key` with `args` now (pinRefusal): the revision's own pins and the server's, read at
|
|
320
224
|
* each call as its permission is, so a pin set or changed reaches a live run at its next call. */
|
|
321
225
|
private pinned;
|
|
226
|
+
/** Why bash's policy refuses the call `name` (held to `key`) with `args` now, or undefined: the revision's own setting
|
|
227
|
+
* (an agent's tool_settings.bash.policy), so every shell tool under every harness's name for it is held to it. A policy
|
|
228
|
+
* this server does not know refuses every shell call (fail closed), as a pin that does not read does. */
|
|
229
|
+
private policyRefusal;
|
|
322
230
|
private lastGood?;
|
|
323
231
|
private readonly told;
|
|
324
232
|
/** The server's settings now: read at each call, so a change reaches a live run; settings that do not read keep the
|
|
@@ -326,87 +234,4 @@ export declare class RunGate {
|
|
|
326
234
|
* while the read fails, as a deny may be in what did not read (undefined: none read yet, every tool asks). Each problem
|
|
327
235
|
* is said once, by file and field, never a value. */
|
|
328
236
|
private serverSettings;
|
|
329
|
-
/** The origin of the turn running now: what the server's internal path wrote for it (TURN_ORIGIN_FILE in the run's
|
|
330
|
-
* folder, read through `files`: the run's Workspace or the local folder's path); none for a person's turn, or a file
|
|
331
|
-
* that is not there or does not read. */
|
|
332
|
-
turnOrigin(): Promise<TurnOrigin | undefined>;
|
|
333
|
-
/** The end-of-run turn's refusal of a write or edit under work/.learning/ (NOTE_ONLY_TEXT, the adapter loop's one text
|
|
334
|
-
* too), whatever the tool's permission: its notes are kept only from its answer. Undefined for any other call or turn,
|
|
335
|
-
* whose write there follows its permission, as anywhere. The first check of `enter` and `decide`. */
|
|
336
|
-
private learningRefusal;
|
|
337
|
-
/** One model-initiated call at the gate: undefined when it may run; else its answer, refused at once (deny) or parked
|
|
338
|
-
* (ask). One call waits at a time: another asked meanwhile is answered so, not run. */
|
|
339
|
-
enter(name: string, args: unknown, callId: string, park: Park, options?: EnterOptions): Promise<Entered>;
|
|
340
|
-
/** pi's `tools` behind the gate: wraps, by name, for the run's registry, which apply wherever it is selected (every
|
|
341
|
-
* agent selects it: the root by default, a workflow's model node by name, app.ts). */
|
|
342
|
-
extension(tools: readonly ToolRegistration[]): Extension;
|
|
343
|
-
private wrap;
|
|
344
|
-
/** Takes the open run, as the run's process opens (its app's onOpen), reading what its store holds of the gate unless
|
|
345
|
-
* `prime` read it before the resume. `coding`: the run's coding source (coding-tools.ts), on which an approved coding
|
|
346
|
-
* call runs, as the run's own would; `extra`, the run's own tools beyond the table (its learned_workflow), on which an
|
|
347
|
-
* approved call of one runs. */
|
|
348
|
-
load(durable: DurableRun, context: Context, coding?: readonly ToolRegistration[], extra?: readonly ToolRegistration[]): Promise<void>;
|
|
349
|
-
private primed;
|
|
350
|
-
/** Reads what the run's store holds of the gate (the calls that wait, the answers acted on, the calls it let through)
|
|
351
|
-
* before the run resumes: its app's beforeResume hook, ahead of harness.resume(), which dispatches the calls a crash
|
|
352
|
-
* cut. Read here, not in onOpen, which a recovered call races. A workflow's run calls only this; load reads nothing more. */
|
|
353
|
-
prime(harness: Pick<Harness, "conversation">, context: Context, syncTarget?: SyncTarget): Promise<void>;
|
|
354
|
-
/** Whether a call waits for its answer, or for its answer to be acted on: a harness keeps the turn it ended closed. */
|
|
355
|
-
waiting(): boolean;
|
|
356
|
-
/** Whether a call of the turn that took `message` was parked, answered or not: that turn ended at the park, though a
|
|
357
|
-
* process that went before the next open settled it leaves it open in its session. */
|
|
358
|
-
parkedIn(message: string | undefined): boolean;
|
|
359
|
-
/** Acts on the answers from now on, resuming the session through `resume`; by default pi's root conversation. */
|
|
360
|
-
start(resume?: Resume, unpark?: () => void): void;
|
|
361
|
-
private note;
|
|
362
|
-
/** Reads the run's serve.json for answers while a call waits. */
|
|
363
|
-
private watch;
|
|
364
|
-
/** pi's resume: an input to the root conversation under the request's own id, which pi takes once however often it
|
|
365
|
-
* is sent, then the mark. */
|
|
366
|
-
private readonly submit;
|
|
367
|
-
private settle;
|
|
368
|
-
/** The approved call in flight, and its own abort: a stop or a cancel of the run cuts it (cutIfWithdrawn). */
|
|
369
|
-
private inFlight?;
|
|
370
|
-
/** Cuts the approved call in flight when a stop or a cancel since withdrew its answer (runs.ts supersede). */
|
|
371
|
-
private cutIfWithdrawn;
|
|
372
|
-
/** A call withdrawn with its run: resolved in the run's store with nothing run and nothing resumed. */
|
|
373
|
-
private resolveSilently;
|
|
374
|
-
/** The run's own `approvals:` session, the journal every approved call runs through: opened once. */
|
|
375
|
-
private journal;
|
|
376
|
-
/** An approved call whose tool was set to deny (or pinned so that its arguments no longer hold) before the gate acted
|
|
377
|
-
* on the answer. A call whose outcome is in the
|
|
378
|
-
* journal RAN (a crash came between it and its resume): the model gets that outcome, as any allowed call's, and nothing
|
|
379
|
-
* runs again; a later deny can't un-run it. One with an intent and no outcome may have been sent: denied, with no claim
|
|
380
|
-
* either way. One the journal never saw is denied, not run and not charged. */
|
|
381
|
-
private ranOrDenied;
|
|
382
|
-
/** The approved call, run once by the kernel through the journal any host tool's call goes through, as an effect of
|
|
383
|
-
* the run's own `approvals:` session, on the run's coding source: its intent is durable before it runs, its outcome
|
|
384
|
-
* after; a replay-safe call a crash cut off runs again, any other is answered interrupted and never runs again. */
|
|
385
|
-
private run;
|
|
386
|
-
private readonly executors;
|
|
387
|
-
/** Registers how an approved call of tools named `prefix…` runs (the MCP gateway's, "mcp:"): one per prefix and run.
|
|
388
|
-
* The gate runs it exactly once on its journaled path, as it runs a kernel host tool, with no deadline of its own: the
|
|
389
|
-
* executor bounds the call (Executor). */
|
|
390
|
-
executor(prefix: string, run: Executor): void;
|
|
391
|
-
/** What runs an approved call: the executor its tool's prefix names, which may have effects anywhere, so a call a
|
|
392
|
-
* crash cut off is never run again; else the kernel's host tool of the name, as replay-safe as that tool is. Neither:
|
|
393
|
-
* refused, in words, and never run. */
|
|
394
|
-
private runnerOf;
|
|
395
237
|
}
|
|
396
|
-
/** A parked call: by its id, or, where the caller cannot name it (OpenCode's MCP calls carry none), by its tool, as the
|
|
397
|
-
* harness reports it, and its arguments' digest (argsDigest). */
|
|
398
|
-
export type ParkedCall = {
|
|
399
|
-
callId: string;
|
|
400
|
-
} | {
|
|
401
|
-
tool: string;
|
|
402
|
-
argsDigest: string;
|
|
403
|
-
};
|
|
404
|
-
/** The digest a park by tool and arguments is matched on: the sha256 of the arguments' canonical JSON, in hex. */
|
|
405
|
-
export declare const argsDigest: (args: unknown) => string;
|
|
406
|
-
/** Whether the tool result `result` ends the turn `parked` waits in (harness-app.ts asks it at each one): the parked
|
|
407
|
-
* call's own, by its id; or, for a park by tool and arguments, the next result of that tool with those arguments. */
|
|
408
|
-
export declare function endsTurn(parked: ParkedCall | undefined, result: {
|
|
409
|
-
callId: string;
|
|
410
|
-
tool: string;
|
|
411
|
-
args: unknown;
|
|
412
|
-
}): boolean;
|