@graphrefly/ts 0.0.1 → 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 (330) hide show
  1. package/dist/actions-types-CSC3NMDl.d.ts +657 -0
  2. package/dist/actions-types-wl9Mgkmr.d.cts +657 -0
  3. package/dist/adapters/index.cjs +5157 -2951
  4. package/dist/adapters/index.cjs.map +1 -1
  5. package/dist/adapters/index.d.cts +207 -70
  6. package/dist/adapters/index.d.ts +207 -70
  7. package/dist/adapters/index.js +3738 -1688
  8. package/dist/adapters/index.js.map +1 -1
  9. package/dist/adapters/nestjs/microservices.cjs +841 -0
  10. package/dist/adapters/nestjs/microservices.cjs.map +1 -0
  11. package/dist/adapters/nestjs/microservices.d.cts +45 -0
  12. package/dist/adapters/nestjs/microservices.d.ts +45 -0
  13. package/dist/adapters/nestjs/microservices.js +206 -0
  14. package/dist/adapters/nestjs/microservices.js.map +1 -0
  15. package/dist/adapters/nestjs/native.cjs +1391 -0
  16. package/dist/adapters/nestjs/native.cjs.map +1 -0
  17. package/dist/adapters/nestjs/native.d.cts +111 -0
  18. package/dist/adapters/nestjs/native.d.ts +111 -0
  19. package/dist/adapters/nestjs/native.js +577 -0
  20. package/dist/adapters/nestjs/native.js.map +1 -0
  21. package/dist/adapters/nestjs/websockets.cjs +924 -0
  22. package/dist/adapters/nestjs/websockets.cjs.map +1 -0
  23. package/dist/adapters/nestjs/websockets.d.cts +47 -0
  24. package/dist/adapters/nestjs/websockets.d.ts +47 -0
  25. package/dist/adapters/nestjs/websockets.js +286 -0
  26. package/dist/adapters/nestjs/websockets.js.map +1 -0
  27. package/dist/adapters/nestjs.cjs +1085 -0
  28. package/dist/adapters/nestjs.cjs.map +1 -0
  29. package/dist/adapters/nestjs.d.cts +385 -0
  30. package/dist/adapters/nestjs.d.ts +385 -0
  31. package/dist/adapters/nestjs.js +112 -0
  32. package/dist/adapters/nestjs.js.map +1 -0
  33. package/dist/adapters/observe-storage.d.cts +3 -3
  34. package/dist/adapters/observe-storage.d.ts +3 -3
  35. package/dist/adapters/observe-storage.js +4 -4
  36. package/dist/adapters/react.cjs.map +1 -1
  37. package/dist/adapters/react.d.cts +2 -2
  38. package/dist/adapters/react.d.ts +2 -2
  39. package/dist/adapters/react.js +1 -1
  40. package/dist/adapters/solid.cjs.map +1 -1
  41. package/dist/adapters/solid.d.cts +2 -2
  42. package/dist/adapters/solid.d.ts +2 -2
  43. package/dist/adapters/solid.js +1 -1
  44. package/dist/adapters/svelte.cjs.map +1 -1
  45. package/dist/adapters/svelte.d.cts +2 -2
  46. package/dist/adapters/svelte.d.ts +2 -2
  47. package/dist/adapters/svelte.js +1 -1
  48. package/dist/adapters/vue.cjs.map +1 -1
  49. package/dist/adapters/vue.d.cts +2 -2
  50. package/dist/adapters/vue.d.ts +2 -2
  51. package/dist/adapters/vue.js +1 -1
  52. package/dist/{agent-runtime-DZTJ3C-p.d.cts → agent-runtime-types-core-CaXfKNtY.d.cts} +171 -320
  53. package/dist/{agent-runtime-BesGDZcB.d.ts → agent-runtime-types-core-hU299uIC.d.ts} +171 -320
  54. package/dist/agent-runtime-types-tool-BEpSINol.d.ts +695 -0
  55. package/dist/agent-runtime-types-tool-DninPEzk.d.cts +695 -0
  56. package/dist/agentic-memory-retention-BmGX368S.d.ts +14 -0
  57. package/dist/agentic-memory-retention-Ih1qhX9Z.d.cts +14 -0
  58. package/dist/{agentic-memory-BmRCvh0d.d.ts → agentic-memory-types-CVSUS6XR.d.ts} +13 -57
  59. package/dist/{agentic-memory-DfuVZ-lY.d.cts → agentic-memory-types-FnnYlVUs.d.cts} +13 -57
  60. package/dist/{capability-admission-g0mn9hpq.d.ts → capability-admission-BW2CziT6.d.ts} +3 -3
  61. package/dist/{capability-admission-B0BzqAm5.d.cts → capability-admission-lwSecxXs.d.cts} +3 -3
  62. package/dist/chunk-2KUAG2GZ.js +9693 -0
  63. package/dist/chunk-2KUAG2GZ.js.map +1 -0
  64. package/dist/chunk-2NJP6GO4.js +1320 -0
  65. package/dist/chunk-2NJP6GO4.js.map +1 -0
  66. package/dist/{chunk-YDSIVHRR.js → chunk-4NWSNI4K.js} +1598 -1584
  67. package/dist/chunk-4NWSNI4K.js.map +1 -0
  68. package/dist/{chunk-Z2ANQ6JW.js → chunk-4Q77MMJY.js} +2 -2
  69. package/dist/chunk-6E76H4OU.js +132 -0
  70. package/dist/chunk-6E76H4OU.js.map +1 -0
  71. package/dist/chunk-7GOTIIQ7.js +819 -0
  72. package/dist/chunk-7GOTIIQ7.js.map +1 -0
  73. package/dist/{chunk-IXZBUWSP.js → chunk-7HZRJMN6.js} +2 -2
  74. package/dist/{chunk-SS2A464I.js → chunk-CJIFGJQG.js} +3 -3
  75. package/dist/{chunk-V7CIJE4B.js → chunk-CX6B6PO2.js} +92 -9
  76. package/dist/chunk-CX6B6PO2.js.map +1 -0
  77. package/dist/{chunk-FBUU43PM.js → chunk-E4QCH32M.js} +448 -446
  78. package/dist/chunk-E4QCH32M.js.map +1 -0
  79. package/dist/{chunk-HKK2JD7Z.js → chunk-ECURQ3HD.js} +12 -125
  80. package/dist/chunk-ECURQ3HD.js.map +1 -0
  81. package/dist/{chunk-3JR3EDB2.js → chunk-EOKT4QFF.js} +121 -115
  82. package/dist/chunk-EOKT4QFF.js.map +1 -0
  83. package/dist/{chunk-K3FXTC3I.js → chunk-HJACH5PU.js} +3 -3
  84. package/dist/{chunk-GTPCOEOZ.js → chunk-IDMLXLLG.js} +3 -3
  85. package/dist/{chunk-DKP56CSW.js → chunk-JKAYLDQV.js} +2 -2
  86. package/dist/{chunk-4VLAQHZI.js → chunk-K7FB3JTD.js} +17 -1
  87. package/dist/chunk-K7FB3JTD.js.map +1 -0
  88. package/dist/{chunk-H75VXTGT.js → chunk-L6LDXRWE.js} +3 -3
  89. package/dist/{chunk-H75VXTGT.js.map → chunk-L6LDXRWE.js.map} +1 -1
  90. package/dist/{chunk-YXMZ2N6J.js → chunk-M7J6Z4IJ.js} +1071 -1025
  91. package/dist/chunk-M7J6Z4IJ.js.map +1 -0
  92. package/dist/chunk-MQEQMS7B.js +1009 -0
  93. package/dist/chunk-MQEQMS7B.js.map +1 -0
  94. package/dist/chunk-MTELVIYR.js +1421 -0
  95. package/dist/chunk-MTELVIYR.js.map +1 -0
  96. package/dist/{chunk-QFY4AFY4.js → chunk-PVC7WDKI.js} +58 -52
  97. package/dist/chunk-PVC7WDKI.js.map +1 -0
  98. package/dist/{chunk-VTHLCFN4.js → chunk-RAHNUYA5.js} +2 -2
  99. package/dist/{chunk-XKXWK2KP.js → chunk-SHZDP2MQ.js} +1157 -1021
  100. package/dist/chunk-SHZDP2MQ.js.map +1 -0
  101. package/dist/{chunk-CZNV3VXM.js → chunk-SIDJO2T4.js} +11 -11
  102. package/dist/chunk-STXRMPW4.js +4131 -0
  103. package/dist/chunk-STXRMPW4.js.map +1 -0
  104. package/dist/{chunk-2747WN4Y.js → chunk-TPND5MJS.js} +3 -3
  105. package/dist/chunk-TQPCAIQI.js +612 -0
  106. package/dist/chunk-TQPCAIQI.js.map +1 -0
  107. package/dist/{chunk-43BKLFZU.js → chunk-YDWBXXQZ.js} +10 -10
  108. package/dist/{chunk-6PHB5CJS.js → chunk-ZLFRB6FI.js} +2 -2
  109. package/dist/composition/index.cjs +1228 -1076
  110. package/dist/composition/index.cjs.map +1 -1
  111. package/dist/composition/index.d.cts +3 -3
  112. package/dist/composition/index.d.ts +3 -3
  113. package/dist/composition/index.js +4 -4
  114. package/dist/core/index.cjs +1198 -1046
  115. package/dist/core/index.cjs.map +1 -1
  116. package/dist/core/index.d.cts +1 -1
  117. package/dist/core/index.d.ts +1 -1
  118. package/dist/core/index.js +2 -2
  119. package/dist/cqrs/index.d.cts +3 -3
  120. package/dist/cqrs/index.d.ts +3 -3
  121. package/dist/cqrs/messaging.d.cts +4 -4
  122. package/dist/cqrs/messaging.d.ts +4 -4
  123. package/dist/cqrs/work-queue.d.cts +5 -5
  124. package/dist/cqrs/work-queue.d.ts +5 -5
  125. package/dist/data-structures/index.cjs +1226 -1074
  126. package/dist/data-structures/index.cjs.map +1 -1
  127. package/dist/data-structures/index.d.cts +8 -7
  128. package/dist/data-structures/index.d.ts +8 -7
  129. package/dist/data-structures/index.js +6 -5
  130. package/dist/{describe-BpyJuWkw.d.ts → describe-B_A5fbXH.d.ts} +1 -1
  131. package/dist/{describe-DYMw_l1C.d.cts → describe-CQRrkv-Q.d.cts} +1 -1
  132. package/dist/executors/tool-provider-adapters.cjs +3091 -0
  133. package/dist/executors/tool-provider-adapters.cjs.map +1 -0
  134. package/dist/executors/tool-provider-adapters.d.cts +174 -0
  135. package/dist/executors/tool-provider-adapters.d.ts +174 -0
  136. package/dist/executors/tool-provider-adapters.js +1336 -0
  137. package/dist/executors/tool-provider-adapters.js.map +1 -0
  138. package/dist/executors/tool-provider-runtime.cjs +5178 -0
  139. package/dist/executors/tool-provider-runtime.cjs.map +1 -0
  140. package/dist/executors/tool-provider-runtime.d.cts +17 -0
  141. package/dist/executors/tool-provider-runtime.d.ts +17 -0
  142. package/dist/executors/tool-provider-runtime.js +15 -0
  143. package/dist/executors/tool-provider-runtime.js.map +1 -0
  144. package/dist/executors/tool-provider.cjs +6392 -0
  145. package/dist/executors/tool-provider.cjs.map +1 -0
  146. package/dist/executors/tool-provider.d.cts +60 -0
  147. package/dist/executors/tool-provider.d.ts +60 -0
  148. package/dist/executors/tool-provider.js +89 -0
  149. package/dist/executors/tool-provider.js.map +1 -0
  150. package/dist/executors/work-queue.d.cts +6 -6
  151. package/dist/executors/work-queue.d.ts +6 -6
  152. package/dist/graph/index.cjs +1499 -1341
  153. package/dist/graph/index.cjs.map +1 -1
  154. package/dist/graph/index.d.cts +9 -8
  155. package/dist/graph/index.d.ts +9 -8
  156. package/dist/graph/index.js +23 -22
  157. package/dist/{graph-DCEWh4T2.d.cts → graph-CWK3HLPB.d.cts} +133 -131
  158. package/dist/{graph-D-1-SQeC.d.ts → graph-ho5sotHP.d.ts} +133 -131
  159. package/dist/{index-Bmxeu0nK.d.ts → index-CQWcE0Dw.d.ts} +18 -4
  160. package/dist/{index-72VZC0-E.d.cts → index-DHA1i67c.d.cts} +18 -4
  161. package/dist/index.cjs +3397 -3140
  162. package/dist/index.cjs.map +1 -1
  163. package/dist/index.d.cts +12 -9
  164. package/dist/index.d.ts +12 -9
  165. package/dist/index.js +110 -109
  166. package/dist/inspection/boundary.d.cts +4 -4
  167. package/dist/inspection/boundary.d.ts +4 -4
  168. package/dist/measurements-C0mAvWU1.d.cts +164 -0
  169. package/dist/measurements-OMpCeBwh.d.ts +164 -0
  170. package/dist/messaging/index.cjs +57 -51
  171. package/dist/messaging/index.cjs.map +1 -1
  172. package/dist/messaging/index.d.cts +11 -276
  173. package/dist/messaging/index.d.ts +11 -276
  174. package/dist/messaging/index.js +1 -1
  175. package/dist/operators/index.cjs +1228 -1076
  176. package/dist/operators/index.cjs.map +1 -1
  177. package/dist/operators/index.d.cts +5 -5
  178. package/dist/operators/index.d.ts +5 -5
  179. package/dist/operators/index.js +5 -5
  180. package/dist/orchestration/index.cjs +8844 -6071
  181. package/dist/orchestration/index.cjs.map +1 -1
  182. package/dist/orchestration/index.d.cts +171 -224
  183. package/dist/orchestration/index.d.ts +171 -224
  184. package/dist/orchestration/index.js +42 -991
  185. package/dist/orchestration/index.js.map +1 -1
  186. package/dist/orchestration/messaging.d.cts +5 -8
  187. package/dist/orchestration/messaging.d.ts +5 -8
  188. package/dist/orchestration/work-queue.cjs +1243 -5
  189. package/dist/orchestration/work-queue.cjs.map +1 -1
  190. package/dist/orchestration/work-queue.d.cts +121 -10
  191. package/dist/orchestration/work-queue.d.ts +121 -10
  192. package/dist/orchestration/work-queue.js +1067 -4
  193. package/dist/orchestration/work-queue.js.map +1 -1
  194. package/dist/patterns/event-flow.cjs +6 -20
  195. package/dist/patterns/event-flow.cjs.map +1 -1
  196. package/dist/patterns/event-flow.d.cts +4 -4
  197. package/dist/patterns/event-flow.d.ts +4 -4
  198. package/dist/patterns/event-flow.js +2 -2
  199. package/dist/patterns/index.cjs +453 -465
  200. package/dist/patterns/index.cjs.map +1 -1
  201. package/dist/patterns/index.d.cts +6 -5
  202. package/dist/patterns/index.d.ts +6 -5
  203. package/dist/patterns/index.js +3 -3
  204. package/dist/process-types-C9uMYz3i.d.ts +200 -0
  205. package/dist/process-types-h3uRlzDc.d.cts +200 -0
  206. package/dist/{reactive-collection-DNV0-gFi.d.cts → reactive-collection-B9R0Bl1P.d.cts} +4 -34
  207. package/dist/{reactive-collection-BAmfrGjd.d.ts → reactive-collection-BXFrH0U2.d.ts} +4 -34
  208. package/dist/{reactive-collection-storage-BNEldDyi.d.cts → reactive-collection-storage-BLGv8Xp8.d.cts} +5 -5
  209. package/dist/{reactive-collection-storage-YZsAQsWK.d.ts → reactive-collection-storage-a4zD3665.d.ts} +5 -5
  210. package/dist/{reactive-map-DRD1LJ2H.d.cts → reactive-map-C_8sOfdS.d.cts} +3 -2
  211. package/dist/{reactive-map-EsDiCmJk.d.ts → reactive-map-jle5dnok.d.ts} +3 -2
  212. package/dist/render/index.d.cts +2 -2
  213. package/dist/render/index.d.ts +2 -2
  214. package/dist/scheduled-readiness-5rwQlyjV.d.ts +91 -0
  215. package/dist/scheduled-readiness-DpRY8jI0.d.cts +91 -0
  216. package/dist/semantic-memory-graph-C2ZUwIlq.d.ts +30 -0
  217. package/dist/semantic-memory-graph-DlZBD_Eu.d.cts +30 -0
  218. package/dist/{semantic-memory-graph-DKuNzuWw.d.cts → semantic-memory-graph-types-BvzdqmkY.d.cts} +2 -28
  219. package/dist/{semantic-memory-graph-uwbwJdhe.d.ts → semantic-memory-graph-types-Ci-OtahO.d.ts} +2 -28
  220. package/dist/solutions/index.cjs +6353 -6169
  221. package/dist/solutions/index.cjs.map +1 -1
  222. package/dist/solutions/index.d.cts +12 -10
  223. package/dist/solutions/index.d.ts +12 -10
  224. package/dist/solutions/index.js +5 -5
  225. package/dist/solutions/reactive-layout/browser/index.cjs +116 -108
  226. package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -1
  227. package/dist/solutions/reactive-layout/browser/index.d.cts +4 -4
  228. package/dist/solutions/reactive-layout/browser/index.d.ts +4 -4
  229. package/dist/solutions/reactive-layout/browser/index.js +3 -3
  230. package/dist/solutions/reactive-layout/index.cjs +3578 -3350
  231. package/dist/solutions/reactive-layout/index.cjs.map +1 -1
  232. package/dist/solutions/reactive-layout/index.d.cts +32 -576
  233. package/dist/solutions/reactive-layout/index.d.ts +32 -576
  234. package/dist/solutions/reactive-layout/index.js +65 -5
  235. package/dist/solutions/reactive-layout/node-canvas/index.cjs +127 -117
  236. package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -1
  237. package/dist/solutions/reactive-layout/node-canvas/index.d.cts +4 -4
  238. package/dist/solutions/reactive-layout/node-canvas/index.d.ts +4 -4
  239. package/dist/solutions/reactive-layout/node-canvas/index.js +3 -3
  240. package/dist/solutions/reactive-layout/react-native/index.cjs +127 -117
  241. package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -1
  242. package/dist/solutions/reactive-layout/react-native/index.d.cts +4 -4
  243. package/dist/solutions/reactive-layout/react-native/index.d.ts +4 -4
  244. package/dist/solutions/reactive-layout/react-native/index.js +3 -3
  245. package/dist/solutions/reactive-layout/skia/index.cjs +127 -117
  246. package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -1
  247. package/dist/solutions/reactive-layout/skia/index.d.cts +4 -4
  248. package/dist/solutions/reactive-layout/skia/index.d.ts +4 -4
  249. package/dist/solutions/reactive-layout/skia/index.js +3 -3
  250. package/dist/solutions/work-item/actions.cjs +1609 -1428
  251. package/dist/solutions/work-item/actions.cjs.map +1 -1
  252. package/dist/solutions/work-item/actions.d.cts +23 -184
  253. package/dist/solutions/work-item/actions.d.ts +23 -184
  254. package/dist/solutions/work-item/actions.js +1558 -934
  255. package/dist/solutions/work-item/actions.js.map +1 -1
  256. package/dist/solutions/work-item/scheduling.cjs +9181 -1838
  257. package/dist/solutions/work-item/scheduling.cjs.map +1 -1
  258. package/dist/solutions/work-item/scheduling.d.cts +1763 -328
  259. package/dist/solutions/work-item/scheduling.d.ts +1763 -328
  260. package/dist/solutions/work-item/scheduling.js +117 -3
  261. package/dist/solutions/work-item/work-queue.d.cts +7 -7
  262. package/dist/solutions/work-item/work-queue.d.ts +7 -7
  263. package/dist/sources/browser.cjs +1318 -1083
  264. package/dist/sources/browser.cjs.map +1 -1
  265. package/dist/sources/browser.d.cts +4 -4
  266. package/dist/sources/browser.d.ts +4 -4
  267. package/dist/sources/browser.js +4 -4
  268. package/dist/sources/index.cjs +1318 -1083
  269. package/dist/sources/index.cjs.map +1 -1
  270. package/dist/sources/index.d.cts +4 -4
  271. package/dist/sources/index.d.ts +4 -4
  272. package/dist/sources/index.js +4 -4
  273. package/dist/sources/node.d.cts +3 -3
  274. package/dist/sources/node.d.ts +3 -3
  275. package/dist/storage/browser.cjs +16 -0
  276. package/dist/storage/browser.cjs.map +1 -1
  277. package/dist/storage/browser.js +3 -3
  278. package/dist/storage/index.cjs +16 -0
  279. package/dist/storage/index.cjs.map +1 -1
  280. package/dist/storage/index.d.cts +5 -4
  281. package/dist/storage/index.d.ts +5 -4
  282. package/dist/storage/index.js +6 -6
  283. package/dist/storage/node.cjs +16 -0
  284. package/dist/storage/node.cjs.map +1 -1
  285. package/dist/storage/node.js +3 -3
  286. package/dist/{store-C-joM4gh.d.ts → store-BmtEs9mG.d.ts} +1 -1
  287. package/dist/{store-CNJwmT-h.d.cts → store-PAAsYvML.d.cts} +1 -1
  288. package/dist/types-BRNKoFHj.d.ts +357 -0
  289. package/dist/{types-CcPIn7sy.d.cts → types-BS6CyR-x.d.cts} +27 -108
  290. package/dist/types-BWK2ay3e.d.cts +457 -0
  291. package/dist/types-BXKSAoE1.d.cts +357 -0
  292. package/dist/types-BaPpZItj.d.ts +457 -0
  293. package/dist/types-BhveCMg5.d.cts +274 -0
  294. package/dist/{types-BsJvElYZ.d.ts → types-C9NOgNJw.d.ts} +27 -108
  295. package/dist/types-CTsQ8Ww4.d.ts +274 -0
  296. package/dist/types-DL_05n2M.d.ts +34 -0
  297. package/dist/types-XDoqxYO9.d.cts +34 -0
  298. package/dist/{work-item-runtime-C3M79vE9.d.ts → work-item-runtime-types-BqtWnSCS.d.ts} +3 -93
  299. package/dist/{work-item-runtime-qaVgsL0T.d.cts → work-item-runtime-types-CHO03AKh.d.cts} +3 -93
  300. package/dist/work-queue/index.cjs +957 -953
  301. package/dist/work-queue/index.cjs.map +1 -1
  302. package/dist/work-queue/index.d.cts +9 -357
  303. package/dist/work-queue/index.d.ts +9 -357
  304. package/dist/work-queue/index.js +957 -953
  305. package/dist/work-queue/index.js.map +1 -1
  306. package/package.json +603 -513
  307. package/dist/chunk-3JR3EDB2.js.map +0 -1
  308. package/dist/chunk-4VLAQHZI.js.map +0 -1
  309. package/dist/chunk-6XAIOL3X.js +0 -2407
  310. package/dist/chunk-6XAIOL3X.js.map +0 -1
  311. package/dist/chunk-FBUU43PM.js.map +0 -1
  312. package/dist/chunk-HKK2JD7Z.js.map +0 -1
  313. package/dist/chunk-PC3BTTBE.js +0 -3217
  314. package/dist/chunk-PC3BTTBE.js.map +0 -1
  315. package/dist/chunk-QFY4AFY4.js.map +0 -1
  316. package/dist/chunk-V7CIJE4B.js.map +0 -1
  317. package/dist/chunk-XKXWK2KP.js.map +0 -1
  318. package/dist/chunk-YDSIVHRR.js.map +0 -1
  319. package/dist/chunk-YXMZ2N6J.js.map +0 -1
  320. /package/dist/{chunk-Z2ANQ6JW.js.map → chunk-4Q77MMJY.js.map} +0 -0
  321. /package/dist/{chunk-IXZBUWSP.js.map → chunk-7HZRJMN6.js.map} +0 -0
  322. /package/dist/{chunk-SS2A464I.js.map → chunk-CJIFGJQG.js.map} +0 -0
  323. /package/dist/{chunk-K3FXTC3I.js.map → chunk-HJACH5PU.js.map} +0 -0
  324. /package/dist/{chunk-GTPCOEOZ.js.map → chunk-IDMLXLLG.js.map} +0 -0
  325. /package/dist/{chunk-DKP56CSW.js.map → chunk-JKAYLDQV.js.map} +0 -0
  326. /package/dist/{chunk-VTHLCFN4.js.map → chunk-RAHNUYA5.js.map} +0 -0
  327. /package/dist/{chunk-CZNV3VXM.js.map → chunk-SIDJO2T4.js.map} +0 -0
  328. /package/dist/{chunk-2747WN4Y.js.map → chunk-TPND5MJS.js.map} +0 -0
  329. /package/dist/{chunk-43BKLFZU.js.map → chunk-YDWBXXQZ.js.map} +0 -0
  330. /package/dist/{chunk-6PHB5CJS.js.map → chunk-ZLFRB6FI.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/orchestration/agent-runtime-outcome-view.ts","../src/orchestration/agent-runtime-tool-provider-policy.ts","../src/orchestration/agent-runtime-tool-provider-input.ts"],"sourcesContent":["import { depBatch } from \"../ctx/types.js\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.js\";\nimport {\n\tdataIssue,\n\tprojectRuntimeFact,\n\tref,\n\tsanitizeProviderGraphVisibleRecord,\n\tuniqueSourceRefs,\n} from \"./agent-runtime-common.js\";\nimport { outcomeIssues } from \"./agent-runtime-executor-outcome.js\";\nimport type { AgentRuntimeAuditRecord } from \"./agent-runtime-types-agent.js\";\nimport type { ExecutorOutcome, SourceRef } from \"./agent-runtime-types-core.js\";\nimport type {\n\tExecutorOutcomeView,\n\tExecutorOutcomeViewBundle,\n\tExecutorOutcomeViewPolicy,\n} from \"./agent-runtime-types-tool.js\";\n\nexport function executorOutcomeViewProjector(\n\tgraph: Graph,\n\topts: {\n\t\treadonly name?: string;\n\t\treadonly outcomes: Node<ExecutorOutcome>;\n\t\treadonly policy?: ExecutorOutcomeViewPolicy;\n\t},\n): ExecutorOutcomeViewBundle {\n\tconst name = opts.name ?? \"executorOutcomeViews\";\n\tconst policy = {\n\t\taudience: opts.policy?.audience ?? \"agent-observation\",\n\t\tmaxSummaryChars: opts.policy?.maxSummaryChars ?? 512,\n\t\tincludeIssues: opts.policy?.includeIssues ?? true,\n\t\tincludeUsage: opts.policy?.includeUsage ?? false,\n\t\tincludeMetadata: opts.policy?.includeMetadata ?? false,\n\t} satisfies Required<ExecutorOutcomeViewPolicy>;\n\tconst runtime = graph.node<ExecutorOutcomeViewFact>(\n\t\t[opts.outcomes],\n\t\t(ctx) => {\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst outcome = raw as ExecutorOutcome;\n\t\t\t\tconst projection = executorOutcomeViewProjectionFromOutcome(outcome, policy);\n\t\t\t\tctx.down([\n\t\t\t\t\t[\"DATA\", { kind: \"view\", view: projection.view } satisfies ExecutorOutcomeViewFact],\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"audit\",\n\t\t\t\t\t\t\taudit: {\n\t\t\t\t\t\t\t\tid: `${outcome.outcomeId}:outcome-view:${policy.audience}`,\n\t\t\t\t\t\t\t\tkind: \"executor-outcome-view-projected\",\n\t\t\t\t\t\t\t\tsubjectId: outcome.requestId,\n\t\t\t\t\t\t\t\tsourceRefs: [ref(\"executor-outcome\", outcome.outcomeId)],\n\t\t\t\t\t\t\t\tmetadata: { audience: policy.audience, status: outcome.kind },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} satisfies ExecutorOutcomeViewFact,\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t\tfor (const issue of projection.issues) {\n\t\t\t\t\tctx.down([[\"DATA\", { kind: \"issue\", issue } satisfies ExecutorOutcomeViewFact]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ name: `${name}/runtime`, factory: \"executorOutcomeViewProjector\" },\n\t);\n\treturn {\n\t\tviews: projectRuntimeFact(graph, runtime, `${name}/views`, \"executorOutcomeViews\", (fact) =>\n\t\t\tfact.kind === \"view\" ? fact.view : undefined,\n\t\t),\n\t\tissues: projectRuntimeFact(\n\t\t\tgraph,\n\t\t\truntime,\n\t\t\t`${name}/issues`,\n\t\t\t\"executorOutcomeViewIssues\",\n\t\t\t(fact) => (fact.kind === \"issue\" ? fact.issue : undefined),\n\t\t),\n\t\taudit: projectRuntimeFact(\n\t\t\tgraph,\n\t\t\truntime,\n\t\t\t`${name}/audit`,\n\t\t\t\"executorOutcomeViewAudit\",\n\t\t\t(fact) => (fact.kind === \"audit\" ? fact.audit : undefined),\n\t\t),\n\t};\n}\n\nexport type ExecutorOutcomeViewFact =\n\t| { readonly kind: \"view\"; readonly view: ExecutorOutcomeView }\n\t| { readonly kind: \"issue\"; readonly issue: DataIssue }\n\t| { readonly kind: \"audit\"; readonly audit: AgentRuntimeAuditRecord };\n\nexport interface ExecutorOutcomeViewProjection {\n\treadonly view: ExecutorOutcomeView;\n\treadonly issues: readonly DataIssue[];\n}\n\nexport interface ExecutorOutcomeSummaryProjection {\n\treadonly summary: string;\n\treadonly truncated: boolean;\n\treadonly originalChars: number;\n\treadonly limitChars: number;\n}\n\nexport function executorOutcomeViewProjectionFromOutcome(\n\toutcome: ExecutorOutcome,\n\tpolicy: Required<ExecutorOutcomeViewPolicy>,\n): ExecutorOutcomeViewProjection {\n\tconst sourceRefs = uniqueSourceRefs([\n\t\tref(\"executor-outcome\", outcome.outcomeId),\n\t\t...(outcome.evidenceRefs ?? []),\n\t]);\n\tconst summary = projectOutcomeSummary(outcome, policy.maxSummaryChars);\n\tconst issues = Object.freeze([\n\t\t...outcomeIssues(outcome),\n\t\t...(summary.truncated ? [outcomeSummaryTruncationIssue(outcome, summary, policy)] : []),\n\t]);\n\tconst metadata = policy.includeMetadata\n\t\t? sanitizeProviderGraphVisibleRecord(outcome.metadata)\n\t\t: undefined;\n\tconst view = Object.freeze({\n\t\tkind: \"executor-outcome-view\",\n\t\tviewId: `${outcome.outcomeId}:${policy.audience}`,\n\t\taudience: policy.audience,\n\t\toutcomeId: outcome.outcomeId,\n\t\trequestId: outcome.requestId,\n\t\toperationId: outcome.operationId,\n\t\trouteId: outcome.routeId,\n\t\texecutorId: outcome.executorId,\n\t\tprofileId: outcome.profileId,\n\t\tstatus: outcome.kind,\n\t\tsummary: summary.summary,\n\t\tsummaryTruncated: summary.truncated,\n\t\tsummaryChars: summary.originalChars,\n\t\tsummaryLimitChars: summary.limitChars,\n\t\terrorKind: outcomeErrorKind(outcome),\n\t\tretryable: outcomeRetryable(outcome),\n\t\tnextActions: outcomeNextActions(outcome),\n\t\tsourceRefs,\n\t\tmaterialRefs: outcomeMaterialRefs(outcome),\n\t\tissues: policy.includeIssues && issues.length > 0 ? issues : undefined,\n\t\tusage: policy.includeUsage ? outcome.usage : undefined,\n\t\t...(metadata === undefined ? {} : { metadata }),\n\t} satisfies ExecutorOutcomeView);\n\treturn Object.freeze({ view, issues });\n}\n\nexport function projectOutcomeSummary(\n\toutcome: ExecutorOutcome,\n\tmaxChars: number,\n): ExecutorOutcomeSummaryProjection {\n\tconst summary = outcomeSummary(outcome);\n\tconst limitChars = Math.max(0, maxChars);\n\tif (summary.length <= limitChars) {\n\t\treturn Object.freeze({\n\t\t\tsummary,\n\t\t\ttruncated: false,\n\t\t\toriginalChars: summary.length,\n\t\t\tlimitChars,\n\t\t});\n\t}\n\tconst bounded =\n\t\tlimitChars <= 1\n\t\t\t? summary.slice(0, limitChars)\n\t\t\t: limitChars <= 3\n\t\t\t\t? summary.slice(0, limitChars)\n\t\t\t\t: `${summary.slice(0, limitChars - 3)}...`;\n\treturn Object.freeze({\n\t\tsummary: bounded,\n\t\ttruncated: true,\n\t\toriginalChars: summary.length,\n\t\tlimitChars,\n\t});\n}\n\nexport function outcomeSummaryTruncationIssue(\n\toutcome: ExecutorOutcome,\n\tsummary: ExecutorOutcomeSummaryProjection,\n\tpolicy: Required<ExecutorOutcomeViewPolicy>,\n): DataIssue {\n\treturn dataIssue(\n\t\t\"executor-outcome-view-summary-truncated\",\n\t\t\"ExecutorOutcome view summary was truncated; inspect material refs or the source outcome for full detail\",\n\t\t{\n\t\t\tsubjectId: outcome.requestId,\n\t\t\trefs: [ref(\"executor-outcome\", outcome.outcomeId)],\n\t\t\tseverity: \"warning\",\n\t\t\tdetails: {\n\t\t\t\taudience: policy.audience,\n\t\t\t\toutcomeId: outcome.outcomeId,\n\t\t\t\toriginalChars: summary.originalChars,\n\t\t\t\tlimitChars: summary.limitChars,\n\t\t\t},\n\t\t},\n\t);\n}\n\nexport function outcomeSummary(outcome: ExecutorOutcome): string {\n\tif (outcome.kind === \"result\") {\n\t\tif (outcome.result.summary !== undefined && outcome.result.summary.length > 0)\n\t\t\treturn outcome.result.summary;\n\t\treturn `Executor result '${outcome.result.kind}' is available via source refs`;\n\t}\n\tif (outcome.kind === \"failure\") return outcome.error.message;\n\tif (outcome.kind === \"blocked\") {\n\t\tconst needKinds = outcome.needs.map((need) => need.kind).join(\", \");\n\t\treturn needKinds.length > 0 ? `Executor blocked: ${needKinds}` : \"Executor blocked\";\n\t}\n\tif (outcome.kind === \"timeout\") {\n\t\treturn outcome.timeoutMs === undefined\n\t\t\t? \"Executor timed out\"\n\t\t\t: `Executor timed out after ${outcome.timeoutMs}ms`;\n\t}\n\treturn outcome.reason ?? \"Executor canceled\";\n}\n\nexport function outcomeErrorKind(outcome: ExecutorOutcome): string | undefined {\n\tif (outcome.kind === \"failure\") return outcome.error.code;\n\tif (outcome.kind === \"timeout\") return \"timeout\";\n\tif (outcome.kind === \"blocked\") return outcome.needs[0]?.kind ?? \"blocked\";\n\tif (outcome.kind === \"canceled\") return \"canceled\";\n\treturn undefined;\n}\n\nexport function outcomeRetryable(outcome: ExecutorOutcome): boolean | undefined {\n\tif (outcome.kind === \"failure\" || outcome.kind === \"timeout\") return outcome.retryable;\n\treturn undefined;\n}\n\nexport function outcomeNextActions(outcome: ExecutorOutcome): readonly string[] | undefined {\n\tif (outcome.kind === \"blocked\") return Object.freeze(outcome.needs.map((need) => need.kind));\n\tif ((outcome.kind === \"failure\" || outcome.kind === \"timeout\") && outcome.retryable === true) {\n\t\treturn Object.freeze([\"retry-or-route\"]);\n\t}\n\treturn undefined;\n}\n\nexport function outcomeMaterialRefs(outcome: ExecutorOutcome): readonly SourceRef[] | undefined {\n\tconst refs =\n\t\toutcome.kind === \"result\"\n\t\t\t? [...(outcome.result.refs ?? [])]\n\t\t\t: outcome.kind === \"blocked\"\n\t\t\t\t? outcome.needs.flatMap((need) => [...(need.refs ?? [])])\n\t\t\t\t: [];\n\treturn refs.length === 0 ? undefined : uniqueSourceRefs(refs);\n}\n","import { depBatch } from \"../ctx/types.js\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.js\";\nimport {\n\tdataIssue,\n\tforbiddenDataKeys,\n\tforbiddenGraphVisibleMaterialIssues,\n\tforbiddenProviderRawMaterialKeys,\n\tforEachDepBatch,\n\tisRecord,\n\tprojectRuntimeFact,\n\tref,\n\tsanitizeProviderGraphVisibleRecord,\n\tunlockedToolProviderPolicyOverrides,\n} from \"./agent-runtime-common.js\";\nimport type { AgentRuntimeAuditRecord } from \"./agent-runtime-types-agent.js\";\nimport type {\n\tAgentRequestFact,\n\tAgentRequestIssued,\n\tExecutorProfile,\n\tExecutorRoute,\n\tSourceRef,\n} from \"./agent-runtime-types-core.js\";\nimport type {\n\tLocalBuiltinToolProviderCatalogOptions,\n\tToolCallInput,\n\tToolProviderApprovalPolicy,\n\tToolProviderArtifactPolicy,\n\tToolProviderCatalog,\n\tToolProviderCatalogEntry,\n\tToolProviderExecutionPolicy,\n\tToolProviderFilesystemPolicy,\n\tToolProviderNetworkPolicy,\n\tToolProviderPathRule,\n\tToolProviderPolicyResolution,\n\tToolProviderPolicyResolutionBundle,\n\tToolProviderPolicyResolutionStatus,\n\tToolProviderRedactionPolicy,\n\tToolProviderSizeCapacityPolicy,\n\tToolProviderSizeLimit,\n\tToolProviderTimeoutPolicy,\n} from \"./agent-runtime-types-tool.js\";\n\nexport function localBuiltinToolProviderCatalog(\n\topts: LocalBuiltinToolProviderCatalogOptions = {},\n): ToolProviderCatalog {\n\tconst providerId = opts.providerId ?? \"local-builtin\";\n\tconst executorId = opts.executorId ?? `${providerId}:tool-executor`;\n\tconst profileId = opts.profileId ?? `${providerId}:tool-profile`;\n\tconst tools =\n\t\topts.tools ??\n\t\t([\n\t\t\t{ toolName: \"document/read-doc\", operation: \"read\" },\n\t\t\t{ toolName: \"file.read\", operation: \"read\" },\n\t\t\t{ toolName: \"file.edit/apply-patch\", operation: \"edit\" },\n\t\t\t{ toolName: \"bash.run\", operation: \"run\" },\n\t\t\t{ toolName: \"url.fetch\", operation: \"fetch\" },\n\t\t\t{ toolName: \"date.now\", operation: \"read\" },\n\t\t\t{ toolName: \"weather.fetch\", operation: \"fetch\" },\n\t\t\t{ toolName: \"calculator/eval\", operation: \"eval\" },\n\t\t] satisfies readonly Omit<\n\t\t\tToolProviderCatalogEntry,\n\t\t\t\"kind\" | \"providerId\" | \"inputKind\" | \"profileId\" | \"executorId\"\n\t\t>[]);\n\tconst candidatePolicies: readonly unknown[] = opts.policies?.map((policy) =>\n\t\tObject.freeze(policy),\n\t) ?? [\n\t\tdefaultLocalBuiltinToolProviderExecutionPolicy({\n\t\t\tproviderId,\n\t\t\tprofileId,\n\t\t\ttools,\n\t\t\toverrides: opts.policyOverrides,\n\t\t}),\n\t];\n\tconst policyIssues = Object.freeze(\n\t\tcandidatePolicies.flatMap((policy) => [\n\t\t\t...validateToolProviderExecutionPolicy(policy),\n\t\t\t...validateToolProviderPolicyProviderScope(policy, providerId),\n\t\t]),\n\t);\n\tconst policies = Object.freeze(\n\t\tcandidatePolicies\n\t\t\t.filter((policy) => isPublishableToolProviderExecutionPolicy(policy, providerId))\n\t\t\t.map((policy) => Object.freeze(policy)),\n\t);\n\tconst policyRefs = Object.freeze(\n\t\tpolicies.map((policy) => ref(\"tool-provider-execution-policy\", policy.policyId)),\n\t);\n\tconst catalogInputIssues = Object.freeze([\n\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\topts.metadata,\n\t\t\tref(\"tool-provider-catalog\", providerId),\n\t\t\t\"catalog-metadata\",\n\t\t),\n\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\topts.capabilities,\n\t\t\tref(\"executor-profile\", profileId),\n\t\t\t\"profile-capabilities\",\n\t\t),\n\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\topts.limits,\n\t\t\tref(\"executor-profile\", profileId),\n\t\t\t\"profile-limits\",\n\t\t),\n\t\t...tools.flatMap((tool) => [\n\t\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\t\ttool.metadata,\n\t\t\t\tref(\"tool\", tool.toolName),\n\t\t\t\t\"tool-metadata\",\n\t\t\t),\n\t\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\t\ttool.capabilities,\n\t\t\t\tref(\"tool\", tool.toolName),\n\t\t\t\t\"tool-capabilities\",\n\t\t\t),\n\t\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\t\ttool.limits,\n\t\t\t\tref(\"tool\", tool.toolName),\n\t\t\t\t\"tool-limits\",\n\t\t\t),\n\t\t]),\n\t]);\n\tconst toolEntries = tools.map((tool) => {\n\t\tconst toolPolicyRefs = policyRefsForTool(policies, profileId, tool);\n\t\treturn Object.freeze({\n\t\t\t...tool,\n\t\t\tkind: \"tool-catalog-entry\",\n\t\t\tproviderId,\n\t\t\tinputKind: \"tool-call\",\n\t\t\tprofileId,\n\t\t\texecutorId,\n\t\t\tcapabilities: sanitizeProviderGraphVisibleRecord(tool.capabilities),\n\t\t\tlimits: sanitizeProviderGraphVisibleRecord(tool.limits),\n\t\t\tpolicyRefs: toolPolicyRefs,\n\t\t\tmetadata: sanitizeProviderGraphVisibleRecord(tool.metadata),\n\t\t} satisfies ToolProviderCatalogEntry);\n\t});\n\tconst profilePolicyRefs = policyRefsForProfile(policies, profileId);\n\tconst issues = Object.freeze([...policyIssues, ...catalogInputIssues]);\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-catalog\",\n\t\tproviderId,\n\t\tproviderKind: \"local-builtin\",\n\t\tstatus: issues.length === 0 ? \"ready\" : \"misconfigured\",\n\t\tprofiles: Object.freeze([\n\t\t\tObject.freeze({\n\t\t\t\tprofileId,\n\t\t\t\texecutorId,\n\t\t\t\tkind: \"tool\",\n\t\t\t\tacceptedInputKinds: Object.freeze([\"tool-call\"]),\n\t\t\t\tacceptedResultKinds: Object.freeze(\n\t\t\t\t\tArray.from(new Set(toolEntries.flatMap((tool) => tool.resultKinds ?? []))),\n\t\t\t\t),\n\t\t\t\tcapabilities: Object.freeze({\n\t\t\t\t\ttoolNames: Object.freeze(toolEntries.map((tool) => tool.toolName)),\n\t\t\t\t\t...(sanitizeProviderGraphVisibleRecord(opts.capabilities) ?? {}),\n\t\t\t\t}),\n\t\t\t\tlimits: sanitizeProviderGraphVisibleRecord(opts.limits),\n\t\t\t\tpolicyRefs: profilePolicyRefs,\n\t\t\t\tmetadata: sanitizeProviderGraphVisibleRecord(opts.metadata),\n\t\t\t} satisfies ExecutorProfile),\n\t\t]),\n\t\ttools: Object.freeze(toolEntries),\n\t\tpolicies,\n\t\tpolicyRefs,\n\t\tissues: issues.length === 0 ? undefined : issues,\n\t\tmetadata: sanitizeProviderGraphVisibleRecord(opts.metadata),\n\t});\n}\n\nexport function validateToolProviderExecutionPolicy(policy: unknown): readonly DataIssue[] {\n\tconst issues: DataIssue[] = [];\n\tif (!isRecord(policy)) {\n\t\treturn Object.freeze([\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-invalid-shape\",\n\t\t\t\t\"Tool provider policy must be a data object.\",\n\t\t\t\t{ refs: [ref(\"tool-provider-execution-policy\", \"<invalid>\")] },\n\t\t\t),\n\t\t]);\n\t}\n\tconst policyId = typeof policy.policyId === \"string\" ? policy.policyId : \"\";\n\tconst providerId = typeof policy.providerId === \"string\" ? policy.providerId : \"\";\n\tconst policyRef = ref(\"tool-provider-execution-policy\", policyId || \"<missing>\");\n\tif (policy.kind !== \"tool-provider-execution-policy\") {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-invalid-kind\",\n\t\t\t\t\"ToolProviderExecutionPolicy.kind must be tool-provider-execution-policy.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tif (!policyId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-missing-policy-id\",\n\t\t\t\t\"Tool provider policy is missing policyId.\",\n\t\t\t\t{\n\t\t\t\t\trefs: [policyRef],\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\tif (!providerId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-missing-provider-id\",\n\t\t\t\t\"Tool provider policy is missing providerId.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tif (\n\t\tpolicy.sizeCapacity === undefined &&\n\t\tpolicy.timeout === undefined &&\n\t\tpolicy.redaction === undefined &&\n\t\tpolicy.filesystem === undefined &&\n\t\tpolicy.approval === undefined &&\n\t\tpolicy.artifacts === undefined &&\n\t\tpolicy.network === undefined\n\t) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-missing-material\",\n\t\t\t\t\"Tool provider policy has no D360 policy material sections.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tif (policy.sizeCapacity !== undefined && !isRecord(policy.sizeCapacity)) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-invalid-size-capacity\",\n\t\t\t\t\"Tool provider size-capacity policy must be a data object.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tconst limits = isRecord(policy.sizeCapacity) ? policy.sizeCapacity.limits : undefined;\n\tif (isRecord(policy.sizeCapacity) && !Array.isArray(limits)) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-invalid-size-capacity\",\n\t\t\t\t\"Tool provider size-capacity limits must be an array.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tfor (const [index, rawLimit] of (Array.isArray(limits) ? limits : []).entries()) {\n\t\tif (!isRecord(rawLimit)) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-size-limit\",\n\t\t\t\t\t\"Tool provider size-capacity limit must be a data object.\",\n\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { index } },\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tconst limit = rawLimit as Partial<ToolProviderSizeLimit>;\n\t\tif (typeof limit.unit !== \"string\" || limit.unit.length === 0) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-size-limit\",\n\t\t\t\t\t\"Tool provider size-capacity limit unit must be a non-empty string.\",\n\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { index } },\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tlimit.softLimit !== undefined &&\n\t\t\t(typeof limit.softLimit !== \"number\" ||\n\t\t\t\t!Number.isFinite(limit.softLimit) ||\n\t\t\t\tlimit.softLimit < 0)\n\t\t) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-size-limit\",\n\t\t\t\t\t\"Tool provider size-capacity softLimit must be a finite non-negative number.\",\n\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { index, unit: limit.unit } },\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tlimit.hardLimit !== undefined &&\n\t\t\t(typeof limit.hardLimit !== \"number\" ||\n\t\t\t\t!Number.isFinite(limit.hardLimit) ||\n\t\t\t\tlimit.hardLimit < 0)\n\t\t) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-size-limit\",\n\t\t\t\t\t\"Tool provider size-capacity hardLimit must be a finite non-negative number.\",\n\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { index, unit: limit.unit } },\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\ttypeof limit.softLimit === \"number\" &&\n\t\t\tNumber.isFinite(limit.softLimit) &&\n\t\t\ttypeof limit.hardLimit === \"number\" &&\n\t\t\tNumber.isFinite(limit.hardLimit) &&\n\t\t\tlimit.softLimit > limit.hardLimit\n\t\t) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-size-limit\",\n\t\t\t\t\t\"Tool provider size-capacity softLimit must not exceed hardLimit.\",\n\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { index, unit: limit.unit } },\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\tif (policy.timeout !== undefined && !isRecord(policy.timeout)) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-invalid-timeout\",\n\t\t\t\t\"Tool provider timeout policy must be a data object.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tfor (const [field, value] of Object.entries(isRecord(policy.timeout) ? policy.timeout : {})) {\n\t\tif (field.endsWith(\"TimeoutMs\") || field === \"timeoutMs\") {\n\t\t\tif (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n\t\t\t\tissues.push(\n\t\t\t\t\tdataIssue(\n\t\t\t\t\t\t\"tool-provider-policy-invalid-timeout\",\n\t\t\t\t\t\t\"Tool provider timeout values must be finite non-negative numbers.\",\n\t\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { field } },\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\tfor (const forbidden of [\n\t\t...forbiddenDataKeys(policy),\n\t\t...forbiddenProviderRawMaterialKeys(policy),\n\t]) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-forbidden-runtime-material\",\n\t\t\t\t\"Tool provider policy must not contain runtime-private adapter material.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { reason: forbidden.reason } },\n\t\t\t),\n\t\t);\n\t}\n\treturn Object.freeze(issues);\n}\n\nexport function resolveToolProviderExecutionPolicies(opts: {\n\treadonly request: AgentRequestIssued;\n\treadonly routes?: readonly ExecutorRoute[];\n\treadonly catalogs?: readonly ToolProviderCatalog[];\n}): readonly ToolProviderPolicyResolution[] {\n\tconst request = opts.request;\n\tconst toolCall = toolCallFromRequest(request);\n\tconst baseSourceRefs = Object.freeze([ref(\"agent-request\", request.requestId)]);\n\tif (toolCall === undefined) {\n\t\treturn Object.freeze([\n\t\t\tObject.freeze({\n\t\t\t\tkind: \"tool-provider-policy-resolution\",\n\t\t\t\tresolutionId: `${request.requestId}:${request.operationId}:tool-policy:missing-tool-call`,\n\t\t\t\tstatus: \"missing-tool-call\",\n\t\t\t\trequestId: request.requestId,\n\t\t\t\toperationId: request.operationId,\n\t\t\t\tissues: Object.freeze([\n\t\t\t\t\tdataIssue(\n\t\t\t\t\t\t\"tool-provider-policy-missing-tool-call\",\n\t\t\t\t\t\t\"Tool provider policy resolution requires AgentRequest input.value to be a ToolCallInput.\",\n\t\t\t\t\t\t{ subjectId: request.requestId, refs: baseSourceRefs },\n\t\t\t\t\t),\n\t\t\t\t]),\n\t\t\t\tsourceRefs: baseSourceRefs,\n\t\t\t} satisfies ToolProviderPolicyResolution),\n\t\t]);\n\t}\n\tconst routes = (opts.routes ?? []).filter(\n\t\t(route) => route.requestId === request.requestId && route.operationId === request.operationId,\n\t);\n\tif (routes.length === 0) {\n\t\treturn Object.freeze([\n\t\t\tObject.freeze({\n\t\t\t\tkind: \"tool-provider-policy-resolution\",\n\t\t\t\tresolutionId: `${request.requestId}:${request.operationId}:tool-policy:pending-route`,\n\t\t\t\tstatus: \"pending-route\",\n\t\t\t\trequestId: request.requestId,\n\t\t\t\toperationId: request.operationId,\n\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\toperation: toolCall.operation,\n\t\t\t\tsourceRefs: baseSourceRefs,\n\t\t\t} satisfies ToolProviderPolicyResolution),\n\t\t]);\n\t}\n\treturn Object.freeze(\n\t\troutes.map((route) =>\n\t\t\tObject.freeze(\n\t\t\t\tresolveToolProviderPolicyForRoute(request, route, toolCall, opts.catalogs ?? []),\n\t\t\t),\n\t\t),\n\t);\n}\n\nexport function toolProviderPolicyResolutionProjector(\n\tgraph: Graph,\n\topts: {\n\t\treadonly name?: string;\n\t\treadonly requestFacts: Node<AgentRequestFact>;\n\t\treadonly executorRoutes?: readonly Node<ExecutorRoute>[];\n\t\treadonly toolProviderCatalogs?: readonly Node<ToolProviderCatalog>[];\n\t},\n): ToolProviderPolicyResolutionBundle {\n\tconst name = opts.name ?? \"toolProviderPolicyResolution\";\n\tconst routeDeps = opts.executorRoutes ?? [];\n\tconst catalogDeps = opts.toolProviderCatalogs ?? [];\n\tconst routeStart = 1;\n\tconst catalogStart = routeStart + routeDeps.length;\n\tconst runtime = graph.node<ToolProviderPolicyResolutionFact>(\n\t\t[opts.requestFacts, ...routeDeps, ...catalogDeps],\n\t\t(ctx) => {\n\t\t\tconst state = ctx.state.get<ToolProviderPolicyResolutionState>() ?? {\n\t\t\t\trequests: new Map<string, AgentRequestIssued>(),\n\t\t\t\troutes: new Map<string, ExecutorRoute>(),\n\t\t\t\tcatalogs: new Map<string, ToolProviderCatalog>(),\n\t\t\t\temittedKeys: new Set<string>(),\n\t\t\t\tauditSeq: 0,\n\t\t\t};\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst fact = raw as AgentRequestFact;\n\t\t\t\tif (fact.kind === \"issued\" && fact.input?.inputKind === \"tool-call\") {\n\t\t\t\t\tstate.requests.set(fact.requestId, fact);\n\t\t\t\t}\n\t\t\t}\n\t\t\tforEachDepBatch(ctx, routeStart, routeDeps.length, (raw) => {\n\t\t\t\tconst route = raw as ExecutorRoute;\n\t\t\t\tstate.routes.set(route.routeId, route);\n\t\t\t});\n\t\t\tforEachDepBatch(ctx, catalogStart, catalogDeps.length, (raw) => {\n\t\t\t\tconst catalog = raw as ToolProviderCatalog;\n\t\t\t\tstate.catalogs.set(catalog.providerId, catalog);\n\t\t\t});\n\t\t\tfor (const request of state.requests.values()) {\n\t\t\t\tconst resolutions = resolveToolProviderExecutionPolicies({\n\t\t\t\t\trequest,\n\t\t\t\t\troutes: Array.from(state.routes.values()),\n\t\t\t\t\tcatalogs: Array.from(state.catalogs.values()),\n\t\t\t\t});\n\t\t\t\tfor (const resolution of resolutions) {\n\t\t\t\t\tconst key = stableToolProviderPolicyResolutionKey(resolution);\n\t\t\t\t\tif (state.emittedKeys.has(key)) continue;\n\t\t\t\t\tstate.emittedKeys.add(key);\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\"DATA\", { kind: \"resolution\", resolution } satisfies ToolProviderPolicyResolutionFact],\n\t\t\t\t\t]);\n\t\t\t\t\tfor (const issue of resolution.issues ?? []) {\n\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t[\"DATA\", { kind: \"issue\", issue } satisfies ToolProviderPolicyResolutionFact],\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\t\t\t\t\tstate.auditSeq += 1;\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: \"audit\",\n\t\t\t\t\t\t\t\taudit: {\n\t\t\t\t\t\t\t\t\tid: `${name}:audit:${state.auditSeq}`,\n\t\t\t\t\t\t\t\t\tkind: \"tool-provider-policy-resolution\",\n\t\t\t\t\t\t\t\t\tsubjectId: request.requestId,\n\t\t\t\t\t\t\t\t\tsourceRefs: resolution.sourceRefs,\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\tstatus: resolution.status,\n\t\t\t\t\t\t\t\t\t\trouteId: resolution.routeId,\n\t\t\t\t\t\t\t\t\t\tproviderId: resolution.providerId,\n\t\t\t\t\t\t\t\t\t\tprofileId: resolution.profileId,\n\t\t\t\t\t\t\t\t\t\ttoolName: resolution.toolName,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} satisfies ToolProviderPolicyResolutionFact,\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\tctx.state.set(state);\n\t\t},\n\t\t{ name: `${name}/runtime`, factory: \"toolProviderPolicyResolutionProjector\", partial: true },\n\t);\n\tconst resolutions = projectRuntimeFact(\n\t\tgraph,\n\t\truntime,\n\t\t`${name}/resolutions`,\n\t\t\"toolProviderPolicyResolutions\",\n\t\t(fact) => (fact.kind === \"resolution\" ? fact.resolution : undefined),\n\t);\n\tconst issues = projectRuntimeFact(\n\t\tgraph,\n\t\truntime,\n\t\t`${name}/issues`,\n\t\t\"toolProviderPolicyResolutionIssues\",\n\t\t(fact) => (fact.kind === \"issue\" ? fact.issue : undefined),\n\t);\n\tconst audit = projectRuntimeFact(\n\t\tgraph,\n\t\truntime,\n\t\t`${name}/audit`,\n\t\t\"toolProviderPolicyResolutionAudit\",\n\t\t(fact) => (fact.kind === \"audit\" ? fact.audit : undefined),\n\t);\n\treturn { resolutions, issues, audit };\n}\n\nexport type ToolProviderPolicyResolutionFact =\n\t| { readonly kind: \"resolution\"; readonly resolution: ToolProviderPolicyResolution }\n\t| { readonly kind: \"issue\"; readonly issue: DataIssue }\n\t| { readonly kind: \"audit\"; readonly audit: AgentRuntimeAuditRecord };\n\nexport interface ToolProviderPolicyResolutionState {\n\trequests: Map<string, AgentRequestIssued>;\n\troutes: Map<string, ExecutorRoute>;\n\tcatalogs: Map<string, ToolProviderCatalog>;\n\temittedKeys: Set<string>;\n\tauditSeq: number;\n}\n\nexport function isPublishableToolProviderExecutionPolicy(\n\tpolicy: unknown,\n\tproviderId?: string,\n): policy is ToolProviderExecutionPolicy {\n\treturn (\n\t\tisRecord(policy) &&\n\t\tpolicy.kind === \"tool-provider-execution-policy\" &&\n\t\ttypeof policy.policyId === \"string\" &&\n\t\tpolicy.policyId.length > 0 &&\n\t\ttypeof policy.providerId === \"string\" &&\n\t\tpolicy.providerId.length > 0 &&\n\t\t(providerId === undefined || policy.providerId === providerId) &&\n\t\tvalidateToolProviderExecutionPolicy(policy).length === 0\n\t);\n}\n\nexport function validateToolProviderPolicyProviderScope(\n\tpolicy: unknown,\n\tproviderId: string,\n): readonly DataIssue[] {\n\tif (!isRecord(policy)) return [];\n\tif (policy.providerId === undefined || policy.providerId === providerId) return [];\n\treturn Object.freeze([\n\t\tdataIssue(\n\t\t\t\"tool-provider-policy-provider-mismatch\",\n\t\t\t\"Tool provider policy providerId must match the catalog providerId.\",\n\t\t\t{\n\t\t\t\tsubjectId: typeof policy.policyId === \"string\" ? policy.policyId : undefined,\n\t\t\t\trefs: [\n\t\t\t\t\tref(\n\t\t\t\t\t\t\"tool-provider-execution-policy\",\n\t\t\t\t\t\ttypeof policy.policyId === \"string\" && policy.policyId.length > 0\n\t\t\t\t\t\t\t? policy.policyId\n\t\t\t\t\t\t\t: \"<missing>\",\n\t\t\t\t\t),\n\t\t\t\t\tref(\"tool-provider-catalog\", providerId),\n\t\t\t\t],\n\t\t\t},\n\t\t),\n\t]);\n}\n\nexport function policyRefsForProfile(\n\tpolicies: readonly ToolProviderExecutionPolicy[],\n\tprofileId: string,\n): readonly SourceRef[] {\n\treturn Object.freeze(\n\t\tpolicies\n\t\t\t.filter((policy) => policyAppliesToProfile(policy, profileId))\n\t\t\t.map((policy) => ref(\"tool-provider-execution-policy\", policy.policyId)),\n\t);\n}\n\nexport function policyRefsForTool(\n\tpolicies: readonly ToolProviderExecutionPolicy[],\n\tprofileId: string,\n\ttool: Omit<\n\t\tToolProviderCatalogEntry,\n\t\t\"kind\" | \"providerId\" | \"inputKind\" | \"profileId\" | \"executorId\"\n\t>,\n): readonly SourceRef[] {\n\treturn Object.freeze(\n\t\tpolicies\n\t\t\t.filter((policy) => policyAppliesToProfile(policy, profileId))\n\t\t\t.filter((policy) => policyAppliesToOptionalScope(policy.toolNames, tool.toolName))\n\t\t\t.filter((policy) => policyAppliesToOptionalScope(policy.operations, tool.operation))\n\t\t\t.map((policy) => ref(\"tool-provider-execution-policy\", policy.policyId)),\n\t);\n}\n\nexport function policyAppliesToProfile(\n\tpolicy: ToolProviderExecutionPolicy,\n\tprofileId: string,\n): boolean {\n\treturn policyAppliesToOptionalScope(policy.profileIds, profileId);\n}\n\nexport function policyAppliesToOptionalScope(\n\tscope: readonly string[] | undefined,\n\tvalue: string | undefined,\n): boolean {\n\treturn (\n\t\tscope === undefined || scope.length === 0 || (value !== undefined && scope.includes(value))\n\t);\n}\n\nexport function toolCallFromRequest(request: AgentRequestIssued): ToolCallInput | undefined {\n\tconst value = request.input?.value;\n\tif (request.input?.inputKind !== \"tool-call\" || !isRecord(value)) return undefined;\n\tif (\n\t\tvalue.kind !== \"tool-call\" ||\n\t\ttypeof value.toolName !== \"string\" ||\n\t\tvalue.toolName.length === 0\n\t) {\n\t\treturn undefined;\n\t}\n\treturn value as unknown as ToolCallInput;\n}\n\nexport function resolveToolProviderPolicyForRoute(\n\trequest: AgentRequestIssued,\n\troute: ExecutorRoute,\n\ttoolCall: ToolCallInput,\n\tcatalogs: readonly ToolProviderCatalog[],\n): ToolProviderPolicyResolution {\n\tconst sourceRefs = Object.freeze([\n\t\tref(\"agent-request\", request.requestId),\n\t\tref(\"executor-route\", route.routeId),\n\t]);\n\tconst matchingCatalogs = catalogs.filter((catalog) => catalogHasRouteProfile(catalog, route));\n\tif (matchingCatalogs.length === 0) {\n\t\treturn policyResolutionWithIssue({\n\t\t\trequest,\n\t\t\troute,\n\t\t\ttoolCall,\n\t\t\tstatus: \"missing-catalog\",\n\t\t\tsourceRefs,\n\t\t\tissue: dataIssue(\n\t\t\t\t\"tool-provider-policy-missing-catalog\",\n\t\t\t\t`No tool provider catalog exposes route profile '${route.profileId}'.`,\n\t\t\t\t{ subjectId: request.requestId, refs: sourceRefs },\n\t\t\t),\n\t\t});\n\t}\n\tif (matchingCatalogs.length > 1) {\n\t\treturn policyResolutionWithIssue({\n\t\t\trequest,\n\t\t\troute,\n\t\t\ttoolCall,\n\t\t\tstatus: \"ambiguous-catalog\",\n\t\t\tsourceRefs,\n\t\t\tissue: dataIssue(\n\t\t\t\t\"tool-provider-policy-ambiguous-catalog\",\n\t\t\t\t`Multiple tool provider catalogs expose route profile '${route.profileId}'.`,\n\t\t\t\t{\n\t\t\t\t\tsubjectId: request.requestId,\n\t\t\t\t\trefs: [\n\t\t\t\t\t\t...sourceRefs,\n\t\t\t\t\t\t...matchingCatalogs.map((catalog) => ref(\"tool-provider-catalog\", catalog.providerId)),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t),\n\t\t});\n\t}\n\tconst catalog = matchingCatalogs[0];\n\tif (catalog === undefined) throw new Error(\"unreachable catalog match\");\n\tconst tool = catalog.tools.find(\n\t\t(entry) =>\n\t\t\tentry.profileId === route.profileId &&\n\t\t\tentry.executorId === route.executorId &&\n\t\t\tentry.toolName === toolCall.toolName &&\n\t\t\t(entry.operation === undefined ||\n\t\t\t\ttoolCall.operation === undefined ||\n\t\t\t\tentry.operation === toolCall.operation),\n\t);\n\tif (tool === undefined) {\n\t\treturn policyResolutionWithIssue({\n\t\t\trequest,\n\t\t\troute,\n\t\t\ttoolCall,\n\t\t\tstatus: \"missing-tool\",\n\t\t\tsourceRefs,\n\t\t\tproviderId: catalog.providerId,\n\t\t\tissue: dataIssue(\n\t\t\t\t\"tool-provider-policy-missing-tool\",\n\t\t\t\t`Tool provider catalog '${catalog.providerId}' does not expose requested tool '${toolCall.toolName}'.`,\n\t\t\t\t{\n\t\t\t\t\tsubjectId: request.requestId,\n\t\t\t\t\trefs: [...sourceRefs, ref(\"tool-provider-catalog\", catalog.providerId)],\n\t\t\t\t},\n\t\t\t),\n\t\t});\n\t}\n\tconst policyRefs = policyRefsForResolution(catalog, route, tool);\n\tif (policyRefs.length === 0) {\n\t\treturn policyResolutionWithIssue({\n\t\t\trequest,\n\t\t\troute,\n\t\t\ttoolCall,\n\t\t\tstatus: \"missing-policy\",\n\t\t\tsourceRefs,\n\t\t\tproviderId: catalog.providerId,\n\t\t\tissue: dataIssue(\n\t\t\t\t\"tool-provider-policy-missing-policy-ref\",\n\t\t\t\t`Tool '${tool.toolName}' has no D360 policy refs on its entry, profile, or catalog.`,\n\t\t\t\t{\n\t\t\t\t\tsubjectId: request.requestId,\n\t\t\t\t\trefs: [...sourceRefs, ref(\"tool-provider-catalog\", catalog.providerId)],\n\t\t\t\t},\n\t\t\t),\n\t\t});\n\t}\n\tconst issues = policyIssuesForRefs(catalog, policyRefs, request, sourceRefs);\n\tconst status = issues.length === 0 ? \"resolved\" : \"invalid-policy\";\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-policy-resolution\",\n\t\tresolutionId: `${request.requestId}:${request.operationId}:${route.routeId}:tool-policy`,\n\t\tstatus,\n\t\trequestId: request.requestId,\n\t\toperationId: request.operationId,\n\t\trouteId: route.routeId,\n\t\tproviderId: catalog.providerId,\n\t\texecutorId: route.executorId,\n\t\tprofileId: route.profileId,\n\t\ttoolName: toolCall.toolName,\n\t\toperation: toolCall.operation,\n\t\tpolicyRefs,\n\t\tissues: issues.length === 0 ? undefined : Object.freeze(issues),\n\t\tsourceRefs: Object.freeze([...sourceRefs, ref(\"tool-provider-catalog\", catalog.providerId)]),\n\t} satisfies ToolProviderPolicyResolution);\n}\n\nexport function catalogHasRouteProfile(\n\tcatalog: ToolProviderCatalog,\n\troute: ExecutorRoute,\n): boolean {\n\treturn catalog.profiles.some(\n\t\t(profile) => profile.profileId === route.profileId && profile.executorId === route.executorId,\n\t);\n}\n\nexport function policyRefsForResolution(\n\tcatalog: ToolProviderCatalog,\n\troute: ExecutorRoute,\n\ttool: ToolProviderCatalogEntry,\n): readonly SourceRef[] {\n\tconst profile = catalog.profiles.find(\n\t\t(candidate) =>\n\t\t\tcandidate.profileId === route.profileId && candidate.executorId === route.executorId,\n\t);\n\treturn Object.freeze([\n\t\t...(tool.policyRefs ?? []),\n\t\t...((tool.policyRefs?.length ?? 0) === 0 ? (profile?.policyRefs ?? []) : []),\n\t\t...((tool.policyRefs?.length ?? 0) === 0 && (profile?.policyRefs?.length ?? 0) === 0\n\t\t\t? (catalog.policyRefs ?? [])\n\t\t\t: []),\n\t]);\n}\n\nexport function policyIssuesForRefs(\n\tcatalog: ToolProviderCatalog,\n\tpolicyRefs: readonly SourceRef[],\n\trequest: AgentRequestIssued,\n\tsourceRefs: readonly SourceRef[],\n): readonly DataIssue[] {\n\tconst policiesById = new Map((catalog.policies ?? []).map((policy) => [policy.policyId, policy]));\n\tconst issues: DataIssue[] = [];\n\tfor (const policyRef of policyRefs) {\n\t\tif (policyRef.kind !== \"tool-provider-execution-policy\") {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-ref-kind\",\n\t\t\t\t\t\"Tool provider policy refs must point at ToolProviderExecutionPolicy facts.\",\n\t\t\t\t\t{ subjectId: request.requestId, refs: [...sourceRefs, policyRef] },\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tconst policy = policiesById.get(policyRef.id);\n\t\tif (policy === undefined) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-ref-missing-material\",\n\t\t\t\t\t`Tool provider policy ref '${policyRef.id}' has no policy material in catalog '${catalog.providerId}'.`,\n\t\t\t\t\t{ subjectId: request.requestId, refs: [...sourceRefs, policyRef] },\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tissues.push(...validateToolProviderExecutionPolicy(policy));\n\t\tissues.push(...validateToolProviderPolicyProviderScope(policy, catalog.providerId));\n\t}\n\treturn Object.freeze(issues);\n}\n\nexport function policyResolutionWithIssue(opts: {\n\treadonly request: AgentRequestIssued;\n\treadonly route: ExecutorRoute;\n\treadonly toolCall: ToolCallInput;\n\treadonly status: ToolProviderPolicyResolutionStatus;\n\treadonly sourceRefs: readonly SourceRef[];\n\treadonly issue: DataIssue;\n\treadonly providerId?: string;\n}): ToolProviderPolicyResolution {\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-policy-resolution\",\n\t\tresolutionId: `${opts.request.requestId}:${opts.request.operationId}:${opts.route.routeId}:tool-policy:${opts.status}`,\n\t\tstatus: opts.status,\n\t\trequestId: opts.request.requestId,\n\t\toperationId: opts.request.operationId,\n\t\trouteId: opts.route.routeId,\n\t\tproviderId: opts.providerId,\n\t\texecutorId: opts.route.executorId,\n\t\tprofileId: opts.route.profileId,\n\t\ttoolName: opts.toolCall.toolName,\n\t\toperation: opts.toolCall.operation,\n\t\tissues: Object.freeze([opts.issue]),\n\t\tsourceRefs: opts.sourceRefs,\n\t} satisfies ToolProviderPolicyResolution);\n}\n\nexport function stableToolProviderPolicyResolutionKey(\n\tresolution: ToolProviderPolicyResolution,\n): string {\n\treturn JSON.stringify({\n\t\tid: resolution.resolutionId,\n\t\tstatus: resolution.status,\n\t\tpolicyRefs:\n\t\t\tresolution.policyRefs?.map((policyRef) => `${policyRef.kind}:${policyRef.id}`) ?? [],\n\t\tissues: resolution.issues?.map((issue) => issue.code) ?? [],\n\t});\n}\n\nexport function defaultLocalBuiltinToolProviderExecutionPolicy(opts: {\n\treadonly providerId: string;\n\treadonly profileId: string;\n\treadonly tools: readonly Omit<\n\t\tToolProviderCatalogEntry,\n\t\t\"kind\" | \"providerId\" | \"inputKind\" | \"profileId\" | \"executorId\"\n\t>[];\n\treadonly overrides?: Partial<\n\t\tOmit<ToolProviderExecutionPolicy, \"kind\" | \"policyId\" | \"providerId\">\n\t>;\n}): ToolProviderExecutionPolicy {\n\tconst toolNames = Object.freeze(Array.from(new Set(opts.tools.map((tool) => tool.toolName))));\n\tconst operations = Object.freeze(\n\t\tArray.from(new Set(opts.tools.map((tool) => tool.operation).filter((op) => op !== undefined))),\n\t);\n\tconst hasUrlFetch = toolNames.includes(\"url.fetch\");\n\tconst filesystemToolNames = toolNames.filter(\n\t\t(toolName) =>\n\t\t\ttoolName.startsWith(\"file.\") || toolName.startsWith(\"document/\") || toolName === \"bash.run\",\n\t);\n\tconst approvalToolNames = toolNames.filter(\n\t\t(toolName) => toolName === \"file.edit/apply-patch\" || toolName === \"bash.run\",\n\t);\n\tconst approvalOperations = operations.filter(\n\t\t(operation) => operation === \"edit\" || operation === \"run\",\n\t);\n\tconst policy = {\n\t\tkind: \"tool-provider-execution-policy\",\n\t\tpolicyId: `${opts.providerId}:policy:default`,\n\t\tproviderId: opts.providerId,\n\t\tprofileIds: Object.freeze([opts.profileId]),\n\t\ttoolNames,\n\t\toperations,\n\t\tsizeCapacity: Object.freeze({\n\t\t\tlimits: Object.freeze([\n\t\t\t\tObject.freeze({\n\t\t\t\t\tunit: \"chars\",\n\t\t\t\t\tsoftLimit: 16_384,\n\t\t\t\t\thardLimit: 65_536,\n\t\t\t\t\tperRequest: true,\n\t\t\t\t\tmeasurementSource: \"adapter-estimated\",\n\t\t\t\t} satisfies ToolProviderSizeLimit),\n\t\t\t\tObject.freeze({\n\t\t\t\t\tunit: \"bytes\",\n\t\t\t\t\tsoftLimit: 1_048_576,\n\t\t\t\t\thardLimit: 8_388_608,\n\t\t\t\t\tperArtifact: true,\n\t\t\t\t\tmeasurementSource: \"adapter-measured\",\n\t\t\t\t} satisfies ToolProviderSizeLimit),\n\t\t\t\tObject.freeze({\n\t\t\t\t\tunit: \"lines\",\n\t\t\t\t\tsoftLimit: 2_000,\n\t\t\t\t\thardLimit: 10_000,\n\t\t\t\t\tperStream: true,\n\t\t\t\t\tmeasurementSource: \"adapter-measured\",\n\t\t\t\t} satisfies ToolProviderSizeLimit),\n\t\t\t]),\n\t\t} satisfies ToolProviderSizeCapacityPolicy),\n\t\ttimeout: Object.freeze({\n\t\t\ttimeoutMs: 30_000,\n\t\t\tidleTimeoutMs: 5_000,\n\t\t} satisfies ToolProviderTimeoutPolicy),\n\t\tredaction: Object.freeze({\n\t\t\tmode: \"summary\",\n\t\t\tsensitivity: Object.freeze([\"private-material\", \"auth-material\", \"personal-data\"]),\n\t\t\tsummaryMaxChars: 512,\n\t\t} satisfies ToolProviderRedactionPolicy),\n\t\t...(filesystemToolNames.length > 0\n\t\t\t? {\n\t\t\t\t\tfilesystem: Object.freeze({\n\t\t\t\t\t\tcwd: \".\",\n\t\t\t\t\t\tallowRead: true,\n\t\t\t\t\t\tallowWrite: false,\n\t\t\t\t\t\tfollowSymlinks: false,\n\t\t\t\t\t\tsourceRefs: Object.freeze(filesystemToolNames.map((toolName) => ref(\"tool\", toolName))),\n\t\t\t\t\t\tpathRules: Object.freeze([\n\t\t\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\t\t\teffect: \"allow\",\n\t\t\t\t\t\t\t\tpath: \".\",\n\t\t\t\t\t\t\t\toperation: \"read\",\n\t\t\t\t\t\t\t\treason: \"Default local builtin catalog is workspace-relative data material.\",\n\t\t\t\t\t\t\t} satisfies ToolProviderPathRule),\n\t\t\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\t\t\teffect: \"deny\",\n\t\t\t\t\t\t\t\tglob: \"**/.env*\",\n\t\t\t\t\t\t\t\treason: \"D360 policies keep private material outside catalog DATA.\",\n\t\t\t\t\t\t\t} satisfies ToolProviderPathRule),\n\t\t\t\t\t\t]),\n\t\t\t\t\t} satisfies ToolProviderFilesystemPolicy),\n\t\t\t\t}\n\t\t\t: {}),\n\t\t...(hasUrlFetch\n\t\t\t? {\n\t\t\t\t\tnetwork: Object.freeze({\n\t\t\t\t\t\tmode: \"custom\",\n\t\t\t\t\t\tprotocols: Object.freeze([\"https:\"]),\n\t\t\t\t\t\tallowedHosts: Object.freeze([\"*\"]),\n\t\t\t\t\t\tsourceRefs: Object.freeze([ref(\"tool\", \"url.fetch\")]),\n\t\t\t\t\t} satisfies ToolProviderNetworkPolicy),\n\t\t\t\t}\n\t\t\t: {}),\n\t\tapproval: Object.freeze({\n\t\t\tmode: approvalToolNames.length > 0 ? \"require\" : \"auto\",\n\t\t\t...(approvalToolNames.length > 0\n\t\t\t\t? { requiredForToolNames: Object.freeze(approvalToolNames) }\n\t\t\t\t: {}),\n\t\t\t...(approvalOperations.length > 0\n\t\t\t\t? { requiredForOperations: Object.freeze(approvalOperations) }\n\t\t\t\t: {}),\n\t\t} satisfies ToolProviderApprovalPolicy),\n\t\tartifacts: Object.freeze({\n\t\t\tdefaultDataMode: \"summary\",\n\t\t\tartifactKinds: Object.freeze([\n\t\t\t\t\"text\",\n\t\t\t\t\"markdown\",\n\t\t\t\t\"file\",\n\t\t\t\t\"stdout\",\n\t\t\t\t\"stderr\",\n\t\t\t\t\"tool-output\",\n\t\t\t\t\"provider-raw\",\n\t\t\t]),\n\t\t\tinlineLimits: Object.freeze([\n\t\t\t\tObject.freeze({\n\t\t\t\t\tunit: \"chars\",\n\t\t\t\t\thardLimit: 4_096,\n\t\t\t\t\tperArtifact: true,\n\t\t\t\t\tmeasurementSource: \"adapter-estimated\",\n\t\t\t\t} satisfies ToolProviderSizeLimit),\n\t\t\t]),\n\t\t\trequireDigest: false,\n\t\t} satisfies ToolProviderArtifactPolicy),\n\t\tsourceRefs: Object.freeze([ref(\"decision\", \"D360\"), ref(\"tool-provider\", opts.providerId)]),\n\t\tmetadata: Object.freeze({\n\t\t\tdescription: \"Default data-only policy material for local builtin tools.\",\n\t\t}),\n\t\t...unlockedToolProviderPolicyOverrides(opts.overrides),\n\t} satisfies ToolProviderExecutionPolicy;\n\treturn Object.freeze(policy);\n}\n","import { depBatch } from \"../ctx/types.js\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.js\";\nimport {\n\tdataIssue,\n\tforbiddenAdapterInputMaterialIssues,\n\tforEachDepBatch,\n\tprojectRuntimeFact,\n\tref,\n\tsanitizeAdapterInputIssue,\n\tsanitizeAdapterInputSourceRefs,\n\tstableJsonStringify,\n} from \"./agent-runtime-common.js\";\nimport {\n\ttoolCallFromRequest,\n\tvalidateToolProviderExecutionPolicy,\n\tvalidateToolProviderPolicyProviderScope,\n} from \"./agent-runtime-tool-provider-policy.js\";\nimport type { AgentRuntimeAuditRecord } from \"./agent-runtime-types-agent.js\";\nimport type {\n\tAgentRequestFact,\n\tAgentRequestInput,\n\tAgentRequestIssued,\n\tExecutorRoute,\n\tSourceRef,\n} from \"./agent-runtime-types-core.js\";\nimport type {\n\tToolCallInput,\n\tToolProviderAdapterInput,\n\tToolProviderAdapterInputBundle,\n\tToolProviderAdapterInputStatus,\n\tToolProviderCatalog,\n\tToolProviderCatalogEntry,\n\tToolProviderExecutionPolicy,\n\tToolProviderPolicyResolution,\n} from \"./agent-runtime-types-tool.js\";\n\nexport function buildToolProviderAdapterInputs(opts: {\n\treadonly requests: readonly AgentRequestIssued[];\n\treadonly routes?: readonly ExecutorRoute[];\n\treadonly catalogs?: readonly ToolProviderCatalog[];\n\treadonly resolutions: readonly ToolProviderPolicyResolution[];\n}): readonly ToolProviderAdapterInput[] {\n\tconst requestsById = new Map(opts.requests.map((request) => [request.requestId, request]));\n\tconst routesById = new Map((opts.routes ?? []).map((route) => [route.routeId, route]));\n\tconst catalogsById = new Map(\n\t\t(opts.catalogs ?? []).map((catalog) => [catalog.providerId, catalog]),\n\t);\n\treturn Object.freeze(\n\t\topts.resolutions.map((resolution) =>\n\t\t\tbuildToolProviderAdapterInput({\n\t\t\t\tresolution,\n\t\t\t\trequest: requestsById.get(resolution.requestId),\n\t\t\t\troute: resolution.routeId === undefined ? undefined : routesById.get(resolution.routeId),\n\t\t\t\tcatalog:\n\t\t\t\t\tresolution.providerId === undefined ? undefined : catalogsById.get(resolution.providerId),\n\t\t\t}),\n\t\t),\n\t);\n}\n\nexport function toolProviderAdapterInputProjector(\n\tgraph: Graph,\n\topts: {\n\t\treadonly name?: string;\n\t\treadonly requestFacts: Node<AgentRequestFact>;\n\t\treadonly executorRoutes?: readonly Node<ExecutorRoute>[];\n\t\treadonly toolProviderCatalogs?: readonly Node<ToolProviderCatalog>[];\n\t\treadonly policyResolutions: readonly Node<ToolProviderPolicyResolution>[];\n\t},\n): ToolProviderAdapterInputBundle {\n\tconst name = opts.name ?? \"toolProviderAdapterInput\";\n\tconst routeDeps = opts.executorRoutes ?? [];\n\tconst catalogDeps = opts.toolProviderCatalogs ?? [];\n\tconst routeStart = 1;\n\tconst catalogStart = routeStart + routeDeps.length;\n\tconst resolutionStart = catalogStart + catalogDeps.length;\n\tconst runtime = graph.node<ToolProviderAdapterInputFact>(\n\t\t[opts.requestFacts, ...routeDeps, ...catalogDeps, ...opts.policyResolutions],\n\t\t(ctx) => {\n\t\t\tconst state = ctx.state.get<ToolProviderAdapterInputState>() ?? {\n\t\t\t\trequests: new Map<string, AgentRequestIssued>(),\n\t\t\t\troutes: new Map<string, ExecutorRoute>(),\n\t\t\t\tcatalogs: new Map<string, ToolProviderCatalog>(),\n\t\t\t\tresolutions: new Map<string, ToolProviderPolicyResolution>(),\n\t\t\t\temittedKeys: new Set<string>(),\n\t\t\t\tauditSeq: 0,\n\t\t\t};\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst fact = raw as AgentRequestFact;\n\t\t\t\tif (fact.kind === \"issued\" && fact.input?.inputKind === \"tool-call\") {\n\t\t\t\t\tstate.requests.set(fact.requestId, fact);\n\t\t\t\t}\n\t\t\t}\n\t\t\tforEachDepBatch(ctx, routeStart, routeDeps.length, (raw) => {\n\t\t\t\tconst route = raw as ExecutorRoute;\n\t\t\t\tstate.routes.set(route.routeId, route);\n\t\t\t});\n\t\t\tforEachDepBatch(ctx, catalogStart, catalogDeps.length, (raw) => {\n\t\t\t\tconst catalog = raw as ToolProviderCatalog;\n\t\t\t\tstate.catalogs.set(catalog.providerId, catalog);\n\t\t\t});\n\t\t\tforEachDepBatch(ctx, resolutionStart, opts.policyResolutions.length, (raw) => {\n\t\t\t\tconst resolution = raw as ToolProviderPolicyResolution;\n\t\t\t\tstate.resolutions.set(resolution.resolutionId, resolution);\n\t\t\t});\n\t\t\tconst inputs = buildToolProviderAdapterInputs({\n\t\t\t\trequests: Array.from(state.requests.values()),\n\t\t\t\troutes: Array.from(state.routes.values()),\n\t\t\t\tcatalogs: Array.from(state.catalogs.values()),\n\t\t\t\tresolutions: Array.from(state.resolutions.values()),\n\t\t\t});\n\t\t\tfor (const input of inputs) {\n\t\t\t\tconst key = stableToolProviderAdapterInputKey(input);\n\t\t\t\tif (state.emittedKeys.has(key)) continue;\n\t\t\t\tstate.emittedKeys.add(key);\n\t\t\t\tctx.down([[\"DATA\", { kind: \"input\", input } satisfies ToolProviderAdapterInputFact]]);\n\t\t\t\tfor (const issue of input.issues ?? []) {\n\t\t\t\t\tctx.down([[\"DATA\", { kind: \"issue\", issue } satisfies ToolProviderAdapterInputFact]]);\n\t\t\t\t}\n\t\t\t\tstate.auditSeq += 1;\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"audit\",\n\t\t\t\t\t\t\taudit: {\n\t\t\t\t\t\t\t\tid: `${name}:audit:${state.auditSeq}`,\n\t\t\t\t\t\t\t\tkind: \"tool-provider-adapter-input\",\n\t\t\t\t\t\t\t\tsubjectId: input.requestId,\n\t\t\t\t\t\t\t\tsourceRefs: input.sourceRefs,\n\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\tstatus: input.status,\n\t\t\t\t\t\t\t\t\trouteId: input.routeId,\n\t\t\t\t\t\t\t\t\tproviderId: input.providerId,\n\t\t\t\t\t\t\t\t\tprofileId: input.profileId,\n\t\t\t\t\t\t\t\t\ttoolName: input.toolName,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} satisfies ToolProviderAdapterInputFact,\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t}\n\t\t\tctx.state.set(state);\n\t\t},\n\t\t{ name: `${name}/runtime`, factory: \"toolProviderAdapterInputProjector\", partial: true },\n\t);\n\tconst inputs = projectRuntimeFact(\n\t\tgraph,\n\t\truntime,\n\t\t`${name}/inputs`,\n\t\t\"toolProviderAdapterInputs\",\n\t\t(fact) => (fact.kind === \"input\" ? fact.input : undefined),\n\t);\n\tconst issues = projectRuntimeFact(\n\t\tgraph,\n\t\truntime,\n\t\t`${name}/issues`,\n\t\t\"toolProviderAdapterInputIssues\",\n\t\t(fact) => (fact.kind === \"issue\" ? fact.issue : undefined),\n\t);\n\tconst audit = projectRuntimeFact(\n\t\tgraph,\n\t\truntime,\n\t\t`${name}/audit`,\n\t\t\"toolProviderAdapterInputAudit\",\n\t\t(fact) => (fact.kind === \"audit\" ? fact.audit : undefined),\n\t);\n\treturn { inputs, issues, audit };\n}\n\nexport type ToolProviderAdapterInputFact =\n\t| { readonly kind: \"input\"; readonly input: ToolProviderAdapterInput }\n\t| { readonly kind: \"issue\"; readonly issue: DataIssue }\n\t| { readonly kind: \"audit\"; readonly audit: AgentRuntimeAuditRecord };\n\nexport interface ToolProviderAdapterInputState {\n\trequests: Map<string, AgentRequestIssued>;\n\troutes: Map<string, ExecutorRoute>;\n\tcatalogs: Map<string, ToolProviderCatalog>;\n\tresolutions: Map<string, ToolProviderPolicyResolution>;\n\temittedKeys: Set<string>;\n\tauditSeq: number;\n}\n\nexport function buildToolProviderAdapterInput(opts: {\n\treadonly resolution: ToolProviderPolicyResolution;\n\treadonly request?: AgentRequestIssued;\n\treadonly route?: ExecutorRoute;\n\treadonly catalog?: ToolProviderCatalog;\n}): ToolProviderAdapterInput {\n\tconst { resolution, request, route, catalog } = opts;\n\tconst sourceRefs = sanitizeAdapterInputSourceRefs([\n\t\tref(\"tool-provider-policy-resolution\", resolution.resolutionId),\n\t\t...(resolution.sourceRefs ?? []),\n\t\t...(resolution.routeId === undefined ? [] : [ref(\"executor-route\", resolution.routeId)]),\n\t\t...(resolution.providerId === undefined\n\t\t\t? []\n\t\t\t: [ref(\"tool-provider-catalog\", resolution.providerId)]),\n\t\t...(resolution.policyRefs ?? []),\n\t]);\n\tconst issues: DataIssue[] = (resolution.issues ?? []).map((issue) =>\n\t\tsanitizeAdapterInputIssue(issue),\n\t);\n\tlet statusOverride: Exclude<ToolProviderAdapterInputStatus, \"ready\"> | undefined;\n\tif (request === undefined) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-missing-request\",\n\t\t\t\t\"Tool provider adapter input requires the issued AgentRequest fact.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs: sourceRefs },\n\t\t\t),\n\t\t);\n\t}\n\tif (request !== undefined && request.requestId !== resolution.requestId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-stale-request\",\n\t\t\t\t\"Tool provider adapter input request identity does not match its policy resolution.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs: sourceRefs },\n\t\t\t),\n\t\t);\n\t}\n\tif (request !== undefined && request.operationId !== resolution.operationId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-stale-request-operation\",\n\t\t\t\t\"Tool provider adapter input request operationId does not match its policy resolution.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs: sourceRefs },\n\t\t\t),\n\t\t);\n\t}\n\tif (resolution.routeId !== undefined && route === undefined) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-missing-route\",\n\t\t\t\t\"Tool provider adapter input requires the selected ExecutorRoute fact.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs: sourceRefs },\n\t\t\t),\n\t\t);\n\t}\n\tif (route !== undefined) {\n\t\tissues.push(...routeIdentityIssuesForAdapterInput(route, resolution, request, sourceRefs));\n\t}\n\tif (resolution.providerId !== undefined && catalog === undefined) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-missing-catalog\",\n\t\t\t\t\"Tool provider adapter input requires the selected ToolProviderCatalog fact.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs: sourceRefs },\n\t\t\t),\n\t\t);\n\t}\n\tif (catalog !== undefined && catalog.status !== undefined && catalog.status !== \"ready\") {\n\t\tstatusOverride = \"invalid-policy\";\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-catalog-unavailable\",\n\t\t\t\t\"Tool provider adapter input requires a ready ToolProviderCatalog.\",\n\t\t\t\t{\n\t\t\t\t\tsubjectId: resolution.requestId,\n\t\t\t\t\trefs: [...sourceRefs, ref(\"tool-provider-catalog\", catalog.providerId)],\n\t\t\t\t\tdetails: { status: catalog.status },\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t\tissues.push(...(catalog.issues ?? []).map((issue) => sanitizeAdapterInputIssue(issue)));\n\t}\n\tconst toolCall = request === undefined ? undefined : toolCallFromRequest(request);\n\tif (request !== undefined && toolCall === undefined) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-missing-tool-call\",\n\t\t\t\t\"Tool provider adapter input requires AgentRequest input.value to be a ToolCallInput.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs: sourceRefs },\n\t\t\t),\n\t\t);\n\t}\n\tconst tool =\n\t\tcatalog === undefined || route === undefined || toolCall === undefined\n\t\t\t? undefined\n\t\t\t: selectedToolForAdapterInput(catalog, route, toolCall);\n\tif (resolution.status === \"resolved\" && tool === undefined) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-missing-tool\",\n\t\t\t\t\"Tool provider adapter input requires the selected catalog tool entry.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs: sourceRefs },\n\t\t\t),\n\t\t);\n\t}\n\tconst policies =\n\t\tcatalog === undefined\n\t\t\t? []\n\t\t\t: selectedPoliciesForAdapterInput(catalog, resolution.policyRefs ?? []);\n\tif (resolution.status === \"resolved\" && (resolution.policyRefs?.length ?? 0) === 0) {\n\t\tstatusOverride = \"missing-policy\";\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-missing-policy-ref\",\n\t\t\t\t\"Ready tool provider adapter input requires at least one D360 policy ref.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs: sourceRefs },\n\t\t\t),\n\t\t);\n\t}\n\tif (catalog !== undefined) {\n\t\tfor (const issue of policyMaterialIssuesForAdapterInput(catalog, resolution, sourceRefs)) {\n\t\t\tstatusOverride ??= \"invalid-policy\";\n\t\t\tissues.push(issue);\n\t\t}\n\t}\n\tfor (const policy of policies) {\n\t\tissues.push(...validateToolProviderExecutionPolicy(policy));\n\t\tif (catalog !== undefined)\n\t\t\tissues.push(...validateToolProviderPolicyProviderScope(policy, catalog.providerId));\n\t}\n\tif (request?.input !== undefined) {\n\t\tissues.push(\n\t\t\t...forbiddenAdapterInputMaterialIssues(\n\t\t\t\trequest.input,\n\t\t\t\tref(\"agent-request\", request.requestId),\n\t\t\t\t\"request-input\",\n\t\t\t),\n\t\t);\n\t}\n\tif (route !== undefined) {\n\t\tissues.push(\n\t\t\t...forbiddenAdapterInputMaterialIssues(\n\t\t\t\troute.allowedParams,\n\t\t\t\tref(\"executor-route\", route.routeId),\n\t\t\t\t\"route-allowed-params\",\n\t\t\t),\n\t\t\t...forbiddenAdapterInputMaterialIssues(\n\t\t\t\troute.metadata,\n\t\t\t\tref(\"executor-route\", route.routeId),\n\t\t\t\t\"route-metadata\",\n\t\t\t),\n\t\t);\n\t}\n\tif (tool !== undefined) {\n\t\tconst toolRef = ref(\"tool\", tool.toolName);\n\t\tissues.push(\n\t\t\t...forbiddenAdapterInputMaterialIssues(tool.capabilities, toolRef, \"tool-capabilities\"),\n\t\t\t...forbiddenAdapterInputMaterialIssues(tool.limits, toolRef, \"tool-limits\"),\n\t\t\t...forbiddenAdapterInputMaterialIssues(tool.metadata, toolRef, \"tool-metadata\"),\n\t\t);\n\t}\n\tfor (const policy of policies) {\n\t\tissues.push(\n\t\t\t...forbiddenAdapterInputMaterialIssues(\n\t\t\t\tpolicy,\n\t\t\t\tref(\"tool-provider-execution-policy\", policy.policyId),\n\t\t\t\t\"policy-material\",\n\t\t\t),\n\t\t);\n\t}\n\tconst status =\n\t\tresolution.status === \"resolved\"\n\t\t\t? issues.length === 0\n\t\t\t\t? \"ready\"\n\t\t\t\t: (statusOverride ?? \"invalid-policy\")\n\t\t\t: resolution.status;\n\tconst ready = status === \"ready\";\n\tconst candidate = {\n\t\tkind: \"tool-provider-adapter-input\",\n\t\tadapterInputId: `${resolution.requestId}:${resolution.operationId}:${resolution.routeId ?? resolution.resolutionId}:adapter-input`,\n\t\tstatus,\n\t\trequestId: resolution.requestId,\n\t\toperationId: resolution.operationId,\n\t\teffectRunId: request?.effectRunId,\n\t\tagentRunId: request?.agentRunId,\n\t\trouteId: resolution.routeId,\n\t\tproviderId: resolution.providerId,\n\t\texecutorId: resolution.executorId,\n\t\tprofileId: resolution.profileId,\n\t\ttoolName: resolution.toolName,\n\t\toperation: resolution.operation,\n\t\tinput: ready ? (request?.input as AgentRequestInput<ToolCallInput> | undefined) : undefined,\n\t\ttoolCall: ready ? toolCall : undefined,\n\t\troute: ready ? route : undefined,\n\t\ttool: ready ? tool : undefined,\n\t\tpolicies: ready ? Object.freeze(policies) : undefined,\n\t\tpolicyRefs: sanitizeAdapterInputSourceRefs(resolution.policyRefs ?? []),\n\t\tsourceRefs,\n\t\tissues: issues.length === 0 ? undefined : Object.freeze(issues),\n\t\tmetadata: { resolutionId: resolution.resolutionId },\n\t} satisfies ToolProviderAdapterInput;\n\tif (ready) {\n\t\tconst candidateIssues = forbiddenAdapterInputMaterialIssues(\n\t\t\tcandidate,\n\t\t\tref(\"tool-provider-adapter-input\", candidate.adapterInputId),\n\t\t\t\"adapter-input\",\n\t\t);\n\t\tif (candidateIssues.length > 0) {\n\t\t\tconst blockedIssues = Object.freeze([...issues, ...candidateIssues]);\n\t\t\treturn Object.freeze({\n\t\t\t\t...candidate,\n\t\t\t\tstatus: \"invalid-policy\",\n\t\t\t\tinput: undefined,\n\t\t\t\ttoolCall: undefined,\n\t\t\t\troute: undefined,\n\t\t\t\ttool: undefined,\n\t\t\t\tpolicies: undefined,\n\t\t\t\tissues: blockedIssues,\n\t\t\t} satisfies ToolProviderAdapterInput);\n\t\t}\n\t}\n\treturn Object.freeze(candidate);\n}\n\nexport function selectedToolForAdapterInput(\n\tcatalog: ToolProviderCatalog,\n\troute: ExecutorRoute,\n\ttoolCall: ToolCallInput,\n): ToolProviderCatalogEntry | undefined {\n\treturn catalog.tools.find(\n\t\t(entry) =>\n\t\t\tentry.profileId === route.profileId &&\n\t\t\tentry.executorId === route.executorId &&\n\t\t\tentry.toolName === toolCall.toolName &&\n\t\t\t(entry.operation === undefined ||\n\t\t\t\ttoolCall.operation === undefined ||\n\t\t\t\tentry.operation === toolCall.operation),\n\t);\n}\n\nexport function selectedPoliciesForAdapterInput(\n\tcatalog: ToolProviderCatalog,\n\tpolicyRefs: readonly SourceRef[],\n): ToolProviderExecutionPolicy[] {\n\tconst policiesById = new Map((catalog.policies ?? []).map((policy) => [policy.policyId, policy]));\n\tconst policies: ToolProviderExecutionPolicy[] = [];\n\tfor (const policyRef of policyRefs) {\n\t\tif (policyRef.kind !== \"tool-provider-execution-policy\") continue;\n\t\tconst policy = policiesById.get(policyRef.id);\n\t\tif (policy !== undefined) policies.push(policy);\n\t}\n\treturn policies;\n}\n\nexport function routeIdentityIssuesForAdapterInput(\n\troute: ExecutorRoute,\n\tresolution: ToolProviderPolicyResolution,\n\trequest: AgentRequestIssued | undefined,\n\tsourceRefs: readonly SourceRef[],\n): readonly DataIssue[] {\n\tconst issues: DataIssue[] = [];\n\tconst refs = [...sourceRefs, ref(\"executor-route\", route.routeId)];\n\tif (route.requestId !== resolution.requestId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-stale-route-request\",\n\t\t\t\t\"ExecutorRoute requestId does not match the tool provider policy resolution.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (route.operationId !== resolution.operationId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-stale-route-operation\",\n\t\t\t\t\"ExecutorRoute operationId does not match the tool provider policy resolution.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (resolution.routeId !== undefined && route.routeId !== resolution.routeId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-stale-route-id\",\n\t\t\t\t\"ExecutorRoute routeId does not match the tool provider policy resolution.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (resolution.executorId !== undefined && route.executorId !== resolution.executorId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-stale-route-executor\",\n\t\t\t\t\"ExecutorRoute executorId does not match the tool provider policy resolution.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (resolution.profileId !== undefined && route.profileId !== resolution.profileId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-stale-route-profile\",\n\t\t\t\t\"ExecutorRoute profileId does not match the tool provider policy resolution.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (\n\t\trequest !== undefined &&\n\t\troute.inputId !== undefined &&\n\t\troute.inputId !== request.input?.inputId\n\t) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-stale-route-input\",\n\t\t\t\t\"ExecutorRoute inputId does not match the issued AgentRequest input.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (route.inputKind !== undefined && route.inputKind !== \"tool-call\") {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-invalid-route-input-kind\",\n\t\t\t\t\"Tool provider adapter input requires ExecutorRoute.inputKind to be tool-call when present.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (\n\t\trequest !== undefined &&\n\t\troute.inputKind !== undefined &&\n\t\trequest.input?.inputKind !== undefined &&\n\t\troute.inputKind !== request.input.inputKind\n\t) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-stale-route-input-kind\",\n\t\t\t\t\"ExecutorRoute inputKind does not match the issued AgentRequest input.\",\n\t\t\t\t{ subjectId: resolution.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\treturn Object.freeze(issues);\n}\n\nexport function policyMaterialIssuesForAdapterInput(\n\tcatalog: ToolProviderCatalog,\n\tresolution: ToolProviderPolicyResolution,\n\tsourceRefs: readonly SourceRef[],\n): readonly DataIssue[] {\n\tconst policiesById = new Map((catalog.policies ?? []).map((policy) => [policy.policyId, policy]));\n\tconst issues: DataIssue[] = [];\n\tfor (const policyRef of resolution.policyRefs ?? []) {\n\t\tif (policyRef.kind !== \"tool-provider-execution-policy\") {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-adapter-input-invalid-policy-ref-kind\",\n\t\t\t\t\t\"Tool provider adapter input policy refs must point at ToolProviderExecutionPolicy facts.\",\n\t\t\t\t\t{ subjectId: resolution.requestId, refs: [...sourceRefs, policyRef] },\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!policiesById.has(policyRef.id)) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-adapter-input-policy-ref-missing-material\",\n\t\t\t\t\t\"Tool provider adapter input policy ref has no selected policy material.\",\n\t\t\t\t\t{ subjectId: resolution.requestId, refs: [...sourceRefs, policyRef] },\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\treturn Object.freeze(issues);\n}\n\nexport function stableToolProviderAdapterInputKey(input: ToolProviderAdapterInput): string {\n\treturn stableJsonStringify({\n\t\tid: input.adapterInputId,\n\t\tstatus: input.status,\n\t\tpolicyRefs: input.policyRefs?.map((policyRef) => `${policyRef.kind}:${policyRef.id}`) ?? [],\n\t\tissues: input.issues?.map((issue) => issue.code) ?? [],\n\t\tinput,\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,SAAS,6BACf,OACA,MAK4B;AAC5B,QAAM,OAAO,KAAK,QAAQ;AAC1B,QAAM,SAAS;AAAA,IACd,UAAU,KAAK,QAAQ,YAAY;AAAA,IACnC,iBAAiB,KAAK,QAAQ,mBAAmB;AAAA,IACjD,eAAe,KAAK,QAAQ,iBAAiB;AAAA,IAC7C,cAAc,KAAK,QAAQ,gBAAgB;AAAA,IAC3C,iBAAiB,KAAK,QAAQ,mBAAmB;AAAA,EAClD;AACA,QAAM,UAAU,MAAM;AAAA,IACrB,CAAC,KAAK,QAAQ;AAAA,IACd,CAAC,QAAQ;AACR,iBAAW,OAAO,SAAS,KAAK,CAAC,KAAK,CAAC,GAAG;AACzC,cAAM,UAAU;AAChB,cAAM,aAAa,yCAAyC,SAAS,MAAM;AAC3E,YAAI,KAAK;AAAA,UACR,CAAC,QAAQ,EAAE,MAAM,QAAQ,MAAM,WAAW,KAAK,CAAmC;AAAA,UAClF;AAAA,YACC;AAAA,YACA;AAAA,cACC,MAAM;AAAA,cACN,OAAO;AAAA,gBACN,IAAI,GAAG,QAAQ,SAAS,iBAAiB,OAAO,QAAQ;AAAA,gBACxD,MAAM;AAAA,gBACN,WAAW,QAAQ;AAAA,gBACnB,YAAY,CAAC,IAAI,oBAAoB,QAAQ,SAAS,CAAC;AAAA,gBACvD,UAAU,EAAE,UAAU,OAAO,UAAU,QAAQ,QAAQ,KA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O;AAAA,QACN;AAAA,UACC;AAAA,UACA;AAAA,UACA,EAAE,WAAW,WAAW,WAAW,MAAM,CAAC,GAAG,YAAY,SAAS,EAAE;AAAA,QACrE;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACA,SAAO,OAAO,OAAO,MAAM;AAC5B;AAEO,SAAS,kCAAkC,OAAyC;AAC1F,SAAO,oBAAoB;AAAA,IAC1B,IAAI,MAAM;AAAA,IACV,QAAQ,MAAM;AAAA,IACd,YAAY,MAAM,YAAY,IAAI,CAAC,cAAc,GAAG,UAAU,IAAI,IAAI,UAAU,EAAE,EAAE,KAAK,CAAC;AAAA,IAC1F,QAAQ,MAAM,QAAQ,IAAI,CAAC,UAAU,MAAM,IAAI,KAAK,CAAC;AAAA,IACrD;AAAA,EACD,CAAC;AACF;","names":["resolutions","catalog","inputs"]}
