nolo-cli 0.228.0 → 0.228.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/{_executeModel-GIFVXKDT.js → _executeModel-AKCTHGMP.js} +62 -61
  2. package/{action-WZTKEF5H.js → action-C6IQAKN4.js} +6 -6
  3. package/{addContentAction-MLI6GOBV.js → addContentAction-53364YDW.js} +10 -10
  4. package/{addDialogAgentAction-ARGQM22H.js → addDialogAgentAction-U5DD5EN5.js} +9 -9
  5. package/{agentDeleteCommand-UF7XVELS.js → agentDeleteCommand-2E5FAGUO.js} +99 -93
  6. package/{agentEmailCommands-SFHRPQYC.js → agentEmailCommands-UGZZAH7E.js} +99 -93
  7. package/{agentListCommands-IXKBP3W5.js → agentListCommands-JCTW3J2K.js} +240 -52
  8. package/{agentMachineCommands-7NX6PWQ6.js → agentMachineCommands-QPG5ZXF4.js} +45 -41
  9. package/{agentProviderCommands-C5T7C5KZ.js → agentProviderCommands-QLTABYR7.js} +2 -2
  10. package/{agentPullCommand-4EQZYHU4.js → agentPullCommand-2EYJ5ENC.js} +1 -1
  11. package/{agentRecordCommands-IUNX6XD6.js → agentRecordCommands-4NTVR6MZ.js} +98 -92
  12. package/{agentRunCommand-LCR4XADM.js → agentRunCommand-VHF34PYC.js} +103 -94
  13. package/{agentRunControl-RN2P6AOD.js → agentRunControl-QYTXUQGY.js} +10 -7
  14. package/{agentRuntimeLocal-LVXPQ7QA.js → agentRuntimeLocal-U54AKHXH.js} +38 -36
  15. package/{agentSlice-ZGMOH6TE.js → agentSlice-4JGDEXWK.js} +10 -10
  16. package/{appDeleteCommands-BESCJOQM.js → appDeleteCommands-XBE5QJ6P.js} +46 -42
  17. package/{appDeployCommands-LPTR6IOX.js → appDeployCommands-QIYLXXGA.js} +46 -42
  18. package/{appDeployStatusCommands-BZ7KZ5RD.js → appDeployStatusCommands-JXS6ZQZZ.js} +46 -42
  19. package/{appGetCommands-EDWGJV4S.js → appGetCommands-SZS7SJPK.js} +46 -42
  20. package/{appListCommands-OPRWYPM6.js → appListCommands-B3GBJSNV.js} +46 -42
  21. package/{authCommand-3C3RN4OU.js → authCommand-V6EOMZX6.js} +15 -15
  22. package/{authCommands-ZMVEDCQD.js → authCommands-T5FODCEG.js} +2 -2
  23. package/{builtinSkillRegistry-VRCMQ77Q.js → builtinSkillRegistry-ZQC3IIO2.js} +4 -3
  24. package/{chromeOpsCommands-NZITLHWO.js → chromeOpsCommands-OFX7ZGKP.js} +2 -2
  25. package/{chunk-MZVCFV3T.js → chunk-223KZUJ6.js} +4 -4
  26. package/{chunk-UF6J7NXV.js → chunk-2C5VN7NH.js} +1 -1
  27. package/{chunk-MAA42MMV.js → chunk-2FZVXOFX.js} +4 -4
  28. package/{chunk-ESN4WNWU.js → chunk-2JHGUL5K.js} +2 -2
  29. package/chunk-3A5NNQCN.js +64 -0
  30. package/chunk-3F2FRLIO.js +372 -0
  31. package/{chunk-V4IYI3SB.js → chunk-46FETNLF.js} +2 -2
  32. package/{chunk-RR3MB26M.js → chunk-4GYVS4PM.js} +8 -6
  33. package/{chunk-ZQ6K57FJ.js → chunk-4YPH5KRA.js} +1 -1
  34. package/{chunk-Y4NPF2UN.js → chunk-5AYP5QBB.js} +5 -5
  35. package/{chunk-4OXPN3WC.js → chunk-5ISNPTQH.js} +4 -4
  36. package/{chunk-CO6E7YK6.js → chunk-5P3PPQVP.js} +1 -1
  37. package/{chunk-6TVYUQRM.js → chunk-6BMTKYAO.js} +2 -2
  38. package/{chunk-KLAMJNKQ.js → chunk-6PAHSSD2.js} +15 -8
  39. package/{chunk-CTWCZKNS.js → chunk-6SOWMEAY.js} +4 -4
  40. package/{chunk-ARFCL53U.js → chunk-6VEO7Z3Y.js} +5 -5
  41. package/{chunk-ZM5AZTQG.js → chunk-7BIJFGKS.js} +20 -8
  42. package/{chunk-BAH3BAUZ.js → chunk-7OVOZRZF.js} +5 -5
  43. package/{chunk-N74XL3NI.js → chunk-7PON4LBY.js} +42 -24
  44. package/{chunk-LTVEOOZL.js → chunk-7WHCIA5V.js} +16 -3
  45. package/{chunk-HZDK56EK.js → chunk-ADYWV732.js} +34 -12
  46. package/{chunk-2FK2KZSL.js → chunk-AIFQKNPP.js} +1 -1
  47. package/{chunk-VTHWBTRE.js → chunk-BPB3T5EU.js} +5 -8
  48. package/{chunk-SX6AWTNK.js → chunk-BZLGPM5B.js} +3 -3
  49. package/{chunk-MTM4LRVG.js → chunk-BZMDWGQQ.js} +2 -2
  50. package/{chunk-JP2BH4NC.js → chunk-CEKRIR22.js} +1 -1
  51. package/{chunk-5HUO7SEX.js → chunk-D634SL2Y.js} +1 -1
  52. package/{chunk-SCMYAGQE.js → chunk-DHRPLRIR.js} +294 -159
  53. package/{chunk-VUHKG4KS.js → chunk-DNNPARJK.js} +9 -5
  54. package/{chunk-X22AUZKL.js → chunk-E3LSO6EI.js} +189 -88
  55. package/{chunk-LHCGKAFO.js → chunk-EHFBP6IK.js} +100 -48
  56. package/{chunk-6ASGEP5D.js → chunk-EJQE5HB7.js} +1 -1
  57. package/{chunk-2BKNICGK.js → chunk-EL5NRJHI.js} +1 -1
  58. package/chunk-EUGTFFO6.js +42 -0
  59. package/{chunk-YFW4H6DL.js → chunk-EVHTYVD2.js} +821 -131
  60. package/{chunk-6XRPBZRS.js → chunk-EYLGAEB4.js} +0 -134
  61. package/{chunk-E5RYFR7E.js → chunk-FEIVARWR.js} +49 -15
  62. package/{chunk-3DJJ4CFG.js → chunk-FLBJ7IJI.js} +9 -9
  63. package/{chunk-W3HSD32M.js → chunk-FXEPZKNJ.js} +2 -2
  64. package/{chunk-VKCPKCSS.js → chunk-FYAMUU55.js} +625 -62
  65. package/{chunk-JEWMQR6J.js → chunk-FZANZZ63.js} +1 -1
  66. package/{chunk-WWTSEBDF.js → chunk-GIXWVN2W.js} +1 -1
  67. package/{chunk-YHNUDTU4.js → chunk-HDKMVYNJ.js} +4 -4
  68. package/chunk-HEVRQGGH.js +106 -0
  69. package/{chunk-PBPXXMWZ.js → chunk-HFHJPHFK.js} +1 -1
  70. package/{chunk-WQDTSK5U.js → chunk-HPDLPEUG.js} +11 -5
  71. package/{chunk-SPU3L3OR.js → chunk-HQUGB2HM.js} +3 -3
  72. package/chunk-IVK2KT3H.js +209 -0
  73. package/{chunk-73PZD7JZ.js → chunk-IYLUK67R.js} +2 -2
  74. package/{chunk-BFKJ2RS3.js → chunk-J55F3IEZ.js} +1 -1
  75. package/{chunk-ADOOL3PG.js → chunk-J7JRCOIW.js} +1 -1
  76. package/{chunk-AEZBAFC6.js → chunk-JAKRY74O.js} +138 -8
  77. package/{chunk-NEG5LYK5.js → chunk-JCQ3WCQ3.js} +3 -1
  78. package/{chunk-W6T4FNZP.js → chunk-JLZJL3WC.js} +219 -351
  79. package/{chunk-PQ63BDV3.js → chunk-JPXACKSW.js} +9 -1
  80. package/{chunk-IIOSZAJX.js → chunk-KDBDOXOM.js} +137 -53
  81. package/{chunk-CIGCTSBF.js → chunk-KDDHQMSH.js} +1 -1
  82. package/{chunk-OAZP4TSA.js → chunk-KG27JIG4.js} +2 -2
  83. package/{chunk-RHBD22LV.js → chunk-KHYSFS3W.js} +80 -4
  84. package/{chunk-7UVVLYKC.js → chunk-KKIQAVDR.js} +5 -5
  85. package/{chunk-HS7MLR74.js → chunk-KZ4A7EIV.js} +3 -5
  86. package/{chunk-OLGFIQN2.js → chunk-LLUBUHNT.js} +1 -1
  87. package/{chunk-QJTZ76CP.js → chunk-LS5KAVFQ.js} +1 -0
  88. package/{chunk-K26XPZRB.js → chunk-LVZVSLKO.js} +29 -9
  89. package/{chunk-XJSEST7D.js → chunk-MNFUKRRU.js} +3 -3
  90. package/{chunk-R5NRFXGD.js → chunk-O3A2CHAL.js} +5 -5
  91. package/{chunk-4IQN6FWY.js → chunk-OB4FBZXJ.js} +4 -4
  92. package/{chunk-J2VIGDJN.js → chunk-OJSJJKHF.js} +3 -3
  93. package/{chunk-OHUYN3YU.js → chunk-OKAXQFON.js} +1 -1
  94. package/{chunk-CD2DK5JA.js → chunk-OKH74FML.js} +2 -1
  95. package/{chunk-MYYNZG2M.js → chunk-OOV5JN25.js} +4 -4
  96. package/{chunk-TMRJGSK2.js → chunk-OOVOAG4Q.js} +1 -1
  97. package/chunk-OQFOE4SJ.js +405 -0
  98. package/{chunk-AS6L5KSD.js → chunk-P4R5KXU7.js} +2 -2
  99. package/{chunk-VIYVRPMJ.js → chunk-PHREU2KZ.js} +5 -3
  100. package/{chunk-EDT65EUE.js → chunk-PIVTQRX6.js} +45 -15
  101. package/{chunk-QMNVV3YM.js → chunk-PJL7OJRC.js} +12 -11
  102. package/{chunk-XCA4WHX5.js → chunk-PNLDLUMO.js} +315 -360
  103. package/{chunk-UPOW5HTG.js → chunk-QGFLVQ6E.js} +3 -3
  104. package/{chunk-JU7VN4LF.js → chunk-QONAOHVW.js} +6 -6
  105. package/{chunk-UOUMPHS5.js → chunk-R3FZHW4Q.js} +13 -13
  106. package/{chunk-K7VIXYTZ.js → chunk-R3MV2GII.js} +1 -45
  107. package/{chunk-FE7G6DSP.js → chunk-R72QWIFO.js} +14 -4
  108. package/{chunk-KZAT2M2V.js → chunk-RIWKZT7E.js} +22 -0
  109. package/{chunk-RMWDKLBE.js → chunk-S7H4KTMB.js} +1099 -71
  110. package/{chunk-IJZC2KIJ.js → chunk-SA356NGW.js} +1 -1
  111. package/{chunk-BVEDT6DM.js → chunk-SCAC3NM5.js} +3 -3
  112. package/{chunk-EQZQUQ33.js → chunk-SLUN7W6S.js} +5 -5
  113. package/{chunk-KK3FCYZM.js → chunk-SQL7YNED.js} +7 -4
  114. package/{chunk-LMGFVH65.js → chunk-SSOR2EDT.js} +10 -10
  115. package/chunk-TRRXYFTR.js +46 -0
  116. package/{chunk-XNTZD4AE.js → chunk-TUOHSUK5.js} +19367 -17503
  117. package/chunk-TYJCIA2O.js +835 -0
  118. package/{chunk-FTWAOKFU.js → chunk-U3BUWDUP.js} +415 -1962
  119. package/{chunk-CD64YXRB.js → chunk-U6QNVOR5.js} +1 -1
  120. package/chunk-UAF5VQCE.js +77 -0
  121. package/{chunk-CIUZXD5D.js → chunk-UFGUJ2IH.js} +5 -5
  122. package/{chunk-CTIEJRTP.js → chunk-UP7KBWLE.js} +81 -29
  123. package/{chunk-GX6DITLQ.js → chunk-UUCYUN6Y.js} +1 -1
  124. package/{chunk-UHW6SCVK.js → chunk-UZKBVQUX.js} +1 -1
  125. package/{chunk-XSRSAU3O.js → chunk-V5TI7HJH.js} +3 -3
  126. package/{chunk-WFGNWWJI.js → chunk-VH7UO6E5.js} +252 -114
  127. package/{chunk-ITBX27W6.js → chunk-VJFDG3ZG.js} +30 -122
  128. package/{chunk-6MTVACLN.js → chunk-WC3J5SL2.js} +277 -293
  129. package/{chunk-HCCQEMTK.js → chunk-WD5547ZF.js} +15 -12
  130. package/{chunk-X3OZ655T.js → chunk-WS36XPJD.js} +2 -2
  131. package/{chunk-JFRJEPFI.js → chunk-WSLL7VV4.js} +2 -2
  132. package/chunk-XRGBJHZX.js +136 -0
  133. package/{chunk-KZ5OD2MO.js → chunk-Y2KWJTOZ.js} +3 -3
  134. package/{dialogUsageCommand-6RW2FY6K.js → chunk-Y2TCTNUD.js} +24 -17
  135. package/{chunk-FFFKAOJN.js → chunk-YN23INFZ.js} +1 -1
  136. package/{chunk-ODBYGVO2.js → chunk-YXK3GJF5.js} +5 -5
  137. package/{chunk-6CXQ3YNJ.js → chunk-Z2OWAYMI.js} +53 -31
  138. package/{chunk-6XVPMGXK.js → chunk-ZTHAJU3O.js} +10 -4
  139. package/{chunk-D25ONVOH.js → chunk-ZYPXOQS2.js} +1 -1
  140. package/{cliAgentConfigHelpers-37ZNEY5Y.js → cliAgentConfigHelpers-BXHQ3PXP.js} +8 -8
  141. package/{cliAuthorityBrokerClient-SFPC3WVK.js → cliAuthorityBrokerClient-TFNXJLXL.js} +1 -1
  142. package/cliAuthorityBrokerProcess-5ZFBTHLB.js +22 -0
  143. package/{cliLocalAgentRecordReader-MCQVRWBR.js → cliLocalAgentRecordReader-47PXMHPH.js} +43 -41
  144. package/{commandRegistry-NTH5IAN5.js → commandRegistry-CTMPAQH2.js} +93 -156
  145. package/{contentThunks-SPXTX5U2.js → contentThunks-CAHIIZO5.js} +25 -25
  146. package/{cooldownCommands-TIFCHCUN.js → cooldownCommands-WDOI5VD7.js} +3 -3
  147. package/{createAgentAutomationAction-KUQKCOXB.js → createAgentAutomationAction-M25XZSPD.js} +25 -25
  148. package/{createDialogAction-HJN5U3XS.js → createDialogAction-4SN7FKI7.js} +26 -26
  149. package/{createPageAction-ZAHRDOAU.js → createPageAction-N7QPDN3M.js} +28 -28
  150. package/{db-CMUTP3W5.js → db-VR74ADGC.js} +7 -2
  151. package/{dbSlice-656PMWR2.js → dbSlice-RWPSVHBC.js} +9 -9
  152. package/{deleteFile-ZCQESEEQ.js → deleteFile-ECU6FU5C.js} +12 -7
  153. package/{dialogCommands-KZTZLWPZ.js → dialogCommands-BBHWCKDP.js} +57 -47
  154. package/{dialogNotifyCommand-PST75COP.js → dialogNotifyCommand-IASQGEMW.js} +9 -9
  155. package/{dialogSlice-BXIERQHO.js → dialogSlice-JI3J22RV.js} +23 -23
  156. package/dialogTraceCommand-EW2KK6A4.js +961 -0
  157. package/dialogUsageCommand-WJ3U6KZU.js +27 -0
  158. package/{docCreateCommands-26HJ5NAY.js → docCreateCommands-QSX3X5U4.js} +45 -41
  159. package/{docDeleteCommands-UAOHH5XK.js → docDeleteCommands-63JBG2HQ.js} +46 -42
  160. package/{docReadCommands-4ADG7YE6.js → docReadCommands-CQFKRQUI.js} +45 -41
  161. package/{docStore-FZ75HWP2.js → docStore-XLBKGGNM.js} +10 -10
  162. package/{docUpdateCommands-OGFJZENF.js → docUpdateCommands-534LUK25.js} +45 -41
  163. package/ebookDownloaderAgentCommand-DYSKF5ZY.js +677 -0
  164. package/{getPricing-FCHYVRJU.js → getPricing-5BLZRPTM.js} +3 -3
  165. package/{handleSendMessageAction-KP6GGBFY.js → handleSendMessageAction-Q2VMEVOR.js} +90 -48
  166. package/{hostCredentialCreate-23TX56G7.js → hostCredentialCreate-C57T7YPE.js} +99 -93
  167. package/index.js +23 -11
  168. package/{localDialogRead-CIOTQM5T.js → localDialogRead-BJJT3TF5.js} +1 -1
  169. package/{localRuntimeAdapter-MTUWOYPN.js → localRuntimeAdapter-OALZPFZU.js} +96 -90
  170. package/{localRuntimeAuthority-TYHQCTZN.js → localRuntimeAuthority-UF2DAQ3F.js} +13 -3
  171. package/{localRuntimeDb-BO7IVWAZ.js → localRuntimeDb-ZJFGNHML.js} +1 -1
  172. package/{machineCommands-4WJUJQHW.js → machineCommands-N6IVWRZT.js} +109 -92
  173. package/{machineWsRunDispatch-V3U4JM67.js → machineWsRunDispatch-PDWYB33B.js} +97 -91
  174. package/{markdownToSlate-KIYM7B3P.js → markdownToSlate-PXYAIBVL.js} +1 -1
  175. package/{mcpLocalAuthorizeCommand-TI656UWC.js → mcpLocalAuthorizeCommand-KYI4EGF5.js} +17 -13
  176. package/{memberThunks-JFYC4Z5L.js → memberThunks-43B7UYC5.js} +11 -11
  177. package/{models-EP7VG6N2.js → models-ZX2BYIMB.js} +2 -2
  178. package/package.json +2 -1
  179. package/{projectArchive-NU2Z5HOR.js → projectArchive-TJNW5DLM.js} +28 -28
  180. package/{providerPresetApply-4H7YP5D7.js → providerPresetApply-NTJUINI6.js} +35 -16
  181. package/{providerRegistry-F3UPOTIY.js → providerRegistry-W45SLUV6.js} +5 -5
  182. package/{read-BRZHXUJ6.js → read-KG6INYUT.js} +12 -7
  183. package/{readDocTool-N7RVFQEE.js → readDocTool-N3GA52JR.js} +1 -1
  184. package/{readlineWorkspace-T56MRMS5.js → readlineWorkspace-PJZJVGA5.js} +1296 -1056
  185. package/{removeDialogAgentAction-J7XU7OUX.js → removeDialogAgentAction-EEVSOQOJ.js} +11 -11
  186. package/{runAgentClientLoop-O2GRCGRZ.js → runAgentClientLoop-3VC5TCDW.js} +69 -58
  187. package/{runtimeDoctorCommands-RDRJXMXC.js → runtimeDoctorCommands-V3M3JTUV.js} +14 -11
  188. package/{secretCommands-2FEMRUFM.js → secretCommands-KVVZS7A6.js} +2 -2
  189. package/{setDialogExtraReferencesAction-Q4V2ZZW2.js → setDialogExtraReferencesAction-DNO5POHA.js} +10 -10
  190. package/{setPrimaryDialogAgentAction-742H5S6T.js → setPrimaryDialogAgentAction-QABBEO4C.js} +11 -11
  191. package/{settingThunks-T4FXSV6M.js → settingThunks-DVKG4X4S.js} +13 -17
  192. package/{skillDiscovery-MDDKPTW3.js → skillDiscovery-ZMJH36AK.js} +3 -3
  193. package/{spaceCommands-W5TAVFDT.js → spaceCommands-AGGZXPY3.js} +218 -77
  194. package/{streamAgentChatTurn-OWDJMU5E.js → streamAgentChatTurn-4GTLL2OF.js} +111 -95
  195. package/{switchDialogAgentAction-HLDLHRRA.js → switchDialogAgentAction-KYWJSGOO.js} +9 -9
  196. package/{tableCommands-44GC4N6J.js → tableCommands-EFA754RE.js} +3 -3
  197. package/{tools-O7SGGVA3.js → tools-5AGPOPLW.js} +48 -47
  198. package/{tuiRestart-EOGC2BYY.js → tuiRestart-77E7PL4R.js} +9 -8
  199. package/{tuiSummaryLlmCaller-TM5BU73J.js → tuiSummaryLlmCaller-HROLGN4F.js} +12 -12
  200. package/{updateCommands-FBYA5WVG.js → updateCommands-GJGRS6JK.js} +3 -3
  201. package/{updateDialogTitleAction-EXSZGTLL.js → updateDialogTitleAction-5OSEDGRK.js} +25 -25
  202. package/{usageCommand-L4OFWXEU.js → usageCommand-WI6SQOPB.js} +2 -2
  203. package/{usageRebuildCommand-7JR33UHS.js → usageRebuildCommand-WQRLLZAT.js} +3 -3
  204. package/{windowsSelfUpdate-M4V77OUB.js → windowsSelfUpdate-C7LGVWYX.js} +2 -2
  205. package/{workloadLifecycle-ZCSQCHG3.js → workloadLifecycle-P2SJVV3S.js} +2 -2
  206. package/chunk-FGHEF6WI.js +0 -34
  207. package/chunk-U5LOKQ2R.js +0 -176
  208. package/chunk-YDRRGVT5.js +0 -142
  209. package/chunk-YGDYYFRX.js +0 -86
  210. package/chunk-Z7KE4K3H.js +0 -758
  211. package/lib-62SWPXNF.js +0 -21042
  212. /package/{chunk-ANUP75N2.js → chunk-2E4BYAUE.js} +0 -0
