nolo-cli 0.258.0-alpha.1 → 0.260.0-alpha.1

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 (316) hide show
  1. package/README.md +1 -1
  2. package/{_executeModel-E2LL7FPO.js → _executeModel-EO6JFCOF.js} +97 -83
  3. package/accountResolver-NGICIMEE.js +1 -1
  4. package/{action-C6IQAKN4.js → action-WIA56QT4.js} +12 -10
  5. package/{addContentAction-53364YDW.js → addContentAction-OCMWZLYG.js} +14 -13
  6. package/{addDialogAgentAction-U5DD5EN5.js → addDialogAgentAction-ER2NZ7BC.js} +20 -24
  7. package/{agentDeleteCommand-ORNRRKJO.js → agentDeleteCommand-KSXSNPAU.js} +184 -146
  8. package/{agentEmailCommands-2ALVFOD5.js → agentEmailCommands-NXRWS7NS.js} +142 -126
  9. package/{agentGrantCommands-L6O2HVJI.js → agentGrantCommands-D2S7LCTU.js} +8 -5
  10. package/{agentListCommands-6I4NQPR4.js → agentListCommands-PFXGZZ3Y.js} +87 -68
  11. package/{agentMachineCommands-PNHTIJ6A.js → agentMachineCommands-2Q55CSL4.js} +68 -59
  12. package/{agentProviderCommands-QLTABYR7.js → agentProviderCommands-EUNS7Y2Z.js} +10 -7
  13. package/{agentPullCommand-2EYJ5ENC.js → agentPullCommand-S2VMPSWL.js} +9 -6
  14. package/agentRecordCommands-FUFI526H.js +210 -0
  15. package/agentRun-ZNMUPDHF.js +250 -0
  16. package/agentRunCommand-ISVQ2UYC.js +248 -0
  17. package/{agentRunControl-3TIVJ3SR.js → agentRunControl-NEK44LDM.js} +19 -12
  18. package/{agentRuntimeLocal-3MAEFYSB.js → agentRuntimeLocal-SST4EPLT.js} +62 -49
  19. package/{agentSlice-KOQXUPKT.js → agentSlice-4ZJJJN4M.js} +15 -18
  20. package/appConfigCommands-MPHS6FHD.js +417 -0
  21. package/{appDeleteCommands-FEPN62UR.js → appDeleteCommands-W26WGENW.js} +68 -58
  22. package/{appDeployCommands-DPFEWFYZ.js → appDeployCommands-ER7IOF5E.js} +74 -59
  23. package/{appDeployStatusCommands-LQ5X5KVX.js → appDeployStatusCommands-VKLL3A77.js} +68 -58
  24. package/{appGetCommands-W3JBBIF7.js → appGetCommands-P6GXJNUD.js} +74 -58
  25. package/{appListCommands-LUHZS7JU.js → appListCommands-ACA2IZZM.js} +74 -58
  26. package/appMigrateCommands-OGF4E2W6.js +230 -0
  27. package/appSourceCommands-GAHVBRUM.js +279 -0
  28. package/{authCommand-HKSXJT3J.js → authCommand-PXE7NZTQ.js} +26 -40
  29. package/{authCommands-T5FODCEG.js → authCommands-AZPYXTUB.js} +20 -17
  30. package/{builtinSkillRegistry-FVEEO4U2.js → builtinSkillRegistry-6XUWMAV5.js} +8 -6
  31. package/{chromeOpsCommands-4UIKH26F.js → chromeOpsCommands-7UKKUOBU.js} +68 -18
  32. package/{chunk-KO5PFS74.js → chunk-2CKFROQS.js} +2454 -1115
  33. package/{chunk-6N4IKMTH.js → chunk-2I4R6ZRV.js} +40 -26
  34. package/{chunk-FXEPZKNJ.js → chunk-2MIZHEND.js} +506 -64
  35. package/{chunk-TLE77UJ5.js → chunk-2OROOEOQ.js} +0 -1
  36. package/{chunk-6RSNVJGO.js → chunk-2ZBPWX7N.js} +4 -4
  37. package/chunk-35JIFLIG.js +30 -0
  38. package/{chunk-ZYPXOQS2.js → chunk-3EPED3UO.js} +1 -1
  39. package/{chunk-DNNPARJK.js → chunk-3QMN3T6L.js} +50 -37
  40. package/{chunk-DMPZMYH4.js → chunk-3R4AYHJR.js} +13 -1
  41. package/{chunk-HPDLPEUG.js → chunk-42JZNSAY.js} +267 -234
  42. package/{chunk-223KZUJ6.js → chunk-4HZCBA4Q.js} +18 -15
  43. package/{chunk-C5A54QS7.js → chunk-4INJGWE3.js} +18 -5
  44. package/chunk-4IVMDQBA.js +261 -0
  45. package/chunk-4Y6CZ2N4.js +82 -0
  46. package/{chunk-OKAXQFON.js → chunk-52BNL6GP.js} +4 -4
  47. package/{chunk-KZ4A7EIV.js → chunk-56OAS5RZ.js} +1 -1
  48. package/{chunk-QGFLVQ6E.js → chunk-6KUTNAPU.js} +4 -14
  49. package/{chunk-MNFUKRRU.js → chunk-6XAAKRJB.js} +7 -7
  50. package/{chunk-P27E22MA.js → chunk-6Z6DGDPI.js} +1 -1
  51. package/chunk-72VWN4VK.js +51 -0
  52. package/{chunk-2RZBFJEG.js → chunk-75FZ2Z7C.js} +16027 -17392
  53. package/{chunk-ADYWV732.js → chunk-76B6YUQS.js} +264 -177
  54. package/{chunk-AKBNCTPY.js → chunk-76K4GTY5.js} +1 -1
  55. package/{chunk-ZMJMHXYX.js → chunk-7HUCUD2I.js} +3 -3
  56. package/chunk-7LR2IFUH.js +100 -0
  57. package/{chunk-S73EPYNC.js → chunk-7LS5ATRP.js} +20 -6
  58. package/{chunk-Y2TCTNUD.js → chunk-7QO6YSA4.js} +4 -4
  59. package/{chunk-TF427WGH.js → chunk-7RYH7YIY.js} +19 -27
  60. package/{chunk-KHYSFS3W.js → chunk-A454UXB6.js} +148 -73
  61. package/chunk-AMNZPQCY.js +635 -0
  62. package/chunk-AMTF6FJD.js +356 -0
  63. package/{chunk-MUDMYJCM.js → chunk-AQNWWJLH.js} +2 -56
  64. package/{chunk-WSLL7VV4.js → chunk-B4NA5UJR.js} +9 -9
  65. package/{chunk-LHCGKAFO.js → chunk-BKP325XS.js} +184 -112
  66. package/{chunk-PENRYZ4D.js → chunk-BPB3T5EU.js} +4 -7
  67. package/{chunk-46FETNLF.js → chunk-BTIFQBYW.js} +7 -6
  68. package/{chunk-2JHGUL5K.js → chunk-BVYHE6QD.js} +2 -2
  69. package/{chunk-KXOPLLFP.js → chunk-CA7LGAHV.js} +69 -9
  70. package/{chunk-2FZVXOFX.js → chunk-CEIWXKHP.js} +112 -200
  71. package/{chunk-AIFQKNPP.js → chunk-CL33RFD7.js} +1 -1
  72. package/{chunk-JAGD4PSH.js → chunk-CRGPRAJ4.js} +46 -42
  73. package/{chunk-P4R5KXU7.js → chunk-CW6LRDSF.js} +5 -5
  74. package/{chunk-BD22OFDQ.js → chunk-CZHIOBBK.js} +8 -3
  75. package/chunk-D3ONA3FP.js +762 -0
  76. package/chunk-D3SAQ6T7.js +1697 -0
  77. package/{chunk-PIVTQRX6.js → chunk-DDKA6V6X.js} +111 -12
  78. package/{chunk-KQHEGELM.js → chunk-DEAII55O.js} +16 -6
  79. package/{chunk-J55F3IEZ.js → chunk-DKJQEFNG.js} +1 -1
  80. package/chunk-DLXL4NSL.js +1179 -0
  81. package/{chunk-EJQE5HB7.js → chunk-DSBRIUX5.js} +4 -2
  82. package/{chunk-XRGBJHZX.js → chunk-E36V7MPY.js} +9 -5
  83. package/{chunk-4YPH5KRA.js → chunk-EDKMRDET.js} +1 -1
  84. package/chunk-EJHLDJWZ.js +58 -0
  85. package/{chunk-E4HBZDV6.js → chunk-EMFZXJTN.js} +15 -47
  86. package/chunk-ER6NTALN.js +34 -0
  87. package/chunk-EUHMI5KG.js +101 -0
  88. package/{chunk-YQLAFJRQ.js → chunk-FBNVJ2TO.js} +1 -1
  89. package/{chunk-EXD7S7QW.js → chunk-FF5ZRKW7.js} +12 -7
  90. package/{chunk-7PTWFSZZ.js → chunk-FGD4NMTP.js} +4 -4
  91. package/{chunk-6XIE5ZGI.js → chunk-FGFJUFPS.js} +5 -6
  92. package/chunk-FI4DPLR7.js +902 -0
  93. package/chunk-FKVLQNGJ.js +25 -0
  94. package/{chunk-JCQ3WCQ3.js → chunk-FOC4TORM.js} +69 -3
  95. package/{chunk-JPXACKSW.js → chunk-G22P2J7O.js} +30 -81
  96. package/{chunk-7WHCIA5V.js → chunk-G5IAIGGD.js} +3 -8
  97. package/{chunk-IZHENZQ5.js → chunk-G5JGA5YM.js} +180 -31
  98. package/{chunk-7EUJ65PF.js → chunk-GMBWWBSJ.js} +782 -449
  99. package/{chunk-WS36XPJD.js → chunk-GYFKKTDI.js} +82 -6
  100. package/{chunk-APXC3SQO.js → chunk-GZ4I5EMM.js} +9 -9
  101. package/{chunk-324FWHUA.js → chunk-HHXF57CL.js} +12 -3
  102. package/chunk-HJTI7RZV.js +94 -0
  103. package/{chunk-JGVWHUYK.js → chunk-HPIY372N.js} +7 -7
  104. package/{chunk-Q2MPKE4B.js → chunk-HVRG27HI.js} +76 -26
  105. package/{chunk-HDKMVYNJ.js → chunk-I3NWAILT.js} +6 -4
  106. package/{chunk-MD7O2NN2.js → chunk-IM7HCFB4.js} +313 -275
  107. package/{chunk-DWES4SXY.js → chunk-INN2PBW7.js} +1 -1
  108. package/chunk-IV6VUVLJ.js +88 -0
  109. package/chunk-J42X32PV.js +472 -0
  110. package/{chunk-V6S5OZSP.js → chunk-JHQNWV2C.js} +4441 -2569
  111. package/{chunk-R7XWZDOH.js → chunk-JUMQJSQF.js} +1423 -282
  112. package/{chunk-BIDSIRTS.js → chunk-JUNYPVL6.js} +10 -16
  113. package/chunk-JVEKCQAP.js +222 -0
  114. package/{chunk-JW6OURKM.js → chunk-KAHYBAEN.js} +215 -473
  115. package/chunk-KDDXC2IH.js +148 -0
  116. package/chunk-KGKTN2NX.js +25 -0
  117. package/chunk-KGWE224L.js +246 -0
  118. package/chunk-L3UFGEDU.js +17157 -0
  119. package/{chunk-CBIGMWMI.js → chunk-LHJB4BXJ.js} +1 -1
  120. package/{chunk-DCTQJDDQ.js → chunk-LIH7WSX5.js} +23 -379
  121. package/chunk-LJOPY4TL.js +443 -0
  122. package/{chunk-TRRXYFTR.js → chunk-LOFRSJX2.js} +1 -0
  123. package/{chunk-SQL7YNED.js → chunk-LPXBBC32.js} +71 -5
  124. package/chunk-LXP53WGF.js +168 -0
  125. package/chunk-MDAYRIP7.js +1889 -0
  126. package/chunk-MRACVEPZ.js +7 -0
  127. package/chunk-NHLLXINQ.js +8 -0
  128. package/{chunk-VQR2ACSC.js → chunk-NTBTVKKB.js} +17 -25
  129. package/{chunk-LVZVSLKO.js → chunk-O7ZY6SUK.js} +5 -22
  130. package/{chunk-APQBEIOQ.js → chunk-P4XAHM4B.js} +1 -1
  131. package/chunk-PL5RKESU.js +40 -0
  132. package/{chunk-U2H426FE.js → chunk-PQ3QZMJK.js} +20 -4
  133. package/chunk-Q5FJJ6XI.js +103 -0
  134. package/{createAgentAutomationAction-HEZ3G5L4.js → chunk-QKM55LP2.js} +3 -160
  135. package/{chunk-SIHOY5YI.js → chunk-QZCLCAYC.js} +170 -164
  136. package/{chunk-FE7G6DSP.js → chunk-R72QWIFO.js} +14 -4
  137. package/{chunk-JLZJL3WC.js → chunk-RDZ5OIAT.js} +370 -39
  138. package/{chunk-5RGU3J7P.js → chunk-REAE2SZK.js} +0 -1
  139. package/chunk-RF576RYE.js +117 -0
  140. package/chunk-RI7SXDJW.js +1317 -0
  141. package/{chunk-JOJH3KWV.js → chunk-RIOAPUGV.js} +242 -25
  142. package/{chunk-7B55IVLF.js → chunk-RL6H2A2Z.js} +2561 -4059
  143. package/{chunk-BZLGPM5B.js → chunk-RNLKWUVY.js} +7 -12
  144. package/{chunk-BB76X6O4.js → chunk-RWXHGPWJ.js} +1 -1
  145. package/chunk-S7BF2OGX.js +432 -0
  146. package/{chunk-6VEO7Z3Y.js → chunk-SD4MBKZ7.js} +6 -6
  147. package/{chunk-PNBQ5JTA.js → chunk-SGEBRBF3.js} +7 -4
  148. package/{chunk-6SOWMEAY.js → chunk-SR57FDTX.js} +2 -258
  149. package/{chunk-CEKRIR22.js → chunk-SU4NCTW4.js} +1 -1
  150. package/{chunk-LJ6WIQZO.js → chunk-SX6PDLBZ.js} +279 -149
  151. package/{chunk-6VNBJ7GI.js → chunk-T4WU747C.js} +5 -5
  152. package/{chunk-53W5BXLN.js → chunk-TCOHWKDM.js} +54 -55
  153. package/{chunk-KO5GO2BC.js → chunk-TXMFSGRY.js} +1 -1
  154. package/{chunk-UUCYUN6Y.js → chunk-UB7NV7NN.js} +1 -1
  155. package/{chunk-CVDJUPBN.js → chunk-UOLGGEEC.js} +774 -119
  156. package/{chunk-ADUCBH4M.js → chunk-USFG4EWQ.js} +51 -42
  157. package/{chunk-LLUBUHNT.js → chunk-UYZOBSSO.js} +5 -9
  158. package/{chunk-ONTHDYFU.js → chunk-VDC3BW24.js} +24 -10
  159. package/chunk-VH356OQ3.js +425 -0
  160. package/{chunk-U6QNVOR5.js → chunk-VKM7DOYB.js} +130 -6
  161. package/{chunk-3GGVFHWI.js → chunk-VPAO5WQX.js} +17 -14
  162. package/{chunk-OYUMJMC5.js → chunk-W2RQYNPI.js} +5 -0
  163. package/{chunk-C63KMRJE.js → chunk-W2Z5E2R7.js} +126 -698
  164. package/{chunk-4ZCTKB27.js → chunk-W5GKF5ZW.js} +1 -0
  165. package/{chunk-NUHQO3RB.js → chunk-WIVVNJUS.js} +1 -1
  166. package/chunk-WLJNHFEB.js +1710 -0
  167. package/chunk-WMBJDXMY.js +408 -0
  168. package/chunk-WSQLCWLQ.js +201 -0
  169. package/{chunk-YN23INFZ.js → chunk-WXD6Y7DW.js} +23 -2
  170. package/{chunk-RQKTCHQM.js → chunk-WY6DMHMG.js} +1 -1
  171. package/{chunk-MLK3FEXG.js → chunk-XJW6SLBZ.js} +3 -3
  172. package/{chunk-7BIJFGKS.js → chunk-XQFDCRG3.js} +105 -51
  173. package/chunk-XT6C2QZW.js +46 -0
  174. package/{chunk-NRUYSNSZ.js → chunk-Y7THFNVJ.js} +9 -9
  175. package/{chunk-ZEZC7IIM.js → chunk-YFSM2366.js} +35 -35
  176. package/{chunk-RD3QLZQV.js → chunk-YM5XULB2.js} +324 -2
  177. package/{chunk-BD5YJJLJ.js → chunk-YNP3ITPU.js} +19 -12
  178. package/{chunk-U35UUM5K.js → chunk-YOUSQIIK.js} +1 -1
  179. package/{chunk-RIWKZT7E.js → chunk-YRPIUIEQ.js} +11 -9
  180. package/{chunk-Z3JZ2R5F.js → chunk-YU235GGN.js} +25 -8
  181. package/chunk-YWEZSBLL.js +790 -0
  182. package/chunk-Z3KTXWWB.js +76 -0
  183. package/{chunk-YLAHYLDQ.js → chunk-ZC3CMUKU.js} +2 -89
  184. package/chunk-ZD7OULYZ.js +368 -0
  185. package/{chunk-5P3PPQVP.js → chunk-ZQAADXSF.js} +1 -1
  186. package/{chunk-HQUGB2HM.js → chunk-ZTCMXPIS.js} +62 -50
  187. package/{cliAgentConfigHelpers-BXHQ3PXP.js → cliAgentConfigHelpers-KMXS7JP5.js} +20 -14
  188. package/{cliAuthorityBrokerClient-TFNXJLXL.js → cliAuthorityBrokerClient-3SKOA7OZ.js} +3 -1
  189. package/cliAuthorityBrokerProcess-DCCUT4YQ.js +34 -0
  190. package/{cliEnvHelpers-CNMP3RDX.js → cliEnvHelpers-YDGDHIEE.js} +5 -2
  191. package/{cliExecutor-K6FDZTQ2.js → cliExecutor-Z62UBJ5S.js} +12 -6
  192. package/cliLocalAgentRecordReader-X2YHEBWI.js +113 -0
  193. package/cloudAutomationCommands-C6Q3BFRB.js +310 -0
  194. package/{commandRegistry-QKOJ5FIC.js → commandRegistry-TYYYTW5E.js} +263 -120
  195. package/{contentThunks-ZDBDDZP3.js → contentThunks-E6BJ5YSX.js} +45 -43
  196. package/{cooldownCommands-Y4ZQQ35D.js → cooldownCommands-FPAFS7XG.js} +1 -1
  197. package/createAgentAutomationAction-L3NLCIIW.js +172 -0
  198. package/{createDialogAction-DK62W5VA.js → createDialogAction-QSWKRPWQ.js} +46 -42
  199. package/{createPageAction-W6NXHVKO.js → createPageAction-ZVVUT4CZ.js} +49 -45
  200. package/{db-VR74ADGC.js → db-KTQ3LL2Q.js} +3 -3
  201. package/{dbSlice-RWPSVHBC.js → dbSlice-SEVKNA7A.js} +21 -16
  202. package/deleteDbKey-43MTK2DI.js +86 -0
  203. package/{dialogCommands-Z24IDINY.js → dialogCommands-UVMTIFSA.js} +80 -66
  204. package/{dialogMessageRecord-OAV77LT7.js → dialogMessageRecord-2HJTEXQX.js} +1 -1
  205. package/{dialogNotifyCommand-IASQGEMW.js → dialogNotifyCommand-LMWF7EQI.js} +22 -14
  206. package/dialogPortabilityCommands-PAMLEBST.js +3036 -0
  207. package/{dialogSlice-62GISS77.js → dialogSlice-VHPXENDZ.js} +43 -42
  208. package/{dialogTraceCommand-FDINAIZ6.js → dialogTraceCommand-SO2WKAXW.js} +83 -69
  209. package/{dialogUsageCommand-WJ3U6KZU.js → dialogUsageCommand-EUO6JXTD.js} +6 -3
  210. package/{docCreateCommands-SXA4TMGJ.js → docCreateCommands-H4RLIUNX.js} +68 -59
  211. package/{docDeleteCommands-ELXSZK3F.js → docDeleteCommands-OVAKCBMT.js} +68 -59
  212. package/{docReadCommands-DFLAQPI4.js → docReadCommands-KFISIUVA.js} +67 -58
  213. package/{docStore-UWF2PMCB.js → docStore-X7BEA735.js} +16 -17
  214. package/{docUpdateCommands-KB6M5HUH.js → docUpdateCommands-VOEER36L.js} +68 -59
  215. package/ebookDownloaderAgentCommand-2DHPGEOQ.js +674 -0
  216. package/{fetchMessages-TQEUZD7H.js → fetchMessages-RGPIYEPZ.js} +2 -2
  217. package/{getPricing-5BLZRPTM.js → getPricing-BK6CUBAE.js} +8 -4
  218. package/{handleSendMessageAction-ZV6OQPQG.js → handleSendMessageAction-GQ2KKOET.js} +265 -119
  219. package/{hostCredentialCreate-3IA5IJFG.js → hostCredentialCreate-PJAIKZQP.js} +138 -122
  220. package/index.js +35 -21
  221. package/{keys-RWF7UCB4.js → keys-FXEGMKSG.js} +2 -2
  222. package/localAutomationCommands-UU66LOWB.js +198 -0
  223. package/localAutomationRuntime-SW4R42SZ.js +60 -0
  224. package/{localDialogRead-BJJT3TF5.js → localDialogRead-W2EVXISA.js} +2 -2
  225. package/{localRuntimeAdapter-SSG5ORLZ.js → localRuntimeAdapter-WRBLXFUZ.js} +136 -119
  226. package/localRuntimeAuthority-3YDFZD3L.js +44 -0
  227. package/{localRuntimeDb-ZJFGNHML.js → localRuntimeDb-CJWJK47G.js} +1 -1
  228. package/{machineCommands-4WKJ3TLO.js → machineCommands-JFYED66N.js} +251 -357
  229. package/{machineInfo-LWHTEBHJ.js → machineInfo-BJIU3WQ5.js} +4 -2
  230. package/machineWsRunDispatch-CZUV2FXE.js +227 -0
  231. package/{mcpLocalAuthorizeCommand-RBXJDE6J.js → mcpLocalAuthorizeCommand-HLU72QME.js} +40 -22
  232. package/mcpLocalManageCommands-OHHU6F5C.js +212 -0
  233. package/{memberThunks-43B7UYC5.js → memberThunks-FJW4GPM5.js} +102 -22
  234. package/{memoryCommands-BC6REPQB.js → memoryCommands-2RLHDMU2.js} +25 -34
  235. package/{models-ZX2BYIMB.js → models-TOXYINNM.js} +3 -2
  236. package/{offlineMarxistsAgentCommand-XVXUE6G5.js → offlineMarxistsAgentCommand-WZBJBCPZ.js} +16 -22
  237. package/package.json +3 -3
  238. package/parityCommands-7EWR34P3.js +613 -0
  239. package/{projectArchive-JN43WW4E.js → projectArchive-JIVRMXVV.js} +49 -45
  240. package/{providerPresetApply-NTJUINI6.js → providerPresetApply-IRJ56XIZ.js} +12 -16
  241. package/{providerRegistry-W45SLUV6.js → providerRegistry-26PAUYH2.js} +3 -13
  242. package/{read-KG6INYUT.js → read-6YR57D6V.js} +11 -10
  243. package/{readDocTool-N3GA52JR.js → readDocTool-NKOGL2MW.js} +5 -1
  244. package/{readlineWorkspace-D6EUSB2Q.js → readlineWorkspace-V26AN2FL.js} +926 -572
  245. package/{rememberExplicit-CPAPONSI.js → rememberExplicit-7KX4HXQC.js} +4 -4
  246. package/remove-BF33RCTH.js +32 -0
  247. package/{removeDialogAgentAction-EEVSOQOJ.js → removeDialogAgentAction-GWHBWF4W.js} +22 -26
  248. package/{runAgentClientLoop-FEZTSUSJ.js → runAgentClientLoop-EKD2EEEA.js} +117 -82
  249. package/{runtimeDoctorCommands-V3M3JTUV.js → runtimeDoctorCommands-IALUR5BZ.js} +23 -16
  250. package/{secretCommands-53NZFD4T.js → secretCommands-CSTQYB6T.js} +2 -2
  251. package/{setDialogExtraReferencesAction-DNO5POHA.js → setDialogExtraReferencesAction-RL6FGO7T.js} +16 -17
  252. package/{setPrimaryDialogAgentAction-QABBEO4C.js → setPrimaryDialogAgentAction-XJASBB3K.js} +23 -27
  253. package/{settingThunks-DVKG4X4S.js → settingThunks-ZT7ZYXXL.js} +170 -497
  254. package/{skillDiscovery-5GEGWJ6N.js → skillDiscovery-IUEZZG2B.js} +3 -3
  255. package/{spaceCommands-4ACQQNZL.js → spaceCommands-65WQHVOI.js} +194 -90
  256. package/spacePruneCommand-PTMRUWYJ.js +233 -0
  257. package/{store-Z53ICFL3.js → store-WSAVTR32.js} +3 -1
  258. package/{streamAgentChatTurn-I425SVYJ.js → streamAgentChatTurn-B5NICHZW.js} +225 -137
  259. package/{switchDialogAgentAction-KYWJSGOO.js → switchDialogAgentAction-X6DFOIAX.js} +19 -23
  260. package/{tableCommands-EFA754RE.js → tableCommands-6E77VD73.js} +28 -49
  261. package/{toolApiClient-N5PYW2R3.js → toolApiClient-GTTWEV6P.js} +15 -4
  262. package/{tools-WBPFTSMK.js → tools-UMCPIQX6.js} +73 -63
  263. package/{tuiRestart-VN5F4GYU.js → tuiRestart-O7UDLNQU.js} +20 -13
  264. package/tuiSummaryLlmCaller-7APIUIIV.js +52 -0
  265. package/{updateCommands-VQEBBIGO.js → updateCommands-DXDIAQFS.js} +12 -7
  266. package/{updateDialogTitleAction-VB5DTVXV.js → updateDialogTitleAction-HZLKWVKM.js} +57 -58
  267. package/{usageCommand-WI6SQOPB.js → usageCommand-WYLNBDHB.js} +6 -8
  268. package/{usageRebuildCommand-WQRLLZAT.js → usageRebuildCommand-AEUPY2PE.js} +11 -15
  269. package/{windowsSelfUpdate-ZEZKGX4M.js → windowsSelfUpdate-SXSVXK4X.js} +2 -2
  270. package/workContext-ZAW6VXT7.js +18 -0
  271. package/workContextQueryProjection-CACY5VFE.js +23 -0
  272. package/{workloadLifecycle-DYX5ZMAT.js → workloadLifecycle-P2SJVV3S.js} +1 -1
  273. package/agentFavoriteCommands-7LOP3HUD.js +0 -186
  274. package/agentRecordCommands-BEZPBYBM.js +0 -194
  275. package/agentRunCommand-2T72V5KY.js +0 -232
  276. package/chunk-2MBTWINN.js +0 -89
  277. package/chunk-523DITKR.js +0 -32
  278. package/chunk-BUDVRYES.js +0 -2213
  279. package/chunk-BXGU6274.js +0 -862
  280. package/chunk-BZMDWGQQ.js +0 -47
  281. package/chunk-GAHJLSDO.js +0 -107
  282. package/chunk-GYX6XTAI.js +0 -84
  283. package/chunk-HNUWUO75.js +0 -93
  284. package/chunk-HSBHS6KT.js +0 -33401
  285. package/chunk-KG27JIG4.js +0 -136
  286. package/chunk-OB4FBZXJ.js +0 -364
  287. package/chunk-OKH74FML.js +0 -3746
  288. package/chunk-OLZBQWZU.js +0 -6
  289. package/chunk-OOV5JN25.js +0 -1317
  290. package/chunk-OQFOE4SJ.js +0 -405
  291. package/chunk-PXYBUFDB.js +0 -53
  292. package/chunk-R3FZHW4Q.js +0 -103
  293. package/chunk-R3MV2GII.js +0 -106
  294. package/chunk-SCAC3NM5.js +0 -11751
  295. package/chunk-SR4FE5VD.js +0 -9
  296. package/chunk-SYTHYBMI.js +0 -3558
  297. package/chunk-UKZX3NHN.js +0 -48
  298. package/chunk-UVLYNWIE.js +0 -74
  299. package/chunk-WFEWP352.js +0 -861
  300. package/chunk-X4O7FJF5.js +0 -160
  301. package/chunk-YJPK35HB.js +0 -175
  302. package/chunk-YNIYE47Z.js +0 -105
  303. package/chunk-Z4PCXPUE.js +0 -127
  304. package/chunk-ZTHAJU3O.js +0 -2537
  305. package/cliAuthorityBrokerProcess-5ZFBTHLB.js +0 -22
  306. package/cliLocalAgentRecordReader-Q6677YID.js +0 -104
  307. package/deleteFile-ECU6FU5C.js +0 -55
  308. package/localRuntimeAuthority-UF2DAQ3F.js +0 -28
  309. package/machineWsRunDispatch-7PROH7E7.js +0 -209
  310. package/markdownToSlate-PXYAIBVL.js +0 -8
  311. package/tuiSummaryLlmCaller-HROLGN4F.js +0 -45
  312. package/webapi-QVV65DQF.js +0 -2487
  313. package/workContext-Y3ADAPZU.js +0 -14
  314. package/{chunk-USGHJSGO.js → chunk-GX2MFKF3.js} +3 -3
  315. package/{chunk-PHREU2KZ.js → chunk-WX266G2C.js} +0 -0
  316. package/{chunk-DXWGFL2Z.js → chunk-YY7IGJMN.js} +3 -3
