@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,743 @@
1
+ import { a as CmdOf, b as CmdDef, C as Cmd, I as Interpret, i as CmdValue, g as PortEmitter, S as Sub, M as Machine } from '../core-CTzMJ82M.js';
2
+ import { M as MsgType, e as ResilientConfig, a as ResilientState, R as RunCmd, S as SucceedMsg, F as FailMsg, f as ResilientTimerMsg, d as ResilientPorts } from '../index-B5BZ-_cT.js';
3
+ export { g as CacheConfig, h as CallBudget, i as CallPhase, C as CircuitConfig, j as CircuitPolicy, k as CircuitState, l as DeadlineExceededError, c as RateLimitConfig, D as ResilientCallDeadlineConfig, m as RunCmdDef, n as SlidingWindow, T as TokenBucket, o as canPass, p as createResilientCall, q as defaultCircuitPolicy, r as initBucket, s as initCircuit, t as initWindow, u as liftResilience, v as onFailure, w as onSuccess, x as record, y as refill, z as remaining, A as runCmdDef, B as tryConsume } from '../index-B5BZ-_cT.js';
4
+ import { a as DeadlineSub } from '../index-q0hXFeZ0.js';
5
+ export { A as ArmTimer, e as CacheEntry, c as CacheEvictMsg, C as CacheEvictionSub, D as DeadlineExceeded, f as DeadlineOpts, T as TtlCache, g as cacheEvictMsg, h as cacheEvictionSub, i as cacheEvictionSubscribe, d as deadlineExceeded, b as deadlineSub, j as evictExpired, k as get, l as has, m as initCache, r as remove, n as set, o as setTimeoutArmTimer, s as subscribeDeadline, p as subscribeWith } from '../index-q0hXFeZ0.js';
6
+ import { Rng, RetryPolicy } from '../retry-backoff/index.js';
7
+ import 'zod';
8
+ import '../types-DP3f5NIl.js';
9
+
10
+ /**
11
+ * A minted credential: the opaque `value` to send on the wire, and the absolute
12
+ * `expiresAt` (epoch milliseconds — the `Date.now()` scale) the issuer stamped
13
+ * it with. Both fields are plain data so a `Token` is trivially serializable
14
+ * into a consumer's `Store<S>`.
15
+ *
16
+ * `value` is `string` because that is the universal shape of a bearer token /
17
+ * API key / session cookie on the wire. A consumer whose refresh port yields a
18
+ * richer object can JSON-encode it into `value`, or keep this module's slice as
19
+ * the "is it fresh?" gate and hold the richer object elsewhere in their Model.
20
+ */
21
+ interface Token {
22
+ /** The opaque credential to present on each request (bearer token, API key). */
23
+ readonly value: string;
24
+ /** Absolute expiry instant, epoch milliseconds. The `Date.now()` scale. */
25
+ readonly expiresAt: number;
26
+ }
27
+ /**
28
+ * Pure configuration — the knob's only field. Carries no mutable state;
29
+ * `TokenState` does. One config is shared across all the refreshes of one
30
+ * logical credential (often a module-scope const).
31
+ */
32
+ interface TokenRefreshConfig {
33
+ /**
34
+ * Refresh-ahead skew, in milliseconds. A token is treated as needing a
35
+ * refresh once `at >= expiresAt - skewMs`, i.e. `skewMs` BEFORE its hard
36
+ * expiry. This buys headroom so a call that starts just under the wire never
37
+ * races a token that lapses mid-flight, and absorbs small client/server clock
38
+ * disagreement. `0` means "refresh exactly at expiry"; a negative value is
39
+ * clamped to `0` (a skew that pushes the trigger past expiry is meaningless).
40
+ *
41
+ * @default 0
42
+ */
43
+ readonly skewMs?: number;
44
+ }
45
+ /**
46
+ * The token slice this knob owns — the Model field a consumer spreads in via
47
+ * `init()`. A two-field record rather than a phase union because the two
48
+ * dimensions are orthogonal: a token can be present-and-fresh, present-but-stale
49
+ * (a 401 came back), absent, or absent-and-stale (cleared after a failed
50
+ * refresh). Every combination is meaningful, so neither field implies the
51
+ * other's value and a discriminated union would only manufacture impossible
52
+ * arms.
53
+ *
54
+ * - `token` — the currently held credential, or `null` when none has been
55
+ * minted yet (fresh boot) or the last refresh failed.
56
+ * - `stale` — set by `on401` when the server rejected a request the client
57
+ * believed valid. Forces the next `needsRefresh` to true regardless of
58
+ * `expiresAt`; cleared by `refreshed` once a new credential lands.
59
+ *
60
+ * Both fields `readonly` so the whole slice threads safely through a pure
61
+ * reducer and serializes into a `Store<S>`.
62
+ */
63
+ interface TokenState {
64
+ /** The held credential, or `null` if none is available (boot / failed refresh). */
65
+ readonly token: Token | null;
66
+ /** Whether a 401 has marked the held token unusable ahead of its `expiresAt`. */
67
+ readonly stale: boolean;
68
+ }
69
+ /**
70
+ * The starting slice: no token held, not stale. The first `needsRefresh` after
71
+ * this returns `true` (no token), so a consumer's first guarded call mints a
72
+ * credential before going out.
73
+ */
74
+ declare function initTokenRefresh(): TokenState;
75
+ /**
76
+ * The Cmd this knob emits to ask the runtime to mint a fresh token. Plain data
77
+ * (no closure — invariant 1) carrying nothing: the refresh port takes no input,
78
+ * and the slice the result installs is read off the follow-up Msg, not this
79
+ * Cmd. The consumer unions this into their machine's Cmd type and lets
80
+ * `handlers` interpret it.
81
+ */
82
+ declare const refreshToken: CmdDef<"refresh_token", Record<string, never>, Token, {
83
+ readonly [detail: string]: unknown;
84
+ readonly _tag: "token_refresh_failed";
85
+ }, unknown>;
86
+ type RefreshTokenCmd = CmdOf<typeof refreshToken>;
87
+ /** Construct a `refresh_token` Cmd. */
88
+ declare function refreshTokenCmd(): RefreshTokenCmd;
89
+ /**
90
+ * The Msg the refresh port dispatches on success — carries the freshly minted
91
+ * `Token`. The consumer unions this into their Msg type and handles it by
92
+ * folding `refreshed(state, msg.token)` into the slice.
93
+ */
94
+ interface TokenRefreshedMsg {
95
+ readonly type: typeof MsgType.TokenRefreshed;
96
+ readonly token: Token;
97
+ }
98
+ /** Construct a `token_refreshed` Msg carrying the new token. */
99
+ declare function tokenRefreshedMsg(token: Token): TokenRefreshedMsg;
100
+ /**
101
+ * The Msg the refresh port dispatches on failure — carries the rejection so the
102
+ * consumer's reducer can decide whether to back off, surface an error, or give
103
+ * up (errors are data: it is dispatched, never swallowed). The slice itself is
104
+ * left untouched by a failed refresh — the held token (if any) stays held and
105
+ * stale stays set, so the consumer can retry; clearing it is the consumer's
106
+ * policy, expressed in their reducer.
107
+ */
108
+ interface TokenRefreshFailedMsg {
109
+ readonly type: typeof MsgType.TokenRefreshFailed;
110
+ readonly error: unknown;
111
+ }
112
+ /** Construct a `token_refresh_failed` Msg carrying the rejection. */
113
+ declare function tokenRefreshFailedMsg(error: unknown): TokenRefreshFailedMsg;
114
+ /** The two Msgs the refresh port can produce. Union for a consumer's Msg type. */
115
+ type TokenRefreshMsg = TokenRefreshedMsg | TokenRefreshFailedMsg;
116
+ /** The ports this knob's `handlers` splice needs — the single refresh DI seam. */
117
+ interface TokenRefreshPorts {
118
+ /**
119
+ * Mint a fresh credential. Called ONLY from the `refresh_token` interpret
120
+ * handler — never from a verb — so the network I/O and any clock the issuer
121
+ * reads stay at the effect boundary. May reject; the rejection is routed to
122
+ * `token_refresh_failed` (errors are data), never thrown into the runtime.
123
+ */
124
+ readonly refresh: () => Promise<Token>;
125
+ }
126
+ /**
127
+ * The knob: hand it a config, get back the slice initializer, the pure verbs,
128
+ * and the `handlers` splice. Mirrors every L2 composition's uniform contract so
129
+ * the call sites read identically across bricks.
130
+ *
131
+ * @example
132
+ * const tr = createTokenRefresh({ skewMs: 30_000 });
133
+ * const s0 = tr.init();
134
+ * const [s1, cmds] = tr.ensureFresh(s0, Date.now()); // cmds = [refreshTokenCmd()]
135
+ */
136
+ declare function createTokenRefresh(config?: TokenRefreshConfig): {
137
+ /** The slice initializer — spread into the consumer's `init`. */
138
+ init: typeof initTokenRefresh;
139
+ needsRefresh: (state: TokenState, at: number) => boolean;
140
+ on401: (state: TokenState) => TokenState;
141
+ refreshed: (state: TokenState, token: Token) => TokenState;
142
+ ensureFresh: (state: TokenState, at: number) => readonly [TokenState, readonly Cmd[]];
143
+ handlers: (ports: TokenRefreshPorts) => Interpret<TokenRefreshMsg, RefreshTokenCmd, unknown>;
144
+ };
145
+ /** The shape `createTokenRefresh` returns — useful for typing a held knob. */
146
+ type TokenRefresh = ReturnType<typeof createTokenRefresh>;
147
+
148
+ /**
149
+ * The authed-call knob. It is `ResilientConfig` widened by the token dimension:
150
+ *
151
+ * - `refresh` — the ONLY required field: the port that mints a fresh `Token`.
152
+ * Identical to token-refresh's `TokenRefreshPorts.refresh`; it is hoisted
153
+ * onto the config (not the ports) so the consumer spells the credential
154
+ * source once, the same way `rng` is curried onto the factory.
155
+ * - `skewMs` — token-refresh's refresh-ahead skew (optional, defaults to 0).
156
+ * - every `ResilientConfig` field (`retry` / `circuit` / `rateLimit` /
157
+ * `cache` / `deadline`) — passed straight through to the resilient-call
158
+ * knob, each still optional, each still "omit a brick → omit its gate".
159
+ */
160
+ interface AuthedConfig extends ResilientConfig, TokenRefreshConfig {
161
+ /** Mint a fresh credential. The single DI seam the auth dimension adds. */
162
+ readonly refresh: () => Promise<Token>;
163
+ }
164
+ /**
165
+ * The composed slice. Three plain-data fields, no closures:
166
+ *
167
+ * - `resilience` — resilient-call's entire slice (circuit, bucket, retry,
168
+ * cache, calls). Owned and mutated only via resilient-call's verbs.
169
+ * - `auth` — token-refresh's `{ token, stale }` slice. Owned and mutated only
170
+ * via token-refresh's verbs.
171
+ * - `authRetry` — per-key count of auth-retries (401 → refresh → retry) spent
172
+ * on a call. Caps the dance at one retry per call so a credential the server
173
+ * keeps rejecting cannot spin forever. A key absent from the record has
174
+ * spent zero. Cleared when a call settles or a fresh `attempt` starts.
175
+ *
176
+ * `pendingAuthRetry` carries the inputs of calls parked waiting for the refresh
177
+ * to land, keyed so `onRefreshed` can re-issue exactly those calls. Plain data —
178
+ * `input` is the same payload the call was issued with.
179
+ */
180
+ interface AuthedState<I, R> {
181
+ readonly resilience: ResilientState<I, R>;
182
+ readonly auth: TokenState;
183
+ readonly authRetry: Readonly<Record<string, number>>;
184
+ readonly pendingAuthRetry: Readonly<Record<string, I>>;
185
+ }
186
+ /** The two effects this knob emits: resilient-call's run, token-refresh's mint. */
187
+ type AuthedCmd<I> = RunCmd<I> | RefreshTokenCmd;
188
+ /**
189
+ * Every Msg the knob's verbs fold. Resilient-call's settle + timer Msgs, token-
190
+ * refresh's refresh-result Msgs, and the 401 trigger the consumer dispatches
191
+ * when a guarded call comes back unauthorized.
192
+ */
193
+ type Unauthorized = {
194
+ readonly type: typeof MsgType.Unauthorized;
195
+ readonly key: string;
196
+ readonly at: number;
197
+ };
198
+ /**
199
+ * The plain-data error a 401 we cannot fix settles with. A `{_tag, ...}`
200
+ * sentinel — NEVER a `new Error(...)` — so the slice stays JSON-serializable
201
+ * (an Error object round-trips to `{}` under JSON and carries a stack trace,
202
+ * both of which break the slice's durability invariant once it is persisted
203
+ * into a `Store<S>` and reloaded). Mirrors resilient-call's `DeadlineExceededError`
204
+ * sentinel discipline. `key` echoes the call that was rejected so a consumer can
205
+ * attribute the failure.
206
+ */
207
+ type UnauthorizedError = {
208
+ readonly _tag: "unauthorized";
209
+ readonly key: string;
210
+ };
211
+ /** Ports `handlers` needs — resilient-call's run port AND token-refresh's refresh port. */
212
+ interface AuthedPorts<I, R> extends ResilientPorts<I, R> {
213
+ /** Mint a fresh credential. Mirrors `AuthedConfig.refresh` for symmetry at the splice site. */
214
+ readonly refresh: () => Promise<Token>;
215
+ }
216
+ /**
217
+ * Build an authed-call knob from `config`. `rng` is injected for retry jitter
218
+ * and threaded straight into the underlying resilient-call knob — pass a fixed
219
+ * `() => 0.5` in tests to pin backoff; defaults to `Math.random` (read only at
220
+ * the verb boundary inside resilient-call, never in a brick op).
221
+ *
222
+ * Returns the uniform L2 knob contract, widened by the auth verbs (`on401`,
223
+ * `onRefreshed`, `installToken`). `I` is the port input type, `R` the result.
224
+ */
225
+ declare function createAuthedCall<I, R>(config: AuthedConfig, rng?: () => number): {
226
+ init: () => AuthedState<I, R>;
227
+ attempt: (s: AuthedState<I, R>, key: string, input: I, at: number) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
228
+ succeed: (s: AuthedState<I, R>, key: string, msg: SucceedMsg<R>) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
229
+ fail: (s: AuthedState<I, R>, key: string, msg: FailMsg) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
230
+ on401: (s: AuthedState<I, R>, key: string, at: number) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
231
+ installToken: (s: AuthedState<I, R>, token: Token) => AuthedState<I, R>;
232
+ onRefreshed: (s: AuthedState<I, R>, at: number) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
233
+ onTimer: (s: AuthedState<I, R>, msg: ResilientTimerMsg) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
234
+ /** token-refresh's call-boundary verb, re-exposed for proactive expiry refresh. */
235
+ needsRefresh: (s: AuthedState<I, R>, at: number) => boolean;
236
+ subs: (s: AuthedState<I, R>) => readonly DeadlineSub[];
237
+ handlers: (ports: AuthedPorts<I, R>) => {
238
+ refresh_token: (cmd: CmdValue<"refresh_token", Record<string, never>, {
239
+ readonly [detail: string]: unknown;
240
+ readonly _tag: "token_refresh_failed";
241
+ }, unknown>, ctx: PortEmitter, dispatch?: ((msg: TokenRefreshMsg) => void) | undefined) => Promise<void | TokenRefreshMsg>;
242
+ resilient_run: (cmd: CmdValue<"resilient_run", {
243
+ readonly key: string;
244
+ readonly input: I;
245
+ }, {
246
+ readonly [detail: string]: unknown;
247
+ readonly _tag: "deadline_exceeded";
248
+ } | {
249
+ readonly [detail: string]: unknown;
250
+ readonly _tag: "port_rejected";
251
+ }, unknown>, ctx: Readonly<Record<never, never>>) => Promise<FailMsg | SucceedMsg<R>>;
252
+ };
253
+ };
254
+ /** The shape `createAuthedCall` returns — useful for typing a held knob. */
255
+ type AuthedCall<I, R> = ReturnType<typeof createAuthedCall<I, R>>;
256
+ /**
257
+ * Lift a knob result `[slice, cmds]` into a host `[State, cmds]` where the slice
258
+ * lives at `state.authed`. A convenience for the common single-slice host;
259
+ * consumers with a differently-named field spread by hand. Pure — a thin record
260
+ * rebuild, no clock / RNG.
261
+ */
262
+ declare function liftAuthed<S extends {
263
+ authed: AuthedState<I, R>;
264
+ }, I, R, C extends Cmd>(state: S, [slice, cmds]: readonly [AuthedState<I, R>, readonly C[]]): readonly [S, readonly C[]];
265
+
266
+ /**
267
+ * internal/resilience/retry-to-success — run a fallible async port through BOUNDED
268
+ * retry + exponential backoff to success-or-terminal-give-up, and hand the
269
+ * caller a `Promise<R>` that resolves on the first success or REJECTS with a
270
+ * checkable {@link RetryExhaustedError} the moment the retry bound is hit.
271
+ *
272
+ * This is the retry-side parallel to `./await-terminal`. `runToTerminal` gives a
273
+ * caller with a one-shot decision *machine* a fire-and-await `Promise<State>`
274
+ * without wiring `observe`; this gives a caller with a one-shot fallible *port*
275
+ * a fire-and-await `Promise<R>` without either hand-folding the
276
+ * `./retry-backoff` primitives (`recordFailure` / `shouldRetry` / `nextDelayMs`)
277
+ * into their own reducer each time, or standing up the full `./resilient-call`
278
+ * verb contract (`init` + `attempt`/`succeed`/`fail`/`onTimer` + `subs` +
279
+ * `handlers`) when they want retry only and none of cache / circuit / rate-limit
280
+ * / deadline.
281
+ *
282
+ * It adds NO new runtime capability and NO new backoff math — the whole retry
283
+ * decision is `./retry-backoff` exactly as `resilient-call`'s `backoff` verb
284
+ * wires it:
285
+ * - `initRetry()` seeds the per-call attempt counter.
286
+ * - `recordFailure(retry, error)` folds each thrown failure (attempt++).
287
+ * - `shouldRetry(retry, policy)` is the terminal-at-`maxAttempts` bound — the
288
+ * `maxAttempts`-th recorded failure refuses another attempt (attempts
289
+ * `0 .. maxAttempts-1` run; the port is invoked at most `maxAttempts` times).
290
+ * - `nextDelayMs(retry, policy, rng)` is the exp+jitter+cap delay before the
291
+ * next attempt, computed on the incremented state — same call order as
292
+ * `resilient-call`.
293
+ *
294
+ * Where the clock / RNG live: injected, never read on the module's own behalf,
295
+ * mirroring `retry-backoff`'s purity discipline. `rng` is an {@link Rng} (branded
296
+ * `[0, 1)` via `asRng` at the caller boundary) threaded straight into
297
+ * `nextDelayMs`; the wait itself is a `sleep(ms)` port defaulting to a real
298
+ * `setTimeout`, injectable so a test can drive the backoff schedule
299
+ * deterministically without touching wall-clock timers.
300
+ *
301
+ * Exhaustion is NEVER a silent swallow: at the bound the returned promise
302
+ * rejects with {@link RetryExhaustedError} (carrying the attempt count and the
303
+ * final failure), the retry-side dialect of `await-terminal`'s
304
+ * `TerminalTimeoutError` — a distinct `instanceof`- and `_tag`-checkable
305
+ * rejection.
306
+ *
307
+ * NOT a substrate primitive: it depends on nothing from `../index`, only on the
308
+ * leaf `retry-backoff` utility. Internal to the package
309
+ * (`src/internal/resilience/`, #46), not a published subpath.
310
+ */
311
+
312
+ /**
313
+ * Raised when `retryToSuccess` exhausts the retry bound without a success — the
314
+ * `maxAttempts`-th recorded failure refuses another attempt. Follows the tea
315
+ * error dialect (`override readonly name`) and carries a `_tag` discriminant, so
316
+ * a caller can branch on it by `instanceof` or on the tag. It carries the number
317
+ * of attempts made and the final failure (`lastError`) so the terminal give-up
318
+ * is a distinct, checkable rejection — never a silent resolve, and never a
319
+ * swallowed error.
320
+ */
321
+ declare class RetryExhaustedError extends Error {
322
+ /** How many times the port was invoked before giving up (= `policy.maxAttempts`). */
323
+ readonly attempts: number;
324
+ /** The failure the final attempt threw — carried, never interpreted. */
325
+ readonly lastError: unknown;
326
+ readonly name = "RetryExhaustedError";
327
+ readonly _tag: "RetryExhaustedError";
328
+ constructor(
329
+ /** How many times the port was invoked before giving up (= `policy.maxAttempts`). */
330
+ attempts: number,
331
+ /** The failure the final attempt threw — carried, never interpreted. */
332
+ lastError: unknown);
333
+ }
334
+ /** Options for {@link retryToSuccess}. */
335
+ interface RetryToSuccessOptions {
336
+ /**
337
+ * The `[0, 1)` jitter source threaded into `nextDelayMs`, branded via
338
+ * `asRng` at construction (a raw `() => number` is rejected by the type).
339
+ * Injected for deterministic backoff in tests; defaults to `defaultRng`
340
+ * (`Math.random`), read only at the delay boundary — never inside the loop's
341
+ * decision.
342
+ */
343
+ readonly rng?: Rng;
344
+ /**
345
+ * The wait between attempts, given the backoff delay in ms. Injectable so a
346
+ * test can drive the retry schedule without wall-clock timers (and assert the
347
+ * exact delays); defaults to a real `setTimeout`. The delay value is always
348
+ * `./retry-backoff`'s `nextDelayMs` — this port only realizes the wait.
349
+ */
350
+ readonly sleep?: (ms: number) => Promise<void>;
351
+ }
352
+ /**
353
+ * Fire-and-await bounded retry: invoke the fallible `port`, and on each thrown
354
+ * failure fold it through `./retry-backoff` — record it, and if the policy
355
+ * still permits an attempt, back off `nextDelayMs` and retry; otherwise REJECT
356
+ * with {@link RetryExhaustedError}. Resolves with the port's value on the first
357
+ * success.
358
+ *
359
+ * The port is invoked at most `policy.maxAttempts` times (attempts
360
+ * `0 .. maxAttempts-1`); the `maxAttempts`-th failure is terminal. Every failure
361
+ * is either retried or surfaced on the rejection's `lastError` — none is
362
+ * swallowed.
363
+ *
364
+ * @param port the fallible work — throws on failure, resolves with `R` on success.
365
+ * @param policy the bounded-retry curve (`baseMs` / `factor` / `capMs` /
366
+ * `maxAttempts` / `jitter`) from `./retry-backoff`.
367
+ * @param opts optional injected `rng` (jitter) and `sleep` (the wait) — see
368
+ * {@link RetryToSuccessOptions}.
369
+ */
370
+ declare function retryToSuccess<R>(port: () => Promise<R>, policy: RetryPolicy, opts?: RetryToSuccessOptions): Promise<R>;
371
+
372
+ /**
373
+ * The wrapper's Model slice. `phase` is the lifecycle (`armed` while the
374
+ * countdown runs, `exceeded` once the deadline fired); `seq` is the monotonic
375
+ * re-arm counter that keys the timer Sub's id so each accepted progress Msg
376
+ * retires the old timer and starts a fresh one.
377
+ *
378
+ * PURE and SERIALIZABLE: there is deliberately NO absolute timestamp here. A
379
+ * deadline timestamp would force the merged `update` to read the wall clock to
380
+ * compute it, which the conformance gate (property 2 — two replays under
381
+ * distinct ambient clocks) is built to catch. Instead, the timer arms a fresh
382
+ * full `ms` countdown per generation; no remaining-delay computation and no
383
+ * clock read occur in the slice or `update` — the only clock is `setTimeout`
384
+ * inside the Sub.
385
+ */
386
+ interface DeadlineSlice {
387
+ /** `armed` while the countdown is live; `exceeded` once the deadline fired. */
388
+ readonly phase: "armed" | "exceeded";
389
+ /**
390
+ * Monotonic re-arm counter. Starts at 0; each accepted progress Msg (while
391
+ * armed) bumps it by one. Folds into the timer Sub's id, so a bump = a new id
392
+ * = the substrate retires the old timer and arms a fresh `ms` countdown.
393
+ */
394
+ readonly seq: number;
395
+ }
396
+ /**
397
+ * The composed Model. The base machine's state is nested under `base`; the
398
+ * wrapper's state lives in the NAMED `$deadline` slice — never hidden in a
399
+ * closure. Both fields are plain data, so the whole composed Model round-trips
400
+ * through `JSON.parse(JSON.stringify(...))` iff the base state does.
401
+ */
402
+ interface DeadlineModel<S> {
403
+ readonly base: S;
404
+ readonly $deadline: DeadlineSlice;
405
+ }
406
+ /**
407
+ * The relative-timeout Sub the wrapper arms while `phase === "armed"`. `delayMs`
408
+ * is the window `config.ms`; the id is `$deadline:timeout:{seq}`, so each
409
+ * progress bump produces a distinct id and the reconcile pass churns the timer.
410
+ * Same `delayMs`-on-the-Sub shape `fromTimeout` consumes.
411
+ */
412
+ type DeadlineTimeoutSub = Sub<"$deadline:timeout"> & {
413
+ readonly delayMs: number;
414
+ };
415
+ /**
416
+ * The Msg the timeout Sub dispatches when `config.ms` elapses with no accepted
417
+ * progress. `seq` echoes the re-arm generation the timer was armed against, so a
418
+ * stale timer's Msg (one whose id was already retired) is identifiable; the
419
+ * merged `update` only honors it when it matches the current slice `seq`.
420
+ */
421
+ interface DeadlineExceededMsg {
422
+ readonly type: "$deadline:exceeded";
423
+ /** The re-arm generation this timer was armed against. */
424
+ readonly seq: number;
425
+ }
426
+ /**
427
+ * Construct the deadline-exceeded Msg. Exported so the subscribe cell and tests
428
+ * share one constructor rather than two literals that can drift.
429
+ */
430
+ declare function deadlineExceededMsg(seq: number): DeadlineExceededMsg;
431
+ /**
432
+ * The fire-and-forget decision Cmd the merged `update` appends on every
433
+ * transition, so the wrapper's choice is visible in the replayed Cmd log
434
+ * (rule 3) — `rearm` when an accepted progress Msg bumped `seq`, `expire` when
435
+ * the deadline-exceeded Msg flipped the phase, `idle` otherwise (a non-progress
436
+ * Msg, or a Msg after the machine already auto-failed). Plain data; its
437
+ * interpret handler is a no-op (the decision is the Cmd's presence in the log,
438
+ * not a side effect).
439
+ */
440
+ declare const deadlineDecision: CmdDef<"$deadline:decision", {
441
+ decision: "idle" | "rearm" | "expire";
442
+ seq: number;
443
+ }, void, never, unknown>;
444
+ type DeadlineDecisionCmd = CmdOf<typeof deadlineDecision>;
445
+ /**
446
+ * A predicate over a Msg that decides whether it re-arms the deadline.
447
+ *
448
+ * The argument is `Readonly<M>` and the result is `boolean`: this is the
449
+ * STRONGEST purity TS can express here. `Readonly<M>` removes the most common
450
+ * impurity at compile time — the predicate cannot reassign the Msg's own
451
+ * fields — and `boolean` pins the return so a side-effecting `(msg) => { … }`
452
+ * with an implicit `undefined`/`void` return is rejected.
453
+ *
454
+ * What the type system CANNOT encode (TS has no effect tracking): observational
455
+ * purity. A body that reads `Date.now()`, calls `Math.random()`, performs IO,
456
+ * or closes over and mutates external state still type-checks. Those remain a
457
+ * CONVENTION enforced by review, not the compiler — the predicate runs inside
458
+ * the pure merged `update` (invariant 2), so it must be a pure function of the
459
+ * Msg alone: no clock, no RNG, no IO, no captured mutable state.
460
+ */
461
+ type ProgressPredicate<M extends {
462
+ type: string;
463
+ }> = (msg: Readonly<M>) => boolean;
464
+ /**
465
+ * The deadline knob. `ms` is the inactivity window; `progress` is an OPTIONAL
466
+ * predicate picking which base Msgs count as activity (default: EVERY base Msg
467
+ * re-arms). The predicate runs INSIDE the pure merged `update`, so it must be a
468
+ * pure function of the Msg — see {@link ProgressPredicate} for what the type
469
+ * enforces vs. what stays a convention.
470
+ */
471
+ interface DeadlineConfig<M extends {
472
+ type: string;
473
+ }> {
474
+ /** The inactivity window in milliseconds. Auto-fail after `ms` with no progress. */
475
+ readonly ms: number;
476
+ /**
477
+ * Predicate picking which base Msgs re-arm the timer. Default: every base Msg
478
+ * counts as progress. Pure — a function of the Msg alone (see
479
+ * {@link ProgressPredicate}).
480
+ */
481
+ readonly progress?: ProgressPredicate<M>;
482
+ }
483
+ /**
484
+ * Wrap `base` with an inactivity deadline. Returns a NEW `Machine` over the
485
+ * composed Model `{ base, $deadline }`, with the base's Msgs/Cmds/Subs extended
486
+ * by the wrapper's own (`$deadline:exceeded` Msg, `$deadline:decision` Cmd,
487
+ * `$deadline:timeout` Sub).
488
+ *
489
+ * The composed machine:
490
+ * - `init` rehydrates the base (honoring the `[loaded, []]` contract) and
491
+ * seeds `$deadline: { phase: "armed", seq: 0 }`. Base init Cmds pass
492
+ * through unchanged.
493
+ * - `update` (Reducer form) runs the base reducer for base Msgs — base Cmds
494
+ * pass through UNCHANGED — and on an accepted progress Msg bumps `seq`
495
+ * (re-arm). The `$deadline:exceeded` Msg cell flips `phase` to `exceeded`.
496
+ * Every transition appends a `$deadline:decision` marker Cmd.
497
+ * - `subscriptions` is the base's, plus a `$deadline:timeout` Sub keyed on
498
+ * `seq` while `phase === "armed"`.
499
+ * - `subscribe` is the base's, plus the `$deadline:timeout` cell.
500
+ * - `interpret` is the base's, plus a no-op `$deadline:decision` handler.
501
+ *
502
+ * @param base any `Machine<S, M, C, U, Ctx>`.
503
+ * @param config the deadline knob (`ms` window + optional `progress` predicate).
504
+ */
505
+ declare function withDeadline<S, M extends {
506
+ type: string;
507
+ }, C extends Cmd, U extends Sub, Ctx>(base: Machine<S, M, C, U, Ctx>, config: DeadlineConfig<M>): Machine<DeadlineModel<S>, M | DeadlineExceededMsg, C | DeadlineDecisionCmd, U | DeadlineTimeoutSub, Ctx>;
508
+
509
+ /**
510
+ * The `withResilience` knob. Extends resilient-call's `ResilientConfig` (every
511
+ * brick optional — omit a brick, omit its gate) with the two fields the wrapper
512
+ * needs that the bare knob does not:
513
+ *
514
+ * - `target` — the `Cmd.type` discriminant of the ONE base Cmd this wrapper
515
+ * hardens. Every other base Cmd passes through untouched.
516
+ * - `keyOf` — OPTIONAL. Derives the per-call resilience `key` from the target
517
+ * base Cmd, so distinct logical calls (distinct urls, distinct ids) get
518
+ * independent retry / cache state. Pure — it runs inside the merged
519
+ * `update`, so it must NOT read the clock / RNG. Defaults to a single
520
+ * shared key (`target`), i.e. one logical call at a time.
521
+ */
522
+ interface ResilienceConfig<TC extends Cmd, TM extends {
523
+ type: string;
524
+ }> extends ResilientConfig {
525
+ /** The base `Cmd.type` to make resilient. */
526
+ readonly target: TC["type"];
527
+ /** Optional per-call key deriver. Pure. Defaults to the target type itself. */
528
+ readonly keyOf?: (cmd: TC) => string;
529
+ /**
530
+ * Extracts the real wall-clock time (ms) the TRIGGERING base Msg carries as
531
+ * data — the time-as-data convention `resilient-call` expects on `attempt`.
532
+ *
533
+ * The merged `update` is PURE: it cannot read `Date.now()` (rule 5). The COLD
534
+ * attempt's gate (the very first `attempt` for a target Cmd in a transition)
535
+ * still needs a real instant — the breaker compares `at` against its recorded
536
+ * `openedAtMs`, the cache against its write `at`, the bucket against its last
537
+ * refill `at`, and the deadline cap anchors at `at + deadline.ms`. Fabricating
538
+ * `at = 0` is the betrayal: a cold attempt after a real-time breaker trip then
539
+ * computes cooldown = `0 - realTripTime < 0` forever, so the breaker NEVER
540
+ * recovers, and a `0`-anchored deadline brick fires immediately.
541
+ *
542
+ * So the base Msg that drove this transition MUST carry its own wall time as
543
+ * data, and `at` reads it off that Msg. The merged update passes
544
+ * `at(currentBaseMsg)` into `rc.attempt` for every target Cmd that transition
545
+ * emitted — real time enters the cold gate as Msg data, never `0`.
546
+ *
547
+ * REQUIRED whenever any time-sensitive brick (`circuit`, `rateLimit`, `cache`,
548
+ * `deadline`) is configured — `withResilience` THROWS at construction if such
549
+ * a brick is set and `at` is absent (errors are data: the cold gate needs real
550
+ * time, refuse to build a breaker that can never recover). OPTIONAL when only
551
+ * `retry` is configured: retry backoff reads its time off the result / timer
552
+ * Msgs (`$resilience:err.at`, `$resilience:timer.atMs`), never the cold attempt
553
+ * — so a `0` cold `at` is harmless there. Pure: it runs inside the merged
554
+ * `update`, so it must NOT read the clock / RNG.
555
+ */
556
+ readonly at?: (msg: TM) => number;
557
+ }
558
+ /**
559
+ * The composed Model. The base machine's state nests under `base`; the wrapper
560
+ * owns the NAMED `$resilience` slice — resilient-call's `ResilientState` keyed
561
+ * by the per-call `key`, with `I = TC` (the original target base Cmd is the
562
+ * port input) and `R = unknown` (the base interpret handler's resolution — the
563
+ * wrapper never inspects it; it routes Ok/Err and delivers a Msg to the base).
564
+ * Plain data → round-trips through `JSON.parse(JSON.stringify(...))` iff the
565
+ * base state does.
566
+ */
567
+ interface ResilienceModel<S, TC extends Cmd> {
568
+ readonly base: S;
569
+ readonly $resilience: ResilientState<TC, unknown>;
570
+ }
571
+ /**
572
+ * The carrier Cmd the wrapper emits when the gate ADMITS a target base Cmd. It
573
+ * RETAGS the original base Cmd into `input` — the base Cmd is plain data, so no
574
+ * closure (invariant 3). The interpret handler unwraps `input` and runs it
575
+ * through the BASE interpret for that Cmd type. `key` indexes the resilient
576
+ * call this run belongs to.
577
+ */
578
+ declare function resilienceRunCmdDef<TC extends Cmd, TM>(): CmdDef<"$resilience:run", {
579
+ readonly key: string;
580
+ /** The ORIGINAL base Cmd, retagged — never swallowed. */
581
+ readonly input: TC;
582
+ }, void | TM, {
583
+ readonly [detail: string]: unknown;
584
+ readonly _tag: "deadline_exceeded";
585
+ } | {
586
+ readonly [detail: string]: unknown;
587
+ readonly _tag: "base_rejected";
588
+ }, unknown>;
589
+ type ResilienceRunCmd<TC extends Cmd> = CmdOf<ReturnType<typeof resilienceRunCmdDef<TC, unknown>>>;
590
+ /**
591
+ * The success Msg the `$resilience:run` handler dispatches back when the base
592
+ * interpret resolved OK. Routes to `succeed`, then `result` — the base
593
+ * handler's follow-up, when it is a Msg — is folded through the base reducer.
594
+ * `at` is stamped at the interpret boundary (the one permitted clock read).
595
+ */
596
+ type ResilienceOkMsg = {
597
+ readonly type: "$resilience:ok";
598
+ readonly key: string;
599
+ readonly result: unknown;
600
+ readonly at: number;
601
+ };
602
+ /**
603
+ * The error Msg the `$resilience:run` handler dispatches back when the base
604
+ * interpret threw / rejected. Routes to `fail` (trip the breaker, then back off
605
+ * or settle). `at` is stamped at the interpret boundary.
606
+ */
607
+ type ResilienceErrMsg = {
608
+ readonly type: "$resilience:err";
609
+ readonly key: string;
610
+ readonly error: unknown;
611
+ readonly at: number;
612
+ };
613
+ /**
614
+ * The retry / deadline timer Msg the `$resilience:timer` Sub dispatches when
615
+ * the wall clock crosses the armed instant. Routes to `onTimer`. `id` is the
616
+ * `$resilience:`-namespaced timer id; `atMs` is the fire instant (Msg data, the
617
+ * clock that drove it lives in the Sub).
618
+ */
619
+ type ResilienceTimerMsg = {
620
+ readonly type: "$resilience:timer";
621
+ readonly id: string;
622
+ readonly atMs: number;
623
+ };
624
+ /** Every Msg the wrapper adds to the base's Msg union. */
625
+ type ResilienceMsg = ResilienceOkMsg | ResilienceErrMsg | ResilienceTimerMsg;
626
+ /** Every Cmd the wrapper adds to the base's Cmd union. */
627
+ type ResilienceCmd<TC extends Cmd> = ResilienceRunCmd<TC>;
628
+ /** The Sub the wrapper adds — a deadline-style timer in the `$resilience` family. */
629
+ type ResilienceTimerSub = Sub<"$resilience:timer"> & {
630
+ readonly atMs: number;
631
+ };
632
+ /**
633
+ * Wrap `base` so its `config.target` Cmd is run through the resilient-call
634
+ * concern (cache → circuit → rate-limit → retry, deadline-capped). Returns a
635
+ * NEW `Machine` over the composed Model `{ base, $resilience }`, with the
636
+ * base's Msgs/Cmds/Subs/Ctx extended by the wrapper's own.
637
+ *
638
+ * @param base any `Machine<S, M, C, U, Ctx>`.
639
+ * @param config the resilience knob: `target`, the optional bricks, `keyOf`.
640
+ * @param rng injected backoff jitter source. Pass a fixed `() => 0.5` in
641
+ * tests to pin retry delays; defaults to `Math.random` (read only
642
+ * at the verb boundary, never inside the merged `update`).
643
+ */
644
+ declare function withResilience<S, M extends {
645
+ type: string;
646
+ }, C extends Cmd, U extends Sub, Ctx>(base: Machine<S, M, C, U, Ctx>, config: ResilienceConfig<C, M>, rng?: () => number): Machine<ResilienceModel<S, C>, M | ResilienceMsg, C | ResilienceCmd<C>, U | ResilienceTimerSub, Ctx>;
647
+
648
+ /**
649
+ * The datum handed to the sink. The default projector emits `{ seq, msgType }`;
650
+ * a custom `event` projector may return any extra fields. `at` is OPTIONAL and
651
+ * plain data — it is stamped at the interpret boundary by the `clock` port, not
652
+ * inside the (pure, clock-free) merged `update`. Every field is JSON-round-trip
653
+ * serializable so a recorded telemetry stream stays durable.
654
+ */
655
+ interface TelemetryEvent {
656
+ /** Monotonic event counter — equals `$telemetry.seq` after the transition. */
657
+ readonly seq: number;
658
+ /** The `Msg.type` discriminant that drove this transition. */
659
+ readonly msgType: string;
660
+ /**
661
+ * Wall-clock instant the event was emitted, ms since epoch. Absent until the
662
+ * interpret boundary stamps it (the `clock` port). Optional because the
663
+ * merged `update` is clock-free — a verb must never read `Date.now()`.
664
+ */
665
+ readonly at?: number;
666
+ }
667
+ /**
668
+ * The wrapper's Model slice. A monotonic event counter — minimal but real, so
669
+ * the named-slice mechanism is exercised for the richer-slice wrappers that
670
+ * follow. `seq` equals the number of base Msgs folded so far: after replaying
671
+ * `N` msgs, `$telemetry.seq === N`. Plain data → serializes into a `Store<S>`.
672
+ */
673
+ interface TelemetrySlice {
674
+ readonly seq: number;
675
+ }
676
+ /**
677
+ * The composed Model. The base machine's state is nested under `base`; the
678
+ * wrapper's state lives in the NAMED `$telemetry` slice — never hidden in a
679
+ * closure. Both fields are plain data, so the whole composed Model round-trips
680
+ * through `JSON.parse(JSON.stringify(...))` iff the base state does.
681
+ */
682
+ interface TelemetryModel<S> {
683
+ readonly base: S;
684
+ readonly $telemetry: TelemetrySlice;
685
+ }
686
+ /**
687
+ * The fire-and-forget Cmd the merged `update` appends after every base
688
+ * transition. It carries the projected `event` as plain data (invariant 3 —
689
+ * no closure). The interpret handler hands `event` to the sink and dispatches
690
+ * NOTHING back, so there is no feedback loop.
691
+ */
692
+ declare const telemetryEmit: CmdDef<"$telemetry:emit", {
693
+ event: TelemetryEvent;
694
+ }, void, never, TelemetryPorts>;
695
+ type TelemetryEmitCmd = CmdOf<typeof telemetryEmit>;
696
+ /**
697
+ * The side-effecting ports the wrapper adds to `Ctx`. The sink (PostHog / Sentry
698
+ * bridge) lives at the interpret boundary, never in a verb. `clock` is the
699
+ * optional wall-clock source used to stamp `event.at` at that same boundary —
700
+ * pass `Date.now` in production, a fixed `() => 1000` in tests; omit it to leave
701
+ * `at` unset.
702
+ */
703
+ interface TelemetryPorts {
704
+ /** The side-effecting sink. Fire-and-forget — its result is never awaited into a Msg. */
705
+ readonly telemetrySink: (event: TelemetryEvent) => void | Promise<void>;
706
+ /** Optional clock for stamping `event.at` at the interpret boundary. */
707
+ readonly clock?: () => number;
708
+ }
709
+ /**
710
+ * The telemetry knob. `event` is an OPTIONAL projector mapping
711
+ * `(msg, prev, next)` to a `TelemetryEvent`; omit it and the default emits
712
+ * `{ seq, msgType }` where `seq` is the post-transition counter. The projector
713
+ * runs INSIDE the pure merged `update`, so it must not read the clock — stamp
714
+ * `at` at the sink boundary via the `clock` port instead.
715
+ */
716
+ interface TelemetryConfig<S, M extends {
717
+ type: string;
718
+ }> {
719
+ readonly event?: (msg: M, prev: TelemetryModel<S>, next: TelemetryModel<S>) => TelemetryEvent;
720
+ }
721
+ /**
722
+ * Wrap `base` with observe-only telemetry. Returns a NEW `Machine` over the
723
+ * composed Model `{ base, $telemetry }`, with the base's Msgs/Cmds/Subs/Ctx
724
+ * extended by the wrapper's own.
725
+ *
726
+ * The composed machine:
727
+ * - `init` rehydrates the base (honoring the `[loaded, []]` contract) and
728
+ * seeds `$telemetry: { seq: 0 }`. Base init Cmds pass through unchanged.
729
+ * - `update` (Reducer form, keyed by every base `Msg.type`) runs the base
730
+ * reducer, increments `seq`, and appends a `$telemetry:emit` Cmd carrying
731
+ * the projected event. Base Cmds pass through UNCHANGED — the observe-only
732
+ * property.
733
+ * - `subscriptions` / `subscribe` are the base's, verbatim (no timers).
734
+ * - `interpret` is `{ ...base.interpret, "$telemetry:emit": sink-handler }`.
735
+ *
736
+ * @param base any `Machine<S, M, C, U, Ctx>`.
737
+ * @param config the telemetry knob (optional `event` projector).
738
+ */
739
+ declare function withTelemetry<S, M extends {
740
+ type: string;
741
+ }, 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>;
742
+
743
+ export { type AuthedCall, type AuthedCmd, type AuthedConfig, type AuthedPorts, type AuthedState, type DeadlineConfig, type DeadlineDecisionCmd, type DeadlineExceededMsg, type DeadlineModel, type DeadlineSlice, DeadlineSub, type DeadlineTimeoutSub, FailMsg, type ProgressPredicate, type RefreshTokenCmd, type ResilienceCmd, type ResilienceConfig, type ResilienceErrMsg, type ResilienceModel, type ResilienceMsg, type ResilienceOkMsg, type ResilienceRunCmd, type ResilienceTimerMsg, type ResilienceTimerSub, ResilientConfig, ResilientPorts, ResilientState, ResilientTimerMsg, RetryExhaustedError, type RetryToSuccessOptions, RunCmd, SucceedMsg, type TelemetryConfig, type TelemetryEmitCmd, type TelemetryEvent, type TelemetryModel, type TelemetryPorts, type TelemetrySlice, type Token, type TokenRefresh, type TokenRefreshConfig, type TokenRefreshFailedMsg, type TokenRefreshMsg, type TokenRefreshPorts, type TokenRefreshedMsg, type TokenState, type Unauthorized, type UnauthorizedError, createAuthedCall, createTokenRefresh, deadlineDecision, deadlineExceededMsg, initTokenRefresh, liftAuthed, refreshToken, refreshTokenCmd, resilienceRunCmdDef, retryToSuccess, telemetryEmit, tokenRefreshFailedMsg, tokenRefreshedMsg, withDeadline, withResilience, withTelemetry };