@qwen-code/qwen-code 0.21.2-nightly.20260801.bc382c3ff → 0.21.3

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 (271) hide show
  1. package/bundled/qc-helper/docs/configuration/settings.md +34 -32
  2. package/bundled/qc-helper/docs/features/code-review.md +78 -23
  3. package/bundled/qc-helper/docs/features/commands.md +1 -0
  4. package/bundled/qc-helper/docs/features/skills.md +32 -1
  5. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +12 -12
  6. package/bundled/qc-helper/docs/support/troubleshooting.md +6 -1
  7. package/bundled/review/DESIGN.md +167 -32
  8. package/bundled/review/SKILL.md +156 -32
  9. package/chunks/{MaxSizedBox-CDHTDITS.js → MaxSizedBox-OJR636GP.js} +14 -13
  10. package/chunks/{StandaloneSessionPicker-L63HUAHP.js → StandaloneSessionPicker-AMMBF5UY.js} +34 -32
  11. package/chunks/{acpAgent-6WVVT2P3.js → acpAgent-M57LVIQA.js} +80 -78
  12. package/chunks/{agent-KDM4CBOU.js → agent-PE37ARLM.js} +13 -12
  13. package/chunks/{agent-headless-AS7K2K57.js → agent-headless-45ASME4R.js} +13 -12
  14. package/chunks/{artifact-tool-ANV4CFCR.js → artifact-tool-TBOYEKTY.js} +1 -1
  15. package/chunks/{askUserQuestion-MALEB47H.js → askUserQuestion-23Y5WZFJ.js} +1 -1
  16. package/chunks/{bridge-JNEW6FES.js → bridge-K3ZRPO4D.js} +14 -13
  17. package/chunks/{channel-management-service-QOO7TD3T.js → channel-management-service-IXJ2MZTS.js} +6 -6
  18. package/chunks/{channel-settings-store-4CSMTR4L.js → channel-settings-store-PEAR3IME.js} +19 -18
  19. package/chunks/{channel-worker-group-ERSUOPIR.js → channel-worker-group-NDG4WOOZ.js} +4 -4
  20. package/chunks/{channel-worker-manager-X247YDQ7.js → channel-worker-manager-ZCW6UW34.js} +4 -4
  21. package/chunks/{channel-worker-supervisor-ORJIEEPP.js → channel-worker-supervisor-ATGFTZRN.js} +3 -3
  22. package/chunks/{chunk-LAPK3GLC.js → chunk-22YFMJBW.js} +24 -6
  23. package/chunks/{chunk-UHTJC7O3.js → chunk-24ER7UV4.js} +1 -1
  24. package/chunks/{chunk-3WXMXT7C.js → chunk-2LZCLQIS.js} +5 -5
  25. package/chunks/{chunk-NZB4NDJL.js → chunk-2MI7ZTRT.js} +4 -4
  26. package/chunks/{chunk-C4L2MEIT.js → chunk-3MWNROHB.js} +3 -3
  27. package/chunks/{chunk-2PNQQ4UR.js → chunk-3XF4WT3B.js} +1 -1
  28. package/chunks/{chunk-TNVKFQXQ.js → chunk-4AGGSHCH.js} +383 -153
  29. package/chunks/{chunk-M2F5PLOW.js → chunk-4K3RV3OA.js} +3 -3
  30. package/chunks/{chunk-5UJ6A3CH.js → chunk-5JPVOYWA.js} +5 -5
  31. package/chunks/{chunk-AYB4HSBI.js → chunk-5VYFXHY2.js} +3 -3
  32. package/chunks/{chunk-AQEWCKX4.js → chunk-6NE5NTHJ.js} +1 -1
  33. package/chunks/{chunk-XSA5EKTJ.js → chunk-BKGA75MU.js} +1 -1
  34. package/chunks/{chunk-MBKPUM5Y.js → chunk-BKXTHMOZ.js} +1 -1
  35. package/chunks/{chunk-LL4U3BSH.js → chunk-BSKUTHLO.js} +3 -3
  36. package/chunks/{chunk-I5GNT6ZS.js → chunk-CFDR3GNL.js} +11 -2
  37. package/chunks/{chunk-DVGTU5TC.js → chunk-CIUUYB23.js} +2 -2
  38. package/chunks/{chunk-BKUN5QHP.js → chunk-D2GPKXCQ.js} +4 -4
  39. package/chunks/{chunk-GB3AB7TR.js → chunk-DIEFUBV6.js} +1 -0
  40. package/chunks/{chunk-KXSYDCP2.js → chunk-DSGJLHM3.js} +3 -3
  41. package/chunks/{chunk-PHODQP2V.js → chunk-EGYJRIDF.js} +2 -2
  42. package/chunks/{chunk-XCLLRKY5.js → chunk-EIMKVOSF.js} +1 -1
  43. package/chunks/{chunk-QTERJVPZ.js → chunk-EKTCKZV5.js} +1 -0
  44. package/chunks/{chunk-42IKVPST.js → chunk-FF75UUB2.js} +1 -1
  45. package/chunks/{chunk-FJHA23GM.js → chunk-FG63DZQA.js} +9 -9
  46. package/chunks/{chunk-5UZITEHA.js → chunk-FHPKHXHT.js} +2 -2
  47. package/chunks/{chunk-25QQVOCG.js → chunk-FXVHVCNA.js} +1 -1
  48. package/chunks/{chunk-7MY2AR5A.js → chunk-GMSBXEH4.js} +9 -9
  49. package/chunks/{chunk-TFFMATHX.js → chunk-H35Q5CEG.js} +5 -5
  50. package/chunks/{chunk-WISQLM4Q.js → chunk-H6FIBBXK.js} +1177 -1806
  51. package/chunks/{chunk-DUIJ2IXG.js → chunk-H6ZYP74A.js} +1 -1
  52. package/chunks/{chunk-XFDPIC4P.js → chunk-HEBW74ZW.js} +3 -3
  53. package/chunks/{chunk-6FMJLI5M.js → chunk-HFVW54NL.js} +41 -6
  54. package/chunks/{chunk-3MHPWQ2M.js → chunk-HIXVWF7I.js} +37 -8
  55. package/chunks/{chunk-GVISB2OH.js → chunk-HUIQ4FYC.js} +2 -2
  56. package/chunks/{chunk-K5Q62CGR.js → chunk-IF6K42YJ.js} +1 -1
  57. package/chunks/{chunk-VWF42XC6.js → chunk-IWGTGH4G.js} +4 -4
  58. package/chunks/{chunk-SWEBEXPI.js → chunk-K2J5JZ6B.js} +1 -1
  59. package/chunks/{chunk-CHCLO3M7.js → chunk-KXWERR6P.js} +4 -4
  60. package/chunks/{chunk-OCRM53TT.js → chunk-L7FTDKCD.js} +3 -3
  61. package/chunks/{chunk-2CTKGIFR.js → chunk-LGT3YMLN.js} +4 -4
  62. package/chunks/{chunk-7IYLHTTM.js → chunk-LZV2BZPL.js} +2 -2
  63. package/chunks/{chunk-434YCHSV.js → chunk-M5LIY7Y6.js} +1 -1
  64. package/chunks/{chunk-JRIDA5HF.js → chunk-MCXMWLFT.js} +5 -5
  65. package/chunks/{chunk-433VD3HX.js → chunk-MTR4JWQJ.js} +4 -4
  66. package/chunks/{chunk-WP4HGHFG.js → chunk-MUEJ4R3E.js} +3 -3
  67. package/chunks/{chunk-UHQ3L6GC.js → chunk-N42C2FU3.js} +1 -1
  68. package/chunks/{chunk-KG22G46Y.js → chunk-NW57GHNL.js} +69 -5
  69. package/chunks/chunk-PWCQRLM5.js +1170 -0
  70. package/chunks/{chunk-H4DSRWAS.js → chunk-Q3G5L5KF.js} +4 -4
  71. package/chunks/{chunk-SK2UKB45.js → chunk-QDWLUXKP.js} +1 -1
  72. package/chunks/{chunk-VS3GXRNZ.js → chunk-QPSYIV2O.js} +3114 -512
  73. package/chunks/{chunk-GHJM2C2T.js → chunk-QWDVZH24.js} +3 -3
  74. package/chunks/{chunk-UWLG4UCE.js → chunk-QWW6I2UO.js} +13 -13
  75. package/chunks/{chunk-W7XZ3KP5.js → chunk-R7XNRHYD.js} +1 -1
  76. package/chunks/{chunk-PGP7Y3RQ.js → chunk-RCXCGZG6.js} +4 -4
  77. package/chunks/{chunk-MSIVKDRC.js → chunk-RL6J3BPE.js} +3 -3
  78. package/chunks/{chunk-H6MC6VQX.js → chunk-RR224BUP.js} +4 -3
  79. package/chunks/{chunk-7K2WTPQO.js → chunk-SKSF3LGQ.js} +4 -4
  80. package/chunks/{chunk-II6WPWHY.js → chunk-SQ3YD5MI.js} +1 -1
  81. package/chunks/{chunk-PGEGUNH5.js → chunk-SRY26X4H.js} +22 -199
  82. package/chunks/{chunk-OBAIHYFT.js → chunk-TXABHVZD.js} +1 -1
  83. package/chunks/chunk-TZTBZ25J.js +222 -0
  84. package/chunks/{chunk-BV4QX43X.js → chunk-UEJESCS7.js} +1 -1
  85. package/chunks/{chunk-NGWYUZZO.js → chunk-UQDFEU47.js} +318 -125
  86. package/chunks/{chunk-CWEIMFFW.js → chunk-VA5NLVPT.js} +1 -1
  87. package/chunks/{chunk-UOFFZNXV.js → chunk-VUNRNRN6.js} +65 -37
  88. package/chunks/{chunk-K4CGQN4Q.js → chunk-VWOVHOTT.js} +1 -1
  89. package/chunks/{chunk-I6FAHB4N.js → chunk-WUC6ZFXO.js} +1 -1
  90. package/chunks/{chunk-2A6MHYIA.js → chunk-WY2ENRDN.js} +1 -1
  91. package/chunks/{chunk-MYT7N6QH.js → chunk-X6QNZOTC.js} +1 -1
  92. package/chunks/{chunk-ZTN6OA5J.js → chunk-X6WUYMOV.js} +8 -8
  93. package/chunks/{chunk-RGJ4JWSU.js → chunk-XMJO6C44.js} +3 -3
  94. package/chunks/{chunk-PXA5AWHY.js → chunk-XUMAD5IT.js} +1 -1
  95. package/chunks/{chunk-GALUTA2C.js → chunk-YPUHMQXV.js} +1 -1
  96. package/chunks/{chunk-A2A34TSB.js → chunk-YU6TBRTA.js} +2 -2
  97. package/chunks/{chunk-ZRFJ75D7.js → chunk-YWMDTMAU.js} +2 -2
  98. package/chunks/{chunk-LRJWFR6L.js → chunk-ZGSUFIL5.js} +1 -1
  99. package/chunks/{chunk-H4346YW5.js → chunk-ZJES4C3I.js} +5 -5
  100. package/chunks/{computer-use-Z4NCIIJN.js → computer-use-UJMK6JQU.js} +13 -12
  101. package/chunks/{config-utils-64LM6OEQ.js → config-utils-7COTJMWK.js} +4 -4
  102. package/chunks/{contextCommand-HVM7XFCB.js → contextCommand-4YABGF4S.js} +16 -15
  103. package/chunks/{core-runtime-NL3ZBHBU.js → core-runtime-7M4VM3DA.js} +13 -12
  104. package/chunks/{create-sub-session-XHSCDYFU.js → create-sub-session-HOFDW4N7.js} +13 -12
  105. package/chunks/{create-sub-session-AM32K2HD.js → create-sub-session-J32WC64U.js} +1 -1
  106. package/chunks/{cron-create-HPXYE6C5.js → cron-create-HMFSHIAR.js} +1 -1
  107. package/chunks/{cron-delete-FPVNTKPK.js → cron-delete-ZJFHOX57.js} +1 -1
  108. package/chunks/{cron-list-ZEI6PAAV.js → cron-list-ZEX2NBMN.js} +1 -1
  109. package/chunks/{daemon-PCNCI5YU.js → daemon-CCIX4BMG.js} +47 -6
  110. package/chunks/{daemon-status-provider-XD23SNAM.js → daemon-status-provider-W2U5Q3J5.js} +18 -17
  111. package/chunks/{daemon-trust-policy-NOHK7IW5.js → daemon-trust-policy-IFICWPXP.js} +18 -17
  112. package/chunks/{daemon-trust-policy-monitor-ZBTSR333.js → daemon-trust-policy-monitor-GX7EO6FW.js} +18 -17
  113. package/chunks/{deferred-core-runtime-JJBHKM2C.js → deferred-core-runtime-U36OOOKE.js} +13 -12
  114. package/chunks/display-image-VS3TXYQH.js +184 -0
  115. package/chunks/{dist-BH76AT7N.js → dist-3BMEUGTG.js} +1 -1
  116. package/chunks/{dist-BXA3JXVQ.js → dist-4KAX7CCL.js} +1 -1
  117. package/chunks/{dist-4T4NCJFL.js → dist-7JGAAQSC.js} +2 -2
  118. package/chunks/{dist-4LAMY2SK.js → dist-A7H2KKUC.js} +1 -1
  119. package/chunks/{dist-OEEFI6UU.js → dist-DPPHJAVL.js} +3 -3
  120. package/chunks/{dist-SMLVOWKV.js → dist-HVBMEYWK.js} +1 -1
  121. package/chunks/{dist-7KOL6OMD.js → dist-NEBRI7WO.js} +1 -1
  122. package/chunks/{dist-V2RK6S6Q.js → dist-SFQ34F4M.js} +24 -6
  123. package/chunks/{earlyInputCapture-KLAZDAIP.js → earlyInputCapture-5ZWDH3SB.js} +13 -12
  124. package/chunks/{edit-YQZWCISX.js → edit-J7SW6UP6.js} +13 -12
  125. package/chunks/{en-RESOFG55.js → en-L4UQDLWW.js} +11 -1
  126. package/chunks/{enter-worktree-WLVWI3FP.js → enter-worktree-NRLOHRB6.js} +13 -12
  127. package/chunks/{enterPlanMode-6RYXFQUD.js → enterPlanMode-GDSTEFSM.js} +13 -12
  128. package/chunks/{environment-DXJTXSVT.js → environment-KHYEKG5W.js} +15 -14
  129. package/chunks/{errors-XGAGG2S2.js → errors-VNLAJV3O.js} +15 -14
  130. package/chunks/{exit-worktree-C4276VPP.js → exit-worktree-ARVID7DF.js} +13 -12
  131. package/chunks/{exitPlanMode-MM5HIRUF.js → exitPlanMode-4ZFY7KUH.js} +13 -12
  132. package/chunks/{fast-path-PIXYOHCH.js → fast-path-KA65VREJ.js} +5 -5
  133. package/chunks/{gemini-43RLVUNP.js → gemini-5PMCNPF7.js} +56 -55
  134. package/chunks/{geminiContentGenerator-PNQ4TSID.js → geminiContentGenerator-NFSYJ4HA.js} +1 -1
  135. package/chunks/{glob-ZMBQKAU5.js → glob-F3EAUDAX.js} +13 -12
  136. package/chunks/{goal-tools-Y767F7LZ.js → goal-tools-SPQ5M6D3.js} +2 -2
  137. package/chunks/{grep-HSV37W2Q.js → grep-UJMPVZER.js} +13 -12
  138. package/chunks/{handleAutoUpdate-QDHZPBAY.js → handleAutoUpdate-MG4FRZPN.js} +18 -17
  139. package/chunks/{i18n-ME22A6RN.js → i18n-EVHV4ZF3.js} +14 -13
  140. package/chunks/{image-gen-IFC7ZWSB.js → image-gen-UC7XVHI7.js} +2 -2
  141. package/chunks/{initializer-J7H2CHVB.js → initializer-O5B6HUBI.js} +18 -17
  142. package/chunks/{installationInfo-R7FXPQN5.js → installationInfo-2LIKCNVX.js} +14 -13
  143. package/chunks/{list-OYDIBA4N.js → list-BPKIE3Z4.js} +21 -20
  144. package/chunks/{list-agents-GATIBBQQ.js → list-agents-TWEGRJWO.js} +1 -1
  145. package/chunks/{loadedSettingsAdapter-OK6GK2GE.js → loadedSettingsAdapter-NGLFF4V4.js} +18 -17
  146. package/chunks/{loggingContentGenerator-U4ZEG4GL.js → loggingContentGenerator-7TFESRG5.js} +5 -5
  147. package/chunks/{loop-wakeup-3DZMQQQQ.js → loop-wakeup-6LLEOQYV.js} +2 -2
  148. package/chunks/{ls-7F4GHXIH.js → ls-H5WX22VK.js} +1 -1
  149. package/chunks/{lsp-6FEHVBWI.js → lsp-G6FXYEIS.js} +1 -1
  150. package/chunks/{managed-npm-update-PGKAJLLO.js → managed-npm-update-CLZGGV7F.js} +14 -13
  151. package/chunks/{mcp-S4DXJD2G.js → mcp-X5OZOOXX.js} +18 -17
  152. package/chunks/{monitor-E5ZFMT74.js → monitor-TGSVSAZZ.js} +13 -12
  153. package/chunks/{nonInteractiveCli-HNOHKEPE.js → nonInteractiveCli-GUMJ5JLG.js} +54 -53
  154. package/chunks/{notebook-edit-6QDN6VZJ.js → notebook-edit-EZISE7IC.js} +13 -12
  155. package/chunks/{openaiContentGenerator-3NLB2C5O.js → openaiContentGenerator-ZAKS5A6P.js} +5 -5
  156. package/chunks/{pidfile-ZMOIUGG6.js → pidfile-PCMBX4LR.js} +13 -12
  157. package/chunks/{processUtils-E4QGQVWW.js → processUtils-2CSVE5BW.js} +2 -2
  158. package/chunks/{qwenContentGenerator-2LFRWJTM.js → qwenContentGenerator-S3H6PIC4.js} +14 -13
  159. package/chunks/{qwenOAuth2-N32BUQDC.js → qwenOAuth2-MNU425VE.js} +1 -1
  160. package/chunks/{read-file-GLDCWZBG.js → read-file-HXJXHBI6.js} +4 -4
  161. package/chunks/{read-mcp-resource-AFS3UKZO.js → read-mcp-resource-DRZSI3HE.js} +1 -1
  162. package/chunks/{record-artifact-ECZSCEG5.js → record-artifact-IPIRWMFY.js} +2 -2
  163. package/chunks/{resumeHistoryUtils-F5BE5QDW.js → resumeHistoryUtils-4QAMC2S6.js} +18 -17
  164. package/chunks/{ripGrep-T23Y4AGY.js → ripGrep-MCETPF2E.js} +13 -12
  165. package/chunks/{run-qwen-serve-TI2HGLLU.js → run-qwen-serve-3NMODTXV.js} +43 -43
  166. package/chunks/{runtime-WCWM3DO7.js → runtime-AQOV7DVP.js} +23 -22
  167. package/chunks/{scheduler-2QZO5AV5.js → scheduler-DN7SZ6ZE.js} +13 -12
  168. package/chunks/{send-message-X7G2JSII.js → send-message-HGCVVDTZ.js} +3 -2
  169. package/chunks/{serve-DZOMYUFU.js → serve-WZB45HVT.js} +18 -17
  170. package/chunks/{server-N4AJRKIQ.js → server-GOTZFEEZ.js} +86 -54
  171. package/chunks/{session-GS6AKMN7.js → session-23LOFLWN.js} +55 -54
  172. package/chunks/{settings-CUN3SELH.js → settings-LI2ORVXC.js} +17 -16
  173. package/chunks/{shell-NGBFVXC5.js → shell-GLC6OP3C.js} +13 -12
  174. package/chunks/{skill-SC2BSO75.js → skill-C7W6M4GO.js} +4 -4
  175. package/chunks/{skill-settings-XVPCPW5K.js → skill-settings-W25NCK5I.js} +17 -16
  176. package/chunks/{spawnChannel-RILO4YY3.js → spawnChannel-OHJLEBLD.js} +13 -12
  177. package/chunks/{standalone-update-TMLT6LVJ.js → standalone-update-E4V5V7WT.js} +15 -14
  178. package/chunks/{startInteractiveUI-J45WOEOU.js → startInteractiveUI-FKILLW7Q.js} +1419 -414
  179. package/chunks/{syntheticOutput-FHRY3BPQ.js → syntheticOutput-EYL7DWO7.js} +2 -2
  180. package/chunks/{task-create-LAQXBIHC.js → task-create-CSCEG4SM.js} +4 -3
  181. package/chunks/{task-list-V6K5DRDH.js → task-list-6CVQPORX.js} +1 -1
  182. package/chunks/{task-stop-LQXE52L6.js → task-stop-Y5ZTFVRX.js} +1 -1
  183. package/chunks/{task-update-NXRCXSPB.js → task-update-C52LNFU5.js} +4 -3
  184. package/chunks/{team-create-W3EVWCTA.js → team-create-HBIJ7NHT.js} +13 -12
  185. package/chunks/{team-delete-Z4KGO7RC.js → team-delete-CE7DC53R.js} +1 -1
  186. package/chunks/{team-plan-approval-URYVKJF4.js → team-plan-approval-IBJOKS4J.js} +13 -12
  187. package/chunks/terminal-image-renderer-BOQJPVLB.js +89 -0
  188. package/chunks/{theme-manager-CUAMS2NI.js → theme-manager-NSS7VLUD.js} +13 -12
  189. package/chunks/{todoWrite-OFIZDI7P.js → todoWrite-YKAA57W2.js} +104 -33
  190. package/chunks/{tool-search-DCICFL32.js → tool-search-DEAS54VG.js} +6 -5
  191. package/chunks/{total-session-admission-3ZTAXVUK.js → total-session-admission-4LWTX3WD.js} +14 -13
  192. package/chunks/{trustedFolders-EVCN36O5.js → trustedFolders-NF3J2TA7.js} +14 -13
  193. package/chunks/{update-relaunch-XLW46RHQ.js → update-relaunch-WUHRH5V3.js} +5 -5
  194. package/chunks/{updateCheck-ZHVXDAIH.js → updateCheck-7EG4BLBH.js} +17 -16
  195. package/chunks/{useAutoAcceptIndicator-ZGD6BJSP.js → useAutoAcceptIndicator-ZRV56GVP.js} +21 -20
  196. package/chunks/{validateNonInterActiveAuth-R3BAQFDY.js → validateNonInterActiveAuth-WC2FPE3I.js} +51 -50
  197. package/chunks/{version-PMWREGCG.js → version-6SS7KCUP.js} +1 -1
  198. package/chunks/{web-fetch-PGN27SGF.js → web-fetch-Y5QQMPKA.js} +4 -4
  199. package/chunks/{web-search-KW4UNMRE.js → web-search-QKKEU723.js} +3 -3
  200. package/chunks/{workflow-SN3TJBTJ.js → workflow-PWIU6Q2M.js} +102 -37
  201. package/chunks/{workspace-providers-status-O3HUZGGR.js → workspace-providers-status-B2DM6FNK.js} +20 -19
  202. package/chunks/{workspace-registration-store-M3FJ74RS.js → workspace-registration-store-7Y33TTHJ.js} +1 -1
  203. package/chunks/{workspace-registry-U7ISW23N.js → workspace-registry-TSNJKLPC.js} +14 -13
  204. package/chunks/{workspace-service-VH6IWADT.js → workspace-service-4I2QHDX4.js} +22 -21
  205. package/chunks/{workspace-skills-status-XANARSZS.js → workspace-skills-status-HVXNWVGR.js} +19 -18
  206. package/chunks/{workspace-trust-reconciler-35EFR4GC.js → workspace-trust-reconciler-RDBBGMWP.js} +19 -18
  207. package/chunks/{write-file-NCRSGUDT.js → write-file-RQ4DG5RY.js} +13 -12
  208. package/chunks/{zh-OHX23Q44.js → zh-72XPUG5P.js} +11 -1
  209. package/chunks/{zh-TW-4G7YKDAQ.js → zh-TW-LTB4SRH3.js} +11 -1
  210. package/chunks/{zoom-image-X7CIADYC.js → zoom-image-O5YCB7WN.js} +4 -4
  211. package/cli.js +26 -15
  212. package/locales/en.js +17 -2
  213. package/locales/zh-TW.js +15 -2
  214. package/locales/zh.js +15 -2
  215. package/package.json +3 -3
  216. package/web-shell/assets/{arc-CaMTqKio.js → arc-Bd7d781i.js} +1 -1
  217. package/web-shell/assets/{architectureDiagram-3BPJPVTR-Bjxztij2.js → architectureDiagram-3BPJPVTR-CpnOJqNE.js} +1 -1
  218. package/web-shell/assets/{blockDiagram-GPEHLZMM-BYJzeHi9.js → blockDiagram-GPEHLZMM-NxVTiWnk.js} +1 -1
  219. package/web-shell/assets/{c4Diagram-AAUBKEIU-fYAa-Eil.js → c4Diagram-AAUBKEIU-BWT75l82.js} +1 -1
  220. package/web-shell/assets/channel-A434sWK5.js +1 -0
  221. package/web-shell/assets/{chunk-2J33WTMH-B1OTlTml.js → chunk-2J33WTMH-Dzz03hk6.js} +1 -1
  222. package/web-shell/assets/{chunk-4BX2VUAB-DNj4uy6k.js → chunk-4BX2VUAB-DRF-egfm.js} +1 -1
  223. package/web-shell/assets/{chunk-55IACEB6-DAqNmg3c.js → chunk-55IACEB6-Co15vq5x.js} +1 -1
  224. package/web-shell/assets/{chunk-727SXJPM-BwB4ddxE.js → chunk-727SXJPM-DHSUk1J7.js} +1 -1
  225. package/web-shell/assets/{chunk-AQP2D5EJ-DmHR_UZs.js → chunk-AQP2D5EJ-Br8u_E2R.js} +1 -1
  226. package/web-shell/assets/{chunk-FMBD7UC4-BlfOXumo.js → chunk-FMBD7UC4-DXbPTnqF.js} +1 -1
  227. package/web-shell/assets/{chunk-ND2GUHAM-BKogiSy7.js → chunk-ND2GUHAM-BleQdi4d.js} +1 -1
  228. package/web-shell/assets/{chunk-QZHKN3VN-DEclVrOF.js → chunk-QZHKN3VN-CqgBf-95.js} +1 -1
  229. package/web-shell/assets/classDiagram-4FO5ZUOK-CwPuhldB.js +1 -0
  230. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-CwPuhldB.js +1 -0
  231. package/web-shell/assets/{cose-bilkent-S5V4N54A-CwtS21WT.js → cose-bilkent-S5V4N54A-WS7b13Yg.js} +1 -1
  232. package/web-shell/assets/{dagre-BM42HDAG-BAAIlB4p.js → dagre-BM42HDAG-v_55ki8o.js} +1 -1
  233. package/web-shell/assets/{diagram-2AECGRRQ-ChljtF_V.js → diagram-2AECGRRQ-DaYAjbdK.js} +1 -1
  234. package/web-shell/assets/{diagram-5GNKFQAL-BIXVd31-.js → diagram-5GNKFQAL-D_Hy-L64.js} +1 -1
  235. package/web-shell/assets/{diagram-KO2AKTUF-BEiBaS15.js → diagram-KO2AKTUF-dB06cZyD.js} +1 -1
  236. package/web-shell/assets/{diagram-LMA3HP47-C-g4tWKM.js → diagram-LMA3HP47-DzSluD4F.js} +1 -1
  237. package/web-shell/assets/{diagram-OG6HWLK6-CNCCbNQG.js → diagram-OG6HWLK6-Cvb6CeXQ.js} +1 -1
  238. package/web-shell/assets/{erDiagram-TEJ5UH35-v8ysnsdI.js → erDiagram-TEJ5UH35-7eB2Hmov.js} +1 -1
  239. package/web-shell/assets/{flowDiagram-I6XJVG4X-LKVlLjwA.js → flowDiagram-I6XJVG4X-B08iGCw_.js} +1 -1
  240. package/web-shell/assets/{ganttDiagram-6RSMTGT7-DA5MrKYG.js → ganttDiagram-6RSMTGT7-BgsrCHq-.js} +1 -1
  241. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-Cyg5fe6d.js → gitGraphDiagram-PVQCEYII-DQLurQ2i.js} +1 -1
  242. package/web-shell/assets/{index-CKdUkVVS.js → index-B_1Z0Mgr.js} +1 -1
  243. package/web-shell/assets/index-Bi1dP2mU.css +5 -0
  244. package/web-shell/assets/index-DJ-z1Oba.js +1756 -0
  245. package/web-shell/assets/{infoDiagram-5YYISTIA-SLsfu3Qd.js → infoDiagram-5YYISTIA-DXZGO8qB.js} +1 -1
  246. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-CmHOmTNx.js → ishikawaDiagram-YF4QCWOH-g7gbuH2w.js} +1 -1
  247. package/web-shell/assets/{journeyDiagram-JHISSGLW-C3gM_HFQ.js → journeyDiagram-JHISSGLW-euefICGn.js} +1 -1
  248. package/web-shell/assets/{kanban-definition-UN3LZRKU-BbHD7duM.js → kanban-definition-UN3LZRKU-Dws8-mjG.js} +1 -1
  249. package/web-shell/assets/{linear-CSBvm435.js → linear-C63F0tyh.js} +1 -1
  250. package/web-shell/assets/{mermaid.core-CPMw15lU.js → mermaid.core-fLrhp_4-.js} +5 -5
  251. package/web-shell/assets/{mindmap-definition-RKZ34NQL-C_tNqXQW.js → mindmap-definition-RKZ34NQL-qRkydfT-.js} +1 -1
  252. package/web-shell/assets/{pieDiagram-4H26LBE5-DH_N-8yY.js → pieDiagram-4H26LBE5-BZ0wQaKN.js} +1 -1
  253. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-CRbS8UkN.js → quadrantDiagram-W4KKPZXB-Fjq6GbSZ.js} +1 -1
  254. package/web-shell/assets/{requirementDiagram-4Y6WPE33-DJgdZPZn.js → requirementDiagram-4Y6WPE33-CqWvjLHU.js} +1 -1
  255. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-vhL1y5zx.js → sankeyDiagram-5OEKKPKP-VcXX6PVZ.js} +1 -1
  256. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-UQthhFwd.js → sequenceDiagram-3UESZ5HK-BJSRtxFr.js} +1 -1
  257. package/web-shell/assets/{stateDiagram-AJRCARHV-CAywEm20.js → stateDiagram-AJRCARHV-Dt9zUwmZ.js} +1 -1
  258. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-CCxQt56w.js +1 -0
  259. package/web-shell/assets/{timeline-definition-PNZ67QCA-CLO8b3FD.js → timeline-definition-PNZ67QCA-DQwlNRws.js} +1 -1
  260. package/web-shell/assets/{vennDiagram-CIIHVFJN-BNAAh0Mu.js → vennDiagram-CIIHVFJN-DwxjUEtQ.js} +1 -1
  261. package/web-shell/assets/{wardley-L42UT6IY-CUY7bLpN.js → wardley-L42UT6IY-D3QdMSpJ.js} +1 -1
  262. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-CSg_ORdW.js → wardleyDiagram-YWT4CUSO-BddN8oK8.js} +1 -1
  263. package/web-shell/assets/{xychartDiagram-2RQKCTM6-BjffV208.js → xychartDiagram-2RQKCTM6-BUNuBrRJ.js} +1 -1
  264. package/web-shell/index.html +2 -2
  265. package/web-shell/assets/channel-LEZei0-5.js +0 -1
  266. package/web-shell/assets/classDiagram-4FO5ZUOK-BiaRhfvf.js +0 -1
  267. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-BiaRhfvf.js +0 -1
  268. package/web-shell/assets/index-BgOcEaVt.js +0 -1756
  269. package/web-shell/assets/index-DA5Lvscv.css +0 -5
  270. package/web-shell/assets/insert-DmRbh9Rv.svg +0 -1
  271. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-lfJQHw-7.js +0 -1