@@ -1,14 +1,20 @@
1
1
  import {
2
2
  resolveAuthGuidanceState
3
- } from "./chunk-4YPH5KRA.js";
3
+ } from "./chunk-EDKMRDET.js";
4
+ import {
5
+ getRestartBlocker,
6
+ hasRestartBlockingRuns
7
+ } from "./chunk-INN2PBW7.js";
4
8
  import {
5
- runAnthropicOAuthLogin,
6
9
  runCursorOAuthLogin,
7
10
  runDevinOAuthLogin,
8
11
  runXaiOAuthDeviceCode,
9
12
  runXaiOAuthLogin,
10
13
  syncCredentialToServer
11
- } from "./chunk-DCTQJDDQ.js";
14
+ } from "./chunk-LIH7WSX5.js";
15
+ import {
16
+ runCloudflareOAuthLogin
17
+ } from "./chunk-P4XAHM4B.js";
12
18
  import {
13
19
  createAccountSessionCore,
14
20
  createDeviceAuthorizationProtocol,
@@ -16,10 +22,15 @@ import {
16
22
  parseStoredTokenEntries,
17
23
  parseUserToken,
18
24
  saveTokenLogin
19
- } from "./chunk-HQUGB2HM.js";
25
+ } from "./chunk-ZTCMXPIS.js";
20
26
  import {
21
- runCloudflareOAuthLogin
22
- } from "./chunk-APQBEIOQ.js";
27
+ buildHostEnvironmentLayer,
28
+ buildSkillContextBlocks,
29
+ emitTerminalProgramStatus,
30
+ isRunResultStalledOrTruncated,
31
+ resolveSkillReference,
32
+ resolveTerminalProgramStatusState
33
+ } from "./chunk-D3SAQ6T7.js";
23
34
  import {
24
35
  COLLAPSED_PASTE_PLACEHOLDER_RE,
25
36
  DEFAULT_TUI_AGENT_KEY,
@@ -30,8 +41,6 @@ import {
30
41
  TUI_TREE_TOOLS,
31
42
  allocateCollapsedPaste,
32
43
  applyDetectedBackground,
33
- buildHostEnvironmentLayer,
34
- buildSkillContextBlocks,
35
44
  clearCollapsedPasteStore,
36
45
  computeBaselineContextTokens,
37
46
  contextRefusalDiagnostics,
@@ -40,7 +49,6 @@ import {
40
49
  describeContextRefusal,
41
50
  detectSystemBrightnessFromEnv,
42
51
  dimCliText,
43
- emitTerminalProgramStatus,
44
52
  expandCollapsedPastes,
45
53
  expandRangeToCollapsedPasteChips,
46
54
  findAgentCatalogEntry,
@@ -59,7 +67,6 @@ import {
59
67
  isInvalidGrantError,
60
68
  isLocalContextCoverageFailure,
61
69
  isOwnerOAuthUnavailableError,
62
- isRunResultStalledOrTruncated,
63
70
  loadAgentCatalog,
64
71
  loadAgentCatalogWithNotices,
65
72
  lookupCachedAgentName,
@@ -70,7 +77,6 @@ import {
70
77
  preferredTopTaskEntries,
71
78
  prefetchAgentCatalog,
72
79
  preserveContextUsageWithoutReceipt,
73
- redactSecrets,
74
80
  releaseCollapsedPaste,
75
81
  releaseCollapsedPasteReferences,
76
82
  renderAgentCatalogList,
@@ -89,9 +95,7 @@ import {
89
95
  resolveContextUsage,
90
96
  resolveHistoryLayoutGeometry,
91
97
  resolveHistoryViewportHeight,
92
- resolveSkillReference,
93
98
  resolveSurfacePaintWidth,
94
- resolveTerminalProgramStatusState,
95
99
  resolveTopTaskEntryBudget,
96
100
  resolveTuiThemeMode,
97
101
  runAgentTurn,
@@ -110,15 +114,16 @@ import {
110
114
  toolRowDetailLine,
111
115
  tuiRenderThemeFingerprint,
112
116
  userBubbleSurfaceBackgroundSequence
113
- } from "./chunk-2RZBFJEG.js";
114
- import "./chunk-6QDYSCPW.js";
115
- import "./chunk-GAHJLSDO.js";
116
- import "./chunk-BD22OFDQ.js";
117
- import "./chunk-P27E22MA.js";
118
- import "./chunk-ZYPXOQS2.js";
117
+ } from "./chunk-75FZ2Z7C.js";
118
+ import "./chunk-WSQLCWLQ.js";
119
+ import "./chunk-CZHIOBBK.js";
120
+ import "./chunk-6Z6DGDPI.js";
121
+ import "./chunk-3EPED3UO.js";
119
122
  import {
123
+ INSTABOX_SCHEMA_EXPOSURE_ENV,
120
124
  MCP_EXPOSURE_ENV,
121
125
  buildCliNoticeText,
126
+ buildLocalPolicyToolNames,
122
127
  buildNoticeTasksFromRuns,
123
128
  buildOpenAiTools,
124
129
  clearCliLocalRuntimePreparedAgentCache,
@@ -126,6 +131,7 @@ import {
126
131
  createCliLocalRuntimeAdapter,
127
132
  createOriginShellGrant,
128
133
  getOrCreateSharedStore,
134
+ loadCliDialogHistoryWithSource,
129
135
  matchContextualFragment,
130
136
  mergeNoticeGroup,
131
137
  readTimestamp,
@@ -134,16 +140,16 @@ import {
134
140
  resolveCliRequestedToolNames,
135
141
  resolveNoticeTitle,
136
142
  setTurnNoticeMeta
137
- } from "./chunk-V6S5OZSP.js";
143
+ } from "./chunk-JHQNWV2C.js";
138
144
  import {
139
145
  createHostApprovalCardQueue,
140
146
  formatApprovalRemaining,
141
147
  registerHostApprovalRenderer
142
- } from "./chunk-HSBHS6KT.js";
143
- import "./chunk-FE7G6DSP.js";
148
+ } from "./chunk-L3UFGEDU.js";
149
+ import "./chunk-XT6C2QZW.js";
150
+ import "./chunk-R72QWIFO.js";
144
151
  import {
145
152
  ANSI_ESCAPE_REGEX,
146
- anthropicGrantRemainingMs,
147
153
  applyTerminalOutputToText,
148
154
  boxGlyphs,
149
155
  buildSourceMapping,
@@ -154,7 +160,6 @@ import {
154
160
  padOrTruncateToWidth,
155
161
  resolveBoxCharset,
156
162
  resolveServerSyncConfig,
157
- runAntigravityOAuthLogin,
158
163
  runOpenAiCodexBrowserPkce,
159
164
  runOpenAiCodexDeviceCode,
160
165
  stripAnsi,
@@ -166,23 +171,18 @@ import {
166
171
  wrapTextToLines,
167
172
  wrapTranscriptLine,
168
173
  wrapTranscriptLineWithLayout
169
- } from "./chunk-C63KMRJE.js";
174
+ } from "./chunk-W2Z5E2R7.js";
170
175
  import "./chunk-GIXWVN2W.js";
171
- import "./chunk-PENRYZ4D.js";
176
+ import "./chunk-BPB3T5EU.js";
172
177
  import "./chunk-U6RD332P.js";
173
178
  import "./chunk-WOAZVUSN.js";
174
- import {
175
- getRestartBlocker,
176
- hasRestartBlockingRuns
177
- } from "./chunk-DWES4SXY.js";
178
179
  import "./chunk-4D4QD7FT.js";
179
180
  import "./chunk-PVFYPUIM.js";
180
- import "./chunk-53W5BXLN.js";
181
+ import "./chunk-TCOHWKDM.js";
181
182
  import "./chunk-QHEN7NZ7.js";
182
183
  import "./chunk-IIRJ4P4I.js";
183
- import "./chunk-C5A54QS7.js";
184
- import "./chunk-6RSNVJGO.js";
185
- import "./chunk-324FWHUA.js";
184
+ import "./chunk-4INJGWE3.js";
185
+ import "./chunk-2ZBPWX7N.js";
186
186
  import {
187
187
  DIALOG_NOTIFY_SOURCE,
188
188
  ensureDialogNotifyDir,
@@ -194,19 +194,18 @@ import {
194
194
  resolveDialogNotifyRoot,
195
195
  writeAck,
196
196
  writeLease
197
- } from "./chunk-OKAXQFON.js";
197
+ } from "./chunk-52BNL6GP.js";
198
198
  import {
199
199
  defaultPromptReader,
200
200
  setSecret
201
- } from "./chunk-BB76X6O4.js";
201
+ } from "./chunk-RWXHGPWJ.js";
202
202
  import {
203
203
  createTuiSummaryLlmCaller
204
- } from "./chunk-OB4FBZXJ.js";
205
- import "./chunk-OYUMJMC5.js";
206
- import "./chunk-R7XWZDOH.js";
207
- import "./chunk-S73EPYNC.js";
208
- import "./chunk-ZEZC7IIM.js";
204
+ } from "./chunk-JVEKCQAP.js";
205
+ import "./chunk-W2RQYNPI.js";
206
+ import "./chunk-JUMQJSQF.js";
209
207
  import "./chunk-VIWDGTDA.js";
208
+ import "./chunk-HHXF57CL.js";
210
209
  import {
211
210
  formatSkillSlashReference,
212
211
  parseSkillSlashReference,
@@ -214,82 +213,94 @@ import {
214
213
  } from "./chunk-PRJ473FK.js";
215
214
  import "./chunk-BMQ2MJUK.js";
216
215
  import "./chunk-ATNTHIZI.js";
217
- import "./chunk-ZMJMHXYX.js";
216
+ import "./chunk-7HUCUD2I.js";
218
217
  import "./chunk-JEXVIMYZ.js";
219
- import "./chunk-JGVWHUYK.js";
220
- import "./chunk-KZ4A7EIV.js";
221
- import "./chunk-KO5PFS74.js";
222
- import "./chunk-EXD7S7QW.js";
218
+ import "./chunk-HPIY372N.js";
219
+ import "./chunk-56OAS5RZ.js";
220
+ import "./chunk-2CKFROQS.js";
221
+ import "./chunk-FF5ZRKW7.js";
222
+ import "./chunk-NHLLXINQ.js";
223
223
  import "./chunk-MVOZ22RZ.js";
224
- import "./chunk-KG27JIG4.js";
225
- import "./chunk-WFEWP352.js";
226
- import "./chunk-NF64D32W.js";
227
- import "./chunk-R3FZHW4Q.js";
228
224
  import "./chunk-WDWZPASX.js";
229
- import "./chunk-BD5YJJLJ.js";
230
- import "./chunk-WSLL7VV4.js";
225
+ import "./chunk-WLJNHFEB.js";
226
+ import "./chunk-NF64D32W.js";
227
+ import "./chunk-LJOPY4TL.js";
228
+ import "./chunk-S7BF2OGX.js";
229
+ import "./chunk-VKM7DOYB.js";
230
+ import "./chunk-YNP3ITPU.js";
231
+ import "./chunk-B4NA5UJR.js";
232
+ import "./chunk-WX266G2C.js";
233
+ import "./chunk-AGIM7IMJ.js";
231
234
  import "./chunk-VF4K2QE6.js";
232
- import "./chunk-LLUBUHNT.js";
233
- import "./chunk-U6QNVOR5.js";
234
- import "./chunk-MNFUKRRU.js";
235
- import "./chunk-TF427WGH.js";
236
- import "./chunk-LJ6WIQZO.js";
235
+ import "./chunk-UYZOBSSO.js";
236
+ import "./chunk-63W5N6P3.js";
237
+ import "./chunk-6XAAKRJB.js";
238
+ import "./chunk-7RYH7YIY.js";
239
+ import "./chunk-SX6PDLBZ.js";
237
240
  import {
238
241
  createChatQueueRuntime,
239
242
  createTurnRequest,
240
243
  estimateMessagesTokens,
241
244
  historyTokensBeforeLatestAssistant,
242
245
  initialChatQueueState,
243
- normalizeRunCompletionShape
244
- } from "./chunk-7B55IVLF.js";
245
- import "./chunk-BUDVRYES.js";
246
+ normalizeRunCompletionShape,
247
+ redactSecrets
248
+ } from "./chunk-RL6H2A2Z.js";
249
+ import "./chunk-KDDXC2IH.js";
246
250
  import "./chunk-TZXPT53C.js";
251
+ import "./chunk-6QDYSCPW.js";
247
252
  import {
248
253
  BUILTIN_DIALOG_LLM_FALLBACK_MODEL,
249
254
  BUILTIN_SUMMARY_LLM_CONFIG
250
- } from "./chunk-523DITKR.js";
251
- import "./chunk-MD7O2NN2.js";
252
- import "./chunk-YN23INFZ.js";
255
+ } from "./chunk-ER6NTALN.js";
256
+ import "./chunk-IM7HCFB4.js";
257
+ import "./chunk-WXD6Y7DW.js";
253
258
  import "./chunk-BYXBJQAS.js";
254
- import "./chunk-6VEO7Z3Y.js";
259
+ import "./chunk-AMNZPQCY.js";
260
+ import "./chunk-SD4MBKZ7.js";
255
261
  import {
256
262
  getActiveDialogAgentId
257
- } from "./chunk-5RGU3J7P.js";
258
- import "./chunk-UVLYNWIE.js";
259
- import "./chunk-YNIYE47Z.js";
260
- import "./chunk-BZMDWGQQ.js";
261
- import "./chunk-46FETNLF.js";
263
+ } from "./chunk-REAE2SZK.js";
264
+ import "./chunk-PL5RKESU.js";
265
+ import "./chunk-FKVLQNGJ.js";
266
+ import "./chunk-BTIFQBYW.js";
262
267
  import "./chunk-UAD2WT54.js";
263
- import "./chunk-ADYWV732.js";
268
+ import "./chunk-76B6YUQS.js";
264
269
  import "./chunk-3PVYUPXK.js";
265
- import "./chunk-WS36XPJD.js";
270
+ import "./chunk-XQFDCRG3.js";
271
+ import "./chunk-GYFKKTDI.js";
272
+ import "./chunk-42JZNSAY.js";
273
+ import "./chunk-AMTF6FJD.js";
266
274
  import {
267
275
  getDefaultCliLocalRuntimeDb
268
- } from "./chunk-J55F3IEZ.js";
276
+ } from "./chunk-DKJQEFNG.js";
277
+ import "./chunk-7LS5ATRP.js";
278
+ import "./chunk-YFSM2366.js";
269
279
  import "./chunk-HXER7YJF.js";
270
280
  import {
271
281
  isHiddenFromDialogList,
272
282
  normalizeDialogRecord,
273
283
  readDialogSnapshot,
274
284
  sortDialogs
275
- } from "./chunk-IZHENZQ5.js";
285
+ } from "./chunk-G5JGA5YM.js";
276
286
  import "./chunk-ID4G2MAR.js";
