@demlik/tea 0.13.0 → 0.15.0

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 (373) hide show
  1. package/README.md +11 -9
  2. package/dist/agent/index.d.ts +638 -45
  3. package/dist/agent/index.js +9 -19
  4. package/dist/{chunk-RH5EFRVJ.js → chunk-22POWGFA.js} +31 -5
  5. package/dist/chunk-22POWGFA.js.map +1 -0
  6. package/dist/{chunk-DMYGQB4O.js → chunk-3B5X7SBB.js} +23 -6
  7. package/dist/chunk-3B5X7SBB.js.map +1 -0
  8. package/dist/chunk-66PY5WYF.js +1816 -0
  9. package/dist/chunk-66PY5WYF.js.map +1 -0
  10. package/dist/{chunk-25LBDCBC.js → chunk-6IQPODUF.js} +2 -2
  11. package/dist/{chunk-25LBDCBC.js.map → chunk-6IQPODUF.js.map} +1 -1
  12. package/dist/chunk-AYS5N6WY.js +505 -0
  13. package/dist/chunk-AYS5N6WY.js.map +1 -0
  14. package/dist/{chunk-EWJP3YYP.js → chunk-HWVW4AXC.js} +3 -3
  15. package/dist/chunk-HWVW4AXC.js.map +1 -0
  16. package/dist/{chunk-O4MVQTEJ.js → chunk-L3TND7LA.js} +20 -16
  17. package/dist/chunk-L3TND7LA.js.map +1 -0
  18. package/dist/{chunk-J6527VRQ.js → chunk-LFZUK6J2.js} +3 -3
  19. package/dist/chunk-LFZUK6J2.js.map +1 -0
  20. package/dist/{chunk-D736QUGF.js → chunk-MYXFNWAJ.js} +4 -5
  21. package/dist/chunk-MYXFNWAJ.js.map +1 -0
  22. package/dist/{chunk-K575PT4S.js → chunk-PR6TB3BL.js} +15 -4
  23. package/dist/chunk-PR6TB3BL.js.map +1 -0
  24. package/dist/{chunk-YUXP55T2.js → chunk-Q5CQTBFA.js} +57 -7
  25. package/dist/chunk-Q5CQTBFA.js.map +1 -0
  26. package/dist/{batch-window/index.js → chunk-QPEVCJ5Q.js} +4 -8
  27. package/dist/chunk-QPEVCJ5Q.js.map +1 -0
  28. package/dist/chunk-TCLBCERH.js +1480 -0
  29. package/dist/chunk-TCLBCERH.js.map +1 -0
  30. package/dist/{chunk-FV3Z5MBE.js → chunk-TXN2KFHF.js} +14 -4
  31. package/dist/chunk-TXN2KFHF.js.map +1 -0
  32. package/dist/{chunk-MUUROGIH.js → chunk-V46HSVCK.js} +62 -12
  33. package/dist/chunk-V46HSVCK.js.map +1 -0
  34. package/dist/{chunk-Q2UM7BXU.js → chunk-VBDU4JL6.js} +2 -2
  35. package/dist/chunk-VBDU4JL6.js.map +1 -0
  36. package/dist/{chunk-ZVJZ72HY.js → chunk-VTQI2NHP.js} +25 -11
  37. package/dist/chunk-VTQI2NHP.js.map +1 -0
  38. package/dist/{core-Co0LWkIA.d.ts → core-DnzqWy6u.d.ts} +72 -23
  39. package/dist/devtools/index.d.ts +2 -2
  40. package/dist/devtools/index.js +207 -2
  41. package/dist/devtools/index.js.map +1 -1
  42. package/dist/do/index.d.ts +43 -29
  43. package/dist/do/index.js +36 -25
  44. package/dist/do/index.js.map +1 -1
  45. package/dist/{durable-effects-C6uwzjb5.d.ts → durable-effects-CWzA-o2B.d.ts} +2 -2
  46. package/dist/extension/index.d.ts +300 -3
  47. package/dist/extension/index.js +596 -5
  48. package/dist/extension/index.js.map +1 -1
  49. package/dist/flow/index.d.ts +1284 -0
  50. package/dist/flow/index.js +732 -0
  51. package/dist/flow/index.js.map +1 -0
  52. package/dist/idempotency/index.d.ts +90 -116
  53. package/dist/idempotency/index.js +4 -1
  54. package/dist/index-Bc40JWVl.d.ts +131 -0
  55. package/dist/{batch-window/index.d.ts → index-C2DwkjlP.d.ts} +7 -12
  56. package/dist/index-CA_7I5g9.d.ts +806 -0
  57. package/dist/index-CSyMYDAB.d.ts +69 -0
  58. package/dist/{fan-out/index.d.ts → index-CuNO9m8i.d.ts} +7 -9
  59. package/dist/{debounce/index.d.ts → index-DHSUmQTR.d.ts} +7 -7
  60. package/dist/{recorder/index.d.ts → index-DrIRb_Ch.d.ts} +4 -7
  61. package/dist/index-HSYgG2Yt.d.ts +380 -0
  62. package/dist/{monitored-run/index.d.ts → index-KXqTRJyb.d.ts} +37 -13
  63. package/dist/{snapshot/index.d.ts → index-ZCMhnVKN.d.ts} +15 -78
  64. package/dist/index.d.ts +771 -6
  65. package/dist/index.js +1 -2
  66. package/dist/jev/index.d.ts +646 -0
  67. package/dist/jev/index.js +485 -0
  68. package/dist/jev/index.js.map +1 -0
  69. package/dist/machine-DGlPWCWI.d.ts +1781 -0
  70. package/dist/machine-viz/index.d.ts +1 -1
  71. package/dist/machine-viz/index.js +12 -5
  72. package/dist/machine-viz/index.js.map +1 -1
  73. package/dist/mem/index.d.ts +18 -3
  74. package/dist/mem/index.js +22 -2
  75. package/dist/mem/index.js.map +1 -1
  76. package/dist/node/index.d.ts +104 -6
  77. package/dist/node/index.js +132 -9
  78. package/dist/node/index.js.map +1 -1
  79. package/dist/{paginator → paginate}/index.d.ts +140 -6
  80. package/dist/paginate/index.js +7 -0
  81. package/dist/parity/index.d.ts +4 -10
  82. package/dist/parity/index.js +4 -7
  83. package/dist/parity/index.js.map +1 -1
  84. package/dist/pbt/index.d.ts +247 -5
  85. package/dist/pbt/index.js +124 -5
  86. package/dist/pbt/index.js.map +1 -1
  87. package/dist/{trace-replay → persistence}/index.d.ts +7 -5
  88. package/dist/persistence/index.js +6 -0
  89. package/dist/{protocol-B5YmJr0d.d.ts → protocol-D8VbH-VH.d.ts} +10 -1
  90. package/dist/react/index.d.ts +2 -2
  91. package/dist/react/index.js +1 -2
  92. package/dist/react/index.js.map +1 -1
  93. package/dist/resilience/index.d.ts +744 -0
  94. package/dist/resilience/index.js +657 -0
  95. package/dist/resilience/index.js.map +1 -0
  96. package/dist/retry-backoff/index.d.ts +3 -2
  97. package/dist/retry-backoff/index.js +1 -1
  98. package/dist/runtime-types-CMF13BBh.d.ts +998 -0
  99. package/dist/testing/index.d.ts +147 -3
  100. package/dist/testing/index.js +95 -3
  101. package/dist/testing/index.js.map +1 -1
  102. package/dist/{throttled-input → timing}/index.d.ts +143 -12
  103. package/dist/{throttled-input → timing}/index.js +57 -12
  104. package/dist/timing/index.js.map +1 -0
  105. package/dist/{types-XS_miRnB.d.ts → types-BseNPIhr.d.ts} +1 -1
  106. package/dist/work-queue/index.d.ts +130 -54
  107. package/dist/work-queue/index.js +3 -2
  108. package/dist/work-queue/index.js.map +1 -1
  109. package/package.json +45 -218
  110. package/dist/authed-call/index.d.ts +0 -120
  111. package/dist/authed-call/index.js +0 -134
  112. package/dist/authed-call/index.js.map +0 -1
  113. package/dist/await-terminal/index.d.ts +0 -101
  114. package/dist/await-terminal/index.js +0 -76
  115. package/dist/await-terminal/index.js.map +0 -1
  116. package/dist/batch-window/index.js.map +0 -1
  117. package/dist/cache/index.d.ts +0 -152
  118. package/dist/cache/index.js +0 -8
  119. package/dist/chart/index.d.ts +0 -218
  120. package/dist/chart/index.js +0 -16
  121. package/dist/chart/index.js.map +0 -1
  122. package/dist/chart/inspect/index.d.ts +0 -86
  123. package/dist/chart/inspect/index.js +0 -5
  124. package/dist/chart/inspect/react.d.ts +0 -113
  125. package/dist/chart/inspect/react.js +0 -11
  126. package/dist/chart/inspect/react.js.map +0 -1
  127. package/dist/chart/inspect/styles.css +0 -286
  128. package/dist/chart/lane/index.d.ts +0 -362
  129. package/dist/chart/lane/index.js +0 -9
  130. package/dist/chart/lane/index.js.map +0 -1
  131. package/dist/chart/lane/react.d.ts +0 -84
  132. package/dist/chart/lane/react.js +0 -559
  133. package/dist/chart/lane/react.js.map +0 -1
  134. package/dist/chart/lane/server.d.ts +0 -148
  135. package/dist/chart/lane/server.js +0 -209
  136. package/dist/chart/lane/server.js.map +0 -1
  137. package/dist/chart/lane/styles.css +0 -498
  138. package/dist/chart/lane/viewer/assets/abnfDiagram-N423BO3Z-C729LI31.js +0 -1
  139. package/dist/chart/lane/viewer/assets/architectureDiagram-T3A2C74G-C729LI31.js +0 -1
  140. package/dist/chart/lane/viewer/assets/blockDiagram-VBNYF7ZC-C729LI31.js +0 -1
  141. package/dist/chart/lane/viewer/assets/c4Diagram-5PPSVZJV-C729LI31.js +0 -1
  142. package/dist/chart/lane/viewer/assets/chunk-2GRJ4B5K-HdDf8SI3.js +0 -1
  143. package/dist/chart/lane/viewer/assets/chunk-5RXB4S5H-CcNtpUd7.js +0 -231
  144. package/dist/chart/lane/viewer/assets/chunk-5VM5RSS4-BP4fRS_5.js +0 -15
  145. package/dist/chart/lane/viewer/assets/chunk-KBJHAD2P-DZOw7xU6.js +0 -1
  146. package/dist/chart/lane/viewer/assets/chunk-NSK5VX7P-CBCyTZMs.js +0 -128
  147. package/dist/chart/lane/viewer/assets/classDiagram-JCYQIIEL-C729LI31.js +0 -1
  148. package/dist/chart/lane/viewer/assets/classDiagram-v2-OCEON4UE-D4uAiFr8.js +0 -206
  149. package/dist/chart/lane/viewer/assets/cose-bilkent-JH36ORCC-DOwCrGXH.js +0 -1
  150. package/dist/chart/lane/viewer/assets/cynefinDiagram-MW4NZA55-C729LI31.js +0 -1
  151. package/dist/chart/lane/viewer/assets/dagre-K_PewWfS.js +0 -1
  152. package/dist/chart/lane/viewer/assets/dagre-VZM6K2ZE-831qZcA8.js +0 -4
  153. package/dist/chart/lane/viewer/assets/diagram-7IWD3JNH-C729LI31.js +0 -1
  154. package/dist/chart/lane/viewer/assets/diagram-B4RE2ZJO-C729LI31.js +0 -1
  155. package/dist/chart/lane/viewer/assets/diagram-LBJQPF4R-C729LI31.js +0 -1
  156. package/dist/chart/lane/viewer/assets/diagram-Q27KOJAE-C729LI31.js +0 -1
  157. package/dist/chart/lane/viewer/assets/diagram-UB23O5K3-C729LI31.js +0 -1
  158. package/dist/chart/lane/viewer/assets/ebnfDiagram-BXEA7PRR-C729LI31.js +0 -1
  159. package/dist/chart/lane/viewer/assets/erDiagram-JOGREHBK-C729LI31.js +0 -1
  160. package/dist/chart/lane/viewer/assets/flowDiagram-UKHOOZJN-C729LI31.js +0 -1
  161. package/dist/chart/lane/viewer/assets/ganttDiagram-PKOTCBZU-C729LI31.js +0 -1
  162. package/dist/chart/lane/viewer/assets/gitGraphDiagram-DS77QQ5N-C729LI31.js +0 -1
  163. package/dist/chart/lane/viewer/assets/index-9SkH5NA3.css +0 -1
  164. package/dist/chart/lane/viewer/assets/index-Bgt4sXpW.js +0 -195
  165. package/dist/chart/lane/viewer/assets/infoDiagram-6WML65LV-C729LI31.js +0 -1
  166. package/dist/chart/lane/viewer/assets/ishikawaDiagram-WSZJBQD7-C729LI31.js +0 -1
  167. package/dist/chart/lane/viewer/assets/journeyDiagram-NVQOT4AX-C729LI31.js +0 -1
  168. package/dist/chart/lane/viewer/assets/kanban-definition-27J2QSJJ-G7PaPzy-.js +0 -89
  169. package/dist/chart/lane/viewer/assets/katex-DOwCrGXH.js +0 -1
  170. package/dist/chart/lane/viewer/assets/mindmap-definition-FAOFIHXS-CGj9nrVk.js +0 -96
  171. package/dist/chart/lane/viewer/assets/path-fybaL0A-.js +0 -1
  172. package/dist/chart/lane/viewer/assets/pegDiagram-VL7TDLO6-C729LI31.js +0 -1
  173. package/dist/chart/lane/viewer/assets/pieDiagram-7S7Q4E2Y-C729LI31.js +0 -1
  174. package/dist/chart/lane/viewer/assets/quadrantDiagram-CIZ2JOQS-C729LI31.js +0 -1
  175. package/dist/chart/lane/viewer/assets/railroadDiagram-AXF67PYL-C729LI31.js +0 -1
  176. package/dist/chart/lane/viewer/assets/requirementDiagram-LRYGKXZP-C729LI31.js +0 -1
  177. package/dist/chart/lane/viewer/assets/sankeyDiagram-W5VNT64P-C729LI31.js +0 -1
  178. package/dist/chart/lane/viewer/assets/sequenceDiagram-SI44F4Z6-C729LI31.js +0 -1
  179. package/dist/chart/lane/viewer/assets/stateDiagram-OKZ733FA-B_88AzBS.js +0 -1
  180. package/dist/chart/lane/viewer/assets/stateDiagram-v2-UEYNNEHI-CR5gcgq6.js +0 -1
  181. package/dist/chart/lane/viewer/assets/swimlanes-SLNWSIFB-B4xK-rwg.js +0 -1
  182. package/dist/chart/lane/viewer/assets/swimlanesDiagram-ULZ7WXOC-C729LI31.js +0 -1
  183. package/dist/chart/lane/viewer/assets/timeline-definition-Z64GVDOM-CCv52MfY.js +0 -120
  184. package/dist/chart/lane/viewer/assets/vennDiagram-T6HMQDX7-C729LI31.js +0 -1
  185. package/dist/chart/lane/viewer/assets/wardleyDiagram-T6FBY63Y-C729LI31.js +0 -1
  186. package/dist/chart/lane/viewer/assets/xychartDiagram-ELKLHX3M-C729LI31.js +0 -1
  187. package/dist/chart/lane/viewer/index.html +0 -15
  188. package/dist/chart/report/index.d.ts +0 -117
  189. package/dist/chart/report/index.js +0 -32
  190. package/dist/chart/report/index.js.map +0 -1
  191. package/dist/chunk-2YFLOCWX.js +0 -15
  192. package/dist/chunk-2YFLOCWX.js.map +0 -1
  193. package/dist/chunk-3I52QZZ5.js +0 -519
  194. package/dist/chunk-3I52QZZ5.js.map +0 -1
  195. package/dist/chunk-3ZAFFRRB.js +0 -457
  196. package/dist/chunk-3ZAFFRRB.js.map +0 -1
  197. package/dist/chunk-4EQZ76JC.js +0 -33
  198. package/dist/chunk-4EQZ76JC.js.map +0 -1
  199. package/dist/chunk-4KLG43GY.js +0 -223
  200. package/dist/chunk-4KLG43GY.js.map +0 -1
  201. package/dist/chunk-7FRZ2CT2.js +0 -424
  202. package/dist/chunk-7FRZ2CT2.js.map +0 -1
  203. package/dist/chunk-AZZLE7XR.js +0 -62
  204. package/dist/chunk-AZZLE7XR.js.map +0 -1
  205. package/dist/chunk-BYQUGDD3.js +0 -16
  206. package/dist/chunk-BYQUGDD3.js.map +0 -1
  207. package/dist/chunk-CIQG5L42.js +0 -685
  208. package/dist/chunk-CIQG5L42.js.map +0 -1
  209. package/dist/chunk-CLM6ERNO.js +0 -61
  210. package/dist/chunk-CLM6ERNO.js.map +0 -1
  211. package/dist/chunk-COS5MSTO.js +0 -88
  212. package/dist/chunk-COS5MSTO.js.map +0 -1
  213. package/dist/chunk-CRPZJVD2.js +0 -71
  214. package/dist/chunk-CRPZJVD2.js.map +0 -1
  215. package/dist/chunk-D62FDQKE.js +0 -53
  216. package/dist/chunk-D62FDQKE.js.map +0 -1
  217. package/dist/chunk-D736QUGF.js.map +0 -1
  218. package/dist/chunk-DGE4PV4A.js +0 -26
  219. package/dist/chunk-DGE4PV4A.js.map +0 -1
  220. package/dist/chunk-DMYGQB4O.js.map +0 -1
  221. package/dist/chunk-EWJP3YYP.js.map +0 -1
  222. package/dist/chunk-FV3Z5MBE.js.map +0 -1
  223. package/dist/chunk-HCEVHFJ7.js +0 -54
  224. package/dist/chunk-HCEVHFJ7.js.map +0 -1
  225. package/dist/chunk-J6527VRQ.js.map +0 -1
  226. package/dist/chunk-JELSZN25.js +0 -47
  227. package/dist/chunk-JELSZN25.js.map +0 -1
  228. package/dist/chunk-K575PT4S.js.map +0 -1
  229. package/dist/chunk-L57ZOT5K.js +0 -184
  230. package/dist/chunk-L57ZOT5K.js.map +0 -1
  231. package/dist/chunk-MU6MCIAC.js +0 -15
  232. package/dist/chunk-MU6MCIAC.js.map +0 -1
  233. package/dist/chunk-MUUROGIH.js.map +0 -1
  234. package/dist/chunk-NR7BU22N.js +0 -758
  235. package/dist/chunk-NR7BU22N.js.map +0 -1
  236. package/dist/chunk-O4MVQTEJ.js.map +0 -1
  237. package/dist/chunk-OOYD44JI.js +0 -317
  238. package/dist/chunk-OOYD44JI.js.map +0 -1
  239. package/dist/chunk-Q2UM7BXU.js.map +0 -1
  240. package/dist/chunk-RH5EFRVJ.js.map +0 -1
  241. package/dist/chunk-S2EGRPCM.js +0 -47
  242. package/dist/chunk-S2EGRPCM.js.map +0 -1
  243. package/dist/chunk-SINXE47Y.js +0 -55
  244. package/dist/chunk-SINXE47Y.js.map +0 -1
  245. package/dist/chunk-UF4MZSLT.js +0 -53
  246. package/dist/chunk-UF4MZSLT.js.map +0 -1
  247. package/dist/chunk-UOC2PL46.js +0 -13
  248. package/dist/chunk-UOC2PL46.js.map +0 -1
  249. package/dist/chunk-VYFAZN3F.js +0 -372
  250. package/dist/chunk-VYFAZN3F.js.map +0 -1
  251. package/dist/chunk-WRAA7GVZ.js +0 -209
  252. package/dist/chunk-WRAA7GVZ.js.map +0 -1
  253. package/dist/chunk-XGELA764.js +0 -163
  254. package/dist/chunk-XGELA764.js.map +0 -1
  255. package/dist/chunk-YUXP55T2.js.map +0 -1
  256. package/dist/chunk-YWIKDKHY.js +0 -307
  257. package/dist/chunk-YWIKDKHY.js.map +0 -1
  258. package/dist/chunk-ZJ5AOYBH.js +0 -8
  259. package/dist/chunk-ZJ5AOYBH.js.map +0 -1
  260. package/dist/chunk-ZSUUOEPL.js +0 -731
  261. package/dist/chunk-ZSUUOEPL.js.map +0 -1
  262. package/dist/chunk-ZVJZ72HY.js.map +0 -1
  263. package/dist/circuit-breaker/index.d.ts +0 -197
  264. package/dist/circuit-breaker/index.js +0 -3
  265. package/dist/circuit-breaker/index.js.map +0 -1
  266. package/dist/deadline/index.d.ts +0 -199
  267. package/dist/deadline/index.js +0 -6
  268. package/dist/deadline/index.js.map +0 -1
  269. package/dist/debounce/index.js +0 -3
  270. package/dist/debounce/index.js.map +0 -1
  271. package/dist/extension/react.d.ts +0 -121
  272. package/dist/extension/react.js +0 -75
  273. package/dist/extension/react.js.map +0 -1
  274. package/dist/extension/subs/index.d.ts +0 -45
  275. package/dist/extension/subs/index.js +0 -80
  276. package/dist/extension/subs/index.js.map +0 -1
  277. package/dist/extension/test-utils.d.ts +0 -128
  278. package/dist/extension/test-utils.js +0 -277
  279. package/dist/extension/test-utils.js.map +0 -1
  280. package/dist/fan-out/index.js +0 -5
  281. package/dist/fan-out/index.js.map +0 -1
  282. package/dist/fold-BJPdjc9w.d.ts +0 -435
  283. package/dist/graph-B3L5e0N1.d.ts +0 -923
  284. package/dist/idempotency/adapter.d.ts +0 -62
  285. package/dist/idempotency/adapter.js +0 -4
  286. package/dist/idempotency/adapter.js.map +0 -1
  287. package/dist/idempotent-intake/index.d.ts +0 -188
  288. package/dist/idempotent-intake/index.js +0 -7
  289. package/dist/idempotent-intake/index.js.map +0 -1
  290. package/dist/journal/index.d.ts +0 -373
  291. package/dist/journal/index.js +0 -3
  292. package/dist/journal/index.js.map +0 -1
  293. package/dist/llm-call/index.d.ts +0 -311
  294. package/dist/llm-call/index.js +0 -16
  295. package/dist/llm-call/index.js.map +0 -1
  296. package/dist/machine-BtFWQmmq.d.ts +0 -804
  297. package/dist/monitored-run/index.js +0 -10
  298. package/dist/monitored-run/index.js.map +0 -1
  299. package/dist/paginated-walk/index.d.ts +0 -235
  300. package/dist/paginated-walk/index.js +0 -16
  301. package/dist/paginated-walk/index.js.map +0 -1
  302. package/dist/paginator/index.js +0 -3
  303. package/dist/paginator/index.js.map +0 -1
  304. package/dist/pbt/arbitraries/index.d.ts +0 -136
  305. package/dist/pbt/arbitraries/index.js +0 -3
  306. package/dist/pbt/arbitraries/index.js.map +0 -1
  307. package/dist/pbt/runners/index.d.ts +0 -118
  308. package/dist/pbt/runners/index.js +0 -5
  309. package/dist/pbt/runners/index.js.map +0 -1
  310. package/dist/poller/index.d.ts +0 -352
  311. package/dist/poller/index.js +0 -115
  312. package/dist/poller/index.js.map +0 -1
  313. package/dist/prediction/index.d.ts +0 -131
  314. package/dist/prediction/index.js +0 -4
  315. package/dist/prediction/index.js.map +0 -1
  316. package/dist/pure/index.d.ts +0 -3
  317. package/dist/pure/index.js +0 -4
  318. package/dist/pure/index.js.map +0 -1
  319. package/dist/rate-limit/index.d.ts +0 -115
  320. package/dist/rate-limit/index.js +0 -3
  321. package/dist/rate-limit/index.js.map +0 -1
  322. package/dist/reconciler/index.d.ts +0 -193
  323. package/dist/reconciler/index.js +0 -164
  324. package/dist/reconciler/index.js.map +0 -1
  325. package/dist/recorder/index.js +0 -3
  326. package/dist/recorder/index.js.map +0 -1
  327. package/dist/reducer-4GNR6b8B.d.ts +0 -447
  328. package/dist/resilient-call/index.d.ts +0 -320
  329. package/dist/resilient-call/index.js +0 -14
  330. package/dist/resilient-call/index.js.map +0 -1
  331. package/dist/retry-to-success/index.d.ts +0 -109
  332. package/dist/retry-to-success/index.js +0 -37
  333. package/dist/retry-to-success/index.js.map +0 -1
  334. package/dist/run-pAcmBpah.d.ts +0 -713
  335. package/dist/runtime-types-CNLmhWif.d.ts +0 -517
  336. package/dist/saga/index.d.ts +0 -241
  337. package/dist/saga/index.js +0 -150
  338. package/dist/saga/index.js.map +0 -1
  339. package/dist/samples-B3My5oh2.d.ts +0 -59
  340. package/dist/snapshot/index.js +0 -5
  341. package/dist/snapshot/index.js.map +0 -1
  342. package/dist/subs/index.d.ts +0 -472
  343. package/dist/subs/index.js +0 -7
  344. package/dist/subs/index.js.map +0 -1
  345. package/dist/throttle/index.d.ts +0 -134
  346. package/dist/throttle/index.js +0 -3
  347. package/dist/throttle/index.js.map +0 -1
  348. package/dist/throttled-input/index.js.map +0 -1
  349. package/dist/token-refresh/index.d.ts +0 -216
  350. package/dist/token-refresh/index.js +0 -6
  351. package/dist/token-refresh/index.js.map +0 -1
  352. package/dist/trace-replay/index.js +0 -6
  353. package/dist/trace-replay/index.js.map +0 -1
  354. package/dist/with-deadline/index.d.ts +0 -197
  355. package/dist/with-deadline/index.js +0 -111
  356. package/dist/with-deadline/index.js.map +0 -1
  357. package/dist/with-resilience/index.d.ts +0 -225
  358. package/dist/with-resilience/index.js +0 -240
  359. package/dist/with-resilience/index.js.map +0 -1
  360. package/dist/with-telemetry/index.d.ts +0 -150
  361. package/dist/with-telemetry/index.js +0 -70
  362. package/dist/with-telemetry/index.js.map +0 -1
  363. package/dist/work-queue/adapter.d.ts +0 -84
  364. package/dist/work-queue/adapter.js +0 -4
  365. package/dist/work-queue/adapter.js.map +0 -1
  366. package/dist/work-queue/ops.d.ts +0 -71
  367. package/dist/work-queue/ops.js +0 -3
  368. package/dist/work-queue/ops.js.map +0 -1
  369. package/dist/workflow/index.d.ts +0 -485
  370. package/dist/workflow/index.js +0 -244
  371. package/dist/workflow/index.js.map +0 -1
  372. /package/dist/{cache → paginate}/index.js.map +0 -0
  373. /package/dist/{chart/inspect → persistence}/index.js.map +0 -0
