nolo-cli 0.11.0 → 0.12.0-alpha.10

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 (123) hide show
  1. package/{_executeModel-ZEDPX6OF.js → _executeModel-4F7VZR5U.js} +52 -50
  2. package/{action-AA4IJ5K2.js → action-OTOWUMPW.js} +8 -9
  3. package/{addContentAction-QYVO4SYP.js → addContentAction-JGBUVR7K.js} +7 -9
  4. package/{addDialogAgentAction-WVVKT5WQ.js → addDialogAgentAction-V6CL2UCF.js} +9 -10
  5. package/{agentDeleteCommand-RDPGYIWF.js → agentDeleteCommand-MMRSG6AB.js} +39 -28
  6. package/{agentEmailCommands-2HJJKS5F.js → agentEmailCommands-YFVKOGM7.js} +65 -62
  7. package/{agentListCommands-HFEVV3ZW.js → agentListCommands-2PZHIQ3I.js} +128 -31
  8. package/{agentMachineCommands-25ZOENJU.js → agentMachineCommands-55UUZNHF.js} +38 -26
  9. package/{agentPullCommand-GOL2S4W2.js → agentPullCommand-KRBRIFIY.js} +7 -7
  10. package/{agentRecordCommands-GTCOAM3L.js → agentRecordCommands-BTP3OAPL.js} +57 -54
  11. package/{agentRunCommand-YBS3JDLD.js → agentRunCommand-AA4QLRQZ.js} +60 -59
  12. package/{agentRunControl-K4VKNEHF.js → agentRunControl-IX4F5W2C.js} +3 -3
  13. package/{agentRuntimeLocal-UQBMQI2M.js → agentRuntimeLocal-QDJCBXM2.js} +31 -15
  14. package/{agentSlice-6EKOBCCS.js → agentSlice-6JAJOU3X.js} +8 -9
  15. package/{authCommand-O2OWACN4.js → authCommand-DMW336GT.js} +15 -15
  16. package/{authCommands-H7365TZP.js → authCommands-GH5T6RYV.js} +6 -6
  17. package/{chunk-E4HNJSHC.js → chunk-2BVGERJ2.js} +81 -19
  18. package/{chunk-LP65VRCI.js → chunk-3MI5LDDU.js} +6 -6
  19. package/{chunk-OPZYGHUC.js → chunk-3WGLLTK4.js} +59 -1
  20. package/{chunk-KJR5KAUQ.js → chunk-3XF6LCCN.js} +20 -7
  21. package/{chunk-PXZAAB4L.js → chunk-4LG74DRG.js} +4 -4
  22. package/{chunk-2FTTDCD4.js → chunk-4ON5AV72.js} +2 -1
  23. package/{chunk-IWX4UW2E.js → chunk-524BDL33.js} +89 -8
  24. package/{chunk-ISNCLGUZ.js → chunk-5NBHQD4D.js} +4 -3
  25. package/{chunk-ZPRK73XY.js → chunk-5S4SWV5G.js} +51 -38
  26. package/{chunk-EVZKZF32.js → chunk-5V524MHX.js} +195 -78
  27. package/{chunk-CKOJQDKR.js → chunk-7JJCGV7N.js} +146 -3
  28. package/{chunk-NEM67FX7.js → chunk-ARSC56DC.js} +1 -1
  29. package/{chunk-AFON4QUU.js → chunk-AS3ZQ3O2.js} +19 -28
  30. package/{chunk-4SOKXIW4.js → chunk-B4KT7RN2.js} +10 -13
  31. package/chunk-BYXBJQAS.js +0 -0
  32. package/{chunk-PXQN7IBQ.js → chunk-C3BFP57W.js} +95 -2
  33. package/{chunk-AEZAORLG.js → chunk-CGDQDXKZ.js} +5 -5
  34. package/{chunk-MQI77IRB.js → chunk-DPFWKRHG.js} +2 -2
  35. package/{chunk-TACHTH5D.js → chunk-EIMX5ER5.js} +18 -18
  36. package/{chunk-5MOUAAMK.js → chunk-FSUZIGIG.js} +197 -2578
  37. package/{chunk-FXXSGWAJ.js → chunk-H5Y2H2N6.js} +1 -1
  38. package/chunk-IKXL2HZ3.js +70 -0
  39. package/{chunk-QNMFBBZK.js → chunk-IVAOVLM7.js} +1 -1
  40. package/chunk-JFANOO7I.js +2274 -0
  41. package/{chunk-YPRZSPF3.js → chunk-JKWWVF2I.js} +1 -1
  42. package/{chunk-3NSIQZZ6.js → chunk-JU7J7EAV.js} +45 -45
  43. package/{chunk-X2S7JTIG.js → chunk-KWBH4RAL.js} +1280 -137
  44. package/{chunk-OUI3ZHYD.js → chunk-LUKQQJFL.js} +39 -2
  45. package/{chunk-BX6U3ETE.js → chunk-MG6BVV3T.js} +320 -102
  46. package/{chunk-L53FGHA4.js → chunk-MQRZ5QUH.js} +1 -1
  47. package/{chunk-2W2VYVI5.js → chunk-MZHSAPZP.js} +675 -177
  48. package/{chunk-YOCHZD7D.js → chunk-NCGFB7NN.js} +5 -3
  49. package/{chunk-DWGAEFJL.js → chunk-O4FOPRCP.js} +1 -1
  50. package/chunk-OGGHETUE.js +4900 -0
  51. package/{chunk-PNEW2Z3T.js → chunk-OHEKYYJF.js} +7 -7
  52. package/chunk-OOIN7HSO.js +146 -0
  53. package/{chunk-SV5MWASH.js → chunk-OPM2DE2J.js} +12 -12
  54. package/{chunk-5OIFWVX7.js → chunk-QJSTNKJY.js} +1 -1
  55. package/{chunk-C4FTUXVF.js → chunk-QLUFR47U.js} +11 -1
  56. package/{chunk-LAX2JSTX.js → chunk-QUHUVG6Y.js} +20 -2
  57. package/{chunk-D6OQHXVG.js → chunk-RQSOAMPJ.js} +22 -6
  58. package/{chunk-ZEYDOXHF.js → chunk-RUGEW4P7.js} +1515 -884
  59. package/{chunk-GBDSZATH.js → chunk-RWO5DGXI.js} +3 -3
  60. package/{chunk-S3GS2PRL.js → chunk-TA7VKOHU.js} +613 -70
  61. package/{chunk-XYZA7S7V.js → chunk-TQYYGE6G.js} +6 -6
  62. package/{chunk-YTBMA7NO.js → chunk-TYPHUVK5.js} +70 -8
  63. package/{chunk-4ZDM73SD.js → chunk-V2J635L5.js} +1 -1
  64. package/{chunk-C2MDQQ4O.js → chunk-VBSWHE5W.js} +1 -1
  65. package/{chunk-O26GI2JP.js → chunk-VKG4HXYV.js} +39 -8
  66. package/{chunk-IPYUUY4E.js → chunk-WPHL6ALY.js} +1 -1
  67. package/{chunk-7D3JY6C2.js → chunk-WVTBAALN.js} +64 -5
  68. package/{chunk-XFOLQLDN.js → chunk-XHQWJUW4.js} +2 -2
  69. package/{chunk-Q3UKJVU4.js → chunk-Y5P3ZRGC.js} +10 -10
  70. package/{chunk-KQQVGRA3.js → chunk-YUMYYXPI.js} +53 -183
  71. package/cliEnvHelpers-VYC2OPTB.js +30 -0
  72. package/{createAgentAutomationAction-LTI5QU35.js → createAgentAutomationAction-4NY4JLOK.js} +26 -26
  73. package/{createDialogAction-OJJ7L3L3.js → createDialogAction-I5WUWFJ6.js} +26 -26
  74. package/{createPageAction-5MXWVRGY.js → createPageAction-HFTIQ7TW.js} +26 -26
  75. package/{dbSlice-RQFQQVHT.js → dbSlice-J4PUZ6Y5.js} +6 -7
  76. package/{deleteFile-7XP5BGC7.js → deleteFile-M7UNIUOO.js} +4 -4
  77. package/{dialogCommands-JTJ3RPPW.js → dialogCommands-SVXRJFZS.js} +34 -23
  78. package/{dialogSlice-OWROKURJ.js → dialogSlice-35LA3ZRG.js} +26 -26
  79. package/{docCreateCommands-WJBEW2V7.js → docCreateCommands-Z7RIAYKQ.js} +34 -23
  80. package/{docDeleteCommands-BVEHJOY5.js → docDeleteCommands-NEYHUVZF.js} +35 -25
  81. package/{docReadCommands-NEWOZIJV.js → docReadCommands-I4US2SDE.js} +34 -23
  82. package/{docStore-3DXRYBMD.js → docStore-3CP2IO6M.js} +25 -25
  83. package/{docUpdateCommands-C7WHT7UU.js → docUpdateCommands-UU5HQBRP.js} +34 -23
  84. package/fetchMessages-KTNM7QAR.js +1 -1
  85. package/{getPricing-3E6UNPKL.js → getPricing-UGDJHI7M.js} +7 -3
  86. package/{handleSendMessageAction-B5PRR7BE.js → handleSendMessageAction-FWTLQGOZ.js} +30 -30
  87. package/index.js +77 -76
  88. package/{localDialogRead-YSKFFRTT.js → localDialogRead-2VRI24F4.js} +1 -1
  89. package/{machineCommands-IIIREAEK.js → machineCommands-STHZKBDJ.js} +64 -61
  90. package/{machineWsRunDispatch-3SIU6ILW.js → machineWsRunDispatch-7YHT4TPT.js} +56 -53
  91. package/{memoryCommands-O4MIPIWQ.js → memoryCommands-AFMES3LN.js} +5 -5
  92. package/{models-4OPOOLFS.js → models-LSCRJJ6P.js} +2 -2
  93. package/package.json +1 -1
  94. package/{read-QJNKRROM.js → read-2MIMRBZ2.js} +4 -4
  95. package/{readDocTool-H6X6KO6X.js → readDocTool-QHVGQHUJ.js} +1 -1
  96. package/{readlineWorkspace-HGP3I3OC.js → readlineWorkspace-OMRWYMB6.js} +1279 -716
  97. package/{removeDialogAgentAction-TCT35SOF.js → removeDialogAgentAction-XUZYQBV4.js} +13 -13
  98. package/{runAgentClientLoop-EFM4PTVI.js → runAgentClientLoop-FP2K33ZO.js} +47 -46
  99. package/{runtimeDoctorCommands-ID43Z7VX.js → runtimeDoctorCommands-QNF3J3UV.js} +6 -6
  100. package/{setDialogExtraReferencesAction-CGYLZMFH.js → setDialogExtraReferencesAction-PTAIFKGM.js} +9 -10
  101. package/{setPrimaryDialogAgentAction-F6BFQDJU.js → setPrimaryDialogAgentAction-HRFTDB44.js} +13 -13
  102. package/{settingSlice-2I5HMG47.js → settingSlice-VGRJUSE5.js} +7 -8
  103. package/{skillDiscovery-UGSQGX2U.js → skillDiscovery-6M2BZUFN.js} +3 -3
  104. package/{spaceCommands-MT7BWCIL.js → spaceCommands-GN73BCOB.js} +38 -29
  105. package/{spaceSlice-BS5TSW3W.js → spaceSlice-WTFNKOVA.js} +30 -26
  106. package/{streamAgentChatTurn-I3VBFNR3.js → streamAgentChatTurn-HBAQQVNK.js} +442 -130
  107. package/{toolApiClient-C7P7YSE4.js → toolApiClient-QI3YBNWB.js} +2 -2
  108. package/{tools-XSD2BOEN.js → tools-TPQYTLQZ.js} +34 -33
  109. package/{tuiSummaryLlmCaller-32NRHTT2.js → tuiSummaryLlmCaller-XDC7WG4K.js} +11 -7
  110. package/{updateCommands-VOSPKXFF.js → updateCommands-XZDOOYFH.js} +13 -5
  111. package/{updateDialogTitleAction-7FYNJOGP.js → updateDialogTitleAction-AWXNPUQJ.js} +30 -29
  112. package/chunk-AZPCASRE.js +0 -36
  113. package/chunk-BBYVOSU2.js +0 -792
  114. package/chunk-DCOA4QSN.js +0 -105
  115. package/chunk-UAD2WT54.js +0 -64
  116. package/{chunk-JK7VW2FN.js → chunk-5MIDPSSK.js} +3 -3
  117. package/{chunk-5CS33IBL.js → chunk-PDL2AV3E.js} +3 -3
  118. package/{chunk-5MMZUWSG.js → chunk-TOILAPLH.js} +5 -5
  119. package/{chunk-OOM6SJNR.js → chunk-TSUJOM6N.js} +6 -6
  120. package/{db-6QED3ZVO.js → db-HCJ5PRB5.js} +3 -3
  121. package/{offlineMarxistsAgentCommand-BCPJITJL.js → offlineMarxistsAgentCommand-5OOWZLJI.js} +3 -3
  122. package/{tableCommands-M3DJUETS.js → tableCommands-E4SQWDOX.js} +6 -6
  123. package/{understanding-ZOESBLF3.js → understanding-3CUQQ6SV.js} +3 -3
@@ -1,6 +1,3 @@
1
- import {
2
- resolveMachineId
3
- } from "./chunk-6HYVJV7B.js";
4
1
  import {
5
2
  buildLocalRunEnv,
6
3
  isFullstackCodingAgentRef,
@@ -11,10 +8,17 @@ import {
11
8
  writeUsage
12
9
  } from "./chunk-3QAF2LTL.js";
13
10
  import {
11
+ resolveMachineId
12
+ } from "./chunk-6HYVJV7B.js";
13
+ import {
14
+ agentRunCardLabels,
14
15
  createCliCallAgentToolExecutor,
15
16
  createCliLocalRuntimeAdapter,
16
- isBuiltinNoloAgentRef
17
- } from "./chunk-X2S7JTIG.js";
17
+ getCliLocale,
18
+ isBuiltinNoloAgentRef,
19
+ t,
20
+ toolLabel
21
+ } from "./chunk-KWBH4RAL.js";
18
22
  import {
19
23
  CliProviderQuotaError
20
24
  } from "./chunk-CMKUBIGW.js";
@@ -24,10 +28,10 @@ import {
24
28
  import {
25
29
  readDbRecord,
26
30
  resolveAgentRecordFromHybridStore
27
- } from "./chunk-AEZAORLG.js";
31
+ } from "./chunk-CGDQDXKZ.js";
28
32
  import {
29
33
  normalizeAgentHandle
30
- } from "./chunk-C2MDQQ4O.js";
34
+ } from "./chunk-VBSWHE5W.js";
31
35
  import {
32
36
  NOLO_PROJECT_MANAGER_AGENT_KEY,
33
37
  isLocalCliAgentKey
@@ -36,78 +40,69 @@ import {
36
40
  applyModelLayerOverride,
37
41
  buildModelLayerOverride
38
42
  } from "./chunk-LTRXGFMS.js";
43
+ import {
44
+ formatAgentListCard,
45
+ formatListRunsCard,
46
+ formatNotFoundRunCard,
47
+ formatStartRunCard,
48
+ formatStatusRunCard,
49
+ formatStopRunCard,
50
+ isAgentRunTerminalStatus
51
+ } from "./chunk-MZHSAPZP.js";
39
52
  import {
40
53
  isGatewayHttpStatus
41
- } from "./chunk-D6OQHXVG.js";
54
+ } from "./chunk-RQSOAMPJ.js";
42
55
  import {
43
56
  buildMemorySubjectsForAgent,
44
57
  resolveAgentMemoryPolicy
45
- } from "./chunk-E4HNJSHC.js";
58
+ } from "./chunk-2BVGERJ2.js";
46
59
  import {
47
60
  parseExternalSkillMarkdown,
48
61
  parseSkillDocProtocol
49
62
  } from "./chunk-VC6OZXO5.js";
50
63
  import {
51
- getModelContextWindow,
64
+ API_REPORTED_COST_MULTIPLIER,
65
+ normalizeUsage,
52
66
  parseUiAskChoiceContent
53
- } from "./chunk-5MOUAAMK.js";
54
- import {
55
- parsePositiveFiniteNumberOrFallback
56
- } from "./chunk-Y5GCAMGP.js";
57
- import {
58
- touchMemoryItemsInDb
59
- } from "./chunk-HNW7IJSK.js";
60
- import {
61
- chooseMemoryOwners,
62
- loadMemoryCandidatesFromDb
63
- } from "./chunk-XENYHRUE.js";
64
- import {
65
- readPipeText,
66
- spawnProcess
67
- } from "./chunk-IDZTNRP2.js";
67
+ } from "./chunk-FSUZIGIG.js";
68
68
  import {
69
69
  buildSkillDiscoveryContextBlock
70
- } from "./chunk-AFON4QUU.js";
71
- import {
72
- buildMemoryOverlayLayer,
73
- buildMemoryUseGuidanceLayer
74
- } from "./chunk-C4FTUXVF.js";
70
+ } from "./chunk-AS3ZQ3O2.js";
75
71
  import {
76
72
  buildPlatformChatCompletionRequest,
77
73
  parsePlatformChatCompletionData
78
- } from "./chunk-ZPRK73XY.js";
74
+ } from "./chunk-5S4SWV5G.js";
79
75
  import {
80
76
  resolveAgentRuntimeConfigFromRecord
81
- } from "./chunk-YOCHZD7D.js";
77
+ } from "./chunk-NCGFB7NN.js";
82
78
  import {
83
79
  LOCAL_AGENT_CONFIG_MISSING_CODE,
84
80
  LOCAL_TURN_ABORTED_CODE,
85
81
  readActionGate,
86
82
  readCommandActionGatePayload
87
- } from "./chunk-S3GS2PRL.js";
83
+ } from "./chunk-TA7VKOHU.js";
88
84
  import {
89
85
  resolvePlatformChatCompletionsEndpoint
90
- } from "./chunk-YTBMA7NO.js";
86
+ } from "./chunk-TYPHUVK5.js";
87
+ import {
88
+ DEFAULT_CONTEXT_WINDOW,
89
+ getModelContextWindow
90
+ } from "./chunk-JFANOO7I.js";
91
91
  import {
92
92
  clipCompactText
93
93
  } from "./chunk-5MMAK75Q.js";
94
94
  import {
95
95
  findModelConfig
96
- } from "./chunk-BBYVOSU2.js";
96
+ } from "./chunk-OGGHETUE.js";
97
97
  import {
98
- asTrimmedLowercaseString
99
- } from "./chunk-QSJ3HFEF.js";
100
- import {
101
- compactWhitespace
102
- } from "./chunk-DWLEOOGR.js";
98
+ buildMemoryOverlayLayer,
99
+ buildMemoryUseGuidanceLayer
100
+ } from "./chunk-QLUFR47U.js";
103
101
  import {
104
102
  createRunActivityTracker,
105
103
  finalizeRunRecord,
106
104
  spawnLocalBackgroundRun
107
- } from "./chunk-2FTTDCD4.js";
108
- import {
109
- resolveAuthToken
110
- } from "./chunk-ISNCLGUZ.js";
105
+ } from "./chunk-4ON5AV72.js";
111
106
  import {
112
107
  toErrorMessage
113
108
  } from "./chunk-HNMXYYJR.js";
@@ -115,14 +110,36 @@ import {
115
110
  getDefaultCliLocalRuntimeDb
116
111
  } from "./chunk-H33743XH.js";
117
112
  import {
113
+ touchMemoryItemsInDb
114
+ } from "./chunk-HNW7IJSK.js";
115
+ import {
116
+ chooseMemoryOwners,
117
+ loadMemoryCandidatesFromDb
118
+ } from "./chunk-XENYHRUE.js";
119
+ import {
120
+ compactWhitespace
121
+ } from "./chunk-DWLEOOGR.js";
122
+ import {
123
+ readPipeText,
124
+ spawnProcess
125
+ } from "./chunk-IDZTNRP2.js";
126
+ import {
127
+ parsePositiveFiniteNumberOrFallback
128
+ } from "./chunk-Y5GCAMGP.js";
129
+ import {
130
+ asTrimmedLowercaseString
131
+ } from "./chunk-QSJ3HFEF.js";
132
+ import {
133
+ BUILTIN_NOLO_AGENT_KEY,
118
134
  PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY,
119
- PUBLIC_DEEPSEEK_V4_PRO_AGENT_KEY,
120
- PUBLIC_GLM_52_AGENT_KEY,
121
135
  PUBLIC_KIMI_K26_IMAGE_AGENT_KEY
122
- } from "./chunk-XFOLQLDN.js";
136
+ } from "./chunk-XHQWJUW4.js";
123
137
  import {
124
138
  asTrimmedString
125
139
  } from "./chunk-3EUW3WEO.js";
140
+ import {
141
+ resolveAuthToken
142
+ } from "./chunk-5NBHQD4D.js";
126
143
  import {
127
144
  isLoopbackUrl
128
145
  } from "./chunk-4SN6J65J.js";
@@ -130,7 +147,242 @@ import {
130
147
  asOptionalTrimmedString
131
148
  } from "./chunk-G3SUCT4W.js";
132
149
 
