@graphrefly/ts 0.0.0 → 0.0.2

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 (405) hide show
  1. package/README.md +135 -0
  2. package/dist/actions-types-CSC3NMDl.d.ts +657 -0
  3. package/dist/actions-types-wl9Mgkmr.d.cts +657 -0
  4. package/dist/adapters/index.cjs +5219 -2974
  5. package/dist/adapters/index.cjs.map +1 -1
  6. package/dist/adapters/index.d.cts +204 -192
  7. package/dist/adapters/index.d.ts +204 -192
  8. package/dist/adapters/index.js +3685 -1833
  9. package/dist/adapters/index.js.map +1 -1
  10. package/dist/adapters/nestjs/microservices.cjs +841 -0
  11. package/dist/adapters/nestjs/microservices.cjs.map +1 -0
  12. package/dist/adapters/nestjs/microservices.d.cts +45 -0
  13. package/dist/adapters/nestjs/microservices.d.ts +45 -0
  14. package/dist/adapters/nestjs/microservices.js +206 -0
  15. package/dist/adapters/nestjs/microservices.js.map +1 -0
  16. package/dist/adapters/nestjs/native.cjs +1391 -0
  17. package/dist/adapters/nestjs/native.cjs.map +1 -0
  18. package/dist/adapters/nestjs/native.d.cts +111 -0
  19. package/dist/adapters/nestjs/native.d.ts +111 -0
  20. package/dist/adapters/nestjs/native.js +577 -0
  21. package/dist/adapters/nestjs/native.js.map +1 -0
  22. package/dist/adapters/nestjs/websockets.cjs +924 -0
  23. package/dist/adapters/nestjs/websockets.cjs.map +1 -0
  24. package/dist/adapters/nestjs/websockets.d.cts +47 -0
  25. package/dist/adapters/nestjs/websockets.d.ts +47 -0
  26. package/dist/adapters/nestjs/websockets.js +286 -0
  27. package/dist/adapters/nestjs/websockets.js.map +1 -0
  28. package/dist/adapters/nestjs.cjs +1085 -0
  29. package/dist/adapters/nestjs.cjs.map +1 -0
  30. package/dist/adapters/nestjs.d.cts +385 -0
  31. package/dist/adapters/nestjs.d.ts +385 -0
  32. package/dist/adapters/nestjs.js +112 -0
  33. package/dist/adapters/nestjs.js.map +1 -0
  34. package/dist/adapters/observe-storage.d.cts +4 -4
  35. package/dist/adapters/observe-storage.d.ts +4 -4
  36. package/dist/adapters/observe-storage.js +5 -4
  37. package/dist/adapters/observe-storage.js.map +1 -1
  38. package/dist/adapters/react.cjs +166 -0
  39. package/dist/adapters/react.cjs.map +1 -0
  40. package/dist/adapters/react.d.cts +31 -0
  41. package/dist/adapters/react.d.ts +31 -0
  42. package/dist/adapters/react.js +51 -0
  43. package/dist/adapters/react.js.map +1 -0
  44. package/dist/adapters/solid.cjs +157 -0
  45. package/dist/adapters/solid.cjs.map +1 -0
  46. package/dist/adapters/solid.d.cts +26 -0
  47. package/dist/adapters/solid.d.ts +26 -0
  48. package/dist/adapters/solid.js +48 -0
  49. package/dist/adapters/solid.js.map +1 -0
  50. package/dist/adapters/svelte.cjs +148 -0
  51. package/dist/adapters/svelte.cjs.map +1 -0
  52. package/dist/adapters/svelte.d.cts +31 -0
  53. package/dist/adapters/svelte.d.ts +31 -0
  54. package/dist/adapters/svelte.js +46 -0
  55. package/dist/adapters/svelte.js.map +1 -0
  56. package/dist/adapters/vue.cjs +155 -0
  57. package/dist/adapters/vue.cjs.map +1 -0
  58. package/dist/adapters/vue.d.cts +26 -0
  59. package/dist/adapters/vue.d.ts +26 -0
  60. package/dist/adapters/vue.js +46 -0
  61. package/dist/adapters/vue.js.map +1 -0
  62. package/dist/agent-runtime-types-core-CaXfKNtY.d.cts +406 -0
  63. package/dist/agent-runtime-types-core-hU299uIC.d.ts +406 -0
  64. package/dist/agent-runtime-types-tool-BEpSINol.d.ts +695 -0
  65. package/dist/agent-runtime-types-tool-DninPEzk.d.cts +695 -0
  66. package/dist/agentic-memory-retention-BmGX368S.d.ts +14 -0
  67. package/dist/agentic-memory-retention-Ih1qhX9Z.d.cts +14 -0
  68. package/dist/agentic-memory-types-CVSUS6XR.d.ts +473 -0
  69. package/dist/agentic-memory-types-FnnYlVUs.d.cts +473 -0
  70. package/dist/capability-admission-BW2CziT6.d.ts +102 -0
  71. package/dist/capability-admission-lwSecxXs.d.cts +102 -0
  72. package/dist/chunk-2KUAG2GZ.js +9693 -0
  73. package/dist/chunk-2KUAG2GZ.js.map +1 -0
  74. package/dist/chunk-2NJP6GO4.js +1320 -0
  75. package/dist/chunk-2NJP6GO4.js.map +1 -0
  76. package/dist/{chunk-GDL26N2T.js → chunk-3KN7NJDR.js} +2 -2
  77. package/dist/{chunk-COHO25CZ.js → chunk-4NWSNI4K.js} +2232 -1672
  78. package/dist/chunk-4NWSNI4K.js.map +1 -0
  79. package/dist/{chunk-Z2ANQ6JW.js → chunk-4Q77MMJY.js} +2 -2
  80. package/dist/chunk-6E76H4OU.js +132 -0
  81. package/dist/chunk-6E76H4OU.js.map +1 -0
  82. package/dist/chunk-7GOTIIQ7.js +819 -0
  83. package/dist/chunk-7GOTIIQ7.js.map +1 -0
  84. package/dist/{chunk-D6BG7U6A.js → chunk-7HZRJMN6.js} +3 -3
  85. package/dist/{chunk-SCRFRCGR.js → chunk-BSQGE5PS.js} +1 -1
  86. package/dist/{chunk-PKVBHGBM.js → chunk-CJIFGJQG.js} +7 -7
  87. package/dist/{chunk-G4M3NHRJ.js → chunk-CX6B6PO2.js} +93 -10
  88. package/dist/chunk-CX6B6PO2.js.map +1 -0
  89. package/dist/chunk-DGUM43GV.js +11 -0
  90. package/dist/chunk-DGUM43GV.js.map +1 -0
  91. package/dist/{chunk-JIMUDQN3.js → chunk-E4QCH32M.js} +449 -447
  92. package/dist/chunk-E4QCH32M.js.map +1 -0
  93. package/dist/{chunk-RIIOUTGM.js → chunk-ECURQ3HD.js} +19 -129
  94. package/dist/chunk-ECURQ3HD.js.map +1 -0
  95. package/dist/{chunk-2ILL7HQI.js → chunk-EOKT4QFF.js} +134 -128
  96. package/dist/chunk-EOKT4QFF.js.map +1 -0
  97. package/dist/{chunk-K3FXTC3I.js → chunk-HJACH5PU.js} +3 -3
  98. package/dist/{chunk-GTPCOEOZ.js → chunk-IDMLXLLG.js} +3 -3
  99. package/dist/{chunk-DKP56CSW.js → chunk-JKAYLDQV.js} +2 -2
  100. package/dist/{chunk-4VLAQHZI.js → chunk-K7FB3JTD.js} +17 -1
  101. package/dist/chunk-K7FB3JTD.js.map +1 -0
  102. package/dist/chunk-L6LDXRWE.js +219 -0
  103. package/dist/chunk-L6LDXRWE.js.map +1 -0
  104. package/dist/chunk-M7J6Z4IJ.js +1930 -0
  105. package/dist/chunk-M7J6Z4IJ.js.map +1 -0
  106. package/dist/chunk-MQEQMS7B.js +1009 -0
  107. package/dist/chunk-MQEQMS7B.js.map +1 -0
  108. package/dist/chunk-MTELVIYR.js +1421 -0
  109. package/dist/chunk-MTELVIYR.js.map +1 -0
  110. package/dist/chunk-PVC7WDKI.js +885 -0
  111. package/dist/chunk-PVC7WDKI.js.map +1 -0
  112. package/dist/chunk-RAHNUYA5.js +368 -0
  113. package/dist/chunk-RAHNUYA5.js.map +1 -0
  114. package/dist/{chunk-DK554R7P.js → chunk-S6HXABGL.js} +2 -1
  115. package/dist/chunk-S6HXABGL.js.map +1 -0
  116. package/dist/{chunk-I3IHOHCJ.js → chunk-SHZDP2MQ.js} +1181 -1001
  117. package/dist/chunk-SHZDP2MQ.js.map +1 -0
  118. package/dist/{chunk-Y3ZLRGHC.js → chunk-SIDJO2T4.js} +16 -16
  119. package/dist/chunk-STXRMPW4.js +4131 -0
  120. package/dist/chunk-STXRMPW4.js.map +1 -0
  121. package/dist/{chunk-JR4IKCR2.js → chunk-TPND5MJS.js} +5 -5
  122. package/dist/chunk-TQPCAIQI.js +612 -0
  123. package/dist/chunk-TQPCAIQI.js.map +1 -0
  124. package/dist/chunk-UT3MHJCW.js +49 -0
  125. package/dist/chunk-UT3MHJCW.js.map +1 -0
  126. package/dist/{chunk-TEW47IVR.js → chunk-VPEFSDME.js} +2 -2
  127. package/dist/{chunk-SWTLEQL6.js → chunk-WQIA3GFB.js} +2 -2
  128. package/dist/chunk-WQIA3GFB.js.map +1 -0
  129. package/dist/{chunk-DJC4CHLQ.js → chunk-YDWBXXQZ.js} +5 -5
  130. package/dist/{chunk-6PHB5CJS.js → chunk-ZLFRB6FI.js} +2 -2
  131. package/dist/composition/index.cjs +1256 -1059
  132. package/dist/composition/index.cjs.map +1 -1
  133. package/dist/composition/index.d.cts +4 -4
  134. package/dist/composition/index.d.ts +4 -4
  135. package/dist/composition/index.js +7 -6
  136. package/dist/core/index.cjs +1218 -1021
  137. package/dist/core/index.cjs.map +1 -1
  138. package/dist/core/index.d.cts +2 -2
  139. package/dist/core/index.d.ts +2 -2
  140. package/dist/core/index.js +5 -4
  141. package/dist/cqrs/index.cjs.map +1 -1
  142. package/dist/cqrs/index.d.cts +4 -4
  143. package/dist/cqrs/index.d.ts +4 -4
  144. package/dist/cqrs/index.js +3 -2
  145. package/dist/cqrs/index.js.map +1 -1
  146. package/dist/cqrs/messaging.cjs +312 -0
  147. package/dist/cqrs/messaging.cjs.map +1 -0
  148. package/dist/cqrs/messaging.d.cts +57 -0
  149. package/dist/cqrs/messaging.d.ts +57 -0
  150. package/dist/cqrs/messaging.js +274 -0
  151. package/dist/cqrs/messaging.js.map +1 -0
  152. package/dist/cqrs/work-queue.cjs +329 -0
  153. package/dist/cqrs/work-queue.cjs.map +1 -0
  154. package/dist/cqrs/work-queue.d.cts +90 -0
  155. package/dist/cqrs/work-queue.d.ts +90 -0
  156. package/dist/cqrs/work-queue.js +292 -0
  157. package/dist/cqrs/work-queue.js.map +1 -0
  158. package/dist/data/index.cjs +19 -0
  159. package/dist/data/index.cjs.map +1 -0
  160. package/dist/data/index.d.cts +36 -0
  161. package/dist/data/index.d.ts +36 -0
  162. package/dist/data/index.js +1 -0
  163. package/dist/data/index.js.map +1 -0
  164. package/dist/data-structures/index.cjs +1252 -1052
  165. package/dist/data-structures/index.cjs.map +1 -1
  166. package/dist/data-structures/index.d.cts +9 -8
  167. package/dist/data-structures/index.d.ts +9 -8
  168. package/dist/data-structures/index.js +9 -7
  169. package/dist/{describe-BZb7AS2y.d.ts → describe-B_A5fbXH.d.ts} +1 -1
  170. package/dist/{describe-Ciu8SUnN.d.cts → describe-CQRrkv-Q.d.cts} +1 -1
  171. package/dist/executors/tool-provider-adapters.cjs +3091 -0
  172. package/dist/executors/tool-provider-adapters.cjs.map +1 -0
  173. package/dist/executors/tool-provider-adapters.d.cts +174 -0
  174. package/dist/executors/tool-provider-adapters.d.ts +174 -0
  175. package/dist/executors/tool-provider-adapters.js +1336 -0
  176. package/dist/executors/tool-provider-adapters.js.map +1 -0
  177. package/dist/executors/tool-provider-runtime.cjs +5178 -0
  178. package/dist/executors/tool-provider-runtime.cjs.map +1 -0
  179. package/dist/executors/tool-provider-runtime.d.cts +17 -0
  180. package/dist/executors/tool-provider-runtime.d.ts +17 -0
  181. package/dist/executors/tool-provider-runtime.js +15 -0
  182. package/dist/executors/tool-provider-runtime.js.map +1 -0
  183. package/dist/executors/tool-provider.cjs +6392 -0
  184. package/dist/executors/tool-provider.cjs.map +1 -0
  185. package/dist/executors/tool-provider.d.cts +60 -0
  186. package/dist/executors/tool-provider.d.ts +60 -0
  187. package/dist/executors/tool-provider.js +89 -0
  188. package/dist/executors/tool-provider.js.map +1 -0
  189. package/dist/executors/work-queue.cjs +342 -0
  190. package/dist/executors/work-queue.cjs.map +1 -0
  191. package/dist/executors/work-queue.d.cts +90 -0
  192. package/dist/executors/work-queue.d.ts +90 -0
  193. package/dist/executors/work-queue.js +306 -0
  194. package/dist/executors/work-queue.js.map +1 -0
  195. package/dist/graph/index.cjs +1536 -1324
  196. package/dist/graph/index.cjs.map +1 -1
  197. package/dist/graph/index.d.cts +10 -9
  198. package/dist/graph/index.d.ts +10 -9
  199. package/dist/graph/index.js +22 -20
  200. package/dist/{graph-s23RbbFO.d.cts → graph-CWK3HLPB.d.cts} +134 -132
  201. package/dist/{graph-DfdF9zy4.d.ts → graph-ho5sotHP.d.ts} +134 -132
  202. package/dist/{index-SnzZu3x7.d.ts → index-CQWcE0Dw.d.ts} +18 -4
  203. package/dist/{index-CAEmLCYF.d.cts → index-DHA1i67c.d.cts} +18 -4
  204. package/dist/index.cjs +3331 -3020
  205. package/dist/index.cjs.map +1 -1
  206. package/dist/index.d.cts +14 -10
  207. package/dist/index.d.ts +14 -10
  208. package/dist/index.js +114 -108
  209. package/dist/inspection/boundary.cjs +98 -0
  210. package/dist/inspection/boundary.cjs.map +1 -0
  211. package/dist/inspection/boundary.d.cts +61 -0
  212. package/dist/inspection/boundary.d.ts +61 -0
  213. package/dist/inspection/boundary.js +75 -0
  214. package/dist/inspection/boundary.js.map +1 -0
  215. package/dist/measurements-C0mAvWU1.d.cts +164 -0
  216. package/dist/measurements-OMpCeBwh.d.ts +164 -0
  217. package/dist/{messages-BZqrGGm1.d.ts → messages-CAzUPPJM.d.cts} +10 -5
  218. package/dist/{messages-BZqrGGm1.d.cts → messages-CAzUPPJM.d.ts} +10 -5
  219. package/dist/messaging/index.cjs +756 -619
  220. package/dist/messaging/index.cjs.map +1 -1
  221. package/dist/messaging/index.d.cts +17 -226
  222. package/dist/messaging/index.d.ts +17 -226
  223. package/dist/messaging/index.js +19 -749
  224. package/dist/messaging/index.js.map +1 -1
  225. package/dist/operators/index.cjs +1256 -1059
  226. package/dist/operators/index.cjs.map +1 -1
  227. package/dist/operators/index.d.cts +6 -6
  228. package/dist/operators/index.d.ts +6 -6
  229. package/dist/operators/index.js +9 -8
  230. package/dist/orchestration/index.cjs +8664 -2617
  231. package/dist/orchestration/index.cjs.map +1 -1
  232. package/dist/orchestration/index.d.cts +171 -221
  233. package/dist/orchestration/index.d.ts +171 -221
  234. package/dist/orchestration/index.js +74 -982
  235. package/dist/orchestration/index.js.map +1 -1
  236. package/dist/orchestration/messaging.cjs +314 -0
  237. package/dist/orchestration/messaging.cjs.map +1 -0
  238. package/dist/orchestration/messaging.d.cts +56 -0
  239. package/dist/orchestration/messaging.d.ts +56 -0
  240. package/dist/orchestration/messaging.js +276 -0
  241. package/dist/orchestration/messaging.js.map +1 -0
  242. package/dist/orchestration/work-queue.cjs +1500 -0
  243. package/dist/orchestration/work-queue.cjs.map +1 -0
  244. package/dist/orchestration/work-queue.d.cts +196 -0
  245. package/dist/orchestration/work-queue.d.ts +196 -0
  246. package/dist/orchestration/work-queue.js +1289 -0
  247. package/dist/orchestration/work-queue.js.map +1 -0
  248. package/dist/patterns/event-flow.cjs +433 -0
  249. package/dist/patterns/event-flow.cjs.map +1 -0
  250. package/dist/patterns/event-flow.d.cts +115 -0
  251. package/dist/patterns/event-flow.d.ts +115 -0
  252. package/dist/patterns/event-flow.js +14 -0
  253. package/dist/patterns/event-flow.js.map +1 -0
  254. package/dist/patterns/index.cjs +748 -355
  255. package/dist/patterns/index.cjs.map +1 -1
  256. package/dist/patterns/index.d.cts +9 -5
  257. package/dist/patterns/index.d.ts +9 -5
  258. package/dist/patterns/index.js +13 -4
  259. package/dist/process-types-C9uMYz3i.d.ts +200 -0
  260. package/dist/process-types-h3uRlzDc.d.cts +200 -0
  261. package/dist/{reactive-collection-BxBqtIOE.d.cts → reactive-collection-B9R0Bl1P.d.cts} +11 -41
  262. package/dist/{reactive-collection-Cb1II1Fi.d.ts → reactive-collection-BXFrH0U2.d.ts} +11 -41
  263. package/dist/{reactive-collection-storage-D-KmjE0J.d.cts → reactive-collection-storage-BLGv8Xp8.d.cts} +5 -5
  264. package/dist/{reactive-collection-storage-BNiEc-Gd.d.ts → reactive-collection-storage-a4zD3665.d.ts} +5 -5
  265. package/dist/{reactive-map-BcB4KsQR.d.ts → reactive-map-C_8sOfdS.d.cts} +7 -6
  266. package/dist/{reactive-map-D-g3dv8I.d.cts → reactive-map-jle5dnok.d.ts} +7 -6
  267. package/dist/render/index.d.cts +3 -3
  268. package/dist/render/index.d.ts +3 -3
  269. package/dist/render/index.js +1 -0
  270. package/dist/scheduled-readiness-5rwQlyjV.d.ts +91 -0
  271. package/dist/scheduled-readiness-DpRY8jI0.d.cts +91 -0
  272. package/dist/semantic-memory-graph-C2ZUwIlq.d.ts +30 -0
  273. package/dist/semantic-memory-graph-DlZBD_Eu.d.cts +30 -0
  274. package/dist/{semantic-memory-graph-BYoIlP35.d.cts → semantic-memory-graph-types-BvzdqmkY.d.cts} +2 -28
  275. package/dist/{semantic-memory-graph-CxyXLms3.d.ts → semantic-memory-graph-types-Ci-OtahO.d.ts} +2 -28
  276. package/dist/solutions/index.cjs +6788 -2128
  277. package/dist/solutions/index.cjs.map +1 -1
  278. package/dist/solutions/index.d.cts +15 -519
  279. package/dist/solutions/index.d.ts +15 -519
  280. package/dist/solutions/index.js +91 -7
  281. package/dist/solutions/reactive-layout/browser/index.cjs +457 -0
  282. package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -0
  283. package/dist/solutions/reactive-layout/browser/index.d.cts +44 -0
  284. package/dist/solutions/reactive-layout/browser/index.d.ts +44 -0
  285. package/dist/solutions/reactive-layout/browser/index.js +69 -0
  286. package/dist/solutions/reactive-layout/browser/index.js.map +1 -0
  287. package/dist/solutions/reactive-layout/index.cjs +4494 -0
  288. package/dist/solutions/reactive-layout/index.cjs.map +1 -0
  289. package/dist/solutions/reactive-layout/index.d.cts +37 -0
  290. package/dist/solutions/reactive-layout/index.d.ts +37 -0
  291. package/dist/solutions/reactive-layout/index.js +146 -0
  292. package/dist/solutions/reactive-layout/index.js.map +1 -0
  293. package/dist/solutions/reactive-layout/node-canvas/index.cjs +555 -0
  294. package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -0
  295. package/dist/solutions/reactive-layout/node-canvas/index.d.cts +54 -0
  296. package/dist/solutions/reactive-layout/node-canvas/index.d.ts +54 -0
  297. package/dist/solutions/reactive-layout/node-canvas/index.js +131 -0
  298. package/dist/solutions/reactive-layout/node-canvas/index.js.map +1 -0
  299. package/dist/solutions/reactive-layout/react-native/index.cjs +504 -0
  300. package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -0
  301. package/dist/solutions/reactive-layout/react-native/index.d.cts +51 -0
  302. package/dist/solutions/reactive-layout/react-native/index.d.ts +51 -0
  303. package/dist/solutions/reactive-layout/react-native/index.js +77 -0
  304. package/dist/solutions/reactive-layout/react-native/index.js.map +1 -0
  305. package/dist/solutions/reactive-layout/skia/index.cjs +557 -0
  306. package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -0
  307. package/dist/solutions/reactive-layout/skia/index.d.cts +64 -0
  308. package/dist/solutions/reactive-layout/skia/index.d.ts +64 -0
  309. package/dist/solutions/reactive-layout/skia/index.js +70 -0
  310. package/dist/solutions/reactive-layout/skia/index.js.map +1 -0
  311. package/dist/solutions/work-item/actions.cjs +2345 -0
  312. package/dist/solutions/work-item/actions.cjs.map +1 -0
  313. package/dist/solutions/work-item/actions.d.cts +40 -0
  314. package/dist/solutions/work-item/actions.d.ts +40 -0
  315. package/dist/solutions/work-item/actions.js +2078 -0
  316. package/dist/solutions/work-item/actions.js.map +1 -0
  317. package/dist/solutions/work-item/scheduling.cjs +9797 -0
  318. package/dist/solutions/work-item/scheduling.cjs.map +1 -0
  319. package/dist/solutions/work-item/scheduling.d.cts +1868 -0
  320. package/dist/solutions/work-item/scheduling.d.ts +1868 -0
  321. package/dist/solutions/work-item/scheduling.js +146 -0
  322. package/dist/solutions/work-item/scheduling.js.map +1 -0
  323. package/dist/solutions/work-item/work-queue.cjs +306 -0
  324. package/dist/solutions/work-item/work-queue.cjs.map +1 -0
  325. package/dist/solutions/work-item/work-queue.d.cts +71 -0
  326. package/dist/solutions/work-item/work-queue.d.ts +71 -0
  327. package/dist/solutions/work-item/work-queue.js +270 -0
  328. package/dist/solutions/work-item/work-queue.js.map +1 -0
  329. package/dist/sources/browser.cjs +1399 -1052
  330. package/dist/sources/browser.cjs.map +1 -1
  331. package/dist/sources/browser.d.cts +33 -6
  332. package/dist/sources/browser.d.ts +33 -6
  333. package/dist/sources/browser.js +73 -6
  334. package/dist/sources/browser.js.map +1 -1
  335. package/dist/sources/index.cjs +1345 -1065
  336. package/dist/sources/index.cjs.map +1 -1
  337. package/dist/sources/index.d.cts +5 -5
  338. package/dist/sources/index.d.ts +5 -5
  339. package/dist/sources/index.js +7 -6
  340. package/dist/sources/node.cjs.map +1 -1
  341. package/dist/sources/node.d.cts +4 -4
  342. package/dist/sources/node.d.ts +4 -4
  343. package/dist/sources/node.js +2 -1
  344. package/dist/sources/node.js.map +1 -1
  345. package/dist/storage/browser.cjs +16 -0
  346. package/dist/storage/browser.cjs.map +1 -1
  347. package/dist/storage/browser.js +4 -3
  348. package/dist/storage/browser.js.map +1 -1
  349. package/dist/storage/index.cjs +16 -0
  350. package/dist/storage/index.cjs.map +1 -1
  351. package/dist/storage/index.d.cts +6 -5
  352. package/dist/storage/index.d.ts +6 -5
  353. package/dist/storage/index.js +10 -9
  354. package/dist/storage/node.cjs +16 -0
  355. package/dist/storage/node.cjs.map +1 -1
  356. package/dist/storage/node.js +4 -3
  357. package/dist/storage/node.js.map +1 -1
  358. package/dist/store-BmtEs9mG.d.ts +123 -0
  359. package/dist/store-PAAsYvML.d.cts +123 -0
  360. package/dist/testing/index.cjs +1 -0
  361. package/dist/testing/index.cjs.map +1 -1
  362. package/dist/testing/index.d.cts +1 -1
  363. package/dist/testing/index.d.ts +1 -1
  364. package/dist/testing/index.js +3 -2
  365. package/dist/types-BRNKoFHj.d.ts +357 -0
  366. package/dist/{types-h12mNYbq.d.ts → types-BS6CyR-x.d.cts} +49 -130
  367. package/dist/types-BWK2ay3e.d.cts +457 -0
  368. package/dist/types-BXKSAoE1.d.cts +357 -0
  369. package/dist/types-BaPpZItj.d.ts +457 -0
  370. package/dist/types-BhveCMg5.d.cts +274 -0
  371. package/dist/{types-bNMSWKqF.d.cts → types-C9NOgNJw.d.ts} +49 -130
  372. package/dist/types-CTsQ8Ww4.d.ts +274 -0
  373. package/dist/types-DL_05n2M.d.ts +34 -0
  374. package/dist/types-XDoqxYO9.d.cts +34 -0
  375. package/dist/work-item-runtime-types-BqtWnSCS.d.ts +138 -0
  376. package/dist/work-item-runtime-types-CHO03AKh.d.cts +138 -0
  377. package/dist/work-queue/index.cjs +1136 -0
  378. package/dist/work-queue/index.cjs.map +1 -0
  379. package/dist/work-queue/index.d.cts +21 -0
  380. package/dist/work-queue/index.d.ts +21 -0
  381. package/dist/work-queue/index.js +1082 -0
  382. package/dist/work-queue/index.js.map +1 -0
  383. package/package.json +603 -249
  384. package/dist/chunk-2ILL7HQI.js.map +0 -1
  385. package/dist/chunk-4VLAQHZI.js.map +0 -1
  386. package/dist/chunk-COHO25CZ.js.map +0 -1
  387. package/dist/chunk-DK554R7P.js.map +0 -1
  388. package/dist/chunk-G4M3NHRJ.js.map +0 -1
  389. package/dist/chunk-I3IHOHCJ.js.map +0 -1
  390. package/dist/chunk-JIMUDQN3.js.map +0 -1
  391. package/dist/chunk-RIIOUTGM.js.map +0 -1
  392. package/dist/chunk-SWTLEQL6.js.map +0 -1
  393. /package/dist/{chunk-GDL26N2T.js.map → chunk-3KN7NJDR.js.map} +0 -0
  394. /package/dist/{chunk-Z2ANQ6JW.js.map → chunk-4Q77MMJY.js.map} +0 -0
  395. /package/dist/{chunk-D6BG7U6A.js.map → chunk-7HZRJMN6.js.map} +0 -0
  396. /package/dist/{chunk-SCRFRCGR.js.map → chunk-BSQGE5PS.js.map} +0 -0
  397. /package/dist/{chunk-PKVBHGBM.js.map → chunk-CJIFGJQG.js.map} +0 -0
  398. /package/dist/{chunk-K3FXTC3I.js.map → chunk-HJACH5PU.js.map} +0 -0
  399. /package/dist/{chunk-GTPCOEOZ.js.map → chunk-IDMLXLLG.js.map} +0 -0
  400. /package/dist/{chunk-DKP56CSW.js.map → chunk-JKAYLDQV.js.map} +0 -0
  401. /package/dist/{chunk-Y3ZLRGHC.js.map → chunk-SIDJO2T4.js.map} +0 -0
  402. /package/dist/{chunk-JR4IKCR2.js.map → chunk-TPND5MJS.js.map} +0 -0
  403. /package/dist/{chunk-TEW47IVR.js.map → chunk-VPEFSDME.js.map} +0 -0
  404. /package/dist/{chunk-DJC4CHLQ.js.map → chunk-YDWBXXQZ.js.map} +0 -0
  405. /package/dist/{chunk-6PHB5CJS.js.map → chunk-ZLFRB6FI.js.map} +0 -0
