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
|
@@ -3,9 +3,10 @@ import {
|
|
|
3
3
|
extractThinkContent,
|
|
4
4
|
flushThinkParser,
|
|
5
5
|
flushToolCallTextParserIntoCallback,
|
|
6
|
+
longestTagPrefixLength,
|
|
6
7
|
processContentChunkWithToolCallStripping,
|
|
7
8
|
processThinkChunk
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-N7J63Q6C.js";
|
|
9
10
|
import {
|
|
10
11
|
convertMessagesToResponsesInput,
|
|
11
12
|
extractTextFromResponseOutput,
|
|
@@ -14,7 +15,7 @@ import {
|
|
|
14
15
|
shouldStripReasoningContentForOutbound,
|
|
15
16
|
toOpenAiCompatibleMessages,
|
|
16
17
|
toResponsesTools
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-D34RI6NI.js";
|
|
18
19
|
import {
|
|
19
20
|
buildProviderExecutionPlan,
|
|
20
21
|
canUsePlatformChatProvider,
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
resolvePlatformAuthToken,
|
|
24
25
|
resolvePlatformServerUrl,
|
|
25
26
|
resolveProviderTransportDecision
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-PXPISYEH.js";
|
|
27
28
|
import {
|
|
28
29
|
clipCompactText
|
|
29
30
|
} from "./chunk-5MMAK75Q.js";
|
|
@@ -59,6 +60,90 @@ function providerHttpFailure(args) {
|
|
|
59
60
|
);
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
// packages/agent-runtime/deepseekDsmlParser.ts
|
|
64
|
+
var DSML_OPEN = "<\uFF5C\uFF5CDSML\uFF5C\uFF5Ctool_calls>";
|
|
65
|
+
var DSML_CLOSE = "</\uFF5C\uFF5CDSML\uFF5C\uFF5Ctool_calls>";
|
|
66
|
+
var DSML_INVOKE_RE = /<||DSML||invoke\s+name="([^"]+)">([\s\S]*?)<\/||DSML||invoke>/g;
|
|
67
|
+
var DSML_PARAMETER_RE = /<||DSML||parameter\s+([^>]+)>([\s\S]*?)<\/||DSML||parameter>/g;
|
|
68
|
+
function createDsmlParserState() {
|
|
69
|
+
return { mode: "content", buffer: "" };
|
|
70
|
+
}
|
|
71
|
+
function parseAttributes(raw) {
|
|
72
|
+
return {
|
|
73
|
+
name: raw.match(/(?:^|\s)name="([^"]+)"/)?.[1],
|
|
74
|
+
stringFlag: raw.match(/(?:^|\s)string="(true|false)"/)?.[1]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function decode(value) {
|
|
78
|
+
return value.replace(/"/g, '"').replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
79
|
+
}
|
|
80
|
+
function parseValue(value) {
|
|
81
|
+
try {
|
|
82
|
+
return JSON.parse(value);
|
|
83
|
+
} catch {
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function parseCalls(text) {
|
|
88
|
+
const calls = [];
|
|
89
|
+
for (const match of text.matchAll(DSML_INVOKE_RE)) {
|
|
90
|
+
const args = {};
|
|
91
|
+
for (const parameter of match[2].matchAll(DSML_PARAMETER_RE)) {
|
|
92
|
+
const attrs = parseAttributes(parameter[1]);
|
|
93
|
+
if (!attrs.name) continue;
|
|
94
|
+
const value = decode(parameter[2]);
|
|
95
|
+
args[attrs.name] = attrs.stringFlag === "true" ? value : attrs.stringFlag === "false" ? parseValue(value) : value;
|
|
96
|
+
}
|
|
97
|
+
const name = match[1];
|
|
98
|
+
if (name === "readFile" && args.path === void 0 && args.file !== void 0) {
|
|
99
|
+
args.path = args.file;
|
|
100
|
+
delete args.file;
|
|
101
|
+
}
|
|
102
|
+
calls.push({ name, arguments: JSON.stringify(args) });
|
|
103
|
+
}
|
|
104
|
+
return calls;
|
|
105
|
+
}
|
|
106
|
+
function pushDsmlChunk(chunk, state) {
|
|
107
|
+
state.buffer += chunk;
|
|
108
|
+
let content = "";
|
|
109
|
+
const toolCalls = [];
|
|
110
|
+
while (true) {
|
|
111
|
+
if (state.mode === "content") {
|
|
112
|
+
const index = state.buffer.indexOf(DSML_OPEN);
|
|
113
|
+
if (index < 0) {
|
|
114
|
+
const keep = longestTagPrefixLength(state.buffer, DSML_OPEN);
|
|
115
|
+
content += state.buffer.slice(0, state.buffer.length - keep);
|
|
116
|
+
state.buffer = state.buffer.slice(state.buffer.length - keep);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
content += state.buffer.slice(0, index);
|
|
120
|
+
state.buffer = state.buffer.slice(index + DSML_OPEN.length);
|
|
121
|
+
state.mode = "dsml";
|
|
122
|
+
} else {
|
|
123
|
+
const index = state.buffer.indexOf(DSML_CLOSE);
|
|
124
|
+
if (index < 0) break;
|
|
125
|
+
toolCalls.push(...parseCalls(state.buffer.slice(0, index)));
|
|
126
|
+
state.buffer = state.buffer.slice(index + DSML_CLOSE.length);
|
|
127
|
+
state.mode = "content";
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return { content, toolCalls };
|
|
131
|
+
}
|
|
132
|
+
function finishDsml(state) {
|
|
133
|
+
const result = { content: "", toolCalls: [] };
|
|
134
|
+
if (state.mode === "dsml") result.toolCalls.push(...parseCalls(state.buffer));
|
|
135
|
+
else result.content = state.buffer;
|
|
136
|
+
state.mode = "content";
|
|
137
|
+
state.buffer = "";
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
function parseDsml(text) {
|
|
141
|
+
const state = createDsmlParserState();
|
|
142
|
+
const chunk = pushDsmlChunk(text, state);
|
|
143
|
+
const tail = finishDsml(state);
|
|
144
|
+
return { content: chunk.content + tail.content, toolCalls: [...chunk.toolCalls, ...tail.toolCalls] };
|
|
145
|
+
}
|
|
146
|
+
|
|
62
147
|
// packages/agent-runtime/processChatCompletionDelta.ts
|
|
63
148
|
function extractChatCompletionStreamError(parsed) {
|
|
64
149
|
const raw = parsed?.error;
|
|
@@ -204,6 +289,9 @@ function shouldDisableThinking(providerConfig) {
|
|
|
204
289
|
function isResponsesEndpoint(endpoint) {
|
|
205
290
|
return /\/responses$/i.test(endpoint.trim());
|
|
206
291
|
}
|
|
292
|
+
function buildDsmlToolCallId(baseCount, index) {
|
|
293
|
+
return `dsml-${baseCount + index + 1}`;
|
|
294
|
+
}
|
|
207
295
|
function toResponsesRequestOptions(options) {
|
|
208
296
|
const next = { ...options };
|
|
209
297
|
const reasoningEffort = next.reasoning_effort;
|
|
@@ -266,9 +354,7 @@ function buildPlatformChatCompletionRequest(args) {
|
|
|
266
354
|
const body = {
|
|
267
355
|
model: args.providerConfig.model,
|
|
268
356
|
...usesResponsesApi ? {
|
|
269
|
-
input: convertMessagesToResponsesInput(args.messages
|
|
270
|
-
stripReasoningContent: shouldStripReasoning
|
|
271
|
-
})
|
|
357
|
+
input: convertMessagesToResponsesInput(args.messages)
|
|
272
358
|
} : {
|
|
273
359
|
messages: toOpenAiCompatibleMessages(args.messages, {
|
|
274
360
|
stripReasoningContent: shouldStripReasoning
|
|
@@ -353,13 +439,19 @@ function parsePlatformChatCompletionData(raw) {
|
|
|
353
439
|
}
|
|
354
440
|
function parsePlatformChatCompletionResponse(args) {
|
|
355
441
|
if (isResponsesEndpoint(args.providerConfig.endpoint)) {
|
|
356
|
-
const
|
|
442
|
+
const rawContent2 = extractTextFromResponseOutput(args.data);
|
|
443
|
+
const dsml = parseDsml(rawContent2);
|
|
357
444
|
const tool_calls = extractToolCallsFromResponseOutput(args.data);
|
|
445
|
+
const normalizedToolCalls = tool_calls.length > 0 ? tool_calls : dsml.toolCalls.map((call, index) => ({
|
|
446
|
+
id: buildDsmlToolCallId(tool_calls.length, index),
|
|
447
|
+
type: "function",
|
|
448
|
+
function: { name: call.name, arguments: call.arguments }
|
|
449
|
+
}));
|
|
358
450
|
return {
|
|
359
|
-
content:
|
|
451
|
+
content: dsml.content,
|
|
360
452
|
model: args.providerConfig.model,
|
|
361
453
|
provider: args.providerConfig.provider,
|
|
362
|
-
...
|
|
454
|
+
...normalizedToolCalls.length > 0 ? { tool_calls: normalizedToolCalls } : {},
|
|
363
455
|
stream_complete: true,
|
|
364
456
|
usage: args.data?.usage,
|
|
365
457
|
trace: args.trace
|
|
@@ -2755,6 +2755,8 @@ var createTokenKey = {
|
|
|
2755
2755
|
record: (0, import_rambda.curry)(
|
|
2756
2756
|
(userId, timestamp) => createKey("token", userId, timestamp.toString())
|
|
2757
2757
|
),
|
|
2758
|
+
/** Server provider-call record: retry-stable even when the retry clock changes. */
|
|
2759
|
+
recordForStableCall: (userId, callId) => createKey("token", userId, "call", encodeURIComponent(callId)),
|
|
2758
2760
|
range: (userId, timestamp) => ({
|
|
2759
2761
|
start: createKey("token", userId, timestamp.toString()),
|
|
2760
2762
|
end: createKey("token", userId, (timestamp + 864e5).toString())
|
|
@@ -3,30 +3,31 @@ import {
|
|
|
3
3
|
buildCurrentTimeBlock,
|
|
4
4
|
buildIdentityBlock,
|
|
5
5
|
buildRuntimeGuidanceBlocks
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZUXIXYJI.js";
|
|
7
7
|
import {
|
|
8
8
|
estimateTokenCount,
|
|
9
9
|
getModelContextWindow,
|
|
10
10
|
planCompression,
|
|
11
11
|
planContextUsage,
|
|
12
12
|
serializeMessageContent
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-PY7VGC5M.js";
|
|
14
14
|
import {
|
|
15
15
|
clipCompactText
|
|
16
16
|
} from "./chunk-5MMAK75Q.js";
|
|
17
17
|
import {
|
|
18
18
|
findModelConfig,
|
|
19
19
|
getProviderByModelName
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import {
|
|
22
|
-
toErrorMessage
|
|
23
|
-
} from "./chunk-HNMXYYJR.js";
|
|
20
|
+
} from "./chunk-LEHTC2FI.js";
|
|
24
21
|
import {
|
|
25
22
|
buildDialogSummaryLayer
|
|
26
23
|
} from "./chunk-AL2V7U3E.js";
|
|
27
24
|
import {
|
|
25
|
+
canonicalizeToolName,
|
|
28
26
|
canonicalizeToolNames
|
|
29
27
|
} from "./chunk-ZZ2MH7LE.js";
|
|
28
|
+
import {
|
|
29
|
+
toErrorMessage
|
|
30
|
+
} from "./chunk-HNMXYYJR.js";
|
|
30
31
|
import {
|
|
31
32
|
asRecordOrEmpty
|
|
32
33
|
} from "./chunk-KX6YBIHG.js";
|
|
@@ -372,24 +373,81 @@ function clipToolText(content, maxChars, headRatio, marker = "\n\n[... tool outp
|
|
|
372
373
|
// packages/agent-runtime/localAutoCompaction.ts
|
|
373
374
|
var LOCAL_AUTO_COMPACTION_SYSTEM_PROMPT = `\u4F60\u662F\u5BF9\u8BDD\u4E0A\u4E0B\u6587\u538B\u7F29\u5668\u3002\u6839\u636E\u3010\u73B0\u6709\u8BB0\u5FC6\u3011\u548C\u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF0C\u8F93\u51FA\u53EF\u66FF\u4EE3\u539F\u59CB\u6D88\u606F\u7684\u4E8B\u5B9E\u6027\u8981\u70B9\uFF0C\u4F9B\u540E\u7EED\u5BF9\u8BDD\u76F4\u63A5\u4F7F\u7528\u3002
|
|
374
375
|
|
|
375
|
-
\u4E25\u683C\u53EA\u8F93\u51FA\u4E0B\u9762\
|
|
376
|
+
\u4E25\u683C\u53EA\u8F93\u51FA\u4E0B\u9762\u4E09\u90E8\u5206\uFF0C\u6807\u9898\u5FC5\u987B\u5B8C\u5168\u4E00\u81F4\uFF1A
|
|
376
377
|
\u5173\u952E\u4E8B\u5B9E\u6863\u6848
|
|
377
378
|
- ...
|
|
378
379
|
\u5BF9\u8BDD\u8FDB\u5C55\u4E0E\u5F85\u529E
|
|
379
380
|
- ...
|
|
381
|
+
\u6587\u4EF6\u64CD\u4F5C\u6E05\u5355
|
|
382
|
+
- ...
|
|
380
383
|
|
|
381
384
|
\u8981\u6C42\uFF1A
|
|
382
385
|
1) \u4F7F\u7528\u5BF9\u8BDD\u4E3B\u8BED\u8A00\uFF1B\u6DF7\u5408\u8BED\u8A00\u65F6\u4F18\u5148\u7528\u6237\u4E3B\u8981\u8BED\u8A00\uFF1B\u4E13\u6709\u540D\u8BCD\u3001\u6587\u4EF6\u8DEF\u5F84\u3001\u6807\u8BC6\u7B26\u3001\u547D\u4EE4\u4FDD\u7559\u539F\u6587\u3002
|
|
383
386
|
2) \u5173\u952E\u4E8B\u5B9E\u6863\u6848\u53EA\u4FDD\u7559\u4E4B\u540E\u7EE7\u7EED\u5BF9\u8BDD\u4ECD\u6709\u4EF7\u503C\u7684\u4FE1\u606F\uFF1A\u7528\u6237\u76EE\u6807/\u504F\u597D\u3001\u7EA6\u675F\u3001\u6280\u672F\u6808\u3001\u786E\u5B9A\u7684\u6587\u4EF6\u8DEF\u5F84\u3001\u6838\u5FC3\u51B3\u7B56\u3001\u672A\u5B8C\u6210\u5F85\u529E\u3002
|
|
384
387
|
3) \u5BF9\u8BDD\u8FDB\u5C55\u4E0E\u5F85\u529E\uFF1A\u5148\u6781\u7B80\u6982\u62EC\u65E7\u4E0A\u4E0B\u6587\uFF0C\u518D\u66F4\u8BE6\u7EC6\u8BB0\u5F55\u6700\u8FD1\u8FDB\u5C55\u3001\u7ED3\u8BBA\u3001\u5206\u6B67\u4E0E\u4E0B\u4E00\u6B65\u3002
|
|
385
|
-
4) \
|
|
386
|
-
5) \
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
388
|
+
4) \u6587\u4EF6\u64CD\u4F5C\u6E05\u5355\uFF1A\u5217\u51FA\u672C\u6B21\u538B\u7F29\u8303\u56F4\u5185\u8BFB\u53D6\u3001\u5199\u5165\u3001\u7F16\u8F91\u8FC7\u7684\u6587\u4EF6\u8DEF\u5F84\u53CA\u64CD\u4F5C\u7C7B\u578B\uFF08\u5982: - \u8BFB\u53D6: path/to/file\uFF1B\u82E5\u672A\u6D89\u53CA\u6587\u4EF6\u64CD\u4F5C\u5199"\u65E0"\uFF09\u3002
|
|
389
|
+
5) \u5FFD\u7565\u5BD2\u6684\u3001\u91CD\u590D\u5C1D\u8BD5\u3001\u5DF2\u653E\u5F03\u65B9\u6848\u548C\u65E0\u4EF7\u503C\u5E9F\u8BDD\u3002
|
|
390
|
+
6) \u4E0D\u8981\u7F16\u9020\u672A\u51FA\u73B0\u7684\u4FE1\u606F\uFF1B\u4E0D\u8981\u5F00\u573A\u767D\u3001\u7ED3\u675F\u8BED\u3001markdown \u4EE3\u7801\u5757\u6216\u989D\u5916\u7AE0\u8282\uFF1B\u4E0D\u8981\u8C03\u7528\u4EFB\u4F55\u5DE5\u5177\u3002`;
|
|
391
|
+
function extractFileOperations(msgs) {
|
|
392
|
+
const result = [];
|
|
393
|
+
const seen = /* @__PURE__ */ new Set();
|
|
394
|
+
for (const msg of msgs) {
|
|
395
|
+
if (!Array.isArray(msg.tool_calls)) continue;
|
|
396
|
+
for (const call of msg.tool_calls) {
|
|
397
|
+
const name = call.function?.name || call.name || "";
|
|
398
|
+
if (!name) continue;
|
|
399
|
+
const canonicalName = canonicalizeToolName(name);
|
|
400
|
+
const fileOperationByTool = {
|
|
401
|
+
readFile: "read",
|
|
402
|
+
writeFile: "write",
|
|
403
|
+
editFile: "edit"
|
|
404
|
+
};
|
|
405
|
+
const opType = fileOperationByTool[canonicalName];
|
|
406
|
+
if (!opType) continue;
|
|
407
|
+
let rawArgs = call.function?.arguments ?? call.arguments;
|
|
408
|
+
let parsedArgs = null;
|
|
409
|
+
if (typeof rawArgs === "string") {
|
|
410
|
+
try {
|
|
411
|
+
parsedArgs = JSON.parse(rawArgs);
|
|
412
|
+
} catch {
|
|
413
|
+
}
|
|
414
|
+
} else if (typeof rawArgs === "object" && rawArgs !== null) {
|
|
415
|
+
parsedArgs = rawArgs;
|
|
416
|
+
}
|
|
417
|
+
const path = parsedArgs?.path ?? parsedArgs?.filePath ?? parsedArgs?.file;
|
|
418
|
+
if (typeof path === "string" && path.trim()) {
|
|
419
|
+
const key = `${opType}:${path.trim()}`;
|
|
420
|
+
if (!seen.has(key)) {
|
|
421
|
+
seen.add(key);
|
|
422
|
+
result.push({ type: opType, path: path.trim() });
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return result;
|
|
428
|
+
}
|
|
429
|
+
function formatFileOperations(msgs) {
|
|
430
|
+
const ops = extractFileOperations(msgs);
|
|
431
|
+
if (ops.length === 0) {
|
|
432
|
+
return "\u65E0";
|
|
433
|
+
}
|
|
434
|
+
const typeLabelMap = {
|
|
435
|
+
read: "\u8BFB\u53D6",
|
|
436
|
+
write: "\u5199\u5165",
|
|
437
|
+
edit: "\u7F16\u8F91"
|
|
438
|
+
};
|
|
439
|
+
return ops.map((op) => `- ${typeLabelMap[op.type]}: ${op.path}`).join("\n");
|
|
440
|
+
}
|
|
441
|
+
function buildLocalAutoCompactionUserContent(previousSummary, messagesText, fileOpsText) {
|
|
442
|
+
const parts = [`\u3010\u73B0\u6709\u8BB0\u5FC6\u3011\uFF1A
|
|
443
|
+
${previousSummary || "(\u65E0)"}`];
|
|
444
|
+
if (fileOpsText !== void 0) {
|
|
445
|
+
parts.push(`\u3010\u6587\u4EF6\u64CD\u4F5C\u6E05\u5355\u3011\uFF1A
|
|
446
|
+
${fileOpsText || "\u65E0"}`);
|
|
447
|
+
}
|
|
448
|
+
parts.push(`\u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF1A
|
|
449
|
+
${messagesText}`);
|
|
450
|
+
return parts.join("\n\n").trim();
|
|
393
451
|
}
|
|
394
452
|
function toPlanCompressionMessages(history) {
|
|
395
453
|
return history.map((message, index) => {
|
|
@@ -485,12 +543,13 @@ async function maybeAutoCompactLocalHistory(args) {
|
|
|
485
543
|
}
|
|
486
544
|
try {
|
|
487
545
|
const provider = await args.resolveProvider();
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
);
|
|
546
|
+
const msgsToCompress = plan.msgsToCompress;
|
|
547
|
+
const messagesText = formatMessagesForLocalSummary(msgsToCompress);
|
|
548
|
+
const fileOpsText = formatFileOperations(msgsToCompress);
|
|
491
549
|
const promptContent = buildLocalAutoCompactionUserContent(
|
|
492
550
|
existingSummary,
|
|
493
|
-
messagesText
|
|
551
|
+
messagesText,
|
|
552
|
+
fileOpsText
|
|
494
553
|
);
|
|
495
554
|
const result = await provider.complete([
|
|
496
555
|
{ role: "system", content: LOCAL_AUTO_COMPACTION_SYSTEM_PROMPT },
|
|
@@ -1074,7 +1133,7 @@ function mergeTurnUsage(current, next) {
|
|
|
1074
1133
|
const right = read(next);
|
|
1075
1134
|
const left = current ? read(current) : { input: 0, output: 0, cacheHit: 0, cacheMiss: 0 };
|
|
1076
1135
|
return {
|
|
1077
|
-
input_tokens:
|
|
1136
|
+
input_tokens: left.input + right.input,
|
|
1078
1137
|
output_tokens: left.output + right.output,
|
|
1079
1138
|
cache_read_input_tokens: left.cacheHit + right.cacheHit,
|
|
1080
1139
|
cache_creation_input_tokens: left.cacheMiss + right.cacheMiss
|
|
@@ -1120,8 +1179,12 @@ async function persistFailedLocalTurn(args) {
|
|
|
1120
1179
|
model: args.model ?? "unknown",
|
|
1121
1180
|
toolCallCount: args.toolCallCount ?? 0,
|
|
1122
1181
|
error: true,
|
|
1123
|
-
errorMessage
|
|
1182
|
+
errorMessage,
|
|
1183
|
+
...args.usage ? { usage: args.usage } : {}
|
|
1124
1184
|
},
|
|
1185
|
+
...args.accountingUsage ? { accountingUsage: args.accountingUsage } : {},
|
|
1186
|
+
...args.usageRecords?.length ? { usageRecords: args.usageRecords } : {},
|
|
1187
|
+
...args.billingConfig ? { billingConfig: args.billingConfig } : {},
|
|
1125
1188
|
...args.input.runtimeContext ? { runtimeContext: args.input.runtimeContext } : {},
|
|
1126
1189
|
...args.input.continueDialogId ? { continueDialogId: args.input.continueDialogId } : {},
|
|
1127
1190
|
...args.input.spaceId ? { spaceId: args.input.spaceId } : {},
|
|
@@ -1159,6 +1222,18 @@ async function runLocalAgentTurn(input) {
|
|
|
1159
1222
|
error.agentRef = input.agentRef;
|
|
1160
1223
|
throw error;
|
|
1161
1224
|
}
|
|
1225
|
+
const rawBillingConfig = agentConfig.rawRecord ?? {};
|
|
1226
|
+
const billingConfig = {
|
|
1227
|
+
model: agentConfig.model || "unknown",
|
|
1228
|
+
...agentConfig.provider ? { provider: agentConfig.provider } : {},
|
|
1229
|
+
...agentConfig.apiSource ? { apiSource: agentConfig.apiSource } : {},
|
|
1230
|
+
...agentConfig.apiKeyRef !== void 0 ? { apiKeyRef: agentConfig.apiKeyRef } : {},
|
|
1231
|
+
...typeof rawBillingConfig.inputPrice === "number" ? { inputPrice: rawBillingConfig.inputPrice } : {},
|
|
1232
|
+
...typeof rawBillingConfig.outputPrice === "number" ? { outputPrice: rawBillingConfig.outputPrice } : {},
|
|
1233
|
+
...rawBillingConfig.sharingLevel ? { sharingLevel: rawBillingConfig.sharingLevel } : {},
|
|
1234
|
+
id: agentConfig.key,
|
|
1235
|
+
...typeof rawBillingConfig.userId === "string" ? { userId: rawBillingConfig.userId } : {}
|
|
1236
|
+
};
|
|
1162
1237
|
let history = [];
|
|
1163
1238
|
try {
|
|
1164
1239
|
history = input.continueDialogId ? await input.adapter.loadDialogHistory(input.continueDialogId) : [];
|
|
@@ -1250,6 +1325,8 @@ async function runLocalAgentTurn(input) {
|
|
|
1250
1325
|
let toolCallCount = 0;
|
|
1251
1326
|
let result;
|
|
1252
1327
|
let turnUsage;
|
|
1328
|
+
let contextUsage;
|
|
1329
|
+
const usageRecords = [];
|
|
1253
1330
|
let loopError;
|
|
1254
1331
|
let round = 0;
|
|
1255
1332
|
let emptyAssistantRepairPending = false;
|
|
@@ -1306,6 +1383,15 @@ async function runLocalAgentTurn(input) {
|
|
|
1306
1383
|
context: contextMetrics
|
|
1307
1384
|
});
|
|
1308
1385
|
turnUsage = mergeTurnUsage(turnUsage, result.usage);
|
|
1386
|
+
contextUsage = result.usage;
|
|
1387
|
+
if (result.usage && Object.keys(result.usage).length > 0) {
|
|
1388
|
+
usageRecords.push({
|
|
1389
|
+
callId: typeof result.usage.provider_call_id === "string" && result.usage.provider_call_id.trim() ? result.usage.provider_call_id.trim() : crypto.randomUUID(),
|
|
1390
|
+
usage: result.usage,
|
|
1391
|
+
model: result.model || agentConfig.model || "unknown",
|
|
1392
|
+
...result.provider || agentConfig.provider ? { provider: result.provider || agentConfig.provider } : {}
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1309
1395
|
const toolCalls = result.tool_calls ?? [];
|
|
1310
1396
|
const rawToolCallsCount = (result.tool_calls?.length ?? 0) || (Array.isArray(result.raw_tool_calls) ? result.raw_tool_calls.length : 0);
|
|
1311
1397
|
if (toolCalls.length === 0 && rawToolCallsCount === 0) {
|
|
@@ -1463,6 +1549,18 @@ async function runLocalAgentTurn(input) {
|
|
|
1463
1549
|
model: agentConfig.model,
|
|
1464
1550
|
toolCallCount,
|
|
1465
1551
|
partialContent,
|
|
1552
|
+
usage: contextUsage,
|
|
1553
|
+
accountingUsage: addOutOfBandUsage(turnUsage, compactionUsage),
|
|
1554
|
+
usageRecords: [
|
|
1555
|
+
...compactionUsage ? [{
|
|
1556
|
+
callId: typeof compactionUsage.provider_call_id === "string" && compactionUsage.provider_call_id.trim() ? compactionUsage.provider_call_id.trim() : crypto.randomUUID(),
|
|
1557
|
+
usage: compactionUsage,
|
|
1558
|
+
model: agentConfig.model || "unknown",
|
|
1559
|
+
...agentConfig.provider ? { provider: agentConfig.provider } : {}
|
|
1560
|
+
}] : [],
|
|
1561
|
+
...usageRecords
|
|
1562
|
+
],
|
|
1563
|
+
billingConfig,
|
|
1466
1564
|
input
|
|
1467
1565
|
});
|
|
1468
1566
|
attachDialogIdToError(loopError, dialogId);
|
|
@@ -1483,6 +1581,15 @@ async function runLocalAgentTurn(input) {
|
|
|
1483
1581
|
input.persistedInput,
|
|
1484
1582
|
input.persistedInputReference
|
|
1485
1583
|
);
|
|
1584
|
+
if (compactionUsage && Object.keys(compactionUsage).length > 0) {
|
|
1585
|
+
usageRecords.unshift({
|
|
1586
|
+
callId: typeof compactionUsage.provider_call_id === "string" && compactionUsage.provider_call_id.trim() ? compactionUsage.provider_call_id.trim() : crypto.randomUUID(),
|
|
1587
|
+
usage: compactionUsage,
|
|
1588
|
+
model: agentConfig.model || result.model || "unknown",
|
|
1589
|
+
...agentConfig.provider ? { provider: agentConfig.provider } : {}
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
const accountingUsage = addOutOfBandUsage(turnUsage, compactionUsage);
|
|
1486
1593
|
const saved = await input.adapter.saveTurn({
|
|
1487
1594
|
agentKey: agentConfig.key,
|
|
1488
1595
|
messages: turnMessages,
|
|
@@ -1491,6 +1598,9 @@ async function runLocalAgentTurn(input) {
|
|
|
1491
1598
|
...toolCallCount > 0 ? { toolCallCount } : {},
|
|
1492
1599
|
...agentConfig.toolSurface ? { runtimeToolSurface: agentConfig.toolSurface } : {}
|
|
1493
1600
|
},
|
|
1601
|
+
...usageRecords.length > 0 ? { usageRecords } : {},
|
|
1602
|
+
...accountingUsage ? { accountingUsage } : {},
|
|
1603
|
+
billingConfig,
|
|
1494
1604
|
...input.runtimeContext ? { runtimeContext: input.runtimeContext } : {},
|
|
1495
1605
|
...input.continueDialogId ? { continueDialogId: input.continueDialogId } : {},
|
|
1496
1606
|
...input.spaceId ? { spaceId: input.spaceId } : {},
|
|
@@ -1500,10 +1610,8 @@ async function runLocalAgentTurn(input) {
|
|
|
1500
1610
|
});
|
|
1501
1611
|
return {
|
|
1502
1612
|
...result,
|
|
1503
|
-
...
|
|
1504
|
-
|
|
1505
|
-
return merged ? { usage: merged } : {};
|
|
1506
|
-
})(),
|
|
1613
|
+
...usageRecords.length > 0 ? { usageRecords } : {},
|
|
1614
|
+
...accountingUsage ? { accountingUsage } : {},
|
|
1507
1615
|
...toolCallCount > 0 ? { toolCallCount } : {},
|
|
1508
1616
|
...agentConfig.toolSurface ? { runtimeToolSurface: agentConfig.toolSurface } : {},
|
|
1509
1617
|
// 透出最后一轮 provider 调用的 finish_reason;多轮工具循环里只有最后一轮收尾状态有意义。
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
extractCustomId
|
|
3
|
-
} from "./chunk-DFFIZ25G.js";
|
|
4
1
|
import {
|
|
5
2
|
getActiveDialogKey
|
|
6
3
|
} from "./chunk-3ASDTTEI.js";
|
|
@@ -10,6 +7,9 @@ import {
|
|
|
10
7
|
import {
|
|
11
8
|
asTrimmedLowercaseString
|
|
12
9
|
} from "./chunk-QSJ3HFEF.js";
|
|
10
|
+
import {
|
|
11
|
+
extractCustomId
|
|
12
|
+
} from "./chunk-SLOGKB7M.js";
|
|
13
13
|
import {
|
|
14
14
|
isRecord
|
|
15
15
|
} from "./chunk-KUG52IAP.js";
|