@assemblyline-agents/runtime 1.0.0 → 3.0.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 (460) 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-capability-snapshot.d.ts +32 -0
  7. package/dist/agent-capability-snapshot.d.ts.map +1 -0
  8. package/dist/agent-capability-snapshot.js +77 -0
  9. package/dist/agent-capability-snapshot.js.map +1 -0
  10. package/dist/agent-event-handlers.d.ts +21 -0
  11. package/dist/agent-event-handlers.d.ts.map +1 -0
  12. package/dist/agent-event-handlers.js +64 -0
  13. package/dist/agent-event-handlers.js.map +1 -0
  14. package/dist/agent-hook-context.d.ts +8 -0
  15. package/dist/agent-hook-context.d.ts.map +1 -0
  16. package/dist/agent-hook-context.js +29 -0
  17. package/dist/agent-hook-context.js.map +1 -0
  18. package/dist/agent-hook-evaluation.d.ts +61 -0
  19. package/dist/agent-hook-evaluation.d.ts.map +1 -0
  20. package/dist/agent-hook-evaluation.js +197 -0
  21. package/dist/agent-hook-evaluation.js.map +1 -0
  22. package/dist/agent-hook-run-lifecycle.d.ts +44 -0
  23. package/dist/agent-hook-run-lifecycle.d.ts.map +1 -0
  24. package/dist/agent-hook-run-lifecycle.js +76 -0
  25. package/dist/agent-hook-run-lifecycle.js.map +1 -0
  26. package/dist/agent-state.d.ts +31 -0
  27. package/dist/agent-state.d.ts.map +1 -0
  28. package/dist/agent-state.js +80 -0
  29. package/dist/agent-state.js.map +1 -0
  30. package/dist/agent-surface.d.ts +32 -0
  31. package/dist/agent-surface.d.ts.map +1 -0
  32. package/dist/agent-surface.js +85 -0
  33. package/dist/agent-surface.js.map +1 -0
  34. package/dist/attachments.d.ts +5 -1
  35. package/dist/attachments.d.ts.map +1 -1
  36. package/dist/attachments.js +58 -32
  37. package/dist/attachments.js.map +1 -1
  38. package/dist/audience.d.ts +30 -0
  39. package/dist/audience.d.ts.map +1 -0
  40. package/dist/audience.js +68 -0
  41. package/dist/audience.js.map +1 -0
  42. package/dist/authored-hooks.d.ts +6 -0
  43. package/dist/authored-hooks.d.ts.map +1 -0
  44. package/dist/authored-hooks.js +17 -0
  45. package/dist/authored-hooks.js.map +1 -0
  46. package/dist/automation-event-match.d.ts +8 -0
  47. package/dist/automation-event-match.d.ts.map +1 -0
  48. package/dist/automation-event-match.js +25 -0
  49. package/dist/automation-event-match.js.map +1 -0
  50. package/dist/background-review-trigger.d.ts +9 -0
  51. package/dist/background-review-trigger.d.ts.map +1 -0
  52. package/dist/background-review-trigger.js +72 -0
  53. package/dist/background-review-trigger.js.map +1 -0
  54. package/dist/background-review-types.d.ts +60 -0
  55. package/dist/background-review-types.d.ts.map +1 -0
  56. package/dist/background-review-types.js +2 -0
  57. package/dist/background-review-types.js.map +1 -0
  58. package/dist/background-review-worker.d.ts +14 -0
  59. package/dist/background-review-worker.d.ts.map +1 -0
  60. package/dist/background-review-worker.js +61 -0
  61. package/dist/background-review-worker.js.map +1 -0
  62. package/dist/background-review.d.ts +5 -0
  63. package/dist/background-review.d.ts.map +1 -0
  64. package/dist/background-review.js +332 -0
  65. package/dist/background-review.js.map +1 -0
  66. package/dist/builtin-tool-executors.d.ts +50 -27
  67. package/dist/builtin-tool-executors.d.ts.map +1 -1
  68. package/dist/builtin-tool-executors.js +332 -124
  69. package/dist/builtin-tool-executors.js.map +1 -1
  70. package/dist/builtin-tools.d.ts +16 -9
  71. package/dist/builtin-tools.d.ts.map +1 -1
  72. package/dist/builtin-tools.js +308 -116
  73. package/dist/builtin-tools.js.map +1 -1
  74. package/dist/capability-catalog.d.ts +3 -2
  75. package/dist/capability-catalog.d.ts.map +1 -1
  76. package/dist/capability-catalog.js +12 -7
  77. package/dist/capability-catalog.js.map +1 -1
  78. package/dist/capability-inspection.d.ts +31 -0
  79. package/dist/capability-inspection.d.ts.map +1 -0
  80. package/dist/capability-inspection.js +58 -0
  81. package/dist/capability-inspection.js.map +1 -0
  82. package/dist/channel-http-util.d.ts.map +1 -1
  83. package/dist/channel-http-util.js +6 -5
  84. package/dist/channel-http-util.js.map +1 -1
  85. package/dist/channel-ingress.d.ts +16 -1
  86. package/dist/channel-ingress.d.ts.map +1 -1
  87. package/dist/channel-ingress.js +152 -14
  88. package/dist/channel-ingress.js.map +1 -1
  89. package/dist/channel.d.ts +73 -3
  90. package/dist/channel.d.ts.map +1 -1
  91. package/dist/checkpoints.d.ts +1 -1
  92. package/dist/checkpoints.d.ts.map +1 -1
  93. package/dist/checkpoints.js +6 -6
  94. package/dist/checkpoints.js.map +1 -1
  95. package/dist/child-process-env.d.ts +7 -0
  96. package/dist/child-process-env.d.ts.map +1 -0
  97. package/dist/child-process-env.js +41 -0
  98. package/dist/child-process-env.js.map +1 -0
  99. package/dist/computer-relay-protocol.d.ts.map +1 -1
  100. package/dist/computer-relay-protocol.js +4 -4
  101. package/dist/computer-relay-protocol.js.map +1 -1
  102. package/dist/concurrency.d.ts +1 -1
  103. package/dist/concurrency.js +1 -1
  104. package/dist/connection-auth-util.d.ts +1 -0
  105. package/dist/connection-auth-util.d.ts.map +1 -1
  106. package/dist/connection-auth-util.js +3 -1
  107. package/dist/connection-auth-util.js.map +1 -1
  108. package/dist/connection-clients.d.ts +11 -3
  109. package/dist/connection-clients.d.ts.map +1 -1
  110. package/dist/connection-clients.js +71 -8
  111. package/dist/connection-clients.js.map +1 -1
  112. package/dist/connection-event-store.d.ts +98 -0
  113. package/dist/connection-event-store.d.ts.map +1 -0
  114. package/dist/connection-event-store.js +162 -0
  115. package/dist/connection-event-store.js.map +1 -0
  116. package/dist/connection-events.d.ts +51 -0
  117. package/dist/connection-events.d.ts.map +1 -0
  118. package/dist/connection-events.js +343 -0
  119. package/dist/connection-events.js.map +1 -0
  120. package/dist/connection-stores.d.ts +6 -0
  121. package/dist/connection-stores.d.ts.map +1 -1
  122. package/dist/connection-stores.js +20 -1
  123. package/dist/connection-stores.js.map +1 -1
  124. package/dist/connection-util.d.ts +3 -2
  125. package/dist/connection-util.d.ts.map +1 -1
  126. package/dist/connection-util.js +18 -1
  127. package/dist/connection-util.js.map +1 -1
  128. package/dist/connections.d.ts +60 -5
  129. package/dist/connections.d.ts.map +1 -1
  130. package/dist/connections.js +390 -57
  131. package/dist/connections.js.map +1 -1
  132. package/dist/context-policy-util.d.ts.map +1 -1
  133. package/dist/context-policy-util.js +1 -3
  134. package/dist/context-policy-util.js.map +1 -1
  135. package/dist/conversation-context.d.ts +9 -4
  136. package/dist/conversation-context.d.ts.map +1 -1
  137. package/dist/conversation-context.js +65 -19
  138. package/dist/conversation-context.js.map +1 -1
  139. package/dist/conversation-transcript.d.ts +8 -5
  140. package/dist/conversation-transcript.d.ts.map +1 -1
  141. package/dist/conversation-transcript.js +24 -5
  142. package/dist/conversation-transcript.js.map +1 -1
  143. package/dist/conversation-turn-coalescing.d.ts +22 -0
  144. package/dist/conversation-turn-coalescing.d.ts.map +1 -0
  145. package/dist/conversation-turn-coalescing.js +121 -0
  146. package/dist/conversation-turn-coalescing.js.map +1 -0
  147. package/dist/conversation-turn-dispatch.d.ts +5 -2
  148. package/dist/conversation-turn-dispatch.d.ts.map +1 -1
  149. package/dist/conversation-turn-dispatch.js +59 -22
  150. package/dist/conversation-turn-dispatch.js.map +1 -1
  151. package/dist/default-outbound-route.d.ts +29 -0
  152. package/dist/default-outbound-route.d.ts.map +1 -0
  153. package/dist/default-outbound-route.js +105 -0
  154. package/dist/default-outbound-route.js.map +1 -0
  155. package/dist/delivery-artifacts.d.ts +2 -0
  156. package/dist/delivery-artifacts.d.ts.map +1 -0
  157. package/dist/delivery-artifacts.js +34 -0
  158. package/dist/delivery-artifacts.js.map +1 -0
  159. package/dist/delivery-files.d.ts +5 -0
  160. package/dist/delivery-files.d.ts.map +1 -0
  161. package/dist/delivery-files.js +33 -0
  162. package/dist/delivery-files.js.map +1 -0
  163. package/dist/delivery-queue.d.ts +21 -1
  164. package/dist/delivery-queue.d.ts.map +1 -1
  165. package/dist/delivery-queue.js +144 -1
  166. package/dist/delivery-queue.js.map +1 -1
  167. package/dist/delivery-send.d.ts +2 -2
  168. package/dist/delivery-send.d.ts.map +1 -1
  169. package/dist/delivery-send.js +256 -100
  170. package/dist/delivery-send.js.map +1 -1
  171. package/dist/durable-files.d.ts +37 -0
  172. package/dist/durable-files.d.ts.map +1 -0
  173. package/dist/durable-files.js +63 -0
  174. package/dist/durable-files.js.map +1 -0
  175. package/dist/harness-loop.d.ts +18 -9
  176. package/dist/harness-loop.d.ts.map +1 -1
  177. package/dist/harness-loop.js +245 -50
  178. package/dist/harness-loop.js.map +1 -1
  179. package/dist/heic-transcode-worker.d.ts +2 -0
  180. package/dist/heic-transcode-worker.d.ts.map +1 -0
  181. package/dist/heic-transcode-worker.js +59 -0
  182. package/dist/heic-transcode-worker.js.map +1 -0
  183. package/dist/heic-transcode.d.ts +18 -0
  184. package/dist/heic-transcode.d.ts.map +1 -0
  185. package/dist/heic-transcode.js +99 -0
  186. package/dist/heic-transcode.js.map +1 -0
  187. package/dist/human-input-routing.d.ts +22 -0
  188. package/dist/human-input-routing.d.ts.map +1 -0
  189. package/dist/human-input-routing.js +26 -0
  190. package/dist/human-input-routing.js.map +1 -0
  191. package/dist/in-memory-agent-state-store.d.ts +21 -0
  192. package/dist/in-memory-agent-state-store.d.ts.map +1 -0
  193. package/dist/in-memory-agent-state-store.js +97 -0
  194. package/dist/in-memory-agent-state-store.js.map +1 -0
  195. package/dist/in-memory-conversation-turn-store.d.ts +3 -1
  196. package/dist/in-memory-conversation-turn-store.d.ts.map +1 -1
  197. package/dist/in-memory-conversation-turn-store.js +41 -2
  198. package/dist/in-memory-conversation-turn-store.js.map +1 -1
  199. package/dist/in-memory-run-store.d.ts +8 -0
  200. package/dist/in-memory-run-store.d.ts.map +1 -1
  201. package/dist/in-memory-run-store.js +28 -5
  202. package/dist/in-memory-run-store.js.map +1 -1
  203. package/dist/in-memory-sandbox-session-store.d.ts +2 -1
  204. package/dist/in-memory-sandbox-session-store.d.ts.map +1 -1
  205. package/dist/in-memory-sandbox-session-store.js +65 -1
  206. package/dist/in-memory-sandbox-session-store.js.map +1 -1
  207. package/dist/in-memory-small-stores.d.ts +18 -1
  208. package/dist/in-memory-small-stores.d.ts.map +1 -1
  209. package/dist/in-memory-small-stores.js +107 -1
  210. package/dist/in-memory-small-stores.js.map +1 -1
  211. package/dist/in-memory-workspace-store.d.ts +40 -0
  212. package/dist/in-memory-workspace-store.d.ts.map +1 -0
  213. package/dist/in-memory-workspace-store.js +370 -0
  214. package/dist/in-memory-workspace-store.js.map +1 -0
  215. package/dist/index.d.ts +116 -45
  216. package/dist/index.d.ts.map +1 -1
  217. package/dist/index.js +637 -566
  218. package/dist/index.js.map +1 -1
  219. package/dist/json-util.d.ts +8 -0
  220. package/dist/json-util.d.ts.map +1 -1
  221. package/dist/json-util.js +8 -0
  222. package/dist/json-util.js.map +1 -1
  223. package/dist/learning-store.d.ts +111 -0
  224. package/dist/learning-store.d.ts.map +1 -0
  225. package/dist/learning-store.js +193 -0
  226. package/dist/learning-store.js.map +1 -0
  227. package/dist/local-sandbox.d.ts +3 -2
  228. package/dist/local-sandbox.d.ts.map +1 -1
  229. package/dist/local-sandbox.js +69 -25
  230. package/dist/local-sandbox.js.map +1 -1
  231. package/dist/mcp-client.d.ts.map +1 -1
  232. package/dist/mcp-client.js +3 -2
  233. package/dist/mcp-client.js.map +1 -1
  234. package/dist/media-processor.d.ts +42 -0
  235. package/dist/media-processor.d.ts.map +1 -0
  236. package/dist/media-processor.js +2 -0
  237. package/dist/media-processor.js.map +1 -0
  238. package/dist/model-media.d.ts +13 -1
  239. package/dist/model-media.d.ts.map +1 -1
  240. package/dist/model-media.js +81 -18
  241. package/dist/model-media.js.map +1 -1
  242. package/dist/model-visible-interrupts.d.ts +10 -0
  243. package/dist/model-visible-interrupts.d.ts.map +1 -0
  244. package/dist/model-visible-interrupts.js +41 -0
  245. package/dist/model-visible-interrupts.js.map +1 -0
  246. package/dist/operator-controls.d.ts.map +1 -1
  247. package/dist/operator-controls.js +16 -3
  248. package/dist/operator-controls.js.map +1 -1
  249. package/dist/outbound-http-policy.d.ts +7 -0
  250. package/dist/outbound-http-policy.d.ts.map +1 -0
  251. package/dist/outbound-http-policy.js +155 -0
  252. package/dist/outbound-http-policy.js.map +1 -0
  253. package/dist/principals.d.ts +18 -0
  254. package/dist/principals.d.ts.map +1 -0
  255. package/dist/principals.js +90 -0
  256. package/dist/principals.js.map +1 -0
  257. package/dist/public-api.d.ts +21 -0
  258. package/dist/public-api.d.ts.map +1 -0
  259. package/dist/public-api.js +19 -0
  260. package/dist/public-api.js.map +1 -0
  261. package/dist/replay-resume.d.ts +15 -3
  262. package/dist/replay-resume.d.ts.map +1 -1
  263. package/dist/replay-resume.js +256 -24
  264. package/dist/replay-resume.js.map +1 -1
  265. package/dist/resource-projection-util.d.ts +1 -1
  266. package/dist/resource-projection-util.d.ts.map +1 -1
  267. package/dist/resource-projection-util.js +21 -10
  268. package/dist/resource-projection-util.js.map +1 -1
  269. package/dist/resource-projection.d.ts +8 -1
  270. package/dist/resource-projection.d.ts.map +1 -1
  271. package/dist/resource-projection.js +230 -26
  272. package/dist/resource-projection.js.map +1 -1
  273. package/dist/run-heartbeat.d.ts +12 -2
  274. package/dist/run-heartbeat.d.ts.map +1 -1
  275. package/dist/run-heartbeat.js +31 -4
  276. package/dist/run-heartbeat.js.map +1 -1
  277. package/dist/run-outcome.d.ts +9 -5
  278. package/dist/run-outcome.d.ts.map +1 -1
  279. package/dist/run-outcome.js +16 -5
  280. package/dist/run-outcome.js.map +1 -1
  281. package/dist/run-recovery.d.ts +31 -2
  282. package/dist/run-recovery.d.ts.map +1 -1
  283. package/dist/run-recovery.js +211 -32
  284. package/dist/run-recovery.js.map +1 -1
  285. package/dist/run-replay.d.ts +35 -0
  286. package/dist/run-replay.d.ts.map +1 -0
  287. package/dist/run-replay.js +193 -0
  288. package/dist/run-replay.js.map +1 -0
  289. package/dist/run-result.d.ts +4 -0
  290. package/dist/run-result.d.ts.map +1 -0
  291. package/dist/run-result.js +18 -0
  292. package/dist/run-result.js.map +1 -0
  293. package/dist/run-timeline-query.d.ts +38 -0
  294. package/dist/run-timeline-query.d.ts.map +1 -0
  295. package/dist/run-timeline-query.js +99 -0
  296. package/dist/run-timeline-query.js.map +1 -0
  297. package/dist/runs-query.d.ts.map +1 -1
  298. package/dist/runs-query.js +12 -4
  299. package/dist/runs-query.js.map +1 -1
  300. package/dist/runtime-bundle.d.ts.map +1 -1
  301. package/dist/runtime-bundle.js +2 -0
  302. package/dist/runtime-bundle.js.map +1 -1
  303. package/dist/runtime-learning.d.ts +88 -0
  304. package/dist/runtime-learning.d.ts.map +1 -0
  305. package/dist/runtime-learning.js +260 -0
  306. package/dist/runtime-learning.js.map +1 -0
  307. package/dist/runtime-types.d.ts +79 -10
  308. package/dist/runtime-types.d.ts.map +1 -1
  309. package/dist/sandbox-fs.d.ts +9 -5
  310. package/dist/sandbox-fs.d.ts.map +1 -1
  311. package/dist/sandbox-fs.js +50 -33
  312. package/dist/sandbox-fs.js.map +1 -1
  313. package/dist/sandbox-handle.d.ts +25 -0
  314. package/dist/sandbox-handle.d.ts.map +1 -0
  315. package/dist/sandbox-handle.js +120 -0
  316. package/dist/sandbox-handle.js.map +1 -0
  317. package/dist/sandbox-session-identity.d.ts +14 -0
  318. package/dist/sandbox-session-identity.d.ts.map +1 -0
  319. package/dist/sandbox-session-identity.js +33 -0
  320. package/dist/sandbox-session-identity.js.map +1 -0
  321. package/dist/sandbox-session-key.d.ts.map +1 -1
  322. package/dist/sandbox-session-key.js +14 -10
  323. package/dist/sandbox-session-key.js.map +1 -1
  324. package/dist/sandbox-session-lifecycle.d.ts +12 -0
  325. package/dist/sandbox-session-lifecycle.d.ts.map +1 -0
  326. package/dist/sandbox-session-lifecycle.js +261 -0
  327. package/dist/sandbox-session-lifecycle.js.map +1 -0
  328. package/dist/sandbox-snapshot-policy.js +3 -3
  329. package/dist/sandbox-snapshot-policy.js.map +1 -1
  330. package/dist/sandbox-state-sync.d.ts +22 -0
  331. package/dist/sandbox-state-sync.d.ts.map +1 -0
  332. package/dist/sandbox-state-sync.js +147 -0
  333. package/dist/sandbox-state-sync.js.map +1 -0
  334. package/dist/sandbox-sync-worker.d.ts +11 -2
  335. package/dist/sandbox-sync-worker.d.ts.map +1 -1
  336. package/dist/sandbox-sync-worker.js +143 -31
  337. package/dist/sandbox-sync-worker.js.map +1 -1
  338. package/dist/schedule-execution.d.ts.map +1 -1
  339. package/dist/schedule-execution.js +187 -57
  340. package/dist/schedule-execution.js.map +1 -1
  341. package/dist/sdk-api-client.d.ts +17 -0
  342. package/dist/sdk-api-client.d.ts.map +1 -0
  343. package/dist/sdk-api-client.js +55 -0
  344. package/dist/sdk-api-client.js.map +1 -0
  345. package/dist/security.js +2 -2
  346. package/dist/security.js.map +1 -1
  347. package/dist/self-improvement.d.ts +34 -6
  348. package/dist/self-improvement.d.ts.map +1 -1
  349. package/dist/self-improvement.js +140 -34
  350. package/dist/self-improvement.js.map +1 -1
  351. package/dist/skill-bundles.d.ts +55 -0
  352. package/dist/skill-bundles.d.ts.map +1 -0
  353. package/dist/skill-bundles.js +134 -0
  354. package/dist/skill-bundles.js.map +1 -0
  355. package/dist/source-loader.d.ts +8 -0
  356. package/dist/source-loader.d.ts.map +1 -1
  357. package/dist/source-loader.js +41 -10
  358. package/dist/source-loader.js.map +1 -1
  359. package/dist/state-store-helpers.d.ts +2 -0
  360. package/dist/state-store-helpers.d.ts.map +1 -1
  361. package/dist/state-store-helpers.js +11 -1
  362. package/dist/state-store-helpers.js.map +1 -1
  363. package/dist/state-stores.d.ts +2 -0
  364. package/dist/state-stores.d.ts.map +1 -1
  365. package/dist/state-stores.js +40 -7
  366. package/dist/state-stores.js.map +1 -1
  367. package/dist/state.d.ts +344 -5
  368. package/dist/state.d.ts.map +1 -1
  369. package/dist/state.js +44 -2
  370. package/dist/state.js.map +1 -1
  371. package/dist/storage.d.ts +59 -2
  372. package/dist/storage.d.ts.map +1 -1
  373. package/dist/storage.js +183 -6
  374. package/dist/storage.js.map +1 -1
  375. package/dist/subagent-execution.d.ts +7 -6
  376. package/dist/subagent-execution.d.ts.map +1 -1
  377. package/dist/subagent-execution.js +58 -19
  378. package/dist/subagent-execution.js.map +1 -1
  379. package/dist/target-instructions.d.ts +14 -0
  380. package/dist/target-instructions.d.ts.map +1 -0
  381. package/dist/target-instructions.js +18 -0
  382. package/dist/target-instructions.js.map +1 -0
  383. package/dist/tool-apis.d.ts.map +1 -1
  384. package/dist/tool-apis.js +55 -10
  385. package/dist/tool-apis.js.map +1 -1
  386. package/dist/tool-execution.d.ts +26 -13
  387. package/dist/tool-execution.d.ts.map +1 -1
  388. package/dist/tool-execution.js +368 -239
  389. package/dist/tool-execution.js.map +1 -1
  390. package/dist/turn-media.d.ts +29 -0
  391. package/dist/turn-media.d.ts.map +1 -0
  392. package/dist/turn-media.js +233 -0
  393. package/dist/turn-media.js.map +1 -0
  394. package/dist/usage-reconciliation.d.ts +1 -1
  395. package/dist/usage-reconciliation.js +1 -1
  396. package/dist/workspace-id.d.ts +10 -0
  397. package/dist/workspace-id.d.ts.map +1 -0
  398. package/dist/workspace-id.js +55 -0
  399. package/dist/workspace-id.js.map +1 -0
  400. package/dist/workspace-manifest.d.ts +24 -0
  401. package/dist/workspace-manifest.d.ts.map +1 -0
  402. package/dist/workspace-manifest.js +111 -0
  403. package/dist/workspace-manifest.js.map +1 -0
  404. package/dist/workspace-operation-limiter.d.ts +16 -0
  405. package/dist/workspace-operation-limiter.d.ts.map +1 -0
  406. package/dist/workspace-operation-limiter.js +31 -0
  407. package/dist/workspace-operation-limiter.js.map +1 -0
  408. package/dist/workspace-operations.d.ts +145 -0
  409. package/dist/workspace-operations.d.ts.map +1 -0
  410. package/dist/workspace-operations.js +420 -0
  411. package/dist/workspace-operations.js.map +1 -0
  412. package/dist/workspace-runtime.d.ts +110 -0
  413. package/dist/workspace-runtime.d.ts.map +1 -0
  414. package/dist/workspace-runtime.js +240 -0
  415. package/dist/workspace-runtime.js.map +1 -0
  416. package/dist/workspace-search.d.ts +55 -0
  417. package/dist/workspace-search.d.ts.map +1 -0
  418. package/dist/workspace-search.js +262 -0
  419. package/dist/workspace-search.js.map +1 -0
  420. package/dist/workspace-service.d.ts +173 -0
  421. package/dist/workspace-service.d.ts.map +1 -0
  422. package/dist/workspace-service.js +619 -0
  423. package/dist/workspace-service.js.map +1 -0
  424. package/dist/workspace.d.ts +7 -0
  425. package/dist/workspace.d.ts.map +1 -0
  426. package/dist/workspace.js +7 -0
  427. package/dist/workspace.js.map +1 -0
  428. package/package.json +7 -4
  429. package/dist/agent-harness.d.ts +0 -108
  430. package/dist/agent-harness.d.ts.map +0 -1
  431. package/dist/agent-harness.js +0 -2
  432. package/dist/agent-harness.js.map +0 -1
  433. package/dist/attachments-legacy.d.ts +0 -17
  434. package/dist/attachments-legacy.d.ts.map +0 -1
  435. package/dist/attachments-legacy.js +0 -273
  436. package/dist/attachments-legacy.js.map +0 -1
  437. package/dist/code-mode.d.ts +0 -20
  438. package/dist/code-mode.d.ts.map +0 -1
  439. package/dist/code-mode.js +0 -658
  440. package/dist/code-mode.js.map +0 -1
  441. package/dist/hook-dispatch.d.ts +0 -19
  442. package/dist/hook-dispatch.d.ts.map +0 -1
  443. package/dist/hook-dispatch.js +0 -37
  444. package/dist/hook-dispatch.js.map +0 -1
  445. package/dist/pi-agent-harness.d.ts +0 -40
  446. package/dist/pi-agent-harness.d.ts.map +0 -1
  447. package/dist/pi-agent-harness.js +0 -222
  448. package/dist/pi-agent-harness.js.map +0 -1
  449. package/dist/pi-harness.d.ts +0 -42
  450. package/dist/pi-harness.d.ts.map +0 -1
  451. package/dist/pi-harness.js +0 -142
  452. package/dist/pi-harness.js.map +0 -1
  453. package/dist/run-resolver.d.ts +0 -35
  454. package/dist/run-resolver.d.ts.map +0 -1
  455. package/dist/run-resolver.js +0 -84
  456. package/dist/run-resolver.js.map +0 -1
  457. package/dist/usage-budget.d.ts +0 -29
  458. package/dist/usage-budget.d.ts.map +0 -1
  459. package/dist/usage-budget.js +0 -145
  460. package/dist/usage-budget.js.map +0 -1
