@assemblyline-agents/runtime 2.0.0 → 3.1.0

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 (389) hide show
  1. package/LICENSE +1 -1
  2. package/dist/a2a-client.d.ts +22 -0
  3. package/dist/a2a-client.d.ts.map +1 -0
  4. package/dist/a2a-client.js +211 -0
  5. package/dist/a2a-client.js.map +1 -0
  6. package/dist/agent-hook-context.d.ts +6 -1
  7. package/dist/agent-hook-context.d.ts.map +1 -1
  8. package/dist/agent-hook-context.js +24 -11
  9. package/dist/agent-hook-context.js.map +1 -1
  10. package/dist/agent-hook-evaluation.d.ts +6 -1
  11. package/dist/agent-hook-evaluation.d.ts.map +1 -1
  12. package/dist/agent-hook-evaluation.js +16 -5
  13. package/dist/agent-hook-evaluation.js.map +1 -1
  14. package/dist/agent-hook-run-lifecycle.d.ts +5 -1
  15. package/dist/agent-hook-run-lifecycle.d.ts.map +1 -1
  16. package/dist/agent-hook-run-lifecycle.js +11 -13
  17. package/dist/agent-hook-run-lifecycle.js.map +1 -1
  18. package/dist/agent-surface.d.ts +32 -0
  19. package/dist/agent-surface.d.ts.map +1 -0
  20. package/dist/agent-surface.js +85 -0
  21. package/dist/agent-surface.js.map +1 -0
  22. package/dist/attachments.d.ts +5 -1
  23. package/dist/attachments.d.ts.map +1 -1
  24. package/dist/attachments.js +58 -32
  25. package/dist/attachments.js.map +1 -1
  26. package/dist/audience.d.ts +30 -0
  27. package/dist/audience.d.ts.map +1 -0
  28. package/dist/audience.js +68 -0
  29. package/dist/audience.js.map +1 -0
  30. package/dist/automation-event-match.d.ts +8 -0
  31. package/dist/automation-event-match.d.ts.map +1 -0
  32. package/dist/automation-event-match.js +25 -0
  33. package/dist/automation-event-match.js.map +1 -0
  34. package/dist/background-review-trigger.d.ts.map +1 -1
  35. package/dist/background-review-trigger.js +14 -16
  36. package/dist/background-review-trigger.js.map +1 -1
  37. package/dist/background-review-types.d.ts +9 -2
  38. package/dist/background-review-types.d.ts.map +1 -1
  39. package/dist/background-review-worker.js +2 -2
  40. package/dist/background-review-worker.js.map +1 -1
  41. package/dist/background-review.d.ts.map +1 -1
  42. package/dist/background-review.js +27 -10
  43. package/dist/background-review.js.map +1 -1
  44. package/dist/builtin-tool-executors.d.ts +47 -21
  45. package/dist/builtin-tool-executors.d.ts.map +1 -1
  46. package/dist/builtin-tool-executors.js +293 -121
  47. package/dist/builtin-tool-executors.js.map +1 -1
  48. package/dist/builtin-tools.d.ts +16 -8
  49. package/dist/builtin-tools.d.ts.map +1 -1
  50. package/dist/builtin-tools.js +309 -70
  51. package/dist/builtin-tools.js.map +1 -1
  52. package/dist/capability-catalog.d.ts +3 -2
  53. package/dist/capability-catalog.d.ts.map +1 -1
  54. package/dist/capability-catalog.js +10 -6
  55. package/dist/capability-catalog.js.map +1 -1
  56. package/dist/capability-inspection.d.ts +31 -0
  57. package/dist/capability-inspection.d.ts.map +1 -0
  58. package/dist/capability-inspection.js +58 -0
  59. package/dist/capability-inspection.js.map +1 -0
  60. package/dist/channel-http-util.d.ts.map +1 -1
  61. package/dist/channel-http-util.js +6 -2
  62. package/dist/channel-http-util.js.map +1 -1
  63. package/dist/channel-ingress.d.ts +16 -1
  64. package/dist/channel-ingress.d.ts.map +1 -1
  65. package/dist/channel-ingress.js +117 -7
  66. package/dist/channel-ingress.js.map +1 -1
  67. package/dist/channel.d.ts +58 -2
  68. package/dist/channel.d.ts.map +1 -1
  69. package/dist/checkpoints.d.ts +1 -1
  70. package/dist/checkpoints.d.ts.map +1 -1
  71. package/dist/checkpoints.js +6 -6
  72. package/dist/checkpoints.js.map +1 -1
  73. package/dist/child-process-env.d.ts +7 -0
  74. package/dist/child-process-env.d.ts.map +1 -0
  75. package/dist/child-process-env.js +41 -0
  76. package/dist/child-process-env.js.map +1 -0
  77. package/dist/computer-relay-protocol.d.ts.map +1 -1
  78. package/dist/computer-relay-protocol.js +4 -4
  79. package/dist/computer-relay-protocol.js.map +1 -1
  80. package/dist/concurrency.d.ts +1 -1
  81. package/dist/concurrency.js +1 -1
  82. package/dist/connection-auth-util.d.ts +1 -0
  83. package/dist/connection-auth-util.d.ts.map +1 -1
  84. package/dist/connection-auth-util.js +1 -1
  85. package/dist/connection-auth-util.js.map +1 -1
  86. package/dist/connection-clients.d.ts +11 -3
  87. package/dist/connection-clients.d.ts.map +1 -1
  88. package/dist/connection-clients.js +71 -8
  89. package/dist/connection-clients.js.map +1 -1
  90. package/dist/connection-event-store.d.ts +98 -0
  91. package/dist/connection-event-store.d.ts.map +1 -0
  92. package/dist/connection-event-store.js +162 -0
  93. package/dist/connection-event-store.js.map +1 -0
  94. package/dist/connection-events.d.ts +51 -0
  95. package/dist/connection-events.d.ts.map +1 -0
  96. package/dist/connection-events.js +343 -0
  97. package/dist/connection-events.js.map +1 -0
  98. package/dist/connection-stores.d.ts +3 -0
  99. package/dist/connection-stores.d.ts.map +1 -1
  100. package/dist/connection-stores.js +4 -1
  101. package/dist/connection-stores.js.map +1 -1
  102. package/dist/connection-util.d.ts +3 -2
  103. package/dist/connection-util.d.ts.map +1 -1
  104. package/dist/connection-util.js +18 -1
  105. package/dist/connection-util.js.map +1 -1
  106. package/dist/connections.d.ts +54 -5
  107. package/dist/connections.d.ts.map +1 -1
  108. package/dist/connections.js +342 -53
  109. package/dist/connections.js.map +1 -1
  110. package/dist/context-policy-util.d.ts.map +1 -1
  111. package/dist/context-policy-util.js +1 -3
  112. package/dist/context-policy-util.js.map +1 -1
  113. package/dist/conversation-context.d.ts +6 -2
  114. package/dist/conversation-context.d.ts.map +1 -1
  115. package/dist/conversation-context.js +45 -12
  116. package/dist/conversation-context.js.map +1 -1
  117. package/dist/conversation-transcript.d.ts +8 -5
  118. package/dist/conversation-transcript.d.ts.map +1 -1
  119. package/dist/conversation-transcript.js +24 -5
  120. package/dist/conversation-transcript.js.map +1 -1
  121. package/dist/conversation-turn-coalescing.d.ts +22 -0
  122. package/dist/conversation-turn-coalescing.d.ts.map +1 -0
  123. package/dist/conversation-turn-coalescing.js +121 -0
  124. package/dist/conversation-turn-coalescing.js.map +1 -0
  125. package/dist/conversation-turn-dispatch.d.ts +5 -2
  126. package/dist/conversation-turn-dispatch.d.ts.map +1 -1
  127. package/dist/conversation-turn-dispatch.js +59 -22
  128. package/dist/conversation-turn-dispatch.js.map +1 -1
  129. package/dist/default-outbound-route.d.ts +29 -0
  130. package/dist/default-outbound-route.d.ts.map +1 -0
  131. package/dist/default-outbound-route.js +105 -0
  132. package/dist/default-outbound-route.js.map +1 -0
  133. package/dist/delivery-artifacts.d.ts +2 -0
  134. package/dist/delivery-artifacts.d.ts.map +1 -0
  135. package/dist/delivery-artifacts.js +34 -0
  136. package/dist/delivery-artifacts.js.map +1 -0
  137. package/dist/delivery-files.d.ts +5 -0
  138. package/dist/delivery-files.d.ts.map +1 -0
  139. package/dist/delivery-files.js +33 -0
  140. package/dist/delivery-files.js.map +1 -0
  141. package/dist/delivery-queue.d.ts +21 -1
  142. package/dist/delivery-queue.d.ts.map +1 -1
  143. package/dist/delivery-queue.js +144 -1
  144. package/dist/delivery-queue.js.map +1 -1
  145. package/dist/delivery-send.d.ts +2 -2
  146. package/dist/delivery-send.d.ts.map +1 -1
  147. package/dist/delivery-send.js +256 -100
  148. package/dist/delivery-send.js.map +1 -1
  149. package/dist/durable-files.d.ts +37 -0
  150. package/dist/durable-files.d.ts.map +1 -0
  151. package/dist/durable-files.js +63 -0
  152. package/dist/durable-files.js.map +1 -0
  153. package/dist/harness-loop.d.ts +6 -1
  154. package/dist/harness-loop.d.ts.map +1 -1
  155. package/dist/harness-loop.js +110 -25
  156. package/dist/harness-loop.js.map +1 -1
  157. package/dist/heic-transcode-worker.d.ts +2 -0
  158. package/dist/heic-transcode-worker.d.ts.map +1 -0
  159. package/dist/heic-transcode-worker.js +59 -0
  160. package/dist/heic-transcode-worker.js.map +1 -0
  161. package/dist/heic-transcode.d.ts +18 -0
  162. package/dist/heic-transcode.d.ts.map +1 -0
  163. package/dist/heic-transcode.js +99 -0
  164. package/dist/heic-transcode.js.map +1 -0
  165. package/dist/human-input-routing.d.ts +22 -0
  166. package/dist/human-input-routing.d.ts.map +1 -0
  167. package/dist/human-input-routing.js +26 -0
  168. package/dist/human-input-routing.js.map +1 -0
  169. package/dist/in-memory-conversation-turn-store.d.ts +3 -1
  170. package/dist/in-memory-conversation-turn-store.d.ts.map +1 -1
  171. package/dist/in-memory-conversation-turn-store.js +41 -2
  172. package/dist/in-memory-conversation-turn-store.js.map +1 -1
  173. package/dist/in-memory-run-store.d.ts +8 -0
  174. package/dist/in-memory-run-store.d.ts.map +1 -1
  175. package/dist/in-memory-run-store.js +28 -5
  176. package/dist/in-memory-run-store.js.map +1 -1
  177. package/dist/in-memory-sandbox-session-store.d.ts +2 -1
  178. package/dist/in-memory-sandbox-session-store.d.ts.map +1 -1
  179. package/dist/in-memory-sandbox-session-store.js +65 -1
  180. package/dist/in-memory-sandbox-session-store.js.map +1 -1
  181. package/dist/in-memory-small-stores.d.ts +18 -1
  182. package/dist/in-memory-small-stores.d.ts.map +1 -1
  183. package/dist/in-memory-small-stores.js +107 -1
  184. package/dist/in-memory-small-stores.js.map +1 -1
  185. package/dist/in-memory-workspace-store.d.ts +40 -0
  186. package/dist/in-memory-workspace-store.d.ts.map +1 -0
  187. package/dist/in-memory-workspace-store.js +370 -0
  188. package/dist/in-memory-workspace-store.js.map +1 -0
  189. package/dist/index.d.ts +73 -36
  190. package/dist/index.d.ts.map +1 -1
  191. package/dist/index.js +390 -258
  192. package/dist/index.js.map +1 -1
  193. package/dist/json-util.d.ts +8 -0
  194. package/dist/json-util.d.ts.map +1 -1
  195. package/dist/json-util.js +8 -0
  196. package/dist/json-util.js.map +1 -1
  197. package/dist/local-sandbox.d.ts +3 -2
  198. package/dist/local-sandbox.d.ts.map +1 -1
  199. package/dist/local-sandbox.js +69 -25
  200. package/dist/local-sandbox.js.map +1 -1
  201. package/dist/mcp-client.d.ts.map +1 -1
  202. package/dist/mcp-client.js +3 -2
  203. package/dist/mcp-client.js.map +1 -1
  204. package/dist/media-processor.d.ts +42 -0
  205. package/dist/media-processor.d.ts.map +1 -0
  206. package/dist/media-processor.js +2 -0
  207. package/dist/media-processor.js.map +1 -0
  208. package/dist/model-media.d.ts +13 -1
  209. package/dist/model-media.d.ts.map +1 -1
  210. package/dist/model-media.js +81 -18
  211. package/dist/model-media.js.map +1 -1
  212. package/dist/model-visible-interrupts.d.ts +10 -0
  213. package/dist/model-visible-interrupts.d.ts.map +1 -0
  214. package/dist/model-visible-interrupts.js +41 -0
  215. package/dist/model-visible-interrupts.js.map +1 -0
  216. package/dist/operator-controls.d.ts.map +1 -1
  217. package/dist/operator-controls.js +16 -3
  218. package/dist/operator-controls.js.map +1 -1
  219. package/dist/outbound-http-policy.d.ts +7 -0
  220. package/dist/outbound-http-policy.d.ts.map +1 -0
  221. package/dist/outbound-http-policy.js +155 -0
  222. package/dist/outbound-http-policy.js.map +1 -0
  223. package/dist/public-api.d.ts +21 -0
  224. package/dist/public-api.d.ts.map +1 -0
  225. package/dist/public-api.js +19 -0
  226. package/dist/public-api.js.map +1 -0
  227. package/dist/replay-resume.d.ts +8 -0
  228. package/dist/replay-resume.d.ts.map +1 -1
  229. package/dist/replay-resume.js +141 -11
  230. package/dist/replay-resume.js.map +1 -1
  231. package/dist/resource-projection-util.d.ts +1 -1
  232. package/dist/resource-projection-util.d.ts.map +1 -1
  233. package/dist/resource-projection-util.js +21 -10
  234. package/dist/resource-projection-util.js.map +1 -1
  235. package/dist/resource-projection.d.ts +8 -1
  236. package/dist/resource-projection.d.ts.map +1 -1
  237. package/dist/resource-projection.js +229 -29
  238. package/dist/resource-projection.js.map +1 -1
  239. package/dist/run-heartbeat.d.ts +12 -2
  240. package/dist/run-heartbeat.d.ts.map +1 -1
  241. package/dist/run-heartbeat.js +31 -4
  242. package/dist/run-heartbeat.js.map +1 -1
  243. package/dist/run-outcome.d.ts +9 -5
  244. package/dist/run-outcome.d.ts.map +1 -1
  245. package/dist/run-outcome.js +14 -5
  246. package/dist/run-outcome.js.map +1 -1
  247. package/dist/run-recovery.d.ts +19 -3
  248. package/dist/run-recovery.d.ts.map +1 -1
  249. package/dist/run-recovery.js +205 -34
  250. package/dist/run-recovery.js.map +1 -1
  251. package/dist/run-replay.d.ts +35 -0
  252. package/dist/run-replay.d.ts.map +1 -0
  253. package/dist/run-replay.js +193 -0
  254. package/dist/run-replay.js.map +1 -0
  255. package/dist/run-result.d.ts +4 -0
  256. package/dist/run-result.d.ts.map +1 -0
  257. package/dist/run-result.js +18 -0
  258. package/dist/run-result.js.map +1 -0
  259. package/dist/run-timeline-query.d.ts +38 -0
  260. package/dist/run-timeline-query.d.ts.map +1 -0
  261. package/dist/run-timeline-query.js +99 -0
  262. package/dist/run-timeline-query.js.map +1 -0
  263. package/dist/runs-query.d.ts.map +1 -1
  264. package/dist/runs-query.js +11 -3
  265. package/dist/runs-query.js.map +1 -1
  266. package/dist/runtime-bundle.d.ts.map +1 -1
  267. package/dist/runtime-bundle.js +2 -0
  268. package/dist/runtime-bundle.js.map +1 -1
  269. package/dist/runtime-learning.d.ts +15 -13
  270. package/dist/runtime-learning.d.ts.map +1 -1
  271. package/dist/runtime-learning.js +79 -58
  272. package/dist/runtime-learning.js.map +1 -1
  273. package/dist/runtime-types.d.ts +68 -9
  274. package/dist/runtime-types.d.ts.map +1 -1
  275. package/dist/sandbox-fs.d.ts +8 -5
  276. package/dist/sandbox-fs.d.ts.map +1 -1
  277. package/dist/sandbox-fs.js +30 -31
  278. package/dist/sandbox-fs.js.map +1 -1
  279. package/dist/sandbox-handle.d.ts +25 -0
  280. package/dist/sandbox-handle.d.ts.map +1 -0
  281. package/dist/sandbox-handle.js +120 -0
  282. package/dist/sandbox-handle.js.map +1 -0
  283. package/dist/sandbox-session-identity.d.ts +14 -0
  284. package/dist/sandbox-session-identity.d.ts.map +1 -0
  285. package/dist/sandbox-session-identity.js +33 -0
  286. package/dist/sandbox-session-identity.js.map +1 -0
  287. package/dist/sandbox-session-key.d.ts.map +1 -1
  288. package/dist/sandbox-session-key.js +12 -9
  289. package/dist/sandbox-session-key.js.map +1 -1
  290. package/dist/sandbox-session-lifecycle.d.ts.map +1 -1
  291. package/dist/sandbox-session-lifecycle.js +187 -44
  292. package/dist/sandbox-session-lifecycle.js.map +1 -1
  293. package/dist/sandbox-snapshot-policy.js +3 -3
  294. package/dist/sandbox-snapshot-policy.js.map +1 -1
  295. package/dist/sandbox-state-sync.d.ts +4 -2
  296. package/dist/sandbox-state-sync.d.ts.map +1 -1
  297. package/dist/sandbox-state-sync.js +47 -15
  298. package/dist/sandbox-state-sync.js.map +1 -1
  299. package/dist/sandbox-sync-worker.d.ts +11 -2
  300. package/dist/sandbox-sync-worker.d.ts.map +1 -1
  301. package/dist/sandbox-sync-worker.js +143 -31
  302. package/dist/sandbox-sync-worker.js.map +1 -1
  303. package/dist/schedule-execution.d.ts.map +1 -1
  304. package/dist/schedule-execution.js +127 -23
  305. package/dist/schedule-execution.js.map +1 -1
  306. package/dist/sdk-api-client.d.ts +17 -0
  307. package/dist/sdk-api-client.d.ts.map +1 -0
  308. package/dist/sdk-api-client.js +55 -0
  309. package/dist/sdk-api-client.js.map +1 -0
  310. package/dist/security.js +2 -2
  311. package/dist/security.js.map +1 -1
  312. package/dist/self-improvement.d.ts +5 -1
  313. package/dist/self-improvement.d.ts.map +1 -1
  314. package/dist/self-improvement.js +28 -14
  315. package/dist/self-improvement.js.map +1 -1
  316. package/dist/skill-bundles.d.ts +55 -0
  317. package/dist/skill-bundles.d.ts.map +1 -0
  318. package/dist/skill-bundles.js +134 -0
  319. package/dist/skill-bundles.js.map +1 -0
  320. package/dist/source-loader.js +7 -7
  321. package/dist/source-loader.js.map +1 -1
  322. package/dist/state-store-helpers.d.ts +2 -0
  323. package/dist/state-store-helpers.d.ts.map +1 -1
  324. package/dist/state-store-helpers.js +11 -1
  325. package/dist/state-store-helpers.js.map +1 -1
  326. package/dist/state-stores.d.ts +1 -0
  327. package/dist/state-stores.d.ts.map +1 -1
  328. package/dist/state-stores.js +26 -7
  329. package/dist/state-stores.js.map +1 -1
  330. package/dist/state.d.ts +305 -5
  331. package/dist/state.d.ts.map +1 -1
  332. package/dist/state.js +41 -2
  333. package/dist/state.js.map +1 -1
  334. package/dist/storage.d.ts +47 -2
  335. package/dist/storage.d.ts.map +1 -1
  336. package/dist/storage.js +158 -6
  337. package/dist/storage.js.map +1 -1
  338. package/dist/subagent-execution.d.ts +1 -1
  339. package/dist/subagent-execution.d.ts.map +1 -1
  340. package/dist/subagent-execution.js +10 -12
  341. package/dist/subagent-execution.js.map +1 -1
  342. package/dist/target-instructions.js +1 -1
  343. package/dist/target-instructions.js.map +1 -1
  344. package/dist/tool-apis.d.ts.map +1 -1
  345. package/dist/tool-apis.js +33 -9
  346. package/dist/tool-apis.js.map +1 -1
  347. package/dist/tool-execution.d.ts +22 -12
  348. package/dist/tool-execution.d.ts.map +1 -1
  349. package/dist/tool-execution.js +368 -238
  350. package/dist/tool-execution.js.map +1 -1
  351. package/dist/turn-media.d.ts +29 -0
  352. package/dist/turn-media.d.ts.map +1 -0
  353. package/dist/turn-media.js +233 -0
  354. package/dist/turn-media.js.map +1 -0
  355. package/dist/usage-reconciliation.d.ts +1 -1
  356. package/dist/usage-reconciliation.js +1 -1
  357. package/dist/workspace-id.d.ts +10 -0
  358. package/dist/workspace-id.d.ts.map +1 -0
  359. package/dist/workspace-id.js +55 -0
  360. package/dist/workspace-id.js.map +1 -0
  361. package/dist/workspace-manifest.d.ts +24 -0
  362. package/dist/workspace-manifest.d.ts.map +1 -0
  363. package/dist/workspace-manifest.js +111 -0
  364. package/dist/workspace-manifest.js.map +1 -0
  365. package/dist/workspace-operation-limiter.d.ts +16 -0
  366. package/dist/workspace-operation-limiter.d.ts.map +1 -0
  367. package/dist/workspace-operation-limiter.js +31 -0
  368. package/dist/workspace-operation-limiter.js.map +1 -0
  369. package/dist/workspace-operations.d.ts +145 -0
  370. package/dist/workspace-operations.d.ts.map +1 -0
  371. package/dist/workspace-operations.js +420 -0
  372. package/dist/workspace-operations.js.map +1 -0
  373. package/dist/workspace-runtime.d.ts +110 -0
  374. package/dist/workspace-runtime.d.ts.map +1 -0
  375. package/dist/workspace-runtime.js +240 -0
  376. package/dist/workspace-runtime.js.map +1 -0
  377. package/dist/workspace-search.d.ts +55 -0
  378. package/dist/workspace-search.d.ts.map +1 -0
  379. package/dist/workspace-search.js +262 -0
  380. package/dist/workspace-search.js.map +1 -0
  381. package/dist/workspace-service.d.ts +173 -0
  382. package/dist/workspace-service.d.ts.map +1 -0
  383. package/dist/workspace-service.js +619 -0
  384. package/dist/workspace-service.js.map +1 -0
  385. package/dist/workspace.d.ts +7 -0
  386. package/dist/workspace.d.ts.map +1 -0
  387. package/dist/workspace.js +7 -0
  388. package/dist/workspace.js.map +1 -0
  389. package/package.json +7 -4