@@ -7,7 +7,59 @@ import {
7
7
  depBatch
8
8
  } from "./chunk-WQIA3GFB.js";
9
9
 
10
- // src/messaging/index.ts
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
11
63
  function eventMessage(type, payload, opts) {
12
64
  assertNonEmpty(type, "eventMessage.type");
13
65
  assertNonEmpty(opts.id, "eventMessage.id");
@@ -53,6 +105,8 @@ function eventIssue(message) {
53
105
  source: "messageBus.eventMessage"
54
106
  };
55
107
  }
108
+
109
+ // src/messaging/types.ts
56
110
  var PROMPTS_TOPIC = "prompts";
57
111
  var RESPONSES_TOPIC = "responses";
58
112
  var INJECTIONS_TOPIC = "injections";
@@ -69,6 +123,8 @@ var STANDARD_TOPICS = Object.freeze([
69
123
  CONTEXT_TOPIC,
70
124
  TODOS_TOPIC
71
125
  ]);
126
+
127
+ // src/messaging/index.ts
72
128
  function messageBus(graph, opts = {}) {
73
129
  const name = opts.name ?? "messageBus";
74
130
  const initialTopics = uniqueTopics(opts.topics ?? []);
@@ -809,56 +865,6 @@ function ensureSubscription(state, opts) {
809
865
  function getSubscription(state, topic, subscriptionId) {
810
866
  return state.subscriptions.get(`${topic}\0${subscriptionId}`);
811
867
  }
812
- function pullParams(pull) {
813
- return isObjectRecord(pull?.params) ? pull.params : {};
814
- }
815
- function publishCommand(commandNode, command) {
816
- commandNode.down([["DATA", command]]);
817
- return command;
818
- }
819
- function makeTopicState() {
820
- return { closed: false, headSeq: 1, nextSeq: 1, messages: [] };
821
- }
822
- function uniqueTopics(topics) {
823
- const unique = [...new Set(topics)];
824
- if (unique.length !== topics.length) throw new Error("messageBus: duplicate topic");
825
- for (const topic of unique) assertTopicKey(topic, "messageBus");
826
- return Object.freeze(unique.sort());
827
- }
828
- function assertTopicKey(topic, owner) {
829
- const error = validateTopicKey(topic, owner);
830
- if (error !== void 0) throw new Error(error);
831
- }
832
- function validateTopicKey(topic, owner) {
833
- if (typeof topic !== "string" || topic.length === 0)
834
- return `${owner}: topic must be a non-empty string`;
835
- return void 0;
836
- }
837
- function assertNonEmpty(value, owner) {
838
- if (typeof value !== "string" || value.length === 0)
839
- throw new Error(`${owner}: must be a non-empty string`);
840
- }
841
- function positiveLimit(limit) {
842
- if (limit === void 0) return 100;
843
- if (!Number.isInteger(limit) || limit < 1)
844
- throw new Error("messageBus: limit must be a positive integer");
845
- return limit;
846
- }
847
- function isPositiveSeq(value) {
848
- return Number.isInteger(value) && value >= 1;
849
- }
850
- function isObjectRecord(value) {
851
- return typeof value === "object" && value !== null && !Array.isArray(value);
852
- }
853
- function commandTopic(command) {
854
- return isObjectRecord(command) && typeof command.topic === "string" ? command.topic : void 0;
855
- }
856
- function commandIdOf(command) {
857
- return isObjectRecord(command) && typeof command.commandId === "string" ? command.commandId : void 0;
858
- }
859
- function idempotencyKey(topic, key) {
860
- return `${topic}\0${key}`;
861
- }
862
868
 
863
869
  export {
864
870
  eventMessage,
@@ -876,4 +882,4 @@ export {
876
882
  fromTopic,
877
883
  toTopic
878
884
  };
879
- //# sourceMappingURL=chunk-QFY4AFY4.js.map
885
+ //# sourceMappingURL=chunk-PVC7WDKI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/messaging/utils.ts","../src/messaging/event-message.ts","../src/messaging/types.ts","../src/messaging/index.ts"],"sourcesContent":["import type { Node } from \"../node/node.js\";\nimport type { PullDemand } from \"../protocol/messages.js\";\nimport type { MessageBusCommand } from \"./types.js\";\n\nexport function pullParams<T>(pull: PullDemand | undefined): T {\n\treturn (isObjectRecord(pull?.params) ? pull.params : {}) as T;\n}\n\nexport function publishCommand<T extends MessageBusCommand>(\n\tcommandNode: Node<MessageBusCommand>,\n\tcommand: T,\n): T {\n\tcommandNode.down([[\"DATA\", command]]);\n\treturn command;\n}\n\nexport function makeTopicState(): {\n\tclosed: boolean;\n\theadSeq: number;\n\tnextSeq: number;\n\tmessages: [];\n} {\n\treturn { closed: false, headSeq: 1, nextSeq: 1, messages: [] };\n}\n\nexport function uniqueTopics(topics: readonly string[]): readonly string[] {\n\tconst unique = [...new Set(topics)];\n\tif (unique.length !== topics.length) throw new Error(\"messageBus: duplicate topic\");\n\tfor (const topic of unique) assertTopicKey(topic, \"messageBus\");\n\treturn Object.freeze(unique.sort());\n}\n\nexport function assertTopicKey(topic: string, owner: string): void {\n\tconst error = validateTopicKey(topic, owner);\n\tif (error !== undefined) throw new Error(error);\n}\n\nexport function validateTopicKey(topic: string, owner: string): string | undefined {\n\tif (typeof topic !== \"string\" || topic.length === 0)\n\t\treturn `${owner}: topic must be a non-empty string`;\n\treturn undefined;\n}\n\nexport function assertNonEmpty(value: string, owner: string): void {\n\tif (typeof value !== \"string\" || value.length === 0)\n\t\tthrow new Error(`${owner}: must be a non-empty string`);\n}\n\nexport function positiveLimit(limit: number | undefined): number {\n\tif (limit === undefined) return 100;\n\tif (!Number.isInteger(limit) || limit < 1)\n\t\tthrow new Error(\"messageBus: limit must be a positive integer\");\n\treturn limit;\n}\n\nexport function isPositiveSeq(value: unknown): value is number {\n\treturn Number.isInteger(value) && (value as number) >= 1;\n}\n\nexport function isObjectRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function commandTopic(command: unknown): string | undefined {\n\treturn isObjectRecord(command) && typeof command.topic === \"string\" ? command.topic : undefined;\n}\n\nexport function commandIdOf(command: unknown): string | undefined {\n\treturn isObjectRecord(command) && typeof command.commandId === \"string\"\n\t\t? command.commandId\n\t\t: undefined;\n}\n\nexport function idempotencyKey(topic: string, key: string): string {\n\treturn `${topic}\\u0000${key}`;\n}\n","import type { DataIssue } from \"../data/index.js\";\nimport type { EventMessage, EventMessageOptions } from \"./types.js\";\nimport { assertNonEmpty, isObjectRecord } from \"./utils.js\";\n\nexport function eventMessage<T>(\n\ttype: string,\n\tpayload: T,\n\topts: EventMessageOptions,\n): EventMessage<T> {\n\tassertNonEmpty(type, \"eventMessage.type\");\n\tassertNonEmpty(opts.id, \"eventMessage.id\");\n\treturn {\n\t\tid: opts.id,\n\t\ttype,\n\t\tpayload,\n\t\t...(opts.key === undefined ? {} : { key: opts.key }),\n\t\t...(opts.subjectId === undefined ? {} : { subjectId: opts.subjectId }),\n\t\t...(opts.correlationId === undefined ? {} : { correlationId: opts.correlationId }),\n\t\t...(opts.causationId === undefined ? {} : { causationId: opts.causationId }),\n\t\t...(opts.occurredAtMs === undefined ? {} : { occurredAtMs: opts.occurredAtMs }),\n\t\t...(opts.actor === undefined ? {} : { actor: opts.actor }),\n\t\t...(opts.evidenceRefs === undefined ? {} : { evidenceRefs: opts.evidenceRefs }),\n\t\t...(opts.schema === undefined ? {} : { schema: opts.schema }),\n\t\t...(opts.metadata === undefined ? {} : { metadata: opts.metadata }),\n\t};\n}\n\nexport function isEventMessage(value: unknown): value is EventMessage {\n\treturn eventMessageIssue(value) === undefined;\n}\n\nexport function eventMessageIssue(value: unknown): DataIssue | undefined {\n\tif (!isObjectRecord(value)) {\n\t\treturn eventIssue(\"event message must be an object\");\n\t}\n\tif (typeof value.id !== \"string\" || value.id.length === 0) {\n\t\treturn eventIssue(\"event message id must be a non-empty string\");\n\t}\n\tif (typeof value.type !== \"string\" || value.type.length === 0) {\n\t\treturn eventIssue(\"event message type must be a non-empty string\");\n\t}\n\tif (!(\"payload\" in value)) {\n\t\treturn eventIssue(\"event message payload field is required\");\n\t}\n\treturn undefined;\n}\n\nfunction eventIssue(message: string): DataIssue {\n\treturn {\n\t\tkind: \"issue\",\n\t\tcode: \"malformed-event-message\",\n\t\tmessage,\n\t\tseverity: \"error\",\n\t\tsource: \"messageBus.eventMessage\",\n\t};\n}\n","import type { DataIssue } from \"../data/index.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { LockId } from \"../protocol/messages.js\";\n\nexport interface MessageEnvelope<T = unknown> {\n\treadonly topic: string;\n\treadonly seq: number;\n\treadonly payload: T;\n\treadonly key?: string;\n\treadonly idempotencyKey?: string;\n\treadonly timestampMs: number;\n\treadonly commandId?: string;\n}\n\n/** Minimal JSON Schema vocabulary for passive topic payload descriptions (D125/D132). */\nexport interface JsonSchema {\n\treadonly type?:\n\t\t| \"string\"\n\t\t| \"number\"\n\t\t| \"integer\"\n\t\t| \"boolean\"\n\t\t| \"object\"\n\t\t| \"array\"\n\t\t| \"null\"\n\t\t| readonly (\"string\" | \"number\" | \"integer\" | \"boolean\" | \"object\" | \"array\" | \"null\")[];\n\treadonly properties?: Readonly<Record<string, JsonSchema>>;\n\treadonly required?: readonly string[];\n\treadonly additionalProperties?: boolean | JsonSchema;\n\treadonly items?: JsonSchema | readonly JsonSchema[];\n\treadonly enum?: readonly unknown[];\n\treadonly const?: unknown;\n\treadonly $ref?: string;\n\treadonly definitions?: Readonly<Record<string, JsonSchema>>;\n\treadonly description?: string;\n\treadonly title?: string;\n}\n\n/** Passive envelope for payloads that cross topic, agent, or graph boundaries. */\nexport interface TopicMessage<T = unknown> {\n\treadonly id: string;\n\treadonly schema?: JsonSchema;\n\treadonly expiresAt?: string;\n\treadonly correlationId?: string;\n\treadonly payload: T;\n}\n\n/** Passive domain event vocabulary for messageBus/eventFlow composition (D329). */\nexport interface EventMessage<T = unknown> {\n\treadonly id: string;\n\treadonly type: string;\n\treadonly payload: T;\n\treadonly key?: string;\n\treadonly subjectId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly occurredAtMs?: number;\n\treadonly actor?: string;\n\treadonly evidenceRefs?: readonly string[];\n\treadonly schema?: JsonSchema;\n\treadonly metadata?: Readonly<Record<string, unknown>>;\n}\n\nexport interface EventMessageOptions {\n\treadonly id: string;\n\treadonly key?: string;\n\treadonly subjectId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly occurredAtMs?: number;\n\treadonly actor?: string;\n\treadonly evidenceRefs?: readonly string[];\n\treadonly schema?: JsonSchema;\n\treadonly metadata?: Readonly<Record<string, unknown>>;\n}\n\nexport const PROMPTS_TOPIC = \"prompts\";\nexport const RESPONSES_TOPIC = \"responses\";\nexport const INJECTIONS_TOPIC = \"injections\";\nexport const DEFERRED_TOPIC = \"deferred\";\nexport const SPAWNS_TOPIC = \"spawns\";\nexport const CONTEXT_TOPIC = \"context\";\nexport const TODOS_TOPIC = \"todos\";\n\nexport const STANDARD_TOPICS = Object.freeze([\n\tPROMPTS_TOPIC,\n\tRESPONSES_TOPIC,\n\tINJECTIONS_TOPIC,\n\tDEFERRED_TOPIC,\n\tSPAWNS_TOPIC,\n\tCONTEXT_TOPIC,\n\tTODOS_TOPIC,\n] as const);\n\nexport type StandardTopic = (typeof STANDARD_TOPICS)[number];\n\nexport type MessageBusTopicPolicy = \"strict\" | \"create-as-fact\";\n\nexport interface MessageBusRetentionPolicy {\n\t/** Count retention. Trimming advances headSeq and never rewrites seq (D284). */\n\treadonly maxMessages?: number;\n}\n\nexport interface MessageBusDedupePolicy {\n\t/** Duplicate commandId emits status and never publishes a second retained message (D284). */\n\treadonly commandId?: \"status\" | \"issue\";\n}\n\nexport interface MessageBusOptions<TTopic extends string = string> {\n\treadonly topics?: readonly TTopic[];\n\treadonly name?: string;\n\treadonly now?: () => number;\n\treadonly topicPolicy?: MessageBusTopicPolicy;\n\treadonly retention?: MessageBusRetentionPolicy;\n\treadonly dedupe?: MessageBusDedupePolicy;\n}\n\nexport type MessageBusCommand<T = unknown> =\n\t| {\n\t\t\treadonly kind: \"ensure-topic\";\n\t\t\treadonly topic: string;\n\t\t\treadonly commandId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"close-topic\";\n\t\t\treadonly topic: string;\n\t\t\treadonly commandId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"publish\";\n\t\t\treadonly topic: string;\n\t\t\treadonly payload: T;\n\t\t\treadonly key?: string;\n\t\t\treadonly commandId?: string;\n\t\t\treadonly idempotencyKey?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"topic-policy\";\n\t\t\treadonly topicPolicy: MessageBusTopicPolicy;\n\t\t\treadonly commandId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"ack\";\n\t\t\treadonly topic: string;\n\t\t\treadonly subscriptionId: string;\n\t\t\treadonly seq: number;\n\t\t\treadonly commandId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"seek\";\n\t\t\treadonly topic: string;\n\t\t\treadonly subscriptionId: string;\n\t\t\treadonly nextSeq: number;\n\t\t\treadonly commandId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"close-subscription\";\n\t\t\treadonly topic: string;\n\t\t\treadonly subscriptionId: string;\n\t\t\treadonly commandId?: string;\n\t };\n\nexport type MessageBusMessage<T = unknown> = MessageEnvelope<T>;\n\nexport interface MessageBusStatus {\n\treadonly kind:\n\t\t| \"topic-created\"\n\t\t| \"topic-closed\"\n\t\t| \"message-published\"\n\t\t| \"retention-trimmed\"\n\t\t| \"duplicate-command\"\n\t\t| \"subscription-acked\"\n\t\t| \"subscription-sought\"\n\t\t| \"subscription-closed\"\n\t\t| \"command-rejected\"\n\t\t| \"projection-ready\"\n\t\t| \"projection-partial\";\n\treadonly topic?: string;\n\treadonly seq?: number;\n\treadonly headSeq?: number;\n\treadonly subscriptionId?: string;\n\treadonly nextSeq?: number;\n\treadonly commandId?: string;\n\treadonly issueCode?: string;\n\treadonly timestampMs: number;\n\treadonly details?: unknown;\n}\n\nexport interface MessageBusCatalogEntry {\n\treadonly topic: string;\n\treadonly closed: boolean;\n\treadonly headSeq: number;\n\treadonly nextSeq: number;\n\treadonly messageCount: number;\n}\n\nexport interface MessageBusCatalogPage {\n\treadonly topics: readonly MessageBusCatalogEntry[];\n\treadonly nextAfterTopic?: string;\n\treadonly hasMore: boolean;\n}\n\nexport interface MessageBusDeadLetterEntry<T = unknown> {\n\treadonly entrySeq: number;\n\treadonly topic?: string;\n\treadonly command?: MessageBusCommand<T>;\n\treadonly message?: MessageBusMessage<T>;\n\treadonly issue: DataIssue;\n\treadonly timestampMs: number;\n}\n\nexport interface MessageBusDeadLetterPage<T = unknown> {\n\treadonly entries: readonly MessageBusDeadLetterEntry<T>[];\n\treadonly nextAfterEntrySeq?: number;\n\treadonly hasMore: boolean;\n}\n\nexport interface MessageBusTopicPage<T = unknown> {\n\treadonly topic: string;\n\treadonly messages: readonly MessageBusMessage<T>[];\n\treadonly fromSeq: number;\n\treadonly throughSeq?: number;\n\treadonly nextAfterSeq?: number;\n\treadonly hasMore: boolean;\n}\n\nexport interface MessageBusCursor {\n\treadonly topic: string;\n\treadonly subscriptionId: string;\n\treadonly nextSeq: number;\n\treadonly closed: boolean;\n\treadonly retentionGap: boolean;\n\treadonly headSeq: number;\n}\n\nexport interface MessageBusAvailablePage<T = unknown> {\n\treadonly topic: string;\n\treadonly subscriptionId: string;\n\treadonly cursor: MessageBusCursor;\n\treadonly messages: readonly MessageBusMessage<T>[];\n\treadonly fromSeq: number;\n\treadonly throughSeq?: number;\n\treadonly nextAfterSeq?: number;\n\treadonly hasMore: boolean;\n}\n\nexport interface MessageBusPageParams {\n\treadonly limit?: number;\n}\n\nexport interface MessageBusCatalogParams extends MessageBusPageParams {\n\treadonly afterTopic?: string;\n\treadonly includeClosed?: boolean;\n}\n\nexport interface MessageBusDeadLetterParams extends MessageBusPageParams {\n\treadonly afterEntrySeq?: number;\n\treadonly topic?: string;\n\treadonly code?: string;\n}\n\nexport interface MessageBusTopicParams extends MessageBusPageParams {\n\treadonly afterSeq?: number;\n}\n\nexport interface MessageBusAvailableParams extends MessageBusPageParams {\n\treadonly afterSeq?: number;\n}\n\nexport interface MessageBusPullProjection<TPage> {\n\treadonly snapshot: Node<TPage>;\n\treadonly snapshotPullId: LockId;\n\treadonly status: Node<MessageBusStatus>;\n\treadonly issues: Node<DataIssue>;\n}\n\nexport interface MessageBusTopicProjection<T = unknown>\n\textends MessageBusPullProjection<MessageBusTopicPage<T>> {}\n\nexport interface MessageBusSubscription<T = unknown> {\n\treadonly available: Node<MessageBusAvailablePage<T>>;\n\treadonly availablePullId: LockId;\n\treadonly cursor: Node<MessageBusCursor>;\n\treadonly status: Node<MessageBusStatus>;\n\treadonly issues: Node<DataIssue>;\n\tack(seq: number, opts?: { commandId?: string }): MessageBusCommand;\n\tseek(nextSeq: number, opts?: { commandId?: string }): MessageBusCommand;\n\tclose(opts?: { commandId?: string }): MessageBusCommand;\n}\n\nexport interface MessageBus<TTopic extends string = string> {\n\treadonly commands: Node<MessageBusCommand>;\n\treadonly messages: Node<MessageBusMessage>;\n\treadonly status: Node<MessageBusStatus>;\n\treadonly issues: Node<DataIssue>;\n\tensureTopic(topic: TTopic | string, opts?: { commandId?: string }): MessageBusCommand;\n\tcloseTopic(topic: TTopic | string, opts?: { commandId?: string }): MessageBusCommand;\n\tpublish<T = unknown>(\n\t\ttopic: TTopic | string,\n\t\tpayload: T,\n\t\topts?: { key?: string; commandId?: string; idempotencyKey?: string },\n\t): MessageBusCommand<T>;\n\ttopic<T = unknown>(\n\t\ttopic: TTopic | string,\n\t\topts?: { name?: string },\n\t): MessageBusTopicProjection<T>;\n\tcatalog(opts?: { name?: string }): MessageBusPullProjection<MessageBusCatalogPage>;\n\tdeadLetter<T = unknown>(opts?: {\n\t\tname?: string;\n\t}): MessageBusPullProjection<MessageBusDeadLetterPage<T>>;\n\tsubscription<T = unknown>(opts: {\n\t\ttopic: TTopic | string;\n\t\tsubscriptionId: string;\n\t\tfrom?: \"earliest\" | \"latest\" | number;\n\t\tname?: string;\n\t}): MessageBusSubscription<T>;\n}\n\nexport interface ToTopicOptions {\n\treadonly name?: string;\n\treadonly keyOf?: (value: unknown) => string | undefined;\n\treadonly commandIdOf?: (value: unknown) => string | undefined;\n}\n\nexport interface ToTopicBundle<T> {\n\treadonly commands: Node<MessageBusCommand<T>>;\n\trelease(): void;\n}\n","/**\n * Reusable application-infrastructure messaging namespace.\n *\n * D279/D282/D284/D285/D276: messageBus is a retained topic-log plus independent\n * subscription-cursor substrate. DynamicHub is intentionally retired; do not add aliases.\n */\n\nimport { depBatch, type NodeFn } from \"../ctx/types.js\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.js\";\nimport {\n\tattachMessageBusCommandSource,\n\tgetMessageBusState,\n\tregisterMessageBusState,\n} from \"./internal.js\";\nimport type {\n\tMessageBusState,\n\tRuntimeEvent,\n\tSubscriptionState,\n\tTopicState,\n} from \"./runtime-types.js\";\nimport type {\n\tMessageBus,\n\tMessageBusAvailablePage,\n\tMessageBusAvailableParams,\n\tMessageBusCatalogPage,\n\tMessageBusCatalogParams,\n\tMessageBusCommand,\n\tMessageBusCursor,\n\tMessageBusDeadLetterEntry,\n\tMessageBusDeadLetterPage,\n\tMessageBusDeadLetterParams,\n\tMessageBusMessage,\n\tMessageBusOptions,\n\tMessageBusStatus,\n\tMessageBusTopicPage,\n\tMessageBusTopicParams,\n\tToTopicBundle,\n\tToTopicOptions,\n} from \"./types.js\";\nimport {\n\tassertNonEmpty,\n\tassertTopicKey,\n\tcommandIdOf,\n\tcommandTopic,\n\tidempotencyKey,\n\tisObjectRecord,\n\tisPositiveSeq,\n\tmakeTopicState,\n\tpositiveLimit,\n\tpublishCommand,\n\tpullParams,\n\tuniqueTopics,\n\tvalidateTopicKey,\n} from \"./utils.js\";\n\nexport {\n\teventMessage,\n\teventMessageIssue,\n\tisEventMessage,\n} from \"./event-message.js\";\nexport type {\n\tEventMessage,\n\tEventMessageOptions,\n\tJsonSchema,\n\tMessageBus,\n\tMessageBusAvailablePage,\n\tMessageBusAvailableParams,\n\tMessageBusCatalogEntry,\n\tMessageBusCatalogPage,\n\tMessageBusCatalogParams,\n\tMessageBusCommand,\n\tMessageBusCursor,\n\tMessageBusDeadLetterEntry,\n\tMessageBusDeadLetterPage,\n\tMessageBusDeadLetterParams,\n\tMessageBusDedupePolicy,\n\tMessageBusMessage,\n\tMessageBusOptions,\n\tMessageBusPageParams,\n\tMessageBusPullProjection,\n\tMessageBusRetentionPolicy,\n\tMessageBusStatus,\n\tMessageBusSubscription,\n\tMessageBusTopicPage,\n\tMessageBusTopicParams,\n\tMessageBusTopicPolicy,\n\tMessageBusTopicProjection,\n\tMessageEnvelope,\n\tStandardTopic,\n\tTopicMessage,\n\tToTopicBundle,\n\tToTopicOptions,\n} from \"./types.js\";\nexport {\n\tCONTEXT_TOPIC,\n\tDEFERRED_TOPIC,\n\tINJECTIONS_TOPIC,\n\tPROMPTS_TOPIC,\n\tRESPONSES_TOPIC,\n\tSPAWNS_TOPIC,\n\tSTANDARD_TOPICS,\n\tTODOS_TOPIC,\n} from \"./types.js\";\n\nexport function messageBus<TTopic extends string>(\n\tgraph: Graph,\n\topts: MessageBusOptions<TTopic> = {},\n): MessageBus<TTopic> {\n\tconst name = opts.name ?? \"messageBus\";\n\tconst initialTopics = uniqueTopics(opts.topics ?? []);\n\tconst commandSources: Node<MessageBusCommand>[] = [];\n\tconst commandBody: NodeFn = (ctx) => {\n\t\tfor (let i = 0; i < commandSources.length; i++) {\n\t\t\tfor (const command of depBatch(ctx, i) ?? []) ctx.down([[\"DATA\", command]]);\n\t\t}\n\t};\n\tconst commands = graph.node<MessageBusCommand>([], commandBody, {\n\t\tname: `${name}/commands`,\n\t\tfactory: \"messageBusCommands\",\n\t\tcompleteWhenDepsComplete: false,\n\t\terrorWhenDepsError: false,\n\t});\n\tconst state: MessageBusState = {\n\t\tgraph,\n\t\tname,\n\t\tnow: opts.now ?? Date.now,\n\t\ttopicPolicy: opts.topicPolicy ?? \"strict\",\n\t\tretention: opts.retention ?? {},\n\t\tdedupe: opts.dedupe ?? { commandId: \"status\" },\n\t\ttopics: new Map(initialTopics.map((topic) => [topic, makeTopicState()])),\n\t\tsubscriptions: new Map(),\n\t\tseenCommandIds: new Set(),\n\t\tseenIdempotencyKeys: new Set(),\n\t\tdeadLetters: [],\n\t\tdeadLetterSeq: 0,\n\t\tcommandSources,\n\t\tcommandBody,\n\t};\n\tconst runtime = graph.node<RuntimeEvent>(\n\t\t[commands],\n\t\t(ctx) => {\n\t\t\tfor (const command of depBatch(ctx, 0) ?? []) {\n\t\t\t\tfor (const event of reduceMessageBusCommand(state, command as MessageBusCommand)) {\n\t\t\t\t\tctx.down([[\"DATA\", event]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/runtime`,\n\t\t\tfactory: \"messageBusRuntime\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tgraph.retain(runtime, { reason: `${name}.messageBus.runtime` });\n\tconst messages = graph.node<MessageBusMessage>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as RuntimeEvent;\n\t\t\t\tif (typed.kind === \"message\") ctx.down([[\"DATA\", typed.message]]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/messages`,\n\t\t\tfactory: \"messageBusMessages\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst status = graph.node<MessageBusStatus>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as RuntimeEvent;\n\t\t\t\tif (typed.kind === \"status\") ctx.down([[\"DATA\", typed.status]]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/status`,\n\t\t\tfactory: \"messageBusStatus\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst issues = graph.node<DataIssue>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const event of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = event as RuntimeEvent;\n\t\t\t\tif (typed.kind === \"issue\") ctx.down([[\"DATA\", typed.issue]]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${name}/issues`,\n\t\t\tfactory: \"messageBusIssues\",\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\n\tconst bus: MessageBus<TTopic> = {\n\t\tcommands,\n\t\tmessages,\n\t\tstatus,\n\t\tissues,\n\t\tensureTopic(topic, commandOpts = {}) {\n\t\t\treturn publishCommand(commands, {\n\t\t\t\tkind: \"ensure-topic\",\n\t\t\t\ttopic,\n\t\t\t\t...(commandOpts.commandId === undefined ? {} : { commandId: commandOpts.commandId }),\n\t\t\t});\n\t\t},\n\t\tcloseTopic(topic, commandOpts = {}) {\n\t\t\treturn publishCommand(commands, {\n\t\t\t\tkind: \"close-topic\",\n\t\t\t\ttopic,\n\t\t\t\t...(commandOpts.commandId === undefined ? {} : { commandId: commandOpts.commandId }),\n\t\t\t});\n\t\t},\n\t\tpublish<T = unknown>(\n\t\t\ttopic: TTopic | string,\n\t\t\tpayload: T,\n\t\t\tpublishOpts: { key?: string; commandId?: string; idempotencyKey?: string } = {},\n\t\t) {\n\t\t\treturn publishCommand(commands, {\n\t\t\t\tkind: \"publish\",\n\t\t\t\ttopic,\n\t\t\t\tpayload,\n\t\t\t\t...(publishOpts.key === undefined ? {} : { key: publishOpts.key }),\n\t\t\t\t...(publishOpts.commandId === undefined ? {} : { commandId: publishOpts.commandId }),\n\t\t\t\t...(publishOpts.idempotencyKey === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { idempotencyKey: publishOpts.idempotencyKey }),\n\t\t\t});\n\t\t},\n\t\ttopic<T = unknown>(topic: TTopic | string, projectionOpts: { name?: string } = {}) {\n\t\t\tassertTopicKey(topic, \"messageBus.topic\");\n\t\t\tconst snapshotPullId = Symbol(`${name}/${topic}/topicSnapshot`);\n\t\t\tconst snapshot = graph.node<MessageBusTopicPage<T>>(\n\t\t\t\t[messages],\n\t\t\t\t(ctx) => {\n\t\t\t\t\tconst params = pullParams<MessageBusTopicParams>(ctx.pull);\n\t\t\t\t\tctx.down([[\"DATA\", topicPage<T>(state, topic, params)]]);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: projectionOpts.name ?? `${name}/${topic}/topic`,\n\t\t\t\t\tfactory: \"messageBusTopicProjection\",\n\t\t\t\t\tmeta: { topic },\n\t\t\t\t\tpullId: snapshotPullId,\n\t\t\t\t\tpartial: true,\n\t\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\t\terrorWhenDepsError: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { snapshot, snapshotPullId, status, issues };\n\t\t},\n\t\tcatalog(projectionOpts: { name?: string } = {}) {\n\t\t\tconst snapshotPullId = Symbol(`${name}/catalogSnapshot`);\n\t\t\tconst snapshot = graph.node<MessageBusCatalogPage>(\n\t\t\t\t[runtime],\n\t\t\t\t(ctx) => {\n\t\t\t\t\tconst params = pullParams<MessageBusCatalogParams>(ctx.pull);\n\t\t\t\t\tctx.down([[\"DATA\", catalogPage(state, params)]]);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: projectionOpts.name ?? `${name}/catalog`,\n\t\t\t\t\tfactory: \"messageBusCatalog\",\n\t\t\t\t\tpullId: snapshotPullId,\n\t\t\t\t\tpartial: true,\n\t\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\t\terrorWhenDepsError: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { snapshot, snapshotPullId, status, issues };\n\t\t},\n\t\tdeadLetter<T = unknown>(projectionOpts: { name?: string } = {}) {\n\t\t\tconst snapshotPullId = Symbol(`${name}/deadLetterSnapshot`);\n\t\t\tconst snapshot = graph.node<MessageBusDeadLetterPage<T>>(\n\t\t\t\t[runtime],\n\t\t\t\t(ctx) => {\n\t\t\t\t\tconst params = pullParams<MessageBusDeadLetterParams>(ctx.pull);\n\t\t\t\t\tctx.down([[\"DATA\", deadLetterPage<T>(state, params)]]);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: projectionOpts.name ?? `${name}/deadLetter`,\n\t\t\t\t\tfactory: \"messageBusDeadLetter\",\n\t\t\t\t\tpullId: snapshotPullId,\n\t\t\t\t\tpartial: true,\n\t\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\t\terrorWhenDepsError: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { snapshot, snapshotPullId, status, issues };\n\t\t},\n\t\tsubscription<T = unknown>(subscriptionOpts: {\n\t\t\ttopic: TTopic | string;\n\t\t\tsubscriptionId: string;\n\t\t\tfrom?: \"earliest\" | \"latest\" | number;\n\t\t\tname?: string;\n\t\t}) {\n\t\t\tassertTopicKey(subscriptionOpts.topic, \"messageBus.subscription\");\n\t\t\tassertNonEmpty(subscriptionOpts.subscriptionId, \"messageBus.subscriptionId\");\n\t\t\tconst sub = ensureSubscription(state, {\n\t\t\t\ttopic: subscriptionOpts.topic,\n\t\t\t\tsubscriptionId: subscriptionOpts.subscriptionId,\n\t\t\t\tfrom: subscriptionOpts.from ?? \"earliest\",\n\t\t\t});\n\t\t\tconst availablePullId = Symbol(\n\t\t\t\t`${name}/${subscriptionOpts.topic}/${subscriptionOpts.subscriptionId}/available`,\n\t\t\t);\n\t\t\tconst projectionName =\n\t\t\t\tsubscriptionOpts.name ??\n\t\t\t\t`${name}/${subscriptionOpts.topic}/${subscriptionOpts.subscriptionId}`;\n\t\t\tconst available = graph.node<MessageBusAvailablePage<T>>(\n\t\t\t\t[messages, status],\n\t\t\t\t(ctx) => {\n\t\t\t\t\tconst params = pullParams<MessageBusAvailableParams>(ctx.pull);\n\t\t\t\t\tctx.down([[\"DATA\", availablePage<T>(state, sub, params)]]);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: `${projectionName}/available`,\n\t\t\t\t\tfactory: \"messageBusSubscriptionAvailable\",\n\t\t\t\t\tmeta: { topic: subscriptionOpts.topic, subscriptionId: subscriptionOpts.subscriptionId },\n\t\t\t\t\tpullId: availablePullId,\n\t\t\t\t\tpartial: true,\n\t\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\t\terrorWhenDepsError: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\tconst cursor = graph.node<MessageBusCursor>(\n\t\t\t\t[status],\n\t\t\t\t(ctx) => {\n\t\t\t\t\tfor (const fact of depBatch(ctx, 0) ?? []) {\n\t\t\t\t\t\tconst typed = fact as MessageBusStatus;\n\t\t\t\t\t\tconst subscriptionMoved =\n\t\t\t\t\t\t\ttyped.topic === sub.topic &&\n\t\t\t\t\t\t\ttyped.subscriptionId === sub.subscriptionId &&\n\t\t\t\t\t\t\t(typed.kind === \"subscription-acked\" ||\n\t\t\t\t\t\t\t\ttyped.kind === \"subscription-sought\" ||\n\t\t\t\t\t\t\t\ttyped.kind === \"subscription-closed\");\n\t\t\t\t\t\tconst retentionMoved = typed.topic === sub.topic && typed.kind === \"retention-trimmed\";\n\t\t\t\t\t\tif (subscriptionMoved || retentionMoved) {\n\t\t\t\t\t\t\tctx.down([[\"DATA\", cursorSnapshot(state, sub)]]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: `${projectionName}/cursor`,\n\t\t\t\t\tfactory: \"messageBusSubscriptionCursor\",\n\t\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\t\terrorWhenDepsError: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tavailable,\n\t\t\t\tavailablePullId,\n\t\t\t\tcursor,\n\t\t\t\tstatus,\n\t\t\t\tissues,\n\t\t\t\tack(seq, commandOpts = {}) {\n\t\t\t\t\treturn publishCommand(commands, {\n\t\t\t\t\t\tkind: \"ack\",\n\t\t\t\t\t\ttopic: sub.topic,\n\t\t\t\t\t\tsubscriptionId: sub.subscriptionId,\n\t\t\t\t\t\tseq,\n\t\t\t\t\t\t...(commandOpts.commandId === undefined ? {} : { commandId: commandOpts.commandId }),\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tseek(nextSeq, commandOpts = {}) {\n\t\t\t\t\treturn publishCommand(commands, {\n\t\t\t\t\t\tkind: \"seek\",\n\t\t\t\t\t\ttopic: sub.topic,\n\t\t\t\t\t\tsubscriptionId: sub.subscriptionId,\n\t\t\t\t\t\tnextSeq,\n\t\t\t\t\t\t...(commandOpts.commandId === undefined ? {} : { commandId: commandOpts.commandId }),\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tclose(commandOpts = {}) {\n\t\t\t\t\treturn publishCommand(commands, {\n\t\t\t\t\t\tkind: \"close-subscription\",\n\t\t\t\t\t\ttopic: sub.topic,\n\t\t\t\t\t\tsubscriptionId: sub.subscriptionId,\n\t\t\t\t\t\t...(commandOpts.commandId === undefined ? {} : { commandId: commandOpts.commandId }),\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n\tregisterMessageBusState(bus, state);\n\treturn bus;\n}\n\nexport function fromTopic<T = unknown, TTopic extends string = string>(\n\tbus: MessageBus<TTopic>,\n\ttopic: TTopic | string,\n): Node<MessageBusTopicPage<T>> {\n\treturn bus.topic<T>(topic).snapshot;\n}\n\nexport function toTopic<T, TTopic extends string>(\n\tgraph: Graph,\n\tsource: Node<T>,\n\tbus: MessageBus<TTopic>,\n\ttopic: TTopic | string,\n\topts: ToTopicOptions = {},\n): ToTopicBundle<T> {\n\tconst state = getMessageBusState(bus);\n\tif (state === undefined) throw new Error(\"toTopic: unknown message bus implementation\");\n\tif (state.graph !== graph) throw new Error(\"toTopic: bus and source graph must match\");\n\tassertTopicKey(topic, \"toTopic\");\n\tconst commands = graph.node<MessageBusCommand<T>>(\n\t\t[source],\n\t\t(ctx) => {\n\t\t\tfor (const value of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst key = opts.keyOf?.(value);\n\t\t\t\tconst commandId = opts.commandIdOf?.(value);\n\t\t\t\tctx.down([\n\t\t\t\t\t[\n\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"publish\",\n\t\t\t\t\t\t\ttopic,\n\t\t\t\t\t\t\tpayload: value as T,\n\t\t\t\t\t\t\t...(key === undefined ? {} : { key }),\n\t\t\t\t\t\t\t...(commandId === undefined ? {} : { commandId }),\n\t\t\t\t\t\t} satisfies MessageBusCommand<T>,\n\t\t\t\t\t],\n\t\t\t\t]);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: opts.name ?? `${state.name}/${topic}/toTopic`,\n\t\t\tfactory: \"toTopic\",\n\t\t\tmeta: { topic },\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\tconst releaseSource = attachMessageBusCommandSource(\n\t\tgraph,\n\t\tbus,\n\t\tcommands as Node<MessageBusCommand>,\n\t);\n\tlet released = false;\n\treturn {\n\t\tcommands,\n\t\trelease() {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\treleaseSource();\n\t\t},\n\t};\n}\n\nfunction reduceMessageBusCommand(\n\tstate: MessageBusState,\n\tcommand: MessageBusCommand,\n): RuntimeEvent[] {\n\tconst malformed = validateCommand(command);\n\tif (malformed !== undefined) return rejectCommand(state, command, malformed);\n\tif (command.commandId !== undefined) {\n\t\tif (state.seenCommandIds.has(command.commandId)) {\n\t\t\treturn duplicateCommandEvents(state, command, \"duplicate commandId\");\n\t\t}\n\t\tstate.seenCommandIds.add(command.commandId);\n\t}\n\tif (\n\t\tcommand.kind === \"publish\" &&\n\t\tcommand.idempotencyKey !== undefined &&\n\t\tstate.seenIdempotencyKeys.has(idempotencyKey(command.topic, command.idempotencyKey))\n\t) {\n\t\treturn duplicateCommandEvents(state, command, \"duplicate idempotencyKey\");\n\t}\n\tswitch (command.kind) {\n\t\tcase \"ensure-topic\":\n\t\t\treturn ensureTopic(state, command.topic, command.commandId);\n\t\tcase \"close-topic\": {\n\t\t\tconst topic = state.topics.get(command.topic);\n\t\t\tif (topic === undefined) {\n\t\t\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\t\t\t}\n\t\t\ttopic.closed = true;\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tkind: \"status\",\n\t\t\t\t\tstatus: statusFact(state, \"topic-closed\", {\n\t\t\t\t\t\ttopic: command.topic,\n\t\t\t\t\t\tcommandId: command.commandId,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\tcase \"topic-policy\":\n\t\t\tstate.topicPolicy = command.topicPolicy;\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tkind: \"status\",\n\t\t\t\t\tstatus: statusFact(state, \"projection-ready\", {\n\t\t\t\t\t\tcommandId: command.commandId,\n\t\t\t\t\t\tdetails: { topicPolicy: command.topicPolicy },\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t];\n\t\tcase \"publish\":\n\t\t\treturn publishMessage(state, command);\n\t\tcase \"ack\":\n\t\t\treturn ackSubscription(state, command);\n\t\tcase \"seek\":\n\t\t\treturn seekSubscription(state, command);\n\t\tcase \"close-subscription\":\n\t\t\treturn closeSubscription(state, command);\n\t}\n}\n\nfunction publishMessage(\n\tstate: MessageBusState,\n\tcommand: Extract<MessageBusCommand, { kind: \"publish\" }>,\n): RuntimeEvent[] {\n\tlet topic = state.topics.get(command.topic);\n\tconst events: RuntimeEvent[] = [];\n\tif (topic === undefined) {\n\t\tif (state.topicPolicy !== \"create-as-fact\") {\n\t\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\t\t}\n\t\tevents.push(...ensureTopic(state, command.topic, command.commandId));\n\t\ttopic = state.topics.get(command.topic);\n\t}\n\tif (topic === undefined)\n\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\tif (topic.closed)\n\t\treturn issueEvents(state, command, \"closed-topic\", `closed topic '${command.topic}'`);\n\tconst message: MessageBusMessage = {\n\t\ttopic: command.topic,\n\t\tseq: topic.nextSeq++,\n\t\tpayload: command.payload,\n\t\ttimestampMs: state.now(),\n\t\t...(command.key === undefined ? {} : { key: command.key }),\n\t\t...(command.idempotencyKey === undefined ? {} : { idempotencyKey: command.idempotencyKey }),\n\t\t...(command.commandId === undefined ? {} : { commandId: command.commandId }),\n\t};\n\tif (command.idempotencyKey !== undefined) {\n\t\tstate.seenIdempotencyKeys.add(idempotencyKey(command.topic, command.idempotencyKey));\n\t}\n\ttopic.messages.push(message);\n\tevents.push({ kind: \"message\", message });\n\tevents.push({\n\t\tkind: \"status\",\n\t\tstatus: statusFact(state, \"message-published\", {\n\t\t\ttopic: command.topic,\n\t\t\tseq: message.seq,\n\t\t\tcommandId: command.commandId,\n\t\t}),\n\t});\n\tevents.push(...trimRetention(state, command.topic, topic));\n\treturn events;\n}\n\nfunction ensureTopic(state: MessageBusState, topic: string, commandId?: string): RuntimeEvent[] {\n\tassertTopicKey(topic, \"messageBus\");\n\tif (!state.topics.has(topic)) state.topics.set(topic, makeTopicState());\n\treturn [\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"topic-created\", { topic, commandId }),\n\t\t},\n\t];\n}\n\nfunction trimRetention(\n\tstate: MessageBusState,\n\ttopicName: string,\n\ttopic: TopicState,\n): RuntimeEvent[] {\n\tconst max = state.retention.maxMessages;\n\tif (max === undefined || topic.messages.length <= max) return [];\n\tif (!Number.isInteger(max) || max < 1) {\n\t\treturn issueEvents(\n\t\t\tstate,\n\t\t\t{ kind: \"publish\", topic: topicName, payload: undefined },\n\t\t\t\"policy-rejected\",\n\t\t\t\"retention.maxMessages must be a positive integer\",\n\t\t);\n\t}\n\tconst trimCount = topic.messages.length - max;\n\ttopic.messages.splice(0, trimCount);\n\ttopic.headSeq = topic.messages[0]?.seq ?? topic.nextSeq;\n\tconst events: RuntimeEvent[] = [\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"retention-trimmed\", {\n\t\t\t\ttopic: topicName,\n\t\t\t\theadSeq: topic.headSeq,\n\t\t\t\tdetails: { trimCount },\n\t\t\t}),\n\t\t},\n\t];\n\tfor (const sub of state.subscriptions.values()) {\n\t\tif (sub.closed || sub.topic !== topicName || sub.nextSeq >= topic.headSeq) continue;\n\t\tsub.retentionGap = true;\n\t\tevents.push(\n\t\t\t...issueEvents(\n\t\t\t\tstate,\n\t\t\t\t{\n\t\t\t\t\tkind: \"seek\",\n\t\t\t\t\ttopic: topicName,\n\t\t\t\t\tsubscriptionId: sub.subscriptionId,\n\t\t\t\t\tnextSeq: sub.nextSeq,\n\t\t\t\t},\n\t\t\t\t\"retention-gap\",\n\t\t\t\t`subscription '${sub.subscriptionId}' is before retained headSeq`,\n\t\t\t),\n\t\t);\n\t}\n\treturn events;\n}\n\nfunction ackSubscription(\n\tstate: MessageBusState,\n\tcommand: Extract<MessageBusCommand, { kind: \"ack\" }>,\n): RuntimeEvent[] {\n\tconst topic = state.topics.get(command.topic);\n\tif (topic === undefined)\n\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\tconst sub = getSubscription(state, command.topic, command.subscriptionId);\n\tif (sub === undefined)\n\t\treturn issueEvents(\n\t\t\tstate,\n\t\t\tcommand,\n\t\t\t\"unknown-subscription\",\n\t\t\t`unknown subscription '${command.subscriptionId}'`,\n\t\t);\n\tif (sub.closed)\n\t\treturn issueEvents(state, command, \"subscription-closed\", \"subscription is closed\");\n\tif (sub.retentionGap)\n\t\treturn issueEvents(state, command, \"retention-gap\", \"subscription must seek before ack\");\n\tif (command.seq < sub.nextSeq)\n\t\treturn issueEvents(state, command, \"source-cursor-stale\", \"ack is behind subscription cursor\");\n\tif (command.seq >= topic.nextSeq)\n\t\treturn issueEvents(state, command, \"cursor-out-of-range\", \"ack is beyond topic tail\");\n\tsub.nextSeq = Math.max(sub.nextSeq, command.seq + 1);\n\treturn [\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"subscription-acked\", {\n\t\t\t\ttopic: command.topic,\n\t\t\t\tsubscriptionId: command.subscriptionId,\n\t\t\t\tnextSeq: sub.nextSeq,\n\t\t\t\tcommandId: command.commandId,\n\t\t\t}),\n\t\t},\n\t];\n}\n\nfunction seekSubscription(\n\tstate: MessageBusState,\n\tcommand: Extract<MessageBusCommand, { kind: \"seek\" }>,\n): RuntimeEvent[] {\n\tconst topic = state.topics.get(command.topic);\n\tif (topic === undefined)\n\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\tconst sub = getSubscription(state, command.topic, command.subscriptionId);\n\tif (sub === undefined)\n\t\treturn issueEvents(\n\t\t\tstate,\n\t\t\tcommand,\n\t\t\t\"unknown-subscription\",\n\t\t\t`unknown subscription '${command.subscriptionId}'`,\n\t\t);\n\tif (sub.closed)\n\t\treturn issueEvents(state, command, \"subscription-closed\", \"subscription is closed\");\n\tif (command.nextSeq < topic.headSeq)\n\t\treturn issueEvents(state, command, \"retention-gap\", \"seek is before retained headSeq\");\n\tif (command.nextSeq > topic.nextSeq)\n\t\treturn issueEvents(state, command, \"cursor-out-of-range\", \"seek is beyond topic tail\");\n\tsub.nextSeq = command.nextSeq;\n\tsub.retentionGap = false;\n\treturn [\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"subscription-sought\", {\n\t\t\t\ttopic: command.topic,\n\t\t\t\tsubscriptionId: command.subscriptionId,\n\t\t\t\tnextSeq: sub.nextSeq,\n\t\t\t\tcommandId: command.commandId,\n\t\t\t}),\n\t\t},\n\t];\n}\n\nfunction closeSubscription(\n\tstate: MessageBusState,\n\tcommand: Extract<MessageBusCommand, { kind: \"close-subscription\" }>,\n): RuntimeEvent[] {\n\tif (!state.topics.has(command.topic))\n\t\treturn issueEvents(state, command, \"unknown-topic\", `unknown topic '${command.topic}'`);\n\tconst sub = getSubscription(state, command.topic, command.subscriptionId);\n\tif (sub === undefined)\n\t\treturn issueEvents(\n\t\t\tstate,\n\t\t\tcommand,\n\t\t\t\"unknown-subscription\",\n\t\t\t`unknown subscription '${command.subscriptionId}'`,\n\t\t);\n\tsub.closed = true;\n\treturn [\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"subscription-closed\", {\n\t\t\t\ttopic: command.topic,\n\t\t\t\tsubscriptionId: command.subscriptionId,\n\t\t\t\tnextSeq: sub.nextSeq,\n\t\t\t\tcommandId: command.commandId,\n\t\t\t}),\n\t\t},\n\t];\n}\n\nfunction issueEvents(\n\tstate: MessageBusState,\n\tcommand: unknown,\n\tcode: string,\n\tmessage: string,\n): RuntimeEvent[] {\n\tconst topic = commandTopic(command);\n\tconst commandId = commandIdOf(command);\n\tconst issue: DataIssue = {\n\t\tkind: \"issue\",\n\t\tcode,\n\t\tmessage,\n\t\tseverity: \"error\",\n\t\tsource: \"messageBus\",\n\t\tdetails: command,\n\t\tmetadata: topic === undefined ? undefined : { topic },\n\t};\n\tconst entry: MessageBusDeadLetterEntry = {\n\t\tentrySeq: ++state.deadLetterSeq,\n\t\t...(topic === undefined ? {} : { topic }),\n\t\t...(isObjectRecord(command) ? { command: command as MessageBusCommand } : {}),\n\t\tissue,\n\t\ttimestampMs: state.now(),\n\t};\n\tstate.deadLetters.push(entry);\n\treturn [\n\t\t{ kind: \"issue\", issue },\n\t\t{ kind: \"dead-letter\", entry },\n\t\t{\n\t\t\tkind: \"status\",\n\t\t\tstatus: statusFact(state, \"command-rejected\", {\n\t\t\t\ttopic,\n\t\t\t\tcommandId,\n\t\t\t\tissueCode: code,\n\t\t\t}),\n\t\t},\n\t];\n}\n\nfunction rejectCommand(state: MessageBusState, command: unknown, reason: string): RuntimeEvent[] {\n\treturn issueEvents(state, command, \"malformed-command\", reason);\n}\n\nfunction duplicateCommandEvents(\n\tstate: MessageBusState,\n\tcommand: MessageBusCommand,\n\tmessage: string,\n): RuntimeEvent[] {\n\tconst status = statusFact(state, \"duplicate-command\", {\n\t\ttopic: \"topic\" in command ? command.topic : undefined,\n\t\tcommandId: command.commandId,\n\t});\n\tif (state.dedupe.commandId === \"issue\") {\n\t\treturn [\n\t\t\t{ kind: \"status\", status },\n\t\t\t...issueEvents(state, command, \"duplicate-command\", message),\n\t\t];\n\t}\n\treturn [{ kind: \"status\", status }];\n}\n\nfunction statusFact(\n\tstate: MessageBusState,\n\tkind: MessageBusStatus[\"kind\"],\n\tfields: Partial<MessageBusStatus>,\n): MessageBusStatus {\n\treturn {\n\t\tkind,\n\t\ttimestampMs: state.now(),\n\t\t...(fields.topic === undefined ? {} : { topic: fields.topic }),\n\t\t...(fields.seq === undefined ? {} : { seq: fields.seq }),\n\t\t...(fields.headSeq === undefined ? {} : { headSeq: fields.headSeq }),\n\t\t...(fields.subscriptionId === undefined ? {} : { subscriptionId: fields.subscriptionId }),\n\t\t...(fields.nextSeq === undefined ? {} : { nextSeq: fields.nextSeq }),\n\t\t...(fields.commandId === undefined ? {} : { commandId: fields.commandId }),\n\t\t...(fields.issueCode === undefined ? {} : { issueCode: fields.issueCode }),\n\t\t...(fields.details === undefined ? {} : { details: fields.details }),\n\t};\n}\n\nfunction validateCommand(command: unknown): string | undefined {\n\tif (!isObjectRecord(command)) return \"command must be an object\";\n\tif (typeof command.kind !== \"string\") return \"command kind is required\";\n\tif (!isMessageBusCommandKind(command.kind)) return `unknown command kind '${command.kind}'`;\n\tif (\"topic\" in command) {\n\t\tif (typeof command.topic !== \"string\") return \"messageBus: topic must be a non-empty string\";\n\t\tconst topicError = validateTopicKey(command.topic, \"messageBus\");\n\t\tif (topicError !== undefined) return topicError;\n\t}\n\tif (\"subscriptionId\" in command && typeof command.subscriptionId !== \"string\") {\n\t\treturn \"subscriptionId must be a string\";\n\t}\n\tif (command.kind === \"publish\" && command.payload === undefined)\n\t\treturn \"publish payload is required\";\n\tif (command.kind === \"ack\" && !isPositiveSeq(command.seq))\n\t\treturn \"ack seq must be a positive integer\";\n\tif (command.kind === \"seek\" && !isPositiveSeq(command.nextSeq)) {\n\t\treturn \"seek nextSeq must be a positive integer\";\n\t}\n\tif (\n\t\tcommand.kind === \"topic-policy\" &&\n\t\tcommand.topicPolicy !== \"strict\" &&\n\t\tcommand.topicPolicy !== \"create-as-fact\"\n\t) {\n\t\treturn \"topicPolicy is not recognized\";\n\t}\n\treturn undefined;\n}\n\nfunction isMessageBusCommandKind(kind: string): kind is MessageBusCommand[\"kind\"] {\n\treturn (\n\t\tkind === \"ensure-topic\" ||\n\t\tkind === \"close-topic\" ||\n\t\tkind === \"publish\" ||\n\t\tkind === \"topic-policy\" ||\n\t\tkind === \"ack\" ||\n\t\tkind === \"seek\" ||\n\t\tkind === \"close-subscription\"\n\t);\n}\n\nfunction catalogPage(\n\tstate: MessageBusState,\n\tparams: MessageBusCatalogParams,\n): MessageBusCatalogPage {\n\tconst limit = positiveLimit(params.limit);\n\tconst topics = [...state.topics.entries()]\n\t\t.filter(\n\t\t\t([topic, value]) =>\n\t\t\t\t(params.includeClosed ? true : !value.closed) &&\n\t\t\t\t(params.afterTopic === undefined || topic > params.afterTopic),\n\t\t)\n\t\t.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n\tconst page = topics.slice(0, limit);\n\tconst hasMore = topics.length > limit;\n\treturn {\n\t\ttopics: page.map(([topic, value]) => ({\n\t\t\ttopic,\n\t\t\tclosed: value.closed,\n\t\t\theadSeq: value.headSeq,\n\t\t\tnextSeq: value.nextSeq,\n\t\t\tmessageCount: value.messages.length,\n\t\t})),\n\t\t...(hasMore && page.length > 0 ? { nextAfterTopic: page[page.length - 1]?.[0] } : {}),\n\t\thasMore,\n\t};\n}\n\nfunction topicPage<T>(\n\tstate: MessageBusState,\n\ttopicName: string,\n\tparams: MessageBusTopicParams,\n): MessageBusTopicPage<T> {\n\tconst topic = state.topics.get(topicName);\n\tconst start = params.afterSeq === undefined ? (topic?.headSeq ?? 1) : params.afterSeq + 1;\n\tconst all = (topic?.messages ?? []).filter((message) => message.seq >= start);\n\tconst limit = positiveLimit(params.limit);\n\tconst messages = all.slice(0, limit) as MessageBusMessage<T>[];\n\tconst hasMore = all.length > limit;\n\treturn {\n\t\ttopic: topicName,\n\t\tmessages,\n\t\tfromSeq: start,\n\t\t...(messages.length > 0 ? { throughSeq: messages[messages.length - 1]?.seq } : {}),\n\t\t...(hasMore && messages.length > 0 ? { nextAfterSeq: messages[messages.length - 1]?.seq } : {}),\n\t\thasMore,\n\t};\n}\n\nfunction availablePage<T>(\n\tstate: MessageBusState,\n\tsub: SubscriptionState,\n\tparams: MessageBusAvailableParams,\n): MessageBusAvailablePage<T> {\n\tconst cursor = cursorSnapshot(state, sub);\n\tconst start = params.afterSeq === undefined ? sub.nextSeq : params.afterSeq + 1;\n\tconst topic = state.topics.get(sub.topic);\n\tconst all = sub.retentionGap\n\t\t? []\n\t\t: (topic?.messages ?? []).filter((message) => message.seq >= start);\n\tconst limit = positiveLimit(params.limit);\n\tconst messages = all.slice(0, limit) as MessageBusMessage<T>[];\n\tconst hasMore = all.length > limit;\n\treturn {\n\t\ttopic: sub.topic,\n\t\tsubscriptionId: sub.subscriptionId,\n\t\tcursor,\n\t\tmessages,\n\t\tfromSeq: start,\n\t\t...(messages.length > 0 ? { throughSeq: messages[messages.length - 1]?.seq } : {}),\n\t\t...(hasMore && messages.length > 0 ? { nextAfterSeq: messages[messages.length - 1]?.seq } : {}),\n\t\thasMore,\n\t};\n}\n\nfunction deadLetterPage<T>(\n\tstate: MessageBusState,\n\tparams: MessageBusDeadLetterParams,\n): MessageBusDeadLetterPage<T> {\n\tconst limit = positiveLimit(params.limit);\n\tconst entries = state.deadLetters.filter((entry) => {\n\t\tif (params.afterEntrySeq !== undefined && entry.entrySeq <= params.afterEntrySeq) return false;\n\t\tif (params.topic !== undefined && entry.topic !== params.topic) return false;\n\t\tif (params.code !== undefined && entry.issue.code !== params.code) return false;\n\t\treturn true;\n\t});\n\tconst page = entries.slice(0, limit) as MessageBusDeadLetterEntry<T>[];\n\tconst hasMore = entries.length > limit;\n\treturn {\n\t\tentries: page,\n\t\t...(hasMore && page.length > 0 ? { nextAfterEntrySeq: page[page.length - 1]?.entrySeq } : {}),\n\t\thasMore,\n\t};\n}\n\nfunction cursorSnapshot(state: MessageBusState, sub: SubscriptionState): MessageBusCursor {\n\tconst topic = state.topics.get(sub.topic);\n\treturn {\n\t\ttopic: sub.topic,\n\t\tsubscriptionId: sub.subscriptionId,\n\t\tnextSeq: sub.nextSeq,\n\t\tclosed: sub.closed,\n\t\tretentionGap: sub.retentionGap,\n\t\theadSeq: topic?.headSeq ?? 1,\n\t};\n}\n\nfunction ensureSubscription(\n\tstate: MessageBusState,\n\topts: { topic: string; subscriptionId: string; from: \"earliest\" | \"latest\" | number },\n): SubscriptionState {\n\tconst key = `${opts.topic}\\u0000${opts.subscriptionId}`;\n\tconst existing = state.subscriptions.get(key);\n\tif (existing !== undefined) return existing;\n\tconst topic = state.topics.get(opts.topic);\n\tconst nextSeq =\n\t\topts.from === \"earliest\"\n\t\t\t? (topic?.headSeq ?? 1)\n\t\t\t: opts.from === \"latest\"\n\t\t\t\t? (topic?.nextSeq ?? 1)\n\t\t\t\t: opts.from;\n\tconst sub: SubscriptionState = {\n\t\ttopic: opts.topic,\n\t\tsubscriptionId: opts.subscriptionId,\n\t\tnextSeq,\n\t\tclosed: false,\n\t\tretentionGap: topic !== undefined && nextSeq < topic.headSeq,\n\t};\n\tstate.subscriptions.set(key, sub);\n\treturn sub;\n}\n\nfunction getSubscription(\n\tstate: MessageBusState,\n\ttopic: string,\n\tsubscriptionId: string,\n): SubscriptionState | undefined {\n\treturn state.subscriptions.get(`${topic}\\u0000${subscriptionId}`);\n}\n"],"mappings":";;;;;;;;;;AAIO,SAAS,WAAc,MAAiC;AAC9D,SAAQ,e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pB,SAAS,IAAI;AAAA,IACb,QAAQ,IAAI;AAAA,IACZ,cAAc,IAAI;AAAA,IAClB,SAAS,OAAO,WAAW;AAAA,EAC5B;AACD;AAEA,SAAS,mBACR,OACA,MACoB;AACpB,QAAM,MAAM,GAAG,KAAK,KAAK,KAAS,KAAK,cAAc;AACrD,QAAM,WAAW,MAAM,cAAc,IAAI,GAAG;AAC5C,MAAI,aAAa,OAAW,QAAO;AACnC,QAAM,QAAQ,MAAM,OAAO,IAAI,KAAK,KAAK;AACzC,QAAM,UACL,KAAK,SAAS,aACV,OAAO,WAAW,IACnB,KAAK,SAAS,WACZ,OAAO,WAAW,IACnB,KAAK;AACV,QAAM,MAAyB;AAAA,IAC9B,OAAO,KAAK;AAAA,IACZ,gBAAgB,KAAK;AAAA,IACrB;AAAA,IACA,QAAQ;AAAA,IACR,cAAc,UAAU,UAAa,UAAU,MAAM;AAAA,EACtD;AACA,QAAM,cAAc,IAAI,KAAK,GAAG;AAChC,SAAO;AACR;AAEA,SAAS,gBACR,OACA,OACA,gBACgC;AAChC,SAAO,MAAM,cAAc,IAAI,GAAG,KAAK,KAAS,cAAc,EAAE;AACjE;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  eventMessageIssue
3
- } from "./chunk-QFY4AFY4.js";
3
+ } from "./chunk-PVC7WDKI.js";
4
4
  import {
5
5
  depBatch
6
6
  } from "./chunk-WQIA3GFB.js";
@@ -365,4 +365,4 @@ export {
365
365
  eventFlow,
366
366
  eventFlowProjection
367
367
  };
368
- //# sourceMappingURL=chunk-VTHLCFN4.js.map
368
+ //# sourceMappingURL=chunk-RAHNUYA5.js.map