@@ -1,37 +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";
12
+ import { initiatorFromRun, principalFromRun } from "./principals.js";
13
+ import { authorizationRequiredModelOutput } from "./model-visible-interrupts.js";
11
14
  /**
12
15
  * Runtime-handled tool executors: the builtin skill/discovery tools
13
- * (load_skill, tool_search, tool_describe), the deferred local tool catalog,
14
- * the tool-call bookkeeping those paths share, and the connection tool
15
- * 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.
16
19
  * None of these route through an authored tool definition, so their records
17
20
  * are written here rather than by executeToolWithRecord in
18
21
  * ./tool-execution.js. Imports only the {@link ToolExecutionHost} type from
19
22
  * ./tool-execution.js, so the value-level module graph stays acyclic.
20
23
  */
21
- export async function skillLoadDetailsImpl(host, skillName) {
22
- await host.ensureSkillsSeeded();
23
- const skill = await host.skillStore.get(host.skillScope(), skillName);
24
- if (!skill || skill.pending)
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);
29
+ if (!skill || skill.pending || skill.archived)
25
30
  throw new Error(`Skill not found: ${skillName}`);
26
31
  const parsed = parseSkillBody(skill.body);
27
- 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 = {
28
39
  name: skill.name,
29
40
  description: parsed.description || `Skill ${skill.name}`,
30
41
  declaredTools: parsed.allowedTools,
31
42
  instructions: parsed.instructions,
32
43
  origin: skill.origin,
33
- 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)
34
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
+ }
35
69
  }
