@demlik/tea 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (368) hide show
  1. package/README.md +11 -9
  2. package/dist/agent/index.d.ts +638 -45
  3. package/dist/agent/index.js +9 -19
  4. package/dist/{chunk-25LBDCBC.js → chunk-6IQPODUF.js} +2 -2
  5. package/dist/{chunk-25LBDCBC.js.map → chunk-6IQPODUF.js.map} +1 -1
  6. package/dist/chunk-AQ6ZIMEA.js +421 -0
  7. package/dist/chunk-AQ6ZIMEA.js.map +1 -0
  8. package/dist/{chunk-MUUROGIH.js → chunk-BLJ2JQSH.js} +62 -12
  9. package/dist/chunk-BLJ2JQSH.js.map +1 -0
  10. package/dist/{chunk-7SVIRMC6.js → chunk-F2US5BW6.js} +25 -5
  11. package/dist/chunk-F2US5BW6.js.map +1 -0
  12. package/dist/{batch-window/index.js → chunk-F7FMAWLA.js} +4 -8
  13. package/dist/chunk-F7FMAWLA.js.map +1 -0
  14. package/dist/{chunk-7V4EVLZA.js → chunk-HUKZQX6U.js} +20 -16
  15. package/dist/chunk-HUKZQX6U.js.map +1 -0
  16. package/dist/{chunk-EWJP3YYP.js → chunk-HWVW4AXC.js} +3 -3
  17. package/dist/chunk-HWVW4AXC.js.map +1 -0
  18. package/dist/{chunk-WLGO64WC.js → chunk-HYDWG35Q.js} +23 -6
  19. package/dist/chunk-HYDWG35Q.js.map +1 -0
  20. package/dist/{chunk-I5OV65MS.js → chunk-I5MQMJDW.js} +57 -7
  21. package/dist/chunk-I5MQMJDW.js.map +1 -0
  22. package/dist/{chunk-J6527VRQ.js → chunk-LFZUK6J2.js} +3 -3
  23. package/dist/chunk-LFZUK6J2.js.map +1 -0
  24. package/dist/{chunk-ZVJZ72HY.js → chunk-LYLTKJWM.js} +25 -11
  25. package/dist/chunk-LYLTKJWM.js.map +1 -0
  26. package/dist/{chunk-D736QUGF.js → chunk-MYXFNWAJ.js} +4 -5
  27. package/dist/chunk-MYXFNWAJ.js.map +1 -0
  28. package/dist/{chunk-K575PT4S.js → chunk-PR6TB3BL.js} +15 -4
  29. package/dist/chunk-PR6TB3BL.js.map +1 -0
  30. package/dist/chunk-RQULHGYH.js +1804 -0
  31. package/dist/chunk-RQULHGYH.js.map +1 -0
  32. package/dist/{chunk-FV3Z5MBE.js → chunk-TXN2KFHF.js} +14 -4
  33. package/dist/chunk-TXN2KFHF.js.map +1 -0
  34. package/dist/{chunk-Q2UM7BXU.js → chunk-VBDU4JL6.js} +2 -2
  35. package/dist/chunk-VBDU4JL6.js.map +1 -0
  36. package/dist/chunk-Z2L3LSNV.js +1470 -0
  37. package/dist/chunk-Z2L3LSNV.js.map +1 -0
  38. package/dist/core-CTzMJ82M.d.ts +562 -0
  39. package/dist/devtools/index.d.ts +2 -2
  40. package/dist/devtools/index.js +207 -2
  41. package/dist/devtools/index.js.map +1 -1
  42. package/dist/do/index.d.ts +48 -31
  43. package/dist/do/index.js +36 -25
  44. package/dist/do/index.js.map +1 -1
  45. package/dist/{durable-effects-D8SqU_if.d.ts → durable-effects-B0-qGQDy.d.ts} +2 -2
  46. package/dist/extension/index.d.ts +301 -3
  47. package/dist/extension/index.js +596 -5
  48. package/dist/extension/index.js.map +1 -1
  49. package/dist/flow/index.d.ts +1295 -0
  50. package/dist/flow/index.js +732 -0
  51. package/dist/flow/index.js.map +1 -0
  52. package/dist/idempotency/index.d.ts +90 -116
  53. package/dist/idempotency/index.js +4 -1
  54. package/dist/{batch-window/index.d.ts → index-4vZzljCD.d.ts} +7 -11
  55. package/dist/{fan-out/index.d.ts → index-6A7dB8f6.d.ts} +7 -8
  56. package/dist/index-B5BZ-_cT.d.ts +616 -0
  57. package/dist/index-Bc40JWVl.d.ts +131 -0
  58. package/dist/{debounce/index.d.ts → index-DHSUmQTR.d.ts} +7 -7
  59. package/dist/index-DJWIER_3.d.ts +69 -0
  60. package/dist/{snapshot/index.d.ts → index-DMCeMPMJ.d.ts} +15 -77
  61. package/dist/{monitored-run/index.d.ts → index-NjrT3fL2.d.ts} +37 -12
  62. package/dist/{recorder/index.d.ts → index-TvRb1KVf.d.ts} +4 -6
  63. package/dist/{deadline/index.d.ts → index-q0hXFeZ0.d.ts} +155 -8
  64. package/dist/index.d.ts +719 -6
  65. package/dist/index.js +1 -2
  66. package/dist/jev/index.d.ts +634 -0
  67. package/dist/jev/index.js +433 -0
  68. package/dist/jev/index.js.map +1 -0
  69. package/dist/machine-CdIcN2Xm.d.ts +1773 -0
  70. package/dist/machine-viz/index.d.ts +2 -1
  71. package/dist/machine-viz/index.js +12 -5
  72. package/dist/machine-viz/index.js.map +1 -1
  73. package/dist/mem/index.d.ts +19 -3
  74. package/dist/mem/index.js +22 -2
  75. package/dist/mem/index.js.map +1 -1
  76. package/dist/node/index.d.ts +130 -4
  77. package/dist/node/index.js +222 -10
  78. package/dist/node/index.js.map +1 -1
  79. package/dist/{paginator → paginate}/index.d.ts +151 -6
  80. package/dist/paginate/index.js +7 -0
  81. package/dist/parity/index.d.ts +5 -10
  82. package/dist/parity/index.js +4 -7
  83. package/dist/parity/index.js.map +1 -1
  84. package/dist/pbt/index.d.ts +248 -5
  85. package/dist/pbt/index.js +124 -5
  86. package/dist/pbt/index.js.map +1 -1
  87. package/dist/{trace-replay → persistence}/index.d.ts +7 -4
  88. package/dist/persistence/index.js +6 -0
  89. package/dist/react/index.d.ts +4 -3
  90. package/dist/react/index.js +1 -2
  91. package/dist/react/index.js.map +1 -1
  92. package/dist/resilience/index.d.ts +743 -0
  93. package/dist/resilience/index.js +657 -0
  94. package/dist/resilience/index.js.map +1 -0
  95. package/dist/retry-backoff/index.d.ts +3 -2
  96. package/dist/retry-backoff/index.js +1 -1
  97. package/dist/runtime-types-LWDoi943.d.ts +998 -0
  98. package/dist/testing/index.d.ts +3 -2
  99. package/dist/testing/index.js +1 -2
  100. package/dist/testing/index.js.map +1 -1
  101. package/dist/{throttled-input → timing}/index.d.ts +144 -12
  102. package/dist/{throttled-input → timing}/index.js +57 -12
  103. package/dist/timing/index.js.map +1 -0
  104. package/dist/{types-D7u9DkH7.d.ts → types-DP3f5NIl.d.ts} +1 -1
  105. package/dist/work-queue/index.d.ts +131 -54
  106. package/dist/work-queue/index.js +3 -2
  107. package/dist/work-queue/index.js.map +1 -1
  108. package/package.json +50 -216
  109. package/dist/authed-call/index.d.ts +0 -119
  110. package/dist/authed-call/index.js +0 -134
  111. package/dist/authed-call/index.js.map +0 -1
  112. package/dist/await-terminal/index.d.ts +0 -100
  113. package/dist/await-terminal/index.js +0 -76
  114. package/dist/await-terminal/index.js.map +0 -1
  115. package/dist/batch-window/index.js.map +0 -1
  116. package/dist/cache/index.d.ts +0 -151
  117. package/dist/cache/index.js +0 -8
  118. package/dist/chart/index.d.ts +0 -217
  119. package/dist/chart/index.js +0 -16
  120. package/dist/chart/index.js.map +0 -1
  121. package/dist/chart/inspect/index.d.ts +0 -85
  122. package/dist/chart/inspect/index.js +0 -5
  123. package/dist/chart/inspect/react.d.ts +0 -112
  124. package/dist/chart/inspect/react.js +0 -11
  125. package/dist/chart/inspect/react.js.map +0 -1
  126. package/dist/chart/inspect/styles.css +0 -286
  127. package/dist/chart/lane/index.d.ts +0 -361
  128. package/dist/chart/lane/index.js +0 -9
  129. package/dist/chart/lane/index.js.map +0 -1
  130. package/dist/chart/lane/react.d.ts +0 -83
  131. package/dist/chart/lane/react.js +0 -559
  132. package/dist/chart/lane/react.js.map +0 -1
  133. package/dist/chart/lane/server.d.ts +0 -148
  134. package/dist/chart/lane/server.js +0 -209
  135. package/dist/chart/lane/server.js.map +0 -1
  136. package/dist/chart/lane/styles.css +0 -498
  137. package/dist/chart/lane/viewer/assets/abnfDiagram-N423BO3Z-C729LI31.js +0 -1
  138. package/dist/chart/lane/viewer/assets/architectureDiagram-T3A2C74G-C729LI31.js +0 -1
  139. package/dist/chart/lane/viewer/assets/blockDiagram-VBNYF7ZC-C729LI31.js +0 -1
  140. package/dist/chart/lane/viewer/assets/c4Diagram-5PPSVZJV-C729LI31.js +0 -1
  141. package/dist/chart/lane/viewer/assets/chunk-2GRJ4B5K-HdDf8SI3.js +0 -1
  142. package/dist/chart/lane/viewer/assets/chunk-5RXB4S5H-CcNtpUd7.js +0 -231
  143. package/dist/chart/lane/viewer/assets/chunk-5VM5RSS4-BP4fRS_5.js +0 -15
  144. package/dist/chart/lane/viewer/assets/chunk-KBJHAD2P-DZOw7xU6.js +0 -1
  145. package/dist/chart/lane/viewer/assets/chunk-NSK5VX7P-CBCyTZMs.js +0 -128
  146. package/dist/chart/lane/viewer/assets/classDiagram-JCYQIIEL-C729LI31.js +0 -1
  147. package/dist/chart/lane/viewer/assets/classDiagram-v2-OCEON4UE-D4uAiFr8.js +0 -206
  148. package/dist/chart/lane/viewer/assets/cose-bilkent-JH36ORCC-DOwCrGXH.js +0 -1
  149. package/dist/chart/lane/viewer/assets/cynefinDiagram-MW4NZA55-C729LI31.js +0 -1
  150. package/dist/chart/lane/viewer/assets/dagre-K_PewWfS.js +0 -1
  151. package/dist/chart/lane/viewer/assets/dagre-VZM6K2ZE-831qZcA8.js +0 -4
  152. package/dist/chart/lane/viewer/assets/diagram-7IWD3JNH-C729LI31.js +0 -1
  153. package/dist/chart/lane/viewer/assets/diagram-B4RE2ZJO-C729LI31.js +0 -1
  154. package/dist/chart/lane/viewer/assets/diagram-LBJQPF4R-C729LI31.js +0 -1
  155. package/dist/chart/lane/viewer/assets/diagram-Q27KOJAE-C729LI31.js +0 -1
  156. package/dist/chart/lane/viewer/assets/diagram-UB23O5K3-C729LI31.js +0 -1
  157. package/dist/chart/lane/viewer/assets/ebnfDiagram-BXEA7PRR-C729LI31.js +0 -1
  158. package/dist/chart/lane/viewer/assets/erDiagram-JOGREHBK-C729LI31.js +0 -1
  159. package/dist/chart/lane/viewer/assets/flowDiagram-UKHOOZJN-C729LI31.js +0 -1
  160. package/dist/chart/lane/viewer/assets/ganttDiagram-PKOTCBZU-C729LI31.js +0 -1
  161. package/dist/chart/lane/viewer/assets/gitGraphDiagram-DS77QQ5N-C729LI31.js +0 -1
  162. package/dist/chart/lane/viewer/assets/index-9SkH5NA3.css +0 -1
  163. package/dist/chart/lane/viewer/assets/index-Bgt4sXpW.js +0 -195
  164. package/dist/chart/lane/viewer/assets/infoDiagram-6WML65LV-C729LI31.js +0 -1
  165. package/dist/chart/lane/viewer/assets/ishikawaDiagram-WSZJBQD7-C729LI31.js +0 -1
  166. package/dist/chart/lane/viewer/assets/journeyDiagram-NVQOT4AX-C729LI31.js +0 -1
  167. package/dist/chart/lane/viewer/assets/kanban-definition-27J2QSJJ-G7PaPzy-.js +0 -89
  168. package/dist/chart/lane/viewer/assets/katex-DOwCrGXH.js +0 -1
  169. package/dist/chart/lane/viewer/assets/mindmap-definition-FAOFIHXS-CGj9nrVk.js +0 -96
  170. package/dist/chart/lane/viewer/assets/path-fybaL0A-.js +0 -1
  171. package/dist/chart/lane/viewer/assets/pegDiagram-VL7TDLO6-C729LI31.js +0 -1
  172. package/dist/chart/lane/viewer/assets/pieDiagram-7S7Q4E2Y-C729LI31.js +0 -1
  173. package/dist/chart/lane/viewer/assets/quadrantDiagram-CIZ2JOQS-C729LI31.js +0 -1
  174. package/dist/chart/lane/viewer/assets/railroadDiagram-AXF67PYL-C729LI31.js +0 -1
  175. package/dist/chart/lane/viewer/assets/requirementDiagram-LRYGKXZP-C729LI31.js +0 -1
  176. package/dist/chart/lane/viewer/assets/sankeyDiagram-W5VNT64P-C729LI31.js +0 -1
  177. package/dist/chart/lane/viewer/assets/sequenceDiagram-SI44F4Z6-C729LI31.js +0 -1
  178. package/dist/chart/lane/viewer/assets/stateDiagram-OKZ733FA-B_88AzBS.js +0 -1
  179. package/dist/chart/lane/viewer/assets/stateDiagram-v2-UEYNNEHI-CR5gcgq6.js +0 -1
  180. package/dist/chart/lane/viewer/assets/swimlanes-SLNWSIFB-B4xK-rwg.js +0 -1
  181. package/dist/chart/lane/viewer/assets/swimlanesDiagram-ULZ7WXOC-C729LI31.js +0 -1
  182. package/dist/chart/lane/viewer/assets/timeline-definition-Z64GVDOM-CCv52MfY.js +0 -120
  183. package/dist/chart/lane/viewer/assets/vennDiagram-T6HMQDX7-C729LI31.js +0 -1
  184. package/dist/chart/lane/viewer/assets/wardleyDiagram-T6FBY63Y-C729LI31.js +0 -1
  185. package/dist/chart/lane/viewer/assets/xychartDiagram-ELKLHX3M-C729LI31.js +0 -1
  186. package/dist/chart/lane/viewer/index.html +0 -15
  187. package/dist/chart/report/index.d.ts +0 -116
  188. package/dist/chart/report/index.js +0 -32
  189. package/dist/chart/report/index.js.map +0 -1
  190. package/dist/chunk-2YFLOCWX.js +0 -15
  191. package/dist/chunk-2YFLOCWX.js.map +0 -1
  192. package/dist/chunk-3JU6657S.js +0 -372
  193. package/dist/chunk-3JU6657S.js.map +0 -1
  194. package/dist/chunk-4KTWLPL5.js +0 -33
  195. package/dist/chunk-4KTWLPL5.js.map +0 -1
  196. package/dist/chunk-5EHLEUTL.js +0 -686
  197. package/dist/chunk-5EHLEUTL.js.map +0 -1
  198. package/dist/chunk-5KJKJOFC.js +0 -758
  199. package/dist/chunk-5KJKJOFC.js.map +0 -1
  200. package/dist/chunk-7SVIRMC6.js.map +0 -1
  201. package/dist/chunk-7V4EVLZA.js.map +0 -1
  202. package/dist/chunk-A56OR5RF.js +0 -184
  203. package/dist/chunk-A56OR5RF.js.map +0 -1
  204. package/dist/chunk-AZZLE7XR.js +0 -62
  205. package/dist/chunk-AZZLE7XR.js.map +0 -1
  206. package/dist/chunk-B5VXOFMZ.js +0 -266
  207. package/dist/chunk-B5VXOFMZ.js.map +0 -1
  208. package/dist/chunk-BYQUGDD3.js +0 -16
  209. package/dist/chunk-BYQUGDD3.js.map +0 -1
  210. package/dist/chunk-D736QUGF.js.map +0 -1
  211. package/dist/chunk-E6GEDSF4.js +0 -307
  212. package/dist/chunk-E6GEDSF4.js.map +0 -1
  213. package/dist/chunk-EUF7XOEE.js +0 -223
  214. package/dist/chunk-EUF7XOEE.js.map +0 -1
  215. package/dist/chunk-EWJP3YYP.js.map +0 -1
  216. package/dist/chunk-FV3Z5MBE.js.map +0 -1
  217. package/dist/chunk-HCEVHFJ7.js +0 -54
  218. package/dist/chunk-HCEVHFJ7.js.map +0 -1
  219. package/dist/chunk-I5OV65MS.js.map +0 -1
  220. package/dist/chunk-J6527VRQ.js.map +0 -1
  221. package/dist/chunk-JELSZN25.js +0 -47
  222. package/dist/chunk-JELSZN25.js.map +0 -1
  223. package/dist/chunk-JER5O7PQ.js +0 -416
  224. package/dist/chunk-JER5O7PQ.js.map +0 -1
  225. package/dist/chunk-JGVL3WPL.js +0 -26
  226. package/dist/chunk-JGVL3WPL.js.map +0 -1
  227. package/dist/chunk-JP5D6GSL.js +0 -71
  228. package/dist/chunk-JP5D6GSL.js.map +0 -1
  229. package/dist/chunk-K575PT4S.js.map +0 -1
  230. package/dist/chunk-MU6MCIAC.js +0 -15
  231. package/dist/chunk-MU6MCIAC.js.map +0 -1
  232. package/dist/chunk-MUUROGIH.js.map +0 -1
  233. package/dist/chunk-ND3DH6KM.js +0 -88
  234. package/dist/chunk-ND3DH6KM.js.map +0 -1
  235. package/dist/chunk-Q2UM7BXU.js.map +0 -1
  236. package/dist/chunk-S2EGRPCM.js +0 -47
  237. package/dist/chunk-S2EGRPCM.js.map +0 -1
  238. package/dist/chunk-SINXE47Y.js +0 -55
  239. package/dist/chunk-SINXE47Y.js.map +0 -1
  240. package/dist/chunk-SUST46KO.js +0 -53
  241. package/dist/chunk-SUST46KO.js.map +0 -1
  242. package/dist/chunk-TP5UPGLY.js +0 -61
  243. package/dist/chunk-TP5UPGLY.js.map +0 -1
  244. package/dist/chunk-UF4MZSLT.js +0 -53
  245. package/dist/chunk-UF4MZSLT.js.map +0 -1
  246. package/dist/chunk-UOC2PL46.js +0 -13
  247. package/dist/chunk-UOC2PL46.js.map +0 -1
  248. package/dist/chunk-WLGO64WC.js.map +0 -1
  249. package/dist/chunk-WRAA7GVZ.js +0 -209
  250. package/dist/chunk-WRAA7GVZ.js.map +0 -1
  251. package/dist/chunk-ZCL7SCBK.js +0 -685
  252. package/dist/chunk-ZCL7SCBK.js.map +0 -1
  253. package/dist/chunk-ZD6PNZBK.js +0 -457
  254. package/dist/chunk-ZD6PNZBK.js.map +0 -1
  255. package/dist/chunk-ZF6WDK2D.js +0 -519
  256. package/dist/chunk-ZF6WDK2D.js.map +0 -1
  257. package/dist/chunk-ZJ5AOYBH.js +0 -8
  258. package/dist/chunk-ZJ5AOYBH.js.map +0 -1
  259. package/dist/chunk-ZVJZ72HY.js.map +0 -1
  260. package/dist/circuit-breaker/index.d.ts +0 -197
  261. package/dist/circuit-breaker/index.js +0 -3
  262. package/dist/circuit-breaker/index.js.map +0 -1
  263. package/dist/core-Bjc0bS8j.d.ts +0 -326
  264. package/dist/deadline/index.js +0 -6
  265. package/dist/deadline/index.js.map +0 -1
  266. package/dist/debounce/index.js +0 -3
  267. package/dist/debounce/index.js.map +0 -1
  268. package/dist/extension/react.d.ts +0 -121
  269. package/dist/extension/react.js +0 -75
  270. package/dist/extension/react.js.map +0 -1
  271. package/dist/extension/subs/index.d.ts +0 -44
  272. package/dist/extension/subs/index.js +0 -80
  273. package/dist/extension/subs/index.js.map +0 -1
  274. package/dist/extension/test-utils.d.ts +0 -128
  275. package/dist/extension/test-utils.js +0 -277
  276. package/dist/extension/test-utils.js.map +0 -1
  277. package/dist/fan-out/index.js +0 -5
  278. package/dist/fan-out/index.js.map +0 -1
  279. package/dist/fold-Blbhru48.d.ts +0 -435
  280. package/dist/graph-CcjWZVrd.d.ts +0 -923
  281. package/dist/idempotency/adapter.d.ts +0 -62
  282. package/dist/idempotency/adapter.js +0 -4
  283. package/dist/idempotency/adapter.js.map +0 -1
  284. package/dist/idempotent-intake/index.d.ts +0 -187
  285. package/dist/idempotent-intake/index.js +0 -7
  286. package/dist/idempotent-intake/index.js.map +0 -1
  287. package/dist/llm-call/index.d.ts +0 -310
  288. package/dist/llm-call/index.js +0 -16
  289. package/dist/llm-call/index.js.map +0 -1
  290. package/dist/machine-0OmPvsy_.d.ts +0 -804
  291. package/dist/monitored-run/index.js +0 -10
  292. package/dist/monitored-run/index.js.map +0 -1
  293. package/dist/paginated-walk/index.d.ts +0 -234
  294. package/dist/paginated-walk/index.js +0 -16
  295. package/dist/paginated-walk/index.js.map +0 -1
  296. package/dist/paginator/index.js +0 -3
  297. package/dist/paginator/index.js.map +0 -1
  298. package/dist/pbt/arbitraries/index.d.ts +0 -135
  299. package/dist/pbt/arbitraries/index.js +0 -3
  300. package/dist/pbt/arbitraries/index.js.map +0 -1
  301. package/dist/pbt/runners/index.d.ts +0 -117
  302. package/dist/pbt/runners/index.js +0 -5
  303. package/dist/pbt/runners/index.js.map +0 -1
  304. package/dist/poller/index.d.ts +0 -351
  305. package/dist/poller/index.js +0 -115
  306. package/dist/poller/index.js.map +0 -1
  307. package/dist/prediction/index.d.ts +0 -130
  308. package/dist/prediction/index.js +0 -4
  309. package/dist/prediction/index.js.map +0 -1
  310. package/dist/protocol-B5YmJr0d.d.ts +0 -45
  311. package/dist/pure/index.d.ts +0 -2
  312. package/dist/pure/index.js +0 -4
  313. package/dist/pure/index.js.map +0 -1
  314. package/dist/rate-limit/index.d.ts +0 -115
  315. package/dist/rate-limit/index.js +0 -3
  316. package/dist/rate-limit/index.js.map +0 -1
  317. package/dist/reconciler/index.d.ts +0 -192
  318. package/dist/reconciler/index.js +0 -164
  319. package/dist/reconciler/index.js.map +0 -1
  320. package/dist/recorder/index.js +0 -3
  321. package/dist/recorder/index.js.map +0 -1
  322. package/dist/reducer-BqyoVyBG.d.ts +0 -447
  323. package/dist/resilient-call/index.d.ts +0 -319
  324. package/dist/resilient-call/index.js +0 -14
  325. package/dist/resilient-call/index.js.map +0 -1
  326. package/dist/retry-to-success/index.d.ts +0 -109
  327. package/dist/retry-to-success/index.js +0 -37
  328. package/dist/retry-to-success/index.js.map +0 -1
  329. package/dist/run-BVeqJDBF.d.ts +0 -713
  330. package/dist/runtime-types-Bxc637bp.d.ts +0 -502
  331. package/dist/saga/index.d.ts +0 -240
  332. package/dist/saga/index.js +0 -150
  333. package/dist/saga/index.js.map +0 -1
  334. package/dist/samples-DCt6nF8H.d.ts +0 -59
  335. package/dist/snapshot/index.js +0 -5
  336. package/dist/snapshot/index.js.map +0 -1
  337. package/dist/subs/index.d.ts +0 -471
  338. package/dist/subs/index.js +0 -7
  339. package/dist/subs/index.js.map +0 -1
  340. package/dist/throttle/index.d.ts +0 -134
  341. package/dist/throttle/index.js +0 -3
  342. package/dist/throttle/index.js.map +0 -1
  343. package/dist/throttled-input/index.js.map +0 -1
  344. package/dist/token-refresh/index.d.ts +0 -215
  345. package/dist/token-refresh/index.js +0 -6
  346. package/dist/token-refresh/index.js.map +0 -1
  347. package/dist/trace-replay/index.js +0 -6
  348. package/dist/trace-replay/index.js.map +0 -1
  349. package/dist/with-deadline/index.d.ts +0 -196
  350. package/dist/with-deadline/index.js +0 -111
  351. package/dist/with-deadline/index.js.map +0 -1
  352. package/dist/with-resilience/index.d.ts +0 -224
  353. package/dist/with-resilience/index.js +0 -240
  354. package/dist/with-resilience/index.js.map +0 -1
  355. package/dist/with-telemetry/index.d.ts +0 -149
  356. package/dist/with-telemetry/index.js +0 -70
  357. package/dist/with-telemetry/index.js.map +0 -1
  358. package/dist/work-queue/adapter.d.ts +0 -83
  359. package/dist/work-queue/adapter.js +0 -4
  360. package/dist/work-queue/adapter.js.map +0 -1
  361. package/dist/work-queue/ops.d.ts +0 -70
  362. package/dist/work-queue/ops.js +0 -3
  363. package/dist/work-queue/ops.js.map +0 -1
  364. package/dist/workflow/index.d.ts +0 -484
  365. package/dist/workflow/index.js +0 -244
  366. package/dist/workflow/index.js.map +0 -1
  367. /package/dist/{cache → paginate}/index.js.map +0 -0
  368. /package/dist/{chart/inspect → persistence}/index.js.map +0 -0