@@ -0,0 +1,885 @@
1
+ import {
2
+ attachMessageBusCommandSource,
3
+ getMessageBusState,
4
+ registerMessageBusState
5
+ } from "./chunk-UT3MHJCW.js";
6
+ import {
7
+ depBatch
8
+ } from "./chunk-WQIA3GFB.js";
9
+
10
+ // src/messaging/utils.ts
11
+ function pullParams(pull) {
12
+ return isObjectRecord(pull?.params) ? pull.params : {};
13
+ }
14
+ function publishCommand(commandNode, command) {
15
+ commandNode.down([["DATA", command]]);
16
+ return command;
17
+ }
18
+ function makeTopicState() {
19
+ return { closed: false, headSeq: 1, nextSeq: 1, messages: [] };
20
+ }
21
+ function uniqueTopics(topics) {
22
+ const unique = [...new Set(topics)];
23
+ if (unique.length !== topics.length) throw new Error("messageBus: duplicate topic");
24
+ for (const topic of unique) assertTopicKey(topic, "messageBus");
25
+ return Object.freeze(unique.sort());
26
+ }
27
+ function assertTopicKey(topic, owner) {
28
+ const error = validateTopicKey(topic, owner);
29
+ if (error !== void 0) throw new Error(error);
30
+ }
31
+ function validateTopicKey(topic, owner) {
32
+ if (typeof topic !== "string" || topic.length === 0)
33
+ return `${owner}: topic must be a non-empty string`;
34
+ return void 0;
35
+ }
36
+ function assertNonEmpty(value, owner) {
37
+ if (typeof value !== "string" || value.length === 0)
38
+ throw new Error(`${owner}: must be a non-empty string`);
39
+ }
40
+ function positiveLimit(limit) {
41
+ if (limit === void 0) return 100;
42
+ if (!Number.isInteger(limit) || limit < 1)
43
+ throw new Error("messageBus: limit must be a positive integer");
44
+ return limit;
45
+ }
46
+ function isPositiveSeq(value) {
47
+ return Number.isInteger(value) && value >= 1;
48
+ }
49
+ function isObjectRecord(value) {
50
+ return typeof value === "object" && value !== null && !Array.isArray(value);
51
+ }
52
+ function commandTopic(command) {
53
+ return isObjectRecord(command) && typeof command.topic === "string" ? command.topic : void 0;
54
+ }
55
+ function commandIdOf(command) {
56
+ return isObjectRecord(command) && typeof command.commandId === "string" ? command.commandId : void 0;
57
+ }
58
+ function idempotencyKey(topic, key) {
59
+ return `${topic}\0${key}`;
60
+ }
61
+
62
+ // src/messaging/event-message.ts
63
+ function eventMessage(type, payload, opts) {
64
+ assertNonEmpty(type, "eventMessage.type");
65
+ assertNonEmpty(opts.id, "eventMessage.id");
66
+ return {
67
+ id: opts.id,
68
+ type,
69
+ payload,
70
+ ...opts.key === void 0 ? {} : { key: opts.key },
71
+ ...opts.subjectId === void 0 ? {} : { subjectId: opts.subjectId },
72
+ ...opts.correlationId === void 0 ? {} : { correlationId: opts.correlationId },
73
+ ...opts.causationId === void 0 ? {} : { causationId: opts.causationId },
74
+ ...opts.occurredAtMs === void 0 ? {} : { occurredAtMs: opts.occurredAtMs },
75
+ ...opts.actor === void 0 ? {} : { actor: opts.actor },
76
+ ...opts.evidenceRefs === void 0 ? {} : { evidenceRefs: opts.evidenceRefs },
77
+ ...opts.schema === void 0 ? {} : { schema: opts.schema },
78
+ ...opts.metadata === void 0 ? {} : { metadata: opts.metadata }
79
+ };
80
+ }
81
+ function isEventMessage(value) {
82
+ return eventMessageIssue(value) === void 0;
83
+ }
84
+ function eventMessageIssue(value) {
85
+ if (!isObjectRecord(value)) {
86
+ return eventIssue("event message must be an object");
87
+ }
88
+ if (typeof value.id !== "string" || value.id.length === 0) {
89
+ return eventIssue("event message id must be a non-empty string");
90
+ }
91
+ if (typeof value.type !== "string" || value.type.length === 0) {
92
+ return eventIssue("event message type must be a non-empty string");
93
+ }
94
+ if (!("payload" in value)) {
95
+ return eventIssue("event message payload field is required");
96
+ }
97
+ return void 0;
98
+ }
99
+ function eventIssue(message) {
100
+ return {
101
+ kind: "issue",
102
+ code: "malformed-event-message",
103
+ message,
104
+ severity: "error",
105
+ source: "messageBus.eventMessage"
106
+ };
107
+ }
108
+
109
+ // src/messaging/types.ts
110
+ var PROMPTS_TOPIC = "prompts";
111
+ var RESPONSES_TOPIC = "responses";
112
+ var INJECTIONS_TOPIC = "injections";
113
+ var DEFERRED_TOPIC = "deferred";
114
+ var SPAWNS_TOPIC = "spawns";
115
+ var CONTEXT_TOPIC = "context";
116
+ var TODOS_TOPIC = "todos";
117
+ var STANDARD_TOPICS = Object.freeze([
118
+ PROMPTS_TOPIC,
119
+ RESPONSES_TOPIC,
120
+ INJECTIONS_TOPIC,
121
+ DEFERRED_TOPIC,
122
+ SPAWNS_TOPIC,
123
+ CONTEXT_TOPIC,
124
+ TODOS_TOPIC
125
+ ]);
126
+
127
+ // src/messaging/index.ts
128
+ function messageBus(graph, opts = {}) {
129
+ const name = opts.name ?? "messageBus";
130
+ const initialTopics = uniqueTopics(opts.topics ?? []);
131
+ const commandSources = [];
132
+ const commandBody = (ctx) => {
133
+ for (let i = 0; i < commandSources.length; i++) {
134
+ for (const command of depBatch(ctx, i) ?? []) ctx.down([["DATA", command]]);
135
+ }
136
+ };
137
+ const commands = graph.node([], commandBody, {
138
+ name: `${name}/commands`,
139
+ factory: "messageBusCommands",
140
+ completeWhenDepsComplete: false,
141
+ errorWhenDepsError: false
142
+ });
143
+ const state = {
144
+ graph,
145
+ name,
146
+ now: opts.now ?? Date.now,
147
+ topicPolicy: opts.topicPolicy ?? "strict",
148
+ retention: opts.retention ?? {},
149
+ dedupe: opts.dedupe ?? { commandId: "status" },
150
+ topics: new Map(initialTopics.map((topic) => [topic, makeTopicState()])),
151
+ subscriptions: /* @__PURE__ */ new Map(),
152
+ seenCommandIds: /* @__PURE__ */ new Set(),
153
+ seenIdempotencyKeys: /* @__PURE__ */ new Set(),
154
+ deadLetters: [],
155
+ deadLetterSeq: 0,
156
+ commandSources,
157
+ commandBody
158
+ };
159
+ const runtime = graph.node(
160
+ [commands],
161
+ (ctx) => {
162
+ for (const command of depBatch(ctx, 0) ?? []) {
163
+ for (const event of reduceMessageBusCommand(state, command)) {
164
+ ctx.down([["DATA", event]]);
165
+ }
166
+ }
167
+ },
168
+ {
169
+ name: `${name}/runtime`,
170
+ factory: "messageBusRuntime",
171
+ completeWhenDepsComplete: false,
172
+ errorWhenDepsError: false
173
+ }
174
+ );
175
+ graph.retain(runtime, { reason: `${name}.messageBus.runtime` });
176
+ const messages = graph.node(
177
+ [runtime],
178
+ (ctx) => {
179
+ for (const event of depBatch(ctx, 0) ?? []) {
180
+ const typed = event;
181
+ if (typed.kind === "message") ctx.down([["DATA", typed.message]]);
182
+ }
183
+ },
184
+ {
185
+ name: `${name}/messages`,
186
+ factory: "messageBusMessages",
187
+ completeWhenDepsComplete: false,
188
+ errorWhenDepsError: false
189
+ }
190
+ );
191
+ const status = graph.node(
192
+ [runtime],
193
+ (ctx) => {
194
+ for (const event of depBatch(ctx, 0) ?? []) {
195
+ const typed = event;
196
+ if (typed.kind === "status") ctx.down([["DATA", typed.status]]);
197
+ }
198
+ },
199
+ {
200
+ name: `${name}/status`,
201
+ factory: "messageBusStatus",
202
+ completeWhenDepsComplete: false,
203
+ errorWhenDepsError: false
204
+ }
205
+ );
206
+ const issues = graph.node(
207
+ [runtime],
208
+ (ctx) => {
209
+ for (const event of depBatch(ctx, 0) ?? []) {
210
+ const typed = event;
211
+ if (typed.kind === "issue") ctx.down([["DATA", typed.issue]]);
212
+ }
213
+ },
214
+ {
215
+ name: `${name}/issues`,
216
+ factory: "messageBusIssues",
217
+ completeWhenDepsComplete: false,
218
+ errorWhenDepsError: false
219
+ }
220
+ );
221
+ const bus = {
222
+ commands,
223
+ messages,
224
+ status,
225
+ issues,
226
+ ensureTopic(topic, commandOpts = {}) {
227
+ return publishCommand(commands, {
228
+ kind: "ensure-topic",
229
+ topic,
230
+ ...commandOpts.commandId === void 0 ? {} : { commandId: commandOpts.commandId }
231
+ });
232
+ },
233
+ closeTopic(topic, commandOpts = {}) {
234
+ return publishCommand(commands, {
235
+ kind: "close-topic",
236
+ topic,
237
+ ...commandOpts.commandId === void 0 ? {} : { commandId: commandOpts.commandId }
238
+ });
239
+ },
240
+ publish(topic, payload, publishOpts = {}) {
241
+ return publishCommand(commands, {
242
+ kind: "publish",
243
+ topic,
244
+ payload,
245
+ ...publishOpts.key === void 0 ? {} : { key: publishOpts.key },
246
+ ...publishOpts.commandId === void 0 ? {} : { commandId: publishOpts.commandId },
247
+ ...publishOpts.idempotencyKey === void 0 ? {} : { idempotencyKey: publishOpts.idempotencyKey }
248
+ });
249
+ },
250
+ topic(topic, projectionOpts = {}) {
251
+ assertTopicKey(topic, "messageBus.topic");
252
+ const snapshotPullId = /* @__PURE__ */ Symbol(`${name}/${topic}/topicSnapshot`);
253
+ const snapshot = graph.node(
254
+ [messages],
255
+ (ctx) => {
256
+ const params = pullParams(ctx.pull);
257
+ ctx.down([["DATA", topicPage(state, topic, params)]]);
258
+ },
259
+ {
260
+ name: projectionOpts.name ?? `${name}/${topic}/topic`,
261
+ factory: "messageBusTopicProjection",
262
+ meta: { topic },
263
+ pullId: snapshotPullId,
264
+ partial: true,
265
+ completeWhenDepsComplete: false,
266
+ errorWhenDepsError: false
267
+ }
268
+ );
269
+ return { snapshot, snapshotPullId, status, issues };
270
+ },
271
+ catalog(projectionOpts = {}) {
272
+ const snapshotPullId = /* @__PURE__ */ Symbol(`${name}/catalogSnapshot`);
273
+ const snapshot = graph.node(
274
+ [runtime],
275
+ (ctx) => {
276
+ const params = pullParams(ctx.pull);
277
+ ctx.down([["DATA", catalogPage(state, params)]]);
278
+ },
279
+ {
280
+ name: projectionOpts.name ?? `${name}/catalog`,
281
+ factory: "messageBusCatalog",
282
+ pullId: snapshotPullId,
283
+ partial: true,
284
+ completeWhenDepsComplete: false,
285
+ errorWhenDepsError: false
286
+ }
287
+ );
288
+ return { snapshot, snapshotPullId, status, issues };
289
+ },
290
+ deadLetter(projectionOpts = {}) {
291
+ const snapshotPullId = /* @__PURE__ */ Symbol(`${name}/deadLetterSnapshot`);
292
+ const snapshot = graph.node(
293
+ [runtime],
294
+ (ctx) => {
295
+ const params = pullParams(ctx.pull);
296
+ ctx.down([["DATA", deadLetterPage(state, params)]]);
297
+ },
298
+ {
299
+ name: projectionOpts.name ?? `${name}/deadLetter`,
300
+ factory: "messageBusDeadLetter",
301
+ pullId: snapshotPullId,
302
+ partial: true,
303
+ completeWhenDepsComplete: false,
304
+ errorWhenDepsError: false
305
+ }
306
+ );
307
+ return { snapshot, snapshotPullId, status, issues };
308
+ },
309
+ subscription(subscriptionOpts) {
310
+ assertTopicKey(subscriptionOpts.topic, "messageBus.subscription");
311
+ assertNonEmpty(subscriptionOpts.subscriptionId, "messageBus.subscriptionId");
312
+ const sub = ensureSubscription(state, {
313
+ topic: subscriptionOpts.topic,
314
+ subscriptionId: subscriptionOpts.subscriptionId,
315
+ from: subscriptionOpts.from ?? "earliest"
316
+ });
317
+ const availablePullId = /* @__PURE__ */ Symbol(
318
+ `${name}/${subscriptionOpts.topic}/${subscriptionOpts.subscriptionId}/available`
319
+ );
320
+ const projectionName = subscriptionOpts.name ?? `${name}/${subscriptionOpts.topic}/${subscriptionOpts.subscriptionId}`;
321
+ const available = graph.node(
322
+ [messages, status],
323
+ (ctx) => {
324
+ const params = pullParams(ctx.pull);
325
+ ctx.down([["DATA", availablePage(state, sub, params)]]);
326
+ },
327
+ {
328
+ name: `${projectionName}/available`,
329
+ factory: "messageBusSubscriptionAvailable",
330
+ meta: { topic: subscriptionOpts.topic, subscriptionId: subscriptionOpts.subscriptionId },
331
+ pullId: availablePullId,
332
+ partial: true,
333
+ completeWhenDepsComplete: false,
334
+ errorWhenDepsError: false
335
+ }
336
+ );
337
+ const cursor = graph.node(
338
+ [status],
339
+ (ctx) => {
340
+ for (const fact of depBatch(ctx, 0) ?? []) {
341
+ const typed = fact;
342
+ const subscriptionMoved = typed.topic === sub.topic && typed.subscriptionId === sub.subscriptionId && (typed.kind === "subscription-acked" || typed.kind === "subscription-sought" || typed.kind === "subscription-closed");
343
+ const retentionMoved = typed.topic === sub.topic && typed.kind === "retention-trimmed";
344
+ if (subscriptionMoved || retentionMoved) {
345
+ ctx.down([["DATA", cursorSnapshot(state, sub)]]);
346
+ }
347
+ }
348
+ },
349
+ {
350
+ name: `${projectionName}/cursor`,
351
+ factory: "messageBusSubscriptionCursor",
352
+ completeWhenDepsComplete: false,
353
+ errorWhenDepsError: false
354
+ }
355
+ );
356
+ return {
357
+ available,
358
+ availablePullId,
359
+ cursor,
360
+ status,
361
+ issues,
362
+ ack(seq, commandOpts = {}) {
363
+ return publishCommand(commands, {
364
+ kind: "ack",
365
+ topic: sub.topic,
366
+ subscriptionId: sub.subscriptionId,
367
+ seq,
368
+ ...commandOpts.commandId === void 0 ? {} : { commandId: commandOpts.commandId }
369
+ });
370
+ },
371
+ seek(nextSeq, commandOpts = {}) {
372
+ return publishCommand(commands, {
373
+ kind: "seek",
374
+ topic: sub.topic,
375
+ subscriptionId: sub.subscriptionId,
376
+ nextSeq,
377
+ ...commandOpts.commandId === void 0 ? {} : { commandId: commandOpts.commandId }
378
+ });
379
+ },
380
+ close(commandOpts = {}) {
381
+ return publishCommand(commands, {
382
+ kind: "close-subscription",
383
+ topic: sub.topic,
384
+ subscriptionId: sub.subscriptionId,
385
+ ...commandOpts.commandId === void 0 ? {} : { commandId: commandOpts.commandId }
386
+ });
387
+ }
388
+ };
389
+ }
390
+ };
391
+ registerMessageBusState(bus, state);
392
+ return bus;
393
+ }
394
+ function fromTopic(bus, topic) {
395
+ return bus.topic(topic).snapshot;
396
+ }
397
+ function toTopic(graph, source, bus, topic, opts = {}) {
398
+ const state = getMessageBusState(bus);
399
+ if (state === void 0) throw new Error("toTopic: unknown message bus implementation");
400
+ if (state.graph !== graph) throw new Error("toTopic: bus and source graph must match");
401
+ assertTopicKey(topic, "toTopic");
402
+ const commands = graph.node(
403
+ [source],
404
+ (ctx) => {
405
+ for (const value of depBatch(ctx, 0) ?? []) {
406
+ const key = opts.keyOf?.(value);
407
+ const commandId = opts.commandIdOf?.(value);
408
+ ctx.down([
409
+ [
410
+ "DATA",
411
+ {
412
+ kind: "publish",
413
+ topic,
414
+ payload: value,
415
+ ...key === void 0 ? {} : { key },
416
+ ...commandId === void 0 ? {} : { commandId }
417
+ }
418
+ ]
419
+ ]);
420
+ }
421
+ },
422
+ {
423
+ name: opts.name ?? `${state.name}/${topic}/toTopic`,
424
+ factory: "toTopic",
425
+ meta: { topic },
426
+ completeWhenDepsComplete: false,
427
+ errorWhenDepsError: false
428
+ }
429
+ );
430
+ const releaseSource = attachMessageBusCommandSource(
431
+ graph,
432
+ bus,
433
+ commands
434
+ );
435
+ let released = false;
436
+ return {
437
+ commands,
438
+ release() {
439
+ if (released) return;
440
+ released = true;
441
+ releaseSource();
442
+ }
443
+ };
444
+ }
445
+ function reduceMessageBusCommand(state, command) {
446
+ const malformed = validateCommand(command);
447
+ if (malformed !== void 0) return rejectCommand(state, command, malformed);
448
+ if (command.commandId !== void 0) {
449
+ if (state.seenCommandIds.has(command.commandId)) {
450
+ return duplicateCommandEvents(state, command, "duplicate commandId");
451
+ }
452
+ state.seenCommandIds.add(command.commandId);
453
+ }
454
+ if (command.kind === "publish" && command.idempotencyKey !== void 0 && state.seenIdempotencyKeys.has(idempotencyKey(command.topic, command.idempotencyKey))) {
455
+ return duplicateCommandEvents(state, command, "duplicate idempotencyKey");
456
+ }
457
+ switch (command.kind) {
458
+ case "ensure-topic":
459
+ return ensureTopic(state, command.topic, command.commandId);
460
+ case "close-topic": {
461
+ const topic = state.topics.get(command.topic);
462
+ if (topic === void 0) {
463
+ return issueEvents(state, command, "unknown-topic", `unknown topic '${command.topic}'`);
464
+ }
465
+ topic.closed = true;
466
+ return [
467
+ {
468
+ kind: "status",
469
+ status: statusFact(state, "topic-closed", {
470
+ topic: command.topic,
471
+ commandId: command.commandId
472
+ })
473
+ }
474
+ ];
475
+ }
476
+ case "topic-policy":
477
+ state.topicPolicy = command.topicPolicy;
478
+ return [
479
+ {
480
+ kind: "status",
481
+ status: statusFact(state, "projection-ready", {
482
+ commandId: command.commandId,
483
+ details: { topicPolicy: command.topicPolicy }
484
+ })
485
+ }
486
+ ];
487
+ case "publish":
488
+ return publishMessage(state, command);
489
+ case "ack":
490
+ return ackSubscription(state, command);
491
+ case "seek":
492
+ return seekSubscription(state, command);
493
+ case "close-subscription":
494
+ return closeSubscription(state, command);
495
+ }
496
+ }
497
+ function publishMessage(state, command) {
498
+ let topic = state.topics.get(command.topic);
499
+ const events = [];
500
+ if (topic === void 0) {
501
+ if (state.topicPolicy !== "create-as-fact") {
502
+ return issueEvents(state, command, "unknown-topic", `unknown topic '${command.topic}'`);
503
+ }
504
+ events.push(...ensureTopic(state, command.topic, command.commandId));
505
+ topic = state.topics.get(command.topic);
506
+ }
507
+ if (topic === void 0)
508
+ return issueEvents(state, command, "unknown-topic", `unknown topic '${command.topic}'`);
509
+ if (topic.closed)
510
+ return issueEvents(state, command, "closed-topic", `closed topic '${command.topic}'`);
511
+ const message = {
512
+ topic: command.topic,
513
+ seq: topic.nextSeq++,
514
+ payload: command.payload,
515
+ timestampMs: state.now(),
516
+ ...command.key === void 0 ? {} : { key: command.key },
517
+ ...command.idempotencyKey === void 0 ? {} : { idempotencyKey: command.idempotencyKey },
518
+ ...command.commandId === void 0 ? {} : { commandId: command.commandId }
519
+ };
520
+ if (command.idempotencyKey !== void 0) {
521
+ state.seenIdempotencyKeys.add(idempotencyKey(command.topic, command.idempotencyKey));
522
+ }
523
+ topic.messages.push(message);
524
+ events.push({ kind: "message", message });
525
+ events.push({
526
+ kind: "status",
527
+ status: statusFact(state, "message-published", {
528
+ topic: command.topic,
529
+ seq: message.seq,
530
+ commandId: command.commandId
531
+ })
532
+ });
533
+ events.push(...trimRetention(state, command.topic, topic));
534
+ return events;
535
+ }
536
+ function ensureTopic(state, topic, commandId) {
537
+ assertTopicKey(topic, "messageBus");
538
+ if (!state.topics.has(topic)) state.topics.set(topic, makeTopicState());
539
+ return [
540
+ {
541
+ kind: "status",
542
+ status: statusFact(state, "topic-created", { topic, commandId })
543
+ }
544
+ ];
545
+ }
546
+ function trimRetention(state, topicName, topic) {
547
+ const max = state.retention.maxMessages;
548
+ if (max === void 0 || topic.messages.length <= max) return [];
549
+ if (!Number.isInteger(max) || max < 1) {
550
+ return issueEvents(
551
+ state,
552
+ { kind: "publish", topic: topicName, payload: void 0 },
553
+ "policy-rejected",
554
+ "retention.maxMessages must be a positive integer"
555
+ );
556
+ }
557
+ const trimCount = topic.messages.length - max;
558
+ topic.messages.splice(0, trimCount);
559
+ topic.headSeq = topic.messages[0]?.seq ?? topic.nextSeq;
560
+ const events = [
561
+ {
562
+ kind: "status",
563
+ status: statusFact(state, "retention-trimmed", {
564
+ topic: topicName,
565
+ headSeq: topic.headSeq,
566
+ details: { trimCount }
567
+ })
568
+ }
569
+ ];
570
+ for (const sub of state.subscriptions.values()) {
571
+ if (sub.closed || sub.topic !== topicName || sub.nextSeq >= topic.headSeq) continue;
572
+ sub.retentionGap = true;
573
+ events.push(
574
+ ...issueEvents(
575
+ state,
576
+ {
577
+ kind: "seek",
578
+ topic: topicName,
579
+ subscriptionId: sub.subscriptionId,
580
+ nextSeq: sub.nextSeq
581
+ },
582
+ "retention-gap",
583
+ `subscription '${sub.subscriptionId}' is before retained headSeq`
584
+ )
585
+ );
586
+ }
587
+ return events;
588
+ }
589
+ function ackSubscription(state, command) {
590
+ const topic = state.topics.get(command.topic);
591
+ if (topic === void 0)
592
+ return issueEvents(state, command, "unknown-topic", `unknown topic '${command.topic}'`);
593
+ const sub = getSubscription(state, command.topic, command.subscriptionId);
594
+ if (sub === void 0)
595
+ return issueEvents(
596
+ state,
597
+ command,
598
+ "unknown-subscription",
599
+ `unknown subscription '${command.subscriptionId}'`
600
+ );
601
+ if (sub.closed)
602
+ return issueEvents(state, command, "subscription-closed", "subscription is closed");
603
+ if (sub.retentionGap)
604
+ return issueEvents(state, command, "retention-gap", "subscription must seek before ack");
605
+ if (command.seq < sub.nextSeq)
606
+ return issueEvents(state, command, "source-cursor-stale", "ack is behind subscription cursor");
607
+ if (command.seq >= topic.nextSeq)
608
+ return issueEvents(state, command, "cursor-out-of-range", "ack is beyond topic tail");
609
+ sub.nextSeq = Math.max(sub.nextSeq, command.seq + 1);
610
+ return [
611
+ {
612
+ kind: "status",
613
+ status: statusFact(state, "subscription-acked", {
614
+ topic: command.topic,
615
+ subscriptionId: command.subscriptionId,
616
+ nextSeq: sub.nextSeq,
617
+ commandId: command.commandId
618
+ })
619
+ }
620
+ ];
621
+ }
622
+ function seekSubscription(state, command) {
623
+ const topic = state.topics.get(command.topic);
624
+ if (topic === void 0)
625
+ return issueEvents(state, command, "unknown-topic", `unknown topic '${command.topic}'`);
626
+ const sub = getSubscription(state, command.topic, command.subscriptionId);
627
+ if (sub === void 0)
628
+ return issueEvents(
629
+ state,
630
+ command,
631
+ "unknown-subscription",
632
+ `unknown subscription '${command.subscriptionId}'`
633
+ );
634
+ if (sub.closed)
635
+ return issueEvents(state, command, "subscription-closed", "subscription is closed");
636
+ if (command.nextSeq < topic.headSeq)
637
+ return issueEvents(state, command, "retention-gap", "seek is before retained headSeq");
638
+ if (command.nextSeq > topic.nextSeq)
639
+ return issueEvents(state, command, "cursor-out-of-range", "seek is beyond topic tail");
640
+ sub.nextSeq = command.nextSeq;
641
+ sub.retentionGap = false;
642
+ return [
643
+ {
644
+ kind: "status",
645
+ status: statusFact(state, "subscription-sought", {
646
+ topic: command.topic,
647
+ subscriptionId: command.subscriptionId,
648
+ nextSeq: sub.nextSeq,
649
+ commandId: command.commandId
650
+ })
651
+ }
652
+ ];
653
+ }
654
+ function closeSubscription(state, command) {
655
+ if (!state.topics.has(command.topic))
656
+ return issueEvents(state, command, "unknown-topic", `unknown topic '${command.topic}'`);
657
+ const sub = getSubscription(state, command.topic, command.subscriptionId);
658
+ if (sub === void 0)
659
+ return issueEvents(
660
+ state,
661
+ command,
662
+ "unknown-subscription",
663
+ `unknown subscription '${command.subscriptionId}'`
664
+ );
665
+ sub.closed = true;
666
+ return [
667
+ {
668
+ kind: "status",
669
+ status: statusFact(state, "subscription-closed", {
670
+ topic: command.topic,
671
+ subscriptionId: command.subscriptionId,
672
+ nextSeq: sub.nextSeq,
673
+ commandId: command.commandId
674
+ })
675
+ }
676
+ ];
677
+ }
678
+ function issueEvents(state, command, code, message) {
679
+ const topic = commandTopic(command);
680
+ const commandId = commandIdOf(command);
681
+ const issue = {
682
+ kind: "issue",
683
+ code,
684
+ message,
685
+ severity: "error",
686
+ source: "messageBus",
687
+ details: command,
688
+ metadata: topic === void 0 ? void 0 : { topic }
689
+ };
690
+ const entry = {
691
+ entrySeq: ++state.deadLetterSeq,
692
+ ...topic === void 0 ? {} : { topic },
693
+ ...isObjectRecord(command) ? { command } : {},
694
+ issue,
695
+ timestampMs: state.now()
696
+ };
697
+ state.deadLetters.push(entry);
698
+ return [
699
+ { kind: "issue", issue },
700
+ { kind: "dead-letter", entry },
701
+ {
702
+ kind: "status",
703
+ status: statusFact(state, "command-rejected", {
704
+ topic,
705
+ commandId,
706
+ issueCode: code
707
+ })
708
+ }
709
+ ];
710
+ }
711
+ function rejectCommand(state, command, reason) {
712
+ return issueEvents(state, command, "malformed-command", reason);
713
+ }
714
+ function duplicateCommandEvents(state, command, message) {
715
+ const status = statusFact(state, "duplicate-command", {
716
+ topic: "topic" in command ? command.topic : void 0,
717
+ commandId: command.commandId
718
+ });
719
+ if (state.dedupe.commandId === "issue") {
720
+ return [
721
+ { kind: "status", status },
722
+ ...issueEvents(state, command, "duplicate-command", message)
723
+ ];
724
+ }
725
+ return [{ kind: "status", status }];
726
+ }
727
+ function statusFact(state, kind, fields) {
728
+ return {
729
+ kind,
730
+ timestampMs: state.now(),
731
+ ...fields.topic === void 0 ? {} : { topic: fields.topic },
732
+ ...fields.seq === void 0 ? {} : { seq: fields.seq },
733
+ ...fields.headSeq === void 0 ? {} : { headSeq: fields.headSeq },
734
+ ...fields.subscriptionId === void 0 ? {} : { subscriptionId: fields.subscriptionId },
735
+ ...fields.nextSeq === void 0 ? {} : { nextSeq: fields.nextSeq },
736
+ ...fields.commandId === void 0 ? {} : { commandId: fields.commandId },
737
+ ...fields.issueCode === void 0 ? {} : { issueCode: fields.issueCode },
738
+ ...fields.details === void 0 ? {} : { details: fields.details }
739
+ };
740
+ }
741
+ function validateCommand(command) {
742
+ if (!isObjectRecord(command)) return "command must be an object";
743
+ if (typeof command.kind !== "string") return "command kind is required";
744
+ if (!isMessageBusCommandKind(command.kind)) return `unknown command kind '${command.kind}'`;
745
+ if ("topic" in command) {
746
+ if (typeof command.topic !== "string") return "messageBus: topic must be a non-empty string";
747
+ const topicError = validateTopicKey(command.topic, "messageBus");
748
+ if (topicError !== void 0) return topicError;
749
+ }
750
+ if ("subscriptionId" in command && typeof command.subscriptionId !== "string") {
751
+ return "subscriptionId must be a string";
752
+ }
753
+ if (command.kind === "publish" && command.payload === void 0)
754
+ return "publish payload is required";
755
+ if (command.kind === "ack" && !isPositiveSeq(command.seq))
756
+ return "ack seq must be a positive integer";
757
+ if (command.kind === "seek" && !isPositiveSeq(command.nextSeq)) {
758
+ return "seek nextSeq must be a positive integer";
759
+ }
760
+ if (command.kind === "topic-policy" && command.topicPolicy !== "strict" && command.topicPolicy !== "create-as-fact") {
761
+ return "topicPolicy is not recognized";
762
+ }
763
+ return void 0;
764
+ }
765
+ function isMessageBusCommandKind(kind) {
766
+ return kind === "ensure-topic" || kind === "close-topic" || kind === "publish" || kind === "topic-policy" || kind === "ack" || kind === "seek" || kind === "close-subscription";
767
+ }
768
+ function catalogPage(state, params) {
769
+ const limit = positiveLimit(params.limit);
770
+ const topics = [...state.topics.entries()].filter(
771
+ ([topic, value]) => (params.includeClosed ? true : !value.closed) && (params.afterTopic === void 0 || topic > params.afterTopic)
772
+ ).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
773
+ const page = topics.slice(0, limit);
774
+ const hasMore = topics.length > limit;
775
+ return {
776
+ topics: page.map(([topic, value]) => ({
777
+ topic,
778
+ closed: value.closed,
779
+ headSeq: value.headSeq,
780
+ nextSeq: value.nextSeq,
781
+ messageCount: value.messages.length
782
+ })),
783
+ ...hasMore && page.length > 0 ? { nextAfterTopic: page[page.length - 1]?.[0] } : {},
784
+ hasMore
785
+ };
786
+ }
787
+ function topicPage(state, topicName, params) {
788
+ const topic = state.topics.get(topicName);
789
+ const start = params.afterSeq === void 0 ? topic?.headSeq ?? 1 : params.afterSeq + 1;
790
+ const all = (topic?.messages ?? []).filter((message) => message.seq >= start);
791
+ const limit = positiveLimit(params.limit);
792
+ const messages = all.slice(0, limit);
793
+ const hasMore = all.length > limit;
794
+ return {
795
+ topic: topicName,
796
+ messages,
797
+ fromSeq: start,
798
+ ...messages.length > 0 ? { throughSeq: messages[messages.length - 1]?.seq } : {},
799
+ ...hasMore && messages.length > 0 ? { nextAfterSeq: messages[messages.length - 1]?.seq } : {},
800
+ hasMore
801
+ };
802
+ }
803
+ function availablePage(state, sub, params) {
804
+ const cursor = cursorSnapshot(state, sub);
805
+ const start = params.afterSeq === void 0 ? sub.nextSeq : params.afterSeq + 1;
806
+ const topic = state.topics.get(sub.topic);
807
+ const all = sub.retentionGap ? [] : (topic?.messages ?? []).filter((message) => message.seq >= start);
808
+ const limit = positiveLimit(params.limit);
809
+ const messages = all.slice(0, limit);
810
+ const hasMore = all.length > limit;
811
+ return {
812
+ topic: sub.topic,
813
+ subscriptionId: sub.subscriptionId,
814
+ cursor,
815
+ messages,
816
+ fromSeq: start,
817
+ ...messages.length > 0 ? { throughSeq: messages[messages.length - 1]?.seq } : {},
818
+ ...hasMore && messages.length > 0 ? { nextAfterSeq: messages[messages.length - 1]?.seq } : {},
819
+ hasMore
820
+ };
821
+ }
822
+ function deadLetterPage(state, params) {
823
+ const limit = positiveLimit(params.limit);
824
+ const entries = state.deadLetters.filter((entry) => {
825
+ if (params.afterEntrySeq !== void 0 && entry.entrySeq <= params.afterEntrySeq) return false;
826
+ if (params.topic !== void 0 && entry.topic !== params.topic) return false;
827
+ if (params.code !== void 0 && entry.issue.code !== params.code) return false;
828
+ return true;
829
+ });
830
+ const page = entries.slice(0, limit);
831
+ const hasMore = entries.length > limit;
832
+ return {
833
+ entries: page,
834
+ ...hasMore && page.length > 0 ? { nextAfterEntrySeq: page[page.length - 1]?.entrySeq } : {},
835
+ hasMore
836
+ };
837
+ }
838
+ function cursorSnapshot(state, sub) {
839
+ const topic = state.topics.get(sub.topic);
840
+ return {
841
+ topic: sub.topic,
842
+ subscriptionId: sub.subscriptionId,
843
+ nextSeq: sub.nextSeq,
844
+ closed: sub.closed,
845
+ retentionGap: sub.retentionGap,
846
+ headSeq: topic?.headSeq ?? 1
847
+ };
848
+ }
849
+ function ensureSubscription(state, opts) {
850
+ const key = `${opts.topic}\0${opts.subscriptionId}`;
851
+ const existing = state.subscriptions.get(key);
852
+ if (existing !== void 0) return existing;
853
+ const topic = state.topics.get(opts.topic);
854
+ const nextSeq = opts.from === "earliest" ? topic?.headSeq ?? 1 : opts.from === "latest" ? topic?.nextSeq ?? 1 : opts.from;
855
+ const sub = {
856
+ topic: opts.topic,
857
+ subscriptionId: opts.subscriptionId,
858
+ nextSeq,
859
+ closed: false,
860
+ retentionGap: topic !== void 0 && nextSeq < topic.headSeq
861
+ };
862
+ state.subscriptions.set(key, sub);
863
+ return sub;
864
+ }
865
+ function getSubscription(state, topic, subscriptionId) {
866
+ return state.subscriptions.get(`${topic}\0${subscriptionId}`);
867
+ }
868
+
869
+ export {
870
+ eventMessage,
871
+ isEventMessage,
872
+ eventMessageIssue,
873
+ PROMPTS_TOPIC,
874
+ RESPONSES_TOPIC,
875
+ INJECTIONS_TOPIC,
876
+ DEFERRED_TOPIC,
877
+ SPAWNS_TOPIC,
878
+ CONTEXT_TOPIC,
879
+ TODOS_TOPIC,
880
+ STANDARD_TOPICS,
881
+ messageBus,
882
+ fromTopic,
883
+ toTopic
884
+ };
885
+ //# sourceMappingURL=chunk-PVC7WDKI.js.map