@qwen-code/qwen-code 0.16.2 → 0.17.0
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 +5 -1
- package/bundled/qc-helper/docs/features/channels/_meta.ts +1 -0
- package/bundled/qc-helper/docs/features/channels/feishu.md +170 -0
- package/chunks/{agent-RY5EB3XR.js → agent-KVXFGIOU.js} +17 -12
- package/chunks/{anthropicContentGenerator-LYI3OHBB.js → anthropicContentGenerator-L4HWAOIV.js} +5 -5
- package/chunks/{askUserQuestion-R3MKD2JT.js → askUserQuestion-DC6OWQIL.js} +5 -3
- package/chunks/chunk-24YKA2DA.js +233 -0
- package/chunks/{chunk-UFC57OYT.js → chunk-33RDTIU6.js} +5 -3
- package/chunks/{chunk-C6WMLUNB.js → chunk-3BJBCG2K.js} +1 -1
- package/chunks/chunk-3HX5LZ6R.js +1798 -0
- package/chunks/{chunk-GQXXO5HJ.js → chunk-4O2TWJK4.js} +25 -5
- package/chunks/{chunk-RDYWTWEM.js → chunk-5IFG2VC4.js} +299 -232
- package/chunks/chunk-6RQTH7UQ.js +115 -0
- package/chunks/{chunk-7HM6OB7M.js → chunk-7EHPK6TK.js} +1336 -5164
- package/chunks/{chunk-PJLEMR7N.js → chunk-7NNBQRV7.js} +6 -6
- package/chunks/{chunk-K5PGHDBN.js → chunk-AKBFRR6J.js} +112 -132
- package/chunks/{chunk-C27V5A2J.js → chunk-EMVEDSVZ.js} +1 -1
- package/chunks/{chunk-TXQI3VZ7.js → chunk-GJHMAWS7.js} +1 -1
- package/chunks/{chunk-K72FHBFO.js → chunk-HAQCNXSG.js} +1 -0
- package/chunks/{chunk-T4VD6OJ4.js → chunk-HCSJIOLR.js} +1 -1
- package/chunks/chunk-J37FGIOA.js +1623 -0
- package/chunks/chunk-J5VCSWPA.js +1467 -0
- package/chunks/{chunk-UE5LPQF7.js → chunk-JI7FDD65.js} +7 -7
- package/chunks/{chunk-4YNZFYJY.js → chunk-MEN6IEKX.js} +2533 -3943
- package/chunks/{chunk-USE2VQ5P.js → chunk-NP3ICQCN.js} +1 -1
- package/chunks/{chunk-66CJCYYZ.js → chunk-QEXSIXLX.js} +1 -1
- package/chunks/{chunk-YMDXEEOW.js → chunk-R2B65CAN.js} +1 -82
- package/chunks/chunk-SZOEIL6S.js +35 -0
- package/chunks/chunk-TI4GXJKO.js +4277 -0
- package/chunks/{chunk-E7E2MFYM.js → chunk-U2K6HDUJ.js} +434 -13
- package/chunks/{chunk-FO7BIVSR.js → chunk-UQRYJQBE.js} +5 -3
- package/chunks/{chunk-VMOWXTRC.js → chunk-V7LMZR76.js} +1 -1
- package/chunks/chunk-W57YDFU5.js +41 -0
- package/chunks/computer-use-2J5ZXEER.js +768 -0
- package/chunks/{contextCommand-DDGVLQSF.js → contextCommand-52NTEMCT.js} +19 -14
- package/chunks/{cron-create-BTEOGHPH.js → cron-create-FXRORK2U.js} +5 -3
- package/chunks/{cron-delete-56CEWELN.js → cron-delete-D24IN6CA.js} +5 -3
- package/chunks/{cron-list-SV6QRZW2.js → cron-list-SMOX26SL.js} +5 -3
- package/chunks/{devtools-WN62SQPV.js → devtools-IXE4UP72.js} +31 -3748
- package/chunks/{dist-MN2PDDPR.js → dist-6RUZ2JD6.js} +13 -1612
- package/chunks/{dist-R2SXPG74.js → dist-AHZNZWRI.js} +5 -4
- package/chunks/dist-GRQVFL3G.js +94147 -0
- package/chunks/{dist-BXDUQ2QY.js → dist-XTTPOFAH.js} +4 -3
- package/chunks/{edit-4LLGNYVZ.js → edit-RLFUTT5F.js} +20 -14
- package/chunks/{enter-worktree-E2R5XAFT.js → enter-worktree-CYRAPQKJ.js} +20 -14
- package/chunks/{exit-worktree-YVBYYYDD.js → exit-worktree-WQZM72QD.js} +20 -14
- package/chunks/{exitPlanMode-WD5IH7NS.js → exitPlanMode-STFEBQZE.js} +20 -14
- package/chunks/{geminiContentGenerator-LM65ADWM.js → geminiContentGenerator-DIV32SKO.js} +4 -3
- package/chunks/{glob-6X6OCEWE.js → glob-N3XO4RVI.js} +20 -14
- package/chunks/{grep-2UUPSSIQ.js → grep-AK5MP7P3.js} +20 -14
- package/chunks/{ls-MYXAM7LJ.js → ls-7FYQHPWF.js} +5 -3
- package/chunks/{lsp-PFGI35JL.js → lsp-DKG34USR.js} +5 -3
- package/chunks/{monitor-VUHPEGUW.js → monitor-IVBWJZEZ.js} +20 -14
- package/chunks/{notebook-edit-P4QVLW6I.js → notebook-edit-PM46AXFS.js} +21 -15
- package/chunks/{openaiContentGenerator-JH4YNZ3H.js → openaiContentGenerator-4QXCH7L2.js} +13 -10
- package/chunks/{qwenContentGenerator-5FE4UYUT.js → qwenContentGenerator-BLXQIIMX.js} +21 -16
- package/chunks/{read-file-J7DH4OKV.js → read-file-IEQAS3EZ.js} +10 -6
- package/chunks/{ripGrep-33DECY4F.js → ripGrep-HQO7IE4C.js} +17 -12
- package/chunks/{send-message-JUFP62VD.js → send-message-ZL7CDM7K.js} +5 -3
- package/chunks/{serve-7FX7MREA.js → serve-CYRAK4UM.js} +63 -1837
- package/chunks/{shell-ZNTQIRK6.js → shell-UZBGNO2Q.js} +17 -12
- package/chunks/{skill-CFCUIY23.js → skill-JVC34QYN.js} +24 -13
- package/chunks/{src-AHV2CWEQ.js → src-FOODLH7B.js} +49 -41
- package/chunks/{syntheticOutput-AKTXC6FR.js → syntheticOutput-U3YJ3GOO.js} +3 -2
- package/chunks/{task-stop-2NYFR2ES.js → task-stop-NPUI3YBA.js} +5 -3
- package/chunks/{todoWrite-WHZ2O2XP.js → todoWrite-Y6F7YEIM.js} +6 -4
- package/chunks/{tool-search-C2EMLFBJ.js → tool-search-P7PRPOW3.js} +13 -8
- package/chunks/{web-fetch-S6MZXPZ5.js → web-fetch-XWEK4TFX.js} +6 -4
- package/chunks/{write-file-EEPVRS4Q.js → write-file-SIIEUON5.js} +21 -15
- package/cli.js +412 -329
- package/package.json +2 -2
- package/chunks/chunk-JVD46YJV.js +0 -434
- package/chunks/undici-4ARNOH74.js +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwen-code/qwen-code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Qwen Code - AI-powered coding assistant",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"bundled"
|
|
23
23
|
],
|
|
24
24
|
"config": {
|
|
25
|
-
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.
|
|
25
|
+
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.17.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {},
|
|
28
28
|
"optionalDependencies": {
|
package/chunks/chunk-JVD46YJV.js
DELETED
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
// Force strict mode and setup for ESM
|
|
2
|
-
"use strict";
|
|
3
|
-
import {
|
|
4
|
-
createDebugLogger
|
|
5
|
-
} from "./chunk-ACBGEKB7.js";
|
|
6
|
-
import {
|
|
7
|
-
require_undici
|
|
8
|
-
} from "./chunk-E7E2MFYM.js";
|
|
9
|
-
import {
|
|
10
|
-
init_esbuild_shims
|
|
11
|
-
} from "./chunk-A4BMJM77.js";
|
|
12
|
-
import {
|
|
13
|
-
__name,
|
|
14
|
-
__toESM
|
|
15
|
-
} from "./chunk-J2S4EL5Y.js";
|
|
16
|
-
|
|
17
|
-
// packages/core/src/utils/runtimeFetchOptions.ts
|
|
18
|
-
init_esbuild_shims();
|
|
19
|
-
var import_undici = __toESM(require_undici(), 1);
|
|
20
|
-
var debugLogger = createDebugLogger("RUNTIME_FETCH");
|
|
21
|
-
function detectRuntime() {
|
|
22
|
-
if (typeof process !== "undefined" && process.versions?.["bun"]) {
|
|
23
|
-
return "bun";
|
|
24
|
-
}
|
|
25
|
-
if (typeof process !== "undefined" && process.versions?.node) {
|
|
26
|
-
return "node";
|
|
27
|
-
}
|
|
28
|
-
return "unknown";
|
|
29
|
-
}
|
|
30
|
-
__name(detectRuntime, "detectRuntime");
|
|
31
|
-
function buildRuntimeFetchOptions(sdkType, proxyUrl) {
|
|
32
|
-
const runtime = detectRuntime();
|
|
33
|
-
switch (runtime) {
|
|
34
|
-
case "bun": {
|
|
35
|
-
if (sdkType === "openai") {
|
|
36
|
-
return {
|
|
37
|
-
fetchOptions: {
|
|
38
|
-
timeout: false
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
} else {
|
|
42
|
-
const bunFetch = /* @__PURE__ */ __name(async (input, init) => {
|
|
43
|
-
const bunFetchOptions = {
|
|
44
|
-
...init,
|
|
45
|
-
// @ts-expect-error - Bun-specific timeout option
|
|
46
|
-
timeout: false
|
|
47
|
-
};
|
|
48
|
-
return fetch(input, bunFetchOptions);
|
|
49
|
-
}, "bunFetch");
|
|
50
|
-
return {
|
|
51
|
-
fetch: bunFetch
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
case "node": {
|
|
56
|
-
return buildFetchOptionsWithDispatcher(sdkType, proxyUrl);
|
|
57
|
-
}
|
|
58
|
-
default: {
|
|
59
|
-
return buildFetchOptionsWithDispatcher(sdkType, proxyUrl);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
__name(buildRuntimeFetchOptions, "buildRuntimeFetchOptions");
|
|
64
|
-
var dispatcherCache = /* @__PURE__ */ new Map();
|
|
65
|
-
var proxyFailureCounts = /* @__PURE__ */ new Map();
|
|
66
|
-
var NO_DISPATCHER_FALLBACK = {
|
|
67
|
-
openai: void 0,
|
|
68
|
-
anthropic: {}
|
|
69
|
-
};
|
|
70
|
-
function getOrCreateSharedDispatcher(proxyUrl) {
|
|
71
|
-
const cached = dispatcherCache.get(proxyUrl);
|
|
72
|
-
if (cached) {
|
|
73
|
-
return cached;
|
|
74
|
-
}
|
|
75
|
-
const dispatcher = new import_undici.ProxyAgent({
|
|
76
|
-
uri: proxyUrl,
|
|
77
|
-
headersTimeout: 0,
|
|
78
|
-
bodyTimeout: 0,
|
|
79
|
-
keepAliveTimeout: 6e4
|
|
80
|
-
});
|
|
81
|
-
dispatcherCache.set(proxyUrl, dispatcher);
|
|
82
|
-
return dispatcher;
|
|
83
|
-
}
|
|
84
|
-
__name(getOrCreateSharedDispatcher, "getOrCreateSharedDispatcher");
|
|
85
|
-
function extractHostnameFromProxyUrl(proxyUrl) {
|
|
86
|
-
try {
|
|
87
|
-
const url = new URL(proxyUrl);
|
|
88
|
-
if (url.hostname) {
|
|
89
|
-
return url.port ? `${url.hostname}:${url.port}` : url.hostname;
|
|
90
|
-
}
|
|
91
|
-
} catch {
|
|
92
|
-
}
|
|
93
|
-
const match = proxyUrl.match(/@([^:/\s]+)(:\d+)?/);
|
|
94
|
-
return match ? match[1] + (match[2] ?? "") : redactProxyCredentials(proxyUrl);
|
|
95
|
-
}
|
|
96
|
-
__name(extractHostnameFromProxyUrl, "extractHostnameFromProxyUrl");
|
|
97
|
-
function hasPlausibleProxyPort(host) {
|
|
98
|
-
const portMatch = host.match(/:(\d{1,5})$/);
|
|
99
|
-
if (!portMatch) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
const port = Number(portMatch[1]);
|
|
103
|
-
return port >= 80 && port <= 65535;
|
|
104
|
-
}
|
|
105
|
-
__name(hasPlausibleProxyPort, "hasPlausibleProxyPort");
|
|
106
|
-
function hasLocalOrProxyLikeHost(host) {
|
|
107
|
-
const hostWithoutPort = host.replace(/:\d{1,5}$/, "").toLowerCase();
|
|
108
|
-
if (hostWithoutPort === "localhost") {
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
if (/^\d{1,3}(\.\d{1,3}){3}$/.test(hostWithoutPort)) {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
return hostWithoutPort.split(/[.-]/).some((label) => /^(proxy|gateway|gw|squid)\d*$/.test(label));
|
|
115
|
-
}
|
|
116
|
-
__name(hasLocalOrProxyLikeHost, "hasLocalOrProxyLikeHost");
|
|
117
|
-
function hasNetworkErrorContext(message, offset) {
|
|
118
|
-
const context = message.slice(Math.max(0, offset - 80), offset).toLowerCase();
|
|
119
|
-
return /\b(connect|dispatcher|econnrefused|econnreset|enotfound|etimedout|proxy|tunnel)\b/.test(
|
|
120
|
-
context
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
__name(hasNetworkErrorContext, "hasNetworkErrorContext");
|
|
124
|
-
function shouldRedactTokenOnlyCredential(host, message, offset) {
|
|
125
|
-
return hasPlausibleProxyPort(host) && (hasLocalOrProxyLikeHost(host) || hasNetworkErrorContext(message, offset));
|
|
126
|
-
}
|
|
127
|
-
__name(shouldRedactTokenOnlyCredential, "shouldRedactTokenOnlyCredential");
|
|
128
|
-
function redactProxyCredentials(message) {
|
|
129
|
-
let result = message.replace(/\/\/[^/\s]*@/g, "//<redacted>@");
|
|
130
|
-
result = result.replace(
|
|
131
|
-
/(^|[\s([=:])([^\s/@()[\]=]+@[^@\s/()[\]=]+)/g,
|
|
132
|
-
(match, prefix, candidate, offset, message2) => {
|
|
133
|
-
const atIndex = candidate.indexOf("@");
|
|
134
|
-
const userInfo = candidate.slice(0, atIndex);
|
|
135
|
-
const host = candidate.slice(atIndex + 1);
|
|
136
|
-
if (!userInfo.includes(":") && !shouldRedactTokenOnlyCredential(host, message2, offset)) {
|
|
137
|
-
return match;
|
|
138
|
-
}
|
|
139
|
-
return `${prefix}<redacted>@${host}`;
|
|
140
|
-
}
|
|
141
|
-
);
|
|
142
|
-
return result;
|
|
143
|
-
}
|
|
144
|
-
__name(redactProxyCredentials, "redactProxyCredentials");
|
|
145
|
-
function redactProxyError(error) {
|
|
146
|
-
return redactProxyErrorValue(error, /* @__PURE__ */ new WeakMap());
|
|
147
|
-
}
|
|
148
|
-
__name(redactProxyError, "redactProxyError");
|
|
149
|
-
function redactProxyErrorValue(error, seen) {
|
|
150
|
-
if (typeof error === "string") {
|
|
151
|
-
return redactProxyCredentials(error);
|
|
152
|
-
}
|
|
153
|
-
if (!error || typeof error !== "object") {
|
|
154
|
-
return error;
|
|
155
|
-
}
|
|
156
|
-
if (seen.has(error)) {
|
|
157
|
-
return seen.get(error);
|
|
158
|
-
}
|
|
159
|
-
const errorRecord = error;
|
|
160
|
-
const needsClone = shouldCloneForRedaction(error, errorRecord);
|
|
161
|
-
const redactedMessage = typeof errorRecord.message === "string" ? redactProxyCredentials(errorRecord.message) : void 0;
|
|
162
|
-
const redactedStack = typeof errorRecord.stack === "string" ? redactProxyCredentials(errorRecord.stack) : void 0;
|
|
163
|
-
let redactedCause = errorRecord.cause;
|
|
164
|
-
let redactedErrors = errorRecord.errors;
|
|
165
|
-
if (needsClone) {
|
|
166
|
-
const clone = Object.create(Object.getPrototypeOf(error));
|
|
167
|
-
seen.set(error, clone);
|
|
168
|
-
if (errorRecord.cause !== void 0) {
|
|
169
|
-
redactedCause = redactProxyErrorValue(errorRecord.cause, seen);
|
|
170
|
-
}
|
|
171
|
-
if (errorRecord.errors !== void 0) {
|
|
172
|
-
redactedErrors = redactProxyErrorCollection(errorRecord.errors, seen);
|
|
173
|
-
}
|
|
174
|
-
cloneErrorWithRedactedFields(
|
|
175
|
-
error,
|
|
176
|
-
clone,
|
|
177
|
-
redactedMessage,
|
|
178
|
-
redactedStack,
|
|
179
|
-
redactedCause,
|
|
180
|
-
redactedErrors
|
|
181
|
-
);
|
|
182
|
-
return clone;
|
|
183
|
-
}
|
|
184
|
-
seen.set(error, error);
|
|
185
|
-
try {
|
|
186
|
-
if (redactedMessage !== void 0) {
|
|
187
|
-
errorRecord.message = redactedMessage;
|
|
188
|
-
}
|
|
189
|
-
if (redactedStack !== void 0) {
|
|
190
|
-
errorRecord.stack = redactedStack;
|
|
191
|
-
}
|
|
192
|
-
if (errorRecord.cause !== void 0) {
|
|
193
|
-
redactedCause = redactProxyErrorValue(errorRecord.cause, seen);
|
|
194
|
-
errorRecord.cause = redactedCause;
|
|
195
|
-
}
|
|
196
|
-
if (errorRecord.errors !== void 0) {
|
|
197
|
-
redactedErrors = redactProxyErrorCollection(errorRecord.errors, seen);
|
|
198
|
-
errorRecord.errors = redactedErrors;
|
|
199
|
-
}
|
|
200
|
-
return error;
|
|
201
|
-
} catch {
|
|
202
|
-
const clone = Object.create(Object.getPrototypeOf(error));
|
|
203
|
-
seen.set(error, clone);
|
|
204
|
-
if (errorRecord.cause !== void 0) {
|
|
205
|
-
redactedCause = redactProxyErrorValue(errorRecord.cause, seen);
|
|
206
|
-
}
|
|
207
|
-
if (errorRecord.errors !== void 0) {
|
|
208
|
-
redactedErrors = redactProxyErrorCollection(errorRecord.errors, seen);
|
|
209
|
-
}
|
|
210
|
-
cloneErrorWithRedactedFields(
|
|
211
|
-
error,
|
|
212
|
-
clone,
|
|
213
|
-
redactedMessage,
|
|
214
|
-
redactedStack,
|
|
215
|
-
redactedCause,
|
|
216
|
-
redactedErrors
|
|
217
|
-
);
|
|
218
|
-
return clone;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
__name(redactProxyErrorValue, "redactProxyErrorValue");
|
|
222
|
-
function redactProxyErrorCollection(errors, seen) {
|
|
223
|
-
if (!Array.isArray(errors)) {
|
|
224
|
-
return redactProxyErrorValue(errors, seen);
|
|
225
|
-
}
|
|
226
|
-
if (seen.has(errors)) {
|
|
227
|
-
return seen.get(errors);
|
|
228
|
-
}
|
|
229
|
-
const redactedErrors = [];
|
|
230
|
-
seen.set(errors, redactedErrors);
|
|
231
|
-
for (const error of errors) {
|
|
232
|
-
redactedErrors.push(redactProxyErrorValue(error, seen));
|
|
233
|
-
}
|
|
234
|
-
return redactedErrors;
|
|
235
|
-
}
|
|
236
|
-
__name(redactProxyErrorCollection, "redactProxyErrorCollection");
|
|
237
|
-
function shouldCloneForRedaction(error, errorRecord) {
|
|
238
|
-
return typeof errorRecord.message === "string" && !canAssignProperty(error, "message") || typeof errorRecord.stack === "string" && !canAssignProperty(error, "stack") || errorRecord.cause !== void 0 && !canAssignProperty(error, "cause") || errorRecord.errors !== void 0 && !canAssignProperty(error, "errors");
|
|
239
|
-
}
|
|
240
|
-
__name(shouldCloneForRedaction, "shouldCloneForRedaction");
|
|
241
|
-
function canAssignProperty(target, key) {
|
|
242
|
-
let current = target;
|
|
243
|
-
while (current) {
|
|
244
|
-
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
245
|
-
if (descriptor) {
|
|
246
|
-
if ("writable" in descriptor) {
|
|
247
|
-
return descriptor.writable === true;
|
|
248
|
-
}
|
|
249
|
-
return typeof descriptor.set === "function";
|
|
250
|
-
}
|
|
251
|
-
current = Object.getPrototypeOf(current);
|
|
252
|
-
}
|
|
253
|
-
return Object.isExtensible(target);
|
|
254
|
-
}
|
|
255
|
-
__name(canAssignProperty, "canAssignProperty");
|
|
256
|
-
function cloneErrorWithRedactedFields(error, clone, redactedMessage, redactedStack, redactedCause, redactedErrors) {
|
|
257
|
-
const copiedKeys = /* @__PURE__ */ new Set();
|
|
258
|
-
for (const key of Reflect.ownKeys(error)) {
|
|
259
|
-
const descriptor = Object.getOwnPropertyDescriptor(error, key);
|
|
260
|
-
if (!descriptor) {
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
copiedKeys.add(key);
|
|
264
|
-
const updatedDescriptor = getRedactedPropertyDescriptor(
|
|
265
|
-
key,
|
|
266
|
-
descriptor,
|
|
267
|
-
redactedMessage,
|
|
268
|
-
redactedStack,
|
|
269
|
-
redactedCause,
|
|
270
|
-
redactedErrors
|
|
271
|
-
);
|
|
272
|
-
try {
|
|
273
|
-
Object.defineProperty(clone, key, updatedDescriptor);
|
|
274
|
-
} catch {
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
defineMissingRedactedValue(clone, copiedKeys, "message", redactedMessage);
|
|
278
|
-
defineMissingRedactedValue(clone, copiedKeys, "stack", redactedStack);
|
|
279
|
-
defineMissingRedactedValue(clone, copiedKeys, "cause", redactedCause);
|
|
280
|
-
defineMissingRedactedValue(clone, copiedKeys, "errors", redactedErrors);
|
|
281
|
-
}
|
|
282
|
-
__name(cloneErrorWithRedactedFields, "cloneErrorWithRedactedFields");
|
|
283
|
-
function getRedactedPropertyDescriptor(key, descriptor, redactedMessage, redactedStack, redactedCause, redactedErrors) {
|
|
284
|
-
const redactedValue = key === "message" ? redactedMessage : key === "stack" ? redactedStack : key === "cause" ? redactedCause : key === "errors" ? redactedErrors : void 0;
|
|
285
|
-
if (redactedValue === void 0) {
|
|
286
|
-
return { ...descriptor };
|
|
287
|
-
}
|
|
288
|
-
if ("value" in descriptor) {
|
|
289
|
-
return { ...descriptor, value: redactedValue };
|
|
290
|
-
}
|
|
291
|
-
return {
|
|
292
|
-
configurable: descriptor.configurable,
|
|
293
|
-
enumerable: descriptor.enumerable,
|
|
294
|
-
value: redactedValue,
|
|
295
|
-
writable: true
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
__name(getRedactedPropertyDescriptor, "getRedactedPropertyDescriptor");
|
|
299
|
-
function defineMissingRedactedValue(target, copiedKeys, key, value) {
|
|
300
|
-
if (value === void 0 || copiedKeys.has(key)) {
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
try {
|
|
304
|
-
Object.defineProperty(target, key, {
|
|
305
|
-
configurable: true,
|
|
306
|
-
enumerable: false,
|
|
307
|
-
value,
|
|
308
|
-
writable: true
|
|
309
|
-
});
|
|
310
|
-
} catch {
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
__name(defineMissingRedactedValue, "defineMissingRedactedValue");
|
|
314
|
-
function recordProxyFailure(hostname) {
|
|
315
|
-
const failureCount = (proxyFailureCounts.get(hostname) ?? 0) + 1;
|
|
316
|
-
proxyFailureCounts.set(hostname, failureCount);
|
|
317
|
-
return failureCount;
|
|
318
|
-
}
|
|
319
|
-
__name(recordProxyFailure, "recordProxyFailure");
|
|
320
|
-
function buildFetchOptionsWithDispatcher(sdkType, proxyUrl) {
|
|
321
|
-
if (!proxyUrl) {
|
|
322
|
-
return NO_DISPATCHER_FALLBACK[sdkType];
|
|
323
|
-
}
|
|
324
|
-
try {
|
|
325
|
-
const dispatcher = getOrCreateSharedDispatcher(proxyUrl);
|
|
326
|
-
return { fetchOptions: { dispatcher }, fetch: import_undici.fetch };
|
|
327
|
-
} catch (error) {
|
|
328
|
-
const hostname = extractHostnameFromProxyUrl(proxyUrl);
|
|
329
|
-
const failureCount = recordProxyFailure(hostname);
|
|
330
|
-
const failureLabel = failureCount === 1 ? "first failure" : `failure #${failureCount}`;
|
|
331
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
332
|
-
const redactedMessage = redactProxyCredentials(errorMessage);
|
|
333
|
-
const logMessage = `Failed to create proxy dispatcher for ${hostname} (${failureLabel}), falling back to direct connection: ${redactedMessage}`;
|
|
334
|
-
debugLogger.warn(logMessage);
|
|
335
|
-
console.error(`[RUNTIME_FETCH] ${logMessage}`);
|
|
336
|
-
return NO_DISPATCHER_FALLBACK[sdkType];
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
__name(buildFetchOptionsWithDispatcher, "buildFetchOptionsWithDispatcher");
|
|
340
|
-
|
|
341
|
-
// packages/core/src/utils/request-tokenizer/textTokenizer.ts
|
|
342
|
-
init_esbuild_shims();
|
|
343
|
-
var TextTokenizer = class {
|
|
344
|
-
static {
|
|
345
|
-
__name(this, "TextTokenizer");
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Calculate tokens for text content
|
|
349
|
-
*
|
|
350
|
-
* @param text - The text to estimate tokens for
|
|
351
|
-
* @returns The estimated token count
|
|
352
|
-
*/
|
|
353
|
-
async calculateTokens(text) {
|
|
354
|
-
return this.calculateTokensSync(text);
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Calculate tokens for multiple text strings
|
|
358
|
-
*
|
|
359
|
-
* @param texts - Array of text strings to estimate tokens for
|
|
360
|
-
* @returns Array of token counts corresponding to each input text
|
|
361
|
-
*/
|
|
362
|
-
async calculateTokensBatch(texts) {
|
|
363
|
-
return texts.map((text) => this.calculateTokensSync(text));
|
|
364
|
-
}
|
|
365
|
-
calculateTokensSync(text) {
|
|
366
|
-
if (!text || text.length === 0) {
|
|
367
|
-
return 0;
|
|
368
|
-
}
|
|
369
|
-
let asciiChars = 0;
|
|
370
|
-
let nonAsciiChars = 0;
|
|
371
|
-
for (let i = 0; i < text.length; i++) {
|
|
372
|
-
const charCode = text.charCodeAt(i);
|
|
373
|
-
if (charCode < 128) {
|
|
374
|
-
asciiChars++;
|
|
375
|
-
} else {
|
|
376
|
-
nonAsciiChars++;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
const tokens = asciiChars / 4 + nonAsciiChars * 1.1;
|
|
380
|
-
return Math.ceil(tokens);
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
// packages/core/src/utils/request-tokenizer/supportedImageFormats.ts
|
|
385
|
-
init_esbuild_shims();
|
|
386
|
-
var SUPPORTED_IMAGE_MIME_TYPES = [
|
|
387
|
-
"image/bmp",
|
|
388
|
-
"image/jpeg",
|
|
389
|
-
"image/jpg",
|
|
390
|
-
// Alternative MIME type for JPEG
|
|
391
|
-
"image/png",
|
|
392
|
-
"image/tiff",
|
|
393
|
-
"image/webp",
|
|
394
|
-
"image/heic"
|
|
395
|
-
];
|
|
396
|
-
function isSupportedImageMimeType(mimeType) {
|
|
397
|
-
return SUPPORTED_IMAGE_MIME_TYPES.includes(
|
|
398
|
-
mimeType
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
__name(isSupportedImageMimeType, "isSupportedImageMimeType");
|
|
402
|
-
function getSupportedImageFormatsString() {
|
|
403
|
-
return SUPPORTED_IMAGE_MIME_TYPES.map(
|
|
404
|
-
(type) => type.replace("image/", "").toUpperCase()
|
|
405
|
-
).join(", ");
|
|
406
|
-
}
|
|
407
|
-
__name(getSupportedImageFormatsString, "getSupportedImageFormatsString");
|
|
408
|
-
function getUnsupportedImageFormatWarning() {
|
|
409
|
-
return `Only the following image formats are supported: ${getSupportedImageFormatsString()}. Other formats may not work as expected.`;
|
|
410
|
-
}
|
|
411
|
-
__name(getUnsupportedImageFormatWarning, "getUnsupportedImageFormatWarning");
|
|
412
|
-
|
|
413
|
-
export {
|
|
414
|
-
detectRuntime,
|
|
415
|
-
buildRuntimeFetchOptions,
|
|
416
|
-
getOrCreateSharedDispatcher,
|
|
417
|
-
redactProxyCredentials,
|
|
418
|
-
redactProxyError,
|
|
419
|
-
TextTokenizer,
|
|
420
|
-
SUPPORTED_IMAGE_MIME_TYPES,
|
|
421
|
-
isSupportedImageMimeType,
|
|
422
|
-
getSupportedImageFormatsString,
|
|
423
|
-
getUnsupportedImageFormatWarning
|
|
424
|
-
};
|
|
425
|
-
/**
|
|
426
|
-
* @license
|
|
427
|
-
* Copyright 2025 Qwen Team
|
|
428
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
429
|
-
*/
|
|
430
|
-
/**
|
|
431
|
-
* @license
|
|
432
|
-
* Copyright 2025 Qwen
|
|
433
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
434
|
-
*/
|