stitchkit 0.133.1 → 0.134.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 (621) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +14 -11
  3. package/dist/agent-executor/acp/v1-connect.d.ts +5 -0
  4. package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
  5. package/dist/agent-executor/acp/v1-map.d.ts +13 -3
  6. package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
  7. package/dist/agent-executor/acp/v1-probe.d.ts +3 -0
  8. package/dist/agent-executor/acp/v1-probe.d.ts.map +1 -1
  9. package/dist/agent-executor/acp/v1-protocol.d.ts +61 -0
  10. package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -1
  11. package/dist/agent-executor/acp/v1-session.d.ts +3 -0
  12. package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
  13. package/dist/agent-executor/codex/connect.d.ts +2 -0
  14. package/dist/agent-executor/codex/connect.d.ts.map +1 -1
  15. package/dist/agent-executor/codex/driver.d.ts +3 -0
  16. package/dist/agent-executor/codex/driver.d.ts.map +1 -1
  17. package/dist/agent-executor/contract.d.ts +42 -0
  18. package/dist/agent-executor/contract.d.ts.map +1 -1
  19. package/dist/agent-executor/engine-process.d.ts +20 -0
  20. package/dist/agent-executor/engine-process.d.ts.map +1 -1
  21. package/dist/agent-executor/executor-contract.d.ts +42 -0
  22. package/dist/agent-executor/executor-contract.d.ts.map +1 -1
  23. package/dist/agent-executor/handoff-schemas.d.ts +30 -0
  24. package/dist/agent-executor/handoff-schemas.d.ts.map +1 -1
  25. package/dist/agent-executor/projection.d.ts.map +1 -1
  26. package/dist/agent-executor/session-primitives.d.ts +4 -1
  27. package/dist/agent-executor/session-primitives.d.ts.map +1 -1
  28. package/dist/agent-executor/testing/consumer-stubs.d.ts.map +1 -1
  29. package/dist/agent-executor/vocabulary.d.ts +100 -0
  30. package/dist/agent-executor/vocabulary.d.ts.map +1 -1
  31. package/dist/agent-parts/model.d.ts +1559 -0
  32. package/dist/agent-parts/model.d.ts.map +1 -0
  33. package/dist/agent-parts/parts.d.ts +21 -0
  34. package/dist/agent-parts/parts.d.ts.map +1 -1
  35. package/dist/agent-runtime/ai-sdk-convert.d.ts +15 -0
  36. package/dist/agent-runtime/ai-sdk-convert.d.ts.map +1 -0
  37. package/dist/agent-runtime/ai-sdk.d.ts +31 -0
  38. package/dist/agent-runtime/ai-sdk.d.ts.map +1 -0
  39. package/dist/agent-runtime/anthropic-media.d.ts +11 -0
  40. package/dist/agent-runtime/anthropic-media.d.ts.map +1 -0
  41. package/dist/agent-runtime/anthropic-messages.d.ts +24 -0
  42. package/dist/agent-runtime/anthropic-messages.d.ts.map +1 -0
  43. package/dist/agent-runtime/anthropic-options.d.ts +79 -0
  44. package/dist/agent-runtime/anthropic-options.d.ts.map +1 -0
  45. package/dist/agent-runtime/anthropic-response.d.ts +19 -0
  46. package/dist/agent-runtime/anthropic-response.d.ts.map +1 -0
  47. package/dist/agent-runtime/anthropic-sse.d.ts +4 -0
  48. package/dist/agent-runtime/anthropic-sse.d.ts.map +1 -0
  49. package/dist/agent-runtime/anthropic.d.ts +27 -0
  50. package/dist/agent-runtime/anthropic.d.ts.map +1 -0
  51. package/dist/agent-runtime/branch-observations.d.ts +25 -25
  52. package/dist/agent-runtime/branch-provider.d.ts +86 -0
  53. package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
  54. package/dist/agent-runtime/branch-replay.d.ts +30 -0
  55. package/dist/agent-runtime/branch-replay.d.ts.map +1 -1
  56. package/dist/agent-runtime/browser-control-contract.d.ts +204 -0
  57. package/dist/agent-runtime/browser-control-contract.d.ts.map +1 -1
  58. package/dist/agent-runtime/browser-controller-view.d.ts +44 -0
  59. package/dist/agent-runtime/browser-controller-view.d.ts.map +1 -0
  60. package/dist/agent-runtime/browser-controller.d.ts +12 -8
  61. package/dist/agent-runtime/browser-controller.d.ts.map +1 -1
  62. package/dist/agent-runtime/child-budget-policy.d.ts +2 -3
  63. package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -1
  64. package/dist/agent-runtime/compaction.d.ts +27 -10
  65. package/dist/agent-runtime/compaction.d.ts.map +1 -1
  66. package/dist/agent-runtime/control-interaction-schema.d.ts +157 -0
  67. package/dist/agent-runtime/control-interaction-schema.d.ts.map +1 -0
  68. package/dist/agent-runtime/control-schema.d.ts +183 -27
  69. package/dist/agent-runtime/control-schema.d.ts.map +1 -1
  70. package/dist/agent-runtime/control-view.d.ts +64 -0
  71. package/dist/agent-runtime/control-view.d.ts.map +1 -0
  72. package/dist/agent-runtime/conversations.d.ts +10 -0
  73. package/dist/agent-runtime/conversations.d.ts.map +1 -1
  74. package/dist/agent-runtime/deferred-tool-selection.d.ts +2 -2
  75. package/dist/agent-runtime/deferred-tool-selection.d.ts.map +1 -1
  76. package/dist/agent-runtime/deferred-tool-types.d.ts +2 -2
  77. package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
  78. package/dist/agent-runtime/deferred-tools-internal.d.ts +8 -11
  79. package/dist/agent-runtime/deferred-tools-internal.d.ts.map +1 -1
  80. package/dist/agent-runtime/deferred-tools.d.ts.map +1 -1
  81. package/dist/agent-runtime/event-schema.d.ts +80 -0
  82. package/dist/agent-runtime/event-schema.d.ts.map +1 -1
  83. package/dist/agent-runtime/harness-contract.d.ts +2 -2
  84. package/dist/agent-runtime/harness-contract.d.ts.map +1 -1
  85. package/dist/agent-runtime/harness-control.d.ts.map +1 -1
  86. package/dist/agent-runtime/harness-realtime.d.ts.map +1 -1
  87. package/dist/agent-runtime/harness.d.ts +2 -2
  88. package/dist/agent-runtime/harness.d.ts.map +1 -1
  89. package/dist/agent-runtime/history.d.ts +25 -16
  90. package/dist/agent-runtime/history.d.ts.map +1 -1
  91. package/dist/agent-runtime/invocation-attempt.d.ts +7 -3
  92. package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
  93. package/dist/agent-runtime/invocation-payload.d.ts +13 -7
  94. package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
  95. package/dist/agent-runtime/invocation-stream.d.ts +20 -0
  96. package/dist/agent-runtime/invocation-stream.d.ts.map +1 -0
  97. package/dist/agent-runtime/invocations.d.ts +2 -2
  98. package/dist/agent-runtime/invocations.d.ts.map +1 -1
  99. package/dist/agent-runtime/models-driver-step.d.ts +212 -0
  100. package/dist/agent-runtime/models-driver-step.d.ts.map +1 -0
  101. package/dist/agent-runtime/models-driver-telemetry.d.ts +42 -0
  102. package/dist/agent-runtime/models-driver-telemetry.d.ts.map +1 -0
  103. package/dist/agent-runtime/models-driver.d.ts +235 -0
  104. package/dist/agent-runtime/models-driver.d.ts.map +1 -0
  105. package/dist/agent-runtime/models.d.ts +3 -26
  106. package/dist/agent-runtime/models.d.ts.map +1 -1
  107. package/dist/agent-runtime/observability.d.ts +64 -0
  108. package/dist/agent-runtime/observability.d.ts.map +1 -1
  109. package/dist/agent-runtime/openai-messages.d.ts +11 -0
  110. package/dist/agent-runtime/openai-messages.d.ts.map +1 -0
  111. package/dist/agent-runtime/openai-options.d.ts +91 -0
  112. package/dist/agent-runtime/openai-options.d.ts.map +1 -0
  113. package/dist/agent-runtime/openai-response.d.ts +77 -0
  114. package/dist/agent-runtime/openai-response.d.ts.map +1 -0
  115. package/dist/agent-runtime/openai-sse-state.d.ts +54 -0
  116. package/dist/agent-runtime/openai-sse-state.d.ts.map +1 -0
  117. package/dist/agent-runtime/openai-sse.d.ts +4 -0
  118. package/dist/agent-runtime/openai-sse.d.ts.map +1 -0
  119. package/dist/agent-runtime/openai.d.ts +31 -0
  120. package/dist/agent-runtime/openai.d.ts.map +1 -0
  121. package/dist/agent-runtime/openrouter-admission.d.ts +3 -0
  122. package/dist/agent-runtime/openrouter-admission.d.ts.map +1 -1
  123. package/dist/agent-runtime/openrouter-benchmarks.d.ts +17 -0
  124. package/dist/agent-runtime/openrouter-benchmarks.d.ts.map +1 -0
  125. package/dist/agent-runtime/openrouter-catalog-cache.d.ts +70 -0
  126. package/dist/agent-runtime/openrouter-catalog-cache.d.ts.map +1 -0
  127. package/dist/agent-runtime/openrouter-catalog-query.d.ts +57 -0
  128. package/dist/agent-runtime/openrouter-catalog-query.d.ts.map +1 -0
  129. package/dist/agent-runtime/openrouter-catalog.d.ts +189 -14
  130. package/dist/agent-runtime/openrouter-catalog.d.ts.map +1 -1
  131. package/dist/agent-runtime/openrouter-models.d.ts +168 -31
  132. package/dist/agent-runtime/openrouter-models.d.ts.map +1 -1
  133. package/dist/agent-runtime/openrouter-options.d.ts +45 -15
  134. package/dist/agent-runtime/openrouter-options.d.ts.map +1 -1
  135. package/dist/agent-runtime/openrouter-response.d.ts +22 -0
  136. package/dist/agent-runtime/openrouter-response.d.ts.map +1 -0
  137. package/dist/agent-runtime/openrouter.d.ts +21 -24
  138. package/dist/agent-runtime/openrouter.d.ts.map +1 -1
  139. package/dist/agent-runtime/owned-provider-stream.d.ts +4 -4
  140. package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -1
  141. package/dist/agent-runtime/prompt.d.ts +3 -3
  142. package/dist/agent-runtime/prompt.d.ts.map +1 -1
  143. package/dist/agent-runtime/protocol.d.ts +28 -3
  144. package/dist/agent-runtime/protocol.d.ts.map +1 -1
  145. package/dist/agent-runtime/provider-cache.d.ts +30 -0
  146. package/dist/agent-runtime/provider-cache.d.ts.map +1 -0
  147. package/dist/agent-runtime/provider-content.d.ts +147 -0
  148. package/dist/agent-runtime/provider-content.d.ts.map +1 -1
  149. package/dist/agent-runtime/provider-failure.d.ts +51 -26
  150. package/dist/agent-runtime/provider-failure.d.ts.map +1 -1
  151. package/dist/agent-runtime/provider-history.d.ts +13 -0
  152. package/dist/agent-runtime/provider-history.d.ts.map +1 -0
  153. package/dist/agent-runtime/provider-http.d.ts +68 -0
  154. package/dist/agent-runtime/provider-http.d.ts.map +1 -0
  155. package/dist/agent-runtime/provider-journal.d.ts +149 -0
  156. package/dist/agent-runtime/provider-journal.d.ts.map +1 -1
  157. package/dist/agent-runtime/provider-json-schema-strip.d.ts +8 -0
  158. package/dist/agent-runtime/provider-json-schema-strip.d.ts.map +1 -0
  159. package/dist/agent-runtime/provider-json-schema.d.ts +28 -0
  160. package/dist/agent-runtime/provider-json-schema.d.ts.map +1 -0
  161. package/dist/agent-runtime/provider-media.d.ts +49 -0
  162. package/dist/agent-runtime/provider-media.d.ts.map +1 -0
  163. package/dist/agent-runtime/provider-openai-chat-helpers.d.ts +27 -0
  164. package/dist/agent-runtime/provider-openai-chat-helpers.d.ts.map +1 -0
  165. package/dist/agent-runtime/provider-openai-chat-sse.d.ts +25 -0
  166. package/dist/agent-runtime/provider-openai-chat-sse.d.ts.map +1 -0
  167. package/dist/agent-runtime/provider-openai-chat.d.ts +27 -0
  168. package/dist/agent-runtime/provider-openai-chat.d.ts.map +1 -0
  169. package/dist/agent-runtime/provider-origin.d.ts +3 -12
  170. package/dist/agent-runtime/provider-origin.d.ts.map +1 -1
  171. package/dist/agent-runtime/provider-sse.d.ts +30 -0
  172. package/dist/agent-runtime/provider-sse.d.ts.map +1 -0
  173. package/dist/agent-runtime/provider-stream-parts.d.ts +5 -0
  174. package/dist/agent-runtime/provider-stream-parts.d.ts.map +1 -0
  175. package/dist/agent-runtime/provider-stream-segments.d.ts +63 -0
  176. package/dist/agent-runtime/provider-stream-segments.d.ts.map +1 -0
  177. package/dist/agent-runtime/provider-usage.d.ts +24 -0
  178. package/dist/agent-runtime/provider-usage.d.ts.map +1 -0
  179. package/dist/agent-runtime/retry-policy.d.ts +19 -3
  180. package/dist/agent-runtime/retry-policy.d.ts.map +1 -1
  181. package/dist/agent-runtime/run-acquisition.d.ts +4 -4
  182. package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
  183. package/dist/agent-runtime/run-approval.d.ts +82 -0
  184. package/dist/agent-runtime/run-approval.d.ts.map +1 -0
  185. package/dist/agent-runtime/run-complete-retry.d.ts +24 -0
  186. package/dist/agent-runtime/run-complete-retry.d.ts.map +1 -0
  187. package/dist/agent-runtime/run-complete-stream.d.ts +9 -0
  188. package/dist/agent-runtime/run-complete-stream.d.ts.map +1 -0
  189. package/dist/agent-runtime/run-complete-tools.d.ts +21 -0
  190. package/dist/agent-runtime/run-complete-tools.d.ts.map +1 -0
  191. package/dist/agent-runtime/run-complete-types.d.ts +168 -0
  192. package/dist/agent-runtime/run-complete-types.d.ts.map +1 -0
  193. package/dist/agent-runtime/run-complete.d.ts +25 -0
  194. package/dist/agent-runtime/run-complete.d.ts.map +1 -0
  195. package/dist/agent-runtime/run-driver-compose.d.ts +21 -0
  196. package/dist/agent-runtime/run-driver-compose.d.ts.map +1 -0
  197. package/dist/agent-runtime/run-execution-state.d.ts +23 -10
  198. package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
  199. package/dist/agent-runtime/run-execution.d.ts +2 -2
  200. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  201. package/dist/agent-runtime/run-failure.d.ts +2 -2
  202. package/dist/agent-runtime/run-failure.d.ts.map +1 -1
  203. package/dist/agent-runtime/run-history-parts.d.ts +14 -0
  204. package/dist/agent-runtime/run-history-parts.d.ts.map +1 -0
  205. package/dist/agent-runtime/run-loop-events.d.ts +126 -0
  206. package/dist/agent-runtime/run-loop-events.d.ts.map +1 -0
  207. package/dist/agent-runtime/run-model-attempts.d.ts +2 -2
  208. package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
  209. package/dist/agent-runtime/run-model-messages.d.ts +9 -0
  210. package/dist/agent-runtime/run-model-messages.d.ts.map +1 -0
  211. package/dist/agent-runtime/run-model-step.d.ts +43 -0
  212. package/dist/agent-runtime/run-model-step.d.ts.map +1 -0
  213. package/dist/agent-runtime/run-model-stream.d.ts +27 -0
  214. package/dist/agent-runtime/run-model-stream.d.ts.map +1 -0
  215. package/dist/agent-runtime/run-operation-lifecycle.d.ts +8 -4
  216. package/dist/agent-runtime/run-operation-lifecycle.d.ts.map +1 -1
  217. package/dist/agent-runtime/run-prompt-history.d.ts +8 -13
  218. package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -1
  219. package/dist/agent-runtime/run-provider-ledger.d.ts +7 -4
  220. package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -1
  221. package/dist/agent-runtime/run-step-barriers.d.ts +58 -16
  222. package/dist/agent-runtime/run-step-barriers.d.ts.map +1 -1
  223. package/dist/agent-runtime/run-step-helpers.d.ts +49 -0
  224. package/dist/agent-runtime/run-step-helpers.d.ts.map +1 -0
  225. package/dist/agent-runtime/run-step-prepare.d.ts +34 -0
  226. package/dist/agent-runtime/run-step-prepare.d.ts.map +1 -0
  227. package/dist/agent-runtime/run-step-spend.d.ts +85 -10
  228. package/dist/agent-runtime/run-step-spend.d.ts.map +1 -1
  229. package/dist/agent-runtime/run-stream-parts.d.ts +13 -9
  230. package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -1
  231. package/dist/agent-runtime/run-stream-recorded.d.ts +8 -0
  232. package/dist/agent-runtime/run-stream-recorded.d.ts.map +1 -0
  233. package/dist/agent-runtime/run-stream-step-text.d.ts +29 -0
  234. package/dist/agent-runtime/run-stream-step-text.d.ts.map +1 -0
  235. package/dist/agent-runtime/run-terminal.d.ts +3 -3
  236. package/dist/agent-runtime/run-terminal.d.ts.map +1 -1
  237. package/dist/agent-runtime/run-tool-approval-flow.d.ts +36 -0
  238. package/dist/agent-runtime/run-tool-approval-flow.d.ts.map +1 -0
  239. package/dist/agent-runtime/run-tool-approval-records.d.ts +24 -0
  240. package/dist/agent-runtime/run-tool-approval-records.d.ts.map +1 -0
  241. package/dist/agent-runtime/run-tool-call.d.ts +73 -0
  242. package/dist/agent-runtime/run-tool-call.d.ts.map +1 -0
  243. package/dist/agent-runtime/run-tool-errors.d.ts +29 -0
  244. package/dist/agent-runtime/run-tool-errors.d.ts.map +1 -0
  245. package/dist/agent-runtime/run-tool-executor.d.ts +34 -0
  246. package/dist/agent-runtime/run-tool-executor.d.ts.map +1 -0
  247. package/dist/agent-runtime/run-tool-progress.d.ts +2 -2
  248. package/dist/agent-runtime/run-tool-progress.d.ts.map +1 -1
  249. package/dist/agent-runtime/run-turn-preparation.d.ts +7 -6
  250. package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -1
  251. package/dist/agent-runtime/run-unacquired.d.ts +2 -2
  252. package/dist/agent-runtime/run-unacquired.d.ts.map +1 -1
  253. package/dist/agent-runtime/runtime-control.d.ts +4 -4
  254. package/dist/agent-runtime/runtime-control.d.ts.map +1 -1
  255. package/dist/agent-runtime/runtime-internals.d.ts +35 -44
  256. package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
  257. package/dist/agent-runtime/runtime-recovery.d.ts +3 -3
  258. package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -1
  259. package/dist/agent-runtime/runtime-state.d.ts +3 -3
  260. package/dist/agent-runtime/runtime-state.d.ts.map +1 -1
  261. package/dist/agent-runtime/runtime-submit.d.ts +2 -2
  262. package/dist/agent-runtime/runtime-submit.d.ts.map +1 -1
  263. package/dist/agent-runtime/runtime.d.ts +51 -16
  264. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  265. package/dist/agent-runtime/sandbox-process-linux.d.ts +8 -0
  266. package/dist/agent-runtime/sandbox-process-linux.d.ts.map +1 -0
  267. package/dist/agent-runtime/sandbox-process-macos.d.ts +21 -0
  268. package/dist/agent-runtime/sandbox-process-macos.d.ts.map +1 -0
  269. package/dist/agent-runtime/sandbox-process-spec.d.ts +114 -0
  270. package/dist/agent-runtime/sandbox-process-spec.d.ts.map +1 -0
  271. package/dist/agent-runtime/sandbox-process-wrapper.d.ts +19 -0
  272. package/dist/agent-runtime/sandbox-process-wrapper.d.ts.map +1 -0
  273. package/dist/agent-runtime/schemas-message.d.ts +10 -0
  274. package/dist/agent-runtime/schemas-message.d.ts.map +1 -1
  275. package/dist/agent-runtime/schemas-provider.d.ts +2 -0
  276. package/dist/agent-runtime/schemas-provider.d.ts.map +1 -1
  277. package/dist/agent-runtime/schemas-run.d.ts +10 -0
  278. package/dist/agent-runtime/schemas-run.d.ts.map +1 -1
  279. package/dist/agent-runtime/schemas-usage-state.d.ts +6 -0
  280. package/dist/agent-runtime/schemas-usage-state.d.ts.map +1 -0
  281. package/dist/agent-runtime/schemas-usage.d.ts +8 -0
  282. package/dist/agent-runtime/schemas-usage.d.ts.map +1 -1
  283. package/dist/agent-runtime/sql-rows.d.ts +20 -10
  284. package/dist/agent-runtime/sql-rows.d.ts.map +1 -1
  285. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +40 -20
  286. package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -1
  287. package/dist/agent-runtime/store-conformance-support.d.ts +20 -10
  288. package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -1
  289. package/dist/agent-runtime/store-driver-contract.d.ts +70 -0
  290. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
  291. package/dist/agent-runtime/store-events.d.ts +120 -0
  292. package/dist/agent-runtime/store-events.d.ts.map +1 -1
  293. package/dist/agent-runtime/store.d.ts +140 -0
  294. package/dist/agent-runtime/store.d.ts.map +1 -1
  295. package/dist/agent-runtime/terminal-commit.d.ts +10 -0
  296. package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
  297. package/dist/agent-runtime/testing.d.ts +20 -0
  298. package/dist/agent-runtime/testing.d.ts.map +1 -1
  299. package/dist/browser/client-call-arguments.d.ts.map +1 -1
  300. package/dist/browser/client-executors.d.ts.map +1 -1
  301. package/dist/browser/client-url.d.ts.map +1 -1
  302. package/dist/browser/client.d.ts +6 -0
  303. package/dist/browser/client.d.ts.map +1 -1
  304. package/dist/browser/device-presence-client.d.ts +42 -0
  305. package/dist/browser/device-presence-client.d.ts.map +1 -0
  306. package/dist/browser/device-presence-ops.d.ts +47 -0
  307. package/dist/browser/device-presence-ops.d.ts.map +1 -0
  308. package/dist/browser/device-presence-relay-adapter.d.ts +37 -0
  309. package/dist/browser/device-presence-relay-adapter.d.ts.map +1 -0
  310. package/dist/browser/http-fetch.d.ts +7 -2
  311. package/dist/browser/http-fetch.d.ts.map +1 -1
  312. package/dist/browser/http-helpers.d.ts +15 -0
  313. package/dist/browser/http-helpers.d.ts.map +1 -0
  314. package/dist/browser/http.d.ts +8 -0
  315. package/dist/browser/http.d.ts.map +1 -1
  316. package/dist/contract/client-types.d.ts +8 -0
  317. package/dist/contract/client-types.d.ts.map +1 -1
  318. package/dist/contract/runtime-context.d.ts +13 -1
  319. package/dist/contract/runtime-context.d.ts.map +1 -1
  320. package/dist/device-relay/agent-handlers.d.ts +45 -0
  321. package/dist/device-relay/agent-handlers.d.ts.map +1 -0
  322. package/dist/device-relay/agent.d.ts +80 -0
  323. package/dist/device-relay/agent.d.ts.map +1 -0
  324. package/dist/device-relay/broker.d.ts +49 -0
  325. package/dist/device-relay/broker.d.ts.map +1 -0
  326. package/dist/device-relay/contract.d.ts +614 -0
  327. package/dist/device-relay/contract.d.ts.map +1 -0
  328. package/dist/device-relay/encoding.d.ts +30 -0
  329. package/dist/device-relay/encoding.d.ts.map +1 -0
  330. package/dist/device-relay/hub-connection.d.ts +43 -0
  331. package/dist/device-relay/hub-connection.d.ts.map +1 -0
  332. package/dist/device-relay/hub-dispatch.d.ts +19 -0
  333. package/dist/device-relay/hub-dispatch.d.ts.map +1 -0
  334. package/dist/device-relay/hub-handshake.d.ts +20 -0
  335. package/dist/device-relay/hub-handshake.d.ts.map +1 -0
  336. package/dist/device-relay/hub-shared-streams.d.ts +24 -0
  337. package/dist/device-relay/hub-shared-streams.d.ts.map +1 -0
  338. package/dist/device-relay/hub-streams.d.ts +57 -0
  339. package/dist/device-relay/hub-streams.d.ts.map +1 -0
  340. package/dist/device-relay/hub.d.ts +117 -0
  341. package/dist/device-relay/hub.d.ts.map +1 -0
  342. package/dist/entrypoints/agent-executor/acp.d.ts +1 -1
  343. package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
  344. package/dist/entrypoints/agent-executor/acp.js +224 -47
  345. package/dist/entrypoints/agent-executor/claude-sdk.js +15 -15
  346. package/dist/entrypoints/agent-executor/claude.js +13 -15
  347. package/dist/entrypoints/agent-executor/codex.js +88 -48
  348. package/dist/entrypoints/agent-executor/testing/claude-sdk.js +5 -5
  349. package/dist/entrypoints/agent-executor/testing.js +31 -30
  350. package/dist/entrypoints/agent-executor.d.ts +2 -2
  351. package/dist/entrypoints/agent-executor.d.ts.map +1 -1
  352. package/dist/entrypoints/agent-executor.js +23 -17
  353. package/dist/entrypoints/agent-runtime/ai-sdk.d.ts +9 -0
  354. package/dist/entrypoints/agent-runtime/ai-sdk.d.ts.map +1 -0
  355. package/dist/entrypoints/agent-runtime/ai-sdk.js +821 -0
  356. package/dist/entrypoints/agent-runtime/anthropic.d.ts +4 -0
  357. package/dist/entrypoints/agent-runtime/anthropic.d.ts.map +1 -0
  358. package/dist/entrypoints/agent-runtime/anthropic.js +1260 -0
  359. package/dist/entrypoints/agent-runtime/browser.d.ts +4 -1
  360. package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -1
  361. package/dist/entrypoints/agent-runtime/browser.js +449 -50
  362. package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
  363. package/dist/entrypoints/agent-runtime/harness.js +24 -19
  364. package/dist/entrypoints/agent-runtime/openai.d.ts +4 -0
  365. package/dist/entrypoints/agent-runtime/openai.d.ts.map +1 -0
  366. package/dist/entrypoints/agent-runtime/openai.js +1246 -0
  367. package/dist/entrypoints/agent-runtime/openrouter.d.ts +5 -2
  368. package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
  369. package/dist/entrypoints/agent-runtime/openrouter.js +2355 -371
  370. package/dist/entrypoints/agent-runtime/postgres.js +12 -10
  371. package/dist/entrypoints/agent-runtime/realtime.js +11 -10
  372. package/dist/entrypoints/agent-runtime/sandbox.d.ts +3 -0
  373. package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -1
  374. package/dist/entrypoints/agent-runtime/sandbox.js +530 -7
  375. package/dist/entrypoints/agent-runtime/sqlite/bun.js +13 -11
  376. package/dist/entrypoints/agent-runtime/sqlite/node.js +13 -11
  377. package/dist/entrypoints/agent-runtime/testing.d.ts +1 -1
  378. package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -1
  379. package/dist/entrypoints/agent-runtime/testing.js +56 -15
  380. package/dist/entrypoints/agent-runtime.d.ts +14 -6
  381. package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
  382. package/dist/entrypoints/agent-runtime.js +1412 -115
  383. package/dist/entrypoints/application/diagnostic-journal.js +6 -6
  384. package/dist/entrypoints/application/directory-inbox.js +6 -6
  385. package/dist/entrypoints/application/opentelemetry.js +3 -3
  386. package/dist/entrypoints/application.js +17 -17
  387. package/dist/entrypoints/cli/publish.js +8 -8
  388. package/dist/entrypoints/cli.js +14 -15
  389. package/dist/entrypoints/contract.d.ts +1 -0
  390. package/dist/entrypoints/contract.d.ts.map +1 -1
  391. package/dist/entrypoints/contract.js +13 -9
  392. package/dist/entrypoints/device-relay.d.ts +10 -0
  393. package/dist/entrypoints/device-relay.d.ts.map +1 -0
  394. package/dist/entrypoints/device-relay.js +2517 -0
  395. package/dist/entrypoints/files/packaging.js +3 -3
  396. package/dist/entrypoints/files.js +11 -11
  397. package/dist/entrypoints/geo.js +5 -5
  398. package/dist/entrypoints/google.js +1 -1
  399. package/dist/entrypoints/handler.js +6 -6
  400. package/dist/entrypoints/http.js +9 -9
  401. package/dist/entrypoints/index.js +21 -17
  402. package/dist/entrypoints/live.js +4 -4
  403. package/dist/entrypoints/node.js +13 -13
  404. package/dist/entrypoints/observability.js +9 -9
  405. package/dist/entrypoints/process/bootstrap.js +1 -1
  406. package/dist/entrypoints/process.js +5 -5
  407. package/dist/entrypoints/react.js +4 -4
  408. package/dist/entrypoints/realtime.d.ts +3 -0
  409. package/dist/entrypoints/realtime.d.ts.map +1 -1
  410. package/dist/entrypoints/realtime.js +413 -4
  411. package/dist/entrypoints/release.js +1 -1
  412. package/dist/entrypoints/remote.js +10 -10
  413. package/dist/entrypoints/server.d.ts +1 -0
  414. package/dist/entrypoints/server.d.ts.map +1 -1
  415. package/dist/entrypoints/server.js +546 -40
  416. package/dist/entrypoints/service-host/macos.js +10 -10
  417. package/dist/entrypoints/service-host/work.js +7 -7
  418. package/dist/entrypoints/service-host.js +15 -15
  419. package/dist/entrypoints/spend.js +3 -3
  420. package/dist/entrypoints/sync.js +4 -4
  421. package/dist/entrypoints/telegram/screens.js +6 -6
  422. package/dist/entrypoints/telegram.js +20 -20
  423. package/dist/entrypoints/testing.js +14 -14
  424. package/dist/entrypoints/tools/agent.d.ts +2 -1
  425. package/dist/entrypoints/tools/agent.d.ts.map +1 -1
  426. package/dist/entrypoints/tools/agent.js +8 -7
  427. package/dist/entrypoints/tools/connections.js +5 -5
  428. package/dist/entrypoints/tools/invoker.js +3 -4
  429. package/dist/entrypoints/tools/mcp.js +8 -9
  430. package/dist/entrypoints/tools/toolkit.js +32 -13
  431. package/dist/entrypoints/tools.d.ts +3 -1
  432. package/dist/entrypoints/tools.d.ts.map +1 -1
  433. package/dist/entrypoints/tools.js +37 -35
  434. package/dist/entrypoints/tracking/contract.js +1 -1
  435. package/dist/entrypoints/tracking/performance.js +4 -4
  436. package/dist/entrypoints/tracking.js +3 -3
  437. package/dist/{index-09f7w2qq.js → index-02kdtrcd.js} +1 -1
  438. package/dist/{index-y53cqwke.js → index-033tyx59.js} +1 -1
  439. package/dist/{index-9ft4n9j1.js → index-05b65gj4.js} +2 -2
  440. package/dist/{index-d04w81fz.js → index-0sxj3y45.js} +1 -1
  441. package/dist/{index-dm6nxkn1.js → index-18pf56dq.js} +4 -6
  442. package/dist/index-1gmgwfn3.js +439 -0
  443. package/dist/index-23wn8sgf.js +47 -0
  444. package/dist/{index-tqjamnax.js → index-27srek2g.js} +15 -13
  445. package/dist/{index-2nwvn7m2.js → index-29v1p1f4.js} +2 -2
  446. package/dist/index-36dmtzjr.js +194 -0
  447. package/dist/{index-ycr4pk0z.js → index-42n9jycn.js} +3 -3
  448. package/dist/{index-ke02kxsr.js → index-43k180c2.js} +1 -1
  449. package/dist/{index-pbekeqzm.js → index-5c4m8zdf.js} +2 -2
  450. package/dist/{index-qggqqja2.js → index-5dxgx3yj.js} +1 -1
  451. package/dist/{index-x5ayy5bn.js → index-5gdexvke.js} +3 -1
  452. package/dist/{index-t1a2jrg7.js → index-5xsxvk2x.js} +1 -1
  453. package/dist/{index-mbd92r1w.js → index-654rhe5d.js} +1 -1
  454. package/dist/{index-2dzc7mv9.js → index-67pnt4bh.js} +1 -1
  455. package/dist/index-6kpwkpgx.js +415 -0
  456. package/dist/{index-s43tr4my.js → index-6kwdfb9m.js} +18 -3
  457. package/dist/{index-1qwd54n3.js → index-6nzzj7qr.js} +1 -1
  458. package/dist/{index-rkjfzs0a.js → index-6p5pshcd.js} +2 -2
  459. package/dist/{index-118aebbg.js → index-6t4c98gr.js} +1 -1
  460. package/dist/{index-pws5c3x6.js → index-6xw1wf4m.js} +51 -32
  461. package/dist/{index-kwsr7j5k.js → index-6yb4stq3.js} +1 -1
  462. package/dist/{index-8jf4bt7v.js → index-76yhxa41.js} +8 -8
  463. package/dist/{index-7416mhyh.js → index-79vqbjcz.js} +1 -1
  464. package/dist/{index-13wmzpa6.js → index-7an2fs5h.js} +1 -1
  465. package/dist/index-7qza24g1.js +14 -0
  466. package/dist/{index-gtaaxe9d.js → index-8cek82ar.js} +1 -1
  467. package/dist/index-9f60gnfn.js +393 -0
  468. package/dist/{index-stpy56r3.js → index-aacwkve4.js} +209 -10
  469. package/dist/{index-rpyn7geq.js → index-ac3rfec5.js} +2 -2
  470. package/dist/{index-d2drhb9c.js → index-b0mh2t9x.js} +2 -2
  471. package/dist/index-b23s6e2c.js +158 -0
  472. package/dist/{index-an7vcmwf.js → index-bvpevwt6.js} +5 -5
  473. package/dist/{index-msxf2r8x.js → index-by8w2461.js} +1 -1
  474. package/dist/{index-8t9dr41h.js → index-c0yym4a0.js} +4 -4
  475. package/dist/{index-wddcfbng.js → index-c7fj4yw9.js} +1 -1
  476. package/dist/{index-tf70nm22.js → index-cb4nnvfr.js} +8 -6
  477. package/dist/{index-205456mf.js → index-d3s070eh.js} +2 -2
  478. package/dist/{index-apf5g7y9.js → index-dz6tstcp.js} +2 -2
  479. package/dist/{index-agy5fqgf.js → index-e1y74yra.js} +15 -8
  480. package/dist/index-edtg4tak.js +55 -0
  481. package/dist/{index-pq6g1k9t.js → index-ek9w11r0.js} +2 -2
  482. package/dist/{index-x46y9z26.js → index-epyj7ptp.js} +7 -5
  483. package/dist/{index-6kmjcm81.js → index-er483f3w.js} +93 -4
  484. package/dist/{index-827bgv33.js → index-f16b7rze.js} +1 -1
  485. package/dist/{index-gbhj370g.js → index-fec05c9k.js} +21 -21
  486. package/dist/{index-9wdrwx3b.js → index-fjac2w5e.js} +20 -22
  487. package/dist/{index-6918kxbf.js → index-fthw8dwa.js} +1 -0
  488. package/dist/{index-2mz8hj58.js → index-g04hszcm.js} +1 -1
  489. package/dist/{index-rw8ze745.js → index-ga6avd48.js} +1 -1
  490. package/dist/{index-paff5y0r.js → index-grhhsrd5.js} +9 -7
  491. package/dist/{index-mxt0wfjy.js → index-h20qcyh5.js} +5 -2
  492. package/dist/index-j3r7r1mh.js +150 -0
  493. package/dist/{index-vgytj9wp.js → index-jmaw365j.js} +1 -1
  494. package/dist/{index-t5g5rm9n.js → index-jzdbkanz.js} +5 -3
  495. package/dist/index-k137ezb6.js +79 -0
  496. package/dist/{index-tazm4dxf.js → index-kdw0n92g.js} +1 -1
  497. package/dist/{index-wh70tmpd.js → index-ke6jtxkd.js} +1 -1
  498. package/dist/index-kgj8j7bv.js +83 -0
  499. package/dist/{index-9kpxz49v.js → index-kgkevngs.js} +1 -1
  500. package/dist/{index-hab790s6.js → index-kp1j7cc8.js} +4 -4
  501. package/dist/{index-jcge9tx3.js → index-krekhmp7.js} +142 -123
  502. package/dist/{index-3y2tzhr8.js → index-ky79wwgs.js} +4 -4
  503. package/dist/{index-39rmc00v.js → index-mfe9a266.js} +1 -1
  504. package/dist/{index-qpzyahe3.js → index-mgr0mdqp.js} +5 -2
  505. package/dist/{index-n20tybgk.js → index-mh3jdb25.js} +2 -2
  506. package/dist/{index-g5fgeb6v.js → index-mkmep637.js} +1 -1
  507. package/dist/{index-02r5sq9p.js → index-mrng24wq.js} +19 -21
  508. package/dist/index-mx2gya05.js +465 -0
  509. package/dist/{index-8yt3rwe7.js → index-n2t87ggz.js} +5 -5
  510. package/dist/index-nfeafbzh.js +7379 -0
  511. package/dist/{index-j0ef04jw.js → index-nfm15ej7.js} +4 -4
  512. package/dist/index-pd9e8rz4.js +193 -0
  513. package/dist/{index-zwgwyvdt.js → index-pdcbjd6a.js} +1 -1
  514. package/dist/{index-q427q23r.js → index-pjjh91vw.js} +2 -2
  515. package/dist/{index-gnjgkecx.js → index-q46b16xz.js} +1 -1
  516. package/dist/{index-9xr44d2g.js → index-qv5v6w9c.js} +330 -106
  517. package/dist/{index-tmv3ez1h.js → index-qymek778.js} +69 -12
  518. package/dist/{index-yrr3n391.js → index-ry8m2mhg.js} +2 -2
  519. package/dist/{index-93n6jwy0.js → index-s0n0nnz5.js} +3 -3
  520. package/dist/{index-1p8q0yrt.js → index-t5zp1jjj.js} +5 -7
  521. package/dist/{index-2rf33y2h.js → index-tav72wz5.js} +4 -2
  522. package/dist/{index-jpecjm30.js → index-tgehj4bp.js} +1 -1
  523. package/dist/{index-ma26mfnt.js → index-v5hmyef8.js} +1 -1
  524. package/dist/index-vebzvse6.js +230 -0
  525. package/dist/index-vv0hxrmy.js +295 -0
  526. package/dist/index-vxm0ya3f.js +707 -0
  527. package/dist/{index-t3qcac2a.js → index-w3s79kcb.js} +1 -1
  528. package/dist/{index-r97ppg0g.js → index-x1r7kxzd.js} +1 -1
  529. package/dist/{index-kynwa08q.js → index-xrsryvd2.js} +2 -2
  530. package/dist/{index-3mcbr8sx.js → index-xtxxt87z.js} +1 -1
  531. package/dist/index-zk839vzf.js +231 -0
  532. package/dist/{index-9c76vfxf.js → index-zyyerdny.js} +4 -4
  533. package/dist/internal/base64.d.ts +9 -0
  534. package/dist/internal/base64.d.ts.map +1 -0
  535. package/dist/internal/deadline-budget.d.ts +57 -0
  536. package/dist/internal/deadline-budget.d.ts.map +1 -0
  537. package/dist/internal/deadline.d.ts.map +1 -1
  538. package/dist/internal/timers.d.ts +2 -0
  539. package/dist/internal/timers.d.ts.map +1 -1
  540. package/dist/realtime/device-presence-contract.d.ts +194 -0
  541. package/dist/realtime/device-presence-contract.d.ts.map +1 -0
  542. package/dist/server/context-contribution.d.ts.map +1 -1
  543. package/dist/server/contract-method.d.ts.map +1 -1
  544. package/dist/server/device-presence-handlers.d.ts +54 -0
  545. package/dist/server/device-presence-handlers.d.ts.map +1 -0
  546. package/dist/server/device-presence-registry.d.ts +35 -0
  547. package/dist/server/device-presence-registry.d.ts.map +1 -0
  548. package/dist/server/device-presence.d.ts +45 -0
  549. package/dist/server/device-presence.d.ts.map +1 -0
  550. package/dist/server/endpoint-dispatch.d.ts.map +1 -1
  551. package/dist/server/middleware/cors.d.ts +3 -1
  552. package/dist/server/middleware/cors.d.ts.map +1 -1
  553. package/dist/server/types.d.ts +4 -11
  554. package/dist/server/types.d.ts.map +1 -1
  555. package/dist/service-host/systemd-render-shared.d.ts.map +1 -1
  556. package/dist/tools/agent-messages.d.ts +6 -0
  557. package/dist/tools/agent-messages.d.ts.map +1 -0
  558. package/dist/tools/agent-tool-error.d.ts +2 -2
  559. package/dist/tools/agent-tools.d.ts +153 -0
  560. package/dist/tools/agent-tools.d.ts.map +1 -0
  561. package/dist/tools/agent.d.ts +6 -56
  562. package/dist/tools/agent.d.ts.map +1 -1
  563. package/dist/tools/runtime-tool.d.ts +3 -4
  564. package/dist/tools/runtime-tool.d.ts.map +1 -1
  565. package/dist/tools/toolkit.d.ts +3 -1
  566. package/dist/tools/toolkit.d.ts.map +1 -1
  567. package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
  568. package/llms/agent-executor-acp.txt +4 -4
  569. package/llms/agent-executor-codex.txt +1 -1
  570. package/llms/agent-executor.txt +7 -3
  571. package/llms/agent-runtime-ai-sdk.txt +26 -0
  572. package/llms/agent-runtime-anthropic.txt +33 -0
  573. package/llms/agent-runtime-browser.txt +22 -8
  574. package/llms/agent-runtime-harness.txt +2 -2
  575. package/llms/agent-runtime-openai.txt +31 -0
  576. package/llms/agent-runtime-openrouter.txt +17 -7
  577. package/llms/agent-runtime-sandbox.txt +53 -1
  578. package/llms/agent-runtime-testing.txt +4 -2
  579. package/llms/agent-runtime.2.txt +158 -271
  580. package/llms/agent-runtime.3.txt +289 -243
  581. package/llms/agent-runtime.4.txt +273 -216
  582. package/llms/agent-runtime.5.txt +209 -2
  583. package/llms/agent-runtime.txt +238 -181
  584. package/llms/contract.txt +2 -1
  585. package/llms/device-relay.txt +34 -0
  586. package/llms/realtime.txt +20 -0
  587. package/llms/server.2.txt +125 -1
  588. package/llms/server.3.txt +111 -122
  589. package/llms/server.4.txt +1 -1
  590. package/llms/server.5.txt +3 -1
  591. package/llms/server.txt +31 -1
  592. package/llms/spend.txt +11 -6
  593. package/llms/stitchkit.2.txt +21 -43
  594. package/llms/stitchkit.3.txt +43 -0
  595. package/llms/stitchkit.txt +93 -84
  596. package/llms/tools-agent.txt +7 -5
  597. package/llms/tools-toolkit.txt +1 -1
  598. package/llms/tools.4.txt +7 -2
  599. package/llms/{upgrading-0.128.0-0.133.0.txt → upgrading-0.128.0-0.134.0.txt} +173 -3
  600. package/llms/upgrading.txt +1 -1
  601. package/llms-full.txt +983 -212
  602. package/llms.txt +21 -17
  603. package/package.json +18 -7
  604. package/dist/index-0p0s5hrj.js +0 -249
  605. package/dist/index-1dn2wjq6.js +0 -135
  606. package/dist/index-1psbyyhj.js +0 -21
  607. package/dist/index-34k82crg.js +0 -3961
  608. package/dist/index-5n3a8hd8.js +0 -102
  609. package/dist/index-97rp94ff.js +0 -8
  610. package/dist/index-bn2baakz.js +0 -336
  611. package/dist/index-eh71zr32.js +0 -14
  612. package/dist/index-emgrmavr.js +0 -1193
  613. package/dist/index-fzd477xk.js +0 -135
  614. package/dist/index-vgzhw2zk.js +0 -304
  615. package/dist/internal/ai-sdk-typed.d.ts +0 -14
  616. package/dist/internal/ai-sdk-typed.d.ts.map +0 -1
  617. package/dist/tools/runtime-call-context.d.ts +0 -15
  618. package/dist/tools/runtime-call-context.d.ts.map +0 -1
  619. package/dist/{index-vmbxj75t.js → index-jwtmw39p.js} +0 -0
  620. package/dist/{index-877e9y8r.js → index-sk03xe0n.js} +3 -3
  621. package/dist/{index-21cfxc4z.js → index-vh4291qh.js} +3 -3
