@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.
Files changed (399) hide show
  1. package/CHANGELOG.md +282 -0
  2. package/README.md +155 -92
  3. package/dist/agent-rows.d.ts +1 -1
  4. package/dist/agents-store.d.ts +35 -3
  5. package/dist/agents-store.js +39 -14
  6. package/dist/answer-json.d.ts +34 -1
  7. package/dist/answer-json.js +91 -9
  8. package/dist/api-only.d.ts +1 -1
  9. package/dist/api-only.js +2 -2
  10. package/dist/browser-cost.js +52 -93
  11. package/dist/cap.d.ts +0 -390
  12. package/dist/cap.js +4 -937
  13. package/dist/catalog.js +1 -1
  14. package/dist/composio-preset.d.ts +17 -0
  15. package/dist/composio-preset.js +43 -1
  16. package/dist/computer-calls.d.ts +36 -24
  17. package/dist/computer-calls.js +110 -27
  18. package/dist/computer-live.d.ts +5 -0
  19. package/dist/computer-live.js +12 -0
  20. package/dist/computer-setting.d.ts +15 -2
  21. package/dist/computer-setting.js +20 -4
  22. package/dist/computer-view.d.ts +3 -2
  23. package/dist/computer-view.js +5 -4
  24. package/dist/computer-viewer.js +26 -12
  25. package/dist/computers.d.ts +4 -1
  26. package/dist/computers.js +12 -6
  27. package/dist/console/assets/index-CjqQirbo.css +1 -0
  28. package/dist/console/assets/index-b6-XY5A9.js +576 -0
  29. package/dist/console/index.html +2 -2
  30. package/dist/console-links.d.ts +2 -0
  31. package/dist/console-links.js +3 -0
  32. package/dist/decisions.js +4 -0
  33. package/dist/faux-computers.js +4 -2
  34. package/dist/harness-opencode/adapter.js +7 -3
  35. package/dist/harness-opencode/facts.js +0 -2
  36. package/dist/harness-opencode/host/policy.d.ts +2 -5
  37. package/dist/harness-opencode/host/policy.js +8 -32
  38. package/dist/harness-table.d.ts +0 -2
  39. package/dist/harness-table.js +0 -2
  40. package/dist/host-tools.d.ts +1 -5
  41. package/dist/host-tools.js +7 -10
  42. package/dist/hosted-search.d.ts +0 -2
  43. package/dist/hosted-search.js +0 -21
  44. package/dist/key-words.d.ts +3 -2
  45. package/dist/key-words.js +4 -2
  46. package/dist/learn/check.d.ts +6 -1
  47. package/dist/learn/check.js +12 -4
  48. package/dist/learn/commit.d.ts +10 -0
  49. package/dist/learn/commit.js +18 -4
  50. package/dist/learn/compile.d.ts +243 -0
  51. package/dist/learn/compile.js +471 -0
  52. package/dist/learn/general.d.ts +3 -0
  53. package/dist/learn/general.js +4 -2
  54. package/dist/learn/grade.d.ts +1 -1
  55. package/dist/learn/grade.js +7 -6
  56. package/dist/learn/notes.d.ts +8 -0
  57. package/dist/learn/notes.js +18 -0
  58. package/dist/learn/promote.d.ts +253 -0
  59. package/dist/learn/promote.js +428 -0
  60. package/dist/learn/refit.d.ts +39 -0
  61. package/dist/learn/refit.js +236 -0
  62. package/dist/learn/reflect.d.ts +5 -25
  63. package/dist/learn/reflect.js +14 -131
  64. package/dist/learn/replay-calls.d.ts +63 -0
  65. package/dist/learn/replay-calls.js +158 -0
  66. package/dist/learn/skills.d.ts +17 -9
  67. package/dist/learn/skills.js +132 -42
  68. package/dist/learn/workflow-nodes.d.ts +15 -0
  69. package/dist/learn/workflow-nodes.js +44 -0
  70. package/dist/learned-nodes.d.ts +50 -2
  71. package/dist/learned-nodes.js +41 -2
  72. package/dist/learned-workflow.d.ts +19 -3
  73. package/dist/learned-workflow.js +105 -26
  74. package/dist/learning-batch.d.ts +2 -2
  75. package/dist/learning-batch.js +1 -1
  76. package/dist/learning-cost.d.ts +18 -6
  77. package/dist/learning-cost.js +15 -7
  78. package/dist/learning-routes.d.ts +14 -2
  79. package/dist/learning-routes.js +14 -3
  80. package/dist/learning-words.d.ts +7 -0
  81. package/dist/learning-words.js +7 -0
  82. package/dist/learning.d.ts +31 -6
  83. package/dist/learning.js +7 -4
  84. package/dist/llm.js +0 -3
  85. package/dist/mcp-gateway.d.ts +12 -20
  86. package/dist/mcp-gateway.js +16 -44
  87. package/dist/mcp-oauth.d.ts +5 -0
  88. package/dist/mcp-oauth.js +1 -1
  89. package/dist/mcp-pin-first.d.ts +37 -0
  90. package/dist/mcp-pin-first.js +107 -0
  91. package/dist/mcp-probe.d.ts +8 -9
  92. package/dist/mcp-probe.js +16 -33
  93. package/dist/mcp-servers-store.d.ts +89 -22
  94. package/dist/mcp-servers-store.js +131 -25
  95. package/dist/mcp-sources.d.ts +39 -0
  96. package/dist/mcp-sources.js +74 -0
  97. package/dist/mcp-store.d.ts +11 -0
  98. package/dist/mcp-store.js +16 -2
  99. package/dist/mcp-wire.d.ts +22 -0
  100. package/dist/mcp-wire.js +36 -0
  101. package/dist/mcp.js +3 -3
  102. package/dist/meta-tool-names.d.ts +1 -0
  103. package/dist/meta-tool-names.js +3 -0
  104. package/dist/model.d.ts +13 -0
  105. package/dist/model.js +46 -15
  106. package/dist/monid.d.ts +51 -25
  107. package/dist/monid.js +226 -140
  108. package/dist/openapi.js +336 -66
  109. package/dist/paid-calls.d.ts +26 -29
  110. package/dist/paid-calls.js +46 -102
  111. package/dist/propose.d.ts +7 -1
  112. package/dist/propose.js +18 -6
  113. package/dist/provider.js +9 -2
  114. package/dist/reflect-range.js +2 -1
  115. package/dist/rows.d.ts +5 -3
  116. package/dist/rows.js +15 -4
  117. package/dist/run-launch.d.ts +13 -0
  118. package/dist/run-launch.js +6 -0
  119. package/dist/run-learning-served.d.ts +13 -2
  120. package/dist/run-manifest.d.ts +5 -0
  121. package/dist/run-manifest.js +20 -0
  122. package/dist/run-secrets.js +2 -3
  123. package/dist/run-timeline-served.js +5 -2
  124. package/dist/run-view.d.ts +17 -6
  125. package/dist/run-view.js +51 -22
  126. package/dist/runnable.d.ts +0 -3
  127. package/dist/runnable.js +37 -29
  128. package/dist/runner/adapter-loop.d.ts +24 -10
  129. package/dist/runner/adapter-loop.js +852 -314
  130. package/dist/runner/adapter-run-spec.d.ts +12 -6
  131. package/dist/runner/adapter-run-spec.js +97 -46
  132. package/dist/runner/adapters/pi-computer.d.ts +3 -1
  133. package/dist/runner/adapters/pi-computer.js +13 -5
  134. package/dist/runner/adapters/pi.d.ts +16 -7
  135. package/dist/runner/adapters/pi.js +94 -33
  136. package/dist/runner/cli-run-spec.js +67 -27
  137. package/dist/runner/computer-channel.js +2 -1
  138. package/dist/runner/conformance/harness.d.ts +3 -0
  139. package/dist/runner/conformance/harness.js +145 -4
  140. package/dist/runner/conformance/subject.d.ts +11 -4
  141. package/dist/runner/end-of-run.d.ts +6 -5
  142. package/dist/runner/end-of-run.js +9 -6
  143. package/dist/runner/feedback-round.d.ts +52 -0
  144. package/dist/runner/feedback-round.js +79 -0
  145. package/dist/runner/journal-kinds.d.ts +24 -6
  146. package/dist/runner/journal-kinds.js +15 -0
  147. package/dist/runner/learning-end.d.ts +54 -19
  148. package/dist/runner/learning-end.js +272 -99
  149. package/dist/runner/learning-loop.d.ts +19 -1
  150. package/dist/runner/learning-loop.js +5 -2
  151. package/dist/runner/learning-seed.d.ts +4 -0
  152. package/dist/runner/learning-seed.js +14 -0
  153. package/dist/runner/loop-contract.d.ts +19 -3
  154. package/dist/runner/loop.d.ts +16 -1
  155. package/dist/runner/loop.js +21 -1
  156. package/dist/runner/mcp-claim.d.ts +5 -1
  157. package/dist/runner/mcp-claim.js +66 -50
  158. package/dist/runner/mcp-run.d.ts +16 -52
  159. package/dist/runner/mcp-run.js +12 -84
  160. package/dist/runner/meta-tools.d.ts +37 -0
  161. package/dist/runner/meta-tools.js +268 -0
  162. package/dist/runner/metrics.js +14 -3
  163. package/dist/runner/model-route.js +12 -3
  164. package/dist/runner/monid-run.d.ts +16 -0
  165. package/dist/runner/monid-run.js +96 -0
  166. package/dist/runner/promotion.d.ts +80 -0
  167. package/dist/runner/promotion.js +562 -0
  168. package/dist/runner/reflect-hook.d.ts +36 -21
  169. package/dist/runner/reflect-hook.js +138 -49
  170. package/dist/runner/runner.js +26 -4
  171. package/dist/runner/sessions.d.ts +8 -3
  172. package/dist/runner/sessions.js +5 -1
  173. package/dist/runner/step-guard.d.ts +62 -0
  174. package/dist/runner/step-guard.js +93 -0
  175. package/dist/runner/subagent.d.ts +0 -3
  176. package/dist/runner/subagent.js +7 -12
  177. package/dist/runner/workflow-first.d.ts +216 -0
  178. package/dist/runner/workflow-first.js +303 -0
  179. package/dist/runner/workflow-loop.js +17 -10
  180. package/dist/runner/workflow-spec.d.ts +1 -0
  181. package/dist/runner/workflow-spec.js +7 -3
  182. package/dist/runs-over-store.d.ts +11 -2
  183. package/dist/runs-over-store.js +21 -11
  184. package/dist/server.d.ts +88 -16
  185. package/dist/server.js +380 -87
  186. package/dist/settings-wake.d.ts +8 -6
  187. package/dist/settings-wake.js +13 -7
  188. package/dist/store/agent-body.d.ts +14 -3
  189. package/dist/store/agent-body.js +14 -10
  190. package/dist/store/command-wake.d.ts +3 -2
  191. package/dist/store/command-wake.js +4 -4
  192. package/dist/store/postgres/connection.js +3 -1
  193. package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
  194. package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
  195. package/dist/store/schema.d.ts +9 -0
  196. package/dist/store/schema.js +28 -8
  197. package/dist/store/sqlite/connection.d.ts +2 -2
  198. package/dist/store/sqlite/connection.js +2 -2
  199. package/dist/store/sqlite/run-patch.js +19 -7
  200. package/dist/store/sqlite/store.js +59 -18
  201. package/dist/store/store.d.ts +46 -14
  202. package/dist/store-reads/journal.d.ts +25 -1
  203. package/dist/store-reads/journal.js +63 -49
  204. package/dist/store-reads/learning.d.ts +101 -15
  205. package/dist/store-reads/learning.js +195 -61
  206. package/dist/store-reads/loop.d.ts +61 -0
  207. package/dist/store-reads/loop.js +111 -0
  208. package/dist/store-view.d.ts +3 -2
  209. package/dist/store-view.js +35 -17
  210. package/dist/template-eval.d.ts +18 -9
  211. package/dist/template-eval.js +91 -66
  212. package/dist/template-github-permissions.d.ts +2 -2
  213. package/dist/template-github-permissions.js +2 -1
  214. package/dist/template-import.d.ts +31 -0
  215. package/dist/template-import.js +121 -0
  216. package/dist/template-source.d.ts +51 -0
  217. package/dist/template-source.js +371 -0
  218. package/dist/templates.d.ts +218 -46
  219. package/dist/templates.js +493 -181
  220. package/dist/timeline/computer.d.ts +48 -0
  221. package/dist/timeline/computer.js +169 -0
  222. package/dist/timeline/index.d.ts +4 -3
  223. package/dist/timeline/index.js +4 -3
  224. package/dist/timeline/labels.d.ts +6 -2
  225. package/dist/timeline/labels.js +93 -2
  226. package/dist/timeline/origin.d.ts +19 -5
  227. package/dist/timeline/origin.js +11 -4
  228. package/dist/timeline/timeline.d.ts +11 -17
  229. package/dist/timeline/timeline.js +24 -9
  230. package/dist/tool-gate.d.ts +73 -46
  231. package/dist/tool-gate.js +133 -66
  232. package/dist/tool-keys.d.ts +4 -1
  233. package/dist/tool-keys.js +8 -3
  234. package/dist/tool-list.d.ts +26 -0
  235. package/dist/tool-list.js +43 -0
  236. package/dist/tool-names.d.ts +71 -0
  237. package/dist/tool-names.js +99 -0
  238. package/dist/tool-plane.d.ts +29 -27
  239. package/dist/tool-plane.js +65 -37
  240. package/dist/tools.d.ts +22 -6
  241. package/dist/tools.js +24 -20
  242. package/dist/validate.d.ts +15 -7
  243. package/dist/validate.js +91 -44
  244. package/dist/web-fetch.d.ts +1 -7
  245. package/dist/web-fetch.js +2 -22
  246. package/dist/workspace/computer-deps.d.ts +3 -0
  247. package/dist/workspace/computer-deps.js +5 -2
  248. package/dist/workspace/computer-for-claim.d.ts +6 -0
  249. package/dist/workspace/computer-for-claim.js +32 -14
  250. package/dist/workspace/computer-hold.js +7 -1
  251. package/dist/workspace/computer-script.d.ts +23 -7
  252. package/dist/workspace/computer-script.js +48 -14
  253. package/dist/workspace/index.d.ts +2 -2
  254. package/dist/workspace/index.js +1 -1
  255. package/dist/workspace/kind-skills/desktop/SKILL.md +13 -0
  256. package/dist/workspace/kind-skills/phone/SKILL.md +4 -0
  257. package/dist/workspace/local.js +2 -2
  258. package/dist/workspace/resolve-computer.d.ts +21 -1
  259. package/dist/workspace/resolve-computer.js +32 -14
  260. package/dist/workspace/run-tools.d.ts +28 -10
  261. package/dist/workspace/run-tools.js +39 -11
  262. package/dist/{tool-budget.d.ts → wrap-up.d.ts} +1 -18
  263. package/dist/wrap-up.js +21 -0
  264. package/launcher/agentrun-serve +4 -2
  265. package/package.json +9 -9
  266. package/templates/README.md +111 -45
  267. package/templates/code-review/agent.md +30 -14
  268. package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
  269. package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
  270. package/templates/code-review/evals/injection/case.yaml +2 -1
  271. package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
  272. package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
  273. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
  274. package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
  275. package/templates/code-review/evals/never-flag/case.yaml +2 -1
  276. package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
  277. package/templates/code-review/evals/null-name/case.yaml +2 -1
  278. package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
  279. package/templates/code-review/evals/off-by-one/case.yaml +2 -1
  280. package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
  281. package/templates/code-review/evals/other-repo/case.yaml +16 -0
  282. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
  283. package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
  284. package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
  285. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
  286. package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
  287. package/templates/code-review/evals/other-repo/prompt.md +10 -0
  288. package/templates/code-review/evals/re-review/case.yaml +2 -1
  289. package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
  290. package/templates/code-review/evals/re-review-open/case.yaml +2 -1
  291. package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
  292. package/templates/code-review/evals/repo-rule/case.yaml +2 -1
  293. package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
  294. package/templates/code-review/evals/two-defects/case.yaml +2 -1
  295. package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
  296. package/templates/code-review/rules/CODEREVIEW.md +1 -1
  297. package/templates/code-review/skills/review/DEEP.md +3 -2
  298. package/templates/code-review/skills/review/REVIEWER.md +3 -2
  299. package/templates/code-review/skills/review/SKILL.md +4 -3
  300. package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
  301. package/templates/inbound-lead/agent.md +26 -16
  302. package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
  303. package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
  304. package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
  305. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
  306. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
  307. package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
  308. package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
  309. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
  310. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
  311. package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
  312. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
  313. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
  314. package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
  315. package/templates/kyb/agent.md +15 -5
  316. package/templates/kyb/evals/adverse-media/prompt.md +2 -7
  317. package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
  318. package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
  319. package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
  320. package/templates/kyb/evals/name-collision/prompt.md +2 -6
  321. package/templates/kyb/evals/no-invention/prompt.md +2 -6
  322. package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
  323. package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
  324. package/templates/kyb/kyb.schema.json +8 -7
  325. package/templates/kyb/skills/kyb/SKILL.md +9 -6
  326. package/templates/market-monitor/agent.md +19 -12
  327. package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
  328. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
  329. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
  330. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
  331. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  332. package/templates/release-notes/agent.md +32 -10
  333. package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
  334. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
  335. package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
  336. package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
  337. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
  338. package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
  339. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
  340. package/templates/release-notes/evals/learned-style/case.yaml +2 -1
  341. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
  342. package/templates/release-notes/evals/other-repo/case.yaml +24 -0
  343. package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
  344. package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
  345. package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
  346. package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
  347. package/templates/release-notes/evals/other-repo/prompt.md +32 -0
  348. package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
  349. package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
  350. package/templates/release-notes/notes.schema.json +1 -1
  351. package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
  352. package/dist/console/assets/index-Cn6JX1uH.js +0 -563
  353. package/dist/console/assets/index-DRN62V5v.css +0 -1
  354. package/dist/tool-blurbs.d.ts +0 -4
  355. package/dist/tool-blurbs.js +0 -28
  356. package/dist/tool-budget.js +0 -62
  357. package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
  358. package/templates/code-review/evals/injection/graders/schema.md +0 -5
  359. package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
  360. package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
  361. package/templates/code-review/evals/null-name/graders/schema.md +0 -5
  362. package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
  363. package/templates/code-review/evals/re-review/graders/schema.md +0 -5
  364. package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
  365. package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
  366. package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
  367. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
  368. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
  369. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
  370. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
  371. package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
  372. package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
  373. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
  374. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
  375. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
  376. package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
  377. package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
  378. package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
  379. package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
  380. package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
  381. package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
  382. package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
  383. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
  384. package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
  385. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
  386. package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
  387. package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
  388. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
  389. package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
  390. package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
  391. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
  392. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
  393. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
  394. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
  395. package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
  396. package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
  397. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
  398. package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
  399. package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