277
287
  import "./chunk-Y5GCAMGP.js";
278
288
  import {
279
289
  listUserRecordsFromServers
280
- } from "./chunk-7PTWFSZZ.js";
290
+ } from "./chunk-FGD4NMTP.js";
281
291
  import {
282
292
  loadLocalRunChildDialogIds
283
- } from "./chunk-AKBNCTPY.js";
293
+ } from "./chunk-76K4GTY5.js";
284
294
  import "./chunk-LKZPX6YH.js";
285
295
  import {
286
296
  deleteDbRecord,
287
297
  readDbRecord
288
- } from "./chunk-E4HBZDV6.js";
289
- import "./chunk-VQR2ACSC.js";
298
+ } from "./chunk-EMFZXJTN.js";
299
+ import "./chunk-NTBTVKKB.js";
290
300
  import "./chunk-AMWMV56B.js";
291
- import "./chunk-DXWGFL2Z.js";
301
+ import "./chunk-YY7IGJMN.js";
292
302
  import "./chunk-3L2WKC3W.js";
303
+ import "./chunk-UEILX4EV.js";
293
304
  import {
294
305
  TAIL_LINES_MAX,
295
306
  backfillRunRecordParentDialog,
@@ -301,7 +312,7 @@ import {
301
312
  readRunRecord,
302
313
  resolveRunsDir,
303
314
  runAgentStopCommand
304
- } from "./chunk-ONTHDYFU.js";
315
+ } from "./chunk-VDC3BW24.js";
305
316
  import {
306
317
  clipText,
307
318
  formatDuration,
@@ -313,69 +324,73 @@ import {
313
324
  shortAgentKey,
314
325
  shortRunId
315
326
  } from "./chunk-S25VJYXV.js";
316
- import "./chunk-KQHEGELM.js";
327
+ import "./chunk-DEAII55O.js";
317
328
  import "./chunk-QYPE3TS3.js";
318
- import "./chunk-U35UUM5K.js";
319
- import "./chunk-RD3QLZQV.js";
320
- import "./chunk-7BIJFGKS.js";
321
- import "./chunk-HPDLPEUG.js";
322
- import "./chunk-ZTHAJU3O.js";
323
- import "./chunk-HDKMVYNJ.js";
329
+ import "./chunk-YOUSQIIK.js";
330
+ import "./chunk-YM5XULB2.js";
331
+ import "./chunk-I3NWAILT.js";
324
332
  import {
325
333
  isExternalSessionKind
326
- } from "./chunk-YJPK35HB.js";
327
- import "./chunk-UEILX4EV.js";
334
+ } from "./chunk-MRACVEPZ.js";
328
335
  import "./chunk-QQ56R7KS.js";
329
- import "./chunk-PXYBUFDB.js";
330
336
  import {
331
337
  buildSkillDiscoveryContextBlock,
332
338
  buildSkillDiscoveryContextLayer,
333
339
  discoverSkills
334
- } from "./chunk-NUHQO3RB.js";
340
+ } from "./chunk-WIVVNJUS.js";
335
341
  import "./chunk-GBWGPTA7.js";
336
- import "./chunk-OQFOE4SJ.js";
337
- import "./chunk-TRRXYFTR.js";
338
- import "./chunk-JLZJL3WC.js";
342
+ import {
343
+ acquireLocalDialogTurnLease,
344
+ resolveLocalDialogTurnAuthority,
345
+ sanitizeDialogTurnIdentifier,
346
+ startDialogTurnHeartbeat
347
+ } from "./chunk-YWEZSBLL.js";
348
+ import "./chunk-LOFRSJX2.js";
349
+ import "./chunk-RDZ5OIAT.js";
339
350
  import "./chunk-3A5NNQCN.js";
340
- import "./chunk-R3MV2GII.js";
341
- import "./chunk-SQL7YNED.js";
351
+ import "./chunk-EUHMI5KG.js";
352
+ import "./chunk-KGWE224L.js";
353
+ import "./chunk-LPXBBC32.js";
342
354
  import "./chunk-CVMMWN6P.js";
343
355
  import "./chunk-GLKOYSRU.js";
344
356
  import {
345
357
  readDialogMessageRecords
346
- } from "./chunk-6VNBJ7GI.js";
347
- import "./chunk-223KZUJ6.js";
348
- import "./chunk-CEKRIR22.js";
349
- import "./chunk-CBIGMWMI.js";
358
+ } from "./chunk-T4WU747C.js";
359
+ import "./chunk-4HZCBA4Q.js";
360
+ import "./chunk-SU4NCTW4.js";
361
+ import "./chunk-LHJB4BXJ.js";
350
362
  import {
351
- RUN_WAKE_CHANNEL_ENV,
363
+ COMPACTION_TELEMETRY_SCHEMA_VERSION,
364
+ appendCompactionTelemetryRecord,
352
365
  buildLoadSkillExecutor,
353
- findSummaryAnchorIndex,
366
+ inspectCompactionSummaryQuality,
354
367
  markCliUserBatchPhase,
355
368
  orderDialogHistory,
369
+ prepareCompactHistory,
356
370
  projectContextProvenance,
357
371
  readAgentsMdLayerFromDisk,
358
372
  readCliPendingUserMessages,
359
373
  readCommandActionGatePayload,
360
374
  resolveCliUnknownBatchWithoutResend,
375
+ resolveCompactHistory,
361
376
  rollbackCliUserBatchPhase,
362
377
  runTaskStop,
363
378
  saveCliPendingUserMessages,
364
- validateStoredSummary
365
- } from "./chunk-7EUJ65PF.js";
379
+ toPlanCompressionMessages
380
+ } from "./chunk-GMBWWBSJ.js";
366
381
  import "./chunk-ZNFJWEN4.js";
367
- import "./chunk-LHCGKAFO.js";
368
- import "./chunk-OOV5JN25.js";
382
+ import "./chunk-BKP325XS.js";
383
+ import "./chunk-Q5FJJ6XI.js";
369
384
  import "./chunk-2E4BYAUE.js";
370
385
  import "./chunk-AL3TYDIF.js";
371
- import "./chunk-PIVTQRX6.js";
372
- import "./chunk-HNUWUO75.js";
386
+ import "./chunk-DDKA6V6X.js";
373
387
  import "./chunk-CHOZJMJS.js";
374
- import "./chunk-DMPZMYH4.js";
375
- import "./chunk-MLK3FEXG.js";
388
+ import "./chunk-3R4AYHJR.js";
389
+ import "./chunk-AQNWWJLH.js";
390
+ import "./chunk-XJW6SLBZ.js";
376
391
  import "./chunk-BYXBJQAS.js";
377
- import "./chunk-BZLGPM5B.js";
378
- import "./chunk-AIFQKNPP.js";
392
+ import "./chunk-RNLKWUVY.js";
393
+ import "./chunk-CL33RFD7.js";
379
394
  import "./chunk-56GBUMO5.js";
380
395
  import {
381
396
  TOOL_GUIDED_SECTION_ORDER,
@@ -384,55 +399,52 @@ import {
384
399
  buildRuntimeGuidanceBlocks,
385
400
  resolveResponseGuidelines,
386
401
  resolveToolGuidedSections
387
- } from "./chunk-BXGU6274.js";
388
- import "./chunk-Q2MPKE4B.js";
402
+ } from "./chunk-D3ONA3FP.js";
403
+ import "./chunk-HVRG27HI.js";
389
404
  import {
390
405
  classifyFailureSubclass,
391
406
  formatQuotaSummary
392
407
  } from "./chunk-LS5KAVFQ.js";
393
- import "./chunk-FXEPZKNJ.js";
394
- import "./chunk-X4O7FJF5.js";
395
- import "./chunk-TLE77UJ5.js";
408
+ import "./chunk-2MIZHEND.js";
409
+ import "./chunk-4IVMDQBA.js";
410
+ import "./chunk-2OROOEOQ.js";
396
411
  import {
397
412
  sanitizeToolOutputText,
398
413
  scrubSecrets
399
- } from "./chunk-KO5GO2BC.js";
400
- import "./chunk-KXOPLLFP.js";
401
- import "./chunk-DNNPARJK.js";
402
- import "./chunk-2MBTWINN.js";
414
+ } from "./chunk-TXMFSGRY.js";
415
+ import "./chunk-CA7LGAHV.js";
416
+ import "./chunk-3QMN3T6L.js";
417
+ import "./chunk-LXP53WGF.js";
418
+ import "./chunk-4Y6CZ2N4.js";
403
419
  import {
404
420
  extractReferenceKeysFromMessage
405
- } from "./chunk-7WHCIA5V.js";
421
+ } from "./chunk-G5IAIGGD.js";
406
422
  import "./chunk-5ZUL4CUO.js";
407
423
  import {
408
424
  COMPACTION_SUMMARY_SYSTEM_PROMPT,
409
425
  DEFAULT_CONTEXT_WINDOW,
410
- buildCompactionMetricsFromPlan,
411
- buildHistoricalCompactionRequest,
412
426
  classifySummaryError,
413
- computeSummarySourceMetadata,
414
427
  createSummaryBudget,
428
+ extractFileOperationsFromCalls,
415
429
  findModelContextWindow,
416
430
  formatCompactionMetricsLog,
417
431
  getModelContextWindow,
418
432
  normalizeUsage,
419
- planCompression,
420
433
  runSummaryWithContract,
421
434
  serializeMessageContent
422
- } from "./chunk-2FZVXOFX.js";
435
+ } from "./chunk-CEIWXKHP.js";
423
436
  import "./chunk-H57T64RA.js";
424
- import "./chunk-UKZX3NHN.js";
425
- import "./chunk-SR4FE5VD.js";
437
+ import "./chunk-WMBJDXMY.js";
426
438
  import {
427
439
  clipCompactText
428
440
  } from "./chunk-5MMAK75Q.js";
429
- import "./chunk-USGHJSGO.js";
441
+ import "./chunk-GX2MFKF3.js";
430
442
  import "./chunk-E6A5NHDH.js";
431
443
  import "./chunk-KX6YBIHG.js";
432
444
  import {
433
445
  formatToolOverflowMarker,
434
446
  getProcessRegistry
435
- } from "./chunk-6N4IKMTH.js";
447
+ } from "./chunk-2I4R6ZRV.js";
436
448
  import "./chunk-HEVRQGGH.js";
437
449
  import {
438
450
  isQuotaExhaustedError
@@ -447,17 +459,20 @@ import {
447
459
  import {
448
460
  isAbortError
449
461
  } from "./chunk-7DPNBQSV.js";
450
- import "./chunk-OW765XBU.js";
451
462
  import {
452
463
  buildMemoryOverlayLayer,
453
464
  buildMemoryUseGuidanceLayer,
454
465
  partitionScopedBlocks,
455
466
  renderTurnContextBlocksWithScope
456
- } from "./chunk-YQLAFJRQ.js";
467
+ } from "./chunk-FBNVJ2TO.js";
457
468
  import {
458
469
  buildUserResponseLanguageContext
459
- } from "./chunk-GYX6XTAI.js";
470
+ } from "./chunk-Z3KTXWWB.js";
460
471
  import "./chunk-2SXN7LAY.js";
472
+ import {
473
+ toErrorMessage
474
+ } from "./chunk-HNMXYYJR.js";
475
+ import "./chunk-OW765XBU.js";
461
476
  import {
462
477
  createOAuthTokenStore,
463
478
  isTokenExpired
@@ -466,45 +481,62 @@ import "./chunk-6UBGXX2W.js";
466
481
  import "./chunk-BV3FLP2L.js";
467
482
  import {
468
483
  dialogMessageRecordToAgentRuntimeMessage
469
- } from "./chunk-4ZCTKB27.js";
484
+ } from "./chunk-W5GKF5ZW.js";
470
485
  import {
471
486
  listBuiltinSkills
472
- } from "./chunk-JW6OURKM.js";
487
+ } from "./chunk-KAHYBAEN.js";
488
+ import "./chunk-J42X32PV.js";
473
489
  import "./chunk-EUGTFFO6.js";
474
490
  import {
475
491
  parseExternalSkillMarkdown
476
492
  } from "./chunk-AETZ7AD6.js";
477
- import "./chunk-5P3PPQVP.js";
493
+ import "./chunk-ZQAADXSF.js";
478
494
  import "./chunk-KHCLMKZZ.js";
479
- import "./chunk-SYTHYBMI.js";
495
+ import "./chunk-DLXL4NSL.js";
480
496
  import "./chunk-OJKUU3LP.js";
481
497
  import "./chunk-YZMNK53S.js";
482
498
  import {
483
499
  resolveLocalUserId
484
- } from "./chunk-QGFLVQ6E.js";
500
+ } from "./chunk-6KUTNAPU.js";
485
501
  import {
486
502
  CURRENT_OPERATOR_USER_ID,
487
503
  resolveCliAgentKeyInput
488
504
  } from "./chunk-BR3GT6MR.js";
489
- import "./chunk-JCQ3WCQ3.js";
490
- import "./chunk-UUCYUN6Y.js";
505
+ import {
506
+ RUN_WAKE_CHANNEL_ENV
507
+ } from "./chunk-FOC4TORM.js";
508
+ import "./chunk-UB7NV7NN.js";
509
+ import {
510
+ resolvePlatformAuthToken
511
+ } from "./chunk-O7ZY6SUK.js";
512
+ import "./chunk-KGKTN2NX.js";
513
+ import "./chunk-BVYHE6QD.js";
491
514
  import {
492
515
  canonicalizeToolNames
493
- } from "./chunk-YLAHYLDQ.js";
516
+ } from "./chunk-HJTI7RZV.js";
517
+ import "./chunk-ZC3CMUKU.js";
494
518
  import {
495
519
  BUILTIN_NOLO_AGENT_KEY,
496
520
  BUILTIN_NOLO_AGENT_MODEL,
497
521
  BUILTIN_NOLO_AGENT_NAME
498
- } from "./chunk-RIWKZT7E.js";
522
+ } from "./chunk-YRPIUIEQ.js";
499
523
  import {
500
524
  extractCustomId
501
525
  } from "./chunk-M2EJHDJP.js";
502
526
  import "./chunk-I42VC5KR.js";
503
- import "./chunk-P4R5KXU7.js";
527
+ import "./chunk-3EUW3WEO.js";
528
+ import "./chunk-CW6LRDSF.js";
504
529
  import "./chunk-VIDPVFP3.js";
505
530
  import "./chunk-4JH2UMJR.js";
531
+ import "./chunk-WWC7I6TA.js";
506
532
  import "./chunk-U6VC4MU4.js";
507
- import "./chunk-XRGBJHZX.js";
533
+ import "./chunk-RI7SXDJW.js";
534
+ import "./chunk-7LR2IFUH.js";
535
+ import "./chunk-JRTNUU5Z.js";
536
+ import {
537
+ isRecord
538
+ } from "./chunk-KUG52IAP.js";
539
+ import "./chunk-E36V7MPY.js";
508
540
  import {
509
541
  getDiagnostics,
510
542
  getProcessRingBuffer,
@@ -515,17 +547,27 @@ import {
515
547
  getCliInstallChannel,
516
548
  probeCliUpdate,
517
549
  runSelfUpdateDetailed
518
- } from "./chunk-Z3JZ2R5F.js";
550
+ } from "./chunk-YU235GGN.js";
519
551
  import {
520
552
  parseUserIdFromAuthToken,
521
553
  resolveAuthToken,
522
554
  resolveServerCandidates,
523
555
  resolveServerUrl
524
- } from "./chunk-BIDSIRTS.js";
556
+ } from "./chunk-JUNYPVL6.js";
525
557
  import {
526
558
  DEFAULT_NOLO_SERVER_URL
527
- } from "./chunk-OLZBQWZU.js";
559
+ } from "./chunk-RF576RYE.js";
560
+ import "./chunk-72VWN4VK.js";
528
561
  import "./chunk-LCBAMY2M.js";