@@ -1 +1 @@
1
- {"version":3,"file":"builtin-tool-executors.d.ts","sourceRoot":"","sources":["../src/builtin-tool-executors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAa1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAGL,yBAAyB,EACzB,KAAK,oCAAoC,EACzC,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAK1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG/D,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG7D;;;;;;;;;GASG;AAEH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9F,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAA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AAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC,CAgFD"}
@@ -1,38 +1,71 @@
1
- import { isConnectionAuthorizationRequiredError, shellQuote } from "@assemblyline-agents/core";
2
- import { CORE_HARNESS_TOOL_NAMES, LOAD_SKILL_TOOL_NAME, runtimeToolsForManifest, TOOL_DESCRIBE_TOOL_NAME, TOOL_SEARCH_TOOL_NAME } from "./builtin-tools.js";
1
+ import { isConnectionAuthorizationRequiredError, isRecoverableToolError, shellQuote } from "@assemblyline-agents/core";
2
+ import { HISTORY_SEARCH_TOOL_NAME, LOAD_SKILL_TOOL_NAME, PAIR_TOOL_NAME, runtimeToolsForSurface, TOOL_SEARCH_TOOL_NAME } from "./builtin-tools.js";
3
3
  import { connectionSearchResultForModel, normalizeDeferredToolSearchInput } from "./capability-catalog.js";
4
- import { CONNECTION_SEARCH_TOOL_NAME, parseQualifiedName, RuntimeConnectionRegistry } from "./connections.js";
4
+ import { CONNECTION_SEARCH_TOOL_NAME, isConnectionConfigurationError, parseQualifiedName, RuntimeConnectionRegistry } from "./connections.js";
5
5
  import { evalRunOptionsForRun } from "./eval-run-options.js";
6
- import { isJsonObject, redactedToolInput, safeJson } from "./json-util.js";
7
- import { failRun } from "./run-outcome.js";
8
- import { skillNameFromSkillPath } from "./resource-projection-util.js";
6
+ import { isJsonObject, previewString, redactedToolInput, safeJson } from "./json-util.js";
7
+ import { normalizeResourcePath, skillNameFromSkillPath } from "./resource-projection-util.js";
9
8
  import { normalizeConnectionApproval, stringValue } from "./runtime-util.js";
9
+ import { audienceFromRun, principalKey } from "./audience.js";
10
+ import { applyCoreToolPolicy } from "./security.js";
10
11
  import { parseSkillBody } from "./self-improvement.js";
11
12
  import { initiatorFromRun, principalFromRun } from "./principals.js";
13
+ import { authorizationRequiredModelOutput } from "./model-visible-interrupts.js";
12
14
  /**
13
15
  * Runtime-handled tool executors: the builtin skill/discovery tools
14
- * (load_skill, tool_search, tool_describe), the deferred local tool catalog,
15
- * the tool-call bookkeeping those paths share, and the connection tool
16
- * executors together with the connection-registry factories they run against.
16
+ * (load_skill and tool_search), the deferred tool catalog, the tool-call
17
+ * bookkeeping those paths share, and the connection tool executors together
18
+ * with the connection-registry factories they run against.
17
19
  * None of these route through an authored tool definition, so their records
18
20
  * are written here rather than by executeToolWithRecord in
19
21
  * ./tool-execution.js. Imports only the {@link ToolExecutionHost} type from
20
22
  * ./tool-execution.js, so the value-level module graph stays acyclic.
21
23
  */
22
- export async function skillLoadDetailsImpl(host, skillName) {
23
- await host.ensureSkillsSeeded();
24
- const skill = await host.skillStore.get(host.skillScope(), skillName);
24
+ /** Cap on inventory entries returned by load_skill; the full tree stays reachable via list/grep. */
25
+ const LOAD_SKILL_RESOURCE_INVENTORY_LIMIT = 150;
26
+ export async function skillLoadDetailsImpl(host, run, skillName) {
27
+ await host.ensureSkillsSeeded(run);
28
+ const skill = await host.skillStore.get(host.skillScopeForRun(run), skillName);
25
29
  if (!skill || skill.pending || skill.archived)
26
30
  throw new Error(`Skill not found: ${skillName}`);
27
31
  const parsed = parseSkillBody(skill.body);
28
- return {
32
+ const surfacePath = host.surfaceForRun(run).path;
33
+ const entryPath = host.skillBundleIndex.entrypointPathForSkill(skill.name, surfacePath);
34
+ const bundle = host.skillBundleIndex.bundleForSkill(skill.name, surfacePath);
35
+ const closure = host.skillBundleIndex
36
+ .resourceClosureForSkill(skill.name, surfacePath)
37
+ .filter((resource) => resource.runtimePath !== entryPath);
38
+ const details = {
29
39
  name: skill.name,
30
40
  description: parsed.description || `Skill ${skill.name}`,
31
41
  declaredTools: parsed.allowedTools,
32
42
  instructions: parsed.instructions,
33
43
  origin: skill.origin,
34
- path: `/skills/${skill.name}/SKILL.md`
44
+ path: entryPath,
45
+ resources: closure
46
+ .slice(0, LOAD_SKILL_RESOURCE_INVENTORY_LIMIT)
47
+ .map((resource) => ({ path: resource.runtimePath, size: resource.size, contentType: resource.contentType })),
48
+ resourceCount: closure.length,
49
+ resourceBytes: closure.reduce((total, resource) => total + resource.size, 0)
35
50
  };
51
+ if (bundle) {
52
+ details.bundle = {
53
+ id: bundle.id,
54
+ kind: bundle.kind,
55
+ ...(bundle.plugin ? { plugin: { name: bundle.plugin.name, ...(bundle.plugin.version ? { version: bundle.plugin.version } : {}) } } : {})
56
+ };
57
+ }
58
+ return details;
59
+ }
60
+ /** Resolve a load_skill `path` input: canonical entrypoint paths first, then the legacy shapes. */
61
+ function skillNameFromLoadInput(host, requested) {
62
+ try {
63
+ return host.skillBundleIndex.skillNameForEntrypointPath(normalizeResourcePath(requested))
64
+ ?? skillNameFromSkillPath(requested);
65
+ }
66
+ catch {
67
+ return skillNameFromSkillPath(requested);
68
+ }
36
69
  }
37
70
  export function createConnectionRegistryImpl(host, channel, turn) {
38
71
  const session = { channel };
@@ -51,6 +84,8 @@ export function createConnectionRegistryImpl(host, channel, turn) {
51
84
  env: host.env,
52
85
  fetch: host.fetch,
53
86
  session,
87
+ audience: turn?.audience ?? { private: true },
88
+ agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
54
89
  grantStore: host.connectionGrantStore,
55
90
  authorizationSessionStore: host.connectionAuthorizationSessionStore,
56
91
  ...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
@@ -73,20 +108,20 @@ export function createConnectionRegistryForRunImpl(host, run, fallbackChannel, s
73
108
  session.principal = principal;
74
109
  if (initiator)
75
110
  session.initiator = initiator;
76
- const subagentName = typeof run.input.subagent === "string" ? run.input.subagent : undefined;
77
- const subagentConnectionNames = subagentName
78
- ? new Set(host.manifest.subagents.find((subagent) => subagent.name === subagentName)?.connections ?? [])
79
- : undefined;
111
+ const surface = host.surfaceForRun(run);
112
+ const subagentConnectionNames = surface.path !== "root" ? new Set(surface.connections) : undefined;
80
113
  const scopedConnectionNames = selectedConnections && subagentConnectionNames
81
114
  ? new Set([...selectedConnections].filter((name) => subagentConnectionNames.has(name)))
82
115
  : selectedConnections ?? subagentConnectionNames;
83
116
  return new RuntimeConnectionRegistry({
84
- connections: scopedConnectionNames
117
+ connections: (scopedConnectionNames
85
118
  ? host.mergedConnections().filter((connection) => scopedConnectionNames.has(connection.name))
86
- : host.mergedConnections(),
119
+ : host.mergedConnections()),
87
120
  env: host.env,
88
121
  fetch: host.fetch,
89
122
  session,
123
+ audience: audienceFromRun(run),
124
+ agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
90
125
  grantStore: host.connectionGrantStore,
91
126
  authorizationSessionStore: host.connectionAuthorizationSessionStore,
92
127
  ...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
@@ -131,6 +166,7 @@ export async function beginConnectionAuthorizationImpl(host, connectionName, ses
131
166
  env: host.env,
132
167
  fetch: host.fetch,
133
168
  session: resolverSession,
169
+ agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
134
170
  grantStore: host.connectionGrantStore,
135
171
  authorizationSessionStore: host.connectionAuthorizationSessionStore,
136
172
  ...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
@@ -144,6 +180,7 @@ export function createConnectionRegistryForSessionImpl(host, session) {
144
180
  env: host.env,
145
181
  fetch: host.fetch,
146
182
  session: session.session,
183
+ agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
147
184
  grantStore: host.connectionGrantStore,
148
185
  authorizationSessionStore: host.connectionAuthorizationSessionStore,
149
186
  ...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
@@ -153,7 +190,9 @@ export function createConnectionRegistryForSessionImpl(host, session) {
153
190
  export async function executeLoadSkillTool(host, run, state, input, idempotencyKey) {
154
191
  const raw = isJsonObject(input) ? input : {};
155
192
  const requested = stringValue(raw.name) || stringValue(raw.skillName) || stringValue(raw.path);
156
- const skillName = requested ? skillNameFromSkillPath(requested) ?? requested : "";
193
+ const skillName = requested
194
+ ? skillNameFromLoadInput(host, requested) ?? requested
195
+ : "";
157
196
  const toolCall = await recordRuntimeHandledToolStart(host, run, LOAD_SKILL_TOOL_NAME, input, idempotencyKey);
158
197
  try {
159
198
  if (!skillName)
@@ -161,7 +200,7 @@ export async function executeLoadSkillTool(host, run, state, input, idempotencyK
161
200
  if (!state.allowedSkills.has(skillName)) {
162
201
  throw new Error(`Skill ${skillName} is not enabled by the current agent capability snapshot.`);
163
202
  }
164
- const loaded = await skillLoadDetailsImpl(host, skillName);
203
+ const loaded = await skillLoadDetailsImpl(host, run, skillName);
165
204
  let sandboxProjected = false;
166
205
  const activeSandbox = state.sandboxHandle.current();
167
206
  if (activeSandbox) {
@@ -187,24 +226,109 @@ export async function executeLoadSkillTool(host, run, state, input, idempotencyK
187
226
  };
188
227
  if (loaded.declaredTools.length > 0)
189
228
  output.declaredTools = loaded.declaredTools;
229
+ if (loaded.bundle)
230
+ output.bundle = safeJson(loaded.bundle);
231
+ if (loaded.resourceCount > 0) {
232
+ output.resources = loaded.resources.map((resource) => safeJson(resource));
233
+ output.resourceCount = loaded.resourceCount;
234
+ output.resourceBytes = loaded.resourceBytes;
235
+ if (loaded.resourceCount > loaded.resources.length) {
236
+ output.resourceInventoryTruncated = true;
237
+ }
238
+ }
190
239
  await completeRuntimeHandledTool(host, run, toolCall, LOAD_SKILL_TOOL_NAME, output);
191
240
  await host.state.appendEvent(run.id, "skill.loaded", {
192
241
  skill: loaded.name,
193
242
  origin: loaded.origin,
194
243
  path: loaded.path,
244
+ ...(loaded.bundle ? { bundle: loaded.bundle.id } : {}),
245
+ resourceCount: loaded.resourceCount,
195
246
  sandboxProjected
196
247
  });
197
248
  return { run: await host.state.getRun(run.id) ?? run, modelOutput: output, skillName: loaded.name };
198
249
  }
199
250
  catch (error) {
200
- return failRuntimeHandledTool(host, run, toolCall, LOAD_SKILL_TOOL_NAME, error, { recoverable: true });
251
+ return failRuntimeHandledTool(host, run, toolCall, LOAD_SKILL_TOOL_NAME, error);
252
+ }
253
+ }
254
+ export async function executeHistorySearchTool(host, run, input, idempotencyKey) {
255
+ const raw = isJsonObject(input) ? input : {};
256
+ const query = stringValue(raw.query);
257
+ const scope = stringValue(raw.scope) || "current_conversation";
258
+ const rawLimit = typeof raw.limit === "number" && Number.isFinite(raw.limit) ? Math.floor(raw.limit) : 8;
259
+ const limit = Math.min(50, Math.max(1, rawLimit));
260
+ const toolCall = await recordRuntimeHandledToolStart(host, run, HISTORY_SEARCH_TOOL_NAME, input, idempotencyKey);
261
+ try {
262
+ if (!query)
263
+ throw new Error("history_search requires query.");
264
+ if (!["current_conversation", "current_channel", "my_conversations"].includes(scope)) {
265
+ throw new Error(`Unsupported history_search scope: ${scope}`);
266
+ }
267
+ const search = {
268
+ agentScope: host.memoryScopeForRun(run).agentScope,
269
+ query,
270
+ limit
271
+ };
272
+ if (scope === "current_conversation") {
273
+ const conversationId = stringValue(run.input.conversationId);
274
+ if (!conversationId)
275
+ throw new Error("history_search current_conversation requires an active conversation.");
276
+ search.conversationId = conversationId;
277
+ }
278
+ else if (scope === "current_channel") {
279
+ const metadata = isJsonObject(run.input.metadata) ? run.input.metadata : {};
280
+ const source = isJsonObject(metadata.source) ? metadata.source : undefined;
281
+ const provider = stringValue(source?.provider);
282
+ const workspaceId = stringValue(source?.workspaceId);
283
+ const channelId = stringValue(source?.channelId);
284
+ if (!provider || !workspaceId || !channelId) {
285
+ throw new Error("history_search current_channel is unavailable because this turn has no attributed channel scope.");
286
+ }
287
+ const channel = stringValue(run.input.channel);
288
+ if (channel)
289
+ search.channel = channel;
290
+ search.source = { provider, workspaceId, channelId };
291
+ }
292
+ else {
293
+ if (!audienceFromRun(run).private) {
294
+ throw new Error("history_search my_conversations is unavailable in a shared conversation.");
295
+ }
296
+ const principal = principalFromRun(run);
297
+ const subject = principal ? principalKey(principal) : stringValue(run.input.userId);
298
+ if (!subject)
299
+ throw new Error("history_search my_conversations requires an authenticated conversation subject.");
300
+ search.subject = subject;
301
+ }
302
+ const results = await host.state.searchMessages(search);
303
+ const output = {
304
+ query,
305
+ scope,
306
+ matches: results.map((result) => {
307
+ const contentSource = isJsonObject(result.message.content.source) ? result.message.content.source : undefined;
308
+ const conversationSource = isJsonObject(result.conversationMetadata.source) ? result.conversationMetadata.source : undefined;
309
+ return {
310
+ messageId: result.message.id,
311
+ conversationId: result.message.conversationId,
312
+ role: result.message.role,
313
+ text: previewString(stringValue(result.message.content.text), 1_200),
314
+ createdAt: result.message.createdAt,
315
+ score: result.score,
316
+ source: safeJson(contentSource ?? conversationSource ?? {})
317
+ };
318
+ })
319
+ };
320
+ await completeRuntimeHandledTool(host, run, toolCall, HISTORY_SEARCH_TOOL_NAME, output);
321
+ return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
322
+ }
323
+ catch (error) {
324
+ return failRuntimeHandledTool(host, run, toolCall, HISTORY_SEARCH_TOOL_NAME, error);
201
325
  }
202
326
  }
203
327
  export async function executeToolSearchTool(host, run, state, input, idempotencyKey) {
204
328
  const request = normalizeDeferredToolSearchInput(input);
205
329
  const toolCall = await recordRuntimeHandledToolStart(host, run, TOOL_SEARCH_TOOL_NAME, input, idempotencyKey);
206
330
  try {
207
- const local = await searchDeferredLocalTools(host, request.query, request.limit);
331
+ const local = searchDeferredTools(host, run, request.query, request.limit);
208
332
  const connectionResults = state.connectionRegistry.hasLiveConnections()
209
333
  ? await state.connectionRegistry.search({
210
334
  keywords: request.query,
@@ -238,10 +362,18 @@ export async function executeToolSearchTool(host, run, state, input, idempotency
238
362
  if (result.outputSchema)
239
363
  metadata.outputSchema = result.outputSchema;
240
364
  state.discoveredConnectionTools.set(result.qualifiedName, metadata);
365
+ state.activeToolNames.add(result.qualifiedName);
241
366
  }
367
+ for (const tool of local)
368
+ state.activeToolNames.add(tool.name);
369
+ const activated = [
370
+ ...local.map((tool) => tool.name),
371
+ ...actionableConnectionMatches.flatMap((result) => result.qualifiedName ? [result.qualifiedName] : [])
372
+ ];
242
373
  const output = {
243
374
  query: request.query,
244
- totalAvailable: deferredLocalTools(host).length + connectionMatches.length,
375
+ totalAvailable: deferredTools(host, run).length + connectionMatches.length,
376
+ activated,
245
377
  matches: [
246
378
  ...local.map((tool) => ({
247
379
  name: tool.name,
@@ -263,77 +395,20 @@ export async function executeToolSearchTool(host, run, state, input, idempotency
263
395
  return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
264
396
  }
265
397
  catch (error) {
266
- return failRuntimeHandledTool(host, run, toolCall, TOOL_SEARCH_TOOL_NAME, error, { recoverable: true });
398
+ return failRuntimeHandledTool(host, run, toolCall, TOOL_SEARCH_TOOL_NAME, error);
267
399
  }
268
400
  }
269
- export async function executeToolDescribeTool(host, run, state, input, idempotencyKey) {
270
- const raw = isJsonObject(input) ? input : {};
271
- const name = stringValue(raw.name);
272
- const toolCall = await recordRuntimeHandledToolStart(host, run, TOOL_DESCRIBE_TOOL_NAME, input, idempotencyKey);
273
- try {
274
- if (!name)
275
- throw new Error("tool_describe requires name.");
276
- const local = deferredLocalTools(host).find((tool) => tool.name === name);
277
- if (local) {
278
- const definition = await host.loadTool(local);
279
- const output = {
280
- name: local.name,
281
- kind: "tool",
282
- description: definition.description ?? local.description,
283
- inputSchema: safeJson(definition.inputSchema ?? local.inputSchema),
284
- outputSchema: safeJson(definition.outputSchema ?? local.outputSchema ?? {})
285
- };
286
- await completeRuntimeHandledTool(host, run, toolCall, TOOL_DESCRIBE_TOOL_NAME, output);
287
- return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
288
- }
289
- let connection = state.discoveredConnectionTools.get(name);
290
- if (!connection && parseQualifiedName(name) && state.connectionRegistry.hasLiveConnections()) {
291
- const parsed = parseQualifiedName(name);
292
- const results = parsed
293
- ? await state.connectionRegistry.search({ keywords: parsed.toolName, connection: parsed.connectionName, limit: 10 }, {
294
- runId: run.id,
295
- toolCallId: toolCall.id,
296
- toolName: TOOL_DESCRIBE_TOOL_NAME
297
- })
298
- : [];
299
- const result = results.find((candidate) => candidate.qualifiedName === name);
300
- if (result?.qualifiedName && result.tool && result.inputSchema) {
301
- connection = {
302
- connection: result.connection,
303
- name: result.tool,
304
- qualifiedName: result.qualifiedName,
305
- description: result.description,
306
- inputSchema: result.inputSchema,
307
- ...(result.outputSchema ? { outputSchema: result.outputSchema } : {})
308
- };
309
- state.discoveredConnectionTools.set(name, connection);
310
- }
311
- }
312
- if (!connection)
313
- throw new Error(`Deferred tool not found: ${name}`);
314
- const output = {
315
- name: connection.qualifiedName,
316
- kind: "connection_tool",
317
- connection: connection.connection,
318
- description: connection.description,
319
- inputSchema: safeJson(connection.inputSchema),
320
- outputSchema: safeJson(connection.outputSchema ?? {})
321
- };
322
- await completeRuntimeHandledTool(host, run, toolCall, TOOL_DESCRIBE_TOOL_NAME, output);
323
- return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
324
- }
325
- catch (error) {
326
- return failRuntimeHandledTool(host, run, toolCall, TOOL_DESCRIBE_TOOL_NAME, error, { recoverable: true });
327
- }
328
- }
329
- export function deferredLocalTools(host) {
330
- return runtimeToolsForManifest(host.manifest)
331
- .filter((tool) => !CORE_HARNESS_TOOL_NAMES.includes(tool.name))
332
- .filter((tool) => tool.visibility !== "hidden");
401
+ export function deferredTools(host, run) {
402
+ return runtimeToolsForSurface(host.surfaceForRun(run).tools)
403
+ .filter((tool) => tool.visibility === "deferred")
404
+ .flatMap((tool) => {
405
+ const policyTool = applyCoreToolPolicy(tool, host.coreToolPolicy);
406
+ return policyTool ? [policyTool] : [];
407
+ });
333
408
  }
334
- async function searchDeferredLocalTools(host, query, limit) {
409
+ function searchDeferredTools(host, run, query, limit) {
335
410
  const lower = query.toLowerCase();
336
- return deferredLocalTools(host)
411
+ return deferredTools(host, run)
337
412
  .map((tool) => ({
338
413
  tool,
339
414
  haystack: [
@@ -348,13 +423,14 @@ async function searchDeferredLocalTools(host, query, limit) {
348
423
  .map((entry) => entry.tool)
349
424
  .slice(0, limit);
350
425
  }
351
- async function recordRuntimeHandledToolStart(host, run, toolName, input, idempotencyKey) {
426
+ export async function recordRuntimeHandledToolStart(host, run, toolName, input, idempotencyKey) {
352
427
  await host.state.appendEvent(run.id, "tool.call_requested", { toolName, input: redactedToolInput(input) });
353
428
  let toolCall = await host.state.createToolCall({
354
429
  runId: run.id,
355
430
  toolName,
356
431
  status: "requested",
357
- input: redactedToolInput(input),
432
+ // Raw, not redacted: resume paths re-execute persisted tool-call input.
433
+ input: safeJson(input),
358
434
  idempotencyKey
359
435
  });
360
436
  toolCall = await host.state.updateToolCall(toolCall.id, { status: "running" });
@@ -373,21 +449,86 @@ async function completeRuntimeHandledTool(host, run, toolCall, toolName, output)
373
449
  modelOutput: safeJson(output)
374
450
  });
375
451
  }
452
+ /**
453
+ * Finalize a durably recordable model-invoked tool failure. Tool failures are
454
+ * model results, not run failures; callers only throw when durable state cannot
455
+ * be written and continuing would therefore be unsafe.
456
+ */
376
457
  export async function failRuntimeHandledTool(host, run, toolCall, toolName, error, options) {
377
458
  const message = error instanceof Error ? error.message : String(error);
459
+ const failureKind = options?.failureKind
460
+ ?? (isRecoverableToolError(error) ? "invalid_input" : "execution_error");
461
+ const modelOutput = {
462
+ error: message,
463
+ failure: {
464
+ kind: failureKind,
465
+ runCanContinue: true
466
+ }
467
+ };
378
468
  await host.state.updateToolCall(toolCall.id, { status: "failed", error: message });
379
- await host.state.appendEvent(run.id, "tool.execution_failed", { toolCallId: toolCall.id, toolName, error: message });
380
- if (options?.recoverable) {
381
- // Model-invoked discovery tools: return the error to the model to reason
382
- // over rather than irreversibly failing the whole run.
383
- return { run, modelOutput: { error: message } };
384
- }
385
- const failedRun = await failRun({ state: host.state }, run.id, {
386
- reason: "tool.execution_failed",
469
+ await host.state.appendEvent(run.id, "tool.execution_failed", {
470
+ toolCallId: toolCall.id,
471
+ toolName,
387
472
  error: message,
388
- data: { toolCallId: toolCall.id, toolName }
473
+ failureKind,
474
+ recoverable: true
389
475
  });
390
- return { run: failedRun, modelOutput: { error: message } };
476
+ return { run: await host.state.getRun(run.id) ?? run, modelOutput };
477
+ }
478
+ /** Event appended whenever a pair call cannot proceed for a connection. */
479
+ export const CONNECTION_PAIRING_UNAVAILABLE_EVENT = "connection.pairing_unavailable";
480
+ /**
481
+ * The core `pair` tool: redeem a user-pasted one-time binding packet against a
482
+ * live connection, host-side. Unlike the synthetic `<connection>__pair`
483
+ * discovery tool this executor never requires prior discovery, and when no
484
+ * connection can pair it reports the per-connection resolve failures instead
485
+ * of a generic "not exposed" dead end. Errors are recoverable: the model
486
+ * relays the cause to the user rather than failing the run.
487
+ */
488
+ export async function executePairTool(host, run, registry, input, idempotencyKey) {
489
+ const toolCall = await recordRuntimeHandledToolStart(host, run, PAIR_TOOL_NAME, input, idempotencyKey);
490
+ try {
491
+ const raw = isJsonObject(input) ? input : {};
492
+ const secret = typeof raw.secret === "string" ? raw.secret.trim() : "";
493
+ const requested = typeof raw.connection === "string" ? raw.connection.trim() : "";
494
+ if (!secret)
495
+ throw new Error("pair requires the full pasted packet or claim code as `secret`.");
496
+ const status = await registry.pairingStatus();
497
+ const target = requested || (status.pairable.length === 1 ? status.pairable[0] : "");
498
+ if (!target) {
499
+ if (status.pairable.length > 1) {
500
+ throw new Error(`Multiple connections support pairing (${status.pairable.join(", ")}); pass the intended one as \`connection\`.`);
501
+ }
502
+ throw await pairingUnavailableError(host, run, status.unavailable);
503
+ }
504
+ if (!status.pairable.includes(target)) {
505
+ const failure = status.unavailable.find((item) => item.connection === target);
506
+ if (failure)
507
+ throw await pairingUnavailableError(host, run, [failure]);
508
+ }
509
+ // Redemption re-validates the target (registered, private-surface access,
510
+ // pairing support) and reports the precise refusal to the model.
511
+ const result = await registry.redeemPairingCode(target, secret);
512
+ const output = { connected: true, connection: result.connection, message: result.message };
513
+ await completeRuntimeHandledTool(host, run, toolCall, PAIR_TOOL_NAME, output);
514
+ return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
515
+ }
516
+ catch (error) {
517
+ return failRuntimeHandledTool(host, run, toolCall, PAIR_TOOL_NAME, error);
518
+ }
519
+ }
520
+ // Persist why pairing is impossible before the error reaches the model, so an
521
+ // operator can see the cause in the event log even if the conversation moves on.
522
+ async function pairingUnavailableError(host, run, unavailable) {
523
+ for (const item of unavailable) {
524
+ await host.state.appendEvent(run.id, CONNECTION_PAIRING_UNAVAILABLE_EVENT, {
525
+ connection: item.connection,
526
+ reason: item.reason
527
+ });
528
+ }
529
+ if (unavailable.length === 0)
530
+ return new Error("No live connection supports pairing.");
531
+ return new Error(`No connection can pair right now: ${unavailable.map((item) => `${item.connection}: ${item.reason}`).join("; ")}`);
391
532
  }
392
533
  export async function executeConnectionSearchTool(host, run, registry, input, idempotencyKey) {
393
534
  await host.state.appendEvent(run.id, "tool.call_requested", { toolName: CONNECTION_SEARCH_TOOL_NAME, input: redactedToolInput(input) });
@@ -395,7 +536,8 @@ export async function executeConnectionSearchTool(host, run, registry, input, id
395
536
  runId: run.id,
396
537
  toolName: CONNECTION_SEARCH_TOOL_NAME,
397
538
  status: "requested",
398
- input: redactedToolInput(input),
539
+ // Raw, not redacted: resume paths re-execute persisted tool-call input.
540
+ input: safeJson(input),
399
541
  idempotencyKey
400
542
  });
401
543
  await host.state.updateToolCall(toolCall.id, { status: "running" });
@@ -430,17 +572,24 @@ export async function executeConnectionSearchTool(host, run, registry, input, id
430
572
  // Recoverable: model-invoked discovery, so return the error, don't fail the run.
431
573
  const message = error instanceof Error ? error.message : String(error);
432
574
  await host.state.updateToolCall(toolCall.id, { status: "failed", error: message });
433
- await host.state.appendEvent(run.id, "tool.execution_failed", { toolCallId: toolCall.id, toolName: CONNECTION_SEARCH_TOOL_NAME, error: message });
575
+ await host.state.appendEvent(run.id, "tool.execution_failed", {
576
+ toolCallId: toolCall.id,
577
+ toolName: CONNECTION_SEARCH_TOOL_NAME,
578
+ error: message,
579
+ failureKind: "execution_error",
580
+ recoverable: true
581
+ });
434
582
  return { run: await host.state.getRun(run.id) ?? run, results: [{ connection: "connection_search", description: "Connection search failed.", error: message }] };
435
583
  }
436
584
  }
437
- export async function executeConnectionTool(host, run, registry, toolName, input, approved, idempotencyKey) {
585
+ export async function executeConnectionTool(host, run, registry, toolName, input, approved, idempotencyKey, authorizationBehavior = "pause") {
438
586
  await host.state.appendEvent(run.id, "tool.call_requested", { toolName, input: redactedToolInput(input) });
439
587
  let toolCall = await host.state.createToolCall({
440
588
  runId: run.id,
441
589
  toolName,
442
590
  status: "requested",
443
- input: redactedToolInput(input),
591
+ // Raw, not redacted: connection-auth resume re-executes this input.
592
+ input: safeJson(input),
444
593
  idempotencyKey
445
594
  });
446
595
  const parsed = parseQualifiedName(toolName);
@@ -461,7 +610,7 @@ export async function executeConnectionTool(host, run, registry, toolName, input
461
610
  toolName,
462
611
  source: "eval"
463
612
  });
464
- return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input);
613
+ return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input, authorizationBehavior);
465
614
  }
466
615
  if (approval.mode !== "never" && !approved) {
467
616
  toolCall = await host.state.updateToolCall(toolCall.id, { status: "waiting_for_approval" });
@@ -478,9 +627,9 @@ export async function executeConnectionTool(host, run, registry, toolName, input
478
627
  });
479
628
  return { run: waitingRun, waitingForApproval: true, toolCallId: toolCall.id, toolName };
480
629
  }
481
- return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input);
630
+ return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input, authorizationBehavior);
482
631
  }
483
- export async function executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input) {
632
+ export async function executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input, authorizationBehavior = "pause") {
484
633
  await host.state.updateToolCall(toolCall.id, { status: "running" });
485
634
  await host.state.appendEvent(run.id, "tool.execution_started", { toolCallId: toolCall.id, toolName });
486
635
  try {
@@ -508,9 +657,13 @@ export async function executeConnectionToolWithRecordImpl(host, run, registry, t
508
657
  }
509
658
  catch (error) {
510
659
  if (isConnectionAuthorizationRequiredError(error)) {
511
- await host.state.updateToolCall(toolCall.id, { status: "failed", error: error.message });
512
- const waitingRun = await host.state.updateRun(run.id, { status: "waiting_for_connection" });
513
660
  const authorizationSessionId = isJsonObject(error.challenge) && typeof error.challenge.sessionId === "string" ? error.challenge.sessionId : undefined;
661
+ const modelOutput = authorizationRequiredModelOutput(error);
662
+ await host.state.updateToolCall(toolCall.id, {
663
+ status: "failed",
664
+ error: error.message,
665
+ modelOutput
666
+ });
514
667
  await host.state.appendEvent(run.id, "authorization.required", {
515
668
  toolCallId: toolCall.id,
516
669
  toolName,
@@ -518,20 +671,39 @@ export async function executeConnectionToolWithRecordImpl(host, run, registry, t
518
671
  reason: error.reason,
519
672
  challenge: safeJson(error.challenge ?? {})
520
673
  });
674
+ if (authorizationBehavior === "return") {
675
+ await host.state.appendEvent(run.id, "authorization.returned_to_model", {
676
+ toolCallId: toolCall.id,
677
+ toolName,
678
+ connectionName: error.connectionName,
679
+ recoverable: true
680
+ });
681
+ return {
682
+ run: await host.state.getRun(run.id) ?? run,
683
+ modelOutput,
684
+ toolCallId: toolCall.id,
685
+ toolName
686
+ };
687
+ }
688
+ const waitingRun = await host.state.updateRun(run.id, { status: "waiting_for_connection" });
521
689
  const out = { run: waitingRun, waitingForConnection: true, toolCallId: toolCall.id, toolName };
522
690
  if (authorizationSessionId)
523
691
  out.authorizationSessionId = authorizationSessionId;
524
692
  return out;
525
693
  }
526
- const message = error instanceof Error ? error.message : String(error);
527
- await host.state.updateToolCall(toolCall.id, { status: "failed", error: message });
528
- await host.state.appendEvent(run.id, "tool.execution_failed", { toolCallId: toolCall.id, toolName, error: message });
529
- const failedRun = await failRun({ state: host.state }, run.id, {
530
- reason: "connection.tool_failed",
531
- error: message,
532
- data: { toolCallId: toolCall.id, toolName }
694
+ // Every connection failure that reached a model-invoked tool boundary is
695
+ // returned through the normal result channel. The model may correct its
696
+ // arguments, choose another connection, or explain configuration trouble
697
+ // to the user. Authorization remains the explicit pause path above.
698
+ const failure = await failRuntimeHandledTool(host, run, toolCall, toolName, error, {
699
+ failureKind: isConnectionConfigurationError(error) ? "configuration_error" : "execution_error"
533
700
  });
534
- return { run: failedRun, modelOutput: { error: message }, toolCallId: toolCall.id, toolName };
701
+ return {
702
+ run: failure.run,
703
+ modelOutput: failure.modelOutput,
704
+ toolCallId: toolCall.id,
705
+ toolName
706
+ };
535
707
  }
536
708
  }
537
709
  //# sourceMappingURL=builtin-tool-executors.js.map