@@ -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 itself. */
4
- export type WakeStore = Pick<Store, "runs" | "agents" | "readJournal">;
5
- /** Whether a save changed any tool key's permission (added, removed or changed). It does not predict which edit flips a
6
- * call's answer (an exact `ask` under a wildcard `deny` flips when only the wildcard moves): it only skips a save that
7
- * touches no permission at all (a provider alone, a pin). The per-run decision is permissionFrom's. Approvals live on the
8
- * run's revision, not in the server's settings, so a save cannot change them. */
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
@@ -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
- /** Whether a save changed any tool key's permission (added, removed or changed). It does not predict which edit flips a
12
- * call's answer (an exact `ask` under a wildcard `deny` flips when only the wildcard moves): it only skips a save that
13
- * touches no permission at all (a provider alone, a pin). The per-run decision is permissionFrom's. Approvals live on the
14
- * run's revision, not in the server's settings, so a save cannot change them. */
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";
@@ -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
- /** A computer as a body keeps it: `{kind, provider?, image?, gpu?, persistent?}`, nothing else: kind and provider ids,
48
- * image a name with no spaces around it, gpu `{type, count}`, a GPU type name and a whole count from 1, and persistent a
49
- * boolean. */
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
- if (!isObject(computer) || !hostId(computer.kind) || (computer.provider !== undefined && !hostId(computer.provider)) || (image !== undefined && !named(image)) || (computer.persistent !== undefined && typeof computer.persistent !== "boolean") || Object.keys(computer).some((key) => key !== "kind" && key !== "provider" && key !== "image" && key !== "gpu" && key !== "persistent"))
54
- invalid("the computer is not {kind, provider?, image?, gpu?, persistent?}, kind and provider each an id (lowercase letters, digits and dashes), image a name, persistent a boolean");
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 `where` (two
2
- // handles on the same data share one), so a write through one handle wakes the readers of the others without waiting for
3
- // their poll. It reaches handles in this process only: a row another process writes wakes nothing here, and the reader's
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
- const config = { connectionString: url, options: session, types, max: poolSize, allowExitOnIdle: true, application_name: "agentrun-store", connectionTimeoutMillis: connectMs, ...tcp };
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;
@@ -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
@@ -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, each run's MCP pin, and the computer ledger. PI_DDL is pi-durable's
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 the server's launcher
75
- * starts Node exactly so (`node --input-type=module -e '…'`), so a store opened under it would have no worker. Undefined
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 the server's launcher
89
- * starts Node exactly so (`node --input-type=module -e '…'`), so a store opened under it would have no worker. Undefined
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: queued, of the run's agent and revision, started once (the same id again adds nothing).
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