package/dist/index.d.ts CHANGED
@@ -1,10 +1,71 @@
1
- import { B as BootingRuntime, C as CtxArg, S as Store, O as OnError, a as Supervision } from './runtime-types-CNLmhWif.js';
2
- export { b as Branded, D as DispatchDiscardedError, c as DispatchSettle, d as DisposeTimeoutNotice, F as FoldRefusal, I as IdentityDropNotice, P as PortNameCollisionError, Q as QuiescenceTimeoutError, R as Runtime, e as RuntimeDiscardNotice, f as RuntimeDiscardedError, g as RuntimeErrorContext, h as RuntimeErrorPhase, i as RuntimeRef, j as Schema, k as SubIdCollisionError, l as SupervisionStrategy, _ as __resetPortRegistry, m as absurd, n as asReducer, o as defineMachine, p as definePort, q as noop, r as replay, s as schemaMigrate, t as settle, u as tryApplyCell, v as tryFoldMsgs, w as tryInterpret, x as wrapDetached } from './runtime-types-CNLmhWif.js';
3
- import { C as Cmd, S as Sub, M as Machine, R as RequiredCtx } from './core-Co0LWkIA.js';
4
- export { A as AnyCmdDef, h as CmdDef, i as CmdInput, e as CmdOf, j as CmdValue, k as ContextFree, D as DepKeyedSub, l as Dispose, E as ErrOf, m as ErrorsOf, n as Identity, I as Interpret, g as InterpretDetached, o as MachineShape, p as MalformedResult, q as Needs, f as NeedsOf, N as NoCellError, r as NoCtx, O as OkOf, a as Port, P as PortEmitter, c as Reducer, d as Settled, s as SettledErr, t as SettledOk, b as SubId, u as Subscribe, v as SyncReturn, w as Tagged, x as TaggedError, T as Transitions, U as UpdateForm, y as acceptsOf, z as applyCell, B as applyCellChecked, F as describeMachine, G as detectUpdateForm, H as foldMsgs, J as foldUpdates, K as formOf, L as msgKeysOf, Q as structuralHash, V as subId } from './core-Co0LWkIA.js';
1
+ import { B as BootingRuntime, a as ScopedCtxArg, S as Store, O as OnError, b as Supervision, R as Runtime } from './runtime-types-CMF13BBh.js';
2
+ export { c as Branded, C as CtxArg, D as DepToken, d as DepsOf, e as DispatchDiscardedError, f as DispatchSettle, g as DisposeTimeoutNotice, h as DriveFailedError, i as DriveStalledError, j as FencedRead, F as FencedStore, k as FoldRefusal, I as IdentityDropNotice, M as MachineTypes, l as OnReleaseError, P as PortNameCollisionError, m as ProvideFailedError, n as Provided, o as ProvidedCtx, p as Provider, q as ProviderCycleError, Q as QuiescenceTimeoutError, r as RuntimeDiscardNotice, s as RuntimeDiscardedError, t as RuntimeErrorContext, u as RuntimeErrorPhase, v as RuntimeRef, w as Schema, x as Scope, y as StoreConflictError, z as SubIdCollisionError, A as SupervisionStrategy, U as UnknownProviderError, _ as __resetPortRegistry, E as absurd, G as asReducer, H as defineMachine, J as definePort, K as dep, L as isFencedStore, N as isProvided, T as layer, V as noop, W as provide, X as replay, Y as schemaMigrate, Z as settle, $ as tryApplyCell, a0 as tryFoldMsgs, a1 as tryInterpret, a2 as value, a3 as wrapDetached } from './runtime-types-CMF13BBh.js';
3
+ import { C as Cmd, S as Sub, M as Machine, R as RequiredCtx, P as Port, D as Dispose, o as DepKeyedSub, c as SubId } from './core-DnzqWy6u.js';
4
+ export { A as AnyCmdDef, b as CmdDef, p as CmdInput, a as CmdOf, l as CmdValue, E as ErrOf, q as ErrorsOf, r as ExhaustiveTransitions, s as Identity, I as Interpret, h as InterpretDetached, t as MachineShape, k as MalformedResult, N as NoCellError, i as NoCtx, O as OkOf, g as PortEmitter, d as Reducer, m as Requirements, f as RequirementsOf, e as Settled, u as SettledErr, v as SettledOk, w as Subscribe, x as SyncReturn, j as Tagged, n as TaggedError, T as Transitions, U as UpdateForm, y as acceptedTypes, z as acceptsOf, B as applyCell, F as applyCellChecked, G as describeMachine, H as detectUpdateForm, J as foldMsgs, K as foldUpdates, L as formOf, Q as msgKeysOf, V as structuralHash, W as subId } from './core-DnzqWy6u.js';
5
+ import { S as SubscribeHandler } from './types-BseNPIhr.js';
5
6
  import 'better-result';
