@parcha/agentrun-serve 0.1.0-beta.37 → 0.1.0-beta.38
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 +282 -0
- package/README.md +155 -92
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +39 -14
- 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/browser-cost.js +52 -93
- package/dist/cap.d.ts +0 -390
- package/dist/cap.js +4 -937
- package/dist/catalog.js +1 -1
- package/dist/composio-preset.d.ts +17 -0
- package/dist/composio-preset.js +43 -1
- package/dist/computer-calls.d.ts +36 -24
- package/dist/computer-calls.js +110 -27
- package/dist/computer-live.d.ts +5 -0
- package/dist/computer-live.js +12 -0
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +3 -2
- package/dist/computer-view.js +5 -4
- package/dist/computer-viewer.js +26 -12
- package/dist/computers.d.ts +4 -1
- package/dist/computers.js +12 -6
- package/dist/console/assets/index-CjqQirbo.css +1 -0
- package/dist/console/assets/index-b6-XY5A9.js +576 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +3 -0
- package/dist/decisions.js +4 -0
- package/dist/faux-computers.js +4 -2
- package/dist/harness-opencode/adapter.js +7 -3
- package/dist/harness-opencode/facts.js +0 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -5
- package/dist/harness-opencode/host/policy.js +8 -32
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +0 -2
- package/dist/host-tools.d.ts +1 -5
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +0 -2
- package/dist/hosted-search.js +0 -21
- package/dist/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +6 -1
- package/dist/learn/check.js +12 -4
- package/dist/learn/commit.d.ts +10 -0
- package/dist/learn/commit.js +18 -4
- package/dist/learn/compile.d.ts +243 -0
- package/dist/learn/compile.js +471 -0
- package/dist/learn/general.d.ts +3 -0
- package/dist/learn/general.js +4 -2
- package/dist/learn/grade.d.ts +1 -1
- package/dist/learn/grade.js +7 -6
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +253 -0
- package/dist/learn/promote.js +428 -0
- package/dist/learn/refit.d.ts +39 -0
- package/dist/learn/refit.js +236 -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 +17 -9
- package/dist/learn/skills.js +132 -42
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +50 -2
- package/dist/learned-nodes.js +41 -2
- package/dist/learned-workflow.d.ts +19 -3
- package/dist/learned-workflow.js +105 -26
- package/dist/learning-batch.d.ts +2 -2
- package/dist/learning-batch.js +1 -1
- package/dist/learning-cost.d.ts +18 -6
- package/dist/learning-cost.js +15 -7
- package/dist/learning-routes.d.ts +14 -2
- package/dist/learning-routes.js +14 -3
- package/dist/learning-words.d.ts +7 -0
- package/dist/learning-words.js +7 -0
- package/dist/learning.d.ts +31 -6
- package/dist/learning.js +7 -4
- package/dist/llm.js +0 -3
- 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 +107 -0
- package/dist/mcp-probe.d.ts +8 -9
- package/dist/mcp-probe.js +16 -33
- package/dist/mcp-servers-store.d.ts +89 -22
- package/dist/mcp-servers-store.js +131 -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.d.ts +13 -0
- package/dist/model.js +46 -15
- package/dist/monid.d.ts +51 -25
- package/dist/monid.js +226 -140
- package/dist/openapi.js +336 -66
- package/dist/paid-calls.d.ts +26 -29
- package/dist/paid-calls.js +46 -102
- package/dist/propose.d.ts +7 -1
- package/dist/propose.js +18 -6
- package/dist/provider.js +9 -2
- package/dist/reflect-range.js +2 -1
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +13 -0
- package/dist/run-launch.js +6 -0
- package/dist/run-learning-served.d.ts +13 -2
- package/dist/run-manifest.d.ts +5 -0
- package/dist/run-manifest.js +20 -0
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.js +5 -2
- package/dist/run-view.d.ts +17 -6
- package/dist/run-view.js +51 -22
- package/dist/runnable.d.ts +0 -3
- package/dist/runnable.js +37 -29
- package/dist/runner/adapter-loop.d.ts +24 -10
- package/dist/runner/adapter-loop.js +852 -314
- package/dist/runner/adapter-run-spec.d.ts +12 -6
- package/dist/runner/adapter-run-spec.js +97 -46
- package/dist/runner/adapters/pi-computer.d.ts +3 -1
- package/dist/runner/adapters/pi-computer.js +13 -5
- package/dist/runner/adapters/pi.d.ts +16 -7
- package/dist/runner/adapters/pi.js +94 -33
- package/dist/runner/cli-run-spec.js +67 -27
- package/dist/runner/computer-channel.js +2 -1
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +145 -4
- package/dist/runner/conformance/subject.d.ts +11 -4
- package/dist/runner/end-of-run.d.ts +6 -5
- package/dist/runner/end-of-run.js +9 -6
- package/dist/runner/feedback-round.d.ts +52 -0
- package/dist/runner/feedback-round.js +79 -0
- package/dist/runner/journal-kinds.d.ts +24 -6
- package/dist/runner/journal-kinds.js +15 -0
- package/dist/runner/learning-end.d.ts +54 -19
- package/dist/runner/learning-end.js +272 -99
- package/dist/runner/learning-loop.d.ts +19 -1
- package/dist/runner/learning-loop.js +5 -2
- 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 +16 -1
- package/dist/runner/loop.js +21 -1
- package/dist/runner/mcp-claim.d.ts +5 -1
- package/dist/runner/mcp-claim.js +66 -50
- package/dist/runner/mcp-run.d.ts +16 -52
- package/dist/runner/mcp-run.js +12 -84
- package/dist/runner/meta-tools.d.ts +37 -0
- package/dist/runner/meta-tools.js +268 -0
- package/dist/runner/metrics.js +14 -3
- package/dist/runner/model-route.js +12 -3
- package/dist/runner/monid-run.d.ts +16 -0
- package/dist/runner/monid-run.js +96 -0
- package/dist/runner/promotion.d.ts +80 -0
- package/dist/runner/promotion.js +562 -0
- package/dist/runner/reflect-hook.d.ts +36 -21
- package/dist/runner/reflect-hook.js +138 -49
- package/dist/runner/runner.js +26 -4
- package/dist/runner/sessions.d.ts +8 -3
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +7 -12
- package/dist/runner/workflow-first.d.ts +216 -0
- package/dist/runner/workflow-first.js +303 -0
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +1 -0
- package/dist/runner/workflow-spec.js +7 -3
- package/dist/runs-over-store.d.ts +11 -2
- package/dist/runs-over-store.js +21 -11
- package/dist/server.d.ts +88 -16
- package/dist/server.js +380 -87
- package/dist/settings-wake.d.ts +8 -6
- package/dist/settings-wake.js +13 -7
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/command-wake.d.ts +3 -2
- package/dist/store/command-wake.js +4 -4
- 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/schema.d.ts +9 -0
- package/dist/store/schema.js +28 -8
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.js +19 -7
- package/dist/store/sqlite/store.js +59 -18
- package/dist/store/store.d.ts +46 -14
- package/dist/store-reads/journal.d.ts +25 -1
- package/dist/store-reads/journal.js +63 -49
- package/dist/store-reads/learning.d.ts +101 -15
- package/dist/store-reads/learning.js +195 -61
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-view.d.ts +3 -2
- package/dist/store-view.js +35 -17
- package/dist/template-eval.d.ts +18 -9
- package/dist/template-eval.js +91 -66
- 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 +218 -46
- package/dist/templates.js +493 -181
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +4 -3
- package/dist/timeline/index.js +4 -3
- package/dist/timeline/labels.d.ts +6 -2
- package/dist/timeline/labels.js +93 -2
- package/dist/timeline/origin.d.ts +19 -5
- package/dist/timeline/origin.js +11 -4
- package/dist/timeline/timeline.d.ts +11 -17
- package/dist/timeline/timeline.js +24 -9
- package/dist/tool-gate.d.ts +73 -46
- package/dist/tool-gate.js +133 -66
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +26 -0
- package/dist/tool-list.js +43 -0
- package/dist/tool-names.d.ts +71 -0
- package/dist/tool-names.js +99 -0
- package/dist/tool-plane.d.ts +29 -27
- package/dist/tool-plane.js +65 -37
- package/dist/tools.d.ts +22 -6
- package/dist/tools.js +24 -20
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +91 -44
- package/dist/web-fetch.d.ts +1 -7
- package/dist/web-fetch.js +2 -22
- package/dist/workspace/computer-deps.d.ts +3 -0
- package/dist/workspace/computer-deps.js +5 -2
- package/dist/workspace/computer-for-claim.d.ts +6 -0
- package/dist/workspace/computer-for-claim.js +32 -14
- package/dist/workspace/computer-hold.js +7 -1
- package/dist/workspace/computer-script.d.ts +23 -7
- package/dist/workspace/computer-script.js +48 -14
- package/dist/workspace/index.d.ts +2 -2
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +13 -0
- package/dist/workspace/kind-skills/phone/SKILL.md +4 -0
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +21 -1
- package/dist/workspace/resolve-computer.js +32 -14
- package/dist/workspace/run-tools.d.ts +28 -10
- package/dist/workspace/run-tools.js +39 -11
- package/dist/{tool-budget.d.ts → wrap-up.d.ts} +1 -18
- package/dist/wrap-up.js +21 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +9 -9
- package/templates/README.md +111 -45
- package/templates/code-review/agent.md +30 -14
- 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 +2 -2
- 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/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/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 +3 -2
- package/templates/code-review/skills/review/REVIEWER.md +3 -2
- package/templates/code-review/skills/review/SKILL.md +4 -3
- 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 +4 -3
- 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 +4 -3
- 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/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.js +0 -62
- 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/settings-wake.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { Store } from "./store/index.js";
|
|
2
2
|
import type { ToolSettingsMap, ToolSettingsRead } from "./tool-plane.js";
|
|
3
|
-
/** The store slice a wake reads and writes: the parked runs, their pinned revisions and journals, and the wake
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
*
|
|
3
|
+
/** The store slice a wake reads and writes: the parked runs, their pinned revisions, MCP pins and journals, and the wake
|
|
4
|
+
* itself. */
|
|
5
|
+
export type WakeStore = Pick<Store, "runs" | "agents" | "readJournal" | "mcp">;
|
|
6
|
+
/** Whether a save changed any tool key's permission (added, removed or changed), or an MCP server's Allow reads
|
|
7
|
+
* (`allow_reads` on its wildcard, which lifts a read-only tool's ask). It does not predict which edit flips a call's
|
|
8
|
+
* answer (an exact `ask` under a wildcard `deny` flips when only the wildcard moves): it only skips a save that touches
|
|
9
|
+
* neither (a provider alone, a pin). The per-run decision is permissionFrom's. Approvals live on the run's revision, not
|
|
10
|
+
* in the server's settings, so a save cannot change them. */
|
|
9
11
|
export declare function permissionsChanged(before: ToolSettingsMap, after: ToolSettingsMap): boolean;
|
|
10
12
|
/**
|
|
11
13
|
* Wakes every parked run with a call waiting on its person whose tool reads allow now on the run's pinned revision: its
|
package/dist/settings-wake.js
CHANGED
|
@@ -7,14 +7,16 @@ import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
|
7
7
|
import { approvalsOf } from "./approvals.js";
|
|
8
8
|
import { answersOf, asksOf } from "./run-view.js";
|
|
9
9
|
import { journalEntries } from "./runner/journal-reader.js";
|
|
10
|
-
import { permissionFrom, SHELL_FAMILY } from "./tool-gate.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
import { permissionFrom, pinnedEffect, SHELL_FAMILY } from "./tool-gate.js";
|
|
11
|
+
import { isMcpName } from "./tool-names.js";
|
|
12
|
+
/** Whether a save changed any tool key's permission (added, removed or changed), or an MCP server's Allow reads
|
|
13
|
+
* (`allow_reads` on its wildcard, which lifts a read-only tool's ask). It does not predict which edit flips a call's
|
|
14
|
+
* answer (an exact `ask` under a wildcard `deny` flips when only the wildcard moves): it only skips a save that touches
|
|
15
|
+
* neither (a provider alone, a pin). The per-run decision is permissionFrom's. Approvals live on the run's revision, not
|
|
16
|
+
* in the server's settings, so a save cannot change them. */
|
|
15
17
|
export function permissionsChanged(before, after) {
|
|
16
18
|
for (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {
|
|
17
|
-
if (before[key]?.permission !== after[key]?.permission)
|
|
19
|
+
if (before[key]?.permission !== after[key]?.permission || before[key]?.allow_reads !== after[key]?.allow_reads)
|
|
18
20
|
return true;
|
|
19
21
|
}
|
|
20
22
|
return false;
|
|
@@ -48,8 +50,12 @@ export async function wakeAnsweredBySetting(store, read, before) {
|
|
|
48
50
|
const revision = await store.agents.revision(run.revisionId);
|
|
49
51
|
const body = (revision?.body ?? {});
|
|
50
52
|
const agent = (body.toolSettings ?? {});
|
|
53
|
+
// An MCP call's effect as the run's pin holds it (the gate's ClaimMcp.effectOf reads the same), so Allow reads lifts a
|
|
54
|
+
// read here as the claim's gate will: read once, only for a run with an MCP call waiting.
|
|
55
|
+
const pin = waiting.some(isMcpName) ? (await store.mcp.pin(run.id))?.body : undefined;
|
|
56
|
+
const effectOf = (tool) => (pin ? pinnedEffect(pin, tool) : undefined);
|
|
51
57
|
const allowed = waiting.some((tool) => {
|
|
52
|
-
const { permission, from } = permissionFrom(tool, server, agent, approvalsOf(body.approvals));
|
|
58
|
+
const { permission, from } = permissionFrom(tool, server, agent, approvalsOf(body.approvals), {}, effectOf(tool));
|
|
53
59
|
return permission === "allow" && !(from === "default" && Object.hasOwn(SHELL_FAMILY, tool));
|
|
54
60
|
});
|
|
55
61
|
if (allowed && (await store.runs.wake(run.id)))
|
|
@@ -28,7 +28,8 @@ export type RevisionPlace = {
|
|
|
28
28
|
};
|
|
29
29
|
/** A revision's computer (computer-setting.ts): its kind and the provider that serves it, ids its host knows, and a
|
|
30
30
|
* sandbox's GPUs, a type its provider names and how many; `place` is its v2 view. `image`: one the provider offers for
|
|
31
|
-
* the kind, absent for its default.
|
|
31
|
+
* the kind, absent for its default. A desktop's or a phone's surface and exec: how the agent drives it, and whether it
|
|
32
|
+
* may run programs on it. */
|
|
32
33
|
export type RevisionComputer = {
|
|
33
34
|
kind: string;
|
|
34
35
|
provider?: string;
|
|
@@ -38,6 +39,8 @@ export type RevisionComputer = {
|
|
|
38
39
|
count: number;
|
|
39
40
|
};
|
|
40
41
|
persistent?: boolean;
|
|
42
|
+
surface?: "code" | "tools";
|
|
43
|
+
exec?: boolean;
|
|
41
44
|
};
|
|
42
45
|
/** A revision's tool settings as its body keeps them: a map of a tool's key to its settings ({provider?, permission?,
|
|
43
46
|
* pin?}), checked and made canonical by the caller (agents-store.ts, through tool-plane's settingsIssues +
|
|
@@ -45,6 +48,13 @@ export type RevisionComputer = {
|
|
|
45
48
|
export type ToolSettings = Record<string, unknown>;
|
|
46
49
|
/** The model of each tier an agentic revision names (its definition's `model_tiers`: fast, strong), each "provider/model-id". */
|
|
47
50
|
export type ModelTiers = Partial<Record<"fast" | "strong", string>>;
|
|
51
|
+
/** A revision's monid pin (monid.ts MonidPin): each granted endpoint by its catalog name, as monid listed it at the save.
|
|
52
|
+
* Stamped by the save's check (server.ts saveable), never read from a definition nor shown in one. */
|
|
53
|
+
export type MonidPinBody = Readonly<Record<string, {
|
|
54
|
+
readonly description: string;
|
|
55
|
+
readonly input: Record<string, unknown>;
|
|
56
|
+
readonly usd: number;
|
|
57
|
+
}>>;
|
|
48
58
|
export type AgenticBody = {
|
|
49
59
|
instructions: string;
|
|
50
60
|
skills: Record<string, string>;
|
|
@@ -61,9 +71,10 @@ export type AgenticBody = {
|
|
|
61
71
|
maxCostUsd?: number;
|
|
62
72
|
capMode?: string;
|
|
63
73
|
approvals?: "ask" | "never";
|
|
74
|
+
inputSchema?: Record<string, unknown>;
|
|
64
75
|
outputSchema?: Record<string, unknown>;
|
|
65
|
-
maxToolCalls?: number;
|
|
66
76
|
checkout?: "pull_request";
|
|
77
|
+
monidPin?: MonidPinBody;
|
|
67
78
|
};
|
|
68
79
|
export type WorkflowBody = {
|
|
69
80
|
workflow: Record<string, unknown>;
|
|
@@ -96,8 +107,8 @@ export type RevisionBodyInput = {
|
|
|
96
107
|
maxCostUsd?: number;
|
|
97
108
|
capMode?: string;
|
|
98
109
|
approvals?: "ask" | "never";
|
|
110
|
+
inputSchema?: Record<string, unknown>;
|
|
99
111
|
outputSchema?: Record<string, unknown>;
|
|
100
|
-
maxToolCalls?: number;
|
|
101
112
|
checkout?: "pull_request";
|
|
102
113
|
} | {
|
|
103
114
|
kind: "workflow";
|
package/dist/store/agent-body.js
CHANGED
|
@@ -44,21 +44,25 @@ function placeOf(place) {
|
|
|
44
44
|
}
|
|
45
45
|
/** A GPU type as a body keeps it: the vendor's own name ("T4", "A100-80GB", "RTX-PRO-6000"). */
|
|
46
46
|
const GPU_TYPE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
/** The keys a body's computer keeps. */
|
|
48
|
+
const COMPUTER_KEYS = new Set(["kind", "provider", "image", "gpu", "persistent", "surface", "exec"]);
|
|
49
|
+
/** A computer as a body keeps it: `{kind, provider?, image?, gpu?, persistent?, surface?, exec?}`, nothing else: kind
|
|
50
|
+
* and provider ids, image a name with no spaces around it, gpu `{type, count}`, a GPU type name and a whole count from
|
|
51
|
+
* 1, persistent and exec booleans, and surface code or tools. */
|
|
50
52
|
function computerOf(computer) {
|
|
51
53
|
const image = isObject(computer) ? computer.image : undefined;
|
|
52
54
|
const named = (value) => typeof value === "string" && value !== "" && value === value.trim();
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const flag = (value) => value === undefined || typeof value === "boolean";
|
|
56
|
+
const surface = isObject(computer) ? computer.surface : undefined;
|
|
57
|
+
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)))
|
|
58
|
+
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
59
|
const ok = computer;
|
|
56
60
|
const gpu = ok.gpu;
|
|
57
61
|
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
62
|
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
63
|
}
|
|
60
64
|
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 } : {}) };
|
|
65
|
+
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
66
|
}
|
|
63
67
|
/** The body of a new revision and the text of each skill it names (path to text), everything checked here, before any
|
|
64
68
|
* write. The body keeps each skill path to its text's SHA-256; `skills` is the texts, for the revision's row. */
|
|
@@ -112,14 +116,14 @@ export function bodyOf(input) {
|
|
|
112
116
|
invalid(`the ${field} is not a non-empty string`);
|
|
113
117
|
if (input.learning !== undefined && typeof input.learning !== "boolean" && input.learning !== "notes")
|
|
114
118
|
invalid("learning is not true, false or \"notes\"");
|
|
119
|
+
if (input.inputSchema !== undefined && !isObject(input.inputSchema))
|
|
120
|
+
invalid("the inputSchema is not a JSON object");
|
|
115
121
|
if (input.outputSchema !== undefined && !isObject(input.outputSchema))
|
|
116
122
|
invalid("the outputSchema is not a JSON object");
|
|
117
123
|
if (input.checkout !== undefined && input.checkout !== "pull_request")
|
|
118
124
|
invalid("the checkout is not pull_request");
|
|
119
125
|
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
126
|
invalid("the modelTiers are not fast and strong to a non-empty model");
|
|
121
|
-
if (input.maxToolCalls !== undefined && !(Number.isSafeInteger(input.maxToolCalls) && input.maxToolCalls > 0))
|
|
122
|
-
invalid("the maxToolCalls is not a whole number above 0");
|
|
123
127
|
const body = {
|
|
124
128
|
instructions: input.instructions,
|
|
125
129
|
skills: skillShas,
|
|
@@ -130,12 +134,12 @@ export function bodyOf(input) {
|
|
|
130
134
|
...(input.prompts !== undefined ? { prompts: structuredClone(input.prompts) } : {}),
|
|
131
135
|
...host,
|
|
132
136
|
...(input.learning !== undefined ? { learning: input.learning } : {}),
|
|
137
|
+
// The JSON Schema each run's input meets (definition.input_schema), checked at every start (validate.ts inputSchemaOf).
|
|
138
|
+
...(input.inputSchema !== undefined ? { inputSchema: structuredClone(input.inputSchema) } : {}),
|
|
133
139
|
// The JSON Schema its final answer's structured part meets (definition.output_schema): a completed run's result.output.
|
|
134
140
|
...(input.outputSchema !== undefined ? { outputSchema: structuredClone(input.outputSchema) } : {}),
|
|
135
141
|
// What the server checks out in each run's folder before its first turn (runner/pr-checkout.ts).
|
|
136
142
|
...(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
143
|
// The agent's unattended policy (PR #2003): the runner's gate reads it from the revision body at claim (`unattended`
|
|
140
144
|
// below: "never" alone is kept).
|
|
141
145
|
...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) {
|
|
@@ -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;
|
package/dist/store/schema.d.ts
CHANGED
|
@@ -6,6 +6,15 @@ export declare const SCHEMA_VERSION = 11;
|
|
|
6
6
|
* the person can answer again. */
|
|
7
7
|
export declare const ONE_ANSWER_INDEX = "commands_one_answer";
|
|
8
8
|
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";
|
|
9
|
+
/** 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
|
|
10
|
+
* server open to a store an earlier build of this version made (one that pinned each run in mcp_pins, dropped at that open). */
|
|
11
|
+
export declare const REVISIONS_MCP_PIN: string;
|
|
12
|
+
/** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
|
|
13
|
+
* source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
|
|
14
|
+
* (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
|
|
15
|
+
* as it loads them at its start (templates.ts readPackage); nothing in them runs. In STORE_DDL, and added at a server
|
|
16
|
+
* open to a store an earlier build of this version made. */
|
|
17
|
+
export declare const IMPORTED_TEMPLATES: string;
|
|
9
18
|
export declare const STORE_DDL: readonly string[];
|
|
10
19
|
/** pi-durable's journal tables (its SqliteStorage schema, version 2, the `sleeping` task status included; MIT, see NOTICE),
|
|
11
20
|
* 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,12 @@
|
|
|
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
|
+
// The template packages imported from GitHub (imported_templates) are a table of their own that nothing
|
|
15
|
+
// else reads, so it needs no version: the server adds it at its open to a store an earlier build of this version made
|
|
16
|
+
// (IMPORTED_TEMPLATES), as it does the one-answer index.
|
|
12
17
|
// Conventions: every time is INTEGER epoch milliseconds; JSON is TEXT checked by json_valid; money is REAL US dollars;
|
|
13
18
|
// sealed columns hold ciphertext only (sealed with the server's key outside the store), so the store never sees a secret
|
|
14
19
|
// in the clear. Foreign keys are on (the connection's pragma).
|
|
@@ -16,7 +21,7 @@
|
|
|
16
21
|
// STORE_DDL is the control plane and the runs: agents and revisions (with a template's package), runs (state, the claim's
|
|
17
22
|
// epoch, runner, claimed_until and wake_at, cost, metrics, summary), commands, idempotency, triggers (their scopes,
|
|
18
23
|
// 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,
|
|
24
|
+
// learning state, the MCP registry, pending MCP sign-ins, and the computer ledger. PI_DDL is pi-durable's
|
|
20
25
|
// journal tables, keyed by run_id (store/journal): one schema for every run's journal, so a query joins runs and their
|
|
21
26
|
// journals.
|
|
22
27
|
export const SCHEMA_VERSION = 11;
|
|
@@ -28,6 +33,22 @@ export const SCHEMA_VERSION = 11;
|
|
|
28
33
|
export const ONE_ANSWER_INDEX = "commands_one_answer";
|
|
29
34
|
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
35
|
const json = (column, nullable = false) => `${column} TEXT${nullable ? "" : " NOT NULL"} CHECK (${column} IS NULL OR json_valid(${column}))`;
|
|
36
|
+
/** 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
|
|
37
|
+
* server open to a store an earlier build of this version made (one that pinned each run in mcp_pins, dropped at that open). */
|
|
38
|
+
export const REVISIONS_MCP_PIN = `ALTER TABLE revisions ADD COLUMN ${json("mcp_pin", true)}`;
|
|
39
|
+
/** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
|
|
40
|
+
* source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
|
|
41
|
+
* (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
|
|
42
|
+
* as it loads them at its start (templates.ts readPackage); nothing in them runs. In STORE_DDL, and added at a server
|
|
43
|
+
* open to a store an earlier build of this version made. */
|
|
44
|
+
export const IMPORTED_TEMPLATES = `CREATE TABLE IF NOT EXISTS imported_templates (
|
|
45
|
+
id TEXT PRIMARY KEY,
|
|
46
|
+
source TEXT NOT NULL,
|
|
47
|
+
sha TEXT NOT NULL,
|
|
48
|
+
publisher TEXT NOT NULL,
|
|
49
|
+
${json("files")},
|
|
50
|
+
imported_at INTEGER NOT NULL
|
|
51
|
+
) STRICT`;
|
|
31
52
|
export const STORE_DDL = [
|
|
32
53
|
`CREATE TABLE IF NOT EXISTS store_meta (
|
|
33
54
|
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
@@ -56,6 +77,8 @@ export const STORE_DDL = [
|
|
|
56
77
|
// read and copied whole with its files. Null is none (a revision with no skills).
|
|
57
78
|
// `parent_id`: the revision that was the agent's current one when this revision was committed (null for its first), kept
|
|
58
79
|
// for the v2 revisions view. `note`: the optional note a revision was committed with (the v2 note), null for none.
|
|
80
|
+
// `mcp_pin`: the MCP tools the revision grants, as their servers listed them when it was saved (mcp-gateway.ts McpPin:
|
|
81
|
+
// per server its URL then, the granted tools, their prices), which every run of it calls; null when it grants none.
|
|
59
82
|
`CREATE TABLE IF NOT EXISTS revisions (
|
|
60
83
|
id TEXT PRIMARY KEY,
|
|
61
84
|
agent_id TEXT NOT NULL REFERENCES agents (id),
|
|
@@ -66,7 +89,8 @@ export const STORE_DDL = [
|
|
|
66
89
|
${json("package", true)},
|
|
67
90
|
note TEXT,
|
|
68
91
|
external_version TEXT,
|
|
69
|
-
created_at INTEGER NOT NULL
|
|
92
|
+
created_at INTEGER NOT NULL,
|
|
93
|
+
${json("mcp_pin", true)}
|
|
70
94
|
) STRICT`,
|
|
71
95
|
`CREATE INDEX IF NOT EXISTS revisions_by_agent ON revisions (agent_id, created_at)`,
|
|
72
96
|
// `external_version`: for a revision of an externally owned agent, the version it maps there (one revision per version),
|
|
@@ -341,6 +365,7 @@ export const STORE_DDL = [
|
|
|
341
365
|
updated_at INTEGER NOT NULL,
|
|
342
366
|
PRIMARY KEY (agent_id, key)
|
|
343
367
|
) STRICT`,
|
|
368
|
+
IMPORTED_TEMPLATES,
|
|
344
369
|
// 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
370
|
// pointer (the vendor's context or profile id) sealed with the store's one rule (store/seal.ts, AAD
|
|
346
371
|
// sign_ins|<agent>:<provider>|pointer), which the store never opens. The owner sees its name ("default") and saved_at,
|
|
@@ -409,11 +434,6 @@ export const STORE_DDL = [
|
|
|
409
434
|
-- The sign-in's non-secret working state the callback rebuilds (url, was, scope, kind, discovery, resource): no secret.
|
|
410
435
|
${json("working", true)},
|
|
411
436
|
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
437
|
) STRICT`,
|
|
418
438
|
// 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
439
|
// 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) {
|
|
@@ -94,17 +94,29 @@ export async function applyRunPatch(tx, claim, patch, also, now, dialect = SQLIT
|
|
|
94
94
|
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
95
|
break;
|
|
96
96
|
}
|
|
97
|
-
// The learning run
|
|
97
|
+
// The learning run is queued after every row of the end (below): only once its kept learning names it.
|
|
98
98
|
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
99
|
break;
|
|
106
100
|
}
|
|
107
101
|
}
|
|
102
|
+
// The learning run: queued, of the run's agent and revision, started once (the same id again adds nothing), and only
|
|
103
|
+
// when the run's kept learning names it. A kept learning is kept once (above): a follow-up's end that keeps another
|
|
104
|
+
// beside one already kept that names no learning run (dropped: nothing to grade) queues none, so no learning run is
|
|
105
|
+
// 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
|
|
106
|
+
// agent's own run (NOT_A_LEARNING_RUN reads the kept learning), and its spend would be booked on no run.
|
|
107
|
+
for (const each of also) {
|
|
108
|
+
if (each.table !== "learning_run")
|
|
109
|
+
continue;
|
|
110
|
+
const named = await tx.get("SELECT 1 AS found FROM learning_proposals WHERE run_id = ? AND learning_run_id = ?", claim.runId, each.row.id);
|
|
111
|
+
if (!named)
|
|
112
|
+
continue;
|
|
113
|
+
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);
|
|
114
|
+
// Its launch row, with it: harness "learning" (the runner's loop factory picks the learning loop by it), its input
|
|
115
|
+
// the run that learned. Written once, as the run is.
|
|
116
|
+
if (!(await tx.get("SELECT 1 AS found FROM run_launch WHERE run_id = ?", each.row.id))) {
|
|
117
|
+
await writeLaunch(tx, each.row.id, { body: learningLaunchOf(claim.runId, each.row.model, each.row.round, each.row.capUsd) }, now);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
108
120
|
return runOf(row);
|
|
109
121
|
}
|
|
110
122
|
/** 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
|