@demlik/tea 0.12.0 → 0.14.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 (368) 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-25LBDCBC.js → chunk-6IQPODUF.js} +2 -2
  5. package/dist/{chunk-25LBDCBC.js.map → chunk-6IQPODUF.js.map} +1 -1
  6. package/dist/chunk-AQ6ZIMEA.js +421 -0
  7. package/dist/chunk-AQ6ZIMEA.js.map +1 -0
  8. package/dist/{chunk-MUUROGIH.js → chunk-BLJ2JQSH.js} +62 -12
  9. package/dist/chunk-BLJ2JQSH.js.map +1 -0
  10. package/dist/{chunk-7SVIRMC6.js → chunk-F2US5BW6.js} +25 -5
  11. package/dist/chunk-F2US5BW6.js.map +1 -0
  12. package/dist/{batch-window/index.js → chunk-F7FMAWLA.js} +4 -8
  13. package/dist/chunk-F7FMAWLA.js.map +1 -0
  14. package/dist/{chunk-7V4EVLZA.js → chunk-HUKZQX6U.js} +20 -16
  15. package/dist/chunk-HUKZQX6U.js.map +1 -0
  16. package/dist/{chunk-EWJP3YYP.js → chunk-HWVW4AXC.js} +3 -3
  17. package/dist/chunk-HWVW4AXC.js.map +1 -0
  18. package/dist/{chunk-WLGO64WC.js → chunk-HYDWG35Q.js} +23 -6
  19. package/dist/chunk-HYDWG35Q.js.map +1 -0
  20. package/dist/{chunk-I5OV65MS.js → chunk-I5MQMJDW.js} +57 -7
  21. package/dist/chunk-I5MQMJDW.js.map +1 -0
  22. package/dist/{chunk-J6527VRQ.js → chunk-LFZUK6J2.js} +3 -3
  23. package/dist/chunk-LFZUK6J2.js.map +1 -0
  24. package/dist/{chunk-ZVJZ72HY.js → chunk-LYLTKJWM.js} +25 -11
  25. package/dist/chunk-LYLTKJWM.js.map +1 -0
  26. package/dist/{chunk-D736QUGF.js → chunk-MYXFNWAJ.js} +4 -5
  27. package/dist/chunk-MYXFNWAJ.js.map +1 -0
  28. package/dist/{chunk-K575PT4S.js → chunk-PR6TB3BL.js} +15 -4
  29. package/dist/chunk-PR6TB3BL.js.map +1 -0
  30. package/dist/chunk-RQULHGYH.js +1804 -0
  31. package/dist/chunk-RQULHGYH.js.map +1 -0
  32. package/dist/{chunk-FV3Z5MBE.js → chunk-TXN2KFHF.js} +14 -4
  33. package/dist/chunk-TXN2KFHF.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-Z2L3LSNV.js +1470 -0
  37. package/dist/chunk-Z2L3LSNV.js.map +1 -0
  38. package/dist/core-CTzMJ82M.d.ts +562 -0
  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 +48 -31
  43. package/dist/do/index.js +36 -25
  44. package/dist/do/index.js.map +1 -1
  45. package/dist/{durable-effects-D8SqU_if.d.ts → durable-effects-B0-qGQDy.d.ts} +2 -2
  46. package/dist/extension/index.d.ts +301 -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 +1295 -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/{batch-window/index.d.ts → index-4vZzljCD.d.ts} +7 -11
  55. package/dist/{fan-out/index.d.ts → index-6A7dB8f6.d.ts} +7 -8
  56. package/dist/index-B5BZ-_cT.d.ts +616 -0
  57. package/dist/index-Bc40JWVl.d.ts +131 -0
  58. package/dist/{debounce/index.d.ts → index-DHSUmQTR.d.ts} +7 -7
  59. package/dist/index-DJWIER_3.d.ts +69 -0
  60. package/dist/{snapshot/index.d.ts → index-DMCeMPMJ.d.ts} +15 -77
  61. package/dist/{monitored-run/index.d.ts → index-NjrT3fL2.d.ts} +37 -12
  62. package/dist/{recorder/index.d.ts → index-TvRb1KVf.d.ts} +4 -6
  63. package/dist/{deadline/index.d.ts → index-q0hXFeZ0.d.ts} +155 -8
  64. package/dist/index.d.ts +719 -6
  65. package/dist/index.js +1 -2
  66. package/dist/jev/index.d.ts +634 -0
  67. package/dist/jev/index.js +433 -0
  68. package/dist/jev/index.js.map +1 -0
  69. package/dist/machine-CdIcN2Xm.d.ts +1773 -0
  70. package/dist/machine-viz/index.d.ts +2 -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 +19 -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 +130 -4
  77. package/dist/node/index.js +222 -10
  78. package/dist/node/index.js.map +1 -1
  79. package/dist/{paginator → paginate}/index.d.ts +151 -6
  80. package/dist/paginate/index.js +7 -0
  81. package/dist/parity/index.d.ts +5 -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 +248 -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 -4
  88. package/dist/persistence/index.js +6 -0
  89. package/dist/react/index.d.ts +4 -3
  90. package/dist/react/index.js +1 -2
  91. package/dist/react/index.js.map +1 -1
  92. package/dist/resilience/index.d.ts +743 -0
  93. package/dist/resilience/index.js +657 -0
  94. package/dist/resilience/index.js.map +1 -0
  95. package/dist/retry-backoff/index.d.ts +3 -2
  96. package/dist/retry-backoff/index.js +1 -1
  97. package/dist/runtime-types-LWDoi943.d.ts +998 -0
  98. package/dist/testing/index.d.ts +3 -2
  99. package/dist/testing/index.js +1 -2
  100. package/dist/testing/index.js.map +1 -1
  101. package/dist/{throttled-input → timing}/index.d.ts +144 -12
  102. package/dist/{throttled-input → timing}/index.js +57 -12
  103. package/dist/timing/index.js.map +1 -0
  104. package/dist/{types-D7u9DkH7.d.ts → types-DP3f5NIl.d.ts} +1 -1
  105. package/dist/work-queue/index.d.ts +131 -54
  106. package/dist/work-queue/index.js +3 -2
  107. package/dist/work-queue/index.js.map +1 -1
  108. package/package.json +50 -216
  109. package/dist/authed-call/index.d.ts +0 -119
  110. package/dist/authed-call/index.js +0 -134
  111. package/dist/authed-call/index.js.map +0 -1
  112. package/dist/await-terminal/index.d.ts +0 -100
  113. package/dist/await-terminal/index.js +0 -76
  114. package/dist/await-terminal/index.js.map +0 -1
  115. package/dist/batch-window/index.js.map +0 -1
  116. package/dist/cache/index.d.ts +0 -151
  117. package/dist/cache/index.js +0 -8
  118. package/dist/chart/index.d.ts +0 -217
  119. package/dist/chart/index.js +0 -16
  120. package/dist/chart/index.js.map +0 -1
  121. package/dist/chart/inspect/index.d.ts +0 -85
  122. package/dist/chart/inspect/index.js +0 -5
  123. package/dist/chart/inspect/react.d.ts +0 -112
  124. package/dist/chart/inspect/react.js +0 -11
  125. package/dist/chart/inspect/react.js.map +0 -1
  126. package/dist/chart/inspect/styles.css +0 -286
  127. package/dist/chart/lane/index.d.ts +0 -361
  128. package/dist/chart/lane/index.js +0 -9
  129. package/dist/chart/lane/index.js.map +0 -1
  130. package/dist/chart/lane/react.d.ts +0 -83
  131. package/dist/chart/lane/react.js +0 -559
  132. package/dist/chart/lane/react.js.map +0 -1
  133. package/dist/chart/lane/server.d.ts +0 -148
  134. package/dist/chart/lane/server.js +0 -209
  135. package/dist/chart/lane/server.js.map +0 -1
  136. package/dist/chart/lane/styles.css +0 -498
  137. package/dist/chart/lane/viewer/assets/abnfDiagram-N423BO3Z-C729LI31.js +0 -1
  138. package/dist/chart/lane/viewer/assets/architectureDiagram-T3A2C74G-C729LI31.js +0 -1
  139. package/dist/chart/lane/viewer/assets/blockDiagram-VBNYF7ZC-C729LI31.js +0 -1
  140. package/dist/chart/lane/viewer/assets/c4Diagram-5PPSVZJV-C729LI31.js +0 -1
  141. package/dist/chart/lane/viewer/assets/chunk-2GRJ4B5K-HdDf8SI3.js +0 -1
  142. package/dist/chart/lane/viewer/assets/chunk-5RXB4S5H-CcNtpUd7.js +0 -231
  143. package/dist/chart/lane/viewer/assets/chunk-5VM5RSS4-BP4fRS_5.js +0 -15
  144. package/dist/chart/lane/viewer/assets/chunk-KBJHAD2P-DZOw7xU6.js +0 -1
  145. package/dist/chart/lane/viewer/assets/chunk-NSK5VX7P-CBCyTZMs.js +0 -128
  146. package/dist/chart/lane/viewer/assets/classDiagram-JCYQIIEL-C729LI31.js +0 -1
  147. package/dist/chart/lane/viewer/assets/classDiagram-v2-OCEON4UE-D4uAiFr8.js +0 -206
  148. package/dist/chart/lane/viewer/assets/cose-bilkent-JH36ORCC-DOwCrGXH.js +0 -1
  149. package/dist/chart/lane/viewer/assets/cynefinDiagram-MW4NZA55-C729LI31.js +0 -1
  150. package/dist/chart/lane/viewer/assets/dagre-K_PewWfS.js +0 -1
  151. package/dist/chart/lane/viewer/assets/dagre-VZM6K2ZE-831qZcA8.js +0 -4
  152. package/dist/chart/lane/viewer/assets/diagram-7IWD3JNH-C729LI31.js +0 -1
  153. package/dist/chart/lane/viewer/assets/diagram-B4RE2ZJO-C729LI31.js +0 -1
  154. package/dist/chart/lane/viewer/assets/diagram-LBJQPF4R-C729LI31.js +0 -1
  155. package/dist/chart/lane/viewer/assets/diagram-Q27KOJAE-C729LI31.js +0 -1
  156. package/dist/chart/lane/viewer/assets/diagram-UB23O5K3-C729LI31.js +0 -1
  157. package/dist/chart/lane/viewer/assets/ebnfDiagram-BXEA7PRR-C729LI31.js +0 -1
  158. package/dist/chart/lane/viewer/assets/erDiagram-JOGREHBK-C729LI31.js +0 -1
  159. package/dist/chart/lane/viewer/assets/flowDiagram-UKHOOZJN-C729LI31.js +0 -1
  160. package/dist/chart/lane/viewer/assets/ganttDiagram-PKOTCBZU-C729LI31.js +0 -1
  161. package/dist/chart/lane/viewer/assets/gitGraphDiagram-DS77QQ5N-C729LI31.js +0 -1
  162. package/dist/chart/lane/viewer/assets/index-9SkH5NA3.css +0 -1
  163. package/dist/chart/lane/viewer/assets/index-Bgt4sXpW.js +0 -195
  164. package/dist/chart/lane/viewer/assets/infoDiagram-6WML65LV-C729LI31.js +0 -1
  165. package/dist/chart/lane/viewer/assets/ishikawaDiagram-WSZJBQD7-C729LI31.js +0 -1
  166. package/dist/chart/lane/viewer/assets/journeyDiagram-NVQOT4AX-C729LI31.js +0 -1
  167. package/dist/chart/lane/viewer/assets/kanban-definition-27J2QSJJ-G7PaPzy-.js +0 -89
  168. package/dist/chart/lane/viewer/assets/katex-DOwCrGXH.js +0 -1
  169. package/dist/chart/lane/viewer/assets/mindmap-definition-FAOFIHXS-CGj9nrVk.js +0 -96
  170. package/dist/chart/lane/viewer/assets/path-fybaL0A-.js +0 -1
  171. package/dist/chart/lane/viewer/assets/pegDiagram-VL7TDLO6-C729LI31.js +0 -1
  172. package/dist/chart/lane/viewer/assets/pieDiagram-7S7Q4E2Y-C729LI31.js +0 -1
  173. package/dist/chart/lane/viewer/assets/quadrantDiagram-CIZ2JOQS-C729LI31.js +0 -1
  174. package/dist/chart/lane/viewer/assets/railroadDiagram-AXF67PYL-C729LI31.js +0 -1
  175. package/dist/chart/lane/viewer/assets/requirementDiagram-LRYGKXZP-C729LI31.js +0 -1
  176. package/dist/chart/lane/viewer/assets/sankeyDiagram-W5VNT64P-C729LI31.js +0 -1
  177. package/dist/chart/lane/viewer/assets/sequenceDiagram-SI44F4Z6-C729LI31.js +0 -1
  178. package/dist/chart/lane/viewer/assets/stateDiagram-OKZ733FA-B_88AzBS.js +0 -1
  179. package/dist/chart/lane/viewer/assets/stateDiagram-v2-UEYNNEHI-CR5gcgq6.js +0 -1
  180. package/dist/chart/lane/viewer/assets/swimlanes-SLNWSIFB-B4xK-rwg.js +0 -1
  181. package/dist/chart/lane/viewer/assets/swimlanesDiagram-ULZ7WXOC-C729LI31.js +0 -1
  182. package/dist/chart/lane/viewer/assets/timeline-definition-Z64GVDOM-CCv52MfY.js +0 -120
  183. package/dist/chart/lane/viewer/assets/vennDiagram-T6HMQDX7-C729LI31.js +0 -1
  184. package/dist/chart/lane/viewer/assets/wardleyDiagram-T6FBY63Y-C729LI31.js +0 -1
  185. package/dist/chart/lane/viewer/assets/xychartDiagram-ELKLHX3M-C729LI31.js +0 -1
  186. package/dist/chart/lane/viewer/index.html +0 -15
  187. package/dist/chart/report/index.d.ts +0 -116
  188. package/dist/chart/report/index.js +0 -32
  189. package/dist/chart/report/index.js.map +0 -1
  190. package/dist/chunk-2YFLOCWX.js +0 -15
  191. package/dist/chunk-2YFLOCWX.js.map +0 -1
  192. package/dist/chunk-3JU6657S.js +0 -372
  193. package/dist/chunk-3JU6657S.js.map +0 -1
  194. package/dist/chunk-4KTWLPL5.js +0 -33
  195. package/dist/chunk-4KTWLPL5.js.map +0 -1
  196. package/dist/chunk-5EHLEUTL.js +0 -686
  197. package/dist/chunk-5EHLEUTL.js.map +0 -1
  198. package/dist/chunk-5KJKJOFC.js +0 -758
  199. package/dist/chunk-5KJKJOFC.js.map +0 -1
  200. package/dist/chunk-7SVIRMC6.js.map +0 -1
  201. package/dist/chunk-7V4EVLZA.js.map +0 -1
  202. package/dist/chunk-A56OR5RF.js +0 -184
  203. package/dist/chunk-A56OR5RF.js.map +0 -1
  204. package/dist/chunk-AZZLE7XR.js +0 -62
  205. package/dist/chunk-AZZLE7XR.js.map +0 -1
  206. package/dist/chunk-B5VXOFMZ.js +0 -266
  207. package/dist/chunk-B5VXOFMZ.js.map +0 -1
  208. package/dist/chunk-BYQUGDD3.js +0 -16
  209. package/dist/chunk-BYQUGDD3.js.map +0 -1
  210. package/dist/chunk-D736QUGF.js.map +0 -1
  211. package/dist/chunk-E6GEDSF4.js +0 -307
  212. package/dist/chunk-E6GEDSF4.js.map +0 -1
  213. package/dist/chunk-EUF7XOEE.js +0 -223
  214. package/dist/chunk-EUF7XOEE.js.map +0 -1
  215. package/dist/chunk-EWJP3YYP.js.map +0 -1
  216. package/dist/chunk-FV3Z5MBE.js.map +0 -1
  217. package/dist/chunk-HCEVHFJ7.js +0 -54
  218. package/dist/chunk-HCEVHFJ7.js.map +0 -1
  219. package/dist/chunk-I5OV65MS.js.map +0 -1
  220. package/dist/chunk-J6527VRQ.js.map +0 -1
  221. package/dist/chunk-JELSZN25.js +0 -47
  222. package/dist/chunk-JELSZN25.js.map +0 -1
  223. package/dist/chunk-JER5O7PQ.js +0 -416
  224. package/dist/chunk-JER5O7PQ.js.map +0 -1
  225. package/dist/chunk-JGVL3WPL.js +0 -26
  226. package/dist/chunk-JGVL3WPL.js.map +0 -1
  227. package/dist/chunk-JP5D6GSL.js +0 -71
  228. package/dist/chunk-JP5D6GSL.js.map +0 -1
  229. package/dist/chunk-K575PT4S.js.map +0 -1
  230. package/dist/chunk-MU6MCIAC.js +0 -15
  231. package/dist/chunk-MU6MCIAC.js.map +0 -1
  232. package/dist/chunk-MUUROGIH.js.map +0 -1
  233. package/dist/chunk-ND3DH6KM.js +0 -88
  234. package/dist/chunk-ND3DH6KM.js.map +0 -1
  235. package/dist/chunk-Q2UM7BXU.js.map +0 -1
  236. package/dist/chunk-S2EGRPCM.js +0 -47
  237. package/dist/chunk-S2EGRPCM.js.map +0 -1
  238. package/dist/chunk-SINXE47Y.js +0 -55
  239. package/dist/chunk-SINXE47Y.js.map +0 -1
  240. package/dist/chunk-SUST46KO.js +0 -53
  241. package/dist/chunk-SUST46KO.js.map +0 -1
  242. package/dist/chunk-TP5UPGLY.js +0 -61
  243. package/dist/chunk-TP5UPGLY.js.map +0 -1
  244. package/dist/chunk-UF4MZSLT.js +0 -53
  245. package/dist/chunk-UF4MZSLT.js.map +0 -1
  246. package/dist/chunk-UOC2PL46.js +0 -13
  247. package/dist/chunk-UOC2PL46.js.map +0 -1
  248. package/dist/chunk-WLGO64WC.js.map +0 -1
  249. package/dist/chunk-WRAA7GVZ.js +0 -209
  250. package/dist/chunk-WRAA7GVZ.js.map +0 -1
  251. package/dist/chunk-ZCL7SCBK.js +0 -685
  252. package/dist/chunk-ZCL7SCBK.js.map +0 -1
  253. package/dist/chunk-ZD6PNZBK.js +0 -457
  254. package/dist/chunk-ZD6PNZBK.js.map +0 -1
  255. package/dist/chunk-ZF6WDK2D.js +0 -519
  256. package/dist/chunk-ZF6WDK2D.js.map +0 -1
  257. package/dist/chunk-ZJ5AOYBH.js +0 -8
  258. package/dist/chunk-ZJ5AOYBH.js.map +0 -1
  259. package/dist/chunk-ZVJZ72HY.js.map +0 -1
  260. package/dist/circuit-breaker/index.d.ts +0 -197
  261. package/dist/circuit-breaker/index.js +0 -3
  262. package/dist/circuit-breaker/index.js.map +0 -1
  263. package/dist/core-Bjc0bS8j.d.ts +0 -326
  264. package/dist/deadline/index.js +0 -6
  265. package/dist/deadline/index.js.map +0 -1
  266. package/dist/debounce/index.js +0 -3
  267. package/dist/debounce/index.js.map +0 -1
  268. package/dist/extension/react.d.ts +0 -121
  269. package/dist/extension/react.js +0 -75
  270. package/dist/extension/react.js.map +0 -1
  271. package/dist/extension/subs/index.d.ts +0 -44
  272. package/dist/extension/subs/index.js +0 -80
  273. package/dist/extension/subs/index.js.map +0 -1
  274. package/dist/extension/test-utils.d.ts +0 -128
  275. package/dist/extension/test-utils.js +0 -277
  276. package/dist/extension/test-utils.js.map +0 -1
  277. package/dist/fan-out/index.js +0 -5
  278. package/dist/fan-out/index.js.map +0 -1
  279. package/dist/fold-Blbhru48.d.ts +0 -435
  280. package/dist/graph-CcjWZVrd.d.ts +0 -923
  281. package/dist/idempotency/adapter.d.ts +0 -62
  282. package/dist/idempotency/adapter.js +0 -4
  283. package/dist/idempotency/adapter.js.map +0 -1
  284. package/dist/idempotent-intake/index.d.ts +0 -187
  285. package/dist/idempotent-intake/index.js +0 -7
  286. package/dist/idempotent-intake/index.js.map +0 -1
  287. package/dist/llm-call/index.d.ts +0 -310
  288. package/dist/llm-call/index.js +0 -16
  289. package/dist/llm-call/index.js.map +0 -1
  290. package/dist/machine-0OmPvsy_.d.ts +0 -804
  291. package/dist/monitored-run/index.js +0 -10
  292. package/dist/monitored-run/index.js.map +0 -1
  293. package/dist/paginated-walk/index.d.ts +0 -234
  294. package/dist/paginated-walk/index.js +0 -16
  295. package/dist/paginated-walk/index.js.map +0 -1
  296. package/dist/paginator/index.js +0 -3
  297. package/dist/paginator/index.js.map +0 -1
  298. package/dist/pbt/arbitraries/index.d.ts +0 -135
  299. package/dist/pbt/arbitraries/index.js +0 -3
  300. package/dist/pbt/arbitraries/index.js.map +0 -1
  301. package/dist/pbt/runners/index.d.ts +0 -117
  302. package/dist/pbt/runners/index.js +0 -5
  303. package/dist/pbt/runners/index.js.map +0 -1
  304. package/dist/poller/index.d.ts +0 -351
  305. package/dist/poller/index.js +0 -115
  306. package/dist/poller/index.js.map +0 -1
  307. package/dist/prediction/index.d.ts +0 -130
  308. package/dist/prediction/index.js +0 -4
  309. package/dist/prediction/index.js.map +0 -1
  310. package/dist/protocol-B5YmJr0d.d.ts +0 -45
  311. package/dist/pure/index.d.ts +0 -2
  312. package/dist/pure/index.js +0 -4
  313. package/dist/pure/index.js.map +0 -1
  314. package/dist/rate-limit/index.d.ts +0 -115
  315. package/dist/rate-limit/index.js +0 -3
  316. package/dist/rate-limit/index.js.map +0 -1
  317. package/dist/reconciler/index.d.ts +0 -192
  318. package/dist/reconciler/index.js +0 -164
  319. package/dist/reconciler/index.js.map +0 -1
  320. package/dist/recorder/index.js +0 -3
  321. package/dist/recorder/index.js.map +0 -1
  322. package/dist/reducer-BqyoVyBG.d.ts +0 -447
  323. package/dist/resilient-call/index.d.ts +0 -319
  324. package/dist/resilient-call/index.js +0 -14
  325. package/dist/resilient-call/index.js.map +0 -1
  326. package/dist/retry-to-success/index.d.ts +0 -109
  327. package/dist/retry-to-success/index.js +0 -37
  328. package/dist/retry-to-success/index.js.map +0 -1
  329. package/dist/run-BVeqJDBF.d.ts +0 -713
  330. package/dist/runtime-types-Bxc637bp.d.ts +0 -502
  331. package/dist/saga/index.d.ts +0 -240
  332. package/dist/saga/index.js +0 -150
  333. package/dist/saga/index.js.map +0 -1
  334. package/dist/samples-DCt6nF8H.d.ts +0 -59
  335. package/dist/snapshot/index.js +0 -5
  336. package/dist/snapshot/index.js.map +0 -1
  337. package/dist/subs/index.d.ts +0 -471
  338. package/dist/subs/index.js +0 -7
  339. package/dist/subs/index.js.map +0 -1
  340. package/dist/throttle/index.d.ts +0 -134
  341. package/dist/throttle/index.js +0 -3
  342. package/dist/throttle/index.js.map +0 -1
  343. package/dist/throttled-input/index.js.map +0 -1
  344. package/dist/token-refresh/index.d.ts +0 -215
  345. package/dist/token-refresh/index.js +0 -6
  346. package/dist/token-refresh/index.js.map +0 -1
  347. package/dist/trace-replay/index.js +0 -6
  348. package/dist/trace-replay/index.js.map +0 -1
  349. package/dist/with-deadline/index.d.ts +0 -196
  350. package/dist/with-deadline/index.js +0 -111
  351. package/dist/with-deadline/index.js.map +0 -1
  352. package/dist/with-resilience/index.d.ts +0 -224
  353. package/dist/with-resilience/index.js +0 -240
  354. package/dist/with-resilience/index.js.map +0 -1
  355. package/dist/with-telemetry/index.d.ts +0 -149
  356. package/dist/with-telemetry/index.js +0 -70
  357. package/dist/with-telemetry/index.js.map +0 -1
  358. package/dist/work-queue/adapter.d.ts +0 -83
  359. package/dist/work-queue/adapter.js +0 -4
  360. package/dist/work-queue/adapter.js.map +0 -1
  361. package/dist/work-queue/ops.d.ts +0 -70
  362. package/dist/work-queue/ops.js +0 -3
  363. package/dist/work-queue/ops.js.map +0 -1
  364. package/dist/workflow/index.d.ts +0 -484
  365. package/dist/workflow/index.js +0 -244
  366. package/dist/workflow/index.js.map +0 -1
  367. /package/dist/{cache → paginate}/index.js.map +0 -0
  368. /package/dist/{chart/inspect → persistence}/index.js.map +0 -0
