nolo-cli 0.228.0-alpha.2 → 0.228.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/README.md +3 -5
  2. package/{_executeModel-VYCHHZVT.js → _executeModel-GIFVXKDT.js} +88 -83
  3. package/{accountResolver-QETKNC7T.js → accountResolver-NGICIMEE.js} +1 -1
  4. package/{action-GDZDXPMB.js → action-WZTKEF5H.js} +9 -6
  5. package/{addContentAction-7RO4AMRI.js → addContentAction-MLI6GOBV.js} +14 -13
  6. package/{addDialogAgentAction-EVYBGTXB.js → addDialogAgentAction-ARGQM22H.js} +17 -16
  7. package/{agentDeleteCommand-QWQKT54A.js → agentDeleteCommand-UF7XVELS.js} +118 -111
  8. package/{agentEmailCommands-EISMBIRE.js → agentEmailCommands-SFHRPQYC.js} +118 -107
  9. package/{agentListCommands-4WLG32IW.js → agentListCommands-IXKBP3W5.js} +208 -177
  10. package/{agentMachineCommands-DC6NKWTU.js → agentMachineCommands-7NX6PWQ6.js} +55 -48
  11. package/{agentProviderCommands-STI3DQ6A.js → agentProviderCommands-C5T7C5KZ.js} +2 -2
  12. package/{agentPullCommand-KHV4EELF.js → agentPullCommand-4EQZYHU4.js} +1 -1
  13. package/agentRecordCommands-IUNX6XD6.js +188 -0
  14. package/{agentRunCommand-QM7ETUTX.js → agentRunCommand-LCR4XADM.js} +125 -111
  15. package/{agentRunControl-MBG4U6SL.js → agentRunControl-RN2P6AOD.js} +11 -9
  16. package/{agentRuntimeLocal-HOXKWCYO.js → agentRuntimeLocal-LVXPQ7QA.js} +56 -43
  17. package/{agentSlice-UG76KEBH.js → agentSlice-ZGMOH6TE.js} +15 -14
  18. package/{appDeleteCommands-WWCC6WA5.js → appDeleteCommands-BESCJOQM.js} +55 -48
  19. package/{appDeployCommands-AU4IUN33.js → appDeployCommands-LPTR6IOX.js} +55 -48
  20. package/{appDeployStatusCommands-STUW7WXL.js → appDeployStatusCommands-BZ7KZ5RD.js} +55 -48
  21. package/{appGetCommands-BGTLIQ4K.js → appGetCommands-EDWGJV4S.js} +55 -48
  22. package/{appListCommands-CUCPRUXW.js → appListCommands-OPRWYPM6.js} +55 -48
  23. package/{authCommand-OZ2KTP4Z.js → authCommand-3C3RN4OU.js} +25 -19
  24. package/{authCommands-55OGQGCR.js → authCommands-ZMVEDCQD.js} +12 -6
  25. package/{builtinSkillRegistry-BAE2LDXF.js → builtinSkillRegistry-VRCMQ77Q.js} +7 -7
  26. package/{chromeCommands-G5UDKVSV.js → chromeCommands-O4IIKTBD.js} +384 -7
  27. package/{chromeOpsCommands-WAA45NCS.js → chromeOpsCommands-NZITLHWO.js} +3 -3
  28. package/{chunk-VQ5N5GSV.js → chunk-2BKNICGK.js} +4 -4
  29. package/{chunk-QYB23WUH.js → chunk-2FK2KZSL.js} +1 -1
  30. package/chunk-2SXN7LAY.js +15 -0
  31. package/{chunk-3VZLEKV2.js → chunk-3DJJ4CFG.js} +11 -11
  32. package/{chunk-TSPMLCWI.js → chunk-4IQN6FWY.js} +5 -5
  33. package/{chunk-XAG3FWBE.js → chunk-4OXPN3WC.js} +6 -6
  34. package/chunk-4ZCTKB27.js +31 -0
  35. package/chunk-53W5BXLN.js +340 -0
  36. package/{chunk-42OKN2LI.js → chunk-5HUO7SEX.js} +9 -107
  37. package/chunk-6ASGEP5D.js +21 -0
  38. package/{chunk-MJI3UAXN.js → chunk-6CXQ3YNJ.js} +40 -36
  39. package/{chunk-G7IUT2V3.js → chunk-6MTVACLN.js} +365 -64
  40. package/{chunk-ZOHO6MOF.js → chunk-6RSNVJGO.js} +2 -99
  41. package/{chunk-XSW4EXQV.js → chunk-6TVYUQRM.js} +55 -18
  42. package/{chunk-PDCV7P5W.js → chunk-6XIE5ZGI.js} +1 -1
  43. package/{chunk-7Z6EW7AH.js → chunk-6XVPMGXK.js} +97 -11
  44. package/{chunk-ALAES342.js → chunk-73PZD7JZ.js} +9 -5
  45. package/{chunk-TCZ2VJZQ.js → chunk-7UVVLYKC.js} +9 -9
  46. package/{chunk-S6FDXXZV.js → chunk-ADOOL3PG.js} +2 -2
  47. package/{chunk-OWKNSIXL.js → chunk-AEZBAFC6.js} +334 -77
  48. package/{chunk-PWTNI4N7.js → chunk-ANUP75N2.js} +22 -0
  49. package/{chunk-RG2DGNL6.js → chunk-ARFCL53U.js} +5 -5
  50. package/{chunk-SRCCSTIM.js → chunk-AS6L5KSD.js} +4 -4
  51. package/{chunk-WFDNADFX.js → chunk-BAH3BAUZ.js} +8 -8
  52. package/{chunk-N5Z2V73W.js → chunk-BFKJ2RS3.js} +1 -1
  53. package/{chunk-F6Z6ZCUV.js → chunk-BVEDT6DM.js} +3 -3
  54. package/chunk-C5A54QS7.js +108 -0
  55. package/{chunk-CD3RU7XL.js → chunk-CD2DK5JA.js} +120 -14
  56. package/{chunk-BP5ZJ6B4.js → chunk-CD64YXRB.js} +1 -1
  57. package/{chunk-VP3BINY7.js → chunk-CIGCTSBF.js} +31 -1
  58. package/{chunk-TQEKUOTI.js → chunk-CIUZXD5D.js} +12 -12
  59. package/{chunk-EVGU5P4U.js → chunk-CO6E7YK6.js} +1 -1
  60. package/{chunk-VMJVAJ6W.js → chunk-CTIEJRTP.js} +28 -4
  61. package/{chunk-7JGMNKKG.js → chunk-CTWCZKNS.js} +29 -8
  62. package/{chunk-YFLVRVYK.js → chunk-D25ONVOH.js} +1 -1
  63. package/{chunk-LKA64WH4.js → chunk-DMPZMYH4.js} +37 -1
  64. package/{chunk-262R3XNN.js → chunk-E5RYFR7E.js} +334 -103
  65. package/{chunk-OQHIVPG4.js → chunk-E6A5NHDH.js} +4 -1
  66. package/{chunk-HSSBDZLD.js → chunk-EDT65EUE.js} +6 -6
  67. package/{chunk-YVFH2MFB.js → chunk-EQZQUQ33.js} +7 -7
  68. package/{chunk-HBRDSQ3M.js → chunk-ESN4WNWU.js} +3 -2
  69. package/{chunk-2YGBI2XB.js → chunk-FE7G6DSP.js} +11 -1
  70. package/{chunk-547ENH5T.js → chunk-FFFKAOJN.js} +4 -4
  71. package/{chunk-5ZUOVCKT.js → chunk-FGHEF6WI.js} +3 -1
  72. package/{chunk-GAYNXB6T.js → chunk-FTWAOKFU.js} +756 -333
  73. package/chunk-GAHJLSDO.js +107 -0
  74. package/{chunk-2X7WFDT6.js → chunk-GX6DITLQ.js} +1 -1
  75. package/{chunk-HXB4VDGK.js → chunk-HCCQEMTK.js} +28 -28
  76. package/{chunk-CMMI3DAT.js → chunk-HZDK56EK.js} +33 -26
  77. package/{chunk-OTKSESZR.js → chunk-IIOSZAJX.js} +4 -4
  78. package/chunk-IIRJ4P4I.js +24 -0
  79. package/{chunk-OJ45MEEI.js → chunk-IJZC2KIJ.js} +1 -1
  80. package/{chunk-MNEZUL5S.js → chunk-ITBX27W6.js} +92 -31
  81. package/{chunk-LYD6C7OU.js → chunk-J2VIGDJN.js} +6 -6
  82. package/{chunk-M3OZRQNH.js → chunk-JEWMQR6J.js} +1 -1
  83. package/{chunk-6QHKRARD.js → chunk-JFRJEPFI.js} +29 -5
  84. package/{chunk-S6K5F3KP.js → chunk-JP2BH4NC.js} +1 -1
  85. package/{chunk-EGHP7KOY.js → chunk-JU7VN4LF.js} +38 -29
  86. package/{chunk-RTHFJZ6M.js → chunk-K26XPZRB.js} +2 -2
  87. package/{chunk-ZYKJBRZ3.js → chunk-K7VIXYTZ.js} +1 -3
  88. package/chunk-KK3FCYZM.js +647 -0
  89. package/chunk-KLAMJNKQ.js +33394 -0
  90. package/{chunk-4JVNURX4.js → chunk-KQHEGELM.js} +68 -16
  91. package/chunk-KXOPLLFP.js +190 -0
  92. package/{chunk-MZG5CETE.js → chunk-KZ5OD2MO.js} +4 -4
  93. package/{chunk-ILHQ2AXT.js → chunk-KZAT2M2V.js} +14 -8
  94. package/chunk-LHCGKAFO.js +739 -0
  95. package/{chunk-HF7BLF3F.js → chunk-LMGFVH65.js} +107 -104
  96. package/{chunk-QRGDJA4B.js → chunk-LTVEOOZL.js} +19 -6
  97. package/{chunk-L32W3PRP.js → chunk-MAA42MMV.js} +233 -17
  98. package/{chunk-ATEKLSLR.js → chunk-MTM4LRVG.js} +14 -9
  99. package/chunk-MVOZ22RZ.js +26 -0
  100. package/{chunk-U2HBB7RS.js → chunk-MYYNZG2M.js} +132 -32
  101. package/{chunk-DBUR22G5.js → chunk-MZVCFV3T.js} +19 -15
  102. package/{chunk-WCFFRBL5.js → chunk-N74XL3NI.js} +9 -9
  103. package/{chunk-VS276URX.js → chunk-NEG5LYK5.js} +1 -1
  104. package/{chunk-RBPUNSG5.js → chunk-OAZP4TSA.js} +18 -108
  105. package/{chunk-4QYJPWHH.js → chunk-ODBYGVO2.js} +232 -10
  106. package/{chunk-M4SFKP5L.js → chunk-OHUYN3YU.js} +3 -3
  107. package/{chunk-HYLRQDEE.js → chunk-OLGFIQN2.js} +6 -6
  108. package/{chunk-M3JEW6N6.js → chunk-OYUMJMC5.js} +15 -0
  109. package/chunk-P27E22MA.js +203 -0
  110. package/{chunk-BIWI5M4E.js → chunk-PBPXXMWZ.js} +1 -1
  111. package/{chunk-OBSEKCVK.js → chunk-PQ63BDV3.js} +210 -51
  112. package/{chunk-4I2MXV5Q.js → chunk-PVFYPUIM.js} +2 -0
  113. package/{chunk-XFXFPUO7.js → chunk-QMNVV3YM.js} +10 -37
  114. package/{chunk-CNMY2XM6.js → chunk-R5NRFXGD.js} +5 -5
  115. package/{chunk-5FUN7EG4.js → chunk-RD3QLZQV.js} +83 -47
  116. package/{chunk-4WVJLODK.js → chunk-RHBD22LV.js} +9 -4
  117. package/{chunk-45CAVC35.js → chunk-RMWDKLBE.js} +1489 -286
  118. package/{chunk-ZEVQHCLM.js → chunk-RR3MB26M.js} +2 -2
  119. package/{chunk-OOJNQK6V.js → chunk-S25VJYXV.js} +8 -2
  120. package/{chunk-DLXMMTGM.js → chunk-SCMYAGQE.js} +1067 -705
  121. package/{chunk-YKY4OVOX.js → chunk-SPU3L3OR.js} +17 -170
  122. package/chunk-SR4FE5VD.js +9 -0
  123. package/{chunk-DUUDXSLX.js → chunk-SX6AWTNK.js} +28 -4
  124. package/{chunk-ZH3KXFHS.js → chunk-TMRJGSK2.js} +1 -1
  125. package/{chunk-S2NTVGA2.js → chunk-U35UUM5K.js} +2 -1
  126. package/{chunk-PPJYZRSQ.js → chunk-U5LOKQ2R.js} +30 -14
  127. package/{chunk-UAIHKQIA.js → chunk-U6RD332P.js} +18 -2
  128. package/{chunk-3U44JB3O.js → chunk-UF6J7NXV.js} +1 -1
  129. package/{chunk-5YMA6DDZ.js → chunk-UHW6SCVK.js} +1 -1
  130. package/chunk-UOUMPHS5.js +103 -0
  131. package/{chunk-HHFGE2WF.js → chunk-UPOW5HTG.js} +5 -5
  132. package/{chunk-DEA37IUY.js → chunk-V4IYI3SB.js} +2 -2
  133. package/{chunk-XTJKU3Z4.js → chunk-VKCPKCSS.js} +66 -92
  134. package/{chunk-HGDKT2D6.js → chunk-VTHWBTRE.js} +177 -1
  135. package/{chunk-OBIC6EG7.js → chunk-VUHKG4KS.js} +3 -3
  136. package/{chunk-EEOOBRA7.js → chunk-W3HSD32M.js} +13 -6
  137. package/{chunk-P2ZLUIW2.js → chunk-W6T4FNZP.js} +351 -26
  138. package/chunk-WDWZPASX.js +29 -0
  139. package/{chunk-R6Z5S5GA.js → chunk-WQDTSK5U.js} +51 -14
  140. package/{chunk-X3E6EHJW.js → chunk-X22AUZKL.js} +149 -165
  141. package/{chunk-4ZGPHFLE.js → chunk-X3OZ655T.js} +2 -2
  142. package/{chunk-RRDRQOEC.js → chunk-XCA4WHX5.js} +95 -77
  143. package/{chunk-TI2EPRHE.js → chunk-XJSEST7D.js} +3 -3
  144. package/{chunk-3QIYD3VM.js → chunk-XNTZD4AE.js} +870 -1068
  145. package/chunk-XSRSAU3O.js +133 -0
  146. package/{chunk-7FEP5USX.js → chunk-Y4NPF2UN.js} +3 -3
  147. package/{chunk-FJSNBZXR.js → chunk-YDRRGVT5.js} +1 -1
  148. package/{chunk-7BCG67EI.js → chunk-YFW4H6DL.js} +405 -338
  149. package/{chunk-JQZRSXS5.js → chunk-YGDYYFRX.js} +9 -13
  150. package/{chunk-4N6G2CKP.js → chunk-YHNUDTU4.js} +49 -3
  151. package/chunk-YJPK35HB.js +175 -0
  152. package/{chunk-6OVNSQHN.js → chunk-YLAHYLDQ.js} +5 -0
  153. package/{chunk-FPBJM2BW.js → chunk-Z7KE4K3H.js} +195 -126
  154. package/{chunk-DGYCDA6W.js → chunk-ZM5AZTQG.js} +20 -13
  155. package/{chunk-CBUZ6DKA.js → chunk-ZQ6K57FJ.js} +1 -1
  156. package/{cliAgentConfigHelpers-BTRHMPW2.js → cliAgentConfigHelpers-37ZNEY5Y.js} +9 -9
  157. package/{cliAuthorityBrokerClient-XHH7MH2P.js → cliAuthorityBrokerClient-SFPC3WVK.js} +1 -1
  158. package/{cliLocalAgentRecordReader-H3HYQRRR.js → cliLocalAgentRecordReader-MCQVRWBR.js} +58 -47
  159. package/{commandRegistry-FVYPE2IN.js → commandRegistry-NTH5IAN5.js} +104 -92
  160. package/{contentThunks-GNFPG32S.js → contentThunks-SPXTX5U2.js} +38 -36
  161. package/{cooldownCommands-YB5H5BBK.js → cooldownCommands-TIFCHCUN.js} +1 -1
  162. package/{createAgentAutomationAction-PB4QIFQ4.js → createAgentAutomationAction-KUQKCOXB.js} +38 -36
  163. package/{createDialogAction-EVTOPY7A.js → createDialogAction-HJN5U3XS.js} +39 -37
  164. package/{createPageAction-2UYF2IDZ.js → createPageAction-ZAHRDOAU.js} +43 -41
  165. package/{db-M7FU2GNK.js → db-CMUTP3W5.js} +2 -2
  166. package/{dbSlice-XRUZOGSU.js → dbSlice-656PMWR2.js} +13 -12
  167. package/{deleteFile-6URDHYRB.js → deleteFile-ZCQESEEQ.js} +10 -7
  168. package/{dialogCommands-6SZD4TYP.js → dialogCommands-KZTZLWPZ.js} +60 -54
  169. package/dialogMessageRecord-OAV77LT7.js +7 -0
  170. package/{dialogNotifyCommand-SHGPCU22.js → dialogNotifyCommand-PST75COP.js} +11 -11
  171. package/{dialogSlice-5EQ2A6LY.js → dialogSlice-BXIERQHO.js} +39 -37
  172. package/{dialogUsageCommand-W2WCSGKF.js → dialogUsageCommand-6RW2FY6K.js} +5 -5
  173. package/{docCreateCommands-25E6PGN3.js → docCreateCommands-26HJ5NAY.js} +54 -47
  174. package/{docDeleteCommands-F7ZVGEHW.js → docDeleteCommands-UAOHH5XK.js} +56 -49
  175. package/{docReadCommands-JY2E5XEN.js → docReadCommands-4ADG7YE6.js} +54 -47
  176. package/{docStore-OKKIKLT3.js → docStore-FZ75HWP2.js} +15 -14
  177. package/{docUpdateCommands-OZ4CUSIQ.js → docUpdateCommands-OGFJZENF.js} +54 -47
  178. package/fetchMessages-TQEUZD7H.js +1 -1
  179. package/{getPricing-LF5C4XSI.js → getPricing-FCHYVRJU.js} +4 -4
  180. package/{handleSendMessageAction-LNT7SZND.js → handleSendMessageAction-KP6GGBFY.js} +82 -78
  181. package/{hostCredentialCreate-XUU2CSHI.js → hostCredentialCreate-23TX56G7.js} +117 -105
  182. package/index.js +8 -8
  183. package/{lib-OT5OTXRU.js → lib-62SWPXNF.js} +3 -7
  184. package/{localDialogRead-CCOCVGAP.js → localDialogRead-CIOTQM5T.js} +1 -1
  185. package/{localRuntimeAdapter-IBSTMSX7.js → localRuntimeAdapter-MTUWOYPN.js} +124 -111
  186. package/{localRuntimeAuthority-IBJAT62G.js → localRuntimeAuthority-TYHQCTZN.js} +5 -3
  187. package/{localRuntimeDb-N7KHDXS2.js → localRuntimeDb-BO7IVWAZ.js} +1 -1
  188. package/{machineCommands-HSQHDHOT.js → machineCommands-4WJUJQHW.js} +241 -321
  189. package/{machineWsRunDispatch-L6H7J66T.js → machineWsRunDispatch-V3U4JM67.js} +113 -102
  190. package/markdownToSlate-KIYM7B3P.js +8 -0
  191. package/mcpLocalAuthorizeCommand-TI656UWC.js +106 -0
  192. package/{memberThunks-7Y3OYSJQ.js → memberThunks-JFYC4Z5L.js} +20 -15
  193. package/{models-H5NNZRLH.js → models-EP7VG6N2.js} +2 -2
  194. package/{overlay-BBQZXGYI.js → overlay-JA3SPVUS.js} +5 -3
  195. package/package.json +1 -1
  196. package/{projectArchive-FQO654Z3.js → projectArchive-NU2Z5HOR.js} +45 -43
  197. package/{providerPresetApply-WHAMP2D5.js → providerPresetApply-4H7YP5D7.js} +6 -6
  198. package/{providerRegistry-ZI2KORJ7.js → providerRegistry-F3UPOTIY.js} +6 -6
  199. package/{read-TYMBGEXO.js → read-BRZHXUJ6.js} +9 -8
  200. package/{readDocTool-SKQVHBLO.js → readDocTool-N7RVFQEE.js} +1 -1
  201. package/{readlineWorkspace-7U272DSA.js → readlineWorkspace-T56MRMS5.js} +6423 -3669
  202. package/rememberExplicit-CPAPONSI.js +15 -0
  203. package/{removeDialogAgentAction-F5QE2O2B.js → removeDialogAgentAction-J7XU7OUX.js} +19 -18
  204. package/{runAgentClientLoop-AF4JQIJ7.js → runAgentClientLoop-O2GRCGRZ.js} +96 -76
  205. package/{runtimeDoctorCommands-RRKPBGVO.js → runtimeDoctorCommands-RDRJXMXC.js} +8 -8
  206. package/{secretCommands-KZWBZIYS.js → secretCommands-2FEMRUFM.js} +3 -3
  207. package/{setDialogExtraReferencesAction-72L27ERM.js → setDialogExtraReferencesAction-Q4V2ZZW2.js} +16 -15
  208. package/{setPrimaryDialogAgentAction-GJJDUSGJ.js → setPrimaryDialogAgentAction-742H5S6T.js} +19 -18
  209. package/{settingThunks-ZRGWVGZD.js → settingThunks-T4FXSV6M.js} +185 -66
  210. package/{skillDiscovery-BHHPCUHZ.js → skillDiscovery-MDDKPTW3.js} +4 -3
  211. package/{spaceCommands-5VNWMDBE.js → spaceCommands-W5TAVFDT.js} +58 -51
  212. package/{streamAgentChatTurn-YSPEFY4K.js → streamAgentChatTurn-OWDJMU5E.js} +234 -177
  213. package/{switchDialogAgentAction-IIJBPND3.js → switchDialogAgentAction-HLDLHRRA.js} +17 -16
  214. package/{tableCommands-FTAOCBTX.js → tableCommands-44GC4N6J.js} +8 -5
  215. package/{toolApiClient-OGQEBQVX.js → toolApiClient-N5PYW2R3.js} +8 -6
  216. package/{tools-M35PTIFB.js → tools-O7SGGVA3.js} +65 -62
  217. package/{tuiRestart-2IL37YIB.js → tuiRestart-EOGC2BYY.js} +10 -10
  218. package/{tuiSummaryLlmCaller-W2QN4VAC.js → tuiSummaryLlmCaller-TM5BU73J.js} +16 -15
  219. package/{updateCommands-CPATDG6J.js → updateCommands-FBYA5WVG.js} +3 -3
  220. package/{updateDialogTitleAction-IMIRJRQQ.js → updateDialogTitleAction-EXSZGTLL.js} +40 -38
  221. package/{usageCommand-2BF74MKF.js → usageCommand-L4OFWXEU.js} +2 -2
  222. package/{usageRebuildCommand-UHB55BQM.js → usageRebuildCommand-7JR33UHS.js} +3 -3
  223. package/webapi-QVV65DQF.js +2487 -0
  224. package/{windowsSelfUpdate-ZFD6J5HF.js → windowsSelfUpdate-M4V77OUB.js} +2 -2
  225. package/workContext-Y3ADAPZU.js +14 -0
  226. package/workContextAccess-VU5I4LKZ.js +11 -0
  227. package/workContextWriteNotice-YCSSMHN4.js +7 -0
  228. package/{workloadLifecycle-HFJIN5IZ.js → workloadLifecycle-ZCSQCHG3.js} +2 -2
  229. package/agentRecordCommands-IZYUVHME.js +0 -177
  230. package/chunk-5ZMIIR23.js +0 -265
  231. package/chunk-62HXNQVV.js +0 -134
  232. package/chunk-TUSTONB3.js +0 -81
  233. package/chunk-ZXF6D3I6.js +0 -359
  234. package/{chunk-W6RFEDN4.js → chunk-AETZ7AD6.js} +3 -3
  235. /package/{chunk-FJ23FZXF.js → chunk-VIYVRPMJ.js} +0 -0