150
+ // packages/agent-runtime/quickChatIntentCore.ts
151
+ var INTENT_MODEL = "deepseek-v4-flash";
152
+ var INTENT_PROVIDER = "deepseek";
153
+ var QUICK_CHAT_INTENT_TIMEOUT_MS = 4e3;
154
+ var SHORT_GREETING_MAX_LENGTH = 20;
155
+ var SHORT_GREETING_PATTERN = /^(?:hi|hello|hey|hiya|yo|sup|howdy|嗨|哈喽|哈囉|你好|您好|在吗|在嘛|喂|早上好|中午好|下午好|晚上好|拜拜|再见|谢谢|thanks|thx|ok|好的|收到|了解)[!.。,、~~]?$/iu;
156
+ var VALID_QUICK_CHAT_SKILLS = /* @__PURE__ */ new Set([
157
+ "table",
158
+ "doc",
159
+ "code",
160
+ "pagebuilder"
161
+ ]);
162
+ function isShortGreeting(text) {
163
+ const trimmed = text.trim();
164
+ if (!trimmed) return false;
165
+ if (trimmed.length > SHORT_GREETING_MAX_LENGTH) return false;
166
+ return SHORT_GREETING_PATTERN.test(trimmed);
167
+ }
168
+ var COMPLEXITY_SIMPLE_MAX_LENGTH = 80;
169
+ var COMPLEXITY_MEDIUM_MAX_LENGTH = 500;
170
+ var COMPLEXITY_KEYWORDS = /为什么|如何|分析|对比|比较|设计|架构|实现|原理|推导|评价|区别|关系|影响|优化|重构/;
171
+ var COMPLEXITY_CODE_BLOCK = /```[\s\S]*```/;
172
+ function estimateComplexity(text) {
173
+ const trimmed = text.trim();
174
+ const len = trimmed.length;
175
+ if (len > COMPLEXITY_MEDIUM_MAX_LENGTH) return "complex";
176
+ if (COMPLEXITY_CODE_BLOCK.test(trimmed)) return "complex";
177
+ if (len > COMPLEXITY_SIMPLE_MAX_LENGTH) return "medium";
178
+ if (COMPLEXITY_KEYWORDS.test(trimmed)) return "medium";
179
+ return "simple";
180
+ }
181
+ var TIER_DESCRIPTIONS = {
182
+ flash: "\u5FEB\u901F\u7B80\u5355\uFF1A\u95EE\u5019\u3001\u95F2\u804A\u3001\u5FEB\u901F\u95EE\u7B54\u3001\u7FFB\u8BD1\u3001\u77ED\u6587",
183
+ balanced: "\u5E73\u8861\u63A8\u7406\uFF1A\u5206\u6790\u3001\u4E2D\u7B49\u957F\u5EA6\u5199\u4F5C\u3001\u4EE3\u7801\u3001\u63A8\u7406\uFF08\u5F53\u524D\u8DEF\u7531\u81F3 DeepSeek V4 Flash\uFF09",
184
+ quality: "\u9AD8\u8D28\u91CF\u6DF1\u5EA6\uFF1A\u590D\u6742\u63A8\u7406\u3001\u957F\u6587\u3001\u67B6\u6784\u8BBE\u8BA1\u3001\u6DF1\u5EA6\u5206\u6790\uFF08\u5F53\u524D\u8DEF\u7531\u81F3 DeepSeek V4 Flash\uFF09"
185
+ };
186
+ function buildQuickChatIntentSystemPrompt(tierAgents) {
187
+ const agentList = tierAgents.map((t2) => ` - "${t2.agentKey}"\uFF1A${t2.description}`).join("\n");
188
+ return `\u4F60\u662F\u4E00\u4E2A\u610F\u56FE\u8DEF\u7531\u5668\u3002\u6839\u636E\u7528\u6237\u6D88\u606F\uFF0C\u5224\u65AD\u5E94\u8BE5\u4EA4\u7ED9\u54EA\u4E2A agent \u5904\u7406\u3002
189
+
190
+ \u53EF\u9009 agent \u5217\u8868\uFF08agentKey \u4E0E\u63CF\u8FF0\uFF09\uFF1A
191
+ ${agentList}
192
+
193
+ \u5224\u65AD\u539F\u5219\uFF08\u9ED8\u8BA4\u504F\u5411\u901A\u7528\u6863\u4F4D\uFF1B\u4E13\u804C agent \u5728\u660E\u786E\u5339\u914D\u65F6\u4F7F\u7528\uFF1B**\u7F16\u7801/\u672C\u5730\u4ED3\u5E93\u4EFB\u52A1\u8D70\u901A\u7528\u6863 + needsWorkspace=true**\uFF09\uFF1A
194
+ - \u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0C**\u9664\u975E\u7528\u6237\u660E\u786E\u8868\u8FBE\u8981\u5EFA\u5E94\u7528/\u5EFA Agent/\u63D0\u4EA4\u53CD\u9988/\u591A Agent \u7F16\u6392**\uFF0C\u5426\u5219\u9009\u901A\u7528\u6863\u4F4D\uFF08flash/balanced/quality\uFF09\uFF1A
195
+ - \u7B80\u5355\u95EE\u5019\u3001\u95F2\u804A\u3001\u5FEB\u901F\u95EE\u7B54\u3001\u7FFB\u8BD1\u3001\u77ED\u6587 \u2192 \u9009 flash \u6863
196
+ - \u9700\u8981\u63A8\u7406\u3001\u5206\u6790\u3001\u4E2D\u7B49\u957F\u5EA6\u5199\u4F5C\u3001\u666E\u901A\u4EE3\u7801\u89E3\u91CA/\u67B6\u6784\u95EE\u7B54 \u2192 \u9009 balanced \u6863
197
+ - \u590D\u6742\u63A8\u7406\u3001\u957F\u6587\u3001\u67B6\u6784\u8BBE\u8BA1\u3001\u6DF1\u5EA6\u5206\u6790 \u2192 \u9009 quality \u6863
198
+ - **\u660E\u786E\u7F16\u7801\u4EFB\u52A1\uFF08\u5B9E\u73B0\u529F\u80FD\u3001\u4FEE bug\u3001refactor\u3001\u5199/\u8865\u6D4B\u8BD5\u3001\u8DD1 build/tests/ci\uFF09\u6216\u67E5\u770B\u672C\u673A\u4ED3\u5E93/\u4EE3\u7801\u72B6\u6001\uFF08git/\u5206\u652F/commit/\u672C\u5730\u4E0E\u8FDC\u7A0B\u5DEE\u8DDD/\u672A\u63D0\u4EA4\u6539\u52A8\u7B49\uFF09** \u2192 \u9009 balanced \u6216 quality \u6863\uFF08\u6309\u590D\u6742\u5EA6\uFF1B**\u4E0D\u8981\u9009 flash**\uFF09\uFF0C\u4E14 needsWorkspace=true
199
+ - \u4E13\u804C agent \u8DEF\u7531\u89C4\u5219\uFF08\u6709\u660E\u786E\u5339\u914D\u65F6\u4F7F\u7528\uFF09\uFF1A
200
+ - \u8981\u63D0\u4EA4/\u8BB0\u5F55 bug\u3001\u4F53\u9A8C\u95EE\u9898\u3001\u6570\u636E\u5F02\u5E38\u3001\u4EA7\u54C1\u5EFA\u8BAE\uFF0C\u6216\u53E3\u8BED\u5982\u300C\u60F3\u53CD\u9988\u4E00\u4E9B\u95EE\u9898\u300D\u300C\u53CD\u9988\u4E00\u4E0B\u300D\u2192 \u9009\u610F\u89C1\u53CD\u9988\u4E13\u804C agent
201
+ - \u8981\u65B0\u5EFA\u6216\u5B9A\u5236 AI/Agent/\u667A\u80FD\u4F53\u52A9\u624B\uFF08\u542B\u914D\u7F6E\u5DE5\u5177\u3001\u77E5\u8BC6\u3001\u786E\u8BA4\u521B\u5EFA\uFF09\u2192 \u9009\u521B\u5EFA Agent \u4E13\u804C agent
202
+ - \u8981\u505A/\u6539/\u53D1\u5E03\u7F51\u7AD9\u3001\u7F51\u9875\u3001\u5C0F\u5E94\u7528\u3001\u9884\u7EA6\u9875\u3001\u535A\u5BA2\u3001\u770B\u677F \u2192 \u9009\u5E94\u7528\u6784\u5EFA\u4E13\u804C agent
203
+ - \u8981\u6D3E\u591A\u4E2A agent\u3001\u591A agent \u5E76\u884C\u3001\u62C6\u6210\u4EFB\u52A1\u540E\u53F0\u6267\u884C\u3001\u591A\u4E2A agent review\u3001\u8BA9\u4E0D\u540C agent \u8BA8\u8BBA/\u4F1A\u5546 \u2192 \u9009\u591A Agent \u7F16\u6392\u4E13\u804C agent\uFF08\u663E\u5F0F multi-agent \u4F18\u5148\uFF09
204
+ - **\u62FF\u4E0D\u51C6\u65F6**\uFF1A\u7EAF\u95F2\u804A\u9009 flash\uFF1B**\u82E5\u6CBE\u8FB9\u672C\u5730\u4ED3\u5E93/\u5F53\u524D\u4EE3\u7801\u72B6\u6001\uFF0C\u9009 balanced/quality + needsWorkspace=true**\u3002
205
+
206
+ \u540C\u65F6\u5224\u65AD\u672C\u8F6E\u662F\u5426\u9700\u8981\u6CE8\u5165\u300C\u5DE5\u4F5C\u533A\u53EA\u8BFB\u5DE5\u5177\u300D\uFF08listFiles/globFiles/searchFiles/readFile/execShell \u7B49\uFF09\uFF1A
207
+ - needsWorkspace=true \u7684\u573A\u666F\uFF1A\u7528\u6237\u8981\u8BFB/\u6539/\u5206\u6790\u6587\u4EF6\u6216\u4EE3\u7801\u3001\u63D0\u5230\u4E86\u6587\u4EF6\u8DEF\u5F84/\u6269\u5C55\u540D\uFF08.md/.csv/.ts \u7B49\uFF09\u3001\u63D0\u5230\u5DE5\u4F5C\u533A/\u4EE3\u7801\u5E93/\u4ED3\u5E93/\u76EE\u5F55/git/\u5206\u652F\u3001\u8981\u770B\u5F53\u524D\u4EE3\u7801\u6216\u4ED3\u5E93\u72B6\u6001\u3001\u672C\u5730\u641C\u7D22/\u67E5\u770B\u4EE3\u7801\u3002
208
+ - needsWorkspace=false \u7684\u573A\u666F\uFF1A\u901A\u7528\u77E5\u8BC6\u95EE\u7B54\uFF08\u5982\u300C\u5E7F\u4E1C\u7ECF\u6D4E\u6570\u636E\u300D\u300C\u5199\u4E00\u9996\u8BD7\u300D\uFF09\u3001\u7EAF\u95F2\u804A\u95EE\u5019\u3001\u7FFB\u8BD1\u3001\u4E0D\u6D89\u53CA\u672C\u5730\u6587\u4EF6/\u4ED3\u5E93\u3002
209
+ - \u6F0F\u5224\uFF08\u7528\u6237\u8981\u6587\u4EF6\u800C\u6CA1\u5E26\u5DE5\u5177\uFF09\u6BD4\u8BEF\u5224\uFF08\u767D\u641C\u51E0\u8F6E\uFF09\u4EE3\u4EF7\u66F4\u9AD8\uFF0C\u5B81\u53EF\u504F\u5BBD\u5224 true\u3002
210
+
211
+ \u5728\u7ED9\u51FA agentKey \u4E4B\u524D\uFF0C\u5148\u5728\u5FC3\u91CC\u533A\u5206\u5019\u9009\u6863\u4F4D\u7684\u8FB9\u754C\u518D\u7ED9\u7F6E\u4FE1\u5EA6\uFF1Abalanced \u4E0E quality \u7684\u8FB9\u754C\u5728\u4E8E\u590D\u6742\u5EA6/\u7BC7\u5E45/\u662F\u5426\u9700\u8981\u6DF1\u5EA6\u5206\u6790\uFF0C\u62FF\u4E0D\u51C6\u5C31\u7ED9\u4F4E confidence\u3002
212
+
213
+ \u540C\u65F6\u5224\u65AD\u672C\u8F6E\u6D88\u606F\u662F\u5426\u9700\u8981\u6302\u8F7D\u5BF9\u8C61\u64CD\u4F5C\u6280\u80FD\uFF08skills \u6570\u7EC4\uFF0C\u672A\u547D\u4E2D\u7ED9 []\uFF09\uFF1A
214
+ - \u7528\u6237\u8981\u65B0\u5EFA/\u6574\u7406/\u5F55\u5165/\u6279\u91CF\u5904\u7406\u8868\u683C\u6570\u636E\uFF08\u5EFA\u8868\u3001\u52A0\u884C\u3001\u6539\u5217\u3001\u6309\u6761\u4EF6\u6574\u7406\u6570\u636E\uFF09\u2192 skills \u542B "table"
215
+ - \u7528\u6237\u8981\u5199/\u6DA6\u8272/\u6539\u5199/\u7EED\u5199/\u6392\u7248\u4E00\u7BC7\u6587\u6863\u6216\u6587\u7AE0 \u2192 skills \u542B "doc"
216
+ - \u7528\u6237\u8981\u5199/\u6539/\u5B9E\u73B0/\u4FEE bug/refactor/\u8865\u6D4B\u8BD5/\u5BA1\u67E5\u5E76\u4FEE\u6539\u4EE3\u7801 \u2192 skills \u542B "code"\uFF08\u4EC5\u95EE\u901A\u7528\u77E5\u8BC6\u3001\u7EAF\u95F2\u804A\u3001\u53EA\u67E5\u770B git/\u4ED3\u5E93\u72B6\u6001\u800C\u4E0D\u4FEE\u6539\u4EE3\u7801\u65F6\u4E0D\u6302 "code"\uFF09
217
+ - \u7528\u6237\u60F3\u8981\u4E00\u4E2A\u53EF\u4EA4\u4E92\u7684\u53EF\u89C6\u5316\u9875\u9762/\u62A5\u544A/\u770B\u677F/\u4E3B\u9875/\u6559\u7A0B/\u5BF9\u6BD4\u9875/\u8BA1\u5212\u9875\uFF08\u5982"\u505A\u4E2A\u65E5\u62A5""\u505A\u4E00\u4E2A\u4E2A\u4EBA\u4E3B\u9875""\u505A\u4E2A\u9500\u552E\u770B\u677F""\u505A\u4E2A\u65B9\u6848\u5BF9\u6BD4\u9875""\u505A\u4E2A\u5B66\u4E60\u8BA1\u5212\u9875"\uFF09\u2192 skills \u542B "pagebuilder"
218
+ - \u666E\u901A\u95EE\u7B54/\u7EAF\u95F2\u804A/\u5EFA\u5E94\u7528 \u2192 skills \u4E3A []
219
+
220
+ \u53EA\u8F93\u51FA JSON\uFF0C\u4E0D\u8981\u8F93\u51FA\u5176\u4ED6\u5185\u5BB9\uFF1A
221
+ {"confidence": <0\u52301\u4E4B\u95F4\u7684\u5C0F\u6570\uFF0C\u8868\u793A\u4F60\u5BF9\u8FD9\u4E2A\u5206\u7C7B\u5224\u65AD\u7684\u628A\u63E1\u7A0B\u5EA6>, "agentKey": "<\u4ECE\u5217\u8868\u4E2D\u9009\u62E9\u7684 agentKey>", "needsWorkspace": <true \u6216 false>, "skills": <\u5B57\u7B26\u4E32\u6570\u7EC4\uFF0C\u5143\u7D20\u53EA\u80FD\u662F ${[...VALID_QUICK_CHAT_SKILLS].map((s) => `"${s}"`).join(" | ")}\uFF0C\u672A\u547D\u4E2D\u7ED9 []>}`;
222
+ }
223
+ function parseQuickChatIntentResult(content, tierAgents) {
224
+ try {
225
+ const parsed = JSON.parse(content.trim());
226
+ if (typeof parsed !== "object" || parsed === null || !("agentKey" in parsed)) return null;
227
+ const key = parsed.agentKey;
228
+ if (typeof key !== "string") return null;
229
+ if (!tierAgents.some((t2) => t2.agentKey === key)) return null;
230
+ const rawNeedsWorkspace = parsed.needsWorkspace;
231
+ const needsWorkspace = rawNeedsWorkspace === true;
232
+ const rawConfidence = parsed.confidence;
233
+ const confidence = typeof rawConfidence === "number" && Number.isFinite(rawConfidence) && rawConfidence >= 0 && rawConfidence <= 1 ? rawConfidence : void 0;
234
+ const rawSkills = parsed.skills;
235
+ let skills;
236
+ if (Array.isArray(rawSkills)) {
237
+ const filtered = [...new Set(rawSkills)].filter(
238
+ (s) => typeof s === "string" && VALID_QUICK_CHAT_SKILLS.has(s)
239
+ );
240
+ if (filtered.length > 0) skills = filtered;
241
+ }
242
+ return { agentKey: key, needsWorkspace, confidence, skills };
243
+ } catch {
244
+ return null;
245
+ }
246
+ }
247
+
248
+ // packages/cli/client/autoModelRouter.ts
249
+ var CLI_AUTO_TIER_AGENT_KEYS = {
250
+ flash: PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY,
251
+ balanced: PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY,
252
+ quality: PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY
253
+ };
254
+ var CLI_AUTO_TIER_MODELS = {
255
+ flash: "deepseek-v4-flash",
256
+ balanced: "deepseek-v4-flash",
257
+ quality: "deepseek-v4-flash"
258
+ };
259
+ var CLI_IMAGE_AGENT_KEY = PUBLIC_KIMI_K26_IMAGE_AGENT_KEY;
260
+ var CLI_IMAGE_AGENT_MODEL = "kimi-k2.6";
261
+ var CLI_AUTO_TIER_AGENT_KEY_TABLE = {
262
+ [CLI_AUTO_TIER_AGENT_KEYS.flash]: true,
263
+ [CLI_AUTO_TIER_AGENT_KEYS.balanced]: true,
264
+ [CLI_AUTO_TIER_AGENT_KEYS.quality]: true
265
+ };
266
+ function resolveCliAutoAgentModel(agentKey) {
267
+ if (agentKey === CLI_AUTO_TIER_AGENT_KEYS.flash) return CLI_AUTO_TIER_MODELS.flash;
268
+ if (agentKey === CLI_AUTO_TIER_AGENT_KEYS.balanced) {
269
+ return CLI_AUTO_TIER_MODELS.balanced;
270
+ }
271
+ if (agentKey === CLI_AUTO_TIER_AGENT_KEYS.quality) {
272
+ return CLI_AUTO_TIER_MODELS.quality;
273
+ }
274
+ if (agentKey === CLI_IMAGE_AGENT_KEY) return CLI_IMAGE_AGENT_MODEL;
275
+ return void 0;
276
+ }
277
+ var buildRouteOptions = () => ["flash", "balanced", "quality"].map((tier) => ({
278
+ tier,
279
+ agentKey: CLI_AUTO_TIER_AGENT_KEYS[tier],
280
+ description: TIER_DESCRIPTIONS[tier]
281
+ }));
282
+ var tierForAgentKey = (agentKey) => {
283
+ for (const tier of ["flash", "balanced", "quality"]) {
284
+ if (CLI_AUTO_TIER_AGENT_KEYS[tier] === agentKey) return tier;
285
+ }
286
+ return null;
287
+ };
288
+ function resolveCliAutoFallbackTier(text) {
289
+ switch (estimateComplexity(text)) {
290
+ case "complex":
291
+ return "quality";
292
+ case "medium":
293
+ return "balanced";
294
+ case "simple":
295
+ default:
296
+ return "flash";
297
+ }
298
+ }
299
+ async function classifyCliAutoRoute(text, options) {
300
+ const timeoutMs = options.timeoutMs ?? QUICK_CHAT_INTENT_TIMEOUT_MS;
301
+ const fallbackTier = resolveCliAutoFallbackTier(text);
302
+ const fallback = () => ({
303
+ agentKey: CLI_AUTO_TIER_AGENT_KEYS[fallbackTier],
304
+ tier: fallbackTier,
305
+ classified: false
306
+ });
307
+ if (!text.trim()) return fallback();
308
+ if (isShortGreeting(text)) {
309
+ return {
310
+ agentKey: CLI_AUTO_TIER_AGENT_KEYS.flash,
311
+ tier: "flash",
312
+ classified: true
313
+ };
314
+ }
315
+ if (!options.authToken) return fallback();
316
+ const fetchImpl = options.fetchImpl ?? globalThis.fetch;
317
+ const controller = new AbortController();
318
+ const timeoutHandle = setTimeout(() => controller.abort(), timeoutMs);
319
+ try {
320
+ const routeOptions = buildRouteOptions();
321
+ const messages = [
322
+ { role: "system", content: buildQuickChatIntentSystemPrompt(routeOptions) },
323
+ { role: "user", content: text }
324
+ ];
325
+ const { url, init } = buildPlatformChatCompletionRequest({
326
+ providerConfig: {
327
+ serverUrl: options.serverUrl,
328
+ authToken: options.authToken,
329
+ agentKey: CLI_AUTO_TIER_AGENT_KEYS.flash,
330
+ model: INTENT_MODEL,
331
+ provider: INTENT_PROVIDER,
332
+ endpoint: resolvePlatformChatCompletionsEndpoint(INTENT_PROVIDER) ?? "",
333
+ requestOptions: {}
334
+ },
335
+ messages,
336
+ stream: false
337
+ });
338
+ const response = await fetchImpl(url, {
339
+ ...init,
340
+ signal: controller.signal
341
+ });
342
+ if (!response.ok) return fallback();
343
+ const data = parsePlatformChatCompletionData(await response.text());
344
+ const content = data?.choices?.[0]?.message?.content;
345
+ if (typeof content !== "string" || !content.trim()) return fallback();
346
+ const parsed = parseQuickChatIntentResult(content, routeOptions);
347
+ if (!parsed) return fallback();
348
+ const tier = tierForAgentKey(parsed.agentKey) ?? fallbackTier;
349
+ return {
350
+ agentKey: parsed.agentKey,
351
+ tier,
352
+ classified: true,
353
+ confidence: parsed.confidence,
354
+ needsWorkspace: parsed.needsWorkspace,
355
+ skills: parsed.skills
356
+ };
357
+ } catch {
358
+ return fallback();
359
+ } finally {
360
+ clearTimeout(timeoutHandle);
361
+ }
362
+ }
363
+
133
364
  // packages/cli/client/tokenUsage.ts
