@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,1336 @@
1
+ import "../chunk-STXRMPW4.js";
2
+ import {
3
+ localBuiltinToolProviderCatalog
4
+ } from "../chunk-MTELVIYR.js";
5
+ import {
6
+ buildToolProviderExecutorOutcome,
7
+ toolProviderAdapterRunProjector
8
+ } from "../chunk-7GOTIIQ7.js";
9
+ import "../chunk-TQPCAIQI.js";
10
+ import "../chunk-TPND5MJS.js";
11
+ import "../chunk-OOEN33FB.js";
12
+ import "../chunk-CX6B6PO2.js";
13
+ import "../chunk-CJIFGJQG.js";
14
+ import "../chunk-SHZDP2MQ.js";
15
+ import "../chunk-WQIA3GFB.js";
16
+ import "../chunk-S6HXABGL.js";
17
+ import "../chunk-K7FB3JTD.js";
18
+ import "../chunk-DGUM43GV.js";
19
+
20
+ // src/executors/tool-provider-adapters.ts
21
+ import { spawnSync } from "child_process";
22
+ import { realpathSync } from "fs";
23
+ import { isAbsolute, relative, resolve } from "path";
24
+ var LOCAL_BUILTIN_TOOLS = Object.freeze([
25
+ Object.freeze({
26
+ toolName: "date.now",
27
+ operation: "read",
28
+ resultKinds: Object.freeze(["json"]),
29
+ capabilities: Object.freeze({ deterministicWithInjectedClock: true })
30
+ }),
31
+ Object.freeze({
32
+ toolName: "json.parse",
33
+ operation: "parse",
34
+ resultKinds: Object.freeze(["json"]),
35
+ capabilities: Object.freeze({ externalSideEffects: false })
36
+ }),
37
+ Object.freeze({
38
+ toolName: "text.concat",
39
+ operation: "transform",
40
+ resultKinds: Object.freeze(["text"]),
41
+ capabilities: Object.freeze({ externalSideEffects: false })
42
+ })
43
+ ]);
44
+ function localBuiltinToolProviderBinding(opts = {}) {
45
+ const providerId = opts.providerId ?? "local-builtin";
46
+ const maxTextChars = nonNegativeFinite(opts.maxTextChars, 16384);
47
+ return Object.freeze({
48
+ providerId,
49
+ run(input, ctx) {
50
+ const toolName = input.toolName;
51
+ switch (toolName) {
52
+ case "date.now":
53
+ return localDateNow(input, ctx, opts.now);
54
+ case "json.parse":
55
+ return localJsonParse(input, maxTextChars);
56
+ case "text.concat":
57
+ return localTextConcat(input, maxTextChars);
58
+ default:
59
+ return blocked(
60
+ input,
61
+ "local-builtin-unsupported-tool",
62
+ "Local builtin tool is not supported."
63
+ );
64
+ }
65
+ }
66
+ });
67
+ }
68
+ function localBuiltinToolProviderAdapterPack(opts = {}) {
69
+ const providerId = opts.providerId ?? "local-builtin";
70
+ const catalog = localBuiltinToolProviderCatalog({
71
+ providerId,
72
+ executorId: opts.executorId ?? `${providerId}:tool-executor`,
73
+ profileId: opts.profileId ?? `${providerId}:tool-profile`,
74
+ tools: LOCAL_BUILTIN_TOOLS,
75
+ policyOverrides: {
76
+ operations: Object.freeze(["read", "parse", "transform"]),
77
+ redaction: Object.freeze({
78
+ mode: "summary",
79
+ summaryMaxChars: opts.publicText?.maxSummaryChars ?? 512
80
+ })
81
+ },
82
+ metadata: Object.freeze({ adapterPack: "local-builtin-v0" })
83
+ });
84
+ return Object.freeze({
85
+ catalogs: Object.freeze([catalog]),
86
+ bindings: Object.freeze([
87
+ localBuiltinToolProviderBinding({
88
+ providerId,
89
+ now: opts.now,
90
+ maxTextChars: opts.maxTextChars ?? opts.publicText?.maxSummaryChars
91
+ })
92
+ ])
93
+ });
94
+ }
95
+ function processToolProviderBinding(opts = {}) {
96
+ const providerId = opts.providerId ?? "process";
97
+ const config = processConfig(opts);
98
+ return Object.freeze({
99
+ providerId,
100
+ run(input) {
101
+ const args = processArguments(input);
102
+ if (args === void 0) {
103
+ return blocked(input, "process-invalid-arguments", "Process tool requires argv arguments.");
104
+ }
105
+ const allowed = config.allowedCommands.get(args.command);
106
+ if (allowed === void 0) {
107
+ if (config.duplicateCommands.has(args.command)) {
108
+ return blocked(
109
+ input,
110
+ "process-command-duplicate-allowlist",
111
+ "Process command has duplicate allowlist entries."
112
+ );
113
+ }
114
+ if (config.invalidCommands.has(args.command)) {
115
+ return blocked(
116
+ input,
117
+ "process-command-invalid-allowlist",
118
+ "Process command has an invalid allowlist entry."
119
+ );
120
+ }
121
+ return blocked(input, "process-command-not-allowed", "Process command is not allowlisted.");
122
+ }
123
+ if (!argsAllowed(allowed, args.args)) {
124
+ return blocked(input, "process-argv-not-allowed", "Process argv is not allowlisted.");
125
+ }
126
+ const cwd = resolveProcessCwd(args.cwd, allowed, config);
127
+ if (cwd === void 0) {
128
+ return blocked(
129
+ input,
130
+ "process-cwd-not-allowed",
131
+ "Process cwd is outside the allowed policy."
132
+ );
133
+ }
134
+ const env = processEnv(args.env, config);
135
+ if (env === void 0) {
136
+ return blocked(
137
+ input,
138
+ "process-env-not-allowed",
139
+ "Process env contains non-allowlisted keys."
140
+ );
141
+ }
142
+ return runProcessTool(input, allowed, args, cwd, env, config);
143
+ }
144
+ });
145
+ }
146
+ function processToolProviderAdapterPack(opts = {}) {
147
+ const providerId = opts.providerId ?? "process";
148
+ const executorId = opts.executorId ?? `${providerId}:tool-executor`;
149
+ const profileId = opts.profileId ?? `${providerId}:tool-profile`;
150
+ return Object.freeze({
151
+ catalogs: Object.freeze([
152
+ processToolProviderCatalog({ ...opts, providerId, executorId, profileId })
153
+ ]),
154
+ bindings: Object.freeze([processToolProviderBinding({ ...opts, providerId })])
155
+ });
156
+ }
157
+ function processToolProviderCatalog(opts = {}) {
158
+ const providerId = opts.providerId ?? "process";
159
+ const executorId = opts.executorId ?? `${providerId}:tool-executor`;
160
+ const profileId = opts.profileId ?? `${providerId}:tool-profile`;
161
+ const normalized = normalizeAllowedCommands(opts.allowedCommands ?? []);
162
+ const allowedCommands = Object.freeze([...normalized.commands.values()]);
163
+ const issueList = [
164
+ ...allowedCommands.length === 0 ? [
165
+ issue(
166
+ "process-tool-provider-empty-allowlist",
167
+ "Process tool provider has no allowlisted commands and will deny execution.",
168
+ "warning"
169
+ )
170
+ ] : [],
171
+ ...[...normalized.duplicates].map(
172
+ (command) => issue(
173
+ "process-tool-provider-duplicate-allowlist",
174
+ "Process tool provider has duplicate command allowlist entries.",
175
+ "error",
176
+ { command }
177
+ )
178
+ ),
179
+ ...[...normalized.invalids].map(
180
+ (command) => issue(
181
+ "process-tool-provider-invalid-allowlist",
182
+ "Process tool provider has invalid command allowlist entries.",
183
+ "error",
184
+ { command }
185
+ )
186
+ )
187
+ ];
188
+ const issues = issueList.length === 0 ? void 0 : Object.freeze(issueList);
189
+ const policy = processToolProviderExecutionPolicy(providerId, profileId, opts);
190
+ const tool = Object.freeze({
191
+ kind: "tool-catalog-entry",
192
+ providerId,
193
+ toolName: "process.execFile",
194
+ operation: "run",
195
+ inputKind: "tool-call",
196
+ profileId,
197
+ executorId,
198
+ resultKinds: Object.freeze(["process-result"]),
199
+ capabilities: Object.freeze({
200
+ argv: true,
201
+ shell: false,
202
+ commands: Object.freeze(allowedCommands.map((cmd) => cmd.command)),
203
+ env: Object.freeze({ allowedKeys: Object.freeze([...opts.allowedEnvKeys ?? []]) })
204
+ }),
205
+ policyRefs: Object.freeze([{ kind: "tool-provider-execution-policy", id: policy.policyId }])
206
+ });
207
+ return Object.freeze({
208
+ kind: "tool-provider-catalog",
209
+ providerId,
210
+ providerKind: "process",
211
+ status: issues === void 0 ? "ready" : "misconfigured",
212
+ profiles: Object.freeze([
213
+ Object.freeze({
214
+ profileId,
215
+ executorId,
216
+ kind: "tool",
217
+ acceptedInputKinds: Object.freeze(["tool-call"]),
218
+ acceptedResultKinds: Object.freeze(["process-result"]),
219
+ capabilities: Object.freeze({
220
+ toolNames: Object.freeze([tool.toolName]),
221
+ argv: true,
222
+ shell: false
223
+ }),
224
+ policyRefs: Object.freeze([
225
+ { kind: "tool-provider-execution-policy", id: policy.policyId }
226
+ ])
227
+ })
228
+ ]),
229
+ tools: Object.freeze([tool]),
230
+ policies: Object.freeze([policy]),
231
+ policyRefs: Object.freeze([{ kind: "tool-provider-execution-policy", id: policy.policyId }]),
232
+ issues,
233
+ metadata: Object.freeze({ adapterPack: "process-v0" })
234
+ });
235
+ }
236
+ function httpToolProviderCatalog(opts = {}) {
237
+ const providerId = opts.providerId ?? "http";
238
+ const executorId = opts.executorId ?? `${providerId}:tool-executor`;
239
+ const profileId = opts.profileId ?? `${providerId}:tool-profile`;
240
+ const allowedOrigins = Object.freeze([...opts.allowedOrigins ?? []]);
241
+ const allowedMethods = Object.freeze(normalizeMethods(opts.allowedMethods ?? ["GET"]));
242
+ const maxResponseBytes = Math.max(1, nonNegativeFinite(opts.maxResponseBytes, 64 * 1024));
243
+ const policy = httpToolProviderExecutionPolicy(providerId, profileId, opts);
244
+ const issues = Object.freeze([
245
+ ...allowedOrigins.length === 0 ? [
246
+ issue(
247
+ "http-tool-provider-empty-origin-allowlist",
248
+ "HTTP tool provider has no allowlisted origins and will deny execution.",
249
+ "warning"
250
+ )
251
+ ] : [],
252
+ ...allowedMethods.length === 0 ? [
253
+ issue(
254
+ "http-tool-provider-empty-method-allowlist",
255
+ "HTTP tool provider has no allowlisted methods and will deny execution."
256
+ )
257
+ ] : []
258
+ ]);
259
+ const tool = Object.freeze({
260
+ kind: "tool-catalog-entry",
261
+ providerId,
262
+ toolName: "http.fetch",
263
+ operation: "fetch",
264
+ inputKind: "tool-call",
265
+ profileId,
266
+ executorId,
267
+ resultKinds: Object.freeze(["http-result"]),
268
+ capabilities: Object.freeze({
269
+ origins: allowedOrigins,
270
+ methods: allowedMethods,
271
+ maxResponseBytes,
272
+ asyncRuntime: true
273
+ }),
274
+ policyRefs: Object.freeze([{ kind: "tool-provider-execution-policy", id: policy.policyId }])
275
+ });
276
+ return Object.freeze({
277
+ kind: "tool-provider-catalog",
278
+ providerId,
279
+ providerKind: "http",
280
+ status: issues.length === 0 ? "ready" : "misconfigured",
281
+ profiles: Object.freeze([
282
+ Object.freeze({
283
+ profileId,
284
+ executorId,
285
+ kind: "tool",
286
+ acceptedInputKinds: Object.freeze(["tool-call"]),
287
+ acceptedResultKinds: Object.freeze(["http-result"]),
288
+ capabilities: Object.freeze({
289
+ toolNames: Object.freeze([tool.toolName]),
290
+ asyncRuntime: true
291
+ }),
292
+ policyRefs: Object.freeze([
293
+ { kind: "tool-provider-execution-policy", id: policy.policyId }
294
+ ])
295
+ })
296
+ ]),
297
+ tools: Object.freeze([tool]),
298
+ policies: Object.freeze([policy]),
299
+ policyRefs: Object.freeze([{ kind: "tool-provider-execution-policy", id: policy.policyId }]),
300
+ issues: issues.length === 0 ? void 0 : issues,
301
+ metadata: Object.freeze({ adapterPack: "http-v0", asyncRuntime: true })
302
+ });
303
+ }
304
+ function httpToolProviderRuntime(graph, opts) {
305
+ const name = opts.name ?? "httpToolProviderRuntime";
306
+ const providerId = opts.providerId ?? "http";
307
+ const catalog = httpToolProviderCatalog(opts);
308
+ const outcomes = graph.node([], null, {
309
+ name: `${name}/outcomes`
310
+ });
311
+ const runStatus = graph.node([], null, {
312
+ name: `${name}/runStatus`
313
+ });
314
+ const status = graph.node([], null, { name: `${name}/status` });
315
+ const issues = graph.node([], null, { name: `${name}/issues` });
316
+ const audit = graph.node([], null, { name: `${name}/audit` });
317
+ const inputs = /* @__PURE__ */ new Map();
318
+ const executions = /* @__PURE__ */ new Set();
319
+ const active = /* @__PURE__ */ new Set();
320
+ const config = httpRuntimeConfig(opts);
321
+ const driver = opts.driver ?? defaultHttpToolProviderDriver(config.maxResponseBytes);
322
+ const forwardedRunStatusKeys = /* @__PURE__ */ new Set();
323
+ let auditSeq = 0;
324
+ let disposed = false;
325
+ function nowMs() {
326
+ return opts.now?.();
327
+ }
328
+ function publishIssue(nextIssue) {
329
+ issues.down([["DATA", nextIssue]]);
330
+ }
331
+ function publishAudit(kind, subjectId, metadata, issueCode) {
332
+ auditSeq += 1;
333
+ audit.down([
334
+ [
335
+ "DATA",
336
+ {
337
+ id: `${name}:audit:${auditSeq}`,
338
+ kind,
339
+ subjectId,
340
+ ...issueCode === void 0 ? {} : { issueCode },
341
+ ...metadata === void 0 ? {} : { metadata }
342
+ }
343
+ ]
344
+ ]);
345
+ }
346
+ function publishRunStatus(request, nextStatus, statusIssues, outcomeId) {
347
+ forwardedRunStatusKeys.add(`${request.runId}:${nextStatus}`);
348
+ runStatus.down([
349
+ [
350
+ "DATA",
351
+ {
352
+ kind: "tool-provider-adapter-run-status",
353
+ runId: request.runId,
354
+ adapterInputId: request.adapterInputId,
355
+ requestId: request.requestId,
356
+ operationId: request.operationId,
357
+ status: nextStatus,
358
+ attempt: request.attempt,
359
+ ...outcomeId === void 0 ? {} : { outcomeId },
360
+ ...statusIssues === void 0 ? {} : { issues: statusIssues },
361
+ sourceRefs: request.sourceRefs,
362
+ metadata: Object.freeze({ providerId, reason: request.reason })
363
+ }
364
+ ]
365
+ ]);
366
+ }
367
+ function publishRequestStatus(input, nextStatus, statusIssues) {
368
+ if (input.effectRunId === void 0) return;
369
+ status.down([
370
+ [
371
+ "DATA",
372
+ {
373
+ kind: "status",
374
+ requestId: input.requestId,
375
+ operationId: input.operationId,
376
+ effectRunId: input.effectRunId,
377
+ status: nextStatus,
378
+ sourceRefs: defaultEvidenceRefs(input),
379
+ ...statusIssues === void 0 ? {} : { issues: statusIssues },
380
+ metadata: Object.freeze({
381
+ adapterInputId: input.adapterInputId,
382
+ providerId: input.providerId,
383
+ toolName: input.toolName
384
+ })
385
+ }
386
+ ]
387
+ ]);
388
+ }
389
+ function publishOutcome(input, request, result) {
390
+ const outcome = buildToolProviderExecutorOutcome(input, result, {
391
+ runId: request.runId,
392
+ attempt: request.attempt,
393
+ occurredAtMs: nowMs(),
394
+ publicText: opts.publicText
395
+ });
396
+ outcomes.down([["DATA", outcome]]);
397
+ const statusIssues = outcomeIssues(outcome);
398
+ for (const statusIssue of statusIssues) publishIssue(statusIssue);
399
+ publishRequestStatus(input, agentStatusForOutcome(outcome), statusIssues);
400
+ publishRunStatus(request, outcome.kind, statusIssues, outcome.outcomeId);
401
+ publishAudit("http-tool-provider-runtime-finished", input.requestId, {
402
+ runId: request.runId,
403
+ attempt: request.attempt,
404
+ status: outcome.kind,
405
+ outcomeId: outcome.outcomeId
406
+ });
407
+ }
408
+ function execute(request) {
409
+ if (disposed || request.providerId !== void 0 && request.providerId !== providerId) return;
410
+ const input = inputs.get(request.adapterInputId);
411
+ if (input === void 0 || input.providerId !== providerId) return;
412
+ const coordinate = `${request.runId}:${request.adapterInputId}:${request.attempt}`;
413
+ if (executions.has(coordinate)) return;
414
+ executions.add(coordinate);
415
+ publishRunStatus(request, "requested");
416
+ if (input.status !== "ready") {
417
+ const inputIssue = issue(
418
+ "http-tool-provider-input-not-ready",
419
+ "HTTP tool provider runtime requires a ready adapter input."
420
+ );
421
+ publishIssue(inputIssue);
422
+ publishRunStatus(request, "stale-request", [inputIssue]);
423
+ publishRequestStatus(input, "blocked", [inputIssue]);
424
+ return;
425
+ }
426
+ if (!requestMatchesInput(request, input)) {
427
+ const mismatch = issue(
428
+ "http-tool-provider-run-request-mismatched-input",
429
+ "HTTP tool provider run request does not match its adapter input."
430
+ );
431
+ publishIssue(mismatch);
432
+ publishRunStatus(request, "mismatched-request", [mismatch]);
433
+ publishRequestStatus(input, "blocked", [mismatch]);
434
+ return;
435
+ }
436
+ const prepared = prepareHttpRequest(input, config);
437
+ if (prepared.kind === "blocked") {
438
+ publishOutcome(input, request, {
439
+ kind: "blocked",
440
+ needs: Object.freeze([
441
+ Object.freeze({
442
+ kind: prepared.issue.code,
443
+ message: prepared.issue.message
444
+ })
445
+ ]),
446
+ issues: Object.freeze([prepared.issue]),
447
+ evidenceRefs: defaultEvidenceRefs(input)
448
+ });
449
+ return;
450
+ }
451
+ if (config.approvalMode === "never") {
452
+ publishOutcome(input, request, {
453
+ kind: "blocked",
454
+ needs: Object.freeze([
455
+ Object.freeze({
456
+ kind: "tool-provider-approval-disabled",
457
+ message: "HTTP tool provider policy disallows execution."
458
+ })
459
+ ]),
460
+ issues: Object.freeze([
461
+ issue("http-tool-provider-approval-never", "HTTP tool provider execution is disabled.")
462
+ ]),
463
+ evidenceRefs: defaultEvidenceRefs(input)
464
+ });
465
+ return;
466
+ }
467
+ if (config.approvalMode === "require" && !requestApproved(request)) {
468
+ publishOutcome(input, request, {
469
+ kind: "blocked",
470
+ needs: Object.freeze([
471
+ Object.freeze({
472
+ kind: "tool-provider-approval",
473
+ message: "HTTP tool provider execution requires a visible approval run request."
474
+ })
475
+ ]),
476
+ issues: Object.freeze([
477
+ issue(
478
+ "http-tool-provider-approval-required",
479
+ "HTTP tool provider execution requires approval."
480
+ )
481
+ ]),
482
+ evidenceRefs: defaultEvidenceRefs(input)
483
+ });
484
+ return;
485
+ }
486
+ const controller = new AbortController();
487
+ active.add(controller);
488
+ publishRunStatus(request, "started");
489
+ publishRequestStatus(input, "in-flight");
490
+ publishAudit("http-tool-provider-runtime-started", input.requestId, {
491
+ runId: request.runId,
492
+ attempt: request.attempt,
493
+ method: prepared.request.method,
494
+ origin: new URL(prepared.request.url).origin
495
+ });
496
+ const timeout = setTimeout(() => controller.abort(), config.timeoutMs);
497
+ Promise.resolve(driver.fetch({ ...prepared.request, signal: controller.signal })).then(
498
+ (response) => {
499
+ clearTimeout(timeout);
500
+ active.delete(controller);
501
+ if (disposed) return;
502
+ publishOutcome(input, request, httpResponseResult(prepared.request, response, config));
503
+ },
504
+ (error) => {
505
+ clearTimeout(timeout);
506
+ active.delete(controller);
507
+ if (disposed) return;
508
+ publishOutcome(input, request, httpErrorResult(error, config));
509
+ }
510
+ );
511
+ }
512
+ const unsubscribeInputs = opts.inputs.subscribe((msg) => {
513
+ if (msg[0] !== "DATA") return;
514
+ const input = msg[1];
515
+ if (input.providerId === providerId) inputs.set(input.adapterInputId, input);
516
+ });
517
+ const autoRunReadyInputs = opts.autoRunReadyInputs ?? (opts.runRequests === void 0 || opts.runRequests.length === 0);
518
+ const runProjector = toolProviderAdapterRunProjector(graph, {
519
+ name: `${name}/runs`,
520
+ inputs: opts.inputs,
521
+ runRequests: opts.runRequests,
522
+ autoRunReadyInputs,
523
+ now: opts.now
524
+ });
525
+ const unsubscribeRunStatus = runProjector.status.subscribe((msg) => {
526
+ if (msg[0] !== "DATA") return;
527
+ const nextStatus = msg[1];
528
+ const statusKey = `${nextStatus.runId}:${nextStatus.status}`;
529
+ if (forwardedRunStatusKeys.has(statusKey)) return;
530
+ forwardedRunStatusKeys.add(statusKey);
531
+ runStatus.down([["DATA", nextStatus]]);
532
+ });
533
+ const unsubscribeRunIssues = runProjector.issues.subscribe((msg) => {
534
+ if (msg[0] === "DATA") publishIssue(msg[1]);
535
+ });
536
+ const unsubscribeRunAudit = runProjector.audit.subscribe((msg) => {
537
+ if (msg[0] === "DATA") audit.down([["DATA", msg[1]]]);
538
+ });
539
+ const unsubscribeRunRequests = runProjector.requests.subscribe((msg) => {
540
+ if (msg[0] === "DATA") execute(msg[1]);
541
+ });
542
+ return Object.freeze({
543
+ catalogs: Object.freeze([catalog]),
544
+ runRequests: runProjector.requests,
545
+ runStatus,
546
+ outcomes,
547
+ status,
548
+ issues,
549
+ audit,
550
+ dispose() {
551
+ if (disposed) return;
552
+ disposed = true;
553
+ unsubscribeInputs();
554
+ unsubscribeRunStatus();
555
+ unsubscribeRunIssues();
556
+ unsubscribeRunAudit();
557
+ unsubscribeRunRequests();
558
+ for (const controller of active) controller.abort();
559
+ active.clear();
560
+ }
561
+ });
562
+ }
563
+ function localDateNow(input, ctx, now) {
564
+ const epochMs = now?.() ?? ctx.now?.() ?? Date.now();
565
+ return Object.freeze({
566
+ kind: "result",
567
+ result: Object.freeze({
568
+ kind: "json",
569
+ value: Object.freeze({
570
+ toolName: "date.now",
571
+ epochMs,
572
+ iso: new Date(epochMs).toISOString()
573
+ }),
574
+ summary: String(epochMs)
575
+ }),
576
+ occurredAtMs: epochMs,
577
+ evidenceRefs: input.sourceRefs
578
+ });
579
+ }
580
+ function localJsonParse(input, maxTextChars) {
581
+ const text = input.toolCall?.arguments?.text;
582
+ if (typeof text !== "string") {
583
+ return failure(
584
+ input,
585
+ "local-json-parse-missing-text",
586
+ "json.parse requires a string text argument."
587
+ );
588
+ }
589
+ if (text.length > maxTextChars) {
590
+ return failure(
591
+ input,
592
+ "local-json-parse-text-too-large",
593
+ "json.parse text exceeds maxTextChars."
594
+ );
595
+ }
596
+ try {
597
+ const value = JSON.parse(text);
598
+ return Object.freeze({
599
+ kind: "result",
600
+ result: Object.freeze({
601
+ kind: "json",
602
+ value: Object.freeze({ toolName: "json.parse", value }),
603
+ summary: "parsed JSON"
604
+ }),
605
+ evidenceRefs: input.sourceRefs
606
+ });
607
+ } catch {
608
+ return failure(input, "local-json-parse-invalid-json", "json.parse received invalid JSON.");
609
+ }
610
+ }
611
+ function localTextConcat(input, maxTextChars) {
612
+ const parts = input.toolCall?.arguments?.parts;
613
+ if (!Array.isArray(parts)) {
614
+ return failure(input, "local-text-concat-missing-parts", "text.concat requires a parts array.");
615
+ }
616
+ const separator = input.toolCall?.arguments?.separator ?? "";
617
+ if (typeof separator !== "string") {
618
+ return failure(
619
+ input,
620
+ "local-text-concat-invalid-separator",
621
+ "text.concat separator must be a string."
622
+ );
623
+ }
624
+ const text = parts.map((part) => String(part)).join(separator);
625
+ if (text.length > maxTextChars) {
626
+ return failure(
627
+ input,
628
+ "local-text-concat-too-large",
629
+ "text.concat result exceeds maxTextChars."
630
+ );
631
+ }
632
+ return Object.freeze({
633
+ kind: "result",
634
+ result: Object.freeze({
635
+ kind: "text",
636
+ value: Object.freeze({ toolName: "text.concat", text }),
637
+ summary: text
638
+ }),
639
+ evidenceRefs: input.sourceRefs
640
+ });
641
+ }
642
+ function processConfig(opts) {
643
+ const workingDirectory = resolve(opts.workingDirectory ?? ".");
644
+ const allowedWorkingDirectories = Object.freeze(
645
+ (opts.allowedWorkingDirectories ?? [workingDirectory]).map((dir) => resolve(dir))
646
+ );
647
+ const allowed = normalizeAllowedCommands(opts.allowedCommands ?? []);
648
+ return {
649
+ allowedCommands: allowed.commands,
650
+ duplicateCommands: allowed.duplicates,
651
+ invalidCommands: allowed.invalids,
652
+ workingDirectory,
653
+ allowedWorkingDirectories,
654
+ baseEnv: Object.freeze({ ...opts.baseEnv ?? {} }),
655
+ allowedEnvKeys: new Set(opts.allowedEnvKeys ?? []),
656
+ timeoutMs: positiveFinite(opts.timeoutMs, 1e4),
657
+ maxOutputBytes: Math.max(1, nonNegativeFinite(opts.maxOutputBytes, 64 * 1024)),
658
+ maxSummaryChars: Math.max(1, nonNegativeFinite(opts.maxSummaryChars, 512))
659
+ };
660
+ }
661
+ function processArguments(input) {
662
+ const raw = input.toolCall?.arguments;
663
+ if (!isRecord(raw) || typeof raw.command !== "string" || raw.command.length === 0) {
664
+ return void 0;
665
+ }
666
+ const rawArgs = raw.args === void 0 ? Object.freeze([]) : stringArray(raw.args);
667
+ if (rawArgs === void 0) return void 0;
668
+ if (raw.cwd !== void 0 && typeof raw.cwd !== "string") return void 0;
669
+ if (raw.input !== void 0 && typeof raw.input !== "string") return void 0;
670
+ const rawEnv = raw.env === void 0 ? void 0 : processArgumentEnv(raw.env);
671
+ if (raw.env !== void 0 && rawEnv === void 0) return void 0;
672
+ return {
673
+ command: raw.command,
674
+ args: rawArgs,
675
+ ...raw.cwd === void 0 ? {} : { cwd: raw.cwd },
676
+ ...rawEnv === void 0 ? {} : { env: rawEnv },
677
+ ...raw.input === void 0 ? {} : { input: raw.input }
678
+ };
679
+ }
680
+ function argsAllowed(command, args) {
681
+ if (command.allowArgs === true) return true;
682
+ if (typeof command.allowArgs === "function") return command.allowArgs(args);
683
+ if (command.allowArgs === void 0) return args.length === 0;
684
+ return arraysEqual(command.allowArgs, args);
685
+ }
686
+ function resolveProcessCwd(requestedCwd, command, config) {
687
+ const rawCwd = command.cwd ?? requestedCwd;
688
+ const cwd = rawCwd === void 0 ? config.workingDirectory : isAbsolute(rawCwd) ? resolve(rawCwd) : resolve(config.workingDirectory, rawCwd);
689
+ const realCwd = realpath(cwd);
690
+ if (realCwd === void 0) return void 0;
691
+ return config.allowedWorkingDirectories.some((allowed) => {
692
+ const realAllowed = realpath(allowed);
693
+ return realAllowed !== void 0 && isPathInside(realCwd, realAllowed);
694
+ }) ? cwd : void 0;
695
+ }
696
+ function processEnv(inputEnv, config) {
697
+ const env = { ...config.baseEnv };
698
+ for (const [key, value] of Object.entries(inputEnv ?? {})) {
699
+ if (!config.allowedEnvKeys.has(key)) return void 0;
700
+ if (value !== void 0) env[key] = String(value);
701
+ }
702
+ return Object.freeze(env);
703
+ }
704
+ function processArgumentEnv(value) {
705
+ if (!isRecord(value)) return void 0;
706
+ const env = {};
707
+ for (const [key, entry] of Object.entries(value)) {
708
+ if (entry !== void 0 && typeof entry !== "string" && typeof entry !== "number" && typeof entry !== "boolean") {
709
+ return void 0;
710
+ }
711
+ env[key] = entry;
712
+ }
713
+ return Object.freeze(env);
714
+ }
715
+ function runProcessTool(input, allowed, args, cwd, env, config) {
716
+ const executable = allowed.executable ?? args.command;
717
+ const argv = Object.freeze([...allowed.fixedArgs ?? [], ...args.args]);
718
+ const result = spawnSync(executable, argv, {
719
+ cwd,
720
+ env,
721
+ input: args.input,
722
+ encoding: "buffer",
723
+ shell: false,
724
+ timeout: config.timeoutMs,
725
+ maxBuffer: config.maxOutputBytes + 1
726
+ });
727
+ const stdout = result.stdout ?? Buffer.alloc(0);
728
+ const stderr = result.stderr ?? Buffer.alloc(0);
729
+ const truncated = stdout.length + stderr.length > config.maxOutputBytes;
730
+ if (result.error !== void 0 && isTimeoutError(result.error)) {
731
+ return Object.freeze({
732
+ kind: "timeout",
733
+ timeoutMs: config.timeoutMs,
734
+ retryable: true,
735
+ evidenceRefs: input.sourceRefs
736
+ });
737
+ }
738
+ if (result.error !== void 0 || truncated) {
739
+ return failure(
740
+ input,
741
+ truncated || isOutputLimitError(result.error) ? "process-output-limit-exceeded" : "process-spawn-failed",
742
+ truncated || isOutputLimitError(result.error) ? "Process output exceeded maxOutputBytes." : "Process execution failed before producing an exit result."
743
+ );
744
+ }
745
+ const value = processResult(
746
+ args.command,
747
+ argv,
748
+ cwd,
749
+ result.status,
750
+ result.signal,
751
+ stdout,
752
+ stderr,
753
+ config
754
+ );
755
+ if ((result.status ?? 1) !== 0) {
756
+ return Object.freeze({
757
+ kind: "failure",
758
+ error: issue("process-exit-nonzero", "Process exited with a non-zero status.", "error", {
759
+ exitCode: result.status,
760
+ signal: result.signal ?? void 0
761
+ }),
762
+ retryable: false,
763
+ evidenceRefs: input.sourceRefs,
764
+ metadata: Object.freeze({
765
+ command: args.command,
766
+ exitCode: result.status,
767
+ signal: result.signal ?? void 0,
768
+ outputBytes: value.outputBytes,
769
+ errorOutputBytes: value.errorOutputBytes
770
+ })
771
+ });
772
+ }
773
+ return Object.freeze({
774
+ kind: "result",
775
+ result: Object.freeze({
776
+ kind: "process-result",
777
+ value,
778
+ summary: value.outputPreview ?? `process exited ${value.exitCode ?? 0}`,
779
+ artifacts: processArtifacts(stdout, stderr, config, input.sourceRefs)
780
+ }),
781
+ evidenceRefs: input.sourceRefs
782
+ });
783
+ }
784
+ function processResult(command, args, cwd, exitCode, signal, stdout, stderr, config) {
785
+ return Object.freeze({
786
+ command,
787
+ args,
788
+ cwd,
789
+ exitCode,
790
+ ...signal === null ? {} : { signal },
791
+ outputPreview: preview(stdout, config.maxSummaryChars),
792
+ errorPreview: preview(stderr, config.maxSummaryChars),
793
+ outputBytes: stdout.length,
794
+ errorOutputBytes: stderr.length,
795
+ truncated: false
796
+ });
797
+ }
798
+ function processArtifacts(stdout, stderr, config, sourceRefs) {
799
+ const artifacts = [
800
+ processTextArtifact("process-stdout", stdout, config, sourceRefs),
801
+ processTextArtifact("process-stderr", stderr, config, sourceRefs)
802
+ ].filter((artifact) => artifact !== void 0);
803
+ return artifacts.length === 0 ? void 0 : Object.freeze(artifacts);
804
+ }
805
+ function processTextArtifact(kind, bytes, config, sourceRefs) {
806
+ if (bytes.length === 0) return void 0;
807
+ const text = bytes.toString("utf8");
808
+ const inline = text.length <= config.maxSummaryChars;
809
+ return Object.freeze({
810
+ kind,
811
+ format: "text",
812
+ mediaType: "text/plain",
813
+ encoding: "utf8",
814
+ byteLength: bytes.length,
815
+ dataMode: inline ? "inline" : "summary",
816
+ summary: preview(bytes, config.maxSummaryChars),
817
+ ...inline ? { value: text } : {},
818
+ ...sourceRefs === void 0 ? {} : { sourceRefs },
819
+ sizeEvidence: Object.freeze([
820
+ sizeEvidence(bytes.length, "adapter-measured-process-output", sourceRefs)
821
+ ])
822
+ });
823
+ }
824
+ function processToolProviderExecutionPolicy(providerId, profileId, opts) {
825
+ const maxOutputBytes = Math.max(1, nonNegativeFinite(opts.maxOutputBytes, 64 * 1024));
826
+ return Object.freeze({
827
+ kind: "tool-provider-execution-policy",
828
+ policyId: `${providerId}:policy:process-v0`,
829
+ providerId,
830
+ profileIds: Object.freeze([profileId]),
831
+ toolNames: Object.freeze(["process.execFile"]),
832
+ operations: Object.freeze(["run"]),
833
+ sizeCapacity: Object.freeze({
834
+ limits: Object.freeze([
835
+ Object.freeze({
836
+ unit: "bytes",
837
+ hardLimit: maxOutputBytes,
838
+ perRequest: true,
839
+ measurementSource: "adapter-measured"
840
+ })
841
+ ])
842
+ }),
843
+ timeout: Object.freeze({ timeoutMs: positiveFinite(opts.timeoutMs, 1e4) }),
844
+ redaction: Object.freeze({
845
+ mode: "summary",
846
+ summaryMaxChars: nonNegativeFinite(opts.maxSummaryChars, 512)
847
+ }),
848
+ filesystem: Object.freeze({
849
+ cwd: opts.workingDirectory ?? ".",
850
+ allowRead: false,
851
+ allowWrite: false,
852
+ followSymlinks: false,
853
+ pathRules: Object.freeze(
854
+ (opts.allowedWorkingDirectories ?? [opts.workingDirectory ?? "."]).map(
855
+ (path) => Object.freeze({
856
+ effect: "allow",
857
+ path,
858
+ operation: "run",
859
+ reason: "Process adapter cwd allowlist."
860
+ })
861
+ )
862
+ )
863
+ }),
864
+ approval: Object.freeze({ mode: "auto" }),
865
+ metadata: Object.freeze({
866
+ argv: true,
867
+ shell: false,
868
+ allowedEnvKeys: Object.freeze([...opts.allowedEnvKeys ?? []])
869
+ })
870
+ });
871
+ }
872
+ function httpRuntimeConfig(opts) {
873
+ return {
874
+ allowedOrigins: new Set(opts.allowedOrigins ?? []),
875
+ allowedMethods: new Set(normalizeMethods(opts.allowedMethods ?? ["GET"])),
876
+ allowedRequestHeaders: new Set(normalizeHeaderNames(opts.allowedRequestHeaders ?? [])),
877
+ exposedResponseHeaders: new Set(normalizeHeaderNames(opts.exposedResponseHeaders ?? [])),
878
+ timeoutMs: positiveFinite(opts.timeoutMs, 1e4),
879
+ maxResponseBytes: Math.max(1, nonNegativeFinite(opts.maxResponseBytes, 64 * 1024)),
880
+ maxInlineBodyChars: Math.max(1, nonNegativeFinite(opts.maxInlineBodyChars, 4096)),
881
+ approvalMode: opts.approvalMode ?? "auto"
882
+ };
883
+ }
884
+ function httpToolProviderExecutionPolicy(providerId, profileId, opts) {
885
+ const allowedOrigins = Object.freeze([...opts.allowedOrigins ?? []]);
886
+ const allowedMethods = Object.freeze(normalizeMethods(opts.allowedMethods ?? ["GET"]));
887
+ const maxResponseBytes = Math.max(1, nonNegativeFinite(opts.maxResponseBytes, 64 * 1024));
888
+ return Object.freeze({
889
+ kind: "tool-provider-execution-policy",
890
+ policyId: `${providerId}:policy:http-v0`,
891
+ providerId,
892
+ profileIds: Object.freeze([profileId]),
893
+ toolNames: Object.freeze(["http.fetch"]),
894
+ operations: Object.freeze(["fetch"]),
895
+ sizeCapacity: Object.freeze({
896
+ limits: Object.freeze([
897
+ Object.freeze({
898
+ unit: "bytes",
899
+ hardLimit: maxResponseBytes,
900
+ perRequest: true,
901
+ measurementSource: "adapter-measured-response-body"
902
+ })
903
+ ])
904
+ }),
905
+ timeout: Object.freeze({ timeoutMs: positiveFinite(opts.timeoutMs, 1e4) }),
906
+ redaction: Object.freeze({
907
+ mode: "summary",
908
+ summaryMaxChars: nonNegativeFinite(opts.maxInlineBodyChars, 4096)
909
+ }),
910
+ network: Object.freeze({
911
+ mode: "allowlist",
912
+ protocols: Object.freeze(["http:", "https:"]),
913
+ allowedHosts: allowedOrigins,
914
+ metadata: Object.freeze({ allowlistKind: "origin" })
915
+ }),
916
+ approval: Object.freeze({ mode: opts.approvalMode ?? "auto" }),
917
+ artifacts: Object.freeze({
918
+ defaultDataMode: "summary",
919
+ inlineLimits: Object.freeze([
920
+ Object.freeze({
921
+ unit: "chars",
922
+ hardLimit: Math.max(1, nonNegativeFinite(opts.maxInlineBodyChars, 4096)),
923
+ perArtifact: true,
924
+ measurementSource: "js-string-length"
925
+ })
926
+ ]),
927
+ artifactKinds: Object.freeze(["http-response-body"])
928
+ }),
929
+ metadata: Object.freeze({
930
+ allowedOrigins,
931
+ allowedMethods,
932
+ allowedRequestHeaders: Object.freeze([...opts.allowedRequestHeaders ?? []]),
933
+ exposedResponseHeaders: Object.freeze([...opts.exposedResponseHeaders ?? []]),
934
+ asyncRuntime: true
935
+ })
936
+ });
937
+ }
938
+ function prepareHttpRequest(input, config) {
939
+ const raw = input.toolCall?.arguments;
940
+ if (!isRecord(raw) || typeof raw.url !== "string") {
941
+ return {
942
+ kind: "blocked",
943
+ issue: issue("http-invalid-arguments", "http.fetch requires a string url argument.")
944
+ };
945
+ }
946
+ let url;
947
+ try {
948
+ url = new URL(raw.url);
949
+ } catch {
950
+ return { kind: "blocked", issue: issue("http-invalid-url", "http.fetch url is invalid.") };
951
+ }
952
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
953
+ return {
954
+ kind: "blocked",
955
+ issue: issue("http-protocol-not-allowed", "http.fetch only allows http and https URLs.")
956
+ };
957
+ }
958
+ if (!config.allowedOrigins.has(url.origin)) {
959
+ return {
960
+ kind: "blocked",
961
+ issue: issue("http-origin-not-allowed", "http.fetch origin is not allowlisted.")
962
+ };
963
+ }
964
+ const method = normalizeMethod(raw.method ?? "GET");
965
+ if (method === void 0 || !config.allowedMethods.has(method)) {
966
+ return {
967
+ kind: "blocked",
968
+ issue: issue("http-method-not-allowed", "http.fetch method is not allowlisted.")
969
+ };
970
+ }
971
+ if (raw.body !== void 0 && typeof raw.body !== "string") {
972
+ return {
973
+ kind: "blocked",
974
+ issue: issue("http-invalid-body", "http.fetch body must be a string when provided.")
975
+ };
976
+ }
977
+ const headers = httpArgumentHeaders(raw.headers, config);
978
+ if (headers === void 0) {
979
+ return {
980
+ kind: "blocked",
981
+ issue: issue("http-request-header-not-allowed", "http.fetch header is not allowlisted.")
982
+ };
983
+ }
984
+ return {
985
+ kind: "ready",
986
+ request: Object.freeze({
987
+ url: url.toString(),
988
+ method,
989
+ headers,
990
+ ...raw.body === void 0 ? {} : { body: raw.body }
991
+ })
992
+ };
993
+ }
994
+ function httpArgumentHeaders(value, config) {
995
+ if (value === void 0) return Object.freeze({});
996
+ if (!isRecord(value)) return void 0;
997
+ const headers = {};
998
+ for (const [key, entry] of Object.entries(value)) {
999
+ const normalized = key.toLowerCase();
1000
+ if (!config.allowedRequestHeaders.has(normalized)) return void 0;
1001
+ if (entry !== void 0 && typeof entry !== "string" && typeof entry !== "number" && typeof entry !== "boolean") {
1002
+ return void 0;
1003
+ }
1004
+ if (entry !== void 0) headers[key] = String(entry);
1005
+ }
1006
+ return Object.freeze(headers);
1007
+ }
1008
+ function httpResponseResult(request, response, config) {
1009
+ const hasInlineBody = response.bodyText !== void 0;
1010
+ const bodyText = response.bodyText ?? "";
1011
+ const bodyBytes = response.bodyBytes ?? textBytes(bodyText);
1012
+ const hasBodyRef = response.bodyRef !== void 0;
1013
+ if (bodyBytes > config.maxResponseBytes && !hasBodyRef) {
1014
+ return {
1015
+ kind: "failure",
1016
+ error: issue("http-response-too-large", "HTTP response body exceeded maxResponseBytes."),
1017
+ retryable: false,
1018
+ metadata: Object.freeze({ bodyBytes, maxResponseBytes: config.maxResponseBytes })
1019
+ };
1020
+ }
1021
+ const inline = hasInlineBody && bodyBytes <= config.maxResponseBytes && bodyText.length <= config.maxInlineBodyChars;
1022
+ const result = Object.freeze({
1023
+ url: response.url ?? request.url,
1024
+ method: request.method,
1025
+ status: response.status,
1026
+ statusText: response.statusText ?? "",
1027
+ headers: filterResponseHeaders(response.headers, config.exposedResponseHeaders),
1028
+ bodyPreview: hasInlineBody ? previewText(bodyText, config.maxInlineBodyChars) : void 0,
1029
+ ...inline ? { bodyText } : {},
1030
+ bodyBytes,
1031
+ bodyTruncated: bodyBytes > config.maxResponseBytes || bodyText.length > config.maxInlineBodyChars,
1032
+ dataMode: inline ? "inline" : hasBodyRef ? "ref" : "summary",
1033
+ ...response.bodyRef === void 0 ? {} : { bodyRef: response.bodyRef }
1034
+ });
1035
+ return {
1036
+ kind: "result",
1037
+ result: Object.freeze({
1038
+ kind: "http-result",
1039
+ value: result,
1040
+ summary: `${request.method} ${response.status} ${response.url ?? request.url}`,
1041
+ refs: response.bodyRef === void 0 ? void 0 : Object.freeze([response.bodyRef]),
1042
+ artifacts: Object.freeze([httpBodyArtifact(result, response.bodyRef)])
1043
+ }),
1044
+ issues: !inline && !hasBodyRef ? Object.freeze([
1045
+ issue(
1046
+ "http-response-body-summary-only",
1047
+ "HTTP response body was summarized without a durable body ref.",
1048
+ "warning"
1049
+ )
1050
+ ]) : void 0,
1051
+ metadata: Object.freeze({ status: response.status, bodyBytes })
1052
+ };
1053
+ }
1054
+ function httpBodyArtifact(result, bodyRef) {
1055
+ return Object.freeze({
1056
+ kind: "http-response-body",
1057
+ format: "text",
1058
+ byteLength: result.bodyBytes,
1059
+ dataMode: result.dataMode,
1060
+ ...result.bodyPreview === void 0 ? {} : { summary: result.bodyPreview },
1061
+ ...result.dataMode === "inline" && result.bodyText !== void 0 ? { value: result.bodyText } : {},
1062
+ ...bodyRef === void 0 ? {} : { ref: bodyRef, refs: Object.freeze([bodyRef]) },
1063
+ sizeEvidence: Object.freeze([
1064
+ sizeEvidence(result.bodyBytes, "adapter-measured-http-response-body", void 0)
1065
+ ])
1066
+ });
1067
+ }
1068
+ function httpErrorResult(error, config) {
1069
+ const aborted = error instanceof Error && error.name === "AbortError";
1070
+ if (aborted) {
1071
+ return { kind: "timeout", timeoutMs: config.timeoutMs, retryable: true };
1072
+ }
1073
+ return {
1074
+ kind: "failure",
1075
+ error: issue("http-fetch-failed", "HTTP fetch failed before producing a response."),
1076
+ retryable: true,
1077
+ metadata: Object.freeze({ errorType: error instanceof Error ? error.name : typeof error })
1078
+ };
1079
+ }
1080
+ function defaultHttpToolProviderDriver(maxResponseBytes) {
1081
+ return Object.freeze({
1082
+ fetch(request) {
1083
+ const fetchImpl = globalThis.fetch;
1084
+ if (typeof fetchImpl !== "function") {
1085
+ throw new Error("global fetch is unavailable");
1086
+ }
1087
+ return fetchImpl(request.url, {
1088
+ method: request.method,
1089
+ headers: request.headers,
1090
+ body: request.body,
1091
+ redirect: "manual",
1092
+ signal: request.signal
1093
+ }).then(
1094
+ (response) => readResponseBody(response, maxResponseBytes).then(
1095
+ (body) => Object.freeze({
1096
+ url: response.url,
1097
+ status: response.status,
1098
+ statusText: response.statusText,
1099
+ headers: responseHeaders(response.headers),
1100
+ bodyText: body.text,
1101
+ bodyBytes: body.bytes
1102
+ })
1103
+ )
1104
+ );
1105
+ }
1106
+ });
1107
+ }
1108
+ function readResponseBody(response, maxBytes) {
1109
+ const body = response.body;
1110
+ if (body === null) return Promise.resolve({ text: "", bytes: 0 });
1111
+ const reader = body.getReader();
1112
+ const decoder = new TextDecoder();
1113
+ const chunks = [];
1114
+ let bytes = 0;
1115
+ function pump() {
1116
+ return reader.read().then((next) => {
1117
+ if (next.done) {
1118
+ chunks.push(decoder.decode());
1119
+ return { text: chunks.join(""), bytes };
1120
+ }
1121
+ bytes += next.value.byteLength;
1122
+ if (bytes > maxBytes) {
1123
+ reader.cancel().catch(() => {
1124
+ });
1125
+ return { text: chunks.join(""), bytes };
1126
+ }
1127
+ chunks.push(decoder.decode(next.value, { stream: true }));
1128
+ return pump();
1129
+ });
1130
+ }
1131
+ return pump();
1132
+ }
1133
+ function responseHeaders(headers) {
1134
+ const out = {};
1135
+ headers.forEach((value, key) => {
1136
+ out[key] = value;
1137
+ });
1138
+ return Object.freeze(out);
1139
+ }
1140
+ function filterResponseHeaders(headers, exposed) {
1141
+ if (headers === void 0 || exposed.size === 0) return void 0;
1142
+ const out = {};
1143
+ for (const [key, value] of Object.entries(headers)) {
1144
+ if (exposed.has(key.toLowerCase())) out[key] = value;
1145
+ }
1146
+ return Object.keys(out).length === 0 ? void 0 : Object.freeze(out);
1147
+ }
1148
+ function requestMatchesInput(request, input) {
1149
+ return request.adapterInputId === input.adapterInputId && request.requestId === input.requestId && request.operationId === input.operationId && (request.routeId === void 0 || request.routeId === input.routeId) && (request.executorId === void 0 || request.executorId === input.executorId) && (request.profileId === void 0 || request.profileId === input.profileId);
1150
+ }
1151
+ function requestApproved(request) {
1152
+ const metadata = request.metadata;
1153
+ return isRecord(metadata) && (metadata.approval === "granted" || metadata.approvalGranted === true || isAdmissionApprovedMetadata(metadata) && hasAdmissionSourceRef(request.sourceRefs));
1154
+ }
1155
+ function isAdmissionApprovedMetadata(metadata) {
1156
+ return typeof metadata.admissionId === "string" && metadata.admissionId.length > 0 && typeof metadata.proposalId === "string" && metadata.proposalId.length > 0 && typeof metadata.approvedFromRunId === "string" && metadata.approvedFromRunId.length > 0;
1157
+ }
1158
+ function hasAdmissionSourceRef(sourceRefs) {
1159
+ return (sourceRefs ?? []).some(
1160
+ (sourceRef) => sourceRef.kind === "tool-provider-run-admission" || sourceRef.kind === "tool-provider-run-admission-decision"
1161
+ );
1162
+ }
1163
+ function defaultEvidenceRefs(input) {
1164
+ return Object.freeze([
1165
+ { kind: "tool-provider-adapter-input", id: input.adapterInputId },
1166
+ ...input.sourceRefs ?? []
1167
+ ]);
1168
+ }
1169
+ function outcomeIssues(outcome) {
1170
+ if (outcome.kind === "failure") return Object.freeze([outcome.error, ...outcome.issues ?? []]);
1171
+ return outcome.issues ?? [];
1172
+ }
1173
+ function agentStatusForOutcome(outcome) {
1174
+ switch (outcome.kind) {
1175
+ case "result":
1176
+ return "completed";
1177
+ case "failure":
1178
+ return "failed";
1179
+ case "blocked":
1180
+ return "blocked";
1181
+ case "canceled":
1182
+ return "canceled";
1183
+ case "timeout":
1184
+ return "timeout";
1185
+ }
1186
+ }
1187
+ function normalizeMethods(methods) {
1188
+ return Object.freeze(
1189
+ methods.map((method) => normalizeMethod(method)).filter((method) => method !== void 0)
1190
+ );
1191
+ }
1192
+ function normalizeMethod(method) {
1193
+ return typeof method === "string" && method.length > 0 ? method.toUpperCase() : void 0;
1194
+ }
1195
+ function normalizeHeaderNames(headers) {
1196
+ return Object.freeze(
1197
+ headers.filter((header) => typeof header === "string" && header.length > 0).map((header) => header.toLowerCase())
1198
+ );
1199
+ }
1200
+ function textBytes(text) {
1201
+ return new TextEncoder().encode(text).byteLength;
1202
+ }
1203
+ function previewText(text, maxChars) {
1204
+ if (text.length === 0) return void 0;
1205
+ return text.length <= maxChars ? text : text.slice(0, maxChars);
1206
+ }
1207
+ function blocked(input, code, message) {
1208
+ return Object.freeze({
1209
+ kind: "blocked",
1210
+ needs: Object.freeze([
1211
+ Object.freeze({
1212
+ kind: code,
1213
+ message,
1214
+ refs: input.providerId === void 0 ? void 0 : Object.freeze([{ kind: "tool-provider", id: input.providerId }])
1215
+ })
1216
+ ]),
1217
+ issues: Object.freeze([issue(code, message, "error")]),
1218
+ evidenceRefs: input.sourceRefs
1219
+ });
1220
+ }
1221
+ function failure(input, code, message) {
1222
+ return Object.freeze({
1223
+ kind: "failure",
1224
+ error: issue(code, message, "error"),
1225
+ retryable: false,
1226
+ evidenceRefs: input.sourceRefs
1227
+ });
1228
+ }
1229
+ function issue(code, message, severity = "error", details) {
1230
+ return Object.freeze({
1231
+ kind: "issue",
1232
+ code,
1233
+ message,
1234
+ severity,
1235
+ ...details === void 0 ? {} : { details }
1236
+ });
1237
+ }
1238
+ function sizeEvidence(quantity, measurementSource, sourceRefs) {
1239
+ return Object.freeze({
1240
+ kind: "size-capacity-evidence",
1241
+ unit: "bytes",
1242
+ quantity,
1243
+ measurementSource,
1244
+ ...sourceRefs === void 0 ? {} : { sourceRefs }
1245
+ });
1246
+ }
1247
+ function nonNegativeFinite(value, fallback) {
1248
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : fallback;
1249
+ }
1250
+ function positiveFinite(value, fallback) {
1251
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
1252
+ }
1253
+ function isRecord(value) {
1254
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1255
+ }
1256
+ function stringArray(value) {
1257
+ if (!Array.isArray(value)) return void 0;
1258
+ const entries = Array.from(value);
1259
+ if (!entries.every((entry) => typeof entry === "string")) return void 0;
1260
+ return Object.freeze(entries);
1261
+ }
1262
+ function arraysEqual(a, b) {
1263
+ return a.length === b.length && a.every((value, index) => value === b[index]);
1264
+ }
1265
+ function normalizeAllowedCommands(commands) {
1266
+ const out = /* @__PURE__ */ new Map();
1267
+ const duplicates = /* @__PURE__ */ new Set();
1268
+ const invalids = /* @__PURE__ */ new Set();
1269
+ for (const command of commands) {
1270
+ if (typeof command.command !== "string" || command.command.length === 0) {
1271
+ invalids.add("<invalid-command>");
1272
+ continue;
1273
+ }
1274
+ const frozen = freezeAllowedCommand(command);
1275
+ if (frozen === void 0) {
1276
+ out.delete(command.command);
1277
+ invalids.add(command.command);
1278
+ continue;
1279
+ }
1280
+ if (out.has(command.command)) {
1281
+ out.delete(command.command);
1282
+ duplicates.add(command.command);
1283
+ continue;
1284
+ }
1285
+ if (duplicates.has(command.command) || invalids.has(command.command)) continue;
1286
+ out.set(command.command, frozen);
1287
+ }
1288
+ return { commands: out, duplicates, invalids };
1289
+ }
1290
+ function freezeAllowedCommand(command) {
1291
+ const fixedArgs = command.fixedArgs === void 0 ? void 0 : stringArray(command.fixedArgs);
1292
+ if (command.fixedArgs !== void 0 && fixedArgs === void 0) return void 0;
1293
+ const allowArgs = Array.isArray(command.allowArgs) ? stringArray(command.allowArgs) : command.allowArgs;
1294
+ if (Array.isArray(command.allowArgs) && allowArgs === void 0) return void 0;
1295
+ return Object.freeze({
1296
+ command: command.command,
1297
+ ...command.executable === void 0 ? {} : { executable: command.executable },
1298
+ ...fixedArgs === void 0 ? {} : { fixedArgs },
1299
+ ...allowArgs === void 0 ? {} : { allowArgs },
1300
+ ...command.cwd === void 0 ? {} : { cwd: command.cwd }
1301
+ });
1302
+ }
1303
+ function realpath(path) {
1304
+ try {
1305
+ return realpathSync.native(path);
1306
+ } catch {
1307
+ return void 0;
1308
+ }
1309
+ }
1310
+ function isPathInside(path, root) {
1311
+ const normalizedPath = resolve(path);
1312
+ const normalizedRoot = resolve(root);
1313
+ const rel = relative(normalizedRoot, normalizedPath);
1314
+ return rel === "" || rel.length > 0 && !rel.startsWith("..") && !isAbsolute(rel);
1315
+ }
1316
+ function isTimeoutError(error) {
1317
+ return error.code === "ETIMEDOUT";
1318
+ }
1319
+ function isOutputLimitError(error) {
1320
+ return error?.code === "ENOBUFS";
1321
+ }
1322
+ function preview(buffer, maxChars) {
1323
+ if (buffer.length === 0) return void 0;
1324
+ const text = buffer.toString("utf8");
1325
+ return text.length <= maxChars ? text : text.slice(0, maxChars);
1326
+ }
1327
+ export {
1328
+ httpToolProviderCatalog,
1329
+ httpToolProviderRuntime,
1330
+ localBuiltinToolProviderAdapterPack,
1331
+ localBuiltinToolProviderBinding,
1332
+ processToolProviderAdapterPack,
1333
+ processToolProviderBinding,
1334
+ processToolProviderCatalog
1335
+ };
1336
+ //# sourceMappingURL=tool-provider-adapters.js.map