@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
@@ -23,6 +23,8 @@ __export(patterns_exports, {
23
23
  admissionFilter3D: () => admissionFilter3D,
24
24
  admissionScored: () => admissionScored,
25
25
  cosineSimilarity: () => cosineSimilarity,
26
+ eventFlow: () => eventFlow,
27
+ eventFlowProjection: () => eventFlowProjection,
26
28
  filterMemoryFragments: () => filterMemoryFragments,
27
29
  isMemoryFragment: () => isMemoryFragment,
28
30
  knowledgeGraphReducerBundle: () => knowledgeGraphReducerBundle,
@@ -35,6 +37,425 @@ __export(patterns_exports, {
35
37
  });
36
38
  module.exports = __toCommonJS(patterns_exports);
37
39
 
40
+ // src/protocol/messages.ts
41
+ var SENTINEL = void 0;
42
+
43
+ // src/ctx/types.ts
44
+ var CTX_DEP_CACHE = /* @__PURE__ */ Symbol("graphrefly.ctx.depCache");
45
+ function depWaves(ctx, depIndex) {
46
+ return ctx.waveData[depIndex] ?? [];
47
+ }
48
+ function depBatch(ctx, depIndex) {
49
+ const waves = depWaves(ctx, depIndex);
50
+ if (waves.length === 0) return null;
51
+ const flattened = waves.flat().filter((v) => v !== SENTINEL);
52
+ return flattened.length === 0 ? [] : flattened;
53
+ }
54
+ function depLatest(ctx, depIndex) {
55
+ return ctx[CTX_DEP_CACHE]?.latest[depIndex];
56
+ }
57
+
58
+ // src/messaging/index.ts
59
+ function eventMessageIssue(value) {
60
+ if (!isObjectRecord(value)) {
61
+ return eventIssue("event message must be an object");
62
+ }
63
+ if (typeof value.id !== "string" || value.id.length === 0) {
64
+ return eventIssue("event message id must be a non-empty string");
65
+ }
66
+ if (typeof value.type !== "string" || value.type.length === 0) {
67
+ return eventIssue("event message type must be a non-empty string");
68
+ }
69
+ if (!("payload" in value)) {
70
+ return eventIssue("event message payload field is required");
71
+ }
72
+ return void 0;
73
+ }
74
+ function eventIssue(message) {
75
+ return {
76
+ kind: "issue",
77
+ code: "malformed-event-message",
78
+ message,
79
+ severity: "error",
80
+ source: "messageBus.eventMessage"
81
+ };
82
+ }
83
+ var PROMPTS_TOPIC = "prompts";
84
+ var RESPONSES_TOPIC = "responses";
85
+ var INJECTIONS_TOPIC = "injections";
86
+ var DEFERRED_TOPIC = "deferred";
87
+ var SPAWNS_TOPIC = "spawns";
88
+ var CONTEXT_TOPIC = "context";
89
+ var TODOS_TOPIC = "todos";
90
+ var STANDARD_TOPICS = Object.freeze([
91
+ PROMPTS_TOPIC,
92
+ RESPONSES_TOPIC,
93
+ INJECTIONS_TOPIC,
94
+ DEFERRED_TOPIC,
95
+ SPAWNS_TOPIC,
96
+ CONTEXT_TOPIC,
97
+ TODOS_TOPIC
98
+ ]);
99
+ function isObjectRecord(value) {
100
+ return typeof value === "object" && value !== null && !Array.isArray(value);
101
+ }
102
+
103
+ // src/patterns/event-flow.ts
104
+ function eventFlow(graph, opts) {
105
+ const name = opts.name ?? opts.flowId ?? "eventFlow";
106
+ const flowId = opts.flowId ?? name;
107
+ const now = opts.now ?? Date.now;
108
+ const sources = normalizeSources(opts.sources);
109
+ const runtime = graph.node(
110
+ sources.map((source) => source.node),
111
+ (ctx) => {
112
+ const state = ctx.state.get() ?? {
113
+ recordSeq: 0,
114
+ auditSeq: 0,
115
+ highWater: /* @__PURE__ */ new Map()
116
+ };
117
+ ctx.state.persist(true);
118
+ for (let i = 0; i < sources.length; i++) {
119
+ const source = sources[i];
120
+ for (const raw of depBatch(ctx, i) ?? []) {
121
+ reduceEventSource(
122
+ raw,
123
+ source.source,
124
+ flowId,
125
+ now(),
126
+ state,
127
+ (fact) => ctx.down([["DATA", fact]])
128
+ );
129
+ }
130
+ }
131
+ ctx.state.set(state);
132
+ },
133
+ {
134
+ name: `${name}/runtime`,
135
+ factory: "eventFlowRuntime",
136
+ meta: { flowId, sources: sources.map((source) => source.source) },
137
+ partial: true,
138
+ completeWhenDepsComplete: false,
139
+ errorWhenDepsError: false
140
+ }
141
+ );
142
+ return {
143
+ records: runtimeProjection(graph, runtime, "record", `${name}/records`, "eventFlowRecords"),
144
+ status: runtimeProjection(graph, runtime, "status", `${name}/status`, "eventFlowStatus"),
145
+ issues: runtimeProjection(graph, runtime, "issue", `${name}/issues`, "eventFlowIssues"),
146
+ audit: runtimeProjection(graph, runtime, "audit", `${name}/audit`, "eventFlowAudit"),
147
+ highWater: runtimeProjection(
148
+ graph,
149
+ runtime,
150
+ "high-water",
151
+ `${name}/highWater`,
152
+ "eventFlowHighWater"
153
+ )
154
+ };
155
+ }
156
+ function eventFlowProjection(graph, flowOrRecords, opts) {
157
+ const records = isEventFlowBundle(flowOrRecords) ? flowOrRecords.records : flowOrRecords;
158
+ const name = opts.name ?? opts.projectionId ?? "eventFlowProjection";
159
+ const projectionId = opts.projectionId ?? name;
160
+ const now = opts.now ?? Date.now;
161
+ const runtime = graph.node(
162
+ [records],
163
+ (ctx) => {
164
+ const state = ctx.state.get() ?? {
165
+ value: opts.initial,
166
+ highWater: emptyHighWater(projectionId),
167
+ sourceHighWater: /* @__PURE__ */ new Map()
168
+ };
169
+ ctx.state.persist(true);
170
+ for (const raw of depBatch(ctx, 0) ?? []) {
171
+ const record = raw;
172
+ try {
173
+ state.value = opts.reduce(state.value, record);
174
+ state.highWater = projectionHighWater(projectionId, record, state.sourceHighWater);
175
+ ctx.down([
176
+ ["DATA", { kind: "frame", frame: { state: state.value, highWater: state.highWater } }],
177
+ [
178
+ "DATA",
179
+ {
180
+ kind: "status",
181
+ status: {
182
+ kind: "projected",
183
+ projectionId,
184
+ recordSeq: record.recordSeq,
185
+ timestampMs: now()
186
+ }
187
+ }
188
+ ],
189
+ ["DATA", { kind: "high-water", highWater: state.highWater }]
190
+ ]);
191
+ } catch (error) {
192
+ const issue = dataIssue(
193
+ "event-flow-projection-threw",
194
+ error instanceof Error ? error.message : "eventFlowProjection reducer threw",
195
+ { projectionId, record }
196
+ );
197
+ ctx.down([
198
+ ["DATA", { kind: "issue", issue }],
199
+ [
200
+ "DATA",
201
+ {
202
+ kind: "status",
203
+ status: {
204
+ kind: "rejected",
205
+ projectionId,
206
+ recordSeq: record.recordSeq,
207
+ issueCode: issue.code,
208
+ timestampMs: now()
209
+ }
210
+ }
211
+ ]
212
+ ]);
213
+ }
214
+ }
215
+ ctx.state.set(state);
216
+ },
217
+ {
218
+ name: `${name}/runtime`,
219
+ factory: "eventFlowProjectionRuntime",
220
+ meta: { projectionId },
221
+ completeWhenDepsComplete: false,
222
+ errorWhenDepsError: false
223
+ }
224
+ );
225
+ return {
226
+ frames: projectionRuntime(
227
+ graph,
228
+ runtime,
229
+ "frame",
230
+ `${name}/frames`,
231
+ "eventFlowProjectionFrames"
232
+ ),
233
+ snapshot: projectionRuntime(
234
+ graph,
235
+ runtime,
236
+ "frame",
237
+ `${name}/snapshot`,
238
+ "eventFlowProjectionSnapshot",
239
+ (fact) => fact.frame.state
240
+ ),
241
+ status: projectionRuntime(
242
+ graph,
243
+ runtime,
244
+ "status",
245
+ `${name}/status`,
246
+ "eventFlowProjectionStatus"
247
+ ),
248
+ issues: projectionRuntime(
249
+ graph,
250
+ runtime,
251
+ "issue",
252
+ `${name}/issues`,
253
+ "eventFlowProjectionIssues"
254
+ ),
255
+ highWater: projectionRuntime(
256
+ graph,
257
+ runtime,
258
+ "high-water",
259
+ `${name}/highWater`,
260
+ "eventFlowProjectionHighWater"
261
+ )
262
+ };
263
+ }
264
+ function reduceEventSource(raw, source, flowId, timestampMs, state, emit) {
265
+ const normalized = normalizeInput(raw, source);
266
+ if (normalized.issue !== void 0) {
267
+ const status2 = {
268
+ kind: "rejected",
269
+ flowId,
270
+ source: normalized.source,
271
+ issueCode: normalized.issue.code,
272
+ timestampMs
273
+ };
274
+ const audit2 = auditRecord(flowId, state, "rejected", timestampMs, {
275
+ source: normalized.source,
276
+ issueCode: normalized.issue.code
277
+ });
278
+ emit({ kind: "issue", issue: normalized.issue });
279
+ emit({ kind: "status", status: status2 });
280
+ emit({ kind: "audit", audit: audit2 });
281
+ emit({ kind: "high-water", highWater: highWaterSnapshot(flowId, state) });
282
+ return;
283
+ }
284
+ const recordSeq = ++state.recordSeq;
285
+ const record = {
286
+ recordSeq,
287
+ flowId,
288
+ event: normalized.event,
289
+ source: normalized.source,
290
+ observedAtMs: timestampMs,
291
+ ...normalized.event.correlationId === void 0 ? {} : { correlationId: normalized.event.correlationId },
292
+ ...normalized.event.causationId === void 0 ? {} : { causationId: normalized.event.causationId }
293
+ };
294
+ state.highWater.set(sourceKey(normalized.source), {
295
+ source: normalized.source.source,
296
+ ...normalized.source.topic === void 0 ? {} : { topic: normalized.source.topic },
297
+ ...normalized.source.seq === void 0 ? {} : { seq: normalized.source.seq },
298
+ messageId: normalized.event.id,
299
+ recordSeq
300
+ });
301
+ const audit = auditRecord(flowId, state, "recorded", timestampMs, {
302
+ source: normalized.source,
303
+ eventId: normalized.event.id,
304
+ eventType: normalized.event.type
305
+ });
306
+ const highWater = highWaterSnapshot(flowId, state);
307
+ const status = {
308
+ kind: "recorded",
309
+ flowId,
310
+ recordSeq,
311
+ eventId: normalized.event.id,
312
+ eventType: normalized.event.type,
313
+ source: normalized.source,
314
+ timestampMs
315
+ };
316
+ emit({ kind: "record", record });
317
+ emit({ kind: "status", status });
318
+ emit({ kind: "audit", audit });
319
+ emit({ kind: "high-water", highWater });
320
+ }
321
+ function normalizeInput(raw, source) {
322
+ const envelope = messageEnvelopeOf(raw);
323
+ const value = envelope?.payload ?? raw;
324
+ const sourceRef = envelope === void 0 ? { source, ...eventIdOf(value) === void 0 ? {} : { messageId: eventIdOf(value) } } : {
325
+ source,
326
+ topic: envelope.topic,
327
+ seq: envelope.seq,
328
+ messageId: envelope.payload.id,
329
+ ...envelope.idempotencyKey === void 0 ? {} : { idempotencyKey: envelope.idempotencyKey }
330
+ };
331
+ const issue = eventMessageIssue(value);
332
+ if (issue !== void 0) {
333
+ return {
334
+ source: sourceRef,
335
+ issue: dataIssue(issue.code, issue.message, { source: sourceRef, value })
336
+ };
337
+ }
338
+ return { event: value, source: sourceRef };
339
+ }
340
+ function messageEnvelopeOf(value) {
341
+ if (!isRecord(value)) return void 0;
342
+ if (typeof value.topic !== "string" || !Number.isInteger(value.seq) || typeof value.timestampMs !== "number" || !("payload" in value)) {
343
+ return void 0;
344
+ }
345
+ const payloadIssue = eventMessageIssue(value.payload);
346
+ return payloadIssue === void 0 ? value : void 0;
347
+ }
348
+ function normalizeSources(sources) {
349
+ if (sources.length === 0) throw new Error("eventFlow: sources must be non-empty");
350
+ return sources.map((source, index) => {
351
+ if (isRecord(source) && "node" in source) {
352
+ if (typeof source.source !== "string" || source.source.length === 0) {
353
+ throw new Error("eventFlow: source name must be non-empty");
354
+ }
355
+ return source;
356
+ }
357
+ return { source: `source-${index}`, node: source };
358
+ });
359
+ }
360
+ function runtimeProjection(graph, runtime, kind, name, factory) {
361
+ return graph.node(
362
+ [runtime],
363
+ (ctx) => {
364
+ for (const fact of depBatch(ctx, 0) ?? []) {
365
+ const typed = fact;
366
+ if (typed.kind === kind) ctx.down([["DATA", valueOfRuntimeFact(typed)]]);
367
+ }
368
+ },
369
+ { name, factory, completeWhenDepsComplete: false, errorWhenDepsError: false }
370
+ );
371
+ }
372
+ function projectionRuntime(graph, runtime, kind, name, factory, map = valueOfRuntimeFact) {
373
+ return graph.node(
374
+ [runtime],
375
+ (ctx) => {
376
+ for (const fact of depBatch(ctx, 0) ?? []) {
377
+ const typed = fact;
378
+ if (typed.kind === kind) ctx.down([["DATA", map(typed)]]);
379
+ }
380
+ },
381
+ { name, factory, completeWhenDepsComplete: false, errorWhenDepsError: false }
382
+ );
383
+ }
384
+ function valueOfRuntimeFact(fact) {
385
+ if ("record" in fact) return fact.record;
386
+ if ("status" in fact) return fact.status;
387
+ if ("issue" in fact) return fact.issue;
388
+ if ("audit" in fact) return fact.audit;
389
+ if ("highWater" in fact) return fact.highWater;
390
+ if ("frame" in fact) return fact.frame;
391
+ return void 0;
392
+ }
393
+ function auditRecord(flowId, state, outcome, timestampMs, opts) {
394
+ return {
395
+ seq: ++state.auditSeq,
396
+ flowId,
397
+ outcome,
398
+ ...opts.eventId === void 0 ? {} : { eventId: opts.eventId },
399
+ ...opts.eventType === void 0 ? {} : { eventType: opts.eventType },
400
+ ...opts.issueCode === void 0 ? {} : { issueCode: opts.issueCode },
401
+ ...opts.source === void 0 ? {} : { source: opts.source },
402
+ highWater: highWaterSnapshot(flowId, state),
403
+ timestampMs
404
+ };
405
+ }
406
+ function highWaterSnapshot(flowId, state) {
407
+ return {
408
+ flowId,
409
+ recordSeq: state.recordSeq,
410
+ auditSeq: state.auditSeq,
411
+ sources: [...state.highWater.values()].sort(
412
+ (a, b) => a.source.localeCompare(b.source) || (a.topic ?? "").localeCompare(b.topic ?? "")
413
+ )
414
+ };
415
+ }
416
+ function emptyHighWater(flowId) {
417
+ return { flowId, recordSeq: 0, auditSeq: 0, sources: [] };
418
+ }
419
+ function projectionHighWater(flowId, record, sourceHighWater) {
420
+ sourceHighWater.set(sourceKey(record.source), {
421
+ source: record.source.source,
422
+ ...record.source.topic === void 0 ? {} : { topic: record.source.topic },
423
+ ...record.source.seq === void 0 ? {} : { seq: record.source.seq },
424
+ messageId: record.event.id,
425
+ recordSeq: record.recordSeq
426
+ });
427
+ return {
428
+ flowId,
429
+ recordSeq: record.recordSeq,
430
+ auditSeq: 0,
431
+ sources: [...sourceHighWater.values()].sort(
432
+ (a, b) => a.source.localeCompare(b.source) || (a.topic ?? "").localeCompare(b.topic ?? "")
433
+ )
434
+ };
435
+ }
436
+ function sourceKey(source) {
437
+ return `${source.source}\0${source.topic ?? ""}`;
438
+ }
439
+ function eventIdOf(value) {
440
+ return isRecord(value) && typeof value.id === "string" ? value.id : void 0;
441
+ }
442
+ function dataIssue(code, message, details) {
443
+ return {
444
+ kind: "issue",
445
+ code,
446
+ message,
447
+ severity: "error",
448
+ source: "eventFlow",
449
+ ...details === void 0 ? {} : { details }
450
+ };
451
+ }
452
+ function isEventFlowBundle(value) {
453
+ return isRecord(value) && "records" in value && "highWater" in value;
454
+ }
455
+ function isRecord(value) {
456
+ return typeof value === "object" && value !== null && !Array.isArray(value);
457
+ }
458
+
38
459
  // src/patterns/inspection.ts
39
460
  function profileSummary(graph, opts = {}) {
40
461
  const profile = graph.profile();
@@ -203,24 +624,6 @@ function scoreAtLeast(score, min) {
203
624
  return Number.isFinite(score) && score >= min;
204
625
  }
205
626
 
206
- // src/protocol/messages.ts
207
- var SENTINEL = void 0;
208
-
209
- // src/ctx/types.ts
210
- var CTX_DEP_CACHE = /* @__PURE__ */ Symbol("graphrefly.ctx.depCache");
211
- function depWaves(ctx, depIndex) {
212
- return ctx.waveData[depIndex] ?? [];
213
- }
214
- function depBatch(ctx, depIndex) {
215
- const waves = depWaves(ctx, depIndex);
216
- if (waves.length === 0) return null;
217
- const flattened = waves.flat().filter((v) => v !== SENTINEL);
218
- return flattened.length === 0 ? [] : flattened;
219
- }
220
- function depLatest(ctx, depIndex) {
221
- return ctx[CTX_DEP_CACHE]?.latest[depIndex];
222
- }
223
-
224
627
  // src/patterns/semantic-memory-graph.ts
225
628
  function memoryRetrievalBundle(graph, opts) {
226
629
  const name = opts.name ?? "memoryRetrieval";
@@ -1032,6 +1435,8 @@ function compareBigIntDesc2(a, b) {
1032
1435
  admissionFilter3D,
1033
1436
  admissionScored,
1034
1437
  cosineSimilarity,
1438
+ eventFlow,
1439
+ eventFlowProjection,
1035
1440
  filterMemoryFragments,
1036
1441
  isMemoryFragment,
1037
1442
  knowledgeGraphReducerBundle,