@@ -1,5 +1,11 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ import {
4
+ startPostRenderPrefetches
5
+ } from "./chunk-FG63DZQA.js";
6
+ import {
7
+ useAutoAcceptIndicator
8
+ } from "./chunk-RL6J3BPE.js";
3
9
  import {
4
10
  classifyApiError,
5
11
  fireSessionDeleteHook
@@ -10,7 +16,7 @@ import {
10
16
  import {
11
17
  TUI_CHAT_RECORDING_FAILURE_MESSAGE,
12
18
  reportChatRecordingFailureToAdapter
13
- } from "./chunk-LRJWFR6L.js";
19
+ } from "./chunk-ZGSUFIL5.js";
14
20
  import {
15
21
  MAX_SUGGESTIONS_TO_SHOW,
16
22
  SESSION_MENTION_PREFIX,
@@ -22,10 +28,10 @@ import {
22
28
  matchMcpServerPrefix,
23
29
  resolveAtCommandQuery,
24
30
  sanitizeDisplayText
25
- } from "./chunk-RGJ4JWSU.js";
31
+ } from "./chunk-XMJO6C44.js";
26
32
  import {
27
33
  StreamJsonOutputAdapter
28
- } from "./chunk-OCRM53TT.js";
34
+ } from "./chunk-L7FTDKCD.js";
29
35
  import {
30
36
  BuiltinCommandLoader,
31
37
  BundledSkillLoader,
@@ -66,18 +72,21 @@ import {
66
72
  resetBackgroundStateForSessionSwitch,
67
73
  serializeUserPromptExpansionPrompt,
68
74
  supportsMatchers
69
- } from "./chunk-TNVKFQXQ.js";
70
- import "./chunk-7K2WTPQO.js";
71
- import {
72
- startPostRenderPrefetches
73
- } from "./chunk-FJHA23GM.js";
75
+ } from "./chunk-4AGGSHCH.js";
74
76
  import {
75
77
  EXTENSION_RELOAD_FAILED_REASON,
76
78
  ExtensionRefreshState,
77
79
  appEvents,
78
80
  cleanupReviewWorktreeLeases,
79
81
  loadHierarchicalGeminiMemory
80
- } from "./chunk-VS3GXRNZ.js";
82
+ } from "./chunk-QPSYIV2O.js";
83
+ import {
84
+ disableKittyProtocol,
85
+ isKittyProtocolEnabled,
86
+ isKittyProtocolSupported,
87
+ pushKittyProtocolFlags
88
+ } from "./chunk-NYX53SV4.js";
89
+ import "./chunk-SKSF3LGQ.js";
81
90
  import {
82
91
  AboutBox,
83
92
  BaseSelectionList,
@@ -143,6 +152,7 @@ import {
143
152
  useIdeTrustListener,
144
153
  useLaunchEditor,
145
154
  useMouseEvents,
155
+ useMouseTrackingEnabled,
146
156
  usePreferredEditor,
147
157
  useProviderUpdates,
148
158
  useSelectionList,
@@ -154,15 +164,34 @@ import {
154
164
  useUIActions,
155
165
  useUIState,
156
166
  useVirtualViewport
157
- } from "./chunk-WISQLM4Q.js";
167
+ } from "./chunk-H6FIBBXK.js";
168
+ import {
169
+ KeypressProvider,
170
+ useFocus,
171
+ useKeypress,
172
+ useKeypressContext
173
+ } from "./chunk-Q3G5L5KF.js";
158
174
  import {
159
175
  getCommandDisplayName,
160
176
  getCommandSourceBadge
161
- } from "./chunk-OBAIHYFT.js";
177
+ } from "./chunk-TXABHVZD.js";
162
178
  import {
163
179
  computeSessionStats,
164
180
  levelLabel
165
- } from "./chunk-7IYLHTTM.js";
181
+ } from "./chunk-LZV2BZPL.js";
182
+ import {
183
+ BEL,
184
+ OSC_PREFIX,
185
+ cleanupOldClipboardImages,
186
+ clipboardHasImage,
187
+ detectTerminal,
188
+ generateKittyId,
189
+ oscGhosttyNotify,
190
+ oscITerm2Notify,
191
+ oscKittyNotify,
192
+ saveClipboardImage,
193
+ writeOsc52
194
+ } from "./chunk-3LGZEYOF.js";
166
195
  import "./chunk-4WGODMVR.js";
167
196
  import {
168
197
  MaxSizedBox,
@@ -181,42 +210,13 @@ import {
181
210
  build_default,
182
211
  expandCollapsedHistory,
183
212
  isCollapsibleTool,
184
- useStreamingContext
185
- } from "./chunk-KG22G46Y.js";
213
+ shouldDisplayGoalStateCause,
214
+ useStreamingContext,
215
+ waitForGoalRuntime
216
+ } from "./chunk-NW57GHNL.js";
186
217
  import {
187
218
  theme
188
219
  } from "./chunk-U25CMJYY.js";
189
- import {
190
- stopAndGetCapturedInput
191
- } from "./chunk-KVUBYJDM.js";
192
- import {
193
- disableKittyProtocol,
194
- isKittyProtocolEnabled,
195
- isKittyProtocolSupported,
196
- pushKittyProtocolFlags
197
- } from "./chunk-NYX53SV4.js";
198
- import {
199
- useAutoAcceptIndicator
200
- } from "./chunk-MSIVKDRC.js";
201
- import {
202
- KeypressProvider,
203
- useFocus,
204
- useKeypress,
205
- useKeypressContext
206
- } from "./chunk-H4DSRWAS.js";
207
- import {
208
- BEL,
209
- OSC_PREFIX,
210
- cleanupOldClipboardImages,
211
- clipboardHasImage,
212
- detectTerminal,
213
- generateKittyId,
214
- oscGhosttyNotify,
215
- oscITerm2Notify,
216
- oscKittyNotify,
217
- saveClipboardImage,
218
- writeOsc52
219
- } from "./chunk-3LGZEYOF.js";
220
220
  import {
221
221
  require_jsx_runtime
222
222
  } from "./chunk-SV5PQVQE.js";
@@ -234,38 +234,41 @@ import {
234
234
  use_stdin_default,
235
235
  use_stdout_default
236
236
  } from "./chunk-2IIJTXYF.js";
237
+ import {
238
+ require_react
239
+ } from "./chunk-5QWWOFGG.js";
240
+ import {
241
+ stopAndGetCapturedInput
242
+ } from "./chunk-KVUBYJDM.js";
243
+ import "./chunk-PWCQRLM5.js";
237
244
  import {
238
245
  relaunchApp
239
- } from "./chunk-42IKVPST.js";
246
+ } from "./chunk-FF75UUB2.js";
240
247
  import {
241
248
  setUpdateHandler
242
- } from "./chunk-C4L2MEIT.js";
243
- import "./chunk-WP4HGHFG.js";
249
+ } from "./chunk-3MWNROHB.js";
250
+ import "./chunk-YWMDTMAU.js";
251
+ import "./chunk-MUEJ4R3E.js";
244
252
  import {
245
253
  AUTO_THEME_NAME,
246
254
  DEFAULT_THEME,
247
255
  themeManager
248
256
  } from "./chunk-KKN2IE7Q.js";
249
257
  import "./chunk-KW7NOTN6.js";
250
- import {
251
- require_react
252
- } from "./chunk-5QWWOFGG.js";
253
- import "./chunk-433VD3HX.js";
258
+ import "./chunk-BSKUTHLO.js";
259
+ import "./chunk-6H67XLET.js";
260
+ import "./chunk-MTR4JWQJ.js";
254
261
  import {
255
262
  getErrorMessage as getErrorMessage2
256
- } from "./chunk-PHODQP2V.js";
257
- import "./chunk-VWF42XC6.js";
258
- import "./chunk-ZRFJ75D7.js";
263
+ } from "./chunk-EGYJRIDF.js";
264
+ import "./chunk-IWGTGH4G.js";
259
265
  import "./chunk-YAF2MQZ6.js";
260
266
  import {
261
267
  openQwenAsrRealtimeStream,
262
268
  openVoiceStream,
263
269
  openVoiceStreamWithRetry
264
270
  } from "./chunk-GTM6IHBB.js";
265
- import {
266
- recordGoalStatusItem,
267
- restoreGoalFromHistory
268
- } from "./chunk-UOFFZNXV.js";
271
+ import "./chunk-VUNRNRN6.js";
269
272
  import "./chunk-DYA25Y7U.js";
270
273
  import {
271
274
  cpLen,
@@ -279,36 +282,45 @@ import {
279
282
  stripUnsafeCharacters,
280
283
  toCodePoints
281
284
  } from "./chunk-4NFY2S7N.js";
282
- import "./chunk-UHQ3L6GC.js";
285
+ import "./chunk-N42C2FU3.js";
283
286
  import {
284
287
  stringWidth
285
288
  } from "./chunk-2MIN6GRR.js";
286
289
  import "./chunk-QHTIBUWB.js";
287
290
  import {
288
291
  isHistoryItemVisibleAfterRestore
289
- } from "./chunk-QTERJVPZ.js";
292
+ } from "./chunk-EKTCKZV5.js";
290
293
  import "./chunk-3Z43GZUQ.js";
291
294
  import "./chunk-RXFQM6FQ.js";
292
- import "./chunk-LL4U3BSH.js";
293
- import "./chunk-6H67XLET.js";
294
295
  import {
295
296
  assertVoiceBaseUrlNetworkAllowed,
296
297
  isKeytermEcho,
297
298
  isStreamingVoiceModel,
298
299
  resolveVoiceStreamConfig,
299
300
  transcribeVoiceAudio
300
- } from "./chunk-2A6MHYIA.js";
301
+ } from "./chunk-WY2ENRDN.js";
301
302
  import {
302
303
  formatUnsupportedVoiceModelMessage,
303
304
  isSelectableVoiceModel
304
- } from "./chunk-XSA5EKTJ.js";
305
+ } from "./chunk-BKGA75MU.js";
305
306
  import "./chunk-JELIWHXD.js";
307
+ import {
308
+ computeWorkspaceSkillListUpdates,
309
+ resolveSkillSettings,
310
+ skillSettingStrings
311
+ } from "./chunk-Z4X5MTRT.js";
312
+ import "./chunk-2LZCLQIS.js";
313
+ import {
314
+ requestConsentInteractive,
315
+ requestConsentOrFail
316
+ } from "./chunk-D2GPKXCQ.js";
317
+ import "./chunk-57OAHC2Y.js";
306
318
  import {
307
319
  createLoadedSettingsAdapter
308
- } from "./chunk-K5Q62CGR.js";
320
+ } from "./chunk-IF6K42YJ.js";
309
321
  import {
310
322
  getExtendedSystemInfo
311
- } from "./chunk-GHJM2C2T.js";
323
+ } from "./chunk-QWDVZH24.js";
312
324
  import {
313
325
  formatDuration,
314
326
  formatRelativeTime,
@@ -318,36 +330,26 @@ import "./chunk-GLWP3FDB.js";
318
330
  import "./chunk-XCGIMOLN.js";
319
331
  import {
320
332
  isInlineModelOverrideAllowed
321
- } from "./chunk-AYB4HSBI.js";
322
- import {
323
- computeWorkspaceSkillListUpdates,
324
- resolveSkillSettings,
325
- skillSettingStrings
326
- } from "./chunk-Z4X5MTRT.js";
327
- import "./chunk-3WXMXT7C.js";
328
- import {
329
- requestConsentInteractive,
330
- requestConsentOrFail
331
- } from "./chunk-BKUN5QHP.js";
332
- import "./chunk-57OAHC2Y.js";
333
- import "./chunk-2CTKGIFR.js";
334
- import "./chunk-K4CGQN4Q.js";
335
- import "./chunk-ZTN6OA5J.js";
333
+ } from "./chunk-5VYFXHY2.js";
334
+ import "./chunk-LGT3YMLN.js";
335
+ import "./chunk-X6WUYMOV.js";
336
+ import "./chunk-VWOVHOTT.js";
336
337
  import "./chunk-V6WHFGST.js";
