@parcha/agentrun-serve 0.1.0-beta.37 → 0.1.0-beta.39
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 +700 -0
- package/README.md +441 -177
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +1 -3
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +48 -23
- package/dist/answer-json.d.ts +34 -1
- package/dist/answer-json.js +91 -9
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/bash-read-only.js +2 -1
- package/dist/browser-cost.js +52 -93
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -400
- package/dist/cap.js +6 -942
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +2 -6
- package/dist/chatgpt-plan.d.ts +163 -0
- package/dist/chatgpt-plan.js +549 -0
- package/dist/cli.js +26 -6
- package/dist/composio-preset.d.ts +25 -0
- package/dist/composio-preset.js +51 -8
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.d.ts +36 -24
- package/dist/computer-calls.js +110 -27
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +12 -2
- package/dist/computer-live.js +21 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +18 -2
- package/dist/computer-view.js +21 -6
- package/dist/computer-viewer.js +40 -13
- package/dist/computers.d.ts +8 -2
- package/dist/computers.js +18 -8
- package/dist/console/assets/index-BNhZs-jp.css +1 -0
- package/dist/console/assets/index-BQv5aOGB.js +700 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +6 -3
- package/dist/decision-cap.d.ts +2 -5
- package/dist/decision-cap.js +3 -6
- package/dist/decision-rows.js +11 -11
- package/dist/decisions.js +4 -0
- package/dist/email/account.d.ts +84 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +10 -0
- package/dist/email/answer.js +182 -0
- package/dist/email/email-faux.d.ts +95 -0
- package/dist/email/email-faux.js +849 -0
- package/dist/email/labels.d.ts +1 -0
- package/dist/email/labels.js +84 -0
- package/dist/email/mail.d.ts +186 -0
- package/dist/email/mail.js +380 -0
- package/dist/email/names.d.ts +20 -0
- package/dist/email/names.js +40 -0
- package/dist/email/routes.d.ts +9 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +20 -0
- package/dist/email/tools.js +517 -0
- package/dist/environment.d.ts +17 -2
- package/dist/environment.js +36 -8
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +12 -0
- package/dist/eval-mailbox.d.ts +103 -0
- package/dist/eval-mailbox.js +236 -0
- package/dist/faux-computers.js +4 -2
- package/dist/graph-view.d.ts +9 -2
- package/dist/graph-view.js +6 -2
- package/dist/harness-install.d.ts +28 -2
- package/dist/harness-install.js +147 -59
- package/dist/harness-opencode/adapter.js +2 -22
- package/dist/harness-opencode/facts.js +5 -4
- package/dist/harness-opencode/host/policy.d.ts +4 -5
- package/dist/harness-opencode/host/policy.js +14 -33
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/versions.d.ts +6 -0
- package/dist/harness-opencode/versions.js +6 -0
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +8 -7
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/host-tools.d.ts +1 -5
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +3 -3
- package/dist/hosted-search.js +51 -32
- package/dist/import-sources.d.ts +1 -1
- package/dist/import-sources.js +3 -3
- package/dist/import.d.ts +21 -0
- package/dist/import.js +186 -1
- package/dist/key-check.d.ts +0 -2
- package/dist/key-check.js +3 -4
- package/dist/key-refusal.d.ts +8 -2
- package/dist/key-refusal.js +16 -13
- package/dist/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +24 -4
- package/dist/learn/check.js +340 -7
- package/dist/learn/commit.d.ts +10 -0
- package/dist/learn/commit.js +18 -4
- package/dist/learn/compile.d.ts +250 -0
- package/dist/learn/compile.js +507 -0
- package/dist/learn/general.d.ts +3 -0
- package/dist/learn/general.js +4 -2
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +11 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +308 -0
- package/dist/learn/promote.js +321 -0
- package/dist/learn/refit.d.ts +48 -0
- package/dist/learn/refit.js +264 -0
- package/dist/learn/reflect.d.ts +5 -25
- package/dist/learn/reflect.js +14 -131
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +19 -16
- package/dist/learn/skills.js +157 -53
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +58 -2
- package/dist/learned-nodes.js +68 -5
- package/dist/learned-workflow.d.ts +58 -32
- package/dist/learned-workflow.js +215 -77
- package/dist/learning-batch.d.ts +2 -2
- package/dist/learning-batch.js +4 -4
- package/dist/learning-cost.d.ts +41 -11
- package/dist/learning-cost.js +31 -13
- package/dist/learning-routes.d.ts +12 -2
- package/dist/learning-routes.js +34 -6
- package/dist/learning-words.d.ts +8 -1
- package/dist/learning-words.js +11 -1
- package/dist/learning.d.ts +26 -1
- package/dist/learning.js +7 -4
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/llm.js +0 -3
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-gateway.d.ts +12 -20
- package/dist/mcp-gateway.js +16 -44
- package/dist/mcp-oauth.d.ts +5 -0
- package/dist/mcp-oauth.js +1 -1
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +113 -0
- package/dist/mcp-probe.d.ts +8 -9
- package/dist/mcp-probe.js +16 -33
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +102 -26
- package/dist/mcp-servers-store.js +151 -25
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +11 -0
- package/dist/mcp-store.js +16 -2
- package/dist/mcp-wire.d.ts +22 -0
- package/dist/mcp-wire.js +36 -0
- package/dist/mcp.js +3 -3
- package/dist/meta-tool-names.d.ts +1 -0
- package/dist/meta-tool-names.js +3 -0
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +39 -6
- package/dist/model.js +171 -32
- package/dist/monid.d.ts +50 -29
- package/dist/monid.js +234 -143
- package/dist/native/binding.d.ts +13 -0
- package/dist/native/binding.js +57 -0
- package/dist/native/cli.d.ts +2 -0
- package/dist/native/cli.js +48 -0
- package/dist/native/connection.d.ts +8 -0
- package/dist/native/connection.js +94 -0
- package/dist/native/context.d.ts +6 -0
- package/dist/native/context.js +22 -0
- package/dist/native/discovery.d.ts +27 -0
- package/dist/native/discovery.js +404 -0
- package/dist/native/environment.d.ts +4 -0
- package/dist/native/environment.js +18 -0
- package/dist/native/history.d.ts +20 -0
- package/dist/native/history.js +147 -0
- package/dist/native/instructions.d.ts +21 -0
- package/dist/native/instructions.js +173 -0
- package/dist/native/remote-worker-bridge.d.ts +3 -0
- package/dist/native/remote-worker-bridge.js +278 -0
- package/dist/native/remote.d.ts +187 -0
- package/dist/native/remote.js +492 -0
- package/dist/native/runtime.d.ts +17 -0
- package/dist/native/runtime.js +316 -0
- package/dist/native/runtimes.d.ts +66 -0
- package/dist/native/runtimes.js +41 -0
- package/dist/native/schema.d.ts +46 -0
- package/dist/native/schema.js +41 -0
- package/dist/native/types.d.ts +87 -0
- package/dist/native/types.js +1 -0
- package/dist/observation/http.d.ts +4 -0
- package/dist/observation/http.js +140 -0
- package/dist/observation/observer.d.ts +301 -0
- package/dist/observation/observer.js +919 -0
- package/dist/observation/schema.d.ts +52 -0
- package/dist/observation/schema.js +154 -0
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +705 -126
- package/dist/paid-calls.d.ts +34 -32
- package/dist/paid-calls.js +52 -104
- package/dist/place-offers.d.ts +4 -8
- package/dist/place-offers.js +4 -9
- package/dist/port-models.d.ts +7 -2
- package/dist/port-models.js +5 -2
- package/dist/print.d.ts +4 -2
- package/dist/print.js +4 -3
- package/dist/propose.d.ts +8 -3
- package/dist/propose.js +28 -7
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +17 -2
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/reflect-range.js +2 -1
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +23 -1
- package/dist/run-launch.js +17 -4
- package/dist/run-learning-served.d.ts +84 -0
- package/dist/run-manifest.d.ts +8 -0
- package/dist/run-manifest.js +33 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +12 -10
- package/dist/run-view.d.ts +59 -41
- package/dist/run-view.js +128 -64
- package/dist/runnable.d.ts +13 -8
- package/dist/runnable.js +77 -60
- package/dist/runner/adapter-loop.d.ts +60 -15
- package/dist/runner/adapter-loop.js +1406 -464
- package/dist/runner/adapter-run-spec.d.ts +45 -14
- package/dist/runner/adapter-run-spec.js +200 -116
- package/dist/runner/adapters/pi.d.ts +40 -7
- package/dist/runner/adapters/pi.js +149 -38
- package/dist/runner/beside.d.ts +3 -1
- package/dist/runner/beside.js +24 -8
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +28 -4
- package/dist/runner/cli-run-spec.d.ts +30 -0
- package/dist/runner/cli-run-spec.js +150 -66
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +5 -3
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +149 -5
- package/dist/runner/conformance/subject.d.ts +11 -4
- package/dist/runner/end-of-run.d.ts +8 -5
- package/dist/runner/end-of-run.js +11 -6
- package/dist/runner/feedback-round.d.ts +79 -0
- package/dist/runner/feedback-round.js +127 -0
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +55 -13
- package/dist/runner/journal-kinds.js +19 -0
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +58 -19
- package/dist/runner/learning-end.js +316 -115
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +21 -1
- package/dist/runner/learning-loop.js +24 -6
- package/dist/runner/learning-seed.d.ts +4 -0
- package/dist/runner/learning-seed.js +14 -0
- package/dist/runner/loop-contract.d.ts +19 -3
- package/dist/runner/loop.d.ts +34 -1
- package/dist/runner/loop.js +55 -1
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-claim.d.ts +5 -1
- package/dist/runner/mcp-claim.js +66 -50
- package/dist/runner/mcp-run.d.ts +20 -53
- package/dist/runner/mcp-run.js +22 -88
- package/dist/runner/meta-tools.d.ts +44 -0
- package/dist/runner/meta-tools.js +344 -0
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +128 -42
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +149 -19
- package/dist/runner/monid-run.d.ts +18 -0
- package/dist/runner/monid-run.js +170 -0
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +146 -0
- package/dist/runner/promotion.js +803 -0
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.d.ts +36 -21
- package/dist/runner/reflect-hook.js +147 -49
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +34 -8
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/sessions.d.ts +8 -3
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +7 -12
- package/dist/runner/workflow-first.d.ts +226 -0
- package/dist/runner/workflow-first.js +293 -0
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +32 -19
- package/dist/runner/workflow-spec.d.ts +5 -1
- package/dist/runner/workflow-spec.js +63 -48
- package/dist/runs-over-store.d.ts +41 -4
- package/dist/runs-over-store.js +64 -22
- package/dist/sdk/runs.d.ts +115 -0
- package/dist/sdk/runs.js +422 -0
- package/dist/sdk/schema.d.ts +175 -0
- package/dist/sdk/schema.js +138 -0
- package/dist/sdk/workflows.d.ts +22 -0
- package/dist/sdk/workflows.js +39 -0
- package/dist/secrets.d.ts +2 -0
- package/dist/secrets.js +19 -1
- package/dist/server.d.ts +108 -20
- package/dist/server.js +874 -157
- package/dist/settings-wake.d.ts +8 -6
- package/dist/settings-wake.js +13 -7
- package/dist/skill-route.d.ts +3 -0
- package/dist/skill-route.js +16 -0
- package/dist/skills/agentrun-serve/SKILL.md +368 -0
- package/dist/stats.d.ts +10 -10
- package/dist/store/agent-body.d.ts +22 -7
- package/dist/store/agent-body.js +23 -14
- package/dist/store/command-wake.d.ts +3 -2
- package/dist/store/command-wake.js +4 -4
- package/dist/store/index.d.ts +1 -1
- package/dist/store/native-command-owner.d.ts +10 -0
- package/dist/store/native-command-owner.js +47 -0
- package/dist/store/postgres/connection.js +3 -1
- package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
- package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
- package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
- package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
- package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
- package/dist/store/postgres/store.js +3 -0
- package/dist/store/schema.d.ts +16 -0
- package/dist/store/schema.js +47 -8
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +33 -10
- package/dist/store/sqlite/store.js +184 -28
- package/dist/store/store.d.ts +98 -21
- package/dist/store-reads/analytics.d.ts +7 -7
- package/dist/store-reads/analytics.js +23 -5
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/journal.d.ts +30 -1
- package/dist/store-reads/journal.js +141 -83
- package/dist/store-reads/learning.d.ts +179 -13
- package/dist/store-reads/learning.js +230 -68
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +3 -2
- package/dist/store-view.js +109 -37
- package/dist/template-eval.d.ts +87 -16
- package/dist/template-eval.js +605 -120
- package/dist/template-github-permissions.d.ts +2 -2
- package/dist/template-github-permissions.js +2 -1
- package/dist/template-import.d.ts +31 -0
- package/dist/template-import.js +121 -0
- package/dist/template-source.d.ts +51 -0
- package/dist/template-source.js +371 -0
- package/dist/templates.d.ts +274 -52
- package/dist/templates.js +670 -201
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +7 -5
- package/dist/timeline/index.js +7 -5
- package/dist/timeline/labels.d.ts +11 -4
- package/dist/timeline/labels.js +122 -8
- package/dist/timeline/origin.d.ts +20 -6
- package/dist/timeline/origin.js +13 -6
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +76 -20
- package/dist/timeline/timeline.js +184 -39
- package/dist/timeline/util.d.ts +5 -0
- package/dist/timeline/util.js +44 -8
- package/dist/timeline/web-calls.d.ts +17 -0
- package/dist/timeline/web-calls.js +106 -0
- package/dist/tool-gate.d.ts +103 -76
- package/dist/tool-gate.js +200 -127
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +29 -0
- package/dist/tool-list.js +50 -0
- package/dist/tool-names.d.ts +76 -0
- package/dist/tool-names.js +101 -0
- package/dist/tool-plane.d.ts +34 -28
- package/dist/tool-plane.js +72 -37
- package/dist/tools.d.ts +59 -15
- package/dist/tools.js +46 -42
- package/dist/trigger-adapter.d.ts +85 -5
- package/dist/trigger-adapter.js +6 -0
- package/dist/trigger-adapters.js +3 -1
- package/dist/trigger-composio.d.ts +10 -0
- package/dist/trigger-composio.js +122 -0
- package/dist/trigger-email.d.ts +4 -0
- package/dist/trigger-email.js +228 -0
- package/dist/trigger-signatures.d.ts +6 -10
- package/dist/trigger-signatures.js +16 -16
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +4 -3
- package/dist/trigger-webhook.js +6 -4
- package/dist/triggers.d.ts +94 -9
- package/dist/triggers.js +263 -62
- package/dist/uploads.d.ts +9 -0
- package/dist/uploads.js +27 -0
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +91 -50
- package/dist/web-fake.d.ts +56 -0
- package/dist/web-fake.js +102 -0
- package/dist/web-fetch-direct.d.ts +3 -0
- package/dist/web-fetch-direct.js +4 -1
- package/dist/web-fetch.d.ts +6 -8
- package/dist/web-fetch.js +10 -53
- package/dist/web-search.d.ts +51 -2
- package/dist/web-search.js +116 -18
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -1
- package/dist/workflow/node-runner.js +10 -2
- package/dist/workspace/archil-claim.d.ts +3 -0
- package/dist/workspace/archil-claim.js +9 -2
- package/dist/workspace/computer-deps.d.ts +25 -9
- package/dist/workspace/computer-deps.js +82 -38
- package/dist/workspace/computer-for-claim.d.ts +60 -4
- package/dist/workspace/computer-for-claim.js +203 -45
- package/dist/workspace/computer-hold.js +7 -1
- package/dist/workspace/computer-janitor.d.ts +10 -3
- package/dist/workspace/computer-janitor.js +96 -29
- package/dist/workspace/computer-kept.d.ts +82 -0
- package/dist/workspace/computer-kept.js +147 -0
- package/dist/workspace/computer-mcp.js +4 -3
- package/dist/workspace/computer-ports.d.ts +23 -3
- package/dist/workspace/computer-ports.js +115 -5
- package/dist/workspace/index.d.ts +2 -3
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +31 -11
- package/dist/workspace/kind-skills/phone/SKILL.md +29 -14
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +33 -1
- package/dist/workspace/resolve-computer.js +37 -16
- package/dist/workspace/revision-skills.d.ts +6 -2
- package/dist/workspace/revision-skills.js +12 -5
- package/dist/workspace/run-end-computers.d.ts +30 -0
- package/dist/workspace/run-end-computers.js +137 -0
- package/dist/workspace/run-tools.d.ts +40 -23
- package/dist/workspace/run-tools.js +46 -19
- package/dist/wrap-up.d.ts +35 -0
- package/dist/wrap-up.js +48 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +220 -60
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +46 -16
- package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
- package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
- package/templates/code-review/evals/injection/case.yaml +2 -1
- package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
- package/templates/code-review/evals/mentions-defused/case.yaml +3 -3
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
- package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
- package/templates/code-review/evals/never-flag/case.yaml +2 -1
- package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
- package/templates/code-review/evals/null-name/case.yaml +2 -1
- package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/case.yaml +2 -1
- package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +16 -0
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
- package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/code-review/evals/other-repo/prompt.md +10 -0
- package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
- package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
- package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
- package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
- package/templates/code-review/evals/re-review/case.yaml +2 -1
- package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
- package/templates/code-review/evals/re-review-open/case.yaml +2 -1
- package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
- package/templates/code-review/evals/repo-rule/case.yaml +2 -1
- package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
- package/templates/code-review/evals/two-defects/case.yaml +2 -1
- package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
- package/templates/code-review/rules/CODEREVIEW.md +1 -1
- package/templates/code-review/skills/review/DEEP.md +5 -4
- package/templates/code-review/skills/review/REVIEWER.md +5 -4
- package/templates/code-review/skills/review/SKILL.md +11 -6
- package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
- package/templates/inbound-lead/agent.md +26 -16
- package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
- package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
- package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
- package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
- package/templates/kyb/agent.md +15 -5
- package/templates/kyb/evals/adverse-media/prompt.md +2 -7
- package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
- package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
- package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
- package/templates/kyb/evals/name-collision/prompt.md +2 -6
- package/templates/kyb/evals/no-invention/prompt.md +2 -6
- package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
- package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
- package/templates/kyb/kyb.schema.json +8 -7
- package/templates/kyb/skills/kyb/SKILL.md +9 -6
- package/templates/market-monitor/agent.md +19 -12
- package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +32 -10
- package/templates/release-notes/evals/draft-not-publish/case.yaml +5 -4
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +5 -4
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/learned-style/case.yaml +2 -1
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
- package/templates/release-notes/evals/other-repo/case.yaml +24 -0
- package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
- package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
- package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/release-notes/evals/other-repo/prompt.md +32 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
- package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
- package/templates/release-notes/notes.schema.json +1 -1
- package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
- package/dist/console/assets/index-Cn6JX1uH.js +0 -563
- package/dist/console/assets/index-DRN62V5v.css +0 -1
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -7
- package/dist/runner/adapters/pi-computer.js +0 -43
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -38
- package/dist/tool-budget.js +0 -62
- package/dist/workspace/computer-script.d.ts +0 -37
- package/dist/workspace/computer-script.js +0 -138
- package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
- package/templates/code-review/evals/injection/graders/schema.md +0 -5
- package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
- package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
- package/templates/code-review/evals/null-name/graders/schema.md +0 -5
- package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
- package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
- package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
- package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
- package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
- package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
- package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
- package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
- package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
- package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
- package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
package/dist/store/agent-body.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// argument `pin` form in tool settings (the lead's ruling): at most 8 arguments mapped to JSON scalars, keys sorted, so
|
|
7
7
|
// two equal pins are one revision.
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
9
|
+
import { nativeBindingOf } from "../native/binding.js";
|
|
9
10
|
/** A revision's body the store refuses: its content is not one the store keeps. The server maps it to an input refusal. */
|
|
10
11
|
export class AgentBodyInvalid extends Error {
|
|
11
12
|
constructor(message) {
|
|
@@ -44,21 +45,25 @@ function placeOf(place) {
|
|
|
44
45
|
}
|
|
45
46
|
/** A GPU type as a body keeps it: the vendor's own name ("T4", "A100-80GB", "RTX-PRO-6000"). */
|
|
46
47
|
const GPU_TYPE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
/** The keys a body's computer keeps. */
|
|
49
|
+
const COMPUTER_KEYS = new Set(["kind", "provider", "image", "gpu", "persistent", "surface", "exec"]);
|
|
50
|
+
/** A computer as a body keeps it: `{kind, provider?, image?, gpu?, persistent?, surface?, exec?}`, nothing else: kind
|
|
51
|
+
* and provider ids, image a name with no spaces around it, gpu `{type, count}`, a GPU type name and a whole count from
|
|
52
|
+
* 1, persistent and exec booleans, and surface code or tools. */
|
|
50
53
|
function computerOf(computer) {
|
|
51
54
|
const image = isObject(computer) ? computer.image : undefined;
|
|
52
55
|
const named = (value) => typeof value === "string" && value !== "" && value === value.trim();
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
const flag = (value) => value === undefined || typeof value === "boolean";
|
|
57
|
+
const surface = isObject(computer) ? computer.surface : undefined;
|
|
58
|
+
if (!isObject(computer) || !hostId(computer.kind) || (computer.provider !== undefined && !hostId(computer.provider)) || (image !== undefined && !named(image)) || !flag(computer.persistent) || !flag(computer.exec) || (surface !== undefined && surface !== "code" && surface !== "tools") || Object.keys(computer).some((key) => !COMPUTER_KEYS.has(key)))
|
|
59
|
+
invalid("the computer is not {kind, provider?, image?, gpu?, persistent?, surface?, exec?}, kind and provider each an id (lowercase letters, digits and dashes), image a name, persistent a boolean, surface code or tools, exec a boolean");
|
|
55
60
|
const ok = computer;
|
|
56
61
|
const gpu = ok.gpu;
|
|
57
62
|
if (gpu !== undefined && (!isObject(gpu) || Object.keys(gpu).some((key) => key !== "type" && key !== "count") || typeof gpu.type !== "string" || !GPU_TYPE.test(gpu.type) || !Number.isSafeInteger(gpu.count) || gpu.count < 1)) {
|
|
58
63
|
invalid("the computer's gpu is not {type, count}: a GPU type name (letters, digits, dots, underscores and dashes) and a whole count from 1");
|
|
59
64
|
}
|
|
60
65
|
const kept = gpu;
|
|
61
|
-
return { kind: ok.kind, ...(ok.provider !== undefined ? { provider: ok.provider } : {}), ...(ok.image !== undefined ? { image: ok.image } : {}), ...(kept !== undefined ? { gpu: { type: kept.type, count: kept.count } } : {}), ...(ok.persistent !== undefined ? { persistent: ok.persistent } : {}) };
|
|
66
|
+
return { kind: ok.kind, ...(ok.provider !== undefined ? { provider: ok.provider } : {}), ...(ok.image !== undefined ? { image: ok.image } : {}), ...(kept !== undefined ? { gpu: { type: kept.type, count: kept.count } } : {}), ...(ok.persistent !== undefined ? { persistent: ok.persistent } : {}), ...(ok.surface !== undefined ? { surface: ok.surface } : {}), ...(ok.exec !== undefined ? { exec: ok.exec } : {}) };
|
|
62
67
|
}
|
|
63
68
|
/** The body of a new revision and the text of each skill it names (path to text), everything checked here, before any
|
|
64
69
|
* write. The body keeps each skill path to its text's SHA-256; `skills` is the texts, for the revision's row. */
|
|
@@ -92,12 +97,10 @@ export function bodyOf(input) {
|
|
|
92
97
|
...(input.computer !== undefined ? { computer: computerOf(input.computer) } : {}),
|
|
93
98
|
...(toolSettings ? { toolSettings } : {}),
|
|
94
99
|
};
|
|
95
|
-
// A default spend cap,
|
|
100
|
+
// A default spend cap, for a revision of either kind.
|
|
96
101
|
if (input.maxCostUsd !== undefined && !(typeof input.maxCostUsd === "number" && Number.isFinite(input.maxCostUsd) && input.maxCostUsd > 0))
|
|
97
102
|
invalid("the maxCostUsd is not a number above 0");
|
|
98
|
-
|
|
99
|
-
invalid("the capMode is not a non-empty string");
|
|
100
|
-
const capped = { ...(input.maxCostUsd !== undefined ? { maxCostUsd: input.maxCostUsd } : {}), ...(input.capMode !== undefined ? { capMode: input.capMode } : {}) };
|
|
103
|
+
const capped = input.maxCostUsd !== undefined ? { maxCostUsd: input.maxCostUsd } : {};
|
|
101
104
|
// Whether the agent runs unattended (its definition.approvals): "never" lets an ask run without a person, for a revision
|
|
102
105
|
// of either kind. "ask" (the default, as an agent read says it) is taken and kept as no value, so the default stays
|
|
103
106
|
// implicit and a definition put back as it reads is the same revision; "never" is kept.
|
|
@@ -112,16 +115,22 @@ export function bodyOf(input) {
|
|
|
112
115
|
invalid(`the ${field} is not a non-empty string`);
|
|
113
116
|
if (input.learning !== undefined && typeof input.learning !== "boolean" && input.learning !== "notes")
|
|
114
117
|
invalid("learning is not true, false or \"notes\"");
|
|
118
|
+
if (input.inputSchema !== undefined && !isObject(input.inputSchema))
|
|
119
|
+
invalid("the inputSchema is not a JSON object");
|
|
115
120
|
if (input.outputSchema !== undefined && !isObject(input.outputSchema))
|
|
116
121
|
invalid("the outputSchema is not a JSON object");
|
|
117
122
|
if (input.checkout !== undefined && input.checkout !== "pull_request")
|
|
118
123
|
invalid("the checkout is not pull_request");
|
|
119
124
|
if (input.modelTiers !== undefined && !(isObject(input.modelTiers) && Object.keys(input.modelTiers).length && Object.entries(input.modelTiers).every(([tier, ref]) => (tier === "fast" || tier === "strong") && typeof ref === "string" && ref !== "")))
|
|
120
125
|
invalid("the modelTiers are not fast and strong to a non-empty model");
|
|
121
|
-
if (input.
|
|
122
|
-
invalid("
|
|
126
|
+
if (input.sdk !== undefined && (!isObject(input.sdk) || Object.keys(input.sdk).some(key => key !== "runtime") || !["claude-agent-sdk", "codex-sdk"].includes(input.sdk.runtime)))
|
|
127
|
+
invalid("sdk is {runtime: claude-agent-sdk or codex-sdk}");
|
|
128
|
+
if (input.sdk && input.native)
|
|
129
|
+
invalid("sdk and native connections are mutually exclusive");
|
|
123
130
|
const body = {
|
|
131
|
+
...(input.sdk ? { sdk: { ...input.sdk } } : {}),
|
|
124
132
|
instructions: input.instructions,
|
|
133
|
+
...(input.native !== undefined ? { native: nativeBindingOf(input.native) } : {}),
|
|
125
134
|
skills: skillShas,
|
|
126
135
|
tools: [...tools],
|
|
127
136
|
...(input.model !== undefined ? { model: input.model } : {}),
|
|
@@ -130,12 +139,12 @@ export function bodyOf(input) {
|
|
|
130
139
|
...(input.prompts !== undefined ? { prompts: structuredClone(input.prompts) } : {}),
|
|
131
140
|
...host,
|
|
132
141
|
...(input.learning !== undefined ? { learning: input.learning } : {}),
|
|
142
|
+
// The JSON Schema each run's input meets (definition.input_schema), checked at every start (validate.ts inputSchemaOf).
|
|
143
|
+
...(input.inputSchema !== undefined ? { inputSchema: structuredClone(input.inputSchema) } : {}),
|
|
133
144
|
// The JSON Schema its final answer's structured part meets (definition.output_schema): a completed run's result.output.
|
|
134
145
|
...(input.outputSchema !== undefined ? { outputSchema: structuredClone(input.outputSchema) } : {}),
|
|
135
146
|
// What the server checks out in each run's folder before its first turn (runner/pr-checkout.ts).
|
|
136
147
|
...(input.checkout !== undefined ? { checkout: input.checkout } : {}),
|
|
137
|
-
// The tool calls each conversation of its runs may make (tool-budget.ts).
|
|
138
|
-
...(input.maxToolCalls !== undefined ? { maxToolCalls: input.maxToolCalls } : {}),
|
|
139
148
|
// The agent's unattended policy (PR #2003): the runner's gate reads it from the revision body at claim (`unattended`
|
|
140
149
|
// below: "never" alone is kept).
|
|
141
150
|
...capped,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/** What woke a listener: a command row was written for the run, or one was taken, refused or answered
|
|
1
|
+
/** What woke a listener: a command row was written for the run, or one was taken, refused or answered; or the run was
|
|
2
|
+
* queued (a new run a runner may claim now). */
|
|
2
3
|
export interface CommandWake {
|
|
3
4
|
readonly runId: string;
|
|
4
|
-
readonly what: "written" | "answered";
|
|
5
|
+
readonly what: "written" | "answered" | "queued";
|
|
5
6
|
}
|
|
6
7
|
type Listener = (event: CommandWake) => void;
|
|
7
8
|
/** Subscribes `listener` to the commands of the data at `where`; answers the unsubscribe. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// A wake for command rows: a hint to read now, not a source of truth. An in-process bus keyed by a store's
|
|
2
|
-
// handles on the same data share one), so a write through one handle wakes the readers of the others without
|
|
3
|
-
// their poll. It reaches handles in this process only: a row another process writes wakes nothing here, and
|
|
4
|
-
// poll finds it.
|
|
1
|
+
// A wake for command rows and new runs: a hint to read now, not a source of truth. An in-process bus keyed by a store's
|
|
2
|
+
// `where` (two handles on the same data share one), so a write through one handle wakes the readers of the others without
|
|
3
|
+
// waiting for their poll. It reaches handles in this process only: a row another process writes wakes nothing here, and
|
|
4
|
+
// the reader's poll finds it.
|
|
5
5
|
const listeners = new Map();
|
|
6
6
|
/** Subscribes `listener` to the commands of the data at `where`; answers the unsubscribe. */
|
|
7
7
|
export function watchCommandsAt(where, listener) {
|
package/dist/store/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AgentArchived, AnswerTaken, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, RunFinal, SchemaVersionUnknown, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreFromEarlierVersion, StoreLaunchMissing, StoreOwned, StoreWorkerLost, STORE_WRITE_DEADLINE_MS, stoppedByPerson, TriggerFull } from "./store.js";
|
|
2
2
|
export type { ConstraintRule, AgentRow, Agents, AlsoRow, ChannelPost, Claim, Command, ComputerLedger, ComputerLedgerRow, Firing, FiringChange, FiringRow, FiringStatus, FiringStreak, Journal, Live, LiveRow, Mcp, McpCredentialMark, McpRemoved, McpOauth, McpOauthPendingRow, McpPinRow, McpServerRow, McpServerStamp, McpServerWrite, NewFiring, NewPairedComputer, NewRevision, NewTrigger, PairedComputerRow, PairedComputers, ReleasedState, RevisionRow, RunPatch, RunRow, Runs, RunState, SealedKeyRow, SealedKeys, SealedPlane, SealedSecretRow, SealedSecrets, SettingRow, Settings, Staged, StagedTake, Store, StoreRole, TemplatePackage, Templates, TriggerDef, TriggerPatch, TriggerRow, Triggers, TriggerScope, TriggerSettingRow, TriggerSettings, Channels, ChannelAttemptRow, ChannelPostRow, ChannelToldRow, ImportedFrom, ImportSource, ImportRunInput, JournalReads, RunOrigin, RunOutcome, RunLaunchInput, RunLaunchRow, Learning, LearningProposal, LiveViewerRow, LiveViewers, SignIns, SignInRow, SignInTombstoneRow, UpdatedRun, ViewerKind, } from "./store.js";
|
|
3
3
|
export { aadOf, type McpCredential, type OpenedMcpCredential, openMcpCredential, openRunMcpAuth, type RunMcpAuth, sealColumn, type SealedAt, sealedAt, sealMcpCredential, sealRunMcpAuth, unsealColumn } from "./seal.js";
|
|
4
|
-
export { AgentBodyInvalid, type AgenticBody, bodyOf, canonical, isObject, isSkillPath, type PromptVariant, type ModelTiers, type RevisionBodyInput, type RevisionComputer, type RevisionPlace, sha256, type ToolSettings, type WorkflowBody, } from "./agent-body.js";
|
|
4
|
+
export { AgentBodyInvalid, type AgenticBody, bodyOf, canonical, isObject, isSkillPath, type PromptVariant, type ModelTiers, type MonidPinBody, type RevisionBodyInput, type RevisionComputer, type RevisionPlace, sha256, type ToolSettings, type WorkflowBody, } from "./agent-body.js";
|
|
5
5
|
export { checkPrompts, OTHER_OPTION, PromptsInvalid } from "./prompts.js";
|
|
6
6
|
export { DDL, PI_DDL, PI_TABLE, PI_TABLES, SCHEMA_VERSION, STORE_DDL } from "./schema.js";
|
|
7
7
|
export { RunStorage } from "./journal/storage.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { StoreConnection } from './sqlite/connection.js';
|
|
2
|
+
export declare const NATIVE_COMMAND_PREFIX = "native.remote.command.";
|
|
3
|
+
export declare const NATIVE_COMMAND_UPPER = "native.remote.command/";
|
|
4
|
+
export declare const validConnectorId: (value: unknown) => value is string;
|
|
5
|
+
export declare function nativeCommandOwner(key: string, encoded: string): string | null;
|
|
6
|
+
/** A server's additive setup, in bounded pages. Never changes a value, timestamp, lease or receipt. A new writer derives
|
|
7
|
+
* its owner atomically; a concurrent legacy update is reread after its raw-value CAS fails, never labelled from stale data.
|
|
8
|
+
* Older native commands keep immutable owners; supported writers update metadata with their value.
|
|
9
|
+
* Null-owner legacy rows remain readable by the filtered reader until a later server can index them. */
|
|
10
|
+
export declare function backfillNativeCommandOwners(connection: StoreConnection): Promise<void>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const NATIVE_COMMAND_PREFIX = 'native.remote.command.';
|
|
2
|
+
export const NATIVE_COMMAND_UPPER = 'native.remote.command/';
|
|
3
|
+
export const validConnectorId = (value) => typeof value === 'string' && value.length > 0 && value.length <= 160 && !/[\x00-\x1f]/.test(value) && /^[\w.-]+$/.test(value);
|
|
4
|
+
export function nativeCommandOwner(key, encoded) {
|
|
5
|
+
if (!key.startsWith(NATIVE_COMMAND_PREFIX))
|
|
6
|
+
return null;
|
|
7
|
+
try {
|
|
8
|
+
const value = JSON.parse(encoded);
|
|
9
|
+
const owner = value !== null && typeof value === 'object' && !Array.isArray(value) ? value.connector_id : undefined;
|
|
10
|
+
return validConnectorId(owner) ? owner : null;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const change = (row) => ({ sql: 'UPDATE settings SET connector_id = ? WHERE key = ? AND value = ? AND connector_id IS NULL', params: [nativeCommandOwner(row.key, row.value), row.key, row.value] });
|
|
17
|
+
/** A server's additive setup, in bounded pages. Never changes a value, timestamp, lease or receipt. A new writer derives
|
|
18
|
+
* its owner atomically; a concurrent legacy update is reread after its raw-value CAS fails, never labelled from stale data.
|
|
19
|
+
* Older native commands keep immutable owners; supported writers update metadata with their value.
|
|
20
|
+
* Null-owner legacy rows remain readable by the filtered reader until a later server can index them. */
|
|
21
|
+
export async function backfillNativeCommandOwners(connection) {
|
|
22
|
+
let after = '';
|
|
23
|
+
for (;;) {
|
|
24
|
+
const page = await connection.all('SELECT key,value,connector_id FROM settings WHERE key >= ? AND key < ? AND key > ? AND connector_id IS NULL ORDER BY key LIMIT 8', NATIVE_COMMAND_PREFIX, NATIVE_COMMAND_UPPER, after);
|
|
25
|
+
if (!page.length)
|
|
26
|
+
return;
|
|
27
|
+
const results = await connection.write(page.map(change));
|
|
28
|
+
for (let i = 0; i < page.length; i++)
|
|
29
|
+
if (results[i].changes === 0) {
|
|
30
|
+
let settled = false;
|
|
31
|
+
for (let attempt = 0; attempt < 10; attempt++) {
|
|
32
|
+
const row = await connection.get('SELECT key,value,connector_id FROM settings WHERE key = ?', page[i].key);
|
|
33
|
+
if (!row || row.connector_id !== null) {
|
|
34
|
+
settled = true;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
if ((await connection.write([change(row)]))[0].changes === 1) {
|
|
38
|
+
settled = true;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!settled)
|
|
43
|
+
throw new Error('Native command ownership setup is busy. Stop older runners and start this build’s server again before its runners.');
|
|
44
|
+
}
|
|
45
|
+
after = page.at(-1).key;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -387,7 +387,9 @@ export class PgConnection {
|
|
|
387
387
|
// connectionTimeoutMillis bounds a new connection's connect and startup, and a wait for a pool client to come free.
|
|
388
388
|
// keepAlive: this end's TCP keepalives, from KEEPALIVE_IDLE_S (pg's default delay, 0, is the OS's 2 h).
|
|
389
389
|
const tcp = { keepAlive: true, keepAliveInitialDelayMillis: KEEPALIVE_IDLE_S * 1_000 };
|
|
390
|
-
|
|
390
|
+
// Every connection named for its schema, as the lease's and the owner lock's are: pg_stat_activity tells which
|
|
391
|
+
// store holds each one.
|
|
392
|
+
const config = { connectionString: url, options: session, types, max: poolSize, allowExitOnIdle: true, application_name: `agentrun-store:${schema}`, connectionTimeoutMillis: connectMs, ...tcp };
|
|
391
393
|
let lock;
|
|
392
394
|
const waitMs = Math.max(0, Math.floor(ownerWaitMs));
|
|
393
395
|
if (owner) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- The store's schema on Postgres, version 10: the template packages imported from GitHub (POST /v2/templates/import), as
|
|
2
|
+
-- store/schema.ts keeps them on SQLite (IMPORTED_TEMPLATES). Applied once, after 0009, inside the transaction
|
|
3
|
+
-- migrate.ts opens. Never edit this file once applied: a change is a new file.
|
|
4
|
+
--
|
|
5
|
+
-- imported_templates: one row per package id (github:<owner>/<repo>[/<path>]); files is a JSON object of path to base64,
|
|
6
|
+
-- the package's files as read. The table is made only where it is missing, so a store whose record of this file was lost
|
|
7
|
+
-- applies it again unharmed.
|
|
8
|
+
|
|
9
|
+
CREATE TABLE IF NOT EXISTS imported_templates (
|
|
10
|
+
id TEXT COLLATE "C" PRIMARY KEY,
|
|
11
|
+
source TEXT COLLATE "C" NOT NULL,
|
|
12
|
+
sha TEXT COLLATE "C" NOT NULL,
|
|
13
|
+
publisher TEXT COLLATE "C" NOT NULL,
|
|
14
|
+
files TEXT COLLATE "C" NOT NULL CHECK (files::json IS NOT NULL),
|
|
15
|
+
imported_at BIGINT NOT NULL
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
UPDATE store_meta SET schema_version = 10 WHERE singleton = 1;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- The store's schema on Postgres, version 11: an agent's MCP tools are pinned on its revision when it is saved
|
|
2
|
+
-- (revisions.mcp_pin), as store/schema.ts keeps them on SQLite (where a server open adds the column), in place of each
|
|
3
|
+
-- run's pin at its first claim (mcp_pins, dropped: a run reads its revision's). Applied once, after 0010, inside the
|
|
4
|
+
-- transaction migrate.ts opens. Never edit this file once applied: a change is a new file.
|
|
5
|
+
--
|
|
6
|
+
-- mcp_pin: JSON text, per granted server its URL then, the granted tools as it listed them and their prices; NULL for a
|
|
7
|
+
-- revision that grants no MCP tool.
|
|
8
|
+
|
|
9
|
+
ALTER TABLE revisions ADD COLUMN IF NOT EXISTS mcp_pin TEXT COLLATE "C" CHECK (mcp_pin IS NULL OR mcp_pin::json IS NOT NULL);
|
|
10
|
+
|
|
11
|
+
DROP TABLE IF EXISTS mcp_pins;
|
|
12
|
+
|
|
13
|
+
UPDATE store_meta SET schema_version = 11 WHERE singleton = 1;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- Version 12: an agent's monid pin on its revision (revisions.monid_pin, as store/schema.ts), no longer in its body.
|
|
2
|
+
-- Applied once, after 0011, inside the transaction migrate.ts opens. Never edit this file once applied.
|
|
3
|
+
ALTER TABLE revisions ADD COLUMN IF NOT EXISTS monid_pin TEXT COLLATE "C" CHECK (monid_pin IS NULL OR monid_pin::json IS NOT NULL);
|
|
4
|
+
UPDATE store_meta SET schema_version = 12 WHERE singleton = 1;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- A bounded connector owner is derived from the exact command JSON by the server, preserving payload bytes (including
|
|
2
|
+
-- escaped NUL, which PostgreSQL JSON extraction cannot read). Existing rows are backfilled before polling is served.
|
|
3
|
+
ALTER TABLE settings ADD COLUMN IF NOT EXISTS connector_id TEXT COLLATE "C";
|
|
4
|
+
CREATE INDEX IF NOT EXISTS settings_native_commands ON settings (connector_id, key)
|
|
5
|
+
WHERE key >= 'native.remote.command.' AND key < 'native.remote.command/';
|
|
6
|
+
UPDATE store_meta SET schema_version = 13 WHERE singleton = 1;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- Version 14: whether a run's stored cost is the most it can have cost (runs.cost_upper_bound, as store/schema.ts keeps it
|
|
2
|
+
-- on SQLite): 1 when it counts a request cut with no answer at what its cap held for it, written in the end's commit with
|
|
3
|
+
-- cost_usd; 0 otherwise, an unknown cost's included. A run ended before reads 0. Applied once, after 0013, inside the
|
|
4
|
+
-- transaction migrate.ts opens. Never edit this file once applied: a change is a new file.
|
|
5
|
+
ALTER TABLE runs ADD COLUMN IF NOT EXISTS cost_upper_bound BIGINT NOT NULL DEFAULT 0 CHECK (cost_upper_bound IN (0, 1));
|
|
6
|
+
UPDATE store_meta SET schema_version = 14 WHERE singleton = 1;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// (connection.ts) in the store's own schema (default "agentrun"). The server sets the schema up (migrate.ts) and holds the
|
|
3
3
|
// owner lock, one server per schema; runners are many, set nothing up, and refuse a schema version they do not know.
|
|
4
4
|
import { SchemaVersionUnknown } from "../store.js";
|
|
5
|
+
import { backfillNativeCommandOwners } from '../native-command-owner.js';
|
|
5
6
|
import { storeOver } from "../sqlite/store.js";
|
|
6
7
|
import { PgConnection, SCHEMA_NAME } from "./connection.js";
|
|
7
8
|
import { migrate, migrationsIn, placeOf, versionOf } from "./migrate.js";
|
|
@@ -42,6 +43,8 @@ export async function openPostgresStore(options) {
|
|
|
42
43
|
const found = await connection.withClient((client) => (role === "server" ? migrate(client, schema, now(), migrations) : versionOf(client, schema)));
|
|
43
44
|
if (found !== known)
|
|
44
45
|
throw new SchemaVersionUnknown(placeOf(schema), found, known);
|
|
46
|
+
if (role === "server")
|
|
47
|
+
await backfillNativeCommandOwners(connection);
|
|
45
48
|
if (role === "runner" && options.warn) {
|
|
46
49
|
const gap = now() - (await connection.clock());
|
|
47
50
|
if (Math.abs(gap) > CLOCK_WARN_MS) {
|
package/dist/store/schema.d.ts
CHANGED
|
@@ -5,7 +5,23 @@ export declare const SCHEMA_VERSION = 11;
|
|
|
5
5
|
/** One unrefused answer per approval of a run: an answer the runner refused (its run could not resume) holds no place, so
|
|
6
6
|
* the person can answer again. */
|
|
7
7
|
export declare const ONE_ANSWER_INDEX = "commands_one_answer";
|
|
8
|
+
/** The connector's own command rows, without parsing another connector's events on every heartbeat. */
|
|
9
|
+
export declare const NATIVE_COMMANDS_INDEX = "CREATE INDEX IF NOT EXISTS settings_native_commands ON settings (connector_id, key) WHERE key >= 'native.remote.command.' AND key < 'native.remote.command/'";
|
|
8
10
|
export declare const COMMANDS_ONE_ANSWER = "CREATE UNIQUE INDEX IF NOT EXISTS commands_one_answer ON commands (run_id, json_extract(body, '$.approval')) WHERE kind IN ('approve', 'deny') AND refused IS NULL";
|
|
11
|
+
/** A revision's MCP pin, as its save listed the tools (JSON, null when it grants no MCP tool). In STORE_DDL, and added at a
|
|
12
|
+
* server open to a store an earlier build of this version made (one that pinned each run in mcp_pins, dropped at that open). */
|
|
13
|
+
export declare const REVISIONS_MCP_PIN: string;
|
|
14
|
+
/** A revision's monid pin (JSON, null for none): in STORE_DDL, and added at a server open as REVISIONS_MCP_PIN is. */
|
|
15
|
+
export declare const REVISIONS_MONID_PIN: string;
|
|
16
|
+
/** The bound beside a run's cost: in STORE_DDL, and added at a server open to a store an earlier build of this version made,
|
|
17
|
+
* as REVISIONS_MCP_PIN is (a run it ended reads 0: an exact cost or an unknown one, as it was read then). */
|
|
18
|
+
export declare const RUNS_COST_UPPER_BOUND = "ALTER TABLE runs ADD COLUMN cost_upper_bound INTEGER NOT NULL DEFAULT 0 CHECK (cost_upper_bound IN (0, 1))";
|
|
19
|
+
/** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
|
|
20
|
+
* source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
|
|
21
|
+
* (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
|
|
22
|
+
* as it loads them at its start (templates.ts readPackage); nothing in them runs. In STORE_DDL, and added at a server
|
|
23
|
+
* open to a store an earlier build of this version made. */
|
|
24
|
+
export declare const IMPORTED_TEMPLATES: string;
|
|
9
25
|
export declare const STORE_DDL: readonly string[];
|
|
10
26
|
/** pi-durable's journal tables (its SqliteStorage schema, version 2, the `sleeping` task status included; MIT, see NOTICE),
|
|
11
27
|
* every one keyed by (run_id, …) with run_id leading its indexes, so one run's scans read only its rows and two runs never
|
package/dist/store/schema.js
CHANGED
|
@@ -8,7 +8,15 @@
|
|
|
8
8
|
// run-change feed (run_changes), each channel post's tries (channel_attempts) and the claim a post's try settles under
|
|
9
9
|
// (channel_posts.claim); version 9 adds where a live viewer answers (computer_viewers.host, a runner's live host,
|
|
10
10
|
// live-reach.ts); version 10 pairs a person's own computer (paired_computers, pairing_codes); version 11 keeps a command's answer
|
|
11
|
-
// (commands.answer).
|
|
11
|
+
// (commands.answer). An agent's MCP tools are pinned on its revision when it is saved (revisions.mcp_pin, REVISIONS_MCP_PIN),
|
|
12
|
+
// in place of each run's pin at its first claim (the mcp_pins table): a server open adds the column to a store an earlier
|
|
13
|
+
// build of this version made and drops the table, so a revision saved before has no pin until its first run pins it.
|
|
14
|
+
// Its monid endpoints are pinned beside them (revisions.monid_pin, REVISIONS_MONID_PIN), added at a server open the same way.
|
|
15
|
+
// A run's cost says whether it is the most the run can have cost (runs.cost_upper_bound, RUNS_COST_UPPER_BOUND), added at a
|
|
16
|
+
// server open the same way.
|
|
17
|
+
// The template packages imported from GitHub (imported_templates) are a table of their own that nothing
|
|
18
|
+
// else reads, so it needs no version: the server adds it at its open to a store an earlier build of this version made
|
|
19
|
+
// (IMPORTED_TEMPLATES), as it does the one-answer index.
|
|
12
20
|
// Conventions: every time is INTEGER epoch milliseconds; JSON is TEXT checked by json_valid; money is REAL US dollars;
|
|
13
21
|
// sealed columns hold ciphertext only (sealed with the server's key outside the store), so the store never sees a secret
|
|
14
22
|
// in the clear. Foreign keys are on (the connection's pragma).
|
|
@@ -16,7 +24,7 @@
|
|
|
16
24
|
// STORE_DDL is the control plane and the runs: agents and revisions (with a template's package), runs (state, the claim's
|
|
17
25
|
// epoch, runner, claimed_until and wake_at, cost, metrics, summary), commands, idempotency, triggers (their scopes,
|
|
18
26
|
// firings, conversations and settings), the channel outbox and told ledger, the review ledger, settings, sealed keys,
|
|
19
|
-
// learning state, the MCP registry, pending MCP sign-ins,
|
|
27
|
+
// learning state, the MCP registry, pending MCP sign-ins, and the computer ledger. PI_DDL is pi-durable's
|
|
20
28
|
// journal tables, keyed by run_id (store/journal): one schema for every run's journal, so a query joins runs and their
|
|
21
29
|
// journals.
|
|
22
30
|
export const SCHEMA_VERSION = 11;
|
|
@@ -26,8 +34,35 @@ export const SCHEMA_VERSION = 11;
|
|
|
26
34
|
/** One unrefused answer per approval of a run: an answer the runner refused (its run could not resume) holds no place, so
|
|
27
35
|
* the person can answer again. */
|
|
28
36
|
export const ONE_ANSWER_INDEX = "commands_one_answer";
|
|
37
|
+
/** The connector's own command rows, without parsing another connector's events on every heartbeat. */
|
|
38
|
+
export const NATIVE_COMMANDS_INDEX = `CREATE INDEX IF NOT EXISTS settings_native_commands ON settings (connector_id, key) WHERE key >= 'native.remote.command.' AND key < 'native.remote.command/'`;
|
|
29
39
|
export const COMMANDS_ONE_ANSWER = `CREATE UNIQUE INDEX IF NOT EXISTS ${ONE_ANSWER_INDEX} ON commands (run_id, json_extract(body, '$.approval')) WHERE kind IN ('approve', 'deny') AND refused IS NULL`;
|
|
30
40
|
const json = (column, nullable = false) => `${column} TEXT${nullable ? "" : " NOT NULL"} CHECK (${column} IS NULL OR json_valid(${column}))`;
|
|
41
|
+
/** A revision's MCP pin, as its save listed the tools (JSON, null when it grants no MCP tool). In STORE_DDL, and added at a
|
|
42
|
+
* server open to a store an earlier build of this version made (one that pinned each run in mcp_pins, dropped at that open). */
|
|
43
|
+
export const REVISIONS_MCP_PIN = `ALTER TABLE revisions ADD COLUMN ${json("mcp_pin", true)}`;
|
|
44
|
+
/** A revision's monid pin (JSON, null for none): in STORE_DDL, and added at a server open as REVISIONS_MCP_PIN is. */
|
|
45
|
+
export const REVISIONS_MONID_PIN = `ALTER TABLE revisions ADD COLUMN ${json("monid_pin", true)}`;
|
|
46
|
+
/** Whether a run's stored cost (cost_usd) is the most it can have cost, not its cost: 1 when it counts a request cut with
|
|
47
|
+
* no answer at what its cap held for it (runner.ts CUT_AT_HOLD), written in the end's commit with the cost; 0 otherwise,
|
|
48
|
+
* an unknown cost's included. */
|
|
49
|
+
const COST_UPPER_BOUND = "cost_upper_bound INTEGER NOT NULL DEFAULT 0 CHECK (cost_upper_bound IN (0, 1))";
|
|
50
|
+
/** The bound beside a run's cost: in STORE_DDL, and added at a server open to a store an earlier build of this version made,
|
|
51
|
+
* as REVISIONS_MCP_PIN is (a run it ended reads 0: an exact cost or an unknown one, as it was read then). */
|
|
52
|
+
export const RUNS_COST_UPPER_BOUND = `ALTER TABLE runs ADD COLUMN ${COST_UPPER_BOUND}`;
|
|
53
|
+
/** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
|
|
54
|
+
* source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
|
|
55
|
+
* (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
|
|
56
|
+
* as it loads them at its start (templates.ts readPackage); nothing in them runs. In STORE_DDL, and added at a server
|
|
57
|
+
* open to a store an earlier build of this version made. */
|
|
58
|
+
export const IMPORTED_TEMPLATES = `CREATE TABLE IF NOT EXISTS imported_templates (
|
|
59
|
+
id TEXT PRIMARY KEY,
|
|
60
|
+
source TEXT NOT NULL,
|
|
61
|
+
sha TEXT NOT NULL,
|
|
62
|
+
publisher TEXT NOT NULL,
|
|
63
|
+
${json("files")},
|
|
64
|
+
imported_at INTEGER NOT NULL
|
|
65
|
+
) STRICT`;
|
|
31
66
|
export const STORE_DDL = [
|
|
32
67
|
`CREATE TABLE IF NOT EXISTS store_meta (
|
|
33
68
|
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
@@ -56,6 +91,9 @@ export const STORE_DDL = [
|
|
|
56
91
|
// read and copied whole with its files. Null is none (a revision with no skills).
|
|
57
92
|
// `parent_id`: the revision that was the agent's current one when this revision was committed (null for its first), kept
|
|
58
93
|
// for the v2 revisions view. `note`: the optional note a revision was committed with (the v2 note), null for none.
|
|
94
|
+
// `mcp_pin`: the MCP tools the revision grants, as their servers listed them when it was saved (mcp-gateway.ts McpPin:
|
|
95
|
+
// per server its URL then, the granted tools, their prices), which every run of it calls; null when it grants none.
|
|
96
|
+
// `monid_pin`: its monid endpoints as monid listed them when it was saved (agent-body.ts MonidPinBody); null for none.
|
|
59
97
|
`CREATE TABLE IF NOT EXISTS revisions (
|
|
60
98
|
id TEXT PRIMARY KEY,
|
|
61
99
|
agent_id TEXT NOT NULL REFERENCES agents (id),
|
|
@@ -66,7 +104,9 @@ export const STORE_DDL = [
|
|
|
66
104
|
${json("package", true)},
|
|
67
105
|
note TEXT,
|
|
68
106
|
external_version TEXT,
|
|
69
|
-
created_at INTEGER NOT NULL
|
|
107
|
+
created_at INTEGER NOT NULL,
|
|
108
|
+
${json("mcp_pin", true)},
|
|
109
|
+
${json("monid_pin", true)}
|
|
70
110
|
) STRICT`,
|
|
71
111
|
`CREATE INDEX IF NOT EXISTS revisions_by_agent ON revisions (agent_id, created_at)`,
|
|
72
112
|
// `external_version`: for a revision of an externally owned agent, the version it maps there (one revision per version),
|
|
@@ -85,6 +125,7 @@ export const STORE_DDL = [
|
|
|
85
125
|
wake_at INTEGER,
|
|
86
126
|
backoff_until INTEGER,
|
|
87
127
|
cost_usd REAL,
|
|
128
|
+
${COST_UPPER_BOUND},
|
|
88
129
|
${json("metrics", true)},
|
|
89
130
|
summary TEXT,
|
|
90
131
|
-- How the run ended beside its state (RunOutcome). An ended run: 'escalated' (it finished its work and waits for a
|
|
@@ -293,8 +334,10 @@ export const STORE_DDL = [
|
|
|
293
334
|
`CREATE TABLE IF NOT EXISTS settings (
|
|
294
335
|
key TEXT PRIMARY KEY,
|
|
295
336
|
${json("value")},
|
|
337
|
+
connector_id TEXT,
|
|
296
338
|
updated_at INTEGER NOT NULL
|
|
297
339
|
) STRICT`,
|
|
340
|
+
NATIVE_COMMANDS_INDEX,
|
|
298
341
|
`CREATE TABLE IF NOT EXISTS sealed_keys (
|
|
299
342
|
name TEXT PRIMARY KEY,
|
|
300
343
|
sealed BLOB NOT NULL,
|
|
@@ -341,6 +384,7 @@ export const STORE_DDL = [
|
|
|
341
384
|
updated_at INTEGER NOT NULL,
|
|
342
385
|
PRIMARY KEY (agent_id, key)
|
|
343
386
|
) STRICT`,
|
|
387
|
+
IMPORTED_TEMPLATES,
|
|
344
388
|
// An agent's saved browser sign-ins (design 2.1, the browser sign-in rules): one live row per agent and browser provider, its
|
|
345
389
|
// pointer (the vendor's context or profile id) sealed with the store's one rule (store/seal.ts, AAD
|
|
346
390
|
// sign_ins|<agent>:<provider>|pointer), which the store never opens. The owner sees its name ("default") and saved_at,
|
|
@@ -409,11 +453,6 @@ export const STORE_DDL = [
|
|
|
409
453
|
-- The sign-in's non-secret working state the callback rebuilds (url, was, scope, kind, discovery, resource): no secret.
|
|
410
454
|
${json("working", true)},
|
|
411
455
|
expires_at INTEGER NOT NULL
|
|
412
|
-
) STRICT`,
|
|
413
|
-
`CREATE TABLE IF NOT EXISTS mcp_pins (
|
|
414
|
-
run_id TEXT PRIMARY KEY REFERENCES runs (id),
|
|
415
|
-
${json("body")},
|
|
416
|
-
pinned_at INTEGER NOT NULL
|
|
417
456
|
) STRICT`,
|
|
418
457
|
// A run's launch record: the one body the server writes when it starts a run (start = INSERT run), read by the runner at
|
|
419
458
|
// its claim to build the run's spec. It replaces the per-run serve.json the old per-run process read: one row per run,
|
|
@@ -71,8 +71,8 @@ export interface StoreConnection {
|
|
|
71
71
|
}
|
|
72
72
|
/** The flags the store's worker is given when this process was started with code on its command line: this process's
|
|
73
73
|
* less those that apply only to that code (`--input-type`, `-e`/`--eval` and `-p`/`--print` with their code). A worker
|
|
74
|
-
* from a file refuses them ("--input-type can only be used with string input via --eval"), and
|
|
75
|
-
*
|
|
74
|
+
* from a file refuses them ("--input-type can only be used with string input via --eval"), and a process started
|
|
75
|
+
* so (`node --input-type=module -e '…'`, as a test or a server's own `--` command may be) would have no worker. Undefined
|
|
76
76
|
* when there are none to drop: the worker then inherits this process's flags as Node gives them, untouched (a list given
|
|
77
77
|
* to Worker is checked flag by flag, and one a worker may not take, a process-wide one, is refused). */
|
|
78
78
|
export declare function workerExecArgv(given: readonly string[]): string[] | undefined;
|
|
@@ -85,8 +85,8 @@ function whereOf(file) {
|
|
|
85
85
|
}
|
|
86
86
|
/** The flags the store's worker is given when this process was started with code on its command line: this process's
|
|
87
87
|
* less those that apply only to that code (`--input-type`, `-e`/`--eval` and `-p`/`--print` with their code). A worker
|
|
88
|
-
* from a file refuses them ("--input-type can only be used with string input via --eval"), and
|
|
89
|
-
*
|
|
88
|
+
* from a file refuses them ("--input-type can only be used with string input via --eval"), and a process started
|
|
89
|
+
* so (`node --input-type=module -e '…'`, as a test or a server's own `--` command may be) would have no worker. Undefined
|
|
90
90
|
* when there are none to drop: the worker then inherits this process's flags as Node gives them, untouched (a list given
|
|
91
91
|
* to Worker is checked flag by flag, and one a worker may not take, a process-wide one, is refused). */
|
|
92
92
|
export function workerExecArgv(given) {
|
|
@@ -36,6 +36,7 @@ export type RunRecord = {
|
|
|
36
36
|
wake_at: number | null;
|
|
37
37
|
backoff_until: number | null;
|
|
38
38
|
cost_usd: number | null;
|
|
39
|
+
cost_upper_bound: number;
|
|
39
40
|
metrics: string | null;
|
|
40
41
|
summary: string | null;
|
|
41
42
|
outcome: string | null;
|
|
@@ -45,7 +46,13 @@ export type RunRecord = {
|
|
|
45
46
|
started_at: number;
|
|
46
47
|
ended_at: number | null;
|
|
47
48
|
};
|
|
48
|
-
export declare const RUN_COLUMNS = "id, agent_id, revision_id, state, epoch, runner, claimed_until, wake_at, backoff_until, cost_usd, metrics, summary, outcome, archived_at, imported_from, sign_in_handed, started_at, ended_at";
|
|
49
|
+
export declare const RUN_COLUMNS = "id, agent_id, revision_id, state, epoch, runner, claimed_until, wake_at, backoff_until, cost_usd, cost_upper_bound, metrics, summary, outcome, archived_at, imported_from, sign_in_handed, started_at, ended_at";
|
|
50
|
+
/** A run's exact cost in SQL, for a query that reads runs.cost_usd itself (`alias`: its runs table's): NULL when the
|
|
51
|
+
* stored figure is only the most the run can have cost, as runOf reads it. Every raw read of the column goes through it. */
|
|
52
|
+
export declare const EXACT_COST_USD: (alias: string) => string;
|
|
53
|
+
/** The run row from its record. The stored cost splits here, once, for every reader: an exact cost (or null) is `costUsd`;
|
|
54
|
+
* a cost stored as the most the run can have cost (cost_upper_bound 1) is `costAtMostUsd` alone, and `costUsd` reads null,
|
|
55
|
+
* as for a cost no one knows. So a reader that sums or shows spend never reads a bound, with no check of its own. */
|
|
49
56
|
export declare const runOf: (r: RunRecord) => RunRow;
|
|
50
57
|
/** Applies `patch` to the claim's run, then writes `also`, through `tx` (an open transaction's handle). Fenced, with nothing
|
|
51
58
|
* of it written once the caller rolls back, when the run's epoch is not the claim's or the claim's lease ran out before
|
|
@@ -18,10 +18,17 @@ export const learningLaunchOf = (runId, model, round = 1, capUsd) => ({ harness:
|
|
|
18
18
|
/** The lock a write of a run's sign_in_handed and a sign-in's forget both take (Dialect.lockKey): the forget's check of
|
|
19
19
|
* the running runs' hashes and a launch's write of them are serialized, as SQLite's one writer serializes them. */
|
|
20
20
|
export const SIGN_IN_HANDED_LOCK = "sign_in_handed";
|
|
21
|
-
export const RUN_COLUMNS = "id, agent_id, revision_id, state, epoch, runner, claimed_until, wake_at, backoff_until, cost_usd, metrics, summary, outcome, archived_at, imported_from, sign_in_handed, started_at, ended_at";
|
|
21
|
+
export const RUN_COLUMNS = "id, agent_id, revision_id, state, epoch, runner, claimed_until, wake_at, backoff_until, cost_usd, cost_upper_bound, metrics, summary, outcome, archived_at, imported_from, sign_in_handed, started_at, ended_at";
|
|
22
|
+
/** A run's exact cost in SQL, for a query that reads runs.cost_usd itself (`alias`: its runs table's): NULL when the
|
|
23
|
+
* stored figure is only the most the run can have cost, as runOf reads it. Every raw read of the column goes through it. */
|
|
24
|
+
export const EXACT_COST_USD = (alias) => `CASE WHEN ${alias}.cost_upper_bound = 1 THEN NULL ELSE ${alias}.cost_usd END`;
|
|
25
|
+
const costOf = (usd, bound) => usd !== null && Number(bound) === 1 ? { costUsd: null, costAtMostUsd: usd } : { costUsd: usd, costAtMostUsd: null };
|
|
26
|
+
/** The run row from its record. The stored cost splits here, once, for every reader: an exact cost (or null) is `costUsd`;
|
|
27
|
+
* a cost stored as the most the run can have cost (cost_upper_bound 1) is `costAtMostUsd` alone, and `costUsd` reads null,
|
|
28
|
+
* as for a cost no one knows. So a reader that sums or shows spend never reads a bound, with no check of its own. */
|
|
22
29
|
export const runOf = (r) => ({
|
|
23
30
|
id: r.id, agentId: r.agent_id, revisionId: r.revision_id, state: r.state, epoch: r.epoch, runner: r.runner, claimedUntil: r.claimed_until,
|
|
24
|
-
wakeAt: r.wake_at, backoffUntil: r.backoff_until,
|
|
31
|
+
wakeAt: r.wake_at, backoffUntil: r.backoff_until, ...costOf(r.cost_usd, r.cost_upper_bound), metrics: r.metrics === null ? null : JSON.parse(r.metrics), summary: r.summary,
|
|
25
32
|
outcome: r.outcome ?? null, archivedAt: r.archived_at, importedFrom: r.imported_from === null ? null : JSON.parse(r.imported_from),
|
|
26
33
|
signInHanded: r.sign_in_handed === null ? null : JSON.parse(r.sign_in_handed), startedAt: r.started_at, endedAt: r.ended_at,
|
|
27
34
|
});
|
|
@@ -36,8 +43,12 @@ export async function applyRunPatch(tx, claim, patch, also, now, dialect = SQLIT
|
|
|
36
43
|
const set = (column, value) => (sets.push(`${column} = ?`), params.push(value));
|
|
37
44
|
if (patch.state !== undefined)
|
|
38
45
|
set("state", patch.state);
|
|
39
|
-
|
|
46
|
+
// The bound beside the cost goes with it: a cost written without one is exact (or unknown), never a bound left from an
|
|
47
|
+
// earlier end of the run.
|
|
48
|
+
if (patch.costUsd !== undefined) {
|
|
40
49
|
set("cost_usd", patch.costUsd);
|
|
50
|
+
set("cost_upper_bound", patch.costUsd !== null && patch.costUpperBound === true ? 1 : 0);
|
|
51
|
+
}
|
|
41
52
|
if (patch.metrics !== undefined)
|
|
42
53
|
set("metrics", patch.metrics === null ? null : JSON.stringify(patch.metrics));
|
|
43
54
|
if (patch.summary !== undefined)
|
|
@@ -94,17 +105,29 @@ export async function applyRunPatch(tx, claim, patch, also, now, dialect = SQLIT
|
|
|
94
105
|
await tx.run("INSERT INTO learning_proposals (run_id, round, agent_id, turn, proposal, learning_run_id, created_at) SELECT id, ?, agent_id, ?, ?, ?, ? FROM runs WHERE id = ? ON CONFLICT (run_id, round) DO NOTHING", each.row.round ?? 1, JSON.stringify(each.row.turn ?? null), JSON.stringify(each.row.proposal ?? null), queued?.row.id ?? null, now, claim.runId);
|
|
95
106
|
break;
|
|
96
107
|
}
|
|
97
|
-
// The learning run
|
|
108
|
+
// The learning run is queued after every row of the end (below): only once its kept learning names it.
|
|
98
109
|
case "learning_run":
|
|
99
|
-
await tx.run("INSERT INTO runs (id, agent_id, revision_id, state, epoch, started_at) SELECT ?, agent_id, revision_id, 'queued', 0, ? FROM runs WHERE id = ? ON CONFLICT (id) DO NOTHING", each.row.id, now, claim.runId);
|
|
100
|
-
// Its launch row, with it: harness "learning" (the runner's loop factory picks the learning loop by it), its input
|
|
101
|
-
// the run that learned, and the cap its grade runs under. Written once, as the run is.
|
|
102
|
-
if (!(await tx.get("SELECT 1 AS found FROM run_launch WHERE run_id = ?", each.row.id))) {
|
|
103
|
-
await writeLaunch(tx, each.row.id, { body: learningLaunchOf(claim.runId, each.row.model, each.row.round, each.row.capUsd) }, now);
|
|
104
|
-
}
|
|
105
110
|
break;
|
|
106
111
|
}
|
|
107
112
|
}
|
|
113
|
+
// The learning run: queued, of the run's agent and revision, started once (the same id again adds nothing), and only
|
|
114
|
+
// when the run's kept learning names it. A kept learning is kept once (above): a follow-up's end that keeps another
|
|
115
|
+
// beside one already kept that names no learning run (dropped: nothing to grade) queues none, so no learning run is
|
|
116
|
+
// ever left that no kept learning names. Such a run would be no run's grade: every list of runs would show it as the
|
|
117
|
+
// agent's own run (NOT_A_LEARNING_RUN reads the kept learning), and its spend would be booked on no run.
|
|
118
|
+
for (const each of also) {
|
|
119
|
+
if (each.table !== "learning_run")
|
|
120
|
+
continue;
|
|
121
|
+
const named = await tx.get("SELECT 1 AS found FROM learning_proposals WHERE run_id = ? AND learning_run_id = ?", claim.runId, each.row.id);
|
|
122
|
+
if (!named)
|
|
123
|
+
continue;
|
|
124
|
+
await tx.run("INSERT INTO runs (id, agent_id, revision_id, state, epoch, started_at) SELECT ?, agent_id, revision_id, 'queued', 0, ? FROM runs WHERE id = ? ON CONFLICT (id) DO NOTHING", each.row.id, now, claim.runId);
|
|
125
|
+
// Its launch row, with it: harness "learning" (the runner's loop factory picks the learning loop by it), its input
|
|
126
|
+
// the run that learned. Written once, as the run is.
|
|
127
|
+
if (!(await tx.get("SELECT 1 AS found FROM run_launch WHERE run_id = ?", each.row.id))) {
|
|
128
|
+
await writeLaunch(tx, each.row.id, { body: learningLaunchOf(claim.runId, each.row.model, each.row.round, each.row.capUsd) }, now);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
108
131
|
return runOf(row);
|
|
109
132
|
}
|
|
110
133
|
/** The one reopen a run that ended may take (runs.reopen, and a run's end with a person's message waiting): back to running
|