@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
package/dist/tool-keys.js
CHANGED
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
// The keys a person saves for this server's tools, by name, through /v2/settings/tool-keys
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// it), so a value sealed under another key reads as that, told apart from a damaged one. Only this process opens a
|
|
7
|
-
// value, when it is asked for. One that does not open is never a crash and never a clear fallback: it reads as not
|
|
8
|
-
// set, to be entered again, and the log says why once, naming the file, never a value. The server reads a saved value by
|
|
9
|
-
// name as it reads a launcher's secret (secrets.ts' `secret`), the launcher's winning: a run gets it over its pipe (a
|
|
10
|
-
// decision key on its decision descriptor) at its launch, and capabilities and checks see it once it is saved. A key is
|
|
11
|
-
// checked against its provider before it is kept (key-check.ts): one the provider refuses is never kept, and the file
|
|
12
|
-
// keeps, beside the sealed values, whether each key was accepted or kept not checked, and why (never any of a value).
|
|
13
|
-
import { createHmac } from "node:crypto";
|
|
14
|
-
import { readFileSync } from "node:fs";
|
|
15
|
-
import { join } from "node:path";
|
|
16
|
-
import { seal, unseal } from "@parcha/pi-durable-agent";
|
|
17
|
-
import { decisionsOf } from "./decisions.js";
|
|
18
|
-
import { ApiError, invalid } from "./errors.js";
|
|
19
|
-
import { writeDurableSync } from "./files.js";
|
|
1
|
+
// The keys a person saves for this server's tools and models, by name, through /v2/settings/tool-keys: the rows each key
|
|
2
|
+
// is entered as and what it unlocks, the words a re-entry gives, and the seal key's name and reading. The values are kept
|
|
3
|
+
// sealed in the one store (tool-keys-store.ts), opened only by the server, never in the clear; a key is checked against
|
|
4
|
+
// its provider before it is kept (key-check.ts). The server reads a saved value by name as it reads a launcher's secret
|
|
5
|
+
// (secrets.ts' `secret`), the launcher's winning: a run gets it over its claim, never its environment.
|
|
20
6
|
import { HARNESSES } from "./harness.js";
|
|
21
|
-
import { checkKey } from "./key-check.js";
|
|
22
|
-
import { toolsView } from "./tools.js";
|
|
23
7
|
import { MODEL_KEYS } from "./model.js";
|
|
24
8
|
import { TOOL_KEY_ROWS } from "./key-words.js";
|
|
25
|
-
import { isObject, unknownFields } from "./validate.js";
|
|
26
9
|
import { registerSecretWrite, secretMeta, secretName } from "./secret-writes.js";
|
|
27
10
|
// Every value a person saves here is a secret (a tool's key, a model provider's key; BROWSERBASE_PROJECT_ID is kept the
|
|
28
11
|
// same way): saving one, replacing it or removing it takes the owner's session (secret-writes.ts), never the token.
|
|
29
12
|
registerSecretWrite("saveToolKey", () => true);
|
|
30
13
|
registerSecretWrite("deleteToolKey", () => true);
|
|
31
|
-
export const TOOL_KEYS_FILE = "tool-keys.json";
|
|
32
14
|
export const SEAL_KEY_ENV = "AGENTRUN_SEAL_KEY";
|
|
33
|
-
const FORMAT = "tool-keys/1";
|
|
34
|
-
const MAX_VALUE_BYTES = 1024;
|
|
35
|
-
const CONTROL = /[\u0000-\u001f\u007f-\u009f]/;
|
|
36
15
|
/** Each key a person may save, fixed here: its kind, the fields it is entered as (BROWSERBASE_PROJECT_ID is no secret,
|
|
37
16
|
* and is kept the same way), and what it may unlock: tools by name, and `decisions.<id>`, a workflow's decision
|
|
38
17
|
* provider. GET lists only those this server binds (unlockedBy), so a name here the server does not bind is never
|
|
@@ -45,7 +24,6 @@ export const TOOL_KEYS = [
|
|
|
45
24
|
// launcher's model keys reach every run. Its harnesses are pi and those that talk to the provider's API (MODEL_KEYS).
|
|
46
25
|
...MODEL_KEYS.map(({ id, label, field, harnesses }) => ({ id, kind: "model", label, fields: [field], unlocks: [], harnesses })),
|
|
47
26
|
];
|
|
48
|
-
const FIELDS = TOOL_KEYS.flatMap((row) => row.fields);
|
|
49
27
|
/** The fields of the `tool` rows: keys a tool or a decision provider reads, and no harness (the harnesses read their
|
|
50
28
|
* packages, their pins and their models' keys). A row of another kind (a model's) is outside them. */
|
|
51
29
|
export const TOOL_FIELDS = TOOL_KEYS.filter((row) => row.kind === "tool").flatMap((row) => row.fields);
|
|
@@ -60,28 +38,24 @@ export function unlockedBy(candidates, tools, providers) {
|
|
|
60
38
|
}
|
|
61
39
|
/** What a row unlocks here: a `tool` row's, its tools and providers as capabilities bind them (unlockedBy); any other
|
|
62
40
|
* kind's (a model's), no tool, on those that run on it (its `harnesses`, when it names them) that this server runs
|
|
63
|
-
* (`offers`, harness.ts' harnessOffers)
|
|
64
|
-
*
|
|
65
|
-
* harness not installed, off its pins or too big
|
|
41
|
+
* (`offers`, harness.ts' harnessOffers) on the row's key: one whose `keys` (the model keys that run it here, available
|
|
42
|
+
* now or once one is saved) include the row's (its first field). So OpenRouter's row names all three before any key
|
|
43
|
+
* is saved, and no row changes when another provider's key is saved; a harness not installed, off its pins or too big
|
|
44
|
+
* for this host is left out. */
|
|
66
45
|
export function rowUnlocks(row, tools, providers, offers) {
|
|
67
46
|
if (row.kind === "tool")
|
|
68
47
|
return unlockedBy(row.unlocks, tools, providers);
|
|
69
48
|
const key = row.fields?.[0];
|
|
70
|
-
|
|
49
|
+
// Where an offer knows which model keys run it (its `keys`), the row's key must be one of them, available now or not;
|
|
50
|
+
// else (no key runs it: pi on any, or one unavailable for another reason) whether it runs here now.
|
|
51
|
+
const runs = (harness) => offers.some((offer) => offer.id === harness && (offer.keys ? key !== undefined && offer.keys.includes(key) : offer.available));
|
|
71
52
|
return { unlocks: [], harnesses: HARNESSES.filter((harness) => (row.harnesses ?? HARNESSES).includes(harness) && runs(harness)) };
|
|
72
53
|
}
|
|
73
54
|
/** The key that unlocks the tool `name` (capabilities' `tools[].key`, so a page links "needs the X key" to it), if any. */
|
|
74
55
|
export const keyOf = (name) => TOOL_KEYS.find((row) => row.unlocks.includes(name))?.id;
|
|
75
|
-
/** Why a stored value does not open, in the order a re-entry names one:
|
|
76
|
-
*
|
|
77
|
-
export const UNREADABLE = ["
|
|
78
|
-
/** The check a key kept before this server checked keys reads as: none was made. */
|
|
79
|
-
const UNCHECKED = { state: "not_checked", reason: "Saved before this server checked keys; save it again to check it" };
|
|
80
|
-
/** A check as the file keeps it, else undefined. */
|
|
81
|
-
const keptCheck = (entry) => !isObject(entry) ? undefined
|
|
82
|
-
: entry.state === "accepted" && typeof entry.at === "string" ? { state: "accepted", at: entry.at }
|
|
83
|
-
: entry.state === "not_checked" && typeof entry.reason === "string" ? { state: "not_checked", reason: entry.reason, ...(typeof entry.at === "string" ? { at: entry.at } : {}) }
|
|
84
|
-
: undefined;
|
|
56
|
+
/** Why a stored value does not open, in the order a re-entry names one: sealed under another key than the server's, or
|
|
57
|
+
* its row damaged. */
|
|
58
|
+
export const UNREADABLE = ["seal_key_changed", "file_unreadable"];
|
|
85
59
|
/** A key row's secrets as every secret's view says them (secret-writes.ts SecretMeta): one per field, named
|
|
86
60
|
* "<kind>:<FIELD>" (tool:MONID_API_KEY, model:OPENROUTER_API_KEY); source env when the server is started with it, console
|
|
87
61
|
* when the owner saved it; `changedAt` the time that field's own value was saved (its own row in the store, its own entry
|
|
@@ -97,233 +71,3 @@ export function sealKeyOf(text) {
|
|
|
97
71
|
const trimmed = text?.trim() ?? "";
|
|
98
72
|
return /^[A-Za-z0-9+/_-]{43}=?$/.test(trimmed) ? Buffer.from(trimmed, "base64") : undefined;
|
|
99
73
|
}
|
|
100
|
-
const aad = (name) => `${FORMAT}|${name}`;
|
|
101
|
-
export class ToolKeys {
|
|
102
|
-
env;
|
|
103
|
-
say;
|
|
104
|
-
file;
|
|
105
|
-
key;
|
|
106
|
-
sealCheck;
|
|
107
|
-
said = "";
|
|
108
|
-
/** The checks of the keys the server was started with, by key id, each once it answered (checkServer). */
|
|
109
|
-
started = {};
|
|
110
|
-
/** `env` is what the server is started with (withSecrets' `"own"`, never a saved key, or each would read as the
|
|
111
|
-
* server's and could not be deleted): a field it sets is the server's, and wins. `say` takes a log line's fields. */
|
|
112
|
-
constructor(data, env, say) {
|
|
113
|
-
this.env = env;
|
|
114
|
-
this.say = say;
|
|
115
|
-
this.file = join(data, TOOL_KEYS_FILE);
|
|
116
|
-
this.key = sealKeyOf(env[SEAL_KEY_ENV]);
|
|
117
|
-
this.sealCheck = this.key && createHmac("sha256", this.key).update(`agentrun-serve ${FORMAT} key check`).digest("base64url");
|
|
118
|
-
if (env[SEAL_KEY_ENV] !== undefined && !this.key)
|
|
119
|
-
say({ condition: "seal_key_invalid", name: SEAL_KEY_ENV });
|
|
120
|
-
}
|
|
121
|
-
/** The file's entries, none with no file; "unreadable" when it does not read as this format. A file from before checks
|
|
122
|
-
* has none. */
|
|
123
|
-
kept() {
|
|
124
|
-
try {
|
|
125
|
-
const doc = JSON.parse(readFileSync(this.file, "utf8"));
|
|
126
|
-
if (!isObject(doc) || doc.v !== 1 || !isObject(doc.fields))
|
|
127
|
-
return "unreadable";
|
|
128
|
-
const checks = Object.entries(isObject(doc.checks) ? doc.checks : {}).flatMap(([id, entry]) => {
|
|
129
|
-
const check = keptCheck(entry);
|
|
130
|
-
return check ? [[id, check]] : [];
|
|
131
|
-
});
|
|
132
|
-
return { fields: { ...doc.fields }, checks: Object.fromEntries(checks) };
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
return error.code === "ENOENT" ? { fields: {}, checks: {} } : "unreadable";
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
open(name, entry) {
|
|
139
|
-
if (!this.key)
|
|
140
|
-
return { unreadable: "seal_key_missing" };
|
|
141
|
-
if (!isObject(entry) || typeof entry.sealed !== "string" || typeof entry.check !== "string")
|
|
142
|
-
return { unreadable: "file_unreadable" };
|
|
143
|
-
if (entry.check !== this.sealCheck)
|
|
144
|
-
return { unreadable: "seal_key_changed" };
|
|
145
|
-
try {
|
|
146
|
-
return { value: unseal(this.key, Buffer.from(entry.sealed, "base64"), aad(name)).toString("utf8") };
|
|
147
|
-
}
|
|
148
|
-
catch {
|
|
149
|
-
return { unreadable: "file_unreadable" };
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/** The stored value of the field `name`, opened now (secrets.ts reads a saved key by name through this); undefined
|
|
153
|
-
* with none, or one that does not open, which view() asks for again: never a clear fallback. */
|
|
154
|
-
value(name) {
|
|
155
|
-
if (!FIELDS.includes(name))
|
|
156
|
-
return undefined;
|
|
157
|
-
const kept = this.kept();
|
|
158
|
-
const opened = kept !== "unreadable" && kept.fields[name] !== undefined ? this.open(name, kept.fields[name]) : undefined;
|
|
159
|
-
return opened && "value" in opened ? opened.value : undefined;
|
|
160
|
-
}
|
|
161
|
-
/** Every stored value that opens, by field name. */
|
|
162
|
-
values() {
|
|
163
|
-
return Object.fromEntries(FIELDS.flatMap((name) => {
|
|
164
|
-
const value = this.value(name);
|
|
165
|
-
return value === undefined ? [] : [[name, value]];
|
|
166
|
-
}));
|
|
167
|
-
}
|
|
168
|
-
/** GET: each key's fields, whether set and where from (never a value), what it unlocks of what capabilities shows
|
|
169
|
-
* here (a model key: the harnesses `offers` says this server runs or would on the key), its check when its key (its first field) is
|
|
170
|
-
* stored here (null otherwise: the server's own is not checked here), and what to enter again, with why. */
|
|
171
|
-
view(offers = []) {
|
|
172
|
-
const kept = this.kept();
|
|
173
|
-
const again = [];
|
|
174
|
-
const tools = toolsView(this.env);
|
|
175
|
-
const providers = decisionsOf(this.env);
|
|
176
|
-
const keys = TOOL_KEYS.map((row) => {
|
|
177
|
-
const fields = row.fields.map((name) => {
|
|
178
|
-
if (this.env[name])
|
|
179
|
-
return { name, set: true, source: "server" };
|
|
180
|
-
const opened = kept !== "unreadable" && kept.fields[name] !== undefined ? this.open(name, kept.fields[name]) : undefined;
|
|
181
|
-
if (opened && "value" in opened)
|
|
182
|
-
return { name, set: true, source: "stored" };
|
|
183
|
-
if (opened)
|
|
184
|
-
again.push({ name, why: opened.unreadable });
|
|
185
|
-
return { name, set: false, source: null, ...(opened ? { stored_unreadable: true } : {}) };
|
|
186
|
-
});
|
|
187
|
-
const check = fields[0].source === "stored" && kept !== "unreadable" ? (kept.checks[row.id] ?? UNCHECKED) : fields[0].source === "server" ? (this.started[row.id] ?? null) : null;
|
|
188
|
-
const secrets = rowSecrets(row, fields, (name) => (kept !== "unreadable" && isObject(kept.fields[name]) && typeof kept.fields[name].changed_at === "string" ? kept.fields[name].changed_at : null));
|
|
189
|
-
return { id: row.id, kind: row.kind, label: row.label, ...rowUnlocks(row, tools, providers, offers), fields, secrets, check };
|
|
190
|
-
});
|
|
191
|
-
// A file that does not read as a whole names no field: which it held is unknown.
|
|
192
|
-
const reason = kept === "unreadable" ? "file_unreadable" : UNREADABLE.find((why) => again.some((field) => field.why === why));
|
|
193
|
-
const reenter = reason ? { reason, fields: again.map((field) => field.name) } : null;
|
|
194
|
-
const said = JSON.stringify(reenter);
|
|
195
|
-
if (reenter && said !== this.said)
|
|
196
|
-
this.say({ condition: reenter.reason, file: this.file, fields: reenter.fields.join(",") || "unknown" });
|
|
197
|
-
this.said = said;
|
|
198
|
-
return { keys, reenter };
|
|
199
|
-
}
|
|
200
|
-
/** Each tool key the server is started with (a `tool` row whose key, its first field, the server sets), checked against
|
|
201
|
-
* its provider once, as a saved one is (key-check.ts), through the fetch `fetchFor` gives for the row (null: not
|
|
202
|
-
* checked, its check stays null); all at once, none holding up another or the start. `answered` is called as each
|
|
203
|
-
* answers, unless `stop` (the server closing) came first. A fetch that cannot be made (a fake that does not load)
|
|
204
|
-
* reads as not checked, saying so; this never rejects. A model key is not checked here: a run on a refused one fails
|
|
205
|
-
* at its first request, saying so. */
|
|
206
|
-
async checkServer(fetchFor, stop, answered) {
|
|
207
|
-
await Promise.all(TOOL_KEYS.filter((row) => row.kind === "tool" && this.env[row.fields[0]]).map(async (row) => {
|
|
208
|
-
const name = row.fields[0];
|
|
209
|
-
let fetcher;
|
|
210
|
-
try {
|
|
211
|
-
fetcher = await fetchFor(row.id);
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
if (stop.aborted)
|
|
215
|
-
return;
|
|
216
|
-
const why = error?.code ?? error?.name ?? "an error";
|
|
217
|
-
this.started[row.id] = { state: "not_checked", reason: `${row.label}'s key could not be checked: its check did not start (${why})`, at: new Date().toISOString() };
|
|
218
|
-
answered();
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
if (!fetcher)
|
|
222
|
-
return;
|
|
223
|
-
const outcome = await checkKey(row, this.env[name], this.env, fetcher, undefined, stop, name).catch(() => undefined);
|
|
224
|
-
if (!outcome || stop.aborted)
|
|
225
|
-
return;
|
|
226
|
-
this.started[row.id] = outcome.state === "refused" ? { state: "refused", reason: `${outcome.message} when this server started: set the right one where AgentRun starts, then restart it`, at: new Date().toISOString() } : outcome;
|
|
227
|
-
answered();
|
|
228
|
-
}));
|
|
229
|
-
}
|
|
230
|
-
/** The variables of the keys the server was started with that their provider refused at the start, each with why
|
|
231
|
-
* (capabilities' tools that need one read unavailable: tools.ts toolsView). */
|
|
232
|
-
refused() {
|
|
233
|
-
return Object.fromEntries(TOOL_KEYS.flatMap((row) => {
|
|
234
|
-
const check = this.started[row.id];
|
|
235
|
-
return check?.state === "refused" ? [[row.fields[0], check.reason]] : [];
|
|
236
|
-
}));
|
|
237
|
-
}
|
|
238
|
-
/** A PUT's check, before save(): the key it sends (its row's first field; Browserbase's project id is no key) checked
|
|
239
|
-
* against its provider (key-check.ts), the fetch `fetchFor` gives for the row (undefined: none, so not checked), its
|
|
240
|
-
* wait cut by `stop`. The body is held to what save() takes first, so a save that would be refused sends nothing. A
|
|
241
|
-
* key the provider refuses is 422 in its words, and nothing is kept; undefined when the body sends no key: the row's
|
|
242
|
-
* check stays as it was. */
|
|
243
|
-
async check(id, body, fetchFor, stop) {
|
|
244
|
-
const { row, values } = this.admit(id, body);
|
|
245
|
-
const name = row.fields[0];
|
|
246
|
-
if (values[name] === undefined)
|
|
247
|
-
return undefined;
|
|
248
|
-
const outcome = await checkKey(row, values[name], this.env, await fetchFor(row.id), undefined, stop);
|
|
249
|
-
if (outcome.state === "refused")
|
|
250
|
-
throw invalid([{ field: `values.${name}`, reason: "refused_by_provider", message: outcome.message }]);
|
|
251
|
-
return outcome;
|
|
252
|
-
}
|
|
253
|
-
/** PUT: each of `body.values` sealed under the seal key, and `check` (check()'s) kept for the key when given; the key's
|
|
254
|
-
* other fields stay as they are. A key saved with no check (a caller other than the route) drops the one it had. */
|
|
255
|
-
save(id, body, check) {
|
|
256
|
-
const { row, values } = this.admit(id, body);
|
|
257
|
-
const kept = this.kept();
|
|
258
|
-
// A file that does not read is replaced: what it held opens nowhere.
|
|
259
|
-
const { fields, checks } = kept === "unreadable" ? { fields: {}, checks: {} } : kept;
|
|
260
|
-
// Each field keeps its own changed_at: saving one key never moves another's.
|
|
261
|
-
const at = new Date().toISOString();
|
|
262
|
-
for (const [name, value] of Object.entries(values))
|
|
263
|
-
fields[name] = { sealed: seal(this.key, Buffer.from(value, "utf8"), aad(name)).toString("base64"), check: this.sealCheck, changed_at: at };
|
|
264
|
-
if (values[row.fields[0]] !== undefined)
|
|
265
|
-
delete checks[row.id];
|
|
266
|
-
if (check)
|
|
267
|
-
checks[row.id] = check;
|
|
268
|
-
this.write(fields, checks);
|
|
269
|
-
}
|
|
270
|
-
/** What a PUT may save: the key's row and the body's values, or 422 (the body), 409 (a field the server's, or no seal
|
|
271
|
-
* key). No message holds a value, or any part of one. */
|
|
272
|
-
admit(id, body) {
|
|
273
|
-
const row = this.row(id);
|
|
274
|
-
const issues = unknownFields(body, ["values"]);
|
|
275
|
-
const values = isObject(body.values) ? body.values : {};
|
|
276
|
-
if (!Object.keys(values).length)
|
|
277
|
-
issues.push({ field: "values", reason: body.values === undefined ? "missing" : "wrong_type", message: `values holds one or more of ${row.fields.join(", ")}, by name` });
|
|
278
|
-
for (const [name, value] of Object.entries(values)) {
|
|
279
|
-
const field = `values.${name}`;
|
|
280
|
-
if (!row.fields.includes(name))
|
|
281
|
-
issues.push({ field, reason: "not_allowed", message: `The key ${row.id} has the fields ${row.fields.join(", ")}.` });
|
|
282
|
-
else if (typeof value !== "string" || value === "")
|
|
283
|
-
issues.push({ field, reason: "wrong_type", message: `${name} is text, not empty` });
|
|
284
|
-
else if (CONTROL.test(value))
|
|
285
|
-
issues.push({ field, reason: "invalid", message: `${name} holds a control character` });
|
|
286
|
-
else if (Buffer.byteLength(value) > MAX_VALUE_BYTES)
|
|
287
|
-
issues.push({ field, reason: "too_long", message: `${name} is at most ${MAX_VALUE_BYTES} bytes` });
|
|
288
|
-
}
|
|
289
|
-
if (issues.length)
|
|
290
|
-
throw invalid(issues);
|
|
291
|
-
this.notServers(Object.keys(values));
|
|
292
|
-
if (!this.key)
|
|
293
|
-
throw new ApiError("no_sealing_key", `This server was handed no seal key (${SEAL_KEY_ENV}), so it keeps no tool key: it never keeps one in the clear.`);
|
|
294
|
-
return { row, values };
|
|
295
|
-
}
|
|
296
|
-
/** DELETE: the key's stored fields gone, and its check. Refused only when the server sets every field of it: none is
|
|
297
|
-
* the page's. */
|
|
298
|
-
remove(id) {
|
|
299
|
-
const row = this.row(id);
|
|
300
|
-
if (row.fields.every((name) => this.env[name]))
|
|
301
|
-
this.notServers(row.fields);
|
|
302
|
-
const kept = this.kept();
|
|
303
|
-
if (kept !== "unreadable" && !row.fields.some((name) => name in kept.fields))
|
|
304
|
-
return;
|
|
305
|
-
const { fields, checks } = kept === "unreadable" ? { fields: {}, checks: {} } : kept;
|
|
306
|
-
for (const name of row.fields)
|
|
307
|
-
delete fields[name];
|
|
308
|
-
delete checks[row.id];
|
|
309
|
-
this.write(fields, checks);
|
|
310
|
-
}
|
|
311
|
-
row(id) {
|
|
312
|
-
const row = TOOL_KEYS.find((r) => r.id === id);
|
|
313
|
-
if (!row)
|
|
314
|
-
throw invalid([{ field: "key_id", reason: "not_an_option", message: `The tool keys are ${TOOL_KEYS.map((r) => r.id).join(", ")}.` }]);
|
|
315
|
-
return row;
|
|
316
|
-
}
|
|
317
|
-
/** 409 when this server's own environment (its launcher) sets one of `names`: that one wins, and is changed where the
|
|
318
|
-
* server is started. */
|
|
319
|
-
notServers(names) {
|
|
320
|
-
const held = names.filter((name) => this.env[name]);
|
|
321
|
-
if (held.length)
|
|
322
|
-
throw new ApiError("key_set_by_server", `This server is started with ${held.join(" and ")}: change it where the server is started.`, { details: { fields: held } });
|
|
323
|
-
}
|
|
324
|
-
write(fields, checks) {
|
|
325
|
-
// On disk, the file and then its directory, before the 204: a crash after it neither loses a saved key nor brings
|
|
326
|
-
// back a forgotten one.
|
|
327
|
-
writeDurableSync(this.file, `${JSON.stringify({ v: 1, fields, checks }, null, 2)}\n`);
|
|
328
|
-
}
|
|
329
|
-
}
|
package/dist/tool-plane.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { InputIssue } from "./errors.js";
|
|
|
2
2
|
import type { Settings } from "./store/index.js";
|
|
3
3
|
import { type HarnessId } from "./harness.js";
|
|
4
4
|
import { type Permission, type Pin } from "./tool-gate.js";
|
|
5
|
+
import { type BashPolicy } from "./bash-read-only.js";
|
|
5
6
|
/**
|
|
6
7
|
* The capabilities a pack or a revision may grant, by name: the tools the kernel gives a run, bound from serve's closed
|
|
7
8
|
* table (tools.ts) and named the same on every harness that runs them. `web_search` and `web_fetch` resolve to a
|
|
@@ -53,19 +54,13 @@ export declare const KIND_KEYS: readonly string[];
|
|
|
53
54
|
export type ToolSetting = {
|
|
54
55
|
provider?: string;
|
|
55
56
|
permission?: Permission;
|
|
56
|
-
pin?: Pin; /**
|
|
57
|
+
pin?: Pin; /** bash's policy, an agent's own only (bash-read-only.ts). */
|
|
58
|
+
policy?: BashPolicy; /** Read as a stand-in for a value not offered (checkToolSettings); never shown or written. */
|
|
57
59
|
fallback?: true; /** The stand-in's value as written in the file, which a save that keeps the stand-in writes back (ToolSettings.put). Never shown. */
|
|
58
60
|
raw?: unknown; /** A pin in the file that does not read (readToolSettings): the gate refuses every call of the tool, and a save keeps it (ToolSettings.put) until the owner sets a valid pin or removes the tool's setting. Served as `pin_broken: true`. */
|
|
59
61
|
brokenPin?: true; /** The broken pin as written in the file, which a save that keeps it writes back. Never shown. */
|
|
60
62
|
rawPin?: unknown;
|
|
61
63
|
};
|
|
62
|
-
/** Whether an agent's own settings (definition.tool_settings) keep a pin. Not yet: the agent store this server writes
|
|
63
|
-
* today keeps a setting's values as names only, and refuses a pin; the store of the rewrite (store/, module A) keeps it
|
|
64
|
-
* as given, and this is true from its cutover on. Until then a pin is set on the server (PUT /v2/settings/tools), which
|
|
65
|
-
* the gate holds every run to; the gate reads an agent's pin wherever a revision carries one. */
|
|
66
|
-
export declare const AGENT_LAYER_PINS: boolean;
|
|
67
|
-
/** Why an agent's own pin is refused while AGENT_LAYER_PINS is false. */
|
|
68
|
-
export declare const AGENT_PIN_LATER = "An agent's own pin is kept once this server's agent store takes it (the store cutover). Until then set the pin on this server, PUT /v2/settings/tools (Settings \u2192 Tools), which the tool gate holds every run to.";
|
|
69
64
|
/** The longest pinned string. */
|
|
70
65
|
export declare const MAX_PIN_TEXT = 1024;
|
|
71
66
|
/** The one check of a pin, every place that takes one calls it (the server's settings, an agent's, a template's mcp
|
|
@@ -215,7 +210,7 @@ export declare const handsParallel: (plane: Plane) => boolean;
|
|
|
215
210
|
* table, a catalog tool, an MCP server's wildcard) to `{provider?, permission?}`, a provider only for a capability that
|
|
216
211
|
* has a choice and one offered for it, a permission one offered for the tool. */
|
|
217
212
|
export declare function settingsIssues(value: unknown, at?: string, layer?: "server" | "agent"): InputIssue[];
|
|
218
|
-
/** `map` as a revision body keeps it: each tool's provider, permission and
|
|
213
|
+
/** `map` as a revision body keeps it: each tool's provider, permission, pin and policy as written (never a stand-in's internal
|
|
219
214
|
* marks), tools, fields and a pin's arguments sorted, and a tool with none of them gone. The one form, so two
|
|
220
215
|
* revisions whose settings say the same (a pin's arguments in another order) are the same text, and so one revision
|
|
221
216
|
* where its id is the body's digest (the store keeps the body as given: store/sqlite/store.ts). */
|
|
@@ -225,12 +220,9 @@ export declare const withDefaults: (map: ToolSettingsMap) => ToolSettingsMap & R
|
|
|
225
220
|
provider: string;
|
|
226
221
|
permission?: Permission;
|
|
227
222
|
}>;
|
|
228
|
-
/** The tool settings
|
|
229
|
-
*
|
|
230
|
-
|
|
231
|
-
* changed, naming the file and the field, never a value. `unreadable`: the file as a whole does not read (none, a
|
|
232
|
-
* missing file is every default). */
|
|
233
|
-
export declare function readToolSettings(dir: string): {
|
|
223
|
+
/** The server's tool settings as read (checkToolSettings, loadToolSettings): the map, a line for each problem, and whether
|
|
224
|
+
* the stored value as a whole does not read. */
|
|
225
|
+
export type ToolSettingsRead = {
|
|
234
226
|
settings: ToolSettingsMap;
|
|
235
227
|
problems: string[];
|
|
236
228
|
unreadable?: true;
|
|
@@ -246,18 +238,14 @@ export declare function checkToolSettings(read: unknown, where: string): {
|
|
|
246
238
|
};
|
|
247
239
|
/** The key the server's tool settings live under in the one store (store.settings). */
|
|
248
240
|
export declare const TOOL_SETTINGS_KEY = "tool-settings";
|
|
249
|
-
/** The server's tool settings read from the one store (store.settings), failing closed
|
|
250
|
-
*
|
|
241
|
+
/** The server's tool settings read from the one store (store.settings), failing closed (checkToolSettings): no row is
|
|
242
|
+
* every default. */
|
|
251
243
|
export declare function loadToolSettings(store: {
|
|
252
244
|
settings: Pick<Settings, "get">;
|
|
253
|
-
}): Promise<
|
|
254
|
-
settings: ToolSettingsMap;
|
|
255
|
-
problems: string[];
|
|
256
|
-
unreadable?: true;
|
|
257
|
-
}>;
|
|
245
|
+
}): Promise<ToolSettingsRead>;
|
|
258
246
|
/** A save of the server's tool settings: `map` (a tool it leaves out takes its defaults) over the settings read before it
|
|
259
247
|
* (`current`), as kept (the marks within) and as written (the raw values, which a read turns back into those marks).
|
|
260
|
-
* The
|
|
248
|
+
* The rule saveToolSettings keeps:
|
|
261
249
|
* - a pin is kept as given, as a pin is a gate fence (tool-gate.ts pinRefusal);
|
|
262
250
|
* - a broken pin (one that did not read) is kept by every save that keeps the tool's key and sets no pin of its own (a
|
|
263
251
|
* console's whole map sends the key back, marked pin_broken): only a valid pin, or the key left out, clears it, so an
|
|
@@ -269,28 +257,12 @@ export declare function keptSettings(map: ToolSettingsMap, current: ToolSettings
|
|
|
269
257
|
kept: ToolSettingsMap;
|
|
270
258
|
written: Record<string, Record<string, unknown>>;
|
|
271
259
|
};
|
|
272
|
-
/** Replaces the server's tool settings in the one store,
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* within). The store-backed replacement for ToolSettings.put; the cut wires it. */
|
|
260
|
+
/** Replaces the server's tool settings in the one store, by keptSettings's rule: a tool `map` leaves out takes its
|
|
261
|
+
* defaults, a pin is kept, a broken pin is kept until a valid one or the key left out clears it, and a stand-in sent
|
|
262
|
+
* back unchanged stays a stand-in. Answers the settings as served (the marks within). */
|
|
276
263
|
export declare function saveToolSettings(store: {
|
|
277
264
|
settings: Pick<Settings, "get" | "put">;
|
|
278
265
|
}, map: ToolSettingsMap): Promise<ToolSettingsMap>;
|
|
279
|
-
export declare class ToolSettings {
|
|
280
|
-
private readonly dir;
|
|
281
|
-
static readonly FILE = "tool-settings.json";
|
|
282
|
-
private current;
|
|
283
|
-
/** The file was present but did not read at the start: every tool takes its defaults until a PUT replaces it. */
|
|
284
|
-
private unread;
|
|
285
|
-
constructor(dir: string, warn?: (line: string) => void);
|
|
286
|
-
/** The settings now. While the file does not read, the map carries SETTINGS_UNREAD (tool-gate.ts), so wherever it goes
|
|
287
|
-
* (the gate's permission, the plane's providers, an agent's tools, a save's blockers) approvals "never" lifts no ask
|
|
288
|
-
* over a deny the file may hold, as the gate itself fails closed. */
|
|
289
|
-
get(): ToolSettingsMap;
|
|
290
|
-
/** Replaces the settings: a tool `map` leaves out takes its defaults; pins, broken pins and stand-ins by the one rule
|
|
291
|
-
* the store's save keeps too (keptSettings). Durable before it returns. */
|
|
292
|
-
put(map: ToolSettingsMap): ToolSettingsMap;
|
|
293
|
-
}
|
|
294
266
|
/** GET /v2/agents/{id}'s `tools`: each tool its current revision grants, in `order` (capabilities.tools'), with its
|
|
295
267
|
* permission in force and where it came from (the agent's own settings, the server's, or the default), the one that
|
|
296
268
|
* applies when the agent sets none (the server's, else the default) and those it may be set to; and for one with a
|
package/dist/tool-plane.js
CHANGED
|
@@ -20,18 +20,15 @@
|
|
|
20
20
|
// told a deny: its Plane resolves a denied capability as under ask, and the gate, which reads the permission at each
|
|
21
21
|
// call, is the one place that refuses it, so a deny lifted mid-run is lifted at the next call.
|
|
22
22
|
import { blurbOf } from "./tool-blurbs.js";
|
|
23
|
-
import { readFileSync } from "node:fs";
|
|
24
|
-
import { isToolSettingsKey } from "@parcha/pi-durable-agent";
|
|
25
|
-
import { join } from "node:path";
|
|
26
23
|
import { decisionKeysOf, PARALLEL_KEY_ENV } from "./decisions.js";
|
|
27
24
|
import { keyNeeded } from "./key-words.js";
|
|
28
|
-
import { writeDurableSync } from "./server-fs.js";
|
|
29
25
|
import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
|
|
30
26
|
import { builtinHarness, harnessOf } from "./harness-table.js";
|
|
31
27
|
import { viaOpenRouter, WIRES } from "./provider.js";
|
|
32
28
|
import { savedIn } from "./secrets.js";
|
|
33
29
|
import { hostModel } from "./model.js";
|
|
34
30
|
import { canonicalPin, defaultPermission, isCatalogTool, isMcpTool, MAX_PIN_ARGS, MAX_PIN_CHOICES, PERMISSIONS, permissionFrom, permissionOf, SETTINGS_UNREAD, SHELL_FAMILY } from "./tool-gate.js";
|
|
31
|
+
import { BASH_POLICIES } from "./bash-read-only.js";
|
|
35
32
|
/**
|
|
36
33
|
* The capabilities a pack or a revision may grant, by name: the tools the kernel gives a run, bound from serve's closed
|
|
37
34
|
* table (tools.ts) and named the same on every harness that runs them. `web_search` and `web_fetch` resolve to a
|
|
@@ -71,14 +68,11 @@ export const KIND_KEYS = ["desktop", "phone"];
|
|
|
71
68
|
/** A settings key: a tool of the table, one of the run's own tools (SERVE_OWN_TOOLS), a computer kind's (KIND_KEYS), a
|
|
72
69
|
* catalog tool (`monid.<tool>`, `mcp:<server>/<tool>`), or an MCP server's wildcard (`mcp:<server>/*`), which sets each
|
|
73
70
|
* of its tools. */
|
|
71
|
+
/** A tool's name in an agent's or the server's tool settings: a plain name, a catalog's tool (`monid.discover`), an MCP
|
|
72
|
+
* server's tool (`mcp:<server>/<tool>`) or its wildcard (`mcp:<server>/*`). */
|
|
73
|
+
const TOOL_KEY = /^(?:[a-z][a-z0-9_-]{0,63}(?:\.[A-Za-z0-9_-]{1,64})?|mcp:[A-Za-z0-9_.-]{1,64}\/(?:\*|[A-Za-z0-9_.-]{1,128}))$/;
|
|
74
|
+
const isToolSettingsKey = (name) => TOOL_KEY.test(name);
|
|
74
75
|
const isSettingsKey = (name) => isToolSettingsKey(name) && (TABLE_TOOLS.includes(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || isCatalogTool(name) || /^mcp:[^/]+\/\*$/.test(name));
|
|
75
|
-
/** Whether an agent's own settings (definition.tool_settings) keep a pin. Not yet: the agent store this server writes
|
|
76
|
-
* today keeps a setting's values as names only, and refuses a pin; the store of the rewrite (store/, module A) keeps it
|
|
77
|
-
* as given, and this is true from its cutover on. Until then a pin is set on the server (PUT /v2/settings/tools), which
|
|
78
|
-
* the gate holds every run to; the gate reads an agent's pin wherever a revision carries one. */
|
|
79
|
-
export const AGENT_LAYER_PINS = true;
|
|
80
|
-
/** Why an agent's own pin is refused while AGENT_LAYER_PINS is false. */
|
|
81
|
-
export const AGENT_PIN_LATER = "An agent's own pin is kept once this server's agent store takes it (the store cutover). Until then set the pin on this server, PUT /v2/settings/tools (Settings → Tools), which the tool gate holds every run to.";
|
|
82
76
|
/** The longest pinned string. */
|
|
83
77
|
export const MAX_PIN_TEXT = 1024;
|
|
84
78
|
/** A pinned argument's name: a top-level argument of the tool, as MCP tools name theirs. */
|
|
@@ -357,10 +351,16 @@ export function settingsIssues(value, at = "", layer = "server") {
|
|
|
357
351
|
if (!isSettingsKey(name))
|
|
358
352
|
return [{ field: field(name), reason: "not_allowed", message: `Tool settings are kept for this server's tools (${[...TABLE_TOOLS, ...SERVE_OWN_TOOLS, ...KIND_KEYS].join(", ")}), catalog tools (monid.<tool>, mcp:<server>/<tool>) and an MCP server's tools (mcp:<server>/*); ${name} is none of them.` }];
|
|
359
353
|
if (!isPlain(setting))
|
|
360
|
-
return [{ field: field(name), reason: "wrong_type", message: `${field(name)} is an object, {${pickable ? "provider, " : ""}permission${isMcpTool(name) ? ", pin" : ""}}` }];
|
|
354
|
+
return [{ field: field(name), reason: "wrong_type", message: `${field(name)} is an object, {${pickable ? "provider, " : ""}permission${isMcpTool(name) ? ", pin" : ""}${layer === "agent" && name === "bash" ? ", policy" : ""}}` }];
|
|
361
355
|
return Object.entries(setting).flatMap(([key, given]) => {
|
|
362
356
|
if (key === "pin")
|
|
363
357
|
return pinIssues(given, field(name, key), name);
|
|
358
|
+
// bash's policy (bash-read-only.ts): an agent's own, on bash's key only, as what its commands may do is the agent's.
|
|
359
|
+
if (key === "policy") {
|
|
360
|
+
if (layer !== "agent" || name !== "bash")
|
|
361
|
+
return [{ field: field(name, key), reason: "not_allowed", message: `A policy is set on bash in an agent's own tool settings (definition.tool_settings.bash.policy), never ${layer === "agent" ? `on ${name}` : "in the server's"}.` }];
|
|
362
|
+
return BASH_POLICIES.includes(given) ? [] : [{ field: field(name, key), reason: "not_an_option", message: `${field(name, key)} is one of ${BASH_POLICIES.join(", ")}: read-only refuses, before it runs, any command that could write, run code or read outside the run's folder` }];
|
|
363
|
+
}
|
|
364
364
|
// The server's own mark of a pin in its file that does not read (withDefaults serves it), which a whole-map save
|
|
365
365
|
// sends back: it keeps the broken pin, and nothing else. Never an agent's.
|
|
366
366
|
if (key === "pin_broken") {
|
|
@@ -380,7 +380,7 @@ export function settingsIssues(value, at = "", layer = "server") {
|
|
|
380
380
|
});
|
|
381
381
|
});
|
|
382
382
|
}
|
|
383
|
-
/** `map` as a revision body keeps it: each tool's provider, permission and
|
|
383
|
+
/** `map` as a revision body keeps it: each tool's provider, permission, pin and policy as written (never a stand-in's internal
|
|
384
384
|
* marks), tools, fields and a pin's arguments sorted, and a tool with none of them gone. The one form, so two
|
|
385
385
|
* revisions whose settings say the same (a pin's arguments in another order) are the same text, and so one revision
|
|
386
386
|
* where its id is the body's digest (the store keeps the body as given: store/sqlite/store.ts). */
|
|
@@ -389,7 +389,7 @@ export function canonicalToolSettings(map) {
|
|
|
389
389
|
return sorted(Object.fromEntries(Object.entries(map).flatMap(([name, setting]) => {
|
|
390
390
|
if (!setting)
|
|
391
391
|
return [];
|
|
392
|
-
const kept = sorted({ ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.pin ? { pin: sortedPin(setting.pin) } : {}), ...(setting.provider ? { provider: setting.provider } : {}) });
|
|
392
|
+
const kept = sorted({ ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.pin ? { pin: sortedPin(setting.pin) } : {}), ...(setting.policy ? { policy: setting.policy } : {}), ...(setting.provider ? { provider: setting.provider } : {}) });
|
|
393
393
|
return Object.keys(kept).length ? [[name, kept]] : [];
|
|
394
394
|
})));
|
|
395
395
|
}
|
|
@@ -399,31 +399,9 @@ export const withDefaults = (map) => ({
|
|
|
399
399
|
...Object.fromEntries(Object.entries(map).map(([name, setting]) => [name, setting && { ...(setting.provider ? { provider: setting.provider } : {}), ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.pin ? { pin: setting.pin } : {}), ...(setting.brokenPin ? { pin_broken: true } : {}) }])),
|
|
400
400
|
...Object.fromEntries(PICKABLE.map((name) => [name, { provider: map[name]?.provider ?? PROVIDERS[name][0], ...(map[name]?.permission ? { permission: map[name].permission } : {}) }])),
|
|
401
401
|
});
|
|
402
|
-
/**
|
|
403
|
-
*
|
|
404
|
-
* default, and so is one it cannot read, which it says in one line. */
|
|
405
|
-
/** An empty settings map marked as standing for a file that does not read (SETTINGS_UNREAD, tool-gate.ts): every caller of
|
|
406
|
-
* readToolSettings inherits the mark, a direct read too (learning's draft check, the learned-draft tools), so none lifts an
|
|
407
|
-
* ask over a file whose deny it cannot see. */
|
|
402
|
+
/** An empty settings map marked as standing for settings that do not read (SETTINGS_UNREAD, tool-gate.ts): every reader
|
|
403
|
+
* inherits the mark, so none lifts an ask over settings whose deny it cannot see. */
|
|
408
404
|
const unreadMap = () => Object.assign({}, { [SETTINGS_UNREAD]: true });
|
|
409
|
-
/** The tool settings in `dir` as the server and the tool gate read them, failing closed: each entry that reads is kept;
|
|
410
|
-
* one that does not is dropped, but a known tool keeps what of it reads, and its permission, when not one offered,
|
|
411
|
-
* reads ask (deny where ask is not offered), never its allow default. `problems`: one line for each entry dropped or
|
|
412
|
-
* changed, naming the file and the field, never a value. `unreadable`: the file as a whole does not read (none, a
|
|
413
|
-
* missing file is every default). */
|
|
414
|
-
export function readToolSettings(dir) {
|
|
415
|
-
const file = join(dir, ToolSettings.FILE);
|
|
416
|
-
let read;
|
|
417
|
-
try {
|
|
418
|
-
read = JSON.parse(readFileSync(file, "utf8"));
|
|
419
|
-
}
|
|
420
|
-
catch (error) {
|
|
421
|
-
if (error.code === "ENOENT")
|
|
422
|
-
return { settings: {}, problems: [] };
|
|
423
|
-
return { settings: unreadMap(), problems: [`${file} does not read as JSON`], unreadable: true };
|
|
424
|
-
}
|
|
425
|
-
return checkToolSettings(read, file);
|
|
426
|
-
}
|
|
427
405
|
/** A parsed tool-settings object (from the file, or the store), checked and failed closed: each entry that reads is kept;
|
|
428
406
|
* one that does not is dropped, but a known tool keeps what of it reads, and its permission, when not one offered, reads
|
|
429
407
|
* ask (deny where ask is not offered), never its allow default. `where` names the source in each problem line (the file's
|
|
@@ -472,15 +450,14 @@ export function checkToolSettings(read, where) {
|
|
|
472
450
|
}
|
|
473
451
|
/** The key the server's tool settings live under in the one store (store.settings). */
|
|
474
452
|
export const TOOL_SETTINGS_KEY = "tool-settings";
|
|
475
|
-
/** The server's tool settings read from the one store (store.settings), failing closed
|
|
476
|
-
*
|
|
453
|
+
/** The server's tool settings read from the one store (store.settings), failing closed (checkToolSettings): no row is
|
|
454
|
+
* every default. */
|
|
477
455
|
export async function loadToolSettings(store) {
|
|
478
456
|
const read = await store.settings.get(TOOL_SETTINGS_KEY);
|
|
479
457
|
if (read === undefined)
|
|
480
458
|
return { settings: {}, problems: [] };
|
|
481
459
|
const checked = checkToolSettings(read, "the stored tool settings");
|
|
482
|
-
// A stored row that does not read carries SETTINGS_UNREAD (tool-gate.ts)
|
|
483
|
-
// these settings go (the plane's providers, an agent's tools, a save's blockers) approvals "never" lifts no ask over a
|
|
460
|
+
// A stored row that does not read carries SETTINGS_UNREAD (tool-gate.ts): wherever these settings go (the plane's providers, an agent's tools, a save's blockers) approvals "never" lifts no ask over a
|
|
484
461
|
// deny the row may hold. A save over it (saveToolSettings) writes a row that reads.
|
|
485
462
|
if (checked.unreadable)
|
|
486
463
|
checked.settings[SETTINGS_UNREAD] = true;
|
|
@@ -488,7 +465,7 @@ export async function loadToolSettings(store) {
|
|
|
488
465
|
}
|
|
489
466
|
/** A save of the server's tool settings: `map` (a tool it leaves out takes its defaults) over the settings read before it
|
|
490
467
|
* (`current`), as kept (the marks within) and as written (the raw values, which a read turns back into those marks).
|
|
491
|
-
* The
|
|
468
|
+
* The rule saveToolSettings keeps:
|
|
492
469
|
* - a pin is kept as given, as a pin is a gate fence (tool-gate.ts pinRefusal);
|
|
493
470
|
* - a broken pin (one that did not read) is kept by every save that keeps the tool's key and sets no pin of its own (a
|
|
494
471
|
* console's whole map sends the key back, marked pin_broken): only a valid pin, or the key left out, clears it, so an
|
|
@@ -509,50 +486,15 @@ export function keptSettings(map, current) {
|
|
|
509
486
|
const written = Object.fromEntries(Object.entries(kept).map(([name, setting]) => [name, { ...(setting.provider ? { provider: setting.provider } : {}), ...(setting.fallback ? { permission: setting.raw } : setting.permission ? { permission: setting.permission } : {}), ...(setting.pin ? { pin: setting.pin } : setting.brokenPin ? { pin: setting.rawPin } : {}) }]));
|
|
510
487
|
return { kept, written };
|
|
511
488
|
}
|
|
512
|
-
/** Replaces the server's tool settings in the one store,
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
* within). The store-backed replacement for ToolSettings.put; the cut wires it. */
|
|
489
|
+
/** Replaces the server's tool settings in the one store, by keptSettings's rule: a tool `map` leaves out takes its
|
|
490
|
+
* defaults, a pin is kept, a broken pin is kept until a valid one or the key left out clears it, and a stand-in sent
|
|
491
|
+
* back unchanged stays a stand-in. Answers the settings as served (the marks within). */
|
|
516
492
|
export async function saveToolSettings(store, map) {
|
|
517
493
|
const { settings: current } = await loadToolSettings(store);
|
|
518
494
|
const { kept, written } = keptSettings(map, current);
|
|
519
495
|
await store.settings.put(TOOL_SETTINGS_KEY, written);
|
|
520
496
|
return structuredClone(kept);
|
|
521
497
|
}
|
|
522
|
-
export class ToolSettings {
|
|
523
|
-
dir;
|
|
524
|
-
static FILE = "tool-settings.json";
|
|
525
|
-
current;
|
|
526
|
-
/** The file was present but did not read at the start: every tool takes its defaults until a PUT replaces it. */
|
|
527
|
-
unread;
|
|
528
|
-
constructor(dir, warn = (line) => void process.stderr.write(`${line}\n`)) {
|
|
529
|
-
this.dir = dir;
|
|
530
|
-
const { settings, problems, unreadable } = readToolSettings(dir);
|
|
531
|
-
for (const line of problems)
|
|
532
|
-
warn(`agentrun-serve: ${line}; ${unreadable ? "every tool takes its defaults" : "that entry is dropped (a permission that is not offered reads ask)"} until a PUT /v2/settings/tools`);
|
|
533
|
-
this.current = settings;
|
|
534
|
-
this.unread = unreadable === true;
|
|
535
|
-
}
|
|
536
|
-
/** The settings now. While the file does not read, the map carries SETTINGS_UNREAD (tool-gate.ts), so wherever it goes
|
|
537
|
-
* (the gate's permission, the plane's providers, an agent's tools, a save's blockers) approvals "never" lifts no ask
|
|
538
|
-
* over a deny the file may hold, as the gate itself fails closed. */
|
|
539
|
-
get() {
|
|
540
|
-
const map = structuredClone(this.current);
|
|
541
|
-
if (this.unread)
|
|
542
|
-
map[SETTINGS_UNREAD] = true;
|
|
543
|
-
return map;
|
|
544
|
-
}
|
|
545
|
-
/** Replaces the settings: a tool `map` leaves out takes its defaults; pins, broken pins and stand-ins by the one rule
|
|
546
|
-
* the store's save keeps too (keptSettings). Durable before it returns. */
|
|
547
|
-
put(map) {
|
|
548
|
-
const { kept, written } = keptSettings(map, this.current);
|
|
549
|
-
writeDurableSync(join(this.dir, ToolSettings.FILE), `${JSON.stringify(written)}\n`);
|
|
550
|
-
this.current = kept;
|
|
551
|
-
// The file is the one just written: it reads.
|
|
552
|
-
this.unread = false;
|
|
553
|
-
return this.get();
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
498
|
/** GET /v2/agents/{id}'s `tools`: each tool its current revision grants, in `order` (capabilities.tools'), with its
|
|
557
499
|
* permission in force and where it came from (the agent's own settings, the server's, or the default), the one that
|
|
558
500
|
* applies when the agent sets none (the server's, else the default) and those it may be set to; and for one with a
|