@demlik/tea 0.13.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 (372) hide show
  1. package/README.md +11 -9
  2. package/dist/agent/index.d.ts +637 -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-RH5EFRVJ.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-O4MVQTEJ.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-DMYGQB4O.js → chunk-HYDWG35Q.js} +23 -6
  19. package/dist/chunk-HYDWG35Q.js.map +1 -0
  20. package/dist/{chunk-YUXP55T2.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-Co0LWkIA.d.ts → core-CTzMJ82M.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 +42 -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-B0-qGQDy.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 +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 -12
  55. package/dist/{fan-out/index.d.ts → index-6A7dB8f6.d.ts} +7 -9
  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 -78
  61. package/dist/{monitored-run/index.d.ts → index-NjrT3fL2.d.ts} +37 -13
  62. package/dist/{recorder/index.d.ts → index-TvRb1KVf.d.ts} +4 -7
  63. package/dist/{deadline/index.d.ts → index-q0hXFeZ0.d.ts} +155 -9
  64. package/dist/index.d.ts +711 -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 +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 +151 -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/react/index.d.ts +2 -2
  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 +2 -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 +143 -12
  102. package/dist/{throttled-input → timing}/index.js +57 -12
  103. package/dist/timing/index.js.map +1 -0
  104. package/dist/{types-XS_miRnB.d.ts → types-DP3f5NIl.d.ts} +1 -1
  105. package/dist/work-queue/index.d.ts +130 -54
  106. package/dist/work-queue/index.js +3 -2
  107. package/dist/work-queue/index.js.map +1 -1
  108. package/package.json +45 -218
  109. package/dist/authed-call/index.d.ts +0 -120
  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 -101
  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 -152
  117. package/dist/cache/index.js +0 -8
  118. package/dist/chart/index.d.ts +0 -218
  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 -86
  122. package/dist/chart/inspect/index.js +0 -5
  123. package/dist/chart/inspect/react.d.ts +0 -113
  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 -362
  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 -84
  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 -117
  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-3I52QZZ5.js +0 -519
  193. package/dist/chunk-3I52QZZ5.js.map +0 -1
  194. package/dist/chunk-3ZAFFRRB.js +0 -457
  195. package/dist/chunk-3ZAFFRRB.js.map +0 -1
  196. package/dist/chunk-4EQZ76JC.js +0 -33
  197. package/dist/chunk-4EQZ76JC.js.map +0 -1
  198. package/dist/chunk-4KLG43GY.js +0 -223
  199. package/dist/chunk-4KLG43GY.js.map +0 -1
  200. package/dist/chunk-7FRZ2CT2.js +0 -424
  201. package/dist/chunk-7FRZ2CT2.js.map +0 -1
  202. package/dist/chunk-AZZLE7XR.js +0 -62
  203. package/dist/chunk-AZZLE7XR.js.map +0 -1
  204. package/dist/chunk-BYQUGDD3.js +0 -16
  205. package/dist/chunk-BYQUGDD3.js.map +0 -1
  206. package/dist/chunk-CIQG5L42.js +0 -685
  207. package/dist/chunk-CIQG5L42.js.map +0 -1
  208. package/dist/chunk-CLM6ERNO.js +0 -61
  209. package/dist/chunk-CLM6ERNO.js.map +0 -1
  210. package/dist/chunk-COS5MSTO.js +0 -88
  211. package/dist/chunk-COS5MSTO.js.map +0 -1
  212. package/dist/chunk-CRPZJVD2.js +0 -71
  213. package/dist/chunk-CRPZJVD2.js.map +0 -1
  214. package/dist/chunk-D62FDQKE.js +0 -53
  215. package/dist/chunk-D62FDQKE.js.map +0 -1
  216. package/dist/chunk-D736QUGF.js.map +0 -1
  217. package/dist/chunk-DGE4PV4A.js +0 -26
  218. package/dist/chunk-DGE4PV4A.js.map +0 -1
  219. package/dist/chunk-DMYGQB4O.js.map +0 -1
  220. package/dist/chunk-EWJP3YYP.js.map +0 -1
  221. package/dist/chunk-FV3Z5MBE.js.map +0 -1
  222. package/dist/chunk-HCEVHFJ7.js +0 -54
  223. package/dist/chunk-HCEVHFJ7.js.map +0 -1
  224. package/dist/chunk-J6527VRQ.js.map +0 -1
  225. package/dist/chunk-JELSZN25.js +0 -47
  226. package/dist/chunk-JELSZN25.js.map +0 -1
  227. package/dist/chunk-K575PT4S.js.map +0 -1
  228. package/dist/chunk-L57ZOT5K.js +0 -184
  229. package/dist/chunk-L57ZOT5K.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-NR7BU22N.js +0 -758
  234. package/dist/chunk-NR7BU22N.js.map +0 -1
  235. package/dist/chunk-O4MVQTEJ.js.map +0 -1
  236. package/dist/chunk-OOYD44JI.js +0 -317
  237. package/dist/chunk-OOYD44JI.js.map +0 -1
  238. package/dist/chunk-Q2UM7BXU.js.map +0 -1
  239. package/dist/chunk-RH5EFRVJ.js.map +0 -1
  240. package/dist/chunk-S2EGRPCM.js +0 -47
  241. package/dist/chunk-S2EGRPCM.js.map +0 -1
  242. package/dist/chunk-SINXE47Y.js +0 -55
  243. package/dist/chunk-SINXE47Y.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-VYFAZN3F.js +0 -372
  249. package/dist/chunk-VYFAZN3F.js.map +0 -1
  250. package/dist/chunk-WRAA7GVZ.js +0 -209
  251. package/dist/chunk-WRAA7GVZ.js.map +0 -1
  252. package/dist/chunk-XGELA764.js +0 -163
  253. package/dist/chunk-XGELA764.js.map +0 -1
  254. package/dist/chunk-YUXP55T2.js.map +0 -1
  255. package/dist/chunk-YWIKDKHY.js +0 -307
  256. package/dist/chunk-YWIKDKHY.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-ZSUUOEPL.js +0 -731
  260. package/dist/chunk-ZSUUOEPL.js.map +0 -1
  261. package/dist/chunk-ZVJZ72HY.js.map +0 -1
  262. package/dist/circuit-breaker/index.d.ts +0 -197
  263. package/dist/circuit-breaker/index.js +0 -3
  264. package/dist/circuit-breaker/index.js.map +0 -1
  265. package/dist/deadline/index.js +0 -6
  266. package/dist/deadline/index.js.map +0 -1
  267. package/dist/debounce/index.js +0 -3
  268. package/dist/debounce/index.js.map +0 -1
  269. package/dist/extension/react.d.ts +0 -121
  270. package/dist/extension/react.js +0 -75
  271. package/dist/extension/react.js.map +0 -1
  272. package/dist/extension/subs/index.d.ts +0 -45
  273. package/dist/extension/subs/index.js +0 -80
  274. package/dist/extension/subs/index.js.map +0 -1
  275. package/dist/extension/test-utils.d.ts +0 -128
  276. package/dist/extension/test-utils.js +0 -277
  277. package/dist/extension/test-utils.js.map +0 -1
  278. package/dist/fan-out/index.js +0 -5
  279. package/dist/fan-out/index.js.map +0 -1
  280. package/dist/fold-BJPdjc9w.d.ts +0 -435
  281. package/dist/graph-B3L5e0N1.d.ts +0 -923
  282. package/dist/idempotency/adapter.d.ts +0 -62
  283. package/dist/idempotency/adapter.js +0 -4
  284. package/dist/idempotency/adapter.js.map +0 -1
  285. package/dist/idempotent-intake/index.d.ts +0 -188
  286. package/dist/idempotent-intake/index.js +0 -7
  287. package/dist/idempotent-intake/index.js.map +0 -1
  288. package/dist/journal/index.d.ts +0 -373
  289. package/dist/journal/index.js +0 -3
  290. package/dist/journal/index.js.map +0 -1
  291. package/dist/llm-call/index.d.ts +0 -311
  292. package/dist/llm-call/index.js +0 -16
  293. package/dist/llm-call/index.js.map +0 -1
  294. package/dist/machine-BtFWQmmq.d.ts +0 -804
  295. package/dist/monitored-run/index.js +0 -10
  296. package/dist/monitored-run/index.js.map +0 -1
  297. package/dist/paginated-walk/index.d.ts +0 -235
  298. package/dist/paginated-walk/index.js +0 -16
  299. package/dist/paginated-walk/index.js.map +0 -1
  300. package/dist/paginator/index.js +0 -3
  301. package/dist/paginator/index.js.map +0 -1
  302. package/dist/pbt/arbitraries/index.d.ts +0 -136
  303. package/dist/pbt/arbitraries/index.js +0 -3
  304. package/dist/pbt/arbitraries/index.js.map +0 -1
  305. package/dist/pbt/runners/index.d.ts +0 -118
  306. package/dist/pbt/runners/index.js +0 -5
  307. package/dist/pbt/runners/index.js.map +0 -1
  308. package/dist/poller/index.d.ts +0 -352
  309. package/dist/poller/index.js +0 -115
  310. package/dist/poller/index.js.map +0 -1
  311. package/dist/prediction/index.d.ts +0 -131
  312. package/dist/prediction/index.js +0 -4
  313. package/dist/prediction/index.js.map +0 -1
  314. package/dist/protocol-B5YmJr0d.d.ts +0 -45
  315. package/dist/pure/index.d.ts +0 -3
  316. package/dist/pure/index.js +0 -4
  317. package/dist/pure/index.js.map +0 -1
  318. package/dist/rate-limit/index.d.ts +0 -115
  319. package/dist/rate-limit/index.js +0 -3
  320. package/dist/rate-limit/index.js.map +0 -1
  321. package/dist/reconciler/index.d.ts +0 -193
  322. package/dist/reconciler/index.js +0 -164
  323. package/dist/reconciler/index.js.map +0 -1
  324. package/dist/recorder/index.js +0 -3
  325. package/dist/recorder/index.js.map +0 -1
  326. package/dist/reducer-4GNR6b8B.d.ts +0 -447
  327. package/dist/resilient-call/index.d.ts +0 -320
  328. package/dist/resilient-call/index.js +0 -14
  329. package/dist/resilient-call/index.js.map +0 -1
  330. package/dist/retry-to-success/index.d.ts +0 -109
  331. package/dist/retry-to-success/index.js +0 -37
  332. package/dist/retry-to-success/index.js.map +0 -1
  333. package/dist/run-pAcmBpah.d.ts +0 -713
  334. package/dist/runtime-types-CNLmhWif.d.ts +0 -517
  335. package/dist/saga/index.d.ts +0 -241
  336. package/dist/saga/index.js +0 -150
  337. package/dist/saga/index.js.map +0 -1
  338. package/dist/samples-B3My5oh2.d.ts +0 -59
  339. package/dist/snapshot/index.js +0 -5
  340. package/dist/snapshot/index.js.map +0 -1
  341. package/dist/subs/index.d.ts +0 -472
  342. package/dist/subs/index.js +0 -7
  343. package/dist/subs/index.js.map +0 -1
  344. package/dist/throttle/index.d.ts +0 -134
  345. package/dist/throttle/index.js +0 -3
  346. package/dist/throttle/index.js.map +0 -1
  347. package/dist/throttled-input/index.js.map +0 -1
  348. package/dist/token-refresh/index.d.ts +0 -216
  349. package/dist/token-refresh/index.js +0 -6
  350. package/dist/token-refresh/index.js.map +0 -1
  351. package/dist/trace-replay/index.js +0 -6
  352. package/dist/trace-replay/index.js.map +0 -1
  353. package/dist/with-deadline/index.d.ts +0 -197
  354. package/dist/with-deadline/index.js +0 -111
  355. package/dist/with-deadline/index.js.map +0 -1
  356. package/dist/with-resilience/index.d.ts +0 -225
  357. package/dist/with-resilience/index.js +0 -240
  358. package/dist/with-resilience/index.js.map +0 -1
  359. package/dist/with-telemetry/index.d.ts +0 -150
  360. package/dist/with-telemetry/index.js +0 -70
  361. package/dist/with-telemetry/index.js.map +0 -1
  362. package/dist/work-queue/adapter.d.ts +0 -84
  363. package/dist/work-queue/adapter.js +0 -4
  364. package/dist/work-queue/adapter.js.map +0 -1
  365. package/dist/work-queue/ops.d.ts +0 -71
  366. package/dist/work-queue/ops.js +0 -3
  367. package/dist/work-queue/ops.js.map +0 -1
  368. package/dist/workflow/index.d.ts +0 -485
  369. package/dist/workflow/index.js +0 -244
  370. package/dist/workflow/index.js.map +0 -1
  371. /package/dist/{cache → paginate}/index.js.map +0 -0
  372. /package/dist/{chart/inspect → persistence}/index.js.map +0 -0
@@ -1,131 +0,0 @@
1
- import { C as Cmd, S as Sub, M as Machine } from '../core-Co0LWkIA.js';
2
- import 'zod';
3
-
4
- /**
5
- * @demlik/tea/prediction — the client-prediction ack primitive (epic #186, facet 2).
6
- *
7
- * The contract the Gambetta/Valve authoritative-server netcode loop needs:
8
- * **command-seq-in → last-applied-seq-out.** A client tags each predicted
9
- * command/`Msg` with a monotonic `seq`; the authoritative side replies with the
10
- * `lastAppliedSeq` it has processed. `partitionByAck` then splits the client's
11
- * pending buffer into the inputs the server has ACKED (`seq <= lastAppliedSeq`)
12
- * and those still PENDING (`seq > lastAppliedSeq`) — the un-acked tail the
13
- * reconciliation pass (#214) replays over the authoritative snapshot via
14
- * `foldMsgs` (#211, `@demlik/tea/pure`).
15
- *
16
- * Deliberately **Model-shape-agnostic** (ADR 0006): the ack is a standalone
17
- * value, NOT a field this module requires on the consumer's `State`. It
18
- * generalizes the `lastAckedSeq`-on-the-Model + `seq`-threaded-through-the-Msg
19
- * pattern vortex hand-rolled (epic #186). It is a LEAF module — pure and
20
- * runtime-free, importing nothing from the tea core or host, so it can never
21
- * drag `run`/the host into a client bundle.
22
- *
23
- * This is the read/ack side of the primitive; `tagSeq`/`nextSeq` are the write
24
- * side, letting a client mint monotonic seqs from its pending buffer alone —
25
- * again with no counter field on the Model.
26
- *
27
- * `reconcile` (the read side's payoff, #214) composes this ack partition with
28
- * the pure fold seam `foldMsgs` (#211) to perform the whole Gambetta/Valve
29
- * reconciliation step in one call. The `foldMsgs` import is the ONLY dependency
30
- * this leaf takes, and it reaches into the pure-core leaf (`../pure/core`) — NOT
31
- * the runtime root — so the module stays runtime-free and the `@demlik/tea/pure`
32
- * import-graph guard (ADR 0006, #213) still holds.
33
- */
34
-
35
- /**
36
- * A monotonic, non-negative sequence number tagging one client-predicted
37
- * command. Monotonicity is the client's contract (mint successive seqs with
38
- * `nextSeq`); this module only ever *compares* seqs.
39
- */
40
- type Seq = number;
41
- /** A command (or `Msg`) tagged with the `seq` the client assigned it. */
42
- interface SeqTagged<T> {
43
- readonly seq: Seq;
44
- readonly value: T;
45
- }
46
- /** Tag a command/`Msg` with its sequence number. */
47
- declare const tagSeq: <T>(seq: Seq, value: T) => SeqTagged<T>;
48
- /**
49
- * The authoritative side's acknowledgement: the highest `seq` it has applied.
50
- * Everything with `seq <= lastAppliedSeq` is settled; everything above is still
51
- * in flight. This *is* the whole "ack from the authoritative side" — a value
52
- * the consumer carries however it likes (a wire field, a message payload),
53
- * never a shape this module imposes on the Model.
54
- */
55
- interface Ack {
56
- readonly lastAppliedSeq: Seq;
57
- }
58
- /** Construct an `Ack` for a last-applied sequence number. */
59
- declare const ack: (lastAppliedSeq: Seq) => Ack;
60
- /**
61
- * The "nothing applied yet" cursor — the ack value for a server that has applied
62
- * no client input at all. Because `nextSeq` mints **0-based** seqs and
63
- * `partitionByAck` acks **inclusively** (`seq <= lastAppliedSeq`), the pre-first
64
- * cursor must sit strictly *below* seq 0: `lastAppliedSeq = 0` would falsely ack
65
- * the seq-0 input before the server ever saw it. `-1` is "before any seq", and
66
- * `partitionByAck(buffer, NO_ACK)` therefore leaves the whole buffer PENDING.
67
- *
68
- * This names the boundary value on the seam so no consumer has to re-discover it
69
- * as a magic number: it is the primitive's own design (0-based mint + inclusive
70
- * partition) that creates the trap, so it is the primitive's job to name the
71
- * escape. Pair with {@link initAck} when an {@link Ack} is wanted instead of the
72
- * bare `Seq`.
73
- */
74
- declare const NO_ACK: Seq;
75
- /**
76
- * The `Ack` for a server that has applied nothing yet — `ack(NO_ACK)`. The `Ack`
77
- * counterpart to the {@link NO_ACK} `Seq` sentinel, for a consumer that carries
78
- * an `Ack` rather than a bare `lastAppliedSeq`.
79
- */
80
- declare const initAck: () => Ack;
81
- /** The result of splitting a seq-tagged buffer against an ack. */
82
- interface AckPartition<T> {
83
- /** Inputs the authoritative side has applied (`seq <= lastAppliedSeq`). */
84
- readonly acked: readonly SeqTagged<T>[];
85
- /** Inputs still in flight / un-acked (`seq > lastAppliedSeq`) — the replay tail. */
86
- readonly pending: readonly SeqTagged<T>[];
87
- }
88
- /**
89
- * Partition a buffer of seq-tagged commands into ACKED and PENDING against the
90
- * authoritative `lastAppliedSeq`. Pure and total: every item lands in exactly
91
- * one bucket, input order is preserved within each bucket, and the boundary
92
- * `seq == lastAppliedSeq` is ACKED (inclusive `<=`). Routing is by `seq` value,
93
- * not buffer position, so an out-of-order or duplicate-seq buffer partitions
94
- * correctly. Accepts either an {@link Ack} or a bare `lastAppliedSeq` number, so
95
- * a caller passes whichever it holds.
96
- */
97
- declare const partitionByAck: <T>(buffer: readonly SeqTagged<T>[], ackOrSeq: Ack | Seq) => AckPartition<T>;
98
- /**
99
- * The next sequence number to assign: one past the highest `seq` in the buffer,
100
- * or `0` for an empty buffer. Lets a client mint monotonic seqs from its pending
101
- * buffer alone — no counter field on the Model — and is tolerant of an unordered
102
- * buffer (it takes the max, not the last element).
103
- */
104
- declare const nextSeq: <T>(buffer: readonly SeqTagged<T>[]) => Seq;
105
- /**
106
- * The client prediction/reconciliation helper — the Gambetta/Valve
107
- * authoritative-server loop's reconcile step, generalized (#214, epic #186).
108
- *
109
- * Given the latest `authoritativeState` from the server, the server's
110
- * `lastAppliedSeq` ack, and the client's `pending` buffer of seq-tagged inputs,
111
- * it returns the corrected predicted state: drop the inputs the server has
112
- * already applied (`seq <= lastAppliedSeq`) and replay ONLY the un-acked tail
113
- * (`seq > lastAppliedSeq`) over the authoritative snapshot.
114
- *
115
- * It is **composed, not re-derived** (ADR 0006): the drop is {@link partitionByAck}
116
- * (the ack primitive, #212) and the replay is `foldMsgs` (the pure fold seam,
117
- * #211) — there is no second copy of the partition logic and no second copy of
118
- * the fold. `lastAppliedSeq` accepts either an {@link Ack} or a bare `Seq`, so a
119
- * caller passes whichever it holds, matching `partitionByAck`.
120
- *
121
- * Pure and host-agnostic: it takes the `machine` (which `foldMsgs` needs to
122
- * dispatch `update`) but touches no `Store`, `interpret`, or subscription, and
123
- * imports nothing from the runtime — so it ships on `@demlik/tea/prediction`
124
- * and the client-safe `@demlik/tea/pure` umbrella without dragging `run` into a
125
- * client bundle.
126
- */
127
- declare function reconcile<S, M extends {
128
- type: string;
129
- }, C extends Cmd, U extends Sub, Ctx>(machine: Machine<S, M, C, U, Ctx>, authoritativeState: S, lastAppliedSeq: Ack | Seq, pending: readonly SeqTagged<M>[]): S;
130
-
131
- export { type Ack, type AckPartition, NO_ACK, type Seq, type SeqTagged, ack, initAck, nextSeq, partitionByAck, reconcile, tagSeq };
@@ -1,4 +0,0 @@
1
- export { NO_ACK, ack, initAck, nextSeq, partitionByAck, reconcile, tagSeq } from '../chunk-4EQZ76JC.js';
2
- import '../chunk-OOYD44JI.js';
3
- //# sourceMappingURL=index.js.map
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -1,45 +0,0 @@
1
- /**
2
- * The closed set of cross-module Msg/Cmd discriminant strings. Declared `as
3
- * const` so each entry is usable as both a value (construction / reducer keys /
4
- * switch labels) and, via `typeof MsgType.X`, a literal type (`readonly type:`
5
- * fields). The single source of truth for issue #60.
6
- */
7
- declare const MsgType: {
8
- /** The "run the port for `key`" effect Cmd resilient-call emits. */
9
- readonly ResilientRun: "resilient_run";
10
- /** PRIVATE success settle Msg (read only by `agentEvents`, #47). */
11
- readonly ResilientOk: "resilient_ok";
12
- /** Failure settle Msg — routed to the `fail` verb (back off via retry). */
13
- readonly ResilientErr: "resilient_err";
14
- /** Begin a run. */
15
- readonly AgentStart: "agent_start";
16
- /** PRIVATE tool-fan-out success settle Msg (read only by `agentEvents`, #47). */
17
- readonly AgentToolOk: "agent_tool_ok";
18
- /** Tool-fan-out failure settle Msg. */
19
- readonly AgentToolErr: "agent_tool_err";
20
- /**
21
- * Re-fire the one outstanding effect on rehydrate (the do↔agent seam). Fired
22
- * by `do/host`'s `autoBoot` via the typed `agentBootMsg` constructor, matched
23
- * by the agent reducer — see `AgentBootPort` in `../agent`.
24
- */
25
- readonly AgentBoot: "agent_boot";
26
- /**
27
- * The "summarize the oldest N turns" effect Cmd the agent emits when its
28
- * `CompactionPolicy` asks to compact before a brain call. A DEDICATED
29
- * round-trip (design B1), distinct from the brain call's `resilient_run`, so
30
- * compaction is its own honest `Awaiting` state — see `../agent`.
31
- */
32
- readonly CompactRun: "compact_run";
33
- /** Compaction round-trip resolved — carries the summary text the fold-back folds. */
34
- readonly CompactOk: "compact_ok";
35
- /** Compaction round-trip failed (exhausted retry) — surfaced as data, not a stall. */
36
- readonly CompactErr: "compact_err";
37
- /** Refresh port resolved — carries the fresh `Token`. */
38
- readonly TokenRefreshed: "token_refreshed";
39
- /** Refresh port rejected — carries the rejection (errors are data). */
40
- readonly TokenRefreshFailed: "token_refresh_failed";
41
- /** The 401 the consumer dispatches when a guarded call comes back unauthorized. */
42
- readonly Unauthorized: "unauthorized";
43
- };
44
-
45
- export { MsgType as M };
@@ -1,3 +0,0 @@
1
- export { Ack, AckPartition, NO_ACK, Seq, SeqTagged, ack, initAck, nextSeq, partitionByAck, reconcile, tagSeq } from '../prediction/index.js';
2
- export { A as AnyCmdDef, C as Cmd, h as CmdDef, i as CmdInput, e as CmdOf, j as CmdValue, k as ContextFree, D as DepKeyedSub, l as Dispose, E as ErrOf, m as ErrorsOf, n as Identity, I as Interpret, g as InterpretDetached, M as Machine, o as MachineShape, p as MalformedResult, q as Needs, f as NeedsOf, N as NoCellError, r as NoCtx, O as OkOf, a as Port, P as PortEmitter, c as Reducer, R as RequiredCtx, d as Settled, s as SettledErr, t as SettledOk, S as Sub, b as SubId, u as Subscribe, v as SyncReturn, w as Tagged, x as TaggedError, T as Transitions, U as UpdateForm, y as acceptsOf, F as describeMachine, G as detectUpdateForm, H as foldMsgs, K as formOf, Q as structuralHash, V as subId } from '../core-Co0LWkIA.js';
3
- import 'zod';
@@ -1,4 +0,0 @@
1
- export { NO_ACK, ack, initAck, nextSeq, partitionByAck, reconcile, tagSeq } from '../chunk-4EQZ76JC.js';
2
- export { Cmd, NoCellError, acceptsOf, describeMachine, detectUpdateForm, foldMsgs, formOf, structuralHash, subId } from '../chunk-OOYD44JI.js';
3
- //# sourceMappingURL=index.js.map
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -1,115 +0,0 @@
1
- /**
2
- * @demlik/tea/rate-limit — two rate limiters as pure state + ops.
3
- *
4
- * Same shape as `@demlik/tea/work-queue`'s `ops.ts`: a state type plus pure
5
- * transition functions. Host-agnostic by construction — no `Date.now()`, no
6
- * timers, no I/O. The caller injects the clock (`nowMs`) and wires the result
7
- * into its own reducer / interpret. This keeps the limiters inside TEA's
8
- * invariant 2 (transitions are pure: same inputs → same outputs, no `Date.now`)
9
- * so a consumer can fold them through `update` and exercise them with `replay`
10
- * / the pbt fold without a fake clock.
11
- *
12
- * Every op returns a NEW state value and never mutates its input (invariant 1 —
13
- * state is a value, not a place). The `tryConsume` / `record` ops return a
14
- * `[next, ok]` tuple so the caller branches on the decision while threading the
15
- * advanced state forward; `refill` / `remaining` are read-shaped helpers.
16
- *
17
- * Two complementary algorithms, picked by the cost the caller wants to pay:
18
- *
19
- * - **Token bucket** — O(1) state (four numbers), smooths bursts against a
20
- * steady refill rate. Allows a burst up to `capacity`, then throttles to
21
- * `refillPerSec`. Cheapest; the default choice.
22
- * - **Sliding window log** — O(limit) state (one timestamp per in-window
23
- * hit), exact "no more than `limit` events per `windowMs`". Pay the memory
24
- * for precise window edges when a token bucket's continuous refill would
25
- * let through too many at a boundary.
26
- *
27
- * NOT exported from the package root — reached via the `@demlik/tea/rate-limit`
28
- * subpath, same one-shape-per-package rule as `work-queue` and `do`.
29
- */
30
- /**
31
- * A token bucket: `tokens` of `capacity` available now, replenished at
32
- * `refillPerSec` tokens per second. `lastRefillMs` is the clock reading at
33
- * which `tokens` was last computed — `refill` advances it. All four fields are
34
- * plain numbers so the whole bucket is trivially JSON-serializable into a
35
- * consumer's `Store<S>`.
36
- */
37
- interface TokenBucket {
38
- readonly tokens: number;
39
- readonly capacity: number;
40
- readonly refillPerSec: number;
41
- readonly lastRefillMs: number;
42
- }
43
- /**
44
- * Create a full bucket. Starts at `capacity` tokens (the conventional "a fresh
45
- * limiter lets the first burst through" behavior) and stamps `lastRefillMs`
46
- * with the caller's clock so the first `refill` measures elapsed time from
47
- * boot, not from epoch 0.
48
- */
49
- declare function initBucket(capacity: number, refillPerSec: number, nowMs: number): TokenBucket;
50
- /**
51
- * Add the tokens accrued since `lastRefillMs`, clamped to `capacity`, and
52
- * advance `lastRefillMs` to `nowMs`. PURE — returns a new bucket; the input is
53
- * untouched.
54
- *
55
- * A `nowMs` at or before `lastRefillMs` (clock not advanced, or skewed
56
- * backwards) adds a non-positive amount; `Math.max(0, …)` floors the elapsed
57
- * term so a backwards clock can never *remove* tokens. `lastRefillMs` still
58
- * advances to `nowMs` so the bucket tracks the latest reading the caller
59
- * presented — the next forward step measures from there, not from a stale
60
- * future timestamp.
61
- */
62
- declare function refill(bucket: TokenBucket, nowMs: number): TokenBucket;
63
- /**
64
- * Refill against `nowMs`, then attempt to take `n` tokens (default 1).
65
- *
66
- * On success returns `[next, true]` with `n` subtracted; on failure returns
67
- * `[refilled, false]` — the refilled bucket (so the caller keeps the advanced
68
- * clock + accrued tokens) with no tokens spent. Branch on the boolean, thread
69
- * the bucket forward regardless:
70
- *
71
- * const [b1, ok] = tryConsume(bucket, nowMs);
72
- * return ok ? [{ ...state, bucket: b1 }, [doWork]] : [{ ...state, bucket: b1 }, []];
73
- *
74
- * PURE — input bucket is never mutated.
75
- */
76
- declare function tryConsume(bucket: TokenBucket, nowMs: number, n?: number): readonly [TokenBucket, boolean];
77
- /**
78
- * A sliding-window log: the timestamps of every hit still inside the trailing
79
- * `windowMs`, capped at `limit` events per window. `hits` is `readonly` and
80
- * kept oldest-first (pruning slices the stale prefix off the front, recording
81
- * appends to the back), so the array is its own sorted index. Exact at the
82
- * window edge — unlike a token bucket's continuous refill, a hit leaves the
83
- * count the instant it ages past `windowMs`.
84
- */
85
- interface SlidingWindow {
86
- readonly hits: readonly number[];
87
- readonly windowMs: number;
88
- readonly limit: number;
89
- }
90
- /** Create an empty window. No hits recorded yet. */
91
- declare function initWindow(windowMs: number, limit: number): SlidingWindow;
92
- /**
93
- * Prune hits older than `nowMs - windowMs`, then record `nowMs` if there is
94
- * room. Returns `[next, true]` with the hit appended when `hits.length < limit`
95
- * after pruning, else `[pruned, false]` — the pruned window (capacity recovers
96
- * as old hits age out) with nothing appended.
97
- *
98
- * The cutoff is half-open (see {@link prune}): a hit exactly `windowMs` old is
99
- * pruned, so a hit recorded at `t` no longer counts at `t + windowMs`. That
100
- * makes the window's capacity fully recover `windowMs` after the last hit, the
101
- * behavior tests pin.
102
- *
103
- * PURE — input window is never mutated; `hits` is rebuilt by `filter` +
104
- * spread.
105
- */
106
- declare function record(window: SlidingWindow, nowMs: number): readonly [SlidingWindow, boolean];
107
- /**
108
- * How many more hits `record` would accept at `nowMs` without blocking —
109
- * `limit` minus the live (post-prune) hit count, floored at 0. Read-only: it
110
- * prunes a local copy to answer but returns no new window. Use it to render a
111
- * "N requests remaining" affordance without committing a hit.
112
- */
113
- declare function remaining(window: SlidingWindow, nowMs: number): number;
114
-
115
- export { type SlidingWindow, type TokenBucket, initBucket, initWindow, record, refill, remaining, tryConsume };
@@ -1,3 +0,0 @@
1
- export { initBucket, initWindow, record, refill, remaining, tryConsume } from '../chunk-S2EGRPCM.js';
2
- //# sourceMappingURL=index.js.map
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -1,193 +0,0 @@
1
- import { CircuitConfig, RateLimitConfig, DeadlineConfig, ResilientPorts, RunCmd, FailMsg, SucceedMsg } from '../resilient-call/index.js';
2
- import { TtlCache } from '../cache/index.js';
3
- import { C as Cmd } from '../core-Co0LWkIA.js';
4
- import { PaginatedWalkState, PaginatedWalkTimerMsg, FetchPageCmd, PageErrMsg, PageOkMsg } from '../paginated-walk/index.js';
5
- import { RetryPolicy } from '../retry-backoff/index.js';
6
- import { DeadlineSub } from '../deadline/index.js';
7
- export { deadlineSub, subscribeDeadline } from '../deadline/index.js';
8
- import '../circuit-breaker/index.js';
9
- import '../protocol-B5YmJr0d.js';
10
- import '../rate-limit/index.js';
11
- import '../types-XS_miRnB.js';
12
- import 'zod';
13
- import '../paginator/index.js';
14
-
15
- /**
16
- * The reconciler knob. Generic in:
17
- * - `Actual` — one item of the ACTUAL world (a fleet node, an audited page, a
18
- * table row). The scan accumulates these.
19
- * - `Desired` — the DESIRED spec value the diff converges toward. Opaque to
20
- * this module; only `diff` reads it.
21
- * - `Page` — the shape one actual-list page fetch resolves with.
22
- * - `Change` — one unit of remediation the diff produces and `apply` realizes.
23
- * - `ApplyCmd`— the Cmd `apply(change)` yields (the effect that mutates the
24
- * actual world toward desired).
25
- *
26
- * `diff` / `apply` / `idOf` / `nextCursor` / `itemsOf` are PURE config functions
27
- * applied at the verb boundary, never stored in the slice or in a Cmd (Cmds are
28
- * plain data, not closures). The resilience bricks (`retry` / `circuit` /
29
- * `rateLimit` / `deadline`) are the SAME optional knobs `paginated-walk` /
30
- * `resilient-call` expose — reconciler extends them; `rateLimit` keeps the scan
31
- * from 429-ing the upstream listing API.
32
- */
33
- interface ReconcilerConfig<Actual, Desired, Page, Change, ApplyCmd extends Cmd, Cursor = number> {
34
- /**
35
- * The DESIRED spec to converge on. Held verbatim and handed to `diff` once the
36
- * scan completes. Any JSON-serializable value — a list of specs, a target map,
37
- * a single target object — `diff` alone interprets it.
38
- */
39
- readonly desired: Desired;
40
- /**
41
- * Compute the remediation plan: the ordered `Change[]` that moves `actual` to
42
- * `desired`. Called once when the scan finishes (the full actual snapshot is in
43
- * hand). An empty plan means "already in sync — nothing to apply". PURE +
44
- * consumer-specific (only the consumer knows the domain's reconcile rules).
45
- */
46
- readonly diff: (desired: Desired, actual: readonly Actual[]) => readonly Change[];
47
- /**
48
- * Realize one `Change` as the Cmd that mutates the actual world. Returns plain
49
- * data (a `{ type, ... }` Cmd the consumer's interpret handler performs).
50
- * PURE — the side effect happens when the runtime performs the emitted Cmd,
51
- * never here.
52
- */
53
- readonly apply: (change: Change) => ApplyCmd;
54
- /**
55
- * Stable identity for a `Change` — the applied-ledger cache key. A re-`applyNext`
56
- * after eviction (or after a re-plan) skips a change whose id is already in the
57
- * ledger (idempotent re-apply). MUST be a property of the change itself, NOT its
58
- * position in the plan: the ledger has to survive re-planning. When omitted the
59
- * default keys by the change's serialized CONTENT (`JSON.stringify(change)`) —
60
- * a stable per-change identity that is unchanged by where the change sits in the
61
- * plan. Supply a domain id (the target node id, the resource key) when one
62
- * exists; it is cheaper than serializing and dedupes two changes that differ
63
- * only in fields irrelevant to identity. PURE.
64
- *
65
- * Why NOT positional: keying by index silently drops changes on the documented
66
- * re-plan path. After applying the index-0 change, its `"0"` ledger entry would
67
- * match WHATEVER different, never-applied change lands at index 0 in the next
68
- * plan — the apply loop skips it as "already done". Identity must be intrinsic
69
- * to the change so the ledger means "this change settled", not "slot N settled".
70
- */
71
- readonly idOf?: (change: Change) => string;
72
- /**
73
- * The cursor the actual-list scan fetches first. For an offset API typically
74
- * `0`; for a token API whatever sentinel the API treats as page one.
75
- */
76
- readonly firstPage: Cursor;
77
- /**
78
- * Extract the next scan cursor from a fetched page — a `Cursor` to keep
79
- * scanning, or `null` when the actual listing is exhausted (scan finishes,
80
- * plan computed). PURE + consumer-specific.
81
- */
82
- readonly nextCursor: (page: Page) => Cursor | null;
83
- /**
84
- * Extract the actual items from one fetched page. Each page's items are
85
- * appended to the running `actual` accumulator. PURE.
86
- */
87
- readonly itemsOf: (page: Page) => readonly Actual[];
88
- /** Exponential-backoff retry policy for a transient scan-page failure. */
89
- readonly retry?: RetryPolicy;
90
- /** Circuit breaker around the scan fetch (one upstream → one breaker). */
91
- readonly circuit?: CircuitConfig;
92
- /** Token-bucket rate limit on the scan — the "don't 429 the listing API" knob. */
93
- readonly rateLimit?: RateLimitConfig;
94
- /** Overall wall-clock deadline per individual scan-page fetch. */
95
- readonly deadline?: DeadlineConfig;
96
- }
97
- /**
98
- * Reconcile lifecycle phase. Discriminated on `phase`:
99
- *
100
- * - `idle` — created, never scanned. `scan` starts the actual-world walk.
101
- * - `scanning` — the paginated-walk is traversing the actual listing; pages
102
- * fold into `actual` as they arrive. The scan owns the `walk`
103
- * sub-slice; this phase ends when the walk finishes.
104
- * - `applying` — the scan finished, `diff` produced the `plan`, and changes are
105
- * being applied one at a time. `appliedCursor` is the index of
106
- * the next change to apply.
107
- * - `done` — every planned change applied (or an empty plan: already in
108
- * sync). Terminal.
109
- * - `failed` — the scan failed terminally (the page-fetch retries were
110
- * exhausted / a deadline fired). `error` carries why. Terminal.
111
- */
112
- type ReconcilePhase = "idle" | "scanning" | "applying" | "done" | "failed";
113
- /**
114
- * The slice. Plain data end to end:
115
- * - `phase` — the lifecycle discriminant.
116
- * - `walk` — the `../paginated-walk` scan slice (cursor + resilience).
117
- * Drives the actual-world traversal; POSITION survives
118
- * eviction.
119
- * - `actual` — the accumulated actual items, appended page by page during
120
- * the scan. The full snapshot `diff` is computed against.
121
- * - `plan` — the `Change[]` `diff` produced. Empty until the scan
122
- * finishes; the apply loop walks it by `appliedCursor`.
123
- * - `appliedCursor` — index of the NEXT change to apply (0 ≤ cursor ≤ plan.length).
124
- * `cursor === plan.length` means every change applied.
125
- * - `applied` — the applied-ledger cache: `idOf(change) → change`, written
126
- * as each change settles. The idempotency memory the apply
127
- * loop reads to skip already-applied changes after eviction.
128
- */
129
- interface ReconcilerState<Actual, Change, Page, Cursor = number> {
130
- readonly phase: ReconcilePhase;
131
- readonly walk: PaginatedWalkState<Cursor, Page>;
132
- readonly actual: readonly Actual[];
133
- readonly plan: readonly Change[];
134
- readonly appliedCursor: number;
135
- readonly applied: TtlCache<Change>;
136
- }
137
- /**
138
- * The actual-list page-fetch effect: the inherited `resilient_run` Cmd from
139
- * paginated-walk, whose `input` is the `Cursor` to fetch and whose `key` is the
140
- * fixed `PAGE_KEY`. The consumer's `handlers(ports)` interprets it.
141
- */
142
- type ScanPageCmd<Cursor> = FetchPageCmd<Cursor>;
143
- /** Page-settled Msgs the scan `handlers` port dispatches back (inherited verbatim). */
144
- type ScanPageOkMsg<Page> = PageOkMsg<Page>;
145
- type ScanPageErrMsg = PageErrMsg;
146
- /** The scan retry / deadline timer Msg — inherited from paginated-walk. */
147
- type ReconcilerTimerMsg = PaginatedWalkTimerMsg;
148
- /**
149
- * Ports the consumer supplies to `handlers`. `run(cursor)` fetches ONE page of
150
- * the ACTUAL listing for the given cursor; throwing routes to `pageErr` (and
151
- * thus the scan backoff). Same shape as paginated-walk's port.
152
- */
153
- interface ReconcilerPorts<Cursor, Page> extends ResilientPorts<Cursor, Page> {
154
- }
155
- /**
156
- * Build a reconciler knob from `config`. `rng` is injected for the underlying
157
- * scan-retry jitter — pass a fixed `() => 0` in tests to pin backoff; defaults
158
- * to `Math.random` (read at the verb boundary inside resilient-call, never in a
159
- * reconciler verb). Inherited straight from paginated-walk.
160
- *
161
- * Returns the uniform L2 knob contract: `init()`, the verbs `scan` / `pageOk` /
162
- * `pageErr` / `planned` / `applyNext` / `applied` / `onTimer`, the derived
163
- * `isComplete`, `subs(state)`, and `handlers(ports)`.
164
- */
165
- declare function createReconciler<Actual, Desired, Page, Change, ApplyCmd extends Cmd = Cmd, Cursor = number>(config: ReconcilerConfig<Actual, Desired, Page, Change, ApplyCmd, Cursor>, rng?: () => number): {
166
- init: () => ReconcilerState<Actual, Change, Page, Cursor>;
167
- scan: (s: ReconcilerState<Actual, Change, Page, Cursor>, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
168
- pageOk: (s: ReconcilerState<Actual, Change, Page, Cursor>, page: Page, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
169
- pageErr: (s: ReconcilerState<Actual, Change, Page, Cursor>, error: unknown, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
170
- planned: (s: ReconcilerState<Actual, Change, Page, Cursor>, at: number, changes?: readonly Change[]) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
171
- applyNext: (s: ReconcilerState<Actual, Change, Page, Cursor>, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
172
- applied: (s: ReconcilerState<Actual, Change, Page, Cursor>, change: Change, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
173
- onTimer: (s: ReconcilerState<Actual, Change, Page, Cursor>, msg: ReconcilerTimerMsg) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
174
- isComplete: (s: ReconcilerState<Actual, Change, Page, Cursor>) => boolean;
175
- subs: (s: ReconcilerState<Actual, Change, Page, Cursor>) => readonly DeadlineSub[];
176
- handlers: (ports: ReconcilerPorts<Cursor, Page>) => {
177
- resilient_run: (cmd: RunCmd<Cursor>, ctx: Readonly<Record<never, never>>) => Promise<FailMsg | SucceedMsg<Page>>;
178
- };
179
- };
180
- /**
181
- * Lift a knob result `[slice, cmds]` into a host `[State, cmds]` where the slice
182
- * lives at `state.rec`. Convenience for the common single-slice host; hosts with
183
- * a differently-named field spread by hand. PURE — a thin record rebuild, no
184
- * clock / RNG.
185
- */
186
- declare function liftReconciler<S extends {
187
- rec: ReconcilerState<Actual, Change, Page, Cursor>;
188
- }, Actual, Change, Page, Cursor, C extends Cmd>(state: S, [slice, cmds]: readonly [
189
- ReconcilerState<Actual, Change, Page, Cursor>,
190
- readonly C[]
191
- ]): readonly [S, readonly C[]];
192
-
193
- export { DeadlineSub, type ReconcilePhase, type ReconcilerConfig, type ReconcilerPorts, type ReconcilerState, type ReconcilerTimerMsg, type ScanPageCmd, type ScanPageErrMsg, type ScanPageOkMsg, createReconciler, liftReconciler };