@qwen-code/qwen-code 0.16.0-preview.0 → 0.16.1-nightly.20260524.84f408017
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/bundled/qc-helper/docs/configuration/settings.md +39 -37
- package/bundled/qc-helper/docs/features/_meta.ts +2 -0
- package/bundled/qc-helper/docs/features/approval-mode.md +119 -2
- package/bundled/qc-helper/docs/features/auto-mode.md +263 -0
- package/bundled/qc-helper/docs/features/commands.md +11 -10
- package/bundled/qc-helper/docs/features/skills.md +3 -0
- package/bundled/qc-helper/docs/features/structured-output.md +309 -0
- package/bundled/qc-helper/docs/features/sub-agents.md +47 -5
- package/bundled/qc-helper/docs/qwen-serve.md +119 -14
- package/bundled/review/SKILL.md +12 -3
- package/chunks/{agent-ZNQPH67I.js → agent-QFQGDV7B.js} +9 -11
- package/chunks/{anthropicContentGenerator-ICBDZ6R2.js → anthropicContentGenerator-RQJNXJIY.js} +6 -3
- package/chunks/{askUserQuestion-WQILGUSQ.js → askUserQuestion-PQPMPNM3.js} +1 -1
- package/chunks/{ca-S3XJMT6P.js → ca-UZ7BANMN.js} +3 -3
- package/chunks/{chunk-XVHR7ATJ.js → chunk-4AOCVI6J.js} +1 -0
- package/chunks/{chunk-MNPZ2WO6.js → chunk-6JQC5PYU.js} +9104 -3955
- package/chunks/{chunk-AEJ2DKLP.js → chunk-C6WMLUNB.js} +1 -1
- package/chunks/{chunk-PPHYLJSS.js → chunk-CAVZVZX6.js} +2 -2
- package/chunks/{chunk-VTPOO6GV.js → chunk-CSWBPY3P.js} +1 -1
- package/chunks/{chunk-NAID3ZWF.js → chunk-DMIMF3CG.js} +1 -1
- package/chunks/{chunk-2B7UBDY5.js → chunk-GGNTZ2NH.js} +90 -19
- package/chunks/{chunk-C3LHPHN2.js → chunk-JUAMIT3V.js} +1227 -657
- package/chunks/{chunk-EDYSNFEM.js → chunk-L5E26RN6.js} +2 -2
- package/chunks/{chunk-7QXHXMC6.js → chunk-LKSMYCUK.js} +96 -20
- package/chunks/chunk-M2TQETH7.js +379 -0
- package/chunks/{chunk-CW44BRRA.js → chunk-MAY32HXD.js} +375 -0
- package/chunks/{chunk-FZIUV27X.js → chunk-PVVL5Q3W.js} +31 -0
- package/chunks/chunk-TEES5V4K.js +956 -0
- package/chunks/chunk-UL4NCM6X.js +19126 -0
- package/chunks/{chunk-YHEAJFCI.js → chunk-USE2VQ5P.js} +3 -0
- package/chunks/{chunk-JYQUJ5DS.js → chunk-YJLGXDQJ.js} +1 -1
- package/chunks/{contextCommand-IGBCEXI4.js → contextCommand-3FI5VRHY.js} +11 -13
- package/chunks/{cron-create-AVI3Q267.js → cron-create-IGYXQVG4.js} +27 -1
- package/chunks/{cron-delete-ZCEGDXXV.js → cron-delete-ETKIZCWT.js} +1 -1
- package/chunks/{cron-list-VN653OK5.js → cron-list-BVCUSWRU.js} +1 -1
- package/chunks/{de-MNR4SMAI.js → de-V4IE2OOZ.js} +3 -3
- package/chunks/{dist-RRYNPBOE.js → dist-4L54HRX2.js} +2 -2
- package/chunks/{dist-WP4AH3VK.js → dist-BXDUQ2QY.js} +1 -1
- package/chunks/{dist-M6GFCZ7S.js → dist-MN2PDDPR.js} +1 -1
- package/chunks/{edit-74Q4AFHQ.js → edit-JXJILHZW.js} +22 -12
- package/chunks/{en-FIUWJSZR.js → en-HGJ2SPLM.js} +4 -3
- package/chunks/{enter-worktree-H72HXC7D.js → enter-worktree-HQ3RBRIA.js} +35 -11
- package/chunks/{exit-worktree-FGIQO3S3.js → exit-worktree-73TYZY5X.js} +35 -11
- package/chunks/{exitPlanMode-NBR2PK2D.js → exitPlanMode-WEETA2GM.js} +9 -11
- package/chunks/{fr-OFJFHLCR.js → fr-CJULI7ZX.js} +3 -3
- package/chunks/{geminiContentGenerator-33RP4WKD.js → geminiContentGenerator-TVVMIHRE.js} +1 -1
- package/chunks/{glob-WEE3CJL6.js → glob-HZYBHMPB.js} +9 -11
- package/chunks/{grep-DZKSBFZK.js → grep-RO7NJDWP.js} +9 -11
- package/chunks/{ja-V6OQ6VL7.js → ja-L7CHRQEW.js} +3 -3
- package/chunks/{ls-6F3VSP6S.js → ls-7HD6XG3V.js} +1 -1
- package/chunks/{lsp-67Y7DJN5.js → lsp-ZZSFCIWD.js} +1 -1
- package/chunks/{monitor-EDZWEZVS.js → monitor-IOU376UD.js} +21 -11
- package/chunks/notebook-edit-7NXIUSLW.js +756 -0
- package/chunks/{openaiContentGenerator-5NQG3W64.js → openaiContentGenerator-BXS7CQJ2.js} +9 -8
- package/chunks/{pt-ZLE6SA4A.js → pt-M6JULLEQ.js} +3 -3
- package/chunks/{qwenContentGenerator-4DPUUS6R.js → qwenContentGenerator-7VOJGPBD.js} +11 -13
- package/chunks/{qwenOAuth2-JE7H47TE.js → qwenOAuth2-EEJGROP7.js} +7 -1
- package/chunks/{read-file-CQOF7BQ2.js → read-file-G4TFJFZ2.js} +4 -5
- package/chunks/{ripGrep-KR5LKGTI.js → ripGrep-IMMYV3HQ.js} +9 -11
- package/chunks/{ru-A4OHIUNN.js → ru-QILM4HBC.js} +3 -3
- package/chunks/{send-message-GB4AQZNC.js → send-message-ULK4MQXJ.js} +22 -1
- package/chunks/{serve-GAD2PEST.js → serve-5EHHVHBV.js} +13728 -3026
- package/chunks/{shell-E2HMCBGR.js → shell-AXZQIDDU.js} +9 -11
- package/chunks/{skill-KDZH6UZ6.js → skill-IMUVSRRZ.js} +19 -6
- package/chunks/{src-LY4RU5AI.js → src-VYNNTRVU.js} +205 -13
- package/chunks/{syntheticOutput-HFL3DE7R.js → syntheticOutput-IS2X5OZ2.js} +2 -2
- package/chunks/{task-stop-ZQF26RXS.js → task-stop-7QSJGSSP.js} +1 -1
- package/chunks/{todoWrite-U4SC643O.js → todoWrite-7CVACFUX.js} +2 -2
- package/chunks/{tool-search-U4XQVLFU.js → tool-search-BTGLGBDQ.js} +4 -5
- package/chunks/{web-fetch-BRWZ4WSE.js → web-fetch-ENQ2I5JA.js} +5 -2
- package/chunks/{write-file-NBLRMNGB.js → write-file-BNUIFGU4.js} +19 -12
- package/chunks/{zh-V32QONGV.js → zh-PWL2NKY3.js} +4 -3
- package/chunks/{zh-TW-552S24LR.js → zh-TW-S3YGWICZ.js} +4 -3
- package/cli.js +14841 -49052
- package/locales/ca.js +4 -5
- package/locales/de.js +4 -5
- package/locales/en.js +6 -5
- package/locales/fr.js +4 -5
- package/locales/ja.js +4 -5
- package/locales/pt.js +4 -5
- package/locales/ru.js +4 -5
- package/locales/zh-TW.js +5 -4
- package/locales/zh.js +5 -4
- package/package.json +2 -2
- package/chunks/chunk-3MBY4GKN.js +0 -350
- package/chunks/chunk-5P5XGNYH.js +0 -93
- package/chunks/chunk-JHMX4QTD.js +0 -2306
- package/chunks/chunk-SYCJMSIJ.js +0 -82
- package/chunks/chunk-Y6Z2O3WR.js +0 -33
|
@@ -10,6 +10,371 @@ import {
|
|
|
10
10
|
__name
|
|
11
11
|
} from "./chunk-J2S4EL5Y.js";
|
|
12
12
|
|
|
13
|
+
// packages/core/src/utils/runtimeDiagnostics.ts
|
|
14
|
+
init_esbuild_shims();
|
|
15
|
+
var RUNTIME_PROFILE_ENV = "QWEN_CODE_PROFILE_RUNTIME";
|
|
16
|
+
function isRuntimeDiagnosticsEnabled(env = process.env) {
|
|
17
|
+
return env[RUNTIME_PROFILE_ENV] === "1";
|
|
18
|
+
}
|
|
19
|
+
__name(isRuntimeDiagnosticsEnabled, "isRuntimeDiagnosticsEnabled");
|
|
20
|
+
var RuntimeDiagnosticsCollector = class {
|
|
21
|
+
static {
|
|
22
|
+
__name(this, "RuntimeDiagnosticsCollector");
|
|
23
|
+
}
|
|
24
|
+
enabled;
|
|
25
|
+
now;
|
|
26
|
+
startedAt;
|
|
27
|
+
requestIndex = 0;
|
|
28
|
+
openAIWireRequestIndex = 0;
|
|
29
|
+
anthropicWireRequestIndex = 0;
|
|
30
|
+
requests = [];
|
|
31
|
+
openaiWireRequests = [];
|
|
32
|
+
anthropicWireRequests = [];
|
|
33
|
+
tools = createInitialToolDiagnostics();
|
|
34
|
+
constructor(options = {}) {
|
|
35
|
+
this.enabled = options.enabled ?? isRuntimeDiagnosticsEnabled();
|
|
36
|
+
this.now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
37
|
+
this.startedAt = this.now();
|
|
38
|
+
}
|
|
39
|
+
reset(options = {}) {
|
|
40
|
+
this.enabled = options.enabled ?? isRuntimeDiagnosticsEnabled();
|
|
41
|
+
this.startedAt = this.now();
|
|
42
|
+
this.requestIndex = 0;
|
|
43
|
+
this.openAIWireRequestIndex = 0;
|
|
44
|
+
this.anthropicWireRequestIndex = 0;
|
|
45
|
+
this.requests = [];
|
|
46
|
+
this.openaiWireRequests = [];
|
|
47
|
+
this.anthropicWireRequests = [];
|
|
48
|
+
this.tools = createInitialToolDiagnostics();
|
|
49
|
+
}
|
|
50
|
+
isEnabled() {
|
|
51
|
+
return this.enabled;
|
|
52
|
+
}
|
|
53
|
+
recordGenerateContentRequest(request, options) {
|
|
54
|
+
if (!this.enabled) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this.requestIndex += 1;
|
|
58
|
+
this.requests.push({
|
|
59
|
+
index: this.requestIndex,
|
|
60
|
+
timestamp: this.now(),
|
|
61
|
+
source: options.source,
|
|
62
|
+
model: request.model,
|
|
63
|
+
stream: options.stream,
|
|
64
|
+
serializedBytes: utf8Bytes(toJsonSafeRequest(request)),
|
|
65
|
+
contents: summarizeContents(request.contents),
|
|
66
|
+
systemInstructionBytes: summarizeContentTextBytes(
|
|
67
|
+
request.config?.systemInstruction
|
|
68
|
+
),
|
|
69
|
+
generationConfigBytes: utf8Bytes(toJsonSafeConfig(request.config)),
|
|
70
|
+
tools: summarizeToolSchemas(request.config?.tools)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
recordOpenAIWireRequest(request) {
|
|
74
|
+
if (!this.enabled) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.openAIWireRequestIndex += 1;
|
|
78
|
+
this.openaiWireRequests.push({
|
|
79
|
+
index: this.openAIWireRequestIndex,
|
|
80
|
+
timestamp: this.now(),
|
|
81
|
+
...summarizeOpenAIWireRequest(request)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
recordAnthropicWireRequest(request) {
|
|
85
|
+
if (!this.enabled) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.anthropicWireRequestIndex += 1;
|
|
89
|
+
this.anthropicWireRequests.push({
|
|
90
|
+
index: this.anthropicWireRequestIndex,
|
|
91
|
+
timestamp: this.now(),
|
|
92
|
+
...summarizeAnthropicWireRequest(request)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
recordToolUse(name, args) {
|
|
96
|
+
if (!this.enabled) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const argBytes = utf8Bytes(args);
|
|
100
|
+
const tool = this.getToolNameDiagnostics(name);
|
|
101
|
+
tool.uses += 1;
|
|
102
|
+
tool.argBytes += argBytes;
|
|
103
|
+
tool.maxArgBytes = Math.max(tool.maxArgBytes, argBytes);
|
|
104
|
+
this.tools.toolUseCount += 1;
|
|
105
|
+
this.tools.totalToolUseArgBytes += argBytes;
|
|
106
|
+
this.tools.maxToolUseArgBytes = Math.max(
|
|
107
|
+
this.tools.maxToolUseArgBytes,
|
|
108
|
+
argBytes
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
recordToolResult(record) {
|
|
112
|
+
if (!this.enabled) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const tool = this.getToolNameDiagnostics(record.name);
|
|
116
|
+
tool.results += 1;
|
|
117
|
+
tool.resultBytes += record.resultBytes;
|
|
118
|
+
tool.maxResultBytes = Math.max(tool.maxResultBytes, record.resultBytes);
|
|
119
|
+
if (record.isError) {
|
|
120
|
+
tool.errors += 1;
|
|
121
|
+
this.tools.toolResultErrorCount += 1;
|
|
122
|
+
}
|
|
123
|
+
this.tools.toolResultCount += 1;
|
|
124
|
+
this.tools.totalToolResultBytes += record.resultBytes;
|
|
125
|
+
this.tools.maxToolResultBytes = Math.max(
|
|
126
|
+
this.tools.maxToolResultBytes,
|
|
127
|
+
record.resultBytes
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
snapshot() {
|
|
131
|
+
return {
|
|
132
|
+
enabled: this.enabled,
|
|
133
|
+
startedAt: this.startedAt,
|
|
134
|
+
requests: this.requests.map((request) => ({
|
|
135
|
+
...request,
|
|
136
|
+
contents: {
|
|
137
|
+
...request.contents,
|
|
138
|
+
roleCounts: { ...request.contents.roleCounts }
|
|
139
|
+
},
|
|
140
|
+
tools: { ...request.tools }
|
|
141
|
+
})),
|
|
142
|
+
openaiWireRequests: this.openaiWireRequests.map((request) => ({
|
|
143
|
+
...request,
|
|
144
|
+
messageBytesByRole: { ...request.messageBytesByRole },
|
|
145
|
+
topLevelKeys: [...request.topLevelKeys]
|
|
146
|
+
})),
|
|
147
|
+
anthropicWireRequests: this.anthropicWireRequests.map((request) => ({
|
|
148
|
+
...request,
|
|
149
|
+
messageBytesByRole: { ...request.messageBytesByRole },
|
|
150
|
+
topLevelKeys: [...request.topLevelKeys]
|
|
151
|
+
})),
|
|
152
|
+
tools: {
|
|
153
|
+
...this.tools,
|
|
154
|
+
byName: Object.fromEntries(
|
|
155
|
+
Object.entries(this.tools.byName).map(([name, value]) => [
|
|
156
|
+
name,
|
|
157
|
+
{ ...value }
|
|
158
|
+
])
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
getToolNameDiagnostics(name) {
|
|
164
|
+
const existing = this.tools.byName[name];
|
|
165
|
+
if (existing) {
|
|
166
|
+
return existing;
|
|
167
|
+
}
|
|
168
|
+
const created = createInitialToolNameDiagnostics();
|
|
169
|
+
this.tools.byName[name] = created;
|
|
170
|
+
return created;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var runtimeDiagnostics = new RuntimeDiagnosticsCollector();
|
|
174
|
+
function summarizeOpenAIWireRequest(request) {
|
|
175
|
+
const requestRecord = asRecord(request);
|
|
176
|
+
const messages = Array.isArray(requestRecord["messages"]) ? requestRecord["messages"] : [];
|
|
177
|
+
const tools = Array.isArray(requestRecord["tools"]) ? requestRecord["tools"] : [];
|
|
178
|
+
const messageBytesByRole = {};
|
|
179
|
+
for (const message of messages) {
|
|
180
|
+
const messageRecord = asRecord(message);
|
|
181
|
+
const role = typeof messageRecord["role"] === "string" ? messageRecord["role"] : "unknown";
|
|
182
|
+
messageBytesByRole[role] = (messageBytesByRole[role] ?? 0) + utf8Bytes(messageRecord["content"]);
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
model: typeof requestRecord["model"] === "string" ? requestRecord["model"] : "unknown",
|
|
186
|
+
stream: requestRecord["stream"] === true,
|
|
187
|
+
bodyBytes: utf8Bytes(request),
|
|
188
|
+
messageCount: messages.length,
|
|
189
|
+
messageBytesByRole,
|
|
190
|
+
toolsCount: tools.length,
|
|
191
|
+
toolSchemaBytes: utf8Bytes(tools),
|
|
192
|
+
topLevelKeys: Object.keys(requestRecord).sort()
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
__name(summarizeOpenAIWireRequest, "summarizeOpenAIWireRequest");
|
|
196
|
+
function summarizeAnthropicWireRequest(request) {
|
|
197
|
+
const requestRecord = asRecord(request);
|
|
198
|
+
const messages = Array.isArray(requestRecord["messages"]) ? requestRecord["messages"] : [];
|
|
199
|
+
const tools = Array.isArray(requestRecord["tools"]) ? requestRecord["tools"] : [];
|
|
200
|
+
const messageBytesByRole = {};
|
|
201
|
+
for (const message of messages) {
|
|
202
|
+
const messageRecord = asRecord(message);
|
|
203
|
+
const role = typeof messageRecord["role"] === "string" ? messageRecord["role"] : "unknown";
|
|
204
|
+
messageBytesByRole[role] = (messageBytesByRole[role] ?? 0) + utf8Bytes(messageRecord["content"]);
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
model: typeof requestRecord["model"] === "string" ? requestRecord["model"] : "unknown",
|
|
208
|
+
stream: requestRecord["stream"] === true,
|
|
209
|
+
bodyBytes: utf8Bytes(request),
|
|
210
|
+
messageCount: messages.length,
|
|
211
|
+
messageBytesByRole,
|
|
212
|
+
systemBytes: utf8Bytes(requestRecord["system"]),
|
|
213
|
+
toolsCount: tools.length,
|
|
214
|
+
toolSchemaBytes: utf8Bytes(tools),
|
|
215
|
+
topLevelKeys: Object.keys(requestRecord).sort()
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
__name(summarizeAnthropicWireRequest, "summarizeAnthropicWireRequest");
|
|
219
|
+
function createInitialToolDiagnostics() {
|
|
220
|
+
return {
|
|
221
|
+
toolUseCount: 0,
|
|
222
|
+
toolResultCount: 0,
|
|
223
|
+
toolResultErrorCount: 0,
|
|
224
|
+
totalToolUseArgBytes: 0,
|
|
225
|
+
maxToolUseArgBytes: 0,
|
|
226
|
+
totalToolResultBytes: 0,
|
|
227
|
+
maxToolResultBytes: 0,
|
|
228
|
+
byName: /* @__PURE__ */ Object.create(null)
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
__name(createInitialToolDiagnostics, "createInitialToolDiagnostics");
|
|
232
|
+
function createInitialToolNameDiagnostics() {
|
|
233
|
+
return {
|
|
234
|
+
uses: 0,
|
|
235
|
+
argBytes: 0,
|
|
236
|
+
maxArgBytes: 0,
|
|
237
|
+
results: 0,
|
|
238
|
+
errors: 0,
|
|
239
|
+
resultBytes: 0,
|
|
240
|
+
maxResultBytes: 0
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
__name(createInitialToolNameDiagnostics, "createInitialToolNameDiagnostics");
|
|
244
|
+
function summarizeContents(contents) {
|
|
245
|
+
const summary = {
|
|
246
|
+
count: 0,
|
|
247
|
+
roleCounts: {},
|
|
248
|
+
partCount: 0,
|
|
249
|
+
textBytes: 0,
|
|
250
|
+
functionCallCount: 0,
|
|
251
|
+
functionCallArgBytes: 0,
|
|
252
|
+
functionResponseCount: 0,
|
|
253
|
+
functionResponseBytes: 0,
|
|
254
|
+
inlineDataCount: 0,
|
|
255
|
+
inlineDataBytes: 0,
|
|
256
|
+
fileDataCount: 0
|
|
257
|
+
};
|
|
258
|
+
const contentItems = Array.isArray(contents) ? contents : contents === void 0 || contents === null ? [] : [contents];
|
|
259
|
+
for (const content of contentItems) {
|
|
260
|
+
summary.count += 1;
|
|
261
|
+
if (typeof content === "string") {
|
|
262
|
+
summary.roleCounts["user"] = (summary.roleCounts["user"] ?? 0) + 1;
|
|
263
|
+
summary.partCount += 1;
|
|
264
|
+
summary.textBytes += utf8Bytes(content);
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
const contentRecord = asRecord(content);
|
|
268
|
+
const role = typeof contentRecord["role"] === "string" ? contentRecord["role"] : "unknown";
|
|
269
|
+
summary.roleCounts[role] = (summary.roleCounts[role] ?? 0) + 1;
|
|
270
|
+
const parts = Array.isArray(contentRecord["parts"]) ? contentRecord["parts"] : [];
|
|
271
|
+
summarizeParts(parts, summary);
|
|
272
|
+
}
|
|
273
|
+
return summary;
|
|
274
|
+
}
|
|
275
|
+
__name(summarizeContents, "summarizeContents");
|
|
276
|
+
function summarizeContentTextBytes(content) {
|
|
277
|
+
const summary = summarizeContents(content);
|
|
278
|
+
return summary.textBytes;
|
|
279
|
+
}
|
|
280
|
+
__name(summarizeContentTextBytes, "summarizeContentTextBytes");
|
|
281
|
+
function summarizeParts(parts, summary) {
|
|
282
|
+
for (const part of parts) {
|
|
283
|
+
summary.partCount += 1;
|
|
284
|
+
if (typeof part === "string") {
|
|
285
|
+
summary.textBytes += utf8Bytes(part);
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
const partRecord = asRecord(part);
|
|
289
|
+
if (typeof partRecord["text"] === "string") {
|
|
290
|
+
summary.textBytes += utf8Bytes(partRecord["text"]);
|
|
291
|
+
}
|
|
292
|
+
const functionCall = asOptionalRecord(partRecord["functionCall"]);
|
|
293
|
+
if (functionCall) {
|
|
294
|
+
summary.functionCallCount += 1;
|
|
295
|
+
summary.functionCallArgBytes += utf8Bytes(functionCall["args"]);
|
|
296
|
+
}
|
|
297
|
+
const functionResponse = asOptionalRecord(partRecord["functionResponse"]);
|
|
298
|
+
if (functionResponse) {
|
|
299
|
+
summary.functionResponseCount += 1;
|
|
300
|
+
summary.functionResponseBytes += utf8Bytes(functionResponse["response"]) + utf8Bytes(functionResponse["parts"]);
|
|
301
|
+
}
|
|
302
|
+
const inlineData = asOptionalRecord(partRecord["inlineData"]);
|
|
303
|
+
if (inlineData) {
|
|
304
|
+
summary.inlineDataCount += 1;
|
|
305
|
+
summary.inlineDataBytes += utf8Bytes(inlineData["data"]);
|
|
306
|
+
}
|
|
307
|
+
if (partRecord["fileData"]) {
|
|
308
|
+
summary.fileDataCount += 1;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
__name(summarizeParts, "summarizeParts");
|
|
313
|
+
function summarizeToolSchemas(tools) {
|
|
314
|
+
const toolList = Array.isArray(tools) ? tools : [];
|
|
315
|
+
let functionDeclarationCount = 0;
|
|
316
|
+
for (const tool of toolList) {
|
|
317
|
+
const toolRecord = asRecord(tool);
|
|
318
|
+
const declarations = Array.isArray(toolRecord["functionDeclarations"]) ? toolRecord["functionDeclarations"] : [];
|
|
319
|
+
functionDeclarationCount += declarations.length;
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
count: toolList.length,
|
|
323
|
+
functionDeclarationCount,
|
|
324
|
+
schemaBytes: utf8Bytes(toolList)
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
__name(summarizeToolSchemas, "summarizeToolSchemas");
|
|
328
|
+
function toJsonSafeRequest(request) {
|
|
329
|
+
return {
|
|
330
|
+
model: request.model,
|
|
331
|
+
contents: request.contents,
|
|
332
|
+
config: toJsonSafeConfig(request.config)
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
__name(toJsonSafeRequest, "toJsonSafeRequest");
|
|
336
|
+
function toJsonSafeConfig(config) {
|
|
337
|
+
if (!config) {
|
|
338
|
+
return void 0;
|
|
339
|
+
}
|
|
340
|
+
const configRecord = asRecord(config);
|
|
341
|
+
const safeConfig = {};
|
|
342
|
+
for (const [key, value] of Object.entries(configRecord)) {
|
|
343
|
+
if (key === "abortSignal") {
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
safeConfig[key] = value;
|
|
347
|
+
}
|
|
348
|
+
return safeConfig;
|
|
349
|
+
}
|
|
350
|
+
__name(toJsonSafeConfig, "toJsonSafeConfig");
|
|
351
|
+
function utf8Bytes(value) {
|
|
352
|
+
if (value === void 0 || value === null) {
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
if (typeof value === "string") {
|
|
356
|
+
return Buffer.byteLength(value, "utf8");
|
|
357
|
+
}
|
|
358
|
+
return Buffer.byteLength(safeStringify(value), "utf8");
|
|
359
|
+
}
|
|
360
|
+
__name(utf8Bytes, "utf8Bytes");
|
|
361
|
+
function safeStringify(value) {
|
|
362
|
+
try {
|
|
363
|
+
return JSON.stringify(value) ?? "";
|
|
364
|
+
} catch {
|
|
365
|
+
return "[unserializable]";
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
__name(safeStringify, "safeStringify");
|
|
369
|
+
function asRecord(value) {
|
|
370
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
371
|
+
}
|
|
372
|
+
__name(asRecord, "asRecord");
|
|
373
|
+
function asOptionalRecord(value) {
|
|
374
|
+
return typeof value === "object" && value !== null ? value : null;
|
|
375
|
+
}
|
|
376
|
+
__name(asOptionalRecord, "asOptionalRecord");
|
|
377
|
+
|
|
13
378
|
// packages/core/src/core/tokenLimits.ts
|
|
14
379
|
init_esbuild_shims();
|
|
15
380
|
var DEFAULT_TOKEN_LIMIT = 131072;
|
|
@@ -1012,6 +1377,11 @@ __name(toOpenAPI30, "toOpenAPI30");
|
|
|
1012
1377
|
export {
|
|
1013
1378
|
safeJsonParse,
|
|
1014
1379
|
convertSchema,
|
|
1380
|
+
isRuntimeDiagnosticsEnabled,
|
|
1381
|
+
RuntimeDiagnosticsCollector,
|
|
1382
|
+
runtimeDiagnostics,
|
|
1383
|
+
summarizeOpenAIWireRequest,
|
|
1384
|
+
summarizeAnthropicWireRequest,
|
|
1015
1385
|
DEFAULT_TOKEN_LIMIT,
|
|
1016
1386
|
DEFAULT_OUTPUT_TOKEN_LIMIT,
|
|
1017
1387
|
CAPPED_DEFAULT_MAX_TOKENS,
|
|
@@ -1026,6 +1396,11 @@ export {
|
|
|
1026
1396
|
DEFAULT_DASHSCOPE_BASE_URL,
|
|
1027
1397
|
DASHSCOPE_PROXY_BASE_URL
|
|
1028
1398
|
};
|
|
1399
|
+
/**
|
|
1400
|
+
* @license
|
|
1401
|
+
* Copyright 2026 Qwen
|
|
1402
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1403
|
+
*/
|
|
1029
1404
|
/**
|
|
1030
1405
|
* @license
|
|
1031
1406
|
* Copyright 2025 Qwen
|
|
@@ -14155,6 +14155,10 @@ var ToolErrorType = /* @__PURE__ */ ((ToolErrorType2) => {
|
|
|
14155
14155
|
ToolErrorType2["EDIT_REQUIRES_PRIOR_READ"] = "edit_requires_prior_read";
|
|
14156
14156
|
ToolErrorType2["FILE_CHANGED_SINCE_READ"] = "file_changed_since_read";
|
|
14157
14157
|
ToolErrorType2["PRIOR_READ_VERIFICATION_FAILED"] = "prior_read_verification_failed";
|
|
14158
|
+
ToolErrorType2["TARGET_NOT_REGULAR_FILE"] = "target_not_regular_file";
|
|
14159
|
+
ToolErrorType2["NOTEBOOK_EDIT_FAILURE"] = "notebook_edit_failure";
|
|
14160
|
+
ToolErrorType2["NOTEBOOK_INVALID_JSON"] = "notebook_invalid_json";
|
|
14161
|
+
ToolErrorType2["NOTEBOOK_CELL_NOT_FOUND"] = "notebook_cell_not_found";
|
|
14158
14162
|
ToolErrorType2["GLOB_EXECUTION_ERROR"] = "glob_execution_error";
|
|
14159
14163
|
ToolErrorType2["GREP_EXECUTION_ERROR"] = "grep_execution_error";
|
|
14160
14164
|
ToolErrorType2["LS_EXECUTION_ERROR"] = "ls_execution_error";
|
|
@@ -14608,6 +14612,31 @@ var DeclarativeTool = class {
|
|
|
14608
14612
|
parametersJsonSchema: this.parameterSchema
|
|
14609
14613
|
};
|
|
14610
14614
|
}
|
|
14615
|
+
/**
|
|
14616
|
+
* Projects tool params for the AUTO approval mode classifier.
|
|
14617
|
+
*
|
|
14618
|
+
* Tools with security-relevant parameters (file paths, shell commands,
|
|
14619
|
+
* URLs) should override this to redact voluminous or sensitive fields
|
|
14620
|
+
* (full content, secrets) while exposing enough for the classifier to
|
|
14621
|
+
* judge safety.
|
|
14622
|
+
*
|
|
14623
|
+
* Returns:
|
|
14624
|
+
* - object: projected params to send to the classifier
|
|
14625
|
+
* - empty string: signals "no security relevance" — the classifier
|
|
14626
|
+
* transcript will record only the tool name
|
|
14627
|
+
* - undefined: fall back to raw params (only safe when the tool is
|
|
14628
|
+
* known to have no sensitive params)
|
|
14629
|
+
*
|
|
14630
|
+
* Default is the empty-string sentinel — fail-closed: a third-party
|
|
14631
|
+
* MCP tool (or any tool that has not opted in) does not leak its raw
|
|
14632
|
+
* parameters (potentially containing API keys, tokens, file contents)
|
|
14633
|
+
* into the classifier LLM prompt. Tools that want their args inspected
|
|
14634
|
+
* by the classifier for safety judgement should override this and
|
|
14635
|
+
* return an object with only the security-relevant fields.
|
|
14636
|
+
*/
|
|
14637
|
+
toAutoClassifierInput(_params) {
|
|
14638
|
+
return "";
|
|
14639
|
+
}
|
|
14611
14640
|
/**
|
|
14612
14641
|
* Validates the raw tool parameters.
|
|
14613
14642
|
* Subclasses should override this to add custom validation logic
|
|
@@ -14832,6 +14861,7 @@ var ToolNames = {
|
|
|
14832
14861
|
SEND_MESSAGE: "send_message",
|
|
14833
14862
|
STRUCTURED_OUTPUT: "structured_output",
|
|
14834
14863
|
MONITOR: "monitor",
|
|
14864
|
+
NOTEBOOK_EDIT: "notebook_edit",
|
|
14835
14865
|
TOOL_SEARCH: "tool_search",
|
|
14836
14866
|
ENTER_WORKTREE: "enter_worktree",
|
|
14837
14867
|
EXIT_WORKTREE: "exit_worktree"
|
|
@@ -14859,6 +14889,7 @@ var ToolDisplayNames = {
|
|
|
14859
14889
|
SEND_MESSAGE: "SendMessage",
|
|
14860
14890
|
STRUCTURED_OUTPUT: "StructuredOutput",
|
|
14861
14891
|
MONITOR: "Monitor",
|
|
14892
|
+
NOTEBOOK_EDIT: "NotebookEdit",
|
|
14862
14893
|
TOOL_SEARCH: "ToolSearch",
|
|
14863
14894
|
ENTER_WORKTREE: "EnterWorktree",
|
|
14864
14895
|
EXIT_WORKTREE: "ExitWorktree"
|