@parcha/agentrun-serve 0.1.0-beta.43 → 0.1.0-beta.45

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 (388) hide show
  1. package/CHANGELOG.md +231 -0
  2. package/README.md +580 -320
  3. package/dist/acp-package.d.ts +28 -0
  4. package/dist/acp-package.js +23 -0
  5. package/dist/adapter-facts.d.ts +8 -1
  6. package/dist/adapter-facts.js +9 -1
  7. package/dist/adapters.d.ts +5 -0
  8. package/dist/adapters.js +36 -3
  9. package/dist/agent-delete.d.ts +50 -0
  10. package/dist/agent-delete.js +125 -0
  11. package/dist/agents-store.d.ts +9 -3
  12. package/dist/agents-store.js +22 -8
  13. package/dist/agents.d.ts +5 -1
  14. package/dist/agents.js +8 -4
  15. package/dist/api-only.d.ts +8 -3
  16. package/dist/api-only.js +10 -4
  17. package/dist/archil-routes.d.ts +5 -1
  18. package/dist/archil-routes.js +57 -2
  19. package/dist/browser-wait-ended.d.ts +2 -0
  20. package/dist/browser-wait-ended.js +2 -0
  21. package/dist/calendar/ics-faux.d.ts +3 -1
  22. package/dist/calendar/ics-faux.js +12 -2
  23. package/dist/calendar/tools.js +5 -2
  24. package/dist/chatgpt-plan.js +3 -1
  25. package/dist/claude-login.d.ts +135 -0
  26. package/dist/claude-login.js +244 -0
  27. package/dist/cli.js +92 -22
  28. package/dist/composio-preset.d.ts +4 -3
  29. package/dist/composio-preset.js +81 -11
  30. package/dist/composio-triggers.d.ts +34 -2
  31. package/dist/composio-triggers.js +261 -31
  32. package/dist/computer-attach.d.ts +40 -5
  33. package/dist/computer-attach.js +130 -15
  34. package/dist/computer-keys.d.ts +3 -0
  35. package/dist/computer-keys.js +7 -1
  36. package/dist/computer-live.js +3 -2
  37. package/dist/computer-lost.d.ts +11 -0
  38. package/dist/computer-lost.js +19 -0
  39. package/dist/computer-record.d.ts +10 -2
  40. package/dist/computer-record.js +50 -18
  41. package/dist/computer-setting.d.ts +1 -0
  42. package/dist/computer-setting.js +2 -2
  43. package/dist/computers.d.ts +21 -10
  44. package/dist/computers.js +39 -28
  45. package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
  46. package/dist/console/assets/index-DaFsZuzQ.css +1 -0
  47. package/dist/console/index.html +2 -2
  48. package/dist/decisions.d.ts +1 -1
  49. package/dist/dial-relay.d.ts +29 -0
  50. package/dist/dial-relay.js +94 -0
  51. package/dist/email/tools.js +10 -5
  52. package/dist/env-proxy.d.ts +2 -0
  53. package/dist/env-proxy.js +35 -0
  54. package/dist/errors.d.ts +4 -1
  55. package/dist/errors.js +10 -4
  56. package/dist/faux-computers.d.ts +8 -2
  57. package/dist/faux-computers.js +83 -6
  58. package/dist/harness-archive.d.ts +67 -0
  59. package/dist/harness-archive.js +177 -0
  60. package/dist/harness-goose.d.ts +34 -0
  61. package/dist/harness-goose.js +87 -0
  62. package/dist/harness-install.d.ts +21 -0
  63. package/dist/harness-install.js +24 -11
  64. package/dist/harness-opencode/adapter.js +1 -1
  65. package/dist/harness-table.d.ts +59 -3
  66. package/dist/harness-table.js +119 -14
  67. package/dist/harness.d.ts +17 -1
  68. package/dist/harness.js +22 -11
  69. package/dist/host.d.ts +12 -10
  70. package/dist/host.js +19 -16
  71. package/dist/import-worker.d.ts +3 -0
  72. package/dist/import-worker.js +7 -5
  73. package/dist/import.d.ts +22 -1
  74. package/dist/import.js +141 -28
  75. package/dist/key-check.js +3 -0
  76. package/dist/learn/audit.d.ts +6 -6
  77. package/dist/learn/audit.js +3 -7
  78. package/dist/learn/check.d.ts +26 -89
  79. package/dist/learn/check.js +58 -336
  80. package/dist/learn/commit.d.ts +63 -90
  81. package/dist/learn/commit.js +124 -316
  82. package/dist/learn/compile.d.ts +53 -50
  83. package/dist/learn/compile.js +88 -103
  84. package/dist/learn/corrections.d.ts +13 -0
  85. package/dist/learn/corrections.js +23 -0
  86. package/dist/learn/delete.d.ts +17 -0
  87. package/dist/learn/delete.js +42 -0
  88. package/dist/learn/folder.d.ts +35 -47
  89. package/dist/learn/folder.js +118 -134
  90. package/dist/learn/index.d.ts +3 -5
  91. package/dist/learn/index.js +6 -9
  92. package/dist/learn/learning.sh +45 -15
  93. package/dist/learn/promote.d.ts +20 -2
  94. package/dist/learn/promote.js +17 -4
  95. package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +34 -38
  96. package/dist/learn/{skills.js → workflow-draft.js} +65 -59
  97. package/dist/learn/workflow-nodes.d.ts +22 -1
  98. package/dist/learn/workflow-nodes.js +29 -10
  99. package/dist/learned-workflow.js +2 -2
  100. package/dist/learning-cost.d.ts +127 -13
  101. package/dist/learning-cost.js +142 -10
  102. package/dist/learning-routes.d.ts +99 -170
  103. package/dist/learning-routes.js +199 -420
  104. package/dist/learning-run.d.ts +19 -40
  105. package/dist/learning-run.js +23 -93
  106. package/dist/learning-setting.d.ts +4 -4
  107. package/dist/learning-setting.js +6 -6
  108. package/dist/learning-words.d.ts +28 -74
  109. package/dist/learning-words.js +64 -162
  110. package/dist/learning.d.ts +62 -393
  111. package/dist/learning.js +101 -651
  112. package/dist/listen-first.d.ts +30 -0
  113. package/dist/listen-first.js +115 -0
  114. package/dist/live-reach.d.ts +25 -2
  115. package/dist/live-reach.js +46 -4
  116. package/dist/llms.txt +2 -1
  117. package/dist/local-models.d.ts +3 -11
  118. package/dist/local-models.js +5 -6
  119. package/dist/mcp-servers-store.d.ts +16 -16
  120. package/dist/model-form.js +6 -5
  121. package/dist/model.d.ts +12 -4
  122. package/dist/model.js +41 -16
  123. package/dist/native/binding.js +1 -1
  124. package/dist/native/connection.js +1 -1
  125. package/dist/native/discovery.js +1 -1
  126. package/dist/native/instructions.d.ts +3 -0
  127. package/dist/native/instructions.js +5 -3
  128. package/dist/native/remote-worker-bridge.js +9 -43
  129. package/dist/native/remote.d.ts +8 -15
  130. package/dist/native/remote.js +3 -3
  131. package/dist/native/schema.js +1 -1
  132. package/dist/native/types.d.ts +2 -2
  133. package/dist/openapi.js +375 -347
  134. package/dist/owner.d.ts +8 -0
  135. package/dist/owner.js +11 -0
  136. package/dist/paid-calls.d.ts +14 -0
  137. package/dist/paid-calls.js +31 -1
  138. package/dist/particle-provider.d.ts +11 -0
  139. package/dist/particle-provider.js +135 -0
  140. package/dist/place.d.ts +8 -3
  141. package/dist/place.js +13 -9
  142. package/dist/port-models.d.ts +12 -4
  143. package/dist/port-models.js +28 -11
  144. package/dist/print.d.ts +27 -0
  145. package/dist/print.js +21 -0
  146. package/dist/provider.d.ts +7 -0
  147. package/dist/provider.js +30 -2
  148. package/dist/reflect-range.js +2 -3
  149. package/dist/run-launch.d.ts +14 -28
  150. package/dist/run-launch.js +9 -12
  151. package/dist/run-learning-served.d.ts +16 -90
  152. package/dist/run-listing.d.ts +34 -0
  153. package/dist/run-listing.js +128 -0
  154. package/dist/run-model-key.d.ts +64 -0
  155. package/dist/run-model-key.js +147 -0
  156. package/dist/run-timeline-served.js +5 -3
  157. package/dist/run-trace.d.ts +97 -0
  158. package/dist/run-trace.js +253 -0
  159. package/dist/run-view.d.ts +15 -0
  160. package/dist/run-view.js +9 -0
  161. package/dist/runnable.js +2 -1
  162. package/dist/runner/adapter-loop.d.ts +14 -6
  163. package/dist/runner/adapter-loop.js +25 -14
  164. package/dist/runner/adapter-run-spec.d.ts +22 -7
  165. package/dist/runner/adapter-run-spec.js +130 -77
  166. package/dist/runner/adapters/index.d.ts +4 -2
  167. package/dist/runner/adapters/index.js +35 -4
  168. package/dist/runner/adapters/pi.d.ts +4 -12
  169. package/dist/runner/adapters/pi.js +2 -2
  170. package/dist/runner/audit.d.ts +5 -1
  171. package/dist/runner/audit.js +31 -12
  172. package/dist/runner/beside.d.ts +7 -2
  173. package/dist/runner/beside.js +41 -9
  174. package/dist/runner/claim-secrets.d.ts +66 -1
  175. package/dist/runner/claim-secrets.js +136 -3
  176. package/dist/runner/cli-run-spec.d.ts +2 -1
  177. package/dist/runner/cli-run-spec.js +82 -59
  178. package/dist/runner/commands.d.ts +3 -6
  179. package/dist/runner/conformance/harness.d.ts +6 -0
  180. package/dist/runner/conformance/harness.js +16 -5
  181. package/dist/runner/dispatch.d.ts +2 -2
  182. package/dist/runner/end-of-run.d.ts +6 -14
  183. package/dist/runner/end-of-run.js +8 -33
  184. package/dist/runner/feedback-round.d.ts +5 -4
  185. package/dist/runner/feedback-round.js +14 -10
  186. package/dist/runner/github-app.js +3 -1
  187. package/dist/runner/harness-loops.d.ts +0 -8
  188. package/dist/runner/harness-loops.js +30 -56
  189. package/dist/runner/held.d.ts +170 -0
  190. package/dist/runner/held.js +57 -0
  191. package/dist/runner/journal-kinds.d.ts +7 -3
  192. package/dist/runner/journal-kinds.js +2 -3
  193. package/dist/runner/learned-first.d.ts +40 -0
  194. package/dist/runner/learned-first.js +32 -0
  195. package/dist/runner/learning-end.d.ts +77 -66
  196. package/dist/runner/learning-end.js +250 -299
  197. package/dist/runner/learning-seed.d.ts +15 -33
  198. package/dist/runner/learning-seed.js +24 -45
  199. package/dist/runner/loop-contract.d.ts +8 -3
  200. package/dist/runner/loop-contract.js +4 -0
  201. package/dist/runner/loop.js +6 -2
  202. package/dist/runner/main.d.ts +18 -9
  203. package/dist/runner/main.js +82 -22
  204. package/dist/runner/mcp-run.d.ts +11 -0
  205. package/dist/runner/mcp-run.js +67 -0
  206. package/dist/runner/memory-claim.d.ts +14 -6
  207. package/dist/runner/memory-claim.js +18 -9
  208. package/dist/runner/model-route.d.ts +7 -4
  209. package/dist/runner/model-route.js +22 -10
  210. package/dist/runner/native-loop.d.ts +0 -7
  211. package/dist/runner/native-loop.js +9 -101
  212. package/dist/runner/promotion.d.ts +13 -6
  213. package/dist/runner/promotion.js +63 -17
  214. package/dist/runner/reflect-hook.d.ts +64 -91
  215. package/dist/runner/reflect-hook.js +112 -206
  216. package/dist/runner/run-channel.d.ts +43 -0
  217. package/dist/runner/run-channel.js +467 -0
  218. package/dist/runner/run-child-host.d.ts +169 -0
  219. package/dist/runner/run-child-host.js +1222 -0
  220. package/dist/runner/run-child.d.ts +1 -0
  221. package/dist/runner/run-child.js +254 -0
  222. package/dist/runner/run-errors.d.ts +2 -0
  223. package/dist/runner/run-errors.js +20 -0
  224. package/dist/runner/runner.js +58 -9
  225. package/dist/runner/sdk-ask.d.ts +78 -0
  226. package/dist/runner/sdk-ask.js +158 -0
  227. package/dist/runner/sdk-loop.d.ts +2 -4
  228. package/dist/runner/sdk-loop.js +29 -49
  229. package/dist/runner/store-secrets.d.ts +5 -3
  230. package/dist/runner/store-secrets.js +14 -6
  231. package/dist/runner/workflow-first.d.ts +5 -0
  232. package/dist/runner/workflow-first.js +4 -0
  233. package/dist/runner/workflow-spec.js +17 -4
  234. package/dist/runs-over-store.d.ts +21 -32
  235. package/dist/runs-over-store.js +44 -41
  236. package/dist/sdk/runs.d.ts +6 -11
  237. package/dist/sdk/runs.js +20 -41
  238. package/dist/sdk/schema.js +3 -4
  239. package/dist/sdk/workflows.d.ts +1 -1
  240. package/dist/seal-key.d.ts +5 -0
  241. package/dist/seal-key.js +7 -0
  242. package/dist/secrets.d.ts +3 -0
  243. package/dist/secrets.js +16 -3
  244. package/dist/server.d.ts +119 -83
  245. package/dist/server.js +1121 -419
  246. package/dist/sign-ins-store.d.ts +8 -0
  247. package/dist/sign-ins-store.js +36 -1
  248. package/dist/skills.js +1 -1
  249. package/dist/store/index.d.ts +3 -3
  250. package/dist/store/index.js +2 -2
  251. package/dist/store/journal/storage.js +3 -0
  252. package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
  253. package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
  254. package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
  255. package/dist/store/schema.d.ts +53 -4
  256. package/dist/store/schema.js +137 -6
  257. package/dist/store/seal.d.ts +20 -2
  258. package/dist/store/seal.js +24 -8
  259. package/dist/store/sqlite/connection.d.ts +2 -0
  260. package/dist/store/sqlite/connection.js +3 -1
  261. package/dist/store/sqlite/run-launch.d.ts +4 -1
  262. package/dist/store/sqlite/run-launch.js +12 -0
  263. package/dist/store/sqlite/run-patch.d.ts +0 -17
  264. package/dist/store/sqlite/run-patch.js +4 -33
  265. package/dist/store/sqlite/store.d.ts +3 -2
  266. package/dist/store/sqlite/store.js +360 -75
  267. package/dist/store/sqlite/worker.js +25 -0
  268. package/dist/store/store.d.ts +231 -39
  269. package/dist/store/store.js +25 -3
  270. package/dist/store-reads/analytics.js +11 -1
  271. package/dist/store-reads/learning.d.ts +131 -194
  272. package/dist/store-reads/learning.js +292 -301
  273. package/dist/store-reads/loop.d.ts +0 -1
  274. package/dist/store-reads/loop.js +1 -1
  275. package/dist/store-reads/stats.js +13 -3
  276. package/dist/store-view.d.ts +34 -2
  277. package/dist/store-view.js +108 -41
  278. package/dist/telemetry.d.ts +59 -0
  279. package/dist/telemetry.js +153 -0
  280. package/dist/template-eval.d.ts +3 -6
  281. package/dist/template-eval.js +22 -36
  282. package/dist/templates.d.ts +2 -1
  283. package/dist/templates.js +6 -3
  284. package/dist/timeline/index.d.ts +1 -1
  285. package/dist/timeline/index.js +1 -1
  286. package/dist/timeline/timeline.d.ts +5 -1
  287. package/dist/timeline/timeline.js +16 -0
  288. package/dist/tool-gate.d.ts +0 -7
  289. package/dist/tool-gate.js +1 -15
  290. package/dist/tool-keys-store.d.ts +1 -1
  291. package/dist/tool-keys.d.ts +6 -4
  292. package/dist/tool-keys.js +12 -6
  293. package/dist/tool-plane.d.ts +12 -12
  294. package/dist/tools.d.ts +13 -13
  295. package/dist/tools.js +29 -9
  296. package/dist/trigger-adapter.d.ts +3 -0
  297. package/dist/trigger-adapters.d.ts +4 -0
  298. package/dist/trigger-adapters.js +13 -0
  299. package/dist/trigger-composio.d.ts +58 -1
  300. package/dist/trigger-composio.js +160 -6
  301. package/dist/triggers.d.ts +64 -5
  302. package/dist/triggers.js +141 -17
  303. package/dist/validate.d.ts +11 -7
  304. package/dist/validate.js +9 -8
  305. package/dist/webhooks.d.ts +4 -1
  306. package/dist/webhooks.js +11 -4
  307. package/dist/workspace/agent-computer.d.ts +2 -0
  308. package/dist/workspace/agent-computer.js +2 -0
  309. package/dist/workspace/archil-claim.d.ts +7 -0
  310. package/dist/workspace/archil-claim.js +29 -0
  311. package/dist/workspace/archil.d.ts +9 -1
  312. package/dist/workspace/archil.js +165 -3
  313. package/dist/workspace/attach.d.ts +3 -1
  314. package/dist/workspace/attach.js +2 -0
  315. package/dist/workspace/attached-computers.d.ts +16 -5
  316. package/dist/workspace/attached-computers.js +25 -9
  317. package/dist/workspace/computer-deps.js +1 -1
  318. package/dist/workspace/computer-for-claim.d.ts +22 -8
  319. package/dist/workspace/computer-for-claim.js +339 -46
  320. package/dist/workspace/computer-hold.js +2 -1
  321. package/dist/workspace/computer-kept.d.ts +11 -1
  322. package/dist/workspace/computer-kept.js +24 -3
  323. package/dist/workspace/resolve-computer.d.ts +41 -21
  324. package/dist/workspace/resolve-computer.js +172 -64
  325. package/dist/workspace/revision-skills.d.ts +1 -2
  326. package/dist/workspace/revision-skills.js +3 -4
  327. package/dist/workspace/run-workspace.d.ts +1 -1
  328. package/dist/workspace/run-workspace.js +5 -0
  329. package/dist/workspace/synced-folder.d.ts +85 -0
  330. package/dist/workspace/synced-folder.js +230 -0
  331. package/dist/workspace/workspace.d.ts +4 -0
  332. package/launcher/agentrun-serve +1 -1
  333. package/package.json +10 -9
  334. package/templates/README.md +7 -7
  335. package/templates/inbound-lead/agent.md +3 -3
  336. package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
  337. package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
  338. package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
  339. package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
  340. package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
  341. package/templates/inbound-lead/lead.schema.json +6 -5
  342. package/templates/inbound-lead/rules/RUBRIC.md +4 -4
  343. package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
  344. package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
  345. package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
  346. package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
  347. package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
  348. package/templates/release-notes/evals/learned-style/case.yaml +4 -4
  349. package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
  350. package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
  351. package/templates/release-notes/evals/learned-style/prompt.md +1 -1
  352. package/dist/console/assets/index-BrcDSBD8.css +0 -1
  353. package/dist/console/assets/index-Bz6IWncl.js +0 -711
  354. package/dist/learn/grade.d.ts +0 -138
  355. package/dist/learn/grade.js +0 -682
  356. package/dist/learn/notes.d.ts +0 -81
  357. package/dist/learn/notes.js +0 -178
  358. package/dist/learn/reflect.d.ts +0 -77
  359. package/dist/learn/reflect.js +0 -228
  360. package/dist/learn/relevance.d.ts +0 -24
  361. package/dist/learn/relevance.js +0 -91
  362. package/dist/learn/seed-check.d.ts +0 -74
  363. package/dist/learn/seed-check.js +0 -103
  364. package/dist/learning-batch.d.ts +0 -291
  365. package/dist/learning-batch.js +0 -600
  366. package/dist/learning-evals.d.ts +0 -33
  367. package/dist/learning-evals.js +0 -98
  368. package/dist/native/context.d.ts +0 -6
  369. package/dist/native/context.js +0 -22
  370. package/dist/propose.d.ts +0 -52
  371. package/dist/propose.js +0 -224
  372. package/dist/runner/learning-ask.d.ts +0 -47
  373. package/dist/runner/learning-ask.js +0 -128
  374. package/dist/runner/learning-dispatch.d.ts +0 -45
  375. package/dist/runner/learning-dispatch.js +0 -99
  376. package/dist/runner/learning-factory.d.ts +0 -16
  377. package/dist/runner/learning-factory.js +0 -50
  378. package/dist/runner/learning-loop.d.ts +0 -273
  379. package/dist/runner/learning-loop.js +0 -521
  380. package/dist/usage.d.ts +0 -11
  381. package/dist/usage.js +0 -11
  382. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
  383. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
  384. package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
  385. package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
  386. package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
  387. package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
  388. package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