365
+ var isUsableModelId = (model) => {
366
+ const raw = model?.trim();
367
+ return Boolean(raw) && raw !== "-" && raw !== "auto";
368
+ };
369
+ function resolveAgentContextWindow(opts) {
370
+ if (isUsableModelId(opts.model)) {
371
+ return getModelContextWindow(opts.model);
372
+ }
373
+ const agentKey = opts.agentKey?.trim();
374
+ if (agentKey) {
375
+ const tierModel = resolveCliAutoAgentModel(agentKey);
376
+ if (tierModel) return getModelContextWindow(tierModel);
377
+ if (opts.autoRouteDefault !== false && agentKey === BUILTIN_NOLO_AGENT_KEY) {
378
+ return getModelContextWindow(CLI_AUTO_TIER_MODELS.flash);
379
+ }
380
+ }
381
+ if (opts.agentName?.trim()) {
382
+ return getModelContextWindow(opts.agentName);
383
+ }
384
+ return DEFAULT_CONTEXT_WINDOW;
385
+ }
134
386
  var PROVIDER_LOOKUP_ORDER = [
135
387
  "openrouter",
136
388
  "fireworks",
@@ -150,7 +402,15 @@ function parseUsageRecord(usage) {
150
402
  const output = Number(usage.output_tokens ?? usage.completion_tokens ?? 0);
151
403
  if (!Number.isFinite(input) || !Number.isFinite(output)) return void 0;
152
404
  if (!input && !output) return void 0;
153
- return { input, output };
405
+ const normalized = normalizeUsage(usage);
406
+ const cacheRead = normalized.cache_read_input_tokens || void 0;
407
+ const cacheWrite = normalized.cache_creation_input_tokens || void 0;
408
+ return {
409
+ input,
410
+ output,
411
+ ...cacheRead === void 0 ? {} : { cacheRead },
412
+ ...cacheWrite === void 0 ? {} : { cacheWrite }
413
+ };
154
414
  }
155
415
  function resolveContextWindow(model) {
156
416
  const raw = model?.trim();
@@ -166,10 +426,13 @@ function buildTurnTokenUsage(usage, model) {
166
426
  if (!parsed) return void 0;
167
427
  const contextWindow = resolveContextWindow(model);
168
428
  const remaining = contextWindow && parsed.input > 0 ? Math.max(0, contextWindow - parsed.input) : void 0;
429
+ const rawCost = typeof usage?.cost === "number" ? usage.cost : void 0;
430
+ const credits = rawCost !== void 0 && rawCost > 0 ? rawCost * API_REPORTED_COST_MULTIPLIER : void 0;
169
431
  return {
170
432
  ...parsed,
171
433
  ...contextWindow ? { contextWindow } : {},
172
- ...remaining != null ? { remaining } : {}
434
+ ...remaining != null ? { remaining } : {},
435
+ ...credits !== void 0 ? { credits } : {}
173
436
  };
174
437
  }
175
438
  function formatTokenCount(value) {
@@ -186,7 +449,8 @@ function formatTokenCount(value) {
186
449
  function renderTokenStatus(tokens) {
187
450
  if (!tokens) return "in \u2014 out \u2014 left \u2014";
188
451
  const left = tokens.remaining != null ? formatTokenCount(tokens.remaining) : tokens.contextWindow ? "\u2014" : "\u2014";
189
- return `in ${formatTokenCount(tokens.input)} out ${formatTokenCount(tokens.output)} left ${left}`;
452
+ const cache = tokens.cacheRead != null && tokens.cacheRead > 0 ? ` (cache ${formatTokenCount(tokens.cacheRead)})` : "";
453
+ return `in ${formatTokenCount(tokens.input)}${cache} out ${formatTokenCount(tokens.output)} left ${left}`;
190
454
  }
191
455
  function shouldShowUsage(env) {
192
456
  return env.NOLO_DEBUG === "1" || env.NOLO_SHOW_USAGE === "1";
@@ -238,8 +502,277 @@ function styleCliText(text, style, enabled = resolveCliColorEnabled()) {
238
502
  if (!code) return text;
239
503
  return `${code}${text}${RESET}`;
240
504
  }
241
- function dimCliText(text, enabled = resolveCliColorEnabled()) {
242
- return styleCliText(text, "dim", enabled);
505
+ function dimCliText(text, enabled = resolveCliColorEnabled()) {
506
+ return styleCliText(text, "dim", enabled);
507
+ }
508
+
509
+ // packages/cli/tui/tuiAnsi.ts
510
+ var ANSI_ESCAPE_REGEX = /\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]/g;
511
+ var OSC_HYPERLINK_REGEX = /\x1b\]8;;[^\x07\x1b]*(?:\x07|\x1b\\)\x1b\]8;;(?:\x07|\x1b\\)|\x1b\]8;;[^\x07\x1b]*(?:\x07|\x1b\\)/g;
512
+ function stripAnsi(text) {
513
+ return text.replace(OSC_HYPERLINK_REGEX, "").replace(ANSI_ESCAPE_REGEX, "");
514
+ }
515
+ var SGR_SEQUENCE_REGEX = /^\x1b\[[0-9;]*m/;
516
+ var TRAILING_SGR_REGEX = /(?:\x1b\[[0-9;]*m)+$/;
517
+ function applyTerminalOutputToText(existing, chunk) {
518
+ if (!chunk) return existing;
519
+ let text = existing;
520
+ let index = 0;
521
+ while (index < chunk.length) {
522
+ if (chunk[index] === "\x1B") {
523
+ const sgr = SGR_SEQUENCE_REGEX.exec(chunk.slice(index));
524
+ if (sgr) {
525
+ text += sgr[0];
526
+ index += sgr[0].length;
527
+ continue;
528
+ }
529
+ const osc = chunk.slice(index).match(/^\x1b\]8;;[^\x07\x1b]*(?:\x07|\x1b\\)/);
530
+ if (osc) {
531
+ index += osc[0].length;
532
+ continue;
533
+ }
534
+ const csi = chunk.slice(index).match(/^\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]/);
535
+ if (csi) {
536
+ index += csi[0].length;
537
+ continue;
538
+ }
539
+ index += 1;
540
+ continue;
541
+ }
542
+ const ch = chunk[index];
543
+ if (ch === "\r") {
544
+ const lastNl = text.lastIndexOf("\n");
545
+ text = lastNl === -1 ? "" : text.slice(0, lastNl + 1);
546
+ index += 1;
547
+ continue;
548
+ }
549
+ if (ch === "\n") {
550
+ text += "\n";
551
+ index += 1;
552
+ continue;
553
+ }
554
+ if (ch === "\b") {
555
+ const trailing = TRAILING_SGR_REGEX.exec(text);
556
+ const sgrTail = trailing ? trailing[0] : "";
557
+ const head = sgrTail ? text.slice(0, -sgrTail.length) : text;
558
+ if (head.length > 0 && head[head.length - 1] !== "\n") {
559
+ text = head.slice(0, -1) + sgrTail;
560
+ }
561
+ index += 1;
562
+ continue;
563
+ }
564
+ const code = ch.charCodeAt(0);
565
+ if (code < 32 && ch !== " " || code === 127) {
566
+ index += 1;
567
+ continue;
568
+ }
569
+ text += ch;
570
+ index += 1;
571
+ }
572
+ return text;
573
+ }
574
+ function displayWidth(str) {
575
+ let width = 0;
576
+ for (const char of str) {
577
+ const code = char.codePointAt(0) ?? 0;
578
+ if (code < 32 || code === 127) continue;
579
+ if (code >= 4352 && code <= 4447 || // 0x2768-0x2775 (ornamental brackets, incl. the ❯ prompt at U+276F)
580
+ // render narrow in terminals; counting them wide drifts the cursor.
581
+ code >= 9728 && code <= 10175 && !(code >= 10088 && code <= 10101) || // 0x2B00-0x2BFF (Misc Symbols and Arrows, incl. ⬢ U+2B22 used as the
582
+ // status-line agent icon) render double-wide in common monospace fonts;
583
+ // counting ⬢ as width 1 drifts the whole status line right of the icon.
584
+ code >= 11008 && code <= 11263 || code >= 11904 && code <= 12350 || code >= 12352 && code <= 13247 || code >= 13312 && code <= 19903 || code >= 19968 && code <= 42191 || code >= 44032 && code <= 55203 || code >= 63744 && code <= 64255 || code >= 65072 && code <= 65135 || code >= 65281 && code <= 65376 || code >= 65504 && code <= 65510 || code >= 127744 && code <= 129791 || code >= 131072 && code <= 196605 || code >= 196608 && code <= 262141 || // East Asian Ambiguous CJK quotation marks (U+201C/D “ ”, U+2018/9 ‘ ’).
585
+ // In CJK locale + CJK fonts these render double-wide like 全角 punctuation;
586
+ // in English fonts they stay width 1. Follow the active locale so Chinese
587
+ // replies align correctly without breaking English terminal output.
588
+ getCliLocale() === "zh" && (code === 8220 || code === 8221 || code === 8216 || code === 8217)) {
589
+ width += 2;
590
+ } else {
591
+ width += 1;
592
+ }
593
+ }
594
+ return width;
595
+ }
596
+ function visibleWidth(str) {
597
+ return displayWidth(stripAnsi(str));
598
+ }
599
+ function truncateAnsi(text, maxWidth) {
600
+ if (maxWidth <= 0) return "";
601
+ if (visibleWidth(text) <= maxWidth) return text;
602
+ let width = 0;
603
+ let out = "";
604
+ let i = 0;
605
+ let sawAnsi = false;
606
+ while (i < text.length) {
607
+ if (text[i] === "\x1B" && text[i + 1] === "[") {
608
+ sawAnsi = true;
609
+ let j = i + 2;
610
+ while (j < text.length) {
611
+ const code = text.charCodeAt(j);
612
+ j += 1;
613
+ if (code >= 64 && code <= 126) break;
614
+ }
615
+ out += text.slice(i, j);
616
+ i = j;
617
+ continue;
618
+ }
619
+ const codePoint = text.codePointAt(i) ?? 0;
620
+ const char = String.fromCodePoint(codePoint);
621
+ const charWidth = displayWidth(char);
622
+ if (width + charWidth > maxWidth) break;
623
+ out += char;
624
+ width += charWidth;
625
+ i += char.length;
626
+ }
627
+ return sawAnsi ? `${out}\x1B[0m` : out;
628
+ }
629
+ function fitAnsiLine(text, width, ellipsis = "\u2026") {
630
+ if (width <= 0) return "";
631
+ if (visibleWidth(text) <= width) return text;
632
+ const ellipsisWidth = displayWidth(ellipsis);
633
+ if (width < ellipsisWidth) return truncateAnsi(text, width);
634
+ if (width === ellipsisWidth) return truncateAnsi(ellipsis, width) || truncateAnsi(text, width);
635
+ return `${truncateAnsi(text, width - ellipsisWidth)}${ellipsis}`;
636
+ }
637
+ function countPhysicalLines(text, columns) {
638
+ const lines = text.split("\n");
639
+ let total = 0;
640
+ for (const line of lines) {
641
+ const width = displayWidth(line);
642
+ total += Math.max(1, Math.ceil(width / columns));
643
+ }
644
+ return Math.max(total, 1);
645
+ }
646
+ function takeDisplayWidth(text, width) {
647
+ let used = 0;
648
+ let index = 0;
649
+ for (const char of text) {
650
+ const charWidth = displayWidth(char);
651
+ if (used + charWidth > width && used > 0) break;
652
+ used += charWidth;
653
+ index += char.length;
654
+ }
655
+ return { prefix: text.slice(0, index), rest: text.slice(index) };
656
+ }
657
+ function padOrTruncateToWidth(text, width) {
658
+ const textWidth = visibleWidth(text);
659
+ if (textWidth > width) {
660
+ return truncateAnsi(text, width);
661
+ }
662
+ return `${text}${" ".repeat(width - textWidth)}`;
663
+ }
664
+ var SGR_RESET_REGEX = /^\x1b\[0?m$/;
665
+ function tokenizeAnsiLine(line) {
666
+ const tokens = [];
667
+ let index = 0;
668
+ while (index < line.length) {
669
+ if (line[index] === "\x1B") {
670
+ const osc = line.slice(index).match(/^\x1b\]8;;[^\x07\x1b]*(?:\x07|\x1b\\)/);
671
+ if (osc) {
672
+ tokens.push({ kind: "sgr", value: osc[0], width: 0 });
673
+ index += osc[0].length;
674
+ continue;
675
+ }
676
+ const sgr = SGR_SEQUENCE_REGEX.exec(line.slice(index));
677
+ if (sgr) {
678
+ tokens.push({ kind: "sgr", value: sgr[0], width: 0 });
679
+ index += sgr[0].length;
680
+ continue;
681
+ }
682
+ }
683
+ const codePoint = line.codePointAt(index) ?? 0;
684
+ const value = String.fromCodePoint(codePoint);
685
+ tokens.push({ kind: "char", value, width: displayWidth(value) });
686
+ index += value.length;
687
+ }
688
+ return tokens;
689
+ }
690
+ function wrapTranscriptLine(line, columns, hangingIndent = "") {
691
+ if (line === "") return [""];
692
+ const tokens = tokenizeAnsiLine(line);
693
+ const result = [];
694
+ let activeStyles = [];
695
+ const applyStyleToken = (value) => {
696
+ if (SGR_RESET_REGEX.test(value)) {
697
+ activeStyles = [];
698
+ } else {
699
+ activeStyles.push(value);
700
+ }
701
+ };
702
+ let start = 0;
703
+ while (start < tokens.length) {
704
+ if (tokens.slice(start).every((token) => token.kind === "sgr")) {
705
+ if (result.length > 0) break;
706
+ }
707
+ const openingStyles = [...activeStyles];
708
+ const isContinuation = result.length > 0 && hangingIndent.length > 0;
709
+ const indentWidth = isContinuation ? displayWidth(hangingIndent) : 0;
710
+ const maxSegmentWidth = Math.max(1, columns - indentWidth);
711
+ let width = 0;
712
+ let end = start;
713
+ let lastBreak = -1;
714
+ while (end < tokens.length) {
715
+ const token = tokens[end];
716
+ if (token.kind === "sgr") {
717
+ end += 1;
718
+ continue;
719
+ }
720
+ if (width + token.width > maxSegmentWidth && width > 0) break;
721
+ width += token.width;
722
+ end += 1;
723
+ if (token.value === " " || token.value === " ") {
724
+ lastBreak = end;
725
+ }
726
+ }
727
+ let segmentEnd = end;
728
+ if (end < tokens.length && lastBreak > start) {
729
+ const overflowToken = tokens[end];
730
+ if (overflowToken.kind === "char" && overflowToken.value !== " " && overflowToken.width === 1) {
731
+ segmentEnd = lastBreak;
732
+ }
733
+ }
734
+ if (segmentEnd === start) segmentEnd = start + 1;
735
+ let segment = "";
736
+ let sawStyle = openingStyles.length > 0;
737
+ for (let i = start; i < segmentEnd; i += 1) {
738
+ const token = tokens[i];
739
+ segment += token.value;
740
+ if (token.kind === "sgr") {
741
+ sawStyle = true;
742
+ applyStyleToken(token.value);
743
+ }
744
+ }
745
+ const prefix = openingStyles.join("");
746
+ const needsReset = (sawStyle || activeStyles.length > 0) && !segment.endsWith("\x1B[0m");
747
+ const lineContent = `${prefix}${segment}${needsReset ? "\x1B[0m" : ""}`;
748
+ result.push(isContinuation ? `${hangingIndent}${lineContent}` : lineContent);
749
+ start = segmentEnd;
750
+ while (start < tokens.length) {
751
+ const token = tokens[start];
752
+ if (token.kind === "char" && token.value === " ") {
753
+ start += 1;
754
+ continue;
755
+ }
756
+ break;
757
+ }
758
+ }
759
+ return result.length > 0 ? result : [""];
760
+ }
761
+ function wrapTextToLines(text, columns) {
762
+ const result = [];
763
+ for (const logicalLine of text.split("\n")) {
764
+ if (logicalLine === "") {
765
+ result.push("");
766
+ continue;
767
+ }
768
+ let remaining = logicalLine;
769
+ while (remaining.length > 0) {
770
+ const { prefix, rest } = takeDisplayWidth(remaining, columns);
771
+ result.push(prefix);
772
+ remaining = rest;
773
+ }
774
+ }
775
+ return result;
243
776
  }
244
777
 
245
778
  // packages/cli/tui/theme.ts
@@ -284,14 +817,14 @@ var THEME_PALETTES = {
284
817
  muted: { hex: "6E7781", ansiFallback: "\x1B[90m" }
285
818
  },
286
819
  dark: {
287
- accent: { hex: "58A6FF", ansiFallback: "\x1B[34m" },
288
- // GitHub sky blue
289
- chrome: { hex: "6E7681", ansiFallback: "\x1B[90m" },
290
- success: { hex: "3FB950", ansiFallback: "\x1B[32m" },
291
- warning: { hex: "D29922", ansiFallback: "\x1B[33m" },
292
- info: { hex: "58A6FF", ansiFallback: "\x1B[36m" },
293
- danger: { hex: "FF7B72", ansiFallback: "\x1B[31m" },
294
- muted: { hex: "B1BAC4", ansiFallback: "\x1B[90m" }
820
+ accent: { hex: "89B4FA", ansiFallback: "\x1B[34m" },
821
+ // Catppuccin Mocha Blue
822
+ chrome: { hex: "6C7086", ansiFallback: "\x1B[90m" },
823
+ success: { hex: "A6E3A1", ansiFallback: "\x1B[32m" },
824
+ warning: { hex: "F9E2AF", ansiFallback: "\x1B[33m" },
825
+ info: { hex: "89B4FA", ansiFallback: "\x1B[36m" },
826
+ danger: { hex: "F38BA8", ansiFallback: "\x1B[31m" },
827
+ muted: { hex: "A6ADC8", ansiFallback: "\x1B[90m" }
295
828
  }
296
829
  },
297
830
  wave: {
@@ -402,8 +935,24 @@ function getActiveDensity() {
402
935
  function setActiveDensity(density) {
403
936
  activeDensity = density;
404
937
  }
938
+ var TRUECOLOR_TERM_PROGRAMS = /* @__PURE__ */ new Set([
939
+ "iterm.app",
940
+ "wezterm",
941
+ "ghostty",
942
+ "vscode",
943
+ "hyper",
944
+ "tabby",
945
+ "rio",
946
+ "warpterminal"
947
+ ]);
405
948
  function supportsTruecolor(env = process.env) {
406
- return /truecolor|24bit/i.test(env.COLORTERM ?? "");
949
+ const explicit = (env.NOLO_TUI_TRUECOLOR ?? "").trim().toLowerCase();
950
+ if (explicit === "1" || explicit === "true") return true;
951
+ if (explicit === "0" || explicit === "false") return false;
952
+ if (/truecolor|24bit/i.test(env.COLORTERM ?? "")) return true;
953
+ if (/direct|24bit/i.test(env.TERM ?? "")) return true;
954
+ const program = (env.TERM_PROGRAM ?? "").toLowerCase();
955
+ return TRUECOLOR_TERM_PROGRAMS.has(program);
407
956
  }
408
957
  function resolveTuiBrightness(env = process.env) {
409
958
  const explicit = (env.NOLO_TUI_THEME ?? "").trim().toLowerCase();
@@ -427,7 +976,7 @@ function hexToSgr(hex) {
427
976
  }
428
977
  var SURFACE_HEX = {
429
978
  trail: { light: "E4E8EC", dark: "313244" },
430
- catppuccin: { light: "E8ECF0", dark: "161B22" },
979
+ catppuccin: { light: "E8ECF0", dark: "181825" },
431
980
  wave: { light: "E5E1D6", dark: "2A2A37" },
432
981
  iris: { light: "E9E8F2", dark: "2A2740" },
433
982
  rose: { light: "F2EAE4", dark: "26233A" },
@@ -437,6 +986,17 @@ var TERMINAL_BASE = {
437
986
  dark: "1E1E2E",
438
987
  light: "FFFFFF"
439
988
  };
989
+ var activeTerminalBaseHex = null;
990
+ function setActiveTerminalBaseHex(hex) {
991
+ if (hex === null) {
992
+ activeTerminalBaseHex = null;
993
+ return;
994
+ }
995
+ activeTerminalBaseHex = readHexChannels(hex.replace(/^#/, "").toUpperCase()) ? hex.replace(/^#/, "").toUpperCase() : null;
996
+ }
997
+ function resolveTerminalBaseHex(brightness) {
998
+ return activeTerminalBaseHex ?? TERMINAL_BASE[brightness];
999
+ }
440
1000
  function readHexChannels(hex) {
441
1001
  if (!/^[0-9A-F]{6}$/.test(hex)) return null;
442
1002
  return [
@@ -474,21 +1034,49 @@ function diffLineSequences(env = process.env, brightness = resolveTuiBrightness(
474
1034
  const palette = THEME_PALETTES[activeThemeName] ?? THEME_PALETTES.trail;
475
1035
  const successHex = palette[brightness].success.hex;
476
1036
  const dangerHex = palette[brightness].danger.hex;
477
- const weight = brightness === "dark" ? 0.14 : 0.1;
478
- const baseHex = TERMINAL_BASE[brightness];
1037
+ const infoHex = palette[brightness].info.hex;
1038
+ const weight = brightness === "dark" ? 0.18 : 0.12;
1039
+ const baseHex = resolveTerminalBaseHex(brightness);
479
1040
  const addedBgHex = blendHex(successHex, baseHex, weight);
480
1041
  const removedBgHex = blendHex(dangerHex, baseHex, weight);
1042
+ const hunkBgHex = blendHex(infoHex, baseHex, weight * 0.6);
1043
+ const successSgr = hexToSgr(successHex);
1044
+ const dangerSgr = hexToSgr(dangerHex);
1045
+ const infoSgr = hexToSgr(infoHex);
481
1046
  return {
482
1047
  added: {
483
- fg: hexToSgr(successHex),
484
- bg: hexToBgSgr(addedBgHex)
1048
+ fg: successSgr,
1049
+ bg: hexToBgSgr(addedBgHex),
1050
+ bar: `${successSgr}\u258C\x1B[39m`
485
1051
  },
486
1052
  removed: {
487
- fg: hexToSgr(dangerHex),
488
- bg: hexToBgSgr(removedBgHex)
489
- }
1053
+ fg: dangerSgr,
1054
+ bg: hexToBgSgr(removedBgHex),
1055
+ bar: `${dangerSgr}\u258C\x1B[39m`
1056
+ },
1057
+ hunk: {
1058
+ fg: infoSgr,
1059
+ bg: hexToBgSgr(hunkBgHex),
1060
+ bar: " "
1061
+ },
1062
+ context: { fg: "", bg: "", bar: " " }
490
1063
  };
491
1064
  }
1065
+ function renderDiffLine(args) {
1066
+ const { kind, text } = args;
1067
+ const env = args.env ?? process.env;
1068
+ const colorEnabled = args.colorEnabled ?? resolveCliColorEnabled();
1069
+ if (!colorEnabled) return text;
1070
+ const seqs = diffLineSequences(env);
1071
+ if (!seqs) {
1072
+ if (kind === "context") return text;
1073
+ const token = kind === "added" ? "success" : kind === "removed" ? "danger" : "info";
1074
+ return `${themeColorSequence(token, env)}${text}\x1B[39m`;
1075
+ }
1076
+ const seq = seqs[kind];
1077
+ const padding = args.padTo === void 0 ? "" : " ".repeat(Math.max(0, args.padTo - displayWidth(text)));
1078
+ return `${seq.bar}${seq.bg}${seq.fg}${text}${padding}\x1B[0m`;
1079
+ }
492
1080
  function surfaceBackgroundSequence(env = process.env, brightness = resolveTuiBrightness(env)) {
493
1081
  if (!supportsTruecolor(env)) return "";
494
1082
  return hexToBgSgr((SURFACE_HEX[activeThemeName] ?? SURFACE_HEX.trail)[brightness]);
@@ -502,69 +1090,11 @@ function themeText(text, token, colorEnabled = resolveCliColorEnabled(), env = p
502
1090
  if (!colorEnabled) return text;
503
1091
  return `${themeColorSequence(token, env)}${text}\x1B[39m`;
504
1092
  }
505
- function renderDiffCodeBlock(code, env = process.env) {
506
- const border = themeText("\u2502", "chrome", true, env);
507
- const addedColor = themeColorSequence("success", env);
508
- const deletedColor = themeColorSequence("danger", env);
509
- const hunkColor = themeColorSequence("info", env);
510
- const contextColor = themeColorSequence("chrome", env);
511
- const reset = "\x1B[0m";
512
- const lines = code.split("\n").map((line) => {
513
- let color = contextColor;
514
- if (line.startsWith("@@")) {
515
- color = hunkColor;
516
- } else if (line.startsWith("+") && !line.startsWith("+++")) {
517
- color = addedColor;
518
- } else if (line.startsWith("-") && !line.startsWith("---")) {
519
- color = deletedColor;
520
- }
521
- return ` ${border} ${color}${line}${reset}`;
522
- });
523
- return ` ${themeText("\u250C\u2500\u2500\u2500", "chrome", true, env)}
524
- ${lines.join("\n")}
525
- ${themeText("\u2514\u2500\u2500\u2500", "chrome", true, env)}`;
526
- }
527
- function highlightMarkdown(text, colorEnabled = resolveCliColorEnabled(), env = process.env) {
528
- if (!colorEnabled) return text;
529
- let result = text;
530
- result = result.replace(/```([a-zA-Z-]*)\n([\s\S]*?)\n```/g, (match, lang, code) => {
531
- if (lang.toLowerCase() === "diff") {
532
- return renderDiffCodeBlock(code, env);
533
- }
534
- const infoColor = themeColorSequence("info", env);
535
- const reset2 = "\x1B[39m\x1B[22m";
536
- const border = themeText("\u2502", "chrome", true, env);
537
- const formattedCode = code.split("\n").map((line) => ` ${border} ${infoColor}${line}${reset2}`).join("\n");
538
- return ` ${themeText("\u250C\u2500\u2500\u2500", "chrome", true, env)}
539
- ${formattedCode}
540
- ${themeText("\u2514\u2500\u2500\u2500", "chrome", true, env)}`;
541
- });
542
- result = result.replace(/^(#{1,3})\s+(.+)$/gm, (match, hashes, title) => {
543
- const level = hashes.length;
544
- const reset2 = "\x1B[0m";
545
- if (level === 1) {
546
- return `\x1B[1m\x1B[4m${themeColorSequence("accent", env)}${title}${reset2}`;
547
- }
548
- if (level === 2) {
549
- return `\x1B[1m${themeColorSequence("warning", env)}${title}${reset2}`;
550
- }
551
- return `\x1B[1m${themeColorSequence("info", env)}${title}${reset2}`;
552
- });
553
- result = result.replace(
554
- /^(进入 nolo-plan[^\n]*)$/gm,
555
- (match, content) => `${themeColorSequence("chrome", env)}\x1B[2m${content}\x1B[0m`
556
- );
557
- result = result.replace(/^>\s?(.*)$/gm, (match, content) => {
558
- const border = themeColorSequence("chrome", env);
559
- return `${border}\u2502\x1B[39m \x1B[2m${content}\x1B[22m`;
560
- });
561
- result = result.replace(/\*\*([\s\S]*?)\*\*/g, "\x1B[1m$1\x1B[22m");
562
- const mutedColor = themeColorSequence("muted", env);
563
- const reset = "\x1B[39m";
564
- result = result.replace(/`([^`\n]+)`/g, `${mutedColor}$1${reset}`);
565
- result = result.replace(/(?<!\*)\*([^*\n]+?)\*(?!\*)/g, `\x1B[2m$1\x1B[22m`);
566
- result = result.replace(/~~([^~\n]+?)~~/g, `\x1B[2m\x1B[9m$1\x1B[29m\x1B[22m`);
567
- return result;
1093
+ function classifyDiffLine(line) {
1094
+ if (line.startsWith("@@")) return "hunk";
1095
+ if (line.startsWith("+") && !line.startsWith("+++")) return "added";
1096
+ if (line.startsWith("-") && !line.startsWith("---")) return "removed";
1097
+ return "context";
568
1098
  }
569
1099
 
570
1100
  // packages/cli/client/assistantOutput.ts
@@ -743,20 +1273,7 @@ function highlightCodeLine(line, lang, brightness) {
743
1273
  return `${info}${line}${STYLE.reset}`;
744
1274
  }
745
1275
  if (lang === "diff") {
746
- const added = colorSeq("success", brightness);
747
- const deleted = colorSeq("danger", brightness);
748
- const hunk = colorSeq("info", brightness);
749
- const context = colorSeq("chrome", brightness);
750
- const reset2 = STYLE.reset;
751
- let color = context;
752
- if (line.startsWith("@@")) {
753
- color = hunk;
754
- } else if (line.startsWith("+") && !line.startsWith("+++")) {
755
- color = added;
756
- } else if (line.startsWith("-") && !line.startsWith("---")) {
757
- color = deleted;
758
- }
759
- return `${color}${line}${reset2}`;
1276
+ return renderDiffLine({ kind: classifyDiffLine(line), text: line, colorEnabled: true });
760
1277
  }
761
1278
  const regions = scanStringCommentRegions(line, lang);
762
1279
  const keywords = KEYWORDS[lang];
@@ -953,7 +1470,7 @@ function styleRichMarkdownLine(line, brightness) {
953
1470
  const ordered = line.match(/^(\s*)(\d+\.)\s(.+)$/);
954
1471
  if (ordered) {
955
1472
  const styled = styleInlineMarkdown(ordered[3], brightness);
956
- return `${ordered[1]}${colorSeq("accent", brightness)}${ordered[2]}${STYLE.reset} ${styled}`;
1473
+ return `${ordered[1]}${colorSeq("chrome", brightness)}${ordered[2]}${STYLE.reset} ${styled}`;
957
1474
  }
958
1475
  const task = line.match(/^(\s*)(☐|☑)\s(.+)$/);
959
1476
  if (task) {
@@ -1354,456 +1871,254 @@ function formatFetchTreeLines(items) {
1354
1871
  return { header, count, lines };
1355
1872
  }
1356
1873
 
1357
- // packages/cli/tui/i18n.ts
1358
- var ZH_PATTERNS = /^zh/i;
1359
- function parseCliLocale(raw) {
1360
- const normalized = raw?.trim().toLowerCase();
1361
- if (!normalized) return null;
1362
- if (ZH_PATTERNS.test(normalized)) return "zh";
1363
- if (normalized === "en" || normalized.startsWith("en")) return "en";
1364
- return null;
1365
- }
1366
- function detectLocaleFromEnv(env) {
1367
- const explicit = parseCliLocale(env.NOLO_LANG);
1368
- if (explicit) return explicit;
1369
- const candidates = [env.LC_ALL, env.LC_CTYPE, env.LANG].filter(Boolean);
1370
- for (const candidate of candidates) {
1371
- if (ZH_PATTERNS.test(candidate)) return "zh";
1372
- if (candidate && !candidate.startsWith("C.") && !candidate.startsWith("POSIX")) {
1373
- return "en";
1874
+ // packages/cli/node_modules/diff/libesm/diff/base.js
1875
+ var Diff = class {
1876
+ diff(oldStr, newStr, options = {}) {
1877
+ let callback;
1878
+ if (typeof options === "function") {
1879
+ callback = options;
1880
+ options = {};
1881
+ } else if ("callback" in options) {
1882
+ callback = options.callback;
1883
+ }
1884
+ const oldString = this.castInput(oldStr, options);
1885
+ const newString = this.castInput(newStr, options);
1886
+ const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
1887
+ const newTokens = this.removeEmpty(this.tokenize(newString, options));
1888
+ return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
1889
+ }
1890
+ diffWithOptionsObj(oldTokens, newTokens, options, callback) {
1891
+ var _a;
1892
+ const done = (value) => {
1893
+ value = this.postProcess(value, options);
1894
+ if (callback) {
1895
+ setTimeout(function() {
1896
+ callback(value);
1897
+ }, 0);
1898
+ return void 0;
1899
+ } else {
1900
+ return value;
1901
+ }
1902
+ };
1903
+ const newLen = newTokens.length, oldLen = oldTokens.length;
1904
+ let editLength = 1;
1905
+ let maxEditLength = newLen + oldLen;
1906
+ if (options.maxEditLength != null) {
1907
+ maxEditLength = Math.min(maxEditLength, options.maxEditLength);
1908
+ }
1909
+ const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
1910
+ const abortAfterTimestamp = Date.now() + maxExecutionTime;
1911
+ const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
1912
+ let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
1913
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
1914
+ return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
1915
+ }
1916
+ let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
1917
+ const execEditLength = () => {
1918
+ for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
1919
+ let basePath;
1920
+ const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
1921
+ if (removePath) {
1922
+ bestPath[diagonalPath - 1] = void 0;
1923
+ }
1924
+ let canAdd = false;
1925
+ if (addPath) {
1926
+ const addPathNewPos = addPath.oldPos - diagonalPath;
1927
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
1928
+ }
1929
+ const canRemove = removePath && removePath.oldPos + 1 < oldLen;
1930
+ if (!canAdd && !canRemove) {
1931
+ bestPath[diagonalPath] = void 0;
1932
+ continue;
1933
+ }
1934
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
1935
+ basePath = this.addToPath(addPath, true, false, 0, options);
1936
+ } else {
1937
+ basePath = this.addToPath(removePath, false, true, 1, options);
1938
+ }
1939
+ newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
1940
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
1941
+ return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
1942
+ } else {
1943
+ bestPath[diagonalPath] = basePath;
1944
+ if (basePath.oldPos + 1 >= oldLen) {
1945
+ maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
1946
+ }
1947
+ if (newPos + 1 >= newLen) {
1948
+ minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
1949
+ }
1950
+ }
1951
+ }
1952
+ editLength++;
1953
+ };
1954
+ if (callback) {
1955
+ (function exec() {
1956
+ setTimeout(function() {
1957
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
1958
+ return callback(void 0);
1959
+ }
1960
+ if (!execEditLength()) {
1961
+ exec();
1962
+ }
1963
+ }, 0);
1964
+ })();
1965
+ } else {
1966
+ while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
1967
+ const ret = execEditLength();
1968
+ if (ret) {
1969
+ return ret;
1970
+ }
1971
+ }
1374
1972
  }
1375
1973
  }
1376
- return null;
1377
- }
1378
- function detectLocale(env) {
1379
- return detectLocaleFromEnv(env) ?? "zh";
1380
- }
1381
- var currentLocale = detectLocale(process.env);
1382
- function getCliLocale() {
1383
- return currentLocale;
1384
- }
1385
- function setCliLocale(locale) {
1386
- currentLocale = locale;
1387
- }
1388
- function initCliLocale(env = process.env) {
1389
- currentLocale = detectLocale(env);
1390
- }
1391
- var STRINGS = {
1392
- welcomeHint: {
1393
- en: "Tell nolo what you want. Use /help for commands. Shift+Enter for newline.",
1394
- zh: "\u544A\u8BC9 nolo \u4F60\u60F3\u8981\u4EC0\u4E48\u3002\u8F93\u5165 /help \u67E5\u770B\u547D\u4EE4\u3002Shift+Enter \u6362\u884C\u3002"
1395
- },
1396
- promptLabel: {
1397
- en: "\u276F ",
1398
- zh: "\u276F "
1399
- },
1400
- continueLabel: {
1401
- en: "\u2502 ",
1402
- zh: "\u2502 "
1403
- },
1404
- placeholder: {
1405
- en: "Type a message or / for commands...",
1406
- zh: "\u8F93\u5165\u6D88\u606F\uFF0C\u6216\u7528 / \u67E5\u770B\u547D\u4EE4\u2026"
1407
- },
1408
- newDialog: {
1409
- en: "new dialog",
1410
- zh: "\u65B0\u5BF9\u8BDD"
1411
- },
1412
- startedFreshDialog: {
1413
- en: "Started a fresh dialog.",
1414
- zh: "\u5DF2\u5F00\u59CB\u65B0\u5BF9\u8BDD\u3002"
1415
- },
1416
- bye: {
1417
- en: "Bye.",
1418
- zh: "\u518D\u89C1\u3002"
1419
- },
1420
- resumedDialogPrefix: {
1421
- en: "Resumed dialog",
1422
- zh: "\u5DF2\u6062\u590D\u5BF9\u8BDD"
1423
- },
1424
- resumeInvalidId: {
1425
- en: "does not look like a dialog id. Use /history to pick one.",
1426
- zh: "\u770B\u8D77\u6765\u4E0D\u662F dialog id\u3002\u7528 /history \u4ECE\u5217\u8868\u91CC\u9009\u4E00\u4E2A\u3002"
1427
- },
1428
- dialogResumeCancelled: {
1429
- en: "Dialog resume cancelled.",
1430
- zh: "\u5DF2\u53D6\u6D88\u6062\u590D\u5BF9\u8BDD\u3002"
1431
- },
1432
- agentSwitchCancelled: {
1433
- en: "Agent switch cancelled.",
1434
- zh: "\u5DF2\u53D6\u6D88\u5207\u6362 agent\u3002"
1435
- },
1436
- historyPickerTitle: {
1437
- en: "Resume dialog (\u2191\u2193 Enter Esc)",
1438
- zh: "\u6062\u590D\u5BF9\u8BDD\uFF08\u2191\u2193 \u79FB\u52A8 \xB7 Enter \u9009\u62E9 \xB7 Esc \u53D6\u6D88\uFF09"
1439
- },
1440
- noDialogsYet: {
1441
- en: "No dialogs yet.",
1442
- zh: "\u8FD8\u6CA1\u6709\u5386\u53F2\u5BF9\u8BDD\u3002"
1443
- },
1444
- langUsage: {
1445
- en: "Usage: /lang <zh|en>",
1446
- zh: "\u7528\u6CD5\uFF1A/lang <zh|en>"
1447
- },
1448
- stopHint: {
1449
- en: "Esc to stop",
1450
- zh: "Esc \u505C\u6B62\u56DE\u590D"
1451
- },
1452
- queuedHint: {
1453
- en: "queued",
1454
- zh: "\u6392\u961F"
1455
- },
1456
- turnStopped: {
1457
- en: "Stopped this reply.",
1458
- zh: "\u5DF2\u505C\u6B62\u672C\u6B21\u56DE\u590D\u3002"
1459
- },
1460
- turnFailed: {
1461
- en: "This reply failed. Queued messages are kept \u2014 press Enter to resend.",
1462
- zh: "\u672C\u6B21\u56DE\u590D\u51FA\u9519\u3002\u5DF2\u6392\u961F\u7684\u6D88\u606F\u4ECD\u4FDD\u7559\uFF0C\u6309 Enter \u53EF\u91CD\u65B0\u53D1\u9001\u3002"
1463
- },
1464
- quotaExhaustedHint: {
1465
- en: "[nolo] This agent seems to have hit a quota/rate limit (HTTP 429).\nUse /agent to switch to another agent and keep going \u2014 the dialog context is preserved.",
1466
- zh: "[nolo] \u5F53\u524D agent \u4F3C\u4E4E\u989D\u5EA6/\u901F\u7387\u53D7\u9650\uFF08429\uFF09\u3002\n\u53EF\u4EE5\u7528 /agent \u5207\u6362\u5230\u5176\u4ED6 agent \u540E\u7EE7\u7EED\uFF0C\u540C\u4E00\u5BF9\u8BDD\u4F1A\u4FDD\u7559\u4E0A\u4E0B\u6587\u3002"
1467
- },
1468
- balanceExhaustedHint: {
1469
- en: '[nolo] Insufficient balance. Your message is saved in this dialog \u2014 top up, then send again or say "continue".',
1470
- zh: "[nolo] \u4F59\u989D\u4E0D\u8DB3\u3002\u4F60\u521A\u53D1\u7684\u8BDD\u5DF2\u4FDD\u5B58\u5728\u5F53\u524D\u5BF9\u8BDD\u91CC\u2014\u2014\u5145\u503C\u540E\u76F4\u63A5\u518D\u8BF4\u4E00\u53E5\u6216\u8BF4\u300C\u7EE7\u7EED\u300D\u5373\u53EF\uFF0C\u4E0D\u4F1A\u4E22\u4E0A\u4E0B\u6587\u3002"
1471
- },
1472
- dialogPreservedHint: {
1473
- en: '[nolo] This turn failed, but the dialog is kept. Send another message (or say "continue") to keep going in the same conversation.',
1474
- zh: "[nolo] \u672C\u8F6E\u5931\u8D25\u4E86\uFF0C\u4F46\u5BF9\u8BDD\u5DF2\u4FDD\u7559\u3002\u76F4\u63A5\u518D\u8BF4\u4E00\u53E5\uFF08\u6216\u8BF4\u300C\u7EE7\u7EED\u300D\uFF09\u5373\u53EF\u5728\u540C\u4E00\u5BF9\u8BDD\u91CC\u63A5\u7740\u804A\u3002"
1475
- },
1476
- dialogNotSavedHint: {
1477
- en: "[nolo] This turn did not create a dialog. Your next message will start a new conversation \u2014 restate what you need.",
1478
- zh: "[nolo] \u672C\u8F6E\u6CA1\u6709\u5EFA\u6210\u5BF9\u8BDD\u3002\u4E0B\u4E00\u53E5\u4F1A\u662F\u65B0\u5BF9\u8BDD\u2014\u2014\u8BF7\u628A\u4F60\u60F3\u505A\u7684\u4E8B\u518D\u8BF4\u4E00\u904D\u3002"
1479
- },
1480
- copiedLastReply: {
1481
- en: "Copied the last reply to the clipboard.",
1482
- zh: "\u5DF2\u590D\u5236\u6700\u540E\u4E00\u6761\u56DE\u590D\u5230\u526A\u8D34\u677F\u3002"
1483
- },
1484
- copyNothing: {
1485
- en: "Nothing to copy yet.",
1486
- zh: "\u8FD8\u6CA1\u6709\u53EF\u590D\u5236\u7684\u5185\u5BB9\u3002"
1487
- },
1488
- copyFailed: {
1489
- en: "Copy failed",
1490
- zh: "\u590D\u5236\u5931\u8D25"
1491
- },
1492
- copyUnavailable: {
1493
- en: "Clipboard is unavailable in this environment. The last reply was printed above for manual copy.",
1494
- zh: "\u5F53\u524D\u73AF\u5883\u6CA1\u6709\u53EF\u7528\u7684\u526A\u8D34\u677F\u3002\u6700\u540E\u4E00\u6761\u56DE\u590D\u5DF2\u6253\u5370\u5728\u4E0A\u65B9\uFF0C\u53EF\u624B\u52A8\u590D\u5236\u3002"
1495
- },
1496
- copyUsage: {
1497
- en: "Usage: /copy or /copy view",
1498
- zh: "\u7528\u6CD5\uFF1A/copy \u6216 /copy view"
1499
- },
1500
- copyViewTitle: {
1501
- en: "Copy view \u2014 latest AI reply",
1502
- zh: "\u590D\u5236\u89C6\u56FE \u2014 \u6700\u65B0 AI \u56DE\u590D"
1503
- },
1504
- copyViewHint: {
1505
- en: "Drag to select; edge scrolling uses native terminal scrollback. Press Esc or Enter to return.",
1506
- zh: "\u76F4\u63A5\u62D6\u9009\uFF0C\u62D6\u5230\u8FB9\u7F18\u53EF\u7528\u7EC8\u7AEF\u539F\u751F\u56DE\u6EDA\u8DE8\u5C4F\u9009\u62E9\u3002\u6309 Esc \u6216 Enter \u8FD4\u56DE\u3002"
1507
- },
1508
- historyNoToken: {
1509
- en: "History requires an auth token. Run `nolo login` or set AUTH_TOKEN.",
1510
- zh: "\u67E5\u770B\u5386\u53F2\u5BF9\u8BDD\u9700\u8981\u767B\u5F55\u51ED\u8BC1\u3002\u8BF7\u8FD0\u884C `nolo login` \u6216\u8BBE\u7F6E AUTH_TOKEN\u3002"
1511
- },
1512
- historyBadToken: {
1513
- en: "Could not read a user id from AUTH_TOKEN. Run `nolo login` again.",
1514
- zh: "\u65E0\u6CD5\u4ECE AUTH_TOKEN \u89E3\u6790\u51FA\u7528\u6237 id\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C `nolo login`\u3002"
1515
- },
1516
- mouseOn: {
1517
- en: "Mouse mode on: wheel scrolls the transcript; hold Shift (or Option/Fn) to select text.",
1518
- zh: "\u9F20\u6807\u6A21\u5F0F\u5DF2\u5F00\u542F\uFF1A\u6EDA\u8F6E\u6EDA\u52A8\u5BF9\u8BDD\u8BB0\u5F55\uFF1B\u6309\u4F4F Shift\uFF08\u6216 Option/Fn\uFF09\u53EF\u62D6\u9009\u590D\u5236\u3002"
1519
- },
1520
- mouseOff: {
1521
- en: "Mouse mode off: drag to select/copy freely; scroll with PageUp/PageDown.",
1522
- zh: "\u9F20\u6807\u6A21\u5F0F\u5DF2\u5173\u95ED\uFF1A\u53EF\u76F4\u63A5\u62D6\u9009\u590D\u5236\uFF1B\u7528 PageUp/PageDown \u6EDA\u52A8\u5BF9\u8BDD\u8BB0\u5F55\u3002"
1523
- },
1524
- mouseUsage: {
1525
- en: "Usage: /mouse <on|off>",
1526
- zh: "\u7528\u6CD5\uFF1A/mouse <on|off>"
1527
- },
1528
- langSwitched: {
1529
- en: "Language switched to English.",
1530
- zh: "\u5DF2\u5207\u6362\u4E3A\u4E2D\u6587\u3002"
1531
- },
1532
- // --- Tool trace copy ------------------------------------------------------
1533
- // The compact trace shows only status, never timing or output size: a line
1534
- // count told the user nothing actionable and the ms figure read as noise.
1535
- toolNeedsAction: {
1536
- en: "needs action",
1537
- zh: "\u5F85\u786E\u8BA4"
1538
- },
1539
- toolTimedOut: {
1540
- en: "timed out",
1541
- zh: "\u5DF2\u8D85\u65F6"
1542
- },
1543
- toolExitCode: {
1544
- en: "exit",
1545
- zh: "\u9000\u51FA\u7801"
1546
- },
1547
- toolFailed: {
1548
- en: "failed",
1549
- zh: "\u5931\u8D25"
1550
- },
1551
- // --- Dialog (picker / confirm) copy --------------------------------------
1552
- // Key-hint wording is unified across select / multi-select / confirm so the
1553
- // three dialogs read as one family: "<Label> <↑↓ move · Enter choose ·
1554
- // Esc cancel> <count>". Connectors are "·" between keys, two spaces between
1555
- // the label, hint, and count. zh uses full-width parentheses to match the
1556
- // existing historyPickerTitle; en uses ASCII parentheses.
1557
- dialogSelectLabel: {
1558
- en: "Select",
1559
- zh: "\u9009\u62E9"
1560
- },
1561
- dialogSelectHint: {
1562
- en: "(\u2191\u2193 move \xB7 Enter choose \xB7 Esc cancel)",
1563
- zh: "\uFF08\u2191\u2193 \u79FB\u52A8 \xB7 Enter \u9009\u62E9 \xB7 Esc \u53D6\u6D88\uFF09"
1564
- },
1565
- dialogMultiSelectLabel: {
1566
- en: "Select",
1567
- zh: "\u9009\u62E9"
1568
- },
1569
- dialogMultiSelectHint: {
1570
- en: "(\u2191\u2193 move \xB7 Space toggle \xB7 Enter submit \xB7 Esc cancel)",
1571
- zh: "\uFF08\u2191\u2193 \u79FB\u52A8 \xB7 Space \u5207\u6362 \xB7 Enter \u63D0\u4EA4 \xB7 Esc \u53D6\u6D88\uFF09"
1572
- },
1573
- dialogMultiSelectSelected: {
1574
- en: "selected",
1575
- zh: "\u5DF2\u9009"
1576
- },
1577
- dialogConfirmHint: {
1578
- en: "(\u2191\u2193 move \xB7 Enter choose \xB7 Esc cancel)",
1579
- zh: "\uFF08\u2191\u2193 \u79FB\u52A8 \xB7 Enter \u9009\u62E9 \xB7 Esc \u53D6\u6D88\uFF09"
1580
- },
1581
- dialogConfirmTitle: {
1582
- en: "Confirm destructive shell command",
1583
- zh: "\u786E\u8BA4\u6267\u884C\u7834\u574F\u6027 shell \u547D\u4EE4"
1584
- },
1585
- dialogConfirmBody: {
1586
- en: "This command may delete or reset user content and needs explicit confirmation before it runs.",
1587
- zh: "\u8BE5\u547D\u4EE4\u53EF\u80FD\u5220\u9664\u6216\u91CD\u7F6E\u7528\u6237\u5185\u5BB9\uFF0C\u9700\u8981\u7528\u6237\u660E\u786E\u786E\u8BA4\u540E\u624D\u80FD\u6267\u884C\u3002"
1588
- },
1589
- dialogConfirmCommandLabel: {
1590
- en: "Command",
1591
- zh: "\u547D\u4EE4"
1592
- },
1593
- dialogConfirmCommandTruncated: {
1594
- en: "(truncated)",
1595
- zh: "\uFF08\u5DF2\u622A\u65AD\uFF09"
1596
- },
1597
- dialogConfirmAllowLabel: {
1598
- en: "Allow",
1599
- zh: "\u5141\u8BB8"
1600
- },
1601
- dialogConfirmAllowDetail: {
1602
- en: "execute this time",
1603
- zh: "\u672C\u6B21\u6267\u884C"
1604
- },
1605
- dialogConfirmCancelLabel: {
1606
- en: "Cancel",
1607
- zh: "\u53D6\u6D88"
1608
- },
1609
- dialogConfirmCancelDetail: {
1610
- en: "abort the operation",
1611
- zh: "\u4E2D\u6B62\u64CD\u4F5C"
1612
- },
1613
- contextTitle: {
1614
- en: "Workspace context",
1615
- zh: "\u5DE5\u4F5C\u533A\u4E0A\u4E0B\u6587"
1616
- },
1617
- contextNext: {
1618
- en: "Next:",
1619
- zh: "\u4E0B\u4E00\u6B65\uFF1A"
1620
- },
1621
- contextFieldAgent: {
1622
- en: "agent",
1623
- zh: "\u667A\u80FD\u4F53"
1624
- },
1625
- contextFieldTokens: {
1626
- en: "tokens",
1627
- zh: "\u4EE4\u724C"
1628
- },
1629
- contextFieldDialog: {
1630
- en: "dialog",
1631
- zh: "\u5BF9\u8BDD"
1632
- },
1633
- contextFieldDocs: {
1634
- en: "docs",
1635
- zh: "\u6587\u6863"
1636
- },
1637
- contextFieldSkills: {
1638
- en: "skills",
1639
- zh: "\u6280\u80FD"
1640
- },
1641
- contextFieldProfile: {
1642
- en: "profile",
1643
- zh: "\u914D\u7F6E"
1644
- },
1645
- contextFieldRuntime: {
1646
- en: "runtime",
1647
- zh: "\u8FD0\u884C\u65F6"
1648
- },
1649
- contextFieldTools: {
1650
- en: "tools",
1651
- zh: "\u5DE5\u5177"
1652
- },
1653
- contextFieldThinking: {
1654
- en: "thinking",
1655
- zh: "\u601D\u8003"
1656
- },
1657
- contextFieldServer: {
1658
- en: "server",
1659
- zh: "\u670D\u52A1\u7AEF"
1660
- },
1661
- contextNextAgents: {
1662
- en: "see specialist shortcuts",
1663
- zh: "\u67E5\u770B\u4E13\u7528\u667A\u80FD\u4F53\u5FEB\u6377\u65B9\u5F0F"
1664
- },
1665
- contextNextDoc: {
1666
- en: "add working context",
1667
- zh: "\u6DFB\u52A0\u5DE5\u4F5C\u4E0A\u4E0B\u6587"
1668
- },
1669
- contextNextSkill: {
1670
- en: "attach a skill to this workspace",
1671
- zh: "\u4E3A\u8BE5\u5DE5\u4F5C\u533A\u6302\u8F7D\u6280\u80FD"
1672
- },
1673
- contextNextNew: {
1674
- en: "start a clean dialog",
1675
- zh: "\u5F00\u59CB\u4E00\u4E2A\u5E72\u51C0\u7684\u5BF9\u8BDD"
1676
- },
1677
- agentsTitle: {
1678
- en: "Agents:",
1679
- zh: "\u667A\u80FD\u4F53\uFF1A"
1680
- },
1681
- agentsTip: {
1682
- en: "Tip: run /switch for the full picker, or /switch list for your private agents too.",
1683
- zh: "\u63D0\u793A\uFF1A\u7528 /switch \u6253\u5F00\u5B8C\u6574\u9009\u62E9\u5668\uFF0C\u6216 /switch list \u8FDE\u4F60\u7684\u79C1\u6709\u667A\u80FD\u4F53\u4E00\u8D77\u5217\u51FA\u3002"
1684
- },
1685
- helpText: {
1686
- en: [
1687
- "Commands:",
1688
- " /help Show this help",
1689
- " /new Clear screen and start a fresh dialog",
1690
- " /compact Compact current dialog and fork a new one",
1691
- " /context Show workspace context and next actions",
1692
- " /runtime <mode> Use auto, local, or server runtime",
1693
- " /tools <mode> Control tool trace: hide, compact, verbose",
1694
- " /thinking <mode> Control thinking output: hide, marker, show",
1695
- " /switch Pick an agent interactively (\u2191\u2193, Enter)",
1696
- " /switch list List agents as text",
1697
- " /switch <name> Switch directly by name, alias, or key (alias: /agent)",
1698
- " /agents List platform agent shortcuts",
1699
- " /history Pick a recent dialog to resume (\u2191\u2193, Enter)",
1700
- " /resume <dialogId> Resume a dialog directly by id",
1701
- " /lang <zh|en> Switch interface language",
1702
- " /copy Copy the last reply to the clipboard",
1703
- " /copy view Open native scrollback for partial selection (Ctrl+O)",
1704
- " /mouse <on|off> Toggle mouse mode (off = drag to select text)",
1705
- " /doc List attached docs",
1706
- " /doc attach <doc> Attach a doc to this workspace",
1707
- " /skill List attached skills",
1708
- " /skill attach <ref> Attach a skill (dbKey, name, or SKILL.md path)",
1709
- " /skill detach <ref> Detach a skill",
1710
- " /skill clear Detach all skills",
1711
- " /customize Describe how you want to tune nolo",
1712
- " /tasks List background process tasks (aliases: /jobs, /procs)",
1713
- " /stop <pid|all> Stop background process tasks",
1714
- " /login Show login/profile hint",
1715
- " /profile Show active profile",
1716
- " /update Update the nolo CLI install",
1717
- " /version Show version/update hint",
1718
- " /exit Leave the workspace",
1719
- "",
1720
- "You can also type normally. nolo routes simple read/status requests to CLI commands and sends the rest to the current agent."
1721
- ].join("\n"),
1722
- zh: [
1723
- "\u547D\u4EE4\uFF1A",
1724
- " /help \u663E\u793A\u672C\u5E2E\u52A9",
1725
- " /new \u6E05\u5C4F\u5E76\u5F00\u59CB\u65B0\u5BF9\u8BDD",
1726
- " /compact \u538B\u7F29\u5F53\u524D\u5BF9\u8BDD\u5E76\u5206\u53C9\u51FA\u65B0\u5BF9\u8BDD",
1727
- " /context \u67E5\u770B\u5DE5\u4F5C\u533A\u4E0A\u4E0B\u6587\u4E0E\u540E\u7EED\u64CD\u4F5C",
1728
- " /runtime <mode> \u5207\u6362 runtime\uFF1Aauto\u3001local\u3001server",
1729
- " /tools <mode> \u5DE5\u5177\u8F68\u8FF9\u663E\u793A\uFF1Ahide\u3001compact\u3001verbose",
1730
- " /thinking <mode> \u601D\u8003\u8FC7\u7A0B\u663E\u793A\uFF1Ahide\u3001marker\u3001show",
1731
- " /switch \u4EA4\u4E92\u5F0F\u9009\u62E9 agent\uFF08\u2191\u2193 \u79FB\u52A8\uFF0CEnter \u786E\u8BA4\uFF09",
1732
- " /switch list \u4EE5\u6587\u672C\u5217\u51FA\u5168\u90E8 agent",
1733
- " /switch <name> \u6309\u540D\u79F0\u3001\u522B\u540D\u6216 key \u76F4\u63A5\u5207\u6362\uFF08\u522B\u540D\uFF1A/agent\uFF09",
1734
- " /agents \u5217\u51FA\u5E73\u53F0 agent \u5FEB\u6377\u65B9\u5F0F",
1735
- " /history \u4ECE\u6700\u8FD1\u5BF9\u8BDD\u4E2D\u9009\u62E9\u5E76\u6062\u590D\uFF08\u2191\u2193\uFF0CEnter\uFF09",
1736
- " /resume <dialogId> \u6309 id \u76F4\u63A5\u6062\u590D\u5BF9\u8BDD",
1737
- " /lang <zh|en> \u5207\u6362\u754C\u9762\u8BED\u8A00",
1738
- " /copy \u590D\u5236\u6700\u540E\u4E00\u6761\u56DE\u590D\u5230\u526A\u8D34\u677F",
1739
- " /copy view \u6253\u5F00\u539F\u751F\u56DE\u6EDA\u8FDB\u884C\u8DE8\u5C4F\u62D6\u9009\uFF08Ctrl+O\uFF09",
1740
- " /mouse <on|off> \u5207\u6362\u9F20\u6807\u6A21\u5F0F\uFF08off \u540E\u53EF\u76F4\u63A5\u62D6\u9009\u6587\u672C\uFF09",
1741
- " /doc \u5217\u51FA\u5DF2\u6302\u8F7D\u7684\u6587\u6863",
1742
- " /doc attach <doc> \u6302\u8F7D\u6587\u6863\u5230\u5F53\u524D\u5DE5\u4F5C\u533A",
1743
- " /skill \u5217\u51FA\u5DF2\u6302\u8F7D\u7684\u6280\u80FD",
1744
- " /skill attach <ref> \u6302\u8F7D\u6280\u80FD\uFF08dbKey\u3001\u540D\u79F0\u6216 SKILL.md \u8DEF\u5F84\uFF09",
1745
- " /skill detach <ref> \u5378\u8F7D\u6307\u5B9A\u6280\u80FD",
1746
- " /skill clear \u5378\u8F7D\u5168\u90E8\u6280\u80FD",
1747
- " /customize \u63CF\u8FF0\u4F60\u60F3\u600E\u4E48\u8C03\u6559 nolo",
1748
- " /tasks \u5217\u51FA\u540E\u53F0\u5B50\u8FDB\u7A0B\u4EFB\u52A1\uFF08\u522B\u540D\uFF1A/jobs, /procs\uFF09",
1749
- " /stop <pid|all> \u505C\u6B62\u6307\u5B9A\u7684\u540E\u53F0\u4EFB\u52A1",
1750
- " /login \u67E5\u770B\u767B\u5F55 / \u914D\u7F6E\u63D0\u793A",
1751
- " /profile \u67E5\u770B\u5F53\u524D\u914D\u7F6E\u73AF\u5883",
1752
- " /update \u66F4\u65B0 nolo CLI",
1753
- " /version \u67E5\u770B\u7248\u672C\u4E0E\u66F4\u65B0\u63D0\u793A",
1754
- " /exit \u9000\u51FA\u5DE5\u4F5C\u533A",
1755
- "",
1756
- "\u4E5F\u53EF\u4EE5\u76F4\u63A5\u8F93\u5165\u81EA\u7136\u8BED\u8A00\u3002\u7B80\u5355\u7684\u8BFB\u53D6/\u72B6\u6001\u8BF7\u6C42\u4F1A\u8D70 CLI \u547D\u4EE4\uFF0C\u5176\u4F59\u4EA4\u7ED9\u5F53\u524D agent\u3002"
1757
- ].join("\n")
1974
+ addToPath(path, added, removed, oldPosInc, options) {
1975
+ const last = path.lastComponent;
1976
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
1977
+ return {
1978
+ oldPos: path.oldPos + oldPosInc,
1979
+ lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
1980
+ };
1981
+ } else {
1982
+ return {
1983
+ oldPos: path.oldPos + oldPosInc,
1984
+ lastComponent: { count: 1, added, removed, previousComponent: last }
1985
+ };
1986
+ }
1987
+ }
1988
+ extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
1989
+ const newLen = newTokens.length, oldLen = oldTokens.length;
1990
+ let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
1991
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
1992
+ newPos++;
1993
+ oldPos++;
1994
+ commonCount++;
1995
+ if (options.oneChangePerToken) {
1996
+ basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
1997
+ }
1998
+ }
1999
+ if (commonCount && !options.oneChangePerToken) {
2000
+ basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
2001
+ }
2002
+ basePath.oldPos = oldPos;
2003
+ return newPos;
2004
+ }
2005
+ equals(left, right, options) {
2006
+ if (options.comparator) {
2007
+ return options.comparator(left, right);
2008
+ } else {
2009
+ return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
2010
+ }
2011
+ }
2012
+ removeEmpty(array) {
2013
+ const ret = [];
2014
+ for (let i = 0; i < array.length; i++) {
2015
+ if (array[i]) {
2016
+ ret.push(array[i]);
2017
+ }
2018
+ }
2019
+ return ret;
2020
+ }
2021
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2022
+ castInput(value, options) {
2023
+ return value;
2024
+ }
2025
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2026
+ tokenize(value, options) {
2027
+ return Array.from(value);
2028
+ }
2029
+ join(chars) {
2030
+ return chars.join("");
2031
+ }
2032
+ postProcess(changeObjects, options) {
2033
+ return changeObjects;
2034
+ }
2035
+ get useLongestToken() {
2036
+ return false;
2037
+ }
2038
+ buildValues(lastComponent, newTokens, oldTokens) {
2039
+ const components = [];
2040
+ let nextComponent;
2041
+ while (lastComponent) {
2042
+ components.push(lastComponent);
2043
+ nextComponent = lastComponent.previousComponent;
2044
+ delete lastComponent.previousComponent;
2045
+ lastComponent = nextComponent;
2046
+ }
2047
+ components.reverse();
2048
+ const componentLen = components.length;
2049
+ let componentPos = 0, newPos = 0, oldPos = 0;
2050
+ for (; componentPos < componentLen; componentPos++) {
2051
+ const component = components[componentPos];
2052
+ if (!component.removed) {
2053
+ if (!component.added && this.useLongestToken) {
2054
+ let value = newTokens.slice(newPos, newPos + component.count);
2055
+ value = value.map(function(value2, i) {
2056
+ const oldValue = oldTokens[oldPos + i];
2057
+ return oldValue.length > value2.length ? oldValue : value2;
2058
+ });
2059
+ component.value = this.join(value);
2060
+ } else {
2061
+ component.value = this.join(newTokens.slice(newPos, newPos + component.count));
2062
+ }
2063
+ newPos += component.count;
2064
+ if (!component.added) {
2065
+ oldPos += component.count;
2066
+ }
2067
+ } else {
2068
+ component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
2069
+ oldPos += component.count;
2070
+ }
2071
+ }
2072
+ return components;
1758
2073
  }
1759
2074
  };
1760
- function t(key) {
1761
- return STRINGS[key][currentLocale];
1762
- }
1763
- var TOOL_LABELS = {
1764
- // Local workspace tools (packages/agent-runtime/localWorkspaceTools.ts)
1765
- readFile: { en: "Read", zh: "\u8BFB\u53D6" },
1766
- writeFile: { en: "Write", zh: "\u5199\u5165" },
1767
- editFile: { en: "Edit", zh: "\u7F16\u8F91" },
1768
- listFiles: { en: "List", zh: "\u5217\u51FA" },
1769
- searchFiles: { en: "Search", zh: "\u641C\u7D22" },
1770
- globFiles: { en: "Glob", zh: "\u5339\u914D" },
1771
- execShell: { en: "Run", zh: "\u6267\u884C" },
1772
- runCommand: { en: "Run", zh: "\u6267\u884C" },
1773
- captureVisualState: { en: "Capture", zh: "\u622A\u5C4F" },
1774
- // Workspace / diagnostics
1775
- searchWorkspace: { en: "Search workspace", zh: "\u641C\u7D22\u5DE5\u4F5C\u533A" },
1776
- cliDoctor: { en: "Doctor", zh: "\u81EA\u68C0" },
1777
- cliWhoami: { en: "Whoami", zh: "\u67E5\u770B\u8EAB\u4EFD" },
1778
- checkEnv: { en: "Check env", zh: "\u68C0\u67E5\u73AF\u5883" },
1779
- configure: { en: "Configure", zh: "\u914D\u7F6E" },
1780
- notifyUser: { en: "Notify", zh: "\u901A\u77E5" },
1781
- // Docs / dialogs / spaces
1782
- readDoc: { en: "Read doc", zh: "\u8BFB\u53D6\u6587\u6863" },
1783
- createDoc: { en: "Create doc", zh: "\u65B0\u5EFA\u6587\u6863" },
1784
- updateDoc: { en: "Update doc", zh: "\u66F4\u65B0\u6587\u6863" },
1785
- readDialog: { en: "Read dialog", zh: "\u8BFB\u53D6\u5BF9\u8BDD" },
1786
- listDialogs: { en: "List dialogs", zh: "\u5217\u51FA\u5BF9\u8BDD" },
1787
- queryDialogsBySubjectRef: { en: "Query dialogs", zh: "\u67E5\u8BE2\u5BF9\u8BDD" },
1788
- searchDialogMessages: { en: "Search messages", zh: "\u641C\u7D22\u6D88\u606F" },
1789
- listSpaces: { en: "List spaces", zh: "\u5217\u51FA\u7A7A\u95F4" },
1790
- readSpace: { en: "Read space", zh: "\u8BFB\u53D6\u7A7A\u95F4" },
1791
- // Tables
1792
- createTable: { en: "Create table", zh: "\u521B\u5EFA\u8868" },
1793
- queryTableRows: { en: "Query rows", zh: "\u67E5\u8BE2\u8868\u884C" },
1794
- addTableRow: { en: "Add row", zh: "\u65B0\u589E\u8868\u884C" },
1795
- addTableRows: { en: "Add rows", zh: "\u65B0\u589E\u8868\u884C" },
1796
- updateTableRow: { en: "Update row", zh: "\u66F4\u65B0\u8868\u884C" },
1797
- deleteTableRow: { en: "Delete row", zh: "\u5220\u9664\u8868\u884C" },
1798
- // Web
1799
- fetchWebpage: { en: "Fetch page", zh: "\u6293\u53D6\u7F51\u9875" },
1800
- readPage: { en: "Read page", zh: "\u8BFB\u53D6\u7F51\u9875" },
1801
- exaSearch: { en: "Web search", zh: "\u8054\u7F51\u641C\u7D22" },
1802
- // Skill loading
1803
- loadSkill: { en: "Used Skill", zh: "\u4F7F\u7528\u6280\u80FD" }
2075
+
2076
+ // packages/cli/node_modules/diff/libesm/diff/line.js
2077
+ var LineDiff = class extends Diff {
2078
+ constructor() {
2079
+ super(...arguments);
2080
+ this.tokenize = tokenize;
2081
+ }
2082
+ equals(left, right, options) {
2083
+ if (options.ignoreWhitespace) {
2084
+ if (!options.newlineIsToken || !left.includes("\n")) {
2085
+ left = left.trim();
2086
+ }
2087
+ if (!options.newlineIsToken || !right.includes("\n")) {
2088
+ right = right.trim();
2089
+ }
2090
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
2091
+ if (left.endsWith("\n")) {
2092
+ left = left.slice(0, -1);
2093
+ }
2094
+ if (right.endsWith("\n")) {
2095
+ right = right.slice(0, -1);
2096
+ }
2097
+ }
2098
+ return super.equals(left, right, options);
2099
+ }
1804
2100
  };
1805
- function toolLabel(name) {
1806
- return TOOL_LABELS[name]?.[currentLocale] ?? name;
2101
+ var lineDiff = new LineDiff();
2102
+ function diffLines(oldStr, newStr, options) {
2103
+ return lineDiff.diff(oldStr, newStr, options);
2104
+ }
2105
+ function tokenize(value, options) {
2106
+ if (options.stripTrailingCr) {
2107
+ value = value.replace(/\r\n/g, "\n");
2108
+ }
2109
+ const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
2110
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
2111
+ linesAndNewlines.pop();
2112
+ }
2113
+ for (let i = 0; i < linesAndNewlines.length; i++) {
2114
+ const line = linesAndNewlines[i];
2115
+ if (i % 2 && !options.newlineIsToken) {
2116
+ retLines[retLines.length - 1] += line;
2117
+ } else {
2118
+ retLines.push(line);
2119
+ }
2120
+ }
2121
+ return retLines;
1807
2122
  }
1808
2123
 
1809
2124
  // packages/cli/client/toolOutput.ts
@@ -1876,25 +2191,65 @@ function readReadFileRange(metadata) {
1876
2191
  if (!truncated && startLine === 1 && endLine === totalLines) return void 0;
1877
2192
  return `${startLine}-${endLine}/${totalLines}`;
1878
2193
  }
1879
- var EDIT_SNIPPET_MAX_LINES = 5;
2194
+ var EDIT_SNIPPET_MAX_LINES = 10;
1880
2195
  var EDIT_SNIPPET_MAX_WIDTH = 96;
1881
2196
  function formatEditFileSnippet(metadata) {
1882
2197
  const oldSnippet = typeof metadata.oldSnippet === "string" ? metadata.oldSnippet : void 0;
1883
2198
  const newSnippet = typeof metadata.newSnippet === "string" ? metadata.newSnippet : void 0;
1884
2199
  if (!oldSnippet && !newSnippet) return void 0;
1885
- const lines = [];
1886
- if (oldSnippet) {
1887
- for (const line of snippetLines(oldSnippet)) lines.push(`- ${line}`);
2200
+ if (oldSnippet && !newSnippet) {
2201
+ return snippetLinesWithKind(oldSnippet, "removed");
2202
+ }
2203
+ if (newSnippet && !oldSnippet) {
2204
+ return snippetLinesWithKind(newSnippet, "added");
1888
2205
  }
1889
- if (newSnippet) {
1890
- for (const line of snippetLines(newSnippet)) lines.push(`+ ${line}`);
2206
+ const parts = diffLines(oldSnippet, newSnippet);
2207
+ const all = [];
2208
+ for (const part of parts) {
2209
+ const kind = part.added ? "added" : part.removed ? "removed" : "context";
2210
+ const raw = part.value.split("\n");
2211
+ if (raw.length > 0 && raw[raw.length - 1] === "") raw.pop();
2212
+ for (const line of raw) all.push(buildEditLine(kind, line));
1891
2213
  }
1892
- return lines.length ? lines.join("\n") : void 0;
2214
+ const changeCount = all.filter((l) => l.kind !== "context").length;
2215
+ if (changeCount === 0) return void 0;
2216
+ return windowAndTruncate(all, EDIT_SNIPPET_MAX_LINES);
1893
2217
  }
1894
- function snippetLines(snippet) {
2218
+ function prefixFor(kind) {
2219
+ return kind === "added" ? "+ " : kind === "removed" ? "- " : " ";
2220
+ }
2221
+ function buildEditLine(kind, body) {
2222
+ return { kind, text: prefixFor(kind) + truncateByDisplayWidth(body, EDIT_SNIPPET_MAX_WIDTH) };
2223
+ }
2224
+ function snippetLinesWithKind(snippet, kind) {
1895
2225
  const lines = snippet.split(/\r?\n/).filter((line) => line.length > 0);
1896
- const shown = lines.slice(0, EDIT_SNIPPET_MAX_LINES);
1897
- return shown.map((line) => line.length > EDIT_SNIPPET_MAX_WIDTH ? `${line.slice(0, EDIT_SNIPPET_MAX_WIDTH)}\u2026` : line);
2226
+ return lines.slice(0, EDIT_SNIPPET_MAX_LINES).map((line) => buildEditLine(kind, line));
2227
+ }
2228
+ function truncateByDisplayWidth(line, maxWidth) {
2229
+ if (displayWidth(line) <= maxWidth) return line;
2230
+ let width = 0;
2231
+ let kept = "";
2232
+ for (const char of line) {
2233
+ const w = displayWidth(char);
2234
+ if (width + w + 1 > maxWidth) break;
2235
+ kept += char;
2236
+ width += w;
2237
+ }
2238
+ return `${kept}\u2026`;
2239
+ }
2240
+ function windowAndTruncate(lines, maxLines) {
2241
+ if (lines.length <= maxLines) return lines;
2242
+ const firstChange = lines.findIndex((l) => l.kind !== "context");
2243
+ if (firstChange === -1) return lines.slice(0, maxLines);
2244
+ const half = Math.floor(maxLines / 2);
2245
+ let start = Math.max(0, firstChange - half);
2246
+ if (start + maxLines > lines.length) start = Math.max(0, lines.length - maxLines);
2247
+ const kept = lines.slice(start, start + maxLines);
2248
+ const omitted = lines.length - kept.length;
2249
+ if (omitted > 0) {
2250
+ kept.push({ kind: "context", text: ` \u2026 +${omitted} more lines` });
2251
+ }
2252
+ return kept;
1898
2253
  }
1899
2254
  function isFailedToolResult(event) {
1900
2255
  const exitCode = event.metadata?.exitCode;
@@ -1905,6 +2260,22 @@ function isFailedToolResult(event) {
1905
2260
  function isNeedsActionToolResult(event) {
1906
2261
  return Boolean(event.metadata?.actionGate);
1907
2262
  }
2263
+ function readRunAgentName(parsed) {
2264
+ const agentName = typeof parsed.agentName === "string" ? parsed.agentName.trim() : "";
2265
+ if (agentName) return agentName;
2266
+ const name = typeof parsed.name === "string" ? parsed.name.trim() : "";
2267
+ return name || "agent";
2268
+ }
2269
+ function readRunLogLines(parsed) {
2270
+ if (Array.isArray(parsed.logLines)) return parsed.logLines;
2271
+ if (typeof parsed.logTail === "string" && parsed.logTail.trim()) {
2272
+ return parsed.logTail.split("\n");
2273
+ }
2274
+ return void 0;
2275
+ }
2276
+ function readRunErrorMessage(parsed) {
2277
+ return typeof parsed.errorMessage === "string" ? parsed.errorMessage : void 0;
2278
+ }
1908
2279
  function parseUiAskChoiceForCli(event) {
1909
2280
  if (event.toolName !== "ui_ask_choice" && !event.metadata?.uiAskChoice) {
1910
2281
  return null;
@@ -1916,18 +2287,66 @@ function parseUiAskChoiceForCli(event) {
1916
2287
  label: String(c.label ?? "").trim(),
1917
2288
  userMessage: typeof c.userMessage === "string" ? c.userMessage : void 0
1918
2289
  })).filter((c) => c.label.length > 0);
1919
- if (!question || choices.length === 0) return null;
1920
- return { question, choices };
2290
+ const selected = parsed.selected && typeof parsed.selected === "object" ? {
2291
+ label: String(parsed.selected.label ?? "").trim(),
2292
+ userMessage: String(parsed.selected.userMessage ?? "").trim()
2293
+ } : void 0;
2294
+ const answers = Array.isArray(parsed.answers) ? parsed.answers : void 0;
2295
+ const cancelled = Boolean(parsed.cancelled);
2296
+ const resolved = Boolean(
2297
+ event.metadata?.resolved || selected || cancelled || answers && answers.length > 0
2298
+ );
2299
+ if (!resolved && (!question || choices.length === 0)) return null;
2300
+ if (!question && !selected && !cancelled) return null;
2301
+ return {
2302
+ question,
2303
+ choices,
2304
+ ...selected ? { selected } : {},
2305
+ ...answers ? { answers } : {},
2306
+ ...cancelled ? { cancelled: true } : {},
2307
+ resolved
2308
+ };
1921
2309
  }
1922
2310
  function formatUiAskChoiceBlock(event, colorEnabled) {
1923
2311
  const parsed = parseUiAskChoiceForCli(event);
1924
2312
  if (!parsed) return null;
1925
2313
  const lines = [];
1926
2314
  lines.push("");
2315
+ const questionText = parsed.question || "";
1927
2316
  if (colorEnabled) {
1928
- lines.push(`${themeText("\u2753 ", "info", true)}${styleCliText(parsed.question, "cyan", true)}`);
2317
+ lines.push(`${themeText("\u2753 ", "info", true)}${styleCliText(questionText, "cyan", true)}`);
1929
2318
  } else {
1930
- lines.push(`\u2753 ${parsed.question}`);
2319
+ lines.push(`\u2753 ${questionText}`);
2320
+ }
2321
+ if (parsed.resolved) {
2322
+ if (parsed.cancelled) {
2323
+ const cancelled = t("askChoiceHistoryCancelled");
2324
+ lines.push(
2325
+ colorEnabled ? ` ${themeText("\xB7", "chrome", true)} ${themeText(cancelled, "muted", true)}` : ` \xB7 ${cancelled}`
2326
+ );
2327
+ return `${lines.join("\n")}
2328
+ `;
2329
+ }
2330
+ const selectedLabel = parsed.selected?.label || parsed.selected?.userMessage || (parsed.answers ? parsed.answers.map((a) => a.userMessage).filter(Boolean).join(", ") : "");
2331
+ const marker = t("askChoiceHistorySelected");
2332
+ const displayLabel = selectedLabel || "\u2014";
2333
+ if (colorEnabled) {
2334
+ lines.push(
2335
+ ` ${themeText("\u2713", "success", true)} ${themeText(marker, "muted", true)} ${displayLabel}`
2336
+ );
2337
+ } else {
2338
+ lines.push(` \u2713 ${marker} ${displayLabel}`);
2339
+ }
2340
+ if (parsed.answers && parsed.answers.length > 1) {
2341
+ for (const answer of parsed.answers) {
2342
+ if (!answer.userMessage) continue;
2343
+ lines.push(
2344
+ colorEnabled ? ` ${themeText("\xB7", "chrome", true)} ${answer.userMessage}` : ` \xB7 ${answer.userMessage}`
2345
+ );
2346
+ }
2347
+ }
2348
+ return `${lines.join("\n")}
2349
+ `;
1931
2350
  }
1932
2351
  parsed.choices.forEach((choice, i) => {
1933
2352
  const num = String(i + 1);
@@ -1940,7 +2359,7 @@ function formatUiAskChoiceBlock(event, colorEnabled) {
1940
2359
  lines.push(` ${num}. ${label}`);
1941
2360
  }
1942
2361
  });
1943
- const hint = "\u8BF7\u8F93\u5165\u5E8F\u53F7\u9009\u62E9\uFF0C\u6216\u76F4\u63A5\u56DE\u590D\uFF1A";
2362
+ const hint = t("askChoiceHistoryHint");
1944
2363
  if (colorEnabled) {
1945
2364
  lines.push(` ${dimCliText(hint, true)}`);
1946
2365
  } else {
@@ -1959,6 +2378,129 @@ function formatToolTraceLine(text, colorEnabled, accent = "none") {
1959
2378
  return `${dimCliText(text, true)}
1960
2379
  `;
1961
2380
  }
2381
+ function recoverOrchestrationDisplayFromContent(toolName, content) {
2382
+ const trimmed = content.trim();
2383
+ if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return content;
2384
+ const labels = agentRunCardLabels();
2385
+ try {
2386
+ const parsed = JSON.parse(trimmed);
2387
+ if (toolName === "listAgents") {
2388
+ const agents = Array.isArray(parsed.agents) ? parsed.agents : [];
2389
+ return formatAgentListCard(agents);
2390
+ }
2391
+ if (toolName === "startAgentRun") {
2392
+ const name = typeof parsed.agentName === "string" && parsed.agentName.trim() ? parsed.agentName.trim() : typeof parsed.name === "string" && parsed.name.trim() ? parsed.name.trim() : "agent";
2393
+ const status = typeof parsed.status === "string" ? parsed.status : "running";
2394
+ return formatStartRunCard(name, status, labels);
2395
+ }
2396
+ if (toolName === "controlAgentRun") {
2397
+ if (Array.isArray(parsed.runs)) {
2398
+ const runs = parsed.runs;
2399
+ return formatListRunsCard(runs, labels);
2400
+ }
2401
+ const status = typeof parsed.status === "string" ? parsed.status : void 0;
2402
+ if (parsed.found === false || status === "not_found") {
2403
+ return formatNotFoundRunCard(labels);
2404
+ }
2405
+ if (status === "killed" || status === "cancelled" || status === "cancelling") {
2406
+ return formatStopRunCard(status, labels);
2407
+ }
2408
+ return formatStatusRunCard(readRunAgentName(parsed), status ?? "\u2014", {
2409
+ errorMessage: readRunErrorMessage(parsed),
2410
+ logLines: readRunLogLines(parsed),
2411
+ labels
2412
+ });
2413
+ }
2414
+ } catch {
2415
+ }
2416
+ return content;
2417
+ }
2418
+ function parseControlAgentRunStatusEvent(event) {
2419
+ const raw = typeof event.content === "string" && event.content.trim() ? event.content.trim() : "";
2420
+ if (!raw.startsWith("{")) return null;
2421
+ try {
2422
+ const parsed = JSON.parse(raw);
2423
+ if (Array.isArray(parsed.runs)) return null;
2424
+ const status = typeof parsed.status === "string" ? parsed.status : void 0;
2425
+ if (parsed.found === false || status === "not_found") return null;
2426
+ if (status === "killed" || status === "cancelled" || status === "cancelling") return null;
2427
+ if (!status) return null;
2428
+ const runId = typeof parsed.runId === "string" && parsed.runId.trim() ? parsed.runId.trim() : typeof event.metadata?.runId === "string" ? event.metadata.runId : "";
2429
+ if (!runId) return null;
2430
+ const agentName = readRunAgentName(parsed);
2431
+ const errorMessage = readRunErrorMessage(parsed);
2432
+ const logLines = readRunLogLines(parsed);
2433
+ const logKey = logLines && logLines.length > 0 ? logLines.join("\n") : "";
2434
+ return { runId, status, agentName, errorMessage, logLines, logKey };
2435
+ } catch {
2436
+ return null;
2437
+ }
2438
+ }
2439
+ function formatOrchestrationCardBlock(event, toolName, colorEnabled) {
2440
+ const rawLabel = toolLabel(toolName);
2441
+ let rawDataStr = typeof event.metadata?.displayData === "string" && event.metadata.displayData.trim() ? event.metadata.displayData : typeof event.content === "string" ? event.content : "";
2442
+ if (typeof event.metadata?.displayData !== "string" && typeof event.content === "string" && event.content.trim()) {
2443
+ rawDataStr = recoverOrchestrationDisplayFromContent(toolName, event.content);
2444
+ }
2445
+ const failed = event.type === "tool-error" || isFailedToolResult(event) || Boolean(event.metadata?.failed) || /^Error:/i.test(rawDataStr.trim());
2446
+ if (failed) {
2447
+ const firstLine = rawDataStr.trim().split("\n")[0] || event.summary || event.message || t("toolFailed");
2448
+ const message = clip(firstLine, 96);
2449
+ if (!colorEnabled) {
2450
+ return `\u2717 ${rawLabel} ${message}
2451
+ `;
2452
+ }
2453
+ const cross = themeText("\u2717", "danger", true);
2454
+ const labelPart2 = themeText(rawLabel, "muted", true);
2455
+ const msgPart = themeText(message, "danger", true);
2456
+ return `${cross} ${labelPart2} ${msgPart}
2457
+ `;
2458
+ }
2459
+ const displayData = rawDataStr.trim();
2460
+ const lines = displayData ? displayData.split("\n").filter((line) => !/^\s*agent\s+agent\s*$/.test(line)) : [];
2461
+ if (!colorEnabled) {
2462
+ let out2 = `\u25CF ${rawLabel}
2463
+ `;
2464
+ for (const line of lines) {
2465
+ out2 += ` ${line}
2466
+ `;
2467
+ }
2468
+ return out2;
2469
+ }
2470
+ const bullet = themeText("\u25CF", "success", true);
2471
+ const labelPart = themeText(rawLabel, "muted", true);
2472
+ let out = `${bullet} ${labelPart}
2473
+ `;
2474
+ for (const line of lines) {
2475
+ out += ` ${themeText(line, "muted", true)}
2476
+ `;
2477
+ }
2478
+ return out;
2479
+ }
2480
+ function formatFoldedControlStatusCard(snapshot, colorEnabled) {
2481
+ const labels = agentRunCardLabels();
2482
+ const body = formatStatusRunCard(snapshot.agentName, snapshot.status, {
2483
+ errorMessage: snapshot.errorMessage,
2484
+ logLines: snapshot.logLines,
2485
+ pollCount: snapshot.pollCount,
2486
+ elapsedMs: snapshot.elapsedMs,
2487
+ includeLogTail: snapshot.includeLogTail,
2488
+ labels
2489
+ });
2490
+ return formatOrchestrationCardBlock(
2491
+ {
2492
+ type: "tool-result",
2493
+ round: 0,
2494
+ toolCallId: `fold-${snapshot.runId}`,
2495
+ toolName: "controlAgentRun",
2496
+ content: "",
2497
+ metadata: { displayData: body },
2498
+ elapsedMs: snapshot.elapsedMs
2499
+ },
2500
+ "controlAgentRun",
2501
+ colorEnabled
2502
+ );
2503
+ }
1962
2504
  function formatVerboseToolEvent(event, colorEnabled) {
1963
2505
  const round = event.round + 1;
1964
2506
  const detail = event.argumentsPreview ? ` ${event.argumentsPreview}` : "";
@@ -2006,15 +2548,16 @@ function isRunResultFoldable(event) {
2006
2548
  function formatSearchTreeBlockForCli(items, colorEnabled) {
2007
2549
  if (items.length === 0) return "";
2008
2550
  const { count, lines } = formatSearchTreeLines(items);
2551
+ const titleText = toolLabel("searchFiles");
2009
2552
  if (!colorEnabled) {
2010
- const headerLine2 = `\u2022 Search (${count})
2553
+ const headerLine2 = `\u2022 ${titleText} (${count})
2011
2554
  `;
2012
2555
  const treeLines2 = lines.map((l) => ` ${l.connector}${l.queryText}`).join("\n");
2013
2556
  return `${headerLine2}${treeLines2}
2014
2557
  `;
2015
2558
  }
2016
2559
  const bullet = themeText("\u2022", "chrome", true);
2017
- const title = styleCliText("Search", "bold", true);
2560
+ const title = styleCliText(titleText, "bold", true);
2018
2561
  const countText = themeText(`(${count})`, "muted", true);
2019
2562
  const headerLine = `${bullet} ${title} ${countText}
2020
2563
  `;
@@ -2029,15 +2572,16 @@ function formatSearchTreeBlockForCli(items, colorEnabled) {
2029
2572
  function formatReadTreeBlockForCli(items, colorEnabled) {
2030
2573
  if (items.length === 0) return "";
2031
2574
  const { count, lines } = formatReadTreeLines(items);
2575
+ const titleText = toolLabel("readFile");
2032
2576
  if (!colorEnabled) {
2033
- const headerLine2 = `\u2022 Read (${count})
2577
+ const headerLine2 = `\u2022 ${titleText} (${count})
2034
2578
  `;
2035
2579
  const treeLines2 = lines.map((l) => ` ${l.connector}${l.pathWithRange}`).join("\n");
2036
2580
  return `${headerLine2}${treeLines2}
2037
2581
  `;
2038
2582
  }
2039
2583
  const bullet = themeText("\u2022", "chrome", true);
2040
- const title = styleCliText("Read", "bold", true);
2584
+ const title = styleCliText(titleText, "bold", true);
2041
2585
  const countText = themeText(`(${count})`, "muted", true);
2042
2586
  const headerLine = `${bullet} ${title} ${countText}
2043
2587
  `;
@@ -2052,15 +2596,16 @@ function formatReadTreeBlockForCli(items, colorEnabled) {
2052
2596
  function formatRunTreeBlockForCli(items, colorEnabled) {
2053
2597
  if (items.length === 0) return "";
2054
2598
  const { count, lines } = formatRunTreeLines(items);
2599
+ const titleText = toolLabel("execShell");
2055
2600
  if (!colorEnabled) {
2056
- const headerLine2 = `\u2022 Run (${count})
2601
+ const headerLine2 = `\u2022 ${titleText} (${count})
2057
2602
  `;
2058
2603
  const treeLines2 = lines.map((l) => ` ${l.connector}${l.commandText}`).join("\n");
2059
2604
  return `${headerLine2}${treeLines2}
2060
2605
  `;
2061
2606
  }
2062
2607
  const bullet = themeText("\u2022", "chrome", true);
2063
- const title = styleCliText("Run", "bold", true);
2608
+ const title = styleCliText(titleText, "bold", true);
2064
2609
  const countText = themeText(`(${count})`, "muted", true);
2065
2610
  const headerLine = `${bullet} ${title} ${countText}
2066
2611
  `;
@@ -2075,15 +2620,16 @@ function formatRunTreeBlockForCli(items, colorEnabled) {
2075
2620
  function formatFetchTreeBlockForCli(items, colorEnabled) {
2076
2621
  if (items.length === 0) return "";
2077
2622
  const { count, lines } = formatFetchTreeLines(items);
2623
+ const titleText = toolLabel("fetchWebpage");
2078
2624
  if (!colorEnabled) {
2079
- const headerLine2 = `\u2022 Fetch (${count})
2625
+ const headerLine2 = `\u2022 ${titleText} (${count})
2080
2626
  `;
2081
2627
  const treeLines2 = lines.map((l) => ` ${l.connector}${l.urlText}`).join("\n");
2082
2628
  return `${headerLine2}${treeLines2}
2083
2629
  `;
2084
2630
  }
2085
2631
  const bullet = themeText("\u2022", "chrome", true);
2086
- const title = styleCliText("Fetch", "bold", true);
2632
+ const title = styleCliText(titleText, "bold", true);
2087
2633
  const countText = themeText(`(${count})`, "muted", true);
2088
2634
  const headerLine = `${bullet} ${title} ${countText}
2089
2635
  `;
@@ -2137,24 +2683,24 @@ function formatCompactToolLine(event, pending, colorEnabled) {
2137
2683
  const skillName = resolveLoadSkillName(event);
2138
2684
  const content = typeof event.content === "string" ? event.content : "";
2139
2685
  const failed2 = /^Skill\s+"[^"]*"\s+not found/.test(content) || isFailedToolResult(event);
2686
+ const labelText = t("usedSkillLabel");
2140
2687
  if (failed2) {
2141
2688
  const message = clip(content.split("\n")[0] || t("toolFailed"), 96);
2142
- return formatToolTraceLine(`\u25B8 Used Skill (${skillName}) \u2717 ${message}`, colorEnabled, "error");
2689
+ return formatToolTraceLine(`\u25B8 ${labelText} (${skillName}) \u2717 ${message}`, colorEnabled, "error");
2143
2690
  }
2144
- const resultLine = `Skill "${skillName}" loaded inline. Follow its instructions.`;
2145
2691
  if (!colorEnabled) {
2146
- return `\u25CF Used Skill (${skillName})
2147
- ${resultLine}
2692
+ return `\u2726 ${labelText}: ${skillName}
2148
2693
  `;
2149
2694
  }
2150
- const bullet = themeText("\u25CF", "success", true);
2151
- const labelPart = themeText("Used Skill", "muted", true);
2152
- const namePart = themeText(`(${skillName})`, "chrome", true);
2153
- const detail = themeText(` ${resultLine}`, "muted", true);
2154
- return `${bullet} ${labelPart} ${namePart}
2155
- ${detail}
2695
+ const star = themeText("\u2726", "success", true);
2696
+ const labelPart = themeText(labelText, "muted", true);
2697
+ const namePart = themeText(skillName, "chrome", true);
2698
+ return `${star} ${labelPart}: ${namePart}
2156
2699
  `;
2157
2700
  }
2701
+ if (event.type === "tool-result" && (toolName === "listAgents" || toolName === "startAgentRun" || toolName === "controlAgentRun")) {
2702
+ return formatOrchestrationCardBlock(event, toolName, colorEnabled);
2703
+ }
2158
2704
  if (event.type === "tool-result" && (event.toolName === "ui_ask_choice" || event.metadata?.uiAskChoice)) {
2159
2705
  const block = formatUiAskChoiceBlock(event, colorEnabled);
2160
2706
  if (block) return block;
@@ -2170,42 +2716,23 @@ ${detail}
2170
2716
  } else {
2171
2717
  const chromePointer = themeText("\u25B8", "chrome", true);
2172
2718
  const mutedLabel = themeText(rawLabel, "muted", true);
2173
- const argsPart = rawArgs ? ` ${dimCliText(rawArgs, true)}` : "";
2174
- const statusToken = failed ? themeText("\u2717", "danger", true) : isNeedsActionToolResult(event) ? themeText("!", "warning", true) : themeText("\u2713", "success", true);
2175
- const suffixPart = hint.inline ? ` ${dimCliText(hint.inline, true)}` : "";
2176
- mainLine = `${chromePointer} ${mutedLabel}${argsPart} ${statusToken}${suffixPart}
2177
- `;
2178
- }
2179
- if (!hint.detail) return mainLine;
2180
- const detailLines = hint.detail.split("\n").map((line) => formatEditDetailLine(line, colorEnabled)).join("");
2181
- return `${mainLine}${detailLines}`;
2182
- }
2183
- function formatEditDetailLine(line, colorEnabled) {
2184
- const marker = line.slice(0, 2);
2185
- const rest = line.slice(2);
2186
- if (!colorEnabled) return ` ${line}
2187
- `;
2188
- const diff = diffLineSequences();
2189
- if (!diff) {
2190
- const color = marker === "- " ? "red" : marker === "+ " ? "green" : void 0;
2191
- if (color) {
2192
- return ` ${styleCliText(marker, color, true)}${dimCliText(rest, true)}
2193
- `;
2194
- }
2195
- return ` ${dimCliText(line, true)}
2196
- `;
2197
- }
2198
- const RESET2 = "\x1B[0m";
2199
- if (marker === "- ") {
2200
- return ` ${diff.removed.bg}${diff.removed.fg}- ${rest}${RESET2}
2719
+ const argsPart = rawArgs ? ` ${dimCliText(rawArgs, true)}` : "";
2720
+ const statusToken = failed ? themeText("\u2717", "danger", true) : isNeedsActionToolResult(event) ? themeText("!", "warning", true) : themeText("\u2713", "success", true);
2721
+ const suffixPart = hint.inline ? ` ${dimCliText(hint.inline, true)}` : "";
2722
+ mainLine = `${chromePointer} ${mutedLabel}${argsPart} ${statusToken}${suffixPart}
2201
2723
  `;
2202
2724
  }
2203
- if (marker === "+ ") {
2204
- return ` ${diff.added.bg}${diff.added.fg}+ ${rest}${RESET2}
2205
- `;
2725
+ if (!hint.detail?.length) return mainLine;
2726
+ return `${mainLine}${formatEditDetailBlock(hint.detail, colorEnabled)}`;
2727
+ }
2728
+ function formatEditDetailBlock(lines, colorEnabled) {
2729
+ if (!colorEnabled) {
2730
+ return lines.map((line) => ` ${line.text}
2731
+ `).join("");
2206
2732
  }
2207
- return ` ${dimCliText(line, true)}
2208
- `;
2733
+ const padTo = Math.max(...lines.map((line) => displayWidth(line.text))) + 1;
2734
+ return lines.map((line) => ` ${renderDiffLine({ kind: line.kind, text: line.text, padTo, colorEnabled: true })}
2735
+ `).join("");
2209
2736
  }
2210
2737
  function createToolEventFormatter(mode, colorEnabled = resolveCliColorEnabled()) {
2211
2738
  const pending = /* @__PURE__ */ new Map();
@@ -2213,8 +2740,33 @@ function createToolEventFormatter(mode, colorEnabled = resolveCliColorEnabled())
2213
2740
  let searchBuffer = [];
2214
2741
  let runBuffer = [];
2215
2742
  let fetchBuffer = [];
2743
+ let statusFold = null;
2744
+ const lastEmittedLogByRunId = /* @__PURE__ */ new Map();
2745
+ const flushStatusFold = () => {
2746
+ if (!statusFold) return "";
2747
+ const fold = statusFold;
2748
+ statusFold = null;
2749
+ const prevLog = lastEmittedLogByRunId.get(fold.runId);
2750
+ const includeLogTail = Boolean(fold.logKey) && fold.logKey !== prevLog;
2751
+ if (fold.logKey) {
2752
+ lastEmittedLogByRunId.set(fold.runId, fold.logKey);
2753
+ }
2754
+ return formatFoldedControlStatusCard(
2755
+ {
2756
+ runId: fold.runId,
2757
+ status: fold.status,
2758
+ agentName: fold.agentName,
2759
+ errorMessage: fold.errorMessage,
2760
+ logLines: fold.logLines,
2761
+ pollCount: fold.pollCount,
2762
+ elapsedMs: fold.elapsedMs,
2763
+ includeLogTail
2764
+ },
2765
+ colorEnabled
2766
+ );
2767
+ };
2216
2768
  const flushBuffers = () => {
2217
- let out = "";
2769
+ let out = flushStatusFold();
2218
2770
  if (readBuffer.length > 0) {
2219
2771
  const items = readBuffer.map((evt) => {
2220
2772
  const call = pending.get(evt.toolCallId);
@@ -2263,6 +2815,51 @@ function createToolEventFormatter(mode, colorEnabled = resolveCliColorEnabled())
2263
2815
  const formatter = (event) => {
2264
2816
  if (mode === "hide") return "";
2265
2817
  if (mode === "verbose") return formatVerboseToolEvent(event, colorEnabled);
2818
+ if (event.toolName === "controlAgentRun") {
2819
+ if (event.type === "tool-call") {
2820
+ pending.set(event.toolCallId, {
2821
+ toolName: event.toolName,
2822
+ argumentsPreview: event.argumentsPreview
2823
+ });
2824
+ return "";
2825
+ }
2826
+ if (event.type === "tool-result") {
2827
+ const snapshot = parseControlAgentRunStatusEvent(event);
2828
+ if (snapshot) {
2829
+ let out = "";
2830
+ if (statusFold && statusFold.runId !== snapshot.runId) {
2831
+ out += flushStatusFold();
2832
+ }
2833
+ if (!statusFold) {
2834
+ statusFold = {
2835
+ ...snapshot,
2836
+ pollCount: 1,
2837
+ elapsedMs: event.elapsedMs
2838
+ };
2839
+ } else {
2840
+ statusFold = {
2841
+ runId: snapshot.runId,
2842
+ status: snapshot.status,
2843
+ agentName: snapshot.agentName,
2844
+ errorMessage: snapshot.errorMessage ?? statusFold.errorMessage,
2845
+ logLines: snapshot.logLines ?? statusFold.logLines,
2846
+ logKey: snapshot.logKey || statusFold.logKey,
2847
+ pollCount: statusFold.pollCount + 1,
2848
+ elapsedMs: event.elapsedMs
2849
+ };
2850
+ }
2851
+ pending.delete(event.toolCallId);
2852
+ if (isAgentRunTerminalStatus(snapshot.status)) {
2853
+ out += flushBuffers();
2854
+ }
2855
+ return out;
2856
+ }
2857
+ const flushed2 = flushBuffers();
2858
+ const call2 = pending.get(event.toolCallId);
2859
+ pending.delete(event.toolCallId);
2860
+ return `${flushed2}${formatCompactToolLine(event, call2, colorEnabled)}`;
2861
+ }
2862
+ }
2266
2863
  if (isReadToolName(event.toolName)) {
2267
2864
  if (event.type === "tool-call") {
2268
2865
  pending.set(event.toolCallId, {
@@ -2563,6 +3160,12 @@ ${options.agentName} > `);
2563
3160
  spinner.show(activeLabel);
2564
3161
  options.activityReporter?.(activeLabel);
2565
3162
  }
3163
+ if (event.type === "tool-result" && options.onAgentRunStatus && (event.toolName === "startAgentRun" || event.toolName === "controlAgentRun")) {
3164
+ const snapshot = extractAgentRunStatusSnapshot(event);
3165
+ if (snapshot) {
3166
+ options.onAgentRunStatus(snapshot);
3167
+ }
3168
+ }
2566
3169
  };
2567
3170
  return {
2568
3171
  spinner,
@@ -2611,6 +3214,30 @@ ${options.agentName} > (no text response)
2611
3214
  }
2612
3215
  };
2613
3216
  }
3217
+ function extractAgentRunStatusSnapshot(event) {
3218
+ if (event.type !== "tool-result") return null;
3219
+ const content = typeof event.content === "string" ? event.content.trim() : "";
3220
+ if (!content.startsWith("{")) return null;
3221
+ try {
3222
+ const parsed = JSON.parse(content);
3223
+ const runId = typeof parsed.runId === "string" ? parsed.runId : "";
3224
+ const status = typeof parsed.status === "string" ? parsed.status : "running";
3225
+ const agentName = typeof parsed.agentName === "string" ? parsed.agentName : typeof parsed.name === "string" ? parsed.name : void 0;
3226
+ const logTail = typeof parsed.logTail === "string" ? parsed.logTail : void 0;
3227
+ const logLines = Array.isArray(parsed.logLines) ? parsed.logLines : void 0;
3228
+ const errorMessage = typeof parsed.errorMessage === "string" ? parsed.errorMessage : void 0;
3229
+ return {
3230
+ runId,
3231
+ agentName,
3232
+ status,
3233
+ logTail,
3234
+ logLines,
3235
+ errorMessage
3236
+ };
3237
+ } catch {
3238
+ return null;
3239
+ }
3240
+ }
2614
3241
 
2615
3242
  // packages/cli/client/agentRunStream.ts
2616
3243
  async function readStreamingAgentRun(options, res, existingSpinner) {
@@ -2835,10 +3462,165 @@ function isKnownServerPlatformAgent(options) {
2835
3462
  );
2836
3463
  }
2837
3464
 
3465
+ // packages/core/collapsedPaste.ts
3466
+ var COLLAPSE_PASTE_MIN_LINES = 8;
3467
+ var COLLAPSE_PASTE_MIN_CHARS = 400;
3468
+ var COLLAPSED_PASTE_PLACEHOLDER_RE = /\[paste #(\d+) · (\d+) lines\]/g;
3469
+ var COLLAPSED_PASTE_MODEL_REFERENCE_RE = /\[paste #(\d+)(?: scope:([a-zA-Z0-9_-]+))? · [^\]]+; full content available via readPastedText\(pasteId=(\d+)\)\]/g;
3470
+ function countTextLines(text) {
3471
+ if (text.length === 0) return 0;
3472
+ let lines = 1;
3473
+ for (let i = 0; i < text.length; i += 1) {
3474
+ if (text.charCodeAt(i) === 10) lines += 1;
3475
+ }
3476
+ return lines;
3477
+ }
3478
+ function shouldCollapsePaste(text, threshold = {}) {
3479
+ const minLines = threshold.minLines ?? COLLAPSE_PASTE_MIN_LINES;
3480
+ const minChars = threshold.minChars ?? COLLAPSE_PASTE_MIN_CHARS;
3481
+ if (text.length === 0) return false;
3482
+ if (text.length >= minChars) return true;
3483
+ return countTextLines(text) >= minLines;
3484
+ }
3485
+ function formatPasteByteSize(bytes) {
3486
+ if (!Number.isFinite(bytes) || bytes < 0) return "0 B";
3487
+ if (bytes < 1024) return `${Math.round(bytes)} B`;
3488
+ if (bytes < 1024 * 1024) {
3489
+ const kb = bytes / 1024;
3490
+ return `${kb >= 10 ? kb.toFixed(0) : kb.toFixed(1)} KB`;
3491
+ }
3492
+ const mb = bytes / (1024 * 1024);
3493
+ return `${mb >= 10 ? mb.toFixed(0) : mb.toFixed(1)} MB`;
3494
+ }
3495
+ function estimatePasteBytes(text) {
3496
+ let bytes = 0;
3497
+ for (let i = 0; i < text.length; i += 1) {
3498
+ const code = text.charCodeAt(i);
3499
+ if (code <= 127) bytes += 1;
3500
+ else if (code <= 2047) bytes += 2;
3501
+ else if (code >= 55296 && code <= 56319) {
3502
+ bytes += 4;
3503
+ i += 1;
3504
+ } else bytes += 3;
3505
+ }
3506
+ return bytes;
3507
+ }
3508
+ function formatCollapsedPastePlaceholder(id, text) {
3509
+ const lines = countTextLines(text);
3510
+ return `[paste #${id} \xB7 ${lines} lines]`;
3511
+ }
3512
+ function generatePasteScope() {
3513
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
3514
+ return crypto.randomUUID().slice(0, 8);
3515
+ }
3516
+ return Math.random().toString(36).slice(2, 10);
3517
+ }
3518
+ function formatCollapsedPasteModelReference(id, text, scope) {
3519
+ const lines = countTextLines(text);
3520
+ const size = formatPasteByteSize(estimatePasteBytes(text));
3521
+ const scopeAttr = scope ? ` scope:${scope}` : "";
3522
+ return `[paste #${id}${scopeAttr} \xB7 ${lines} lines \xB7 ${size}; full content available via readPastedText(pasteId=${id})]`;
3523
+ }
3524
+ function createCollapsedPasteStore(scope) {
3525
+ return { scope: scope ?? generatePasteScope(), nextId: 1, items: /* @__PURE__ */ new Map() };
3526
+ }
3527
+ function allocateCollapsedPaste(store, text) {
3528
+ const id = store.nextId;
3529
+ store.nextId += 1;
3530
+ store.items.set(id, text);
3531
+ return { id, placeholder: formatCollapsedPastePlaceholder(id, text) };
3532
+ }
3533
+ function releaseCollapsedPaste(store, id) {
3534
+ store.items.delete(id);
3535
+ }
3536
+ function clearCollapsedPasteStore(store) {
3537
+ store.items.clear();
3538
+ store.nextId = 1;
3539
+ store.scope = generatePasteScope();
3540
+ }
3541
+ function expandCollapsedPastes(buffer, store) {
3542
+ COLLAPSED_PASTE_MODEL_REFERENCE_RE.lastIndex = 0;
3543
+ const expandedReferences = buffer.replace(
3544
+ COLLAPSED_PASTE_MODEL_REFERENCE_RE,
3545
+ (match, _displayIdRaw, scopeRaw, idRaw) => {
3546
+ if (scopeRaw && scopeRaw === store.scope) {
3547
+ const full = store.items.get(Number(idRaw));
3548
+ return full === void 0 ? match : full;
3549
+ }
3550
+ return match;
3551
+ }
3552
+ );
3553
+ if (store.items.size === 0) return expandedReferences;
3554
+ COLLAPSED_PASTE_PLACEHOLDER_RE.lastIndex = 0;
3555
+ return expandedReferences.replace(COLLAPSED_PASTE_PLACEHOLDER_RE, (match, idRaw) => {
3556
+ const id = Number(idRaw);
3557
+ const full = store.items.get(id);
3558
+ return full === void 0 ? match : full;
3559
+ });
3560
+ }
3561
+ function replaceCollapsedPastesWithReferences(buffer, store) {
3562
+ if (store.items.size === 0) return buffer;
3563
+ COLLAPSED_PASTE_PLACEHOLDER_RE.lastIndex = 0;
3564
+ return buffer.replace(COLLAPSED_PASTE_PLACEHOLDER_RE, (match, idRaw) => {
3565
+ const id = Number(idRaw);
3566
+ const full = store.items.get(id);
3567
+ return full === void 0 ? match : formatCollapsedPasteModelReference(id, full, store.scope);
3568
+ });
3569
+ }
3570
+ function releaseCollapsedPasteReferences(buffer, store) {
3571
+ const ids = /* @__PURE__ */ new Set();
3572
+ COLLAPSED_PASTE_MODEL_REFERENCE_RE.lastIndex = 0;
3573
+ let modelMatch;
3574
+ while ((modelMatch = COLLAPSED_PASTE_MODEL_REFERENCE_RE.exec(buffer)) !== null) {
3575
+ const id = Number(modelMatch[3]);
3576
+ const scope = modelMatch[2];
3577
+ if (scope && scope === store.scope) {
3578
+ ids.add(id);
3579
+ }
3580
+ }
3581
+ COLLAPSED_PASTE_PLACEHOLDER_RE.lastIndex = 0;
3582
+ let placeholderMatch;
3583
+ while ((placeholderMatch = COLLAPSED_PASTE_PLACEHOLDER_RE.exec(buffer)) !== null) {
3584
+ ids.add(Number(placeholderMatch[1]));
3585
+ }
3586
+ for (const id of ids) releaseCollapsedPaste(store, id);
3587
+ }
3588
+ function expandRangeToCollapsedPasteChips(buffer, start, end) {
3589
+ let s = Math.max(0, Math.min(start, end));
3590
+ let e = Math.max(s, Math.max(start, end));
3591
+ if (s === e) return { start: s, end: e };
3592
+ COLLAPSED_PASTE_PLACEHOLDER_RE.lastIndex = 0;
3593
+ let match;
3594
+ while ((match = COLLAPSED_PASTE_PLACEHOLDER_RE.exec(buffer)) !== null) {
3595
+ const chipStart = match.index;
3596
+ const chipEnd = chipStart + match[0].length;
3597
+ if (chipStart < e && chipEnd > s) {
3598
+ if (chipStart < s) s = chipStart;
3599
+ if (chipEnd > e) e = chipEnd;
3600
+ }
3601
+ }
3602
+ return { start: s, end: e };
3603
+ }
3604
+ function findCollapsedPasteSpanAt(buffer, pos, opts = {}) {
3605
+ COLLAPSED_PASTE_PLACEHOLDER_RE.lastIndex = 0;
3606
+ let match;
3607
+ while ((match = COLLAPSED_PASTE_PLACEHOLDER_RE.exec(buffer)) !== null) {
3608
+ const start = match.index;
3609
+ const end = start + match[0].length;
3610
+ const inside = pos > start && pos < end;
3611
+ const atEnd = opts.preferLeft && pos === end;
3612
+ const atStart = !opts.preferLeft && pos === start;
3613
+ if (inside || atEnd || atStart) {
3614
+ return { id: Number(match[1]), start, end };
3615
+ }
3616
+ }
3617
+ return null;
3618
+ }
3619
+
2838
3620
  // packages/cli/client/agentRun.ts
2839
3621
  import { ulid } from "ulid";
2840
3622
  async function loadRunLocalAgentTurn() {
2841
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-UQBMQI2M.js");
3623
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-QDJCBXM2.js");
2842
3624
  return runLocalAgentTurn;
2843
3625
  }
2844
3626
  async function resolveCurrentMachineId(options) {
@@ -2851,6 +3633,12 @@ function resolveRequestedRuntimeMode(options) {
2851
3633
  return envMode;
2852
3634
  return "auto";
2853
3635
  }
3636
+ function canResolveCollapsedPasteReference(store, content) {
3637
+ const expand = (text) => expandCollapsedPastes(text, store) !== text;
3638
+ if (typeof content === "string") return expand(content);
3639
+ if (!Array.isArray(content)) return false;
3640
+ return content.some((part) => part.type === "text" && expand(part.text));
3641
+ }
2854
3642
  function buildDefaultLocalRuntimeAdapter(options) {
2855
3643
  return createCliLocalRuntimeAdapter({
2856
3644
  env: options.env,
@@ -2858,7 +3646,8 @@ function buildDefaultLocalRuntimeAdapter(options) {
2858
3646
  cwd: options.localRuntimeCwd,
2859
3647
  output: options.output,
2860
3648
  ...options.confirmDestructiveAction ? { confirmDestructiveAction: options.confirmDestructiveAction } : {},
2861
- ...options.requestUserChoice ? { requestUserChoice: options.requestUserChoice } : {}
3649
+ ...options.requestUserChoice ? { requestUserChoice: options.requestUserChoice } : {},
3650
+ ...options.pastedTextStore?.items.size ? { pastedTextStore: options.pastedTextStore } : {}
2862
3651
  });
2863
3652
  }
2864
3653
  function resolveLocalRuntimeAdapter(options) {
@@ -3083,12 +3872,14 @@ async function runHttpAgentTurn(options, authToken) {
3083
3872
  (name) => name.trim()
3084
3873
  );
3085
3874
  const shouldStream = !options.noStream && !options.background;
3875
+ const expandedMessage = options.pastedTextStore?.items.size ? expandCollapsedPastes(options.message, options.pastedTextStore) : options.message;
3876
+ const serverContextBlockScopes = options.contextBlockScopes && options.contextBlockScopes.length > 0 ? options.contextBlockScopes : options.extraContextBlocks && options.extraContextBlocks.length > 0 ? options.extraContextBlocks.map((block) => ({
3877
+ content: block,
3878
+ cacheScope: "turn"
3879
+ })) : void 0;
3086
3880
  const buildRequestBody = (stream) => JSON.stringify({
3087
3881
  agentKey: options.agentKey,
3088
- userInput: buildUserInputContent(
3089
- options.extraContextBlocks?.length ? [...options.extraContextBlocks, "", options.message].join("\n") : options.message,
3090
- options.imageUrls
3091
- ),
3882
+ userInput: buildUserInputContent(expandedMessage, options.imageUrls),
3092
3883
  runtimeContext: {
3093
3884
  surface: "cli",
3094
3885
  host: "terminal",
@@ -3108,6 +3899,7 @@ async function runHttpAgentTurn(options, authToken) {
3108
3899
  ...options.background ? { background: true } : {},
3109
3900
  ...typeof options.timeoutMs === "number" ? { timeoutMs: options.timeoutMs } : {},
3110
3901
  ...options.modelOverride ? { runtimeOptions: { quickChatModelOverride: options.modelOverride } } : {},
3902
+ ...serverContextBlockScopes ? { contextBlockScopes: serverContextBlockScopes } : {},
3111
3903
  stream
3112
3904
  });
3113
3905
  const postAgentRun = (stream) => fetchImpl(`${options.serverUrl}/api/agent/run`, {
@@ -3265,7 +4057,7 @@ async function runLocalAgentTurnForCli(options, settings) {
3265
4057
  } : void 0;
3266
4058
  const currentDialogId = options.continueDialogId ?? ulid();
3267
4059
  const runChildTurn = async (input) => {
3268
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-UQBMQI2M.js");
4060
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-QDJCBXM2.js");
3269
4061
  return runLocalAgentTurn(input);
3270
4062
  };
3271
4063
  const createFreshChildBaseAdapter = () => {
@@ -3313,6 +4105,7 @@ async function runLocalAgentTurnForCli(options, settings) {
3313
4105
  spaceId: options.spaceId,
3314
4106
  runtimeContext
3315
4107
  });
4108
+ const expandedMessage = options.pastedTextStore?.items.size ? expandCollapsedPastes(options.message, options.pastedTextStore) : options.message;
3316
4109
  const workingLabel = `${options.agentName} -> working locally`;
3317
4110
  const turnOutput = createCliTurnOutput({
3318
4111
  options,
@@ -3325,6 +4118,19 @@ async function runLocalAgentTurnForCli(options, settings) {
3325
4118
  adapter,
3326
4119
  agentRef: options.agentKey,
3327
4120
  input: buildUserInputContent(options.message, options.imageUrls),
4121
+ ...expandedMessage !== options.message ? {
4122
+ persistedInput: buildUserInputContent(
4123
+ expandedMessage,
4124
+ options.imageUrls
4125
+ ),
4126
+ persistedInputReference: buildUserInputContent(
4127
+ options.message,
4128
+ options.imageUrls
4129
+ )
4130
+ } : {},
4131
+ ...options.pastedTextStore ? {
4132
+ contextReferenceResolver: (reference) => canResolveCollapsedPasteReference(options.pastedTextStore, reference)
4133
+ } : {},
3328
4134
  continueDialogId: currentDialogId,
3329
4135
  spaceId: options.spaceId,
3330
4136
  category: options.category,
@@ -3333,8 +4139,7 @@ async function runLocalAgentTurnForCli(options, settings) {
3333
4139
  background: options.background,
3334
4140
  noStream: options.noStream,
3335
4141
  ...runtimeContext ? { runtimeContext } : {},
3336
- ...options.extraContextBlocks?.length ? { contextBlocks: options.extraContextBlocks } : {},
3337
- ...options.contextBlockScopes?.length ? { contextBlockScopes: options.contextBlockScopes } : {},
4142
+ ...options.contextBlockScopes?.length ? { contextBlockScopes: options.contextBlockScopes } : options.extraContextBlocks?.length ? { contextBlocks: options.extraContextBlocks } : {},
3338
4143
  ...typeof options.timeoutMs === "number" ? { timeoutMs: options.timeoutMs } : {},
3339
4144
  ...options.actionGateHandler ? { onActionGate: options.actionGateHandler } : {},
3340
4145
  onLoopEvent: (event) => {
@@ -3370,10 +4175,12 @@ async function runLocalAgentTurnForCli(options, settings) {
3370
4175
  turnOutput.spinner.stop();
3371
4176
  const savedDialogId = error?.dialogId;
3372
4177
  if (error?.code === LOCAL_TURN_ABORTED_CODE || options.abortSignal?.aborted) {
4178
+ const pendingToolName = error?.pendingToolName;
3373
4179
  return {
3374
4180
  exitCode: 0,
3375
4181
  streamInterrupted: true,
3376
- ...savedDialogId ? { dialogId: savedDialogId } : {}
4182
+ ...savedDialogId ? { dialogId: savedDialogId } : {},
4183
+ ...pendingToolName ? { pendingToolName } : {}
3377
4184
  };
3378
4185
  }
3379
4186
  if (settings.reportFailure) {
@@ -3406,7 +4213,8 @@ async function runAgentTurn(options) {
3406
4213
  exitCode: localResult.exitCode,
3407
4214
  ...localResult.dialogId ? { dialogId: localResult.dialogId } : {},
3408
4215
  ...localResult.turnTokens ? { turnTokens: localResult.turnTokens } : {},
3409
- ...localResult.streamInterrupted ? { streamInterrupted: localResult.streamInterrupted } : {}
4216
+ ...localResult.streamInterrupted ? { streamInterrupted: localResult.streamInterrupted } : {},
4217
+ ...localResult.pendingToolName ? { pendingToolName: localResult.pendingToolName } : {}
3410
4218
  };
3411
4219
  }
3412
4220
  if (isMissingLocalAgentConfigError(localResult.localError, options.agentKey)) {
@@ -3460,196 +4268,6 @@ async function runAgentTurn(options) {
3460
4268
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
3461
4269
  import { join as join2 } from "node:path";
3462
4270
 
3463
- // packages/agent-runtime/quickChatIntentCore.ts
3464
- var INTENT_MODEL = "deepseek-v4-flash";
3465
- var INTENT_PROVIDER = "deepseek";
3466
- var QUICK_CHAT_INTENT_TIMEOUT_MS = 4e3;
3467
- var SHORT_GREETING_MAX_LENGTH = 20;
3468
- var SHORT_GREETING_PATTERN = /^(?:hi|hello|hey|hiya|yo|sup|howdy|嗨|哈喽|哈囉|你好|您好|在吗|在嘛|喂|早上好|中午好|下午好|晚上好|拜拜|再见|谢谢|thanks|thx|ok|好的|收到|了解)[!.。,、~~]?$/iu;
3469
- function isShortGreeting(text) {
3470
- const trimmed = text.trim();
3471
- if (!trimmed) return false;
3472
- if (trimmed.length > SHORT_GREETING_MAX_LENGTH) return false;
3473
- return SHORT_GREETING_PATTERN.test(trimmed);
3474
- }
3475
- var COMPLEXITY_SIMPLE_MAX_LENGTH = 80;
3476
- var COMPLEXITY_MEDIUM_MAX_LENGTH = 500;
3477
- var COMPLEXITY_KEYWORDS = /为什么|如何|分析|对比|比较|设计|架构|实现|原理|推导|评价|区别|关系|影响|优化|重构/;
3478
- var COMPLEXITY_CODE_BLOCK = /```[\s\S]*```/;
3479
- function estimateComplexity(text) {
3480
- const trimmed = text.trim();
3481
- const len = trimmed.length;
3482
- if (len > COMPLEXITY_MEDIUM_MAX_LENGTH) return "complex";
3483
- if (COMPLEXITY_CODE_BLOCK.test(trimmed)) return "complex";
3484
- if (len > COMPLEXITY_SIMPLE_MAX_LENGTH) return "medium";
3485
- if (COMPLEXITY_KEYWORDS.test(trimmed)) return "medium";
3486
- return "simple";
3487
- }
3488
- var TIER_DESCRIPTIONS = {
3489
- flash: "\u5FEB\u901F\u7B80\u5355\uFF1A\u95EE\u5019\u3001\u95F2\u804A\u3001\u5FEB\u901F\u95EE\u7B54\u3001\u7FFB\u8BD1\u3001\u77ED\u6587",
3490
- balanced: "\u5E73\u8861\u63A8\u7406\uFF1A\u5206\u6790\u3001\u4E2D\u7B49\u957F\u5EA6\u5199\u4F5C\u3001\u4EE3\u7801\u3001\u63A8\u7406",
3491
- quality: "\u9AD8\u8D28\u91CF\u6DF1\u5EA6\uFF1A\u590D\u6742\u63A8\u7406\u3001\u957F\u6587\u3001\u67B6\u6784\u8BBE\u8BA1\u3001\u6DF1\u5EA6\u5206\u6790"
3492
- };
3493
- function buildQuickChatIntentSystemPrompt(tierAgents) {
3494
- const agentList = tierAgents.map((t2) => ` - "${t2.agentKey}"\uFF1A${t2.description}`).join("\n");
3495
- return `\u4F60\u662F\u4E00\u4E2A\u610F\u56FE\u8DEF\u7531\u5668\u3002\u6839\u636E\u7528\u6237\u6D88\u606F\uFF0C\u5224\u65AD\u5E94\u8BE5\u4EA4\u7ED9\u54EA\u4E2A agent \u5904\u7406\u3002
3496
-
3497
- \u53EF\u9009 agent \u5217\u8868\uFF08agentKey \u4E0E\u63CF\u8FF0\uFF09\uFF1A
3498
- ${agentList}
3499
-
3500
- \u5224\u65AD\u539F\u5219\uFF08\u9ED8\u8BA4\u504F\u5411\u901A\u7528\u6863\u4F4D\uFF1B\u4E13\u804C agent \u5728\u660E\u786E\u5339\u914D\u65F6\u4F7F\u7528\uFF1B**\u7F16\u7801/\u672C\u5730\u4ED3\u5E93\u4EFB\u52A1\u8D70\u901A\u7528\u6863 + needsWorkspace=true**\uFF09\uFF1A
3501
- - \u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0C**\u9664\u975E\u7528\u6237\u660E\u786E\u8868\u8FBE\u8981\u5EFA\u5E94\u7528/\u5EFA Agent/\u63D0\u4EA4\u53CD\u9988/\u591A Agent \u7F16\u6392**\uFF0C\u5426\u5219\u9009\u901A\u7528\u6863\u4F4D\uFF08flash/balanced/quality\uFF09\uFF1A
3502
- - \u7B80\u5355\u95EE\u5019\u3001\u95F2\u804A\u3001\u5FEB\u901F\u95EE\u7B54\u3001\u7FFB\u8BD1\u3001\u77ED\u6587 \u2192 \u9009 flash \u6863
3503
- - \u9700\u8981\u63A8\u7406\u3001\u5206\u6790\u3001\u4E2D\u7B49\u957F\u5EA6\u5199\u4F5C\u3001\u666E\u901A\u4EE3\u7801\u89E3\u91CA/\u67B6\u6784\u95EE\u7B54 \u2192 \u9009 balanced \u6863
3504
- - \u590D\u6742\u63A8\u7406\u3001\u957F\u6587\u3001\u67B6\u6784\u8BBE\u8BA1\u3001\u6DF1\u5EA6\u5206\u6790 \u2192 \u9009 quality \u6863
3505
- - **\u660E\u786E\u7F16\u7801\u4EFB\u52A1\uFF08\u5B9E\u73B0\u529F\u80FD\u3001\u4FEE bug\u3001refactor\u3001\u5199/\u8865\u6D4B\u8BD5\u3001\u8DD1 build/tests/ci\uFF09\u6216\u67E5\u770B\u672C\u673A\u4ED3\u5E93/\u4EE3\u7801\u72B6\u6001\uFF08git/\u5206\u652F/commit/\u672C\u5730\u4E0E\u8FDC\u7A0B\u5DEE\u8DDD/\u672A\u63D0\u4EA4\u6539\u52A8\u7B49\uFF09** \u2192 \u9009 balanced \u6216 quality \u6863\uFF08\u6309\u590D\u6742\u5EA6\uFF1B**\u4E0D\u8981\u9009 flash**\uFF09\uFF0C\u4E14 needsWorkspace=true
3506
- - \u4E13\u804C agent \u8DEF\u7531\u89C4\u5219\uFF08\u6709\u660E\u786E\u5339\u914D\u65F6\u4F7F\u7528\uFF09\uFF1A
3507
- - \u8981\u63D0\u4EA4/\u8BB0\u5F55 bug\u3001\u4F53\u9A8C\u95EE\u9898\u3001\u6570\u636E\u5F02\u5E38\u3001\u4EA7\u54C1\u5EFA\u8BAE\uFF0C\u6216\u53E3\u8BED\u5982\u300C\u60F3\u53CD\u9988\u4E00\u4E9B\u95EE\u9898\u300D\u300C\u53CD\u9988\u4E00\u4E0B\u300D\u2192 \u9009\u610F\u89C1\u53CD\u9988\u4E13\u804C agent
3508
- - \u8981\u65B0\u5EFA\u6216\u5B9A\u5236 AI/Agent/\u667A\u80FD\u4F53\u52A9\u624B\uFF08\u542B\u914D\u7F6E\u5DE5\u5177\u3001\u77E5\u8BC6\u3001\u786E\u8BA4\u521B\u5EFA\uFF09\u2192 \u9009\u521B\u5EFA Agent \u4E13\u804C agent
3509
- - \u8981\u505A/\u6539/\u53D1\u5E03\u7F51\u7AD9\u3001\u7F51\u9875\u3001\u5C0F\u5E94\u7528\u3001\u9884\u7EA6\u9875\u3001\u535A\u5BA2\u3001\u770B\u677F \u2192 \u9009\u5E94\u7528\u6784\u5EFA\u4E13\u804C agent
3510
- - \u8981\u6D3E\u591A\u4E2A agent\u3001\u591A agent \u5E76\u884C\u3001\u62C6\u6210\u4EFB\u52A1\u540E\u53F0\u6267\u884C\u3001\u591A\u4E2A agent review\u3001\u8BA9\u4E0D\u540C agent \u8BA8\u8BBA/\u4F1A\u5546 \u2192 \u9009\u591A Agent \u7F16\u6392\u4E13\u804C agent\uFF08\u663E\u5F0F multi-agent \u4F18\u5148\uFF09
3511
- - **\u62FF\u4E0D\u51C6\u65F6**\uFF1A\u7EAF\u95F2\u804A\u9009 flash\uFF1B**\u82E5\u6CBE\u8FB9\u672C\u5730\u4ED3\u5E93/\u5F53\u524D\u4EE3\u7801\u72B6\u6001\uFF0C\u9009 balanced/quality + needsWorkspace=true**\u3002
3512
-
3513
- \u540C\u65F6\u5224\u65AD\u672C\u8F6E\u662F\u5426\u9700\u8981\u6CE8\u5165\u300C\u5DE5\u4F5C\u533A\u53EA\u8BFB\u5DE5\u5177\u300D\uFF08listFiles/globFiles/searchFiles/readFile/execShell \u7B49\uFF09\uFF1A
3514
- - needsWorkspace=true \u7684\u573A\u666F\uFF1A\u7528\u6237\u8981\u8BFB/\u6539/\u5206\u6790\u6587\u4EF6\u6216\u4EE3\u7801\u3001\u63D0\u5230\u4E86\u6587\u4EF6\u8DEF\u5F84/\u6269\u5C55\u540D\uFF08.md/.csv/.ts \u7B49\uFF09\u3001\u63D0\u5230\u5DE5\u4F5C\u533A/\u4EE3\u7801\u5E93/\u4ED3\u5E93/\u76EE\u5F55/git/\u5206\u652F\u3001\u8981\u770B\u5F53\u524D\u4EE3\u7801\u6216\u4ED3\u5E93\u72B6\u6001\u3001\u672C\u5730\u641C\u7D22/\u67E5\u770B\u4EE3\u7801\u3002
3515
- - needsWorkspace=false \u7684\u573A\u666F\uFF1A\u901A\u7528\u77E5\u8BC6\u95EE\u7B54\uFF08\u5982\u300C\u5E7F\u4E1C\u7ECF\u6D4E\u6570\u636E\u300D\u300C\u5199\u4E00\u9996\u8BD7\u300D\uFF09\u3001\u7EAF\u95F2\u804A\u95EE\u5019\u3001\u7FFB\u8BD1\u3001\u4E0D\u6D89\u53CA\u672C\u5730\u6587\u4EF6/\u4ED3\u5E93\u3002
3516
- - \u6F0F\u5224\uFF08\u7528\u6237\u8981\u6587\u4EF6\u800C\u6CA1\u5E26\u5DE5\u5177\uFF09\u6BD4\u8BEF\u5224\uFF08\u767D\u641C\u51E0\u8F6E\uFF09\u4EE3\u4EF7\u66F4\u9AD8\uFF0C\u5B81\u53EF\u504F\u5BBD\u5224 true\u3002
3517
-
3518
- \u5728\u7ED9\u51FA agentKey \u4E4B\u524D\uFF0C\u5148\u5728\u5FC3\u91CC\u533A\u5206\u5019\u9009\u6863\u4F4D\u7684\u8FB9\u754C\u518D\u7ED9\u7F6E\u4FE1\u5EA6\uFF1Abalanced \u4E0E quality \u7684\u8FB9\u754C\u5728\u4E8E\u590D\u6742\u5EA6/\u7BC7\u5E45/\u662F\u5426\u9700\u8981\u6DF1\u5EA6\u5206\u6790\uFF0C\u62FF\u4E0D\u51C6\u5C31\u7ED9\u4F4E confidence\u3002
3519
-
3520
- \u540C\u65F6\u5224\u65AD\u672C\u8F6E\u6D88\u606F\u662F\u5426\u9700\u8981\u6302\u8F7D\u5BF9\u8C61\u64CD\u4F5C\u6280\u80FD\uFF08skills \u6570\u7EC4\uFF0C\u672A\u547D\u4E2D\u7ED9 []\uFF09\uFF1A
3521
- - \u7528\u6237\u8981\u65B0\u5EFA/\u6574\u7406/\u5F55\u5165/\u6279\u91CF\u5904\u7406\u8868\u683C\u6570\u636E\uFF08\u5EFA\u8868\u3001\u52A0\u884C\u3001\u6539\u5217\u3001\u6309\u6761\u4EF6\u6574\u7406\u6570\u636E\uFF09\u2192 skills \u542B "table"
3522
- - \u7528\u6237\u8981\u5199/\u6DA6\u8272/\u6539\u5199/\u7EED\u5199/\u6392\u7248\u4E00\u7BC7\u6587\u6863\u6216\u6587\u7AE0 \u2192 skills \u542B "doc"
3523
- - \u7528\u6237\u8981\u5199/\u6539/\u5B9E\u73B0/\u4FEE bug/refactor/\u8865\u6D4B\u8BD5/\u5BA1\u67E5\u5E76\u4FEE\u6539\u4EE3\u7801 \u2192 skills \u542B "code"\uFF08\u4EC5\u95EE\u901A\u7528\u77E5\u8BC6\u3001\u7EAF\u95F2\u804A\u3001\u53EA\u67E5\u770B git/\u4ED3\u5E93\u72B6\u6001\u800C\u4E0D\u4FEE\u6539\u4EE3\u7801\u65F6\u4E0D\u6302 "code"\uFF09
3524
- - \u666E\u901A\u95EE\u7B54/\u7EAF\u95F2\u804A/\u5EFA\u5E94\u7528 \u2192 skills \u4E3A []
3525
-
3526
- \u53EA\u8F93\u51FA JSON\uFF0C\u4E0D\u8981\u8F93\u51FA\u5176\u4ED6\u5185\u5BB9\uFF1A
3527
- {"confidence": <0\u52301\u4E4B\u95F4\u7684\u5C0F\u6570\uFF0C\u8868\u793A\u4F60\u5BF9\u8FD9\u4E2A\u5206\u7C7B\u5224\u65AD\u7684\u628A\u63E1\u7A0B\u5EA6>, "agentKey": "<\u4ECE\u5217\u8868\u4E2D\u9009\u62E9\u7684 agentKey>", "needsWorkspace": <true \u6216 false>, "skills": <\u5B57\u7B26\u4E32\u6570\u7EC4\uFF0C\u5143\u7D20\u53EA\u80FD\u662F "table" | "doc" | "code"\uFF0C\u672A\u547D\u4E2D\u7ED9 []>}`;
3528
- }
3529
- function parseQuickChatIntentResult(content, tierAgents) {
3530
- try {
3531
- const parsed = JSON.parse(content.trim());
3532
- if (typeof parsed !== "object" || parsed === null || !("agentKey" in parsed)) return null;
3533
- const key = parsed.agentKey;
3534
- if (typeof key !== "string") return null;
3535
- if (!tierAgents.some((t2) => t2.agentKey === key)) return null;
3536
- const rawNeedsWorkspace = parsed.needsWorkspace;
3537
- const needsWorkspace = rawNeedsWorkspace === true;
3538
- const rawConfidence = parsed.confidence;
3539
- const confidence = typeof rawConfidence === "number" && Number.isFinite(rawConfidence) && rawConfidence >= 0 && rawConfidence <= 1 ? rawConfidence : void 0;
3540
- const rawSkills = parsed.skills;
3541
- let skills;
3542
- if (Array.isArray(rawSkills)) {
3543
- const filtered = [...new Set(rawSkills)].filter(
3544
- (s) => s === "table" || s === "doc" || s === "code"
3545
- );
3546
- if (filtered.length > 0) skills = filtered;
3547
- }
3548
- return { agentKey: key, needsWorkspace, confidence, skills };
3549
- } catch {
3550
- return null;
3551
- }
3552
- }
3553
-
3554
- // packages/cli/client/autoModelRouter.ts
3555
- var CLI_AUTO_TIER_AGENT_KEYS = {
3556
- flash: PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY,
3557
- balanced: PUBLIC_DEEPSEEK_V4_PRO_AGENT_KEY,
3558
- quality: PUBLIC_GLM_52_AGENT_KEY
3559
- };
3560
- var CLI_IMAGE_AGENT_KEY = PUBLIC_KIMI_K26_IMAGE_AGENT_KEY;
3561
- var CLI_AUTO_TIER_AGENT_KEY_TABLE = {
3562
- [CLI_AUTO_TIER_AGENT_KEYS.flash]: true,
3563
- [CLI_AUTO_TIER_AGENT_KEYS.balanced]: true,
3564
- [CLI_AUTO_TIER_AGENT_KEYS.quality]: true
3565
- };
3566
- var buildRouteOptions = () => ["flash", "balanced", "quality"].map((tier) => ({
3567
- tier,
3568
- agentKey: CLI_AUTO_TIER_AGENT_KEYS[tier],
3569
- description: TIER_DESCRIPTIONS[tier]
3570
- }));
3571
- var tierForAgentKey = (agentKey) => {
3572
- for (const tier of ["flash", "balanced", "quality"]) {
3573
- if (CLI_AUTO_TIER_AGENT_KEYS[tier] === agentKey) return tier;
3574
- }
3575
- return null;
3576
- };
3577
- function resolveCliAutoFallbackTier(text) {
3578
- switch (estimateComplexity(text)) {
3579
- case "complex":
3580
- return "quality";
3581
- case "medium":
3582
- return "balanced";
3583
- case "simple":
3584
- default:
3585
- return "flash";
3586
- }
3587
- }
3588
- async function classifyCliAutoRoute(text, options) {
3589
- const timeoutMs = options.timeoutMs ?? QUICK_CHAT_INTENT_TIMEOUT_MS;
3590
- const fallbackTier = resolveCliAutoFallbackTier(text);
3591
- const fallback = () => ({
3592
- agentKey: CLI_AUTO_TIER_AGENT_KEYS[fallbackTier],
3593
- tier: fallbackTier,
3594
- classified: false
3595
- });
3596
- if (!text.trim()) return fallback();
3597
- if (isShortGreeting(text)) {
3598
- return {
3599
- agentKey: CLI_AUTO_TIER_AGENT_KEYS.flash,
3600
- tier: "flash",
3601
- classified: true
3602
- };
3603
- }
3604
- if (!options.authToken) return fallback();
3605
- const fetchImpl = options.fetchImpl ?? globalThis.fetch;
3606
- const controller = new AbortController();
3607
- const timeoutHandle = setTimeout(() => controller.abort(), timeoutMs);
3608
- try {
3609
- const routeOptions = buildRouteOptions();
3610
- const messages = [
3611
- { role: "system", content: buildQuickChatIntentSystemPrompt(routeOptions) },
3612
- { role: "user", content: text }
3613
- ];
3614
- const { url, init } = buildPlatformChatCompletionRequest({
3615
- providerConfig: {
3616
- serverUrl: options.serverUrl,
3617
- authToken: options.authToken,
3618
- agentKey: CLI_AUTO_TIER_AGENT_KEYS.flash,
3619
- model: INTENT_MODEL,
3620
- provider: INTENT_PROVIDER,
3621
- endpoint: resolvePlatformChatCompletionsEndpoint(INTENT_PROVIDER) ?? "",
3622
- requestOptions: {}
3623
- },
3624
- messages,
3625
- stream: false
3626
- });
3627
- const response = await fetchImpl(url, {
3628
- ...init,
3629
- signal: controller.signal
3630
- });
3631
- if (!response.ok) return fallback();
3632
- const data = parsePlatformChatCompletionData(await response.text());
3633
- const content = data?.choices?.[0]?.message?.content;
3634
- if (typeof content !== "string" || !content.trim()) return fallback();
3635
- const parsed = parseQuickChatIntentResult(content, routeOptions);
3636
- if (!parsed) return fallback();
3637
- const tier = tierForAgentKey(parsed.agentKey) ?? fallbackTier;
3638
- return {
3639
- agentKey: parsed.agentKey,
3640
- tier,
3641
- classified: true,
3642
- confidence: parsed.confidence,
3643
- needsWorkspace: parsed.needsWorkspace,
3644
- skills: parsed.skills
3645
- };
3646
- } catch {
3647
- return fallback();
3648
- } finally {
3649
- clearTimeout(timeoutHandle);
3650
- }
3651
- }
3652
-
3653
4271
  // packages/cli/agentRunPrompts.ts
3654
4272
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
3655
4273
  import { dirname, extname, isAbsolute, join, relative as relativePath, resolve, sep } from "node:path";
@@ -3664,8 +4282,7 @@ function workflowRefToCandidatePath(cwd, ref) {
3664
4282
  return resolve(cwd, "docs", "workflows", `${fileName}.md`);
3665
4283
  }
3666
4284
  var SKILL_SEARCH_DIRS = [
3667
- ".agents/skills",
3668
- "docs/skills"
4285
+ ".agents/skills"
3669
4286
  ];
3670
4287
  function skillRefToCandidatePath(cwd, ref) {
3671
4288
  const normalized = ref.trim();
@@ -3676,15 +4293,10 @@ function skillRefToCandidatePath(cwd, ref) {
3676
4293
  }
3677
4294
  const fileName = normalized.replace(/[^a-zA-Z0-9一-鿿]+/g, "-").replace(/^-+|-+$/g, "");
3678
4295
  for (const dir of SKILL_SEARCH_DIRS) {
3679
- if (dir === "docs/skills") {
3680
- const flatPath = resolve(cwd, dir, `${fileName}.md`);
3681
- if (existsSync(flatPath)) return flatPath;
3682
- } else {
3683
- const skillMdPath = resolve(cwd, dir, fileName, "SKILL.md");
3684
- if (existsSync(skillMdPath)) return skillMdPath;
3685
- }
4296
+ const skillMdPath = resolve(cwd, dir, fileName, "SKILL.md");
4297
+ if (existsSync(skillMdPath)) return skillMdPath;
3686
4298
  }
3687
- return resolve(cwd, "docs", "skills", `${fileName}.md`);
4299
+ return resolve(cwd, ".agents", "skills", fileName, "SKILL.md");
3688
4300
  }
3689
4301
  async function resolveWorkflowReference(ref, cwd = process.cwd()) {
3690
4302
  const path = workflowRefToCandidatePath(cwd, ref);
@@ -3993,16 +4605,16 @@ var buildCjkTokens = (text) => {
3993
4605
  }
3994
4606
  return tokens;
3995
4607
  };
3996
- var tokenize = (text) => {
4608
+ var tokenize2 = (text) => {
3997
4609
  const normalized = text.toLowerCase();
3998
4610
  const wordTokens = normalized.split(/[\s,.;:!?()[\]{}"'`,。!?:;、]+/).map((token) => token.trim()).filter((token) => token.length >= 2);
3999
4611
  return [...wordTokens, ...buildCjkTokens(normalized)];
4000
4612
  };
4001
4613
  var keywordScore = (query, item) => {
4002
- const queryTokens = new Set(tokenize(query));
4614
+ const queryTokens = new Set(tokenize2(query));
4003
4615
  if (queryTokens.size === 0) return 0;
4004
4616
  const haystack = /* @__PURE__ */ new Set([
4005
- ...tokenize(item.content),
4617
+ ...tokenize2(item.content),
4006
4618
  ...(item.tags ?? []).map((tag) => tag.toLowerCase()),
4007
4619
  item.patternKey?.toLowerCase() ?? ""
4008
4620
  ]);
@@ -4616,8 +5228,7 @@ ${mdContent}`);
4616
5228
  traceTools: parsed.traceTools,
4617
5229
  ...parsed.eventsMode ? { eventsMode: parsed.eventsMode } : {},
4618
5230
  ...parsed.taskEvidence ? { taskEvidence: parsed.taskEvidence } : {},
4619
- ...extraContextBlocks.length > 0 ? { extraContextBlocks } : {},
4620
- ...contextBlockScopes.length > 0 ? { contextBlockScopes } : {}
5231
+ ...contextBlockScopes.length > 0 ? { contextBlockScopes } : extraContextBlocks.length > 0 ? { extraContextBlocks } : {}
4621
5232
  });
4622
5233
  let result = await raceWithWatchdog(
4623
5234
  runner({
@@ -4748,10 +5359,28 @@ function isBalanceExhaustedError(error) {
4748
5359
  }
4749
5360
 
4750
5361
  export {
5362
+ CLI_AUTO_TIER_AGENT_KEYS,
5363
+ CLI_IMAGE_AGENT_KEY,
5364
+ CLI_AUTO_TIER_AGENT_KEY_TABLE,
5365
+ resolveCliAutoFallbackTier,
5366
+ classifyCliAutoRoute,
5367
+ resolveAgentContextWindow,
4751
5368
  formatTokenCount,
4752
5369
  renderTokenStatus,
4753
5370
  resolveCliColorEnabled,
4754
5371
  dimCliText,
5372
+ ANSI_ESCAPE_REGEX,
5373
+ stripAnsi,
5374
+ applyTerminalOutputToText,
5375
+ displayWidth,
5376
+ visibleWidth,
5377
+ truncateAnsi,
5378
+ fitAnsiLine,
5379
+ countPhysicalLines,
5380
+ takeDisplayWidth,
5381
+ padOrTruncateToWidth,
5382
+ wrapTranscriptLine,
5383
+ wrapTextToLines,
4755
5384
  THEME_PALETTES,
4756
5385
  getActiveThemeName,
4757
5386
  setActiveThemeName,
@@ -4760,22 +5389,24 @@ export {
4760
5389
  getActiveDensity,
4761
5390
  setActiveDensity,
4762
5391
  resolveTuiBrightness,
5392
+ setActiveTerminalBaseHex,
4763
5393
  surfaceBackgroundSequence,
4764
5394
  themeColorSequence,
4765
5395
  themeText,
4766
- highlightMarkdown,
4767
5396
  formatAssistantDisplay,
4768
5397
  normalizeThinkingDisplayMode,
4769
- parseCliLocale,
4770
- getCliLocale,
4771
- setCliLocale,
4772
- initCliLocale,
4773
- t,
4774
5398
  normalizeToolDisplayMode,
5399
+ COLLAPSED_PASTE_PLACEHOLDER_RE,
5400
+ shouldCollapsePaste,
5401
+ createCollapsedPasteStore,
5402
+ allocateCollapsedPaste,
5403
+ releaseCollapsedPaste,
5404
+ clearCollapsedPasteStore,
5405
+ replaceCollapsedPastesWithReferences,
5406
+ releaseCollapsedPasteReferences,
5407
+ expandRangeToCollapsedPasteChips,
5408
+ findCollapsedPasteSpanAt,
4775
5409
  runAgentTurn,
4776
- CLI_IMAGE_AGENT_KEY,
4777
- CLI_AUTO_TIER_AGENT_KEY_TABLE,
4778
- classifyCliAutoRoute,
4779
5410
  resolveWorkflowReference,
4780
5411
  resolveSkillReference,
4781
5412
  buildSkillContextBlocks,