@graphrefly/ts 0.0.0 → 0.0.1

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 (307) hide show
  1. package/README.md +135 -0
  2. package/dist/adapters/index.cjs +105 -66
  3. package/dist/adapters/index.cjs.map +1 -1
  4. package/dist/adapters/index.d.cts +11 -136
  5. package/dist/adapters/index.d.ts +11 -136
  6. package/dist/adapters/index.js +27 -225
  7. package/dist/adapters/index.js.map +1 -1
  8. package/dist/adapters/observe-storage.d.cts +4 -4
  9. package/dist/adapters/observe-storage.d.ts +4 -4
  10. package/dist/adapters/observe-storage.js +1 -0
  11. package/dist/adapters/observe-storage.js.map +1 -1
  12. package/dist/adapters/react.cjs +166 -0
  13. package/dist/adapters/react.cjs.map +1 -0
  14. package/dist/adapters/react.d.cts +31 -0
  15. package/dist/adapters/react.d.ts +31 -0
  16. package/dist/adapters/react.js +51 -0
  17. package/dist/adapters/react.js.map +1 -0
  18. package/dist/adapters/solid.cjs +157 -0
  19. package/dist/adapters/solid.cjs.map +1 -0
  20. package/dist/adapters/solid.d.cts +26 -0
  21. package/dist/adapters/solid.d.ts +26 -0
  22. package/dist/adapters/solid.js +48 -0
  23. package/dist/adapters/solid.js.map +1 -0
  24. package/dist/adapters/svelte.cjs +148 -0
  25. package/dist/adapters/svelte.cjs.map +1 -0
  26. package/dist/adapters/svelte.d.cts +31 -0
  27. package/dist/adapters/svelte.d.ts +31 -0
  28. package/dist/adapters/svelte.js +46 -0
  29. package/dist/adapters/svelte.js.map +1 -0
  30. package/dist/adapters/vue.cjs +155 -0
  31. package/dist/adapters/vue.cjs.map +1 -0
  32. package/dist/adapters/vue.d.cts +26 -0
  33. package/dist/adapters/vue.d.ts +26 -0
  34. package/dist/adapters/vue.js +46 -0
  35. package/dist/adapters/vue.js.map +1 -0
  36. package/dist/agent-runtime-BesGDZcB.d.ts +555 -0
  37. package/dist/agent-runtime-DZTJ3C-p.d.cts +555 -0
  38. package/dist/agentic-memory-BmRCvh0d.d.ts +517 -0
  39. package/dist/agentic-memory-DfuVZ-lY.d.cts +517 -0
  40. package/dist/capability-admission-B0BzqAm5.d.cts +102 -0
  41. package/dist/capability-admission-g0mn9hpq.d.ts +102 -0
  42. package/dist/{chunk-JR4IKCR2.js → chunk-2747WN4Y.js} +5 -5
  43. package/dist/{chunk-2ILL7HQI.js → chunk-3JR3EDB2.js} +17 -17
  44. package/dist/{chunk-2ILL7HQI.js.map → chunk-3JR3EDB2.js.map} +1 -1
  45. package/dist/{chunk-GDL26N2T.js → chunk-3KN7NJDR.js} +2 -2
  46. package/dist/{chunk-DJC4CHLQ.js → chunk-43BKLFZU.js} +9 -9
  47. package/dist/chunk-6XAIOL3X.js +2407 -0
  48. package/dist/chunk-6XAIOL3X.js.map +1 -0
  49. package/dist/{chunk-SCRFRCGR.js → chunk-BSQGE5PS.js} +1 -1
  50. package/dist/{chunk-Y3ZLRGHC.js → chunk-CZNV3VXM.js} +16 -16
  51. package/dist/chunk-DGUM43GV.js +11 -0
  52. package/dist/chunk-DGUM43GV.js.map +1 -0
  53. package/dist/{chunk-JIMUDQN3.js → chunk-FBUU43PM.js} +2 -2
  54. package/dist/chunk-H75VXTGT.js +219 -0
  55. package/dist/chunk-H75VXTGT.js.map +1 -0
  56. package/dist/{chunk-RIIOUTGM.js → chunk-HKK2JD7Z.js} +12 -9
  57. package/dist/chunk-HKK2JD7Z.js.map +1 -0
  58. package/dist/{chunk-D6BG7U6A.js → chunk-IXZBUWSP.js} +3 -3
  59. package/dist/chunk-PC3BTTBE.js +3217 -0
  60. package/dist/chunk-PC3BTTBE.js.map +1 -0
  61. package/dist/chunk-QFY4AFY4.js +879 -0
  62. package/dist/chunk-QFY4AFY4.js.map +1 -0
  63. package/dist/{chunk-DK554R7P.js → chunk-S6HXABGL.js} +2 -1
  64. package/dist/chunk-S6HXABGL.js.map +1 -0
  65. package/dist/{chunk-PKVBHGBM.js → chunk-SS2A464I.js} +7 -7
  66. package/dist/chunk-UT3MHJCW.js +49 -0
  67. package/dist/chunk-UT3MHJCW.js.map +1 -0
  68. package/dist/{chunk-G4M3NHRJ.js → chunk-V7CIJE4B.js} +3 -3
  69. package/dist/{chunk-TEW47IVR.js → chunk-VPEFSDME.js} +2 -2
  70. package/dist/chunk-VTHLCFN4.js +368 -0
  71. package/dist/chunk-VTHLCFN4.js.map +1 -0
  72. package/dist/{chunk-SWTLEQL6.js → chunk-WQIA3GFB.js} +2 -2
  73. package/dist/chunk-WQIA3GFB.js.map +1 -0
  74. package/dist/{chunk-I3IHOHCJ.js → chunk-XKXWK2KP.js} +108 -64
  75. package/dist/chunk-XKXWK2KP.js.map +1 -0
  76. package/dist/{chunk-COHO25CZ.js → chunk-YDSIVHRR.js} +553 -7
  77. package/dist/chunk-YDSIVHRR.js.map +1 -0
  78. package/dist/chunk-YXMZ2N6J.js +1884 -0
  79. package/dist/chunk-YXMZ2N6J.js.map +1 -0
  80. package/dist/composition/index.cjs +102 -57
  81. package/dist/composition/index.cjs.map +1 -1
  82. package/dist/composition/index.d.cts +4 -4
  83. package/dist/composition/index.d.ts +4 -4
  84. package/dist/composition/index.js +6 -5
  85. package/dist/core/index.cjs +102 -57
  86. package/dist/core/index.cjs.map +1 -1
  87. package/dist/core/index.d.cts +2 -2
  88. package/dist/core/index.d.ts +2 -2
  89. package/dist/core/index.js +5 -4
  90. package/dist/cqrs/index.cjs.map +1 -1
  91. package/dist/cqrs/index.d.cts +4 -4
  92. package/dist/cqrs/index.d.ts +4 -4
  93. package/dist/cqrs/index.js +3 -2
  94. package/dist/cqrs/index.js.map +1 -1
  95. package/dist/cqrs/messaging.cjs +312 -0
  96. package/dist/cqrs/messaging.cjs.map +1 -0
  97. package/dist/cqrs/messaging.d.cts +57 -0
  98. package/dist/cqrs/messaging.d.ts +57 -0
  99. package/dist/cqrs/messaging.js +274 -0
  100. package/dist/cqrs/messaging.js.map +1 -0
  101. package/dist/cqrs/work-queue.cjs +329 -0
  102. package/dist/cqrs/work-queue.cjs.map +1 -0
  103. package/dist/cqrs/work-queue.d.cts +90 -0
  104. package/dist/cqrs/work-queue.d.ts +90 -0
  105. package/dist/cqrs/work-queue.js +292 -0
  106. package/dist/cqrs/work-queue.js.map +1 -0
  107. package/dist/data/index.cjs +19 -0
  108. package/dist/data/index.cjs.map +1 -0
  109. package/dist/data/index.d.cts +36 -0
  110. package/dist/data/index.d.ts +36 -0
  111. package/dist/data/index.js +1 -0
  112. package/dist/data/index.js.map +1 -0
  113. package/dist/data-structures/index.cjs +105 -57
  114. package/dist/data-structures/index.cjs.map +1 -1
  115. package/dist/data-structures/index.d.cts +8 -8
  116. package/dist/data-structures/index.d.ts +8 -8
  117. package/dist/data-structures/index.js +7 -6
  118. package/dist/{describe-BZb7AS2y.d.ts → describe-BpyJuWkw.d.ts} +1 -1
  119. package/dist/{describe-Ciu8SUnN.d.cts → describe-DYMw_l1C.d.cts} +1 -1
  120. package/dist/executors/work-queue.cjs +342 -0
  121. package/dist/executors/work-queue.cjs.map +1 -0
  122. package/dist/executors/work-queue.d.cts +90 -0
  123. package/dist/executors/work-queue.d.ts +90 -0
  124. package/dist/executors/work-queue.js +306 -0
  125. package/dist/executors/work-queue.js.map +1 -0
  126. package/dist/graph/index.cjs +112 -58
  127. package/dist/graph/index.cjs.map +1 -1
  128. package/dist/graph/index.d.cts +9 -9
  129. package/dist/graph/index.d.ts +9 -9
  130. package/dist/graph/index.js +18 -17
  131. package/dist/{graph-DfdF9zy4.d.ts → graph-D-1-SQeC.d.ts} +3 -3
  132. package/dist/{graph-s23RbbFO.d.cts → graph-DCEWh4T2.d.cts} +3 -3
  133. package/dist/{index-CAEmLCYF.d.cts → index-72VZC0-E.d.cts} +2 -2
  134. package/dist/{index-SnzZu3x7.d.ts → index-Bmxeu0nK.d.ts} +2 -2
  135. package/dist/index.cjs +112 -58
  136. package/dist/index.cjs.map +1 -1
  137. package/dist/index.d.cts +11 -10
  138. package/dist/index.d.ts +11 -10
  139. package/dist/index.js +118 -113
  140. package/dist/inspection/boundary.cjs +98 -0
  141. package/dist/inspection/boundary.cjs.map +1 -0
  142. package/dist/inspection/boundary.d.cts +61 -0
  143. package/dist/inspection/boundary.d.ts +61 -0
  144. package/dist/inspection/boundary.js +75 -0
  145. package/dist/inspection/boundary.js.map +1 -0
  146. package/dist/{messages-BZqrGGm1.d.ts → messages-CAzUPPJM.d.cts} +10 -5
  147. package/dist/{messages-BZqrGGm1.d.cts → messages-CAzUPPJM.d.ts} +10 -5
  148. package/dist/messaging/index.cjs +744 -613
  149. package/dist/messaging/index.cjs.map +1 -1
  150. package/dist/messaging/index.d.cts +216 -160
  151. package/dist/messaging/index.d.ts +216 -160
  152. package/dist/messaging/index.js +19 -749
  153. package/dist/messaging/index.js.map +1 -1
  154. package/dist/operators/index.cjs +102 -57
  155. package/dist/operators/index.cjs.map +1 -1
  156. package/dist/operators/index.d.cts +6 -6
  157. package/dist/operators/index.d.ts +6 -6
  158. package/dist/operators/index.js +8 -7
  159. package/dist/orchestration/index.cjs +3333 -59
  160. package/dist/orchestration/index.cjs.map +1 -1
  161. package/dist/orchestration/index.d.cts +7 -4
  162. package/dist/orchestration/index.d.ts +7 -4
  163. package/dist/orchestration/index.js +49 -8
  164. package/dist/orchestration/index.js.map +1 -1
  165. package/dist/orchestration/messaging.cjs +314 -0
  166. package/dist/orchestration/messaging.cjs.map +1 -0
  167. package/dist/orchestration/messaging.d.cts +59 -0
  168. package/dist/orchestration/messaging.d.ts +59 -0
  169. package/dist/orchestration/messaging.js +276 -0
  170. package/dist/orchestration/messaging.js.map +1 -0
  171. package/dist/orchestration/work-queue.cjs +262 -0
  172. package/dist/orchestration/work-queue.cjs.map +1 -0
  173. package/dist/orchestration/work-queue.d.cts +85 -0
  174. package/dist/orchestration/work-queue.d.ts +85 -0
  175. package/dist/orchestration/work-queue.js +226 -0
  176. package/dist/orchestration/work-queue.js.map +1 -0
  177. package/dist/patterns/event-flow.cjs +447 -0
  178. package/dist/patterns/event-flow.cjs.map +1 -0
  179. package/dist/patterns/event-flow.d.cts +115 -0
  180. package/dist/patterns/event-flow.d.ts +115 -0
  181. package/dist/patterns/event-flow.js +14 -0
  182. package/dist/patterns/event-flow.js.map +1 -0
  183. package/dist/patterns/index.cjs +423 -18
  184. package/dist/patterns/index.cjs.map +1 -1
  185. package/dist/patterns/index.d.cts +8 -5
  186. package/dist/patterns/index.d.ts +8 -5
  187. package/dist/patterns/index.js +13 -4
  188. package/dist/{reactive-collection-Cb1II1Fi.d.ts → reactive-collection-BAmfrGjd.d.ts} +9 -9
  189. package/dist/{reactive-collection-BxBqtIOE.d.cts → reactive-collection-DNV0-gFi.d.cts} +9 -9
  190. package/dist/{reactive-collection-storage-D-KmjE0J.d.cts → reactive-collection-storage-BNEldDyi.d.cts} +5 -5
  191. package/dist/{reactive-collection-storage-BNiEc-Gd.d.ts → reactive-collection-storage-YZsAQsWK.d.ts} +5 -5
  192. package/dist/{reactive-map-D-g3dv8I.d.cts → reactive-map-DRD1LJ2H.d.cts} +6 -6
  193. package/dist/{reactive-map-BcB4KsQR.d.ts → reactive-map-EsDiCmJk.d.ts} +6 -6
  194. package/dist/render/index.d.cts +3 -3
  195. package/dist/render/index.d.ts +3 -3
  196. package/dist/render/index.js +1 -0
  197. package/dist/{semantic-memory-graph-BYoIlP35.d.cts → semantic-memory-graph-DKuNzuWw.d.cts} +2 -2
  198. package/dist/{semantic-memory-graph-CxyXLms3.d.ts → semantic-memory-graph-uwbwJdhe.d.ts} +2 -2
  199. package/dist/solutions/index.cjs +4478 -2
  200. package/dist/solutions/index.cjs.map +1 -1
  201. package/dist/solutions/index.d.cts +13 -519
  202. package/dist/solutions/index.d.ts +13 -519
  203. package/dist/solutions/index.js +90 -6
  204. package/dist/solutions/reactive-layout/browser/index.cjs +449 -0
  205. package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -0
  206. package/dist/solutions/reactive-layout/browser/index.d.cts +44 -0
  207. package/dist/solutions/reactive-layout/browser/index.d.ts +44 -0
  208. package/dist/solutions/reactive-layout/browser/index.js +69 -0
  209. package/dist/solutions/reactive-layout/browser/index.js.map +1 -0
  210. package/dist/solutions/reactive-layout/index.cjs +4266 -0
  211. package/dist/solutions/reactive-layout/index.cjs.map +1 -0
  212. package/dist/solutions/reactive-layout/index.d.cts +581 -0
  213. package/dist/solutions/reactive-layout/index.d.ts +581 -0
  214. package/dist/solutions/reactive-layout/index.js +86 -0
  215. package/dist/solutions/reactive-layout/index.js.map +1 -0
  216. package/dist/solutions/reactive-layout/node-canvas/index.cjs +545 -0
  217. package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -0
  218. package/dist/solutions/reactive-layout/node-canvas/index.d.cts +54 -0
  219. package/dist/solutions/reactive-layout/node-canvas/index.d.ts +54 -0
  220. package/dist/solutions/reactive-layout/node-canvas/index.js +131 -0
  221. package/dist/solutions/reactive-layout/node-canvas/index.js.map +1 -0
  222. package/dist/solutions/reactive-layout/react-native/index.cjs +494 -0
  223. package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -0
  224. package/dist/solutions/reactive-layout/react-native/index.d.cts +51 -0
  225. package/dist/solutions/reactive-layout/react-native/index.d.ts +51 -0
  226. package/dist/solutions/reactive-layout/react-native/index.js +77 -0
  227. package/dist/solutions/reactive-layout/react-native/index.js.map +1 -0
  228. package/dist/solutions/reactive-layout/skia/index.cjs +547 -0
  229. package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -0
  230. package/dist/solutions/reactive-layout/skia/index.d.cts +64 -0
  231. package/dist/solutions/reactive-layout/skia/index.d.ts +64 -0
  232. package/dist/solutions/reactive-layout/skia/index.js +70 -0
  233. package/dist/solutions/reactive-layout/skia/index.js.map +1 -0
  234. package/dist/solutions/work-item/actions.cjs +2164 -0
  235. package/dist/solutions/work-item/actions.cjs.map +1 -0
  236. package/dist/solutions/work-item/actions.d.cts +201 -0
  237. package/dist/solutions/work-item/actions.d.ts +201 -0
  238. package/dist/solutions/work-item/actions.js +1454 -0
  239. package/dist/solutions/work-item/actions.js.map +1 -0
  240. package/dist/solutions/work-item/scheduling.cjs +2454 -0
  241. package/dist/solutions/work-item/scheduling.cjs.map +1 -0
  242. package/dist/solutions/work-item/scheduling.d.cts +433 -0
  243. package/dist/solutions/work-item/scheduling.d.ts +433 -0
  244. package/dist/solutions/work-item/scheduling.js +32 -0
  245. package/dist/solutions/work-item/scheduling.js.map +1 -0
  246. package/dist/solutions/work-item/work-queue.cjs +306 -0
  247. package/dist/solutions/work-item/work-queue.cjs.map +1 -0
  248. package/dist/solutions/work-item/work-queue.d.cts +71 -0
  249. package/dist/solutions/work-item/work-queue.d.ts +71 -0
  250. package/dist/solutions/work-item/work-queue.js +270 -0
  251. package/dist/solutions/work-item/work-queue.js.map +1 -0
  252. package/dist/sources/browser.cjs +169 -57
  253. package/dist/sources/browser.cjs.map +1 -1
  254. package/dist/sources/browser.d.cts +33 -6
  255. package/dist/sources/browser.d.ts +33 -6
  256. package/dist/sources/browser.js +73 -6
  257. package/dist/sources/browser.js.map +1 -1
  258. package/dist/sources/index.cjs +102 -57
  259. package/dist/sources/index.cjs.map +1 -1
  260. package/dist/sources/index.d.cts +5 -5
  261. package/dist/sources/index.d.ts +5 -5
  262. package/dist/sources/index.js +6 -5
  263. package/dist/sources/node.cjs.map +1 -1
  264. package/dist/sources/node.d.cts +4 -4
  265. package/dist/sources/node.d.ts +4 -4
  266. package/dist/sources/node.js +2 -1
  267. package/dist/sources/node.js.map +1 -1
  268. package/dist/storage/browser.js +1 -0
  269. package/dist/storage/browser.js.map +1 -1
  270. package/dist/storage/index.d.cts +5 -5
  271. package/dist/storage/index.d.ts +5 -5
  272. package/dist/storage/index.js +5 -4
  273. package/dist/storage/node.js +1 -0
  274. package/dist/storage/node.js.map +1 -1
  275. package/dist/store-C-joM4gh.d.ts +123 -0
  276. package/dist/store-CNJwmT-h.d.cts +123 -0
  277. package/dist/testing/index.cjs +1 -0
  278. package/dist/testing/index.cjs.map +1 -1
  279. package/dist/testing/index.d.cts +1 -1
  280. package/dist/testing/index.d.ts +1 -1
  281. package/dist/testing/index.js +3 -2
  282. package/dist/{types-h12mNYbq.d.ts → types-BsJvElYZ.d.ts} +31 -31
  283. package/dist/{types-bNMSWKqF.d.cts → types-CcPIn7sy.d.cts} +31 -31
  284. package/dist/work-item-runtime-C3M79vE9.d.ts +228 -0
  285. package/dist/work-item-runtime-qaVgsL0T.d.cts +228 -0
  286. package/dist/work-queue/index.cjs +1132 -0
  287. package/dist/work-queue/index.cjs.map +1 -0
  288. package/dist/work-queue/index.d.cts +369 -0
  289. package/dist/work-queue/index.d.ts +369 -0
  290. package/dist/work-queue/index.js +1078 -0
  291. package/dist/work-queue/index.js.map +1 -0
  292. package/package.json +266 -2
  293. package/dist/chunk-COHO25CZ.js.map +0 -1
  294. package/dist/chunk-DK554R7P.js.map +0 -1
  295. package/dist/chunk-I3IHOHCJ.js.map +0 -1
  296. package/dist/chunk-RIIOUTGM.js.map +0 -1
  297. package/dist/chunk-SWTLEQL6.js.map +0 -1
  298. /package/dist/{chunk-JR4IKCR2.js.map → chunk-2747WN4Y.js.map} +0 -0
  299. /package/dist/{chunk-GDL26N2T.js.map → chunk-3KN7NJDR.js.map} +0 -0
  300. /package/dist/{chunk-DJC4CHLQ.js.map → chunk-43BKLFZU.js.map} +0 -0
  301. /package/dist/{chunk-SCRFRCGR.js.map → chunk-BSQGE5PS.js.map} +0 -0
  302. /package/dist/{chunk-Y3ZLRGHC.js.map → chunk-CZNV3VXM.js.map} +0 -0
  303. /package/dist/{chunk-JIMUDQN3.js.map → chunk-FBUU43PM.js.map} +0 -0
  304. /package/dist/{chunk-D6BG7U6A.js.map → chunk-IXZBUWSP.js.map} +0 -0
  305. /package/dist/{chunk-PKVBHGBM.js.map → chunk-SS2A464I.js.map} +0 -0
  306. /package/dist/{chunk-G4M3NHRJ.js.map → chunk-V7CIJE4B.js.map} +0 -0
  307. /package/dist/{chunk-TEW47IVR.js.map → chunk-VPEFSDME.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/messaging/index.ts"],"sourcesContent":["/**\n * Reusable application-infrastructure messaging namespace.\n *\n * Retained root messaging utilities land here only after B63 re-derives them\n * onto the D125 package DAG.\n */\n\nimport { depBatch, type NodeFn } from \"../ctx/types.js\";\nimport { type Graph, releaseGraphNodes } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.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 timestampMs: number;\n}\n\n/**\n * Minimal JSON Schema vocabulary for cross-graph/topic payload descriptions.\n *\n * D125/D132 keep this as passive messaging vocabulary: GraphReFly does not ship\n * a validator here and does not make schemas protocol messages.\n */\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/**\n * Recommended passive envelope for payloads that cross topic, agent, or graph\n * boundaries. It is an application fact shape, not a required protocol type.\n */\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\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 interface MessageBusEvent<T = unknown> {\n\treadonly kind: \"publish\" | \"complete\" | \"error\";\n\treadonly topic: string;\n\treadonly seq?: number;\n\treadonly payload?: T;\n\treadonly error?: unknown;\n}\n\nexport interface MessageBusOptions<TTopic extends string = string> {\n\treadonly topics: readonly TTopic[];\n\treadonly name?: string;\n\treadonly now?: () => number;\n}\n\nexport interface MessageBus<TTopic extends string = string> {\n\treadonly topics: readonly TTopic[];\n\ttopic<T = unknown>(name: TTopic): Node<MessageEnvelope<T>>;\n\tpublish<T = unknown>(name: TTopic, payload: T, opts?: { key?: string }): MessageEnvelope<T>;\n\thas(name: string): name is TTopic;\n}\n\ninterface MessageBusState<TTopic extends string> {\n\treadonly graph: Graph;\n\treadonly name: string;\n\treadonly now: () => number;\n\treadonly topics: readonly TTopic[];\n\treadonly records: Map<TTopic, TopicRecord>;\n\tseq: number;\n}\n\ntype ProducedTopicMessage<T = unknown> =\n\t| { readonly kind: \"publish\"; readonly envelope: MessageEnvelope<T> }\n\t| { readonly kind: \"error\"; readonly topic: string; readonly error: unknown };\n\ninterface TopicRecord {\n\treadonly node: Node<MessageEnvelope<unknown>>;\n\treadonly producers: Node<ProducedTopicMessage<unknown>>[];\n\treadonly body: NodeFn;\n}\n\nconst busStates = new WeakMap<MessageBus<string>, MessageBusState<string>>();\n\nexport interface ToTopicOptions {\n\treadonly name?: string;\n\treadonly keyOf?: (value: unknown) => string | undefined;\n}\n\nexport interface ToTopicBundle<T> {\n\treadonly events: Node<MessageBusEvent<T>>;\n}\n\nexport type DynamicHubUnknownTopicPolicy = \"drop\" | \"error\" | \"dead-letter\" | \"create-as-fact\";\n\nexport interface DynamicHubOptions {\n\treadonly name?: string;\n\treadonly topics?: readonly string[];\n\treadonly unknownTopic?: DynamicHubUnknownTopicPolicy;\n\treadonly deadLetter?: boolean;\n\treadonly maxTopics?: number;\n\treadonly maxTopicLength?: number;\n\treadonly now?: () => number;\n}\n\nexport interface DynamicHubMetadata {\n\treadonly seq: number;\n\treadonly cursor: number;\n\treadonly timestampMs: number;\n}\n\nexport type DynamicHubEventKind =\n\t| \"create\"\n\t| \"delete\"\n\t| \"message\"\n\t| \"subscribe\"\n\t| \"close\"\n\t| \"error\"\n\t| \"dead-letter\";\n\nexport type DynamicHubCommand<T = unknown> =\n\t| {\n\t\t\treadonly kind: \"create\";\n\t\t\treadonly topic: string;\n\t\t\treadonly key?: string;\n\t\t\treadonly payload?: T;\n\t }\n\t| {\n\t\t\treadonly kind: \"delete\";\n\t\t\treadonly topic: string;\n\t\t\treadonly key?: string;\n\t\t\treadonly payload?: T;\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 }\n\t| {\n\t\t\treadonly kind: \"subscribe\";\n\t\t\treadonly topic: string;\n\t\t\treadonly key?: string;\n\t\t\treadonly payload?: T;\n\t }\n\t| {\n\t\t\treadonly kind: \"close\";\n\t\t\treadonly key?: string;\n\t\t\treadonly payload?: T;\n\t };\n\nexport interface DynamicHubStatus {\n\treadonly open: boolean;\n\treadonly topics: readonly string[];\n\treadonly seq: number;\n\treadonly cursor: number;\n\treadonly lastEventKind?: DynamicHubEventKind;\n}\n\ninterface DynamicHubEventFrame {\n\treadonly meta: DynamicHubMetadata;\n\treadonly status: DynamicHubStatus;\n}\n\nexport type DynamicHubEvent<T = unknown> = DynamicHubEventFrame &\n\t(\n\t\t| {\n\t\t\t\treadonly kind: \"create\";\n\t\t\t\treadonly topic: string;\n\t\t\t\treadonly key?: string;\n\t\t\t\treadonly payload?: T;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: \"delete\";\n\t\t\t\treadonly topic: string;\n\t\t\t\treadonly key?: string;\n\t\t\t\treadonly payload?: T;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: \"message\";\n\t\t\t\treadonly topic: string;\n\t\t\t\treadonly payload: T;\n\t\t\t\treadonly key?: string;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: \"subscribe\";\n\t\t\t\treadonly topic: string;\n\t\t\t\treadonly key?: string;\n\t\t\t\treadonly payload?: T;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: \"close\";\n\t\t\t\treadonly key?: string;\n\t\t\t\treadonly payload?: T;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: \"error\";\n\t\t\t\treadonly topic?: string;\n\t\t\t\treadonly error: string;\n\t\t\t\treadonly command: unknown;\n\t\t }\n\t\t| {\n\t\t\t\treadonly kind: \"dead-letter\";\n\t\t\t\treadonly topic?: string;\n\t\t\t\treadonly reason: string;\n\t\t\t\treadonly command: unknown;\n\t\t }\n\t);\n\nexport interface DynamicHubError {\n\treadonly topic?: string;\n\treadonly error: string;\n\treadonly command: unknown;\n\treadonly meta: DynamicHubMetadata;\n}\n\nexport interface DynamicHubDeadLetter {\n\treadonly topic?: string;\n\treadonly reason: string;\n\treadonly command: unknown;\n\treadonly meta: DynamicHubMetadata;\n}\n\nexport interface DynamicHub<T = unknown> {\n\treadonly command: Node<DynamicHubCommand<T>>;\n\treadonly events: Node<DynamicHubEvent<T>>;\n\treadonly status: Node<DynamicHubStatus>;\n\treadonly errors: Node<DynamicHubError>;\n\treadonly deadLetter?: Node<DynamicHubDeadLetter>;\n\tcreate(topic: string, opts?: { key?: string; payload?: T }): DynamicHubCommand<T>;\n\tdelete(topic: string, opts?: { key?: string; payload?: T }): DynamicHubCommand<T>;\n\tpublish(topic: string, payload: T, opts?: { key?: string }): DynamicHubCommand<T>;\n\tsubscribeTopic(topic: string, opts?: { key?: string; payload?: T }): DynamicHubCommand<T>;\n\tclose(opts?: { key?: string; payload?: T }): DynamicHubCommand<T>;\n}\n\nexport interface ToHubTopicOptions<T> {\n\treadonly name?: string;\n\treadonly keyOf?: (value: T) => string | undefined;\n}\n\nexport interface ToHubTopicBundle<T> {\n\treadonly commands: Node<DynamicHubCommand<T>>;\n}\n\ninterface DynamicHubState<T> {\n\treadonly graph: Graph;\n\treadonly name: string;\n\treadonly maxTopicLength: number;\n\treadonly commandSources: Node<DynamicHubCommand<T>>[];\n\treadonly commandBody: NodeFn;\n\treadonly releaseEventsRetain: () => void;\n}\n\ninterface DynamicHubRuntime {\n\ttopics: string[];\n\topen: boolean;\n\tseq: number;\n\tcursor: number;\n}\n\nconst dynamicHubStates = new WeakMap<DynamicHub<unknown>, DynamicHubState<unknown>>();\nconst DEFAULT_DYNAMIC_HUB_MAX_TOPICS = 1024;\nconst DEFAULT_DYNAMIC_HUB_MAX_TOPIC_LENGTH = 256;\n\nexport function messageBus<TTopic extends string>(\n\tgraph: Graph,\n\topts: MessageBusOptions<TTopic>,\n): MessageBus<TTopic> {\n\tconst unique = [...new Set(opts.topics)];\n\tif (unique.length !== opts.topics.length) throw new Error(\"messageBus: duplicate topic\");\n\tif (unique.length === 0) throw new Error(\"messageBus: at least one topic is required\");\n\tconst name = opts.name ?? \"messageBus\";\n\tconst state: MessageBusState<TTopic> = {\n\t\tgraph,\n\t\tname,\n\t\tnow: opts.now ?? Date.now,\n\t\ttopics: Object.freeze([...unique]),\n\t\trecords: new Map(),\n\t\tseq: 0,\n\t};\n\tfor (const topic of unique) {\n\t\tconst producers: Node<ProducedTopicMessage<unknown>>[] = [];\n\t\tconst body: NodeFn = (ctx) => {\n\t\t\tfor (let i = 0; i < producers.length; i++) {\n\t\t\t\tfor (const produced of depBatch(ctx, i) ?? []) {\n\t\t\t\t\tif ((produced as ProducedTopicMessage).kind === \"publish\") {\n\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\tproduced as ProducedTopicMessage<unknown> & {\n\t\t\t\t\t\t\t\t\t\tkind: \"publish\";\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t).envelope,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tconst node = graph.node<MessageEnvelope<unknown>>([], body, {\n\t\t\tname: `${name}/${topic}`,\n\t\t\tfactory: \"messageTopic\",\n\t\t\tmeta: { topic },\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t});\n\t\tstate.records.set(topic, { node, producers, body });\n\t}\n\tconst bus: MessageBus<TTopic> = {\n\t\ttopics: state.topics,\n\t\ttopic<T = unknown>(topic: TTopic): Node<MessageEnvelope<T>> {\n\t\t\treturn requireTopic(state, topic) as Node<MessageEnvelope<T>>;\n\t\t},\n\t\tpublish<T = unknown>(\n\t\t\ttopic: TTopic,\n\t\t\tpayload: T,\n\t\t\tpublishOpts: { key?: string } = {},\n\t\t): MessageEnvelope<T> {\n\t\t\tconst node = requireTopic(state, topic);\n\t\t\tconst envelope: MessageEnvelope<T> = {\n\t\t\t\ttopic,\n\t\t\t\tseq: ++state.seq,\n\t\t\t\tpayload,\n\t\t\t\ttimestampMs: state.now(),\n\t\t\t\t...(publishOpts.key === undefined ? {} : { key: publishOpts.key }),\n\t\t\t};\n\t\t\tnode.down([[\"DATA\", envelope as MessageEnvelope<unknown>]]);\n\t\t\treturn envelope;\n\t\t},\n\t\thas(topic: string): topic is TTopic {\n\t\t\treturn state.records.has(topic as TTopic);\n\t\t},\n\t};\n\tbusStates.set(bus as MessageBus<string>, state as unknown as MessageBusState<string>);\n\treturn bus;\n}\n\n/**\n * D135 dynamic messaging hub: topic lifecycle is DATA facts over fixed graph-visible\n * command/event/status/error nodes. Topic keys never create or delete graph nodes.\n */\nexport function dynamicHub<T = unknown>(graph: Graph, opts: DynamicHubOptions = {}): DynamicHub<T> {\n\tconst name = opts.name ?? \"dynamicHub\";\n\tconst unknownTopic = normalizeUnknownTopicPolicy(opts.unknownTopic);\n\tconst maxTopics = normalizeHubLimit(\n\t\topts.maxTopics,\n\t\tDEFAULT_DYNAMIC_HUB_MAX_TOPICS,\n\t\t\"dynamicHub: maxTopics\",\n\t);\n\tconst maxTopicLength = normalizeHubLimit(\n\t\topts.maxTopicLength,\n\t\tDEFAULT_DYNAMIC_HUB_MAX_TOPIC_LENGTH,\n\t\t\"dynamicHub: maxTopicLength\",\n\t);\n\tconst now = opts.now ?? Date.now;\n\tconst initialTopics = uniqueTopics(opts.topics ?? [], maxTopicLength);\n\tif (initialTopics.length > maxTopics) {\n\t\tthrow new Error(\"dynamicHub: topics exceed maxTopics\");\n\t}\n\tconst commandSources: Node<DynamicHubCommand<T>>[] = [];\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 command = graph.node<DynamicHubCommand<T>>([], commandBody, {\n\t\tname: `${name}/command`,\n\t\tfactory: \"dynamicHubCommand\",\n\t\tcompleteWhenDepsComplete: false,\n\t\terrorWhenDepsError: false,\n\t});\n\tconst events = graph.node<DynamicHubEvent<T>>(\n\t\t[command],\n\t\t(ctx) => {\n\t\t\tconst runtime =\n\t\t\t\tctx.state.get<DynamicHubRuntime>() ??\n\t\t\t\t({\n\t\t\t\t\ttopics: [...initialTopics],\n\t\t\t\t\topen: true,\n\t\t\t\t\tseq: 0,\n\t\t\t\t\tcursor: 0,\n\t\t\t\t} satisfies DynamicHubRuntime);\n\t\t\tctx.state.persist(true);\n\t\t\tfor (const commandFact of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst parsed = parseDynamicHubCommand(commandFact);\n\t\t\t\tif (typeof parsed === \"string\") {\n\t\t\t\t\tctx.down([[\"DATA\", hubError(runtime, commandFact, parsed, timestampOrFallback(now))]]);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst reduced = reduceDynamicHubCommand(\n\t\t\t\t\truntime,\n\t\t\t\t\tparsed as DynamicHubCommand<T>,\n\t\t\t\t\tunknownTopic,\n\t\t\t\t\tmaxTopics,\n\t\t\t\t\tmaxTopicLength,\n\t\t\t\t\tnow,\n\t\t\t\t);\n\t\t\t\tfor (const event of reduced) ctx.down([[\"DATA\", event]]);\n\t\t\t}\n\t\t\tctx.state.set(runtime);\n\t\t},\n\t\t{\n\t\t\tname: `${name}/events`,\n\t\t\tfactory: \"dynamicHubEvents\",\n\t\t\tmeta: { unknownTopic },\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst status = graph.node<DynamicHubStatus>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as DynamicHubEvent<T>;\n\t\t\t\tctx.down([[\"DATA\", typed.status]]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/status`,\n\t\t\tfactory: \"dynamicHubStatus\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst errors = graph.node<DynamicHubError>(\n\t\t[events],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as DynamicHubEvent<T>;\n\t\t\t\tif (typed.kind !== \"error\") continue;\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\t...(typed.topic === undefined ? {} : { topic: typed.topic }),\n\t\t\t\t\t\t\terror: typed.error,\n\t\t\t\t\t\t\tcommand: typed.command,\n\t\t\t\t\t\t\tmeta: typed.meta,\n\t\t\t\t\t\t} satisfies DynamicHubError,\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: `${name}/errors`,\n\t\t\tfactory: \"dynamicHubErrors\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst deadLetter =\n\t\topts.deadLetter === true || unknownTopic === \"dead-letter\"\n\t\t\t? graph.node<DynamicHubDeadLetter>(\n\t\t\t\t\t[events],\n\t\t\t\t\t(ctx) => {\n\t\t\t\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\t\t\t\tconst typed = event as DynamicHubEvent<T>;\n\t\t\t\t\t\t\tif (typed.kind !== \"dead-letter\") continue;\n\t\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t...(typed.topic === undefined ? {} : { topic: typed.topic }),\n\t\t\t\t\t\t\t\t\t\treason: typed.reason,\n\t\t\t\t\t\t\t\t\t\tcommand: typed.command,\n\t\t\t\t\t\t\t\t\t\tmeta: typed.meta,\n\t\t\t\t\t\t\t\t\t} satisfies DynamicHubDeadLetter,\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: `${name}/deadLetter`,\n\t\t\t\t\t\tfactory: \"dynamicHubDeadLetter\",\n\t\t\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\t\t\terrorWhenDepsError: false,\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t: undefined;\n\tconst releaseEventsRetain = graph.retain(events, { reason: `${name}.dynamicHub.events` });\n\tconst hub: DynamicHub<T> = {\n\t\tcommand,\n\t\tevents,\n\t\tstatus,\n\t\terrors,\n\t\t...(deadLetter === undefined ? {} : { deadLetter }),\n\t\tcreate(topic, commandOpts = {}) {\n\t\t\treturn publishHubCommand(command, {\n\t\t\t\tkind: \"create\",\n\t\t\t\ttopic,\n\t\t\t\t...(commandOpts.key === undefined ? {} : { key: commandOpts.key }),\n\t\t\t\t...(commandOpts.payload === undefined ? {} : { payload: commandOpts.payload }),\n\t\t\t} as DynamicHubCommand<T>);\n\t\t},\n\t\tdelete(topic, commandOpts = {}) {\n\t\t\treturn publishHubCommand(command, {\n\t\t\t\tkind: \"delete\",\n\t\t\t\ttopic,\n\t\t\t\t...(commandOpts.key === undefined ? {} : { key: commandOpts.key }),\n\t\t\t\t...(commandOpts.payload === undefined ? {} : { payload: commandOpts.payload }),\n\t\t\t} as DynamicHubCommand<T>);\n\t\t},\n\t\tpublish(topic, payload, commandOpts = {}) {\n\t\t\treturn publishHubCommand(command, {\n\t\t\t\tkind: \"publish\",\n\t\t\t\ttopic,\n\t\t\t\tpayload,\n\t\t\t\t...(commandOpts.key === undefined ? {} : { key: commandOpts.key }),\n\t\t\t});\n\t\t},\n\t\tsubscribeTopic(topic, commandOpts = {}) {\n\t\t\treturn publishHubCommand(command, {\n\t\t\t\tkind: \"subscribe\",\n\t\t\t\ttopic,\n\t\t\t\t...(commandOpts.key === undefined ? {} : { key: commandOpts.key }),\n\t\t\t\t...(commandOpts.payload === undefined ? {} : { payload: commandOpts.payload }),\n\t\t\t} as DynamicHubCommand<T>);\n\t\t},\n\t\tclose(commandOpts = {}) {\n\t\t\treturn publishHubCommand(command, {\n\t\t\t\tkind: \"close\",\n\t\t\t\t...(commandOpts.key === undefined ? {} : { key: commandOpts.key }),\n\t\t\t\t...(commandOpts.payload === undefined ? {} : { payload: commandOpts.payload }),\n\t\t\t} as DynamicHubCommand<T>);\n\t\t},\n\t};\n\tdynamicHubStates.set(hub as DynamicHub<unknown>, {\n\t\tgraph,\n\t\tname,\n\t\tmaxTopicLength,\n\t\tcommandSources: commandSources as Node<DynamicHubCommand<unknown>>[],\n\t\tcommandBody,\n\t\treleaseEventsRetain,\n\t});\n\treturn hub;\n}\n\n/** Static D135 projection over hub event facts for one topic key; no topic node is created. */\nexport function fromHubTopic<T = unknown>(\n\thub: DynamicHub<unknown>,\n\ttopic: string,\n\topts: { name?: string } = {},\n): Node<MessageEnvelope<T>> {\n\tconst state = requireDynamicHubState(hub);\n\tassertTopicKey(topic, \"fromHubTopic\", state.maxTopicLength);\n\treturn state.graph.node<MessageEnvelope<T>>(\n\t\t[hub.events],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as DynamicHubEvent<T>;\n\t\t\t\tif (typed.kind !== \"message\" || typed.topic !== topic) continue;\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\ttopic,\n\t\t\t\t\t\t\tseq: typed.meta.seq,\n\t\t\t\t\t\t\tpayload: typed.payload,\n\t\t\t\t\t\t\ttimestampMs: typed.meta.timestampMs,\n\t\t\t\t\t\t\t...(typed.key === undefined ? {} : { key: typed.key }),\n\t\t\t\t\t\t} satisfies MessageEnvelope<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}/fromHubTopic`,\n\t\t\tfactory: \"fromHubTopic\",\n\t\t\tmeta: { topic },\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n}\n\n/** Static D135 command helper: source DATA becomes publish command facts for one topic key. */\nexport function toHubTopic<T>(\n\tgraph: Graph,\n\tsource: Node<T>,\n\thub: DynamicHub<unknown>,\n\ttopic: string,\n\topts: ToHubTopicOptions<T> = {},\n): ToHubTopicBundle<T> {\n\tconst state = requireDynamicHubState(hub);\n\tassertTopicKey(topic, \"toHubTopic\", state.maxTopicLength);\n\tif (state.graph !== graph) throw new Error(\"toHubTopic: hub and source graph must match\");\n\tif (isReachableUpstream(source as Node<unknown>, hub.command as Node<unknown>)) {\n\t\tthrow new Error(\"toHubTopic: source already depends on hub command path\");\n\t}\n\tconst commands = graph.node<DynamicHubCommand<T>>(\n\t\t[source],\n\t\t(ctx) => {\n\t\t\tfor (const value of depBatch(ctx, 0) ?? []) {\n\t\t\t\ttry {\n\t\t\t\t\tconst key = opts.keyOf?.(value as T);\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"publish\",\n\t\t\t\t\t\t\t\ttopic,\n\t\t\t\t\t\t\t\tpayload: value as T,\n\t\t\t\t\t\t\t\t...(key === undefined ? {} : { key }),\n\t\t\t\t\t\t\t} satisfies DynamicHubCommand<T>,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"invalid\",\n\t\t\t\t\t\t\t\ttopic,\n\t\t\t\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\t\t} as unknown as DynamicHubCommand<T>,\n\t\t\t\t\t\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}/toHubTopic`,\n\t\t\tfactory: \"toHubTopic\",\n\t\t\tmeta: { topic },\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst commandSource = commands as Node<DynamicHubCommand<unknown>>;\n\tstate.commandSources.push(commandSource);\n\ttry {\n\t\thub.command.replaceDeps([...state.commandSources], state.commandBody);\n\t} catch (error) {\n\t\tstate.commandSources.splice(state.commandSources.indexOf(commandSource), 1);\n\t\treleaseGraphNodes(graph, [commands as Node<unknown>], {\n\t\t\treason: \"toHubTopic failed command wiring\",\n\t\t});\n\t\tthrow error;\n\t}\n\treturn { commands };\n}\n\nexport function fromTopic<T = unknown, TTopic extends string = string>(\n\tbus: MessageBus<TTopic>,\n\ttopic: TTopic,\n): Node<MessageEnvelope<T>> {\n\treturn bus.topic<T>(topic);\n}\n\nexport function toTopic<T, TTopic extends string>(\n\tgraph: Graph,\n\tsource: Node<T>,\n\tbus: MessageBus<TTopic>,\n\ttopic: TTopic,\n\topts: ToTopicOptions = {},\n): ToTopicBundle<T> {\n\tconst state = busStates.get(bus as MessageBus<string>) as MessageBusState<TTopic> | undefined;\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\tconst record = requireTopicRecord(state, topic);\n\tconst name = opts.name ?? `toTopic/${topic}`;\n\tconst producer = graph.node<ProducedTopicMessage<T>>(\n\t\t[source],\n\t\t(ctx) => {\n\t\t\tfor (const value of depBatch(ctx, 0) ?? []) {\n\t\t\t\ttry {\n\t\t\t\t\tconst key = opts.keyOf?.(value);\n\t\t\t\t\tconst envelope: MessageEnvelope<T> = {\n\t\t\t\t\t\ttopic,\n\t\t\t\t\t\tseq: ++state.seq,\n\t\t\t\t\t\tpayload: value as T,\n\t\t\t\t\t\ttimestampMs: state.now(),\n\t\t\t\t\t\t...(key === undefined ? {} : { key }),\n\t\t\t\t\t};\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"publish\",\n\t\t\t\t\t\t\t\tenvelope,\n\t\t\t\t\t\t\t} satisfies ProducedTopicMessage<T>,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tctx.down([[\"DATA\", { kind: \"error\", topic, error } satisfies ProducedTopicMessage<T>]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname,\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\trecord.producers.push(producer as Node<ProducedTopicMessage<unknown>>);\n\trecord.node.replaceDeps([...record.producers], record.body);\n\tconst events = graph.node<MessageBusEvent<T>>(\n\t\t[producer, source],\n\t\t(ctx) => {\n\t\t\tfor (const produced of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = produced as ProducedTopicMessage<T>;\n\t\t\t\tif (typed.kind === \"publish\") {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"publish\",\n\t\t\t\t\t\t\t\ttopic,\n\t\t\t\t\t\t\t\tseq: typed.envelope.seq,\n\t\t\t\t\t\t\t\tpayload: typed.envelope.payload,\n\t\t\t\t\t\t\t} satisfies MessageBusEvent<T>,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t} else {\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\"DATA\", { kind: \"error\", topic, error: typed.error } satisfies MessageBusEvent<T>],\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst terminal = ctx.terminal[0];\n\t\t\tif (terminal !== false && terminal !== undefined && terminal !== true) {\n\t\t\t\tctx.down([\n\t\t\t\t\t[\"DATA\", { kind: \"error\", topic, error: terminal } satisfies MessageBusEvent<T>],\n\t\t\t\t]);\n\t\t\t}\n\t\t\tconst sourceTerminal = ctx.terminal[1];\n\t\t\tif (sourceTerminal === true) {\n\t\t\t\tctx.down([[\"DATA\", { kind: \"complete\", topic } satisfies MessageBusEvent<T>]]);\n\t\t\t} else if (sourceTerminal !== false && sourceTerminal !== undefined) {\n\t\t\t\tctx.down([\n\t\t\t\t\t[\"DATA\", { kind: \"error\", topic, error: sourceTerminal } satisfies MessageBusEvent<T>],\n\t\t\t\t]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/events`,\n\t\t\tfactory: \"toTopicEvents\",\n\t\t\tmeta: { topic },\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t\tterminalAsRealInput: true,\n\t\t},\n\t);\n\treturn { events };\n}\n\nfunction requireTopic<TTopic extends string>(\n\tstate: MessageBusState<TTopic>,\n\ttopic: TTopic,\n): Node<MessageEnvelope<unknown>> {\n\treturn requireTopicRecord(state, topic).node;\n}\n\nfunction requireTopicRecord<TTopic extends string>(\n\tstate: MessageBusState<TTopic>,\n\ttopic: TTopic,\n): TopicRecord {\n\tconst record = state.records.get(topic);\n\tif (record === undefined) throw new Error(`messageBus: unknown topic '${topic}'`);\n\treturn record;\n}\n\nfunction uniqueTopics(topics: readonly string[], maxTopicLength: number): readonly string[] {\n\tconst unique = [...new Set(topics)];\n\tif (unique.length !== topics.length) throw new Error(\"dynamicHub: duplicate topic\");\n\tfor (const topic of unique) assertTopicKey(topic, \"dynamicHub\", maxTopicLength);\n\treturn Object.freeze(unique.sort());\n}\n\nfunction normalizeUnknownTopicPolicy(\n\tpolicy: DynamicHubOptions[\"unknownTopic\"],\n): DynamicHubUnknownTopicPolicy {\n\tif (policy === undefined) return \"error\";\n\tif (\n\t\tpolicy === \"drop\" ||\n\t\tpolicy === \"error\" ||\n\t\tpolicy === \"dead-letter\" ||\n\t\tpolicy === \"create-as-fact\"\n\t) {\n\t\treturn policy;\n\t}\n\tthrow new Error(\"dynamicHub: unknownTopic policy is not recognized\");\n}\n\nfunction normalizeHubLimit(value: number | undefined, fallback: number, owner: string): number {\n\tif (value === undefined) return fallback;\n\tif (!Number.isInteger(value) || value < 1) {\n\t\tthrow new Error(`${owner} must be a positive integer`);\n\t}\n\treturn value;\n}\n\nfunction publishHubCommand<T>(\n\tcommandNode: Node<DynamicHubCommand<T>>,\n\tcommand: DynamicHubCommand<T>,\n): DynamicHubCommand<T> {\n\tcommandNode.down([[\"DATA\", command]]);\n\treturn command;\n}\n\nfunction parseDynamicHubCommand(value: unknown): DynamicHubCommand<unknown> | string {\n\tif (!isObjectRecord(value)) return \"dynamicHub: command fact must be an object\";\n\tconst kind = value.kind;\n\tif (\n\t\tkind !== \"create\" &&\n\t\tkind !== \"delete\" &&\n\t\tkind !== \"publish\" &&\n\t\tkind !== \"subscribe\" &&\n\t\tkind !== \"close\"\n\t) {\n\t\treturn \"dynamicHub: command kind is not recognized\";\n\t}\n\tif (kind === \"close\") {\n\t\treturn {\n\t\t\tkind,\n\t\t\t...(typeof value.key === \"string\" ? { key: value.key } : {}),\n\t\t\t...(value.payload === undefined ? {} : { payload: value.payload }),\n\t\t};\n\t}\n\tconst topic = value.topic;\n\tif (typeof topic !== \"string\" || topic.length === 0) {\n\t\treturn \"dynamicHub: command topic must be a non-empty string\";\n\t}\n\tif (kind === \"publish\") {\n\t\tif (value.payload === undefined) return \"dynamicHub: publish command payload is required\";\n\t\treturn {\n\t\t\tkind,\n\t\t\ttopic,\n\t\t\tpayload: value.payload,\n\t\t\t...(typeof value.key === \"string\" ? { key: value.key } : {}),\n\t\t};\n\t}\n\treturn {\n\t\tkind,\n\t\ttopic,\n\t\t...(typeof value.key === \"string\" ? { key: value.key } : {}),\n\t\t...(value.payload === undefined ? {} : { payload: value.payload }),\n\t};\n}\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction readHubTimestamp(now: () => number): number | string {\n\ttry {\n\t\tconst timestampMs = now();\n\t\treturn Number.isFinite(timestampMs)\n\t\t\t? timestampMs\n\t\t\t: \"dynamicHub: now() must return a finite number\";\n\t} catch (error) {\n\t\treturn `dynamicHub: now() threw: ${error instanceof Error ? error.message : String(error)}`;\n\t}\n}\n\nfunction timestampOrFallback(now: () => number): number {\n\tconst timestampMs = readHubTimestamp(now);\n\treturn typeof timestampMs === \"number\" ? timestampMs : Date.now();\n}\n\nfunction reduceDynamicHubCommand<T>(\n\truntime: DynamicHubRuntime,\n\tcommand: DynamicHubCommand<T>,\n\tunknownTopic: DynamicHubUnknownTopicPolicy,\n\tmaxTopics: number,\n\tmaxTopicLength: number,\n\tnow: () => number,\n): DynamicHubEvent<T>[] {\n\tconst topic = \"topic\" in command ? command.topic : undefined;\n\tif (topic !== undefined) {\n\t\tconst topicError = validateTopicKey(topic, \"dynamicHub\", maxTopicLength);\n\t\tif (topicError !== undefined) {\n\t\t\treturn [hubError(runtime, command, topicError, timestampOrFallback(now))];\n\t\t}\n\t}\n\tif (!runtime.open && command.kind !== \"close\") {\n\t\treturn [hubError(runtime, command, \"dynamicHub: hub is closed\", timestampOrFallback(now))];\n\t}\n\tswitch (command.kind) {\n\t\tcase \"create\": {\n\t\t\tconst capacityError = canAddHubTopic(runtime, command.topic, maxTopics);\n\t\t\tif (capacityError !== undefined) {\n\t\t\t\treturn [hubError(runtime, command, capacityError, timestampOrFallback(now))];\n\t\t\t}\n\t\t\tconst timestampMs = readHubTimestamp(now);\n\t\t\tif (typeof timestampMs === \"string\")\n\t\t\t\treturn [hubError(runtime, command, timestampMs, Date.now())];\n\t\t\taddHubTopic(runtime, command.topic);\n\t\t\treturn [hubEvent(runtime, timestampMs, command)];\n\t\t}\n\t\tcase \"delete\": {\n\t\t\tif (!hasHubTopic(runtime, command.topic)) {\n\t\t\t\treturn unknownHubTopic(runtime, command, unknownTopic, now);\n\t\t\t}\n\t\t\tconst timestampMs = readHubTimestamp(now);\n\t\t\tif (typeof timestampMs === \"string\")\n\t\t\t\treturn [hubError(runtime, command, timestampMs, Date.now())];\n\t\t\tdeleteHubTopic(runtime, command.topic);\n\t\t\treturn [hubEvent(runtime, timestampMs, command)];\n\t\t}\n\t\tcase \"publish\": {\n\t\t\tif (!hasHubTopic(runtime, command.topic)) {\n\t\t\t\tif (unknownTopic === \"create-as-fact\") {\n\t\t\t\t\tconst capacityError = canAddHubTopic(runtime, command.topic, maxTopics);\n\t\t\t\t\tif (capacityError !== undefined) {\n\t\t\t\t\t\treturn [hubError(runtime, command, capacityError, timestampOrFallback(now))];\n\t\t\t\t\t}\n\t\t\t\t\tconst createTimestampMs = readHubTimestamp(now);\n\t\t\t\t\tif (typeof createTimestampMs === \"string\") {\n\t\t\t\t\t\treturn [hubError(runtime, command, createTimestampMs, Date.now())];\n\t\t\t\t\t}\n\t\t\t\t\tconst messageTimestampMs = readHubTimestamp(now);\n\t\t\t\t\tif (typeof messageTimestampMs === \"string\") {\n\t\t\t\t\t\treturn [hubError(runtime, command, messageTimestampMs, Date.now())];\n\t\t\t\t\t}\n\t\t\t\t\taddHubTopic(runtime, command.topic);\n\t\t\t\t\treturn [\n\t\t\t\t\t\thubEvent(runtime, createTimestampMs, { kind: \"create\", topic: command.topic }),\n\t\t\t\t\t\thubEvent(runtime, messageTimestampMs, {\n\t\t\t\t\t\t\tkind: \"message\",\n\t\t\t\t\t\t\ttopic: command.topic,\n\t\t\t\t\t\t\tpayload: command.payload,\n\t\t\t\t\t\t\t...(command.key === undefined ? {} : { key: command.key }),\n\t\t\t\t\t\t}),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\treturn unknownHubTopic(runtime, command, unknownTopic, now);\n\t\t\t}\n\t\t\tconst timestampMs = readHubTimestamp(now);\n\t\t\tif (typeof timestampMs === \"string\")\n\t\t\t\treturn [hubError(runtime, command, timestampMs, Date.now())];\n\t\t\treturn [\n\t\t\t\thubEvent(runtime, timestampMs, {\n\t\t\t\t\tkind: \"message\",\n\t\t\t\t\ttopic: command.topic,\n\t\t\t\t\tpayload: command.payload,\n\t\t\t\t\t...(command.key === undefined ? {} : { key: command.key }),\n\t\t\t\t}),\n\t\t\t];\n\t\t}\n\t\tcase \"subscribe\": {\n\t\t\tif (!hasHubTopic(runtime, command.topic)) {\n\t\t\t\tif (unknownTopic === \"create-as-fact\") {\n\t\t\t\t\tconst capacityError = canAddHubTopic(runtime, command.topic, maxTopics);\n\t\t\t\t\tif (capacityError !== undefined) {\n\t\t\t\t\t\treturn [hubError(runtime, command, capacityError, timestampOrFallback(now))];\n\t\t\t\t\t}\n\t\t\t\t\tconst createTimestampMs = readHubTimestamp(now);\n\t\t\t\t\tif (typeof createTimestampMs === \"string\") {\n\t\t\t\t\t\treturn [hubError(runtime, command, createTimestampMs, Date.now())];\n\t\t\t\t\t}\n\t\t\t\t\tconst subscribeTimestampMs = readHubTimestamp(now);\n\t\t\t\t\tif (typeof subscribeTimestampMs === \"string\") {\n\t\t\t\t\t\treturn [hubError(runtime, command, subscribeTimestampMs, Date.now())];\n\t\t\t\t\t}\n\t\t\t\t\taddHubTopic(runtime, command.topic);\n\t\t\t\t\treturn [\n\t\t\t\t\t\thubEvent(runtime, createTimestampMs, { kind: \"create\", topic: command.topic }),\n\t\t\t\t\t\thubEvent(runtime, subscribeTimestampMs, command),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\treturn unknownHubTopic(runtime, command, unknownTopic, now);\n\t\t\t}\n\t\t\tconst timestampMs = readHubTimestamp(now);\n\t\t\tif (typeof timestampMs === \"string\")\n\t\t\t\treturn [hubError(runtime, command, timestampMs, Date.now())];\n\t\t\treturn [hubEvent(runtime, timestampMs, command)];\n\t\t}\n\t\tcase \"close\": {\n\t\t\tconst timestampMs = readHubTimestamp(now);\n\t\t\tif (typeof timestampMs === \"string\")\n\t\t\t\treturn [hubError(runtime, command, timestampMs, Date.now())];\n\t\t\truntime.open = false;\n\t\t\treturn [hubEvent(runtime, timestampMs, command)];\n\t\t}\n\t}\n}\n\nfunction hubEvent<T>(\n\truntime: DynamicHubRuntime,\n\ttimestampMs: number,\n\tevent: Record<string, unknown> & { readonly kind: DynamicHubEventKind },\n): DynamicHubEvent<T> {\n\tconst meta = nextHubMetadata(runtime, timestampMs);\n\treturn {\n\t\t...event,\n\t\tmeta,\n\t\tstatus: snapshotHubStatus(runtime, meta, event.kind),\n\t} as DynamicHubEvent<T>;\n}\n\nfunction hubError<T>(\n\truntime: DynamicHubRuntime,\n\tcommand: unknown,\n\terror: string,\n\ttimestampMs: number,\n): DynamicHubEvent<T> {\n\treturn hubEvent(runtime, timestampMs, {\n\t\tkind: \"error\",\n\t\t...(isObjectRecord(command) && typeof command.topic === \"string\"\n\t\t\t? { topic: command.topic }\n\t\t\t: {}),\n\t\terror,\n\t\tcommand,\n\t});\n}\n\nfunction unknownHubTopic<T>(\n\truntime: DynamicHubRuntime,\n\tcommand: DynamicHubCommand<T>,\n\tpolicy: DynamicHubUnknownTopicPolicy,\n\tnow: () => number,\n): DynamicHubEvent<T>[] {\n\tconst topic = \"topic\" in command ? command.topic : undefined;\n\tconst reason = `dynamicHub: unknown topic '${topic ?? \"\"}'`;\n\tif (policy === \"drop\") return [];\n\tif (policy === \"dead-letter\") {\n\t\treturn [\n\t\t\thubEvent(runtime, timestampOrFallback(now), {\n\t\t\t\tkind: \"dead-letter\",\n\t\t\t\t...(topic === undefined ? {} : { topic }),\n\t\t\t\treason,\n\t\t\t\tcommand,\n\t\t\t}),\n\t\t];\n\t}\n\treturn [hubError(runtime, command, reason, timestampOrFallback(now))];\n}\n\nfunction nextHubMetadata(runtime: DynamicHubRuntime, timestampMs: number): DynamicHubMetadata {\n\truntime.seq += 1;\n\truntime.cursor = runtime.seq;\n\treturn { seq: runtime.seq, cursor: runtime.cursor, timestampMs };\n}\n\nfunction snapshotHubStatus(\n\truntime: DynamicHubRuntime,\n\tmeta: DynamicHubMetadata,\n\tkind: DynamicHubEventKind,\n): DynamicHubStatus {\n\treturn {\n\t\topen: runtime.open,\n\t\ttopics: Object.freeze([...runtime.topics].sort()),\n\t\tseq: meta.seq,\n\t\tcursor: meta.cursor,\n\t\tlastEventKind: kind,\n\t};\n}\n\nfunction assertTopicKey(topic: string, owner: string, maxTopicLength: number): void {\n\tconst error = validateTopicKey(topic, owner, maxTopicLength);\n\tif (error !== undefined) throw new Error(error);\n}\n\nfunction validateTopicKey(\n\ttopic: string,\n\towner: string,\n\tmaxTopicLength: number,\n): string | undefined {\n\tif (typeof topic !== \"string\" || topic.length === 0) {\n\t\treturn `${owner}: topic must be a non-empty string`;\n\t}\n\tif (topic.length > maxTopicLength) {\n\t\treturn `${owner}: topic exceeds maxTopicLength`;\n\t}\n\treturn undefined;\n}\n\nfunction hasHubTopic(runtime: DynamicHubRuntime, topic: string): boolean {\n\treturn runtime.topics.includes(topic);\n}\n\nfunction addHubTopic(runtime: DynamicHubRuntime, topic: string): void {\n\tif (!hasHubTopic(runtime, topic)) runtime.topics = [...runtime.topics, topic];\n}\n\nfunction deleteHubTopic(runtime: DynamicHubRuntime, topic: string): void {\n\truntime.topics = runtime.topics.filter((existing) => existing !== topic);\n}\n\nfunction canAddHubTopic(\n\truntime: DynamicHubRuntime,\n\ttopic: string,\n\tmaxTopics: number,\n): string | undefined {\n\tif (hasHubTopic(runtime, topic)) return undefined;\n\treturn runtime.topics.length >= maxTopics\n\t\t? \"dynamicHub: topic count exceeds maxTopics\"\n\t\t: undefined;\n}\n\nfunction isReachableUpstream(from: Node<unknown>, target: Node<unknown>): boolean {\n\tconst seen = new Set<Node<unknown>>();\n\tconst stack: Node<unknown>[] = [from];\n\twhile (stack.length > 0) {\n\t\tconst node = stack.pop();\n\t\tif (node === undefined) continue;\n\t\tif (node === target) return true;\n\t\tif (seen.has(node)) continue;\n\t\tseen.add(node);\n\t\tfor (const dep of node.deps) stack.push(dep);\n\t}\n\treturn false;\n}\n\nfunction requireDynamicHubState(hub: DynamicHub<unknown>): DynamicHubState<unknown> {\n\tconst state = dynamicHubStates.get(hub);\n\tif (state === undefined) throw new Error(\"dynamicHub: unknown hub implementation\");\n\treturn state;\n}\n"],"mappings":";;;;;;;;;;;;AA2DO,IAAM,gBAAgB;AACtB,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AACzB,IAAM,iBAAiB;AACvB,IAAM,eAAe;AACrB,IAAM,gBAAgB;AACtB,IAAM,cAAc;AAEpB,IAAM,kBAAkB,OAAO,OAAO;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;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AACjF,SAAO;AACR;","names":["command"]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -91,6 +91,7 @@ var TIER = {
91
91
  START: TIER_START,
92
92
  PAUSE: TIER_CONTROL,
93
93
  RESUME: TIER_CONTROL,
94
+ PULL: TIER_CONTROL,
94
95
  DIRTY: TIER_NOTIFICATION,
95
96
  DATA: TIER_VALUE,
96
97
  RESOLVED: TIER_VALUE,
@@ -1211,6 +1212,17 @@ function notifyTopologyDepsChanged(node, prevDeps, deps) {
1211
1212
  function terminalView(t) {
1212
1213
  return t === void 0 ? false : t;
1213
1214
  }
1215
+ function normalizePullDemand(demand) {
1216
+ if (typeof demand !== "object" || demand === null || Array.isArray(demand)) {
1217
+ throw new Error("ctx.up: PULL requires { pullId, params? } demand payload (D269)");
1218
+ }
1219
+ const pullId = demand.pullId;
1220
+ if (typeof pullId !== "string" && typeof pullId !== "symbol") {
1221
+ throw new Error("ctx.up: PULL demand requires a string or symbol pullId (D269)");
1222
+ }
1223
+ const params = demand.params;
1224
+ return params === void 0 ? { pullId } : { pullId, params };
1225
+ }
1214
1226
  function validateDownPayloads(msgs) {
1215
1227
  for (const m of msgs) {
1216
1228
  if (m[0] === "DATA" && m[1] === void 0) {
@@ -1254,7 +1266,7 @@ var Node = class {
1254
1266
  const pull = opts.pullId !== void 0;
1255
1267
  if (pull && pausable === false)
1256
1268
  throw new Error(
1257
- "node: pullId is incompatible with pausable:false \u2014 a pull node is demanded via RESUME, which pausable:false ignores (R-pull / R-pause-modes / D55,D59)"
1269
+ "node: pullId is incompatible with pausable:false \u2014 a pull node uses the pausable delivery-content axis (R-pull / R-pause-modes / D55,D269)"
1258
1270
  );
1259
1271
  let handle;
1260
1272
  if (handleOrFn === null) handle = null;
@@ -1277,7 +1289,6 @@ var Node = class {
1277
1289
  value.status = "settled";
1278
1290
  }
1279
1291
  const pauseLockset = /* @__PURE__ */ new Set();
1280
- if (pull) pauseLockset.add(pullLock);
1281
1292
  this._core = core ?? new NodeCore();
1282
1293
  const created = this._core.createSlot(
1283
1294
  {
@@ -1318,7 +1329,9 @@ var Node = class {
1318
1329
  pauseLockset,
1319
1330
  pausedDepWaveOccurred: false,
1320
1331
  pauseBuffer: [],
1321
- demandOwed: false,
1332
+ demandOwed: void 0,
1333
+ activePull: void 0,
1334
+ pullDirtyOwed: false,
1322
1335
  inDeliverDemand: false
1323
1336
  },
1324
1337
  privateState: { value: SENTINEL, persist: false },
@@ -1375,10 +1388,11 @@ var Node = class {
1375
1388
  this._wave.batchDirtyOwed = false;
1376
1389
  this._control.pauseBuffer = [];
1377
1390
  this._control.pausedDepWaveOccurred = false;
1378
- this._control.demandOwed = false;
1391
+ this._control.demandOwed = void 0;
1392
+ this._control.activePull = void 0;
1393
+ this._control.pullDirtyOwed = false;
1379
1394
  this._control.inDeliverDemand = false;
1380
1395
  this._control.pauseLockset.clear();
1381
- if (this._slot.pull) this._control.pauseLockset.add(this._slot.pullLock);
1382
1396
  this._privateState.value = state.ctxState.value;
1383
1397
  this._privateState.persist = state.ctxState.persist;
1384
1398
  if (state.version === false) {
@@ -1417,17 +1431,16 @@ var Node = class {
1417
1431
  subscriberCountReaders.set(this, () => this._subscriberCount());
1418
1432
  activationReaders.set(this, () => this._lifecycle.activated);
1419
1433
  }
1420
- /** R-pull (D55): true while a pull node is quiet (holds its own pullId/demand lock). */
1434
+ /** R-pull (D55/D272): true while a pull node is not serving a PULL demand pulse. */
1421
1435
  _isPullQuiet() {
1422
- return this._slot.pull && this._control.pauseLockset.has(this._slot.pullLock);
1436
+ return this._slot.pull && this._control.activePull === void 0;
1423
1437
  }
1424
1438
  /**
1425
- * R-pull (D55/D59): this pull node's pullId (pure data, like {@link cache}/{@link handle} — never
1426
- * triggers computation). A consumer demands one delivery by cone-routing a RESUME of it (no node
1427
- * reference): `ctx.up([["RESUME", pullId]])` (immediate; loops back → D37 for a self-read dep) or
1428
- * `ctx.upNext([["RESUME", pullId]])` (boundary-deferred self-demand, R-up-routing/R-rewire-deferred).
1429
- * Undefined for a non-pull node. The author writes the pullId verbatim, so this getter is mainly
1430
- * for inspection/describe; routing matches by the pullId value carried in the RESUME, by identity.
1439
+ * R-pull (D269/D272): this pull node's pullId (pure data, like {@link cache}/{@link handle} —
1440
+ * never triggers computation). A consumer demands one delivery by cone-routing PULL of it (no
1441
+ * node reference): `ctx.up([["PULL", { pullId }]])` (immediate; loops back → D37 for a self-read
1442
+ * dep) or `ctx.upNext([["PULL", { pullId }]])` (boundary-deferred self-demand). Undefined for a
1443
+ * non-pull node. The author writes the pullId verbatim; routing matches by identity.
1431
1444
  */
1432
1445
  get pullId() {
1433
1446
  return this._slot.pullLock;
@@ -1534,10 +1547,10 @@ var Node = class {
1534
1547
  });
1535
1548
  }
1536
1549
  /**
1537
- * Enqueue a deferred up-going control wave (R-up-routing / R-pull / D59): at the committed wave
1550
+ * Enqueue a deferred up-going control/demand wave (R-up-routing / R-pull / D269): at the committed wave
1538
1551
  * boundary, route `msgs` up from THIS node (broadcast, or up the single `towardDep` edge). The
1539
- * deferred form of `ctx.up` — the SELF-demand path: a consumer issues `ctx.upNext([[RESUME,
1540
- * pullId]])` to demand a dep it ALSO reads; the demand applies at the boundary (not mid-fn), so
1552
+ * deferred form of `ctx.up` — the SELF-demand path: a consumer issues `ctx.upNext([[PULL,
1553
+ * { pullId }]])` to demand a dep it ALSO reads; the demand applies at the boundary (not mid-fn), so
1541
1554
  * the pull node's delivery loops back as a FRESH wave rather than re-entering the consumer (D37 /
1542
1555
  * R-reentrancy). Rides the same R-rewire-deferred (D47) drain as ctx.rewireNext.
1543
1556
  */
@@ -1752,7 +1765,6 @@ var Node = class {
1752
1765
  this._lifecycle.activated = true;
1753
1766
  const seedRestoredDeps = this._restoredActivationPending;
1754
1767
  this._restoredActivationPending = false;
1755
- if (this._slot.pull) this._control.pauseLockset.add(this._slot.pullLock);
1756
1768
  this._dep.unsubs = new Array(this._slot.deps.length);
1757
1769
  this._dep.idxBoxes = new Array(this._slot.deps.length);
1758
1770
  for (const dep of this._slot.deps)
@@ -1824,7 +1836,9 @@ var Node = class {
1824
1836
  this._control.pauseLockset.clear();
1825
1837
  this._control.pauseBuffer = [];
1826
1838
  this._control.pausedDepWaveOccurred = false;
1827
- this._control.demandOwed = false;
1839
+ this._control.demandOwed = void 0;
1840
+ this._control.activePull = void 0;
1841
+ this._control.pullDirtyOwed = false;
1828
1842
  this._value.replayRing = [];
1829
1843
  if (!this._privateState.persist) this._privateState.value = SENTINEL;
1830
1844
  }
@@ -1836,8 +1850,7 @@ var Node = class {
1836
1850
  return this._lifecycle.subscribers.size;
1837
1851
  }
1838
1852
  _isRuntimeQuiescentForRelease() {
1839
- const allowedPullQuietLock = this._slot.pull && this._control.pauseLockset.size === 1 && this._control.pauseLockset.has(this._slot.pullLock);
1840
- return !this._released && this._value.status !== "dirty" && this._value.status !== "pending" && this._wave.pending === 0 && !this._wave.insideRunWave && !this._wave.inDepMutation && !this._wave.rewireRunPending && !this._wave.batchDirtyOwed && this._dep.dirty.every((dirty) => !dirty) && this._control.pauseBuffer.length === 0 && !this._control.pausedDepWaveOccurred && !this._control.demandOwed && !this._control.inDeliverDemand && (this._control.pauseLockset.size === 0 || allowedPullQuietLock);
1853
+ return !this._released && this._value.status !== "dirty" && this._value.status !== "pending" && this._wave.pending === 0 && !this._wave.insideRunWave && !this._wave.inDepMutation && !this._wave.rewireRunPending && !this._wave.batchDirtyOwed && this._dep.dirty.every((dirty) => !dirty) && this._control.pauseBuffer.length === 0 && !this._control.pausedDepWaveOccurred && this._control.demandOwed === void 0 && this._control.activePull === void 0 && !this._control.inDeliverDemand && this._control.pauseLockset.size === 0;
1841
1854
  }
1842
1855
  _releaseRuntime() {
1843
1856
  if (this._released) return;
@@ -1893,7 +1906,9 @@ var Node = class {
1893
1906
  this._control.pauseLockset.clear();
1894
1907
  this._control.pauseBuffer = [];
1895
1908
  this._control.pausedDepWaveOccurred = false;
1896
- this._control.demandOwed = false;
1909
+ this._control.demandOwed = void 0;
1910
+ this._control.activePull = void 0;
1911
+ this._control.pullDirtyOwed = false;
1897
1912
  this._restoredActivationPending = false;
1898
1913
  checkpointReaders.delete(this);
1899
1914
  restoreWriters.delete(this);
@@ -2075,7 +2090,7 @@ var Node = class {
2075
2090
  this._wave.rewireRunPending = true;
2076
2091
  return;
2077
2092
  }
2078
- if (this._slot.pausable === true && this._isPaused()) {
2093
+ if (this._slot.pausable === true && (this._isPaused() || this._isPullQuiet())) {
2079
2094
  this._control.pausedDepWaveOccurred = true;
2080
2095
  return;
2081
2096
  }
@@ -2215,10 +2230,11 @@ var Node = class {
2215
2230
  unsubscribeDep: (dep, fn) => this._requestRewireNext({ kind: "remove", dep, fn }),
2216
2231
  replaceDeps: (deps, fn) => this._requestRewireNext({ kind: "set", deps, fn })
2217
2232
  },
2218
- // R-up-routing / R-pull (D59): deferred up — route a control wave (e.g. a RESUME pull
2219
- // DEMAND) up the declared cone at the committed boundary. The SELF-demand path: an
2233
+ // R-up-routing / R-pull (D269): deferred up — route a control/demand wave (e.g. PULL)
2234
+ // up the declared cone at the committed boundary. The SELF-demand path: an
2220
2235
  // immediate ctx.up whose delivery loops back re-enters this fn (D37 / R-reentrancy).
2221
2236
  upNext: (msgs, towardDep) => this._requestUpNext(msgs, towardDep),
2237
+ ...this._control.activePull === void 0 ? {} : { pull: this._control.activePull },
2222
2238
  [CTX_DEP_CACHE]: { latest: snapshot?.latest ?? this._dep.prev },
2223
2239
  [CTX_NODE_BINDING]: {
2224
2240
  dispatcher: this._slot.dispatcher,
@@ -2233,6 +2249,11 @@ var Node = class {
2233
2249
  _refreshCtx(ctx) {
2234
2250
  ctx.waveData = this._dep.waveData;
2235
2251
  ctx.terminal = this._dep.terminalInput.map(terminalView);
2252
+ if (this._control.activePull === void 0) {
2253
+ delete ctx.pull;
2254
+ } else {
2255
+ ctx.pull = this._control.activePull;
2256
+ }
2236
2257
  ctx[CTX_DEP_CACHE] = { latest: this._dep.prev };
2237
2258
  }
2238
2259
  _makeState() {
@@ -2325,7 +2346,7 @@ var Node = class {
2325
2346
  plannedVersions[i] = plannedVersion;
2326
2347
  }
2327
2348
  }
2328
- if (hasTier3 && !this._wave.insideRunWave && !this._wave.emittedDirtyThisWave) {
2349
+ if (hasTier3 && (!this._wave.insideRunWave || this._control.pullDirtyOwed) && !this._wave.emittedDirtyThisWave) {
2329
2350
  this._wave.emittedDirtyThisWave = true;
2330
2351
  this._value.status = "dirty";
2331
2352
  this._emitToSubs(["DIRTY"], { wave: deliveryWave, last: false });
@@ -2405,13 +2426,18 @@ var Node = class {
2405
2426
  if (m[0] === "PAUSE") {
2406
2427
  this._pauseAcquire(m[1]);
2407
2428
  } else if (m[0] === "RESUME") {
2408
- if (this._slot.pull && m[1] === this._slot.pullLock) {
2409
- if (!this._markDemandRouted(m[1], routeState)) this._onDemand();
2410
- } else if (this._control.pauseLockset.has(m[1])) {
2429
+ if (this._control.pauseLockset.has(m[1])) {
2411
2430
  this._pauseRelease(m[1]);
2412
2431
  } else {
2413
2432
  this._forwardUp(m, towardDep, routeState);
2414
2433
  }
2434
+ } else if (m[0] === "PULL") {
2435
+ const demand = normalizePullDemand(m[1]);
2436
+ if (this._slot.pull && demand.pullId === this._slot.pullLock) {
2437
+ if (!this._markDemandRouted(demand.pullId, routeState)) this._onDemand(demand);
2438
+ } else {
2439
+ this._forwardUp(["PULL", demand], towardDep, routeState);
2440
+ }
2415
2441
  } else if (this._slot.deps.length === 0) {
2416
2442
  if (m[0] === "INVALIDATE") this._down([["INVALIDATE"]]);
2417
2443
  } else {
@@ -2433,7 +2459,7 @@ var Node = class {
2433
2459
  * Forward one up-going control message toward deps (R-up-routing): up the single declared edge
2434
2460
  * `towardDep` (directed — prunes other branches; only meaningful on the issuer's FIRST hop) or
2435
2461
  * broadcast up ALL deps. A depless source has no deps → the message DROPS here (the terminus —
2436
- * e.g. a cone-routed RESUME whose pullId no node up this cone holds, R-up-at-source). Recursive
2462
+ * e.g. a cone-routed PULL whose pullId no node up this cone holds, R-up-at-source). Recursive
2437
2463
  * forwarding carries the same per-wave route state and no `towardDep` → broadcast beyond the
2438
2464
  * first hop.
2439
2465
  */
@@ -2452,9 +2478,7 @@ var Node = class {
2452
2478
  }
2453
2479
  _hasBoundaryPauseLock() {
2454
2480
  if (this._slot.pausable === false) return false;
2455
- let locks = this._control.pauseLockset.size;
2456
- if (this._slot.pull && this._control.pauseLockset.has(this._slot.pullLock)) locks--;
2457
- return locks > 0;
2481
+ return this._control.pauseLockset.size > 0;
2458
2482
  }
2459
2483
  _isAsyncPool() {
2460
2484
  return this._slot.handle !== null && this._slot.dispatcher.poolKind(this._slot.handle.poolId) === "async";
@@ -2465,17 +2489,19 @@ var Node = class {
2465
2489
  _pauseRelease(lockId) {
2466
2490
  if (!this._control.pauseLockset.has(lockId)) return;
2467
2491
  this._control.pauseLockset.delete(lockId);
2468
- if (this._slot.pull && this._control.demandOwed) this._fireOwedDemandIfReady();
2492
+ if (this._slot.pull && this._control.demandOwed !== void 0) this._fireOwedDemandIfReady();
2469
2493
  if (this._hasBoundaryPauseLock()) return;
2470
2494
  scheduleBoundaryDrain(this._core);
2471
- if (this._control.pauseLockset.size > 0) return;
2495
+ if (this._slot.pull) return;
2472
2496
  this._onResume();
2473
2497
  }
2474
2498
  _onResume() {
2475
2499
  if (this._value.terminal !== void 0) {
2476
2500
  this._control.pauseBuffer = [];
2477
2501
  this._control.pausedDepWaveOccurred = false;
2478
- this._control.demandOwed = false;
2502
+ this._control.demandOwed = void 0;
2503
+ this._control.activePull = void 0;
2504
+ this._control.pullDirtyOwed = false;
2479
2505
  return;
2480
2506
  }
2481
2507
  if (this._control.pauseBuffer.length > 0) {
@@ -2489,41 +2515,38 @@ var Node = class {
2489
2515
  }
2490
2516
  }
2491
2517
  /**
2492
- * R-pull (D59): can this pull node fire a demand NOW? — not terminal, settle-ready (_pending===0),
2518
+ * R-pull (D269): can this pull node fire a demand NOW? — not terminal, settle-ready (_pending===0),
2493
2519
  * and no OTHER (non-pullId) lock holds it paused. The gate that decides fire-now vs OWE.
2494
2520
  */
2495
2521
  _canFireDemand() {
2496
2522
  if (this._value.terminal !== void 0 || this._wave.pending > 0) return false;
2497
- const own = this._control.pauseLockset.has(this._slot.pullLock) ? 1 : 0;
2498
- return this._control.pauseLockset.size <= own;
2523
+ return this._control.pauseLockset.size === 0;
2499
2524
  }
2500
2525
  /**
2501
- * R-pull (D59): deliver ONE demand pulse — release the pullId so the demand wave RELAYS (not
2502
- * absorbed), fire it, then RE-QUIET (1:1). The pullId re-add + the re-entrancy flag are in a
2503
- * `finally` so a throwing pull fn (graph-less node, no D30 catch) cannot leave the node
2504
- * permanently non-quiet (the wedge-fix silently disabled) — QA-found robustness fix.
2526
+ * R-pull (D269/D272): deliver ONE demand pulse — install activePull so the demand wave may
2527
+ * emit, fire it, then clear activePull so the node is quiet again (1:1).
2505
2528
  */
2506
- _deliverPullDemand() {
2507
- this._control.demandOwed = false;
2529
+ _deliverPullDemand(demand) {
2530
+ this._control.demandOwed = void 0;
2531
+ this._control.activePull = demand;
2508
2532
  this._control.inDeliverDemand = true;
2509
- this._control.pauseLockset.delete(this._slot.pullLock);
2510
2533
  try {
2511
2534
  this._firePullDemand();
2512
2535
  } finally {
2513
- this._control.pauseLockset.add(this._slot.pullLock);
2536
+ this._control.activePull = void 0;
2514
2537
  this._control.inDeliverDemand = false;
2515
2538
  }
2516
2539
  }
2517
2540
  /**
2518
- * R-pull (D59): a cone-routed RESUME of THIS node's pullId arrived (R-up-routing) = a DEMAND.
2541
+ * R-pull (D269): a cone-routed PULL of THIS node's pullId arrived (R-up-routing) = a DEMAND.
2519
2542
  * Fire immediately if able; else OWE it — pin-5 (a dep DIRTY in flight, _pending>0) or F4/F5 (an
2520
2543
  * external PAUSE lock co-holds the node) — and fire when the node next becomes able. A demand
2521
2544
  * arriving WHILE a delivery is in flight (synchronous re-entry) is DROPPED (1:1, QA guard).
2522
2545
  */
2523
- _onDemand() {
2546
+ _onDemand(demand) {
2524
2547
  if (this._control.inDeliverDemand) return;
2525
- if (this._canFireDemand()) this._deliverPullDemand();
2526
- else this._control.demandOwed = true;
2548
+ if (this._canFireDemand()) this._deliverPullDemand(demand);
2549
+ else this._control.demandOwed = demand;
2527
2550
  }
2528
2551
  /**
2529
2552
  * R-pull (D55): service ONE demand. Delivery content = the orthogonal pausable mode:
@@ -2536,33 +2559,53 @@ var Node = class {
2536
2559
  * `_markDirty` relays the leading DIRTY (not absorbed).
2537
2560
  */
2538
2561
  _firePullDemand() {
2562
+ let drainedBuffer = false;
2539
2563
  if (this._control.pauseBuffer.length > 0) {
2540
2564
  const buf = this._control.pauseBuffer;
2541
2565
  this._control.pauseBuffer = [];
2542
2566
  for (const wave of buf) this._down(wave);
2567
+ drainedBuffer = true;
2543
2568
  }
2569
+ if (drainedBuffer) return;
2544
2570
  if (this._control.pausedDepWaveOccurred) {
2545
2571
  const gated = this._slot.handle !== null && !this._wave.hasCalledFnOnce && !(this._slot.partial || this._allDepsSettled());
2546
2572
  if (this._wave.pending > 0 || gated) return;
2547
2573
  this._control.pausedDepWaveOccurred = false;
2548
- this._markDirty();
2549
- this._tryRun();
2574
+ this._wave.emittedDirtyThisWave = false;
2575
+ this._control.pullDirtyOwed = true;
2576
+ try {
2577
+ this._tryRun();
2578
+ } finally {
2579
+ this._control.pullDirtyOwed = false;
2580
+ }
2581
+ return;
2582
+ }
2583
+ if (this._slot.handle !== null) {
2584
+ if (!this._wave.hasCalledFnOnce && !(this._slot.partial || this._allDepsSettled())) return;
2585
+ this._wave.emittedDirtyThisWave = false;
2586
+ this._control.pullDirtyOwed = true;
2587
+ try {
2588
+ this._runWave();
2589
+ } finally {
2590
+ this._control.pullDirtyOwed = false;
2591
+ }
2550
2592
  }
2551
2593
  }
2552
2594
  /**
2553
- * R-pull (D55/D59): fire a demand that was OWED (deferred at demand time) once the node becomes
2595
+ * R-pull (D269): fire a demand that was OWED (deferred at demand time) once the node becomes
2554
2596
  * able — called from the dep-settle arms (DATA/RESOLVED/INVALIDATE/terminal drain _pending, pin-5
2555
2597
  * + B1/F6) and from `_pauseRelease` (an external PAUSE lock releases, F4/F5).
2556
2598
  */
2557
2599
  _fireOwedDemandIfReady() {
2558
2600
  if (this._control.inDeliverDemand) return;
2559
- if (this._slot.pull && this._control.demandOwed && this._canFireDemand())
2560
- this._deliverPullDemand();
2601
+ if (this._slot.pull && this._control.demandOwed !== void 0 && this._canFireDemand()) {
2602
+ this._deliverPullDemand(this._control.demandOwed);
2603
+ }
2561
2604
  }
2562
2605
  /** Should an outgoing settle slice be deferred into the pause buffer? */
2563
2606
  _shouldBufferOnPause() {
2564
2607
  if (this._slot.pausable === false) return false;
2565
- if (!this._isPaused()) return false;
2608
+ if (!this._isPaused() && !this._isPullQuiet()) return false;
2566
2609
  if (this._slot.pausable === "resumeAll") return true;
2567
2610
  if (!this._wave.insideRunWave && this._isAsyncPool() && this._slot.deps.length > 0) return true;
2568
2611
  return false;
@@ -2602,7 +2645,9 @@ var Node = class {
2602
2645
  this._control.pauseLockset.clear();
2603
2646
  this._control.pauseBuffer = [];
2604
2647
  this._control.pausedDepWaveOccurred = false;
2605
- this._control.demandOwed = false;
2648
+ this._control.demandOwed = void 0;
2649
+ this._control.activePull = void 0;
2650
+ this._control.pullDirtyOwed = false;
2606
2651
  this._value.replayRing = [];
2607
2652
  const isCompute = this._slot.handle !== null || this._slot.deps.length > 0;
2608
2653
  if (isCompute) {