@google/gemini-cli-a2a-server 0.11.0-preview.1 → 0.11.1
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/dist/a2a-server.mjs +263 -154
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/a2a-server.mjs
CHANGED
|
@@ -288503,8 +288503,8 @@ var Float64Vector = import_vector.default.Float64Vector;
|
|
|
288503
288503
|
var PointerVector = import_vector.default.PointerVector;
|
|
288504
288504
|
|
|
288505
288505
|
// packages/core/dist/src/generated/git-commit.js
|
|
288506
|
-
var GIT_COMMIT_INFO = "
|
|
288507
|
-
var CLI_VERSION = "0.11.
|
|
288506
|
+
var GIT_COMMIT_INFO = "d9f6cebe";
|
|
288507
|
+
var CLI_VERSION = "0.11.1";
|
|
288508
288508
|
|
|
288509
288509
|
// packages/core/dist/src/ide/detect-ide.js
|
|
288510
288510
|
var IDE_DEFINITIONS = {
|
|
@@ -290849,43 +290849,6 @@ function isApiError(error) {
|
|
|
290849
290849
|
function isStructuredError(error) {
|
|
290850
290850
|
return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
|
|
290851
290851
|
}
|
|
290852
|
-
function isProQuotaExceededError(error) {
|
|
290853
|
-
const checkMessage = (message) => message.includes("Quota exceeded for quota metric 'Gemini") && message.includes("Pro Requests'");
|
|
290854
|
-
if (typeof error === "string") {
|
|
290855
|
-
return checkMessage(error);
|
|
290856
|
-
}
|
|
290857
|
-
if (isStructuredError(error)) {
|
|
290858
|
-
return checkMessage(error.message);
|
|
290859
|
-
}
|
|
290860
|
-
if (isApiError(error)) {
|
|
290861
|
-
return checkMessage(error.error.message);
|
|
290862
|
-
}
|
|
290863
|
-
if (error && typeof error === "object" && "response" in error) {
|
|
290864
|
-
const gaxiosError = error;
|
|
290865
|
-
if (gaxiosError.response && gaxiosError.response.data) {
|
|
290866
|
-
if (typeof gaxiosError.response.data === "string") {
|
|
290867
|
-
return checkMessage(gaxiosError.response.data);
|
|
290868
|
-
}
|
|
290869
|
-
if (typeof gaxiosError.response.data === "object" && gaxiosError.response.data !== null && "error" in gaxiosError.response.data) {
|
|
290870
|
-
const errorData = gaxiosError.response.data;
|
|
290871
|
-
return checkMessage(errorData.error?.message || "");
|
|
290872
|
-
}
|
|
290873
|
-
}
|
|
290874
|
-
}
|
|
290875
|
-
return false;
|
|
290876
|
-
}
|
|
290877
|
-
function isGenericQuotaExceededError(error) {
|
|
290878
|
-
if (typeof error === "string") {
|
|
290879
|
-
return error.includes("Quota exceeded for quota metric");
|
|
290880
|
-
}
|
|
290881
|
-
if (isStructuredError(error)) {
|
|
290882
|
-
return error.message.includes("Quota exceeded for quota metric");
|
|
290883
|
-
}
|
|
290884
|
-
if (isApiError(error)) {
|
|
290885
|
-
return error.error.message.includes("Quota exceeded for quota metric");
|
|
290886
|
-
}
|
|
290887
|
-
return false;
|
|
290888
|
-
}
|
|
290889
290852
|
|
|
290890
290853
|
// packages/core/dist/src/core/loggingContentGenerator.js
|
|
290891
290854
|
var LoggingContentGenerator = class {
|
|
@@ -291007,7 +290970,7 @@ function createContentGeneratorConfig(config2, authType) {
|
|
|
291007
290970
|
return contentGeneratorConfig;
|
|
291008
290971
|
}
|
|
291009
290972
|
async function createContentGenerator(config2, gcConfig, sessionId2) {
|
|
291010
|
-
const version3 = "0.11.
|
|
290973
|
+
const version3 = "0.11.1";
|
|
291011
290974
|
const userAgent = `GeminiCLI/${version3} (${process.platform}; ${process.arch})`;
|
|
291012
290975
|
const baseHeaders = {
|
|
291013
290976
|
"User-Agent": userAgent
|
|
@@ -324663,6 +324626,226 @@ async function reportError(error, baseMessage, context2, type = "general", repor
|
|
|
324663
324626
|
}
|
|
324664
324627
|
}
|
|
324665
324628
|
|
|
324629
|
+
// packages/core/dist/src/utils/googleErrors.js
|
|
324630
|
+
function parseGoogleApiError(error) {
|
|
324631
|
+
if (!error) {
|
|
324632
|
+
return null;
|
|
324633
|
+
}
|
|
324634
|
+
let errorObj = error;
|
|
324635
|
+
if (typeof errorObj === "string") {
|
|
324636
|
+
try {
|
|
324637
|
+
errorObj = JSON.parse(errorObj);
|
|
324638
|
+
} catch (_) {
|
|
324639
|
+
return null;
|
|
324640
|
+
}
|
|
324641
|
+
}
|
|
324642
|
+
if (Array.isArray(errorObj) && errorObj.length > 0) {
|
|
324643
|
+
errorObj = errorObj[0];
|
|
324644
|
+
}
|
|
324645
|
+
if (typeof errorObj !== "object" || errorObj === null) {
|
|
324646
|
+
return null;
|
|
324647
|
+
}
|
|
324648
|
+
let currentError = fromGaxiosError(errorObj) ?? fromApiError(errorObj);
|
|
324649
|
+
let depth = 0;
|
|
324650
|
+
const maxDepth = 10;
|
|
324651
|
+
while (currentError && typeof currentError.message === "string" && depth < maxDepth) {
|
|
324652
|
+
try {
|
|
324653
|
+
const parsedMessage = JSON.parse(currentError.message.replace(/\u00A0/g, "").replace(/\n/g, " "));
|
|
324654
|
+
if (parsedMessage.error) {
|
|
324655
|
+
currentError = parsedMessage.error;
|
|
324656
|
+
depth++;
|
|
324657
|
+
} else {
|
|
324658
|
+
break;
|
|
324659
|
+
}
|
|
324660
|
+
} catch (_error) {
|
|
324661
|
+
break;
|
|
324662
|
+
}
|
|
324663
|
+
}
|
|
324664
|
+
if (!currentError) {
|
|
324665
|
+
return null;
|
|
324666
|
+
}
|
|
324667
|
+
const code2 = currentError.code;
|
|
324668
|
+
const message = currentError.message;
|
|
324669
|
+
const errorDetails = currentError.details;
|
|
324670
|
+
if (Array.isArray(errorDetails) && code2 && message) {
|
|
324671
|
+
const details = [];
|
|
324672
|
+
for (const detail of errorDetails) {
|
|
324673
|
+
if (detail && typeof detail === "object") {
|
|
324674
|
+
const detailObj = detail;
|
|
324675
|
+
const typeKey = Object.keys(detailObj).find((key) => key.trim() === "@type");
|
|
324676
|
+
if (typeKey) {
|
|
324677
|
+
if (typeKey !== "@type") {
|
|
324678
|
+
detailObj["@type"] = detailObj[typeKey];
|
|
324679
|
+
delete detailObj[typeKey];
|
|
324680
|
+
}
|
|
324681
|
+
details.push(detailObj);
|
|
324682
|
+
}
|
|
324683
|
+
}
|
|
324684
|
+
}
|
|
324685
|
+
if (details.length > 0) {
|
|
324686
|
+
return {
|
|
324687
|
+
code: code2,
|
|
324688
|
+
message,
|
|
324689
|
+
details
|
|
324690
|
+
};
|
|
324691
|
+
}
|
|
324692
|
+
}
|
|
324693
|
+
return null;
|
|
324694
|
+
}
|
|
324695
|
+
function fromGaxiosError(errorObj) {
|
|
324696
|
+
const gaxiosError = errorObj;
|
|
324697
|
+
let outerError;
|
|
324698
|
+
if (gaxiosError.response?.data) {
|
|
324699
|
+
let data = gaxiosError.response.data;
|
|
324700
|
+
if (typeof data === "string") {
|
|
324701
|
+
try {
|
|
324702
|
+
data = JSON.parse(data);
|
|
324703
|
+
} catch (_) {
|
|
324704
|
+
}
|
|
324705
|
+
}
|
|
324706
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
324707
|
+
data = data[0];
|
|
324708
|
+
}
|
|
324709
|
+
if (typeof data === "object" && data !== null) {
|
|
324710
|
+
if ("error" in data) {
|
|
324711
|
+
outerError = data.error;
|
|
324712
|
+
}
|
|
324713
|
+
}
|
|
324714
|
+
}
|
|
324715
|
+
if (!outerError) {
|
|
324716
|
+
if (gaxiosError.error) {
|
|
324717
|
+
outerError = gaxiosError.error;
|
|
324718
|
+
} else {
|
|
324719
|
+
return void 0;
|
|
324720
|
+
}
|
|
324721
|
+
}
|
|
324722
|
+
return outerError;
|
|
324723
|
+
}
|
|
324724
|
+
function fromApiError(errorObj) {
|
|
324725
|
+
const apiError = errorObj;
|
|
324726
|
+
let outerError;
|
|
324727
|
+
if (apiError.message) {
|
|
324728
|
+
let data = apiError.message;
|
|
324729
|
+
if (typeof data === "string") {
|
|
324730
|
+
try {
|
|
324731
|
+
data = JSON.parse(data);
|
|
324732
|
+
} catch (_) {
|
|
324733
|
+
}
|
|
324734
|
+
}
|
|
324735
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
324736
|
+
data = data[0];
|
|
324737
|
+
}
|
|
324738
|
+
if (typeof data === "object" && data !== null) {
|
|
324739
|
+
if ("error" in data) {
|
|
324740
|
+
outerError = data.error;
|
|
324741
|
+
}
|
|
324742
|
+
}
|
|
324743
|
+
}
|
|
324744
|
+
return outerError;
|
|
324745
|
+
}
|
|
324746
|
+
|
|
324747
|
+
// packages/core/dist/src/utils/googleQuotaErrors.js
|
|
324748
|
+
var TerminalQuotaError = class extends Error {
|
|
324749
|
+
cause;
|
|
324750
|
+
constructor(message, cause) {
|
|
324751
|
+
super(message);
|
|
324752
|
+
this.cause = cause;
|
|
324753
|
+
this.name = "TerminalQuotaError";
|
|
324754
|
+
}
|
|
324755
|
+
};
|
|
324756
|
+
var RetryableQuotaError = class extends Error {
|
|
324757
|
+
cause;
|
|
324758
|
+
retryDelayMs;
|
|
324759
|
+
constructor(message, cause, retryDelaySeconds) {
|
|
324760
|
+
super(message);
|
|
324761
|
+
this.cause = cause;
|
|
324762
|
+
this.name = "RetryableQuotaError";
|
|
324763
|
+
this.retryDelayMs = retryDelaySeconds * 1e3;
|
|
324764
|
+
}
|
|
324765
|
+
};
|
|
324766
|
+
function parseDurationInSeconds(duration) {
|
|
324767
|
+
if (!duration.endsWith("s")) {
|
|
324768
|
+
return null;
|
|
324769
|
+
}
|
|
324770
|
+
const seconds = parseFloat(duration.slice(0, -1));
|
|
324771
|
+
return isNaN(seconds) ? null : seconds;
|
|
324772
|
+
}
|
|
324773
|
+
function classifyGoogleError(error) {
|
|
324774
|
+
const googleApiError = parseGoogleApiError(error);
|
|
324775
|
+
if (!googleApiError || googleApiError.code !== 429) {
|
|
324776
|
+
return error;
|
|
324777
|
+
}
|
|
324778
|
+
const quotaFailure = googleApiError.details.find((d) => d["@type"] === "type.googleapis.com/google.rpc.QuotaFailure");
|
|
324779
|
+
const errorInfo = googleApiError.details.find((d) => d["@type"] === "type.googleapis.com/google.rpc.ErrorInfo");
|
|
324780
|
+
const retryInfo = googleApiError.details.find((d) => d["@type"] === "type.googleapis.com/google.rpc.RetryInfo");
|
|
324781
|
+
if (quotaFailure) {
|
|
324782
|
+
for (const violation of quotaFailure.violations) {
|
|
324783
|
+
const quotaId = violation.quotaId ?? "";
|
|
324784
|
+
if (quotaId.includes("PerDay") || quotaId.includes("Daily")) {
|
|
324785
|
+
return new TerminalQuotaError(`${googleApiError.message}
|
|
324786
|
+
Expected quota reset within 24h.`, googleApiError);
|
|
324787
|
+
}
|
|
324788
|
+
}
|
|
324789
|
+
}
|
|
324790
|
+
if (errorInfo) {
|
|
324791
|
+
if (errorInfo.domain) {
|
|
324792
|
+
const validDomains = [
|
|
324793
|
+
"cloudcode-pa.googleapis.com",
|
|
324794
|
+
"staging-cloudcode-pa.googleapis.com",
|
|
324795
|
+
"autopush-cloudcode-pa.googleapis.com"
|
|
324796
|
+
];
|
|
324797
|
+
if (validDomains.includes(errorInfo.domain)) {
|
|
324798
|
+
if (errorInfo.reason === "RATE_LIMIT_EXCEEDED") {
|
|
324799
|
+
let delaySeconds = 10;
|
|
324800
|
+
if (retryInfo?.retryDelay) {
|
|
324801
|
+
const parsedDelay = parseDurationInSeconds(retryInfo.retryDelay);
|
|
324802
|
+
if (parsedDelay) {
|
|
324803
|
+
delaySeconds = parsedDelay;
|
|
324804
|
+
}
|
|
324805
|
+
}
|
|
324806
|
+
return new RetryableQuotaError(`${googleApiError.message}`, googleApiError, delaySeconds);
|
|
324807
|
+
}
|
|
324808
|
+
if (errorInfo.reason === "QUOTA_EXHAUSTED") {
|
|
324809
|
+
return new TerminalQuotaError(`${googleApiError.message}`, googleApiError);
|
|
324810
|
+
}
|
|
324811
|
+
}
|
|
324812
|
+
}
|
|
324813
|
+
const quotaLimit = errorInfo.metadata?.["quota_limit"] ?? "";
|
|
324814
|
+
if (quotaLimit.includes("PerDay") || quotaLimit.includes("Daily")) {
|
|
324815
|
+
return new TerminalQuotaError(`${googleApiError.message}
|
|
324816
|
+
Expected quota reset within 24h.`, googleApiError);
|
|
324817
|
+
}
|
|
324818
|
+
}
|
|
324819
|
+
if (retryInfo?.retryDelay) {
|
|
324820
|
+
const delaySeconds = parseDurationInSeconds(retryInfo.retryDelay);
|
|
324821
|
+
if (delaySeconds) {
|
|
324822
|
+
if (delaySeconds > 120) {
|
|
324823
|
+
return new TerminalQuotaError(`${googleApiError.message}
|
|
324824
|
+
Suggested retry after ${retryInfo.retryDelay}.`, googleApiError);
|
|
324825
|
+
}
|
|
324826
|
+
return new RetryableQuotaError(`${googleApiError.message}
|
|
324827
|
+
Suggested retry after ${retryInfo.retryDelay}.`, googleApiError, delaySeconds);
|
|
324828
|
+
}
|
|
324829
|
+
}
|
|
324830
|
+
if (quotaFailure) {
|
|
324831
|
+
for (const violation of quotaFailure.violations) {
|
|
324832
|
+
const quotaId = violation.quotaId ?? "";
|
|
324833
|
+
if (quotaId.includes("PerMinute")) {
|
|
324834
|
+
return new RetryableQuotaError(`${googleApiError.message}
|
|
324835
|
+
Suggested retry after 60s.`, googleApiError, 60);
|
|
324836
|
+
}
|
|
324837
|
+
}
|
|
324838
|
+
}
|
|
324839
|
+
if (errorInfo) {
|
|
324840
|
+
const quotaLimit = errorInfo.metadata?.["quota_limit"] ?? "";
|
|
324841
|
+
if (quotaLimit.includes("PerMinute")) {
|
|
324842
|
+
return new RetryableQuotaError(`${errorInfo.reason}
|
|
324843
|
+
Suggested retry after 60s.`, googleApiError, 60);
|
|
324844
|
+
}
|
|
324845
|
+
}
|
|
324846
|
+
return error;
|
|
324847
|
+
}
|
|
324848
|
+
|
|
324666
324849
|
// packages/core/dist/src/utils/delay.js
|
|
324667
324850
|
function createAbortError() {
|
|
324668
324851
|
const abortError = new Error("Aborted");
|
|
@@ -324693,7 +324876,7 @@ function delay2(ms, signal) {
|
|
|
324693
324876
|
// packages/core/dist/src/utils/retry.js
|
|
324694
324877
|
var FETCH_FAILED_MESSAGE = "exception TypeError: fetch failed sending request";
|
|
324695
324878
|
var DEFAULT_RETRY_OPTIONS = {
|
|
324696
|
-
maxAttempts:
|
|
324879
|
+
maxAttempts: 3,
|
|
324697
324880
|
initialDelayMs: 5e3,
|
|
324698
324881
|
maxDelayMs: 3e4,
|
|
324699
324882
|
// 30 seconds
|
|
@@ -324728,7 +324911,6 @@ async function retryWithBackoff(fn, options2) {
|
|
|
324728
324911
|
};
|
|
324729
324912
|
let attempt = 0;
|
|
324730
324913
|
let currentDelay = initialDelayMs;
|
|
324731
|
-
let consecutive429Count = 0;
|
|
324732
324914
|
while (attempt < maxAttempts) {
|
|
324733
324915
|
if (signal?.aborted) {
|
|
324734
324916
|
throw createAbortError();
|
|
@@ -324748,72 +324930,51 @@ async function retryWithBackoff(fn, options2) {
|
|
|
324748
324930
|
if (error instanceof Error && error.name === "AbortError") {
|
|
324749
324931
|
throw error;
|
|
324750
324932
|
}
|
|
324751
|
-
const
|
|
324752
|
-
if (
|
|
324753
|
-
|
|
324754
|
-
|
|
324755
|
-
|
|
324756
|
-
|
|
324757
|
-
|
|
324758
|
-
|
|
324759
|
-
|
|
324760
|
-
|
|
324761
|
-
|
|
324762
|
-
|
|
324763
|
-
} catch (fallbackError) {
|
|
324764
|
-
debugLogger.warn("Fallback to Flash model failed:", fallbackError);
|
|
324765
|
-
}
|
|
324766
|
-
}
|
|
324767
|
-
if (errorStatus === 429 && authType === AuthType2.LOGIN_WITH_GOOGLE && !isProQuotaExceededError(error) && isGenericQuotaExceededError(error) && onPersistent429) {
|
|
324768
|
-
try {
|
|
324769
|
-
const fallbackModel = await onPersistent429(authType, error);
|
|
324770
|
-
if (fallbackModel !== false && fallbackModel !== null) {
|
|
324771
|
-
attempt = 0;
|
|
324772
|
-
consecutive429Count = 0;
|
|
324773
|
-
currentDelay = initialDelayMs;
|
|
324774
|
-
continue;
|
|
324775
|
-
} else {
|
|
324776
|
-
throw error;
|
|
324933
|
+
const classifiedError = classifyGoogleError(error);
|
|
324934
|
+
if (classifiedError instanceof TerminalQuotaError) {
|
|
324935
|
+
if (onPersistent429 && authType === AuthType2.LOGIN_WITH_GOOGLE) {
|
|
324936
|
+
try {
|
|
324937
|
+
const fallbackModel = await onPersistent429(authType, classifiedError);
|
|
324938
|
+
if (fallbackModel) {
|
|
324939
|
+
attempt = 0;
|
|
324940
|
+
currentDelay = initialDelayMs;
|
|
324941
|
+
continue;
|
|
324942
|
+
}
|
|
324943
|
+
} catch (fallbackError) {
|
|
324944
|
+
debugLogger.warn("Fallback to Flash model failed:", fallbackError);
|
|
324777
324945
|
}
|
|
324778
|
-
} catch (fallbackError) {
|
|
324779
|
-
debugLogger.warn("Fallback to Flash model failed:", fallbackError);
|
|
324780
324946
|
}
|
|
324947
|
+
throw classifiedError;
|
|
324781
324948
|
}
|
|
324782
|
-
if (
|
|
324783
|
-
|
|
324784
|
-
|
|
324785
|
-
|
|
324786
|
-
|
|
324787
|
-
|
|
324788
|
-
|
|
324789
|
-
|
|
324790
|
-
|
|
324791
|
-
|
|
324792
|
-
|
|
324793
|
-
|
|
324794
|
-
|
|
324795
|
-
} else {
|
|
324796
|
-
throw error;
|
|
324949
|
+
if (classifiedError instanceof RetryableQuotaError) {
|
|
324950
|
+
if (attempt >= maxAttempts) {
|
|
324951
|
+
if (onPersistent429 && authType === AuthType2.LOGIN_WITH_GOOGLE) {
|
|
324952
|
+
try {
|
|
324953
|
+
const fallbackModel = await onPersistent429(authType, classifiedError);
|
|
324954
|
+
if (fallbackModel) {
|
|
324955
|
+
attempt = 0;
|
|
324956
|
+
currentDelay = initialDelayMs;
|
|
324957
|
+
continue;
|
|
324958
|
+
}
|
|
324959
|
+
} catch (fallbackError) {
|
|
324960
|
+
console.warn("Model fallback failed:", fallbackError);
|
|
324961
|
+
}
|
|
324797
324962
|
}
|
|
324798
|
-
|
|
324799
|
-
debugLogger.warn("Fallback to Flash model failed:", fallbackError);
|
|
324963
|
+
throw classifiedError;
|
|
324800
324964
|
}
|
|
324965
|
+
console.warn(`Attempt ${attempt} failed: ${classifiedError.message}. Retrying after ${classifiedError.retryDelayMs}ms...`);
|
|
324966
|
+
await delay2(classifiedError.retryDelayMs, signal);
|
|
324967
|
+
continue;
|
|
324801
324968
|
}
|
|
324802
324969
|
if (attempt >= maxAttempts || !shouldRetryOnError(error, retryFetchErrors)) {
|
|
324803
324970
|
throw error;
|
|
324804
324971
|
}
|
|
324805
|
-
const
|
|
324806
|
-
|
|
324807
|
-
|
|
324808
|
-
|
|
324809
|
-
|
|
324810
|
-
|
|
324811
|
-
logRetryAttempt(attempt, error, errorStatus);
|
|
324812
|
-
const jitter = currentDelay * 0.3 * (Math.random() * 2 - 1);
|
|
324813
|
-
const delayWithJitter = Math.max(0, currentDelay + jitter);
|
|
324814
|
-
await delay2(delayWithJitter, signal);
|
|
324815
|
-
currentDelay = Math.min(maxDelayMs, currentDelay * 2);
|
|
324816
|
-
}
|
|
324972
|
+
const errorStatus = getErrorStatus(error);
|
|
324973
|
+
logRetryAttempt(attempt, error, errorStatus);
|
|
324974
|
+
const jitter = currentDelay * 0.3 * (Math.random() * 2 - 1);
|
|
324975
|
+
const delayWithJitter = Math.max(0, currentDelay + jitter);
|
|
324976
|
+
await delay2(delayWithJitter, signal);
|
|
324977
|
+
currentDelay = Math.min(maxDelayMs, currentDelay * 2);
|
|
324817
324978
|
}
|
|
324818
324979
|
}
|
|
324819
324980
|
throw new Error("Retry attempts exhausted");
|
|
@@ -324832,36 +324993,6 @@ function getErrorStatus(error) {
|
|
|
324832
324993
|
}
|
|
324833
324994
|
return void 0;
|
|
324834
324995
|
}
|
|
324835
|
-
function getRetryAfterDelayMs(error) {
|
|
324836
|
-
if (typeof error === "object" && error !== null) {
|
|
324837
|
-
if ("response" in error && typeof error.response === "object" && error.response !== null) {
|
|
324838
|
-
const response = error.response;
|
|
324839
|
-
if ("headers" in response && typeof response.headers === "object" && response.headers !== null) {
|
|
324840
|
-
const headers = response.headers;
|
|
324841
|
-
const retryAfterHeader = headers["retry-after"];
|
|
324842
|
-
if (typeof retryAfterHeader === "string") {
|
|
324843
|
-
const retryAfterSeconds = parseInt(retryAfterHeader, 10);
|
|
324844
|
-
if (!isNaN(retryAfterSeconds)) {
|
|
324845
|
-
return retryAfterSeconds * 1e3;
|
|
324846
|
-
}
|
|
324847
|
-
const retryAfterDate = new Date(retryAfterHeader);
|
|
324848
|
-
if (!isNaN(retryAfterDate.getTime())) {
|
|
324849
|
-
return Math.max(0, retryAfterDate.getTime() - Date.now());
|
|
324850
|
-
}
|
|
324851
|
-
}
|
|
324852
|
-
}
|
|
324853
|
-
}
|
|
324854
|
-
}
|
|
324855
|
-
return 0;
|
|
324856
|
-
}
|
|
324857
|
-
function getDelayDurationAndStatus(error) {
|
|
324858
|
-
const errorStatus = getErrorStatus(error);
|
|
324859
|
-
let delayDurationMs = 0;
|
|
324860
|
-
if (errorStatus === 429) {
|
|
324861
|
-
delayDurationMs = getRetryAfterDelayMs(error);
|
|
324862
|
-
}
|
|
324863
|
-
return { delayDurationMs, errorStatus };
|
|
324864
|
-
}
|
|
324865
324996
|
function logRetryAttempt(attempt, error, errorStatus) {
|
|
324866
324997
|
let message = `Attempt ${attempt} failed. Retrying with backoff...`;
|
|
324867
324998
|
if (errorStatus) {
|
|
@@ -351837,34 +351968,12 @@ var hasFileExtension = (0, import_picomatch.default)("**/*[*.]*");
|
|
|
351837
351968
|
var import_fdir = __toESM(require_dist10(), 1);
|
|
351838
351969
|
|
|
351839
351970
|
// packages/core/dist/src/utils/errorParsing.js
|
|
351840
|
-
var getRateLimitErrorMessageGoogleFree = (fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `
|
|
351841
|
-
Possible quota limitations in place or slow response times detected. Switching to the ${fallbackModel} model for the rest of this session.`;
|
|
351842
|
-
var getRateLimitErrorMessageGoogleProQuotaFree = (currentModel = DEFAULT_GEMINI_MODEL, fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `
|
|
351843
|
-
You have reached your daily ${currentModel} quota limit. You will be switched to the ${fallbackModel} model for the rest of this session. To increase your limits, upgrade to get higher limits at https://goo.gle/set-up-gemini-code-assist, or use /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
351844
|
-
var getRateLimitErrorMessageGoogleGenericQuotaFree = () => `
|
|
351845
|
-
You have reached your daily quota limit. To increase your limits, upgrade to get higher limits at https://goo.gle/set-up-gemini-code-assist, or use /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
351846
|
-
var getRateLimitErrorMessageGooglePaid = (fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `
|
|
351847
|
-
Possible quota limitations in place or slow response times detected. Switching to the ${fallbackModel} model for the rest of this session. We appreciate you for choosing Gemini Code Assist and the Gemini CLI.`;
|
|
351848
|
-
var getRateLimitErrorMessageGoogleProQuotaPaid = (currentModel = DEFAULT_GEMINI_MODEL, fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `
|
|
351849
|
-
You have reached your daily ${currentModel} quota limit. You will be switched to the ${fallbackModel} model for the rest of this session. We appreciate you for choosing Gemini Code Assist and the Gemini CLI. To continue accessing the ${currentModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
351850
|
-
var getRateLimitErrorMessageGoogleGenericQuotaPaid = (currentModel = DEFAULT_GEMINI_MODEL) => `
|
|
351851
|
-
You have reached your daily quota limit. We appreciate you for choosing Gemini Code Assist and the Gemini CLI. To continue accessing the ${currentModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
351852
351971
|
var RATE_LIMIT_ERROR_MESSAGE_USE_GEMINI = "\nPlease wait and try again later. To increase your limits, request a quota increase through AI Studio, or switch to another /auth method";
|
|
351853
351972
|
var RATE_LIMIT_ERROR_MESSAGE_VERTEX = "\nPlease wait and try again later. To increase your limits, request a quota increase through Vertex, or switch to another /auth method";
|
|
351854
351973
|
var getRateLimitErrorMessageDefault = (fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `
|
|
351855
351974
|
Possible quota limitations in place or slow response times detected. Switching to the ${fallbackModel} model for the rest of this session.`;
|
|
351856
|
-
function getRateLimitMessage(authType,
|
|
351975
|
+
function getRateLimitMessage(authType, fallbackModel) {
|
|
351857
351976
|
switch (authType) {
|
|
351858
|
-
case AuthType2.LOGIN_WITH_GOOGLE: {
|
|
351859
|
-
const isPaidTier = userTier === UserTierId.LEGACY || userTier === UserTierId.STANDARD;
|
|
351860
|
-
if (isProQuotaExceededError(error)) {
|
|
351861
|
-
return isPaidTier ? getRateLimitErrorMessageGoogleProQuotaPaid(currentModel || DEFAULT_GEMINI_MODEL, fallbackModel) : getRateLimitErrorMessageGoogleProQuotaFree(currentModel || DEFAULT_GEMINI_MODEL, fallbackModel);
|
|
351862
|
-
} else if (isGenericQuotaExceededError(error)) {
|
|
351863
|
-
return isPaidTier ? getRateLimitErrorMessageGoogleGenericQuotaPaid(currentModel || DEFAULT_GEMINI_MODEL) : getRateLimitErrorMessageGoogleGenericQuotaFree();
|
|
351864
|
-
} else {
|
|
351865
|
-
return isPaidTier ? getRateLimitErrorMessageGooglePaid(fallbackModel) : getRateLimitErrorMessageGoogleFree(fallbackModel);
|
|
351866
|
-
}
|
|
351867
|
-
}
|
|
351868
351977
|
case AuthType2.USE_GEMINI:
|
|
351869
351978
|
return RATE_LIMIT_ERROR_MESSAGE_USE_GEMINI;
|
|
351870
351979
|
case AuthType2.USE_VERTEX_AI:
|
|
@@ -351877,7 +351986,7 @@ function parseAndFormatApiError(error, authType, userTier, currentModel, fallbac
|
|
|
351877
351986
|
if (isStructuredError(error)) {
|
|
351878
351987
|
let text = `[API Error: ${error.message}]`;
|
|
351879
351988
|
if (error.status === 429) {
|
|
351880
|
-
text += getRateLimitMessage(authType,
|
|
351989
|
+
text += getRateLimitMessage(authType, fallbackModel);
|
|
351881
351990
|
}
|
|
351882
351991
|
return text;
|
|
351883
351992
|
}
|
|
@@ -351900,7 +352009,7 @@ function parseAndFormatApiError(error, authType, userTier, currentModel, fallbac
|
|
|
351900
352009
|
}
|
|
351901
352010
|
let text = `[API Error: ${finalMessage} (Status: ${parsedError.error.status})]`;
|
|
351902
352011
|
if (parsedError.error.code === 429) {
|
|
351903
|
-
text += getRateLimitMessage(authType,
|
|
352012
|
+
text += getRateLimitMessage(authType, fallbackModel);
|
|
351904
352013
|
}
|
|
351905
352014
|
return text;
|
|
351906
352015
|
}
|