@@ -6,9 +6,19 @@ import {
6
6
  resolvePureVNextRuntime,
7
7
  touchMemoryItemsInDb
8
8
  } from "./chunk-GAHJLSDO.js";
9
+ import {
10
+ listFavoriteAgentIdsAcrossServers,
11
+ listLocalCachedAgents,
12
+ listRemoteAgents,
13
+ listRemoteAgentsAcrossServers,
14
+ normalizeListedAgent
15
+ } from "./chunk-5AYP5QBB.js";
16
+ import {
17
+ refreshSubscriptionQuotas
18
+ } from "./chunk-P27E22MA.js";
9
19
  import {
10
20
  getReadableCliDb
11
- } from "./chunk-D25ONVOH.js";
21
+ } from "./chunk-ZYPXOQS2.js";
12
22
  import {
13
23
  INSTABOX_RUN_CONFIG_ENV,
14
24
  buildLocalRunEnv,
@@ -30,10 +40,10 @@ import {
30
40
  resolveBoundMachineId,
31
41
  resolveFileWriteGateEnabled,
32
42
  resolveRawAgentInput,
33
- resolveServerUrl,
43
+ resolveServerUrl as resolveServerUrl2,
34
44
  validateInstaboxWorkspaceSelection,
35
45
  writeUsage
36
- } from "./chunk-SCMYAGQE.js";
46
+ } from "./chunk-DHRPLRIR.js";
37
47
  import {
38
48
  boxGlyphs,
39
49
  displayWidth,
@@ -43,11 +53,11 @@ import {
43
53
  stripAnsi,
44
54
  tokenizeAnsiLine,
45
55
  visibleWidth
46
- } from "./chunk-6TVYUQRM.js";
56
+ } from "./chunk-6BMTKYAO.js";
47
57
  import {
48
58
  clearCredentialAvailability,
49
59
  readEffectiveCredentialEntry
50
- } from "./chunk-WWTSEBDF.js";
60
+ } from "./chunk-GIXWVN2W.js";
51
61
  import {
52
62
  rankMemoryCandidates,
53
63
  recallMemoryVNextLocal
@@ -84,16 +94,19 @@ import {
84
94
  import {
85
95
  resolveMachineId
86
96
  } from "./chunk-S73EPYNC.js";
87
- import {
88
- resolveCliLocalRuntimeKeyCapability
89
- } from "./chunk-FTWAOKFU.js";
90
97
  import {
91
98
  extractGoogleValidationLink
92
99
  } from "./chunk-BMQ2MJUK.js";
100
+ import {
101
+ resolveCliLocalRuntimeKeyCapability
102
+ } from "./chunk-U3BUWDUP.js";
103
+ import {
104
+ isCallerAtFreePoolTop
105
+ } from "./chunk-3F2FRLIO.js";
93
106
  import {
94
107
  parseUiCard,
95
108
  uiCardFallback
96
- } from "./chunk-LMGFVH65.js";
109
+ } from "./chunk-SSOR2EDT.js";
97
110
  import {
98
111
  isGatewayHttpStatus
99
112
  } from "./chunk-NF64D32W.js";
@@ -104,7 +117,7 @@ import {
104
117
  loadOwnerItemsFromDb,
105
118
  parseUiAskChoiceContent,
106
119
  resolveAgentMemoryPolicy
107
- } from "./chunk-ODBYGVO2.js";
120
+ } from "./chunk-YXK3GJF5.js";
108
121
  import {
109
122
  API_REPORTED_COST_MULTIPLIER,
110
123
  estimateMessagesTokens,
@@ -113,14 +126,26 @@ import {
113
126
  resolveAgentContextWindow,
114
127
  resolveOccupancy,
115
128
  resolveOccupancyWindow
116
- } from "./chunk-YFW4H6DL.js";
129
+ } from "./chunk-EVHTYVD2.js";
130
+ import {
131
+ getDefaultCliLocalRuntimeDb
132
+ } from "./chunk-J55F3IEZ.js";
117
133
  import {
118
134
  parsePositiveFiniteNumberOrFallback
119
135
  } from "./chunk-Y5GCAMGP.js";
120
136
  import {
137
+ readLiveDbRecordAfterTombstoneMerge
138
+ } from "./chunk-FZANZZ63.js";
139
+ import {
140
+ queryUserRecords,
121
141
  readDbRecord,
122
142
  resolveAgentRecordFromHybridStore
123
- } from "./chunk-CIUZXD5D.js";
143
+ } from "./chunk-UFGUJ2IH.js";
144
+ import {
145
+ isPlatformPaidAgentCall,
146
+ resolveEffectiveReasoningEffortOverride,
147
+ withReasoningEffortOverride
148
+ } from "./chunk-PNLDLUMO.js";
124
149
  import {
125
150
  isTransientFetchError
126
151
  } from "./chunk-DXWGFL2Z.js";
@@ -144,7 +169,7 @@ import {
144
169
  settleRunTerminalAuthoritatively,
145
170
  spawnLocalBackgroundRun,
146
171
  transitionRunToTerminal
147
- } from "./chunk-AEZBAFC6.js";
172
+ } from "./chunk-JAKRY74O.js";
148
173
  import {
149
174
  formatAgentListCard,
150
175
  formatFinishedRunCard,
@@ -158,15 +183,12 @@ import {
158
183
  } from "./chunk-S25VJYXV.js";
159
184
  import {
160
185
  buildSkillDiscoveryContextLayer
161
- } from "./chunk-UHW6SCVK.js";
186
+ } from "./chunk-UZKBVQUX.js";
162
187
  import {
163
188
  isCliAuthorityBrokerProtocolError,
164
189
  isCliAuthorityBrokerTimeoutError,
165
190
  isCliAuthorityBrokerUnavailableError
166
- } from "./chunk-KK3FCYZM.js";
167
- import {
168
- getDefaultCliLocalRuntimeDb
169
- } from "./chunk-BFKJ2RS3.js";
191
+ } from "./chunk-SQL7YNED.js";
170
192
  import {
171
193
  LOCAL_AGENT_CONFIG_MISSING_CODE,
172
194
  LOCAL_TURN_ABORTED_CODE,
@@ -178,10 +200,13 @@ import {
178
200
  readActionGate,
179
201
  readAgentsMdLayerFromDisk,
180
202
  registerDialogOwner
181
- } from "./chunk-XNTZD4AE.js";
203
+ } from "./chunk-TUOHSUK5.js";
182
204
  import {
183
205
  resolveAgentRuntimeConfigFromRecord
184
- } from "./chunk-4OXPN3WC.js";
206
+ } from "./chunk-5ISNPTQH.js";
207
+ import {
208
+ resolveAgentImageInputSupport
209
+ } from "./chunk-BZLGPM5B.js";
185
210
  import {
186
211
  createThinkParserState,
187
212
  flushThinkParser,
@@ -189,14 +214,12 @@ import {
189
214
  } from "./chunk-56GBUMO5.js";
190
215
  import {
191
216
  classifyFailureSubclass,
217
+ formatQuotaSummary,
192
218
  isCapacitySaturatedRateLimit,
193
219
  isQuotaExhaustedText,
194
220
  resolveAvailabilityAction,
195
221
  resolveCredentialKeyWithFallback
196
- } from "./chunk-QJTZ76CP.js";
197
- import {
198
- resolveAgentImageInputSupport
199
- } from "./chunk-SX6AWTNK.js";
222
+ } from "./chunk-LS5KAVFQ.js";
200
223
  import {
201
224
  isContextOverflowText
202
225
  } from "./chunk-TLE77UJ5.js";
