nolo-cli 0.19.0 → 0.24.0-alpha.14
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.
- package/README.md +9 -18
- package/{_executeModel-X5PCIZN6.js → _executeModel-ZPNYAEFW.js} +46 -44
- package/{action-LT7BRFLK.js → action-5MNAXR5B.js} +7 -6
- package/{addContentAction-PL3KKBDH.js → addContentAction-UNSYTVTB.js} +5 -5
- package/{addDialogAgentAction-FCMSKYAF.js → addDialogAgentAction-LJGNP2AO.js} +5 -5
- package/{agentDeleteCommand-2BZDQV36.js → agentDeleteCommand-5ZV4433K.js} +27 -26
- package/{agentEmailCommands-2QJDGRMB.js → agentEmailCommands-Z7KOYDVQ.js} +57 -55
- package/{agentListCommands-6VEPTKBI.js → agentListCommands-UQUXJYUN.js} +30 -26
- package/{agentMachineCommands-NVVHNWYI.js → agentMachineCommands-53O6P6L5.js} +25 -24
- package/{agentRecordCommands-4GGRDMD4.js → agentRecordCommands-ZRYNBSSS.js} +52 -50
- package/{agentRunCommand-XOLQNKBZ.js → agentRunCommand-B73MKVOG.js} +55 -54
- package/{agentRunControl-Y5AFH5PQ.js → agentRunControl-SNUKXN6J.js} +6 -2
- package/{agentRuntimeLocal-7WYWCGL4.js → agentRuntimeLocal-GVNERRKQ.js} +21 -18
- package/{agentSlice-EAXPGEYV.js → agentSlice-OJBHIL34.js} +5 -5
- package/{appDeleteCommands-77KR2RJ4.js → appDeleteCommands-23Z3Z6KE.js} +23 -22
- package/{appDeployCommands-K7CAHGBI.js → appDeployCommands-3MFAR4Z7.js} +23 -22
- package/{appDeployStatusCommands-4OEKLTBT.js → appDeployStatusCommands-JHU6GSN4.js} +23 -22
- package/{appGetCommands-VM2WDLAZ.js → appGetCommands-24J55H2Y.js} +23 -22
- package/{appListCommands-GX6BBA6U.js → appListCommands-HE5KP3PH.js} +23 -22
- package/{authCommand-DY6UUL6O.js → authCommand-KGRK6MNU.js} +12 -13
- package/{authCommands-XTBV7OFZ.js → authCommands-JSOG2H4E.js} +4 -5
- package/{chunk-OWOHNGCN.js → chunk-2MBTWINN.js} +42 -3
- package/{chunk-MVQ4TBSD.js → chunk-54VHTARN.js} +1 -1
- package/{chunk-RQN4SEKL.js → chunk-5DWZ46RJ.js} +1 -1
- package/{chunk-VYHDJEQD.js → chunk-5EDKWSQN.js} +136 -78
- package/{chunk-Z4NR32XR.js → chunk-5RGU3J7P.js} +13 -0
- package/{chunk-7BUYEZ6U.js → chunk-7H3UTGPM.js} +12 -72
- package/{chunk-3ZX7PERL.js → chunk-AAWJ5S3G.js} +20 -7
- package/{chunk-SCTYAHYK.js → chunk-ADE6577S.js} +237 -142
- package/{chunk-PJSV3IZ5.js → chunk-AOPOTHFK.js} +1 -1
- package/{chunk-3ND52WIL.js → chunk-ATWUOTJP.js} +180 -24
- package/{chunk-SWDPIPOY.js → chunk-AZW5AHMW.js} +1 -1
- package/chunk-CF7S2RYZ.js +376 -0
- package/{chunk-L4F3I4SR.js → chunk-CV6BM7LU.js} +4 -6
- package/{chunk-G5U6LDLG.js → chunk-CWTT2NZ6.js} +6 -6
- package/{chunk-MKA6QE5E.js → chunk-CZHE6LLV.js} +135 -55
- package/{chunk-KFEVY3ST.js → chunk-D34RI6NI.js} +18 -8
- package/{chunk-XRZJGPFI.js → chunk-FON47ACC.js} +4 -4
- package/{chunk-K6EUAOW3.js → chunk-FXFGNOT2.js} +67 -1
- package/{chunk-LLWKHDG4.js → chunk-G36SUBHA.js} +14 -6
- package/{chunk-REA4JLBH.js → chunk-GD23ZX7Z.js} +7 -6
- package/{chunk-ROWQEJRP.js → chunk-GE6IWA5N.js} +12 -4
- package/{chunk-EDV7EBOI.js → chunk-GGB6MPHD.js} +2155 -1503
- package/{chunk-IYEXFJPC.js → chunk-GNGOZMU2.js} +64 -57
- package/{chunk-4T5F7YZQ.js → chunk-I6RJGORZ.js} +1 -1
- package/{chunk-DFCFMCY6.js → chunk-J2WT5CEO.js} +2 -2
- package/{chunk-AHCY2S2I.js → chunk-JJ2WUBFN.js} +1 -1
- package/{chunk-UGUW3FHG.js → chunk-JMSCXQUG.js} +2 -2
- package/{chunk-VDXCXCXH.js → chunk-KURQBS7S.js} +1 -1
- package/{chunk-FQZZLA3C.js → chunk-KXKQO4Q6.js} +17 -0
- package/{chunk-3Q7WHGCB.js → chunk-L65QKSVJ.js} +1 -1
- package/{chunk-UAIVG4J6.js → chunk-LEHTC2FI.js} +1 -8
- package/{chunk-UBHAWFQ6.js → chunk-LLDGWLML.js} +42 -19
- package/{chunk-JLA4FXYC.js → chunk-MALVZUYL.js} +1 -1
- package/{chunk-N54HIJVJ.js → chunk-MCXQNEJ3.js} +101 -9
- package/{chunk-GFUIQ4RY.js → chunk-MXFQHRSS.js} +1 -1
- package/{chunk-LSFAWXKC.js → chunk-N7J63Q6C.js} +1 -0
- package/{chunk-6Y7A3OQQ.js → chunk-NRY4GCKJ.js} +2 -0
- package/{chunk-ELT65PZW.js → chunk-OXLLFZNF.js} +1 -1
- package/{chunk-YGW4G5W5.js → chunk-P3RZ6DHN.js} +133 -25
- package/{chunk-5MIDPSSK.js → chunk-PB7G5MAM.js} +3 -3
- package/{chunk-HEGV7BH3.js → chunk-PMCKFQYC.js} +1 -1
- package/{chunk-23FZYPLC.js → chunk-PTKI7TIN.js} +911 -1064
- package/{chunk-MHSGJW4Z.js → chunk-PXPISYEH.js} +44 -14
- package/{chunk-I2ZJKTG5.js → chunk-PY7VGC5M.js} +29 -10
- package/{chunk-PIZYJVHQ.js → chunk-RM464B7I.js} +4 -4
- package/{chunk-XHG22OEX.js → chunk-ROJI6DRT.js} +2 -2
- package/{chunk-VNAEBGDK.js → chunk-RZNYL4LW.js} +123 -26
- package/{chunk-RVOUXDFU.js → chunk-S6KVFOUG.js} +6 -34
- package/{chunk-BV4VEE3W.js → chunk-S7AV3NCK.js} +277 -357
- package/{chunk-R35XMF6F.js → chunk-SIUEKVK4.js} +484 -67
- package/{chunk-B5TOXZAK.js → chunk-SIZQB7BD.js} +1 -1
- package/{chunk-DFFIZ25G.js → chunk-SLOGKB7M.js} +4 -1
- package/{chunk-MPVYDS7I.js → chunk-TLYHUIWF.js} +3 -3
- package/{chunk-HWW2M4SN.js → chunk-TNM27YZ7.js} +5 -4
- package/{chunk-OK6YSWLH.js → chunk-TWA4L7J7.js} +1 -1
- package/chunk-UZ6XXCVR.js +50 -0
- package/{chunk-DKZFOK24.js → chunk-WCP5FDTF.js} +16 -304
- package/{chunk-TRT4I4UD.js → chunk-WSQLK2KR.js} +2 -2
- package/{chunk-FXUSIQC2.js → chunk-XNZJVYFS.js} +1 -1
- package/{chunk-V3ED5AWK.js → chunk-YJY7HODU.js} +27 -16
- package/chunk-YYLHWIW6.js +48 -0
- package/{chunk-CZ6NYQTV.js → chunk-ZFL3LTU7.js} +2 -2
- package/{chunk-34WPV75U.js → chunk-ZUXIXYJI.js} +1 -1
- package/{chunk-VC6OZXO5.js → chunk-ZWJOGMKH.js} +2 -26
- package/{cliExecutor-DNE7TCC4.js → cliExecutor-K3F7DMRO.js} +2 -2
- package/{codingSkills-36KN5NQT.js → codingSkills-EN6Z6G6U.js} +4 -4
- package/{createAgentAutomationAction-GNFF524X.js → createAgentAutomationAction-PO62NUR7.js} +19 -18
- package/{createDialogAction-RB55KCLO.js → createDialogAction-ORFRYI3C.js} +22 -20
- package/{createPageAction-Y7343GLU.js → createPageAction-XWVMNTYH.js} +20 -19
- package/{db-W3O47YGF.js → db-W5UHK4P3.js} +150 -0
- package/{dbSlice-CGSRFJN3.js → dbSlice-5BKDURDL.js} +4 -4
- package/{dialogCommands-IAZK6YHQ.js → dialogCommands-XTJHROXM.js} +24 -23
- package/{dialogSlice-UQAXF23P.js → dialogSlice-DJXC53YW.js} +24 -18
- package/{docCreateCommands-I2EWZGCI.js → docCreateCommands-T2XRVXYS.js} +24 -27
- package/{docDeleteCommands-IZ45UZKG.js → docDeleteCommands-L7RXFXY3.js} +25 -24
- package/{docReadCommands-R6Z4QJYU.js → docReadCommands-M5PYNADQ.js} +24 -23
- package/{docStore-5HOJ4D7D.js → docStore-6LKLLFDW.js} +20 -19
- package/{docUpdateCommands-2LRBKQPY.js → docUpdateCommands-OA5EGPLQ.js} +24 -27
- package/{fetchMessages-BMGVZVSE.js → fetchMessages-W4IKHPCS.js} +2 -3
- package/{getPricing-G7DLAST6.js → getPricing-6C3C47Y4.js} +3 -3
- package/{handleSendMessageAction-Q4HY35WX.js → handleSendMessageAction-ILFGZTN5.js} +23 -20
- package/index.js +74 -74
- package/{localDialogRead-4H3QJFLW.js → localDialogRead-JXTAHW2E.js} +2 -2
- package/{machineCommands-PKBPQKTY.js → machineCommands-AKAQGPAO.js} +59 -57
- package/{machineWsRunDispatch-UZAW4OXJ.js → machineWsRunDispatch-RSBERM64.js} +51 -49
- package/{models-DJFSJ7SW.js → models-ILWKIX2Y.js} +2 -2
- package/package.json +1 -1
- package/{read-3FMPZPER.js → read-F3L3T2WJ.js} +2 -1
- package/{readDocTool-VSYHKK3V.js → readDocTool-FOHWVA4R.js} +1 -1
- package/{readlineWorkspace-Y2RDOFZG.js → readlineWorkspace-TUH3SFHO.js} +937 -430
- package/{removeDialogAgentAction-OAGA2G3U.js → removeDialogAgentAction-QCFGIUIH.js} +8 -7
- package/{runAgentClientLoop-NBPIKJ6J.js → runAgentClientLoop-C3QB2EXV.js} +45 -38
- package/{setDialogExtraReferencesAction-JZEXA5SL.js → setDialogExtraReferencesAction-DK4CKERU.js} +5 -5
- package/{setPrimaryDialogAgentAction-4ZUQQKDG.js → setPrimaryDialogAgentAction-SJSO6N27.js} +8 -7
- package/{settingSlice-7MNKHZ6R.js → settingSlice-XNM5AFPU.js} +6 -5
- package/{spaceCommands-DHCZ7J5I.js → spaceCommands-SXYOFGUJ.js} +25 -24
- package/{spaceSlice-ZXLLG3CR.js → spaceSlice-6BHMRP5O.js} +21 -18
- package/{streamAgentChatTurn-L3YW6LSB.js → streamAgentChatTurn-GF5W5OIP.js} +140 -98
- package/switchDialogAgentAction-4OAC6QRN.js +61 -0
- package/{tableCommands-BEQAGE4I.js → tableCommands-QSZILI7I.js} +1 -1
- package/{toolApiClient-QI3YBNWB.js → toolApiClient-ISM4ZQX4.js} +2 -2
- package/{tools-ECGXR5QF.js → tools-KBCLJ43G.js} +36 -33
- package/{tuiSummaryLlmCaller-OMSCNHXA.js → tuiSummaryLlmCaller-ARIMGILF.js} +6 -6
- package/{updateCommands-XTW55TOT.js → updateCommands-AK2RDOFR.js} +8 -2
- package/{updateDialogTitleAction-HQ2EUDFT.js → updateDialogTitleAction-LMHZUY4Q.js} +28 -27
- package/chunk-DL6EPNIK.js +0 -50
- package/chunk-V5R4NZP2.js +0 -78
- package/chunk-X4Q4UZEY.js +0 -26
- package/queryRunOverlay-O4LOMMPO.js +0 -161
- package/runOverlayPresentation-ZO4VCWEU.js +0 -11
- package/types-ZSTJ7MPR.js +0 -7
- package/{chunk-X7W4TNB4.js → chunk-CMKUBIGW.js} +3 -3
- package/{runtimeDoctorCommands-E2OUORHK.js → runtimeDoctorCommands-HSU632DY.js} +3 -3
|
@@ -8,24 +8,26 @@ import {
|
|
|
8
8
|
writeUsage
|
|
9
9
|
} from "./chunk-DZ3XJVET.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import {
|
|
14
|
-
normalizeAgentHandle,
|
|
15
|
-
readDbRecord,
|
|
16
|
-
resolveAgentRecordFromHybridStore
|
|
17
|
-
} from "./chunk-DFCFMCY6.js";
|
|
11
|
+
resolveMachineId
|
|
12
|
+
} from "./chunk-6HYVJV7B.js";
|
|
18
13
|
import {
|
|
19
14
|
agentRunCardLabels,
|
|
20
|
-
createCliCallAgentToolExecutor,
|
|
21
15
|
createCliLocalRuntimeAdapter,
|
|
22
16
|
getCliLocale,
|
|
23
17
|
isBuiltinNoloAgentRef,
|
|
24
|
-
|
|
18
|
+
isSubtaskRun,
|
|
25
19
|
parseAgentRunEvent,
|
|
26
20
|
t,
|
|
27
21
|
toolLabel
|
|
28
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-PTKI7TIN.js";
|
|
23
|
+
import {
|
|
24
|
+
getReadableCliDb
|
|
25
|
+
} from "./chunk-WFHXMLHZ.js";
|
|
26
|
+
import {
|
|
27
|
+
normalizeAgentHandle,
|
|
28
|
+
readDbRecord,
|
|
29
|
+
resolveAgentRecordFromHybridStore
|
|
30
|
+
} from "./chunk-J2WT5CEO.js";
|
|
29
31
|
import {
|
|
30
32
|
NOLO_PROJECT_MANAGER_AGENT_KEY,
|
|
31
33
|
isLocalCliAgentKey
|
|
@@ -34,12 +36,9 @@ import {
|
|
|
34
36
|
applyModelLayerOverride,
|
|
35
37
|
buildModelLayerOverride
|
|
36
38
|
} from "./chunk-LTRXGFMS.js";
|
|
37
|
-
import {
|
|
38
|
-
resolveMachineId
|
|
39
|
-
} from "./chunk-6HYVJV7B.js";
|
|
40
39
|
import {
|
|
41
40
|
formatAgentListCard
|
|
42
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-GGB6MPHD.js";
|
|
43
42
|
import {
|
|
44
43
|
isGatewayHttpStatus
|
|
45
44
|
} from "./chunk-RQSOAMPJ.js";
|
|
@@ -51,23 +50,19 @@ import {
|
|
|
51
50
|
chooseMemoryOwners,
|
|
52
51
|
loadMemoryCandidatesFromDb,
|
|
53
52
|
resolveAgentMemoryPolicy
|
|
54
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-GNGOZMU2.js";
|
|
55
54
|
import {
|
|
56
55
|
API_REPORTED_COST_MULTIPLIER,
|
|
57
56
|
normalizeUsage,
|
|
58
57
|
parseUiAskChoiceContent
|
|
59
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-ADE6577S.js";
|
|
60
59
|
import {
|
|
61
60
|
buildSkillDiscoveryContextBlock
|
|
62
61
|
} from "./chunk-7OBMZCRD.js";
|
|
63
62
|
import {
|
|
64
63
|
parseExternalSkillMarkdown,
|
|
65
64
|
parseSkillDocProtocol
|
|
66
|
-
} from "./chunk-
|
|
67
|
-
import {
|
|
68
|
-
buildPlatformChatCompletionRequest,
|
|
69
|
-
parsePlatformChatCompletionData
|
|
70
|
-
} from "./chunk-N54HIJVJ.js";
|
|
65
|
+
} from "./chunk-ZWJOGMKH.js";
|
|
71
66
|
import {
|
|
72
67
|
resolveAgentRuntimeConfigFromRecord
|
|
73
68
|
} from "./chunk-OIQPORYI.js";
|
|
@@ -76,29 +71,25 @@ import {
|
|
|
76
71
|
LOCAL_TURN_ABORTED_CODE,
|
|
77
72
|
readActionGate,
|
|
78
73
|
readCommandActionGatePayload
|
|
79
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-P3RZ6DHN.js";
|
|
80
75
|
import {
|
|
81
76
|
createThinkParserState,
|
|
82
77
|
flushThinkParser,
|
|
83
78
|
processThinkChunk
|
|
84
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-N7J63Q6C.js";
|
|
85
80
|
import {
|
|
86
|
-
resolvePlatformAuthToken
|
|
87
|
-
|
|
88
|
-
} from "./chunk-MHSGJW4Z.js";
|
|
81
|
+
resolvePlatformAuthToken
|
|
82
|
+
} from "./chunk-PXPISYEH.js";
|
|
89
83
|
import {
|
|
90
84
|
DEFAULT_CONTEXT_WINDOW,
|
|
91
85
|
getModelContextWindow
|
|
92
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-PY7VGC5M.js";
|
|
93
87
|
import {
|
|
94
88
|
clipCompactText
|
|
95
89
|
} from "./chunk-5MMAK75Q.js";
|
|
96
90
|
import {
|
|
97
91
|
findModelConfig
|
|
98
|
-
} from "./chunk-
|
|
99
|
-
import {
|
|
100
|
-
toErrorMessage
|
|
101
|
-
} from "./chunk-HNMXYYJR.js";
|
|
92
|
+
} from "./chunk-LEHTC2FI.js";
|
|
102
93
|
import {
|
|
103
94
|
buildMemoryOverlayLayer,
|
|
104
95
|
buildMemoryUseGuidanceLayer
|
|
@@ -110,7 +101,7 @@ import {
|
|
|
110
101
|
createRunActivityTracker,
|
|
111
102
|
finalizeRunRecord,
|
|
112
103
|
spawnLocalBackgroundRun
|
|
113
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-RZNYL4LW.js";
|
|
114
105
|
import {
|
|
115
106
|
formatFinishedRunCard,
|
|
116
107
|
formatListRunsCard,
|
|
@@ -120,10 +111,13 @@ import {
|
|
|
120
111
|
formatStopRunCard,
|
|
121
112
|
isAgentRunTerminalStatus,
|
|
122
113
|
runShowsLogTail
|
|
123
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-KXKQO4Q6.js";
|
|
124
115
|
import {
|
|
125
116
|
CliProviderQuotaError
|
|
126
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-CMKUBIGW.js";
|
|
118
|
+
import {
|
|
119
|
+
toErrorMessage
|
|
120
|
+
} from "./chunk-HNMXYYJR.js";
|
|
127
121
|
import {
|
|
128
122
|
readPipeText,
|
|
129
123
|
spawnProcess
|
|
@@ -136,7 +130,7 @@ import {
|
|
|
136
130
|
} from "./chunk-Y5GCAMGP.js";
|
|
137
131
|
import {
|
|
138
132
|
createMemoryKey
|
|
139
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-NRY4GCKJ.js";
|
|
140
134
|
import {
|
|
141
135
|
asTrimmedLowercaseString
|
|
142
136
|
} from "./chunk-QSJ3HFEF.js";
|
|
@@ -144,7 +138,7 @@ import {
|
|
|
144
138
|
BUILTIN_NOLO_AGENT_KEY,
|
|
145
139
|
PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY,
|
|
146
140
|
PUBLIC_KIMI_K26_IMAGE_AGENT_KEY
|
|
147
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-ATWUOTJP.js";
|
|
148
142
|
import {
|
|
149
143
|
asTrimmedString
|
|
150
144
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -155,97 +149,6 @@ import {
|
|
|
155
149
|
asOptionalTrimmedString
|
|
156
150
|
} from "./chunk-G3SUCT4W.js";
|
|
157
151
|
|
|
158
|
-
// packages/agent-runtime/quickChatIntentCore.ts
|
|
159
|
-
var INTENT_MODEL = "deepseek-v4-flash";
|
|
160
|
-
var INTENT_PROVIDER = "nolo";
|
|
161
|
-
var QUICK_CHAT_INTENT_TIMEOUT_MS = 4e3;
|
|
162
|
-
var SHORT_GREETING_MAX_LENGTH = 20;
|
|
163
|
-
var SHORT_GREETING_PATTERN = /^(?:hi|hello|hey|hiya|yo|sup|howdy|嗨|哈喽|哈囉|你好|您好|在吗|在嘛|喂|早上好|中午好|下午好|晚上好|拜拜|再见|谢谢|thanks|thx|ok|好的|收到|了解)[!.。,、~~]?$/iu;
|
|
164
|
-
var VALID_QUICK_CHAT_SKILLS = /* @__PURE__ */ new Set([
|
|
165
|
-
"table",
|
|
166
|
-
"doc",
|
|
167
|
-
"code",
|
|
168
|
-
"pagebuilder"
|
|
169
|
-
]);
|
|
170
|
-
function isShortGreeting(text) {
|
|
171
|
-
const trimmed = text.trim();
|
|
172
|
-
if (!trimmed) return false;
|
|
173
|
-
if (trimmed.length > SHORT_GREETING_MAX_LENGTH) return false;
|
|
174
|
-
return SHORT_GREETING_PATTERN.test(trimmed);
|
|
175
|
-
}
|
|
176
|
-
var COMPLEXITY_SIMPLE_MAX_LENGTH = 80;
|
|
177
|
-
var COMPLEXITY_MEDIUM_MAX_LENGTH = 500;
|
|
178
|
-
var COMPLEXITY_KEYWORDS = /为什么|如何|分析|对比|比较|设计|架构|实现|原理|推导|评价|区别|关系|影响|优化|重构/;
|
|
179
|
-
var COMPLEXITY_CODE_BLOCK = /```[\s\S]*```/;
|
|
180
|
-
function estimateComplexity(text) {
|
|
181
|
-
const trimmed = text.trim();
|
|
182
|
-
const len = trimmed.length;
|
|
183
|
-
if (len > COMPLEXITY_MEDIUM_MAX_LENGTH) return "complex";
|
|
184
|
-
if (COMPLEXITY_CODE_BLOCK.test(trimmed)) return "complex";
|
|
185
|
-
if (len > COMPLEXITY_SIMPLE_MAX_LENGTH) return "medium";
|
|
186
|
-
if (COMPLEXITY_KEYWORDS.test(trimmed)) return "medium";
|
|
187
|
-
return "simple";
|
|
188
|
-
}
|
|
189
|
-
var TIER_DESCRIPTIONS = {
|
|
190
|
-
flash: "\u5FEB\u901F\u7B80\u5355\uFF1A\u95EE\u5019\u3001\u95F2\u804A\u3001\u5FEB\u901F\u95EE\u7B54\u3001\u7FFB\u8BD1\u3001\u77ED\u6587",
|
|
191
|
-
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",
|
|
192
|
-
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"
|
|
193
|
-
};
|
|
194
|
-
function buildQuickChatIntentSystemPrompt(tierAgents) {
|
|
195
|
-
const agentList = tierAgents.map((t2) => ` - "${t2.agentKey}"\uFF1A${t2.description}`).join("\n");
|
|
196
|
-
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
|
|
197
|
-
|
|
198
|
-
\u53EF\u9009 agent \u5217\u8868\uFF08agentKey \u4E0E\u63CF\u8FF0\uFF09\uFF1A
|
|
199
|
-
${agentList}
|
|
200
|
-
|
|
201
|
-
\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 balanced/quality**\uFF09\uFF1A
|
|
202
|
-
- \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
|
|
203
|
-
- \u7B80\u5355\u95EE\u5019\u3001\u95F2\u804A\u3001\u5FEB\u901F\u95EE\u7B54\u3001\u7FFB\u8BD1\u3001\u77ED\u6587 \u2192 \u9009 flash \u6863
|
|
204
|
-
- \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
|
|
205
|
-
- \u590D\u6742\u63A8\u7406\u3001\u957F\u6587\u3001\u67B6\u6784\u8BBE\u8BA1\u3001\u6DF1\u5EA6\u5206\u6790 \u2192 \u9009 quality \u6863
|
|
206
|
-
- **\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
|
|
207
|
-
- \u4E13\u804C agent \u8DEF\u7531\u89C4\u5219\uFF08\u6709\u660E\u786E\u5339\u914D\u65F6\u4F7F\u7528\uFF09\uFF1A
|
|
208
|
-
- \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
|
|
209
|
-
- \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
|
|
210
|
-
- \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
|
|
211
|
-
- \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
|
|
212
|
-
- **\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**\u3002
|
|
213
|
-
|
|
214
|
-
\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
|
|
215
|
-
|
|
216
|
-
\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
|
|
217
|
-
- \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"
|
|
218
|
-
- \u7528\u6237\u8981\u5199/\u6DA6\u8272/\u6539\u5199/\u7EED\u5199/\u6392\u7248\u4E00\u7BC7\u6587\u6863\u6216\u6587\u7AE0 \u2192 skills \u542B "doc"
|
|
219
|
-
- \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
|
|
220
|
-
- \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"
|
|
221
|
-
- \u666E\u901A\u95EE\u7B54/\u7EAF\u95F2\u804A/\u5EFA\u5E94\u7528 \u2192 skills \u4E3A []
|
|
222
|
-
|
|
223
|
-
\u53EA\u8F93\u51FA JSON\uFF0C\u4E0D\u8981\u8F93\u51FA\u5176\u4ED6\u5185\u5BB9\uFF1A
|
|
224
|
-
{"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>", "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 []>}`;
|
|
225
|
-
}
|
|
226
|
-
function parseQuickChatIntentResult(content, tierAgents) {
|
|
227
|
-
try {
|
|
228
|
-
const parsed = JSON.parse(content.trim());
|
|
229
|
-
if (typeof parsed !== "object" || parsed === null || !("agentKey" in parsed)) return null;
|
|
230
|
-
const key = parsed.agentKey;
|
|
231
|
-
if (typeof key !== "string") return null;
|
|
232
|
-
if (!tierAgents.some((t2) => t2.agentKey === key)) return null;
|
|
233
|
-
const rawConfidence = parsed.confidence;
|
|
234
|
-
const confidence = typeof rawConfidence === "number" && Number.isFinite(rawConfidence) && rawConfidence >= 0 && rawConfidence <= 1 ? rawConfidence : void 0;
|
|
235
|
-
const rawSkills = parsed.skills;
|
|
236
|
-
let skills;
|
|
237
|
-
if (Array.isArray(rawSkills)) {
|
|
238
|
-
const filtered = [...new Set(rawSkills)].filter(
|
|
239
|
-
(s) => typeof s === "string" && VALID_QUICK_CHAT_SKILLS.has(s)
|
|
240
|
-
);
|
|
241
|
-
if (filtered.length > 0) skills = filtered;
|
|
242
|
-
}
|
|
243
|
-
return { agentKey: key, confidence, skills };
|
|
244
|
-
} catch {
|
|
245
|
-
return null;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
152
|
// packages/cli/client/autoModelRouter.ts
|
|
250
153
|
var CLI_AUTO_TIER_AGENT_KEYS = {
|
|
251
154
|
flash: PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY,
|
|
@@ -260,9 +163,7 @@ var CLI_AUTO_TIER_MODELS = {
|
|
|
260
163
|
var CLI_IMAGE_AGENT_KEY = PUBLIC_KIMI_K26_IMAGE_AGENT_KEY;
|
|
261
164
|
var CLI_IMAGE_AGENT_MODEL = "kimi-k2.6";
|
|
262
165
|
var CLI_AUTO_TIER_AGENT_KEY_TABLE = {
|
|
263
|
-
[CLI_AUTO_TIER_AGENT_KEYS.flash]: true
|
|
264
|
-
[CLI_AUTO_TIER_AGENT_KEYS.balanced]: true,
|
|
265
|
-
[CLI_AUTO_TIER_AGENT_KEYS.quality]: true
|
|
166
|
+
[CLI_AUTO_TIER_AGENT_KEYS.flash]: true
|
|
266
167
|
};
|
|
267
168
|
function resolveCliAutoAgentModel(agentKey) {
|
|
268
169
|
if (agentKey === CLI_AUTO_TIER_AGENT_KEYS.flash) return CLI_AUTO_TIER_MODELS.flash;
|
|
@@ -275,90 +176,15 @@ function resolveCliAutoAgentModel(agentKey) {
|
|
|
275
176
|
if (agentKey === CLI_IMAGE_AGENT_KEY) return CLI_IMAGE_AGENT_MODEL;
|
|
276
177
|
return void 0;
|
|
277
178
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
description: TIER_DESCRIPTIONS[tier]
|
|
282
|
-
}));
|
|
283
|
-
var tierForAgentKey = (agentKey) => {
|
|
284
|
-
for (const tier of ["flash", "balanced", "quality"]) {
|
|
285
|
-
if (CLI_AUTO_TIER_AGENT_KEYS[tier] === agentKey) return tier;
|
|
286
|
-
}
|
|
287
|
-
return null;
|
|
288
|
-
};
|
|
289
|
-
function resolveCliAutoFallbackTier(text) {
|
|
290
|
-
switch (estimateComplexity(text)) {
|
|
291
|
-
case "complex":
|
|
292
|
-
return "quality";
|
|
293
|
-
case "medium":
|
|
294
|
-
return "balanced";
|
|
295
|
-
case "simple":
|
|
296
|
-
default:
|
|
297
|
-
return "flash";
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
async function classifyCliAutoRoute(text, options) {
|
|
301
|
-
const timeoutMs = options.timeoutMs ?? QUICK_CHAT_INTENT_TIMEOUT_MS;
|
|
302
|
-
const fallbackTier = resolveCliAutoFallbackTier(text);
|
|
303
|
-
const fallback = () => ({
|
|
304
|
-
agentKey: CLI_AUTO_TIER_AGENT_KEYS[fallbackTier],
|
|
305
|
-
tier: fallbackTier,
|
|
306
|
-
classified: false
|
|
307
|
-
});
|
|
308
|
-
if (!text.trim()) return fallback();
|
|
309
|
-
if (isShortGreeting(text)) {
|
|
310
|
-
return {
|
|
311
|
-
agentKey: CLI_AUTO_TIER_AGENT_KEYS.flash,
|
|
312
|
-
tier: "flash",
|
|
313
|
-
classified: true
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
if (!options.authToken) return fallback();
|
|
317
|
-
const fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
318
|
-
const controller = new AbortController();
|
|
319
|
-
const timeoutHandle = setTimeout(() => controller.abort(), timeoutMs);
|
|
320
|
-
try {
|
|
321
|
-
const routeOptions = buildRouteOptions();
|
|
322
|
-
const messages = [
|
|
323
|
-
{ role: "system", content: buildQuickChatIntentSystemPrompt(routeOptions) },
|
|
324
|
-
{ role: "user", content: text }
|
|
325
|
-
];
|
|
326
|
-
const { url, init } = buildPlatformChatCompletionRequest({
|
|
327
|
-
providerConfig: {
|
|
328
|
-
serverUrl: options.serverUrl,
|
|
329
|
-
authToken: options.authToken,
|
|
330
|
-
agentKey: CLI_AUTO_TIER_AGENT_KEYS.flash,
|
|
331
|
-
model: INTENT_MODEL,
|
|
332
|
-
provider: INTENT_PROVIDER,
|
|
333
|
-
endpoint: resolvePlatformChatCompletionsEndpoint(INTENT_PROVIDER) ?? "",
|
|
334
|
-
requestOptions: {}
|
|
335
|
-
},
|
|
336
|
-
messages,
|
|
337
|
-
stream: false
|
|
338
|
-
});
|
|
339
|
-
const response = await fetchImpl(url, {
|
|
340
|
-
...init,
|
|
341
|
-
signal: controller.signal
|
|
342
|
-
});
|
|
343
|
-
if (!response.ok) return fallback();
|
|
344
|
-
const data = parsePlatformChatCompletionData(await response.text());
|
|
345
|
-
const content = data?.choices?.[0]?.message?.content;
|
|
346
|
-
if (typeof content !== "string" || !content.trim()) return fallback();
|
|
347
|
-
const parsed = parseQuickChatIntentResult(content, routeOptions);
|
|
348
|
-
if (!parsed) return fallback();
|
|
349
|
-
const tier = tierForAgentKey(parsed.agentKey) ?? fallbackTier;
|
|
350
|
-
return {
|
|
351
|
-
agentKey: parsed.agentKey,
|
|
352
|
-
tier,
|
|
353
|
-
classified: true,
|
|
354
|
-
confidence: parsed.confidence,
|
|
355
|
-
skills: parsed.skills
|
|
356
|
-
};
|
|
357
|
-
} catch {
|
|
358
|
-
return fallback();
|
|
359
|
-
} finally {
|
|
360
|
-
clearTimeout(timeoutHandle);
|
|
179
|
+
function classifyCliAutoRoute(_text, options) {
|
|
180
|
+
if (options.hasImages) {
|
|
181
|
+
return { agentKey: CLI_IMAGE_AGENT_KEY, tier: "image", classified: true };
|
|
361
182
|
}
|
|
183
|
+
return {
|
|
184
|
+
agentKey: CLI_AUTO_TIER_AGENT_KEYS.flash,
|
|
185
|
+
tier: "flash",
|
|
186
|
+
classified: true
|
|
187
|
+
};
|
|
362
188
|
}
|
|
363
189
|
|
|
364
190
|
// packages/cli/client/tokenUsage.ts
|
|
@@ -459,9 +285,20 @@ function formatUsage(usage, dialogId) {
|
|
|
459
285
|
const parts = [];
|
|
460
286
|
if (typeof dialogId === "string" && dialogId)
|
|
461
287
|
parts.push(`dialog=${dialogId}`);
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
288
|
+
if (usage && typeof usage === "object") {
|
|
289
|
+
const normalized = normalizeUsage(usage);
|
|
290
|
+
const input = Number(normalized.input_tokens || usage?.input_tokens || usage?.prompt_tokens || 0);
|
|
291
|
+
const output = Number(normalized.output_tokens || usage?.output_tokens || usage?.completion_tokens || 0);
|
|
292
|
+
const cacheHit = Number(normalized.cache_read_input_tokens || 0);
|
|
293
|
+
if (input || output) {
|
|
294
|
+
let tokenStr = `tokens=${input}+${output}`;
|
|
295
|
+
if (cacheHit > 0 && input > 0) {
|
|
296
|
+
const hitPercent = (cacheHit / (input + cacheHit) * 100).toFixed(1).replace(/\.0$/, "");
|
|
297
|
+
tokenStr += ` (cache: ${formatTokenCount(cacheHit)} / ${hitPercent}%)`;
|
|
298
|
+
}
|
|
299
|
+
parts.push(tokenStr);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
465
302
|
return parts.length ? ` (${parts.join(" ")})` : "";
|
|
466
303
|
}
|
|
467
304
|
|
|
@@ -706,7 +543,7 @@ function wrapTranscriptLine(line, columns, hangingIndent = "") {
|
|
|
706
543
|
}
|
|
707
544
|
const openingStyles = [...activeStyles];
|
|
708
545
|
const isContinuation = result.length > 0 && hangingIndent.length > 0;
|
|
709
|
-
const indentWidth = isContinuation ?
|
|
546
|
+
const indentWidth = isContinuation ? visibleWidth(hangingIndent) : 0;
|
|
710
547
|
const maxSegmentWidth = Math.max(1, columns - indentWidth);
|
|
711
548
|
let width = 0;
|
|
712
549
|
let end = start;
|
|
@@ -808,13 +645,17 @@ var THEME_PALETTES = {
|
|
|
808
645
|
// denser slate — 687584 read too blue in dense prose (inline code/tool labels); 5E6A78 pulls blue down while staying darker than the old value
|
|
809
646
|
},
|
|
810
647
|
dark: {
|
|
811
|
-
accent: { hex: "
|
|
812
|
-
//
|
|
648
|
+
accent: { hex: "5BA3D9", ansiFallback: "\x1B[34m" },
|
|
649
|
+
// trail dark primary (was wrongly copied from catppuccin 89B4FA)
|
|
813
650
|
chrome: { hex: "6C7086", ansiFallback: "\x1B[90m" },
|
|
814
|
-
success: { hex: "
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
651
|
+
success: { hex: "5CB87A", ansiFallback: "\x1B[32m" },
|
|
652
|
+
// trail dark success (was A6E3A1)
|
|
653
|
+
warning: { hex: "E6B35C", ansiFallback: "\x1B[33m" },
|
|
654
|
+
// trail dark warning (was F9E2AF)
|
|
655
|
+
info: { hex: "6BB8E8", ansiFallback: "\x1B[36m" },
|
|
656
|
+
// trail dark info (was 94E2D5)
|
|
657
|
+
danger: { hex: "E07060", ansiFallback: "\x1B[31m" },
|
|
658
|
+
// trail dark error (was F38BA8)
|
|
818
659
|
muted: { hex: "9AA3B8", ansiFallback: "\x1B[90m" }
|
|
819
660
|
// dimmed from A6ADC8 so secondary text sits a step below body text
|
|
820
661
|
}
|
|
@@ -1096,6 +937,13 @@ function diffLineSequences(env = process.env, brightness = resolveTuiBrightness(
|
|
|
1096
937
|
context: { fg: "", bg: "", bar: " " }
|
|
1097
938
|
};
|
|
1098
939
|
}
|
|
940
|
+
function renderSurfaceLine(args) {
|
|
941
|
+
const { text, surface, padTo } = args;
|
|
942
|
+
if (!surface) return text;
|
|
943
|
+
const reopened = text.split("\x1B[0m").join(`\x1B[0m${surface}`);
|
|
944
|
+
const padding = " ".repeat(Math.max(0, padTo - visibleWidth(text)));
|
|
945
|
+
return `${surface}${reopened}${padding}\x1B[0m`;
|
|
946
|
+
}
|
|
1099
947
|
function renderDiffLine(args) {
|
|
1100
948
|
const { kind, text } = args;
|
|
1101
949
|
const env = args.env ?? process.env;
|
|
@@ -1108,13 +956,23 @@ function renderDiffLine(args) {
|
|
|
1108
956
|
return `${themeColorSequence(token, env)}${text}\x1B[39m`;
|
|
1109
957
|
}
|
|
1110
958
|
const seq = seqs[kind];
|
|
1111
|
-
|
|
1112
|
-
|
|
959
|
+
return renderSurfaceLine({
|
|
960
|
+
text: `${seq.fg}${text}`,
|
|
961
|
+
surface: seq.bg,
|
|
962
|
+
padTo: args.padTo ?? visibleWidth(text)
|
|
963
|
+
});
|
|
1113
964
|
}
|
|
1114
965
|
function surfaceBackgroundSequence(env = process.env, brightness = resolveTuiBrightness(env)) {
|
|
1115
966
|
if (!supportsTruecolor(env)) return "";
|
|
1116
967
|
return hexToBgSgr((SURFACE_HEX[activeThemeName] ?? SURFACE_HEX.trail)[brightness]);
|
|
1117
968
|
}
|
|
969
|
+
function userSurfaceBackgroundSequence(env = process.env, brightness = resolveTuiBrightness(env)) {
|
|
970
|
+
if (!supportsTruecolor(env)) return "";
|
|
971
|
+
const palette = THEME_PALETTES[activeThemeName] ?? THEME_PALETTES.trail;
|
|
972
|
+
const accentHex = palette[brightness].accent.hex;
|
|
973
|
+
const weight = brightness === "dark" ? 0.24 : 0.16;
|
|
974
|
+
return hexToBgSgr(blendHex(accentHex, resolveTerminalBaseHex(brightness), weight));
|
|
975
|
+
}
|
|
1118
976
|
function themeColorSequence(token, env = process.env, brightness = resolveTuiBrightness(env)) {
|
|
1119
977
|
const palette = THEME_PALETTES[activeThemeName] ?? THEME_PALETTES.trail;
|
|
1120
978
|
const entry = palette[brightness][token];
|
|
@@ -1558,9 +1416,28 @@ function createRenderAwareStreamWriter(args) {
|
|
|
1558
1416
|
let inFence = false;
|
|
1559
1417
|
let fenceLang = "unknown";
|
|
1560
1418
|
let lastKind = null;
|
|
1419
|
+
const PARTIAL_FLUSH_THRESHOLD = 48;
|
|
1561
1420
|
const emitBreathIfNeeded = (nextKind) => {
|
|
1562
1421
|
if (needsListProseBreath(lastKind, nextKind)) args.write("\n");
|
|
1563
1422
|
};
|
|
1423
|
+
const flushPartialProse = () => {
|
|
1424
|
+
if (inFence || buffer.length < PARTIAL_FLUSH_THRESHOLD) return;
|
|
1425
|
+
const firstLine = buffer.split("\n", 1)[0] ?? "";
|
|
1426
|
+
if (isTableRow(firstLine) || classifyStreamLine(firstLine) !== "prose") return;
|
|
1427
|
+
const Segmenter = Intl.Segmenter;
|
|
1428
|
+
const graphemes = typeof Segmenter === "function" ? Array.from(new Segmenter(void 0, { granularity: "grapheme" }).segment(firstLine), (part) => part.segment) : Array.from(firstLine);
|
|
1429
|
+
if (graphemes.length < PARTIAL_FLUSH_THRESHOLD) return;
|
|
1430
|
+
let cut = PARTIAL_FLUSH_THRESHOLD;
|
|
1431
|
+
const whitespaceIndex = graphemes.slice(0, cut).findLastIndex((part) => /\s/.test(part));
|
|
1432
|
+
if (whitespaceIndex > 0) cut = whitespaceIndex + 1;
|
|
1433
|
+
const prefix = graphemes.slice(0, cut).join("");
|
|
1434
|
+
const hasUnsafeMarkdownPrefix = /[`*_~\[]/.test(prefix) || /^\s*[#>]/.test(prefix) || /!\[/.test(prefix);
|
|
1435
|
+
if (hasUnsafeMarkdownPrefix) return;
|
|
1436
|
+
emitBreathIfNeeded("prose");
|
|
1437
|
+
emitFormattedAssistantBlock(args.write, prefix, false);
|
|
1438
|
+
lastKind = "prose";
|
|
1439
|
+
buffer = prefix.length === buffer.length ? "" : buffer.slice(prefix.length);
|
|
1440
|
+
};
|
|
1564
1441
|
const flushCompleteBlocks = () => {
|
|
1565
1442
|
while (buffer.includes("\n")) {
|
|
1566
1443
|
const lines = buffer.split("\n");
|
|
@@ -1620,6 +1497,7 @@ function createRenderAwareStreamWriter(args) {
|
|
|
1620
1497
|
if (!chunk) return;
|
|
1621
1498
|
buffer += chunk;
|
|
1622
1499
|
flushCompleteBlocks();
|
|
1500
|
+
flushPartialProse();
|
|
1623
1501
|
},
|
|
1624
1502
|
flush() {
|
|
1625
1503
|
if (!buffer) return;
|
|
@@ -2426,7 +2304,7 @@ function isReadToolName(name) {
|
|
|
2426
2304
|
}
|
|
2427
2305
|
function isSearchToolName(name) {
|
|
2428
2306
|
if (!name) return false;
|
|
2429
|
-
return name === "grep" || name === "searchFiles" || name === "search_files" || name === "globFiles" || name === "glob_files" || name === "glob" || name === "searchWorkspace" || name === "search";
|
|
2307
|
+
return name === "grep" || name === "searchFiles" || name === "search_files" || name === "globFiles" || name === "glob_files" || name === "glob" || name === "searchWorkspace" || name === "search_workspace" || name === "search_all_spaces" || name === "search";
|
|
2430
2308
|
}
|
|
2431
2309
|
function isRunToolName(name) {
|
|
2432
2310
|
if (!name) return false;
|
|
@@ -2573,8 +2451,43 @@ function resolveLoadSkillName(event) {
|
|
|
2573
2451
|
if (match?.[1]) return match[1];
|
|
2574
2452
|
return argName || "skill";
|
|
2575
2453
|
}
|
|
2454
|
+
function formatTodoListForCli(event, colorEnabled) {
|
|
2455
|
+
if (event.type !== "tool-result" || event.toolName !== "setTodoList") {
|
|
2456
|
+
return void 0;
|
|
2457
|
+
}
|
|
2458
|
+
let raw = event.metadata?.displayData;
|
|
2459
|
+
let parsed = typeof raw === "object" && raw !== null;
|
|
2460
|
+
if (typeof raw === "string") {
|
|
2461
|
+
try {
|
|
2462
|
+
raw = JSON.parse(raw);
|
|
2463
|
+
parsed = true;
|
|
2464
|
+
} catch {
|
|
2465
|
+
raw = void 0;
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
if (!parsed && typeof event.content === "string") {
|
|
2469
|
+
try {
|
|
2470
|
+
raw = JSON.parse(event.content);
|
|
2471
|
+
parsed = true;
|
|
2472
|
+
} catch {
|
|
2473
|
+
raw = void 0;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
const todos = Array.isArray(raw?.todos) ? raw.todos : void 0;
|
|
2477
|
+
if (!todos) return void 0;
|
|
2478
|
+
if (todos.length === 0) return "\u2611 Todo\n (empty)\n";
|
|
2479
|
+
const lines = todos.map((todo) => {
|
|
2480
|
+
const status = todo?.status === "done" ? "\u2713" : todo?.status === "in_progress" ? "\u25D0" : "\u25CB";
|
|
2481
|
+
const title = typeof todo?.title === "string" ? todo.title : "Untitled task";
|
|
2482
|
+
return ` ${status} ${title}`;
|
|
2483
|
+
});
|
|
2484
|
+
const text = [`\u2611 Todo (${todos.length})`, ...lines].join("\n") + "\n";
|
|
2485
|
+
return colorEnabled ? themeText(text, "chrome") : text;
|
|
2486
|
+
}
|
|
2576
2487
|
function formatCompactToolLine(event, pending, colorEnabled) {
|
|
2577
2488
|
const toolName = event.toolName || pending?.toolName || "tool";
|
|
2489
|
+
const todoBlock = formatTodoListForCli(event, colorEnabled);
|
|
2490
|
+
if (todoBlock) return todoBlock;
|
|
2578
2491
|
if (isReadToolName(toolName) && event.type === "tool-result") {
|
|
2579
2492
|
const rawPath = (typeof event.metadata?.path === "string" ? event.metadata.path : void 0) || (typeof event.metadata?.filePath === "string" ? event.metadata.filePath : void 0) || event.argumentsPreview || pending?.argumentsPreview || "";
|
|
2580
2493
|
return formatReadTreeBlockForCli([{ path: rawPath, metadata: event.metadata }], colorEnabled);
|
|
@@ -2656,7 +2569,8 @@ function formatEditDetailBlock(lines, colorEnabled) {
|
|
|
2656
2569
|
return lines.map((line) => ` ${renderDiffLine({ kind: line.kind, text: line.text, padTo, colorEnabled: true })}
|
|
2657
2570
|
`).join("");
|
|
2658
2571
|
}
|
|
2659
|
-
function createToolEventFormatter(mode, colorEnabled = resolveCliColorEnabled()) {
|
|
2572
|
+
function createToolEventFormatter(mode, colorEnabled = resolveCliColorEnabled(), opts = {}) {
|
|
2573
|
+
const suppressRunProgressCards = opts.suppressRunProgressCards === true;
|
|
2660
2574
|
const pending = /* @__PURE__ */ new Map();
|
|
2661
2575
|
let readBuffer = [];
|
|
2662
2576
|
let searchBuffer = [];
|
|
@@ -2680,9 +2594,16 @@ function createToolEventFormatter(mode, colorEnabled = resolveCliColorEnabled())
|
|
|
2680
2594
|
statusFold = null;
|
|
2681
2595
|
const substance = cardSubstance(fold);
|
|
2682
2596
|
if (lastPrintedCardByRunId.get(fold.runId) === substance) return "";
|
|
2683
|
-
lastPrintedCardByRunId.set(fold.runId, substance);
|
|
2684
2597
|
const prevLog = lastEmittedLogByRunId.get(fold.runId);
|
|
2685
2598
|
const changed = Boolean(fold.logKey) && fold.logKey !== prevLog;
|
|
2599
|
+
if (suppressRunProgressCards) {
|
|
2600
|
+
const terminal = isAgentRunTerminalStatus(fold.status);
|
|
2601
|
+
if (!terminal && !fold.errorMessage && !changed) {
|
|
2602
|
+
lastPrintedCardByRunId.set(fold.runId, substance);
|
|
2603
|
+
return "";
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
lastPrintedCardByRunId.set(fold.runId, substance);
|
|
2686
2607
|
if (changed && runShowsLogTail(fold.status)) {
|
|
2687
2608
|
lastEmittedLogByRunId.set(fold.runId, fold.logKey);
|
|
2688
2609
|
}
|
|
@@ -3060,7 +2981,9 @@ function createCliTurnOutput(params) {
|
|
|
3060
2981
|
const spinner = params.spinner ?? new Spinner(options.output, workingLabel, Boolean(options.activityReporter));
|
|
3061
2982
|
const toolDisplayMode = resolveToolDisplayMode(options.env);
|
|
3062
2983
|
const traceLocalTools = shouldEmitToolEvents(toolDisplayMode);
|
|
3063
|
-
const formatToolEvent = createToolEventFormatter(toolDisplayMode
|
|
2984
|
+
const formatToolEvent = createToolEventFormatter(toolDisplayMode, void 0, {
|
|
2985
|
+
suppressRunProgressCards: typeof options.onAgentRunStatus === "function"
|
|
2986
|
+
});
|
|
3064
2987
|
const eventMode = resolveAgentEventMode(options);
|
|
3065
2988
|
let streamedAssistantText = false;
|
|
3066
2989
|
let everStreamedAnyText = false;
|
|
@@ -3557,7 +3480,7 @@ function findCollapsedPasteSpanAt(buffer, pos, opts = {}) {
|
|
|
3557
3480
|
// packages/cli/client/agentRun.ts
|
|
3558
3481
|
import { ulid } from "ulid";
|
|
3559
3482
|
async function loadRunLocalAgentTurn() {
|
|
3560
|
-
const { runLocalAgentTurn } = await import("./agentRuntimeLocal-
|
|
3483
|
+
const { runLocalAgentTurn } = await import("./agentRuntimeLocal-GVNERRKQ.js");
|
|
3561
3484
|
return runLocalAgentTurn;
|
|
3562
3485
|
}
|
|
3563
3486
|
async function resolveCurrentMachineId(options) {
|
|
@@ -3996,55 +3919,7 @@ async function runLocalAgentTurnForCli(options, settings) {
|
|
|
3996
3919
|
...options.parentDialogId ? { parentThreadId: options.parentDialogId } : {}
|
|
3997
3920
|
} : void 0;
|
|
3998
3921
|
const currentDialogId = options.continueDialogId ?? ulid();
|
|
3999
|
-
const
|
|
4000
|
-
const { runLocalAgentTurn } = await import("./agentRuntimeLocal-7WYWCGL4.js");
|
|
4001
|
-
return runLocalAgentTurn(input);
|
|
4002
|
-
};
|
|
4003
|
-
const createFreshChildBaseAdapter = () => {
|
|
4004
|
-
const fresh = options.localRuntimeAdapterFactory?.(options.env, {
|
|
4005
|
-
cwd: options.localRuntimeCwd
|
|
4006
|
-
}) ?? buildDefaultLocalRuntimeAdapter(options);
|
|
4007
|
-
return applyEphemeralIfRequested(options, fresh);
|
|
4008
|
-
};
|
|
4009
|
-
const withLocalDelegation = (args) => {
|
|
4010
|
-
let adapter2;
|
|
4011
|
-
const callAgentExecutor = createCliCallAgentToolExecutor(
|
|
4012
|
-
{
|
|
4013
|
-
env: options.env,
|
|
4014
|
-
fetchImpl: options.fetchImpl,
|
|
4015
|
-
cwd: options.localRuntimeCwd,
|
|
4016
|
-
output: options.output
|
|
4017
|
-
},
|
|
4018
|
-
{
|
|
4019
|
-
createChildAdapter: (child) => withLocalDelegation({
|
|
4020
|
-
base: createFreshChildBaseAdapter(),
|
|
4021
|
-
dialogId: child.dialogId,
|
|
4022
|
-
spaceId: child.spaceId,
|
|
4023
|
-
runtimeContext: child.runtimeContext
|
|
4024
|
-
}),
|
|
4025
|
-
runChildTurn,
|
|
4026
|
-
dialogId: args.dialogId,
|
|
4027
|
-
spaceId: args.spaceId,
|
|
4028
|
-
runtimeContext: args.runtimeContext
|
|
4029
|
-
}
|
|
4030
|
-
);
|
|
4031
|
-
adapter2 = {
|
|
4032
|
-
...args.base,
|
|
4033
|
-
executeTool: async (call) => {
|
|
4034
|
-
if (call.name === "callAgent") {
|
|
4035
|
-
return callAgentExecutor(call);
|
|
4036
|
-
}
|
|
4037
|
-
return args.base.executeTool(call);
|
|
4038
|
-
}
|
|
4039
|
-
};
|
|
4040
|
-
return adapter2;
|
|
4041
|
-
};
|
|
4042
|
-
const adapter = withLocalDelegation({
|
|
4043
|
-
base: baseAdapter,
|
|
4044
|
-
dialogId: currentDialogId,
|
|
4045
|
-
spaceId: options.spaceId,
|
|
4046
|
-
runtimeContext
|
|
4047
|
-
});
|
|
3922
|
+
const adapter = baseAdapter;
|
|
4048
3923
|
const expandedMessage = options.pastedTextStore?.items.size ? expandCollapsedPastes(options.message, options.pastedTextStore) : options.message;
|
|
4049
3924
|
const workingLabel = `${options.agentName} -> working locally`;
|
|
4050
3925
|
const turnOutput = createCliTurnOutput({
|
|
@@ -4795,6 +4670,40 @@ var resolveMemoryRuntime = async (input) => {
|
|
|
4795
4670
|
};
|
|
4796
4671
|
};
|
|
4797
4672
|
|
|
4673
|
+
// packages/ai/tools/agent/quotaCircuitBreaker.ts
|
|
4674
|
+
var QUOTA_ERROR_PATTERNS = [
|
|
4675
|
+
/429/,
|
|
4676
|
+
/quota/i,
|
|
4677
|
+
/rate\s*limit/i,
|
|
4678
|
+
/too\s*many\s*requests/i,
|
|
4679
|
+
/额度/,
|
|
4680
|
+
/上限/,
|
|
4681
|
+
/用尽/,
|
|
4682
|
+
/CliProviderQuotaError/i
|
|
4683
|
+
];
|
|
4684
|
+
function isCliProviderQuotaErrorShape(error) {
|
|
4685
|
+
if (!error || typeof error !== "object") return false;
|
|
4686
|
+
const e = error;
|
|
4687
|
+
return e.name === "CliProviderQuotaError" || typeof e.message === "string" && e.message.startsWith("[QUOTA_LIMITED:");
|
|
4688
|
+
}
|
|
4689
|
+
function isQuotaExhaustedError(error) {
|
|
4690
|
+
if (!error) return false;
|
|
4691
|
+
if (isCliProviderQuotaErrorShape(error)) return true;
|
|
4692
|
+
if (error instanceof Error) {
|
|
4693
|
+
return QUOTA_ERROR_PATTERNS.some((pattern) => pattern.test(error.message));
|
|
4694
|
+
}
|
|
4695
|
+
if (typeof error === "string") {
|
|
4696
|
+
return QUOTA_ERROR_PATTERNS.some((pattern) => pattern.test(error));
|
|
4697
|
+
}
|
|
4698
|
+
const maybeStatus = error.status;
|
|
4699
|
+
if (typeof maybeStatus === "number" && maybeStatus === 429) return true;
|
|
4700
|
+
const maybeStatusCode = error.statusCode;
|
|
4701
|
+
if (typeof maybeStatusCode === "number" && maybeStatusCode === 429) return true;
|
|
4702
|
+
return false;
|
|
4703
|
+
}
|
|
4704
|
+
var DEFAULT_QUOTA_BREAKER_MS = 6 * 3600 * 1e3;
|
|
4705
|
+
var DEFAULT_AGENT_NOT_FOUND_BREAKER_MS = 15 * 60 * 1e3;
|
|
4706
|
+
|
|
4798
4707
|
// packages/cli/agentRunCommand.ts
|
|
4799
4708
|
function resolvePositiveMs(value, fallback) {
|
|
4800
4709
|
return parsePositiveFiniteNumberOrFallback(value, fallback);
|
|
@@ -4918,7 +4827,7 @@ async function runAgentRunCommand(args, deps) {
|
|
|
4918
4827
|
if (wantsFallbackSuggestions) {
|
|
4919
4828
|
effectiveMessage = `${parsed.message}
|
|
4920
4829
|
|
|
4921
|
-
[Quota fallback context for agent decision: If this execution for ${parsed.agentKey} hits subscription quota, YOU (the agent) must decide the next agent to use. Do not rely on automatic wrapper. Reason based on the specific task (complexity, length, domain), agent strengths, cost, previous attempt results. Suggested alternatives: ${parsed.fallbackAgentKeys.join(", ")}. Update the task row with attempt history and dispatch the chosen next (via
|
|
4830
|
+
[Quota fallback context for agent decision: If this execution for ${parsed.agentKey} hits subscription quota, YOU (the agent) must decide the next agent to use. Do not rely on automatic wrapper. Reason based on the specific task (complexity, length, domain), agent strengths, cost, previous attempt results. Suggested alternatives: ${parsed.fallbackAgentKeys.join(", ")}. Update the task row with attempt history and dispatch the chosen next (via startAgentRun \u5F02\u6B65\u6D3E\u53D1)).]`;
|
|
4922
4831
|
}
|
|
4923
4832
|
const resolvedAgentKey = parsed.runtimeMode !== "local" ? await (deps.resolveAgentRunAgentKey ?? resolveAgentRunAgentKey)({
|
|
4924
4833
|
agentInput: resolveRawAgentInput(args, deps.commandPath) ?? parsed.agentKey,
|
|
@@ -4936,7 +4845,9 @@ async function runAgentRunCommand(args, deps) {
|
|
|
4936
4845
|
const hasExplicitAgent = Boolean(readFlagValue(args, "--agent"));
|
|
4937
4846
|
const route = await classifyCliAutoRoute(effectiveMessage, {
|
|
4938
4847
|
serverUrl,
|
|
4939
|
-
authToken
|
|
4848
|
+
authToken,
|
|
4849
|
+
// 有图 → kimi vision 档;无图 → flash 档。漏传会永远走 flash。
|
|
4850
|
+
hasImages: parsed.imageUrls.length > 0
|
|
4940
4851
|
});
|
|
4941
4852
|
if (hasExplicitAgent) {
|
|
4942
4853
|
modelOverride = buildModelLayerOverride(
|
|
@@ -5054,92 +4965,99 @@ async function runAgentRunCommand(args, deps) {
|
|
|
5054
4965
|
return 0;
|
|
5055
4966
|
}
|
|
5056
4967
|
const cliCwd = parsed.cwd ?? process.cwd();
|
|
4968
|
+
const isSubtask = isSubtaskRun(env);
|
|
5057
4969
|
const extraContextBlocks = [];
|
|
5058
|
-
const
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
4970
|
+
const contextBlockScopes = [];
|
|
4971
|
+
let memoryPromptBlock = null;
|
|
4972
|
+
let memoryOverlayLayer = null;
|
|
4973
|
+
let memoryUseGuidanceLayer = null;
|
|
4974
|
+
if (!isSubtask) {
|
|
4975
|
+
const AGENTS_MD_MAX = 8192;
|
|
4976
|
+
for (const name of ["AGENTS.md", "CLAUDE.md"]) {
|
|
4977
|
+
const agentsMdPath = join2(cliCwd, name);
|
|
4978
|
+
if (existsSync2(agentsMdPath)) {
|
|
4979
|
+
try {
|
|
4980
|
+
let mdContent = readFileSync2(agentsMdPath, "utf8").trim();
|
|
4981
|
+
if (!mdContent) continue;
|
|
4982
|
+
if (Buffer.byteLength(mdContent, "utf8") > AGENTS_MD_MAX) {
|
|
4983
|
+
mdContent = Buffer.from(mdContent, "utf8").subarray(0, AGENTS_MD_MAX).toString("utf8") + "\n\n<!-- AGENTS.md truncated -->";
|
|
4984
|
+
}
|
|
4985
|
+
extraContextBlocks.push(`--- \u9879\u76EE\u6307\u4EE4\uFF08${name}\uFF09---
|
|
5069
4986
|
${mdContent}`);
|
|
5070
|
-
|
|
5071
|
-
|
|
4987
|
+
break;
|
|
4988
|
+
} catch {
|
|
4989
|
+
}
|
|
5072
4990
|
}
|
|
5073
4991
|
}
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
4992
|
+
extraContextBlocks.push(...buildSkillContextBlocks(skillReferences));
|
|
4993
|
+
const skillDiscoveryBlock = buildSkillDiscoveryContextBlock(cliCwd);
|
|
4994
|
+
if (skillDiscoveryBlock) {
|
|
4995
|
+
extraContextBlocks.push(skillDiscoveryBlock);
|
|
4996
|
+
}
|
|
4997
|
+
if (!deps.memoryRecallDisabled) {
|
|
4998
|
+
const memoryServerUrl = resolveServerUrl(env);
|
|
4999
|
+
const memoryAuthToken = resolveAuthToken(args, env);
|
|
5000
|
+
const memoryAgentKey = effectiveAgentKey;
|
|
5001
|
+
const memorySpaceId = parsed.spaceId ?? void 0;
|
|
5002
|
+
try {
|
|
5003
|
+
const resolvedRuntimeMode = parsed.runtimeMode ?? (env.NOLO_RUNTIME_MODE === "local" || env.NOLO_RUNTIME_MODE === "server" || env.NOLO_RUNTIME_MODE === "auto" ? env.NOLO_RUNTIME_MODE : "auto");
|
|
5004
|
+
const usesExplicitServerRuntime = resolvedRuntimeMode === "server";
|
|
5005
|
+
if (usesExplicitServerRuntime && memoryAuthToken && memoryServerUrl) {
|
|
5006
|
+
const memoryResponse = await fetch(`${memoryServerUrl}/api/memory/query`, {
|
|
5007
|
+
method: "POST",
|
|
5008
|
+
headers: {
|
|
5009
|
+
"Content-Type": "application/json",
|
|
5010
|
+
Authorization: `Bearer ${memoryAuthToken}`
|
|
5011
|
+
},
|
|
5012
|
+
body: JSON.stringify({
|
|
5013
|
+
agentKey: memoryAgentKey,
|
|
5014
|
+
userInput: effectiveMessage,
|
|
5015
|
+
...memorySpaceId ? { spaceId: memorySpaceId } : {}
|
|
5016
|
+
}),
|
|
5017
|
+
signal: AbortSignal.timeout(5e3)
|
|
5018
|
+
});
|
|
5019
|
+
if (memoryResponse.ok) {
|
|
5020
|
+
const memoryPayload = await memoryResponse.json().catch(() => null);
|
|
5021
|
+
const block = typeof memoryPayload?.promptBlock === "string" ? memoryPayload.promptBlock.trim() : "";
|
|
5022
|
+
memoryPromptBlock = block || null;
|
|
5023
|
+
} else {
|
|
5024
|
+
console.warn("[cli-memory] memory query returned non-ok status:", memoryResponse.status);
|
|
5025
|
+
}
|
|
5026
|
+
} else {
|
|
5027
|
+
const localDb = await getDefaultCliLocalRuntimeDb({ env });
|
|
5028
|
+
const machineId = resolveMachineId();
|
|
5029
|
+
const resolution = await resolveMemoryRuntime({
|
|
5030
|
+
db: localDb,
|
|
5031
|
+
userId: machineId,
|
|
5095
5032
|
agentKey: memoryAgentKey,
|
|
5096
5033
|
userInput: effectiveMessage,
|
|
5097
5034
|
...memorySpaceId ? { spaceId: memorySpaceId } : {}
|
|
5098
|
-
})
|
|
5099
|
-
|
|
5100
|
-
});
|
|
5101
|
-
if (memoryResponse.ok) {
|
|
5102
|
-
const memoryPayload = await memoryResponse.json().catch(() => null);
|
|
5103
|
-
const block = typeof memoryPayload?.promptBlock === "string" ? memoryPayload.promptBlock.trim() : "";
|
|
5104
|
-
memoryPromptBlock = block || null;
|
|
5105
|
-
} else {
|
|
5106
|
-
console.warn("[cli-memory] memory query returned non-ok status:", memoryResponse.status);
|
|
5035
|
+
});
|
|
5036
|
+
memoryPromptBlock = resolution.promptBlock;
|
|
5107
5037
|
}
|
|
5108
|
-
}
|
|
5109
|
-
|
|
5110
|
-
const machineId = resolveMachineId();
|
|
5111
|
-
const resolution = await resolveMemoryRuntime({
|
|
5112
|
-
db: localDb,
|
|
5113
|
-
userId: machineId,
|
|
5114
|
-
agentKey: memoryAgentKey,
|
|
5115
|
-
userInput: effectiveMessage,
|
|
5116
|
-
...memorySpaceId ? { spaceId: memorySpaceId } : {}
|
|
5117
|
-
});
|
|
5118
|
-
memoryPromptBlock = resolution.promptBlock;
|
|
5038
|
+
} catch (memoryError) {
|
|
5039
|
+
console.warn("[cli-memory] memory recall failed, omitting memory layer:", memoryError);
|
|
5119
5040
|
}
|
|
5120
|
-
} catch (memoryError) {
|
|
5121
|
-
console.warn("[cli-memory] memory recall failed, omitting memory layer:", memoryError);
|
|
5122
5041
|
}
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
contextBlockScopes.push({ content: block, cacheScope: "session" });
|
|
5042
|
+
memoryOverlayLayer = buildMemoryOverlayLayer({ promptBlock: memoryPromptBlock });
|
|
5043
|
+
memoryUseGuidanceLayer = buildMemoryUseGuidanceLayer({ promptBlock: memoryPromptBlock });
|
|
5044
|
+
const agentsMdMarker = "--- \u9879\u76EE\u6307\u4EE4\uFF08";
|
|
5045
|
+
for (const block of extraContextBlocks) {
|
|
5046
|
+
if (block.startsWith(agentsMdMarker)) {
|
|
5047
|
+
contextBlockScopes.push({ content: block, cacheScope: "session" });
|
|
5048
|
+
}
|
|
5131
5049
|
}
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5050
|
+
if (memoryUseGuidanceLayer?.content?.trim()) {
|
|
5051
|
+
contextBlockScopes.push({ content: memoryUseGuidanceLayer.content, cacheScope: "session" });
|
|
5052
|
+
}
|
|
5053
|
+
for (const block of extraContextBlocks) {
|
|
5054
|
+
if (!block.startsWith(agentsMdMarker)) {
|
|
5055
|
+
contextBlockScopes.push({ content: block, cacheScope: "turn" });
|
|
5056
|
+
}
|
|
5057
|
+
}
|
|
5058
|
+
if (memoryOverlayLayer?.content?.trim()) {
|
|
5059
|
+
contextBlockScopes.push({ content: memoryOverlayLayer.content, cacheScope: "turn" });
|
|
5139
5060
|
}
|
|
5140
|
-
}
|
|
5141
|
-
if (memoryOverlayLayer?.content?.trim()) {
|
|
5142
|
-
contextBlockScopes.push({ content: memoryOverlayLayer.content, cacheScope: "turn" });
|
|
5143
5061
|
}
|
|
5144
5062
|
const buildRunOptions = (targetAgentKey) => ({
|
|
5145
5063
|
agentName: targetAgentKey,
|
|
@@ -5287,10 +5205,8 @@ function isBalanceExhaustedError(error) {
|
|
|
5287
5205
|
}
|
|
5288
5206
|
|
|
5289
5207
|
export {
|
|
5290
|
-
CLI_AUTO_TIER_AGENT_KEYS,
|
|
5291
5208
|
CLI_IMAGE_AGENT_KEY,
|
|
5292
5209
|
CLI_AUTO_TIER_AGENT_KEY_TABLE,
|
|
5293
|
-
resolveCliAutoFallbackTier,
|
|
5294
5210
|
classifyCliAutoRoute,
|
|
5295
5211
|
resolveAgentContextWindow,
|
|
5296
5212
|
formatTokenCount,
|
|
@@ -5321,7 +5237,9 @@ export {
|
|
|
5321
5237
|
resolveTuiBrightness,
|
|
5322
5238
|
setActiveTerminalBaseHex,
|
|
5323
5239
|
applyDetectedBackground,
|
|
5240
|
+
renderSurfaceLine,
|
|
5324
5241
|
surfaceBackgroundSequence,
|
|
5242
|
+
userSurfaceBackgroundSequence,
|
|
5325
5243
|
themeColorSequence,
|
|
5326
5244
|
themeText,
|
|
5327
5245
|
formatAssistantDisplay,
|
|
@@ -5343,6 +5261,8 @@ export {
|
|
|
5343
5261
|
prependSubjectDialogMarker,
|
|
5344
5262
|
normalizeCliImageInput,
|
|
5345
5263
|
inspectLocalRunWorkspace,
|
|
5264
|
+
QUOTA_ERROR_PATTERNS,
|
|
5265
|
+
isQuotaExhaustedError,
|
|
5346
5266
|
runAgentRunCommand,
|
|
5347
5267
|
isBalanceExhaustedError
|
|
5348
5268
|
};
|