@graphrefly/ts 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/README.md +197 -117
  2. package/dist/actions-types-CH-XCU9O.d.cts +657 -0
  3. package/dist/actions-types-w2iPQTkv.d.ts +657 -0
  4. package/dist/adapters/index.cjs +5157 -2951
  5. package/dist/adapters/index.cjs.map +1 -1
  6. package/dist/adapters/index.d.cts +207 -70
  7. package/dist/adapters/index.d.ts +207 -70
  8. package/dist/adapters/index.js +3738 -1688
  9. package/dist/adapters/index.js.map +1 -1
  10. package/dist/adapters/nestjs/microservices.cjs +841 -0
  11. package/dist/adapters/nestjs/microservices.cjs.map +1 -0
  12. package/dist/adapters/nestjs/microservices.d.cts +45 -0
  13. package/dist/adapters/nestjs/microservices.d.ts +45 -0
  14. package/dist/adapters/nestjs/microservices.js +206 -0
  15. package/dist/adapters/nestjs/microservices.js.map +1 -0
  16. package/dist/adapters/nestjs/native.cjs +1391 -0
  17. package/dist/adapters/nestjs/native.cjs.map +1 -0
  18. package/dist/adapters/nestjs/native.d.cts +111 -0
  19. package/dist/adapters/nestjs/native.d.ts +111 -0
  20. package/dist/adapters/nestjs/native.js +577 -0
  21. package/dist/adapters/nestjs/native.js.map +1 -0
  22. package/dist/adapters/nestjs/websockets.cjs +924 -0
  23. package/dist/adapters/nestjs/websockets.cjs.map +1 -0
  24. package/dist/adapters/nestjs/websockets.d.cts +47 -0
  25. package/dist/adapters/nestjs/websockets.d.ts +47 -0
  26. package/dist/adapters/nestjs/websockets.js +286 -0
  27. package/dist/adapters/nestjs/websockets.js.map +1 -0
  28. package/dist/adapters/nestjs.cjs +1085 -0
  29. package/dist/adapters/nestjs.cjs.map +1 -0
  30. package/dist/adapters/nestjs.d.cts +385 -0
  31. package/dist/adapters/nestjs.d.ts +385 -0
  32. package/dist/adapters/nestjs.js +112 -0
  33. package/dist/adapters/nestjs.js.map +1 -0
  34. package/dist/adapters/observe-storage.d.cts +3 -3
  35. package/dist/adapters/observe-storage.d.ts +3 -3
  36. package/dist/adapters/observe-storage.js +4 -4
  37. package/dist/adapters/react.cjs.map +1 -1
  38. package/dist/adapters/react.d.cts +2 -2
  39. package/dist/adapters/react.d.ts +2 -2
  40. package/dist/adapters/react.js +1 -1
  41. package/dist/adapters/solid.cjs.map +1 -1
  42. package/dist/adapters/solid.d.cts +2 -2
  43. package/dist/adapters/solid.d.ts +2 -2
  44. package/dist/adapters/solid.js +1 -1
  45. package/dist/adapters/svelte.cjs.map +1 -1
  46. package/dist/adapters/svelte.d.cts +2 -2
  47. package/dist/adapters/svelte.d.ts +2 -2
  48. package/dist/adapters/svelte.js +1 -1
  49. package/dist/adapters/vue.cjs.map +1 -1
  50. package/dist/adapters/vue.d.cts +2 -2
  51. package/dist/adapters/vue.d.ts +2 -2
  52. package/dist/adapters/vue.js +1 -1
  53. package/dist/{agent-runtime-BesGDZcB.d.ts → agent-runtime-types-core-CKwrBDyi.d.ts} +171 -320
  54. package/dist/{agent-runtime-DZTJ3C-p.d.cts → agent-runtime-types-core-bfl4m0vM.d.cts} +171 -320
  55. package/dist/agent-runtime-types-tool-BLPV3azj.d.cts +695 -0
  56. package/dist/agent-runtime-types-tool-hwqvVqNt.d.ts +695 -0
  57. package/dist/agentic-memory-retention-CLwI76JK.d.ts +14 -0
  58. package/dist/agentic-memory-retention-Cz8GR6ie.d.cts +14 -0
  59. package/dist/{agentic-memory-DfuVZ-lY.d.cts → agentic-memory-types-JDr7MPhh.d.cts} +13 -57
  60. package/dist/{agentic-memory-BmRCvh0d.d.ts → agentic-memory-types-khYJgzKL.d.ts} +13 -57
  61. package/dist/{capability-admission-B0BzqAm5.d.cts → capability-admission-B8RNFyaZ.d.cts} +3 -3
  62. package/dist/{capability-admission-g0mn9hpq.d.ts → capability-admission-Dkw1Xz3r.d.ts} +3 -3
  63. package/dist/chunk-2KUAG2GZ.js +9693 -0
  64. package/dist/chunk-2KUAG2GZ.js.map +1 -0
  65. package/dist/{chunk-CZNV3VXM.js → chunk-3J7UPZL5.js} +11 -11
  66. package/dist/{chunk-HKK2JD7Z.js → chunk-3LYI6ADX.js} +12 -125
  67. package/dist/chunk-3LYI6ADX.js.map +1 -0
  68. package/dist/{chunk-YXMZ2N6J.js → chunk-4M37FH2I.js} +1071 -1025
  69. package/dist/chunk-4M37FH2I.js.map +1 -0
  70. package/dist/{chunk-YDSIVHRR.js → chunk-4NWSNI4K.js} +1598 -1584
  71. package/dist/chunk-4NWSNI4K.js.map +1 -0
  72. package/dist/{chunk-Z2ANQ6JW.js → chunk-4Q77MMJY.js} +2 -2
  73. package/dist/{chunk-SS2A464I.js → chunk-54WPEODM.js} +3 -3
  74. package/dist/chunk-54WPEODM.js.map +1 -0
  75. package/dist/chunk-6E76H4OU.js +132 -0
  76. package/dist/chunk-6E76H4OU.js.map +1 -0
  77. package/dist/chunk-7GOTIIQ7.js +819 -0
  78. package/dist/chunk-7GOTIIQ7.js.map +1 -0
  79. package/dist/{chunk-V7CIJE4B.js → chunk-DKFWDTVY.js} +92 -9
  80. package/dist/chunk-DKFWDTVY.js.map +1 -0
  81. package/dist/{chunk-FBUU43PM.js → chunk-E4QCH32M.js} +448 -446
  82. package/dist/chunk-E4QCH32M.js.map +1 -0
  83. package/dist/{chunk-XKXWK2KP.js → chunk-GXU6WFEJ.js} +1157 -1021
  84. package/dist/chunk-GXU6WFEJ.js.map +1 -0
  85. package/dist/{chunk-K3FXTC3I.js → chunk-HJACH5PU.js} +3 -3
  86. package/dist/{chunk-GTPCOEOZ.js → chunk-IDMLXLLG.js} +3 -3
  87. package/dist/{chunk-DKP56CSW.js → chunk-JKAYLDQV.js} +2 -2
  88. package/dist/{chunk-4VLAQHZI.js → chunk-K7FB3JTD.js} +17 -1
  89. package/dist/chunk-K7FB3JTD.js.map +1 -0
  90. package/dist/{chunk-43BKLFZU.js → chunk-KFURM6FM.js} +10 -10
  91. package/dist/{chunk-H75VXTGT.js → chunk-L6LDXRWE.js} +3 -3
  92. package/dist/{chunk-H75VXTGT.js.map → chunk-L6LDXRWE.js.map} +1 -1
  93. package/dist/chunk-MCOFHMUU.js +4131 -0
  94. package/dist/chunk-MCOFHMUU.js.map +1 -0
  95. package/dist/chunk-MQEQMS7B.js +1009 -0
  96. package/dist/chunk-MQEQMS7B.js.map +1 -0
  97. package/dist/chunk-MTELVIYR.js +1421 -0
  98. package/dist/chunk-MTELVIYR.js.map +1 -0
  99. package/dist/{chunk-3JR3EDB2.js → chunk-NNDIFUKX.js} +121 -115
  100. package/dist/chunk-NNDIFUKX.js.map +1 -0
  101. package/dist/{chunk-2747WN4Y.js → chunk-PUSRRALM.js} +3 -3
  102. package/dist/{chunk-QFY4AFY4.js → chunk-PVC7WDKI.js} +58 -52
  103. package/dist/chunk-PVC7WDKI.js.map +1 -0
  104. package/dist/{chunk-VTHLCFN4.js → chunk-RAHNUYA5.js} +2 -2
  105. package/dist/chunk-TQPCAIQI.js +612 -0
  106. package/dist/chunk-TQPCAIQI.js.map +1 -0
  107. package/dist/{chunk-IXZBUWSP.js → chunk-UEMN5URK.js} +2 -2
  108. package/dist/chunk-WOS7RJYZ.js +1320 -0
  109. package/dist/chunk-WOS7RJYZ.js.map +1 -0
  110. package/dist/{chunk-6PHB5CJS.js → chunk-ZLFRB6FI.js} +2 -2
  111. package/dist/composition/index.cjs +1228 -1076
  112. package/dist/composition/index.cjs.map +1 -1
  113. package/dist/composition/index.d.cts +3 -3
  114. package/dist/composition/index.d.ts +3 -3
  115. package/dist/composition/index.js +4 -4
  116. package/dist/core/index.cjs +1198 -1046
  117. package/dist/core/index.cjs.map +1 -1
  118. package/dist/core/index.d.cts +23 -2
  119. package/dist/core/index.d.ts +23 -2
  120. package/dist/core/index.js +2 -2
  121. package/dist/cqrs/index.d.cts +3 -3
  122. package/dist/cqrs/index.d.ts +3 -3
  123. package/dist/cqrs/messaging.d.cts +4 -4
  124. package/dist/cqrs/messaging.d.ts +4 -4
  125. package/dist/cqrs/work-queue.d.cts +5 -5
  126. package/dist/cqrs/work-queue.d.ts +5 -5
  127. package/dist/data-structures/index.cjs +1226 -1074
  128. package/dist/data-structures/index.cjs.map +1 -1
  129. package/dist/data-structures/index.d.cts +8 -7
  130. package/dist/data-structures/index.d.ts +8 -7
  131. package/dist/data-structures/index.js +6 -5
  132. package/dist/{describe-DYMw_l1C.d.cts → describe-BumQ-3_0.d.cts} +1 -1
  133. package/dist/{describe-BpyJuWkw.d.ts → describe-cYr_Z5zm.d.ts} +1 -1
  134. package/dist/executors/tool-provider-adapters.cjs +3091 -0
  135. package/dist/executors/tool-provider-adapters.cjs.map +1 -0
  136. package/dist/executors/tool-provider-adapters.d.cts +174 -0
  137. package/dist/executors/tool-provider-adapters.d.ts +174 -0
  138. package/dist/executors/tool-provider-adapters.js +1336 -0
  139. package/dist/executors/tool-provider-adapters.js.map +1 -0
  140. package/dist/executors/tool-provider-runtime.cjs +5178 -0
  141. package/dist/executors/tool-provider-runtime.cjs.map +1 -0
  142. package/dist/executors/tool-provider-runtime.d.cts +17 -0
  143. package/dist/executors/tool-provider-runtime.d.ts +17 -0
  144. package/dist/executors/tool-provider-runtime.js +15 -0
  145. package/dist/executors/tool-provider-runtime.js.map +1 -0
  146. package/dist/executors/tool-provider.cjs +6392 -0
  147. package/dist/executors/tool-provider.cjs.map +1 -0
  148. package/dist/executors/tool-provider.d.cts +60 -0
  149. package/dist/executors/tool-provider.d.ts +60 -0
  150. package/dist/executors/tool-provider.js +89 -0
  151. package/dist/executors/tool-provider.js.map +1 -0
  152. package/dist/executors/work-queue.d.cts +6 -6
  153. package/dist/executors/work-queue.d.ts +6 -6
  154. package/dist/graph/index.cjs +1499 -1341
  155. package/dist/graph/index.cjs.map +1 -1
  156. package/dist/graph/index.d.cts +9 -8
  157. package/dist/graph/index.d.ts +9 -8
  158. package/dist/graph/index.js +23 -22
  159. package/dist/{graph-DCEWh4T2.d.cts → graph-C1C-wb0L.d.cts} +266 -137
  160. package/dist/{graph-D-1-SQeC.d.ts → graph-CS0b4V9B.d.ts} +266 -137
  161. package/dist/{index-72VZC0-E.d.cts → index-DLrNopda.d.cts} +151 -10
  162. package/dist/{index-Bmxeu0nK.d.ts → index-DzJni3_6.d.ts} +151 -10
  163. package/dist/index.cjs +3397 -3140
  164. package/dist/index.cjs.map +1 -1
  165. package/dist/index.d.cts +12 -9
  166. package/dist/index.d.ts +12 -9
  167. package/dist/index.js +110 -109
  168. package/dist/inspection/boundary.d.cts +4 -4
  169. package/dist/inspection/boundary.d.ts +4 -4
  170. package/dist/measurements-BWAnochv.d.ts +294 -0
  171. package/dist/measurements-B_gJfD8h.d.cts +294 -0
  172. package/dist/messaging/index.cjs +57 -51
  173. package/dist/messaging/index.cjs.map +1 -1
  174. package/dist/messaging/index.d.cts +11 -276
  175. package/dist/messaging/index.d.ts +11 -276
  176. package/dist/messaging/index.js +1 -1
  177. package/dist/operators/index.cjs +1228 -1076
  178. package/dist/operators/index.cjs.map +1 -1
  179. package/dist/operators/index.d.cts +5 -5
  180. package/dist/operators/index.d.ts +5 -5
  181. package/dist/operators/index.js +5 -5
  182. package/dist/orchestration/index.cjs +8844 -6071
  183. package/dist/orchestration/index.cjs.map +1 -1
  184. package/dist/orchestration/index.d.cts +171 -224
  185. package/dist/orchestration/index.d.ts +171 -224
  186. package/dist/orchestration/index.js +42 -991
  187. package/dist/orchestration/index.js.map +1 -1
  188. package/dist/orchestration/messaging.d.cts +5 -8
  189. package/dist/orchestration/messaging.d.ts +5 -8
  190. package/dist/orchestration/work-queue.cjs +1243 -5
  191. package/dist/orchestration/work-queue.cjs.map +1 -1
  192. package/dist/orchestration/work-queue.d.cts +121 -10
  193. package/dist/orchestration/work-queue.d.ts +121 -10
  194. package/dist/orchestration/work-queue.js +1067 -4
  195. package/dist/orchestration/work-queue.js.map +1 -1
  196. package/dist/patterns/event-flow.cjs +6 -20
  197. package/dist/patterns/event-flow.cjs.map +1 -1
  198. package/dist/patterns/event-flow.d.cts +4 -4
  199. package/dist/patterns/event-flow.d.ts +4 -4
  200. package/dist/patterns/event-flow.js +2 -2
  201. package/dist/patterns/index.cjs +453 -465
  202. package/dist/patterns/index.cjs.map +1 -1
  203. package/dist/patterns/index.d.cts +6 -5
  204. package/dist/patterns/index.d.ts +6 -5
  205. package/dist/patterns/index.js +3 -3
  206. package/dist/process-types-BB7oRhX3.d.cts +200 -0
  207. package/dist/process-types-QNhyoYJ8.d.ts +200 -0
  208. package/dist/{reactive-collection-DNV0-gFi.d.cts → reactive-collection-BYlWvtnp.d.cts} +4 -34
  209. package/dist/{reactive-collection-BAmfrGjd.d.ts → reactive-collection-efOEdGFN.d.ts} +4 -34
  210. package/dist/{reactive-collection-storage-BNEldDyi.d.cts → reactive-collection-storage-BjoLsoiC.d.cts} +5 -5
  211. package/dist/{reactive-collection-storage-YZsAQsWK.d.ts → reactive-collection-storage-DwW6UuK_.d.ts} +5 -5
  212. package/dist/{reactive-map-DRD1LJ2H.d.cts → reactive-map-BHacbIqz.d.cts} +7 -2
  213. package/dist/{reactive-map-EsDiCmJk.d.ts → reactive-map-DN4Jyqnf.d.ts} +7 -2
  214. package/dist/render/index.d.cts +2 -2
  215. package/dist/render/index.d.ts +2 -2
  216. package/dist/scheduled-readiness-BmqXxnzX.d.ts +91 -0
  217. package/dist/scheduled-readiness-CYSw7KDE.d.cts +91 -0
  218. package/dist/semantic-memory-graph-B_LwbM-E.d.cts +30 -0
  219. package/dist/semantic-memory-graph-rsFNNhwn.d.ts +30 -0
  220. package/dist/{semantic-memory-graph-DKuNzuWw.d.cts → semantic-memory-graph-types-Y73bbwVI.d.cts} +2 -28
  221. package/dist/{semantic-memory-graph-uwbwJdhe.d.ts → semantic-memory-graph-types-safmPkuX.d.ts} +2 -28
  222. package/dist/solutions/index.cjs +6353 -6169
  223. package/dist/solutions/index.cjs.map +1 -1
  224. package/dist/solutions/index.d.cts +12 -10
  225. package/dist/solutions/index.d.ts +12 -10
  226. package/dist/solutions/index.js +5 -5
  227. package/dist/solutions/reactive-layout/browser/index.cjs +116 -108
  228. package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -1
  229. package/dist/solutions/reactive-layout/browser/index.d.cts +4 -4
  230. package/dist/solutions/reactive-layout/browser/index.d.ts +4 -4
  231. package/dist/solutions/reactive-layout/browser/index.js +3 -3
  232. package/dist/solutions/reactive-layout/index.cjs +3578 -3350
  233. package/dist/solutions/reactive-layout/index.cjs.map +1 -1
  234. package/dist/solutions/reactive-layout/index.d.cts +32 -576
  235. package/dist/solutions/reactive-layout/index.d.ts +32 -576
  236. package/dist/solutions/reactive-layout/index.js +65 -5
  237. package/dist/solutions/reactive-layout/node-canvas/index.cjs +127 -117
  238. package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -1
  239. package/dist/solutions/reactive-layout/node-canvas/index.d.cts +4 -4
  240. package/dist/solutions/reactive-layout/node-canvas/index.d.ts +4 -4
  241. package/dist/solutions/reactive-layout/node-canvas/index.js +3 -3
  242. package/dist/solutions/reactive-layout/react-native/index.cjs +127 -117
  243. package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -1
  244. package/dist/solutions/reactive-layout/react-native/index.d.cts +4 -4
  245. package/dist/solutions/reactive-layout/react-native/index.d.ts +4 -4
  246. package/dist/solutions/reactive-layout/react-native/index.js +3 -3
  247. package/dist/solutions/reactive-layout/skia/index.cjs +127 -117
  248. package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -1
  249. package/dist/solutions/reactive-layout/skia/index.d.cts +4 -4
  250. package/dist/solutions/reactive-layout/skia/index.d.ts +4 -4
  251. package/dist/solutions/reactive-layout/skia/index.js +3 -3
  252. package/dist/solutions/work-item/actions.cjs +1609 -1428
  253. package/dist/solutions/work-item/actions.cjs.map +1 -1
  254. package/dist/solutions/work-item/actions.d.cts +23 -184
  255. package/dist/solutions/work-item/actions.d.ts +23 -184
  256. package/dist/solutions/work-item/actions.js +1558 -934
  257. package/dist/solutions/work-item/actions.js.map +1 -1
  258. package/dist/solutions/work-item/scheduling.cjs +9181 -1838
  259. package/dist/solutions/work-item/scheduling.cjs.map +1 -1
  260. package/dist/solutions/work-item/scheduling.d.cts +1763 -328
  261. package/dist/solutions/work-item/scheduling.d.ts +1763 -328
  262. package/dist/solutions/work-item/scheduling.js +117 -3
  263. package/dist/solutions/work-item/work-queue.d.cts +7 -7
  264. package/dist/solutions/work-item/work-queue.d.ts +7 -7
  265. package/dist/sources/browser.cjs +1318 -1083
  266. package/dist/sources/browser.cjs.map +1 -1
  267. package/dist/sources/browser.d.cts +22 -6
  268. package/dist/sources/browser.d.ts +22 -6
  269. package/dist/sources/browser.js +4 -4
  270. package/dist/sources/browser.js.map +1 -1
  271. package/dist/sources/index.cjs +1318 -1083
  272. package/dist/sources/index.cjs.map +1 -1
  273. package/dist/sources/index.d.cts +4 -4
  274. package/dist/sources/index.d.ts +4 -4
  275. package/dist/sources/index.js +4 -4
  276. package/dist/sources/node.d.cts +3 -3
  277. package/dist/sources/node.d.ts +3 -3
  278. package/dist/storage/browser.cjs +16 -0
  279. package/dist/storage/browser.cjs.map +1 -1
  280. package/dist/storage/browser.js +3 -3
  281. package/dist/storage/index.cjs +16 -0
  282. package/dist/storage/index.cjs.map +1 -1
  283. package/dist/storage/index.d.cts +5 -4
  284. package/dist/storage/index.d.ts +5 -4
  285. package/dist/storage/index.js +6 -6
  286. package/dist/storage/node.cjs +16 -0
  287. package/dist/storage/node.cjs.map +1 -1
  288. package/dist/storage/node.js +3 -3
  289. package/dist/{store-C-joM4gh.d.ts → store-6_CHF6Ge.d.ts} +1 -1
  290. package/dist/{store-CNJwmT-h.d.cts → store-BljX8RkQ.d.cts} +1 -1
  291. package/dist/types-BAw2QVVE.d.cts +274 -0
  292. package/dist/types-BUbbbh4f.d.cts +34 -0
  293. package/dist/types-CMnzoL54.d.cts +457 -0
  294. package/dist/{types-CcPIn7sy.d.cts → types-CTN3XoMl.d.cts} +57 -108
  295. package/dist/types-CV_ohy5T.d.cts +357 -0
  296. package/dist/{types-BsJvElYZ.d.ts → types-DChxk1vK.d.ts} +57 -108
  297. package/dist/types-DRu7SnLV.d.ts +274 -0
  298. package/dist/types-DeID_FRl.d.ts +34 -0
  299. package/dist/types-IhKH0hGW.d.ts +357 -0
  300. package/dist/types-ePlD2uyT.d.ts +457 -0
  301. package/dist/{work-item-runtime-qaVgsL0T.d.cts → work-item-runtime-types-BTxLskN5.d.cts} +3 -93
  302. package/dist/{work-item-runtime-C3M79vE9.d.ts → work-item-runtime-types-DAsZbb2y.d.ts} +3 -93
  303. package/dist/work-queue/index.cjs +957 -953
  304. package/dist/work-queue/index.cjs.map +1 -1
  305. package/dist/work-queue/index.d.cts +9 -357
  306. package/dist/work-queue/index.d.ts +9 -357
  307. package/dist/work-queue/index.js +957 -953
  308. package/dist/work-queue/index.js.map +1 -1
  309. package/package.json +611 -513
  310. package/dist/chunk-3JR3EDB2.js.map +0 -1
  311. package/dist/chunk-4VLAQHZI.js.map +0 -1
  312. package/dist/chunk-6XAIOL3X.js +0 -2407
  313. package/dist/chunk-6XAIOL3X.js.map +0 -1
  314. package/dist/chunk-FBUU43PM.js.map +0 -1
  315. package/dist/chunk-HKK2JD7Z.js.map +0 -1
  316. package/dist/chunk-PC3BTTBE.js +0 -3217
  317. package/dist/chunk-PC3BTTBE.js.map +0 -1
  318. package/dist/chunk-QFY4AFY4.js.map +0 -1
  319. package/dist/chunk-SS2A464I.js.map +0 -1
  320. package/dist/chunk-V7CIJE4B.js.map +0 -1
  321. package/dist/chunk-XKXWK2KP.js.map +0 -1
  322. package/dist/chunk-YDSIVHRR.js.map +0 -1
  323. package/dist/chunk-YXMZ2N6J.js.map +0 -1
  324. /package/dist/{chunk-CZNV3VXM.js.map → chunk-3J7UPZL5.js.map} +0 -0
  325. /package/dist/{chunk-Z2ANQ6JW.js.map → chunk-4Q77MMJY.js.map} +0 -0
  326. /package/dist/{chunk-K3FXTC3I.js.map → chunk-HJACH5PU.js.map} +0 -0
  327. /package/dist/{chunk-GTPCOEOZ.js.map → chunk-IDMLXLLG.js.map} +0 -0
  328. /package/dist/{chunk-DKP56CSW.js.map → chunk-JKAYLDQV.js.map} +0 -0
  329. /package/dist/{chunk-43BKLFZU.js.map → chunk-KFURM6FM.js.map} +0 -0
  330. /package/dist/{chunk-2747WN4Y.js.map → chunk-PUSRRALM.js.map} +0 -0
  331. /package/dist/{chunk-VTHLCFN4.js.map → chunk-RAHNUYA5.js.map} +0 -0
  332. /package/dist/{chunk-IXZBUWSP.js.map → chunk-UEMN5URK.js.map} +0 -0
  333. /package/dist/{chunk-6PHB5CJS.js.map → chunk-ZLFRB6FI.js.map} +0 -0