6
7
  import 'zod';
7
8
 
9
+ /**
10
+ * @packageDocumentation
11
+ * The composition seam — the layer between a battery and a door.
12
+ *
13
+ * A battery is pure state plus verbs over that state. A door holds several
14
+ * batteries side by side in one Model. Everything between those two facts was,
15
+ * until now, hand-written at every consumer: the one-key record rebuild that
16
+ * threads a verb's `[slice, cmds]` result back into the host state, and the
17
+ * statement order that decides which slice wins a derived read.
18
+ *
19
+ * Two helpers cover it, and neither is an optics kit. {@link liftSlice} is the
20
+ * record rebuild with the key checked by the type system; {@link readInOrder}
21
+ * turns a read's precedence from statement order into a value you can name,
22
+ * export and assert on. ADR 0001 (no off-the-shelf resilience) and ADR 0014
23
+ * (Effect's types, never its runtime values) between them settle why this is
24
+ * forty lines here rather than a dependency.
25
+ *
26
+ * Both are pure: no clock, no RNG, no storage, nothing captured. A `liftSlice`
27
+ * result is a fresh record and a Cmd array, so ADR 0014's journal/hash promise
28
+ * over a reducer's return value is untouched.
29
+ */
30
+ /**
31
+ * Lift a battery verb's result into the host state that carries its slice.
32
+ *
33
+ * `liftSlice("resilience", state, knob.attempt(state.resilience, …))` is the
34
+ * `{ ...state, resilience: slice }` every consumer writes by hand, with the key
35
+ * checked: `key` must be a key of `S`, and the slice the verb returned must be
36
+ * assignable to the type that key carries — so naming the wrong field, or
37
+ * threading one battery's slice into another's key, is a compile error rather
38
+ * than a state shape nothing reads correctly.
39
+ *
40
+ * PURE — a fresh record and the verb's own Cmds, unchanged.
41
+ */
42
+ declare function liftSlice<S, K extends keyof S, C>(key: K, state: S, [slice, cmds]: readonly [S[K], readonly C[]]): readonly [S, readonly C[]];
43
+ /**
44
+ * One step of a composed read: the slice it consults, under the name that slice
45
+ * goes by. `read` returns `undefined` for "this slice has nothing to say",
46
+ * which is what hands the read on to the next step.
47
+ */
48
+ interface ReadStep<In, Out> {
49
+ /** The slice this step consults — `"cache"`, `"failed"`, `"inFlight"`. */
50
+ readonly name: string;
51
+ /** What this slice says about `input`, or `undefined` to defer. */
52
+ readonly read: (input: In) => Out | undefined;
53
+ }
54
+ /**
55
+ * Run a composed read through `order` and return the first answer any step
56
+ * gives, or `absent` when every one defers.
57
+ *
58
+ * The point is that `order` is a VALUE. A derived read over three battery
59
+ * slices otherwise states its precedence as the order of three `if` statements,
60
+ * where it is invisible to the type system, unnameable in a test and one
61
+ * innocent-looking reshuffle away from being wrong — which is exactly the
62
+ * defect that escaped `classify-batch`'s per-battery test suites. Written as
63
+ * data, the precedence can be exported, printed and asserted on directly.
64
+ *
65
+ * PURE — it evaluates `read` in order and stores nothing.
66
+ */
67
+ declare function readInOrder<In, Out>(input: In, order: readonly ReadStep<In, Out>[], absent: Out): Out;
68
+
8
69
  interface HistoryTracker<S, M extends {
9
70
  type: string;
10
71
  }> {
@@ -51,6 +112,135 @@ declare function historyTracker<S, M extends {
51
112
  type: string;
52
113
  }>(runtime: BootingRuntime<S, M>, size: number): HistoryTracker<S, M>;
53
114
 
115
+ /**
116
+ * internal/prediction — the client-prediction ack primitive (epic #186, facet 2).
117
+ * Internal since #49 — not published on any subpath of its own; the
118
+ * client-safe barrel `src/pure/` re-exports the public surface, and the root
119
+ * `@demlik/tea` door publishes it.
120
+ *
121
+ * The contract the Gambetta/Valve authoritative-server netcode loop needs:
122
+ * **command-seq-in → last-applied-seq-out.** A client tags each predicted
123
+ * command/`Msg` with a monotonic `seq`; the authoritative side replies with the
124
+ * `lastAppliedSeq` it has processed. `partitionByAck` then splits the client's
125
+ * pending buffer into the inputs the server has ACKED (`seq <= lastAppliedSeq`)
126
+ * and those still PENDING (`seq > lastAppliedSeq`) — the un-acked tail the
127
+ * reconciliation pass (#214) replays over the authoritative snapshot via
128
+ * `foldMsgs` (#211, the client-safe barrel `src/pure/`).
129
+ *
130
+ * Deliberately **Model-shape-agnostic** (ADR 0006): the ack is a standalone
131
+ * value, NOT a field this module requires on the consumer's `State`. It
132
+ * generalizes the `lastAckedSeq`-on-the-Model + `seq`-threaded-through-the-Msg
133
+ * pattern vortex hand-rolled (epic #186). It is a LEAF module — pure and
134
+ * runtime-free, importing nothing from the tea core or host, so it can never
135
+ * drag `run`/the host into a client bundle.
136
+ *
137
+ * This is the read/ack side of the primitive; `tagSeq`/`nextSeq` are the write
138
+ * side, letting a client mint monotonic seqs from its pending buffer alone —
139
+ * again with no counter field on the Model.
140
+ *
141
+ * `reconcile` (the read side's payoff, #214) composes this ack partition with
142
+ * the pure fold seam `foldMsgs` to perform the whole Gambetta/Valve
143
+ * reconciliation step in one call. The `foldMsgs` import is the ONLY dependency
144
+ * this leaf takes, and it reaches into the pure-core leaf (`../pure/core`) — NOT
145
+ * the runtime root — so the module stays runtime-free and the client-safe
146
+ * import-graph guard (ADR 0006, #213) still holds.
147
+ */
148
+
149
+ /**
150
+ * A monotonic, non-negative sequence number tagging one client-predicted
151
+ * command. Monotonicity is the client's contract (mint successive seqs with
152
+ * `nextSeq`); this module only ever *compares* seqs.
153
+ */
154
+ type Seq = number;
155
+ /** A command (or `Msg`) tagged with the `seq` the client assigned it. */
156
+ interface SeqTagged<T> {
157
+ readonly seq: Seq;
158
+ readonly value: T;
159
+ }
160
+ /** Tag a command/`Msg` with its sequence number. */
161
+ declare const tagSeq: <T>(seq: Seq, value: T) => SeqTagged<T>;
162
+ /**
163
+ * The authoritative side's acknowledgement: the highest `seq` it has applied.
164
+ * Everything with `seq <= lastAppliedSeq` is settled; everything above is still
165
+ * in flight. This *is* the whole "ack from the authoritative side" — a value
166
+ * the consumer carries however it likes (a wire field, a message payload),
167
+ * never a shape this module imposes on the Model.
168
+ */
169
+ interface Ack {
170
+ readonly lastAppliedSeq: Seq;
171
+ }
172
+ /** Construct an `Ack` for a last-applied sequence number. */
173
+ declare const ack: (lastAppliedSeq: Seq) => Ack;
174
+ /**
175
+ * The "nothing applied yet" cursor — the ack value for a server that has applied
176
+ * no client input at all. Because `nextSeq` mints **0-based** seqs and
177
+ * `partitionByAck` acks **inclusively** (`seq <= lastAppliedSeq`), the pre-first
178
+ * cursor must sit strictly *below* seq 0: `lastAppliedSeq = 0` would falsely ack
179
+ * the seq-0 input before the server ever saw it. `-1` is "before any seq", and
180
+ * `partitionByAck(buffer, NO_ACK)` therefore leaves the whole buffer PENDING.
181
+ *
182
+ * This names the boundary value on the seam so no consumer has to re-discover it
183
+ * as a magic number: it is the primitive's own design (0-based mint + inclusive
184
+ * partition) that creates the trap, so it is the primitive's job to name the
185
+ * escape. Pair with {@link initAck} when an {@link Ack} is wanted instead of the
186
+ * bare `Seq`.
187
+ */
188
+ declare const NO_ACK: Seq;
189
+ /**
190
+ * The `Ack` for a server that has applied nothing yet — `ack(NO_ACK)`. The `Ack`
191
+ * counterpart to the {@link NO_ACK} `Seq` sentinel, for a consumer that carries
192
+ * an `Ack` rather than a bare `lastAppliedSeq`.
193
+ */
194
+ declare const initAck: () => Ack;
195
+ /** The result of splitting a seq-tagged buffer against an ack. */
196
+ interface AckPartition<T> {
197
+ /** Inputs the authoritative side has applied (`seq <= lastAppliedSeq`). */
198
+ readonly acked: readonly SeqTagged<T>[];
199
+ /** Inputs still in flight / un-acked (`seq > lastAppliedSeq`) — the replay tail. */
200
+ readonly pending: readonly SeqTagged<T>[];
201
+ }
202
+ /**
203
+ * Partition a buffer of seq-tagged commands into ACKED and PENDING against the
204
+ * authoritative `lastAppliedSeq`. Pure and total: every item lands in exactly
205
+ * one bucket, input order is preserved within each bucket, and the boundary
206
+ * `seq == lastAppliedSeq` is ACKED (inclusive `<=`). Routing is by `seq` value,
207
+ * not buffer position, so an out-of-order or duplicate-seq buffer partitions
208
+ * correctly. Accepts either an {@link Ack} or a bare `lastAppliedSeq` number, so
209
+ * a caller passes whichever it holds.
210
+ */
211
+ declare const partitionByAck: <T>(buffer: readonly SeqTagged<T>[], ackOrSeq: Ack | Seq) => AckPartition<T>;
212
+ /**
213
+ * The next sequence number to assign: one past the highest `seq` in the buffer,
214
+ * or `0` for an empty buffer. Lets a client mint monotonic seqs from its pending
215
+ * buffer alone — no counter field on the Model — and is tolerant of an unordered
216
+ * buffer (it takes the max, not the last element).
217
+ */
218
+ declare const nextSeq: <T>(buffer: readonly SeqTagged<T>[]) => Seq;
219
+ /**
220
+ * The client prediction/reconciliation helper — the Gambetta/Valve
221
+ * authoritative-server loop's reconcile step, generalized.
222
+ *
223
+ * Given the latest `authoritativeState` from the server, the server's
224
+ * `lastAppliedSeq` ack, and the client's `pending` buffer of seq-tagged inputs,
225
+ * it returns the corrected predicted state: drop the inputs the server has
226
+ * already applied (`seq <= lastAppliedSeq`) and replay ONLY the un-acked tail
227
+ * (`seq > lastAppliedSeq`) over the authoritative snapshot.
228
+ *
229
+ * It is **composed, not re-derived** (ADR 0006): the drop is {@link partitionByAck}
230
+ * (the ack primitive, #212) and the replay is `foldMsgs` (the pure fold seam,
231
+ * #211) — there is no second copy of the partition logic and no second copy of
232
+ * the fold. `lastAppliedSeq` accepts either an {@link Ack} or a bare `Seq`, so a
233
+ * caller passes whichever it holds, matching `partitionByAck`.
234
+ *
235
+ * Pure and host-agnostic: it takes the `machine` (which `foldMsgs` needs to
236
+ * dispatch `update`) but touches no `Store`, `interpret`, or subscription, and
237
+ * imports nothing from the runtime — so it ships through the client-safe
238
+ * umbrella without dragging `run` into a client bundle.
239
+ */
240
+ declare function reconcile<S, M extends {
241
+ type: string;
242
+ }, C extends Cmd, U extends Sub, Ctx>(machine: Machine<S, M, C, U, Ctx>, authoritativeState: S, lastAppliedSeq: Ack | Seq, pending: readonly SeqTagged<M>[]): S;
243
+
54
244
  /**
55
245
  * @demlik/tea runtime — `run`: boot + the serial dispatch loop. The pure helpers
56
246
  * that compose against a machine without running it (`replay`, `tryInterpret`)
@@ -61,7 +251,7 @@ declare function run<S, M extends {
61
251
  type: string;
62
252
  }, C extends Cmd, U extends Sub, Ctx, E extends {
63
253
  type: string;
64
- } = never>(machine: Machine<S, M, C, U, Ctx>, opts: CtxArg<Ctx & RequiredCtx<C>> & {
254
+ } = never>(machine: Machine<S, M, C, U, Ctx>, opts: ScopedCtxArg<Ctx & RequiredCtx<C>> & {
65
255
  store?: Store<S>;
66
256
  onError?: OnError;
67
257
  /**
@@ -111,5 +301,580 @@ declare function run<S, M extends {
111
301
  */
112
302
  __idleCap?: number;
113
303
  }): BootingRuntime<S, M, E>;
