@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.37

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 (522) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/README.md +417 -219
  3. package/dist/adapters.d.ts +12 -2
  4. package/dist/adapters.js +27 -2
  5. package/dist/agent-rows.d.ts +2 -1
  6. package/dist/agents-store.d.ts +2 -0
  7. package/dist/agents-store.js +9 -4
  8. package/dist/api-only.d.ts +2 -1
  9. package/dist/api-only.js +3 -1
  10. package/dist/archil-routes.d.ts +40 -7
  11. package/dist/archil-routes.js +167 -54
  12. package/dist/archil-settings.d.ts +79 -7
  13. package/dist/archil-settings.js +140 -14
  14. package/dist/attach-conformance-cli.d.ts +1 -0
  15. package/dist/attach-conformance-cli.js +18 -0
  16. package/dist/attach-conformance.d.ts +25 -0
  17. package/dist/attach-conformance.js +343 -0
  18. package/dist/attach-images.d.ts +15 -0
  19. package/dist/attach-images.js +59 -0
  20. package/dist/background.d.ts +0 -6
  21. package/dist/background.js +0 -28
  22. package/dist/box-image.d.ts +1 -97
  23. package/dist/box-image.js +4 -284
  24. package/dist/box-paths.d.ts +2 -7
  25. package/dist/box-paths.js +7 -13
  26. package/dist/box-settings.d.ts +0 -11
  27. package/dist/box-settings.js +4 -29
  28. package/dist/browser-commands.js +1 -1
  29. package/dist/browser-computer.d.ts +47 -3
  30. package/dist/browser-computer.js +286 -18
  31. package/dist/browser-cost.d.ts +1 -1
  32. package/dist/browser-live.d.ts +20 -8
  33. package/dist/browser-live.js +50 -27
  34. package/dist/browser-person.d.ts +19 -2
  35. package/dist/browser-person.js +55 -6
  36. package/dist/browser-wait-ended.d.ts +23 -0
  37. package/dist/browser-wait-ended.js +42 -0
  38. package/dist/cap.d.ts +12 -57
  39. package/dist/cap.js +20 -160
  40. package/dist/catalog.d.ts +1 -12
  41. package/dist/catalog.js +3 -33
  42. package/dist/cli.js +17 -26
  43. package/dist/composio-preset.d.ts +36 -0
  44. package/dist/composio-preset.js +179 -0
  45. package/dist/computer-attach.d.ts +125 -0
  46. package/dist/computer-attach.js +330 -0
  47. package/dist/computer-calls.d.ts +48 -0
  48. package/dist/computer-calls.js +126 -0
  49. package/dist/computer-channel.d.ts +57 -0
  50. package/dist/computer-channel.js +115 -0
  51. package/dist/computer-commands.d.ts +1 -1
  52. package/dist/computer-held-routes.d.ts +35 -0
  53. package/dist/computer-held-routes.js +106 -0
  54. package/dist/computer-held.d.ts +48 -0
  55. package/dist/computer-held.js +87 -0
  56. package/dist/computer-keys.d.ts +21 -1
  57. package/dist/computer-keys.js +53 -11
  58. package/dist/computer-live.d.ts +160 -0
  59. package/dist/computer-live.js +643 -0
  60. package/dist/computer-routes.d.ts +1 -4
  61. package/dist/computer-routes.js +3 -5
  62. package/dist/computer-setting.d.ts +2 -0
  63. package/dist/computer-setting.js +38 -1
  64. package/dist/computer-view.d.ts +24 -2
  65. package/dist/computer-view.js +51 -3
  66. package/dist/computer-viewer.d.ts +6 -0
  67. package/dist/computer-viewer.js +297 -0
  68. package/dist/computers.d.ts +79 -12
  69. package/dist/computers.js +147 -28
  70. package/dist/console/assets/index-Cn6JX1uH.js +563 -0
  71. package/dist/console/assets/index-DRN62V5v.css +1 -0
  72. package/dist/console/index.html +2 -2
  73. package/dist/docker-daemon.d.ts +2 -2
  74. package/dist/docker-daemon.js +2 -2
  75. package/dist/errors.js +5 -5
  76. package/dist/faux-computers.d.ts +9 -20
  77. package/dist/faux-computers.js +56 -24
  78. package/dist/files.d.ts +1 -9
  79. package/dist/files.js +1 -9
  80. package/dist/github-connection.d.ts +10 -2
  81. package/dist/github-connection.js +65 -2
  82. package/dist/github-faux.js +1 -1
  83. package/dist/github.d.ts +22 -2
  84. package/dist/github.js +42 -8
  85. package/dist/gpu-words.d.ts +14 -0
  86. package/dist/gpu-words.js +21 -0
  87. package/dist/graph-view.d.ts +3 -1
  88. package/dist/graph-view.js +25 -1
  89. package/dist/handed-values.d.ts +1 -1
  90. package/dist/handed-values.js +1 -1
  91. package/dist/harness-install.d.ts +60 -3
  92. package/dist/harness-install.js +322 -34
  93. package/dist/harness.d.ts +1 -0
  94. package/dist/harness.js +36 -2
  95. package/dist/host-tools.d.ts +9 -10
  96. package/dist/host-tools.js +7 -7
  97. package/dist/hosted-search.d.ts +5 -4
  98. package/dist/hosted-search.js +2 -7
  99. package/dist/import-sources.d.ts +10 -0
  100. package/dist/import-sources.js +44 -2
  101. package/dist/import.d.ts +3 -3
  102. package/dist/import.js +37 -6
  103. package/dist/index.d.ts +1 -3
  104. package/dist/index.js +1 -2
  105. package/dist/key-refusal.d.ts +1 -1
  106. package/dist/key-refusal.js +2 -2
  107. package/dist/learn/check.d.ts +11 -2
  108. package/dist/learn/check.js +124 -6
  109. package/dist/learn/commit.d.ts +43 -7
  110. package/dist/learn/commit.js +166 -22
  111. package/dist/learn/folder.d.ts +11 -0
  112. package/dist/learn/folder.js +37 -1
  113. package/dist/learn/general.d.ts +66 -0
  114. package/dist/learn/general.js +73 -0
  115. package/dist/learn/grade.d.ts +22 -1
  116. package/dist/learn/grade.js +107 -16
  117. package/dist/learn/index.d.ts +1 -1
  118. package/dist/learn/index.js +1 -1
  119. package/dist/learn/learning.sh +12 -1
  120. package/dist/learn/notes.d.ts +3 -0
  121. package/dist/learn/notes.js +3 -0
  122. package/dist/learn/reflect.d.ts +14 -2
  123. package/dist/learn/reflect.js +54 -30
  124. package/dist/learn/skills.d.ts +37 -5
  125. package/dist/learn/skills.js +60 -7
  126. package/dist/learned-nodes.d.ts +6 -2
  127. package/dist/learned-workflow.d.ts +43 -9
  128. package/dist/learned-workflow.js +128 -37
  129. package/dist/learning-batch.d.ts +283 -0
  130. package/dist/learning-batch.js +574 -0
  131. package/dist/learning-cost.d.ts +79 -0
  132. package/dist/learning-cost.js +69 -0
  133. package/dist/learning-evals.d.ts +33 -0
  134. package/dist/learning-evals.js +98 -0
  135. package/dist/learning-routes.d.ts +32 -4
  136. package/dist/learning-routes.js +48 -12
  137. package/dist/learning-words.d.ts +9 -0
  138. package/dist/learning-words.js +12 -2
  139. package/dist/learning.d.ts +39 -19
  140. package/dist/learning.js +88 -46
  141. package/dist/live/stream.js +6 -3
  142. package/dist/live/translate.d.ts +4 -3
  143. package/dist/live/translate.js +8 -4
  144. package/dist/live-reach.d.ts +37 -0
  145. package/dist/live-reach.js +62 -0
  146. package/dist/mcp-gateway.d.ts +9 -0
  147. package/dist/mcp-gateway.js +60 -11
  148. package/dist/mcp-oauth.d.ts +57 -7
  149. package/dist/mcp-oauth.js +133 -18
  150. package/dist/mcp-private-hosts.d.ts +4 -4
  151. package/dist/mcp-private-hosts.js +20 -12
  152. package/dist/mcp-probe.d.ts +27 -3
  153. package/dist/mcp-probe.js +106 -29
  154. package/dist/mcp-secret-writes.js +8 -0
  155. package/dist/mcp-servers-store.d.ts +38 -15
  156. package/dist/mcp-servers-store.js +120 -23
  157. package/dist/mcp-store.d.ts +10 -4
  158. package/dist/mcp-store.js +17 -6
  159. package/dist/model-form.d.ts +26 -0
  160. package/dist/model-form.js +80 -0
  161. package/dist/model.d.ts +5 -5
  162. package/dist/model.js +29 -16
  163. package/dist/openapi.d.ts +2 -0
  164. package/dist/openapi.js +586 -64
  165. package/dist/owner.d.ts +0 -1
  166. package/dist/owner.js +0 -2
  167. package/dist/page.d.ts +18 -0
  168. package/dist/page.js +48 -20
  169. package/dist/paid-calls.d.ts +1 -1
  170. package/dist/paid-calls.js +1 -1
  171. package/dist/place-offers.d.ts +96 -0
  172. package/dist/place-offers.js +202 -0
  173. package/dist/place.d.ts +9 -13
  174. package/dist/place.js +21 -32
  175. package/dist/port-models.d.ts +2 -1
  176. package/dist/port-models.js +5 -3
  177. package/dist/print.d.ts +16 -9
  178. package/dist/print.js +15 -17
  179. package/dist/propose.d.ts +4 -0
  180. package/dist/propose.js +34 -11
  181. package/dist/provider.js +3 -2
  182. package/dist/reflect-range.d.ts +8 -1
  183. package/dist/reflect-range.js +1 -1
  184. package/dist/run-cut.d.ts +5 -0
  185. package/dist/run-cut.js +19 -0
  186. package/dist/run-launch.d.ts +28 -3
  187. package/dist/run-launch.js +14 -4
  188. package/dist/run-learning-served.d.ts +2 -2
  189. package/dist/run-manifest.d.ts +2 -2
  190. package/dist/run-manifest.js +2 -2
  191. package/dist/run-reads-over-store.d.ts +1 -1
  192. package/dist/run-repo.d.ts +20 -0
  193. package/dist/run-repo.js +63 -0
  194. package/dist/run-secrets.js +3 -3
  195. package/dist/run-timeline-served.d.ts +1 -1
  196. package/dist/run-timeline-served.js +56 -44
  197. package/dist/run-view.d.ts +8 -5
  198. package/dist/run-view.js +18 -10
  199. package/dist/runnable.d.ts +2 -2
  200. package/dist/runnable.js +6 -2
  201. package/dist/runner/adapter-loop.d.ts +39 -8
  202. package/dist/runner/adapter-loop.js +770 -83
  203. package/dist/runner/adapter-run-spec.d.ts +36 -7
  204. package/dist/runner/adapter-run-spec.js +171 -37
  205. package/dist/runner/adapters/pi-computer.d.ts +7 -0
  206. package/dist/runner/adapters/pi-computer.js +43 -0
  207. package/dist/runner/adapters/pi.d.ts +20 -7
  208. package/dist/runner/adapters/pi.js +111 -26
  209. package/dist/runner/beside.d.ts +7 -3
  210. package/dist/runner/beside.js +26 -12
  211. package/dist/runner/claim-secrets.d.ts +4 -0
  212. package/dist/runner/claim-secrets.js +6 -1
  213. package/dist/runner/cli-run-spec.d.ts +27 -3
  214. package/dist/runner/cli-run-spec.js +198 -74
  215. package/dist/runner/commands.d.ts +8 -2
  216. package/dist/runner/commands.js +31 -6
  217. package/dist/runner/computer-channel.d.ts +34 -0
  218. package/dist/runner/computer-channel.js +61 -0
  219. package/dist/runner/conformance/harness.d.ts +0 -1
  220. package/dist/runner/conformance/harness.js +87 -18
  221. package/dist/runner/conformance/subject.d.ts +1 -1
  222. package/dist/runner/dispatch.js +3 -0
  223. package/dist/runner/end-of-run.d.ts +22 -12
  224. package/dist/runner/end-of-run.js +38 -16
  225. package/dist/runner/github-app.d.ts +2 -1
  226. package/dist/runner/github-app.js +6 -4
  227. package/dist/runner/harness-loops.js +16 -2
  228. package/dist/runner/held-run.d.ts +65 -0
  229. package/dist/runner/held-run.js +158 -0
  230. package/dist/runner/journal-kinds.d.ts +35 -6
  231. package/dist/runner/journal-kinds.js +20 -1
  232. package/dist/runner/journal-reader.d.ts +5 -4
  233. package/dist/runner/journal-reader.js +12 -10
  234. package/dist/runner/learning-ask.d.ts +7 -1
  235. package/dist/runner/learning-ask.js +21 -6
  236. package/dist/runner/learning-dispatch.d.ts +22 -0
  237. package/dist/runner/learning-dispatch.js +77 -10
  238. package/dist/runner/learning-end.d.ts +37 -1
  239. package/dist/runner/learning-end.js +115 -14
  240. package/dist/runner/learning-factory.d.ts +1 -1
  241. package/dist/runner/learning-factory.js +15 -5
  242. package/dist/runner/learning-loop.d.ts +139 -7
  243. package/dist/runner/learning-loop.js +369 -32
  244. package/dist/runner/learning-seed.d.ts +9 -0
  245. package/dist/runner/learning-seed.js +14 -1
  246. package/dist/runner/live-ticker.js +1 -0
  247. package/dist/runner/loop-contract.d.ts +16 -1
  248. package/dist/runner/loop-contract.js +6 -0
  249. package/dist/runner/loop.d.ts +10 -2
  250. package/dist/runner/loop.js +22 -1
  251. package/dist/runner/main.d.ts +13 -1
  252. package/dist/runner/main.js +38 -6
  253. package/dist/runner/mcp-claim.d.ts +11 -4
  254. package/dist/runner/mcp-claim.js +140 -23
  255. package/dist/runner/mcp-github.d.ts +4 -2
  256. package/dist/runner/mcp-github.js +1 -8
  257. package/dist/runner/mcp-run.d.ts +6 -4
  258. package/dist/runner/mcp-run.js +16 -3
  259. package/dist/runner/metrics.d.ts +15 -2
  260. package/dist/runner/metrics.js +21 -2
  261. package/dist/runner/model-route.d.ts +3 -0
  262. package/dist/runner/model-route.js +5 -2
  263. package/dist/runner/pr-checkout.d.ts +60 -0
  264. package/dist/runner/pr-checkout.js +176 -0
  265. package/dist/runner/reflect-hook.d.ts +19 -0
  266. package/dist/runner/reflect-hook.js +20 -8
  267. package/dist/runner/runner.d.ts +26 -0
  268. package/dist/runner/runner.js +231 -27
  269. package/dist/runner/scratch-sweep.d.ts +13 -0
  270. package/dist/runner/scratch-sweep.js +62 -0
  271. package/dist/runner/sessions.d.ts +1 -1
  272. package/dist/runner/spec-holds.d.ts +8 -3
  273. package/dist/runner/spec-holds.js +12 -10
  274. package/dist/runner/store-port.d.ts +7 -2
  275. package/dist/runner/store-secrets.js +21 -4
  276. package/dist/runner/subagent.d.ts +44 -0
  277. package/dist/runner/subagent.js +190 -0
  278. package/dist/runner/workflow-host.d.ts +24 -3
  279. package/dist/runner/workflow-host.js +24 -4
  280. package/dist/runner/workflow-loop.d.ts +6 -3
  281. package/dist/runner/workflow-loop.js +9 -8
  282. package/dist/runner/workflow-spec.d.ts +39 -15
  283. package/dist/runner/workflow-spec.js +143 -40
  284. package/dist/runs-over-store.d.ts +16 -6
  285. package/dist/runs-over-store.js +145 -29
  286. package/dist/seal-key.js +3 -3
  287. package/dist/sealed-settings-store.d.ts +5 -2
  288. package/dist/sealed-settings-store.js +10 -4
  289. package/dist/sealing.js +1 -2
  290. package/dist/secret-cut.d.ts +1 -1
  291. package/dist/secret-cut.js +1 -1
  292. package/dist/secret-writes.d.ts +5 -4
  293. package/dist/secret-writes.js +5 -4
  294. package/dist/server-secrets-store.d.ts +4 -3
  295. package/dist/server-secrets-store.js +15 -9
  296. package/dist/server-secrets.js +3 -2
  297. package/dist/server.d.ts +75 -63
  298. package/dist/server.js +712 -316
  299. package/dist/settings-wake.d.ts +21 -0
  300. package/dist/settings-wake.js +59 -0
  301. package/dist/standard-webhooks.d.ts +4 -1
  302. package/dist/standard-webhooks.js +8 -4
  303. package/dist/store/agent-body.d.ts +9 -2
  304. package/dist/store/agent-body.js +16 -8
  305. package/dist/store/command-wake.d.ts +12 -0
  306. package/dist/store/command-wake.js +37 -0
  307. package/dist/store/deadline.js +9 -5
  308. package/dist/store/dialect.d.ts +6 -0
  309. package/dist/store/dialect.js +5 -0
  310. package/dist/store/index.d.ts +4 -4
  311. package/dist/store/index.js +2 -2
  312. package/dist/store/journal/storage.d.ts +3 -2
  313. package/dist/store/journal/storage.js +15 -6
  314. package/dist/store/postgres/connection.js +9 -4
  315. package/dist/store/postgres/dialect.js +4 -0
  316. package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
  317. package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
  318. package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
  319. package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
  320. package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
  321. package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
  322. package/dist/store/schema.d.ts +2 -1
  323. package/dist/store/schema.js +85 -13
  324. package/dist/store/seal.d.ts +13 -0
  325. package/dist/store/seal.js +19 -0
  326. package/dist/store/sqlite/connection.d.ts +5 -0
  327. package/dist/store/sqlite/connection.js +88 -47
  328. package/dist/store/sqlite/run-patch.d.ts +25 -7
  329. package/dist/store/sqlite/run-patch.js +58 -14
  330. package/dist/store/sqlite/store.js +331 -59
  331. package/dist/store/store.d.ts +330 -21
  332. package/dist/store/store.js +34 -2
  333. package/dist/store-reads/analytics.js +3 -2
  334. package/dist/store-reads/cap.d.ts +2 -4
  335. package/dist/store-reads/cap.js +16 -7
  336. package/dist/store-reads/decisions.d.ts +3 -3
  337. package/dist/store-reads/decisions.js +3 -6
  338. package/dist/store-reads/import-summary.d.ts +1 -1
  339. package/dist/store-reads/journal.d.ts +5 -4
  340. package/dist/store-reads/journal.js +118 -27
  341. package/dist/store-reads/learning.d.ts +34 -4
  342. package/dist/store-reads/learning.js +137 -23
  343. package/dist/store-reads/runs.d.ts +7 -5
  344. package/dist/store-reads/runs.js +17 -10
  345. package/dist/store-reads/stats.js +5 -1
  346. package/dist/store-reads/workflow.d.ts +1 -1
  347. package/dist/store-view.d.ts +5 -0
  348. package/dist/store-view.js +70 -29
  349. package/dist/template-eval.js +8 -5
  350. package/dist/template-github-permissions.d.ts +22 -8
  351. package/dist/template-github-permissions.js +35 -15
  352. package/dist/templates.d.ts +64 -0
  353. package/dist/templates.js +101 -16
  354. package/dist/timeline/timeline.d.ts +30 -1
  355. package/dist/timeline/timeline.js +29 -13
  356. package/dist/timeline/util.d.ts +4 -0
  357. package/dist/timeline/util.js +14 -0
  358. package/dist/tool-blurbs.js +1 -0
  359. package/dist/tool-budget.d.ts +27 -7
  360. package/dist/tool-budget.js +21 -9
  361. package/dist/tool-gate.d.ts +23 -10
  362. package/dist/tool-gate.js +60 -44
  363. package/dist/tool-plane.d.ts +46 -28
  364. package/dist/tool-plane.js +73 -31
  365. package/dist/tools.d.ts +31 -38
  366. package/dist/tools.js +117 -74
  367. package/dist/trigger-adapter.d.ts +4 -0
  368. package/dist/trigger-secrets-shown.d.ts +2 -2
  369. package/dist/trigger-secrets-shown.js +1 -1
  370. package/dist/trigger-signatures.d.ts +26 -6
  371. package/dist/trigger-signatures.js +44 -8
  372. package/dist/trigger-targets.d.ts +2 -0
  373. package/dist/trigger-targets.js +1 -0
  374. package/dist/trigger-webhook.js +5 -2
  375. package/dist/triggers.d.ts +10 -6
  376. package/dist/triggers.js +37 -7
  377. package/dist/turn-end.d.ts +0 -3
  378. package/dist/turn-end.js +0 -3
  379. package/dist/turns.js +16 -1
  380. package/dist/usage-lines.d.ts +1 -1
  381. package/dist/validate.d.ts +6 -0
  382. package/dist/validate.js +41 -4
  383. package/dist/web-fetch.d.ts +1 -1
  384. package/dist/web-search.d.ts +10 -5
  385. package/dist/web-search.js +7 -6
  386. package/dist/webhooks.d.ts +147 -103
  387. package/dist/webhooks.js +564 -324
  388. package/dist/workflow/decision-recovery.d.ts +23 -0
  389. package/dist/workflow/decision-recovery.js +80 -0
  390. package/dist/workflow/decisions.d.ts +134 -0
  391. package/dist/workflow/decisions.js +46 -0
  392. package/dist/workflow/host-session.d.ts +5 -0
  393. package/dist/workflow/host-session.js +85 -0
  394. package/dist/workflow/host-tools.d.ts +3 -0
  395. package/dist/workflow/host-tools.js +3 -0
  396. package/dist/workflow/node-runner.d.ts +113 -0
  397. package/dist/workflow/node-runner.js +270 -0
  398. package/dist/workflow/node.d.ts +89 -0
  399. package/dist/workflow/node.js +101 -0
  400. package/dist/workflow/operator-error.d.ts +4 -0
  401. package/dist/workflow/operator-error.js +4 -0
  402. package/dist/workflow/pi-versions.d.ts +32 -0
  403. package/dist/workflow/pi-versions.js +65 -0
  404. package/dist/workflow/record-file.d.ts +10 -0
  405. package/dist/workflow/record-file.js +56 -0
  406. package/dist/workflow/record-tool.d.ts +77 -0
  407. package/dist/workflow/record-tool.js +126 -0
  408. package/dist/workflow/record.d.ts +151 -0
  409. package/dist/workflow/record.js +401 -0
  410. package/dist/workflow/run-error.d.ts +16 -0
  411. package/dist/workflow/run-error.js +26 -0
  412. package/dist/workflow/runner.d.ts +6 -0
  413. package/dist/workflow/runner.js +240 -0
  414. package/dist/workflow/store.d.ts +23 -0
  415. package/dist/workflow/store.js +242 -0
  416. package/dist/workflow/task.d.ts +133 -0
  417. package/dist/workflow/task.js +412 -0
  418. package/dist/workflow/thinking.d.ts +3 -0
  419. package/dist/workflow/thinking.js +7 -0
  420. package/dist/workflow/tool-context.d.ts +21 -0
  421. package/dist/workflow/tool-context.js +13 -0
  422. package/dist/workflow/types.d.ts +126 -0
  423. package/dist/workflow/types.js +1 -0
  424. package/dist/workflow-run.d.ts +2 -2
  425. package/dist/workspace/agent-computer.d.ts +137 -0
  426. package/dist/workspace/agent-computer.js +292 -0
  427. package/dist/workspace/archil-claim.d.ts +11 -0
  428. package/dist/workspace/archil-claim.js +18 -10
  429. package/dist/workspace/archil-disks.d.ts +49 -0
  430. package/dist/workspace/archil-disks.js +185 -0
  431. package/dist/workspace/archil-exec.js +2 -3
  432. package/dist/workspace/archil-mount-credential.d.ts +20 -4
  433. package/dist/workspace/archil-mount-credential.js +13 -4
  434. package/dist/workspace/attached-computers.d.ts +41 -0
  435. package/dist/workspace/attached-computers.js +114 -0
  436. package/dist/workspace/computer-deps.d.ts +32 -17
  437. package/dist/workspace/computer-deps.js +37 -14
  438. package/dist/workspace/computer-for-claim.d.ts +58 -13
  439. package/dist/workspace/computer-for-claim.js +267 -26
  440. package/dist/workspace/computer-hold.d.ts +11 -27
  441. package/dist/workspace/computer-hold.js +36 -56
  442. package/dist/workspace/computer-janitor.d.ts +3 -2
  443. package/dist/workspace/computer-janitor.js +43 -9
  444. package/dist/workspace/computer-ledger.d.ts +5 -1
  445. package/dist/workspace/computer-ledger.js +11 -0
  446. package/dist/workspace/computer-mcp.d.ts +25 -0
  447. package/dist/workspace/computer-mcp.js +41 -0
  448. package/dist/workspace/computer-ports.d.ts +4 -13
  449. package/dist/workspace/computer-ports.js +4 -107
  450. package/dist/workspace/computer-script.d.ts +37 -0
  451. package/dist/workspace/computer-script.js +138 -0
  452. package/dist/workspace/executors.d.ts +1 -1
  453. package/dist/workspace/index.d.ts +7 -4
  454. package/dist/workspace/index.js +4 -1
  455. package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
  456. package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
  457. package/dist/workspace/resolve-computer.d.ts +45 -11
  458. package/dist/workspace/resolve-computer.js +72 -14
  459. package/dist/workspace/run-disk.d.ts +34 -0
  460. package/dist/workspace/run-disk.js +91 -0
  461. package/dist/workspace/run-tools.d.ts +35 -18
  462. package/dist/workspace/run-tools.js +24 -29
  463. package/dist/workspace/server-run-workspace.d.ts +3 -2
  464. package/dist/workspace/server-run-workspace.js +17 -4
  465. package/dist/workspace.js +1 -1
  466. package/package.json +19 -21
  467. package/templates/README.md +9 -6
  468. package/templates/code-review/agent.md +27 -11
  469. package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
  470. package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
  471. package/templates/code-review/evals/injection/graders/ignores.md +1 -1
  472. package/templates/code-review/evals/never-flag/case.yaml +3 -0
  473. package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
  474. package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
  475. package/templates/code-review/evals/never-flag/prompt.md +30 -0
  476. package/templates/code-review/evals/null-name/graders/finds.md +1 -1
  477. package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
  478. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
  479. package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
  480. package/templates/code-review/evals/re-review/prompt.md +1 -1
  481. package/templates/code-review/evals/re-review-open/case.yaml +3 -0
  482. package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
  483. package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
  484. package/templates/code-review/evals/re-review-open/prompt.md +27 -0
  485. package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
  486. package/templates/code-review/evals/two-defects/case.yaml +3 -0
  487. package/templates/code-review/evals/two-defects/graders/both.md +4 -0
  488. package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
  489. package/templates/code-review/evals/two-defects/prompt.md +25 -0
  490. package/templates/code-review/findings.schema.json +131 -27
  491. package/templates/code-review/rules/CODEREVIEW.md +76 -0
  492. package/templates/code-review/skills/review/DEEP.md +130 -0
  493. package/templates/code-review/skills/review/REVIEWER.md +116 -0
  494. package/templates/code-review/skills/review/SKILL.md +104 -154
  495. package/templates/market-monitor/agent.md +1 -1
  496. package/dist/box/record.d.ts +0 -6
  497. package/dist/box/record.js +0 -41
  498. package/dist/box/sweep.d.ts +0 -53
  499. package/dist/box/sweep.js +0 -193
  500. package/dist/box-egress-vm.d.ts +0 -118
  501. package/dist/box-egress-vm.js +0 -354
  502. package/dist/box-egress.d.ts +0 -105
  503. package/dist/box-egress.js +0 -256
  504. package/dist/box-relay-vm.d.ts +0 -84
  505. package/dist/box-relay-vm.js +0 -437
  506. package/dist/box-relay.d.ts +0 -36
  507. package/dist/box-relay.js +0 -207
  508. package/dist/boxes.d.ts +0 -109
  509. package/dist/boxes.js +0 -249
  510. package/dist/budget.d.ts +0 -71
  511. package/dist/budget.js +0 -199
  512. package/dist/console/assets/index-B7NKTU8E.css +0 -1
  513. package/dist/console/assets/index-CXZMgJE7.js +0 -550
  514. package/dist/daytona-api.d.ts +0 -10
  515. package/dist/daytona-api.js +0 -20
  516. package/dist/egress-proxy.d.ts +0 -45
  517. package/dist/egress-proxy.js +0 -416
  518. package/dist/egress-table.d.ts +0 -24
  519. package/dist/egress-table.js +0 -165
  520. package/dist/run-db.d.ts +0 -53
  521. package/dist/run-db.js +0 -116
  522. package/templates/code-review/rules/REVIEW.md +0 -41