562
+ import "./chunk-IV6VUVLJ.js";
563
+ import {
564
+ asOptionalTrimmedString
565
+ } from "./chunk-G3SUCT4W.js";
566
+ import "./chunk-FI4DPLR7.js";
567
+ import "./chunk-4SN6J65J.js";
568
+ import {
569
+ normalizeServerOrigin
570
+ } from "./chunk-CF7PE763.js";
529
571
  import {
530
572
  PERMISSION_GRANT_KINDS,
531
573
  getAgentSelectionAuditPath,
@@ -544,7 +586,7 @@ import {
544
586
  resolveDefaultSpawn,
545
587
  spawnProcess
546
588
  } from "./chunk-4O22PGNQ.js";
547
- import "./chunk-RQKTCHQM.js";
589
+ import "./chunk-WY6DMHMG.js";
548
590
  import {
549
591
  dailyWelcomeTip,
550
592
  getCliLocale,
@@ -554,33 +596,14 @@ import {
554
596
  t,
555
597
  toolFamilyOf,
556
598
  toolLabelVariants
557
- } from "./chunk-JOJH3KWV.js";
558
- import "./chunk-EJQE5HB7.js";
559
- import "./chunk-6SOWMEAY.js";
560
- import {
561
- toErrorMessage
562
- } from "./chunk-HNMXYYJR.js";
563
- import {
564
- resolvePlatformAuthToken
565
- } from "./chunk-LVZVSLKO.js";
566
- import "./chunk-2JHGUL5K.js";
567
- import "./chunk-3EUW3WEO.js";
568
- import "./chunk-WWC7I6TA.js";
569
- import "./chunk-OKH74FML.js";
570
- import "./chunk-JRTNUU5Z.js";
571
- import {
572
- isRecord
573
- } from "./chunk-KUG52IAP.js";
574
- import {
575
- asOptionalTrimmedString
576
- } from "./chunk-G3SUCT4W.js";
577
- import "./chunk-4SN6J65J.js";
578
- import {
579
- normalizeServerOrigin
580
- } from "./chunk-CF7PE763.js";
599
+ } from "./chunk-RIOAPUGV.js";
600
+ import "./chunk-DSBRIUX5.js";
601
+ import "./chunk-35JIFLIG.js";
602
+ import "./chunk-SR57FDTX.js";
603
+ import "./chunk-MDAYRIP7.js";
581
604
  import {
582
605
  PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL
583
- } from "./chunk-JPXACKSW.js";
606
+ } from "./chunk-G22P2J7O.js";
584
607
  import {
585
608
  asTrimmedLowercaseString
586
609
  } from "./chunk-QSJ3HFEF.js";
@@ -1719,6 +1742,8 @@ function codeBlockGutterWidth(plainAfterPrefix, charset) {
1719
1742
  const bar = charset === "ascii" ? "|" : "\u2502";
1720
1743
  if (plainAfterPrefix.startsWith(`${bar} `)) return 2;
1721
1744
  if (plainAfterPrefix === bar) return 1;
1745
+ if (plainAfterPrefix.startsWith(` ${bar} `)) return 4;
1746
+ if (plainAfterPrefix === ` ${bar}`) return 3;
1722
1747
  return 0;
1723
1748
  }