304
+ /**
305
+ * The outside-in stop, as a PAIR. A signal is only cancellation if something can
306
+ * turn "aborted" into a transition this machine understands, and the kernel has
307
+ * no built-in cancel Msg any more than it has a built-in terminal set — so the
308
+ * `signal` and the `cancel` that reads it are one option, present together or
309
+ * absent together. A discriminated union rather than two optional fields, on the
310
+ * same reasoning as `AgentCompactionConfig`: a signal with no `cancel` is a stop
311
+ * button wired to nothing, and that is a state worth making unrepresentable
312
+ * rather than checking for.
313
+ */
314
+ type DriveCancellation<S, M> = {
315
+ readonly signal?: undefined;
316
+ readonly cancel?: undefined;
317
+ } | {
318
+ /**
319
+ * Abort the run through this signal. On abort the drive dispatches
320
+ * `cancel`'s Msg and resolves on the State that lands — it does NOT reject,
321
+ * and a cancellation is never a `DriveFailedError`. Already aborted when
322
+ * the drive is called → the cancel Msg goes in place of `start`, so the
323
+ * run ends without the start's effects ever firing.
324
+ */
325
+ readonly signal: AbortSignal;
326
+ /**
327
+ * The Msg that settles this machine as cancelled, chosen off the current
328
+ * State exactly as `start` is. PURE. It must land a State `isTerminal`
329
+ * holds for — the drive resolves on the terminal predicate, not on the
330
+ * abort — and that State should be DURABLE, or a reload resumes the run
331
+ * its caller stopped.
332
+ */
333
+ readonly cancel: (state: S) => M;
334
+ };
335
+ /** Options for `driveToDone`. */
336
+ type DriveToDoneOptions<S, M extends {
337
+ type: string;
338
+ } = never> = DriveCancellation<S, M> & {
339
+ /**
340
+ * Marks a terminal State as a FAILURE. A State this holds for ends the drive
341
+ * like any terminal one — the runtime is stopped — but the drive REJECTS with
342
+ * `DriveFailedError` carrying it instead of resolving. A failed State is
343
+ * terminal by definition; it need not also satisfy `isTerminal`. Omit → the
344
+ * drive never rejects on State, only on a runtime error.
345
+ */
346
+ readonly failed?: (state: S) => boolean;
347
+ };
348
+ /**
349
+ * Drive a machine from `start` to its terminal State in one call, then tear the
350
+ * runtime down. The one-shot shape every "run this machine to done" test and
351
+ * caller boundary otherwise hand-wires as six steps — `await ready`, `observe`,
352
+ * park a promise, `dispatch(start)`, `getState()`, `stop()` — with the observer
353
+ * leak and the forgotten `stop` those six steps invite.
354
+ *
355
+ * Takes the handle `run()` returns (a `Runtime` extends it, so a booted one is
356
+ * accepted too), awaits `ready`, dispatches `start`, and resolves with the first
357
+ * State for which `isTerminal` holds. A machine that boots already terminal (a
358
+ * rehydrated finished run) resolves on its boot State and `start` is never
359
+ * dispatched — a finished run has nothing to set in motion. `start` may be a
360
+ * function of the boot State instead of a Msg: a machine rehydrated MID-run
361
+ * needs its resume Msg, not its start Msg, and only the boot State says which
362
+ * (the agent's `agent_boot` vs `agent_start` is the case in point). The
363
+ * observer is detached and `stop()` awaited on EVERY exit: resolve, `failed`,
364
+ * a stall, a boot or dispatch throw, the quiescence cap.
365
+ *
366
+ * Rejections are typed, never silent:
367
+ * - `DriveFailedError<S>` when `opts.failed` marks the final State — the State
368
+ * rides on `error.state`.
369
+ * - `DriveStalledError<S>` when `start`'s follow-up chain quiesces on a State
370
+ * that is neither terminal nor `failed` and the runtime has no live Sub and
371
+ * no Cmd in flight — nothing inside it can deliver another transition, so
372
+ * waiting would be a hang with the runtime leaked. The stalled State rides
373
+ * on `error.state`. A machine that CAN still move is not stalled: a live Sub
374
+ * (manual or dep-keyed) that delivers the terminal Msg after the dispatch
375
+ * quiesces keeps the drive waiting, and it resolves on that State. What the
376
+ * runtime cannot see — a dispatch from outside it after quiescence — does
377
+ * not count as live; a machine that depends on one declares it as a Sub.
378
+ * - `QuiescenceTimeoutError` when `start`'s follow-up chain never settles —
379
+ * the SAME cap `dispatch` and `idle()` already reject on (invariant 6), not a
380
+ * second clock. A livelocking machine surfaces as its own failure class.
381
+ * - the boot error, or whatever `dispatch(start)` rejects with, otherwise.
382
+ *
383
+ * `isTerminal` is caller-supplied, exactly as `run()`'s `terminal` option is —
384
+ * the kernel has no built-in terminal-set concept and this does not add one.
385
+ *
386
+ * Cancellation is the same story: `{ signal, cancel }` stops the drive from
387
+ * outside, and it settles the run rather than escaping it. On abort the drive
388
+ * dispatches `cancel`'s Msg and RESOLVES on the terminal State that transition
389
+ * lands — no rejection, no `DriveFailedError`, no `AbortError`. That is the whole
390
+ * point of routing a stop through the Model: the outcome is durable, so a killed
391
+ * process resumes reading a run that ended instead of restarting one someone
392
+ * stopped. A cancel that THROWS is the one abort that rejects: it lands
393
+ * no State, so its error is what the drive has to report — and that holds
394
+ * whether the `cancel` function throws synchronously or the fold it produced
395
+ * throws later, since both leave the run with no State to settle on. A State the
396
+ * caller's `failed` predicate marks rejects on an abort exit exactly as it does
397
+ * anywhere else. In-flight effects are not recalled — a promise cannot be cancelled —
398
+ * so they settle to their own end and `stop()` drains them as it always did;
399
+ * keeping their results off the public channels is the machine's own business.
400
+ * Omit the pair and every path here behaves exactly as it did before.
401
+ *
402
+ * @param handle the handle `run(machine, opts)` returned.
403
+ * @param start the Msg that sets the run in motion, or a function choosing
404
+ * it off the boot State. PURE.
405
+ * @param isTerminal the terminal predicate over the machine's State. PURE.
406
+ * @param opts an optional `failed` predicate and an optional
407
+ * `{ signal, cancel }` pair (see {@link DriveToDoneOptions}).
408
+ */
409
+ declare function driveToDone<S, M extends {
410
+ type: string;
411
+ }, E extends {
412
+ type: string;
413
+ } = never>(handle: BootingRuntime<S, M, E>, start: M | ((booted: S) => M), isTerminal: (state: S) => boolean, opts?: DriveToDoneOptions<S, M>): Promise<S>;
414
+
415
+ /**
416
+ * The imperative listener target, expressed as the `add`/`remove` pair the
417
+ * substrate pairs into a reconciled resource. Both halves receive the SAME
418
+ * `listener` reference — the substrate builds it once — so `remove` can never
419
+ * be handed a different function than `add` saw.
420
+ *
421
+ * `add`/`remove` also receive `(sub, ctx)` so the target may be resolved from
422
+ * `ctx` (a runtime, a port, a DOM node looked up lazily) or keyed on the Sub
423
+ * (an alarm name, a channel name). Resolving the target inside `add` and
424
+ * closing over nothing but the listener keeps a target swap from leaking the
425
+ * old target's listener — same rationale as `fromEventTarget`'s captured
426
+ * target.
427
+ *
428
+ * `Args` is the tuple the platform invokes the listener with — `[Alarm]` for
429
+ * `chrome.alarms.onAlarm`, `[message, sender, sendResponse]` for
430
+ * `chrome.runtime.onMessage`, `[changes, areaName]` for
431
+ * `chrome.storage.onChanged`. The substrate builds ONE function of this exact
432
+ * shape and threads the IDENTICAL reference to both `add` and `remove` — so a
433
+ * platform that matches `removeListener` by reference (every chrome surface)
434
+ * removes exactly what it added. A consumer that wrapped the listener inside
435
+ * `add` would break reference identity (leak #2 above); carrying the native
436
+ * `Args` on the listener itself removes the need for any wrapper.
437
+ */
438
+ interface ListenerTarget<Args extends readonly unknown[], S extends Sub, Ctx> {
439
+ add: (listener: (...args: Args) => void, sub: S, ctx: Ctx) => void;
440
+ remove: (listener: (...args: Args) => void, sub: S, ctx: Ctx) => void;
441
+ }
442
+ /**
443
+ * Build a listener-backed Sub factory whose cleanup is mandatory and derived.
444
+ *
445
+ * `Args`, `S`, `Ctx` are fixed when the target is defined — they describe the
446
+ * one listener topology this factory owns (the platform arg tuple, which Sub
447
+ * shape it filters on, what context resolves it). `M` is supplied at the
448
+ * subscribe cell because the same listener feeds different Msgs in different
449
+ * machines. Pinning `S` here (rather than at the `msgFn` step) lets
450
+ * `add`/`remove` read the concrete Sub's fields — `sub.alarmName`,
451
+ * `sub.channel` — with NO cast at the substrate edge: the narrowing happens in
452
+ * author-land where the Sub shape is in scope.
453
+ *
454
+ * The returned function is a `SubscribeHandler` factory in the exact shape of
455
+ * every other Sub factory in `src/subs/`: supply the `msgFn` projection, get a
456
+ * `(sub, ctx, dispatch) => cleanup` handler assignable to `machine.subscribe`.
457
+ * The cleanup the author NEVER writes is `() => remove(listener, sub, ctx)`,
458
+ * with `listener` the identical reference passed to `add`.
459
+ */
460
+ declare function defineListener<Args extends readonly unknown[], S extends Sub = Sub, Ctx = unknown>(target: ListenerTarget<Args, S, Ctx>): <M>(msgFn: (sub: S, ...args: Args) => M | null) => SubscribeHandler<S, M, Ctx>;
461
+
462
+ interface MinimalEvent {
463
+ readonly type: string;
464
+ }
465
+ interface MinimalMessageEvent extends MinimalEvent {
466
+ readonly data: unknown;
467
+ }
468
+ interface MinimalEventTarget {
469
+ addEventListener(type: string, listener: (event: MinimalEvent) => void): void;
470
+ removeEventListener(type: string, listener: (event: MinimalEvent) => void): void;
471
+ }
472
+ interface MinimalCloseEvent extends MinimalEvent {
473
+ readonly code: number;
474
+ readonly reason: string;
475
+ }
476
+ interface MinimalWebSocket {
477
+ close(code?: number, reason?: string): void;
478
+ onopen: ((event: MinimalEvent) => void) | null;
479
+ onmessage: ((event: MinimalMessageEvent) => void) | null;
480
+ onerror: ((event: MinimalEvent) => void) | null;
481
+ onclose: ((event: MinimalCloseEvent) => void) | null;
482
+ }
483
+
484
+ type BroadcastSubData = {
485
+ channelName: string;
486
+ };
487
+ declare function fromBroadcastChannel<S extends Sub & BroadcastSubData, M>(msgFn: (event: MinimalMessageEvent, sub: S) => M | null): SubscribeHandler<S, M, unknown>;
488
+
489
+ type EventSourceSubData = {
490
+ url: string;
491
+ };
492
+ interface EventSourceFactoryOpts<S, M> {
493
+ onMessage: (data: string, sub: S) => M | null;
494
+ onError?: (event: MinimalEvent, sub: S) => M | null;
495
+ onOpen?: (sub: S) => M | null;
496
+ }
497
+ declare function fromEventSource<S extends Sub & EventSourceSubData, M>(opts: EventSourceFactoryOpts<S, M>): SubscribeHandler<S, M, unknown>;
498
+
499
+ declare function fromEventTarget<S extends Sub, M>(getTarget: () => MinimalEventTarget, eventName: string, msgFn: (event: MinimalEvent, sub: S) => M | null): SubscribeHandler<S, M, unknown>;
500
+
501
+ type IntervalSubData = {
502
+ intervalMs: number;
503
+ };
504
+ declare function fromInterval<S extends Sub & IntervalSubData, M>(msgFn: (sub: S) => M): SubscribeHandler<S, M, unknown>;
505
+
506
+ declare function fromPort<S extends Sub, M, Ctx, T, RS = unknown, RM extends {
507
+ type: string;
508
+ } = {
509
+ type: string;
510
+ }>(selectRuntime: (ctx: Ctx) => Runtime<RS, RM>, port: Port<T>, msgFn: (value: T, sub: S) => M | null): SubscribeHandler<S, M, Ctx>;
511
+
512
+ type WebSocketSubData = {
513
+ wsUrl: string;
514
+ };
515
+ interface WebSocketFactoryOpts<S, M> {
516
+ onMessage: (data: unknown, sub: S) => M | null;
517
+ onOpen?: (sub: S) => M | null;
518
+ onError?: (event: MinimalEvent, sub: S) => M | null;
519
+ onClose?: (code: number, reason: string, sub: S) => M | null;
520
+ }
521
+ declare function fromWebSocket<S extends Sub & WebSocketSubData, M>(opts: WebSocketFactoryOpts<S, M>): SubscribeHandler<S, M, unknown>;
522
+
523
+ /** Cancels a scheduled reconnect timer (the inverse of `schedule`). */
524
+ type CancelTimer = () => void;
525
+ interface ReconnectingWebSocketFactoryOpts<S, M> {
526
+ onMessage: (data: unknown, sub: S) => M | null;
527
+ onOpen?: (sub: S) => M | null;
528
+ onError?: (event: MinimalEvent, sub: S) => M | null;
529
+ onClose?: (code: number, reason: string, sub: S) => M | null;
530
+ /**
531
+ * Fires when a reconnection (any open after the first) succeeds, carrying the
532
+ * 1-based reconnect count — the resync hook. Omitting drops reconnect events
533
+ * silently.
534
+ */
535
+ onReconnect?: (attempt: number, sub: S) => M | null;
536
+ /** First backoff delay in ms (doubles each failed attempt). Default 250. */
537
+ backoffBaseMs?: number;
538
+ /** Backoff ceiling in ms. Default 5000. */
539
+ backoffMaxMs?: number;
540
+ /** Inject the socket constructor (defaults to the global `WebSocket`); the test seam. */
541
+ connect?: (url: string) => MinimalWebSocket;
542
+ /** Inject the timer (defaults to `setTimeout`/`clearTimeout`); the test seam. */
543
+ schedule?: (fn: () => void, ms: number) => CancelTimer;
544
+ }
545
+ declare function fromReconnectingWebSocket<S extends Sub & WebSocketSubData, M>(opts: ReconnectingWebSocketFactoryOpts<S, M>): SubscribeHandler<S, M, unknown>;
546
+
547
+ type TimeoutSubData = {
548
+ delayMs: number;
549
+ };
550
+ declare function fromTimeout<S extends Sub & TimeoutSubData, M>(msgFn: (sub: S) => M): SubscribeHandler<S, M, unknown>;
551
+
552
+ /**
553
+ * The Sub the battery builds. The consumer's `Sub` union includes
554
+ * `ManagedResourceSub<TKey>` directly — the substrate reconciles by `id` and
555
+ * `type` like any other Sub.
556
+ */
557
+ interface ManagedResourceSub<TKey> extends Sub<"managed_resource"> {
558
+ /** The lifetime key. Stable while the resource should be held; a change
559
+ * retires the old resource (release) and acquires a fresh one. */
560
+ readonly key: TKey;
561
+ }
562
+ /**
563
+ * A battery paired with a state-gate. Self-contained: it knows its `name`
564
+ * (for the unique-name assert), how to derive its live Sub from a state
565
+ * (`subFor`), how to handle its own `subscribe`, and whether it `owns` a given
566
+ * Sub id.
567
+ *
568
+ * Generic in the consumer state `S`, the shared lifetime key `TKey`, and the
569
+ * shared `Ctx`. `Handle` is the ONLY thing erased — each battery's handle type
570
+ * differs (a checkpoint saver vs. a tool-call bridge) but never crosses this
571
+ * interface, so a `combineManagedResources` array holds entries of
572
+ * heterogeneous handle types with no cast. The sub type stays
573
+ * `ManagedResourceSub<TKey>` end to end, so the substrate's narrowed Sub flows
574
+ * straight in.
575
+ */
576
+ interface GatedManagedResource<S, TKey, Ctx> {
577
+ /** The owning battery's `name`. The combinator asserts these are unique. */
578
+ readonly name: string;
579
+ /**
580
+ * Derive this resource's live Sub for a given state: the battery's
581
+ * `.sub(key)` when `when(state)` returns a key, or `null` when it returns
582
+ * `null` (the resource should be torn down in that state).
583
+ */
584
+ readonly subFor: (state: S) => ManagedResourceSub<TKey> | null;
585
+ /**
586
+ * This battery's own `.subscribe`. The combinator routes an incoming
587
+ * `managed_resource` Sub to the entry whose `owns(sub)` is true, then calls
588
+ * this.
589
+ */
590
+ readonly subscribe: (sub: ManagedResourceSub<TKey>, ctx: Ctx, dispatch: (msg: never) => void) => Dispose;
591
+ /**
592
+ * Does this entry own the given Sub? `sub.id === subIdFor(sub.key)` encodes
593
+ * the battery `name`, so a match is unambiguous.
594
+ */
595
+ readonly owns: (sub: ManagedResourceSub<TKey>) => boolean;
596
+ }
597
+ /**
598
+ * What `combineManagedResources` returns: the single managed-resource
599
+ * `subscribe` handler for the machine's `subscribe` record, and a `subs(state)`
600
+ * builder for `subscriptions(state)`.
601
+ */
602
+ interface CombinedManagedResources<S, TKey, Ctx> {
603
+ /**
604
+ * Map every entry through its `when(state)`, drop the `null`s, and build the
605
+ * live Subs. Spread into `subscriptions(state)`. The derived list and the
606
+ * `subscribe` routing share one source — the entries — so they never drift.
607
+ */
608
+ readonly subs: (state: S) => ManagedResourceSub<TKey>[];
609
+ /**
610
+ * The SINGLE `subscribe.managed_resource` handler. Routes an incoming Sub to
611
+ * the owning battery by matching `sub.id === battery.subIdFor(sub.key)` (the
612
+ * id encodes the battery `name`). Throws loudly on an unrouted id — a wiring
613
+ * bug, never a silent no-op resource.
614
+ */
615
+ readonly subscribe: (sub: ManagedResourceSub<TKey>, ctx: Ctx, dispatch: (msg: never) => void) => Dispose;
616
+ }
617
+ interface DefineManagedResourceOpts<TKey, Handle, Ctx> {
618
+ /**
619
+ * A short, stable name. The Sub id is `managed:${name}:${stringify(key)}`,
620
+ * so two managed resources in one machine never collide and neither
621
+ * collides with a `fromTransport` Sub keyed on the same identity.
622
+ */
623
+ readonly name: string;
624
+ /**
625
+ * Build the resource. Runs when the Sub appears in `subscriptions(state)`.
626
+ * The returned Handle is the ONLY thing `release` receives — capture
627
+ * everything teardown needs into it. If `acquire` throws, the substrate's
628
+ * reconcile does NOT register the Sub and `release` is never called (no
629
+ * dangling half-built resource).
630
+ */
631
+ readonly acquire: (key: TKey, ctx: Ctx) => Handle;
632
+ /**
633
+ * Tear the resource down. Runs when the Sub leaves the desired set (phase
634
+ * exited) or when its key changes. MANDATORY — the guaranteed teardown is
635
+ * the reason this battery exists.
636
+ *
637
+ * May be sync or async, and an async one is really awaited: the promise is
638
+ * returned to the substrate, which tracks it and drains it inside `stop()`
639
+ * (bounded by `run({ disposeTimeoutMs })`). So `await runtime.stop()` means
640
+ * the release finished — the reading a host evicting an isolate acts on.
641
+ * MID-RUN teardown (a phase exit, a key change) is still fire-and-forget
642
+ * (Rule 2): the reconcile pass is synchronous by construction, so it starts
643
+ * the release and moves on. A rejection is never a Msg — it reaches the
644
+ * runtime's `onError` sink under `phase: "sub-cleanup"`.
645
+ */
646
+ readonly release: (handle: Handle) => void | Promise<void>;
647
+ }
648
+ /**
649
+ * What the battery returns: a `.sub(key)` builder for `subscriptions`, the
650
+ * `.subscribe` handler for the machine's `subscribe` record, a `.get(key)`
651
+ * accessor so Cmd handlers can reach the live Handle while the resource is
652
+ * held, and a `.subIdFor(key)` for tests.
653
+ */
654
+ interface ManagedResourceBattery<TKey, Handle, Ctx> {
655
+ /**
656
+ * Build the Sub for `subscriptions(state)`. The consumer calls this from
657
+ * inside their `subscriptions` cell for the phases where the resource
658
+ * should be live.
659
+ */
660
+ readonly sub: (key: TKey) => ManagedResourceSub<TKey>;
661
+ /**
662
+ * Pair this battery with a state-gate, producing a self-contained entry for
663
+ * `combineManagedResources`. `when(state)` returns the resource's KEY when
664
+ * it should be live in that state, or `null` when it should be torn down.
665
+ *
666
+ * Folding "is it active?" and "what key?" into ONE declaration at the
667
+ * battery's own definition site is the point: a central `subscriptions(state)`
668
+ * list can silently forget to gate a new phase, but a per-resource gate
669
+ * travels with the resource. The combinator derives BOTH the active-sub list
670
+ * and the subscribe routing from these entries, so the two can never disagree.
671
+ *
672
+ * Generic in the consumer's state `S` (each `.gated` call binds its own `S`).
673
+ * The returned entry erases this battery's `Handle` — `combineManagedResources`
674
+ * holds entries of heterogeneous handle types with no cast — while keeping
675
+ * `TKey` and `Ctx` so the substrate's narrowed `ManagedResourceSub<TKey>`
676
+ * flows straight into the entry's `subscribe`.
677
+ */
678
+ readonly gated: <S>(when: (state: S) => TKey | null) => GatedManagedResource<S, TKey, Ctx>;
679
+ /**
680
+ * Dep-keyed entry for the machine's `subs` array. `when(state)` returns the
681
+ * resource's KEY when it should be held, or `null` when it should be torn
682
+ * down — the exact gate `.gated` takes, now producing a `DepKeyedSub` the
683
+ * kernel folds directly instead of an entry the `combineManagedResources`
684
+ * router multiplexes.
685
+ *
686
+ * This is the simplification the dep-keyed kernel unlocks: two managed
687
+ * resources used to COLLIDE on the single `subscribe.managed_resource` key
688
+ * (both subs share `type: "managed_resource"`), forcing
689
+ * `combineManagedResources` to route by SubId. A dep-keyed Sub has its OWN
690
+ * reconcile slot (its array position), so there is no shared `type` to route
691
+ * — each resource is one `subs` entry, no combinator, no router. `acquire` /
692
+ * `release` still ride the kernel's dispose-on-change / dispose-on-null
693
+ * reconcile, now via the dep-keyed source's `Dispose` instead of the
694
+ * `subscribe` cell's cleanup.
695
+ */
696
+ readonly depKeyed: <S>(when: (state: S) => TKey | null) => DepKeyedSub<S, never, Ctx>;
697
+ /**
698
+ * The `subscribe.managed_resource` handler. Drop straight into the
699
+ * machine's `subscribe` record. Runs `acquire` on install, holds the
700
+ * Handle in the battery's handle table, and returns a cleanup that runs
701
+ * `release` (and forgets the Handle) on reconcile-out.
702
+ */
703
+ readonly subscribe: (sub: ManagedResourceSub<TKey>, ctx: Ctx, dispatch: (msg: never) => void) => Dispose;
704
+ /**
705
+ * Accessor for the live Handle, keyed on `key`. Returns `undefined` when
706
+ * the resource is not currently held (no active sub for that key) — the
707
+ * caller decides whether that is an error. A Cmd handler wires its
708
+ * `ctx.getX(key)` through this, so the handler reads the SAME owner the
709
+ * reconciler holds, never a hand-built duplicate.
710
+ */
711
+ readonly get: (key: TKey) => Handle | undefined;
712
+ /** Pre-derived subId for `(key)` — handy for tests. */
713
+ readonly subIdFor: (key: TKey) => SubId;
714
+ }
715
+ /**
716
+ * Build the battery. One call per managed resource at the machine's host
717
+ * file.
718
+ *
719
+ * @example
720
+ * const checkpointStore = defineManagedResource<RunId, CheckpointSaver, Ctx>({
721
+ * name: "checkpoint",
722
+ * acquire: (runId, ctx) =>
723
+ * new CheckpointSaver({ storage: ctx.storage, bucket: ctx.bucket, runId }),
724
+ * release: (saver) => saver.clear(),
725
+ * });
726
+ *
727
+ * // In the machine:
728
+ * subscriptions: (state) =>
729
+ * state.type === "running" ? [checkpointStore.sub(state.runId)] : [],
730
+ * subscribe: { managed_resource: checkpointStore.subscribe },
731
+ *
732
+ * // In interpret (read the live handle the reconciler holds):
733
+ * start_graph: async (cmd, ctx) => {
734
+ * const saver = checkpointStore.get(cmd.runId); // same owner, no rebuild
735
+ * ...
736
+ * }
737
+ */
738
+ declare function defineManagedResource<TKey, Handle, Ctx>(opts: DefineManagedResourceOpts<TKey, Handle, Ctx>): ManagedResourceBattery<TKey, Handle, Ctx>;
739
+ declare function combineManagedResources<S, TKey, Ctx>(entries: readonly GatedManagedResource<S, TKey, Ctx>[]): CombinedManagedResources<S, TKey, Ctx>;
740
+
741
+ /**
742
+ * Duplex transport. The host (DO, worker thread, in-process bus) constructs
743
+ * one from whatever the platform offers. `fromTransport` does not know what
744
+ * a WebSocket is — it knows `send`, `onMessage`, `onClose`.
745
+ */
746
+ interface Transport {
747
+ /** Send a string frame. Best-effort; failures are logged at the boundary. */
748
+ send(data: string): void;
749
+ /**
750
+ * Subscribe to inbound frames. Returns a cleanup that removes the listener.
751
+ * The battery wires this in its Sub's subscribe handler; cleanup runs when
752
+ * the phase exits (the substrate's reconcileSubs).
753
+ */
754
+ onMessage(listener: (data: string) => void): () => void;
755
+ /**
756
+ * Subscribe to a one-shot close. Returns a cleanup that removes the
757
+ * listener. The battery dispatches `lostMsg` on close.
758
+ */
759
+ onClose(listener: () => void): () => void;
760
+ /** Close the underlying channel cleanly. Called by the Sub cleanup. */
761
+ close(): void;
762
+ }
763
+ /**
764
+ * Factory the consumer wires to a platform-specific transport. The battery
765
+ * passes the runtime-derived key (`runId`, or whatever identity is on the
766
+ * phase) so per-run transports can be addressed.
767
+ */
768
+ type TransportFactory<K> = (key: K) => Transport;
769
+ /**
770
+ * The Sub the battery builds. The consumer's `Sub` union includes
771
+ * `TransportSub<TKey>` directly — no wrapping needed, the substrate
772
+ * reconciles by `id` and `type` like any other Sub.
773
+ */
774
+ interface TransportSub<TKey> extends Sub<"transport"> {
775
+ /** The phase / run identity. Stable for the lifetime of the seam. */
776
+ readonly key: TKey;
777
+ }
778
+ interface FromTransportOpts<TKey, Inbound, Outbound, M, Ctx> {
779
+ /**
780
+ * A short, stable name for this seam. The Sub id is derived from
781
+ * `${name}:${stringify(key)}` so two seams in the same machine (e.g.
782
+ * `hands` + `worker`) never collide.
783
+ */
784
+ readonly name: string;
785
+ /**
786
+ * Build the transport. The battery owns the lifetime; the factory is the
787
+ * platform-specific constructor (`new WebSocket(...)` adapter on a DO,
788
+ * `MessagePort` adapter in a worker, in-memory stub in tests).
789
+ */
790
+ readonly openTransport: (key: TKey, ctx: Ctx) => Transport;
791
+ /**
792
+ * Parse one inbound frame. The battery hands `unknown` through (boundary
793
+ * parse is the consumer's responsibility per invariant 8). Returning
794
+ * `null` drops the frame silently — useful for frames the seam doesn't
795
+ * recognize at this layer (e.g. transport-level keepalive).
796
+ */
797
+ readonly parseInbound: (raw: string, key: TKey) => Inbound | null;
798
+ /**
799
+ * Map a parsed inbound to a domain Msg. Returning `null` drops the
800
+ * dispatch (e.g. a transport-level pong that doesn't change domain state).
801
+ */
802
+ readonly onInbound: (inbound: Inbound, key: TKey) => M | null;
803
+ /**
804
+ * The Msg dispatched when the transport closes (peer gone, network
805
+ * dropped, normal close). ONE Msg arm, not a Sub, not a heartbeat-derived
806
+ * deadline — the transport's own close signal is the truth.
807
+ */
808
+ readonly lostMsg: (key: TKey) => M;
809
+ /**
810
+ * Serialize an outbound. Called by the Cmd handler the battery wires.
811
+ * Pure data → string at the seam boundary.
812
+ */
813
+ readonly serializeOutbound: (outbound: Outbound) => string;
814
+ }
815
+ /**
816
+ * What the battery returns: a Sub builder (for `subscriptions`), the Sub's
817
+ * `subscribe` handler (for `subscribe.transport`), and a `send(key, outbound)`
818
+ * helper the consumer's Cmd handler calls. Plus a `subIdFor` factory the
819
+ * consumer can use when keying related Subs (e.g. a deadline) to the same seam
820
+ * identity.
821
+ */
822
+ interface TransportBattery<TKey, Outbound, M, Ctx> {
823
+ /**
824
+ * Build the Sub for `subscriptions(state)`. The consumer calls this from
825
+ * inside their `subscriptions` cell when the seam should be open.
826
+ */
827
+ readonly sub: (key: TKey) => TransportSub<TKey>;
828
+ /**
829
+ * The `subscribe.transport` handler. Drop straight into the machine's
830
+ * `subscribe` record — the battery wires inbound + close in one shot.
831
+ */
832
+ readonly subscribe: (sub: TransportSub<TKey>, ctx: Ctx, dispatch: (msg: M) => void) => () => void;
833
+ /**
834
+ * Outbound send. The Cmd handler calls this; the battery's handle table
835
+ * (built when subscribe ran) routes to the live transport. If the seam
836
+ * is closed (no active sub), the send is dropped honestly (logged, not
837
+ * thrown — the reducer already moved past caring, same shape as Rule 2
838
+ * fire-and-forget Cmds).
839
+ */
840
+ readonly send: (key: TKey, outbound: Outbound) => void;
841
+ /** Pre-derived subId for `(key)` — handy for deadline Subs keyed to the same seam. */
842
+ readonly subIdFor: (key: TKey) => SubId;
843
+ /**
844
+ * Pair this seam with a state-gate, producing a dep-keyed Sub for the
845
+ * machine's `subs` array. `when(state)` returns the seam's KEY when it
846
+ * should be open, or `null` when it should be torn down. The kernel derives
847
+ * the id from `structuralHash(key)` and reconciles the seam's lifetime — so
848
+ * the author neither lists this Sub in a central `subscriptions(state)` nor
849
+ * writes its id. Replaces `subscriptions: (s) => active(s) ? [hands.sub(...)] : []`
850
+ * + `subscribe: { transport: hands.subscribe }` with one `subs` entry.
851
+ *
852
+ * The `source` closes over the battery's own `subscribe` (open inbound +
853
+ * close, wire the handle table) using the same `ctx` the kernel passes every
854
+ * Sub source.
855
+ */
856
+ readonly depKeyed: <S>(when: (state: S) => TKey | null) => DepKeyedSub<S, M, Ctx>;
857
+ }
858
+ /**
859
+ * Build the battery. One call per seam at the machine's host file.
860
+ *
861
+ * @example
862
+ * const handsSeam = fromTransport<RunId, HandsInbound, HandsOutbound, Msg, Ctx>({
863
+ * name: "hands",
864
+ * openTransport: (runId, ctx) => ctx.openHandsWs(runId),
865
+ * parseInbound: (raw) => parseHandsInbound(JSON.parse(raw)),
866
+ * onInbound: (inbound, runId) => ({ type: "hands_said", runId, inbound }),
867
+ * lostMsg: (runId) => ({ type: "hands_lost", runId }),
868
+ * serializeOutbound: (out) => JSON.stringify(out),
869
+ * });
870
+ *
871
+ * // In the machine:
872
+ * subscriptions: (state) => state.type === "auditing" ? [handsSeam.sub(state.runId)] : [],
873
+ * subscribe: { transport: handsSeam.subscribe },
874
+ *
875
+ * // In interpret:
876
+ * send_hands: async (cmd) => { handsSeam.send(cmd.runId, cmd.outbound); },
877
+ */
878
+ declare function fromTransport<TKey, Inbound, Outbound, M, Ctx>(opts: FromTransportOpts<TKey, Inbound, Outbound, M, Ctx>): TransportBattery<TKey, Outbound, M, Ctx>;
114
879
 