338
+ import "./chunk-DP3IHZGG.js";
337
339
  import "./chunk-6PLDPT2C.js";
338
340
  import "./chunk-FYJ7W2PI.js";
339
341
  import "./chunk-QONSRAEV.js";
340
- import "./chunk-UHTJC7O3.js";
342
+ import "./chunk-24ER7UV4.js";
341
343
  import "./chunk-ALMR3E6Q.js";
342
344
  import "./chunk-BK2UNYWD.js";
343
345
  import "./chunk-M5GB774H.js";
344
346
  import "./chunk-XC2VAFVZ.js";
345
- import "./chunk-I6FAHB4N.js";
346
- import "./chunk-GB3AB7TR.js";
347
+ import "./chunk-WUC6ZFXO.js";
348
+ import "./chunk-DIEFUBV6.js";
347
349
  import "./chunk-UDXSXLER.js";
348
350
  import {
349
351
  loadMcpApprovals
350
- } from "./chunk-NZB4NDJL.js";
352
+ } from "./chunk-2MI7ZTRT.js";
351
353
  import {
352
354
  CORRUPTED_SUFFIX,
353
355
  SettingScope,
@@ -370,7 +372,7 @@ import {
370
372
  settingExistsInScope,
371
373
  validateSettingValue,
372
374
  writeOutputLanguageAndRegisterPath
373
- } from "./chunk-LAPK3GLC.js";
375
+ } from "./chunk-22YFMJBW.js";
374
376
  import "./chunk-RKUWKYED.js";
375
377
  import "./chunk-GOXKNSDZ.js";
376
378
  import "./chunk-IDS7MSUP.js";
@@ -379,25 +381,24 @@ import {
379
381
  localizeToolDisplayName,
380
382
  t,
381
383
  ta
382
- } from "./chunk-CHCLO3M7.js";
383
- import "./chunk-AQEWCKX4.js";
384
+ } from "./chunk-KXWERR6P.js";
385
+ import "./chunk-6NE5NTHJ.js";
384
386
  import "./chunk-6PEXNQTX.js";
385
- import "./chunk-DP3IHZGG.js";
386
- import "./chunk-25QQVOCG.js";
387
+ import "./chunk-FXVHVCNA.js";
388
+ import {
389
+ getCliVersion
390
+ } from "./chunk-BKXTHMOZ.js";
391
+ import "./chunk-VJNBRRZG.js";
387
392
  import {
388
393
  isWorkspaceTrusted,
389
394
  loadTrustedFolders
390
- } from "./chunk-434YCHSV.js";
395
+ } from "./chunk-M5LIY7Y6.js";
391
396
  import {
392
397
  require_strip_json_comments
393
398
  } from "./chunk-ALGGS7UH.js";
394
399
  import "./chunk-MR3PXB6E.js";
395
400
  import "./chunk-XFSFZCM5.js";
396
401
  import "./chunk-URK542T4.js";