@@ -1,4 +1,4 @@
1
- import type { Context } from "@earendil-works/chord";
1
+ import type { Context } from "@earendil-works/chord/context";
2
2
  import type { Storage, StorageWrite } from "@earendil-works/pi-durable";
3
3
  import type { JournalPage } from "./journal/storage.js";
4
4
  /** A run's state. queued: a row, no runner yet. running: a runner holds the claim. parked: waiting for a person (an
@@ -89,9 +89,16 @@ export interface RevisionRow {
89
89
  /** The version this revision maps in the agent's owning system (one revision per version), or null for one committed here. */
90
90
  readonly externalVersion: string | null;
91
91
  }
92
- /** How an ended run (state 'ended') ended apart from being done: 'escalated' (it finished its work and waits for a person,
93
- * which the v2 status reads as completed with a review) or 'completed'. A failed or stopped run says so in its state. */
94
- export type RunOutcome = "completed" | "escalated";
92
+ /** How a run ended, beside its state. An ended run (state 'ended'): 'escalated' (it finished its work and waits for a
93
+ * person, which the v2 status reads as completed with a review) or 'completed'. A stopped run (state 'stopped'): 'stopped'
94
+ * when a person stopped it (its turn ended, never the run: an agentic run reads input_required and idle, as main's
95
+ * statusOf reads a stopped run, and a person's message reopens it), 'cancelled' when it was cancelled (over for good). A
96
+ * failed run says so in its state. */
97
+ export type RunOutcome = "completed" | "escalated" | "stopped" | "cancelled";
98
+ /** Whether `run`, of a revision of `kind`, was stopped by a person and waits for them (state 'stopped', outcome 'stopped',
99
+ * an agentic run started here): its turn is over, the run is not. A workflow's stop, a cancel and an imported run's stop
100
+ * are over for good. */
101
+ export declare function stoppedByPerson(run: Pick<RunRow, "state" | "outcome" | "importedFrom">, kind: string): boolean;
95
102
  /** The harness an imported run came from. */