115
- export { BootingRuntime, Cmd, CtxArg, type HistoryTracker, Machine, OnError, RequiredCtx, Store, Sub, Supervision, historyTracker, run };
880
+ export { type Ack, type AckPartition, BootingRuntime, type CancelTimer, Cmd, type CombinedManagedResources, type DefineManagedResourceOpts, DepKeyedSub, Dispose, type DriveToDoneOptions, type EventSourceFactoryOpts, type FromTransportOpts, type GatedManagedResource, type HistoryTracker, type ListenerTarget, Machine, type ManagedResourceBattery, type ManagedResourceSub, NO_ACK, OnError, Port, type ReadStep, type ReconnectingWebSocketFactoryOpts, RequiredCtx, Runtime, ScopedCtxArg, type Seq, type SeqTagged, Store, Sub, SubId, SubscribeHandler, Supervision, type Transport, type TransportBattery, type TransportFactory, type TransportSub, type WebSocketFactoryOpts, type WebSocketSubData, ack, combineManagedResources, defineListener, defineManagedResource, driveToDone, fromBroadcastChannel, fromEventSource, fromEventTarget, fromInterval, fromPort, fromReconnectingWebSocket, fromTimeout, fromTransport, fromWebSocket, historyTracker, initAck, liftSlice, nextSeq, partitionByAck, readInOrder, reconcile, run, tagSeq };