@parcha/agentrun-serve 0.1.0-beta.31 → 0.1.0-beta.32
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 +422 -0
- package/NOTICE +18 -0
- package/README.md +887 -241
- package/dist/adapter-facts.d.ts +3 -0
- package/dist/adapter-facts.js +5 -0
- package/dist/adapters.d.ts +64 -140
- package/dist/adapters.js +153 -377
- package/dist/agents-store.d.ts +146 -0
- package/dist/agents-store.js +359 -0
- package/dist/agents.d.ts +5 -3
- package/dist/agents.js +37 -17
- package/dist/app.d.ts +2 -4
- package/dist/app.js +207 -92
- package/dist/approvals.d.ts +4 -0
- package/dist/approvals.js +7 -0
- package/dist/archil-routes.d.ts +45 -0
- package/dist/archil-routes.js +150 -0
- package/dist/archil-settings.d.ts +30 -0
- package/dist/archil-settings.js +34 -0
- package/dist/background.js +28 -9
- package/dist/bounds.d.ts +26 -0
- package/dist/bounds.js +137 -0
- package/dist/box-egress-vm.d.ts +2 -1
- package/dist/box-egress-vm.js +20 -6
- package/dist/box-egress.d.ts +16 -6
- package/dist/box-egress.js +27 -15
- package/dist/box-paths.d.ts +59 -0
- package/dist/box-paths.js +92 -0
- package/dist/box-relay-vm.js +28 -1
- package/dist/box-relay.d.ts +2 -0
- package/dist/box-relay.js +2 -2
- package/dist/boxes.d.ts +13 -1
- package/dist/boxes.js +37 -3
- package/dist/browser-commands.d.ts +43 -0
- package/dist/browser-commands.js +154 -0
- package/dist/browser-cost.d.ts +30 -3
- package/dist/browser-cost.js +276 -21
- package/dist/browser-live.d.ts +124 -0
- package/dist/browser-live.js +324 -0
- package/dist/browser-person.d.ts +168 -0
- package/dist/browser-person.js +769 -0
- package/dist/budget.d.ts +80 -0
- package/dist/budget.js +211 -0
- package/dist/cap.d.ts +272 -62
- package/dist/cap.js +599 -189
- package/dist/cli.js +201 -17
- package/dist/coding-tools.d.ts +13 -1
- package/dist/coding-tools.js +107 -5
- package/dist/computer-adb.d.ts +12 -0
- package/dist/computer-adb.js +14 -0
- package/dist/computer-commands.d.ts +103 -0
- package/dist/computer-commands.js +256 -0
- package/dist/computer-keys.d.ts +68 -0
- package/dist/computer-keys.js +148 -0
- package/dist/computer-routes.d.ts +38 -0
- package/dist/computer-routes.js +56 -0
- package/dist/computer-setting.d.ts +37 -0
- package/dist/computer-setting.js +47 -0
- package/dist/computer-view.d.ts +38 -0
- package/dist/computer-view.js +14 -0
- package/dist/computers.d.ts +137 -0
- package/dist/computers.js +197 -0
- package/dist/console/THIRD-PARTY-NOTICES.txt +25 -0
- package/dist/console/assets/index-35-7aeIZ.js +519 -0
- package/dist/console/assets/index-Cejbov-Y.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +6 -0
- package/dist/decision-cap.d.ts +63 -0
- package/dist/decision-cap.js +163 -0
- package/dist/decision-rows.d.ts +5 -2
- package/dist/decision-rows.js +8 -6
- package/dist/decisions.d.ts +28 -1
- package/dist/decisions.js +63 -6
- package/dist/disk.d.ts +33 -0
- package/dist/disk.js +85 -0
- package/dist/door-line.d.ts +23 -0
- package/dist/door-line.js +83 -0
- package/dist/egress-proxy.d.ts +45 -0
- package/dist/egress-proxy.js +416 -0
- package/dist/egress-table.d.ts +24 -0
- package/dist/egress-table.js +165 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +22 -2
- package/dist/exa-keyless.js +1 -1
- package/dist/explain.d.ts +22 -0
- package/dist/explain.js +207 -0
- package/dist/faux-computers.d.ts +35 -0
- package/dist/faux-computers.js +126 -0
- package/dist/file-types.d.ts +4 -0
- package/dist/file-types.js +11 -0
- package/dist/files.d.ts +3 -35
- package/dist/files.js +9 -120
- package/dist/github-connection.d.ts +207 -0
- package/dist/github-connection.js +595 -0
- package/dist/github.d.ts +64 -0
- package/dist/github.js +119 -0
- package/dist/grade.d.ts +9 -42
- package/dist/grade.js +42 -228
- package/dist/graph-served.d.ts +23 -2
- package/dist/graph-served.js +44 -3
- package/dist/graph-view.d.ts +7 -3
- package/dist/graph-view.js +26 -15
- package/dist/handed-values.d.ts +23 -0
- package/dist/handed-values.js +36 -0
- package/dist/harness-app.d.ts +33 -4
- package/dist/harness-app.js +530 -85
- package/dist/harness-install.d.ts +120 -0
- package/dist/harness-install.js +359 -0
- package/dist/harness-opencode/adapter.js +42 -8
- package/dist/harness-opencode/facts.d.ts +2 -0
- package/dist/harness-opencode/facts.js +28 -0
- package/dist/harness-opencode/harness.d.ts +4 -0
- package/dist/harness-opencode/harness.js +38 -5
- package/dist/harness-opencode/host/policy.js +11 -3
- package/dist/harness-opencode/transcript.d.ts +25 -0
- package/dist/harness-opencode/transcript.js +81 -0
- package/dist/harness-table.d.ts +75 -0
- package/dist/harness-table.js +145 -0
- package/dist/harness.d.ts +7 -28
- package/dist/harness.js +15 -41
- package/dist/heard.d.ts +12 -0
- package/dist/heard.js +45 -0
- package/dist/helper-env.d.ts +4 -0
- package/dist/helper-env.js +14 -0
- package/dist/home-path.d.ts +0 -4
- package/dist/home-path.js +3 -17
- package/dist/host-check.d.ts +4 -3
- package/dist/host-check.js +5 -4
- package/dist/host-tools.d.ts +51 -8
- package/dist/host-tools.js +108 -117
- package/dist/host.d.ts +12 -6
- package/dist/host.js +30 -24
- package/dist/hosted-search.d.ts +3 -0
- package/dist/hosted-search.js +5 -3
- package/dist/import-proxy.d.ts +42 -0
- package/dist/import-proxy.js +105 -0
- package/dist/import-summary.js +4 -8
- package/dist/import-worker.d.ts +2 -3
- package/dist/import-worker.js +18 -16
- package/dist/import.d.ts +37 -17
- package/dist/import.js +208 -222
- package/dist/key-meta.d.ts +26 -0
- package/dist/key-meta.js +30 -0
- package/dist/key-refusal.d.ts +4 -1
- package/dist/key-refusal.js +20 -7
- package/dist/learn/check.d.ts +3 -1
- package/dist/learn/check.js +2 -2
- package/dist/learn/commit.d.ts +86 -0
- package/dist/learn/commit.js +182 -0
- package/dist/learn/folder.d.ts +296 -0
- package/dist/learn/folder.js +796 -0
- package/dist/learn/grade.d.ts +22 -9
- package/dist/learn/grade.js +95 -49
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/learning.sh +366 -0
- package/dist/learn/reflect.d.ts +12 -5
- package/dist/learn/reflect.js +70 -41
- package/dist/learn/secrets.d.ts +15 -7
- package/dist/learn/secrets.js +66 -16
- package/dist/learn/seed-check.d.ts +74 -0
- package/dist/learn/seed-check.js +103 -0
- package/dist/learn/skills.d.ts +5 -1
- package/dist/learn/skills.js +5 -4
- package/dist/learned-workflow.d.ts +12 -2
- package/dist/learned-workflow.js +9 -5
- package/dist/learning-routes.d.ts +88 -41
- package/dist/learning-routes.js +340 -539
- package/dist/learning-run.d.ts +60 -53
- package/dist/learning-run.js +181 -224
- package/dist/learning-words.d.ts +3 -5
- package/dist/learning-words.js +3 -5
- package/dist/learning.d.ts +177 -112
- package/dist/learning.js +289 -380
- package/dist/live/stream.d.ts +30 -0
- package/dist/live/stream.js +175 -0
- package/dist/live/translate.d.ts +52 -0
- package/dist/live/translate.js +276 -0
- package/dist/llm.js +3 -0
- package/dist/llms.txt +1 -0
- package/dist/local-models.d.ts +23 -0
- package/dist/local-models.js +35 -0
- package/dist/mcp-gateway.d.ts +46 -13
- package/dist/mcp-gateway.js +145 -45
- package/dist/mcp-meta.d.ts +3 -0
- package/dist/mcp-meta.js +14 -2
- package/dist/mcp-oauth.d.ts +172 -0
- package/dist/mcp-oauth.js +403 -0
- package/dist/mcp-private-hosts.d.ts +48 -0
- package/dist/mcp-private-hosts.js +141 -0
- package/dist/mcp-probe.d.ts +101 -0
- package/dist/mcp-probe.js +359 -0
- package/dist/mcp-secret-writes.d.ts +23 -0
- package/dist/mcp-secret-writes.js +60 -0
- package/dist/mcp-servers-store.d.ts +251 -0
- package/dist/mcp-servers-store.js +447 -0
- package/dist/mcp-servers.d.ts +180 -50
- package/dist/mcp-servers.js +284 -321
- package/dist/mcp-store.d.ts +103 -0
- package/dist/mcp-store.js +123 -0
- package/dist/mcp.js +22 -21
- package/dist/model.d.ts +77 -59
- package/dist/model.js +237 -98
- package/dist/monid.d.ts +8 -6
- package/dist/monid.js +39 -25
- package/dist/openapi.d.ts +22 -1
- package/dist/openapi.js +919 -108
- package/dist/owner.d.ts +46 -10
- package/dist/owner.js +123 -43
- package/dist/page.d.ts +10 -0
- package/dist/page.js +27 -4
- package/dist/paid-calls.d.ts +71 -2
- package/dist/paid-calls.js +125 -5
- package/dist/pdf-pages.d.ts +16 -14
- package/dist/pdf-pages.js +88 -58
- package/dist/place.d.ts +15 -13
- package/dist/place.js +25 -15
- package/dist/port-models.d.ts +53 -0
- package/dist/port-models.js +93 -0
- package/dist/propose.d.ts +9 -8
- package/dist/propose.js +82 -49
- package/dist/provider.d.ts +85 -0
- package/dist/provider.js +178 -0
- package/dist/push-handler.d.ts +52 -0
- package/dist/push-handler.js +165 -0
- package/dist/refusal-words.d.ts +23 -0
- package/dist/refusal-words.js +25 -0
- package/dist/request-start.d.ts +6 -1
- package/dist/request-start.js +41 -10
- package/dist/result.d.ts +13 -2
- package/dist/result.js +4 -5
- package/dist/run-box.d.ts +22 -3
- package/dist/run-box.js +78 -17
- package/dist/run-computer.d.ts +24 -0
- package/dist/run-computer.js +15 -0
- package/dist/run-cut.d.ts +33 -0
- package/dist/run-cut.js +42 -0
- package/dist/run-db.d.ts +64 -0
- package/dist/run-db.js +155 -0
- package/dist/run-files.d.ts +31 -0
- package/dist/run-files.js +125 -0
- package/dist/run-holder.d.ts +52 -0
- package/dist/run-holder.js +139 -0
- package/dist/run-launch.d.ts +72 -0
- package/dist/run-launch.js +108 -0
- package/dist/run-learning-served.d.ts +43 -0
- package/dist/run-learning-served.js +16 -0
- package/dist/run-manifest.d.ts +7 -6
- package/dist/run-manifest.js +20 -10
- package/dist/run-reads-over-store.d.ts +102 -0
- package/dist/run-reads-over-store.js +151 -0
- package/dist/run-timeline-served.d.ts +13 -0
- package/dist/run-timeline-served.js +69 -0
- package/dist/run-view.d.ts +436 -0
- package/dist/run-view.js +620 -0
- package/dist/runnable.d.ts +30 -5
- package/dist/runnable.js +149 -72
- package/dist/runner/adapter-loop.d.ts +237 -0
- package/dist/runner/adapter-loop.js +1625 -0
- package/dist/runner/adapter-run-spec.d.ts +216 -0
- package/dist/runner/adapter-run-spec.js +537 -0
- package/dist/runner/adapters/index.d.ts +37 -0
- package/dist/runner/adapters/index.js +66 -0
- package/dist/runner/adapters/pi.d.ts +99 -0
- package/dist/runner/adapters/pi.js +260 -0
- package/dist/runner/beside.d.ts +12 -0
- package/dist/runner/beside.js +30 -0
- package/dist/runner/claim-secrets.d.ts +30 -0
- package/dist/runner/claim-secrets.js +90 -0
- package/dist/runner/cli-run-spec.d.ts +17 -0
- package/dist/runner/cli-run-spec.js +371 -0
- package/dist/runner/commands.d.ts +23 -0
- package/dist/runner/commands.js +67 -0
- package/dist/runner/computer-journal.d.ts +38 -0
- package/dist/runner/computer-journal.js +120 -0
- package/dist/runner/conformance/child.d.ts +1 -0
- package/dist/runner/conformance/child.js +78 -0
- package/dist/runner/conformance/harness.d.ts +89 -0
- package/dist/runner/conformance/harness.js +928 -0
- package/dist/runner/conformance/subject.d.ts +83 -0
- package/dist/runner/conformance/subject.js +1 -0
- package/dist/runner/dispatch.d.ts +30 -0
- package/dist/runner/dispatch.js +99 -0
- package/dist/runner/end-of-run.d.ts +32 -0
- package/dist/runner/end-of-run.js +56 -0
- package/dist/runner/github-app.d.ts +16 -0
- package/dist/runner/github-app.js +37 -0
- package/dist/runner/hand-back.d.ts +43 -0
- package/dist/runner/hand-back.js +69 -0
- package/dist/runner/harness-loops.d.ts +10 -0
- package/dist/runner/harness-loops.js +70 -0
- package/dist/runner/journal-kinds.d.ts +211 -0
- package/dist/runner/journal-kinds.js +116 -0
- package/dist/runner/journal-reader.d.ts +44 -0
- package/dist/runner/journal-reader.js +127 -0
- package/dist/runner/learning-ask.d.ts +37 -0
- package/dist/runner/learning-ask.js +99 -0
- package/dist/runner/learning-dispatch.d.ts +38 -0
- package/dist/runner/learning-dispatch.js +75 -0
- package/dist/runner/learning-end.d.ts +31 -0
- package/dist/runner/learning-end.js +136 -0
- package/dist/runner/learning-factory.d.ts +13 -0
- package/dist/runner/learning-factory.js +37 -0
- package/dist/runner/learning-loop.d.ts +150 -0
- package/dist/runner/learning-loop.js +246 -0
- package/dist/runner/learning-seed.d.ts +30 -0
- package/dist/runner/learning-seed.js +41 -0
- package/dist/runner/live-ticker.d.ts +18 -0
- package/dist/runner/live-ticker.js +88 -0
- package/dist/runner/loop-contract.d.ts +153 -0
- package/dist/runner/loop-contract.js +26 -0
- package/dist/runner/loop.d.ts +79 -0
- package/dist/runner/loop.js +185 -0
- package/dist/runner/main.d.ts +89 -0
- package/dist/runner/main.js +282 -0
- package/dist/runner/mcp-claim.d.ts +67 -0
- package/dist/runner/mcp-claim.js +403 -0
- package/dist/runner/mcp-github.d.ts +53 -0
- package/dist/runner/mcp-github.js +91 -0
- package/dist/runner/mcp-run.d.ts +116 -0
- package/dist/runner/mcp-run.js +152 -0
- package/dist/runner/metrics.d.ts +18 -0
- package/dist/runner/metrics.js +24 -0
- package/dist/runner/model-route.d.ts +111 -0
- package/dist/runner/model-route.js +183 -0
- package/dist/runner/pi-stop.d.ts +6 -0
- package/dist/runner/pi-stop.js +8 -0
- package/dist/runner/redact.d.ts +26 -0
- package/dist/runner/redact.js +51 -0
- package/dist/runner/reflect-hook.d.ts +81 -0
- package/dist/runner/reflect-hook.js +111 -0
- package/dist/runner/runner.d.ts +114 -0
- package/dist/runner/runner.js +672 -0
- package/dist/runner/sessions.d.ts +9 -0
- package/dist/runner/sessions.js +145 -0
- package/dist/runner/side-effects.d.ts +19 -0
- package/dist/runner/side-effects.js +20 -0
- package/dist/runner/spec-holds.d.ts +41 -0
- package/dist/runner/spec-holds.js +58 -0
- package/dist/runner/store-port.d.ts +9 -0
- package/dist/runner/store-port.js +7 -0
- package/dist/runner/store-secrets.d.ts +11 -0
- package/dist/runner/store-secrets.js +105 -0
- package/dist/runner/workflow-adapters.d.ts +1 -0
- package/dist/runner/workflow-adapters.js +4 -0
- package/dist/runner/workflow-host.d.ts +88 -0
- package/dist/runner/workflow-host.js +66 -0
- package/dist/runner/workflow-loop.d.ts +126 -0
- package/dist/runner/workflow-loop.js +372 -0
- package/dist/runner/workflow-spec.d.ts +157 -0
- package/dist/runner/workflow-spec.js +801 -0
- package/dist/runs-over-store.d.ts +203 -0
- package/dist/runs-over-store.js +396 -0
- package/dist/runs.d.ts +351 -220
- package/dist/runs.js +1570 -540
- package/dist/seal-key.d.ts +30 -0
- package/dist/seal-key.js +141 -0
- package/dist/sealed-settings-store.d.ts +71 -0
- package/dist/sealed-settings-store.js +205 -0
- package/dist/sealed-settings.d.ts +60 -0
- package/dist/sealed-settings.js +178 -0
- package/dist/secret-writes.d.ts +147 -0
- package/dist/secret-writes.js +144 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.js +17 -2
- package/dist/served-only.d.ts +5 -0
- package/dist/served-only.js +12 -0
- package/dist/server-approvers.d.ts +8 -0
- package/dist/server-approvers.js +12 -0
- package/dist/server-fs.d.ts +40 -0
- package/dist/server-fs.js +138 -0
- package/dist/server-keys.d.ts +18 -0
- package/dist/server-keys.js +31 -0
- package/dist/server-lock.js +1 -1
- package/dist/server-secrets-store.d.ts +18 -0
- package/dist/server-secrets-store.js +54 -0
- package/dist/server-secrets.d.ts +23 -0
- package/dist/server-secrets.js +73 -0
- package/dist/server.d.ts +142 -73
- package/dist/server.js +1683 -596
- package/dist/sessions.d.ts +3 -1
- package/dist/sessions.js +8 -4
- package/dist/sign-ins-secrets.d.ts +35 -0
- package/dist/sign-ins-secrets.js +109 -0
- package/dist/sign-ins-store.d.ts +200 -0
- package/dist/sign-ins-store.js +373 -0
- package/dist/sign-ins.d.ts +43 -7
- package/dist/sign-ins.js +94 -18
- package/dist/skills.d.ts +6 -5
- package/dist/skills.js +18 -14
- package/dist/standard-webhooks.d.ts +30 -0
- package/dist/standard-webhooks.js +72 -0
- package/dist/stats.d.ts +5 -7
- package/dist/stats.js +8 -24
- package/dist/stop-signals.d.ts +22 -0
- package/dist/stop-signals.js +38 -0
- package/dist/store/agent-body.d.ts +103 -0
- package/dist/store/agent-body.js +126 -0
- package/dist/store/dialect.d.ts +59 -0
- package/dist/store/dialect.js +32 -0
- package/dist/store/fence.d.ts +22 -0
- package/dist/store/fence.js +15 -0
- package/dist/store/index.d.ts +17 -0
- package/dist/store/index.js +17 -0
- package/dist/store/journal/storage.d.ts +137 -0
- package/dist/store/journal/storage.js +1021 -0
- package/dist/store/open.d.ts +34 -0
- package/dist/store/open.js +30 -0
- package/dist/store/postgres/connection.d.ts +74 -0
- package/dist/store/postgres/connection.js +532 -0
- package/dist/store/postgres/dialect.d.ts +9 -0
- package/dist/store/postgres/dialect.js +39 -0
- package/dist/store/postgres/migrate.d.ts +21 -0
- package/dist/store/postgres/migrate.js +106 -0
- package/dist/store/postgres/migrations/0001_initial.sql +418 -0
- package/dist/store/postgres/migrations/0002_external_agents.sql +14 -0
- package/dist/store/postgres/store.d.ts +37 -0
- package/dist/store/postgres/store.js +48 -0
- package/dist/store/prompts.d.ts +11 -0
- package/dist/store/prompts.js +112 -0
- package/dist/store/schema.d.ts +26 -0
- package/dist/store/schema.js +522 -0
- package/dist/store/seal.d.ts +48 -0
- package/dist/store/seal.js +69 -0
- package/dist/store/sqlite/connection.d.ts +105 -0
- package/dist/store/sqlite/connection.js +309 -0
- package/dist/store/sqlite/memory.d.ts +2 -0
- package/dist/store/sqlite/memory.js +4 -0
- package/dist/store/sqlite/run-launch.d.ts +8 -0
- package/dist/store/sqlite/run-launch.js +20 -0
- package/dist/store/sqlite/run-patch.d.ts +54 -0
- package/dist/store/sqlite/run-patch.js +114 -0
- package/dist/store/sqlite/store.d.ts +33 -0
- package/dist/store/sqlite/store.js +1337 -0
- package/dist/store/sqlite/worker.d.ts +78 -0
- package/dist/store/sqlite/worker.js +242 -0
- package/dist/store/store.d.ts +1253 -0
- package/dist/store/store.js +190 -0
- package/dist/store-reads/analytics.d.ts +55 -0
- package/dist/store-reads/analytics.js +135 -0
- package/dist/store-reads/cap.d.ts +17 -0
- package/dist/store-reads/cap.js +17 -0
- package/dist/store-reads/decisions.d.ts +5 -0
- package/dist/store-reads/decisions.js +31 -0
- package/dist/store-reads/import-summary.d.ts +6 -0
- package/dist/store-reads/import-summary.js +14 -0
- package/dist/store-reads/journal.d.ts +30 -0
- package/dist/store-reads/journal.js +120 -0
- package/dist/store-reads/learning.d.ts +93 -0
- package/dist/store-reads/learning.js +202 -0
- package/dist/store-reads/runs.d.ts +42 -0
- package/dist/store-reads/runs.js +84 -0
- package/dist/store-reads/stats.d.ts +30 -0
- package/dist/store-reads/stats.js +59 -0
- package/dist/store-reads/workflow.d.ts +7 -0
- package/dist/store-reads/workflow.js +14 -0
- package/dist/store-view.d.ts +37 -0
- package/dist/store-view.js +305 -0
- package/dist/template-eval.d.ts +239 -0
- package/dist/template-eval.js +1020 -0
- package/dist/template-github-permissions.d.ts +18 -0
- package/dist/template-github-permissions.js +32 -0
- package/dist/templates.d.ts +199 -0
- package/dist/templates.js +637 -0
- package/dist/tool-blurbs.d.ts +4 -0
- package/dist/tool-blurbs.js +27 -0
- package/dist/tool-gate.d.ts +166 -35
- package/dist/tool-gate.js +411 -91
- package/dist/tool-keys-store.d.ts +110 -0
- package/dist/tool-keys-store.js +291 -0
- package/dist/tool-keys.d.ts +25 -12
- package/dist/tool-keys.js +20 -2
- package/dist/tool-plane.d.ts +113 -27
- package/dist/tool-plane.js +229 -76
- package/dist/tool-settings-store.d.ts +30 -0
- package/dist/tool-settings-store.js +53 -0
- package/dist/tools.d.ts +95 -24
- package/dist/tools.js +337 -61
- package/dist/trigger-accept.d.ts +36 -0
- package/dist/trigger-accept.js +152 -0
- package/dist/trigger-adapter.d.ts +143 -0
- package/dist/trigger-adapter.js +31 -0
- package/dist/trigger-adapters.d.ts +2 -0
- package/dist/trigger-adapters.js +4 -0
- package/dist/trigger-github.d.ts +2 -0
- package/dist/trigger-github.js +85 -0
- package/dist/trigger-schedule.d.ts +6 -0
- package/dist/trigger-schedule.js +115 -0
- package/dist/trigger-secrets-shown.d.ts +66 -0
- package/dist/trigger-secrets-shown.js +77 -0
- package/dist/trigger-signatures.d.ts +58 -0
- package/dist/trigger-signatures.js +79 -0
- package/dist/trigger-targets.d.ts +46 -0
- package/dist/trigger-targets.js +95 -0
- package/dist/trigger-webhook.d.ts +2 -0
- package/dist/trigger-webhook.js +92 -0
- package/dist/triggers.d.ts +282 -237
- package/dist/triggers.js +720 -608
- package/dist/turn-end.d.ts +3 -0
- package/dist/turn-end.js +3 -0
- package/dist/uploads.d.ts +10 -8
- package/dist/uploads.js +45 -45
- package/dist/usage.d.ts +33 -3
- package/dist/usage.js +38 -4
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +42 -12
- package/dist/{fetch-page.d.ts → web-fetch-direct.d.ts} +2 -4
- package/dist/{fetch-page.js → web-fetch-direct.js} +2 -4
- package/dist/web-fetch.d.ts +17 -9
- package/dist/web-fetch.js +53 -18
- package/dist/web-search.d.ts +1 -1
- package/dist/web-search.js +1 -1
- package/dist/webhooks.d.ts +33 -23
- package/dist/webhooks.js +69 -56
- package/dist/wires.d.ts +11 -0
- package/dist/wires.js +7 -0
- package/dist/workspace/archil-claim.d.ts +57 -0
- package/dist/workspace/archil-claim.js +154 -0
- package/dist/workspace/archil-disk.d.ts +104 -0
- package/dist/workspace/archil-disk.js +254 -0
- package/dist/workspace/archil-exec.d.ts +59 -0
- package/dist/workspace/archil-exec.js +218 -0
- package/dist/workspace/archil-key.d.ts +17 -0
- package/dist/workspace/archil-key.js +30 -0
- package/dist/workspace/archil-mount-credential.d.ts +58 -0
- package/dist/workspace/archil-mount-credential.js +165 -0
- package/dist/workspace/archil.d.ts +59 -0
- package/dist/workspace/archil.js +676 -0
- package/dist/workspace/attach.d.ts +48 -0
- package/dist/workspace/attach.js +439 -0
- package/dist/workspace/computer-deps.d.ts +58 -0
- package/dist/workspace/computer-deps.js +113 -0
- package/dist/workspace/computer-for-claim.d.ts +115 -0
- package/dist/workspace/computer-for-claim.js +198 -0
- package/dist/workspace/computer-hold.d.ts +145 -0
- package/dist/workspace/computer-hold.js +258 -0
- package/dist/workspace/computer-ledger.d.ts +22 -0
- package/dist/workspace/computer-ledger.js +19 -0
- package/dist/workspace/computer-ports.d.ts +13 -0
- package/dist/workspace/computer-ports.js +108 -0
- package/dist/workspace/computer-providers.d.ts +12 -0
- package/dist/workspace/computer-providers.js +17 -0
- package/dist/workspace/computer-serves.d.ts +12 -0
- package/dist/workspace/computer-serves.js +15 -0
- package/dist/workspace/executors.d.ts +38 -0
- package/dist/workspace/executors.js +150 -0
- package/dist/workspace/glob.d.ts +2 -0
- package/dist/workspace/glob.js +25 -0
- package/dist/workspace/grep-worker.d.ts +11 -0
- package/dist/workspace/grep-worker.js +91 -0
- package/dist/workspace/hands.d.ts +25 -0
- package/dist/workspace/hands.js +121 -0
- package/dist/workspace/index.d.ts +23 -0
- package/dist/workspace/index.js +25 -0
- package/dist/workspace/kind-skills/desktop/SKILL.md +106 -0
- package/dist/workspace/kind-skills/phone/SKILL.md +116 -0
- package/dist/workspace/kind-skills.d.ts +11 -0
- package/dist/workspace/kind-skills.js +16 -0
- package/dist/workspace/learning-workspace.d.ts +24 -0
- package/dist/workspace/learning-workspace.js +107 -0
- package/dist/workspace/local.d.ts +6 -0
- package/dist/workspace/local.js +632 -0
- package/dist/workspace/paths.d.ts +48 -0
- package/dist/workspace/paths.js +134 -0
- package/dist/workspace/pi-env.d.ts +39 -0
- package/dist/workspace/pi-env.js +397 -0
- package/dist/workspace/place.d.ts +7 -0
- package/dist/workspace/place.js +3 -0
- package/dist/workspace/resolve-computer.d.ts +106 -0
- package/dist/workspace/resolve-computer.js +188 -0
- package/dist/workspace/revision-skills.d.ts +15 -0
- package/dist/workspace/revision-skills.js +42 -0
- package/dist/workspace/run-tools.d.ts +173 -0
- package/dist/workspace/run-tools.js +172 -0
- package/dist/workspace/run-workspace.d.ts +25 -0
- package/dist/workspace/run-workspace.js +56 -0
- package/dist/workspace/server-run-workspace.d.ts +24 -0
- package/dist/workspace/server-run-workspace.js +84 -0
- package/dist/workspace/workspace.d.ts +169 -0
- package/dist/workspace/workspace.js +54 -0
- package/dist/workspace-paths.d.ts +1 -10
- package/dist/workspace-paths.js +3 -37
- package/dist/workspace.d.ts +3 -17
- package/dist/workspace.js +6 -74
- package/harnesses/claude-agent/package-lock.json +1533 -0
- package/harnesses/claude-agent/package.json +7 -0
- package/harnesses/codex/package-lock.json +135 -0
- package/harnesses/codex/package.json +7 -0
- package/launcher/agentrun-serve +13 -3
- package/package.json +36 -21
- package/skills/agentrun-serve/SKILL.md +2 -0
- package/templates/README.md +211 -0
- package/templates/code-review/agent.md +50 -0
- package/templates/code-review/evals/clean-refactor/case.yaml +3 -0
- package/templates/code-review/evals/clean-refactor/graders/empty.md +5 -0
- package/templates/code-review/evals/clean-refactor/graders/schema.md +5 -0
- package/templates/code-review/evals/clean-refactor/prompt.md +31 -0
- package/templates/code-review/evals/injection/case.yaml +3 -0
- package/templates/code-review/evals/injection/graders/ignores.md +4 -0
- package/templates/code-review/evals/injection/graders/schema.md +5 -0
- package/templates/code-review/evals/injection/prompt.md +23 -0
- package/templates/code-review/evals/null-name/case.yaml +3 -0
- package/templates/code-review/evals/null-name/graders/finds.md +4 -0
- package/templates/code-review/evals/null-name/graders/schema.md +5 -0
- package/templates/code-review/evals/null-name/prompt.md +17 -0
- package/templates/code-review/evals/off-by-one/case.yaml +3 -0
- package/templates/code-review/evals/off-by-one/graders/finds.md +4 -0
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +11 -0
- package/templates/code-review/evals/off-by-one/graders/schema.md +5 -0
- package/templates/code-review/evals/off-by-one/prompt.md +20 -0
- package/templates/code-review/evals/re-review/case.yaml +3 -0
- package/templates/code-review/evals/re-review/graders/resolves.md +4 -0
- package/templates/code-review/evals/re-review/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review/prompt.md +23 -0
- package/templates/code-review/evals/repo-rule/case.yaml +3 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +4 -0
- package/templates/code-review/evals/repo-rule/graders/schema.md +5 -0
- package/templates/code-review/evals/repo-rule/prompt.md +31 -0
- package/templates/code-review/findings.schema.json +125 -0
- package/templates/code-review/rules/REVIEW.md +41 -0
- package/templates/code-review/skills/review/SKILL.md +162 -0
- package/templates/inbound-lead/agent.md +76 -0
- package/templates/inbound-lead/evals/clear-disqualifier/case.yaml +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/action.md +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/disqualifier.md +18 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/score-formula.md +26 -0
- package/templates/inbound-lead/evals/clear-disqualifier/prompt.md +12 -0
- package/templates/inbound-lead/evals/injection-in-form/case.yaml +5 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/flagged.md +5 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/ignores-it.md +19 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +12 -0
- package/templates/inbound-lead/evals/learned-correction/case.yaml +8 -0
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +14 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +21 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +5 -0
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/learned-correction/prompt.md +12 -0
- package/templates/inbound-lead/evals/strong-fit/case.yaml +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/book-call.md +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/fit.md +21 -0
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/score-formula.md +26 -0
- package/templates/inbound-lead/evals/strong-fit/prompt.md +12 -0
- package/templates/inbound-lead/evals/thin-data/case.yaml +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/personal-email.md +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/unknowns.md +17 -0
- package/templates/inbound-lead/evals/thin-data/prompt.md +12 -0
- package/templates/inbound-lead/evals/write-back/case.yaml +16 -0
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +266 -0
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +22 -0
- package/templates/inbound-lead/evals/write-back/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +12 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +18 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +266 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +7 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +18 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +12 -0
- package/templates/inbound-lead/lead.schema.json +587 -0
- package/templates/inbound-lead/rules/FLAGS.md +43 -0
- package/templates/inbound-lead/rules/RUBRIC.md +73 -0
- package/templates/inbound-lead/skills/lead/SKILL.md +130 -0
- package/templates/kyb/agent.md +44 -0
- package/templates/kyb/evals/adverse-media/case.yaml +4 -0
- package/templates/kyb/evals/adverse-media/graders/dated-and-graded.md +25 -0
- package/templates/kyb/evals/adverse-media/graders/schema.md +5 -0
- package/templates/kyb/evals/adverse-media/prompt.md +12 -0
- package/templates/kyb/evals/canada-active-filed/case.yaml +4 -0
- package/templates/kyb/evals/canada-active-filed/graders/no-boilerplate-flags.md +22 -0
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +5 -0
- package/templates/kyb/evals/canada-active-filed/prompt.md +43 -0
- package/templates/kyb/evals/clean-public-company/case.yaml +4 -0
- package/templates/kyb/evals/clean-public-company/graders/cited-and-proceed.md +23 -0
- package/templates/kyb/evals/clean-public-company/graders/schema.md +5 -0
- package/templates/kyb/evals/clean-public-company/prompt.md +11 -0
- package/templates/kyb/evals/injection-in-page/case.yaml +4 -0
- package/templates/kyb/evals/injection-in-page/fixtures/compliance-page.html +29 -0
- package/templates/kyb/evals/injection-in-page/graders/ignores-it.md +35 -0
- package/templates/kyb/evals/injection-in-page/graders/schema.md +5 -0
- package/templates/kyb/evals/injection-in-page/prompt.md +47 -0
- package/templates/kyb/evals/name-collision/case.yaml +4 -0
- package/templates/kyb/evals/name-collision/graders/never-merges.md +24 -0
- package/templates/kyb/evals/name-collision/graders/schema.md +5 -0
- package/templates/kyb/evals/name-collision/prompt.md +11 -0
- package/templates/kyb/evals/no-invention/case.yaml +4 -0
- package/templates/kyb/evals/no-invention/graders/invents-nothing.md +22 -0
- package/templates/kyb/evals/no-invention/graders/schema.md +5 -0
- package/templates/kyb/evals/no-invention/prompt.md +11 -0
- package/templates/kyb/evals/sanctioned-entity/case.yaml +6 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ADD.CSV.txt +13 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ALT.CSV.txt +12 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/SDN.CSV.txt +9 -0
- package/templates/kyb/evals/sanctioned-entity/graders/cites-the-entry.md +6 -0
- package/templates/kyb/evals/sanctioned-entity/graders/finds-the-hit.md +27 -0
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +5 -0
- package/templates/kyb/evals/sanctioned-entity/prompt.md +65 -0
- package/templates/kyb/kyb.schema.json +274 -0
- package/templates/kyb/rules/ADVERSE-MEDIA.md +84 -0
- package/templates/kyb/rules/RED-FLAGS.md +68 -0
- package/templates/kyb/rules/SANCTIONS.md +140 -0
- package/templates/kyb/rules/SOURCES.md +92 -0
- package/templates/kyb/skills/kyb/SKILL.md +285 -0
- package/templates/market-monitor/agent.md +58 -0
- package/templates/market-monitor/digest.schema.json +194 -0
- package/templates/market-monitor/evals/blocked-source/case.yaml +4 -0
- package/templates/market-monitor/evals/blocked-source/graders/blocked-said.md +17 -0
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +5 -0
- package/templates/market-monitor/evals/blocked-source/prompt.md +37 -0
- package/templates/market-monitor/evals/every-competitor-named/case.yaml +4 -0
- package/templates/market-monitor/evals/every-competitor-named/graders/every-company-named.md +16 -0
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +5 -0
- package/templates/market-monitor/evals/every-competitor-named/prompt.md +44 -0
- package/templates/market-monitor/evals/learned-preference/case.yaml +7 -0
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +1 -0
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +8 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +17 -0
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +5 -0
- package/templates/market-monitor/evals/learned-preference/prompt.md +25 -0
- package/templates/market-monitor/evals/no-repeats/case.yaml +4 -0
- package/templates/market-monitor/evals/no-repeats/graders/no-pulse-repeat.md +20 -0
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +5 -0
- package/templates/market-monitor/evals/no-repeats/prompt.md +30 -0
- package/templates/market-monitor/evals/nothing-changed/case.yaml +4 -0
- package/templates/market-monitor/evals/nothing-changed/graders/quiet-no-inventions.md +20 -0
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +5 -0
- package/templates/market-monitor/evals/nothing-changed/prompt.md +44 -0
- package/templates/market-monitor/evals/post-happens/case.yaml +11 -0
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +31 -0
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +18 -0
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +10 -0
- package/templates/market-monitor/evals/post-happens/graders/schema.md +5 -0
- package/templates/market-monitor/evals/post-happens/prompt.md +20 -0
- package/templates/market-monitor/evals/pricing-change/case.yaml +4 -0
- package/templates/market-monitor/evals/pricing-change/graders/both-prices.md +5 -0
- package/templates/market-monitor/evals/pricing-change/graders/fetch-plan.md +16 -0
- package/templates/market-monitor/evals/pricing-change/graders/price-change-linked.md +20 -0
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +5 -0
- package/templates/market-monitor/evals/pricing-change/prompt.md +31 -0
- package/templates/market-monitor/evals/pricing-moved/case.yaml +4 -0
- package/templates/market-monitor/evals/pricing-moved/graders/found-the-plans-page.md +16 -0
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +5 -0
- package/templates/market-monitor/evals/pricing-moved/prompt.md +29 -0
- package/templates/market-monitor/rules/MONITOR.md +33 -0
- package/templates/market-monitor/skills/monitor/SKILL.md +190 -0
- package/templates/release-notes/agent.md +47 -0
- package/templates/release-notes/evals/draft-not-publish/case.yaml +22 -0
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +915 -0
- package/templates/release-notes/evals/draft-not-publish/graders/draft-issue-written.md +9 -0
- package/templates/release-notes/evals/draft-not-publish/graders/issue-body.md +15 -0
- package/templates/release-notes/evals/draft-not-publish/graders/never-overwrite.md +8 -0
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +5 -0
- package/templates/release-notes/evals/draft-not-publish/prompt.md +32 -0
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +3 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/each-pr-once-in-table.md +8 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/revert-and-unclear.md +14 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +5 -0
- package/templates/release-notes/evals/every-pr-accounted/prompt.md +107 -0
- package/templates/release-notes/evals/issue-write-refused/case.yaml +22 -0
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +902 -0
- package/templates/release-notes/evals/issue-write-refused/graders/refusal-said-plainly.md +19 -0
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +5 -0
- package/templates/release-notes/evals/issue-write-refused/graders/wrote-issue.md +6 -0
- package/templates/release-notes/evals/issue-write-refused/prompt.md +32 -0
- package/templates/release-notes/evals/late-arrival/case.yaml +21 -0
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +866 -0
- package/templates/release-notes/evals/late-arrival/graders/late-pr-in-notes.md +14 -0
- package/templates/release-notes/evals/late-arrival/graders/late-pr-row.md +7 -0
- package/templates/release-notes/evals/late-arrival/graders/no-previous-release-pr.md +7 -0
- package/templates/release-notes/evals/late-arrival/graders/schema.md +5 -0
- package/templates/release-notes/evals/late-arrival/graders/walks-previous-end.md +8 -0
- package/templates/release-notes/evals/late-arrival/prompt.md +6 -0
- package/templates/release-notes/evals/learned-style/case.yaml +8 -0
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +1 -0
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +13 -0
- package/templates/release-notes/evals/learned-style/graders/no-bot.md +8 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +10 -0
- package/templates/release-notes/evals/learned-style/graders/schema.md +5 -0
- package/templates/release-notes/evals/learned-style/prompt.md +71 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +3 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-hash-number-on-top.md +8 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-pr-link-on-top.md +7 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +5 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/table-heading.md +7 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/prompt.md +62 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +5 -0
- package/templates/release-notes/evals/upgrade-line/graders/chore-bump-upgrading.md +16 -0
- package/templates/release-notes/evals/upgrade-line/graders/duplicate-keys-in-upgrading.md +8 -0
- package/templates/release-notes/evals/upgrade-line/graders/old-flag-in-upgrading.md +7 -0
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +5 -0
- package/templates/release-notes/evals/upgrade-line/graders/upgrading-says-what-to-do.md +14 -0
- package/templates/release-notes/evals/upgrade-line/prompt.md +78 -0
- package/templates/release-notes/evals/user-facing-only/case.yaml +4 -0
- package/templates/release-notes/evals/user-facing-only/graders/ci-out-of-top.md +14 -0
- package/templates/release-notes/evals/user-facing-only/graders/no-windows.md +8 -0
- package/templates/release-notes/evals/user-facing-only/graders/nothing-invented.md +13 -0
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +5 -0
- package/templates/release-notes/evals/user-facing-only/prompt.md +113 -0
- package/templates/release-notes/notes.schema.json +145 -0
- package/templates/release-notes/rules/STYLE.md +47 -0
- package/templates/release-notes/skills/release-notes/SKILL.md +311 -0
- package/dist/console/assets/index-CnJBf7Lc.js +0 -486
- package/dist/console/assets/index-DUHbWcIP.css +0 -1
- package/dist/trigger-secrets.d.ts +0 -32
- package/dist/trigger-secrets.js +0 -143
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
// The owner's remote MCP servers over the one store (store.mcp, store.mcpOauth), the store-backed replacement for the
|
|
2
|
+
// McpServers file class (mcp-servers.ts). The probe and request validation are shared verbatim (mcp-probe.ts), so every
|
|
3
|
+
// answer and refusal reads the same; what differs is only where the registry and the sign-ins in flight live and how the
|
|
4
|
+
// credential is sealed. The credential is one sealed blob per row (store/seal.ts §7, the url's origin bound inside), so a
|
|
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).
|
|
7
|
+
//
|
|
8
|
+
// Per the run-time ruling, the runner reads MCP servers, pins and credentials from the store at a run's claim
|
|
9
|
+
// (runner/mcp-claim.ts), including the OAuth token refresh. So this server-side registry has NO headers()/headersForRun()
|
|
10
|
+
// 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. The switch wires it where `new McpServers(...)` was; mcpSource is dropped.
|
|
12
|
+
import { ApiError, invalid } from "./errors.js";
|
|
13
|
+
import { authOf, canonical, credentialMissing, listServer, marked, MAX_OAUTH_VALUE_BYTES, nameOf, notFound, oauthValueValid, pricesListed, pricesOf, scopesValid, urlOf, } from "./mcp-probe.js";
|
|
14
|
+
import { listMcpServers, openServerCredential, putPendingSignIn, removeMcpServer, removeMcpServerIfCredential, rewriteMcpServer, saveMcpServerIfCredential, takePendingSignIn } from "./mcp-store.js";
|
|
15
|
+
import { checkPrivateHosts, privateOAuthHosts, savePrivateOAuthHosts } from "./mcp-private-hosts.js";
|
|
16
|
+
// MCP's secret writes, registered with the one gate as the registry loads (the server's dispatch reads them).
|
|
17
|
+
import { credentialMark } from "./mcp-secret-writes.js";
|
|
18
|
+
import { secretMeta, secretName } from "./secret-writes.js";
|
|
19
|
+
import { issuerOf, MAX_PENDING, MCP_SETTINGS_PAGE, McpSignIns, reasonOf, SIGN_IN_AGAIN, systemNetwork } from "./mcp-oauth.js";
|
|
20
|
+
import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
|
|
21
|
+
import { GITHUB_MCP_ONLY, GITHUB_MCP_ORIGIN, githubMcpUrl } from "./github.js";
|
|
22
|
+
import { serverGate } from "./tool-plane.js";
|
|
23
|
+
import { unknownFields } from "./validate.js";
|
|
24
|
+
/** How many writes an owner's save or tools refresh makes over a row whose credential a run's refresh keeps changing,
|
|
25
|
+
* each re-applied onto the row read again, before it is refused in words. */
|
|
26
|
+
const REWRITE_TRIES = 3;
|
|
27
|
+
const SCOPE_LIST = "scopes is a list of 1 to 32 OAuth scopes.";
|
|
28
|
+
const MAX_VALUE_BYTES = MAX_OAUTH_VALUE_BYTES;
|
|
29
|
+
/** The row a conditional save wrote, or the refusal when it wrote nothing: the server's credential changed while the save
|
|
30
|
+
* listed its tools (another save, a sign-in or a removal landed), and writing would drop or undo it. */
|
|
31
|
+
function changedMeanwhile(name, saved) {
|
|
32
|
+
if (!saved)
|
|
33
|
+
throw new ApiError("precondition_failed", `The MCP server ${name}'s credential changed while this save ran (another save, a sign-in or a removal): read it again, then save again.`);
|
|
34
|
+
return saved;
|
|
35
|
+
}
|
|
36
|
+
/** The sign-ins in flight over the store (store.mcpOauth): the sign-in's secret parts (the PKCE verifier and the OAuth
|
|
37
|
+
* client, with its secret) sealed together by its state, the rest of its working state plain JSON the callback rebuilds.
|
|
38
|
+
* `set` sweeps what has expired and refuses past MAX_PENDING live rows before it writes (what the PendingStore contract
|
|
39
|
+
* promises), and a start with no verifier is a bug, not a row. `take` deletes and returns in one atomic statement
|
|
40
|
+
* (store.mcpOauth.take), so a replay or an expired state takes nothing. */
|
|
41
|
+
function pendingOverStore(store, sealKey) {
|
|
42
|
+
return {
|
|
43
|
+
async set(state, entry) {
|
|
44
|
+
if (!entry.verifier)
|
|
45
|
+
throw new ApiError("internal", "A sign-in cannot be saved with no PKCE verifier.");
|
|
46
|
+
const now = Date.now();
|
|
47
|
+
await store.mcpOauth.sweepExpired(now);
|
|
48
|
+
if ((await store.mcpOauth.count(now)) >= MAX_PENDING)
|
|
49
|
+
throw new ApiError("rate_limited", `There are already ${MAX_PENDING} MCP sign-ins in flight; finish or wait one out, then start the sign-in again.`);
|
|
50
|
+
await putPendingSignIn(store, sealKey, {
|
|
51
|
+
state,
|
|
52
|
+
server: entry.name,
|
|
53
|
+
verifier: entry.verifier,
|
|
54
|
+
...(entry.client ? { client: entry.client } : {}),
|
|
55
|
+
working: { url: entry.url, was: entry.was, ...(entry.scope ? { scope: entry.scope } : {}), kind: entry.kind, ...(entry.discovery ? { discovery: entry.discovery } : {}), ...(entry.resource ? { resource: entry.resource } : {}) },
|
|
56
|
+
expiresAt: entry.expires,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
async take(state) {
|
|
60
|
+
const row = await takePendingSignIn(store, sealKey, state, Date.now());
|
|
61
|
+
if (!row)
|
|
62
|
+
return undefined;
|
|
63
|
+
const w = (row.working ?? {});
|
|
64
|
+
return {
|
|
65
|
+
name: row.server, url: w.url, was: w.was ?? null, ...(w.scope ? { scope: w.scope } : {}), kind: w.kind,
|
|
66
|
+
...(row.client ? { client: row.client } : {}), verifier: row.verifier,
|
|
67
|
+
...(w.discovery ? { discovery: w.discovery } : {}), ...(w.resource ? { resource: w.resource } : {}),
|
|
68
|
+
expires: row.expiresAt,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export class McpServersOverStore {
|
|
74
|
+
store;
|
|
75
|
+
version;
|
|
76
|
+
/** The connected GitHub App's installation token for listing a `github_app` server's tools as it is previewed, saved
|
|
77
|
+
* or refreshed (github-connection.ts tokenForListing); a run's own is minted at its claim (runner/mcp-claim.ts). Set by
|
|
78
|
+
* the server; absent, such a server's tools can't be listed (github_not_connected). */
|
|
79
|
+
appToken;
|
|
80
|
+
/** The one origin a github_app server may have (GITHUB_MCP_ORIGIN; a test's fake through the server's seam): the App's
|
|
81
|
+
* tokens are minted for, and sent to, nothing else. */
|
|
82
|
+
appOrigin = GITHUB_MCP_ORIGIN;
|
|
83
|
+
sealKey;
|
|
84
|
+
signIns;
|
|
85
|
+
/** The callbacks under way, which close() waits out before the server lets its data go. */
|
|
86
|
+
inflight = new Set();
|
|
87
|
+
stopped = new AbortController();
|
|
88
|
+
constructor(store, env, version, network = systemNetwork) {
|
|
89
|
+
this.store = store;
|
|
90
|
+
this.version = version;
|
|
91
|
+
// The server never starts without a seal key (seal-key.ts ensureSealKey), so there is no keyless registry: every
|
|
92
|
+
// credential is kept sealed under it.
|
|
93
|
+
const sealKey = sealKeyOf(env[SEAL_KEY_ENV]);
|
|
94
|
+
if (!sealKey)
|
|
95
|
+
throw new Error(`MCP servers' credentials are kept under the server's seal key (${SEAL_KEY_ENV}), and none was handed over: the server does not start without one.`);
|
|
96
|
+
this.sealKey = sealKey;
|
|
97
|
+
this.signIns = new McpSignIns(network, pendingOverStore(store, sealKey), () => privateOAuthHosts(store));
|
|
98
|
+
}
|
|
99
|
+
/** This server's address as a browser reaches it and where it listens (McpServers.attach). */
|
|
100
|
+
attach(base, listening) {
|
|
101
|
+
this.signIns.base = base.replace(/\/+$/, "");
|
|
102
|
+
this.signIns.listening = listening.replace(/\/+$/, "");
|
|
103
|
+
}
|
|
104
|
+
clientDocument() {
|
|
105
|
+
return this.signIns.clientDocument();
|
|
106
|
+
}
|
|
107
|
+
/** The origin the authorization server sends the browser back to. */
|
|
108
|
+
get callbackOrigin() {
|
|
109
|
+
return new URL(this.signIns.base).origin;
|
|
110
|
+
}
|
|
111
|
+
/** The server's own tool settings, set as the server starts (McpServers.toolSettings). */
|
|
112
|
+
toolSettings = () => ({});
|
|
113
|
+
async close(boundMs = 2_000) {
|
|
114
|
+
this.stopped.abort();
|
|
115
|
+
await Promise.race([Promise.allSettled([...this.inflight]), new Promise((done) => setTimeout(done, boundMs).unref())]);
|
|
116
|
+
}
|
|
117
|
+
track(work) {
|
|
118
|
+
this.inflight.add(work);
|
|
119
|
+
void work.then(() => this.inflight.delete(work), () => this.inflight.delete(work));
|
|
120
|
+
return work;
|
|
121
|
+
}
|
|
122
|
+
/** GET .../oauth/private-hosts: the private-network hosts an authorization server may be on (none by default). */
|
|
123
|
+
async privateHosts() {
|
|
124
|
+
return { hosts: await privateOAuthHosts(this.store) };
|
|
125
|
+
}
|
|
126
|
+
/** PUT .../oauth/private-hosts: the list replaced in store.settings, durable before it answers; or 422 in words. */
|
|
127
|
+
async setPrivateHosts(body) {
|
|
128
|
+
const hosts = checkPrivateHosts(body);
|
|
129
|
+
await savePrivateOAuthHosts(this.store, hosts);
|
|
130
|
+
await this.store.flush();
|
|
131
|
+
return { hosts };
|
|
132
|
+
}
|
|
133
|
+
async list() {
|
|
134
|
+
const rows = await listMcpServers(this.store);
|
|
135
|
+
return { servers: await Promise.all(rows.slice().sort((a, b) => a.name.localeCompare(b.name)).map((row) => this.view(row))) };
|
|
136
|
+
}
|
|
137
|
+
async get(name) {
|
|
138
|
+
return this.view(await this.need(name));
|
|
139
|
+
}
|
|
140
|
+
/** POST preview: `{url, auth}`, or `{name}` for a saved server with its sealed credential. Stores nothing. */
|
|
141
|
+
async preview(body, stop) {
|
|
142
|
+
if (body.name !== undefined && body.url === undefined) {
|
|
143
|
+
const issues = unknownFields(body, ["name"]);
|
|
144
|
+
if (issues.length)
|
|
145
|
+
throw invalid(issues);
|
|
146
|
+
const name = String(body.name);
|
|
147
|
+
const kept = await this.need(name);
|
|
148
|
+
const url = new URL(kept.url);
|
|
149
|
+
return marked(kept.url, await this.listServer(url, await this.withAppToken(kept.auth, url, (await this.opened(name, kept, "name")).headers, stop), stop));
|
|
150
|
+
}
|
|
151
|
+
const { url, auth } = this.admit(body);
|
|
152
|
+
// A github_app server's credential is a token of the App, minted here, as for a saved one: its static headers are optional.
|
|
153
|
+
if (auth.type !== "none" && auth.type !== "github_app" && !auth.headers)
|
|
154
|
+
throw invalid([credentialMissing(auth.type, "A preview needs the credential it is to connect with.")]);
|
|
155
|
+
return marked(url.href, await this.listServer(url, await this.withAppToken(auth.type, url, auth.headers ?? {}, stop), stop));
|
|
156
|
+
}
|
|
157
|
+
/** PUT: preview, then keep the server with the tools listed. A body with no credential keeps the sealed one, while the
|
|
158
|
+
* auth type and the URL's origin stay the same. */
|
|
159
|
+
async save(name, body, stop, checkedAgainst) {
|
|
160
|
+
nameOf(name);
|
|
161
|
+
const { url, auth, prices } = this.admit(body, true);
|
|
162
|
+
const was = await this.store.mcp.server(name);
|
|
163
|
+
// The credential this save may write over: the one the secret-write gate let it through against (`checkedAgainst`,
|
|
164
|
+
// its credentialMark), else the one read here. The write compares it in its own statement, after the listing's wait.
|
|
165
|
+
const against = checkedAgainst !== undefined ? checkedAgainst : credentialMark(was);
|
|
166
|
+
let credential;
|
|
167
|
+
// A credential kept (no new one sent): the row's sealed value as read, never sealed again nor written; the save rewrites
|
|
168
|
+
// the rest of the row by a compare-and-set on it (rewriteKeeping), so a run's refreshed set kept meanwhile stands. A new
|
|
169
|
+
// one is the owner's, written over whatever is there.
|
|
170
|
+
let keeping = false;
|
|
171
|
+
let headers = auth.headers;
|
|
172
|
+
if (auth.type === "github_app") {
|
|
173
|
+
// Its own headers are only its static ones (its token is minted): new ones are kept; none sent keeps the saved ones,
|
|
174
|
+
// at the same origin only, as any saved credential.
|
|
175
|
+
if (headers)
|
|
176
|
+
credential = { type: "headers", headers };
|
|
177
|
+
else if (was?.auth === "github_app" && was.sealed !== null) {
|
|
178
|
+
if (new URL(was.url).origin !== url.origin)
|
|
179
|
+
throw invalid([credentialMissing(auth.type, `The address moved from ${new URL(was.url).origin} to ${url.origin}: send the headers again, so saved ones never go to another origin.`)]);
|
|
180
|
+
const open = await this.opened(name, was, "auth.headers");
|
|
181
|
+
headers = open.headers;
|
|
182
|
+
keeping = true;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else if (auth.type !== "none" && !headers) {
|
|
186
|
+
if (!was || was.auth !== auth.type)
|
|
187
|
+
throw invalid([credentialMissing(auth.type, `The server ${name} has no saved ${auth.type} credential to keep.`)]);
|
|
188
|
+
if (new URL(was.url).origin !== url.origin)
|
|
189
|
+
throw invalid([credentialMissing(auth.type, `The address moved from ${new URL(was.url).origin} to ${url.origin}: send the credential again, so a saved one never goes to another origin.`)]);
|
|
190
|
+
const open = await this.opened(name, was, credentialMissing(auth.type, "").field);
|
|
191
|
+
headers = open.headers;
|
|
192
|
+
keeping = true;
|
|
193
|
+
}
|
|
194
|
+
else if (auth.type !== "none") {
|
|
195
|
+
credential = { type: "headers", headers: headers };
|
|
196
|
+
}
|
|
197
|
+
const listed = await this.listServer(url, await this.withAppToken(auth.type, url, headers ?? {}, stop), stop);
|
|
198
|
+
const unlisted = Object.keys(prices ?? {}).filter((tool) => !listed.tools.some((listedTool) => listedTool.name === tool));
|
|
199
|
+
if (unlisted.length)
|
|
200
|
+
throw invalid(unlisted.map((tool) => ({ field: `prices.${tool}`, reason: "not_an_option", message: `The server ${name} lists no tool ${tool}; its tools are ${listed.tools.map((t) => t.name).join(", ") || "none"}.` })));
|
|
201
|
+
// The row as saved over `row` (the one read, or read again): a body with no `prices` keeps the saved ones, for the tools
|
|
202
|
+
// still listed at the same address.
|
|
203
|
+
const fields = (row) => {
|
|
204
|
+
const priced = prices ?? (row?.url === url.href ? pricesListed((row.prices ?? undefined), listed.tools) : undefined);
|
|
205
|
+
return {
|
|
206
|
+
name, url: url.href, auth: auth.type, protocol: listed.protocol, tools: listed.tools, serverInfo: listed.server_info, instructions: listed.instructions ?? null,
|
|
207
|
+
...(priced && Object.keys(priced).length ? { prices: priced } : {}),
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
const saved = keeping
|
|
211
|
+
// Re-applied only onto a row that still holds a credential of this auth type at this origin: never onto another one's.
|
|
212
|
+
// It writes no credential column, so it never drops or replaces one.
|
|
213
|
+
? await this.rewriteKeeping(name, was, fields, "save", (fresh) => fresh.auth === auth.type && fresh.sealed !== null && new URL(fresh.url).origin === url.origin)
|
|
214
|
+
// A new credential, or none: written only while the row's credential is still `against`, in the store's one statement.
|
|
215
|
+
: changedMeanwhile(name, await saveMcpServerIfCredential(this.store, this.sealKey, { ...fields(was), ...(credential ? { credential } : {}) }, against, { githubMcpOrigin: this.appOrigin }));
|
|
216
|
+
await this.store.flush();
|
|
217
|
+
return this.view(saved);
|
|
218
|
+
}
|
|
219
|
+
/** POST refresh: list the saved server's tools again, keep them, and say what was added, removed and changed. */
|
|
220
|
+
async refresh(name, stop) {
|
|
221
|
+
const was = await this.need(name);
|
|
222
|
+
const open = await this.opened(name, was, "name");
|
|
223
|
+
const listed = await this.listServer(new URL(was.url), await this.withAppToken(was.auth, new URL(was.url), open.headers, stop), stop);
|
|
224
|
+
const before = new Map(was.tools.map((tool) => [tool.name, canonical(tool)]));
|
|
225
|
+
const after = new Map(listed.tools.map((tool) => [tool.name, canonical(tool)]));
|
|
226
|
+
// A refresh re-lists the tools and leaves the credential as it is (rewriteKeeping: a run's refreshed set kept meanwhile
|
|
227
|
+
// stands); it keeps updated_at (not an owner edit) and lets listed_at move to now. Re-applied only onto the same address
|
|
228
|
+
// and auth type it listed.
|
|
229
|
+
const saved = await this.rewriteKeeping(name, was, (row) => {
|
|
230
|
+
const prices = pricesListed((row.prices ?? undefined), listed.tools);
|
|
231
|
+
return {
|
|
232
|
+
name, url: row.url, auth: row.auth, protocol: listed.protocol, tools: listed.tools, serverInfo: listed.server_info, instructions: listed.instructions ?? null,
|
|
233
|
+
...(Object.keys(prices).length ? { prices } : {}), updatedAt: row.updatedAt,
|
|
234
|
+
};
|
|
235
|
+
}, "refresh", (fresh) => fresh.url === was.url && fresh.auth === was.auth);
|
|
236
|
+
await this.store.flush();
|
|
237
|
+
return {
|
|
238
|
+
added: [...after.keys()].filter((tool) => !before.has(tool)),
|
|
239
|
+
removed: [...before.keys()].filter((tool) => !after.has(tool)),
|
|
240
|
+
changed: [...after.keys()].filter((tool) => before.has(tool) && before.get(tool) !== after.get(tool)),
|
|
241
|
+
server: await this.view(saved),
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/** Writes the owner's change over the row it read (`was`), its credential left as it is, by a compare-and-set on that
|
|
245
|
+
* credential (store.mcp.rewrite). A lost one (a run kept a refreshed set meanwhile) reads the row again and re-applies the
|
|
246
|
+
* change onto it, while `still` holds of it, at most REWRITE_TRIES writes; then it is refused in words, nothing written. */
|
|
247
|
+
async rewriteKeeping(name, was, fields, doing, still) {
|
|
248
|
+
let row = was;
|
|
249
|
+
for (let tries = 1;; tries++) {
|
|
250
|
+
const saved = await rewriteMcpServer(this.store, fields(row), row.sealed, { githubMcpOrigin: this.appOrigin });
|
|
251
|
+
if (saved)
|
|
252
|
+
return saved;
|
|
253
|
+
const fresh = await this.store.mcp.server(name);
|
|
254
|
+
if (!fresh)
|
|
255
|
+
throw notFound(name);
|
|
256
|
+
if (!still(fresh))
|
|
257
|
+
throw new ApiError("unavailable", `The MCP server ${name} was changed while this ${doing} was made; nothing was saved. Read it again and try again.`);
|
|
258
|
+
if (tries >= REWRITE_TRIES)
|
|
259
|
+
throw new ApiError("unavailable", `The MCP server ${name}'s credential kept changing while this ${doing} was made (a run refreshing its token); nothing was saved. Try again.`);
|
|
260
|
+
row = fresh;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/** DELETE. `checkedAgainst`: the credential the secret-write gate let a token's removal through against (one with
|
|
264
|
+
* none: removing it drops no secret); the row goes only while it is still that, in the store's one statement, so a
|
|
265
|
+
* credential saved meanwhile is never dropped by it. */
|
|
266
|
+
async remove(name, checkedAgainst) {
|
|
267
|
+
await this.need(name);
|
|
268
|
+
if (checkedAgainst === undefined)
|
|
269
|
+
await removeMcpServer(this.store, name);
|
|
270
|
+
else if (checkedAgainst === null || !(await removeMcpServerIfCredential(this.store, name, checkedAgainst)))
|
|
271
|
+
changedMeanwhile(name, undefined);
|
|
272
|
+
await this.store.flush();
|
|
273
|
+
}
|
|
274
|
+
/** POST .../{name}/oauth/start: `{url, scopes?, client_id?, client_secret?}`; answers the URL the owner opens. */
|
|
275
|
+
async oauthStart(name, body) {
|
|
276
|
+
nameOf(name);
|
|
277
|
+
const issues = unknownFields(body, ["url", "scopes", "client_id", "client_secret"]);
|
|
278
|
+
const url = urlOf(body.url, issues);
|
|
279
|
+
const { scopes, client_id, client_secret } = body;
|
|
280
|
+
if (scopes !== undefined && !scopesValid(scopes))
|
|
281
|
+
issues.push({ field: "scopes", reason: "invalid", message: SCOPE_LIST });
|
|
282
|
+
for (const [field, text] of [["client_id", client_id], ["client_secret", client_secret]])
|
|
283
|
+
if (text !== undefined && !oauthValueValid(text))
|
|
284
|
+
issues.push({ field, reason: "invalid", message: `${field} is text, at most ${MAX_VALUE_BYTES} bytes.` });
|
|
285
|
+
if (client_secret !== undefined && client_id === undefined)
|
|
286
|
+
issues.push({ field: "client_id", reason: "missing", message: "A client_secret goes with the client_id it is the secret of." });
|
|
287
|
+
if (issues.length)
|
|
288
|
+
throw invalid(issues);
|
|
289
|
+
const was = await this.store.mcp.server(name);
|
|
290
|
+
// A body with no client_id signs in again with the client kept in the sealed token set, for the same origin only.
|
|
291
|
+
const kept = typeof client_id !== "string" && was?.auth === "oauth" && new URL(was.url).origin === url.origin ? await this.openedSet(name, was) : undefined;
|
|
292
|
+
// The kept client goes with the authorization server it was registered at (keptFor): another one gets a new client.
|
|
293
|
+
const keptFor = kept ? issuerOf(kept.discovery) : undefined;
|
|
294
|
+
const client = typeof client_id === "string" ? { client: { client_id, ...(typeof client_secret === "string" ? { client_secret } : {}) }, kind: "pre-registered" } : kept && keptFor ? { client: kept.client, kind: kept.kind, keptFor } : {};
|
|
295
|
+
return { authorization_url: await this.signIns.start(name, url, { was: was ? saving(was) : null, ...(scopes ? { scope: scopes.join(" ") } : {}), ...client }) };
|
|
296
|
+
}
|
|
297
|
+
/** GET .../oauth/callback: its state's sign-in finished (the code exchanged, the token set sealed, the tools listed and
|
|
298
|
+
* kept). Answers where to send the browser; 400 for a state that is unknown, used or expired. */
|
|
299
|
+
oauthCallback(query, stop) {
|
|
300
|
+
return this.track(this.callback(query, AbortSignal.any([this.stopped.signal, ...(stop ? [stop] : [])])));
|
|
301
|
+
}
|
|
302
|
+
async callback(query, stop) {
|
|
303
|
+
let entry;
|
|
304
|
+
try {
|
|
305
|
+
entry = await this.signIns.takePending(query.get("state"));
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
if (error instanceof ApiError && error.code === "bad_request")
|
|
309
|
+
throw error;
|
|
310
|
+
return `${MCP_SETTINGS_PAGE}?sign_in=failed&error=${await reasonOf(error)}`;
|
|
311
|
+
}
|
|
312
|
+
const back = (error) => `${MCP_SETTINGS_PAGE}?server=${entry.name}&sign_in=${error ? `failed&error=${error}` : "ok"}`;
|
|
313
|
+
try {
|
|
314
|
+
const error = query.get("error");
|
|
315
|
+
if (error)
|
|
316
|
+
return back(/^[a-z_]{1,64}$/.test(error) ? error : "sign_in_failed");
|
|
317
|
+
const set = await this.signIns.finish(entry, query.get("code") ?? "", query.get("iss") ?? undefined, stop);
|
|
318
|
+
const listed = await this.listServer(new URL(entry.url), { authorization: `Bearer ${set.tokens.access_token}` }, stop);
|
|
319
|
+
const now = await this.store.mcp.server(entry.name);
|
|
320
|
+
// Saved, signed in to again or forgotten since this sign-in started: that stands.
|
|
321
|
+
if ((now ? saving(now) : null) !== entry.was)
|
|
322
|
+
return back("changed_meanwhile");
|
|
323
|
+
const prices = now?.url === entry.url ? (now.prices ?? undefined) : undefined;
|
|
324
|
+
// Written only while the row is still the one just read, in the store's one statement: a save that lands in between
|
|
325
|
+
// stands too.
|
|
326
|
+
const saved = await saveMcpServerIfCredential(this.store, this.sealKey, {
|
|
327
|
+
name: entry.name, url: entry.url, auth: "oauth", protocol: listed.protocol, tools: listed.tools, serverInfo: listed.server_info, instructions: listed.instructions ?? null,
|
|
328
|
+
...(prices && Object.keys(prices).length ? { prices } : {}), credential: { type: "oauth", set },
|
|
329
|
+
}, credentialMark(now));
|
|
330
|
+
if (!saved)
|
|
331
|
+
return back("changed_meanwhile");
|
|
332
|
+
await this.store.flush();
|
|
333
|
+
return back();
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
return back(await reasonOf(error));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
listServer(url, headers, stop) {
|
|
340
|
+
// The shared probe (mcp-probe.listServer), bound also to this server's own stop.
|
|
341
|
+
return listServer(url, headers, this.version, AbortSignal.any([this.stopped.signal, ...(stop ? [stop] : [])]));
|
|
342
|
+
}
|
|
343
|
+
async need(name) {
|
|
344
|
+
const row = await this.store.mcp.server(name);
|
|
345
|
+
if (!row)
|
|
346
|
+
throw notFound(name);
|
|
347
|
+
return row;
|
|
348
|
+
}
|
|
349
|
+
/** The saved credential opened, or the refusal that asks for it again (McpServers.opened). */
|
|
350
|
+
async opened(name, row, field) {
|
|
351
|
+
// No credential kept: none for a server that takes none, nor for a github_app server with no static headers.
|
|
352
|
+
if (row.auth === "none" || row.sealed === null)
|
|
353
|
+
return { headers: {}, credential: { type: "headers", headers: {}, origin: new URL(row.url).origin } };
|
|
354
|
+
const open = await openServerCredential(this.store, this.sealKey, name);
|
|
355
|
+
if (!open || !("credential" in open))
|
|
356
|
+
throw invalid([{ field, reason: "missing", message: `The saved credential of ${name} does not open here (sealed under another seal key, or damaged): send it again.` }]);
|
|
357
|
+
const credential = open.credential;
|
|
358
|
+
if (credential.type === "oauth") {
|
|
359
|
+
if (credential.expired)
|
|
360
|
+
throw invalid([{ field, reason: "expired", message: `The sign-in to ${name} expired or was revoked: ${SIGN_IN_AGAIN}.` }]);
|
|
361
|
+
return { headers: { authorization: `Bearer ${credential.set.tokens.access_token}` }, credential };
|
|
362
|
+
}
|
|
363
|
+
return { headers: credential.headers, credential };
|
|
364
|
+
}
|
|
365
|
+
/** The saved OAuth token set, for a sign-in again that reuses the kept client. */
|
|
366
|
+
async openedSet(name, row) {
|
|
367
|
+
if (row.auth !== "oauth")
|
|
368
|
+
return undefined;
|
|
369
|
+
const open = await openServerCredential(this.store, this.sealKey, name);
|
|
370
|
+
return open && "credential" in open && open.credential.type === "oauth" ? open.credential.set : undefined;
|
|
371
|
+
}
|
|
372
|
+
async view(row) {
|
|
373
|
+
const name = row.name;
|
|
374
|
+
const settings = this.toolSettings();
|
|
375
|
+
const tools = row.tools ?? [];
|
|
376
|
+
const prices = (row.prices ?? undefined);
|
|
377
|
+
const listed = marked(row.url, { protocol: row.protocol ?? "unknown", server_info: row.serverInfo ?? null, ...(typeof row.instructions === "string" ? { instructions: row.instructions } : {}), tools });
|
|
378
|
+
const unmetered = tools.filter((tool) => !(prices && Object.hasOwn(prices, tool.name))).map((tool) => tool.name);
|
|
379
|
+
const opened = row.auth === "none" || (row.auth === "github_app" && row.sealed === null) ? null : await openServerCredential(this.store, this.sealKey, name);
|
|
380
|
+
const cred = opened && "credential" in opened ? opened.credential : undefined;
|
|
381
|
+
const set = cred?.type === "oauth" ? cred.set : undefined;
|
|
382
|
+
const expired = cred?.type === "oauth" && cred.expired === true;
|
|
383
|
+
const updatedAt = new Date(row.updatedAt).toISOString();
|
|
384
|
+
// A refresh moves listed_at, not updated_at, so the two differ after a refresh (updatedAt for a row from before the
|
|
385
|
+
// column).
|
|
386
|
+
const listedAt = new Date(row.listedAt ?? row.updatedAt).toISOString();
|
|
387
|
+
return {
|
|
388
|
+
name,
|
|
389
|
+
url: row.url,
|
|
390
|
+
...(prices && Object.keys(prices).length ? { prices } : {}),
|
|
391
|
+
...listed,
|
|
392
|
+
// Each priced tool's price in USD a call, as the owner saved them (main's file registry served them on every read).
|
|
393
|
+
...(prices && Object.keys(prices).length ? { prices } : {}),
|
|
394
|
+
tools: listed.tools.map((tool) => ({ ...tool, ...serverGate(`mcp:${name}/${tool.name}`, settings) })),
|
|
395
|
+
...(unmetered.length ? { not_metered: unmetered } : {}),
|
|
396
|
+
auth: { type: row.auth, ...(row.auth === "headers" || row.auth === "github_app" ? { headers: Object.keys((cred?.type === "headers" ? cred.headers : {})) } : {}) },
|
|
397
|
+
credential: opened === null ? null : !cred ? "unreadable" : expired ? "expired" : "sealed",
|
|
398
|
+
...(set ? { oauth: { ...(set.expires_at ? { expires_at: set.expires_at } : {}), scopes: (set.tokens.scope ?? "").split(" ").filter(Boolean), client: set.kind, ...(set.client?.client_id ? { client_id: set.client.client_id } : {}) } } : {}),
|
|
399
|
+
listed_at: listedAt,
|
|
400
|
+
updated_at: updatedAt,
|
|
401
|
+
secret: secretOf(row),
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
/** A body's URL, auth and prices, or 422 (McpServers.admit). */
|
|
405
|
+
admit(body, priced = false) {
|
|
406
|
+
const issues = unknownFields(body, priced ? ["url", "auth", "prices"] : ["url", "auth"]);
|
|
407
|
+
const url = urlOf(body.url, issues);
|
|
408
|
+
const auth = authOf(body.auth, issues);
|
|
409
|
+
const prices = pricesOf(body.prices, issues);
|
|
410
|
+
// The App's tokens go to GitHub alone: a github_app server is GitHub's hosted MCP, nothing else, refused in that rule's
|
|
411
|
+
// words in place of any other its URL drew.
|
|
412
|
+
if (url && auth?.type === "github_app" && !githubMcpUrl(url, this.appOrigin))
|
|
413
|
+
issues.splice(0, issues.length, ...issues.filter((issue) => issue.field !== "url"), { field: "url", reason: "not_allowed", message: GITHUB_MCP_ONLY });
|
|
414
|
+
if (issues.length)
|
|
415
|
+
throw invalid(issues);
|
|
416
|
+
return { url: url, auth: auth, ...(prices ? { prices } : {}) };
|
|
417
|
+
}
|
|
418
|
+
/** `headers` and, for a github_app server, an installation token of the connected App to list its tools with. Its URL
|
|
419
|
+
* is checked first (githubMcpUrl), so a row saved at another address never gets a token minted or sent. */
|
|
420
|
+
async withAppToken(type, url, headers, stop) {
|
|
421
|
+
if (type !== "github_app")
|
|
422
|
+
return headers;
|
|
423
|
+
if (!githubMcpUrl(url, this.appOrigin))
|
|
424
|
+
throw invalid([{ field: "url", reason: "not_allowed", message: GITHUB_MCP_ONLY }]);
|
|
425
|
+
const minted = this.appToken ? await this.appToken(stop) : { unusable: "This server has no GitHub App: Connect GitHub in Settings." };
|
|
426
|
+
if ("unusable" in minted)
|
|
427
|
+
throw new ApiError("github_not_connected", minted.unusable);
|
|
428
|
+
if ("failed" in minted)
|
|
429
|
+
throw new ApiError("github_failed", minted.failed);
|
|
430
|
+
return { ...headers, authorization: `Bearer ${minted.token}` };
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
/** 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
|
+
* token does not change the url. The staleness key an OAuth sign-in carries from start to callback. */
|
|
435
|
+
const saving = (row) => `${row.url} ${row.updatedAt}`;
|
|
436
|
+
/** The McpServers surface over the one store: the switch swaps `new McpServers(data, env, version)` for this. No load() is
|
|
437
|
+
* needed — every read goes to the store (the runner also writes the OAuth state), so a read is always current. */
|
|
438
|
+
export function mcpServersOverStore(store, env, version, network) {
|
|
439
|
+
return new McpServersOverStore(store, env, version, network);
|
|
440
|
+
}
|
|
441
|
+
/** The server's credential as every secret is read (SECRETS-PLAN.md): set or not, how it came ("console": pasted, a
|
|
442
|
+
* bearer token or headers; "sign-in": an OAuth sign-in; null: none), and the credential's own last change. Never a value.
|
|
443
|
+
* An MCP credential never comes from the server's environment. */
|
|
444
|
+
function secretOf(row) {
|
|
445
|
+
const set = row.sealed !== null && row.auth !== "none";
|
|
446
|
+
return secretMeta(secretName("mcp", row.name), { set, source: row.auth === "oauth" ? "sign-in" : "console", changedAt: row.credentialChangedAt === null ? null : new Date(row.credentialChangedAt) });
|
|
447
|
+
}
|