@qwen-code/qwen-code 0.15.12-preview.2 → 0.16.0-nightly.20260522.48b0a8bfc
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 +69 -71
- 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/lsp.md +87 -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 +179 -24
- package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +11 -11
- package/bundled/review/SKILL.md +12 -3
- package/bundled/stuck/SKILL.md +124 -0
- package/chunks/{agent-UQY6A6OS.js → agent-GRCSD6XI.js} +15 -17
- package/chunks/{anthropicContentGenerator-4QE6LTVV.js → anthropicContentGenerator-RQJNXJIY.js} +7 -4
- package/chunks/{askUserQuestion-QFSCBTUO.js → askUserQuestion-PQPMPNM3.js} +2 -2
- package/chunks/{ca-VQSV6JHA.js → ca-UZ7BANMN.js} +29 -3
- package/chunks/{chunk-B7ZL7HUA.js → chunk-4AOCVI6J.js} +2 -1
- package/chunks/{chunk-PCL3EJGY.js → chunk-4U3O4VDA.js} +4722 -3823
- package/chunks/{chunk-AEJ2DKLP.js → chunk-C6WMLUNB.js} +1 -1
- package/chunks/{chunk-FSYKVGER.js → chunk-C7PY32RJ.js} +115 -23
- package/chunks/{chunk-JMZQICAL.js → chunk-CAVZVZX6.js} +2 -2
- package/chunks/{chunk-CAWKL3UC.js → chunk-CSWBPY3P.js} +2 -2
- package/chunks/{chunk-G27O2LD2.js → chunk-D5NTAHYL.js} +1 -1
- package/chunks/{chunk-BXNCPI75.js → chunk-DMIMF3CG.js} +2 -2
- package/chunks/{chunk-OCC4MZRS.js → chunk-F23NCRJ2.js} +1 -1
- package/chunks/{chunk-SOIEFHIK.js → chunk-G7YTSRES.js} +1 -100
- package/chunks/{chunk-SQNQIOD5.js → chunk-GGNTZ2NH.js} +92 -21
- package/chunks/{chunk-FKVKVE6N.js → chunk-KXZ4TJB4.js} +1 -1
- package/chunks/{chunk-CBVB66WY.js → chunk-L5E26RN6.js} +2 -2
- package/chunks/{chunk-UXW7MYAW.js → chunk-MAY32HXD.js} +376 -1
- package/chunks/{chunk-2WFU3IUH.js → chunk-OZO6R4KI.js} +11796 -4086
- package/chunks/{chunk-CM2IESUE.js → chunk-PR4T27R7.js} +1 -1
- package/chunks/{chunk-FYMSCRHM.js → chunk-PVVL5Q3W.js} +32 -1
- package/chunks/{chunk-MXBWOU2L.js → chunk-TM4RMEYN.js} +17 -349
- package/chunks/{chunk-YHEAJFCI.js → chunk-USE2VQ5P.js} +3 -0
- package/chunks/chunk-UY2AYRZF.js +19126 -0
- package/chunks/{chunk-GJXIKCKL.js → chunk-XP27SJMH.js} +76 -5
- package/chunks/chunk-XTYIPAUG.js +379 -0
- package/chunks/{chunk-TPGOGCWM.js → chunk-YJLGXDQJ.js} +1 -1
- package/chunks/{contextCommand-MQRG6RMG.js → contextCommand-O2OLCMOG.js} +17 -19
- package/chunks/{cron-create-WUTD5ZTH.js → cron-create-IGYXQVG4.js} +28 -2
- package/chunks/{cron-delete-N3UQYCRA.js → cron-delete-ETKIZCWT.js} +2 -2
- package/chunks/{cron-list-Z6RJJ4YH.js → cron-list-BVCUSWRU.js} +2 -2
- package/chunks/{de-M2IPQRBS.js → de-V4IE2OOZ.js} +29 -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-3KCBTA25.js → edit-NRL5ZYWP.js} +32 -18
- package/chunks/{en-N5GMPCVT.js → en-HGJ2SPLM.js} +32 -3
- package/chunks/{enter-worktree-VWS5QZTU.js → enter-worktree-TLT6EXVN.js} +41 -17
- package/chunks/{exit-worktree-RVXFWAPD.js → exit-worktree-PE7RZMLE.js} +41 -17
- package/chunks/{exitPlanMode-UL5DILDG.js → exitPlanMode-JYMKAHYD.js} +15 -17
- package/chunks/{fr-BTHRYEXO.js → fr-CJULI7ZX.js} +29 -3
- package/chunks/{geminiContentGenerator-O2OPGHJG.js → geminiContentGenerator-GYIOVT4A.js} +3 -3
- package/chunks/{glob-57BSREPN.js → glob-T7KIVIWT.js} +15 -17
- package/chunks/{grep-XO5JOC7T.js → grep-4KI7ZJR5.js} +15 -17
- package/chunks/{ja-D63TAEBO.js → ja-L7CHRQEW.js} +29 -3
- package/chunks/{keychain-token-storage-DMFP5IJM.js → keychain-token-storage-335UOLJ6.js} +2 -2
- package/chunks/{ls-SUILOZZB.js → ls-7HD6XG3V.js} +3 -3
- package/chunks/{lsp-6TQBWVMZ.js → lsp-ZZSFCIWD.js} +2 -2
- package/chunks/{monitor-BECPGO3K.js → monitor-L5YPPGVO.js} +45 -26
- package/chunks/notebook-edit-HYXLIC3D.js +756 -0
- package/chunks/{openaiContentGenerator-KEZQHIRM.js → openaiContentGenerator-XRP5JM6P.js} +12 -11
- package/chunks/{pt-XUV7FSKC.js → pt-M6JULLEQ.js} +29 -3
- package/chunks/{qwenContentGenerator-RPMRXTNH.js → qwenContentGenerator-EOX3HZXX.js} +17 -19
- package/chunks/{qwenOAuth2-JSQ7EPR3.js → qwenOAuth2-EEJGROP7.js} +9 -3
- package/chunks/{read-file-LGHEIQNH.js → read-file-3XOYPTIB.js} +7 -8
- package/chunks/{ripGrep-6SFSXZ2G.js → ripGrep-5QUURWGU.js} +15 -17
- package/chunks/{ru-7KHWMN3A.js → ru-QILM4HBC.js} +29 -3
- package/chunks/{send-message-Q2JRAC3J.js → send-message-ULK4MQXJ.js} +23 -2
- package/chunks/{serve-27O2AFE3.js → serve-AZ44ZNWF.js} +8864 -1351
- package/chunks/{shell-J7K5KYCH.js → shell-O6OTTSIP.js} +15 -17
- package/chunks/{skill-2R7P4ATS.js → skill-MUGS3H4M.js} +23 -10
- package/chunks/{src-CGEDVW67.js → src-YCQBAYCP.js} +292 -28
- package/chunks/{syntheticOutput-S4DRGMQM.js → syntheticOutput-IS2X5OZ2.js} +3 -3
- package/chunks/{task-stop-7THHVAQS.js → task-stop-7QSJGSSP.js} +2 -2
- package/chunks/{todoWrite-WKUGUTPX.js → todoWrite-7CVACFUX.js} +3 -3
- package/chunks/{tool-search-XOH3ZWVS.js → tool-search-UFDQJOXT.js} +7 -8
- package/chunks/{web-fetch-OZE6ZQUF.js → web-fetch-ENQ2I5JA.js} +7 -4
- package/chunks/{write-file-74NQ27Q2.js → write-file-GBLDDYQT.js} +29 -18
- package/chunks/{zh-VGHU6XBB.js → zh-PWL2NKY3.js} +32 -3
- package/chunks/{zh-TW-O36Q4V7E.js → zh-TW-S3YGWICZ.js} +32 -3
- package/cli.js +61338 -76795
- package/locales/ca.js +44 -5
- package/locales/de.js +44 -5
- package/locales/en.js +49 -5
- package/locales/fr.js +45 -5
- package/locales/ja.js +43 -5
- package/locales/pt.js +43 -5
- package/locales/ru.js +43 -5
- package/locales/zh-TW.js +46 -4
- package/locales/zh.js +46 -4
- package/package.json +2 -2
- package/chunks/chunk-5P5XGNYH.js +0 -93
- package/chunks/chunk-SYCJMSIJ.js +0 -82
- package/chunks/chunk-Y6Z2O3WR.js +0 -33
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
import {
|
|
4
4
|
ToolNames
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-PVVL5Q3W.js";
|
|
6
6
|
import {
|
|
7
7
|
init_esbuild_shims
|
|
8
8
|
} from "./chunk-A4BMJM77.js";
|
|
@@ -85,7 +85,7 @@ async function checkPriorRead(cache, filePath, verb, options = {}) {
|
|
|
85
85
|
}
|
|
86
86
|
if (status.state === "fresh" && status.entry.lastReadAt !== void 0 && !status.entry.lastReadCacheable) {
|
|
87
87
|
const verbBare2 = verb === "editing" ? "edit" : "overwrite";
|
|
88
|
-
const raw2 = `File ${filePath} is a binary / image / audio / video / PDF / notebook payload that the ${ToolNames.READ_FILE} tool returns as a structured value rather than as plain text. The Edit / WriteFile tools cannot mutate that payload safely \u2014 re-reading it would not change this.
|
|
88
|
+
const raw2 = `File ${filePath} is a binary / image / audio / video / PDF / notebook payload that the ${ToolNames.READ_FILE} tool returns as a structured value rather than as plain text. The Edit / WriteFile tools cannot mutate that payload safely \u2014 re-reading it would not change this. If this is a Jupyter notebook (.ipynb), use the ${ToolNames.NOTEBOOK_EDIT} tool for cell-level edits after reading it. For other non-text files, use a different mechanism (e.g. shell tool with an appropriate writer) if you need to ${verbBare2} it.`;
|
|
89
89
|
return {
|
|
90
90
|
ok: false,
|
|
91
91
|
type: "edit_requires_prior_read" /* EDIT_REQUIRES_PRIOR_READ */,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
import {
|
|
4
4
|
createDebugLogger
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-XP27SJMH.js";
|
|
6
6
|
import {
|
|
7
7
|
init_esbuild_shims
|
|
8
8
|
} from "./chunk-A4BMJM77.js";
|
|
@@ -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
|