@@ -0,0 +1,1320 @@
1
+ import {
2
+ adapterRuntimeIssue,
3
+ agentRequestStatusForExecutorOutcome,
4
+ buildToolProviderExecutorOutcome,
5
+ defaultToolProviderAdapterEvidenceRefs,
6
+ normalizeToolProviderAdapterBindings,
7
+ outcomeIssues,
8
+ runRequestIdentityIssues,
9
+ toolProviderAdapterRunProjectorInternal
10
+ } from "./chunk-7GOTIIQ7.js";
11
+ import {
12
+ boundPublicText,
13
+ canonicalPublicSourceRefs,
14
+ dataIssue,
15
+ isPlainRecord,
16
+ isRecord,
17
+ maxPublicMetadataStringChars,
18
+ publicMaterialForbiddenKeys,
19
+ ref,
20
+ sanitizeAdapterInputIssue,
21
+ sanitizeAdapterInputSourceRefs,
22
+ sanitizeGraphVisibleRecord,
23
+ sanitizeProviderGraphVisibleRecord,
24
+ stableStringHash
25
+ } from "./chunk-TQPCAIQI.js";
26
+ import {
27
+ PolicyInputs,
28
+ selectRetentionVictims,
29
+ trimHeadOverflow
30
+ } from "./chunk-6E76H4OU.js";
31
+ import {
32
+ Node
33
+ } from "./chunk-GXU6WFEJ.js";
34
+
35
+ // src/orchestration/agent-runtime-adapter-retention.ts
36
+ var RuntimeRetentionIndex = class {
37
+ items = /* @__PURE__ */ new Map();
38
+ get size() {
39
+ return this.items.size;
40
+ }
41
+ get(key) {
42
+ return this.items.get(key);
43
+ }
44
+ has(key) {
45
+ return this.items.has(key);
46
+ }
47
+ set(key, entry, value) {
48
+ const item = { key, entry, value };
49
+ this.items.set(key, item);
50
+ return item;
51
+ }
52
+ delete(key) {
53
+ const item = this.items.get(key);
54
+ if (item !== void 0) this.items.delete(key);
55
+ return item;
56
+ }
57
+ trimFifo(maxSize) {
58
+ const items = Array.from(this.items.values()).sort(
59
+ (a, b) => a.entry.sequence - b.entry.sequence
60
+ );
61
+ return trimHeadOverflow(items, { maxSize }).map((item) => this.delete(item.key)).filter((item) => item !== void 0);
62
+ }
63
+ trimScored(maxSize, score) {
64
+ const scored = [];
65
+ for (const item of this.items.values()) {
66
+ let value;
67
+ try {
68
+ value = score(item.entry);
69
+ } catch {
70
+ return { invalid: "threw" };
71
+ }
72
+ if (!Number.isFinite(value)) return { invalid: "non-finite" };
73
+ scored.push({ entry: item, score: value });
74
+ }
75
+ const victims = selectRetentionVictims(scored, { maxSize }).map(
76
+ (item) => this.delete(item.key)
77
+ );
78
+ return {
79
+ victims: victims.filter((item) => item !== void 0)
80
+ };
81
+ }
82
+ };
83
+ var toolProviderAdapterRuntimeRetentionIndexes = Object.freeze([
84
+ "adapterInputs",
85
+ "runRequests",
86
+ "executions",
87
+ "runStatuses",
88
+ "runIssues",
89
+ "retentionEvidence"
90
+ ]);
91
+ function toolProviderAdapterRuntimeRetentionIndex(value) {
92
+ return toolProviderAdapterRuntimeRetentionIndexes.find((index) => index === value);
93
+ }
94
+ function isNodeOpt(value) {
95
+ return value instanceof Node;
96
+ }
97
+ function retentionIndexSourceRef(index) {
98
+ return { kind: "tool-provider-adapter-runtime-retention-index", id: index };
99
+ }
100
+ function runtimeEvidenceSourceRefs(index, refs = []) {
101
+ return canonicalPublicSourceRefs([...refs, retentionIndexSourceRef(index)]);
102
+ }
103
+ function runtimeEvidenceMetadata(index, opts = {}) {
104
+ return {
105
+ index,
106
+ ...opts.key === void 0 ? {} : { key: runtimeDiagnosticKey(opts.key) },
107
+ ...opts.extra ?? {}
108
+ };
109
+ }
110
+ function runtimeDiagnosticKey(key) {
111
+ return `key:${stableStringHash(key)}:${key.length}`;
112
+ }
113
+ var maxRuntimeRetentionScorerStringChars = 256;
114
+ function runtimeRetentionScorerEntry(index, entry) {
115
+ if (!isPlainRecord(entry) || publicMaterialForbiddenKeys(entry, "provider").length > 0) {
116
+ throw new TypeError(`unsafe ${index} retention scorer entry`);
117
+ }
118
+ const bounded = {};
119
+ for (const value of Object.values(entry)) {
120
+ if (value !== void 0 && typeof value !== "string" && typeof value !== "number") {
121
+ throw new TypeError(`unsafe ${index} retention scorer entry`);
122
+ }
123
+ }
124
+ for (const [key, value] of Object.entries(entry)) {
125
+ bounded[key] = key === "key" && typeof value === "string" ? runtimeDiagnosticKey(value) : typeof value === "string" && value.length > maxRuntimeRetentionScorerStringChars ? `bounded:${stableStringHash(value)}:${value.length}` : value;
126
+ }
127
+ return Object.freeze(bounded);
128
+ }
129
+ function retentionPolicyMaxSize(policy) {
130
+ return policy?.maxSize;
131
+ }
132
+ function retentionPolicyMode(policy) {
133
+ if (policy === void 0) return void 0;
134
+ return "score" in policy && policy.score !== void 0 ? "score" : "fifo";
135
+ }
136
+ function buildRetentionPolicyReaders(graph, name, retention) {
137
+ const inputs = new PolicyInputs();
138
+ const readers = /* @__PURE__ */ new Map();
139
+ const statics = /* @__PURE__ */ new Map();
140
+ for (const index of toolProviderAdapterRuntimeRetentionIndexes) {
141
+ const policy = retention?.[index];
142
+ const maxSize = retentionPolicyMaxSize(policy);
143
+ if (maxSize === void 0) {
144
+ statics.set(index, void 0);
145
+ readers.set(index, inputs.add(void 0));
146
+ continue;
147
+ }
148
+ const node = isNodeOpt(maxSize) ? maxSize : graph.node([], null, {
149
+ name: `${name}/retentionPolicy/${index}/maxSize`,
150
+ factory: "toolProviderAdapterRuntimeRetentionPolicy.maxSize",
151
+ initial: maxSize
152
+ });
153
+ if (!isNodeOpt(maxSize)) statics.set(index, maxSize);
154
+ readers.set(index, inputs.add(node));
155
+ }
156
+ return { inputs, readers, statics };
157
+ }
158
+ function readRetentionPolicyFact(ctx, retention, readers, current) {
159
+ const policies = /* @__PURE__ */ new Map();
160
+ const issues = [];
161
+ for (const index of toolProviderAdapterRuntimeRetentionIndexes) {
162
+ const raw = retention?.[index];
163
+ if (raw === void 0) continue;
164
+ const reader = readers.readers.get(index);
165
+ const previous = current?.policies.get(index)?.maxSize ?? readers.statics.get(index);
166
+ const maxSize = reader?.read(ctx, previous);
167
+ const issue = validateRuntimeRetentionPolicy(index, raw, maxSize);
168
+ if (issue !== void 0) {
169
+ issues.push(issue);
170
+ continue;
171
+ }
172
+ policies.set(index, {
173
+ maxSize,
174
+ mode: retentionPolicyMode(raw) ?? "fifo"
175
+ });
176
+ }
177
+ return {
178
+ kind: "tool-provider-adapter-runtime-retention-policy",
179
+ policies,
180
+ ...issues.length === 0 ? {} : { issues: Object.freeze(issues) }
181
+ };
182
+ }
183
+ function validateRuntimeRetentionPolicy(index, policy, maxSize) {
184
+ if ("score" in policy && policy.score !== void 0 && typeof policy.score !== "function")
185
+ return invalidRetentionPolicyIssue(index, "score must be a function");
186
+ if (!("score" in policy) || policy.score === void 0) {
187
+ const order = policy.order ?? "fifo";
188
+ if (order !== "fifo") return invalidRetentionPolicyIssue(index, "order must be fifo");
189
+ }
190
+ if (maxSize === void 0 || !Number.isSafeInteger(maxSize) || maxSize < 1)
191
+ return invalidRetentionPolicyIssue(index, "maxSize must be a safe integer >= 1");
192
+ return void 0;
193
+ }
194
+ function invalidRetentionPolicyIssue(index, reason) {
195
+ return dataIssue(
196
+ "tool-provider-adapter-runtime-invalid-retention-policy",
197
+ "Tool provider adapter runtime retention policy is invalid; last-known-good policy remains active.",
198
+ {
199
+ subjectId: index,
200
+ refs: [retentionIndexSourceRef(index)],
201
+ details: { index, reason },
202
+ severity: "warning"
203
+ }
204
+ );
205
+ }
206
+ function adapterInputRetentionEntry(key, sequence, input, insertedAtMs) {
207
+ return Object.freeze({
208
+ key,
209
+ sequence,
210
+ ...insertedAtMs === void 0 ? {} : { insertedAtMs },
211
+ adapterInputId: input.adapterInputId,
212
+ requestId: input.requestId,
213
+ operationId: input.operationId,
214
+ ...input.routeId === void 0 ? {} : { routeId: input.routeId },
215
+ ...input.providerId === void 0 ? {} : { providerId: input.providerId },
216
+ ...input.executorId === void 0 ? {} : { executorId: input.executorId },
217
+ ...input.profileId === void 0 ? {} : { profileId: input.profileId },
218
+ status: input.status
219
+ });
220
+ }
221
+ function runRequestRetentionEntry(key, sequence, request) {
222
+ return Object.freeze({
223
+ key,
224
+ sequence,
225
+ ...request.requestedAtMs === void 0 ? {} : { requestedAtMs: request.requestedAtMs },
226
+ adapterInputId: request.adapterInputId,
227
+ runId: request.runId,
228
+ attempt: request.attempt,
229
+ requestId: request.requestId,
230
+ operationId: request.operationId,
231
+ ...request.routeId === void 0 ? {} : { routeId: request.routeId },
232
+ ...request.providerId === void 0 ? {} : { providerId: request.providerId },
233
+ ...request.executorId === void 0 ? {} : { executorId: request.executorId },
234
+ ...request.profileId === void 0 ? {} : { profileId: request.profileId },
235
+ reason: request.reason
236
+ });
237
+ }
238
+ function executionRetentionEntry(key, sequence, request, status, occurredAtMs, outcomeId) {
239
+ return Object.freeze({
240
+ key,
241
+ sequence,
242
+ ...occurredAtMs === void 0 ? {} : { occurredAtMs },
243
+ adapterInputId: request.adapterInputId,
244
+ runId: request.runId,
245
+ attempt: request.attempt,
246
+ requestId: request.requestId,
247
+ operationId: request.operationId,
248
+ ...request.routeId === void 0 ? {} : { routeId: request.routeId },
249
+ ...request.providerId === void 0 ? {} : { providerId: request.providerId },
250
+ ...request.executorId === void 0 ? {} : { executorId: request.executorId },
251
+ ...request.profileId === void 0 ? {} : { profileId: request.profileId },
252
+ ...outcomeId === void 0 ? {} : { outcomeId },
253
+ status,
254
+ reason: request.reason
255
+ });
256
+ }
257
+ function runStatusRetentionEntry(key, sequence, status, occurredAtMs) {
258
+ const issueCode = status.issues?.[0]?.code;
259
+ return Object.freeze({
260
+ key,
261
+ sequence,
262
+ ...occurredAtMs === void 0 ? {} : { occurredAtMs },
263
+ adapterInputId: status.adapterInputId,
264
+ runId: status.runId,
265
+ ...status.attempt === void 0 ? {} : { attempt: status.attempt },
266
+ ...status.requestId === void 0 ? {} : { requestId: status.requestId },
267
+ ...status.operationId === void 0 ? {} : { operationId: status.operationId },
268
+ status: status.status,
269
+ ...status.outcomeId === void 0 ? {} : { outcomeId: status.outcomeId },
270
+ ...issueCode === void 0 ? {} : { issueCode }
271
+ });
272
+ }
273
+ function runIssueRetentionEntry(key, sequence, issue, occurredAtMs, context = {}) {
274
+ return Object.freeze({
275
+ key,
276
+ sequence,
277
+ ...occurredAtMs === void 0 ? {} : { occurredAtMs },
278
+ ...context.adapterInputId === void 0 ? {} : { adapterInputId: context.adapterInputId },
279
+ ...context.runId === void 0 ? {} : { runId: context.runId },
280
+ ...context.attempt === void 0 ? {} : { attempt: context.attempt },
281
+ ...context.requestId === void 0 ? {} : { requestId: context.requestId },
282
+ ...context.operationId === void 0 ? {} : { operationId: context.operationId },
283
+ issueCode: issue.code,
284
+ ...issue.severity === void 0 ? {} : { severity: issue.severity },
285
+ ...issue.subjectId === void 0 ? {} : { subjectId: issue.subjectId }
286
+ });
287
+ }
288
+ function retentionEvidenceEntry(key, sequence, opts) {
289
+ return Object.freeze({
290
+ key,
291
+ sequence,
292
+ ...opts.occurredAtMs === void 0 ? {} : { occurredAtMs: opts.occurredAtMs },
293
+ adapterInputId: opts.adapterInputId,
294
+ evidenceKind: opts.evidenceKind,
295
+ ...opts.attemptHighWater === void 0 ? {} : { attemptHighWater: opts.attemptHighWater },
296
+ reason: opts.reason
297
+ });
298
+ }
299
+
300
+ // src/orchestration/agent-runtime-adapter-runtime-execute.ts
301
+ function runAdapterRuntimeRequest(ctx, request) {
302
+ if (ctx.isDisposed()) return;
303
+ const input = ctx.adapterInputs.get(request.adapterInputId)?.value;
304
+ if (input === void 0) {
305
+ const missingInputClassification = ctx.classifyRunRequestReplayEvidence(request);
306
+ ctx.publishReplayClassification(request, missingInputClassification);
307
+ return;
308
+ }
309
+ if (input.status !== "ready") {
310
+ const issue = dataIssue(
311
+ "tool-provider-adapter-runtime-input-not-ready",
312
+ "Tool provider adapter runtime requires a ready adapter input.",
313
+ {
314
+ subjectId: input.requestId,
315
+ refs: [ref("tool-provider-adapter-input", input.adapterInputId)],
316
+ details: { status: input.status }
317
+ }
318
+ );
319
+ ctx.publishIssue(issue);
320
+ ctx.publishRunStatus(request, "stale-request", [issue]);
321
+ ctx.publishStatus(input, "blocked", [issue]);
322
+ return;
323
+ }
324
+ const requestIssues = runRequestIdentityIssues(request, input);
325
+ if (requestIssues.length > 0) {
326
+ for (const issue of requestIssues) ctx.publishIssue(issue);
327
+ ctx.publishRunStatus(request, "mismatched-request", requestIssues);
328
+ ctx.publishStatus(input, "blocked", requestIssues);
329
+ ctx.publishAudit(input, "tool-provider-adapter-runtime-run-request-rejected", {
330
+ runId: request.runId,
331
+ attempt: request.attempt,
332
+ issueCodes: requestIssues.map((issue) => issue.code)
333
+ });
334
+ return;
335
+ }
336
+ if (ctx.executions.has(ctx.executionCoordinate(request))) {
337
+ ctx.startExecutionProof(request);
338
+ return;
339
+ }
340
+ const classification = ctx.classifyRunRequestReplayEvidence(request, input);
341
+ if (ctx.publishReplayClassification(request, classification)) return;
342
+ if (!ctx.startExecutionProof(request)) return;
343
+ const binding = input.providerId === void 0 ? void 0 : ctx.bindings.get(input.providerId);
344
+ if (binding === void 0) {
345
+ const issue = dataIssue(
346
+ "tool-provider-adapter-runtime-missing-binding",
347
+ "Tool provider adapter runtime requires a matching runtime-private binding.",
348
+ {
349
+ subjectId: input.requestId,
350
+ refs: [ref("tool-provider-adapter-input", input.adapterInputId)],
351
+ details: { providerId: input.providerId }
352
+ }
353
+ );
354
+ ctx.publishOutcome(
355
+ input,
356
+ {
357
+ kind: "blocked",
358
+ needs: [
359
+ {
360
+ kind: "tool-provider-binding",
361
+ message: "Matching runtime-private tool provider binding is unavailable.",
362
+ ...input.providerId === void 0 ? {} : { refs: [ref("tool-provider", input.providerId)] }
363
+ }
364
+ ],
365
+ issues: [issue]
366
+ },
367
+ request
368
+ );
369
+ return;
370
+ }
371
+ ctx.publishRunStatus(request, "started");
372
+ ctx.publishStatus(input, "in-flight");
373
+ ctx.publishAudit(input, "tool-provider-adapter-runtime-started", {
374
+ providerId: binding.providerId,
375
+ runId: request.runId,
376
+ attempt: request.attempt,
377
+ reason: request.reason
378
+ });
379
+ let result;
380
+ try {
381
+ result = binding.run(input, {
382
+ runId: request.runId,
383
+ attempt: request.attempt,
384
+ reason: request.reason,
385
+ sourceRefs: request.sourceRefs ?? input.sourceRefs ?? [],
386
+ now: ctx.now
387
+ });
388
+ } catch (error) {
389
+ ctx.publishRuntimeFailure(input, request, "tool-provider-adapter-runtime-threw", error);
390
+ return;
391
+ }
392
+ if (isThenableResult(result)) {
393
+ ctx.publishRuntimeFailure(
394
+ input,
395
+ request,
396
+ "tool-provider-adapter-runtime-async-result-unsupported",
397
+ new Error("Tool provider adapter runtime bindings must return synchronously.")
398
+ );
399
+ return;
400
+ }
401
+ ctx.publishOutcome(input, result, request);
402
+ }
403
+ function isThenableResult(value) {
404
+ if (value === null || typeof value !== "object" && typeof value !== "function") return false;
405
+ try {
406
+ return typeof value.then === "function";
407
+ } catch {
408
+ return true;
409
+ }
410
+ }
411
+
412
+ // src/orchestration/agent-runtime-adapter-runtime-retention-gaps.ts
413
+ function retentionGapIssueCode(gapKind) {
414
+ switch (gapKind) {
415
+ case "evidence-horizon":
416
+ return "tool-provider-adapter-runtime-retention-evidence-gap";
417
+ case "evidence-horizon-closed":
418
+ return "tool-provider-adapter-runtime-retention-evidence-horizon-closed";
419
+ case "adapter-input-trimmed":
420
+ case "execution-proof-trimmed":
421
+ return "tool-provider-adapter-runtime-retention-gap";
422
+ }
423
+ }
424
+ function retentionGapMessage(gapKind) {
425
+ switch (gapKind) {
426
+ case "evidence-horizon":
427
+ return "Tool provider adapter runtime retention evidence horizon no longer proves this request is fresh.";
428
+ case "evidence-horizon-closed":
429
+ return "Tool provider adapter runtime retention evidence horizon is closed; this request must fail closed.";
430
+ case "adapter-input-trimmed":
431
+ return "Tool provider adapter runtime retention removed the requested adapter input proof.";
432
+ case "execution-proof-trimmed":
433
+ return "Tool provider adapter runtime retention removed execution proof needed to safely replay this request.";
434
+ }
435
+ }
436
+ function retentionGapEvidenceKind(gapKind) {
437
+ switch (gapKind) {
438
+ case "adapter-input-trimmed":
439
+ return "adapter-input-trimmed";
440
+ case "execution-proof-trimmed":
441
+ return "execution-high-water";
442
+ case "evidence-horizon":
443
+ case "evidence-horizon-closed":
444
+ return void 0;
445
+ }
446
+ }
447
+ function publishAdapterRuntimeRetentionGap(ctx, request, classification) {
448
+ const { index, gapKind } = classification;
449
+ const key = classification.key ?? request.adapterInputId;
450
+ const issueCode = retentionGapIssueCode(gapKind);
451
+ const evidenceKind = retentionGapEvidenceKind(gapKind);
452
+ const sourceRefs = runtimeEvidenceSourceRefs(index, [
453
+ ref("tool-provider-adapter-run", request.runId),
454
+ ref("tool-provider-adapter-input", request.adapterInputId)
455
+ ]);
456
+ const metadata = runtimeEvidenceMetadata(index, {
457
+ key,
458
+ extra: {
459
+ gapKind,
460
+ ...evidenceKind === void 0 ? {} : { evidenceKind }
461
+ }
462
+ });
463
+ const issue = dataIssue(issueCode, retentionGapMessage(gapKind), {
464
+ subjectId: request.adapterInputId,
465
+ refs: sourceRefs,
466
+ details: {
467
+ index,
468
+ adapterInputId: request.adapterInputId,
469
+ runId: request.runId,
470
+ attempt: request.attempt,
471
+ issueCode,
472
+ gapKind,
473
+ key: runtimeDiagnosticKey(key),
474
+ ...evidenceKind === void 0 ? {} : { evidenceKind }
475
+ }
476
+ });
477
+ ctx.publishIssue(issue);
478
+ ctx.publishRunStatus(request, "retention-gap", [issue]);
479
+ ctx.publishRuntimeStatus({
480
+ status: "retention-gap",
481
+ index,
482
+ key,
483
+ adapterInputId: request.adapterInputId,
484
+ runId: request.runId,
485
+ attempt: request.attempt,
486
+ issueCode: issue.code,
487
+ sourceRefs,
488
+ metadata
489
+ });
490
+ ctx.publishRuntimeAudit("tool-provider-adapter-runtime-retention-gap", {
491
+ subjectId: request.adapterInputId,
492
+ sourceRefs,
493
+ issueCode: issue.code,
494
+ metadata
495
+ });
496
+ }
497
+ function publishAdapterRuntimeRetentionEvidenceGlobalFailClosed(ctx, victim) {
498
+ const sourceRefs = runtimeEvidenceSourceRefs("retentionEvidence");
499
+ const metadata = runtimeEvidenceMetadata("retentionEvidence", {
500
+ key: victim.key,
501
+ extra: {
502
+ evidenceKind: victim.value.evidenceKind,
503
+ gapKind: "evidence-horizon-closed"
504
+ }
505
+ });
506
+ const issue = dataIssue(
507
+ "tool-provider-adapter-runtime-retention-evidence-horizon-closed",
508
+ "Tool provider adapter runtime retention evidence closed-marker horizon overflowed; future requests fail closed until runtime reset.",
509
+ {
510
+ subjectId: victim.value.adapterInputId,
511
+ refs: sourceRefs,
512
+ details: {
513
+ index: "retentionEvidence",
514
+ key: runtimeDiagnosticKey(victim.key),
515
+ gapKind: "evidence-horizon-closed"
516
+ }
517
+ }
518
+ );
519
+ ctx.publishIssue(issue, false);
520
+ ctx.publishRuntimeStatus({
521
+ status: "retention-gap",
522
+ index: "retentionEvidence",
523
+ key: victim.key,
524
+ adapterInputId: victim.value.adapterInputId,
525
+ ...victim.value.attemptHighWater === void 0 ? {} : { attempt: victim.value.attemptHighWater },
526
+ issueCode: issue.code,
527
+ sourceRefs,
528
+ metadata
529
+ });
530
+ ctx.publishRuntimeAudit("tool-provider-adapter-runtime-retention-evidence-horizon-closed", {
531
+ subjectId: victim.value.adapterInputId,
532
+ sourceRefs,
533
+ issueCode: issue.code,
534
+ metadata
535
+ });
536
+ }
537
+
538
+ // src/orchestration/agent-runtime-adapter-runtime-state.ts
539
+ function createAdapterRuntimeRetentionIndexes() {
540
+ return {
541
+ adapterInputs: new RuntimeRetentionIndex(),
542
+ runRequests: new RuntimeRetentionIndex(),
543
+ executions: new RuntimeRetentionIndex(),
544
+ runStatuses: new RuntimeRetentionIndex(),
545
+ runIssues: new RuntimeRetentionIndex(),
546
+ retentionEvidence: new RuntimeRetentionIndex(),
547
+ closedRetentionEvidence: new RuntimeRetentionIndex()
548
+ };
549
+ }
550
+ function createAdapterRuntimeOutputNodes(graph, name) {
551
+ return {
552
+ outcomes: graph.node([], null, {
553
+ name: `${name}/outcomes`,
554
+ factory: "toolProviderAdapterRuntimeOutcomes"
555
+ }),
556
+ runStatus: graph.node([], null, {
557
+ name: `${name}/runStatus`,
558
+ factory: "toolProviderAdapterRuntimeRunStatus"
559
+ }),
560
+ status: graph.node([], null, {
561
+ name: `${name}/status`,
562
+ factory: "toolProviderAdapterRuntimeStatus"
563
+ }),
564
+ runtimeStatus: graph.node([], null, {
565
+ name: `${name}/runtimeStatus`,
566
+ factory: "toolProviderAdapterRuntimeStatus"
567
+ }),
568
+ issues: graph.node([], null, {
569
+ name: `${name}/issues`,
570
+ factory: "toolProviderAdapterRuntimeIssues"
571
+ }),
572
+ audit: graph.node([], null, {
573
+ name: `${name}/audit`,
574
+ factory: "toolProviderAdapterRuntimeAudit"
575
+ })
576
+ };
577
+ }
578
+
579
+ // src/orchestration/agent-runtime-adapter-runtime.ts
580
+ function attachToolProviderAdapterRuntime(graph, opts) {
581
+ const name = opts.name ?? "toolProviderAdapterRuntime";
582
+ const bindings = normalizeToolProviderAdapterBindings(opts.bindings);
583
+ const retentionReaders = buildRetentionPolicyReaders(graph, name, opts.retention);
584
+ const retentionPolicy = graph.node(
585
+ retentionReaders.inputs.deps,
586
+ (ctx) => {
587
+ const current = ctx.state.get();
588
+ const fact = readRetentionPolicyFact(ctx, opts.retention, retentionReaders, current);
589
+ ctx.state.set(fact);
590
+ ctx.down([["DATA", fact]]);
591
+ },
592
+ {
593
+ name: `${name}/retentionPolicy`,
594
+ factory: "toolProviderAdapterRuntimeRetentionPolicy",
595
+ partial: true
596
+ }
597
+ );
598
+ const {
599
+ adapterInputs,
600
+ runRequests,
601
+ executions,
602
+ runStatuses,
603
+ runIssues,
604
+ retentionEvidence,
605
+ closedRetentionEvidence
606
+ } = createAdapterRuntimeRetentionIndexes();
607
+ const executionHighWaterByInput = /* @__PURE__ */ new Map();
608
+ const trimmedAdapterInputIds = /* @__PURE__ */ new Set();
609
+ const projectorInputDropById = /* @__PURE__ */ new Map();
610
+ let retentionEvidenceHorizonExceeded = false;
611
+ const { outcomes, runStatus, status, runtimeStatus, issues, audit } = createAdapterRuntimeOutputNodes(graph, name);
612
+ let disposed = false;
613
+ let auditSeq = 0;
614
+ let retentionSeq = 0;
615
+ let effectiveRetention = {};
616
+ function nowMs() {
617
+ return opts.now?.();
618
+ }
619
+ function nextRetentionSequence() {
620
+ retentionSeq += 1;
621
+ return retentionSeq;
622
+ }
623
+ function publishRuntimeStatus(fact) {
624
+ const occurredAtMs = nowMs();
625
+ const { sourceRefs: rawSourceRefs, metadata: rawMetadata, key: rawKey, ...statusFields } = fact;
626
+ const sourceRefs = rawSourceRefs === void 0 ? void 0 : sanitizeAdapterInputSourceRefs(rawSourceRefs);
627
+ const metadata = sanitizeProviderGraphVisibleRecord(rawMetadata, opts.publicText);
628
+ const key = rawKey === void 0 ? void 0 : boundPublicText(
629
+ runtimeDiagnosticKey(rawKey),
630
+ maxPublicMetadataStringChars(opts.publicText)
631
+ ).text;
632
+ runtimeStatus.down([
633
+ [
634
+ "DATA",
635
+ {
636
+ kind: "tool-provider-adapter-runtime-status",
637
+ ...occurredAtMs === void 0 ? {} : { occurredAtMs },
638
+ ...statusFields,
639
+ ...key === void 0 ? {} : { key },
640
+ ...sourceRefs === void 0 ? {} : { sourceRefs },
641
+ ...metadata === void 0 ? {} : { metadata }
642
+ }
643
+ ]
644
+ ]);
645
+ }
646
+ function publishRuntimeAudit(kind, auditOpts = {}) {
647
+ auditSeq += 1;
648
+ const metadata = sanitizeProviderGraphVisibleRecord(auditOpts.metadata, opts.publicText);
649
+ audit.down([
650
+ [
651
+ "DATA",
652
+ {
653
+ id: `${name}:audit:${auditSeq}`,
654
+ kind,
655
+ ...auditOpts.subjectId === void 0 ? {} : { subjectId: auditOpts.subjectId },
656
+ ...auditOpts.sourceRefs === void 0 ? {} : { sourceRefs: sanitizeAdapterInputSourceRefs(auditOpts.sourceRefs) },
657
+ ...auditOpts.issueCode === void 0 ? {} : { issueCode: auditOpts.issueCode },
658
+ ...metadata === void 0 ? {} : { metadata }
659
+ }
660
+ ]
661
+ ]);
662
+ }
663
+ function trackRunIssue(issue, emittedKey, dropKey) {
664
+ const sequence = nextRetentionSequence();
665
+ const key = emittedKey ?? `${sequence}:${issue.code}:${issue.subjectId ?? ""}`;
666
+ runIssues.set(key, runIssueRetentionEntry(key, sequence, issue, nowMs()), {
667
+ fact: issue,
668
+ dropKey
669
+ });
670
+ trimRunIssues();
671
+ }
672
+ function publishIssue(issue, track = true) {
673
+ issues.down([["DATA", sanitizeAdapterInputIssue(issue)]]);
674
+ if (track) trackRunIssue(issue);
675
+ }
676
+ function publishRunStatus(request, nextStatus, statusIssues, outcomeId) {
677
+ const statusFact = {
678
+ kind: "tool-provider-adapter-run-status",
679
+ runId: request.runId,
680
+ adapterInputId: request.adapterInputId,
681
+ requestId: request.requestId,
682
+ operationId: request.operationId,
683
+ status: nextStatus,
684
+ attempt: request.attempt,
685
+ outcomeId,
686
+ issues: statusIssues,
687
+ sourceRefs: sanitizeAdapterInputSourceRefs(request.sourceRefs ?? []),
688
+ metadata: sanitizeGraphVisibleRecord(
689
+ {
690
+ providerId: request.providerId,
691
+ routeId: request.routeId,
692
+ reason: request.reason
693
+ },
694
+ opts.publicText
695
+ )
696
+ };
697
+ runStatus.down([["DATA", statusFact]]);
698
+ trackRunStatus(statusFact);
699
+ }
700
+ function trackRunStatus(statusFact, emittedKey, dropKey) {
701
+ const sequence = nextRetentionSequence();
702
+ const key = emittedKey ?? `${sequence}:${statusFact.runId}:${statusFact.status}`;
703
+ runStatuses.set(key, runStatusRetentionEntry(key, sequence, statusFact, nowMs()), {
704
+ fact: statusFact,
705
+ dropKey
706
+ });
707
+ trimRunStatuses();
708
+ }
709
+ function retentionScore(index) {
710
+ const policy = opts.retention?.[index];
711
+ return typeof policy?.score === "function" ? policy.score : void 0;
712
+ }
713
+ function trimRuntimeIndex(indexName, store, config, onVictim) {
714
+ if (config?.maxSize === void 0) return;
715
+ let victims;
716
+ if (config.mode === "score") {
717
+ const score = retentionScore(indexName);
718
+ if (score === void 0) return;
719
+ const selected = store.trimScored(config.maxSize, (entry) => {
720
+ return score(runtimeRetentionScorerEntry(indexName, entry));
721
+ });
722
+ if (selected.invalid !== void 0) {
723
+ publishRetentionScoreInvalid(indexName, selected.invalid);
724
+ return;
725
+ }
726
+ victims = selected.victims ?? [];
727
+ } else {
728
+ victims = store.trimFifo(config.maxSize);
729
+ }
730
+ for (const victim of victims) {
731
+ onVictim?.(victim);
732
+ publishRetentionTrimmed(indexName, victim.key, victim.entry);
733
+ }
734
+ }
735
+ function trackAdapterInputTrimmedEvidence(adapterInputId) {
736
+ trimmedAdapterInputIds.add(adapterInputId);
737
+ const sequence = nextRetentionSequence();
738
+ const key = `adapter-input-trimmed:${adapterInputId}`;
739
+ const entry = retentionEvidenceEntry(key, sequence, {
740
+ adapterInputId,
741
+ evidenceKind: "adapter-input-trimmed",
742
+ occurredAtMs: nowMs(),
743
+ reason: "adapter-input-retention"
744
+ });
745
+ retentionEvidence.set(key, entry, entry);
746
+ trimRetentionEvidence();
747
+ }
748
+ function trackExecutionHighWaterEvidence(adapterInputId, attempt) {
749
+ const previous = executionHighWaterByInput.get(adapterInputId) ?? 0;
750
+ const attemptHighWater = Math.max(previous, attempt);
751
+ executionHighWaterByInput.set(adapterInputId, attemptHighWater);
752
+ const sequence = nextRetentionSequence();
753
+ const key = `execution-high-water:${adapterInputId}`;
754
+ const entry = retentionEvidenceEntry(key, sequence, {
755
+ adapterInputId,
756
+ evidenceKind: "execution-high-water",
757
+ occurredAtMs: nowMs(),
758
+ attemptHighWater,
759
+ reason: "execution-proof-retention"
760
+ });
761
+ retentionEvidence.set(key, entry, entry);
762
+ trimRetentionEvidence();
763
+ }
764
+ function retentionEvidenceClosedKey(adapterInputId) {
765
+ return `closed:${adapterInputId}`;
766
+ }
767
+ function isRetentionEvidenceClosed(adapterInputId) {
768
+ return retentionEvidenceHorizonExceeded || closedRetentionEvidence.has(retentionEvidenceClosedKey(adapterInputId));
769
+ }
770
+ function classifyRunRequestReplayEvidence(request, input) {
771
+ if (isRetentionEvidenceClosed(request.adapterInputId)) {
772
+ return {
773
+ kind: "retention-gap",
774
+ index: "retentionEvidence",
775
+ gapKind: "evidence-horizon-closed",
776
+ key: retentionEvidenceClosedKey(request.adapterInputId)
777
+ };
778
+ }
779
+ if (input === void 0 && trimmedAdapterInputIds.has(request.adapterInputId)) {
780
+ return {
781
+ kind: "retention-gap",
782
+ index: "adapterInputs",
783
+ gapKind: "adapter-input-trimmed",
784
+ key: `adapter-input-trimmed:${request.adapterInputId}`
785
+ };
786
+ }
787
+ const highWater = executionHighWaterByInput.get(request.adapterInputId) ?? 0;
788
+ if (highWater >= request.attempt) {
789
+ return {
790
+ kind: "retention-gap",
791
+ index: "executions",
792
+ gapKind: "execution-proof-trimmed",
793
+ key: `execution-high-water:${request.adapterInputId}`
794
+ };
795
+ }
796
+ if (input === void 0) return { kind: "missing-input" };
797
+ return { kind: "fresh" };
798
+ }
799
+ function classifyRetainedRunRequestReplayEvidence(request) {
800
+ return classifyRunRequestReplayEvidence(request);
801
+ }
802
+ function dropProjectorInput(adapterInputId) {
803
+ projectorInputDropById.get(adapterInputId)?.();
804
+ projectorInputDropById.delete(adapterInputId);
805
+ }
806
+ function closeRetentionEvidenceHorizon(victim) {
807
+ const key = retentionEvidenceClosedKey(victim.value.adapterInputId);
808
+ const sequence = nextRetentionSequence();
809
+ const entry = retentionEvidenceEntry(key, sequence, {
810
+ adapterInputId: victim.value.adapterInputId,
811
+ evidenceKind: victim.value.evidenceKind,
812
+ occurredAtMs: nowMs(),
813
+ ...victim.value.attemptHighWater === void 0 ? {} : { attemptHighWater: victim.value.attemptHighWater },
814
+ reason: victim.value.reason
815
+ });
816
+ closedRetentionEvidence.set(key, entry, entry);
817
+ trimClosedRetentionEvidence();
818
+ }
819
+ function trimClosedRetentionEvidence() {
820
+ const maxSize = effectiveRetention.retentionEvidence?.maxSize;
821
+ if (maxSize === void 0) return;
822
+ const victims = closedRetentionEvidence.trimFifo(maxSize);
823
+ for (const victim of victims) {
824
+ const firstGlobalClosure = !retentionEvidenceHorizonExceeded;
825
+ if (firstGlobalClosure) retentionEvidenceHorizonExceeded = true;
826
+ publishRetentionTrimmed("retentionEvidence", victim.key, victim.entry);
827
+ if (firstGlobalClosure) {
828
+ publishRetentionEvidenceGlobalFailClosed(victim);
829
+ }
830
+ }
831
+ }
832
+ function trimAdapterInputs() {
833
+ trimRuntimeIndex("adapterInputs", adapterInputs, effectiveRetention.adapterInputs, (victim) => {
834
+ dropProjectorInput(victim.value.adapterInputId);
835
+ trackAdapterInputTrimmedEvidence(victim.value.adapterInputId);
836
+ });
837
+ }
838
+ function trimRunRequests() {
839
+ trimRuntimeIndex("runRequests", runRequests, effectiveRetention.runRequests, (victim) => {
840
+ victim.value.dropKey?.();
841
+ });
842
+ }
843
+ function trimExecutions() {
844
+ trimRuntimeIndex("executions", executions, effectiveRetention.executions, (victim) => {
845
+ trackExecutionHighWaterEvidence(victim.value.adapterInputId, victim.value.attempt);
846
+ });
847
+ }
848
+ function trimRunStatuses() {
849
+ trimRuntimeIndex("runStatuses", runStatuses, effectiveRetention.runStatuses, (victim) => {
850
+ victim.value.dropKey?.();
851
+ });
852
+ }
853
+ function trimRunIssues() {
854
+ trimRuntimeIndex("runIssues", runIssues, effectiveRetention.runIssues, (victim) => {
855
+ victim.value.dropKey?.();
856
+ });
857
+ }
858
+ function trimRetentionEvidence() {
859
+ trimRuntimeIndex(
860
+ "retentionEvidence",
861
+ retentionEvidence,
862
+ effectiveRetention.retentionEvidence,
863
+ (victim) => {
864
+ closeRetentionEvidenceHorizon(victim);
865
+ if (victim.value.evidenceKind === "adapter-input-trimmed") {
866
+ trimmedAdapterInputIds.delete(victim.value.adapterInputId);
867
+ } else {
868
+ executionHighWaterByInput.delete(victim.value.adapterInputId);
869
+ }
870
+ adapterInputs.delete(victim.value.adapterInputId);
871
+ dropProjectorInput(victim.value.adapterInputId);
872
+ }
873
+ );
874
+ }
875
+ function trimAllRetentionIndexes() {
876
+ trimAdapterInputs();
877
+ trimRunRequests();
878
+ trimExecutions();
879
+ trimRunStatuses();
880
+ trimRunIssues();
881
+ trimRetentionEvidence();
882
+ }
883
+ function publishRetentionTrimmed(index, key, entry) {
884
+ const record = isRecord(entry) ? entry : {};
885
+ const evidenceKind = typeof record.evidenceKind === "string" ? record.evidenceKind : void 0;
886
+ const code = index === "retentionEvidence" ? "tool-provider-adapter-runtime-retention-evidence-trimmed" : "tool-provider-adapter-runtime-retention-trimmed";
887
+ const issue = dataIssue(
888
+ code,
889
+ index === "retentionEvidence" ? "Tool provider adapter runtime retention trimmed replay proof evidence and closed the affected horizon." : "Tool provider adapter runtime retention trimmed a runtime-private index entry.",
890
+ {
891
+ subjectId: typeof record.adapterInputId === "string" ? record.adapterInputId : typeof record.key === "string" ? runtimeDiagnosticKey(record.key) : index,
892
+ refs: runtimeEvidenceSourceRefs(index),
893
+ details: runtimeEvidenceMetadata(index, { key }),
894
+ severity: "info"
895
+ }
896
+ );
897
+ publishIssue(issue, false);
898
+ const sourceRefs = runtimeEvidenceSourceRefs(index);
899
+ const metadata = runtimeEvidenceMetadata(index, {
900
+ key,
901
+ extra: evidenceKind === void 0 ? {} : { evidenceKind }
902
+ });
903
+ publishRuntimeStatus({
904
+ status: "retention-trimmed",
905
+ index,
906
+ key,
907
+ ...typeof record.adapterInputId === "string" ? { adapterInputId: record.adapterInputId } : {},
908
+ ...typeof record.runId === "string" ? { runId: record.runId } : {},
909
+ ...typeof record.attempt === "number" ? { attempt: record.attempt } : {},
910
+ issueCode: issue.code,
911
+ sourceRefs,
912
+ metadata
913
+ });
914
+ publishRuntimeAudit("tool-provider-adapter-runtime-retention-trimmed", {
915
+ subjectId: issue.subjectId,
916
+ sourceRefs,
917
+ issueCode: issue.code,
918
+ metadata
919
+ });
920
+ }
921
+ function publishRetentionScoreInvalid(index, reason) {
922
+ const issue = dataIssue(
923
+ "tool-provider-adapter-retention-score-invalid",
924
+ "Tool provider adapter runtime retention scorer returned invalid material; last-known-good policy remains active.",
925
+ {
926
+ subjectId: index,
927
+ refs: runtimeEvidenceSourceRefs(index),
928
+ details: runtimeEvidenceMetadata(index, { extra: { reason } }),
929
+ severity: "warning"
930
+ }
931
+ );
932
+ publishIssue(issue, index !== "runIssues");
933
+ const sourceRefs = runtimeEvidenceSourceRefs(index);
934
+ const metadata = runtimeEvidenceMetadata(index, { extra: { reason } });
935
+ publishRuntimeStatus({
936
+ status: "invalid-retention-policy",
937
+ index,
938
+ issueCode: issue.code,
939
+ sourceRefs,
940
+ metadata
941
+ });
942
+ publishRuntimeAudit("tool-provider-adapter-runtime-invalid-retention-policy", {
943
+ subjectId: index,
944
+ sourceRefs,
945
+ issueCode: issue.code,
946
+ metadata
947
+ });
948
+ }
949
+ function applyRetentionPolicyFact(fact) {
950
+ const invalidIndexes = /* @__PURE__ */ new Set();
951
+ if (fact.issues !== void 0 && fact.issues.length > 0) {
952
+ for (const issue of fact.issues) {
953
+ publishIssue(issue);
954
+ const index = toolProviderAdapterRuntimeRetentionIndex(issue.subjectId);
955
+ if (index !== void 0) invalidIndexes.add(index);
956
+ publishRuntimeStatus({
957
+ status: "invalid-retention-policy",
958
+ ...index === void 0 ? {} : { index },
959
+ issueCode: issue.code,
960
+ ...index === void 0 ? {} : { sourceRefs: runtimeEvidenceSourceRefs(index) }
961
+ });
962
+ publishRuntimeAudit("tool-provider-adapter-runtime-invalid-retention-policy", {
963
+ ...issue.subjectId === void 0 ? {} : { subjectId: issue.subjectId },
964
+ ...index === void 0 ? {} : { sourceRefs: runtimeEvidenceSourceRefs(index) },
965
+ issueCode: issue.code
966
+ });
967
+ }
968
+ }
969
+ const adapterInputsPolicy = fact.policies.get("adapterInputs");
970
+ const runRequestsPolicy = fact.policies.get("runRequests");
971
+ const executionsPolicy = fact.policies.get("executions");
972
+ const runStatusesPolicy = fact.policies.get("runStatuses");
973
+ const runIssuesPolicy = fact.policies.get("runIssues");
974
+ const retentionEvidencePolicy = fact.policies.get("retentionEvidence");
975
+ effectiveRetention = {
976
+ ...invalidIndexes.has("adapterInputs") ? effectiveRetention.adapterInputs === void 0 ? {} : { adapterInputs: effectiveRetention.adapterInputs } : adapterInputsPolicy === void 0 ? {} : { adapterInputs: adapterInputsPolicy },
977
+ ...invalidIndexes.has("runRequests") ? effectiveRetention.runRequests === void 0 ? {} : { runRequests: effectiveRetention.runRequests } : runRequestsPolicy === void 0 ? {} : { runRequests: runRequestsPolicy },
978
+ ...invalidIndexes.has("executions") ? effectiveRetention.executions === void 0 ? {} : { executions: effectiveRetention.executions } : executionsPolicy === void 0 ? {} : { executions: executionsPolicy },
979
+ ...invalidIndexes.has("runStatuses") ? effectiveRetention.runStatuses === void 0 ? {} : { runStatuses: effectiveRetention.runStatuses } : runStatusesPolicy === void 0 ? {} : { runStatuses: runStatusesPolicy },
980
+ ...invalidIndexes.has("runIssues") ? effectiveRetention.runIssues === void 0 ? {} : { runIssues: effectiveRetention.runIssues } : runIssuesPolicy === void 0 ? {} : { runIssues: runIssuesPolicy },
981
+ ...invalidIndexes.has("retentionEvidence") ? effectiveRetention.retentionEvidence === void 0 ? {} : { retentionEvidence: effectiveRetention.retentionEvidence } : retentionEvidencePolicy === void 0 ? {} : { retentionEvidence: retentionEvidencePolicy }
982
+ };
983
+ trimAllRetentionIndexes();
984
+ }
985
+ function publishStatus(input, nextStatus, statusIssues) {
986
+ if (input.effectRunId === void 0) return;
987
+ const metadata = sanitizeGraphVisibleRecord({
988
+ adapterInputId: input.adapterInputId,
989
+ providerId: input.providerId,
990
+ toolName: input.toolName
991
+ });
992
+ status.down([
993
+ [
994
+ "DATA",
995
+ {
996
+ kind: "status",
997
+ requestId: input.requestId,
998
+ operationId: input.operationId,
999
+ effectRunId: input.effectRunId,
1000
+ status: nextStatus,
1001
+ sourceRefs: defaultToolProviderAdapterEvidenceRefs(input),
1002
+ ...statusIssues === void 0 ? {} : { issues: statusIssues },
1003
+ ...metadata === void 0 ? {} : { metadata }
1004
+ }
1005
+ ]
1006
+ ]);
1007
+ }
1008
+ function publishAudit(input, kind, metadata, issueCode) {
1009
+ auditSeq += 1;
1010
+ const cleanMetadata = sanitizeGraphVisibleRecord({
1011
+ adapterInputId: input.adapterInputId,
1012
+ providerId: input.providerId,
1013
+ toolName: input.toolName,
1014
+ ...metadata
1015
+ });
1016
+ audit.down([
1017
+ [
1018
+ "DATA",
1019
+ {
1020
+ id: `${name}:audit:${auditSeq}`,
1021
+ kind,
1022
+ subjectId: input.requestId,
1023
+ sourceRefs: defaultToolProviderAdapterEvidenceRefs(input),
1024
+ ...issueCode === void 0 ? {} : { issueCode },
1025
+ ...cleanMetadata === void 0 ? {} : { metadata: cleanMetadata }
1026
+ }
1027
+ ]
1028
+ ]);
1029
+ }
1030
+ function publishOutcome(input, result, request) {
1031
+ if (disposed) return;
1032
+ let outcome;
1033
+ try {
1034
+ outcome = buildToolProviderExecutorOutcome(input, result, {
1035
+ attempt: request.attempt,
1036
+ runId: request.runId,
1037
+ occurredAtMs: opts.now?.(),
1038
+ publicText: opts.publicText
1039
+ });
1040
+ } catch (error) {
1041
+ const issue = adapterRuntimeIssue(
1042
+ input,
1043
+ "tool-provider-adapter-runtime-invalid-input",
1044
+ error
1045
+ );
1046
+ publishIssue(issue);
1047
+ publishRunStatus(request, "failure", [issue]);
1048
+ publishStatus(input, "failed", [issue]);
1049
+ publishAudit(input, "tool-provider-adapter-runtime-invalid-input", void 0, issue.code);
1050
+ return;
1051
+ }
1052
+ outcomes.down([["DATA", outcome]]);
1053
+ const execution = executions.get(executionCoordinate(request));
1054
+ if (execution !== void 0) {
1055
+ executions.set(
1056
+ execution.key,
1057
+ executionRetentionEntry(
1058
+ execution.key,
1059
+ execution.entry.sequence,
1060
+ request,
1061
+ outcome.kind,
1062
+ outcome.occurredAtMs,
1063
+ outcome.outcomeId
1064
+ ),
1065
+ request
1066
+ );
1067
+ }
1068
+ const publishedIssueKeys = /* @__PURE__ */ new Set();
1069
+ for (const issue of outcome.issues ?? []) {
1070
+ publishedIssueKeys.add(`${issue.code}:${issue.message}`);
1071
+ publishIssue(issue);
1072
+ }
1073
+ if (outcome.kind === "failure" && !publishedIssueKeys.has(`${outcome.error.code}:${outcome.error.message}`)) {
1074
+ publishIssue(outcome.error);
1075
+ }
1076
+ const statusIssues = outcomeIssues(outcome);
1077
+ publishStatus(
1078
+ input,
1079
+ agentRequestStatusForExecutorOutcome(outcome),
1080
+ statusIssues.length === 0 ? void 0 : statusIssues
1081
+ );
1082
+ publishRunStatus(
1083
+ request,
1084
+ outcome.kind,
1085
+ statusIssues.length === 0 ? void 0 : statusIssues,
1086
+ outcome.outcomeId
1087
+ );
1088
+ publishAudit(input, "tool-provider-adapter-runtime-finished", {
1089
+ status: outcome.kind,
1090
+ outcomeId: outcome.outcomeId,
1091
+ runId: request.runId,
1092
+ attempt: request.attempt
1093
+ });
1094
+ }
1095
+ function publishRuntimeFailure(input, request, code, error) {
1096
+ const issue = adapterRuntimeIssue(input, code, error);
1097
+ publishOutcome(
1098
+ input,
1099
+ {
1100
+ kind: "failure",
1101
+ error: issue,
1102
+ retryable: false,
1103
+ issues: [issue]
1104
+ },
1105
+ request
1106
+ );
1107
+ }
1108
+ function executionCoordinate(request) {
1109
+ return `${request.adapterInputId}:${request.attempt}`;
1110
+ }
1111
+ function trackRunRequest(request, emittedKey, dropKey) {
1112
+ const sequence = nextRetentionSequence();
1113
+ runRequests.set(emittedKey, runRequestRetentionEntry(emittedKey, sequence, request), {
1114
+ fact: request,
1115
+ dropKey
1116
+ });
1117
+ trimRunRequests();
1118
+ }
1119
+ function startExecutionProof(request) {
1120
+ const coordinate = executionCoordinate(request);
1121
+ const existing = executions.get(coordinate);
1122
+ if (existing !== void 0) {
1123
+ if (existing.value.runId !== request.runId) {
1124
+ const issue = dataIssue(
1125
+ "tool-provider-adapter-runtime-duplicate-execution-coordinate",
1126
+ "Tool provider adapter runtime requires one visible runId per adapterInputId and attempt.",
1127
+ {
1128
+ subjectId: request.adapterInputId,
1129
+ refs: [ref("tool-provider-adapter-run", request.runId)],
1130
+ details: {
1131
+ adapterInputId: request.adapterInputId,
1132
+ attempt: request.attempt
1133
+ }
1134
+ }
1135
+ );
1136
+ publishIssue(issue);
1137
+ publishRunStatus(request, "mismatched-request", [issue]);
1138
+ publishRuntimeAudit("tool-provider-adapter-runtime-duplicate-execution-coordinate", {
1139
+ subjectId: request.adapterInputId,
1140
+ sourceRefs: [ref("tool-provider-adapter-run", request.runId)],
1141
+ issueCode: issue.code,
1142
+ metadata: {
1143
+ adapterInputId: request.adapterInputId,
1144
+ attempt: request.attempt,
1145
+ key: runtimeDiagnosticKey(coordinate)
1146
+ }
1147
+ });
1148
+ }
1149
+ return false;
1150
+ }
1151
+ const sequence = nextRetentionSequence();
1152
+ executions.set(
1153
+ coordinate,
1154
+ executionRetentionEntry(coordinate, sequence, request, "started", nowMs()),
1155
+ request
1156
+ );
1157
+ trimExecutions();
1158
+ const classification = classifyRunRequestReplayEvidence(
1159
+ request,
1160
+ adapterInputs.get(request.adapterInputId)?.value
1161
+ );
1162
+ if (classification.kind !== "fresh") {
1163
+ executions.delete(coordinate);
1164
+ publishReplayClassification(request, classification);
1165
+ return false;
1166
+ }
1167
+ return true;
1168
+ }
1169
+ function publishReplayClassification(request, classification) {
1170
+ if (classification.kind === "fresh") return false;
1171
+ if (classification.kind === "missing-input") {
1172
+ const issueCode = "tool-provider-adapter-runtime-missing-input";
1173
+ const issue = dataIssue(
1174
+ issueCode,
1175
+ "Tool provider adapter runtime requires the requested adapter input.",
1176
+ {
1177
+ subjectId: request.adapterInputId,
1178
+ refs: [ref("tool-provider-adapter-run", request.runId)],
1179
+ details: {
1180
+ adapterInputId: request.adapterInputId,
1181
+ runId: request.runId,
1182
+ attempt: request.attempt,
1183
+ issueCode
1184
+ }
1185
+ }
1186
+ );
1187
+ publishIssue(issue);
1188
+ publishRunStatus(request, "missing-input", [issue]);
1189
+ return true;
1190
+ }
1191
+ publishRetentionGap(request, classification);
1192
+ return true;
1193
+ }
1194
+ function publishRetentionGap(request, classification) {
1195
+ publishAdapterRuntimeRetentionGap(
1196
+ { publishIssue, publishRunStatus, publishRuntimeStatus, publishRuntimeAudit },
1197
+ request,
1198
+ classification
1199
+ );
1200
+ }
1201
+ function publishRetentionEvidenceGlobalFailClosed(victim) {
1202
+ publishAdapterRuntimeRetentionEvidenceGlobalFailClosed(
1203
+ { publishIssue, publishRunStatus, publishRuntimeStatus, publishRuntimeAudit },
1204
+ victim
1205
+ );
1206
+ }
1207
+ function runRequest(request) {
1208
+ runAdapterRuntimeRequest(
1209
+ {
1210
+ isDisposed: () => disposed,
1211
+ adapterInputs,
1212
+ executions,
1213
+ bindings,
1214
+ now: opts.now,
1215
+ classifyRunRequestReplayEvidence,
1216
+ publishReplayClassification,
1217
+ startExecutionProof,
1218
+ executionCoordinate,
1219
+ publishIssue,
1220
+ publishRunStatus,
1221
+ publishStatus,
1222
+ publishAudit,
1223
+ publishOutcome,
1224
+ publishRuntimeFailure
1225
+ },
1226
+ request
1227
+ );
1228
+ }
1229
+ const unsubscribeRetentionPolicy = retentionPolicy.subscribe((msg) => {
1230
+ if (msg[0] === "DATA") applyRetentionPolicyFact(msg[1]);
1231
+ });
1232
+ const unsubscribeInputs = opts.inputs.subscribe((msg) => {
1233
+ if (msg[0] !== "DATA") return;
1234
+ const input = msg[1];
1235
+ if (isRetentionEvidenceClosed(input.adapterInputId)) {
1236
+ adapterInputs.delete(input.adapterInputId);
1237
+ dropProjectorInput(input.adapterInputId);
1238
+ return;
1239
+ }
1240
+ if (trimmedAdapterInputIds.delete(input.adapterInputId)) {
1241
+ retentionEvidence.delete(`adapter-input-trimmed:${input.adapterInputId}`);
1242
+ }
1243
+ const sequence = nextRetentionSequence();
1244
+ adapterInputs.set(
1245
+ input.adapterInputId,
1246
+ adapterInputRetentionEntry(input.adapterInputId, sequence, input, nowMs()),
1247
+ input
1248
+ );
1249
+ trimAdapterInputs();
1250
+ });
1251
+ const runProjector = toolProviderAdapterRunProjectorInternal(graph, {
1252
+ name: `${name}/runs`,
1253
+ inputs: opts.inputs,
1254
+ runRequests: opts.runRequests,
1255
+ autoRunReadyInputs: opts.autoRunReadyInputs,
1256
+ now: opts.now,
1257
+ publicText: opts.publicText,
1258
+ privateRetentionHooks: {
1259
+ onRunRequestKey(entry) {
1260
+ trackRunRequest(entry.request, entry.key, entry.dropKey);
1261
+ },
1262
+ onRunStatusKey(entry) {
1263
+ trackRunStatus(entry.status, entry.key, entry.dropKey);
1264
+ },
1265
+ onRunIssueKey(entry) {
1266
+ trackRunIssue(entry.issue, entry.key, entry.dropKey);
1267
+ },
1268
+ onAdapterInputKey(entry) {
1269
+ if (isRetentionEvidenceClosed(entry.adapterInputId) || !adapterInputs.has(entry.adapterInputId)) {
1270
+ entry.dropInput();
1271
+ projectorInputDropById.delete(entry.adapterInputId);
1272
+ return;
1273
+ }
1274
+ projectorInputDropById.set(entry.adapterInputId, entry.dropInput);
1275
+ },
1276
+ classifyRetainedRunRequestReplayEvidence
1277
+ }
1278
+ });
1279
+ const unsubscribeRunProjectorStatus = runProjector.status.subscribe((msg) => {
1280
+ if (msg[0] === "DATA") {
1281
+ const statusFact = msg[1];
1282
+ runStatus.down([["DATA", statusFact]]);
1283
+ }
1284
+ });
1285
+ const unsubscribeRunProjectorIssues = runProjector.issues.subscribe((msg) => {
1286
+ if (msg[0] === "DATA") publishIssue(msg[1], false);
1287
+ });
1288
+ const unsubscribeRunProjectorAudit = runProjector.audit.subscribe((msg) => {
1289
+ if (msg[0] === "DATA") audit.down([["DATA", msg[1]]]);
1290
+ });
1291
+ const unsubscribeRunRequests = runProjector.requests.subscribe((msg) => {
1292
+ if (msg[0] !== "DATA") return;
1293
+ const request = msg[1];
1294
+ runRequest(request);
1295
+ });
1296
+ return {
1297
+ runRequests: runProjector.requests,
1298
+ runStatus,
1299
+ runtimeStatus,
1300
+ outcomes,
1301
+ status,
1302
+ issues,
1303
+ audit,
1304
+ dispose() {
1305
+ if (disposed) return;
1306
+ disposed = true;
1307
+ unsubscribeRetentionPolicy();
1308
+ unsubscribeInputs();
1309
+ unsubscribeRunProjectorStatus();
1310
+ unsubscribeRunProjectorIssues();
1311
+ unsubscribeRunProjectorAudit();
1312
+ unsubscribeRunRequests();
1313
+ }
1314
+ };
1315
+ }
1316
+
1317
+ export {
1318
+ attachToolProviderAdapterRuntime
1319
+ };
1320
+ //# sourceMappingURL=chunk-WOS7RJYZ.js.map