@@ -2,14 +2,13 @@ import {
2
2
  findPotentialSecrets
3
3
  } from "./chunk-6QDYSCPW.js";
4
4
  import {
5
- applyMemoryInterpreterMutation,
6
5
  deriveStateResident,
7
6
  resolvePureVNextRuntime,
8
7
  touchMemoryItemsInDb
9
- } from "./chunk-ZOHO6MOF.js";
8
+ } from "./chunk-GAHJLSDO.js";
10
9
  import {
11
10
  getReadableCliDb
12
- } from "./chunk-YFLVRVYK.js";
11
+ } from "./chunk-D25ONVOH.js";
13
12
  import {
14
13
  INSTABOX_RUN_CONFIG_ENV,
15
14
  buildLocalRunEnv,
@@ -23,7 +22,6 @@ import {
23
22
  isInstaboxBillingPolicy,
24
23
  isLiveAgentRunObservation,
25
24
  isMachineBoundLocalhostCustomProvider,
26
- isSubtaskRun,
27
25
  normalizeCliRunImages,
28
26
  parseAgentRunArgs,
29
27
  parseAgentRunEvent,
@@ -35,30 +33,21 @@ import {
35
33
  resolveServerUrl,
36
34
  validateInstaboxWorkspaceSelection,
37
35
  writeUsage
38
- } from "./chunk-DLXMMTGM.js";
36
+ } from "./chunk-SCMYAGQE.js";
39
37
  import {
40
38
  boxGlyphs,
41
39
  displayWidth,
40
+ fitAnsiLine,
41
+ resolveAmbiguousWidth,
42
42
  resolveBoxCharset,
43
43
  stripAnsi,
44
44
  tokenizeAnsiLine,
45
45
  visibleWidth
46
- } from "./chunk-XSW4EXQV.js";
46
+ } from "./chunk-6TVYUQRM.js";
47
47
  import {
48
48
  clearCredentialAvailability,
49
49
  readEffectiveCredentialEntry
50
50
  } from "./chunk-WWTSEBDF.js";
51
- import {
52
- CliProviderQuotaError
53
- } from "./chunk-R7XWZDOH.js";
54
- import {
55
- resolveMachineId
56
- } from "./chunk-S73EPYNC.js";
57
- import {
58
- getMemoryEvidenceVNextStrict,
59
- loadMemoryVNextCatalog,
60
- putMemoryEvidenceVNext
61
- } from "./chunk-324FWHUA.js";
62
51
  import {
63
52
  rankMemoryCandidates,
64
53
  recallMemoryVNextLocal
@@ -67,26 +56,44 @@ import {
67
56
  DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET,
68
57
  EXPLICIT_REMEMBER_PREFIX_REGEX,
69
58
  buildMemoryOverlay,
70
- emptyMemoryInjectionObservation
71
- } from "./chunk-4I2MXV5Q.js";
59
+ emptyMemoryInjectionObservation,
60
+ estimateMemoryBlockTokens
61
+ } from "./chunk-PVFYPUIM.js";
72
62
  import {
73
63
  buildLegacyMemoryEvidence,
74
64
  resolveLegacyMemoryPrincipal
75
65
  } from "./chunk-QHEN7NZ7.js";
76
66
  import {
77
- isBuiltinNoloAgentRef,
78
- resolveLocalUserId
79
- } from "./chunk-HHFGE2WF.js";
67
+ resolveWorkContextAccess
68
+ } from "./chunk-IIRJ4P4I.js";
80
69
  import {
81
- extractGoogleValidationLink
82
- } from "./chunk-BMQ2MJUK.js";
70
+ isWorkContextState,
71
+ readWorkContexts
72
+ } from "./chunk-C5A54QS7.js";
73
+ import {
74
+ applyMemoryInterpreterMutation
75
+ } from "./chunk-6RSNVJGO.js";
76
+ import {
77
+ getMemoryEvidenceVNextStrict,
78
+ loadMemoryVNextCatalog,
79
+ putMemoryEvidenceVNext
80
+ } from "./chunk-324FWHUA.js";
81
+ import {
82
+ CliProviderQuotaError
83
+ } from "./chunk-R7XWZDOH.js";
84
+ import {
85
+ resolveMachineId
86
+ } from "./chunk-S73EPYNC.js";
83
87
  import {
84
88
  resolveCliLocalRuntimeKeyCapability
85
- } from "./chunk-GAYNXB6T.js";
89
+ } from "./chunk-FTWAOKFU.js";
90
+ import {
91
+ extractGoogleValidationLink
92
+ } from "./chunk-BMQ2MJUK.js";
86
93
  import {
87
94
  parseUiCard,
88
95
  uiCardFallback
89
- } from "./chunk-HF7BLF3F.js";
96
+ } from "./chunk-LMGFVH65.js";
90
97
  import {
91
98
  isGatewayHttpStatus
92
99
  } from "./chunk-NF64D32W.js";
@@ -95,38 +102,31 @@ import {
95
102
  chooseMemoryOwners,
96
103
  loadMemoryCandidatesFromDb,
97
104
  loadOwnerItemsFromDb,
105
+ parseUiAskChoiceContent,
98
106
  resolveAgentMemoryPolicy
99
- } from "./chunk-4QYJPWHH.js";
107
+ } from "./chunk-ODBYGVO2.js";
100
108
  import {
101
109
  API_REPORTED_COST_MULTIPLIER,
102
110
  estimateMessagesTokens,
103
111
  isAgentRunStartFailureStatus,
104
112
  isAgentRunStatusNormal,
105
- parseUiAskChoiceContent,
106
113
  resolveAgentContextWindow,
107
114
  resolveOccupancy,
108
115
  resolveOccupancyWindow
109
- } from "./chunk-7BCG67EI.js";
116
+ } from "./chunk-YFW4H6DL.js";
110
117
  import {
111
118
  parsePositiveFiniteNumberOrFallback
112
119
  } from "./chunk-Y5GCAMGP.js";
113
120
  import {
114
121
  readDbRecord,
115
122
  resolveAgentRecordFromHybridStore
116
- } from "./chunk-TQEKUOTI.js";
123
+ } from "./chunk-CIUZXD5D.js";
117
124
  import {
118
125
  isTransientFetchError
119
126
  } from "./chunk-DXWGFL2Z.js";
120
- import {
121
- isCliAuthorityBrokerProtocolError,
122
- isCliAuthorityBrokerTimeoutError,
123
- isCliAuthorityBrokerUnavailableError
124
- } from "./chunk-5ZMIIR23.js";
125
- import {
126
- getDefaultCliLocalRuntimeDb
127
- } from "./chunk-N5Z2V73W.js";
128
127
  import {
129
128
  awaitLocalWriterChild,
129
+ createMcpApprovalChild,
130
130
  createRunActivityTracker,
131
131
  createShellApprovalChild,
132
132
  getRunResultHeaderMeta,
@@ -144,7 +144,7 @@ import {
144
144
  settleRunTerminalAuthoritatively,
145
145
  spawnLocalBackgroundRun,
146
146
  transitionRunToTerminal
147
- } from "./chunk-OWKNSIXL.js";
147
+ } from "./chunk-AEZBAFC6.js";
148
148
  import {
149
149
  formatAgentListCard,
150
150
  formatFinishedRunCard,
@@ -155,26 +155,33 @@ import {
155
155
  formatStopRunCard,
156
156
  getAgentRunStatusIcon,
157
157
  isAgentRunTerminalStatus
158
- } from "./chunk-OOJNQK6V.js";
159
- import {
160
- isLocalCliAgentKey
161
- } from "./chunk-BR3GT6MR.js";
158
+ } from "./chunk-S25VJYXV.js";
162
159
  import {
163
160
  buildSkillDiscoveryContextLayer
164
- } from "./chunk-5YMA6DDZ.js";
161
+ } from "./chunk-UHW6SCVK.js";
162
+ import {
163
+ isCliAuthorityBrokerProtocolError,
164
+ isCliAuthorityBrokerTimeoutError,
165
+ isCliAuthorityBrokerUnavailableError
166
+ } from "./chunk-KK3FCYZM.js";
167
+ import {
168
+ getDefaultCliLocalRuntimeDb
169
+ } from "./chunk-BFKJ2RS3.js";
165
170
  import {
166
171
  LOCAL_AGENT_CONFIG_MISSING_CODE,
167
172
  LOCAL_TURN_ABORTED_CODE,
173
+ buildLocalDialogWritePlan,
174
+ dialogOwnerKey,
175
+ dialogTurnUserMessageId,
176
+ isSubtaskRun,
168
177
  markCliUserBatchPhase,
169
178
  readActionGate,
170
- readAgentsMdLayerFromDisk
171
- } from "./chunk-3QIYD3VM.js";
179
+ readAgentsMdLayerFromDisk,
180
+ registerDialogOwner
181
+ } from "./chunk-XNTZD4AE.js";
172
182
  import {
173
183
  resolveAgentRuntimeConfigFromRecord
174
- } from "./chunk-XAG3FWBE.js";
175
- import {
176
- resolveAgentImageInputSupport
177
- } from "./chunk-DUUDXSLX.js";
184
+ } from "./chunk-4OXPN3WC.js";
178
185
  import {
179
186
  createThinkParserState,
180
187
  flushThinkParser,
@@ -187,17 +194,23 @@ import {
187
194
  resolveAvailabilityAction,
188
195
  resolveCredentialKeyWithFallback
189
196
  } from "./chunk-QJTZ76CP.js";
197
+ import {
198
+ resolveAgentImageInputSupport
199
+ } from "./chunk-SX6AWTNK.js";
200
+ import {
201
+ isContextOverflowText
202
+ } from "./chunk-TLE77UJ5.js";
190
203
  import {
191
204
  ATTACHMENT_PART_TYPE,
192
205
  ATTACHMENT_PART_VERSION,
193
206
  describeAttachmentForModel,
194
207
  normalizeAttachmentPart
195
- } from "./chunk-QRGDJA4B.js";
208
+ } from "./chunk-LTVEOOZL.js";
196
209
  import {
197
210
  findCodexOAuthPinnedContextWindow,
198
211
  normalizeUsage,
199
212
  readCacheReadInputTokensOrNull
200
- } from "./chunk-L32W3PRP.js";
213
+ } from "./chunk-MAA42MMV.js";
201
214
  import {
202
215
  isOAuthApiKeyRef
203
216
  } from "./chunk-UKZX3NHN.js";
@@ -209,8 +222,8 @@ import {
209
222
  resolveEffectiveRuntimeToolPolicy
210
223
  } from "./chunk-USGHJSGO.js";
211
224
  import {
212
- compactWhitespace
213
- } from "./chunk-DWLEOOGR.js";
225
+ workspaceChildEnv
226
+ } from "./chunk-CTIEJRTP.js";
214
227
  import {
215
228
  QUOTA_ERROR_PATTERNS,
216
229
  isQuotaExhaustedError
@@ -218,28 +231,43 @@ import {
218
231
  import {
219
232
  estimateTokenCount
220
233
  } from "./chunk-PSCNXBYA.js";
234
+ import {
235
+ compactWhitespace
236
+ } from "./chunk-DWLEOOGR.js";
237
+ import {
238
+ buildMemoryOverlayLayer,
239
+ buildMemoryUseGuidanceLayer,
240
+ partitionScopedBlocks,
241
+ renderTurnContextBlocksWithScope
242
+ } from "./chunk-5HUO7SEX.js";
243
+ import {
244
+ isTombstoneRecord
245
+ } from "./chunk-BV3FLP2L.js";
221
246
  import {
222
247
  parseExternalSkillMarkdown,
223
248
  parseSkillDocProtocol
224
- } from "./chunk-W6RFEDN4.js";
249
+ } from "./chunk-AETZ7AD6.js";
250
+ import {
251
+ buildDialogKey,
252
+ dialogMessageKey,
253
+ ulid
254
+ } from "./chunk-OJKUU3LP.js";
255
+ import {
256
+ isBuiltinNoloAgentRef,
257
+ resolveLocalUserId
258
+ } from "./chunk-UPOW5HTG.js";
259
+ import {
260
+ isLocalCliAgentKey
261
+ } from "./chunk-BR3GT6MR.js";
225
262
  import {
226
263
  BUILTIN_NOLO_AGENT_KEY,
227
264
  BUILTIN_NOLO_AGENT_NAME,
228
265
  builtinAgentCatalogEntryById,
229
266
  parseBuiltinPlatformAgentId
230
- } from "./chunk-ILHQ2AXT.js";
267
+ } from "./chunk-KZAT2M2V.js";
231
268
  import {
232
269
  parsePublicAgentId
233
270
  } from "./chunk-M2EJHDJP.js";
234
- import {
235
- ulid
236
- } from "./chunk-OJKUU3LP.js";
237
- import {
238
- buildMemoryOverlayLayer,
239
- buildMemoryUseGuidanceLayer,
240
- partitionScopedBlocks,
241
- renderTurnContextBlocksWithScope
242
- } from "./chunk-42OKN2LI.js";
243
271
  import {
244
272
  exitCliFromWatchdog,
245
273
  getLogger,
@@ -259,24 +287,28 @@ import {
259
287
  agentRunCardLabels,
260
288
  getCliLocale,
261
289
  t,
290
+ toolFamilyLabel,
291
+ toolFamilyOf,
292
+ toolFamilyOfIcon,
293
+ toolIcon,
262
294
  toolLabel,
263
295
  toolLabelVariants
264
- } from "./chunk-262R3XNN.js";
296
+ } from "./chunk-E5RYFR7E.js";
265
297
  import {
266
298
  isAntigravityOAuthAgent
267
- } from "./chunk-7JGMNKKG.js";
268
- import {
269
- resolveClientVersion
270
- } from "./chunk-RTHFJZ6M.js";
299
+ } from "./chunk-CTWCZKNS.js";
271
300
  import {
272
301
  toErrorMessage
273
302
  } from "./chunk-HNMXYYJR.js";
303
+ import {
304
+ resolveClientVersion
305
+ } from "./chunk-K26XPZRB.js";
274
306
  import {
275
307
  asTrimmedString
276
308
  } from "./chunk-3EUW3WEO.js";
277
309
  import {
278
310
  findModelConfig
279
- } from "./chunk-CD3RU7XL.js";
311
+ } from "./chunk-CD2DK5JA.js";
280
312
  import {
281
313
  asOptionalTrimmedString
282
314
  } from "./chunk-G3SUCT4W.js";
@@ -284,13 +316,13 @@ import {
284
316
  CLIENT_VERSION_TOO_OLD_CODE,
285
317
  NOLO_CLIENT_VERSION_HEADER,
286
318
  buildClientVersionUpgradeMessage
287
- } from "./chunk-OBSEKCVK.js";
319
+ } from "./chunk-PQ63BDV3.js";
288
320
  import {
289
321
  asTrimmedLowercaseString
290
322
  } from "./chunk-QSJ3HFEF.js";
291
323
 
292
324
  // packages/cli/agentRunCommand.ts
293
- import { createHash as createHash3 } from "node:crypto";
325
+ import { createHash as createHash2 } from "node:crypto";
294
326
 
295
327
  // packages/cli/agentRunLocalWorkspace.ts
296
328
  import { createHash } from "node:crypto";