@@ -205,12 +228,12 @@ import {
205
228
  ATTACHMENT_PART_VERSION,
206
229
  describeAttachmentForModel,
207
230
  normalizeAttachmentPart
208
- } from "./chunk-LTVEOOZL.js";
231
+ } from "./chunk-7WHCIA5V.js";
209
232
  import {
210
233
  findCodexOAuthPinnedContextWindow,
211
234
  normalizeUsage,
212
235
  readCacheReadInputTokensOrNull
213
- } from "./chunk-MAA42MMV.js";
236
+ } from "./chunk-2FZVXOFX.js";
214
237
  import {
215
238
  isOAuthApiKeyRef
216
239
  } from "./chunk-UKZX3NHN.js";
@@ -223,7 +246,7 @@ import {
223
246
  } from "./chunk-USGHJSGO.js";
224
247
  import {
225
248
  workspaceChildEnv
226
- } from "./chunk-CTIEJRTP.js";
249
+ } from "./chunk-UP7KBWLE.js";
227
250
  import {
228
251
  QUOTA_ERROR_PATTERNS,
229
252
  isQuotaExhaustedError
@@ -239,7 +262,7 @@ import {
239
262
  buildMemoryUseGuidanceLayer,
240
263
  partitionScopedBlocks,
241
264
  renderTurnContextBlocksWithScope
242
- } from "./chunk-5HUO7SEX.js";
265
+ } from "./chunk-D634SL2Y.js";
243
266
  import {
244
267
  isTombstoneRecord
245
268
  } from "./chunk-BV3FLP2L.js";
@@ -255,28 +278,35 @@ import {
255
278
  import {
256
279
  isBuiltinNoloAgentRef,
257
280
  resolveLocalUserId
258
- } from "./chunk-UPOW5HTG.js";
281
+ } from "./chunk-QGFLVQ6E.js";
259
282
  import {
283
+ NOLO_DEFAULT_AGENT_KEY,
260
284
  isLocalCliAgentKey
261
285
  } from "./chunk-BR3GT6MR.js";
262
286
  import {
263
287
  BUILTIN_NOLO_AGENT_KEY,
288
+ BUILTIN_NOLO_AGENT_MODEL,
264
289
  BUILTIN_NOLO_AGENT_NAME,
265
290
  builtinAgentCatalogEntryById,
266
291
  parseBuiltinPlatformAgentId
267
- } from "./chunk-KZAT2M2V.js";
292
+ } from "./chunk-RIWKZT7E.js";
268
293
  import {
269
294
  parsePublicAgentId
270
295
  } from "./chunk-M2EJHDJP.js";
271
296
  import {
272
- exitCliFromWatchdog,
297
+ exitCliFromWatchdog
298
+ } from "./chunk-XRGBJHZX.js";
299
+ import {
273
300
  getLogger,
274
301
  normalizeError
275
- } from "./chunk-6XRPBZRS.js";
302
+ } from "./chunk-EYLGAEB4.js";
276
303
  import {
277
304
  RuntimeProtocolMismatchError,
278
305
  RuntimeVersionMismatchError,
306
+ parseUserIdFromAuthToken,
279
307
  resolveAuthToken,
308
+ resolveServerCandidates,
309
+ resolveServerUrl,
280
310
  validateAgentRunProtocol
281
311
  } from "./chunk-BIDSIRTS.js";
282
312
  import {
@@ -293,22 +323,22 @@ import {
293
323
  toolIcon,
294
324
  toolLabel,
295
325
  toolLabelVariants
296
- } from "./chunk-E5RYFR7E.js";
326
+ } from "./chunk-FEIVARWR.js";
297
327
  import {
298
328
  isAntigravityOAuthAgent
299
- } from "./chunk-CTWCZKNS.js";
329
+ } from "./chunk-6SOWMEAY.js";
300
330
  import {
301
331
  toErrorMessage
302
332
  } from "./chunk-HNMXYYJR.js";
303
333
  import {
304
334
  resolveClientVersion
305
- } from "./chunk-K26XPZRB.js";
335
+ } from "./chunk-LVZVSLKO.js";
306
336
  import {
307
337
  asTrimmedString
308
338
  } from "./chunk-3EUW3WEO.js";
309
339
  import {
310
340
  findModelConfig
311
- } from "./chunk-CD2DK5JA.js";
341
+ } from "./chunk-OKH74FML.js";
312
342
  import {
313
343
  asOptionalTrimmedString
314
344
  } from "./chunk-G3SUCT4W.js";
@@ -316,7 +346,7 @@ import {
316
346
  CLIENT_VERSION_TOO_OLD_CODE,
317
347
  NOLO_CLIENT_VERSION_HEADER,
318
348
  buildClientVersionUpgradeMessage
319
- } from "./chunk-PQ63BDV3.js";
349
+ } from "./chunk-JPXACKSW.js";
320
350
  import {
321
351
  asTrimmedLowercaseString
322
352
  } from "./chunk-QSJ3HFEF.js";