96
103
  export type ImportSource = "claude-code" | "codex" | "pi";
97
104
  /** Where an imported run came from: the harness that ran it, and its own session id. `file` is the server's own record of
@@ -127,7 +134,7 @@ export interface RunRow {
127
134
  readonly costUsd: number | null;
128
135
  readonly metrics: unknown;
129
136
  readonly summary: string | null;
130
- /** An ended run's outcome (RunOutcome), null for a plain completion or a run not ended this way. */
137
+ /** How the run ended beside its state (RunOutcome), null for a plain completion, a failure, or a run not ended. */
131
138
  readonly outcome: RunOutcome | null;
132
139
  /** When the run itself was archived (its agent's archive is read apart); null when it is not. */
133
140
  readonly archivedAt: number | null;
@@ -145,7 +152,7 @@ export interface RunPatch {
145
152
  readonly costUsd?: number | null;
146
153
  readonly metrics?: unknown;
147
154
  readonly summary?: string | null;
148
- /** An ended run's outcome, set in its end commit; null clears it. */
155
+ /** How the run ended (RunOutcome), set in its end commit; null clears it. */
149
156
  readonly outcome?: RunOutcome | null;
150
157
  /** The SHA-256 hashes of the sign-in pointers handed to the run, which the runner writes at its claim (under the epoch
151
158
  * fence); null clears them. While the run runs, a sign-in hashing to one of these cannot be forgotten (sign-ins-store.ts). */
@@ -161,7 +168,9 @@ export type UpdatedRun = RunRow & {
161
168
  };
162
169
  /** A run's launch, as the server writes it at start: its JSON `body` (run-launch.ts: the first input, title, place, effort,
163
170
  * cap, trigger and origin), and `sealed` ciphertext for any secret it carries (sealed with the server's key outside the
164
- * store, AAD `run_launch|<run_id>|sealed`), or none. Written once, in the same transaction as the queued run. */
171
+ * store, AAD `run_launch|<run_id>|sealed`: the MCP credentials its caller handed it, store/seal.ts sealRunMcpAuth), or
172
+ * none. The body is written once, in the same transaction as the queued run. `sealed` is the run's for its life only: a
173
+ * message may replace it (runs.command and runs.reopen, `launchSealed`), and the write that ends the run erases it. */
165
174
  export interface RunLaunchInput {
166
175
  readonly body: unknown;
167
176
  readonly sealed?: Uint8Array | null;
@@ -174,6 +183,11 @@ export interface RunLaunchRow {
174
183
  readonly sealed: Uint8Array | null;
175
184
  readonly createdAt: number;
176
185
  }
186
+ /** A message's new launch secrets (runs.command, runs.reopen): `launchSealed` replaces the run's launch `sealed` in the
187
+ * command's own transaction, so the runner that takes the command reads them, and a run already final takes neither. */
188
+ export interface LaunchSealedWrite {
189
+ readonly launchSealed?: Uint8Array;
190
+ }
177
191
  /** A run imported from another harness's session: an ended run with where it came from, its launch (built from the
178
192
  * session), its cost and metrics, and its transcript as journal batches — the whole thing written in one transaction.
179
193
  * `transcript` is the session as pi-durable write batches (a root conversation and its entries), each batch a commit. */
@@ -205,27 +219,36 @@ export type AlsoRow = {
205
219
  marker: string;
206
220
  };
207
221
  }