@@ -1,319 +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-Bjc0bS8j.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-D7u9DkH7.js';
10
-
11
- /**
12
- * @packageDocumentation
13
- *
14
- * @deprecated `@demlik/tea/resilient-call` is deprecated in favor of
15
- * `@demlik/tea/with-resilience` — the higher-order `withResilience(base,
16
- * config)` wrapper (TEA-idiomatic: it wraps any existing machine instead of
17
- * forcing a bespoke embedded slice; epic consolidation verdict, survivor
18
- * `with-resilience`). The APIs are NOT drop-in; migration map:
19
- *
20
- * - `createResilientCall(config, rng)` + hand-wiring `init` / the verbs /
21
- * `subs` / `handlers` into your machine → `withResilience(base, { target,
22
- * ...bricks }, rng)`. Nothing is wired by hand anymore: the wrapper
23
- * intercepts the `target` base Cmd and routes it through the gate.
24
- * - `ResilientConfig` bricks (`retry` / `circuit` / `rateLimit` / `cache` /
25
- * `deadline`) → unchanged; `ResilienceConfig` extends the same knob and
26
- * adds `target` (required), `keyOf?` (per-call key — was `attempt`'s `key`
27
- * argument), and `at?` (time-as-data reader — REQUIRED with any
28
- * time-sensitive brick; `withResilience` throws at construction without it).
29
- * - The slice at your chosen Model field + `liftResilience` → the wrapper
30
- * owns `model.$resilience`; there is nothing to lift.
31
- * - Verbs `attempt` / `succeed` / `fail` / `onTimer` → internal to the
32
- * wrapper; results route as `$resilience:ok` / `$resilience:err` /
33
- * `$resilience:timer` Msgs through the merged `update` (the old
34
- * `resilient_run` / `resilient_ok` / `resilient_err` vocabulary is renamed
35
- * into the `$resilience:` namespace).
36
- * - `settleFailed` → NO equivalent. It exists for embedded-slice consumers
37
- * (`authed-call`, `paginated-walk`) that settle a call without touching the
38
- * breaker; the wrapper exposes no caller-facing settle verb.
39
- * - `handlers(ports)` / `subs(state)` / the `subscribeDeadline` re-export →
40
- * handled by the wrapper; run the returned machine like any other.
41
- *
42
- * Removal window ("deprecate, don't delete"): the `./resilient-call` subpath
43
- * export survives one minor release after this deprecation ships, then is
44
- * removed. Internal sibling modules (`with-resilience` itself, `agent`,
45
- * `llm-call`, `authed-call`, `reconciler`, `paginated-walk`) intentionally keep
46
- * importing `../resilient-call` — the deprecation targets the PUBLISHED export,
47
- * not the module's internal role.
48
- *
49
- * @demlik/tea/resilient-call — the ROOT composition: a single resilience knob
50
- * that bundles cache → circuit-breaker → rate-limit → exponential-backoff retry
51
- * (with a deadline-driven retry timer) around any fallible `(input) => Promise`
52
- * port.
53
- *
54
- * This is `examples/resilient-fetch.ts`'s hand-wired `attempt()` generalized:
55
- *
56
- * - It is **keyed**. The example tracked one URL at a time; this tracks N
57
- * concurrent logical calls, each under a string `key`. The cache, the
58
- * waiting-retry bookkeeping, and the retry timers are all per-key, while the
59
- * circuit breaker and token bucket are shared (one downstream target, one
60
- * breaker / one bucket — the example's implicit single-target assumption
61
- * made explicit).
62
- * - It is **config-driven**, not hand-wired. You hand `createResilientCall`
63
- * a `ResilientConfig` and get back the uniform knob contract every L2
64
- * composition exposes: `init()`, the four verbs (`attempt` / `succeed` /
65
- * `fail` / `onTimer`), `subs(state)`, and `handlers(ports)`.
66
- * - Every brick is **optional**. Omit `cache` and the cache gate disappears
67
- * (`get` is never consulted); omit `circuit` and every call passes the
68
- * breaker; omit `rateLimit` and the bucket never throttles; omit `retry`
69
- * and a failure is terminal (no backoff, no timer); omit `deadline` and no
70
- * overall wall-clock cap is armed. "Omit a brick → omit its gate" is the
71
- * whole config story — there are no other modes.
72
- *
73
- * Four later compositions (`llm-call`, `paginated-walk`, `authed-call`,
74
- * `reconciler`) inherit THIS slice + verb shape, so the contract here is
75
- * load-bearing: the slice is a flat record of brick states, every verb returns
76
- * `readonly [State, Cmd[]]`, time is always an `at` / `now` parameter, and the
77
- * RNG used for jitter is injected on the config (never read inside a verb).
78
- *
79
- * ## The two non-negotiables (canon)
80
- *
81
- * - **Durable** — the slice is a plain-data Model field (brick states are all
82
- * JSON-serializable), so it survives DO eviction / reload.
83
- * - **Replayable** — every transition is a verb returning new state + Cmds;
84
- * `replay` reconstructs it exactly. Nothing here closes over time or RNG.
85
- *
86
- * ## Where the clock / RNG live
87
- *
88
- * Inside the verbs: nowhere. Time arrives as `at` on `attempt` / `onTimer` and
89
- * is carried on the result / timer Msgs the consumer dispatches. Jitter RNG is
90
- * injected once at `createResilientCall(config, rng)` and threaded into
91
- * `nextDelayMs` at the verb boundary — deterministic in tests, `Math.random`
92
- * by default. The ONLY clock read is `Date.now()` inside the `handlers` port
93
- * (the effect boundary), exactly as `resilient-fetch.ts` stamps its result Msgs.
94
- *
95
- * That same `at` is what makes a DURATION-bounded retry budget reachable here:
96
- * `recordFailure` / `shouldRetry` are fed the failure's observation instant,
97
- * so `config.retry` accepts any `AnyRetryPolicy` — a count, a wall-clock outage
98
- * budget (`maxElapsedMs`), or explicit `unbounded: true` — with no new argument
99
- * on any verb and no clock read inside one.
100
- *
101
- * ## Typical wiring
102
- *
103
- * const rc = createResilientCall<string, Result>({
104
- * cache: { ttlMs: 60_000 },
105
- * circuit: { threshold: 5, cooldownMs: 30_000 },
106
- * rateLimit: { capacity: 10, refillPerSec: 5 },
107
- * retry: defaultRetryPolicy,
108
- * deadline: { ms: 5_000 },
109
- * });
110
- *
111
- * // in the machine:
112
- * init: () => [{ resilience: rc.init() }, []],
113
- * update: {
114
- * fetch: (s, m) => lift(s, rc.attempt(s.resilience, m.key, m.input, m.at)),
115
- * call_ok: (s, m) => lift(s, rc.succeed(s.resilience, m.key, m)),
116
- * call_err:(s, m) => lift(s, rc.fail(s.resilience, m.key, m)),
117
- * retry_due:(s, m) => lift(s, rc.onTimer(s.resilience, m)),
118
- * },
119
- * subscriptions: (s) => rc.subs(s.resilience),
120
- * subscribe: { deadline: subscribeDeadline },
121
- * interpret: rc.handlers({ run: ctx.call }),
122
- */
123
-
124
- /** Circuit-breaker knob — only the two numbers a consumer ever tunes. */
125
- interface CircuitConfig {
126
- /** Consecutive failures that trip the breaker open. */
127
- readonly threshold: number;
128
- /** How long the breaker stays open before admitting a probe, in ms. */
129
- readonly cooldownMs: number;
130
- /**
131
- * Probes admitted in `half_open` before fast-failing the rest of the round.
132
- * Defaults to 1 (a single probe decides recovery) — matches the circuit-
133
- * breaker module's `defaultCircuitPolicy`.
134
- */
135
- readonly halfOpenMaxProbes?: number;
136
- }
137
- /** Token-bucket rate-limit knob. */
138
- interface RateLimitConfig {
139
- /** Burst size — the bucket starts full at `capacity`. */
140
- readonly capacity: number;
141
- /** Steady-state refill rate, tokens per second. */
142
- readonly refillPerSec: number;
143
- }
144
- /** Per-entry TTL cache knob. */
145
- interface CacheConfig {
146
- /** How long a cached success stays fresh, in ms. */
147
- readonly ttlMs: number;
148
- }
149
- /** Overall wall-clock deadline knob — an absolute cap per in-flight call. */
150
- interface DeadlineConfig {
151
- /** Budget from the moment a call starts, in ms. */
152
- readonly ms: number;
153
- }
154
- /**
155
- * The resilience knob. EVERY field is optional: omit a brick and its gate is
156
- * skipped entirely (the slice still carries a default brick state so the shape
157
- * stays uniform across configs, but the gate is never consulted). An empty
158
- * config `{}` is a valid pass-through — a bare effect with no resilience at all.
159
- */
160
- interface ResilientConfig {
161
- /**
162
- * The backoff brick. Omit and a failure is terminal (no backoff, no timer).
163
- *
164
- * Any bound the `../retry-backoff` union admits: a count (`RetryPolicy`), a
165
- * wall-clock outage budget (`DurationRetryPolicy`), or explicit
166
- * `unbounded: true`. A duration bound needs no extra wiring: every path that
167
- * records a failure already holds the instant it was observed as DATA —
168
- * `fail`'s `msg.at` (stamped at the interpret boundary) and `gate`'s `at`
169
- * (the caller's `attempt` / the retry timer's `atMs`) — so the streak clock
170
- * is fed from a Msg, never from a `Date.now()` inside a verb (invariant 2).
171
- */
172
- readonly retry?: AnyRetryPolicy;
173
- readonly circuit?: CircuitConfig;
174
- readonly rateLimit?: RateLimitConfig;
175
- readonly cache?: CacheConfig;
176
- readonly deadline?: DeadlineConfig;
177
- }
178
- /**
179
- * Per-key call phase. `key` indexes a logical call; several can be in flight at
180
- * once (the generalization of the example's single `url`). Discriminated on
181
- * `phase` so each phase carries only its own data (pattern 11):
182
- *
183
- * - `idle` — never attempted, or fully settled and forgotten.
184
- * - `running` — the effect Cmd is out; awaiting `succeed` / `fail`.
185
- * Carries `deadlineAtMs` (absolute cap, `0` if no deadline
186
- * brick) and the last `input` so a retry can re-issue it.
187
- * - `waiting_retry` — a transient failure backed off; the retry timer is armed
188
- * for `retryAtMs`. Carries `input` for the re-attempt.
189
- * - `circuit_open` — the breaker fast-failed this attempt. Terminal for this
190
- * call until the consumer re-attempts after cooldown.
191
- * - `succeeded` — settled OK. `result` is the value the port produced.
192
- * - `failed` — settled Err (out of retries, or no retry brick). `error`
193
- * carries the last failure.
194
- */
195
- type CallPhase<I, R> = {
196
- readonly phase: "idle";
197
- } | {
198
- readonly phase: "running";
199
- readonly input: I;
200
- readonly deadlineAtMs: number;
201
- } | {
202
- readonly phase: "waiting_retry";
203
- readonly input: I;
204
- readonly retryAtMs: number;
205
- readonly deadlineAtMs: number;
206
- } | {
207
- readonly phase: "circuit_open";
208
- } | {
209
- readonly phase: "succeeded";
210
- readonly result: R;
211
- } | {
212
- readonly phase: "failed";
213
- readonly error: unknown;
214
- };
215
- /**
216
- * The slice. `circuit` / `bucket` are SHARED across keys (one downstream target
217
- * → one breaker, one bucket). `retry` and `cache` are PER KEY (each logical call
218
- * has its own backoff count + cached result), as is the per-call `CallPhase`.
219
- * Every field is plain data → the whole slice serializes into a `Store<S>`.
220
- *
221
- * `retry` / `cache` keep a default brick value even when the corresponding
222
- * config brick is omitted, so the slice shape is identical regardless of which
223
- * bricks the consumer enabled — the verbs simply never consult the unused brick.
224
- */
225
- interface ResilientState<I, R> {
226
- readonly circuit: CircuitState;
227
- readonly bucket: TokenBucket;
228
- /**
229
- * Per-key backoff counter. Entries minted by `backoff` are `TimedRetryState`s
230
- * (they carry the streak's `firstFailureAtMs`, since every failure path holds
231
- * the observation instant); the field is typed at the `RetryState` supertype
232
- * because a key that has never failed has no streak, and a slice persisted
233
- * before the origin existed rehydrates without one. Still plain data.
234
- */
235
- readonly retry: Readonly<Record<string, RetryState>>;
236
- readonly cache: TtlCache<R>;
237
- readonly calls: Readonly<Record<string, CallPhase<I, R>>>;
238
- }
239
- /**
240
- * The one effect this knob emits: "run the port for `key` with `input`". The
241
- * consumer's `handlers(ports)` interprets it; it carries no closure — `input`
242
- * is plain data (invariant 3).
243
- */
244
- type RunCmd<I> = Cmd<typeof MsgType.ResilientRun> & {
245
- readonly key: string;
246
- readonly input: I;
247
- };
248
- /** Settle Msgs the `handlers` port dispatches back. `at` is stamped at the boundary. */
249
- type SucceedMsg<R> = {
250
- readonly type: typeof MsgType.ResilientOk;
251
- readonly key: string;
252
- readonly result: R;
253
- readonly at: number;
254
- };
255
- type FailMsg = {
256
- readonly type: typeof MsgType.ResilientErr;
257
- readonly key: string;
258
- readonly error: unknown;
259
- readonly at: number;
260
- };
261
- /** The retry / deadline timer Msg — `DeadlineExceeded`, keyed by the call `key`. */
262
- type ResilientTimerMsg = DeadlineExceeded;
263
- /**
264
- * The plain-data error a deadline-failed call settles with. A `{_tag, ...}`
265
- * sentinel — NEVER a `new Error(...)` — so the slice stays JSON-serializable
266
- * (Error objects round-trip to `{}` and carry a stack trace, both of which break
267
- * the slice's durability invariant). `id` / `atMs` echo the timer that fired so
268
- * a consumer can attribute the failure to its deadline.
269
- */
270
- type DeadlineExceededError = {
271
- readonly _tag: "deadline_exceeded";
272
- readonly id: string;
273
- readonly atMs: number;
274
- };
275
- /** Ports the consumer supplies to `handlers`. */
276
- interface ResilientPorts<I, R> {
277
- /** The fallible work this knob wraps. Throws on failure → routed to `fail`. */
278
- readonly run: (input: I, key: string) => Promise<R>;
279
- }
280
- /**
281
- * Build a resilient-call knob from `config`. `rng` is injected for retry
282
- * jitter — pass a fixed `() => 0.5` in tests to pin backoff; defaults to
283
- * `Math.random` (read at the verb boundary, never inside a brick op). It is
284
- * curried onto the factory rather than threaded through every verb so callers
285
- * spell the determinism choice once.
286
- *
287
- * Returns the uniform L2 knob contract. `I` is the port input type, `R` the
288
- * port result type.
289
- *
290
- * @deprecated Use `withResilience` from `@demlik/tea/with-resilience` — not
291
- * drop-in; see the migration map at the top of this module.
292
- */
293
- declare function createResilientCall<I, R>(config: ResilientConfig, rng?: () => number): {
294
- init: () => ResilientState<I, R>;
295
- attempt: (s: ResilientState<I, R>, key: string, input: I, at: number) => readonly [ResilientState<I, R>, readonly RunCmd<I>[]];
296
- succeed: (s: ResilientState<I, R>, key: string, msg: SucceedMsg<R>) => readonly [ResilientState<I, R>, readonly RunCmd<I>[]];
297
- fail: (s: ResilientState<I, R>, key: string, msg: FailMsg) => readonly [ResilientState<I, R>, readonly RunCmd<I>[]];
298
- settleFailed: (s: ResilientState<I, R>, key: string, error: unknown) => readonly [ResilientState<I, R>, readonly RunCmd<I>[]];
299
- onTimer: (s: ResilientState<I, R>, msg: ResilientTimerMsg) => readonly [ResilientState<I, R>, readonly RunCmd<I>[]];
300
- subs: (s: ResilientState<I, R>) => readonly DeadlineSub[];
301
- handlers: (ports: ResilientPorts<I, R>) => {
302
- resilient_run: (cmd: RunCmd<I>, ctx: Readonly<Record<never, never>>) => Promise<FailMsg | SucceedMsg<R>>;
303
- };
304
- };
305
- /**
306
- * Lift a knob result `[slice, cmds]` into a host `[State, cmds]` where the
307
- * slice lives at `state.resilience`. A convenience for the common single-slice
308
- * host; consumers with a differently-named field spread by hand. Pure — a thin
309
- * record rebuild, no clock / RNG.
310
- *
311
- * @deprecated Use `withResilience` from `@demlik/tea/with-resilience` — the
312
- * wrapper owns `model.$resilience`, so there is nothing to lift; see the
313
- * migration map at the top of this module.
314
- */
315
- declare function liftResilience<S extends {
316
- resilience: ResilientState<I, R>;
317
- }, I, R, C extends Cmd>(state: S, [slice, cmds]: readonly [ResilientState<I, R>, readonly C[]]): readonly [S, readonly C[]];
318
-
319
- 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-EUF7XOEE.js';
2
- import '../chunk-JELSZN25.js';
3
- export { deadlineSub, subscribeDeadline } from '../chunk-JGVL3WPL.js';
4
- import '../chunk-Q2UM7BXU.js';
5
- import '../chunk-S2EGRPCM.js';
6
- import '../chunk-UF4MZSLT.js';
7
- import '../chunk-7SVIRMC6.js';
8
- import '../chunk-3JU6657S.js';
9
- import '../chunk-2YFLOCWX.js';
10
- import '../chunk-ZJ5AOYBH.js';
11
- import '../chunk-5EHLEUTL.js';
12
- import '../chunk-B5VXOFMZ.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"]}