397
- import {
398
- getCliVersion
399
- } from "./chunk-MBKPUM5Y.js";
400
- import "./chunk-VJNBRRZG.js";
401
402
  import {
402
403
  ALIBABA_PROVIDERS,
403
404
  AsyncFzf,
@@ -423,7 +424,6 @@ import {
423
424
  THIRD_PARTY_PROVIDERS,
424
425
  abortSpeculation,
425
426
  acceptSpeculation,
426
- activeGoalEquals,
427
427
  aggregateUsage,
428
428
  allowEditorTypeInSandbox,
429
429
  applyProviderInstallPlan,
@@ -433,7 +433,6 @@ import {
433
433
  checkForExtensionUpdate,
434
434
  checkHasEditorType,
435
435
  clampInlineMediaPart,
436
- clearActiveGoal,
437
436
  clearWelcomeBackState,
438
437
  clearWorktreeSession,
439
438
  compactToolResultDisplayForHistory,
@@ -458,7 +457,6 @@ import {
458
457
  generatePromptSuggestion,
459
458
  generateSessionRecap,
460
459
  generateToolUseSummary,
461
- getActiveGoal,
462
460
  getDefaultBaseUrlForProtocol,
463
461
  getDefaultModelIds,
464
462
  getExtensionDisplayName,
@@ -496,7 +494,6 @@ import {
496
494
  restoreWorktreeContext,
497
495
  saveWelcomeBackRestartChoice,
498
496
  saveWorkflowScript,
499
- setActiveGoal,
500
497
  shouldShowStep,
501
498
  startSpeculation,
502
499
  stripTerminalControlSequences,
@@ -504,27 +501,28 @@ import {
504
501
  validateWorkflowName,
505
502
  watchRepoBranch,
506
503
  writeRuntimeStatus
507
- } from "./chunk-NGWYUZZO.js";
504
+ } from "./chunk-UQDFEU47.js";
508
505
  import "./chunk-GOFAQQZA.js";
509
506
  import "./chunk-5M6IDOMF.js";
510
507
  import "./chunk-TWPJO254.js";
511
508
  import "./chunk-H6XPXXMH.js";
512
- import "./chunk-CWEIMFFW.js";
509
+ import "./chunk-VA5NLVPT.js";
513
510
  import "./chunk-I7JDGNG6.js";
514
511
  import "./chunk-A6SX5TAH.js";
515
512
  import "./chunk-33FNCQSY.js";
516
513
  import "./chunk-6PVPNMXU.js";
517
514
  import {
518
515
  resolveModelId
519
- } from "./chunk-PXA5AWHY.js";
516
+ } from "./chunk-XUMAD5IT.js";
520
517
  import "./chunk-IRH27ZC2.js";
521
518
  import "./chunk-QHWCP53L.js";
522
519
  import "./chunk-MOHAWIAW.js";
523
- import "./chunk-MYT7N6QH.js";
520
+ import "./chunk-X6QNZOTC.js";
524
521
  import {
525
522
  promptIdContext
526
523
  } from "./chunk-O6GEWCJA.js";
527
524
  import "./chunk-T26EAKDL.js";
525
+ import "./chunk-ZPJWUGCS.js";
528
526
  import "./chunk-CPBF7KYF.js";
529
527
  import "./chunk-MISUEWB4.js";
530
528
  import "./chunk-KRXPRVGL.js";
@@ -533,20 +531,24 @@ import {
533
531
  } from "./chunk-A5YZ3FA2.js";
534
532
  import "./chunk-YAVY33G4.js";
535
533
  import "./chunk-2UISUFHQ.js";
536
- import "./chunk-6FMJLI5M.js";
534
+ import {
535
+ elapsedActiveTime,
536
+ goalRequiresExactPermit
537
+ } from "./chunk-HFVW54NL.js";
537
538
  import {
538
539
  APPROVAL_MODES,
539
- getStartupContextLength,
540
- isSystemReminderContent,
541
540
  runOutsideAgentContext
542
- } from "./chunk-PGEGUNH5.js";
541
+ } from "./chunk-TZTBZ25J.js";
543
542
  import "./chunk-S6LOFUVP.js";
543
+ import {
544
+ getStartupContextLength,
545
+ isSystemReminderContent
546
+ } from "./chunk-SRY26X4H.js";
544
547
  import "./chunk-K623ENWT.js";
545
548
  import "./chunk-AQ37AY7B.js";
546
549
  import {
547
550
  isPathWithinRoot
548
551
  } from "./chunk-432XCUHF.js";
549
- import "./chunk-ZPJWUGCS.js";
550
552
  import {
551
553
  osc8Hyperlink,
552
554
  qwenOAuth2Events,
@@ -566,7 +568,7 @@ import {
566
568
  } from "./chunk-MPHPFVKK.js";
567
569
  import "./chunk-GLNBDYUX.js";
568
570
  import "./chunk-DJ2GSRLV.js";
569
- import "./chunk-XCLLRKY5.js";
571
+ import "./chunk-EIMKVOSF.js";
570
572
  import "./chunk-RPYYTL7E.js";
571
573
  import "./chunk-2J3OJGTL.js";
572
574
  import "./chunk-P3QQPMQA.js";
@@ -613,7 +615,7 @@ import {
613
615
  runVisionBridge,
614
616
  shouldRunVisionBridge,
615
617
  splitImageParts
616
- } from "./chunk-M2F5PLOW.js";
618
+ } from "./chunk-4K3RV3OA.js";
617
619
  import "./chunk-VGC4I5JJ.js";
618
620
  import {
619
621
  AUTO_MEMORY_INDEX_FILENAME,
@@ -622,14 +624,14 @@ import {
622
624
  getUserAutoMemoryRoot,
623
625
  isAnyAutoMemPath
624
626
  } from "./chunk-E4WHKETF.js";
625
- import "./chunk-BV4QX43X.js";
627
+ import "./chunk-UEJESCS7.js";
626
628
  import {
627
629
  ToolNames,
628
630
  isShellProgressData
629
- } from "./chunk-I5GNT6ZS.js";
631
+ } from "./chunk-CFDR3GNL.js";
630
632
  import {
631
633
  MAINLINE_CODER_MODEL
632
- } from "./chunk-TFFMATHX.js";
634
+ } from "./chunk-H35Q5CEG.js";
633
635
  import "./chunk-46UV252V.js";
634
636
  import {
635
637
  DEFAULT_TOKEN_LIMIT
@@ -655,11 +657,11 @@ import {
655
657
  tildeifyPath
656
658
  } from "./chunk-3RXUYQJI.js";
657
659
  import "./chunk-VOQXFAY5.js";
658
- import "./chunk-W7XZ3KP5.js";
660
+ import "./chunk-R7XNRHYD.js";
659
661
  import {
660
662
  registerCleanup,
661
663
  runExitCleanup
662
- } from "./chunk-SK2UKB45.js";
664
+ } from "./chunk-QDWLUXKP.js";
663
665
  import {
664
666
  finalizeStartupProfile,
665
667
  profileCheckpoint
@@ -2356,6 +2358,7 @@ function isSyntheticHistoryItem(item) {
2356
2358
  case "arena_agent_complete":
2357
2359
  case "arena_session_complete":
2358
2360
  case "goal_status":
2361
+ case "goal_state":
2359
2362
  return false;
2360
2363
  default: {
2361
2364
  const _exhaustive = item;
@@ -11054,6 +11057,7 @@ function ModelDialog({
11054
11057
  isFastModelMode,
11055
11058
  isVoiceModelMode,
11056
11059
  isVisionModelMode,
11060
+ isCompactionModelMode,
11057
11061
  isImageModelMode,
11058
11062
  persistScope,
11059
11063
  availableTerminalHeight
@@ -11072,7 +11076,7 @@ function ModelDialog({
11072
11076
  buildModelSelectionKey(m.authType, m.id, m.baseUrl)
11073
11077
  );
11074
11078
  const isSelectableImageModel = isImageModelMode ? m.imageOnly === true && config?.resolveImageGenerationModel(imageModelSelector) !== void 0 : m.imageOnly !== true;
11075
- return !m.isRuntimeModel && (m.authType !== "qwen-oauth" /* QWEN_OAUTH */ || authType === "qwen-oauth" /* QWEN_OAUTH */) && isSelectableImageModel && (isFastModelMode || !m.fastOnly) && (isVoiceModelMode || !m.voiceOnly);
11079
+ return !m.isRuntimeModel && (m.authType !== "qwen-oauth" /* QWEN_OAUTH */ || authType === "qwen-oauth" /* QWEN_OAUTH */) && isSelectableImageModel && (isFastModelMode || !m.fastOnly) && (isVoiceModelMode || !m.voiceOnly) && (isVisionModelMode || !m.visionOnly);
11076
11080
  });
11077
11081
  const modelsByAuthTypeMap = /* @__PURE__ */ new Map();
11078
11082
  for (const model of registryModels) {
@@ -11108,7 +11112,14 @@ function ModelDialog({
11108
11112
  }
11109
11113
  }
11110
11114
  return result;
11111
- }, [authType, config, isFastModelMode, isImageModelMode, isVoiceModelMode]);
11115
+ }, [
11116
+ authType,
11117
+ config,
11118
+ isFastModelMode,
11119
+ isImageModelMode,
11120
+ isVoiceModelMode,
11121
+ isVisionModelMode
11122
+ ]);
11112
11123
  const MODEL_OPTIONS = (0, import_react34.useMemo)(
11113
11124
  () => availableModelEntries.map(
11114
11125
  ({ authType: t2, model, isRuntime, snapshotId }) => {
@@ -11202,7 +11213,7 @@ function ModelDialog({
11202
11213
  }
11203
11214
  }, [parsedImageModelValue?.selector, isImageModelMode]);
11204
11215
  const preferredModelId = isFastModelMode && parsedFastModelSetting ? parsedFastModelSetting.modelId : isVisionModelMode && parsedVisionModelSetting ? parsedVisionModelSetting.modelId : isImageModelMode && parsedImageModelSetting ? parsedImageModelSetting.modelId : config?.getModel() || MAINLINE_CODER_MODEL;
11205
- const activeRuntimeSnapshot = isFastModelMode || isVoiceModelMode || isVisionModelMode || isImageModelMode ? void 0 : config?.getActiveRuntimeModelSnapshot?.();
11216
+ const activeRuntimeSnapshot = isFastModelMode || isVoiceModelMode || isVisionModelMode || isCompactionModelMode || isImageModelMode ? void 0 : config?.getActiveRuntimeModelSnapshot?.();
11206
11217
  const currentBaseUrl = config?.getModelsConfig().getGenerationConfig()?.baseUrl;
11207
11218
  const preferredFastModelEntry = isFastModelMode && parsedFastModelSetting ? parsedFastModelSetting.authType ? availableModelEntries.find(
11208
11219
  ({ authType: t2, model }) => t2 === parsedFastModelSetting.authType && model.id === parsedFastModelSetting.modelId
@@ -11223,6 +11234,21 @@ function ModelDialog({
11223
11234
  ) : availableModelEntries.find(
11224
11235
  ({ model }) => model.id === parsedImageModelSetting.modelId && (!parsedImageModelValue?.baseUrl || model.baseUrl === parsedImageModelValue.baseUrl)
11225
11236
  ) : void 0;
11237
+ const parsedCompactionSetting = (0, import_react34.useMemo)(() => {
11238
+ if (!isCompactionModelMode) return void 0;
11239
+ const raw = settings?.merged?.compactionModel?.trim();
11240
+ if (!raw) return void 0;
11241
+ try {
11242
+ return resolveModelId(raw);
11243
+ } catch {
11244
+ return void 0;
11245
+ }
11246
+ }, [settings?.merged?.compactionModel, isCompactionModelMode]);
11247
+ const preferredCompactionModelEntry = isCompactionModelMode && parsedCompactionSetting ? parsedCompactionSetting.authType ? availableModelEntries.find(
11248
+ ({ authType: t2, model }) => t2 === parsedCompactionSetting.authType && model.id === parsedCompactionSetting.modelId
11249
+ ) : availableModelEntries.find(
11250
+ ({ model }) => model.id === parsedCompactionSetting.modelId
11251
+ ) : void 0;
11226
11252
  const preferredKey = activeRuntimeSnapshot ? activeRuntimeSnapshot.id : preferredVoiceModelEntry ? buildModelSelectionKey(
11227
11253
  preferredVoiceModelEntry.authType,
11228
11254
  preferredVoiceModelEntry.model.id,
@@ -11231,6 +11257,10 @@ function ModelDialog({
11231
11257
  preferredVisionModelEntry.authType,
11232
11258
  preferredVisionModelEntry.model.id,
11233
11259
  preferredVisionModelEntry.model.baseUrl
11260
+ ) : preferredCompactionModelEntry ? buildModelSelectionKey(
11261
+ preferredCompactionModelEntry.authType,
11262
+ preferredCompactionModelEntry.model.id,
11263
+ preferredCompactionModelEntry.model.baseUrl
11234
11264
  ) : preferredImageModelEntry ? buildModelSelectionKey(
11235
11265
  preferredImageModelEntry.authType,
11236
11266
  preferredImageModelEntry.model.id,
@@ -11246,7 +11276,7 @@ function ModelDialog({
11246
11276
  ) : "";
11247
11277
  useKeypress(
11248
11278
  (key) => {
11249
- if (key.name === "escape" || key.name === "left" && (isFastModelMode || isVoiceModelMode || isVisionModelMode || isImageModelMode)) {
11279
+ if (key.name === "escape" || key.name === "left" && (isFastModelMode || isVoiceModelMode || isVisionModelMode || isCompactionModelMode || isImageModelMode)) {
11250
11280
  onClose();
11251
11281
  }
11252
11282
  },
@@ -11359,6 +11389,26 @@ ${t("\u26A0 '{{model}}' is not a known image-capable model; the vision bridge ma
11359
11389
  onClose();
11360
11390
  return;
11361
11391
  }
11392
+ if (isCompactionModelMode) {
11393
+ if (!selectedEntry || !config) {
11394
+ setErrorMessage(t("Selected compaction model is unavailable."));
11395
+ return;
11396
+ }
11397
+ const compactionModelId = encodeAuxModelSelector(selected);
11398
+ const scope = resolvePersistScope(settings, persistScope);
11399
+ settings.setValue(scope, "compactionModel", compactionModelId);
11400
+ config.setCompactionModel(compactionModelId);
11401
+ const scopeSuffix = persistScope === "workspace" ? t(" (this project)") : persistScope === "user" ? t(" (global)") : "";
11402
+ uiState?.historyManager.addItem(
11403
+ {
11404
+ type: "success",
11405
+ text: `${t("Compaction Model")}: ${compactionModelId}${scopeSuffix}`
11406
+ },
11407
+ Date.now()
11408
+ );
11409
+ onClose();
11410
+ return;
11411
+ }
11362
11412
  if (isImageModelMode) {
11363
11413
  if (!selectedEntry || !config) {
11364
11414
  setErrorMessage(t("Selected image model is unavailable."));
@@ -11476,6 +11526,7 @@ ${baseErrorMessage}`);
11476
11526
  isFastModelMode,
11477
11527
  isVoiceModelMode,
11478
11528
  isVisionModelMode,
11529
+ isCompactionModelMode,
11479
11530
  isImageModelMode,
11480
11531
  availableModelEntries,
11481
11532
  persistScope
@@ -11491,7 +11542,7 @@ ${baseErrorMessage}`);
11491
11542
  padding: 1,
11492
11543
  width: "100%",
11493
11544
  children: [
11494
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Text, { bold: true, children: (isVoiceModelMode ? t("Select Voice Model") : isVisionModelMode ? t("Select Vision Model") : isImageModelMode ? t("Select Image Model") : isFastModelMode ? t("Select Fast Model") : t("Select Model")) + (persistScope === "workspace" ? t(" (this project)") : persistScope === "user" ? t(" (global)") : "") }),
11545
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Text, { bold: true, children: (isVoiceModelMode ? t("Select Voice Model") : isVisionModelMode ? t("Select Vision Model") : isCompactionModelMode ? t("Select Compaction Model") : isImageModelMode ? t("Select Image Model") : isFastModelMode ? t("Select Fast Model") : t("Select Model")) + (persistScope === "workspace" ? t(" (this project)") : persistScope === "user" ? t(" (global)") : "") }),
11495
11546
  !hasModels ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [
11496
11547
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Text, { color: theme.status.warning, children: t(
11497
11548
  "No models available for the current authentication type ({{authType}}).",
@@ -24431,6 +24482,7 @@ var DialogManager = /* @__PURE__ */ __name(({
24431
24482
  isFastModelMode: uiState.isFastModelMode,
24432
24483
  isVoiceModelMode: uiState.isVoiceModelMode,
24433
24484
  isVisionModelMode: uiState.isVisionModelMode,
24485
+ isCompactionModelMode: uiState.isCompactionModelMode,
24434
24486
  isImageModelMode: uiState.isImageModelMode,
24435
24487
  persistScope: uiState.modelDialogPersistScope,
24436
24488
  availableTerminalHeight: listDialogHeight
@@ -29189,9 +29241,8 @@ var InputPrompt = /* @__PURE__ */ __name(({
29189
29241
  const uiState = useUIState();
29190
29242
  const uiActions = useUIActions();
29191
29243
  const settings = useSettings();
29192
- const mouseInteractionsEnabled = useVirtualViewport(
29193
- settings.merged.ui?.useTerminalBuffer
29194
- );
29244
+ const mouseTrackingEnabled = useMouseTrackingEnabled();
29245
+ const mouseInteractionsEnabled = useVirtualViewport(settings.merged.ui?.useTerminalBuffer) && mouseTrackingEnabled;
29195
29246
  const { pasteWorkaround } = useKeypressContext();
29196
29247
  const { agents, agentTabBarFocused } = useAgentViewState();
29197
29248
  const { setAgentTabBarFocused } = useAgentViewActions();
@@ -31274,45 +31325,102 @@ __name(useConfigInitMessage, "useConfigInitMessage");
31274
31325
  init_esbuild_shims();
31275
31326
  var import_react103 = __toESM(require_react(), 1);
31276
31327
  var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
31277
- var POLL_INTERVAL_MS = 1e3;
31328
+ var ELAPSED_REFRESH_MS = 1e3;
31278
31329
  function formatElapsed(ms) {
31279
31330
  if (ms < 1e3) return "";
31280
- const s = Math.floor(ms / 1e3);
31281
- if (s < 60) return `${s}s`;
31282
- const m = Math.floor(s / 60);
31283
- if (m < 60) return `${m}m`;
31284
- const h = Math.floor(m / 60);
31285
- return `${h}h ${m % 60}m`;
31331
+ const seconds = Math.floor(ms / 1e3);
31332
+ if (seconds < 60) return `${seconds}s`;
31333
+ const minutes = Math.floor(seconds / 60);
31334
+ if (minutes < 60) return `${minutes}m`;
31335
+ const hours = Math.floor(minutes / 60);
31336
+ return `${hours}h ${minutes % 60}m`;
31286
31337
  }
31287
31338
  __name(formatElapsed, "formatElapsed");
31288
- function useActiveGoal(sessionId) {
31289
- const [goal, setGoal] = (0, import_react103.useState)(
31290
- () => getActiveGoal(sessionId)
31291
- );
31292
- const [, setTick] = (0, import_react103.useState)(0);
31293
- (0, import_react103.useEffect)(() => {
31294
- const id = setInterval(() => {
31295
- const next = getActiveGoal(sessionId);
31296
- setGoal(next);
31297
- if (next) setTick((t2) => (t2 + 1) % 1e6);
31298
- }, POLL_INTERVAL_MS);
31299
- return () => clearInterval(id);
31300
- }, [sessionId]);
31301
- return goal;
31339
+ function getRuntime(config) {
31340
+ if (typeof config.getGoalRuntime !== "function") return null;
31341
+ try {
31342
+ return config.getGoalRuntime();
31343
+ } catch {
31344
+ return null;
31345
+ }
31302
31346
  }
31303
- __name(useActiveGoal, "useActiveGoal");
31347
+ __name(getRuntime, "getRuntime");
31304
31348
  function useFooterGoalState() {
31305
31349
  const config = useConfig();
31306
- return useActiveGoal(config.getSessionId());
31350
+ const sessionId = config.getSessionId();
31351
+ const runtime = getRuntime(config);
31352
+ const [observed, setObserved] = (0, import_react103.useState)(() => ({
31353
+ runtime,
31354
+ snapshot: runtime?.getSnapshot()
31355
+ }));
31356
+ (0, import_react103.useEffect)(() => {
31357
+ if (!runtime) {
31358
+ setObserved({ runtime });
31359
+ return;
31360
+ }
31361
+ setObserved({ runtime, snapshot: runtime.getSnapshot() });
31362
+ return runtime.subscribe((snapshot) => {
31363
+ setObserved({ runtime, snapshot });
31364
+ });
31365
+ }, [runtime, sessionId]);
31366
+ return observed.runtime === runtime ? observed.snapshot : runtime?.getSnapshot();
31307
31367
  }
31308
31368
  __name(useFooterGoalState, "useFooterGoalState");
31309
- var GoalPill = /* @__PURE__ */ __name(() => {
31310
- const goal = useFooterGoalState();
31369
+ function isLiveGoalSnapshot(snapshot) {
31370
+ const status = snapshot?.goal?.status;
31371
+ return status !== void 0 && status !== "complete";
31372
+ }
31373
+ __name(isLiveGoalSnapshot, "isLiveGoalSnapshot");
31374
+ function presentation(snapshot) {
31375
+ const goal = snapshot.goal;
31376
+ if (!goal || goal.status === "complete") return null;
31377
+ if (goal.status === "active") {
31378
+ return snapshot.activity === "verifying" ? {
31379
+ icon: ICON.CIRCLE_EMPTY,
31380
+ label: "checking",
31381
+ color: theme.text.secondary
31382
+ } : { icon: ICON.BULLSEYE, label: "active", color: theme.text.accent };
31383
+ }
31384
+ switch (goal.status) {
31385
+ case "paused":
31386
+ return { icon: "!", label: "paused", color: theme.status.warning };
31387
+ case "blocked":
31388
+ return { icon: ICON.CROSS, label: "blocked", color: theme.status.error };
31389
+ case "usage_limited":
31390
+ return {
31391
+ icon: "!",
31392
+ label: "usage limited",
31393
+ color: theme.status.warning
31394
+ };
31395
+ default: {
31396
+ const exhaustive = goal.status;
31397
+ void exhaustive;
31398
+ return null;
31399
+ }
31400
+ }
31401
+ }
31402
+ __name(presentation, "presentation");
31403
+ var GoalPill = /* @__PURE__ */ __name(({ snapshot }) => {
31404
+ const [, setTick] = (0, import_react103.useState)(0);
31405
+ const refreshElapsed = snapshot?.goal?.status === "active";
31406
+ (0, import_react103.useEffect)(() => {
31407
+ if (!refreshElapsed) return;
31408
+ const interval = setInterval(() => {
31409
+ setTick((tick) => (tick + 1) % 1e6);
31410
+ }, ELAPSED_REFRESH_MS);
31411
+ return () => clearInterval(interval);
31412
+ }, [refreshElapsed]);
31413
+ if (!snapshot) return null;
31414
+ const goal = snapshot.goal;
31311
31415
  if (!goal) return null;
31312
- const elapsed = formatElapsed(Date.now() - goal.setAt);
31416
+ const visible = presentation(snapshot);
31417
+ if (!visible) return null;
31418
+ const elapsed = formatElapsed(elapsedActiveTime(goal, Date.now()));
31313
31419
  const suffix = elapsed ? ` (${elapsed})` : "";
31314
- return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(Text, { color: theme.text.accent, children: [
31315
- "\u25CE /goal active",
31420
+ return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(Text, { color: visible.color, children: [
31421
+ visible.icon,
31422
+ " /goal ",
31423
+ visible.label,
31316
31424
  suffix
31317
31425
  ] });
31318
31426
  }, "GoalPill");
@@ -31321,7 +31429,7 @@ var GoalPill = /* @__PURE__ */ __name(() => {
31321
31429
  init_esbuild_shims();
31322
31430
  var import_react104 = __toESM(require_react(), 1);
31323
31431
  var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
31324
- var POLL_INTERVAL_MS2 = 1e3;
31432
+ var POLL_INTERVAL_MS = 1e3;
31325
31433
  function getScheduledTaskCount(config) {
31326
31434
  if (!config?.isCronEnabled?.()) return 0;
31327
31435
  return config.getCronScheduler?.()?.size ?? 0;
@@ -31332,7 +31440,7 @@ function useScheduledTaskCount(config) {
31332
31440
  (0, import_react104.useEffect)(() => {
31333
31441
  const id = setInterval(() => {
31334
31442
  setCount(getScheduledTaskCount(config));
31335
- }, POLL_INTERVAL_MS2);
31443
+ }, POLL_INTERVAL_MS);
31336
31444
  return () => clearInterval(id);
31337
31445
  }, [config]);
31338
31446
  return count;
@@ -31441,9 +31549,12 @@ var Footer = /* @__PURE__ */ __name(() => {
31441
31549
  ) })
31442
31550
  });
31443
31551
  }
31444
- const goalActive = useFooterGoalState() !== void 0;
31445
- if (goalActive) {
31446
- rightItems.push({ key: "goal", node: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(GoalPill, {}) });
31552
+ const goalState = useFooterGoalState();
31553
+ if (isLiveGoalSnapshot(goalState)) {
31554
+ rightItems.push({
31555
+ key: "goal",
31556
+ node: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(GoalPill, { snapshot: goalState })
31557
+ });
31447
31558
  }
31448
31559
  const cronTaskCount = useFooterCronTaskCount();
31449
31560
  if (cronTaskCount > 0) {
@@ -33608,20 +33719,25 @@ var useModelCommand = /* @__PURE__ */ __name(() => {
33608
33719
  const [isFastModelMode, setIsFastModelMode] = (0, import_react122.useState)(false);
33609
33720
  const [isVoiceModelMode, setIsVoiceModelMode] = (0, import_react122.useState)(false);
33610
33721
  const [isVisionModelMode, setIsVisionModelMode] = (0, import_react122.useState)(false);
33722
+ const [isCompactionModelMode, setIsCompactionModelMode] = (0, import_react122.useState)(false);
33611
33723
  const [isImageModelMode, setIsImageModelMode] = (0, import_react122.useState)(false);
33612
33724
  const [modelDialogPersistScope, setModelDialogPersistScope] = (0, import_react122.useState)(void 0);
33613
33725
  const openModelDialog = (0, import_react122.useCallback)(
33614
33726
  (options) => {
33615
33727
  const voiceModelMode = options?.voiceModelMode ?? false;
33616
33728
  const visionModelMode = options?.visionModelMode ?? false;
33729
+ const compactionModelMode = options?.compactionModelMode ?? false;
33617
33730
  const imageModelMode = options?.imageModelMode ?? false;
33618
33731
  setIsFastModelMode(
33619
- voiceModelMode || visionModelMode || imageModelMode ? false : options?.fastModelMode ?? false
33732
+ voiceModelMode || visionModelMode || compactionModelMode || imageModelMode ? false : options?.fastModelMode ?? false
33620
33733
  );
33621
33734
  setIsVoiceModelMode(
33622
- visionModelMode || imageModelMode ? false : voiceModelMode
33735
+ visionModelMode || compactionModelMode || imageModelMode ? false : voiceModelMode
33736
+ );
33737
+ setIsVisionModelMode(
33738
+ compactionModelMode || imageModelMode ? false : visionModelMode
33623
33739
  );
33624
- setIsVisionModelMode(imageModelMode ? false : visionModelMode);
33740
+ setIsCompactionModelMode(imageModelMode ? false : compactionModelMode);
33625
33741
  setIsImageModelMode(imageModelMode);
33626
33742
  setModelDialogPersistScope(options?.persistScope);
33627
33743
  setIsModelDialogOpen(true);
@@ -33633,6 +33749,7 @@ var useModelCommand = /* @__PURE__ */ __name(() => {
33633
33749
  setIsFastModelMode(false);
33634
33750
  setIsVoiceModelMode(false);
33635
33751
  setIsVisionModelMode(false);
33752
+ setIsCompactionModelMode(false);
33636
33753
  setIsImageModelMode(false);
33637
33754
  setModelDialogPersistScope(void 0);
33638
33755
  }, []);
@@ -33641,6 +33758,7 @@ var useModelCommand = /* @__PURE__ */ __name(() => {
33641
33758
  isFastModelMode,
33642
33759
  isVoiceModelMode,
33643
33760
  isVisionModelMode,
33761
+ isCompactionModelMode,
33644
33762
  isImageModelMode,
33645
33763
  modelDialogPersistScope,
33646
33764
  openModelDialog,
@@ -33814,6 +33932,7 @@ function useBranchCommand(options) {
33814
33932
  }
33815
33933
  config.startNewSession(newSessionId, resumed);
33816
33934
  coreSwapped = true;
33935
+ await waitForGoalRuntime(config);
33817
33936
  await config.getGeminiClient()?.initialize?.("branch" /* Branch */);
33818
33937
  const rawItems = buildResumedHistoryItems(resumed, config);
33819
33938
  const collapseOnResume = options.settings.merged.ui?.history?.collapseOnResume ?? false;
@@ -33828,14 +33947,6 @@ function useBranchCommand(options) {
33828
33947
  historyManager.loadHistory(uiHistoryItems);
33829
33948
  uiSwapped = true;
33830
33949
  resetBackgroundStateForSessionSwitch(config);
33831
- try {
33832
- restoreGoalFromHistory(
33833
- uiHistoryItems,
33834
- config,
33835
- historyManager.addItem
33836
- );
33837
- } catch {
33838
- }
33839
33950
  setSessionName?.(effectiveTitle);
33840
33951
  remount?.();
33841
33952
  const titleInfo = name ? ` "${name}"` : "";
@@ -33979,10 +34090,7 @@ function useResumeCommand(options) {
33979
34090
  resetBackgroundStateForSessionSwitch(config);
33980
34091
  config.startNewSession(sessionId, sessionData);
33981
34092
  coreSwapped = true;
33982
- try {
33983
- restoreGoalFromHistory(uiHistoryItems, config, addItem);
33984
- } catch {
33985
- }
34093
+ await waitForGoalRuntime(config);
33986
34094
  config.getChatRecordingService()?.rebuildTurnBoundaries(sessionData.conversation.messages);
33987
34095
  await config.getGeminiClient()?.initialize?.();
33988
34096
  const recovered = await config.loadPausedBackgroundAgents(sessionId);
@@ -35023,6 +35131,29 @@ var useSlashCommandProcessor = /* @__PURE__ */ __name((config, settings, history
35023
35131
  });
35024
35132
  }
35025
35133
  return { type: "handled" };
35134
+ case "goal_control": {
35135
+ const rendersHere = result.cause === void 0 || commandContext.ui.isIdleRef.current;
35136
+ if (rendersHere) {
35137
+ const snapshot = result.response.snapshot;
35138
+ if (snapshot.goal || result.cause === "clear") {
35139
+ addItem(
35140
+ {
35141
+ type: "goal_state" /* GOAL_STATE */,
35142
+ snapshot,
35143
+ ...result.cause ? { cause: result.cause } : {}
35144
+ },
35145
+ Date.now()
35146
+ );
35147
+ } else {
35148
+ addMessage({
35149
+ type: "info" /* INFO */,
35150
+ content: "No Goal set.",
35151
+ timestamp: /* @__PURE__ */ new Date()
35152
+ });
35153
+ }
35154
+ }
35155
+ return { type: "handled" };
35156
+ }
35026
35157
  case "dialog":
35027
35158
  switch (result.dialog) {
35028
35159
  case "arena_start":
@@ -35078,6 +35209,12 @@ var useSlashCommandProcessor = /* @__PURE__ */ __name((config, settings, history
35078
35209
  persistScope: result.persistScope
35079
35210
  });
35080
35211
  return { type: "handled" };
35212
+ case "compaction-model":
35213
+ actions.openModelDialog({
35214
+ compactionModelMode: true,
35215
+ persistScope: result.persistScope
35216
+ });
35217
+ return { type: "handled" };
35081
35218
  case "image-model":
35082
35219
  actions.openModelDialog({
35083
35220
  imageModelMode: true,
@@ -36110,85 +36247,201 @@ import process15 from "node:process";
36110
36247
  // packages/cli/src/ui/hooks/useMessageQueue.ts
36111
36248
  init_esbuild_shims();
36112
36249
  var import_react134 = __toESM(require_react(), 1);
36250
+ import { randomUUID as randomUUID2 } from "node:crypto";
36113
36251
  var GOAL_COMMAND_RE = /^\/goal(?:\s|$)/;
36114
- function aggregateMessages(messages) {
36115
- const modelText = messages.map((message) => message.modelText).join("\n\n");
36252
+ function aggregateUserMessages(messages) {
36253
+ const text = messages.map((message) => message.text).join("\n\n");
36116
36254
  const submittedPrompts = messages.map((message) => message.submittedPrompt);
36117
- return submittedPrompts.every(
36118
- (submittedPrompt) => submittedPrompt !== void 0
36119
- ) ? { modelText, submittedPrompt: submittedPrompts.join("\n\n") } : { modelText };
36255
+ return {
36256
+ kind: "user",
36257
+ modelText: text,
36258
+ turnKey: messages[0].key,
36259
+ ...submittedPrompts.every(
36260
+ (submittedPrompt) => submittedPrompt !== void 0
36261
+ ) ? { submittedPrompt: submittedPrompts.join("\n\n") } : {}
36262
+ };
36120
36263
  }
36121
- __name(aggregateMessages, "aggregateMessages");
36264
+ __name(aggregateUserMessages, "aggregateUserMessages");
36122
36265
  function useMessageQueue() {
36123
36266
  const [queuedMessages, setQueuedMessages] = (0, import_react134.useState)([]);
36267
+ const [queuedGoalTurns, setQueuedGoalTurns] = (0, import_react134.useState)([]);
36124
36268
  const queueRef = (0, import_react134.useRef)([]);
36269
+ const goalQueueRef = (0, import_react134.useRef)([]);
36270
+ const nextMessageKey = (0, import_react134.useCallback)(() => `message-queue:${randomUUID2()}`, []);
36125
36271
  const addMessage = (0, import_react134.useCallback)(
36126
36272
  (message, deferUntilIdle = false, submittedPrompt) => {
36127
- const modelText = message.trim();
36128
- if (modelText.length > 0) {
36129
- queueRef.current = [
36130
- ...queueRef.current,
36131
- { modelText, deferUntilIdle, submittedPrompt }
36132
- ];
36133
- setQueuedMessages(queueRef.current);
36273
+ const text = message.trim();
36274
+ if (!text) return;
36275
+ queueRef.current = [
36276
+ ...queueRef.current,
36277
+ {
36278
+ key: nextMessageKey(),
36279
+ text,
36280
+ deferUntilIdle,
36281
+ submittedPrompt
36282
+ }
36283
+ ];
36284
+ setQueuedMessages(queueRef.current);
36285
+ },
36286
+ [nextMessageKey]
36287
+ );
36288
+ const enqueueGoalTurn = (0, import_react134.useCallback)(
36289
+ (input) => {
36290
+ if (goalQueueRef.current.some(
36291
+ ({ permit }) => permit.turnId === input.permit.turnId
36292
+ )) {
36293
+ return;
36134
36294
  }
36295
+ const entry = {
36296
+ kind: "goal",
36297
+ permit: { ...input.permit },
36298
+ turnKey: `goal-runtime:${input.permit.turnId}`,
36299
+ continuationContext: input.continuationContext,
36300
+ ...input.verifierFeedback ? { verifierFeedback: input.verifierFeedback } : {}
36301
+ };
36302
+ goalQueueRef.current = [...goalQueueRef.current, entry];
36303
+ setQueuedGoalTurns(goalQueueRef.current);
36135
36304
  },
36136
36305
  []
36137
36306
  );
36307
+ const peekNextUserBatchKey = (0, import_react134.useCallback)(
36308
+ (goalTurnActive = false) => goalTurnActive ? void 0 : queueRef.current.find(({ text }) => !isSlashCommand(text))?.key,
36309
+ []
36310
+ );
36311
+ const hasQueuedUserMessages = (0, import_react134.useCallback)(
36312
+ () => queueRef.current.length > 0,
36313
+ []
36314
+ );
36315
+ const getPendingSubmissionCount = (0, import_react134.useCallback)(
36316
+ () => queueRef.current.length + goalQueueRef.current.length,
36317
+ []
36318
+ );
36319
+ const claimGoalTurn = (0, import_react134.useCallback)(() => {
36320
+ const [goal, ...remainingGoals] = goalQueueRef.current;
36321
+ if (goal) {
36322
+ goalQueueRef.current = remainingGoals;
36323
+ setQueuedGoalTurns(remainingGoals);
36324
+ }
36325
+ return goal;
36326
+ }, []);
36327
+ const claimDirectUserAdmission = (0, import_react134.useCallback)(() => {
36328
+ const goal = claimGoalTurn();
36329
+ return {
36330
+ turnKey: nextMessageKey(),
36331
+ ...goal ? { goal } : {}
36332
+ };
36333
+ }, [claimGoalTurn, nextMessageKey]);
36334
+ const removeGoalTurns = (0, import_react134.useCallback)(() => {
36335
+ const keys = goalQueueRef.current.map(({ turnKey }) => turnKey);
36336
+ if (keys.length === 0) return [];
36337
+ goalQueueRef.current = [];
36338
+ setQueuedGoalTurns([]);
36339
+ return keys;
36340
+ }, []);
36341
+ const popNextSubmission = (0, import_react134.useCallback)(
36342
+ (goalControlMode = "normal") => {
36343
+ if (goalControlMode !== "normal") {
36344
+ const goalCommandIndex = queueRef.current.findIndex(
36345
+ ({ text }) => GOAL_COMMAND_RE.test(text)
36346
+ );
36347
+ if (goalCommandIndex >= 0) {
36348
+ const goalCommand = queueRef.current[goalCommandIndex];
36349
+ queueRef.current = [
36350
+ ...queueRef.current.slice(0, goalCommandIndex),
36351
+ ...queueRef.current.slice(goalCommandIndex + 1)
36352
+ ];
36353
+ setQueuedMessages(queueRef.current);
36354
+ return aggregateUserMessages([goalCommand]);
36355
+ }
36356
+ if (goalControlMode === "priority") {
36357
+ return claimGoalTurn() ?? null;
36358
+ }
36359
+ if (goalControlMode === "only") return null;
36360
+ }
36361
+ const plainMessages = queueRef.current.filter(
36362
+ ({ text }) => !isSlashCommand(text)
36363
+ );
36364
+ if (plainMessages.length > 0) {
36365
+ queueRef.current = queueRef.current.filter(
36366
+ ({ text }) => isSlashCommand(text)
36367
+ );
36368
+ setQueuedMessages(queueRef.current);
36369
+ return aggregateUserMessages(plainMessages);
36370
+ }
36371
+ const [userHead, ...userRest] = queueRef.current;
36372
+ if (userHead) {
36373
+ queueRef.current = userRest;
36374
+ setQueuedMessages(userRest);
36375
+ return aggregateUserMessages([userHead]);
36376
+ }
36377
+ return claimGoalTurn() ?? null;
36378
+ },
36379
+ [claimGoalTurn]
36380
+ );
36138
36381
  const clearQueue = (0, import_react134.useCallback)(() => {
36139
36382
  queueRef.current = [];
36140
36383
  setQueuedMessages([]);
36141
36384
  }, []);
36142
36385
  const getQueuedMessagesText = (0, import_react134.useCallback)(() => {
36143
36386
  if (queuedMessages.length === 0) return "";
36144
- return queuedMessages.map(({ modelText }) => modelText).join("\n\n");
36387
+ return queuedMessages.map(({ text }) => text).join("\n\n");
36145
36388
  }, [queuedMessages]);
36146
- const popAllMessages = (0, import_react134.useCallback)(() => {
36147
- const current = queueRef.current;
36148
- if (current.length === 0) return null;
36149
- queueRef.current = [];
36150
- setQueuedMessages([]);
36151
- return aggregateMessages(current);
36152
- }, []);
36153
- const restoreMessages = (0, import_react134.useCallback)((messages) => {
36154
- const restored = messages.map((text) => text.trim()).filter(Boolean).map((modelText) => ({ modelText, deferUntilIdle: false }));
36155
- if (restored.length === 0) return;
36156
- queueRef.current = [...restored, ...queueRef.current];
36157
- setQueuedMessages(queueRef.current);
36158
- }, []);
36159
- const drainQueue = (0, import_react134.useCallback)((includeDeferred = false) => {
36160
- const current = queueRef.current;
36161
- if (current.length === 0) return [];
36162
- const shouldDrain = /* @__PURE__ */ __name((message) => (!isSlashCommand(message.modelText) || !includeDeferred && GOAL_COMMAND_RE.test(message.modelText)) && (includeDeferred || !message.deferUntilIdle), "shouldDrain");
36163
- const drained = current.filter(shouldDrain);
36164
- if (drained.length === 0) return [];
36165
- const rest = current.filter((message) => !shouldDrain(message));
36166
- queueRef.current = rest;
36167
- setQueuedMessages(rest);
36168
- return drained.map(({ modelText }) => modelText);
36169
- }, []);
36170
- const popNextTurn = (0, import_react134.useCallback)(() => {
36171
- const current = queueRef.current;
36172
- if (current.length === 0) return null;
36173
- const plainMessages = current.filter(
36174
- (message) => !isSlashCommand(message.modelText)
36175
- );
36176
- const messages = plainMessages.length > 0 ? plainMessages : [current[0]];
36177
- const selected = new Set(messages);
36178
- const rest = current.filter((message) => !selected.has(message));
36179
- queueRef.current = rest;
36180
- setQueuedMessages(rest);
36181
- return aggregateMessages(messages);
36182
- }, []);
36389
+ const popAllMessages = (0, import_react134.useCallback)(
36390
+ (onRemoved) => {
36391
+ const current = queueRef.current;
36392
+ if (current.length === 0) return null;
36393
+ queueRef.current = [];
36394
+ setQueuedMessages([]);
36395
+ onRemoved?.(current.map(({ key }) => key));
36396
+ return aggregateUserMessages(current);
36397
+ },
36398
+ []
36399
+ );
36400
+ const restoreMessages = (0, import_react134.useCallback)(
36401
+ (messages, submittedPrompt) => {
36402
+ const restored = messages.map((text) => text.trim()).filter(Boolean).map((text) => ({
36403
+ key: nextMessageKey(),
36404
+ text,
36405
+ ...messages.length === 1 && submittedPrompt !== void 0 ? { submittedPrompt } : {},
36406
+ deferUntilIdle: false
36407
+ }));
36408
+ if (restored.length === 0) return;
36409
+ queueRef.current = [...restored, ...queueRef.current];
36410
+ setQueuedMessages(queueRef.current);
36411
+ },
36412
+ [nextMessageKey]
36413
+ );
36414
+ const drainQueue = (0, import_react134.useCallback)(
36415
+ (includeDeferred = false, goalTurnActive = false) => {
36416
+ const current = queueRef.current;
36417
+ if (current.length === 0) return [];
36418
+ const shouldDrain = /* @__PURE__ */ __name((message) => (goalTurnActive ? GOAL_COMMAND_RE.test(message.text) : !isSlashCommand(message.text)) && (includeDeferred || !message.deferUntilIdle), "shouldDrain");
36419
+ const drained = current.filter(shouldDrain);
36420
+ if (drained.length === 0) return [];
36421
+ const rest = current.filter((message) => !shouldDrain(message));
36422
+ queueRef.current = rest;
36423
+ setQueuedMessages(rest);
36424
+ return drained.map(({ text }) => text);
36425
+ },
36426
+ []
36427
+ );
36183
36428
  return {
36184
- messageQueue: queuedMessages.map(({ modelText }) => modelText),
36429
+ messageQueue: queuedMessages.map(({ text }) => text),
36430
+ pendingSubmissionCount: queuedMessages.length + queuedGoalTurns.length,
36185
36431
  addMessage,
36432
+ enqueueGoalTurn,
36433
+ peekNextUserBatchKey,
36434
+ hasQueuedUserMessages,
36435
+ getPendingSubmissionCount,
36436
+ claimGoalTurn,
36437
+ claimDirectUserAdmission,
36438
+ removeGoalTurns,
36439
+ popNextSubmission,
36186
36440
  clearQueue,
36187
36441
  getQueuedMessagesText,
36188
36442
  popAllMessages,
36189
36443
  restoreMessages,
36190
- drainQueue,
36191
- popNextTurn
36444
+ drainQueue
36192
36445
  };
36193
36446
  }
36194
36447
  __name(useMessageQueue, "useMessageQueue");
@@ -36209,6 +36462,19 @@ function clearModelOverride(modelOverrideRef, inlineActiveRef) {
36209
36462
  __name(clearModelOverride, "clearModelOverride");
36210
36463
  var MID_TURN_AT_COMMAND_RESOLVE_TIMEOUT_MS = 1e4;
36211
36464
  var MID_TURN_AT_COMMAND_RESOLVE_TIMEOUT_MESSAGE = "Mid-turn @ command resolution timed out";
36465
+ function sameGoalPermit(left, right) {
36466
+ return left.goalId === right.goalId && left.revision === right.revision && left.turnId === right.turnId;
36467
+ }
36468
+ __name(sameGoalPermit, "sameGoalPermit");
36469
+ function sharedGoalPermit(contexts) {
36470
+ const first = contexts[0];
36471
+ if (contexts.every((context) => context === void 0)) return void 0;
36472
+ if (!first || contexts.some((context) => !context || !sameGoalPermit(first, context))) {
36473
+ throw new Error("ToolResult batch has mixed Goal contexts");
36474
+ }
36475
+ return { ...first };
36476
+ }
36477
+ __name(sharedGoalPermit, "sharedGoalPermit");
36212
36478
  function extractLastAssistantText(history) {
36213
36479
  for (let i = history.length - 1; i >= 0; i--) {
36214
36480
  const item = history[i];
@@ -36335,17 +36601,120 @@ function charIndexAfterLine(text, keptLines) {
36335
36601
  return -1;
36336
36602
  }
36337
36603
  __name(charIndexAfterLine, "charIndexAfterLine");
36338
- var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, config, isConfigInitialized, settings, onDebugMessage, handleSlashCommand, shellModeActive, getPreferredEditor, onAuthError, performMemoryRefresh, modelSwitchedFromQuotaError, setModelSwitchedFromQuotaError, onEditorClose, onCancelSubmit, setShellInputFocused, terminalWidth, terminalHeight, midTurnDrainRef, logger, availableTerminalHeightRef, terminalWidthRef, midTurnRestoreRef) => {
36604
+ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, config, isConfigInitialized, settings, onDebugMessage, handleSlashCommand, shellModeActive, getPreferredEditor, onAuthError, performMemoryRefresh, modelSwitchedFromQuotaError, setModelSwitchedFromQuotaError, onEditorClose, onCancelSubmit, setShellInputFocused, terminalWidth, terminalHeight, midTurnDrainRef, logger, availableTerminalHeightRef, terminalWidthRef, midTurnRestoreRef, goalQueueRef) => {
36339
36605
  const [initError, setInitError] = (0, import_react135.useState)(null);
36340
36606
  const abortControllerRef = (0, import_react135.useRef)(null);
36607
+ const activeGoalTurnRef = (0, import_react135.useRef)(null);
36608
+ const activeGoalAdmissionRef = (0, import_react135.useRef)(null);
36609
+ const goalTurnBindingsRef = (0, import_react135.useRef)(/* @__PURE__ */ new Map());
36610
+ const bindGoalTurn = (0, import_react135.useCallback)(
36611
+ (permit, turnKey, origin, controller = new AbortController()) => {
36612
+ const existing = goalTurnBindingsRef.current.get(permit.turnId);
36613
+ if (existing && existing.turnKey === turnKey && sameGoalPermit(existing.permit, permit) && !existing.controller.signal.aborted) {
36614
+ activeGoalTurnRef.current = existing;
36615
+ activeGoalAdmissionRef.current = existing;
36616
+ return existing;
36617
+ }
36618
+ const binding = {
36619
+ permit: { ...permit },
36620
+ turnKey,
36621
+ controller,
36622
+ origin
36623
+ };
36624
+ goalTurnBindingsRef.current.set(permit.turnId, binding);
36625
+ activeGoalTurnRef.current = binding;
36626
+ activeGoalAdmissionRef.current = binding;
36627
+ return binding;
36628
+ },
36629
+ []
36630
+ );
36631
+ const releaseGoalTurn = (0, import_react135.useCallback)((binding) => {
36632
+ if (goalTurnBindingsRef.current.get(binding.permit.turnId) === binding) {
36633
+ goalTurnBindingsRef.current.delete(binding.permit.turnId);
36634
+ }
36635
+ if (activeGoalTurnRef.current === binding) {
36636
+ activeGoalTurnRef.current = null;
36637
+ }
36638
+ if (activeGoalAdmissionRef.current?.controller === binding.controller && activeGoalAdmissionRef.current.turnKey === binding.turnKey) {
36639
+ activeGoalAdmissionRef.current = null;
36640
+ }
36641
+ }, []);
36642
+ const failClosedGoalTurn = (0, import_react135.useCallback)(
36643
+ async (binding, reason) => {
36644
+ if (!binding.controller.signal.aborted) {
36645
+ binding.controller.abort(reason);
36646
+ }
36647
+ try {
36648
+ const runtime = await config.getGoalRuntimeReady();
36649
+ const admittedPermit = runtime.permitForTurn(binding.turnKey);
36650
+ if (!admittedPermit || !sameGoalPermit(admittedPermit, binding.permit)) {
36651
+ return;
36652
+ }
36653
+ if (runtime.getSnapshot().goal?.status === "active") {
36654
+ try {
36655
+ await runtime.dispatch({
36656
+ action: "pause",
36657
+ expectedGoalId: binding.permit.goalId,
36658
+ expectedRevision: binding.permit.revision
36659
+ });
36660
+ } catch (error) {
36661
+ debugLogger36.warn("Failed to pause invalid Goal tool batch", error);
36662
+ }
36663
+ }
36664
+ try {
36665
+ await config.getChatRecordingService()?.flush();
36666
+ } catch (error) {
36667
+ debugLogger36.warn("Failed to flush invalid Goal tool batch", error);
36668
+ }
36669
+ const currentPermit = runtime.permitForTurn(binding.turnKey);
36670
+ if (currentPermit && sameGoalPermit(currentPermit, binding.permit)) {
36671
+ await runtime.finishTurn(binding.permit);
36672
+ }
36673
+ } catch (error) {
36674
+ debugLogger36.warn("Failed to close invalid Goal tool batch", error);
36675
+ } finally {
36676
+ releaseGoalTurn(binding);
36677
+ }
36678
+ },
36679
+ [config, releaseGoalTurn]
36680
+ );
36681
+ const releaseUndeliveredGoalTurn = (0, import_react135.useCallback)(
36682
+ async (turnKey) => {
36683
+ if (!turnKey) return;
36684
+ try {
36685
+ const runtime = await config.getGoalRuntimeReady();
36686
+ await runtime.releaseTurn(turnKey);
36687
+ } catch (error) {
36688
+ debugLogger36.warn(
36689
+ `Failed to release undelivered Goal turn ${turnKey}`,
36690
+ error
36691
+ );
36692
+ }
36693
+ },
36694
+ [config]
36695
+ );
36341
36696
  const flushBufferedStreamEventsRef = (0, import_react135.useRef)(/* @__PURE__ */ new Set());
36342
36697
  const turnCancelledRef = (0, import_react135.useRef)(false);
36343
36698
  const isSubmittingQueryRef = (0, import_react135.useRef)(false);
36699
+ const submissionLeaseGenerationRef = (0, import_react135.useRef)(0);
36700
+ const setSubmissionInFlight = (0, import_react135.useCallback)(
36701
+ (inFlight) => {
36702
+ const changed = isSubmittingQueryRef.current !== inFlight;
36703
+ isSubmittingQueryRef.current = inFlight;
36704
+ const sharedRef = goalQueueRef?.current?.submissionInFlightRef;
36705
+ if (sharedRef) sharedRef.current = inFlight;
36706
+ if (changed && !inFlight) {
36707
+ goalQueueRef?.current?.onSubmissionSettled?.();
36708
+ }
36709
+ },
36710
+ [goalQueueRef]
36711
+ );
36344
36712
  const lastPromptRef = (0, import_react135.useRef)(null);
36345
36713
  const lastTurnUserItemRef = (0, import_react135.useRef)(null);
36346
36714
  const canUndoLastLoggedUserMessageRef = (0, import_react135.useRef)(false);
36347
36715
  const turnSawContentEventRef = (0, import_react135.useRef)(false);
36348
36716
  const lastPromptErroredRef = (0, import_react135.useRef)(false);
36717
+ const goalTerminalErrorRef = (0, import_react135.useRef)(false);
36349
36718
  const commitItem = (0, import_react135.useCallback)(
36350
36719
  (item, userMessageTimestamp) => {
36351
36720
  if (item.type === "gemini" && !item.timestamp) {
@@ -36562,7 +36931,8 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
36562
36931
  }
36563
36932
  const pendingItemAtCancel = pendingHistoryItemRef.current;
36564
36933
  turnCancelledRef.current = true;
36565
- isSubmittingQueryRef.current = false;
36934
+ submissionLeaseGenerationRef.current += 1;
36935
+ setSubmissionInFlight(false);
36566
36936
  abortControllerRef.current?.abort();
36567
36937
  const loopWakeupsCancelled = config.getCronScheduler()?.cancelAllWakeups() ?? 0;
36568
36938
  for (const ac of auxiliaryAbortRefsRef.current) {
@@ -36604,7 +36974,8 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
36604
36974
  pendingItem: pendingItemAtCancel,
36605
36975
  lastTurnUserItem: lastTurnUserItemRef.current,
36606
36976
  canUndoLastLoggedUserMessage: canUndoLastLoggedUserMessageRef.current,
36607
- turnProducedMeaningfulContent: turnSawContentEventRef.current
36977
+ turnProducedMeaningfulContent: turnSawContentEventRef.current,
36978
+ wasGoalTurn: activeGoalTurnRef.current !== null
36608
36979
  });
36609
36980
  } finally {
36610
36981
  setIsResponding(false);
@@ -36620,7 +36991,8 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
36620
36991
  setShellInputFocused,
36621
36992
  clearRetryCountdown,
36622
36993
  config,
36623
- getPromptCount
36994
+ getPromptCount,
36995
+ setSubmissionInFlight
36624
36996
  ]);
36625
36997
  const applyVisionBridgeIfNeeded = (0, import_react135.useCallback)(
36626
36998
  async (parts, timestamp, signal) => {
@@ -37115,8 +37487,12 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37115
37487
  ]
37116
37488
  );
37117
37489
  const handleErrorEvent = (0, import_react135.useCallback)(
37118
- (eventValue, userMessageTimestamp) => {
37119
- lastPromptErroredRef.current = true;
37490
+ (eventValue, userMessageTimestamp, submitType) => {
37491
+ if (submitType !== "goal" /* Goal */) {
37492
+ lastPromptErroredRef.current = true;
37493
+ } else {
37494
+ goalTerminalErrorRef.current = true;
37495
+ }
37120
37496
  commitPendingThought(userMessageTimestamp);
37121
37497
  if (pendingHistoryItemRef.current) {
37122
37498
  commitItem(pendingHistoryItemRef.current, userMessageTimestamp);
@@ -37129,7 +37505,7 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37129
37505
  config.getContentGeneratorConfig()?.authType
37130
37506
  );
37131
37507
  if (!isShowingAutoRetry) {
37132
- const retryHint = t("Press Ctrl+Y to retry");
37508
+ const retryHint = submitType !== "goal" /* Goal */ ? t("Press Ctrl+Y to retry") : void 0;
37133
37509
  setPendingRetryErrorItem({
37134
37510
  type: "error",
37135
37511
  text: formattedErrorText,
@@ -37227,10 +37603,12 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37227
37603
  }
37228
37604
  const activeModel = modelOverrideRef.current ?? config.getModel();
37229
37605
  const reasonClause = eventValue?.triggerReason === "image_overflow" ? `accumulated enough tool screenshots to trigger compaction for ${activeModel}` : `approached the input token limit for ${activeModel}`;
37606
+ const warningSuffix = eventValue?.warning ? `
37607
+ \u26A0\uFE0F ${eventValue.warning}` : "";
37230
37608
  return addItem(
37231
37609
  {
37232
37610
  type: "info",
37233
- text: `IMPORTANT: This conversation ${reasonClause}. A compressed context will be sent for future messages (compressed from: ${eventValue?.originalTokenCount ?? "unknown"} to ${eventValue?.newTokenCount ?? "unknown"} tokens).`
37611
+ text: `IMPORTANT: This conversation ${reasonClause}. A compressed context will be sent for future messages (compressed from: ${eventValue?.originalTokenCount ?? "unknown"} to ${eventValue?.newTokenCount ?? "unknown"} tokens).` + warningSuffix
37234
37612
  },
37235
37613
  Date.now()
37236
37614
  );
@@ -37314,22 +37692,6 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37314
37692
  commitItem(pendingHistoryItemRef.current, userMessageTimestamp);
37315
37693
  setPendingHistoryItem(null);
37316
37694
  }
37317
- const activeGoal = getActiveGoal(config.getSessionId());
37318
- if (activeGoal && activeGoal.condition) {
37319
- const item = {
37320
- type: "goal_status" /* GOAL_STATUS */,
37321
- kind: "checking",
37322
- condition: activeGoal.condition,
37323
- iterations: activeGoal.iterations,
37324
- // Carried so a transcript truncated past its `set` card can still
37325
- // restore the goal's original start time.
37326
- setAt: activeGoal.setAt,
37327
- lastReason: activeGoal.lastReason ?? value.reasons[value.reasons.length - 1]
37328
- };
37329
- addItem(item, userMessageTimestamp);
37330
- recordGoalStatusItem(config, item);
37331
- return;
37332
- }
37333
37695
  addItem(
37334
37696
  {
37335
37697
  type: "stop_hook_loop",
@@ -37340,30 +37702,13 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37340
37702
  userMessageTimestamp
37341
37703
  );
37342
37704
  },
37343
- [addItem, commitItem, config, pendingHistoryItemRef, setPendingHistoryItem]
37344
- );
37345
- const handleActiveGoalEvent = (0, import_react135.useCallback)(
37346
- (activeGoal) => {
37347
- const sessionId = config.getSessionId();
37348
- const currentActiveGoal = getActiveGoal(sessionId);
37349
- if (activeGoal) {
37350
- if (activeGoalEquals(currentActiveGoal, activeGoal)) {
37351
- return;
37352
- }
37353
- setActiveGoal(sessionId, activeGoal);
37354
- return;
37355
- }
37356
- if (!currentActiveGoal) {
37357
- return;
37358
- }
37359
- clearActiveGoal(sessionId);
37360
- },
37361
- [config]
37705
+ [addItem, commitItem, pendingHistoryItemRef, setPendingHistoryItem]
37362
37706
  );
37363
37707
  const processGeminiStreamEvents = (0, import_react135.useCallback)(
37364
- async (stream, userMessageTimestamp, signal) => {
37708
+ async (stream, userMessageTimestamp, signal, submitType, turnAdmission) => {
37365
37709
  let geminiMessageBuffer = "";
37366
37710
  let thoughtBuffer = "";
37711
+ let scheduledToolContinuation = false;
37367
37712
  const toolCallRequests = [];
37368
37713
  const bufferedEvents = [];
37369
37714
  let flushTimer = null;
@@ -37463,6 +37808,14 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37463
37808
  commitPendingThought(userMessageTimestamp);
37464
37809
  thoughtBuffer = "";
37465
37810
  setThought((prev) => prev ? null : prev);
37811
+ if (event.value.goalContext && turnAdmission) {
37812
+ bindGoalTurn(
37813
+ event.value.goalContext,
37814
+ turnAdmission.turnKey,
37815
+ turnAdmission.origin,
37816
+ turnAdmission.controller
37817
+ );
37818
+ }
37466
37819
  toolCallRequests.push(event.value);
37467
37820
  try {
37468
37821
  const argsJson = JSON.stringify(event.value.args);
@@ -37474,10 +37827,13 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37474
37827
  flushBufferedStreamEvents();
37475
37828
  toolCallRequests.length = 0;
37476
37829
  handleUserCancelledEvent(userMessageTimestamp);
37477
- return 1 /* UserCancelled */;
37830
+ return {
37831
+ status: 1 /* UserCancelled */,
37832
+ scheduledToolContinuation: false
37833
+ };
37478
37834
  case "error" /* Error */:
37479
37835
  flushBufferedStreamEvents();
37480
- handleErrorEvent(event.value, userMessageTimestamp);
37836
+ handleErrorEvent(event.value, userMessageTimestamp, submitType);
37481
37837
  break;
37482
37838
  case "chat_compressed" /* ChatCompressed */:
37483
37839
  flushBufferedStreamEvents();
@@ -37586,9 +37942,26 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37586
37942
  handleStopHookLoopEvent(event.value, userMessageTimestamp);
37587
37943
  break;
37588
37944
  case "active_goal" /* ActiveGoal */:
37589
- handleActiveGoalEvent(event.value);
37590
37945
  break;
37591
37946
  case "goal_state" /* GoalState */:
37947
+ if (event.cause && shouldDisplayGoalStateCause(event.cause)) {
37948
+ flushBufferedStreamEvents();
37949
+ if (pendingHistoryItemRef.current) {
37950
+ commitItem(
37951
+ pendingHistoryItemRef.current,
37952
+ userMessageTimestamp
37953
+ );
37954
+ setPendingHistoryItem(null);
37955
+ }
37956
+ addItem(
37957
+ {
37958
+ type: "goal_state",
37959
+ snapshot: event.value,
37960
+ cause: event.cause
37961
+ },
37962
+ userMessageTimestamp
37963
+ );
37964
+ }
37592
37965
  break;
37593
37966
  default: {
37594
37967
  const unreachable = event;
@@ -37623,7 +37996,10 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37623
37996
  `[processGeminiStreamEvents] Dropping batch after repeated duplicate provider tool-call id: ${repeatedDuplicateRequest.providerCallId} (tool: ${repeatedDuplicateRequest.name})`
37624
37997
  );
37625
37998
  loopDetectedRef.current = true;
37626
- return 0 /* Completed */;
37999
+ return {
38000
+ status: 0 /* Completed */,
38001
+ scheduledToolContinuation: false
38002
+ };
37627
38003
  }
37628
38004
  for (const request of toolCallRequests) {
37629
38005
  const providerCallId = request.providerCallId;
@@ -37666,6 +38042,7 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37666
38042
  }
37667
38043
  }
37668
38044
  if (executableToolCallRequests.length > 0) {
38045
+ scheduledToolContinuation = true;
37669
38046
  scheduleToolCalls(
37670
38047
  executableToolCallRequests,
37671
38048
  signal,
@@ -37673,7 +38050,10 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37673
38050
  );
37674
38051
  }
37675
38052
  }
37676
- return 0 /* Completed */;
38053
+ return {
38054
+ status: 0 /* Completed */,
38055
+ scheduledToolContinuation
38056
+ };
37677
38057
  },
37678
38058
  [
37679
38059
  handleContentEvent,
@@ -37696,7 +38076,7 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37696
38076
  setPendingHistoryItem,
37697
38077
  handleUserPromptSubmitBlockedEvent,
37698
38078
  handleStopHookLoopEvent,
37699
- handleActiveGoalEvent,
38079
+ bindGoalTurn,
37700
38080
  addItem,
37701
38081
  commitItem,
37702
38082
  dualOutput
@@ -37707,7 +38087,6 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37707
38087
  const resolvedSegments = [];
37708
38088
  const resolvedForRecording = [];
37709
38089
  const restoreMessages = [];
37710
- let pendingGoalSegmentIndex;
37711
38090
  const timestamp = Date.now();
37712
38091
  for (let index = 0; index < messages.length; index += 1) {
37713
38092
  if (signal.aborted) {
@@ -37716,21 +38095,7 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37716
38095
  }
37717
38096
  const message = messages[index];
37718
38097
  if (GOAL_COMMAND_RE.test(message)) {
37719
- const activeGoalBeforeCommand = getActiveGoal(config.getSessionId());
37720
- const result = await handleSlashCommand(message);
37721
- const activeGoalAfterCommand = getActiveGoal(config.getSessionId());
37722
- if (result && result.type === "submit_prompt") {
37723
- if (pendingGoalSegmentIndex !== void 0) {
37724
- resolvedSegments[pendingGoalSegmentIndex] = [];
37725
- }
37726
- pendingGoalSegmentIndex = resolvedSegments.length;
37727
- resolvedSegments.push(normalizePartList(result.content));
37728
- } else if (activeGoalBeforeCommand?.hookId !== activeGoalAfterCommand?.hookId) {
37729
- if (pendingGoalSegmentIndex !== void 0) {
37730
- resolvedSegments[pendingGoalSegmentIndex] = [];
37731
- pendingGoalSegmentIndex = void 0;
37732
- }
37733
- }
38098
+ await handleSlashCommand(message);
37734
38099
  continue;
37735
38100
  }
37736
38101
  restoreMessages.push(message);
@@ -37849,7 +38214,13 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37849
38214
  accept: /* @__PURE__ */ __name(() => {
37850
38215
  for (const { message, parts, sideEffects } of resolvedForRecording) {
37851
38216
  for (const sideEffect of sideEffects) sideEffect();
37852
- config.getChatRecordingService?.()?.recordMidTurnUserMessage(parts, message);
38217
+ const recorder = config.getChatRecordingService?.();
38218
+ const goalPermit = activeGoalTurnRef.current?.permit;
38219
+ if (goalPermit) {
38220
+ recorder?.recordMidTurnUserMessage(parts, message, goalPermit);
38221
+ } else {
38222
+ recorder?.recordMidTurnUserMessage(parts, message);
38223
+ }
37853
38224
  addItem(
37854
38225
  {
37855
38226
  type: "user" /* USER */,
@@ -37910,7 +38281,10 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37910
38281
  );
37911
38282
  const drainSteerAtBoundary = (0, import_react135.useCallback)(
37912
38283
  async (signal) => {
37913
- const messages = midTurnDrainRef?.current?.() ?? [];
38284
+ const messages = midTurnDrainRef?.current?.(
38285
+ false,
38286
+ Boolean(activeGoalAdmissionRef.current)
38287
+ ) ?? [];
37914
38288
  if (messages.length === 0) return void 0;
37915
38289
  return resolveDrainedSteerMessages(messages, signal);
37916
38290
  },
@@ -37918,18 +38292,39 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37918
38292
  );
37919
38293
  const submitQuery = (0, import_react135.useCallback)(
37920
38294
  async (query, submitType = "userQuery" /* UserQuery */, prompt_id, metadata) => {
37921
- const allowConcurrentBtwDuringResponse = submitType === "userQuery" /* UserQuery */ && streamingState === "responding" /* Responding */ && typeof query === "string" && isBtwCommand(query);
38295
+ const allowConcurrentBtwDuringResponse = submitType === "userQuery" /* UserQuery */ && streamingState === "responding" /* Responding */ && typeof query === "string" && isBtwCommand(query) && !activeGoalAdmissionRef.current;
38296
+ let ownsSubmissionLease = false;
38297
+ let submissionLeaseGeneration;
38298
+ const acquireSubmissionLease = /* @__PURE__ */ __name(() => {
38299
+ if (isSubmittingQueryRef.current) return;
38300
+ ownsSubmissionLease = true;
38301
+ submissionLeaseGeneration = submissionLeaseGenerationRef.current + 1;
38302
+ submissionLeaseGenerationRef.current = submissionLeaseGeneration;
38303
+ setSubmissionInFlight(true);
38304
+ }, "acquireSubmissionLease");
38305
+ const releaseSubmissionLease = /* @__PURE__ */ __name(() => {
38306
+ if (!ownsSubmissionLease) return;
38307
+ ownsSubmissionLease = false;
38308
+ if (submissionLeaseGeneration !== submissionLeaseGenerationRef.current) {
38309
+ return;
38310
+ }
38311
+ setSubmissionInFlight(false);
38312
+ }, "releaseSubmissionLease");
37922
38313
  const isTurnContinuation = submitType === "toolResult" /* ToolResult */ || submitType === "steer" /* Steer */;
37923
38314
  const submittedPrompt = submitType === "userQuery" /* UserQuery */ ? metadata?.submittedPrompt : void 0;
37924
38315
  if (isSubmittingQueryRef.current && !isTurnContinuation && !allowConcurrentBtwDuringResponse) {
38316
+ await releaseUndeliveredGoalTurn(metadata?.userAdmission?.turnKey);
38317
+ metadata?.onAdmissionFailed?.();
37925
38318
  metadata?.onDeliveryFailed?.();
37926
38319
  return;
37927
38320
  }
37928
38321
  if ((streamingState === "responding" /* Responding */ || streamingState === "waiting_for_confirmation" /* WaitingForConfirmation */) && !isTurnContinuation && !allowConcurrentBtwDuringResponse) {
38322
+ await releaseUndeliveredGoalTurn(metadata?.userAdmission?.turnKey);
38323
+ metadata?.onAdmissionFailed?.();
37929
38324
  metadata?.onDeliveryFailed?.();
37930
38325
  return;
37931
38326
  }
37932
- isSubmittingQueryRef.current = true;
38327
+ acquireSubmissionLease();
37933
38328
  loopDetectedRef.current = false;
37934
38329
  if (!isTurnContinuation && !allowConcurrentBtwDuringResponse) {
37935
38330
  lastTurnUserItemRef.current = null;
@@ -37941,7 +38336,7 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37941
38336
  immediateDuplicateToolResponsesRef.current = null;
37942
38337
  }
37943
38338
  const userMessageTimestamp = Date.now();
37944
- if (!isTurnContinuation && submitType !== "notification" /* Notification */ && !allowConcurrentBtwDuringResponse) {
38339
+ if (!isTurnContinuation && submitType !== "notification" /* Notification */ && submitType !== "goal" /* Goal */ && !allowConcurrentBtwDuringResponse) {
37945
38340
  setModelSwitchedFromQuotaError(false);
37946
38341
  const droppingInlineOverrideOnRetry = submitType === "retry" /* Retry */ && inlineModelOverrideActiveRef.current;
37947
38342
  if (submitType !== "retry" /* Retry */ || inlineModelOverrideActiveRef.current) {
@@ -37975,20 +38370,87 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
37975
38370
  prompt_id = config.getSessionId() + "########" + getPromptCount();
37976
38371
  }
37977
38372
  return promptIdContext.run(prompt_id, async () => {
37978
- const { queryToSend, shouldProceed } = submitType === "retry" /* Retry */ ? { queryToSend: query, shouldProceed: true } : await prepareQueryForGemini(
37979
- query,
37980
- userMessageTimestamp,
37981
- abortSignal,
37982
- prompt_id,
37983
- submitType,
37984
- submittedPrompt,
37985
- allowConcurrentBtwDuringResponse
37986
- );
38373
+ let queuedGoal = metadata?.goal;
38374
+ let preparedQuery;
38375
+ try {
38376
+ preparedQuery = submitType === "goal" /* Goal */ ? queuedGoal ? {
38377
+ queryToSend: [
38378
+ "Continue working on the active Goal.",
38379
+ "Use get_goal for the authoritative objective and evidence state.",
38380
+ "Follow the objective's requested output format exactly. Do not add progress, status, or completion commentary unless the objective asks for it.",
38381
+ "If completion depends on content delivered in this turn, deliver only that content and call get_goal in the same response before update_goal.",
38382
+ "This is a synthetic continuation turn. It contains no new real user input and cannot satisfy an objective condition that requires the user to send, confirm, choose, approve, or provide something.",
38383
+ "A phrase mentioned in the objective or this prompt is not evidence that the user supplied it.",
38384
+ ...queuedGoal.verifierFeedback ? [`Verifier feedback: ${queuedGoal.verifierFeedback}`] : []
38385
+ ].join("\n"),
38386
+ shouldProceed: true
38387
+ } : { queryToSend: null, shouldProceed: false } : submitType === "retry" /* Retry */ ? { queryToSend: query, shouldProceed: true } : await prepareQueryForGemini(
38388
+ query,
38389
+ userMessageTimestamp,
38390
+ abortSignal,
38391
+ prompt_id,
38392
+ submitType,
38393
+ submittedPrompt,
38394
+ allowConcurrentBtwDuringResponse
38395
+ );
38396
+ } catch (error) {
38397
+ await releaseUndeliveredGoalTurn(metadata?.userAdmission?.turnKey);
38398
+ releaseSubmissionLease();
38399
+ metadata?.onAdmissionFailed?.();
38400
+ throw error;
38401
+ }
38402
+ const { queryToSend, shouldProceed } = preparedQuery;
37987
38403
  if (!shouldProceed || queryToSend === null) {
37988
- isSubmittingQueryRef.current = false;
38404
+ await releaseUndeliveredGoalTurn(metadata?.userAdmission?.turnKey);
38405
+ releaseSubmissionLease();
37989
38406
  metadata?.onDeliveryFailed?.();
37990
38407
  return;
37991
38408
  }
38409
+ await goalQueueRef?.current?.waitForReservationSettlement?.();
38410
+ if (!queuedGoal && metadata?.claimGoalTurn) {
38411
+ queuedGoal = metadata.claimGoalTurn();
38412
+ if (!queuedGoal) {
38413
+ releaseSubmissionLease();
38414
+ metadata.onGoalClaimDeferred?.();
38415
+ return;
38416
+ }
38417
+ }
38418
+ let userAdmission;
38419
+ if (submitType === "userQuery" /* UserQuery */) {
38420
+ if (metadata?.userAdmission) {
38421
+ const goal2 = metadata.userAdmission.goal ?? goalQueueRef?.current?.claimGoalTurn?.();
38422
+ userAdmission = {
38423
+ turnKey: metadata.userAdmission.turnKey,
38424
+ ...goal2 ? { goal: goal2 } : {}
38425
+ };
38426
+ } else {
38427
+ userAdmission = goalQueueRef?.current?.claimDirectUserAdmission?.() ?? {
38428
+ turnKey: prompt_id
38429
+ };
38430
+ }
38431
+ }
38432
+ const goal = queuedGoal ?? userAdmission?.goal;
38433
+ let goalBinding = metadata?.goalBinding ?? (goal ? bindGoalTurn(
38434
+ goal.permit,
38435
+ goal.turnKey,
38436
+ submitType === "userQuery" /* UserQuery */ ? "user" : "runtime"
38437
+ ) : void 0);
38438
+ const turnKey = goalBinding?.turnKey ?? userAdmission?.turnKey;
38439
+ const turnController = goalBinding?.controller ?? (turnKey ? new AbortController() : void 0);
38440
+ const processingSignal = turnController ? AbortSignal.any([abortSignal, turnController.signal]) : abortSignal;
38441
+ const turnAdmission = turnKey && turnController ? {
38442
+ turnKey,
38443
+ controller: turnController,
38444
+ origin: goalBinding?.origin ?? "user"
38445
+ } : void 0;
38446
+ if (turnAdmission && !goalBinding && submitType === "userQuery" /* UserQuery */ && !allowConcurrentBtwDuringResponse && !activeGoalAdmissionRef.current) {
38447
+ try {
38448
+ if (config.getGoalRuntime().getSnapshot().goal?.status === "active") {
38449
+ activeGoalAdmissionRef.current = turnAdmission;
38450
+ }
38451
+ } catch {
38452
+ }
38453
+ }
37992
38454
  if (submitType === "userQuery" /* UserQuery */ || submitType === "cron" /* Cron */ || submitType === "teammate" /* Teammate */) {
37993
38455
  const formatCheck = checkImageFormatsSupport(queryToSend);
37994
38456
  if (formatCheck.hasUnsupportedFormats) {
@@ -38002,8 +38464,11 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38002
38464
  }
38003
38465
  }
38004
38466
  const finalQueryToSend = queryToSend;
38005
- lastPromptRef.current = finalQueryToSend;
38006
- lastPromptErroredRef.current = false;
38467
+ goalTerminalErrorRef.current = false;
38468
+ if (submitType !== "goal" /* Goal */) {
38469
+ lastPromptRef.current = finalQueryToSend;
38470
+ lastPromptErroredRef.current = false;
38471
+ }
38007
38472
  if (submitType === "userQuery" /* UserQuery */ || submitType === "cron" /* Cron */ || submitType === "teammate" /* Teammate */) {
38008
38473
  startNewPrompt();
38009
38474
  if (typeof queryToSend === "string") {
@@ -38032,8 +38497,9 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38032
38497
  streamingResponseLengthRef.current = 0;
38033
38498
  }
38034
38499
  let cleanupReviewLease = false;
38500
+ let keepGoalBinding = false;
38035
38501
  try {
38036
- if (dualOutput && submitType !== "toolResult" /* ToolResult */) {
38502
+ if (dualOutput && submitType !== "toolResult" /* ToolResult */ && submitType !== "goal" /* Goal */) {
38037
38503
  const rawParts = typeof finalQueryToSend === "string" ? [finalQueryToSend] : Array.isArray(finalQueryToSend) ? finalQueryToSend : [finalQueryToSend];
38038
38504
  const userParts = rawParts.map(
38039
38505
  (p) => typeof p === "string" ? { text: p } : p
@@ -38053,17 +38519,36 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38053
38519
  finalQueryToSend,
38054
38520
  abortSignal,
38055
38521
  prompt_id,
38056
- sendOptions
38522
+ {
38523
+ ...sendOptions,
38524
+ ...goalBinding ? {
38525
+ goalPermit: goalBinding.permit,
38526
+ goalTurnKey: goalBinding.turnKey,
38527
+ goalSignal: goalBinding.controller.signal,
38528
+ goalOrigin: goalBinding.origin,
38529
+ getQueuedGoalTurnKey: /* @__PURE__ */ __name(() => goalQueueRef?.current?.peekNextUserBatchKey(true), "getQueuedGoalTurnKey")
38530
+ } : userAdmission ? {
38531
+ goalTurnKey: userAdmission.turnKey,
38532
+ goalSignal: turnController.signal,
38533
+ goalOrigin: "user",
38534
+ getQueuedGoalTurnKey: /* @__PURE__ */ __name(() => goalQueueRef?.current?.peekNextUserBatchKey(true), "getQueuedGoalTurnKey")
38535
+ } : {}
38536
+ }
38057
38537
  );
38058
- const processingStatus = await processGeminiStreamEvents(
38538
+ const processingResult = await processGeminiStreamEvents(
38059
38539
  stream,
38060
38540
  userMessageTimestamp,
38061
- abortSignal
38541
+ processingSignal,
38542
+ submitType,
38543
+ turnAdmission
38062
38544
  );
38063
- if (processingStatus === 1 /* UserCancelled */) {
38545
+ if (!goalBinding && turnAdmission && activeGoalTurnRef.current?.controller === turnAdmission.controller && activeGoalTurnRef.current.turnKey === turnAdmission.turnKey) {
38546
+ goalBinding = activeGoalTurnRef.current;
38547
+ }
38548
+ keepGoalBinding = processingResult.scheduledToolContinuation;
38549
+ if (processingResult.status === 1 /* UserCancelled */) {
38064
38550
  cleanupReviewLease = true;
38065
38551
  submitPromptOnCompleteRef.current = null;
38066
- isSubmittingQueryRef.current = false;
38067
38552
  metadata?.onDeliveryFailed?.();
38068
38553
  return;
38069
38554
  }
@@ -38090,24 +38575,36 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38090
38575
  );
38091
38576
  immediateDuplicateToolResponses.responses.forEach(
38092
38577
  ({ request, response }, index) => {
38093
- config.getChatRecordingService?.()?.recordToolResult?.(finalized[index].responseParts, {
38094
- callId: request.callId,
38095
- status: response.error ? "error" : "success",
38096
- resultDisplay: response.resultDisplay,
38097
- error: response.error,
38098
- errorType: response.errorType
38099
- });
38578
+ const goalContext = request.goalContext;
38579
+ config.getChatRecordingService?.()?.recordToolResult?.(
38580
+ finalized[index].responseParts,
38581
+ {
38582
+ callId: request.callId,
38583
+ status: response.error ? "error" : "success",
38584
+ resultDisplay: response.resultDisplay,
38585
+ error: response.error,
38586
+ errorType: response.errorType
38587
+ },
38588
+ goalContext ? request.name === ToolNames.GET_GOAL || request.name === ToolNames.UPDATE_GOAL ? {
38589
+ goalContext: { ...goalContext },
38590
+ provenance: "goal_runtime"
38591
+ } : { goalContext: { ...goalContext } } : void 0
38592
+ );
38100
38593
  }
38101
38594
  );
38102
38595
  await submitQuery(
38103
38596
  responseParts,
38104
38597
  "toolResult" /* ToolResult */,
38105
- immediateDuplicateToolResponses.promptId
38598
+ immediateDuplicateToolResponses.promptId,
38599
+ { goalBinding }
38106
38600
  );
38601
+ if (goalBinding && !turnCancelledRef.current && !abortControllerRef.current?.signal.aborted && goalTurnBindingsRef.current.get(goalBinding.permit.turnId) === goalBinding && !goalBinding.controller.signal.aborted) {
38602
+ keepGoalBinding = true;
38603
+ }
38107
38604
  }
38108
38605
  if (retryCountdownTimerRef.current) {
38109
38606
  clearRetryCountdown();
38110
- } else if (pendingRetryErrorItemRef.current && !lastPromptErroredRef.current) {
38607
+ } else if (pendingRetryErrorItemRef.current && !lastPromptErroredRef.current && !goalTerminalErrorRef.current) {
38111
38608
  clearRetryCountdown();
38112
38609
  }
38113
38610
  const loopDetected = loopDetectedRef.current;
@@ -38116,7 +38613,7 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38116
38613
  loopDetectedRef.current = false;
38117
38614
  handleLoopDetectedEvent();
38118
38615
  }
38119
- if (lastPromptErroredRef.current) {
38616
+ if (lastPromptErroredRef.current || goalTerminalErrorRef.current) {
38120
38617
  metadata?.onDeliveryFailed?.();
38121
38618
  } else {
38122
38619
  metadata?.onDelivered?.();
@@ -38151,8 +38648,10 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38151
38648
  if (error instanceof UnauthorizedError) {
38152
38649
  onAuthError("Session expired or is unauthorized.");
38153
38650
  } else if (!isNodeError(error) || error.name !== "AbortError") {
38154
- lastPromptErroredRef.current = true;
38155
- const retryHint = t("Press Ctrl+Y to retry");
38651
+ if (submitType !== "goal" /* Goal */) {
38652
+ lastPromptErroredRef.current = true;
38653
+ }
38654
+ const retryHint = submitType !== "goal" /* Goal */ ? t("Press Ctrl+Y to retry") : void 0;
38156
38655
  setPendingRetryErrorItem({
38157
38656
  type: "error",
38158
38657
  text: parseAndFormatApiError(
@@ -38178,7 +38677,26 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38178
38677
  if (activeModelStreamsRef.current === 0) {
38179
38678
  setIsResponding(false);
38180
38679
  }
38181
- isSubmittingQueryRef.current = false;
38680
+ if (goalBinding) {
38681
+ let retainGoalBinding = keepGoalBinding && !goalBinding.controller.signal.aborted;
38682
+ if (retainGoalBinding) {
38683
+ try {
38684
+ const currentPermit = config.getGoalRuntime().permitForTurn(goalBinding.turnKey);
38685
+ retainGoalBinding = currentPermit !== void 0 && sameGoalPermit(currentPermit, goalBinding.permit);
38686
+ } catch {
38687
+ }
38688
+ }
38689
+ if (!retainGoalBinding) {
38690
+ await failClosedGoalTurn(
38691
+ goalBinding,
38692
+ "Goal turn ended without a valid continuation"
38693
+ );
38694
+ }
38695
+ }
38696
+ if (turnAdmission && !goalBinding && activeGoalAdmissionRef.current?.controller === turnAdmission.controller && activeGoalAdmissionRef.current.turnKey === turnAdmission.turnKey) {
38697
+ activeGoalAdmissionRef.current = null;
38698
+ }
38699
+ releaseSubmissionLease();
38182
38700
  }
38183
38701
  });
38184
38702
  },
@@ -38205,7 +38723,12 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38205
38723
  setPendingThoughtItem,
38206
38724
  dualOutput,
38207
38725
  drainSteerAtBoundary,
38208
- midTurnDrainRef
38726
+ midTurnDrainRef,
38727
+ goalQueueRef,
38728
+ bindGoalTurn,
38729
+ failClosedGoalTurn,
38730
+ releaseUndeliveredGoalTurn,
38731
+ setSubmissionInFlight
38209
38732
  ]
38210
38733
  );
38211
38734
  const retryLastPrompt = (0, import_react135.useCallback)(async () => {
@@ -38232,6 +38755,11 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38232
38755
  clearRetryCountdown();
38233
38756
  await submitQuery(lastPrompt, "retry" /* Retry */);
38234
38757
  }, [streamingState, addItem, clearRetryCountdown, submitQuery]);
38758
+ const preemptGoalTurn = (0, import_react135.useCallback)((reason) => {
38759
+ const active = activeGoalAdmissionRef.current;
38760
+ if (!active || active.controller.signal.aborted) return;
38761
+ active.controller.abort(reason);
38762
+ }, []);
38235
38763
  const handleApprovalModeChange = (0, import_react135.useCallback)(
38236
38764
  async (newApprovalMode) => {
38237
38765
  if (newApprovalMode === "yolo" /* YOLO */ || newApprovalMode === "auto-edit" /* AUTO_EDIT */) {
@@ -38313,6 +38841,95 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38313
38841
  const geminiTools = completedAndReadyToSubmitTools.filter(
38314
38842
  (t2) => !t2.request.isClientInitiated && !historyCallIdsWithResponse.has(t2.request.callId)
38315
38843
  );
38844
+ let toolGoalPermit;
38845
+ const toolGoalContexts = geminiTools.map(
38846
+ (toolCall) => toolCall.request.goalContext
38847
+ );
38848
+ try {
38849
+ toolGoalPermit = sharedGoalPermit(toolGoalContexts);
38850
+ } catch (error) {
38851
+ const callIds = geminiTools.map((toolCall) => toolCall.request.callId);
38852
+ markToolsAsSubmitted(callIds);
38853
+ const reason = getErrorMessage(error);
38854
+ const bindings = /* @__PURE__ */ new Map();
38855
+ const active = activeGoalTurnRef.current;
38856
+ if (active) {
38857
+ bindings.set(active.turnKey, active);
38858
+ }
38859
+ for (const permit of toolGoalContexts) {
38860
+ if (!permit) continue;
38861
+ const existing = goalTurnBindingsRef.current.get(permit.turnId);
38862
+ const binding = existing ?? {
38863
+ permit: { ...permit },
38864
+ turnKey: `goal-runtime:${permit.turnId}`,
38865
+ controller: new AbortController(),
38866
+ origin: "runtime"
38867
+ };
38868
+ bindings.set(binding.turnKey, binding);
38869
+ }
38870
+ for (const binding of bindings.values()) {
38871
+ await failClosedGoalTurn(binding, reason);
38872
+ }
38873
+ addItem(
38874
+ {
38875
+ type: "error" /* ERROR */,
38876
+ text: reason
38877
+ },
38878
+ Date.now()
38879
+ );
38880
+ return;
38881
+ }
38882
+ if (!toolGoalPermit && toolGoalContexts.length > 0) {
38883
+ const active = activeGoalTurnRef.current;
38884
+ let activeGoalPermitValid = false;
38885
+ if (active) {
38886
+ try {
38887
+ const runtime = config.getGoalRuntime();
38888
+ const currentPermit = runtime.permitForTurn(active.turnKey);
38889
+ activeGoalPermitValid = currentPermit !== void 0 && sameGoalPermit(currentPermit, active.permit);
38890
+ } catch {
38891
+ }
38892
+ }
38893
+ if (active && activeGoalPermitValid) {
38894
+ markToolsAsSubmitted(
38895
+ geminiTools.map((toolCall) => toolCall.request.callId)
38896
+ );
38897
+ const reason = "ToolResult batch is missing the active Goal context";
38898
+ await failClosedGoalTurn(active, reason);
38899
+ addItem(
38900
+ {
38901
+ type: "error" /* ERROR */,
38902
+ text: reason
38903
+ },
38904
+ Date.now()
38905
+ );
38906
+ return;
38907
+ }
38908
+ }
38909
+ let toolGoalBinding;
38910
+ if (toolGoalPermit) {
38911
+ const existing = goalTurnBindingsRef.current.get(toolGoalPermit.turnId);
38912
+ if (existing && !sameGoalPermit(existing.permit, toolGoalPermit)) {
38913
+ markToolsAsSubmitted(
38914
+ geminiTools.map((toolCall) => toolCall.request.callId)
38915
+ );
38916
+ const reason = "ToolResult batch has a stale Goal context";
38917
+ await failClosedGoalTurn(existing, reason);
38918
+ addItem(
38919
+ {
38920
+ type: "error" /* ERROR */,
38921
+ text: reason
38922
+ },
38923
+ Date.now()
38924
+ );
38925
+ return;
38926
+ }
38927
+ toolGoalBinding = existing ?? bindGoalTurn(
38928
+ toolGoalPermit,
38929
+ `goal-runtime:${toolGoalPermit.turnId}`,
38930
+ "runtime"
38931
+ );
38932
+ }
38316
38933
  const didRefreshManagedMemory = await refreshMemoryAfterManagedWrite(
38317
38934
  config,
38318
38935
  completedAndReadyToSubmitTools.map((toolCall) => ({
@@ -38358,6 +38975,12 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38358
38975
  );
38359
38976
  }
38360
38977
  if (geminiTools.length === 0 && pendingDuplicateResponses.length === 0) {
38978
+ if (toolGoalBinding) {
38979
+ await failClosedGoalTurn(
38980
+ toolGoalBinding,
38981
+ "Goal tool continuation ended without a result"
38982
+ );
38983
+ }
38361
38984
  return;
38362
38985
  }
38363
38986
  const executableQueues = /* @__PURE__ */ new Map();
@@ -38410,18 +39033,32 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38410
39033
  (entry) => entry.responseParts
38411
39034
  );
38412
39035
  orderedResponses.forEach(({ request, response, status }, index) => {
38413
- config.getChatRecordingService?.()?.recordToolResult?.(finalizedResponses[index].responseParts, {
38414
- callId: request.callId,
38415
- status,
38416
- resultDisplay: response.resultDisplay,
38417
- error: response.error,
38418
- errorType: response.errorType
38419
- });
39036
+ const goalContext = request.goalContext;
39037
+ config.getChatRecordingService?.()?.recordToolResult?.(
39038
+ finalizedResponses[index].responseParts,
39039
+ {
39040
+ callId: request.callId,
39041
+ status,
39042
+ resultDisplay: response.resultDisplay,
39043
+ error: response.error,
39044
+ errorType: response.errorType
39045
+ },
39046
+ goalContext ? request.name === ToolNames.GET_GOAL || request.name === ToolNames.UPDATE_GOAL ? {
39047
+ goalContext: { ...goalContext },
39048
+ provenance: "goal_runtime"
39049
+ } : { goalContext: { ...goalContext } } : void 0
39050
+ );
38420
39051
  });
38421
39052
  if (turnCancelledRef.current || abortControllerRef.current?.signal.aborted) {
38422
39053
  markToolsAsSubmitted(
38423
39054
  geminiTools.map((toolCall) => toolCall.request.callId)
38424
39055
  );
39056
+ if (toolGoalBinding) {
39057
+ await failClosedGoalTurn(
39058
+ toolGoalBinding,
39059
+ "Goal tool continuation was cancelled"
39060
+ );
39061
+ }
38425
39062
  return;
38426
39063
  }
38427
39064
  const allToolsCancelled = geminiTools.every(
@@ -38439,6 +39076,12 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38439
39076
  (toolCall) => toolCall.request.callId
38440
39077
  );
38441
39078
  markToolsAsSubmitted(callIdsToMarkAsSubmitted2);
39079
+ if (toolGoalBinding) {
39080
+ await failClosedGoalTurn(
39081
+ toolGoalBinding,
39082
+ "Goal tool continuation was cancelled"
39083
+ );
39084
+ }
38442
39085
  return;
38443
39086
  }
38444
39087
  const callIdsToMarkAsSubmitted = geminiTools.map(
@@ -38472,9 +39115,43 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38472
39115
  }
38473
39116
  }
38474
39117
  markToolsAsSubmitted(callIdsToMarkAsSubmitted);
39118
+ const terminatesGoalTurn = geminiTools.some(
39119
+ (toolCall) => toolCall.response.terminateTurn === true
39120
+ );
39121
+ if (terminatesGoalTurn && toolGoalBinding) {
39122
+ geminiClient.addHistory({ role: "user", parts: responsesToSend });
39123
+ try {
39124
+ await config.getChatRecordingService()?.flush();
39125
+ const runtime = await config.getGoalRuntimeReady();
39126
+ const currentPermit = runtime.permitForTurn(toolGoalBinding.turnKey);
39127
+ if (currentPermit && sameGoalPermit(currentPermit, toolGoalBinding.permit)) {
39128
+ await runtime.finishTurn(toolGoalBinding.permit);
39129
+ const snapshot = runtime.getSnapshot();
39130
+ const status = snapshot.goal?.status;
39131
+ if (status === "complete" || status === "blocked" || status === "usage_limited") {
39132
+ addItem(
39133
+ {
39134
+ type: "goal_state",
39135
+ snapshot,
39136
+ cause: status
39137
+ },
39138
+ Date.now()
39139
+ );
39140
+ }
39141
+ }
39142
+ } catch (error) {
39143
+ await failClosedGoalTurn(
39144
+ toolGoalBinding,
39145
+ `Goal turn could not finish: ${getErrorMessage(error)}`
39146
+ );
39147
+ } finally {
39148
+ releaseGoalTurn(toolGoalBinding);
39149
+ }
39150
+ return;
39151
+ }
38475
39152
  if (config.getEmitToolUseSummaries()) {
38476
39153
  const successfulTools = geminiTools.filter(
38477
- (tc) => tc.status === "success"
39154
+ (tc) => tc.status === "success" && tc.request.name !== ToolNames.GET_GOAL && tc.request.name !== ToolNames.UPDATE_GOAL
38478
39155
  );
38479
39156
  if (successfulTools.length > 0) {
38480
39157
  const toolInfoForSummary = successfulTools.map((tc) => ({
@@ -38521,6 +39198,12 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38521
39198
  }
38522
39199
  }
38523
39200
  if (modelSwitchedFromQuotaError) {
39201
+ if (toolGoalBinding) {
39202
+ await failClosedGoalTurn(
39203
+ toolGoalBinding,
39204
+ "Goal tool continuation stopped after a model switch"
39205
+ );
39206
+ }
38524
39207
  return;
38525
39208
  }
38526
39209
  const backgroundTaskRegistry = config.getBackgroundTaskRegistry();
@@ -38530,9 +39213,18 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38530
39213
  });
38531
39214
  if (backgroundLaunchExhaustedCapacity) {
38532
39215
  geminiClient?.addHistory({ role: "user", parts: responsesToSend });
39216
+ if (toolGoalBinding) {
39217
+ await failClosedGoalTurn(
39218
+ toolGoalBinding,
39219
+ "Goal tool continuation stopped: background capacity exhausted"
39220
+ );
39221
+ }
38533
39222
  return;
38534
39223
  }
38535
- const drained = turnCancelledRef.current || abortControllerRef.current?.signal.aborted ? [] : midTurnDrainRef?.current?.() ?? [];
39224
+ const drained = turnCancelledRef.current || abortControllerRef.current?.signal.aborted ? [] : midTurnDrainRef?.current?.(
39225
+ false,
39226
+ Boolean(activeGoalAdmissionRef.current)
39227
+ ) ?? [];
38536
39228
  let drainedSteer;
38537
39229
  if (drained.length > 0) {
38538
39230
  const midTurnAbort = abortControllerRef.current ?? new AbortController();
@@ -38557,12 +39249,27 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38557
39249
  }
38558
39250
  if (turnCancelledRef.current || abortControllerRef.current?.signal.aborted) {
38559
39251
  drainedSteer?.restore();
39252
+ if (toolGoalBinding) {
39253
+ await failClosedGoalTurn(
39254
+ toolGoalBinding,
39255
+ "Goal tool continuation was cancelled"
39256
+ );
39257
+ }
39258
+ return;
39259
+ }
39260
+ if (toolGoalBinding?.controller.signal.aborted) {
39261
+ drainedSteer?.restore();
39262
+ await failClosedGoalTurn(
39263
+ toolGoalBinding,
39264
+ "Goal tool continuation was preempted"
39265
+ );
38560
39266
  return;
38561
39267
  }
38562
39268
  void submitQuery(responsesToSend, "toolResult" /* ToolResult */, promptId, {
38563
39269
  steerInput: drainedSteer,
38564
39270
  onDelivered: drainedSteer?.accept,
38565
- onDeliveryFailed: drainedSteer?.restore
39271
+ onDeliveryFailed: drainedSteer?.restore,
39272
+ goalBinding: toolGoalBinding
38566
39273
  });
38567
39274
  },
38568
39275
  [
@@ -38575,7 +39282,10 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38575
39282
  midTurnDrainRef,
38576
39283
  addItem,
38577
39284
  dualOutput,
38578
- resolveDrainedSteerMessages
39285
+ resolveDrainedSteerMessages,
39286
+ bindGoalTurn,
39287
+ failClosedGoalTurn,
39288
+ releaseGoalTurn
38579
39289
  ]
38580
39290
  );
38581
39291
  const pendingHistoryItems = (0, import_react135.useMemo)(
@@ -38668,6 +39378,31 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38668
39378
  }, [toolCalls, config, onDebugMessage, history, geminiClient, storage]);
38669
39379
  const notificationQueueRef = (0, import_react135.useRef)([]);
38670
39380
  const [notificationTrigger, setNotificationTrigger] = (0, import_react135.useState)(0);
39381
+ const goalQueuePendingCount = goalQueueRef?.current?.getPendingSubmissionCount?.() ?? 0;
39382
+ const claimSystemGoalTurn = (0, import_react135.useCallback)(() => {
39383
+ if (goalQueueRef?.current?.hasQueuedUserMessages?.()) {
39384
+ return { ready: false };
39385
+ }
39386
+ let goalOwnsTurn = false;
39387
+ try {
39388
+ goalOwnsTurn = goalRequiresExactPermit(
39389
+ config.getGoalRuntime().getSnapshot()
39390
+ );
39391
+ } catch {
39392
+ goalOwnsTurn = false;
39393
+ }
39394
+ if (!goalOwnsTurn) return { ready: true };
39395
+ if ((goalQueueRef?.current?.getPendingSubmissionCount?.() ?? 0) === 0) {
39396
+ return { ready: false };
39397
+ }
39398
+ return {
39399
+ ready: true,
39400
+ claimGoalTurn: /* @__PURE__ */ __name(() => {
39401
+ if (goalQueueRef?.current?.hasQueuedUserMessages?.()) return void 0;
39402
+ return goalQueueRef?.current?.claimGoalTurn?.();
39403
+ }, "claimGoalTurn")
39404
+ };
39405
+ }, [config, goalQueueRef]);
38671
39406
  const getAutonomousLoopTickResolver = (0, import_react135.useCallback)(() => {
38672
39407
  autonomousLoopTickResolverRef.current ??= new AutonomousLoopTickResolver();
38673
39408
  return autonomousLoopTickResolverRef.current;
@@ -38768,6 +39503,21 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38768
39503
  registry.setNotificationCallback(void 0);
38769
39504
  };
38770
39505
  }, [config]);
39506
+ (0, import_react135.useEffect)(() => {
39507
+ const registry = config.getWorkflowRunRegistry();
39508
+ registry.setCompletionCallback((displayText, modelText, meta) => {
39509
+ notificationQueueRef.current.push({
39510
+ displayText,
39511
+ modelText,
39512
+ sendMessageType: "notification" /* Notification */,
39513
+ todoWorkChainId: meta.todoWorkChainId
39514
+ });
39515
+ setNotificationTrigger((n) => n + 1);
39516
+ });
39517
+ return () => {
39518
+ registry.setCompletionCallback(void 0);
39519
+ };
39520
+ }, [config]);
38771
39521
  (0, import_react135.useEffect)(() => {
38772
39522
  const registry = config.getMonitorRegistry();
38773
39523
  registry.setNotificationCallback((displayText, modelText, meta) => {
@@ -38791,6 +39541,8 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38791
39541
  (0, import_react135.useEffect)(() => {
38792
39542
  if (streamingState === "idle" /* Idle */ && !isSubmittingQueryRef.current && notificationQueueRef.current.length > 0) {
38793
39543
  runOutsideAgentContext(() => {
39544
+ const admission = claimSystemGoalTurn();
39545
+ if (!admission.ready) return;
38794
39546
  const queue = notificationQueueRef.current;
38795
39547
  const monitorRegistry = config.getMonitorRegistry();
38796
39548
  for (let i = queue.length - 1; i >= 0; i--) {
@@ -38805,15 +39557,28 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38805
39557
  const targetType = queue[0].sendMessageType;
38806
39558
  if (targetType === "cron" /* Cron */) {
38807
39559
  const item = queue.shift();
38808
- addItem(
38809
- { type: "notification", text: item.displayText },
38810
- Date.now()
38811
- );
38812
- submitQuery(item.modelText, item.sendMessageType, void 0, {
39560
+ if (!item.displayed) {
39561
+ addItem(
39562
+ { type: "notification", text: item.displayText },
39563
+ Date.now()
39564
+ );
39565
+ item.displayed = true;
39566
+ }
39567
+ void submitQuery(item.modelText, item.sendMessageType, void 0, {
38813
39568
  notificationDisplayText: item.displayText,
38814
39569
  todoWorkChainId: item.todoWorkChainId,
38815
39570
  onDelivered: item.onDelivered,
38816
- onDeliveryFailed: item.onDeliveryFailed
39571
+ onDeliveryFailed: item.onDeliveryFailed,
39572
+ onAdmissionFailed: /* @__PURE__ */ __name(() => {
39573
+ queue.unshift(item);
39574
+ }, "onAdmissionFailed"),
39575
+ claimGoalTurn: admission.claimGoalTurn,
39576
+ onGoalClaimDeferred: /* @__PURE__ */ __name(() => {
39577
+ queue.unshift(item);
39578
+ setNotificationTrigger((n) => n + 1);
39579
+ }, "onGoalClaimDeferred")
39580
+ }).catch((error) => {
39581
+ debugLogger36.warn("Failed to admit cron notification", error);
38817
39582
  });
38818
39583
  return;
38819
39584
  }
@@ -38824,20 +39589,41 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38824
39589
  const batch = queue.splice(0, splitIdx);
38825
39590
  const now = Date.now();
38826
39591
  for (const item of batch) {
38827
- addItem(
38828
- { type: "notification", text: item.displayText },
38829
- now
38830
- );
39592
+ if (!item.displayed) {
39593
+ addItem(
39594
+ { type: "notification", text: item.displayText },
39595
+ now
39596
+ );
39597
+ item.displayed = true;
39598
+ }
38831
39599
  }
38832
39600
  const combinedModelText = batch.map((e) => e.modelText).join("\n\n");
38833
39601
  const combinedDisplayText = batch.map((e) => e.displayText).join("; ");
38834
- submitQuery(combinedModelText, targetType, void 0, {
39602
+ void submitQuery(combinedModelText, targetType, void 0, {
38835
39603
  notificationDisplayText: combinedDisplayText,
38836
- todoWorkChainId: batch[0]?.todoWorkChainId
39604
+ todoWorkChainId: batch[0]?.todoWorkChainId,
39605
+ onAdmissionFailed: /* @__PURE__ */ __name(() => {
39606
+ queue.unshift(...batch);
39607
+ }, "onAdmissionFailed"),
39608
+ claimGoalTurn: admission.claimGoalTurn,
39609
+ onGoalClaimDeferred: /* @__PURE__ */ __name(() => {
39610
+ queue.unshift(...batch);
39611
+ setNotificationTrigger((n) => n + 1);
39612
+ }, "onGoalClaimDeferred")
39613
+ }).catch((error) => {
39614
+ debugLogger36.warn("Failed to admit background notification", error);
38837
39615
  });
38838
39616
  });
38839
39617
  }
38840
- }, [streamingState, submitQuery, notificationTrigger, addItem, config]);
39618
+ }, [
39619
+ streamingState,
39620
+ submitQuery,
39621
+ notificationTrigger,
39622
+ addItem,
39623
+ config,
39624
+ claimSystemGoalTurn,
39625
+ goalQueuePendingCount
39626
+ ]);
38841
39627
  const teammateQueueRef = (0, import_react135.useRef)([]);
38842
39628
  const [teammateTrigger, setTeammateTrigger] = (0, import_react135.useState)(0);
38843
39629
  (0, import_react135.useEffect)(() => {
@@ -38873,21 +39659,43 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38873
39659
  (0, import_react135.useEffect)(() => {
38874
39660
  if (streamingState === "idle" /* Idle */ && !isSubmittingQueryRef.current && teammateQueueRef.current.length > 0) {
38875
39661
  runOutsideAgentContext(() => {
39662
+ const admission = claimSystemGoalTurn();
39663
+ if (!admission.ready) return;
38876
39664
  const batch = teammateQueueRef.current.splice(0);
38877
39665
  for (const entry of batch) {
38878
- addItem(
38879
- { type: "notification", text: entry.display },
38880
- Date.now()
38881
- );
39666
+ if (!entry.displayed) {
39667
+ addItem(
39668
+ { type: "notification", text: entry.display },
39669
+ Date.now()
39670
+ );
39671
+ entry.displayed = true;
39672
+ }
38882
39673
  }
38883
39674
  const modelText = batch.map((e) => e.modelText).join("\n\n");
38884
39675
  const display = batch.map((e) => e.display).join("; ");
38885
- submitQuery(modelText, "teammate" /* Teammate */, void 0, {
38886
- notificationDisplayText: display
39676
+ void submitQuery(modelText, "teammate" /* Teammate */, void 0, {
39677
+ notificationDisplayText: display,
39678
+ onAdmissionFailed: /* @__PURE__ */ __name(() => {
39679
+ teammateQueueRef.current.unshift(...batch);
39680
+ }, "onAdmissionFailed"),
39681
+ claimGoalTurn: admission.claimGoalTurn,
39682
+ onGoalClaimDeferred: /* @__PURE__ */ __name(() => {
39683
+ teammateQueueRef.current.unshift(...batch);
39684
+ setTeammateTrigger((n) => n + 1);
39685
+ }, "onGoalClaimDeferred")
39686
+ }).catch((error) => {
39687
+ debugLogger36.warn("Failed to admit teammate notification", error);
38887
39688
  });
38888
39689
  });
38889
39690
  }
38890
- }, [streamingState, submitQuery, teammateTrigger, addItem]);
39691
+ }, [
39692
+ streamingState,
39693
+ submitQuery,
39694
+ teammateTrigger,
39695
+ addItem,
39696
+ claimSystemGoalTurn,
39697
+ goalQueuePendingCount
39698
+ ]);
38891
39699
  return {
38892
39700
  streamingState,
38893
39701
  submitQuery,
@@ -38895,6 +39703,7 @@ var useGeminiStream = /* @__PURE__ */ __name((geminiClient, history, addItem, co
38895
39703
  pendingHistoryItems,
38896
39704
  thought,
38897
39705
  cancelOngoingRequest,
39706
+ preemptGoalTurn,
38898
39707
  retryLastPrompt,
38899
39708
  pendingToolCalls: toolCalls,
38900
39709
  handleApprovalModeChange,
@@ -42196,6 +43005,131 @@ function shouldDrainMessageQueue({
42196
43005
  return isConfigInitialized && streamingState === "idle" /* Idle */ && !isProcessing && !dialogsVisible && messageQueueLength > 0;
42197
43006
  }
42198
43007
  __name(shouldDrainMessageQueue, "shouldDrainMessageQueue");
43008
+ function useQueuedSubmissionDrain({
43009
+ config,
43010
+ isConfigInitialized,
43011
+ streamingState,
43012
+ isProcessing,
43013
+ dialogsVisible,
43014
+ pendingSubmissionCount,
43015
+ getPendingSubmissionCount,
43016
+ popNextSubmission,
43017
+ enqueueGoalTurn,
43018
+ restoreMessages,
43019
+ submitQuery,
43020
+ submissionInFlightRef,
43021
+ submissionSettledRevision
43022
+ }) {
43023
+ const goalRuntimeSessionId = config.getSessionId();
43024
+ const [goalQueueRevision, setGoalQueueRevision] = (0, import_react161.useState)(0);
43025
+ (0, import_react161.useEffect)(() => {
43026
+ try {
43027
+ return config.getGoalRuntime().subscribe(() => {
43028
+ setGoalQueueRevision((revision) => revision + 1);
43029
+ });
43030
+ } catch {
43031
+ return void 0;
43032
+ }
43033
+ }, [config, goalRuntimeSessionId]);
43034
+ const queueDrainingRef = (0, import_react161.useRef)(false);
43035
+ const admissionFailureRef = (0, import_react161.useRef)(null);
43036
+ const [queueDrainNonce, setQueueDrainNonce] = (0, import_react161.useState)(0);
43037
+ (0, import_react161.useEffect)(() => {
43038
+ if (queueDrainingRef.current || submissionInFlightRef.current) return;
43039
+ const admissionFailure = admissionFailureRef.current;
43040
+ if (admissionFailure) {
43041
+ if (pendingSubmissionCount === 0) {
43042
+ admissionFailureRef.current = null;
43043
+ } else if (pendingSubmissionCount <= admissionFailure.pendingSubmissionCount && goalQueueRevision === admissionFailure.goalQueueRevision && streamingState === admissionFailure.streamingState && isProcessing === admissionFailure.isProcessing) {
43044
+ return;
43045
+ } else {
43046
+ admissionFailureRef.current = null;
43047
+ }
43048
+ }
43049
+ if (!shouldDrainMessageQueue({
43050
+ isConfigInitialized,
43051
+ streamingState,
43052
+ isProcessing,
43053
+ dialogsVisible,
43054
+ messageQueueLength: pendingSubmissionCount
43055
+ })) {
43056
+ return;
43057
+ }
43058
+ let goalControlMode = "normal";
43059
+ try {
43060
+ const status = config.getGoalRuntime().getSnapshot().goal?.status;
43061
+ if (status === "active") {
43062
+ goalControlMode = "priority";
43063
+ }
43064
+ } catch {
43065
+ }
43066
+ const submission = popNextSubmission(goalControlMode);
43067
+ if (submission === null) return;
43068
+ queueDrainingRef.current = true;
43069
+ let admissionFailed = false;
43070
+ const markAdmissionFailed = /* @__PURE__ */ __name(() => {
43071
+ admissionFailed = true;
43072
+ admissionFailureRef.current = {
43073
+ pendingSubmissionCount: getPendingSubmissionCount(),
43074
+ goalQueueRevision,
43075
+ streamingState,
43076
+ isProcessing
43077
+ };
43078
+ }, "markAdmissionFailed");
43079
+ const request = submission.kind === "goal" ? submitQuery(
43080
+ submission.continuationContext,
43081
+ "goal" /* Goal */,
43082
+ void 0,
43083
+ {
43084
+ goal: submission,
43085
+ onAdmissionFailed: /* @__PURE__ */ __name(() => {
43086
+ enqueueGoalTurn(submission);
43087
+ markAdmissionFailed();
43088
+ }, "onAdmissionFailed")
43089
+ }
43090
+ ) : submitQuery(
43091
+ submission.modelText,
43092
+ "userQuery" /* UserQuery */,
43093
+ void 0,
43094
+ {
43095
+ userAdmission: { turnKey: submission.turnKey },
43096
+ ...submission.submittedPrompt === void 0 ? {} : { submittedPrompt: submission.submittedPrompt },
43097
+ onAdmissionFailed: /* @__PURE__ */ __name(() => {
43098
+ restoreMessages(
43099
+ [submission.modelText],
43100
+ submission.submittedPrompt
43101
+ );
43102
+ markAdmissionFailed();
43103
+ }, "onAdmissionFailed")
43104
+ }
43105
+ );
43106
+ void Promise.resolve(request).catch((error) => {
43107
+ debugLogger39.warn("Queued submission failed during admission", error);
43108
+ }).finally(() => {
43109
+ queueDrainingRef.current = false;
43110
+ if (!admissionFailed) {
43111
+ setQueueDrainNonce((nonce) => nonce + 1);
43112
+ }
43113
+ });
43114
+ }, [
43115
+ config,
43116
+ dialogsVisible,
43117
+ enqueueGoalTurn,
43118
+ goalQueueRevision,
43119
+ getPendingSubmissionCount,
43120
+ isConfigInitialized,
43121
+ isProcessing,
43122
+ pendingSubmissionCount,
43123
+ popNextSubmission,
43124
+ queueDrainNonce,
43125
+ restoreMessages,
43126
+ streamingState,
43127
+ submissionInFlightRef,
43128
+ submissionSettledRevision,
43129
+ submitQuery
43130
+ ]);
43131
+ }
43132
+ __name(useQueuedSubmissionDrain, "useQueuedSubmissionDrain");
42199
43133
  function getSpeculativeToolResult(response) {
42200
43134
  const responseRecord = typeof response === "object" && response ? response : void 0;
42201
43135
  const hasError = responseRecord !== void 0 && Object.prototype.hasOwnProperty.call(responseRecord, "error");
@@ -42415,6 +43349,7 @@ var AppContainer = /* @__PURE__ */ __name((props) => {
42415
43349
  (async () => {
42416
43350
  profileCheckpoint("config_initialize_start");
42417
43351
  await config.initialize();
43352
+ await waitForGoalRuntime(config);
42418
43353
  setStartupWarnings(
42419
43354
  (currentWarnings) => mergeStartupWarnings(currentWarnings, config.getWarnings())
42420
43355
  );
@@ -42446,10 +43381,6 @@ var AppContainer = /* @__PURE__ */ __name((props) => {
42446
43381
  if (userTurnCount > 0) {
42447
43382
  seedPromptCount(userTurnCount);
42448
43383
  }
42449
- try {
42450
- restoreGoalFromHistory(historyItems, config, historyManager.addItem);
42451
- } catch {
42452
- }
42453
43384
  const recovered = await config.loadPausedBackgroundAgents(
42454
43385
  config.getSessionId()
42455
43386
  );
@@ -42754,6 +43685,7 @@ var AppContainer = /* @__PURE__ */ __name((props) => {
42754
43685
  isFastModelMode,
42755
43686
  isVoiceModelMode,
42756
43687
  isVisionModelMode,
43688
+ isCompactionModelMode,
42757
43689
  isImageModelMode,
42758
43690
  modelDialogPersistScope,
42759
43691
  openModelDialog,
@@ -43185,8 +44117,21 @@ var AppContainer = /* @__PURE__ */ __name((props) => {
43185
44117
  }, [config, historyManager, settings.merged]);
43186
44118
  const cancelHandlerRef = (0, import_react161.useRef)(() => {
43187
44119
  });
43188
- const midTurnDrainRef = (0, import_react161.useRef)(null);
44120
+ const midTurnDrainRef = (0, import_react161.useRef)(
44121
+ null
44122
+ );
43189
44123
  const midTurnRestoreRef = (0, import_react161.useRef)(null);
44124
+ const goalQueueRef = (0, import_react161.useRef)(null);
44125
+ const goalReservationSettlementRef = (0, import_react161.useRef)(Promise.resolve());
44126
+ const submissionInFlightRef = (0, import_react161.useRef)(false);
44127
+ const [submissionSettledRevision, setSubmissionSettledRevision] = (0, import_react161.useState)(0);
44128
+ const onSubmissionSettled = (0, import_react161.useCallback)(() => {
44129
+ setSubmissionSettledRevision((revision) => revision + 1);
44130
+ }, []);
44131
+ const waitForReservationSettlement = (0, import_react161.useCallback)(
44132
+ () => goalReservationSettlementRef.current,
44133
+ []
44134
+ );
43190
44135
  const {
43191
44136
  streamingState,
43192
44137
  submitQuery,
@@ -43194,6 +44139,7 @@ var AppContainer = /* @__PURE__ */ __name((props) => {
43194
44139
  pendingHistoryItems: pendingGeminiHistoryItems,
43195
44140
  thought,
43196
44141
  cancelOngoingRequest,
44142
+ preemptGoalTurn,
43197
44143
  retryLastPrompt,
43198
44144
  handleApprovalModeChange,
43199
44145
  activePtyId,
@@ -43225,7 +44171,8 @@ var AppContainer = /* @__PURE__ */ __name((props) => {
43225
44171
  logger,
43226
44172
  availableTerminalHeightRef,
43227
44173
  terminalWidthRef,
43228
- midTurnRestoreRef
44174
+ midTurnRestoreRef,
44175
+ goalQueueRef
43229
44176
  );
43230
44177
  cancelOngoingRequestRef.current = cancelOngoingRequest;
43231
44178
  isIdleRef.current = streamingState === "idle" /* Idle */;
@@ -43292,35 +44239,85 @@ var AppContainer = /* @__PURE__ */ __name((props) => {
43292
44239
  });
43293
44240
  const {
43294
44241
  messageQueue,
44242
+ pendingSubmissionCount,
43295
44243
  addMessage,
44244
+ enqueueGoalTurn,
44245
+ peekNextUserBatchKey,
44246
+ hasQueuedUserMessages,
44247
+ getPendingSubmissionCount,
44248
+ claimGoalTurn,
44249
+ claimDirectUserAdmission,
44250
+ removeGoalTurns,
44251
+ popNextSubmission,
43296
44252
  popAllMessages,
43297
44253
  restoreMessages,
43298
- drainQueue,
43299
- popNextTurn
44254
+ drainQueue
43300
44255
  } = useMessageQueue();
43301
- const submitUserQuery = (0, import_react161.useCallback)(
43302
- (submission) => submitQuery(
43303
- submission.modelText,
43304
- "userQuery" /* UserQuery */,
43305
- void 0,
43306
- submission.submittedPrompt === void 0 ? void 0 : { submittedPrompt: submission.submittedPrompt }
43307
- ),
43308
- [submitQuery]
44256
+ midTurnDrainRef.current = drainQueue;
44257
+ midTurnRestoreRef.current = restoreMessages;
44258
+ goalQueueRef.current = {
44259
+ peekNextUserBatchKey,
44260
+ claimDirectUserAdmission,
44261
+ claimGoalTurn,
44262
+ hasQueuedUserMessages,
44263
+ getPendingSubmissionCount,
44264
+ waitForReservationSettlement,
44265
+ submissionInFlightRef,
44266
+ onSubmissionSettled
44267
+ };
44268
+ const releaseQueuedGoalReservations = (0, import_react161.useCallback)(
44269
+ (turnKeys) => {
44270
+ let runtime;
44271
+ try {
44272
+ runtime = config.getGoalRuntime();
44273
+ } catch {
44274
+ return;
44275
+ }
44276
+ const previousSettlement = goalReservationSettlementRef.current;
44277
+ const settlement = previousSettlement.then(async () => {
44278
+ await Promise.all(
44279
+ turnKeys.map((turnKey) => runtime.releaseTurn(turnKey))
44280
+ );
44281
+ });
44282
+ goalReservationSettlementRef.current = settlement.catch((error) => {
44283
+ debugLogger39.warn(
44284
+ `Failed to release queued Goal turns: ${getErrorMessage(error)}`
44285
+ );
44286
+ });
44287
+ },
44288
+ [config]
43309
44289
  );
43310
44290
  const popAllQueuedMessages = (0, import_react161.useCallback)(() => {
44291
+ const goalTurnKeys = removeGoalTurns();
44292
+ if (goalTurnKeys.length > 0) {
44293
+ releaseQueuedGoalReservations(goalTurnKeys);
44294
+ }
43311
44295
  const submission = popAllMessages();
43312
44296
  if (submission === null) return null;
43313
44297
  restoredSubmissionRef.current = submission;
43314
44298
  submittedPromptProvenanceUnavailableRef.current = false;
43315
44299
  return submission.modelText;
43316
- }, [popAllMessages]);
43317
- midTurnDrainRef.current = drainQueue;
43318
- midTurnRestoreRef.current = restoreMessages;
44300
+ }, [popAllMessages, releaseQueuedGoalReservations, removeGoalTurns]);
44301
+ (0, import_react161.useEffect)(() => {
44302
+ const host = {
44303
+ startGoalTurn: /* @__PURE__ */ __name(async (input) => {
44304
+ enqueueGoalTurn(input);
44305
+ }, "startGoalTurn"),
44306
+ preemptGoalTurn: /* @__PURE__ */ __name((reason) => {
44307
+ removeGoalTurns();
44308
+ preemptGoalTurn(reason);
44309
+ }, "preemptGoalTurn")
44310
+ };
44311
+ return config.bindGoalTurnHost(host);
44312
+ }, [config, enqueueGoalTurn, preemptGoalTurn, removeGoalTurns]);
43319
44313
  const remoteInput = useRemoteInput();
43320
44314
  (0, import_react161.useEffect)(() => {
43321
44315
  if (!remoteInput) return;
43322
- remoteInput.setSubmitFn((text) => submitQuery(text));
43323
- }, [remoteInput, submitQuery]);
44316
+ remoteInput.setSubmitFn((text) => {
44317
+ addMessage(text);
44318
+ return true;
44319
+ });
44320
+ }, [addMessage, remoteInput]);
43324
44321
  (0, import_react161.useEffect)(() => {
43325
44322
  if (!remoteInput) return;
43326
44323
  if (streamingState === "idle" /* Idle */) {
@@ -43473,9 +44470,15 @@ ${buildWorkflowSteeringNotice()}
43473
44470
  return;
43474
44471
  }
43475
44472
  if (streamingState === "responding" /* Responding */ && isBtwCommand(submittedValue)) {
43476
- void submitUserQuery({
43477
- modelText: submittedValue,
43478
- submittedPrompt
44473
+ void Promise.resolve(
44474
+ submitQuery(
44475
+ submittedValue,
44476
+ "userQuery" /* UserQuery */,
44477
+ void 0,
44478
+ submittedPrompt === void 0 ? void 0 : { submittedPrompt }
44479
+ )
44480
+ ).catch((error) => {
44481
+ debugLogger39.warn("Failed to admit /btw submission", error);
43479
44482
  });
43480
44483
  return;
43481
44484
  }
@@ -43561,9 +44564,15 @@ ${buildWorkflowSteeringNotice()}
43561
44564
  speculationRef.current = IDLE_SPECULATION;
43562
44565
  }
43563
44566
  if (streamingState === "idle" /* Idle */ && !isProcessing && isSlashCommand(submittedValue)) {
43564
- void submitUserQuery({
43565
- modelText: submittedValue,
43566
- submittedPrompt
44567
+ void Promise.resolve(
44568
+ submitQuery(
44569
+ submittedValue,
44570
+ "userQuery" /* UserQuery */,
44571
+ void 0,
44572
+ submittedPrompt === void 0 ? void 0 : { submittedPrompt }
44573
+ )
44574
+ ).catch((error) => {
44575
+ debugLogger39.warn("Failed to admit slash command", error);
43567
44576
  });
43568
44577
  return;
43569
44578
  }
@@ -43574,7 +44583,7 @@ ${buildWorkflowSteeringNotice()}
43574
44583
  agentViewState,
43575
44584
  streamingState,
43576
44585
  isProcessing,
43577
- submitUserQuery,
44586
+ submitQuery,
43578
44587
  handleSlashCommand,
43579
44588
  slashCommands,
43580
44589
  config,
@@ -43622,6 +44631,10 @@ ${buildWorkflowSteeringNotice()}
43622
44631
  pendingHistoryItems2.push(info.pendingItem);
43623
44632
  }
43624
44633
  const draftWasEmpty = buffer.text.length === 0;
44634
+ const goalTurnKeys = removeGoalTurns();
44635
+ if (goalTurnKeys.length > 0) {
44636
+ releaseQueuedGoalReservations(goalTurnKeys);
44637
+ }
43625
44638
  const popped = popAllMessages();
43626
44639
  if (popped) {
43627
44640
  restoredSubmissionRef.current = popped;
@@ -43632,6 +44645,9 @@ ${buildWorkflowSteeringNotice()}
43632
44645
  ${currentText}` : popped.modelText
43633
44646
  );
43634
44647
  }
44648
+ if (info?.wasGoalTurn) {
44649
+ geminiClient?.stripOrphanedUserEntriesFromHistory?.();
44650
+ }
43635
44651
  if (!draftWasEmpty) {
43636
44652
  debugLogger39.debug("auto-restore bail: buffer was non-empty");
43637
44653
  return;
@@ -43718,6 +44734,8 @@ ${currentText}` : popped.modelText
43718
44734
  [
43719
44735
  buffer,
43720
44736
  popAllMessages,
44737
+ releaseQueuedGoalReservations,
44738
+ removeGoalTurns,
43721
44739
  historyManager,
43722
44740
  logger,
43723
44741
  geminiClient,
@@ -44621,36 +45639,21 @@ ${migrationResult.failedFiles.map((f) => ` \u2022 ${f.file}: ${f.error}`).join(
44621
45639
  settings.merged.ui?.showStatusInTitle,
44622
45640
  config
44623
45641
  ]);
44624
- const queueDrainingRef = (0, import_react161.useRef)(false);
44625
- const [queueDrainNonce, setQueueDrainNonce] = (0, import_react161.useState)(0);
44626
- (0, import_react161.useEffect)(() => {
44627
- if (queueDrainingRef.current) return;
44628
- if (!shouldDrainMessageQueue({
44629
- isConfigInitialized,
44630
- streamingState,
44631
- isProcessing,
44632
- dialogsVisible,
44633
- messageQueueLength: messageQueue.length
44634
- })) {
44635
- return;
44636
- }
44637
- const submission = popNextTurn();
44638
- if (submission === null) return;
44639
- queueDrainingRef.current = true;
44640
- Promise.resolve(submitUserQuery(submission)).finally(() => {
44641
- queueDrainingRef.current = false;
44642
- setQueueDrainNonce((n) => n + 1);
44643
- });
44644
- }, [
45642
+ useQueuedSubmissionDrain({
45643
+ config,
44645
45644
  isConfigInitialized,
44646
45645
  streamingState,
44647
45646
  isProcessing,
44648
45647
  dialogsVisible,
44649
- messageQueue,
44650
- popNextTurn,
44651
- submitUserQuery,
44652
- queueDrainNonce
44653
- ]);
45648
+ pendingSubmissionCount,
45649
+ getPendingSubmissionCount,
45650
+ popNextSubmission,
45651
+ enqueueGoalTurn,
45652
+ restoreMessages,
45653
+ submitQuery,
45654
+ submissionInFlightRef,
45655
+ submissionSettledRevision
45656
+ });
44654
45657
  const nightly = props.version.includes("nightly");
44655
45658
  const uiState = (0, import_react161.useMemo)(
44656
45659
  () => ({
@@ -44675,6 +45678,7 @@ ${migrationResult.failedFiles.map((f) => ` \u2022 ${f.file}: ${f.error}`).join(
44675
45678
  isFastModelMode,
44676
45679
  isVoiceModelMode,
44677
45680
  isVisionModelMode,
45681
+ isCompactionModelMode,
44678
45682
  isImageModelMode,
44679
45683
  modelDialogPersistScope,
44680
45684
  isTrustDialogOpen,
@@ -44819,6 +45823,7 @@ ${migrationResult.failedFiles.map((f) => ` \u2022 ${f.file}: ${f.error}`).join(
44819
45823
  isFastModelMode,
44820
45824
  isVoiceModelMode,
44821
45825
  isVisionModelMode,
45826
+ isCompactionModelMode,
44822
45827
  isImageModelMode,
44823
45828
  modelDialogPersistScope,
44824
45829
  isTrustDialogOpen,