1724
1749
  function extractSelectedText(history, anchor, head, contentWidth) {
@@ -2143,13 +2168,42 @@ function applyOutputChunkToCurrentTurn(history, chunk, kind = "assistant") {
2143
2168
  appendCurrentBlock(history, kind, chunk);
2144
2169
  return true;
2145
2170
  }
2146
- function styleAssistantTurn(content, colorEnabled, state = assistantLayoutState()) {
2171
+ function firstAnchorIsBoxBlock(content, state) {
2172
+ if (state.anchored) return false;
2173
+ let inTool = state.inToolBlock;
2174
+ const lines = content.split("\n");
2175
+ for (let i = 0; i < lines.length; i++) {
2176
+ const plain = stripAnsi(lines[i] ?? "");
2177
+ if (plain.trim().length === 0 || plain.startsWith("[nolo]")) continue;
2178
+ if (/^[●▸✦✗]/.test(plain)) {
2179
+ inTool = true;
2180
+ continue;
2181
+ }
2182
+ if (inTool && /^\s+/.test(plain)) continue;
2183
+ const trimmed = plain.trim();
2184
+ if (/^[ ]{0,3}(?:`{3,}|~{3,})/.test(plain)) return true;
2185
+ const next = stripAnsi(lines[i + 1] ?? "").trim();
2186
+ if (trimmed.includes("|") && next.includes("|") && /^[|:\-\s]+$/.test(next)) {
2187
+ return true;
2188
+ }
2189
+ return false;
2190
+ }
2191
+ return false;
2192
+ }
2193
+ function styleAssistantTurn(content, colorEnabled, state = assistantLayoutState(), contentWidth) {
2147
2194
  content = content.split("\n").map(
2148
2195
  (line) => /^[●▸✦✗]/.test(stripAnsi(line)) && /\x1b\[(?:48;2;[0-9;]+|100)m/.test(line) ? line.replace(/ +(?=(?:\x1b\[[0-9;]*m)*$)/, "") : line
2149
2196
  ).join("\n");
2150
- const highlighted = colorEnabled ? formatAssistantDisplay(content, { trimEdges: false }) : resolveCliHyperlinkEnabled() ? stripAnsiKeepingOsc8(formatAssistantDisplay(content, { trimEdges: false })) : stripAnsi(formatAssistantDisplay(content, { trimEdges: false }));
2197
+ const boxNeedsAnchorIndent = firstAnchorIsBoxBlock(content, state);
2198
+ const tableWidth = typeof contentWidth === "number" && contentWidth > 0 ? Math.max(1, contentWidth - (boxNeedsAnchorIndent ? 2 : 0)) : void 0;
2199
+ const formatted = formatAssistantDisplay(content, {
2200
+ trimEdges: false,
2201
+ width: tableWidth
2202
+ });
2203
+ const highlighted = colorEnabled ? formatted : resolveCliHyperlinkEnabled() ? stripAnsiKeepingOsc8(formatted) : stripAnsi(formatted);
2151
2204
  const rawLines = highlighted.split("\n");
2152
2205
  let { anchored, inToolBlock } = state;
2206
+ let alignAnchoredBoxBlock = false;
2153
2207
  const styledLines = rawLines.map((line) => {
2154
2208
  const plain = stripAnsi(line);
2155
2209
  if (!anchored && plain.trim().length > 0 && !plain.startsWith("[nolo]")) {
@@ -2159,9 +2213,20 @@ function styleAssistantTurn(content, colorEnabled, state = assistantLayoutState(
2159
2213
  } else {
2160
2214
  inToolBlock = false;
2161
2215
  anchored = true;
2216
+ if (/^(?:[┌╭]─|\+-)/.test(plain)) {
2217
+ alignAnchoredBoxBlock = true;
2218
+ }
2162
2219
  const anchorPrefix = colorEnabled ? `${themeColorSequence("chrome")}\u25C8\x1B[39m ` : "\u25C8 ";
2163
2220
  return `${anchorPrefix}${line}`;
2164
2221
  }
2222
+ } else if (alignAnchoredBoxBlock) {
2223
+ if (/^(?:[│├└╰]|\||\+-)/.test(plain)) {
2224
+ if (/^[└╰]─/.test(plain)) {
2225
+ alignAnchoredBoxBlock = false;
2226
+ }
2227
+ return ` ${line}`;
2228
+ }
2229
+ alignAnchoredBoxBlock = false;
2165
2230
  }
2166
2231
  return line.startsWith("[nolo]") && colorEnabled ? themeText(line, "chrome", true) : line;
2167
2232
  });
@@ -2315,7 +2380,7 @@ function layoutTextRows(role, content, contentWidth, colorEnabled, command, stat
2315
2380
  return rows2.length > 0 ? rows2 : [{ rendered: "", sourceStart: 0, sourceEnd: 0, prefixWidth: 2 }];
2316
2381
  }
2317
2382
  let { inToolBlock, fenceMarker, inRenderedFence } = state;
2318
- const styledEntry = styleAssistantTurn(content, colorEnabled, state);
2383
+ const styledEntry = styleAssistantTurn(content, colorEnabled, state, contentWidth);
2319
2384
  const styledLines = styledEntry.split("\n");
2320
2385
  const rawLines = content.split("\n");
2321
2386
  let rawIdx = 0;
@@ -2350,9 +2415,10 @@ function layoutTextRows(role, content, contentWidth, colorEnabled, command, stat
2350
2415
  if (fenceMarker === null) fenceMarker = marker;
2351
2416
  else if (marker[0] === fenceMarker[0] && marker.length >= fenceMarker.length) fenceMarker = null;
2352
2417
  }
2353
- const asciiFence = /^\+(?:-{24}|- [^+]+ -{4,})$/.test(plain);
2354
- const renderedOpen = /^[┌╭]─/.test(plain) || asciiFence && !inRenderedFence;
2355
- const renderedClose = /^[└╰]─/.test(plain) || asciiFence && inRenderedFence;
2418
+ const trimmedPlain = plain.trimStart();
2419
+ const asciiFence = /^\+(?:-{24}|- [^+]+ -{4,})$/.test(trimmedPlain);
2420
+ const renderedOpen = /^[┌╭]─/.test(trimmedPlain) || asciiFence && !inRenderedFence;
2421
+ const renderedClose = /^[└╰]─/.test(trimmedPlain) || asciiFence && inRenderedFence;
2356
2422
  if (renderedOpen && !inRenderedFence) inRenderedFence = true;
2357
2423
  if (/^[●▸✦✗]/.test(plain)) inToolBlock = true;
2358
2424
  else if (plain.trim() && !/^\s/.test(plain)) inToolBlock = false;
@@ -3926,17 +3992,36 @@ async function fetchRecentDialogs(args) {
3926
3992
  }
3927
3993
  async function loadDialogHistoryForDisplay(args) {
3928
3994
  const authToken = resolveAuthToken(args.env);
3929
- if (!authToken) throw new Error(t("historyNoToken"));
3930
- const read = await readDialogSnapshot({
3931
- authToken,
3932
- base: resolveServerUrl(args.env),
3933
- dialogId: args.dialog.id,
3934
- dialogKey: args.dialog.dbKey,
3935
- fetchImpl: args.fetchImpl ?? fetch,
3936
- limit: MAX_TUI_HISTORY_TURNS * HISTORY_OVERSAMPLE_FACTOR,
3937
- messagesOnly: true
3938
- });
3939
- const messages = Array.isArray(read.msgs) ? [...read.msgs].reverse() : [];
3995
+ let loaded;
3996
+ const userId = resolveLocalUserId(args.env);
3997
+ if (args.dialog.dbKey === `dialog-${userId}-${args.dialog.id}`) {
3998
+ const store = args.store ?? await getOrCreateSharedStore(args).catch(() => void 0);
3999
+ if (store) loaded = await loadCliDialogHistoryWithSource({
4000
+ ...args,
4001
+ store,
4002
+ dialogId: args.dialog.id,
4003
+ preferLocalHistory: true
4004
+ });
4005
+ }
4006
+ let messages;
4007
+ if (loaded && (loaded.messages.length > 0 || loaded.source === "remote")) {
4008
+ messages = loaded.messages;
4009
+ } else if (authToken) {
4010
+ const read = await readDialogSnapshot({
4011
+ authToken,
4012
+ base: resolveServerUrl(args.env),
4013
+ dialogId: args.dialog.id,
4014
+ dialogKey: args.dialog.dbKey,
4015
+ fetchImpl: args.fetchImpl ?? fetch,
4016
+ limit: MAX_TUI_HISTORY_TURNS * HISTORY_OVERSAMPLE_FACTOR,
4017
+ messagesOnly: true
4018
+ });
4019
+ messages = Array.isArray(read.msgs) ? [...read.msgs].reverse() : [];
4020
+ } else if (loaded) {
4021
+ messages = [];
4022
+ } else {
4023
+ throw new Error(t("historyNoToken"));
4024
+ }
3940
4025
  const turns = [];
3941
4026
  for (const message of messages) {
3942
4027
  const role = message?.role ?? message?.authorRole;
@@ -4161,6 +4246,16 @@ function createSnapshotGuardedApproval(kind, getGrants, approve) {
4161
4246
  // packages/core/accountSession/accountSessionService.ts
4162
4247
  var AccountSessionService = class {
4163
4248
  deps;
4249
+ /**
4250
+ * 单调认证代次。每次 signIn / signUp / acceptExternalAuthentication 开始时推进。
4251
+ * 认证必须跨重挂载互斥:旧请求晚到时既不能写 token,也不能覆盖新激活的账号。
4252
+ */
4253
+ authEpoch = 0;
4254
+ /**
4255
+ * 串行化所有「重置运行时 → 持久化 token → 激活会话」尾链,
4256
+ * 避免 RN 先读整表再异步写回的 tokenManager 发生并发交错,导致旧写入覆盖新登录的 token。
4257
+ */
4258
+ commitQueue = Promise.resolve();
4164
4259
  constructor(deps) {
4165
4260
  this.deps = deps;
4166
4261
  }
@@ -4204,19 +4299,19 @@ var AccountSessionService = class {
4204
4299
  }
4205
4300
  /** Network sign-in, then persist + activate. A→B ordering preserved. */
4206
4301
  async signIn(input) {
4207
- this.deps.core.beginTransition("signing-in");
4302
+ const epoch = this.beginAuthEpoch();
4208
4303
  try {
4209
4304
  const result = await this.deps.authenticate(input);
4210
- await this.persistAndActivate(result.token, result.account);
4305
+ await this.persistAndActivate(result.token, result.account, epoch);
4211
4306
  return result;
4212
4307
  } catch (error) {
4213
- this.deps.core.failTransition();
4308
+ this.failAuthTransition(epoch);
4214
4309
  throw error;
4215
4310
  }
4216
4311
  }
4217
4312
  /** Accept an already authenticated external session; caller supplies no profile override. */
4218
4313
  async acceptExternalAuthentication(result) {
4219
- this.deps.core.beginTransition("signing-in");
4314
+ const epoch = this.beginAuthEpoch();
4220
4315
  try {
4221
4316
  const [encoded, secret, extra] = result.token.split(".");
4222
4317
  let payload;
@@ -4228,9 +4323,9 @@ var AccountSessionService = class {
4228
4323
  if (!secret || extra !== void 0 || typeof payload !== "object" || payload === null || Array.isArray(payload) || Object.keys(payload).some((key) => !["authKind", "userId", "username", "exp"].includes(key)) || !isExternalSessionKind(payload.authKind)) {
4229
4324
  throw new Error("invalid_session_token");
4230
4325
  }
4231
- await this.persistAndActivate(result.token);
4326
+ await this.persistAndActivate(result.token, void 0, epoch);
4232
4327
  } catch (error) {
4233
- this.deps.core.failTransition();
4328
+ this.failAuthTransition(epoch);
4234
4329
  throw error;
4235
4330
  }
4236
4331
  }
@@ -4239,13 +4334,13 @@ var AccountSessionService = class {
4239
4334
  if (!this.deps.signUpWithApi) {
4240
4335
  throw new Error("sign_up_unavailable");
4241
4336
  }
4242
- this.deps.core.beginTransition("signing-in");
4337
+ const epoch = this.beginAuthEpoch();
4243
4338
  try {
4244
4339
  const result = await this.deps.signUpWithApi(input);
4245
- await this.persistAndActivate(result.token, result.account);
4340
+ await this.persistAndActivate(result.token, result.account, epoch);
4246
4341
  return result;
4247
4342
  } catch (error) {
4248
- this.deps.core.failTransition();
4343
+ this.failAuthTransition(epoch);
4249
4344
  throw error;
4250
4345
  }
4251
4346
  }
@@ -4336,15 +4431,36 @@ var AccountSessionService = class {
4336
4431
  * BEFORE reset/persist and leaves the Core untouched (the caller's catch
4337
4432
  * then fails the transition explicitly).
4338
4433
  */
4339
- async persistAndActivate(token, account) {
4434
+ beginAuthEpoch() {
4435
+ this.authEpoch += 1;
4436
+ this.deps.core.beginTransition("signing-in");
4437
+ return this.authEpoch;
4438
+ }
4439
+ /** 只有仍是最新一次认证时才允许收尾 transition,避免旧请求把新流程打回 idle。 */
4440
+ failAuthTransition(epoch) {
4441
+ if (epoch === this.authEpoch) this.deps.core.failTransition();
4442
+ }
4443
+ persistAndActivate(token, account, epoch) {
4340
4444
  if (!parseUserToken(token)) {
4341
- throw new Error("invalid_session_token");
4445
+ return Promise.reject(new Error("invalid_session_token"));
4342
4446
  }
4343
- await this.deps.resetRuntime?.();
4344
- await this.deps.tokenManager.storeToken(token);
4345
- const activated = this.deps.core.activateToken(token, account ?? void 0);
4346
- if (!activated) {
4347
- throw new Error("invalid_session_token");
4447
+ const run = this.commitQueue.then(async () => {
4448
+ this.assertAuthStillCurrent(epoch);
4449
+ await this.deps.resetRuntime?.();
4450
+ this.assertAuthStillCurrent(epoch);
4451
+ await this.deps.tokenManager.storeToken(token);
4452
+ const activated = this.deps.core.activateToken(token, account ?? void 0);
4453
+ if (!activated) {
4454
+ throw new Error("invalid_session_token");
4455
+ }
4456
+ });
4457
+ this.commitQueue = run.catch(() => {
4458
+ });
4459
+ return run;
4460
+ }
4461
+ assertAuthStillCurrent(epoch) {
4462
+ if (epoch !== this.authEpoch) {
4463
+ throw new Error("auth_superseded");
4348
4464
  }
4349
4465
  }
4350
4466
  };
@@ -9753,9 +9869,13 @@ var CLI_ESTIMATE_ENV = { [RUN_WAKE_CHANNEL_ENV]: "1" };
9753
9869
  function resolveEstimateEnv(env) {
9754
9870
  const source = env ?? process.env;
9755
9871
  const exposeMcp = String(source[MCP_EXPOSURE_ENV] ?? "").trim();
9872
+ const exposeInstaboxParams = String(
9873
+ source[INSTABOX_SCHEMA_EXPOSURE_ENV] ?? ""
9874
+ ).trim();
9756
9875
  return {
9757
9876
  ...CLI_ESTIMATE_ENV,
9758
- ...exposeMcp ? { [MCP_EXPOSURE_ENV]: exposeMcp } : {}
9877
+ ...exposeMcp ? { [MCP_EXPOSURE_ENV]: exposeMcp } : {},
9878
+ ...exposeInstaboxParams ? { [INSTABOX_SCHEMA_EXPOSURE_ENV]: exposeInstaboxParams } : {}
9759
9879
  };
9760
9880
  }
9761
9881
  function resolveDefaultCliToolNames(env) {
@@ -9767,6 +9887,15 @@ function resolveDefaultCliToolNames(env) {
9767
9887
  )
9768
9888
  );
9769
9889
  }
9890
+ function resolveExposedCliToolNames(requestedToolNames, env) {
9891
+ return canonicalizeToolNames(
9892
+ buildLocalPolicyToolNames({
9893
+ agentKey: BUILTIN_NOLO_AGENT_KEY,
9894
+ toolNames: requestedToolNames,
9895
+ env
9896
+ })
9897
+ );
9898
+ }
9770
9899
  var DEFAULT_PROMPT_ESTIMATE_BASELINE = "\u4F60\u662F\u5171\u4EAB\u7A7A\u95F4\u91CC\u7684\u9AD8\u6027\u4EF7\u6BD4\u901A\u7528 AI \u52A9\u624B\u3002\u4F18\u5148\u5FEB\u901F\u3001\u76F4\u63A5\u3001\u7A33\u5B9A\u5730\u5B8C\u6210\u4EFB\u52A1\uFF1B\u9700\u8981\u63A8\u7406\u65F6\u4FDD\u6301\u6B65\u9AA4\u6E05\u6670\u3002";
9771
9900
  function readAgentsMd(cwd) {
9772
9901
  return readAgentsMdLayerFromDisk(cwd)?.content ?? "";
@@ -9786,8 +9915,12 @@ function buildCliEstimateSystemText(opts = {}) {
9786
9915
  const agentKey = opts.agentKey?.trim() || BUILTIN_NOLO_AGENT_KEY;
9787
9916
  const prompt = opts.agentPrompt?.trim() || DEFAULT_PROMPT_ESTIMATE_BASELINE;
9788
9917
  const toolNames = resolveDefaultCliToolNames(resolveEstimateEnv(opts.env));
9789
- const guidance = buildRuntimeGuidanceBlocks(toolNames);
9790
- const toolSections = resolveToolGuidedSections(toolNames, {
9918
+ const guidanceToolNames = resolveExposedCliToolNames(
9919
+ toolNames,
9920
+ resolveEstimateEnv(opts.env)
9921
+ );
9922
+ const guidance = buildRuntimeGuidanceBlocks(guidanceToolNames);
9923
+ const toolSections = resolveToolGuidedSections(guidanceToolNames, {
9791
9924
  callerModel: opts.model?.trim() || void 0,
9792
9925
  callerIsPoolTop: opts.callerIsPoolTop
9793
9926
  });
@@ -10390,7 +10523,7 @@ function parsePermissionGrants(raw) {
10390
10523
  }
10391
10524
  return grants;
10392
10525
  }
10393
- function applyAgentSwitch(state, target, historyTurns) {
10526
+ function applyAgentSwitch(state, target, historyTurns, estimateEnv) {
10394
10527
  const contextWindow = resolveAgentContextWindow({
10395
10528
  agentKey: target.key,
10396
10529
  agentName: target.name,
@@ -10409,7 +10542,8 @@ function applyAgentSwitch(state, target, historyTurns) {
10409
10542
  model: target.model,
10410
10543
  userLanguage: state.userLanguage,
10411
10544
  responseViewport: TUI_RESPONSE_VIEWPORT,
10412
- messages: historyTurns
10545
+ messages: historyTurns,
10546
+ env: estimateEnv ?? process.env
10413
10547
  })
10414
10548
  },
10415
10549
  output: `Switched to ${target.name}. ${state.dialogId ? `Dialog kept: ${state.dialogId}` : "Dialog kept: new"}`
@@ -10493,6 +10627,9 @@ function formatUnknownSlashCommand(cmd, allowSuggestion = true) {
10493
10627
  function isShellPassthroughInput(input) {
10494
10628
  return input.trimStart().startsWith("!");
10495
10629
  }
10630
+ function resolveEstimateEnv2(deps) {
10631
+ return deps?.estimateEnv ?? deps?.env;
10632
+ }
10496
10633
  function handleTuiInput(input, state, historyTurns, deps) {
10497
10634
  const trimmed = input.trim();
10498
10635
  if (!trimmed) {
@@ -10858,7 +10995,7 @@ ${t("autoUsage")}` };
10858
10995
  output: t("agentUnknown", argText)
10859
10996
  };
10860
10997
  }
10861
- return applyAgentSwitch(state, resolvedTarget, historyTurns);
10998
+ return applyAgentSwitch(state, resolvedTarget, historyTurns, resolveEstimateEnv2(deps) ?? process.env);
10862
10999
  }
10863
11000
  case "/lang": {
10864
11001
  const locale = parseCliLocale(argText);
@@ -10879,6 +11016,7 @@ ${t("autoUsage")}` };
10879
11016
  userLanguage: locale,
10880
11017
  responseViewport: TUI_RESPONSE_VIEWPORT,
10881
11018
  messages: historyTurns,
11019
+ env: resolveEstimateEnv2(deps) ?? process.env,
10882
11020
  ...resolveAgentModelIdentity({
10883
11021
  agentKey: state.agentKey,
10884
11022
  agentName: state.agentName
@@ -11198,7 +11336,7 @@ function resolveTuiIdentityEnv(startupEnv, liveEnv) {
11198
11336
  }
11199
11337
 
11200
11338
  // packages/cli/tui/session.ts
11201
- function applyAgentSwitchState(state, target, messages) {
11339
+ function applyAgentSwitchState(state, target, messages, env) {
11202
11340
  return {
11203
11341
  ...state,
11204
11342
  agentName: target.name,
@@ -11211,7 +11349,8 @@ function applyAgentSwitchState(state, target, messages) {
11211
11349
  model: target.model,
11212
11350
  userLanguage: state.userLanguage,
11213
11351
  responseViewport: TUI_RESPONSE_VIEWPORT,
11214
- messages
11352
+ messages,
11353
+ env: env ?? process.env
11215
11354
  }),
11216
11355
  turnTokens: void 0,
11217
11356
  lastAuthorityTurnCount: void 0,
@@ -11266,7 +11405,7 @@ function handleTuiInput2(input, state, historyTurns, deps) {
11266
11405
  ...applyAgentSwitchState(state, {
11267
11406
  key: result.nextState.agentKey,
11268
11407
  name: result.nextState.agentName
11269
- }),
11408
+ }, historyTurns, deps?.estimateEnv ?? deps?.env),
11270
11409
  // The synchronous platform resolver already has the model identity.
11271
11410
  contextWindow: result.nextState.contextWindow,
11272
11411
  estimatedContextTokens: result.nextState.estimatedContextTokens
@@ -14888,7 +15027,8 @@ async function runAgentChat(scriptDir, state, message, env, output, agentRunner
14888
15027
  }
14889
15028
  } : {},
14890
15029
  ...skillAllowedTools !== void 0 ? { allowedToolNames: skillAllowedTools } : {},
14891
- ...contextBlockScopes.length > 0 ? { contextBlockScopes } : {}
15030
+ ...contextBlockScopes.length > 0 ? { contextBlockScopes } : {},
15031
+ ...options.dialogTurnLease ? { dialogTurnLease: options.dialogTurnLease } : {}
14892
15032
  });
14893
15033
  if (result.dialogId && spawnedRunsMissingParent.length > 0) {
14894
15034
  for (const runId of spawnedRunsMissingParent) {
@@ -15329,6 +15469,57 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
15329
15469
  const freshDialog = !ctx.state.dialogId || ctx.pendingFreshDialogId === ctx.state.dialogId;
15330
15470
  ctx.pendingFreshDialogId = void 0;
15331
15471
  if (!ctx.state.dialogId) ctx.state = { ...ctx.state, dialogId: mintTaskUserMessageId() };
15472
+ const resolvedAuthority = ctx.dialogTurnAuthority ?? (ctx.getDialogTurnAuthority ? await ctx.getDialogTurnAuthority() : !ctx.options.agentRunner || ctx.options.agentRunner === runAgentTurn ? resolveLocalDialogTurnAuthority(
15473
+ await getOrCreateSharedStore({
15474
+ env: ctx.effectiveEnv,
15475
+ cwd: ctx.state.cwd,
15476
+ fetchImpl: ctx.options.fetchImpl
15477
+ })
15478
+ ) : void 0);
15479
+ let activeTurnLease;
15480
+ let turnHeartbeat;
15481
+ const acquireTuiTurnLease = async (attemptIndex, reuseLease) => {
15482
+ if (!resolvedAuthority || !ctx.state.dialogId) return { ok: true };
15483
+ const runId = reuseLease ? reuseLease.runId : sanitizeDialogTurnIdentifier(`tui-${mintTaskUserMessageId()}`, "tui");
15484
+ const holder = reuseLease?.holder ?? `tui:${process.pid}`;
15485
+ const res = await acquireLocalDialogTurnLease({
15486
+ authority: resolvedAuthority,
15487
+ dialogRef: {
15488
+ userId: resolveLocalUserId(ctx.effectiveEnv),
15489
+ dialogId: ctx.state.dialogId
15490
+ },
15491
+ runId,
15492
+ holder,
15493
+ holderKind: "tui",
15494
+ commandId: `cmd-${runId}-${attemptIndex}`
15495
+ });
15496
+ if (!res.ok) return res;
15497
+ activeTurnLease = res.lease;
15498
+ turnHeartbeat?.stop();
15499
+ turnHeartbeat = startDialogTurnHeartbeat({
15500
+ authority: resolvedAuthority,
15501
+ dialogRef: res.lease.dialogRef,
15502
+ runToken: res.lease.runToken
15503
+ });
15504
+ return { ok: true };
15505
+ };
15506
+ let initialLease;
15507
+ try {
15508
+ initialLease = await acquireTuiTurnLease(0);
15509
+ } catch {
15510
+ ctx.emitCommandOutput("\u6682\u65F6\u65E0\u6CD5\u8FDE\u63A5\u5BF9\u8BDD\u670D\u52A1\u3002\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002");
15511
+ return { ok: false, aborted: false };
15512
+ }
15513
+ if (!initialLease.ok) {
15514
+ if (initialLease.status === "busy") {
15515
+ ctx.emitCommandOutput("\u6B64\u5BF9\u8BDD\u6B63\u5728\u53E6\u4E00\u7AEF\u8FD0\u884C\u3002\u8BF7\u7B49\u5F85\u5F53\u524D\u56DE\u590D\u7ED3\u675F\uFF0C\u6216\u5728\u53D1\u8D77\u7AEF\u505C\u6B62\u540E\u91CD\u8BD5\u3002");
15516
+ } else if (["forbidden", "unauthorized"].includes(initialLease.status)) {
15517
+ ctx.emitCommandOutput("\u767B\u5F55\u5DF2\u5931\u6548\u6216\u6CA1\u6709\u6B64\u5BF9\u8BDD\u7684\u8BBF\u95EE\u6743\u9650\u3002\u8BF7\u8FD0\u884C `nolo login` \u540E\u91CD\u8BD5\u3002");
15518
+ } else {
15519
+ ctx.emitCommandOutput("\u6682\u65F6\u65E0\u6CD5\u5F00\u59CB\u6B64\u5BF9\u8BDD\u3002\u8BF7\u91CD\u65B0\u6253\u5F00\u5BF9\u8BDD\u540E\u91CD\u8BD5\u3002");
15520
+ }
15521
+ return { ok: false, aborted: false };
15522
+ }
15332
15523
  ctx.forcedStop = false;
15333
15524
  ctx.turnEpoch += 1;
15334
15525
  const myEpoch = ctx.turnEpoch;
@@ -15339,243 +15530,258 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
15339
15530
  const emitStatusUnlessForceStopped = (report) => {
15340
15531
  if (myEpoch === ctx.turnEpoch && ctx.forcedStopEpoch !== myEpoch) emitStatus(report);
15341
15532
  };
15342
- emitStatus({ state: "working" });
15343
- const gateHandlerWithStatus = async (gate) => {
15344
- if (ctx.state.permissionGrants?.local === true && isAutoConfirmableFileWriteGate(gate)) {
15345
- return await actionGateHandler(gate);
15346
- }
15347
- emitStatusUnlessForceStopped({
15348
- state: "blocked",
15349
- kind: gate.kind === "confirm" ? "permission" : "question"
15350
- });
15351
- try {
15352
- return await actionGateHandler(gate);
15353
- } finally {
15354
- emitStatusUnlessForceStopped({ state: "working" });
15355
- }
15356
- };
15357
- const confirmDestructiveActionWithStatus = (
15358
- // 真实流(process.stdout 等)在运行期带可选 isTTY 旗标,但
15359
- // NodeJS.WritableStream 类型不声明它(terminalProgramStatus.ts 的
15360
- // TerminalProgramStatusOutput 同一口径)——这里只做类型收窄,不改值。
15361
- confirmDestructiveAction && ctx.output.isTTY === true ? async (request) => {
15362
- if (ctx.state.permissionGrants?.local === true) return await confirmDestructiveAction(request);
15363
- emitStatusUnlessForceStopped({ state: "blocked", kind: "permission" });
15533
+ let turnOutcomeSettled = false;
15534
+ let didBeginHold = false;
15535
+ let injectionInbox = null;
15536
+ let settleNotices = null;
15537
+ try {
15538
+ emitStatus({ state: "working" });
15539
+ const gateHandlerWithStatus = async (gate) => {
15540
+ if (ctx.state.permissionGrants?.local === true && isAutoConfirmableFileWriteGate(gate)) {
15541
+ return await actionGateHandler(gate);
15542
+ }
15543
+ emitStatusUnlessForceStopped({
15544
+ state: "blocked",
15545
+ kind: gate.kind === "confirm" ? "permission" : "question"
15546
+ });
15364
15547
  try {
15365
- const approved = await confirmDestructiveAction(request);
15366
- if (!approved) return false;
15367
- const commandText = typeof request.command === "string" ? request.command : "";
15368
- if (commandText) {
15369
- const { runApprovedCredentialCommand } = await import("./hostCredentialCreate-3IA5IJFG.js");
15370
- const hostResult = await runApprovedCredentialCommand({
15371
- commandText,
15372
- approvalEventId: request.id,
15373
- env: process.env ?? {}
15374
- });
15375
- if (hostResult) return { approved: true, hostResult };
15376
- }
15377
- return true;
15548
+ return await actionGateHandler(gate);
15378
15549
  } finally {
15379
15550
  emitStatusUnlessForceStopped({ state: "working" });
15380
15551
  }
15381
- } : confirmDestructiveAction
15382
- );
15383
- ctx.history.followBottom = true;
15384
- const isInternalEvent = req.event.kind !== "user";
15385
- const isContextualFragment = matchContextualFragment(message) !== null;
15386
- const batchDisplay = req.userMessages?.map((user) => ({
15387
- text: typeof user.content === "string" ? user.content : (user.content ?? []).filter((part) => part.type === "text").map((part) => part.text).join("\n"),
15388
- imageUrls: typeof user.content === "string" ? [] : (user.content ?? []).filter((part) => part.type === "image_url").map((part) => part.image_url.url)
15389
- }));
15390
- const batchLast = batchDisplay?.at(-1);
15391
- const transcriptText = batchLast ? batchLast.text : isContextualFragment && (req.event.kind === "child-run-completed" || req.event.kind === "background-task-completed") ? req.event.displayText ?? req.event.text : message;
15392
- const noticeTasks = req.event.kind === "child-run-completed" ? buildNoticeTasksFromRuns(req.event.runs, Date.now()) : null;
15393
- if (ctx.history.currentRole !== null && ctx.history.currentContent) {
15394
- finalizeCurrentTurn(ctx.history);
15395
- }
15396
- const merged = noticeTasks ? mergeNoticeGroup(
15397
- ctx.history.turns,
15398
- noticeTasks,
15399
- (text) => dimCliText(text, resolveCliColorEnabled())
15400
- ) : null;
15401
- if (!merged) {
15402
- for (const prior of batchDisplay?.slice(0, -1) ?? []) {
15403
- startTurn(ctx.history, "user");
15404
- appendToCurrentTurn(ctx.history, prior.text);
15552
+ };
15553
+ const confirmDestructiveActionWithStatus = (
15554
+ // 真实流(process.stdout 等)在运行期带可选 isTTY 旗标,但
15555
+ // NodeJS.WritableStream 类型不声明它(terminalProgramStatus.ts 的
15556
+ // TerminalProgramStatusOutput 同一口径)——这里只做类型收窄,不改值。
15557
+ confirmDestructiveAction && ctx.output.isTTY === true ? async (request) => {
15558
+ if (ctx.state.permissionGrants?.local === true) return await confirmDestructiveAction(request);
15559
+ emitStatusUnlessForceStopped({ state: "blocked", kind: "permission" });
15560
+ try {
15561
+ const approved = await confirmDestructiveAction(request);
15562
+ if (!approved) return false;
15563
+ const commandText = typeof request.command === "string" ? request.command : "";
15564
+ if (commandText) {
15565
+ const { runApprovedCredentialCommand } = await import("./hostCredentialCreate-PJAIKZQP.js");
15566
+ const hostResult = await runApprovedCredentialCommand({
15567
+ commandText,
15568
+ approvalEventId: request.id,
15569
+ env: process.env ?? {}
15570
+ });
15571
+ if (hostResult) return { approved: true, hostResult };
15572
+ }
15573
+ return true;
15574
+ } finally {
15575
+ emitStatusUnlessForceStopped({ state: "working" });
15576
+ }
15577
+ } : confirmDestructiveAction
15578
+ );
15579
+ ctx.history.followBottom = true;
15580
+ const isInternalEvent = req.event.kind !== "user";
15581
+ const isContextualFragment = matchContextualFragment(message) !== null;
15582
+ const batchDisplay = req.userMessages?.map((user) => ({
15583
+ text: typeof user.content === "string" ? user.content : (user.content ?? []).filter((part) => part.type === "text").map((part) => part.text).join("\n"),
15584
+ imageUrls: typeof user.content === "string" ? [] : (user.content ?? []).filter((part) => part.type === "image_url").map((part) => part.image_url.url)
15585
+ }));
15586
+ const batchLast = batchDisplay?.at(-1);
15587
+ const transcriptText = batchLast ? batchLast.text : isContextualFragment && (req.event.kind === "child-run-completed" || req.event.kind === "background-task-completed") ? req.event.displayText ?? req.event.text : message;
15588
+ const noticeTasks = req.event.kind === "child-run-completed" ? buildNoticeTasksFromRuns(req.event.runs, Date.now()) : null;
15589
+ if (ctx.history.currentRole !== null && ctx.history.currentContent) {
15405
15590
  finalizeCurrentTurn(ctx.history);
15406
- const turn = ctx.history.turns[ctx.history.turns.length - 1];
15407
- if (turn?.role === "user") ctx.onUserTurnFinalized?.(turn, prior.imageUrls);
15408
15591
  }
15409
- startTurn(ctx.history, isInternalEvent ? "assistant" : "user");
15410
- appendToCurrentTurn(
15411
- ctx.history,
15412
- isInternalEvent ? dimCliText(transcriptText, resolveCliColorEnabled()) : transcriptText
15413
- );
15414
- finalizeCurrentTurn(ctx.history);
15415
- if (noticeTasks) {
15416
- setTurnNoticeMeta(ctx.history.turns[ctx.history.turns.length - 1], {
15417
- tasks: noticeTasks
15418
- });
15592
+ const merged = noticeTasks ? mergeNoticeGroup(
15593
+ ctx.history.turns,
15594
+ noticeTasks,
15595
+ (text) => dimCliText(text, resolveCliColorEnabled())
15596
+ ) : null;
15597
+ if (!merged) {
15598
+ for (const prior of batchDisplay?.slice(0, -1) ?? []) {
15599
+ startTurn(ctx.history, "user");
15600
+ appendToCurrentTurn(ctx.history, prior.text);
15601
+ finalizeCurrentTurn(ctx.history);
15602
+ const turn = ctx.history.turns[ctx.history.turns.length - 1];
15603
+ if (turn?.role === "user") ctx.onUserTurnFinalized?.(turn, prior.imageUrls);
15604
+ }
15605
+ startTurn(ctx.history, isInternalEvent ? "assistant" : "user");
15606
+ appendToCurrentTurn(
15607
+ ctx.history,
15608
+ isInternalEvent ? dimCliText(transcriptText, resolveCliColorEnabled()) : transcriptText
15609
+ );
15610
+ finalizeCurrentTurn(ctx.history);
15611
+ if (noticeTasks) {
15612
+ setTurnNoticeMeta(ctx.history.turns[ctx.history.turns.length - 1], {
15613
+ tasks: noticeTasks
15614
+ });
15615
+ }
15419
15616
  }
15420
- }
15421
- const finalizedUserTurn = ctx.history.turns[ctx.history.turns.length - 1];
15422
- if (!isInternalEvent && finalizedUserTurn?.role === "user" && finalizedUserTurn.content === transcriptText) {
15423
- ctx.onUserTurnFinalized?.(finalizedUserTurn, batchLast?.imageUrls ?? imageUrls);
15424
- }
15425
- ctx.renderHistoryToOutput();
15426
- if (ctx.fixedInput.active) ctx.fixedInput.repaint(ctx.buffer, ctx.cursorPos);
15427
- const prepareAttemptRenderAndBaseline = () => {
15428
- const previousContextUsage = { turnTokens: ctx.state.turnTokens, lastAuthorityTurnCount: ctx.state.lastAuthorityTurnCount };
15429
- const nextBaseline = computeBaselineContextTokens({
15430
- authoritativeInput: ctx.state.turnTokens?.input,
15431
- lastAuthorityTurnCount: ctx.state.lastAuthorityTurnCount,
15432
- turns: ctx.history.turns,
15433
- fallbackEstimate: () => estimateDefaultCliContextTokens({
15434
- cwd: ctx.state.cwd,
15435
- agentKey: ctx.state.agentKey,
15436
- agentName: ctx.state.agentName,
15437
- userLanguage: ctx.state.userLanguage,
15438
- responseViewport: TUI_RESPONSE_VIEWPORT,
15439
- messages: ctx.history.turns,
15440
- ...resolveAgentModelIdentity({
15617
+ const finalizedUserTurn = ctx.history.turns[ctx.history.turns.length - 1];
15618
+ if (!isInternalEvent && finalizedUserTurn?.role === "user" && finalizedUserTurn.content === transcriptText) {
15619
+ ctx.onUserTurnFinalized?.(finalizedUserTurn, batchLast?.imageUrls ?? imageUrls);
15620
+ }
15621
+ ctx.renderHistoryToOutput();
15622
+ if (ctx.fixedInput.active) ctx.fixedInput.repaint(ctx.buffer, ctx.cursorPos);
15623
+ const prepareAttemptRenderAndBaseline = () => {
15624
+ const previousContextUsage = { turnTokens: ctx.state.turnTokens, lastAuthorityTurnCount: ctx.state.lastAuthorityTurnCount };
15625
+ const nextBaseline = computeBaselineContextTokens({
15626
+ authoritativeInput: ctx.state.turnTokens?.input,
15627
+ lastAuthorityTurnCount: ctx.state.lastAuthorityTurnCount,
15628
+ turns: ctx.history.turns,
15629
+ fallbackEstimate: () => estimateDefaultCliContextTokens({
15630
+ cwd: ctx.state.cwd,
15441
15631
  agentKey: ctx.state.agentKey,
15442
- agentName: ctx.state.agentName
15632
+ agentName: ctx.state.agentName,
15633
+ userLanguage: ctx.state.userLanguage,
15634
+ responseViewport: TUI_RESPONSE_VIEWPORT,
15635
+ messages: ctx.history.turns,
15636
+ // 回退估算必须与下面真正发请求的 runAgentChat 共用同一份 env:
15637
+ // NOLO_EXPOSE_MCP_TOOLS / NOLO_EXPOSE_INSTABOX_PARAMS 会改变工具面。
15638
+ env: ctx.options.env ?? process.env,
15639
+ ...resolveAgentModelIdentity({
15640
+ agentKey: ctx.state.agentKey,
15641
+ agentName: ctx.state.agentName
15642
+ })
15443
15643
  })
15444
- })
15445
- });
15446
- ctx.state = {
15447
- ...ctx.state,
15448
- turnTokens: void 0,
15449
- estimatedContextTokens: nextBaseline,
15450
- liveTurnCredits: void 0,
15451
- liveTurnEstimatedTokens: void 0
15644
+ });
15645
+ ctx.state = {
15646
+ ...ctx.state,
15647
+ turnTokens: void 0,
15648
+ estimatedContextTokens: nextBaseline,
15649
+ liveTurnCredits: void 0,
15650
+ liveTurnEstimatedTokens: void 0
15651
+ };
15652
+ startTurn(ctx.history, "assistant");
15653
+ const liveTracker = createLiveTurnTracker();
15654
+ const agentOutput = isInteractiveInput(ctx.input) ? createHistoryOutputStream(ctx.history, () => {
15655
+ const { updated, liveTokens } = liveTracker.onStreamChunk(ctx.history.currentContent);
15656
+ if (updated) {
15657
+ ctx.state = {
15658
+ ...ctx.state,
15659
+ liveTurnEstimatedTokens: liveTokens
15660
+ };
15661
+ }
15662
+ ctx.scheduleRender();
15663
+ }, {
15664
+ visibleRunIds: () => ctx.activityIndicator.getVisibleRunIds?.() ?? /* @__PURE__ */ new Set()
15665
+ }) : ctx.output;
15666
+ return { previousContextUsage, nextBaseline, agentOutput };
15452
15667
  };
15453
- startTurn(ctx.history, "assistant");
15454
- const liveTracker = createLiveTurnTracker();
15455
- const agentOutput = isInteractiveInput(ctx.input) ? createHistoryOutputStream(ctx.history, () => {
15456
- const { updated, liveTokens } = liveTracker.onStreamChunk(ctx.history.currentContent);
15457
- if (updated) {
15458
- ctx.state = {
15459
- ...ctx.state,
15460
- liveTurnEstimatedTokens: liveTokens
15461
- };
15462
- }
15463
- ctx.scheduleRender();
15464
- }, {
15465
- visibleRunIds: () => ctx.activityIndicator.getVisibleRunIds?.() ?? /* @__PURE__ */ new Set()
15466
- }) : ctx.output;
15467
- return { previousContextUsage, nextBaseline, agentOutput };
15468
- };
15469
- const requestUserChoice = isInteractiveInput(ctx.input) && ctx.dialogHost ? async (choiceReq) => {
15470
- const signals = [choiceReq.signal, ctx.activeTurnAbort?.signal].filter((signal2) => !!signal2);
15471
- const signal = signals.length ? AbortSignal.any(signals) : void 0;
15472
- return await runWithInputRequiredAttention(
15473
- {
15474
- output: ctx.output,
15475
- env: ctx.effectiveEnv,
15476
- onWaiting: () => emitStatusUnlessForceStopped({ state: "blocked", kind: "question" }),
15477
- onResumed: () => emitStatusUnlessForceStopped({ state: "working" })
15478
- },
15479
- async () => {
15480
- try {
15481
- return await ctx.dialogHost.run(
15482
- (anchor) => runAskChoiceDialog({
15483
- request: { ...choiceReq, signal },
15484
- input: ctx.input,
15485
- output: ctx.output,
15486
- ...anchor,
15487
- // ask_user hosted: the wheel scrolls the transcript above the
15488
- // dialog; the option list is navigated with ↑↓ only.
15489
- inputPolicy: { ...anchor.inputPolicy, wheel: "transcript" }
15490
- }),
15491
- signal ? { signal, cancelled: () => ({ kind: "cancelled" }) } : void 0
15492
- );
15493
- } catch {
15494
- return { kind: "cancelled" };
15668
+ const requestUserChoice = isInteractiveInput(ctx.input) && ctx.dialogHost ? async (choiceReq) => {
15669
+ const signals = [choiceReq.signal, ctx.activeTurnAbort?.signal].filter((signal2) => !!signal2);
15670
+ const signal = signals.length ? AbortSignal.any(signals) : void 0;
15671
+ return await runWithInputRequiredAttention(
15672
+ {
15673
+ output: ctx.output,
15674
+ env: ctx.effectiveEnv,
15675
+ onWaiting: () => emitStatusUnlessForceStopped({ state: "blocked", kind: "question" }),
15676
+ onResumed: () => emitStatusUnlessForceStopped({ state: "working" })
15677
+ },
15678
+ async () => {
15679
+ try {
15680
+ return await ctx.dialogHost.run(
15681
+ (anchor) => runAskChoiceDialog({
15682
+ request: { ...choiceReq, signal },
15683
+ input: ctx.input,
15684
+ output: ctx.output,
15685
+ ...anchor,
15686
+ // ask_user hosted: the wheel scrolls the transcript above the
15687
+ // dialog; the option list is navigated with ↑↓ only.
15688
+ inputPolicy: { ...anchor.inputPolicy, wheel: "transcript" }
15689
+ }),
15690
+ signal ? { signal, cancelled: () => ({ kind: "cancelled" }) } : void 0
15691
+ );
15692
+ } catch {
15693
+ return { kind: "cancelled" };
15694
+ }
15695
+ }
15696
+ );
15697
+ } : void 0;
15698
+ ctx.idleHeapReleaser.cancel();
15699
+ ctx.runRegistryPoller.beginHold();
15700
+ didBeginHold = true;
15701
+ const localInjectionInbox = createTurnInjectionInbox();
15702
+ injectionInbox = localInjectionInbox;
15703
+ ctx.turnInjectionInbox = localInjectionInbox;
15704
+ const drainInjectedBatches = [];
15705
+ let processCausalDepth = req.event.kind === "background-task-completed" ? req.event.processCausalDepth ?? 0 : 0;
15706
+ let injectedProcessNoticeLines = [];
15707
+ const consumeInjectedProcessNotices = (keepAll = false) => {
15708
+ if (keepAll || injectedProcessNoticeLines.length === 0) {
15709
+ return ctx.state.pendingProcessNotices ?? [];
15710
+ }
15711
+ const injected = new Set(injectedProcessNoticeLines);
15712
+ return (ctx.state.pendingProcessNotices ?? []).filter(
15713
+ (line) => !injected.has(line)
15714
+ );
15715
+ };
15716
+ let injectedChildRunNoticeItems = [];
15717
+ const consumeInjectedChildRunNotices = (keepAll = false) => {
15718
+ if (keepAll || injectedChildRunNoticeItems.length === 0) {
15719
+ return ctx.state.pendingChildRunNotices ?? [];
15720
+ }
15721
+ const injectedIds = new Set(injectedChildRunNoticeItems.map((r) => r.runId));
15722
+ return (ctx.state.pendingChildRunNotices ?? []).filter(
15723
+ (r) => !injectedIds.has(r.runId)
15724
+ );
15725
+ };
15726
+ const refreshInjectedSnapshots = () => {
15727
+ injectedProcessNoticeLines = ctx.state.pendingProcessNotices ? [...ctx.state.pendingProcessNotices] : [];
15728
+ injectedChildRunNoticeItems = (ctx.state.pendingChildRunNotices ?? []).filter(
15729
+ (r) => !!r.parentDialogId && r.parentDialogId === ctx.state.dialogId
15730
+ );
15731
+ };
15732
+ refreshInjectedSnapshots();
15733
+ const originDialogId = ctx.state.dialogId;
15734
+ let terminalEvents = [req.event];
15735
+ const settleTurnNotices = (persisted, eventsToSettle = terminalEvents) => {
15736
+ const keepPending = !persisted;
15737
+ if (persisted) {
15738
+ for (const run of injectedChildRunNoticeItems) ctx.runCompletionWatcher?.markAcknowledged(run.runId);
15739
+ for (const event of eventsToSettle) {
15740
+ if (event.kind === "child-run-completed") for (const run of event.runs) ctx.runCompletionWatcher?.markAcknowledged(run.runId);
15495
15741
  }
15496
15742
  }
15497
- );
15498
- } : void 0;
15499
- ctx.idleHeapReleaser.cancel();
15500
- ctx.runRegistryPoller.beginHold();
15501
- const injectionInbox = createTurnInjectionInbox();
15502
- ctx.turnInjectionInbox = injectionInbox;
15503
- const drainInjectedBatches = [];
15504
- let processCausalDepth = req.event.kind === "background-task-completed" ? req.event.processCausalDepth ?? 0 : 0;
15505
- let injectedProcessNoticeLines = [];
15506
- const consumeInjectedProcessNotices = (keepAll = false) => {
15507
- if (keepAll || injectedProcessNoticeLines.length === 0) {
15508
- return ctx.state.pendingProcessNotices ?? [];
15509
- }
15510
- const injected = new Set(injectedProcessNoticeLines);
15511
- return (ctx.state.pendingProcessNotices ?? []).filter(
15512
- (line) => !injected.has(line)
15513
- );
15514
- };
15515
- let injectedChildRunNoticeItems = [];
15516
- const consumeInjectedChildRunNotices = (keepAll = false) => {
15517
- if (keepAll || injectedChildRunNoticeItems.length === 0) {
15518
- return ctx.state.pendingChildRunNotices ?? [];
15519
- }
15520
- const injectedIds = new Set(injectedChildRunNoticeItems.map((r) => r.runId));
15521
- return (ctx.state.pendingChildRunNotices ?? []).filter(
15522
- (r) => !injectedIds.has(r.runId)
15523
- );
15524
- };
15525
- const refreshInjectedSnapshots = () => {
15526
- injectedProcessNoticeLines = ctx.state.pendingProcessNotices ? [...ctx.state.pendingProcessNotices] : [];
15527
- injectedChildRunNoticeItems = (ctx.state.pendingChildRunNotices ?? []).filter(
15528
- (r) => !!r.parentDialogId && r.parentDialogId === ctx.state.dialogId
15529
- );
15530
- };
15531
- refreshInjectedSnapshots();
15532
- const originDialogId = ctx.state.dialogId;
15533
- let terminalEvents = [req.event];
15534
- const settleNotices = (persisted, eventsToSettle = terminalEvents) => {
15535
- const keepPending = !persisted;
15536
- if (persisted) {
15537
- for (const run of injectedChildRunNoticeItems) ctx.runCompletionWatcher?.markAcknowledged(run.runId);
15743
+ for (const event of eventsToSettle) traceChildRunWake("turn-notice-settle", event, ctx.state.dialogId ?? null, { persisted, ...queueWakeFields(ctx.chatQueueBinding?.getStatus?.()) });
15744
+ let nextProcessNotices = consumeInjectedProcessNotices(keepPending);
15745
+ let nextChildRunNotices = consumeInjectedChildRunNotices(keepPending);
15538
15746
  for (const event of eventsToSettle) {
15539
- if (event.kind === "child-run-completed") for (const run of event.runs) ctx.runCompletionWatcher?.markAcknowledged(run.runId);
15540
- }
15541
- }
15542
- for (const event of eventsToSettle) traceChildRunWake("turn-notice-settle", event, ctx.state.dialogId ?? null, { persisted, ...queueWakeFields(ctx.chatQueueBinding?.getStatus?.()) });
15543
- let nextProcessNotices = consumeInjectedProcessNotices(keepPending);
15544
- let nextChildRunNotices = consumeInjectedChildRunNotices(keepPending);
15545
- for (const event of eventsToSettle) {
15546
- if (keepPending && event.kind === "background-task-completed") {
15547
- const ownerDialogId = originDialogId ?? null;
15548
- const noticeToStore = event.notice ?? {
15549
- taskId: event.taskId,
15550
- pid: 0,
15551
- label: event.text,
15552
- command: event.taskId,
15553
- status: event.status,
15554
- exitCode: event.exitCode
15555
- };
15556
- const line = serializePendingProcessNotice(noticeToStore, ownerDialogId);
15557
- if (!nextProcessNotices.includes(line)) {
15558
- nextProcessNotices = [...nextProcessNotices, line];
15747
+ if (keepPending && event.kind === "background-task-completed") {
15748
+ const ownerDialogId = originDialogId ?? null;
15749
+ const noticeToStore = event.notice ?? {
15750
+ taskId: event.taskId,
15751
+ pid: 0,
15752
+ label: event.text,
15753
+ command: event.taskId,
15754
+ status: event.status,
15755
+ exitCode: event.exitCode
15756
+ };
15757
+ const line = serializePendingProcessNotice(noticeToStore, ownerDialogId);
15758
+ if (!nextProcessNotices.includes(line)) {
15759
+ nextProcessNotices = [...nextProcessNotices, line];
15760
+ }
15559
15761
  }
15560
- }
15561
- if (keepPending && event.kind === "child-run-completed" && event.runs.length > 0) {
15562
- const existingIds = new Set(nextChildRunNotices.map((r) => r.runId));
15563
- const newItems = event.runs.filter((r) => !existingIds.has(r.runId)).map((r) => ({ ...r }));
15564
- if (newItems.length > 0) {
15565
- nextChildRunNotices = [...nextChildRunNotices, ...newItems];
15762
+ if (keepPending && event.kind === "child-run-completed" && event.runs.length > 0) {
15763
+ const existingIds = new Set(nextChildRunNotices.map((r) => r.runId));
15764
+ const newItems = event.runs.filter((r) => !existingIds.has(r.runId)).map((r) => ({ ...r }));
15765
+ if (newItems.length > 0) {
15766
+ nextChildRunNotices = [...nextChildRunNotices, ...newItems];
15767
+ }
15566
15768
  }
15567
15769
  }
15568
- }
15569
- return {
15570
- pendingProcessNotices: nextProcessNotices.length ? nextProcessNotices : void 0,
15571
- pendingChildRunNotices: nextChildRunNotices.length ? nextChildRunNotices : void 0
15770
+ return {
15771
+ pendingProcessNotices: nextProcessNotices.length ? nextProcessNotices : void 0,
15772
+ pendingChildRunNotices: nextChildRunNotices.length ? nextChildRunNotices : void 0
15773
+ };
15572
15774
  };
15573
- };
15574
- let turnOutcomeSettled = false;
15575
- let attemptMessage = message;
15576
- let attemptFreshDialog = freshDialog;
15577
- try {
15775
+ settleNotices = settleTurnNotices;
15776
+ let attemptMessage = message;
15777
+ let attemptFreshDialog = freshDialog;
15578
15778
  for (let wakeAttempt = 0; ; wakeAttempt++) {
15779
+ if (wakeAttempt > 0 && resolvedAuthority) {
15780
+ const nextLease = await acquireTuiTurnLease(wakeAttempt, activeTurnLease);
15781
+ if (!nextLease.ok) {
15782
+ return { ok: false, aborted: false };
15783
+ }
15784
+ }
15579
15785
  drainInjectedBatches.length = 0;
15580
15786
  const turnToolImageArtifacts = [];
15581
15787
  let toolImageArtifactsDeliveredViaCallback = false;
@@ -15592,6 +15798,7 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
15592
15798
  {
15593
15799
  freshDialog: attemptFreshDialog,
15594
15800
  internalTurn: isInternalEvent,
15801
+ ...activeTurnLease ? { dialogTurnLease: activeTurnLease } : {},
15595
15802
  userMessages: req.userMessages,
15596
15803
  ...req.cliBatchId ? { cliBatchId: req.cliBatchId } : {},
15597
15804
  // accountTaskUserSource 已移除(host task 证据链下线,无消费者)。
@@ -15604,7 +15811,7 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
15604
15811
  getProcessCausalDepth: () => processCausalDepth,
15605
15812
  drainInjections: async () => {
15606
15813
  const entries = [];
15607
- for (const text of injectionInbox.drain(({ fallback }) => {
15814
+ for (const text of localInjectionInbox.drain(({ fallback }) => {
15608
15815
  let event = typeof fallback === "object" && fallback !== null && "event" in fallback ? fallback.event : fallback;
15609
15816
  if (typeof event === "object" && event !== null && event.kind === "child-run-completed") {
15610
15817
  const prepared = prepareChildRunConsumption(event, { env: ctx.effectiveEnv, currentDialogId: ctx.state.dialogId ?? null, deferRuns: (runs) => ctx.runCompletionWatcher?.deferRuns?.(runs) });
@@ -15778,7 +15985,7 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
15778
15985
  // Cwd notices are independent; terminal notices require a save receipt.
15779
15986
  pendingCwdNotice: void 0,
15780
15987
  // 只移除本轮注入过的行(见 processNoticeBlocks 的快照注释)。
15781
- ...settleNotices(runResult.savedTurnPersisted === true)
15988
+ ...settleTurnNotices(runResult.savedTurnPersisted === true)
15782
15989
  };
15783
15990
  turnOutcomeSettled = true;
15784
15991
  ctx.accumulateSessionCredits(runResult.turnCredits);
@@ -15838,7 +16045,8 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
15838
16045
  agentName: ctx.state.agentName,
15839
16046
  userLanguage: ctx.state.userLanguage,
15840
16047
  responseViewport: TUI_RESPONSE_VIEWPORT,
15841
- messages: ctx.history.turns
16048
+ messages: ctx.history.turns,
16049
+ env: ctx.options.env ?? process.env
15842
16050
  }),
15843
16051
  lastAuthorityTurnCount: void 0,
15844
16052
  liveTurnEstimatedTokens: void 0
@@ -15876,13 +16084,16 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
15876
16084
  }) && wakeAttempt < maxWakeRetries) {
15877
16085
  const persisted = runResult.savedTurnPersisted === true;
15878
16086
  if (persisted) {
15879
- foldAttemptBaseState(settleNotices(true));
16087
+ turnHeartbeat?.stop();
16088
+ turnHeartbeat = void 0;
16089
+ activeTurnLease = void 0;
16090
+ foldAttemptBaseState(settleTurnNotices(true));
15880
16091
  terminalEvents = [];
15881
16092
  attemptMessage = buildWakeRetryContinuationMessage(childRunWakeEvent);
15882
16093
  attemptFreshDialog = false;
15883
16094
  } else {
15884
16095
  const extraDrained = terminalEvents.slice(1);
15885
- const settledExtra = extraDrained.length > 0 ? settleNotices(false, extraDrained) : {
16096
+ const settledExtra = extraDrained.length > 0 ? settleTurnNotices(false, extraDrained) : {
15886
16097
  pendingProcessNotices: ctx.state.pendingProcessNotices,
15887
16098
  pendingChildRunNotices: ctx.state.pendingChildRunNotices
15888
16099
  };
@@ -15909,7 +16120,7 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
15909
16120
  if (abortedDuringBackoff && ctx.forcedStopEpoch !== myEpoch) {
15910
16121
  ctx.emitCommandOutput(t("turnStopped"));
15911
16122
  }
15912
- const preserved = settleNotices(false);
16123
+ const preserved = settleTurnNotices(false);
15913
16124
  ctx.state = {
15914
16125
  ...ctx.state,
15915
16126
  pendingProcessNotices: preserved.pendingProcessNotices,
@@ -15940,7 +16151,7 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
15940
16151
  ctx.emitCommandOutput(t("turnStopped"));
15941
16152
  }
15942
16153
  }
15943
- foldAttemptBaseState(settleNotices(runResult.savedTurnPersisted === true));
16154
+ foldAttemptBaseState(settleTurnNotices(runResult.savedTurnPersisted === true));
15944
16155
  turnOutcomeSettled = true;
15945
16156
  recordAttemptBillingAndTitle();
15946
16157
  if (!wasAborted && (runResult.exitCode !== 0 || runResult.streamInterrupted === true)) {
@@ -15975,32 +16186,55 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
15975
16186
  emitStatusUnlessForceStopped({ state: "error" });
15976
16187
  throw error;
15977
16188
  } finally {
15978
- ctx.runRegistryPoller.endHold();
16189
+ turnHeartbeat?.stop();
16190
+ turnHeartbeat = void 0;
16191
+ if (activeTurnLease && resolvedAuthority) {
16192
+ const releaseReason = ctx.forcedStopEpoch === myEpoch ? "tui_force_stopped" : ctx.activeTurnAbort?.signal.aborted ? "tui_aborted" : "tui_turn_finally";
16193
+ const leaseToRelease = activeTurnLease;
16194
+ activeTurnLease = void 0;
16195
+ const endTurn = () => resolvedAuthority.endDialogTurn({
16196
+ dialogRef: leaseToRelease.dialogRef,
16197
+ runToken: leaseToRelease.runToken,
16198
+ reason: releaseReason
16199
+ });
16200
+ try {
16201
+ await endTurn();
16202
+ } catch {
16203
+ await waitForWakeRetryBackoff(ctx.turnReleaseRetryDelayMs ?? 300);
16204
+ try {
16205
+ await endTurn();
16206
+ } catch {
16207
+ }
16208
+ }
16209
+ }
16210
+ if (didBeginHold) ctx.runRegistryPoller.endHold();
15979
16211
  ctx.idleHeapReleaser.schedule();
15980
16212
  ctx.activityIndicator.stop();
15981
16213
  ctx.activeTurnAbort = null;
15982
- if (!turnOutcomeSettled) {
16214
+ if (!turnOutcomeSettled && settleNotices) {
15983
16215
  ctx.state = {
15984
16216
  ...ctx.state,
15985
16217
  ...settleNotices(false)
15986
16218
  };
15987
16219
  }
15988
- if (ctx.turnInjectionInbox === injectionInbox) ctx.turnInjectionInbox = null;
15989
- const leftover = injectionInbox.close();
15990
- if (leftover.length > 0) {
15991
- const binding = ensureChatQueueBinding(
15992
- ctx,
15993
- actionGateHandler,
15994
- confirmDestructiveAction
15995
- );
15996
- for (const entry of leftover) {
15997
- try {
15998
- const status = binding.enqueue(entry.fallback);
15999
- const event = typeof entry.fallback === "object" && "event" in entry.fallback ? entry.fallback.event : entry.fallback;
16000
- traceChildRunWake("inbox-leftover-queue", event, ctx.state.dialogId ?? null, queueWakeFields(status));
16001
- } catch {
16002
- const event = typeof entry.fallback === "object" && "event" in entry.fallback ? entry.fallback.event : entry.fallback;
16003
- traceChildRunWake("inbox-leftover-enqueue-failed", event, ctx.state.dialogId ?? null);
16220
+ if (injectionInbox) {
16221
+ if (ctx.turnInjectionInbox === injectionInbox) ctx.turnInjectionInbox = null;
16222
+ const leftover = injectionInbox.close();
16223
+ if (leftover.length > 0) {
16224
+ const binding = ensureChatQueueBinding(
16225
+ ctx,
16226
+ actionGateHandler,
16227
+ confirmDestructiveAction
16228
+ );
16229
+ for (const entry of leftover) {
16230
+ try {
16231
+ const status = binding.enqueue(entry.fallback);
16232
+ const event = typeof entry.fallback === "object" && "event" in entry.fallback ? entry.fallback.event : entry.fallback;
16233
+ traceChildRunWake("inbox-leftover-queue", event, ctx.state.dialogId ?? null, queueWakeFields(status));
16234
+ } catch {
16235
+ const event = typeof entry.fallback === "object" && "event" in entry.fallback ? entry.fallback.event : entry.fallback;
16236
+ traceChildRunWake("inbox-leftover-enqueue-failed", event, ctx.state.dialogId ?? null);
16237
+ }
16004
16238
  }
16005
16239
  }
16006
16240
  }
@@ -17211,7 +17445,7 @@ function createManualCompactionSummaryCaller(args) {
17211
17445
  model: PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL,
17212
17446
  provider: "nolo",
17213
17447
  attemptId: options?.attemptId,
17214
- run: () => platform.complete(content, callOptions)
17448
+ run: (context) => platform.complete(content, { ...callOptions, ...context })
17215
17449
  },
17216
17450
  current: { attemptId: options?.attemptId, run: async ({ signal, deadlineMs }) => {
17217
17451
  if (!args.agentRef) throw { code: "SUMMARY_CURRENT_UNAVAILABLE", stage: "resolve" };
@@ -17517,7 +17751,7 @@ async function compactDialog(options) {
17517
17751
  fetchImpl,
17518
17752
  agentRef: getActiveDialogAgentId(current) ?? void 0,
17519
17753
  loadAdapter: async () => {
17520
- const { createCliLocalRuntimeAdapter: createCliLocalRuntimeAdapter2 } = await import("./localRuntimeAdapter-SSG5ORLZ.js");
17754
+ const { createCliLocalRuntimeAdapter: createCliLocalRuntimeAdapter2 } = await import("./localRuntimeAdapter-WRBLXFUZ.js");
17521
17755
  return createCliLocalRuntimeAdapter2({ env: { ...options.env ?? {}, AUTH_TOKEN: options.authToken, NOLO_SERVER: options.serverUrl }, fetchImpl });
17522
17756
  }
17523
17757
  }) : void 0);
@@ -17581,33 +17815,17 @@ async function compactDialog(options) {
17581
17815
  if (!parsed) throw new Error("[nolo] compact: invalid current history message");
17582
17816
  return parsed;
17583
17817
  });
17584
- const storedSummaryValid = validateStoredSummary({ history, stored: {
17818
+ const source = toPlanCompressionMessages(history);
17819
+ const active = resolveCompactHistory(source, {
17820
+ summary: current.summary,
17585
17821
  summarizedBeforeId: current.summarizedBeforeId,
17586
17822
  sourceHash: current.sourceHash,
17587
17823
  sourceCount: current.sourceCount,
17588
17824
  schemaVersion: current.schemaVersion
17589
- } });
17590
- let activeSummary = typeof current.summary === "string" ? current.summary.trim() : "";
17591
- let activeSummarizedBeforeId;
17592
- pendingHistory = allMsgs;
17593
- if (storedSummaryValid === false) {
17594
- activeSummary = "";
17595
- activeSummarizedBeforeId = void 0;
17596
- generatedSummary = void 0;
17597
- } else if (typeof current.summarizedBeforeId === "string" && current.summarizedBeforeId) {
17598
- const anchor = findSummaryAnchorIndex(allMsgs, current.summarizedBeforeId);
17599
- if (anchor < 0) {
17600
- activeSummary = "";
17601
- activeSummarizedBeforeId = void 0;
17602
- generatedSummary = void 0;
17603
- } else {
17604
- activeSummarizedBeforeId = allMsgs[anchor]?.id ?? current.summarizedBeforeId;
17605
- generatedSummary = activeSummary || void 0;
17606
- pendingHistory = allMsgs.slice(anchor + 1);
17607
- }
17608
- } else {
17609
- generatedSummary = activeSummary || void 0;
17610
- }
17825
+ });
17826
+ const activeSummary = active.summary.trim();
17827
+ generatedSummary = activeSummary || void 0;
17828
+ pendingHistory = allMsgs.slice(allMsgs.length - active.pending.length);
17611
17829
  if (allMsgs.length > 0) {
17612
17830
  const agentKey = Array.isArray(current.cybots) && current.cybots.length > 0 ? current.cybots[0] : void 0;
17613
17831
  const contextWindow = await resolveContextWindow(
@@ -17617,38 +17835,64 @@ async function compactDialog(options) {
17617
17835
  agentKey,
17618
17836
  localStore
17619
17837
  );
17620
- const plan = planCompression({
17838
+ const core = prepareCompactHistory({
17621
17839
  allMsgs,
17622
- summarizedBeforeId: activeSummarizedBeforeId,
17840
+ summarizedBeforeId: active.anchor,
17623
17841
  summary: activeSummary,
17624
17842
  contextWindow,
17625
17843
  force: true,
17626
17844
  reason: "manual"
17627
- });
17628
- if (plan.shouldCompress && plan.msgsToCompress.length > 0) {
17845
+ }, source, (message) => ({ ...dialogMessageRecordToAgentRuntimeMessage(message), id: message.id }), SUMMARY_CONTEXT_WINDOW);
17846
+ const { request, plan } = core;
17847
+ if (request) {
17629
17848
  const previousSummary = activeSummary;
17630
- const request = buildHistoricalCompactionRequest({
17631
- // Planning/persistence retain stored records (toolCallId); the bounded
17632
- // request validates runtime messages (tool_call_id). Reuse the canonical
17633
- // projection already validated above, without changing source coverage.
17634
- msgsToCompress: plan.msgsToCompress.map((message) => ({
17635
- ...dialogMessageRecordToAgentRuntimeMessage(message),
17636
- id: message.id
17637
- })),
17638
- previousSummary,
17639
- contextWindow: SUMMARY_CONTEXT_WINDOW
17640
- });
17849
+ const telemetryOpts = options.telemetryLogFile ? { logFile: options.telemetryLogFile } : void 0;
17850
+ const manualT0 = Date.now();
17641
17851
  if (request.status === "blocked") {
17852
+ appendCompactionTelemetryRecord(
17853
+ {
17854
+ schemaVersion: COMPACTION_TELEMETRY_SCHEMA_VERSION,
17855
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
17856
+ dialogId: options.dialogId,
17857
+ outcome: "blocked",
17858
+ trigger: "manual",
17859
+ attempts: 0,
17860
+ model: null,
17861
+ provider: null,
17862
+ contextWindow: SUMMARY_CONTEXT_WINDOW,
17863
+ triggerPromptTokens: null,
17864
+ realUsageRatio: null,
17865
+ estimatedTokens: plan.diagnostics?.totalUsed ?? null,
17866
+ elapsedMs: Date.now() - manualT0,
17867
+ primaryElapsedMs: null,
17868
+ saveElapsedMs: null,
17869
+ summaryInputTokens: null,
17870
+ summaryInputCapTokens: request.diagnostics?.cap ?? null,
17871
+ summaryExpandedMessages: request.diagnostics?.expandedMessages ?? null,
17872
+ summaryOmittedMessages: null,
17873
+ pendingMessageCount: plan.diagnostics?.pendingMsgCount ?? null,
17874
+ compressedCount: null,
17875
+ retainedCount: null,
17876
+ compressedTokens: null,
17877
+ newSummaryTokens: null,
17878
+ residentReductionTokens: null,
17879
+ beforeProjectedTokens: null,
17880
+ afterProjectedTokens: null,
17881
+ finishReason: null,
17882
+ mode: "cli-manual",
17883
+ route: null,
17884
+ blockedReason: request.reason,
17885
+ previousSummaryTokens: request.diagnostics?.previousSummaryTokens ?? null,
17886
+ fileOpsCount: request.diagnostics?.fileOpsCount ?? null
17887
+ },
17888
+ telemetryOpts
17889
+ );
17642
17890
  throw new Error(`[nolo] compact: summary blocked: ${request.reason}`);
17643
17891
  } else {
17644
17892
  options.onProgress?.("summarizing");
17645
17893
  const summaryBudget = createSummaryBudget({ mode: "manual", signal: options.signal });
17646
17894
  try {
17647
- const newSummary = await summaryBudget.run(({ signal, deadlineMs }) => summaryLlmCaller(request.promptContent, {
17648
- signal,
17649
- deadlineMs,
17650
- maxOutputTokens: request.outputTokenBudget
17651
- }));
17895
+ const newSummary = await summaryBudget.run(({ signal, deadlineMs }) => core.summarize((content, maxOutputTokens) => summaryLlmCaller(content, { signal, deadlineMs, maxOutputTokens })));
17652
17896
  if (!newSummary?.trim()) throw new Error("[nolo] compact: empty summary");
17653
17897
  if (newSummary.trim()) {
17654
17898
  const compressionCount = current.compressionCount || 0;
@@ -17660,16 +17904,7 @@ async function compactDialog(options) {
17660
17904
  extractedKeys.add(key);
17661
17905
  }
17662
17906
  }
17663
- const summarySourceMsgs = allMsgs.map((m) => ({
17664
- id: m.id,
17665
- role: m.role,
17666
- content: m.content,
17667
- ...m.tool_calls !== void 0 ? { tool_calls: m.tool_calls } : {}
17668
- }));
17669
- const sourceMeta = await computeSummarySourceMetadata(
17670
- summarySourceMsgs,
17671
- request.summarizedBeforeId
17672
- );
17907
+ const sourceMeta = core.metadata();
17673
17908
  if (options.signal?.aborted) throw new DOMException("summary aborted", "AbortError");
17674
17909
  if (summaryBudget.remainingMs() <= 0) throw new DOMException("Summary deadline exceeded", "TimeoutError");
17675
17910
  const patchChanges = {
@@ -17707,30 +17942,104 @@ async function compactDialog(options) {
17707
17942
  generatedSummary = newSummary.trim();
17708
17943
  pendingHistory = allMsgs.slice(allMsgs.findIndex((msg) => msg.id === request.summarizedBeforeId) + 1);
17709
17944
  compactedMessageCount = request.coveredMessages.length;
17710
- const metrics = buildCompactionMetricsFromPlan({
17711
- reason: "manual",
17712
- previousSummary,
17713
- plan: {
17714
- msgsToCompress: request.coveredMessages,
17715
- msgsToKeep: [...plan.msgsToCompress.slice(request.coveredMessages.length), ...plan.msgsToKeep]
17716
- },
17945
+ const metrics = core.metrics("manual", newSummary.trim());
17946
+ console.log(formatCompactionMetricsLog(metrics));
17947
+ const coveredFileOps = [];
17948
+ for (const msg of request.coveredMessages) {
17949
+ if (!Array.isArray(msg.tool_calls)) continue;
17950
+ coveredFileOps.push(...extractFileOperationsFromCalls(msg.tool_calls, (n) => n));
17951
+ }
17952
+ const quality = inspectCompactionSummaryQuality({
17717
17953
  newSummary: newSummary.trim(),
17718
- summaryInput: {
17719
- inputTokens: request.inputTokens,
17720
- capTokens: request.capTokens,
17721
- expandedMessages: request.expandedMessages,
17722
- omittedMessages: request.omittedMessages
17723
- },
17724
- planCounts: {
17725
- pendingMessageCount: plan.diagnostics?.pendingMsgCount,
17726
- plannedCompressCount: plan.diagnostics?.compressCount
17727
- }
17954
+ previousSummary,
17955
+ fileOps: coveredFileOps
17728
17956
  });
17729
- console.log(formatCompactionMetricsLog(metrics));
17957
+ appendCompactionTelemetryRecord(
17958
+ {
17959
+ schemaVersion: COMPACTION_TELEMETRY_SCHEMA_VERSION,
17960
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
17961
+ dialogId: options.dialogId,
17962
+ outcome: "success",
17963
+ trigger: "manual",
17964
+ attempts: 1,
17965
+ model: null,
17966
+ provider: null,
17967
+ contextWindow,
17968
+ triggerPromptTokens: null,
17969
+ realUsageRatio: null,
17970
+ estimatedTokens: plan.diagnostics?.totalUsed ?? null,
17971
+ elapsedMs: Date.now() - manualT0,
17972
+ primaryElapsedMs: null,
17973
+ saveElapsedMs: null,
17974
+ summaryInputTokens: request.inputTokens,
17975
+ summaryInputCapTokens: request.capTokens,
17976
+ summaryExpandedMessages: request.expandedMessages,
17977
+ summaryOmittedMessages: request.omittedMessages,
17978
+ pendingMessageCount: plan.diagnostics?.pendingMsgCount ?? null,
17979
+ compressedCount: metrics.compressedCount,
17980
+ retainedCount: metrics.retainedCount,
17981
+ compressedTokens: metrics.compressedTokens,
17982
+ newSummaryTokens: metrics.newSummaryTokens,
17983
+ residentReductionTokens: metrics.residentReductionTokens,
17984
+ beforeProjectedTokens: null,
17985
+ afterProjectedTokens: null,
17986
+ finishReason: null,
17987
+ mode: "cli-manual",
17988
+ route: null,
17989
+ blockedReason: null,
17990
+ previousSummaryTokens: metrics.previousSummaryTokens,
17991
+ fileOpsCount: coveredFileOps.length,
17992
+ qualitySectionsPresent: quality.sectionsPresent,
17993
+ qualitySlotsPresent: quality.requiredSlotsPresent,
17994
+ qualityOriginalGoalPreserved: quality.originalGoalPreserved,
17995
+ qualityWrittenPathsTotal: quality.writtenPathsTotal,
17996
+ qualityWrittenPathsCovered: quality.writtenPathsCovered
17997
+ },
17998
+ telemetryOpts
17999
+ );
17730
18000
  }
17731
18001
  } catch (error) {
18002
+ const safeErr = classifySummaryError(error);
18003
+ const outcome = options.signal?.aborted || isAbortError(error) || safeErr.category === "cancelled" ? "aborted" : safeErr.category === "timeout" ? "timeout" : safeErr.code === "SUMMARY_TRUNCATED" ? "truncated" : error instanceof Error && error.message.includes("empty summary") ? "empty" : "provider-error";
18004
+ appendCompactionTelemetryRecord(
18005
+ {
18006
+ schemaVersion: COMPACTION_TELEMETRY_SCHEMA_VERSION,
18007
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
18008
+ dialogId: options.dialogId,
18009
+ outcome,
18010
+ trigger: "manual",
18011
+ attempts: 1,
18012
+ model: safeErr.model ?? null,
18013
+ provider: safeErr.provider ?? null,
18014
+ contextWindow,
18015
+ triggerPromptTokens: null,
18016
+ realUsageRatio: null,
18017
+ estimatedTokens: plan.diagnostics?.totalUsed ?? null,
18018
+ elapsedMs: Date.now() - manualT0,
18019
+ primaryElapsedMs: null,
18020
+ saveElapsedMs: null,
18021
+ summaryInputTokens: request.inputTokens,
18022
+ summaryInputCapTokens: request.capTokens,
18023
+ summaryExpandedMessages: request.expandedMessages,
18024
+ summaryOmittedMessages: null,
18025
+ pendingMessageCount: plan.diagnostics?.pendingMsgCount ?? null,
18026
+ compressedCount: null,
18027
+ retainedCount: null,
18028
+ compressedTokens: null,
18029
+ newSummaryTokens: null,
18030
+ residentReductionTokens: null,
18031
+ beforeProjectedTokens: null,
18032
+ afterProjectedTokens: null,
18033
+ finishReason: safeErr.finishReason ?? null,
18034
+ mode: "cli-manual",
18035
+ route: null,
18036
+ blockedReason: null
18037
+ },
18038
+ telemetryOpts
18039
+ );
17732
18040
  if (options.signal?.aborted || isAbortError(error)) throw new DOMException("summary aborted", "AbortError");
17733
- throw new Error(`[nolo] compact: summary failed (${classifySummaryError(error).category ?? "unknown"})`, { cause: error });
18041
+ const httpDetail = safeErr.category === "http" && safeErr.status !== void 0 ? `: HTTP ${safeErr.status}${safeErr.code ? ` ${safeErr.code}` : ""}` : "";
18042
+ throw new Error(`[nolo] compact: summary failed (${safeErr.category})${httpDetail}`, { cause: error });
17734
18043
  } finally {
17735
18044
  summaryBudget.dispose();
17736
18045
  }
@@ -17900,17 +18209,13 @@ async function runTuiLogin(args, emit, deps = {}) {
17900
18209
 
17901
18210
  // packages/cli/tui/tuiAuth.ts
17902
18211
  var TUI_AUTH_PROVIDERS = [
17903
- "claude",
17904
18212
  "chatgpt",
17905
- "antigravity",
17906
18213
  "xai",
17907
18214
  "cursor",
17908
18215
  "devin"
17909
18216
  ];
17910
18217
  var PROVIDER_DISPLAY_NAMES = {
17911
- claude: "Claude (Anthropic)",
17912
18218
  chatgpt: "ChatGPT (OpenAI)",
17913
- antigravity: "Antigravity (Google)",
17914
18219
  xai: "xAI (Grok)",
17915
18220
  cursor: "Cursor",
17916
18221
  devin: "Devin",
@@ -17927,18 +18232,6 @@ function padRight(str, width) {
17927
18232
  const diff = width - strWidth(str);
17928
18233
  return diff > 0 ? str + " ".repeat(diff) : str;
17929
18234
  }
17930
- function formatGrantRemaining(provider, credential, now) {
17931
- if (provider !== "claude" || !credential) return "-";
17932
- const rem = anthropicGrantRemainingMs(credential, now);
17933
- if (rem === void 0) return "-";
17934
- if (rem <= 0) return t("auth.grantExpired");
17935
- const days = Math.floor(rem / (24 * 3600 * 1e3));
17936
- const hours = Math.floor(rem % (24 * 3600 * 1e3) / (3600 * 1e3));
17937
- if (days > 0) return `${days}d ${hours}h`;
17938
- const minutes = Math.floor(rem / (60 * 1e3));
17939
- if (minutes > 0) return `${minutes}m`;
17940
- return "<1m";
17941
- }
17942
18235
  function formatLocalStatus(credential, now) {
17943
18236
  if (!credential) return t("auth.statusUnauthenticated");
17944
18237
  if (isTokenExpired(credential, 0, now)) return t("auth.statusExpired");
@@ -17959,12 +18252,8 @@ function toAuthProviderPickerItems(tokenStore, now = Date.now()) {
17959
18252
  const statusLabel = isAuthed ? `\u2713 ${t("auth.statusAuthenticated")}` : isExp ? `\u26A0 ${t("auth.statusExpired")}` : t("auth.statusUnauthenticated");
17960
18253
  const brandName = PROVIDER_DISPLAY_NAMES[provider] ?? provider;
17961
18254
  const label = `${padRight(brandName, 26)} ${statusLabel}`;
17962
- const grantPart = formatGrantRemaining(provider, cred, now);
17963
18255
  const syncPart = formatServerSyncStatus(cred);
17964
18256
  const detailParts = [];
17965
- if (provider === "claude" && cred && grantPart !== "-") {
17966
- detailParts.push(`${t("auth.statusColGrantRemaining")}: ${grantPart}`);
17967
- }
17968
18257
  if (cred && syncPart !== "-") {
17969
18258
  detailParts.push(syncPart);
17970
18259
  }
@@ -18003,7 +18292,6 @@ function renderAuthStatusPanel(tokenStore, now = Date.now()) {
18003
18292
  const headers = [
18004
18293
  t("auth.statusColProvider"),
18005
18294
  t("auth.statusColLocalStatus"),
18006
- t("auth.statusColGrantRemaining"),
18007
18295
  t("auth.statusColServerSync")
18008
18296
  ];
18009
18297
  const rows = TUI_AUTH_PROVIDERS.map((provider) => {
@@ -18011,7 +18299,6 @@ function renderAuthStatusPanel(tokenStore, now = Date.now()) {
18011
18299
  return [
18012
18300
  provider,
18013
18301
  formatLocalStatus(cred, now),
18014
- formatGrantRemaining(provider, cred, now),
18015
18302
  formatServerSyncStatus(cred)
18016
18303
  ];
18017
18304
  });
@@ -18141,9 +18428,7 @@ async function runTuiAuth(args, emit, deps = {}) {
18141
18428
  };
18142
18429
  let credential;
18143
18430
  try {
18144
- if (provider === "claude") {
18145
- credential = await runAnthropicOAuthLogin(flowDeps);
18146
- } else if (provider === "chatgpt") {
18431
+ if (provider === "chatgpt") {
18147
18432
  const useDeviceCode = rest.includes("--device-code");
18148
18433
  credential = useDeviceCode ? await runOpenAiCodexDeviceCode(flowDeps) : await runOpenAiCodexBrowserPkce(flowDeps);
18149
18434
  } else if (provider === "xai") {
@@ -18153,10 +18438,8 @@ async function runTuiAuth(args, emit, deps = {}) {
18153
18438
  credential = await runCursorOAuthLogin(flowDeps);
18154
18439
  } else if (provider === "devin") {
18155
18440
  credential = await runDevinOAuthLogin(flowDeps);
18156
- } else if (provider === "cloudflare") {
18157
- credential = await runCloudflareOAuthLogin(flowDeps);
18158
18441
  } else {
18159
- credential = await runAntigravityOAuthLogin(flowDeps);
18442
+ credential = await runCloudflareOAuthLogin(flowDeps);
18160
18443
  }
18161
18444
  } catch (err) {
18162
18445
  const errorText = classifyAuthFlowError(err, provider);
@@ -18325,6 +18608,10 @@ async function runSubmittedSlashLine(line, host, actionGateHandler, confirmDestr
18325
18608
  }
18326
18609
  const result = handleTuiInput2(line, host.state, collectConversationTurns(host.history), {
18327
18610
  env: host.taskEnv,
18611
+ // Context estimate must see the runtime's env, not the merged task env:
18612
+ // an explicit `{}` in options.env means the turn runs without the process
18613
+ // env (no MCP/Instabox schemas), so the chip must not count them either.
18614
+ estimateEnv: host.options.env ?? process.env,
18328
18615
  authEnv: resolveTuiIdentityEnv(host.taskEnv, host.options.env ?? process.env),
18329
18616
  // 交互模式下非 chat 输出会进 transcript(emitCommandOutput → appendLocalTurn),
18330
18617
  // /links 的 Ctrl+左键提示才成立;管道/脚本下同一份文本只是 stdout,不能用快捷键承诺。
@@ -18414,6 +18701,7 @@ async function runSubmittedSlashLine(line, host, actionGateHandler, confirmDestr
18414
18701
  agentKey: host.state.agentKey,
18415
18702
  userLanguage: host.state.userLanguage,
18416
18703
  responseViewport: TUI_RESPONSE_VIEWPORT,
18704
+ env: host.options.env ?? process.env,
18417
18705
  ...resolveAgentModelIdentity({
18418
18706
  agentKey: host.state.agentKey,
18419
18707
  agentName: host.state.agentName
@@ -18519,6 +18807,7 @@ async function runSubmittedSlashLine(line, host, actionGateHandler, confirmDestr
18519
18807
  agentKey: host.state.agentKey,
18520
18808
  userLanguage: host.state.userLanguage,
18521
18809
  responseViewport: TUI_RESPONSE_VIEWPORT,
18810
+ env: host.options.env ?? process.env,
18522
18811
  messages: [
18523
18812
  ...compactResult.summary ? [{ role: "system", content: compactResult.summary }] : [],
18524
18813
  ...compactResult.compactedMessageCount > 0 ? host.history.turns.slice(compactResult.compactedMessageCount) : compactResult.summaryGenerated ? [] : host.history.turns
@@ -18646,7 +18935,7 @@ async function runSubmittedSlashLine(line, host, actionGateHandler, confirmDestr
18646
18935
  if (!target || !entries.some((entry) => entry.key === target.key)) {
18647
18936
  emitCommandOutput(t("agentUnknown", query));
18648
18937
  } else {
18649
- const nextState = applyAgentSwitchState(host.state, target, host.history.turns);
18938
+ const nextState = applyAgentSwitchState(host.state, target, host.history.turns, options.env ?? process.env);
18650
18939
  const oldKey = host.state.agentKey;
18651
18940
  host.state = nextState;
18652
18941
  clearCliLocalRuntimePreparedAgentCache();
@@ -18690,7 +18979,8 @@ async function runSubmittedSlashLine(line, host, actionGateHandler, confirmDestr
18690
18979
  model: pickResult.model,
18691
18980
  userLanguage: host.state.userLanguage,
18692
18981
  responseViewport: TUI_RESPONSE_VIEWPORT,
18693
- messages: host.history.turns
18982
+ messages: host.history.turns,
18983
+ env: host.options.env ?? process.env
18694
18984
  }),
18695
18985
  turnTokens: void 0,
18696
18986
  lastAuthorityTurnCount: void 0,
@@ -18759,7 +19049,10 @@ async function runSubmittedSlashLine(line, host, actionGateHandler, confirmDestr
18759
19049
  if (pickResult.kind === "selected") {
18760
19050
  const loadedTurns = await (options.dialogHistoryLoader ?? loadDialogHistoryForDisplay)({
18761
19051
  dialog: pickResult.dialog,
18762
- env: options.env ?? process.env
19052
+ env: options.env ?? process.env,
19053
+ fetchImpl: options.fetchImpl,
19054
+ cwd: host.state.cwd,
19055
+ log: (message) => host.emitCommandOutput(message)
18763
19056
  });
18764
19057
  const restored = loadedTurns.slice(-MAX_TUI_HISTORY_TURNS);
18765
19058
  history.turns.length = 0;
@@ -18793,6 +19086,7 @@ async function runSubmittedSlashLine(line, host, actionGateHandler, confirmDestr
18793
19086
  userLanguage: host.state.userLanguage,
18794
19087
  responseViewport: TUI_RESPONSE_VIEWPORT,
18795
19088
  messages: history.turns,
19089
+ env: host.options.env ?? process.env,
18796
19090
  ...resolveAgentModelIdentity({
18797
19091
  agentKey: host.state.agentKey,
18798
19092
  agentName: host.state.agentName
@@ -19160,6 +19454,18 @@ function persistAgentSelection(state, env, saveSelection = saveProfileAgentSelec
19160
19454
  var latestWorkspaceThemeOwner = 0;
19161
19455
  var WELCOME_ANIM_MAX_FRAME = 8;
19162
19456
  var WELCOME_ANIM_INTERVAL_MS = 70;
19457
+ var TITLE_SPINNER_FRAMES = [
19458
+ "\u2816",
19459
+ "\u2832",
19460
+ "\u28B2",
19461
+ "\u28B0",
19462
+ "\u28F0",
19463
+ "\u28E0",
19464
+ "\u28C4",
19465
+ "\u28C6",
19466
+ "\u2846",
19467
+ "\u2856"
19468
+ ];
19163
19469
  function isClipboardImageFallbackEligible(error) {
19164
19470
  const code = error instanceof ClipboardImageError ? error.code : typeof error === "object" && error !== null && "code" in error ? String(error.code) : void 0;
19165
19471
  return isTextFallbackEligibleCode(code);
@@ -19277,6 +19583,19 @@ async function runTuiWorkspace(options) {
19277
19583
  const titleEnv = options.env ?? process.env;
19278
19584
  const titleEnabled = output.isTTY === true && !["0", "false"].includes((titleEnv.NOLO_TUI_TITLE ?? "").trim().toLowerCase());
19279
19585
  const TITLE_SPINNER_INTERVAL_MS = 200;
19586
+ const TITLE_SUFFIX_BLOCKED = " \xB7 \u9700\u63A5\u7BA1 \u2014 Nolo";
19587
+ const TITLE_SUFFIX_ERROR = " \xB7 \u5931\u8D25\u9700\u5904\u7406 \u2014 Nolo";
19588
+ const TITLE_SUFFIX_IDLE = " \u2014 Nolo";
19589
+ const TITLE_SUFFIX_WIDTH_BLOCKED = displayWidth(TITLE_SUFFIX_BLOCKED);
19590
+ const TITLE_SUFFIX_WIDTH_ERROR = displayWidth(TITLE_SUFFIX_ERROR);
19591
+ const TITLE_SUFFIX_WIDTH_IDLE = displayWidth(TITLE_SUFFIX_IDLE);
19592
+ const TITLE_WORKING_SUFFIXES = TITLE_SPINNER_FRAMES.map((frame) => ` \xB7 ${frame} \u2014 Nolo`);
19593
+ const TITLE_WORKING_SUFFIX_WIDTHS = TITLE_WORKING_SUFFIXES.map((suffix) => displayWidth(suffix));
19594
+ let cachedRawTitleLabel = null;
19595
+ let cachedCleanTitleLabel = "";
19596
+ let cachedClippedLabelSource = null;
19597
+ let cachedClippedLabelMaxWidth = -1;
19598
+ let cachedClippedLabelPrefix = "";
19280
19599
  let titleFrameIndex = 0;
19281
19600
  let titleAnimTimer = null;
19282
19601
  const stopTitleAnimation = () => {
@@ -19320,17 +19639,44 @@ async function runTuiWorkspace(options) {
19320
19639
  titleFrameIndex = 0;
19321
19640
  } else if (titleAnimTimer === null) {
19322
19641
  titleAnimTimer = setInterval(() => {
19323
- titleFrameIndex = (titleFrameIndex + 1) % ACTIVITY_FRAMES.length;
19642
+ titleFrameIndex = (titleFrameIndex + 1) % TITLE_SPINNER_FRAMES.length;
19324
19643
  syncWindowTitle();
19325
19644
  }, TITLE_SPINNER_INTERVAL_MS);
19326
19645
  titleAnimTimer.unref?.();
19327
19646
  }
19328
19647
  const rawDialogLabel = state.dialogLabel?.trim();
19329
19648
  const rawLabel = !rawDialogLabel || rawDialogLabel === "new" ? basename2(state.cwd) || "Nolo" : rawDialogLabel;
19330
- const label = stripAnsi(rawLabel).replace(/[\x00-\x1f\x7f-\x9f]+/g, " ");
19331
- const frame = ACTIVITY_FRAMES[titleFrameIndex % ACTIVITY_FRAMES.length];
19332
- const suffix = phase === "blocked" ? " \xB7 \u9700\u63A5\u7BA1 \u2014 Nolo" : phase === "error" ? " \xB7 \u5931\u8D25\u9700\u5904\u7406 \u2014 Nolo" : isWorking ? ` \xB7 ${frame} \u601D\u8003\u4E2D \u2014 Nolo` : label === "Nolo" ? "" : " \u2014 Nolo";
19333
- const currentTitle = takeDisplayWidth(label, 80 - displayWidth(suffix)).prefix + suffix;
19649
+ if (rawLabel !== cachedRawTitleLabel) {
19650
+ cachedRawTitleLabel = rawLabel;
19651
+ cachedCleanTitleLabel = stripAnsi(rawLabel).replace(/[\x00-\x1f\x7f-\x9f]+/g, " ");
19652
+ }
19653
+ const label = cachedCleanTitleLabel;
19654
+ let suffix;
19655
+ let suffixWidth;
19656
+ if (phase === "blocked") {
19657
+ suffix = TITLE_SUFFIX_BLOCKED;
19658
+ suffixWidth = TITLE_SUFFIX_WIDTH_BLOCKED;
19659
+ } else if (phase === "error") {
19660
+ suffix = TITLE_SUFFIX_ERROR;
19661
+ suffixWidth = TITLE_SUFFIX_WIDTH_ERROR;
19662
+ } else if (isWorking) {
19663
+ const frameIdx = titleFrameIndex % TITLE_WORKING_SUFFIXES.length;
19664
+ suffix = TITLE_WORKING_SUFFIXES[frameIdx];
19665
+ suffixWidth = TITLE_WORKING_SUFFIX_WIDTHS[frameIdx];
19666
+ } else if (label === "Nolo") {
19667
+ suffix = "";
19668
+ suffixWidth = 0;
19669
+ } else {
19670
+ suffix = TITLE_SUFFIX_IDLE;
19671
+ suffixWidth = TITLE_SUFFIX_WIDTH_IDLE;
19672
+ }
19673
+ const maxLabelWidth = 80 - suffixWidth;
19674
+ if (label !== cachedClippedLabelSource || maxLabelWidth !== cachedClippedLabelMaxWidth) {
19675
+ cachedClippedLabelSource = label;
19676
+ cachedClippedLabelMaxWidth = maxLabelWidth;
19677
+ cachedClippedLabelPrefix = takeDisplayWidth(label, maxLabelWidth).prefix;
19678
+ }
19679
+ const currentTitle = cachedClippedLabelPrefix + suffix;
19334
19680
  if (currentTitle === lastSentTitle) return;
19335
19681
  lastSentTitle = currentTitle;
19336
19682
  try {
@@ -19462,7 +19808,10 @@ async function runTuiWorkspace(options) {
19462
19808
  cybots: []
19463
19809
  },
19464
19810
  env: runtimeEnv,
19465
- fetchImpl
19811
+ fetchImpl,
19812
+ cwd: state.cwd,
19813
+ log: (message) => output.write(`${message}
19814
+ `)
19466
19815
  });
19467
19816
  history.turns.push(...turns);
19468
19817
  } catch (error) {
@@ -20654,7 +21003,7 @@ ${lines}` : lines;
20654
21003
  onApprove: createSnapshotGuardedApproval("local", () => state.permissionGrants, approveLocalConfirms),
20655
21004
  onApproved: async (approvedGate) => {
20656
21005
  if (approvedGate.kind !== "confirm") return null;
20657
- const { executeApprovedCredentialCreate } = await import("./hostCredentialCreate-3IA5IJFG.js");
21006
+ const { executeApprovedCredentialCreate } = await import("./hostCredentialCreate-PJAIKZQP.js");
20658
21007
  const hostResult = await executeApprovedCredentialCreate({
20659
21008
  gate: approvedGate,
20660
21009
  approvalGateId: approvedGate.id,
@@ -21048,6 +21397,10 @@ ${err.message}` : ""}`)
21048
21397
  const beforeAgentKey = state.agentKey;
21049
21398
  const res = handleTuiInput2(submittedText, state, collectConversationTurns(history), {
21050
21399
  env: effectiveEnv,
21400
+ // Same env the busy turn runs with; `effectiveEnv` is the merged
21401
+ // startup snapshot and would over-count MCP/Instabox tool schemas when
21402
+ // options.env is an explicit `{}`.
21403
+ estimateEnv: options.env ?? process.env,
21051
21404
  // Identity only: `effectiveEnv` is the startup snapshot, `options.env`
21052
21405
  // is where a `/login` in this session writes its token.
21053
21406
  authEnv: resolveTuiIdentityEnv(effectiveEnv, options.env ?? process.env),
@@ -21967,6 +22320,7 @@ async function startTuiWorkspace(options) {
21967
22320
  }
21968
22321
  export {
21969
22322
  ANSI_ESCAPE_REGEX,
22323
+ TITLE_SPINNER_FRAMES,
21970
22324
  appendLocalTurn,
21971
22325
  appendToCurrentTurn,
21972
22326
  applyOutputChunkToCurrentTurn,