208
- /** What the run's end-of-run turn kept: the turn and the proposal checked from it (the run's agent is the row's). */
222
+ /** What the run's end-of-run turn kept: the turn and the proposal checked from it (the run's agent is the row's), and
223
+ * its `round` (absent: 1): the run's first end is round 1, each end after a follow-up opened it again the next. */
209
224
  | {
210
225
  readonly table: "learning_proposals";
211
226
  readonly row: {
212
227
  turn: unknown;
213
228
  proposal: unknown;
229
+ round?: number;
214
230
  };
215
231
  }
216
232
  /** The learning run that grades and merges the kept proposal: a queued run `id` of the run's agent and revision. Started
217
233
  * once: the same id staged again (an end replayed after a crash) adds nothing. */
218
- /** `model`: the grade model (gradeModelOf, as the server resolves it), on the learning run's launch; none, the agent's own. */
234
+ /** `model`: the grade model (gradeModelOf, as the server resolves it), on the learning run's launch; none, the agent's own.
235
+ * `round`: the round it grades (absent: 1), named in its launch. `capUsd`: what the run's cap leaves once everything it
236
+ * spent is counted (learning-end.ts gradeCapOf), the learning run's own cap (its launch's max_cost_usd), so its grade
237
+ * never takes the run past its cap; absent for an uncapped run, whose grade is capped by nothing. */
219
238
  | {
220
239
  readonly table: "learning_run";
221
240
  readonly row: {
222
241
  id: string;
223
242
  model?: string;
243
+ round?: number;
244
+ capUsd?: number;
224
245
  };
225
246
  };
