@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
@@ -1,149 +0,0 @@
1
- import { C as Cmd, S as Sub, M as Machine } from '../core-Bjc0bS8j.js';
2
-
3
- /**
4
- * @demlik/tea/with-telemetry — the pattern-setting wrapper of the wrapper tier.
5
- *
6
- * `withTelemetry(base, config)` is a **pure function over machine data**: it
7
- * takes any `Machine<S, M, C, U, Ctx>` and returns a NEW `Machine` over the
8
- * composed Model `{ base, $telemetry }`. You `run()` / `replay()` the result
9
- * exactly like any other machine — there is no new runtime, no privileged
10
- * interception path.
11
- *
12
- * This is the SAFEST wrapper and the one every future wrapper (`withDeadline`,
13
- * `withResilience`) copies: it is **OBSERVE-ONLY**. It observes every base Msg
14
- * + transition, increments a monotonic counter, and emits a fire-and-forget
15
- * telemetry Cmd whose interpret handler hands the event to a sink Port. It must
16
- * NOT transform base Cmds or gate base Msgs — base behavior is byte-identical
17
- * with or without it. The moment a telemetry wrapper alters the Msg/Cmd stream
18
- * instead of observing it, it has become saga middleware (the betrayal the
19
- * research warned of).
20
- *
21
- * ## The 5 rules it satisfies (from the wrapper-tier contract)
22
- *
23
- * 1. **Named, serializable slice.** Wrapper state lives at `model.$telemetry`,
24
- * a plain `{ seq: number }` — JSON-serializable, never a closure.
25
- * 2. **Retag-and-re-emit, never swallow.** The merged `update` runs the base
26
- * reducer, passes its Cmds through UNCHANGED, and APPENDS its own
27
- * `$telemetry:emit` Cmd. No base Cmd ever vanishes; nothing is gated.
28
- * 3. **Every decision is a Msg/Cmd.** Each telemetry emission is a
29
- * `$telemetry:emit` Cmd through the merged `update`, so "why did this fire"
30
- * is answerable from reducer + log alone, and `runtime.observe` sees it.
31
- * 4. **Subs merge by id.** Telemetry has no timers — merged subs/subscribe are
32
- * the base's, verbatim.
33
- * 5. **Clock out of update.** The default event carries no wall-clock read.
34
- * The optional `at` is stamped at the interpret boundary (the `clock`
35
- * port), never inside the merged `update`.
36
- *
37
- * ## Where the clock lives
38
- *
39
- * Inside the merged `update`: nowhere. The reducer is pure — it reads `seq` from
40
- * the slice and projects the event from `(msg, prev, next)`. The ONLY clock read
41
- * is at the interpret boundary: the `$telemetry:emit` handler stamps `event.at`
42
- * from the injected `clock` port (if supplied and the projector left `at`
43
- * unset), exactly as `resilient-call` reads `Date.now()` only inside `handlers`.
44
- *
45
- * ## Typical wiring
46
- *
47
- * const observed = withTelemetry(baseMachine, {
48
- * event: (msg, _prev, next) => ({ seq: next.$telemetry.seq, msgType: msg.type }),
49
- * });
50
- * const runtime = run(observed, {
51
- * ctx: { ...baseCtx, telemetrySink: (e) => posthog.capture(e), clock: Date.now },
52
- * });
53
- */
54
-
55
- /**
56
- * The datum handed to the sink. The default projector emits `{ seq, msgType }`;
57
- * a custom `event` projector may return any extra fields. `at` is OPTIONAL and
58
- * plain data — it is stamped at the interpret boundary by the `clock` port, not
59
- * inside the (pure, clock-free) merged `update`. Every field is JSON-round-trip
60
- * serializable so a recorded telemetry stream stays durable.
61
- */
62
- interface TelemetryEvent {
63
- /** Monotonic event counter — equals `$telemetry.seq` after the transition. */
64
- readonly seq: number;
65
- /** The `Msg.type` discriminant that drove this transition. */
66
- readonly msgType: string;
67
- /**
68
- * Wall-clock instant the event was emitted, ms since epoch. Absent until the
69
- * interpret boundary stamps it (the `clock` port). Optional because the
70
- * merged `update` is clock-free — a verb must never read `Date.now()`.
71
- */
72
- readonly at?: number;
73
- }
74
- /**
75
- * The wrapper's Model slice. A monotonic event counter — minimal but real, so
76
- * the named-slice mechanism is exercised for the richer-slice wrappers that
77
- * follow. `seq` equals the number of base Msgs folded so far: after replaying
78
- * `N` msgs, `$telemetry.seq === N`. Plain data → serializes into a `Store<S>`.
79
- */
80
- interface TelemetrySlice {
81
- readonly seq: number;
82
- }
83
- /**
84
- * The composed Model. The base machine's state is nested under `base`; the
85
- * wrapper's state lives in the NAMED `$telemetry` slice — never hidden in a
86
- * closure. Both fields are plain data, so the whole composed Model round-trips
87
- * through `JSON.parse(JSON.stringify(...))` iff the base state does.
88
- */
89
- interface TelemetryModel<S> {
90
- readonly base: S;
91
- readonly $telemetry: TelemetrySlice;
92
- }
93
- /**
94
- * The fire-and-forget Cmd the merged `update` appends after every base
95
- * transition. It carries the projected `event` as plain data (invariant 3 —
96
- * no closure). The interpret handler hands `event` to the sink and dispatches
97
- * NOTHING back, so there is no feedback loop.
98
- */
99
- type TelemetryEmitCmd = Cmd<"$telemetry:emit"> & {
100
- readonly event: TelemetryEvent;
101
- };
102
- /**
103
- * The side-effecting ports the wrapper adds to `Ctx`. The sink (PostHog / Sentry
104
- * bridge) lives at the interpret boundary, never in a verb. `clock` is the
105
- * optional wall-clock source used to stamp `event.at` at that same boundary —
106
- * pass `Date.now` in production, a fixed `() => 1000` in tests; omit it to leave
107
- * `at` unset.
108
- */
109
- interface TelemetryPorts {
110
- /** The side-effecting sink. Fire-and-forget — its result is never awaited into a Msg. */
111
- readonly telemetrySink: (event: TelemetryEvent) => void | Promise<void>;
112
- /** Optional clock for stamping `event.at` at the interpret boundary. */
113
- readonly clock?: () => number;
114
- }
115
- /**
116
- * The telemetry knob. `event` is an OPTIONAL projector mapping
117
- * `(msg, prev, next)` to a `TelemetryEvent`; omit it and the default emits
118
- * `{ seq, msgType }` where `seq` is the post-transition counter. The projector
119
- * runs INSIDE the pure merged `update`, so it must not read the clock — stamp
120
- * `at` at the sink boundary via the `clock` port instead.
121
- */
122
- interface TelemetryConfig<S, M extends {
123
- type: string;
124
- }> {
125
- readonly event?: (msg: M, prev: TelemetryModel<S>, next: TelemetryModel<S>) => TelemetryEvent;
126
- }
127
- /**
128
- * Wrap `base` with observe-only telemetry. Returns a NEW `Machine` over the
129
- * composed Model `{ base, $telemetry }`, with the base's Msgs/Cmds/Subs/Ctx
130
- * extended by the wrapper's own.
131
- *
132
- * The composed machine:
133
- * - `init` rehydrates the base (honoring the `[loaded, []]` contract) and
134
- * seeds `$telemetry: { seq: 0 }`. Base init Cmds pass through unchanged.
135
- * - `update` (Reducer form, keyed by every base `Msg.type`) runs the base
136
- * reducer, increments `seq`, and appends a `$telemetry:emit` Cmd carrying
137
- * the projected event. Base Cmds pass through UNCHANGED — the observe-only
138
- * property.
139
- * - `subscriptions` / `subscribe` are the base's, verbatim (no timers).
140
- * - `interpret` is `{ ...base.interpret, "$telemetry:emit": sink-handler }`.
141
- *
142
- * @param base any `Machine<S, M, C, U, Ctx>`.
143
- * @param config the telemetry knob (optional `event` projector).
144
- */
145
- declare function withTelemetry<S, M extends {
146
- type: string;
147
- }, C extends Cmd, U extends Sub, Ctx>(base: Machine<S, M, C, U, Ctx>, config?: TelemetryConfig<S, M>): Machine<TelemetryModel<S>, M, C | TelemetryEmitCmd, U, Ctx & TelemetryPorts>;
148
-
149
- export { type TelemetryConfig, type TelemetryEmitCmd, type TelemetryEvent, type TelemetryModel, type TelemetryPorts, type TelemetrySlice, withTelemetry };
@@ -1,70 +0,0 @@
1
- import '../chunk-5EHLEUTL.js';
2
- import { msgKeysOf, applyCell } from '../chunk-B5VXOFMZ.js';
3
-
4
- // src/with-telemetry/index.ts
5
- function withTelemetry(base, config = {}) {
6
- const project = config.event;
7
- const msgKeys = msgKeysOf(base);
8
- const update = {};
9
- for (const key of msgKeys) {
10
- update[key] = (state, msg) => {
11
- const [nextBase, baseCmds] = applyCell(base, state.base, msg);
12
- const $telemetry = { seq: state.$telemetry.seq + 1 };
13
- const next = { base: nextBase, $telemetry };
14
- const event = project ? project(msg, state, next) : { seq: $telemetry.seq, msgType: msg.type };
15
- const emit = { type: "$telemetry:emit", event };
16
- return [next, [...baseCmds, emit]];
17
- };
18
- }
19
- const baseInterpret = base.interpret ?? {};
20
- if (Object.hasOwn(baseInterpret, "$telemetry:emit")) {
21
- throw new Error(
22
- 'withTelemetry: the base machine declares a reserved "$telemetry:emit" interpret handler \u2014 the wrapper owns the "$telemetry:" Cmd namespace. Rename the base handler.'
23
- );
24
- }
25
- const interpret = {
26
- ...baseInterpret,
27
- // OBSERVE-ONLY at the boundary: the sink is fire-and-forget. The runtime
28
- // `await`s every interpret handler in its dispatch loop, so awaiting the
29
- // sink here would let a SLOW sink backpressure the wrapped machine (its
30
- // next dispatch waits) and a FAILING sink crash dispatch (the throw would
31
- // propagate out of the transition). Both violate the contract: telemetry
32
- // must never affect base behavior OR latency. So we DO NOT await — we hand
33
- // the event to the sink, normalize its result to a Promise, swallow any
34
- // rejection/throw, and return immediately. The handler resolves in the same
35
- // microtask the dispatch loop reaches it; the machine never waits on the
36
- // sink, and a rejected sink can never become an unhandled rejection.
37
- "$telemetry:emit": (cmd, ctx) => {
38
- const event = cmd.event.at === void 0 && ctx.clock !== void 0 ? { ...cmd.event, at: ctx.clock() } : cmd.event;
39
- try {
40
- Promise.resolve(ctx.telemetrySink(event)).catch(() => {
41
- });
42
- } catch {
43
- }
44
- }
45
- };
46
- const baseSubscriptions = base.subscriptions;
47
- const baseSubscribe = base.subscribe;
48
- return {
49
- init: (loaded, ctx) => {
50
- if (loaded !== null) {
51
- return [loaded, []];
52
- }
53
- const [base0, cmds] = base.init(null, ctx);
54
- const model = { base: base0, $telemetry: { seq: 0 } };
55
- return [model, cmds];
56
- },
57
- update,
58
- // Subs merge to the base's, verbatim — telemetry owns no timers. The base
59
- // subscribes against its own nested slice.
60
- ...baseSubscriptions ? {
61
- subscriptions: (state) => baseSubscriptions(state.base)
62
- } : {},
63
- ...baseSubscribe ? { subscribe: baseSubscribe } : {},
64
- interpret
65
- };
66
- }
67
-
68
- export { withTelemetry };
69
- //# sourceMappingURL=index.js.map
70
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/with-telemetry/index.ts"],"names":[],"mappings":";;;;AAiKO,SAAS,aAAA,CAOd,IAAA,EACA,MAAA,GAAgC,EAAC,EAOjC;AACA,EAAA,MAAM,UAAU,MAAA,CAAO,KAAA;AAMvB,EAAA,MAAM,OAAA,GAAU,UAAU,IAAI,CAAA;AAE9B,EAAA,MAAM,SAAS,EAAC;AAOhB,EAAA,KAAA,MAAW,OAAO,OAAA,EAAS;AACzB,IAAA,MAAA,CAAO,GAAG,CAAA,GAAI,CAAC,KAAA,EAAO,GAAA,KAAQ;AAE5B,MAAA,MAAM,CAAC,UAAU,QAAQ,CAAA,GAAI,UAAmB,IAAA,EAAM,KAAA,CAAM,MAAM,GAAG,CAAA;AAErE,MAAA,MAAM,aAA6B,EAAE,GAAA,EAAK,KAAA,CAAM,UAAA,CAAW,MAAM,CAAA,EAAE;AACnE,MAAA,MAAM,IAAA,GAA0B,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAW;AAE7D,MAAA,MAAM,KAAA,GAAwB,OAAA,GAC1B,OAAA,CAAQ,GAAA,EAAK,KAAA,EAAO,IAAI,CAAA,GACxB,EAAE,GAAA,EAAK,UAAA,CAAW,GAAA,EAAK,OAAA,EAAS,IAAI,IAAA,EAAK;AAE7C,MAAA,MAAM,IAAA,GAAyB,EAAE,IAAA,EAAM,iBAAA,EAAmB,KAAA,EAAM;AAChE,MAAA,OAAO,CAAC,IAAA,EAAM,CAAC,GAAG,QAAA,EAAU,IAAI,CAAC,CAAA;AAAA,IACnC,CAAA;AAAA,EACF;AAQA,EAAA,MAAM,aAAA,GACH,IAAA,CAA8C,SAAA,IAC9C,EAAC;AAMJ,EAAA,IAAI,MAAA,CAAO,MAAA,CAAO,aAAA,EAAyB,iBAAiB,CAAA,EAAG;AAC7D,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KAGF;AAAA,EACF;AACA,EAAA,MAAM,SAAA,GAAY;AAAA,IAChB,GAAI,aAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWJ,iBAAA,EAAmB,CACjB,GAAA,EACA,GAAA,KACS;AACT,MAAA,MAAM,QACJ,GAAA,CAAI,KAAA,CAAM,EAAA,KAAO,MAAA,IAAa,IAAI,KAAA,KAAU,MAAA,GACxC,EAAE,GAAG,IAAI,KAAA,EAAO,EAAA,EAAI,IAAI,KAAA,EAAM,KAC9B,GAAA,CAAI,KAAA;AAIV,MAAA,IAAI;AACF,QAAA,OAAA,CAAQ,QAAQ,GAAA,CAAI,aAAA,CAAc,KAAK,CAAC,CAAA,CAAE,MAAM,MAAM;AAAA,QAAC,CAAC,CAAA;AAAA,MAC1D,CAAA,CAAA,MAAQ;AAAA,MAIR;AAAA,IACF;AAAA,GACF;AAGA,EAAA,MAAM,oBAAoB,IAAA,CAAK,aAAA;AAC/B,EAAA,MAAM,gBAAiB,IAAA,CAAiC,SAAA;AAExD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,CAAC,MAAA,EAAQ,GAAA,KAAQ;AAKrB,MAAA,IAAI,WAAW,IAAA,EAAM;AACnB,QAAA,OAAO,CAAC,MAAA,EAAQ,EAAE,CAAA;AAAA,MACpB;AACA,MAAA,MAAM,CAAC,KAAA,EAAO,IAAI,IAAI,IAAA,CAAK,IAAA,CAAK,MAAM,GAAG,CAAA;AACzC,MAAA,MAAM,KAAA,GAA2B,EAAE,IAAA,EAAM,KAAA,EAAO,YAAY,EAAE,GAAA,EAAK,GAAE,EAAE;AAGvE,MAAA,OAAO,CAAC,OAAO,IAAI,CAAA;AAAA,IACrB,CAAA;AAAA,IACA,MAAA;AAAA;AAAA;AAAA,IAOA,GAAI,iBAAA,GACA;AAAA,MACE,aAAA,EAAe,CAAC,KAAA,KACd,iBAAA,CAAkB,MAAM,IAAI;AAAA,QAEhC,EAAC;AAAA,IACL,GAAI,aAAA,GAAgB,EAAE,SAAA,EAAW,aAAA,KAAkB,EAAC;AAAA,IACpD;AAAA,GACF;AAOF","file":"index.js","sourcesContent":["/**\n * @demlik/tea/with-telemetry — the pattern-setting wrapper of the wrapper tier.\n *\n * `withTelemetry(base, config)` is a **pure function over machine data**: it\n * takes any `Machine<S, M, C, U, Ctx>` and returns a NEW `Machine` over the\n * composed Model `{ base, $telemetry }`. You `run()` / `replay()` the result\n * exactly like any other machine — there is no new runtime, no privileged\n * interception path.\n *\n * This is the SAFEST wrapper and the one every future wrapper (`withDeadline`,\n * `withResilience`) copies: it is **OBSERVE-ONLY**. It observes every base Msg\n * + transition, increments a monotonic counter, and emits a fire-and-forget\n * telemetry Cmd whose interpret handler hands the event to a sink Port. It must\n * NOT transform base Cmds or gate base Msgs — base behavior is byte-identical\n * with or without it. The moment a telemetry wrapper alters the Msg/Cmd stream\n * instead of observing it, it has become saga middleware (the betrayal the\n * research warned of).\n *\n * ## The 5 rules it satisfies (from the wrapper-tier contract)\n *\n * 1. **Named, serializable slice.** Wrapper state lives at `model.$telemetry`,\n * a plain `{ seq: number }` — JSON-serializable, never a closure.\n * 2. **Retag-and-re-emit, never swallow.** The merged `update` runs the base\n * reducer, passes its Cmds through UNCHANGED, and APPENDS its own\n * `$telemetry:emit` Cmd. No base Cmd ever vanishes; nothing is gated.\n * 3. **Every decision is a Msg/Cmd.** Each telemetry emission is a\n * `$telemetry:emit` Cmd through the merged `update`, so \"why did this fire\"\n * is answerable from reducer + log alone, and `runtime.observe` sees it.\n * 4. **Subs merge by id.** Telemetry has no timers — merged subs/subscribe are\n * the base's, verbatim.\n * 5. **Clock out of update.** The default event carries no wall-clock read.\n * The optional `at` is stamped at the interpret boundary (the `clock`\n * port), never inside the merged `update`.\n *\n * ## Where the clock lives\n *\n * Inside the merged `update`: nowhere. The reducer is pure — it reads `seq` from\n * the slice and projects the event from `(msg, prev, next)`. The ONLY clock read\n * is at the interpret boundary: the `$telemetry:emit` handler stamps `event.at`\n * from the injected `clock` port (if supplied and the projector left `at`\n * unset), exactly as `resilient-call` reads `Date.now()` only inside `handlers`.\n *\n * ## Typical wiring\n *\n * const observed = withTelemetry(baseMachine, {\n * event: (msg, _prev, next) => ({ seq: next.$telemetry.seq, msgType: msg.type }),\n * });\n * const runtime = run(observed, {\n * ctx: { ...baseCtx, telemetrySink: (e) => posthog.capture(e), clock: Date.now },\n * });\n */\n\nimport type { Cmd, Interpret, Machine, Reducer, Sub } from \"../index\";\nimport { applyCell, msgKeysOf } from \"../index\";\n\n// ===========================================================================\n// The event + the slice + the ports — the telemetry vocabulary.\n// ===========================================================================\n\n/**\n * The datum handed to the sink. The default projector emits `{ seq, msgType }`;\n * a custom `event` projector may return any extra fields. `at` is OPTIONAL and\n * plain data — it is stamped at the interpret boundary by the `clock` port, not\n * inside the (pure, clock-free) merged `update`. Every field is JSON-round-trip\n * serializable so a recorded telemetry stream stays durable.\n */\nexport interface TelemetryEvent {\n /** Monotonic event counter — equals `$telemetry.seq` after the transition. */\n readonly seq: number;\n /** The `Msg.type` discriminant that drove this transition. */\n readonly msgType: string;\n /**\n * Wall-clock instant the event was emitted, ms since epoch. Absent until the\n * interpret boundary stamps it (the `clock` port). Optional because the\n * merged `update` is clock-free — a verb must never read `Date.now()`.\n */\n readonly at?: number;\n}\n\n/**\n * The wrapper's Model slice. A monotonic event counter — minimal but real, so\n * the named-slice mechanism is exercised for the richer-slice wrappers that\n * follow. `seq` equals the number of base Msgs folded so far: after replaying\n * `N` msgs, `$telemetry.seq === N`. Plain data → serializes into a `Store<S>`.\n */\nexport interface TelemetrySlice {\n readonly seq: number;\n}\n\n/**\n * The composed Model. The base machine's state is nested under `base`; the\n * wrapper's state lives in the NAMED `$telemetry` slice — never hidden in a\n * closure. Both fields are plain data, so the whole composed Model round-trips\n * through `JSON.parse(JSON.stringify(...))` iff the base state does.\n */\nexport interface TelemetryModel<S> {\n readonly base: S;\n readonly $telemetry: TelemetrySlice;\n}\n\n/**\n * The fire-and-forget Cmd the merged `update` appends after every base\n * transition. It carries the projected `event` as plain data (invariant 3 —\n * no closure). The interpret handler hands `event` to the sink and dispatches\n * NOTHING back, so there is no feedback loop.\n */\nexport type TelemetryEmitCmd = Cmd<\"$telemetry:emit\"> & {\n readonly event: TelemetryEvent;\n};\n\n/**\n * The side-effecting ports the wrapper adds to `Ctx`. The sink (PostHog / Sentry\n * bridge) lives at the interpret boundary, never in a verb. `clock` is the\n * optional wall-clock source used to stamp `event.at` at that same boundary —\n * pass `Date.now` in production, a fixed `() => 1000` in tests; omit it to leave\n * `at` unset.\n */\nexport interface TelemetryPorts {\n /** The side-effecting sink. Fire-and-forget — its result is never awaited into a Msg. */\n readonly telemetrySink: (event: TelemetryEvent) => void | Promise<void>;\n /** Optional clock for stamping `event.at` at the interpret boundary. */\n readonly clock?: () => number;\n}\n\n/**\n * The telemetry knob. `event` is an OPTIONAL projector mapping\n * `(msg, prev, next)` to a `TelemetryEvent`; omit it and the default emits\n * `{ seq, msgType }` where `seq` is the post-transition counter. The projector\n * runs INSIDE the pure merged `update`, so it must not read the clock — stamp\n * `at` at the sink boundary via the `clock` port instead.\n */\nexport interface TelemetryConfig<S, M extends { type: string }> {\n readonly event?: (\n msg: M,\n prev: TelemetryModel<S>,\n next: TelemetryModel<S>,\n ) => TelemetryEvent;\n}\n\n// ===========================================================================\n// withTelemetry — the wrapper.\n// ===========================================================================\n\n/**\n * Wrap `base` with observe-only telemetry. Returns a NEW `Machine` over the\n * composed Model `{ base, $telemetry }`, with the base's Msgs/Cmds/Subs/Ctx\n * extended by the wrapper's own.\n *\n * The composed machine:\n * - `init` rehydrates the base (honoring the `[loaded, []]` contract) and\n * seeds `$telemetry: { seq: 0 }`. Base init Cmds pass through unchanged.\n * - `update` (Reducer form, keyed by every base `Msg.type`) runs the base\n * reducer, increments `seq`, and appends a `$telemetry:emit` Cmd carrying\n * the projected event. Base Cmds pass through UNCHANGED — the observe-only\n * property.\n * - `subscriptions` / `subscribe` are the base's, verbatim (no timers).\n * - `interpret` is `{ ...base.interpret, \"$telemetry:emit\": sink-handler }`.\n *\n * @param base any `Machine<S, M, C, U, Ctx>`.\n * @param config the telemetry knob (optional `event` projector).\n */\nexport function withTelemetry<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n base: Machine<S, M, C, U, Ctx>,\n config: TelemetryConfig<S, M> = {},\n): Machine<\n TelemetryModel<S>,\n M,\n C | TelemetryEmitCmd,\n U,\n Ctx & TelemetryPorts\n> {\n const project = config.event;\n\n // The merged update is a flat Reducer over the composed Model. The composed\n // Model is NOT discriminated on `.type`, so the Transitions form is never an\n // option here — every base Msg variant gets exactly one cell, enumerated via\n // `msgKeysOf(base)` (keyed on the authoritative `__form` tag; #275).\n const msgKeys = msgKeysOf(base);\n\n const update = {} as Record<\n string,\n (\n state: TelemetryModel<S>,\n msg: M,\n ) => readonly [TelemetryModel<S>, readonly (C | TelemetryEmitCmd)[]]\n >;\n for (const key of msgKeys) {\n update[key] = (state, msg) => {\n // 1) Run the base reducer — its result passes through UNCHANGED.\n const [nextBase, baseCmds] = applyCell<S, M, C>(base, state.base, msg);\n // 2) Advance the wrapper slice (monotonic counter). New object — no mutation.\n const $telemetry: TelemetrySlice = { seq: state.$telemetry.seq + 1 };\n const next: TelemetryModel<S> = { base: nextBase, $telemetry };\n // 3) Project the event (pure — no clock). Default: { seq, msgType }.\n const event: TelemetryEvent = project\n ? project(msg, state, next)\n : { seq: $telemetry.seq, msgType: msg.type };\n // 4) Append the fire-and-forget emit Cmd. Base Cmds come FIRST, unchanged.\n const emit: TelemetryEmitCmd = { type: \"$telemetry:emit\", event };\n return [next, [...baseCmds, emit]];\n };\n }\n\n // The base's interpret, extended with the one telemetry handler. The sink is\n // the ONLY side effect, and it lives here at the interpret boundary — never in\n // a verb. `clock` (if provided) stamps `event.at` here too, the one permitted\n // clock read. The handler returns void synchronously — it dispatches NOTHING\n // back (no feedback loop) AND it does NOT await the sink (no backpressure /\n // crash from a slow or failing sink). See the fire-and-forget note below.\n const baseInterpret =\n (base as { interpret?: Interpret<M, C, Ctx> }).interpret ??\n ({} as Interpret<M, C, Ctx>);\n // Namespace guard (mirrors the substrate's SubId / definePort collision\n // asserts). The spread below merges `$telemetry:emit` into the base's\n // interpret map; if the base already declares that key, the spread would\n // SILENTLY clobber the base handler. The `$telemetry:` Cmd namespace is the\n // wrapper's — refuse to wrap a base that squats on it instead of stealing it.\n if (Object.hasOwn(baseInterpret as object, \"$telemetry:emit\")) {\n throw new Error(\n 'withTelemetry: the base machine declares a reserved \"$telemetry:emit\" ' +\n 'interpret handler — the wrapper owns the \"$telemetry:\" Cmd namespace. ' +\n \"Rename the base handler.\",\n );\n }\n const interpret = {\n ...(baseInterpret as Record<string, unknown>),\n // OBSERVE-ONLY at the boundary: the sink is fire-and-forget. The runtime\n // `await`s every interpret handler in its dispatch loop, so awaiting the\n // sink here would let a SLOW sink backpressure the wrapped machine (its\n // next dispatch waits) and a FAILING sink crash dispatch (the throw would\n // propagate out of the transition). Both violate the contract: telemetry\n // must never affect base behavior OR latency. So we DO NOT await — we hand\n // the event to the sink, normalize its result to a Promise, swallow any\n // rejection/throw, and return immediately. The handler resolves in the same\n // microtask the dispatch loop reaches it; the machine never waits on the\n // sink, and a rejected sink can never become an unhandled rejection.\n \"$telemetry:emit\": (\n cmd: TelemetryEmitCmd,\n ctx: Ctx & TelemetryPorts,\n ): void => {\n const event =\n cmd.event.at === undefined && ctx.clock !== undefined\n ? { ...cmd.event, at: ctx.clock() }\n : cmd.event;\n // `Promise.resolve(fn())` covers BOTH failure shapes: a sync `throw` is\n // caught by `Promise.resolve` (the call is the argument, so a throw here\n // would escape — guard it), and an async rejection is caught by `.catch`.\n try {\n Promise.resolve(ctx.telemetrySink(event)).catch(() => {});\n } catch {\n // A sink that throws SYNCHRONOUSLY (before returning a Promise) is\n // swallowed here. Either way the slow/failing sink never reaches the\n // dispatch loop's `await`.\n }\n },\n } as Interpret<M, C | TelemetryEmitCmd, Ctx & TelemetryPorts>;\n\n // Capture once so the narrowing survives into the spread (no non-null assert).\n const baseSubscriptions = base.subscriptions;\n const baseSubscribe = (base as { subscribe?: unknown }).subscribe;\n\n return {\n init: (loaded, ctx) => {\n // Rehydrate path: `loaded !== null` MUST return `[loaded, []]` (no Cmds) —\n // the substrate's replay enforces this. We split the composed loaded Model\n // into its base slice and feed the base its own loaded snapshot, so the\n // base's rehydrate contract is honored transitively.\n if (loaded !== null) {\n return [loaded, []];\n }\n const [base0, cmds] = base.init(null, ctx);\n const model: TelemetryModel<S> = { base: base0, $telemetry: { seq: 0 } };\n // Base init Cmds pass through unchanged; no telemetry Cmd on boot (boot is\n // not a base Msg transition, so it does not advance `seq`).\n return [model, cmds];\n },\n update: update as unknown as Reducer<\n TelemetryModel<S>,\n M,\n C | TelemetryEmitCmd\n >,\n // Subs merge to the base's, verbatim — telemetry owns no timers. The base\n // subscribes against its own nested slice.\n ...(baseSubscriptions\n ? {\n subscriptions: (state: TelemetryModel<S>) =>\n baseSubscriptions(state.base),\n }\n : {}),\n ...(baseSubscribe ? { subscribe: baseSubscribe } : {}),\n interpret,\n } as Machine<\n TelemetryModel<S>,\n M,\n C | TelemetryEmitCmd,\n U,\n Ctx & TelemetryPorts\n >;\n}\n"]}
@@ -1,83 +0,0 @@
1
- import { QueueItem } from './index.js';
2
- import '../runtime-types-Bxc637bp.js';
3
- import 'better-result';
4
- import '../core-Bjc0bS8j.js';
5
-
6
- /**
7
- * @demlik/tea/work-queue/adapter — the verb seam over the pure queue ops.
8
- *
9
- * The pure ops in `./ops` are the BLESSED transitions, but their names and
10
- * argument tuples (`enqueueOp(queue, input, now, id)`, `claimNextOp(queue,
11
- * now)`, …) and their `{ next, item }` / `{ next, changed }` result shapes are
12
- * the STORE's vocabulary, not the consumer's. An L2 composition that owns a
13
- * `QueueItem<I>[]` slice (`monitored-run`, `saga`, `idempotent-intake`,
14
- * `fan-out`) used to import those ops by name and call them directly, so a
15
- * change to the op surface — or to `QueueItem`'s fields — cascaded to every
16
- * call site.
17
- *
18
- * `QueueAdapter<I>` is the insulating interface: four VERBS (`enqueue` /
19
- * `claim` / `markDone` / `patch`) that consumers depend on instead of the raw
20
- * ops. The verbs keep the ops' pure `(queue, …) => { next, … }` contract — they
21
- * are pure array transforms, no I/O, no `Date.now` (the clock is injected as
22
- * `now`, exactly as the ops require it) — so a consumer folding the adapter
23
- * through its reducer stays inside invariant 2 (pure transitions).
24
- *
25
- * `queueAdapter<I>()` is the canonical implementation, a thin binding of the
26
- * blessed ops. Because the verbs are the only surface consumers touch, a
27
- * `QueueItem` shape change (a new field, a renamed status, a different op
28
- * signature) is now absorbed HERE — re-bind the verb once — rather than at the
29
- * 4 consumer call sites. The `patch` verb deliberately takes the same
30
- * `(item) => item` closure `patchItemOp` does, so the one place a `QueueItem`
31
- * literal is spread stays the consumer's patch closure, never a re-rolled
32
- * record.
33
- *
34
- * This is an INTERNAL seam (no public-API port): consumers import the adapter
35
- * from this subpath the same way they imported the ops. The ops remain
36
- * exported for the in-process `createQueue` adapter (`./index`) and for any
37
- * call site that genuinely wants the op directly.
38
- */
39
-
40
- /**
41
- * The verb interface over a `QueueItem<I>[]` slice. Each verb mirrors a blessed
42
- * op's pure contract but speaks the consumer's lifecycle vocabulary, so the
43
- * consumer never names a `*Op` function or reaches into a `QueueItem` field it
44
- * did not put there.
45
- */
46
- interface QueueAdapter<I> {
47
- /** Append a new `pending` item stamped `now` under `id`. */
48
- enqueue(queue: readonly QueueItem<I>[], input: I, now: number, id: string): {
49
- next: QueueItem<I>[];
50
- item: QueueItem<I>;
51
- };
52
- /**
53
- * Claim the first `pending` item — flip it `running`, stamp `startedAt` to
54
- * `now` — or `null` if nothing is pending.
55
- */
56
- claim(queue: readonly QueueItem<I>[], now: number): {
57
- next: QueueItem<I>[];
58
- claimed: QueueItem<I>;
59
- } | null;
60
- /** Drop the item `id` from the queue (completed runs leave the queue). */
61
- markDone(queue: readonly QueueItem<I>[], id: string): {
62
- next: QueueItem<I>[];
63
- changed: boolean;
64
- };
65
- /**
66
- * Single-item transition: replace the item `id` with `patch(item)`. The
67
- * closure is the only place a `QueueItem` literal is constructed, so the
68
- * field shape stays out of the consumer's hands except through this verb.
69
- */
70
- patch(queue: readonly QueueItem<I>[], id: string, patch: (item: QueueItem<I>) => QueueItem<I>): {
71
- next: QueueItem<I>[];
72
- changed: boolean;
73
- };
74
- }
75
- /**
76
- * The canonical `QueueAdapter<I>`, binding each verb to its blessed op. Pure
77
- * and stateless — call once at module scope in a consumer and fold its verbs
78
- * through the reducer. A `QueueItem` shape change is absorbed by re-binding a
79
- * verb here, not at the consumers.
80
- */
81
- declare function queueAdapter<I>(): QueueAdapter<I>;
82
-
83
- export { type QueueAdapter, queueAdapter };
@@ -1,4 +0,0 @@
1
- export { queueAdapter } from '../chunk-MU6MCIAC.js';
2
- import '../chunk-FV3Z5MBE.js';
3
- //# sourceMappingURL=adapter.js.map
4
- //# sourceMappingURL=adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"adapter.js"}
@@ -1,70 +0,0 @@
1
- import { QueueItem } from './index.js';
2
- import '../runtime-types-Bxc637bp.js';
3
- import 'better-result';
4
- import '../core-Bjc0bS8j.js';
5
-
6
- /**
7
- * Pure queue-lifecycle ops over `QueueItem<I>[]` — the BLESSED delegation
8
- * surface for this package.
9
- *
10
- * Each op is `(queue, ...args) => { next, result? }`. No I/O, no Date.now
11
- * indirection beyond a plain call site — the adapter in `./index.ts` injects
12
- * `Store<QueueItem<I>[]>` and orchestrates `load → mutate → save`.
13
- *
14
- * Substrate-agnostic by construction: nothing here references chrome.storage,
15
- * Cloudflare, or any concrete persistence layer. The audit-specific shape
16
- * (journeyId, projectId, ...) is lifted into the caller's `I` parameter.
17
- *
18
- * Importable two ways. The `createQueue(...)` adapter in `./index.ts` binds
19
- * these ops to a `Store` for in-process use (same one-shape-per-package rule
20
- * as `@demlik/tea/do`). L2 compositions that own their own Model slice
21
- * (`monitored-run`, `idempotent-intake`, …) instead reach these ops directly
22
- * via the `@demlik/tea/work-queue/ops` subpath, so a status flip is delegated
23
- * here rather than re-rolled per call site.
24
- */
25
-
26
- /** Append a new pending item. Returns the new queue and the created item. */
27
- declare function enqueueOp<I>(queue: readonly QueueItem<I>[], input: I, now: number, id: string): {
28
- next: QueueItem<I>[];
29
- item: QueueItem<I>;
30
- };
31
- /**
32
- * Claim the first pending item by flipping it to `running` and stamping
33
- * `startedAt`. Returns the new queue and the claimed item, or `null` if no
34
- * pending item exists.
35
- */
36
- declare function claimNextOp<I>(queue: readonly QueueItem<I>[], now: number): {
37
- next: QueueItem<I>[];
38
- claimed: QueueItem<I>;
39
- } | null;
40
- /**
41
- * Done items leave the queue — completed runs live wherever the caller
42
- * persists their output. Returns the new queue (or the original reference if
43
- * no item matched, so the adapter can skip a save).
44
- */
45
- declare function markDoneOp<I>(queue: readonly QueueItem<I>[], id: string): {
46
- next: QueueItem<I>[];
47
- changed: boolean;
48
- };
49
- /**
50
- * Generic single-item status transition. Used by `markFailed`,
51
- * `markCancelled`, `retryItem`, `bindOutput`. The patch closure receives the
52
- * matched item and returns its replacement; returning the same reference is
53
- * fine (the adapter only saves on `changed`).
54
- */
55
- declare function patchItemOp<I>(queue: readonly QueueItem<I>[], id: string, patch: (item: QueueItem<I>) => QueueItem<I>): {
56
- next: QueueItem<I>[];
57
- changed: boolean;
58
- };
59
- /** Reset every `running` item back to `pending`, clearing `startedAt`. */
60
- declare function resetRunningOp<I>(queue: readonly QueueItem<I>[]): {
61
- next: QueueItem<I>[];
62
- changed: boolean;
63
- };
64
- /** Hard-delete an item regardless of status. */
65
- declare function removeOp<I>(queue: readonly QueueItem<I>[], id: string): {
66
- next: QueueItem<I>[];
67
- changed: boolean;
68
- };
69
-
70
- export { claimNextOp, enqueueOp, markDoneOp, patchItemOp, removeOp, resetRunningOp };
@@ -1,3 +0,0 @@
1
- export { claimNextOp, enqueueOp, markDoneOp, patchItemOp, removeOp, resetRunningOp } from '../chunk-FV3Z5MBE.js';
2
- //# sourceMappingURL=ops.js.map
3
- //# sourceMappingURL=ops.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"ops.js"}