@@ -1,3 +1,19 @@
1
+ import {
2
+ AgentModelProviderOptionsSchema2,
3
+ AgentCacheControlSchema2,
4
+ AgentModelResponseFormatSchema2,
5
+ AgentModelFileDataSchema2,
6
+ AgentToolModelOutputSchema2,
7
+ AgentModelSystemMessageSchema2,
8
+ normalizeAgentInstructions,
9
+ AgentModelUserContentPartSchema2,
10
+ AgentModelAssistantContentPartSchema2,
11
+ AgentModelToolContentPartSchema2,
12
+ AgentModelUserMessageSchema2,
13
+ AgentModelAssistantMessageSchema2,
14
+ AgentModelToolMessageSchema2,
15
+ AgentModelMessageSchema2
16
+ } from "../index-vebzvse6.js";
1
17
  import {
2
18
  AgentRecordIdSchema2,
3
19
  AgentStoreEventKindSchema2,
@@ -15,18 +31,8 @@ import {
15
31
  AgentProvenanceSchema2,
16
32
  AgentUsageValueSchema2,
17
33
  AgentCostValueSchema2,
18
- AgentUsageSchema2,
19
- AgentRunStateSchema2,
20
- AgentRunQueuePrioritySchema2,
21
- AgentRunOperationKindSchema2,
22
- AgentRunOperationPhaseSchema2,
23
- AgentRunOperationSchema2,
24
- AgentTerminalReasonSchema2,
25
- runStateForTerminalReason2,
26
- AgentRunSchema2,
27
- AgentSnapshotSchema2,
28
- AgentRunMetricsSchema2
29
- } from "../index-bn2baakz.js";
34
+ AgentUsageSchema2
35
+ } from "../index-j3r7r1mh.js";
30
36
  import {
31
37
  AgentBranchRefusalCodeSchema2,
32
38
  AgentBranchRefusalSchema2,
@@ -62,11 +68,11 @@ import {
62
68
  createAgentEventSearchTools2,
63
69
  AgentStoreUnsupportedCapabilityError2,
64
70
  createAgentRuntimeStore2
65
- } from "../index-tqjamnax.js";
71
+ } from "../index-27srek2g.js";
66
72
  import {
67
73
  AgentCodingToolAuthorizationSchema2,
68
74
  refuseUnknownSpillReference
69
- } from "../index-3y2tzhr8.js";
75
+ } from "../index-ky79wwgs.js";
70
76
  import {
71
77
  AgentProviderEnvelopeSchema2,
72
78
  AgentTextPartSchema2,
@@ -80,10 +86,22 @@ import {
80
86
  AgentOpaquePartSchema2,
81
87
  AgentControlPartSchema2,
82
88
  AgentMessagePartSchema2
83
- } from "../index-2rf33y2h.js";
89
+ } from "../index-tav72wz5.js";
84
90
  import {
85
91
  AgentProviderResponseSchema2
86
- } from "../index-97rp94ff.js";
92
+ } from "../index-7qza24g1.js";
93
+ import {
94
+ AgentRunStateSchema2,
95
+ AgentRunQueuePrioritySchema2,
96
+ AgentRunOperationKindSchema2,
97
+ AgentRunOperationPhaseSchema2,
98
+ AgentRunOperationSchema2,
99
+ AgentTerminalReasonSchema2,
100
+ runStateForTerminalReason2,
101
+ AgentRunSchema2,
102
+ AgentSnapshotSchema2,
103
+ AgentRunMetricsSchema2
104
+ } from "../index-pd9e8rz4.js";
87
105
  import {
88
106
  AgentRuntimeHeadSchema2,
89
107
  AgentStoredRunSchema2,
@@ -115,10 +133,7 @@ import {
115
133
  AgentConversationArchiveSchema2,
116
134
  encodeAgentConversationArchive2,
117
135
  decodeAgentConversationArchive2,
118
- conversationOfRun
119
- } from "../index-9xr44d2g.js";
120
- import"../index-brhhaygm.js";
121
- import {
136
+ conversationOfRun,
122
137
  PurgeInvocationPayloadsInputSchema2,
123
138
  PurgeInvocationPayloadsResultSchema2,
124
139
  ModelInvocationTraceSchema2,
@@ -127,13 +142,36 @@ import {
127
142
  InvocationResponseSchema,
128
143
  ModelInvocationRecordSchema2,
129
144
  ModelInvocationPayloadReadSchema2,
130
- isModelInvocationRecord,
131
- isAssistantHistoryEvidence2,
132
- isCompleteAgentHistoryTurn
133
- } from "../index-vgzhw2zk.js";
145
+ isModelInvocationRecord
146
+ } from "../index-qv5v6w9c.js";
147
+ import"../index-brhhaygm.js";
148
+ import {
149
+ AgentRuntimeConflictError2,
150
+ AgentRunUnsettledError2,
151
+ parseOptionalAgentUsage,
152
+ addUsage,
153
+ createIdleDeadline
154
+ } from "../index-9f60gnfn.js";
155
+ import {
156
+ AgentConversationSummarySchema2,
157
+ AgentConversationPageSchema2,
158
+ AgentConversationMessagePageSchema2
159
+ } from "../index-79vqbjcz.js";
160
+ import"../index-27hck3z2.js";
161
+ import"../index-ngwf1s3c.js";
162
+ import"../index-78da4g74.js";
163
+ import"../index-dsa676h8.js";
164
+ import"../index-360j58vb.js";
165
+ import"../index-j903yhp4.js";
166
+ import {
167
+ resolveToolAccess
168
+ } from "../index-er483f3w.js";
169
+ import"../index-yt1gg11x.js";
170
+ import"../index-v5hmyef8.js";
171
+ import"../index-werjqesf.js";
134
172
  import {
135
173
  createBoundedSinkManager
136
- } from "../index-13wmzpa6.js";
174
+ } from "../index-7an2fs5h.js";
137
175
  import {
138
176
  AgentAdmissionEventSchema2,
139
177
  AgentTransientDeltaEventSchema2,
@@ -151,57 +189,10 @@ import {
151
189
  AgentRuntimeEventCursorSchema2,
152
190
  advanceAgentRuntimeEventCursor2,
153
191
  agentDurableEventId2
154
- } from "../index-paff5y0r.js";
192
+ } from "../index-grhhsrd5.js";
155
193
  import {
156
- AgentRuntimeConflictError2,
157
- AgentRunUnsettledError2,
158
- addUsage,
159
- statedUsage,
160
194
  unknownUsage,
161
- AgentStepSpendPhaseSchema2,
162
- AgentStepSpendProviderSchema,
163
- AgentStepSpendSchema2,
164
- normalizeStepUsage,
165
- InvocationPayloadTooLargeError2,
166
- currentModelInvocationAttempt2,
167
- AgentModelCapabilitySchema2,
168
- AgentModelDescriptorSchema2,
169
- AgentModelRegistrySnapshotSchema2,
170
- AgentModelPriceSchema2,
171
- AgentModelMetricSchema2,
172
- AgentModelPopularitySchema2,
173
- AgentModelCatalogEntrySchema2,
174
- AgentModelCatalogSchema2,
175
- AgentModelSelectionSchema2,
176
- AgentModelSearchInputSchema2,
177
- AgentModelSearchResultSchema2,
178
- searchAgentModelCatalog2,
179
- createMemoryAgentModelSelectionStore2,
180
- defineModelRegistry2,
181
- validateAgentModelSnapshot2
182
- } from "../index-emgrmavr.js";
183
- import {
184
- AgentConversationSummarySchema2,
185
- AgentConversationPageSchema2,
186
- AgentConversationMessagePageSchema2
187
- } from "../index-7416mhyh.js";
188
- import"../index-78da4g74.js";
189
- import"../index-dsa676h8.js";
190
- import"../index-27hck3z2.js";
191
- import"../index-ngwf1s3c.js";
192
- import"../index-360j58vb.js";
193
- import"../index-j903yhp4.js";
194
- import {
195
- resolveToolAccess
196
- } from "../index-6kmjcm81.js";
197
- import"../index-yt1gg11x.js";
198
- import"../index-ma26mfnt.js";
199
- import"../index-5n3a8hd8.js";
200
- import"../index-werjqesf.js";
201
- import {
202
- mountAgent2
203
- } from "../index-1dn2wjq6.js";
204
- import {
195
+ statedUsage,
205
196
  AgentContextOverflowError2,
206
197
  createAgentSessionCoordinator2,
207
198
  registerDeferredToolRepair,
@@ -210,26 +201,66 @@ import {
210
201
  repairedSearchCall,
211
202
  projectAgentHistoryDetailed2,
212
203
  projectAgentHistory2,
204
+ InvocationPayloadTooLargeError2,
205
+ markProviderOrigin,
206
+ hasProviderOrigin,
207
+ currentModelInvocationAttempt2,
208
+ consumeStandaloneDriverStream,
213
209
  createModelInvocationLedger2,
214
210
  createAgentToolFenceLifecycle2,
211
+ AgentModelFinishReasonSchema,
212
+ AgentModelCostDetailsSchema,
213
+ AgentStepTimingsSchema,
214
+ AgentStepSpendPhaseSchema2,
215
+ AgentStepSpendProviderSchema,
216
+ AgentStepSpendSchema2,
215
217
  AgentTokenCountSchema2,
216
218
  selectAgentHistory2,
217
219
  composeAgentPrompt2,
218
- AgentProviderStreamCutError2,
219
- classifyProviderFailure2,
220
- isToolResultFailure2,
220
+ assertAgentRetryPolicy,
221
+ resolveAgentRetryDecision,
221
222
  recordAgentRetryDecision2,
223
+ AgentToolApprovalError2,
224
+ AgentInvalidToolApprovalSignatureError2,
225
+ AgentToolCallNotFoundForApprovalError2,
222
226
  AgentStepBarrierError2,
223
227
  createToolDependencyResolver2,
228
+ AgentUnknownToolError2,
229
+ AgentInvalidToolInputError2,
230
+ createCallSlotResult,
231
+ safeToolErrorMessage,
232
+ defaultToolWireOutput,
233
+ resolveToolCallInput,
234
+ emptyStepToolExecutionResult,
235
+ buildActiveToolSpecs,
236
+ mergeStepCallSettings,
237
+ isStepUnsafeForClientTools,
238
+ buildStepTimings,
239
+ assembleStepResult,
224
240
  defineStateSlot2,
225
241
  createAgentStateSlotStore2,
226
242
  renderAgentStateSlots2,
227
243
  agentGoalStateSlot2,
228
244
  agentTodoStateSlot2,
229
245
  createAgentRuntime2
230
- } from "../index-34k82crg.js";
231
- import"../index-m38ej7e5.js";
232
- import"../index-9c76vfxf.js";
246
+ } from "../index-nfeafbzh.js";
247
+ import {
248
+ AgentModelCapabilitySchema2,
249
+ AgentModelDescriptorSchema2,
250
+ AgentModelRegistrySnapshotSchema2,
251
+ AgentModelPriceSchema2,
252
+ AgentModelMetricSchema2,
253
+ AgentModelPopularitySchema2,
254
+ AgentModelCatalogEntrySchema2,
255
+ AgentModelCatalogSchema2,
256
+ AgentModelSelectionSchema2,
257
+ AgentModelSearchInputSchema2,
258
+ AgentModelSearchResultSchema2,
259
+ searchAgentModelCatalog2,
260
+ createMemoryAgentModelSelectionStore2,
261
+ defineModelRegistry2,
262
+ validateAgentModelSnapshot2
263
+ } from "../index-b23s6e2c.js";
233
264
  import {
234
265
  DURABILITY_STEP_EVENT_KIND2,
235
266
  StepResultDecodeError2,
@@ -238,29 +269,51 @@ import {
238
269
  ParkRecordDecodeError2,
239
270
  ParkAbortedError2
240
271
  } from "../index-snef22zr.js";
241
- import"../index-kynwa08q.js";
272
+ import"../index-xrsryvd2.js";
273
+ import"../index-m38ej7e5.js";
274
+ import"../index-zyyerdny.js";
242
275
  import"../index-6kec3b14.js";
243
- import"../index-jpecjm30.js";
244
- import"../index-pbekeqzm.js";
276
+ import"../index-tgehj4bp.js";
277
+ import"../index-5c4m8zdf.js";
245
278
  import {
246
279
  createMemoryAgentRuntimeStore2
247
- } from "../index-dm6nxkn1.js";
280
+ } from "../index-18pf56dq.js";
248
281
  import {
249
- createAgentRuntimeEventSink2
250
- } from "../index-205456mf.js";
282
+ isAssistantHistoryEvidence2,
283
+ isCompleteAgentHistoryTurn
284
+ } from "../index-kgj8j7bv.js";
251
285
  import"../index-rj32hkkp.js";