@@ -0,0 +1,562 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * @demlik/tea — pure-core leaf (ADR 0006).
5
+ *
6
+ * This is the runtime-free pure core of the substrate. It holds the
7
+ * client-prediction fold seam (`foldMsgs`), the form reader
8
+ * (`formOf`/`detectUpdateForm`), and the pure type vocabulary (`Machine`,
9
+ * `Reducer`, `Transitions`, `Cmd`, `Sub`, `Port`, …).
10
+ *
11
+ * **Dependency direction (the actual decoupling):** this module imports
12
+ * NOTHING from the runtime — no `better-result`, no `run`/host/`Store`. The
13
+ * runtime (`run`, the host, interpret, `Store`, subscribe — all in
14
+ * `../index.ts`) imports *from* here; never the reverse. The root door
15
+ * re-exports this surface through `./index.ts`, and
16
+ * `pure/import-graph.test.ts` is the regression fence asserting the pure
17
+ * entrypoint's import graph never reaches `run`.
18
+ *
19
+ * The one external name it reaches for is zod's TYPE surface (`import type`),
20
+ * erased at compile time — `Cmd.define` accepts zod schemas, and the parse
21
+ * against them happens at the interpret edge in `../run.ts`, never here.
22
+ */
23
+
24
+ type RequirementsOf<C> = C extends {
25
+ readonly __r?: infer R;
26
+ } ? R : unknown;
27
+ /** The `E` union one Cmd can settle with; `unknown` for an untyped Cmd. */
28
+ type ErrorsOf<C> = C extends {
29
+ readonly __e?: infer E;
30
+ } ? E : unknown;
31
+ type UnionToIntersection<U> = (U extends unknown ? (u: U) => void : never) extends (u: infer I) => void ? I : never;
32
+ type RequirementsBoxed<C> = C extends unknown ? [RequirementsOf<C>] : never;
33
+ type KnownRequirements<B> = B extends [infer R] ? unknown extends R ? never : R : never;
34
+ /**
35
+ * The `ctx` a machine's whole Cmd union requires: every Cmd's `R`, intersected.
36
+ * `run` types its `ctx` as `Ctx & RequiredCtx<C>`, so handing a machine whose
37
+ * Cmds need `{ http }` to a `run` whose ctx lacks it is a compile error. A Cmd
38
+ * that requires nothing — untyped, or `Cmd.define`d without `requirements` — leaves
39
+ * the demand of its siblings intact (#56).
40
+ *
41
+ * This is the requirement. `provide` is what satisfies it: hand `run` a
42
+ * `provide({ … })` graph in place of the object and the same `Ctx` is built once
43
+ * at boot, in dependency order, and released in reverse when the run ends.
44
+ */
45
+ type RequiredCtx<C> = UnionToIntersection<KnownRequirements<RequirementsBoxed<C>>>;
46
+ /** The shape every settled failure has (ADR 0011): a plain `_tag` record. */
47
+ type Tagged = {
48
+ readonly _tag: string;
49
+ };
50
+ /**
51
+ * One declared failure per tag. Distributive, so `TaggedError<"a" | "b">` is
52
+ * the two-arm union a `switch (error._tag)` narrows; the index signature lets a
53
+ * settle site carry detail beside the tag (`{ _tag: "timeout", afterMs }`).
54
+ */
55
+ type TaggedError<Tag extends string> = Tag extends string ? {
56
+ readonly _tag: Tag;
57
+ readonly [detail: string]: unknown;
58
+ } : never;
59
+ /**
60
+ * The kernel-minted failure: a handler returned a `_ok` value the Cmd's `ok`
61
+ * schema rejects. Plain data, so it folds into Model like any settled error;
62
+ * `issues` is zod's issue list flattened to `path` + `message` strings.
63
+ */
64
+ type MalformedResult = {
65
+ readonly _tag: "malformed_result";
66
+ readonly issues: ReadonlyArray<{
67
+ readonly path: string;
68
+ readonly message: string;
69
+ }>;
70
+ };
71
+ /**
72
+ * The payload a constructor accepts: a plain record spread beside `type`. A
73
+ * `type` key is refused at the type level — it would overwrite the discriminant.
74
+ */
75
+ type CmdInput = {
76
+ readonly type?: never;
77
+ } & Record<string, unknown>;
78
+ /**
79
+ * Phantom carrier for a Cmd's `R`. `Cmd.requirements<{ http: Http }>()` is how a
80
+ * declaration names the `Ctx` slice its handler reads — a type, not a value, so
81
+ * nothing is constructed and nothing is checked at runtime.
82
+ */
83
+ type Requirements<R> = {
84
+ readonly __r?: R;
85
+ };
86
+ /** The value `Cmd.define("fetch", …)` builds: `{ type: "fetch", ...input }`. */
87
+ type CmdValue<Name extends string, Input extends CmdInput, E extends Tagged, R> = Cmd<Name, E | MalformedResult, R> & Readonly<Input>;
88
+ type SettledOk<Name extends string, C, Ok> = {
89
+ readonly type: `${Name}_ok`;
90
+ readonly cmd: C;
91
+ readonly value: Ok;
92
+ /** Stamped by the runtime at the interpret edge (`run`'s `clock`). */
93
+ readonly at: number;
94
+ };
95
+ type SettledErr<Name extends string, C, E extends Tagged> = {
96
+ readonly type: `${Name}_err`;
97
+ readonly cmd: C;
98
+ readonly error: E | MalformedResult;
99
+ /** Stamped by the runtime at the interpret edge (`run`'s `clock`). */
100
+ readonly at: number;
101
+ };
102
+ /**
103
+ * What `Cmd.define` returns: the Cmd builder itself (`fetch({ url })`), with
104
+ * the minted Msg builders and the declaration hung on it. `E` here is the
105
+ * DECLARED tag union; the settled `_err` arm widens it by `MalformedResult`.
106
+ *
107
+ * `ok` / `err` take an optional `at` for minting OUTSIDE the runtime (a
108
+ * `replay` log, a unit test); inside `run` the interpret edge stamps it from
109
+ * the clock, so a handler never reads `Date.now()` itself.
110
+ */
111
+ interface CmdDef<Name extends string, Input extends CmdInput, Ok, E extends Tagged, R> {
112
+ (input: Input): CmdValue<Name, Input, E, R>;
113
+ /** The `type` discriminant of every Cmd this builds. */
114
+ readonly cmdType: Name;
115
+ readonly okType: `${Name}_ok`;
116
+ readonly errType: `${Name}_err`;
117
+ readonly ok: (cmd: CmdValue<Name, Input, E, R>, value: Ok, at?: number) => SettledOk<Name, CmdValue<Name, Input, E, R>, Ok>;
118
+ readonly err: (cmd: CmdValue<Name, Input, E, R>, error: E, at?: number) => SettledErr<Name, CmdValue<Name, Input, E, R>, E>;
119
+ readonly schema: {
120
+ readonly input: z.ZodType<Input>;
121
+ readonly ok: z.ZodType<Ok>;
122
+ };
123
+ /** The declared `_tag` list, verbatim. */
124
+ readonly errTags: ReadonlyArray<E["_tag"]>;
125
+ }
126
+ /**
127
+ * The declaration-erased view the runtime reads: which `type` a def builds,
128
+ * which two Msg types it settles with, and the `ok` schema the edge parses
129
+ * against. Every `CmdDef<…>` is one of these structurally.
130
+ */
131
+ type AnyCmdDef = {
132
+ readonly cmdType: string;
133
+ readonly okType: string;
134
+ readonly errType: string;
135
+ readonly schema: {
136
+ readonly ok: z.ZodType;
137
+ };
138
+ };
139
+ /** The Cmd value a def (or a union of defs) builds. */
140
+ type CmdOf<D extends AnyCmdDef> = D extends ((input: never) => infer C extends Cmd) ? C : never;
141
+ /**
142
+ * The settled-Msg union a def (or a union of defs) mints: `<name>_ok` carrying
143
+ * `value`, `<name>_err` carrying `error`. `defineMachine({ cmds })` folds this
144
+ * into the machine's `M` so the user never spells the effect half of it.
145
+ */
146
+ type Settled<D extends AnyCmdDef> = D extends CmdDef<infer Name, infer Input, infer Ok, infer E, infer R> ? SettledOk<Name, CmdValue<Name, Input, E, R>, Ok> | SettledErr<Name, CmdValue<Name, Input, E, R>, E> : never;
147
+ /** The `Ok` a def's handler must produce. */
148
+ type OkOf<D extends AnyCmdDef> = D extends CmdDef<infer _Name, infer _Input, infer Ok, infer _E, infer _R> ? Ok : never;
149
+ /** The DECLARED failure union a def's handler may settle with. */
150
+ type ErrOf<D extends AnyCmdDef> = D extends CmdDef<infer _Name, infer _Input, infer _Ok, infer E, infer _R> ? E : never;
151
+ declare function defineCmd<const Name extends string, Input extends CmdInput, Ok, const Tags extends readonly string[], R = unknown>(name: Name, spec: {
152
+ readonly input: z.ZodType<Input>;
153
+ readonly ok: z.ZodType<Ok>;
154
+ readonly err: Tags;
155
+ readonly requirements?: Requirements<R>;
156
+ }): CmdDef<Name, Input, Ok, TaggedError<Tags[number]>, R>;
157
+ type SyncReturn<S, C extends Cmd> = readonly [S, readonly C[]] & {
158
+ readonly then?: never;
159
+ };
160
+ type UpdateForm = "reducer" | "transitions";
161
+ declare function detectUpdateForm(update: object): UpdateForm;
162
+ declare function formOf(machine: {
163
+ update: object;
164
+ __form?: UpdateForm;
165
+ }): UpdateForm;
166
+ declare class NoCellError extends Error {
167
+ readonly msgType: string;
168
+ readonly stateName: string;
169
+ /** The Msg types the refusing state has cells for; empty when it has none. */
170
+ readonly acceptedTypes: readonly string[];
171
+ readonly name = "NoCellError";
172
+ readonly _tag: "NoCellError";
173
+ constructor(msgType: string, stateName: string,
174
+ /** The Msg types the refusing state has cells for; empty when it has none. */
175
+ acceptedTypes: readonly string[]);
176
+ }
177
+ /**
178
+ * The Msg types this machine would accept in this state — the same set a
179
+ * `NoCellError` reports, asked before anything is dispatched. Returns the
180
+ * state's own row keys in transitions form and the flat table's keys in
181
+ * reducer form, counting only keys whose cell is a function, and an empty
182
+ * array (never `undefined`, never a throw) for a state with no cells, no row
183
+ * at all, or no state value at all.
184
+ */
185
+ declare function acceptedTypes<S>(machine: {
186
+ update: object;
187
+ __form?: UpdateForm;
188
+ }, state: S): readonly string[];
189
+ declare function applyCell<S, M extends {
190
+ type: string;
191
+ }, C extends Cmd>(machine: {
192
+ update: object;
193
+ __form?: UpdateForm;
194
+ }, state: S, msg: M): readonly [S, readonly C[]];
195
+ declare function applyCellChecked<S, M extends {
196
+ type: string;
197
+ }, C extends Cmd>(machine: {
198
+ update: object;
199
+ __form?: UpdateForm;
200
+ }, state: S, msg: M): readonly [S, readonly C[]];
201
+ declare function msgKeysOf(machine: {
202
+ update: object;
203
+ __form?: UpdateForm;
204
+ }): readonly string[];
205
+ type MachineShape = {
206
+ readonly form: "reducer";
207
+ /** Every `Msg.type` the flat reducer has a cell for. */
208
+ readonly msgs: readonly string[];
209
+ } | {
210
+ readonly form: "transitions";
211
+ /** The union of every row's `Msg.type` keys (see `msgKeysOf`). */
212
+ readonly msgs: readonly string[];
213
+ /** Every `state.type` the table has a row for, in table order. */
214
+ readonly states: readonly string[];
215
+ /** `state.type` → the `Msg.type`s that state has a cell for. */
216
+ readonly accepts: Readonly<Record<string, readonly string[]>>;
217
+ };
218
+ declare function describeMachine(machine: {
219
+ update: object;
220
+ __form?: UpdateForm;
221
+ }): MachineShape;
222
+ declare function acceptsOf(machine: {
223
+ update: object;
224
+ __form?: UpdateForm;
225
+ }, stateType: string): readonly string[];
226
+ type Reducer<S, M extends {
227
+ type: string;
228
+ }, C extends Cmd> = {
229
+ [K in M["type"]]: (state: S, msg: Extract<M, {
230
+ type: K;
231
+ }>) => SyncReturn<S, C>;
232
+ };
233
+ /**
234
+ * The state × message table form of `update`. Every state of `S` needs a row;
235
+ * a cell inside a row is optional, and leaving one out DECLARES that the state
236
+ * does not accept that message — the runtime refuses it with `NoCellError`
237
+ * naming `acceptedTypes`. `ExhaustiveTransitions` requires every cell instead.
238
+ */
239
+ type Transitions<S extends {
240
+ type: string;
241
+ }, M extends {
242
+ type: string;
243
+ }, C extends Cmd> = {
244
+ [P in S["type"]]: Partial<ExhaustiveTransitions<S, M, C>[P]>;
245
+ };
246
+ /**
247
+ * `Transitions<S, M, C>` with every cell REQUIRED — the opt-in floor for a
248
+ * machine that wants the compiler to force a decision on every (state,
249
+ * message) pair. An annotation on your own table, not a third update form:
250
+ * `defineMachine` takes the annotated table unchanged.
251
+ */
252
+ type ExhaustiveTransitions<S extends {
253
+ type: string;
254
+ }, M extends {
255
+ type: string;
256
+ }, C extends Cmd> = {
257
+ [P in S["type"]]: {
258
+ [K in M["type"]]: (state: Extract<S, {
259
+ type: P;
260
+ }>, msg: Extract<M, {
261
+ type: K;
262
+ }>) => SyncReturn<S, C>;
263
+ };
264
+ };
265
+ /**
266
+ * A tagged-union, one-shot effect — JSON-plain, hashable, replayable.
267
+ *
268
+ * `T` is the tag. `E` and `R` are Effect's Error and **Requirements** channels,
269
+ * carried as phantom type parameters (ADR 0014): `E` is the `_tag` union this
270
+ * Cmd can settle with, and `R` is the slice of `Ctx` its interpret handler
271
+ * reads. `R` is a requirement, not a wiring — what SATISFIES it is the `ctx`
272
+ * handed to `run`, built by hand or by a `provide` graph that acquires each
273
+ * dependency once and releases it when the run ends.
274
+ *
275
+ * @see {@link RequiredCtx} — every Cmd's `R`, intersected: what `run` demands.
276
+ * @see `provide` — the host-side graph that builds a `ctx` satisfying `R`.
277
+ */
278
+ type Cmd<T extends string = string, E = unknown, R = unknown> = {
279
+ readonly type: T;
280
+ /** Phantom — the `_tag` union this Cmd can settle with. Never assigned. */
281
+ readonly __e?: E;
282
+ /** Phantom — the `Ctx` slice this Cmd's handler needs. Never assigned. */
283
+ readonly __r?: R;
284
+ };
285
+ declare const Cmd: {
286
+ /**
287
+ * Declare a typed Cmd constructor (ADR 0014). Returns the builder —
288
+ * `fetch({ url })` yields `{ type: "fetch", url }` — carrying the minted Msg
289
+ * builders `fetch.ok(cmd, value)` / `fetch.err(cmd, error)` and the
290
+ * declaration the runtime edge parses against. `Settled<typeof fetch>` is
291
+ * the two-arm Msg union it settles with; `defineMachine({ cmds: [fetch] })`
292
+ * folds that union into the machine's `M`.
293
+ *
294
+ * const fetch = Cmd.define("fetch", {
295
+ * input: z.object({ url: z.string() }),
296
+ * ok: z.object({ status: z.number(), body: z.string() }),
297
+ * err: ["not_found", "timeout"],
298
+ * requirements: Cmd.requirements<{ http: Http }>(),
299
+ * });
300
+ *
301
+ * `err` is the `_tag` list the handler may settle with; the runtime adds
302
+ * `malformed_result` for an `_ok` value the `ok` schema rejects. `requirements`
303
+ * names the `Ctx` slice the handler reads — `run` refuses a ctx without it.
304
+ *
305
+ * A Cmd must not wait; see `DepKeyedSub` for anything that watches.
306
+ */
307
+ readonly define: typeof defineCmd;
308
+ /**
309
+ * Name a Cmd's `R` — the `Ctx` slice its handler reads. A phantom: nothing
310
+ * is built, nothing is checked at runtime; the type is what `run` reads.
311
+ */
312
+ readonly requirements: <R>() => Requirements<R>;
313
+ /**
314
+ * The empty Cmd array. Typed `readonly never[]` so it's assignable to any
315
+ * `readonly C[]` for any `C extends Cmd`. Use in `init` returns and
316
+ * Transitions cells that emit zero effects:
317
+ *
318
+ * init: (loaded) => [loaded ?? initial, Cmd.none],
319
+ * tick: (state) => [state, Cmd.none],
320
+ *
321
+ * Elm's `Cmd.none` analogue. Cultural signal alongside the runtime help:
322
+ * `[state, Cmd.none]` reads as intent ("this transition emits nothing"),
323
+ * `[state, []]` reads as "empty array of what".
324
+ *
325
+ * Frozen at runtime so a downstream consumer can't `.push()` into the
326
+ * shared reference.
327
+ */
328
+ readonly none: readonly never[];
329
+ /**
330
+ * Flat concat of cmd arrays. Use when a cell composes effects from
331
+ * multiple conditional sources:
332
+ *
333
+ * return [next, Cmd.batch(
334
+ * Cmd.whenDefined(state.queueItemId, (id) => ({ type: "complete", id })),
335
+ * Cmd.when(state.windowId !== undefined, { type: "close_window", windowId }),
336
+ * [{ type: "detach_debugger", tabId: state.tabId }],
337
+ * )];
338
+ *
339
+ * `<const C>` keeps inline cmd literals' discriminants narrow (same
340
+ * rationale as `when` / `whenDefined` above).
341
+ */
342
+ readonly batch: <const C extends Cmd>(...arrs: readonly (readonly C[])[]) => readonly C[];
343
+ /**
344
+ * Emit `cmd` wrapped in a single-element array iff `cond` is true.
345
+ * Otherwise return the empty array. Spreads cleanly into the cmds array
346
+ * returned by a Transitions cell.
347
+ *
348
+ * `const C` (TypeScript 5.0+) keeps the inferred `type:` discriminator
349
+ * literal narrow when called with an object literal — so `Cmd.when(b,
350
+ * { type: "x", ... })` infers as `{ type: "x", ... }`, not `{ type:
351
+ * string, ... }`, and stays assignable to a discriminated-union arm
352
+ * without `as const` at the call site.
353
+ */
354
+ readonly when: <const C extends Cmd>(cond: boolean, cmd: C) => readonly C[];
355
+ /**
356
+ * If `value` is defined, call `build(value)` and emit the resulting cmd
357
+ * wrapped in a single-element array. If `value` is `undefined`, return
358
+ * the empty array. `value` is narrowed to `T` inside `build`.
359
+ *
360
+ * `const C` on the return type keeps the callback's object-literal
361
+ * `type:` field narrow (see `when` above for the full rationale).
362
+ */
363
+ readonly whenDefined: <T, const C extends Cmd>(value: T | undefined, build: (value: T) => C) => readonly C[];
364
+ };
365
+ type SubId = string & {
366
+ readonly __brand: "SubId";
367
+ };
368
+ /**
369
+ * Construct a `SubId` from a string. Use this everywhere a Sub literal is
370
+ * built — including ids derived from runtime data (`subId(\`ws:${auditId}\`)`).
371
+ * The brand is structural, not nominal, so dynamic ids are permitted; the
372
+ * constructor's job is to make the identity decision explicit at every call
373
+ * site so the type system can catch accidental raw-string drift.
374
+ *
375
+ * Strengthens invariant 7 (identity is explicit).
376
+ */
377
+ declare function subId(s: string): SubId;
378
+ type Sub<T extends string = string> = {
379
+ readonly id: SubId;
380
+ readonly type: T;
381
+ };
382
+ type Dispose = () => void | Promise<void>;
383
+ declare function structuralHash(deps: unknown): string;
384
+ interface DepKeyedSub<S, M, Ctx = unknown> {
385
+ /**
386
+ * The slice of state this Sub depends on. `null` OR `undefined` ⇒ the Sub is
387
+ * inactive in this state (the substrate disposes it if it was running) — see
388
+ * `depsInactive`, so `(s) => s.optionalRunId` gates correctly. Otherwise the
389
+ * Sub is active, keyed on `structuralHash(deps)`.
390
+ *
391
+ * Pure (invariant 2). Plain JSON-compatible data only (invariant 1) — the
392
+ * structural hash walks it deterministically and THROWS on a `Date`, `Map`,
393
+ * `Set`, `Error` or class instance rather than collapsing them all onto one
394
+ * id. Project such a value first (`startedAt.toISOString()`).
395
+ */
396
+ readonly deps: (state: S) => unknown;
397
+ /**
398
+ * Open the resource for the current `state` (whose `deps` the kernel just
399
+ * found non-null). Receives `dispatch` to fire follow-up Msgs (a timer's
400
+ * fire, an inbound frame) and the machine's `ctx` (the host's transport
401
+ * factory, storage handles). Returns the `Dispose` the substrate runs on
402
+ * teardown / re-arm. Same role as a `subscribe[type]` handler's returned
403
+ * cleanup.
404
+ *
405
+ * `source` takes `state` (not the deps slice) so the slice type `D` never
406
+ * escapes the entry — each battery's `.depKeyed` closes over its own typed
407
+ * deps internally (cast-free existential: the entry that produced the deps
408
+ * is the entry that consumes them).
409
+ */
410
+ readonly source: (state: S, dispatch: (msg: M) => void, ctx: Ctx) => Dispose;
411
+ }
412
+ interface Identity<S, M> {
413
+ /** The identity THIS instance owns. Pure (invariant 2); plain value. */
414
+ readonly ofState: (state: S) => unknown;
415
+ /**
416
+ * The identity a message is addressed to, or `undefined` when the message
417
+ * carries no identity (lifecycle / pre-identity messages — never dropped).
418
+ * Pure (invariant 2); plain value when defined.
419
+ */
420
+ readonly ofMsg: (msg: M) => unknown;
421
+ }
422
+ interface Port<T> {
423
+ readonly __brand: "port";
424
+ readonly name: string;
425
+ readonly __t?: T;
426
+ }
427
+ /**
428
+ * Augmentation injected onto `ctx` inside Cmd handlers. Handlers receive
429
+ * `ctx & PortEmitter` so they can call `ctx.emit(port, value)` synchronously.
430
+ * Subscribers registered via `runtime.subscribePort(port, listener)` receive
431
+ * the value immediately.
432
+ *
433
+ * Emitting to a port with no subscribers is a no-op (does not throw).
434
+ */
435
+ interface PortEmitter {
436
+ emit<T>(port: Port<T>, value: T): void;
437
+ }
438
+ type NoCtx = Readonly<Record<never, never>>;
439
+ type Interpret<M extends {
440
+ type: string;
441
+ }, C extends Cmd, Ctx> = {
442
+ [K in C["type"]]: (cmd: Extract<C, {
443
+ type: K;
444
+ }>, ctx: Ctx & RequirementsOf<Extract<C, {
445
+ type: K;
446
+ }>> & PortEmitter, dispatch?: (msg: M) => void) => Promise<M | void>;
447
+ };
448
+ type InterpretDetached<C extends Cmd, Allowed extends {
449
+ type: string;
450
+ }, Ctx> = (cmd: C, ctx: Ctx & PortEmitter, dispatch: (msg: Allowed) => void) => Promise<void>;
451
+ type Subscribe<M extends {
452
+ type: string;
453
+ }, U extends Sub, Ctx> = {
454
+ [K in U["type"]]: (sub: Extract<U, {
455
+ type: K;
456
+ }>, ctx: Ctx, dispatch: (msg: M) => void) => Dispose;
457
+ };
458
+ type Machine<S, M extends {
459
+ type: string;
460
+ }, C extends Cmd, U extends Sub, Ctx> = {
461
+ /**
462
+ * Boot the runtime. Called once by `run(...)` with whatever `Store.load()`
463
+ * returned: `null` on fresh boot, the persisted state on rehydrate.
464
+ *
465
+ * **Contract:** when `loaded !== null`, init MUST return `[loaded, []]` —
466
+ * no Cmds. Init's rehydrate branch is the migration / parse boundary, not
467
+ * the boot-effect hook. See Invariant 2 in `.patterns/tea/tea-invariants.md`.
468
+ *
469
+ * Boot effects routes:
470
+ * - Stateless infrastructure → host module top, outside TEA.
471
+ * - State-conditional resume → a `boot` Msg the host dispatches once
472
+ * after `run(...)` returns.
473
+ *
474
+ * Violations are caught at runtime by `replay` (which throws with a
475
+ * pointer to the alternatives).
476
+ */
477
+ init: (loaded: S | null, ctx: Ctx) => readonly [S, readonly C[]];
478
+ /**
479
+ * The typed Cmd constructors this machine emits (`Cmd.define`). Declared
480
+ * through `defineMachine({ cmds })`, which derives `C` and the settled half
481
+ * of `M` from them; the runtime reads the list to parse each handler's
482
+ * `_ok` value against its `ok` schema and stamp `at` at the interpret edge.
483
+ * A machine of hand-written Cmds omits it and runs exactly as before.
484
+ */
485
+ readonly cmds?: readonly AnyCmdDef[];
486
+ update: Reducer<S, M, C> | ([S] extends [{
487
+ type: string;
488
+ }] ? Transitions<S, M, C> : never);
489
+ /**
490
+ * Dep-keyed Subs. Each declares the state slice it depends on; the substrate
491
+ * derives the id (`structuralHash(deps)`) and the gate (`deps` non-null) and
492
+ * folds them into the SAME reconcile loop `subscriptions` feeds. The author
493
+ * never writes `subId(...)` and never lists Subs in a central
494
+ * `subscriptions(state)` aggregate — a per-Sub gate travels with the Sub, so
495
+ * a new phase can't silently forget to arm it.
496
+ *
497
+ * The deps slice type is erased to `unknown` per entry — each Sub's slice
498
+ * differs, but the slice type never crosses this field (the kernel only needs
499
+ * to hash it and pass `state` back to that same entry's `source`).
500
+ *
501
+ * Optional and independent of `subscriptions` / `subscribe`: a machine that
502
+ * omits `subs` reconciles exactly as before.
503
+ *
504
+ * Strengthens invariant 4 (lifecycle owned by the substrate) and invariant 7
505
+ * (identity derived, not hand-authored).
506
+ */
507
+ subs?: ReadonlyArray<DepKeyedSub<S, M, Ctx>>;
508
+ /**
509
+ * Instance-identity filter. Declares THIS instance's identity once; the
510
+ * substrate drops any message addressed to a DIFFERENT identity before it
511
+ * reaches `update`. Replaces the per-cell `if (msg.runId !== state.runId)`
512
+ * guard entirely — the reducer never sees a foreign-instance message, so no
513
+ * cell needs to check.
514
+ *
515
+ * Opt-in: a machine that omits `identity` skips the filter (every message
516
+ * reaches `update`, exactly as before). A message whose `ofMsg` returns
517
+ * `undefined` is identity-agnostic and always reaches `update` (lifecycle /
518
+ * pre-identity messages).
519
+ *
520
+ * Strengthens invariant 7 (identity is explicit — declared once, enforced by
521
+ * the substrate) and invariant 6 (mis-addressed messages dropped at one
522
+ * observable point, not per cell).
523
+ */
524
+ identity?: Identity<S, M>;
525
+ /**
526
+ * Manual Sub aggregate — the documented escape hatch, KEPT alongside `subs`.
527
+ * The machine that needs cross-Sub logic the per-Sub `deps` fold can't
528
+ * express lists Subs here; the substrate reconciles them via `subscribe`.
529
+ * Both paths feed ONE reconcile pass.
530
+ */
531
+ subscriptions?: (state: S) => readonly U[];
532
+ subscribe?: Subscribe<M, U, Ctx>;
533
+ /**
534
+ * The update form ("reducer" | "transitions"), stamped non-enumerably by
535
+ * `defineMachine` at construction (see `UpdateForm` / `formOf`). Optional in
536
+ * the type so the structural `Machine` annotation form keeps accepting plain
537
+ * object literals; readers go through `formOf`, which falls back to
538
+ * `detectUpdateForm` when the tag is absent. Never written by hand.
539
+ */
540
+ readonly __form?: UpdateForm;
541
+ } & ([C] extends [Cmd<never>] ? {
542
+ interpret?: Interpret<M, C, Ctx>;
543
+ } : {
544
+ interpret: Interpret<M, C, Ctx>;
545
+ }) & ([U] extends [Sub<never>] ? unknown : {
546
+ subscriptions: (state: S) => readonly U[];
547
+ subscribe: Subscribe<M, U, Ctx>;
548
+ });
549
+ declare function foldUpdates<S, M extends {
550
+ type: string;
551
+ }, C extends Cmd>(machine: {
552
+ update: object;
553
+ __form?: UpdateForm;
554
+ }, initialState: S, msgs: readonly M[]): {
555
+ state: S;
556
+ cmds: C[];
557
+ };
558
+ declare function foldMsgs<S, M extends {
559
+ type: string;
560
+ }, C extends Cmd, U extends Sub, Ctx>(machine: Machine<S, M, C, U, Ctx>, base: S, msgs: readonly M[]): S;
561
+
562
+ export { type AnyCmdDef as A, applyCell as B, Cmd as C, type Dispose as D, type ErrOf as E, applyCellChecked as F, describeMachine as G, detectUpdateForm as H, type Interpret as I, foldMsgs as J, foldUpdates as K, formOf as L, type Machine as M, NoCellError as N, type OkOf as O, type Port as P, msgKeysOf as Q, type RequiredCtx as R, type Sub as S, type Transitions as T, type UpdateForm as U, structuralHash as V, subId as W, type CmdOf as a, type CmdDef as b, type SubId as c, type Reducer as d, type Settled as e, type RequirementsOf as f, type PortEmitter as g, type InterpretDetached as h, type CmdValue as i, type Tagged as j, type NoCtx as k, type MalformedResult as l, type Requirements as m, type TaggedError as n, type DepKeyedSub as o, type CmdInput as p, type ErrorsOf as q, type ExhaustiveTransitions as r, type Identity as s, type MachineShape as t, type SettledErr as u, type SettledOk as v, type Subscribe as w, type SyncReturn as x, acceptedTypes as y, acceptsOf as z };
@@ -15,7 +15,7 @@ interface MsgLogProps {
15
15
  declare function MsgLog({ history, className }: MsgLogProps): react_jsx_runtime.JSX.Element;
16
16
 
17
17
  /**
18
- * A single differing cell between two states.
18
+ * A single differing leaf value between two states.
19
19
  *
20
20
  * - `kind: "added"` — the path exists in `actual` but not `expected`
21
21
  * (`expected` is `undefined`).
@@ -35,7 +35,7 @@ interface StateChange {
35
35
  actual: unknown;
36
36
  }
37
37
  /**
38
- * Deep-walk two states and return EVERY differing cell, in deterministic
38
+ * Deep-walk two states and return EVERY differing leaf value, in deterministic
39
39
  * pre-order (the node before its children; children in array-index order, then
40
40
  * sorted-union key order for objects). The empty array means the two states are
41
41
  * deeply equal.