@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/mcp-oauth.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// OAuth sign-in to a remote MCP server, run by this server with the official SDK's `auth` (@modelcontextprotocol/client):
|
|
2
2
|
// RFC 9728 then RFC 8414 discovery, the client (the owner's pre-registered one; else this server's client metadata
|
|
3
3
|
// document, only when its address is public https; else dynamic registration), PKCE S256, the RFC 8707 resource, the
|
|
4
|
-
// code exchange and the refresh. What is here is only what the SDK's provider keeps: a sign-in in progress, in
|
|
5
|
-
// its state (random, used once, ten minutes), and the token set the
|
|
6
|
-
// ever answered, logged or handed to the browser.
|
|
4
|
+
// code exchange and the refresh. What is here is only what the SDK's provider keeps: a sign-in in progress, kept in the
|
|
5
|
+
// store by its state (random, used once, ten minutes; mcp-servers-store.ts pendingOverStore), and the token set the
|
|
6
|
+
// callback hands mcp-servers-store.ts to seal. No token is ever answered, logged or handed to the browser.
|
|
7
7
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
8
8
|
import dns from "node:dns/promises";
|
|
9
9
|
import net from "node:net";
|
|
@@ -22,7 +22,7 @@ const STATE_MS = 10 * 60_000;
|
|
|
22
22
|
/** The most sign-ins that may be in flight at once: the in-memory map evicts to it, and the store-backed one refuses past it. */
|
|
23
23
|
export const MAX_PENDING = 64;
|
|
24
24
|
const REQUEST_MS = 15_000;
|
|
25
|
-
/** How long a token refresh's request may take: a run's start waits for it, two tries at most (mcp-
|
|
25
|
+
/** How long a token refresh's request may take: a run's start waits for it, two tries at most (runner/mcp-claim.ts), so an
|
|
26
26
|
* authorization server that never answers holds a start's answer no more than about eight seconds, well under a
|
|
27
27
|
* client's timeout, and its call is then refused unsent, saying to try again. */
|
|
28
28
|
export const REFRESH_REQUEST_MS = 4_000;
|
|
@@ -238,20 +238,18 @@ export class McpSignIns {
|
|
|
238
238
|
network;
|
|
239
239
|
pendingStore;
|
|
240
240
|
allowed;
|
|
241
|
-
/** `pendingStore`: where sign-ins in flight are kept
|
|
242
|
-
*
|
|
243
|
-
|
|
244
|
-
constructor(network = systemNetwork, pendingStore, allowed = async () => []) {
|
|
241
|
+
/** `pendingStore`: where sign-ins in flight are kept (over store.mcpOauth). `allowed`: the private-network hosts the
|
|
242
|
+
* owner allows (privateOAuthHosts), read at a sign-in's start and again at its callback. */
|
|
243
|
+
constructor(network, pendingStore, allowed) {
|
|
245
244
|
this.network = network;
|
|
246
245
|
this.pendingStore = pendingStore;
|
|
247
246
|
this.allowed = allowed;
|
|
248
247
|
}
|
|
249
|
-
pending = new Map();
|
|
250
248
|
/** This server's address as a browser reaches it (AGENTRUN_PUBLIC_URL, else where it listens), no trailing slash:
|
|
251
|
-
* set by
|
|
249
|
+
* set by McpServersOverStore.attach as the server starts listening. */
|
|
252
250
|
base = "";
|
|
253
251
|
/** Where this server listens (`http://<host>:<port>`), whatever `base` is: its port is never an endpoint a loopback
|
|
254
|
-
* authorization server may name. Set by
|
|
252
|
+
* authorization server may name. Set by McpServersOverStore.attach. */
|
|
255
253
|
listening = "";
|
|
256
254
|
/** This server's own local addresses, whose ports a loopback authorization server may never name: where it listens,
|
|
257
255
|
* and its public address too when that is on loopback (a local https proxy on another port, in front of the
|
|
@@ -276,10 +274,6 @@ export class McpSignIns {
|
|
|
276
274
|
/** Discovery, the client, PKCE and the state: the URL the owner opens to say yes. */
|
|
277
275
|
async start(name, url, options) {
|
|
278
276
|
const now = Date.now();
|
|
279
|
-
if (!this.pendingStore)
|
|
280
|
-
for (const [state, entry] of this.pending)
|
|
281
|
-
if (entry.expires <= now || this.pending.size >= MAX_PENDING)
|
|
282
|
-
this.pending.delete(state);
|
|
283
277
|
const state = randomBytes(32).toString("base64url");
|
|
284
278
|
const entry = { name, url: url.href, was: options.was, ...(options.scope ? { scope: options.scope } : {}), kind: options.kind ?? "dynamic", ...(options.client ? { client: options.client } : {}), ...(options.keptFor ? { keptFor: options.keptFor } : {}), expires: now + STATE_MS };
|
|
285
279
|
let opened;
|
|
@@ -299,26 +293,14 @@ export class McpSignIns {
|
|
|
299
293
|
throw new ApiError("upstream_failed", `The sign-in to ${url.origin} did not start: its authorization server gave no page to open.`);
|
|
300
294
|
if (entry.client?.client_id === provider.clientMetadataUrl)
|
|
301
295
|
entry.kind = "metadata-document";
|
|
302
|
-
|
|
303
|
-
await this.pendingStore.set(state, entry);
|
|
304
|
-
else
|
|
305
|
-
this.pending.set(state, entry);
|
|
296
|
+
await this.pendingStore.set(state, entry);
|
|
306
297
|
return opened.href;
|
|
307
298
|
}
|
|
308
|
-
/** The callback's sign-in, by its state: once, and only within ten minutes of its start. `was`
|
|
309
|
-
* when it started (null for none), so a sign-in the owner since replaced or forgot is not
|
|
310
|
-
|
|
311
|
-
const entry = state ? this.pending.get(state) : undefined;
|
|
312
|
-
if (state)
|
|
313
|
-
this.pending.delete(state);
|
|
314
|
-
if (!entry || entry.expires <= Date.now())
|
|
315
|
-
throw new ApiError("bad_request", `This sign-in link was used already, is older than ${STATE_MS / 60_000} minutes, or is not this server's: start the sign-in again in Settings → MCP servers.`);
|
|
316
|
-
return entry;
|
|
317
|
-
}
|
|
318
|
-
/** take() over the pending store (the store server), async: the callback's sign-in, by its state, once and only within
|
|
319
|
-
* ten minutes of its start. The same refusal as take() when it is used, expired or unknown. */
|
|
299
|
+
/** The callback's sign-in, by its state, from the pending store: once, and only within ten minutes of its start. `was`
|
|
300
|
+
* is the server's save when it started (null for none), so a sign-in the owner since replaced or forgot is not
|
|
301
|
+
* written back. */
|
|
320
302
|
async takePending(state) {
|
|
321
|
-
const entry = state
|
|
303
|
+
const entry = state ? await this.pendingStore.take(state) : undefined;
|
|
322
304
|
if (!entry || entry.expires <= Date.now())
|
|
323
305
|
throw new ApiError("bad_request", `This sign-in link was used already, is older than ${STATE_MS / 60_000} minutes, or is not this server's: start the sign-in again in Settings → MCP servers.`);
|
|
324
306
|
return entry;
|
package/dist/mcp-probe.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { ApiError, type InputIssue } from "./errors.js";
|
|
2
2
|
export declare const MCP_SERVER_NAME: RegExp;
|
|
3
|
-
/** The names AgentRun's own tools are called by, which no MCP server takes: claude-agent calls the kernel's host tools
|
|
4
|
-
* as `mcp__hands__<tool>`, and monid's are `monid_<tool>` (tool-gate.ts settingsKeyOf reads both as AgentRun's). */
|
|
5
|
-
export declare const RESERVED_MCP_NAMES: readonly string[];
|
|
6
3
|
export declare const MCP_AUTH_TYPES: readonly ["none", "bearer", "headers", "oauth", "github_app"];
|
|
7
4
|
/** Why a saved credential can't be used for a run's calls, each with its own remedy and no other, as the model reads it
|
|
8
5
|
* after "The MCP server <name>'s credential can't be used right now: " (mcp-gateway.ts). The one place they are said. */
|
|
9
6
|
export declare const UNUSABLE: {
|
|
10
|
-
/** This server was started without its seal key. */
|
|
11
|
-
readonly noSealKey: "this server was started without its seal key (AGENTRUN_SEAL_KEY); start it with the key the credential was saved under, or update the credential in Settings → MCP servers";
|
|
12
7
|
/** Sealed under another seal key, or damaged. */
|
|
13
8
|
readonly damaged: "it was sealed under another seal key, or damaged; update it in Settings → MCP servers";
|
|
14
9
|
/** An OAuth sign-in its authorization server refused to refresh, or with no refresh token left. */
|
|
@@ -60,8 +55,6 @@ export type Auth = {
|
|
|
60
55
|
type: AuthType;
|
|
61
56
|
headers?: HeaderMap;
|
|
62
57
|
};
|
|
63
|
-
/** How a server gets a seal key: what its launcher does (launcher/agentrun-serve). */
|
|
64
|
-
export declare const SEAL_KEY_HOW = "Start it with its launcher, agentrun-serve, which keeps one in agentrun/seal.key under $XDG_CONFIG_HOME (~/.config by default), made at the first start, 0600 in a 0700 directory; or hand it AGENTRUN_SEAL_KEY (32 random bytes in base64).";
|
|
65
58
|
export declare const notFound: (name: string) => ApiError;
|
|
66
59
|
export declare const credentialMissing: (type: AuthType, message: string) => InputIssue;
|
|
67
60
|
export declare const nameOf: (name: string) => void;
|
package/dist/mcp-probe.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// The MCP server probe and request validation
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// its own copies; from the cutover on this is the one home (the switch repoints mcp-gateway.ts's UNUSABLE import here).
|
|
1
|
+
// The MCP server probe and request validation of the owner's registry (mcp-servers-store.ts), and the words a run's calls
|
|
2
|
+
// read when a saved credential can't be used (UNUSABLE, which the runner's claim step
|
|
3
|
+
// runner/mcp-claim.ts hands the gateway).
|
|
5
4
|
//
|
|
6
5
|
// Nothing here opens a credential or touches a store: listServer connects to a URL with the official SDK client, agrees a
|
|
7
6
|
// protocol revision and lists every tool (all pages, under caps); the validation turns a request body into a URL, auth and
|
|
@@ -9,20 +8,17 @@
|
|
|
9
8
|
import { ApiError, invalid } from "./errors.js";
|
|
10
9
|
import { metaToolOf } from "./mcp-meta.js";
|
|
11
10
|
import { SIGN_IN_AGAIN } from "./mcp-oauth.js";
|
|
12
|
-
import { SEAL_KEY_ENV } from "./tool-keys.js";
|
|
13
11
|
import { isObject, unknownFields } from "./validate.js";
|
|
14
12
|
export const MCP_SERVER_NAME = /^[a-z][a-z0-9-]{0,31}$/;
|
|
15
13
|
/** The names AgentRun's own tools are called by, which no MCP server takes: claude-agent calls the kernel's host tools
|
|
16
14
|
* as `mcp__hands__<tool>`, and monid's are `monid_<tool>` (tool-gate.ts settingsKeyOf reads both as AgentRun's). */
|
|
17
|
-
|
|
15
|
+
const RESERVED_MCP_NAMES = ["hands", "monid"];
|
|
18
16
|
export const MCP_AUTH_TYPES = ["none", "bearer", "headers", "oauth", "github_app"];
|
|
19
17
|
/** Where an owner updates a saved MCP server, as people read it. */
|
|
20
18
|
const MCP_SETTINGS = "Settings → MCP servers";
|
|
21
19
|
/** Why a saved credential can't be used for a run's calls, each with its own remedy and no other, as the model reads it
|
|
22
20
|
* after "The MCP server <name>'s credential can't be used right now: " (mcp-gateway.ts). The one place they are said. */
|
|
23
21
|
export const UNUSABLE = {
|
|
24
|
-
/** This server was started without its seal key. */
|
|
25
|
-
noSealKey: `this server was started without its seal key (${SEAL_KEY_ENV}); start it with the key the credential was saved under, or update the credential in ${MCP_SETTINGS}`,
|
|
26
22
|
/** Sealed under another seal key, or damaged. */
|
|
27
23
|
damaged: `it was sealed under another seal key, or damaged; update it in ${MCP_SETTINGS}`,
|
|
28
24
|
/** An OAuth sign-in its authorization server refused to refresh, or with no refresh token left. */
|
|
@@ -69,8 +65,6 @@ const LOOPBACK = (host) => LOOPBACK_NAMES.includes(host) || LOOPBACK_V4.test(hos
|
|
|
69
65
|
export function boundTool(tool) {
|
|
70
66
|
return { name: tool.name, ...(tool.title ? { title: tool.title } : {}), ...(tool.description ? { description: tool.description } : {}), inputSchema: (tool.input_schema ?? {}), ...(tool.annotations ? { annotations: tool.annotations } : {}) };
|
|
71
67
|
}
|
|
72
|
-
/** How a server gets a seal key: what its launcher does (launcher/agentrun-serve). */
|
|
73
|
-
export const SEAL_KEY_HOW = `Start it with its launcher, agentrun-serve, which keeps one in agentrun/seal.key under $XDG_CONFIG_HOME (~/.config by default), made at the first start, 0600 in a 0700 directory; or hand it ${SEAL_KEY_ENV} (32 random bytes in base64).`;
|
|
74
68
|
export const notFound = (name) => new ApiError("not_found", `No MCP server ${name}: GET /v2/settings/mcp-servers lists them.`);
|
|
75
69
|
export const credentialMissing = (type, message) => ({ field: type === "bearer" ? "auth.token" : type === "oauth" ? "auth.type" : "auth.headers", reason: "missing", message: type === "oauth" ? `${message} An OAuth server is signed in to first: POST /v2/settings/mcp-servers/{name}/oauth/start.` : message });
|
|
76
70
|
export const nameOf = (name) => {
|
|
@@ -32,7 +32,7 @@ export declare class McpServersOverStore {
|
|
|
32
32
|
private readonly inflight;
|
|
33
33
|
private readonly stopped;
|
|
34
34
|
constructor(store: McpServersStore, env: NodeJS.ProcessEnv, version: string, network?: OAuthNetwork);
|
|
35
|
-
/** This server's address as a browser reaches it and where it listens
|
|
35
|
+
/** This server's address as a browser reaches it and where it listens. */
|
|
36
36
|
attach(base: string, listening: string): void;
|
|
37
37
|
clientDocument(): {
|
|
38
38
|
redirect_uris: string[];
|
|
@@ -56,7 +56,7 @@ export declare class McpServersOverStore {
|
|
|
56
56
|
};
|
|
57
57
|
/** The origin the authorization server sends the browser back to. */
|
|
58
58
|
get callbackOrigin(): string;
|
|
59
|
-
/** The server's own tool settings, set as the server starts
|
|
59
|
+
/** The server's own tool settings, set as the server starts. */
|
|
60
60
|
toolSettings: () => ToolSettingsMap;
|
|
61
61
|
close(boundMs?: number): Promise<void>;
|
|
62
62
|
private track;
|
|
@@ -234,18 +234,18 @@ export declare class McpServersOverStore {
|
|
|
234
234
|
private callback;
|
|
235
235
|
private listServer;
|
|
236
236
|
private need;
|
|
237
|
-
/** The saved credential opened, or the refusal that asks for it again
|
|
237
|
+
/** The saved credential opened, or the refusal that asks for it again. */
|
|
238
238
|
private opened;
|
|
239
239
|
/** The saved OAuth token set, for a sign-in again that reuses the kept client. */
|
|
240
240
|
private openedSet;
|
|
241
241
|
private view;
|
|
242
|
-
/** A body's URL, auth and prices, or 422
|
|
242
|
+
/** A body's URL, auth and prices, or 422. */
|
|
243
243
|
private admit;
|
|
244
244
|
/** `headers` and, for a github_app server, an installation token of the connected App to list its tools with. Its URL
|
|
245
245
|
* is checked first (githubMcpUrl), so a row saved at another address never gets a token minted or sent. */
|
|
246
246
|
private withAppToken;
|
|
247
247
|
}
|
|
248
|
-
/** The
|
|
249
|
-
*
|
|
248
|
+
/** The owner's MCP registry over the one store. No load() is needed: every read goes to the store (the runner also writes
|
|
249
|
+
* the OAuth state), so a read is always current. */
|
|
250
250
|
export declare function mcpServersOverStore(store: McpServersStore, env: NodeJS.ProcessEnv, version: string, network?: OAuthNetwork): McpServersOverStore;
|
|
251
251
|
export {};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
// The owner's remote MCP servers over the one store (store.mcp, store.mcpOauth)
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// read opens it to show the auth's header names, the OAuth note and whether the sign-in expired; with no seal key a read
|
|
6
|
-
// shows less than the file did (a degenerate misconfiguration — no credential can be saved without the key anyway).
|
|
1
|
+
// The owner's remote MCP servers over the one store (store.mcp, store.mcpOauth): the registry and the sign-ins in flight.
|
|
2
|
+
// The probe and request validation are mcp-probe.ts'. The credential is one sealed blob per row (store/seal.ts §7, the
|
|
3
|
+
// url's origin bound inside), so a read opens it to show the auth's header names, the OAuth note and whether the sign-in
|
|
4
|
+
// expired. The server never starts without its seal key, so every credential is kept sealed under it.
|
|
7
5
|
//
|
|
8
6
|
// Per the run-time ruling, the runner reads MCP servers, pins and credentials from the store at a run's claim
|
|
9
7
|
// (runner/mcp-claim.ts), including the OAuth token refresh. So this server-side registry has NO headers()/headersForRun()
|
|
10
8
|
// and does NO token refresh: it is the owner's create/preview/save/refresh(tools)/remove and the OAuth sign-in, and nothing
|
|
11
|
-
// a run's launch calls.
|
|
9
|
+
// a run's launch calls.
|
|
12
10
|
import { ApiError, invalid } from "./errors.js";
|
|
13
11
|
import { authOf, canonical, credentialMissing, listServer, marked, MAX_OAUTH_VALUE_BYTES, nameOf, notFound, oauthValueValid, pricesListed, pricesOf, scopesValid, urlOf, } from "./mcp-probe.js";
|
|
14
12
|
import { listMcpServers, openServerCredential, putPendingSignIn, removeMcpServer, removeMcpServerIfCredential, rewriteMcpServer, saveMcpServerIfCredential, takePendingSignIn } from "./mcp-store.js";
|
|
@@ -88,7 +86,7 @@ export class McpServersOverStore {
|
|
|
88
86
|
constructor(store, env, version, network = systemNetwork) {
|
|
89
87
|
this.store = store;
|
|
90
88
|
this.version = version;
|
|
91
|
-
// The server never starts without a seal key (seal-key.ts
|
|
89
|
+
// The server never starts without a seal key (seal-key.ts bootSealKey), so there is no keyless registry: every
|
|
92
90
|
// credential is kept sealed under it.
|
|
93
91
|
const sealKey = sealKeyOf(env[SEAL_KEY_ENV]);
|
|
94
92
|
if (!sealKey)
|
|
@@ -96,7 +94,7 @@ export class McpServersOverStore {
|
|
|
96
94
|
this.sealKey = sealKey;
|
|
97
95
|
this.signIns = new McpSignIns(network, pendingOverStore(store, sealKey), () => privateOAuthHosts(store));
|
|
98
96
|
}
|
|
99
|
-
/** This server's address as a browser reaches it and where it listens
|
|
97
|
+
/** This server's address as a browser reaches it and where it listens. */
|
|
100
98
|
attach(base, listening) {
|
|
101
99
|
this.signIns.base = base.replace(/\/+$/, "");
|
|
102
100
|
this.signIns.listening = listening.replace(/\/+$/, "");
|
|
@@ -108,7 +106,7 @@ export class McpServersOverStore {
|
|
|
108
106
|
get callbackOrigin() {
|
|
109
107
|
return new URL(this.signIns.base).origin;
|
|
110
108
|
}
|
|
111
|
-
/** The server's own tool settings, set as the server starts
|
|
109
|
+
/** The server's own tool settings, set as the server starts. */
|
|
112
110
|
toolSettings = () => ({});
|
|
113
111
|
async close(boundMs = 2_000) {
|
|
114
112
|
this.stopped.abort();
|
|
@@ -346,7 +344,7 @@ export class McpServersOverStore {
|
|
|
346
344
|
throw notFound(name);
|
|
347
345
|
return row;
|
|
348
346
|
}
|
|
349
|
-
/** The saved credential opened, or the refusal that asks for it again
|
|
347
|
+
/** The saved credential opened, or the refusal that asks for it again. */
|
|
350
348
|
async opened(name, row, field) {
|
|
351
349
|
// No credential kept: none for a server that takes none, nor for a github_app server with no static headers.
|
|
352
350
|
if (row.auth === "none" || row.sealed === null)
|
|
@@ -389,7 +387,7 @@ export class McpServersOverStore {
|
|
|
389
387
|
url: row.url,
|
|
390
388
|
...(prices && Object.keys(prices).length ? { prices } : {}),
|
|
391
389
|
...listed,
|
|
392
|
-
// Each priced tool's price in USD a call, as the owner saved them
|
|
390
|
+
// Each priced tool's price in USD a call, as the owner saved them, on every read.
|
|
393
391
|
...(prices && Object.keys(prices).length ? { prices } : {}),
|
|
394
392
|
tools: listed.tools.map((tool) => ({ ...tool, ...serverGate(`mcp:${name}/${tool.name}`, settings) })),
|
|
395
393
|
...(unmetered.length ? { not_metered: unmetered } : {}),
|
|
@@ -401,7 +399,7 @@ export class McpServersOverStore {
|
|
|
401
399
|
secret: secretOf(row),
|
|
402
400
|
};
|
|
403
401
|
}
|
|
404
|
-
/** A body's URL, auth and prices, or 422
|
|
402
|
+
/** A body's URL, auth and prices, or 422. */
|
|
405
403
|
admit(body, priced = false) {
|
|
406
404
|
const issues = unknownFields(body, priced ? ["url", "auth", "prices"] : ["url", "auth"]);
|
|
407
405
|
const url = urlOf(body.url, issues);
|
|
@@ -433,8 +431,8 @@ export class McpServersOverStore {
|
|
|
433
431
|
/** Which save of a server this is: a PUT or a sign-in makes a new one (its updated time moves), a refresh of its tools or
|
|
434
432
|
* token does not change the url. The staleness key an OAuth sign-in carries from start to callback. */
|
|
435
433
|
const saving = (row) => `${row.url} ${row.updatedAt}`;
|
|
436
|
-
/** The
|
|
437
|
-
*
|
|
434
|
+
/** The owner's MCP registry over the one store. No load() is needed: every read goes to the store (the runner also writes
|
|
435
|
+
* the OAuth state), so a read is always current. */
|
|
438
436
|
export function mcpServersOverStore(store, env, version, network) {
|
|
439
437
|
return new McpServersOverStore(store, env, version, network);
|
|
440
438
|
}
|
package/dist/mcp-store.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// The MCP registry and OAuth sign-ins in flight, in the one store (store.mcp, store.mcpOauth), sealed with the store's one
|
|
2
2
|
// rule (store/seal.ts): the registry row's credential under AAD mcp_servers|<name>|sealed with the url
|
|
3
3
|
// origin inside the plaintext, and a pending sign-in's secret parts (the PKCE verifier and the OAuth client, with its
|
|
4
|
-
// secret) under AAD mcp_oauth_pending|<state>|sealed.
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// credential; only this process (and a runner) does, with the seal key.
|
|
4
|
+
// secret) under AAD mcp_oauth_pending|<state>|sealed. McpServersOverStore (mcp-servers-store.ts) and McpSignIns
|
|
5
|
+
// (mcp-oauth.ts) keep the SDK tool-probe, validation and sign-in flow over these. The store never opens a credential;
|
|
6
|
+
// only this process (and a runner) does, with the seal key.
|
|
8
7
|
import { openMcpCredential, sealColumn, sealedAt, sealMcpCredential, unsealColumn, } from "./store/index.js";
|
|
9
8
|
import { GITHUB_MCP_ONLY, GITHUB_MCP_ORIGIN, githubMcpUrl } from "./github.js";
|
|
10
9
|
import { tokenLeftOf } from "./mcp-probe.js";
|
package/dist/mcp.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// server's own (the transport's rule against DNS rebinding; on loopback the Host check comes first, in server.ts).
|
|
7
7
|
import { readFile } from "node:fs/promises";
|
|
8
8
|
import { Readable, Writable } from "node:stream";
|
|
9
|
-
import {
|
|
9
|
+
import { answerOf, logged } from "./agents.js";
|
|
10
10
|
import { ApiError, invalid } from "./errors.js";
|
|
11
11
|
import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
|
|
12
12
|
import { isJson, ownOrigin } from "./page.js";
|
|
@@ -289,8 +289,9 @@ export function mcpEndpoint({ route, authorized, authFailed, version }) {
|
|
|
289
289
|
await res.settled;
|
|
290
290
|
}
|
|
291
291
|
catch (error) {
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
// The same answer the HTTP route gives (answerOf): a store busy or past a write's deadline is home_busy, never 500.
|
|
293
|
+
const known = answerOf(error);
|
|
294
|
+
if (logged(error))
|
|
294
295
|
process.stderr.write(`agentrun-serve: mcp: ${error?.stack ?? String(error)}\n`);
|
|
295
296
|
return { status: known.status, headers: { "content-type": "application/json" }, bytes: Buffer.from(JSON.stringify(known.body(requestId))), tooBig: false };
|
|
296
297
|
}
|
package/dist/model.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ModelCost
|
|
1
|
+
import type { ModelCost } from "@earendil-works/pi-ai";
|
|
2
2
|
import { type HarnessEntry } from "./harness-table.js";
|
|
3
|
-
import type { Revision } from "
|
|
3
|
+
import type { Revision } from "./agent-rows.js";
|
|
4
4
|
/** The child's environment names the faux module by absolute path. */
|
|
5
5
|
export declare const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
|
|
6
6
|
/** Every test hook's name starts so (AGENTRUN_SERVE_FAUX, AGENTRUN_SERVE_FAUX_WEB, ...), but the harness table's
|
|
@@ -13,8 +13,6 @@ export declare const withoutFaux: (env: NodeJS.ProcessEnv) => NodeJS.ProcessEnv;
|
|
|
13
13
|
* tests' fake upstream), in place of their APIs. With it they are registered beside the faux model, for a tool's own
|
|
14
14
|
* request to the provider the revision's model names (web_search's, hosted-search.ts); the run's turns stay faux. */
|
|
15
15
|
export declare const FAUX_UPSTREAM_ENV = "AGENTRUN_SERVE_FAUX_UPSTREAM";
|
|
16
|
-
/** A run's `effort`, passed to its child. */
|
|
17
|
-
export declare const EFFORT_ENV = "AGENTRUN_SERVE_EFFORT";
|
|
18
16
|
/** The model the server's keys give a run that names none (hostModel at the run's launch, from every key the server
|
|
19
17
|
* holds), passed to its child as its effort is: behind a gateway the run holds the gateway's key alone, never the key
|
|
20
18
|
* that names its default (runs.ts). A model id, never a secret, so its name has no secret's segment (pi-durable-disk's
|
|
@@ -25,6 +23,7 @@ export declare const EFFORTS: readonly ["low", "medium", "high"];
|
|
|
25
23
|
export type Effort = (typeof EFFORTS)[number];
|
|
26
24
|
/** The thinking levels a revision or the host may name. Never off. */
|
|
27
25
|
export declare const THINKING_LEVELS: readonly ["low", "medium", "high", "xhigh", "max"];
|
|
26
|
+
export type ThinkingLevel = (typeof THINKING_LEVELS)[number];
|
|
28
27
|
export declare const TIERS: readonly ["fast", "default", "strong"];
|
|
29
28
|
export type Tier = (typeof TIERS)[number];
|
|
30
29
|
/** The workflow node kinds that run on a model. */
|
|
@@ -131,9 +130,9 @@ export declare const GATEWAY_KEY_ENV = "AGENT_MODEL_API_KEY";
|
|
|
131
130
|
* of that tier; through a gateway (`AGENT_MODEL_BASE_URL`), where every model is the gateway's, its key alone. Asked as
|
|
132
131
|
* chooseModel is, faux or not, so a run on the faux model is handed what a run on its model would be. */
|
|
133
132
|
export declare function modelKeys(env: NodeJS.ProcessEnv, ref: string | undefined, tiers?: readonly Tier[]): string[];
|
|
134
|
-
/**
|
|
135
|
-
*
|
|
136
|
-
export declare function
|
|
133
|
+
/** `value` as a thinking level (THINKING_LEVELS, exactly), else undefined: a revision's `thinking` or the host's
|
|
134
|
+
* `AGENT_THINKING` that names none is no level. A run's effort is its own, else these (runs-over-store.ts prepareLaunch). */
|
|
135
|
+
export declare function thinkingLevel(value: unknown): ThinkingLevel | undefined;
|
|
137
136
|
/** The helpers a faux module's reply gets, so it needs no import of its own. */
|
|
138
137
|
export type FauxHelpers = {
|
|
139
138
|
/** Aborted when the turn is stopped: a slow reply resolves with `message("", { stopReason: "aborted" })`. */
|
package/dist/model.js
CHANGED
|
@@ -25,8 +25,6 @@ export const withoutFaux = (env) => Object.fromEntries(Object.entries(env).filte
|
|
|
25
25
|
* tests' fake upstream), in place of their APIs. With it they are registered beside the faux model, for a tool's own
|
|
26
26
|
* request to the provider the revision's model names (web_search's, hosted-search.ts); the run's turns stay faux. */
|
|
27
27
|
export const FAUX_UPSTREAM_ENV = "AGENTRUN_SERVE_FAUX_UPSTREAM";
|
|
28
|
-
/** A run's `effort`, passed to its child. */
|
|
29
|
-
export const EFFORT_ENV = "AGENTRUN_SERVE_EFFORT";
|
|
30
28
|
/** The model the server's keys give a run that names none (hostModel at the run's launch, from every key the server
|
|
31
29
|
* holds), passed to its child as its effort is: behind a gateway the run holds the gateway's key alone, never the key
|
|
32
30
|
* that names its default (runs.ts). A model id, never a secret, so its name has no secret's segment (pi-durable-disk's
|
|
@@ -277,11 +275,10 @@ export function modelKeys(env, ref, tiers = ["default"]) {
|
|
|
277
275
|
const providers = named.flatMap((name) => (name && name.indexOf("/") > 0 ? [name.slice(0, name.indexOf("/"))] : []));
|
|
278
276
|
return [...new Set(providers.flatMap((provider) => PROVIDER_KEYS[provider] ?? []))];
|
|
279
277
|
}
|
|
280
|
-
/**
|
|
281
|
-
*
|
|
282
|
-
export function
|
|
283
|
-
|
|
284
|
-
return (level ?? "medium");
|
|
278
|
+
/** `value` as a thinking level (THINKING_LEVELS, exactly), else undefined: a revision's `thinking` or the host's
|
|
279
|
+
* `AGENT_THINKING` that names none is no level. A run's effort is its own, else these (runs-over-store.ts prepareLaunch). */
|
|
280
|
+
export function thinkingLevel(value) {
|
|
281
|
+
return THINKING_LEVELS.includes(value) ? value : undefined;
|
|
285
282
|
}
|
|
286
283
|
/** The models for a run, and its model of each tier it uses and of no other: an agentic revision's `ref` (or the
|
|
287
284
|
* default) is its `default` (a claimed run's: its pin, chooseModel), and a workflow's tiers are the ones its nodes name.
|
|
@@ -400,7 +397,8 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
|
|
|
400
397
|
/** The price of each gateway model of `byTier` (its tiers' models, `namedBy` the provider a ref named), in USD per million
|
|
401
398
|
* input, output, cache-read and cache-write tokens: a tier's own price (`AGENT_MODEL_FAST_PRICE`,
|
|
402
399
|
* `AGENT_MODEL_STRONG_PRICE`) goes with its model, else the default's (`AGENT_MODEL_PRICE`); a model two tiers share
|
|
403
|
-
* takes the default's. With none set, pi-ai's catalog prices it (catalogPrice), a
|
|
400
|
+
* takes the default's. With none set, pi-ai's catalog prices it (catalogPrice), from a metered entry alone: a $0 one (a
|
|
401
|
+
* plan's, a free tier's) never prices it (#2339). An id with no price
|
|
404
402
|
* is absent: its answers carry no total (unpricedApi) and a harness books it unknown (adapters.ts priceOf), so the run's
|
|
405
403
|
* cost reads unknown, never $0, and a cap refuses it (blockersOf refuses a capped run on it before it starts). */
|
|
406
404
|
async function gatewayPrices(env, byTier, namedBy) {
|
|
@@ -596,29 +594,47 @@ export function catalogPrice(catalog, id, named) {
|
|
|
596
594
|
* gpt-5.4-mini; pair by pair, so llama-3-1-8b is llama-3.1-8b), and each digit-dot-digit as a dash (claude-haiku-4.5,
|
|
597
595
|
* claude-haiku-4-5). Not `id` itself. */
|
|
598
596
|
const flippedForms = (id) => [...new Set([id.replace(/(\d)-(\d)/g, "$1.$2"), id.replace(/(\d)\.(\d)/g, "$1-$2")])].filter((form) => form !== id);
|
|
599
|
-
/** `id`'s price in `catalog` (listedPrice): its own entries when the catalog lists
|
|
600
|
-
* (flippedForms), only when every entry they hold has one price
|
|
601
|
-
*
|
|
597
|
+
/** `id`'s price in `catalog` (listedPrice): its own entries' metered price when the catalog lists one; else its flipped
|
|
598
|
+
* forms' (flippedForms), only when every metered entry they hold has one price; else the metered price a gateway lists
|
|
599
|
+
* under a vendor's id for it (`<vendor>/<id>`, the named vendor's first: pi-ai lists the bare id of some models only
|
|
600
|
+
* under subscription plans, at $0, and the gateways that meter them under the vendor's). A flip that finds different
|
|
601
|
+
* prices leaves the model unpriced, and so does an id with no metered entry anywhere (#2339: a plan's $0 never prices a
|
|
602
|
+
* metered model): the cap refuses it rather than keep a price picked by luck or a $0 nobody bills. */
|
|
602
603
|
function catalogEntries(catalog, id, named) {
|
|
603
604
|
const own = catalog.get(id);
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
605
|
+
const listed = own ? listedPrice(own, named) : undefined;
|
|
606
|
+
if (listed)
|
|
607
|
+
return listed;
|
|
608
|
+
const flipped = flippedForms(id).flatMap((form) => (catalog.get(form) ?? []).filter(({ cost }) => cost.input + cost.output > 0));
|
|
609
|
+
if (flipped.length) {
|
|
610
|
+
const one = JSON.stringify(flipped[0].cost);
|
|
611
|
+
return flipped.every((entry) => JSON.stringify(entry.cost) === one) ? flipped[0].cost : undefined;
|
|
612
|
+
}
|
|
613
|
+
return vendorPrice(catalog, id, named);
|
|
611
614
|
}
|
|
612
|
-
/**
|
|
613
|
-
*
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
615
|
+
/** The metered price gateways list for `id` under a vendor's id (`<vendor>/<id>`, or a flipped form of it): the named
|
|
616
|
+
* vendor's id when the catalog has one, else every vendor's; the highest paid entry, so an estimate errs high. */
|
|
617
|
+
function vendorPrice(catalog, id, named) {
|
|
618
|
+
const forms = new Set([id, ...flippedForms(id)]);
|
|
619
|
+
const keyed = (key) => {
|
|
620
|
+
const slash = key.indexOf("/");
|
|
621
|
+
return slash > 0 && forms.has(key.slice(slash + 1)) ? key.slice(0, slash) : undefined;
|
|
622
|
+
};
|
|
623
|
+
const vendors = [...catalog.keys()].filter((key) => keyed(key) !== undefined);
|
|
624
|
+
const chosen = named !== undefined && vendors.some((key) => keyed(key) === named) ? vendors.filter((key) => keyed(key) === named) : vendors;
|
|
625
|
+
return listedPrice(chosen.flatMap((key) => catalog.get(key) ?? []), undefined);
|
|
626
|
+
}
|
|
627
|
+
/** A gateway model's catalog price from `entries`: the metered (paid) entry of the provider its ref names, when the
|
|
628
|
+
* catalog lists one. Else, as the gateway does not say whose model answers (a named provider is a hint), the highest
|
|
629
|
+
* paid entry any provider lists, so the estimate and a cap on it err high: one entry's whole price, the one with the
|
|
630
|
+
* most input plus output (the first of equals). A $0 entry (a plan's, a free tier's) never prices it: with no paid
|
|
631
|
+
* entry the price is unknown (undefined), never $0. */
|
|
617
632
|
function listedPrice(entries, named) {
|
|
618
|
-
|
|
633
|
+
const paid = entries.filter(({ cost }) => cost.input + cost.output > 0);
|
|
634
|
+
if (!paid.length)
|
|
619
635
|
return undefined;
|
|
620
|
-
const own = named === undefined ? undefined :
|
|
621
|
-
if (own
|
|
636
|
+
const own = named === undefined ? undefined : paid.find((entry) => entry.provider === named);
|
|
637
|
+
if (own)
|
|
622
638
|
return own.cost;
|
|
623
|
-
return
|
|
639
|
+
return paid.reduce((top, entry) => (entry.cost.input + entry.cost.output > top.cost.input + top.cost.output ? entry : top)).cost;
|
|
624
640
|
}
|
package/dist/monid.d.ts
CHANGED
|
@@ -69,8 +69,6 @@ export declare const MONID_RUN_ALLOWANCE_USD = 1;
|
|
|
69
69
|
* and the run's cost unknown, never $0. pi binds it (monidTool); another harness runs it as a host tool
|
|
70
70
|
* (host-tools.ts), whose `api` commits to the run's store as pi's does. */
|
|
71
71
|
export declare function monidRegistration(kind: Kind, env: NodeJS.ProcessEnv, work: () => Workspace): ToolRegistration;
|
|
72
|
-
/** The three, as another harness's host tools. */
|
|
73
|
-
export declare const monidTools: (env: NodeJS.ProcessEnv, work: () => Workspace) => ToolRegistration[];
|
|
74
72
|
/** The table's entry for `monid.<kind>`: it needs MONID_API_KEY, and no workflow node names it yet. */
|
|
75
73
|
export declare const monidTool: (kind: Kind) => ToolEntry;
|
|
76
74
|
export {};
|
package/dist/monid.js
CHANGED
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
import { randomUUID } from "node:crypto";
|
|
18
18
|
import { localWorkspace, workspaceErrorWords } from "./workspace/index.js";
|
|
19
19
|
import { defineExtension, defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
20
|
-
import { registerLabel, TOOL_COST } from "
|
|
20
|
+
import { registerLabel, TOOL_COST } from "./timeline/index.js";
|
|
21
21
|
import { paidCall } from "./cap.js";
|
|
22
22
|
import { wireName } from "./catalog.js";
|
|
23
23
|
import { fauxFetch } from "./decisions.js";
|
|
24
|
-
import { holdRefusal, paidLedger, paidStep,
|
|
24
|
+
import { holdRefusal, paidLedger, paidStep, writeHold } from "./paid-calls.js";
|
|
25
25
|
import { forModel } from "./result.js";
|
|
26
26
|
import { isObject } from "./validate.js";
|
|
27
27
|
export const MONID_KEY_ENV = "MONID_API_KEY";
|
|
@@ -246,9 +246,8 @@ export function monidRegistration(kind, env, work) {
|
|
|
246
246
|
// Settled at what it charged: $0 only when monid charged nothing, null (unknown) when it may have and did not say.
|
|
247
247
|
// Paid for, it answers even when this cannot be written, never a failure the model would retry.
|
|
248
248
|
const usd = chargeOf(answer);
|
|
249
|
-
// Written to the run's root when it is set (paid-calls.ts settleIn): a stopped turn's call can no longer commit.
|
|
250
249
|
const settle = { ...label, usd: usd === undefined ? 0 : usd };
|
|
251
|
-
await
|
|
250
|
+
await record(api, TOOL_COST, settle, context).catch(() => undefined);
|
|
252
251
|
return answer;
|
|
253
252
|
};
|
|
254
253
|
// On the runner's one ledger (paid-calls.ts Ledger.paid): held there at the same figure and settled at the same charge
|
|
@@ -273,8 +272,6 @@ export function monidRegistration(kind, env, work) {
|
|
|
273
272
|
},
|
|
274
273
|
});
|
|
275
274
|
}
|
|
276
|
-
/** The three, as another harness's host tools. */
|
|
277
|
-
export const monidTools = (env, work) => KINDS.map((kind) => monidRegistration(kind, env, work));
|
|
278
275
|
/** The table's entry for `monid.<kind>`: it needs MONID_API_KEY, and no workflow node names it yet. */
|
|
279
276
|
export const monidTool = (kind) => ({
|
|
280
277
|
summary: SPECS[kind].summary,
|
package/dist/openapi.d.ts
CHANGED
|
@@ -4,8 +4,15 @@ import "./computers.js";
|
|
|
4
4
|
type Json = Record<string, unknown>;
|
|
5
5
|
/** Why each capability this server turns off answers 501, by the route's capability. */
|
|
6
6
|
export declare const UNSUPPORTED: Readonly<Record<string, string>>;
|
|
7
|
+
/** The contract's operations this server does not serve, and never will as they are: a home's packed export and import
|
|
8
|
+
* (its files are read and written one by one, under /agents/{id}/home/files) and a run's kill (stop and cancel end a
|
|
9
|
+
* run). They are left out of the served document, so no client is generated for them, and their paths answer 404.
|
|
10
|
+
* Capabilities say each is off (home.export, home.import, runs.kill). */
|
|
11
|
+
export declare const NOT_SERVED: readonly string[];
|
|
7
12
|
/** The RUN_FIELDS every run's view and summary hold (runs.ts): required, beside the contract's. */
|
|
8
13
|
export declare const RUN_FIELDS_SENT: string[];
|
|
14
|
+
/** The capabilities every answer carries beside the contract's required ones (server.ts capabilitiesWith). */
|
|
15
|
+
export declare const CAPABILITIES_SENT: string[];
|
|
9
16
|
/** The field every saved sign-in is sent with beside the contract's, required: `secret`, its one secret's metadata
|
|
10
17
|
* (secrets/1, sign-ins-secrets.ts). */
|
|
11
18
|
export declare const SIGN_IN_FIELDS_SENT: string[];
|
|
@@ -13,7 +20,7 @@ export declare const SIGN_IN_FIELDS_SENT: string[];
|
|
|
13
20
|
* instructions, and the server mints or keeps version, skills and tools when a write leaves them out. */
|
|
14
21
|
export declare const DEFINITION_INPUT_OPTIONAL: string[];
|
|
15
22
|
/** Definition's own: only instructions ever misses from an answer (a workflow revision keeps none); version, skills
|
|
16
|
-
* and tools are always sent (agents.ts definitionOf), so they stay required there. */
|
|
23
|
+
* and tools are always sent (agents-store.ts definitionOf), so they stay required there. */
|
|
17
24
|
export declare const DEFINITION_OPTIONAL: string[];
|
|
18
25
|
/** The document: the contract, its operations this server turns off marked with why (`capabilityOf` gives an
|
|
19
26
|
* operation's capability here, by its operationId), and this server's own routes added and marked. */
|