36
70
  export function createConnectionRegistryImpl(host, channel, turn) {
37
71
  const session = { channel };
@@ -41,18 +75,24 @@ export function createConnectionRegistryImpl(host, channel, turn) {
41
75
  session.userId = turn.userId;
42
76
  if (turn?.metadata)
43
77
  session.metadata = turn.metadata;
78
+ if (turn?.principal)
79
+ session.principal = turn.principal;
80
+ if (turn?.initiator)
81
+ session.initiator = turn.initiator;
44
82
  return new RuntimeConnectionRegistry({
45
83
  connections: host.mergedConnections(),
46
84
  env: host.env,
47
85
  fetch: host.fetch,
48
86
  session,
87
+ audience: turn?.audience ?? { private: true },
88
+ agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
49
89
  grantStore: host.connectionGrantStore,
50
90
  authorizationSessionStore: host.connectionAuthorizationSessionStore,
51
91
  ...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
52
92
  loadDefinition: async (connection) => host.loadConnectionDefinition(connection)
53
93
  });
54
94
  }
55
- export function createConnectionRegistryForRunImpl(host, run, fallbackChannel, sandboxHandle) {
95
+ export function createConnectionRegistryForRunImpl(host, run, fallbackChannel, sandboxHandle, selectedConnections) {
56
96
  const session = {
57
97
  channel: typeof run.input.channel === "string" ? run.input.channel : fallbackChannel
58
98
  };
@@ -62,17 +102,26 @@ export function createConnectionRegistryForRunImpl(host, run, fallbackChannel, s
62
102
  session.userId = run.input.userId;
63
103
  if (isJsonObject(run.input.metadata))
64
104
  session.metadata = run.input.metadata;
65
- const subagentName = typeof run.input.subagent === "string" ? run.input.subagent : undefined;
66
- const scopedConnectionNames = subagentName
67
- ? new Set(host.manifest.subagents.find((subagent) => subagent.name === subagentName)?.connections ?? [])
68
- : undefined;
105
+ const principal = principalFromRun(run);
106
+ const initiator = initiatorFromRun(run);
107
+ if (principal)
108
+ session.principal = principal;
109
+ if (initiator)
110
+ session.initiator = initiator;
111
+ const surface = host.surfaceForRun(run);
112
+ const subagentConnectionNames = surface.path !== "root" ? new Set(surface.connections) : undefined;
113
+ const scopedConnectionNames = selectedConnections && subagentConnectionNames
114
+ ? new Set([...selectedConnections].filter((name) => subagentConnectionNames.has(name)))
115
+ : selectedConnections ?? subagentConnectionNames;
69
116
  return new RuntimeConnectionRegistry({
70
- connections: scopedConnectionNames
117
+ connections: (scopedConnectionNames
71
118
  ? host.mergedConnections().filter((connection) => scopedConnectionNames.has(connection.name))
72
- : host.mergedConnections(),
119
+ : host.mergedConnections()),
73
120
  env: host.env,
74
121
  fetch: host.fetch,
75
122
  session,
123
+ audience: audienceFromRun(run),
124
+ agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
76
125
  grantStore: host.connectionGrantStore,
77
126
  authorizationSessionStore: host.connectionAuthorizationSessionStore,
78
127
  ...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
@@ -108,11 +157,16 @@ export async function beginConnectionAuthorizationImpl(host, connectionName, ses
108
157
  resolverSession.conversationId = session.conversationId;
109
158
  if (session.userId)
110
159
  resolverSession.userId = session.userId;
160
+ if (session.principal)
161
+ resolverSession.principal = session.principal;
162
+ if (session.initiator)
163
+ resolverSession.initiator = session.initiator;
111
164
  const registry = new RuntimeConnectionRegistry({
112
165
  connections: host.mergedConnections(),
113
166
  env: host.env,
114
167
  fetch: host.fetch,
115
168
  session: resolverSession,
169
+ agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
116
170
  grantStore: host.connectionGrantStore,
117
171
  authorizationSessionStore: host.connectionAuthorizationSessionStore,
118
172
  ...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
@@ -126,6 +180,7 @@ export function createConnectionRegistryForSessionImpl(host, session) {
126
180
  env: host.env,
127
181
  fetch: host.fetch,
128
182
  session: session.session,
183
+ agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
129
184
  grantStore: host.connectionGrantStore,
130
185
  authorizationSessionStore: host.connectionAuthorizationSessionStore,
131
186
  ...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
@@ -135,12 +190,17 @@ export function createConnectionRegistryForSessionImpl(host, session) {
135
190
  export async function executeLoadSkillTool(host, run, state, input, idempotencyKey) {
136
191
  const raw = isJsonObject(input) ? input : {};
137
192
  const requested = stringValue(raw.name) || stringValue(raw.skillName) || stringValue(raw.path);
138
- const skillName = requested ? skillNameFromSkillPath(requested) ?? requested : "";
193
+ const skillName = requested
194
+ ? skillNameFromLoadInput(host, requested) ?? requested
195
+ : "";
139
196
  const toolCall = await recordRuntimeHandledToolStart(host, run, LOAD_SKILL_TOOL_NAME, input, idempotencyKey);
140
197
  try {
141
198
  if (!skillName)
142
199
  throw new Error("load_skill requires name.");
143
- const loaded = await skillLoadDetailsImpl(host, skillName);
200
+ if (!state.allowedSkills.has(skillName)) {
201
+ throw new Error(`Skill ${skillName} is not enabled by the current agent capability snapshot.`);
202
+ }
203
+ const loaded = await skillLoadDetailsImpl(host, run, skillName);
144
204
  let sandboxProjected = false;
145
205
  const activeSandbox = state.sandboxHandle.current();
146
206
  if (activeSandbox) {
@@ -166,24 +226,109 @@ export async function executeLoadSkillTool(host, run, state, input, idempotencyK
166
226
  };
167
227
  if (loaded.declaredTools.length > 0)
168
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
+ }
169
239
  await completeRuntimeHandledTool(host, run, toolCall, LOAD_SKILL_TOOL_NAME, output);
170
240
  await host.state.appendEvent(run.id, "skill.loaded", {
171
241
  skill: loaded.name,
172
242
  origin: loaded.origin,
173
243
  path: loaded.path,
244
+ ...(loaded.bundle ? { bundle: loaded.bundle.id } : {}),
245
+ resourceCount: loaded.resourceCount,
174
246
  sandboxProjected
175
247
  });
176
248
  return { run: await host.state.getRun(run.id) ?? run, modelOutput: output, skillName: loaded.name };
177
249
  }
178
250
  catch (error) {
179
- 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);
180
325
  }
181
326
  }
182
327
  export async function executeToolSearchTool(host, run, state, input, idempotencyKey) {
183
328
  const request = normalizeDeferredToolSearchInput(input);
184
329
  const toolCall = await recordRuntimeHandledToolStart(host, run, TOOL_SEARCH_TOOL_NAME, input, idempotencyKey);
185
330
  try {
186
- const local = await searchDeferredLocalTools(host, request.query, request.limit);
331
+ const local = searchDeferredTools(host, run, request.query, request.limit);
187
332
  const connectionResults = state.connectionRegistry.hasLiveConnections()
188
333
  ? await state.connectionRegistry.search({
189
334
  keywords: request.query,
@@ -195,7 +340,16 @@ export async function executeToolSearchTool(host, run, state, input, idempotency
195
340
  toolName: TOOL_SEARCH_TOOL_NAME
196
341
  })
197
342
  : [];
198
- for (const result of connectionResults) {
343
+ const connectionFailures = connectionResults.filter((result) => result.error && result.needsAuthorization !== true);
344
+ const connectionStatuses = connectionResults.filter((result) => result.needsAuthorization === true);
345
+ const connectionMatches = connectionResults.filter((result) => !result.error);
346
+ const actionableConnectionMatches = connectionMatches.filter((result) => result.qualifiedName && result.tool && result.inputSchema);
347
+ if (connectionFailures.length > 0 && local.length === 0 && actionableConnectionMatches.length === 0) {
348
+ throw new Error(`Deferred connection tool discovery failed: ${connectionFailures
349
+ .map((result) => `${result.connection}: ${result.error}`)
350
+ .join("; ")}`);
351
+ }
352
+ for (const result of actionableConnectionMatches) {
199
353
  if (!result.qualifiedName || !result.tool || !result.inputSchema)
200
354
  continue;
201
355
  const metadata = {
@@ -208,10 +362,18 @@ export async function executeToolSearchTool(host, run, state, input, idempotency
208
362
  if (result.outputSchema)
209
363
  metadata.outputSchema = result.outputSchema;
210
364
  state.discoveredConnectionTools.set(result.qualifiedName, metadata);
365
+ state.activeToolNames.add(result.qualifiedName);
211
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
+ ];
212
373
  const output = {
213
374
  query: request.query,
214
- totalAvailable: deferredLocalTools(host).length + connectionResults.length,
375
+ totalAvailable: deferredTools(host, run).length + connectionMatches.length,
376
+ activated,
215
377
  matches: [
216
378
  ...local.map((tool) => ({
217
379
  name: tool.name,
@@ -220,84 +382,33 @@ export async function executeToolSearchTool(host, run, state, input, idempotency
220
382
  tags: tool.tags ?? [],
221
383
  aliases: tool.aliases ?? []
222
384
  })),
223
- ...connectionResults.map(connectionSearchResultForModel)
385
+ ...connectionMatches.map(connectionSearchResultForModel)
224
386
  ].slice(0, request.limit)
225
387
  };
226
- await completeRuntimeHandledTool(host, run, toolCall, TOOL_SEARCH_TOOL_NAME, output);
227
- return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
228
- }
229
- catch (error) {
230
- return failRuntimeHandledTool(host, run, toolCall, TOOL_SEARCH_TOOL_NAME, error, { recoverable: true });
231
- }
232
- }
233
- export async function executeToolDescribeTool(host, run, state, input, idempotencyKey) {
234
- const raw = isJsonObject(input) ? input : {};
235
- const name = stringValue(raw.name);
236
- const toolCall = await recordRuntimeHandledToolStart(host, run, TOOL_DESCRIBE_TOOL_NAME, input, idempotencyKey);
237
- try {
238
- if (!name)
239
- throw new Error("tool_describe requires name.");
240
- const local = deferredLocalTools(host).find((tool) => tool.name === name);
241
- if (local) {
242
- const definition = await host.loadTool(local);
243
- const output = {
244
- name: local.name,
245
- kind: "tool",
246
- description: definition.description ?? local.description,
247
- inputSchema: safeJson(definition.inputSchema ?? local.inputSchema),
248
- outputSchema: safeJson(definition.outputSchema ?? local.outputSchema ?? {})
249
- };
250
- await completeRuntimeHandledTool(host, run, toolCall, TOOL_DESCRIBE_TOOL_NAME, output);
251
- return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
388
+ if (connectionStatuses.length > 0) {
389
+ output.connectionStatuses = connectionStatuses.map(connectionSearchResultForModel);
252
390
  }
253
- let connection = state.discoveredConnectionTools.get(name);
254
- if (!connection && parseQualifiedName(name) && state.connectionRegistry.hasLiveConnections()) {
255
- const parsed = parseQualifiedName(name);
256
- const results = parsed
257
- ? await state.connectionRegistry.search({ keywords: parsed.toolName, connection: parsed.connectionName, limit: 10 }, {
258
- runId: run.id,
259
- toolCallId: toolCall.id,
260
- toolName: TOOL_DESCRIBE_TOOL_NAME
261
- })
262
- : [];
263
- const result = results.find((candidate) => candidate.qualifiedName === name);
264
- if (result?.qualifiedName && result.tool && result.inputSchema) {
265
- connection = {
266
- connection: result.connection,
267
- name: result.tool,
268
- qualifiedName: result.qualifiedName,
269
- description: result.description,
270
- inputSchema: result.inputSchema,
271
- ...(result.outputSchema ? { outputSchema: result.outputSchema } : {})
272
- };
273
- state.discoveredConnectionTools.set(name, connection);
274
- }
391
+ if (connectionFailures.length > 0) {
392
+ output.connectionErrors = connectionFailures.map(connectionSearchResultForModel);
275
393
  }
276
- if (!connection)
277
- throw new Error(`Deferred tool not found: ${name}`);
278
- const output = {
279
- name: connection.qualifiedName,
280
- kind: "connection_tool",
281
- connection: connection.connection,
282
- description: connection.description,
283
- inputSchema: safeJson(connection.inputSchema),
284
- outputSchema: safeJson(connection.outputSchema ?? {})
285
- };
286
- await completeRuntimeHandledTool(host, run, toolCall, TOOL_DESCRIBE_TOOL_NAME, output);
394
+ await completeRuntimeHandledTool(host, run, toolCall, TOOL_SEARCH_TOOL_NAME, output);
287
395
  return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
288
396
  }
289
397
  catch (error) {
290
- return failRuntimeHandledTool(host, run, toolCall, TOOL_DESCRIBE_TOOL_NAME, error, { recoverable: true });
398
+ return failRuntimeHandledTool(host, run, toolCall, TOOL_SEARCH_TOOL_NAME, error);
291
399
  }
292
400
  }
293
- export function deferredLocalTools(host) {
294
- return runtimeToolsForManifest(host.manifest)
295
- .filter((tool) => !CORE_HARNESS_TOOL_NAMES.includes(tool.name))
296
- .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
+ });
297
408
  }
298
- async function searchDeferredLocalTools(host, query, limit) {
409
+ function searchDeferredTools(host, run, query, limit) {
299
410
  const lower = query.toLowerCase();
300
- return deferredLocalTools(host)
411
+ return deferredTools(host, run)
301
412
  .map((tool) => ({
302
413
  tool,
303
414
  haystack: [
@@ -312,13 +423,14 @@ async function searchDeferredLocalTools(host, query, limit) {
312
423
  .map((entry) => entry.tool)
313
424
  .slice(0, limit);
314
425
  }
315
- async function recordRuntimeHandledToolStart(host, run, toolName, input, idempotencyKey) {
426
+ export async function recordRuntimeHandledToolStart(host, run, toolName, input, idempotencyKey) {
316
427
  await host.state.appendEvent(run.id, "tool.call_requested", { toolName, input: redactedToolInput(input) });
317
428
  let toolCall = await host.state.createToolCall({
318
429
  runId: run.id,
319
430
  toolName,
320
431
  status: "requested",
321
- input: redactedToolInput(input),
432
+ // Raw, not redacted: resume paths re-execute persisted tool-call input.
433
+ input: safeJson(input),
322
434
  idempotencyKey
323
435
  });
324
436
  toolCall = await host.state.updateToolCall(toolCall.id, { status: "running" });
@@ -337,21 +449,86 @@ async function completeRuntimeHandledTool(host, run, toolCall, toolName, output)
337
449
  modelOutput: safeJson(output)
338
450
  });
339
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
+ */
340
457
  export async function failRuntimeHandledTool(host, run, toolCall, toolName, error, options) {
341
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
+ };
342
468
  await host.state.updateToolCall(toolCall.id, { status: "failed", error: message });
343
- await host.state.appendEvent(run.id, "tool.execution_failed", { toolCallId: toolCall.id, toolName, error: message });
344
- if (options?.recoverable) {
345
- // Model-invoked discovery tools: return the error to the model to reason
346
- // over rather than irreversibly failing the whole run.
347
- return { run, modelOutput: { error: message } };
348
- }
349
- const failedRun = await failRun({ state: host.state }, run.id, {
350
- reason: "tool.execution_failed",
469
+ await host.state.appendEvent(run.id, "tool.execution_failed", {
470
+ toolCallId: toolCall.id,
471
+ toolName,
351
472
  error: message,
352
- data: { toolCallId: toolCall.id, toolName }
473
+ failureKind,
474
+ recoverable: true
353
475
  });
354
- 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("; ")}`);
355
532
  }
356
533
  export async function executeConnectionSearchTool(host, run, registry, input, idempotencyKey) {
357
534
  await host.state.appendEvent(run.id, "tool.call_requested", { toolName: CONNECTION_SEARCH_TOOL_NAME, input: redactedToolInput(input) });
@@ -359,7 +536,8 @@ export async function executeConnectionSearchTool(host, run, registry, input, id
359
536
  runId: run.id,
360
537
  toolName: CONNECTION_SEARCH_TOOL_NAME,
361
538
  status: "requested",
362
- input: redactedToolInput(input),
539
+ // Raw, not redacted: resume paths re-execute persisted tool-call input.
540
+ input: safeJson(input),
363
541
  idempotencyKey
364
542
  });
365
543
  await host.state.updateToolCall(toolCall.id, { status: "running" });
@@ -394,17 +572,24 @@ export async function executeConnectionSearchTool(host, run, registry, input, id
394
572
  // Recoverable: model-invoked discovery, so return the error, don't fail the run.
395
573
  const message = error instanceof Error ? error.message : String(error);
396
574
  await host.state.updateToolCall(toolCall.id, { status: "failed", error: message });
397
- 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
+ });
398
582
  return { run: await host.state.getRun(run.id) ?? run, results: [{ connection: "connection_search", description: "Connection search failed.", error: message }] };
399
583
  }
400
584
  }
401
- 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") {
402
586
  await host.state.appendEvent(run.id, "tool.call_requested", { toolName, input: redactedToolInput(input) });
403
587
  let toolCall = await host.state.createToolCall({
404
588
  runId: run.id,
405
589
  toolName,
406
590
  status: "requested",
407
- input: redactedToolInput(input),
591
+ // Raw, not redacted: connection-auth resume re-executes this input.
592
+ input: safeJson(input),
408
593
  idempotencyKey
409
594
  });
410
595
  const parsed = parseQualifiedName(toolName);
@@ -425,7 +610,7 @@ export async function executeConnectionTool(host, run, registry, toolName, input
425
610
  toolName,
426
611
  source: "eval"
427
612
  });
428
- return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input);
613
+ return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input, authorizationBehavior);
429
614
  }
430
615
  if (approval.mode !== "never" && !approved) {
431
616
  toolCall = await host.state.updateToolCall(toolCall.id, { status: "waiting_for_approval" });
@@ -442,9 +627,9 @@ export async function executeConnectionTool(host, run, registry, toolName, input
442
627
  });
443
628
  return { run: waitingRun, waitingForApproval: true, toolCallId: toolCall.id, toolName };
444
629
  }
445
- return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input);
630
+ return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input, authorizationBehavior);
446
631
  }
447
- export async function executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input) {
632
+ export async function executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input, authorizationBehavior = "pause") {
448
633
  await host.state.updateToolCall(toolCall.id, { status: "running" });
449
634
  await host.state.appendEvent(run.id, "tool.execution_started", { toolCallId: toolCall.id, toolName });
450
635
  try {
@@ -472,9 +657,13 @@ export async function executeConnectionToolWithRecordImpl(host, run, registry, t
472
657
  }
473
658
  catch (error) {
474
659
  if (isConnectionAuthorizationRequiredError(error)) {
475
- await host.state.updateToolCall(toolCall.id, { status: "failed", error: error.message });
476
- const waitingRun = await host.state.updateRun(run.id, { status: "waiting_for_connection" });
477
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
+ });
478
667
  await host.state.appendEvent(run.id, "authorization.required", {
479
668
  toolCallId: toolCall.id,
480
669
  toolName,
@@ -482,20 +671,39 @@ export async function executeConnectionToolWithRecordImpl(host, run, registry, t
482
671
  reason: error.reason,
483
672
  challenge: safeJson(error.challenge ?? {})
484
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" });
485
689
  const out = { run: waitingRun, waitingForConnection: true, toolCallId: toolCall.id, toolName };
486
690
  if (authorizationSessionId)
487
691
  out.authorizationSessionId = authorizationSessionId;
488
692
  return out;
489
693
  }
490
- const message = error instanceof Error ? error.message : String(error);
491
- await host.state.updateToolCall(toolCall.id, { status: "failed", error: message });
492
- await host.state.appendEvent(run.id, "tool.execution_failed", { toolCallId: toolCall.id, toolName, error: message });
493
- const failedRun = await failRun({ state: host.state }, run.id, {
494
- reason: "connection.tool_failed",
495
- error: message,
496
- 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"
497
700
  });
498
- 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
+ };
499
707
  }
500
708
  }
501
709
  //# sourceMappingURL=builtin-tool-executors.js.map