@@ -187,6 +187,14 @@ export declare function signInsOverStore(store: SignInsStore, sealKey: Buffer, v
187
187
  message?: string;
188
188
  }>;
189
189
  }>;
190
+ /** Every saved sign-in of a deleted agent (agent-delete.ts), once no run of it is going, forgotten here and its object
191
+ * deleted at the vendor. Each live sign-in moves to a tombstone first (forgetSignIn's hold check; one forgotten
192
+ * meanwhile is passed by), and then every tombstone of the agent's, which stays until the agent's row goes, is
193
+ * deleted at its vendor (a 404 there is gone already). So a vendor delete that failed, or a stop after the move, is
194
+ * done again by the next call. Throws `unavailable` naming each vendor that did not delete, the tombstones kept. A
195
+ * tombstone whose pointer does not open under this server's seal key is passed by: no call of this server's can
196
+ * delete its object. */
197
+ forgetAll: (agentId: string) => Promise<void>;
190
198
  peek: (agentId: string, resolution: string) => Promise<"unreadable" | {
191
199
  ref: string;
192
200
  } | undefined>;
@@ -177,7 +177,7 @@ export async function handedSignInReadsBack(store, sealKey, run) {
177
177
  if (pointer !== undefined)
178
178
  known.add(pointerHash(pointer));
179
179
  }