@@ -1621,6 +1651,7 @@ function setActiveThemeMode(mode, options) {
1621
1651
  activeThemeMode = mode;
1622
1652
  if (mode === "terminal") {
1623
1653
  resolvedBrightness = null;
1654
+ trustedCanvasBrightness = null;
1624
1655
  terminalModeExplicit = options?.explicit === true;
1625
1656
  } else {
1626
1657
  terminalModeExplicit = false;
@@ -1790,13 +1821,16 @@ function pushToContrast(rawHex, canvasHex, target, floor) {
1790
1821
  }
1791
1822
  return best;
1792
1823
  }
1824
+ function hasTrustedCanvasEvidence(env) {
1825
+ return activeTerminalBaseHex !== null || trustedCanvasBrightness !== null || detectColorFgBgBrightness(env) !== null;
1826
+ }
1793
1827
  function shouldUseTruecolorTokens(env) {
1794
1828
  if (!supportsTruecolor(env)) return false;
1795
1829
  const explicit = (env.NOLO_TUI_THEME ?? "").trim().toLowerCase();
1796
1830
  if (explicit === "terminal" || explicit === "ansi") return false;
1797
1831
  if (resolveTuiThemeMode(env) !== "terminal") return true;
1798
1832
  if (terminalModeExplicit) return false;
1799
- return activeTerminalBaseHex !== null || detectColorFgBgBrightness(env) !== null;
1833
+ return hasTrustedCanvasEvidence(env);
1800
1834
  }
1801
1835
  function themeSgrParams(token, env = process.env, brightness = resolveTuiBrightness(env)) {
1802
1836
  const palette = THEME_PALETTES[activeThemeName] ?? THEME_PALETTES.nature;
@@ -1824,7 +1858,9 @@ var TERMINAL_BASE = {
1824
1858
  light: "FFFFFF"
1825
1859
  };
1826
1860
  var activeTerminalBaseHex = null;
1861
+ var trustedCanvasBrightness = null;
1827
1862
  function setActiveTerminalBaseHex(hex) {
1863
+ trustedCanvasBrightness = null;
1828
1864
  if (hex === null) {
1829
1865
  activeTerminalBaseHex = null;
1830
1866
  return;
@@ -1838,10 +1874,14 @@ function resetWorkspaceThemeState() {
1838
1874
  }
1839
1875
  function applyDetectedBackground(detected) {
1840
1876
  const normalizedHex = detected.hex.replace(/^#/, "").toUpperCase();
1877
+ const validHex = Boolean(readHexChannels(normalizedHex));
1878
+ const nextTrustedCanvas = !validHex && detected.trustedCanvas === true ? detected.brightness : null;
1841
1879
  const hexChanged = normalizedHex !== "" && normalizedHex !== activeTerminalBaseHex;
1842
- const changed = detected.brightness !== resolvedBrightness || hexChanged;
1880
+ const trustedChanged = nextTrustedCanvas !== trustedCanvasBrightness;
1881
+ const changed = detected.brightness !== resolvedBrightness || hexChanged || trustedChanged;
1843
1882
  resolvedBrightness = detected.brightness;
1844
1883
  setActiveTerminalBaseHex(detected.hex);
1884
+ trustedCanvasBrightness = nextTrustedCanvas;
1845
1885
  return changed;
1846
1886
  }
1847
1887
  function resolveTerminalBaseHex(brightness) {
@@ -1961,12 +2001,12 @@ function surfaceBackgroundSequence(env = process.env, brightness = resolveTuiBri
1961
2001
  return hexToBgSgr((SURFACE_HEX[activeThemeName] ?? SURFACE_HEX.trail)[brightness]);
1962
2002
  }
1963
2003
  function resolveSurfaceWashFallback(env) {
1964
- if (!supportsTruecolor(env) || activeTerminalBaseHex === null && detectColorFgBgBrightness(env) === null && resolveTuiThemeMode(env) === "terminal") {
2004
+ if (!supportsTruecolor(env) || !hasTrustedCanvasEvidence(env) && resolveTuiThemeMode(env) === "terminal") {
1965
2005
  return "\x1B[100m";
1966
2006
  }
1967
2007
  return null;
1968
2008
  }
1969
- function composerSurfaceBackgroundSequence(env = process.env, brightness = resolveTuiBrightness(env)) {
2009
+ function neutralSurfaceBackgroundSequence(env, brightness, darkWeight, lightWeight) {
1970
2010
  const fallback = resolveSurfaceWashFallback(env);
1971
2011
  if (fallback !== null) return fallback;
1972
2012
  const base = resolveTerminalBaseHex(brightness);
@@ -1974,9 +2014,15 @@ function composerSurfaceBackgroundSequence(env = process.env, brightness = resol
1974
2014
  const baseLuma = channels ? (0.299 * channels[0] + 0.587 * channels[1] + 0.114 * channels[2]) / 255 : null;
1975
2015
  const darkCanvas = baseLuma === null ? brightness === "dark" : baseLuma < 0.5;
1976
2016
  const tint = darkCanvas ? "FFFFFF" : "000000";
1977
- const weight = darkCanvas ? 0.1 : 0.07;
2017
+ const weight = darkCanvas ? darkWeight : lightWeight;
1978
2018
  return hexToBgSgr(blendHex(tint, base, weight));
1979
2019
  }
2020
+ function composerSurfaceBackgroundSequence(env = process.env, brightness = resolveTuiBrightness(env)) {
2021
+ return neutralSurfaceBackgroundSequence(env, brightness, 0.1, 0.07);
2022
+ }
2023
+ function userBubbleSurfaceBackgroundSequence(env = process.env, brightness = resolveTuiBrightness(env)) {
2024
+ return neutralSurfaceBackgroundSequence(env, brightness, 0.13, 0.08);
2025
+ }
1980
2026
  function userSurfaceBackgroundSequence(env = process.env, brightness = resolveTuiBrightness(env)) {
1981
2027
  const fallback = resolveSurfaceWashFallback(env);
1982
2028
  if (fallback !== null) return fallback;
@@ -1993,7 +2039,8 @@ function tuiRenderThemeFingerprint(colorEnabled, env = process.env) {
1993
2039
  const mode = resolveTuiThemeMode(env);
1994
2040
  const colorKind = !colorEnabled ? "plain" : shouldUseTruecolorTokens(env) ? "truecolor" : "ansi";
1995
2041
  const surface = colorEnabled ? userSurfaceBackgroundSequence(env) : "";
1996
- return `${activeThemeName}|${mode}|${colorKind}|${resolveTuiBrightness(env)}|${activeTerminalBaseHex ?? ""}|${env.COLORFGBG ?? ""}|${surface}`;
2042
+ const bubbleSurface = colorEnabled ? userBubbleSurfaceBackgroundSequence(env) : "";
2043
+ return `${activeThemeName}|${mode}|${colorKind}|${resolveTuiBrightness(env)}|${activeTerminalBaseHex ?? ""}|${env.COLORFGBG ?? ""}|${surface}|${bubbleSurface}`;
1997
2044
  }
1998
2045
  function classifyDiffLine(line) {
1999
2046
  if (line.startsWith("@@")) return "hunk";
@@ -8882,6 +8929,7 @@ function polishBreathInsertsBlankBetween(cur, next) {
8882
8929
  if (isPolishIntroLine(cur) && isPolishListLikeLine(next)) return false;
8883
8930
  if (isPolishHeadingLine(cur) || isPolishHeadingLine(next)) return false;
8884
8931
  if (isCodeFenceLine(cur) !== isCodeFenceLine(next)) return true;
8932
+ if (plainToolLine(cur).startsWith("\u25B8 ") && plainToolLine(next).startsWith(" \u2026")) return false;
8885
8933
  const toolBoundary = toolRowBoundary(cur, next);
8886
8934
  if (toolBoundary !== null) return toolBoundary;
8887
8935
  return isPolishListLikeLine(cur) !== isPolishListLikeLine(next);
@@ -9585,6 +9633,7 @@ function parseGit(rest) {
9585
9633
  const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
9586
9634
  if (!tokens2) return null;
9587
9635
  let i = 0, context;
9636
+ if (tokens2.length === 1 && tokens2[0] === "--version") return { action: "\u67E5\u7248\u672C", readOnly: true };
9588
9637
  while (tokens2[i]?.startsWith("-")) {
9589
9638
  const option = tokens2[i++];
9590
9639
  if (["-C", "-c", "--git-dir", "--work-tree"].includes(option)) {
@@ -9618,20 +9667,35 @@ function parseGit(rest) {
9618
9667
  return null;
9619
9668
  }
9620
9669
  if (sub === "branch") {
9621
- let mode = "create", end = false;
9670
+ let mode = "create", end = false, explicitList = false, listFilter = false;
9622
9671
  const operands = [];
9623
- for (const token of args) {
9672
+ const BRANCH_FILTER_FLAGS = ["--merged", "--no-merged", "--contains", "--no-contains", "--points-at"];
9673
+ for (let j = 0; j < args.length; j++) {
9674
+ const token = args[j];
9624
9675
  if (!end && token === "--") {
9625
9676
  end = true;
9626
9677
  continue;
9627
9678
  }
9628
9679
  if (!end && token.startsWith("-")) {
9629
9680
  if (["-d", "-D", "--delete"].includes(token) && mode === "create") mode = "delete";
9630
- else if (["--list", "-a", "--all", "-r", "--remotes", "-v", "-vv", "--show-current"].includes(token) && mode === "create") mode = "list";
9681
+ else if (token === "--list" && mode === "create") {
9682
+ mode = "list";
9683
+ explicitList = true;
9684
+ } else if (["-a", "--all", "-r", "--remotes", "-v", "-vv", "--verbose", "--show-current"].includes(token) && mode === "create") mode = "list";
9685
+ else if (mode === "create" && (BRANCH_FILTER_FLAGS.includes(token) || BRANCH_FILTER_FLAGS.some((f) => token.startsWith(`${f}=`)))) {
9686
+ mode = "list";
9687
+ listFilter = true;
9688
+ if (BRANCH_FILTER_FLAGS.includes(token)) {
9689
+ const value = args[j + 1];
9690
+ if (!value || value.startsWith("-")) return null;
9691
+ j++;
9692
+ }
9693
+ } else if (mode === "list" && ["-i", "--ignore-case", "-v", "-vv", "--verbose", "--no-color", "--color", "--column", "--no-column"].includes(token)) continue;
9631
9694
  else return null;
9632
9695
  } else operands.push(token);
9633
9696
  }
9634
9697
  if (mode === "delete" && operands.length === 1) return result("\u5220\u9664\u5206\u652F", operands[0], false);
9698
+ if (mode === "list" && operands.length && !explicitList && !listFilter) return null;
9635
9699
  if (mode === "list" || !args.length) return result("\u5217\u51FA\u5206\u652F", void 0, true);
9636
9700
  if (mode === "create" && operands.length >= 1 && operands.length <= 2) return result("\u521B\u5EFA\u5206\u652F", operands[0], false);
9637
9701
  return null;
@@ -9646,7 +9710,7 @@ function parseGit(rest) {
9646
9710
  break;
9647
9711
  }
9648
9712
  if (tok.startsWith("-")) {
9649
- if (["-m", "-F", "-b", "-B", "-n", "--max-count", "--format", "--pretty", "--since", "--until", "--author", "-U"].includes(tok)) j++;
9713
+ if (["-m", "-F", "-b", "-B", "-n", "--max-count", "--format", "--pretty", "--since", "--until", "--author", "-U", "-L", "-S", "-G"].includes(tok)) j++;
9650
9714
  continue;
9651
9715
  }
9652
9716
  out.push(tok);
@@ -9664,6 +9728,60 @@ function parseGit(rest) {
9664
9728
  return result("\u67E5\u5171\u540C\u7956\u5148", void 0, true);
9665
9729
  case "rev-parse":
9666
9730
  return result("\u67E5\u4ED3\u5E93\u4FE1\u606F", void 0, true);
9731
+ // 以下子命令在 git 里没有写/执行形态(例外一律单独把关),可安全折进探索树。
9732
+ case "version":
9733
+ return result("\u67E5\u7248\u672C", void 0, true);
9734
+ case "ls-files":
9735
+ return result("\u5217\u8DDF\u8E2A\u6587\u4EF6", void 0, true);
9736
+ case "ls-tree": {
9737
+ const target = nonFlagArgs(args).find(isSafeGitTarget);
9738
+ return result("\u770B\u6811", target ? clipShortText(target, 20) : void 0, true);
9739
+ }
9740
+ case "cat-file": {
9741
+ const target = nonFlagArgs(args).find(isSafeGitTarget);
9742
+ return result("\u770B\u5BF9\u8C61", target ? clipShortText(target, 20) : void 0, true);
9743
+ }
9744
+ case "show-ref":
9745
+ case "for-each-ref":
9746
+ return result("\u67E5\u5F15\u7528", void 0, true);
9747
+ case "grep": {
9748
+ if (args.some(
9749
+ (t2) => t2.startsWith("-") && !t2.startsWith("--") && t2.slice(1).includes("O") || t2 === "--open-files-in-pager" || t2.startsWith("--open-files-in-pager=")
9750
+ )) return null;
9751
+ return result("\u641C\u4EE3\u7801", extractSafeSearchTarget(args.join(" ")), true);
9752
+ }
9753
+ case "blame": {
9754
+ const files = nonFlagArgs(args).filter(isSafeGitTarget);
9755
+ const file = files[files.length - 1];
9756
+ return result("\u67E5\u884C\u4F5C\u8005", file ? baseName(file) ?? clipShortText(file, 20) : void 0, true);
9757
+ }
9758
+ case "describe":
9759
+ return result("\u67E5\u7248\u672C\u63CF\u8FF0", void 0, true);
9760
+ case "count-objects":
9761
+ return result("\u7EDF\u8BA1\u5BF9\u8C61", void 0, true);
9762
+ case "shortlog":
9763
+ return result("\u6C47\u603B\u63D0\u4EA4", void 0, true);
9764
+ case "check-ignore": {
9765
+ const file = nonFlagArgs(args).find(isSafeGitTarget);
9766
+ return result("\u67E5\u5FFD\u7565\u89C4\u5219", file ? baseName(file) : void 0, true);
9767
+ }
9768
+ case "reflog": {
9769
+ const op = nonFlagArgs(args)[0];
9770
+ if (op === "expire" || op === "delete" || op === "drop") return null;
9771
+ return result("\u67E5\u5F15\u7528\u65E5\u5FD7", void 0, true);
9772
+ }
9773
+ case "remote": {
9774
+ if (nonFlagArgs(args).length) return null;
9775
+ if (args.some((t2) => !["-v", "--verbose"].includes(t2))) return null;
9776
+ return result("\u67E5\u8FDC\u7AEF", void 0, true);
9777
+ }
9778
+ case "config": {
9779
+ const isReadForm = args.some((t2) => ["--get", "--get-all", "--get-regexp", "--list", "-l", "--show-origin"].includes(t2) || /^--(?:get|get-all|get-regexp|list|show-origin)(?:=|$)/.test(t2));
9780
+ if (!isReadForm) return null;
9781
+ if (args.some((t2) => ["--unset", "--unset-all", "--add", "--replace-all", "--rename-section", "--remove-section", "-e", "--edit"].includes(t2) || /^--(?:unset|unset-all|add|replace-all|rename-section|remove-section|edit)(?:=|$)/.test(t2))) return null;
9782
+ const key = nonFlagArgs(args)[0];
9783
+ return result("\u67E5\u914D\u7F6E", key && isSafeGitTarget(key) ? clipShortText(key, 24) : void 0, true);
9784
+ }
9667
9785
  case "show": {
9668
9786
  const target = nonFlagArgs(args)[0];
9669
9787
  return result("\u770B\u63D0\u4EA4", isSafeGitTarget(target) ? clipShortText(target, 20) : void 0, true);
@@ -9727,6 +9845,23 @@ function baseName(path2) {
9727
9845
  const base = parts.pop();
9728
9846
  return base || void 0;
9729
9847
  }
9848
+ function lastFileOperand(tokens2, valueFlags) {
9849
+ let file;
9850
+ for (let i = 0; i < tokens2.length; i++) {
9851
+ const tok = tokens2[i];
9852
+ if (tok === "--") {
9853
+ const rest = tokens2.slice(i + 1);
9854
+ if (rest.length) file = rest[rest.length - 1];
9855
+ break;
9856
+ }
9857
+ if (tok.startsWith("-")) {
9858
+ if (!tok.includes("=") && valueFlags.has(tok)) i++;
9859
+ continue;
9860
+ }
9861
+ file = tok;
9862
+ }
9863
+ return file;
9864
+ }
9730
9865
  function splitSegments(command) {
9731
9866
  const segments = [];
9732
9867
  let current = "";
@@ -10241,11 +10376,79 @@ function classifySegment(segment) {
10241
10376
  }
10242
10377
  case "ps":
10243
10378
  return { verb: "\u67E5\u8FDB\u7A0B", readOnly: true };
10244
- case "sha256sum": {
10379
+ case "sha256sum":
10380
+ case "sha1sum":
10381
+ case "md5sum":
10382
+ case "sha512sum":
10383
+ case "b2sum":
10384
+ case "cksum": {
10245
10385
  const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
10246
10386
  const file = tokens2?.find((t2) => !t2.startsWith("-"));
10247
10387
  return { verb: "\u7B97\u6821\u9A8C\u548C", target: file ? baseName(file) : void 0, readOnly: true };
10248
10388
  }
10389
+ case "du": {
10390
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10391
+ if (!tokens2) return null;
10392
+ const path2 = lastFileOperand(tokens2, /* @__PURE__ */ new Set(["-d", "--max-depth", "-B", "--block-size", "--files0-from", "--exclude", "-t", "--threshold", "--time-style"]));
10393
+ return { verb: "\u67E5\u78C1\u76D8\u5360\u7528", target: path2 ? baseName(path2) : void 0, readOnly: true };
10394
+ }
10395
+ case "df":
10396
+ return { verb: "\u67E5\u78C1\u76D8\u7A7A\u95F4", readOnly: true };
10397
+ case "free":
10398
+ return { verb: "\u67E5\u5185\u5B58", readOnly: true };
10399
+ case "nproc":
10400
+ return { verb: "\u67E5 CPU \u6570", readOnly: true };
10401
+ case "uptime":
10402
+ return { verb: "\u67E5\u8D1F\u8F7D", readOnly: true };
10403
+ case "id": {
10404
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10405
+ if (!tokens2) return null;
10406
+ const user = tokens2.find((t2) => !t2.startsWith("-"));
10407
+ return { verb: "\u67E5\u8EAB\u4EFD", target: user ? clipShortText(user, 24) : void 0, readOnly: true };
10408
+ }
10409
+ case "hostname": {
10410
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10411
+ if (!tokens2) return null;
10412
+ if (tokens2.some((t2) => ["-F", "--file", "-b", "--boot"].includes(t2))) return null;
10413
+ if (tokens2.some((t2) => !t2.startsWith("-"))) return null;
10414
+ return { verb: "\u67E5\u4E3B\u673A\u540D", readOnly: true };
10415
+ }
10416
+ case "date": {
10417
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10418
+ if (!tokens2) return null;
10419
+ if (tokens2.some((t2) => ["-s", "--set", "-f", "--file"].includes(t2) || t2.startsWith("--set="))) return null;
10420
+ const valueFlags = /* @__PURE__ */ new Set(["-d", "--date", "-r", "--reference"]);
10421
+ const positionals = [];
10422
+ for (let i = 0; i < tokens2.length; i++) {
10423
+ const tok = tokens2[i];
10424
+ if (tok.startsWith("-")) {
10425
+ if (!tok.includes("=") && valueFlags.has(tok)) i++;
10426
+ continue;
10427
+ }
10428
+ positionals.push(tok);
10429
+ }
10430
+ if (positionals.some((t2) => !t2.startsWith("+"))) return null;
10431
+ return { verb: "\u67E5\u65F6\u95F4", readOnly: true };
10432
+ }
10433
+ case "basename": {
10434
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10435
+ if (!tokens2) return null;
10436
+ const path2 = tokens2.find((t2) => !t2.startsWith("-"));
10437
+ return { verb: "\u53D6\u6587\u4EF6\u540D", target: path2 ? baseName(path2) : void 0, readOnly: true };
10438
+ }
10439
+ case "dirname": {
10440
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10441
+ if (!tokens2) return null;
10442
+ const path2 = tokens2.find((t2) => !t2.startsWith("-"));
10443
+ return { verb: "\u53D6\u6240\u5728\u76EE\u5F55", target: path2 ? clipShortText(path2, 24) : void 0, readOnly: true };
10444
+ }
10445
+ case "diff":
10446
+ case "cmp": {
10447
+ const tokens2 = shellWords(stripTrailingPipe(rest));
10448
+ if (!tokens2) return null;
10449
+ const file = lastFileOperand(tokens2, /* @__PURE__ */ new Set(["-x", "--exclude", "-I", "--ignore-matching-lines", "-U", "--unified", "-C", "--context", "--label", "-L", "--to-file", "--from-file", "-S", "--starting-file", "--horizon-lines", "--tabsize", "-t"]));
10450
+ return { verb: "\u5BF9\u6BD4\u6587\u4EF6", target: file ? baseName(file) : void 0, readOnly: true };
10451
+ }
10249
10452
  case "dnf":
10250
10453
  case "yum": {
10251
10454
  const sub = rest.split(/\s+/)[0] ?? "";
@@ -10286,7 +10489,7 @@ function classifySegment(segment) {
10286
10489
  case "awk":
10287
10490
  return { verb: "\u5904\u7406\u6587\u672C", readOnly: true };
10288
10491
  case "find": {
10289
- if (/(?:^|\s)(?:-delete|-exec|-execdir|-ok|-okdir)(?:\s|$)/.test(rest)) return null;
10492
+ if (/(?:^|\s)(?:-delete|-exec|-execdir|-ok|-okdir|-fprint|-fprint0|-fprintf|-fls)(?:\s|$)/.test(rest)) return null;
10290
10493
  return { verb: "\u67E5\u627E\u6587\u4EF6", readOnly: true };
10291
10494
  }
10292
10495
  case "curl":
@@ -10298,6 +10501,7 @@ function classifySegment(segment) {
10298
10501
  case "yarn": {
10299
10502
  const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]) ?? rest.split(/\s+/).filter(Boolean);
10300
10503
  const sub = tokens2[0] ?? "";
10504
+ if (tokens2.length === 1 && ["-v", "-V", "--version"].includes(sub)) return { verb: "\u67E5\u7248\u672C", readOnly: true };
10301
10505
  if (sub === "test") {
10302
10506
  const target = tokens2.slice(1).find((t2) => !t2.startsWith("-"));
10303
10507
  return { verb: "\u8DD1\u6D4B\u8BD5", target: target ? baseName(target) : void 0, readOnly: false };
@@ -10323,6 +10527,7 @@ function classifySegment(segment) {
10323
10527
  case "python":
10324
10528
  case "python3": {
10325
10529
  const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]) ?? [];
10530
+ if (tokens2.length === 1 && ["-V", "-v", "--version"].includes(tokens2[0])) return { verb: "\u67E5\u7248\u672C", readOnly: true };
10326
10531
  if (tokens2.includes("--inline-heredoc") || /(?:^|\s)-[A-Za-z]*c(?:\s|$)/.test(rest)) {
10327
10532
  return { verb: "\u6267\u884C\u5185\u8054\u811A\u672C (Python)", readOnly: false };
10328
10533
  }
@@ -10331,6 +10536,8 @@ function classifySegment(segment) {
10331
10536
  }
10332
10537
  case "node": {
10333
10538
  if (/(?:^|\s)-[A-Za-z]*e(?:\s|$)/.test(rest)) return null;
10539
+ const nodeTokens = shellWords(stripTrailingPipe(rest));
10540
+ if (nodeTokens?.length === 1 && ["-v", "-V", "--version"].includes(nodeTokens[0])) return { verb: "\u67E5\u7248\u672C", readOnly: true };
10334
10541
  const script = rest.split(/\s+/).find((t2) => t2 && !t2.startsWith("-"));
10335
10542
  return { verb: "\u6267\u884C\u811A\u672C", target: baseName(script ?? ""), readOnly: false };
10336
10543
  }
@@ -10489,6 +10696,8 @@ var PIPELINE_FILTER_COMMANDS = /* @__PURE__ */ new Set([
10489
10696
  "nl",
10490
10697
  "column",
10491
10698
  "grep",
10699
+ "egrep",
10700
+ "fgrep",
10492
10701
  "rg",
10493
10702
  "ag",
10494
10703
  "ack",
@@ -10497,7 +10706,28 @@ var PIPELINE_FILTER_COMMANDS = /* @__PURE__ */ new Set([
10497
10706
  "more",
10498
10707
  "bat",
10499
10708
  "awk",
10500
- "sed"
10709
+ "sed",
10710
+ // 纯 stdout 文本/校验和工具:只读 stdin/文件,没有输出文件参数
10711
+ // (写文件的 tee/xargs/split/xxd 之类**不在此列**)。
10712
+ "diff",
10713
+ "cmp",
10714
+ "comm",
10715
+ "paste",
10716
+ "join",
10717
+ "fold",
10718
+ "expand",
10719
+ "unexpand",
10720
+ "tac",
10721
+ "rev",
10722
+ "strings",
10723
+ "od",
10724
+ "base64",
10725
+ "md5sum",
10726
+ "sha1sum",
10727
+ "sha256sum",
10728
+ "sha512sum",
10729
+ "b2sum",
10730
+ "cksum"
10501
10731
  ]);
10502
10732
  function hasNonFilterPipeline(command) {
10503
10733
  let quote = null;
@@ -11704,7 +11934,7 @@ function normalToolGistRaw(event) {
11704
11934
  if (query2 || path3) return formatSearchItemQuery(query2, path3);
11705
11935
  }
11706
11936
  if (isRunToolName(toolName)) {
11707
- const command2 = typeof metadata.command === "string" ? metadata.command : "";
11937
+ const command2 = typeof metadata.command === "string" ? metadata.command : typeof metadata.cmd === "string" ? metadata.cmd : "";
11708
11938
  if (command2) {
11709
11939
  const gist = summarizeShellCommand(command2);
11710
11940
  if (gist) return truncateByDisplayWidth(redactSecrets(gist.summary), normalRunGistMaxWidth());
@@ -11728,8 +11958,8 @@ function normalToolGistRaw(event) {
11728
11958
  function normalToolGist(event) {
11729
11959
  return withholdIfSecretLike(normalToolGistRaw(event));
11730
11960
  }
11731
- function formatNormalToolDuration(elapsedMs) {
11732
- if (typeof elapsedMs !== "number" || !Number.isFinite(elapsedMs) || elapsedMs <= 500) return "";
11961
+ function formatNormalToolDuration(elapsedMs, includeThreshold = false) {
11962
+ if (typeof elapsedMs !== "number" || !Number.isFinite(elapsedMs) || elapsedMs < 500 || elapsedMs === 500 && !includeThreshold) return "";
11733
11963
  if (elapsedMs < 1e3) return `${Math.round(elapsedMs)}ms`;
11734
11964
  return `${(elapsedMs / 1e3).toFixed(1)}s`;
11735
11965
  }
@@ -11892,8 +12122,9 @@ var TUI_TREE_TOOLS = {
11892
12122
  Search: ["exa_search", "globFiles", "searchFiles", "codeSearch"],
11893
12123
  Fetch: ["fetchWebpage"]
11894
12124
  };
12125
+ var RUN_WINDOW_SIZE = 3;
11895
12126
  function toolDetails(event, line) {
11896
- const command = event.metadata?.command;
12127
+ const command = event.metadata?.command ?? event.metadata?.cmd;
11897
12128
  return isRunToolName(event.toolName) && typeof command === "string" ? `${toolRowDetailLine(line)}${safeApprovalMultilineText(command)}
11898
12129
  ` : toolRowDetailLine(line);
11899
12130
  }
@@ -11914,6 +12145,43 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
11914
12145
  let scope = 0;
11915
12146
  let lastFamilyId;
11916
12147
  let tree = null;
12148
+ let runGroup;
12149
+ const formatRunGroup = (event, line) => {
12150
+ const group = runGroup ??= { count: 0, elapsedMs: 0, recent: [], rows: [] };
12151
+ const elapsed = event.elapsedMs;
12152
+ group.count++;
12153
+ if (typeof elapsed === "number" && Number.isFinite(elapsed) && elapsed > 0) group.elapsedMs += elapsed;
12154
+ const gist = safeAskText(normalToolGist(event)) || toolLabel(event.toolName);
12155
+ group.recent.push({ gist, duration: formatNormalToolDuration(elapsed) });
12156
+ if (group.recent.length > RUN_WINDOW_SIZE) group.recent.shift();
12157
+ const payload = { kind: "Run", summary: "", fallback: line, details: toolDetails(event, line) };
12158
+ if (group.count <= RUN_WINDOW_SIZE) {
12159
+ group.rows.push(line.replace(/\n$/, ""));
12160
+ payload.appendOnly = true;
12161
+ } else {
12162
+ const budget = Math.max(1, resolveHistoryLayoutGeometry(process.stdout.columns).contentWidth - displayWidth("\u25C8 "));
12163
+ const fit = (text) => themeText(truncateByDisplayWidth(text, budget), "muted", colorEnabled);
12164
+ const total = formatNormalToolDuration(group.elapsedMs, true);
12165
+ const timing = total ? t("runGroupTiming", total) : "";
12166
+ const count = String(group.count);
12167
+ const prefix = `\u25B8 ${toolIcon("execShell")} \xB7 `;
12168
+ payload.previousLines = group.rows;
12169
+ payload.lines = [
12170
+ fit(prefix + t("runGroupHeader", count, timing)),
12171
+ fit(` \u2026 ${t("runGroupCollapsed", String(group.count - RUN_WINDOW_SIZE))}`),
12172
+ ...group.recent.map(({ gist: gist2, duration }) => {
12173
+ const leafPrefix = " \u2713 ";
12174
+ const leafTail = duration ? ` \xB7 ${duration}` : "";
12175
+ const gistBudget = Math.max(0, budget - displayWidth(leafPrefix + leafTail));
12176
+ return fit(`${leafPrefix}${truncateByDisplayWidth(gist2, gistBudget)}${leafTail}`);
12177
+ })
12178
+ ];
12179
+ payload.finalizedSummary = fit(prefix + t("runGroupFinal", count, timing));
12180
+ group.rows = payload.lines;
12181
+ }
12182
+ return `${TUI_TREE_MARKER}${JSON.stringify(payload)}${TUI_TREE_END}
12183
+ `;
12184
+ };
11917
12185
  const treeKind = (name) => Object.keys(TUI_TREE_TOOLS).find((kind) => TUI_TREE_TOOLS[kind].includes(name)) ?? null;
11918
12186
  const treeLine = (kind, counts, items, fallback, details) => {
11919
12187
  const activeKinds = Object.keys(counts).filter((k) => counts[k] > 0);
@@ -11957,16 +12225,21 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
11957
12225
  `;
11958
12226
  };
11959
12227
  const formatTreeEvent = (event, call) => {
11960
- if (event.type === "tool-error") tree = null;
12228
+ if (event.type === "tool-error") {
12229
+ tree = null;
12230
+ runGroup = void 0;
12231
+ }
11961
12232
  if (!opts.tuiTrees || event.type !== "tool-result") return null;
11962
12233
  if (isFailedToolResult(event) || event.metadata?.failed || event.metadata?.timedOut || readActionGate(event.metadata?.actionGate) || event.metadata?.permissionRequest) {
11963
12234
  tree = null;
12235
+ runGroup = void 0;
11964
12236
  return null;
11965
12237
  }
11966
12238
  const name = event.toolName || call?.toolName || "tool";
11967
12239
  const kind = treeKind(name);
11968
12240
  if (!kind) {
11969
12241
  tree = null;
12242
+ runGroup = void 0;
11970
12243
  return null;
11971
12244
  }
11972
12245
  const activity = projectToolActivity({
@@ -11986,8 +12259,14 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
11986
12259
  const isReadOnlyExploration = kind === "Read" || kind === "Search" || kind === "Fetch" || kind === "Run" && activity.readOnly === true;
11987
12260
  if (!isReadOnlyExploration) {
11988
12261
  tree = null;
11989
- return null;
12262
+ if (event.metadata?.actionGate) {
12263
+ runGroup = void 0;
12264
+ return null;
12265
+ }
12266
+ const runEvent = name === event.toolName ? event : { ...event, toolName: name };
12267
+ return formatRunGroup(runEvent, formatNormalToolLine(runEvent, call, colorEnabled, opts));
11990
12268
  }
12269
+ runGroup = void 0;
11991
12270
  let item = "";
11992
12271
  const m = event.metadata ?? {};
11993
12272
  if (kind === "Run") {
@@ -12019,6 +12298,7 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
12019
12298
  };
12020
12299
  const format = (event) => {
12021
12300
  if (event.type === "tool-call") {
12301
+ if (!isRunToolName(event.toolName)) runGroup = void 0;
12022
12302
  pending.set(event.toolCallId, {
12023
12303
  toolName: event.toolName,
12024
12304
  argumentsPreview: event.argumentsPreview
@@ -12043,10 +12323,12 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
12043
12323
  };
12044
12324
  format.reset = () => {
12045
12325
  tree = null;
12326
+ runGroup = void 0;
12046
12327
  lastFamilyId = void 0;
12047
12328
  scope++;
12048
12329
  };
12049
12330
  format.consume = (event) => {
12331
+ runGroup = void 0;
12050
12332
  if (event.type === "tool-call") {
12051
12333
  pending.set(event.toolCallId, {
12052
12334
  toolName: event.toolName,
@@ -12373,7 +12655,7 @@ function createCliTurnOutput(params) {
12373
12655
  };
12374
12656
  const writeVisibleAssistantChunk = (chunk) => {
12375
12657
  if (!chunk) return;
12376
- if (!assistantLabelManaged) formatToolEvent.reset?.();
12658
+ if (!assistantLabelManaged || tuiNarrationPromoted) formatToolEvent.reset?.();
12377
12659
  const parsed = processThinkChunk(chunk, thinkState);
12378
12660
  thinkState = parsed.state;
12379
12661
  if (!parsed.content && !parsed.reasoning) return;
@@ -12768,6 +13050,667 @@ ${t("agentRunStream.malformedToolCallRejectedNoDialog")}
12768
13050
  };
12769
13051
  }
12770
13052
 
13053
+ // packages/cli/client/callerPoolTop.ts
13054
+ function catalogEntryToPoolCandidate(entry, userId) {
13055
+ return {
13056
+ agentKey: entry.key,
13057
+ model: entry.model,
13058
+ requiresPaidApproval: isPlatformPaidAgentCall({
13059
+ agentConfig: {
13060
+ key: entry.key,
13061
+ // 自有 agent 的私有 key 形如 agent-<userId>-<id>:归属判据认这个形状。
13062
+ privateKey: entry.kind === "private" ? entry.key : void 0,
13063
+ model: entry.model,
13064
+ apiSource: entry.apiSource,
13065
+ cliProvider: entry.cliProvider
13066
+ },
13067
+ callerUserId: userId ?? void 0
13068
+ })
13069
+ };
13070
+ }
13071
+ function resolveCallerPoolTopFromCatalog(args) {
13072
+ const entries = args.entries;
13073
+ const userId = typeof args.userId === "string" ? args.userId.trim() : "";
13074
+ if (!entries || entries.length === 0 || !userId) return void 0;
13075
+ return isCallerAtFreePoolTop(
13076
+ { model: args.model ?? null, agentKey: args.agentKey ?? null },
13077
+ entries.map((entry) => catalogEntryToPoolCandidate(entry, userId))
13078
+ );
13079
+ }
13080
+ function pickCallerPoolIdentityFromAgentConfig(args) {
13081
+ const asPart = (value) => {
13082
+ const text = typeof value === "string" ? value.trim() : "";
13083
+ return text.length > 0 ? text : null;
13084
+ };
13085
+ const config = args.agentConfig ?? null;
13086
+ return {
13087
+ agentKey: asPart(config?.key) ?? asPart(args.agentKey),
13088
+ model: asPart(config?.model) ?? asPart(args.modelOverride)
13089
+ };
13090
+ }
13091
+ var CLI_CALLER_POOL_TOP_LATCH_LIMIT = 64;
13092
+ var cliCallerPoolTopLatch = /* @__PURE__ */ new Map();
13093
+ var asLatchPart = (value) => {
13094
+ const text = typeof value === "string" ? value.trim() : "";
13095
+ return text.length > 0 ? text : "-";
13096
+ };
13097
+ function buildCliCallerPoolTopLatchKey(args) {
13098
+ const dialogId = typeof args.dialogId === "string" ? args.dialogId.trim() : "";
13099
+ if (!dialogId) return null;
13100
+ return [dialogId, asLatchPart(args.agentKey), asLatchPart(args.model)].join("\0");
13101
+ }
13102
+ function resolveLatchedCliCallerIsPoolTop(args) {
13103
+ const latchAgentKey = "latchAgentKey" in args ? args.latchAgentKey : args.agentKey;
13104
+ const latchModel = "latchModel" in args ? args.latchModel : args.model;
13105
+ const latchKey = buildCliCallerPoolTopLatchKey({
13106
+ dialogId: args.dialogId,
13107
+ agentKey: latchAgentKey,
13108
+ model: latchModel
13109
+ });
13110
+ if (!latchKey) return resolveCallerPoolTopFromCatalog(args);
13111
+ if (cliCallerPoolTopLatch.has(latchKey)) return cliCallerPoolTopLatch.get(latchKey);
13112
+ const resolved = resolveCallerPoolTopFromCatalog(args);
13113
+ cliCallerPoolTopLatch.set(latchKey, resolved);
13114
+ while (cliCallerPoolTopLatch.size > CLI_CALLER_POOL_TOP_LATCH_LIMIT) {
13115
+ const oldest = cliCallerPoolTopLatch.keys().next();
13116
+ if (oldest.done) break;
13117
+ cliCallerPoolTopLatch.delete(oldest.value);
13118
+ }
13119
+ return resolved;
13120
+ }
13121
+
13122
+ // packages/ai/agent/utils/sortUtils.ts
13123
+ function sortAgentsFavoriteOwnedPublic(items) {
13124
+ const map = /* @__PURE__ */ new Map();
13125
+ for (const item of items) {
13126
+ const existing = map.get(item.key);
13127
+ if (!existing) {
13128
+ map.set(item.key, { ...item });
13129
+ continue;
13130
+ }
13131
+ map.set(item.key, {
13132
+ ...existing,
13133
+ ...item,
13134
+ key: existing.key,
13135
+ favoritedAt: Math.max(existing.favoritedAt ?? 0, item.favoritedAt ?? 0) || void 0,
13136
+ isOwned: Boolean(existing.isOwned || item.isOwned),
13137
+ isPublic: Boolean(existing.isPublic || item.isPublic),
13138
+ updatedAt: Math.max(existing.updatedAt ?? 0, item.updatedAt ?? 0),
13139
+ order: existing.order ?? item.order
13140
+ });
13141
+ }
13142
+ const arr = Array.from(map.values());
13143
+ arr.sort((a, b) => {
13144
+ const aFav = a.favoritedAt != null && a.favoritedAt > 0;
13145
+ const bFav = b.favoritedAt != null && b.favoritedAt > 0;
13146
+ if (aFav !== bFav) return aFav ? -1 : 1;
13147
+ if (aFav && bFav) {
13148
+ const diff = (b.favoritedAt ?? 0) - (a.favoritedAt ?? 0);
13149
+ if (diff !== 0) return diff;
13150
+ }
13151
+ const aOwned = Boolean(a.isOwned);
13152
+ const bOwned = Boolean(b.isOwned);
13153
+ if (aOwned !== bOwned) return aOwned ? -1 : 1;
13154
+ const aPublic = Boolean(a.isPublic);
13155
+ const bPublic = Boolean(b.isPublic);
13156
+ if (aPublic !== bPublic) return aPublic ? -1 : 1;
13157
+ const tsDiff = (b.updatedAt ?? 0) - (a.updatedAt ?? 0);
13158
+ if (tsDiff !== 0) return tsDiff;
13159
+ const aOrder = a.order ?? Number.POSITIVE_INFINITY;
13160
+ const bOrder = b.order ?? Number.POSITIVE_INFINITY;
13161
+ if (aOrder !== bOrder) return aOrder - bOrder;
13162
+ return a.key.localeCompare(b.key);
13163
+ });
13164
+ return arr;
13165
+ }
13166
+
13167
+ // packages/cli/tui/agentCatalog.ts
13168
+ var DEFAULT_TUI_AGENT_KEY = NOLO_DEFAULT_AGENT_KEY;
13169
+ function formatAgentSourceLabel(entry) {
13170
+ if (entry.kind === "platform" || entry.apiSource === "platform") return t("agentSourcePlatform");
13171
+ if (entry.apiSource === "cli") {
13172
+ return entry.cliProvider ? `${t("agentSourceSubscription")}(${entry.cliProvider})` : t("agentSourceSubscription");
13173
+ }
13174
+ if (entry.apiSource === "custom") return t("agentSourceApi");
13175
+ return t("agentSourcePlatform");
13176
+ }
13177
+ var PLATFORM_AGENTS = [
13178
+ {
13179
+ // 名称与模型都从 builtinAgentCatalog 派生:`/switch` 里的 nolo 项直接显示
13180
+ // 它实际指向的模型(当前 deepseek-flash),换代自动跟随。
13181
+ name: BUILTIN_NOLO_AGENT_NAME,
13182
+ key: DEFAULT_TUI_AGENT_KEY,
13183
+ model: BUILTIN_NOLO_AGENT_MODEL,
13184
+ kind: "platform",
13185
+ description: "one assistant that routes work across your agents and data"
13186
+ }
13187
+ ];
13188
+ function resolveCatalogPlatformAgents(_env = process.env) {
13189
+ return PLATFORM_AGENTS;
13190
+ }
13191
+ function toUpdatedAt(value) {
13192
+ if (value == null) return 0;
13193
+ const parsed = new Date(value).getTime();
13194
+ return Number.isFinite(parsed) ? parsed : 0;
13195
+ }
13196
+ function listedAgentToCatalogEntry(agent) {
13197
+ return {
13198
+ name: agent.name,
13199
+ key: agent.privateKey,
13200
+ model: agent.model,
13201
+ kind: "private",
13202
+ updatedAt: toUpdatedAt(agent.updatedAt),
13203
+ ...agent.apiSource ? { apiSource: agent.apiSource } : {},
13204
+ ...agent.cliProvider ? { cliProvider: agent.cliProvider } : {},
13205
+ ...agent.quota ? { quota: agent.quota } : {}
13206
+ };
13207
+ }
13208
+ function mergeCatalogEntries(currentKey, platformAgents, privateAgents, favoritedAtByKey = {}) {
13209
+ const seen = /* @__PURE__ */ new Set();
13210
+ const merged = [];
13211
+ const push = (entry) => {
13212
+ if (seen.has(entry.key)) return;
13213
+ seen.add(entry.key);
13214
+ const favoritedAt = favoritedAtByKey[entry.key];
13215
+ merged.push(favoritedAt ? { ...entry, favoritedAt } : entry);
13216
+ };
13217
+ const current = [...platformAgents, ...privateAgents].find((entry) => entry.key === currentKey) ?? null;
13218
+ if (current) push(current);
13219
+ for (const entry of platformAgents) {
13220
+ if (entry.key !== currentKey) push(entry);
13221
+ }
13222
+ const sortablePrivate = privateAgents.map((entry) => ({
13223
+ key: entry.key,
13224
+ ...favoritedAtByKey[entry.key] !== void 0 ? { favoritedAt: favoritedAtByKey[entry.key] } : {},
13225
+ isOwned: true,
13226
+ updatedAt: entry.updatedAt ?? 0
13227
+ }));
13228
+ const sortedKeys = sortAgentsFavoriteOwnedPublic(sortablePrivate);
13229
+ const sortedKeyOrder = new Map(sortedKeys.map((item, i) => [item.key, i]));
13230
+ const sortedPrivate = [...privateAgents].sort(
13231
+ (a, b) => (sortedKeyOrder.get(a.key) ?? 0) - (sortedKeyOrder.get(b.key) ?? 0)
13232
+ );
13233
+ for (const entry of sortedPrivate) {
13234
+ if (entry.key !== currentKey) push(entry);
13235
+ }
13236
+ return merged;
13237
+ }
13238
+ function formatUnavailableFavoritesNotice(unavailableFavoriteCount) {
13239
+ if (!Number.isFinite(unavailableFavoriteCount) || unavailableFavoriteCount <= 0) {
13240
+ return null;
13241
+ }
13242
+ return t(
13243
+ "agentCatalogUnavailableFavorites",
13244
+ String(Math.floor(unavailableFavoriteCount))
13245
+ );
13246
+ }
13247
+ var agentCatalogCache = null;
13248
+ var lastRefresh = null;
13249
+ function getAgentCatalogRefreshStatus(args = {}) {
13250
+ const env = args.env ?? process.env;
13251
+ const token = resolveAuthToken([], env);
13252
+ const key = `${token ? parseUserIdFromAuthToken(token) ?? "anon" : "anon"}|${resolveServerUrl(env)}`;
13253
+ return lastRefresh?.cacheKey === key ? lastRefresh.status : null;
13254
+ }
13255
+ var agentCatalogRefreshInFlight = null;
13256
+ var agentCatalogGeneration = 0;
13257
+ var agentCatalogRawLoadInFlight = /* @__PURE__ */ new Map();
13258
+ var AGENT_CATALOG_FRESH_MS = 15e3;
13259
+ var AGENT_CATALOG_MAX_STALE_MS = 5 * 6e4;
13260
+ var AGENT_CATALOG_FOREGROUND_DEADLINE_MS = 2500;
13261
+ var AGENT_CATALOG_BACKGROUND_DEADLINE_MS = 8e3;
13262
+ function resolveCatalogDeadlineMs(kind, env) {
13263
+ const override = Number.parseInt(env.NOLO_TUI_CATALOG_DEADLINE_MS ?? "", 10);
13264
+ if (Number.isFinite(override) && override > 0) return override;
13265
+ return kind === "foreground" ? AGENT_CATALOG_FOREGROUND_DEADLINE_MS : AGENT_CATALOG_BACKGROUND_DEADLINE_MS;
13266
+ }
13267
+ var SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES = 1;
13268
+ var SERVER_COOLDOWN_MS = 5 * 6e4;
13269
+ var serverHealth = /* @__PURE__ */ new Map();
13270
+ var serverHealthNow = () => Date.now();
13271
+ function filterHealthyServers(serverUrls) {
13272
+ const now = serverHealthNow();
13273
+ const healthy = serverUrls.filter((url) => {
13274
+ const state2 = serverHealth.get(url);
13275
+ if (!state2) return true;
13276
+ return !(state2.consecutiveFailures >= SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES && now - state2.trippedAt < SERVER_COOLDOWN_MS);
13277
+ });
13278
+ return healthy.length > 0 ? healthy : serverUrls;
13279
+ }
13280
+ function keepPrimaryServer(serverUrls, primary) {
13281
+ return serverUrls.includes(primary) ? serverUrls : [primary, ...serverUrls];
13282
+ }
13283
+ function recordServerFailures(failures) {
13284
+ const now = serverHealthNow();
13285
+ for (const failure of failures) {
13286
+ const state2 = serverHealth.get(failure.serverUrl) ?? {
13287
+ consecutiveFailures: 0,
13288
+ trippedAt: 0
13289
+ };
13290
+ state2.consecutiveFailures += 1;
13291
+ if (state2.consecutiveFailures >= SERVER_TRIP_AFTER_CONSECUTIVE_FAILURES) {
13292
+ state2.trippedAt = now;
13293
+ }
13294
+ serverHealth.set(failure.serverUrl, state2);
13295
+ }
13296
+ }
13297
+ function recordServerSuccesses(serverUrls) {
13298
+ for (const url of serverUrls) serverHealth.delete(url);
13299
+ }
13300
+ function withFetchDeadline(fetchImpl, deadlineMs) {
13301
+ return async (input, init) => {
13302
+ let timer;
13303
+ const deadline = new Promise((_, reject) => {
13304
+ timer = setTimeout(
13305
+ () => reject(new Error(`catalog fetch deadline exceeded (${deadlineMs}ms)`)),
13306
+ deadlineMs
13307
+ );
13308
+ });
13309
+ const signal = init?.signal;
13310
+ let onAbort;
13311
+ let aborted = null;
13312
+ if (signal) {
13313
+ if (signal.aborted) {
13314
+ throw signal.reason ?? new Error("catalog fetch aborted");
13315
+ }
13316
+ aborted = new Promise((_, reject) => {
13317
+ onAbort = () => reject(signal.reason ?? new Error("catalog fetch aborted"));
13318
+ signal.addEventListener("abort", onAbort, { once: true });
13319
+ });
13320
+ }
13321
+ try {
13322
+ const response = await Promise.race([
13323
+ fetchImpl(input, init),
13324
+ deadline,
13325
+ ...aborted ? [aborted] : []
13326
+ ]);
13327
+ const text = await Promise.race([
13328
+ response.text(),
13329
+ deadline,
13330
+ ...aborted ? [aborted] : []
13331
+ ]);
13332
+ return new Response(text, {
13333
+ status: response.status,
13334
+ statusText: response.statusText,
13335
+ headers: response.headers
13336
+ });
13337
+ } finally {
13338
+ if (timer) clearTimeout(timer);
13339
+ if (signal && onAbort) signal.removeEventListener("abort", onAbort);
13340
+ }
13341
+ };
13342
+ }
13343
+ function readCachedAgentCatalogEntries() {
13344
+ return agentCatalogCache?.entries ?? null;
13345
+ }
13346
+ function hasWarmAgentCatalogCache(args = {}) {
13347
+ const env = args.env ?? process.env;
13348
+ const authToken = resolveAuthToken([], env);
13349
+ const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
13350
+ const cacheKey = `${userId ?? "anon"}|${resolveServerUrl(env)}`;
13351
+ return agentCatalogCache?.cacheKey === cacheKey && Date.now() - agentCatalogCache.at < AGENT_CATALOG_MAX_STALE_MS;
13352
+ }
13353
+ async function loadAgentCatalog(args) {
13354
+ return (await loadAgentCatalogWithNotices(args)).entries;
13355
+ }
13356
+ async function loadAgentCatalogWithNotices(args) {
13357
+ const env = args.env ?? process.env;
13358
+ const authToken = resolveAuthToken([], env);
13359
+ const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
13360
+ const cacheKey = `${userId ?? "anon"}|${resolveServerUrl(env)}`;
13361
+ const cached = agentCatalogCache?.cacheKey === cacheKey ? agentCatalogCache : null;
13362
+ if (cached && !args.fresh && Date.now() - cached.at < AGENT_CATALOG_MAX_STALE_MS) {
13363
+ const refreshStatus = getAgentCatalogRefreshStatus({ env });
13364
+ if (args.revalidateInBackground || Date.now() - cached.at >= AGENT_CATALOG_FRESH_MS) {
13365
+ refreshAgentCatalogInBackground(args, env, cacheKey);
13366
+ }
13367
+ if (args.currentKey && cached.entries.length > 1 && cached.entries[0]?.key !== args.currentKey) {
13368
+ const idx = cached.entries.findIndex((entry) => entry.key === args.currentKey);
13369
+ if (idx > 0) {
13370
+ return {
13371
+ entries: [
13372
+ cached.entries[idx],
13373
+ ...cached.entries.slice(0, idx),
13374
+ ...cached.entries.slice(idx + 1)
13375
+ ],
13376
+ refreshStatus,
13377
+ unavailableFavoriteCount: cached.unavailableFavoriteCount
13378
+ };
13379
+ }
13380
+ }
13381
+ return {
13382
+ entries: cached.entries,
13383
+ refreshStatus,
13384
+ unavailableFavoriteCount: cached.unavailableFavoriteCount
13385
+ };
13386
+ }
13387
+ let rawData;
13388
+ const generation = args.fresh ? ++agentCatalogGeneration : agentCatalogGeneration;
13389
+ const deadlineKind = args.fresh ? "foreground" : args.deadlineKind ?? "foreground";
13390
+ const inFlight2 = agentCatalogRawLoadInFlight.get(deadlineKind);
13391
+ if (inFlight2) {
13392
+ rawData = await inFlight2;
13393
+ } else {
13394
+ const promise = fetchRawCatalogData({ ...args, deadlineKind }, env);
13395
+ agentCatalogRawLoadInFlight.set(deadlineKind, promise);
13396
+ try {
13397
+ rawData = await promise;
13398
+ } finally {
13399
+ if (agentCatalogRawLoadInFlight.get(deadlineKind) === promise) {
13400
+ agentCatalogRawLoadInFlight.delete(deadlineKind);
13401
+ }
13402
+ }
13403
+ }
13404
+ const entries = mergeCatalogEntries(
13405
+ args.currentKey,
13406
+ resolveCatalogPlatformAgents(env),
13407
+ rawData.privateAgents,
13408
+ rawData.favoritedAtByKey
13409
+ );
13410
+ if (generation === agentCatalogGeneration) {
13411
+ lastRefresh = { cacheKey, status: rawData.status };
13412
+ }
13413
+ if (generation === agentCatalogGeneration && rawData.status === "success") {
13414
+ agentCatalogCache = {
13415
+ cacheKey,
13416
+ at: Date.now(),
13417
+ entries,
13418
+ unavailableFavoriteCount: rawData.unavailableFavoriteCount
13419
+ };
13420
+ }
13421
+ void mergeCatalogQuotas(entries, { env, fetchImpl: args.fetchImpl }).catch(() => {
13422
+ });
13423
+ return { entries, unavailableFavoriteCount: rawData.unavailableFavoriteCount, refreshStatus: rawData.status };
13424
+ }
13425
+ async function mergeCatalogQuotas(entries, args) {
13426
+ const fresh = await refreshSubscriptionQuotas({
13427
+ entries: entries.map((entry) => ({
13428
+ key: entry.key,
13429
+ ...entry.quota ? { quota: entry.quota } : {},
13430
+ probeable: entry.kind === "private"
13431
+ })),
13432
+ ...args.env ? { env: args.env } : {},
13433
+ ...args.fetchImpl ? { fetchImpl: args.fetchImpl } : {}
13434
+ });
13435
+ for (const entry of entries) {
13436
+ const quota = fresh[entry.key];
13437
+ if (quota) entry.quota = quota;
13438
+ }
13439
+ }
13440
+ function refreshAgentCatalogInBackground(args, env, cacheKey) {
13441
+ if (agentCatalogRefreshInFlight) return;
13442
+ const generation = agentCatalogGeneration;
13443
+ agentCatalogRefreshInFlight = fetchRawCatalogData(
13444
+ { ...args, deadlineKind: "background" },
13445
+ env
13446
+ ).then(async (rawData) => {
13447
+ if (generation !== agentCatalogGeneration) return;
13448
+ lastRefresh = { cacheKey, status: rawData.status };
13449
+ if (rawData.status !== "success") return;
13450
+ const entries = mergeCatalogEntries(
13451
+ args.currentKey,
13452
+ resolveCatalogPlatformAgents(env),
13453
+ rawData.privateAgents,
13454
+ rawData.favoritedAtByKey
13455
+ );
13456
+ await mergeCatalogQuotas(entries, { env, fetchImpl: args.fetchImpl });
13457
+ if (generation === agentCatalogGeneration) {
13458
+ agentCatalogCache = {
13459
+ cacheKey,
13460
+ at: Date.now(),
13461
+ entries,
13462
+ unavailableFavoriteCount: rawData.unavailableFavoriteCount
13463
+ };
13464
+ }
13465
+ }).catch(() => {
13466
+ if (generation === agentCatalogGeneration) lastRefresh = { cacheKey, status: "failed" };
13467
+ }).finally(() => {
13468
+ agentCatalogRefreshInFlight = null;
13469
+ });
13470
+ }
13471
+ async function prefillCatalogFromLocalDb(_args) {
13472
+ }
13473
+ function prefetchAgentCatalog(args) {
13474
+ void (async () => {
13475
+ await prefillCatalogFromLocalDb({ env: args.env, getDb: args.getDb }).catch(() => {
13476
+ });
13477
+ void loadAgentCatalog({ ...args, currentKey: "", deadlineKind: "background" }).catch(() => {
13478
+ });
13479
+ })();
13480
+ }
13481
+ async function fetchRawCatalogData(args, env) {
13482
+ const deadlineMs = resolveCatalogDeadlineMs(args.deadlineKind ?? "foreground", env);
13483
+ const fetchImpl = withFetchDeadline(args.fetchImpl ?? fetch, deadlineMs);
13484
+ const fallbackFetchImpl = args.fallbackFetchImpl ? withFetchDeadline(args.fallbackFetchImpl, deadlineMs) : void 0;
13485
+ const authToken = resolveAuthToken([], env);
13486
+ const userId = authToken ? parseUserIdFromAuthToken(authToken) : null;
13487
+ if (!authToken || !userId) {
13488
+ return { privateAgents: [], favoritedAtByKey: {}, unavailableFavoriteCount: 0, status: "success" };
13489
+ }
13490
+ const serverUrl = resolveServerUrl(env);
13491
+ const allServerUrls = resolveServerCandidates([], env, serverUrl);
13492
+ const serverUrls = (args.deadlineKind ?? "foreground") === "foreground" ? keepPrimaryServer(filterHealthyServers(allServerUrls), serverUrl) : allServerUrls;
13493
+ const fetchStartedAt = performance.now();
13494
+ let listedAgents = [];
13495
+ let catalogAuthoritative = false;
13496
+ let catalogAvailable = false;
13497
+ let favoritesFailed = false;
13498
+ const favoritesPromise = listFavoriteAgentIdsAcrossServers({
13499
+ authToken,
13500
+ fetchImpl,
13501
+ serverUrls,
13502
+ onFailure: () => {
13503
+ favoritesFailed = true;
13504
+ }
13505
+ }).catch(() => {
13506
+ favoritesFailed = true;
13507
+ return {};
13508
+ });
13509
+ try {
13510
+ const remoteResult = await listRemoteAgentsAcrossServers({
13511
+ authToken,
13512
+ fallbackFetchImpl,
13513
+ fetchImpl,
13514
+ serverUrls,
13515
+ userId
13516
+ });
13517
+ listedAgents = remoteResult.agents;
13518
+ catalogAvailable = true;
13519
+ catalogAuthoritative = remoteResult.failures.length === 0 && serverUrls.length === allServerUrls.length;
13520
+ recordServerSuccesses(serverUrls.filter(
13521
+ (url) => !remoteResult.failures.some((f) => f.serverUrl === url)
13522
+ ));
13523
+ recordServerFailures(remoteResult.failures);
13524
+ } catch {
13525
+ try {
13526
+ const localBudgetMs = Math.max(
13527
+ 500,
13528
+ deadlineMs - (performance.now() - fetchStartedAt)
13529
+ );
13530
+ let localTimer;
13531
+ try {
13532
+ listedAgents = await Promise.race([
13533
+ (async () => {
13534
+ const db = args.getDb ? await args.getDb() : await getReadableCliDb({ write: () => {
13535
+ } });
13536
+ return listLocalCachedAgents({ db, userId });
13537
+ })(),
13538
+ new Promise((_, reject) => {
13539
+ localTimer = setTimeout(
13540
+ () => reject(new Error("local catalog deadline exceeded")),
13541
+ localBudgetMs
13542
+ );
13543
+ })
13544
+ ]);
13545
+ catalogAvailable = true;
13546
+ } finally {
13547
+ if (localTimer) clearTimeout(localTimer);
13548
+ }
13549
+ } catch {
13550
+ try {
13551
+ listedAgents = await listRemoteAgents({
13552
+ authToken,
13553
+ fallbackFetchImpl,
13554
+ fetchImpl,
13555
+ serverUrl,
13556
+ userId,
13557
+ queryUserRecords,
13558
+ readDbRecord
13559
+ });
13560
+ catalogAvailable = true;
13561
+ } catch {
13562
+ listedAgents = [];
13563
+ }
13564
+ }
13565
+ }
13566
+ const privateAgents = listedAgents.map(listedAgentToCatalogEntry);
13567
+ const favoritedAtByKey = await favoritesPromise;
13568
+ for (const agent of listedAgents) {
13569
+ const favoritedAt = [agent.privateKey, agent.publicKey, agent.id].map((key) => favoritedAtByKey[key]).find((value) => value !== void 0);
13570
+ if (favoritedAt !== void 0) favoritedAtByKey[agent.privateKey] = favoritedAt;
13571
+ }
13572
+ const existingKeys = /* @__PURE__ */ new Set();
13573
+ for (const agent of listedAgents) {
13574
+ existingKeys.add(agent.privateKey);
13575
+ existingKeys.add(agent.publicKey);
13576
+ existingKeys.add(agent.id);
13577
+ }
13578
+ let unavailableFavoriteCount = 0;
13579
+ let orphanSkipped = false;
13580
+ await Promise.all(
13581
+ Object.keys(favoritedAtByKey).map(async (favKey) => {
13582
+ if (existingKeys.has(favKey)) return;
13583
+ const remainingMs = deadlineMs - (performance.now() - fetchStartedAt);
13584
+ if (remainingMs <= 0) {
13585
+ orphanSkipped = true;
13586
+ return;
13587
+ }
13588
+ try {
13589
+ let orphanTimer;
13590
+ const orphanDeadline = new Promise((_, reject) => {
13591
+ orphanTimer = setTimeout(
13592
+ () => reject(new Error("orphan hydrate deadline")),
13593
+ remainingMs
13594
+ );
13595
+ });
13596
+ try {
13597
+ const favRead = await Promise.race([
13598
+ readLiveDbRecordAfterTombstoneMerge({
13599
+ authToken,
13600
+ dbKey: favKey,
13601
+ fallbackFetchImpl,
13602
+ fetchImpl,
13603
+ serverUrls
13604
+ }),
13605
+ orphanDeadline
13606
+ ]);
13607
+ const record = favRead.record;
13608
+ if (!record || record.type && record.type !== "agent") return;
13609
+ const norm = normalizeListedAgent(record);
13610
+ if (!norm) return;
13611
+ if (existingKeys.has(norm.privateKey) || existingKeys.has(norm.publicKey) || existingKeys.has(norm.id)) {
13612
+ return;
13613
+ }
13614
+ existingKeys.add(norm.privateKey);
13615
+ existingKeys.add(norm.publicKey);
13616
+ existingKeys.add(norm.id);
13617
+ privateAgents.push(listedAgentToCatalogEntry(norm));
13618
+ } finally {
13619
+ if (orphanTimer) clearTimeout(orphanTimer);
13620
+ }
13621
+ } catch {
13622
+ unavailableFavoriteCount += 1;
13623
+ }
13624
+ })
13625
+ );
13626
+ const status = !catalogAvailable && favoritesFailed ? "failed" : catalogAuthoritative && !favoritesFailed && unavailableFavoriteCount === 0 && !orphanSkipped ? "success" : "degraded";
13627
+ return { privateAgents, favoritedAtByKey, unavailableFavoriteCount, status };
13628
+ }
13629
+ function renderAgentCatalogList(entries, currentKey, options) {
13630
+ const lines = ["Agents:"];
13631
+ entries.forEach((entry, index) => {
13632
+ const current = entry.key === currentKey ? " (current)" : "";
13633
+ const favorite = entry.favoritedAt ? " \u2605" : "";
13634
+ const detail = entry.description ? ` \u2014 ${entry.description}` : "";
13635
+ const quota = formatQuotaSummary(entry.quota, Date.now(), { model: entry.model });
13636
+ const trailing = quota ? ` [${quota}]` : detail;
13637
+ lines.push(
13638
+ ` ${String(index + 1).padStart(2)} ${entry.name.padEnd(18)} ${entry.model.padEnd(14)} ${formatAgentSourceLabel(entry)}${favorite}${trailing}${current}`
13639
+ );
13640
+ });
13641
+ lines.push("");
13642
+ const notice = formatUnavailableFavoritesNotice(
13643
+ options?.unavailableFavoriteCount ?? 0
13644
+ );
13645
+ if (notice) lines.push(notice);
13646
+ lines.push("Tip: run /switch in an interactive terminal to pick with \u2191\u2193.");
13647
+ return lines.join("\n");
13648
+ }
13649
+ function resolveEntryApiSource(entry) {
13650
+ if (entry.apiSource) return entry.apiSource;
13651
+ return entry.kind === "platform" ? "platform" : void 0;
13652
+ }
13653
+ function toSwitchTarget(entry) {
13654
+ const apiSource = resolveEntryApiSource(entry);
13655
+ return {
13656
+ name: entry.name,
13657
+ key: entry.key,
13658
+ model: entry.model,
13659
+ ...apiSource ? { apiSource } : {}
13660
+ };
13661
+ }
13662
+ function findAgentCatalogEntry(entries, rawTarget) {
13663
+ const target = rawTarget.trim();
13664
+ if (!target) return null;
13665
+ if (/^\d+$/.test(target)) {
13666
+ const entry = entries[Number(target) - 1];
13667
+ return entry ? toSwitchTarget(entry) : null;
13668
+ }
13669
+ const lower = target.toLowerCase();
13670
+ const byName = entries.find(
13671
+ (entry) => entry.name.toLowerCase() === lower || entry.key.toLowerCase() === lower || entry.key.toLowerCase().endsWith(`-${lower}`)
13672
+ );
13673
+ if (byName) return toSwitchTarget(byName);
13674
+ if (target.startsWith("agent-") || target.startsWith("agent-pub-")) {
13675
+ const builtin = builtinAgentCatalogEntryById(
13676
+ parseBuiltinPlatformAgentId(target) ?? parsePublicAgentId(target)
13677
+ );
13678
+ if (builtin) {
13679
+ return {
13680
+ name: builtin.name,
13681
+ key: target,
13682
+ model: builtin.model,
13683
+ apiSource: builtin.apiSource ?? "platform"
13684
+ };
13685
+ }
13686
+ return { name: target, key: target };
13687
+ }
13688
+ return null;
13689
+ }
13690
+ function lookupCachedAgentName(agentKey) {
13691
+ const trimmed = agentKey.trim();
13692
+ if (!trimmed) return void 0;
13693
+ const platform = PLATFORM_AGENTS.find(
13694
+ (p) => p.key === trimmed || p.key.toLowerCase() === trimmed.toLowerCase()
13695
+ );
13696
+ if (platform?.name) return platform.name;
13697
+ const builtin = builtinAgentCatalogEntryById(
13698
+ parseBuiltinPlatformAgentId(trimmed) ?? parsePublicAgentId(trimmed)
13699
+ );
13700
+ if (builtin?.name) return builtin.name;
13701
+ if (agentCatalogCache?.entries) {
13702
+ const direct = agentCatalogCache.entries.find(
13703
+ (entry) => entry.key === trimmed || entry.key.toLowerCase() === trimmed.toLowerCase()
13704
+ );
13705
+ if (direct?.name) return direct.name;
13706
+ const suffix = agentCatalogCache.entries.find(
13707
+ (entry) => entry.key.toLowerCase().endsWith(`-${trimmed.toLowerCase()}`) || trimmed.toLowerCase().endsWith(`-${entry.key.toLowerCase()}`)
13708
+ );
13709
+ if (suffix?.name) return suffix.name;
13710
+ }
13711
+ return void 0;
13712
+ }
13713
+
12771
13714
  // packages/cli/client/agentRunPlatformTools.ts
12772
13715
  var SERVER_PLATFORM_TOOL_NAMES = /* @__PURE__ */ new Set([
12773
13716
  "addTableRow",
@@ -13064,7 +14007,7 @@ function isBalanceExhaustedError(error) {
13064
14007
 
13065
14008
  // packages/cli/client/agentRun.ts
13066
14009
  async function loadRunLocalAgentTurn() {
13067
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-LVXPQ7QA.js");
14010
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-U54AKHXH.js");
13068
14011
  return runLocalAgentTurn;
13069
14012
  }
13070
14013
  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();
@@ -13203,6 +14146,22 @@ function wrapLoadAgentConfigWithModelOverride(adapter, targetAgentKey, override)
13203
14146
  }
13204
14147
  };
13205
14148
  }
14149
+ function wrapLoadAgentConfigWithReasoningEffortOverride(adapter, targetAgentKey, override) {
14150
+ return {
14151
+ ...adapter,
14152
+ loadAgentConfig: async (agentRef) => {
14153
+ const config = await adapter.loadAgentConfig(agentRef);
14154
+ if (!config || agentRef !== targetAgentKey) return config;
14155
+ const effective = resolveEffectiveReasoningEffortOverride({
14156
+ override,
14157
+ provider: config.provider,
14158
+ model: config.model,
14159
+ recordReasoningEffort: config.reasoning_effort
14160
+ });
14161
+ return withReasoningEffortOverride(config, effective);
14162
+ }
14163
+ };
14164
+ }
13206
14165
  var oauthChannelSkipReportedAgentKeys = /* @__PURE__ */ new Set();
13207
14166
  function resolveOAuthChannelOwnerSkip(agentConfig, options) {
13208
14167
  if (!agentConfig) return null;
@@ -13843,6 +14802,10 @@ function describeLocalRunFailure(message, rawError) {
13843
14802
  const details = parseContextLengthDetails(message);
13844
14803
  const shownMessage = details.requested && details.max ? t("contextLengthExceeded", details.requested, details.max) : details.max ? t("contextLengthExceededLimitOnly", details.max) : t("contextLengthExceededGeneric");
13845
14804
  return `[nolo] ${shownMessage}
14805
+ `;
14806
+ }
14807
+ if (/CLI authority broker upgrade requires exit/i.test(message)) {
14808
+ return `${RUN_UNAVAILABLE_PREFIX} (${stripDebugNoise(message)})
13846
14809
  `;
13847
14810
  }
13848
14811
  if (isCliAuthorityBrokerTimeoutError(rawError) || /CLI authority broker .* timed out/i.test(message)) {
@@ -14226,6 +15189,13 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
14226
15189
  options.agentKey,
14227
15190
  options.modelOverride
14228
15191
  ) : resolvedBaseAdapter;
15192
+ if (adapter2 && options.reasoningEffortOverride) {
15193
+ adapter2 = wrapLoadAgentConfigWithReasoningEffortOverride(
15194
+ adapter2,
15195
+ options.agentKey,
15196
+ options.reasoningEffortOverride
15197
+ );
15198
+ }
14229
15199
  if (adapter2) adapter2 = applyEphemeralIfRequested(options, adapter2);
14230
15200
  if (adapter2 && options.imageUrls?.length) {
14231
15201
  const imageAdapter = adapter2;
@@ -14394,6 +15364,32 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
14394
15364
  const durableAttachmentParts = ENABLE_REMOTE_ATTACHMENT_PART_WRITES ? localAttachmentParts : [];
14395
15365
  const hasDurableAttachments = durableAttachmentParts.length > 0;
14396
15366
  const runLocalAgentTurn = await loadRunLocalAgentTurn();
15367
+ const poolEntries = readCachedAgentCatalogEntries();
15368
+ const poolAgentConfig = poolEntries && poolEntries.length > 0 && userId ? await (async () => {
15369
+ try {
15370
+ return await adapter.loadAgentConfig(options.agentKey);
15371
+ } catch {
15372
+ return null;
15373
+ }
15374
+ })() : null;
15375
+ const poolIdentity = pickCallerPoolIdentityFromAgentConfig({
15376
+ agentConfig: poolAgentConfig,
15377
+ agentKey: options.agentKey,
15378
+ // --model 覆盖已在 adapter 层应用到 agentConfig,这里只是 config 未加载时的兜底。
15379
+ modelOverride: options.modelOverride?.model ?? null
15380
+ });
15381
+ const callerIsPoolTop = resolveLatchedCliCallerIsPoolTop({
15382
+ dialogId: currentDialogId,
15383
+ entries: poolEntries,
15384
+ agentKey: poolIdentity.agentKey,
15385
+ latchAgentKey: options.agentKey,
15386
+ latchModel: options.modelOverride?.model ?? null,
15387
+ model: poolIdentity.model ?? resolveAgentModelIdentity({
15388
+ agentKey: options.agentKey,
15389
+ agentName: options.agentName
15390
+ }).model ?? null,
15391
+ userId
15392
+ });
14397
15393
  const result = await runLocalAgentTurn({
14398
15394
  adapter,
14399
15395
  agentRef: options.agentKey,
@@ -14451,6 +15447,7 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
14451
15447
  userMessages: messages
14452
15448
  }) } : {},
14453
15449
  runKind: options.env.NOLO_AGENT_RUN_CHILD === "1" ? "subtask" : "interactive",
15450
+ ...callerIsPoolTop === void 0 ? {} : { callerIsPoolTop },
14454
15451
  // 展示能力由宿主声明(TUI=narrow),非交互 CLI/后台留空 → unknown;
14455
15452
  // 排版段只在能力已知时由 localLoop 注入,server 线不读该字段。
14456
15453
  ...options.responseViewport ? { responseViewport: options.responseViewport } : {},
@@ -15020,25 +16017,33 @@ function buildHostEnvironmentLayer(options) {
15020
16017
  var finiteCount = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : void 0;
15021
16018
  var isUsageObject = (usage) => Boolean(usage) && typeof usage === "object";
15022
16019
  var readInputTokens = (usage) => finiteCount(usage.input_tokens) ?? finiteCount(usage.prompt_tokens) ?? 0;
16020
+ var readOutputTokens = (usage) => finiteCount(usage.output_tokens) ?? finiteCount(usage.completion_tokens);
15023
16021
  var computeCacheHitRatio = (inputTokens, cachedTokens) => {
15024
16022
  if (cachedTokens === null) return null;
15025
16023
  if (!Number.isFinite(inputTokens) || inputTokens <= 0) return 0;
15026
16024
  return Math.round(cachedTokens / inputTokens * 1e4) / 1e4;
15027
16025
  };
15028
- var withRatio = (inputTokens, cachedTokens) => ({
16026
+ var withRatio = (inputTokens, cachedTokens, outputTokens) => ({
15029
16027
  input_tokens: inputTokens,
15030
16028
  cached_tokens: cachedTokens,
15031
- cache_hit_ratio: computeCacheHitRatio(inputTokens, cachedTokens)
16029
+ cache_hit_ratio: computeCacheHitRatio(inputTokens, cachedTokens),
16030
+ ...typeof outputTokens === "number" && Number.isFinite(outputTokens) ? { output_tokens: Math.max(0, Math.floor(outputTokens)) } : {}
15032
16031
  });
15033
16032
  var summarizeCacheUsage = (usage) => {
15034
16033
  if (!isUsageObject(usage)) return void 0;
15035
16034
  if (Object.keys(usage).length === 0) return void 0;
15036
- return withRatio(readInputTokens(usage), readCacheReadInputTokensOrNull(usage));
16035
+ return withRatio(
16036
+ readInputTokens(usage),
16037
+ readCacheReadInputTokensOrNull(usage),
16038
+ readOutputTokens(usage)
16039
+ );
15037
16040
  };
15038
16041
  var summarizeCacheUsageRecords = (records) => {
15039
16042
  if (!records || records.length === 0) return void 0;
15040
16043
  let inputTokens = 0;
15041
16044
  let cachedTokens = 0;
16045
+ let outputTokens = 0;
16046
+ let sawOutput = false;
15042
16047
  let sawUsage = false;
15043
16048
  for (const record of records) {
15044
16049
  const summary = summarizeCacheUsage(record?.usage);
@@ -15046,16 +16051,21 @@ var summarizeCacheUsageRecords = (records) => {
15046
16051
  sawUsage = true;
15047
16052
  inputTokens += summary.input_tokens;
15048
16053
  cachedTokens = cachedTokens === null || summary.cached_tokens === null ? null : cachedTokens + summary.cached_tokens;
16054
+ if (typeof summary.output_tokens === "number") {
16055
+ sawOutput = true;
16056
+ outputTokens += summary.output_tokens;
16057
+ }
15049
16058
  }
15050
16059
  if (!sawUsage) return void 0;
15051
- return withRatio(inputTokens, cachedTokens);
16060
+ return withRatio(inputTokens, cachedTokens, sawOutput ? outputTokens : void 0);
15052
16061
  };
15053
16062
  var mergeCacheUsageSummaries = (left, right) => {
15054
16063
  if (!left) return right;
15055
16064
  if (!right) return left;
15056
16065
  const inputTokens = left.input_tokens + right.input_tokens;
15057
16066
  const cachedTokens = left.cached_tokens === null || right.cached_tokens === null ? null : left.cached_tokens + right.cached_tokens;
15058
- return withRatio(inputTokens, cachedTokens);
16067
+ const outputTokens = typeof left.output_tokens === "number" && typeof right.output_tokens === "number" ? left.output_tokens + right.output_tokens : typeof left.output_tokens === "number" ? left.output_tokens : right.output_tokens;
16068
+ return withRatio(inputTokens, cachedTokens, outputTokens);
15059
16069
  };
15060
16070
 
15061
16071
  // packages/cli/agentRunDoD.ts
@@ -17412,7 +18422,8 @@ async function runAgentRunCommandImpl(args, deps) {
17412
18422
  if (hasRegistry && (parsed.runtimeKey?.trim() === "local" || locatedExecution?.state === "known")) {
17413
18423
  const implicitReadonlyHost = !parsed.runtimeKey && args.includes("--read-only") && locatedExecution?.state === "known" && locatedExecution.runtimeKey === "local" && locatedExecution.permissions.readOnly;
17414
18424
  if (parsed.runtimeKey?.trim() !== "local" && !implicitReadonlyHost) throw new Error("[local-writer-resource] child binding runtime mismatch");
17415
- await awaitLocalWriterChild(childRunId, parsed.cwd ?? process.cwd(), hostPolicy(), { env, homedir: deps.homedir, fs: deps.fs });
18425
+ const { blockedToolNames } = await awaitLocalWriterChild(childRunId, parsed.cwd ?? process.cwd(), hostPolicy(), { env, homedir: deps.homedir, fs: deps.fs });
18426
+ parsed.blockedToolNames = blockedToolNames;
17416
18427
  }
17417
18428
  if (hasRegistry && parsed.runtimeKey?.trim() !== "local" && locatedExecution?.state !== "known") reportRunProcessIdentity(childRunId, { env, homedir: deps.homedir, fs: deps.fs, now: deps.now });
17418
18429
  const processExit = deps.processExit ?? ((code) => process.exit(code));
@@ -17598,7 +18609,7 @@ async function runAgentRunCommandImpl(args, deps) {
17598
18609
  await readDbRecord({
17599
18610
  dbKey: agentKey,
17600
18611
  authToken: resolveAuthToken(args, env),
17601
- serverUrl: resolveServerUrl(env),
18612
+ serverUrl: resolveServerUrl2(env),
17602
18613
  fetchImpl: fetch
17603
18614
  }).catch(() => null)
17604
18615
  );
@@ -17631,7 +18642,7 @@ async function runAgentRunCommandImpl(args, deps) {
17631
18642
  if (parsed.skillRefs?.length) {
17632
18643
  const skills = [];
17633
18644
  const authToken = resolveAuthToken(args, env);
17634
- const serverUrl = resolveServerUrl(env);
18645
+ const serverUrl = resolveServerUrl2(env);
17635
18646
  for (const ref of parsed.skillRefs) {
17636
18647
  try {
17637
18648
  const resolved = await resolveSkillReference(ref, {
@@ -17746,7 +18757,8 @@ async function runAgentRunCommandImpl(args, deps) {
17746
18757
  if (hostRuntimeLocal && !parsed.background) {
17747
18758
  const policy = { ...hostPolicy(), ...skillAllowedToolOverride !== void 0 ? { allowedToolNames: skillAllowedToolOverride } : {} };
17748
18759
  if (hasRegistry) {
17749
- await awaitLocalWriterChild(childRunId, localRuntimeCwd, policy, { env, homedir: deps.homedir, fs: deps.fs });
18760
+ const { blockedToolNames } = await awaitLocalWriterChild(childRunId, localRuntimeCwd, policy, { env, homedir: deps.homedir, fs: deps.fs });
18761
+ parsed.blockedToolNames = blockedToolNames;
17750
18762
  } else if (!policy.readOnly) {
17751
18763
  childRunId = registerLocalForegroundWriter(localRuntimeCwd, policy, agentKey, { env, homedir: deps.homedir, fs: deps.fs, now: deps.now });
17752
18764
  hasRegistry = true;
@@ -17766,7 +18778,7 @@ async function runAgentRunCommandImpl(args, deps) {
17766
18778
  if (!deps.memoryRecallDisabled) {
17767
18779
  try {
17768
18780
  memoryPromptBlock = await resolveCliMemory({
17769
- serverUrl: resolveServerUrl(env),
18781
+ serverUrl: resolveServerUrl2(env),
17770
18782
  authToken: resolveAuthToken(args, env),
17771
18783
  agentKey: effectiveAgentKey,
17772
18784
  userInput: effectiveMessage,
@@ -17845,7 +18857,7 @@ async function runAgentRunCommandImpl(args, deps) {
17845
18857
  // 放在 buildRunOptions 这个唯一构造点上,首轮 / quota fallback / 队列 drain
17846
18858
  // 三处 runner(...) 调用自动一致;远端分支走 server 线,不读该字段。
17847
18859
  responseViewport: "unknown",
17848
- serverUrl: resolveServerUrl(env),
18860
+ serverUrl: resolveServerUrl2(env),
17849
18861
  message: formatTurnMessage(turnMessage),
17850
18862
  imageUrls,
17851
18863
  scriptDir: deps.scriptDir,
@@ -17895,7 +18907,9 @@ async function runAgentRunCommandImpl(args, deps) {
17895
18907
  runner({
17896
18908
  ...buildRunOptions(effectiveAgentKey),
17897
18909
  ...parsed.freshDialog ? { freshDialog: true } : {},
17898
- ...modelOverride ? { modelOverride } : {}
18910
+ ...modelOverride ? { modelOverride } : {},
18911
+ // `--reasoning-effort`:本次 run 的有效推理档覆盖(内存生效,不写回记录)。
18912
+ ...parsed.reasoningEffort ? { reasoningEffortOverride: parsed.reasoningEffort } : {}
17899
18913
  })
17900
18914
  );
17901
18915
  clearWatchdogs();
@@ -17964,7 +18978,9 @@ async function runAgentRunCommandImpl(args, deps) {
17964
18978
  runner({
17965
18979
  ...buildRunOptions(effectiveAgentKey, nextEntry.text),
17966
18980
  continueDialogId: result.dialogId,
17967
- ...modelOverride ? { modelOverride } : {}
18981
+ ...modelOverride ? { modelOverride } : {},
18982
+ // `--reasoning-effort`:本次 run 的有效推理档覆盖(内存生效,不写回记录)。
18983
+ ...parsed.reasoningEffort ? { reasoningEffortOverride: parsed.reasoningEffort } : {}
17968
18984
  })
17969
18985
  );
17970
18986
  clearWatchdogs();
@@ -18167,6 +19183,17 @@ export {
18167
19183
  preserveContextUsageWithoutReceipt,
18168
19184
  resolveContextUsage,
18169
19185
  renderTokenStatus,
19186
+ DEFAULT_TUI_AGENT_KEY,
19187
+ formatAgentSourceLabel,
19188
+ resolveCatalogPlatformAgents,
19189
+ formatUnavailableFavoritesNotice,
19190
+ hasWarmAgentCatalogCache,
19191
+ loadAgentCatalog,
19192
+ loadAgentCatalogWithNotices,
19193
+ prefetchAgentCatalog,
19194
+ renderAgentCatalogList,
19195
+ findAgentCatalogEntry,
19196
+ lookupCachedAgentName,
18170
19197
  redactSecrets,
18171
19198
  resolveCliColorEnabled,
18172
19199
  dimCliText,
@@ -18184,6 +19211,7 @@ export {
18184
19211
  applyDetectedBackground,
18185
19212
  renderSurfaceLine,
18186
19213
  surfaceBackgroundSequence,
19214
+ userBubbleSurfaceBackgroundSequence,
18187
19215
  themeText,
18188
19216
  tuiRenderThemeFingerprint,
18189
19217
  MAX_URL_LENGTH,