@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,1253 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord";
|
|
2
|
+
import type { Storage, StorageWrite } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { JournalPage } from "./journal/storage.js";
|
|
4
|
+
/** A run's state. queued: a row, no runner yet. running: a runner holds the claim. parked: waiting for a person (an
|
|
5
|
+
* approval, a raised cap) with no claim held; a command row or its wake_at makes it claimable again. ended, stopped and
|
|
6
|
+
* failed are final. A running run whose runner died is claimable once its claim runs out. */
|
|
7
|
+
export type RunState = "queued" | "running" | "parked" | "ended" | "stopped" | "failed";
|
|
8
|
+
export declare const FINAL_STATES: readonly RunState[];
|
|
9
|
+
/** A state a release may leave a run in: never a final one (Store.release). */
|
|
10
|
+
export type ReleasedState = Exclude<RunState, "ended" | "stopped" | "failed">;
|
|
11
|
+
/** Why a command row still untaken when its run went final is refused: the write that makes a run final refuses each
|
|
12
|
+
* such row with these words, in that same transaction (a final run takes no new row, so none is left for good). */
|
|
13
|
+
export declare function endedReason(state: "ended" | "stopped" | "failed"): string;
|
|
14
|
+
/** A runner's hold on a run: the epoch every write it makes for the run carries, until `until` (ms) unless renewed. `from`:
|
|
15
|
+
* the run's state before this claim (queued; parked: woken by a command or its wake_at; running: released, or its last
|
|
16
|
+
* claim lapsed). */
|
|
17
|
+
export interface Claim {
|
|
18
|
+
readonly runId: string;
|
|
19
|
+
readonly runner: string;
|
|
20
|
+
readonly epoch: number;
|
|
21
|
+
readonly until: number;
|
|
22
|
+
readonly from: RunState;
|
|
23
|
+
/** The runner that held the run when this claim took it over: its lease ran out with the run still running (that
|
|
24
|
+
* runner was lost, or lost its claim). Its loop says so on the run's timeline. Absent for any other claim. */
|
|
25
|
+
readonly lost?: {
|
|
26
|
+
readonly runner: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** A command the server wrote for a run (stop, cancel, steer, approve, deny, raise): one row, read by the run's runner in id order
|
|
30
|
+
* and marked taken, or refused with why. `body` is JSON. */
|
|
31
|
+
export interface Command {
|
|
32
|
+
readonly id: number;
|
|
33
|
+
readonly runId: string;
|
|
34
|
+
readonly kind: string;
|
|
35
|
+
readonly body: unknown;
|
|
36
|
+
readonly createdAt: number;
|
|
37
|
+
readonly takenAt: number | null;
|
|
38
|
+
readonly refused: string | null;
|
|
39
|
+
/** The resumes it woke that failed (retry), across runners and restarts. */
|
|
40
|
+
readonly tries: number;
|
|
41
|
+
}
|
|
42
|
+
export interface AgentRow {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly name: string;
|
|
45
|
+
readonly description: string | null;
|
|
46
|
+
readonly currentRevision: string | null;
|
|
47
|
+
readonly createdAt: number;
|
|
48
|
+
readonly archivedAt: number | null;
|
|
49
|
+
/** The reference of the agent this one mirrors in another system ("<source>:<kind>:<id>"), or null for one made here. An
|
|
50
|
+
* agent with a reference is read-only from here: it is written on the first run that names it and never edited. */
|
|
51
|
+
readonly externalRef: string | null;
|
|
52
|
+
}
|
|
53
|
+
/** A template's package, kept on the revision made from it. */
|
|
54
|
+
export interface TemplatePackage {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly version: string;
|
|
57
|
+
readonly source: "builtin" | "git";
|
|
58
|
+
readonly ref?: string;
|
|
59
|
+
readonly sha?: string;
|
|
60
|
+
readonly parameters?: unknown;
|
|
61
|
+
}
|
|
62
|
+
export interface NewRevision {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly kind: string;
|
|
65
|
+
readonly body: unknown;
|
|
66
|
+
/** The revision's skill files, a JSON object keyed by the skill's path to its text, or none. The body's own `skills`
|
|
67
|
+
* map keeps each path to its text's SHA-256; this is the texts, kept on the revision's row (store schema `revisions`). */
|
|
68
|
+
readonly skills?: unknown;
|
|
69
|
+
/** The optional note the revision is committed with (the v2 note), or none. */
|
|
70
|
+
readonly note?: string;
|
|
71
|
+
readonly package?: TemplatePackage;
|
|
72
|
+
/** The version this revision maps in an externally owned agent, set only on an inline-agent run's revision. */
|
|
73
|
+
readonly externalVersion?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface RevisionRow {
|
|
76
|
+
readonly id: string;
|
|
77
|
+
readonly agentId: string;
|
|
78
|
+
/** The revision that was the agent's current one when this one was committed (null for its first): the v2 revisions
|
|
79
|
+
* view's parent. */
|
|
80
|
+
readonly parent: string | null;
|
|
81
|
+
readonly kind: string;
|
|
82
|
+
readonly body: unknown;
|
|
83
|
+
/** The revision's skill files as it was written (path to text), or null for a revision with none. */
|
|
84
|
+
readonly skills: unknown;
|
|
85
|
+
/** The note the revision was committed with, or null. */
|
|
86
|
+
readonly note: string | null;
|
|
87
|
+
readonly package: TemplatePackage | null;
|
|
88
|
+
readonly createdAt: number;
|
|
89
|
+
/** The version this revision maps in the agent's owning system (one revision per version), or null for one committed here. */
|
|
90
|
+
readonly externalVersion: string | null;
|
|
91
|
+
}
|
|
92
|
+
/** How an ended run (state 'ended') ended apart from being done: 'escalated' (it finished its work and waits for a person,
|
|
93
|
+
* which the v2 status reads as completed with a review) or 'completed'. A failed or stopped run says so in its state. */
|
|
94
|
+
export type RunOutcome = "completed" | "escalated";
|
|
95
|
+
/** The harness an imported run came from. */
|
|
96
|
+
export type ImportSource = "claude-code" | "codex" | "pi";
|
|
97
|
+
/** Where an imported run came from: the harness that ran it, and its own session id. `file` is the server's own record of
|
|
98
|
+
* the session file an import read whole (the sha-256 of its path, never the path, with its size and mtime), so a later
|
|
99
|
+
* import does not read an unchanged file again; it is internal and never shown on an answer. The unique import index keys
|
|
100
|
+
* on source and session alone, so a re-import of the same session with a different `file` is still the same run. */
|
|
101
|
+
export interface ImportedFrom {
|
|
102
|
+
readonly source: ImportSource;
|
|
103
|
+
readonly session: string;
|
|
104
|
+
readonly file?: {
|
|
105
|
+
readonly path_sha256: string;
|
|
106
|
+
readonly size: number;
|
|
107
|
+
readonly mtime_ms: number;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** What a run was started under: `key`, the caller's name for it (a create's idempotency key, a trigger's firing key),
|
|
111
|
+
* which starts one run only, and `fingerprint`, what was asked, kept to tell a retry from another request under the key. */
|
|
112
|
+
export interface RunOrigin {
|
|
113
|
+
readonly key: string;
|
|
114
|
+
readonly fingerprint?: string | null;
|
|
115
|
+
}
|
|
116
|
+
export interface RunRow {
|
|
117
|
+
readonly id: string;
|
|
118
|
+
readonly agentId: string;
|
|
119
|
+
readonly revisionId: string;
|
|
120
|
+
readonly state: RunState;
|
|
121
|
+
readonly epoch: number;
|
|
122
|
+
readonly runner: string | null;
|
|
123
|
+
readonly claimedUntil: number | null;
|
|
124
|
+
readonly wakeAt: number | null;
|
|
125
|
+
/** A parked run's backoff after a failed resume: its untaken commands wait for it, a stop and its wake_at do not. */
|
|
126
|
+
readonly backoffUntil: number | null;
|
|
127
|
+
readonly costUsd: number | null;
|
|
128
|
+
readonly metrics: unknown;
|
|
129
|
+
readonly summary: string | null;
|
|
130
|
+
/** An ended run's outcome (RunOutcome), null for a plain completion or a run not ended this way. */
|
|
131
|
+
readonly outcome: RunOutcome | null;
|
|
132
|
+
/** When the run itself was archived (its agent's archive is read apart); null when it is not. */
|
|
133
|
+
readonly archivedAt: number | null;
|
|
134
|
+
/** The session an imported run came from; null for a run started here. */
|
|
135
|
+
readonly importedFrom: ImportedFrom | null;
|
|
136
|
+
/** The SHA-256 hashes of the browser sign-in pointers handed to the run at its launch (never the pointers), or null when
|
|
137
|
+
* it was handed none. A sign-in whose pointer hashes to one of these cannot be forgotten while the run runs. */
|
|
138
|
+
readonly signInHanded: readonly string[] | null;
|
|
139
|
+
readonly startedAt: number;
|
|
140
|
+
readonly endedAt: number | null;
|
|
141
|
+
}
|
|
142
|
+
/** What a runner may change on its run's row, under its claim. A final state with no `endedAt` is stamped now. */
|
|
143
|
+
export interface RunPatch {
|
|
144
|
+
readonly state?: RunState;
|
|
145
|
+
readonly costUsd?: number | null;
|
|
146
|
+
readonly metrics?: unknown;
|
|
147
|
+
readonly summary?: string | null;
|
|
148
|
+
/** An ended run's outcome, set in its end commit; null clears it. */
|
|
149
|
+
readonly outcome?: RunOutcome | null;
|
|
150
|
+
/** The SHA-256 hashes of the sign-in pointers handed to the run, which the runner writes at its claim (under the epoch
|
|
151
|
+
* fence); null clears them. While the run runs, a sign-in hashing to one of these cannot be forgotten (sign-ins-store.ts). */
|
|
152
|
+
readonly signInHanded?: readonly string[] | null;
|
|
153
|
+
readonly endedAt?: number | null;
|
|
154
|
+
}
|
|
155
|
+
/** The row runs.update answers. When the patch wrote `signInHanded` (the runner's bind at its claim), `save` rides with it:
|
|
156
|
+
* whether this run holds the sign-in's save lease — true unless another run already holds one of the handed pointers,
|
|
157
|
+
* decided in the same transaction as the sign_in_handed write so two binds of one sign-in never both save. Absent when the
|
|
158
|
+
* patch wrote no `signInHanded`. */
|
|
159
|
+
export type UpdatedRun = RunRow & {
|
|
160
|
+
readonly save?: boolean;
|
|
161
|
+
};
|
|
162
|
+
/** A run's launch, as the server writes it at start: its JSON `body` (run-launch.ts: the first input, title, place, effort,
|
|
163
|
+
* cap, trigger and origin), and `sealed` ciphertext for any secret it carries (sealed with the server's key outside the
|
|
164
|
+
* store, AAD `run_launch|<run_id>|sealed`), or none. Written once, in the same transaction as the queued run. */
|
|
165
|
+
export interface RunLaunchInput {
|
|
166
|
+
readonly body: unknown;
|
|
167
|
+
readonly sealed?: Uint8Array | null;
|
|
168
|
+
}
|
|
169
|
+
/** A run's launch as the store holds it: the body the runner reads at its claim, and its sealed bytes, which the store never
|
|
170
|
+
* opens. */
|
|
171
|
+
export interface RunLaunchRow {
|
|
172
|
+
readonly runId: string;
|
|
173
|
+
readonly body: unknown;
|
|
174
|
+
readonly sealed: Uint8Array | null;
|
|
175
|
+
readonly createdAt: number;
|
|
176
|
+
}
|
|
177
|
+
/** A run imported from another harness's session: an ended run with where it came from, its launch (built from the
|
|
178
|
+
* session), its cost and metrics, and its transcript as journal batches — the whole thing written in one transaction.
|
|
179
|
+
* `transcript` is the session as pi-durable write batches (a root conversation and its entries), each batch a commit. */
|
|
180
|
+
export interface ImportRunInput {
|
|
181
|
+
readonly id: string;
|
|
182
|
+
readonly agentId: string;
|
|
183
|
+
readonly revisionId: string;
|
|
184
|
+
readonly importedFrom: ImportedFrom;
|
|
185
|
+
readonly launch: RunLaunchInput;
|
|
186
|
+
/** How the imported run ended (default 'ended'); `outcome` an ended run's (completed is the default). */
|
|
187
|
+
readonly state?: "ended" | "failed" | "stopped";
|
|
188
|
+
readonly outcome?: RunOutcome | null;
|
|
189
|
+
readonly costUsd?: number | null;
|
|
190
|
+
readonly summary?: string | null;
|
|
191
|
+
readonly metrics?: unknown;
|
|
192
|
+
readonly startedAt: number;
|
|
193
|
+
readonly endedAt?: number;
|
|
194
|
+
readonly transcript: readonly (readonly StorageWrite[])[];
|
|
195
|
+
}
|
|
196
|
+
/** Rows written in the same commit as a run's update (runs.update, or a journal commit's staged patch): a channel post the
|
|
197
|
+
* run's moment owes (the outbox), what a channel was told. A command consumed is Staged.take, refused when not untaken. */
|
|
198
|
+
export type AlsoRow = {
|
|
199
|
+
readonly table: "channel_posts";
|
|
200
|
+
readonly row: ChannelPost;
|
|
201
|
+
} | {
|
|
202
|
+
readonly table: "channel_told";
|
|
203
|
+
readonly row: {
|
|
204
|
+
channel: string;
|
|
205
|
+
marker: string;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/** What the run's end-of-run turn kept: the turn and the proposal checked from it (the run's agent is the row's). */
|
|
209
|
+
| {
|
|
210
|
+
readonly table: "learning_proposals";
|
|
211
|
+
readonly row: {
|
|
212
|
+
turn: unknown;
|
|
213
|
+
proposal: unknown;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/** The learning run that grades and merges the kept proposal: a queued run `id` of the run's agent and revision. Started
|
|
217
|
+
* once: the same id staged again (an end replayed after a crash) adds nothing. */
|
|
218
|
+
/** `model`: the grade model (gradeModelOf, as the server resolves it), on the learning run's launch; none, the agent's own. */
|
|
219
|
+
| {
|
|
220
|
+
readonly table: "learning_run";
|
|
221
|
+
readonly row: {
|
|
222
|
+
id: string;
|
|
223
|
+
model?: string;
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
/** A run's kept learning (learning_proposals): what its end-of-run turn asked and answered, and the proposal checked from it. */
|
|
227
|
+
export interface LearningProposal {
|
|
228
|
+
readonly runId: string;
|
|
229
|
+
readonly agentId: string;
|
|
230
|
+
readonly turn: unknown;
|
|
231
|
+
readonly proposal: unknown;
|
|
232
|
+
/** The learning run its end queued with it, which grades and merges it; absent for a learning dropped before. */
|
|
233
|
+
readonly learningRunId?: string;
|
|
234
|
+
readonly createdAt: number;
|
|
235
|
+
}
|
|
236
|
+
/** Learning on the runner: the kept proposals, written only beside a run's end (AlsoRow learning_proposals). */
|
|
237
|
+
export interface Learning {
|
|
238
|
+
/** The run's kept proposal; undefined when its end kept none. */
|
|
239
|
+
proposal(runId: string): Promise<LearningProposal | undefined>;
|
|
240
|
+
/** The agent's kept proposals, newest first. */
|
|
241
|
+
proposals(agentId: string, options?: {
|
|
242
|
+
limit?: number;
|
|
243
|
+
}): Promise<LearningProposal[]>;
|
|
244
|
+
}
|
|
245
|
+
/** A command a journal commit takes, with the id of the record that is its effect, an id the effect's batch newly
|
|
246
|
+
* allocates (an entry, a created document, a new task): written only by the commit that newly writes that record, in its
|
|
247
|
+
* transaction, so the command is taken with its own effect or not at all. An effect that updates an existing record (a
|
|
248
|
+
* document change or retire, a task update) carries a marker entry minted for it in the same batch: an entry of kind
|
|
249
|
+
* `agentrun.command` on the run's root conversation, data `{ command }`, which the runner's reader and live view skip.
|
|
250
|
+
* The effect must be an id the journal minted and has not yet written: stage() refuses any other. */
|
|
251
|
+
export interface StagedTake {
|
|
252
|
+
readonly command: number;
|
|
253
|
+
readonly effect: number;
|
|
254
|
+
}
|
|
255
|
+
/** What a journal commit writes beside its batches, in its one transaction, under its fence: the run row's patch and rows
|
|
256
|
+
* beside it, landing with the record `effect` names (required with either: a park's ask, an end's entry), and the
|
|
257
|
+
* commands it takes (each with its own effect). Each is written only by the commit that stores its effect. */
|
|
258
|
+
export interface Staged {
|
|
259
|
+
readonly run?: RunPatch;
|
|
260
|
+
readonly also?: readonly AlsoRow[];
|
|
261
|
+
readonly effect?: number;
|
|
262
|
+
readonly take?: readonly StagedTake[];
|
|
263
|
+
}
|
|
264
|
+
/** A run's journal: pi-durable's Storage for the one run, every commit fenced by the claim, and stage() for what its next
|
|
265
|
+
* commit writes beside its batches. Staged rows are cleared once a commit stores a batch and kept when it does not. */
|
|
266
|
+
export interface Journal extends Storage {
|
|
267
|
+
readonly runId: string;
|
|
268
|
+
stage(staged: Staged): void;
|
|
269
|
+
/** The run's commits after `afterSeq`, at most `limit`, each with only what it wrote (store/journal JournalPage). */
|
|
270
|
+
commitsAfter(afterSeq: number, limit: number, context: Context): Promise<JournalPage>;
|
|
271
|
+
}
|
|
272
|
+
/** A run's journal opened for reading only: the read half of its Storage — its scans and lookups and commitsAfter, with no
|
|
273
|
+
* commit, stage or mintId, and no claim. The server reads a run this way (its timeline, the records analytics sums), where
|
|
274
|
+
* it holds no claim; a writer uses journal(claim) instead. A read never fences (only a commit does), so the view needs no
|
|
275
|
+
* epoch; a run with no journal yet reads as empty. close() lets its admitted reads drain, and leaves the store's
|
|
276
|
+
* connection open: the store owns it. */
|
|
277
|
+
export type JournalReads = Pick<Journal, "runId" | "conversation" | "scanConversations" | "entry" | "findLatestHeadMarker" | "scanEntries" | "task" | "scanTasks" | "submission" | "scanSubmissions" | "submissionByRequest" | "findDocument" | "document" | "scanDocuments" | "commitsAfter" | "close">;
|
|
278
|
+
export interface ChannelPost {
|
|
279
|
+
readonly id: string;
|
|
280
|
+
readonly channel: string;
|
|
281
|
+
readonly conversation?: string | null;
|
|
282
|
+
readonly wait?: string | null;
|
|
283
|
+
readonly moment: string;
|
|
284
|
+
readonly body: unknown;
|
|
285
|
+
readonly nextAt?: number;
|
|
286
|
+
}
|
|
287
|
+
/** A trigger as a template or an upgrade gives it. `scopes`: the (kind, scope) keys it answers, rows only while enabled. */
|
|
288
|
+
export interface TriggerDef {
|
|
289
|
+
readonly id: string;
|
|
290
|
+
readonly name: string;
|
|
291
|
+
readonly enabled?: boolean;
|
|
292
|
+
readonly source: unknown;
|
|
293
|
+
readonly target: unknown;
|
|
294
|
+
readonly nextAt?: number | null;
|
|
295
|
+
readonly catchupWindowS?: number | null;
|
|
296
|
+
readonly scopes?: readonly TriggerScope[];
|
|
297
|
+
}
|
|
298
|
+
export interface TriggerScope {
|
|
299
|
+
readonly kind: string;
|
|
300
|
+
readonly scope: string;
|
|
301
|
+
}
|
|
302
|
+
export interface TriggerRow {
|
|
303
|
+
readonly id: string;
|
|
304
|
+
readonly agentId: string;
|
|
305
|
+
readonly name: string;
|
|
306
|
+
readonly enabled: boolean;
|
|
307
|
+
readonly source: unknown;
|
|
308
|
+
readonly target: unknown;
|
|
309
|
+
readonly nextAt: number | null;
|
|
310
|
+
readonly lastRunId: string | null;
|
|
311
|
+
readonly catchupWindowS: number | null;
|
|
312
|
+
readonly failuresInARow: number;
|
|
313
|
+
/** Why it is off, when a failure streak or its source turned it off (JSON); null once it is on again. */
|
|
314
|
+
readonly disabled: unknown;
|
|
315
|
+
readonly maxActiveRuns: number | null;
|
|
316
|
+
readonly createdAt: number;
|
|
317
|
+
readonly updatedAt: number;
|
|
318
|
+
}
|
|
319
|
+
/** A trigger's firing that starts a run. */
|
|
320
|
+
export interface Firing {
|
|
321
|
+
readonly triggerId: string;
|
|
322
|
+
readonly key: string;
|
|
323
|
+
readonly by?: string | null;
|
|
324
|
+
readonly nominalAt?: number | null;
|
|
325
|
+
readonly catchUp?: boolean;
|
|
326
|
+
readonly payload?: string | null;
|
|
327
|
+
}
|
|
328
|
+
export type FiringStatus = "due" | "started" | "sent" | "skipped" | "failed" | "missed" | "ignored";
|
|
329
|
+
/** A trigger's firing as its row keeps it. `shown`: in the trigger's history (the newest HISTORY_KEPT); false, kept only
|
|
330
|
+
* for its key's day. `retryAt`: a due firing's next try; `waitsOn`: the run whose turn end wakes a due firing. */
|
|
331
|
+
export interface FiringRow {
|
|
332
|
+
readonly triggerId: string;
|
|
333
|
+
readonly key: string;
|
|
334
|
+
readonly by: string;
|
|
335
|
+
readonly nominalAt: number;
|
|
336
|
+
readonly status: FiringStatus;
|
|
337
|
+
readonly at: number;
|
|
338
|
+
readonly runId: string | null;
|
|
339
|
+
readonly reason: string | null;
|
|
340
|
+
readonly error: {
|
|
341
|
+
code: string;
|
|
342
|
+
message: string;
|
|
343
|
+
} | null;
|
|
344
|
+
readonly count: number | null;
|
|
345
|
+
readonly attempts: number;
|
|
346
|
+
readonly retryAt: number | null;
|
|
347
|
+
readonly payload: string | null;
|
|
348
|
+
readonly attrs: unknown;
|
|
349
|
+
readonly notified: boolean;
|
|
350
|
+
readonly catchUp: boolean;
|
|
351
|
+
readonly paused: boolean;
|
|
352
|
+
readonly shown: boolean;
|
|
353
|
+
readonly waitsOn: string | null;
|
|
354
|
+
}
|
|
355
|
+
/** A firing recorded: due (to be driven), or settled at once (skipped, missed, ignored). */
|
|
356
|
+
export interface NewFiring {
|
|
357
|
+
readonly key: string;
|
|
358
|
+
readonly by: string;
|
|
359
|
+
readonly nominalAt: number;
|
|
360
|
+
readonly status: "due" | "skipped" | "missed" | "ignored";
|
|
361
|
+
readonly reason?: string;
|
|
362
|
+
readonly count?: number;
|
|
363
|
+
readonly catchUp?: boolean;
|
|
364
|
+
readonly payload?: string;
|
|
365
|
+
readonly attrs?: unknown;
|
|
366
|
+
/** False: kept only for its key's day, never in the history (an ignored delivery's key). */
|
|
367
|
+
readonly shown?: boolean;
|
|
368
|
+
}
|
|
369
|
+
/** A trigger made, as POST /triggers keeps it. */
|
|
370
|
+
export interface NewTrigger {
|
|
371
|
+
readonly id: string;
|
|
372
|
+
readonly agentId: string;
|
|
373
|
+
readonly name: string;
|
|
374
|
+
readonly enabled: boolean;
|
|
375
|
+
readonly source: unknown;
|
|
376
|
+
readonly target: unknown;
|
|
377
|
+
readonly nextAt: number | null;
|
|
378
|
+
readonly catchupWindowS: number;
|
|
379
|
+
readonly maxActiveRuns?: number | null;
|
|
380
|
+
}
|
|
381
|
+
/** A trigger's fields changed; the ones absent stay. */
|
|
382
|
+
/** `agentId`: the agent it belongs to, which follows its target (a PATCH may aim it at another agent's run or agent). */
|
|
383
|
+
export type TriggerPatch = Partial<Pick<TriggerRow, "agentId" | "name" | "enabled" | "source" | "target" | "nextAt" | "catchupWindowS" | "failuresInARow" | "disabled" | "maxActiveRuns">>;
|
|
384
|
+
/** A firing's new state. Out of due, a firing keeps no retry, wait, payload nor the reason its last try gave (unless given). */
|
|
385
|
+
export interface FiringChange {
|
|
386
|
+
readonly status?: FiringStatus;
|
|
387
|
+
readonly runId?: string;
|
|
388
|
+
readonly reason?: string | null;
|
|
389
|
+
readonly error?: {
|
|
390
|
+
code: string;
|
|
391
|
+
message: string;
|
|
392
|
+
};
|
|
393
|
+
readonly attempts?: number;
|
|
394
|
+
readonly retryAt?: number | null;
|
|
395
|
+
readonly waitsOn?: string | null;
|
|
396
|
+
readonly notified?: boolean;
|
|
397
|
+
}
|
|
398
|
+
/** What a settle does to the firing's trigger besides: `reset` its failure streak (a run started, a message sent), or
|
|
399
|
+
* count a `failure` toward it, turning it off at `pauseAt` in a row (auto-pause, the firing marked paused). */
|
|
400
|
+
export type FiringStreak = {
|
|
401
|
+
readonly reset: true;
|
|
402
|
+
} | {
|
|
403
|
+
readonly failure: true;
|
|
404
|
+
readonly pauseAt: number;
|
|
405
|
+
};
|
|
406
|
+
/** A firing a trigger has no room for: `due` firings are DUE_KEPT already. Nothing was written. */
|
|
407
|
+
export declare class TriggerFull extends Error {
|
|
408
|
+
readonly triggerId: string;
|
|
409
|
+
readonly due: number;
|
|
410
|
+
name: string;
|
|
411
|
+
constructor(triggerId: string, due: number);
|
|
412
|
+
}
|
|
413
|
+
/** A run of an archived agent, or a trigger of it made on or turned on: refused, nothing written (Agents.archive). */
|
|
414
|
+
export declare class AgentArchived extends Error {
|
|
415
|
+
readonly agentId: string;
|
|
416
|
+
name: string;
|
|
417
|
+
constructor(agentId: string);
|
|
418
|
+
}
|
|
419
|
+
/** An inline-agent run whose body differs from the one already stored for its external reference and version: refused,
|
|
420
|
+
* nothing written (Runs.createInline). A version's body is immutable; a changed body needs a new version. */
|
|
421
|
+
export declare class ExternalBodyConflict extends Error {
|
|
422
|
+
readonly ref: string;
|
|
423
|
+
readonly version: string;
|
|
424
|
+
name: string;
|
|
425
|
+
constructor(ref: string, version: string);
|
|
426
|
+
}
|
|
427
|
+
export interface Agents {
|
|
428
|
+
/** Creates the agent, or renames it (name, description) when it exists. */
|
|
429
|
+
put(agent: {
|
|
430
|
+
id: string;
|
|
431
|
+
name: string;
|
|
432
|
+
description?: string | null;
|
|
433
|
+
}): Promise<void>;
|
|
434
|
+
/** The agent row and its first revision, current, in one transaction: both or neither. */
|
|
435
|
+
create(agent: {
|
|
436
|
+
id: string;
|
|
437
|
+
name: string;
|
|
438
|
+
description?: string | null;
|
|
439
|
+
}, firstRevision: NewRevision): Promise<void>;
|
|
440
|
+
get(id: string): Promise<AgentRow | undefined>;
|
|
441
|
+
/** The agent an external reference ("<source>:<kind>:<id>") maps to (Runs.createInline), or undefined before its first
|
|
442
|
+
* run. */
|
|
443
|
+
byExternal(ref: string): Promise<AgentRow | undefined>;
|
|
444
|
+
list(options?: {
|
|
445
|
+
archived?: boolean;
|
|
446
|
+
}): Promise<AgentRow[]>;
|
|
447
|
+
/** Archives the agent, or unarchives it. Archived, every trigger of it that is on is turned off in the same transaction
|
|
448
|
+
* (`disabled` set to `why`, JSON; its scope rows dropped), and those are the answer: from its commit no firing starts a
|
|
449
|
+
* run of the agent (triggers.fire refuses it, AgentArchived), and none of its triggers is made on or turned on.
|
|
450
|
+
* Unarchived, none turns on again: the answer is empty. */
|
|
451
|
+
archive(id: string, archived: boolean, why?: unknown): Promise<{
|
|
452
|
+
id: string;
|
|
453
|
+
name: string;
|
|
454
|
+
}[]>;
|
|
455
|
+
/** Adds a revision and makes it the agent's current one, in one commit. */
|
|
456
|
+
addRevision(revision: NewRevision & {
|
|
457
|
+
agentId: string;
|
|
458
|
+
}): Promise<void>;
|
|
459
|
+
/** Makes `revisionId`, one of the agent's own, its current one. StoreConstraint when it is not a revision of `agentId`. */
|
|
460
|
+
setCurrent(agentId: string, revisionId: string): Promise<void>;
|
|
461
|
+
revision(id: string): Promise<RevisionRow | undefined>;
|
|
462
|
+
revisions(agentId: string): Promise<RevisionRow[]>;
|
|
463
|
+
}
|
|
464
|
+
export interface Templates {
|
|
465
|
+
/** A template applied: the agent, its first revision (with the package) and its triggers, in one transaction, all or
|
|
466
|
+
* nothing. The triggers are checked before it; inside it the only failures are the store's. With `idempotencyKey`, the
|
|
467
|
+
* same key again answers the first apply's result and writes nothing. */
|
|
468
|
+
apply(agent: {
|
|
469
|
+
id: string;
|
|
470
|
+
name: string;
|
|
471
|
+
description?: string | null;
|
|
472
|
+
}, revision: NewRevision, triggers: readonly TriggerDef[], idempotencyKey?: string): Promise<{
|
|
473
|
+
agentId: string;
|
|
474
|
+
revisionId: string;
|
|
475
|
+
}>;
|
|
476
|
+
/** A template upgraded: revision n+1 made current, and the triggers changed by name (upsert, remove), in one transaction.
|
|
477
|
+
* The agent's learning is untouched. */
|
|
478
|
+
upgrade(agentId: string, revision: NewRevision, triggers: {
|
|
479
|
+
upsert: readonly TriggerDef[];
|
|
480
|
+
remove: readonly string[];
|
|
481
|
+
}): Promise<void>;
|
|
482
|
+
}
|
|
483
|
+
export interface Triggers {
|
|
484
|
+
get(id: string): Promise<TriggerRow | undefined>;
|
|
485
|
+
list(agentId: string): Promise<TriggerRow[]>;
|
|
486
|
+
/** Every trigger, oldest first. */
|
|
487
|
+
all(): Promise<TriggerRow[]>;
|
|
488
|
+
/** The trigger and, while it is enabled, its scope rows (`scopes`), in one transaction: a scope another enabled trigger
|
|
489
|
+
* holds is refused (StoreConstraint on trigger_scopes), nothing written; one made on for an archived agent too
|
|
490
|
+
* (AgentArchived). */
|
|
491
|
+
create(trigger: NewTrigger, scopes?: readonly TriggerScope[]): Promise<TriggerRow>;
|
|
492
|
+
/** The fields given changed, `updatedAt` set: undefined when there is no such trigger. With `scopes`, its scope rows
|
|
493
|
+
* rewritten in the same transaction (none while it is off); a patch that turns it off drops them. One that leaves it
|
|
494
|
+
* on for an archived agent, turned on or moved there, is refused (AgentArchived), nothing written. */
|
|
495
|
+
update(id: string, patch: TriggerPatch, scopes?: readonly TriggerScope[]): Promise<TriggerRow | undefined>;
|
|
496
|
+
/** The trigger, its scope rows and its firings gone. */
|
|
497
|
+
remove(id: string): Promise<void>;
|
|
498
|
+
/** Enables the trigger and writes its scope rows, in one transaction; refused for an archived agent's (AgentArchived). */
|
|
499
|
+
enable(triggerId: string, scopes: readonly TriggerScope[]): Promise<void>;
|
|
500
|
+
/** Disables the trigger (with why, JSON) and deletes its scope rows, in one transaction. */
|
|
501
|
+
disable(triggerId: string, why?: unknown): Promise<void>;
|
|
502
|
+
/** The firing starts a run: the queued run, the `started` firing that names it (the due firing's row, or a new one) and
|
|
503
|
+
* the trigger's last_run_id, with its failure streak reset, in one transaction; with `launch`, the run's launch row in
|
|
504
|
+
* that same transaction (the store's one writeLaunch). A run of an archived agent is refused in it (AgentArchived),
|
|
505
|
+
* nothing written: a firing claimed before the archive committed starts no run after it. */
|
|
506
|
+
fire(firing: Firing, run: {
|
|
507
|
+
id: string;
|
|
508
|
+
agentId: string;
|
|
509
|
+
revisionId: string;
|
|
510
|
+
}, options?: {
|
|
511
|
+
launch?: RunLaunchInput;
|
|
512
|
+
}): Promise<RunRow>;
|
|
513
|
+
/** The enabled triggers listening on (`kind`, `scope`): its scope rows. */
|
|
514
|
+
scoped(kind: string, scope: string): Promise<string[]>;
|
|
515
|
+
/** `firings` recorded and the trigger's `patch` applied, in one transaction; a key already there is not recorded again
|
|
516
|
+
* (`created` false for it). With `room`, a due firing is refused (TriggerFull, nothing written) while the trigger holds
|
|
517
|
+
* `room` due already. Undefined when there is no such trigger. */
|
|
518
|
+
record(triggerId: string, firings: readonly NewFiring[], options?: {
|
|
519
|
+
patch?: TriggerPatch;
|
|
520
|
+
room?: number;
|
|
521
|
+
}): Promise<{
|
|
522
|
+
created: boolean[];
|
|
523
|
+
} | undefined>;
|
|
524
|
+
/** The firing's row, shown or kept for its day. */
|
|
525
|
+
firing(triggerId: string, key: string): Promise<FiringRow | undefined>;
|
|
526
|
+
/** The trigger's history, newest first: its shown firings. */
|
|
527
|
+
firings(triggerId: string): Promise<FiringRow[]>;
|
|
528
|
+
/** The firing changed (with its trigger's last_run_id moved to a newer run it names, and `streak`), in one transaction:
|
|
529
|
+
* undefined when the firing is gone (its trigger deleted). `paused`: this failure turned the trigger off. */
|
|
530
|
+
settle(triggerId: string, key: string, change: FiringChange, streak?: FiringStreak): Promise<{
|
|
531
|
+
firing: FiringRow;
|
|
532
|
+
paused: boolean;
|
|
533
|
+
} | undefined>;
|
|
534
|
+
/** Every due firing, and every failed one whose trigger.failed is not marked queued, oldest first. */
|
|
535
|
+
pending(): Promise<FiringRow[]>;
|
|
536
|
+
/** A message_run firing's message queued for run `runId` as a command row (its body's origin names the trigger), with
|
|
537
|
+
* the firing marked sent and the trigger's streak reset, in one transaction; unless the run already holds `bound.max`
|
|
538
|
+
* untaken command rows from this trigger, read in that same transaction: then the firing is skipped with
|
|
539
|
+
* `bound.reason` and nothing is queued. Undefined when the firing is gone or no longer due. A run that has ended takes no
|
|
540
|
+
* message (RunFinal, as command()), and nothing is written. */
|
|
541
|
+
message(firing: {
|
|
542
|
+
triggerId: string;
|
|
543
|
+
key: string;
|
|
544
|
+
}, runId: string, command: {
|
|
545
|
+
kind: string;
|
|
546
|
+
body: unknown;
|
|
547
|
+
}, bound: {
|
|
548
|
+
max: number;
|
|
549
|
+
reason: string;
|
|
550
|
+
}): Promise<{
|
|
551
|
+
sent: true;
|
|
552
|
+
commandId: number;
|
|
553
|
+
} | {
|
|
554
|
+
skipped: string;
|
|
555
|
+
} | undefined>;
|
|
556
|
+
/** Every due firing waiting for its trigger's room (waits_on), oldest first, each with whether the room is there now
|
|
557
|
+
* (fewer of its trigger's started runs not ended than its max_active_runs): one read for all of them. */
|
|
558
|
+
waiting(): Promise<(FiringRow & {
|
|
559
|
+
readonly free: boolean;
|
|
560
|
+
})[]>;
|
|
561
|
+
/** The soonest next time of an enabled trigger, or null. */
|
|
562
|
+
soonest(): Promise<number | null>;
|
|
563
|
+
/** How many of the trigger's started runs have not ended (a run reopened later does not count). */
|
|
564
|
+
activeRuns(triggerId: string): Promise<number>;
|
|
565
|
+
/** The history kept to `history` shown firings: older ones a sender's key names (manual, pushed) are kept for their day
|
|
566
|
+
* (shown 0), others removed; shown-0 rows past `dayMs` removed, then the oldest past `kept` of them. Never a due
|
|
567
|
+
* firing, a failure not yet told, nor a started firing whose run has not ended. Answers how many went past `kept`. */
|
|
568
|
+
prune(triggerId: string, options: {
|
|
569
|
+
history: number;
|
|
570
|
+
dayMs: number;
|
|
571
|
+
keepByKey: (by: string) => boolean;
|
|
572
|
+
kept?: number;
|
|
573
|
+
}): Promise<number>;
|
|
574
|
+
}
|
|
575
|
+
export interface Runs {
|
|
576
|
+
/** A queued run of `revisionId`, its row's only writer until a runner claims it. With `origin`, the origin row is written
|
|
577
|
+
* in the same transaction, so a retry under the same key finds this run (runOfOrigin); a key already used is refused
|
|
578
|
+
* (StoreConstraint), and nothing is written. With `launch`, its launch row is written in the same transaction too (all
|
|
579
|
+
* or nothing). */
|
|
580
|
+
create(run: {
|
|
581
|
+
id: string;
|
|
582
|
+
agentId: string;
|
|
583
|
+
revisionId: string;
|
|
584
|
+
origin?: RunOrigin;
|
|
585
|
+
}, launch?: RunLaunchInput): Promise<RunRow>;
|
|
586
|
+
/** A run whose agent is given inline and mapped to a source system by `agent.ref` and `revision.version`. In one
|
|
587
|
+
* transaction: the agent (one per `ref`, written on its first run, its name and description brought up to the version
|
|
588
|
+
* whose first use this is) and the revision (one per `version`, made current on its first use) are written or read, then
|
|
589
|
+
* the run, its origin and its launch. Idempotent — a later run under the same (`ref`, `version`) reuses that revision and
|
|
590
|
+
* changes nothing; a different body under an existing version is refused (ExternalBodyConflict), nothing written. The
|
|
591
|
+
* revision's `note` is kept by its first use, as an edit's note is; it is not part of its body. */
|
|
592
|
+
createInline(input: {
|
|
593
|
+
agent: {
|
|
594
|
+
id: string;
|
|
595
|
+
name: string;
|
|
596
|
+
description?: string | null;
|
|
597
|
+
ref: string;
|
|
598
|
+
};
|
|
599
|
+
revision: {
|
|
600
|
+
id: string;
|
|
601
|
+
version: string;
|
|
602
|
+
kind: string;
|
|
603
|
+
body: unknown;
|
|
604
|
+
skills?: unknown;
|
|
605
|
+
note?: string;
|
|
606
|
+
};
|
|
607
|
+
run: {
|
|
608
|
+
id: string;
|
|
609
|
+
origin?: RunOrigin;
|
|
610
|
+
};
|
|
611
|
+
launch: RunLaunchInput;
|
|
612
|
+
}): Promise<RunRow>;
|
|
613
|
+
get(id: string): Promise<RunRow | undefined>;
|
|
614
|
+
/** The run's launch row (the runner reads it at its claim; the server for views). StoreLaunchMissing when the run has
|
|
615
|
+
* none (it was not started with one), never a default. */
|
|
616
|
+
launch(runId: string): Promise<RunLaunchRow>;
|
|
617
|
+
/** Newest first, at most `limit` (no limit: all). `archived` filters on the run's own archive time (true: archived,
|
|
618
|
+
* false: not); its agent's archive is read apart. */
|
|
619
|
+
list(filter: {
|
|
620
|
+
agentId?: string;
|
|
621
|
+
revisionId?: string;
|
|
622
|
+
state?: RunState;
|
|
623
|
+
archived?: boolean;
|
|
624
|
+
limit?: number;
|
|
625
|
+
}): Promise<RunRow[]>;
|
|
626
|
+
/** Archives the run (its own archive time), or unarchives it: idempotent. */
|
|
627
|
+
archive(runId: string, archived: boolean): Promise<void>;
|
|
628
|
+
/** A person's follow-up to a run that ended completed: in one transaction, the run goes back to running with no runner
|
|
629
|
+
* (released, so a runner claims it at once by the claimable rule's released branch), its end's own fields cleared
|
|
630
|
+
* (ended_at, summary, outcome, its waits) and everything it did kept (its epoch, its journal, its cost and metrics,
|
|
631
|
+
* so its next turn is booked on top of what it spent), and `command` (the follow-up's steer) is written untaken for it.
|
|
632
|
+
* Only an agentic run that ended completed (state 'ended'), not imported and not a learning run, reopens: a workflow,
|
|
633
|
+
* a failed, stopped or cancelled run, any other, or none is RunFinal, and nothing is written. */
|
|
634
|
+
reopen(runId: string, command: {
|
|
635
|
+
kind: string;
|
|
636
|
+
body?: unknown;
|
|
637
|
+
}): Promise<Command>;
|
|
638
|
+
/** The runs a runner may claim, oldest first: queued; parked with an untaken command or its wake_at passed; running with
|
|
639
|
+
* no runner (released at a runner's shutdown: it stays running, a run that started keeps that fact) or its claim run
|
|
640
|
+
* out. */
|
|
641
|
+
claimable(options?: {
|
|
642
|
+
limit?: number;
|
|
643
|
+
}): Promise<string[]>;
|
|
644
|
+
/** Claims up to `k` claimable runs for `runner`, oldest first, in one transaction: each at its own epoch + 1, with its
|
|
645
|
+
* `from`. A runner fills its free loops with one call. */
|
|
646
|
+
claimMany(runner: string, k: number, options?: {
|
|
647
|
+
leaseMs?: number;
|
|
648
|
+
}): Promise<Claim[]>;
|
|
649
|
+
/** Changes the run's row under `claim`, and in the same commit writes `also` and marks `take`'s command rows taken (a
|
|
650
|
+
* stop the runner applies itself ends the run with its stop row taken, or neither). Refused, nothing written: Fenced when
|
|
651
|
+
* the run's epoch is not the claim's; CommandTaken when a command in `take` is taken already, or not the run's. When the
|
|
652
|
+
* patch writes `signInHanded` (the runner's bind), the answer carries `save`: whether this run holds the sign-in's save
|
|
653
|
+
* lease, decided in this same transaction so two binds of one sign-in never both save — no other run holds a handed
|
|
654
|
+
* pointer, counting a running run and (within `signInSettleMs` of leaving running, a vendor's settle window) one that
|
|
655
|
+
* recently left running. `signInSettleMs` defaults to 0 (other vendors free the lease the instant a run leaves running). */
|
|
656
|
+
update(claim: Claim, patch: RunPatch, rows?: {
|
|
657
|
+
readonly also?: readonly AlsoRow[];
|
|
658
|
+
readonly take?: readonly number[];
|
|
659
|
+
readonly signInSettleMs?: number;
|
|
660
|
+
}): Promise<UpdatedRun>;
|
|
661
|
+
}
|
|
662
|
+
/** A saved MCP server: its listed tools (each with whether it can be granted, and why not), the owner's prices, and its
|
|
663
|
+
* credential sealed (store/seal.ts): bytes the store never opens. `tools` and `prices` are JSON. */
|
|
664
|
+
export interface McpServerRow {
|
|
665
|
+
readonly name: string;
|
|
666
|
+
readonly url: string;
|
|
667
|
+
readonly auth: string;
|
|
668
|
+
readonly protocol: string | null;
|
|
669
|
+
readonly tools: unknown;
|
|
670
|
+
readonly prices: unknown;
|
|
671
|
+
/** The remote server's reported info (its name and version) and its instructions, as it gave them, bounded at save: JSON
|
|
672
|
+
* and TEXT, or null when the server gave none. Shown on a read; `instructions` is never handed to the model. */
|
|
673
|
+
readonly serverInfo: unknown;
|
|
674
|
+
readonly instructions: string | null;
|
|
675
|
+
readonly sealed: Uint8Array | null;
|
|
676
|
+
/** A refresh in flight: its holder and the lease's end (ms), or null. */
|
|
677
|
+
readonly refreshHolder: string | null;
|
|
678
|
+
readonly refreshUntil: number | null;
|
|
679
|
+
/** Whether that lease has run out, judged by the store's own clock when the row was read: the clock leaseRefresh writes
|
|
680
|
+
* and grants it by. A reader judges the lease by this, never by its own clock against refreshUntil: on another machine
|
|
681
|
+
* its clock may run ahead of the store's, and a live lease would read as lapsed. False with no lease. */
|
|
682
|
+
readonly refreshLapsed: boolean;
|
|
683
|
+
/** How much of the credential's access token is left (ms; negative once run out), by the store's own clock when the row
|
|
684
|
+
* was read: the store stamps its end when the credential is written (token_until). A claim judges the token by this,
|
|
685
|
+
* never by its own clock against the set's expires_at, which the writer stamped on its clock. Null when the writer
|
|
686
|
+
* gave no measure of the token's life. */
|
|
687
|
+
readonly tokenLeftMs: number | null;
|
|
688
|
+
readonly createdAt: number;
|
|
689
|
+
readonly updatedAt: number;
|
|
690
|
+
/** When the tools were last listed (ms): a refresh moves this, not updatedAt, so a refresh is not read as an owner edit.
|
|
691
|
+
* Null for a row written before this column. */
|
|
692
|
+
readonly listedAt: number | null;
|
|
693
|
+
/** When the sealed credential was last set (ms): a new credential's save or a sign-in, never a token refresh. Null with
|
|
694
|
+
* no credential. */
|
|
695
|
+
readonly credentialChangedAt: number | null;
|
|
696
|
+
}
|
|
697
|
+
/** A run's MCP pin: what it may call, per granted server (url, tools, prices), written once at its first claim. */
|
|
698
|
+
export interface McpPinRow {
|
|
699
|
+
readonly runId: string;
|
|
700
|
+
readonly body: unknown;
|
|
701
|
+
readonly pinnedAt: number;
|
|
702
|
+
}
|
|
703
|
+
/** The longest an MCP token refresh may take: two tries of 4 s each. The runner's claim step gives its call up by then. */
|
|
704
|
+
export declare const MCP_REFRESH_CALL_MS: number;
|
|
705
|
+
/** The most one bounded store write may take, counted from its call: its wait behind its connection (SQLite's queue, a
|
|
706
|
+
* Postgres pool's connect), for the database's lock, its statement and its commit (keepRefreshed's on both stores). */
|
|
707
|
+
export declare const STORE_WRITE_DEADLINE_MS = 10000;
|
|
708
|
+
/** A refresh lease's length by default: it covers the holder's whole custody of the refresh token, the refresh call
|
|
709
|
+
* (MCP_REFRESH_CALL_MS) and then the keep of its new set (STORE_WRITE_DEADLINE_MS, from the keep's call), with 2 s to
|
|
710
|
+
* spare (a Postgres commit sent at the deadline is given 1 s of it to answer). A lease shorter than both lapses while a
|
|
711
|
+
* slow commit is still landing a set whose token the provider already spent, and a waiter then takes over and refreshes
|
|
712
|
+
* with the spent one. Made from the two bounds so it cannot drift. */
|
|
713
|
+
export declare const MCP_REFRESH_LEASE_MS: number;
|
|
714
|
+
/** A saved server's credential as a writer read it: its auth type, whether one is sealed, and when that was set (a token
|
|
715
|
+
* refresh keeps the time; a new credential or a sign-in moves it). Null: no server by that name. */
|
|
716
|
+
export type McpCredentialMark = {
|
|
717
|
+
readonly auth: string;
|
|
718
|
+
readonly sealed: boolean;
|
|
719
|
+
readonly changedAt: number | null;
|
|
720
|
+
} | null;
|
|
721
|
+
/** The fields of a server's write (Mcp.put). */
|
|
722
|
+
export type McpServerWrite = {
|
|
723
|
+
name: string;
|
|
724
|
+
url: string;
|
|
725
|
+
auth: string;
|
|
726
|
+
protocol?: string | null;
|
|
727
|
+
tools: unknown;
|
|
728
|
+
prices?: unknown;
|
|
729
|
+
serverInfo?: unknown;
|
|
730
|
+
instructions?: string | null;
|
|
731
|
+
sealed?: Uint8Array | null;
|
|
732
|
+
listedAt?: number;
|
|
733
|
+
updatedAt?: number;
|
|
734
|
+
credentialChangedAt?: number | null;
|
|
735
|
+
tokenLeftMs?: number | null;
|
|
736
|
+
};
|
|
737
|
+
export interface Mcp {
|
|
738
|
+
/** The server's write: the server's row, inserted or replaced by name (its first save's time kept). An owner's save
|
|
739
|
+
* clears any refresh lease and changes the credential, so a refresh in flight is dropped (keepRefreshed's `kept: false`)
|
|
740
|
+
* and never overwrites it. `tokenLeftMs`: the writer's measure of the credential's access token's remaining life (a
|
|
741
|
+
* duration, on its own clock); the store stamps the token's end on its clock from it (token_until), none without it. */
|
|
742
|
+
put(server: McpServerWrite): Promise<McpServerRow>;
|
|
743
|
+
/** put(), only while the server's credential is still `expected` (its mark as the writer read it; null: no server by
|
|
744
|
+
* that name), compared and written in one statement: no other write lands between. Undefined, writing nothing, when
|
|
745
|
+
* it is not. */
|
|
746
|
+
putIfCredential(server: McpServerWrite, expected: McpCredentialMark): Promise<McpServerRow | undefined>;
|
|
747
|
+
/** An owner's rewrite of a row it read, its credential kept as it is (a tools refresh, a save that sends no new
|
|
748
|
+
* credential): the listing, prices, url and times written by a compare-and-set on the CREDENTIAL, iff the row is still
|
|
749
|
+
* saved and its sealed value is still `seen` (the one the owner read). The credential's columns (sealed, token_until,
|
|
750
|
+
* credential_changed_at) and any refresh lease are left as they are, so a runner's refresh in flight still keeps its
|
|
751
|
+
* set. undefined, writing nothing, when the credential changed meanwhile (a refresh kept a rotated set) or the row went:
|
|
752
|
+
* the caller reads it again and re-applies its change onto the fresh row, a bounded few times. */
|
|
753
|
+
rewrite(server: {
|
|
754
|
+
name: string;
|
|
755
|
+
url: string;
|
|
756
|
+
auth: string;
|
|
757
|
+
protocol?: string | null;
|
|
758
|
+
tools: unknown;
|
|
759
|
+
prices?: unknown;
|
|
760
|
+
serverInfo?: unknown;
|
|
761
|
+
instructions?: string | null;
|
|
762
|
+
listedAt?: number;
|
|
763
|
+
updatedAt?: number;
|
|
764
|
+
}, seen: Uint8Array | null): Promise<McpServerRow | undefined>;
|
|
765
|
+
remove(name: string): Promise<void>;
|
|
766
|
+
/** remove(), only while the server's credential is still `expected` (its mark as the remover read it), compared and
|
|
767
|
+
* deleted in one statement. False, deleting nothing, when it is not (or the server is gone). */
|
|
768
|
+
removeIfCredential(name: string, expected: NonNullable<McpCredentialMark>): Promise<boolean>;
|
|
769
|
+
/** The registry's rows, by name. */
|
|
770
|
+
servers(): Promise<McpServerRow[]>;
|
|
771
|
+
server(name: string): Promise<McpServerRow | undefined>;
|
|
772
|
+
/** The run's pin, or none (a run that grants no MCP tool has none). */
|
|
773
|
+
pin(runId: string): Promise<McpPinRow | undefined>;
|
|
774
|
+
/** Writes the run's pin under `claim` unless it has one, in one transaction with the claim's epoch fence, and answers the
|
|
775
|
+
* pin as stored: never rewritten, so a second call (or a later claim's) reads the first. Fenced, writing nothing, on a
|
|
776
|
+
* stale claim. */
|
|
777
|
+
pinOnce(claim: Claim, body: unknown): Promise<McpPinRow>;
|
|
778
|
+
/** One refresh at a time per server (a provider that rotates refresh tokens spends the old one at each refresh): the lease
|
|
779
|
+
* is granted to `holder` for `ms` (MCP_REFRESH_LEASE_MS by default) only while the credential is still the one it read
|
|
780
|
+
* (`seen`: the sealed bytes, null for none) and no live lease is held. Not granted: the current row comes back, and the
|
|
781
|
+
* caller waits for the holder's set (re-reading) or the lease's end. A lease whose holder died runs out; the next claim
|
|
782
|
+
* may take it. `ms` must be longer than the refresh call's own deadline (MCP_REFRESH_CALL_MS: the holder gives its call
|
|
783
|
+
* up by then), so a lease never lapses while its holder's call may still spend the token; a shorter one is refused. */
|
|
784
|
+
leaseRefresh(name: string, lease: {
|
|
785
|
+
seen: Uint8Array | null;
|
|
786
|
+
holder: string;
|
|
787
|
+
ms?: number;
|
|
788
|
+
}): Promise<{
|
|
789
|
+
leased: boolean;
|
|
790
|
+
row: McpServerRow;
|
|
791
|
+
}>;
|
|
792
|
+
/** A refresh's new credential, kept by a compare-and-set on the CREDENTIAL in one statement: written iff the server's
|
|
793
|
+
* sealed value is still `seen` (the one the refresh started from, its lease's), whoever holds the lease now, so a
|
|
794
|
+
* token already spent at the provider is never lost to a lease that lapsed; the lease cleared only when `holder` still
|
|
795
|
+
* holds it. `kept: false` (nothing written) when the credential changed meanwhile (a newer set landed, or the owner saved
|
|
796
|
+
* one): ours is dropped, and no refresh is tried again with any token. Under one deadline from its call
|
|
797
|
+
* (STORE_WRITE_DEADLINE_MS). `row`: the server as it is after, undefined when it is no longer saved. */
|
|
798
|
+
keepRefreshed(name: string, keep: {
|
|
799
|
+
seen: Uint8Array | null;
|
|
800
|
+
sealed: Uint8Array;
|
|
801
|
+
holder: string;
|
|
802
|
+
tokenLeftMs?: number | null;
|
|
803
|
+
}): Promise<{
|
|
804
|
+
kept: boolean;
|
|
805
|
+
row: McpServerRow | undefined;
|
|
806
|
+
}>;
|
|
807
|
+
/** Gives the lease back without a new credential (the refresh failed or got no answer), so the next claim may try at once. */
|
|
808
|
+
releaseRefresh(name: string, holder: string): Promise<void>;
|
|
809
|
+
}
|
|
810
|
+
/** A server setting as a row (store schema `settings`): its key, its value (JSON) and when it was last written. */
|
|
811
|
+
export interface SettingRow {
|
|
812
|
+
readonly key: string;
|
|
813
|
+
readonly value: unknown;
|
|
814
|
+
readonly updatedAt: number;
|
|
815
|
+
}
|
|
816
|
+
export interface Settings {
|
|
817
|
+
/** The value saved under `key`, or undefined when none is (a value saved as null reads as null, told apart from none). */
|
|
818
|
+
get(key: string): Promise<unknown | undefined>;
|
|
819
|
+
/** Saves `value` (JSON) under `key`, inserted or replaced in place. */
|
|
820
|
+
put(key: string, value: unknown): Promise<void>;
|
|
821
|
+
/** The key's row goes; a key with no row is left as it is. */
|
|
822
|
+
remove(key: string): Promise<void>;
|
|
823
|
+
/** Every setting, by key. */
|
|
824
|
+
all(): Promise<SettingRow[]>;
|
|
825
|
+
}
|
|
826
|
+
/** A sealed key as a row (store schema `sealed_keys`): its name and the bytes the server sealed (store/seal.ts, AAD
|
|
827
|
+
* sealed_keys|<name>|sealed), which the store never opens. */
|
|
828
|
+
export interface SealedKeyRow {
|
|
829
|
+
readonly name: string;
|
|
830
|
+
readonly sealed: Uint8Array;
|
|
831
|
+
readonly updatedAt: number;
|
|
832
|
+
}
|
|
833
|
+
/** The tables the store keeps a sealed value in: each a plane of the server's secrets. */
|
|
834
|
+
export type SealedPlane = "sealed_keys" | "mcp_servers" | "mcp_oauth_pending" | "trigger_settings" | "sign_ins" | "sign_in_tombstones" | "computer_viewers" | "run_launch";
|
|
835
|
+
/** One sealed value the store keeps: its plane, where in it (its row's key, by column), the AAD it was sealed under (the
|
|
836
|
+
* store's documented one for that table: store/seal.ts aadOf, or trigger_settings|<adapter>|<scope>|<field>), and its
|
|
837
|
+
* sealed bytes. The store never opens it. */
|
|
838
|
+
export interface SealedSecretRow {
|
|
839
|
+
readonly plane: SealedPlane;
|
|
840
|
+
readonly where: Readonly<Record<string, string>>;
|
|
841
|
+
readonly aad: string;
|
|
842
|
+
readonly sealed: Uint8Array;
|
|
843
|
+
}
|
|
844
|
+
/** Every sealed value the store keeps, across all its planes, in one read: what a runner's redaction set holds at each
|
|
845
|
+
* claim (runner/store-secrets.ts), so a run's text that quotes any secret the server keeps is cut when it is written. */
|
|
846
|
+
export interface SealedSecrets {
|
|
847
|
+
all(): Promise<SealedSecretRow[]>;
|
|
848
|
+
}
|
|
849
|
+
export interface SealedKeys {
|
|
850
|
+
/** The sealed bytes saved under `name`, or undefined when none is. */
|
|
851
|
+
get(name: string): Promise<Uint8Array | undefined>;
|
|
852
|
+
/** Saves `sealed` under `name`, inserted or replaced in place. */
|
|
853
|
+
put(name: string, sealed: Uint8Array): Promise<void>;
|
|
854
|
+
/** The key's row goes. */
|
|
855
|
+
remove(name: string): Promise<void>;
|
|
856
|
+
/** Every saved key, by name (its bytes never opened here). */
|
|
857
|
+
all(): Promise<SealedKeyRow[]>;
|
|
858
|
+
}
|
|
859
|
+
/** One session a provider runs, with the labels we gave it and the rest of the provider's entry for it (store schema
|
|
860
|
+
* `computer_ledger`). */
|
|
861
|
+
export interface ComputerLedgerRow {
|
|
862
|
+
readonly provider: string;
|
|
863
|
+
readonly sessionId: string;
|
|
864
|
+
readonly labels: Readonly<Record<string, string>>;
|
|
865
|
+
/** The provider's other fields for the session, as it gave them (a phone's image and deadline). */
|
|
866
|
+
readonly detail: Readonly<Record<string, unknown>>;
|
|
867
|
+
readonly updatedAt: number;
|
|
868
|
+
}
|
|
869
|
+
/** The labels of the sessions a provider runs with none of its own (a phone provider's), so its list, an attach by
|
|
870
|
+
* labels and the janitor outlive a restart. */
|
|
871
|
+
export interface ComputerLedger {
|
|
872
|
+
/** Saves `labels` and `detail` for `provider`'s session `sessionId`, inserted or replaced in place. */
|
|
873
|
+
put(provider: string, sessionId: string, labels: Readonly<Record<string, string>>, detail: Readonly<Record<string, unknown>>): Promise<void>;
|
|
874
|
+
/** The session's row, or undefined when none is kept. */
|
|
875
|
+
get(provider: string, sessionId: string): Promise<ComputerLedgerRow | undefined>;
|
|
876
|
+
/** Every session of `provider`, by its id. */
|
|
877
|
+
list(provider: string): Promise<ComputerLedgerRow[]>;
|
|
878
|
+
/** The session's row goes. */
|
|
879
|
+
remove(provider: string, sessionId: string): Promise<void>;
|
|
880
|
+
}
|
|
881
|
+
/** A trigger source's sealed setting as a row (store schema `trigger_settings`): its adapter, scope ("server" for the one
|
|
882
|
+
* server-wide set, or a trigger's id for its own), field, and the value sealed (store/seal.ts) under AAD
|
|
883
|
+
* trigger_settings|<adapter>|<scope>|<field>: TEXT the store never opens. */
|
|
884
|
+
export interface TriggerSettingRow {
|
|
885
|
+
readonly adapter: string;
|
|
886
|
+
readonly scope: string;
|
|
887
|
+
readonly field: string;
|
|
888
|
+
readonly sealed: string;
|
|
889
|
+
readonly updatedAt: number;
|
|
890
|
+
}
|
|
891
|
+
export interface TriggerSettings {
|
|
892
|
+
/** Every (scope, field) the adapter has, by scope then field. */
|
|
893
|
+
get(adapter: string): Promise<TriggerSettingRow[]>;
|
|
894
|
+
/** Saves (inserts or replaces in place) the sealed value for the adapter's scope and field. */
|
|
895
|
+
put(setting: {
|
|
896
|
+
adapter: string;
|
|
897
|
+
scope: string;
|
|
898
|
+
field: string;
|
|
899
|
+
sealed: string;
|
|
900
|
+
}): Promise<void>;
|
|
901
|
+
/** A scope's fields go (a deleted trigger's). */
|
|
902
|
+
removeScope(adapter: string, scope: string): Promise<void>;
|
|
903
|
+
}
|
|
904
|
+
/** An MCP OAuth sign-in in flight (store schema `mcp_oauth_pending`): its state the key, the server it is for, its secret
|
|
905
|
+
* parts (the PKCE verifier and the OAuth client, with its secret) sealed together (store/seal.ts, AAD
|
|
906
|
+
* mcp_oauth_pending|<state>|sealed) as bytes the store never opens, the non-secret working state the callback needs
|
|
907
|
+
* (`working`: discovery, kind, scope, resource and url, plain JSON — no secret), and when it expires (ms). */
|
|
908
|
+
export interface McpOauthPendingRow {
|
|
909
|
+
readonly state: string;
|
|
910
|
+
readonly server: string;
|
|
911
|
+
readonly sealed: Uint8Array;
|
|
912
|
+
readonly working: unknown;
|
|
913
|
+
readonly expiresAt: number;
|
|
914
|
+
}
|
|
915
|
+
export interface McpOauth {
|
|
916
|
+
/** Saves a pending sign-in, inserted or replaced by its state. */
|
|
917
|
+
put(pending: McpOauthPendingRow): Promise<void>;
|
|
918
|
+
/** Deletes the pending sign-in `state` and returns it, in one statement (atomic, single-use): the row if it was there and
|
|
919
|
+
* is not past its expiry (`now`, else the store's clock), else undefined. The row is deleted whether or not it had
|
|
920
|
+
* expired, so a replay and an expired state both read as gone and cannot be retried. The one way to read a pending
|
|
921
|
+
* sign-in: two concurrent takes of one state can never both get the row, which a get()+remove() split could not
|
|
922
|
+
* promise. The secret parts come back sealed; the caller opens them at their own AAD, so the store opens nothing. */
|
|
923
|
+
take(state: string, now?: number): Promise<McpOauthPendingRow | undefined>;
|
|
924
|
+
/** Removes every pending sign-in whose expiry is at or before `now`; answers how many went. */
|
|
925
|
+
sweepExpired(now: number): Promise<number>;
|
|
926
|
+
/** How many pending sign-ins are still live (expiry after `now`): the server caps the rows in flight by it. */
|
|
927
|
+
count(now: number): Promise<number>;
|
|
928
|
+
}
|
|
929
|
+
/** A saved browser sign-in as the store holds it (store schema `sign_ins`): one live row per agent and provider, its
|
|
930
|
+
* pointer sealed (store/seal.ts, AAD sign_ins|<agent>:<provider>|pointer), which the store never opens. `name` is the
|
|
931
|
+
* owner's label for it ("default"). */
|
|
932
|
+
export interface SignInRow {
|
|
933
|
+
readonly agentId: string;
|
|
934
|
+
readonly provider: string;
|
|
935
|
+
readonly name: string;
|
|
936
|
+
readonly pointerSealed: Uint8Array;
|
|
937
|
+
readonly savedAt: number;
|
|
938
|
+
/** This save's number: 1 when the row was first saved, one more on every save of it since. A verify is guarded by it
|
|
939
|
+
* (verify's ifSave), never by savedAt, which two saves in one millisecond share. */
|
|
940
|
+
readonly save: number;
|
|
941
|
+
/** When a run last verified this sign-in (saved a live session back to the vendor), ms; null when none has since it was
|
|
942
|
+
* saved. The v2 view's verified_at. */
|
|
943
|
+
readonly verifiedAt: number | null;
|
|
944
|
+
}
|
|
945
|
+
/** A forgotten sign-in's pointer, kept sealed byte for byte as its live row held it (so it still opens under the same
|
|
946
|
+
* binding), only so a server started later can cut it from what a run it was handed shows. */
|
|
947
|
+
export interface SignInTombstoneRow {
|
|
948
|
+
readonly agentId: string;
|
|
949
|
+
readonly provider: string;
|
|
950
|
+
readonly pointerSealed: Uint8Array;
|
|
951
|
+
readonly forgottenAt: number;
|
|
952
|
+
}
|
|
953
|
+
/** How many forgotten pointers an agent keeps per store, the oldest dropped first. */
|
|
954
|
+
export declare const SIGN_IN_TOMBSTONES_KEPT = 32;
|
|
955
|
+
export interface SignIns {
|
|
956
|
+
/** Saves the one live sign-in for the agent and provider, its pointer already sealed by the caller: inserted, or replaced
|
|
957
|
+
* in place when one is saved already (one per agent and provider). */
|
|
958
|
+
save(signIn: {
|
|
959
|
+
agentId: string;
|
|
960
|
+
provider: string;
|
|
961
|
+
name: string;
|
|
962
|
+
pointerSealed: Uint8Array;
|
|
963
|
+
}): Promise<SignInRow>;
|
|
964
|
+
/** Saves the agent's first sign-in for the provider only when it has none, in one atomic step: `saved` true with the row
|
|
965
|
+
* it inserted, or false with the live row a save before it left (never the one asked for), so a caller that made a
|
|
966
|
+
* vendor object for it lets its own go and uses the winner's. Two first creates at once: exactly one wins. */
|
|
967
|
+
saveIfAbsent(signIn: {
|
|
968
|
+
agentId: string;
|
|
969
|
+
provider: string;
|
|
970
|
+
name: string;
|
|
971
|
+
pointerSealed: Uint8Array;
|
|
972
|
+
}): Promise<{
|
|
973
|
+
saved: boolean;
|
|
974
|
+
row: SignInRow;
|
|
975
|
+
}>;
|
|
976
|
+
/** The agent's live sign-ins, by provider (their pointers stay sealed). */
|
|
977
|
+
list(agentId: string): Promise<SignInRow[]>;
|
|
978
|
+
/** The agent's live sign-in for the provider, or undefined. */
|
|
979
|
+
get(agentId: string, provider: string): Promise<SignInRow | undefined>;
|
|
980
|
+
/** Marks the agent's sign-in for the provider verified at `at` (a run saved a live session back): sets verified_at, for
|
|
981
|
+
* the v2 view, and answers whether it stamped a row. With `ifSave`, it stamps only while the sign-in is still that save
|
|
982
|
+
* (SignInRow.save; WHERE save = ?), so a save that landed since the caller checked (allowed while held; it clears
|
|
983
|
+
* verified_at), in the same millisecond or not, is never re-stamped stale: the answer is false then, and nothing is
|
|
984
|
+
* written. The run path (E2) calls it at a run's save; a missing sign-in is left as it is (false). */
|
|
985
|
+
verify(agentId: string, provider: string, at: number, options?: {
|
|
986
|
+
ifSave?: number;
|
|
987
|
+
}): Promise<boolean>;
|
|
988
|
+
/** The agent's forgotten pointers for the provider, newest first (kept sealed, never opened here). */
|
|
989
|
+
tombstones(agentId: string, provider: string): Promise<SignInTombstoneRow[]>;
|
|
990
|
+
/** Forgets the agent's live sign-in for the provider, in the one transaction a launch shares as its lock: when a running
|
|
991
|
+
* run holds `hash` in its sign_in_handed (or, with `heldUnreadable`, when any running run was handed a sign-in at all),
|
|
992
|
+
* the forget is refused (SignInHandedTo, naming the run) and nothing is written; otherwise the live row's sealed pointer
|
|
993
|
+
* moves to a tombstone (the newest SIGN_IN_TOMBSTONES_KEPT kept) and the live row goes. SignInMissing when the agent has
|
|
994
|
+
* no live sign-in for the provider. */
|
|
995
|
+
forget(agentId: string, provider: string, held: {
|
|
996
|
+
hash?: string;
|
|
997
|
+
heldUnreadable?: boolean;
|
|
998
|
+
}): Promise<SignInTombstoneRow>;
|
|
999
|
+
/** The id of a running run whose sign_in_handed holds `hash`, if one does; undefined otherwise. The check the runner
|
|
1000
|
+
* makes before it serves a run's output, and forget makes before it removes a sign-in. With `settleMs` (a vendor's settle
|
|
1001
|
+
* window, from the store clock or `at`), a run that left running (ended or parked) less than that ago also counts as
|
|
1002
|
+
* holding it, so a new run does not save over a context write-back still in flight. */
|
|
1003
|
+
handedHolder(hash: string, options?: {
|
|
1004
|
+
settleMs?: number;
|
|
1005
|
+
at?: number;
|
|
1006
|
+
}): Promise<string | undefined>;
|
|
1007
|
+
/** The id of a running run that was handed any sign-in (a non-empty sign_in_handed), if one was: for a pointer that does
|
|
1008
|
+
* not open here, which any such run may hold. */
|
|
1009
|
+
handedAny(): Promise<string | undefined>;
|
|
1010
|
+
}
|
|
1011
|
+
/** A running run's live view as the store keeps it: `state` is JSON (the tool it runs now, its partial text). */
|
|
1012
|
+
export interface LiveRow {
|
|
1013
|
+
readonly runId: string;
|
|
1014
|
+
readonly state: unknown;
|
|
1015
|
+
readonly updatedAt: number;
|
|
1016
|
+
}
|
|
1017
|
+
export interface Live {
|
|
1018
|
+
/** A runner's tick: every changed run's row, written in ONE transaction, each fenced by its claim's epoch. A row whose
|
|
1019
|
+
* claim is stale is skipped (never written); the rest are written, overwriting each run's last. */
|
|
1020
|
+
put(rows: readonly {
|
|
1021
|
+
readonly claim: Claim;
|
|
1022
|
+
readonly state: unknown;
|
|
1023
|
+
}[]): Promise<{
|
|
1024
|
+
written: string[];
|
|
1025
|
+
fenced: string[];
|
|
1026
|
+
}>;
|
|
1027
|
+
/** The rows of `runIds` that have one, in one query: the server's read. */
|
|
1028
|
+
read(runIds: readonly string[]): Promise<LiveRow[]>;
|
|
1029
|
+
/** The run's row goes, at its end, under `claim`: fenced by its epoch like a put, so a loop that ends after its claim
|
|
1030
|
+
* was lost drops nothing of the row a later claim wrote. */
|
|
1031
|
+
drop(claim: Claim): Promise<void>;
|
|
1032
|
+
}
|
|
1033
|
+
/** A live view's computer kind: the live view is proxy-only for each (browser, desktop, phone). (Distinct from
|
|
1034
|
+
* @parcha/computer's ComputerKind, which names a provider's OS family.) */
|
|
1035
|
+
export type ViewerKind = "browser" | "desktop" | "phone";
|
|
1036
|
+
/** One open computer session's viewer as the store keeps it: one row per (run, computer kind, session tag), its token
|
|
1037
|
+
* sealed (sealedAt.liveViewer), `at` the store's clock when it was put, `runner` the claim's holder. */
|
|
1038
|
+
export type LiveViewerRow = {
|
|
1039
|
+
kind: ViewerKind;
|
|
1040
|
+
tag: string;
|
|
1041
|
+
port: number;
|
|
1042
|
+
id: string;
|
|
1043
|
+
sealed: Uint8Array;
|
|
1044
|
+
at: number;
|
|
1045
|
+
runner: string;
|
|
1046
|
+
};
|
|
1047
|
+
/** The computer sessions' viewer hand-overs (browser-live.ts): the runner puts and drops them under its claim, the server
|
|
1048
|
+
* reads them. The rows go with the run's end (its end commit), a take or reclaim of the run (a newer epoch, in the
|
|
1049
|
+
* claim's transaction), and the run's delete (on delete cascade). */
|
|
1050
|
+
export interface LiveViewers {
|
|
1051
|
+
/** The runner's put under its claim, upsert on (run_id, kind, tag), `at` stamped by the store: false when the claim is
|
|
1052
|
+
* stale (its epoch moved on, or its lease ran out), and nothing written. */
|
|
1053
|
+
put(claim: Claim, viewer: {
|
|
1054
|
+
kind: ViewerKind;
|
|
1055
|
+
tag: string;
|
|
1056
|
+
port: number;
|
|
1057
|
+
id: string;
|
|
1058
|
+
sealed: Uint8Array;
|
|
1059
|
+
}): Promise<boolean>;
|
|
1060
|
+
/** The runner's drop, fenced by its claim's epoch: with no kind every row of the run; a kind with no tag that kind's
|
|
1061
|
+
* rows; a kind and a tag that one row. */
|
|
1062
|
+
drop(claim: Claim, kind?: ViewerKind, tag?: string): Promise<void>;
|
|
1063
|
+
/** The server's read: the run's rows, newest first, only those of its epoch, under a live claim, by its runner (a runner
|
|
1064
|
+
* that died, or a claim lost, names no viewer), each carrying its kind. */
|
|
1065
|
+
of(runId: string): Promise<LiveViewerRow[]>;
|
|
1066
|
+
}
|
|
1067
|
+
/** Who opens the store. The server sets the schema up at its start and holds the store's owner lock (one server per
|
|
1068
|
+
* store); a runner never sets anything up, and refuses a schema version it does not know. */
|
|
1069
|
+
export type StoreRole = "server" | "runner";
|
|
1070
|
+
export interface Store {
|
|
1071
|
+
/** Where this store's data is, as an identity two instances over the same data share and two over different data never
|
|
1072
|
+
* do: "sqlite:" and the database file's real path, or "sqlite:memory:<n>" for an in-memory one (each its own data);
|
|
1073
|
+
* a store over a database server names its host, database and schema, never a user, a password or a credential.
|
|
1074
|
+
* What waits on another claim's work in this process keys on it (mcp-claim.ts), not on an object. */
|
|
1075
|
+
readonly where: string;
|
|
1076
|
+
readonly agents: Agents;
|
|
1077
|
+
readonly templates: Templates;
|
|
1078
|
+
readonly triggers: Triggers;
|
|
1079
|
+
readonly runs: Runs;
|
|
1080
|
+
readonly mcp: Mcp;
|
|
1081
|
+
readonly live: Live;
|
|
1082
|
+
readonly liveViewers: LiveViewers;
|
|
1083
|
+
readonly learning: Learning;
|
|
1084
|
+
/** The server's tool settings and any other server setting it keeps (design 2.1): one JSON value per key. */
|
|
1085
|
+
readonly settings: Settings;
|
|
1086
|
+
/** The model and provider keys the server holds, sealed (store/seal.ts): bytes the store never opens. */
|
|
1087
|
+
readonly sealedKeys: SealedKeys;
|
|
1088
|
+
/** The labels of the sessions a provider runs with none of its own (a phone provider's). */
|
|
1089
|
+
readonly computerLedger: ComputerLedger;
|
|
1090
|
+
/** Each trigger source's sealed settings (design 2.1): a value per adapter, scope and field. */
|
|
1091
|
+
readonly triggerSettings: TriggerSettings;
|
|
1092
|
+
/** MCP OAuth sign-ins in flight (design 2.1): one row per pending sign-in, its verifier sealed. */
|
|
1093
|
+
readonly mcpOauth: McpOauth;
|
|
1094
|
+
/** Each agent's saved browser sign-ins (design 2.1): one live row per agent and provider, its pointer sealed, with the
|
|
1095
|
+
* forgotten pointers kept as tombstones. */
|
|
1096
|
+
readonly signIns: SignIns;
|
|
1097
|
+
/** Every sealed value the store keeps, across all its planes, in one read (a runner's redaction set at each claim). */
|
|
1098
|
+
readonly sealedSecrets: SealedSecrets;
|
|
1099
|
+
/** Claims the run for `runner` until now + `leaseMs`: the run's epoch + 1 when it is claimable (runs.claimable); null when
|
|
1100
|
+
* another claim holds it, or it is final, or parked with nothing to wake it. A queued or parked run becomes running. */
|
|
1101
|
+
claim(runId: string, runner: string, options?: {
|
|
1102
|
+
leaseMs?: number;
|
|
1103
|
+
}): Promise<Claim | null>;
|
|
1104
|
+
/** Moves the claim's end to now + `leaseMs`. Fenced when the run's epoch moved on. */
|
|
1105
|
+
renew(claim: Claim, options?: {
|
|
1106
|
+
leaseMs?: number;
|
|
1107
|
+
}): Promise<Claim>;
|
|
1108
|
+
/** Renews every claim in one transaction, each to now + `leaseMs`: a runner's renew of all it holds. Each answer is the
|
|
1109
|
+
* renewed claim, or Fenced for one whose epoch moved on (nothing written to it; the others renew). */
|
|
1110
|
+
renewMany(claims: readonly Claim[], options?: {
|
|
1111
|
+
leaseMs?: number;
|
|
1112
|
+
}): Promise<(Claim | Fenced)[]>;
|
|
1113
|
+
/** Gives the run back (no runner, no claimed_until; `state` when given; `wakeAt` and `backoffUntil` or none), in a
|
|
1114
|
+
* durable commit (as flush). Fenced when the epoch moved on. Never a final state: the run's end commit is the one write
|
|
1115
|
+
* that makes it final (a release asked for one is refused with a TypeError). */
|
|
1116
|
+
release(claim: Claim, options?: {
|
|
1117
|
+
state?: ReleasedState;
|
|
1118
|
+
wakeAt?: number | null;
|
|
1119
|
+
backoffUntil?: number | null;
|
|
1120
|
+
}): Promise<void>;
|
|
1121
|
+
/** The run's journal: pi-durable's Storage for this one run, every commit fenced by the claim (store/journal). Its commit
|
|
1122
|
+
* holds the store's one connection while it runs, so it awaits nothing but its own statements, under a deadline. */
|
|
1123
|
+
journal(claim: Claim): Journal;
|
|
1124
|
+
/** A run's journal opened for reading only (JournalReads): the server's reads of a run, which hold no claim. Its reads
|
|
1125
|
+
* alone, never a commit; a read never fences, so it needs no claim. A run with no journal yet reads as empty. */
|
|
1126
|
+
readJournal(runId: string): JournalReads;
|
|
1127
|
+
/** The run started under origin `key` (runs.create's origin), with the fingerprint recorded then; undefined when no run
|
|
1128
|
+
* was started under it. The one read a retry under a key makes to find the run its first request started. */
|
|
1129
|
+
runOfOrigin(key: string): Promise<{
|
|
1130
|
+
runId: string;
|
|
1131
|
+
fingerprint: string | null;
|
|
1132
|
+
} | undefined>;
|
|
1133
|
+
/** Imports a run that has already ended: its row (ended, imported_from, cost, summary, metrics, outcome), its launch row
|
|
1134
|
+
* and its transcript's journal, all in one transaction — the server's own writer, no second writer and no throwaway
|
|
1135
|
+
* database. The run is created at epoch 0 in the same transaction, so the journal's fence passes; a crash mid-import
|
|
1136
|
+
* leaves nothing. StoreConstraint on a duplicate run id or import (source, session). */
|
|
1137
|
+
importRun(run: ImportRunInput): Promise<RunRow>;
|
|
1138
|
+
/** One durable commit: every commit before it, of every run, is on the disk when it resolves. Before a call that must
|
|
1139
|
+
* not run twice, at a run's end and when a claim is released. */
|
|
1140
|
+
flush(): Promise<void>;
|
|
1141
|
+
/** Writes a command for the run. RunFinal when the run is final; unknown runs are refused the same way. */
|
|
1142
|
+
command(runId: string, command: {
|
|
1143
|
+
kind: string;
|
|
1144
|
+
body?: unknown;
|
|
1145
|
+
}): Promise<Command>;
|
|
1146
|
+
/** The run's commands with an id above `after`, in id order. */
|
|
1147
|
+
commands(runId: string, after: number): Promise<Command[]>;
|
|
1148
|
+
/** Every run's commands with an id above its own cursor, in id order, in one read: a runner's poll of all it holds. A run
|
|
1149
|
+
* with none is absent from the map. */
|
|
1150
|
+
commandsOf(cursors: readonly {
|
|
1151
|
+
runId: string;
|
|
1152
|
+
after: number;
|
|
1153
|
+
}[]): Promise<Map<string, Command[]>>;
|
|
1154
|
+
/** Marks the command taken (or refused, with `reason`) under the claim, once: a command already taken stays as it was.
|
|
1155
|
+
* Fenced on a stale claim. */
|
|
1156
|
+
take(claim: Claim, commandId: number, outcome?: "taken" | "refused", reason?: string): Promise<void>;
|
|
1157
|
+
/** Counts a failed resume on the untaken command that woke the run, under the claim, and answers its tries; the command
|
|
1158
|
+
* stays untaken. Fenced on a stale claim; StoreConstraint when the command is taken or not the run's. */
|
|
1159
|
+
retry(claim: Claim, commandId: number): Promise<number>;
|
|
1160
|
+
/** Waits for every write asked for before it, then closes (and lets the owner lock go). A call after it is refused
|
|
1161
|
+
* (StoreClosed). */
|
|
1162
|
+
close(): Promise<void>;
|
|
1163
|
+
}
|
|
1164
|
+
/** A write under a claim whose epoch is no longer the run's: refused, and nothing written. */
|
|
1165
|
+
export declare class Fenced extends Error {
|
|
1166
|
+
readonly runId: string;
|
|
1167
|
+
readonly epoch: number;
|
|
1168
|
+
constructor(runId: string, epoch: number);
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* A journal commit that takes a command which is not the run's untaken command (already taken, or another run's): the
|
|
1172
|
+
* whole commit is refused and nothing of it written, so a command's effect never applies twice. Like Fenced, it fails the
|
|
1173
|
+
* run's Session (pi: any commit error is final).
|
|
1174
|
+
*/
|
|
1175
|
+
export declare class CommandTaken extends Error {
|
|
1176
|
+
readonly runId: string;
|
|
1177
|
+
readonly commandId: number;
|
|
1178
|
+
constructor(runId: string, commandId: number);
|
|
1179
|
+
}
|
|
1180
|
+
/** An interactive transaction still open at its deadline: rolled back, nothing of it written, and the calls behind it go on. */
|
|
1181
|
+
export declare class StoreDeadline extends Error {
|
|
1182
|
+
readonly deadlineMs: number;
|
|
1183
|
+
/** `message`: words of its own (a connection the store's database never gave, StoreConnect's); by default a transaction's. */
|
|
1184
|
+
constructor(deadlineMs: number, message?: string);
|
|
1185
|
+
}
|
|
1186
|
+
/** The database stayed locked past the store's busy wait. */
|
|
1187
|
+
export declare class StoreBusy extends Error {
|
|
1188
|
+
constructor(message: string);
|
|
1189
|
+
}
|
|
1190
|
+
/** A call after close(). */
|
|
1191
|
+
export declare class StoreClosed extends Error {
|
|
1192
|
+
constructor();
|
|
1193
|
+
}
|
|
1194
|
+
/** The store's worker thread failed or exited: every call after it is refused in these words, never left waiting. */
|
|
1195
|
+
export declare class StoreWorkerLost extends Error {
|
|
1196
|
+
constructor(why: string);
|
|
1197
|
+
}
|
|
1198
|
+
/** A second server on a store another server holds (one server per store). */
|
|
1199
|
+
export declare class StoreOwned extends Error {
|
|
1200
|
+
constructor(message: string);
|
|
1201
|
+
}
|
|
1202
|
+
/** A data directory an earlier version wrote (its store, agent homes, run databases or settings files): this version
|
|
1203
|
+
* neither reads nor moves it, and its words give the two ways on: keep the directory with the earlier version, or start
|
|
1204
|
+
* this one on a new directory and add the agents again. `found`: what was found, relative to the directory. */
|
|
1205
|
+
export declare class StoreFromEarlierVersion extends Error {
|
|
1206
|
+
readonly found: readonly string[];
|
|
1207
|
+
constructor(dataDir: string, found: readonly string[]);
|
|
1208
|
+
}
|
|
1209
|
+
/** A store whose schema version this build does not know (or one the server has not set up yet). */
|
|
1210
|
+
export declare class SchemaVersionUnknown extends Error {
|
|
1211
|
+
readonly found: number | null;
|
|
1212
|
+
readonly known: number;
|
|
1213
|
+
constructor(file: string, found: number | null, known: number);
|
|
1214
|
+
}
|
|
1215
|
+
/** A command for a run that is final, or that does not exist. */
|
|
1216
|
+
export declare class RunFinal extends Error {
|
|
1217
|
+
readonly runId: string;
|
|
1218
|
+
constructor(runId: string);
|
|
1219
|
+
}
|
|
1220
|
+
/** A run with no launch row: it was not started with one (an unknown run reads the same way). The runner's claim needs it to
|
|
1221
|
+
* build the run's spec, so its absence is this named refusal, never a default. */
|
|
1222
|
+
export declare class StoreLaunchMissing extends Error {
|
|
1223
|
+
readonly runId: string;
|
|
1224
|
+
constructor(runId: string);
|
|
1225
|
+
}
|
|
1226
|
+
/** Which of a table's rules refused a row, as both databases report it by code (never by its message's words). */
|
|
1227
|
+
export type ConstraintRule = "check" | "unique" | "foreign_key" | "not_null";
|
|
1228
|
+
/** A row the store's constraints refuse (a duplicate id or name, a revision of an unknown agent, a bad kind). When the
|
|
1229
|
+
* database said which rule refused it, `rule`; for a duplicate, `unique`: the table and the columns whose values were
|
|
1230
|
+
* taken already (a primary key's or a UNIQUE's), so a caller tells "the name is taken" from any other refusal. */
|
|
1231
|
+
export declare class StoreConstraint extends Error {
|
|
1232
|
+
readonly rule?: ConstraintRule;
|
|
1233
|
+
readonly unique?: {
|
|
1234
|
+
readonly table: string;
|
|
1235
|
+
readonly columns: readonly string[];
|
|
1236
|
+
};
|
|
1237
|
+
constructor(message: string, details?: {
|
|
1238
|
+
rule?: ConstraintRule;
|
|
1239
|
+
unique?: {
|
|
1240
|
+
table: string;
|
|
1241
|
+
columns: readonly string[];
|
|
1242
|
+
};
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
/** Forgetting a sign-in a running run was handed: refused, nothing written. `runId` is the run that holds it. */
|
|
1246
|
+
export declare class SignInHandedTo extends Error {
|
|
1247
|
+
readonly runId: string;
|
|
1248
|
+
constructor(runId: string);
|
|
1249
|
+
}
|
|
1250
|
+
/** Forgetting a sign-in the agent does not have for the provider. */
|
|
1251
|
+
export declare class SignInMissing extends Error {
|
|
1252
|
+
constructor(agentId: string, provider: string);
|
|
1253
|
+
}
|