226
247
  /** A run's kept learning (learning_proposals): what its end-of-run turn asked and answered, and the proposal checked from it. */
227
248
  export interface LearningProposal {
228
249
  readonly runId: string;
250
+ /** Which of the run's looks back: 1 for its first end, then one more for each end after a follow-up opened it again. */
251
+ readonly round: number;
229
252
  readonly agentId: string;
230
253
  readonly turn: unknown;
231
254
  readonly proposal: unknown;
@@ -235,9 +258,9 @@ export interface LearningProposal {
235
258
  }
236
259
  /** Learning on the runner: the kept proposals, written only beside a run's end (AlsoRow learning_proposals). */
237
260
  export interface Learning {
238
- /** The run's kept proposal; undefined when its end kept none. */
239
- proposal(runId: string): Promise<LearningProposal | undefined>;
240
- /** The agent's kept proposals, newest first. */
261
+ /** The run's kept proposal of round `round`, else its newest round's; undefined when its end kept none. */
262
+ proposal(runId: string, round?: number): Promise<LearningProposal | undefined>;
263
+ /** The agent's kept proposals (each round of a run one), newest first. */
241
264
  proposals(agentId: string, options?: {
242
265
  limit?: number;
243
266
  }): Promise<LearningProposal[]>;
@@ -249,6 +272,14 @@ export interface Learning {
249
272
  from: number;
250
273
  to: number;
251
274
  }): Promise<LearningSpend[]>;
275
+ /** What was spent beside run `runId` on its behalf, the one figure every cap gate of the run reads with its own
276
+ * sessions (and its grade's cap, learning-end.ts gradeCapOf): each learning run its rounds queued (`beforeRound`: only
277
+ * those of the rounds before it), one that ended at its cost, one not ended at its own cap (the most its grade may
278
+ * take), and one that ended at an unknown cost at that cap too, the most it could have taken. Null: unknown (one with
279
+ * neither). 0 for a run that queued none. */
280
+ spentBeside(runId: string, options?: {
281
+ beforeRound?: number;
282
+ }): Promise<number | null>;
252
283
  }
253
284
  /** One run's learning end as GET /usage's learning meter counts it (Learning.spend). */
