@graphrefly/ts 0.0.1 → 0.0.3

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 (333) hide show
  1. package/README.md +197 -117
  2. package/dist/actions-types-CH-XCU9O.d.cts +657 -0
  3. package/dist/actions-types-w2iPQTkv.d.ts +657 -0
  4. package/dist/adapters/index.cjs +5157 -2951
  5. package/dist/adapters/index.cjs.map +1 -1
  6. package/dist/adapters/index.d.cts +207 -70
  7. package/dist/adapters/index.d.ts +207 -70
  8. package/dist/adapters/index.js +3738 -1688
  9. package/dist/adapters/index.js.map +1 -1
  10. package/dist/adapters/nestjs/microservices.cjs +841 -0
  11. package/dist/adapters/nestjs/microservices.cjs.map +1 -0
  12. package/dist/adapters/nestjs/microservices.d.cts +45 -0
  13. package/dist/adapters/nestjs/microservices.d.ts +45 -0
  14. package/dist/adapters/nestjs/microservices.js +206 -0
  15. package/dist/adapters/nestjs/microservices.js.map +1 -0
  16. package/dist/adapters/nestjs/native.cjs +1391 -0
  17. package/dist/adapters/nestjs/native.cjs.map +1 -0
  18. package/dist/adapters/nestjs/native.d.cts +111 -0
  19. package/dist/adapters/nestjs/native.d.ts +111 -0
  20. package/dist/adapters/nestjs/native.js +577 -0
  21. package/dist/adapters/nestjs/native.js.map +1 -0
  22. package/dist/adapters/nestjs/websockets.cjs +924 -0
  23. package/dist/adapters/nestjs/websockets.cjs.map +1 -0
  24. package/dist/adapters/nestjs/websockets.d.cts +47 -0
  25. package/dist/adapters/nestjs/websockets.d.ts +47 -0
  26. package/dist/adapters/nestjs/websockets.js +286 -0
  27. package/dist/adapters/nestjs/websockets.js.map +1 -0
  28. package/dist/adapters/nestjs.cjs +1085 -0
  29. package/dist/adapters/nestjs.cjs.map +1 -0
  30. package/dist/adapters/nestjs.d.cts +385 -0
  31. package/dist/adapters/nestjs.d.ts +385 -0
  32. package/dist/adapters/nestjs.js +112 -0
  33. package/dist/adapters/nestjs.js.map +1 -0
  34. package/dist/adapters/observe-storage.d.cts +3 -3
  35. package/dist/adapters/observe-storage.d.ts +3 -3
  36. package/dist/adapters/observe-storage.js +4 -4
  37. package/dist/adapters/react.cjs.map +1 -1
  38. package/dist/adapters/react.d.cts +2 -2
  39. package/dist/adapters/react.d.ts +2 -2
  40. package/dist/adapters/react.js +1 -1
  41. package/dist/adapters/solid.cjs.map +1 -1
  42. package/dist/adapters/solid.d.cts +2 -2
  43. package/dist/adapters/solid.d.ts +2 -2
  44. package/dist/adapters/solid.js +1 -1
  45. package/dist/adapters/svelte.cjs.map +1 -1
  46. package/dist/adapters/svelte.d.cts +2 -2
  47. package/dist/adapters/svelte.d.ts +2 -2
  48. package/dist/adapters/svelte.js +1 -1
  49. package/dist/adapters/vue.cjs.map +1 -1
  50. package/dist/adapters/vue.d.cts +2 -2
  51. package/dist/adapters/vue.d.ts +2 -2
  52. package/dist/adapters/vue.js +1 -1
  53. package/dist/{agent-runtime-BesGDZcB.d.ts → agent-runtime-types-core-CKwrBDyi.d.ts} +171 -320
  54. package/dist/{agent-runtime-DZTJ3C-p.d.cts → agent-runtime-types-core-bfl4m0vM.d.cts} +171 -320
  55. package/dist/agent-runtime-types-tool-BLPV3azj.d.cts +695 -0
  56. package/dist/agent-runtime-types-tool-hwqvVqNt.d.ts +695 -0
  57. package/dist/agentic-memory-retention-CLwI76JK.d.ts +14 -0
  58. package/dist/agentic-memory-retention-Cz8GR6ie.d.cts +14 -0
  59. package/dist/{agentic-memory-DfuVZ-lY.d.cts → agentic-memory-types-JDr7MPhh.d.cts} +13 -57
  60. package/dist/{agentic-memory-BmRCvh0d.d.ts → agentic-memory-types-khYJgzKL.d.ts} +13 -57
  61. package/dist/{capability-admission-B0BzqAm5.d.cts → capability-admission-B8RNFyaZ.d.cts} +3 -3
  62. package/dist/{capability-admission-g0mn9hpq.d.ts → capability-admission-Dkw1Xz3r.d.ts} +3 -3
  63. package/dist/chunk-2KUAG2GZ.js +9693 -0
  64. package/dist/chunk-2KUAG2GZ.js.map +1 -0
  65. package/dist/{chunk-CZNV3VXM.js → chunk-3J7UPZL5.js} +11 -11
  66. package/dist/{chunk-HKK2JD7Z.js → chunk-3LYI6ADX.js} +12 -125
  67. package/dist/chunk-3LYI6ADX.js.map +1 -0
  68. package/dist/{chunk-YXMZ2N6J.js → chunk-4M37FH2I.js} +1071 -1025
  69. package/dist/chunk-4M37FH2I.js.map +1 -0
  70. package/dist/{chunk-YDSIVHRR.js → chunk-4NWSNI4K.js} +1598 -1584
  71. package/dist/chunk-4NWSNI4K.js.map +1 -0
  72. package/dist/{chunk-Z2ANQ6JW.js → chunk-4Q77MMJY.js} +2 -2
  73. package/dist/{chunk-SS2A464I.js → chunk-54WPEODM.js} +3 -3
  74. package/dist/chunk-54WPEODM.js.map +1 -0
  75. package/dist/chunk-6E76H4OU.js +132 -0
  76. package/dist/chunk-6E76H4OU.js.map +1 -0
  77. package/dist/chunk-7GOTIIQ7.js +819 -0
  78. package/dist/chunk-7GOTIIQ7.js.map +1 -0
  79. package/dist/{chunk-V7CIJE4B.js → chunk-DKFWDTVY.js} +92 -9
  80. package/dist/chunk-DKFWDTVY.js.map +1 -0
  81. package/dist/{chunk-FBUU43PM.js → chunk-E4QCH32M.js} +448 -446
  82. package/dist/chunk-E4QCH32M.js.map +1 -0
  83. package/dist/{chunk-XKXWK2KP.js → chunk-GXU6WFEJ.js} +1157 -1021
  84. package/dist/chunk-GXU6WFEJ.js.map +1 -0
  85. package/dist/{chunk-K3FXTC3I.js → chunk-HJACH5PU.js} +3 -3
  86. package/dist/{chunk-GTPCOEOZ.js → chunk-IDMLXLLG.js} +3 -3
  87. package/dist/{chunk-DKP56CSW.js → chunk-JKAYLDQV.js} +2 -2
  88. package/dist/{chunk-4VLAQHZI.js → chunk-K7FB3JTD.js} +17 -1
  89. package/dist/chunk-K7FB3JTD.js.map +1 -0
  90. package/dist/{chunk-43BKLFZU.js → chunk-KFURM6FM.js} +10 -10
  91. package/dist/{chunk-H75VXTGT.js → chunk-L6LDXRWE.js} +3 -3
  92. package/dist/{chunk-H75VXTGT.js.map → chunk-L6LDXRWE.js.map} +1 -1
  93. package/dist/chunk-MCOFHMUU.js +4131 -0
  94. package/dist/chunk-MCOFHMUU.js.map +1 -0
  95. package/dist/chunk-MQEQMS7B.js +1009 -0
  96. package/dist/chunk-MQEQMS7B.js.map +1 -0
  97. package/dist/chunk-MTELVIYR.js +1421 -0
  98. package/dist/chunk-MTELVIYR.js.map +1 -0
  99. package/dist/{chunk-3JR3EDB2.js → chunk-NNDIFUKX.js} +121 -115
  100. package/dist/chunk-NNDIFUKX.js.map +1 -0
  101. package/dist/{chunk-2747WN4Y.js → chunk-PUSRRALM.js} +3 -3
  102. package/dist/{chunk-QFY4AFY4.js → chunk-PVC7WDKI.js} +58 -52
  103. package/dist/chunk-PVC7WDKI.js.map +1 -0
  104. package/dist/{chunk-VTHLCFN4.js → chunk-RAHNUYA5.js} +2 -2
  105. package/dist/chunk-TQPCAIQI.js +612 -0
  106. package/dist/chunk-TQPCAIQI.js.map +1 -0
  107. package/dist/{chunk-IXZBUWSP.js → chunk-UEMN5URK.js} +2 -2
  108. package/dist/chunk-WOS7RJYZ.js +1320 -0
  109. package/dist/chunk-WOS7RJYZ.js.map +1 -0
  110. package/dist/{chunk-6PHB5CJS.js → chunk-ZLFRB6FI.js} +2 -2
  111. package/dist/composition/index.cjs +1228 -1076
  112. package/dist/composition/index.cjs.map +1 -1
  113. package/dist/composition/index.d.cts +3 -3
  114. package/dist/composition/index.d.ts +3 -3
  115. package/dist/composition/index.js +4 -4
  116. package/dist/core/index.cjs +1198 -1046
  117. package/dist/core/index.cjs.map +1 -1
  118. package/dist/core/index.d.cts +23 -2
  119. package/dist/core/index.d.ts +23 -2
  120. package/dist/core/index.js +2 -2
  121. package/dist/cqrs/index.d.cts +3 -3
  122. package/dist/cqrs/index.d.ts +3 -3
  123. package/dist/cqrs/messaging.d.cts +4 -4
  124. package/dist/cqrs/messaging.d.ts +4 -4
  125. package/dist/cqrs/work-queue.d.cts +5 -5
  126. package/dist/cqrs/work-queue.d.ts +5 -5
  127. package/dist/data-structures/index.cjs +1226 -1074
  128. package/dist/data-structures/index.cjs.map +1 -1
  129. package/dist/data-structures/index.d.cts +8 -7
  130. package/dist/data-structures/index.d.ts +8 -7
  131. package/dist/data-structures/index.js +6 -5
  132. package/dist/{describe-DYMw_l1C.d.cts → describe-BumQ-3_0.d.cts} +1 -1
  133. package/dist/{describe-BpyJuWkw.d.ts → describe-cYr_Z5zm.d.ts} +1 -1
  134. package/dist/executors/tool-provider-adapters.cjs +3091 -0
  135. package/dist/executors/tool-provider-adapters.cjs.map +1 -0
  136. package/dist/executors/tool-provider-adapters.d.cts +174 -0
  137. package/dist/executors/tool-provider-adapters.d.ts +174 -0
  138. package/dist/executors/tool-provider-adapters.js +1336 -0
  139. package/dist/executors/tool-provider-adapters.js.map +1 -0
  140. package/dist/executors/tool-provider-runtime.cjs +5178 -0
  141. package/dist/executors/tool-provider-runtime.cjs.map +1 -0
  142. package/dist/executors/tool-provider-runtime.d.cts +17 -0
  143. package/dist/executors/tool-provider-runtime.d.ts +17 -0
  144. package/dist/executors/tool-provider-runtime.js +15 -0
  145. package/dist/executors/tool-provider-runtime.js.map +1 -0
  146. package/dist/executors/tool-provider.cjs +6392 -0
  147. package/dist/executors/tool-provider.cjs.map +1 -0
  148. package/dist/executors/tool-provider.d.cts +60 -0
  149. package/dist/executors/tool-provider.d.ts +60 -0
  150. package/dist/executors/tool-provider.js +89 -0
  151. package/dist/executors/tool-provider.js.map +1 -0
  152. package/dist/executors/work-queue.d.cts +6 -6
  153. package/dist/executors/work-queue.d.ts +6 -6
  154. package/dist/graph/index.cjs +1499 -1341
  155. package/dist/graph/index.cjs.map +1 -1
  156. package/dist/graph/index.d.cts +9 -8
  157. package/dist/graph/index.d.ts +9 -8
  158. package/dist/graph/index.js +23 -22
  159. package/dist/{graph-DCEWh4T2.d.cts → graph-C1C-wb0L.d.cts} +266 -137
  160. package/dist/{graph-D-1-SQeC.d.ts → graph-CS0b4V9B.d.ts} +266 -137
  161. package/dist/{index-72VZC0-E.d.cts → index-DLrNopda.d.cts} +151 -10
  162. package/dist/{index-Bmxeu0nK.d.ts → index-DzJni3_6.d.ts} +151 -10
  163. package/dist/index.cjs +3397 -3140
  164. package/dist/index.cjs.map +1 -1
  165. package/dist/index.d.cts +12 -9
  166. package/dist/index.d.ts +12 -9
  167. package/dist/index.js +110 -109
  168. package/dist/inspection/boundary.d.cts +4 -4
  169. package/dist/inspection/boundary.d.ts +4 -4
  170. package/dist/measurements-BWAnochv.d.ts +294 -0
  171. package/dist/measurements-B_gJfD8h.d.cts +294 -0
  172. package/dist/messaging/index.cjs +57 -51
  173. package/dist/messaging/index.cjs.map +1 -1
  174. package/dist/messaging/index.d.cts +11 -276
  175. package/dist/messaging/index.d.ts +11 -276
  176. package/dist/messaging/index.js +1 -1
  177. package/dist/operators/index.cjs +1228 -1076
  178. package/dist/operators/index.cjs.map +1 -1
  179. package/dist/operators/index.d.cts +5 -5
  180. package/dist/operators/index.d.ts +5 -5
  181. package/dist/operators/index.js +5 -5
  182. package/dist/orchestration/index.cjs +8844 -6071
  183. package/dist/orchestration/index.cjs.map +1 -1
  184. package/dist/orchestration/index.d.cts +171 -224
  185. package/dist/orchestration/index.d.ts +171 -224
  186. package/dist/orchestration/index.js +42 -991
  187. package/dist/orchestration/index.js.map +1 -1
  188. package/dist/orchestration/messaging.d.cts +5 -8
  189. package/dist/orchestration/messaging.d.ts +5 -8
  190. package/dist/orchestration/work-queue.cjs +1243 -5
  191. package/dist/orchestration/work-queue.cjs.map +1 -1
  192. package/dist/orchestration/work-queue.d.cts +121 -10
  193. package/dist/orchestration/work-queue.d.ts +121 -10
  194. package/dist/orchestration/work-queue.js +1067 -4
  195. package/dist/orchestration/work-queue.js.map +1 -1
  196. package/dist/patterns/event-flow.cjs +6 -20
  197. package/dist/patterns/event-flow.cjs.map +1 -1
  198. package/dist/patterns/event-flow.d.cts +4 -4
  199. package/dist/patterns/event-flow.d.ts +4 -4
  200. package/dist/patterns/event-flow.js +2 -2
  201. package/dist/patterns/index.cjs +453 -465
  202. package/dist/patterns/index.cjs.map +1 -1
  203. package/dist/patterns/index.d.cts +6 -5
  204. package/dist/patterns/index.d.ts +6 -5
  205. package/dist/patterns/index.js +3 -3
  206. package/dist/process-types-BB7oRhX3.d.cts +200 -0
  207. package/dist/process-types-QNhyoYJ8.d.ts +200 -0
  208. package/dist/{reactive-collection-DNV0-gFi.d.cts → reactive-collection-BYlWvtnp.d.cts} +4 -34
  209. package/dist/{reactive-collection-BAmfrGjd.d.ts → reactive-collection-efOEdGFN.d.ts} +4 -34
  210. package/dist/{reactive-collection-storage-BNEldDyi.d.cts → reactive-collection-storage-BjoLsoiC.d.cts} +5 -5
  211. package/dist/{reactive-collection-storage-YZsAQsWK.d.ts → reactive-collection-storage-DwW6UuK_.d.ts} +5 -5
  212. package/dist/{reactive-map-DRD1LJ2H.d.cts → reactive-map-BHacbIqz.d.cts} +7 -2
  213. package/dist/{reactive-map-EsDiCmJk.d.ts → reactive-map-DN4Jyqnf.d.ts} +7 -2
  214. package/dist/render/index.d.cts +2 -2
  215. package/dist/render/index.d.ts +2 -2
  216. package/dist/scheduled-readiness-BmqXxnzX.d.ts +91 -0
  217. package/dist/scheduled-readiness-CYSw7KDE.d.cts +91 -0
  218. package/dist/semantic-memory-graph-B_LwbM-E.d.cts +30 -0
  219. package/dist/semantic-memory-graph-rsFNNhwn.d.ts +30 -0
  220. package/dist/{semantic-memory-graph-DKuNzuWw.d.cts → semantic-memory-graph-types-Y73bbwVI.d.cts} +2 -28
  221. package/dist/{semantic-memory-graph-uwbwJdhe.d.ts → semantic-memory-graph-types-safmPkuX.d.ts} +2 -28
  222. package/dist/solutions/index.cjs +6353 -6169
  223. package/dist/solutions/index.cjs.map +1 -1
  224. package/dist/solutions/index.d.cts +12 -10
  225. package/dist/solutions/index.d.ts +12 -10
  226. package/dist/solutions/index.js +5 -5
  227. package/dist/solutions/reactive-layout/browser/index.cjs +116 -108
  228. package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -1
  229. package/dist/solutions/reactive-layout/browser/index.d.cts +4 -4
  230. package/dist/solutions/reactive-layout/browser/index.d.ts +4 -4
  231. package/dist/solutions/reactive-layout/browser/index.js +3 -3
  232. package/dist/solutions/reactive-layout/index.cjs +3578 -3350
  233. package/dist/solutions/reactive-layout/index.cjs.map +1 -1
  234. package/dist/solutions/reactive-layout/index.d.cts +32 -576
  235. package/dist/solutions/reactive-layout/index.d.ts +32 -576
  236. package/dist/solutions/reactive-layout/index.js +65 -5
  237. package/dist/solutions/reactive-layout/node-canvas/index.cjs +127 -117
  238. package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -1
  239. package/dist/solutions/reactive-layout/node-canvas/index.d.cts +4 -4
  240. package/dist/solutions/reactive-layout/node-canvas/index.d.ts +4 -4
  241. package/dist/solutions/reactive-layout/node-canvas/index.js +3 -3
  242. package/dist/solutions/reactive-layout/react-native/index.cjs +127 -117
  243. package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -1
  244. package/dist/solutions/reactive-layout/react-native/index.d.cts +4 -4
  245. package/dist/solutions/reactive-layout/react-native/index.d.ts +4 -4
  246. package/dist/solutions/reactive-layout/react-native/index.js +3 -3
  247. package/dist/solutions/reactive-layout/skia/index.cjs +127 -117
  248. package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -1
  249. package/dist/solutions/reactive-layout/skia/index.d.cts +4 -4
  250. package/dist/solutions/reactive-layout/skia/index.d.ts +4 -4
  251. package/dist/solutions/reactive-layout/skia/index.js +3 -3
  252. package/dist/solutions/work-item/actions.cjs +1609 -1428
  253. package/dist/solutions/work-item/actions.cjs.map +1 -1
  254. package/dist/solutions/work-item/actions.d.cts +23 -184
  255. package/dist/solutions/work-item/actions.d.ts +23 -184
  256. package/dist/solutions/work-item/actions.js +1558 -934
  257. package/dist/solutions/work-item/actions.js.map +1 -1
  258. package/dist/solutions/work-item/scheduling.cjs +9181 -1838
  259. package/dist/solutions/work-item/scheduling.cjs.map +1 -1
  260. package/dist/solutions/work-item/scheduling.d.cts +1763 -328
  261. package/dist/solutions/work-item/scheduling.d.ts +1763 -328
  262. package/dist/solutions/work-item/scheduling.js +117 -3
  263. package/dist/solutions/work-item/work-queue.d.cts +7 -7
  264. package/dist/solutions/work-item/work-queue.d.ts +7 -7
  265. package/dist/sources/browser.cjs +1318 -1083
  266. package/dist/sources/browser.cjs.map +1 -1
  267. package/dist/sources/browser.d.cts +22 -6
  268. package/dist/sources/browser.d.ts +22 -6
  269. package/dist/sources/browser.js +4 -4
  270. package/dist/sources/browser.js.map +1 -1
  271. package/dist/sources/index.cjs +1318 -1083
  272. package/dist/sources/index.cjs.map +1 -1
  273. package/dist/sources/index.d.cts +4 -4
  274. package/dist/sources/index.d.ts +4 -4
  275. package/dist/sources/index.js +4 -4
  276. package/dist/sources/node.d.cts +3 -3
  277. package/dist/sources/node.d.ts +3 -3
  278. package/dist/storage/browser.cjs +16 -0
  279. package/dist/storage/browser.cjs.map +1 -1
  280. package/dist/storage/browser.js +3 -3
  281. package/dist/storage/index.cjs +16 -0
  282. package/dist/storage/index.cjs.map +1 -1
  283. package/dist/storage/index.d.cts +5 -4
  284. package/dist/storage/index.d.ts +5 -4
  285. package/dist/storage/index.js +6 -6
  286. package/dist/storage/node.cjs +16 -0
  287. package/dist/storage/node.cjs.map +1 -1
  288. package/dist/storage/node.js +3 -3
  289. package/dist/{store-C-joM4gh.d.ts → store-6_CHF6Ge.d.ts} +1 -1
  290. package/dist/{store-CNJwmT-h.d.cts → store-BljX8RkQ.d.cts} +1 -1
  291. package/dist/types-BAw2QVVE.d.cts +274 -0
  292. package/dist/types-BUbbbh4f.d.cts +34 -0
  293. package/dist/types-CMnzoL54.d.cts +457 -0
  294. package/dist/{types-CcPIn7sy.d.cts → types-CTN3XoMl.d.cts} +57 -108
  295. package/dist/types-CV_ohy5T.d.cts +357 -0
  296. package/dist/{types-BsJvElYZ.d.ts → types-DChxk1vK.d.ts} +57 -108
  297. package/dist/types-DRu7SnLV.d.ts +274 -0
  298. package/dist/types-DeID_FRl.d.ts +34 -0
  299. package/dist/types-IhKH0hGW.d.ts +357 -0
  300. package/dist/types-ePlD2uyT.d.ts +457 -0
  301. package/dist/{work-item-runtime-qaVgsL0T.d.cts → work-item-runtime-types-BTxLskN5.d.cts} +3 -93
  302. package/dist/{work-item-runtime-C3M79vE9.d.ts → work-item-runtime-types-DAsZbb2y.d.ts} +3 -93
  303. package/dist/work-queue/index.cjs +957 -953
  304. package/dist/work-queue/index.cjs.map +1 -1
  305. package/dist/work-queue/index.d.cts +9 -357
  306. package/dist/work-queue/index.d.ts +9 -357
  307. package/dist/work-queue/index.js +957 -953
  308. package/dist/work-queue/index.js.map +1 -1
  309. package/package.json +611 -513
  310. package/dist/chunk-3JR3EDB2.js.map +0 -1
  311. package/dist/chunk-4VLAQHZI.js.map +0 -1
  312. package/dist/chunk-6XAIOL3X.js +0 -2407
  313. package/dist/chunk-6XAIOL3X.js.map +0 -1
  314. package/dist/chunk-FBUU43PM.js.map +0 -1
  315. package/dist/chunk-HKK2JD7Z.js.map +0 -1
  316. package/dist/chunk-PC3BTTBE.js +0 -3217
  317. package/dist/chunk-PC3BTTBE.js.map +0 -1
  318. package/dist/chunk-QFY4AFY4.js.map +0 -1
  319. package/dist/chunk-SS2A464I.js.map +0 -1
  320. package/dist/chunk-V7CIJE4B.js.map +0 -1
  321. package/dist/chunk-XKXWK2KP.js.map +0 -1
  322. package/dist/chunk-YDSIVHRR.js.map +0 -1
  323. package/dist/chunk-YXMZ2N6J.js.map +0 -1
  324. /package/dist/{chunk-CZNV3VXM.js.map → chunk-3J7UPZL5.js.map} +0 -0
  325. /package/dist/{chunk-Z2ANQ6JW.js.map → chunk-4Q77MMJY.js.map} +0 -0
  326. /package/dist/{chunk-K3FXTC3I.js.map → chunk-HJACH5PU.js.map} +0 -0
  327. /package/dist/{chunk-GTPCOEOZ.js.map → chunk-IDMLXLLG.js.map} +0 -0
  328. /package/dist/{chunk-DKP56CSW.js.map → chunk-JKAYLDQV.js.map} +0 -0
  329. /package/dist/{chunk-43BKLFZU.js.map → chunk-KFURM6FM.js.map} +0 -0
  330. /package/dist/{chunk-2747WN4Y.js.map → chunk-PUSRRALM.js.map} +0 -0
  331. /package/dist/{chunk-VTHLCFN4.js.map → chunk-RAHNUYA5.js.map} +0 -0
  332. /package/dist/{chunk-IXZBUWSP.js.map → chunk-UEMN5URK.js.map} +0 -0
  333. /package/dist/{chunk-6PHB5CJS.js.map → chunk-ZLFRB6FI.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/messaging/index.ts"],"sourcesContent":["/**\n * Reusable application-infrastructure messaging namespace.\n *\n * D279/D282/D284/D285/D276: messageBus is a retained topic-log plus independent\n * subscription-cursor substrate. DynamicHub is intentionally retired; do not add aliases.\n */\n\nimport { depBatch, type NodeFn } from \"../ctx/types.js\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { LockId, PullDemand } from \"../protocol/messages.js\";\nimport {\n\tattachMessageBusCommandSource,\n\tgetMessageBusState,\n\tregisterMessageBusState,\n} from \"./internal.js\";\n\nexport interface MessageEnvelope<T = unknown> {\n\treadonly topic: string;\n\treadonly seq: number;\n\treadonly payload: T;\n\treadonly key?: string;\n\treadonly idempotencyKey?: string;\n\treadonly timestampMs: number;\n\treadonly commandId?: string;\n}\n\n/** Minimal JSON Schema vocabulary for passive topic payload descriptions (D125/D132). */\nexport interface JsonSchema {\n\treadonly type?:\n\t\t| \"string\"\n\t\t| \"number\"\n\t\t| \"integer\"\n\t\t| \"boolean\"\n\t\t| \"object\"\n\t\t| \"array\"\n\t\t| \"null\"\n\t\t| readonly (\"string\" | \"number\" | \"integer\" | \"boolean\" | \"object\" | \"array\" | \"null\")[];\n\treadonly properties?: Readonly<Record<string, JsonSchema>>;\n\treadonly required?: readonly string[];\n\treadonly additionalProperties?: boolean | JsonSchema;\n\treadonly items?: JsonSchema | readonly JsonSchema[];\n\treadonly enum?: readonly unknown[];\n\treadonly const?: unknown;\n\treadonly $ref?: string;\n\treadonly definitions?: Readonly<Record<string, JsonSchema>>;\n\treadonly description?: string;\n\treadonly title?: string;\n}\n\n/** Passive envelope for payloads that cross topic, agent, or graph boundaries. */\nexport interface TopicMessage<T = unknown> {\n\treadonly id: string;\n\treadonly schema?: JsonSchema;\n\treadonly expiresAt?: string;\n\treadonly correlationId?: string;\n\treadonly payload: T;\n}\n\n/** Passive domain event vocabulary for messageBus/eventFlow composition (D329). */\nexport interface EventMessage<T = unknown> {\n\treadonly id: string;\n\treadonly type: string;\n\treadonly payload: T;\n\treadonly key?: string;\n\treadonly subjectId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly occurredAtMs?: number;\n\treadonly actor?: string;\n\treadonly evidenceRefs?: readonly string[];\n\treadonly schema?: JsonSchema;\n\treadonly metadata?: Readonly<Record<string, unknown>>;\n}\n\nexport interface EventMessageOptions {\n\treadonly id: string;\n\treadonly key?: string;\n\treadonly subjectId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly occurredAtMs?: number;\n\treadonly actor?: string;\n\treadonly evidenceRefs?: readonly string[];\n\treadonly schema?: JsonSchema;\n\treadonly metadata?: Readonly<Record<string, unknown>>;\n}\n\nexport function eventMessage<T>(\n\ttype: string,\n\tpayload: T,\n\topts: EventMessageOptions,\n): EventMessage<T> {\n\tassertNonEmpty(type, \"eventMessage.type\");\n\tassertNonEmpty(opts.id, \"eventMessage.id\");\n\treturn {\n\t\tid: opts.id,\n\t\ttype,\n\t\tpayload,\n\t\t...(opts.key === undefined ? {} : { key: opts.key }),\n\t\t...(opts.subjectId === undefined ? {} : { subjectId: opts.subjectId }),\n\t\t...(opts.correlationId === undefined ? {} : { correlationId: opts.correlationId }),\n\t\t...(opts.causationId === undefined ? {} : { causationId: opts.causationId }),\n\t\t...(opts.occurredAtMs === undefined ? {} : { occurredAtMs: opts.occurredAtMs }),\n\t\t...(opts.actor === undefined ? {} : { actor: opts.actor }),\n\t\t...(opts.evidenceRefs === undefined ? {} : { evidenceRefs: opts.evidenceRefs }),\n\t\t...(opts.schema === undefined ? {} : { schema: opts.schema }),\n\t\t...(opts.metadata === undefined ? {} : { metadata: opts.metadata }),\n\t};\n}\n\nexport function isEventMessage(value: unknown): value is EventMessage {\n\treturn eventMessageIssue(value) === undefined;\n}\n\nexport function eventMessageIssue(value: unknown): DataIssue | undefined {\n\tif (!isObjectRecord(value)) {\n\t\treturn eventIssue(\"event message must be an object\");\n\t}\n\tif (typeof value.id !== \"string\" || value.id.length === 0) {\n\t\treturn eventIssue(\"event message id must be a non-empty string\");\n\t}\n\tif (typeof value.type !== \"string\" || value.type.length === 0) {\n\t\treturn eventIssue(\"event message type must be a non-empty string\");\n\t}\n\tif (!(\"payload\" in value)) {\n\t\treturn eventIssue(\"event message payload field is required\");\n\t}\n\treturn undefined;\n}\n\nfunction eventIssue(message: string): DataIssue {\n\treturn {\n\t\tkind: \"issue\",\n\t\tcode: \"malformed-event-message\",\n\t\tmessage,\n\t\tseverity: \"error\",\n\t\tsource: \"messageBus.eventMessage\",\n\t};\n}\n\nexport const PROMPTS_TOPIC = \"prompts\";\nexport const RESPONSES_TOPIC = \"responses\";\nexport const INJECTIONS_TOPIC = \"injections\";\nexport const DEFERRED_TOPIC = \"deferred\";\nexport const SPAWNS_TOPIC = \"spawns\";\nexport const CONTEXT_TOPIC = \"context\";\nexport const TODOS_TOPIC = \"todos\";\n\nexport const STANDARD_TOPICS = Object.freeze([\n\tPROMPTS_TOPIC,\n\tRESPONSES_TOPIC,\n\tINJECTIONS_TOPIC,\n\tDEFERRED_TOPIC,\n\tSPAWNS_TOPIC,\n\tCONTEXT_TOPIC,\n\tTODOS_TOPIC,\n] as const);\n\nexport type StandardTopic = (typeof STANDARD_TOPICS)[number];\n\nexport type MessageBusTopicPolicy = \"strict\" | \"create-as-fact\";\n\nexport interface MessageBusRetentionPolicy {\n\t/** Count retention. Trimming advances headSeq and never rewrites seq (D284). */\n\treadonly maxMessages?: number;\n}\n\nexport interface MessageBusDedupePolicy {\n\t/** Duplicate commandId emits status and never publishes a second retained message (D284). */\n\treadonly commandId?: \"status\" | \"issue\";\n}\n\nexport interface MessageBusOptions<TTopic extends string = string> {\n\treadonly topics?: readonly TTopic[];\n\treadonly name?: string;\n\treadonly now?: () => number;\n\treadonly topicPolicy?: MessageBusTopicPolicy;\n\treadonly retention?: MessageBusRetentionPolicy;\n\treadonly dedupe?: MessageBusDedupePolicy;\n}\n\nexport type MessageBusCommand<T = unknown> =\n\t| {\n\t\t\treadonly kind: \"ensure-topic\";\n\t\t\treadonly topic: string;\n\t\t\treadonly commandId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"close-topic\";\n\t\t\treadonly topic: string;\n\t\t\treadonly commandId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"publish\";\n\t\t\treadonly topic: string;\n\t\t\treadonly payload: T;\n\t\t\treadonly key?: string;\n\t\t\treadonly commandId?: string;\n\t\t\treadonly idempotencyKey?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"topic-policy\";\n\t\t\treadonly topicPolicy: MessageBusTopicPolicy;\n\t\t\treadonly commandId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"ack\";\n\t\t\treadonly topic: string;\n\t\t\treadonly subscriptionId: string;\n\t\t\treadonly seq: number;\n\t\t\treadonly commandId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"seek\";\n\t\t\treadonly topic: string;\n\t\t\treadonly subscriptionId: string;\n\t\t\treadonly nextSeq: number;\n\t\t\treadonly commandId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"close-subscription\";\n\t\t\treadonly topic: string;\n\t\t\treadonly subscriptionId: string;\n\t\t\treadonly commandId?: string;\n\t };\n\nexport type MessageBusMessage<T = unknown> = MessageEnvelope<T>;\n\nexport interface MessageBusStatus {\n\treadonly kind:\n\t\t| \"topic-created\"\n\t\t| \"topic-closed\"\n\t\t| \"message-published\"\n\t\t| \"retention-trimmed\"\n\t\t| \"duplicate-command\"\n\t\t| \"subscription-acked\"\n\t\t| \"subscription-sought\"\n\t\t| \"subscription-closed\"\n\t\t| \"command-rejected\"\n\t\t| \"projection-ready\"\n\t\t| \"projection-partial\";\n\treadonly topic?: string;\n\treadonly seq?: number;\n\treadonly headSeq?: number;\n\treadonly subscriptionId?: string;\n\treadonly nextSeq?: number;\n\treadonly commandId?: string;\n\treadonly issueCode?: string;\n\treadonly timestampMs: number;\n\treadonly details?: unknown;\n}\n\nexport interface MessageBusCatalogEntry {\n\treadonly topic: string;\n\treadonly closed: boolean;\n\treadonly headSeq: number;\n\treadonly nextSeq: number;\n\treadonly messageCount: number;\n}\n\nexport interface MessageBusCatalogPage {\n\treadonly topics: readonly MessageBusCatalogEntry[];\n\treadonly nextAfterTopic?: string;\n\treadonly hasMore: boolean;\n}\n\nexport interface MessageBusDeadLetterEntry<T = unknown> {\n\treadonly entrySeq: number;\n\treadonly topic?: string;\n\treadonly command?: MessageBusCommand<T>;\n\treadonly message?: MessageBusMessage<T>;\n\treadonly issue: DataIssue;\n\treadonly timestampMs: number;\n}\n\nexport interface MessageBusDeadLetterPage<T = unknown> {\n\treadonly entries: readonly MessageBusDeadLetterEntry<T>[];\n\treadonly nextAfterEntrySeq?: number;\n\treadonly hasMore: boolean;\n}\n\nexport interface MessageBusTopicPage<T = unknown> {\n\treadonly topic: string;\n\treadonly messages: readonly MessageBusMessage<T>[];\n\treadonly fromSeq: number;\n\treadonly throughSeq?: number;\n\treadonly nextAfterSeq?: number;\n\treadonly hasMore: boolean;\n}\n\nexport interface MessageBusCursor {\n\treadonly topic: string;\n\treadonly subscriptionId: string;\n\treadonly nextSeq: number;\n\treadonly closed: boolean;\n\treadonly retentionGap: boolean;\n\treadonly headSeq: number;\n}\n\nexport interface MessageBusAvailablePage<T = unknown> {\n\treadonly topic: string;\n\treadonly subscriptionId: string;\n\treadonly cursor: MessageBusCursor;\n\treadonly messages: readonly MessageBusMessage<T>[];\n\treadonly fromSeq: number;\n\treadonly throughSeq?: number;\n\treadonly nextAfterSeq?: number;\n\treadonly hasMore: boolean;\n}\n\nexport interface MessageBusPageParams {\n\treadonly limit?: number;\n}\n\nexport interface MessageBusCatalogParams extends MessageBusPageParams {\n\treadonly afterTopic?: string;\n\treadonly includeClosed?: boolean;\n}\n\nexport interface MessageBusDeadLetterParams extends MessageBusPageParams {\n\treadonly afterEntrySeq?: number;\n\treadonly topic?: string;\n\treadonly code?: string;\n}\n\nexport interface MessageBusTopicParams extends MessageBusPageParams {\n\treadonly afterSeq?: number;\n}\n\nexport interface MessageBusAvailableParams extends MessageBusPageParams {\n\treadonly afterSeq?: number;\n}\n\nexport interface MessageBusPullProjection<TPage> {\n\treadonly snapshot: Node<TPage>;\n\treadonly snapshotPullId: LockId;\n\treadonly status: Node<MessageBusStatus>;\n\treadonly issues: Node<DataIssue>;\n}\n\nexport interface MessageBusTopicProjection<T = unknown>\n\textends MessageBusPullProjection<MessageBusTopicPage<T>> {}\n\nexport interface MessageBusSubscription<T = unknown> {\n\treadonly available: Node<MessageBusAvailablePage<T>>;\n\treadonly availablePullId: LockId;\n\treadonly cursor: Node<MessageBusCursor>;\n\treadonly status: Node<MessageBusStatus>;\n\treadonly issues: Node<DataIssue>;\n\tack(seq: number, opts?: { commandId?: string }): MessageBusCommand;\n\tseek(nextSeq: number, opts?: { commandId?: string }): MessageBusCommand;\n\tclose(opts?: { commandId?: string }): MessageBusCommand;\n}\n\nexport interface MessageBus<TTopic extends string = string> {\n\treadonly commands: Node<MessageBusCommand>;\n\treadonly messages: Node<MessageBusMessage>;\n\treadonly status: Node<MessageBusStatus>;\n\treadonly issues: Node<DataIssue>;\n\tensureTopic(topic: TTopic | string, opts?: { commandId?: string }): MessageBusCommand;\n\tcloseTopic(topic: TTopic | string, opts?: { commandId?: string }): MessageBusCommand;\n\tpublish<T = unknown>(\n\t\ttopic: TTopic | string,\n\t\tpayload: T,\n\t\topts?: { key?: string; commandId?: string; idempotencyKey?: string },\n\t): MessageBusCommand<T>;\n\ttopic<T = unknown>(\n\t\ttopic: TTopic | string,\n\t\topts?: { name?: string },\n\t): MessageBusTopicProjection<T>;\n\tcatalog(opts?: { name?: string }): MessageBusPullProjection<MessageBusCatalogPage>;\n\tdeadLetter<T = unknown>(opts?: {\n\t\tname?: string;\n\t}): MessageBusPullProjection<MessageBusDeadLetterPage<T>>;\n\tsubscription<T = unknown>(opts: {\n\t\ttopic: TTopic | string;\n\t\tsubscriptionId: string;\n\t\tfrom?: \"earliest\" | \"latest\" | number;\n\t\tname?: string;\n\t}): MessageBusSubscription<T>;\n}\n\nexport interface ToTopicOptions {\n\treadonly name?: string;\n\treadonly keyOf?: (value: unknown) => string | undefined;\n\treadonly commandIdOf?: (value: unknown) => string | undefined;\n}\n\nexport interface ToTopicBundle<T> {\n\treadonly commands: Node<MessageBusCommand<T>>;\n\trelease(): void;\n}\n\ninterface TopicState {\n\tclosed: boolean;\n\theadSeq: number;\n\tnextSeq: number;\n\tmessages: MessageBusMessage[];\n}\n\ninterface SubscriptionState {\n\ttopic: string;\n\tsubscriptionId: string;\n\tnextSeq: number;\n\tclosed: boolean;\n\tretentionGap: boolean;\n}\n\ntype RuntimeEvent<T = unknown> =\n\t| { readonly kind: \"message\"; readonly message: MessageBusMessage<T> }\n\t| { readonly kind: \"status\"; readonly status: MessageBusStatus }\n\t| { readonly kind: \"issue\"; readonly issue: DataIssue }\n\t| { readonly kind: \"dead-letter\"; readonly entry: MessageBusDeadLetterEntry<T> };\n\ninterface MessageBusState {\n\treadonly graph: Graph;\n\treadonly name: string;\n\treadonly now: () => number;\n\ttopicPolicy: MessageBusTopicPolicy;\n\treadonly retention: MessageBusRetentionPolicy;\n\treadonly dedupe: MessageBusDedupePolicy;\n\treadonly topics: Map<string, TopicState>;\n\treadonly subscriptions: Map<string, SubscriptionState>;\n\treadonly seenCommandIds: Set<string>;\n\treadonly seenIdempotencyKeys: Set<string>;\n\treadonly deadLetters: MessageBusDeadLetterEntry[];\n\tdeadLetterSeq: number;\n\treadonly commandSources: Node<MessageBusCommand>[];\n\treadonly commandBody: NodeFn;\n}\n\nexport function messageBus<TTopic extends string>(\n\tgraph: Graph,\n\topts: MessageBusOptions<TTopic> = {},\n): MessageBus<TTopic> {\n\tconst name = opts.name ?? \"messageBus\";\n\tconst initialTopics = uniqueTopics(opts.topics ?? []);\n\tconst commandSources: Node<MessageBusCommand>[] = [];\n\tconst commandBody: NodeFn = (ctx) => {\n\t\tfor (let i = 0; i < commandSources.length; i++) {\n\t\t\tfor (const command of depBatch(ctx, i) ?? []) ctx.down([[\"DATA\", command]]);\n\t\t}\n\t};\n\tconst commands = graph.node<MessageBusCommand>([], commandBody, {\n\t\tname: `${name}/commands`,\n\t\tfactory: \"messageBusCommands\",\n\t\tcompleteWhenDepsComplete: false,\n\t\terrorWhenDepsError: false,\n\t});\n\tconst state: MessageBusState = {\n\t\tgraph,\n\t\tname,\n\t\tnow: opts.now ?? Date.now,\n\t\ttopicPolicy: opts.topicPolicy ?? \"strict\",\n\t\tretention: opts.retention ?? {},\n\t\tdedupe: opts.dedupe ?? { commandId: \"status\" },\n\t\ttopics: new Map(initialTopics.map((topic) => [topic, makeTopicState()])),\n\t\tsubscriptions: new Map(),\n\t\tseenCommandIds: new Set(),\n\t\tseenIdempotencyKeys: new Set(),\n\t\tdeadLetters: [],\n\t\tdeadLetterSeq: 0,\n\t\tcommandSources,\n\t\tcommandBody,\n\t};\n\tconst runtime = graph.node<RuntimeEvent>(\n\t\t[commands],\n\t\t(ctx) => {\n\t\t\tfor (const command of depBatch(ctx, 0) ?? []) {\n\t\t\t\tfor (const event of reduceMessageBusCommand(state, command as MessageBusCommand)) {\n\t\t\t\t\tctx.down([[\"DATA\", event]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/runtime`,\n\t\t\tfactory: \"messageBusRuntime\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tgraph.retain(runtime, { reason: `${name}.messageBus.runtime` });\n\tconst messages = graph.node<MessageBusMessage>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as RuntimeEvent;\n\t\t\t\tif (typed.kind === \"message\") ctx.down([[\"DATA\", typed.message]]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/messages`,\n\t\t\tfactory: \"messageBusMessages\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst status = graph.node<MessageBusStatus>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as RuntimeEvent;\n\t\t\t\tif (typed.kind === \"status\") ctx.down([[\"DATA\", typed.status]]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/status`,\n\t\t\tfactory: \"messageBusStatus\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst issues = graph.node<DataIssue>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as RuntimeEvent;\n\t\t\t\tif (typed.kind === \"issue\") ctx.down([[\"DATA\", typed.issue]]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/issues`,\n\t\t\tfactory: \"messageBusIssues\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\n\tconst bus: MessageBus<TTopic> = {\n\t\tcommands,\n\t\tmessages,\n\t\tstatus,\n\t\tissues,\n\t\tensureTopic(topic, commandOpts = {}) {\n\t\t\treturn publishCommand(commands, {\n\t\t\t\tkind: \"ensure-topic\",\n\t\t\t\ttopic,\n\t\t\t\t...(commandOpts.commandId === undefined ? {} : { commandId: commandOpts.commandId }),\n\t\t\t});\n\t\t},\n\t\tcloseTopic(topic, commandOpts = {}) {\n\t\t\treturn publishCommand(commands, {\n\t\t\t\tkind: \"close-topic\",\n\t\t\t\ttopic,\n\t\t\t\t...(commandOpts.commandId === undefined ? {} : { commandId: commandOpts.commandId }),\n\t\t\t});\n\t\t},\n\t\tpublish<T = unknown>(\n\t\t\ttopic: TTopic | string,\n\t\t\tpayload: T,\n\t\t\tpublishOpts: { key?: string; commandId?: string; idempotencyKey?: string } = {},\n\t\t) {\n\t\t\treturn publishCommand(commands, {\n\t\t\t\tkind: \"publish\",\n\t\t\t\ttopic,\n\t\t\t\tpayload,\n\t\t\t\t...(publishOpts.key === undefined ? {} : { key: publishOpts.key }),\n\t\t\t\t...(publishOpts.commandId === undefined ? {} : { commandId: publishOpts.commandId }),\n\t\t\t\t...(publishOpts.idempotencyKey === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { idempotencyKey: publishOpts.idempotencyKey }),\n\t\t\t});\n\t\t},\n\t\ttopic<T = unknown>(topic: TTopic | string, projectionOpts: { name?: string } = {}) {\n\t\t\tassertTopicKey(topic, \"messageBus.topic\");\n\t\t\tconst snapshotPullId = Symbol(`${name}/${topic}/topicSnapshot`);\n\t\t\tconst snapshot = graph.node<MessageBusTopicPage<T>>(\n\t\t\t\t[messages],\n\t\t\t\t(ctx) => {\n\t\t\t\t\tconst params = pullParams<MessageBusTopicParams>(ctx.pull);\n\t\t\t\t\tctx.down([[\"DATA\", topicPage<T>(state, topic, params)]]);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: projectionOpts.name ?? `${name}/${topic}/topic`,\n\t\t\t\t\tfactory: \"messageBusTopicProjection\",\n\t\t\t\t\tmeta: { topic },\n\t\t\t\t\tpullId: snapshotPullId,\n\t\t\t\t\tpartial: true,\n\t\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\t\terrorWhenDepsError: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { snapshot, snapshotPullId, status, issues };\n\t\t},\n\t\tcatalog(projectionOpts: { name?: string } = {}) {\n\t\t\tconst snapshotPullId = Symbol(`${name}/catalogSnapshot`);\n\t\t\tconst snapshot = graph.node<MessageBusCatalogPage>(\n\t\t\t\t[runtime],\n\t\t\t\t(ctx) => {\n\t\t\t\t\tconst params = pullParams<MessageBusCatalogParams>(ctx.pull);\n\t\t\t\t\tctx.down([[\"DATA\", catalogPage(state, params)]]);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: projectionOpts.name ?? `${name}/catalog`,\n\t\t\t\t\tfactory: \"messageBusCatalog\",\n\t\t\t\t\tpullId: snapshotPullId,\n\t\t\t\t\tpartial: true,\n\t\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\t\terrorWhenDepsError: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { snapshot, snapshotPullId, status, issues };\n\t\t},\n\t\tdeadLetter<T = unknown>(projectionOpts: { name?: string } = {}) {\n\t\t\tconst snapshotPullId = Symbol(`${name}/deadLetterSnapshot`);\n\t\t\tconst snapshot = graph.node<MessageBusDeadLetterPage<T>>(\n\t\t\t\t[runtime],\n\t\t\t\t(ctx) => {\n\t\t\t\t\tconst params = pullParams<MessageBusDeadLetterParams>(ctx.pull);\n\t\t\t\t\tctx.down([[\"DATA\", deadLetterPage<T>(state, params)]]);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: projectionOpts.name ?? `${name}/deadLetter`,\n\t\t\t\t\tfactory: \"messageBusDeadLetter\",\n\t\t\t\t\tpullId: snapshotPullId,\n\t\t\t\t\tpartial: true,\n\t\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\t\terrorWhenDepsError: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { snapshot, snapshotPullId, status, issues };\n\t\t},\n\t\tsubscription<T = unknown>(subscriptionOpts: {\n\t\t\ttopic: TTopic | string;\n\t\t\tsubscriptionId: string;\n\t\t\tfrom?: \"earliest\" | \"latest\" | number;\n\t\t\tname?: string;\n\t\t}) {\n\t\t\tassertTopicKey(subscriptionOpts.topic, \"messageBus.subscription\");\n\t\t\tassertNonEmpty(subscriptionOpts.subscriptionId, \"messageBus.subscriptionId\");\n\t\t\tconst sub = ensureSubscription(state, {\n\t\t\t\ttopic: subscriptionOpts.topic,\n\t\t\t\tsubscriptionId: subscriptionOpts.subscriptionId,\n\t\t\t\tfrom: subscriptionOpts.from ?? \"earliest\",\n\t\t\t});\n\t\t\tconst availablePullId = Symbol(\n\t\t\t\t`${name}/${subscriptionOpts.topic}/${subscriptionOpts.subscriptionId}/available`,\n\t\t\t);\n\t\t\tconst projectionName =\n\t\t\t\tsubscriptionOpts.name ??\n\t\t\t\t`${name}/${subscriptionOpts.topic}/${subscriptionOpts.subscriptionId}`;\n\t\t\tconst available = graph.node<MessageBusAvailablePage<T>>(\n\t\t\t\t[messages, status],\n\t\t\t\t(ctx) => {\n\t\t\t\t\tconst params = pullParams<MessageBusAvailableParams>(ctx.pull);\n\t\t\t\t\tctx.down([[\"DATA\", availablePage<T>(state, sub, params)]]);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: `${projectionName}/available`,\n\t\t\t\t\tfactory: \"messageBusSubscriptionAvailable\",\n\t\t\t\t\tmeta: { topic: subscriptionOpts.topic, subscriptionId: subscriptionOpts.subscriptionId },\n\t\t\t\t\tpullId: availablePullId,\n\t\t\t\t\tpartial: true,\n\t\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\t\terrorWhenDepsError: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\tconst cursor = graph.node<MessageBusCursor>(\n\t\t\t\t[status],\n\t\t\t\t(ctx) => {\n\t\t\t\t\tfor (const fact of depBatch(ctx, 0) ?? []) {\n\t\t\t\t\t\tconst typed = fact as MessageBusStatus;\n\t\t\t\t\t\tconst subscriptionMoved =\n\t\t\t\t\t\t\ttyped.topic === sub.topic &&\n\t\t\t\t\t\t\ttyped.subscriptionId === sub.subscriptionId &&\n\t\t\t\t\t\t\t(typed.kind === \"subscription-acked\" ||\n\t\t\t\t\t\t\t\ttyped.kind === \"subscription-sought\" ||\n\t\t\t\t\t\t\t\ttyped.kind === \"subscription-closed\");\n\t\t\t\t\t\tconst retentionMoved = typed.topic === sub.topic && typed.kind === \"retention-trimmed\";\n\t\t\t\t\t\tif (subscriptionMoved || retentionMoved) {\n\t\t\t\t\t\t\tctx.down([[\"DATA\", cursorSnapshot(state, sub)]]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: `${projectionName}/cursor`,\n\t\t\t\t\tfactory: \"messageBusSubscriptionCursor\",\n\t\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\t\terrorWhenDepsError: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tavailable,\n\t\t\t\tavailablePullId,\n\t\t\t\tcursor,\n\t\t\t\tstatus,\n\t\t\t\tissues,\n\t\t\t\tack(seq, commandOpts = {}) {\n\t\t\t\t\treturn publishCommand(commands, {\n\t\t\t\t\t\tkind: \"ack\",\n\t\t\t\t\t\ttopic: sub.topic,\n\t\t\t\t\t\tsubscriptionId: sub.subscriptionId,\n\t\t\t\t\t\tseq,\n\t\t\t\t\t\t...(commandOpts.commandId === undefined ? {} : { commandId: commandOpts.commandId }),\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tseek(nextSeq, commandOpts = {}) {\n\t\t\t\t\treturn publishCommand(commands, {\n\t\t\t\t\t\tkind: \"seek\",\n\t\t\t\t\t\ttopic: sub.topic,\n\t\t\t\t\t\tsubscriptionId: sub.subscriptionId,\n\t\t\t\t\t\tnextSeq,\n\t\t\t\t\t\t...(commandOpts.commandId === undefined ? {} : { commandId: commandOpts.commandId }),\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tclose(commandOpts = {}) {\n\t\t\t\t\treturn publishCommand(commands, {\n\t\t\t\t\t\tkind: \"close-subscription\",\n\t\t\t\t\t\ttopic: sub.topic,\n\t\t\t\t\t\tsubscriptionId: sub.subscriptionId,\n\t\t\t\t\t\t...(commandOpts.commandId === undefined ? {} : { commandId: commandOpts.commandId }),\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n\tregisterMessageBusState(bus, state);\n\treturn bus;\n}\n\nexport function fromTopic<T = unknown, TTopic extends string = string>(\n\tbus: MessageBus<TTopic>,\n\ttopic: TTopic | string,\n): Node<MessageBusTopicPage<T>> {\n\treturn bus.topic<T>(topic).snapshot;\n}\n\nexport function toTopic<T, TTopic extends string>(\n\tgraph: Graph,\n\tsource: Node<T>,\n\tbus: MessageBus<TTopic>,\n\ttopic: TTopic | string,\n\topts: ToTopicOptions = {},\n): ToTopicBundle<T> {\n\tconst state = getMessageBusState(bus);\n\tif (state === undefined) throw new Error(\"toTopic: unknown message bus implementation\");\n\tif (state.graph !== graph) throw new Error(\"toTopic: bus and source graph must match\");\n\tassertTopicKey(topic, \"toTopic\");\n\tconst commands = graph.node<MessageBusCommand<T>>(\n\t\t[source],\n\t\t(ctx) => {\n\t\t\tfor (const value of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst key = opts.keyOf?.(value);\n\t\t\t\tconst commandId = opts.commandIdOf?.(value);\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"publish\",\n\t\t\t\t\t\t\ttopic,\n\t\t\t\t\t\t\tpayload: value as T,\n\t\t\t\t\t\t\t...(key === undefined ? {} : { key }),\n\t\t\t\t\t\t\t...(commandId === undefined ? {} : { commandId }),\n\t\t\t\t\t\t} satisfies MessageBusCommand<T>,\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: opts.name ?? `${state.name}/${topic}/toTopic`,\n\t\t\tfactory: \"toTopic\",\n\t\t\tmeta: { topic },\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst releaseSource = attachMessageBusCommandSource(\n\t\tgraph,\n\t\tbus,\n\t\tcommands as Node<MessageBusCommand>,\n\t);\n\tlet released = false;\n\treturn {\n\t\tcommands,\n\t\trelease() {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\treleaseSource();\n\t\t},\n\t};\n}\n\nfunction reduceMessageBusCommand(\n\tstate: MessageBusState,\n\tcommand: MessageBusCommand,\n): RuntimeEvent[] {\n\tconst malformed = validateCommand(command);\n\tif (malformed !== undefined) return rejectCommand(state, command, malformed);\n\tif (command.commandId !== undefined) {\n\t\tif (state.seenCommandIds.has(command.commandId)) {\n\t\t\treturn duplicateCommandEvents(state, command, \"duplicate commandId\");\n\t\t}\n\t\tstate.seenCommandIds.add(command.commandId);\n\t}\n\tif (\n\t\tcommand.kind === \"publish\" &&\n\t\tcommand.idempotencyKey !== undefined &&\n\t\tstate.seenIdempotencyKeys.has(idempotencyKey(command.topic, command.idempotencyKey))\n\t) {\n\t\treturn duplicateCommandEvents(state, command, \"duplicate idempotencyKey\");\n\t}\n\tswitch (command.kind) {\n\t\tcase \"ensure-topic\":\n\t\t\treturn ensureTopic(state, command.topic, command.commandId);\n\t\tcase \"close-topic\": {\n\t\t\tconst topic = state.topics.get(command.topic);\n\t\t\tif (topic === undefined) {\n\t\t\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\t\t\t}\n\t\t\ttopic.closed = true;\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tkind: \"status\",\n\t\t\t\t\tstatus: statusFact(state, \"topic-closed\", {\n\t\t\t\t\t\ttopic: command.topic,\n\t\t\t\t\t\tcommandId: command.commandId,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\tcase \"topic-policy\":\n\t\t\tstate.topicPolicy = command.topicPolicy;\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tkind: \"status\",\n\t\t\t\t\tstatus: statusFact(state, \"projection-ready\", {\n\t\t\t\t\t\tcommandId: command.commandId,\n\t\t\t\t\t\tdetails: { topicPolicy: command.topicPolicy },\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t];\n\t\tcase \"publish\":\n\t\t\treturn publishMessage(state, command);\n\t\tcase \"ack\":\n\t\t\treturn ackSubscription(state, command);\n\t\tcase \"seek\":\n\t\t\treturn seekSubscription(state, command);\n\t\tcase \"close-subscription\":\n\t\t\treturn closeSubscription(state, command);\n\t}\n}\n\nfunction publishMessage(\n\tstate: MessageBusState,\n\tcommand: Extract<MessageBusCommand, { kind: \"publish\" }>,\n): RuntimeEvent[] {\n\tlet topic = state.topics.get(command.topic);\n\tconst events: RuntimeEvent[] = [];\n\tif (topic === undefined) {\n\t\tif (state.topicPolicy !== \"create-as-fact\") {\n\t\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\t\t}\n\t\tevents.push(...ensureTopic(state, command.topic, command.commandId));\n\t\ttopic = state.topics.get(command.topic);\n\t}\n\tif (topic === undefined)\n\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\tif (topic.closed)\n\t\treturn issueEvents(state, command, \"closed-topic\", `closed topic '${command.topic}'`);\n\tconst message: MessageBusMessage = {\n\t\ttopic: command.topic,\n\t\tseq: topic.nextSeq++,\n\t\tpayload: command.payload,\n\t\ttimestampMs: state.now(),\n\t\t...(command.key === undefined ? {} : { key: command.key }),\n\t\t...(command.idempotencyKey === undefined ? {} : { idempotencyKey: command.idempotencyKey }),\n\t\t...(command.commandId === undefined ? {} : { commandId: command.commandId }),\n\t};\n\tif (command.idempotencyKey !== undefined) {\n\t\tstate.seenIdempotencyKeys.add(idempotencyKey(command.topic, command.idempotencyKey));\n\t}\n\ttopic.messages.push(message);\n\tevents.push({ kind: \"message\", message });\n\tevents.push({\n\t\tkind: \"status\",\n\t\tstatus: statusFact(state, \"message-published\", {\n\t\t\ttopic: command.topic,\n\t\t\tseq: message.seq,\n\t\t\tcommandId: command.commandId,\n\t\t}),\n\t});\n\tevents.push(...trimRetention(state, command.topic, topic));\n\treturn events;\n}\n\nfunction ensureTopic(state: MessageBusState, topic: string, commandId?: string): RuntimeEvent[] {\n\tassertTopicKey(topic, \"messageBus\");\n\tif (!state.topics.has(topic)) state.topics.set(topic, makeTopicState());\n\treturn [\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"topic-created\", { topic, commandId }),\n\t\t},\n\t];\n}\n\nfunction trimRetention(\n\tstate: MessageBusState,\n\ttopicName: string,\n\ttopic: TopicState,\n): RuntimeEvent[] {\n\tconst max = state.retention.maxMessages;\n\tif (max === undefined || topic.messages.length <= max) return [];\n\tif (!Number.isInteger(max) || max < 1) {\n\t\treturn issueEvents(\n\t\t\tstate,\n\t\t\t{ kind: \"publish\", topic: topicName, payload: undefined },\n\t\t\t\"policy-rejected\",\n\t\t\t\"retention.maxMessages must be a positive integer\",\n\t\t);\n\t}\n\tconst trimCount = topic.messages.length - max;\n\ttopic.messages.splice(0, trimCount);\n\ttopic.headSeq = topic.messages[0]?.seq ?? topic.nextSeq;\n\tconst events: RuntimeEvent[] = [\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"retention-trimmed\", {\n\t\t\t\ttopic: topicName,\n\t\t\t\theadSeq: topic.headSeq,\n\t\t\t\tdetails: { trimCount },\n\t\t\t}),\n\t\t},\n\t];\n\tfor (const sub of state.subscriptions.values()) {\n\t\tif (sub.closed || sub.topic !== topicName || sub.nextSeq >= topic.headSeq) continue;\n\t\tsub.retentionGap = true;\n\t\tevents.push(\n\t\t\t...issueEvents(\n\t\t\t\tstate,\n\t\t\t\t{\n\t\t\t\t\tkind: \"seek\",\n\t\t\t\t\ttopic: topicName,\n\t\t\t\t\tsubscriptionId: sub.subscriptionId,\n\t\t\t\t\tnextSeq: sub.nextSeq,\n\t\t\t\t},\n\t\t\t\t\"retention-gap\",\n\t\t\t\t`subscription '${sub.subscriptionId}' is before retained headSeq`,\n\t\t\t),\n\t\t);\n\t}\n\treturn events;\n}\n\nfunction ackSubscription(\n\tstate: MessageBusState,\n\tcommand: Extract<MessageBusCommand, { kind: \"ack\" }>,\n): RuntimeEvent[] {\n\tconst topic = state.topics.get(command.topic);\n\tif (topic === undefined)\n\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\tconst sub = getSubscription(state, command.topic, command.subscriptionId);\n\tif (sub === undefined)\n\t\treturn issueEvents(\n\t\t\tstate,\n\t\t\tcommand,\n\t\t\t\"unknown-subscription\",\n\t\t\t`unknown subscription '${command.subscriptionId}'`,\n\t\t);\n\tif (sub.closed)\n\t\treturn issueEvents(state, command, \"subscription-closed\", \"subscription is closed\");\n\tif (sub.retentionGap)\n\t\treturn issueEvents(state, command, \"retention-gap\", \"subscription must seek before ack\");\n\tif (command.seq < sub.nextSeq)\n\t\treturn issueEvents(state, command, \"source-cursor-stale\", \"ack is behind subscription cursor\");\n\tif (command.seq >= topic.nextSeq)\n\t\treturn issueEvents(state, command, \"cursor-out-of-range\", \"ack is beyond topic tail\");\n\tsub.nextSeq = Math.max(sub.nextSeq, command.seq + 1);\n\treturn [\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"subscription-acked\", {\n\t\t\t\ttopic: command.topic,\n\t\t\t\tsubscriptionId: command.subscriptionId,\n\t\t\t\tnextSeq: sub.nextSeq,\n\t\t\t\tcommandId: command.commandId,\n\t\t\t}),\n\t\t},\n\t];\n}\n\nfunction seekSubscription(\n\tstate: MessageBusState,\n\tcommand: Extract<MessageBusCommand, { kind: \"seek\" }>,\n): RuntimeEvent[] {\n\tconst topic = state.topics.get(command.topic);\n\tif (topic === undefined)\n\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\tconst sub = getSubscription(state, command.topic, command.subscriptionId);\n\tif (sub === undefined)\n\t\treturn issueEvents(\n\t\t\tstate,\n\t\t\tcommand,\n\t\t\t\"unknown-subscription\",\n\t\t\t`unknown subscription '${command.subscriptionId}'`,\n\t\t);\n\tif (sub.closed)\n\t\treturn issueEvents(state, command, \"subscription-closed\", \"subscription is closed\");\n\tif (command.nextSeq < topic.headSeq)\n\t\treturn issueEvents(state, command, \"retention-gap\", \"seek is before retained headSeq\");\n\tif (command.nextSeq > topic.nextSeq)\n\t\treturn issueEvents(state, command, \"cursor-out-of-range\", \"seek is beyond topic tail\");\n\tsub.nextSeq = command.nextSeq;\n\tsub.retentionGap = false;\n\treturn [\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"subscription-sought\", {\n\t\t\t\ttopic: command.topic,\n\t\t\t\tsubscriptionId: command.subscriptionId,\n\t\t\t\tnextSeq: sub.nextSeq,\n\t\t\t\tcommandId: command.commandId,\n\t\t\t}),\n\t\t},\n\t];\n}\n\nfunction closeSubscription(\n\tstate: MessageBusState,\n\tcommand: Extract<MessageBusCommand, { kind: \"close-subscription\" }>,\n): RuntimeEvent[] {\n\tif (!state.topics.has(command.topic))\n\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\tconst sub = getSubscription(state, command.topic, command.subscriptionId);\n\tif (sub === undefined)\n\t\treturn issueEvents(\n\t\t\tstate,\n\t\t\tcommand,\n\t\t\t\"unknown-subscription\",\n\t\t\t`unknown subscription '${command.subscriptionId}'`,\n\t\t);\n\tsub.closed = true;\n\treturn [\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"subscription-closed\", {\n\t\t\t\ttopic: command.topic,\n\t\t\t\tsubscriptionId: command.subscriptionId,\n\t\t\t\tnextSeq: sub.nextSeq,\n\t\t\t\tcommandId: command.commandId,\n\t\t\t}),\n\t\t},\n\t];\n}\n\nfunction issueEvents(\n\tstate: MessageBusState,\n\tcommand: unknown,\n\tcode: string,\n\tmessage: string,\n): RuntimeEvent[] {\n\tconst topic = commandTopic(command);\n\tconst commandId = commandIdOf(command);\n\tconst issue: DataIssue = {\n\t\tkind: \"issue\",\n\t\tcode,\n\t\tmessage,\n\t\tseverity: \"error\",\n\t\tsource: \"messageBus\",\n\t\tdetails: command,\n\t\tmetadata: topic === undefined ? undefined : { topic },\n\t};\n\tconst entry: MessageBusDeadLetterEntry = {\n\t\tentrySeq: ++state.deadLetterSeq,\n\t\t...(topic === undefined ? {} : { topic }),\n\t\t...(isObjectRecord(command) ? { command: command as MessageBusCommand } : {}),\n\t\tissue,\n\t\ttimestampMs: state.now(),\n\t};\n\tstate.deadLetters.push(entry);\n\treturn [\n\t\t{ kind: \"issue\", issue },\n\t\t{ kind: \"dead-letter\", entry },\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"command-rejected\", {\n\t\t\t\ttopic,\n\t\t\t\tcommandId,\n\t\t\t\tissueCode: code,\n\t\t\t}),\n\t\t},\n\t];\n}\n\nfunction rejectCommand(state: MessageBusState, command: unknown, reason: string): RuntimeEvent[] {\n\treturn issueEvents(state, command, \"malformed-command\", reason);\n}\n\nfunction duplicateCommandEvents(\n\tstate: MessageBusState,\n\tcommand: MessageBusCommand,\n\tmessage: string,\n): RuntimeEvent[] {\n\tconst status = statusFact(state, \"duplicate-command\", {\n\t\ttopic: \"topic\" in command ? command.topic : undefined,\n\t\tcommandId: command.commandId,\n\t});\n\tif (state.dedupe.commandId === \"issue\") {\n\t\treturn [\n\t\t\t{ kind: \"status\", status },\n\t\t\t...issueEvents(state, command, \"duplicate-command\", message),\n\t\t];\n\t}\n\treturn [{ kind: \"status\", status }];\n}\n\nfunction statusFact(\n\tstate: MessageBusState,\n\tkind: MessageBusStatus[\"kind\"],\n\tfields: Partial<MessageBusStatus>,\n): MessageBusStatus {\n\treturn {\n\t\tkind,\n\t\ttimestampMs: state.now(),\n\t\t...(fields.topic === undefined ? {} : { topic: fields.topic }),\n\t\t...(fields.seq === undefined ? {} : { seq: fields.seq }),\n\t\t...(fields.headSeq === undefined ? {} : { headSeq: fields.headSeq }),\n\t\t...(fields.subscriptionId === undefined ? {} : { subscriptionId: fields.subscriptionId }),\n\t\t...(fields.nextSeq === undefined ? {} : { nextSeq: fields.nextSeq }),\n\t\t...(fields.commandId === undefined ? {} : { commandId: fields.commandId }),\n\t\t...(fields.issueCode === undefined ? {} : { issueCode: fields.issueCode }),\n\t\t...(fields.details === undefined ? {} : { details: fields.details }),\n\t};\n}\n\nfunction validateCommand(command: unknown): string | undefined {\n\tif (!isObjectRecord(command)) return \"command must be an object\";\n\tif (typeof command.kind !== \"string\") return \"command kind is required\";\n\tif (!isMessageBusCommandKind(command.kind)) return `unknown command kind '${command.kind}'`;\n\tif (\"topic\" in command) {\n\t\tif (typeof command.topic !== \"string\") return \"messageBus: topic must be a non-empty string\";\n\t\tconst topicError = validateTopicKey(command.topic, \"messageBus\");\n\t\tif (topicError !== undefined) return topicError;\n\t}\n\tif (\"subscriptionId\" in command && typeof command.subscriptionId !== \"string\") {\n\t\treturn \"subscriptionId must be a string\";\n\t}\n\tif (command.kind === \"publish\" && command.payload === undefined)\n\t\treturn \"publish payload is required\";\n\tif (command.kind === \"ack\" && !isPositiveSeq(command.seq))\n\t\treturn \"ack seq must be a positive integer\";\n\tif (command.kind === \"seek\" && !isPositiveSeq(command.nextSeq)) {\n\t\treturn \"seek nextSeq must be a positive integer\";\n\t}\n\tif (\n\t\tcommand.kind === \"topic-policy\" &&\n\t\tcommand.topicPolicy !== \"strict\" &&\n\t\tcommand.topicPolicy !== \"create-as-fact\"\n\t) {\n\t\treturn \"topicPolicy is not recognized\";\n\t}\n\treturn undefined;\n}\n\nfunction isMessageBusCommandKind(kind: string): kind is MessageBusCommand[\"kind\"] {\n\treturn (\n\t\tkind === \"ensure-topic\" ||\n\t\tkind === \"close-topic\" ||\n\t\tkind === \"publish\" ||\n\t\tkind === \"topic-policy\" ||\n\t\tkind === \"ack\" ||\n\t\tkind === \"seek\" ||\n\t\tkind === \"close-subscription\"\n\t);\n}\n\nfunction catalogPage(\n\tstate: MessageBusState,\n\tparams: MessageBusCatalogParams,\n): MessageBusCatalogPage {\n\tconst limit = positiveLimit(params.limit);\n\tconst topics = [...state.topics.entries()]\n\t\t.filter(\n\t\t\t([topic, value]) =>\n\t\t\t\t(params.includeClosed ? true : !value.closed) &&\n\t\t\t\t(params.afterTopic === undefined || topic > params.afterTopic),\n\t\t)\n\t\t.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n\tconst page = topics.slice(0, limit);\n\tconst hasMore = topics.length > limit;\n\treturn {\n\t\ttopics: page.map(([topic, value]) => ({\n\t\t\ttopic,\n\t\t\tclosed: value.closed,\n\t\t\theadSeq: value.headSeq,\n\t\t\tnextSeq: value.nextSeq,\n\t\t\tmessageCount: value.messages.length,\n\t\t})),\n\t\t...(hasMore && page.length > 0 ? { nextAfterTopic: page[page.length - 1]?.[0] } : {}),\n\t\thasMore,\n\t};\n}\n\nfunction topicPage<T>(\n\tstate: MessageBusState,\n\ttopicName: string,\n\tparams: MessageBusTopicParams,\n): MessageBusTopicPage<T> {\n\tconst topic = state.topics.get(topicName);\n\tconst start = params.afterSeq === undefined ? (topic?.headSeq ?? 1) : params.afterSeq + 1;\n\tconst all = (topic?.messages ?? []).filter((message) => message.seq >= start);\n\tconst limit = positiveLimit(params.limit);\n\tconst messages = all.slice(0, limit) as MessageBusMessage<T>[];\n\tconst hasMore = all.length > limit;\n\treturn {\n\t\ttopic: topicName,\n\t\tmessages,\n\t\tfromSeq: start,\n\t\t...(messages.length > 0 ? { throughSeq: messages[messages.length - 1]?.seq } : {}),\n\t\t...(hasMore && messages.length > 0 ? { nextAfterSeq: messages[messages.length - 1]?.seq } : {}),\n\t\thasMore,\n\t};\n}\n\nfunction availablePage<T>(\n\tstate: MessageBusState,\n\tsub: SubscriptionState,\n\tparams: MessageBusAvailableParams,\n): MessageBusAvailablePage<T> {\n\tconst cursor = cursorSnapshot(state, sub);\n\tconst start = params.afterSeq === undefined ? sub.nextSeq : params.afterSeq + 1;\n\tconst topic = state.topics.get(sub.topic);\n\tconst all = sub.retentionGap\n\t\t? []\n\t\t: (topic?.messages ?? []).filter((message) => message.seq >= start);\n\tconst limit = positiveLimit(params.limit);\n\tconst messages = all.slice(0, limit) as MessageBusMessage<T>[];\n\tconst hasMore = all.length > limit;\n\treturn {\n\t\ttopic: sub.topic,\n\t\tsubscriptionId: sub.subscriptionId,\n\t\tcursor,\n\t\tmessages,\n\t\tfromSeq: start,\n\t\t...(messages.length > 0 ? { throughSeq: messages[messages.length - 1]?.seq } : {}),\n\t\t...(hasMore && messages.length > 0 ? { nextAfterSeq: messages[messages.length - 1]?.seq } : {}),\n\t\thasMore,\n\t};\n}\n\nfunction deadLetterPage<T>(\n\tstate: MessageBusState,\n\tparams: MessageBusDeadLetterParams,\n): MessageBusDeadLetterPage<T> {\n\tconst limit = positiveLimit(params.limit);\n\tconst entries = state.deadLetters.filter((entry) => {\n\t\tif (params.afterEntrySeq !== undefined && entry.entrySeq <= params.afterEntrySeq) return false;\n\t\tif (params.topic !== undefined && entry.topic !== params.topic) return false;\n\t\tif (params.code !== undefined && entry.issue.code !== params.code) return false;\n\t\treturn true;\n\t});\n\tconst page = entries.slice(0, limit) as MessageBusDeadLetterEntry<T>[];\n\tconst hasMore = entries.length > limit;\n\treturn {\n\t\tentries: page,\n\t\t...(hasMore && page.length > 0 ? { nextAfterEntrySeq: page[page.length - 1]?.entrySeq } : {}),\n\t\thasMore,\n\t};\n}\n\nfunction cursorSnapshot(state: MessageBusState, sub: SubscriptionState): MessageBusCursor {\n\tconst topic = state.topics.get(sub.topic);\n\treturn {\n\t\ttopic: sub.topic,\n\t\tsubscriptionId: sub.subscriptionId,\n\t\tnextSeq: sub.nextSeq,\n\t\tclosed: sub.closed,\n\t\tretentionGap: sub.retentionGap,\n\t\theadSeq: topic?.headSeq ?? 1,\n\t};\n}\n\nfunction ensureSubscription(\n\tstate: MessageBusState,\n\topts: { topic: string; subscriptionId: string; from: \"earliest\" | \"latest\" | number },\n): SubscriptionState {\n\tconst key = `${opts.topic}\\u0000${opts.subscriptionId}`;\n\tconst existing = state.subscriptions.get(key);\n\tif (existing !== undefined) return existing;\n\tconst topic = state.topics.get(opts.topic);\n\tconst nextSeq =\n\t\topts.from === \"earliest\"\n\t\t\t? (topic?.headSeq ?? 1)\n\t\t\t: opts.from === \"latest\"\n\t\t\t\t? (topic?.nextSeq ?? 1)\n\t\t\t\t: opts.from;\n\tconst sub: SubscriptionState = {\n\t\ttopic: opts.topic,\n\t\tsubscriptionId: opts.subscriptionId,\n\t\tnextSeq,\n\t\tclosed: false,\n\t\tretentionGap: topic !== undefined && nextSeq < topic.headSeq,\n\t};\n\tstate.subscriptions.set(key, sub);\n\treturn sub;\n}\n\nfunction getSubscription(\n\tstate: MessageBusState,\n\ttopic: string,\n\tsubscriptionId: string,\n): SubscriptionState | undefined {\n\treturn state.subscriptions.get(`${topic}\\u0000${subscriptionId}`);\n}\n\nfunction pullParams<T>(pull: PullDemand | undefined): T {\n\treturn (isObjectRecord(pull?.params) ? pull.params : {}) as T;\n}\n\nfunction publishCommand<T extends MessageBusCommand>(\n\tcommandNode: Node<MessageBusCommand>,\n\tcommand: T,\n): T {\n\tcommandNode.down([[\"DATA\", command]]);\n\treturn command;\n}\n\nfunction makeTopicState(): TopicState {\n\treturn { closed: false, headSeq: 1, nextSeq: 1, messages: [] };\n}\n\nfunction uniqueTopics(topics: readonly string[]): readonly string[] {\n\tconst unique = [...new Set(topics)];\n\tif (unique.length !== topics.length) throw new Error(\"messageBus: duplicate topic\");\n\tfor (const topic of unique) assertTopicKey(topic, \"messageBus\");\n\treturn Object.freeze(unique.sort());\n}\n\nfunction assertTopicKey(topic: string, owner: string): void {\n\tconst error = validateTopicKey(topic, owner);\n\tif (error !== undefined) throw new Error(error);\n}\n\nfunction validateTopicKey(topic: string, owner: string): string | undefined {\n\tif (typeof topic !== \"string\" || topic.length === 0)\n\t\treturn `${owner}: topic must be a non-empty string`;\n\treturn undefined;\n}\n\nfunction assertNonEmpty(value: string, owner: string): void {\n\tif (typeof value !== \"string\" || value.length === 0)\n\t\tthrow new Error(`${owner}: must be a non-empty string`);\n}\n\nfunction positiveLimit(limit: number | undefined): number {\n\tif (limit === undefined) return 100;\n\tif (!Number.isInteger(limit) || limit < 1)\n\t\tthrow new Error(\"messageBus: limit must be a positive integer\");\n\treturn limit;\n}\n\nfunction isPositiveSeq(value: unknown): value is number {\n\treturn Number.isInteger(value) && (value as number) >= 1;\n}\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction commandTopic(command: unknown): string | undefined {\n\treturn isObjectRecord(command) && typeof command.topic === \"string\" ? command.topic : undefined;\n}\n\nfunction commandIdOf(command: unknown): string | undefined {\n\treturn isObjectRecord(command) && typeof command.commandId === \"string\"\n\t\t? command.commandId\n\t\t: undefined;\n}\n\nfunction idempotencyKey(topic: string, key: string): string {\n\treturn `${topic}\\u0000${key}`;\n}\n"],"mappings":";;;;;;;;;;AAyFO,SAAS,aACf,MACA,SACA,MACkB;AAClB,iBAAe,MAAM,mBAAmB;AACxC,iBAAe,KAAK,IAAI,iBAAiB;AACzC,SAAO;AAAA,IACN,IAAI,KAAK;AAAA,IACT;AAAA,IACA;AAAA,IACA,GAAI,KAAK,QAAQ,SAAY,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI;AAAA,IAClD,GAAI,KAAK,cAAc,SAAY,CAAC,IAAI,EAAE,WAAW,KAAK,UAAU;AAAA,IACpE,GAAI,KAAK,kBAAkB,SAAY,CAAC,IAAI,EAAE,eAAe,KAAK,cAAc;AAAA,IAChF,GAAI,KAAK,gBAAgB,SAAY,CAAC,IAAI,EAAE,aAAa,KAAK,YAAY;AAAA,IAC1E,GAAI,KAAK,iBAAiB,SAAY,CAAC,IAA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,SAAsC;AAC3D,SAAO,eAAe,OAAO,KAAK,OAAO,QAAQ,UAAU,WAAW,QAAQ,QAAQ;AACvF;AAEA,SAAS,YAAY,SAAsC;AAC1D,SAAO,eAAe,OAAO,KAAK,OAAO,QAAQ,cAAc,WAC5D,QAAQ,YACR;AACJ;AAEA,SAAS,eAAe,OAAe,KAAqB;AAC3D,SAAO,GAAG,KAAK,KAAS,GAAG;AAC5B;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/graph/checkpoint.ts","../src/graph/operators.ts"],"sourcesContent":["/**\n * Graph checkpoint public data shape (D83/D86/D90/D116).\n *\n * Checkpoint is a graph lifecycle snapshot: strict-JSON-compatible data, no storage I/O,\n * no observe-log replay, and no restore runtime in this first TS slice.\n */\n\nimport { type StrictJsonValue, strictJsonCodec } from \"../json/codec.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { NodeVersionJson } from \"../node/versioning.js\";\nimport { SENTINEL } from \"../protocol/messages.js\";\n\nexport const GRAPH_CHECKPOINT_VERSION = \"graphrefly.checkpoint.v1\" as const;\n\nexport type GraphCheckpointVersion = typeof GRAPH_CHECKPOINT_VERSION;\n\nexport type GraphCheckpointJson = StrictJsonValue;\n\nexport type GraphCheckpointValue =\n\t| { kind: \"SENTINEL\" }\n\t| { kind: \"DATA\"; data: GraphCheckpointJson };\n\nexport type GraphCheckpointTerminal =\n\t| { kind: \"none\" }\n\t| { kind: \"COMPLETE\" }\n\t| { kind: \"ERROR\"; error: GraphCheckpointJson };\n\nexport type GraphCheckpointFactory =\n\t| {\n\t\t\tkind: \"registry-ref\";\n\t\t\tref: string;\n\t\t\tconfig?: GraphCheckpointJson;\n\t\t\tconfigVersion?: GraphCheckpointJson;\n\t }\n\t| { kind: \"local-only\"; name: string; reason: string };\n\nexport interface GraphCheckpointNode {\n\tid: string;\n\tname?: string;\n\tfactory: GraphCheckpointFactory;\n\tstatus: string;\n\tdeps: string[];\n\tvalue: GraphCheckpointValue;\n\tbackendState?: GraphCheckpointJson;\n\tversion?: NodeVersionJson;\n\tterminal: GraphCheckpointTerminal;\n\tlifecycle: { activated: boolean; hasCalledFnOnce: boolean };\n\tctxState: { persist: boolean; value: GraphCheckpointValue };\n\tmeta?: { [key: string]: GraphCheckpointJson };\n}\n\nexport interface GraphCheckpointEdge {\n\tfrom: string;\n\tto: string;\n}\n\nexport interface GraphCheckpointMount {\n\tat: string;\n\tcheckpoint: GraphCheckpoint;\n}\n\nexport interface GraphCheckpoint {\n\tversion: GraphCheckpointVersion;\n\tname?: string;\n\tnodes: GraphCheckpointNode[];\n\tedges: GraphCheckpointEdge[];\n\tmounts?: GraphCheckpointMount[];\n}\n\nexport function toCheckpointJson(value: unknown, path = \"$\"): GraphCheckpointJson {\n\ttry {\n\t\treturn strictJsonCodec.decode(strictJsonCodec.encode(value)) as GraphCheckpointJson;\n\t} catch (cause) {\n\t\tthrow new TypeError(`checkpoint: value at ${path} is not strict JSON compatible`, {\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport function checkpointValue(\n\tvalue: unknown,\n\thasData: boolean,\n\tpath: string,\n): GraphCheckpointValue {\n\tif (!hasData || value === SENTINEL) return { kind: \"SENTINEL\" };\n\treturn { kind: \"DATA\", data: toCheckpointJson(value, path) };\n}\n\nexport function checkpointTerminal(value: unknown, path: string): GraphCheckpointTerminal {\n\tif (value === undefined) return { kind: \"none\" };\n\tif (value === true) return { kind: \"COMPLETE\" };\n\treturn { kind: \"ERROR\", error: toCheckpointJson(value, path) };\n}\n\ntype BackendStateContributor = () => unknown;\n\nconst backendStateContributors = new WeakMap<Node<unknown>, BackendStateContributor>();\n\n/** @internal D160: collection-owned backend checkpoint contributor for graph checkpoint. */\nexport function registerBackendStateContributor(\n\tnode: Node<unknown>,\n\tcontributor: BackendStateContributor,\n): void {\n\tbackendStateContributors.set(node, contributor);\n}\n\n/** @internal D160: capture a node's collection backend state when it has a contributor. */\nexport function checkpointBackendStateOfNode(\n\tnode: Node<unknown>,\n\tpath: string,\n): GraphCheckpointJson | undefined {\n\tconst contributor = backendStateContributors.get(node);\n\tif (contributor === undefined) return undefined;\n\treturn toCheckpointJson(contributor(), path);\n}\n","/**\n * Operators as free-standing factory definitions (D43 / D6 / D40 Catalog-first).\n *\n * Operators are `node` sugar (D6), NOT verbs (D4) and NEVER in parity (D24). Each is a\n * pure {@link Operator} spec — `{factory, body, opts}` — built on the bare `node` primitive\n * (NOT the `derived` verb): `body` reads ctx dep slots positionally and emits via\n * `ctx.down`. Two ways to instantiate:\n *\n * - {@link initNode}(op, deps, opts?) — bare, no Graph; returns a working `Node<T>`.\n * - `g.initNode(op, deps, opts?)` — graph-bound; the SAME call, plus inspection registration\n * (the real factory name lands in the graph's `_entries`, so describe/observe/profile\n * show it — D6/R-describe — while the node stays thin, R-node-thin).\n *\n * The D30 throw→ERROR boundary lives once, in the free {@link initNode} (which `g.initNode`\n * funnels through). The pure-ts `operatorOpts/partialOperatorOpts/gatedOperatorOpts` trio is\n * NOT ported: its sole job (`describeKind:\"derived\"`) is dead under D6/D39 (factory = the\n * REAL operator name); only the `partial`/`terminalAsRealInput` flags survive, carried\n * per-operator in `op.opts`.\n *\n * Config is folded into the factory (`map(fn)`, `scan(reducer, seed)`, `take(n)`, `merge()`),\n * so fn params are annotated where the source type can't be inferred (RxJS-pipe cost);\n * dep-type safety is recovered by the typed `g.initNode` overloads.\n */\n\nimport {\n\ttype Ctx,\n\tdepBatch,\n\tdepCount,\n\tdepLatest,\n\tdepTerminal,\n\tisTerminalComplete,\n\tisTerminalError,\n\ttype NodeFn,\n\tterminalErrorValue,\n} from \"../ctx/types.js\";\nimport type { NodeCore } from \"../node/core.js\";\nimport { Node, type NodeOptions, withNodeCore } from \"../node/node.js\";\nimport { errorPayload } from \"../protocol/messages.js\";\nimport { type GraphCheckpointJson, toCheckpointJson } from \"./checkpoint.js\";\nimport type { GraphRestoreDefinition, GraphRestoreEntry, GraphRestoreRegistry } from \"./restore.js\";\n\n/**\n * A free-standing operator definition (D43). `TIn` = the element type each dep delivers\n * (the operator reads `depLatest(ctx, i) as TIn`); `TOut` = the emitted value type.\n * `__in`/`__out` are phantom-only (never assigned) — they let `g.initNode` infer + check the\n * dep tuple against the operator without an explicit type argument.\n */\nexport interface Operator<TIn = unknown, TOut = unknown> {\n\t/** Real operator name shown in describe (D6/L1.5) — recorded at `_add` by `g.initNode`. */\n\treadonly factory: string;\n\t/** The ctx-body: reads ctx dep slots positionally, emits via `ctx.down`. */\n\treadonly body: (ctx: Ctx) => void;\n\t/** Behavioral node options the operator needs (e.g. `partial:true` for combine-family). */\n\treadonly opts?: Partial<NodeOptions<TOut>>;\n\t/**\n\t * D97/D100 restore metadata derived from a named definition or static built-in config.\n\t * This is semantic metadata only; dispatcher handles stay graph-local runtime state.\n\t */\n\treadonly restore?: {\n\t\tref: string;\n\t\tconfig?: GraphCheckpointJson;\n\t\tconfigVersion?: GraphCheckpointJson;\n\t};\n\t/** @internal phantom — never set; carries the dep element type for `g.initNode` inference. */\n\treadonly __in?: TIn;\n\t/** @internal phantom — never set; carries the output value type. */\n\treadonly __out?: TOut;\n}\n\ntype MutableRestoreRegistry = Map<string, GraphRestoreEntry> | Record<string, GraphRestoreEntry>;\n\nexport type RestoreRegistryEntry = GraphRestoreEntry;\n\nexport interface Definition<S = unknown, T = unknown> extends GraphRestoreDefinition<S, T> {\n\treadonly ref: string;\n\treadonly fn: (v: S) => T;\n}\n\nexport interface DefineOpts {\n\tregistry?: MutableRestoreRegistry;\n}\n\nfunction registryHas(registry: MutableRestoreRegistry, ref: string): boolean {\n\treturn registry instanceof Map ? registry.has(ref) : Object.hasOwn(registry, ref);\n}\n\nfunction registrySet(\n\tregistry: MutableRestoreRegistry,\n\tref: string,\n\tentry: GraphRestoreEntry,\n): void {\n\tif (registryHas(registry, ref)) {\n\t\tthrow new Error(`restoreRegistry: duplicate ref '${ref}'`);\n\t}\n\tif (registry instanceof Map) registry.set(ref, entry);\n\telse registry[ref] = entry;\n}\n\nexport function addToRestoreRegistry(\n\tregistry: MutableRestoreRegistry,\n\tentry: GraphRestoreEntry,\n): void {\n\tregistrySet(registry, entry.ref, entry);\n}\n\nexport function restoreRegistry(\n\tentries: readonly GraphRestoreEntry[] = [],\n\tbase?: GraphRestoreRegistry,\n): Map<string, GraphRestoreEntry> {\n\tconst out = new Map<string, GraphRestoreEntry>();\n\tif (base instanceof Map) {\n\t\tfor (const [ref, entry] of base) registrySet(out, ref, entry);\n\t} else if (base !== undefined) {\n\t\tfor (const [ref, entry] of Object.entries(base)) registrySet(out, ref, entry);\n\t}\n\tfor (const entry of entries) addToRestoreRegistry(out, entry);\n\treturn out;\n}\n\nfunction isDefinition<S, T>(fn: ((v: S) => T) | Definition<S, T>): fn is Definition<S, T> {\n\treturn typeof fn === \"object\" && fn !== null && (fn as Definition<S, T>).kind === \"definition\";\n}\n\nexport function define<S, T>(\n\tref: string,\n\tfn: (v: S) => T,\n\topts: DefineOpts = {},\n): Definition<S, T> {\n\tconst jsonRef = toCheckpointJson(ref, \"define.ref\");\n\tif (typeof jsonRef !== \"string\") throw new TypeError(\"define: ref must be a string\");\n\tconst definition: Definition<S, T> = {\n\t\tkind: \"definition\",\n\t\tref: jsonRef,\n\t\tfn,\n\t};\n\tif (opts.registry !== undefined) addToRestoreRegistry(opts.registry, definition);\n\treturn definition;\n}\n\n/**\n * Instantiate an operator as a bare `Node<T>` — NO Graph required (D43 bare-node path).\n * Wraps `op.body` in the D30 value-throw→ERROR boundary; merges `op.opts` with caller `opts`\n * (caller wins, so `partial`/`pool`/`dispatcher` overrides take effect). The\n * dispatcher defaults to the process-global (D26) unless `opts.dispatcher` is passed.\n *\n * `g.initNode` is the same call PLUS graph registration; graph inspection\n * (describe/observe/profile) requires that path — a node built bare here is not registered in\n * any graph's index.\n */\nexport function initNode<TIn, TOut>(\n\top: Operator<TIn, TOut>,\n\tdeps: readonly Node<unknown>[],\n\topts: NodeOptions<TOut> = {},\n): Node<TOut> {\n\treturn makeInitNode(op, deps, opts);\n}\n\n/** @internal Graph-bound operator instantiation into a graph-local B49 core. */\nexport function initNodeWithCore<TIn, TOut>(\n\tcore: NodeCore,\n\top: Operator<TIn, TOut>,\n\tdeps: readonly Node<unknown>[],\n\topts: NodeOptions<TOut> = {},\n): Node<TOut> {\n\treturn withNodeCore(core, () => makeInitNode(op, deps, opts));\n}\n\nfunction makeInitNode<TIn, TOut>(\n\top: Operator<TIn, TOut>,\n\tdeps: readonly Node<unknown>[],\n\topts: NodeOptions<TOut>,\n): Node<TOut> {\n\tconst body = operatorNodeFn(op);\n\t// D43-reserved / D51: stamp the operator's real factory onto the bare node so a runtime *Map\n\t// inner (created here via fromAny, NOT registered in any graph) is named in describe's\n\t// auto-discovery. A graph-bound g.initNode also records it in `_entries` (entry.factory wins\n\t// there); this field is only read for a node absent from the graph index. Caller opts win.\n\treturn new Node<TOut>([...deps], body, { factory: op.factory, ...op.opts, ...opts });\n}\n\n/** @internal Build the dispatcher body for an Operator spec. */\nexport function operatorNodeFn<TIn, TOut>(op: Operator<TIn, TOut>): NodeFn {\n\treturn (ctx) => {\n\t\ttry {\n\t\t\top.body(ctx);\n\t\t} catch (e) {\n\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"operator threw without a valid error payload\")]]); // D30: value-level throw → ERROR\n\t\t}\n\t};\n}\n\n// ── Slice 1 — single-dep map / take / control (CSP-2.7 catalog re-derive, D40) ──\n// All read dep 0 positionally + emit via ctx.down. Under D49 every occurrence is DATA (no\n// equals-absorption); a body that returns WITHOUT emitting gets a substrate-synthesized undirty\n// RESOLVED (R-resolved-undirty) — so a \"skip this wave\" is a bare `return`. Terminal-emitting\n// operators (reduce/last/find/elementAt) read `depTerminal(ctx, 0)` via the\n// `completeWhenDepsComplete:false + terminalAsRealInput:true` flags (R-deps-terminal): the fn fires\n// on the source's COMPLETE and emits its final value. NOT 1:1 pure-ts ports — the frozen reference\n// (D41) uses a producer + internal `subscribeOr`, the D45-banned describe island; these are\n// declared-dep nodes whose single edge `describe` shows truthfully.\n\n/** map: emit fn(value). A named {@link define} makes the map restorable via the map descriptor (D101). */\nexport function map<S, T>(fn: ((v: S) => T) | Definition<S, T>): Operator<S, T> {\n\tif (isDefinition(fn)) {\n\t\treturn mapFromFunction(fn.fn, {\n\t\t\tref: \"map\",\n\t\t\tconfig: { fn: toCheckpointJson(fn.ref, `map.fn`) },\n\t\t});\n\t}\n\treturn mapFromFunction(fn);\n}\n\nfunction mapFromFunction<S, T>(\n\tfn: (v: S) => T,\n\trestore?: {\n\t\tref: string;\n\t\tconfig?: GraphCheckpointJson;\n\t\tconfigVersion?: GraphCheckpointJson;\n\t},\n): Operator<S, T> {\n\treturn {\n\t\tfactory: \"map\",\n\t\t...(restore ? { restore } : {}),\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b) ctx.down([[\"DATA\", fn(v as S)]]);\n\t\t},\n\t};\n}\n\n/** filter: emit value only when pred(value) (else skip the wave). */\nexport function filter<S>(pred: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"filter\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b) if (pred(v as S)) ctx.down([[\"DATA\", v]]);\n\t\t},\n\t};\n}\n\n/** scan: stateful accumulator over the upstream (acc seeded once, kept in ctx.state). */\nexport function scan<S, T>(reducer: (acc: T, v: S) => T, seed: T): Operator<S, T> {\n\treturn {\n\t\tfactory: \"scan\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet acc = ctx.state.get<T>() ?? seed;\n\t\t\tfor (const v of b) {\n\t\t\t\tacc = reducer(acc, v as S);\n\t\t\t\tctx.down([[\"DATA\", acc]]);\n\t\t\t}\n\t\t\tctx.state.set(acc);\n\t\t},\n\t};\n}\n\n/** take: emit the first n values, then COMPLETE (terminal-is-forever). */\nexport function take<S>(n: number): Operator<S, S> {\n\treturn {\n\t\tfactory: \"take\",\n\t\trestore: { ref: \"take\", config: { n: toCheckpointJson(n, \"take.n\") } },\n\t\tbody: (ctx) => {\n\t\t\tif (n <= 0) {\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet count = ctx.state.get<number>() ?? 0;\n\t\t\tif (count >= n) return; // already satisfied\n\t\t\tfor (const v of b) {\n\t\t\t\tif (count >= n) break;\n\t\t\t\tcount += 1;\n\t\t\t\tctx.down(count >= n ? [[\"DATA\", v], [\"COMPLETE\"]] : [[\"DATA\", v]]);\n\t\t\t}\n\t\t\tctx.state.set(count);\n\t\t},\n\t};\n}\n\n/** distinctUntilChanged: emit only when the value differs from the previous emit. */\nexport function distinctUntilChanged<S>(eq: (a: S, b: S) => boolean = Object.is): Operator<S, S> {\n\treturn {\n\t\tfactory: \"distinctUntilChanged\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tconst prev = ctx.state.get<{ v: S }>();\n\t\t\tlet last = prev?.v;\n\t\t\tlet hasLast = prev !== undefined;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (hasLast && eq(last as S, v)) continue;\n\t\t\t\tlast = v;\n\t\t\t\thasLast = true;\n\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t}\n\t\t\tif (hasLast) ctx.state.set({ v: last as S });\n\t\t},\n\t};\n}\n\n/**\n * merge: interleave several sources — emit each DATA from whichever dep fired. `partial:true`\n * (combine-family): fires on any single dep, not gated on all deps settling.\n */\nexport function merge<T>(): Operator<T, T> {\n\treturn {\n\t\tfactory: \"merge\",\n\t\topts: { partial: true },\n\t\tbody: (ctx) => {\n\t\t\tfor (let i = 0; i < depCount(ctx); i++) {\n\t\t\t\tconst b = depBatch(ctx, i);\n\t\t\t\tif (b && b.length > 0) {\n\t\t\t\t\tfor (const v of b) ctx.down([[\"DATA\", v]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * reduce: accumulate over the whole source, emit ONE final value on the source's COMPLETE\n * (RxJS `reduce`). Unlike {@link scan} (which emits every step), reduce stays quiet until the\n * source terminates. `completeWhenDepsComplete:false + terminalAsRealInput:true`: the fn fires on\n * the source COMPLETE (reading `terminal===true`) and emits the accumulator + COMPLETE. An empty\n * source emits the seed (RxJS parity). A source ERROR auto-forwards (errorWhenDepsError default).\n */\nexport function reduce<S, T>(reducer: (acc: T, v: S) => T, seed: T): Operator<S, T> {\n\treturn {\n\t\tfactory: \"reduce\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tlet acc = ctx.state.get<T>() ?? seed;\n\t\t\tif (b) for (const v of b) acc = reducer(acc, v as S);\n\t\t\tctx.state.set(acc);\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([[\"DATA\", acc], [\"COMPLETE\"]]);\n\t\t\t// else (live DATA wave): no emit → substrate-synthesized undirty RESOLVED (D49).\n\t\t},\n\t};\n}\n\n/**\n * pairwise: emit `[previous, current]` for each consecutive pair; the very first value produces no\n * pair (quiet → undirty RESOLVED). Previous value is kept in `ctx.state`.\n */\nexport function pairwise<S>(): Operator<S, readonly [S, S]> {\n\treturn {\n\t\tfactory: \"pairwise\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tconst st = ctx.state.get<{ prev: S }>();\n\t\t\tlet prev = st?.prev;\n\t\t\tlet hasPrev = st !== undefined;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (hasPrev) ctx.down([[\"DATA\", [prev as S, v] as const]]);\n\t\t\t\tprev = v;\n\t\t\t\thasPrev = true;\n\t\t\t}\n\t\t\tif (hasPrev) ctx.state.set({ prev: prev as S });\n\t\t},\n\t};\n}\n\n/** skip: drop the first `n` DATA values, then pass the rest through. */\nexport function skip<S>(n: number): Operator<S, S> {\n\treturn {\n\t\tfactory: \"skip\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet count = ctx.state.get<number>() ?? 0;\n\t\t\tfor (const v of b) {\n\t\t\t\tif (count < n) {\n\t\t\t\t\tcount += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t}\n\t\t\tctx.state.set(count);\n\t\t},\n\t};\n}\n\n/**\n * takeWhile: emit values while `pred` holds; on the first value that fails `pred`, COMPLETE\n * WITHOUT emitting it (RxJS default, non-inclusive). Terminal-is-forever once it completes.\n */\nexport function takeWhile<S>(pred: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"takeWhile\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (pred(v)) ctx.down([[\"DATA\", v]]);\n\t\t\t\telse {\n\t\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * first: emit the first value matching `pred` (or simply the first value), then COMPLETE. EDGE\n * (RxJS divergence, flagged — same class as last/find/elementAt): if the source COMPLETEs with no\n * matching value, the substrate auto-cascades a bare COMPLETE (no value); RxJS `first()` throws\n * EmptyError. Could align to `[[ERROR, EmptyError]]` (expressible) if strict RxJS parity is wanted.\n */\nexport function first<S>(pred?: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"first\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (!pred || pred(v)) {\n\t\t\t\t\tctx.down([[\"DATA\", v], [\"COMPLETE\"]]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// no match in this wave → undirty RESOLVED (await next match)\n\t\t},\n\t};\n}\n\n/**\n * last: emit the last value matching `pred` (or the last value) on the source's COMPLETE.\n * `completeWhenDepsComplete:false + terminalAsRealInput:true`. EDGE (RxJS divergence, flagged):\n * RxJS `last()` throws EmptyError when no value matched; we COMPLETE without a value (no throw) —\n * the clean-slate substrate has no \"complete-or-throw\" terminal and SENTINEL forbids emitting a\n * placeholder.\n */\nexport function last<S>(pred?: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"last\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (b) for (const v of b) if (!pred || pred(v as S)) ctx.state.set({ v });\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) {\n\t\t\t\tconst st = ctx.state.get<{ v: S }>();\n\t\t\t\tctx.down(st ? [[\"DATA\", st.v], [\"COMPLETE\"]] : [[\"COMPLETE\"]]);\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * find: emit the first value matching `pred`, then COMPLETE. EDGE (RxJS divergence, flagged): RxJS\n * `find` emits `undefined` then COMPLETE when nothing matched — but `undefined` IS the SENTINEL\n * (R-sentinel), so a not-found source COMPLETE here emits a bare COMPLETE (no value).\n */\nexport function find<S>(pred: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"find\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (b) {\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tif (pred(v as S)) {\n\t\t\t\t\t\tctx.down([[\"DATA\", v], [\"COMPLETE\"]]);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([[\"COMPLETE\"]]); // not found → bare COMPLETE\n\t\t},\n\t};\n}\n\n/**\n * elementAt: emit the value at zero-based `index`, then COMPLETE. EDGE (RxJS divergence, flagged):\n * RxJS throws ArgumentOutOfRangeError if the source completes before `index`; we COMPLETE without\n * a value (no throw), consistent with last/find.\n */\nexport function elementAt<S>(index: number): Operator<S, S> {\n\treturn {\n\t\tfactory: \"elementAt\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tlet count = ctx.state.get<number>() ?? 0;\n\t\t\tif (b) {\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tif (count === index) {\n\t\t\t\t\t\tctx.down([[\"DATA\", v], [\"COMPLETE\"]]);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tctx.state.set(count);\n\t\t\t}\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([[\"COMPLETE\"]]); // index out of range → bare COMPLETE\n\t\t},\n\t};\n}\n\n/** Observer object for {@link tap} — lifecycle-aware side effects (RxJS tap observer form). */\nexport interface TapObserver<T> {\n\tdata?: (value: T) => void;\n\terror?: (err: unknown) => void;\n\tcomplete?: () => void;\n}\n\n/**\n * tap: invoke a side effect on each DATA (function form) or on data/error/complete (observer form);\n * values pass through unchanged. The observer form reads source terminals\n * (`completeWhenDepsComplete:false + errorWhenDepsError:false + terminalAsRealInput:true`) so it can\n * call `error`/`complete` then forward the terminal; the function form lets the substrate\n * auto-cascade terminals.\n */\nexport function tap<S>(fnOrObserver: ((v: S) => void) | TapObserver<S>): Operator<S, S> {\n\tif (typeof fnOrObserver === \"function\") {\n\t\tconst fn = fnOrObserver;\n\t\treturn {\n\t\t\tfactory: \"tap\",\n\t\t\tbody: (ctx) => {\n\t\t\t\tconst b = depBatch(ctx, 0);\n\t\t\t\tif (b)\n\t\t\t\t\tfor (const v of b) {\n\t\t\t\t\t\tfn(v as S);\n\t\t\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\tconst obs = fnOrObserver;\n\treturn {\n\t\tfactory: \"tap\",\n\t\topts: {\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t\tterminalAsRealInput: true,\n\t\t},\n\t\tbody: (ctx) => {\n\t\t\tconst terminal = depTerminal(ctx, 0);\n\t\t\tif (isTerminalComplete(terminal)) {\n\t\t\t\tobs.complete?.();\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isTerminalError(terminal)) {\n\t\t\t\tconst err = terminalErrorValue(terminal);\n\t\t\t\tobs.error?.(err);\n\t\t\t\tctx.down([[\"ERROR\", err]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (b)\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tobs.data?.(v as S);\n\t\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * onFirstData (alias `tapFirst`): invoke `fn` exactly once on the first qualifying value (default\n * `where: v => v != null` — null/undefined pass through without counting as \"first\"), then pass all\n * values through unchanged. The one-shot guard is per-node `ctx.state` (NOT a factory closure, so a\n * second instantiation of the same factory re-arms — R-ctx-state).\n */\nexport function onFirstData<S>(\n\tfn: (v: S) => void,\n\topts?: { where?: (v: S) => boolean },\n): Operator<S, S> {\n\tconst where = opts?.where ?? ((v: S) => v != null);\n\treturn {\n\t\tfactory: \"onFirstData\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet fired = ctx.state.get<boolean>() ?? false;\n\t\t\tfor (const v of b) {\n\t\t\t\tif (!fired && where(v as S)) {\n\t\t\t\t\tfired = true;\n\t\t\t\t\tfn(v as S);\n\t\t\t\t}\n\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t}\n\t\t\tctx.state.set(fired);\n\t\t},\n\t};\n}\n\n/** tapFirst: alias of {@link onFirstData} (the one-shot companion to {@link tap}). */\nexport const tapFirst = onFirstData;\n\n/** Options for {@link settle}. */\nexport interface SettleOpts<S> {\n\t/** Consecutive no-change waves before declaring convergence + COMPLETE. */\n\tquietWaves: number;\n\t/** Optional hard cap on total waves before forced COMPLETE. */\n\tmaxWaves?: number;\n\t/** Optional comparator; a DATA equal to the previous one does NOT reset the quiet counter. */\n\tequals?: (a: S, b: S) => boolean;\n}\n\n/** Internal settle accumulator state (per-node, R-ctx-state). */\ninterface SettleState<S> {\n\tlast: S | undefined;\n\thasValue: boolean;\n\tquiet: number;\n\twaves: number;\n\tdone: boolean;\n}\n\n/**\n * settle: forward each DATA unchanged, watch for convergence, COMPLETE once the source has been\n * quiet for `quietWaves` consecutive waves (or `maxWaves` elapsed). \"Wave\" = one fn invocation\n * (a DATA batch OR a bare undirty RESOLVED end-of-wave). No polling (R-no-polling) — the counter\n * advances only on real upstream waves. `settle`'s own `equals` is a body comparator, NOT the\n * removed substrate `equals` (D49).\n */\nexport function settle<S>(opts: SettleOpts<S>): Operator<S, S> {\n\tconst { quietWaves, maxWaves, equals } = opts;\n\tif (!Number.isInteger(quietWaves) || quietWaves < 1) {\n\t\tthrow new RangeError(`settle: quietWaves must be a positive integer (got ${quietWaves})`);\n\t}\n\tif (maxWaves != null && (!Number.isInteger(maxWaves) || maxWaves < 1)) {\n\t\tthrow new RangeError(`settle: maxWaves must be a positive integer when set (got ${maxWaves})`);\n\t}\n\treturn {\n\t\tfactory: \"settle\",\n\t\tbody: (ctx) => {\n\t\t\tconst st: SettleState<S> = ctx.state.get<SettleState<S>>() ?? {\n\t\t\t\tlast: undefined,\n\t\t\t\thasValue: false,\n\t\t\t\tquiet: 0,\n\t\t\t\twaves: 0,\n\t\t\t\tdone: false,\n\t\t\t};\n\t\t\tif (st.done) return;\n\t\t\tst.waves++;\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tlet sawChange = false;\n\t\t\tif (b && b.length > 0) {\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tconst next = v as S;\n\t\t\t\t\tconst isChange = !st.hasValue || equals == null || !equals(st.last as S, next);\n\t\t\t\t\tif (isChange) sawChange = true;\n\t\t\t\t\tst.last = next;\n\t\t\t\t\tst.hasValue = true;\n\t\t\t\t\tctx.down([[\"DATA\", next]]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tst.quiet = sawChange ? 0 : st.quiet + 1;\n\t\t\tconst settled = st.hasValue && st.quiet >= quietWaves;\n\t\t\tconst exhausted = maxWaves != null && st.waves >= maxWaves;\n\t\t\tif (settled || exhausted) {\n\t\t\t\tst.done = true;\n\t\t\t\tctx.state.set(st);\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tctx.state.set(st);\n\t\t\t// A no-DATA wave that didn't converge → bare undirty RESOLVED is synthesized by the\n\t\t\t// substrate (D49); nothing to emit here.\n\t\t},\n\t};\n}\n\n// ── Slice 3 — error-handling control (CSP-2.7, D40) ──\n// rescue/catchError ABSORB the source ERROR (errorWhenDepsError:false) and read the error payload\n// from `depTerminal(ctx, 0)` (R-deps-terminal). They set completeWhenDepsComplete:false so a\n// normal source COMPLETE is forwarded explicitly — which ALSO sidesteps B40 (the\n// completeWhenDepsComplete:true × absorbed-errored-dep auto-complete gap): there is no auto-complete\n// to block. valve is a [source, control] gate (state-verb-legitimate control input).\n\n/**\n * rescue (alias `catchError`): replace an upstream ERROR with a recovered value. On source DATA →\n * forward; on source ERROR → emit `recover(err)` as DATA (if `recover` throws, forward THAT as\n * ERROR); on source COMPLETE → COMPLETE. After recovery the source is terminal-errored (dead) so no\n * further values flow — the recovered value is the final cached value (matches the frozen pure-ts\n * reference; it does NOT auto-COMPLETE, RxJS-`catchError(()=>of(x))` divergence, flagged).\n */\nexport function rescue<S>(recover: (err: unknown) => S): Operator<S, S> {\n\treturn {\n\t\tfactory: \"rescue\",\n\t\topts: {\n\t\t\terrorWhenDepsError: false,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\tterminalAsRealInput: true,\n\t\t},\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tconst terminal = depTerminal(ctx, 0);\n\t\t\tif (b) for (const v of b) ctx.down([[\"DATA\", v]]);\n\t\t\tif (isTerminalComplete(terminal)) {\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t} else if (isTerminalError(terminal)) {\n\t\t\t\t// ERROR payload absorbed → recover.\n\t\t\t\ttry {\n\t\t\t\t\tctx.down([[\"DATA\", recover(terminalErrorValue(terminal))]]);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"rescue threw without a valid error payload\")]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/** catchError: RxJS-named alias of {@link rescue}. */\nexport const catchError = rescue;\n\n/** Options for {@link valve}. */\nexport interface ValveOpts {\n\t/**\n\t * Optional AbortController (or a `() => AbortController | undefined` factory): on the control's\n\t * truthy→falsy edge, `valve` calls `controller.abort()` — cancel an in-flight async boundary\n\t * (LLM/fetch) the caller threaded `controller.signal` into. An external-resource cleanup (like\n\t * `ctx.onDeactivation`), NOT an imperative reactive trigger (R-no-imperative).\n\t */\n\tabortInFlight?: AbortController | (() => AbortController | undefined);\n}\n\n/**\n * valve: forward the source's DATA only while `control` (dep 1) is truthy; when closed, stay quiet\n * (undirty RESOLVED). `[source, control]` declared deps + `partial:true` (the control wave can fire\n * before the source ever delivers). `completeWhenDepsComplete:false` — closing the gate (control\n * terminating) does NOT complete the valve; only the SOURCE's terminal (read via\n * `terminalAsRealInput`) is forwarded. The `state`-verb control input is a legitimate external\n * boundary (D4 / D54), not a forbidden imperative trigger.\n */\nexport function valve<S>(opts?: ValveOpts): Operator<S, S> {\n\tconst abortInFlight = opts?.abortInFlight;\n\treturn {\n\t\tfactory: \"valve\",\n\t\topts: { partial: true, completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst srcBatch = depBatch(ctx, 0);\n\t\t\tconst ctlBatch = depBatch(ctx, 1);\n\t\t\tconst srcTerminal = depTerminal(ctx, 0);\n\t\t\tconst controlValue = depLatest(ctx, 1) as boolean | undefined;\n\n\t\t\tif (abortInFlight != null) {\n\t\t\t\t// Fire abort on the truthy→falsy edge only (never on activation / no prior state).\n\t\t\t\tconst prev = ctx.state.get<{ ctl: boolean | undefined }>();\n\t\t\t\tif (prev?.ctl === true && !controlValue) {\n\t\t\t\t\tconst c = typeof abortInFlight === \"function\" ? abortInFlight() : abortInFlight;\n\t\t\t\t\tc?.abort();\n\t\t\t\t}\n\t\t\t\tctx.state.set({\n\t\t\t\t\tctl: controlValue === true ? true : controlValue == null ? undefined : false,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Source terminal forwarding (control terminal is absorbed by completeWhenDepsComplete:false).\n\t\t\tif (isTerminalComplete(srcTerminal)) {\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isTerminalError(srcTerminal)) {\n\t\t\t\tctx.down([[\"ERROR\", terminalErrorValue(srcTerminal)]]);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!controlValue) return; // gate closed → quiet (undirty RESOLVED)\n\n\t\t\tif (srcBatch && srcBatch.length > 0) {\n\t\t\t\tfor (const v of srcBatch) ctx.down([[\"DATA\", v]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Gate just opened this wave (control fired, source didn't): re-emit the last source value.\n\t\t\tconst srcLatest = depLatest(ctx, 0);\n\t\t\tif (ctlBatch && ctlBatch.length > 0 && srcLatest !== undefined) {\n\t\t\t\tctx.down([[\"DATA\", src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.ts"],"sourcesContent":["/**\n * Async + sync sources (binding-layer sugar, D43 / D40 / feedback_async_sources_binding_layer).\n *\n * Sources are depless {@link Operator}`<never, T>` specs built on the `producer`/`node` path:\n * the body runs ONCE on activation (node `_activate`), schedules its work, and emits later via\n * the captured `ctx.down` (an external tier-3 emit → the leading DIRTY is synthesized for it,\n * R-dirty-before-data). Async lives ONLY here (R-no-raw-async / F-SYNC-CORE): `setTimeout` /\n * `Promise` / `for await` are confined to source bodies; the wave core stays sync. Cleanup is\n * `ctx.onDeactivation` (D28), NOT a returned object. Per-language (D6/D24), never in parity.\n *\n * Instantiate via `g.initNode(timer(1000), [])` (graph-bound, inspectable) or\n * {@link initNode}(timer(1000), []) (bare). Pool/pause defaults (D43): timer/interval =\n * sync + pausable:false (keep producing through PAUSE); fromPromise/fromAsyncIter = async\n * (default pausable, so a paused source buffers its late emits — R-async-paused).\n */\n\nimport type { Ctx } from \"../ctx/types.js\";\nimport type { Node, NodeOptions } from \"../node/node.js\";\nimport { errorPayload } from \"../protocol/messages.js\";\nimport { toCheckpointJson } from \"./checkpoint.js\";\nimport type {\n\tDriverCancel,\n\tDriverResult,\n\tHttpRequest,\n\tHttpResponse,\n\tProcessCommand,\n\tProcessResult,\n\tSseDriverEvent,\n\tSseEvent,\n\tSseRequest,\n\tWebhookDriverEvent,\n\tWebhookEvent,\n\tWebhookRegistration,\n\tWebSocketDriverEvent,\n\tWebSocketEvent,\n\tWebSocketRequest,\n} from \"./environment.js\";\nimport { initNode, type Operator } from \"./operators.js\";\n\n/**\n * Values accepted by {@link fromAny}: an existing Node, a Promise, an (a)sync iterable, or a\n * bare scalar. The universal coercion target for higher-order operators (CSP-2.7).\n */\nexport type NodeInput<T> = Node<T> | PromiseLike<T> | AsyncIterable<T> | Iterable<T> | T;\n\n/** Host-boundary options for {@link singleFromAny}. */\nexport interface SingleFromAnyOptions<K> {\n\t/**\n\t * Map a caller key to the in-flight dedupe key. Defaults to key identity; object keys dedupe only\n\t * when the same object reference is reused. Return a stable string/canonical value for structural\n\t * object-key dedupe.\n\t */\n\tkeyOf?: (key: K) => unknown;\n\t/** Treat a sync iterable result as a stream and take its first item. Defaults to scalar value. */\n\titer?: boolean;\n}\n\n/**\n * Internal: build a depless source spec. `setup` runs once on activation; its returned fn (if\n * any) is registered as the deactivation cleanup (clear timers / abort). `setup` schedules the\n * async work and emits via `ctx.down` — synchronously (sync sources) or later (async sources).\n */\nfunction source<T>(\n\tfactory: string,\n\t// biome-ignore lint/suspicious/noConfusingVoidType: setup returns a cleanup fn OR nothing — the void arm keeps no-return source bodies (e.g. `of`/`fromIter`) ergonomic, same idiom as EffectFn.\n\tsetup: (ctx: Ctx) => void | (() => void),\n\topts?: Partial<NodeOptions<T>>,\n): Operator<never, T> {\n\treturn {\n\t\tfactory,\n\t\topts,\n\t\tbody: (ctx) => {\n\t\t\tlet cleanup: undefined | (() => void);\n\t\t\tlet deactivated = false;\n\t\t\tctx.onDeactivation(() => {\n\t\t\t\tdeactivated = true;\n\t\t\t\tif (typeof cleanup === \"function\") cleanup();\n\t\t\t});\n\t\t\tconst maybeCleanup = setup(ctx);\n\t\t\tcleanup = typeof maybeCleanup === \"function\" ? maybeCleanup : undefined;\n\t\t\tif (deactivated && typeof cleanup === \"function\") cleanup();\n\t\t},\n\t};\n}\n\nfunction assertNonEmptyString(value: string, label: string): void {\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tthrow new TypeError(`${label} must be a non-empty string`);\n\t}\n}\n\nfunction cleanupDriverWork(\n\tactive: { value: boolean },\n\tcancelSlot: { value: DriverCancel | undefined },\n): void {\n\tactive.value = false;\n\tconst cancel = cancelSlot.value;\n\tcancelSlot.value = undefined;\n\tif (cancel !== undefined) runDriverCancel(cancel);\n}\n\nfunction installDriverCancel(\n\tactive: { value: boolean },\n\tcancelSlot: { value: DriverCancel | undefined },\n\tcancel: DriverCancel,\n): void {\n\tif (active.value) cancelSlot.value = cancel;\n\telse runDriverCancel(cancel);\n}\n\nfunction runDriverCancel(cancel: DriverCancel): void {\n\ttry {\n\t\tcancel();\n\t} catch {\n\t\t// Driver cleanup is best-effort: it must not suppress graph-visible terminal delivery.\n\t}\n}\n\nfunction driverOneShotSource<T>(\n\tfactory: string,\n\tmissing: string,\n\tstart: (ctx: Ctx, callback: (result: DriverResult<T>) => void) => DriverCancel | undefined,\n): Operator<never, T> {\n\treturn source<T>(\n\t\tfactory,\n\t\t(ctx) => {\n\t\t\tconst active = { value: true };\n\t\t\tconst cancelSlot: { value: DriverCancel | undefined } = { value: undefined };\n\t\t\tconst callback = (result: DriverResult<T>) => {\n\t\t\t\tif (!active.value) return;\n\t\t\t\tcleanupDriverWork(active, cancelSlot);\n\t\t\t\tif (result.ok) ctx.down([[\"DATA\", result.value], [\"COMPLETE\"]]);\n\t\t\t\telse ctx.down([[\"ERROR\", errorPayload(result.error)]]);\n\t\t\t};\n\t\t\tlet cancel: DriverCancel | undefined;\n\t\t\ttry {\n\t\t\t\tcancel = start(ctx, callback);\n\t\t\t} catch (e) {\n\t\t\t\tactive.value = false;\n\t\t\t\tctx.down([[\"ERROR\", errorPayload(e)]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (cancel === undefined) {\n\t\t\t\tactive.value = false;\n\t\t\t\tctx.down([[\"ERROR\", missing]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tinstallDriverCancel(active, cancelSlot, cancel);\n\t\t\treturn () => cleanupDriverWork(active, cancelSlot);\n\t\t},\n\t\t{ pool: \"async\", pausable: false },\n\t);\n}\n\nfunction driverStreamSource<T, E extends { readonly kind: string }>(\n\tfactory: string,\n\tmissing: string,\n\tstart: (ctx: Ctx, callback: (event: E) => void) => DriverCancel | undefined,\n\tdataOf: (event: E) => T | undefined,\n\terrorOf: (event: E) => unknown,\n): Operator<never, T> {\n\treturn source<T>(\n\t\tfactory,\n\t\t(ctx) => {\n\t\t\tconst active = { value: true };\n\t\t\tconst cancelSlot: { value: DriverCancel | undefined } = { value: undefined };\n\t\t\tconst callback = (event: E) => {\n\t\t\t\tif (!active.value) return;\n\t\t\t\tif (event.kind === \"event\") {\n\t\t\t\t\tconst value = dataOf(event);\n\t\t\t\t\tif (value !== undefined) ctx.down([[\"DATA\", value]]);\n\t\t\t\t} else if (event.kind === \"error\") {\n\t\t\t\t\tcleanupDriverWork(active, cancelSlot);\n\t\t\t\t\tctx.down([[\"ERROR\", errorPayload(errorOf(event))]]);\n\t\t\t\t} else if (event.kind === \"complete\") {\n\t\t\t\t\tcleanupDriverWork(active, cancelSlot);\n\t\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\t}\n\t\t\t};\n\t\t\tlet cancel: DriverCancel | undefined;\n\t\t\ttry {\n\t\t\t\tcancel = start(ctx, callback);\n\t\t\t} catch (e) {\n\t\t\t\tactive.value = false;\n\t\t\t\tctx.down([[\"ERROR\", errorPayload(e)]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (cancel === undefined) {\n\t\t\t\tactive.value = false;\n\t\t\t\tctx.down([[\"ERROR\", missing]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tinstallDriverCancel(active, cancelSlot, cancel);\n\t\t\treturn () => cleanupDriverWork(active, cancelSlot);\n\t\t},\n\t\t{ pool: \"async\", pausable: false },\n\t);\n}\n\nfunction isNode(x: unknown): x is Node {\n\treturn (\n\t\tx != null &&\n\t\ttypeof x === \"object\" &&\n\t\t\"cache\" in x &&\n\t\ttypeof (x as Node).subscribe === \"function\"\n\t);\n}\n\nfunction isThenable(x: unknown): x is PromiseLike<unknown> {\n\treturn x != null && typeof (x as PromiseLike<unknown>).then === \"function\";\n}\n\nfunction isAsyncIterable<T>(x: unknown): x is AsyncIterable<T> {\n\treturn (\n\t\tx !== null &&\n\t\tx !== undefined &&\n\t\ttypeof (x as { [Symbol.asyncIterator]?: unknown })[Symbol.asyncIterator] === \"function\"\n\t);\n}\n\nfunction isIterable<T>(x: unknown): x is Iterable<T> {\n\treturn (\n\t\tx !== null &&\n\t\tx !== undefined &&\n\t\ttypeof (x as { [Symbol.iterator]?: unknown })[Symbol.iterator] === \"function\"\n\t);\n}\n\n/** Options shared by async/timer sources: an optional AbortSignal → ERROR on abort. */\nexport interface AsyncSourceOpts {\n\tsignal?: AbortSignal;\n}\n\nexport interface TimerSourceOpts extends AsyncSourceOpts {\n\tperiod?: number;\n}\n\n/** Options for {@link fromCron}. */\nexport interface FromCronOptions extends AsyncSourceOpts {\n\t/** Cron matcher polling interval in milliseconds. Default: 60_000. */\n\ttickMs?: number;\n\t/**\n\t * Emitted value shape. `timestamp_ns` is a decimal string so it cannot lose precision as a\n\t * JavaScript number; use `timestamp_ms` when numeric millisecond precision is enough.\n\t */\n\toutput?: \"date\" | \"timestamp_ms\" | \"timestamp_ns\";\n}\n\n/** Minimal five-field cron schedule: minute hour day-of-month month day-of-week. */\nexport interface CronSchedule {\n\treadonly minutes: ReadonlySet<number>;\n\treadonly hours: ReadonlySet<number>;\n\treadonly daysOfMonth: ReadonlySet<number>;\n\treadonly months: ReadonlySet<number>;\n\treadonly daysOfWeek: ReadonlySet<number>;\n}\n\n/** DOM/EventEmitter-style target accepted by {@link fromEvent}. */\nexport interface EventTargetLike {\n\taddEventListener(\n\t\ttype: string,\n\t\tlistener: (event: unknown) => void,\n\t\toptions?: EventListenerOptionsLike,\n\t): void;\n\tremoveEventListener(\n\t\ttype: string,\n\t\tlistener: (event: unknown) => void,\n\t\toptions?: EventListenerOptionsLike,\n\t): void;\n}\n\nexport interface EventListenerOptionsLike {\n\tcapture?: boolean;\n\tpassive?: boolean;\n\tonce?: boolean;\n}\n\nexport type FromEventOptions = EventListenerOptionsLike;\n\n/** Host push registration callback accepted by {@link fromPushNotification}. */\nexport type PushUnsubscribe = () => void;\nexport type PushRegister<T> = (deliver: (payload: T) => void) => PushUnsubscribe | undefined;\n\nfunction parseCronField(field: string, min: number, max: number): Set<number> {\n\tif (field.length === 0) throw new Error(\"Invalid cron field: empty\");\n\tconst out = new Set<number>();\n\tfor (const part of field.split(\",\")) {\n\t\tif (part.length === 0) throw new Error(`Invalid cron field: ${field}`);\n\t\tconst stepParts = part.split(\"/\");\n\t\tif (stepParts.length > 2) throw new Error(`Invalid cron step: ${part}`);\n\t\tconst [range, stepText] = stepParts;\n\t\tif (range == null || range.length === 0) throw new Error(`Invalid cron field: ${field}`);\n\t\tif (stepText === \"\") throw new Error(`Invalid cron step: ${part}`);\n\t\tconst step = stepText == null ? 1 : parseCronInt(stepText, `Invalid cron step: ${part}`);\n\t\tif (step < 1) throw new Error(`Invalid cron step: ${part}`);\n\n\t\tlet start: number;\n\t\tlet end: number;\n\t\tif (range === \"*\") {\n\t\t\tstart = min;\n\t\t\tend = max;\n\t\t} else if (range.includes(\"-\")) {\n\t\t\tconst [a, b, extra] = range.split(\"-\");\n\t\t\tif (extra !== undefined || a === \"\" || b === \"\")\n\t\t\t\tthrow new Error(`Invalid cron field: ${field}`);\n\t\t\tstart = parseCronInt(a, `Invalid cron field: ${field}`);\n\t\t\tend = parseCronInt(b, `Invalid cron field: ${field}`);\n\t\t} else {\n\t\t\tstart = parseCronInt(range, `Invalid cron field: ${field}`);\n\t\t\tend = start;\n\t\t}\n\n\t\tif (!Number.isInteger(start) || !Number.isInteger(end)) {\n\t\t\tthrow new Error(`Invalid cron field: ${field}`);\n\t\t}\n\t\tif (start < min || end > max) {\n\t\t\tthrow new RangeError(`Cron field out of range: ${field} (${min}-${max})`);\n\t\t}\n\t\tif (start > end) throw new Error(`Invalid cron range: ${start}-${end} in ${field}`);\n\t\tfor (let i = start; i <= end; i += step) out.add(i);\n\t}\n\treturn out;\n}\n\nfunction parseCronInt(text: string, message: string): number {\n\tif (!/^\\d+$/.test(text)) throw new Error(message);\n\tconst value = Number.parseInt(text, 10);\n\tif (!Number.isSafeInteger(value)) throw new Error(message);\n\treturn value;\n}\n\n/** Parse a standard five-field cron expression. */\nexport function parseCron(expr: string): CronSchedule {\n\tconst parts = expr.trim().split(/\\s+/);\n\tif (parts.length !== 5 || parts.some((part) => part.length === 0)) {\n\t\tthrow new Error(`Invalid cron: expected 5 fields, got ${parts.length}`);\n\t}\n\treturn {\n\t\tminutes: parseCronField(parts[0], 0, 59),\n\t\thours: parseCronField(parts[1], 0, 23),\n\t\tdaysOfMonth: parseCronField(parts[2], 1, 31),\n\t\tmonths: parseCronField(parts[3], 1, 12),\n\t\tdaysOfWeek: parseCronField(parts[4], 0, 6),\n\t};\n}\n\n/** Test whether a local Date matches a parsed cron schedule. */\nexport function matchesCron(schedule: CronSchedule, date: Date): boolean {\n\treturn (\n\t\tschedule.minutes.has(date.getMinutes()) &&\n\t\tschedule.hours.has(date.getHours()) &&\n\t\tschedule.daysOfMonth.has(date.getDate()) &&\n\t\tschedule.months.has(date.getMonth() + 1) &&\n\t\tschedule.daysOfWeek.has(date.getDay())\n\t);\n}\n\nfunction cronMinuteKey(date: Date): string {\n\treturn `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}-${date.getHours()}-${date.getMinutes()}`;\n}\n\nfunction dateToTimestampNs(date: Date): string {\n\treturn (BigInt(date.getTime()) * 1_000_000n).toString();\n}\n\nexport function fromCron(\n\texpr: string,\n\topts: FromCronOptions & { output: \"date\" },\n): Operator<never, Date>;\nexport function fromCron(\n\texpr: string,\n\topts: FromCronOptions & { output: \"timestamp_ms\" },\n): Operator<never, number>;\nexport function fromCron(\n\texpr: string,\n\topts?: FromCronOptions & { output?: \"timestamp_ns\" },\n): Operator<never, string>;\nexport function fromCron(\n\texpr: string,\n\topts?: FromCronOptions,\n): Operator<never, Date | number | string>;\nexport function fromCron(\n\texpr: string,\n\topts: FromCronOptions = {},\n): Operator<never, Date | number | string> {\n\tconst schedule = parseCron(expr);\n\tconst { tickMs = 60_000, output = \"timestamp_ns\", signal } = opts;\n\tif (!Number.isFinite(tickMs) || tickMs <= 0) {\n\t\tthrow new RangeError(\"fromCron: tickMs must be a positive finite number\");\n\t}\n\treturn source<Date | number | string>(\n\t\t\"fromCron\",\n\t\t(ctx) => {\n\t\t\tlet done = false;\n\t\t\tlet lastFiredKey: string | undefined;\n\t\t\tlet intervalId: ReturnType<typeof setInterval> | undefined;\n\t\t\tconst cleanup = () => {\n\t\t\t\tdone = true;\n\t\t\t\tif (intervalId !== undefined) clearInterval(intervalId);\n\t\t\t\tintervalId = undefined;\n\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t};\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (done) return;\n\t\t\t\tcleanup();\n\t\t\t\tctx.down([[\"ERROR\", errorPayload(signal?.reason)]]);\n\t\t\t};\n\t\t\tconst emitNow = (now: Date) => {\n\t\t\t\tif (output === \"date\") ctx.down([[\"DATA\", now]]);\n\t\t\t\telse if (output === \"timestamp_ms\") ctx.down([[\"DATA\", now.getTime()]]);\n\t\t\t\telse ctx.down([[\"DATA\", dateToTimestampNs(now)]]);\n\t\t\t};\n\t\t\tconst check = () => {\n\t\t\t\tif (done) return;\n\t\t\t\tconst now = new Date();\n\t\t\t\tconst key = cronMinuteKey(now);\n\t\t\t\tif (key !== lastFiredKey && matchesCron(schedule, now)) {\n\t\t\t\t\tlastFiredKey = key;\n\t\t\t\t\temitNow(now);\n\t\t\t\t}\n\t\t\t};\n\t\t\tif (signal?.aborted) {\n\t\t\t\tonAbort();\n\t\t\t\treturn cleanup;\n\t\t\t}\n\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\tcheck();\n\t\t\tintervalId = setInterval(check, tickMs);\n\t\t\treturn cleanup;\n\t\t},\n\t\t{ pool: \"sync\", pausable: false },\n\t);\n}\n\nexport function runProcess(\n\tprogram: string,\n\targs: readonly string[] = [],\n): Operator<never, ProcessResult> {\n\treturn runProcessWithOptions({ program, args });\n}\n\nexport function fromProcess(\n\tprogram: string,\n\targs: readonly string[] = [],\n): Operator<never, ProcessResult> {\n\treturn processSource(\"fromProcess\", { program, args });\n}\n\nexport function runProcessWithOptions(command: ProcessCommand): Operator<never, ProcessResult> {\n\treturn processSource(\"runProcess\", command);\n}\n\nfunction processSource(factory: string, command: ProcessCommand): Operator<never, ProcessResult> {\n\tassertNonEmptyString(command.program, `${factory}: program`);\n\treturn driverOneShotSource<ProcessResult>(\n\t\tfactory,\n\t\t`${factory}: missing process driver`,\n\t\t(ctx, callback) => ctx.environment().processDriver()?.run(command, callback),\n\t);\n}\n\nexport function fromHttp(url: string): Operator<never, HttpResponse> {\n\treturn fromHttpWithOptions({ method: \"GET\", url });\n}\n\nexport function fromHttpWithOptions(request: HttpRequest): Operator<never, HttpResponse> {\n\tassertNonEmptyString(request.url, \"fromHttp: url\");\n\tassertNonEmptyString(request.method, \"fromHttp: method\");\n\treturn driverOneShotSource<HttpResponse>(\n\t\t\"fromHttp\",\n\t\t\"fromHttp: missing http driver\",\n\t\t(ctx, callback) => ctx.environment().httpDriver()?.request(request, callback),\n\t);\n}\n\nexport function fromSSE(url: string): Operator<never, SseEvent> {\n\treturn fromSSEWithOptions({ url });\n}\n\nexport function fromSSEWithOptions(request: SseRequest): Operator<never, SseEvent> {\n\tassertNonEmptyString(request.url, \"fromSSE: url\");\n\treturn driverStreamSource<SseEvent, SseDriverEvent>(\n\t\t\"fromSSE\",\n\t\t\"fromSSE: missing sse driver\",\n\t\t(ctx, callback) => ctx.environment().sseDriver()?.connect(request, callback),\n\t\t(event) => (event.kind === \"event\" ? event.event : undefined),\n\t\t(event) => (event.kind === \"error\" ? event.error : undefined),\n\t);\n}\n\nexport function fromWebSocket(url: string): Operator<never, WebSocketEvent> {\n\treturn fromWebSocketWithOptions({ url });\n}\n\nexport function fromWebSocketWithOptions(\n\trequest: WebSocketRequest,\n): Operator<never, WebSocketEvent> {\n\tassertNonEmptyString(request.url, \"fromWebSocket: url\");\n\treturn driverStreamSource<WebSocketEvent, WebSocketDriverEvent>(\n\t\t\"fromWebSocket\",\n\t\t\"fromWebSocket: missing websocket driver\",\n\t\t(ctx, callback) => ctx.environment().webSocketDriver()?.connect(request, callback),\n\t\t(event) => (event.kind === \"event\" ? event.event : undefined),\n\t\t(event) => (event.kind === \"error\" ? event.error : undefined),\n\t);\n}\n\nexport function fromWebhook(id: string): Operator<never, WebhookEvent> {\n\treturn fromWebhookWithOptions({ id });\n}\n\nexport function fromWebhookWithOptions(\n\tregistration: WebhookRegistration,\n): Operator<never, WebhookEvent> {\n\tassertNonEmptyString(registration.id, \"fromWebhook: id\");\n\treturn driverStreamSource<WebhookEvent, WebhookDriverEvent>(\n\t\t\"fromWebhook\",\n\t\t\"fromWebhook: missing webhook driver\",\n\t\t(ctx, callback) => ctx.environment().webhookDriver()?.register(registration, callback),\n\t\t(event) => (event.kind === \"event\" ? event.event : undefined),\n\t\t(event) => (event.kind === \"error\" ? event.error : undefined),\n\t);\n}\n\nfunction timerSource(factory: string, ms: number, opts?: TimerSourceOpts): Operator<never, number> {\n\tconst { period, signal } = opts ?? {};\n\tconst op = source<number>(\n\t\tfactory,\n\t\t(ctx) => {\n\t\t\tlet done = false;\n\t\t\tlet count = 0;\n\t\t\tlet t: ReturnType<typeof setTimeout> | undefined;\n\t\t\tlet iv: ReturnType<typeof setInterval> | undefined;\n\t\t\tconst cleanup = () => {\n\t\t\t\tdone = true;\n\t\t\t\tif (t !== undefined) clearTimeout(t);\n\t\t\t\tif (iv !== undefined) clearInterval(iv);\n\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t};\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (done) return;\n\t\t\t\tcleanup();\n\t\t\t\tctx.down([[\"ERROR\", errorPayload(signal?.reason)]]);\n\t\t\t};\n\t\t\tconst finish = () => {\n\t\t\t\tif (done) return;\n\t\t\t\tif (period != null) {\n\t\t\t\t\tctx.down([[\"DATA\", count++]]);\n\t\t\t\t\tiv = setInterval(() => {\n\t\t\t\t\t\tif (done) return;\n\t\t\t\t\t\tctx.down([[\"DATA\", count++]]);\n\t\t\t\t\t}, period);\n\t\t\t\t} else {\n\t\t\t\t\t// One-shot: DATA then COMPLETE in one wave (terminal-is-forever).\n\t\t\t\t\tdone = true;\n\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\tctx.down([[\"DATA\", count++], [\"COMPLETE\"]]);\n\t\t\t\t}\n\t\t\t};\n\t\t\tif (signal?.aborted) {\n\t\t\t\tonAbort();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\tt = setTimeout(finish, ms);\n\t\t\treturn cleanup;\n\t\t},\n\t\t{ pool: \"sync\", pausable: false },\n\t);\n\tif (factory === \"timer\" && period === undefined && signal === undefined) {\n\t\treturn { ...op, restore: { ref: \"timer\", config: { ms: toCheckpointJson(ms, \"timer.ms\") } } };\n\t}\n\treturn op;\n}\n\n/**\n * Timer source: one-shot (first tick then COMPLETE) or periodic (`{period}` → 0, 1, 2, …).\n * sync pool + pausable:false (a timer keeps producing through PAUSE, R-pause-modes). Emits the\n * tick counter from 0; deactivation clears the timers.\n */\nexport function timer(ms: number, opts?: TimerSourceOpts): Operator<never, number> {\n\treturn timerSource(\"timer\", ms, opts);\n}\n\n/** Frozen pure-ts name for {@link timer}; preserves the real factory name in describe(). */\nexport function fromTimer(ms: number, opts?: TimerSourceOpts): Operator<never, number> {\n\treturn timerSource(\"fromTimer\", ms, opts);\n}\n\n/** interval: periodic ticks (0, 1, 2, …), first at `ms`, then every `ms` (RxJS semantics). */\nexport function interval(ms: number): Operator<never, number> {\n\treturn timerSource(\"interval\", ms, { period: ms });\n}\n\n/**\n * Lift a Promise (or thenable) to a single-value stream: one DATA then COMPLETE, or ERROR on\n * rejection. async pool (default pausable → a paused source buffers its late emit). Optional\n * `signal` aborts to ERROR.\n */\nexport function fromPromise<T>(\n\tp: Promise<T> | PromiseLike<T>,\n\topts?: AsyncSourceOpts,\n): Operator<never, T> {\n\tconst signal = opts?.signal;\n\treturn source<T>(\n\t\t\"fromPromise\",\n\t\t(ctx) => {\n\t\t\tlet settled = false;\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\t// onAbort only runs from a `signal` listener / the `signal.aborted` guard → signal is defined.\n\t\t\t\tctx.down([[\"ERROR\", errorPayload((signal as AbortSignal).reason)]]);\n\t\t\t};\n\t\t\tif (signal?.aborted) {\n\t\t\t\tonAbort();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\tvoid Promise.resolve(p).then(\n\t\t\t\t(v) => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\tsettled = true;\n\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\tctx.down([[\"DATA\", v], [\"COMPLETE\"]]);\n\t\t\t\t},\n\t\t\t\t(e) => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\tsettled = true;\n\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\tctx.down([[\"ERROR\", errorPayload(e)]]);\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn () => {\n\t\t\t\tsettled = true;\n\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t};\n\t\t},\n\t\t{ pool: \"async\" },\n\t);\n}\n\n/**\n * Read an async iterable: each value → DATA; COMPLETE when done; ERROR on failure. async pool.\n * Optional `signal` aborts the pump.\n */\nexport function fromAsyncIter<T>(\n\titerable: AsyncIterable<T>,\n\topts?: AsyncSourceOpts,\n): Operator<never, T> {\n\tconst outerSignal = opts?.signal;\n\treturn source<T>(\n\t\t\"fromAsyncIter\",\n\t\t(ctx) => {\n\t\t\tconst ac = new AbortController();\n\t\t\tconst onOuterAbort = () => ac.abort(outerSignal?.reason);\n\t\t\touterSignal?.addEventListener(\"abort\", onOuterAbort, { once: true });\n\t\t\tlet done = false;\n\t\t\tconst pump = async () => {\n\t\t\t\ttry {\n\t\t\t\t\tfor await (const v of iterable) {\n\t\t\t\t\t\tif (ac.signal.aborted) break;\n\t\t\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t\t\t}\n\t\t\t\t\tif (!ac.signal.aborted) ctx.down([[\"COMPLETE\"]]);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (!ac.signal.aborted) ctx.down([[\"ERROR\", errorPayload(e)]]);\n\t\t\t\t} finally {\n\t\t\t\t\tdone = true;\n\t\t\t\t}\n\t\t\t};\n\t\t\tvoid pump();\n\t\t\treturn () => {\n\t\t\t\tif (!done) ac.abort();\n\t\t\t\touterSignal?.removeEventListener(\"abort\", onOuterAbort);\n\t\t\t};\n\t\t},\n\t\t{ pool: \"async\" },\n\t);\n}\n\n/**\n * of: synchronous values — each argument as DATA, then COMPLETE. `of()` is the EMPTY source.\n */\nexport function of<T = never>(...values: T[]): Operator<never, T> {\n\treturn source<T>(\n\t\t\"of\",\n\t\t(ctx) => {\n\t\t\tfor (const value of values) ctx.down([[\"DATA\", value]]);\n\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t},\n\t\t{ pool: \"sync\" },\n\t);\n}\n\n/** fromIter: a sync iterable — each value → DATA (in order), then COMPLETE, on activation. */\nexport function fromIter<T>(iterable: Iterable<T>): Operator<never, T> {\n\treturn source<T>(\n\t\t\"fromIter\",\n\t\t(ctx) => {\n\t\t\tfor (const v of iterable) ctx.down([[\"DATA\", v]]);\n\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t},\n\t\t{ pool: \"sync\" },\n\t);\n}\n\n/** EMPTY analogue: complete immediately with no DATA. */\nexport function empty<T = never>(): Operator<never, T> {\n\treturn source<T>(\n\t\t\"empty\",\n\t\t(ctx) => {\n\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t},\n\t\t{ pool: \"sync\" },\n\t);\n}\n\n/** NEVER analogue: activate and remain silent until deactivation. */\nexport function never<T = never>(): Operator<never, T> {\n\treturn source<T>(\"never\", () => undefined, { pool: \"sync\" });\n}\n\n/** Error source: terminate with ERROR on activation, coercing invalid host-language payloads. */\nexport function throwError(err: unknown): Operator<never, never> {\n\treturn source<never>(\n\t\t\"throwError\",\n\t\t(ctx) => {\n\t\t\tctx.down([[\"ERROR\", errorPayload(err)]]);\n\t\t},\n\t\t{ pool: \"sync\" },\n\t);\n}\n\n/**\n * Wrap a DOM-style event target. Each event becomes DATA; deactivation removes the listener.\n * External callbacks are source boundaries (D43), so no polling or operator-level async leaks in.\n */\nexport function fromEvent<T = unknown>(\n\ttarget: EventTargetLike,\n\ttype: string,\n\topts: FromEventOptions = {},\n): Operator<never, T> {\n\tif (target == null || typeof target.addEventListener !== \"function\") {\n\t\tthrow new TypeError(\"fromEvent: target must implement addEventListener\");\n\t}\n\tif (typeof target.removeEventListener !== \"function\") {\n\t\tthrow new TypeError(\"fromEvent: target must implement removeEventListener\");\n\t}\n\tif (typeof type !== \"string\" || type.length === 0) {\n\t\tthrow new TypeError(\"fromEvent: event type must be a non-empty string\");\n\t}\n\treturn source<T>(\n\t\t\"fromEvent\",\n\t\t(ctx) => {\n\t\t\tlet done = false;\n\t\t\tconst handler = (event: unknown) => {\n\t\t\t\tif (!done) ctx.down([[\"DATA\", event as T]]);\n\t\t\t};\n\t\t\ttarget.addEventListener(type, handler, opts);\n\t\t\treturn () => {\n\t\t\t\tdone = true;\n\t\t\t\ttarget.removeEventListener(type, handler, opts);\n\t\t\t};\n\t\t},\n\t\t{ pool: \"sync\" },\n\t);\n}\n\n/**\n * Wrap a host push transport. The host owns network/native setup; this factory owns reactive\n * delivery and teardown only, preserving async-at-source-boundary discipline.\n */\nexport function fromPushNotification<T = unknown>(register: PushRegister<T>): Operator<never, T> {\n\tif (typeof register !== \"function\") {\n\t\tthrow new TypeError(\"fromPushNotification: register must be a function\");\n\t}\n\treturn source<T>(\n\t\t\"fromPushNotification\",\n\t\t(ctx) => {\n\t\t\tlet done = false;\n\t\t\tconst deliver = (payload: T) => {\n\t\t\t\tif (!done) ctx.down([[\"DATA\", payload]]);\n\t\t\t};\n\t\t\tconst unsubscribe = register(deliver);\n\t\t\treturn () => {\n\t\t\t\tdone = true;\n\t\t\t\tif (typeof unsubscribe === \"function\") unsubscribe();\n\t\t\t};\n\t\t},\n\t\t{ pool: \"sync\" },\n\t);\n}\n\n/**\n * Coerce a {@link NodeInput}`<T>` to a `Node<T>` (D43 — coercion prerequisite for the CSP-2.7\n * higher-order operators). An existing Node passes through; a thenable → {@link fromPromise};\n * an async iterable → {@link fromAsyncIter}; with `{iter:true}` a sync iterable →\n * {@link fromIter}; everything else → {@link of}. Coerced nodes are bare (use\n * `opts.dispatcher` to bind one, default = process-global D26).\n */\nexport function fromAny<T>(\n\tinput: NodeInput<T>,\n\topts: NodeOptions<T> & { iter?: boolean } = {},\n): Node<T> {\n\tif (isNode(input)) return input as Node<T>;\n\tconst { iter, ...nodeOpts } = opts;\n\tif (isThenable(input)) {\n\t\treturn initNode(fromPromise(input as PromiseLike<T>), [], nodeOpts);\n\t}\n\tif (input !== null && input !== undefined) {\n\t\tconst candidate = input as {\n\t\t\t[Symbol.asyncIterator]?: unknown;\n\t\t\t[Symbol.iterator]?: unknown;\n\t\t};\n\t\tif (typeof candidate[Symbol.asyncIterator] === \"function\") {\n\t\t\treturn initNode(fromAsyncIter(input as AsyncIterable<T>), [], nodeOpts);\n\t\t}\n\t\tif (iter === true && typeof candidate[Symbol.iterator] === \"function\") {\n\t\t\treturn initNode(fromIter(input as Iterable<T>), [], nodeOpts);\n\t\t}\n\t}\n\treturn initNode(of(input as T), [], nodeOpts);\n}\n\n/**\n * Resolve the first DATA from a Node as a Promise. This is a host-boundary escape hatch, not a\n * graph operator; do not call it from reactive node bodies. ERROR rejects, and COMPLETE before DATA\n * rejects because no value exists.\n */\nexport function firstValueFrom<T>(source: Node<T>): Promise<T> {\n\treturn new Promise<T>((resolve, reject) => {\n\t\tlet settled = false;\n\t\tlet shouldUnsub = false;\n\t\tlet unsub: (() => void) | undefined;\n\t\tconst finish = (f: () => void): void => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tf();\n\t\t\tif (unsub) {\n\t\t\t\tunsub();\n\t\t\t\tunsub = undefined;\n\t\t\t} else {\n\t\t\t\tshouldUnsub = true;\n\t\t\t}\n\t\t};\n\t\tunsub = source.subscribe((msg) => {\n\t\t\tif (msg[0] === \"DATA\") {\n\t\t\t\tfinish(() => resolve(msg[1] as T));\n\t\t\t} else if (msg[0] === \"ERROR\") {\n\t\t\t\tfinish(() => reject(msg[1]));\n\t\t\t} else if (msg[0] === \"COMPLETE\") {\n\t\t\t\tfinish(() => reject(new Error(\"firstValueFrom: completed without DATA\")));\n\t\t\t} else if (msg[0] === \"TEARDOWN\") {\n\t\t\t\tfinish(() => reject(new Error(\"firstValueFrom: torn down without DATA\")));\n\t\t\t}\n\t\t});\n\t\tif (shouldUnsub) {\n\t\t\tunsub?.();\n\t\t\tunsub = undefined;\n\t\t}\n\t});\n}\n\nfunction singleFromAnyValue<T>(value: T): T {\n\tif (value === undefined) {\n\t\tthrow new TypeError(\"singleFromAny: undefined is the substrate SENTINEL\");\n\t}\n\treturn value;\n}\n\nasync function firstFromAsyncIterable<T>(input: AsyncIterable<T>): Promise<T> {\n\tconst iter = input[Symbol.asyncIterator]();\n\tconst { value, done } = await iter.next();\n\tif (done) {\n\t\tawait iter.return?.();\n\t\tthrow new Error(\"singleFromAny: factory returned empty async iterable\");\n\t}\n\ttry {\n\t\tawait iter.return?.();\n\t} catch {\n\t\t// The first value is the bridge result; close failures after that are cleanup-only.\n\t}\n\treturn value as T;\n}\n\nfunction firstFromIterable<T>(input: Iterable<T>): Promise<T> {\n\tconst iter = input[Symbol.iterator]();\n\tconst { value, done } = iter.next();\n\tif (done) {\n\t\titer.return?.();\n\t\treturn Promise.reject(new Error(\"singleFromAny: factory returned empty iterable\"));\n\t}\n\ttry {\n\t\titer.return?.();\n\t} catch {\n\t\t// The first value is the bridge result; close failures after that are cleanup-only.\n\t}\n\treturn Promise.resolve(value as T);\n}\n\nfunction nodeInputToPromise<T>(input: NodeInput<T>, opts: { iter?: boolean }): Promise<T> {\n\tif (isThenable(input)) return Promise.resolve(input as PromiseLike<T>).then(singleFromAnyValue);\n\tif (isNode(input)) return firstValueFrom(input as Node<T>).then(singleFromAnyValue);\n\tif (isAsyncIterable<T>(input)) return firstFromAsyncIterable(input).then(singleFromAnyValue);\n\tif (opts.iter === true && isIterable<T>(input)) {\n\t\treturn firstFromIterable(input).then(singleFromAnyValue);\n\t}\n\tif (input === undefined) {\n\t\treturn Promise.reject(new TypeError(\"singleFromAny: undefined is the substrate SENTINEL\"));\n\t}\n\treturn Promise.resolve(singleFromAnyValue(input as T));\n}\n\n/**\n * Keyed singleflight over {@link NodeInput}. Concurrent calls with the same key share one Promise;\n * once that input resolves/rejects, the in-flight entry is cleared and a later call re-runs the\n * factory. Host-boundary helper only; it does not create graph topology.\n */\nexport function singleFromAny<K, T>(\n\tfactory: (key: K) => NodeInput<T>,\n\topts: SingleFromAnyOptions<K> = {},\n): (key: K) => Promise<T> {\n\tconst keyOf = opts.keyOf ?? ((key: K): unknown => key);\n\tconst inFlight = new Map<unknown, Promise<T>>();\n\n\treturn (key: K): Promise<T> => {\n\t\tconst dedupeKey = keyOf(key);\n\t\tconst existing = inFlight.get(dedupeKey);\n\t\tif (existing) return existing;\n\n\t\tlet resolvePending!: (value: T) => void;\n\t\tlet rejectPending!: (reason: unknown) => void;\n\t\tlet tracked!: Promise<T>;\n\t\tconst cleanup = (): void => {\n\t\t\tif (inFlight.get(dedupeKey) === tracked) inFlight.delete(dedupeKey);\n\t\t};\n\t\tconst pending = new Promise<T>((resolve, reject) => {\n\t\t\tresolvePending = resolve;\n\t\t\trejectPending = reject;\n\t\t});\n\t\ttracked = pending.then(\n\t\t\t(value) => {\n\t\t\t\tcleanup();\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(error) => {\n\t\t\t\tcleanup();\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\tinFlight.set(dedupeKey, tracked);\n\t\ttry {\n\t\t\tnodeInputToPromise(factory(key), opts).then(resolvePending, rejectPending);\n\t\t} catch (e) {\n\t\t\trejectPending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