@demlik/tea 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/README.md +11 -9
  2. package/dist/agent/index.d.ts +638 -45
  3. package/dist/agent/index.js +9 -19
  4. package/dist/{chunk-RH5EFRVJ.js → chunk-22POWGFA.js} +31 -5
  5. package/dist/chunk-22POWGFA.js.map +1 -0
  6. package/dist/{chunk-DMYGQB4O.js → chunk-3B5X7SBB.js} +23 -6
  7. package/dist/chunk-3B5X7SBB.js.map +1 -0
  8. package/dist/chunk-66PY5WYF.js +1816 -0
  9. package/dist/chunk-66PY5WYF.js.map +1 -0
  10. package/dist/{chunk-25LBDCBC.js → chunk-6IQPODUF.js} +2 -2
  11. package/dist/{chunk-25LBDCBC.js.map → chunk-6IQPODUF.js.map} +1 -1
  12. package/dist/chunk-AYS5N6WY.js +505 -0
  13. package/dist/chunk-AYS5N6WY.js.map +1 -0
  14. package/dist/{chunk-EWJP3YYP.js → chunk-HWVW4AXC.js} +3 -3
  15. package/dist/chunk-HWVW4AXC.js.map +1 -0
  16. package/dist/{chunk-O4MVQTEJ.js → chunk-L3TND7LA.js} +20 -16
  17. package/dist/chunk-L3TND7LA.js.map +1 -0
  18. package/dist/{chunk-J6527VRQ.js → chunk-LFZUK6J2.js} +3 -3
  19. package/dist/chunk-LFZUK6J2.js.map +1 -0
  20. package/dist/{chunk-D736QUGF.js → chunk-MYXFNWAJ.js} +4 -5
  21. package/dist/chunk-MYXFNWAJ.js.map +1 -0
  22. package/dist/{chunk-K575PT4S.js → chunk-PR6TB3BL.js} +15 -4
  23. package/dist/chunk-PR6TB3BL.js.map +1 -0
  24. package/dist/{chunk-YUXP55T2.js → chunk-Q5CQTBFA.js} +57 -7
  25. package/dist/chunk-Q5CQTBFA.js.map +1 -0
  26. package/dist/{batch-window/index.js → chunk-QPEVCJ5Q.js} +4 -8
  27. package/dist/chunk-QPEVCJ5Q.js.map +1 -0
  28. package/dist/chunk-TCLBCERH.js +1480 -0
  29. package/dist/chunk-TCLBCERH.js.map +1 -0
  30. package/dist/{chunk-FV3Z5MBE.js → chunk-TXN2KFHF.js} +14 -4
  31. package/dist/chunk-TXN2KFHF.js.map +1 -0
  32. package/dist/{chunk-MUUROGIH.js → chunk-V46HSVCK.js} +62 -12
  33. package/dist/chunk-V46HSVCK.js.map +1 -0
  34. package/dist/{chunk-Q2UM7BXU.js → chunk-VBDU4JL6.js} +2 -2
  35. package/dist/chunk-VBDU4JL6.js.map +1 -0
  36. package/dist/{chunk-ZVJZ72HY.js → chunk-VTQI2NHP.js} +25 -11
  37. package/dist/chunk-VTQI2NHP.js.map +1 -0
  38. package/dist/{core-Co0LWkIA.d.ts → core-DnzqWy6u.d.ts} +72 -23
  39. package/dist/devtools/index.d.ts +2 -2
  40. package/dist/devtools/index.js +207 -2
  41. package/dist/devtools/index.js.map +1 -1
  42. package/dist/do/index.d.ts +43 -29
  43. package/dist/do/index.js +36 -25
  44. package/dist/do/index.js.map +1 -1
  45. package/dist/{durable-effects-C6uwzjb5.d.ts → durable-effects-CWzA-o2B.d.ts} +2 -2
  46. package/dist/extension/index.d.ts +300 -3
  47. package/dist/extension/index.js +596 -5
  48. package/dist/extension/index.js.map +1 -1
  49. package/dist/flow/index.d.ts +1284 -0
  50. package/dist/flow/index.js +732 -0
  51. package/dist/flow/index.js.map +1 -0
  52. package/dist/idempotency/index.d.ts +90 -116
  53. package/dist/idempotency/index.js +4 -1
  54. package/dist/index-Bc40JWVl.d.ts +131 -0
  55. package/dist/{batch-window/index.d.ts → index-C2DwkjlP.d.ts} +7 -12
  56. package/dist/index-CA_7I5g9.d.ts +806 -0
  57. package/dist/index-CSyMYDAB.d.ts +69 -0
  58. package/dist/{fan-out/index.d.ts → index-CuNO9m8i.d.ts} +7 -9
  59. package/dist/{debounce/index.d.ts → index-DHSUmQTR.d.ts} +7 -7
  60. package/dist/{recorder/index.d.ts → index-DrIRb_Ch.d.ts} +4 -7
  61. package/dist/index-HSYgG2Yt.d.ts +380 -0
  62. package/dist/{monitored-run/index.d.ts → index-KXqTRJyb.d.ts} +37 -13
  63. package/dist/{snapshot/index.d.ts → index-ZCMhnVKN.d.ts} +15 -78
  64. package/dist/index.d.ts +771 -6
  65. package/dist/index.js +1 -2
  66. package/dist/jev/index.d.ts +646 -0
  67. package/dist/jev/index.js +485 -0
  68. package/dist/jev/index.js.map +1 -0
  69. package/dist/machine-DGlPWCWI.d.ts +1781 -0
  70. package/dist/machine-viz/index.d.ts +1 -1
  71. package/dist/machine-viz/index.js +12 -5
  72. package/dist/machine-viz/index.js.map +1 -1
  73. package/dist/mem/index.d.ts +18 -3
  74. package/dist/mem/index.js +22 -2
  75. package/dist/mem/index.js.map +1 -1
  76. package/dist/node/index.d.ts +104 -6
  77. package/dist/node/index.js +132 -9
  78. package/dist/node/index.js.map +1 -1
  79. package/dist/{paginator → paginate}/index.d.ts +140 -6
  80. package/dist/paginate/index.js +7 -0
  81. package/dist/parity/index.d.ts +4 -10
  82. package/dist/parity/index.js +4 -7
  83. package/dist/parity/index.js.map +1 -1
  84. package/dist/pbt/index.d.ts +247 -5
  85. package/dist/pbt/index.js +124 -5
  86. package/dist/pbt/index.js.map +1 -1
  87. package/dist/{trace-replay → persistence}/index.d.ts +7 -5
  88. package/dist/persistence/index.js +6 -0
  89. package/dist/{protocol-B5YmJr0d.d.ts → protocol-D8VbH-VH.d.ts} +10 -1
  90. package/dist/react/index.d.ts +2 -2
  91. package/dist/react/index.js +1 -2
  92. package/dist/react/index.js.map +1 -1
  93. package/dist/resilience/index.d.ts +744 -0
  94. package/dist/resilience/index.js +657 -0
  95. package/dist/resilience/index.js.map +1 -0
  96. package/dist/retry-backoff/index.d.ts +3 -2
  97. package/dist/retry-backoff/index.js +1 -1
  98. package/dist/runtime-types-CMF13BBh.d.ts +998 -0
  99. package/dist/testing/index.d.ts +147 -3
  100. package/dist/testing/index.js +95 -3
  101. package/dist/testing/index.js.map +1 -1
  102. package/dist/{throttled-input → timing}/index.d.ts +143 -12
  103. package/dist/{throttled-input → timing}/index.js +57 -12
  104. package/dist/timing/index.js.map +1 -0
  105. package/dist/{types-XS_miRnB.d.ts → types-BseNPIhr.d.ts} +1 -1
  106. package/dist/work-queue/index.d.ts +130 -54
  107. package/dist/work-queue/index.js +3 -2
  108. package/dist/work-queue/index.js.map +1 -1
  109. package/package.json +45 -218
  110. package/dist/authed-call/index.d.ts +0 -120
  111. package/dist/authed-call/index.js +0 -134
  112. package/dist/authed-call/index.js.map +0 -1
  113. package/dist/await-terminal/index.d.ts +0 -101
  114. package/dist/await-terminal/index.js +0 -76
  115. package/dist/await-terminal/index.js.map +0 -1
  116. package/dist/batch-window/index.js.map +0 -1
  117. package/dist/cache/index.d.ts +0 -152
  118. package/dist/cache/index.js +0 -8
  119. package/dist/chart/index.d.ts +0 -218
  120. package/dist/chart/index.js +0 -16
  121. package/dist/chart/index.js.map +0 -1
  122. package/dist/chart/inspect/index.d.ts +0 -86
  123. package/dist/chart/inspect/index.js +0 -5
  124. package/dist/chart/inspect/react.d.ts +0 -113
  125. package/dist/chart/inspect/react.js +0 -11
  126. package/dist/chart/inspect/react.js.map +0 -1
  127. package/dist/chart/inspect/styles.css +0 -286
  128. package/dist/chart/lane/index.d.ts +0 -362
  129. package/dist/chart/lane/index.js +0 -9
  130. package/dist/chart/lane/index.js.map +0 -1
  131. package/dist/chart/lane/react.d.ts +0 -84
  132. package/dist/chart/lane/react.js +0 -559
  133. package/dist/chart/lane/react.js.map +0 -1
  134. package/dist/chart/lane/server.d.ts +0 -148
  135. package/dist/chart/lane/server.js +0 -209
  136. package/dist/chart/lane/server.js.map +0 -1
  137. package/dist/chart/lane/styles.css +0 -498
  138. package/dist/chart/lane/viewer/assets/abnfDiagram-N423BO3Z-C729LI31.js +0 -1
  139. package/dist/chart/lane/viewer/assets/architectureDiagram-T3A2C74G-C729LI31.js +0 -1
  140. package/dist/chart/lane/viewer/assets/blockDiagram-VBNYF7ZC-C729LI31.js +0 -1
  141. package/dist/chart/lane/viewer/assets/c4Diagram-5PPSVZJV-C729LI31.js +0 -1
  142. package/dist/chart/lane/viewer/assets/chunk-2GRJ4B5K-HdDf8SI3.js +0 -1
  143. package/dist/chart/lane/viewer/assets/chunk-5RXB4S5H-CcNtpUd7.js +0 -231
  144. package/dist/chart/lane/viewer/assets/chunk-5VM5RSS4-BP4fRS_5.js +0 -15
  145. package/dist/chart/lane/viewer/assets/chunk-KBJHAD2P-DZOw7xU6.js +0 -1
  146. package/dist/chart/lane/viewer/assets/chunk-NSK5VX7P-CBCyTZMs.js +0 -128
  147. package/dist/chart/lane/viewer/assets/classDiagram-JCYQIIEL-C729LI31.js +0 -1
  148. package/dist/chart/lane/viewer/assets/classDiagram-v2-OCEON4UE-D4uAiFr8.js +0 -206
  149. package/dist/chart/lane/viewer/assets/cose-bilkent-JH36ORCC-DOwCrGXH.js +0 -1
  150. package/dist/chart/lane/viewer/assets/cynefinDiagram-MW4NZA55-C729LI31.js +0 -1
  151. package/dist/chart/lane/viewer/assets/dagre-K_PewWfS.js +0 -1
  152. package/dist/chart/lane/viewer/assets/dagre-VZM6K2ZE-831qZcA8.js +0 -4
  153. package/dist/chart/lane/viewer/assets/diagram-7IWD3JNH-C729LI31.js +0 -1
  154. package/dist/chart/lane/viewer/assets/diagram-B4RE2ZJO-C729LI31.js +0 -1
  155. package/dist/chart/lane/viewer/assets/diagram-LBJQPF4R-C729LI31.js +0 -1
  156. package/dist/chart/lane/viewer/assets/diagram-Q27KOJAE-C729LI31.js +0 -1
  157. package/dist/chart/lane/viewer/assets/diagram-UB23O5K3-C729LI31.js +0 -1
  158. package/dist/chart/lane/viewer/assets/ebnfDiagram-BXEA7PRR-C729LI31.js +0 -1
  159. package/dist/chart/lane/viewer/assets/erDiagram-JOGREHBK-C729LI31.js +0 -1
  160. package/dist/chart/lane/viewer/assets/flowDiagram-UKHOOZJN-C729LI31.js +0 -1
  161. package/dist/chart/lane/viewer/assets/ganttDiagram-PKOTCBZU-C729LI31.js +0 -1
  162. package/dist/chart/lane/viewer/assets/gitGraphDiagram-DS77QQ5N-C729LI31.js +0 -1
  163. package/dist/chart/lane/viewer/assets/index-9SkH5NA3.css +0 -1
  164. package/dist/chart/lane/viewer/assets/index-Bgt4sXpW.js +0 -195
  165. package/dist/chart/lane/viewer/assets/infoDiagram-6WML65LV-C729LI31.js +0 -1
  166. package/dist/chart/lane/viewer/assets/ishikawaDiagram-WSZJBQD7-C729LI31.js +0 -1
  167. package/dist/chart/lane/viewer/assets/journeyDiagram-NVQOT4AX-C729LI31.js +0 -1
  168. package/dist/chart/lane/viewer/assets/kanban-definition-27J2QSJJ-G7PaPzy-.js +0 -89
  169. package/dist/chart/lane/viewer/assets/katex-DOwCrGXH.js +0 -1
  170. package/dist/chart/lane/viewer/assets/mindmap-definition-FAOFIHXS-CGj9nrVk.js +0 -96
  171. package/dist/chart/lane/viewer/assets/path-fybaL0A-.js +0 -1
  172. package/dist/chart/lane/viewer/assets/pegDiagram-VL7TDLO6-C729LI31.js +0 -1
  173. package/dist/chart/lane/viewer/assets/pieDiagram-7S7Q4E2Y-C729LI31.js +0 -1
  174. package/dist/chart/lane/viewer/assets/quadrantDiagram-CIZ2JOQS-C729LI31.js +0 -1
  175. package/dist/chart/lane/viewer/assets/railroadDiagram-AXF67PYL-C729LI31.js +0 -1
  176. package/dist/chart/lane/viewer/assets/requirementDiagram-LRYGKXZP-C729LI31.js +0 -1
  177. package/dist/chart/lane/viewer/assets/sankeyDiagram-W5VNT64P-C729LI31.js +0 -1
  178. package/dist/chart/lane/viewer/assets/sequenceDiagram-SI44F4Z6-C729LI31.js +0 -1
  179. package/dist/chart/lane/viewer/assets/stateDiagram-OKZ733FA-B_88AzBS.js +0 -1
  180. package/dist/chart/lane/viewer/assets/stateDiagram-v2-UEYNNEHI-CR5gcgq6.js +0 -1
  181. package/dist/chart/lane/viewer/assets/swimlanes-SLNWSIFB-B4xK-rwg.js +0 -1
  182. package/dist/chart/lane/viewer/assets/swimlanesDiagram-ULZ7WXOC-C729LI31.js +0 -1
  183. package/dist/chart/lane/viewer/assets/timeline-definition-Z64GVDOM-CCv52MfY.js +0 -120
  184. package/dist/chart/lane/viewer/assets/vennDiagram-T6HMQDX7-C729LI31.js +0 -1
  185. package/dist/chart/lane/viewer/assets/wardleyDiagram-T6FBY63Y-C729LI31.js +0 -1
  186. package/dist/chart/lane/viewer/assets/xychartDiagram-ELKLHX3M-C729LI31.js +0 -1
  187. package/dist/chart/lane/viewer/index.html +0 -15
  188. package/dist/chart/report/index.d.ts +0 -117
  189. package/dist/chart/report/index.js +0 -32
  190. package/dist/chart/report/index.js.map +0 -1
  191. package/dist/chunk-2YFLOCWX.js +0 -15
  192. package/dist/chunk-2YFLOCWX.js.map +0 -1
  193. package/dist/chunk-3I52QZZ5.js +0 -519
  194. package/dist/chunk-3I52QZZ5.js.map +0 -1
  195. package/dist/chunk-3ZAFFRRB.js +0 -457
  196. package/dist/chunk-3ZAFFRRB.js.map +0 -1
  197. package/dist/chunk-4EQZ76JC.js +0 -33
  198. package/dist/chunk-4EQZ76JC.js.map +0 -1
  199. package/dist/chunk-4KLG43GY.js +0 -223
  200. package/dist/chunk-4KLG43GY.js.map +0 -1
  201. package/dist/chunk-7FRZ2CT2.js +0 -424
  202. package/dist/chunk-7FRZ2CT2.js.map +0 -1
  203. package/dist/chunk-AZZLE7XR.js +0 -62
  204. package/dist/chunk-AZZLE7XR.js.map +0 -1
  205. package/dist/chunk-BYQUGDD3.js +0 -16
  206. package/dist/chunk-BYQUGDD3.js.map +0 -1
  207. package/dist/chunk-CIQG5L42.js +0 -685
  208. package/dist/chunk-CIQG5L42.js.map +0 -1
  209. package/dist/chunk-CLM6ERNO.js +0 -61
  210. package/dist/chunk-CLM6ERNO.js.map +0 -1
  211. package/dist/chunk-COS5MSTO.js +0 -88
  212. package/dist/chunk-COS5MSTO.js.map +0 -1
  213. package/dist/chunk-CRPZJVD2.js +0 -71
  214. package/dist/chunk-CRPZJVD2.js.map +0 -1
  215. package/dist/chunk-D62FDQKE.js +0 -53
  216. package/dist/chunk-D62FDQKE.js.map +0 -1
  217. package/dist/chunk-D736QUGF.js.map +0 -1
  218. package/dist/chunk-DGE4PV4A.js +0 -26
  219. package/dist/chunk-DGE4PV4A.js.map +0 -1
  220. package/dist/chunk-DMYGQB4O.js.map +0 -1
  221. package/dist/chunk-EWJP3YYP.js.map +0 -1
  222. package/dist/chunk-FV3Z5MBE.js.map +0 -1
  223. package/dist/chunk-HCEVHFJ7.js +0 -54
  224. package/dist/chunk-HCEVHFJ7.js.map +0 -1
  225. package/dist/chunk-J6527VRQ.js.map +0 -1
  226. package/dist/chunk-JELSZN25.js +0 -47
  227. package/dist/chunk-JELSZN25.js.map +0 -1
  228. package/dist/chunk-K575PT4S.js.map +0 -1
  229. package/dist/chunk-L57ZOT5K.js +0 -184
  230. package/dist/chunk-L57ZOT5K.js.map +0 -1
  231. package/dist/chunk-MU6MCIAC.js +0 -15
  232. package/dist/chunk-MU6MCIAC.js.map +0 -1
  233. package/dist/chunk-MUUROGIH.js.map +0 -1
  234. package/dist/chunk-NR7BU22N.js +0 -758
  235. package/dist/chunk-NR7BU22N.js.map +0 -1
  236. package/dist/chunk-O4MVQTEJ.js.map +0 -1
  237. package/dist/chunk-OOYD44JI.js +0 -317
  238. package/dist/chunk-OOYD44JI.js.map +0 -1
  239. package/dist/chunk-Q2UM7BXU.js.map +0 -1
  240. package/dist/chunk-RH5EFRVJ.js.map +0 -1
  241. package/dist/chunk-S2EGRPCM.js +0 -47
  242. package/dist/chunk-S2EGRPCM.js.map +0 -1
  243. package/dist/chunk-SINXE47Y.js +0 -55
  244. package/dist/chunk-SINXE47Y.js.map +0 -1
  245. package/dist/chunk-UF4MZSLT.js +0 -53
  246. package/dist/chunk-UF4MZSLT.js.map +0 -1
  247. package/dist/chunk-UOC2PL46.js +0 -13
  248. package/dist/chunk-UOC2PL46.js.map +0 -1
  249. package/dist/chunk-VYFAZN3F.js +0 -372
  250. package/dist/chunk-VYFAZN3F.js.map +0 -1
  251. package/dist/chunk-WRAA7GVZ.js +0 -209
  252. package/dist/chunk-WRAA7GVZ.js.map +0 -1
  253. package/dist/chunk-XGELA764.js +0 -163
  254. package/dist/chunk-XGELA764.js.map +0 -1
  255. package/dist/chunk-YUXP55T2.js.map +0 -1
  256. package/dist/chunk-YWIKDKHY.js +0 -307
  257. package/dist/chunk-YWIKDKHY.js.map +0 -1
  258. package/dist/chunk-ZJ5AOYBH.js +0 -8
  259. package/dist/chunk-ZJ5AOYBH.js.map +0 -1
  260. package/dist/chunk-ZSUUOEPL.js +0 -731
  261. package/dist/chunk-ZSUUOEPL.js.map +0 -1
  262. package/dist/chunk-ZVJZ72HY.js.map +0 -1
  263. package/dist/circuit-breaker/index.d.ts +0 -197
  264. package/dist/circuit-breaker/index.js +0 -3
  265. package/dist/circuit-breaker/index.js.map +0 -1
  266. package/dist/deadline/index.d.ts +0 -199
  267. package/dist/deadline/index.js +0 -6
  268. package/dist/deadline/index.js.map +0 -1
  269. package/dist/debounce/index.js +0 -3
  270. package/dist/debounce/index.js.map +0 -1
  271. package/dist/extension/react.d.ts +0 -121
  272. package/dist/extension/react.js +0 -75
  273. package/dist/extension/react.js.map +0 -1
  274. package/dist/extension/subs/index.d.ts +0 -45
  275. package/dist/extension/subs/index.js +0 -80
  276. package/dist/extension/subs/index.js.map +0 -1
  277. package/dist/extension/test-utils.d.ts +0 -128
  278. package/dist/extension/test-utils.js +0 -277
  279. package/dist/extension/test-utils.js.map +0 -1
  280. package/dist/fan-out/index.js +0 -5
  281. package/dist/fan-out/index.js.map +0 -1
  282. package/dist/fold-BJPdjc9w.d.ts +0 -435
  283. package/dist/graph-B3L5e0N1.d.ts +0 -923
  284. package/dist/idempotency/adapter.d.ts +0 -62
  285. package/dist/idempotency/adapter.js +0 -4
  286. package/dist/idempotency/adapter.js.map +0 -1
  287. package/dist/idempotent-intake/index.d.ts +0 -188
  288. package/dist/idempotent-intake/index.js +0 -7
  289. package/dist/idempotent-intake/index.js.map +0 -1
  290. package/dist/journal/index.d.ts +0 -373
  291. package/dist/journal/index.js +0 -3
  292. package/dist/journal/index.js.map +0 -1
  293. package/dist/llm-call/index.d.ts +0 -311
  294. package/dist/llm-call/index.js +0 -16
  295. package/dist/llm-call/index.js.map +0 -1
  296. package/dist/machine-BtFWQmmq.d.ts +0 -804
  297. package/dist/monitored-run/index.js +0 -10
  298. package/dist/monitored-run/index.js.map +0 -1
  299. package/dist/paginated-walk/index.d.ts +0 -235
  300. package/dist/paginated-walk/index.js +0 -16
  301. package/dist/paginated-walk/index.js.map +0 -1
  302. package/dist/paginator/index.js +0 -3
  303. package/dist/paginator/index.js.map +0 -1
  304. package/dist/pbt/arbitraries/index.d.ts +0 -136
  305. package/dist/pbt/arbitraries/index.js +0 -3
  306. package/dist/pbt/arbitraries/index.js.map +0 -1
  307. package/dist/pbt/runners/index.d.ts +0 -118
  308. package/dist/pbt/runners/index.js +0 -5
  309. package/dist/pbt/runners/index.js.map +0 -1
  310. package/dist/poller/index.d.ts +0 -352
  311. package/dist/poller/index.js +0 -115
  312. package/dist/poller/index.js.map +0 -1
  313. package/dist/prediction/index.d.ts +0 -131
  314. package/dist/prediction/index.js +0 -4
  315. package/dist/prediction/index.js.map +0 -1
  316. package/dist/pure/index.d.ts +0 -3
  317. package/dist/pure/index.js +0 -4
  318. package/dist/pure/index.js.map +0 -1
  319. package/dist/rate-limit/index.d.ts +0 -115
  320. package/dist/rate-limit/index.js +0 -3
  321. package/dist/rate-limit/index.js.map +0 -1
  322. package/dist/reconciler/index.d.ts +0 -193
  323. package/dist/reconciler/index.js +0 -164
  324. package/dist/reconciler/index.js.map +0 -1
  325. package/dist/recorder/index.js +0 -3
  326. package/dist/recorder/index.js.map +0 -1
  327. package/dist/reducer-4GNR6b8B.d.ts +0 -447
  328. package/dist/resilient-call/index.d.ts +0 -320
  329. package/dist/resilient-call/index.js +0 -14
  330. package/dist/resilient-call/index.js.map +0 -1
  331. package/dist/retry-to-success/index.d.ts +0 -109
  332. package/dist/retry-to-success/index.js +0 -37
  333. package/dist/retry-to-success/index.js.map +0 -1
  334. package/dist/run-pAcmBpah.d.ts +0 -713
  335. package/dist/runtime-types-CNLmhWif.d.ts +0 -517
  336. package/dist/saga/index.d.ts +0 -241
  337. package/dist/saga/index.js +0 -150
  338. package/dist/saga/index.js.map +0 -1
  339. package/dist/samples-B3My5oh2.d.ts +0 -59
  340. package/dist/snapshot/index.js +0 -5
  341. package/dist/snapshot/index.js.map +0 -1
  342. package/dist/subs/index.d.ts +0 -472
  343. package/dist/subs/index.js +0 -7
  344. package/dist/subs/index.js.map +0 -1
  345. package/dist/throttle/index.d.ts +0 -134
  346. package/dist/throttle/index.js +0 -3
  347. package/dist/throttle/index.js.map +0 -1
  348. package/dist/throttled-input/index.js.map +0 -1
  349. package/dist/token-refresh/index.d.ts +0 -216
  350. package/dist/token-refresh/index.js +0 -6
  351. package/dist/token-refresh/index.js.map +0 -1
  352. package/dist/trace-replay/index.js +0 -6
  353. package/dist/trace-replay/index.js.map +0 -1
  354. package/dist/with-deadline/index.d.ts +0 -197
  355. package/dist/with-deadline/index.js +0 -111
  356. package/dist/with-deadline/index.js.map +0 -1
  357. package/dist/with-resilience/index.d.ts +0 -225
  358. package/dist/with-resilience/index.js +0 -240
  359. package/dist/with-resilience/index.js.map +0 -1
  360. package/dist/with-telemetry/index.d.ts +0 -150
  361. package/dist/with-telemetry/index.js +0 -70
  362. package/dist/with-telemetry/index.js.map +0 -1
  363. package/dist/work-queue/adapter.d.ts +0 -84
  364. package/dist/work-queue/adapter.js +0 -4
  365. package/dist/work-queue/adapter.js.map +0 -1
  366. package/dist/work-queue/ops.d.ts +0 -71
  367. package/dist/work-queue/ops.js +0 -3
  368. package/dist/work-queue/ops.js.map +0 -1
  369. package/dist/workflow/index.d.ts +0 -485
  370. package/dist/workflow/index.js +0 -244
  371. package/dist/workflow/index.js.map +0 -1
  372. /package/dist/{cache → paginate}/index.js.map +0 -0
  373. /package/dist/{chart/inspect → persistence}/index.js.map +0 -0