254
285
  export interface LearningSpend {
@@ -265,6 +296,8 @@ export interface LearningSpend {
265
296
  export interface StagedTake {
266
297
  readonly command: number;
267
298
  readonly effect: number;
299
+ /** What the command answers, JSON, written with its take (Store.answerOf reads it once). */
300
+ readonly answer?: unknown;
268
301
  }
269
302
  /** What a journal commit writes beside its batches, in its one transaction, under its fence: the run row's patch and rows
270
303
  * beside it, landing with the record `effect` names (required with either: a park's ask, an end's entry), and the
@@ -298,6 +331,104 @@ export interface ChannelPost {
298
331
  readonly body: unknown;
299
332
  readonly nextAt?: number;
300
333
  }
334
+ /** A channel post as the store keeps it (store schema `channel_posts`): `body` its JSON text, byte for byte as it was
335
+ * given; `state` queued (still to send), sending, sent or dropped (given up, `reason` says why). */
336
+ export interface ChannelPostRow {
337
+ readonly id: string;
338
+ readonly channel: string;
339
+ readonly runId: string | null;
340
+ readonly moment: string;
341
+ readonly body: string;
342
+ readonly attempts: number;
343
+ readonly nextAt: number;
344
+ readonly state: "queued" | "sending" | "sent" | "dropped";
345
+ readonly reason: string | null;
346
+ /** Until when a sender's claim holds the post (state sending); null when none does. */
347
+ readonly claimedUntil: number | null;
348
+ /** The try whose claim took the post last, and whose settle may write it (Channels.settle's fence); null once a write
349
+ * outside every claim (a redelivery's landing, a drop, a start's release) took it from that try. */
350
+ readonly claim: string | null;
351
+ readonly createdAt: number;
352
+ }
353
+ /** One try of a channel's post (store schema `channel_attempts`): its HTTP status, or null when none came back. `tryId`
354
+ * names the try, once: a settle written again (its outcome unknown) logs it once. */
355
+ export interface ChannelAttemptRow {
356
+ readonly tryId: string;
357
+ readonly postId: string;
358
+ readonly moment: string;
359
+ readonly at: number;
360
+ readonly statusCode: number | null;
361
+ readonly latencyMs: number;
362
+ readonly error: string | null;
363
+ readonly retryAt: number | null;
364
+ readonly redelivery: boolean;
365
+ }
366
+ /** What a channel was told of a run (store schema `channel_told`): a marker, and when. */
367
+ export interface ChannelToldRow {
368
+ readonly runId: string;
369
+ readonly marker: string;
370
+ readonly at: number;
371
+ }
372
+ /** A channel's outbox (channel_posts), the tries of its posts (channel_attempts) and what it told each run
373
+ * (channel_told), for a channel the server sends itself (the outbound webhook). */
374
+ export interface Channels {
375
+ /** Queues `post` (by its id: one already there is left as it is) and, in the same transaction, `told` (each marker of
376
+ * its run; `replacing`, a prefix, drops that run's markers with it first). Answers whether the post is new. */
377
+ post(post: {
378
+ id: string;
379
+ channel: string;
380
+ runId?: string | null;
381
+ moment: string;
382
+ body: string;
383
+ nextAt: number;
384
+ }, told?: {
385
+ runId: string;
386
+ marker: string;
387
+ replacing?: string;
388
+ }): Promise<boolean>;
389
+ /** The post `id`, or undefined. */
390
+ get(id: string): Promise<ChannelPostRow | undefined>;
391
+ /** `channel`'s posts still to send (queued or sending), oldest first. */
392
+ queued(channel: string): Promise<ChannelPostRow[]>;
393
+ /** The post `id` claimed by the try `token` until `now + leaseMs` (state sending, `claim` the token), by
394
+ * compare-and-set: it is queued and due (`next_at` at or before `now`), or a claim on it ran out. The post as the claim
395
+ * took it, for the one caller that took it; undefined for any other at the same time, and for a post sent, dropped or
396
+ * held. */
397
+ claim(id: string, now: number, leaseMs: number, token: string): Promise<ChannelPostRow | undefined>;
398
+ /** Every claim on `channel`'s posts let go (sending back to queued, no try's claim): a server's start, when it is the
399
+ * store's one server and no try of an earlier one is still out. Answers how many. */
400
+ release(channel: string): Promise<number>;
401
+ /** A try's outcome: the post's new state (`to`, none for a try that leaves it as it is), with `attempt` added to its
402
+ * channel's tries in the same transaction, once by its tryId. Fenced by `claim`, the token of the claim that made the
403
+ * try: the state is written only while the post still holds that claim (compare-and-set), so a write that comes late,
404
+ * after a newer claim, a redelivery's landing or a drop, changes nothing; written again with the same fence (its
405
+ * outcome unknown), it writes the same row. With no `claim`, the state is written whatever holds the post, and the
406
+ * post's claim goes with it (a redelivery's landing: sent is final). Answers whether `to` was written; a try that
407
+ * wrote nothing is logged with no retry_at. The channel keeps its newest `kept` tries (50 by default), and of its sent
408
+ * or dropped posts only those a kept try names or `sending` lists (a try of it still in flight, which a redelivery may
409
+ * send again). */
410
+ settle(id: string, to: {
411
+ state: ChannelPostRow["state"];
412
+ attempts?: number;
413
+ nextAt?: number;
414
+ reason?: string | null;
415
+ } | undefined, attempt?: ChannelAttemptRow, options?: {
416
+ kept?: number;
417
+ sending?: readonly string[];
418
+ claim?: string;
419
+ }): Promise<boolean>;
420
+ /** Every queued or sending post of `channel` dropped, `reason` kept on each, no try's claim left on it: how many. */
421
+ dropAll(channel: string, reason: string): Promise<number>;
422
+ /** `channel`'s newest tries, newest first, at most `limit`. */
423
+ attempts(channel: string, limit: number): Promise<ChannelAttemptRow[]>;
424
+ /** What `channel` told: every run's markers, or `runId`'s. */
425
+ told(channel: string, runId?: string): Promise<ChannelToldRow[]>;
426
+ /** The told rows given go. */
427
+ forget(channel: string, rows: readonly {
428
+ runId: string;
429
+ marker: string;
430
+ }[]): Promise<void>;
431
+ }
301
432
  /** A trigger as a template or an upgrade gives it. `scopes`: the (kind, scope) keys it answers, rows only while enabled. */
302
433
  export interface TriggerDef {
303
434
  readonly id: string;
@@ -455,6 +586,8 @@ export interface Agents {
455
586
  /** The agent an external reference ("<source>:<kind>:<id>") maps to (Runs.createInline), or undefined before its first
456
587
  * run. */
457
588
  byExternal(ref: string): Promise<AgentRow | undefined>;
589
+ /** Whether the agent already has the revision that maps `version` of its owning system (one row looked up, no bodies read). */
590
+ hasExternalVersion(agentId: string, version: string): Promise<boolean>;
458
591
  list(options?: {
459
592
  archived?: boolean;
460
593
  }): Promise<AgentRow[]>;
@@ -643,16 +776,22 @@ export interface Runs {
643
776
  }): Promise<RunRow[]>;
644
777
  /** Archives the run (its own archive time), or unarchives it: idempotent. */
645
778
  archive(runId: string, archived: boolean): Promise<void>;
646
- /** A person's follow-up to a run that ended completed: in one transaction, the run goes back to running with no runner
779
+ /** A person's follow-up to a run that ended completed, or that a person stopped: in one transaction, the run goes back to running with no runner
647
780
  * (released, so a runner claims it at once by the claimable rule's released branch), its end's own fields cleared
648
781
  * (ended_at, summary, outcome, its waits) and everything it did kept (its epoch, its journal, its cost and metrics,
649
782
  * so its next turn is booked on top of what it spent), and `command` (the follow-up's steer) is written untaken for it.
650
- * Only an agentic run that ended completed (state 'ended'), not imported and not a learning run, reopens: a workflow,
651
- * a failed, stopped or cancelled run, any other, or none is RunFinal, and nothing is written. */
783
+ * Only an agentic run that ended completed (state 'ended') or that a person stopped (state 'stopped', outcome
784
+ * 'stopped'), not imported and not a learning run, reopens: a workflow, a failed or cancelled run, any other, or none
785
+ * is RunFinal, and nothing is written. */
652
786
  reopen(runId: string, command: {
653
787
  kind: string;
654
788
  body?: unknown;
655
- }): Promise<Command>;
789
+ }, options?: LaunchSealedWrite): Promise<Command>;
790
+ /** Wakes a parked run: its wake_at set to now on the deadlines' clock, so a runner claims it at its next poll (the
791
+ * claimable rule's wake branch) and its loop reads what it waits on again. True when the run was parked; a run in any
792
+ * other state (or none) is left as it is, false. Its claim, if one holds it while it parks, is let go as before: the
793
+ * release sets wake_at as the loop's end says. */
794
+ wake(runId: string): Promise<boolean>;
656
795
  /** The runs a runner may claim, oldest first: queued; parked with an untaken command or its wake_at passed; running with
657
796
  * no runner (released at a runner's shutdown: it stays running, a run that started keeps that fact) or its claim run
658
797
  * out. */
@@ -663,6 +802,10 @@ export interface Runs {
663
802
  * and fenced by), never a reader's; undefined when no claim holds it (none, released, or run out) or there is no
664
803
  * such run. */
665
804
  heldAt(runId: string): Promise<number | undefined>;
805
+ /** The claims `runner` holds now (its name on the run's row, its lease not run out on the store's clock), each with the
806
+ * epoch it holds at: what a runner reads back when a claim or release commit was answered Unanswered, to learn
807
+ * whether it landed. `from` is "running" (the claim's own `from` is not kept). */
808
+ claimsOf(runner: string): Promise<Claim[]>;
666
809
  /** Claims up to `k` claimable runs for `runner`, oldest first, in one transaction: each at its own epoch + 1, with its
667
810
  * `from`. A runner fills its free loops with one call. */
668
811
  claimMany(runner: string, k: number, options?: {
@@ -680,6 +823,41 @@ export interface Runs {
680
823
  readonly take?: readonly number[];
681
824
  readonly signInSettleMs?: number;
682
825
  }): Promise<UpdatedRun>;
826
+ /** The run changes after `cursor` (undefined: from the feed's start), oldest first, at most `limit` (default
827
+ * RUN_CHANGES_PAGE), and the cursor to read on from (`next`; the one given when nothing is new). A change is a run
828
+ * reaching a final state, or its runner letting it go (parked, or running with no runner), recorded by the write that
829
+ * made it, in that write's own transaction, with the row as that write left it.
830
+ *
831
+ * The guarantee: every change is read exactly once by a reader that reads on from each `next` it was handed. None is
832
+ * skipped, even one committed after a change numbered above it was already read (concurrent writers): `next` never
833
+ * passes a change a transaction still in flight may yet commit (a watermark; a store with one writer commits in the
834
+ * order it numbers, so its watermark is its last change). None is read twice from a later cursor. The cursor is the
835
+ * store's own: never a time, so writes in one millisecond are each read. */
836
+ changedSince(cursor: RunChangeCursor | undefined, options?: {
837
+ limit?: number;
838
+ }): Promise<RunChanges>;
839
+ /** The feed's head, in one read: the cursor a reader holds once it has read on until a page comes back empty, so one
840
+ * that starts here reads only the changes made after. It keeps changedSince's watermark: never past a change a
841
+ * transaction still in flight may yet commit. */
842
+ changesHead(): Promise<RunChangeCursor>;
843
+ }
844
+ /** A position in the run-change feed (Runs.changedSince): opaque, the store's own; only one it handed back is valid. */
845
+ export type RunChangeCursor = string;
846
+ /** The most run changes one read returns unless asked for fewer. */
847
+ export declare const RUN_CHANGES_PAGE = 200;
848
+ /** A run change (Runs.changedSince): the run, and its row as the write that made the change left it. */
849
+ export interface RunChange {
850
+ readonly id: string;
851
+ readonly state: RunState;
852
+ /** When it ended (ms): set for a final state, null otherwise. */
853
+ readonly endedAt: number | null;
854
+ readonly epoch: number;
855
+ readonly runner: string | null;
856
+ }
857
+ /** One read of the run-change feed: its changes, oldest first, and the cursor to read on from. */
858
+ export interface RunChanges {
859
+ readonly changes: readonly RunChange[];
860
+ readonly next: RunChangeCursor;
683
861
  }
684
862
  /** A saved MCP server: its listed tools (each with whether it can be granted, and why not), the owner's prices, and its
685
863
  * credential sealed (store/seal.ts): bytes the store never opens. `tools` and `prices` are JSON. */
@@ -707,6 +885,9 @@ export interface McpServerRow {
707
885
  * never by its own clock against the set's expires_at, which the writer stamped on its clock. Null when the writer
708
886
  * gave no measure of the token's life. */
709
887
  readonly tokenLeftMs: number | null;
888
+ /** The token's end as the store stamped it (token_until), read in the same snapshot as `sealed`: the end of the very
889
+ * token the sealed set holds. A refresh by any claim moves it. Null as tokenLeftMs. */
890
+ readonly tokenUntil: number | null;
710
891
  readonly createdAt: number;
711
892
  readonly updatedAt: number;
712
893
  /** When the tools were last listed (ms): a refresh moves this, not updatedAt, so a refresh is not read as an owner edit.
@@ -716,6 +897,17 @@ export interface McpServerRow {
716
897
  * no credential. */
717
898
  readonly credentialChangedAt: number | null;
718
899
  }
900
+ /** A saved MCP server's stamp (Mcp.stamp): its url and auth, when its credential last changed (credentialChangedAt), and
901
+ * its access token's time left by the store's own clock (tokenLeftMs), as on its row. */
902
+ export interface McpServerStamp {
903
+ readonly url: string;
904
+ readonly auth: string;
905
+ readonly credentialChangedAt: number | null;
906
+ readonly tokenLeftMs: number | null;
907
+ /** Its access token's end as the store stamped it (token_until, the store's clock): a refresh by any claim moves it, so a
908
+ * claim that opened the row at one end knows the token it holds is not the row's once this differs. */
909
+ readonly tokenUntil: number | null;
910
+ }
719
911
  /** A run's MCP pin: what it may call, per granted server (url, tools, prices), written once at its first claim. */
720
912
  export interface McpPinRow {
721
913
  readonly runId: string;
@@ -740,6 +932,12 @@ export type McpCredentialMark = {
740
932
  readonly sealed: boolean;
741
933
  readonly changedAt: number | null;
742
934
  } | null;
935
+ /** The row a removal deleted, as the statement that deleted it saw it: the address and the sealed credential as they were
936
+ * at that instant (a token refresh landing earlier is in it, one landing later finds no row to keep). */
937
+ export type McpRemoved = {
938
+ readonly url: string;
939
+ readonly sealed: Uint8Array | null;
940
+ };
743
941
  /** The fields of a server's write (Mcp.put). */
744
942
  export type McpServerWrite = {
745
943
  name: string;
@@ -784,13 +982,18 @@ export interface Mcp {
784
982
  listedAt?: number;
785
983
  updatedAt?: number;
786
984
  }, seen: Uint8Array | null): Promise<McpServerRow | undefined>;
787
- remove(name: string): Promise<void>;
985
+ /** Deletes the row, answering what it held as it went (McpRemoved); undefined when there was none. */
986
+ remove(name: string): Promise<McpRemoved | undefined>;
788
987
  /** remove(), only while the server's credential is still `expected` (its mark as the remover read it), compared and
789
- * deleted in one statement. False, deleting nothing, when it is not (or the server is gone). */
790
- removeIfCredential(name: string, expected: NonNullable<McpCredentialMark>): Promise<boolean>;
988
+ * deleted in one statement. Undefined, deleting nothing, when it is not (or the server is gone). */
989
+ removeIfCredential(name: string, expected: NonNullable<McpCredentialMark>): Promise<McpRemoved | undefined>;
791
990
  /** The registry's rows, by name. */
792
991
  servers(): Promise<McpServerRow[]>;
793
992
  server(name: string): Promise<McpServerRow | undefined>;
993
+ /** The server's stamp, read cheaply (no tools, no sealed bytes): what a claimed run checks before each call
994
+ * (runner/mcp-claim.ts) to see its credential removed, replaced or moved, or its access token near its end. Undefined
995
+ * when it is no longer saved. */
996
+ stamp(name: string): Promise<McpServerStamp | undefined>;
794
997
  /** The run's pin, or none (a run that grants no MCP tool has none). */
795
998
  pin(runId: string): Promise<McpPinRow | undefined>;
796
999
  /** Writes the run's pin under `claim` unless it has one, in one transaction with the claim's epoch fence, and answers the
@@ -843,6 +1046,12 @@ export interface Settings {
843
1046
  /** Saves `value` under `key` only when the key has no row yet, in one statement, so of two processes that race the first
844
1047
  * wins; the value saved under it after (this one, or the one there before). */
845
1048
  putIfAbsent(key: string, value: unknown): Promise<unknown>;
1049
+ /** Saves `value` under `key` only while its row still holds `was` (as get read it), in one statement: a compare-and-set,
1050
+ * so of two writers that read one row only one replaces it. True when it was replaced; false, with nothing written,
1051
+ * when the row changed since or is gone. */
1052
+ replaceIf(key: string, was: unknown, value: unknown): Promise<boolean>;
1053
+ /** The key's row goes only while it still holds `was`, in one statement: true when it went. */
1054
+ removeIf(key: string, was: unknown): Promise<boolean>;
846
1055
  /** The key's row goes; a key with no row is left as it is. */
847
1056
  remove(key: string): Promise<void>;
848
1057
  /** Every setting, by key. */
@@ -896,12 +1105,71 @@ export interface ComputerLedgerRow {
896
1105
  export interface ComputerLedger {
897
1106
  /** Saves `labels` and `detail` for `provider`'s session `sessionId`, inserted or replaced in place. */
898
1107
  put(provider: string, sessionId: string, labels: Readonly<Record<string, string>>, detail: Readonly<Record<string, unknown>>): Promise<void>;
1108
+ /** Saves `labels` and `detail` for the session only while no row is kept for it, in one statement (two writers never
1109
+ * both claim it): true when it was saved; false, with nothing written, when a row was there. */
1110
+ claim(provider: string, sessionId: string, labels: Readonly<Record<string, string>>, detail: Readonly<Record<string, unknown>>): Promise<boolean>;
899
1111
  /** The session's row, or undefined when none is kept. */
900
1112
  get(provider: string, sessionId: string): Promise<ComputerLedgerRow | undefined>;
901
1113
  /** Every session of `provider`, by its id. */
902
1114
  list(provider: string): Promise<ComputerLedgerRow[]>;
903
1115
  /** The session's row goes. */
904
1116
  remove(provider: string, sessionId: string): Promise<void>;
1117
+ /** Replaces the session's `labels` and `detail` only while its row still holds `was`'s, in one statement (a
1118
+ * compare-and-set, so two writers that read one row never both write it): true when it was replaced; false, with
1119
+ * nothing written, when the row changed since or is gone. */
1120
+ swap(provider: string, sessionId: string, was: {
1121
+ readonly labels: Readonly<Record<string, string>>;
1122
+ readonly detail: Readonly<Record<string, unknown>>;
1123
+ }, labels: Readonly<Record<string, string>>, detail: Readonly<Record<string, unknown>>): Promise<boolean>;
1124
+ }
1125
+ /** A person's own machine paired with this server (spec/computer/attach.md, store schema `paired_computers`): its driver
1126
+ * dials the attach socket with the token pairing gave it, of which the store keeps only the SHA-256. */
1127
+ export interface PairedComputerRow {
1128
+ readonly id: string;
1129
+ /** What the person calls it. */
1130
+ readonly name: string;
1131
+ /** Its driver's last hello: at pairing, then each socket's (kind, os, groups, features). Kind and os stay what it
1132
+ * paired as, since a socket that says others is refused at hello; groups follow its driver, so an updated driver's
1133
+ * new groups serve the kinds they make. */
1134
+ readonly hello: Readonly<Record<string, unknown>>;
1135
+ /** The driver build its last hello named. */
1136
+ readonly driver: string;
1137
+ readonly labels: Readonly<Record<string, string>>;
1138
+ /** The pairing (addCode's id) whose code made it. */
1139
+ readonly pairingId: string;
1140
+ readonly createdAt: number;
1141
+ /** When its last socket said hello; null before its first. */
1142
+ readonly seenAt: number | null;
1143
+ /** When it was removed: its token no longer dials. Null while it is paired. */
1144
+ readonly revokedAt: number | null;
1145
+ }
1146
+ /** What pairing records for a new computer: its row's own fields, and its token's SHA-256. */
1147
+ export interface NewPairedComputer {
1148
+ readonly id: string;
1149
+ readonly name: string;
1150
+ readonly hello: Readonly<Record<string, unknown>>;
1151
+ readonly labels: Readonly<Record<string, string>>;
1152
+ readonly tokenSha256: string;
1153
+ }
1154
+ /** Paired computers and the pairing codes that make them (store schema `paired_computers`, `pairing_codes`). A code is
1155
+ * kept by its SHA-256 alone, good once until its expiry; a computer by its token's SHA-256. */
1156
+ export interface PairedComputers {
1157
+ /** Keeps a new code's SHA-256 until `expiresAt`, under the pairing `id` the computer it makes keeps. Codes past their
1158
+ * expiry go in the same write. */
1159
+ addCode(id: string, codeSha256: string, expiresAt: number): Promise<void>;
1160
+ /** Burns the code and records `computer`, in one transaction: false, with nothing written, when no unexpired code has
1161
+ * that SHA-256 (wrong, used or expired alike). */
1162
+ pair(codeSha256: string, computer: NewPairedComputer): Promise<boolean>;
1163
+ /** The computer's row, removed or not; undefined when no computer has that id. */
1164
+ get(id: string): Promise<PairedComputerRow | undefined>;
1165
+ /** The paired (not removed) computer whose token has this SHA-256. */
1166
+ byToken(tokenSha256: string): Promise<PairedComputerRow | undefined>;
1167
+ /** Every paired computer not removed, oldest first. */
1168
+ list(): Promise<PairedComputerRow[]>;
1169
+ /** A socket of the computer said `hello` now: kept as its hello, and its build (`hello.version`) as its driver. */
1170
+ seen(id: string, hello: Readonly<Record<string, unknown>>): Promise<void>;
1171
+ /** Removes the computer: its token dials no more. False when it was not paired (unknown, or removed already). */
1172
+ revoke(id: string): Promise<boolean>;
905
1173
  }
906
1174
  /** A trigger source's sealed setting as a row (store schema `trigger_settings`): its adapter, scope ("server" for the one
907
1175
  * server-wide set, or a trigger's id for its own), field, and the value sealed (store/seal.ts) under AAD
@@ -1060,9 +1328,12 @@ export interface Live {
1060
1328
  export type ViewerKind = "browser" | "desktop" | "phone";
1061
1329
  /** One open computer session's viewer as the store keeps it: one row per (run, computer kind, session tag), its token
1062
1330
  * sealed (sealedAt.liveViewer), `at` the store's clock when it was put, `runner` the claim's holder. */
1331
+ /** `host`: where the viewer answers when its runner is on another host than the server (live-reach.ts); none, the
1332
+ * server's own machine (loopback). */
1063
1333
  export type LiveViewerRow = {
1064
1334
  kind: ViewerKind;
1065
1335
  tag: string;
1336
+ host?: string;
1066
1337
  port: number;
1067
1338
  id: string;
1068
1339
  sealed: Uint8Array;
@@ -1078,6 +1349,7 @@ export interface LiveViewers {
1078
1349
  put(claim: Claim, viewer: {
1079
1350
  kind: ViewerKind;
1080
1351
  tag: string;
1352
+ host?: string;
1081
1353
  port: number;
1082
1354
  id: string;
1083
1355
  sealed: Uint8Array;
@@ -1112,8 +1384,12 @@ export interface Store {
1112
1384
  readonly sealedKeys: SealedKeys;
1113
1385
  /** The labels of the sessions a provider runs with none of its own (a phone provider's). */
1114
1386
  readonly computerLedger: ComputerLedger;
1387
+ /** The people's own machines paired with this server, and the codes that pair them (spec/computer/attach.md). */
1388
+ readonly pairedComputers: PairedComputers;
1115
1389
  /** Each trigger source's sealed settings (design 2.1): a value per adapter, scope and field. */
1116
1390
  readonly triggerSettings: TriggerSettings;
1391
+ /** The outbox of a channel the server sends itself, its tries and what it told each run. */
1392
+ readonly channels: Channels;
1117
1393
  /** MCP OAuth sign-ins in flight (design 2.1): one row per pending sign-in, its verifier sealed. */
1118
1394
  readonly mcpOauth: McpOauth;
1119
1395
  /** Each agent's saved browser sign-ins (design 2.1): one live row per agent and provider, its pointer sealed, with the
@@ -1146,6 +1422,15 @@ export interface Store {
1146
1422
  /** The run's journal: pi-durable's Storage for this one run, every commit fenced by the claim (store/journal). Its commit
1147
1423
  * holds the store's one connection while it runs, so it awaits nothing but its own statements, under a deadline. */
1148
1424
  journal(claim: Claim): Journal;
1425
+ /** The store this one reads from: itself, but for the store a snapshot hands its callback, which is a new object at each
1426
+ * snapshot and gives the store it was taken of. What a reader keeps per store (a served answer's cache) is kept by this. */
1427
+ readonly origin: Store;
1428
+ /** `read` against this store as it stood at one moment: every read it makes sees one snapshot (one read-only transaction),
1429
+ * so a write that lands meanwhile, a runner's commit among them, is in all of its reads or in none. The store it is given
1430
+ * only reads. On SQLite the transaction holds this process's one connection until `read` settles, so `read` awaits the
1431
+ * store it is given and nothing else: never this store (that waits for the snapshot, which waits for it), and no
1432
+ * network or disk. Its deadline is the transaction's (StoreDeadline). */
1433
+ snapshot<T>(read: (store: Store) => Promise<T>): Promise<T>;
1149
1434
  /** A run's journal opened for reading only (JournalReads): the server's reads of a run, which hold no claim. Its reads
1150
1435
  * alone, never a commit; a read never fences, so it needs no claim. A run with no journal yet reads as empty. */
1151
1436
  readJournal(runId: string): JournalReads;
@@ -1167,7 +1452,7 @@ export interface Store {
1167
1452
  command(runId: string, command: {
1168
1453
  kind: string;
1169
1454
  body?: unknown;
1170
- }): Promise<Command>;
1455
+ }, options?: LaunchSealedWrite): Promise<Command>;
1171
1456
  /** The run's commands with an id above `after`, in id order. */
1172
1457
  commands(runId: string, after: number): Promise<Command[]>;
1173
1458
  /** Every run's commands with an id above its own cursor, in id order, in one read: a runner's poll of all it holds. A run
@@ -1179,6 +1464,19 @@ export interface Store {
1179
1464
  /** Marks the command taken (or refused, with `reason`) under the claim, once: a command already taken stays as it was.
1180
1465
  * Fenced on a stale claim. */
1181
1466
  take(claim: Claim, commandId: number, outcome?: "taken" | "refused", reason?: string): Promise<void>;
1467
+ /** What the run's command answered, read once: the row's answer is cleared in the same transaction, so its bytes do not
1468
+ * stay in the store. Undefined when the row is untaken, refused, taken with no answer, already read, or not the run's. */
1469
+ answerOf(runId: string, commandId: number): Promise<{
1470
+ readonly value: unknown;
1471
+ } | undefined>;
1472
+ /** Tells `listener` when a command of a run in this store is written ("written", after command() commits) or taken,
1473
+ * refused or answered ("answered": a take, a run update that takes, a journal commit that takes or ends the run).
1474
+ * A hint to read now, for handles in this process only: a row another process writes wakes nothing here, the reader's
1475
+ * poll finds it. Called after the commit, asynchronously; a listener's throw is swallowed. Answers the unsubscribe. */
1476
+ watchCommands(listener: (event: {
1477
+ readonly runId: string;
1478
+ readonly what: "written" | "answered";
1479
+ }) => void): () => void;
1182
1480
  /** Counts a failed resume on the untaken command that woke the run, under the claim, and answers its tries; the command
1183
1481
  * stays untaken. Fenced on a stale claim; StoreConstraint when the command is taken or not the run's. */
1184
1482
  retry(claim: Claim, commandId: number): Promise<number>;
@@ -1252,21 +1550,32 @@ export declare class StoreLaunchMissing extends Error {
1252
1550
  export type ConstraintRule = "check" | "unique" | "foreign_key" | "not_null";
1253
1551
  /** A row the store's constraints refuse (a duplicate id or name, a revision of an unknown agent, a bad kind). When the
1254
1552
  * database said which rule refused it, `rule`; for a duplicate, `unique`: the table and the columns whose values were
1255
- * taken already (a primary key's or a UNIQUE's), so a caller tells "the name is taken" from any other refusal. */
1553
+ * taken already (a primary key's or a UNIQUE's), so a caller tells "the name is taken" from any other refusal. `index`:
1554
+ * the unique index (or constraint) the database named, when it named one: an index on an expression (one answer per
1555
+ * approval, schema.ts ONE_ANSWER_INDEX) has no plain columns to name, only its name. */
1256
1556
  export declare class StoreConstraint extends Error {
1257
1557
  readonly rule?: ConstraintRule;
1258
1558
  readonly unique?: {
1259
1559
  readonly table: string;
1260
1560
  readonly columns: readonly string[];
1261
1561
  };
1562
+ readonly index?: string;
1262
1563
  constructor(message: string, details?: {
1263
1564
  rule?: ConstraintRule;
1264
1565
  unique?: {
1265
1566
  table: string;
1266
1567
  columns: readonly string[];
1267
1568
  };
1569
+ index?: string;
1268
1570
  });
1269
1571
  }
1572
+ /** An approve or deny command refused because its approval is answered already: an unrefused answer naming it was
1573
+ * written first (the one-answer index, schema.ts ONE_ANSWER_INDEX), so this one lost. Both stores raise it from that
1574
+ * index's unique violation alone, at the command's insert; any other refusal stays a plain StoreConstraint. Its caller
1575
+ * reads the answer that won: approve's 409 already_answered, or nothing to do. */
1576
+ export declare class AnswerTaken extends StoreConstraint {
1577
+ constructor(message: string, index: string);
1578
+ }
1270
1579
  /** An agent's current revision is not the one a conditional write expected (addRevision's `ifCurrent`): another write
1271
1580
  * moved it first. `current` is the agent's current revision now. Nothing was written. */
1272
1581
  export declare class RevisionMoved extends Error {