180
- for (const provider of ["browserbase", "kernel"]) {
180
+ for (const provider of VENDORS) {
181
181
  for (const tomb of await store.signIns.tombstones(run.agentId, provider)) {
182
182
  const pointer = open(sealKey, run.agentId, provider, tomb.pointerSealed);
183
183
  if (pointer !== undefined)
@@ -259,6 +259,8 @@ export { SignInHandedTo, SignInMissing };
259
259
  export const BROWSERBASE_SETTLE_MS = 10_000;
260
260
  /** The settle window a provider's save lease outlives its run leaving 'running' by: Browserbase's, and none for the rest. */
261
261
  const settleFor = (provider) => (provider === "browserbase" ? BROWSERBASE_SETTLE_MS : 0);
262
+ /** Every vendor a sign-in is kept at, for a walk over an agent's tombstones. */
263
+ const VENDORS = ["browserbase", "kernel"];
262
264
  /** The vendor a run's browser resolves to keeps a sign-in for: Browserbase's and Kernel's; a local Chrome is refused by
263
265
  * name; an unavailable browser has none. */
264
266
  export function vendorOf(resolution) {
@@ -358,5 +360,38 @@ export function signInsOverStore(store, sealKey, vendors) {
358
360
  view: (agentId) => signInViews(store, sealKey, agentId),
359
361
  ...signInReads(store, sealKey),
360
362
  forget: (agentId, key) => forgetSignInView(store, sealKey, vendors, agentId, key),
363
+ /** Every saved sign-in of a deleted agent (agent-delete.ts), once no run of it is going, forgotten here and its object
364
+ * deleted at the vendor. Each live sign-in moves to a tombstone first (forgetSignIn's hold check; one forgotten
365
+ * meanwhile is passed by), and then every tombstone of the agent's, which stays until the agent's row goes, is
366
+ * deleted at its vendor (a 404 there is gone already). So a vendor delete that failed, or a stop after the move, is
367
+ * done again by the next call. Throws `unavailable` naming each vendor that did not delete, the tombstones kept. A
368
+ * tombstone whose pointer does not open under this server's seal key is passed by: no call of this server's can
369
+ * delete its object. */
370
+ forgetAll: async (agentId) => {
371
+ for (const row of await store.signIns.list(agentId)) {
372
+ checkParts(agentId, row.provider);
373
+ const pointer = open(sealKey, agentId, row.provider, row.pointerSealed);
374
+ try {
375
+ await store.signIns.forget(agentId, row.provider, pointer === undefined ? { heldUnreadable: true } : { hash: pointerHash(pointer) });
376
+ }
377
+ catch (error) {
378
+ if (!(error instanceof SignInMissing))
379
+ throw error;
380
+ }
381
+ }
382
+ const failed = [];
383
+ for (const provider of VENDORS) {
384
+ for (const tomb of await store.signIns.tombstones(agentId, provider)) {
385
+ const pointer = open(sealKey, agentId, provider, tomb.pointerSealed);
386
+ if (pointer === undefined)
387
+ continue;
388
+ const error = await vendors.remove(provider, pointer).then(() => undefined, (e) => e);
389
+ if (error)
390
+ failed.push(`${provider} (${error.message})`);
391
+ }
392
+ }
393
+ if (failed.length)
394
+ throw new ApiError("unavailable", `The agent ${agentId}'s saved sign-in${failed.length === 1 ? " is" : "s are"} not deleted at ${failed.join(", ")} yet.`, { retry_after_ms: 5_000 });
395
+ },
361
396
  };
362
397
  }
package/dist/skills.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // refuse. The adapter's own check (its exported skillProblems) says which: serve takes any <name>/SKILL.md, the adapter
8
8
  // only a lowercase name, a SKILL.md whose front matter names the skill and describes it, plain file paths, and 1 MiB in
9
9
  // all.
10
- import { learnedFront } from "./learn/skills.js";
10
+ import { learnedFront } from "./learn/workflow-draft.js";
11
11
  import { skillNames } from "./validate.js";
12
12
  import { workspaceAt } from "./workspace/index.js";
13
13
  /** The most skill files read at once, so a run with many skill files stays under a low open-file limit. */
@@ -1,6 +1,6 @@
1
- export { AgentArchived, AnswerTaken, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, RunFinal, SchemaVersionUnknown, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreFromEarlierVersion, StoreLaunchMissing, StoreOwned, StoreWorkerLost, STORE_WRITE_DEADLINE_MS, stoppedByPerson, TriggerFull } from "./store.js";
2
- export type { ConstraintRule, AgentRow, Agents, AlsoRow, ChannelPost, Claim, Command, ComputerLedger, ComputerLedgerRow, Firing, FiringChange, FiringRow, FiringStatus, FiringStreak, Journal, Live, LiveRow, Mcp, McpCredentialMark, McpRemoved, McpOauth, McpOauthPendingRow, McpPinRow, McpServerRow, McpServerStamp, McpServerWrite, MintedTokenRow, MintedTokens, NewFiring, NewPairedComputer, NewRevision, NewTrigger, PairedComputerRow, PairedComputers, ReleasedState, RevisionRow, RunPatch, RunRow, Runs, RunState, SealedKeyRow, SealedKeys, SealedPlane, SealedSecretRow, SealedSecrets, SettingRow, Settings, Staged, StagedTake, Store, StoreRole, TemplatePackage, Templates, TriggerDef, TriggerPatch, TriggerRow, Triggers, TriggerScope, TriggerSettingRow, TriggerSettings, Channels, ChannelAttemptRow, ChannelPostRow, ChannelToldRow, ImportedFrom, ImportSource, ImportRunInput, JournalReads, RunLabels, RunOrigin, RunOutcome, RunLaunchInput, RunLaunchRow, Learning, LearningProposal, LiveViewerRow, LiveViewers, SignIns, SignInRow, SignInTombstoneRow, UpdatedRun, ViewerKind, } from "./store.js";
3
- export { aadOf, type McpCredential, type OpenedMcpCredential, openMcpCredential, openRunMcpAuth, type RunMcpAuth, sealColumn, type SealedAt, sealedAt, sealMcpCredential, sealRunMcpAuth, unsealColumn } from "./seal.js";
1
+ export { AgentArchived, AgentDeleting, AnswerTaken, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, RunFinal, SchemaVersionUnknown, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreFromEarlierVersion, StoreLaunchMissing, StoreOwned, StoreWorkerLost, STORE_WRITE_DEADLINE_MS, stoppedByPerson, TriggerFull, TriggersLeft } from "./store.js";
2
+ export type { ConstraintRule, AgentRow, Agents, AlsoRow, ChannelPost, Claim, Command, ComputerLedger, ComputerLedgerRow, Firing, FiringChange, FiringRow, FiringStatus, FiringStreak, Journal, Live, LiveRow, Mcp, McpCredentialMark, McpRemoved, McpOauth, McpOauthPendingRow, McpPinRow, McpServerRow, McpServerStamp, McpServerWrite, MintedTokenRow, MintedTokens, NewFiring, NewPairedComputer, NewRevision, NewTrigger, PairedComputerRow, PairedComputers, ReleasedState, RevisionRow, RunnerRelayRow, RunnerRelays, RunPatch, RunRow, Runs, RunState, SealedKeyRow, SealedKeys, SealedPlane, SealedSecretRow, SealedSecrets, SettingRow, Settings, Staged, StagedTake, Store, StoreRole, TemplatePackage, Templates, TriggerDef, TriggerPatch, TriggerRow, Triggers, TriggerScope, TriggerSettingRow, TriggerSettings, Channels, ChannelAttemptRow, ChannelPostRow, ChannelToldRow, ImportedFrom, ImportSource, ImportRunInput, JournalReads, RunLabels, RunOrigin, RunOutcome, RunLaunchInput, RunLaunchRow, LaunchSealed, LaunchSealedWrite, Learning, LearningProposal, LiveViewerRow, LiveViewers, SignIns, SignInRow, SignInTombstoneRow, UpdatedRun, ViewerKind, } from "./store.js";
3
+ export { aadOf, type McpCredential, type OpenedMcpCredential, openMcpCredential, openRunLaunch, openRunMcpAuth, type RunLaunchSecrets, type RunMcpAuth, type RunModelKey, sealColumn, type SealedAt, sealedAt, sealMcpCredential, sealRunLaunch, sealRunMcpAuth, unsealColumn } from "./seal.js";
4
4
  export { AgentBodyInvalid, type AgenticBody, bodyOf, canonical, isObject, isSkillPath, type PromptVariant, type ModelTiers, type MonidPinBody, type RevisionBodyInput, type RevisionComputer, type RevisionPlace, sha256, type ToolSettings, type WorkflowBody, } from "./agent-body.js";
5
5
  export { checkPrompts, OTHER_OPTION, PromptsInvalid } from "./prompts.js";
6
6
  export { DDL, PI_DDL, PI_TABLE, PI_TABLES, SCHEMA_VERSION, STORE_DDL } from "./schema.js";
@@ -1,6 +1,6 @@
1
1
  // The one store (design 2.1), for the cutover: nothing on main imports it until then.
2
- export { AgentArchived, AnswerTaken, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, RunFinal, SchemaVersionUnknown, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreFromEarlierVersion, StoreLaunchMissing, StoreOwned, StoreWorkerLost, STORE_WRITE_DEADLINE_MS, stoppedByPerson, TriggerFull } from "./store.js";
3
- export { aadOf, openMcpCredential, openRunMcpAuth, sealColumn, sealedAt, sealMcpCredential, sealRunMcpAuth, unsealColumn } from "./seal.js";
2
+ export { AgentArchived, AgentDeleting, AnswerTaken, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, RunFinal, SchemaVersionUnknown, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreFromEarlierVersion, StoreLaunchMissing, StoreOwned, StoreWorkerLost, STORE_WRITE_DEADLINE_MS, stoppedByPerson, TriggerFull, TriggersLeft } from "./store.js";
3
+ export { aadOf, openMcpCredential, openRunLaunch, openRunMcpAuth, sealColumn, sealedAt, sealMcpCredential, sealRunLaunch, sealRunMcpAuth, unsealColumn } from "./seal.js";
4
4
  export { AgentBodyInvalid, bodyOf, canonical, isObject, isSkillPath, sha256, } from "./agent-body.js";
5
5
  export { checkPrompts, OTHER_OPTION, PromptsInvalid } from "./prompts.js";
6
6
  export { DDL, PI_DDL, PI_TABLE, PI_TABLES, SCHEMA_VERSION, STORE_DDL } from "./schema.js";
@@ -307,6 +307,9 @@ export class RunStorage {
307
307
  }
308
308
  if (seqs.length > 0) {
309
309
  await tx.run(`INSERT INTO ${T.metadata} (run_id, next_id, next_seq) VALUES (?, ?, ?) ON CONFLICT (run_id) DO UPDATE SET next_id = excluded.next_id, next_seq = excluded.next_seq`, this.#runId, String(Math.max(Number(metadata.next_id), candidateNextId)), next);
310
+ // What the run's list shows may have moved with what this commit stored (a turn, an ask, a request's cost): its
311
+ // listing is behind from this commit on (store/schema.ts RUN_LISTING_COLUMNS), in this commit's transaction.
312
+ await tx.run("UPDATE runs SET list_mark = list_mark + 1 WHERE id = ?", this.#runId);
310
313
  // The run patch's fenced UPDATE (0 rows: Fenced), then its rows (store/sqlite/run-patch.ts, as runs.update writes
311
314
  // them), then the takes.
312
315
  const now = this.#now();
@@ -0,0 +1,83 @@
1
+ -- Version 17: each run's listing on its row (store/schema.ts RUN_LISTING_COLUMNS, as SQLite's schema version 12 keeps it):
2
+ -- what a runs list shows of the run, so a list reads rows alone and never builds a run's view. list_mark moves (+1) in the
3
+ -- transaction of every write that can change the run's view: its journal's commits (store/journal/storage.ts), its row's
4
+ -- state, claim, cost and end (runs_list_moved), its commands (commands_list_moved), its learning's rows
5
+ -- (learning_list_moved), and its learning run's or audit's own moves (runs_list_parent). The server's lister rebuilds a
6
+ -- listing from the run's view and writes it with the mark it read before it built (listing_mark), so a row whose listing is
7
+ -- behind says so. Every run starts behind; a settled run's status is set from its row here (an end that is no person's stop
8
+ -- of an agentic run). Applied once, after 0016, inside the transaction migrate.ts opens. Never edit this file once
9
+ -- applied: a change is a new file.
10
+ ALTER TABLE runs ADD COLUMN IF NOT EXISTS list_mark BIGINT NOT NULL DEFAULT 1;
11
+ ALTER TABLE runs ADD COLUMN IF NOT EXISTS listing TEXT COLLATE "C" CHECK (listing IS NULL OR listing::json IS NOT NULL);
12
+ ALTER TABLE runs ADD COLUMN IF NOT EXISTS list_status TEXT COLLATE "C";
13
+ ALTER TABLE runs ADD COLUMN IF NOT EXISTS listing_mark BIGINT NOT NULL DEFAULT 0;
14
+ ALTER TABLE runs ADD COLUMN IF NOT EXISTS listing_live BIGINT NOT NULL DEFAULT 0 CHECK (listing_live IN (0, 1));
15
+ ALTER TABLE runs ADD COLUMN IF NOT EXISTS listing_until BIGINT;
16
+ ALTER TABLE runs ADD COLUMN IF NOT EXISTS listing_flags BIGINT NOT NULL DEFAULT 0;
17
+
18
+ CREATE INDEX IF NOT EXISTS runs_listing_behind ON runs (started_at) WHERE listing_mark < list_mark;
19
+ CREATE INDEX IF NOT EXISTS runs_listing_live ON runs (started_at) WHERE listing_live = 1;
20
+ CREATE INDEX IF NOT EXISTS runs_listing_until ON runs (listing_until) WHERE listing_until IS NOT NULL;
21
+ CREATE INDEX IF NOT EXISTS runs_by_list_status ON runs (list_status, started_at);
22
+ CREATE INDEX IF NOT EXISTS runs_listing_flagged ON runs (agent_id) WHERE listing_flags <> 0;
23
+ CREATE INDEX IF NOT EXISTS learning_proposals_by_learning_run ON learning_proposals (learning_run_id) WHERE learning_run_id IS NOT NULL;
24
+
25
+ -- The run's own mark, for a change of its row a list may show (a renew, which moves only claimed_until, is none), and its
26
+ -- list_status from the row: a settled run's status, else none until its listing is built.
27
+ CREATE OR REPLACE FUNCTION run_list_moved() RETURNS trigger LANGUAGE plpgsql AS $$
28
+ BEGIN
29
+ EXECUTE format('UPDATE %I.runs SET list_mark = list_mark + 1, list_status = CASE
30
+ WHEN state = ''ended'' THEN ''completed''
31
+ WHEN state = ''failed'' THEN ''failed''
32
+ WHEN state = ''stopped'' AND (outcome IS NULL OR outcome <> ''stopped'' OR imported_from IS NOT NULL
33
+ OR (SELECT kind FROM %I.revisions WHERE revisions.id = runs.revision_id) <> ''agentic'') THEN ''cancelled''
34
+ ELSE NULL END
35
+ WHERE id = $1', TG_TABLE_SCHEMA, TG_TABLE_SCHEMA) USING NEW.id;
36
+ RETURN NULL;
37
+ END
38
+ $$;
39
+ DROP TRIGGER IF EXISTS runs_list_moved ON runs;
40
+ CREATE TRIGGER runs_list_moved AFTER UPDATE OF state, epoch, runner, cost_usd, cost_upper_bound, metrics, summary, outcome, imported_from, sign_in_handed, labels, ended_at ON runs
41
+ FOR EACH ROW EXECUTE FUNCTION run_list_moved();
42
+
43
+ -- A learning run's or an audit shadow run's move is its served run's too: that run's view reads them.
44
+ CREATE OR REPLACE FUNCTION run_list_parent() RETURNS trigger LANGUAGE plpgsql AS $$
45
+ BEGIN
46
+ IF NEW.id LIKE 'audit.%' THEN
47
+ EXECUTE format('UPDATE %I.runs SET list_mark = list_mark + 1 WHERE id = $1', TG_TABLE_SCHEMA) USING substr(NEW.id, 7);
48
+ END IF;
49
+ EXECUTE format('UPDATE %I.runs SET list_mark = list_mark + 1 WHERE id IN (SELECT run_id FROM %I.learning_proposals WHERE learning_run_id = $1)', TG_TABLE_SCHEMA, TG_TABLE_SCHEMA) USING NEW.id;
50
+ RETURN NULL;
51
+ END
52
+ $$;
53
+ DROP TRIGGER IF EXISTS runs_list_parent ON runs;
54
+ CREATE TRIGGER runs_list_parent AFTER UPDATE OF list_mark ON runs
55
+ FOR EACH ROW WHEN (pg_trigger_depth() < 3) EXECUTE FUNCTION run_list_parent();
56
+
57
+ -- A command written, taken or refused, and a learning row written or changed: its run's mark, moved at the commit of the
58
+ -- write's transaction (deferred), still inside it. The run's row is locked only for that moment: a command whose
59
+ -- transaction waits on something else (its launch row) never holds up the run's journal commits, or the run's other
60
+ -- commands, which take their ids in the order they were inserted.
61
+ CREATE OR REPLACE FUNCTION run_list_of_row() RETURNS trigger LANGUAGE plpgsql AS $$
62
+ BEGIN
63
+ EXECUTE format('UPDATE %I.runs SET list_mark = list_mark + 1 WHERE id = $1', TG_TABLE_SCHEMA) USING NEW.run_id;
64
+ RETURN NULL;
65
+ END
66
+ $$;
67
+ DROP TRIGGER IF EXISTS commands_list_moved ON commands;
68
+ CREATE CONSTRAINT TRIGGER commands_list_moved AFTER INSERT ON commands DEFERRABLE INITIALLY DEFERRED
69
+ FOR EACH ROW EXECUTE FUNCTION run_list_of_row();
70
+ DROP TRIGGER IF EXISTS commands_list_settled ON commands;
71
+ CREATE CONSTRAINT TRIGGER commands_list_settled AFTER UPDATE OF taken_at, refused ON commands DEFERRABLE INITIALLY DEFERRED
72
+ FOR EACH ROW EXECUTE FUNCTION run_list_of_row();
73
+ DROP TRIGGER IF EXISTS learning_list_moved ON learning_proposals;
74
+ CREATE CONSTRAINT TRIGGER learning_list_moved AFTER INSERT OR UPDATE ON learning_proposals DEFERRABLE INITIALLY DEFERRED
75
+ FOR EACH ROW EXECUTE FUNCTION run_list_of_row();
76
+
77
+ UPDATE runs SET list_status = CASE
78
+ WHEN state = 'ended' THEN 'completed'
79
+ WHEN state = 'failed' THEN 'failed'
80
+ WHEN state = 'stopped' AND (outcome IS NULL OR outcome <> 'stopped' OR imported_from IS NOT NULL
81
+ OR (SELECT kind FROM revisions WHERE revisions.id = runs.revision_id) <> 'agentic') THEN 'cancelled'
82
+ ELSE NULL END;
83
+ UPDATE store_meta SET schema_version = 17 WHERE singleton = 1;
@@ -0,0 +1,6 @@
1
+ -- A trigger's package mark (triggers.template_id, as store/schema.ts keeps it on SQLite: TRIGGERS_TEMPLATE_ID): the id of
2
+ -- the template package whose apply made or last kept the trigger, null for one a person made, so a trigger made before
3
+ -- reads as no package's. A template update removes only triggers marked with its own package. Applied once, after the
4
+ -- migration before it, inside the transaction migrate.ts opens. Never edit this file once applied: a change is a new file.
5
+ ALTER TABLE triggers ADD COLUMN IF NOT EXISTS template_id TEXT COLLATE "C";
6
+ UPDATE store_meta SET schema_version = 18 WHERE singleton = 1;
@@ -0,0 +1,28 @@
1
+ -- The store's schema on Postgres, version 19: a dial relayed to the runner that made its machine (dial-relay.ts), as
2
+ -- store/schema.ts keeps it on SQLite (version 13). Applied once, after 0018, inside the transaction migrate.ts opens.
3
+ -- Never edit this file once applied: a change is a new file.
4
+ --
5
+ -- minted_tokens.runner, .incarnation: the runner in a process of its own that minted the machine's token, and its
6
+ -- incarnation (its process since its start); null for a token the server's own process minted.
7
+ -- minted_tokens.run: the run the machine works for, as its create named it, which the words about its dial say; null for
8
+ -- a machine of no run.
9
+ -- minted_tokens.refused: why the server refused to relay the machine's dial, in its 503's words (never the token), which
10
+ -- the minting runner's create reads to end its wait; null while none was, and again at a mint.
11
+ -- runner_relays: one row per runner in a process of its own, where its attach listener takes the dials the server relays
12
+ -- to it (its host and port), under its incarnation, and when it last said it was there.
13
+ -- IF NOT EXISTS: applied again over a store that has them, it changes nothing.
14
+
15
+ ALTER TABLE minted_tokens ADD COLUMN IF NOT EXISTS runner TEXT COLLATE "C";
16
+ ALTER TABLE minted_tokens ADD COLUMN IF NOT EXISTS incarnation TEXT COLLATE "C";
17
+ ALTER TABLE minted_tokens ADD COLUMN IF NOT EXISTS run TEXT COLLATE "C";
18
+ ALTER TABLE minted_tokens ADD COLUMN IF NOT EXISTS refused TEXT;
19
+
20
+ CREATE TABLE IF NOT EXISTS runner_relays (
21
+ runner TEXT COLLATE "C" PRIMARY KEY,
22
+ incarnation TEXT COLLATE "C" NOT NULL,
23
+ host TEXT COLLATE "C" NOT NULL,
24
+ port INTEGER NOT NULL,
25
+ seen_at BIGINT NOT NULL
26
+ );
27
+
28
+ UPDATE store_meta SET schema_version = 19 WHERE singleton = 1;
@@ -1,4 +1,4 @@
1
- export declare const SCHEMA_VERSION = 11;
1
+ export declare const SCHEMA_VERSION = 13;
2
2
  /** One answer per approval of a run: a second approve or deny command naming the same approval is refused
3
3
  * (StoreConstraint), so the first answer a person gives wins from the moment it is written, before the runner takes it
4
4
  * (runs-over-store.ts approve). In STORE_DDL, and added at a server open to a store an earlier build of this version made. */
@@ -19,6 +19,10 @@ export declare const RUNS_COST_UPPER_BOUND = "ALTER TABLE runs ADD COLUMN cost_u
19
19
  /** A run's labels (JSON, null for none): in STORE_DDL, and added at a server open to a store an earlier build of this version
20
20
  * made, as RUNS_COST_UPPER_BOUND is (a run started before reads as given none). */
21
21
  export declare const RUNS_LABELS: string;
22
+ /** A trigger's package mark (TriggerRow.templateId): the id of the template package whose apply made or last kept it, null
23
+ * for one a person made. In STORE_DDL, and added at a server open to a store an earlier build of this version made, as
24
+ * RUNS_LABELS is (a trigger made before reads as no package's). */
25
+ export declare const TRIGGERS_TEMPLATE_ID = "ALTER TABLE triggers ADD COLUMN template_id TEXT";
22
26
  /** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
23
27
  * source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
24
28
  * (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
@@ -28,9 +32,54 @@ export declare const IMPORTED_TEMPLATES: string;
28
32
  /** A hosted machine's minted token (a dial provider's create, spec/computer/attach.md): its computerd dials the attach
29
33
  * socket and fetches the daemon with it. By the machine (its name, from its create's request id): the token's SHA-256
30
34
  * alone (hex), what the machine must say it is at hello (kind, os, arch), and when the token ends (`expires_at`, the
31
- * machine's backstop) or was revoked (its delete). A row past its end goes at the next mint. In STORE_DDL, and added at
32
- * a server open to a store an earlier build of this version made. */
33
- export declare const MINTED_TOKENS = "CREATE TABLE IF NOT EXISTS minted_tokens (\n machine TEXT PRIMARY KEY,\n token_sha256 TEXT NOT NULL UNIQUE,\n kind TEXT NOT NULL,\n os TEXT NOT NULL,\n arch TEXT NOT NULL,\n expires_at INTEGER NOT NULL,\n revoked_at INTEGER,\n created_at INTEGER NOT NULL\n ) STRICT";
35
+ * machine's backstop) or was revoked (its delete). A row past its end goes at the next mint. `runner` and `incarnation`
36
+ * (version 13): the runner in a process of its own that minted it, and its incarnation, to which the server relays the
37
+ * machine's socket (dial-relay.ts); null for the server's own process. `run` (version 13): the run the machine works for,
38
+ * as its create named it, which the words about its dial say; null for a machine of no run. `refused` (version 13): why
39
+ * the server refused to relay its dial, in its 503's words (never the token), which the minting runner's create reads to
40
+ * end its wait; null while none was, and again at a mint. In STORE_DDL, and added at a server open to a store an earlier
41
+ * build of this version made. */
42
+ export declare const MINTED_TOKENS = "CREATE TABLE IF NOT EXISTS minted_tokens (\n machine TEXT PRIMARY KEY,\n token_sha256 TEXT NOT NULL UNIQUE,\n kind TEXT NOT NULL,\n os TEXT NOT NULL,\n arch TEXT NOT NULL,\n expires_at INTEGER NOT NULL,\n revoked_at INTEGER,\n created_at INTEGER NOT NULL,\n runner TEXT,\n incarnation TEXT,\n run TEXT,\n refused TEXT\n ) STRICT";
43
+ /** Where each runner in a process of its own takes the dials the server relays to it (version 13, dial-relay.ts): its
44
+ * attach listener's host and port under its name, with its incarnation and when it last said it was there. */
45
+ export declare const RUNNER_RELAYS = "CREATE TABLE IF NOT EXISTS runner_relays (\n runner TEXT PRIMARY KEY,\n incarnation TEXT NOT NULL,\n host TEXT NOT NULL,\n port INTEGER NOT NULL,\n seen_at INTEGER NOT NULL\n ) STRICT";
46
+ /** Version 12 → 13 on SQLite (the server's open, sqlite/store.ts), given minted_tokens' columns now: the minting runner,
47
+ * its incarnation, the machine's run and a refused relay's words on each token's row (none of the rows there has one: the
48
+ * server's own process minted them, naming no run), the runners' relays, and the version, in one durable write. */
49
+ export declare function relayUpgrade(mintedColumns: ReadonlySet<string>): readonly string[];
50
+ /** A run's listing on its row (version 12): what a runs list shows of the run, so a list reads rows alone and never builds
51
+ * a run's view. `list_mark` moves (+1) in the transaction of every write that can change what the run's view shows: its
52
+ * journal's commits (store/journal/storage.ts), its row's state, claim, cost and end (runs_list_moved), its commands
53
+ * (commands_list_moved), its learning's rows (learning_list_moved), and its learning run's or audit's own moves
54
+ * (runs_list_parent). The server rebuilds a listing from the run's view (store-view.ts listingOverStore, run-listing.ts)
55
+ * and writes it with the mark it read before it built (`listing_mark`), only while list_mark is still that mark: a write
56
+ * that lands meanwhile keeps the row as it left it (its list_status too), behind (listing_mark < list_mark), and it is
57
+ * built again: a crash between a write and its listing leaves a row that says
58
+ * it is behind, never one that says it is current. `listing` is the list item without the parts read when it is listed
59
+ * (console_url, archived_at); `list_status` its status, which a status filter reads in SQL; `listing_live` whether a runner
60
+ * held the run when it was built (its status reads otherwise once that claim runs out); `listing_until` when it goes stale
61
+ * by the clock alone (an ask that expires, or the retry of a build that withheld the run for a sign-in it could not read
62
+ * back); `listing_flags` what outside the run it read (LISTING_HELD: learning held for
63
+ * its owner's OK on its agent's folder; LISTING_KEYED: a failed run's error words, which read the server's keys). */
64
+ export declare const RUN_LISTING_COLUMNS: readonly ["list_mark INTEGER NOT NULL DEFAULT 1", string, "list_status TEXT", "listing_mark INTEGER NOT NULL DEFAULT 0", "listing_live INTEGER NOT NULL DEFAULT 0 CHECK (listing_live IN (0, 1))", "listing_until INTEGER", "listing_flags INTEGER NOT NULL DEFAULT 0"];
65
+ /** listing_flags: the run's learning holds items for its owner's OK, read as they stand on its agent's folder now. */
66
+ export declare const LISTING_HELD = 1;
67
+ /** listing_flags: a failed run's error words, which name a refused key by the server's keys and settings. */
68
+ export declare const LISTING_KEYED = 2;
69
+ /** A run's status from its row alone, where its row says it (an end that is no person's stop of an agentic run): the status
70
+ * its view reads (store-view.ts STATUS_OF), in SQL. Null for any other run, whose listing says it once it is built. */
71
+ export declare const SETTLED_LIST_STATUS = "CASE\n WHEN state = 'ended' THEN 'completed'\n WHEN state = 'failed' THEN 'failed'\n WHEN state = 'stopped' AND (outcome IS NULL OR outcome <> 'stopped' OR imported_from IS NOT NULL\n OR (SELECT kind FROM revisions WHERE revisions.id = runs.revision_id) <> 'agentic') THEN 'cancelled'\n ELSE NULL END";
72
+ /** The listing's indexes and triggers (RUN_LISTING_COLUMNS), after every table they name. A write to a run's row moves its
73
+ * mark and sets its list_status from the row (SETTLED_LIST_STATUS: a settled run's status, else none until its listing
74
+ * is built), so a status filter never reads a status the row has left. The parent trigger moves the mark of the run a
75
+ * learning run grades (learning_proposals.learning_run_id) or an audit's shadow run audits (its id after "audit.",
76
+ * learn/audit.ts shadowRunId), since each run's view reads those. */
77
+ export declare const RUN_LISTING_DDL: readonly string[];
78
+ /** Version 11 → 12 on SQLite (the server's open, sqlite/store.ts), given the runs table's columns now: the listing's columns
79
+ * it lacks, its indexes and triggers, every settled run's status from its row (SETTLED_LIST_STATUS), and the version, in
80
+ * one durable write. Every run starts behind (listing_mark 0 < list_mark 1): the server's lister builds each listing in
81
+ * the background, the runs no runner holds first. */
82
+ export declare function listingUpgrade(runColumns: ReadonlySet<string>): readonly string[];
34
83
  export declare const STORE_DDL: readonly string[];
35
84
  /** pi-durable's journal tables (its SqliteStorage schema, version 2, the `sleeping` task status included; MIT, see NOTICE),
36
85
  * 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
@@ -13,7 +13,8 @@
13
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
14
  // Its monid endpoints are pinned beside them (revisions.monid_pin, REVISIONS_MONID_PIN), added at a server open the same way.
15
15
  // A run's cost says whether it is the most the run can have cost (runs.cost_upper_bound, RUNS_COST_UPPER_BOUND), added at a
16
- // server open the same way. A run's labels (runs.labels, RUNS_LABELS) are added at a server open the same way.
16
+ // server open the same way. A run's labels (runs.labels, RUNS_LABELS) are added at a server open the same way, and so is
17
+ // a trigger's package mark (triggers.template_id, TRIGGERS_TEMPLATE_ID).
17
18
  // The template packages imported from GitHub (imported_templates) are a table of their own that nothing
18
19
  // else reads, so it needs no version: the server adds it at its open to a store an earlier build of this version made
19
20
  // (IMPORTED_TEMPLATES), as it does the one-answer index. A hosted machine's minted token (minted_tokens, MINTED_TOKENS) is
@@ -28,7 +29,11 @@
28
29
  // learning state, the MCP registry, pending MCP sign-ins, and the computer ledger. PI_DDL is pi-durable's
29
30
  // journal tables, keyed by run_id (store/journal): one schema for every run's journal, so a query joins runs and their
30
31
  // journals.
31
- export const SCHEMA_VERSION = 11;
32
+ // Version 12 keeps each run's listing on its row (RUN_LISTING_COLUMNS): what a runs list shows of it, so a list reads rows
33
+ // alone. Version 13 names the runner in a process of its own that minted a hosted machine's token (minted_tokens.runner,
34
+ // .incarnation), the run the machine works for (.run), why the server refused to relay its dial (.refused), and where each
35
+ // such runner takes the dials the server relays to it (runner_relays, dial-relay.ts). The server upgrades these two in place at its open (listingUpgrade from 11, then relayUpgrade from 12); a runner waits for it.
36
+ export const SCHEMA_VERSION = 13;
32
37
  /** One answer per approval of a run: a second approve or deny command naming the same approval is refused
33
38
  * (StoreConstraint), so the first answer a person gives wins from the moment it is written, before the runner takes it
34
39
  * (runs-over-store.ts approve). In STORE_DDL, and added at a server open to a store an earlier build of this version made. */
@@ -54,6 +59,10 @@ export const RUNS_COST_UPPER_BOUND = `ALTER TABLE runs ADD COLUMN ${COST_UPPER_B
54
59
  /** A run's labels (JSON, null for none): in STORE_DDL, and added at a server open to a store an earlier build of this version
55
60
  * made, as RUNS_COST_UPPER_BOUND is (a run started before reads as given none). */
56
61
  export const RUNS_LABELS = `ALTER TABLE runs ADD COLUMN ${json("labels", true)}`;
62
+ /** A trigger's package mark (TriggerRow.templateId): the id of the template package whose apply made or last kept it, null
63
+ * for one a person made. In STORE_DDL, and added at a server open to a store an earlier build of this version made, as
64
+ * RUNS_LABELS is (a trigger made before reads as no package's). */
65
+ export const TRIGGERS_TEMPLATE_ID = "ALTER TABLE triggers ADD COLUMN template_id TEXT";
57
66
  /** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
58
67
  * source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
59
68
  * (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
@@ -70,8 +79,13 @@ export const IMPORTED_TEMPLATES = `CREATE TABLE IF NOT EXISTS imported_templates
70
79
  /** A hosted machine's minted token (a dial provider's create, spec/computer/attach.md): its computerd dials the attach
71
80
  * socket and fetches the daemon with it. By the machine (its name, from its create's request id): the token's SHA-256
72
81
  * alone (hex), what the machine must say it is at hello (kind, os, arch), and when the token ends (`expires_at`, the
73
- * machine's backstop) or was revoked (its delete). A row past its end goes at the next mint. In STORE_DDL, and added at
74
- * a server open to a store an earlier build of this version made. */
82
+ * machine's backstop) or was revoked (its delete). A row past its end goes at the next mint. `runner` and `incarnation`
83
+ * (version 13): the runner in a process of its own that minted it, and its incarnation, to which the server relays the
84
+ * machine's socket (dial-relay.ts); null for the server's own process. `run` (version 13): the run the machine works for,
85
+ * as its create named it, which the words about its dial say; null for a machine of no run. `refused` (version 13): why
86
+ * the server refused to relay its dial, in its 503's words (never the token), which the minting runner's create reads to
87
+ * end its wait; null while none was, and again at a mint. In STORE_DDL, and added at a server open to a store an earlier
88
+ * build of this version made. */
75
89
  export const MINTED_TOKENS = `CREATE TABLE IF NOT EXISTS minted_tokens (
76
90
  machine TEXT PRIMARY KEY,
77
91
  token_sha256 TEXT NOT NULL UNIQUE,
@@ -80,8 +94,117 @@ export const MINTED_TOKENS = `CREATE TABLE IF NOT EXISTS minted_tokens (
80
94
  arch TEXT NOT NULL,
81
95
  expires_at INTEGER NOT NULL,
82
96
  revoked_at INTEGER,
83
- created_at INTEGER NOT NULL
97
+ created_at INTEGER NOT NULL,
98
+ runner TEXT,
99
+ incarnation TEXT,
100
+ run TEXT,
101
+ refused TEXT
102
+ ) STRICT`;
103
+ /** Where each runner in a process of its own takes the dials the server relays to it (version 13, dial-relay.ts): its
104
+ * attach listener's host and port under its name, with its incarnation and when it last said it was there. */
105
+ export const RUNNER_RELAYS = `CREATE TABLE IF NOT EXISTS runner_relays (
106
+ runner TEXT PRIMARY KEY,
107
+ incarnation TEXT NOT NULL,
108
+ host TEXT NOT NULL,
109
+ port INTEGER NOT NULL,
110
+ seen_at INTEGER NOT NULL
84
111
  ) STRICT`;
112
+ /** Version 12 → 13 on SQLite (the server's open, sqlite/store.ts), given minted_tokens' columns now: the minting runner,
113
+ * its incarnation, the machine's run and a refused relay's words on each token's row (none of the rows there has one: the
114
+ * server's own process minted them, naming no run), the runners' relays, and the version, in one durable write. */
115
+ export function relayUpgrade(mintedColumns) {
116
+ return [
117
+ ...["runner", "incarnation", "run", "refused"].filter((column) => !mintedColumns.has(column)).map((column) => `ALTER TABLE minted_tokens ADD COLUMN ${column} TEXT`),
118
+ RUNNER_RELAYS,
119
+ "UPDATE store_meta SET schema_version = 13 WHERE singleton = 1",
120
+ ];
121
+ }
122
+ /** A run's listing on its row (version 12): what a runs list shows of the run, so a list reads rows alone and never builds
123
+ * a run's view. `list_mark` moves (+1) in the transaction of every write that can change what the run's view shows: its
124
+ * journal's commits (store/journal/storage.ts), its row's state, claim, cost and end (runs_list_moved), its commands
125
+ * (commands_list_moved), its learning's rows (learning_list_moved), and its learning run's or audit's own moves
126
+ * (runs_list_parent). The server rebuilds a listing from the run's view (store-view.ts listingOverStore, run-listing.ts)
127
+ * and writes it with the mark it read before it built (`listing_mark`), only while list_mark is still that mark: a write
128
+ * that lands meanwhile keeps the row as it left it (its list_status too), behind (listing_mark < list_mark), and it is
129
+ * built again: a crash between a write and its listing leaves a row that says
130
+ * it is behind, never one that says it is current. `listing` is the list item without the parts read when it is listed
131
+ * (console_url, archived_at); `list_status` its status, which a status filter reads in SQL; `listing_live` whether a runner
132
+ * held the run when it was built (its status reads otherwise once that claim runs out); `listing_until` when it goes stale
133
+ * by the clock alone (an ask that expires, or the retry of a build that withheld the run for a sign-in it could not read
134
+ * back); `listing_flags` what outside the run it read (LISTING_HELD: learning held for
135
+ * its owner's OK on its agent's folder; LISTING_KEYED: a failed run's error words, which read the server's keys). */
136
+ export const RUN_LISTING_COLUMNS = [
137
+ "list_mark INTEGER NOT NULL DEFAULT 1",
138
+ json("listing", true),
139
+ "list_status TEXT",
140
+ "listing_mark INTEGER NOT NULL DEFAULT 0",
141
+ "listing_live INTEGER NOT NULL DEFAULT 0 CHECK (listing_live IN (0, 1))",
142
+ "listing_until INTEGER",
143
+ "listing_flags INTEGER NOT NULL DEFAULT 0",
144
+ ];
145
+ /** listing_flags: the run's learning holds items for its owner's OK, read as they stand on its agent's folder now. */
146
+ export const LISTING_HELD = 1;
147
+ /** listing_flags: a failed run's error words, which name a refused key by the server's keys and settings. */
148
+ export const LISTING_KEYED = 2;
149
+ /** A run's status from its row alone, where its row says it (an end that is no person's stop of an agentic run): the status
150
+ * its view reads (store-view.ts STATUS_OF), in SQL. Null for any other run, whose listing says it once it is built. */
151
+ export const SETTLED_LIST_STATUS = `CASE
152
+ WHEN state = 'ended' THEN 'completed'
153
+ WHEN state = 'failed' THEN 'failed'
154
+ WHEN state = 'stopped' AND (outcome IS NULL OR outcome <> 'stopped' OR imported_from IS NOT NULL
155
+ OR (SELECT kind FROM revisions WHERE revisions.id = runs.revision_id) <> 'agentic') THEN 'cancelled'
156
+ ELSE NULL END`;
157
+ /** The listing's indexes and triggers (RUN_LISTING_COLUMNS), after every table they name. A write to a run's row moves its
158
+ * mark and sets its list_status from the row (SETTLED_LIST_STATUS: a settled run's status, else none until its listing
159
+ * is built), so a status filter never reads a status the row has left. The parent trigger moves the mark of the run a
160
+ * learning run grades (learning_proposals.learning_run_id) or an audit's shadow run audits (its id after "audit.",
161
+ * learn/audit.ts shadowRunId), since each run's view reads those. */
162
+ export const RUN_LISTING_DDL = [
163
+ `CREATE INDEX IF NOT EXISTS runs_listing_behind ON runs (started_at) WHERE listing_mark < list_mark`,
164
+ `CREATE INDEX IF NOT EXISTS runs_listing_live ON runs (started_at) WHERE listing_live = 1`,
165
+ `CREATE INDEX IF NOT EXISTS runs_listing_until ON runs (listing_until) WHERE listing_until IS NOT NULL`,
166
+ `CREATE INDEX IF NOT EXISTS runs_by_list_status ON runs (list_status, started_at)`,
167
+ `CREATE INDEX IF NOT EXISTS runs_listing_flagged ON runs (agent_id) WHERE listing_flags <> 0`,
168
+ `CREATE INDEX IF NOT EXISTS learning_proposals_by_learning_run ON learning_proposals (learning_run_id) WHERE learning_run_id IS NOT NULL`,
169
+ `CREATE TRIGGER IF NOT EXISTS runs_list_moved AFTER UPDATE OF state, epoch, runner, cost_usd, cost_upper_bound, metrics, summary, outcome, imported_from, sign_in_handed, labels, ended_at ON runs
170
+ BEGIN
171
+ UPDATE runs SET list_mark = list_mark + 1, list_status = ${SETTLED_LIST_STATUS} WHERE id = NEW.id;
172
+ END`,
173
+ `CREATE TRIGGER IF NOT EXISTS runs_list_parent AFTER UPDATE OF list_mark ON runs
174
+ WHEN substr(NEW.id, 1, 6) = 'audit.' OR EXISTS (SELECT 1 FROM learning_proposals WHERE learning_run_id = NEW.id)
175
+ BEGIN
176
+ UPDATE runs SET list_mark = list_mark + 1
177
+ WHERE (substr(NEW.id, 1, 6) = 'audit.' AND id = substr(NEW.id, 7)) OR id IN (SELECT run_id FROM learning_proposals WHERE learning_run_id = NEW.id);
178
+ END`,
179
+ `CREATE TRIGGER IF NOT EXISTS commands_list_moved AFTER INSERT ON commands
180
+ BEGIN
181
+ UPDATE runs SET list_mark = list_mark + 1 WHERE id = NEW.run_id;
182
+ END`,
183
+ `CREATE TRIGGER IF NOT EXISTS commands_list_settled AFTER UPDATE OF taken_at, refused ON commands
184
+ BEGIN
185
+ UPDATE runs SET list_mark = list_mark + 1 WHERE id = NEW.run_id;
186
+ END`,
187
+ `CREATE TRIGGER IF NOT EXISTS learning_list_moved AFTER INSERT ON learning_proposals
188
+ BEGIN
189
+ UPDATE runs SET list_mark = list_mark + 1 WHERE id = NEW.run_id;
190
+ END`,
191
+ `CREATE TRIGGER IF NOT EXISTS learning_list_changed AFTER UPDATE ON learning_proposals
192
+ BEGIN
193
+ UPDATE runs SET list_mark = list_mark + 1 WHERE id = NEW.run_id;
194
+ END`,
195
+ ];
196
+ /** Version 11 → 12 on SQLite (the server's open, sqlite/store.ts), given the runs table's columns now: the listing's columns
197
+ * it lacks, its indexes and triggers, every settled run's status from its row (SETTLED_LIST_STATUS), and the version, in
198
+ * one durable write. Every run starts behind (listing_mark 0 < list_mark 1): the server's lister builds each listing in
199
+ * the background, the runs no runner holds first. */
200
+ export function listingUpgrade(runColumns) {
201
+ return [
202
+ ...RUN_LISTING_COLUMNS.filter((column) => !runColumns.has(column.split(" ")[0])).map((column) => `ALTER TABLE runs ADD COLUMN ${column}`),
203
+ ...RUN_LISTING_DDL,
204
+ `UPDATE runs SET list_status = ${SETTLED_LIST_STATUS}`,
205
+ "UPDATE store_meta SET schema_version = 12 WHERE singleton = 1",
206
+ ];
207
+ }
85
208
  export const STORE_DDL = [
86
209
  `CREATE TABLE IF NOT EXISTS store_meta (
87
210
  singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
@@ -171,7 +294,9 @@ export const STORE_DDL = [
171
294
  -- build of this version made (RUNS_LABELS), its runs reading as given none.
172
295
  ${json("labels", true)},
173
296
  started_at INTEGER NOT NULL,
174
- ended_at INTEGER
297
+ ended_at INTEGER,
298
+ -- The run's listing (RUN_LISTING_COLUMNS): what a runs list shows of it, kept on its row so a list reads rows alone.
299
+ ${RUN_LISTING_COLUMNS.join(",\n ")}
175
300
  ) STRICT`,
176
301
  `CREATE INDEX IF NOT EXISTS runs_by_agent ON runs (agent_id, started_at)`,
177
302
  `CREATE INDEX IF NOT EXISTS runs_by_revision ON runs (revision_id, started_at)`,
@@ -251,6 +376,10 @@ export const STORE_DDL = [
251
376
  max_active_runs INTEGER CHECK (max_active_runs IS NULL OR max_active_runs BETWEEN 1 AND 100),
252
377
  created_at INTEGER NOT NULL,
253
378
  updated_at INTEGER NOT NULL,
379
+ -- The template package whose apply made or last kept the trigger (TriggerRow.templateId), null for one a person made:
380
+ -- a template update removes only triggers marked with its own package. Written by the apply alone; a move to another
381
+ -- agent clears it. Added at a server open to a store an earlier build of this version made (TRIGGERS_TEMPLATE_ID).
382
+ template_id TEXT,
254
383
  UNIQUE (agent_id, name)
255
384
  ) STRICT`,
256
385
  `CREATE INDEX IF NOT EXISTS triggers_due ON triggers (enabled, next_at)`,
@@ -409,6 +538,7 @@ export const STORE_DDL = [
409
538
  ) STRICT`,
410
539
  IMPORTED_TEMPLATES,
411
540
  MINTED_TOKENS,
541
+ RUNNER_RELAYS,
412
542
  // An agent's saved browser sign-ins (design 2.1, the browser sign-in rules): one live row per agent and browser provider, its
413
543
  // pointer (the vendor's context or profile id) sealed with the store's one rule (store/seal.ts, AAD
414
544
  // sign_ins|<agent>:<provider>|pointer), which the store never opens. The owner sees its name ("default") and saved_at,
@@ -529,6 +659,7 @@ export const STORE_DDL = [
529
659
  PRIMARY KEY (run_id, round)
530
660
  ) STRICT`,
531
661
  `CREATE INDEX IF NOT EXISTS learning_proposals_by_agent ON learning_proposals (agent_id, created_at DESC)`,
662
+ ...RUN_LISTING_DDL,
532
663
  ];
533
664
  /** pi-durable's journal tables (its SqliteStorage schema, version 2, the `sleeping` task status included; MIT, see NOTICE),
534
665
  * 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
@@ -13,7 +13,8 @@ export declare const sealedAt: {
13
13
  signIn: (agentId: string, provider: string) => SealedAt;
14
14
  /** A run's computer session's live viewer token (browser-live.ts): one row per run, computer kind and session tag. */
15
15
  liveViewer: (runId: string, kind: string, tag: string) => SealedAt;
16
- /** A run's launch secrets: the MCP credentials its caller handed it for its `per_run` servers (mcp_auth). */
16
+ /** A run's launch secrets: the MCP credentials its caller handed it for its `per_run` servers (mcp_auth), and its own
17
+ * model key (model_key), with the gateway's origin it was handed for. */
17
18
  runLaunch: (runId: string) => SealedAt;
18
19
  };
19
20
  /** The AAD a value at `at` is sealed under. A part with the separator in it is refused: no two places share an AAD. */
@@ -54,7 +55,24 @@ export type RunMcpAuth = Readonly<Record<string, {
54
55
  readonly headers: Readonly<Record<string, string>>;
55
56
  readonly origin: string;
56
57
  }>>;
57
- /** Seals a run's handed MCP credentials as its launch's sealed column (AAD run_launch|<run_id>|sealed). */
58
+ /** A run's own model key (`model_key` at its start or with a message): the key its model requests carry, and the origin
59
+ * of the gateway it was handed for (AGENT_MODEL_BASE_URL's then), so a gateway moved since never receives it. */
60
+ export type RunModelKey = {
61
+ readonly key: string;
62
+ readonly origin: string;
63
+ };
64
+ /** What a run's launch holds sealed: its handed MCP credentials and its own model key, each when it has one. */
65
+ export type RunLaunchSecrets = {
66
+ readonly mcp?: RunMcpAuth;
67
+ readonly model?: RunModelKey;
68
+ };
69
+ /** Seals a run's launch secrets as its launch's sealed column (AAD run_launch|<run_id>|sealed); null when it holds none. */
70
+ export declare function sealRunLaunch(key: Buffer, runId: string, secrets: RunLaunchSecrets): Uint8Array | null;
71
+ /** A run's launch secrets, opened: none when its launch holds none; undefined when the bytes do not open under `key` for
72
+ * this run (sealed for another run, or under another key). */
73
+ export declare function openRunLaunch(key: Buffer, runId: string, sealed: Uint8Array | null): RunLaunchSecrets | undefined;
74
+ /** Seals a run's handed MCP credentials alone as its launch's sealed column (AAD run_launch|<run_id>|sealed): a run started
75
+ * by the runner from another (a replay, an audit) takes its MCP credentials, never its model key. */
58
76
  export declare function sealRunMcpAuth(key: Buffer, runId: string, auth: RunMcpAuth): Uint8Array;
59
77
  /** A run's handed MCP credentials, opened: none when its launch holds none; undefined when the bytes do not open under
60
78
  * `key` for this run (sealed for another run, or under another key). */