@qwen-code/qwen-code 0.8.2-preview.1 → 0.8.2
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/cli.js +366 -339
- package/package.json +2 -2
package/cli.js
CHANGED
|
@@ -20993,7 +20993,7 @@ var require_dist2 = __commonJS({
|
|
|
20993
20993
|
}
|
|
20994
20994
|
return options2;
|
|
20995
20995
|
}, "setServernameFromNonIpHost");
|
|
20996
|
-
var
|
|
20996
|
+
var HttpsProxyAgent4 = class extends agent_base_1.Agent {
|
|
20997
20997
|
static {
|
|
20998
20998
|
__name(this, "HttpsProxyAgent");
|
|
20999
20999
|
}
|
|
@@ -21075,8 +21075,8 @@ var require_dist2 = __commonJS({
|
|
|
21075
21075
|
return fakeSocket;
|
|
21076
21076
|
}
|
|
21077
21077
|
};
|
|
21078
|
-
|
|
21079
|
-
exports2.HttpsProxyAgent =
|
|
21078
|
+
HttpsProxyAgent4.protocols = ["http", "https"];
|
|
21079
|
+
exports2.HttpsProxyAgent = HttpsProxyAgent4;
|
|
21080
21080
|
function resume(socket) {
|
|
21081
21081
|
socket.resume();
|
|
21082
21082
|
}
|
|
@@ -28313,11 +28313,11 @@ var require_gaxios = __commonJS({
|
|
|
28313
28313
|
const proxy = opts.proxy || process?.env?.HTTPS_PROXY || process?.env?.https_proxy || process?.env?.HTTP_PROXY || process?.env?.http_proxy;
|
|
28314
28314
|
if (opts.agent) {
|
|
28315
28315
|
} else if (proxy && this.#urlMayUseProxy(opts.url, opts.noProxy)) {
|
|
28316
|
-
const
|
|
28316
|
+
const HttpsProxyAgent4 = await _a7.#getProxyAgent();
|
|
28317
28317
|
if (this.agentCache.has(proxy)) {
|
|
28318
28318
|
opts.agent = this.agentCache.get(proxy);
|
|
28319
28319
|
} else {
|
|
28320
|
-
opts.agent = new
|
|
28320
|
+
opts.agent = new HttpsProxyAgent4(proxy, {
|
|
28321
28321
|
cert: opts.cert,
|
|
28322
28322
|
key: opts.key
|
|
28323
28323
|
});
|
|
@@ -129795,6 +129795,30 @@ function isQwenQuotaExceededError(error2) {
|
|
|
129795
129795
|
}
|
|
129796
129796
|
return false;
|
|
129797
129797
|
}
|
|
129798
|
+
function isQwenThrottlingError(error2) {
|
|
129799
|
+
const checkMessage = /* @__PURE__ */ __name((message) => {
|
|
129800
|
+
const lowerMessage = message.toLowerCase();
|
|
129801
|
+
return lowerMessage.includes("throttling") || lowerMessage.includes("requests throttling triggered") || lowerMessage.includes("rate limit") || lowerMessage.includes("too many requests");
|
|
129802
|
+
}, "checkMessage");
|
|
129803
|
+
const getStatusCode = /* @__PURE__ */ __name((error3) => {
|
|
129804
|
+
if (error3 && typeof error3 === "object") {
|
|
129805
|
+
const errorObj = error3;
|
|
129806
|
+
return errorObj.status || errorObj.code;
|
|
129807
|
+
}
|
|
129808
|
+
return void 0;
|
|
129809
|
+
}, "getStatusCode");
|
|
129810
|
+
const statusCode = getStatusCode(error2);
|
|
129811
|
+
if (typeof error2 === "string") {
|
|
129812
|
+
return statusCode === 429 && checkMessage(error2) || error2.includes("throttling");
|
|
129813
|
+
}
|
|
129814
|
+
if (isStructuredError(error2)) {
|
|
129815
|
+
return statusCode === 429 && checkMessage(error2.message);
|
|
129816
|
+
}
|
|
129817
|
+
if (isApiError(error2)) {
|
|
129818
|
+
return error2.error.code === 429 && checkMessage(error2.error.message);
|
|
129819
|
+
}
|
|
129820
|
+
return false;
|
|
129821
|
+
}
|
|
129798
129822
|
var init_quotaErrorDetection = __esm({
|
|
129799
129823
|
"packages/core/dist/src/utils/quotaErrorDetection.js"() {
|
|
129800
129824
|
"use strict";
|
|
@@ -129802,6 +129826,7 @@ var init_quotaErrorDetection = __esm({
|
|
|
129802
129826
|
__name(isApiError, "isApiError");
|
|
129803
129827
|
__name(isStructuredError, "isStructuredError");
|
|
129804
129828
|
__name(isQwenQuotaExceededError, "isQwenQuotaExceededError");
|
|
129829
|
+
__name(isQwenThrottlingError, "isQwenThrottlingError");
|
|
129805
129830
|
}
|
|
129806
129831
|
});
|
|
129807
129832
|
|
|
@@ -140591,43 +140616,33 @@ function buildRuntimeFetchOptions(sdkType, proxyUrl) {
|
|
|
140591
140616
|
}
|
|
140592
140617
|
}
|
|
140593
140618
|
case "node": {
|
|
140594
|
-
|
|
140595
|
-
|
|
140596
|
-
|
|
140597
|
-
return {
|
|
140598
|
-
|
|
140599
|
-
};
|
|
140600
|
-
} else {
|
|
140601
|
-
return {
|
|
140602
|
-
httpAgent: dispatcher
|
|
140603
|
-
};
|
|
140604
|
-
}
|
|
140605
|
-
} catch {
|
|
140606
|
-
if (sdkType === "openai") {
|
|
140619
|
+
if (sdkType === "openai") {
|
|
140620
|
+
try {
|
|
140621
|
+
const dispatcher = createDispatcher(proxyUrl);
|
|
140622
|
+
return { dispatcher };
|
|
140623
|
+
} catch {
|
|
140607
140624
|
return void 0;
|
|
140608
|
-
} else {
|
|
140609
|
-
return {};
|
|
140610
140625
|
}
|
|
140626
|
+
} else {
|
|
140627
|
+
if (proxyUrl) {
|
|
140628
|
+
return { httpAgent: new import_https_proxy_agent2.HttpsProxyAgent(proxyUrl) };
|
|
140629
|
+
}
|
|
140630
|
+
return {};
|
|
140611
140631
|
}
|
|
140612
140632
|
}
|
|
140613
140633
|
default: {
|
|
140614
|
-
|
|
140615
|
-
|
|
140616
|
-
|
|
140617
|
-
return {
|
|
140618
|
-
|
|
140619
|
-
};
|
|
140620
|
-
} else {
|
|
140621
|
-
return {
|
|
140622
|
-
httpAgent: dispatcher
|
|
140623
|
-
};
|
|
140624
|
-
}
|
|
140625
|
-
} catch {
|
|
140626
|
-
if (sdkType === "openai") {
|
|
140634
|
+
if (sdkType === "openai") {
|
|
140635
|
+
try {
|
|
140636
|
+
const dispatcher = createDispatcher(proxyUrl);
|
|
140637
|
+
return { dispatcher };
|
|
140638
|
+
} catch {
|
|
140627
140639
|
return void 0;
|
|
140628
|
-
} else {
|
|
140629
|
-
return {};
|
|
140630
140640
|
}
|
|
140641
|
+
} else {
|
|
140642
|
+
if (proxyUrl) {
|
|
140643
|
+
return { httpAgent: new import_https_proxy_agent2.HttpsProxyAgent(proxyUrl) };
|
|
140644
|
+
}
|
|
140645
|
+
return {};
|
|
140631
140646
|
}
|
|
140632
140647
|
}
|
|
140633
140648
|
}
|
|
@@ -140645,12 +140660,13 @@ function createDispatcher(proxyUrl) {
|
|
|
140645
140660
|
bodyTimeout: 0
|
|
140646
140661
|
});
|
|
140647
140662
|
}
|
|
140648
|
-
var import_undici;
|
|
140663
|
+
var import_undici, import_https_proxy_agent2;
|
|
140649
140664
|
var init_runtimeFetchOptions = __esm({
|
|
140650
140665
|
"packages/core/dist/src/utils/runtimeFetchOptions.js"() {
|
|
140651
140666
|
"use strict";
|
|
140652
140667
|
init_esbuild_shims();
|
|
140653
140668
|
import_undici = __toESM(require_undici(), 1);
|
|
140669
|
+
import_https_proxy_agent2 = __toESM(require_dist2(), 1);
|
|
140654
140670
|
__name(detectRuntime, "detectRuntime");
|
|
140655
140671
|
__name(buildRuntimeFetchOptions, "buildRuntimeFetchOptions");
|
|
140656
140672
|
__name(createDispatcher, "createDispatcher");
|
|
@@ -155640,7 +155656,7 @@ __export(geminiContentGenerator_exports, {
|
|
|
155640
155656
|
createGeminiContentGenerator: () => createGeminiContentGenerator
|
|
155641
155657
|
});
|
|
155642
155658
|
function createGeminiContentGenerator(config2, gcConfig) {
|
|
155643
|
-
const version2 = "0.8.2
|
|
155659
|
+
const version2 = "0.8.2";
|
|
155644
155660
|
const userAgent2 = config2.userAgent || `QwenCode/${version2} (${process.platform}; ${process.arch})`;
|
|
155645
155661
|
const baseHeaders = {
|
|
155646
155662
|
"User-Agent": userAgent2
|
|
@@ -155809,8 +155825,19 @@ var init_contentGenerator = __esm({
|
|
|
155809
155825
|
|
|
155810
155826
|
// packages/core/dist/src/utils/retry.js
|
|
155811
155827
|
function defaultShouldRetry(error2) {
|
|
155812
|
-
|
|
155813
|
-
|
|
155828
|
+
if (error2 && typeof error2.status === "number") {
|
|
155829
|
+
const status = error2.status;
|
|
155830
|
+
if (status === 429 || status >= 500 && status < 600) {
|
|
155831
|
+
return true;
|
|
155832
|
+
}
|
|
155833
|
+
}
|
|
155834
|
+
if (error2 instanceof Error && error2.message) {
|
|
155835
|
+
if (error2.message.includes("429"))
|
|
155836
|
+
return true;
|
|
155837
|
+
if (error2.message.match(/5\d{2}/))
|
|
155838
|
+
return true;
|
|
155839
|
+
}
|
|
155840
|
+
return false;
|
|
155814
155841
|
}
|
|
155815
155842
|
function delay(ms) {
|
|
155816
155843
|
return new Promise((resolve28) => setTimeout(resolve28, ms));
|
|
@@ -155826,6 +155853,7 @@ async function retryWithBackoff(fn, options2) {
|
|
|
155826
155853
|
};
|
|
155827
155854
|
let attempt = 0;
|
|
155828
155855
|
let currentDelay = initialDelayMs;
|
|
155856
|
+
let consecutive429Count = 0;
|
|
155829
155857
|
while (attempt < maxAttempts) {
|
|
155830
155858
|
attempt++;
|
|
155831
155859
|
try {
|
|
@@ -155843,13 +155871,23 @@ async function retryWithBackoff(fn, options2) {
|
|
|
155843
155871
|
if (authType === AuthType2.QWEN_OAUTH && isQwenQuotaExceededError(error2)) {
|
|
155844
155872
|
throw new Error(`Qwen API quota exceeded: Your Qwen API quota has been exhausted. Please wait for your quota to reset.`);
|
|
155845
155873
|
}
|
|
155874
|
+
if (errorStatus === 429) {
|
|
155875
|
+
if (authType === AuthType2.QWEN_OAUTH && isQwenThrottlingError(error2)) {
|
|
155876
|
+
consecutive429Count = 0;
|
|
155877
|
+
} else {
|
|
155878
|
+
consecutive429Count++;
|
|
155879
|
+
}
|
|
155880
|
+
} else {
|
|
155881
|
+
consecutive429Count = 0;
|
|
155882
|
+
}
|
|
155883
|
+
console.debug("consecutive429Count", consecutive429Count);
|
|
155846
155884
|
if (attempt >= maxAttempts || !shouldRetryOnError(error2)) {
|
|
155847
155885
|
throw error2;
|
|
155848
155886
|
}
|
|
155849
|
-
const
|
|
155850
|
-
if (
|
|
155851
|
-
console.warn(`Attempt ${attempt} failed with status ${
|
|
155852
|
-
await delay(
|
|
155887
|
+
const { delayDurationMs, errorStatus: delayErrorStatus } = getDelayDurationAndStatus(error2);
|
|
155888
|
+
if (delayDurationMs > 0) {
|
|
155889
|
+
console.warn(`Attempt ${attempt} failed with status ${delayErrorStatus ?? "unknown"}. Retrying after explicit delay of ${delayDurationMs}ms...`, error2);
|
|
155890
|
+
await delay(delayDurationMs);
|
|
155853
155891
|
currentDelay = initialDelayMs;
|
|
155854
155892
|
} else {
|
|
155855
155893
|
logRetryAttempt(attempt, error2, errorStatus);
|
|
@@ -155863,12 +155901,18 @@ async function retryWithBackoff(fn, options2) {
|
|
|
155863
155901
|
throw new Error("Retry attempts exhausted");
|
|
155864
155902
|
}
|
|
155865
155903
|
function getErrorStatus(error2) {
|
|
155866
|
-
if (typeof error2
|
|
155867
|
-
|
|
155904
|
+
if (typeof error2 === "object" && error2 !== null) {
|
|
155905
|
+
if ("status" in error2 && typeof error2.status === "number") {
|
|
155906
|
+
return error2.status;
|
|
155907
|
+
}
|
|
155908
|
+
if ("response" in error2 && typeof error2.response === "object" && error2.response !== null) {
|
|
155909
|
+
const response = error2.response;
|
|
155910
|
+
if ("status" in response && typeof response.status === "number") {
|
|
155911
|
+
return response.status;
|
|
155912
|
+
}
|
|
155913
|
+
}
|
|
155868
155914
|
}
|
|
155869
|
-
|
|
155870
|
-
const value = err.status ?? err.statusCode ?? err.response?.status ?? err.error?.code;
|
|
155871
|
-
return typeof value === "number" && value >= 100 && value <= 599 ? value : void 0;
|
|
155915
|
+
return void 0;
|
|
155872
155916
|
}
|
|
155873
155917
|
function getRetryAfterDelayMs(error2) {
|
|
155874
155918
|
if (typeof error2 === "object" && error2 !== null) {
|
|
@@ -155892,12 +155936,31 @@ function getRetryAfterDelayMs(error2) {
|
|
|
155892
155936
|
}
|
|
155893
155937
|
return 0;
|
|
155894
155938
|
}
|
|
155939
|
+
function getDelayDurationAndStatus(error2) {
|
|
155940
|
+
const errorStatus = getErrorStatus(error2);
|
|
155941
|
+
let delayDurationMs = 0;
|
|
155942
|
+
if (errorStatus === 429) {
|
|
155943
|
+
delayDurationMs = getRetryAfterDelayMs(error2);
|
|
155944
|
+
}
|
|
155945
|
+
return { delayDurationMs, errorStatus };
|
|
155946
|
+
}
|
|
155895
155947
|
function logRetryAttempt(attempt, error2, errorStatus) {
|
|
155896
|
-
|
|
155948
|
+
let message = `Attempt ${attempt} failed. Retrying with backoff...`;
|
|
155949
|
+
if (errorStatus) {
|
|
155950
|
+
message = `Attempt ${attempt} failed with status ${errorStatus}. Retrying with backoff...`;
|
|
155951
|
+
}
|
|
155897
155952
|
if (errorStatus === 429) {
|
|
155898
155953
|
console.warn(message, error2);
|
|
155899
155954
|
} else if (errorStatus && errorStatus >= 500 && errorStatus < 600) {
|
|
155900
155955
|
console.error(message, error2);
|
|
155956
|
+
} else if (error2 instanceof Error) {
|
|
155957
|
+
if (error2.message.includes("429")) {
|
|
155958
|
+
console.warn(`Attempt ${attempt} failed with 429 error (no Retry-After header). Retrying with backoff...`, error2);
|
|
155959
|
+
} else if (error2.message.match(/5\d{2}/)) {
|
|
155960
|
+
console.error(`Attempt ${attempt} failed with 5xx error. Retrying with backoff...`, error2);
|
|
155961
|
+
} else {
|
|
155962
|
+
console.warn(message, error2);
|
|
155963
|
+
}
|
|
155901
155964
|
} else {
|
|
155902
155965
|
console.warn(message, error2);
|
|
155903
155966
|
}
|
|
@@ -155910,8 +155973,8 @@ var init_retry = __esm({
|
|
|
155910
155973
|
init_contentGenerator();
|
|
155911
155974
|
init_quotaErrorDetection();
|
|
155912
155975
|
DEFAULT_RETRY_OPTIONS = {
|
|
155913
|
-
maxAttempts:
|
|
155914
|
-
initialDelayMs:
|
|
155976
|
+
maxAttempts: 5,
|
|
155977
|
+
initialDelayMs: 5e3,
|
|
155915
155978
|
maxDelayMs: 3e4,
|
|
155916
155979
|
// 30 seconds
|
|
155917
155980
|
shouldRetryOnError: defaultShouldRetry
|
|
@@ -155921,6 +155984,7 @@ var init_retry = __esm({
|
|
|
155921
155984
|
__name(retryWithBackoff, "retryWithBackoff");
|
|
155922
155985
|
__name(getErrorStatus, "getErrorStatus");
|
|
155923
155986
|
__name(getRetryAfterDelayMs, "getRetryAfterDelayMs");
|
|
155987
|
+
__name(getDelayDurationAndStatus, "getDelayDurationAndStatus");
|
|
155924
155988
|
__name(logRetryAttempt, "logRetryAttempt");
|
|
155925
155989
|
}
|
|
155926
155990
|
});
|
|
@@ -156024,7 +156088,7 @@ var init_baseLlmClient = __esm({
|
|
|
156024
156088
|
init_errors();
|
|
156025
156089
|
init_retry();
|
|
156026
156090
|
init_generateContentResponseUtilities();
|
|
156027
|
-
DEFAULT_MAX_ATTEMPTS =
|
|
156091
|
+
DEFAULT_MAX_ATTEMPTS = 5;
|
|
156028
156092
|
BaseLlmClient = class {
|
|
156029
156093
|
static {
|
|
156030
156094
|
__name(this, "BaseLlmClient");
|
|
@@ -156464,6 +156528,42 @@ var init_chatRecordingService = __esm({
|
|
|
156464
156528
|
}
|
|
156465
156529
|
});
|
|
156466
156530
|
|
|
156531
|
+
// packages/core/dist/src/fallback/handler.js
|
|
156532
|
+
async function handleFallback(config2, failedModel, authType, error2) {
|
|
156533
|
+
if (authType === AuthType2.QWEN_OAUTH) {
|
|
156534
|
+
return handleQwenOAuthError(error2);
|
|
156535
|
+
}
|
|
156536
|
+
return null;
|
|
156537
|
+
}
|
|
156538
|
+
async function handleQwenOAuthError(error2) {
|
|
156539
|
+
if (!error2) {
|
|
156540
|
+
return null;
|
|
156541
|
+
}
|
|
156542
|
+
const errorMessage = error2 instanceof Error ? error2.message.toLowerCase() : String(error2).toLowerCase();
|
|
156543
|
+
const errorCode = error2?.status || error2?.code;
|
|
156544
|
+
const isAuthError = errorCode === 401 || errorCode === 403 || errorMessage.includes("unauthorized") || errorMessage.includes("forbidden") || errorMessage.includes("invalid api key") || errorMessage.includes("authentication") || errorMessage.includes("access denied") || errorMessage.includes("token") && errorMessage.includes("expired");
|
|
156545
|
+
const isRateLimitError = errorCode === 429 || errorMessage.includes("429") || errorMessage.includes("rate limit") || errorMessage.includes("too many requests");
|
|
156546
|
+
if (isAuthError) {
|
|
156547
|
+
console.warn("Qwen OAuth authentication error detected:", errorMessage);
|
|
156548
|
+
console.log("Note: If this persists, you may need to re-authenticate with Qwen OAuth");
|
|
156549
|
+
return null;
|
|
156550
|
+
}
|
|
156551
|
+
if (isRateLimitError) {
|
|
156552
|
+
console.warn("Qwen API rate limit encountered:", errorMessage);
|
|
156553
|
+
return null;
|
|
156554
|
+
}
|
|
156555
|
+
return null;
|
|
156556
|
+
}
|
|
156557
|
+
var init_handler = __esm({
|
|
156558
|
+
"packages/core/dist/src/fallback/handler.js"() {
|
|
156559
|
+
"use strict";
|
|
156560
|
+
init_esbuild_shims();
|
|
156561
|
+
init_contentGenerator();
|
|
156562
|
+
__name(handleFallback, "handleFallback");
|
|
156563
|
+
__name(handleQwenOAuthError, "handleQwenOAuthError");
|
|
156564
|
+
}
|
|
156565
|
+
});
|
|
156566
|
+
|
|
156467
156567
|
// packages/core/dist/src/core/geminiChat.js
|
|
156468
156568
|
function isValidResponse2(response) {
|
|
156469
156569
|
if (response.usageMetadata) {
|
|
@@ -156553,6 +156653,7 @@ var init_geminiChat = __esm({
|
|
|
156553
156653
|
init_loggers();
|
|
156554
156654
|
init_chatRecordingService();
|
|
156555
156655
|
init_types();
|
|
156656
|
+
init_handler();
|
|
156556
156657
|
init_uiTelemetry();
|
|
156557
156658
|
(function(StreamEventType2) {
|
|
156558
156659
|
StreamEventType2["CHUNK"] = "chunk";
|
|
@@ -156687,23 +156788,22 @@ var init_geminiChat = __esm({
|
|
|
156687
156788
|
contents: requestContents,
|
|
156688
156789
|
config: { ...this.generationConfig, ...params.config }
|
|
156689
156790
|
}, prompt_id), "apiCall");
|
|
156791
|
+
const onPersistent429Callback = /* @__PURE__ */ __name(async (authType, error2) => await handleFallback(this.config, model, authType, error2), "onPersistent429Callback");
|
|
156690
156792
|
const streamResponse2 = await retryWithBackoff(apiCall, {
|
|
156691
156793
|
shouldRetryOnError: /* @__PURE__ */ __name((error2) => {
|
|
156692
|
-
if (error2 instanceof
|
|
156693
|
-
if (
|
|
156794
|
+
if (error2 instanceof ApiError && error2.message) {
|
|
156795
|
+
if (error2.status === 400)
|
|
156694
156796
|
return false;
|
|
156695
|
-
if (
|
|
156797
|
+
if (isSchemaDepthError(error2.message))
|
|
156696
156798
|
return false;
|
|
156799
|
+
if (error2.status === 429)
|
|
156800
|
+
return true;
|
|
156801
|
+
if (error2.status >= 500 && error2.status < 600)
|
|
156802
|
+
return true;
|
|
156697
156803
|
}
|
|
156698
|
-
const status = getErrorStatus(error2);
|
|
156699
|
-
if (status === 400)
|
|
156700
|
-
return false;
|
|
156701
|
-
if (status === 429)
|
|
156702
|
-
return true;
|
|
156703
|
-
if (status && status >= 500 && status < 600)
|
|
156704
|
-
return true;
|
|
156705
156804
|
return false;
|
|
156706
156805
|
}, "shouldRetryOnError"),
|
|
156806
|
+
onPersistent429: onPersistent429Callback,
|
|
156707
156807
|
authType: this.config.getContentGeneratorConfig()?.authType
|
|
156708
156808
|
});
|
|
156709
156809
|
return this.processStreamResponse(model, streamResponse2);
|
|
@@ -171092,11 +171192,12 @@ function isShellCommandReadOnly(command2) {
|
|
|
171092
171192
|
}
|
|
171093
171193
|
const segments = splitCommands(command2);
|
|
171094
171194
|
for (const segment of segments) {
|
|
171095
|
-
|
|
171195
|
+
const isAllowed = evaluateShellSegment(segment);
|
|
171196
|
+
if (!isAllowed) {
|
|
171096
171197
|
return false;
|
|
171097
171198
|
}
|
|
171098
171199
|
}
|
|
171099
|
-
return
|
|
171200
|
+
return true;
|
|
171100
171201
|
}
|
|
171101
171202
|
var import_shell_quote, READ_ONLY_ROOT_COMMANDS, BLOCKED_FIND_FLAGS, BLOCKED_FIND_PREFIXES, READ_ONLY_GIT_SUBCOMMANDS, BLOCKED_GIT_REMOTE_ACTIONS, BLOCKED_GIT_BRANCH_FLAGS, BLOCKED_SED_PREFIXES, AWK_SIDE_EFFECT_PATTERNS, SED_SIDE_EFFECT_PATTERNS, ENV_ASSIGNMENT_REGEX;
|
|
171102
171203
|
var init_shellReadOnlyChecker = __esm({
|
|
@@ -171294,13 +171395,6 @@ function splitCommands(command2) {
|
|
|
171294
171395
|
} else if (char === ";" || char === "&" || char === "|") {
|
|
171295
171396
|
commands.push(currentCommand.trim());
|
|
171296
171397
|
currentCommand = "";
|
|
171297
|
-
} else if (char === "\r" && nextChar === "\n") {
|
|
171298
|
-
commands.push(currentCommand.trim());
|
|
171299
|
-
currentCommand = "";
|
|
171300
|
-
i3++;
|
|
171301
|
-
} else if (char === "\n") {
|
|
171302
|
-
commands.push(currentCommand.trim());
|
|
171303
|
-
currentCommand = "";
|
|
171304
171398
|
} else {
|
|
171305
171399
|
currentCommand += char;
|
|
171306
171400
|
}
|
|
@@ -172111,7 +172205,6 @@ var init_coreToolScheduler = __esm({
|
|
|
172111
172205
|
"use strict";
|
|
172112
172206
|
init_esbuild_shims();
|
|
172113
172207
|
init_src2();
|
|
172114
|
-
init_tool_names();
|
|
172115
172208
|
init_generateContentResponseUtilities();
|
|
172116
172209
|
init_modifiable_tool();
|
|
172117
172210
|
init_lib();
|
|
@@ -172327,21 +172420,15 @@ var init_coreToolScheduler = __esm({
|
|
|
172327
172420
|
}
|
|
172328
172421
|
}
|
|
172329
172422
|
/**
|
|
172330
|
-
* Generates
|
|
172331
|
-
*
|
|
172423
|
+
* Generates a suggestion string for a tool name that was not found in the registry.
|
|
172424
|
+
* Uses Levenshtein distance to suggest similar tool names for hallucinated or misspelled tools.
|
|
172425
|
+
* Note: Excluded tools are handled separately before calling this method, so this only
|
|
172426
|
+
* handles the case where a tool is truly not found (hallucinated or typo).
|
|
172427
|
+
* @param unknownToolName The tool name that was not found.
|
|
172428
|
+
* @param topN The number of suggestions to return. Defaults to 3.
|
|
172429
|
+
* @returns A suggestion string like " Did you mean 'tool'?" or " Did you mean one of: 'tool1', 'tool2'?",
|
|
172430
|
+
* or an empty string if no suggestions are found.
|
|
172332
172431
|
*/
|
|
172333
|
-
getToolNotFoundMessage(unknownToolName, topN = 3) {
|
|
172334
|
-
const skillTool = this.toolRegistry.getTool(ToolNames.SKILL);
|
|
172335
|
-
if (skillTool instanceof SkillTool) {
|
|
172336
|
-
const availableSkillNames = skillTool.getAvailableSkillNames();
|
|
172337
|
-
if (availableSkillNames.includes(unknownToolName)) {
|
|
172338
|
-
return `"${unknownToolName}" is a skill name, not a tool name. To use this skill, invoke the "${ToolNames.SKILL}" tool with parameter: skill: "${unknownToolName}"`;
|
|
172339
|
-
}
|
|
172340
|
-
}
|
|
172341
|
-
const suggestion = this.getToolSuggestion(unknownToolName, topN);
|
|
172342
|
-
return `Tool "${unknownToolName}" not found in registry. Tools must use the exact names that are registered.${suggestion}`;
|
|
172343
|
-
}
|
|
172344
|
-
/** Suggests similar tool names using Levenshtein distance. */
|
|
172345
172432
|
getToolSuggestion(unknownToolName, topN = 3) {
|
|
172346
172433
|
const allToolNames = this.toolRegistry.getAllToolNames();
|
|
172347
172434
|
const matches = allToolNames.map((toolName) => ({
|
|
@@ -172411,7 +172498,8 @@ var init_coreToolScheduler = __esm({
|
|
|
172411
172498
|
}
|
|
172412
172499
|
const toolInstance = this.toolRegistry.getTool(reqInfo.name);
|
|
172413
172500
|
if (!toolInstance) {
|
|
172414
|
-
const
|
|
172501
|
+
const suggestion = this.getToolSuggestion(reqInfo.name);
|
|
172502
|
+
const errorMessage = `Tool "${reqInfo.name}" not found in registry. Tools must use the exact names that are registered.${suggestion}`;
|
|
172415
172503
|
return {
|
|
172416
172504
|
status: "error",
|
|
172417
172505
|
request: reqInfo,
|
|
@@ -173301,15 +173389,13 @@ var init_subagent = __esm({
|
|
|
173301
173389
|
const parts = content?.parts || [];
|
|
173302
173390
|
for (const p2 of parts) {
|
|
173303
173391
|
const txt = p2.text;
|
|
173304
|
-
|
|
173305
|
-
if (txt && !isThought)
|
|
173392
|
+
if (txt)
|
|
173306
173393
|
roundText += txt;
|
|
173307
173394
|
if (txt)
|
|
173308
173395
|
this.eventEmitter?.emit(SubAgentEventType.STREAM_TEXT, {
|
|
173309
173396
|
subagentId: this.subagentId,
|
|
173310
173397
|
round: turnCounter,
|
|
173311
173398
|
text: txt,
|
|
173312
|
-
thought: isThought,
|
|
173313
173399
|
timestamp: Date.now()
|
|
173314
173400
|
});
|
|
173315
173401
|
}
|
|
@@ -179170,6 +179256,7 @@ var init_client2 = __esm({
|
|
|
179170
179256
|
init_retry();
|
|
179171
179257
|
init_ideContext();
|
|
179172
179258
|
init_types7();
|
|
179259
|
+
init_handler();
|
|
179173
179260
|
MAX_TURNS = 100;
|
|
179174
179261
|
GeminiClient = class {
|
|
179175
179262
|
static {
|
|
@@ -179536,7 +179623,12 @@ var init_client2 = __esm({
|
|
|
179536
179623
|
contents
|
|
179537
179624
|
}, this.lastPromptId);
|
|
179538
179625
|
}, "apiCall");
|
|
179626
|
+
const onPersistent429Callback = /* @__PURE__ */ __name(async (authType, error2) => (
|
|
179627
|
+
// Pass the captured model to the centralized handler.
|
|
179628
|
+
await handleFallback(this.config, currentAttemptModel, authType, error2)
|
|
179629
|
+
), "onPersistent429Callback");
|
|
179539
179630
|
const result = await retryWithBackoff(apiCall, {
|
|
179631
|
+
onPersistent429: onPersistent429Callback,
|
|
179540
179632
|
authType: this.config.getContentGeneratorConfig()?.authType
|
|
179541
179633
|
});
|
|
179542
179634
|
return result;
|
|
@@ -218674,7 +218766,7 @@ function createFsWatchInstance(path118, options2, listener, errHandler, emitRaw)
|
|
|
218674
218766
|
}
|
|
218675
218767
|
}
|
|
218676
218768
|
var STR_DATA, STR_END, STR_CLOSE, EMPTY_FN, pl, isWindows2, isMacos, isLinux, isFreeBSD, isIBMi, EVENTS, EV, THROTTLE_MODE_WATCH, statMethods, KEY_LISTENERS, KEY_ERR, KEY_RAW, HANDLER_KEYS, binaryExtensions, isBinaryPath, foreach, addAndConvert, clearItem, delFromSet, isEmptySet, FsWatchInstances, fsWatchBroadcast, setFsWatchListener, FsWatchFileInstances, setFsWatchFileListener, NodeFsHandler;
|
|
218677
|
-
var
|
|
218769
|
+
var init_handler2 = __esm({
|
|
218678
218770
|
"node_modules/chokidar/esm/handler.js"() {
|
|
218679
218771
|
init_esbuild_shims();
|
|
218680
218772
|
STR_DATA = "data";
|
|
@@ -219496,7 +219588,7 @@ var init_esm21 = __esm({
|
|
|
219496
219588
|
"node_modules/chokidar/esm/index.js"() {
|
|
219497
219589
|
init_esbuild_shims();
|
|
219498
219590
|
init_esm20();
|
|
219499
|
-
|
|
219591
|
+
init_handler2();
|
|
219500
219592
|
SLASH = "/";
|
|
219501
219593
|
SLASH_SLASH = "//";
|
|
219502
219594
|
ONE_DOT = ".";
|
|
@@ -231814,24 +231906,18 @@ async function convertClaudePluginPackage(extensionDir, pluginName) {
|
|
|
231814
231906
|
const tmpDir = await ExtensionStorage.createTmpDir();
|
|
231815
231907
|
try {
|
|
231816
231908
|
await copyDirectory(pluginSource, tmpDir);
|
|
231817
|
-
|
|
231818
|
-
|
|
231819
|
-
|
|
231820
|
-
|
|
231821
|
-
|
|
231822
|
-
|
|
231823
|
-
|
|
231824
|
-
const sourceFolderPath = path61.join(pluginSource, name3);
|
|
231825
|
-
if (config2) {
|
|
231826
|
-
if (fs59.existsSync(folderPath)) {
|
|
231827
|
-
fs59.rmSync(folderPath, { recursive: true, force: true });
|
|
231828
|
-
}
|
|
231829
|
-
await collectResources(config2, pluginSource, folderPath);
|
|
231830
|
-
} else if (!fs59.existsSync(sourceFolderPath) && fs59.existsSync(folderPath)) {
|
|
231831
|
-
fs59.rmSync(folderPath, { recursive: true, force: true });
|
|
231832
|
-
}
|
|
231909
|
+
if (mergedConfig.commands) {
|
|
231910
|
+
const commandsDestDir = path61.join(tmpDir, "commands");
|
|
231911
|
+
await collectResources(mergedConfig.commands, pluginSource, commandsDestDir);
|
|
231912
|
+
}
|
|
231913
|
+
if (mergedConfig.skills) {
|
|
231914
|
+
const skillsDestDir = path61.join(tmpDir, "skills");
|
|
231915
|
+
await collectResources(mergedConfig.skills, pluginSource, skillsDestDir);
|
|
231833
231916
|
}
|
|
231834
231917
|
const agentsDestDir = path61.join(tmpDir, "agents");
|
|
231918
|
+
if (mergedConfig.agents) {
|
|
231919
|
+
await collectResources(mergedConfig.agents, pluginSource, agentsDestDir);
|
|
231920
|
+
}
|
|
231835
231921
|
await convertAgentFiles(agentsDestDir);
|
|
231836
231922
|
const qwenConfig = convertClaudeToQwenConfig(mergedConfig);
|
|
231837
231923
|
const qwenConfigPath = path61.join(tmpDir, "qwen-extension.json");
|
|
@@ -231868,7 +231954,6 @@ async function collectResources(resourcePaths, pluginRoot, destDir) {
|
|
|
231868
231954
|
console.log(`Skipping ${resolvedPath} as it's already in the correct location`);
|
|
231869
231955
|
continue;
|
|
231870
231956
|
}
|
|
231871
|
-
const finalDestDir = path61.join(destDir, dirName);
|
|
231872
231957
|
const files = await glob("**/*", {
|
|
231873
231958
|
cwd: resolvedPath,
|
|
231874
231959
|
nodir: true,
|
|
@@ -231876,7 +231961,7 @@ async function collectResources(resourcePaths, pluginRoot, destDir) {
|
|
|
231876
231961
|
});
|
|
231877
231962
|
for (const file of files) {
|
|
231878
231963
|
const srcFile = path61.join(resolvedPath, file);
|
|
231879
|
-
const destFile = path61.join(
|
|
231964
|
+
const destFile = path61.join(destDir, file);
|
|
231880
231965
|
const destFileDir = path61.dirname(destFile);
|
|
231881
231966
|
if (!fs59.existsSync(destFileDir)) {
|
|
231882
231967
|
fs59.mkdirSync(destFileDir, { recursive: true });
|
|
@@ -241676,7 +241761,7 @@ var init_config3 = __esm({
|
|
|
241676
241761
|
contentGeneratorConfigSources = {};
|
|
241677
241762
|
contentGenerator;
|
|
241678
241763
|
embeddingModel;
|
|
241679
|
-
|
|
241764
|
+
_modelsConfig;
|
|
241680
241765
|
modelProvidersConfig;
|
|
241681
241766
|
sandbox;
|
|
241682
241767
|
targetDir;
|
|
@@ -241855,7 +241940,7 @@ var init_config3 = __esm({
|
|
|
241855
241940
|
if (params.contextFileName) {
|
|
241856
241941
|
setGeminiMdFilename(params.contextFileName);
|
|
241857
241942
|
}
|
|
241858
|
-
this.
|
|
241943
|
+
this._modelsConfig = new ModelsConfig({
|
|
241859
241944
|
initialAuthType: params.authType ?? params.generationConfig?.authType,
|
|
241860
241945
|
modelProvidersConfig: this.modelProvidersConfig,
|
|
241861
241946
|
generationConfig: {
|
|
@@ -241922,8 +242007,8 @@ var init_config3 = __esm({
|
|
|
241922
242007
|
* Get the ModelsConfig instance for model-related operations.
|
|
241923
242008
|
* External code (e.g., CLI) can use this to access model configuration.
|
|
241924
242009
|
*/
|
|
241925
|
-
|
|
241926
|
-
return this.
|
|
242010
|
+
get modelsConfig() {
|
|
242011
|
+
return this._modelsConfig;
|
|
241927
242012
|
}
|
|
241928
242013
|
/**
|
|
241929
242014
|
* Updates the credentials in the generation config.
|
|
@@ -241931,17 +242016,17 @@ var init_config3 = __esm({
|
|
|
241931
242016
|
* Delegates to ModelsConfig.
|
|
241932
242017
|
*/
|
|
241933
242018
|
updateCredentials(credentials, settingsGenerationConfig) {
|
|
241934
|
-
this.
|
|
242019
|
+
this._modelsConfig.updateCredentials(credentials, settingsGenerationConfig);
|
|
241935
242020
|
}
|
|
241936
242021
|
/**
|
|
241937
242022
|
* Refresh authentication and rebuild ContentGenerator.
|
|
241938
242023
|
*/
|
|
241939
242024
|
async refreshAuth(authMethod, isInitialAuth) {
|
|
241940
|
-
const modelId = this.
|
|
241941
|
-
this.
|
|
241942
|
-
const requireCached = this.
|
|
241943
|
-
const { config: config2, sources } = resolveContentGeneratorConfigWithSources(this, authMethod, this.
|
|
241944
|
-
strictModelProvider: this.
|
|
242025
|
+
const modelId = this._modelsConfig.getModel();
|
|
242026
|
+
this._modelsConfig.syncAfterAuthRefresh(authMethod, modelId);
|
|
242027
|
+
const requireCached = this._modelsConfig.consumeRequireCachedCredentialsFlag();
|
|
242028
|
+
const { config: config2, sources } = resolveContentGeneratorConfigWithSources(this, authMethod, this._modelsConfig.getGenerationConfig(), this._modelsConfig.getGenerationConfigSources(), {
|
|
242029
|
+
strictModelProvider: this._modelsConfig.isStrictModelProviderSelection()
|
|
241945
242030
|
});
|
|
241946
242031
|
const newContentGeneratorConfig = config2;
|
|
241947
242032
|
this.contentGenerator = await createContentGenerator(newContentGeneratorConfig, this, requireCached ? true : isInitialAuth);
|
|
@@ -241999,20 +242084,20 @@ var init_config3 = __esm({
|
|
|
241999
242084
|
return this.contentGeneratorConfig;
|
|
242000
242085
|
}
|
|
242001
242086
|
getContentGeneratorConfigSources() {
|
|
242002
|
-
if (Object.keys(this.contentGeneratorConfigSources).length === 0 && this.
|
|
242003
|
-
return this.
|
|
242087
|
+
if (Object.keys(this.contentGeneratorConfigSources).length === 0 && this._modelsConfig) {
|
|
242088
|
+
return this._modelsConfig.getGenerationConfigSources();
|
|
242004
242089
|
}
|
|
242005
242090
|
return this.contentGeneratorConfigSources;
|
|
242006
242091
|
}
|
|
242007
242092
|
getModel() {
|
|
242008
|
-
return this.contentGeneratorConfig?.model || this.
|
|
242093
|
+
return this.contentGeneratorConfig?.model || this._modelsConfig.getModel();
|
|
242009
242094
|
}
|
|
242010
242095
|
/**
|
|
242011
242096
|
* Set model programmatically (e.g., VLM auto-switch, fallback).
|
|
242012
242097
|
* Delegates to ModelsConfig.
|
|
242013
242098
|
*/
|
|
242014
242099
|
async setModel(newModel, metadata) {
|
|
242015
|
-
await this.
|
|
242100
|
+
await this._modelsConfig.setModel(newModel, metadata);
|
|
242016
242101
|
if (this.contentGeneratorConfig) {
|
|
242017
242102
|
this.contentGeneratorConfig.model = newModel;
|
|
242018
242103
|
}
|
|
@@ -242026,8 +242111,8 @@ var init_config3 = __esm({
|
|
|
242026
242111
|
return;
|
|
242027
242112
|
}
|
|
242028
242113
|
if (authType === AuthType2.QWEN_OAUTH && !requiresRefresh) {
|
|
242029
|
-
const { config: config2, sources } = resolveContentGeneratorConfigWithSources(this, authType, this.
|
|
242030
|
-
strictModelProvider: this.
|
|
242114
|
+
const { config: config2, sources } = resolveContentGeneratorConfigWithSources(this, authType, this._modelsConfig.getGenerationConfig(), this._modelsConfig.getGenerationConfigSources(), {
|
|
242115
|
+
strictModelProvider: this._modelsConfig.isStrictModelProviderSelection()
|
|
242031
242116
|
});
|
|
242032
242117
|
this.contentGeneratorConfig.model = config2.model;
|
|
242033
242118
|
this.contentGeneratorConfig.samplingParams = config2.samplingParams;
|
|
@@ -242050,14 +242135,14 @@ var init_config3 = __esm({
|
|
|
242050
242135
|
* Delegates to ModelsConfig.
|
|
242051
242136
|
*/
|
|
242052
242137
|
getAvailableModels() {
|
|
242053
|
-
return this.
|
|
242138
|
+
return this._modelsConfig.getAvailableModels();
|
|
242054
242139
|
}
|
|
242055
242140
|
/**
|
|
242056
242141
|
* Get available models for a specific authType.
|
|
242057
242142
|
* Delegates to ModelsConfig.
|
|
242058
242143
|
*/
|
|
242059
242144
|
getAvailableModelsForAuthType(authType) {
|
|
242060
|
-
return this.
|
|
242145
|
+
return this._modelsConfig.getAvailableModelsForAuthType(authType);
|
|
242061
242146
|
}
|
|
242062
242147
|
/**
|
|
242063
242148
|
* Switch authType+model via registry-backed selection.
|
|
@@ -242070,7 +242155,7 @@ var init_config3 = __esm({
|
|
|
242070
242155
|
* @param metadata - Metadata for logging/tracking
|
|
242071
242156
|
*/
|
|
242072
242157
|
async switchModel(authType, modelId, options2, metadata) {
|
|
242073
|
-
await this.
|
|
242158
|
+
await this._modelsConfig.switchModel(authType, modelId, options2, metadata);
|
|
242074
242159
|
}
|
|
242075
242160
|
getMaxSessionTurns() {
|
|
242076
242161
|
return this.maxSessionTurns;
|
|
@@ -339879,11 +339964,11 @@ var require_gaxios2 = __commonJS({
|
|
|
339879
339964
|
const proxy = opts.proxy || process?.env?.HTTPS_PROXY || process?.env?.https_proxy || process?.env?.HTTP_PROXY || process?.env?.http_proxy;
|
|
339880
339965
|
if (opts.agent) {
|
|
339881
339966
|
} else if (proxy && this.#urlMayUseProxy(opts.url, opts.noProxy)) {
|
|
339882
|
-
const
|
|
339967
|
+
const HttpsProxyAgent4 = await _a7.#getProxyAgent();
|
|
339883
339968
|
if (this.agentCache.has(proxy)) {
|
|
339884
339969
|
opts.agent = this.agentCache.get(proxy);
|
|
339885
339970
|
} else {
|
|
339886
|
-
opts.agent = new
|
|
339971
|
+
opts.agent = new HttpsProxyAgent4(proxy, {
|
|
339887
339972
|
cert: opts.cert,
|
|
339888
339973
|
key: opts.key
|
|
339889
339974
|
});
|
|
@@ -353006,7 +353091,7 @@ init_supportedImageFormats();
|
|
|
353006
353091
|
|
|
353007
353092
|
// packages/core/dist/src/telemetry/clearcut-logger/clearcut-logger.js
|
|
353008
353093
|
init_esbuild_shims();
|
|
353009
|
-
var
|
|
353094
|
+
var import_https_proxy_agent3 = __toESM(require_dist2(), 1);
|
|
353010
353095
|
|
|
353011
353096
|
// packages/core/dist/src/telemetry/clearcut-logger/event-metadata-key.js
|
|
353012
353097
|
init_esbuild_shims();
|
|
@@ -362814,7 +362899,7 @@ function findModelConfig(modelProviders, authType, modelId) {
|
|
|
362814
362899
|
__name(findModelConfig, "findModelConfig");
|
|
362815
362900
|
function hasApiKeyForAuth(authType, settings, config2) {
|
|
362816
362901
|
const modelProviders = settings.modelProviders;
|
|
362817
|
-
const modelId = config2?.
|
|
362902
|
+
const modelId = config2?.modelsConfig.getModel() ?? settings.model?.name;
|
|
362818
362903
|
const modelConfig = findModelConfig(modelProviders, authType, modelId);
|
|
362819
362904
|
if (modelConfig?.envKey) {
|
|
362820
362905
|
const hasKey2 = !!process.env[modelConfig.envKey];
|
|
@@ -362900,7 +362985,7 @@ function validateAuthMethod(authMethod, config2) {
|
|
|
362900
362985
|
return apiKeyError;
|
|
362901
362986
|
}
|
|
362902
362987
|
const modelProviders = settings.merged.modelProviders;
|
|
362903
|
-
const modelId = config2?.
|
|
362988
|
+
const modelId = config2?.modelsConfig.getModel() ?? settings.merged.model?.name;
|
|
362904
362989
|
const modelConfig = findModelConfig(modelProviders, authMethod, modelId);
|
|
362905
362990
|
if (modelConfig && !modelConfig.baseUrl) {
|
|
362906
362991
|
return t4(
|
|
@@ -369381,7 +369466,7 @@ __name(getPackageJson, "getPackageJson");
|
|
|
369381
369466
|
// packages/cli/src/utils/version.ts
|
|
369382
369467
|
async function getCliVersion() {
|
|
369383
369468
|
const pkgJson = await getPackageJson();
|
|
369384
|
-
return "0.8.2
|
|
369469
|
+
return "0.8.2";
|
|
369385
369470
|
}
|
|
369386
369471
|
__name(getCliVersion, "getCliVersion");
|
|
369387
369472
|
|
|
@@ -376466,11 +376551,125 @@ function validateTheme(settings) {
|
|
|
376466
376551
|
}
|
|
376467
376552
|
__name(validateTheme, "validateTheme");
|
|
376468
376553
|
|
|
376554
|
+
// packages/cli/src/utils/languageUtils.ts
|
|
376555
|
+
init_esbuild_shims();
|
|
376556
|
+
import * as fs78 from "node:fs";
|
|
376557
|
+
import * as path86 from "node:path";
|
|
376558
|
+
var LLM_OUTPUT_LANGUAGE_RULE_FILENAME = "output-language.md";
|
|
376559
|
+
var LLM_OUTPUT_LANGUAGE_MARKER_PREFIX = "qwen-code:llm-output-language:";
|
|
376560
|
+
var OUTPUT_LANGUAGE_AUTO = "auto";
|
|
376561
|
+
function isAutoLanguage(value) {
|
|
376562
|
+
return !value || value.toLowerCase() === OUTPUT_LANGUAGE_AUTO;
|
|
376563
|
+
}
|
|
376564
|
+
__name(isAutoLanguage, "isAutoLanguage");
|
|
376565
|
+
function normalizeOutputLanguage(language) {
|
|
376566
|
+
const lowered = language.toLowerCase();
|
|
376567
|
+
const fullName = getLanguageNameFromLocale(lowered);
|
|
376568
|
+
if (fullName !== "English" || lowered === "en") {
|
|
376569
|
+
return fullName;
|
|
376570
|
+
}
|
|
376571
|
+
return language;
|
|
376572
|
+
}
|
|
376573
|
+
__name(normalizeOutputLanguage, "normalizeOutputLanguage");
|
|
376574
|
+
function resolveOutputLanguage(value) {
|
|
376575
|
+
if (isAutoLanguage(value)) {
|
|
376576
|
+
const detectedLocale = detectSystemLanguage();
|
|
376577
|
+
return getLanguageNameFromLocale(detectedLocale);
|
|
376578
|
+
}
|
|
376579
|
+
return normalizeOutputLanguage(value);
|
|
376580
|
+
}
|
|
376581
|
+
__name(resolveOutputLanguage, "resolveOutputLanguage");
|
|
376582
|
+
function getOutputLanguageFilePath() {
|
|
376583
|
+
return path86.join(
|
|
376584
|
+
Storage.getGlobalQwenDir(),
|
|
376585
|
+
LLM_OUTPUT_LANGUAGE_RULE_FILENAME
|
|
376586
|
+
);
|
|
376587
|
+
}
|
|
376588
|
+
__name(getOutputLanguageFilePath, "getOutputLanguageFilePath");
|
|
376589
|
+
function sanitizeForMarker(language) {
|
|
376590
|
+
return language.replace(/[\r\n]/g, " ").replace(/--!?>/g, "").replace(/--/g, "");
|
|
376591
|
+
}
|
|
376592
|
+
__name(sanitizeForMarker, "sanitizeForMarker");
|
|
376593
|
+
function generateOutputLanguageFileContent(language) {
|
|
376594
|
+
const safeLanguage = sanitizeForMarker(language);
|
|
376595
|
+
return `# Output language preference: ${language}
|
|
376596
|
+
<!-- ${LLM_OUTPUT_LANGUAGE_MARKER_PREFIX} ${safeLanguage} -->
|
|
376597
|
+
|
|
376598
|
+
## Goal
|
|
376599
|
+
Prefer responding in **${language}** for normal assistant messages and explanations.
|
|
376600
|
+
|
|
376601
|
+
## Keep technical artifacts unchanged
|
|
376602
|
+
Do **not** translate or rewrite:
|
|
376603
|
+
- Code blocks, CLI commands, file paths, stack traces, logs, JSON keys, identifiers
|
|
376604
|
+
- Exact quoted text from the user (keep quotes verbatim)
|
|
376605
|
+
|
|
376606
|
+
## When a conflict exists
|
|
376607
|
+
If higher-priority instructions (system/developer) require a different behavior, follow them.
|
|
376608
|
+
|
|
376609
|
+
## Tool / system outputs
|
|
376610
|
+
Raw tool/system outputs may contain fixed-format English. Preserve them verbatim, and if needed, add a short **${language}** explanation below.
|
|
376611
|
+
`;
|
|
376612
|
+
}
|
|
376613
|
+
__name(generateOutputLanguageFileContent, "generateOutputLanguageFileContent");
|
|
376614
|
+
function parseOutputLanguageFromContent(content) {
|
|
376615
|
+
const markerRegex = new RegExp(
|
|
376616
|
+
String.raw`<!--\s*${LLM_OUTPUT_LANGUAGE_MARKER_PREFIX}\s*(.*?)\s*-->`,
|
|
376617
|
+
"i"
|
|
376618
|
+
);
|
|
376619
|
+
const markerMatch = content.match(markerRegex);
|
|
376620
|
+
if (markerMatch?.[1]?.trim()) {
|
|
376621
|
+
return markerMatch[1].trim();
|
|
376622
|
+
}
|
|
376623
|
+
const headingMatch = content.match(
|
|
376624
|
+
/^#.*?CRITICAL:\s*(.*?)\s+Output Language Rule\b/im
|
|
376625
|
+
);
|
|
376626
|
+
if (headingMatch?.[1]?.trim()) {
|
|
376627
|
+
return headingMatch[1].trim();
|
|
376628
|
+
}
|
|
376629
|
+
return null;
|
|
376630
|
+
}
|
|
376631
|
+
__name(parseOutputLanguageFromContent, "parseOutputLanguageFromContent");
|
|
376632
|
+
function readOutputLanguageFromFile() {
|
|
376633
|
+
const filePath = getOutputLanguageFilePath();
|
|
376634
|
+
if (!fs78.existsSync(filePath)) {
|
|
376635
|
+
return null;
|
|
376636
|
+
}
|
|
376637
|
+
try {
|
|
376638
|
+
const content = fs78.readFileSync(filePath, "utf-8");
|
|
376639
|
+
return parseOutputLanguageFromContent(content);
|
|
376640
|
+
} catch {
|
|
376641
|
+
return null;
|
|
376642
|
+
}
|
|
376643
|
+
}
|
|
376644
|
+
__name(readOutputLanguageFromFile, "readOutputLanguageFromFile");
|
|
376645
|
+
function writeOutputLanguageFile(language) {
|
|
376646
|
+
const filePath = getOutputLanguageFilePath();
|
|
376647
|
+
const content = generateOutputLanguageFileContent(language);
|
|
376648
|
+
const dir = path86.dirname(filePath);
|
|
376649
|
+
fs78.mkdirSync(dir, { recursive: true });
|
|
376650
|
+
fs78.writeFileSync(filePath, content, "utf-8");
|
|
376651
|
+
}
|
|
376652
|
+
__name(writeOutputLanguageFile, "writeOutputLanguageFile");
|
|
376653
|
+
function updateOutputLanguageFile(settingValue) {
|
|
376654
|
+
const resolved = resolveOutputLanguage(settingValue);
|
|
376655
|
+
writeOutputLanguageFile(resolved);
|
|
376656
|
+
}
|
|
376657
|
+
__name(updateOutputLanguageFile, "updateOutputLanguageFile");
|
|
376658
|
+
function initializeLlmOutputLanguage(outputLanguage) {
|
|
376659
|
+
const resolved = resolveOutputLanguage(outputLanguage);
|
|
376660
|
+
const currentFileLanguage = readOutputLanguageFromFile();
|
|
376661
|
+
if (currentFileLanguage !== resolved) {
|
|
376662
|
+
writeOutputLanguageFile(resolved);
|
|
376663
|
+
}
|
|
376664
|
+
}
|
|
376665
|
+
__name(initializeLlmOutputLanguage, "initializeLlmOutputLanguage");
|
|
376666
|
+
|
|
376469
376667
|
// packages/cli/src/core/initializer.ts
|
|
376470
376668
|
async function initializeApp(config2, settings) {
|
|
376471
376669
|
const languageSetting = process.env["QWEN_CODE_LANG"] || settings.merged.general?.language || "auto";
|
|
376472
376670
|
await initializeI18n(languageSetting);
|
|
376473
|
-
|
|
376671
|
+
initializeLlmOutputLanguage(settings.merged.general?.outputLanguage);
|
|
376672
|
+
const authType = config2.modelsConfig.getCurrentAuthType();
|
|
376474
376673
|
const authError = await performInitialAuth(config2, authType);
|
|
376475
376674
|
if (authError) {
|
|
376476
376675
|
settings.setValue(
|
|
@@ -376480,7 +376679,7 @@ async function initializeApp(config2, settings) {
|
|
|
376480
376679
|
);
|
|
376481
376680
|
}
|
|
376482
376681
|
const themeError = validateTheme(settings);
|
|
376483
|
-
const shouldOpenAuthDialog = !config2.
|
|
376682
|
+
const shouldOpenAuthDialog = !config2.modelsConfig.wasAuthTypeExplicitlyProvided() || !!authError;
|
|
376484
376683
|
if (config2.getIdeMode()) {
|
|
376485
376684
|
const ideClient = await IdeClient.getInstance();
|
|
376486
376685
|
await ideClient.connect();
|
|
@@ -376887,7 +377086,7 @@ var formatDuration = /* @__PURE__ */ __name((milliseconds) => {
|
|
|
376887
377086
|
|
|
376888
377087
|
// packages/cli/src/generated/git-commit.ts
|
|
376889
377088
|
init_esbuild_shims();
|
|
376890
|
-
var GIT_COMMIT_INFO2 = "
|
|
377089
|
+
var GIT_COMMIT_INFO2 = "bb53d92d";
|
|
376891
377090
|
|
|
376892
377091
|
// packages/cli/src/utils/systemInfo.ts
|
|
376893
377092
|
async function getNpmVersion() {
|
|
@@ -377501,7 +377700,7 @@ var docsCommand = {
|
|
|
377501
377700
|
// packages/cli/src/ui/commands/directoryCommand.tsx
|
|
377502
377701
|
init_esbuild_shims();
|
|
377503
377702
|
import * as os31 from "node:os";
|
|
377504
|
-
import * as
|
|
377703
|
+
import * as path87 from "node:path";
|
|
377505
377704
|
function expandHomeDir(p2) {
|
|
377506
377705
|
if (!p2) {
|
|
377507
377706
|
return "";
|
|
@@ -377512,7 +377711,7 @@ function expandHomeDir(p2) {
|
|
|
377512
377711
|
} else if (p2 === "~" || p2.startsWith("~/")) {
|
|
377513
377712
|
expandedPath = os31.homedir() + p2.substring(1);
|
|
377514
377713
|
}
|
|
377515
|
-
return
|
|
377714
|
+
return path87.normalize(expandedPath);
|
|
377516
377715
|
}
|
|
377517
377716
|
__name(expandHomeDir, "expandHomeDir");
|
|
377518
377717
|
var directoryCommand = {
|
|
@@ -378297,7 +378496,7 @@ var helpCommand = {
|
|
|
378297
378496
|
|
|
378298
378497
|
// packages/cli/src/ui/commands/ideCommand.ts
|
|
378299
378498
|
init_esbuild_shims();
|
|
378300
|
-
import
|
|
378499
|
+
import path88 from "node:path";
|
|
378301
378500
|
function getIdeStatusMessage(ideClient) {
|
|
378302
378501
|
const connection = ideClient.getConnectionStatus();
|
|
378303
378502
|
switch (connection.status) {
|
|
@@ -378327,13 +378526,13 @@ __name(getIdeStatusMessage, "getIdeStatusMessage");
|
|
|
378327
378526
|
function formatFileList(openFiles) {
|
|
378328
378527
|
const basenameCounts = /* @__PURE__ */ new Map();
|
|
378329
378528
|
for (const file of openFiles) {
|
|
378330
|
-
const basename24 =
|
|
378529
|
+
const basename24 = path88.basename(file.path);
|
|
378331
378530
|
basenameCounts.set(basename24, (basenameCounts.get(basename24) || 0) + 1);
|
|
378332
378531
|
}
|
|
378333
378532
|
const fileList = openFiles.map((file) => {
|
|
378334
|
-
const basename24 =
|
|
378533
|
+
const basename24 = path88.basename(file.path);
|
|
378335
378534
|
const isDuplicate = (basenameCounts.get(basename24) || 0) > 1;
|
|
378336
|
-
const parentDir =
|
|
378535
|
+
const parentDir = path88.basename(path88.dirname(file.path));
|
|
378337
378536
|
const displayName = isDuplicate ? `${basename24} (/${parentDir})` : basename24;
|
|
378338
378537
|
return ` - ${displayName}${file.isActive ? " (active)" : ""}`;
|
|
378339
378538
|
}).join("\n");
|
|
@@ -378576,8 +378775,8 @@ var ideCommand = /* @__PURE__ */ __name(async () => {
|
|
|
378576
378775
|
|
|
378577
378776
|
// packages/cli/src/ui/commands/initCommand.ts
|
|
378578
378777
|
init_esbuild_shims();
|
|
378579
|
-
import * as
|
|
378580
|
-
import * as
|
|
378778
|
+
import * as fs79 from "node:fs";
|
|
378779
|
+
import * as path89 from "node:path";
|
|
378581
378780
|
var import_react27 = __toESM(require_react(), 1);
|
|
378582
378781
|
var initCommand = {
|
|
378583
378782
|
name: "init",
|
|
@@ -378595,11 +378794,11 @@ var initCommand = {
|
|
|
378595
378794
|
}
|
|
378596
378795
|
const targetDir = context2.services.config.getTargetDir();
|
|
378597
378796
|
const contextFileName = getCurrentGeminiMdFilename();
|
|
378598
|
-
const contextFilePath =
|
|
378797
|
+
const contextFilePath = path89.join(targetDir, contextFileName);
|
|
378599
378798
|
try {
|
|
378600
|
-
if (
|
|
378799
|
+
if (fs79.existsSync(contextFilePath)) {
|
|
378601
378800
|
try {
|
|
378602
|
-
const existing =
|
|
378801
|
+
const existing = fs79.readFileSync(contextFilePath, "utf8");
|
|
378603
378802
|
if (existing && existing.trim().length > 0) {
|
|
378604
378803
|
if (!context2.overwriteConfirmed) {
|
|
378605
378804
|
return {
|
|
@@ -378621,7 +378820,7 @@ var initCommand = {
|
|
|
378621
378820
|
}
|
|
378622
378821
|
}
|
|
378623
378822
|
try {
|
|
378624
|
-
|
|
378823
|
+
fs79.writeFileSync(contextFilePath, "", "utf8");
|
|
378625
378824
|
context2.ui.addItem(
|
|
378626
378825
|
{
|
|
378627
378826
|
type: "info",
|
|
@@ -378686,121 +378885,6 @@ Write the complete content to the \`${contextFileName}\` file. The output must b
|
|
|
378686
378885
|
|
|
378687
378886
|
// packages/cli/src/ui/commands/languageCommand.ts
|
|
378688
378887
|
init_esbuild_shims();
|
|
378689
|
-
|
|
378690
|
-
// packages/cli/src/utils/languageUtils.ts
|
|
378691
|
-
init_esbuild_shims();
|
|
378692
|
-
import * as fs79 from "node:fs";
|
|
378693
|
-
import * as path89 from "node:path";
|
|
378694
|
-
var LLM_OUTPUT_LANGUAGE_RULE_FILENAME = "output-language.md";
|
|
378695
|
-
var LLM_OUTPUT_LANGUAGE_MARKER_PREFIX = "qwen-code:llm-output-language:";
|
|
378696
|
-
var OUTPUT_LANGUAGE_AUTO = "auto";
|
|
378697
|
-
function isAutoLanguage(value) {
|
|
378698
|
-
return !value || value.toLowerCase() === OUTPUT_LANGUAGE_AUTO;
|
|
378699
|
-
}
|
|
378700
|
-
__name(isAutoLanguage, "isAutoLanguage");
|
|
378701
|
-
function normalizeOutputLanguage(language) {
|
|
378702
|
-
const lowered = language.toLowerCase();
|
|
378703
|
-
const fullName = getLanguageNameFromLocale(lowered);
|
|
378704
|
-
if (fullName !== "English" || lowered === "en") {
|
|
378705
|
-
return fullName;
|
|
378706
|
-
}
|
|
378707
|
-
return language;
|
|
378708
|
-
}
|
|
378709
|
-
__name(normalizeOutputLanguage, "normalizeOutputLanguage");
|
|
378710
|
-
function resolveOutputLanguage(value) {
|
|
378711
|
-
if (isAutoLanguage(value)) {
|
|
378712
|
-
const detectedLocale = detectSystemLanguage();
|
|
378713
|
-
return getLanguageNameFromLocale(detectedLocale);
|
|
378714
|
-
}
|
|
378715
|
-
return normalizeOutputLanguage(value);
|
|
378716
|
-
}
|
|
378717
|
-
__name(resolveOutputLanguage, "resolveOutputLanguage");
|
|
378718
|
-
function getOutputLanguageFilePath() {
|
|
378719
|
-
return path89.join(
|
|
378720
|
-
Storage.getGlobalQwenDir(),
|
|
378721
|
-
LLM_OUTPUT_LANGUAGE_RULE_FILENAME
|
|
378722
|
-
);
|
|
378723
|
-
}
|
|
378724
|
-
__name(getOutputLanguageFilePath, "getOutputLanguageFilePath");
|
|
378725
|
-
function sanitizeForMarker(language) {
|
|
378726
|
-
return language.replace(/[\r\n]/g, " ").replace(/--!?>/g, "").replace(/--/g, "");
|
|
378727
|
-
}
|
|
378728
|
-
__name(sanitizeForMarker, "sanitizeForMarker");
|
|
378729
|
-
function generateOutputLanguageFileContent(language) {
|
|
378730
|
-
const safeLanguage = sanitizeForMarker(language);
|
|
378731
|
-
return `# Output language preference: ${language}
|
|
378732
|
-
<!-- ${LLM_OUTPUT_LANGUAGE_MARKER_PREFIX} ${safeLanguage} -->
|
|
378733
|
-
|
|
378734
|
-
## Goal
|
|
378735
|
-
Prefer responding in **${language}** for normal assistant messages and explanations.
|
|
378736
|
-
|
|
378737
|
-
## Keep technical artifacts unchanged
|
|
378738
|
-
Do **not** translate or rewrite:
|
|
378739
|
-
- Code blocks, CLI commands, file paths, stack traces, logs, JSON keys, identifiers
|
|
378740
|
-
- Exact quoted text from the user (keep quotes verbatim)
|
|
378741
|
-
|
|
378742
|
-
## When a conflict exists
|
|
378743
|
-
If higher-priority instructions (system/developer) require a different behavior, follow them.
|
|
378744
|
-
|
|
378745
|
-
## Tool / system outputs
|
|
378746
|
-
Raw tool/system outputs may contain fixed-format English. Preserve them verbatim, and if needed, add a short **${language}** explanation below.
|
|
378747
|
-
`;
|
|
378748
|
-
}
|
|
378749
|
-
__name(generateOutputLanguageFileContent, "generateOutputLanguageFileContent");
|
|
378750
|
-
function parseOutputLanguageFromContent(content) {
|
|
378751
|
-
const markerRegex = new RegExp(
|
|
378752
|
-
String.raw`<!--\s*${LLM_OUTPUT_LANGUAGE_MARKER_PREFIX}\s*(.*?)\s*-->`,
|
|
378753
|
-
"i"
|
|
378754
|
-
);
|
|
378755
|
-
const markerMatch = content.match(markerRegex);
|
|
378756
|
-
if (markerMatch?.[1]?.trim()) {
|
|
378757
|
-
return markerMatch[1].trim();
|
|
378758
|
-
}
|
|
378759
|
-
const headingMatch = content.match(
|
|
378760
|
-
/^#.*?CRITICAL:\s*(.*?)\s+Output Language Rule\b/im
|
|
378761
|
-
);
|
|
378762
|
-
if (headingMatch?.[1]?.trim()) {
|
|
378763
|
-
return headingMatch[1].trim();
|
|
378764
|
-
}
|
|
378765
|
-
return null;
|
|
378766
|
-
}
|
|
378767
|
-
__name(parseOutputLanguageFromContent, "parseOutputLanguageFromContent");
|
|
378768
|
-
function readOutputLanguageFromFile() {
|
|
378769
|
-
const filePath = getOutputLanguageFilePath();
|
|
378770
|
-
if (!fs79.existsSync(filePath)) {
|
|
378771
|
-
return null;
|
|
378772
|
-
}
|
|
378773
|
-
try {
|
|
378774
|
-
const content = fs79.readFileSync(filePath, "utf-8");
|
|
378775
|
-
return parseOutputLanguageFromContent(content);
|
|
378776
|
-
} catch {
|
|
378777
|
-
return null;
|
|
378778
|
-
}
|
|
378779
|
-
}
|
|
378780
|
-
__name(readOutputLanguageFromFile, "readOutputLanguageFromFile");
|
|
378781
|
-
function writeOutputLanguageFile(language) {
|
|
378782
|
-
const filePath = getOutputLanguageFilePath();
|
|
378783
|
-
const content = generateOutputLanguageFileContent(language);
|
|
378784
|
-
const dir = path89.dirname(filePath);
|
|
378785
|
-
fs79.mkdirSync(dir, { recursive: true });
|
|
378786
|
-
fs79.writeFileSync(filePath, content, "utf-8");
|
|
378787
|
-
}
|
|
378788
|
-
__name(writeOutputLanguageFile, "writeOutputLanguageFile");
|
|
378789
|
-
function updateOutputLanguageFile(settingValue) {
|
|
378790
|
-
const resolved = resolveOutputLanguage(settingValue);
|
|
378791
|
-
writeOutputLanguageFile(resolved);
|
|
378792
|
-
}
|
|
378793
|
-
__name(updateOutputLanguageFile, "updateOutputLanguageFile");
|
|
378794
|
-
function initializeLlmOutputLanguage(outputLanguage) {
|
|
378795
|
-
const resolved = resolveOutputLanguage(outputLanguage);
|
|
378796
|
-
const currentFileLanguage = readOutputLanguageFromFile();
|
|
378797
|
-
if (currentFileLanguage !== resolved) {
|
|
378798
|
-
writeOutputLanguageFile(resolved);
|
|
378799
|
-
}
|
|
378800
|
-
}
|
|
378801
|
-
__name(initializeLlmOutputLanguage, "initializeLlmOutputLanguage");
|
|
378802
|
-
|
|
378803
|
-
// packages/cli/src/ui/commands/languageCommand.ts
|
|
378804
378888
|
function getCurrentOutputLanguage(context2) {
|
|
378805
378889
|
const settingValue = context2?.services?.settings?.merged?.general?.outputLanguage || OUTPUT_LANGUAGE_AUTO;
|
|
378806
378890
|
const resolved = resolveOutputLanguage(settingValue);
|
|
@@ -425818,7 +425902,7 @@ var AppContainer = /* @__PURE__ */ __name((props) => {
|
|
|
425818
425902
|
} = useAuthCommand(settings, config2, historyManager.addItem);
|
|
425819
425903
|
useInitializationAuthError(initializationResult.authError, onAuthError);
|
|
425820
425904
|
(0, import_react134.useEffect)(() => {
|
|
425821
|
-
const currentAuthType = config2.
|
|
425905
|
+
const currentAuthType = config2.modelsConfig.getCurrentAuthType();
|
|
425822
425906
|
if (settings.merged.security?.auth?.enforcedType && currentAuthType && settings.merged.security?.auth.enforcedType !== currentAuthType) {
|
|
425823
425907
|
onAuthError(
|
|
425824
425908
|
t4(
|
|
@@ -427741,7 +427825,7 @@ __name(getUserStartupWarnings, "getUserStartupWarnings");
|
|
|
427741
427825
|
init_esbuild_shims();
|
|
427742
427826
|
async function validateNonInteractiveAuth(useExternalAuth, nonInteractiveConfig, settings) {
|
|
427743
427827
|
try {
|
|
427744
|
-
const authType = nonInteractiveConfig.
|
|
427828
|
+
const authType = nonInteractiveConfig.modelsConfig.getCurrentAuthType();
|
|
427745
427829
|
if (!authType) {
|
|
427746
427830
|
throw new Error(
|
|
427747
427831
|
"No auth type is selected. Please configure an auth type (e.g. via settings or `--auth-type`) before running in non-interactive mode."
|
|
@@ -428082,9 +428166,7 @@ var usageSchema = external_exports.object({
|
|
|
428082
428166
|
var sessionUpdateMetaSchema = external_exports.object({
|
|
428083
428167
|
usage: usageSchema.optional().nullable(),
|
|
428084
428168
|
durationMs: external_exports.number().optional().nullable(),
|
|
428085
|
-
toolName: external_exports.string().optional().nullable()
|
|
428086
|
-
parentToolCallId: external_exports.string().optional().nullable(),
|
|
428087
|
-
subagentType: external_exports.string().optional().nullable()
|
|
428169
|
+
toolName: external_exports.string().optional().nullable()
|
|
428088
428170
|
});
|
|
428089
428171
|
var requestPermissionResponseSchema = external_exports.object({
|
|
428090
428172
|
outcome: requestPermissionOutcomeSchema
|
|
@@ -428768,7 +428850,7 @@ var MessageEmitter = class extends BaseEmitter {
|
|
|
428768
428850
|
/**
|
|
428769
428851
|
* Emits usage metadata.
|
|
428770
428852
|
*/
|
|
428771
|
-
async emitUsageMetadata(usageMetadata, text = "", durationMs
|
|
428853
|
+
async emitUsageMetadata(usageMetadata, text = "", durationMs) {
|
|
428772
428854
|
const usage2 = {
|
|
428773
428855
|
promptTokens: usageMetadata.promptTokenCount,
|
|
428774
428856
|
completionTokens: usageMetadata.candidatesTokenCount,
|
|
@@ -428776,7 +428858,7 @@ var MessageEmitter = class extends BaseEmitter {
|
|
|
428776
428858
|
totalTokens: usageMetadata.totalTokenCount,
|
|
428777
428859
|
cachedTokens: usageMetadata.cachedContentTokenCount
|
|
428778
428860
|
};
|
|
428779
|
-
const meta = typeof durationMs === "number" ? { usage: usage2, durationMs
|
|
428861
|
+
const meta = typeof durationMs === "number" ? { usage: usage2, durationMs } : { usage: usage2 };
|
|
428780
428862
|
await this.sendUpdate({
|
|
428781
428863
|
sessionUpdate: "agent_message_chunk",
|
|
428782
428864
|
content: { type: "text", text },
|
|
@@ -428902,10 +428984,7 @@ var ToolCallEmitter = class extends BaseEmitter {
|
|
|
428902
428984
|
locations,
|
|
428903
428985
|
kind: kind2,
|
|
428904
428986
|
rawInput: params.args ?? {},
|
|
428905
|
-
_meta: {
|
|
428906
|
-
toolName: params.toolName,
|
|
428907
|
-
...params.subagentMeta
|
|
428908
|
-
}
|
|
428987
|
+
_meta: { toolName: params.toolName }
|
|
428909
428988
|
});
|
|
428910
428989
|
return true;
|
|
428911
428990
|
}
|
|
@@ -428947,10 +429026,7 @@ var ToolCallEmitter = class extends BaseEmitter {
|
|
|
428947
429026
|
toolCallId: params.callId,
|
|
428948
429027
|
status: params.success ? "completed" : "failed",
|
|
428949
429028
|
content: contentArray,
|
|
428950
|
-
_meta: {
|
|
428951
|
-
toolName: params.toolName,
|
|
428952
|
-
...params.subagentMeta
|
|
428953
|
-
}
|
|
429029
|
+
_meta: { toolName: params.toolName }
|
|
428954
429030
|
};
|
|
428955
429031
|
if (params.resultDisplay !== void 0) {
|
|
428956
429032
|
update2["rawOutput"] = params.resultDisplay;
|
|
@@ -428962,11 +429038,9 @@ var ToolCallEmitter = class extends BaseEmitter {
|
|
|
428962
429038
|
* Use this for explicit error handling when not using emitResult.
|
|
428963
429039
|
*
|
|
428964
429040
|
* @param callId - The tool call ID
|
|
428965
|
-
* @param toolName - The tool name
|
|
428966
429041
|
* @param error - The error that occurred
|
|
428967
|
-
* @param subagentMeta - Optional subagent metadata
|
|
428968
429042
|
*/
|
|
428969
|
-
async emitError(callId, toolName, error2
|
|
429043
|
+
async emitError(callId, toolName, error2) {
|
|
428970
429044
|
await this.sendUpdate({
|
|
428971
429045
|
sessionUpdate: "tool_call_update",
|
|
428972
429046
|
toolCallId: callId,
|
|
@@ -428974,10 +429048,7 @@ var ToolCallEmitter = class extends BaseEmitter {
|
|
|
428974
429048
|
content: [
|
|
428975
429049
|
{ type: "content", content: { type: "text", text: error2.message } }
|
|
428976
429050
|
],
|
|
428977
|
-
_meta: {
|
|
428978
|
-
toolName,
|
|
428979
|
-
...subagentMeta
|
|
428980
|
-
}
|
|
429051
|
+
_meta: { toolName }
|
|
428981
429052
|
});
|
|
428982
429053
|
}
|
|
428983
429054
|
// ==================== Public Utilities ====================
|
|
@@ -429254,11 +429325,9 @@ var basicPermissionOptions = [
|
|
|
429254
429325
|
}
|
|
429255
429326
|
];
|
|
429256
429327
|
var SubAgentTracker = class {
|
|
429257
|
-
constructor(ctx, client
|
|
429328
|
+
constructor(ctx, client) {
|
|
429258
429329
|
this.ctx = ctx;
|
|
429259
429330
|
this.client = client;
|
|
429260
|
-
this.parentToolCallId = parentToolCallId;
|
|
429261
|
-
this.subagentType = subagentType;
|
|
429262
429331
|
this.toolCallEmitter = new ToolCallEmitter(ctx);
|
|
429263
429332
|
this.messageEmitter = new MessageEmitter(ctx);
|
|
429264
429333
|
}
|
|
@@ -429268,15 +429337,6 @@ var SubAgentTracker = class {
|
|
|
429268
429337
|
toolCallEmitter;
|
|
429269
429338
|
messageEmitter;
|
|
429270
429339
|
toolStates = /* @__PURE__ */ new Map();
|
|
429271
|
-
/**
|
|
429272
|
-
* Gets the subagent metadata to attach to all events.
|
|
429273
|
-
*/
|
|
429274
|
-
getSubagentMeta() {
|
|
429275
|
-
return {
|
|
429276
|
-
parentToolCallId: this.parentToolCallId,
|
|
429277
|
-
subagentType: this.subagentType
|
|
429278
|
-
};
|
|
429279
|
-
}
|
|
429280
429340
|
/**
|
|
429281
429341
|
* Sets up event listeners for a sub-agent's tool events.
|
|
429282
429342
|
*
|
|
@@ -429289,19 +429349,16 @@ var SubAgentTracker = class {
|
|
|
429289
429349
|
const onToolResult = this.createToolResultHandler(abortSignal);
|
|
429290
429350
|
const onApproval = this.createApprovalHandler(abortSignal);
|
|
429291
429351
|
const onUsageMetadata = this.createUsageMetadataHandler(abortSignal);
|
|
429292
|
-
const onStreamText = this.createStreamTextHandler(abortSignal);
|
|
429293
429352
|
eventEmitter.on(SubAgentEventType.TOOL_CALL, onToolCall);
|
|
429294
429353
|
eventEmitter.on(SubAgentEventType.TOOL_RESULT, onToolResult);
|
|
429295
429354
|
eventEmitter.on(SubAgentEventType.TOOL_WAITING_APPROVAL, onApproval);
|
|
429296
429355
|
eventEmitter.on(SubAgentEventType.USAGE_METADATA, onUsageMetadata);
|
|
429297
|
-
eventEmitter.on(SubAgentEventType.STREAM_TEXT, onStreamText);
|
|
429298
429356
|
return [
|
|
429299
429357
|
() => {
|
|
429300
429358
|
eventEmitter.off(SubAgentEventType.TOOL_CALL, onToolCall);
|
|
429301
429359
|
eventEmitter.off(SubAgentEventType.TOOL_RESULT, onToolResult);
|
|
429302
429360
|
eventEmitter.off(SubAgentEventType.TOOL_WAITING_APPROVAL, onApproval);
|
|
429303
429361
|
eventEmitter.off(SubAgentEventType.USAGE_METADATA, onUsageMetadata);
|
|
429304
|
-
eventEmitter.off(SubAgentEventType.STREAM_TEXT, onStreamText);
|
|
429305
429362
|
this.toolStates.clear();
|
|
429306
429363
|
}
|
|
429307
429364
|
];
|
|
@@ -429331,8 +429388,7 @@ var SubAgentTracker = class {
|
|
|
429331
429388
|
void this.toolCallEmitter.emitStart({
|
|
429332
429389
|
toolName: event.name,
|
|
429333
429390
|
callId: event.callId,
|
|
429334
|
-
args: event.args
|
|
429335
|
-
subagentMeta: this.getSubagentMeta()
|
|
429391
|
+
args: event.args
|
|
429336
429392
|
});
|
|
429337
429393
|
};
|
|
429338
429394
|
}
|
|
@@ -429350,8 +429406,7 @@ var SubAgentTracker = class {
|
|
|
429350
429406
|
success: event.success,
|
|
429351
429407
|
message: event.responseParts ?? [],
|
|
429352
429408
|
resultDisplay: event.resultDisplay,
|
|
429353
|
-
args: state?.args
|
|
429354
|
-
subagentMeta: this.getSubagentMeta()
|
|
429409
|
+
args: state?.args
|
|
429355
429410
|
});
|
|
429356
429411
|
this.toolStates.delete(event.callId);
|
|
429357
429412
|
};
|
|
@@ -429413,27 +429468,7 @@ var SubAgentTracker = class {
|
|
|
429413
429468
|
return (...args) => {
|
|
429414
429469
|
const event = args[0];
|
|
429415
429470
|
if (abortSignal.aborted) return;
|
|
429416
|
-
this.messageEmitter.emitUsageMetadata(
|
|
429417
|
-
event.usage,
|
|
429418
|
-
"",
|
|
429419
|
-
event.durationMs,
|
|
429420
|
-
this.getSubagentMeta()
|
|
429421
|
-
);
|
|
429422
|
-
};
|
|
429423
|
-
}
|
|
429424
|
-
/**
|
|
429425
|
-
* Creates a handler for stream text events.
|
|
429426
|
-
* Emits agent message or thought chunks for text content from subagent model responses.
|
|
429427
|
-
*/
|
|
429428
|
-
createStreamTextHandler(abortSignal) {
|
|
429429
|
-
return (...args) => {
|
|
429430
|
-
const event = args[0];
|
|
429431
|
-
if (abortSignal.aborted) return;
|
|
429432
|
-
void this.messageEmitter.emitMessage(
|
|
429433
|
-
event.text,
|
|
429434
|
-
"assistant",
|
|
429435
|
-
event.thought ?? false
|
|
429436
|
-
);
|
|
429471
|
+
this.messageEmitter.emitUsageMetadata(event.usage, "", event.durationMs);
|
|
429437
429472
|
};
|
|
429438
429473
|
}
|
|
429439
429474
|
/**
|
|
@@ -429791,14 +429826,7 @@ var Session3 = class {
|
|
|
429791
429826
|
const invocation = tool.build(args);
|
|
429792
429827
|
if (isTaskTool && "eventEmitter" in invocation) {
|
|
429793
429828
|
const taskEventEmitter = invocation.eventEmitter;
|
|
429794
|
-
const
|
|
429795
|
-
const subagentType = args["subagent_type"] ?? "";
|
|
429796
|
-
const subAgentTracker = new SubAgentTracker(
|
|
429797
|
-
this,
|
|
429798
|
-
this.client,
|
|
429799
|
-
parentToolCallId,
|
|
429800
|
-
subagentType
|
|
429801
|
-
);
|
|
429829
|
+
const subAgentTracker = new SubAgentTracker(this, this.client);
|
|
429802
429830
|
subAgentCleanupFunctions = subAgentTracker.setup(
|
|
429803
429831
|
taskEventEmitter,
|
|
429804
429832
|
abortSignal
|
|
@@ -430345,7 +430373,7 @@ var GeminiAgent = class {
|
|
|
430345
430373
|
name: APPROVAL_MODE_INFO[mode].name,
|
|
430346
430374
|
description: APPROVAL_MODE_INFO[mode].description
|
|
430347
430375
|
}));
|
|
430348
|
-
const version2 = "0.8.2
|
|
430376
|
+
const version2 = "0.8.2";
|
|
430349
430377
|
return {
|
|
430350
430378
|
protocolVersion: PROTOCOL_VERSION,
|
|
430351
430379
|
agentInfo: {
|
|
@@ -430504,7 +430532,7 @@ var GeminiAgent = class {
|
|
|
430504
430532
|
return session.setModel(params);
|
|
430505
430533
|
}
|
|
430506
430534
|
async ensureAuthenticated(config2) {
|
|
430507
|
-
const selectedType =
|
|
430535
|
+
const selectedType = this.settings.merged.security?.auth?.selectedType;
|
|
430508
430536
|
if (!selectedType) {
|
|
430509
430537
|
throw RequestError.authRequired(
|
|
430510
430538
|
"Use Qwen Code CLI to authenticate first."
|
|
@@ -430720,7 +430748,7 @@ async function main() {
|
|
|
430720
430748
|
);
|
|
430721
430749
|
if (!settings.merged.security?.auth?.useExternal) {
|
|
430722
430750
|
try {
|
|
430723
|
-
const authType = partialConfig.
|
|
430751
|
+
const authType = partialConfig.modelsConfig.getCurrentAuthType();
|
|
430724
430752
|
if (authType) {
|
|
430725
430753
|
const err = validateAuthMethod(authType, partialConfig);
|
|
430726
430754
|
if (err) {
|
|
@@ -430770,7 +430798,6 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
430770
430798
|
}
|
|
430771
430799
|
argv = { ...argv, resume: selectedSessionId };
|
|
430772
430800
|
}
|
|
430773
|
-
initializeLlmOutputLanguage(settings.merged.general?.outputLanguage);
|
|
430774
430801
|
{
|
|
430775
430802
|
const config2 = await loadCliConfig(
|
|
430776
430803
|
settings.merged,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwen-code/qwen-code",
|
|
3
|
-
"version": "0.8.2
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Qwen Code - AI-powered coding assistant",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"locales"
|
|
21
21
|
],
|
|
22
22
|
"config": {
|
|
23
|
-
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.8.2
|
|
23
|
+
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.8.2"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {},
|
|
26
26
|
"optionalDependencies": {
|