fengming 0.3.4 → 0.3.5

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 (2016) hide show
  1. package/CHANGELOG.md +3 -2
  2. package/dist/abort-CjCDVBbH.js +277 -0
  3. package/dist/abort.runtime-DxJ8129J.js +2 -0
  4. package/dist/abort.runtime.js +1 -1
  5. package/dist/accounts-Cyn0sm_v.js +423 -0
  6. package/dist/accounts-DzcLKcN5.js +2 -0
  7. package/dist/acp/control-plane/manager.js +1 -1
  8. package/dist/acp-spawn-4lfz_3K9.js +1286 -0
  9. package/dist/acp-spawn-BCUjuO6L.js +2 -0
  10. package/dist/acp-stateful-target-driver-Bv99uwEA.js +89 -0
  11. package/dist/action-info-CP-p6RHS.js +75 -0
  12. package/dist/active-runtime-registry-DjKe53a5.js +62 -0
  13. package/dist/active-tool-schema-warnings-p7CqUnu1.js +105 -0
  14. package/dist/active-tool-schema-warnings-pGI92yka.js +2 -0
  15. package/dist/agent-B77yluip.js +1825 -0
  16. package/dist/agent-BooUvZnR.js +2 -0
  17. package/dist/agent-bundle-lsp-runtime-3ieSgTgo.js +389 -0
  18. package/dist/agent-bundle-lsp-runtime-CkJ0XJK7.js +2 -0
  19. package/dist/agent-bundle-mcp-materialize-BH-esGZL.js +124 -0
  20. package/dist/agent-bundle-mcp-tools-DkixTTnL.js +3 -0
  21. package/dist/agent-command-BJKcnQy6.js +1435 -0
  22. package/dist/agent-delivery-CEfe_Zzt.js +117 -0
  23. package/dist/agent-harness-runtime-R_Ae6o9C.js +207 -0
  24. package/dist/agent-kWSaRcQt.js +3 -0
  25. package/dist/agent-model-discovery-C49swEgd.js +238 -0
  26. package/dist/agent-model-discovery-DZbixJQs.js +3 -0
  27. package/dist/agent-runner-utils-BChpi9Ec.js +267 -0
  28. package/dist/agent-runner.runtime-3LOdt215.js +3784 -0
  29. package/dist/agent-runner.runtime.js +1 -1
  30. package/dist/agent-runtime-3jsv8b7Y.js +199 -0
  31. package/dist/agent-runtime-label-uoFI4ovH.js +30 -0
  32. package/dist/agent-runtime-metadata-BhFt6kLt.js +53 -0
  33. package/dist/agent-tool-result-middleware-loader-BxYJNC1i.js +55 -0
  34. package/dist/agent-tools-COLEG7aL.js +2506 -0
  35. package/dist/agent-tools.before-tool-call--rMZI5Rd.js +1274 -0
  36. package/dist/agent-tools.before-tool-call-CbX2sfP4.js +2 -0
  37. package/dist/agent-via-gateway-DfKij3De.js +486 -0
  38. package/dist/agent-wait-dedupe-BAUSJotw.js +180 -0
  39. package/dist/agents/agent-bundle-mcp-materialize.js +1 -1
  40. package/dist/agents/auth-profiles.runtime.js +1 -1
  41. package/dist/agents/compaction-planning.worker.js +1 -1
  42. package/dist/agents/embedded-agent-runner/effective-tool-policy.js +1 -1
  43. package/dist/agents/embedded-agent-runner/tool-split.js +1 -1
  44. package/dist/agents/model-catalog.runtime.js +1 -1
  45. package/dist/agents/model-provider-auth.worker.js +3 -3
  46. package/dist/agents/models-config.runtime.js +1 -1
  47. package/dist/agents-CZSNDJWD.js +632 -0
  48. package/dist/agents.command-shared-DgbjfH23.js +16 -0
  49. package/dist/agents.commands.add-DknGM1oz.js +304 -0
  50. package/dist/agents.commands.bind-DDVI0yDe.js +265 -0
  51. package/dist/agents.commands.delete-Dv4RHEhc.js +128 -0
  52. package/dist/agents.commands.identity-BSZbc1QR.js +143 -0
  53. package/dist/agents.commands.list-CA0OTw59.js +235 -0
  54. package/dist/aliases-EY1GbfwT.js +97 -0
  55. package/dist/api-CY0oKcRz.js +3 -0
  56. package/dist/api-DgjY0gIl.js +6 -0
  57. package/dist/api-VyMyAYze.js +2 -0
  58. package/dist/api-key-rotation-DxPKIdmC.js +167 -0
  59. package/dist/app-registration-BBDxCbFo.js +194 -0
  60. package/dist/apply-DMYy7tc3.js +544 -0
  61. package/dist/apply-Dd0n97MD.js +2 -0
  62. package/dist/apply-bHIT1nMp.js +416 -0
  63. package/dist/apply-g8x7Z83S.js +510 -0
  64. package/dist/apply-nnbx9TaB.js +2 -0
  65. package/dist/approval-native-helpers-CjaYvOaZ.js +398 -0
  66. package/dist/artifacts-B55YR-uA.js +368 -0
  67. package/dist/assistant-hJaOgfKl.js +291 -0
  68. package/dist/attachment-normalize-COsastJx.js +213 -0
  69. package/dist/attempt-execution-fDWDWcWe.js +584 -0
  70. package/dist/attempt-execution.helpers-Cze5xPim.js +969 -0
  71. package/dist/attempt-execution.runtime-B1iCG6LN.js +3 -0
  72. package/dist/attempt-execution.runtime.js +1 -1
  73. package/dist/attempt.prompt-helpers-CkBYHBBo.js +543 -0
  74. package/dist/attempt.tool-run-context-DzfRK5pV.js +1240 -0
  75. package/dist/audio-preflight.runtime-rjWd9uyk.js +7 -0
  76. package/dist/audio-preflight.runtime.js +1 -1
  77. package/dist/audit-DgFtNg3U.js +1108 -0
  78. package/dist/audit-L8EC3WhV.js +477 -0
  79. package/dist/audit.nondeep.runtime-D0sQ6bO2.js +1416 -0
  80. package/dist/audit.nondeep.runtime.js +1 -1
  81. package/dist/audit.runtime-CiG82F31.js +7 -0
  82. package/dist/audit.runtime.js +1 -1
  83. package/dist/auth-CzPdsZVM.js +567 -0
  84. package/dist/auth-choice-BNzS9QBI.js +3 -0
  85. package/dist/auth-choice-Cwr5kgcD.js +110 -0
  86. package/dist/auth-choice-DW9qPpMS.js +400 -0
  87. package/dist/auth-choice.apply.api-providers-C68tOdqj.js +34 -0
  88. package/dist/auth-choice.apply.api-providers-DSRK0gYo.js +2 -0
  89. package/dist/auth-choice.plugin-providers.runtime-BJ9VyO1C.js +11 -0
  90. package/dist/auth-choice.plugin-providers.runtime.js +1 -1
  91. package/dist/auth-health-BanKwsTW.js +219 -0
  92. package/dist/auth-list-Dq8obVno.js +115 -0
  93. package/dist/auth-order-VXqoAroP.js +105 -0
  94. package/dist/auth-profiles-6VFEdgC-.js +73 -0
  95. package/dist/auth-profiles-a0M4JYYg.js +14 -0
  96. package/dist/backend-config-COaTdVnN.js +259 -0
  97. package/dist/bash-tools-BMAquSiM.js +3 -0
  98. package/dist/bash-tools-DLiUXfaS.js +3497 -0
  99. package/dist/binding-routing-Bwvdx_7S.js +113 -0
  100. package/dist/binding-targets-Z_d0mK_1.js +121 -0
  101. package/dist/bootstrap-files-CoCV_zqu.js +202 -0
  102. package/dist/bootstrap-files-_T3VoTrV.js +3 -0
  103. package/dist/bridge-server-BIaNurGa.js +113 -0
  104. package/dist/browser-cli-D4wL8NU9.js +230 -0
  105. package/dist/browser-cli-actions-input-z40PGiYI.js +522 -0
  106. package/dist/browser-cli-actions-observe-C4TeyNke.js +81 -0
  107. package/dist/browser-cli-debug-Dv0gH-c8.js +137 -0
  108. package/dist/browser-cli-inspect-BUXeITYc.js +117 -0
  109. package/dist/browser-cli-manage-qMb3Yw5Y.js +446 -0
  110. package/dist/browser-cli-resize-CZWnGwGz.js +32 -0
  111. package/dist/browser-cli-shared-BpinhvE3.js +69 -0
  112. package/dist/browser-cli-state-CBbKqqgP.js +371 -0
  113. package/dist/browser-cli-uI5GGX51.js +2 -0
  114. package/dist/browser-control-auth-CFPJXdN_.js +2 -0
  115. package/dist/browser-profiles-D4ni3t4J.js +2 -0
  116. package/dist/browser-runtime-Dm5D_PLf.js +389 -0
  117. package/dist/browser-tool.schema-Bek02ox5.js +132 -0
  118. package/dist/btw-command-DdrwvCK4.js +18 -0
  119. package/dist/build-DkEeJ9sO.js +261 -0
  120. package/dist/build-info.json +2 -2
  121. package/dist/bundled/boot-md/handler.js +2 -2
  122. package/dist/bundled/session-memory/handler.js +1 -1
  123. package/dist/bundled-channel-config-schema-BeowdkHi.d.ts +3168 -0
  124. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  125. package/dist/capability-cli-DTRuKZJC.js +1809 -0
  126. package/dist/capability-provider-runtime-Cpp-Jq9g.js +346 -0
  127. package/dist/cdp.helpers-GfQkB-B5.js +637 -0
  128. package/dist/channel-BRehZ4Cg.js +2309 -0
  129. package/dist/channel-actions-hdQKe_se.js +46 -0
  130. package/dist/channel-bootstrap.runtime-BzjlNG_j.js +38 -0
  131. package/dist/channel-bootstrap.runtime-CmNNVl40.js +2 -0
  132. package/dist/channel-bootstrap.runtime.js +1 -1
  133. package/dist/channel-core-BLcWqSk-.js +5 -0
  134. package/dist/channel-inbound-pR1B7HTU.js +121 -0
  135. package/dist/channel-message-W0VurpjH.js +12 -0
  136. package/dist/channel-outbound-DO4HI6E_.js +436 -0
  137. package/dist/channel-plugin-resolution-CLA7S5_A.js +2 -0
  138. package/dist/channel-plugin-resolution-DzwVj01h.js +135 -0
  139. package/dist/channel-resolution-DOPyiG4k.js +46 -0
  140. package/dist/channel-selection-kwoWZDQ3.js +171 -0
  141. package/dist/channel-selection.runtime-LiDliif9.js +2 -0
  142. package/dist/channel-selection.runtime.js +1 -1
  143. package/dist/channel.runtime-DDt3PayH.js +697 -0
  144. package/dist/channel.runtime.js +1 -1
  145. package/dist/channels-CKJd4eUz.js +1004 -0
  146. package/dist/channels-cli-DLAPi8pX.js +331 -0
  147. package/dist/chat-6WsYrS9m.js +3 -0
  148. package/dist/chat-DpsCEXAx.js +2940 -0
  149. package/dist/chrome-BWHc9vYG.js +1517 -0
  150. package/dist/chrome-mcp-BGKgR8A_.js +2 -0
  151. package/dist/chrome-mcp-Bg5D5PDc.js +864 -0
  152. package/dist/claude-live-session-BLCZnv-A.js +2 -0
  153. package/dist/claude-live-session-CGnB64D6.js +1338 -0
  154. package/dist/clawbot-cli-ynXzgp8B.js +9 -0
  155. package/dist/cli/daemon-cli.js +3 -3
  156. package/dist/cli/gateway-lifecycle.runtime.js +4 -4
  157. package/dist/cli/run-main.js +12 -12
  158. package/dist/cli-B4Ttnj0P.js +2 -0
  159. package/dist/cli-BjVgdamH.js +2 -0
  160. package/dist/cli-CNqBrHLU.js +293 -0
  161. package/dist/cli-backends.runtime-DoxtCrow.js +7 -0
  162. package/dist/cli-backends.runtime.js +1 -1
  163. package/dist/cli-compaction-BCuLbs75.js +363 -0
  164. package/dist/cli-mthNIkji.js +141 -0
  165. package/dist/cli-registry-loader-B2sNTdgY.js +2 -0
  166. package/dist/cli-registry-loader-Dz9YFrjw.js +193 -0
  167. package/dist/cli-runner-C9t-9-Io.js +597 -0
  168. package/dist/cli-runner-D21qMGk7.js +2 -0
  169. package/dist/cli-runner.runtime-BNqbJFgu.js +3 -0
  170. package/dist/cli-runner.runtime-Dv50IEvH.js +4 -0
  171. package/dist/cli-runner.runtime.js +1 -1
  172. package/dist/cli-session-jBtClYfT.js +119 -0
  173. package/dist/cli-startup-metadata.json +9 -9
  174. package/dist/cli.runtime-CGBzSGAG.js +1276 -0
  175. package/dist/cli.runtime.js +1 -1
  176. package/dist/codex-native-web-search-B3C-srtm.js +20 -0
  177. package/dist/codex-native-web-search-B7xh2Xcb.js +4 -0
  178. package/dist/codex-native-web-search-core-CrwANQg5.js +106 -0
  179. package/dist/command-auth-Dz_pdczs.js +135 -0
  180. package/dist/command-config-resolution-XCA63Yv8.js +25 -0
  181. package/dist/command-config-resolution-xtKMDTG9.js +2 -0
  182. package/dist/command-config-resolution.runtime-xtKMDTG9.js +2 -0
  183. package/dist/command-config-resolution.runtime.js +1 -1
  184. package/dist/command-execution-startup-CasEqEXh.js +90 -0
  185. package/dist/command-primitives-runtime-DC9gtSI3.js +3 -0
  186. package/dist/command-registry-BQnMdca9.js +9 -0
  187. package/dist/command-registry-core-hx2t1jQP.js +114 -0
  188. package/dist/command-registry-rbKA-L_8.js +4 -0
  189. package/dist/command-secret-gateway-7oveYQCx.js +589 -0
  190. package/dist/command-secret-targets-B7M1Us_C.js +2 -0
  191. package/dist/command-status-builders-DrSoZhiI.js +147 -0
  192. package/dist/command-status.runtime-By0071-y.js +90 -0
  193. package/dist/command-status.runtime.js +1 -1
  194. package/dist/commands/status.summary.runtime.js +3 -3
  195. package/dist/commands-B1MnUj5-.js +161 -0
  196. package/dist/commands-compact.runtime-DELj3JaW.js +10 -0
  197. package/dist/commands-compact.runtime.js +1 -1
  198. package/dist/commands-core.runtime-Zw0grrkC.js +2 -0
  199. package/dist/commands-core.runtime.js +1 -1
  200. package/dist/commands-handlers.runtime-BCl_ZHJZ.js +6327 -0
  201. package/dist/commands-handlers.runtime.js +1 -1
  202. package/dist/commands-models-Uurm-0C3.js +448 -0
  203. package/dist/commands-registry-Bo1AeDcq.js +195 -0
  204. package/dist/commands-registry.runtime-C9DBHyhh.js +4 -0
  205. package/dist/commands-registry.runtime.js +1 -1
  206. package/dist/commands-status-BoAXH-wg.js +16 -0
  207. package/dist/commands-status-CNALMTN9.js +3 -0
  208. package/dist/commands-status.runtime-CNALMTN9.js +3 -0
  209. package/dist/commands-status.runtime.js +1 -1
  210. package/dist/commands-subagents-control.runtime-Dl4IuTzV.js +2 -0
  211. package/dist/commands-subagents-control.runtime.js +1 -1
  212. package/dist/commands-system-prompt-BPzpLmUp.js +2 -0
  213. package/dist/commands-system-prompt-DCOZSNh5.js +161 -0
  214. package/dist/commands.runtime-bfCLM0Sg.js +175 -0
  215. package/dist/commands.runtime.js +1 -1
  216. package/dist/commitments/runtime.js +1 -1
  217. package/dist/common-CoOYhmSg.js +286 -0
  218. package/dist/compact-yqaUOESq.js +1165 -0
  219. package/dist/compact.runtime-Y91AFZVE.js +12 -0
  220. package/dist/compact.runtime.js +1 -1
  221. package/dist/compaction-planning-DVnykwzd.js +202 -0
  222. package/dist/completion-cli-BJjq_g_B.js +393 -0
  223. package/dist/config-CsmSEaNn.js +374 -0
  224. package/dist/config-CtNXZ0iy.js +610 -0
  225. package/dist/config-cli-CNpIVdqp.js +1703 -0
  226. package/dist/config-mutation-B-SErGM0.js +5 -0
  227. package/dist/config-mutations-Bu3ahkX8.js +161 -0
  228. package/dist/config-utils-Bv0Nisds.js +141 -0
  229. package/dist/config-validation-DitvTYD8.js +33 -0
  230. package/dist/configure-CdjbRKTg.js +771 -0
  231. package/dist/configure-Cvi-5ml4.js +3 -0
  232. package/dist/configure.commands-BJii4733.js +1253 -0
  233. package/dist/configure.commands-tJzVFJ0o.js +2 -0
  234. package/dist/context-D1N9oPds.js +2 -0
  235. package/dist/context-XMtJ9b3v.js +248 -0
  236. package/dist/context-engine-host-compat-3QznbSaW.js +280 -0
  237. package/dist/context-engine-host-compat-DquSpnKD.js +2 -0
  238. package/dist/context-engine-lifecycle-Bqdhy9JU.js +627 -0
  239. package/dist/control-auth-CMW_9jmY.js +114 -0
  240. package/dist/control-service-D-r3k91q.js +40 -0
  241. package/dist/control-service-uIPYrp9F.js +3 -0
  242. package/dist/control-ui/assets/activity-DgMhyllD.js +124 -0
  243. package/dist/control-ui/assets/agents-CsRhxO2O.js +1030 -0
  244. package/dist/control-ui/assets/channels-Dq8bzpMg.js +120 -0
  245. package/dist/control-ui/assets/cron-Dk5bqYwg.js +1016 -0
  246. package/dist/control-ui/assets/debug-CNIwFEQO.js +97 -0
  247. package/dist/control-ui/assets/index-CV2NsPlu.js +7214 -0
  248. package/dist/control-ui/assets/instances-DLr0iEvT.js +57 -0
  249. package/dist/control-ui/assets/nodes-D3JEksjl.js +444 -0
  250. package/dist/control-ui/assets/sessions-nbXWGlHZ.js +425 -0
  251. package/dist/control-ui/assets/skills-tBOi8OBq.js +362 -0
  252. package/dist/control-ui/assets/workboard-ClTo7wmK.js +402 -0
  253. package/dist/control-ui/index.html +1 -1
  254. package/dist/control-ui/sw.js +1 -1
  255. package/dist/control-ui-AkRMsk9S.js +750 -0
  256. package/dist/conversation-label-generator-DHtcgSBn.js +72 -0
  257. package/dist/conversation-runtime-BEgHW4ta.js +31 -0
  258. package/dist/core-Bslrvfnp.js +284 -0
  259. package/dist/core-api-BOlUb7G8.js +5 -0
  260. package/dist/core-api-CiBoGa2I.js +2 -0
  261. package/dist/crestodian/crestodian.js +1 -1
  262. package/dist/crestodian/rescue-message.js +1 -1
  263. package/dist/crestodian-mXnyuHx9.js +55 -0
  264. package/dist/cron-PbdpyFrD.js +453 -0
  265. package/dist/daemon-install-C-d4dFvn.js +66 -0
  266. package/dist/daemon-install-auth-profiles-store.runtime-CvE2EVVo.js +2 -0
  267. package/dist/daemon-install-auth-profiles-store.runtime.js +1 -1
  268. package/dist/dashboard-Ey5dnvMI.js +263 -0
  269. package/dist/defaults-CsRAv-qE.js +130 -0
  270. package/dist/defaults-DHZBSNHC.js +3 -0
  271. package/dist/defaults.constants-CR4S_tvw.js +76 -0
  272. package/dist/deliver-BkuuFBlm.js +1399 -0
  273. package/dist/deliver-P4upyes7.js +3 -0
  274. package/dist/deliver-runtime-CjnLI_nC.js +2 -0
  275. package/dist/delivery-outbound.runtime-fcJ-M8qj.js +7 -0
  276. package/dist/delivery-outbound.runtime.js +1 -1
  277. package/dist/delivery-queue-BqgHvNlY.js +863 -0
  278. package/dist/delivery-queue-CfsRscJb.js +2 -0
  279. package/dist/delivery-queue-runtime-D0PKG1Bv.js +16 -0
  280. package/dist/delivery-target.runtime-C5e8d0WH.js +45 -0
  281. package/dist/delivery-target.runtime.js +1 -1
  282. package/dist/delivery.runtime-2Ut8xM3P.js +470 -0
  283. package/dist/delivery.runtime.js +1 -1
  284. package/dist/detached-task-runtime-OOZBqRy-.js +86 -0
  285. package/dist/diagnostics-zf6WQ2h7.js +168 -0
  286. package/dist/dialogue-C8IOya-l.js +37 -0
  287. package/dist/direct-dm-wPF-KfNb.js +81 -0
  288. package/dist/directive-handling.defaults-C-1lmFYo.js +22 -0
  289. package/dist/directive-handling.fast-lane-DENPMtYI.js +70 -0
  290. package/dist/directive-handling.impl-C1p5t3qA.js +2 -0
  291. package/dist/directive-handling.impl-DOo2Sa7C.js +823 -0
  292. package/dist/directive-handling.model-selection-6gC-fr_g.js +122 -0
  293. package/dist/directive-handling.persist.runtime-CuhUd2kW.js +274 -0
  294. package/dist/directive-handling.persist.runtime.js +1 -1
  295. package/dist/directives-BIKSyN8C.js +319 -0
  296. package/dist/directory-cli-DZ0PU0Rv.js +239 -0
  297. package/dist/dispatch-DQLImAqt.js +2057 -0
  298. package/dist/dispatch-acp-DzyX7wsq.js +1102 -0
  299. package/dist/dispatch-acp-manager.runtime-CoAfs4O1.js +3 -0
  300. package/dist/dispatch-acp-manager.runtime.js +1 -1
  301. package/dist/dispatch-acp-media.runtime-7uUP_jr9.js +4 -0
  302. package/dist/dispatch-acp-media.runtime.js +1 -1
  303. package/dist/dispatch-acp-transcript.runtime-BUlmV_h0.js +40 -0
  304. package/dist/dispatch-acp-transcript.runtime.js +1 -1
  305. package/dist/dispatch-acp-tts.runtime-ChBnVkNt.js +3 -0
  306. package/dist/dispatch-acp-tts.runtime.js +1 -1
  307. package/dist/dispatch-acp.runtime-DAexFaBu.js +18 -0
  308. package/dist/dispatch-acp.runtime.js +1 -1
  309. package/dist/dispatcher-D3IQEbf9.js +106 -0
  310. package/dist/doctor-BSqEqfb6.js +760 -0
  311. package/dist/doctor-auth-flat-profiles-BIZ4wsYP.js +2 -0
  312. package/dist/doctor-auth-flat-profiles-DXtD5LfC.js +516 -0
  313. package/dist/doctor-auth-legacy-oauth-DwFbRYTP.js +48 -0
  314. package/dist/doctor-auth-oauth-sidecar-6I3FEJbi.js +2 -0
  315. package/dist/doctor-auth-oauth-sidecar-BSC3rnDM.js +177 -0
  316. package/dist/doctor-auth-tVGsUiM6.js +216 -0
  317. package/dist/doctor-bootstrap-size-B0q6bdkO.js +57 -0
  318. package/dist/doctor-claude-cli-Bn79OuBT.js +150 -0
  319. package/dist/doctor-config-flow-CCwocXpV.js +1819 -0
  320. package/dist/doctor-core-checks-D7-1l8jy.js +666 -0
  321. package/dist/doctor-core-checks-eM8FNi8B.js +2 -0
  322. package/dist/doctor-core-checks.runtime-Dc03aeoU.js +278 -0
  323. package/dist/doctor-core-checks.runtime.js +1 -1
  324. package/dist/doctor-gRYfpEbB.js +6 -0
  325. package/dist/doctor-gateway-daemon-flow-KTnHAdeV.js +349 -0
  326. package/dist/doctor-gateway-services-BByDQtjY.js +465 -0
  327. package/dist/doctor-health-CnoM718z.js +65 -0
  328. package/dist/doctor-health-contributions-flVKMQwr.js +874 -0
  329. package/dist/doctor-lint-BBm6gtBa.js +95 -0
  330. package/dist/doctor-memory-search-DjHVDCGo.js +407 -0
  331. package/dist/doctor-state-integrity-Bgw25cz1.js +1257 -0
  332. package/dist/doctor-tool-result-cap-advice-B8wTpiTO.js +27 -0
  333. package/dist/doctor-workspace-status-DcjeJIpT.js +76 -0
  334. package/dist/dreaming-BE4t8DVf.js +523 -0
  335. package/dist/dreaming-command-DWm1lB-Z.js +101 -0
  336. package/dist/dreaming-narrative-8DM-OMrm.js +721 -0
  337. package/dist/dreaming-narrative-CcFfheQI.js +2 -0
  338. package/dist/dreaming-phases-CqOhhTdZ.js +2 -0
  339. package/dist/dreaming-phases-D9eT6Kk0.js +1162 -0
  340. package/dist/drive-D2M5B7-2.js +899 -0
  341. package/dist/echo-transcript-B-wl5MoX.js +52 -0
  342. package/dist/effective-tool-policy-Cx8mC5aA.js +89 -0
  343. package/dist/embedded-agent-BTvtoOe_.js +4 -0
  344. package/dist/embedded-agent-CGmSKuNM.js +4074 -0
  345. package/dist/embedded-agent-helpers-CboIPx57.js +6 -0
  346. package/dist/embedded-agent-helpers-cw0InMDZ.js +1037 -0
  347. package/dist/embedded-agent.runtime-Bfe4bjyF.js +4 -0
  348. package/dist/embedded-agent.runtime.js +1 -1
  349. package/dist/embedded-backend-D-EshN85.js +744 -0
  350. package/dist/embedded-gateway-stub.runtime-Cx9qs0KV.js +12 -0
  351. package/dist/embedded-gateway-stub.runtime.js +1 -1
  352. package/dist/embedding-provider-runtime-DaXfsUPo.js +86 -0
  353. package/dist/embedding-providers-CdU99clu.js +2 -0
  354. package/dist/embeddings-http-BQnlTr-1.js +222 -0
  355. package/dist/engine-qmd-5jbjGywA.js +708 -0
  356. package/dist/engine-storage-CfAgwoDp.js +203 -0
  357. package/dist/entry.js +1 -1
  358. package/dist/errors-C0AUxo3P.js +2 -0
  359. package/dist/exec-approval-forwarder.runtime-BvR47p5Z.js +4 -0
  360. package/dist/exec-approval-forwarder.runtime.js +1 -1
  361. package/dist/exec-approval-session-target-CCqYgaVa.js +177 -0
  362. package/dist/exec-auto-reviewer-BfJaNkNy.js +2 -0
  363. package/dist/exec-auto-reviewer-Dqx7I88Z.js +241 -0
  364. package/dist/execute.runtime-Qb6Z75sG.js +579 -0
  365. package/dist/execute.runtime.js +1 -1
  366. package/dist/extensionAPI.js +2 -2
  367. package/dist/extensions/active-memory/index.js +3 -3
  368. package/dist/extensions/admin-http-rpc/index.js +1 -1
  369. package/dist/extensions/alibaba/index.js +1 -1
  370. package/dist/extensions/alibaba/video-generation-provider.js +1 -1
  371. package/dist/extensions/baichuan/index.js +1 -1
  372. package/dist/extensions/browser/browser-bridge.js +1 -1
  373. package/dist/extensions/browser/browser-cdp.js +1 -1
  374. package/dist/extensions/browser/browser-config.js +5 -5
  375. package/dist/extensions/browser/browser-control-auth.js +2 -2
  376. package/dist/extensions/browser/browser-doctor.js +3 -3
  377. package/dist/extensions/browser/browser-maintenance.js +1 -1
  378. package/dist/extensions/browser/browser-profiles.js +3 -3
  379. package/dist/extensions/browser/browser-runtime-api.js +14 -14
  380. package/dist/extensions/browser/cli-metadata.js +1 -1
  381. package/dist/extensions/browser/index.js +1 -1
  382. package/dist/extensions/browser/plugin-registration.js +1 -1
  383. package/dist/extensions/browser/register.runtime.js +4 -4
  384. package/dist/extensions/browser/runtime-api.js +16 -16
  385. package/dist/extensions/byteplus/index.js +3 -3
  386. package/dist/extensions/byteplus/video-generation-provider.js +1 -1
  387. package/dist/extensions/canvas/index.js +3 -3
  388. package/dist/extensions/canvas/runtime-api.js +2 -2
  389. package/dist/extensions/deepseek/index.js +1 -1
  390. package/dist/extensions/device-pair/api.js +2 -2
  391. package/dist/extensions/device-pair/pair-command-approve.js +1 -1
  392. package/dist/extensions/device-pair/qr-image.js +2 -2
  393. package/dist/extensions/longcat/index.js +1 -1
  394. package/dist/extensions/memory-core/api.js +3 -3
  395. package/dist/extensions/memory-core/cli-metadata.js +1 -1
  396. package/dist/extensions/memory-core/cli.js +2 -2
  397. package/dist/extensions/memory-core/index.js +11 -11
  398. package/dist/extensions/memory-core/manager-runtime.js +1 -1
  399. package/dist/extensions/memory-core/runtime-api.js +6 -6
  400. package/dist/extensions/minimax/image-generation-provider.js +1 -1
  401. package/dist/extensions/minimax/index.js +7 -7
  402. package/dist/extensions/minimax/media-understanding-provider.js +1 -1
  403. package/dist/extensions/minimax/music-generation-provider.js +1 -1
  404. package/dist/extensions/minimax/oauth.js +1 -1
  405. package/dist/extensions/minimax/oauth.runtime.js +1 -1
  406. package/dist/extensions/minimax/provider-registration.js +1 -1
  407. package/dist/extensions/minimax/speech-provider.js +1 -1
  408. package/dist/extensions/minimax/video-generation-provider.js +1 -1
  409. package/dist/extensions/minimax/web-search-provider.js +1 -1
  410. package/dist/extensions/moonshot/index.js +5 -5
  411. package/dist/extensions/moonshot/media-understanding-provider.js +1 -1
  412. package/dist/extensions/moonshot/web-search-provider.js +1 -1
  413. package/dist/extensions/qianfan/index.js +1 -1
  414. package/dist/extensions/qwen/index.js +5 -5
  415. package/dist/extensions/qwen/media-understanding-provider.js +1 -1
  416. package/dist/extensions/qwen/video-generation-provider.js +1 -1
  417. package/dist/extensions/sensenova/index.js +1 -1
  418. package/dist/extensions/skill-workshop/api.js +2 -2
  419. package/dist/extensions/skill-workshop/index.js +4 -4
  420. package/dist/extensions/stepfun/index.js +2 -2
  421. package/dist/extensions/tavily/index.js +1 -1
  422. package/dist/extensions/tavily/web-search-provider.js +1 -1
  423. package/dist/extensions/tencent/index.js +2 -2
  424. package/dist/extensions/tiangong/index.js +1 -1
  425. package/dist/extensions/volcengine/index.js +3 -3
  426. package/dist/extensions/volcengine/speech-provider.js +1 -1
  427. package/dist/extensions/webhooks/api.js +1 -1
  428. package/dist/extensions/webhooks/index.js +1 -1
  429. package/dist/extensions/weixin/index.js +3 -3
  430. package/dist/extensions/workboard/index.js +2 -2
  431. package/dist/extensions/xiaomi/index.js +4 -4
  432. package/dist/extensions/xiaomi/speech-provider.js +1 -1
  433. package/dist/extensions/xingchen/index.js +1 -1
  434. package/dist/extensions/yi/index.js +1 -1
  435. package/dist/extensions/zai/index.js +4 -4
  436. package/dist/extensions/zai/media-understanding-provider.js +1 -1
  437. package/dist/extensions/zhinao/index.js +1 -1
  438. package/dist/external-cli-auth-selection-CM_aOUJw.js +113 -0
  439. package/dist/extra-params-Bm1eLWN9.js +615 -0
  440. package/dist/fallback-notice-state-v1kyWACv.js +15 -0
  441. package/dist/fallbacks-CDllk2g1.js +31 -0
  442. package/dist/fallbacks-shared-DdMKEmAC.js +116 -0
  443. package/dist/fengming-runtime-DSv30J04.js +33 -0
  444. package/dist/fengming-runtime-config-BE-DquuY.js +2 -0
  445. package/dist/fengming-runtime-memory-BE-DquuY.js +2 -0
  446. package/dist/fengming-runtime-session-BE-DquuY.js +2 -0
  447. package/dist/fengming-tools-DHb-ZeDC.js +12221 -0
  448. package/dist/flows-Cz3y10A9.js +189 -0
  449. package/dist/fs-utils-D05rps7O.js +9 -0
  450. package/dist/gateway/protocol/index.d.ts +1 -1
  451. package/dist/gateway-DTi2D7ZS.js +133 -0
  452. package/dist/gateway-cli-DT2fL2fX.js +443 -0
  453. package/dist/gateway-install-token-CJhAycOA.js +136 -0
  454. package/dist/gateway-method-runtime-BuiYTDQk.js +21 -0
  455. package/dist/gateway-runtime-C5_cVlSW.js +23 -0
  456. package/dist/get-reply-Cz-dUrWm.js +5198 -0
  457. package/dist/get-reply-from-config.runtime-BC1HT67i.js +2 -0
  458. package/dist/get-reply-from-config.runtime.js +1 -1
  459. package/dist/github-copilot-token-09lxV3kH.js +2 -0
  460. package/dist/health-CmihbcqN.js +621 -0
  461. package/dist/health-D8L37hBZ.js +111 -0
  462. package/dist/health-DU7I9RrJ.js +3 -0
  463. package/dist/health-state-QZ2E6xGQ.js +106 -0
  464. package/dist/heartbeat-runner-Bz5PMzEI.js +1930 -0
  465. package/dist/heartbeat-runner-DfqqQ_8w.js +5 -0
  466. package/dist/heartbeat-runner.runtime-8BshUhoS.js +3 -0
  467. package/dist/heartbeat-runner.runtime.js +1 -1
  468. package/dist/helpers-Bkq4POdX.js +406 -0
  469. package/dist/hook-helpers-nmDwt3Fa.js +44 -0
  470. package/dist/hooks-9FOcRqfu.js +536 -0
  471. package/dist/hooks-cli-CrQelcwo.js +465 -0
  472. package/dist/http-endpoint-helpers-BD5u6YsT.js +37 -0
  473. package/dist/http-utils-RcKuBJ0I.js +98 -0
  474. package/dist/image-DwNoypK2.js +385 -0
  475. package/dist/image-fallbacks-BUyDnmUX.js +31 -0
  476. package/dist/image-generation-core.auth.runtime-CA8miEMh.js +2 -0
  477. package/dist/image-generation-core.auth.runtime.js +1 -1
  478. package/dist/image-generation-provider-DXMW5EmB.js +152 -0
  479. package/dist/image-runtime-D5QpNNzz.js +9 -0
  480. package/dist/image-tool.helpers-6vGxo1Y0.js +150 -0
  481. package/dist/images-BGWLzQEJ.js +416 -0
  482. package/dist/images-Db4UB3JG.js +2 -0
  483. package/dist/inbound-reply-dispatch-DRF6ZmQg.js +2 -0
  484. package/dist/inbound-reply-dispatch-RAKLqow4.js +147 -0
  485. package/dist/index-DhOQs6M_.d.ts +1497 -0
  486. package/dist/index.js +1 -1
  487. package/dist/infra-runtime-BFrpRc_V.js +32 -0
  488. package/dist/init-sR7bCS9D.js +59 -0
  489. package/dist/install-BzdJbOUx.js +262 -0
  490. package/dist/install.runtime-Zye6pbZ6.js +2 -0
  491. package/dist/internal-DL_vFx8C.js +399 -0
  492. package/dist/isolated-agent-Qif8Llbt.js +2 -0
  493. package/dist/isolated-agent-aqEjxqs-.js +1097 -0
  494. package/dist/kernel-B-i4c2IK.js +979 -0
  495. package/dist/kernel-DYDJ_hLb.js +3 -0
  496. package/dist/kimi-web-search-provider.runtime-95HAkvHY.js +307 -0
  497. package/dist/kimi-web-search-provider.runtime.js +1 -1
  498. package/dist/library-CZVbE5hF.js +45 -0
  499. package/dist/lifecycle-C8M3YLbT.js +2 -0
  500. package/dist/lifecycle-CPDNQnUN.js +570 -0
  501. package/dist/lifecycle-DpuP7n3J.js +355 -0
  502. package/dist/lifecycle.runtime-C8M3YLbT.js +2 -0
  503. package/dist/lifecycle.runtime.js +1 -1
  504. package/dist/link-understanding/apply.runtime.js +3 -3
  505. package/dist/list-B_ALwpPl.js +2 -0
  506. package/dist/list-Bda_GYFy.js +207 -0
  507. package/dist/list.list-command-W9OGfAIU.js +429 -0
  508. package/dist/list.model-row-LV4AaX0H.js +39 -0
  509. package/dist/list.probe-CrZm6BH2.js +451 -0
  510. package/dist/list.probe-Dfdmb8bC.js +2 -0
  511. package/dist/list.provider-catalog-7T1jKk0n.js +211 -0
  512. package/dist/list.provider-catalog-DjGyZVEj.js +2 -0
  513. package/dist/list.registry-load-DkCS8JZQ.js +152 -0
  514. package/dist/list.row-sources-B1vjo_Y9.js +474 -0
  515. package/dist/list.source-plan-C9Sa6zRK.js +81 -0
  516. package/dist/list.status-command-9daSZZDm.js +815 -0
  517. package/dist/live-model-switch-Dy-UFUMS.js +119 -0
  518. package/dist/llm-slug-generator-DEmh5-_1.js +78 -0
  519. package/dist/llm-slug-generator.js +1 -1
  520. package/dist/load-config-CvQpC8k6.js +27 -0
  521. package/dist/load-context-_qSHpZ5S.js +82 -0
  522. package/dist/loader-CntMt07B.js +7008 -0
  523. package/dist/local-dispatch.runtime-BSN_gqNS.js +10 -0
  524. package/dist/local-dispatch.runtime.js +1 -1
  525. package/dist/main-session-restart-recovery-Db7366lt.js +2 -0
  526. package/dist/main-session-restart-recovery-n87NTooQ.js +389 -0
  527. package/dist/managed-image-attachments-BTBBHlKl.js +2 -0
  528. package/dist/managed-image-attachments-C6_V1yX0.js +616 -0
  529. package/dist/manager-CKrWxjV6.js +3737 -0
  530. package/dist/manager-Dvb1FVnx.js +2314 -0
  531. package/dist/mcp/plugin-tools-serve.js +2 -2
  532. package/dist/mcp-http-CSoGXOa_.js +583 -0
  533. package/dist/mcp-http-D4ieDB3W.js +2 -0
  534. package/dist/media-runtime-GeQTQkkK.js +391 -0
  535. package/dist/media-services-CWbIUZDe.js +416 -0
  536. package/dist/media-understanding/apply.runtime.js +1 -1
  537. package/dist/media-understanding-DXc2BD2L.js +87 -0
  538. package/dist/media-understanding-provider-BkdUiVWU.js +70 -0
  539. package/dist/media-understanding-provider-BlgmLViW.js +13 -0
  540. package/dist/media-understanding-provider-C9P2VjkC.js +29 -0
  541. package/dist/media-understanding-provider-CJlbgAvl.js +69 -0
  542. package/dist/memory-CnC2jM1l.js +437 -0
  543. package/dist/memory-core-host-engine-embeddings-Dy9vN-Ce.js +667 -0
  544. package/dist/memory-core-host-engine-foundation-C-pGGQnm.js +15 -0
  545. package/dist/memory-core-host-engine-qmd-DLJDON9w.js +2 -0
  546. package/dist/memory-core-host-engine-storage-Bzf-C8XE.js +2 -0
  547. package/dist/memory-core-host-runtime-cli-_LWA6G3x.js +10 -0
  548. package/dist/memory-core-host-runtime-core-CromkNBr.js +12 -0
  549. package/dist/memory-core-host-runtime-files-DpbviC1b.js +4 -0
  550. package/dist/memory-embedding-provider-runtime-CaVVaYC5.js +36 -0
  551. package/dist/memory-host-core-B5dWHwBF.js +78 -0
  552. package/dist/memory-host-search.runtime-DqlCFac1.js +2 -0
  553. package/dist/memory-host-search.runtime.js +1 -1
  554. package/dist/memory-runtime-BCeeWb1G.js +2 -0
  555. package/dist/memory-runtime-pR9KGin0.js +57 -0
  556. package/dist/memory-search-CpDEEY2Q.js +235 -0
  557. package/dist/message-BeGCG-D8.js +284 -0
  558. package/dist/message-YGMOyqP5.js +2 -0
  559. package/dist/message-action-runner-ByMT3_eb.js +1922 -0
  560. package/dist/message-action-runner-VXmKO_W7.js +2 -0
  561. package/dist/message-handler-MZ0DMbCx.js +1806 -0
  562. package/dist/metadata-registry-loader-BH9D1UOx.js +2 -0
  563. package/dist/metadata-registry-loader-BK1cHCas.js +22 -0
  564. package/dist/migrate-BA6w0hd3.js +2 -0
  565. package/dist/migrate-BGuQC-1W.js +458 -0
  566. package/dist/migration-provider-runtime-BBdDegWG.js +2 -0
  567. package/dist/migration-provider-runtime-C5WUjrQz.js +68 -0
  568. package/dist/minimax-web-search-provider.runtime-suVFk3Zx.js +148 -0
  569. package/dist/minimax-web-search-provider.runtime.js +1 -1
  570. package/dist/model-BJZXR9dq.js +1302 -0
  571. package/dist/model-BL7xlN5h.js +2 -0
  572. package/dist/model-auth-C-6dYVob.js +6 -0
  573. package/dist/model-auth-DJz7R41W.js +705 -0
  574. package/dist/model-auth-label-DKNXktIu.js +67 -0
  575. package/dist/model-catalog-BjiK5rtT.js +3 -0
  576. package/dist/model-catalog-DM1CTjkW.js +434 -0
  577. package/dist/model-catalog-visibility-DEJZG0In.js +76 -0
  578. package/dist/model-config.helpers-BKcUeE_P.js +95 -0
  579. package/dist/model-context-tokens-5y_PQELY.js +572 -0
  580. package/dist/model-fallback-BDdBR053.js +1288 -0
  581. package/dist/model-fallback-auth.runtime-pcWfkIUF.js +5 -0
  582. package/dist/model-fallback-auth.runtime.js +1 -1
  583. package/dist/model-picker-Bpvp4_N4.js +1135 -0
  584. package/dist/model-picker-DWPPtq6d.js +3 -0
  585. package/dist/model-picker-visibility-BtdqVF80.js +22 -0
  586. package/dist/model-picker.runtime-CYlqts2z.js +48 -0
  587. package/dist/model-picker.runtime.js +1 -1
  588. package/dist/model-pricing-cache-BmmncDqL.js +856 -0
  589. package/dist/model-pricing-cache-CEwRyWw2.js +3 -0
  590. package/dist/model-pricing-cache-state-B8Aspp85.js +83 -0
  591. package/dist/model-provider-auth-B3KXoKkE.js +2 -0
  592. package/dist/model-provider-auth-Bo_8T7of.js +375 -0
  593. package/dist/model-runtime-aliases-Br-ZlhrL.js +133 -0
  594. package/dist/model-selection-D5-ERakL.js +254 -0
  595. package/dist/model-selection-DrzgktRu.js +7 -0
  596. package/dist/model-selection-ibwsPgIw.js +352 -0
  597. package/dist/model-selection.runtime-BRkOZejt.js +7 -0
  598. package/dist/model-selection.runtime.js +1 -1
  599. package/dist/models-RPAH3ZBn.js +57 -0
  600. package/dist/models-auth-status-Cwu9OXU8.js +280 -0
  601. package/dist/models-cli-CrYkSUoa.js +257 -0
  602. package/dist/models-config-Ayzj9gDz.js +1189 -0
  603. package/dist/models-config-BFcjB7nN.js +2 -0
  604. package/dist/models-config.providers.secrets-CCRUW7gL.js +2 -0
  605. package/dist/models-config.providers.secrets-DdX_XSRo.js +382 -0
  606. package/dist/models-http-jLFnelH7.js +88 -0
  607. package/dist/monitor-CqWICrjO.js +60 -0
  608. package/dist/monitor-DwccYPfp.js +1024 -0
  609. package/dist/monitor.account-e9EVttpP.js +5382 -0
  610. package/dist/music-generation-provider-Dfc--R-x.js +308 -0
  611. package/dist/native-hook-relay-Cioqiqv8.js +1378 -0
  612. package/dist/native-hook-relay-DRwJIspI.js +19 -0
  613. package/dist/node-cli-CrG3LH9J.js +2806 -0
  614. package/dist/node-command-policy-CkBTEmhl.js +295 -0
  615. package/dist/nodes-BxrWFA09.js +1483 -0
  616. package/dist/nodes-DFPTGZjc.js +3 -0
  617. package/dist/nodes-cli-Czwyt6r1.js +960 -0
  618. package/dist/nodes-pending-B_4QHyB2.js +211 -0
  619. package/dist/nodes-utils-c4k31OaG.js +85 -0
  620. package/dist/oauth-BXncC0JP.js +852 -0
  621. package/dist/oauth-Ba1O2vqP.js +207 -0
  622. package/dist/oauth-CGQkfxbJ.js +746 -0
  623. package/dist/onboard-I5tQlVm6.js +768 -0
  624. package/dist/onboard-channels-BleKfB1D.js +2 -0
  625. package/dist/onboard-channels-jVaUjGYX.js +1534 -0
  626. package/dist/onboard-custom-BR_5oqUr.js +3 -0
  627. package/dist/onboard-custom-Ss0DThuP.js +280 -0
  628. package/dist/onboard-custom-config-B-knjQm7.js +422 -0
  629. package/dist/onboard-search-BsIztGYF.js +412 -0
  630. package/dist/openai-compat-errors-UkLkk8Q9.js +136 -0
  631. package/dist/openai-http-mTQB44gu.js +836 -0
  632. package/dist/openai-transport-stream-CZSs3SIi.js +3427 -0
  633. package/dist/openresponses-http-BA1Shmj-.js +1175 -0
  634. package/dist/operations-DhgPih1F.js +805 -0
  635. package/dist/order-CaXafMPG.js +218 -0
  636. package/dist/outbound-attachment-BAp7DXDc.js +19 -0
  637. package/dist/param-readers-De-m2SoB.js +2 -0
  638. package/dist/payloads-Dg9aAEOC.js +256 -0
  639. package/dist/persistent-bindings.lifecycle-BkLOz501.js +2 -0
  640. package/dist/persistent-bindings.lifecycle-e2MLbBCo.js +85 -0
  641. package/dist/plugin-enabled-CGSENjXc.js +232 -0
  642. package/dist/plugin-install-BI9_bsVT.js +118 -0
  643. package/dist/plugin-install-an4V2iXO.js +2 -0
  644. package/dist/plugin-install-config-policy-C66Nss3D.js +169 -0
  645. package/dist/plugin-registration-DMerQktl.js +97 -0
  646. package/dist/plugin-registry-BZfdCw65.js +3 -0
  647. package/dist/plugin-registry-I1fegSdK.js +2 -0
  648. package/dist/plugin-runtime-B3XMLJka.js +102 -0
  649. package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
  650. package/dist/plugin-sdk/acp-binding-runtime.js +1 -1
  651. package/dist/plugin-sdk/acp-runtime-backend.js +1 -1
  652. package/dist/plugin-sdk/acp-runtime.js +2 -2
  653. package/dist/plugin-sdk/agent-harness-runtime.js +16 -16
  654. package/dist/plugin-sdk/agent-harness-task-runtime.js +4 -4
  655. package/dist/plugin-sdk/agent-harness.js +17 -17
  656. package/dist/plugin-sdk/agent-runtime.js +17 -17
  657. package/dist/plugin-sdk/agent-sessions.js +1 -1
  658. package/dist/plugin-sdk/approval-native-runtime.js +2 -2
  659. package/dist/plugin-sdk/approval-reaction-runtime.js +1 -1
  660. package/dist/plugin-sdk/approval-runtime.js +2 -2
  661. package/dist/plugin-sdk/bundled-channel-config-schema-BsOWCrJT.d.ts +3169 -0
  662. package/dist/plugin-sdk/bundled-channel-config-schema.d.ts +1 -1
  663. package/dist/plugin-sdk/channel-actions.js +2 -2
  664. package/dist/plugin-sdk/channel-config-schema-legacy.d.ts +1 -1
  665. package/dist/plugin-sdk/channel-core.js +2 -2
  666. package/dist/plugin-sdk/channel-envelope.js +1 -1
  667. package/dist/plugin-sdk/channel-inbound-roots.js +1 -1
  668. package/dist/plugin-sdk/channel-inbound.js +4 -4
  669. package/dist/plugin-sdk/channel-location.js +1 -1
  670. package/dist/plugin-sdk/channel-message-runtime.js +5 -5
  671. package/dist/plugin-sdk/channel-message.js +5 -5
  672. package/dist/plugin-sdk/channel-outbound.js +2 -2
  673. package/dist/plugin-sdk/channel-reply-options-runtime.js +1 -1
  674. package/dist/plugin-sdk/command-auth-native.js +2 -2
  675. package/dist/plugin-sdk/command-auth.js +4 -4
  676. package/dist/plugin-sdk/command-primitives-runtime.js +2 -2
  677. package/dist/plugin-sdk/command-status-runtime.js +1 -1
  678. package/dist/plugin-sdk/command-status.js +1 -1
  679. package/dist/plugin-sdk/compat.js +2 -2
  680. package/dist/plugin-sdk/config-mutation.js +2 -2
  681. package/dist/plugin-sdk/config-runtime.js +1 -1
  682. package/dist/plugin-sdk/config-schema.d.ts +2 -2
  683. package/dist/plugin-sdk/conversation-binding-runtime.js +1 -1
  684. package/dist/plugin-sdk/conversation-runtime.js +3 -3
  685. package/dist/plugin-sdk/core.js +3 -3
  686. package/dist/plugin-sdk/delivery-queue-runtime.js +1 -1
  687. package/dist/plugin-sdk/direct-dm.js +1 -1
  688. package/dist/plugin-sdk/discord.d.ts +1 -1
  689. package/dist/plugin-sdk/embedding-providers.js +2 -2
  690. package/dist/plugin-sdk/gateway-method-runtime.js +1 -1
  691. package/dist/plugin-sdk/gateway-runtime.js +2 -2
  692. package/dist/plugin-sdk/health.js +1 -1
  693. package/dist/plugin-sdk/image-generation-core.js +3 -3
  694. package/dist/plugin-sdk/image-generation-runtime.js +1 -1
  695. package/dist/plugin-sdk/image-generation.js +2 -2
  696. package/dist/plugin-sdk/inbound-reply-dispatch.js +3 -3
  697. package/dist/plugin-sdk/index.js +1 -1
  698. package/dist/plugin-sdk/infra-runtime.js +3 -3
  699. package/dist/plugin-sdk/mattermost.js +1 -1
  700. package/dist/plugin-sdk/media-generation-runtime-shared.js +1 -1
  701. package/dist/plugin-sdk/media-generation-runtime.js +1 -1
  702. package/dist/plugin-sdk/media-runtime.js +7 -7
  703. package/dist/plugin-sdk/media-understanding-runtime.js +1 -1
  704. package/dist/plugin-sdk/media-understanding.js +2 -2
  705. package/dist/plugin-sdk/memory-core-host-engine-embeddings.js +4 -4
  706. package/dist/plugin-sdk/memory-core-host-engine-foundation.js +2 -2
  707. package/dist/plugin-sdk/memory-core-host-engine-qmd.js +2 -2
  708. package/dist/plugin-sdk/memory-core-host-engine-storage.js +6 -6
  709. package/dist/plugin-sdk/memory-core-host-runtime-cli.js +2 -2
  710. package/dist/plugin-sdk/memory-core-host-runtime-core.js +3 -3
  711. package/dist/plugin-sdk/memory-core-host-runtime-files.js +4 -4
  712. package/dist/plugin-sdk/memory-core.js +3 -3
  713. package/dist/plugin-sdk/memory-host-core.js +3 -3
  714. package/dist/plugin-sdk/memory-host-files.js +4 -4
  715. package/dist/plugin-sdk/memory-host-search.js +1 -1
  716. package/dist/plugin-sdk/models-provider-runtime.js +1 -1
  717. package/dist/plugin-sdk/music-generation-core.js +1 -1
  718. package/dist/plugin-sdk/native-command-registry.js +1 -1
  719. package/dist/plugin-sdk/outbound-media.js +2 -2
  720. package/dist/plugin-sdk/outbound-runtime.js +3 -3
  721. package/dist/plugin-sdk/param-readers.js +2 -2
  722. package/dist/plugin-sdk/plugin-runtime.js +2 -2
  723. package/dist/plugin-sdk/provider-auth-api-key.js +4 -4
  724. package/dist/plugin-sdk/provider-auth-login.js +1 -1
  725. package/dist/plugin-sdk/provider-auth-runtime.js +2 -2
  726. package/dist/plugin-sdk/provider-auth.js +6 -6
  727. package/dist/plugin-sdk/provider-catalog-runtime.js +2 -2
  728. package/dist/plugin-sdk/provider-entry.js +1 -1
  729. package/dist/plugin-sdk/provider-setup.js +1 -1
  730. package/dist/plugin-sdk/provider-stream-family.js +3 -3
  731. package/dist/plugin-sdk/provider-stream.js +2 -2
  732. package/dist/plugin-sdk/provider-transport-runtime.js +1 -1
  733. package/dist/plugin-sdk/provider-web-fetch.js +2 -2
  734. package/dist/plugin-sdk/provider-web-search.js +4 -4
  735. package/dist/plugin-sdk/realtime-bootstrap-context.js +2 -2
  736. package/dist/plugin-sdk/realtime-transcription.js +1 -1
  737. package/dist/plugin-sdk/realtime-voice.js +2 -2
  738. package/dist/plugin-sdk/reply-dispatch-runtime.js +1 -1
  739. package/dist/plugin-sdk/reply-runtime.js +6 -6
  740. package/dist/plugin-sdk/runtime-secret-resolution.js +2 -2
  741. package/dist/plugin-sdk/runtime.js +3 -3
  742. package/dist/plugin-sdk/self-hosted-provider-setup.js +1 -1
  743. package/dist/plugin-sdk/simple-completion-runtime.js +1 -1
  744. package/dist/plugin-sdk/speech-core.js +2 -2
  745. package/dist/plugin-sdk/speech.js +1 -1
  746. package/dist/plugin-sdk/tool-plugin.js +1 -1
  747. package/dist/plugin-sdk/transcripts.js +1 -1
  748. package/dist/plugin-sdk/tts-runtime.js +1 -1
  749. package/dist/plugin-sdk/video-generation-core.js +2 -2
  750. package/dist/plugin-sdk/video-generation-runtime.js +1 -1
  751. package/dist/plugin-sdk/web-media.js +3 -3
  752. package/dist/plugin-sdk/zalouser.js +1 -1
  753. package/dist/plugin-service-2XF6Lu_a.js +1249 -0
  754. package/dist/plugins/build-smoke-entry.js +2 -2
  755. package/dist/plugins/loader.js +1 -1
  756. package/dist/plugins/provider-discovery.runtime.js +1 -1
  757. package/dist/plugins/provider-runtime.runtime.js +1 -1
  758. package/dist/plugins/runtime/index.js +19 -19
  759. package/dist/plugins/tools.js +1 -1
  760. package/dist/plugins-authoring-command-CCX6tJwd.js +304 -0
  761. package/dist/plugins-cli-HX8nTV2h.js +63 -0
  762. package/dist/plugins-cli.runtime-BYn4VsLP.js +339 -0
  763. package/dist/plugins-cli.runtime.js +1 -1
  764. package/dist/plugins-command-helpers-ByuW-yNj.js +2 -0
  765. package/dist/plugins-command-helpers-DaaxGnCD.js +164 -0
  766. package/dist/plugins-inspect-command-C9NDk23X.js +248 -0
  767. package/dist/plugins-install-command-B0NfUxeA.js +993 -0
  768. package/dist/plugins-install-command-BmuScfLI.js +2 -0
  769. package/dist/plugins-install-persist-CfwO876P.js +252 -0
  770. package/dist/plugins-list-command-Bx8X908n.js +184 -0
  771. package/dist/plugins-uninstall-command-p6h44-Ft.js +118 -0
  772. package/dist/postinstall-inventory.json +862 -862
  773. package/dist/prepare.runtime-8DdQ4k9k.js +798 -0
  774. package/dist/prepare.runtime.js +1 -1
  775. package/dist/presentation-card-DeAf3jYW.js +164 -0
  776. package/dist/preview-warnings-BF7nlTo8.js +618 -0
  777. package/dist/profiles-DUhMLnqX.js +194 -0
  778. package/dist/program-C7f_U7fr.js +131 -0
  779. package/dist/provider-adapters-CWLwE9KS.js +104 -0
  780. package/dist/provider-api-key-auth-CshQbUPZ.js +117 -0
  781. package/dist/provider-api-key-auth.runtime-B64jPCKn.js +14 -0
  782. package/dist/provider-api-key-auth.runtime.js +1 -1
  783. package/dist/provider-auth-D-I3YLSn.js +281 -0
  784. package/dist/provider-auth-api-key-Bub0Rjak.js +5 -0
  785. package/dist/provider-auth-choice-DpNAEScm.js +311 -0
  786. package/dist/provider-auth-choice-helpers-Bof937LW.js +210 -0
  787. package/dist/provider-auth-choice.runtime-B3spikLY.js +18 -0
  788. package/dist/provider-auth-choice.runtime-vVgz7FKq.js +2 -0
  789. package/dist/provider-auth-choice.runtime.js +1 -1
  790. package/dist/provider-auth-guidance-DcCL0Q2U.js +2 -0
  791. package/dist/provider-auth-guidance-rWRMN4Jn.js +34 -0
  792. package/dist/provider-auth-helpers-Cp8L-Xha.js +177 -0
  793. package/dist/provider-auth-login.runtime-BJUzc4iH.js +156 -0
  794. package/dist/provider-auth-login.runtime.js +1 -1
  795. package/dist/provider-auth-runtime-DmcWtzbb.js +186 -0
  796. package/dist/provider-discovery-JyAJi97k.js +95 -0
  797. package/dist/provider-discovery.runtime-D_0WTYr8.js +290 -0
  798. package/dist/provider-discovery.runtime.js +1 -1
  799. package/dist/provider-dispatcher-C8Jt94Xl.js +22 -0
  800. package/dist/provider-dispatcher.runtime.js +1 -1
  801. package/dist/provider-entry-By0ggZuI.js +134 -0
  802. package/dist/provider-hook-runtime-B8AUbQxf.js +255 -0
  803. package/dist/provider-openai-codex-oauth-C9Mmnt7d.js +2 -0
  804. package/dist/provider-openai-codex-oauth-CH5Jg1vk.js +44 -0
  805. package/dist/provider-registration-C1zvaHQP.js +235 -0
  806. package/dist/provider-registry-B9diJyLv.js +31 -0
  807. package/dist/provider-registry-BXSxmPGA.js +61 -0
  808. package/dist/provider-registry-CoE-sxbq.js +61 -0
  809. package/dist/provider-registry-DLth_GdI.js +61 -0
  810. package/dist/provider-registry-J4LRd5Rg.js +36 -0
  811. package/dist/provider-runtime-B4cw16pt.js +3 -0
  812. package/dist/provider-runtime-DNNbfwOK.js +386 -0
  813. package/dist/provider-runtime.runtime-98mAe_ni.js +26 -0
  814. package/dist/provider-runtime.runtime.js +1 -1
  815. package/dist/provider-self-hosted-setup-Dysv2Kwt.js +373 -0
  816. package/dist/provider-stream-BLaC8bqO.js +1084 -0
  817. package/dist/provider-stream-Caa5YOx2.js +313 -0
  818. package/dist/provider-stream-family-CvvfxLyP.js +2 -0
  819. package/dist/provider-usage-CVNosTP3.js +71 -0
  820. package/dist/provider-usage-D2NudXbO.js +4 -0
  821. package/dist/provider-usage.load-DG6R3lkG.js +357 -0
  822. package/dist/provider-web-search-DmgTaxRU.js +58 -0
  823. package/dist/provider-wizard-Cw-5H3tX.js +125 -0
  824. package/dist/providers.runtime-DF0T9lFz.js +240 -0
  825. package/dist/providers.runtime-oM9Vn1wr.js +2 -0
  826. package/dist/providers.runtime.js +1 -1
  827. package/dist/proxy-BxGnVyJu.js +662 -0
  828. package/dist/public-artifacts-BMP9hZfh.js +7 -0
  829. package/dist/pw-ai-CD52qfYo.js +3064 -0
  830. package/dist/qmd-manager-BYbvU4YC.js +2040 -0
  831. package/dist/qr-cli-Btz2ZdO3.js +2 -0
  832. package/dist/qr-cli-eyTRwMm2.js +371 -0
  833. package/dist/qr-image-BCwiO6tL.js +2 -0
  834. package/dist/queue-CJRoTOBi.js +923 -0
  835. package/dist/read-file-ogB-HjbK.js +183 -0
  836. package/dist/register-service-commands-D_gQ3b6_.js +77 -0
  837. package/dist/register.agent-DXQLn-r0.js +152 -0
  838. package/dist/register.configure-FavQPGce.js +16 -0
  839. package/dist/register.crestodian-Cbfmnl6h.js +24 -0
  840. package/dist/register.maintenance-B8xODEMU.js +85 -0
  841. package/dist/register.message-B8PYgZ-j.js +404 -0
  842. package/dist/register.migrate-CieoN8zZ.js +106 -0
  843. package/dist/register.onboard-BqWDIDKH.js +115 -0
  844. package/dist/register.setup-CgeTBW4T.js +40 -0
  845. package/dist/register.status-health-sessions-C99aHa5h.js +293 -0
  846. package/dist/register.subclis-79SvyMFt.js +31 -0
  847. package/dist/register.subclis-CXrO8_TO.js +3 -0
  848. package/dist/register.subclis-core-GoXV1yMG.js +273 -0
  849. package/dist/rem-harness-laL5luQa.js +649 -0
  850. package/dist/repair-sequencing-DGY2mBg6.js +652 -0
  851. package/dist/reply-media-paths.runtime-BeWVPkgy.js +2 -0
  852. package/dist/reply-media-paths.runtime-rzAV_Kee.js +154 -0
  853. package/dist/reply-media-paths.runtime.js +1 -1
  854. package/dist/reply-payloads-D_JHMviC.js +79 -0
  855. package/dist/reply-payloads-dedupe-B9GGGaL-.js +176 -0
  856. package/dist/reply-payloads-dedupe.runtime--C3jHs9y.js +2 -0
  857. package/dist/reply-payloads-dedupe.runtime.js +1 -1
  858. package/dist/reply-timing-tracker-DPjlETUb.js +205 -0
  859. package/dist/reply-turn-admission-DdfIwcMK.js +2056 -0
  860. package/dist/reply.runtime-BC1HT67i.js +2 -0
  861. package/dist/reply.runtime.js +1 -1
  862. package/dist/reset-preserved-selection-Czd80hug.js +45 -0
  863. package/dist/resolve-COJFlAZT.js +106 -0
  864. package/dist/restart-B9GMMIZt.js +121 -0
  865. package/dist/result-fallback-classifier-By0Z6b8r.js +98 -0
  866. package/dist/root-help-Bp0kGaUZ.js +43 -0
  867. package/dist/route-CgG9Z7OI.js +475 -0
  868. package/dist/route-reply-D9_9oRg1.js +174 -0
  869. package/dist/route-reply.runtime-BwNl3h2m.js +2 -0
  870. package/dist/route-reply.runtime.js +1 -1
  871. package/dist/routes-Cz2NHUV4.js +2 -0
  872. package/dist/routes-DMo6Eacc.js +3701 -0
  873. package/dist/run-SFRSThMI.js +1162 -0
  874. package/dist/run-auth-profile.runtime-BxLM8m_2.js +2 -0
  875. package/dist/run-auth-profile.runtime.js +1 -1
  876. package/dist/run-command-Cd5iN7eN.js +2 -0
  877. package/dist/run-command-ah46O06U.js +23 -0
  878. package/dist/run-context-DGCQJldA.js +66 -0
  879. package/dist/run-context.runtime-CSBHDAd5.js +2 -0
  880. package/dist/run-context.runtime.js +1 -1
  881. package/dist/run-delivery.runtime-C9xoiZ3h.js +762 -0
  882. package/dist/run-delivery.runtime.js +1 -1
  883. package/dist/run-embedded.runtime-D8bz5vfV.js +4 -0
  884. package/dist/run-embedded.runtime.js +1 -1
  885. package/dist/run-execution-cli.runtime-BAa8KPn7.js +4 -0
  886. package/dist/run-execution-cli.runtime.js +1 -1
  887. package/dist/run-executor.runtime-CNnemqSa.js +330 -0
  888. package/dist/run-executor.runtime.js +1 -1
  889. package/dist/run-model-catalog.runtime-Dh7EghXr.js +2 -0
  890. package/dist/run-model-catalog.runtime.js +1 -1
  891. package/dist/run-session-state-cMlTFwT_.js +159 -0
  892. package/dist/run-subagent-registry.runtime-BgQU86-E.js +2 -0
  893. package/dist/run-subagent-registry.runtime.js +1 -1
  894. package/dist/runner-B3YXRJOB.js +704 -0
  895. package/dist/runner.entries-DMTKpRDP.js +1485 -0
  896. package/dist/runtime-BHReFHE2.js +2 -0
  897. package/dist/runtime-BiQZ6Usw.js +615 -0
  898. package/dist/runtime-CAeriu2O.js +10 -0
  899. package/dist/runtime-CAnCRCX3.js +224 -0
  900. package/dist/runtime-CV_2NqSY.js +300 -0
  901. package/dist/runtime-CmpnvXo3.js +245 -0
  902. package/dist/runtime-D2fci1Ey.js +2 -0
  903. package/dist/runtime-DAsYmYeA.js +3 -0
  904. package/dist/runtime-DeA45VKG.js +210 -0
  905. package/dist/runtime-DvkZ8tHI.js +436 -0
  906. package/dist/runtime-DxVUR2Xg.js +2 -0
  907. package/dist/runtime-api-B88le0UE.js +12 -0
  908. package/dist/runtime-channel-AubRWvnH.js +2 -0
  909. package/dist/runtime-channel-DdclSuEu.js +148 -0
  910. package/dist/runtime-config-collectors-DukTj2va.js +525 -0
  911. package/dist/runtime-embedded-agent.runtime-BpLweeFv.js +2 -0
  912. package/dist/runtime-embedded-agent.runtime.js +1 -1
  913. package/dist/runtime-internal-CaoUylZw.js +2 -0
  914. package/dist/runtime-llm.runtime-DlpqGc7S.js +307 -0
  915. package/dist/runtime-llm.runtime.js +1 -1
  916. package/dist/runtime-model-auth.runtime-CLAaWzxY.js +46 -0
  917. package/dist/runtime-model-auth.runtime-DxVvqRTd.js +2 -0
  918. package/dist/runtime-model-auth.runtime.js +1 -1
  919. package/dist/runtime-options-TTtN01-I.js +275 -0
  920. package/dist/runtime-plugin-ClqxJSbp.js +92 -0
  921. package/dist/runtime-plugins-Bq01wLXP.js +32 -0
  922. package/dist/runtime-plugins.runtime-cwCvl1TR.js +2 -0
  923. package/dist/runtime-plugins.runtime.js +1 -1
  924. package/dist/runtime-prepare.runtime-Cz_hV_k5.js +81 -0
  925. package/dist/runtime-prepare.runtime.js +1 -1
  926. package/dist/runtime-provider-QCJq90av.js +24 -0
  927. package/dist/runtime-provider-Wllc3jC6.js +2 -0
  928. package/dist/runtime-registry-loader-BM1mQBJr.js +2 -0
  929. package/dist/runtime-registry-loader-DzhYCt4s.js +117 -0
  930. package/dist/runtime-shared-BfqOW-Vb.js +365 -0
  931. package/dist/runtime-web-channel-plugin-BcVPgD14.js +204 -0
  932. package/dist/runtime-web-tools-fallback.runtime.js +1 -1
  933. package/dist/scan-ldbaD8jq.js +573 -0
  934. package/dist/sdk-security-runtime-Bxhq2O1G.js +86 -0
  935. package/dist/sdk-setup-tools-CsQM9pF0.js +8 -0
  936. package/dist/secrets-cli-DbpIf4-z.js +150 -0
  937. package/dist/security-cli-BK4Xpa6h.js +520 -0
  938. package/dist/selection-BXKik6Ps.js +3 -0
  939. package/dist/selection-D4O3gK3Q.js +18365 -0
  940. package/dist/send-DaoGIay5.js +1222 -0
  941. package/dist/send-DzNjJGJX.js +178 -0
  942. package/dist/send-f5w9krNS.js +711 -0
  943. package/dist/send-media-cOciBxcg.js +2072 -0
  944. package/dist/send-result-DMFwBuOl.js +141 -0
  945. package/dist/server-BoC1mxZ-.js +24 -0
  946. package/dist/server-DZnI6w5k.js +72 -0
  947. package/dist/server-aux-handlers-BwRdYdub.js +1347 -0
  948. package/dist/server-chat-Q95f4ywD.js +827 -0
  949. package/dist/server-close.runtime.js +3 -3
  950. package/dist/server-context-CnXNaarB.js +2 -0
  951. package/dist/server-context-DRBebo7Y.js +955 -0
  952. package/dist/server-cron-C0o0ZvqF.js +3173 -0
  953. package/dist/server-cron-CLeBvurR.js +2 -0
  954. package/dist/server-maintenance-CqHfTnFD.js +152 -0
  955. package/dist/server-methods-BmlBQJMD.js +497 -0
  956. package/dist/server-middleware-DJhnR6jl.js +122 -0
  957. package/dist/server-model-catalog-CoSSk_Gy.js +2 -0
  958. package/dist/server-model-catalog-D32oDTQp.js +73 -0
  959. package/dist/server-node-events-DX9a4etQ.js +597 -0
  960. package/dist/server-plugin-bootstrap-Vco-EpxY.js +71 -0
  961. package/dist/server-plugins-WBX2fZRp.js +435 -0
  962. package/dist/server-reload-handlers-DGJLH8bg.js +719 -0
  963. package/dist/server-restart-sentinel-Bvon7f8K.js +700 -0
  964. package/dist/server-runtime-services-BNcH4vhR.js +3 -0
  965. package/dist/server-runtime-services-BjcQG5y7.js +147 -0
  966. package/dist/server-runtime-subscriptions-W39HeyoT.js +67 -0
  967. package/dist/server-session-events-CO73dMU-.js +244 -0
  968. package/dist/server-session-key-D8V67lDk.js +2 -0
  969. package/dist/server-session-key-v-KYSmRS.js +75 -0
  970. package/dist/server-startup-config-u54lUdWN.js +305 -0
  971. package/dist/server-startup-early-Cy5kArJG.js +87 -0
  972. package/dist/server-startup-memory-DvINFAYn.js +72 -0
  973. package/dist/server-startup-plugins-CerpbOSQ.js +127 -0
  974. package/dist/server-startup-post-attach-COUCwhNa.js +793 -0
  975. package/dist/server-ws-runtime-BfznAnbI.js +374 -0
  976. package/dist/server.impl-dQXccj0z.js +2622 -0
  977. package/dist/session-cost-usage-Bs5yIOBH.js +1600 -0
  978. package/dist/session-kill-http-DVleb3RW.js +121 -0
  979. package/dist/session-log-runtime-OG7J4j9m.js +1258 -0
  980. package/dist/session-override-LIWl5a9T.js +134 -0
  981. package/dist/session-reset-model.runtime-BpnTi4sa.js +144 -0
  982. package/dist/session-reset-model.runtime.js +1 -1
  983. package/dist/session-reset-service-HA07zS8L.js +651 -0
  984. package/dist/session-status.runtime-D6_clH8l.js +2 -0
  985. package/dist/session-status.runtime.js +1 -1
  986. package/dist/session-store-Cj4Rh6qc.js +273 -0
  987. package/dist/session-store.runtime-DSCxACdZ.js +4 -0
  988. package/dist/session-store.runtime.js +1 -1
  989. package/dist/session-subagent-reactivation.runtime-CcwaHAxg.js +2 -0
  990. package/dist/session-subagent-reactivation.runtime.js +1 -1
  991. package/dist/session-tab-registry-C-9uI2Wi.js +551 -0
  992. package/dist/session-utils-BRtPESA4.js +1508 -0
  993. package/dist/sessions-Beltl3Ra.js +1917 -0
  994. package/dist/sessions-DR-X-j8D.js +316 -0
  995. package/dist/sessions-cleanup-CR1CFcJb.js +165 -0
  996. package/dist/sessions-history-http-CjyHWYEv.js +432 -0
  997. package/dist/sessions-patch-peSeltuF.js +401 -0
  998. package/dist/sessions-resolve-D9ULr95s.js +180 -0
  999. package/dist/sessions-table-Da6bua9d.js +161 -0
  1000. package/dist/sessions-uKpnhod0.js +12736 -0
  1001. package/dist/sessions.runtime-C1mVNaU3.js +2 -0
  1002. package/dist/sessions.runtime.js +1 -1
  1003. package/dist/set-DVj21EuB.js +31 -0
  1004. package/dist/set-image-JChDCaAP.js +17 -0
  1005. package/dist/setup-5I-zpID3.js +614 -0
  1006. package/dist/setup-CjtY6cli.js +2 -0
  1007. package/dist/setup-onboard-configure-help-fast-path-C5GcSuXb.js +64 -0
  1008. package/dist/setup.finalize-Bf10PNbl.js +586 -0
  1009. package/dist/setup.gateway-config-EH5Rvwzy.js +281 -0
  1010. package/dist/setup.migration-import-CoeV4Kc1.js +200 -0
  1011. package/dist/setup.migration-import-DFFGw4DI.js +2 -0
  1012. package/dist/setup.post-install-migration-DcQmWTE7.js +128 -0
  1013. package/dist/shared-BFSJZ6B3.js +212 -0
  1014. package/dist/shared-CVM-dYkO.js +5 -0
  1015. package/dist/shared-fvgcmCsj.js +71 -0
  1016. package/dist/simple-completion-runtime-C_TXe4M1.js +2 -0
  1017. package/dist/simple-completion-runtime-DREq-fcF.js +206 -0
  1018. package/dist/simple-completion-transport-DtD1fEvJ.js +83 -0
  1019. package/dist/snapshot-urls-B-wkwDI9.js +317 -0
  1020. package/dist/speech-core-KQg6oKcR.js +119 -0
  1021. package/dist/speech-provider-DfyLYitQ.js +171 -0
  1022. package/dist/speech-provider-oDvTumNW.js +227 -0
  1023. package/dist/speech-provider-yL-TQ3Em.js +233 -0
  1024. package/dist/stale-oauth-profile-shadows-CW11VYMM.js +2 -0
  1025. package/dist/stale-oauth-profile-shadows-DFl6Lyf1.js +186 -0
  1026. package/dist/standalone-runtime-registry-loader-BiponY-y.js +59 -0
  1027. package/dist/startup-context-PVXYM-X3.js +314 -0
  1028. package/dist/status-BA_0z83w.js +249 -0
  1029. package/dist/status-Bc7BGlRt.js +2 -0
  1030. package/dist/status-BwPWg9eQ.js +3 -0
  1031. package/dist/status-CLQ66eml.js +4 -0
  1032. package/dist/status-Ci2gChtY.js +466 -0
  1033. package/dist/status-CmtBWJEE.js +2 -0
  1034. package/dist/status-DdnMnPNs.js +73 -0
  1035. package/dist/status-all-BpTvkYrt.js +573 -0
  1036. package/dist/status-json-CizozZCr.js +15 -0
  1037. package/dist/status-json-command-FzKa2t6O.js +84 -0
  1038. package/dist/status-message-BHbnxwmt.js +495 -0
  1039. package/dist/status-message.runtime-Df5WBBAk.js +6 -0
  1040. package/dist/status-message.runtime.js +1 -1
  1041. package/dist/status-queue.runtime-CXnZV4Bj.js +2 -0
  1042. package/dist/status-queue.runtime.js +1 -1
  1043. package/dist/status-runtime-shared-D3Hz8WZ_.js +289 -0
  1044. package/dist/status-subagents.runtime-PoDdwwaw.js +32 -0
  1045. package/dist/status-subagents.runtime.js +1 -1
  1046. package/dist/status-text-DNxXSCuI.js +301 -0
  1047. package/dist/status.command-C_e9GcMg.js +2 -0
  1048. package/dist/status.command-DjVKDmt_.js +425 -0
  1049. package/dist/status.command.text-runtime-BeHlqL8b.js +15 -0
  1050. package/dist/status.runtime-h--fx9HY.js +2 -0
  1051. package/dist/status.scan-WyR8TeJz.js +72 -0
  1052. package/dist/status.scan-overview-CMzUAQMQ.js +460 -0
  1053. package/dist/status.scan.deps.runtime-1JTrdyHk.js +19 -0
  1054. package/dist/status.scan.deps.runtime.js +1 -1
  1055. package/dist/status.scan.fast-json-D2jw1wKO.js +163 -0
  1056. package/dist/status.scan.fast-json-DbN1KxJT.js +2 -0
  1057. package/dist/status.summary-6ZijZM1g.js +2 -0
  1058. package/dist/status.summary-CiCsChO-.js +276 -0
  1059. package/dist/store-CdBPITcg.js +2302 -0
  1060. package/dist/store-D0l2NCdn.js +3 -0
  1061. package/dist/stored-model-override-HEgnFh6b.js +79 -0
  1062. package/dist/subagent-announce-BUv_kA1W.js +353 -0
  1063. package/dist/subagent-announce-delivery-Ci2Y_p--.js +1369 -0
  1064. package/dist/subagent-control-BM3vNgsQ.js +492 -0
  1065. package/dist/subagent-control.runtime-Df3pVQL9.js +3 -0
  1066. package/dist/subagent-control.runtime.js +1 -1
  1067. package/dist/subagent-hooks-CN2fLez2.js +2 -0
  1068. package/dist/subagent-hooks-CeOmTJBf.js +230 -0
  1069. package/dist/subagent-hooks-api-Cfe4DAT9.js +23 -0
  1070. package/dist/subagent-registry-B9RPAXUs.js +2627 -0
  1071. package/dist/subagent-registry-C7tedtVB.js +3 -0
  1072. package/dist/subagent-registry.runtime.js +2 -2
  1073. package/dist/subagent-session-cleanup-y0ijZ-LQ.js +390 -0
  1074. package/dist/system-DVtrOGbV.js +111 -0
  1075. package/dist/system-prompt-config-BVmrcmmr.js +918 -0
  1076. package/dist/talk-CrdgqTCl.js +2454 -0
  1077. package/dist/target-id-CrUyi-Uq.js +107 -0
  1078. package/dist/targets-KZ2ezPwx.js +267 -0
  1079. package/dist/targets.runtime-iZ8KdQ1C.js +2 -0
  1080. package/dist/targets.runtime.js +1 -1
  1081. package/dist/task-executor-893pMqzn.js +349 -0
  1082. package/dist/task-owner-access-DC7MKz3n.js +74 -0
  1083. package/dist/task-registry-control.runtime.js +2 -2
  1084. package/dist/task-registry-delivery-runtime-YGMOyqP5.js +2 -0
  1085. package/dist/task-registry-uaYJfgXF.js +2362 -0
  1086. package/dist/task-registry.maintenance-Dx0m2NYh.js +2 -0
  1087. package/dist/task-registry.maintenance-gApg-XOt.js +764 -0
  1088. package/dist/task-status-access-CFhD_ieY.js +18 -0
  1089. package/dist/tasks-B_Qoz38D.js +153 -0
  1090. package/dist/tasks-DtV85zJT.js +548 -0
  1091. package/dist/tasks-audit-system-Con3yYnm.js +210 -0
  1092. package/dist/tasks-json-BM3pauZl.js +73 -0
  1093. package/dist/tavily-web-search-provider.runtime-Cmyyc5kX.js +112 -0
  1094. package/dist/tavily-web-search-provider.runtime.js +1 -1
  1095. package/dist/text-report-CKxmVmt5.js +695 -0
  1096. package/dist/text-transforms.runtime-DVwVsBRS.js +113 -0
  1097. package/dist/text-transforms.runtime.js +1 -1
  1098. package/dist/thread-bindings-B6UEVp9q.js +228 -0
  1099. package/dist/tool-KOZc7TIF.js +143 -0
  1100. package/dist/tool-dispatch-Ca4z2GEr.js +155 -0
  1101. package/dist/tool-images-CzDwHeDR.js +247 -0
  1102. package/dist/tool-plugin-BvQBJ2gU.js +93 -0
  1103. package/dist/tool-resolution-Ddxl6tjh.js +153 -0
  1104. package/dist/tool-result-truncation-BSKuIhd5.js +498 -0
  1105. package/dist/tool-schema-nB27q-vb.js +40 -0
  1106. package/dist/tool-schema-projection-COrMarLR.js +215 -0
  1107. package/dist/tool-split-BjPHBFrv.js +323 -0
  1108. package/dist/tools-CV40BWkc.js +901 -0
  1109. package/dist/tools-catalog-5stC7W2V.js +156 -0
  1110. package/dist/tools-effective-BVjqz2FV.js +442 -0
  1111. package/dist/tools-effective-inventory-esPY5jRB.js +379 -0
  1112. package/dist/tools-invoke-Czk_NM9G.js +51 -0
  1113. package/dist/tools-invoke-http-D7PbsODz.js +68 -0
  1114. package/dist/tools-invoke-shared-CzrEn0Dm.js +200 -0
  1115. package/dist/tools-rSjgf61B.js +579 -0
  1116. package/dist/tools.runtime-DiChCSGI.js +5 -0
  1117. package/dist/tools.runtime.js +1 -1
  1118. package/dist/transcript-rewrite-4IQefjvK.js +688 -0
  1119. package/dist/transcripts-tool-BXTS8tE5.js +2 -0
  1120. package/dist/transcripts-tool-CeWGgz5k.js +656 -0
  1121. package/dist/tts-BS8EeM8p.js +2 -0
  1122. package/dist/tts-BlTZjsaE.js +194 -0
  1123. package/dist/tts-runtime-BfRdJDyY.js +1337 -0
  1124. package/dist/tts-vRSvSw-t.js +3 -0
  1125. package/dist/tts.runtime-ChBnVkNt.js +3 -0
  1126. package/dist/tts.runtime-CmVCUbzq.js +2 -0
  1127. package/dist/tts.runtime.js +1 -1
  1128. package/dist/tui-BoQVBgWB.js +4860 -0
  1129. package/dist/tui-DBYK9BeQ.js +2 -0
  1130. package/dist/tui-backend-X0NI7rAv.js +256 -0
  1131. package/dist/tui-cli-BpUtjV38.js +40 -0
  1132. package/dist/typing-policy-CBwyAQh4.js +199 -0
  1133. package/dist/usage-Bl-tgGx-.js +623 -0
  1134. package/dist/usage-Cj_ektBl.js +1113 -0
  1135. package/dist/usage-format-DWO9ckX3.js +394 -0
  1136. package/dist/usage-format-DnCIXsqG.js +2 -0
  1137. package/dist/video-generation-provider-B7ib4AeI.js +297 -0
  1138. package/dist/video-generation-provider-CXQ6fqJx.js +64 -0
  1139. package/dist/video-generation-provider-DXjl05T6.js +325 -0
  1140. package/dist/video-generation-provider-Db8h71jA.js +77 -0
  1141. package/dist/web-fetch/runtime.js +1 -1
  1142. package/dist/web-fetch-providers.runtime-DhPkYjgB.js +41 -0
  1143. package/dist/web-fetch-providers.runtime.js +1 -1
  1144. package/dist/web-guarded-fetch-BdsVyvDS.js +58 -0
  1145. package/dist/web-guarded-fetch-CJR3JCwT.js +2 -0
  1146. package/dist/web-media-BzzQJAwk.js +4 -0
  1147. package/dist/web-media-DViZjNBa.js +2 -0
  1148. package/dist/web-media-inHawfBU.js +651 -0
  1149. package/dist/web-provider-runtime-shared-Cc08Lt9p.js +142 -0
  1150. package/dist/web-search-provider-common-CtbtmUL-.js +252 -0
  1151. package/dist/web-search-providers.runtime-B7x_cRVn.js +41 -0
  1152. package/dist/web-search-providers.runtime.js +1 -1
  1153. package/dist/zod-schema.core-Cuz0lz6m.d.ts +166 -0
  1154. package/package.json +1 -1
  1155. package/dist/abort-CR0u3VsG.js +0 -277
  1156. package/dist/abort.runtime-CXUxanGg.js +0 -2
  1157. package/dist/accounts-BxBaquAf.js +0 -423
  1158. package/dist/accounts-vQjpoqEe.js +0 -2
  1159. package/dist/acp-spawn-2elSoS0E.js +0 -1286
  1160. package/dist/acp-spawn-DtKOHNO1.js +0 -2
  1161. package/dist/acp-stateful-target-driver-BqeA5j0h.js +0 -89
  1162. package/dist/action-info-B8NotHFw.js +0 -75
  1163. package/dist/active-runtime-registry-BO9mpPuB.js +0 -62
  1164. package/dist/active-tool-schema-warnings-C8vGj5FX.js +0 -105
  1165. package/dist/active-tool-schema-warnings-CVeFJuWI.js +0 -2
  1166. package/dist/agent-BgEaDMdp.js +0 -1825
  1167. package/dist/agent-_V5GbziF.js +0 -2
  1168. package/dist/agent-bundle-lsp-runtime-0jBcDEHh.js +0 -389
  1169. package/dist/agent-bundle-lsp-runtime-CQ6dZLs_.js +0 -2
  1170. package/dist/agent-bundle-mcp-materialize-Cu6JqMzC.js +0 -124
  1171. package/dist/agent-bundle-mcp-tools-BGL827cn.js +0 -3
  1172. package/dist/agent-command-CMJdGr16.js +0 -1435
  1173. package/dist/agent-delivery-DMu1MOeq.js +0 -117
  1174. package/dist/agent-harness-runtime-BKSW2E1O.js +0 -207
  1175. package/dist/agent-model-discovery-Cu4YL31r.js +0 -3
  1176. package/dist/agent-model-discovery-DdmVtkZo.js +0 -238
  1177. package/dist/agent-runner-utils-DXNDhwkI.js +0 -267
  1178. package/dist/agent-runner.runtime-Cym4Odfd.js +0 -3784
  1179. package/dist/agent-runtime-BkbhevY3.js +0 -199
  1180. package/dist/agent-runtime-label-DNP06p76.js +0 -30
  1181. package/dist/agent-runtime-metadata-JaTKc7mA.js +0 -53
  1182. package/dist/agent-tool-result-middleware-loader-FbZE0Qpk.js +0 -55
  1183. package/dist/agent-tools-Nwh8BlKX.js +0 -2506
  1184. package/dist/agent-tools.before-tool-call-BwY-FYFl.js +0 -1274
  1185. package/dist/agent-tools.before-tool-call-DwUmYhE3.js +0 -2
  1186. package/dist/agent-u5NDWrw9.js +0 -3
  1187. package/dist/agent-via-gateway-DMtOMwZa.js +0 -486
  1188. package/dist/agent-wait-dedupe-CLuKbI_7.js +0 -180
  1189. package/dist/agents-CiW7UEuB.js +0 -632
  1190. package/dist/agents.command-shared-CXGSQscb.js +0 -16
  1191. package/dist/agents.commands.add-BYBrZDXD.js +0 -304
  1192. package/dist/agents.commands.bind-nfg3AlVc.js +0 -265
  1193. package/dist/agents.commands.delete-pRj6vIrn.js +0 -128
  1194. package/dist/agents.commands.identity-Ci2PnDDl.js +0 -143
  1195. package/dist/agents.commands.list-Crj3BmqB.js +0 -235
  1196. package/dist/aliases-BFspFx3-.js +0 -97
  1197. package/dist/api-BiXhdPle.js +0 -3
  1198. package/dist/api-Cptkjys5.js +0 -6
  1199. package/dist/api-D3vT4ZVi.js +0 -2
  1200. package/dist/api-key-rotation-CQgW8LEx.js +0 -167
  1201. package/dist/app-registration-YW276fZC.js +0 -194
  1202. package/dist/apply-BRxKrOiK.js +0 -510
  1203. package/dist/apply-D0fWCa-U.js +0 -2
  1204. package/dist/apply-DIR8y0ZA.js +0 -2
  1205. package/dist/apply-DNUIV0Lt.js +0 -416
  1206. package/dist/apply-Dux9jI7f.js +0 -544
  1207. package/dist/approval-native-helpers-BMT-5X47.js +0 -398
  1208. package/dist/artifacts-CTrtIv9T.js +0 -368
  1209. package/dist/assistant-ClfI8Kho.js +0 -291
  1210. package/dist/attachment-normalize-DAW86mZY.js +0 -213
  1211. package/dist/attempt-execution-DTi2UfET.js +0 -584
  1212. package/dist/attempt-execution.helpers-DrX0QToi.js +0 -969
  1213. package/dist/attempt-execution.runtime-BCmAxwGy.js +0 -3
  1214. package/dist/attempt.prompt-helpers-BE6kGRtT.js +0 -543
  1215. package/dist/attempt.tool-run-context-J9O2yjbV.js +0 -1240
  1216. package/dist/audio-preflight.runtime-D3GXVYBI.js +0 -7
  1217. package/dist/audit-5T20D-xm.js +0 -1108
  1218. package/dist/audit-CWuV5GlP.js +0 -477
  1219. package/dist/audit.nondeep.runtime-DeYwRDYj.js +0 -1416
  1220. package/dist/audit.runtime-rUlvK4Rb.js +0 -7
  1221. package/dist/auth-DunUSatn.js +0 -567
  1222. package/dist/auth-choice--eBzca8Y.js +0 -3
  1223. package/dist/auth-choice-DJ9jsFUq.js +0 -400
  1224. package/dist/auth-choice-_pLkIdVh.js +0 -110
  1225. package/dist/auth-choice.apply.api-providers-CALcopRP.js +0 -2
  1226. package/dist/auth-choice.apply.api-providers-Dzzm1snk.js +0 -34
  1227. package/dist/auth-choice.plugin-providers.runtime-BHKTeZZc.js +0 -11
  1228. package/dist/auth-health-Cs4OjiF2.js +0 -219
  1229. package/dist/auth-list-bwJ4QDs0.js +0 -115
  1230. package/dist/auth-order-BoHN3Dc_.js +0 -105
  1231. package/dist/auth-profiles-BOLncVgy.js +0 -73
  1232. package/dist/auth-profiles-BiQRkULt.js +0 -14
  1233. package/dist/backend-config-B5yga5ay.js +0 -259
  1234. package/dist/bash-tools-BWvldguc.js +0 -3
  1235. package/dist/bash-tools-DEAAO5np.js +0 -3497
  1236. package/dist/binding-routing-BbtHmU_l.js +0 -113
  1237. package/dist/binding-targets-DSNv3-QA.js +0 -121
  1238. package/dist/bootstrap-files-DD8V2dLe.js +0 -202
  1239. package/dist/bootstrap-files-_6u1uJW2.js +0 -3
  1240. package/dist/bridge-server-v1-XPnAZ.js +0 -113
  1241. package/dist/browser-cli-CnpuO4KR.js +0 -230
  1242. package/dist/browser-cli-DPbIn8SK.js +0 -2
  1243. package/dist/browser-cli-actions-input-DoGR6LI-.js +0 -522
  1244. package/dist/browser-cli-actions-observe-CYMpgmtF.js +0 -81
  1245. package/dist/browser-cli-debug-ChJjSq-h.js +0 -137
  1246. package/dist/browser-cli-inspect-Bbci-WPG.js +0 -117
  1247. package/dist/browser-cli-manage-Bnscjb7b.js +0 -446
  1248. package/dist/browser-cli-resize-D1MJdvZI.js +0 -32
  1249. package/dist/browser-cli-shared-BCQwqz51.js +0 -69
  1250. package/dist/browser-cli-state-BWkPsvUg.js +0 -371
  1251. package/dist/browser-control-auth-CEP_ExeC.js +0 -2
  1252. package/dist/browser-profiles-SvnqnHVN.js +0 -2
  1253. package/dist/browser-runtime-0mRxjFpp.js +0 -389
  1254. package/dist/browser-tool.schema--CLR3nDv.js +0 -132
  1255. package/dist/btw-command-DV6HfrRV.js +0 -18
  1256. package/dist/build-DiRmljCi.js +0 -261
  1257. package/dist/bundled-channel-config-schema-Bte--ZlY.d.ts +0 -3168
  1258. package/dist/capability-cli-ATfwTYFe.js +0 -1809
  1259. package/dist/capability-provider-runtime-l3nnLGvn.js +0 -346
  1260. package/dist/cdp.helpers-IIuc0KGS.js +0 -637
  1261. package/dist/channel-CzTD2ouI.js +0 -2309
  1262. package/dist/channel-actions-B5Yk5Axf.js +0 -46
  1263. package/dist/channel-bootstrap.runtime-C9F-Pq1o.js +0 -38
  1264. package/dist/channel-bootstrap.runtime-TPyY5Ngv.js +0 -2
  1265. package/dist/channel-core-XMZJ-ZGF.js +0 -5
  1266. package/dist/channel-inbound-DvqkKmiH.js +0 -121
  1267. package/dist/channel-message-CnJ4vUyt.js +0 -12
  1268. package/dist/channel-outbound-BhefGAqY.js +0 -436
  1269. package/dist/channel-plugin-resolution-BiaJ8aRa.js +0 -2
  1270. package/dist/channel-plugin-resolution-D_CxkMVc.js +0 -135
  1271. package/dist/channel-resolution-DzI28gIM.js +0 -46
  1272. package/dist/channel-selection-CLFO4-eQ.js +0 -171
  1273. package/dist/channel-selection.runtime-Beb2-bMH.js +0 -2
  1274. package/dist/channel.runtime-By5T5eGw.js +0 -697
  1275. package/dist/channels-BrRY9Mag.js +0 -1004
  1276. package/dist/channels-cli-CF--e2RU.js +0 -331
  1277. package/dist/chat-BTMPilpx.js +0 -2940
  1278. package/dist/chat-DnC7XCWK.js +0 -3
  1279. package/dist/chrome-C3_dN9jE.js +0 -1517
  1280. package/dist/chrome-mcp-5jjDHIgn.js +0 -864
  1281. package/dist/chrome-mcp-DFAa-WzK.js +0 -2
  1282. package/dist/claude-live-session-BUPeOzLE.js +0 -1338
  1283. package/dist/claude-live-session-Bprgmr1-.js +0 -2
  1284. package/dist/clawbot-cli-5UVkLT1Y.js +0 -9
  1285. package/dist/cli-6a6sMEUB.js +0 -2
  1286. package/dist/cli-COCN9B5e.js +0 -2
  1287. package/dist/cli-CpI4dBXy.js +0 -141
  1288. package/dist/cli-YLx-ekdH.js +0 -293
  1289. package/dist/cli-backends.runtime-CsBjr7ag.js +0 -7
  1290. package/dist/cli-compaction-Bh0oMwUa.js +0 -363
  1291. package/dist/cli-registry-loader-DDbaAJgY.js +0 -2
  1292. package/dist/cli-registry-loader-xc2Ah8S4.js +0 -193
  1293. package/dist/cli-runner-BfSrIn-9.js +0 -597
  1294. package/dist/cli-runner-D_FAjNbR.js +0 -2
  1295. package/dist/cli-runner.runtime-BJetQDu1.js +0 -3
  1296. package/dist/cli-runner.runtime-BKJQkc7C.js +0 -4
  1297. package/dist/cli-session-Cy3IeH0g.js +0 -119
  1298. package/dist/cli.runtime-BpOz0s3N.js +0 -1276
  1299. package/dist/codex-native-web-search-BDtKRV3F.js +0 -4
  1300. package/dist/codex-native-web-search-C0TrfoMX.js +0 -20
  1301. package/dist/codex-native-web-search-core-CzlK1GfN.js +0 -106
  1302. package/dist/command-auth-CFnvdYX2.js +0 -135
  1303. package/dist/command-config-resolution-B_86rG8v.js +0 -2
  1304. package/dist/command-config-resolution-BbadcA2M.js +0 -25
  1305. package/dist/command-config-resolution.runtime-B_86rG8v.js +0 -2
  1306. package/dist/command-execution-startup-Rrwwdg_5.js +0 -90
  1307. package/dist/command-primitives-runtime-C9bTt5IV.js +0 -3
  1308. package/dist/command-registry-CbpdQKmu.js +0 -9
  1309. package/dist/command-registry-Dw-XC_Zk.js +0 -4
  1310. package/dist/command-registry-core-rvEDki6p.js +0 -114
  1311. package/dist/command-secret-gateway-BX6BIiFn.js +0 -589
  1312. package/dist/command-secret-targets-DCzlTkb5.js +0 -2
  1313. package/dist/command-status-builders-DIsZN9aY.js +0 -147
  1314. package/dist/command-status.runtime-C2x4yMRd.js +0 -90
  1315. package/dist/commands-FYCxWqIx.js +0 -161
  1316. package/dist/commands-compact.runtime-BTMQfx1k.js +0 -10
  1317. package/dist/commands-core.runtime-CuNLz2wm.js +0 -2
  1318. package/dist/commands-handlers.runtime-DyNuPOmY.js +0 -6327
  1319. package/dist/commands-models-s7BRmLQh.js +0 -448
  1320. package/dist/commands-registry-BxEq-3UJ.js +0 -195
  1321. package/dist/commands-registry.runtime-CbXW33S_.js +0 -4
  1322. package/dist/commands-status-BRJMba4h.js +0 -16
  1323. package/dist/commands-status-DCXEwlSF.js +0 -3
  1324. package/dist/commands-status.runtime-DCXEwlSF.js +0 -3
  1325. package/dist/commands-subagents-control.runtime-CduLQJFD.js +0 -2
  1326. package/dist/commands-system-prompt-B3LD8CDs.js +0 -161
  1327. package/dist/commands-system-prompt-DPsXTqOQ.js +0 -2
  1328. package/dist/commands.runtime-3sVz8Qgo.js +0 -175
  1329. package/dist/common-CZvBLb3w.js +0 -286
  1330. package/dist/compact-DxU_9XEc.js +0 -1165
  1331. package/dist/compact.runtime-CqQTypVl.js +0 -12
  1332. package/dist/compaction-planning-DArTi9SN.js +0 -202
  1333. package/dist/completion-cli-CiKl5HhI.js +0 -393
  1334. package/dist/config--yllOaSC.js +0 -374
  1335. package/dist/config-Yt5UcD91.js +0 -610
  1336. package/dist/config-cli-BeXS3R6k.js +0 -1703
  1337. package/dist/config-mutation-cQeWhUqy.js +0 -5
  1338. package/dist/config-mutations-Cg04LH_S.js +0 -161
  1339. package/dist/config-utils-Dhq_UKMC.js +0 -141
  1340. package/dist/config-validation-BANohTKD.js +0 -33
  1341. package/dist/configure-CWxhlx9G.js +0 -771
  1342. package/dist/configure-Jejkc6dn.js +0 -3
  1343. package/dist/configure.commands-BYy1bz8G.js +0 -2
  1344. package/dist/configure.commands-C3hDvZse.js +0 -1253
  1345. package/dist/context-DptQ59DZ.js +0 -248
  1346. package/dist/context-_ZshNBhD.js +0 -2
  1347. package/dist/context-engine-host-compat-C_eflvRw.js +0 -2
  1348. package/dist/context-engine-host-compat-s15Pu845.js +0 -280
  1349. package/dist/context-engine-lifecycle-COHFLnj4.js +0 -627
  1350. package/dist/control-auth-CQJpLoIb.js +0 -114
  1351. package/dist/control-service-BFSgA0Py.js +0 -40
  1352. package/dist/control-service-D7GZv-GS.js +0 -3
  1353. package/dist/control-ui/assets/activity-CCu43qU8.js +0 -124
  1354. package/dist/control-ui/assets/agents-DCvsB0yO.js +0 -1030
  1355. package/dist/control-ui/assets/channels-CpM2j5xT.js +0 -120
  1356. package/dist/control-ui/assets/cron-CLXNfwYa.js +0 -1016
  1357. package/dist/control-ui/assets/debug-BcJ34lrC.js +0 -97
  1358. package/dist/control-ui/assets/index-CuBn2YpX.js +0 -7214
  1359. package/dist/control-ui/assets/instances-Bu6NM_Hs.js +0 -57
  1360. package/dist/control-ui/assets/nodes-Bd1WzVLK.js +0 -444
  1361. package/dist/control-ui/assets/sessions-C2r8pbt7.js +0 -425
  1362. package/dist/control-ui/assets/skills-DIjn93ee.js +0 -362
  1363. package/dist/control-ui/assets/workboard-CHb0if1l.js +0 -402
  1364. package/dist/control-ui-ChfTPXZo.js +0 -750
  1365. package/dist/conversation-label-generator-CTfnInQF.js +0 -72
  1366. package/dist/conversation-runtime-B7oAN9Tq.js +0 -31
  1367. package/dist/core-api-CBD0dvTQ.js +0 -5
  1368. package/dist/core-api-ClCm_yM8.js +0 -2
  1369. package/dist/core-wuoxL08a.js +0 -284
  1370. package/dist/crestodian--iYeGB8u.js +0 -55
  1371. package/dist/cron-D2SzQyqo.js +0 -453
  1372. package/dist/daemon-install-B6CAkU3V.js +0 -66
  1373. package/dist/daemon-install-auth-profiles-store.runtime-Cpt5LSD6.js +0 -2
  1374. package/dist/dashboard-ChYOQjM2.js +0 -263
  1375. package/dist/defaults-CCopehWw.js +0 -130
  1376. package/dist/defaults-H4kBp17N.js +0 -3
  1377. package/dist/defaults.constants-CjB9HP6f.js +0 -76
  1378. package/dist/deliver-BzPhWO_F.js +0 -3
  1379. package/dist/deliver-DGyKH3Qi.js +0 -1399
  1380. package/dist/deliver-runtime-Ca2kcQoZ.js +0 -2
  1381. package/dist/delivery-outbound.runtime-D7ycPxY-.js +0 -7
  1382. package/dist/delivery-queue-CnLv30ko.js +0 -863
  1383. package/dist/delivery-queue-CuaDjNMh.js +0 -2
  1384. package/dist/delivery-queue-runtime-DO2vqOIJ.js +0 -16
  1385. package/dist/delivery-target.runtime-QcBVk_j8.js +0 -45
  1386. package/dist/delivery.runtime-L09v4tys.js +0 -470
  1387. package/dist/detached-task-runtime-BqU7YXYT.js +0 -86
  1388. package/dist/diagnostics-T-Hk_Qzi.js +0 -168
  1389. package/dist/dialogue-C0VnTMMn.js +0 -37
  1390. package/dist/direct-dm-BWn67tDD.js +0 -81
  1391. package/dist/directive-handling.defaults-DO6Snm4_.js +0 -22
  1392. package/dist/directive-handling.fast-lane-BemYRfPn.js +0 -70
  1393. package/dist/directive-handling.impl-BMVh1pMh.js +0 -823
  1394. package/dist/directive-handling.impl-vr4MsYbt.js +0 -2
  1395. package/dist/directive-handling.model-selection-DegP9exp.js +0 -122
  1396. package/dist/directive-handling.persist.runtime-BUdU6_zm.js +0 -274
  1397. package/dist/directives-1xk_ZcMf.js +0 -319
  1398. package/dist/directory-cli-D83WEjEG.js +0 -239
  1399. package/dist/dispatch-Ck2tvRYH.js +0 -2057
  1400. package/dist/dispatch-acp-GdaHNdvf.js +0 -1102
  1401. package/dist/dispatch-acp-manager.runtime-BGSrJqrW.js +0 -3
  1402. package/dist/dispatch-acp-media.runtime-DQ8dYQh8.js +0 -4
  1403. package/dist/dispatch-acp-transcript.runtime-CsJZGhnu.js +0 -40
  1404. package/dist/dispatch-acp-tts.runtime-Bo-QxKgx.js +0 -3
  1405. package/dist/dispatch-acp.runtime-C_u7sGcQ.js +0 -18
  1406. package/dist/dispatcher-GtuYO6Ni.js +0 -106
  1407. package/dist/doctor-B2qP9g8d.js +0 -760
  1408. package/dist/doctor-D9wCez5t.js +0 -6
  1409. package/dist/doctor-auth-XnseqtS7.js +0 -216
  1410. package/dist/doctor-auth-flat-profiles-B6cL-TiJ.js +0 -516
  1411. package/dist/doctor-auth-flat-profiles-Birb7qIk.js +0 -2
  1412. package/dist/doctor-auth-legacy-oauth-CXO3OtyG.js +0 -48
  1413. package/dist/doctor-auth-oauth-sidecar-BSgQPbcS.js +0 -177
  1414. package/dist/doctor-auth-oauth-sidecar-CzzyNwxc.js +0 -2
  1415. package/dist/doctor-bootstrap-size-BlVcO5D6.js +0 -57
  1416. package/dist/doctor-claude-cli-_MTVnCQ-.js +0 -150
  1417. package/dist/doctor-config-flow-0kxzjUjK.js +0 -1819
  1418. package/dist/doctor-core-checks-C_g9REOd.js +0 -666
  1419. package/dist/doctor-core-checks-CahzmM1L.js +0 -2
  1420. package/dist/doctor-core-checks.runtime-Bi_oTiTZ.js +0 -278
  1421. package/dist/doctor-gateway-daemon-flow-UAIWsI9w.js +0 -349
  1422. package/dist/doctor-gateway-services-BiMEGiw_.js +0 -465
  1423. package/dist/doctor-health-C69GVfMl.js +0 -65
  1424. package/dist/doctor-health-contributions-Bz19QhI4.js +0 -874
  1425. package/dist/doctor-lint-BVW4E6Qf.js +0 -95
  1426. package/dist/doctor-memory-search-D2PWzDCY.js +0 -407
  1427. package/dist/doctor-state-integrity-DuJIszQj.js +0 -1257
  1428. package/dist/doctor-tool-result-cap-advice-Dpn4zNH3.js +0 -27
  1429. package/dist/doctor-workspace-status-nW9TcIWi.js +0 -76
  1430. package/dist/dreaming-CcOWzGN5.js +0 -523
  1431. package/dist/dreaming-command-sxm3FQGb.js +0 -101
  1432. package/dist/dreaming-narrative-BSRwiUPL.js +0 -2
  1433. package/dist/dreaming-narrative-BskwmYdC.js +0 -721
  1434. package/dist/dreaming-phases-BuHjGyPw.js +0 -2
  1435. package/dist/dreaming-phases-ChVT8Ovk.js +0 -1162
  1436. package/dist/drive-C_u5W4ln.js +0 -899
  1437. package/dist/echo-transcript-tnZWH4EO.js +0 -52
  1438. package/dist/effective-tool-policy-CeHdL2D7.js +0 -89
  1439. package/dist/embedded-agent-CGULn3lb.js +0 -4
  1440. package/dist/embedded-agent-DZTa1YiK.js +0 -4074
  1441. package/dist/embedded-agent-helpers-B65K9o55.js +0 -6
  1442. package/dist/embedded-agent-helpers-BPXCvWBb.js +0 -1037
  1443. package/dist/embedded-agent.runtime-TfBgXcUV.js +0 -4
  1444. package/dist/embedded-backend-BAaFwayA.js +0 -744
  1445. package/dist/embedded-gateway-stub.runtime-CNyrjvgT.js +0 -12
  1446. package/dist/embedding-provider-runtime-EnkHdROJ.js +0 -86
  1447. package/dist/embedding-providers-CDkDb0kv.js +0 -2
  1448. package/dist/embeddings-http-ClIu4_mP.js +0 -222
  1449. package/dist/engine-qmd-DZRiT9i4.js +0 -708
  1450. package/dist/engine-storage-BEqlN8TR.js +0 -203
  1451. package/dist/errors-Co8auIlv.js +0 -2
  1452. package/dist/exec-approval-forwarder.runtime-C7QvfWQ6.js +0 -4
  1453. package/dist/exec-approval-session-target-ChuH1nXL.js +0 -177
  1454. package/dist/exec-auto-reviewer-Bm7380HF.js +0 -2
  1455. package/dist/exec-auto-reviewer-BrrdGleK.js +0 -241
  1456. package/dist/execute.runtime-B-8jUqDB.js +0 -579
  1457. package/dist/external-cli-auth-selection-0BxmRUps.js +0 -113
  1458. package/dist/extra-params-BgyvpEpv.js +0 -615
  1459. package/dist/fallback-notice-state-BXk_kRWM.js +0 -15
  1460. package/dist/fallbacks-CPdVRP81.js +0 -31
  1461. package/dist/fallbacks-shared-CSGf1oaf.js +0 -116
  1462. package/dist/fengming-runtime-NUA51sEw.js +0 -33
  1463. package/dist/fengming-runtime-config-CIZ-SHPt.js +0 -2
  1464. package/dist/fengming-runtime-memory-CIZ-SHPt.js +0 -2
  1465. package/dist/fengming-runtime-session-CIZ-SHPt.js +0 -2
  1466. package/dist/fengming-tools-MvRSt0JA.js +0 -12221
  1467. package/dist/flows-BocRit8D.js +0 -189
  1468. package/dist/fs-utils-DSXeBcjj.js +0 -9
  1469. package/dist/gateway-BCrUxrVw.js +0 -133
  1470. package/dist/gateway-cli-B8bXBd_L.js +0 -443
  1471. package/dist/gateway-install-token-pngTMc-f.js +0 -136
  1472. package/dist/gateway-method-runtime-ueZTz7WH.js +0 -21
  1473. package/dist/gateway-runtime-DbsoThML.js +0 -23
  1474. package/dist/get-reply-DUuaxcBz.js +0 -5198
  1475. package/dist/get-reply-from-config.runtime-B4Dgs3Hg.js +0 -2
  1476. package/dist/github-copilot-token-7AfRRF7J.js +0 -2
  1477. package/dist/health-7Yq5zpoZ.js +0 -3
  1478. package/dist/health-DlZqxm2f.js +0 -621
  1479. package/dist/health-DxesUuur.js +0 -111
  1480. package/dist/health-state-BMG8kOby.js +0 -106
  1481. package/dist/heartbeat-runner-Bq7A_Cjm.js +0 -5
  1482. package/dist/heartbeat-runner-DVwbVyft.js +0 -1930
  1483. package/dist/heartbeat-runner.runtime-DQ2NPXMD.js +0 -3
  1484. package/dist/helpers-PCu2RivJ.js +0 -406
  1485. package/dist/hook-helpers-DLEnCRO7.js +0 -44
  1486. package/dist/hooks-Bv-otcl7.js +0 -536
  1487. package/dist/hooks-cli-C5ve0nzF.js +0 -465
  1488. package/dist/http-endpoint-helpers-w2SagsQz.js +0 -37
  1489. package/dist/http-utils-CVvn0ZA-.js +0 -98
  1490. package/dist/image-BeixBis4.js +0 -385
  1491. package/dist/image-fallbacks-CPbmIMn9.js +0 -31
  1492. package/dist/image-generation-core.auth.runtime-Co38iRxQ.js +0 -2
  1493. package/dist/image-generation-provider-BA4Ar91S.js +0 -152
  1494. package/dist/image-runtime-7ZsfioS1.js +0 -9
  1495. package/dist/image-tool.helpers-upjA3ksB.js +0 -150
  1496. package/dist/images-ChLi1Uog.js +0 -2
  1497. package/dist/images-nB0XAnTa.js +0 -416
  1498. package/dist/inbound-reply-dispatch-DglobJ8j.js +0 -2
  1499. package/dist/inbound-reply-dispatch-QKOgNx-m.js +0 -147
  1500. package/dist/index-AZzJCgph.d.ts +0 -1497
  1501. package/dist/infra-runtime-CGD3RE_2.js +0 -32
  1502. package/dist/init-poVZDCAM.js +0 -59
  1503. package/dist/install-Dn9oPGmU.js +0 -262
  1504. package/dist/install.runtime-D5sllsjl.js +0 -2
  1505. package/dist/internal-CnOL_Roa.js +0 -399
  1506. package/dist/isolated-agent-CNw6E3F0.js +0 -1097
  1507. package/dist/isolated-agent-DjkHhEyR.js +0 -2
  1508. package/dist/kernel-B5Y5IQ-A.js +0 -3
  1509. package/dist/kernel-CMuO4VJy.js +0 -979
  1510. package/dist/kimi-web-search-provider.runtime-V4m_MHsk.js +0 -307
  1511. package/dist/library-B-1EZjtY.js +0 -45
  1512. package/dist/lifecycle-B-5gEZ7O.js +0 -570
  1513. package/dist/lifecycle-Bzh5Jo09.js +0 -2
  1514. package/dist/lifecycle-DvbcJYMl.js +0 -355
  1515. package/dist/lifecycle.runtime-Bzh5Jo09.js +0 -2
  1516. package/dist/list-B4xSHRdU.js +0 -2
  1517. package/dist/list-BnhZHpxx.js +0 -207
  1518. package/dist/list.list-command-DAz-Ws_6.js +0 -429
  1519. package/dist/list.model-row-DtdX9KDu.js +0 -39
  1520. package/dist/list.probe-CY6lxq51.js +0 -2
  1521. package/dist/list.probe-DPuE1GOH.js +0 -451
  1522. package/dist/list.provider-catalog-BHc9WXI6.js +0 -211
  1523. package/dist/list.provider-catalog-CFbrroys.js +0 -2
  1524. package/dist/list.registry-load-C1_sr3gb.js +0 -152
  1525. package/dist/list.row-sources-BMtHc9oi.js +0 -474
  1526. package/dist/list.source-plan-Dth72qPP.js +0 -81
  1527. package/dist/list.status-command-BXCnEq8Q.js +0 -815
  1528. package/dist/live-model-switch-Dxav22vq.js +0 -119
  1529. package/dist/llm-slug-generator-6o8RXL11.js +0 -78
  1530. package/dist/load-config-EF3n0Dyo.js +0 -27
  1531. package/dist/load-context-CI_ogQt_.js +0 -82
  1532. package/dist/loader-DtwEzpp-.js +0 -7008
  1533. package/dist/local-dispatch.runtime-21liE3rA.js +0 -10
  1534. package/dist/main-session-restart-recovery-D1g62iJ5.js +0 -2
  1535. package/dist/main-session-restart-recovery-v2I9CEXi.js +0 -389
  1536. package/dist/managed-image-attachments-BEl5qfCT.js +0 -616
  1537. package/dist/managed-image-attachments-D5KqX2Qy.js +0 -2
  1538. package/dist/manager-DZc3xiNq.js +0 -2314
  1539. package/dist/manager-Vf3vLTGe.js +0 -3737
  1540. package/dist/mcp-http-BaJoPKF9.js +0 -583
  1541. package/dist/mcp-http-CpEaJIGJ.js +0 -2
  1542. package/dist/media-runtime-DtP_Ff8m.js +0 -391
  1543. package/dist/media-services-CXYbyIIp.js +0 -416
  1544. package/dist/media-understanding-DvTIsIyr.js +0 -87
  1545. package/dist/media-understanding-provider-DBBAvuwG.js +0 -13
  1546. package/dist/media-understanding-provider-DOf_uZrx.js +0 -70
  1547. package/dist/media-understanding-provider-DdRfNh9h.js +0 -69
  1548. package/dist/media-understanding-provider-mqpQDt8V.js +0 -29
  1549. package/dist/memory-BNk25Hi6.js +0 -437
  1550. package/dist/memory-core-host-engine-embeddings-XsK5xS70.js +0 -667
  1551. package/dist/memory-core-host-engine-foundation-BYkoOLXl.js +0 -15
  1552. package/dist/memory-core-host-engine-qmd-0JuUCKCK.js +0 -2
  1553. package/dist/memory-core-host-engine-storage-MCFGjDwW.js +0 -2
  1554. package/dist/memory-core-host-runtime-cli-fVGH65E8.js +0 -10
  1555. package/dist/memory-core-host-runtime-core-JtXIAdlM.js +0 -12
  1556. package/dist/memory-core-host-runtime-files-BGw_ypoN.js +0 -4
  1557. package/dist/memory-embedding-provider-runtime-3UBzs4sx.js +0 -36
  1558. package/dist/memory-host-core-Y_O5V-mu.js +0 -78
  1559. package/dist/memory-host-search.runtime-B4TzyvmR.js +0 -2
  1560. package/dist/memory-runtime-9kEPAeKV.js +0 -2
  1561. package/dist/memory-runtime-BU4t85uu.js +0 -57
  1562. package/dist/memory-search-CVX--mSz.js +0 -235
  1563. package/dist/message-BVXoNpWP.js +0 -284
  1564. package/dist/message-HaiKqj0A.js +0 -2
  1565. package/dist/message-action-runner-Chwzn02r.js +0 -2
  1566. package/dist/message-action-runner-tEEliptt.js +0 -1922
  1567. package/dist/message-handler-CHDS_NF-.js +0 -1806
  1568. package/dist/metadata-registry-loader-Croa1pgR.js +0 -22
  1569. package/dist/metadata-registry-loader-w0p86vis.js +0 -2
  1570. package/dist/migrate-CPCZJ4H5.js +0 -2
  1571. package/dist/migrate-CUj6m6Cx.js +0 -458
  1572. package/dist/migration-provider-runtime-4r4WGtf2.js +0 -2
  1573. package/dist/migration-provider-runtime-TxrH_mM7.js +0 -68
  1574. package/dist/minimax-web-search-provider.runtime-Dr2GJiWj.js +0 -148
  1575. package/dist/model-BQSouNOa.js +0 -2
  1576. package/dist/model-CAk0bcuO.js +0 -1302
  1577. package/dist/model-auth-BF7w9Fiv.js +0 -705
  1578. package/dist/model-auth-label-r729wcPk.js +0 -67
  1579. package/dist/model-auth-us8b_D5d.js +0 -6
  1580. package/dist/model-catalog-BGykBGxx.js +0 -434
  1581. package/dist/model-catalog-BVXrqFbI.js +0 -3
  1582. package/dist/model-catalog-visibility-Bsup46vy.js +0 -76
  1583. package/dist/model-config.helpers-wzD1EEfE.js +0 -95
  1584. package/dist/model-context-tokens-DrIU9eJc.js +0 -572
  1585. package/dist/model-fallback-GySPjr3J.js +0 -1288
  1586. package/dist/model-fallback-auth.runtime-Dg_Jmguu.js +0 -5
  1587. package/dist/model-picker-BI6jXOjt.js +0 -3
  1588. package/dist/model-picker-DYyJHhfH.js +0 -1135
  1589. package/dist/model-picker-visibility-D_IMZfxd.js +0 -22
  1590. package/dist/model-picker.runtime-B70kQMyc.js +0 -48
  1591. package/dist/model-pricing-cache-CSpUDzSt.js +0 -856
  1592. package/dist/model-pricing-cache-dkPwTUVJ.js +0 -3
  1593. package/dist/model-pricing-cache-state-C6shoEWy.js +0 -83
  1594. package/dist/model-provider-auth-BfZHbTaj.js +0 -2
  1595. package/dist/model-provider-auth-CPCBWvqL.js +0 -375
  1596. package/dist/model-runtime-aliases-DUzusc9_.js +0 -133
  1597. package/dist/model-selection-8UzO5mgF.js +0 -254
  1598. package/dist/model-selection-Cb7azWw1.js +0 -7
  1599. package/dist/model-selection-jDYEo0WI.js +0 -352
  1600. package/dist/model-selection.runtime-D_yHZLbs.js +0 -7
  1601. package/dist/models-BxA2IU3W.js +0 -57
  1602. package/dist/models-auth-status-yG7yyRcv.js +0 -280
  1603. package/dist/models-cli-DUt4uiMH.js +0 -257
  1604. package/dist/models-config-B5bkuh6A.js +0 -1189
  1605. package/dist/models-config-Xj8vG_x2.js +0 -2
  1606. package/dist/models-config.providers.secrets-DNBB440Z.js +0 -2
  1607. package/dist/models-config.providers.secrets-DNIQlBSE.js +0 -382
  1608. package/dist/models-http-DMILRsry.js +0 -88
  1609. package/dist/monitor-2_c2Ttjf.js +0 -1024
  1610. package/dist/monitor-7tD_FE_5.js +0 -60
  1611. package/dist/monitor.account-D0F9tnWD.js +0 -5382
  1612. package/dist/music-generation-provider-3ykPaUwR.js +0 -308
  1613. package/dist/native-hook-relay-BJKHIhWd.js +0 -1378
  1614. package/dist/native-hook-relay-V8Kappw1.js +0 -19
  1615. package/dist/node-cli-BLVyQ93e.js +0 -2806
  1616. package/dist/node-command-policy-B0ezpI_O.js +0 -295
  1617. package/dist/nodes-DnWH_15m.js +0 -3
  1618. package/dist/nodes-RkB4ZmP6.js +0 -1483
  1619. package/dist/nodes-cli-upwPs91b.js +0 -960
  1620. package/dist/nodes-pending--sojaxpI.js +0 -211
  1621. package/dist/nodes-utils-Yks_uDZK.js +0 -85
  1622. package/dist/oauth-CQN2efEy.js +0 -207
  1623. package/dist/oauth-DApi3OI9.js +0 -746
  1624. package/dist/oauth-DkUWBub2.js +0 -852
  1625. package/dist/onboard-CiQSBSrz.js +0 -768
  1626. package/dist/onboard-channels-DaWYXiLv.js +0 -1534
  1627. package/dist/onboard-channels-DnwM2_IL.js +0 -2
  1628. package/dist/onboard-custom-BQPckD0V.js +0 -3
  1629. package/dist/onboard-custom-config-BmbThk2-.js +0 -422
  1630. package/dist/onboard-custom-xInFj1Rs.js +0 -280
  1631. package/dist/onboard-search-DSfmthe5.js +0 -412
  1632. package/dist/openai-compat-errors-VR4SN1MV.js +0 -136
  1633. package/dist/openai-http-DV95ynPi.js +0 -836
  1634. package/dist/openai-transport-stream-BwpzqR-b.js +0 -3427
  1635. package/dist/openresponses-http-DPchx8IC.js +0 -1175
  1636. package/dist/operations-f9R8j-r9.js +0 -805
  1637. package/dist/order-BQx8mNGZ.js +0 -218
  1638. package/dist/outbound-attachment-C4yojK6p.js +0 -19
  1639. package/dist/param-readers-BIXyd5la.js +0 -2
  1640. package/dist/payloads-DrY1bKyF.js +0 -256
  1641. package/dist/persistent-bindings.lifecycle-BiPN7luW.js +0 -85
  1642. package/dist/persistent-bindings.lifecycle-X3wfan2Z.js +0 -2
  1643. package/dist/plugin-enabled-CqsBObeO.js +0 -232
  1644. package/dist/plugin-install-CfB1_kpX.js +0 -118
  1645. package/dist/plugin-install-DzMraXHH.js +0 -2
  1646. package/dist/plugin-install-config-policy-BD_elPNg.js +0 -169
  1647. package/dist/plugin-registration-Dy58ncPf.js +0 -97
  1648. package/dist/plugin-registry-BlmODeop.js +0 -3
  1649. package/dist/plugin-registry-k5OK18l5.js +0 -2
  1650. package/dist/plugin-runtime-B3t53CKr.js +0 -102
  1651. package/dist/plugin-sdk/bundled-channel-config-schema-UtIBjviA.d.ts +0 -3169
  1652. package/dist/plugin-service-sKF4gWFm.js +0 -1249
  1653. package/dist/plugins-authoring-command-I72k2cuv.js +0 -304
  1654. package/dist/plugins-cli-DMQRbPsU.js +0 -63
  1655. package/dist/plugins-cli.runtime-CvDuKFJj.js +0 -339
  1656. package/dist/plugins-command-helpers-C5WMM4bk.js +0 -164
  1657. package/dist/plugins-command-helpers-DDt_pMQ4.js +0 -2
  1658. package/dist/plugins-inspect-command-ka7Hpld3.js +0 -248
  1659. package/dist/plugins-install-command-BHSgof-_.js +0 -2
  1660. package/dist/plugins-install-command-t5caX9q_.js +0 -993
  1661. package/dist/plugins-install-persist-Bah1m3x7.js +0 -252
  1662. package/dist/plugins-list-command-BXLWwXHM.js +0 -184
  1663. package/dist/plugins-uninstall-command-C_3m6CrW.js +0 -118
  1664. package/dist/prepare.runtime-COZaHg5E.js +0 -798
  1665. package/dist/presentation-card-CciJv4ru.js +0 -164
  1666. package/dist/preview-warnings-L4VuEOyB.js +0 -618
  1667. package/dist/profiles-CM2xoUYX.js +0 -194
  1668. package/dist/program-B-4C7bC-.js +0 -131
  1669. package/dist/provider-adapters-Eh8mS2Fd.js +0 -104
  1670. package/dist/provider-api-key-auth-DTh2cbmS.js +0 -117
  1671. package/dist/provider-api-key-auth.runtime-DrTYYfxK.js +0 -14
  1672. package/dist/provider-auth-Bnaijzmv.js +0 -281
  1673. package/dist/provider-auth-api-key-CNP8o5E7.js +0 -5
  1674. package/dist/provider-auth-choice-Devw4sQf.js +0 -311
  1675. package/dist/provider-auth-choice-helpers-DmVudRp6.js +0 -210
  1676. package/dist/provider-auth-choice.runtime-C337IQ3W.js +0 -2
  1677. package/dist/provider-auth-choice.runtime-DqGYalFo.js +0 -18
  1678. package/dist/provider-auth-guidance-Bk4WV6Lg.js +0 -2
  1679. package/dist/provider-auth-guidance-C7NCKuKn.js +0 -34
  1680. package/dist/provider-auth-helpers-r7mC8I5l.js +0 -177
  1681. package/dist/provider-auth-login.runtime-BFJgAAS6.js +0 -156
  1682. package/dist/provider-auth-runtime-BiLPGiMW.js +0 -186
  1683. package/dist/provider-discovery-uxRmAIf_.js +0 -95
  1684. package/dist/provider-discovery.runtime-mwbSivDS.js +0 -290
  1685. package/dist/provider-dispatcher-CtKWj3r-.js +0 -22
  1686. package/dist/provider-entry-DjACqdrB.js +0 -134
  1687. package/dist/provider-hook-runtime-CpJsM7Dk.js +0 -255
  1688. package/dist/provider-openai-codex-oauth-DWGmVUYg.js +0 -2
  1689. package/dist/provider-openai-codex-oauth-ctxd00JW.js +0 -44
  1690. package/dist/provider-registration-l8EX4voM.js +0 -235
  1691. package/dist/provider-registry-BgIQXJle.js +0 -31
  1692. package/dist/provider-registry-CVuzobHN.js +0 -36
  1693. package/dist/provider-registry-DmdDbSQs.js +0 -61
  1694. package/dist/provider-registry-LqtLqheu.js +0 -61
  1695. package/dist/provider-registry-pTYVjODc.js +0 -61
  1696. package/dist/provider-runtime-BQZSuC9l.js +0 -3
  1697. package/dist/provider-runtime-D9Q-7VuO.js +0 -386
  1698. package/dist/provider-runtime.runtime-C6YZ8YI0.js +0 -26
  1699. package/dist/provider-self-hosted-setup-BIAD2ISe.js +0 -373
  1700. package/dist/provider-stream-DScdaoRo.js +0 -313
  1701. package/dist/provider-stream-PE0IxmpZ.js +0 -1084
  1702. package/dist/provider-stream-family-S2fhlydZ.js +0 -2
  1703. package/dist/provider-usage-DVKHMF6l.js +0 -4
  1704. package/dist/provider-usage-EEjx1av0.js +0 -71
  1705. package/dist/provider-usage.load-Cu11xbrw.js +0 -357
  1706. package/dist/provider-web-search-Dbk7MO-1.js +0 -58
  1707. package/dist/provider-wizard-DS2Xb2eu.js +0 -125
  1708. package/dist/providers.runtime-BPhGcupv.js +0 -240
  1709. package/dist/providers.runtime-DoylK-ht.js +0 -2
  1710. package/dist/proxy-BxacG0p3.js +0 -662
  1711. package/dist/public-artifacts-Dq3y7bBv.js +0 -7
  1712. package/dist/pw-ai-DlSSqerW.js +0 -3064
  1713. package/dist/qmd-manager-B_SG-ejE.js +0 -2040
  1714. package/dist/qr-cli-CT-sE_j9.js +0 -2
  1715. package/dist/qr-cli-DPlDCXJQ.js +0 -371
  1716. package/dist/qr-image--VmmvuDB.js +0 -2
  1717. package/dist/queue-Be2Y7PcO.js +0 -923
  1718. package/dist/read-file-hhemkDfq.js +0 -183
  1719. package/dist/register-service-commands-CeVpCQU3.js +0 -77
  1720. package/dist/register.agent-JLsb-giw.js +0 -152
  1721. package/dist/register.configure-CP0Q-ost.js +0 -16
  1722. package/dist/register.crestodian-CBXyXEix.js +0 -24
  1723. package/dist/register.maintenance-DGIPQ2Vo.js +0 -85
  1724. package/dist/register.message-BBQwz0Ld.js +0 -404
  1725. package/dist/register.migrate-CkgNlvLD.js +0 -106
  1726. package/dist/register.onboard-CS9gRK0c.js +0 -115
  1727. package/dist/register.setup-DhqDOer9.js +0 -40
  1728. package/dist/register.status-health-sessions-CiwQN_lw.js +0 -293
  1729. package/dist/register.subclis-86Md7P0P.js +0 -3
  1730. package/dist/register.subclis-CTVI8zvZ.js +0 -31
  1731. package/dist/register.subclis-core-Cy4AnRCu.js +0 -273
  1732. package/dist/rem-harness-vSsq3HiK.js +0 -649
  1733. package/dist/repair-sequencing-SHADYdcA.js +0 -652
  1734. package/dist/reply-media-paths.runtime-Bf5nxPuP.js +0 -154
  1735. package/dist/reply-media-paths.runtime-sLsMpKGO.js +0 -2
  1736. package/dist/reply-payloads-CJ3w8rSA.js +0 -79
  1737. package/dist/reply-payloads-dedupe-DDFXWCVR.js +0 -176
  1738. package/dist/reply-payloads-dedupe.runtime-DbXPzKmG.js +0 -2
  1739. package/dist/reply-timing-tracker-DjVIBsVb.js +0 -205
  1740. package/dist/reply-turn-admission-nEW5QbY5.js +0 -2056
  1741. package/dist/reply.runtime-B4Dgs3Hg.js +0 -2
  1742. package/dist/reset-preserved-selection-CVD1yeVC.js +0 -45
  1743. package/dist/resolve-DidlinMh.js +0 -106
  1744. package/dist/restart-DzTrO95c.js +0 -121
  1745. package/dist/result-fallback-classifier-BqsFUDvP.js +0 -98
  1746. package/dist/root-help-QGs0dCCN.js +0 -43
  1747. package/dist/route-B3R-uzFG.js +0 -475
  1748. package/dist/route-reply-CdfhgIoY.js +0 -174
  1749. package/dist/route-reply.runtime-DwuU2WjH.js +0 -2
  1750. package/dist/routes-ChXmJocl.js +0 -3701
  1751. package/dist/routes-D-ZF4AdA.js +0 -2
  1752. package/dist/run-ClmVDTET.js +0 -1162
  1753. package/dist/run-auth-profile.runtime-CTxrwz0y.js +0 -2
  1754. package/dist/run-command-CqZJQ0Im.js +0 -2
  1755. package/dist/run-command-GClW75NL.js +0 -23
  1756. package/dist/run-context-BOdGeRg5.js +0 -66
  1757. package/dist/run-context.runtime-CwuKVYPj.js +0 -2
  1758. package/dist/run-delivery.runtime-BQ39dm34.js +0 -762
  1759. package/dist/run-embedded.runtime-e1K4Bt1_.js +0 -4
  1760. package/dist/run-execution-cli.runtime-Cjrgt4cV.js +0 -4
  1761. package/dist/run-executor.runtime-C2JE6JGb.js +0 -330
  1762. package/dist/run-model-catalog.runtime-DkrLKopr.js +0 -2
  1763. package/dist/run-session-state-C5YdQs7o.js +0 -159
  1764. package/dist/run-subagent-registry.runtime-Dl_lXi6y.js +0 -2
  1765. package/dist/runner-CNGHdaIg.js +0 -704
  1766. package/dist/runner.entries-dckPkeld.js +0 -1485
  1767. package/dist/runtime-9LxcVCyw.js +0 -615
  1768. package/dist/runtime-BCOtBS5G.js +0 -3
  1769. package/dist/runtime-C-pgjoJr.js +0 -210
  1770. package/dist/runtime-CyF0vJXG.js +0 -10
  1771. package/dist/runtime-D-7lMvGV.js +0 -2
  1772. package/dist/runtime-D17OmF9G.js +0 -224
  1773. package/dist/runtime-D6SweufG.js +0 -245
  1774. package/dist/runtime-DVAM7AFd.js +0 -2
  1775. package/dist/runtime-DX2ClrP-.js +0 -436
  1776. package/dist/runtime-FOOWuiYX.js +0 -300
  1777. package/dist/runtime-api-B0F0JsV1.js +0 -12
  1778. package/dist/runtime-cREKSBYC.js +0 -2
  1779. package/dist/runtime-channel-BmD4hoCR.js +0 -148
  1780. package/dist/runtime-channel-BsebQSPL.js +0 -2
  1781. package/dist/runtime-config-collectors-BjYeQ0Tk.js +0 -525
  1782. package/dist/runtime-embedded-agent.runtime-A4r23Bn8.js +0 -2
  1783. package/dist/runtime-internal-DkV-EMTK.js +0 -2
  1784. package/dist/runtime-llm.runtime-BQKNnuRc.js +0 -307
  1785. package/dist/runtime-model-auth.runtime-BbGqHVM5.js +0 -2
  1786. package/dist/runtime-model-auth.runtime-rtJH4LBB.js +0 -46
  1787. package/dist/runtime-options-B0EGb1Wq.js +0 -275
  1788. package/dist/runtime-plugin-Bdqm44bH.js +0 -92
  1789. package/dist/runtime-plugins-rZk1eAK_.js +0 -32
  1790. package/dist/runtime-plugins.runtime-DApiYzny.js +0 -2
  1791. package/dist/runtime-prepare.runtime-DWxvnbyY.js +0 -81
  1792. package/dist/runtime-provider-B0slPjtk.js +0 -2
  1793. package/dist/runtime-provider-DLgupOKt.js +0 -24
  1794. package/dist/runtime-registry-loader-Cf2HuMjd.js +0 -2
  1795. package/dist/runtime-registry-loader-DLzDrA7e.js +0 -117
  1796. package/dist/runtime-shared-Bg-OiD4u.js +0 -365
  1797. package/dist/runtime-web-channel-plugin-DrMjRaqi.js +0 -204
  1798. package/dist/scan-DA7Oqxuv.js +0 -573
  1799. package/dist/sdk-security-runtime-WjOaCbga.js +0 -86
  1800. package/dist/sdk-setup-tools-DaYT6_jD.js +0 -8
  1801. package/dist/secrets-cli-fJQ0geWO.js +0 -150
  1802. package/dist/security-cli-CJMwGp8U.js +0 -520
  1803. package/dist/selection-BNwLQzqJ.js +0 -3
  1804. package/dist/selection-Cj-l80pO.js +0 -18365
  1805. package/dist/send-DstYcrDW.js +0 -711
  1806. package/dist/send-aTxtLkJm.js +0 -178
  1807. package/dist/send-media-OG5Gd31l.js +0 -2072
  1808. package/dist/send-qwDMMnM6.js +0 -1222
  1809. package/dist/send-result-BWRKr16H.js +0 -141
  1810. package/dist/server-CMtA1S09.js +0 -24
  1811. package/dist/server-DIRaYiiH.js +0 -72
  1812. package/dist/server-aux-handlers-BRO-9-Jf.js +0 -1347
  1813. package/dist/server-chat-0J_ke0ph.js +0 -827
  1814. package/dist/server-context-DWOSX34k.js +0 -2
  1815. package/dist/server-context-R7MFLFdI.js +0 -955
  1816. package/dist/server-cron-2FuFg2j8.js +0 -2
  1817. package/dist/server-cron-ChPAVQtg.js +0 -3173
  1818. package/dist/server-maintenance-ZvS7Id6T.js +0 -152
  1819. package/dist/server-methods-DSbhPK3k.js +0 -497
  1820. package/dist/server-middleware-CYxFU-e5.js +0 -122
  1821. package/dist/server-model-catalog-B22UhmRr.js +0 -73
  1822. package/dist/server-model-catalog-BJIHPP3P.js +0 -2
  1823. package/dist/server-node-events-tNWJnXQM.js +0 -597
  1824. package/dist/server-plugin-bootstrap-Ccu97zi8.js +0 -71
  1825. package/dist/server-plugins-ByXwKPnj.js +0 -435
  1826. package/dist/server-reload-handlers-ConGiT9Q.js +0 -719
  1827. package/dist/server-restart-sentinel-mPHo61LL.js +0 -700
  1828. package/dist/server-runtime-services-BR1icaUW.js +0 -3
  1829. package/dist/server-runtime-services-Bx8n34dj.js +0 -147
  1830. package/dist/server-runtime-subscriptions-CZklTkRG.js +0 -67
  1831. package/dist/server-session-events-DxdiZYM2.js +0 -244
  1832. package/dist/server-session-key-CYvLslFO.js +0 -75
  1833. package/dist/server-session-key-D9GQut81.js +0 -2
  1834. package/dist/server-startup-config-Byb0vR8j.js +0 -305
  1835. package/dist/server-startup-early-a65fHTQS.js +0 -87
  1836. package/dist/server-startup-memory-ClwzC9jX.js +0 -72
  1837. package/dist/server-startup-plugins-CaBj0Nt2.js +0 -127
  1838. package/dist/server-startup-post-attach-B7TcxkmO.js +0 -793
  1839. package/dist/server-ws-runtime-Cxk_CqMr.js +0 -374
  1840. package/dist/server.impl-CQ6dnx43.js +0 -2622
  1841. package/dist/session-cost-usage-GsYDNvka.js +0 -1600
  1842. package/dist/session-kill-http-CKkxZhhd.js +0 -121
  1843. package/dist/session-log-runtime-Bwc2Oijk.js +0 -1258
  1844. package/dist/session-override-CWbKiXiC.js +0 -134
  1845. package/dist/session-reset-model.runtime-CDFMjwWA.js +0 -144
  1846. package/dist/session-reset-service-SE0aK4cw.js +0 -651
  1847. package/dist/session-status.runtime-Df89I7Fk.js +0 -2
  1848. package/dist/session-store-RkvjJPMQ.js +0 -273
  1849. package/dist/session-store.runtime-C7P5asx7.js +0 -4
  1850. package/dist/session-subagent-reactivation.runtime-BhGUZG1Z.js +0 -2
  1851. package/dist/session-tab-registry-9rSuQ0Yz.js +0 -551
  1852. package/dist/session-utils-De8TIM0h.js +0 -1508
  1853. package/dist/sessions-6b9a00Tl.js +0 -1917
  1854. package/dist/sessions-CEPHczjC.js +0 -316
  1855. package/dist/sessions-CEojHc8b.js +0 -12736
  1856. package/dist/sessions-cleanup-BkG7_sq9.js +0 -165
  1857. package/dist/sessions-history-http-BjJEfjJa.js +0 -432
  1858. package/dist/sessions-patch-PwG5sknc.js +0 -401
  1859. package/dist/sessions-resolve-CSIrd_fi.js +0 -180
  1860. package/dist/sessions-table-8CbU7jXa.js +0 -161
  1861. package/dist/sessions.runtime-BYHMD0M7.js +0 -2
  1862. package/dist/set-BJDpe28W.js +0 -31
  1863. package/dist/set-image-CwTFx7PX.js +0 -17
  1864. package/dist/setup-B6LmeIms.js +0 -614
  1865. package/dist/setup-B_zxHfYu.js +0 -2
  1866. package/dist/setup-onboard-configure-help-fast-path-Bck3SKEH.js +0 -64
  1867. package/dist/setup.finalize-CmLYX-Rf.js +0 -586
  1868. package/dist/setup.gateway-config-H_89Msro.js +0 -281
  1869. package/dist/setup.migration-import-DVzyUjX6.js +0 -2
  1870. package/dist/setup.migration-import-DmJpqoqf.js +0 -200
  1871. package/dist/setup.post-install-migration-WPFWKXXg.js +0 -128
  1872. package/dist/shared-CUhu8NTs.js +0 -5
  1873. package/dist/shared-D-BN2JhY.js +0 -71
  1874. package/dist/shared-ES8nDIcn.js +0 -212
  1875. package/dist/simple-completion-runtime-BGZkWvKr.js +0 -206
  1876. package/dist/simple-completion-runtime-CM_IISYW.js +0 -2
  1877. package/dist/simple-completion-transport-Bo0u9dhp.js +0 -83
  1878. package/dist/snapshot-urls-C1KjRQD5.js +0 -317
  1879. package/dist/speech-core-Bas7e4h0.js +0 -119
  1880. package/dist/speech-provider-BonJQv5S.js +0 -227
  1881. package/dist/speech-provider-CwdKQmDv.js +0 -171
  1882. package/dist/speech-provider-DcQRnYhZ.js +0 -233
  1883. package/dist/stale-oauth-profile-shadows-C3aeAWfv.js +0 -186
  1884. package/dist/stale-oauth-profile-shadows-m5rb8dPc.js +0 -2
  1885. package/dist/standalone-runtime-registry-loader-B9n2LBKC.js +0 -59
  1886. package/dist/startup-context-DY7C4riM.js +0 -314
  1887. package/dist/status-6EPKat7p.js +0 -73
  1888. package/dist/status-C6Fa7Dsf.js +0 -2
  1889. package/dist/status-CNnxDQlM.js +0 -4
  1890. package/dist/status-D2Scvbc0.js +0 -3
  1891. package/dist/status-Ducanro3.js +0 -2
  1892. package/dist/status-_XX_6QVA.js +0 -466
  1893. package/dist/status-all-BP1u6vou.js +0 -573
  1894. package/dist/status-json-DPlOJ_ue.js +0 -15
  1895. package/dist/status-json-command-BT7EwVKj.js +0 -84
  1896. package/dist/status-message-Dzr9-MX-.js +0 -495
  1897. package/dist/status-message.runtime-DFezIt1d.js +0 -6
  1898. package/dist/status-prBlcUV5.js +0 -249
  1899. package/dist/status-queue.runtime-C1bmg2rl.js +0 -2
  1900. package/dist/status-runtime-shared-RjKIPEQ0.js +0 -289
  1901. package/dist/status-subagents.runtime-tsCCe4Ny.js +0 -32
  1902. package/dist/status-text-Bkeyg8Bf.js +0 -301
  1903. package/dist/status.command-D06_4ATq.js +0 -425
  1904. package/dist/status.command-dDEZM84a.js +0 -2
  1905. package/dist/status.command.text-runtime-WH9tP7yg.js +0 -15
  1906. package/dist/status.runtime-B76GaBIR.js +0 -2
  1907. package/dist/status.scan-Bc6clx0F.js +0 -72
  1908. package/dist/status.scan-overview-v_-AaFhC.js +0 -460
  1909. package/dist/status.scan.deps.runtime-BkH1HAb4.js +0 -19
  1910. package/dist/status.scan.fast-json-CrlfKKI3.js +0 -2
  1911. package/dist/status.scan.fast-json-D8v6zfP8.js +0 -163
  1912. package/dist/status.summary-DBhvgOPr.js +0 -276
  1913. package/dist/status.summary-hQV0PKFO.js +0 -2
  1914. package/dist/store-BClomp_4.js +0 -3
  1915. package/dist/store-BHqDPtNw.js +0 -2302
  1916. package/dist/stored-model-override-vm4CtQWX.js +0 -79
  1917. package/dist/subagent-announce-D244Q4w2.js +0 -353
  1918. package/dist/subagent-announce-delivery-qKZfF7Bs.js +0 -1369
  1919. package/dist/subagent-control-c87mVGUE.js +0 -492
  1920. package/dist/subagent-control.runtime-DfQtIsDb.js +0 -3
  1921. package/dist/subagent-hooks-B_UW5Len.js +0 -2
  1922. package/dist/subagent-hooks-CYvFWt_r.js +0 -230
  1923. package/dist/subagent-hooks-api-DZgaJf19.js +0 -23
  1924. package/dist/subagent-registry-BlcoCggo.js +0 -2627
  1925. package/dist/subagent-registry-CuObhNeO.js +0 -3
  1926. package/dist/subagent-session-cleanup-hFF8Z34s.js +0 -390
  1927. package/dist/system-CN_Knfqq.js +0 -111
  1928. package/dist/system-prompt-config-BmZlhYK9.js +0 -918
  1929. package/dist/talk-DrjGczYs.js +0 -2454
  1930. package/dist/target-id-BNpbyWkq.js +0 -107
  1931. package/dist/targets-CQcGo6u4.js +0 -267
  1932. package/dist/targets.runtime-DwcxNI-x.js +0 -2
  1933. package/dist/task-executor-CZg-qt4u.js +0 -349
  1934. package/dist/task-owner-access-Duem5jjb.js +0 -74
  1935. package/dist/task-registry-Cw8pc3Ry.js +0 -2362
  1936. package/dist/task-registry-delivery-runtime-HaiKqj0A.js +0 -2
  1937. package/dist/task-registry.maintenance-BLv3wpK9.js +0 -764
  1938. package/dist/task-registry.maintenance-CvlIcxE-.js +0 -2
  1939. package/dist/task-status-access-C5nDJSI4.js +0 -18
  1940. package/dist/tasks-D3CfEAlq.js +0 -548
  1941. package/dist/tasks-WKnE5fvr.js +0 -153
  1942. package/dist/tasks-audit-system-okJjcOjU.js +0 -210
  1943. package/dist/tasks-json-C-iUgWNu.js +0 -73
  1944. package/dist/tavily-web-search-provider.runtime-jpagljrA.js +0 -112
  1945. package/dist/text-report-BTsF3Pv3.js +0 -695
  1946. package/dist/text-transforms.runtime-CgH_pbcQ.js +0 -113
  1947. package/dist/thread-bindings-BWxpUE9U.js +0 -228
  1948. package/dist/tool-DhJbbm91.js +0 -143
  1949. package/dist/tool-dispatch-CpFUfblu.js +0 -155
  1950. package/dist/tool-images-C-tFlXjE.js +0 -247
  1951. package/dist/tool-plugin-3NejWxZW.js +0 -93
  1952. package/dist/tool-resolution-oW8Cbamd.js +0 -153
  1953. package/dist/tool-result-truncation-CWFGf7Eu.js +0 -498
  1954. package/dist/tool-schema-CMtc7PdZ.js +0 -40
  1955. package/dist/tool-schema-projection-DJRPEEvY.js +0 -215
  1956. package/dist/tool-split-E4RdK5jS.js +0 -323
  1957. package/dist/tools-BAl3JiNw.js +0 -901
  1958. package/dist/tools-DC8tCPxR.js +0 -579
  1959. package/dist/tools-catalog-Dzv9zaBD.js +0 -156
  1960. package/dist/tools-effective-CGvzyIL2.js +0 -442
  1961. package/dist/tools-effective-inventory-GI5N5Q9v.js +0 -379
  1962. package/dist/tools-invoke-CU2U0hNH.js +0 -51
  1963. package/dist/tools-invoke-http-8s3FiUy4.js +0 -68
  1964. package/dist/tools-invoke-shared-DIETrEY7.js +0 -200
  1965. package/dist/tools.runtime-Bnm8CI7w.js +0 -5
  1966. package/dist/transcript-rewrite-Buv2ITw4.js +0 -688
  1967. package/dist/transcripts-tool-BCFlLCFd.js +0 -2
  1968. package/dist/transcripts-tool-CWgNd0Uw.js +0 -656
  1969. package/dist/tts-Aguo4zC5.js +0 -3
  1970. package/dist/tts-Bf77cURn.js +0 -2
  1971. package/dist/tts-DnADOKOP.js +0 -194
  1972. package/dist/tts-runtime-MBSH-nOM.js +0 -1337
  1973. package/dist/tts.runtime-B-NR9osE.js +0 -2
  1974. package/dist/tts.runtime-Bo-QxKgx.js +0 -3
  1975. package/dist/tui-B0CdNmCz.js +0 -4860
  1976. package/dist/tui-ByRcXM3Z.js +0 -2
  1977. package/dist/tui-backend-C52BUoZI.js +0 -256
  1978. package/dist/tui-cli-BQHpZ4n0.js +0 -40
  1979. package/dist/typing-policy-XspVOezC.js +0 -199
  1980. package/dist/usage-BOYwzimH.js +0 -1113
  1981. package/dist/usage-BSmLrVWB.js +0 -623
  1982. package/dist/usage-format-CfzICmvv.js +0 -2
  1983. package/dist/usage-format-DPJKCPic.js +0 -394
  1984. package/dist/video-generation-provider-CdCTztQ7.js +0 -77
  1985. package/dist/video-generation-provider-MUUshUzz.js +0 -325
  1986. package/dist/video-generation-provider-XmzzTa6e.js +0 -297
  1987. package/dist/video-generation-provider-weiQUJE5.js +0 -64
  1988. package/dist/web-fetch-providers.runtime-tD9zqAS2.js +0 -41
  1989. package/dist/web-guarded-fetch-CyhQZ1yD.js +0 -2
  1990. package/dist/web-guarded-fetch-DIXHI-yJ.js +0 -58
  1991. package/dist/web-media-BPnTMYE5.js +0 -4
  1992. package/dist/web-media-DV_tCQiQ.js +0 -2
  1993. package/dist/web-media-DYydVGCK.js +0 -651
  1994. package/dist/web-provider-runtime-shared-h3M6Bqyg.js +0 -142
  1995. package/dist/web-search-provider-common-CEYWuDcp.js +0 -252
  1996. package/dist/web-search-providers.runtime-YrayP296.js +0 -41
  1997. package/dist/zod-schema.core-BGLctDlK.d.ts +0 -166
  1998. /package/dist/{acp-runtime-backend-CHZtaM6t.js → acp-runtime-backend-B83JR5Zf.js} +0 -0
  1999. /package/dist/{agent-turn-attachments-BYCRK86s.js → agent-turn-attachments-D5uJijuK.js} +0 -0
  2000. /package/dist/{auth-install-policy-t46tJ8jV.js → auth-install-policy-BIpdwrZ9.js} +0 -0
  2001. /package/dist/{cli-backends-BHXnrVN_.js → cli-backends-79CCRQ2a.js} +0 -0
  2002. /package/dist/{command-secret-targets-DZ0J2Wm3.js → command-secret-targets-BOJlcBil.js} +0 -0
  2003. /package/dist/{commands-DWp49Exc.js → commands-Dw9hwmVt.js} +0 -0
  2004. /package/dist/{commands-reset-hooks-MMq2dvff.js → commands-reset-hooks-epArfNOY.js} +0 -0
  2005. /package/dist/{delegate-Dkj_5OvH.js → delegate-Bw8NQXVr.js} +0 -0
  2006. /package/dist/{jobs-BGELIHcx.js → jobs-BIOTaq7l.js} +0 -0
  2007. /package/dist/{kimi-web-search-provider-4PlMYsPx.js → kimi-web-search-provider-Bzg_DiXO.js} +0 -0
  2008. /package/dist/{memory-host-search-Ds9GiNpf.js → memory-host-search-Dph0Mq-v.js} +0 -0
  2009. /package/dist/{minimax-web-search-provider-d5gTJUNg.js → minimax-web-search-provider-CETxDkkI.js} +0 -0
  2010. /package/dist/{model-selection-cli-CO6BHPiL.js → model-selection-cli-DizUvxeY.js} +0 -0
  2011. /package/dist/{provider-auth-choice-preference-f7Us6TQL.js → provider-auth-choice-preference-uJn1811S.js} +0 -0
  2012. /package/dist/{runtime-wfO9bV5y.js → runtime-BEVbpIgZ.js} +0 -0
  2013. /package/dist/{runtime-web-tools-B6vr1LZs.js → runtime-web-tools-Bf0aEe-F.js} +0 -0
  2014. /package/dist/{runtime-web-tools-fallback.runtime-Crs7KfH5.js → runtime-web-tools-fallback.runtime-DU6rTj6l.js} +0 -0
  2015. /package/dist/{session-subagent-reactivation-H5Rdwkyy.js → session-subagent-reactivation-Bb5SCi9J.js} +0 -0
  2016. /package/dist/{tavily-web-search-provider-DbdIzpMv.js → tavily-web-search-provider-CIEhV60D.js} +0 -0
@@ -0,0 +1,4074 @@
1
+ import { c as normalizeOptionalString, s as normalizeOptionalLowercaseString } from "./string-coerce-DKw2K5wM.js";
2
+ import { t as sanitizeForLog } from "./ansi-BCVkJ8zW.js";
3
+ import { i as formatErrorMessage } from "./errors-5ePGD43N.js";
4
+ import { p as resolveUserPath } from "./utils-v5zGdVpj.js";
5
+ import { b as freezeDiagnosticTraceContext } from "./diagnostic-events-Bwqd0ZOT.js";
6
+ import { t as createSubsystemLogger } from "./subsystem-46gngkCY.js";
7
+ import { o as resolveAgentExecutionContract, r as hasConfiguredModelFallbacks, v as resolveSessionAgentIds } from "./agent-scope-DYvAPpmY.js";
8
+ import { c as parseAgentSessionKey, i as isCronSessionKey } from "./session-key-utils-CdfsDYvz.js";
9
+ import { a as resolveAgentDir, o as resolveAgentWorkspaceDir } from "./agent-scope-config-BFfPgg3b.js";
10
+ import { r as resolveProviderIdForAuth } from "./provider-auth-aliases-C1s6dq0f.js";
11
+ import { n as DEFAULT_MODEL, r as DEFAULT_PROVIDER, t as DEFAULT_CONTEXT_TOKENS } from "./defaults-DNFU4TYx.js";
12
+ import { i as isMarkdownCapableMessageChannel } from "./message-channel-DcN_7tYD.js";
13
+ import { o as resolveSafeTimeoutDelayMs } from "./timeouts-tJvqW40V.js";
14
+ import { a as normalizeOptionalAgentRuntimeId, r as isDefaultAgentRuntimeId } from "./agent-runtime-id-DMrPVcZQ.js";
15
+ import { a as listOpenAIAuthProfileProvidersForAgentRuntime, d as resolveSelectedOpenAIRuntimeProvider, i as isOpenAIProvider, l as resolveContextConfigProviderForRuntime, n as OPENAI_PROVIDER_ID, r as isOpenAICodexProvider } from "./openai-codex-routing-CJw0IxWE.js";
16
+ import { t as resolveAgentHarnessPolicy } from "./policy-BoAopVZT.js";
17
+ import { d as setReplyPayloadMetadata, i as getReplyPayloadMetadata, r as copyReplyPayloadMetadata, u as markReplyPayloadForSourceSuppressionDelivery } from "./reply-payload-DM17pxMC.js";
18
+ import { t as getGlobalHookRunner } from "./hook-runner-global-lWQvOg8l.js";
19
+ import { o as resolveContextEngine, s as resolveContextEngineOwnerPluginId } from "./registry-edunJA46.js";
20
+ import { s as emitAgentPlanEvent } from "./agent-events-Dl8p_DjC.js";
21
+ import { u as resolveStorePath } from "./paths-C79m3Aob.js";
22
+ import { f as updateSessionStoreEntry } from "./store-BfSa-Tzr.js";
23
+ import "./sessions-Cs11K_1i.js";
24
+ import { t as extractAssistantTextForPhase } from "./chat-message-content-CeOacmio.js";
25
+ import { a as resolveProviderAuthProfileId } from "./provider-hook-runtime-B8AUbQxf.js";
26
+ import { y as prepareProviderRuntimeAuth } from "./provider-runtime-DNNbfwOK.js";
27
+ import { i as ensureAuthProfileStoreWithoutExternalProfiles, n as ensureAuthProfileStore } from "./store-CdBPITcg.js";
28
+ import "./auth-profiles-6VFEdgC-.js";
29
+ import { n as markAuthProfileSuccess } from "./profiles-DUhMLnqX.js";
30
+ import { a as isProfileInCooldown } from "./usage-state-C6N0ss4h.js";
31
+ import { i as resolveAuthProfileOrder, r as resolveAuthProfileEligibility } from "./order-CaXafMPG.js";
32
+ import { d as sanitizeRuntimeProviderRequestOverrides, o as resolveProviderRequestConfig } from "./provider-request-config-D6EBylE2.js";
33
+ import { t as redactIdentifier } from "./redact-identifier-BI6BTlLC.js";
34
+ import { t as sanitizeForConsole } from "./console-sanitize-BUMxGUp3.js";
35
+ import { a as markAuthProfileFailure, s as resolveProfilesUnavailableReason } from "./usage-Bl-tgGx-.js";
36
+ import { t as ensureFengMingModelsJson } from "./models-config-Ayzj9gDz.js";
37
+ import { t as formatMissingAuthError } from "./model-auth-runtime-shared-cdTr1v5l.js";
38
+ import { i as getApiKeyForModel, n as applyLocalNoAuthHeaderOverride, p as shouldPreferExplicitConfigApiKeyAuth, t as applyAuthHeaderOverride } from "./model-auth-DJz7R41W.js";
39
+ import { r as formatRawAssistantErrorForUi } from "./assistant-error-format-DzIdQVBf.js";
40
+ import { l as isRawApiErrorPayload, n as formatBillingErrorMessage, o as getApiErrorPayloadFingerprint, t as BILLING_ERROR_USER_MESSAGE, y as isTimeoutErrorMessage } from "./sanitize-user-facing-text-B7CiNPI8.js";
41
+ import "./runs-O0PIwYP5.js";
42
+ import { n as SILENT_REPLY_TOKEN, r as isSilentReplyPayloadText } from "./tokens-T0RrWCee.js";
43
+ import { n as derivePromptTokens, o as normalizeUsage } from "./usage-B1VvYcZy.js";
44
+ import { n as sleepWithAbort } from "./backoff-DMecH_qr.js";
45
+ import { i as enqueueCommandInLane } from "./command-queue-DFj-9GVz.js";
46
+ import { S as parseImageSizeError, _ as isRateLimitAssistantError, a as formatAssistantErrorText, c as isBillingAssistantError, f as isFailoverAssistantError, g as isLikelyContextOverflowError, i as extractObservedOverflowTokenCount, p as isFailoverErrorMessage, s as isAuthAssistantError, t as classifyFailoverReason, u as isCompactionFailureError, x as parseImageDimensionError } from "./errors-16HnpAR8.js";
47
+ import { c as resolveFailoverStatus, n as coerceToFailoverError, r as describeFailoverError, t as FailoverError } from "./failover-error-B4bd4ckx.js";
48
+ import { a as hasReplyPayloadContent } from "./payload-Cpx3heIy.js";
49
+ import { u as isStrictAgenticExecutionContractActive } from "./fengming-tools-DHb-ZeDC.js";
50
+ import { A as shouldRotateCompactionTranscript, C as EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE, Ct as resolveSilentToolResultReplyPayload, Dt as observeReplayMetadata, E as shouldWarnEmbeddedRunStageSummary, Et as createEmbeddedRunReplayState, P as normalizeContextTokenBudget, S as mergeUsageIntoAccumulator, St as resolveRunLivenessState, T as formatEmbeddedRunStageSummary, Tt as shouldTreatEmptyAssistantReplyAsSilent, _ as resolveOverloadProfileRotationLimit, _t as resolveIncompleteTurnPayloadText, a as RUNTIME_AUTH_REFRESH_MARGIN_MS, b as scrubAnthropicRefusalMagic, bt as resolveReasoningOnlyRetryInstruction, c as buildErrorAgentMeta, d as isAssistantForModelRef, f as resolveActiveErrorContext, ft as STRICT_AGENTIC_BLOCKED_TEXT, g as resolveOverloadFailoverBackoffMs, gt as resolveEmptyResponseRetryInstruction, h as resolveMaxRunRetryIterations, ht as resolveAttemptReplayMetadata, i as selectAgentHarness, k as rotateTranscriptFileAfterCompaction, l as buildUsageAgentMetaFields, m as resolveFinalAssistantVisibleText, mt as resolveAckExecutionFastPathInstruction, o as RUNTIME_AUTH_REFRESH_MIN_DELAY_MS, p as resolveFinalAssistantRawText, pt as extractPlanningOnlyPlanDetails, r as runAgentHarnessAttempt, s as RUNTIME_AUTH_REFRESH_RETRY_MS, t as maybeCompactAgentHarnessSession, u as createCompactionDiagId, v as resolveRateLimitProfileRotationLimit, vt as resolvePlanningOnlyRetryInstruction, w as createEmbeddedRunStageTracker, wt as shouldRetryMissingAssistantTurn, x as createUsageAccumulator, xt as resolveReplayInvalidFlag, y as resolveReportedModelRef, yt as resolvePlanningOnlyRetryLimit } from "./selection-D4O3gK3Q.js";
51
+ import { i as createHeartbeatToolResponsePayload } from "./heartbeat-tool-response-BjnQjIIz.js";
52
+ import { t as log$1 } from "./logger-CshSmlns.js";
53
+ import { _ as listActiveProcessSessionReferences, g as resolveContextEngineCapabilities, m as resolveEmbeddedCompactionTarget, p as buildEmbeddedCompactionRuntimeContext, r as forgetPromptBuildDrainCacheForRun, v as buildAgentHookContextChannelFields } from "./attempt.prompt-helpers-CkBYHBBo.js";
54
+ import { d as retireSessionMcpRuntimeForSessionKey, u as retireSessionMcpRuntime } from "./agent-bundle-mcp-runtime-3i6m0706.js";
55
+ import "./agent-bundle-mcp-tools-DkixTTnL.js";
56
+ import "./tool-split-BjPHBFrv.js";
57
+ import { n as resolveProcessToolScopeKey } from "./agent-tools-COLEG7aL.js";
58
+ import { t as resolveToolLoopDetectionConfig } from "./tool-loop-detection-config-DOPGGB14.js";
59
+ import { l as hasMessagingToolDeliveryEvidence, u as hasOutboundDeliveryEvidence } from "./subagent-announce-delivery-Ci2Y_p--.js";
60
+ import { n as resolveGlobalLane, r as resolveSessionLane } from "./lanes-CVttd5qX.js";
61
+ import { i as pickFallbackThinkingLevel, s as normalizeTextForComparison } from "./embedded-agent-helpers-cw0InMDZ.js";
62
+ import { P as formatToolAggregate } from "./streaming-Cdmwb_WC.js";
63
+ import { p as parseReplyDirectives } from "./payloads-Dg9aAEOC.js";
64
+ import { c as suspendSession, d as shouldSuppressRawErrorConsoleSuffix, f as LiveSessionModelSwitchError, l as buildApiErrorObservationFields, m as shouldAllowCooldownProbeForReason, s as resolveSessionSuspensionReason } from "./model-fallback-BDdBR053.js";
65
+ import { i as resolveStoredSessionKeyForSessionId, r as resolveSessionKeyForRequest } from "./session-B9XAIPr3.js";
66
+ import { i as extractAssistantVisibleText, r as extractAssistantThinking } from "./embedded-agent-utils-BwOZaOZq.js";
67
+ import { n as resolveModelAsync } from "./model-BJZXR9dq.js";
68
+ import { t as ensureContextEnginesInitialized } from "./init-sR7bCS9D.js";
69
+ import { n as isLikelyMutatingToolName } from "./tool-mutation-BZiYsk_N.js";
70
+ import { f as compactContextEngineWithSafetyTimeout, m as resolveCompactionTimeoutMs, v as runAgentCleanupStep } from "./attempt.tool-run-context-DzfRK5pV.js";
71
+ import { a as resolveLiveToolResultMaxChars, c as truncateOversizedToolResultsInSession, o as sessionLikelyHasOversizedToolResults } from "./tool-result-truncation-BSKuIhd5.js";
72
+ import "./extra-params-Bm1eLWN9.js";
73
+ import { c as runContextEngineMaintenance } from "./context-engine-lifecycle-Bqdhy9JU.js";
74
+ import { a as formatContextWindowWarningMessage, i as formatContextWindowBlockMessage, r as evaluateContextWindowGuard, s as resolveContextWindowInfo } from "./context-window-guard-CLUkhh9l.js";
75
+ import "./sandbox-info-Bda0PKe4.js";
76
+ import { _ as persistSessionCompactionCheckpoint, c as DEFERRED_CONTEXT_ENGINE_COMPACTION_REASON, f as captureCompactionCheckpointSnapshotAsync, n as asCompactionHookRunner, p as cleanupCompactionCheckpointSnapshot, s as runPostCompactionSideEffects, t as readAgentModelContextTokens, v as readSessionLeafIdFromTranscriptAsync, y as resolveSessionCompactionCheckpointReason } from "./model-context-tokens-5y_PQELY.js";
77
+ import { t as isRecoverableNativeHarnessBindingFailure } from "./compaction-recovery-DmE01ro4.js";
78
+ import { t as ensureSelectedAgentHarnessPlugin } from "./runtime-plugin-ClqxJSbp.js";
79
+ import { t as ensureRuntimePluginsLoaded } from "./runtime-plugins-Bq01wLXP.js";
80
+ import { n as createAgentHarnessTaskRuntimeScope } from "./agent-harness-task-runtime-scope-Cnr0DP1A.js";
81
+ import { t as resolveExternalCliAuthOverlayScopeFromSelection } from "./external-cli-auth-selection-CM_aOUJw.js";
82
+ import { n as shouldSwitchToLiveModel, t as clearLiveModelSwitchPending } from "./live-model-switch-Dy-UFUMS.js";
83
+ import { t as buildAgentRuntimeAuthPlan } from "./auth-CK6yaauP.js";
84
+ import { r as buildAgentRuntimePlan } from "./build-DkEeJ9sO.js";
85
+ import { n as resolveRunWorkspaceDir, t as redactRunIdentifier } from "./workspace-run-Bed7Kfkh.js";
86
+ import fs from "node:fs/promises";
87
+ import { randomBytes } from "node:crypto";
88
+ //#region src/agents/embedded-agent-runner/compact.queued.ts
89
+ function shouldFallbackAfterHarnessCompaction(result) {
90
+ return isRecoverableNativeHarnessBindingFailure(result);
91
+ }
92
+ const DEFERRED_CONTEXT_ENGINE_COMPACTION_SCHEDULE_FAILURE_REASON = "failed to schedule background context-engine maintenance";
93
+ function shouldDeferOwningContextEngineBudgetCompaction(params) {
94
+ return params.compactParams.deferOwningContextEngineCompaction === true && params.compactParams.trigger === "budget" && params.contextEngine.info.ownsCompaction === true && params.contextEngine.info.turnMaintenanceMode === "background" && typeof params.contextEngine.maintain === "function";
95
+ }
96
+ async function disposeContextEngine(contextEngine) {
97
+ try {
98
+ await contextEngine.dispose?.();
99
+ } catch (err) {
100
+ log$1.warn("context engine dispose failed after deferred maintenance", { errorMessage: formatErrorMessage(err) });
101
+ }
102
+ }
103
+ async function deferOwningContextEngineBudgetCompaction(params) {
104
+ let deferredScheduled = false;
105
+ let deferredScheduleFailure;
106
+ try {
107
+ await runContextEngineMaintenance({
108
+ contextEngine: params.contextEngine,
109
+ sessionId: params.compactParams.sessionId,
110
+ sessionKey: params.compactParams.sessionKey,
111
+ sessionFile: params.compactParams.sessionFile,
112
+ reason: "turn",
113
+ runtimeContext: params.contextEngineRuntimeContext,
114
+ config: params.compactParams.config,
115
+ disposeDeferredContextEngineAfterMaintenance: true,
116
+ onDeferredMaintenance: () => {
117
+ deferredScheduled = true;
118
+ },
119
+ onDeferredMaintenanceFailure: (error) => {
120
+ deferredScheduleFailure = error;
121
+ }
122
+ });
123
+ } catch (err) {
124
+ log$1.warn("failed to defer context-engine budget compaction", { errorMessage: formatErrorMessage(err) });
125
+ }
126
+ if (!deferredScheduled || deferredScheduleFailure) {
127
+ await disposeContextEngine(params.contextEngine);
128
+ log$1.warn(`[compaction] failed to schedule context-engine-owned budget compaction background maintenance (sessionKey=${params.compactParams.sessionKey ?? params.compactParams.sessionId}${deferredScheduleFailure ? ` error=${formatErrorMessage(deferredScheduleFailure)}` : ""})`);
129
+ return {
130
+ ok: false,
131
+ compacted: false,
132
+ reason: DEFERRED_CONTEXT_ENGINE_COMPACTION_SCHEDULE_FAILURE_REASON,
133
+ failure: { reason: "deferred_compaction_not_scheduled" }
134
+ };
135
+ }
136
+ log$1.info(`[compaction] deferred context-engine-owned budget compaction to background maintenance (sessionKey=${params.compactParams.sessionKey ?? params.compactParams.sessionId} scheduled=${String(deferredScheduled)})`);
137
+ return {
138
+ ok: true,
139
+ compacted: false,
140
+ reason: DEFERRED_CONTEXT_ENGINE_COMPACTION_REASON
141
+ };
142
+ }
143
+ /**
144
+ * Compacts a session with lane queueing (session lane + global lane).
145
+ * Use this from outside a lane context. If already inside a lane, use
146
+ * `compactEmbeddedAgentSessionDirect` to avoid deadlocks.
147
+ */
148
+ async function compactEmbeddedAgentSession(params) {
149
+ ensureRuntimePluginsLoaded({
150
+ config: params.config,
151
+ workspaceDir: params.workspaceDir,
152
+ allowGatewaySubagentBinding: params.allowGatewaySubagentBinding
153
+ });
154
+ ensureContextEnginesInitialized();
155
+ const agentIds = resolveSessionAgentIds({
156
+ sessionKey: params.sessionKey,
157
+ config: params.config,
158
+ agentId: params.agentId
159
+ });
160
+ const agentDir = params.agentDir ?? resolveAgentDir(params.config ?? {}, agentIds.sessionAgentId);
161
+ const resolvedWorkspaceDir = resolveUserPath(params.workspaceDir);
162
+ const contextEngine = await resolveContextEngine(params.config, {
163
+ agentDir,
164
+ workspaceDir: resolvedWorkspaceDir
165
+ });
166
+ const runtimePolicySessionKey = params.sandboxSessionKey ?? params.sessionKey;
167
+ const runtimePolicyAgentId = params.sandboxSessionKey && parseAgentSessionKey(params.sandboxSessionKey) ? void 0 : params.agentId;
168
+ const policyCompactionTarget = resolveEmbeddedCompactionTarget({
169
+ config: params.config,
170
+ provider: params.provider,
171
+ modelId: params.model,
172
+ authProfileId: params.authProfileId,
173
+ defaultProvider: DEFAULT_PROVIDER,
174
+ defaultModel: DEFAULT_MODEL
175
+ });
176
+ const configuredHarnessPolicy = resolveAgentHarnessPolicy({
177
+ provider: policyCompactionTarget.provider ?? "byteplus",
178
+ modelId: policyCompactionTarget.model ?? "doubao-pro-32k",
179
+ config: params.config,
180
+ agentId: runtimePolicyAgentId,
181
+ sessionKey: runtimePolicySessionKey
182
+ });
183
+ const configuredHarnessRuntime = configuredHarnessPolicy.runtimeSource && configuredHarnessPolicy.runtimeSource !== "implicit" && !isDefaultAgentRuntimeId(configuredHarnessPolicy.runtime) ? configuredHarnessPolicy.runtime : void 0;
184
+ const selectedHarnessRuntime = params.agentHarnessId ?? configuredHarnessRuntime;
185
+ const resolvedCompactionTarget = resolveEmbeddedCompactionTarget({
186
+ config: params.config,
187
+ provider: params.provider,
188
+ modelId: params.model,
189
+ authProfileId: params.authProfileId,
190
+ harnessRuntime: selectedHarnessRuntime,
191
+ defaultProvider: DEFAULT_PROVIDER,
192
+ defaultModel: DEFAULT_MODEL
193
+ });
194
+ const ceProvider = resolvedCompactionTarget.provider ?? "byteplus";
195
+ const ceRuntimeProvider = resolvedCompactionTarget.runtimeProvider ?? ceProvider;
196
+ const ceContextConfigProvider = resolvedCompactionTarget.contextProvider ?? ceProvider;
197
+ const ceModelId = resolvedCompactionTarget.model ?? "doubao-pro-32k";
198
+ const attemptNativeHarnessCompaction = shouldAttemptNativeHarnessCompaction({
199
+ provider: ceProvider,
200
+ contextProvider: resolvedCompactionTarget.contextProvider,
201
+ selectedHarnessRuntime
202
+ });
203
+ if (attemptNativeHarnessCompaction) await ensureSelectedAgentHarnessPlugin({
204
+ config: params.config,
205
+ provider: ceProvider,
206
+ modelId: ceModelId,
207
+ agentId: runtimePolicyAgentId,
208
+ sessionKey: runtimePolicySessionKey,
209
+ agentHarnessRuntimeOverride: selectedHarnessRuntime,
210
+ workspaceDir: resolvedWorkspaceDir
211
+ });
212
+ const { model: ceModel } = await resolveModelAsync(ceRuntimeProvider, ceModelId, agentDir, params.config);
213
+ const ceRuntimeModel = ceModel;
214
+ const resolvedContextTokenBudget = normalizeContextTokenBudget(resolveContextWindowInfo({
215
+ cfg: params.config,
216
+ provider: ceContextConfigProvider,
217
+ modelId: ceModelId,
218
+ modelContextTokens: readAgentModelContextTokens(ceModel),
219
+ modelContextWindow: ceRuntimeModel?.contextWindow,
220
+ defaultTokens: 2e5
221
+ }).tokens) ?? 2e5;
222
+ const requestedContextTokenBudget = normalizeContextTokenBudget(params.contextTokenBudget);
223
+ const contextTokenBudget = Math.min(requestedContextTokenBudget ?? resolvedContextTokenBudget, resolvedContextTokenBudget);
224
+ const contextEngineRuntimeContext = buildCompactionContextEngineRuntimeContext({
225
+ params,
226
+ agentDir,
227
+ harnessRuntime: selectedHarnessRuntime,
228
+ contextTokenBudget,
229
+ contextEnginePluginId: resolveContextEngineOwnerPluginId(contextEngine)
230
+ });
231
+ const harnessResult = attemptNativeHarnessCompaction ? await maybeCompactAgentHarnessSession({
232
+ ...params,
233
+ contextEngine,
234
+ contextTokenBudget,
235
+ contextEngineRuntimeContext
236
+ }) : void 0;
237
+ if (harnessResult) {
238
+ if (!shouldFallbackAfterHarnessCompaction(harnessResult)) {
239
+ await contextEngine.dispose?.();
240
+ return harnessResult;
241
+ }
242
+ log$1.warn(`native harness compaction could not use its session binding; falling back to context engine: ${harnessResult.reason ?? "unknown"}`);
243
+ }
244
+ if (shouldDeferOwningContextEngineBudgetCompaction({
245
+ compactParams: params,
246
+ contextEngine
247
+ })) return await deferOwningContextEngineBudgetCompaction({
248
+ compactParams: params,
249
+ contextEngine,
250
+ contextEngineRuntimeContext
251
+ });
252
+ const sessionLane = resolveSessionLane(params.sessionKey?.trim() || params.sessionId);
253
+ const globalLane = resolveGlobalLane(params.lane);
254
+ const enqueueGlobal = params.enqueue ?? ((task, opts) => enqueueCommandInLane(globalLane, task, opts));
255
+ return enqueueCommandInLane(sessionLane, () => enqueueGlobal(async () => {
256
+ let checkpointSnapshot = null;
257
+ let checkpointSnapshotRetained = false;
258
+ try {
259
+ const engineOwnsCompaction = contextEngine.info.ownsCompaction === true;
260
+ checkpointSnapshot = engineOwnsCompaction ? await captureCompactionCheckpointSnapshotAsync({ sessionFile: params.sessionFile }) : null;
261
+ const hookRunner = engineOwnsCompaction ? asCompactionHookRunner(getGlobalHookRunner()) : null;
262
+ const hookSessionKey = params.sessionKey?.trim() || params.sessionId;
263
+ const { sessionAgentId } = resolveSessionAgentIds({
264
+ sessionKey: params.sessionKey,
265
+ config: params.config,
266
+ agentId: params.agentId
267
+ });
268
+ const resolvedMessageProvider = params.messageChannel ?? params.messageProvider;
269
+ const hookCtx = {
270
+ sessionId: params.sessionId,
271
+ agentId: sessionAgentId,
272
+ sessionKey: hookSessionKey,
273
+ workspaceDir: resolvedWorkspaceDir,
274
+ messageProvider: resolvedMessageProvider
275
+ };
276
+ const runtimeContext = contextEngineRuntimeContext;
277
+ if (hookRunner?.hasHooks?.("before_compaction") && hookRunner.runBeforeCompaction) try {
278
+ await hookRunner.runBeforeCompaction({
279
+ messageCount: -1,
280
+ sessionFile: params.sessionFile
281
+ }, hookCtx);
282
+ } catch (err) {
283
+ log$1.warn("before_compaction hook failed", { errorMessage: formatErrorMessage(err) });
284
+ }
285
+ let result;
286
+ try {
287
+ result = await compactContextEngineWithSafetyTimeout(contextEngine, {
288
+ sessionId: params.sessionId,
289
+ sessionKey: params.sessionKey,
290
+ sessionFile: params.sessionFile,
291
+ tokenBudget: contextTokenBudget,
292
+ currentTokenCount: params.currentTokenCount,
293
+ compactionTarget: params.trigger === "manual" ? "threshold" : "budget",
294
+ customInstructions: params.customInstructions,
295
+ force: params.trigger === "manual",
296
+ runtimeContext
297
+ }, resolveCompactionTimeoutMs(params.config), params.abortSignal);
298
+ } catch (compactErr) {
299
+ log$1.warn("context-engine compaction failed", { errorMessage: formatErrorMessage(compactErr) });
300
+ result = {
301
+ ok: false,
302
+ compacted: false,
303
+ reason: formatErrorMessage(compactErr)
304
+ };
305
+ }
306
+ const delegatedSessionId = result.result?.sessionId;
307
+ const delegatedSessionFile = result.result?.sessionFile;
308
+ const delegatedRotatedTranscript = typeof delegatedSessionId === "string" && delegatedSessionId !== params.sessionId || typeof delegatedSessionFile === "string" && delegatedSessionFile !== params.sessionFile;
309
+ let postCompactionSessionId = delegatedSessionId ?? params.sessionId;
310
+ let postCompactionSessionFile = delegatedSessionFile ?? params.sessionFile;
311
+ let postCompactionLeafId;
312
+ if (result.ok && result.compacted) {
313
+ if (shouldRotateCompactionTranscript(params.config) && !delegatedRotatedTranscript) try {
314
+ const rotation = await rotateTranscriptFileAfterCompaction({ sessionFile: params.sessionFile });
315
+ if (rotation.rotated) {
316
+ postCompactionSessionId = rotation.sessionId ?? postCompactionSessionId;
317
+ postCompactionSessionFile = rotation.sessionFile ?? postCompactionSessionFile;
318
+ postCompactionLeafId = rotation.leafId;
319
+ log$1.info(`[compaction] rotated active transcript after context-engine compaction (sessionKey=${params.sessionKey ?? params.sessionId})`);
320
+ }
321
+ } catch (err) {
322
+ log$1.warn("failed to rotate compacted transcript", { errorMessage: formatErrorMessage(err) });
323
+ }
324
+ if (params.config && params.sessionKey && checkpointSnapshot) try {
325
+ const postLeafId = postCompactionLeafId ?? await readSessionLeafIdFromTranscriptAsync(postCompactionSessionFile) ?? void 0;
326
+ checkpointSnapshotRetained = await persistSessionCompactionCheckpoint({
327
+ cfg: params.config,
328
+ sessionKey: params.sessionKey,
329
+ sessionId: postCompactionSessionId,
330
+ reason: resolveSessionCompactionCheckpointReason({ trigger: params.trigger }),
331
+ snapshot: checkpointSnapshot,
332
+ summary: result.result?.summary,
333
+ firstKeptEntryId: result.result?.firstKeptEntryId,
334
+ tokensBefore: result.result?.tokensBefore,
335
+ tokensAfter: result.result?.tokensAfter,
336
+ postSessionFile: postCompactionSessionFile,
337
+ postLeafId,
338
+ postEntryId: postLeafId
339
+ }) !== null;
340
+ } catch (err) {
341
+ log$1.warn("failed to persist compaction checkpoint", { errorMessage: formatErrorMessage(err) });
342
+ }
343
+ await runContextEngineMaintenance({
344
+ contextEngine,
345
+ sessionId: postCompactionSessionId,
346
+ sessionKey: params.sessionKey,
347
+ sessionFile: postCompactionSessionFile,
348
+ reason: "compaction",
349
+ runtimeContext,
350
+ config: params.config
351
+ });
352
+ }
353
+ if (engineOwnsCompaction && result.ok && result.compacted) await runPostCompactionSideEffects({
354
+ config: params.config,
355
+ sessionKey: params.sessionKey,
356
+ agentId: sessionAgentId,
357
+ sessionFile: postCompactionSessionFile
358
+ });
359
+ if (result.ok && result.compacted && hookRunner?.hasHooks?.("after_compaction") && hookRunner.runAfterCompaction) try {
360
+ const afterHookCtx = {
361
+ ...hookCtx,
362
+ sessionId: postCompactionSessionId
363
+ };
364
+ await hookRunner.runAfterCompaction({
365
+ messageCount: -1,
366
+ compactedCount: -1,
367
+ tokenCount: result.result?.tokensAfter,
368
+ sessionFile: postCompactionSessionFile
369
+ }, afterHookCtx);
370
+ } catch (err) {
371
+ log$1.warn("after_compaction hook failed", { errorMessage: formatErrorMessage(err) });
372
+ }
373
+ return {
374
+ ok: result.ok,
375
+ compacted: result.compacted,
376
+ reason: result.reason,
377
+ result: result.result ? {
378
+ summary: result.result.summary ?? "",
379
+ firstKeptEntryId: result.result.firstKeptEntryId ?? "",
380
+ tokensBefore: result.result.tokensBefore,
381
+ tokensAfter: result.result.tokensAfter,
382
+ details: result.result.details,
383
+ ...postCompactionSessionId !== params.sessionId ? { sessionId: postCompactionSessionId } : {},
384
+ ...postCompactionSessionFile !== params.sessionFile ? { sessionFile: postCompactionSessionFile } : {}
385
+ } : void 0
386
+ };
387
+ } finally {
388
+ if (!checkpointSnapshotRetained) await cleanupCompactionCheckpointSnapshot(checkpointSnapshot);
389
+ await contextEngine.dispose?.();
390
+ }
391
+ }));
392
+ }
393
+ function shouldAttemptNativeHarnessCompaction(params) {
394
+ if (isOpenAICodexProvider(params.provider)) return true;
395
+ const selectedRuntime = normalizeOptionalAgentRuntimeId(params.selectedHarnessRuntime);
396
+ if (!selectedRuntime || selectedRuntime === "auto" || selectedRuntime === "fengming") return false;
397
+ return isOpenAIProvider(params.provider) ? params.contextProvider !== void 0 : true;
398
+ }
399
+ function buildCompactionContextEngineRuntimeContext(params) {
400
+ const { sessionAgentId } = resolveSessionAgentIds({
401
+ sessionKey: params.params.sessionKey,
402
+ config: params.params.config,
403
+ agentId: params.params.agentId
404
+ });
405
+ return {
406
+ ...params.params,
407
+ ...buildEmbeddedCompactionRuntimeContext({
408
+ sessionKey: params.params.sessionKey,
409
+ messageChannel: params.params.messageChannel,
410
+ messageProvider: params.params.messageProvider,
411
+ agentAccountId: params.params.agentAccountId,
412
+ currentChannelId: params.params.currentChannelId,
413
+ currentThreadTs: params.params.currentThreadTs,
414
+ currentMessageId: params.params.currentMessageId,
415
+ authProfileId: params.params.authProfileId,
416
+ workspaceDir: params.params.workspaceDir,
417
+ cwd: params.params.cwd,
418
+ agentDir: params.agentDir,
419
+ config: params.params.config,
420
+ skillsSnapshot: params.params.skillsSnapshot,
421
+ senderIsOwner: params.params.senderIsOwner,
422
+ senderId: params.params.senderId,
423
+ provider: params.params.provider,
424
+ modelId: params.params.model,
425
+ harnessRuntime: params.harnessRuntime,
426
+ modelFallbacksOverride: params.params.modelFallbacksOverride,
427
+ thinkLevel: params.params.thinkLevel,
428
+ reasoningLevel: params.params.reasoningLevel,
429
+ bashElevated: params.params.bashElevated,
430
+ extraSystemPrompt: params.params.extraSystemPrompt,
431
+ sourceReplyDeliveryMode: params.params.sourceReplyDeliveryMode,
432
+ ownerNumbers: params.params.ownerNumbers
433
+ }),
434
+ ...resolveContextEngineCapabilities({
435
+ config: params.params.config,
436
+ sessionKey: params.params.sessionKey,
437
+ agentId: sessionAgentId,
438
+ authProfileId: params.params.authProfileId,
439
+ contextEnginePluginId: params.contextEnginePluginId,
440
+ purpose: "context-engine.compaction"
441
+ }),
442
+ tokenBudget: params.contextTokenBudget,
443
+ currentTokenCount: params.params.currentTokenCount
444
+ };
445
+ }
446
+ //#endregion
447
+ //#region src/agents/tool-error-summary.ts
448
+ const EXEC_LIKE_TOOL_NAMES = new Set(["exec", "bash"]);
449
+ function isExecLikeToolName(toolName) {
450
+ return EXEC_LIKE_TOOL_NAMES.has(normalizeOptionalLowercaseString(toolName) ?? "");
451
+ }
452
+ //#endregion
453
+ //#region src/agents/embedded-agent-runner/failure-signal.ts
454
+ const FAILURE_SIGNAL_CODES = ["SYSTEM_RUN_DENIED", "INVALID_REQUEST"];
455
+ function resolveFailureSignalCode(value) {
456
+ for (const code of FAILURE_SIGNAL_CODES) if (value === code) return code;
457
+ }
458
+ function resolveEmbeddedRunFailureSignal(params) {
459
+ if (params.trigger !== "cron") return;
460
+ const lastToolError = params.lastToolError;
461
+ if (!lastToolError || !isExecLikeToolName(lastToolError.toolName)) return;
462
+ const code = resolveFailureSignalCode(normalizeOptionalString(lastToolError.errorCode));
463
+ if (!code) return;
464
+ const message = normalizeOptionalString(lastToolError.error) ?? code;
465
+ return {
466
+ kind: "execution_denied",
467
+ source: "tool",
468
+ ...lastToolError.toolName ? { toolName: lastToolError.toolName } : {},
469
+ code,
470
+ message,
471
+ fatalForCron: true
472
+ };
473
+ }
474
+ //#endregion
475
+ //#region src/agents/embedded-agent-runner/post-compaction-loop-guard.ts
476
+ const log = createSubsystemLogger("agents/post-compaction-guard");
477
+ const DEFAULT_WINDOW_SIZE = 3;
478
+ function asPositiveInt(value, fallback) {
479
+ if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) return fallback;
480
+ return value;
481
+ }
482
+ function createPostCompactionLoopGuard(config, options) {
483
+ const state = {
484
+ enabled: options?.enabled ?? true,
485
+ windowSize: asPositiveInt(config?.windowSize, DEFAULT_WINDOW_SIZE),
486
+ remainingAttempts: 0,
487
+ history: []
488
+ };
489
+ const armPostCompaction = () => {
490
+ state.remainingAttempts = state.windowSize;
491
+ state.history = [];
492
+ if (state.enabled) log.info(`post-compaction guard armed for ${state.windowSize} attempts`);
493
+ };
494
+ const observe = (call) => {
495
+ if (!state.enabled) return {
496
+ shouldAbort: false,
497
+ armed: false,
498
+ remainingAttempts: 0
499
+ };
500
+ if (state.remainingAttempts <= 0) return {
501
+ shouldAbort: false,
502
+ armed: false,
503
+ remainingAttempts: 0
504
+ };
505
+ state.remainingAttempts -= 1;
506
+ state.history.push(call);
507
+ const armedAfter = state.remainingAttempts > 0;
508
+ const matches = state.history.filter((entry) => entry.toolName === call.toolName && entry.argsHash === call.argsHash && entry.resultHash === call.resultHash);
509
+ if (matches.length >= state.windowSize) {
510
+ log.error(`post-compaction loop persisted: tool=${call.toolName} repeated ${matches.length} times with identical args+result post-compaction`);
511
+ return {
512
+ shouldAbort: true,
513
+ armed: armedAfter,
514
+ remainingAttempts: state.remainingAttempts,
515
+ detector: "compaction_loop_persisted",
516
+ count: matches.length,
517
+ toolName: call.toolName,
518
+ message: `CRITICAL: tool ${call.toolName} repeated ${matches.length} times with identical arguments and identical results within ${state.windowSize} attempts after auto-compaction. The compaction did not break the loop. Aborting to prevent runaway resource use.`
519
+ };
520
+ }
521
+ return {
522
+ shouldAbort: false,
523
+ armed: armedAfter,
524
+ remainingAttempts: state.remainingAttempts
525
+ };
526
+ };
527
+ const snapshot = () => ({
528
+ armed: state.remainingAttempts > 0,
529
+ remainingAttempts: state.remainingAttempts
530
+ });
531
+ return {
532
+ armPostCompaction,
533
+ observe,
534
+ snapshot
535
+ };
536
+ }
537
+ var PostCompactionLoopPersistedError = class PostCompactionLoopPersistedError extends Error {
538
+ constructor(message, details) {
539
+ super(message);
540
+ this.name = "PostCompactionLoopPersistedError";
541
+ this.detector = details.detector;
542
+ this.count = details.count;
543
+ this.toolName = details.toolName;
544
+ }
545
+ static fromVerdict(verdict) {
546
+ return new PostCompactionLoopPersistedError(verdict.message, {
547
+ detector: verdict.detector,
548
+ count: verdict.count,
549
+ toolName: verdict.toolName
550
+ });
551
+ }
552
+ };
553
+ //#endregion
554
+ //#region src/agents/embedded-agent-runner/run/failover-policy.ts
555
+ function shouldEscalateRetryLimit(reason) {
556
+ return Boolean(reason && reason !== "timeout" && reason !== "model_not_found" && reason !== "format" && reason !== "session_expired");
557
+ }
558
+ function isTerminalFormatFailure(params) {
559
+ return params.failoverFailure && params.failoverReason === "format" && params.allowFormatRetry !== true;
560
+ }
561
+ function shouldRotatePrompt(params) {
562
+ return params.failoverFailure && params.failoverReason !== "timeout" && !isTerminalFormatFailure(params);
563
+ }
564
+ function isAssistantTimeoutFailure(params) {
565
+ return params.idleTimedOut || params.timedOut && !params.timedOutDuringCompaction && !params.timedOutDuringToolExecution;
566
+ }
567
+ function isConcreteNonTimeoutAssistantFailure(params) {
568
+ return params.failoverFailure && Boolean(params.failoverReason) && params.failoverReason !== "timeout";
569
+ }
570
+ function shouldRotateAssistant(params) {
571
+ if (isTerminalFormatFailure(params)) return false;
572
+ const timeoutFailure = isAssistantTimeoutFailure(params);
573
+ if (params.harnessOwnsTransport && (timeoutFailure || params.failoverReason === "timeout") && !isConcreteNonTimeoutAssistantFailure(params)) return false;
574
+ return !params.aborted && params.failoverFailure || timeoutFailure;
575
+ }
576
+ function assistantFallbackReason(params) {
577
+ const failoverReason = params.failoverReason;
578
+ if (params.failoverFailure && failoverReason && failoverReason !== "timeout") return failoverReason;
579
+ return isAssistantTimeoutFailure(params) ? "timeout" : failoverReason ?? "unknown";
580
+ }
581
+ function mergeRetryFailoverReason(params) {
582
+ return params.failoverReason ?? (params.timedOut ? "timeout" : null) ?? params.previous;
583
+ }
584
+ function resolveRunFailoverDecision(params) {
585
+ if (params.stage === "retry_limit") {
586
+ if (params.fallbackConfigured && shouldEscalateRetryLimit(params.failoverReason)) return {
587
+ action: "fallback_model",
588
+ reason: params.failoverReason ?? "unknown"
589
+ };
590
+ return { action: "return_error_payload" };
591
+ }
592
+ if (params.stage === "prompt") {
593
+ if (params.externalAbort) return {
594
+ action: "surface_error",
595
+ reason: params.failoverReason
596
+ };
597
+ if (params.harnessOwnsTransport && params.failoverReason === "timeout") return {
598
+ action: "surface_error",
599
+ reason: params.failoverReason
600
+ };
601
+ if (!params.profileRotated && shouldRotatePrompt(params)) return {
602
+ action: "rotate_profile",
603
+ reason: params.failoverReason
604
+ };
605
+ if (params.fallbackConfigured && params.failoverFailure && !isTerminalFormatFailure(params)) return {
606
+ action: "fallback_model",
607
+ reason: params.failoverReason ?? "unknown"
608
+ };
609
+ return {
610
+ action: "surface_error",
611
+ reason: params.failoverReason
612
+ };
613
+ }
614
+ if (params.externalAbort) return {
615
+ action: "surface_error",
616
+ reason: params.failoverReason
617
+ };
618
+ if (isTerminalFormatFailure(params)) return {
619
+ action: "surface_error",
620
+ reason: params.failoverReason
621
+ };
622
+ const assistantShouldRotate = shouldRotateAssistant(params);
623
+ if (!params.profileRotated && assistantShouldRotate) return {
624
+ action: "rotate_profile",
625
+ reason: params.failoverReason
626
+ };
627
+ if (assistantShouldRotate && params.fallbackConfigured) return {
628
+ action: "fallback_model",
629
+ reason: assistantFallbackReason(params)
630
+ };
631
+ if (!assistantShouldRotate) return { action: "continue_normal" };
632
+ return {
633
+ action: "surface_error",
634
+ reason: params.failoverReason
635
+ };
636
+ }
637
+ //#endregion
638
+ //#region src/agents/embedded-agent-runner/run/assistant-failover.ts
639
+ async function handleAssistantFailover(params) {
640
+ let overloadProfileRotations = params.overloadProfileRotations;
641
+ let decision = params.initialDecision;
642
+ const sameModelIdleTimeoutRetry = () => {
643
+ params.warn(`[llm-idle-timeout] ${sanitizeForLog(params.provider)}/${sanitizeForLog(params.modelId)} produced no reply before the idle watchdog; retrying same model`);
644
+ return {
645
+ action: "retry",
646
+ overloadProfileRotations,
647
+ retryKind: "same_model_idle_timeout",
648
+ lastRetryFailoverReason: mergeRetryFailoverReason({
649
+ previous: params.previousRetryFailoverReason,
650
+ failoverReason: params.failoverReason,
651
+ timedOut: true
652
+ })
653
+ };
654
+ };
655
+ if (decision.action === "rotate_profile") {
656
+ const failedProfileId = params.lastProfileId;
657
+ const timeoutFailure = params.timedOut || params.idleTimedOut;
658
+ const failureReason = params.assistantProfileFailureReason;
659
+ const markFailedProfile = async () => {
660
+ if (!failedProfileId || !failureReason) return;
661
+ try {
662
+ await params.maybeMarkAuthProfileFailure({
663
+ profileId: failedProfileId,
664
+ reason: failureReason,
665
+ modelId: params.modelId
666
+ });
667
+ } catch (err) {
668
+ params.warn(`profile failure mark failed: ${String(err)}`);
669
+ }
670
+ };
671
+ if (params.failoverReason === "overloaded") {
672
+ overloadProfileRotations += 1;
673
+ if (overloadProfileRotations > params.overloadProfileRotationLimit && params.fallbackConfigured) {
674
+ const status = resolveFailoverStatus("overloaded");
675
+ params.warn(`overload profile rotation cap reached for ${sanitizeForLog(params.provider)}/${sanitizeForLog(params.modelId)} after ${overloadProfileRotations} rotations; escalating to model fallback`);
676
+ await markFailedProfile();
677
+ params.logAssistantFailoverDecision("fallback_model", { status });
678
+ return {
679
+ action: "throw",
680
+ overloadProfileRotations,
681
+ error: new FailoverError("The AI service is temporarily overloaded. Please try again in a moment.", {
682
+ reason: "overloaded",
683
+ provider: params.activeErrorContext.provider,
684
+ model: params.activeErrorContext.model,
685
+ profileId: params.lastProfileId,
686
+ status,
687
+ rawError: params.lastAssistant?.errorMessage?.trim()
688
+ })
689
+ };
690
+ }
691
+ }
692
+ if (params.failoverReason === "rate_limit") params.maybeEscalateRateLimitProfileFallback({
693
+ failoverProvider: params.activeErrorContext.provider,
694
+ failoverModel: params.activeErrorContext.model,
695
+ logFallbackDecision: params.logAssistantFailoverDecision
696
+ });
697
+ const rotated = await params.advanceAuthProfile();
698
+ const markFailedProfilePromise = markFailedProfile();
699
+ if (timeoutFailure && !params.isProbeSession && failedProfileId) {
700
+ const timeoutLabel = params.idleTimedOut ? "idle timeout (model silent)" : "timed out";
701
+ params.warn(`Profile ${failedProfileId} ${timeoutLabel}. Trying next account...`);
702
+ }
703
+ if (params.cloudCodeAssistFormatError && failedProfileId) params.warn(`Profile ${failedProfileId} hit Cloud Code Assist format error. Tool calls will be sanitized on retry.`);
704
+ if (rotated) {
705
+ params.logAssistantFailoverDecision("rotate_profile");
706
+ await params.maybeBackoffBeforeOverloadFailover(params.failoverReason);
707
+ return {
708
+ action: "retry",
709
+ overloadProfileRotations,
710
+ lastRetryFailoverReason: mergeRetryFailoverReason({
711
+ previous: params.previousRetryFailoverReason,
712
+ failoverReason: params.failoverReason,
713
+ timedOut: params.timedOut || params.idleTimedOut
714
+ })
715
+ };
716
+ }
717
+ await markFailedProfilePromise;
718
+ if (params.idleTimedOut && params.allowSameModelIdleTimeoutRetry) return sameModelIdleTimeoutRetry();
719
+ decision = resolveRunFailoverDecision({
720
+ stage: "assistant",
721
+ allowFormatRetry: params.cloudCodeAssistFormatError,
722
+ aborted: params.aborted,
723
+ externalAbort: params.externalAbort,
724
+ fallbackConfigured: params.fallbackConfigured,
725
+ failoverFailure: params.failoverFailure,
726
+ failoverReason: params.failoverReason,
727
+ timedOut: params.timedOut,
728
+ idleTimedOut: params.idleTimedOut,
729
+ timedOutDuringCompaction: params.timedOutDuringCompaction,
730
+ timedOutDuringToolExecution: params.timedOutDuringToolExecution,
731
+ profileRotated: true
732
+ });
733
+ }
734
+ if (decision.action === "fallback_model") {
735
+ await params.maybeBackoffBeforeOverloadFailover(params.failoverReason);
736
+ const message = resolveAssistantFailoverErrorMessage(params);
737
+ const status = resolveFailoverStatus(decision.reason) ?? (isTimeoutErrorMessage(message) ? 408 : void 0);
738
+ params.logAssistantFailoverDecision("fallback_model", { status });
739
+ const shouldSuspend = Boolean(params.sessionKey) && (decision.reason === "rate_limit" || decision.reason === "billing");
740
+ return {
741
+ action: "throw",
742
+ overloadProfileRotations,
743
+ error: new FailoverError(message, {
744
+ reason: decision.reason,
745
+ provider: params.activeErrorContext.provider,
746
+ model: params.activeErrorContext.model,
747
+ profileId: params.lastProfileId,
748
+ status,
749
+ rawError: params.lastAssistant?.errorMessage?.trim(),
750
+ suspend: shouldSuspend
751
+ })
752
+ };
753
+ }
754
+ if (decision.action === "surface_error") {
755
+ if (!params.externalAbort && params.idleTimedOut && params.allowSameModelIdleTimeoutRetry) return sameModelIdleTimeoutRetry();
756
+ params.logAssistantFailoverDecision("surface_error");
757
+ if (!params.externalAbort && !params.timedOut && params.failoverFailure) {
758
+ const message = resolveAssistantFailoverErrorMessage(params);
759
+ const reason = resolveSurfaceErrorReason(decision.reason, params);
760
+ const status = resolveFailoverStatus(reason) ?? (isTimeoutErrorMessage(message) ? 408 : void 0);
761
+ const shouldSuspend = Boolean(params.sessionKey) && (reason === "rate_limit" || reason === "billing");
762
+ return {
763
+ action: "throw",
764
+ overloadProfileRotations,
765
+ error: new FailoverError(message, {
766
+ reason,
767
+ provider: params.activeErrorContext.provider,
768
+ model: params.activeErrorContext.model,
769
+ profileId: params.lastProfileId,
770
+ status,
771
+ rawError: params.lastAssistant?.errorMessage?.trim(),
772
+ suspend: shouldSuspend
773
+ })
774
+ };
775
+ }
776
+ }
777
+ return {
778
+ action: "continue_normal",
779
+ overloadProfileRotations
780
+ };
781
+ }
782
+ function resolveAssistantFailoverErrorMessage(params) {
783
+ const timeoutFailure = params.timedOut || params.idleTimedOut;
784
+ return (params.lastAssistant ? formatAssistantErrorText(params.lastAssistant, {
785
+ cfg: params.config,
786
+ sessionKey: params.sessionKey,
787
+ provider: params.activeErrorContext.provider,
788
+ model: params.activeErrorContext.model
789
+ }) : void 0) || params.lastAssistant?.errorMessage?.trim() || (timeoutFailure ? "LLM request timed out." : params.rateLimitFailure ? "LLM request rate limited." : params.billingFailure ? formatBillingErrorMessage(params.activeErrorContext.provider, params.activeErrorContext.model) : params.authFailure ? "LLM request unauthorized." : "LLM request failed.");
790
+ }
791
+ function resolveSurfaceErrorReason(declared, params) {
792
+ if (declared) return declared;
793
+ if (params.billingFailure) return "billing";
794
+ if (params.authFailure) return "auth";
795
+ if (params.rateLimitFailure) return "rate_limit";
796
+ return "unknown";
797
+ }
798
+ //#endregion
799
+ //#region src/agents/runtime-auth-refresh.ts
800
+ function clampRuntimeAuthRefreshDelayMs(params) {
801
+ return resolveSafeTimeoutDelayMs(params.refreshAt - params.now, { minMs: params.minDelayMs });
802
+ }
803
+ //#endregion
804
+ //#region src/agents/embedded-agent-runner/run/auth-controller.ts
805
+ function createEmbeddedRunAuthController(params) {
806
+ const applyPreparedRuntimeRequestOverrides = (paramsForApply) => {
807
+ if (!paramsForApply.preparedAuth.baseUrl && !paramsForApply.preparedAuth.request) return;
808
+ const runtimeRequestConfig = resolveProviderRequestConfig({
809
+ provider: paramsForApply.runtimeModel.provider,
810
+ api: paramsForApply.runtimeModel.api,
811
+ baseUrl: paramsForApply.preparedAuth.baseUrl ?? paramsForApply.runtimeModel.baseUrl,
812
+ providerHeaders: paramsForApply.runtimeModel.headers && typeof paramsForApply.runtimeModel.headers === "object" ? paramsForApply.runtimeModel.headers : void 0,
813
+ request: sanitizeRuntimeProviderRequestOverrides(paramsForApply.preparedAuth.request),
814
+ capability: "llm",
815
+ transport: "stream"
816
+ });
817
+ params.setRuntimeModel({
818
+ ...paramsForApply.runtimeModel,
819
+ ...paramsForApply.preparedAuth.baseUrl ? { baseUrl: paramsForApply.preparedAuth.baseUrl } : {},
820
+ ...runtimeRequestConfig.headers ? { headers: runtimeRequestConfig.headers } : {}
821
+ });
822
+ params.setEffectiveModel({
823
+ ...params.getEffectiveModel(),
824
+ ...paramsForApply.preparedAuth.baseUrl ? { baseUrl: paramsForApply.preparedAuth.baseUrl } : {},
825
+ ...runtimeRequestConfig.headers ? { headers: runtimeRequestConfig.headers } : {}
826
+ });
827
+ };
828
+ const hasRefreshableRuntimeAuth = () => Boolean(params.getRuntimeAuthState()?.sourceApiKey.trim());
829
+ const nextRuntimeAuthGeneration = () => (params.getRuntimeAuthState()?.generation ?? 0) + 1;
830
+ const prepareRuntimeAuthForModel = async (prepareParams) => prepareProviderRuntimeAuth({
831
+ provider: prepareParams.runtimeModel.provider,
832
+ config: params.config,
833
+ workspaceDir: params.workspaceDir,
834
+ env: process.env,
835
+ context: {
836
+ config: params.config,
837
+ agentDir: params.agentDir,
838
+ workspaceDir: params.workspaceDir,
839
+ env: process.env,
840
+ provider: prepareParams.runtimeModel.provider,
841
+ modelId: params.getModelId(),
842
+ model: prepareParams.runtimeModel,
843
+ apiKey: prepareParams.apiKey,
844
+ authMode: prepareParams.authMode,
845
+ profileId: prepareParams.profileId
846
+ }
847
+ });
848
+ const clearRuntimeAuthRefreshTimer = () => {
849
+ const runtimeAuthState = params.getRuntimeAuthState();
850
+ if (!runtimeAuthState?.refreshTimer) return;
851
+ clearTimeout(runtimeAuthState.refreshTimer);
852
+ runtimeAuthState.refreshTimer = void 0;
853
+ };
854
+ const stopRuntimeAuthRefreshTimer = () => {
855
+ if (!params.getRuntimeAuthState()) return;
856
+ params.setRuntimeAuthRefreshCancelled(true);
857
+ clearRuntimeAuthRefreshTimer();
858
+ };
859
+ const refreshRuntimeAuth = async (reason) => {
860
+ const runtimeAuthState = params.getRuntimeAuthState();
861
+ if (!runtimeAuthState) return;
862
+ if (runtimeAuthState.refreshInFlight) {
863
+ await runtimeAuthState.refreshInFlight;
864
+ return;
865
+ }
866
+ const refreshGeneration = runtimeAuthState.generation;
867
+ const refreshProfileId = runtimeAuthState.profileId;
868
+ let refreshPromise;
869
+ refreshPromise = (async () => {
870
+ const currentRuntimeAuthState = params.getRuntimeAuthState();
871
+ const sourceApiKey = currentRuntimeAuthState?.sourceApiKey.trim() ?? "";
872
+ if (!sourceApiKey) throw new Error(`Runtime auth refresh requires a source credential.`);
873
+ const runtimeModel = params.getRuntimeModel();
874
+ params.log.debug(`Refreshing runtime auth for ${runtimeModel.provider} (${reason})...`);
875
+ const preparedAuth = await prepareRuntimeAuthForModel({
876
+ runtimeModel,
877
+ apiKey: sourceApiKey,
878
+ authMode: currentRuntimeAuthState?.authMode ?? "unknown",
879
+ profileId: currentRuntimeAuthState?.profileId
880
+ });
881
+ if (!preparedAuth?.apiKey) throw new Error(`Provider "${runtimeModel.provider}" does not support runtime auth refresh.`);
882
+ const activeRuntimeAuthState = params.getRuntimeAuthState();
883
+ if (!activeRuntimeAuthState || activeRuntimeAuthState.generation !== refreshGeneration || activeRuntimeAuthState.profileId !== refreshProfileId || activeRuntimeAuthState.sourceApiKey.trim() !== sourceApiKey) {
884
+ params.log.debug(`Ignoring stale runtime auth refresh for ${runtimeModel.provider}; auth state advanced before ${reason} refresh completed.`);
885
+ return;
886
+ }
887
+ params.authStorage.setRuntimeApiKey(runtimeModel.provider, preparedAuth.apiKey);
888
+ applyPreparedRuntimeRequestOverrides({
889
+ runtimeModel,
890
+ preparedAuth
891
+ });
892
+ params.setRuntimeAuthState({
893
+ ...activeRuntimeAuthState,
894
+ expiresAt: preparedAuth.expiresAt
895
+ });
896
+ if (preparedAuth.expiresAt) {
897
+ const remaining = preparedAuth.expiresAt - Date.now();
898
+ params.log.debug(`Runtime auth refreshed for ${runtimeModel.provider}; expires in ${Math.max(0, Math.floor(remaining / 1e3))}s.`);
899
+ }
900
+ })().catch((err) => {
901
+ const runtimeModel = params.getRuntimeModel();
902
+ params.log.warn(`Runtime auth refresh failed for ${runtimeModel.provider}: ${formatErrorMessage(err)}`);
903
+ throw err;
904
+ }).finally(() => {
905
+ const activeState = params.getRuntimeAuthState();
906
+ if (activeState && activeState.generation === refreshGeneration && activeState.refreshInFlight === refreshPromise) activeState.refreshInFlight = void 0;
907
+ });
908
+ runtimeAuthState.refreshInFlight = refreshPromise;
909
+ await refreshPromise;
910
+ };
911
+ const scheduleRuntimeAuthRefresh = () => {
912
+ const runtimeAuthState = params.getRuntimeAuthState();
913
+ if (!runtimeAuthState || params.getRuntimeAuthRefreshCancelled()) return;
914
+ const runtimeModel = params.getRuntimeModel();
915
+ if (!hasRefreshableRuntimeAuth()) {
916
+ params.log.warn(`Skipping runtime auth refresh scheduling for ${runtimeModel.provider}; source credential missing.`);
917
+ return;
918
+ }
919
+ if (!runtimeAuthState.expiresAt) return;
920
+ clearRuntimeAuthRefreshTimer();
921
+ const now = Date.now();
922
+ const delayMs = clampRuntimeAuthRefreshDelayMs({
923
+ refreshAt: runtimeAuthState.expiresAt - RUNTIME_AUTH_REFRESH_MARGIN_MS,
924
+ now,
925
+ minDelayMs: RUNTIME_AUTH_REFRESH_MIN_DELAY_MS
926
+ });
927
+ const timer = setTimeout(() => {
928
+ if (params.getRuntimeAuthRefreshCancelled()) return;
929
+ refreshRuntimeAuth("scheduled").then(() => scheduleRuntimeAuthRefresh()).catch(() => {
930
+ if (params.getRuntimeAuthRefreshCancelled()) return;
931
+ const retryTimer = setTimeout(() => {
932
+ if (params.getRuntimeAuthRefreshCancelled()) return;
933
+ refreshRuntimeAuth("scheduled-retry").then(() => scheduleRuntimeAuthRefresh()).catch(() => void 0);
934
+ }, RUNTIME_AUTH_REFRESH_RETRY_MS);
935
+ const activeRuntimeAuthState = params.getRuntimeAuthState();
936
+ if (activeRuntimeAuthState) activeRuntimeAuthState.refreshTimer = retryTimer;
937
+ if (params.getRuntimeAuthRefreshCancelled() && activeRuntimeAuthState) {
938
+ clearTimeout(retryTimer);
939
+ activeRuntimeAuthState.refreshTimer = void 0;
940
+ }
941
+ });
942
+ }, delayMs);
943
+ runtimeAuthState.refreshTimer = timer;
944
+ if (params.getRuntimeAuthRefreshCancelled()) {
945
+ clearTimeout(timer);
946
+ runtimeAuthState.refreshTimer = void 0;
947
+ }
948
+ };
949
+ const resolveAuthProfileFailoverReason = (failoverParams) => {
950
+ if (failoverParams.allInCooldown) {
951
+ const profileIds = (failoverParams.profileIds ?? params.profileCandidates).filter((id) => typeof id === "string" && id.length > 0);
952
+ return resolveProfilesUnavailableReason({
953
+ store: params.authStore,
954
+ profileIds
955
+ }) ?? "unknown";
956
+ }
957
+ return classifyFailoverReason(failoverParams.message, { provider: params.getProvider() }) ?? "auth";
958
+ };
959
+ const throwAuthProfileFailover = (failoverParams) => {
960
+ const provider = params.getProvider();
961
+ const modelId = params.getModelId();
962
+ const fallbackMessage = `No available auth profile for ${provider} (all in cooldown or unavailable).`;
963
+ const message = failoverParams.message?.trim() || (failoverParams.error ? formatErrorMessage(failoverParams.error).trim() : "") || fallbackMessage;
964
+ const reason = resolveAuthProfileFailoverReason({
965
+ allInCooldown: failoverParams.allInCooldown,
966
+ message,
967
+ profileIds: params.profileCandidates
968
+ });
969
+ if (params.fallbackConfigured) throw new FailoverError(message, {
970
+ reason,
971
+ provider,
972
+ model: modelId,
973
+ status: resolveFailoverStatus(reason),
974
+ cause: failoverParams.error
975
+ });
976
+ if (failoverParams.error instanceof Error) throw failoverParams.error;
977
+ throw new Error(message);
978
+ };
979
+ const resolveApiKeyForCandidate = async (candidate) => {
980
+ return getApiKeyForModel({
981
+ model: params.getRuntimeModel(),
982
+ cfg: params.config,
983
+ profileId: candidate,
984
+ store: params.authStore,
985
+ agentDir: params.agentDir,
986
+ workspaceDir: params.workspaceDir,
987
+ lockedProfile: candidate != null && candidate === params.lockedProfileId
988
+ });
989
+ };
990
+ const applyApiKeyInfo = async (candidate) => {
991
+ const apiKeyInfo = await resolveApiKeyForCandidate(candidate);
992
+ params.setApiKeyInfo(apiKeyInfo);
993
+ const resolvedProfileId = apiKeyInfo.profileId ?? candidate;
994
+ if (!apiKeyInfo.apiKey) {
995
+ if (apiKeyInfo.mode !== "aws-sdk") {
996
+ const runtimeModel = params.getRuntimeModel();
997
+ throw new Error(formatMissingAuthError(apiKeyInfo, runtimeModel.provider));
998
+ }
999
+ const runtimeModel = params.getRuntimeModel();
1000
+ const AWS_SDK_AUTH_SENTINEL = "__aws_sdk_auth__";
1001
+ try {
1002
+ const preparedAuth = await prepareRuntimeAuthForModel({
1003
+ runtimeModel,
1004
+ apiKey: AWS_SDK_AUTH_SENTINEL,
1005
+ authMode: apiKeyInfo.mode,
1006
+ profileId: apiKeyInfo.profileId
1007
+ });
1008
+ applyPreparedRuntimeRequestOverrides({
1009
+ runtimeModel,
1010
+ preparedAuth: preparedAuth ?? {}
1011
+ });
1012
+ if (preparedAuth?.apiKey) {
1013
+ clearRuntimeAuthRefreshTimer();
1014
+ params.authStorage.setRuntimeApiKey(runtimeModel.provider, preparedAuth.apiKey);
1015
+ params.setRuntimeAuthState({
1016
+ generation: nextRuntimeAuthGeneration(),
1017
+ sourceApiKey: AWS_SDK_AUTH_SENTINEL,
1018
+ authMode: apiKeyInfo.mode,
1019
+ profileId: resolvedProfileId,
1020
+ expiresAt: preparedAuth.expiresAt
1021
+ });
1022
+ if (preparedAuth.expiresAt) scheduleRuntimeAuthRefresh();
1023
+ params.setLastProfileId(resolvedProfileId);
1024
+ return;
1025
+ }
1026
+ } catch (error) {
1027
+ params.log.warn(`prepareProviderRuntimeAuth failed for ${runtimeModel.provider}, falling back to sentinel: ${formatErrorMessage(error)}`);
1028
+ }
1029
+ clearRuntimeAuthRefreshTimer();
1030
+ params.authStorage.setRuntimeApiKey(runtimeModel.provider, AWS_SDK_AUTH_SENTINEL);
1031
+ params.setRuntimeAuthState(null);
1032
+ params.setLastProfileId(resolvedProfileId);
1033
+ return;
1034
+ }
1035
+ let runtimeAuthHandled = false;
1036
+ const runtimeModel = params.getRuntimeModel();
1037
+ const preparedAuth = await prepareRuntimeAuthForModel({
1038
+ runtimeModel,
1039
+ apiKey: apiKeyInfo.apiKey,
1040
+ authMode: apiKeyInfo.mode,
1041
+ profileId: apiKeyInfo.profileId
1042
+ });
1043
+ applyPreparedRuntimeRequestOverrides({
1044
+ runtimeModel,
1045
+ preparedAuth: preparedAuth ?? {}
1046
+ });
1047
+ if (preparedAuth?.apiKey) {
1048
+ clearRuntimeAuthRefreshTimer();
1049
+ params.authStorage.setRuntimeApiKey(runtimeModel.provider, preparedAuth.apiKey);
1050
+ params.setRuntimeAuthState({
1051
+ generation: nextRuntimeAuthGeneration(),
1052
+ sourceApiKey: apiKeyInfo.apiKey,
1053
+ authMode: apiKeyInfo.mode,
1054
+ profileId: apiKeyInfo.profileId,
1055
+ expiresAt: preparedAuth.expiresAt
1056
+ });
1057
+ if (preparedAuth.expiresAt) scheduleRuntimeAuthRefresh();
1058
+ runtimeAuthHandled = true;
1059
+ }
1060
+ if (!runtimeAuthHandled) {
1061
+ clearRuntimeAuthRefreshTimer();
1062
+ params.authStorage.setRuntimeApiKey(runtimeModel.provider, apiKeyInfo.apiKey);
1063
+ params.setRuntimeAuthState(null);
1064
+ }
1065
+ params.setLastProfileId(apiKeyInfo.profileId);
1066
+ };
1067
+ const advanceAuthProfile = async () => {
1068
+ if (params.lockedProfileId) return false;
1069
+ let nextIndex = params.getProfileIndex() + 1;
1070
+ while (nextIndex < params.profileCandidates.length) {
1071
+ const candidate = params.profileCandidates[nextIndex];
1072
+ if (candidate && isProfileInCooldown(params.authStore, candidate, void 0, params.getModelId())) {
1073
+ nextIndex += 1;
1074
+ continue;
1075
+ }
1076
+ try {
1077
+ await applyApiKeyInfo(candidate);
1078
+ params.setProfileIndex(nextIndex);
1079
+ params.setThinkLevel(params.initialThinkLevel);
1080
+ params.attemptedThinking.clear();
1081
+ return true;
1082
+ } catch (err) {
1083
+ if (candidate && candidate === params.lockedProfileId) throw err;
1084
+ nextIndex += 1;
1085
+ }
1086
+ }
1087
+ return false;
1088
+ };
1089
+ const initializeAuthProfile = async () => {
1090
+ try {
1091
+ const autoProfileCandidates = params.profileCandidates.filter((candidate) => typeof candidate === "string" && candidate.length > 0 && candidate !== params.lockedProfileId);
1092
+ const modelId = params.getModelId();
1093
+ const allAutoProfilesInCooldown = autoProfileCandidates.length > 0 && autoProfileCandidates.every((candidate) => isProfileInCooldown(params.authStore, candidate, void 0, modelId));
1094
+ const unavailableReason = allAutoProfilesInCooldown ? resolveProfilesUnavailableReason({
1095
+ store: params.authStore,
1096
+ profileIds: autoProfileCandidates
1097
+ }) ?? "unknown" : null;
1098
+ const allowTransientCooldownProbe = params.allowTransientCooldownProbe && allAutoProfilesInCooldown && shouldAllowCooldownProbeForReason(unavailableReason);
1099
+ let didTransientCooldownProbe = false;
1100
+ while (params.getProfileIndex() < params.profileCandidates.length) {
1101
+ const candidate = params.profileCandidates[params.getProfileIndex()];
1102
+ if (candidate && candidate !== params.lockedProfileId && isProfileInCooldown(params.authStore, candidate, void 0, modelId)) if (allowTransientCooldownProbe && !didTransientCooldownProbe) {
1103
+ didTransientCooldownProbe = true;
1104
+ params.log.warn(`probing cooldowned auth profile for ${params.getProvider()}/${modelId} due to ${unavailableReason ?? "transient"} unavailability`);
1105
+ } else {
1106
+ params.setProfileIndex(params.getProfileIndex() + 1);
1107
+ continue;
1108
+ }
1109
+ await applyApiKeyInfo(params.profileCandidates[params.getProfileIndex()]);
1110
+ break;
1111
+ }
1112
+ if (params.getProfileIndex() >= params.profileCandidates.length) throwAuthProfileFailover({ allInCooldown: true });
1113
+ } catch (err) {
1114
+ if (err instanceof FailoverError) throw err;
1115
+ if (params.profileCandidates[params.getProfileIndex()] === params.lockedProfileId) throwAuthProfileFailover({
1116
+ allInCooldown: false,
1117
+ error: err
1118
+ });
1119
+ if (!await advanceAuthProfile()) throwAuthProfileFailover({
1120
+ allInCooldown: false,
1121
+ error: err
1122
+ });
1123
+ }
1124
+ };
1125
+ const maybeRefreshRuntimeAuthForAuthError = async (errorText, retried) => {
1126
+ if (!params.getRuntimeAuthState() || retried) return false;
1127
+ if (!isFailoverErrorMessage(errorText, { provider: params.getProvider() })) return false;
1128
+ if (classifyFailoverReason(errorText, { provider: params.getProvider() }) !== "auth") return false;
1129
+ try {
1130
+ await refreshRuntimeAuth("auth-error");
1131
+ scheduleRuntimeAuthRefresh();
1132
+ return true;
1133
+ } catch {
1134
+ return false;
1135
+ }
1136
+ };
1137
+ return {
1138
+ advanceAuthProfile,
1139
+ initializeAuthProfile,
1140
+ maybeRefreshRuntimeAuthForAuthError,
1141
+ stopRuntimeAuthRefreshTimer
1142
+ };
1143
+ }
1144
+ //#endregion
1145
+ //#region src/agents/embedded-agent-runner/run/auth-profile-failure-policy.ts
1146
+ function resolveAuthProfileFailureReason(params) {
1147
+ if (params.policy === "local" || !params.failoverReason || params.failoverReason === "server_error" || params.failoverReason === "empty_response" || params.failoverReason === "format") return null;
1148
+ if (params.failoverReason === "timeout" && params.providerStarted !== true) return null;
1149
+ return params.failoverReason;
1150
+ }
1151
+ //#endregion
1152
+ //#region src/agents/embedded-agent-runner/run/backend.ts
1153
+ async function runEmbeddedAttemptWithBackend(params) {
1154
+ return runAgentHarnessAttempt(params);
1155
+ }
1156
+ //#endregion
1157
+ //#region src/agents/embedded-agent-runner/run/codex-app-server-recovery.ts
1158
+ function resolveCodexAppServerRecoveryRetry(params) {
1159
+ const failure = params.attempt.codexAppServerFailure;
1160
+ if (!failure) return {
1161
+ retry: false,
1162
+ reason: "not_codex_app_server_failure"
1163
+ };
1164
+ if (failure.kind !== "client_closed_before_turn_completed" && failure.kind !== "turn_completion_idle_timeout") return {
1165
+ retry: false,
1166
+ reason: failure.kind
1167
+ };
1168
+ if (failure.kind === "turn_completion_idle_timeout" && failure.turnWatchTimeoutKind !== "completion") return {
1169
+ retry: false,
1170
+ reason: failure.turnWatchTimeoutKind ?? "unknown_turn_watch_timeout"
1171
+ };
1172
+ if (failure.transport !== "stdio") return {
1173
+ retry: false,
1174
+ reason: "non_stdio_transport"
1175
+ };
1176
+ if (params.alreadyRetried) return {
1177
+ retry: false,
1178
+ reason: "retry_exhausted"
1179
+ };
1180
+ if (!failure.replaySafe || !params.attempt.replayMetadata.replaySafe) return {
1181
+ retry: false,
1182
+ reason: failure.replayBlockedReason ?? "replay_unsafe"
1183
+ };
1184
+ if (params.attempt.assistantTexts.some((text) => text.trim().length > 0)) return {
1185
+ retry: false,
1186
+ reason: "assistant_output"
1187
+ };
1188
+ if (params.attempt.toolMetas.length > 0 || params.attempt.clientToolCalls || params.attempt.lastToolError || params.attempt.didSendDeterministicApprovalPrompt) return {
1189
+ retry: false,
1190
+ reason: "tool_activity"
1191
+ };
1192
+ if (params.attempt.itemLifecycle.startedCount > 0 || params.attempt.itemLifecycle.activeCount > 0) return {
1193
+ retry: false,
1194
+ reason: "active_item"
1195
+ };
1196
+ return { retry: true };
1197
+ }
1198
+ //#endregion
1199
+ //#region src/agents/embedded-agent-runner/run/failover-observation.ts
1200
+ function normalizeFailoverDecisionObservationBase(base) {
1201
+ return {
1202
+ ...base,
1203
+ failoverReason: base.failoverReason ?? (base.timedOut ? "timeout" : null),
1204
+ profileFailureReason: base.profileFailureReason ?? (base.timedOut ? "timeout" : null)
1205
+ };
1206
+ }
1207
+ function createFailoverDecisionLogger(base) {
1208
+ const normalizedBase = normalizeFailoverDecisionObservationBase(base);
1209
+ const safeProfileId = normalizedBase.profileId ? redactIdentifier(normalizedBase.profileId, { len: 12 }) : void 0;
1210
+ const safeRunId = sanitizeForConsole(normalizedBase.runId) ?? "-";
1211
+ const safeProvider = sanitizeForConsole(normalizedBase.provider) ?? "-";
1212
+ const safeModel = sanitizeForConsole(normalizedBase.model) ?? "-";
1213
+ const safeSourceProvider = sanitizeForConsole(normalizedBase.sourceProvider) ?? safeProvider;
1214
+ const safeSourceModel = sanitizeForConsole(normalizedBase.sourceModel) ?? safeModel;
1215
+ const profileText = safeProfileId ?? "-";
1216
+ const reasonText = normalizedBase.failoverReason ?? "none";
1217
+ const sourceChanged = safeSourceProvider !== safeProvider || safeSourceModel !== safeModel;
1218
+ return (decision, extra) => {
1219
+ const observedError = buildApiErrorObservationFields(normalizedBase.rawError);
1220
+ const safeRawErrorPreview = sanitizeForConsole(observedError.rawErrorPreview);
1221
+ const rawErrorConsoleSuffix = safeRawErrorPreview && !shouldSuppressRawErrorConsoleSuffix(observedError.providerRuntimeFailureKind) ? ` rawError=${safeRawErrorPreview}` : "";
1222
+ log$1.warn("embedded run failover decision", {
1223
+ event: "embedded_run_failover_decision",
1224
+ tags: [
1225
+ "error_handling",
1226
+ "failover",
1227
+ normalizedBase.stage,
1228
+ decision
1229
+ ],
1230
+ runId: normalizedBase.runId,
1231
+ stage: normalizedBase.stage,
1232
+ decision,
1233
+ failoverReason: normalizedBase.failoverReason,
1234
+ profileFailureReason: normalizedBase.profileFailureReason,
1235
+ provider: normalizedBase.provider,
1236
+ model: normalizedBase.model,
1237
+ sourceProvider: normalizedBase.sourceProvider ?? normalizedBase.provider,
1238
+ sourceModel: normalizedBase.sourceModel ?? normalizedBase.model,
1239
+ profileId: safeProfileId,
1240
+ fallbackConfigured: normalizedBase.fallbackConfigured,
1241
+ timedOut: normalizedBase.timedOut,
1242
+ aborted: normalizedBase.aborted,
1243
+ status: extra?.status,
1244
+ ...observedError,
1245
+ consoleMessage: `embedded run failover decision: runId=${safeRunId} stage=${normalizedBase.stage} decision=${decision} reason=${reasonText} from=${safeSourceProvider}/${safeSourceModel}${sourceChanged ? ` to=${safeProvider}/${safeModel}` : ""} profile=${profileText}${rawErrorConsoleSuffix}`
1246
+ });
1247
+ };
1248
+ }
1249
+ //#endregion
1250
+ //#region src/agents/embedded-agent-runner/run/fallbacks.ts
1251
+ function hasEmbeddedRunConfiguredModelFallbacks(params) {
1252
+ if (params.modelFallbacksOverride !== void 0) return params.modelFallbacksOverride.length > 0;
1253
+ return hasConfiguredModelFallbacks({
1254
+ cfg: params.cfg,
1255
+ agentId: params.agentId,
1256
+ sessionKey: params.sessionKey
1257
+ });
1258
+ }
1259
+ function createIdleTimeoutBreakerState() {
1260
+ return { consecutiveIdleTimeoutsBeforeOutput: 0 };
1261
+ }
1262
+ /**
1263
+ * Update the breaker counter from the latest attempt's outcome and report
1264
+ * whether the cap is now tripped. Designed to be called from the outer run
1265
+ * loop right after an embedded attempt completes.
1266
+ *
1267
+ * Pure function modulo the mutable `state.consecutiveIdleTimeoutsBeforeOutput`
1268
+ * field, so the caller decides where the state lives (typically a `let` in
1269
+ * the outer loop).
1270
+ *
1271
+ * Decision table:
1272
+ * idleTimedOut completedModelProgress action
1273
+ * ------------ ---------------------- ------
1274
+ * true false count += 1 (wedged provider candidate)
1275
+ * true true count = 0 (model is alive but slow tail)
1276
+ * false true count = 0 (clean progress, all good)
1277
+ * false false count unchanged (e.g. non-timeout error;
1278
+ * don't poison or reset)
1279
+ *
1280
+ * The "false / false" branch matters: a non-timeout error attempt with no
1281
+ * completed progress should not reset the breaker (it isn't a sign the
1282
+ * provider is healthy), but it also shouldn't increment it (the issue at hand
1283
+ * is idle timeouts, not arbitrary errors).
1284
+ *
1285
+ * `outputTokens` is intentionally not part of the reset condition. Some
1286
+ * transports can accumulate billed output tokens from partial tool-call
1287
+ * argument deltas before the model stalls; those tokens are cost, not completed
1288
+ * progress, so they must not keep the breaker disarmed.
1289
+ */
1290
+ function stepIdleTimeoutBreaker(state, input, options) {
1291
+ const cap = options?.cap ?? 5;
1292
+ if (input.idleTimedOut && !input.completedModelProgress) state.consecutiveIdleTimeoutsBeforeOutput += 1;
1293
+ else if (input.completedModelProgress) state.consecutiveIdleTimeoutsBeforeOutput = 0;
1294
+ return {
1295
+ consecutive: state.consecutiveIdleTimeoutsBeforeOutput,
1296
+ tripped: cap > 0 && state.consecutiveIdleTimeoutsBeforeOutput >= cap
1297
+ };
1298
+ }
1299
+ //#endregion
1300
+ //#region src/agents/embedded-agent-runner/run/payloads.ts
1301
+ const RECOVERABLE_TOOL_ERROR_KEYWORDS = [
1302
+ "required",
1303
+ "missing",
1304
+ "invalid",
1305
+ "must be",
1306
+ "must have",
1307
+ "needs",
1308
+ "requires"
1309
+ ];
1310
+ const MUTATING_FAILURE_ACTION_PATTERN = "(?:write|edit|update|save|create|delete|remove|modify|change|apply|patch|move|rename|send|reply|message|run|execute|execution|command|script|shell|bash|exec|tool|action|operation)";
1311
+ const MUTATING_FAILURE_INABILITY_PATTERN = new RegExp(`\\b(?:couldn't|could not|can't|cannot|unable to|am unable to|wasn't able to|was not able to|were unable to)\\b.{0,100}\\b${MUTATING_FAILURE_ACTION_PATTERN}\\b`, "u");
1312
+ const MUTATING_FAILURE_ACTION_THEN_FAILURE_PATTERN = new RegExp(`\\b${MUTATING_FAILURE_ACTION_PATTERN}\\b.{0,100}\\b(?:failed|failure|errored)\\b`, "u");
1313
+ const MUTATING_FAILURE_FAILURE_THEN_ACTION_PATTERN = new RegExp(`\\b(?:failed|failure)\\b.{0,100}\\b${MUTATING_FAILURE_ACTION_PATTERN}\\b`, "u");
1314
+ const MUTATING_FAILURE_ERROR_WHILE_ACTION_PATTERN = new RegExp(`\\b(?:hit|encountered|ran into)\\b.{0,60}\\berror\\b.{0,100}\\b(?:while|trying to|when)\\b.{0,100}\\b${MUTATING_FAILURE_ACTION_PATTERN}\\b`, "u");
1315
+ const DID_NOT_FAIL_PATTERN = /\b(?:did not|didn't)\s+fail\b/u;
1316
+ const NEGATED_FAILURE_PATTERN = /\b(?:no|not|without)\s+(?:failures?|errors?)\b/u;
1317
+ function isRecoverableToolError(error) {
1318
+ const errorLower = normalizeOptionalLowercaseString(error) ?? "";
1319
+ return RECOVERABLE_TOOL_ERROR_KEYWORDS.some((keyword) => errorLower.includes(keyword));
1320
+ }
1321
+ function hasExplicitMutatingToolFailureAcknowledgement(text) {
1322
+ const normalizedText = normalizeTextForComparison(text);
1323
+ if (!normalizedText) return false;
1324
+ if (DID_NOT_FAIL_PATTERN.test(normalizedText)) return false;
1325
+ if (MUTATING_FAILURE_INABILITY_PATTERN.test(normalizedText)) return true;
1326
+ if (NEGATED_FAILURE_PATTERN.test(normalizedText)) return false;
1327
+ return MUTATING_FAILURE_ACTION_THEN_FAILURE_PATTERN.test(normalizedText) || MUTATING_FAILURE_FAILURE_THEN_ACTION_PATTERN.test(normalizedText) || MUTATING_FAILURE_ERROR_WHILE_ACTION_PATTERN.test(normalizedText);
1328
+ }
1329
+ function isVerboseToolDetailEnabled(level) {
1330
+ return level === "full";
1331
+ }
1332
+ function resolveRawAssistantAnswerText(lastAssistant) {
1333
+ if (!lastAssistant) return "";
1334
+ return normalizeOptionalString(extractAssistantTextForPhase(lastAssistant, { phase: "final_answer" }) ?? extractAssistantTextForPhase(lastAssistant)) ?? "";
1335
+ }
1336
+ function normalizeReplyTextForComparison(text) {
1337
+ return normalizeTextForComparison(parseReplyDirectives(text).text ?? "");
1338
+ }
1339
+ function shouldIncludeToolErrorDetails(params) {
1340
+ if (isVerboseToolDetailEnabled(params.verboseLevel)) return true;
1341
+ return isExecLikeToolName(params.lastToolError.toolName) && params.lastToolError.timedOut === true && (params.isCronTrigger === true || isCronSessionKey(params.sessionKey));
1342
+ }
1343
+ function shouldMarkNonTerminalToolErrorWarning(lastToolError) {
1344
+ return lastToolError.middlewareError === true;
1345
+ }
1346
+ function resolveToolErrorWarningPolicy(params) {
1347
+ const normalizedToolName = normalizeOptionalLowercaseString(params.lastToolError.toolName) ?? "";
1348
+ let toolErrorWarningOverride;
1349
+ let dynamicToolErrorWarningsDisabled = false;
1350
+ if (typeof params.suppressToolErrorWarnings === "function") {
1351
+ toolErrorWarningOverride = params.suppressToolErrorWarnings();
1352
+ dynamicToolErrorWarningsDisabled = toolErrorWarningOverride === false;
1353
+ } else toolErrorWarningOverride = params.suppressToolErrorWarnings;
1354
+ const includeDetails = shouldIncludeToolErrorDetails({
1355
+ ...params,
1356
+ verboseLevel: dynamicToolErrorWarningsDisabled ? "off" : params.verboseLevel
1357
+ });
1358
+ if (toolErrorWarningOverride === true) return {
1359
+ showWarning: false,
1360
+ includeDetails
1361
+ };
1362
+ if (normalizedToolName === "sessions_send") return {
1363
+ showWarning: false,
1364
+ includeDetails
1365
+ };
1366
+ if (params.suppressToolErrors) return {
1367
+ showWarning: false,
1368
+ includeDetails
1369
+ };
1370
+ if (params.lastToolError.mutatingAction ?? isLikelyMutatingToolName(params.lastToolError.toolName)) return {
1371
+ showWarning: !params.hasUserFacingErrorReply && !params.hasUserFacingFailureAcknowledgement,
1372
+ includeDetails
1373
+ };
1374
+ if (isExecLikeToolName(params.lastToolError.toolName) && !includeDetails) return {
1375
+ showWarning: false,
1376
+ includeDetails
1377
+ };
1378
+ return {
1379
+ showWarning: !params.hasUserFacingReply && !isRecoverableToolError(params.lastToolError.error),
1380
+ includeDetails
1381
+ };
1382
+ }
1383
+ function buildEmbeddedRunPayloads(params) {
1384
+ if (params.heartbeatToolResponse) return [createHeartbeatToolResponsePayload(params.heartbeatToolResponse)];
1385
+ const replyItems = [];
1386
+ const sourceReplyPayloads = params.sourceReplyDeliveryMode === "message_tool_only" ? params.messagingToolSourceReplyPayloads ?? [] : [];
1387
+ const sourceReplyStartIndex = replyItems.length;
1388
+ sourceReplyPayloads.forEach((payload, index) => {
1389
+ const text = normalizeOptionalString(payload.text) ?? "";
1390
+ const media = Array.from(new Set([...payload.mediaUrl ? [payload.mediaUrl] : [], ...payload.mediaUrls ?? []])).filter((value) => value.trim().length > 0);
1391
+ if (!text && media.length === 0 && !payload.presentation && !payload.interactive && !payload.channelData) return;
1392
+ replyItems.push({
1393
+ text,
1394
+ ...payload.mediaUrl ? { mediaUrl: payload.mediaUrl } : {},
1395
+ ...media.length ? { media } : {},
1396
+ ...payload.audioAsVoice ? { audioAsVoice: true } : {},
1397
+ ...payload.presentation ? { presentation: payload.presentation } : {},
1398
+ ...payload.interactive ? { interactive: payload.interactive } : {},
1399
+ ...payload.channelData ? { channelData: payload.channelData } : {},
1400
+ sourceReplyMirror: { idempotencyKey: payload.idempotencyKey ?? (params.runId ? `${params.runId}:internal-source-reply:${index}` : void 0) }
1401
+ });
1402
+ });
1403
+ const hasSourceReplyPayload = replyItems.length > sourceReplyStartIndex;
1404
+ const useMarkdown = params.toolResultFormat === "markdown";
1405
+ const suppressAssistantArtifacts = params.didSendDeterministicApprovalPrompt === true || hasSourceReplyPayload;
1406
+ const nonEmptyAssistantTexts = params.assistantTexts.filter((text) => text.trim().length > 0);
1407
+ const assistantForPayload = params.currentAssistant ?? void 0 ?? (nonEmptyAssistantTexts.length === 1 ? void 0 : params.lastAssistant);
1408
+ const lastAssistantStopReason = assistantForPayload?.stopReason;
1409
+ const lastAssistantErrored = lastAssistantStopReason === "error";
1410
+ const lastAssistantAborted = lastAssistantStopReason === "aborted";
1411
+ const runAborted = params.runAborted === true || lastAssistantAborted;
1412
+ const lastAssistantNeedsErrorSurface = lastAssistantErrored || lastAssistantAborted;
1413
+ const errorText = assistantForPayload && lastAssistantNeedsErrorSurface ? suppressAssistantArtifacts ? void 0 : formatAssistantErrorText(assistantForPayload, {
1414
+ cfg: params.config,
1415
+ sessionKey: params.sessionKey,
1416
+ provider: params.provider,
1417
+ model: params.model
1418
+ }) : void 0;
1419
+ const rawErrorMessage = lastAssistantNeedsErrorSurface ? normalizeOptionalString(assistantForPayload?.errorMessage) : void 0;
1420
+ const rawErrorFingerprint = rawErrorMessage ? getApiErrorPayloadFingerprint(rawErrorMessage) : null;
1421
+ const formattedRawErrorMessage = rawErrorMessage ? formatRawAssistantErrorForUi(rawErrorMessage) : null;
1422
+ const normalizedFormattedRawErrorMessage = formattedRawErrorMessage ? normalizeTextForComparison(formattedRawErrorMessage) : null;
1423
+ const normalizedRawErrorText = rawErrorMessage ? normalizeTextForComparison(rawErrorMessage) : null;
1424
+ const normalizedErrorText = errorText ? normalizeTextForComparison(errorText) : null;
1425
+ const normalizedGenericBillingErrorText = normalizeTextForComparison(BILLING_ERROR_USER_MESSAGE);
1426
+ const genericErrorText = "The AI service returned an error. Please try again.";
1427
+ if (errorText) replyItems.push({
1428
+ text: errorText,
1429
+ isError: true
1430
+ });
1431
+ if (params.inlineToolResultsAllowed && params.verboseLevel !== "off" && params.toolMetas.length > 0) for (const { toolName, meta } of params.toolMetas) {
1432
+ const { text: cleanedText, mediaUrls, audioAsVoice, replyToId, replyToTag, replyToCurrent } = parseReplyDirectives(formatToolAggregate(toolName, meta ? [meta] : [], { markdown: useMarkdown }));
1433
+ if (cleanedText) replyItems.push({
1434
+ text: cleanedText,
1435
+ media: mediaUrls,
1436
+ audioAsVoice,
1437
+ replyToId,
1438
+ replyToTag,
1439
+ replyToCurrent
1440
+ });
1441
+ }
1442
+ const reasoningText = suppressAssistantArtifacts || runAborted ? "" : assistantForPayload && params.reasoningLevel === "on" && params.thinkingLevel !== "off" ? extractAssistantThinking(assistantForPayload) : "";
1443
+ if (reasoningText) replyItems.push({
1444
+ text: reasoningText,
1445
+ isReasoning: true
1446
+ });
1447
+ const fallbackAnswerText = assistantForPayload ? extractAssistantVisibleText(assistantForPayload) : "";
1448
+ const fallbackRawAnswerText = resolveRawAssistantAnswerText(assistantForPayload);
1449
+ const shouldSuppressRawErrorText = (text) => {
1450
+ if (!lastAssistantNeedsErrorSurface) return false;
1451
+ const trimmed = text.trim();
1452
+ if (!trimmed) return false;
1453
+ if (errorText) {
1454
+ const normalized = normalizeTextForComparison(trimmed);
1455
+ if (normalized && normalizedErrorText && normalized === normalizedErrorText) return true;
1456
+ if (trimmed === genericErrorText) return true;
1457
+ if (normalized && normalizedGenericBillingErrorText && normalized === normalizedGenericBillingErrorText) return true;
1458
+ }
1459
+ if (rawErrorMessage && trimmed === rawErrorMessage) return true;
1460
+ if (formattedRawErrorMessage && trimmed === formattedRawErrorMessage) return true;
1461
+ if (normalizedRawErrorText) {
1462
+ const normalized = normalizeTextForComparison(trimmed);
1463
+ if (normalized && normalized === normalizedRawErrorText) return true;
1464
+ }
1465
+ if (normalizedFormattedRawErrorMessage) {
1466
+ const normalized = normalizeTextForComparison(trimmed);
1467
+ if (normalized && normalized === normalizedFormattedRawErrorMessage) return true;
1468
+ }
1469
+ if (rawErrorFingerprint) {
1470
+ const fingerprint = getApiErrorPayloadFingerprint(trimmed);
1471
+ if (fingerprint && fingerprint === rawErrorFingerprint) return true;
1472
+ }
1473
+ return isRawApiErrorPayload(trimmed);
1474
+ };
1475
+ const rawAnswerDirectiveState = fallbackRawAnswerText ? parseReplyDirectives(fallbackRawAnswerText) : null;
1476
+ const rawAnswerHasMedia = (rawAnswerDirectiveState?.mediaUrls?.length ?? 0) > 0 || rawAnswerDirectiveState?.audioAsVoice;
1477
+ const assistantTextsHaveMedia = params.assistantTexts.some((text) => {
1478
+ const parsed = parseReplyDirectives(text);
1479
+ return (parsed.mediaUrls?.length ?? 0) > 0 || parsed.audioAsVoice;
1480
+ });
1481
+ const normalizedAssistantTexts = normalizeTextForComparison(nonEmptyAssistantTexts.join("\n\n"));
1482
+ const normalizedRawAnswerText = normalizeTextForComparison(rawAnswerDirectiveState?.text ?? "");
1483
+ const shouldPreferRawAnswerText = rawAnswerHasMedia && (!nonEmptyAssistantTexts.length || !assistantTextsHaveMedia && normalizedAssistantTexts.length > 0 && normalizedAssistantTexts === normalizedRawAnswerText);
1484
+ const fallbackAnswerSourceText = shouldPreferRawAnswerText && fallbackRawAnswerText ? fallbackRawAnswerText : fallbackAnswerText;
1485
+ const normalizedFallbackAnswerSourceText = fallbackAnswerSourceText ? normalizeReplyTextForComparison(fallbackAnswerSourceText) : "";
1486
+ const shouldUseCanonicalFinalAnswer = !lastAssistantNeedsErrorSurface && fallbackAnswerSourceText.length > 0 && normalizedFallbackAnswerSourceText.length > 0;
1487
+ const hasAssistantTextPayload = nonEmptyAssistantTexts.length > 0;
1488
+ const answerTexts = suppressAssistantArtifacts || runAborted ? [] : (shouldUseCanonicalFinalAnswer ? [fallbackAnswerSourceText] : shouldPreferRawAnswerText && fallbackRawAnswerText ? [fallbackRawAnswerText] : hasAssistantTextPayload ? nonEmptyAssistantTexts : fallbackAnswerText ? [fallbackAnswerText] : []).filter((text) => !shouldSuppressRawErrorText(text));
1489
+ let hasUserFacingAssistantReply = hasSourceReplyPayload;
1490
+ const hasUserFacingErrorReply = replyItems.some((item) => item.isError === true);
1491
+ let hasUserFacingFailureAcknowledgement = false;
1492
+ for (const text of answerTexts) {
1493
+ const { text: cleanedText, mediaUrls, audioAsVoice, replyToId, replyToTag, replyToCurrent } = parseReplyDirectives(text);
1494
+ if (!cleanedText && (!mediaUrls || mediaUrls.length === 0) && !audioAsVoice) continue;
1495
+ replyItems.push({
1496
+ text: cleanedText,
1497
+ media: mediaUrls,
1498
+ audioAsVoice,
1499
+ replyToId,
1500
+ replyToTag,
1501
+ replyToCurrent
1502
+ });
1503
+ hasUserFacingAssistantReply = true;
1504
+ if (cleanedText && hasExplicitMutatingToolFailureAcknowledgement(cleanedText)) hasUserFacingFailureAcknowledgement = true;
1505
+ }
1506
+ if (params.lastToolError) {
1507
+ const warningPolicy = resolveToolErrorWarningPolicy({
1508
+ lastToolError: params.lastToolError,
1509
+ hasUserFacingReply: hasUserFacingAssistantReply,
1510
+ hasUserFacingErrorReply,
1511
+ hasUserFacingFailureAcknowledgement,
1512
+ suppressToolErrors: Boolean(params.config?.messages?.suppressToolErrors),
1513
+ suppressToolErrorWarnings: params.suppressToolErrorWarnings,
1514
+ isCronTrigger: params.isCronTrigger,
1515
+ sessionKey: params.sessionKey,
1516
+ verboseLevel: params.verboseLevel
1517
+ });
1518
+ if (warningPolicy.showWarning) {
1519
+ const warningText = `⚠️ ${formatToolAggregate(params.lastToolError.toolName, params.lastToolError.meta ? [params.lastToolError.meta] : void 0, { markdown: useMarkdown })} failed${warningPolicy.includeDetails && params.lastToolError.error ? `: ${params.lastToolError.error}` : ""}`;
1520
+ const normalizedWarning = normalizeTextForComparison(warningText);
1521
+ if (!(normalizedWarning ? replyItems.some((item) => {
1522
+ if (!item.text) return false;
1523
+ const normalizedExisting = normalizeTextForComparison(item.text);
1524
+ return normalizedExisting.length > 0 && normalizedExisting === normalizedWarning;
1525
+ }) : false)) replyItems.push({
1526
+ text: warningText,
1527
+ isError: true,
1528
+ nonTerminalToolErrorWarning: hasUserFacingAssistantReply && shouldMarkNonTerminalToolErrorWarning(params.lastToolError)
1529
+ });
1530
+ }
1531
+ }
1532
+ const hasAudioAsVoiceTag = replyItems.some((item) => item.audioAsVoice);
1533
+ return replyItems.map((item) => {
1534
+ const payload = { text: normalizeOptionalString(item.text) };
1535
+ const mediaUrl = item.mediaUrl ?? item.media?.[0];
1536
+ if (mediaUrl) payload.mediaUrl = mediaUrl;
1537
+ if (item.media?.length) payload.mediaUrls = item.media;
1538
+ if (item.isError !== void 0) payload.isError = item.isError;
1539
+ if (item.nonTerminalToolErrorWarning) setReplyPayloadMetadata(payload, { nonTerminalToolErrorWarning: true });
1540
+ if (item.replyToId) payload.replyToId = item.replyToId;
1541
+ if (item.replyToTag !== void 0) payload.replyToTag = item.replyToTag;
1542
+ if (item.replyToCurrent !== void 0) payload.replyToCurrent = item.replyToCurrent;
1543
+ if (item.audioAsVoice || Boolean(hasAudioAsVoiceTag && item.media?.length)) payload.audioAsVoice = true;
1544
+ if (item.presentation) payload.presentation = item.presentation;
1545
+ if (item.interactive) payload.interactive = item.interactive;
1546
+ if (item.channelData) payload.channelData = item.channelData;
1547
+ if (item.sourceReplyMirror) {
1548
+ markReplyPayloadForSourceSuppressionDelivery(payload);
1549
+ if (params.sessionKey) {
1550
+ const sourceReplyTranscriptMirror = { sessionKey: params.sessionKey };
1551
+ if (params.agentId) sourceReplyTranscriptMirror.agentId = params.agentId;
1552
+ if (payload.text) sourceReplyTranscriptMirror.text = payload.text;
1553
+ if (payload.mediaUrls?.length) sourceReplyTranscriptMirror.mediaUrls = payload.mediaUrls;
1554
+ if (item.sourceReplyMirror.idempotencyKey) sourceReplyTranscriptMirror.idempotencyKey = item.sourceReplyMirror.idempotencyKey;
1555
+ setReplyPayloadMetadata(payload, { sourceReplyTranscriptMirror });
1556
+ }
1557
+ }
1558
+ if (payload.text && isSilentReplyPayloadText(payload.text, "NO_REPLY")) {
1559
+ const silentText = payload.text;
1560
+ payload.text = void 0;
1561
+ if (hasReplyPayloadContent(payload)) return payload;
1562
+ payload.text = silentText;
1563
+ }
1564
+ return payload;
1565
+ }).filter((p) => {
1566
+ if (!hasReplyPayloadContent(p)) return false;
1567
+ if (p.text && isSilentReplyPayloadText(p.text, "NO_REPLY")) return false;
1568
+ return true;
1569
+ });
1570
+ }
1571
+ //#endregion
1572
+ //#region src/agents/embedded-agent-runner/run/retry-limit.ts
1573
+ function handleRetryLimitExhaustion(params) {
1574
+ if (params.decision.action === "fallback_model") throw new FailoverError(params.message, {
1575
+ reason: params.decision.reason,
1576
+ provider: params.provider,
1577
+ model: params.model,
1578
+ profileId: params.profileId,
1579
+ status: resolveFailoverStatus(params.decision.reason)
1580
+ });
1581
+ return {
1582
+ payloads: [{
1583
+ text: "Request failed after repeated internal retries. Please try again, or use /new to start a fresh session.",
1584
+ isError: true
1585
+ }],
1586
+ meta: {
1587
+ durationMs: params.durationMs,
1588
+ agentMeta: params.agentMeta,
1589
+ ...params.replayInvalid ? { replayInvalid: true } : {},
1590
+ ...params.livenessState ? { livenessState: params.livenessState } : {},
1591
+ error: {
1592
+ kind: "retry_limit",
1593
+ message: params.message
1594
+ }
1595
+ }
1596
+ };
1597
+ }
1598
+ //#endregion
1599
+ //#region src/agents/embedded-agent-runner/run/setup.ts
1600
+ async function resolveHookModelSelection(params) {
1601
+ let provider = params.provider;
1602
+ let modelId = params.modelId;
1603
+ let modelResolveOverride;
1604
+ let beforeAgentStartResult;
1605
+ const hookRunner = params.hookRunner;
1606
+ if (hookRunner?.hasHooks("before_model_resolve")) try {
1607
+ const event = params.attachments ? {
1608
+ prompt: params.prompt,
1609
+ attachments: params.attachments
1610
+ } : { prompt: params.prompt };
1611
+ modelResolveOverride = await hookRunner.runBeforeModelResolve(event, params.hookContext);
1612
+ } catch (hookErr) {
1613
+ log$1.warn(`before_model_resolve hook failed: ${String(hookErr)}`);
1614
+ }
1615
+ if (hookRunner?.hasHooks("before_agent_start")) try {
1616
+ beforeAgentStartResult = await hookRunner.runBeforeAgentStart({ prompt: params.prompt }, params.hookContext);
1617
+ modelResolveOverride = {
1618
+ providerOverride: modelResolveOverride?.providerOverride ?? beforeAgentStartResult?.providerOverride,
1619
+ modelOverride: modelResolveOverride?.modelOverride ?? beforeAgentStartResult?.modelOverride
1620
+ };
1621
+ } catch (hookErr) {
1622
+ log$1.warn(`deprecated before_agent_start hook failed during model resolve: ${String(hookErr)}`);
1623
+ }
1624
+ if (modelResolveOverride?.providerOverride) {
1625
+ provider = modelResolveOverride.providerOverride;
1626
+ log$1.info(`[hooks] provider overridden to ${provider}`);
1627
+ }
1628
+ if (modelResolveOverride?.modelOverride) {
1629
+ modelId = modelResolveOverride.modelOverride;
1630
+ log$1.info(`[hooks] model overridden to ${modelId}`);
1631
+ }
1632
+ return {
1633
+ provider,
1634
+ modelId,
1635
+ beforeAgentStartResult
1636
+ };
1637
+ }
1638
+ function buildBeforeModelResolveAttachments(images) {
1639
+ if (!images?.length) return;
1640
+ return images.map((img) => ({
1641
+ kind: "image",
1642
+ mimeType: img.mimeType
1643
+ }));
1644
+ }
1645
+ function resolveEffectiveRuntimeModel(params) {
1646
+ const ctxInfo = resolveContextWindowInfo({
1647
+ cfg: params.cfg,
1648
+ provider: params.contextConfigProvider ?? params.provider,
1649
+ modelId: params.modelId,
1650
+ modelContextTokens: readAgentModelContextTokens(params.runtimeModel),
1651
+ modelContextWindow: params.runtimeModel.contextWindow,
1652
+ defaultTokens: DEFAULT_CONTEXT_TOKENS
1653
+ });
1654
+ const effectiveModel = ctxInfo.tokens < (params.runtimeModel.contextWindow ?? Infinity) ? {
1655
+ ...params.runtimeModel,
1656
+ contextWindow: ctxInfo.tokens
1657
+ } : params.runtimeModel;
1658
+ const ctxGuard = evaluateContextWindowGuard({ info: ctxInfo });
1659
+ const runtimeBaseUrl = typeof params.runtimeModel.baseUrl === "string" ? params.runtimeModel.baseUrl : void 0;
1660
+ if (ctxGuard.shouldWarn) log$1.warn(formatContextWindowWarningMessage({
1661
+ provider: params.provider,
1662
+ modelId: params.modelId,
1663
+ guard: ctxGuard,
1664
+ runtimeBaseUrl
1665
+ }));
1666
+ if (ctxGuard.shouldBlock) {
1667
+ const message = formatContextWindowBlockMessage({
1668
+ guard: ctxGuard,
1669
+ runtimeBaseUrl
1670
+ });
1671
+ log$1.error(`blocked model (context window too small): ${params.provider}/${params.modelId} ctx=${ctxGuard.tokens} (min=${ctxGuard.hardMinTokens}) source=${ctxGuard.source}; ${message}`);
1672
+ throw new FailoverError(message, {
1673
+ reason: "unknown",
1674
+ provider: params.provider,
1675
+ model: params.modelId
1676
+ });
1677
+ }
1678
+ return {
1679
+ ctxInfo,
1680
+ effectiveModel
1681
+ };
1682
+ }
1683
+ //#endregion
1684
+ //#region src/agents/embedded-agent-runner/run/tool-media-payloads.ts
1685
+ function mergeAttemptToolMediaPayloads(params) {
1686
+ const mediaUrls = Array.from(new Set(params.toolMediaUrls?.map((url) => url.trim()).filter(Boolean) ?? []));
1687
+ if (mediaUrls.length === 0 && !params.toolAudioAsVoice && !params.toolTrustedLocalMedia) return params.payloads;
1688
+ const payloads = params.payloads?.length ? [...params.payloads] : [];
1689
+ const payloadIndex = payloads.findIndex((payload) => !payload.isReasoning);
1690
+ if (payloadIndex >= 0) {
1691
+ const payload = payloads[payloadIndex];
1692
+ if (params.sourceReplyDeliveryMode === "message_tool_only" && getReplyPayloadMetadata(payload)?.sourceReplyTranscriptMirror) return payloads;
1693
+ const mergedMediaUrls = Array.from(new Set([...payload.mediaUrls ?? [], ...mediaUrls]));
1694
+ payloads[payloadIndex] = copyReplyPayloadMetadata(payload, {
1695
+ ...payload,
1696
+ mediaUrls: mergedMediaUrls.length ? mergedMediaUrls : void 0,
1697
+ mediaUrl: payload.mediaUrl ?? mergedMediaUrls[0],
1698
+ audioAsVoice: payload.audioAsVoice || params.toolAudioAsVoice || void 0,
1699
+ trustedLocalMedia: payload.trustedLocalMedia || params.toolTrustedLocalMedia || void 0
1700
+ });
1701
+ return payloads;
1702
+ }
1703
+ return [...payloads, {
1704
+ mediaUrls: mediaUrls.length ? mediaUrls : void 0,
1705
+ mediaUrl: mediaUrls[0],
1706
+ audioAsVoice: params.toolAudioAsVoice || void 0,
1707
+ trustedLocalMedia: params.toolTrustedLocalMedia || void 0
1708
+ }];
1709
+ }
1710
+ //#endregion
1711
+ //#region src/agents/embedded-agent-runner/run.ts
1712
+ const MAX_SAME_MODEL_IDLE_TIMEOUT_RETRIES = 1;
1713
+ const EMBEDDED_RUN_LANE_TIMEOUT_GRACE_MS = 3e4;
1714
+ const MID_TURN_PRECHECK_CONTINUATION_PROMPT = "Continue from the current transcript after the latest tool result. Do not repeat the original user request, and do not rerun completed tools unless the transcript shows they are still needed.";
1715
+ const COMPACTION_CONTINUATION_RETRY_INSTRUCTION = "The previous attempt compacted the conversation context before producing a final user-visible answer. Continue from the compacted transcript and produce the final answer now. Do not restart from scratch, do not repeat completed work, and do not rerun tools unless the transcript clearly lacks required evidence.";
1716
+ const NO_REAL_CONVERSATION_MESSAGES_REASON = "no real conversation messages";
1717
+ function isNoRealConversationCompactionNoop(params) {
1718
+ return params.ok === true && params.compacted === false && params.reason === NO_REAL_CONVERSATION_MESSAGES_REASON;
1719
+ }
1720
+ async function resetNoRealConversationTokenSnapshot(params) {
1721
+ if (!params.sessionKey) return;
1722
+ const storePath = resolveStorePath(params.config?.session?.store, { agentId: params.agentId });
1723
+ try {
1724
+ await updateSessionStoreEntry({
1725
+ storePath,
1726
+ sessionKey: params.sessionKey,
1727
+ skipMaintenance: true,
1728
+ takeCacheOwnership: true,
1729
+ update: async () => ({
1730
+ totalTokens: 0,
1731
+ totalTokensFresh: true,
1732
+ inputTokens: void 0,
1733
+ outputTokens: void 0,
1734
+ cacheRead: void 0,
1735
+ cacheWrite: void 0,
1736
+ contextBudgetStatus: void 0,
1737
+ updatedAt: Date.now()
1738
+ })
1739
+ });
1740
+ } catch (err) {
1741
+ log$1.warn(`[context-overflow-precheck] failed to reset stale context snapshot for ${params.sessionKey}: ${String(err)}`);
1742
+ }
1743
+ }
1744
+ function resolveAttemptDispatchApiKey(params) {
1745
+ if (params.runtimeAuthState) return;
1746
+ return params.apiKeyInfo?.apiKey;
1747
+ }
1748
+ function resolveEmbeddedRunLaneTimeoutMs(timeoutMs) {
1749
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) return;
1750
+ return Math.floor(timeoutMs) + EMBEDDED_RUN_LANE_TIMEOUT_GRACE_MS;
1751
+ }
1752
+ function withEmbeddedRunLaneTimeout(opts, laneTaskTimeoutMs) {
1753
+ if (laneTaskTimeoutMs === void 0 || opts?.taskTimeoutMs !== void 0) return opts;
1754
+ return {
1755
+ ...opts,
1756
+ taskTimeoutMs: laneTaskTimeoutMs
1757
+ };
1758
+ }
1759
+ function resolveEmbeddedRunSessionQueuePriority(trigger) {
1760
+ switch (trigger) {
1761
+ case "user":
1762
+ case "manual": return "foreground";
1763
+ case "cron":
1764
+ case "heartbeat":
1765
+ case "memory":
1766
+ case "overflow": return "background";
1767
+ default: return "normal";
1768
+ }
1769
+ }
1770
+ function normalizeEmbeddedRunAttemptResult(attempt) {
1771
+ const raw = attempt;
1772
+ return {
1773
+ ...attempt,
1774
+ assistantTexts: raw.assistantTexts ?? [],
1775
+ toolMetas: raw.toolMetas ?? [],
1776
+ acceptedSessionSpawns: raw.acceptedSessionSpawns ?? [],
1777
+ messagesSnapshot: raw.messagesSnapshot ?? [],
1778
+ messagingToolSentTexts: raw.messagingToolSentTexts ?? [],
1779
+ messagingToolSentMediaUrls: raw.messagingToolSentMediaUrls ?? [],
1780
+ messagingToolSentTargets: raw.messagingToolSentTargets ?? [],
1781
+ messagingToolSourceReplyPayloads: raw.messagingToolSourceReplyPayloads ?? [],
1782
+ itemLifecycle: raw.itemLifecycle ?? {
1783
+ startedCount: 0,
1784
+ completedCount: 0,
1785
+ activeCount: 0
1786
+ },
1787
+ replayMetadata: resolveAttemptReplayMetadata(raw)
1788
+ };
1789
+ }
1790
+ function hasCompletedModelProgressForIdleBreaker(attempt) {
1791
+ return attempt.assistantTexts.some((text) => text.trim().length > 0) || attempt.toolMetas.length > 0 || (attempt.clientToolCalls?.length ?? 0) > 0 || hasOutboundDeliveryEvidence(attempt) || attempt.itemLifecycle.completedCount > 0;
1792
+ }
1793
+ function createEmptyAuthProfileStore() {
1794
+ return {
1795
+ version: 1,
1796
+ profiles: {}
1797
+ };
1798
+ }
1799
+ function createScopedAuthProfileStore(store, profileIds) {
1800
+ const profiles = store.profiles ?? {};
1801
+ const normalizedProfileIds = (Array.isArray(profileIds) ? profileIds : [profileIds]).map((profileId) => profileId?.trim()).filter((profileId) => !!profileId);
1802
+ const scopedProfiles = Object.fromEntries(normalizedProfileIds.flatMap((profileId) => {
1803
+ const credential = profiles[profileId];
1804
+ return credential ? [[profileId, credential]] : [];
1805
+ }));
1806
+ return Object.keys(scopedProfiles).length > 0 ? {
1807
+ version: store.version,
1808
+ profiles: scopedProfiles
1809
+ } : createEmptyAuthProfileStore();
1810
+ }
1811
+ function buildTraceToolSummary(params) {
1812
+ if (!params.toolMetas?.length) return;
1813
+ const tools = [];
1814
+ const seen = /* @__PURE__ */ new Set();
1815
+ for (const entry of params.toolMetas) {
1816
+ const toolName = normalizeOptionalString(entry.toolName);
1817
+ if (!toolName || seen.has(toolName)) continue;
1818
+ seen.add(toolName);
1819
+ tools.push(toolName);
1820
+ }
1821
+ return {
1822
+ calls: params.toolMetas?.length ?? 0,
1823
+ tools,
1824
+ failures: params.hadFailure ? 1 : 0
1825
+ };
1826
+ }
1827
+ /**
1828
+ * Best-effort backfill of sessionKey from sessionId when not explicitly provided.
1829
+ * The return value is normalized: whitespace-only inputs collapse to undefined, and
1830
+ * successful resolution returns a trimmed session key. This is a read-only lookup
1831
+ * with no side effects.
1832
+ * See: https://github.com/fengming/fengming/issues/60552
1833
+ */
1834
+ function backfillSessionKey(params) {
1835
+ const trimmed = normalizeOptionalString(params.sessionKey);
1836
+ if (trimmed) return trimmed;
1837
+ if (!params.config || !params.sessionId) return;
1838
+ try {
1839
+ return normalizeOptionalString((normalizeOptionalString(params.agentId) ? resolveStoredSessionKeyForSessionId({
1840
+ cfg: params.config,
1841
+ sessionId: params.sessionId,
1842
+ agentId: params.agentId
1843
+ }) : resolveSessionKeyForRequest({
1844
+ cfg: params.config,
1845
+ sessionId: params.sessionId,
1846
+ clone: false
1847
+ })).sessionKey);
1848
+ } catch (err) {
1849
+ log$1.warn(`[backfillSessionKey] Failed to resolve sessionKey for sessionId=${redactRunIdentifier(sanitizeForLog(params.sessionId))}: ${formatErrorMessage(err)}`);
1850
+ return;
1851
+ }
1852
+ }
1853
+ function buildHandledReplyPayloads(reply) {
1854
+ const normalized = reply ?? { text: "NO_REPLY" };
1855
+ return [{
1856
+ text: normalized.text,
1857
+ mediaUrl: normalized.mediaUrl,
1858
+ mediaUrls: normalized.mediaUrls,
1859
+ replyToId: normalized.replyToId,
1860
+ audioAsVoice: normalized.audioAsVoice,
1861
+ isError: normalized.isError,
1862
+ isReasoning: normalized.isReasoning
1863
+ }];
1864
+ }
1865
+ async function runEmbeddedAgent(params) {
1866
+ const effectiveSessionKey = backfillSessionKey({
1867
+ config: params.config,
1868
+ sessionId: params.sessionId,
1869
+ sessionKey: params.sessionKey,
1870
+ agentId: params.agentId
1871
+ });
1872
+ if (effectiveSessionKey !== params.sessionKey) params = {
1873
+ ...params,
1874
+ sessionKey: effectiveSessionKey
1875
+ };
1876
+ const sessionLane = resolveSessionLane(params.sessionKey?.trim() || params.sessionId);
1877
+ const globalLane = resolveGlobalLane(params.lane);
1878
+ const sessionQueuePriority = resolveEmbeddedRunSessionQueuePriority(params.trigger);
1879
+ const laneTaskTimeoutMs = resolveEmbeddedRunLaneTimeoutMs(params.timeoutMs);
1880
+ let laneTaskProgressAtMs = Date.now();
1881
+ const noteLaneTaskProgress = () => {
1882
+ laneTaskProgressAtMs = Date.now();
1883
+ };
1884
+ const withLaneTimeout = (opts) => withEmbeddedRunLaneTimeout({
1885
+ ...opts,
1886
+ taskTimeoutProgressAtMs: () => laneTaskProgressAtMs
1887
+ }, laneTaskTimeoutMs);
1888
+ const enqueueGlobal = (task, opts) => {
1889
+ const globalOpts = {
1890
+ ...opts,
1891
+ priority: sessionQueuePriority
1892
+ };
1893
+ return params.enqueue ? params.enqueue(task, withLaneTimeout(globalOpts)) : enqueueCommandInLane(globalLane, task, withLaneTimeout(globalOpts));
1894
+ };
1895
+ const enqueueSession = (task, opts) => {
1896
+ const sessionOpts = {
1897
+ ...opts,
1898
+ priority: sessionQueuePriority
1899
+ };
1900
+ return params.enqueue ? params.enqueue(task, sessionOpts) : enqueueCommandInLane(sessionLane, task, sessionOpts);
1901
+ };
1902
+ const channelHint = params.messageChannel ?? params.messageProvider;
1903
+ const resolvedToolResultFormat = params.toolResultFormat ?? (channelHint ? isMarkdownCapableMessageChannel(channelHint) ? "markdown" : "plain" : "markdown");
1904
+ const isProbeSession = params.sessionId?.startsWith("probe-") ?? false;
1905
+ const throwIfAborted = () => {
1906
+ if (!params.abortSignal?.aborted) return;
1907
+ const reason = params.abortSignal.reason;
1908
+ if (reason instanceof Error) throw reason;
1909
+ const abortErr = reason !== void 0 ? new Error("操作已中止", { cause: reason }) : /* @__PURE__ */ new Error("操作已中止");
1910
+ abortErr.name = "AbortError";
1911
+ throw abortErr;
1912
+ };
1913
+ throwIfAborted();
1914
+ return enqueueSession(() => {
1915
+ throwIfAborted();
1916
+ return enqueueGlobal(async () => {
1917
+ throwIfAborted();
1918
+ const started = Date.now();
1919
+ const startupStages = createEmbeddedRunStageTracker();
1920
+ let startupStagesEmitted = false;
1921
+ const notifyExecutionPhase = (phase, extra) => {
1922
+ noteLaneTaskProgress();
1923
+ params.onExecutionPhase?.({
1924
+ phase,
1925
+ ...extra
1926
+ });
1927
+ };
1928
+ const notifyRunProgress = (info) => {
1929
+ noteLaneTaskProgress();
1930
+ params.onRunProgress?.(info);
1931
+ };
1932
+ const emitStartupStageSummary = (phase) => {
1933
+ const summary = startupStages.snapshot();
1934
+ const shouldWarn = shouldWarnEmbeddedRunStageSummary(summary);
1935
+ if (!shouldWarn && !log$1.isEnabled("trace")) return;
1936
+ const message = formatEmbeddedRunStageSummary(`[trace:embedded-run] startup stages: runId=${params.runId} sessionId=${params.sessionId} phase=${phase}`, summary);
1937
+ if (shouldWarn) log$1.warn(message);
1938
+ else log$1.trace(message);
1939
+ };
1940
+ params.onExecutionStarted?.();
1941
+ notifyExecutionPhase("runner_entered");
1942
+ const workspaceResolution = resolveRunWorkspaceDir({
1943
+ workspaceDir: params.workspaceDir,
1944
+ sessionKey: params.sessionKey,
1945
+ agentId: params.agentId,
1946
+ config: params.config
1947
+ });
1948
+ const resolvedWorkspace = workspaceResolution.workspaceDir;
1949
+ const isCanonicalWorkspace = resolveUserPath(resolveAgentWorkspaceDir(params.config ?? {}, workspaceResolution.agentId)) === resolvedWorkspace;
1950
+ const redactedSessionId = redactRunIdentifier(params.sessionId);
1951
+ const redactedSessionKey = redactRunIdentifier(params.sessionKey);
1952
+ const redactedWorkspace = redactRunIdentifier(resolvedWorkspace);
1953
+ if (workspaceResolution.usedFallback) log$1.warn(`[workspace-fallback] caller=runEmbeddedAgent reason=${workspaceResolution.fallbackReason} run=${params.runId} session=${redactedSessionId} sessionKey=${redactedSessionKey} agent=${workspaceResolution.agentId} workspace=${redactedWorkspace}`);
1954
+ startupStages.mark("workspace");
1955
+ notifyExecutionPhase("workspace");
1956
+ ensureRuntimePluginsLoaded({
1957
+ config: params.config,
1958
+ workspaceDir: resolvedWorkspace,
1959
+ allowGatewaySubagentBinding: params.allowGatewaySubagentBinding
1960
+ });
1961
+ startupStages.mark("runtime-plugins");
1962
+ notifyExecutionPhase("runtime_plugins");
1963
+ let provider = (params.provider ?? "byteplus").trim() || "byteplus";
1964
+ let modelId = (params.model ?? "doubao-pro-32k").trim() || "doubao-pro-32k";
1965
+ const agentDir = params.agentDir ?? resolveAgentDir(params.config ?? {}, workspaceResolution.agentId);
1966
+ const normalizedSessionKey = params.sessionKey?.trim();
1967
+ const fallbackConfigured = hasEmbeddedRunConfiguredModelFallbacks({
1968
+ cfg: params.config,
1969
+ agentId: params.agentId,
1970
+ sessionKey: normalizedSessionKey,
1971
+ modelFallbacksOverride: params.modelFallbacksOverride
1972
+ });
1973
+ const resolvedSessionKey = normalizedSessionKey;
1974
+ const hookRunner = getGlobalHookRunner();
1975
+ const hookCtx = {
1976
+ runId: params.runId,
1977
+ jobId: params.jobId,
1978
+ agentId: workspaceResolution.agentId,
1979
+ sessionKey: resolvedSessionKey,
1980
+ sessionId: params.sessionId,
1981
+ workspaceDir: resolvedWorkspace,
1982
+ modelProviderId: provider,
1983
+ modelId,
1984
+ trigger: params.trigger,
1985
+ ...buildAgentHookContextChannelFields(params)
1986
+ };
1987
+ if (params.trigger === "cron" && hookRunner?.hasHooks("before_agent_reply")) {
1988
+ notifyExecutionPhase("before_agent_reply", {
1989
+ provider,
1990
+ model: modelId
1991
+ });
1992
+ const hookResult = await hookRunner.runBeforeAgentReply({ cleanedBody: params.prompt }, hookCtx);
1993
+ if (hookResult?.handled) return {
1994
+ payloads: buildHandledReplyPayloads(hookResult.reply),
1995
+ meta: {
1996
+ durationMs: Date.now() - started,
1997
+ agentMeta: {
1998
+ sessionId: params.sessionId,
1999
+ provider,
2000
+ model: modelId
2001
+ },
2002
+ finalAssistantVisibleText: hookResult.reply?.text ?? "NO_REPLY",
2003
+ finalAssistantRawText: hookResult.reply?.text ?? "NO_REPLY"
2004
+ }
2005
+ };
2006
+ notifyExecutionPhase("runtime_plugins", {
2007
+ provider,
2008
+ model: modelId
2009
+ });
2010
+ }
2011
+ const hookSelection = await resolveHookModelSelection({
2012
+ prompt: params.prompt,
2013
+ attachments: buildBeforeModelResolveAttachments(params.images),
2014
+ provider,
2015
+ modelId,
2016
+ hookRunner,
2017
+ hookContext: hookCtx
2018
+ });
2019
+ provider = hookSelection.provider;
2020
+ modelId = hookSelection.modelId;
2021
+ const beforeAgentStartResult = hookSelection.beforeAgentStartResult;
2022
+ startupStages.mark("hooks");
2023
+ await ensureSelectedAgentHarnessPlugin({
2024
+ provider,
2025
+ modelId,
2026
+ config: params.config,
2027
+ agentId: params.agentId,
2028
+ sessionKey: params.sessionKey,
2029
+ agentHarnessRuntimeOverride: params.agentHarnessRuntimeOverride,
2030
+ workspaceDir: resolvedWorkspace
2031
+ });
2032
+ const agentHarness = selectAgentHarness({
2033
+ provider,
2034
+ modelId,
2035
+ config: params.config,
2036
+ agentId: params.agentId,
2037
+ sessionKey: params.sessionKey,
2038
+ agentHarnessId: params.agentHarnessId,
2039
+ agentHarnessRuntimeOverride: params.agentHarnessRuntimeOverride
2040
+ });
2041
+ const pluginHarnessOwnsTransport = agentHarness.id !== "fengming";
2042
+ const modelConfigProvider = provider;
2043
+ const selectedRuntimeProvider = resolveSelectedOpenAIRuntimeProvider({
2044
+ provider,
2045
+ harnessRuntime: agentHarness.id,
2046
+ agentHarnessId: agentHarness.id,
2047
+ authProfileProvider: params.authProfileId?.split(":", 1)[0],
2048
+ authProfileId: params.authProfileId,
2049
+ config: params.config,
2050
+ workspaceDir: resolvedWorkspace
2051
+ });
2052
+ const modelResolutionProviders = selectedRuntimeProvider !== provider ? [selectedRuntimeProvider, provider] : [provider];
2053
+ let resolvedModelProvider = provider;
2054
+ let firstModelResolution;
2055
+ let modelResolution;
2056
+ for (const candidateProvider of modelResolutionProviders) {
2057
+ const candidateResolution = await resolveModelAsync(candidateProvider, modelId, agentDir, params.config, {
2058
+ skipAgentDiscovery: true,
2059
+ workspaceDir: resolvedWorkspace,
2060
+ authProfileId: params.authProfileId
2061
+ });
2062
+ firstModelResolution ??= candidateResolution;
2063
+ if (candidateResolution.model) {
2064
+ resolvedModelProvider = candidateProvider;
2065
+ modelResolution = candidateResolution;
2066
+ break;
2067
+ }
2068
+ }
2069
+ if (!modelResolution && pluginHarnessOwnsTransport) modelResolution = firstModelResolution;
2070
+ if (!modelResolution) {
2071
+ await ensureFengMingModelsJson(params.config, agentDir, { workspaceDir: resolvedWorkspace });
2072
+ for (const candidateProvider of modelResolutionProviders) {
2073
+ const candidateResolution = await resolveModelAsync(candidateProvider, modelId, agentDir, params.config, {
2074
+ workspaceDir: resolvedWorkspace,
2075
+ authProfileId: params.authProfileId
2076
+ });
2077
+ firstModelResolution ??= candidateResolution;
2078
+ if (candidateResolution.model) {
2079
+ resolvedModelProvider = candidateProvider;
2080
+ modelResolution = candidateResolution;
2081
+ break;
2082
+ }
2083
+ }
2084
+ }
2085
+ modelResolution ??= firstModelResolution;
2086
+ if (!modelResolution) throw new FailoverError(`Unknown model: ${provider}/${modelId}`, {
2087
+ reason: "model_not_found",
2088
+ provider,
2089
+ model: modelId,
2090
+ sessionId: params.sessionId,
2091
+ lane: globalLane
2092
+ });
2093
+ provider = resolvedModelProvider;
2094
+ const { model, error, authStorage, modelRegistry } = modelResolution;
2095
+ if (!model) throw new FailoverError(error ?? `Unknown model: ${provider}/${modelId}`, {
2096
+ reason: "model_not_found",
2097
+ provider,
2098
+ model: modelId,
2099
+ sessionId: params.sessionId,
2100
+ lane: globalLane
2101
+ });
2102
+ let runtimeModel = model;
2103
+ const resolvedRuntimeModel = resolveEffectiveRuntimeModel({
2104
+ cfg: params.config,
2105
+ provider,
2106
+ contextConfigProvider: resolveContextConfigProviderForRuntime({
2107
+ provider: modelConfigProvider,
2108
+ runtimeId: agentHarness.id,
2109
+ config: params.config
2110
+ }),
2111
+ modelId,
2112
+ runtimeModel
2113
+ });
2114
+ const ctxInfo = resolvedRuntimeModel.ctxInfo;
2115
+ let effectiveModel = resolvedRuntimeModel.effectiveModel;
2116
+ startupStages.mark("model-resolution");
2117
+ notifyExecutionPhase("model_resolution", {
2118
+ provider,
2119
+ model: modelId
2120
+ });
2121
+ const pluginHarnessNeedsFengMingAuthBootstrap = pluginHarnessOwnsTransport && provider === "openai" && effectiveModel.api === "openai-codex-responses";
2122
+ const fengMingNativeCodexResponsesNeedsAuthBootstrap = !pluginHarnessOwnsTransport && provider === "openai" && effectiveModel.api === "openai-codex-responses";
2123
+ let piExternalCliAuthScope = pluginHarnessOwnsTransport ? { ignoreAutoPreferredProfile: false } : fengMingNativeCodexResponsesNeedsAuthBootstrap ? {
2124
+ providerIds: [OPENAI_PROVIDER_ID],
2125
+ ignoreAutoPreferredProfile: false
2126
+ } : resolveExternalCliAuthOverlayScopeFromSelection({
2127
+ provider,
2128
+ cfg: params.config,
2129
+ agentId: params.agentId,
2130
+ modelId,
2131
+ workspaceDir: resolvedWorkspace,
2132
+ userLockedAuthProfileId: params.authProfileIdSource === "user" ? params.authProfileId : void 0
2133
+ });
2134
+ let noExternalAuthStore;
2135
+ if (!pluginHarnessOwnsTransport && !pluginHarnessNeedsFengMingAuthBootstrap && !piExternalCliAuthScope.providerIds) {
2136
+ noExternalAuthStore = ensureAuthProfileStoreWithoutExternalProfiles(agentDir, { allowKeychainPrompt: false });
2137
+ piExternalCliAuthScope = resolveExternalCliAuthOverlayScopeFromSelection({
2138
+ provider,
2139
+ cfg: params.config,
2140
+ agentId: params.agentId,
2141
+ modelId,
2142
+ workspaceDir: resolvedWorkspace,
2143
+ store: noExternalAuthStore,
2144
+ userLockedAuthProfileId: params.authProfileIdSource === "user" ? params.authProfileId : void 0
2145
+ });
2146
+ }
2147
+ const authStore = pluginHarnessOwnsTransport && !pluginHarnessNeedsFengMingAuthBootstrap ? createEmptyAuthProfileStore() : pluginHarnessNeedsFengMingAuthBootstrap ? ensureAuthProfileStore(agentDir, {
2148
+ externalCliProviderIds: [OPENAI_PROVIDER_ID],
2149
+ allowKeychainPrompt: false
2150
+ }) : piExternalCliAuthScope.providerIds ? ensureAuthProfileStore(agentDir, {
2151
+ externalCliProviderIds: piExternalCliAuthScope.providerIds,
2152
+ allowKeychainPrompt: false
2153
+ }) : noExternalAuthStore ?? ensureAuthProfileStoreWithoutExternalProfiles(agentDir, { allowKeychainPrompt: false });
2154
+ const attemptAuthProfileStore = pluginHarnessOwnsTransport && !pluginHarnessNeedsFengMingAuthBootstrap ? ensureAuthProfileStoreWithoutExternalProfiles(agentDir, { allowKeychainPrompt: false }) : authStore;
2155
+ const requestedProfileId = params.authProfileId?.trim();
2156
+ const requestedProfileIsUserLocked = params.authProfileIdSource === "user";
2157
+ const isForwardablePluginHarnessAuthProfile = (profileId) => {
2158
+ if (!pluginHarnessOwnsTransport || !profileId) return false;
2159
+ const credential = attemptAuthProfileStore.profiles?.[profileId];
2160
+ return buildAgentRuntimeAuthPlan({
2161
+ provider,
2162
+ authProfileProvider: credential?.provider ?? profileId.split(":", 1)[0],
2163
+ authProfileMode: credential?.type,
2164
+ sessionAuthProfileId: profileId,
2165
+ config: params.config,
2166
+ workspaceDir: resolvedWorkspace,
2167
+ harnessId: agentHarness.id,
2168
+ harnessRuntime: agentHarness.id,
2169
+ allowHarnessAuthProfileForwarding: true
2170
+ }).forwardedAuthProfileId === profileId;
2171
+ };
2172
+ const resolvePluginHarnessProfileOrder = () => {
2173
+ if (requestedProfileId && requestedProfileIsUserLocked) return isForwardablePluginHarnessAuthProfile(requestedProfileId) ? [requestedProfileId] : [];
2174
+ if (!pluginHarnessOwnsTransport) return [];
2175
+ const harnessAuthProvider = buildAgentRuntimeAuthPlan({
2176
+ provider,
2177
+ config: params.config,
2178
+ workspaceDir: resolvedWorkspace,
2179
+ harnessId: agentHarness.id,
2180
+ harnessRuntime: agentHarness.id,
2181
+ allowHarnessAuthProfileForwarding: true
2182
+ }).harnessAuthProvider;
2183
+ if (!harnessAuthProvider) return [];
2184
+ const resolvedOrder = resolveAuthProfileOrder({
2185
+ cfg: params.config,
2186
+ store: attemptAuthProfileStore,
2187
+ provider: harnessAuthProvider
2188
+ }).filter(isForwardablePluginHarnessAuthProfile);
2189
+ if (resolvedOrder.length > 0) return resolvedOrder;
2190
+ if (requestedProfileId && isForwardablePluginHarnessAuthProfile(requestedProfileId)) return [requestedProfileId];
2191
+ return [];
2192
+ };
2193
+ const pluginHarnessProfileOrder = pluginHarnessOwnsTransport ? resolvePluginHarnessProfileOrder() : [];
2194
+ const resolvePluginHarnessPreferredProfileId = () => pluginHarnessProfileOrder[0];
2195
+ const preferredProfileId = pluginHarnessOwnsTransport ? resolvePluginHarnessPreferredProfileId() : piExternalCliAuthScope.ignoreAutoPreferredProfile && !requestedProfileIsUserLocked ? void 0 : requestedProfileId;
2196
+ let lockedProfileId = requestedProfileIsUserLocked ? preferredProfileId : void 0;
2197
+ if (lockedProfileId) if (pluginHarnessOwnsTransport) {
2198
+ if (!isForwardablePluginHarnessAuthProfile(lockedProfileId)) lockedProfileId = void 0;
2199
+ } else {
2200
+ const lockedProfile = authStore.profiles[lockedProfileId];
2201
+ const lockedProfileProvider = lockedProfile ? resolveProviderIdForAuth(lockedProfile.provider, {
2202
+ config: params.config,
2203
+ workspaceDir: resolvedWorkspace
2204
+ }) : void 0;
2205
+ const runProvider = resolveProviderIdForAuth(provider, {
2206
+ config: params.config,
2207
+ workspaceDir: resolvedWorkspace
2208
+ });
2209
+ if (!lockedProfile || !lockedProfileProvider || lockedProfileProvider !== runProvider) lockedProfileId = void 0;
2210
+ }
2211
+ const forwardedPluginHarnessProfileId = pluginHarnessOwnsTransport && !lockedProfileId && isForwardablePluginHarnessAuthProfile(preferredProfileId) ? preferredProfileId : void 0;
2212
+ if (lockedProfileId && !pluginHarnessOwnsTransport) {
2213
+ if (!resolveAuthProfileEligibility({
2214
+ cfg: params.config,
2215
+ store: authStore,
2216
+ provider,
2217
+ profileId: lockedProfileId
2218
+ }).eligible) throw new Error(`认证配置 "${lockedProfileId}" is not configured for ${provider}.`);
2219
+ }
2220
+ const profileOrder = shouldPreferExplicitConfigApiKeyAuth(params.config, provider) ? [] : [...new Set(listOpenAIAuthProfileProvidersForAgentRuntime({
2221
+ provider,
2222
+ harnessRuntime: agentHarness.id,
2223
+ agentHarnessId: agentHarness.id,
2224
+ config: params.config
2225
+ }).flatMap((authProvider) => resolveAuthProfileOrder({
2226
+ cfg: params.config,
2227
+ store: authStore,
2228
+ provider: authProvider,
2229
+ preferredProfile: preferredProfileId
2230
+ })))];
2231
+ const providerPreferredProfileId = lockedProfileId ? void 0 : resolveProviderAuthProfileId({
2232
+ provider,
2233
+ config: params.config,
2234
+ workspaceDir: resolvedWorkspace,
2235
+ context: {
2236
+ config: params.config,
2237
+ agentDir,
2238
+ workspaceDir: resolvedWorkspace,
2239
+ provider,
2240
+ modelId,
2241
+ preferredProfileId,
2242
+ lockedProfileId,
2243
+ profileOrder,
2244
+ authStore
2245
+ }
2246
+ });
2247
+ const providerOrderedProfiles = providerPreferredProfileId && profileOrder.includes(providerPreferredProfileId) ? [providerPreferredProfileId, ...profileOrder.filter((profileId) => profileId !== providerPreferredProfileId)] : profileOrder;
2248
+ const profileCandidates = pluginHarnessOwnsTransport ? lockedProfileId ? [lockedProfileId] : pluginHarnessProfileOrder.length > 0 ? pluginHarnessProfileOrder : [void 0] : lockedProfileId ? [lockedProfileId] : providerOrderedProfiles.length > 0 ? providerOrderedProfiles : [void 0];
2249
+ const pluginHarnessForwardedProfileCandidates = pluginHarnessOwnsTransport ? profileCandidates.filter(isForwardablePluginHarnessAuthProfile) : [];
2250
+ const profileFailureStore = pluginHarnessOwnsTransport ? attemptAuthProfileStore : authStore;
2251
+ let profileIndex = 0;
2252
+ const traceAttempts = [];
2253
+ const initialThinkLevel = params.thinkLevel ?? "off";
2254
+ let thinkLevel = initialThinkLevel;
2255
+ const attemptedThinking = /* @__PURE__ */ new Set();
2256
+ let apiKeyInfo = null;
2257
+ let lastProfileId;
2258
+ let runtimeAuthState = null;
2259
+ let runtimeAuthRefreshCancelled = false;
2260
+ const { advanceAuthProfile, initializeAuthProfile, maybeRefreshRuntimeAuthForAuthError, stopRuntimeAuthRefreshTimer } = createEmbeddedRunAuthController({
2261
+ config: params.config,
2262
+ agentDir,
2263
+ workspaceDir: resolvedWorkspace,
2264
+ authStore,
2265
+ authStorage,
2266
+ profileCandidates,
2267
+ lockedProfileId,
2268
+ initialThinkLevel,
2269
+ attemptedThinking,
2270
+ fallbackConfigured,
2271
+ allowTransientCooldownProbe: params.allowTransientCooldownProbe === true,
2272
+ getProvider: () => provider,
2273
+ getModelId: () => modelId,
2274
+ getRuntimeModel: () => runtimeModel,
2275
+ setRuntimeModel: (next) => {
2276
+ runtimeModel = next;
2277
+ },
2278
+ getEffectiveModel: () => effectiveModel,
2279
+ setEffectiveModel: (next) => {
2280
+ effectiveModel = next;
2281
+ },
2282
+ getApiKeyInfo: () => apiKeyInfo,
2283
+ setApiKeyInfo: (next) => {
2284
+ apiKeyInfo = next;
2285
+ },
2286
+ getLastProfileId: () => lastProfileId,
2287
+ setLastProfileId: (next) => {
2288
+ lastProfileId = next;
2289
+ },
2290
+ getRuntimeAuthState: () => runtimeAuthState,
2291
+ setRuntimeAuthState: (next) => {
2292
+ runtimeAuthState = next;
2293
+ },
2294
+ getRuntimeAuthRefreshCancelled: () => runtimeAuthRefreshCancelled,
2295
+ setRuntimeAuthRefreshCancelled: (next) => {
2296
+ runtimeAuthRefreshCancelled = next;
2297
+ },
2298
+ getProfileIndex: () => profileIndex,
2299
+ setProfileIndex: (next) => {
2300
+ profileIndex = next;
2301
+ },
2302
+ setThinkLevel: (next) => {
2303
+ thinkLevel = next;
2304
+ },
2305
+ log: log$1
2306
+ });
2307
+ const advancePluginHarnessAuthProfile = async () => {
2308
+ if (!pluginHarnessOwnsTransport || lockedProfileId) return false;
2309
+ let nextIndex = profileIndex + 1;
2310
+ while (nextIndex < profileCandidates.length) {
2311
+ const candidate = profileCandidates[nextIndex];
2312
+ if (!candidate || !isForwardablePluginHarnessAuthProfile(candidate)) {
2313
+ nextIndex += 1;
2314
+ continue;
2315
+ }
2316
+ if (isProfileInCooldown(attemptAuthProfileStore, candidate, void 0, modelId)) {
2317
+ nextIndex += 1;
2318
+ continue;
2319
+ }
2320
+ profileIndex = nextIndex;
2321
+ lastProfileId = candidate;
2322
+ thinkLevel = initialThinkLevel;
2323
+ attemptedThinking.clear();
2324
+ return true;
2325
+ }
2326
+ return false;
2327
+ };
2328
+ const advanceAttemptAuthProfile = pluginHarnessOwnsTransport && !pluginHarnessNeedsFengMingAuthBootstrap ? advancePluginHarnessAuthProfile : advanceAuthProfile;
2329
+ if (!pluginHarnessOwnsTransport || pluginHarnessNeedsFengMingAuthBootstrap) await initializeAuthProfile();
2330
+ else if (lockedProfileId) lastProfileId = lockedProfileId;
2331
+ else if (forwardedPluginHarnessProfileId) lastProfileId = forwardedPluginHarnessProfileId;
2332
+ startupStages.mark("auth");
2333
+ notifyExecutionPhase("auth", {
2334
+ provider,
2335
+ model: modelId
2336
+ });
2337
+ const runAttemptAuthProfileStore = pluginHarnessOwnsTransport ? createScopedAuthProfileStore(attemptAuthProfileStore, pluginHarnessForwardedProfileCandidates.length > 0 ? pluginHarnessForwardedProfileCandidates : lastProfileId) : attemptAuthProfileStore;
2338
+ const harnessBuildsFengMingTools = agentHarness.id === "codex" || agentHarness.id === "copilot";
2339
+ const { sessionAgentId } = resolveSessionAgentIds({
2340
+ sessionKey: params.sessionKey,
2341
+ config: params.config,
2342
+ agentId: params.agentId
2343
+ });
2344
+ const configuredExecutionContract = resolveAgentExecutionContract(params.config, sessionAgentId);
2345
+ const strictAgenticActive = isStrictAgenticExecutionContractActive({
2346
+ config: params.config,
2347
+ sessionKey: params.sessionKey,
2348
+ agentId: params.agentId,
2349
+ provider,
2350
+ modelId
2351
+ });
2352
+ const executionContract = strictAgenticActive ? "strict-agentic" : "default";
2353
+ const configuredExecutionContractForLog = configuredExecutionContract ?? "unspecified";
2354
+ const maxPlanningOnlyRetryAttempts = resolvePlanningOnlyRetryLimit(executionContract);
2355
+ const maxReasoningOnlyRetryAttempts = 2;
2356
+ const maxEmptyResponseRetryAttempts = 1;
2357
+ const MAX_TIMEOUT_COMPACTION_ATTEMPTS = 2;
2358
+ const MAX_OVERFLOW_COMPACTION_ATTEMPTS = 3;
2359
+ const MAX_RUN_LOOP_ITERATIONS = resolveMaxRunRetryIterations(profileCandidates.length, params.config, sessionAgentId);
2360
+ let overflowCompactionAttempts = 0;
2361
+ let toolResultTruncationAttempted = false;
2362
+ let bootstrapPromptWarningSignaturesSeen = params.bootstrapPromptWarningSignaturesSeen ?? (params.bootstrapPromptWarningSignature ? [params.bootstrapPromptWarningSignature] : []);
2363
+ const usageAccumulator = createUsageAccumulator();
2364
+ let lastRunPromptUsage;
2365
+ let autoCompactionCount = 0;
2366
+ let lastCompactionTokensAfter;
2367
+ let lastContextBudgetStatus;
2368
+ let runLoopIterations = 0;
2369
+ let overloadProfileRotations = 0;
2370
+ let planningOnlyRetryAttempts = 0;
2371
+ let reasoningOnlyRetryAttempts = 0;
2372
+ let emptyResponseRetryAttempts = 0;
2373
+ let compactionContinuationRetryAttempts = 0;
2374
+ let sameModelIdleTimeoutRetries = 0;
2375
+ const idleTimeoutBreakerState = createIdleTimeoutBreakerState();
2376
+ const resolvedLoopDetectionConfig = resolveToolLoopDetectionConfig({
2377
+ cfg: params.config,
2378
+ agentId: sessionAgentId
2379
+ });
2380
+ const postCompactionGuard = createPostCompactionLoopGuard(resolvedLoopDetectionConfig?.postCompactionGuard, { enabled: resolvedLoopDetectionConfig?.enabled !== false });
2381
+ let postCompactionAbortController;
2382
+ let postCompactionAbortError;
2383
+ const observePostCompactionToolOutcome = (observation) => {
2384
+ const verdict = postCompactionGuard.observe(observation);
2385
+ if (verdict.shouldAbort) {
2386
+ postCompactionAbortError ??= PostCompactionLoopPersistedError.fromVerdict(verdict);
2387
+ postCompactionAbortController?.abort(postCompactionAbortError);
2388
+ }
2389
+ };
2390
+ let lastRetryFailoverReason = null;
2391
+ let planningOnlyRetryInstruction = null;
2392
+ let reasoningOnlyRetryInstruction = null;
2393
+ let emptyResponseRetryInstruction = null;
2394
+ let compactionContinuationRetryInstruction = null;
2395
+ let nextAttemptPromptOverride = null;
2396
+ const ackExecutionFastPathInstruction = resolveAckExecutionFastPathInstruction({
2397
+ provider,
2398
+ modelId,
2399
+ prompt: params.prompt
2400
+ });
2401
+ let rateLimitProfileRotations = 0;
2402
+ let timeoutCompactionAttempts = 0;
2403
+ let codexAppServerRecoveryRetries = 0;
2404
+ const MAX_EMPTY_ERROR_RETRIES = 3;
2405
+ let emptyErrorRetries = 0;
2406
+ const MAX_MISSING_ASSISTANT_RETRIES = 1;
2407
+ let missingAssistantRetryAttempts = 0;
2408
+ const overloadFailoverBackoffMs = resolveOverloadFailoverBackoffMs(params.config);
2409
+ const overloadProfileRotationLimit = resolveOverloadProfileRotationLimit(params.config);
2410
+ const rateLimitProfileRotationLimit = resolveRateLimitProfileRotationLimit(params.config);
2411
+ let activeSessionId = params.sessionId;
2412
+ let activeSessionFile = params.sessionFile;
2413
+ let suppressNextUserMessagePersistence = params.suppressNextUserMessagePersistence ?? false;
2414
+ let lastPersistedCurrentMessageId;
2415
+ const onUserMessagePersisted = (message) => {
2416
+ if (params.currentMessageId !== void 0) lastPersistedCurrentMessageId = params.currentMessageId;
2417
+ params.userTurnTranscriptRecorder?.markRuntimePersisted(message);
2418
+ params.onUserMessagePersisted?.(message);
2419
+ };
2420
+ const continueFromCurrentTranscript = () => {
2421
+ nextAttemptPromptOverride = MID_TURN_PRECHECK_CONTINUATION_PROMPT;
2422
+ suppressNextUserMessagePersistence = true;
2423
+ };
2424
+ const maybeEscalateRateLimitProfileFallback = (params) => {
2425
+ rateLimitProfileRotations += 1;
2426
+ if (rateLimitProfileRotations <= rateLimitProfileRotationLimit || !fallbackConfigured) return;
2427
+ const status = resolveFailoverStatus("rate_limit");
2428
+ log$1.warn(`rate-limit profile rotation cap reached for ${sanitizeForLog(provider)}/${sanitizeForLog(modelId)} after ${rateLimitProfileRotations} rotations; escalating to model fallback`);
2429
+ params.logFallbackDecision("fallback_model", { status });
2430
+ throw new FailoverError("The AI service is temporarily rate-limited. Please try again in a moment.", {
2431
+ reason: "rate_limit",
2432
+ provider: params.failoverProvider,
2433
+ model: params.failoverModel,
2434
+ profileId: lastProfileId,
2435
+ sessionId: activeSessionId,
2436
+ lane: globalLane,
2437
+ status
2438
+ });
2439
+ };
2440
+ const maybeMarkAuthProfileFailure = async (failure) => {
2441
+ const { profileId, reason } = failure;
2442
+ if (!profileId || !reason) return;
2443
+ if (pluginHarnessOwnsTransport && reason === "timeout") return;
2444
+ await markAuthProfileFailure({
2445
+ store: profileFailureStore,
2446
+ profileId,
2447
+ reason,
2448
+ cfg: params.config,
2449
+ agentDir,
2450
+ runId: params.runId,
2451
+ modelId: failure.modelId
2452
+ });
2453
+ };
2454
+ const resolveRunAuthProfileFailureReason = (failoverReason, opts) => resolveAuthProfileFailureReason({
2455
+ failoverReason,
2456
+ providerStarted: opts?.providerStarted,
2457
+ policy: params.authProfileFailurePolicy
2458
+ });
2459
+ const maybeBackoffBeforeOverloadFailover = async (reason) => {
2460
+ if (reason !== "overloaded" || overloadFailoverBackoffMs <= 0) return;
2461
+ log$1.warn(`overload backoff before failover for ${provider}/${modelId}: delayMs=${overloadFailoverBackoffMs}`);
2462
+ try {
2463
+ await sleepWithAbort(overloadFailoverBackoffMs, params.abortSignal);
2464
+ } catch (err) {
2465
+ if (params.abortSignal?.aborted) {
2466
+ const abortErr = new Error("操作已中止", { cause: err });
2467
+ abortErr.name = "AbortError";
2468
+ throw abortErr;
2469
+ }
2470
+ throw err;
2471
+ }
2472
+ };
2473
+ ensureContextEnginesInitialized();
2474
+ const contextEngine = await resolveContextEngine(params.config, {
2475
+ agentDir,
2476
+ workspaceDir: resolvedWorkspace
2477
+ });
2478
+ const resolveContextEnginePluginId = () => resolveContextEngineOwnerPluginId(contextEngine);
2479
+ startupStages.mark("context-engine");
2480
+ notifyExecutionPhase("context_engine", {
2481
+ provider,
2482
+ model: modelId
2483
+ });
2484
+ try {
2485
+ const resolveActiveHookContext = () => ({
2486
+ ...hookCtx,
2487
+ sessionId: activeSessionId
2488
+ });
2489
+ const adoptCompactionTranscript = (compactResult) => {
2490
+ const nextSessionId = compactResult.result?.sessionId;
2491
+ const nextSessionFile = compactResult.result?.sessionFile;
2492
+ if (nextSessionId && nextSessionId !== activeSessionId) activeSessionId = nextSessionId;
2493
+ if (nextSessionFile && nextSessionFile !== activeSessionFile) activeSessionFile = nextSessionFile;
2494
+ };
2495
+ const onCompactionHookMessages = async (payload) => {
2496
+ const messages = payload.messages.filter((message) => message.trim().length > 0);
2497
+ if (messages.length === 0) return;
2498
+ await params.onAgentEvent?.({
2499
+ stream: "compaction",
2500
+ data: {
2501
+ phase: payload.phase === "before" ? "start" : "end",
2502
+ ...payload.phase === "after" ? { completed: true } : {},
2503
+ messages
2504
+ },
2505
+ ...params.sessionKey ? { sessionKey: params.sessionKey } : {}
2506
+ });
2507
+ };
2508
+ const runOwnsCompactionBeforeHook = async (reason) => {
2509
+ if (contextEngine.info.ownsCompaction !== true || !hookRunner?.hasHooks("before_compaction")) return;
2510
+ try {
2511
+ await hookRunner.runBeforeCompaction({
2512
+ messageCount: -1,
2513
+ sessionFile: activeSessionFile
2514
+ }, resolveActiveHookContext());
2515
+ } catch (hookErr) {
2516
+ log$1.warn(`before_compaction hook failed during ${reason}: ${String(hookErr)}`);
2517
+ }
2518
+ };
2519
+ const runOwnsCompactionAfterHook = async (reason, compactResult) => {
2520
+ if (contextEngine.info.ownsCompaction !== true || !compactResult.ok || !compactResult.compacted || !hookRunner?.hasHooks("after_compaction")) return;
2521
+ try {
2522
+ await hookRunner.runAfterCompaction({
2523
+ messageCount: -1,
2524
+ compactedCount: -1,
2525
+ tokenCount: compactResult.result?.tokensAfter,
2526
+ sessionFile: compactResult.result?.sessionFile ?? activeSessionFile
2527
+ }, resolveActiveHookContext());
2528
+ } catch (hookErr) {
2529
+ log$1.warn(`after_compaction hook failed during ${reason}: ${String(hookErr)}`);
2530
+ }
2531
+ };
2532
+ let authRetryPending = false;
2533
+ let accumulatedReplayState = createEmbeddedRunReplayState();
2534
+ let lastTurnTotal;
2535
+ while (true) {
2536
+ if (runLoopIterations >= MAX_RUN_LOOP_ITERATIONS) {
2537
+ const message = `Exceeded retry limit after ${runLoopIterations} attempts (max=${MAX_RUN_LOOP_ITERATIONS}).`;
2538
+ log$1.error(`[run-retry-limit] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} attempts=${runLoopIterations} maxAttempts=${MAX_RUN_LOOP_ITERATIONS}`);
2539
+ return handleRetryLimitExhaustion({
2540
+ message,
2541
+ decision: resolveRunFailoverDecision({
2542
+ stage: "retry_limit",
2543
+ fallbackConfigured,
2544
+ failoverReason: lastRetryFailoverReason
2545
+ }),
2546
+ provider,
2547
+ model: modelId,
2548
+ profileId: lastProfileId,
2549
+ durationMs: Date.now() - started,
2550
+ agentMeta: buildErrorAgentMeta({
2551
+ sessionId: activeSessionId,
2552
+ sessionFile: activeSessionFile,
2553
+ provider,
2554
+ model: model.id,
2555
+ contextTokens: ctxInfo.tokens,
2556
+ usageAccumulator,
2557
+ lastRunPromptUsage,
2558
+ lastTurnTotal
2559
+ }),
2560
+ replayInvalid: accumulatedReplayState.replayInvalid ? true : void 0,
2561
+ livenessState: "blocked"
2562
+ });
2563
+ }
2564
+ runLoopIterations += 1;
2565
+ const runtimeAuthRetry = authRetryPending;
2566
+ authRetryPending = false;
2567
+ attemptedThinking.add(thinkLevel);
2568
+ await fs.mkdir(resolvedWorkspace, { recursive: true });
2569
+ if (!startupStagesEmitted) startupStages.mark(EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE.workspace);
2570
+ const basePrompt = nextAttemptPromptOverride ?? (provider === "anthropic" ? scrubAnthropicRefusalMagic(params.prompt) : params.prompt);
2571
+ nextAttemptPromptOverride = null;
2572
+ const promptAdditions = [
2573
+ ackExecutionFastPathInstruction,
2574
+ planningOnlyRetryInstruction,
2575
+ reasoningOnlyRetryInstruction,
2576
+ emptyResponseRetryInstruction,
2577
+ compactionContinuationRetryInstruction
2578
+ ].filter((value) => typeof value === "string" && value.trim().length > 0);
2579
+ const prompt = promptAdditions.length > 0 ? `${basePrompt}\n\n${promptAdditions.join("\n\n")}` : basePrompt;
2580
+ const resolvedStreamApiKey = resolveAttemptDispatchApiKey({
2581
+ apiKeyInfo,
2582
+ runtimeAuthState
2583
+ });
2584
+ if (!startupStagesEmitted) startupStages.mark(EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE.prompt);
2585
+ const runtimePlan = buildAgentRuntimePlan({
2586
+ provider,
2587
+ modelId,
2588
+ model: effectiveModel,
2589
+ modelApi: effectiveModel.api,
2590
+ harnessId: agentHarness.id,
2591
+ harnessRuntime: agentHarness.id,
2592
+ allowHarnessAuthProfileForwarding: pluginHarnessOwnsTransport,
2593
+ authProfileProvider: (lastProfileId ? attemptAuthProfileStore.profiles?.[lastProfileId]?.provider : void 0) ?? lastProfileId?.split(":", 1)[0],
2594
+ authProfileMode: lastProfileId ? attemptAuthProfileStore.profiles?.[lastProfileId]?.type : void 0,
2595
+ sessionAuthProfileId: lastProfileId,
2596
+ sessionAuthProfileCandidateIds: pluginHarnessOwnsTransport ? pluginHarnessForwardedProfileCandidates : void 0,
2597
+ config: params.config,
2598
+ workspaceDir: resolvedWorkspace,
2599
+ agentDir,
2600
+ agentId: workspaceResolution.agentId,
2601
+ thinkingLevel: thinkLevel,
2602
+ extraParamsOverride: {
2603
+ ...params.streamParams,
2604
+ fastMode: params.fastMode
2605
+ }
2606
+ });
2607
+ if (!startupStagesEmitted) {
2608
+ startupStages.mark(EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE.runtimePlan);
2609
+ startupStages.mark(EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE.dispatch);
2610
+ notifyExecutionPhase("attempt_dispatch", {
2611
+ provider,
2612
+ model: modelId
2613
+ });
2614
+ emitStartupStageSummary(EMBEDDED_RUN_ATTEMPT_DISPATCH_STAGE.dispatch);
2615
+ startupStagesEmitted = true;
2616
+ }
2617
+ const attemptAbortController = new AbortController();
2618
+ postCompactionAbortController = attemptAbortController;
2619
+ const parentAbortSignal = params.abortSignal;
2620
+ const relayParentAbort = () => {
2621
+ attemptAbortController.abort(parentAbortSignal?.reason);
2622
+ };
2623
+ if (parentAbortSignal?.aborted) relayParentAbort();
2624
+ else parentAbortSignal?.addEventListener("abort", relayParentAbort, { once: true });
2625
+ const rawAttempt = await runEmbeddedAttemptWithBackend({
2626
+ sessionId: activeSessionId,
2627
+ sessionKey: resolvedSessionKey,
2628
+ promptCacheKey: params.promptCacheKey,
2629
+ sandboxSessionKey: params.sandboxSessionKey,
2630
+ trigger: params.trigger,
2631
+ memoryFlushWritePath: params.memoryFlushWritePath,
2632
+ messageChannel: params.messageChannel,
2633
+ messageProvider: params.messageProvider,
2634
+ agentAccountId: params.agentAccountId,
2635
+ messageTo: params.messageTo,
2636
+ messageThreadId: params.messageThreadId,
2637
+ groupId: params.groupId,
2638
+ groupChannel: params.groupChannel,
2639
+ groupSpace: params.groupSpace,
2640
+ memberRoleIds: params.memberRoleIds,
2641
+ spawnedBy: params.spawnedBy,
2642
+ isCanonicalWorkspace,
2643
+ senderId: params.senderId,
2644
+ senderName: params.senderName,
2645
+ senderUsername: params.senderUsername,
2646
+ senderE164: params.senderE164,
2647
+ currentChannelId: params.currentChannelId,
2648
+ currentThreadTs: params.currentThreadTs,
2649
+ currentMessageId: params.currentMessageId,
2650
+ replyToMode: params.replyToMode,
2651
+ hasRepliedRef: params.hasRepliedRef,
2652
+ sessionFile: activeSessionFile,
2653
+ workspaceDir: resolvedWorkspace,
2654
+ cwd: params.cwd,
2655
+ agentDir,
2656
+ config: params.config,
2657
+ allowGatewaySubagentBinding: params.allowGatewaySubagentBinding,
2658
+ contextEngine,
2659
+ contextTokenBudget: ctxInfo.tokens,
2660
+ contextWindowInfo: ctxInfo,
2661
+ skillsSnapshot: params.skillsSnapshot,
2662
+ prompt,
2663
+ transcriptPrompt: params.transcriptPrompt,
2664
+ userTurnTranscriptRecorder: params.userTurnTranscriptRecorder,
2665
+ currentInboundEventKind: params.currentInboundEventKind,
2666
+ currentInboundContext: params.currentInboundContext,
2667
+ images: params.images,
2668
+ imageOrder: params.imageOrder,
2669
+ clientTools: params.clientTools,
2670
+ disableTools: params.disableTools,
2671
+ provider,
2672
+ modelId,
2673
+ agentHarnessId: agentHarness.id,
2674
+ ...params.sessionKey ? { agentHarnessTaskRuntimeScope: createAgentHarnessTaskRuntimeScope({ requesterSessionKey: params.sessionKey }) } : {},
2675
+ runtimePlan,
2676
+ model: applyAuthHeaderOverride(applyLocalNoAuthHeaderOverride(effectiveModel, apiKeyInfo), runtimeAuthState ? null : apiKeyInfo, params.config),
2677
+ resolvedApiKey: resolvedStreamApiKey,
2678
+ authProfileId: lastProfileId,
2679
+ authProfileIdSource: lockedProfileId ? "user" : "auto",
2680
+ initialReplayState: accumulatedReplayState,
2681
+ authStorage,
2682
+ authProfileStore: runAttemptAuthProfileStore,
2683
+ toolAuthProfileStore: harnessBuildsFengMingTools ? attemptAuthProfileStore : void 0,
2684
+ modelRegistry,
2685
+ agentId: workspaceResolution.agentId,
2686
+ beforeAgentStartResult,
2687
+ thinkLevel,
2688
+ onToolOutcome: observePostCompactionToolOutcome,
2689
+ onRunProgress: notifyRunProgress,
2690
+ fastMode: params.fastMode,
2691
+ verboseLevel: params.verboseLevel,
2692
+ reasoningLevel: params.reasoningLevel,
2693
+ toolResultFormat: resolvedToolResultFormat,
2694
+ toolProgressDetail: params.toolProgressDetail,
2695
+ execOverrides: params.execOverrides,
2696
+ bashElevated: params.bashElevated,
2697
+ timeoutMs: params.timeoutMs,
2698
+ runTimeoutOverrideMs: params.runTimeoutOverrideMs,
2699
+ runId: params.runId,
2700
+ abortSignal: attemptAbortController.signal,
2701
+ replyOperation: params.replyOperation,
2702
+ shouldEmitToolResult: params.shouldEmitToolResult,
2703
+ shouldEmitToolOutput: params.shouldEmitToolOutput,
2704
+ onPartialReply: params.onPartialReply,
2705
+ onAssistantMessageStart: params.onAssistantMessageStart,
2706
+ onBlockReply: params.onBlockReply,
2707
+ onBlockReplyFlush: params.onBlockReplyFlush,
2708
+ blockReplyBreak: params.blockReplyBreak,
2709
+ blockReplyChunking: params.blockReplyChunking,
2710
+ onReasoningStream: params.onReasoningStream,
2711
+ onReasoningEnd: params.onReasoningEnd,
2712
+ onToolResult: params.onToolResult,
2713
+ onAgentEvent: params.onAgentEvent,
2714
+ onExecutionPhase: params.onExecutionPhase,
2715
+ extraSystemPrompt: params.extraSystemPrompt,
2716
+ sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
2717
+ inputProvenance: params.inputProvenance,
2718
+ streamParams: params.streamParams,
2719
+ modelRun: params.modelRun,
2720
+ promptMode: params.promptMode,
2721
+ ownerNumbers: params.ownerNumbers,
2722
+ enforceFinalTag: params.enforceFinalTag,
2723
+ silentExpected: params.silentExpected,
2724
+ bootstrapContextMode: params.bootstrapContextMode,
2725
+ bootstrapContextRunKind: params.bootstrapContextRunKind,
2726
+ jobId: params.jobId,
2727
+ toolsAllow: params.toolsAllow,
2728
+ disableMessageTool: params.disableMessageTool,
2729
+ forceMessageTool: params.forceMessageTool,
2730
+ enableHeartbeatTool: params.enableHeartbeatTool,
2731
+ forceHeartbeatTool: params.forceHeartbeatTool,
2732
+ requireExplicitMessageTarget: params.requireExplicitMessageTarget,
2733
+ internalEvents: params.internalEvents,
2734
+ bootstrapPromptWarningSignaturesSeen,
2735
+ bootstrapPromptWarningSignature: bootstrapPromptWarningSignaturesSeen[bootstrapPromptWarningSignaturesSeen.length - 1],
2736
+ suppressNextUserMessagePersistence,
2737
+ suppressTranscriptOnlyAssistantPersistence: params.suppressTranscriptOnlyAssistantPersistence,
2738
+ suppressAssistantErrorPersistence: params.suppressAssistantErrorPersistence,
2739
+ onUserMessagePersisted,
2740
+ onAssistantErrorMessagePersisted: params.onAssistantErrorMessagePersisted
2741
+ }).catch((err) => {
2742
+ throw postCompactionAbortError ?? err;
2743
+ }).finally(() => {
2744
+ parentAbortSignal?.removeEventListener?.("abort", relayParentAbort);
2745
+ if (postCompactionAbortController === attemptAbortController) postCompactionAbortController = void 0;
2746
+ });
2747
+ if (postCompactionAbortError) throw postCompactionAbortError;
2748
+ const attempt = normalizeEmbeddedRunAttemptResult(rawAttempt);
2749
+ const { aborted, externalAbort, promptError, promptErrorSource, preflightRecovery, timedOut, idleTimedOut, timedOutDuringCompaction, sessionIdUsed, sessionFileUsed, lastAssistant: sessionLastAssistant, currentAttemptAssistant } = attempt;
2750
+ const timedOutDuringToolExecution = attempt.timedOutDuringToolExecution ?? false;
2751
+ if (sessionIdUsed && sessionIdUsed !== activeSessionId) activeSessionId = sessionIdUsed;
2752
+ if (sessionFileUsed && sessionFileUsed !== activeSessionFile) activeSessionFile = sessionFileUsed;
2753
+ bootstrapPromptWarningSignaturesSeen = attempt.bootstrapPromptWarningSignaturesSeen ?? (attempt.bootstrapPromptWarningSignature ? Array.from(new Set([...bootstrapPromptWarningSignaturesSeen, attempt.bootstrapPromptWarningSignature])) : bootstrapPromptWarningSignaturesSeen);
2754
+ const lastAssistantUsage = normalizeUsage(sessionLastAssistant?.usage);
2755
+ const attemptUsage = attempt.attemptUsage ?? lastAssistantUsage;
2756
+ mergeUsageIntoAccumulator(usageAccumulator, attemptUsage);
2757
+ lastRunPromptUsage = lastAssistantUsage ?? attemptUsage;
2758
+ lastTurnTotal = lastAssistantUsage?.total ?? attemptUsage?.total;
2759
+ const breakerStep = stepIdleTimeoutBreaker(idleTimeoutBreakerState, {
2760
+ idleTimedOut,
2761
+ completedModelProgress: hasCompletedModelProgressForIdleBreaker(attempt),
2762
+ outputTokens: attemptUsage?.output
2763
+ });
2764
+ if (breakerStep.tripped) {
2765
+ const breakerMessage = `Idle-timeout cost-runaway breaker tripped: ${breakerStep.consecutive} consecutive idle timeouts without completed model progress (cap=5). Halting further attempts to bound paid model calls. See issue #76293.`;
2766
+ log$1.error(`[idle-timeout-circuit-breaker-tripped] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} consecutive=${breakerStep.consecutive} cap=5`);
2767
+ return handleRetryLimitExhaustion({
2768
+ message: breakerMessage,
2769
+ decision: resolveRunFailoverDecision({
2770
+ stage: "retry_limit",
2771
+ fallbackConfigured,
2772
+ failoverReason: lastRetryFailoverReason
2773
+ }),
2774
+ provider,
2775
+ model: modelId,
2776
+ profileId: lastProfileId,
2777
+ durationMs: Date.now() - started,
2778
+ agentMeta: buildErrorAgentMeta({
2779
+ sessionId: activeSessionId,
2780
+ sessionFile: activeSessionFile,
2781
+ provider,
2782
+ model: model.id,
2783
+ contextTokens: ctxInfo.tokens,
2784
+ usageAccumulator,
2785
+ lastRunPromptUsage,
2786
+ lastTurnTotal
2787
+ }),
2788
+ replayInvalid: accumulatedReplayState.replayInvalid ? true : void 0,
2789
+ livenessState: "blocked"
2790
+ });
2791
+ }
2792
+ const attemptCompactionCount = Math.max(0, attempt.compactionCount ?? 0);
2793
+ autoCompactionCount += attemptCompactionCount;
2794
+ if (typeof attempt.compactionTokensAfter === "number" && Number.isFinite(attempt.compactionTokensAfter) && attempt.compactionTokensAfter >= 0) lastCompactionTokensAfter = Math.floor(attempt.compactionTokensAfter);
2795
+ if (attempt.contextBudgetStatus) lastContextBudgetStatus = attempt.contextBudgetStatus;
2796
+ const sessionAssistantForCandidate = !currentAttemptAssistant && !isAssistantForModelRef(sessionLastAssistant, {
2797
+ provider,
2798
+ model: modelId
2799
+ }) ? void 0 : sessionLastAssistant;
2800
+ const activeErrorContext = resolveActiveErrorContext({
2801
+ provider,
2802
+ model: modelId,
2803
+ assistant: currentAttemptAssistant ?? sessionAssistantForCandidate
2804
+ });
2805
+ const resolveReplayInvalidForAttempt = (incompleteTurnText) => accumulatedReplayState.replayInvalid || resolveReplayInvalidFlag({
2806
+ attempt,
2807
+ incompleteTurnText
2808
+ });
2809
+ if (resolveReplayInvalidForAttempt(null)) accumulatedReplayState.replayInvalid = true;
2810
+ accumulatedReplayState = observeReplayMetadata(accumulatedReplayState, attempt.replayMetadata);
2811
+ const formattedAssistantErrorText = sessionAssistantForCandidate ? formatAssistantErrorText(sessionAssistantForCandidate, {
2812
+ cfg: params.config,
2813
+ sessionKey: resolvedSessionKey ?? params.sessionId,
2814
+ provider: activeErrorContext.provider,
2815
+ model: activeErrorContext.model
2816
+ }) : void 0;
2817
+ const assistantErrorText = sessionAssistantForCandidate?.stopReason === "error" ? sessionAssistantForCandidate.errorMessage?.trim() || formattedAssistantErrorText : void 0;
2818
+ const canRestartForLiveSwitch = !hasOutboundDeliveryEvidence(attempt) && !attempt.didSendDeterministicApprovalPrompt && !attempt.lastToolError && (attempt.toolMetas?.length ?? 0) === 0 && (attempt.assistantTexts?.length ?? 0) === 0;
2819
+ if (preflightRecovery?.handled) {
2820
+ const retryingFromTranscript = preflightRecovery.source === "mid-turn";
2821
+ log$1.info(`[context-overflow-precheck] early recovery route=${preflightRecovery.route} completed for ${provider}/${modelId}; ` + (retryingFromTranscript ? "retrying from current transcript" : "retrying prompt"));
2822
+ if (retryingFromTranscript) continueFromCurrentTranscript();
2823
+ continue;
2824
+ }
2825
+ const requestedSelection = shouldSwitchToLiveModel({
2826
+ cfg: params.config,
2827
+ sessionKey: resolvedSessionKey,
2828
+ agentId: params.agentId,
2829
+ defaultProvider: DEFAULT_PROVIDER,
2830
+ defaultModel: DEFAULT_MODEL,
2831
+ currentProvider: provider,
2832
+ currentModel: modelId,
2833
+ currentAuthProfileId: preferredProfileId,
2834
+ currentAuthProfileIdSource: params.authProfileIdSource
2835
+ });
2836
+ if (requestedSelection && canRestartForLiveSwitch) {
2837
+ await clearLiveModelSwitchPending({
2838
+ cfg: params.config,
2839
+ sessionKey: resolvedSessionKey,
2840
+ agentId: params.agentId
2841
+ });
2842
+ log$1.info(`live session model switch requested during active attempt for ${params.sessionId}: ${provider}/${modelId} -> ${requestedSelection.provider}/${requestedSelection.model}`);
2843
+ throw new LiveSessionModelSwitchError(requestedSelection);
2844
+ }
2845
+ if (timedOut && !timedOutDuringCompaction && !timedOutDuringToolExecution) {
2846
+ const lastTurnPromptTokens = derivePromptTokens(lastRunPromptUsage);
2847
+ const tokenUsedRatio = lastTurnPromptTokens != null && ctxInfo.tokens > 0 ? lastTurnPromptTokens / ctxInfo.tokens : 0;
2848
+ if (timeoutCompactionAttempts >= MAX_TIMEOUT_COMPACTION_ATTEMPTS) log$1.warn(`[timeout-compaction] already attempted timeout compaction ${timeoutCompactionAttempts} time(s); falling through to failover rotation`);
2849
+ else if (tokenUsedRatio > .65) {
2850
+ const timeoutDiagId = createCompactionDiagId();
2851
+ timeoutCompactionAttempts++;
2852
+ log$1.warn(`[timeout-compaction] LLM timed out with high prompt token usage (${Math.round(tokenUsedRatio * 100)}%); attempting compaction before retry (attempt ${timeoutCompactionAttempts}/${MAX_TIMEOUT_COMPACTION_ATTEMPTS}) diagId=${timeoutDiagId}`);
2853
+ let timeoutCompactResult;
2854
+ await runOwnsCompactionBeforeHook("timeout recovery");
2855
+ try {
2856
+ const timeoutCompactionRuntimeContext = {
2857
+ ...buildEmbeddedCompactionRuntimeContext({
2858
+ sessionKey: params.sessionKey,
2859
+ messageChannel: params.messageChannel,
2860
+ messageProvider: params.messageProvider,
2861
+ agentAccountId: params.agentAccountId,
2862
+ currentChannelId: params.currentChannelId,
2863
+ currentThreadTs: params.currentThreadTs,
2864
+ currentMessageId: params.currentMessageId,
2865
+ authProfileId: lastProfileId,
2866
+ workspaceDir: resolvedWorkspace,
2867
+ agentDir,
2868
+ config: params.config,
2869
+ skillsSnapshot: params.skillsSnapshot,
2870
+ senderId: params.senderId,
2871
+ provider,
2872
+ modelId,
2873
+ harnessRuntime: agentHarness.id,
2874
+ modelFallbacksOverride: params.modelFallbacksOverride,
2875
+ thinkLevel,
2876
+ reasoningLevel: params.reasoningLevel,
2877
+ bashElevated: params.bashElevated,
2878
+ extraSystemPrompt: params.extraSystemPrompt,
2879
+ sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
2880
+ ownerNumbers: params.ownerNumbers,
2881
+ activeProcessSessions: listActiveProcessSessionReferences({ scopeKey: resolveProcessToolScopeKey({
2882
+ sessionKey: params.sandboxSessionKey?.trim() || params.sessionKey,
2883
+ sessionId: activeSessionId,
2884
+ agentId: sessionAgentId
2885
+ }) })
2886
+ }),
2887
+ ...resolveContextEngineCapabilities({
2888
+ config: params.config,
2889
+ sessionKey: params.sessionKey,
2890
+ agentId: sessionAgentId,
2891
+ contextEnginePluginId: resolveContextEnginePluginId(),
2892
+ purpose: "context-engine.timeout-compaction"
2893
+ }),
2894
+ onCompactionHookMessages,
2895
+ ...attempt.promptCache ? { promptCache: attempt.promptCache } : {},
2896
+ runId: params.runId,
2897
+ trigger: "timeout_recovery",
2898
+ diagId: timeoutDiagId,
2899
+ attempt: timeoutCompactionAttempts,
2900
+ maxAttempts: MAX_TIMEOUT_COMPACTION_ATTEMPTS
2901
+ };
2902
+ timeoutCompactResult = await compactContextEngineWithSafetyTimeout(contextEngine, {
2903
+ sessionId: activeSessionId,
2904
+ sessionKey: params.sessionKey,
2905
+ sessionFile: activeSessionFile,
2906
+ tokenBudget: ctxInfo.tokens,
2907
+ force: true,
2908
+ compactionTarget: "budget",
2909
+ runtimeContext: timeoutCompactionRuntimeContext
2910
+ }, resolveCompactionTimeoutMs(params.config), params.abortSignal);
2911
+ } catch (compactErr) {
2912
+ log$1.warn(`[timeout-compaction] contextEngine.compact() threw during timeout recovery for ${provider}/${modelId}: ${String(compactErr)}`);
2913
+ timeoutCompactResult = {
2914
+ ok: false,
2915
+ compacted: false,
2916
+ reason: String(compactErr)
2917
+ };
2918
+ }
2919
+ if (timeoutCompactResult.compacted) adoptCompactionTranscript(timeoutCompactResult);
2920
+ await runOwnsCompactionAfterHook("timeout recovery", timeoutCompactResult);
2921
+ if (timeoutCompactResult.compacted) {
2922
+ autoCompactionCount += 1;
2923
+ if (typeof timeoutCompactResult.result?.tokensAfter === "number" && Number.isFinite(timeoutCompactResult.result.tokensAfter) && timeoutCompactResult.result.tokensAfter >= 0) lastCompactionTokensAfter = Math.floor(timeoutCompactResult.result.tokensAfter);
2924
+ if (contextEngine.info.ownsCompaction === true) await runPostCompactionSideEffects({
2925
+ config: params.config,
2926
+ sessionKey: params.sessionKey,
2927
+ agentId: sessionAgentId,
2928
+ sessionFile: activeSessionFile
2929
+ });
2930
+ log$1.info(`[timeout-compaction] compaction succeeded for ${provider}/${modelId}; retrying prompt`);
2931
+ postCompactionGuard.armPostCompaction();
2932
+ continue;
2933
+ } else log$1.warn(`[timeout-compaction] compaction did not reduce context for ${provider}/${modelId}; falling through to normal handling`);
2934
+ }
2935
+ }
2936
+ const contextOverflowError = !aborted ? (() => {
2937
+ if (promptError) {
2938
+ const errorText = formatErrorMessage(promptError);
2939
+ if (isLikelyContextOverflowError(errorText)) return {
2940
+ text: errorText,
2941
+ source: "promptError"
2942
+ };
2943
+ return null;
2944
+ }
2945
+ if (assistantErrorText && isLikelyContextOverflowError(assistantErrorText)) return {
2946
+ text: assistantErrorText,
2947
+ source: "assistantError"
2948
+ };
2949
+ return null;
2950
+ })() : null;
2951
+ if (contextOverflowError) {
2952
+ const overflowDiagId = createCompactionDiagId();
2953
+ const errorText = contextOverflowError.text;
2954
+ const msgCount = attempt.messagesSnapshot?.length ?? 0;
2955
+ const observedOverflowTokens = extractObservedOverflowTokenCount(errorText);
2956
+ const overflowTokenCountForCompaction = observedOverflowTokens ?? (ctxInfo.tokens > 0 ? ctxInfo.tokens + 1 : void 0);
2957
+ log$1.warn(`[context-overflow-diag] sessionKey=${params.sessionKey ?? params.sessionId} provider=${provider}/${modelId} source=${contextOverflowError.source} messages=${msgCount} sessionFile=${activeSessionFile} diagId=${overflowDiagId} compactionAttempts=${overflowCompactionAttempts} observedTokens=${observedOverflowTokens ?? "unknown"} compactionTokens=${overflowTokenCountForCompaction ?? "unknown"} error=${errorText.slice(0, 200)}`);
2958
+ const isCompactionFailure = isCompactionFailureError(errorText);
2959
+ const hadAttemptLevelCompaction = attemptCompactionCount > 0;
2960
+ if (!isCompactionFailure && hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
2961
+ overflowCompactionAttempts++;
2962
+ log$1.warn(`context overflow persisted after in-attempt compaction (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); retrying prompt without additional compaction for ${provider}/${modelId}`);
2963
+ if (preflightRecovery?.source === "mid-turn") continueFromCurrentTranscript();
2964
+ continue;
2965
+ }
2966
+ if (!isCompactionFailure && !hadAttemptLevelCompaction && overflowCompactionAttempts < MAX_OVERFLOW_COMPACTION_ATTEMPTS) {
2967
+ if (log$1.isEnabled("debug")) log$1.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=compact isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts + 1} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
2968
+ overflowCompactionAttempts++;
2969
+ log$1.warn(`context overflow detected (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); attempting auto-compaction for ${provider}/${modelId}`);
2970
+ let compactResult;
2971
+ await runOwnsCompactionBeforeHook("overflow recovery");
2972
+ try {
2973
+ const overflowCompactionRuntimeContext = {
2974
+ ...buildEmbeddedCompactionRuntimeContext({
2975
+ sessionKey: params.sessionKey,
2976
+ messageChannel: params.messageChannel,
2977
+ messageProvider: params.messageProvider,
2978
+ agentAccountId: params.agentAccountId,
2979
+ currentChannelId: params.currentChannelId,
2980
+ currentThreadTs: params.currentThreadTs,
2981
+ currentMessageId: params.currentMessageId,
2982
+ authProfileId: lastProfileId,
2983
+ workspaceDir: resolvedWorkspace,
2984
+ agentDir,
2985
+ config: params.config,
2986
+ skillsSnapshot: params.skillsSnapshot,
2987
+ senderId: params.senderId,
2988
+ provider,
2989
+ modelId,
2990
+ harnessRuntime: agentHarness.id,
2991
+ thinkLevel,
2992
+ reasoningLevel: params.reasoningLevel,
2993
+ bashElevated: params.bashElevated,
2994
+ extraSystemPrompt: params.extraSystemPrompt,
2995
+ sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
2996
+ ownerNumbers: params.ownerNumbers,
2997
+ activeProcessSessions: listActiveProcessSessionReferences({ scopeKey: resolveProcessToolScopeKey({
2998
+ sessionKey: params.sandboxSessionKey?.trim() || params.sessionKey,
2999
+ sessionId: activeSessionId,
3000
+ agentId: sessionAgentId
3001
+ }) })
3002
+ }),
3003
+ ...resolveContextEngineCapabilities({
3004
+ config: params.config,
3005
+ sessionKey: params.sessionKey,
3006
+ agentId: sessionAgentId,
3007
+ contextEnginePluginId: resolveContextEnginePluginId(),
3008
+ purpose: "context-engine.overflow-compaction"
3009
+ }),
3010
+ onCompactionHookMessages,
3011
+ ...attempt.promptCache ? { promptCache: attempt.promptCache } : {},
3012
+ runId: params.runId,
3013
+ trigger: "overflow",
3014
+ ...overflowTokenCountForCompaction !== void 0 ? { currentTokenCount: overflowTokenCountForCompaction } : {},
3015
+ diagId: overflowDiagId,
3016
+ attempt: overflowCompactionAttempts,
3017
+ maxAttempts: MAX_OVERFLOW_COMPACTION_ATTEMPTS
3018
+ };
3019
+ compactResult = await compactContextEngineWithSafetyTimeout(contextEngine, {
3020
+ sessionId: activeSessionId,
3021
+ sessionKey: params.sessionKey,
3022
+ sessionFile: activeSessionFile,
3023
+ tokenBudget: ctxInfo.tokens,
3024
+ ...overflowTokenCountForCompaction !== void 0 ? { currentTokenCount: overflowTokenCountForCompaction } : {},
3025
+ force: true,
3026
+ compactionTarget: "budget",
3027
+ runtimeContext: overflowCompactionRuntimeContext
3028
+ }, resolveCompactionTimeoutMs(params.config), params.abortSignal);
3029
+ if (compactResult.ok && compactResult.compacted) {
3030
+ adoptCompactionTranscript(compactResult);
3031
+ await runContextEngineMaintenance({
3032
+ contextEngine,
3033
+ sessionId: activeSessionId,
3034
+ sessionKey: params.sessionKey,
3035
+ sessionFile: activeSessionFile,
3036
+ reason: "compaction",
3037
+ runtimeContext: overflowCompactionRuntimeContext,
3038
+ config: params.config,
3039
+ agentId: sessionAgentId
3040
+ });
3041
+ }
3042
+ } catch (compactErr) {
3043
+ log$1.warn(`contextEngine.compact() threw during overflow recovery for ${provider}/${modelId}: ${String(compactErr)}`);
3044
+ compactResult = {
3045
+ ok: false,
3046
+ compacted: false,
3047
+ reason: String(compactErr)
3048
+ };
3049
+ }
3050
+ await runOwnsCompactionAfterHook("overflow recovery", compactResult);
3051
+ if (preflightRecovery && isNoRealConversationCompactionNoop(compactResult)) {
3052
+ lastCompactionTokensAfter = void 0;
3053
+ lastContextBudgetStatus = void 0;
3054
+ await resetNoRealConversationTokenSnapshot({
3055
+ config: params.config,
3056
+ sessionKey: params.sessionKey,
3057
+ agentId: sessionAgentId
3058
+ });
3059
+ log$1.info(`[context-overflow-precheck] stale token state had no real conversation messages for ${provider}/${modelId}; resetting the context snapshot and retrying prompt`);
3060
+ if (preflightRecovery.source === "mid-turn") continueFromCurrentTranscript();
3061
+ continue;
3062
+ }
3063
+ if (compactResult.compacted) {
3064
+ adoptCompactionTranscript(compactResult);
3065
+ if (typeof compactResult.result?.tokensAfter === "number" && Number.isFinite(compactResult.result.tokensAfter) && compactResult.result.tokensAfter >= 0) lastCompactionTokensAfter = Math.floor(compactResult.result.tokensAfter);
3066
+ if (preflightRecovery?.route === "compact_then_truncate") {
3067
+ const truncResult = await truncateOversizedToolResultsInSession({
3068
+ sessionFile: activeSessionFile,
3069
+ contextWindowTokens: ctxInfo.tokens,
3070
+ maxCharsOverride: resolveLiveToolResultMaxChars({
3071
+ contextWindowTokens: ctxInfo.tokens,
3072
+ cfg: params.config,
3073
+ agentId: sessionAgentId
3074
+ }),
3075
+ sessionId: activeSessionId,
3076
+ sessionKey: params.sessionKey,
3077
+ agentId: sessionAgentId,
3078
+ config: params.config
3079
+ });
3080
+ if (truncResult.truncated) log$1.info(`[context-overflow-precheck] post-compaction tool-result truncation succeeded for ${provider}/${modelId}; truncated ${truncResult.truncatedCount} tool result(s)`);
3081
+ else log$1.warn(`[context-overflow-precheck] post-compaction tool-result truncation did not help for ${provider}/${modelId}: ${truncResult.reason ?? "unknown"}`);
3082
+ }
3083
+ autoCompactionCount += 1;
3084
+ log$1.info(`auto-compaction succeeded for ${provider}/${modelId}; retrying prompt`);
3085
+ postCompactionGuard.armPostCompaction();
3086
+ if (preflightRecovery?.source === "mid-turn") continueFromCurrentTranscript();
3087
+ else if (params.currentMessageId !== void 0 && params.currentMessageId === lastPersistedCurrentMessageId) {
3088
+ nextAttemptPromptOverride = MID_TURN_PRECHECK_CONTINUATION_PROMPT;
3089
+ suppressNextUserMessagePersistence = true;
3090
+ }
3091
+ continue;
3092
+ }
3093
+ log$1.warn(`auto-compaction failed for ${provider}/${modelId}: ${compactResult.reason ?? "nothing to compact"}`);
3094
+ }
3095
+ if (!toolResultTruncationAttempted) {
3096
+ const contextWindowTokens = ctxInfo.tokens;
3097
+ const toolResultMaxChars = resolveLiveToolResultMaxChars({
3098
+ contextWindowTokens,
3099
+ cfg: params.config,
3100
+ agentId: sessionAgentId
3101
+ });
3102
+ if (attempt.messagesSnapshot ? sessionLikelyHasOversizedToolResults({
3103
+ messages: attempt.messagesSnapshot,
3104
+ contextWindowTokens,
3105
+ maxCharsOverride: toolResultMaxChars
3106
+ }) : false) {
3107
+ toolResultTruncationAttempted = true;
3108
+ log$1.warn(`[context-overflow-recovery] Attempting tool result truncation for ${provider}/${modelId} (contextWindow=${contextWindowTokens} tokens)`);
3109
+ const truncResult = await truncateOversizedToolResultsInSession({
3110
+ sessionFile: activeSessionFile,
3111
+ contextWindowTokens,
3112
+ maxCharsOverride: toolResultMaxChars,
3113
+ sessionId: activeSessionId,
3114
+ sessionKey: params.sessionKey,
3115
+ agentId: sessionAgentId,
3116
+ config: params.config
3117
+ });
3118
+ if (truncResult.truncated) {
3119
+ log$1.info(`[context-overflow-recovery] Truncated ${truncResult.truncatedCount} tool result(s); retrying prompt`);
3120
+ if (preflightRecovery?.source === "mid-turn") continueFromCurrentTranscript();
3121
+ continue;
3122
+ }
3123
+ log$1.warn(`[context-overflow-recovery] Tool result truncation did not help: ${truncResult.reason ?? "unknown"}`);
3124
+ }
3125
+ }
3126
+ if ((isCompactionFailure || overflowCompactionAttempts >= MAX_OVERFLOW_COMPACTION_ATTEMPTS) && log$1.isEnabled("debug")) log$1.debug(`[compaction-diag] decision diagId=${overflowDiagId} branch=give_up isCompactionFailure=${isCompactionFailure} hasOversizedToolResults=unknown attempt=${overflowCompactionAttempts} maxAttempts=${MAX_OVERFLOW_COMPACTION_ATTEMPTS}`);
3127
+ const kind = isCompactionFailure ? "compaction_failure" : "context_overflow";
3128
+ const overflowRecoveryText = "Context overflow: prompt too large for the model. Try /reset (or /new) to start a fresh session, or use a larger-context model.";
3129
+ log$1.warn(`[context-overflow-recovery] exhausted provider overflow recovery for ${provider}/${modelId}; livenessState=blocked suggestedAction=reset_or_new kind=${kind}`);
3130
+ attempt.setTerminalLifecycleMeta?.({
3131
+ replayInvalid: resolveReplayInvalidForAttempt(),
3132
+ livenessState: "blocked"
3133
+ });
3134
+ return {
3135
+ payloads: [{
3136
+ text: overflowRecoveryText,
3137
+ isError: true
3138
+ }],
3139
+ meta: {
3140
+ durationMs: Date.now() - started,
3141
+ agentMeta: buildErrorAgentMeta({
3142
+ sessionId: sessionIdUsed,
3143
+ sessionFile: activeSessionFile,
3144
+ provider,
3145
+ model: model.id,
3146
+ contextTokens: ctxInfo.tokens,
3147
+ usageAccumulator,
3148
+ lastRunPromptUsage,
3149
+ lastAssistant: sessionLastAssistant,
3150
+ lastTurnTotal
3151
+ }),
3152
+ systemPromptReport: attempt.systemPromptReport,
3153
+ finalAssistantVisibleText: overflowRecoveryText,
3154
+ finalAssistantRawText: overflowRecoveryText,
3155
+ finalPromptText: attempt.finalPromptText,
3156
+ replayInvalid: resolveReplayInvalidForAttempt(),
3157
+ livenessState: "blocked",
3158
+ error: {
3159
+ kind,
3160
+ message: errorText
3161
+ }
3162
+ }
3163
+ };
3164
+ }
3165
+ if (promptErrorSource === "hook:before_agent_run" && !aborted) {
3166
+ const errorText = formatErrorMessage(promptError);
3167
+ const replayInvalid = resolveReplayInvalidForAttempt();
3168
+ attempt.setTerminalLifecycleMeta?.({
3169
+ replayInvalid,
3170
+ livenessState: "blocked"
3171
+ });
3172
+ return {
3173
+ payloads: [{
3174
+ text: errorText,
3175
+ isError: true
3176
+ }],
3177
+ meta: {
3178
+ durationMs: Date.now() - started,
3179
+ agentMeta: buildErrorAgentMeta({
3180
+ sessionId: sessionIdUsed,
3181
+ sessionFile: activeSessionFile,
3182
+ provider,
3183
+ model: model.id,
3184
+ contextTokens: ctxInfo.tokens,
3185
+ usageAccumulator,
3186
+ lastRunPromptUsage,
3187
+ lastAssistant: sessionLastAssistant,
3188
+ lastTurnTotal
3189
+ }),
3190
+ systemPromptReport: attempt.systemPromptReport,
3191
+ finalAssistantVisibleText: errorText,
3192
+ finalAssistantRawText: errorText,
3193
+ finalPromptText: void 0,
3194
+ replayInvalid,
3195
+ livenessState: "blocked",
3196
+ error: {
3197
+ kind: "hook_block",
3198
+ message: errorText
3199
+ }
3200
+ }
3201
+ };
3202
+ }
3203
+ const hasRecoverableCodexAppServerTimeoutOutcome = Boolean(attempt.codexAppServerFailure && attempt.promptTimeoutOutcome);
3204
+ let shouldSurfaceCodexCompletionTimeout = false;
3205
+ if (promptError && promptErrorSource !== "compaction" && attempt.codexAppServerFailure) {
3206
+ if (resolveCodexAppServerRecoveryRetry({
3207
+ attempt,
3208
+ alreadyRetried: codexAppServerRecoveryRetries > 0
3209
+ }).retry) {
3210
+ codexAppServerRecoveryRetries += 1;
3211
+ suppressNextUserMessagePersistence = true;
3212
+ log$1.warn(`codex app-server replay-safe failure; retrying once failureKind=${attempt.codexAppServerFailure?.kind} runId=${params.runId} sessionId=${params.sessionId}`);
3213
+ continue;
3214
+ }
3215
+ shouldSurfaceCodexCompletionTimeout = attempt.codexAppServerFailure?.kind === "turn_completion_idle_timeout" && attempt.timedOut;
3216
+ if (attempt.codexAppServerFailure && !hasRecoverableCodexAppServerTimeoutOutcome && !shouldSurfaceCodexCompletionTimeout) throw promptError;
3217
+ }
3218
+ if (promptError && !aborted && promptErrorSource !== "compaction" && !hasRecoverableCodexAppServerTimeoutOutcome && !shouldSurfaceCodexCompletionTimeout) {
3219
+ const normalizedPromptFailover = coerceToFailoverError(promptError, {
3220
+ provider: activeErrorContext.provider,
3221
+ model: activeErrorContext.model,
3222
+ profileId: lastProfileId,
3223
+ sessionId: sessionIdUsed,
3224
+ lane: globalLane
3225
+ });
3226
+ const promptErrorDetails = normalizedPromptFailover ? describeFailoverError(normalizedPromptFailover) : describeFailoverError(promptError);
3227
+ if (normalizedPromptFailover?.suspend) suspendSession({
3228
+ cfg: params.config,
3229
+ agentDir,
3230
+ sessionId: activeSessionId ?? params.sessionId,
3231
+ laneId: globalLane,
3232
+ reason: resolveSessionSuspensionReason(normalizedPromptFailover.reason),
3233
+ failedProvider: normalizedPromptFailover.provider ?? provider,
3234
+ failedModel: normalizedPromptFailover.model ?? modelId
3235
+ });
3236
+ const errorText = promptErrorDetails.message || formatErrorMessage(promptError);
3237
+ if (await maybeRefreshRuntimeAuthForAuthError(errorText, runtimeAuthRetry)) {
3238
+ authRetryPending = true;
3239
+ continue;
3240
+ }
3241
+ if (/incorrect role information|roles must alternate/i.test(errorText)) {
3242
+ attempt.setTerminalLifecycleMeta?.({
3243
+ replayInvalid: resolveReplayInvalidForAttempt(),
3244
+ livenessState: "blocked"
3245
+ });
3246
+ return {
3247
+ payloads: [{
3248
+ text: "Message ordering conflict - please try again. If this persists, use /new to start a fresh session.",
3249
+ isError: true
3250
+ }],
3251
+ meta: {
3252
+ durationMs: Date.now() - started,
3253
+ agentMeta: buildErrorAgentMeta({
3254
+ sessionId: sessionIdUsed,
3255
+ sessionFile: activeSessionFile,
3256
+ provider,
3257
+ model: model.id,
3258
+ contextTokens: ctxInfo.tokens,
3259
+ usageAccumulator,
3260
+ lastRunPromptUsage,
3261
+ lastAssistant: sessionLastAssistant,
3262
+ lastTurnTotal
3263
+ }),
3264
+ systemPromptReport: attempt.systemPromptReport,
3265
+ finalPromptText: attempt.finalPromptText,
3266
+ replayInvalid: resolveReplayInvalidForAttempt(),
3267
+ livenessState: "blocked",
3268
+ error: {
3269
+ kind: "role_ordering",
3270
+ message: errorText
3271
+ }
3272
+ }
3273
+ };
3274
+ }
3275
+ const imageSizeError = parseImageSizeError(errorText);
3276
+ if (imageSizeError) {
3277
+ const maxMb = imageSizeError.maxMb;
3278
+ const maxMbLabel = typeof maxMb === "number" && Number.isFinite(maxMb) ? `${maxMb}` : null;
3279
+ const maxBytesHint = maxMbLabel ? ` (max ${maxMbLabel}MB)` : "";
3280
+ attempt.setTerminalLifecycleMeta?.({
3281
+ replayInvalid: resolveReplayInvalidForAttempt(),
3282
+ livenessState: "blocked"
3283
+ });
3284
+ return {
3285
+ payloads: [{
3286
+ text: `Image too large for the model${maxBytesHint}. Please compress or resize the image and try again.`,
3287
+ isError: true
3288
+ }],
3289
+ meta: {
3290
+ durationMs: Date.now() - started,
3291
+ agentMeta: buildErrorAgentMeta({
3292
+ sessionId: sessionIdUsed,
3293
+ sessionFile: activeSessionFile,
3294
+ provider,
3295
+ model: model.id,
3296
+ contextTokens: ctxInfo.tokens,
3297
+ usageAccumulator,
3298
+ lastRunPromptUsage,
3299
+ lastAssistant: sessionLastAssistant,
3300
+ lastTurnTotal
3301
+ }),
3302
+ systemPromptReport: attempt.systemPromptReport,
3303
+ finalPromptText: attempt.finalPromptText,
3304
+ replayInvalid: resolveReplayInvalidForAttempt(),
3305
+ livenessState: "blocked",
3306
+ error: {
3307
+ kind: "image_size",
3308
+ message: errorText
3309
+ }
3310
+ }
3311
+ };
3312
+ }
3313
+ const promptFailoverReason = promptErrorDetails.reason ?? classifyFailoverReason(errorText, { provider });
3314
+ const promptProfileFailureReason = resolveRunAuthProfileFailureReason(promptFailoverReason, { providerStarted: promptErrorSource === "prompt" });
3315
+ const promptFailoverFailure = promptFailoverReason !== null || isFailoverErrorMessage(errorText, { provider });
3316
+ const failedPromptProfileId = lastProfileId;
3317
+ const logPromptFailoverDecision = createFailoverDecisionLogger({
3318
+ stage: "prompt",
3319
+ runId: params.runId,
3320
+ rawError: errorText,
3321
+ failoverReason: promptFailoverReason,
3322
+ profileFailureReason: promptProfileFailureReason,
3323
+ provider,
3324
+ model: modelId,
3325
+ sourceProvider: provider,
3326
+ sourceModel: modelId,
3327
+ profileId: failedPromptProfileId,
3328
+ fallbackConfigured,
3329
+ aborted
3330
+ });
3331
+ if (promptFailoverReason === "rate_limit") maybeEscalateRateLimitProfileFallback({
3332
+ failoverProvider: provider,
3333
+ failoverModel: modelId,
3334
+ logFallbackDecision: logPromptFailoverDecision
3335
+ });
3336
+ let promptFailoverDecision = resolveRunFailoverDecision({
3337
+ stage: "prompt",
3338
+ aborted,
3339
+ externalAbort,
3340
+ fallbackConfigured,
3341
+ failoverFailure: promptFailoverFailure,
3342
+ failoverReason: promptFailoverReason,
3343
+ harnessOwnsTransport: pluginHarnessOwnsTransport,
3344
+ profileRotated: false
3345
+ });
3346
+ if (promptFailoverDecision.action === "rotate_profile" && await advanceAttemptAuthProfile()) {
3347
+ if (failedPromptProfileId && promptProfileFailureReason) maybeMarkAuthProfileFailure({
3348
+ profileId: failedPromptProfileId,
3349
+ reason: promptProfileFailureReason,
3350
+ modelId
3351
+ }).catch((err) => {
3352
+ log$1.warn(`prompt profile failure mark failed: ${String(err)}`);
3353
+ });
3354
+ traceAttempts.push({
3355
+ provider,
3356
+ model: modelId,
3357
+ result: promptFailoverReason === "timeout" ? "timeout" : "rotate_profile",
3358
+ ...promptFailoverReason ? { reason: promptFailoverReason } : {},
3359
+ stage: "prompt"
3360
+ });
3361
+ lastRetryFailoverReason = mergeRetryFailoverReason({
3362
+ previous: lastRetryFailoverReason,
3363
+ failoverReason: promptFailoverReason
3364
+ });
3365
+ logPromptFailoverDecision("rotate_profile");
3366
+ await maybeBackoffBeforeOverloadFailover(promptFailoverReason);
3367
+ continue;
3368
+ }
3369
+ if (promptFailoverDecision.action === "rotate_profile") promptFailoverDecision = resolveRunFailoverDecision({
3370
+ stage: "prompt",
3371
+ aborted,
3372
+ externalAbort,
3373
+ fallbackConfigured,
3374
+ failoverFailure: promptFailoverFailure,
3375
+ failoverReason: promptFailoverReason,
3376
+ harnessOwnsTransport: pluginHarnessOwnsTransport,
3377
+ profileRotated: true
3378
+ });
3379
+ if (failedPromptProfileId && promptProfileFailureReason) try {
3380
+ await maybeMarkAuthProfileFailure({
3381
+ profileId: failedPromptProfileId,
3382
+ reason: promptProfileFailureReason,
3383
+ modelId
3384
+ });
3385
+ } catch (err) {
3386
+ log$1.warn(`prompt profile failure mark failed: ${String(err)}`);
3387
+ }
3388
+ const fallbackThinking = pickFallbackThinkingLevel({
3389
+ message: errorText,
3390
+ attempted: attemptedThinking
3391
+ });
3392
+ if (fallbackThinking) {
3393
+ log$1.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
3394
+ thinkLevel = fallbackThinking;
3395
+ continue;
3396
+ }
3397
+ if (promptFailoverDecision.action === "fallback_model") {
3398
+ const fallbackReason = promptFailoverDecision.reason ?? "unknown";
3399
+ const status = resolveFailoverStatus(fallbackReason);
3400
+ traceAttempts.push({
3401
+ provider,
3402
+ model: modelId,
3403
+ result: promptFailoverReason === "timeout" ? "timeout" : "fallback_model",
3404
+ reason: fallbackReason,
3405
+ stage: "prompt",
3406
+ ...typeof status === "number" ? { status } : {}
3407
+ });
3408
+ logPromptFailoverDecision("fallback_model", { status });
3409
+ await maybeBackoffBeforeOverloadFailover(promptFailoverReason);
3410
+ throw normalizedPromptFailover ?? new FailoverError(errorText, {
3411
+ reason: fallbackReason,
3412
+ provider,
3413
+ model: modelId,
3414
+ profileId: lastProfileId,
3415
+ sessionId: sessionIdUsed,
3416
+ lane: globalLane,
3417
+ status
3418
+ });
3419
+ }
3420
+ if (promptFailoverDecision.action === "surface_error") {
3421
+ traceAttempts.push({
3422
+ provider,
3423
+ model: modelId,
3424
+ result: promptFailoverReason === "timeout" ? "timeout" : "surface_error",
3425
+ ...promptFailoverReason ? { reason: promptFailoverReason } : {},
3426
+ stage: "prompt"
3427
+ });
3428
+ logPromptFailoverDecision("surface_error");
3429
+ }
3430
+ throw promptError;
3431
+ }
3432
+ const assistantForFailover = currentAttemptAssistant ?? sessionAssistantForCandidate;
3433
+ const fallbackThinking = pickFallbackThinkingLevel({
3434
+ message: assistantForFailover?.errorMessage,
3435
+ attempted: attemptedThinking
3436
+ });
3437
+ if (fallbackThinking && !aborted) {
3438
+ log$1.warn(`unsupported thinking level for ${provider}/${modelId}; retrying with ${fallbackThinking}`);
3439
+ thinkLevel = fallbackThinking;
3440
+ continue;
3441
+ }
3442
+ const authFailure = isAuthAssistantError(assistantForFailover);
3443
+ const rateLimitFailure = isRateLimitAssistantError(assistantForFailover);
3444
+ const billingFailure = isBillingAssistantError(assistantForFailover);
3445
+ const failoverFailure = isFailoverAssistantError(assistantForFailover);
3446
+ const assistantFailoverReason = classifyFailoverReason(assistantForFailover?.errorMessage ?? "", { provider: assistantForFailover?.provider });
3447
+ const assistantProviderStarted = Boolean(currentAttemptAssistant?.provider) || idleTimedOut || timedOut && !timedOutDuringCompaction && !timedOutDuringToolExecution;
3448
+ const assistantProfileFailureReason = resolveRunAuthProfileFailureReason(assistantFailoverReason ?? (assistantProviderStarted && (timedOut || idleTimedOut) ? "timeout" : null), { providerStarted: assistantProviderStarted });
3449
+ const cloudCodeAssistFormatError = attempt.cloudCodeAssistFormatError;
3450
+ const imageDimensionError = parseImageDimensionError(assistantForFailover?.errorMessage ?? "");
3451
+ const failedAssistantProfileId = lastProfileId;
3452
+ const logAssistantFailoverDecision = createFailoverDecisionLogger({
3453
+ stage: "assistant",
3454
+ runId: params.runId,
3455
+ rawError: assistantForFailover?.errorMessage?.trim(),
3456
+ failoverReason: assistantFailoverReason,
3457
+ profileFailureReason: assistantProfileFailureReason,
3458
+ provider: activeErrorContext.provider,
3459
+ model: activeErrorContext.model,
3460
+ sourceProvider: assistantForFailover?.provider ?? provider,
3461
+ sourceModel: assistantForFailover?.model ?? modelId,
3462
+ profileId: failedAssistantProfileId,
3463
+ fallbackConfigured,
3464
+ timedOut,
3465
+ aborted
3466
+ });
3467
+ if (authFailure && await maybeRefreshRuntimeAuthForAuthError(assistantForFailover?.errorMessage ?? "", runtimeAuthRetry)) {
3468
+ authRetryPending = true;
3469
+ continue;
3470
+ }
3471
+ if (imageDimensionError && lastProfileId) {
3472
+ const details = [
3473
+ imageDimensionError.messageIndex !== void 0 ? `message=${imageDimensionError.messageIndex}` : null,
3474
+ imageDimensionError.contentIndex !== void 0 ? `content=${imageDimensionError.contentIndex}` : null,
3475
+ imageDimensionError.maxDimensionPx !== void 0 ? `limit=${imageDimensionError.maxDimensionPx}px` : null
3476
+ ].filter(Boolean).join(" ");
3477
+ log$1.warn(`Profile ${lastProfileId} rejected image payload${details ? ` (${details})` : ""}.`);
3478
+ }
3479
+ const assistantFailoverDecision = resolveRunFailoverDecision({
3480
+ stage: "assistant",
3481
+ allowFormatRetry: cloudCodeAssistFormatError,
3482
+ aborted,
3483
+ externalAbort,
3484
+ fallbackConfigured,
3485
+ failoverFailure,
3486
+ failoverReason: assistantFailoverReason,
3487
+ timedOut,
3488
+ idleTimedOut,
3489
+ timedOutDuringCompaction,
3490
+ timedOutDuringToolExecution,
3491
+ harnessOwnsTransport: pluginHarnessOwnsTransport,
3492
+ profileRotated: false
3493
+ });
3494
+ const assistantFailoverOutcome = await handleAssistantFailover({
3495
+ initialDecision: assistantFailoverDecision,
3496
+ aborted,
3497
+ externalAbort,
3498
+ fallbackConfigured,
3499
+ failoverFailure,
3500
+ failoverReason: assistantFailoverReason,
3501
+ timedOut,
3502
+ idleTimedOut,
3503
+ timedOutDuringCompaction,
3504
+ timedOutDuringToolExecution,
3505
+ allowSameModelIdleTimeoutRetry: timedOut && idleTimedOut && !timedOutDuringCompaction && !fallbackConfigured && canRestartForLiveSwitch && sameModelIdleTimeoutRetries < MAX_SAME_MODEL_IDLE_TIMEOUT_RETRIES,
3506
+ assistantProfileFailureReason,
3507
+ lastProfileId,
3508
+ modelId,
3509
+ provider,
3510
+ activeErrorContext,
3511
+ lastAssistant: assistantForFailover,
3512
+ config: params.config,
3513
+ sessionKey: params.sessionKey ?? params.sessionId,
3514
+ authFailure,
3515
+ rateLimitFailure,
3516
+ billingFailure,
3517
+ cloudCodeAssistFormatError,
3518
+ isProbeSession,
3519
+ overloadProfileRotations,
3520
+ overloadProfileRotationLimit,
3521
+ previousRetryFailoverReason: lastRetryFailoverReason,
3522
+ logAssistantFailoverDecision,
3523
+ warn: (message) => log$1.warn(message),
3524
+ maybeMarkAuthProfileFailure,
3525
+ maybeEscalateRateLimitProfileFallback,
3526
+ maybeBackoffBeforeOverloadFailover,
3527
+ advanceAuthProfile: advanceAttemptAuthProfile
3528
+ });
3529
+ overloadProfileRotations = assistantFailoverOutcome.overloadProfileRotations;
3530
+ if (assistantFailoverOutcome.action === "retry") {
3531
+ traceAttempts.push({
3532
+ provider: activeErrorContext.provider,
3533
+ model: activeErrorContext.model,
3534
+ result: assistantFailoverOutcome.retryKind === "same_model_idle_timeout" || assistantFailoverReason === "timeout" ? "timeout" : "rotate_profile",
3535
+ ...assistantFailoverReason ? { reason: assistantFailoverReason } : {},
3536
+ stage: "assistant"
3537
+ });
3538
+ if (assistantFailoverOutcome.retryKind === "same_model_idle_timeout") sameModelIdleTimeoutRetries += 1;
3539
+ lastRetryFailoverReason = assistantFailoverOutcome.lastRetryFailoverReason;
3540
+ continue;
3541
+ }
3542
+ if (assistantFailoverOutcome.action === "throw") {
3543
+ traceAttempts.push({
3544
+ provider: activeErrorContext.provider,
3545
+ model: activeErrorContext.model,
3546
+ result: assistantFailoverReason === "timeout" ? "timeout" : assistantFailoverDecision.action === "fallback_model" ? "fallback_model" : "error",
3547
+ ...assistantFailoverReason ? { reason: assistantFailoverReason } : {},
3548
+ stage: "assistant",
3549
+ ...typeof assistantFailoverOutcome.error.status === "number" ? { status: assistantFailoverOutcome.error.status } : {}
3550
+ });
3551
+ if (assistantFailoverOutcome.error.suspend) suspendSession({
3552
+ cfg: params.config,
3553
+ agentDir,
3554
+ sessionId: activeSessionId ?? params.sessionId,
3555
+ laneId: globalLane,
3556
+ reason: resolveSessionSuspensionReason(assistantFailoverOutcome.error.reason),
3557
+ failedProvider: assistantFailoverOutcome.error.provider ?? provider,
3558
+ failedModel: assistantFailoverOutcome.error.model ?? modelId
3559
+ });
3560
+ throw assistantFailoverOutcome.error;
3561
+ }
3562
+ const usageMeta = buildUsageAgentMetaFields({
3563
+ usageAccumulator,
3564
+ lastAssistantUsage: sessionLastAssistant?.usage,
3565
+ lastRunPromptUsage,
3566
+ lastTurnTotal
3567
+ });
3568
+ const reportedModelRef = resolveReportedModelRef({
3569
+ provider,
3570
+ model: model.id,
3571
+ assistant: sessionLastAssistant
3572
+ });
3573
+ const agentMeta = {
3574
+ sessionId: sessionIdUsed,
3575
+ sessionFile: sessionFileUsed,
3576
+ provider: reportedModelRef.provider,
3577
+ model: reportedModelRef.model,
3578
+ contextTokens: ctxInfo.tokens,
3579
+ agentHarnessId: attempt.agentHarnessId,
3580
+ usage: usageMeta.usage,
3581
+ lastCallUsage: usageMeta.lastCallUsage,
3582
+ promptTokens: usageMeta.promptTokens,
3583
+ ...lastContextBudgetStatus ? { contextBudgetStatus: lastContextBudgetStatus } : {},
3584
+ compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
3585
+ compactionTokensAfter: lastCompactionTokensAfter
3586
+ };
3587
+ const finalAssistantVisibleText = resolveFinalAssistantVisibleText(sessionLastAssistant);
3588
+ const finalAssistantRawText = resolveFinalAssistantRawText(sessionLastAssistant);
3589
+ const payloads = buildEmbeddedRunPayloads({
3590
+ assistantTexts: attempt.assistantTexts,
3591
+ toolMetas: attempt.toolMetas,
3592
+ lastAssistant: attempt.lastAssistant,
3593
+ currentAssistant: currentAttemptAssistant ?? null,
3594
+ lastToolError: attempt.lastToolError,
3595
+ config: params.config,
3596
+ isCronTrigger: params.trigger === "cron",
3597
+ sessionKey: params.sessionKey ?? params.sessionId,
3598
+ provider: activeErrorContext.provider,
3599
+ model: activeErrorContext.model,
3600
+ verboseLevel: params.verboseLevel,
3601
+ reasoningLevel: params.reasoningLevel,
3602
+ thinkingLevel: params.thinkLevel,
3603
+ toolResultFormat: resolvedToolResultFormat,
3604
+ suppressToolErrorWarnings: params.suppressToolErrorWarnings,
3605
+ inlineToolResultsAllowed: false,
3606
+ didSendViaMessagingTool: attempt.didSendViaMessagingTool,
3607
+ messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
3608
+ sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
3609
+ agentId: params.agentId,
3610
+ runId: params.runId,
3611
+ runAborted: aborted,
3612
+ didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
3613
+ heartbeatToolResponse: attempt.heartbeatToolResponse
3614
+ });
3615
+ const payloadsWithToolMedia = mergeAttemptToolMediaPayloads({
3616
+ payloads,
3617
+ toolMediaUrls: attempt.toolMediaUrls,
3618
+ toolAudioAsVoice: attempt.toolAudioAsVoice,
3619
+ toolTrustedLocalMedia: attempt.toolTrustedLocalMedia,
3620
+ sourceReplyDeliveryMode: params.sourceReplyDeliveryMode
3621
+ });
3622
+ const timedOutDuringPrompt = timedOut && !timedOutDuringCompaction && !timedOutDuringToolExecution;
3623
+ const finalAssistantStopReason = (sessionLastAssistant?.stopReason ?? "").trim().toLowerCase();
3624
+ const recoveredFinalAssistantTextAfterPromptTimeout = timedOutDuringPrompt && [
3625
+ "completed",
3626
+ "end_turn",
3627
+ "stop"
3628
+ ].includes(finalAssistantStopReason) ? (finalAssistantVisibleText ?? finalAssistantRawText)?.trim() : void 0;
3629
+ const payloadAlreadyContainsRecoveredFinalAssistant = recoveredFinalAssistantTextAfterPromptTimeout ? (payloadsWithToolMedia ?? []).some((payload) => payload?.isError !== true && payload?.isReasoning !== true && typeof payload.text === "string" && payload.text.trim() === recoveredFinalAssistantTextAfterPromptTimeout) : false;
3630
+ const recoveredFinalAssistantPayloadsAfterPromptTimeout = recoveredFinalAssistantTextAfterPromptTimeout && !payloadAlreadyContainsRecoveredFinalAssistant ? [{ text: recoveredFinalAssistantTextAfterPromptTimeout }] : void 0;
3631
+ const hasSuccessfulFinalAssistantAfterPromptTimeout = timedOutDuringPrompt && Boolean(payloadAlreadyContainsRecoveredFinalAssistant || recoveredFinalAssistantPayloadsAfterPromptTimeout?.length);
3632
+ const hasPartialAssistantTextAfterPromptTimeout = timedOutDuringPrompt && (attempt.assistantTexts ?? []).some((text) => text.trim().length > 0) && !attempt.clientToolCalls && !attempt.yieldDetected && !attempt.didSendViaMessagingTool && !attempt.didSendDeterministicApprovalPrompt && !attempt.lastToolError && (attempt.toolMetas?.length ?? 0) === 0;
3633
+ const attemptToolSummary = buildTraceToolSummary({
3634
+ toolMetas: attempt.toolMetas,
3635
+ hadFailure: Boolean(attempt.lastToolError)
3636
+ });
3637
+ const failureSignal = resolveEmbeddedRunFailureSignal({
3638
+ trigger: params.trigger,
3639
+ lastToolError: attempt.lastToolError
3640
+ });
3641
+ if (timedOutDuringPrompt && !hasSuccessfulFinalAssistantAfterPromptTimeout && (shouldSurfaceCodexCompletionTimeout || !hasMessagingToolDeliveryEvidence(attempt))) {
3642
+ const defaultTimeoutText = idleTimedOut ? "The model did not produce a response before the model idle timeout. Please try again, or increase `models.providers.<id>.timeoutSeconds` for slow local or self-hosted providers. If `agents.defaults.timeoutSeconds` or a run-specific timeout is lower, raise that ceiling too; provider timeouts cannot extend the whole agent run." : "Request timed out before a response was generated. Please try again, or increase `agents.defaults.timeoutSeconds` in your config.";
3643
+ const timeoutText = attempt.promptTimeoutOutcome?.message?.trim() || defaultTimeoutText;
3644
+ const replayInvalid = attempt.promptTimeoutOutcome?.replayInvalid ?? resolveReplayInvalidForAttempt(null);
3645
+ const livenessState = attempt.promptTimeoutOutcome?.livenessState ?? resolveRunLivenessState({
3646
+ payloadCount: hasPartialAssistantTextAfterPromptTimeout ? 0 : payloads.length,
3647
+ aborted,
3648
+ timedOut,
3649
+ attempt,
3650
+ incompleteTurnText: null
3651
+ });
3652
+ const timeoutPhase = attempt.promptTimeoutOutcome?.timeoutPhase ?? "provider";
3653
+ const providerStarted = attempt.promptTimeoutOutcome?.providerStarted ?? true;
3654
+ attempt.setTerminalLifecycleMeta?.({
3655
+ replayInvalid,
3656
+ livenessState,
3657
+ timeoutPhase,
3658
+ providerStarted
3659
+ });
3660
+ return {
3661
+ payloads: [...hasPartialAssistantTextAfterPromptTimeout ? [] : payloadsWithToolMedia || [], {
3662
+ text: timeoutText,
3663
+ isError: true
3664
+ }],
3665
+ meta: {
3666
+ durationMs: Date.now() - started,
3667
+ agentMeta,
3668
+ aborted,
3669
+ systemPromptReport: attempt.systemPromptReport,
3670
+ finalPromptText: attempt.finalPromptText,
3671
+ finalAssistantVisibleText,
3672
+ finalAssistantRawText,
3673
+ replayInvalid,
3674
+ livenessState,
3675
+ timeoutPhase,
3676
+ providerStarted,
3677
+ toolSummary: attemptToolSummary,
3678
+ ...failureSignal ? { failureSignal } : {},
3679
+ agentHarnessResultClassification: attempt.agentHarnessResultClassification
3680
+ },
3681
+ didSendViaMessagingTool: attempt.didSendViaMessagingTool,
3682
+ didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
3683
+ messagingToolSentTexts: attempt.messagingToolSentTexts,
3684
+ messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
3685
+ messagingToolSentTargets: attempt.messagingToolSentTargets,
3686
+ messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
3687
+ heartbeatToolResponse: attempt.heartbeatToolResponse,
3688
+ successfulCronAdds: attempt.successfulCronAdds,
3689
+ acceptedSessionSpawns: attempt.acceptedSessionSpawns
3690
+ };
3691
+ }
3692
+ const silentToolResultReplyPayload = resolveSilentToolResultReplyPayload({
3693
+ isCronTrigger: params.trigger === "cron",
3694
+ payloadCount: payloadsWithToolMedia?.length ?? 0,
3695
+ aborted,
3696
+ timedOut,
3697
+ attempt
3698
+ });
3699
+ const payloadsForTerminalPath = recoveredFinalAssistantPayloadsAfterPromptTimeout ? recoveredFinalAssistantPayloadsAfterPromptTimeout : payloadsWithToolMedia?.length ? payloadsWithToolMedia : silentToolResultReplyPayload ? [silentToolResultReplyPayload] : payloadsWithToolMedia;
3700
+ const payloadCount = payloadsForTerminalPath?.length ?? 0;
3701
+ const emptyAssistantReplyIsSilent = shouldTreatEmptyAssistantReplyAsSilent({
3702
+ allowEmptyAssistantReplyAsSilent: params.allowEmptyAssistantReplyAsSilent,
3703
+ payloadCount,
3704
+ aborted,
3705
+ timedOut,
3706
+ attempt
3707
+ });
3708
+ const nextPlanningOnlyRetryInstruction = emptyAssistantReplyIsSilent ? null : resolvePlanningOnlyRetryInstruction({
3709
+ provider,
3710
+ modelId,
3711
+ executionContract,
3712
+ prompt: params.prompt,
3713
+ aborted,
3714
+ timedOut,
3715
+ attempt
3716
+ });
3717
+ const nextReasoningOnlyRetryInstruction = emptyAssistantReplyIsSilent ? null : resolveReasoningOnlyRetryInstruction({
3718
+ provider: activeErrorContext.provider,
3719
+ modelId: activeErrorContext.model,
3720
+ modelApi: effectiveModel.api,
3721
+ executionContract,
3722
+ aborted,
3723
+ timedOut,
3724
+ attempt
3725
+ });
3726
+ const nextEmptyResponseRetryInstruction = emptyAssistantReplyIsSilent ? null : resolveEmptyResponseRetryInstruction({
3727
+ provider: activeErrorContext.provider,
3728
+ modelId: activeErrorContext.model,
3729
+ modelApi: effectiveModel.api,
3730
+ executionContract,
3731
+ payloadCount,
3732
+ aborted,
3733
+ timedOut,
3734
+ attempt
3735
+ });
3736
+ if (nextPlanningOnlyRetryInstruction && planningOnlyRetryAttempts < maxPlanningOnlyRetryAttempts) {
3737
+ const planDetails = extractPlanningOnlyPlanDetails((attempt.assistantTexts ?? []).join("\n\n").trim());
3738
+ if (planDetails) {
3739
+ emitAgentPlanEvent({
3740
+ runId: params.runId,
3741
+ ...params.sessionKey ? { sessionKey: params.sessionKey } : {},
3742
+ data: {
3743
+ phase: "update",
3744
+ title: "Assistant proposed a plan",
3745
+ explanation: planDetails.explanation,
3746
+ steps: planDetails.steps,
3747
+ source: "planning_only_retry"
3748
+ }
3749
+ });
3750
+ params.onAgentEvent?.({
3751
+ stream: "plan",
3752
+ data: {
3753
+ phase: "update",
3754
+ title: "Assistant proposed a plan",
3755
+ explanation: planDetails.explanation,
3756
+ steps: planDetails.steps,
3757
+ source: "planning_only_retry"
3758
+ }
3759
+ });
3760
+ }
3761
+ planningOnlyRetryAttempts += 1;
3762
+ planningOnlyRetryInstruction = nextPlanningOnlyRetryInstruction;
3763
+ const planningOnlyRetryLogPrefix = executionContract === "strict-agentic" ? "strict-agentic execution contract triggered" : "planning-only turn detected";
3764
+ log$1.warn(`${planningOnlyRetryLogPrefix}: runId=${params.runId} sessionId=${params.sessionId} provider=${provider}/${modelId} harness=${sanitizeForLog(agentHarness.id)} contract=${executionContract} configured=${configuredExecutionContractForLog} — retrying ${planningOnlyRetryAttempts}/${maxPlanningOnlyRetryAttempts} with act-now steer`);
3765
+ continue;
3766
+ }
3767
+ if (!nextPlanningOnlyRetryInstruction && nextReasoningOnlyRetryInstruction && reasoningOnlyRetryAttempts < maxReasoningOnlyRetryAttempts) {
3768
+ reasoningOnlyRetryAttempts += 1;
3769
+ reasoningOnlyRetryInstruction = nextReasoningOnlyRetryInstruction;
3770
+ log$1.warn(`reasoning-only assistant turn detected: runId=${params.runId} sessionId=${params.sessionId} provider=${activeErrorContext.provider}/${activeErrorContext.model} — retrying ${reasoningOnlyRetryAttempts}/${maxReasoningOnlyRetryAttempts} with visible-answer continuation`);
3771
+ continue;
3772
+ }
3773
+ const reasoningOnlyRetriesExhausted = !nextPlanningOnlyRetryInstruction && nextReasoningOnlyRetryInstruction && reasoningOnlyRetryAttempts >= maxReasoningOnlyRetryAttempts;
3774
+ if (!emptyAssistantReplyIsSilent && shouldRetryMissingAssistantTurn({
3775
+ payloadCount,
3776
+ aborted,
3777
+ promptError,
3778
+ timedOut,
3779
+ attempt
3780
+ }) && missingAssistantRetryAttempts < MAX_MISSING_ASSISTANT_RETRIES) {
3781
+ missingAssistantRetryAttempts += 1;
3782
+ log$1.warn(`missing assistant terminal message detected: runId=${params.runId} sessionId=${params.sessionId} provider=${activeErrorContext.provider}/${activeErrorContext.model} — retrying ${missingAssistantRetryAttempts}/${MAX_MISSING_ASSISTANT_RETRIES} with same prompt`);
3783
+ continue;
3784
+ }
3785
+ if (!nextPlanningOnlyRetryInstruction && !nextReasoningOnlyRetryInstruction && nextEmptyResponseRetryInstruction && emptyResponseRetryAttempts < maxEmptyResponseRetryAttempts) {
3786
+ emptyResponseRetryAttempts += 1;
3787
+ emptyResponseRetryInstruction = nextEmptyResponseRetryInstruction;
3788
+ log$1.warn(`empty response detected: runId=${params.runId} sessionId=${params.sessionId} provider=${activeErrorContext.provider}/${activeErrorContext.model} — retrying ${emptyResponseRetryAttempts}/${maxEmptyResponseRetryAttempts} with visible-answer continuation`);
3789
+ continue;
3790
+ }
3791
+ const incompleteTurnText = emptyAssistantReplyIsSilent ? null : resolveIncompleteTurnPayloadText({
3792
+ payloadCount,
3793
+ aborted,
3794
+ timedOut,
3795
+ attempt
3796
+ });
3797
+ if (!emptyAssistantReplyIsSilent && attemptCompactionCount > 0 && payloadCount === 0 && !aborted && !promptError && !timedOut && !attempt.clientToolCalls && !attempt.yieldDetected && !attempt.didSendDeterministicApprovalPrompt && !attempt.lastToolError && !resolveAttemptReplayMetadata(attempt).hadPotentialSideEffects && compactionContinuationRetryAttempts < 1) {
3798
+ compactionContinuationRetryAttempts += 1;
3799
+ compactionContinuationRetryInstruction = COMPACTION_CONTINUATION_RETRY_INSTRUCTION;
3800
+ log$1.warn(`compaction interrupted visible final answer: runId=${params.runId} sessionId=${params.sessionId} compactions=${attemptCompactionCount} — retrying ${compactionContinuationRetryAttempts}/1 with compacted-transcript continuation`);
3801
+ postCompactionGuard.armPostCompaction();
3802
+ continue;
3803
+ }
3804
+ compactionContinuationRetryInstruction = null;
3805
+ if (reasoningOnlyRetriesExhausted && !finalAssistantVisibleText) log$1.warn(`reasoning-only retries exhausted: runId=${params.runId} sessionId=${params.sessionId} provider=${activeErrorContext.provider}/${activeErrorContext.model} attempts=${reasoningOnlyRetryAttempts}/${maxReasoningOnlyRetryAttempts} — surfacing incomplete-turn error`);
3806
+ if (!incompleteTurnText && nextPlanningOnlyRetryInstruction && strictAgenticActive) {
3807
+ log$1.warn(`strict-agentic run exhausted planning-only retries: runId=${params.runId} sessionId=${params.sessionId} provider=${provider}/${modelId} configured=${configuredExecutionContractForLog} — surfacing blocked state`);
3808
+ const replayInvalid = resolveReplayInvalidForAttempt(null);
3809
+ const livenessState = "blocked";
3810
+ attempt.setTerminalLifecycleMeta?.({
3811
+ replayInvalid,
3812
+ livenessState
3813
+ });
3814
+ return {
3815
+ payloads: [{
3816
+ text: STRICT_AGENTIC_BLOCKED_TEXT,
3817
+ isError: true
3818
+ }],
3819
+ meta: {
3820
+ durationMs: Date.now() - started,
3821
+ agentMeta,
3822
+ aborted,
3823
+ systemPromptReport: attempt.systemPromptReport,
3824
+ finalPromptText: attempt.finalPromptText,
3825
+ finalAssistantVisibleText,
3826
+ finalAssistantRawText,
3827
+ replayInvalid,
3828
+ livenessState,
3829
+ toolSummary: attemptToolSummary,
3830
+ ...failureSignal ? { failureSignal } : {},
3831
+ agentHarnessResultClassification: attempt.agentHarnessResultClassification
3832
+ },
3833
+ didSendViaMessagingTool: attempt.didSendViaMessagingTool,
3834
+ didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
3835
+ messagingToolSentTexts: attempt.messagingToolSentTexts,
3836
+ messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
3837
+ messagingToolSentTargets: attempt.messagingToolSentTargets,
3838
+ messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
3839
+ heartbeatToolResponse: attempt.heartbeatToolResponse,
3840
+ successfulCronAdds: attempt.successfulCronAdds,
3841
+ acceptedSessionSpawns: attempt.acceptedSessionSpawns
3842
+ };
3843
+ }
3844
+ if (reasoningOnlyRetriesExhausted && !finalAssistantVisibleText) {
3845
+ const replayInvalid = resolveReplayInvalidForAttempt("⚠️ Agent couldn't generate a response. Please try again.");
3846
+ const livenessState = resolveRunLivenessState({
3847
+ payloadCount: 0,
3848
+ aborted,
3849
+ timedOut,
3850
+ attempt,
3851
+ incompleteTurnText: "⚠️ Agent couldn't generate a response. Please try again."
3852
+ });
3853
+ attempt.setTerminalLifecycleMeta?.({
3854
+ replayInvalid,
3855
+ livenessState
3856
+ });
3857
+ if (lastProfileId) await maybeMarkAuthProfileFailure({
3858
+ profileId: lastProfileId,
3859
+ reason: assistantProfileFailureReason
3860
+ });
3861
+ return {
3862
+ payloads: [{
3863
+ text: "⚠️ Agent couldn't generate a response. Please try again.",
3864
+ isError: true
3865
+ }],
3866
+ meta: {
3867
+ durationMs: Date.now() - started,
3868
+ agentMeta,
3869
+ aborted,
3870
+ systemPromptReport: attempt.systemPromptReport,
3871
+ finalPromptText: attempt.finalPromptText,
3872
+ finalAssistantVisibleText,
3873
+ finalAssistantRawText,
3874
+ replayInvalid,
3875
+ livenessState,
3876
+ toolSummary: attemptToolSummary,
3877
+ ...failureSignal ? { failureSignal } : {},
3878
+ agentHarnessResultClassification: attempt.agentHarnessResultClassification
3879
+ },
3880
+ didSendViaMessagingTool: attempt.didSendViaMessagingTool,
3881
+ didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
3882
+ messagingToolSentTexts: attempt.messagingToolSentTexts,
3883
+ messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
3884
+ messagingToolSentTargets: attempt.messagingToolSentTargets,
3885
+ messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
3886
+ heartbeatToolResponse: attempt.heartbeatToolResponse,
3887
+ successfulCronAdds: attempt.successfulCronAdds,
3888
+ acceptedSessionSpawns: attempt.acceptedSessionSpawns
3889
+ };
3890
+ }
3891
+ if (!nextPlanningOnlyRetryInstruction && !nextReasoningOnlyRetryInstruction && nextEmptyResponseRetryInstruction && emptyResponseRetryAttempts >= maxEmptyResponseRetryAttempts) log$1.warn(`empty response retries exhausted: runId=${params.runId} sessionId=${params.sessionId} provider=${activeErrorContext.provider}/${activeErrorContext.model} attempts=${emptyResponseRetryAttempts}/${maxEmptyResponseRetryAttempts} — surfacing incomplete-turn error`);
3892
+ const silentErrorContent = sessionLastAssistant?.content;
3893
+ if (incompleteTurnText && !aborted && !promptError && !timedOut && sessionLastAssistant?.stopReason === "error" && ((sessionLastAssistant?.usage)?.output ?? 0) === 0 && (silentErrorContent?.length ?? 0) === 0 && (attempt.replayMetadata ? !attempt.replayMetadata.hadPotentialSideEffects : false) && emptyErrorRetries < MAX_EMPTY_ERROR_RETRIES) {
3894
+ emptyErrorRetries += 1;
3895
+ log$1.warn(`[empty-error-retry] stopReason=error output=0; resubmitting attempt=${emptyErrorRetries}/${MAX_EMPTY_ERROR_RETRIES} provider=${sessionLastAssistant?.provider ?? provider} model=${sessionLastAssistant?.model ?? model.id} sessionKey=${params.sessionKey ?? params.sessionId}`);
3896
+ continue;
3897
+ }
3898
+ if (incompleteTurnText) {
3899
+ const replayInvalid = resolveReplayInvalidForAttempt(incompleteTurnText);
3900
+ const livenessState = resolveRunLivenessState({
3901
+ payloadCount,
3902
+ aborted,
3903
+ timedOut,
3904
+ attempt,
3905
+ incompleteTurnText
3906
+ });
3907
+ attempt.setTerminalLifecycleMeta?.({
3908
+ replayInvalid,
3909
+ livenessState
3910
+ });
3911
+ const incompleteStopReason = attempt.lastAssistant?.stopReason;
3912
+ const replayMetadata = resolveAttemptReplayMetadata(attempt);
3913
+ log$1.warn(`incomplete turn detected: runId=${params.runId} sessionId=${params.sessionId} provider=${activeErrorContext.provider}/${activeErrorContext.model} stopReason=${incompleteStopReason ?? "missing"} hasLastAssistant=${attempt.lastAssistant ? "yes" : "no"} hasCurrentAttemptAssistant=${attempt.currentAttemptAssistant ? "yes" : "no"} payloads=${payloadCount} tools=${attempt.toolMetas?.length ?? 0} replaySafe=${replayMetadata.replaySafe ? "yes" : "no"} compactions=${attemptCompactionCount} planningRetries=${planningOnlyRetryAttempts}/${maxPlanningOnlyRetryAttempts} reasoningRetries=${reasoningOnlyRetryAttempts}/${maxReasoningOnlyRetryAttempts} emptyRetries=${emptyResponseRetryAttempts}/${maxEmptyResponseRetryAttempts} missingAssistantRetries=${missingAssistantRetryAttempts}/${MAX_MISSING_ASSISTANT_RETRIES} — surfacing error to user`);
3914
+ if (lastProfileId) await maybeMarkAuthProfileFailure({
3915
+ profileId: lastProfileId,
3916
+ reason: assistantProfileFailureReason
3917
+ });
3918
+ return {
3919
+ payloads: [{
3920
+ text: incompleteTurnText,
3921
+ isError: true
3922
+ }],
3923
+ meta: {
3924
+ durationMs: Date.now() - started,
3925
+ agentMeta,
3926
+ aborted,
3927
+ systemPromptReport: attempt.systemPromptReport,
3928
+ finalPromptText: attempt.finalPromptText,
3929
+ finalAssistantVisibleText,
3930
+ finalAssistantRawText,
3931
+ replayInvalid,
3932
+ livenessState,
3933
+ toolSummary: attemptToolSummary,
3934
+ ...failureSignal ? { failureSignal } : {},
3935
+ agentHarnessResultClassification: attempt.agentHarnessResultClassification
3936
+ },
3937
+ didSendViaMessagingTool: attempt.didSendViaMessagingTool,
3938
+ didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
3939
+ messagingToolSentTexts: attempt.messagingToolSentTexts,
3940
+ messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
3941
+ messagingToolSentTargets: attempt.messagingToolSentTargets,
3942
+ messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
3943
+ heartbeatToolResponse: attempt.heartbeatToolResponse,
3944
+ successfulCronAdds: attempt.successfulCronAdds,
3945
+ acceptedSessionSpawns: attempt.acceptedSessionSpawns
3946
+ };
3947
+ }
3948
+ log$1.debug(`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`);
3949
+ if (lastProfileId) await markAuthProfileSuccess({
3950
+ store: profileFailureStore,
3951
+ provider: resolveAuthProfileStateProvider(profileFailureStore, lastProfileId, provider),
3952
+ profileId: lastProfileId,
3953
+ agentDir: params.agentDir
3954
+ });
3955
+ const replayInvalid = resolveReplayInvalidForAttempt(null);
3956
+ const livenessState = attempt.yieldDetected ? "paused" : resolveRunLivenessState({
3957
+ payloadCount,
3958
+ aborted,
3959
+ timedOut,
3960
+ attempt,
3961
+ incompleteTurnText: null
3962
+ });
3963
+ const stopReason = attempt.clientToolCalls ? "tool_calls" : attempt.yieldDetected ? "end_turn" : sessionLastAssistant?.stopReason;
3964
+ const terminalPayloads = emptyAssistantReplyIsSilent ? [{ text: SILENT_REPLY_TOKEN }] : payloadsForTerminalPath;
3965
+ attempt.setTerminalLifecycleMeta?.({
3966
+ replayInvalid,
3967
+ livenessState,
3968
+ stopReason,
3969
+ yielded: attempt.yieldDetected === true
3970
+ });
3971
+ return {
3972
+ payloads: terminalPayloads?.length ? terminalPayloads : void 0,
3973
+ ...attempt.diagnosticTrace ? { diagnosticTrace: freezeDiagnosticTraceContext(attempt.diagnosticTrace) } : {},
3974
+ meta: {
3975
+ durationMs: Date.now() - started,
3976
+ agentMeta,
3977
+ aborted,
3978
+ systemPromptReport: attempt.systemPromptReport,
3979
+ finalPromptText: attempt.finalPromptText,
3980
+ finalAssistantVisibleText,
3981
+ finalAssistantRawText,
3982
+ replayInvalid,
3983
+ livenessState,
3984
+ agentHarnessResultClassification: attempt.agentHarnessResultClassification,
3985
+ ...attempt.yieldDetected ? { yielded: true } : {},
3986
+ ...emptyAssistantReplyIsSilent ? { terminalReplyKind: "silent-empty" } : {},
3987
+ stopReason,
3988
+ pendingToolCalls: attempt.clientToolCalls?.map((call) => ({
3989
+ id: randomBytes(5).toString("hex").slice(0, 9),
3990
+ name: call.name,
3991
+ arguments: JSON.stringify(call.params)
3992
+ })),
3993
+ executionTrace: {
3994
+ winnerProvider: reportedModelRef.provider,
3995
+ winnerModel: reportedModelRef.model,
3996
+ attempts: traceAttempts.length > 0 || sessionLastAssistant?.provider || sessionLastAssistant?.model ? [...traceAttempts, {
3997
+ provider: reportedModelRef.provider,
3998
+ model: reportedModelRef.model,
3999
+ result: "success",
4000
+ stage: "assistant"
4001
+ }] : void 0,
4002
+ fallbackUsed: traceAttempts.length > 0,
4003
+ runner: "embedded"
4004
+ },
4005
+ requestShaping: {
4006
+ ...lastProfileId ? { authMode: "auth-profile" } : {},
4007
+ ...thinkLevel ? { thinking: thinkLevel } : {},
4008
+ ...params.reasoningLevel ? { reasoning: params.reasoningLevel } : {},
4009
+ ...params.verboseLevel ? { verbose: params.verboseLevel } : {},
4010
+ ...params.blockReplyBreak ? { blockStreaming: params.blockReplyBreak } : {}
4011
+ },
4012
+ toolSummary: attemptToolSummary,
4013
+ ...failureSignal ? { failureSignal } : {},
4014
+ completion: {
4015
+ ...stopReason ? { stopReason } : {},
4016
+ ...stopReason ? { finishReason: stopReason } : {},
4017
+ ...stopReason?.toLowerCase().includes("refusal") ? { refusal: true } : {}
4018
+ },
4019
+ contextManagement: autoCompactionCount > 0 ? { lastTurnCompactions: autoCompactionCount } : void 0
4020
+ },
4021
+ didSendViaMessagingTool: attempt.didSendViaMessagingTool,
4022
+ didSendDeterministicApprovalPrompt: attempt.didSendDeterministicApprovalPrompt,
4023
+ messagingToolSentTexts: attempt.messagingToolSentTexts,
4024
+ messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
4025
+ messagingToolSentTargets: attempt.messagingToolSentTargets,
4026
+ messagingToolSourceReplyPayloads: attempt.messagingToolSourceReplyPayloads,
4027
+ heartbeatToolResponse: attempt.heartbeatToolResponse,
4028
+ successfulCronAdds: attempt.successfulCronAdds,
4029
+ acceptedSessionSpawns: attempt.acceptedSessionSpawns
4030
+ };
4031
+ }
4032
+ } finally {
4033
+ forgetPromptBuildDrainCacheForRun(params.runId);
4034
+ stopRuntimeAuthRefreshTimer();
4035
+ await runAgentCleanupStep({
4036
+ runId: params.runId,
4037
+ sessionId: params.sessionId,
4038
+ step: "context-engine-dispose",
4039
+ log: log$1,
4040
+ cleanup: async () => {
4041
+ await contextEngine.dispose?.();
4042
+ }
4043
+ });
4044
+ if (params.cleanupBundleMcpOnRunEnd === true) await runAgentCleanupStep({
4045
+ runId: params.runId,
4046
+ sessionId: params.sessionId,
4047
+ step: "bundle-mcp-retire",
4048
+ log: log$1,
4049
+ cleanup: async () => {
4050
+ const onError = (error, sessionId) => {
4051
+ log$1.warn(`bundle-mcp cleanup failed after run for ${sessionId}: ${formatErrorMessage(error)}`);
4052
+ };
4053
+ if (!await retireSessionMcpRuntimeForSessionKey({
4054
+ sessionKey: params.sessionKey,
4055
+ reason: "embedded-run-end",
4056
+ onError
4057
+ })) await retireSessionMcpRuntime({
4058
+ sessionId: params.sessionId,
4059
+ reason: "embedded-run-end",
4060
+ onError
4061
+ });
4062
+ }
4063
+ });
4064
+ }
4065
+ });
4066
+ });
4067
+ }
4068
+ function resolveAuthProfileStateProvider(store, profileId, fallbackProvider) {
4069
+ const profileProvider = store.profiles?.[profileId]?.provider?.trim();
4070
+ if (profileProvider) return profileProvider;
4071
+ return profileId.split(":", 1)[0]?.trim() || fallbackProvider;
4072
+ }
4073
+ //#endregion
4074
+ export { compactEmbeddedAgentSession as n, runEmbeddedAgent as t };