286
+ import {
287
+ createAgentRuntimeEventSink2
288
+ } from "../index-d3s070eh.js";
289
+ import {
290
+ stripStrictOptionalNulls
291
+ } from "../index-1gmgwfn3.js";
292
+ import {
293
+ envelopeToProviderOptions,
294
+ AgentProviderError2,
295
+ AgentProviderStreamCutError2,
296
+ isAgentProviderError2,
297
+ classifyProviderFailure2,
298
+ isToolResultFailure2
299
+ } from "../index-6kpwkpgx.js";
300
+ import {
301
+ buildToolManifest2
302
+ } from "../index-ga6avd48.js";
303
+ import"../index-ek9w11r0.js";
304
+ import"../index-6nzzj7qr.js";
305
+ import"../index-fthw8dwa.js";
252
306
  import {
253
307
  rankToolsByQuery
254
308
  } from "../index-kne9g2c5.js";
309
+ import {
310
+ finalizeAgentToolOutput,
311
+ zodToAgentInputJsonSchema,
312
+ mountAgentTools2
313
+ } from "../index-zk839vzf.js";
255
314
  import"../index-rjs94dny.js";
256
315
  import"../index-xrgn784x.js";
257
- import {
258
- buildToolManifest2
259
- } from "../index-rw8ze745.js";
260
- import"../index-pq6g1k9t.js";
261
- import"../index-1qwd54n3.js";
262
- import"../index-6918kxbf.js";
263
- import"../index-q427q23r.js";
316
+ import"../index-pjjh91vw.js";
264
317
  import {
265
318
  defineRuntimeTool2,
266
319
  executableAgentRuntimeTools
@@ -274,14 +327,20 @@ import {
274
327
  assertPositiveSafeInteger
275
328
  } from "../index-gr0kxymw.js";
276
329
  import {
330
+ assertTimerMs,
277
331
  withDeadline
278
- } from "../index-agy5fqgf.js";
332
+ } from "../index-e1y74yra.js";
279
333
  import {
280
334
  scheduleAt
281
- } from "../index-mxt0wfjy.js";
335
+ } from "../index-h20qcyh5.js";
282
336
  import {
283
- abortReason
337
+ abortReason,
338
+ linkAbortSignals
284
339
  } from "../index-rptj3qnc.js";