@@ -1053,6 +1085,75 @@ ${cardText}` : cardText;
1053
1085
  // packages/chat/messages/attachmentWriteRollout.ts
1054
1086
  var ENABLE_REMOTE_ATTACHMENT_PART_WRITES = false;
1055
1087
 
1088
+ // packages/cli/client/cliTurnUserMessage.ts
1089
+ async function resolvePersistedTurnUserMessageId(input) {
1090
+ const { store, dialogId, userId, userMessages, batchMessageIds } = input;
1091
+ if (userMessages && userMessages.length !== 1) return void 0;
1092
+ if (batchMessageIds && batchMessageIds.length !== 1) return void 0;
1093
+ const candidate = userMessages ? userMessages[0]?.cliMessageId : batchMessageIds?.[0];
1094
+ if (!candidate || batchMessageIds && batchMessageIds[0] !== candidate) return void 0;
1095
+ try {
1096
+ await resolveWorkContextAccess({ get: (key) => store.read(key, { remote: false }) }, userId, dialogId, candidate);
1097
+ return candidate;
1098
+ } catch {
1099
+ return void 0;
1100
+ }
1101
+ }
1102
+ async function persistDirectWorkMemorySource(args) {
1103
+ const { store, userId, dialogId, turnId, message } = args;
1104
+ if (!userId || userId === "server" || !/^[A-Za-z0-9_-]{1,128}$/.test(dialogId)) return void 0;
1105
+ const id = dialogTurnUserMessageId(turnId, 0);
1106
+ if (!id || message.role !== "user" || message.id !== id || typeof message.content !== "string") return void 0;
1107
+ const dialogKey = buildDialogKey(userId, dialogId);
1108
+ const messageKey = dialogMessageKey(dialogId, id);
1109
+ const existingDialog = await store.read(dialogKey, { remote: false });
1110
+ if (existingDialog) {
1111
+ await resolveWorkContextAccess({ get: async () => existingDialog }, userId, dialogId);
1112
+ } else if (!args.freshDialog) {
1113
+ return void 0;
1114
+ }
1115
+ const existingMessage = await store.read(messageKey, { remote: false });
1116
+ if (!existingMessage) {
1117
+ const { ops } = buildLocalDialogWritePlan({
1118
+ input: { ...args.input, continueDialogId: dialogId, messages: [message], result: { content: "", model: "" } },
1119
+ userId,
1120
+ now: Date.now(),
1121
+ createId: () => dialogId,
1122
+ existingDialog
1123
+ });
1124
+ const userOp = ops.find((op) => op.key === messageKey && op.value.role === "user");
1125
+ const dialogOp = ops.find((op) => op.key === dialogKey);
1126
+ if (!userOp || !dialogOp) return void 0;
1127
+ const { status, finishedAt, ...openDialog } = dialogOp.value;
1128
+ if (!existingDialog) {
1129
+ await registerDialogOwner({
1130
+ store: {
1131
+ get: (key) => store.read(key, { remote: false }),
1132
+ put: (key, value) => store.batch([{ type: "put", key, value }])
1133
+ },
1134
+ dialogId,
1135
+ ownerId: userId,
1136
+ spaceId: args.input.spaceId,
1137
+ source: "cli-work-memory-source"
1138
+ });
1139
+ const owner = await store.read(dialogOwnerKey(dialogId), { remote: false });
1140
+ if (owner?.dialogId !== dialogId || owner.ownerId !== userId) return void 0;
1141
+ const currentDialog = await store.read(dialogKey, { remote: false });
1142
+ if (currentDialog) {
1143
+ await resolveWorkContextAccess({ get: async () => currentDialog }, userId, dialogId);
1144
+ await store.batch([userOp]);
1145
+ } else {
1146
+ await store.batch([{ ...dialogOp, value: openDialog }, userOp]);
1147
+ }
1148
+ } else {
1149
+ await store.batch([userOp]);
1150
+ }
1151
+ }
1152
+ const persisted = await store.read(messageKey, { remote: false });
1153
+ if (!persisted || isTombstoneRecord(persisted) || persisted.content !== message.content) return void 0;
1154
+ return resolvePersistedTurnUserMessageId({ store, userId, dialogId, userMessages: [{ cliMessageId: id }] });
1155
+ }
1156
+
1056
1157
  // packages/cli/client/tokenUsage.ts
1057
1158
  var PLATFORM_CREDIT_UNIT = "credits";
1058
1159
  var isUsableModelId = (model) => {
@@ -1326,6 +1427,40 @@ function formatCliHyperlink(url, label, enabled = resolveCliHyperlinkEnabled())
1326
1427
 
1327
1428
  // packages/cli/tui/theme.ts
1328
1429
  var THEME_PALETTES = {
1430
+ nature: {
1431
+ light: {
1432
+ accent: { hex: "1A5FA4", ansiFallback: "\x1B[34m" },
1433
+ // deep ocean ink (--hl-blue-text, 6.53:1 on #FFFFFF)
1434
+ chrome: { hex: "78828E", ansiFallback: "\x1B[90m" },
1435
+ // mist slate (3.90:1 on #FFFFFF — structural rules/comments recede cleanly)
1436
+ success: { hex: "267347", ansiFallback: "\x1B[32m" },
1437
+ // pine forest green (5.61:1 on #FFFFFF)
1438
+ warning: { hex: "966014", ansiFallback: "\x1B[33m" },
1439
+ // warm sand amber (5.38:1 on #FFFFFF, never muddy yellow)
1440
+ info: { hex: "1B6F8A", ansiFallback: "\x1B[36m" },
1441
+ // fjord cyan-blue (5.77:1 on #FFFFFF, distinct from accent)
1442
+ danger: { hex: "BE3428", ansiFallback: "\x1B[31m" },
1443
+ // terracotta red (5.68:1 on #FFFFFF)
1444
+ muted: { hex: "525D6B", ansiFallback: "\x1B[90m" }
1445
+ // mountain granite (6.73:1 on #FFFFFF — crisp secondary copy)
1446
+ },
1447
+ dark: {
1448
+ accent: { hex: "6AA8EA", ansiFallback: "\x1B[94m" },
1449
+ // moonlight ocean (--hl-blue dark, 6.89:1 on #1C1C1F)
1450
+ chrome: { hex: "6E7683", ansiFallback: "\x1B[90m" },
1451
+ // night stone (3.69:1 on #1C1C1F — clear rules/comments below muted)
1452
+ success: { hex: "72C488", ansiFallback: "\x1B[32m" },
1453
+ // alpine meadow green (8.22:1 on #1C1C1F)
1454
+ warning: { hex: "DDA955", ansiFallback: "\x1B[33m" },
1455
+ // sunset sand gold (7.98:1 on #1C1C1F)
1456
+ info: { hex: "5EB5C8", ansiFallback: "\x1B[36m" },
1457
+ // glacier stream cyan (7.36:1 on #1C1C1F)
1458
+ danger: { hex: "E6766B", ansiFallback: "\x1B[31m" },
1459
+ // warm coral clay (5.86:1 on #1C1C1F)
1460
+ muted: { hex: "9AA3B0", ansiFallback: "\x1B[90m" }
1461
+ // silver mist (6.67:1 on #1C1C1F — legible status & tool details)
1462
+ }
1463
+ },
1329
1464
  trail: {
1330
1465
  light: {
1331
1466
  accent: { hex: "2E7DB5", ansiFallback: "\x1B[34m" },
@@ -1336,8 +1471,8 @@ var THEME_PALETTES = {
1336
1471
  // moss green
1337
1472
  warning: { hex: "9A6A1F", ansiFallback: "\x1B[33m" },
1338
1473
  // deeper amber — B57F2E still read as yellow/washed on white (H2 headers like ## Plan floated); 9A6A1F raises contrast
1339
- info: { hex: "4A9FD4", ansiFallback: "\x1B[36m" },
1340
- // sky blue
1474
+ info: { hex: "2376A6", ansiFallback: "\x1B[36m" },
1475
+ // deepened sky blue (5.05:1 on white; 4A9FD4 was only 3.0:1)
1341
1476
  danger: { hex: "C45C4A", ansiFallback: "\x1B[31m" },
1342
1477
  // reddish
1343
1478
  muted: { hex: "5E6A78", ansiFallback: "\x1B[90m" }
@@ -1346,7 +1481,7 @@ var THEME_PALETTES = {
1346
1481
  dark: {
1347
1482
  accent: { hex: "5BA3D9", ansiFallback: "\x1B[94m" },
1348
1483
  // trail dark primary (was wrongly copied from catppuccin 89B4FA)
1349
- chrome: { hex: "6C7086", ansiFallback: "\x1B[90m" },
1484
+ chrome: { hex: "747E91", ansiFallback: "\x1B[90m" },
1350
1485
  success: { hex: "5CB87A", ansiFallback: "\x1B[32m" },
1351
1486
  // trail dark success (was A6E3A1)
1352
1487
  warning: { hex: "E6B35C", ansiFallback: "\x1B[33m" },
@@ -1362,17 +1497,19 @@ var THEME_PALETTES = {
1362
1497
  catppuccin: {
1363
1498
  light: {
1364
1499
  accent: { hex: "0969DA", ansiFallback: "\x1B[34m" },
1365
- chrome: { hex: "57606A", ansiFallback: "\x1B[90m" },
1500
+ chrome: { hex: "77808B", ansiFallback: "\x1B[90m" },
1501
+ // lighter than muted so structural chrome recedes below secondary text
1366
1502
  success: { hex: "116329", ansiFallback: "\x1B[32m" },
1367
1503
  warning: { hex: "9A6700", ansiFallback: "\x1B[33m" },
1368
- info: { hex: "0969DA", ansiFallback: "\x1B[36m" },
1504
+ info: { hex: "0E7490", ansiFallback: "\x1B[36m" },
1505
+ // distinct cyan-teal rather than duplicating accent
1369
1506
  danger: { hex: "CF222E", ansiFallback: "\x1B[31m" },
1370
- muted: { hex: "6E7781", ansiFallback: "\x1B[90m" }
1507
+ muted: { hex: "57606A", ansiFallback: "\x1B[90m" }
1371
1508
  },
1372
1509
  dark: {
1373
1510
  accent: { hex: "89B4FA", ansiFallback: "\x1B[94m" },
1374
1511
  // Catppuccin Mocha Blue
1375
- chrome: { hex: "6C7086", ansiFallback: "\x1B[90m" },
1512
+ chrome: { hex: "7F849C", ansiFallback: "\x1B[90m" },
1376
1513
  success: { hex: "A6E3A1", ansiFallback: "\x1B[32m" },
1377
1514
  warning: { hex: "F9E2AF", ansiFallback: "\x1B[33m" },
1378
1515
  info: { hex: "89B4FA", ansiFallback: "\x1B[36m" },
@@ -1463,7 +1600,7 @@ var THEME_PALETTES = {
1463
1600
  }
1464
1601
  }
1465
1602
  };
1466
- var activeThemeName = "catppuccin";
1603
+ var activeThemeName = "nature";
1467
1604
  function getActiveThemeName() {
1468
1605
  return activeThemeName;
1469
1606
  }
@@ -1476,15 +1613,21 @@ function setActiveThemeName(name) {
1476
1613
  }
1477
1614
  var activeThemeMode = "terminal";
1478
1615
  var resolvedBrightness = null;
1616
+ var terminalModeExplicit = false;
1479
1617
  function getActiveThemeMode() {
1480
1618
  return activeThemeMode;
1481
1619
  }
1482
- function setActiveThemeMode(mode) {
1620
+ function setActiveThemeMode(mode, options) {
1483
1621
  activeThemeMode = mode;
1484
- if (mode === "terminal") resolvedBrightness = null;
1622
+ if (mode === "terminal") {
1623
+ resolvedBrightness = null;
1624
+ terminalModeExplicit = options?.explicit === true;
1625
+ } else {
1626
+ terminalModeExplicit = false;
1627
+ }
1485
1628
  }
1486
- function setActiveBrightness(brightness) {
1487
- setActiveThemeMode(brightness ?? "terminal");
1629
+ function setActiveBrightness(brightness, options) {
1630
+ setActiveThemeMode(brightness ?? "terminal", options);
1488
1631
  }
1489
1632
  var TRUECOLOR_TERM_PROGRAMS = /* @__PURE__ */ new Set([
1490
1633
  "iterm.app",
@@ -1494,12 +1637,17 @@ var TRUECOLOR_TERM_PROGRAMS = /* @__PURE__ */ new Set([
1494
1637
  "hyper",
1495
1638
  "tabby",
1496
1639
  "rio",
1497
- "warpterminal"
1640
+ "warpterminal",
1641
+ "ptyxis"
1498
1642
  ]);
1499
1643
  function supportsTruecolor(env = process.env) {
1500
1644
  const explicit = (env.NOLO_TUI_TRUECOLOR ?? "").trim().toLowerCase();
1501
1645
  if (explicit === "1" || explicit === "true") return true;
1502
1646
  if (explicit === "0" || explicit === "false") return false;
1647
+ if ((env.WT_SESSION ?? "").trim()) return true;
1648
+ if ((env.PTYXIS_VERSION ?? "").trim()) return true;
1649
+ const vteVersion = Number.parseInt((env.VTE_VERSION ?? "").trim(), 10);
1650
+ if (Number.isFinite(vteVersion) && vteVersion >= 3600) return true;
1503
1651
  if (/truecolor|24bit/i.test(env.COLORTERM ?? "")) return true;
1504
1652
  if (/direct|24bit/i.test(env.TERM ?? "")) return true;
1505
1653
  const program = (env.TERM_PROGRAM ?? "").toLowerCase();
@@ -1549,18 +1697,121 @@ function hexToSgrParams(hex) {
1549
1697
  const b = Number.parseInt(hex.slice(4, 6), 16);
1550
1698
  return `38;2;${r};${g};${b}`;
1551
1699
  }
1552
- function hexToSgr(hex) {
1553
- return `\x1B[${hexToSgrParams(hex)}m`;
1700
+ function relativeLuminanceFromHex(hex) {
1701
+ const channels = readHexChannels(hex.replace(/^#/, "").toUpperCase());
1702
+ if (!channels) return null;
1703
+ const linearize = (byte) => {
1704
+ const s = byte / 255;
1705
+ return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
1706
+ };
1707
+ return 0.2126 * linearize(channels[0]) + 0.7152 * linearize(channels[1]) + 0.0722 * linearize(channels[2]);
1708
+ }
1709
+ function wcagContrastRatio(fgHex, bgHex) {
1710
+ const l1 = relativeLuminanceFromHex(fgHex);
1711
+ const l2 = relativeLuminanceFromHex(bgHex);
1712
+ if (l1 === null || l2 === null) return null;
1713
+ const lighter = Math.max(l1, l2);
1714
+ const darker = Math.min(l1, l2);
1715
+ return (lighter + 0.05) / (darker + 0.05);
1716
+ }
1717
+ var POLE_LIGHT_NEUTRAL = "F7F9FC";
1718
+ var POLE_DARK_NEUTRAL = "0A0C10";
1719
+ var POLE_LIGHT_EXTREME = "FFFFFF";
1720
+ var POLE_DARK_EXTREME = "000000";
1721
+ function solveBlendForContrast(sourceHex, anchorHex, canvasHex, targetRatio) {
1722
+ let lo = 0;
1723
+ let hi = 1;
1724
+ let best = sourceHex;
1725
+ let bestErr = Math.abs((wcagContrastRatio(sourceHex, canvasHex) ?? targetRatio) - targetRatio);
1726
+ for (let step = 0; step < 16; step++) {
1727
+ const mid = (lo + hi) / 2;
1728
+ const candidate = blendHex(anchorHex, sourceHex, mid);
1729
+ const ratio = wcagContrastRatio(candidate, canvasHex) ?? targetRatio;
1730
+ const err = Math.abs(ratio - targetRatio);
1731
+ if (err < bestErr) {
1732
+ bestErr = err;
1733
+ best = candidate;
1734
+ }
1735
+ const anchorRatio = wcagContrastRatio(anchorHex, canvasHex) ?? targetRatio;
1736
+ const sourceRatio = wcagContrastRatio(sourceHex, canvasHex) ?? targetRatio;
1737
+ const increasing = anchorRatio >= sourceRatio;
1738
+ if (increasing && ratio < targetRatio || !increasing && ratio > targetRatio) {
1739
+ lo = mid;
1740
+ } else {
1741
+ hi = mid;
1742
+ }
1743
+ }
1744
+ return best;
1745
+ }
1746
+ function adaptTokenHexToCanvas(rawHex, tokenKey, canvasHex) {
1747
+ const normRaw = rawHex.replace(/^#/, "").toUpperCase();
1748
+ const normCanvas = canvasHex.replace(/^#/, "").toUpperCase();
1749
+ const canvasLum = relativeLuminanceFromHex(normCanvas);
1750
+ const ratio = wcagContrastRatio(normRaw, normCanvas);
1751
+ if (canvasLum === null || ratio === null) return normRaw;
1752
+ if (tokenKey === "chrome") {
1753
+ if (ratio < 3.25) return pushToContrast(normRaw, normCanvas, 3.7, 3.3);
1754
+ if (ratio > 4.45) return solveBlendForContrast(normRaw, normCanvas, normCanvas, 3.85);
1755
+ return normRaw;
1756
+ }
1757
+ if (tokenKey === "muted") {
1758
+ if (ratio < 5.2) return pushToContrast(normRaw, normCanvas, 6.1, 6.1);
1759
+ if (ratio > 8.2) return solveBlendForContrast(normRaw, normCanvas, normCanvas, 6.6);
1760
+ return normRaw;
1761
+ }
1762
+ if (ratio < 4.5) {
1763
+ return pushToContrast(normRaw, normCanvas, 4.85, 4.55);
1764
+ }
1765
+ return normRaw;
1766
+ }
1767
+ function polesByReach(canvasHex) {
1768
+ const ranked = [
1769
+ POLE_LIGHT_NEUTRAL,
1770
+ POLE_DARK_NEUTRAL,
1771
+ POLE_LIGHT_EXTREME,
1772
+ POLE_DARK_EXTREME
1773
+ ].map((pole) => ({ pole, reach: wcagContrastRatio(pole, canvasHex) ?? 1 }));
1774
+ const neutralFirst = (pole) => pole === POLE_LIGHT_NEUTRAL || pole === POLE_DARK_NEUTRAL ? 0 : 1;
1775
+ ranked.sort(
1776
+ (a, b) => a.reach !== b.reach ? b.reach - a.reach : neutralFirst(a.pole) - neutralFirst(b.pole)
1777
+ );
1778
+ return ranked.map((r) => r.pole);
1779
+ }
1780
+ function pushToContrast(rawHex, canvasHex, target, floor) {
1781
+ const poles = polesByReach(canvasHex);
1782
+ for (const pole of poles) {
1783
+ if ((wcagContrastRatio(pole, canvasHex) ?? 1) > target) {
1784
+ return solveBlendForContrast(rawHex, pole, canvasHex, target);
1785
+ }
1786
+ }
1787
+ const best = poles[0];
1788
+ if ((wcagContrastRatio(best, canvasHex) ?? 1) > floor) {
1789
+ return solveBlendForContrast(rawHex, best, canvasHex, floor);
1790
+ }
1791
+ return best;
1792
+ }
1793
+ function shouldUseTruecolorTokens(env) {
1794
+ if (!supportsTruecolor(env)) return false;
1795
+ const explicit = (env.NOLO_TUI_THEME ?? "").trim().toLowerCase();
1796
+ if (explicit === "terminal" || explicit === "ansi") return false;
1797
+ if (resolveTuiThemeMode(env) !== "terminal") return true;
1798
+ if (terminalModeExplicit) return false;
1799
+ return activeTerminalBaseHex !== null || detectColorFgBgBrightness(env) !== null;
1554
1800
  }
1555
1801
  function themeSgrParams(token, env = process.env, brightness = resolveTuiBrightness(env)) {
1556
- const palette = THEME_PALETTES[activeThemeName] ?? THEME_PALETTES.trail;
1802
+ const palette = THEME_PALETTES[activeThemeName] ?? THEME_PALETTES.nature;
1557
1803
  const entry = palette[brightness][token];
1558
- return resolveTuiThemeMode(env) !== "terminal" && supportsTruecolor(env) ? hexToSgrParams(entry.hex) : entry.ansiFallback.slice(2, -1);
1804
+ if (!shouldUseTruecolorTokens(env)) {
1805
+ return entry.ansiFallback.slice(2, -1);
1806
+ }
1807
+ const effectiveHex = activeTerminalBaseHex ? adaptTokenHexToCanvas(entry.hex, token, activeTerminalBaseHex) : entry.hex;
1808
+ return hexToSgrParams(effectiveHex);
1559
1809
  }
1560
1810
  function themeColorSequence(token, env = process.env, brightness = resolveTuiBrightness(env)) {
1561
1811
  return `\x1B[${themeSgrParams(token, env, brightness)}m`;
1562
1812
  }
1563
1813
  var SURFACE_HEX = {
1814
+ nature: { light: "EBF0F5", dark: "262932" },
1564
1815
  trail: { light: "E4E8EC", dark: "313244" },
1565
1816
  catppuccin: { light: "E8ECF0", dark: "181825" },
1566
1817
  wave: { light: "E5E1D6", dark: "2A2A37" },
@@ -1582,6 +1833,7 @@ function setActiveTerminalBaseHex(hex) {
1582
1833
  }
1583
1834
  function resetWorkspaceThemeState() {
1584
1835
  setActiveThemeMode("terminal");
1836
+ terminalModeExplicit = false;
1585
1837
  setActiveTerminalBaseHex(null);
1586
1838
  }
1587
1839
  function applyDetectedBackground(detected) {
@@ -1628,37 +1880,40 @@ function blendHex(fg, base, weight) {
1628
1880
  return `${r}${g}${b}`;
1629
1881
  }
1630
1882
  function diffLineSequences(env = process.env, brightness = resolveTuiBrightness(env)) {
1631
- if (resolveTuiThemeMode(env) === "terminal") return null;
1632
- if (!supportsTruecolor(env)) return null;
1633
- const palette = THEME_PALETTES[activeThemeName] ?? THEME_PALETTES.trail;
1883
+ if (resolveSurfaceWashFallback(env) !== null) return null;
1884
+ const palette = THEME_PALETTES[activeThemeName] ?? THEME_PALETTES.nature;
1634
1885
  const successHex = palette[brightness].success.hex;
1635
1886
  const dangerHex = palette[brightness].danger.hex;
1636
1887
  const infoHex = palette[brightness].info.hex;
1637
- const weight = brightness === "dark" ? 0.18 : 0.12;
1888
+ const weight = brightness === "dark" ? 0.15 : 0.1;
1638
1889
  const baseHex = resolveTerminalBaseHex(brightness);
1639
1890
  const addedBgHex = blendHex(successHex, baseHex, weight);
1640
1891
  const removedBgHex = blendHex(dangerHex, baseHex, weight);
1641
1892
  const hunkBgHex = blendHex(infoHex, baseHex, weight * 0.6);
1642
- const successSgr = hexToSgr(successHex);
1643
- const dangerSgr = hexToSgr(dangerHex);
1644
- const infoSgr = hexToSgr(infoHex);
1893
+ const successSgr = themeColorSequence("success", env, brightness);
1894
+ const dangerSgr = themeColorSequence("danger", env, brightness);
1895
+ const infoSgr = themeColorSequence("info", env, brightness);
1645
1896
  return {
1646
1897
  added: {
1647
1898
  fg: successSgr,
1648
1899
  bg: hexToBgSgr(addedBgHex),
1649
- bar: `${successSgr}\u258C\x1B[39m`
1900
+ bar: `${successSgr}\u258E\x1B[39m`
1650
1901
  },
1651
1902
  removed: {
1652
1903
  fg: dangerSgr,
1653
1904
  bg: hexToBgSgr(removedBgHex),
1654
- bar: `${dangerSgr}\u258C\x1B[39m`
1905
+ bar: `${dangerSgr}\u258E\x1B[39m`
1655
1906
  },
1656
1907
  hunk: {
1657
1908
  fg: infoSgr,
1658
1909
  bg: hexToBgSgr(hunkBgHex),
1659
- bar: " "
1910
+ bar: `${infoSgr}\u258E\x1B[39m`
1660
1911
  },
1661
- context: { fg: "", bg: "", bar: " " }
1912
+ context: {
1913
+ fg: "",
1914
+ bg: "",
1915
+ bar: `${themeColorSequence("chrome", env, brightness)}\u258E\x1B[39m`
1916
+ }
1662
1917
  };
1663
1918
  }
1664
1919
  function renderSurfaceLine(args) {
@@ -1669,10 +1924,24 @@ function renderSurfaceLine(args) {
1669
1924
  return `${surface}${reopened}${padding}\x1B[0m`;
1670
1925
  }
1671
1926
  function renderDiffLine(args) {
1672
- const { kind, text, highlightedText } = args;
1927
+ const { kind, text, highlightedText, gutter } = args;
1673
1928
  const env = args.env ?? process.env;
1674
1929
  const colorEnabled = args.colorEnabled ?? resolveCliColorEnabled();
1675
1930
  if (!colorEnabled) return text;
1931
+ if (gutter) {
1932
+ const charset = args.boxCharset ?? resolveBoxCharset(resolveAmbiguousWidth(void 0, env), env);
1933
+ const railGlyph = charset === "ascii" ? "|" : "\u258E";
1934
+ const railTone = kind === "added" ? "success" : kind === "removed" ? "danger" : kind === "hunk" ? "info" : "chrome";
1935
+ const rail = `${themeColorSequence(railTone, env)}${railGlyph}\x1B[39m`;
1936
+ const body = highlightedText ?? (kind === "context" ? text : `${themeColorSequence(railTone, env)}${text}`);
1937
+ const closedBody = body.endsWith("\x1B[0m") ? body : `${body}\x1B[0m`;
1938
+ const seq2 = diffLineSequences(env)?.[kind];
1939
+ return `${rail} ${seq2?.bg ? renderSurfaceLine({
1940
+ text: body,
1941
+ surface: seq2.bg,
1942
+ padTo: args.padTo ?? visibleWidth(text)
1943
+ }) : closedBody}`;
1944
+ }
1676
1945
  const seqs = diffLineSequences(env);
1677
1946
  if (!seqs) {
1678
1947
  if (kind === "context") return highlightedText ?? text;
@@ -1691,11 +1960,15 @@ function surfaceBackgroundSequence(env = process.env, brightness = resolveTuiBri
1691
1960
  if (!supportsTruecolor(env)) return "";
1692
1961
  return hexToBgSgr((SURFACE_HEX[activeThemeName] ?? SURFACE_HEX.trail)[brightness]);
1693
1962
  }
1694
- function composerSurfaceBackgroundSequence(env = process.env, brightness = resolveTuiBrightness(env)) {
1695
- if (!supportsTruecolor(env)) return "";
1696
- if (resolveTuiThemeMode(env) === "terminal" && activeTerminalBaseHex === null && detectColorFgBgBrightness(env) === null) {
1697
- return "";
1963
+ function resolveSurfaceWashFallback(env) {
1964
+ if (!supportsTruecolor(env) || activeTerminalBaseHex === null && detectColorFgBgBrightness(env) === null && resolveTuiThemeMode(env) === "terminal") {
1965
+ return "\x1B[100m";
1698
1966
  }
1967
+ return null;
1968
+ }
1969
+ function composerSurfaceBackgroundSequence(env = process.env, brightness = resolveTuiBrightness(env)) {
1970
+ const fallback = resolveSurfaceWashFallback(env);
1971
+ if (fallback !== null) return fallback;
1699
1972
  const base = resolveTerminalBaseHex(brightness);
1700
1973
  const channels = readHexChannels(base.replace(/^#/, "").toUpperCase());
1701
1974
  const baseLuma = channels ? (0.299 * channels[0] + 0.587 * channels[1] + 0.114 * channels[2]) / 255 : null;
@@ -1705,10 +1978,8 @@ function composerSurfaceBackgroundSequence(env = process.env, brightness = resol
1705
1978
  return hexToBgSgr(blendHex(tint, base, weight));
1706
1979
  }
1707
1980
  function userSurfaceBackgroundSequence(env = process.env, brightness = resolveTuiBrightness(env)) {
1708
- if (!supportsTruecolor(env)) return "";
1709
- if (resolveTuiThemeMode(env) === "terminal" && activeTerminalBaseHex === null && detectColorFgBgBrightness(env) === null) {
1710
- return "";
1711
- }
1981
+ const fallback = resolveSurfaceWashFallback(env);
1982
+ if (fallback !== null) return fallback;
1712
1983
  const palette = THEME_PALETTES[activeThemeName] ?? THEME_PALETTES.trail;
1713
1984
  const weight = brightness === "dark" ? 0.3 : 0.14;
1714
1985
  const surfaceHex = (brightness === "light" ? palette.light : palette.dark).accent.hex;
@@ -1720,9 +1991,9 @@ function themeText(text, token, colorEnabled = resolveCliColorEnabled(), env = p
1720
1991
  }
1721
1992
  function tuiRenderThemeFingerprint(colorEnabled, env = process.env) {
1722
1993
  const mode = resolveTuiThemeMode(env);
1723
- const colorKind = !colorEnabled ? "plain" : mode !== "terminal" && supportsTruecolor(env) ? "truecolor" : "ansi";
1994
+ const colorKind = !colorEnabled ? "plain" : shouldUseTruecolorTokens(env) ? "truecolor" : "ansi";
1724
1995
  const surface = colorEnabled ? userSurfaceBackgroundSequence(env) : "";
1725
- return `${activeThemeName}|${mode}|${colorKind}|${surface}`;
1996
+ return `${activeThemeName}|${mode}|${colorKind}|${resolveTuiBrightness(env)}|${activeTerminalBaseHex ?? ""}|${env.COLORFGBG ?? ""}|${surface}`;
1726
1997
  }
1727
1998
  function classifyDiffLine(line) {
1728
1999
  if (line.startsWith("@@")) return "hunk";
@@ -7243,6 +7514,59 @@ function renderMermaidBlock(source, brightness, colorEnabled = true, cols) {
7243
7514
  return toAnsi(art, themeAnsiTheme(brightness)).join("\n");
7244
7515
  }
7245
7516
 
7517
+ // packages/cli/tui/tuiUrlOpener.ts
7518
+ import { spawn as nodeSpawn } from "node:child_process";
7519
+ var MAX_URL_LENGTH = 2048;
7520
+ function normalizeHttpUrl(raw) {
7521
+ const trimmed = raw.trim();
7522
+ if (trimmed.length === 0 || trimmed.length > MAX_URL_LENGTH) return null;
7523
+ if (/[\u0000-\u001f\u007f]/.test(trimmed)) return null;
7524
+ let parsed;
7525
+ try {
7526
+ parsed = new URL(trimmed);
7527
+ } catch {
7528
+ return null;
7529
+ }
7530
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return null;
7531
+ if (parsed.hostname.length === 0) return null;
7532
+ return trimmed;
7533
+ }
7534
+ function resolveUrlOpenCommand(platform, url) {
7535
+ if (normalizeHttpUrl(url) === null) return null;
7536
+ if (platform === "darwin") {
7537
+ return { command: "open", args: [url] };
7538
+ }
7539
+ if (platform === "win32") {
7540
+ return { command: "rundll32.exe", args: ["url.dll,FileProtocolHandler", url] };
7541
+ }
7542
+ return { command: "xdg-open", args: [url] };
7543
+ }
7544
+ function openExternalUrl(raw, options = {}) {
7545
+ const url = normalizeHttpUrl(raw);
7546
+ if (url === null) return false;
7547
+ const resolved = resolveUrlOpenCommand(options.platform ?? process.platform, url);
7548
+ if (!resolved) return false;
7549
+ const spawnImpl = options.spawnImpl ?? nodeSpawn;
7550
+ const report = (error) => {
7551
+ try {
7552
+ options.onError?.(error instanceof Error ? error.message : String(error));
7553
+ } catch {
7554
+ }
7555
+ };
7556
+ try {
7557
+ const child = spawnImpl(resolved.command, resolved.args, {
7558
+ detached: true,
7559
+ stdio: "ignore"
7560
+ });
7561
+ child.on?.("error", report);
7562
+ child.unref?.();
7563
+ return true;
7564
+ } catch (error) {
7565
+ report(error);
7566
+ return false;
7567
+ }
7568
+ }
7569
+
7246
7570
  // packages/cli/client/mathText.ts
7247
7571
  var mathRenderingEnabled = true;
7248
7572
  function setMathRenderingEnabled(enabled) {
@@ -7807,19 +8131,42 @@ var STYLE = {
7807
8131
  function colorSeq(token, brightness) {
7808
8132
  return themeColorSequence(token, process.env, brightness);
7809
8133
  }
7810
- function renderMarkdownLink(match, text, url) {
7811
- const visible = `${text} (${url})`;
7812
- return `\x1B]8;;${url}\x1B\\${visible}\x1B]8;;\x1B\\`;
8134
+ function renderMarkdownLink(text, url, brightness) {
8135
+ const safeText = sanitizeHyperlinkLabel(text);
8136
+ const safeHttpUrl = normalizeHttpUrl(url);
8137
+ if (safeHttpUrl === null) {
8138
+ const safeRawUrl = sanitizeHyperlinkLabel(url);
8139
+ return safeText.trim() === safeRawUrl.trim() ? safeText : `${safeText} (${safeRawUrl})`;
8140
+ }
8141
+ const sameAsUrl = safeText.trim() === safeHttpUrl.trim();
8142
+ if (!resolveCliHyperlinkEnabled()) {
8143
+ return sameAsUrl ? safeText : `${safeText} (${safeHttpUrl})`;
8144
+ }
8145
+ const colorEnabled = resolveCliColorEnabled();
8146
+ if (sameAsUrl || !safeText.trim()) {
8147
+ const label = safeText.trim() ? safeText : safeHttpUrl;
8148
+ if (!colorEnabled) {
8149
+ return `\x1B]8;;${safeHttpUrl}\x1B\\${label}\x1B]8;;\x1B\\`;
8150
+ }
8151
+ const linkColor2 = colorSeq("accent", brightness);
8152
+ return `\x1B]8;;${safeHttpUrl}\x1B\\\x1B[4m${linkColor2}${label}${STYLE.reset}\x1B]8;;\x1B\\`;
8153
+ }
8154
+ if (!colorEnabled) {
8155
+ return `\x1B]8;;${safeHttpUrl}\x1B\\${safeText} \u2197\x1B]8;;\x1B\\`;
8156
+ }
8157
+ const linkColor = colorSeq("accent", brightness);
8158
+ const muted = colorSeq("muted", brightness);
8159
+ return `\x1B]8;;${safeHttpUrl}\x1B\\\x1B[4m${linkColor}${safeText}${STYLE.reset}${muted} \u2197${STYLE.reset}\x1B]8;;\x1B\\`;
7813
8160
  }
7814
8161
  var MARKDOWN_LINK_RE = /\[([^\]]+)\]\(([^)\s]+)\)/g;
7815
8162
  function styleInlineMarkdown(line, brightness) {
7816
- const inlineCode = colorSeq("muted", brightness);
8163
+ const inlineCode = colorSeq("info", brightness);
7817
8164
  const reset = STYLE.reset;
7818
8165
  const bold = STYLE.bold;
7819
8166
  const dim = STYLE.dim;
7820
8167
  const zwsCode = "\u200B";
7821
8168
  const mathMask = maskMathInLine(line, brightness);
7822
- const styled = mathMask.maskedText.replace(MARKDOWN_LINK_RE, (m, t2, u) => renderMarkdownLink(m, t2, u)).replace(
8169
+ const styled = mathMask.maskedText.replace(MARKDOWN_LINK_RE, (_m, t2, u) => renderMarkdownLink(t2, u, brightness)).replace(
7823
8170
  /\u200b([^\u200b\n]+)\u200b/g,
7824
8171
  (_m, inner) => `${zwsCode}${inlineCode}${inner}${reset}${zwsCode}`
7825
8172
  ).replace(/`([^`]+)`/g, `${inlineCode}$1${reset}`).replace(/\*\*(.+?)\*\*/g, `${bold}$1${reset}`).replace(/(?<!\*)\*([^*]+?)\*(?!\*)/g, `${dim}$1${reset}`).replace(/~~([^~]+?)~~/g, `${dim}\x1B[9m$1\x1B[29m${reset}`);
@@ -8340,24 +8687,23 @@ function highlightCodeLine(line, lang, brightness) {
8340
8687
  const success = colorSeq("success", brightness);
8341
8688
  const warning = colorSeq("warning", brightness);
8342
8689
  const chrome = colorSeq("chrome", brightness);
8343
- const dim = STYLE.dim;
8344
8690
  const reset = STYLE.reset;
8345
8691
  const out = [];
8346
8692
  let cursor = 0;
8347
8693
  for (const region of regions) {
8348
8694
  if (region.start > cursor) {
8349
- out.push(emitPlainGap(line.slice(cursor, region.start), keywords, info, accent, warning, reset));
8695
+ out.push(emitPlainGap(line.slice(cursor, region.start), keywords, "\x1B[39m", accent, warning, reset));
8350
8696
  }
8351
8697
  const text = line.slice(region.start, region.end);
8352
8698
  if (region.kind === "string") {
8353
8699
  out.push(`${success}${text}${reset}`);
8354
8700
  } else {
8355
- out.push(`${chrome}${dim}${text}${reset}`);
8701
+ out.push(`${chrome}${text}${reset}`);
8356
8702
  }
8357
8703
  cursor = region.end;
8358
8704
  }
8359
8705
  if (cursor < line.length) {
8360
- out.push(emitPlainGap(line.slice(cursor), keywords, info, accent, warning, reset));
8706
+ out.push(emitPlainGap(line.slice(cursor), keywords, "\x1B[39m", accent, warning, reset));
8361
8707
  }
8362
8708
  return out.join("");
8363
8709
  }
@@ -8423,7 +8769,15 @@ function plainToolLine(line) {
8423
8769
  return stripAnsi(line);
8424
8770
  }
8425
8771
  var TOOL_TREE_GROUP_LABELS = new Set(
8426
- ["execShell", "readFile", "fetchWebpage", "exa_search"].flatMap(toolLabelVariants)
8772
+ ["execShell", "readFile", "fetchWebpage", "exa_search"].flatMap((name) => {
8773
+ const fam = toolFamilyOf(name);
8774
+ return [
8775
+ fam.icon,
8776
+ fam.en,
8777
+ fam.zh,
8778
+ ...toolLabelVariants(name)
8779
+ ];
8780
+ })
8427
8781
  );
8428
8782
  function isKnownToolGroupLabel(label) {
8429
8783
  return TOOL_TREE_GROUP_LABELS.has(label);
@@ -8442,12 +8796,12 @@ function toolGroupKeyOf(line) {
8442
8796
  const plain = plainToolLine(line);
8443
8797
  const flat = plain.match(TOOL_SINGLE_RE);
8444
8798
  if (flat) {
8445
- const label = (flat[1] ?? "").replace(/\s*×\d+$/, "").trim();
8799
+ const label = (flat[1] ?? "").trim();
8446
8800
  return label ? `flat:${label}` : null;
8447
8801
  }
8448
8802
  const header = toolTreeHeaderMatch(plain);
8449
8803
  if (header) {
8450
- const label = (header[1] ?? "").replace(/\s*×\d+$/, "").trim();
8804
+ const label = (header[1] ?? "").trim();
8451
8805
  return label ? `tree:${label}` : null;
8452
8806
  }
8453
8807
  return null;
@@ -8468,7 +8822,7 @@ function styleToolDetailSegments(detail, muted, chrome) {
8468
8822
  if (!metaMatch) {
8469
8823
  return `${muted}${detail}${STYLE.reset}`;
8470
8824
  }
8471
- return `${muted}${metaMatch[1]}${STYLE.reset}${chrome}${STYLE.dim}${metaMatch[2]}${STYLE.reset}`;
8825
+ return `${muted}${metaMatch[1]}${STYLE.reset}${chrome}${metaMatch[2]}${STYLE.reset}`;
8472
8826
  }
8473
8827
  function styleTuiToolLine(line, brightness) {
8474
8828
  const plain = plainToolLine(line);
@@ -8479,13 +8833,13 @@ function styleTuiToolLine(line, brightness) {
8479
8833
  const header = toolTreeHeaderMatch(plain);
8480
8834
  if (header) {
8481
8835
  const glyph = plain.startsWith("\u2022") ? "\u2022" : "\u25B8";
8482
- return `${chrome}${glyph}${STYLE.reset} ${STYLE.bold}${info}${header[1]}${STYLE.reset} ${chrome}${STYLE.dim}(${header[2]})${STYLE.reset} ${chrome}\xB7${STYLE.reset} ${muted}${header[3]}${STYLE.reset} ${statusColorSeq("\u2713", brightness)}\u2713${STYLE.reset}`;
8836
+ return `${chrome}${glyph}${STYLE.reset} ${STYLE.bold}${muted}${header[1]}${STYLE.reset} ${chrome}(${header[2]})${STYLE.reset} ${chrome}\xB7${STYLE.reset} ${muted}${header[3]}${STYLE.reset} ${statusColorSeq("\u2713", brightness)}\u2713${STYLE.reset}`;
8483
8837
  }
8484
8838
  const single = plain.match(TOOL_SINGLE_RE);
8485
8839
  if (single) {
8486
8840
  const [, label, detail, marker, statusDetail] = single;
8487
8841
  const isError = marker === "\u2717";
8488
- const labelColor = isError ? danger : info;
8842
+ const labelColor = isError ? danger : muted;
8489
8843
  let rendered = `${chrome}\u25B8${STYLE.reset} ${STYLE.bold}${labelColor}${label}${STYLE.reset}`;
8490
8844
  if (detail) {
8491
8845
  rendered += ` ${chrome}\xB7${STYLE.reset} ${styleToolDetailSegments(detail, muted, chrome)}`;
@@ -8495,7 +8849,7 @@ function styleTuiToolLine(line, brightness) {
8495
8849
  if (isError) {
8496
8850
  rendered += ` ${danger}${statusDetail}${STYLE.reset}`;
8497
8851
  } else {
8498
- rendered += ` ${chrome}${STYLE.dim}${statusDetail}${STYLE.reset}`;
8852
+ rendered += ` ${chrome}${statusDetail}${STYLE.reset}`;
8499
8853
  }
8500
8854
  }
8501
8855
  return rendered;
@@ -8627,25 +8981,23 @@ function styleRichMarkdownLine(line, brightness) {
8627
8981
  return `${STYLE.bold}${colorSeq("accent", brightness)}${styledTitle}${STYLE.reset}`;
8628
8982
  }
8629
8983
  if (level === 2) {
8630
- return `${STYLE.bold}${colorSeq("warning", brightness)}${styledTitle}${STYLE.reset}`;
8631
- }
8632
- if (level === 3) {
8633
8984
  return `${STYLE.bold}${colorSeq("info", brightness)}${styledTitle}${STYLE.reset}`;
8634
8985
  }
8635
8986
  return `${STYLE.bold}${colorSeq("muted", brightness)}${styledTitle}${STYLE.reset}`;
8636
8987
  }
8637
8988
  if (line.startsWith("\u8FDB\u5165 nolo-plan")) {
8638
- return `${colorSeq("chrome", brightness)}${STYLE.dim}${line}${STYLE.reset}`;
8989
+ return `${colorSeq("chrome", brightness)}${line}${STYLE.reset}`;
8639
8990
  }
8640
8991
  const blockquote = line.match(/^>\s?(.*)$/);
8641
8992
  if (blockquote) {
8642
8993
  const border = colorSeq("chrome", brightness);
8994
+ const muted = colorSeq("muted", brightness);
8643
8995
  const content = blockquote[1];
8644
- const styled = styleInlineMarkdown(content, brightness);
8645
- return `${border}\u2502${STYLE.reset} ${STYLE.dim}${styled}${STYLE.reset}`;
8996
+ const styled = styleInlineMarkdown(content, brightness).split(STYLE.reset).join(`${STYLE.reset}${muted}`);
8997
+ return `${border}\u2502${STYLE.reset} ${muted}${styled}${STYLE.reset}`;
8646
8998
  }
8647
8999
  if (THEMATIC_BREAK_RE.test(line)) {
8648
- return `${colorSeq("chrome", brightness)}${STYLE.dim}${boxGlyphs(resolveBoxCharset()).h.repeat(36)}${STYLE.reset}`;
9000
+ return `${colorSeq("chrome", brightness)}${boxGlyphs(resolveBoxCharset()).h.repeat(36)}${STYLE.reset}`;
8649
9001
  }
8650
9002
  const bullet = line.match(/^(\s*)(•)\s(.+)$/);
8651
9003
  if (bullet) {
@@ -8667,6 +9019,26 @@ function styleRichMarkdownLine(line, brightness) {
8667
9019
  }
8668
9020
  return styleInlineMarkdown(line, brightness);
8669
9021
  }
9022
+ var CODE_FENCE_RULE_WIDTH = 24;
9023
+ function renderCodeFenceOpen(rawLang, brightness) {
9024
+ const { h, tl } = boxGlyphs(resolveBoxCharset());
9025
+ const chrome = colorSeq("chrome", brightness);
9026
+ if (rawLang) {
9027
+ const tailLen = Math.max(4, CODE_FENCE_RULE_WIDTH - rawLang.length - 3);
9028
+ return `${chrome}${tl}${h} ${rawLang} ${h.repeat(tailLen)}${STYLE.reset}`;
9029
+ }
9030
+ return `${chrome}${tl}${h.repeat(CODE_FENCE_RULE_WIDTH)}${STYLE.reset}`;
9031
+ }
9032
+ function renderCodeFenceClose(brightness) {
9033
+ const { h, bl } = boxGlyphs(resolveBoxCharset());
9034
+ const chrome = colorSeq("chrome", brightness);
9035
+ return `${chrome}${bl}${h.repeat(CODE_FENCE_RULE_WIDTH)}${STYLE.reset}`;
9036
+ }
9037
+ function renderCodeFenceLine(line, lang, brightness) {
9038
+ const { v } = boxGlyphs(resolveBoxCharset());
9039
+ const chrome = colorSeq("chrome", brightness);
9040
+ return `${chrome}${v}${STYLE.reset} ${highlightCodeLine(line, lang, brightness)}`;
9041
+ }
8670
9042
  var FenceTracker = class {
8671
9043
  inFence = false;
8672
9044
  inMermaid = false;
@@ -8693,15 +9065,15 @@ var FenceTracker = class {
8693
9065
  this.fenceLang = "unknown";
8694
9066
  return { kind: "close-code" };
8695
9067
  }
8696
- const lang = readFenceLanguage(line);
8697
- this.fenceLang = normalizeCodeLang(lang);
9068
+ const rawLang = readFenceLanguage(line);
9069
+ this.fenceLang = normalizeCodeLang(rawLang);
8698
9070
  this.inFence = true;
8699
- if (/^mermaid$/i.test(lang)) {
9071
+ if (/^mermaid$/i.test(rawLang)) {
8700
9072
  this.inMermaid = true;
8701
9073
  this.mermaidBody = [];
8702
- return { kind: "open" };
9074
+ return { kind: "open-mermaid" };
8703
9075
  }
8704
- return { kind: "open" };
9076
+ return { kind: "open-code", rawLang };
8705
9077
  }
8706
9078
  if (this.inMermaid) {
8707
9079
  this.mermaidBody.push(line);
@@ -8749,21 +9121,25 @@ function formatAssistantDisplay(text, options = {}) {
8749
9121
  const event = tracker.processLine(line);
8750
9122
  if (event.kind === "close-mermaid") {
8751
9123
  out.push(renderMermaidBody(event.body, brightness));
8752
- out.push(`${STYLE.dim}${line}${STYLE.reset}`);
8753
9124
  i++;
8754
9125
  continue;
8755
9126
  }
8756
- if (event.kind === "open" || event.kind === "close-code") {
8757
- out.push(`${STYLE.dim}${line}${STYLE.reset}`);
9127
+ if (event.kind === "open-mermaid" || event.kind === "mermaid-body") {
8758
9128
  i++;
8759
9129
  continue;
8760
9130
  }
8761
- if (event.kind === "mermaid-body") {
9131
+ if (event.kind === "open-code") {
9132
+ out.push(renderCodeFenceOpen(event.rawLang, brightness));
9133
+ i++;
9134
+ continue;
9135
+ }
9136
+ if (event.kind === "close-code") {
9137
+ out.push(renderCodeFenceClose(brightness));
8762
9138
  i++;
8763
9139
  continue;
8764
9140
  }
8765
9141
  if (event.kind === "code-line") {
8766
- out.push(highlightCodeLine(line, event.lang, brightness));
9142
+ out.push(renderCodeFenceLine(line, event.lang, brightness));
8767
9143
  i++;
8768
9144
  continue;
8769
9145
  }
@@ -8889,17 +9265,30 @@ function createRenderAwareStreamWriter(args) {
8889
9265
  if (event.kind === "close-mermaid") {
8890
9266
  const diagram = renderMermaidBody(event.body, brightness);
8891
9267
  args.write(diagram + "\n");
8892
- emitBreathIfNeeded("fence");
8893
- args.write(`${STYLE.dim}${firstLine}${STYLE.reset}
9268
+ lastKind = "fence";
9269
+ lastLine = firstLine;
9270
+ buffer = lines.slice(1).join("\n");
9271
+ continue;
9272
+ }
9273
+ if (event.kind === "open-mermaid") {
9274
+ emitBreathIfNeeded("fence", firstLine);
9275
+ lastKind = "fence";
9276
+ lastLine = firstLine;
9277
+ buffer = lines.slice(1).join("\n");
9278
+ continue;
9279
+ }
9280
+ if (event.kind === "open-code") {
9281
+ emitBreathIfNeeded("fence", firstLine);
9282
+ args.write(`${renderCodeFenceOpen(event.rawLang, brightness)}
8894
9283
  `);
8895
9284
  lastKind = "fence";
8896
9285
  lastLine = firstLine;
8897
9286
  buffer = lines.slice(1).join("\n");
8898
9287
  continue;
8899
9288
  }
8900
- if (event.kind === "open" || event.kind === "close-code") {
8901
- emitBreathIfNeeded("fence");
8902
- args.write(`${STYLE.dim}${firstLine}${STYLE.reset}
9289
+ if (event.kind === "close-code") {
9290
+ emitBreathIfNeeded("fence", firstLine);
9291
+ args.write(`${renderCodeFenceClose(brightness)}
8903
9292
  `);
8904
9293
  lastKind = "fence";
8905
9294
  lastLine = firstLine;
@@ -8911,7 +9300,7 @@ function createRenderAwareStreamWriter(args) {
8911
9300
  continue;
8912
9301
  }
8913
9302
  if (event.kind === "code-line") {
8914
- args.write(`${highlightCodeLine(firstLine, event.lang, brightness)}
9303
+ args.write(`${renderCodeFenceLine(firstLine, event.lang, brightness)}
8915
9304
  `);
8916
9305
  lastKind = "fence";
8917
9306
  lastLine = firstLine;
@@ -9004,6 +9393,16 @@ function createRenderAwareStreamWriter(args) {
9004
9393
  },
9005
9394
  flush() {
9006
9395
  if (tracker.isInMermaid()) {
9396
+ if (buffer && isCodeFenceLine(buffer)) {
9397
+ const event2 = tracker.processLine(buffer);
9398
+ buffer = "";
9399
+ if (event2.kind === "close-mermaid") {
9400
+ args.write(renderMermaidBody(event2.body, brightness));
9401
+ lastKind = "fence";
9402
+ lastLine = "```";
9403
+ return;
9404
+ }
9405
+ }
9007
9406
  const extra = buffer ? buffer.split("\n") : void 0;
9008
9407
  const unclosed = tracker.flushMermaid(extra);
9009
9408
  if (unclosed !== null) {
@@ -9013,8 +9412,25 @@ function createRenderAwareStreamWriter(args) {
9013
9412
  return;
9014
9413
  }
9015
9414
  if (!buffer) return;
9016
- if (tracker.isInFence()) {
9017
- args.write(buffer);
9415
+ const event = tracker.processLine(buffer);
9416
+ if (event.kind === "open-mermaid") {
9417
+ emitBreathIfNeeded("fence", buffer);
9418
+ lastKind = "fence";
9419
+ lastLine = buffer;
9420
+ } else if (event.kind === "open-code") {
9421
+ emitBreathIfNeeded("fence", buffer);
9422
+ args.write(renderCodeFenceOpen(event.rawLang, brightness));
9423
+ lastKind = "fence";
9424
+ lastLine = buffer;
9425
+ } else if (event.kind === "close-code") {
9426
+ emitBreathIfNeeded("fence", buffer);
9427
+ args.write(renderCodeFenceClose(brightness));
9428
+ lastKind = "fence";
9429
+ lastLine = buffer;
9430
+ } else if (event.kind === "code-line") {
9431
+ args.write(renderCodeFenceLine(buffer, event.lang, brightness));
9432
+ lastKind = "fence";
9433
+ lastLine = buffer;
9018
9434
  } else {
9019
9435
  emitBreathIfNeeded(classifyStreamLine(buffer), buffer);
9020
9436
  emitFormattedAssistantBlock(args.write, buffer);
@@ -9027,38 +9443,51 @@ function formatAssistantTextForCli(text) {
9027
9443
  return text.replace(/\u003cthink\u003e[\s\S]*?\u003c\/think\u003e\s*/gi, "").replace(/\n{3,}/g, "\n\n").trim();
9028
9444
  }
9029
9445
 
9030
- // packages/cli/client/toolOutput.ts
9031
- import { createHash as createHash2 } from "node:crypto";
9032
-
9033
9446
  // packages/cli/tui/tuiLayout.ts
9034
9447
  var DEFAULT_TERMINAL_ROWS = 24;
9035
9448
  var DEFAULT_TERMINAL_COLUMNS = 80;
9036
9449
  var TUI_MARGIN_LEFT = 1;
9037
9450
  var TUI_MARGIN_RIGHT = 1;
9038
9451
  var TUI_MARGIN_RESPONSIVE_MIN_COLUMNS = 40;
9452
+ function resolveSurfacePaintWidth(columns) {
9453
+ return Math.max(0, columns - 1);
9454
+ }
9039
9455
  function resolveHistoryLayoutGeometry(columns) {
9040
9456
  const cols = Math.max(1, (columns ?? 0) > 0 ? columns : DEFAULT_TERMINAL_COLUMNS);
9041
9457
  if (cols <= TUI_MARGIN_RESPONSIVE_MIN_COLUMNS) {
9042
9458
  return {
9043
- contentWidth: Math.max(1, cols - 1),
9459
+ contentWidth: Math.max(1, resolveSurfacePaintWidth(cols)),
9044
9460
  marginLeft: 0,
9045
9461
  marginRight: 0
9046
9462
  };
9047
9463
  }
9048
9464
  const marginLeft = TUI_MARGIN_LEFT;
9049
9465
  const marginRight = TUI_MARGIN_RIGHT;
9050
- const contentWidth = Math.max(1, cols - 1 - marginLeft - marginRight);
9466
+ const contentWidth = Math.max(1, resolveSurfacePaintWidth(cols) - marginLeft - marginRight);
9051
9467
  return {
9052
9468
  contentWidth,
9053
9469
  marginLeft,
9054
9470
  marginRight
9055
9471
  };
9056
9472
  }
9057
- function resolveHistoryViewportHeight(terminalRows, composerRows, foregroundReservedRows = 0) {
9473
+ function resolveHistoryViewportHeight(terminalRows, composerRows, foregroundReservedRows = 0, topReservedRows = 0) {
9058
9474
  const rows = Math.max(1, terminalRows > 0 ? terminalRows : DEFAULT_TERMINAL_ROWS);
9059
9475
  const composer = Math.max(0, composerRows);
9060
9476
  const reserved = Math.max(0, foregroundReservedRows);
9061
- return Math.max(0, rows - composer - reserved);
9477
+ return Math.max(0, rows - composer - reserved - Math.max(0, topReservedRows));
9478
+ }
9479
+ var topRowsByOutput = /* @__PURE__ */ new WeakMap();
9480
+ var getTopReservedRows = (output) => topRowsByOutput.get(output) ?? 0;
9481
+ function setTopReservedRows(output, rows) {
9482
+ topRowsByOutput.set(output, Math.max(0, rows));
9483
+ }
9484
+ function resolveTopTaskEntryBudget(rows = 24, composerRows = 4, modalRows = 0, decorationRows = 0) {
9485
+ const preferred = Math.max(2, preferredTopTaskEntries(rows));
9486
+ const free = Math.max(0, rows - composerRows - modalRows - decorationRows);
9487
+ return Math.max(0, Math.min(preferred, Math.floor(free / 2) - 1));
9488
+ }
9489
+ function preferredTopTaskEntries(rows = 24) {
9490
+ return rows >= 40 ? Math.min(12, 7 + Math.floor((rows - 32) / 4)) : rows < 10 ? 1 : rows < 16 ? 2 : 7;
9062
9491
  }
9063
9492
 
9064
9493
  // packages/core/redactSecrets.ts
@@ -9123,6 +9552,11 @@ function shellWords(text, validationOnly = false) {
9123
9552
  started = true;
9124
9553
  continue;
9125
9554
  }
9555
+ if (ch === "?" && /^https?:\/\//i.test(word)) {
9556
+ word += ch;
9557
+ started = true;
9558
+ continue;
9559
+ }
9126
9560
  if (/[<> &|;(){}*?\[\]#~]/.test(ch) && !/\s/.test(ch)) return null;
9127
9561
  if (/\s/.test(ch)) {
9128
9562
  if (started) words2.push(word);
@@ -9370,6 +9804,9 @@ function firstVerbToken(segment) {
9370
9804
  const [, word, restAfter] = m;
9371
9805
  const base = word.replace(/^.*\//, "");
9372
9806
  if (wrappers.has(base) && restAfter.trim()) {
9807
+ if (base === "command" && /^-(?:v|V)(?:\s|$)/.test(restAfter.trim())) {
9808
+ return { verb: base, rest: restAfter.trim() };
9809
+ }
9373
9810
  rest = restAfter.trim();
9374
9811
  continue;
9375
9812
  }
@@ -9573,6 +10010,179 @@ function parseNolo(rest) {
9573
10010
  if (sub === "ci") return { verb: "\u67E5 CI \u72B6\u6001", readOnly: true };
9574
10011
  return null;
9575
10012
  }
10013
+ function stripTrailingPipe(rest) {
10014
+ let quote = null;
10015
+ for (let i = 0; i < rest.length; i++) {
10016
+ const ch = rest[i];
10017
+ const next = rest[i + 1];
10018
+ if (quote) {
10019
+ if (ch === "\\" && next && quote === '"') {
10020
+ i++;
10021
+ continue;
10022
+ }
10023
+ if (ch === quote) quote = null;
10024
+ continue;
10025
+ }
10026
+ if (ch === '"' || ch === "'") {
10027
+ quote = ch;
10028
+ continue;
10029
+ }
10030
+ if (ch === "\\" && next) {
10031
+ i++;
10032
+ continue;
10033
+ }
10034
+ if (ch === "|" && next !== "|" && rest[i - 1] !== "|") {
10035
+ return rest.slice(0, i).trim();
10036
+ }
10037
+ }
10038
+ return rest.trim();
10039
+ }
10040
+ var CURL_VALUE_FLAGS = /* @__PURE__ */ new Set([
10041
+ "-o",
10042
+ "--output",
10043
+ "-H",
10044
+ "--header",
10045
+ "-d",
10046
+ "--data",
10047
+ "--data-raw",
10048
+ "--data-binary",
10049
+ "--data-urlencode",
10050
+ "--data-ascii",
10051
+ "-F",
10052
+ "--form",
10053
+ "--form-string",
10054
+ "-u",
10055
+ "--user",
10056
+ "-A",
10057
+ "--user-agent",
10058
+ "-e",
10059
+ "--referer",
10060
+ "-b",
10061
+ "--cookie",
10062
+ "-c",
10063
+ "--cookie-jar",
10064
+ "-x",
10065
+ "--proxy",
10066
+ "-U",
10067
+ "--proxy-user",
10068
+ "-X",
10069
+ "--request",
10070
+ "-m",
10071
+ "--max-time",
10072
+ "--connect-timeout",
10073
+ "--retry",
10074
+ "--retry-delay",
10075
+ "--retry-max-time",
10076
+ "-w",
10077
+ "--write-out",
10078
+ "-T",
10079
+ "--upload-file",
10080
+ "-K",
10081
+ "--config",
10082
+ "--resolve",
10083
+ "--cacert",
10084
+ "--capath",
10085
+ "--cert",
10086
+ "--key",
10087
+ "-E",
10088
+ "--interface",
10089
+ "--limit-rate",
10090
+ "-r",
10091
+ "--range",
10092
+ "-Y",
10093
+ "-y",
10094
+ "--oauth2-bearer",
10095
+ "--aws-sigv4",
10096
+ "--connect-to",
10097
+ "--dns-servers"
10098
+ ]);
10099
+ var WGET_VALUE_FLAGS = /* @__PURE__ */ new Set([
10100
+ "-O",
10101
+ "--output-document",
10102
+ "-P",
10103
+ "--directory-prefix",
10104
+ "--header",
10105
+ "--user",
10106
+ "--password",
10107
+ "--http-user",
10108
+ "--http-password",
10109
+ "-U",
10110
+ "--user-agent",
10111
+ "-T",
10112
+ "--timeout",
10113
+ "-t",
10114
+ "--tries",
10115
+ "-a",
10116
+ "--append-output",
10117
+ "-o",
10118
+ "--output-file",
10119
+ "--post-data",
10120
+ "--post-file",
10121
+ "--load-cookies",
10122
+ "--save-cookies",
10123
+ "-e",
10124
+ "--execute",
10125
+ "--referer",
10126
+ "--wait",
10127
+ "--limit-rate",
10128
+ "--ca-certificate",
10129
+ "--certificate"
10130
+ ]);
10131
+ function extractSafeUrlTarget(rawUrl) {
10132
+ const trimmed = rawUrl.trim();
10133
+ if (!/^(?:https?|ftp):\/\//i.test(trimmed)) return null;
10134
+ let parsed;
10135
+ try {
10136
+ parsed = new URL(trimmed);
10137
+ } catch {
10138
+ return null;
10139
+ }
10140
+ if (!["http:", "https:", "ftp:"].includes(parsed.protocol)) return null;
10141
+ const hostname = parsed.hostname;
10142
+ if (!hostname) return null;
10143
+ const pathname = parsed.pathname || "/";
10144
+ if (!pathname.endsWith("/")) {
10145
+ const rawLast = pathname.split("/").filter(Boolean).pop();
10146
+ if (rawLast) {
10147
+ let decoded = rawLast;
10148
+ try {
10149
+ decoded = decodeURIComponent(rawLast);
10150
+ } catch {
10151
+ }
10152
+ const looksLikeSecret = decoded.includes("=") || /^(?:sk-|ghp_|gho_|ghu_|ghs_|github_pat_|AKIA|AIza|xox[baprs]-|eyJ)/i.test(decoded);
10153
+ if (!looksLikeSecret && !/[\s?#\\]/.test(decoded) && decoded.length <= 64 && /^[^/]+\.[A-Za-z0-9]{1,8}$/.test(decoded)) {
10154
+ return { kind: "file", target: clipShortText(decoded, 32) };
10155
+ }
10156
+ }
10157
+ }
10158
+ return { kind: "host", target: clipShortText(hostname, 32) };
10159
+ }
10160
+ function parseCurlOrWget(verb, rest) {
10161
+ const head = stripTrailingPipe(rest);
10162
+ const tokens2 = shellWords(head);
10163
+ if (!tokens2) return null;
10164
+ const valueFlags = verb === "curl" ? CURL_VALUE_FLAGS : WGET_VALUE_FLAGS;
10165
+ const positionals = [];
10166
+ for (let i = 0; i < tokens2.length; i++) {
10167
+ const tok = tokens2[i];
10168
+ if (tok === "--") {
10169
+ positionals.push(...tokens2.slice(i + 1));
10170
+ break;
10171
+ }
10172
+ if (tok.startsWith("-")) {
10173
+ if (!tok.includes("=") && valueFlags.has(tok)) i++;
10174
+ continue;
10175
+ }
10176
+ positionals.push(tok);
10177
+ }
10178
+ for (const pos of positionals) {
10179
+ const extracted = extractSafeUrlTarget(pos);
10180
+ if (extracted) {
10181
+ return extracted.kind === "file" ? { verb: "\u4E0B\u8F7D", target: extracted.target, readOnly: false } : { verb: "\u8BF7\u6C42", target: extracted.target, readOnly: false };
10182
+ }
10183
+ }
10184
+ return { verb: "\u4E0B\u8F7D", readOnly: false };
10185
+ }
9576
10186
  function classifySegment(segment) {
9577
10187
  const { verb, rest } = firstVerbToken(segment);
9578
10188
  if (!verb) return null;
@@ -9681,7 +10291,7 @@ function classifySegment(segment) {
9681
10291
  }
9682
10292
  case "curl":
9683
10293
  case "wget":
9684
- return { verb: "\u4E0B\u8F7D", readOnly: false };
10294
+ return parseCurlOrWget(verb, rest);
9685
10295
  case "bun":
9686
10296
  case "npm":
9687
10297
  case "pnpm":
@@ -9739,22 +10349,104 @@ function classifySegment(segment) {
9739
10349
  case "wc":
9740
10350
  case "sort":
9741
10351
  case "uniq": {
9742
- const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
9743
- let file;
9744
- if (tokens2) {
9745
- for (let i = 0; i < tokens2.length; i++) {
9746
- const tok = tokens2[i];
9747
- if (tok === "-n" || tok === "-c") {
9748
- i++;
9749
- continue;
9750
- }
9751
- if (tok.startsWith("-")) continue;
9752
- file = tok;
10352
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10353
+ if (!tokens2) return null;
10354
+ if (verb === "sort" && tokens2.some((t2) => t2 === "-o" || t2.startsWith("-") && !t2.startsWith("--") && t2.includes("o") || t2 === "--output" || t2.startsWith("--output="))) {
10355
+ return null;
10356
+ }
10357
+ const valueFlagsByCmd = {
10358
+ head: /* @__PURE__ */ new Set(["-n", "-c", "--lines", "--bytes"]),
10359
+ tail: /* @__PURE__ */ new Set(["-n", "-c", "-s", "--lines", "--bytes", "--sleep-interval", "--pid"]),
10360
+ wc: /* @__PURE__ */ new Set(["--files0-from"]),
10361
+ sort: /* @__PURE__ */ new Set(["-t", "-k", "-T", "-S", "--field-separator", "--key", "--temporary-directory", "--buffer-size", "--files0-from"]),
10362
+ uniq: /* @__PURE__ */ new Set(["-f", "-s", "-w", "--skip-fields", "--skip-chars", "--check-chars"])
10363
+ };
10364
+ const valueFlags = valueFlagsByCmd[verb];
10365
+ const positionals = [];
10366
+ for (let i = 0; i < tokens2.length; i++) {
10367
+ const tok = tokens2[i];
10368
+ if (tok === "--") {
10369
+ positionals.push(...tokens2.slice(i + 1));
9753
10370
  break;
9754
10371
  }
10372
+ if (tok.startsWith("-")) {
10373
+ if (!tok.includes("=") && valueFlags.has(tok)) i++;
10374
+ continue;
10375
+ }
10376
+ positionals.push(tok);
9755
10377
  }
10378
+ if (verb === "uniq" && positionals.length >= 2) return null;
10379
+ const file = positionals[0];
9756
10380
  return file ? { verb: "\u67E5\u770B", target: baseName(file), readOnly: true } : { verb: "\u67E5\u770B\u8F93\u51FA", readOnly: true };
9757
10381
  }
10382
+ case "which": {
10383
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10384
+ if (!tokens2) return null;
10385
+ const target = tokens2.find((t2) => !t2.startsWith("-"));
10386
+ return target ? { verb: "\u67E5\u547D\u4EE4", target: clipShortText(target, 24), readOnly: true } : { verb: "\u67E5\u547D\u4EE4", readOnly: true };
10387
+ }
10388
+ case "command": {
10389
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10390
+ if (!tokens2 || tokens2.length < 2) return null;
10391
+ if (tokens2[0] !== "-v" && tokens2[0] !== "-V") return null;
10392
+ const target = tokens2.slice(1).find((t2) => !t2.startsWith("-"));
10393
+ return target ? { verb: "\u67E5\u547D\u4EE4", target: clipShortText(target, 24), readOnly: true } : null;
10394
+ }
10395
+ case "file": {
10396
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10397
+ if (!tokens2) return null;
10398
+ for (const tok of tokens2) {
10399
+ if (tok === "--") break;
10400
+ if (tok === "--compile" || tok.startsWith("-") && !tok.startsWith("--") && tok.includes("C")) {
10401
+ return null;
10402
+ }
10403
+ }
10404
+ let file;
10405
+ for (let i = 0; i < tokens2.length; i++) {
10406
+ const tok = tokens2[i];
10407
+ if (tok === "--") {
10408
+ file = tokens2[i + 1];
10409
+ break;
10410
+ }
10411
+ if (["-m", "-f", "-F", "-e", "--exclude", "--magic-file"].includes(tok)) {
10412
+ i++;
10413
+ continue;
10414
+ }
10415
+ if (tok.startsWith("-")) continue;
10416
+ file = tok;
10417
+ break;
10418
+ }
10419
+ return { verb: "\u67E5\u7C7B\u578B", target: file ? baseName(file) : void 0, readOnly: true };
10420
+ }
10421
+ case "stat": {
10422
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10423
+ if (!tokens2) return null;
10424
+ let file;
10425
+ for (let i = 0; i < tokens2.length; i++) {
10426
+ const tok = tokens2[i];
10427
+ if (["-c", "--format", "--printf"].includes(tok)) {
10428
+ i++;
10429
+ continue;
10430
+ }
10431
+ if (tok.startsWith("-")) continue;
10432
+ file = tok;
10433
+ break;
10434
+ }
10435
+ return { verb: "\u67E5\u6587\u4EF6\u4FE1\u606F", target: file ? baseName(file) : void 0, readOnly: true };
10436
+ }
10437
+ case "readlink":
10438
+ case "realpath": {
10439
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10440
+ if (!tokens2) return null;
10441
+ const file = tokens2.find((t2) => !t2.startsWith("-"));
10442
+ return { verb: "\u89E3\u6790\u8DEF\u5F84", target: file ? baseName(file) : void 0, readOnly: true };
10443
+ }
10444
+ case "pwd":
10445
+ return { verb: "\u67E5\u5F53\u524D\u76EE\u5F55", readOnly: true };
10446
+ case "uname":
10447
+ return { verb: "\u67E5\u7CFB\u7EDF\u4FE1\u606F", readOnly: true };
10448
+ case "whoami":
10449
+ return { verb: "\u67E5\u8EAB\u4EFD", readOnly: true };
9758
10450
  default:
9759
10451
  return null;
9760
10452
  }
@@ -9948,10 +10640,13 @@ var families = {
9948
10640
  readFile: ["read", "\u8BFB\u53D6", ["path"], true],
9949
10641
  read_file: ["read", "\u8BFB\u53D6", ["path"], true],
9950
10642
  readWorkspaceFile: ["read", "\u8BFB\u53D6", ["path"], true],
10643
+ read_image: ["read", "\u770B\u56FE", ["path"], true],
9951
10644
  writeFile: ["write", "\u5199\u5165", ["path"], false],
9952
10645
  editFile: ["edit", "\u4FEE\u6539", ["path"], false],
9953
10646
  globFiles: ["find", "\u67E5\u627E\u6587\u4EF6", ["pattern", "path"], true],
9954
10647
  search: ["search", "\u641C\u7D22", ["query", "pattern"], true],
10648
+ codeSearch: ["search", "\u641C\u7D22", ["query", "pattern"], true],
10649
+ exa_search: ["search", "\u641C\u7D22", ["query", "pattern"], true],
9955
10650
  grep: ["search", "\u641C\u7D22", ["pattern", "query"], true],
9956
10651
  loadSkill: ["skill", "\u52A0\u8F7D\u6280\u80FD", ["name", "slug"], true]
9957
10652
  };
@@ -10009,10 +10704,14 @@ function safeAskText(value, max) {
10009
10704
  const guarded = withholdIfSecretLike(cleaned) || ASK_SECRET_PLACEHOLDER;
10010
10705
  return max === void 0 ? guarded : clipCompactText(guarded, max, "\u2026");
10011
10706
  }
10707
+ var BIDI_CONTROL_REGEX = new RegExp("\\p{Bidi_Control}", "gu");
10708
+ function safeApprovalSingleLineText(value, max) {
10709
+ return safeAskText(value, max).replace(BIDI_CONTROL_REGEX, "");
10710
+ }
10012
10711
  function safeApprovalMultilineText(value) {
10013
10712
  const lines = stripAnsi(String(value ?? "")).replace(/\r\n?|\u2028|\u2029/g, "\n").split("\n");
10014
10713
  return lines.map((line) => {
10015
- const cleaned = line.replace(/\t/g, " ").replace(C0_C1_CONTROL_REGEX, "");
10714
+ const cleaned = line.replace(/\t/g, " ").replace(C0_C1_CONTROL_REGEX, "").replace(BIDI_CONTROL_REGEX, "");
10016
10715
  const redacted = redactSecrets(cleaned);
10017
10716
  return redacted ? withholdIfSecretLike(redacted) || ASK_SECRET_PLACEHOLDER : "";
10018
10717
  }).join("\n");
@@ -10331,10 +11030,11 @@ function formatReadItemPath(rawPath, metadata, customHomedir) {
10331
11030
  }
10332
11031
  function formatSearchItemQuery(query, path2, customHomedir) {
10333
11032
  let text = (query || "").trim();
10334
- if (path2) {
10335
- const formattedPath = formatHomePath(path2, customHomedir);
11033
+ const trimmedPath = (path2 || "").trim();
11034
+ if (trimmedPath && trimmedPath !== "." && trimmedPath !== "./") {
11035
+ const formattedPath = formatHomePath(trimmedPath, customHomedir);
10336
11036
  if (formattedPath) {
10337
- text = text ? `${text} in ${formattedPath}` : formattedPath;
11037
+ text = text ? `${text} \xB7 ${formattedPath}` : formattedPath;
10338
11038
  }
10339
11039
  }
10340
11040
  if (!text) return "search";
@@ -10467,7 +11167,7 @@ function formatUiAskChoiceBlock(event, colorEnabled) {
10467
11167
  `;
10468
11168
  }
10469
11169
  function formatShowInteractionBlock(event, colorEnabled) {
10470
- const label = toolLabel(event.toolName || "show_interaction");
11170
+ const label = toolIcon(event.toolName || "show_interaction");
10471
11171
  let parsedPayload;
10472
11172
  if (typeof event.content === "string") {
10473
11173
  try {
@@ -10550,11 +11250,16 @@ ${cleanLines.join("\n")}
10550
11250
  function formatToolTraceLine(text, colorEnabled, accent = "none") {
10551
11251
  if (!colorEnabled) return `${text}
10552
11252
  `;
10553
- if (accent === "error") {
10554
- return `${themeText(text, "danger", true)}
10555
- `;
10556
- }
10557
- return `${dimCliText(text, true)}
11253
+ const width = resolveSurfacePaintWidth(process.stdout.columns || 80);
11254
+ const fitted = fitAnsiLine(text.replace(/\r?\n/g, " "), width);
11255
+ const styled = accent === "error" ? themeText(fitted, "danger", true) : themeText(fitted, "muted", true);
11256
+ const candidateSurface = composerSurfaceBackgroundSequence();
11257
+ const surface = candidateSurface.startsWith("\x1B[48;2;") ? candidateSurface : "";
11258
+ return `${renderSurfaceLine({
11259
+ text: styled,
11260
+ surface,
11261
+ padTo: width
11262
+ })}
10558
11263
  `;
10559
11264
  }
10560
11265
  var cleanUserText = (value) => stripAnsi(value).replace(/[\r\n]+/g, " ").replace(/\s+/g, " ").trim();
@@ -10825,7 +11530,7 @@ function prefixFor(kind) {
10825
11530
  return kind === "added" ? "+ " : kind === "removed" ? "- " : " ";
10826
11531
  }
10827
11532
  function buildEditLine(kind, body, maxWidth = resolveEditSnippetMaxWidth()) {
10828
- return { kind, text: prefixFor(kind) + truncateByDisplayWidth(body, maxWidth) };
11533
+ return { kind, text: prefixFor(kind) + truncateByDisplayWidth(body.replace(/\t/g, " "), maxWidth) };
10829
11534
  }
10830
11535
  function snippetLinesWithKind(snippet, kind, maxWidth = resolveEditSnippetMaxWidth()) {
10831
11536
  const lines = snippet.split(/\r?\n/);
@@ -10909,16 +11614,23 @@ function formatEditDetailBlock(lines, colorEnabled, filePath, env = process.env)
10909
11614
  const isTruecolor = supportsTruecolor(env);
10910
11615
  const lang = isTruecolor ? detectCodeLangFromPath(filePath) : "unknown";
10911
11616
  const brightness = resolveTuiBrightness(env);
10912
- const padTo = Math.max(...lines.map((line) => displayWidth(line.text))) + 1;
10913
- return lines.map((line) => ` ${renderDiffLine({
10914
- kind: line.kind,
10915
- text: line.text,
10916
- highlightedText: shouldHighlightEditLine(line, lang, isTruecolor) ? buildHighlightedEditLine(line, lang, brightness, env) : void 0,
10917
- padTo,
10918
- colorEnabled: true,
10919
- env
10920
- })}
10921
- `).join("");
11617
+ const contentWidth = resolveHistoryLayoutGeometry(process.stdout.columns || 80).contentWidth;
11618
+ const bodyBudget = Math.max(0, contentWidth - 4);
11619
+ const clipped = lines.map((line) => ({ ...line, text: truncateByDisplayWidth(line.text, bodyBudget) }));
11620
+ const padTo = Math.max(0, ...clipped.map((line) => displayWidth(line.text)));
11621
+ return clipped.map((line) => {
11622
+ const rendered = renderDiffLine({
11623
+ kind: line.kind,
11624
+ text: line.text,
11625
+ highlightedText: shouldHighlightEditLine(line, lang, isTruecolor) ? buildHighlightedEditLine(line, lang, brightness, env) : void 0,
11626
+ gutter: true,
11627
+ padTo,
11628
+ colorEnabled: true,
11629
+ env
11630
+ });
11631
+ return `${fitAnsiLine(` ${rendered}`, contentWidth)}
11632
+ `;
11633
+ }).join("");
10922
11634
  }
10923
11635
  function shouldHighlightEditLine(line, lang, isTruecolor) {
10924
11636
  if (!isTruecolor || lang === "unknown") return false;
@@ -10957,9 +11669,27 @@ function memoryToolGist(toolName, metadata) {
10957
11669
  }
10958
11670
  return "";
10959
11671
  }
11672
+ function formatReadImageSummary(metadata) {
11673
+ const rawPaths = Array.isArray(metadata.paths) ? metadata.paths.filter((p) => typeof p === "string" && p.trim().length > 0) : [];
11674
+ const singlePath = typeof metadata.path === "string" && metadata.path.trim() || (rawPaths.length === 1 ? rawPaths[0].trim() : "");
11675
+ if (singlePath && rawPaths.length <= 1) {
11676
+ return gistClip(redactSecrets(formatReadItemPath(singlePath, metadata)), 52);
11677
+ }
11678
+ if (rawPaths.length > 1) {
11679
+ const firstRaw = rawPaths[0];
11680
+ const first = pathBasenameGist(redactSecrets(firstRaw)) || gistClip(redactSecrets(formatHomePath(firstRaw)), 28) || "image";
11681
+ const text = getCliLocale() === "zh" ? `${first} \u7B49 ${rawPaths.length} \u5F20\u56FE` : `${first} +${rawPaths.length - 1} more`;
11682
+ return gistClip(redactSecrets(text), 52);
11683
+ }
11684
+ return "";
11685
+ }
10960
11686
  function normalToolGistRaw(event) {
10961
11687
  const metadata = event.metadata ?? {};
10962
11688
  const toolName = event.toolName || "";
11689
+ if (toolName === "read_image") {
11690
+ const summary = formatReadImageSummary(metadata);
11691
+ if (summary) return summary;
11692
+ }
10963
11693
  if (toolName === "readFile" || toolName === "writeFile" || toolName === "editFile") {
10964
11694
  const path3 = typeof metadata.path === "string" ? metadata.path : typeof metadata.filePath === "string" ? metadata.filePath : "";
10965
11695
  if (path3) return gistClip(formatReadItemPath(path3, metadata), 52);
@@ -10968,7 +11698,7 @@ function normalToolGistRaw(event) {
10968
11698
  const url = typeof metadata.url === "string" ? metadata.url : "";
10969
11699
  if (url) return formatFetchItemUrl(url);
10970
11700
  }
10971
- if (toolName === "exa_search") {
11701
+ if (toolName === "exa_search" || toolName === "codeSearch" || toolName === "globFiles" || toolName === "searchFiles") {
10972
11702
  const query2 = typeof metadata.query === "string" ? metadata.query : typeof metadata.pattern === "string" ? metadata.pattern : "";
10973
11703
  const path3 = typeof metadata.path === "string" ? metadata.path : void 0;
10974
11704
  if (query2 || path3) return formatSearchItemQuery(query2, path3);
@@ -11018,7 +11748,7 @@ function fitNormalLine(head, tail, budget) {
11018
11748
  const room = Math.max(0, budget - displayWidth(status) - 2);
11019
11749
  return room ? `${truncateByDisplayWidth(head, room)} ${status}` : status;
11020
11750
  }
11021
- function formatNormalToolLine(event, pending, colorEnabled, opts) {
11751
+ function formatNormalToolLine(event, pending, colorEnabled, opts, omitSuccessGlyph) {
11022
11752
  if (event.type === "tool-call") return "";
11023
11753
  const toolName = event.toolName || pending?.toolName || "tool";
11024
11754
  if (event.type === "tool-result" && (event.toolName === "ask_user" || event.metadata?.uiAskChoice)) {
@@ -11037,7 +11767,7 @@ function formatNormalToolLine(event, pending, colorEnabled, opts) {
11037
11767
  if (event.type === "tool-result" && toolName === "show_interaction") {
11038
11768
  return formatShowInteractionBlock(event, colorEnabled);
11039
11769
  }
11040
- const label = toolLabel(toolName);
11770
+ const label = toolIcon(toolName);
11041
11771
  const cols = typeof process !== "undefined" && typeof process.stdout?.columns === "number" && process.stdout.columns > 0 ? process.stdout.columns : 80;
11042
11772
  const totalBudget = Math.max(1, resolveHistoryLayoutGeometry(cols).contentWidth - displayWidth("\u25C8 "));
11043
11773
  if (readActionGate(event.metadata?.actionGate) || event.metadata?.permissionRequest) {
@@ -11055,11 +11785,13 @@ function formatNormalToolLine(event, pending, colorEnabled, opts) {
11055
11785
  const gist = [normalToolGist(event), resultSummary].filter(Boolean).join(" \xB7 ");
11056
11786
  const hint = editFileResultHint(event);
11057
11787
  const statsInline = hint?.inline ? ` ${hint.inline}` : "";
11788
+ const canOmitLabel = Boolean(gist || statsInline);
11789
+ const successLabel = canOmitLabel && omitSuccessGlyph?.(toolName) ? " ".repeat(displayWidth(label)) : label;
11058
11790
  const durationInline = formatNormalToolDuration(event.elapsedMs);
11059
11791
  const tail = durationInline ? ` \u2713 ${durationInline}` : " \u2713";
11060
11792
  let fittedGist = gist;
11061
11793
  if (gist) {
11062
- const prefix = `\u25B8 ${label} \xB7 `;
11794
+ const prefix = `\u25B8 ${successLabel} \xB7 `;
11063
11795
  const suffix = `${statsInline}${tail}`;
11064
11796
  const prefixWidth = displayWidth(prefix);
11065
11797
  const suffixWidth = displayWidth(suffix);
@@ -11068,7 +11800,7 @@ function formatNormalToolLine(event, pending, colorEnabled, opts) {
11068
11800
  fittedGist = maxGistWidth > 0 ? truncateByDisplayWidth(gist, maxGistWidth) : "";
11069
11801
  }
11070
11802
  }
11071
- const lineContent = fittedGist ? `\u25B8 ${label} \xB7 ${fittedGist}${statsInline}${tail}` : `\u25B8 ${label}${statsInline}${tail}`;
11803
+ const lineContent = fittedGist ? `\u25B8 ${successLabel} \xB7 ${fittedGist}${statsInline}${tail}` : `\u25B8 ${successLabel}${statsInline}${tail}`;
11072
11804
  const mainLine = formatToolTraceLine(fitNormalLine(lineContent.slice(0, -tail.length), tail, totalBudget), colorEnabled);
11073
11805
  if (hint?.detail?.length) {
11074
11806
  const filePath = typeof event.metadata?.path === "string" ? event.metadata.path : void 0;
@@ -11156,34 +11888,65 @@ var TUI_TREE_MARKER = "TUI_TREE\n";
11156
11888
  var TUI_TREE_END = "";
11157
11889
  var TUI_TREE_TOOLS = {
11158
11890
  Run: ["execShell", "runCommand", "launchProcess"],
11159
- Read: ["readFile"],
11160
- Search: ["exa_search"],
11891
+ Read: ["readFile", "read_image"],
11892
+ Search: ["exa_search", "globFiles", "searchFiles", "codeSearch"],
11161
11893
  Fetch: ["fetchWebpage"]
11162
11894
  };
11163
11895
  function toolDetails(event, line) {
11164
11896
  const command = event.metadata?.command;
11165
- return isRunToolName(event.toolName) && typeof command === "string" ? `${line}${safeApprovalMultilineText(command)}
11166
- ` : line;
11897
+ return isRunToolName(event.toolName) && typeof command === "string" ? `${toolRowDetailLine(line)}${safeApprovalMultilineText(command)}
11898
+ ` : toolRowDetailLine(line);
11899
+ }
11900
+ function toolRowDetailLine(line) {
11901
+ if (/^(?:\u001b\[[0-9;]*m)*▸ /.test(line)) return line;
11902
+ const match = /^(?:\u001b\[[0-9;]*m)*▸ (\S+)/.exec(line);
11903
+ if (!match) return line;
11904
+ const glyph = match[1] ?? "";
11905
+ const family = toolFamilyOfIcon(glyph);
11906
+ if (!family) return line;
11907
+ if (glyph === family.en || glyph === family.zh) return line;
11908
+ const familyName = toolFamilyLabel(glyph);
11909
+ const glyphIndex = match[0].length - glyph.length;
11910
+ return `${line.slice(0, glyphIndex)}${familyName}${line.slice(match[0].length)}`;
11167
11911
  }
11168
11912
  function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts = {}) {
11169
11913
  const pending = /* @__PURE__ */ new Map();
11170
11914
  let scope = 0;
11915
+ let lastFamilyId;
11171
11916
  let tree = null;
11172
11917
  const treeKind = (name) => Object.keys(TUI_TREE_TOOLS).find((kind) => TUI_TREE_TOOLS[kind].includes(name)) ?? null;
11173
- const treeLine = (kind, items, fallback, details) => {
11174
- const label = kind === "Run" ? toolLabel("execShell") : kind === "Read" ? toolLabel("readFile") : kind === "Fetch" ? toolLabel("fetchWebpage") : toolLabel("exa_search");
11175
- const header = `${label} (${items.length}) \xB7 `;
11918
+ const treeLine = (kind, counts, items, fallback, details) => {
11919
+ const activeKinds = Object.keys(counts).filter((k) => counts[k] > 0);
11920
+ const isMixed = activeKinds.length > 1;
11176
11921
  const columns = resolveHistoryLayoutGeometry(process.stdout.columns).contentWidth - displayWidth("\u25C8 ");
11177
11922
  const budget = Math.max(1, columns);
11178
- let shown = 1;
11179
- for (let count = 2; count <= items.length; count++) {
11180
- const suffix = count < items.length ? ", \u2026" : "";
11181
- if (displayWidth(`\u25B8 ${header}${items.slice(0, count).join(", ")}${suffix} \u2713`) > budget) break;
11182
- shown = count;
11923
+ let summary;
11924
+ let payloadKind = kind;
11925
+ if (isMixed) {
11926
+ const parts = [
11927
+ counts.Read > 0 ? t("explorePartRead", String(counts.Read)) : "",
11928
+ counts.Search > 0 ? t("explorePartSearch", String(counts.Search)) : "",
11929
+ counts.Run > 0 ? t("explorePartRun", String(counts.Run)) : "",
11930
+ counts.Fetch > 0 ? t("explorePartFetch", String(counts.Fetch)) : ""
11931
+ ].filter(Boolean).join(", ");
11932
+ const label = toolIcon("readFile");
11933
+ summary = fitNormalLine(`${label} \xB7 ${t("exploreSummary", String(items.length), parts)}`, "\u2713", Math.max(1, budget - 2));
11934
+ payloadKind = "Read";
11935
+ } else {
11936
+ const singleKind = activeKinds[0] ?? kind;
11937
+ payloadKind = singleKind;
11938
+ const label = singleKind === "Run" ? toolIcon("execShell") : singleKind === "Read" ? toolIcon("readFile") : singleKind === "Fetch" ? toolIcon("fetchWebpage") : toolIcon("exa_search");
11939
+ const header = `${label} (${items.length}) \xB7 `;
11940
+ let shown = 1;
11941
+ for (let count = 2; count <= items.length; count++) {
11942
+ const suffix = count < items.length ? ", \u2026" : "";
11943
+ if (displayWidth(`\u25B8 ${header}${items.slice(0, count).join(", ")}${suffix} \u2713`) > budget) break;
11944
+ shown = count;
11945
+ }
11946
+ summary = fitNormalLine(`${header}${items.slice(0, shown).join(", ")}${shown < items.length ? ", \u2026" : ""}`, "\u2713", Math.max(1, budget - 2));
11183
11947
  }
11184
- const summary = fitNormalLine(`${header}${items.slice(0, shown).join(", ")}${shown < items.length ? ", \u2026" : ""}`, "\u2713", Math.max(1, budget - 2));
11185
11948
  const payload = {
11186
- kind,
11949
+ kind: payloadKind,
11187
11950
  summary,
11188
11951
  fallback,
11189
11952
  details,
@@ -11214,32 +11977,45 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
11214
11977
  attention: [],
11215
11978
  mode: "ordinary",
11216
11979
  // Formatter lifecycle/reset is the real assistant-output boundary;
11217
- // round comes from the execution stream, never from adjacent rows.
11980
+ // consecutive read-only exploration folds across rounds until a
11981
+ // non-readonly tool, error/gate, or assistant prose interrupts it.
11218
11982
  scopeKey: `assistant:${scope}`,
11219
- batchKey: Number.isInteger(event.round) && event.round >= 0 ? `round:${event.round}` : void 0,
11983
+ batchKey: `explore:${scope}`,
11220
11984
  evidenceKey: event.toolCallId
11221
11985
  });
11986
+ const isReadOnlyExploration = kind === "Read" || kind === "Search" || kind === "Fetch" || kind === "Run" && activity.readOnly === true;
11987
+ if (!isReadOnlyExploration) {
11988
+ tree = null;
11989
+ return null;
11990
+ }
11222
11991
  let item = "";
11223
11992
  const m = event.metadata ?? {};
11224
11993
  if (kind === "Run") {
11225
11994
  item = activity.summary ?? (activity.confidence === "raw-fallback" ? clipCompactText(redactSecrets(activity.object ?? ""), 56, "\u2026") : [activity.action, activity.object].filter(Boolean).join(" "));
11226
11995
  }
11227
- if (kind === "Read") item = formatReadItemPath(typeof m.path === "string" ? m.path : typeof m.filePath === "string" ? m.filePath : "file", m);
11996
+ if (kind === "Read") {
11997
+ if (name === "read_image") {
11998
+ item = formatReadImageSummary(m) || toolIcon("read_image");
11999
+ } else {
12000
+ item = formatReadItemPath(typeof m.path === "string" ? m.path : typeof m.filePath === "string" ? m.filePath : "file", m);
12001
+ }
12002
+ }
11228
12003
  if (kind === "Search") item = formatSearchItemQuery(typeof m.query === "string" ? m.query : typeof m.pattern === "string" ? m.pattern : "search", typeof m.path === "string" ? m.path : void 0);
11229
12004
  if (kind === "Fetch") item = formatFetchItemUrl(typeof m.url === "string" ? m.url : "webpage");
11230
12005
  item = safeAskText(item) || toolLabel(name);
11231
- if (tree?.kind !== kind || !canCoalesceToolActivities(tree.activity, activity)) tree = { kind, items: [], activity };
12006
+ if (!tree || !canCoalesceToolActivities(tree.activity, activity)) {
12007
+ tree = { counts: { Run: 0, Read: 0, Search: 0, Fetch: 0 }, items: [], activity };
12008
+ }
12009
+ tree.counts[kind] += 1;
11232
12010
  tree.items.push(item);
11233
12011
  if (tree.items.length < 2) {
11234
12012
  const line2 = formatNormalToolLine(event, call, colorEnabled, opts);
11235
12013
  tree.lastRow = stripAnsi(line2).trimEnd();
11236
- const rawCommand = typeof m.command === "string" ? m.command : "";
11237
- const runIdentity = kind === "Run" && activity.readOnly && rawCommand ? createHash2("sha256").update(rawCommand).digest("hex").slice(0, 16) : void 0;
11238
- return `${TUI_TREE_MARKER}${JSON.stringify({ kind, summary: stripAnsi(line2).trimEnd().replace(/^▸ /, ""), fallback: line2, details: toolDetails(event, line2), appendOnly: true, ...runIdentity ? { readOnly: true, runIdentity } : {} })}${TUI_TREE_END}
12014
+ return `${TUI_TREE_MARKER}${JSON.stringify({ kind, summary: stripAnsi(line2).trimEnd().replace(/^▸ /, ""), fallback: line2, details: toolDetails(event, line2), appendOnly: true })}${TUI_TREE_END}
11239
12015
  `;
11240
12016
  }
11241
12017
  const line = formatNormalToolLine(event, call, colorEnabled, opts);
11242
- return treeLine(kind, tree.items, line, toolDetails(event, line));
12018
+ return treeLine(kind, tree.counts, tree.items, line, toolDetails(event, line));
11243
12019
  };
11244
12020
  const format = (event) => {
11245
12021
  if (event.type === "tool-call") {
@@ -11251,9 +12027,14 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
11251
12027
  }
11252
12028
  const call = pending.get(event.toolCallId);
11253
12029
  pending.delete(event.toolCallId);
12030
+ const previousFamilyId = lastFamilyId;
12031
+ lastFamilyId = void 0;
11254
12032
  const treeOutput = formatTreeEvent(event, call);
11255
12033
  if (treeOutput !== null) return treeOutput;
11256
- const line = formatNormalToolLine(event, call, colorEnabled, opts);
12034
+ const line = formatNormalToolLine(event, call, colorEnabled, opts, opts.tuiTrees ? void 0 : (name) => {
12035
+ lastFamilyId = toolFamilyOf(name).id;
12036
+ return previousFamilyId === lastFamilyId;
12037
+ });
11257
12038
  if (opts.tuiTrees && line && isRunToolName(event.toolName)) {
11258
12039
  return `${TUI_TREE_MARKER}${JSON.stringify({ kind: "Run", summary: "", fallback: line, details: toolDetails(event, line), appendOnly: true })}${TUI_TREE_END}
11259
12040
  `;
@@ -11262,6 +12043,7 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
11262
12043
  };
11263
12044
  format.reset = () => {
11264
12045
  tree = null;
12046
+ lastFamilyId = void 0;
11265
12047
  scope++;
11266
12048
  };
11267
12049
  format.consume = (event) => {
@@ -11274,6 +12056,7 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
11274
12056
  }
11275
12057
  pending.delete(event.toolCallId);
11276
12058
  tree = null;
12059
+ lastFamilyId = void 0;
11277
12060
  };
11278
12061
  return format;
11279
12062
  }
@@ -11363,7 +12146,9 @@ var Spinner = class {
11363
12146
  timer = null;
11364
12147
  startTime = 0;
11365
12148
  frameIndex = 0;
11366
- frames = ["\xB7", "~", "\u2248", "\u223F", "\u2248", "~"];
12149
+ // 与 TUI 活动行同一套 braille 帧(tui/activityIndicator.ts 的 ACTIVITY_FRAMES),
12150
+ // 保持两条指示器观感一致;每帧宽度 1 列。
12151
+ frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
11367
12152
  isTTY;
11368
12153
  thinkingHint = "";
11369
12154
  start() {
@@ -11520,7 +12305,7 @@ function createCliTurnOutput(params) {
11520
12305
  });
11521
12306
  const eventMode = resolveAgentEventMode(options);
11522
12307
  const assistantLabelManaged = options.output.assistantLabelManaged === true;
11523
- const showThinking = !assistantLabelManaged && options.showThinking !== false;
12308
+ const showThinking = options.showThinking !== false;
11524
12309
  const hidesRoutineTuiToolDetail = (event) => {
11525
12310
  return false;
11526
12311
  };
@@ -11530,28 +12315,17 @@ function createCliTurnOutput(params) {
11530
12315
  let thinkState = createThinkParserState();
11531
12316
  let thinkingFirstAt = null;
11532
12317
  let thinkingPreview = "";
11533
- let tuiThinkingReported = false;
11534
- const clearTuiThinkingLabel = () => {
11535
- if (!tuiThinkingReported) return;
11536
- tuiThinkingReported = false;
11537
- options.activityReporter?.(null);
11538
- };
11539
12318
  const markThinkingDelta = (chunk) => {
11540
- if (assistantLabelManaged) {
11541
- if (!tuiThinkingReported && !streamedAssistantText) {
11542
- tuiThinkingReported = true;
11543
- options.activityReporter?.(t("thinkingActive"));
11544
- }
11545
- return;
11546
- }
11547
12319
  if (!showThinking) return;
11548
- if (streamedAssistantText) return;
12320
+ if (streamedAssistantText || assistantLabelManaged && pendingTuiNarration) return;
11549
12321
  if (thinkingFirstAt === null) {
11550
12322
  thinkingFirstAt = Date.now();
11551
12323
  thinkingPreview = "";
11552
12324
  }
11553
12325
  thinkingPreview = appendThinkingPreview(thinkingPreview, chunk);
11554
- spinner.setThinkingHint(thinkingPreview);
12326
+ if (!assistantLabelManaged) {
12327
+ spinner.setThinkingHint(thinkingPreview);
12328
+ }
11555
12329
  reportThinkingProgress();
11556
12330
  };
11557
12331
  const reportThinkingProgress = () => {
@@ -11561,14 +12335,15 @@ function createCliTurnOutput(params) {
11561
12335
  options.activityReporter?.(label);
11562
12336
  };
11563
12337
  const endThinkingPhase = () => {
11564
- clearTuiThinkingLabel();
11565
12338
  if (thinkingFirstAt === null) return;
11566
12339
  const seconds = Math.max(0, Math.round((Date.now() - thinkingFirstAt) / 1e3));
11567
12340
  thinkingFirstAt = null;
11568
12341
  thinkingPreview = "";
11569
- spinner.stop();
12342
+ if (!assistantLabelManaged) {
12343
+ spinner.stop();
12344
+ }
11570
12345
  options.activityReporter?.(null);
11571
- if (seconds >= 1) {
12346
+ if (!assistantLabelManaged && seconds >= 1) {
11572
12347
  options.output.write(`${dimCliText(t("thinkingTraceLine", formatElapsed(seconds)))}
11573
12348
  `);
11574
12349
  }
@@ -12192,11 +12967,15 @@ function findCollapsedPasteSpanAt(buffer, pos, opts = {}) {
12192
12967
  return null;
12193
12968
  }
12194
12969
 
12195
- // packages/cli/idleHeapRelease.ts
12970
+ // packages/agent-runtime/idleHeapRelease.ts
12196
12971
  var IDLE_HEAP_RELEASE_DELAY_MS = 2e3;
12972
+ function isIdleHeapReleaseDisabled(env, disableEnvVar) {
12973
+ return env?.[disableEnvVar] === "0";
12974
+ }
12197
12975
  function releaseHeapPages(options = {}) {
12198
12976
  const env = options.env ?? process.env;
12199
- if (env.NOLO_TUI_IDLE_HEAP_RELEASE === "0") return;
12977
+ const disableEnvVar = options.disableEnvVar ?? "NOLO_TUI_IDLE_HEAP_RELEASE";
12978
+ if (isIdleHeapReleaseDisabled(env, disableEnvVar)) return;
12200
12979
  const bun = "bun" in options ? options.bun : globalThis.Bun;
12201
12980
  if (typeof bun?.gc !== "function" || typeof bun?.shrink !== "function") return;
12202
12981
  try {
@@ -12206,10 +12985,11 @@ function releaseHeapPages(options = {}) {
12206
12985
  }
12207
12986
  }
12208
12987
  function createIdleHeapReleaser(options = {}) {
12209
- const env = options.env ?? process.env;
12988
+ const disableEnvVar = options.disableEnvVar ?? "NOLO_TUI_IDLE_HEAP_RELEASE";
12989
+ const hasExplicitEnv = "env" in options;
12210
12990
  const bun = "bun" in options ? options.bun : globalThis.Bun;
12211
- const disabled = env.NOLO_TUI_IDLE_HEAP_RELEASE === "0" || typeof bun?.gc !== "function" || typeof bun?.shrink !== "function";
12212
- if (disabled) return { schedule() {
12991
+ const disabledAtCreation = hasExplicitEnv && isIdleHeapReleaseDisabled(options.env, disableEnvVar) || typeof bun?.gc !== "function" || typeof bun?.shrink !== "function";
12992
+ if (disabledAtCreation) return { schedule() {
12213
12993
  }, cancel() {
12214
12994
  } };
12215
12995
  const delayMs = options.delayMs ?? IDLE_HEAP_RELEASE_DELAY_MS;
@@ -12220,20 +13000,26 @@ function createIdleHeapReleaser(options = {}) {
12220
13000
  });
12221
13001
  const clearTimer = options.clearTimer ?? ((handle) => clearTimeout(handle));
12222
13002
  let pending = null;
13003
+ const currentEnv = () => hasExplicitEnv ? options.env : process.env;
13004
+ const cancel = () => {
13005
+ if (pending === null) return;
13006
+ clearTimer(pending);
13007
+ pending = null;
13008
+ };
12223
13009
  const release = () => {
12224
13010
  pending = null;
12225
- releaseHeapPages({ env, bun });
13011
+ releaseHeapPages({ env: currentEnv(), disableEnvVar, bun });
12226
13012
  };
12227
13013
  return {
12228
13014
  schedule() {
13015
+ if (isIdleHeapReleaseDisabled(currentEnv(), disableEnvVar)) {
13016
+ cancel();
13017
+ return;
13018
+ }
12229
13019
  if (pending !== null) clearTimer(pending);
12230
13020
  pending = setTimer(release, delayMs);
12231
13021
  },
12232
- cancel() {
12233
- if (pending === null) return;
12234
- clearTimer(pending);
12235
- pending = null;
12236
- }
13022
+ cancel
12237
13023
  };
12238
13024
  }
12239
13025
 
@@ -12278,7 +13064,7 @@ function isBalanceExhaustedError(error) {
12278
13064
 
12279
13065
  // packages/cli/client/agentRun.ts
12280
13066
  async function loadRunLocalAgentTurn() {
12281
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-HOXKWCYO.js");
13067
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-LVXPQ7QA.js");
12282
13068
  return runLocalAgentTurn;
12283
13069
  }
12284
13070
  var stripDebugNoise = (s) => s.replace(/\s*raw="[\s\S]*"/g, "").replace(/\s*raw=\S+/g, "").replace(/\s*headers=\[[^\]]*\]/g, "").replace(/\s*headers=\S+/g, "").trim();
@@ -12326,7 +13112,7 @@ function parseEmbeddedBalanceDetails(message) {
12326
13112
  function parseContextLengthDetails(message) {
12327
13113
  let max;
12328
13114
  let requested;
12329
- const maxMatch = message.match(/maximum context length\s+(?:is|of)\s*(\d+)/i);
13115
+ const maxMatch = message.match(/maximum context length\s+(?:is|of)\s*(\d+)/i) ?? message.match(/maximum number of tokens allowed(?:\s*(?:is|of))?\s*[:=]?\s*(\d+)/i) ?? message.match(/exceeds?\s+(?:the\s+)?(?:model(?:'s)?\s+)?maximum(?:\s+context)?\s+(?:length|limit|tokens?)\s*(?:is|of|:)?\s*(\d+)/i);
12330
13116
  if (maxMatch) {
12331
13117
  max = maxMatch[1];
12332
13118
  }
@@ -12364,6 +13150,9 @@ function buildDefaultLocalRuntimeAdapter(options) {
12364
13150
  // 分享 OAuth agent 的 shell 会话授权(块 D):仅 owner-required 场景生效。
12365
13151
  ...options.shellGrant ? { shellGrant: options.shellGrant } : {},
12366
13152
  ...options.shellApprovalSession ? { shellApprovalSession: options.shellApprovalSession } : {},
13153
+ ...options.mcpConfirmation ? { mcpConfirmation: options.mcpConfirmation } : {},
13154
+ // A background child's approval channel belongs to the host session, not the spawning turn.
13155
+ mcpApprovalSignal: options.mcpApprovalSignal ?? options.shellApprovalSession?.signal,
12367
13156
  ...options.execShellApproval ? { execShellApproval: options.execShellApproval } : {},
12368
13157
  // 运行位置展示(块 D):TUI 消费 projectToolExecutionLocation 渲染工具实际
12369
13158
  // 执行设备/工作区;非 owner-required 场景 adapter 不回调。
@@ -12548,6 +13337,12 @@ function looksLikeRateLimitedText(message) {
12548
13337
  return EXTRA_RATE_LIMIT_TEXT_RE.test(message) || QUOTA_ERROR_PATTERNS.some((pattern) => pattern.test(message));
12549
13338
  }
12550
13339
  var AUTH_TEXT_SIGNAL_RE = /\b401\b|unauthori[sz]ed|invalid[_\s-]?(?:api[_\s-]?key|token|credential)s?|(?:api[_\s-]?key|token|credential)s?[_\s-](?:invalid|expired|rejected|missing|not[_\s-]?found)|authentication[_\s-]?(?:error|failed|required)/i;
13340
+ function isAuthFailureError(error) {
13341
+ if (!error) return false;
13342
+ const msg = toErrorMessage(error);
13343
+ if (!msg) return false;
13344
+ return AUTH_TEXT_SIGNAL_RE.test(msg) || classifyLocalRunError(msg).kind === "auth";
13345
+ }
12551
13346
  var QUOTA_EXHAUSTED_EXTRA_RE = /insufficient[_\s-]?(?:quota|balance|credits?)|余额不足|额度已?用尽/i;
12552
13347
  function looksLikeQuotaExhaustedText(message) {
12553
13348
  return isQuotaExhaustedText(message) || QUOTA_EXHAUSTED_EXTRA_RE.test(message);
@@ -12974,6 +13769,12 @@ function formatLocalTurnFailureLine(error) {
12974
13769
  }
12975
13770
  if (isMissingBatchReceiptFailure(message)) {
12976
13771
  return `[nolo] ${describeMissingBatchReceipt()}.
13772
+ `;
13773
+ }
13774
+ if (isContextOverflowText(message)) {
13775
+ const details = parseContextLengthDetails(message);
13776
+ const shownMessage = details.requested && details.max ? t("contextLengthExceeded", details.requested, details.max) : details.max ? t("contextLengthExceededLimitOnly", details.max) : t("contextLengthExceededGeneric");
13777
+ return `[nolo] ${shownMessage}
12977
13778
  `;
12978
13779
  }
12979
13780
  if (error?.code === "LLM_REQUEST_TIMEOUT") {
@@ -13034,7 +13835,11 @@ function describeLocalRunFailure(message, rawError) {
13034
13835
  where: PLATFORM_TRANSPORT_RE.test(message) ? "server chat proxy" : "local provider"
13035
13836
  });
13036
13837
  }
13037
- if (/maximum context length/i.test(message)) {
13838
+ if (isLocalContextCoverageFailure(rawError ?? message)) {
13839
+ return `[nolo] ${describeContextRefusal(contextRefusalDiagnostics(rawError))}
13840
+ `;
13841
+ }
13842
+ if (isContextOverflowText(message)) {
13038
13843
  const details = parseContextLengthDetails(message);
13039
13844
  const shownMessage = details.requested && details.max ? t("contextLengthExceeded", details.requested, details.max) : details.max ? t("contextLengthExceededLimitOnly", details.max) : t("contextLengthExceededGeneric");
13040
13845
  return `[nolo] ${shownMessage}
@@ -13067,10 +13872,6 @@ function describeLocalRunFailure(message, rawError) {
13067
13872
  if (isCliBatchPhaseFailure(rawError)) {
13068
13873
  return describeCliBatchPhaseFailure(rawError);
13069
13874
  }
13070
- if (isLocalContextCoverageFailure(rawError ?? message)) {
13071
- return `[nolo] ${describeContextRefusal(contextRefusalDiagnostics(rawError))}
13072
- `;
13073
- }
13074
13875
  if (isMissingBatchReceiptFailure(message)) {
13075
13876
  return `[nolo] ${describeMissingBatchReceipt()}.
13076
13877
  `;
@@ -13484,6 +14285,26 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
13484
14285
  `);
13485
14286
  return { exitCode: 1, localError: error };
13486
14287
  }
14288
+ const userId = resolveLocalUserId(options.env);
14289
+ const getTurnStore = () => getOrCreateSharedStore({
14290
+ env: options.env,
14291
+ cwd: options.localRuntimeCwd,
14292
+ fetchImpl: options.fetchImpl
14293
+ });
14294
+ const canUseWorkSource = !options.ephemeral && !options.background && !options.internalTurn && options.env.NOLO_AGENT_RUN_CHILD !== "1";
14295
+ if (canUseWorkSource && options.userMessages?.length === 1) {
14296
+ try {
14297
+ const id = await resolvePersistedTurnUserMessageId({
14298
+ store: await getTurnStore(),
14299
+ userId,
14300
+ dialogId: currentDialogId,
14301
+ batchMessageIds: batchIdentity?.messageIds,
14302
+ userMessages: options.userMessages
14303
+ });
14304
+ if (id) runtimeContextWithOwnership.userMessageId = id;
14305
+ } catch {
14306
+ }
14307
+ }
13487
14308
  const markBatch = async (phase) => {
13488
14309
  if (!batchIdentity) return;
13489
14310
  const store = await getOrCreateSharedStore({ env: options.env, cwd: options.localRuntimeCwd, fetchImpl: options.fetchImpl });
@@ -13549,6 +14370,7 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
13549
14370
  };
13550
14371
  const expandedMessage = options.pastedTextStore?.items.size ? expandCollapsedPastes(options.message, options.pastedTextStore) : options.message;
13551
14372
  const commandObservations = [];
14373
+ const collectedToolImageArtifacts = [];
13552
14374
  const retainCommandObservations = (result) => {
13553
14375
  recordRunResultHeaderMeta(result, { commandObservations });
13554
14376
  return result;
@@ -13606,6 +14428,28 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
13606
14428
  inheritedFromDialogKey: options.inheritedFromDialogKey,
13607
14429
  parentDialogId: options.parentDialogId,
13608
14430
  runtimeContext: runtimeContextWithOwnership,
14431
+ ...canUseWorkSource && !batchIdentity && !options.userMessages?.length ? { prepareDirectWorkMemorySource: async (message) => persistDirectWorkMemorySource({
14432
+ store: await getTurnStore(),
14433
+ userId,
14434
+ dialogId: currentDialogId,
14435
+ turnId,
14436
+ freshDialog,
14437
+ input: {
14438
+ agentKey: options.agentKey,
14439
+ runtimeContext: runtimeContextWithOwnership,
14440
+ spaceId: options.spaceId,
14441
+ category: options.category,
14442
+ inheritedFromDialogKey: options.inheritedFromDialogKey,
14443
+ parentDialogId: options.parentDialogId
14444
+ },
14445
+ message
14446
+ }) } : {},
14447
+ ...!options.ephemeral ? { resolveInjectedUserMessageId: async (messages) => resolvePersistedTurnUserMessageId({
14448
+ store: await getTurnStore(),
14449
+ userId,
14450
+ dialogId: currentDialogId,
14451
+ userMessages: messages
14452
+ }) } : {},
13609
14453
  runKind: options.env.NOLO_AGENT_RUN_CHILD === "1" ? "subtask" : "interactive",
13610
14454
  // 展示能力由宿主声明(TUI=narrow),非交互 CLI/后台留空 → unknown;
13611
14455
  // 排版段只在能力已知时由 localLoop 注入,server 线不读该字段。
@@ -13639,11 +14483,18 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
13639
14483
  ...options.abortSignal ? { abortSignal: options.abortSignal } : {},
13640
14484
  // 回合内注入(TUI 后台 run 唤醒直投):透传给 local loop。
13641
14485
  ...options.drainInjections ? { drainInjections: options.drainInjections } : {},
13642
- // tool-gist-fold 后 onToolEvent 无条件挂载(不再受 traceLocalTools 开关
13643
- // 控制,显示模式合并为单一 gist/折叠通道)——保留 alpha 的新形态。
14486
+ // tool-gist 化后 onToolEvent 无条件挂载(不再受 traceLocalTools 开关
14487
+ // 控制,显示模式合并为单一 gist 通道)——保留 alpha 的新形态。
13644
14488
  onToolEvent: (event) => {
13645
14489
  const observation = observeLocalCommandResult(event, options.localRuntimeCwd ?? process.cwd());
13646
14490
  if (observation) commandObservations.push({ ...observation, ...commandVersionBindings.get(event.toolCallId) });
14491
+ if (event.type === "tool-result" && event.imageArtifacts?.length) {
14492
+ if (options.onToolImageArtifacts) {
14493
+ options.onToolImageArtifacts(event.imageArtifacts);
14494
+ } else {
14495
+ collectedToolImageArtifacts.push(...event.imageArtifacts);
14496
+ }
14497
+ }
13647
14498
  turnOutput.handleToolEvent(event);
13648
14499
  },
13649
14500
  ...!options.noStream ? {
@@ -13661,6 +14512,7 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
13661
14512
  );
13662
14513
  const turnCredits = sumPlatformCredits(result.usageRecords);
13663
14514
  const turnTokens = withTurnCredits(buildTurnTokenUsage(result.usage, result.model), turnCredits);
14515
+ const runContextWindow = result.model ? resolveAgentContextWindow2({ model: result.model }) : void 0;
13664
14516
  const turnResult = {
13665
14517
  savedTurnPersisted: turnPersisted,
13666
14518
  mainProviderAttempted: mainProviderStarted,
@@ -13677,7 +14529,9 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
13677
14529
  // 上下文占用本来就该看最后一次调用的累计输入,不是各次相加。
13678
14530
  ...turnTokens !== void 0 ? { turnTokens } : {},
13679
14531
  ...turnCredits !== void 0 ? { turnCredits } : {},
13680
- ...usageRecords?.length ? { usageRecords } : {}
14532
+ ...usageRecords?.length ? { usageRecords } : {},
14533
+ ...runContextWindow !== void 0 ? { contextWindow: runContextWindow } : {},
14534
+ ...collectedToolImageArtifacts.length > 0 ? { toolImageArtifacts: collectedToolImageArtifacts } : {}
13681
14535
  };
13682
14536
  const serverMeta = resolveResultServerMeta({
13683
14537
  env: options.env ?? {},
@@ -13818,7 +14672,7 @@ function foldLocalResultForTui(localResult) {
13818
14672
  exitCode: localResult.exitCode,
13819
14673
  ...projectLocalTurnFacts(localResult),
13820
14674
  ...localResult.dialogId ? { dialogId: localResult.dialogId } : {},
13821
- title: localResult.title,
14675
+ ...localResult.title !== void 0 ? { title: localResult.title } : {},
13822
14676
  ...localResult.titlePatchPromise ? { titlePatchPromise: localResult.titlePatchPromise } : {},
13823
14677
  // 空 assistant 兜底成因必须随行:后台 run 的结算(resolveRunOutcome 的
13824
14678
  // isStalledOrTruncated)靠它把截断轮判成 stalled 而不是 clean 失败。
@@ -13839,7 +14693,11 @@ function foldLocalResultForTui(localResult) {
13839
14693
  // Authoritatively 拿不到 lastAssistantText → `.result.md` 不写、status 无
13840
14694
  // resultFile,编排者只能去啃带 ANSI 的 .log(同坑位历史:turnCredits)。
13841
14695
  ...localResult.finalText ? { finalText: localResult.finalText } : {},
13842
- ...localResult.failureSubclass ? { failureSubclass: localResult.failureSubclass } : {}
14696
+ ...localResult.failureSubclass ? { failureSubclass: localResult.failureSubclass } : {},
14697
+ // 窗口上限必须随行:provider 不回 usage 帧(自有 API / 订阅制 CLI)时
14698
+ // turnTokens 为 undefined,状态行 ctx chip 的窗口就只剩这一个来源;白名单
14699
+ // 漏掉它 = 自建 custom agent 永远显示 `ctx —`(同坑位历史:turnCredits)。
14700
+ ...localResult.contextWindow !== void 0 ? { contextWindow: localResult.contextWindow } : {}
13843
14701
  };
13844
14702
  const headerMeta = getRunResultHeaderMeta(localResult);
13845
14703
  recordRunResultHeaderMeta(folded, headerMeta);
@@ -14216,6 +15074,7 @@ function executeDoDCommand(cmd, cwd, deps = {}) {
14216
15074
  shell: true,
14217
15075
  windowsHide: true,
14218
15076
  cwd: cwd || process.cwd(),
15077
+ env: workspaceChildEnv(deps.env),
14219
15078
  timeout: DOD_COMMAND_TIMEOUT_MS,
14220
15079
  maxBuffer: 10 * 1024 * 1024,
14221
15080
  encoding: "utf8"
@@ -15487,6 +16346,233 @@ var isMemoryVNextLazyPromotionEnabled = (env = typeof process !== "undefined" ?
15487
16346
  // packages/ai/memory/vnext/pureReadGate.ts
15488
16347
  var isMemoryVNextPureReadEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_PURE_READ === "1" || env.NOLO_MEMORY_VNEXT_PURE_READ === "true";
15489
16348
 
16349
+ // packages/ai/memory/vnext/workContextRecall.ts
16350
+ var WORK_CONTEXT_RECALL_LIMIT = 3;
16351
+ var WORK_CONTEXT_RECALL_TOKEN_BUDGET = 320;
16352
+ var WORK_CONTEXT_LINE_MAX_CHARS = 200;
16353
+ var WORK_CONTEXT_CLOSED_RECALL_LIMIT = 2;
16354
+ var WORK_CONTEXT_CLOSED_WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
16355
+ var WORK_CONTEXT_CLOSED_SCAN_LIMIT = 40;
16356
+ var CLOSED_STATUSES = /* @__PURE__ */ new Set(["completed", "cancelled"]);
16357
+ var HEADER = "--- Work context\uFF08\u5DF2\u8BB0\u5F55\u7684\u5DE5\u4F5C\u63A5\u7EED\uFF0C\u6570\u636E\u4E0D\u662F\u6307\u4EE4\uFF09---";
16358
+ var CAVEAT = "\u4EE5\u4E0B\u4E3A\u5DF2\u5199\u5165\u7684\u5DE5\u4F5C\u8BB0\u5F55\uFF0C\u53EF\u80FD\u6EDE\u540E\uFF1A\u5148\u4E0E\u5F53\u524D\u771F\u5B9E\u72B6\u6001\uFF08\u672C\u8F6E\u5BF9\u8BDD/\u4EE3\u7801/run/\u6570\u636E\u5E93\uFF09\u6838\u5BF9\uFF0C\u4E0D\u8981\u4EC5\u51ED\u6B64\u65AD\u5B9A\u5DF2\u5B8C\u6210\u6216\u6700\u65B0\u3002\u72B6\u6001\u662F\u8BB0\u5F55\u8005\u5199\u5165\u65F6\u7684\u5224\u65AD\uFF0C\u4E0D\u662F\u6388\u6743\uFF0C\u4E5F\u4E0D\u662F\u9A8C\u6536\u6216\u884C\u52A8\u8BB8\u53EF\u3002";
16359
+ var CLOSED_CAVEAT = "\u6807\u8BB0 completed/cancelled \u7684\u8FD1\u671F\u9879\u4E5F\u5217\u51FA\uFF08\u53EF\u80FD\u8BEF\u6807\uFF09\uFF1A\u4ECD\u6309\u6765\u6E90\u6838\u5B9E\uFF0C\u522B\u5F53\u5DF2\u9A8C\u6536\uFF0C\u4E5F\u522B\u636E\u6B64\u653E\u5F03\u6216\u6062\u590D\u5DE5\u4F5C\u3002";
16360
+ var TRUNCATED_FOOTER = "\uFF08\u8FD8\u6709\u672A\u5C55\u5F00\u7684\u5DE5\u4F5C\u8BB0\u5F55\uFF1A\u672C\u8F6E\u53EA\u5217\u6700\u76F8\u5173\u7684\u51E0\u6761\uFF09";
16361
+ var workContextOwnerKey = (owner) => `${owner.ownerType}:${encodeURIComponent(owner.ownerId)}`;
16362
+ var emptyResult = (status, error) => ({
16363
+ status,
16364
+ block: null,
16365
+ items: [],
16366
+ totalActive: 0,
16367
+ closedCount: 0,
16368
+ hasMore: false,
16369
+ omittedCount: 0,
16370
+ truncated: false,
16371
+ tokens: 0,
16372
+ ...error ? { error } : {}
16373
+ });
16374
+ var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
16375
+ var toRecallItem = (item, dialogId) => ({
16376
+ activityId: item.activityId,
16377
+ status: item.value.status,
16378
+ goal: item.value.goal,
16379
+ nextStep: item.value.nextStep ?? null,
16380
+ openItems: [...item.value.openItems],
16381
+ revision: item.value.revision,
16382
+ updatedAt: item.updatedAt,
16383
+ sourceRef: item.value.latestSourceRefs[0] ?? null,
16384
+ inThisDialog: item.value.dialogIds.includes(dialogId)
16385
+ });
16386
+ var clip2 = (text, max) => text.length <= max ? text : `${text.slice(0, max - 1)}\u2026`;
16387
+ var WORK_CONTEXT_SOURCE_MAX_CHARS = 60;
16388
+ var MIN_GOAL_CHARS = 24;
16389
+ var clipMiddle = (text, max) => {
16390
+ if (text.length <= max) return text;
16391
+ const head = Math.ceil((max - 1) / 2);
16392
+ const tail = max - 1 - head;
16393
+ return `${text.slice(0, head)}\u2026${text.slice(text.length - tail)}`;
16394
+ };
16395
+ var renderItemLine = (item) => {
16396
+ const where = item.inThisDialog ? "\u672C\u5BF9\u8BDD" : "\u5176\u5B83\u5BF9\u8BDD\uFF08\u9700\u786E\u8BA4\u662F\u5426\u4ECD\u76F8\u5173\uFF09";
16397
+ const source = clipMiddle(item.sourceRef ?? "\u672A\u8BB0\u5F55\u6765\u6E90", WORK_CONTEXT_SOURCE_MAX_CHARS);
16398
+ const status = CLOSED_STATUSES.has(item.status) ? `${item.status}\xB7\u8BB0\u5F55\u8005\u5224\u65AD\uFF08\u975E\u6388\u6743/\u975E\u9A8C\u6536\uFF09` : item.status;
16399
+ const head = `- [${status}] `;
16400
+ const meta = ` \uFF5C rev ${item.revision} \uFF5C \u66F4\u65B0\u4E8E ${item.updatedAt} \uFF5C \u6765\u6E90 ${source} \uFF5C ${where}`;
16401
+ const goalBudget = Math.max(
16402
+ MIN_GOAL_CHARS,
16403
+ WORK_CONTEXT_LINE_MAX_CHARS - head.length - meta.length
16404
+ );
16405
+ return `${head}${clip2(item.goal, goalBudget)}${meta}`;
16406
+ };
16407
+ var itemLines = (item) => {
16408
+ const lines = [renderItemLine(item)];
16409
+ if (item.nextStep) lines.push(clip2(` next: ${item.nextStep}`, WORK_CONTEXT_LINE_MAX_CHARS));
16410
+ if (item.openItems.length > 0) {
16411
+ lines.push(clip2(` open: ${item.openItems.join("\uFF1B")}`, WORK_CONTEXT_LINE_MAX_CHARS));
16412
+ }
16413
+ return lines;
16414
+ };
16415
+ var recallWorkContextBlock = async (input) => {
16416
+ const dialogId = input?.dialogId ?? null;
16417
+ const ownerId = input?.owner?.ownerId ?? "";
16418
+ if (!dialogId || !ownerId) return emptyResult("skipped", "no authorized dialog scope");
16419
+ const limit = clamp(input.limit ?? WORK_CONTEXT_RECALL_LIMIT, 1, 10);
16420
+ const maxTokens = clamp(input.maxTokens ?? WORK_CONTEXT_RECALL_TOKEN_BUDGET, 40, 2e3);
16421
+ const primaryOwnerKey = workContextOwnerKey(input.owner);
16422
+ const baseScope = {
16423
+ ownerId: primaryOwnerKey,
16424
+ spaceId: input.spaceId ?? null,
16425
+ dialogId
16426
+ };
16427
+ const now = input.now ?? Date.now();
16428
+ const relatedQuery = input.relatedQuery?.trim();
16429
+ let page;
16430
+ let activeScope = baseScope;
16431
+ try {
16432
+ page = await readWorkContexts(input.db, baseScope, {
16433
+ status: "active",
16434
+ discovery: "scope",
16435
+ limit
16436
+ });
16437
+ if (page.items.length === 0 && primaryOwnerKey !== ownerId) {
16438
+ activeScope = { ...baseScope, ownerId };
16439
+ page = await readWorkContexts(input.db, activeScope, {
16440
+ status: "active",
16441
+ discovery: "scope",
16442
+ limit
16443
+ });
16444
+ }
16445
+ } catch (error) {
16446
+ return emptyResult(
16447
+ "error",
16448
+ error instanceof Error ? error.message : String(error)
16449
+ );
16450
+ }
16451
+ const byRecency = (a, b) => Number(b.inThisDialog) - Number(a.inThisDialog) || b.updatedAt.localeCompare(a.updatedAt) || a.activityId.localeCompare(b.activityId);
16452
+ const activeItems = page.items.map((item) => toRecallItem(item, dialogId)).sort(byRecency);
16453
+ const totalActive = activeItems.length;
16454
+ const closedCutoff = now - WORK_CONTEXT_CLOSED_WINDOW_MS;
16455
+ const matchesRelatedQuery = (item) => {
16456
+ if (!relatedQuery) return false;
16457
+ const needle = relatedQuery.toLowerCase();
16458
+ const hay = [item.goal, item.nextStep ?? "", ...item.openItems].join("\n").toLowerCase();
16459
+ return hay.includes(needle) || item.goal.length > 0 && needle.includes(item.goal.toLowerCase());
16460
+ };
16461
+ const loadClosed = async (readScope) => {
16462
+ const closedPage = await readWorkContexts(input.db, readScope, {
16463
+ status: "all",
16464
+ discovery: "scope",
16465
+ limit: WORK_CONTEXT_CLOSED_SCAN_LIMIT
16466
+ });
16467
+ const candidates = closedPage.items.map((item) => toRecallItem(item, dialogId)).filter((item) => CLOSED_STATUSES.has(item.status)).filter((item) => {
16468
+ const updatedAt = Date.parse(item.updatedAt);
16469
+ return Number.isFinite(updatedAt) && updatedAt >= closedCutoff;
16470
+ }).filter((item) => item.inThisDialog || matchesRelatedQuery(item)).sort(byRecency);
16471
+ const items2 = candidates.slice(0, WORK_CONTEXT_CLOSED_RECALL_LIMIT);
16472
+ return { items: items2, hasMore: closedPage.hasMore || candidates.length > items2.length };
16473
+ };
16474
+ let closedItems = [];
16475
+ let closedHasMore = false;
16476
+ let closedReadError;
16477
+ try {
16478
+ const primaryClosed = await loadClosed(baseScope);
16479
+ closedItems = primaryClosed.items;
16480
+ closedHasMore = primaryClosed.hasMore;
16481
+ if (closedItems.length === 0 && !closedHasMore && primaryOwnerKey !== ownerId) {
16482
+ const fallbackClosed = await loadClosed({ ...baseScope, ownerId });
16483
+ closedItems = fallbackClosed.items;
16484
+ closedHasMore = fallbackClosed.hasMore;
16485
+ }
16486
+ } catch {
16487
+ closedItems = [];
16488
+ closedHasMore = false;
16489
+ closedReadError = "closed_read_failed";
16490
+ }
16491
+ const items = [...activeItems, ...closedItems];
16492
+ if (items.length === 0) {
16493
+ return {
16494
+ ...emptyResult("ok"),
16495
+ hasMore: page.hasMore || closedHasMore,
16496
+ ...closedReadError ? { closedCount: void 0, closedReadError } : { closedCount: 0 }
16497
+ };
16498
+ }
16499
+ const maxKept = limit + WORK_CONTEXT_CLOSED_RECALL_LIMIT;
16500
+ const baseLines = [HEADER, CAVEAT];
16501
+ const kept = [];
16502
+ const keptLines = [];
16503
+ let closedCaveatAdded = false;
16504
+ let truncated = false;
16505
+ for (let index = 0; index < items.length; index += 1) {
16506
+ if (kept.length >= maxKept) {
16507
+ truncated = true;
16508
+ break;
16509
+ }
16510
+ const item = items[index];
16511
+ const extra = [];
16512
+ if (CLOSED_STATUSES.has(item.status) && !closedCaveatAdded) {
16513
+ extra.push(CLOSED_CAVEAT);
16514
+ }
16515
+ extra.push(...itemLines(item));
16516
+ const moreAfterThis = page.hasMore || closedHasMore || index < items.length - 1;
16517
+ const projected = [
16518
+ ...baseLines,
16519
+ ...keptLines,
16520
+ ...extra,
16521
+ ...moreAfterThis ? [TRUNCATED_FOOTER] : []
16522
+ ].join("\n");
16523
+ if (estimateMemoryBlockTokens(projected) > maxTokens) {
16524
+ truncated = true;
16525
+ break;
16526
+ }
16527
+ if (CLOSED_STATUSES.has(item.status)) closedCaveatAdded = true;
16528
+ keptLines.push(...extra);
16529
+ kept.push(item);
16530
+ }
16531
+ if (kept.length === 0) {
16532
+ return {
16533
+ ...emptyResult("ok"),
16534
+ items: [],
16535
+ totalActive,
16536
+ hasMore: page.hasMore || closedHasMore || items.length > 0,
16537
+ omittedCount: items.length,
16538
+ truncated: true,
16539
+ ...closedReadError ? { closedCount: void 0, closedReadError } : { closedCount: 0 }
16540
+ };
16541
+ }
16542
+ const omittedCount = Math.max(0, items.length - kept.length);
16543
+ const hasMore = page.hasMore || closedHasMore || omittedCount > 0;
16544
+ const closedCount = closedReadError ? void 0 : kept.filter((item) => CLOSED_STATUSES.has(item.status)).length;
16545
+ const block = [
16546
+ ...baseLines,
16547
+ ...keptLines,
16548
+ ...hasMore ? [TRUNCATED_FOOTER] : []
16549
+ ].join("\n");
16550
+ const tokens2 = estimateMemoryBlockTokens(block);
16551
+ if (tokens2 > maxTokens) {
16552
+ return {
16553
+ ...emptyResult("ok"),
16554
+ totalActive,
16555
+ closedCount,
16556
+ hasMore: true,
16557
+ omittedCount: items.length,
16558
+ truncated: true,
16559
+ ...closedReadError ? { closedReadError } : {}
16560
+ };
16561
+ }
16562
+ return {
16563
+ status: "ok",
16564
+ block,
16565
+ items: kept,
16566
+ totalActive,
16567
+ closedCount,
16568
+ hasMore,
16569
+ omittedCount,
16570
+ truncated,
16571
+ tokens: tokens2,
16572
+ ...closedReadError ? { closedReadError } : {}
16573
+ };
16574
+ };
16575
+
15490
16576
  // packages/ai/memory/vnext/primaryRead.ts
15491
16577
  var MEMORY_VNEXT_PRIMARY_READ_TIMEOUT_MS = 300;
15492
16578
  var isMemoryVNextPrimaryReadEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_PRIMARY_READ === "1" || env.NOLO_MEMORY_VNEXT_PRIMARY_READ === "true";
@@ -15525,7 +16611,9 @@ var resolveMemoryVNextM4Selection = async (input) => {
15525
16611
  const principalId = `${owner.ownerType}:${encodeURIComponent(owner.ownerId)}`;
15526
16612
  const catalog = catalogs.get(principalId);
15527
16613
  if (!catalog) continue;
15528
- const currentStates = catalog.states.filter((s) => !s.retiredAt && s.text.trim());
16614
+ const currentStates = catalog.states.filter(
16615
+ (s) => !s.retiredAt && s.text.trim() && !isWorkContextState(s)
16616
+ );
15529
16617
  const hits = recallMemoryVNextLocal({
15530
16618
  query,
15531
16619
  entities: catalog.entities,
@@ -15680,7 +16768,7 @@ var selectRuntimeMemoryItems = (items, context, userInput = "") => {
15680
16768
  }
15681
16769
  return selected;
15682
16770
  };
15683
- var resolveMemoryRuntime = async (input) => {
16771
+ var resolveSemanticMemoryRuntime = async (input) => {
15684
16772
  const configuredPure = isMemoryVNextPureReadEnabled();
15685
16773
  const configuredPrimary = isMemoryVNextPrimaryReadEnabled();
15686
16774
  let branch = "no_owner";
@@ -15958,6 +17046,43 @@ var resolveMemoryRuntime = async (input) => {
15958
17046
  }
15959
17047
  }
15960
17048
  };
17049
+ var resolveMemoryRuntime = async (input) => {
17050
+ const resolution = await resolveSemanticMemoryRuntime(input);
17051
+ if ((input.workContext ?? "scope") === "off") return resolution;
17052
+ if (!input.db || !input.userId || !input.dialogId) return resolution;
17053
+ const trimmedUserInput = input.userInput?.trim().slice(0, 200);
17054
+ const recall = await recallWorkContextBlock({
17055
+ db: input.db,
17056
+ owner: { ownerType: "user", ownerId: input.userId },
17057
+ spaceId: input.workContextSpaceId ?? input.spaceId ?? null,
17058
+ dialogId: input.dialogId,
17059
+ // 本轮输入本身就是「明确相关」的最短证据:只截断,不做意图解析。
17060
+ // 同 dialog 的近期关闭项无论是否命中都会回看;跨 dialog 的关闭项要靠它。
17061
+ ...trimmedUserInput ? { relatedQuery: trimmedUserInput } : {},
17062
+ ...input.workContextLimit ? { limit: input.workContextLimit } : {}
17063
+ }).catch((error) => ({
17064
+ status: "error",
17065
+ block: null,
17066
+ items: [],
17067
+ totalActive: 0,
17068
+ hasMore: false,
17069
+ omittedCount: 0,
17070
+ truncated: false,
17071
+ tokens: 0,
17072
+ error: error instanceof Error ? error.message : String(error)
17073
+ }));
17074
+ try {
17075
+ input.workContextEmit?.(recall);
17076
+ } catch {
17077
+ }
17078
+ if (!recall.block) return resolution;
17079
+ return {
17080
+ ...resolution,
17081
+ promptBlock: resolution.promptBlock ? `${resolution.promptBlock}
17082
+
17083
+ ${recall.block}` : recall.block
17084
+ };
17085
+ };
15961
17086
 
15962
17087
  // packages/cli/memoryRecall.ts
15963
17088
  var logger = getLogger("cli.memoryRecall");
@@ -16090,6 +17215,45 @@ var resolveCliMemory = async (input) => {
16090
17215
  return null;
16091
17216
  }
16092
17217
  };
17218
+ var resolveCliWorkContext = async (input) => {
17219
+ const dialogId = input.dialogId ?? null;
17220
+ if (!dialogId) return null;
17221
+ if (input.signal?.aborted) {
17222
+ throw input.signal.reason ?? new DOMException("Aborted", "AbortError");
17223
+ }
17224
+ try {
17225
+ const localDb = input.db ?? await getDefaultCliLocalRuntimeDb({ env: input.env });
17226
+ const trimmedUserInput = input.userInput?.trim().slice(0, 200);
17227
+ const result = await recallWorkContextBlock({
17228
+ db: localDb,
17229
+ // owner 必须与写入侧(工具经 resolveLocalUserId 校验并写个人 owner)一致,
17230
+ // 否则工具成功写入后这里按机器 id 去查,永远召回不到。
17231
+ owner: { ownerType: "user", ownerId: resolveLocalUserId(input.env) },
17232
+ spaceId: input.spaceId ?? null,
17233
+ dialogId,
17234
+ ...trimmedUserInput ? { relatedQuery: trimmedUserInput } : {}
17235
+ });
17236
+ if (result.status === "error") {
17237
+ logDeduped(
17238
+ "warn",
17239
+ fingerprintFor("work-context-failed", result.error ? "read" : void 0),
17240
+ "work context recall failed, omitting work context block",
17241
+ normalizeError(result.error ?? "unknown")
17242
+ );
17243
+ return null;
17244
+ }
17245
+ return result.block;
17246
+ } catch (error) {
17247
+ if (input.signal?.aborted) throw error;
17248
+ logDeduped(
17249
+ "warn",
17250
+ fingerprintFor("work-context-failed", error instanceof Error ? error.name : void 0),
17251
+ "work context recall failed, omitting work context block",
17252
+ normalizeError(error)
17253
+ );
17254
+ return null;
17255
+ }
17256
+ };
16093
17257
 
16094
17258
  // packages/cli/agentRunCommand.ts
16095
17259
  function resolvePositiveMs(value, fallback) {
@@ -16145,22 +17309,32 @@ async function resolveAgentBoundMachineIdFromRecord(args) {
16145
17309
  return resolveBoundMachineId(record) || void 0;
16146
17310
  }
16147
17311
  async function runAgentRunCommand(args, deps) {
17312
+ if (args.includes("--help") || args.includes("-h")) {
17313
+ writeUsage(deps.output ?? process.stdout, deps.commandPath);
17314
+ return 0;
17315
+ }
16148
17316
  const env = deps.env ?? process.env;
16149
17317
  const runId = env.NOLO_AGENT_RUN_ID;
16150
17318
  const controlDeps = { env, homedir: deps.homedir, fs: deps.fs, now: deps.now };
16151
17319
  const failStartup = async (error) => {
16152
- if (!runId || readRunRecord(runId, controlDeps)?.status !== "running") return;
17320
+ if (!runId) return;
17321
+ const record = readRunRecord(runId, controlDeps);
17322
+ if (record?.status !== "running" || record.pid != null && record.pid !== process.pid) return;
16153
17323
  const result = await settleRunTerminalAuthoritatively(runId, {
16154
17324
  status: "failed",
16155
17325
  exitCode: 1,
16156
17326
  failureReason: error instanceof RuntimeProtocolMismatchError ? "runtime_protocol_mismatch" : error instanceof RuntimeVersionMismatchError ? "runtime_version_mismatch" : "startup_failed",
16157
17327
  note: error ? toErrorMessage(error) : "Child initialization returned without terminal result"
16158
- }, controlDeps, (id, update, d) => transitionRunToTerminal(id, update, d));
17328
+ }, controlDeps, (id, update, d, opts) => transitionRunToTerminal(id, update, d, {
17329
+ ...opts?.expectedPid != null ? { expectedPid: opts.expectedPid } : {}
17330
+ }), { expectedPid: process.pid });
16159
17331
  if (result.kind === "contended") throw new Error(`Startup settlement lock busy: ${runId}`);
16160
17332
  };
16161
17333
  try {
16162
17334
  if (runId) {
16163
- if (!readRunRecord(runId, controlDeps)) throw new Error("[local-writer-resource] missing child binding");
17335
+ const record = readRunRecord(runId, controlDeps);
17336
+ if (record?.pid != null && record.pid !== process.pid) throw new Error(`Run ${runId} belongs to PID ${record.pid}, not ${process.pid}`);
17337
+ if (!record) throw new Error("[local-writer-resource] missing child binding");
16164
17338
  await recordRunStartup(runId, "initializing", controlDeps);
16165
17339
  validateAgentRunProtocol(env.NOLO_AGENT_RUN_PROTOCOL);
16166
17340
  await recordRunStartup(runId, "protocol_validated", controlDeps);
@@ -16179,10 +17353,6 @@ async function runAgentRunCommandImpl(args, deps) {
16179
17353
  write: (chunk) => process.stdout.write(chunk),
16180
17354
  writeErr: (chunk) => process.stderr.write(chunk)
16181
17355
  };
16182
- if (args.includes("--help") || args.includes("-h")) {
16183
- writeUsage(output, deps.commandPath);
16184
- return 0;
16185
- }
16186
17356
  let parsed;
16187
17357
  try {
16188
17358
  parsed = parseAgentRunArgs(args, { commandPath: deps.commandPath });
@@ -16309,7 +17479,8 @@ async function runAgentRunCommandImpl(args, deps) {
16309
17479
  },
16310
17480
  { env, homedir: deps.homedir, fs: deps.fs, now: deps.now, sleep: deps.sleep },
16311
17481
  // Test seam: stubbed transitions keep their single-attempt semantics.
16312
- deps.transitionRunToTerminal
17482
+ deps.transitionRunToTerminal,
17483
+ { expectedPid: process.pid }
16313
17484
  );
16314
17485
  };
16315
17486
  if (armStallWatchdog) {
@@ -16552,7 +17723,8 @@ async function runAgentRunCommandImpl(args, deps) {
16552
17723
  fs: deps.fs,
16553
17724
  now: deps.now,
16554
17725
  generateRunId: deps.generateRunId,
16555
- shellApprovalHost: deps.shellApprovalHost
17726
+ shellApprovalHost: deps.shellApprovalHost,
17727
+ mcpApprovalHost: deps.mcpApprovalHost
16556
17728
  }
16557
17729
  );
16558
17730
  output.write(`[nolo] runId=${runId}
@@ -16605,6 +17777,16 @@ async function runAgentRunCommandImpl(args, deps) {
16605
17777
  console.warn("[cli-memory] memory recall failed, omitting memory layer:", memoryError);
16606
17778
  }
16607
17779
  }
17780
+ let workContextBlock = null;
17781
+ if (!deps.memoryRecallDisabled) {
17782
+ workContextBlock = await resolveCliWorkContext({
17783
+ env,
17784
+ dialogId: parsed.continueDialogId ?? null,
17785
+ spaceId: parsed.spaceId ?? null,
17786
+ // 本轮真实用户输入(不是历史摘要):跨 dialog 的近期关闭项只按它匹配。
17787
+ userInput: effectiveMessage
17788
+ });
17789
+ }
16608
17790
  memoryOverlayLayer = buildMemoryOverlayLayer({ promptBlock: memoryPromptBlock });
16609
17791
  memoryUseGuidanceLayer = buildMemoryUseGuidanceLayer({ promptBlock: memoryPromptBlock });
16610
17792
  contextBlockScopes.push(
@@ -16614,7 +17796,8 @@ async function runAgentRunCommandImpl(args, deps) {
16614
17796
  memoryUseGuidanceLayer
16615
17797
  ]),
16616
17798
  ...skillContentBlocks.map((content) => content.trim()).filter((content) => content.length > 0).map((content) => ({ content, cacheScope: "turn" })),
16617
- ...renderTurnContextBlocksWithScope([memoryOverlayLayer])
17799
+ ...renderTurnContextBlocksWithScope([memoryOverlayLayer]),
17800
+ ...workContextBlock ? [{ content: workContextBlock, cacheScope: "turn" }] : []
16618
17801
  ])
16619
17802
  );
16620
17803
  extraContextBlocks.push(...contextBlockScopes.map((block) => block.content));
@@ -16637,10 +17820,15 @@ async function runAgentRunCommandImpl(args, deps) {
16637
17820
  ),
16638
17821
  workflowReference
16639
17822
  );
17823
+ const mcpApprovalChild = process.connected && typeof process.send === "function" ? createMcpApprovalChild(process) : void 0;
16640
17824
  const shellApprovalChild = process.connected && typeof process.send === "function" ? createShellApprovalChild(process) : void 0;
16641
17825
  try {
16642
17826
  const imageUrls = await normalizeCliRunImages(parsed.imageUrls, normalizeCliImageInput);
16643
17827
  const buildRunOptions = (targetAgentKey, turnMessage = effectiveMessage) => ({
17828
+ ...mcpApprovalChild ? {
17829
+ mcpConfirmation: targetAgentKey === agentKey ? mcpApprovalChild.confirm : async () => "unavailable",
17830
+ mcpApprovalSignal: mcpApprovalChild.signal
17831
+ } : {},
16644
17832
  ...shellApprovalChild ? { execShellApproval: targetAgentKey === agentKey ? shellApprovalChild.authority : {
16645
17833
  request: async () => {
16646
17834
  throw new Error("Shell approval agent binding mismatch");
@@ -16856,7 +18044,8 @@ async function runAgentRunCommandImpl(args, deps) {
16856
18044
  try {
16857
18045
  dodResults = (deps.runDoDCommands ?? runDoDCommands)(
16858
18046
  childRecordForDoD?.dodCommands,
16859
- childRecordForDoD?.cwd
18047
+ childRecordForDoD?.cwd,
18048
+ { env }
16860
18049
  );
16861
18050
  } catch (dodError) {
16862
18051
  console.warn(`[nolo] DoD verification failed to run for ${childRunId}:`, dodError);
@@ -16889,7 +18078,7 @@ async function runAgentRunCommandImpl(args, deps) {
16889
18078
  acceptance.checks.observations = dodResults.map((check, index) => ({
16890
18079
  // Command lines/output can contain credentials. Persist only a digest
16891
18080
  // here; the pre-existing registry is the execution evidence reference.
16892
- commandFingerprint: `sha256:${createHash3("sha256").update(check.command).digest("hex")}`,
18081
+ commandFingerprint: `sha256:${createHash2("sha256").update(check.command).digest("hex")}`,
16893
18082
  cwd: childRecordForDoD?.cwd || process.cwd(),
16894
18083
  exitCode: check.exitCode,
16895
18084
  evidence: `${childRunId}.json#/dodResults/${index}`,
@@ -16931,7 +18120,8 @@ async function runAgentRunCommandImpl(args, deps) {
16931
18120
  now: deps.now,
16932
18121
  sleep: deps.sleep
16933
18122
  },
16934
- deps.transitionRunToTerminal
18123
+ deps.transitionRunToTerminal,
18124
+ { expectedPid: process.pid }
16935
18125
  );
16936
18126
  } catch (error) {
16937
18127
  terminalStatus.fail();
@@ -16953,16 +18143,25 @@ async function runAgentRunCommandImpl(args, deps) {
16953
18143
  terminalStatus.fail();
16954
18144
  throw error;
16955
18145
  } finally {
18146
+ mcpApprovalChild?.close();
16956
18147
  shellApprovalChild?.close();
16957
- if (shellApprovalChild && process.connected) process.disconnect();
18148
+ if ((shellApprovalChild || mcpApprovalChild) && process.connected) process.disconnect();
16958
18149
  }
16959
18150
  }
16960
18151
 
16961
18152
  export {
18153
+ resolveSurfacePaintWidth,
18154
+ resolveHistoryLayoutGeometry,
18155
+ resolveHistoryViewportHeight,
18156
+ getTopReservedRows,
18157
+ setTopReservedRows,
18158
+ resolveTopTaskEntryBudget,
18159
+ preferredTopTaskEntries,
16962
18160
  resolveAgentModelIdentity,
16963
18161
  resolveAgentContextWindow2 as resolveAgentContextWindow,
16964
18162
  platformCreditsFromUsage,
16965
18163
  formatCreditsChip,
18164
+ formatTokenCount,
16966
18165
  resolveAuthorityTurnCount,
16967
18166
  computeBaselineContextTokens,
16968
18167
  preserveContextUsageWithoutReceipt,
@@ -16971,6 +18170,7 @@ export {
16971
18170
  redactSecrets,
16972
18171
  resolveCliColorEnabled,
16973
18172
  dimCliText,
18173
+ resolveCliHyperlinkEnabled,
16974
18174
  THEME_PALETTES,
16975
18175
  getActiveThemeName,
16976
18176
  setActiveThemeName,
@@ -16978,42 +18178,44 @@ export {
16978
18178
  setActiveThemeMode,
16979
18179
  setActiveBrightness,
16980
18180
  detectSystemBrightnessFromEnv,
16981
- resolveTuiBrightnessSignal,
16982
18181
  resolveTuiThemeMode,
16983
18182
  themeColorSequence,
16984
18183
  resetWorkspaceThemeState,
16985
18184
  applyDetectedBackground,
16986
18185
  renderSurfaceLine,
16987
18186
  surfaceBackgroundSequence,
16988
- composerSurfaceBackgroundSequence,
16989
- userSurfaceBackgroundSequence,
16990
18187
  themeText,
16991
18188
  tuiRenderThemeFingerprint,
18189
+ MAX_URL_LENGTH,
18190
+ normalizeHttpUrl,
18191
+ openExternalUrl,
16992
18192
  setMathRenderingEnabled,
16993
18193
  polishBreathInsertsBlankBetween,
16994
18194
  formatAssistantDisplay,
16995
- resolveHistoryLayoutGeometry,
16996
- resolveHistoryViewportHeight,
16997
18195
  safeAskText,
18196
+ safeApprovalSingleLineText,
16998
18197
  safeApprovalMultilineText,
16999
18198
  TUI_TREE_MARKER,
17000
18199
  TUI_TREE_TOOLS,
17001
- createIdleHeapReleaser,
18200
+ toolRowDetailLine,
17002
18201
  COLLAPSED_PASTE_PLACEHOLDER_RE,
17003
18202
  shouldCollapsePaste,
17004
18203
  createCollapsedPasteStore,
17005
18204
  allocateCollapsedPaste,
17006
18205
  releaseCollapsedPaste,
17007
18206
  clearCollapsedPasteStore,
18207
+ expandCollapsedPastes,
17008
18208
  replaceCollapsedPastesWithReferences,
17009
18209
  releaseCollapsedPasteReferences,
17010
18210
  expandRangeToCollapsedPasteChips,
17011
18211
  findCollapsedPasteSpanAt,
18212
+ createIdleHeapReleaser,
17012
18213
  emitTerminalProgramStatus,
17013
18214
  contextRefusalDiagnostics,
17014
18215
  describeContextRefusal,
17015
18216
  inspectLocalRunWorkspace,
17016
18217
  isBalanceExhaustedError,
18218
+ isAuthFailureError,
17017
18219
  OWNER_OAUTH_UNAVAILABLE_HINT,
17018
18220
  isOwnerOAuthUnavailableError,
17019
18221
  isInvalidGrantError,
@@ -17026,6 +18228,7 @@ export {
17026
18228
  normalizeCliImageInput,
17027
18229
  buildHostEnvironmentLayer,
17028
18230
  resolveCliMemory,
18231
+ resolveCliWorkContext,
17029
18232
  FAILED_EMPTY_ASSISTANT_REASONS,
17030
18233
  isRunResultStalledOrTruncated,
17031
18234
  resolveTerminalProgramStatusState,