@@ -1,320 +0,0 @@
1
- import { TtlCache } from '../cache/index.js';
2
- import { CircuitState } from '../circuit-breaker/index.js';
3
- import { DeadlineExceeded, DeadlineSub } from '../deadline/index.js';
4
- export { deadlineSub, subscribeDeadline } from '../deadline/index.js';
5
- import { C as Cmd } from '../core-Co0LWkIA.js';
6
- import { M as MsgType } from '../protocol-B5YmJr0d.js';
7
- import { TokenBucket } from '../rate-limit/index.js';
8
- import { RetryState, AnyRetryPolicy } from '../retry-backoff/index.js';
9
- import '../types-XS_miRnB.js';
10
- import 'zod';
11
-
12
- /**
13
- * @packageDocumentation
14
- *
15
- * @deprecated `@demlik/tea/resilient-call` is deprecated in favor of
16
- * `@demlik/tea/with-resilience` — the higher-order `withResilience(base,
17
- * config)` wrapper (TEA-idiomatic: it wraps any existing machine instead of
18
- * forcing a bespoke embedded slice; epic consolidation verdict, survivor
19
- * `with-resilience`). The APIs are NOT drop-in; migration map:
20
- *
21
- * - `createResilientCall(config, rng)` + hand-wiring `init` / the verbs /
22
- * `subs` / `handlers` into your machine → `withResilience(base, { target,
23
- * ...bricks }, rng)`. Nothing is wired by hand anymore: the wrapper
24
- * intercepts the `target` base Cmd and routes it through the gate.
25
- * - `ResilientConfig` bricks (`retry` / `circuit` / `rateLimit` / `cache` /
26
- * `deadline`) → unchanged; `ResilienceConfig` extends the same knob and
27
- * adds `target` (required), `keyOf?` (per-call key — was `attempt`'s `key`
28
- * argument), and `at?` (time-as-data reader — REQUIRED with any
29
- * time-sensitive brick; `withResilience` throws at construction without it).
30
- * - The slice at your chosen Model field + `liftResilience` → the wrapper
31
- * owns `model.$resilience`; there is nothing to lift.
32
- * - Verbs `attempt` / `succeed` / `fail` / `onTimer` → internal to the
33
- * wrapper; results route as `$resilience:ok` / `$resilience:err` /
34
- * `$resilience:timer` Msgs through the merged `update` (the old
35
- * `resilient_run` / `resilient_ok` / `resilient_err` vocabulary is renamed
36
- * into the `$resilience:` namespace).
37
- * - `settleFailed` → NO equivalent. It exists for embedded-slice consumers
38
- * (`authed-call`, `paginated-walk`) that settle a call without touching the
39
- * breaker; the wrapper exposes no caller-facing settle verb.
40
- * - `handlers(ports)` / `subs(state)` / the `subscribeDeadline` re-export →
41
- * handled by the wrapper; run the returned machine like any other.
42
- *
43
- * Removal window ("deprecate, don't delete"): the `./resilient-call` subpath
44
- * export survives one minor release after this deprecation ships, then is
45
- * removed. Internal sibling modules (`with-resilience` itself, `agent`,
46
- * `llm-call`, `authed-call`, `reconciler`, `paginated-walk`) intentionally keep
47
- * importing `../resilient-call` — the deprecation targets the PUBLISHED export,
48
- * not the module's internal role.
49
- *
50
- * @demlik/tea/resilient-call — the ROOT composition: a single resilience knob
51
- * that bundles cache → circuit-breaker → rate-limit → exponential-backoff retry
52
- * (with a deadline-driven retry timer) around any fallible `(input) => Promise`
53
- * port.
54
- *
55
- * This is `examples/resilient-fetch.ts`'s hand-wired `attempt()` generalized:
56
- *
57
- * - It is **keyed**. The example tracked one URL at a time; this tracks N
58
- * concurrent logical calls, each under a string `key`. The cache, the
59
- * waiting-retry bookkeeping, and the retry timers are all per-key, while the
60
- * circuit breaker and token bucket are shared (one downstream target, one
61
- * breaker / one bucket — the example's implicit single-target assumption
62
- * made explicit).
63
- * - It is **config-driven**, not hand-wired. You hand `createResilientCall`
64
- * a `ResilientConfig` and get back the uniform knob contract every L2
65
- * composition exposes: `init()`, the four verbs (`attempt` / `succeed` /
66
- * `fail` / `onTimer`), `subs(state)`, and `handlers(ports)`.
67
- * - Every brick is **optional**. Omit `cache` and the cache gate disappears
68
- * (`get` is never consulted); omit `circuit` and every call passes the
69
- * breaker; omit `rateLimit` and the bucket never throttles; omit `retry`
70
- * and a failure is terminal (no backoff, no timer); omit `deadline` and no
71
- * overall wall-clock cap is armed. "Omit a brick → omit its gate" is the
72
- * whole config story — there are no other modes.
73
- *
74
- * Four later compositions (`llm-call`, `paginated-walk`, `authed-call`,
75
- * `reconciler`) inherit THIS slice + verb shape, so the contract here is
76
- * load-bearing: the slice is a flat record of brick states, every verb returns
77
- * `readonly [State, Cmd[]]`, time is always an `at` / `now` parameter, and the
78
- * RNG used for jitter is injected on the config (never read inside a verb).
79
- *
80
- * ## The two non-negotiables (canon)
81
- *
82
- * - **Durable** — the slice is a plain-data Model field (brick states are all
83
- * JSON-serializable), so it survives DO eviction / reload.
84
- * - **Replayable** — every transition is a verb returning new state + Cmds;
85
- * `replay` reconstructs it exactly. Nothing here closes over time or RNG.
86
- *
87
- * ## Where the clock / RNG live
88
- *
89
- * Inside the verbs: nowhere. Time arrives as `at` on `attempt` / `onTimer` and
90
- * is carried on the result / timer Msgs the consumer dispatches. Jitter RNG is
91
- * injected once at `createResilientCall(config, rng)` and threaded into
92
- * `nextDelayMs` at the verb boundary — deterministic in tests, `Math.random`
93
- * by default. The ONLY clock read is `Date.now()` inside the `handlers` port
94
- * (the effect boundary), exactly as `resilient-fetch.ts` stamps its result Msgs.
95
- *
96
- * That same `at` is what makes a DURATION-bounded retry budget reachable here:
97
- * `recordFailure` / `shouldRetry` are fed the failure's observation instant,
98
- * so `config.retry` accepts any `AnyRetryPolicy` — a count, a wall-clock outage
99
- * budget (`maxElapsedMs`), or explicit `unbounded: true` — with no new argument
100
- * on any verb and no clock read inside one.
101
- *
102
- * ## Typical wiring
103
- *
104
- * const rc = createResilientCall<string, Result>({
105
- * cache: { ttlMs: 60_000 },
106
- * circuit: { threshold: 5, cooldownMs: 30_000 },
107
- * rateLimit: { capacity: 10, refillPerSec: 5 },
108
- * retry: defaultRetryPolicy,
109
- * deadline: { ms: 5_000 },
110
- * });
111
- *
112
- * // in the machine:
113
- * init: () => [{ resilience: rc.init() }, []],
114
- * update: {
115
- * fetch: (s, m) => lift(s, rc.attempt(s.resilience, m.key, m.input, m.at)),
116
- * call_ok: (s, m) => lift(s, rc.succeed(s.resilience, m.key, m)),
117
- * call_err:(s, m) => lift(s, rc.fail(s.resilience, m.key, m)),
118
- * retry_due:(s, m) => lift(s, rc.onTimer(s.resilience, m)),
119
- * },
120
- * subscriptions: (s) => rc.subs(s.resilience),
121
- * subscribe: { deadline: subscribeDeadline },
122
- * interpret: rc.handlers({ run: ctx.call }),
123
- */
124
-
125
- /** Circuit-breaker knob — only the two numbers a consumer ever tunes. */
126
- interface CircuitConfig {
127
- /** Consecutive failures that trip the breaker open. */
128
- readonly threshold: number;
129
- /** How long the breaker stays open before admitting a probe, in ms. */
130
- readonly cooldownMs: number;
131
- /**
132
- * Probes admitted in `half_open` before fast-failing the rest of the round.
133
- * Defaults to 1 (a single probe decides recovery) — matches the circuit-
134
- * breaker module's `defaultCircuitPolicy`.
135
- */
136
- readonly halfOpenMaxProbes?: number;
137
- }
138
- /** Token-bucket rate-limit knob. */
139
- interface RateLimitConfig {
140
- /** Burst size — the bucket starts full at `capacity`. */
141
- readonly capacity: number;
142
- /** Steady-state refill rate, tokens per second. */
143
- readonly refillPerSec: number;
144
- }
145
- /** Per-entry TTL cache knob. */
146
- interface CacheConfig {
147
- /** How long a cached success stays fresh, in ms. */
148
- readonly ttlMs: number;
149
- }
150
- /** Overall wall-clock deadline knob — an absolute cap per in-flight call. */
151
- interface DeadlineConfig {
152
- /** Budget from the moment a call starts, in ms. */
153
- readonly ms: number;
154
- }
155
- /**
156
- * The resilience knob. EVERY field is optional: omit a brick and its gate is
157
- * skipped entirely (the slice still carries a default brick state so the shape
158
- * stays uniform across configs, but the gate is never consulted). An empty
159
- * config `{}` is a valid pass-through — a bare effect with no resilience at all.
160
- */
161
- interface ResilientConfig {
162
- /**
163
- * The backoff brick. Omit and a failure is terminal (no backoff, no timer).
164
- *
165
- * Any bound the `../retry-backoff` union admits: a count (`RetryPolicy`), a
166
- * wall-clock outage budget (`DurationRetryPolicy`), or explicit
167
- * `unbounded: true`. A duration bound needs no extra wiring: every path that
168
- * records a failure already holds the instant it was observed as DATA —
169
- * `fail`'s `msg.at` (stamped at the interpret boundary) and `gate`'s `at`
170
- * (the caller's `attempt` / the retry timer's `atMs`) — so the streak clock
171
- * is fed from a Msg, never from a `Date.now()` inside a verb (invariant 2).
172
- */
173
- readonly retry?: AnyRetryPolicy;
174
- readonly circuit?: CircuitConfig;
175
- readonly rateLimit?: RateLimitConfig;
176
- readonly cache?: CacheConfig;
177
- readonly deadline?: DeadlineConfig;
178
- }
179
- /**
180
- * Per-key call phase. `key` indexes a logical call; several can be in flight at
181
- * once (the generalization of the example's single `url`). Discriminated on
182
- * `phase` so each phase carries only its own data (pattern 11):
183
- *
184
- * - `idle` — never attempted, or fully settled and forgotten.
185
- * - `running` — the effect Cmd is out; awaiting `succeed` / `fail`.
186
- * Carries `deadlineAtMs` (absolute cap, `0` if no deadline
187
- * brick) and the last `input` so a retry can re-issue it.
188
- * - `waiting_retry` — a transient failure backed off; the retry timer is armed
189
- * for `retryAtMs`. Carries `input` for the re-attempt.
190
- * - `circuit_open` — the breaker fast-failed this attempt. Terminal for this
191
- * call until the consumer re-attempts after cooldown.
192
- * - `succeeded` — settled OK. `result` is the value the port produced.
193
- * - `failed` — settled Err (out of retries, or no retry brick). `error`
194
- * carries the last failure.
195
- */
196
- type CallPhase<I, R> = {
197
- readonly phase: "idle";
198
- } | {
199
- readonly phase: "running";
200
- readonly input: I;
201
- readonly deadlineAtMs: number;
202
- } | {
203
- readonly phase: "waiting_retry";
204
- readonly input: I;
205
- readonly retryAtMs: number;
206
- readonly deadlineAtMs: number;
207
- } | {
208
- readonly phase: "circuit_open";
209
- } | {
210
- readonly phase: "succeeded";
211
- readonly result: R;
212
- } | {
213
- readonly phase: "failed";
214
- readonly error: unknown;
215
- };
216
- /**
217
- * The slice. `circuit` / `bucket` are SHARED across keys (one downstream target
218
- * → one breaker, one bucket). `retry` and `cache` are PER KEY (each logical call
219
- * has its own backoff count + cached result), as is the per-call `CallPhase`.
220
- * Every field is plain data → the whole slice serializes into a `Store<S>`.
221
- *
222
- * `retry` / `cache` keep a default brick value even when the corresponding
223
- * config brick is omitted, so the slice shape is identical regardless of which
224
- * bricks the consumer enabled — the verbs simply never consult the unused brick.
225
- */
226
- interface ResilientState<I, R> {
227
- readonly circuit: CircuitState;
228
- readonly bucket: TokenBucket;
229
- /**
230
- * Per-key backoff counter. Entries minted by `backoff` are `TimedRetryState`s
231
- * (they carry the streak's `firstFailureAtMs`, since every failure path holds
232
- * the observation instant); the field is typed at the `RetryState` supertype
233
- * because a key that has never failed has no streak, and a slice persisted
234
- * before the origin existed rehydrates without one. Still plain data.
235
- */
236
- readonly retry: Readonly<Record<string, RetryState>>;
237
- readonly cache: TtlCache<R>;
238
- readonly calls: Readonly<Record<string, CallPhase<I, R>>>;
239
- }
240
- /**
241
- * The one effect this knob emits: "run the port for `key` with `input`". The
242
- * consumer's `handlers(ports)` interprets it; it carries no closure — `input`
243
- * is plain data (invariant 3).
244
- */
245
- type RunCmd<I> = Cmd<typeof MsgType.ResilientRun> & {
246
- readonly key: string;
247
- readonly input: I;
248
- };
249
- /** Settle Msgs the `handlers` port dispatches back. `at` is stamped at the boundary. */
250
- type SucceedMsg<R> = {
251
- readonly type: typeof MsgType.ResilientOk;
252
- readonly key: string;
253
- readonly result: R;
254
- readonly at: number;
255
- };
256
- type FailMsg = {
257
- readonly type: typeof MsgType.ResilientErr;
258
- readonly key: string;
259
- readonly error: unknown;
260
- readonly at: number;
261
- };
262
- /** The retry / deadline timer Msg — `DeadlineExceeded`, keyed by the call `key`. */
263
- type ResilientTimerMsg = DeadlineExceeded;
264
- /**
265
- * The plain-data error a deadline-failed call settles with. A `{_tag, ...}`
266
- * sentinel — NEVER a `new Error(...)` — so the slice stays JSON-serializable
267
- * (Error objects round-trip to `{}` and carry a stack trace, both of which break
268
- * the slice's durability invariant). `id` / `atMs` echo the timer that fired so
269
- * a consumer can attribute the failure to its deadline.
270
- */
271
- type DeadlineExceededError = {
272
- readonly _tag: "deadline_exceeded";
273
- readonly id: string;
274
- readonly atMs: number;
275
- };
276
- /** Ports the consumer supplies to `handlers`. */
277
- interface ResilientPorts<I, R> {
278
- /** The fallible work this knob wraps. Throws on failure → routed to `fail`. */
279
- readonly run: (input: I, key: string) => Promise<R>;
280
- }
281
- /**
282
- * Build a resilient-call knob from `config`. `rng` is injected for retry
283
- * jitter — pass a fixed `() => 0.5` in tests to pin backoff; defaults to
284
- * `Math.random` (read at the verb boundary, never inside a brick op). It is
285
- * curried onto the factory rather than threaded through every verb so callers
286
- * spell the determinism choice once.
287
- *
288
- * Returns the uniform L2 knob contract. `I` is the port input type, `R` the
289
- * port result type.
290
- *
291
- * @deprecated Use `withResilience` from `@demlik/tea/with-resilience` — not
292
- * drop-in; see the migration map at the top of this module.
293
- */
294
- declare function createResilientCall<I, R>(config: ResilientConfig, rng?: () => number): {
295
- init: () => ResilientState<I, R>;
296
- attempt: (s: ResilientState<I, R>, key: string, input: I, at: number) => readonly [ResilientState<I, R>, readonly RunCmd<I>[]];
297
- succeed: (s: ResilientState<I, R>, key: string, msg: SucceedMsg<R>) => readonly [ResilientState<I, R>, readonly RunCmd<I>[]];
298
- fail: (s: ResilientState<I, R>, key: string, msg: FailMsg) => readonly [ResilientState<I, R>, readonly RunCmd<I>[]];
299
- settleFailed: (s: ResilientState<I, R>, key: string, error: unknown) => readonly [ResilientState<I, R>, readonly RunCmd<I>[]];
300
- onTimer: (s: ResilientState<I, R>, msg: ResilientTimerMsg) => readonly [ResilientState<I, R>, readonly RunCmd<I>[]];
301
- subs: (s: ResilientState<I, R>) => readonly DeadlineSub[];
302
- handlers: (ports: ResilientPorts<I, R>) => {
303
- resilient_run: (cmd: RunCmd<I>, ctx: Readonly<Record<never, never>>) => Promise<FailMsg | SucceedMsg<R>>;
304
- };
305
- };
306
- /**
307
- * Lift a knob result `[slice, cmds]` into a host `[State, cmds]` where the
308
- * slice lives at `state.resilience`. A convenience for the common single-slice
309
- * host; consumers with a differently-named field spread by hand. Pure — a thin
310
- * record rebuild, no clock / RNG.
311
- *
312
- * @deprecated Use `withResilience` from `@demlik/tea/with-resilience` — the
313
- * wrapper owns `model.$resilience`, so there is nothing to lift; see the
314
- * migration map at the top of this module.
315
- */
316
- declare function liftResilience<S extends {
317
- resilience: ResilientState<I, R>;
318
- }, I, R, C extends Cmd>(state: S, [slice, cmds]: readonly [ResilientState<I, R>, readonly C[]]): readonly [S, readonly C[]];
319
-
320
- export { type CacheConfig, type CallPhase, type CircuitConfig, type DeadlineConfig, DeadlineExceeded, type DeadlineExceededError, DeadlineSub, type FailMsg, type RateLimitConfig, type ResilientConfig, type ResilientPorts, type ResilientState, type ResilientTimerMsg, type RunCmd, type SucceedMsg, createResilientCall, liftResilience };
@@ -1,14 +0,0 @@
1
- export { createResilientCall, liftResilience } from '../chunk-4KLG43GY.js';
2
- import '../chunk-JELSZN25.js';
3
- import '../chunk-RH5EFRVJ.js';
4
- export { deadlineSub, subscribeDeadline } from '../chunk-DGE4PV4A.js';
5
- import '../chunk-Q2UM7BXU.js';
6
- import '../chunk-S2EGRPCM.js';
7
- import '../chunk-UF4MZSLT.js';
8
- import '../chunk-VYFAZN3F.js';
9
- import '../chunk-2YFLOCWX.js';
10
- import '../chunk-ZJ5AOYBH.js';
11
- import '../chunk-ZSUUOEPL.js';
12
- import '../chunk-OOYD44JI.js';
13
- //# sourceMappingURL=index.js.map
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -1,109 +0,0 @@
1
- import { Rng, RetryPolicy } from '../retry-backoff/index.js';
2
-
3
- /**
4
- * @demlik/tea/retry-to-success — run a fallible async port through BOUNDED
5
- * retry + exponential backoff to success-or-terminal-give-up, and hand the
6
- * caller a `Promise<R>` that resolves on the first success or REJECTS with a
7
- * checkable {@link RetryExhaustedError} the moment the retry bound is hit.
8
- *
9
- * This is the retry-side parallel to `./await-terminal`. `runToTerminal` gives a
10
- * caller with a one-shot decision *machine* a fire-and-await `Promise<State>`
11
- * without wiring `observe`; this gives a caller with a one-shot fallible *port*
12
- * a fire-and-await `Promise<R>` without either hand-folding the
13
- * `./retry-backoff` primitives (`recordFailure` / `shouldRetry` / `nextDelayMs`)
14
- * into their own reducer each time, or standing up the full `./resilient-call`
15
- * verb contract (`init` + `attempt`/`succeed`/`fail`/`onTimer` + `subs` +
16
- * `handlers`) when they want retry only and none of cache / circuit / rate-limit
17
- * / deadline.
18
- *
19
- * It adds NO new runtime capability and NO new backoff math — the whole retry
20
- * decision is `./retry-backoff` exactly as `resilient-call`'s `backoff` verb
21
- * wires it:
22
- * - `initRetry()` seeds the per-call attempt counter.
23
- * - `recordFailure(retry, error)` folds each thrown failure (attempt++).
24
- * - `shouldRetry(retry, policy)` is the terminal-at-`maxAttempts` bound — the
25
- * `maxAttempts`-th recorded failure refuses another attempt (attempts
26
- * `0 .. maxAttempts-1` run; the port is invoked at most `maxAttempts` times).
27
- * - `nextDelayMs(retry, policy, rng)` is the exp+jitter+cap delay before the
28
- * next attempt, computed on the incremented state — same call order as
29
- * `resilient-call`.
30
- *
31
- * Where the clock / RNG live: injected, never read on the module's own behalf,
32
- * mirroring `retry-backoff`'s purity discipline. `rng` is an {@link Rng} (branded
33
- * `[0, 1)` via `asRng` at the caller boundary) threaded straight into
34
- * `nextDelayMs`; the wait itself is a `sleep(ms)` port defaulting to a real
35
- * `setTimeout`, injectable so a test can drive the backoff schedule
36
- * deterministically without touching wall-clock timers.
37
- *
38
- * Exhaustion is NEVER a silent swallow: at the bound the returned promise
39
- * rejects with {@link RetryExhaustedError} (carrying the attempt count and the
40
- * final failure), the retry-side dialect of `await-terminal`'s
41
- * `TerminalTimeoutError` — a distinct `instanceof`- and `_tag`-checkable
42
- * rejection.
43
- *
44
- * NOT a substrate primitive: it depends on nothing from `../index`, only on the
45
- * leaf `../retry-backoff` utility. Callers reach it via the
46
- * `@demlik/tea/retry-to-success` subpath.
47
- */
48
-
49
- /**
50
- * Raised when `retryToSuccess` exhausts the retry bound without a success — the
51
- * `maxAttempts`-th recorded failure refuses another attempt. Follows the tea
52
- * error dialect (`override readonly name`) and carries a `_tag` discriminant, so
53
- * a caller can branch on it by `instanceof` or on the tag. It carries the number
54
- * of attempts made and the final failure (`lastError`) so the terminal give-up
55
- * is a distinct, checkable rejection — never a silent resolve, and never a
56
- * swallowed error.
57
- */
58
- declare class RetryExhaustedError extends Error {
59
- /** How many times the port was invoked before giving up (= `policy.maxAttempts`). */
60
- readonly attempts: number;
61
- /** The failure the final attempt threw — carried, never interpreted. */
62
- readonly lastError: unknown;
63
- readonly name = "RetryExhaustedError";
64
- readonly _tag: "RetryExhaustedError";
65
- constructor(
66
- /** How many times the port was invoked before giving up (= `policy.maxAttempts`). */
67
- attempts: number,
68
- /** The failure the final attempt threw — carried, never interpreted. */
69
- lastError: unknown);
70
- }
71
- /** Options for {@link retryToSuccess}. */
72
- interface RetryToSuccessOptions {
73
- /**
74
- * The `[0, 1)` jitter source threaded into `nextDelayMs`, branded via
75
- * `asRng` at construction (a raw `() => number` is rejected by the type).
76
- * Injected for deterministic backoff in tests; defaults to `defaultRng`
77
- * (`Math.random`), read only at the delay boundary — never inside the loop's
78
- * decision.
79
- */
80
- readonly rng?: Rng;
81
- /**
82
- * The wait between attempts, given the backoff delay in ms. Injectable so a
83
- * test can drive the retry schedule without wall-clock timers (and assert the
84
- * exact delays); defaults to a real `setTimeout`. The delay value is always
85
- * `./retry-backoff`'s `nextDelayMs` — this port only realizes the wait.
86
- */
87
- readonly sleep?: (ms: number) => Promise<void>;
88
- }
89
- /**
90
- * Fire-and-await bounded retry: invoke the fallible `port`, and on each thrown
91
- * failure fold it through `./retry-backoff` — record it, and if the policy
92
- * still permits an attempt, back off `nextDelayMs` and retry; otherwise REJECT
93
- * with {@link RetryExhaustedError}. Resolves with the port's value on the first
94
- * success.
95
- *
96
- * The port is invoked at most `policy.maxAttempts` times (attempts
97
- * `0 .. maxAttempts-1`); the `maxAttempts`-th failure is terminal. Every failure
98
- * is either retried or surfaced on the rejection's `lastError` — none is
99
- * swallowed.
100
- *
101
- * @param port the fallible work — throws on failure, resolves with `R` on success.
102
- * @param policy the bounded-retry curve (`baseMs` / `factor` / `capMs` /
103
- * `maxAttempts` / `jitter`) from `./retry-backoff`.
104
- * @param opts optional injected `rng` (jitter) and `sleep` (the wait) — see
105
- * {@link RetryToSuccessOptions}.
106
- */
107
- declare function retryToSuccess<R>(port: () => Promise<R>, policy: RetryPolicy, opts?: RetryToSuccessOptions): Promise<R>;
108
-
109
- export { RetryExhaustedError, type RetryToSuccessOptions, retryToSuccess };
@@ -1,37 +0,0 @@
1
- import { defaultRng, initRetry, recordFailure, shouldRetry, nextDelayMs } from '../chunk-Q2UM7BXU.js';
2
-
3
- // src/retry-to-success/index.ts
4
- var RetryExhaustedError = class extends Error {
5
- constructor(attempts, lastError) {
6
- super(
7
- `@demlik/tea: retryToSuccess gave up after ${attempts} attempt(s) \u2014 the bounded retry reached maxAttempts without a success. See .lastError for the final failure.`
8
- );
9
- this.attempts = attempts;
10
- this.lastError = lastError;
11
- }
12
- attempts;
13
- lastError;
14
- name = "RetryExhaustedError";
15
- _tag = "RetryExhaustedError";
16
- };
17
- var defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
18
- async function retryToSuccess(port, policy, opts = {}) {
19
- const rng = opts.rng ?? defaultRng;
20
- const sleep = opts.sleep ?? defaultSleep;
21
- let retry = initRetry();
22
- for (; ; ) {
23
- try {
24
- return await port();
25
- } catch (error) {
26
- retry = recordFailure(retry, error);
27
- if (!shouldRetry(retry, policy)) {
28
- throw new RetryExhaustedError(retry.attempt, error);
29
- }
30
- await sleep(nextDelayMs(retry, policy, rng));
31
- }
32
- }
33
- }
34
-
35
- export { RetryExhaustedError, retryToSuccess };
36
- //# sourceMappingURL=index.js.map
37
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/retry-to-success/index.ts"],"names":[],"mappings":";;;AAiEO,IAAM,mBAAA,GAAN,cAAkC,KAAA,CAAM;AAAA,EAG7C,WAAA,CAEkB,UAEA,SAAA,EAChB;AACA,IAAA,KAAA;AAAA,MACE,6CAA6C,QAAQ,CAAA,iHAAA;AAAA,KAGvD;AARgB,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AAEA,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AAAA,EAOlB;AAAA,EATkB,QAAA;AAAA,EAEA,SAAA;AAAA,EANA,IAAA,GAAO,qBAAA;AAAA,EAChB,IAAA,GAAO,qBAAA;AAalB;AAGA,IAAM,YAAA,GAAe,CAAC,EAAA,KACpB,IAAI,OAAA,CAAQ,CAAC,OAAA,KAAY,UAAA,CAAW,OAAA,EAAS,EAAE,CAAC,CAAA;AAuClD,eAAsB,cAAA,CACpB,IAAA,EACA,MAAA,EACA,IAAA,GAA8B,EAAC,EACnB;AACZ,EAAA,MAAM,GAAA,GAAM,KAAK,GAAA,IAAO,UAAA;AACxB,EAAA,MAAM,KAAA,GAAQ,KAAK,KAAA,IAAS,YAAA;AAI5B,EAAA,IAAI,QAAQ,SAAA,EAAU;AACtB,EAAA,WAAS;AACP,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,IAAA,EAAK;AAAA,IACpB,SAAS,KAAA,EAAO;AAId,MAAA,KAAA,GAAQ,aAAA,CAAc,OAAO,KAAK,CAAA;AAClC,MAAA,IAAI,CAAC,WAAA,CAAY,KAAA,EAAO,MAAM,CAAA,EAAG;AAG/B,QAAA,MAAM,IAAI,mBAAA,CAAoB,KAAA,CAAM,OAAA,EAAS,KAAK,CAAA;AAAA,MACpD;AACA,MAAA,MAAM,KAAA,CAAM,WAAA,CAAY,KAAA,EAAO,MAAA,EAAQ,GAAG,CAAC,CAAA;AAAA,IAC7C;AAAA,EACF;AACF","file":"index.js","sourcesContent":["/**\n * @demlik/tea/retry-to-success — run a fallible async port through BOUNDED\n * retry + exponential backoff to success-or-terminal-give-up, and hand the\n * caller a `Promise<R>` that resolves on the first success or REJECTS with a\n * checkable {@link RetryExhaustedError} the moment the retry bound is hit.\n *\n * This is the retry-side parallel to `./await-terminal`. `runToTerminal` gives a\n * caller with a one-shot decision *machine* a fire-and-await `Promise<State>`\n * without wiring `observe`; this gives a caller with a one-shot fallible *port*\n * a fire-and-await `Promise<R>` without either hand-folding the\n * `./retry-backoff` primitives (`recordFailure` / `shouldRetry` / `nextDelayMs`)\n * into their own reducer each time, or standing up the full `./resilient-call`\n * verb contract (`init` + `attempt`/`succeed`/`fail`/`onTimer` + `subs` +\n * `handlers`) when they want retry only and none of cache / circuit / rate-limit\n * / deadline.\n *\n * It adds NO new runtime capability and NO new backoff math — the whole retry\n * decision is `./retry-backoff` exactly as `resilient-call`'s `backoff` verb\n * wires it:\n * - `initRetry()` seeds the per-call attempt counter.\n * - `recordFailure(retry, error)` folds each thrown failure (attempt++).\n * - `shouldRetry(retry, policy)` is the terminal-at-`maxAttempts` bound — the\n * `maxAttempts`-th recorded failure refuses another attempt (attempts\n * `0 .. maxAttempts-1` run; the port is invoked at most `maxAttempts` times).\n * - `nextDelayMs(retry, policy, rng)` is the exp+jitter+cap delay before the\n * next attempt, computed on the incremented state — same call order as\n * `resilient-call`.\n *\n * Where the clock / RNG live: injected, never read on the module's own behalf,\n * mirroring `retry-backoff`'s purity discipline. `rng` is an {@link Rng} (branded\n * `[0, 1)` via `asRng` at the caller boundary) threaded straight into\n * `nextDelayMs`; the wait itself is a `sleep(ms)` port defaulting to a real\n * `setTimeout`, injectable so a test can drive the backoff schedule\n * deterministically without touching wall-clock timers.\n *\n * Exhaustion is NEVER a silent swallow: at the bound the returned promise\n * rejects with {@link RetryExhaustedError} (carrying the attempt count and the\n * final failure), the retry-side dialect of `await-terminal`'s\n * `TerminalTimeoutError` — a distinct `instanceof`- and `_tag`-checkable\n * rejection.\n *\n * NOT a substrate primitive: it depends on nothing from `../index`, only on the\n * leaf `../retry-backoff` utility. Callers reach it via the\n * `@demlik/tea/retry-to-success` subpath.\n */\n\nimport {\n defaultRng,\n initRetry,\n nextDelayMs,\n type RetryPolicy,\n type Rng,\n recordFailure,\n shouldRetry,\n} from \"../retry-backoff\";\n\n/**\n * Raised when `retryToSuccess` exhausts the retry bound without a success — the\n * `maxAttempts`-th recorded failure refuses another attempt. Follows the tea\n * error dialect (`override readonly name`) and carries a `_tag` discriminant, so\n * a caller can branch on it by `instanceof` or on the tag. It carries the number\n * of attempts made and the final failure (`lastError`) so the terminal give-up\n * is a distinct, checkable rejection — never a silent resolve, and never a\n * swallowed error.\n */\nexport class RetryExhaustedError extends Error {\n override readonly name = \"RetryExhaustedError\";\n readonly _tag = \"RetryExhaustedError\" as const;\n constructor(\n /** How many times the port was invoked before giving up (= `policy.maxAttempts`). */\n public readonly attempts: number,\n /** The failure the final attempt threw — carried, never interpreted. */\n public readonly lastError: unknown,\n ) {\n super(\n `@demlik/tea: retryToSuccess gave up after ${attempts} attempt(s) — the ` +\n `bounded retry reached maxAttempts without a success. See .lastError ` +\n `for the final failure.`,\n );\n }\n}\n\n/** Default wait: a real `setTimeout(ms)`, the sole clock read this module makes. */\nconst defaultSleep = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\n/** Options for {@link retryToSuccess}. */\nexport interface RetryToSuccessOptions {\n /**\n * The `[0, 1)` jitter source threaded into `nextDelayMs`, branded via\n * `asRng` at construction (a raw `() => number` is rejected by the type).\n * Injected for deterministic backoff in tests; defaults to `defaultRng`\n * (`Math.random`), read only at the delay boundary — never inside the loop's\n * decision.\n */\n readonly rng?: Rng;\n /**\n * The wait between attempts, given the backoff delay in ms. Injectable so a\n * test can drive the retry schedule without wall-clock timers (and assert the\n * exact delays); defaults to a real `setTimeout`. The delay value is always\n * `./retry-backoff`'s `nextDelayMs` — this port only realizes the wait.\n */\n readonly sleep?: (ms: number) => Promise<void>;\n}\n\n/**\n * Fire-and-await bounded retry: invoke the fallible `port`, and on each thrown\n * failure fold it through `./retry-backoff` — record it, and if the policy\n * still permits an attempt, back off `nextDelayMs` and retry; otherwise REJECT\n * with {@link RetryExhaustedError}. Resolves with the port's value on the first\n * success.\n *\n * The port is invoked at most `policy.maxAttempts` times (attempts\n * `0 .. maxAttempts-1`); the `maxAttempts`-th failure is terminal. Every failure\n * is either retried or surfaced on the rejection's `lastError` — none is\n * swallowed.\n *\n * @param port the fallible work — throws on failure, resolves with `R` on success.\n * @param policy the bounded-retry curve (`baseMs` / `factor` / `capMs` /\n * `maxAttempts` / `jitter`) from `./retry-backoff`.\n * @param opts optional injected `rng` (jitter) and `sleep` (the wait) — see\n * {@link RetryToSuccessOptions}.\n */\nexport async function retryToSuccess<R>(\n port: () => Promise<R>,\n policy: RetryPolicy,\n opts: RetryToSuccessOptions = {},\n): Promise<R> {\n const rng = opts.rng ?? defaultRng;\n const sleep = opts.sleep ?? defaultSleep;\n\n // The retry counter folds over `./retry-backoff` exactly as resilient-call's\n // `backoff` verb does — no local attempt bookkeeping, no local backoff math.\n let retry = initRetry();\n for (;;) {\n try {\n return await port();\n } catch (error) {\n // Fold the failure first (attempt++), then consult the bound on the\n // incremented state — same order as resilient-call so the semantics of\n // `maxAttempts` are identical across both surfaces.\n retry = recordFailure(retry, error);\n if (!shouldRetry(retry, policy)) {\n // Terminal give-up at the bound: reject, never swallow. `retry.attempt`\n // is the number of failures = the number of port invocations made.\n throw new RetryExhaustedError(retry.attempt, error);\n }\n await sleep(nextDelayMs(retry, policy, rng));\n }\n }\n}\n"]}