340
+ import {
341
+ isRecord,
342
+ isAsyncIterable
343
+ } from "../index-ps3djm8d.js";
285
344
  // src/agent-runtime/child-tools.ts
286
345
  import { z as z3 } from "zod";
287
346
 
@@ -1027,14 +1086,14 @@ function agentChildBudgetStopPolicy(input) {
1027
1086
  let lastBoundary = performance.now();
1028
1087
  return {
1029
1088
  name: "child-budget",
1030
- when: async ({ steps, selectedModel }) => {
1089
+ when: async ({ steps }) => {
1031
1090
  const step = steps.at(-1);
1032
1091
  if (!step || steps.length <= stepsSeen)
1033
1092
  return false;
1034
1093
  stepsSeen = steps.length;
1035
1094
  const elapsedMs = Math.round(Math.max(0, performance.now() - lastBoundary));
1036
1095
  lastBoundary = performance.now();
1037
- const usage = normalizeStepUsage(selectedModel, step.usage, step.providerMetadata);
1096
+ const usage = statedUsage(step.usage);
1038
1097
  const boundary = await input.manager.recordStepUsage({
1039
1098
  childConversationId: input.childConversationId,
1040
1099
  usage,
@@ -1214,11 +1273,42 @@ function selectCompactableHistory(options) {
1214
1273
  retained: rest.slice(compactable.length)
1215
1274
  };
1216
1275
  }
1217
- function mutationSnapshot(result, fallback, attempts) {
1276
+ function mutationSnapshot(result, fallback, attempts, usage) {
1218
1277
  if (result.outcome === "applied" || result.outcome === "duplicate") {
1219
- return { outcome: "applied", snapshot: result.snapshot, attempts };
1278
+ return {
1279
+ outcome: "applied",
1280
+ snapshot: result.snapshot,
1281
+ attempts,
1282
+ ...usage !== undefined && { usage }
1283
+ };
1220
1284
  }
1221
- return { outcome: result.outcome, snapshot: fallback, attempts };
1285
+ return {
1286
+ outcome: result.outcome,
1287
+ snapshot: fallback,
1288
+ attempts,
1289
+ ...usage !== undefined && { usage }
1290
+ };
1291
+ }
1292
+ function unpackSummaryOutput(schema, raw) {
1293
+ if (isRecord(raw) && Object.hasOwn(raw, "summary")) {
1294
+ const keys = Object.keys(raw);
1295
+ const onlyEnvelopeKeys = keys.every((key) => key === "summary" || key === "usage");
1296
+ if (onlyEnvelopeKeys) {
1297
+ const hasUsage = Object.hasOwn(raw, "usage") && raw.usage !== undefined;
1298
+ const parsedUsage = parseOptionalAgentUsage(raw.usage);
1299
+ if (hasUsage && parsedUsage !== undefined) {
1300
+ return { summary: schema.parse(raw.summary), usage: parsedUsage };
1301
+ }
1302
+ const direct = schema.safeParse(raw);
1303
+ if (direct.success)
1304
+ return { summary: direct.data };
1305
+ if (hasUsage && parsedUsage === undefined) {
1306
+ throw new TypeError("Compaction summarize usage must be a valid AgentUsage");
1307
+ }
1308
+ return { summary: schema.parse(raw.summary) };
1309
+ }
1310
+ }
1311
+ return { summary: schema.parse(raw) };
1222
1312
  }
1223
1313
  function structuredCompaction(config) {
1224
1314
  assertPositiveSafeInteger("keepRecentTurns", config.keepRecentTurns);
@@ -1226,11 +1316,22 @@ function structuredCompaction(config) {
1226
1316
  assertPositiveSafeInteger("maxAttempts", maxAttempts);
1227
1317
  return async (input) => {
1228
1318
  let lastSnapshot = await input.store.loadSnapshot(input.conversationId);
1319
+ let accumulatedUsage;
1320
+ const thresholdContext = input.model !== undefined || input.tools !== undefined || input.context !== undefined ? {
1321
+ ...input.model !== undefined && { model: input.model },
1322
+ ...input.tools !== undefined && { tools: input.tools },
1323
+ ...input.context !== undefined && { context: input.context }
1324
+ } : undefined;
1229
1325
  for (let attempt = 1;attempt <= maxAttempts; attempt += 1) {
1230
1326
  const snapshot = attempt === 1 ? lastSnapshot : await input.store.loadSnapshot(input.conversationId);
1231
1327
  lastSnapshot = snapshot;
1232
- if (!await config.threshold(snapshot)) {
1233
- return { outcome: "not_needed", snapshot, attempts: attempt };
1328
+ if (!await config.threshold(snapshot, thresholdContext)) {
1329
+ return {
1330
+ outcome: "not_needed",
1331
+ snapshot,
1332
+ attempts: attempt,
1333
+ ...accumulatedUsage !== undefined && { usage: accumulatedUsage }
1334
+ };
1234
1335
  }
1235
1336
  const { leadingSummary, compactable: eligibleMessages } = selectCompactableHistory({
1236
1337
  messages: snapshot.messages,
@@ -1238,7 +1339,12 @@ function structuredCompaction(config) {
1238
1339
  ...config.evidencePolicy !== undefined && { evidencePolicy: config.evidencePolicy }
1239
1340
  });
1240
1341
  if (eligibleMessages.length === 0) {
1241
- return { outcome: "nothing_eligible", snapshot, attempts: attempt };
1342
+ return {
1343
+ outcome: "nothing_eligible",
1344
+ snapshot,
1345
+ attempts: attempt,
1346
+ ...accumulatedUsage !== undefined && { usage: accumulatedUsage }
1347
+ };
1242
1348
  }
1243
1349
  const previousSummary = leadingSummary && config.readPreviousSummary ? config.schema.parse(config.readPreviousSummary(leadingSummary)) : attempt === 1 ? input.previousSummary : undefined;
1244
1350
  const rawSummary = await config.summarize({
@@ -1246,9 +1352,15 @@ function structuredCompaction(config) {
1246
1352
  snapshot,
1247
1353
  eligibleMessages,
1248
1354
  ...previousSummary !== undefined && { previousSummary },
1249
- signal: input.signal
1355
+ signal: input.signal,
1356
+ ...input.model !== undefined && { model: input.model },
1357
+ ...input.tools !== undefined && { tools: input.tools },
1358
+ ...input.context !== undefined && { context: input.context }
1250
1359
  });
1251
- const summary = config.schema.parse(rawSummary);
1360
+ const { summary, usage } = unpackSummaryOutput(config.schema, rawSummary);
1361
+ if (usage !== undefined) {
1362
+ accumulatedUsage = accumulatedUsage ? addUsage(accumulatedUsage, usage) : usage;
1363
+ }
1252
1364
  if (input.signal.aborted)
1253
1365
  throw abortReason(input.signal);
1254
1366
  const summaryMessage = config.createSummaryMessage({
@@ -1269,10 +1381,15 @@ function structuredCompaction(config) {
1269
1381
  summary: summaryMessage
1270
1382
  });
1271
1383
  if (applied.outcome !== "conflict" || attempt === maxAttempts) {
1272
- return mutationSnapshot(applied, snapshot, attempt);
1384
+ return mutationSnapshot(applied, snapshot, attempt, accumulatedUsage);
1273
1385
  }
1274
1386
  }
1275
- return { outcome: "conflict", snapshot: lastSnapshot, attempts: maxAttempts };
1387
+ return {
1388
+ outcome: "conflict",
1389
+ snapshot: lastSnapshot,
1390
+ attempts: maxAttempts,
1391
+ ...accumulatedUsage !== undefined && { usage: accumulatedUsage }
1392
+ };
1276
1393
  };
1277
1394
  }
1278
1395
  // src/agent-runtime/deferred-tool-selection.ts
@@ -1577,7 +1694,7 @@ function createDeferredAgentToolSurface(config) {
1577
1694
  ...executableAgentRuntimeTools(surface.definition.runtimeTools ?? []),
1578
1695
  createDeferredSearchTool(config, runContext, surface)
1579
1696
  ];
1580
- const tools = mountAgent2([...surface.definition.services ?? []], {
1697
+ const tools = mountAgentTools2([...surface.definition.services ?? []], {
1581
1698
  ...mountConfig,
1582
1699
  ...projection,
1583
1700
  runtimeTools
@@ -1599,7 +1716,12 @@ function createDeferredAgentToolSurface(config) {
1599
1716
  const names = uniqueKnown([config.search.name, ...surface.alwaysOn, ...pins.names, ...selected.names], surface).names;
1600
1717
  if (!names.includes(config.search.name))
1601
1718
  names.unshift(config.search.name);
1602
- const bytes = assertActiveBudget(config, names, surface);
1719
+ const surfaceBytes = assertActiveBudget(config, names, surface);
1720
+ const activeTools = application?.activeTools !== undefined ? (() => {
1721
+ const allowed = new Set(application.activeTools);
1722
+ return names.filter((name) => allowed.has(name));
1723
+ })() : names;
1724
+ const bytes = activeTools.length === names.length ? surfaceBytes : schemaBytes(activeTools, surface);
1603
1725
  config.observe?.({
1604
1726
  schemaVersion: 1,
1605
1727
  type: "step",
@@ -1609,17 +1731,22 @@ function createDeferredAgentToolSurface(config) {
1609
1731
  baseTools: surface.alwaysOn.length + 1,
1610
1732
  pinnedTools: pins.names.length,
1611
1733
  selectedTools: selected.names.length,
1612
- activeTools: names.length,
1734
+ activeTools: activeTools.length,
1613
1735
  activeSchemaBytes: bytes,
1614
1736
  rejectedNames: selected.rejected,
1615
1737
  replacementTools: selected.names.length,
1616
1738
  source: currentSelection.source === "durable" ? "current" : selection.source
1617
1739
  });
1618
- return { ...application, activeTools: names };
1740
+ return { ...application, activeTools };
1619
1741
  };
1620
- const repair = async ({ toolCall, tools, error }) => {
1742
+ const repair = async ({
1743
+ toolCall,
1744
+ activeTools,
1745
+ tools,
1746
+ error
1747
+ }) => {
1621
1748
  const catalog = deferredToolCatalog(tools, config.search.name);
1622
- if (!("toolName" in error) || !catalog?.has(toolCall.toolName) || toolCall.toolName in tools) {
1749
+ if (error.kind !== "unknown-tool" || !catalog?.has(toolCall.toolName) || activeTools.includes(toolCall.toolName)) {
1623
1750
  return null;
1624
1751
  }
1625
1752
  return repairedSearchCall(toolCall, config.search.name);
@@ -1667,6 +1794,11 @@ var AgentStepFinishedEventSchema = AgentRunEventBaseSchema.extend({
1667
1794
  attempt: z4.int().nonnegative(),
1668
1795
  phase: AgentStepSpendPhaseSchema2,
1669
1796
  provider: AgentStepSpendProviderSchema.optional(),
1797
+ finishReason: AgentModelFinishReasonSchema.optional(),
1798
+ rawFinishReason: z4.string().min(1).optional(),
1799
+ toolCallCount: z4.int().nonnegative().optional(),
1800
+ costDetails: AgentModelCostDetailsSchema.optional(),
1801
+ timings: AgentStepTimingsSchema.optional(),
1670
1802
  ttftMs: z4.number().nonnegative().optional(),
1671
1803
  usage: AgentUsageSchema2,
1672
1804
  response: AgentProviderResponseSchema2.optional(),
@@ -2039,6 +2171,9 @@ var agentOutlineProjection = defineAgentProjection({
2039
2171
  }
2040
2172
  });
2041
2173
  // src/agent-runtime/protocol.ts
2174
+ function carriedToolWork(steps) {
2175
+ return steps.some((step) => step.toolCalls.length > 0 || step.toolResults.length > 0 || step.content.some((part) => part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-error"));
2176
+ }
2042
2177
  function hasAgentTerminalOutput(input) {
2043
2178
  for (const part of input.message.parts) {
2044
2179
  if (part.type === "text" && part.text.trim().length > 0)
@@ -2065,6 +2200,1140 @@ function defineAgentProtocol(config) {
2065
2200
  }
2066
2201
  };
2067
2202
  }
2203
+ // src/agent-runtime/run-complete-retry.ts
2204
+ import { setTimeout as delay } from "node:timers/promises";
2205
+
2206
+ // src/agent-runtime/run-complete-types.ts
2207
+ class AgentStructuredOutputError extends Error {
2208
+ reason;
2209
+ finishReason;
2210
+ rawText;
2211
+ usage;
2212
+ steps;
2213
+ constructor(message, details) {
2214
+ super(message, details.cause !== undefined ? { cause: details.cause } : undefined);
2215
+ this.name = "AgentStructuredOutputError";
2216
+ this.reason = details.reason;
2217
+ this.finishReason = details.finishReason;
2218
+ this.rawText = details.rawText;
2219
+ this.usage = details.usage;
2220
+ this.steps = details.steps;
2221
+ }
2222
+ }
2223
+
2224
+ class AgentRetryExhaustedError extends Error {
2225
+ attempts;
2226
+ lastError;
2227
+ usage;
2228
+ constructor(message, details) {
2229
+ super(message, details.lastError !== undefined ? { cause: details.lastError } : undefined);
2230
+ this.name = "AgentRetryExhaustedError";
2231
+ this.attempts = details.attempts;
2232
+ this.lastError = details.lastError;
2233
+ this.usage = details.usage;
2234
+ }
2235
+ }
2236
+
2237
+ // src/agent-runtime/run-complete-retry.ts
2238
+ async function callDriverOnce(input) {
2239
+ const stepAbort = new AbortController;
2240
+ const baseSignal = input.signal ?? new AbortController().signal;
2241
+ const idleDeadline = createIdleDeadline(baseSignal, input.idleTimeoutMs);
2242
+ const link = linkAbortSignals(idleDeadline.signal, stepAbort.signal);
2243
+ const stepStartedAt = performance.now();
2244
+ try {
2245
+ idleDeadline.start();
2246
+ let modelStream;
2247
+ try {
2248
+ modelStream = await input.driver.stream(input.request, link.signal);
2249
+ } catch (error) {
2250
+ if (!input.signal?.aborted)
2251
+ markProviderOrigin(error);
2252
+ throw error;
2253
+ }
2254
+ const consumed = await consumeStandaloneDriverStream({
2255
+ modelStream,
2256
+ abortAttempt: () => stepAbort.abort(new Error("Completion released provider stream")),
2257
+ onChunk: () => idleDeadline.touch(),
2258
+ ...input.onPart !== undefined && {
2259
+ onPart: (part) => input.onPart?.(part, link.signal)
2260
+ },
2261
+ captureErrorUsage: input.captureErrorUsage
2262
+ });
2263
+ const responseFinishedAt = performance.now();
2264
+ if (idleDeadline.signal.aborted && !input.signal?.aborted) {
2265
+ throw markProviderOrigin(new AgentProviderError2(`Provider stream idle timeout after ${input.idleTimeoutMs}ms`, {
2266
+ provider: input.driver.provider,
2267
+ failureReason: "timeout"
2268
+ }));
2269
+ }
2270
+ return {
2271
+ consumed,
2272
+ ...consumed.errorPart !== undefined && { errorPart: consumed.errorPart },
2273
+ stepStartedAt,
2274
+ responseFinishedAt
2275
+ };
2276
+ } catch (error) {
2277
+ if (idleDeadline.signal.aborted && !input.signal?.aborted && (hasProviderOrigin(error) || error === idleDeadline.signal.reason)) {
2278
+ throw markProviderOrigin(new AgentProviderError2(`Provider stream idle timeout after ${input.idleTimeoutMs}ms`, {
2279
+ provider: input.driver.provider,
2280
+ failureReason: "timeout",
2281
+ cause: error
2282
+ }));
2283
+ }
2284
+ throw error;
2285
+ } finally {
2286
+ idleDeadline.dispose();
2287
+ link.release();
2288
+ idleDeadline.release();
2289
+ }
2290
+ }
2291
+ async function runStepModelCallWithRetry(input) {
2292
+ const retryPolicy = input.retry;
2293
+ const retryWindowStart = performance.now();
2294
+ const attempts = [];
2295
+ let discardedUsage;
2296
+ for (let attempt = 1;; attempt += 1) {
2297
+ input.signal?.throwIfAborted();
2298
+ let attemptError;
2299
+ let attemptUsage;
2300
+ try {
2301
+ const outcome = await callDriverOnce({
2302
+ driver: input.driver,
2303
+ request: input.request,
2304
+ signal: input.signal,
2305
+ idleTimeoutMs: input.idleTimeoutMs,
2306
+ captureErrorUsage: retryPolicy !== undefined,
2307
+ ...input.onPart !== undefined && { onPart: input.onPart }
2308
+ });
2309
+ if (outcome.errorPart !== undefined) {
2310
+ attemptError = markProviderOrigin(outcome.errorPart);
2311
+ if (outcome.consumed.finishPart) {
2312
+ attemptUsage = statedUsage(outcome.consumed.finishPart.usage);
2313
+ }
2314
+ } else if (!outcome.consumed.finishPart) {
2315
+ input.signal?.throwIfAborted();
2316
+ attemptError = markProviderOrigin(new AgentProviderStreamCutError2("Provider stream ended without a finish event", {
2317
+ provider: input.driver.provider
2318
+ }));
2319
+ } else {
2320
+ return {
2321
+ consumed: outcome.consumed,
2322
+ stepStartedAt: outcome.stepStartedAt,
2323
+ responseFinishedAt: outcome.responseFinishedAt,
2324
+ discardedUsage
2325
+ };
2326
+ }
2327
+ } catch (error) {
2328
+ if (input.signal?.aborted || !hasProviderOrigin(error))
2329
+ throw error;
2330
+ attemptError = error;
2331
+ }
2332
+ if (!retryPolicy)
2333
+ throw attemptError;
2334
+ if (attemptUsage !== undefined) {
2335
+ discardedUsage = addUsage(discardedUsage, attemptUsage);
2336
+ }
2337
+ const failure = classifyProviderFailure2(attemptError);
2338
+ attempts.push({
2339
+ attempt,
2340
+ error: attemptError,
2341
+ failure,
2342
+ ...attemptUsage !== undefined && { usage: attemptUsage }
2343
+ });
2344
+ const decision = resolveAgentRetryDecision({
2345
+ attempt,
2346
+ failure,
2347
+ policy: retryPolicy,
2348
+ elapsedMs: Math.max(0, performance.now() - retryWindowStart)
2349
+ });
2350
+ if (!decision.retry) {
2351
+ if (attempts.length === 1 && !failure.retryable)
2352
+ throw attemptError;
2353
+ const accumulated = discardedUsage !== undefined ? addUsage(input.priorUsage, discardedUsage) : input.priorUsage;
2354
+ throw new AgentRetryExhaustedError(`Completion failed after ${attempts.length} attempt(s) (${failure.reason})`, {
2355
+ attempts,
2356
+ lastError: attemptError,
2357
+ usage: statedUsage(accumulated ?? unknownUsage())
2358
+ });
2359
+ }
2360
+ await input.onAttemptDiscarded?.({
2361
+ attempt,
2362
+ reason: failure.reason,
2363
+ ...attemptUsage !== undefined && { usage: attemptUsage }
2364
+ });
2365
+ await input.onPart?.({
2366
+ type: "attempt-reset",
2367
+ attempt,
2368
+ reason: failure.reason,
2369
+ ...attemptUsage !== undefined && { usage: attemptUsage }
2370
+ }, input.signal);
2371
+ if (decision.delayMs > 0) {
2372
+ await delay(decision.delayMs, undefined, { signal: input.signal });
2373
+ }
2374
+ }
2375
+ }
2376
+
2377
+ // src/agent-runtime/run-complete-stream.ts
2378
+ var STREAM_COMPLETE_BUFFER_LIMIT = 64;
2379
+ function discardUncommittedQueueParts(queue) {
2380
+ let keepCount = 0;
2381
+ for (let index = queue.length - 1;index >= 0; index -= 1) {
2382
+ if (queue[index]?.type === "finish-step") {
2383
+ keepCount = index + 1;
2384
+ break;
2385
+ }
2386
+ }
2387
+ if (queue.length <= keepCount)
2388
+ return false;
2389
+ queue.length = keepCount;
2390
+ return true;
2391
+ }
2392
+ function waitForQueueCapacity(pushWaiters, waitSignal) {
2393
+ if (waitSignal?.aborted)
2394
+ return Promise.reject(abortReason(waitSignal));
2395
+ return new Promise((resolve, reject) => {
2396
+ let settled = false;
2397
+ const onQueueWake = () => {
2398
+ if (settled)
2399
+ return;
2400
+ settled = true;
2401
+ if (waitSignal)
2402
+ waitSignal.removeEventListener("abort", onSignalAbort);
2403
+ resolve();
2404
+ };
2405
+ const onSignalAbort = () => {
2406
+ if (settled)
2407
+ return;
2408
+ settled = true;
2409
+ const index = pushWaiters.indexOf(onQueueWake);
2410
+ if (index >= 0)
2411
+ pushWaiters.splice(index, 1);
2412
+ reject(waitSignal ? abortReason(waitSignal) : undefined);
2413
+ };
2414
+ pushWaiters.push(onQueueWake);
2415
+ if (waitSignal) {
2416
+ waitSignal.addEventListener("abort", onSignalAbort, { once: true });
2417
+ }
2418
+ });
2419
+ }
2420
+ function createCompleteTextStream(input, runLoop) {
2421
+ const streamAbort = new AbortController;
2422
+ const link = linkAbortSignals(input.signal, streamAbort.signal);
2423
+ const queue = [];
2424
+ const pushWaiters = [];
2425
+ let done = false;
2426
+ let failure;
2427
+ let hasFailure = false;
2428
+ let consumerClosed = false;
2429
+ let startedIterating = false;
2430
+ let pullWaiter;
2431
+ const wakePull = () => {
2432
+ const resolve = pullWaiter;
2433
+ pullWaiter = undefined;
2434
+ resolve?.();
2435
+ };
2436
+ const wakeOnePush = () => {
2437
+ pushWaiters.shift()?.();
2438
+ };
2439
+ const wakeAllPush = () => {
2440
+ while (pushWaiters.length > 0) {
2441
+ pushWaiters.shift()?.();
2442
+ }
2443
+ };
2444
+ const onAbort = () => {
2445
+ queue.length = 0;
2446
+ wakeAllPush();
2447
+ wakePull();
2448
+ };
2449
+ if (!link.signal.aborted) {
2450
+ link.signal.addEventListener("abort", onAbort, { once: true });
2451
+ }
2452
+ const emitPart = async (part, waitSignal) => {
2453
+ if (consumerClosed || link.signal.aborted)
2454
+ return;
2455
+ if (waitSignal?.aborted)
2456
+ throw abortReason(waitSignal);
2457
+ try {
2458
+ await input.onPart?.(part);
2459
+ } catch (error) {
2460
+ if (!streamAbort.signal.aborted)
2461
+ streamAbort.abort(error);
2462
+ throw error;
2463
+ }
2464
+ if (consumerClosed || link.signal.aborted)
2465
+ return;
2466
+ if (waitSignal?.aborted)
2467
+ throw abortReason(waitSignal);
2468
+ while (queue.length >= STREAM_COMPLETE_BUFFER_LIMIT && !consumerClosed && !link.signal.aborted && !waitSignal?.aborted) {
2469
+ await waitForQueueCapacity(pushWaiters, waitSignal);
2470
+ }
2471
+ if (consumerClosed || link.signal.aborted)
2472
+ return;
2473
+ if (waitSignal?.aborted)
2474
+ throw abortReason(waitSignal);
2475
+ queue.push(part);
2476
+ wakePull();
2477
+ };
2478
+ const wrappedInput = {
2479
+ ...input,
2480
+ onAttemptDiscarded: async (info) => {
2481
+ if (discardUncommittedQueueParts(queue))
2482
+ wakeAllPush();
2483
+ await input.onAttemptDiscarded?.(info);
2484
+ }
2485
+ };
2486
+ const cleanupSignal = () => {
2487
+ link.signal.removeEventListener("abort", onAbort);
2488
+ link.release();
2489
+ };
2490
+ const result = runLoop(wrappedInput, emitPart, link.signal).then((res) => {
2491
+ done = true;
2492
+ cleanupSignal();
2493
+ wakeAllPush();
2494
+ wakePull();
2495
+ return res;
2496
+ }, (error) => {
2497
+ done = true;
2498
+ hasFailure = true;
2499
+ failure = error;
2500
+ cleanupSignal();
2501
+ wakeAllPush();
2502
+ wakePull();
2503
+ throw error;
2504
+ });
2505
+ result.catch(() => {
2506
+ return;
2507
+ });
2508
+ const parts = {
2509
+ [Symbol.asyncIterator]() {
2510
+ if (startedIterating) {
2511
+ throw new TypeError("streamComplete().parts can only be iterated once");
2512
+ }
2513
+ startedIterating = true;
2514
+ return {
2515
+ async next() {
2516
+ for (;; ) {
2517
+ if (queue.length > 0) {
2518
+ const value = queue.shift();
2519
+ wakeOnePush();
2520
+ if (value !== undefined)
2521
+ return { done: false, value };
2522
+ }
2523
+ if (done) {
2524
+ if (hasFailure)
2525
+ throw failure;
2526
+ return { done: true, value: undefined };
2527
+ }
2528
+ await new Promise((resolve) => {
2529
+ pullWaiter = resolve;
2530
+ });
2531
+ }
2532
+ },
2533
+ async return() {
2534
+ consumerClosed = true;
2535
+ queue.length = 0;
2536
+ streamAbort.abort(new Error("streamComplete consumer closed stream"));
2537
+ wakeAllPush();
2538
+ wakePull();
2539
+ await result.catch(() => {
2540
+ return;
2541
+ });
2542
+ return { done: true, value: undefined };
2543
+ }
2544
+ };
2545
+ }
2546
+ };
2547
+ return { parts, result };
2548
+ }
2549
+
2550
+ // src/agent-runtime/run-complete-tools.ts
2551
+ async function assertStandaloneToolApproval(input) {
2552
+ const { tool, toolName, toolCallId, parsedInput, messages, signal } = input;
2553
+ if (tool.needsApproval === undefined)
2554
+ return;
2555
+ const requiresApproval = typeof tool.needsApproval === "function" ? await tool.needsApproval.call(tool, parsedInput, {
2556
+ toolCallId,
2557
+ messages,
2558
+ abortSignal: signal
2559
+ }) : tool.needsApproval;
2560
+ signal.throwIfAborted();
2561
+ if (requiresApproval) {
2562
+ throw new AgentToolApprovalError2(`Tool "${toolName}" requires approval, which is not supported in stateless completion; use createAgentRuntime`, { reason: "approval-unsupported" });
2563
+ }
2564
+ }
2565
+ async function recordInvalidStandaloneToolCall(input) {
2566
+ const { raw, kind, toolName, parsedInput, error, slot, onPart } = input;
2567
+ const providerOptions = envelopeToProviderOptions(raw.provider);
2568
+ const wireInput = kind === "invalid-input" ? {} : isRecord(parsedInput) ? parsedInput : {};
2569
+ const callRecord = {
2570
+ type: "tool-call",
2571
+ toolCallId: raw.toolCallId,
2572
+ toolName,
2573
+ input: parsedInput,
2574
+ invalid: true,
2575
+ error
2576
+ };
2577
+ slot.toolCalls.push(callRecord);
2578
+ slot.stepContent.push(callRecord, {
2579
+ type: "tool-error",
2580
+ toolCallId: raw.toolCallId,
2581
+ toolName,
2582
+ input: parsedInput,
2583
+ error
2584
+ });
2585
+ slot.assistantParts.push({
2586
+ type: "tool-call",
2587
+ toolCallId: raw.toolCallId,
2588
+ toolName,
2589
+ input: wireInput,
2590
+ ...providerOptions && { providerOptions }
2591
+ });
2592
+ slot.toolParts.push({
2593
+ type: "tool-result",
2594
+ toolCallId: raw.toolCallId,
2595
+ toolName,
2596
+ output: { type: "error-text", value: safeToolErrorMessage(error) }
2597
+ });
2598
+ await onPart?.({
2599
+ type: "tool-call",
2600
+ toolCallId: raw.toolCallId,
2601
+ toolName,
2602
+ input: parsedInput,
2603
+ invalid: true,
2604
+ error,
2605
+ ...raw.provider !== undefined && { provider: raw.provider }
2606
+ });
2607
+ await onPart?.({
2608
+ type: "tool-error",
2609
+ toolCallId: raw.toolCallId,
2610
+ toolName,
2611
+ input: parsedInput,
2612
+ error
2613
+ });
2614
+ }
2615
+ async function executeStandaloneToolCall(input) {
2616
+ const { raw, toolName, tool, execute, parsedInput, messages, signal, slot, onPart } = input;
2617
+ const call = {
2618
+ toolCallId: raw.toolCallId,
2619
+ messages,
2620
+ abortSignal: signal
2621
+ };
2622
+ let outcome;
2623
+ let onPartFailed = false;
2624
+ try {
2625
+ signal.throwIfAborted();
2626
+ const rawResult = await execute.call(tool, parsedInput, call);
2627
+ signal.throwIfAborted();
2628
+ const wasAsyncIterable = isAsyncIterable(rawResult);
2629
+ let finalValue = rawResult;
2630
+ if (wasAsyncIterable) {
2631
+ let last;
2632
+ for await (const chunk of rawResult) {
2633
+ signal.throwIfAborted();
2634
+ last = chunk;
2635
+ try {
2636
+ await onPart?.({
2637
+ type: "tool-result",
2638
+ toolCallId: raw.toolCallId,
2639
+ toolName,
2640
+ input: parsedInput,
2641
+ result: chunk,
2642
+ preliminary: true,
2643
+ providerExecuted: false
2644
+ });
2645
+ } catch (partError) {
2646
+ onPartFailed = true;
2647
+ throw partError;
2648
+ }
2649
+ }
2650
+ signal.throwIfAborted();
2651
+ finalValue = last;
2652
+ }
2653
+ finalValue = finalizeAgentToolOutput(tool, finalValue, wasAsyncIterable);
2654
+ const wireOutput = tool.toModelOutput ? await tool.toModelOutput({
2655
+ toolCallId: raw.toolCallId,
2656
+ input: parsedInput,
2657
+ output: finalValue
2658
+ }) : defaultToolWireOutput(finalValue);
2659
+ signal.throwIfAborted();
2660
+ outcome = { ok: true, finalValue, wireOutput };
2661
+ } catch (error) {
2662
+ if (onPartFailed || signal.aborted)
2663
+ throw error;
2664
+ outcome = { ok: false, error };
2665
+ }
2666
+ signal.throwIfAborted();
2667
+ if (outcome.ok) {
2668
+ const resultRecord = {
2669
+ type: "tool-result",
2670
+ toolCallId: raw.toolCallId,
2671
+ toolName,
2672
+ input: parsedInput,
2673
+ output: outcome.finalValue
2674
+ };
2675
+ slot.toolResults.push(resultRecord);
2676
+ slot.stepContent.push(resultRecord);
2677
+ slot.toolParts.push({
2678
+ type: "tool-result",
2679
+ toolCallId: raw.toolCallId,
2680
+ toolName,
2681
+ output: outcome.wireOutput
2682
+ });
2683
+ await onPart?.({
2684
+ type: "tool-result",
2685
+ toolCallId: raw.toolCallId,
2686
+ toolName,
2687
+ input: parsedInput,
2688
+ result: outcome.finalValue,
2689
+ preliminary: false,
2690
+ providerExecuted: false
2691
+ });
2692
+ input.onSettled();
2693
+ } else {
2694
+ slot.stepContent.push({
2695
+ type: "tool-error",
2696
+ toolCallId: raw.toolCallId,
2697
+ toolName,
2698
+ input: parsedInput,
2699
+ error: outcome.error
2700
+ });
2701
+ slot.toolParts.push({
2702
+ type: "tool-result",
2703
+ toolCallId: raw.toolCallId,
2704
+ toolName,
2705
+ output: { type: "error-text", value: safeToolErrorMessage(outcome.error) }
2706
+ });
2707
+ await onPart?.({
2708
+ type: "tool-error",
2709
+ toolCallId: raw.toolCallId,
2710
+ toolName,
2711
+ input: parsedInput,
2712
+ error: outcome.error
2713
+ });
2714
+ input.onSettled();
2715
+ }
2716
+ }
2717
+ async function runStandaloneClientTools(input) {
2718
+ const clientCalls = input.rawCalls.filter((call) => call.providerExecuted !== true);
2719
+ if (clientCalls.length === 0)
2720
+ return emptyStepToolExecutionResult();
2721
+ const slots = clientCalls.map(() => createCallSlotResult());
2722
+ const pending = [];
2723
+ const stepAbort = new AbortController;
2724
+ const stepSignalLink = linkAbortSignals(input.signal, stepAbort.signal);
2725
+ const emitStepPart = input.onPart ? (part) => input.onPart?.(part, stepSignalLink.signal) : undefined;
2726
+ let settledCount = 0;
2727
+ try {
2728
+ for (const [index, raw] of clientCalls.entries()) {
2729
+ stepSignalLink.signal.throwIfAborted();
2730
+ const slot = slots[index];
2731
+ if (!slot)
2732
+ continue;
2733
+ const resolved = await resolveToolCallInput({
2734
+ raw,
2735
+ tools: input.tools,
2736
+ activeTools: input.activeTools,
2737
+ messages: input.messages,
2738
+ repairToolCall: input.repairToolCall
2739
+ });
2740
+ stepSignalLink.signal.throwIfAborted();
2741
+ if (!resolved.ok) {
2742
+ await recordInvalidStandaloneToolCall({
2743
+ raw,
2744
+ kind: resolved.kind,
2745
+ toolName: resolved.toolName,
2746
+ parsedInput: resolved.parsedInput,
2747
+ error: resolved.error,
2748
+ slot,
2749
+ ...emitStepPart !== undefined && { onPart: emitStepPart }
2750
+ });
2751
+ settledCount += 1;
2752
+ continue;
2753
+ }
2754
+ const { toolName, tool, parsedInput } = resolved;
2755
+ const providerOptions = envelopeToProviderOptions(raw.provider);
2756
+ const callRecord = {
2757
+ type: "tool-call",
2758
+ toolCallId: raw.toolCallId,
2759
+ toolName,
2760
+ input: parsedInput
2761
+ };
2762
+ slot.toolCalls.push(callRecord);
2763
+ slot.stepContent.push(callRecord);
2764
+ slot.assistantParts.push({
2765
+ type: "tool-call",
2766
+ toolCallId: raw.toolCallId,
2767
+ toolName,
2768
+ input: parsedInput,
2769
+ ...providerOptions && { providerOptions }
2770
+ });
2771
+ await emitStepPart?.({
2772
+ type: "tool-call",
2773
+ toolCallId: raw.toolCallId,
2774
+ toolName,
2775
+ input: parsedInput,
2776
+ ...raw.provider !== undefined && { provider: raw.provider }
2777
+ });
2778
+ if (tool.onInputAvailable) {
2779
+ await tool.onInputAvailable.call(tool, {
2780
+ input: parsedInput,
2781
+ toolCallId: raw.toolCallId,
2782
+ messages: input.messages,
2783
+ abortSignal: stepSignalLink.signal
2784
+ });
2785
+ stepSignalLink.signal.throwIfAborted();
2786
+ }
2787
+ const execute = tool.execute;
2788
+ if (typeof execute !== "function")
2789
+ continue;
2790
+ if (tool.needsApproval !== undefined) {
2791
+ await assertStandaloneToolApproval({
2792
+ tool,
2793
+ toolName,
2794
+ toolCallId: raw.toolCallId,
2795
+ parsedInput,
2796
+ messages: input.messages,
2797
+ signal: stepSignalLink.signal
2798
+ });
2799
+ }
2800
+ const task = executeStandaloneToolCall({
2801
+ raw,
2802
+ toolName,
2803
+ tool,
2804
+ execute,
2805
+ parsedInput,
2806
+ messages: input.messages,
2807
+ signal: stepSignalLink.signal,
2808
+ slot,
2809
+ ...emitStepPart !== undefined && { onPart: emitStepPart },
2810
+ onSettled: () => {
2811
+ settledCount += 1;
2812
+ }
2813
+ }).catch((error) => {
2814
+ if (!stepAbort.signal.aborted)
2815
+ stepAbort.abort(error);
2816
+ throw error;
2817
+ });
2818
+ task.catch(() => {
2819
+ return;
2820
+ });
2821
+ pending.push(task);
2822
+ }
2823
+ if (pending.length > 0)
2824
+ await Promise.all(pending);
2825
+ stepSignalLink.signal.throwIfAborted();
2826
+ } catch (error) {
2827
+ if (!stepAbort.signal.aborted)
2828
+ stepAbort.abort(error);
2829
+ throw error;
2830
+ } finally {
2831
+ if (pending.length > 0)
2832
+ await Promise.allSettled(pending);
2833
+ stepSignalLink.release();
2834
+ }
2835
+ return {
2836
+ assistantParts: slots.flatMap((slot) => slot.assistantParts),
2837
+ toolParts: slots.flatMap((slot) => slot.toolParts),
2838
+ stepContent: slots.flatMap((slot) => slot.stepContent),
2839
+ toolCalls: slots.flatMap((slot) => slot.toolCalls),
2840
+ toolResults: slots.flatMap((slot) => slot.toolResults),
2841
+ clientToolCallCount: clientCalls.length,
2842
+ settledClientToolCount: settledCount
2843
+ };
2844
+ }
2845
+
2846
+ // src/agent-runtime/run-complete.ts
2847
+ var LITERAL_SCHEMA_KEYS = new Set(["const", "default", "examples", "enum"]);
2848
+ var SCHEMA_MAP_KEYS = new Set([
2849
+ "properties",
2850
+ "$defs",
2851
+ "definitions",
2852
+ "patternProperties",
2853
+ "dependentSchemas"
2854
+ ]);
2855
+ function resolveInitialMessages(input) {
2856
+ if (input.prompt !== undefined && input.messages !== undefined) {
2857
+ throw new TypeError("completeText accepts either prompt or messages, not both");
2858
+ }
2859
+ if (input.messages !== undefined)
2860
+ return [...input.messages];
2861
+ if (input.prompt !== undefined)
2862
+ return [{ role: "user", content: input.prompt }];
2863
+ throw new TypeError("completeText requires either prompt or messages");
2864
+ }
2865
+ function assertCompleteStopPolicies(policies) {
2866
+ if (!policies)
2867
+ return;
2868
+ const names = new Set;
2869
+ for (const policy of policies) {
2870
+ if (!policy.name || names.has(policy.name)) {
2871
+ throw new TypeError("completeText stop policy names must be non-empty and unique");
2872
+ }
2873
+ names.add(policy.name);
2874
+ }
2875
+ }
2876
+ function buildCompleteStepRequest(params) {
2877
+ const { input, prepared, stepInstructions, currentMessages, specs } = params;
2878
+ const toolChoice = prepared?.toolChoice ?? input.toolChoice;
2879
+ const responseFormat = prepared?.responseFormat ?? input.responseFormat;
2880
+ const cacheControl = prepared?.cacheControl ?? input.cacheControl;
2881
+ const providerOptions = prepared?.providerOptions ?? input.providerOptions;
2882
+ const headers = prepared?.headers ?? input.headers;
2883
+ return {
2884
+ instructions: normalizeAgentInstructions(stepInstructions),
2885
+ messages: currentMessages,
2886
+ tools: specs,
2887
+ ...toolChoice !== undefined && { toolChoice },
2888
+ ...responseFormat !== undefined && { responseFormat },
2889
+ ...cacheControl !== undefined && { cacheControl },
2890
+ settings: mergeStepCallSettings(input.settings, prepared),
2891
+ ...providerOptions !== undefined && { providerOptions },
2892
+ ...headers !== undefined && { headers },
2893
+ correlation: {
2894
+ conversationId: params.defaultConversationId,
2895
+ ...input.correlation?.runId !== undefined && { runId: input.correlation.runId },
2896
+ ...input.correlation?.invocationId !== undefined && {
2897
+ invocationId: input.correlation.invocationId
2898
+ },
2899
+ attemptId: input.correlation?.attemptId ?? params.callId,
2900
+ step: params.stepNumber
2901
+ }
2902
+ };
2903
+ }
2904
+ async function finalizeCompleteResult(params) {
2905
+ const { steps, responseMessages, totalUsage, stoppedByPolicy, emitPart, effectiveSignal } = params;
2906
+ const lastStep = steps.at(-1);
2907
+ const finalUsage = statedUsage(totalUsage ?? unknownUsage());
2908
+ const finalFinishReason = lastStep?.finishReason ?? "other";
2909
+ await emitPart?.({
2910
+ type: "finish",
2911
+ finishReason: finalFinishReason,
2912
+ ...lastStep?.rawFinishReason !== undefined && {
2913
+ rawFinishReason: lastStep.rawFinishReason
2914
+ },
2915
+ usage: finalUsage,
2916
+ ...lastStep !== undefined && {
2917
+ response: {
2918
+ id: lastStep.response.id,
2919
+ ...lastStep.response.modelId !== undefined && {
2920
+ modelId: lastStep.response.modelId
2921
+ },
2922
+ ...lastStep.response.timestamp !== undefined && {
2923
+ timestamp: lastStep.response.timestamp
2924
+ }
2925
+ }
2926
+ }
2927
+ }, effectiveSignal);
2928
+ return {
2929
+ text: lastStep?.text ?? "",
2930
+ finishReason: finalFinishReason,
2931
+ ...lastStep?.rawFinishReason !== undefined && {
2932
+ rawFinishReason: lastStep.rawFinishReason
2933
+ },
2934
+ usage: finalUsage,
2935
+ steps,
2936
+ responseMessages,
2937
+ ...stoppedByPolicy !== undefined && { stoppedByPolicy }
2938
+ };
2939
+ }
2940
+ async function runCompleteLoop(input, emitPart, effectiveSignal) {
2941
+ const tools = input.tools;
2942
+ const declaredTools = tools ? Object.keys(tools) : [];
2943
+ const maxSteps = input.maxSteps ?? (declaredTools.length > 0 ? 10 : 1);
2944
+ assertPositiveSafeInteger("completeText.maxSteps", maxSteps, RangeError);
2945
+ assertTimerMs("completeText.idleTimeoutMs", input.idleTimeoutMs);
2946
+ if (input.retry)
2947
+ assertAgentRetryPolicy("completeText.retry", input.retry);
2948
+ assertCompleteStopPolicies(input.stopPolicies);
2949
+ const initialMessages = resolveInitialMessages(input);
2950
+ const initialInstructions = input.instructions ?? "";
2951
+ const defaultConversationId = input.correlation?.conversationId ?? crypto.randomUUID();
2952
+ let currentMessages = [...initialMessages];
2953
+ let activeDriver = input.driver;
2954
+ const responseMessages = [];
2955
+ const steps = [];
2956
+ let totalUsage;
2957
+ let stoppedByPolicy;
2958
+ for (let stepNumber = 0;stepNumber < maxSteps; stepNumber += 1) {
2959
+ effectiveSignal?.throwIfAborted();
2960
+ const prepared = await input.prepareStep?.({
2961
+ stepNumber,
2962
+ steps,
2963
+ messages: currentMessages,
2964
+ responseMessages,
2965
+ initialMessages,
2966
+ initialInstructions,
2967
+ instructions: initialInstructions,
2968
+ driver: activeDriver,
2969
+ activeTools: declaredTools
2970
+ }) ?? undefined;
2971
+ currentMessages = [...prepared?.messages ?? currentMessages];
2972
+ const stepInstructions = prepared?.instructions ?? initialInstructions;
2973
+ const { activeNames, specs } = tools ? buildActiveToolSpecs(tools, prepared?.activeTools) : { activeNames: [], specs: [] };
2974
+ const effectiveDriver = prepared?.driver ?? activeDriver;
2975
+ activeDriver = effectiveDriver;
2976
+ const callId = crypto.randomUUID();
2977
+ const request = buildCompleteStepRequest({
2978
+ input,
2979
+ prepared,
2980
+ stepInstructions,
2981
+ currentMessages,
2982
+ specs,
2983
+ defaultConversationId,
2984
+ callId,
2985
+ stepNumber
2986
+ });
2987
+ const callOutcome = await runStepModelCallWithRetry({
2988
+ driver: effectiveDriver,
2989
+ request,
2990
+ signal: effectiveSignal,
2991
+ idleTimeoutMs: input.idleTimeoutMs,
2992
+ retry: input.retry,
2993
+ onAttemptDiscarded: input.onAttemptDiscarded,
2994
+ onPart: emitPart,
2995
+ priorUsage: totalUsage
2996
+ });
2997
+ if (callOutcome.discardedUsage !== undefined) {
2998
+ totalUsage = addUsage(totalUsage, callOutcome.discardedUsage);
2999
+ }
3000
+ const { consumed, stepStartedAt, responseFinishedAt } = callOutcome;
3001
+ const finishPart = consumed.finishPart;
3002
+ if (!finishPart) {
3003
+ throw markProviderOrigin(new AgentProviderStreamCutError2("Provider stream ended without a finish event", {
3004
+ provider: effectiveDriver.provider
3005
+ }));
3006
+ }
3007
+ const unsafeForClientTools = isStepUnsafeForClientTools(finishPart.finishReason, consumed.sawErrorPart);
3008
+ const toolStartedAt = performance.now();
3009
+ const toolExecution = unsafeForClientTools || !tools ? emptyStepToolExecutionResult() : await runStandaloneClientTools({
3010
+ rawCalls: consumed.rawToolCalls,
3011
+ tools,
3012
+ activeTools: activeNames,
3013
+ repairToolCall: input.repairToolCall,
3014
+ messages: currentMessages,
3015
+ signal: effectiveSignal ?? new AbortController().signal,
3016
+ ...emitPart !== undefined && { onPart: emitPart }
3017
+ });
3018
+ const stepFinishedAt = performance.now();
3019
+ const toolExecutionMs = unsafeForClientTools || !tools ? 0 : Math.max(0, stepFinishedAt - toolStartedAt);
3020
+ const timings = buildStepTimings({
3021
+ stepStartedAt,
3022
+ responseFinishedAt,
3023
+ stepFinishedAt,
3024
+ firstOutputAt: consumed.firstOutputAt,
3025
+ toolExecutionMs,
3026
+ outputChunkTimestamps: consumed.outputChunkTimestamps
3027
+ });
3028
+ const stepUsage = statedUsage(finishPart.usage);
3029
+ totalUsage = addUsage(totalUsage, stepUsage);
3030
+ const { stepResponseMessages, stepResult } = assembleStepResult({
3031
+ stepNumber,
3032
+ callId,
3033
+ model: { provider: effectiveDriver.provider, modelId: effectiveDriver.modelId },
3034
+ consumed,
3035
+ finishPart,
3036
+ toolExecution,
3037
+ timings,
3038
+ stepUsage
3039
+ });
3040
+ currentMessages = [...currentMessages, ...stepResponseMessages];
3041
+ responseMessages.push(...stepResponseMessages);
3042
+ steps.push(stepResult);
3043
+ await emitPart?.({ type: "finish-step", step: stepResult }, effectiveSignal);
3044
+ await input.onStepFinish?.(stepResult);
3045
+ const canContinue = !unsafeForClientTools && toolExecution.clientToolCallCount > 0 && toolExecution.settledClientToolCount === toolExecution.clientToolCallCount;
3046
+ if (!canContinue)
3047
+ break;
3048
+ let halted = false;
3049
+ for (const policy of input.stopPolicies ?? []) {
3050
+ if (await policy.when({ steps })) {
3051
+ stoppedByPolicy = policy.name;
3052
+ halted = true;
3053
+ break;
3054
+ }
3055
+ }
3056
+ if (halted)
3057
+ break;
3058
+ }
3059
+ return finalizeCompleteResult({
3060
+ steps,
3061
+ responseMessages,
3062
+ totalUsage,
3063
+ stoppedByPolicy,
3064
+ emitPart,
3065
+ effectiveSignal
3066
+ });
3067
+ }
3068
+ async function completeText(input) {
3069
+ const onPart = input.onPart;
3070
+ return runCompleteLoop(input, onPart ? (part) => onPart(part) : undefined, input.signal);
3071
+ }
3072
+ function streamComplete(input) {
3073
+ return createCompleteTextStream(input, runCompleteLoop);
3074
+ }
3075
+ function closeStrictObjectNodes(value) {
3076
+ if (Array.isArray(value))
3077
+ return value.map(closeStrictObjectNodes);
3078
+ if (!isRecord(value))
3079
+ return value;
3080
+ const out = {};
3081
+ for (const [key, entry] of Object.entries(value)) {
3082
+ if (LITERAL_SCHEMA_KEYS.has(key)) {
3083
+ out[key] = entry;
3084
+ } else if (SCHEMA_MAP_KEYS.has(key) && isRecord(entry)) {
3085
+ const mapped = {};
3086
+ for (const [subKey, subEntry] of Object.entries(entry)) {
3087
+ mapped[subKey] = closeStrictObjectNodes(subEntry);
3088
+ }
3089
+ out[key] = mapped;
3090
+ } else {
3091
+ out[key] = closeStrictObjectNodes(entry);
3092
+ }
3093
+ }
3094
+ if (out.type === "object" && isRecord(out.properties) && out.additionalProperties === undefined) {
3095
+ out.additionalProperties = false;
3096
+ }
3097
+ return out;
3098
+ }
3099
+ async function completeObject(input) {
3100
+ const { schema, schemaName, schemaDescription, strict, ...rest } = input;
3101
+ const effectiveStrict = strict ?? true;
3102
+ const jsonSchema = zodToAgentInputJsonSchema(schema);
3103
+ const wireSchema = effectiveStrict ? closeStrictObjectNodes(jsonSchema) : jsonSchema;
3104
+ const responseFormat = AgentModelResponseFormatSchema2.parse({
3105
+ type: "json-schema",
3106
+ name: schemaName ?? "output",
3107
+ schema: isRecord(wireSchema) ? wireSchema : jsonSchema,
3108
+ ...schemaDescription !== undefined && { description: schemaDescription },
3109
+ strict: effectiveStrict
3110
+ });
3111
+ const textInput = rest.prompt !== undefined ? { ...rest, prompt: rest.prompt, responseFormat } : { ...rest, messages: rest.messages, responseFormat };
3112
+ const result = await completeText(textInput);
3113
+ const baseDetails = {
3114
+ finishReason: result.finishReason,
3115
+ rawText: result.text,
3116
+ usage: result.usage,
3117
+ steps: result.steps
3118
+ };
3119
+ if (result.finishReason === "length") {
3120
+ throw new AgentStructuredOutputError("Structured output was truncated before completion (finishReason: length)", { ...baseDetails, reason: "truncated" });
3121
+ }
3122
+ if (result.finishReason === "tool-calls") {
3123
+ throw new AgentStructuredOutputError("Structured output did not complete before step limit or stop policy (finishReason: tool-calls)", { ...baseDetails, reason: "tool-calls" });
3124
+ }
3125
+ if (result.finishReason === "content-filter") {
3126
+ throw new AgentStructuredOutputError("Structured output was blocked by content filter (finishReason: content-filter)", { ...baseDetails, reason: "content-filter" });
3127
+ }
3128
+ if (result.finishReason === "error") {
3129
+ throw new AgentStructuredOutputError("Structured output stopped due to a provider error (finishReason: error)", { ...baseDetails, reason: "provider-error" });
3130
+ }
3131
+ if (result.finishReason === "interrupted") {
3132
+ throw new AgentStructuredOutputError("Structured output was interrupted before completion (finishReason: interrupted)", { ...baseDetails, reason: "interrupted" });
3133
+ }
3134
+ const trimmed = result.text.trim();
3135
+ if (trimmed.length === 0) {
3136
+ throw new AgentStructuredOutputError("Structured output was empty", {
3137
+ ...baseDetails,
3138
+ reason: "empty"
3139
+ });
3140
+ }
3141
+ let parsedJson;
3142
+ try {
3143
+ parsedJson = JSON.parse(trimmed);
3144
+ } catch (cause) {
3145
+ throw new AgentStructuredOutputError("Structured output is not valid JSON", {
3146
+ ...baseDetails,
3147
+ reason: "invalid-json",
3148
+ cause
3149
+ });
3150
+ }
3151
+ const normalizedJson = effectiveStrict ? stripStrictOptionalNulls(parsedJson, jsonSchema) : parsedJson;
3152
+ const validated = schema.safeParse(normalizedJson);
3153
+ if (!validated.success) {
3154
+ throw new AgentStructuredOutputError("Structured output failed schema validation", {
3155
+ ...baseDetails,
3156
+ reason: "schema-mismatch",
3157
+ cause: validated.error
3158
+ });
3159
+ }
3160
+ return { ...result, object: validated.data };
3161
+ }
3162
+ // src/agent-runtime/run-driver-compose.ts
3163
+ function buildFinishedOutcome(part, sawErrorPart, lastErrorPart) {
3164
+ return {
3165
+ status: "finished",
3166
+ finishReason: part.finishReason,
3167
+ usage: part.usage,
3168
+ ...part.rawFinishReason !== undefined && { rawFinishReason: part.rawFinishReason },
3169
+ ...part.costDetails !== undefined && { costDetails: part.costDetails },
3170
+ ...part.responseProvider !== undefined && { responseProvider: part.responseProvider },
3171
+ ...part.response !== undefined && { response: part.response },
3172
+ ...sawErrorPart && lastErrorPart !== undefined && { error: lastErrorPart }
3173
+ };
3174
+ }
3175
+ async function runDecoratedStream(driver, decorator, request, signal, state) {
3176
+ let closePromise;
3177
+ let iterating = false;
3178
+ let terminalOutcome;
3179
+ let sawErrorPart = false;
3180
+ let lastErrorPart;
3181
+ let effectiveLink;
3182
+ let effectiveSignal = signal;
3183
+ const onAbort = () => {
3184
+ if (iterating)
3185
+ return;
3186
+ closeOnce(terminalOutcome ?? { status: "cancelled" }).catch(() => {
3187
+ return;
3188
+ });
3189
+ };
3190
+ const closeOnce = (outcome) => {
3191
+ if (!closePromise) {
3192
+ signal.removeEventListener("abort", onAbort);
3193
+ effectiveSignal.removeEventListener("abort", onAbort);
3194
+ effectiveLink?.release();
3195
+ effectiveLink = undefined;
3196
+ closePromise = Promise.resolve().then(() => decorator.onClose?.(outcome, state));
3197
+ }
3198
+ return closePromise;
3199
+ };
3200
+ if (signal.aborted) {
3201
+ await closeOnce({ status: "cancelled" });
3202
+ signal.throwIfAborted();
3203
+ }
3204
+ let inner;
3205
+ try {
3206
+ const effectiveRequest = decorator.transformRequest ? await decorator.transformRequest(request, state) : request;
3207
+ if (decorator.transformSignal) {
3208
+ const tightened = decorator.transformSignal(signal, state);
3209
+ if (tightened !== undefined && tightened !== signal) {
3210
+ effectiveLink = linkAbortSignals(signal, tightened);
3211
+ effectiveSignal = effectiveLink.signal;
3212
+ }
3213
+ }
3214
+ if (effectiveSignal.aborted) {
3215
+ await closeOnce({ status: "cancelled" });
3216
+ effectiveSignal.throwIfAborted();
3217
+ }
3218
+ inner = await driver.stream(effectiveRequest, effectiveSignal);
3219
+ } catch (error) {
3220
+ await closeOnce(effectiveSignal.aborted ? { status: "cancelled" } : { status: "errored", error });
3221
+ throw error;
3222
+ }
3223
+ if (effectiveSignal.aborted) {
3224
+ closeOnce({ status: "cancelled" }).catch(() => {
3225
+ return;
3226
+ });
3227
+ } else {
3228
+ effectiveSignal.addEventListener("abort", onAbort, { once: true });
3229
+ }
3230
+ const parts = {
3231
+ [Symbol.asyncIterator]() {
3232
+ iterating = true;
3233
+ effectiveSignal.removeEventListener("abort", onAbort);
3234
+ let iterator;
3235
+ try {
3236
+ iterator = inner.parts[Symbol.asyncIterator]();
3237
+ } catch (error) {
3238
+ closeOnce(effectiveSignal.aborted ? { status: "cancelled" } : { status: "errored", error }).catch(() => {
3239
+ return;
3240
+ });
3241
+ throw error;
3242
+ }
3243
+ const closeOnDone = () => {
3244
+ if (terminalOutcome !== undefined)
3245
+ return closeOnce(terminalOutcome);
3246
+ if (sawErrorPart)
3247
+ return closeOnce({ status: "errored", error: lastErrorPart });
3248
+ if (effectiveSignal.aborted)
3249
+ return closeOnce({ status: "cancelled" });
3250
+ return closeOnce({
3251
+ status: "errored",
3252
+ error: new AgentProviderStreamCutError2("Provider stream ended before a finish part", {
3253
+ provider: driver.provider
3254
+ })
3255
+ });
3256
+ };
3257
+ return {
3258
+ async next() {
3259
+ let next;
3260
+ try {
3261
+ next = await iterator.next();
3262
+ } catch (error) {
3263
+ await closeOnce(terminalOutcome ?? (effectiveSignal.aborted ? { status: "cancelled" } : { status: "errored", error }));
3264
+ throw error;
3265
+ }
3266
+ if (next.done) {
3267
+ await closeOnDone();
3268
+ return next;
3269
+ }
3270
+ const part = next.value;
3271
+ try {
3272
+ await decorator.onPart?.(part, state);
3273
+ } catch (error) {
3274
+ try {
3275
+ await iterator.return?.();
3276
+ } catch {}
3277
+ await closeOnce({ status: "errored", error });
3278
+ throw error;
3279
+ }
3280
+ if (part.type === "finish") {
3281
+ terminalOutcome = buildFinishedOutcome(part, sawErrorPart, lastErrorPart);
3282
+ } else if (part.type === "error") {
3283
+ sawErrorPart = true;
3284
+ lastErrorPart = part.error;
3285
+ }
3286
+ return next;
3287
+ },
3288
+ async return(value) {
3289
+ try {
3290
+ if (iterator.return)
3291
+ await iterator.return(value);
3292
+ } finally {
3293
+ await closeOnce(terminalOutcome ?? (sawErrorPart ? { status: "errored", error: lastErrorPart } : { status: "cancelled" }));
3294
+ }
3295
+ return { done: true, value: undefined };
3296
+ },
3297
+ async throw(error) {
3298
+ try {
3299
+ if (iterator.throw)
3300
+ return await iterator.throw(error);
3301
+ throw error;
3302
+ } finally {
3303
+ await closeOnce(terminalOutcome ?? (effectiveSignal.aborted ? { status: "cancelled" } : { status: "errored", error }));
3304
+ }
3305
+ }
3306
+ };
3307
+ }
3308
+ };
3309
+ return {
3310
+ ...inner.response !== undefined && { response: inner.response },
3311
+ parts
3312
+ };
3313
+ }
3314
+ function wrapModelDriver(driver, decorator) {
3315
+ return {
3316
+ provider: driver.provider,
3317
+ modelId: driver.modelId,
3318
+ async stream(request, signal) {
3319
+ const state = decorator.beforeStream ? await decorator.beforeStream(request, signal, {
3320
+ provider: driver.provider,
3321
+ modelId: driver.modelId
3322
+ }) : undefined;
3323
+ return runDecoratedStream(driver, decorator, request, signal, state);
3324
+ }
3325
+ };
3326
+ }
3327
+ function composeModelDrivers(driver, decorators) {
3328
+ let current = driver;
3329
+ for (let index = decorators.length - 1;index >= 0; index -= 1) {
3330
+ const decorator = decorators[index];
3331
+ if (decorator !== undefined) {
3332
+ current = wrapModelDriver(current, decorator);
3333
+ }
3334
+ }
3335
+ return current;
3336
+ }
2068
3337
  // src/agent-runtime/schedule-contract.ts
2069
3338
  import { z as z6 } from "zod";
2070
3339
  var AgentScheduleSchema = z6.object({
@@ -2842,6 +4111,7 @@ export {
2842
4111
  AgentAttemptResetEventSchema2 as AgentAttemptResetEventSchema,
2843
4112
  AgentBranchRefusalCodeSchema2 as AgentBranchRefusalCodeSchema,
2844
4113
  AgentBranchRefusalSchema2 as AgentBranchRefusalSchema,
4114
+ AgentCacheControlSchema2 as AgentCacheControlSchema,
2845
4115
  AgentCheckpointEventSchema2 as AgentCheckpointEventSchema,
2846
4116
  AgentChildBlockingEventSchema2 as AgentChildBlockingEventSchema,
2847
4117
  AgentChildBlockingKindSchema2 as AgentChildBlockingKindSchema,
@@ -2866,25 +4136,39 @@ export {
2866
4136
  AgentEventSearchResultSchema2 as AgentEventSearchResultSchema,
2867
4137
  AgentFilePartSchema2 as AgentFilePartSchema,
2868
4138
  AgentHistoryMutationSchema2 as AgentHistoryMutationSchema,
4139
+ AgentInvalidToolApprovalSignatureError2 as AgentInvalidToolApprovalSignatureError,
4140
+ AgentInvalidToolInputError2 as AgentInvalidToolInputError,
2869
4141
  AgentJsonObjectSchema2 as AgentJsonObjectSchema,
2870
4142
  AgentMessagePartSchema2 as AgentMessagePartSchema,
2871
4143
  AgentMessageRoleSchema2 as AgentMessageRoleSchema,
2872
4144
  AgentMessageSchema2 as AgentMessageSchema,
2873
4145
  AgentMessageStatusSchema2 as AgentMessageStatusSchema,
4146
+ AgentModelAssistantContentPartSchema2 as AgentModelAssistantContentPartSchema,
4147
+ AgentModelAssistantMessageSchema2 as AgentModelAssistantMessageSchema,
2874
4148
  AgentModelCapabilitySchema2 as AgentModelCapabilitySchema,
2875
4149
  AgentModelCatalogEntrySchema2 as AgentModelCatalogEntrySchema,
2876
4150
  AgentModelCatalogSchema2 as AgentModelCatalogSchema,
2877
4151
  AgentModelDescriptorSchema2 as AgentModelDescriptorSchema,
4152
+ AgentModelFileDataSchema2 as AgentModelFileDataSchema,
4153
+ AgentModelMessageSchema2 as AgentModelMessageSchema,
2878
4154
  AgentModelMetricSchema2 as AgentModelMetricSchema,
2879
4155
  AgentModelPopularitySchema2 as AgentModelPopularitySchema,
2880
4156
  AgentModelPriceSchema2 as AgentModelPriceSchema,
4157
+ AgentModelProviderOptionsSchema2 as AgentModelProviderOptionsSchema,
2881
4158
  AgentModelRegistrySnapshotSchema2 as AgentModelRegistrySnapshotSchema,
4159
+ AgentModelResponseFormatSchema2 as AgentModelResponseFormatSchema,
2882
4160
  AgentModelSearchInputSchema2 as AgentModelSearchInputSchema,
2883
4161
  AgentModelSearchResultSchema2 as AgentModelSearchResultSchema,
2884
4162
  AgentModelSelectionSchema2 as AgentModelSelectionSchema,
4163
+ AgentModelSystemMessageSchema2 as AgentModelSystemMessageSchema,
4164
+ AgentModelToolContentPartSchema2 as AgentModelToolContentPartSchema,
4165
+ AgentModelToolMessageSchema2 as AgentModelToolMessageSchema,
4166
+ AgentModelUserContentPartSchema2 as AgentModelUserContentPartSchema,
4167
+ AgentModelUserMessageSchema2 as AgentModelUserMessageSchema,
2885
4168
  AgentOpaquePartSchema2 as AgentOpaquePartSchema,
2886
4169
  AgentProvenanceSchema2 as AgentProvenanceSchema,
2887
4170
  AgentProviderEnvelopeSchema2 as AgentProviderEnvelopeSchema,
4171
+ AgentProviderError2 as AgentProviderError,
2888
4172
  AgentProviderResponseSchema2 as AgentProviderResponseSchema,
2889
4173
  AgentProviderStreamCutError2 as AgentProviderStreamCutError,
2890
4174
  AgentReasoningDeltaEventSchema2 as AgentReasoningDeltaEventSchema,
@@ -2895,6 +4179,7 @@ export {
2895
4179
  AgentRecordVersionSchema2 as AgentRecordVersionSchema,
2896
4180
  AgentRecoverableDescriptorSchema2 as AgentRecoverableDescriptorSchema,
2897
4181
  AgentRecoverablePageSchema2 as AgentRecoverablePageSchema,
4182
+ AgentRetryExhaustedError,
2898
4183
  AgentRunEventSchema,
2899
4184
  AgentRunMetricsSchema2 as AgentRunMetricsSchema,
2900
4185
  AgentRunOperationEventSchema2 as AgentRunOperationEventSchema,
@@ -2934,18 +4219,23 @@ export {
2934
4219
  AgentStoreTransitionSchema2 as AgentStoreTransitionSchema,
2935
4220
  AgentStoreUnsupportedCapabilityError2 as AgentStoreUnsupportedCapabilityError,
2936
4221
  AgentStoredRunSchema2 as AgentStoredRunSchema,
4222
+ AgentStructuredOutputError,
2937
4223
  AgentTerminalEventSchema2 as AgentTerminalEventSchema,
2938
4224
  AgentTerminalReasonSchema2 as AgentTerminalReasonSchema,
2939
4225
  AgentTextPartSchema2 as AgentTextPartSchema,
2940
4226
  AgentTimestampSchema2 as AgentTimestampSchema,
2941
4227
  AgentTokenCountSchema2 as AgentTokenCountSchema,
4228
+ AgentToolApprovalError2 as AgentToolApprovalError,
2942
4229
  AgentToolApprovalRequestPartSchema2 as AgentToolApprovalRequestPartSchema,
2943
4230
  AgentToolApprovalResponsePartSchema2 as AgentToolApprovalResponsePartSchema,
4231
+ AgentToolCallNotFoundForApprovalError2 as AgentToolCallNotFoundForApprovalError,
2944
4232
  AgentToolCallPartSchema2 as AgentToolCallPartSchema,
4233
+ AgentToolModelOutputSchema2 as AgentToolModelOutputSchema,
2945
4234
  AgentToolProgressEventSchema2 as AgentToolProgressEventSchema,
2946
4235
  AgentToolResultPartSchema2 as AgentToolResultPartSchema,
2947
4236
  AgentToolStatusEventSchema2 as AgentToolStatusEventSchema,
2948
4237
  AgentTransientDeltaEventSchema2 as AgentTransientDeltaEventSchema,
4238
+ AgentUnknownToolError2 as AgentUnknownToolError,
2949
4239
  AgentUsageSchema2 as AgentUsageSchema,
2950
4240
  AgentUsageValueSchema2 as AgentUsageValueSchema,
2951
4241
  AppendAgentStoreEventSchema2 as AppendAgentStoreEventSchema,
@@ -2987,8 +4277,12 @@ export {
2987
4277
  agentTodoStateSlot2 as agentTodoStateSlot,
2988
4278
  agentUsageProjection,
2989
4279
  canonicalAgentJson2 as canonicalAgentJson,
4280
+ carriedToolWork,
2990
4281
  classifyProviderFailure2 as classifyProviderFailure,
4282
+ completeObject,
4283
+ completeText,
2991
4284
  composeAgentPrompt2 as composeAgentPrompt,
4285
+ composeModelDrivers,
2992
4286
  createAgentChildManager,
2993
4287
  createAgentChildTools,
2994
4288
  createAgentEventSearch2 as createAgentEventSearch,
@@ -3020,6 +4314,7 @@ export {
3020
4314
  defineStateSlot2 as defineStateSlot,
3021
4315
  encodeAgentConversationArchive2 as encodeAgentConversationArchive,
3022
4316
  hasAgentTerminalOutput,
4317
+ isAgentProviderError2 as isAgentProviderError,
3023
4318
  isAssistantHistoryEvidence2 as isAssistantHistoryEvidence,
3024
4319
  isToolResultFailure2 as isToolResultFailure,
3025
4320
  modelInvocationSpendAttribution,
@@ -3032,6 +4327,8 @@ export {
3032
4327
  searchAgentModelCatalog2 as searchAgentModelCatalog,
3033
4328
  selectAgentHistory2 as selectAgentHistory,
3034
4329
  selectCompactableHistory,
4330
+ streamComplete,
3035
4331
  structuredCompaction,
3036
- validateAgentModelSnapshot2 as validateAgentModelSnapshot
4332
+ validateAgentModelSnapshot2 as validateAgentModelSnapshot,
4333
+ wrapModelDriver
3037
4334
  };