@google/genai 2.9.0-rc.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/genai.d.ts +570 -363
- package/dist/index.cjs +283 -120
- package/dist/index.mjs +284 -121
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +283 -120
- package/dist/node/index.mjs +284 -121
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +570 -363
- package/dist/tokenizer/node.cjs +56 -20
- package/dist/tokenizer/node.d.ts +41 -10
- package/dist/tokenizer/node.mjs +56 -20
- package/dist/tokenizer/node.mjs.map +1 -1
- package/dist/vertex_internal/index.cjs +57 -21
- package/dist/vertex_internal/index.cjs.map +1 -1
- package/dist/vertex_internal/index.d.ts +71 -18
- package/dist/vertex_internal/index.js +57 -21
- package/dist/vertex_internal/index.js.map +1 -1
- package/dist/web/index.mjs +284 -121
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +570 -363
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -682,26 +682,6 @@ var Type;
|
|
|
682
682
|
*/
|
|
683
683
|
Type["NULL"] = "NULL";
|
|
684
684
|
})(Type || (Type = {}));
|
|
685
|
-
/** The environment being operated. */
|
|
686
|
-
var Environment;
|
|
687
|
-
(function (Environment) {
|
|
688
|
-
/**
|
|
689
|
-
* Defaults to browser.
|
|
690
|
-
*/
|
|
691
|
-
Environment["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
|
|
692
|
-
/**
|
|
693
|
-
* Operates in a web browser.
|
|
694
|
-
*/
|
|
695
|
-
Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
696
|
-
/**
|
|
697
|
-
* Operates in a mobile environment.
|
|
698
|
-
*/
|
|
699
|
-
Environment["ENVIRONMENT_MOBILE"] = "ENVIRONMENT_MOBILE";
|
|
700
|
-
/**
|
|
701
|
-
* Operates in a desktop environment.
|
|
702
|
-
*/
|
|
703
|
-
Environment["ENVIRONMENT_DESKTOP"] = "ENVIRONMENT_DESKTOP";
|
|
704
|
-
})(Environment || (Environment = {}));
|
|
705
685
|
/** Type of auth scheme. This enum is not supported in Gemini API. */
|
|
706
686
|
var AuthType;
|
|
707
687
|
(function (AuthType) {
|
|
@@ -772,6 +752,62 @@ var ApiSpec;
|
|
|
772
752
|
*/
|
|
773
753
|
ApiSpec["ELASTIC_SEARCH"] = "ELASTIC_SEARCH";
|
|
774
754
|
})(ApiSpec || (ApiSpec = {}));
|
|
755
|
+
/** The environment being operated. */
|
|
756
|
+
var Environment;
|
|
757
|
+
(function (Environment) {
|
|
758
|
+
/**
|
|
759
|
+
* Defaults to browser.
|
|
760
|
+
*/
|
|
761
|
+
Environment["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
|
|
762
|
+
/**
|
|
763
|
+
* Operates in a web browser.
|
|
764
|
+
*/
|
|
765
|
+
Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
766
|
+
/**
|
|
767
|
+
* Operates in a mobile environment.
|
|
768
|
+
*/
|
|
769
|
+
Environment["ENVIRONMENT_MOBILE"] = "ENVIRONMENT_MOBILE";
|
|
770
|
+
/**
|
|
771
|
+
* Operates in a desktop environment.
|
|
772
|
+
*/
|
|
773
|
+
Environment["ENVIRONMENT_DESKTOP"] = "ENVIRONMENT_DESKTOP";
|
|
774
|
+
})(Environment || (Environment = {}));
|
|
775
|
+
/** SafetyPolicy */
|
|
776
|
+
var SafetyPolicy;
|
|
777
|
+
(function (SafetyPolicy) {
|
|
778
|
+
/**
|
|
779
|
+
* Unspecified safety policy.
|
|
780
|
+
*/
|
|
781
|
+
SafetyPolicy["SAFETY_POLICY_UNSPECIFIED"] = "SAFETY_POLICY_UNSPECIFIED";
|
|
782
|
+
/**
|
|
783
|
+
* Safety policy for financial transactions.
|
|
784
|
+
*/
|
|
785
|
+
SafetyPolicy["FINANCIAL_TRANSACTIONS"] = "FINANCIAL_TRANSACTIONS";
|
|
786
|
+
/**
|
|
787
|
+
* Safety policy for sensitive data modification.
|
|
788
|
+
*/
|
|
789
|
+
SafetyPolicy["SENSITIVE_DATA_MODIFICATION"] = "SENSITIVE_DATA_MODIFICATION";
|
|
790
|
+
/**
|
|
791
|
+
* Safety policy for communication tools (e.g. Gmail, Chat, Meet).
|
|
792
|
+
*/
|
|
793
|
+
SafetyPolicy["COMMUNICATION_TOOL"] = "COMMUNICATION_TOOL";
|
|
794
|
+
/**
|
|
795
|
+
* Safety policy for account creation.
|
|
796
|
+
*/
|
|
797
|
+
SafetyPolicy["ACCOUNT_CREATION"] = "ACCOUNT_CREATION";
|
|
798
|
+
/**
|
|
799
|
+
* Safety policy for data modification.
|
|
800
|
+
*/
|
|
801
|
+
SafetyPolicy["DATA_MODIFICATION"] = "DATA_MODIFICATION";
|
|
802
|
+
/**
|
|
803
|
+
* Safety policy for user consent management.
|
|
804
|
+
*/
|
|
805
|
+
SafetyPolicy["USER_CONSENT_MANAGEMENT"] = "USER_CONSENT_MANAGEMENT";
|
|
806
|
+
/**
|
|
807
|
+
* Safety policy for legal terms and agreements.
|
|
808
|
+
*/
|
|
809
|
+
SafetyPolicy["LEGAL_TERMS_AND_AGREEMENTS"] = "LEGAL_TERMS_AND_AGREEMENTS";
|
|
810
|
+
})(SafetyPolicy || (SafetyPolicy = {}));
|
|
775
811
|
/** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
|
|
776
812
|
var PhishBlockThreshold;
|
|
777
813
|
(function (PhishBlockThreshold) {
|
|
@@ -5951,6 +5987,29 @@ function codeExecutionResultToVertex$3(fromObject) {
|
|
|
5951
5987
|
}
|
|
5952
5988
|
return toObject;
|
|
5953
5989
|
}
|
|
5990
|
+
function computerUseToVertex$2(fromObject) {
|
|
5991
|
+
const toObject = {};
|
|
5992
|
+
const fromEnvironment = getValueByPath(fromObject, ['environment']);
|
|
5993
|
+
if (fromEnvironment != null) {
|
|
5994
|
+
setValueByPath(toObject, ['environment'], fromEnvironment);
|
|
5995
|
+
}
|
|
5996
|
+
const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
|
|
5997
|
+
'excludedPredefinedFunctions',
|
|
5998
|
+
]);
|
|
5999
|
+
if (fromExcludedPredefinedFunctions != null) {
|
|
6000
|
+
setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
|
|
6001
|
+
}
|
|
6002
|
+
const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
|
|
6003
|
+
'enablePromptInjectionDetection',
|
|
6004
|
+
]);
|
|
6005
|
+
if (fromEnablePromptInjectionDetection != null) {
|
|
6006
|
+
setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
|
|
6007
|
+
}
|
|
6008
|
+
if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
|
|
6009
|
+
throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
6010
|
+
}
|
|
6011
|
+
return toObject;
|
|
6012
|
+
}
|
|
5954
6013
|
function contentToMldev$3(fromObject) {
|
|
5955
6014
|
const toObject = {};
|
|
5956
6015
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
@@ -6626,7 +6685,7 @@ function toolToVertex$2(fromObject) {
|
|
|
6626
6685
|
}
|
|
6627
6686
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
6628
6687
|
if (fromComputerUse != null) {
|
|
6629
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
6688
|
+
setValueByPath(toObject, ['computerUse'], computerUseToVertex$2(fromComputerUse));
|
|
6630
6689
|
}
|
|
6631
6690
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
6632
6691
|
throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
@@ -7693,7 +7752,7 @@ class Files extends BaseModule {
|
|
|
7693
7752
|
* file extension.
|
|
7694
7753
|
* - For Blob object inputs, the `mimeType` will be set to the Blob's `type`
|
|
7695
7754
|
* property.
|
|
7696
|
-
*
|
|
7755
|
+
* Some examples for file extension to mimeType mapping:
|
|
7697
7756
|
* .txt -> text/plain
|
|
7698
7757
|
* .json -> application/json
|
|
7699
7758
|
* .jpg -> image/jpeg
|
|
@@ -7981,6 +8040,22 @@ function audioTranscriptionConfigToMldev$1(fromObject) {
|
|
|
7981
8040
|
if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
|
|
7982
8041
|
throw new Error('languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
|
|
7983
8042
|
}
|
|
8043
|
+
const fromLanguageAuto = getValueByPath(fromObject, ['languageAuto']);
|
|
8044
|
+
if (fromLanguageAuto != null) {
|
|
8045
|
+
setValueByPath(toObject, ['languageAuto'], fromLanguageAuto);
|
|
8046
|
+
}
|
|
8047
|
+
const fromLanguageHints = getValueByPath(fromObject, [
|
|
8048
|
+
'languageHints',
|
|
8049
|
+
]);
|
|
8050
|
+
if (fromLanguageHints != null) {
|
|
8051
|
+
setValueByPath(toObject, ['languageHints'], fromLanguageHints);
|
|
8052
|
+
}
|
|
8053
|
+
const fromAdaptationPhrases = getValueByPath(fromObject, [
|
|
8054
|
+
'adaptationPhrases',
|
|
8055
|
+
]);
|
|
8056
|
+
if (fromAdaptationPhrases != null) {
|
|
8057
|
+
setValueByPath(toObject, ['adaptationPhrases'], fromAdaptationPhrases);
|
|
8058
|
+
}
|
|
7984
8059
|
return toObject;
|
|
7985
8060
|
}
|
|
7986
8061
|
function authConfigToMldev$2(fromObject) {
|
|
@@ -8040,6 +8115,29 @@ function codeExecutionResultToVertex$2(fromObject) {
|
|
|
8040
8115
|
}
|
|
8041
8116
|
return toObject;
|
|
8042
8117
|
}
|
|
8118
|
+
function computerUseToVertex$1(fromObject) {
|
|
8119
|
+
const toObject = {};
|
|
8120
|
+
const fromEnvironment = getValueByPath(fromObject, ['environment']);
|
|
8121
|
+
if (fromEnvironment != null) {
|
|
8122
|
+
setValueByPath(toObject, ['environment'], fromEnvironment);
|
|
8123
|
+
}
|
|
8124
|
+
const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
|
|
8125
|
+
'excludedPredefinedFunctions',
|
|
8126
|
+
]);
|
|
8127
|
+
if (fromExcludedPredefinedFunctions != null) {
|
|
8128
|
+
setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
|
|
8129
|
+
}
|
|
8130
|
+
const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
|
|
8131
|
+
'enablePromptInjectionDetection',
|
|
8132
|
+
]);
|
|
8133
|
+
if (fromEnablePromptInjectionDetection != null) {
|
|
8134
|
+
setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
|
|
8135
|
+
}
|
|
8136
|
+
if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
|
|
8137
|
+
throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
8138
|
+
}
|
|
8139
|
+
return toObject;
|
|
8140
|
+
}
|
|
8043
8141
|
function contentToMldev$2(fromObject) {
|
|
8044
8142
|
const toObject = {};
|
|
8045
8143
|
const fromParts = getValueByPath(fromObject, ['parts']);
|
|
@@ -8998,7 +9096,7 @@ function toolToVertex$1(fromObject) {
|
|
|
8998
9096
|
}
|
|
8999
9097
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
9000
9098
|
if (fromComputerUse != null) {
|
|
9001
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
9099
|
+
setValueByPath(toObject, ['computerUse'], computerUseToVertex$1(fromComputerUse));
|
|
9002
9100
|
}
|
|
9003
9101
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
9004
9102
|
throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
@@ -9161,6 +9259,10 @@ function voiceActivityFromVertex(fromObject) {
|
|
|
9161
9259
|
if (fromVoiceActivityType != null) {
|
|
9162
9260
|
setValueByPath(toObject, ['voiceActivityType'], fromVoiceActivityType);
|
|
9163
9261
|
}
|
|
9262
|
+
const fromAudioOffset = getValueByPath(fromObject, ['audioOffset']);
|
|
9263
|
+
if (fromAudioOffset != null) {
|
|
9264
|
+
setValueByPath(toObject, ['audioOffset'], fromAudioOffset);
|
|
9265
|
+
}
|
|
9164
9266
|
return toObject;
|
|
9165
9267
|
}
|
|
9166
9268
|
|
|
@@ -9338,6 +9440,29 @@ function computeTokensResponseFromVertex(fromObject, _rootObject) {
|
|
|
9338
9440
|
}
|
|
9339
9441
|
return toObject;
|
|
9340
9442
|
}
|
|
9443
|
+
function computerUseToVertex(fromObject, _rootObject) {
|
|
9444
|
+
const toObject = {};
|
|
9445
|
+
const fromEnvironment = getValueByPath(fromObject, ['environment']);
|
|
9446
|
+
if (fromEnvironment != null) {
|
|
9447
|
+
setValueByPath(toObject, ['environment'], fromEnvironment);
|
|
9448
|
+
}
|
|
9449
|
+
const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
|
|
9450
|
+
'excludedPredefinedFunctions',
|
|
9451
|
+
]);
|
|
9452
|
+
if (fromExcludedPredefinedFunctions != null) {
|
|
9453
|
+
setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
|
|
9454
|
+
}
|
|
9455
|
+
const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
|
|
9456
|
+
'enablePromptInjectionDetection',
|
|
9457
|
+
]);
|
|
9458
|
+
if (fromEnablePromptInjectionDetection != null) {
|
|
9459
|
+
setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
|
|
9460
|
+
}
|
|
9461
|
+
if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
|
|
9462
|
+
throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
9463
|
+
}
|
|
9464
|
+
return toObject;
|
|
9465
|
+
}
|
|
9341
9466
|
function contentEmbeddingFromVertex(fromObject, rootObject) {
|
|
9342
9467
|
const toObject = {};
|
|
9343
9468
|
const fromValues = getValueByPath(fromObject, ['values']);
|
|
@@ -12416,7 +12541,7 @@ function toolToVertex(fromObject, rootObject) {
|
|
|
12416
12541
|
}
|
|
12417
12542
|
const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
|
|
12418
12543
|
if (fromComputerUse != null) {
|
|
12419
|
-
setValueByPath(toObject, ['computerUse'], fromComputerUse);
|
|
12544
|
+
setValueByPath(toObject, ['computerUse'], computerUseToVertex(fromComputerUse));
|
|
12420
12545
|
}
|
|
12421
12546
|
if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
|
|
12422
12547
|
throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
@@ -13040,7 +13165,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
13040
13165
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
13041
13166
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
13042
13167
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
13043
|
-
const SDK_VERSION = '2.
|
|
13168
|
+
const SDK_VERSION = '2.10.0'; // x-release-please-version
|
|
13044
13169
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
13045
13170
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
13046
13171
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -14754,7 +14879,7 @@ class Models extends BaseModule {
|
|
|
14754
14879
|
this.generateContent = async (params) => {
|
|
14755
14880
|
var _a, _b, _c, _d, _e;
|
|
14756
14881
|
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14757
|
-
this.
|
|
14882
|
+
this.maybeMoveToResponseJsonSchema(params);
|
|
14758
14883
|
if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
|
|
14759
14884
|
return await this.generateContentInternal(transformedParams);
|
|
14760
14885
|
}
|
|
@@ -14846,7 +14971,7 @@ class Models extends BaseModule {
|
|
|
14846
14971
|
*/
|
|
14847
14972
|
this.generateContentStream = async (params) => {
|
|
14848
14973
|
var _a, _b, _c, _d, _e;
|
|
14849
|
-
this.
|
|
14974
|
+
this.maybeMoveToResponseJsonSchema(params);
|
|
14850
14975
|
if (shouldDisableAfc(params.config)) {
|
|
14851
14976
|
const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
|
|
14852
14977
|
return await this.generateContentStreamInternal(transformedParams);
|
|
@@ -15071,7 +15196,7 @@ class Models extends BaseModule {
|
|
|
15071
15196
|
* To maintain backward compatibility, we move the data that was treated as
|
|
15072
15197
|
* JSON schema from the responseSchema field to the responseJsonSchema field.
|
|
15073
15198
|
*/
|
|
15074
|
-
|
|
15199
|
+
maybeMoveToResponseJsonSchema(params) {
|
|
15075
15200
|
if (params.config && params.config.responseSchema) {
|
|
15076
15201
|
if (!params.config.responseJsonSchema) {
|
|
15077
15202
|
if (Object.keys(params.config.responseSchema).includes('$schema')) {
|
|
@@ -15173,7 +15298,7 @@ class Models extends BaseModule {
|
|
|
15173
15298
|
throw new Error('Function call name was not returned by the model.');
|
|
15174
15299
|
}
|
|
15175
15300
|
if (!afcTools.has(part.functionCall.name)) {
|
|
15176
|
-
throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${afcTools.keys()},
|
|
15301
|
+
throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${afcTools.keys()}, missing tool: ${part.functionCall.name}`);
|
|
15177
15302
|
}
|
|
15178
15303
|
else {
|
|
15179
15304
|
const responseParts = yield __await(afcTools
|
|
@@ -16394,6 +16519,22 @@ function audioTranscriptionConfigToMldev(fromObject) {
|
|
|
16394
16519
|
if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
|
|
16395
16520
|
throw new Error('languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
|
|
16396
16521
|
}
|
|
16522
|
+
const fromLanguageAuto = getValueByPath(fromObject, ['languageAuto']);
|
|
16523
|
+
if (fromLanguageAuto != null) {
|
|
16524
|
+
setValueByPath(toObject, ['languageAuto'], fromLanguageAuto);
|
|
16525
|
+
}
|
|
16526
|
+
const fromLanguageHints = getValueByPath(fromObject, [
|
|
16527
|
+
'languageHints',
|
|
16528
|
+
]);
|
|
16529
|
+
if (fromLanguageHints != null) {
|
|
16530
|
+
setValueByPath(toObject, ['languageHints'], fromLanguageHints);
|
|
16531
|
+
}
|
|
16532
|
+
const fromAdaptationPhrases = getValueByPath(fromObject, [
|
|
16533
|
+
'adaptationPhrases',
|
|
16534
|
+
]);
|
|
16535
|
+
if (fromAdaptationPhrases != null) {
|
|
16536
|
+
setValueByPath(toObject, ['adaptationPhrases'], fromAdaptationPhrases);
|
|
16537
|
+
}
|
|
16397
16538
|
return toObject;
|
|
16398
16539
|
}
|
|
16399
16540
|
function authConfigToMldev(fromObject) {
|
|
@@ -18000,15 +18141,6 @@ class GoogleGenAiError extends Error {
|
|
|
18000
18141
|
* g3-prettier-ignore-file
|
|
18001
18142
|
*/
|
|
18002
18143
|
class GeminiNextGenAPIClientError extends Error {
|
|
18003
|
-
static [Symbol.hasInstance](instance) {
|
|
18004
|
-
if (Function.prototype[Symbol.hasInstance].call(this, instance)) {
|
|
18005
|
-
return true;
|
|
18006
|
-
}
|
|
18007
|
-
if (this === GeminiNextGenAPIClientError) {
|
|
18008
|
-
return isKnownLegacyErrorLike(instance);
|
|
18009
|
-
}
|
|
18010
|
-
return isNamedLegacyErrorLike(instance, this.name);
|
|
18011
|
-
}
|
|
18012
18144
|
}
|
|
18013
18145
|
/** General errors raised by the GenAI API. */
|
|
18014
18146
|
class APIError extends GeminiNextGenAPIClientError {
|
|
@@ -18023,6 +18155,7 @@ class APIError extends GeminiNextGenAPIClientError {
|
|
|
18023
18155
|
this.rawResponse = undefined;
|
|
18024
18156
|
this.cause = undefined;
|
|
18025
18157
|
this.name = this.constructor.name;
|
|
18158
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
18026
18159
|
}
|
|
18027
18160
|
static makeMessage(status, error, message) {
|
|
18028
18161
|
var _a;
|
|
@@ -18034,15 +18167,6 @@ class APIError extends GeminiNextGenAPIClientError {
|
|
|
18034
18167
|
const statusText = status ? `${status} ` : "";
|
|
18035
18168
|
return `${statusText}${msg}`;
|
|
18036
18169
|
}
|
|
18037
|
-
static [Symbol.hasInstance](instance) {
|
|
18038
|
-
if (Function.prototype[Symbol.hasInstance].call(this, instance)) {
|
|
18039
|
-
return true;
|
|
18040
|
-
}
|
|
18041
|
-
if (this === APIError) {
|
|
18042
|
-
return isAPIErrorLike(instance);
|
|
18043
|
-
}
|
|
18044
|
-
return isNamedLegacyErrorLike(instance, this.name);
|
|
18045
|
-
}
|
|
18046
18170
|
static generate(status, errorResponse, message, headers) {
|
|
18047
18171
|
if (!status || !headers) {
|
|
18048
18172
|
return new APIConnectionError({
|
|
@@ -18183,57 +18307,12 @@ function stringifyErrorBody(error) {
|
|
|
18183
18307
|
function isPlainObject$2(value) {
|
|
18184
18308
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
18185
18309
|
}
|
|
18186
|
-
function isLegacyErrorLike(value) {
|
|
18187
|
-
if (!(value instanceof Error) || !isPlainObject$2(value)) {
|
|
18188
|
-
return false;
|
|
18189
|
-
}
|
|
18190
|
-
return ("status" in value ||
|
|
18191
|
-
"statusCode" in value ||
|
|
18192
|
-
"error" in value ||
|
|
18193
|
-
"headers" in value);
|
|
18194
|
-
}
|
|
18195
|
-
function isAPIErrorLike(value) {
|
|
18196
|
-
return isLegacyErrorLike(value) && "error" in value;
|
|
18197
|
-
}
|
|
18198
18310
|
function isCompatAPIErrorInstance(value) {
|
|
18311
|
+
// Avoid instanceof here so this guard never depends on Symbol.hasInstance.
|
|
18199
18312
|
return typeof value === "object" && value !== null
|
|
18200
18313
|
? APIError.prototype.isPrototypeOf(value)
|
|
18201
18314
|
: false;
|
|
18202
18315
|
}
|
|
18203
|
-
const knownLegacyErrorNames = [
|
|
18204
|
-
"GeminiNextGenAPIClientError",
|
|
18205
|
-
"APIError",
|
|
18206
|
-
"APIUserAbortError",
|
|
18207
|
-
"APIConnectionError",
|
|
18208
|
-
"APIConnectionTimeoutError",
|
|
18209
|
-
"BadRequestError",
|
|
18210
|
-
"AuthenticationError",
|
|
18211
|
-
"PermissionDeniedError",
|
|
18212
|
-
"NotFoundError",
|
|
18213
|
-
"ConflictError",
|
|
18214
|
-
"UnprocessableEntityError",
|
|
18215
|
-
"RateLimitError",
|
|
18216
|
-
"InternalServerError",
|
|
18217
|
-
];
|
|
18218
|
-
const legacySubclassNamesByBaseName = {
|
|
18219
|
-
GeminiNextGenAPIClientError: knownLegacyErrorNames,
|
|
18220
|
-
APIConnectionError: ["APIConnectionTimeoutError"],
|
|
18221
|
-
};
|
|
18222
|
-
function isKnownLegacyErrorLike(value) {
|
|
18223
|
-
if (!isLegacyErrorLike(value)) {
|
|
18224
|
-
return false;
|
|
18225
|
-
}
|
|
18226
|
-
return knownLegacyErrorNames.includes(value.name);
|
|
18227
|
-
}
|
|
18228
|
-
function isNamedLegacyErrorLike(value, name) {
|
|
18229
|
-
var _a, _b;
|
|
18230
|
-
if (!isLegacyErrorLike(value)) {
|
|
18231
|
-
return false;
|
|
18232
|
-
}
|
|
18233
|
-
const valueName = value.name;
|
|
18234
|
-
return (valueName === name ||
|
|
18235
|
-
((_b = (_a = legacySubclassNamesByBaseName[name]) === null || _a === void 0 ? void 0 : _a.includes(valueName)) !== null && _b !== void 0 ? _b : false));
|
|
18236
|
-
}
|
|
18237
18316
|
function defineReadonly(target, key, value) {
|
|
18238
18317
|
Object.defineProperty(target, key, {
|
|
18239
18318
|
configurable: true,
|
|
@@ -18443,7 +18522,7 @@ function serverURLFromOptions(options) {
|
|
|
18443
18522
|
return new URL(u);
|
|
18444
18523
|
}
|
|
18445
18524
|
const SDK_METADATA = {
|
|
18446
|
-
userAgent: "speakeasy-sdk/typescript 2.4.1-preview.4 2.
|
|
18525
|
+
userAgent: "speakeasy-sdk/typescript 2.4.1-preview.4 2.911.0 v1beta @google/genai",
|
|
18447
18526
|
};
|
|
18448
18527
|
|
|
18449
18528
|
/**
|
|
@@ -18992,14 +19071,19 @@ async function retry(fetchFn, options) {
|
|
|
18992
19071
|
statusCodes: options.statusCodes,
|
|
18993
19072
|
retryConnectionErrors: !!options.config.retryConnectionErrors,
|
|
18994
19073
|
}), (_a = options.config.backoff) !== null && _a !== void 0 ? _a : defaultBackoff);
|
|
19074
|
+
case "attempt-count-backoff":
|
|
19075
|
+
return retryAttemptCountBackoff(wrapFetcher(fetchFn, {
|
|
19076
|
+
statusCodes: options.statusCodes,
|
|
19077
|
+
retryConnectionErrors: !!options.config.retryConnectionErrors,
|
|
19078
|
+
}), Object.assign(Object.assign({}, defaultBackoff), options.config.backoff), options.config);
|
|
18995
19079
|
default:
|
|
18996
|
-
return await fetchFn();
|
|
19080
|
+
return await fetchFn(0);
|
|
18997
19081
|
}
|
|
18998
19082
|
}
|
|
18999
19083
|
function wrapFetcher(fn, options) {
|
|
19000
|
-
return async () => {
|
|
19084
|
+
return async (attempt) => {
|
|
19001
19085
|
try {
|
|
19002
|
-
const res = await fn();
|
|
19086
|
+
const res = await fn(attempt);
|
|
19003
19087
|
if (isRetryableResponse(res, options.statusCodes)) {
|
|
19004
19088
|
throw new TemporaryError("Response failed with retryable status code", res);
|
|
19005
19089
|
}
|
|
@@ -19041,7 +19125,7 @@ async function retryBackoff(fn, strategy) {
|
|
|
19041
19125
|
let x = 0;
|
|
19042
19126
|
while (true) {
|
|
19043
19127
|
try {
|
|
19044
|
-
const res = await fn();
|
|
19128
|
+
const res = await fn(x);
|
|
19045
19129
|
return res;
|
|
19046
19130
|
}
|
|
19047
19131
|
catch (err) {
|
|
@@ -19069,7 +19153,46 @@ async function retryBackoff(fn, strategy) {
|
|
|
19069
19153
|
}
|
|
19070
19154
|
}
|
|
19071
19155
|
}
|
|
19156
|
+
async function retryAttemptCountBackoff(fn, strategy, config) {
|
|
19157
|
+
let attempt = 0;
|
|
19158
|
+
while (true) {
|
|
19159
|
+
try {
|
|
19160
|
+
return await fn(attempt);
|
|
19161
|
+
}
|
|
19162
|
+
catch (err) {
|
|
19163
|
+
if (err instanceof PermanentError) {
|
|
19164
|
+
throw err.cause;
|
|
19165
|
+
}
|
|
19166
|
+
if (attempt >= config.maxRetries) {
|
|
19167
|
+
if (err instanceof TemporaryError) {
|
|
19168
|
+
return err.response;
|
|
19169
|
+
}
|
|
19170
|
+
throw err;
|
|
19171
|
+
}
|
|
19172
|
+
let retryInterval = 0;
|
|
19173
|
+
if (err instanceof TemporaryError) {
|
|
19174
|
+
retryInterval = retryIntervalFromResponse(err.response);
|
|
19175
|
+
}
|
|
19176
|
+
if (retryInterval <= 0) {
|
|
19177
|
+
retryInterval =
|
|
19178
|
+
strategy.initialInterval *
|
|
19179
|
+
Math.pow(strategy.exponent, attempt) *
|
|
19180
|
+
(1 - Math.random() * 0.25);
|
|
19181
|
+
}
|
|
19182
|
+
const d = Math.min(retryInterval, strategy.maxInterval);
|
|
19183
|
+
await delay(d);
|
|
19184
|
+
attempt++;
|
|
19185
|
+
}
|
|
19186
|
+
}
|
|
19187
|
+
}
|
|
19072
19188
|
function retryIntervalFromResponse(res) {
|
|
19189
|
+
const retryAfterMsVal = res.headers.get("retry-after-ms");
|
|
19190
|
+
if (retryAfterMsVal) {
|
|
19191
|
+
const parsedMs = Number(retryAfterMsVal);
|
|
19192
|
+
if (Number.isFinite(parsedMs) && parsedMs >= 0) {
|
|
19193
|
+
return parsedMs;
|
|
19194
|
+
}
|
|
19195
|
+
}
|
|
19073
19196
|
const retryVal = res.headers.get("retry-after") || "";
|
|
19074
19197
|
if (!retryVal) {
|
|
19075
19198
|
return 0;
|
|
@@ -19524,13 +19647,12 @@ class Stream extends ReadableStream {
|
|
|
19524
19647
|
cancel: reason => upstream.cancel(reason),
|
|
19525
19648
|
});
|
|
19526
19649
|
}
|
|
19527
|
-
|
|
19528
|
-
[Symbol.asyncIterator]() {
|
|
19650
|
+
[Symbol.asyncIterator](options) {
|
|
19529
19651
|
const fn = ReadableStream.prototype[Symbol.asyncIterator];
|
|
19530
19652
|
if (typeof fn === "function")
|
|
19531
|
-
return fn.call(this);
|
|
19653
|
+
return fn.call(this, options);
|
|
19532
19654
|
const reader = this.getReader();
|
|
19533
|
-
|
|
19655
|
+
const iterator = {
|
|
19534
19656
|
next: async () => {
|
|
19535
19657
|
const r = await reader.read();
|
|
19536
19658
|
if (r.done) {
|
|
@@ -19553,6 +19675,17 @@ class Stream extends ReadableStream {
|
|
|
19553
19675
|
return this;
|
|
19554
19676
|
},
|
|
19555
19677
|
};
|
|
19678
|
+
const asyncDispose = Symbol.asyncDispose;
|
|
19679
|
+
if (asyncDispose) {
|
|
19680
|
+
iterator[asyncDispose] = async () => {
|
|
19681
|
+
var _a;
|
|
19682
|
+
await ((_a = iterator.return) === null || _a === void 0 ? void 0 : _a.call(iterator));
|
|
19683
|
+
};
|
|
19684
|
+
}
|
|
19685
|
+
return iterator;
|
|
19686
|
+
}
|
|
19687
|
+
values(options) {
|
|
19688
|
+
return this[Symbol.asyncIterator](options);
|
|
19556
19689
|
}
|
|
19557
19690
|
}
|
|
19558
19691
|
const CR = 13;
|
|
@@ -19693,7 +19826,16 @@ function match(...matchers) {
|
|
|
19693
19826
|
switch (encoding) {
|
|
19694
19827
|
case "json":
|
|
19695
19828
|
body = await response.text();
|
|
19696
|
-
|
|
19829
|
+
try {
|
|
19830
|
+
raw = JSON.parse(body);
|
|
19831
|
+
}
|
|
19832
|
+
catch (err) {
|
|
19833
|
+
// Passthrough for malformed error bodies; success bodies must be valid.
|
|
19834
|
+
if (!("err" in matcher)) {
|
|
19835
|
+
throw err;
|
|
19836
|
+
}
|
|
19837
|
+
raw = body;
|
|
19838
|
+
}
|
|
19697
19839
|
break;
|
|
19698
19840
|
case "jsonl":
|
|
19699
19841
|
raw = response.body;
|
|
@@ -20051,7 +20193,7 @@ async function $do$e(client, body, api_version, options) {
|
|
|
20051
20193
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20052
20194
|
|| client._options.retry_config
|
|
20053
20195
|
|| {
|
|
20054
|
-
strategy: "backoff",
|
|
20196
|
+
strategy: "attempt-count-backoff",
|
|
20055
20197
|
backoff: {
|
|
20056
20198
|
initialInterval: 500,
|
|
20057
20199
|
maxInterval: 8000,
|
|
@@ -20059,6 +20201,7 @@ async function $do$e(client, body, api_version, options) {
|
|
|
20059
20201
|
maxElapsedTime: 30000,
|
|
20060
20202
|
},
|
|
20061
20203
|
retryConnectionErrors: true,
|
|
20204
|
+
maxRetries: 4,
|
|
20062
20205
|
}
|
|
20063
20206
|
|| { strategy: "none" },
|
|
20064
20207
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20138,7 +20281,7 @@ async function $do$d(client, id, api_version, options) {
|
|
|
20138
20281
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20139
20282
|
|| client._options.retry_config
|
|
20140
20283
|
|| {
|
|
20141
|
-
strategy: "backoff",
|
|
20284
|
+
strategy: "attempt-count-backoff",
|
|
20142
20285
|
backoff: {
|
|
20143
20286
|
initialInterval: 500,
|
|
20144
20287
|
maxInterval: 8000,
|
|
@@ -20146,6 +20289,7 @@ async function $do$d(client, id, api_version, options) {
|
|
|
20146
20289
|
maxElapsedTime: 30000,
|
|
20147
20290
|
},
|
|
20148
20291
|
retryConnectionErrors: true,
|
|
20292
|
+
maxRetries: 4,
|
|
20149
20293
|
}
|
|
20150
20294
|
|| { strategy: "none" },
|
|
20151
20295
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20225,7 +20369,7 @@ async function $do$c(client, id, api_version, options) {
|
|
|
20225
20369
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20226
20370
|
|| client._options.retry_config
|
|
20227
20371
|
|| {
|
|
20228
|
-
strategy: "backoff",
|
|
20372
|
+
strategy: "attempt-count-backoff",
|
|
20229
20373
|
backoff: {
|
|
20230
20374
|
initialInterval: 500,
|
|
20231
20375
|
maxInterval: 8000,
|
|
@@ -20233,6 +20377,7 @@ async function $do$c(client, id, api_version, options) {
|
|
|
20233
20377
|
maxElapsedTime: 30000,
|
|
20234
20378
|
},
|
|
20235
20379
|
retryConnectionErrors: true,
|
|
20380
|
+
maxRetries: 4,
|
|
20236
20381
|
}
|
|
20237
20382
|
|| { strategy: "none" },
|
|
20238
20383
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20315,7 +20460,7 @@ async function $do$b(client, api_version, page_size, page_token, parent, options
|
|
|
20315
20460
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20316
20461
|
|| client._options.retry_config
|
|
20317
20462
|
|| {
|
|
20318
|
-
strategy: "backoff",
|
|
20463
|
+
strategy: "attempt-count-backoff",
|
|
20319
20464
|
backoff: {
|
|
20320
20465
|
initialInterval: 500,
|
|
20321
20466
|
maxInterval: 8000,
|
|
@@ -20323,6 +20468,7 @@ async function $do$b(client, api_version, page_size, page_token, parent, options
|
|
|
20323
20468
|
maxElapsedTime: 30000,
|
|
20324
20469
|
},
|
|
20325
20470
|
retryConnectionErrors: true,
|
|
20471
|
+
maxRetries: 4,
|
|
20326
20472
|
}
|
|
20327
20473
|
|| { strategy: "none" },
|
|
20328
20474
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20585,7 +20731,7 @@ async function $do$a(client, id, api_version, options) {
|
|
|
20585
20731
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20586
20732
|
|| client._options.retry_config
|
|
20587
20733
|
|| {
|
|
20588
|
-
strategy: "backoff",
|
|
20734
|
+
strategy: "attempt-count-backoff",
|
|
20589
20735
|
backoff: {
|
|
20590
20736
|
initialInterval: 500,
|
|
20591
20737
|
maxInterval: 8000,
|
|
@@ -20593,6 +20739,7 @@ async function $do$a(client, id, api_version, options) {
|
|
|
20593
20739
|
maxElapsedTime: 30000,
|
|
20594
20740
|
},
|
|
20595
20741
|
retryConnectionErrors: true,
|
|
20742
|
+
maxRetries: 4,
|
|
20596
20743
|
}
|
|
20597
20744
|
|| { strategy: "none" },
|
|
20598
20745
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20669,7 +20816,7 @@ async function $do$9(client, body, api_version, options) {
|
|
|
20669
20816
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20670
20817
|
|| client._options.retry_config
|
|
20671
20818
|
|| {
|
|
20672
|
-
strategy: "backoff",
|
|
20819
|
+
strategy: "attempt-count-backoff",
|
|
20673
20820
|
backoff: {
|
|
20674
20821
|
initialInterval: 500,
|
|
20675
20822
|
maxInterval: 8000,
|
|
@@ -20677,6 +20824,7 @@ async function $do$9(client, body, api_version, options) {
|
|
|
20677
20824
|
maxElapsedTime: 30000,
|
|
20678
20825
|
},
|
|
20679
20826
|
retryConnectionErrors: true,
|
|
20827
|
+
maxRetries: 4,
|
|
20680
20828
|
}
|
|
20681
20829
|
|| { strategy: "none" },
|
|
20682
20830
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20765,7 +20913,7 @@ async function $do$8(client, id, api_version, options) {
|
|
|
20765
20913
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20766
20914
|
|| client._options.retry_config
|
|
20767
20915
|
|| {
|
|
20768
|
-
strategy: "backoff",
|
|
20916
|
+
strategy: "attempt-count-backoff",
|
|
20769
20917
|
backoff: {
|
|
20770
20918
|
initialInterval: 500,
|
|
20771
20919
|
maxInterval: 8000,
|
|
@@ -20773,6 +20921,7 @@ async function $do$8(client, id, api_version, options) {
|
|
|
20773
20921
|
maxElapsedTime: 30000,
|
|
20774
20922
|
},
|
|
20775
20923
|
retryConnectionErrors: true,
|
|
20924
|
+
maxRetries: 4,
|
|
20776
20925
|
}
|
|
20777
20926
|
|| { strategy: "none" },
|
|
20778
20927
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20860,7 +21009,7 @@ async function $do$7(client, id, stream, last_event_id, include_input, api_versi
|
|
|
20860
21009
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20861
21010
|
|| client._options.retry_config
|
|
20862
21011
|
|| {
|
|
20863
|
-
strategy: "backoff",
|
|
21012
|
+
strategy: "attempt-count-backoff",
|
|
20864
21013
|
backoff: {
|
|
20865
21014
|
initialInterval: 500,
|
|
20866
21015
|
maxInterval: 8000,
|
|
@@ -20868,6 +21017,7 @@ async function $do$7(client, id, stream, last_event_id, include_input, api_versi
|
|
|
20868
21017
|
maxElapsedTime: 30000,
|
|
20869
21018
|
},
|
|
20870
21019
|
retryConnectionErrors: true,
|
|
21020
|
+
maxRetries: 4,
|
|
20871
21021
|
}
|
|
20872
21022
|
|| { strategy: "none" },
|
|
20873
21023
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -20986,7 +21136,7 @@ async function $do$6(client, body, api_version, options) {
|
|
|
20986
21136
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
20987
21137
|
|| client._options.retry_config
|
|
20988
21138
|
|| {
|
|
20989
|
-
strategy: "backoff",
|
|
21139
|
+
strategy: "attempt-count-backoff",
|
|
20990
21140
|
backoff: {
|
|
20991
21141
|
initialInterval: 500,
|
|
20992
21142
|
maxInterval: 8000,
|
|
@@ -20994,6 +21144,7 @@ async function $do$6(client, body, api_version, options) {
|
|
|
20994
21144
|
maxElapsedTime: 30000,
|
|
20995
21145
|
},
|
|
20996
21146
|
retryConnectionErrors: true,
|
|
21147
|
+
maxRetries: 4,
|
|
20997
21148
|
}
|
|
20998
21149
|
|| { strategy: "none" },
|
|
20999
21150
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21073,7 +21224,7 @@ async function $do$5(client, id, api_version, options) {
|
|
|
21073
21224
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21074
21225
|
|| client._options.retry_config
|
|
21075
21226
|
|| {
|
|
21076
|
-
strategy: "backoff",
|
|
21227
|
+
strategy: "attempt-count-backoff",
|
|
21077
21228
|
backoff: {
|
|
21078
21229
|
initialInterval: 500,
|
|
21079
21230
|
maxInterval: 8000,
|
|
@@ -21081,6 +21232,7 @@ async function $do$5(client, id, api_version, options) {
|
|
|
21081
21232
|
maxElapsedTime: 30000,
|
|
21082
21233
|
},
|
|
21083
21234
|
retryConnectionErrors: true,
|
|
21235
|
+
maxRetries: 4,
|
|
21084
21236
|
}
|
|
21085
21237
|
|| { strategy: "none" },
|
|
21086
21238
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21160,7 +21312,7 @@ async function $do$4(client, id, api_version, options) {
|
|
|
21160
21312
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21161
21313
|
|| client._options.retry_config
|
|
21162
21314
|
|| {
|
|
21163
|
-
strategy: "backoff",
|
|
21315
|
+
strategy: "attempt-count-backoff",
|
|
21164
21316
|
backoff: {
|
|
21165
21317
|
initialInterval: 500,
|
|
21166
21318
|
maxInterval: 8000,
|
|
@@ -21168,6 +21320,7 @@ async function $do$4(client, id, api_version, options) {
|
|
|
21168
21320
|
maxElapsedTime: 30000,
|
|
21169
21321
|
},
|
|
21170
21322
|
retryConnectionErrors: true,
|
|
21323
|
+
maxRetries: 4,
|
|
21171
21324
|
}
|
|
21172
21325
|
|| { strategy: "none" },
|
|
21173
21326
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21248,7 +21401,7 @@ async function $do$3(client, api_version, page_size, page_token, options) {
|
|
|
21248
21401
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21249
21402
|
|| client._options.retry_config
|
|
21250
21403
|
|| {
|
|
21251
|
-
strategy: "backoff",
|
|
21404
|
+
strategy: "attempt-count-backoff",
|
|
21252
21405
|
backoff: {
|
|
21253
21406
|
initialInterval: 500,
|
|
21254
21407
|
maxInterval: 8000,
|
|
@@ -21256,6 +21409,7 @@ async function $do$3(client, api_version, page_size, page_token, options) {
|
|
|
21256
21409
|
maxElapsedTime: 30000,
|
|
21257
21410
|
},
|
|
21258
21411
|
retryConnectionErrors: true,
|
|
21412
|
+
maxRetries: 4,
|
|
21259
21413
|
}
|
|
21260
21414
|
|| { strategy: "none" },
|
|
21261
21415
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21338,7 +21492,7 @@ async function $do$2(client, id, api_version, body, options) {
|
|
|
21338
21492
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21339
21493
|
|| client._options.retry_config
|
|
21340
21494
|
|| {
|
|
21341
|
-
strategy: "backoff",
|
|
21495
|
+
strategy: "attempt-count-backoff",
|
|
21342
21496
|
backoff: {
|
|
21343
21497
|
initialInterval: 500,
|
|
21344
21498
|
maxInterval: 8000,
|
|
@@ -21346,6 +21500,7 @@ async function $do$2(client, id, api_version, body, options) {
|
|
|
21346
21500
|
maxElapsedTime: 30000,
|
|
21347
21501
|
},
|
|
21348
21502
|
retryConnectionErrors: true,
|
|
21503
|
+
maxRetries: 4,
|
|
21349
21504
|
}
|
|
21350
21505
|
|| { strategy: "none" },
|
|
21351
21506
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21427,7 +21582,7 @@ async function $do$1(client, id, api_version, body, options) {
|
|
|
21427
21582
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21428
21583
|
|| client._options.retry_config
|
|
21429
21584
|
|| {
|
|
21430
|
-
strategy: "backoff",
|
|
21585
|
+
strategy: "attempt-count-backoff",
|
|
21431
21586
|
backoff: {
|
|
21432
21587
|
initialInterval: 500,
|
|
21433
21588
|
maxInterval: 8000,
|
|
@@ -21435,6 +21590,7 @@ async function $do$1(client, id, api_version, body, options) {
|
|
|
21435
21590
|
maxElapsedTime: 30000,
|
|
21436
21591
|
},
|
|
21437
21592
|
retryConnectionErrors: true,
|
|
21593
|
+
maxRetries: 4,
|
|
21438
21594
|
}
|
|
21439
21595
|
|| { strategy: "none" },
|
|
21440
21596
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21520,7 +21676,7 @@ async function $do(client, id, api_version, update_mask, body, options) {
|
|
|
21520
21676
|
retry_config: (options === null || options === void 0 ? void 0 : options.retries)
|
|
21521
21677
|
|| client._options.retry_config
|
|
21522
21678
|
|| {
|
|
21523
|
-
strategy: "backoff",
|
|
21679
|
+
strategy: "attempt-count-backoff",
|
|
21524
21680
|
backoff: {
|
|
21525
21681
|
initialInterval: 500,
|
|
21526
21682
|
maxInterval: 8000,
|
|
@@ -21528,6 +21684,7 @@ async function $do(client, id, api_version, update_mask, body, options) {
|
|
|
21528
21684
|
maxElapsedTime: 30000,
|
|
21529
21685
|
},
|
|
21530
21686
|
retryConnectionErrors: true,
|
|
21687
|
+
maxRetries: 4,
|
|
21531
21688
|
}
|
|
21532
21689
|
|| { strategy: "none" },
|
|
21533
21690
|
retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
|
|
@@ -21794,7 +21951,7 @@ function toGoogleGenAIRequestOptions(options, streaming = false) {
|
|
|
21794
21951
|
if (!options && !streaming) {
|
|
21795
21952
|
return undefined;
|
|
21796
21953
|
}
|
|
21797
|
-
const _e = options !== null && options !== void 0 ? options : {}, { timeout, maxRetries
|
|
21954
|
+
const _e = options !== null && options !== void 0 ? options : {}, { timeout, maxRetries, defaultBaseURL, query, body, fetchOptions } = _e, rest = __rest(_e, ["timeout", "maxRetries", "defaultBaseURL", "query", "body", "fetchOptions"]);
|
|
21798
21955
|
const nextOptions = Object.assign({}, rest);
|
|
21799
21956
|
if (isPlainObject(query)) {
|
|
21800
21957
|
nextOptions.extra_query = query;
|
|
@@ -21820,6 +21977,13 @@ function toGoogleGenAIRequestOptions(options, streaming = false) {
|
|
|
21820
21977
|
if (timeout_ms !== undefined) {
|
|
21821
21978
|
nextOptions.timeout_ms = timeout_ms;
|
|
21822
21979
|
}
|
|
21980
|
+
if (maxRetries !== undefined) {
|
|
21981
|
+
nextOptions.retries = {
|
|
21982
|
+
strategy: "attempt-count-backoff",
|
|
21983
|
+
retryConnectionErrors: true,
|
|
21984
|
+
maxRetries,
|
|
21985
|
+
};
|
|
21986
|
+
}
|
|
21823
21987
|
if (streaming) {
|
|
21824
21988
|
const headers = new Headers((_d = nextOptions.headers) !== null && _d !== void 0 ? _d : fetch_options === null || fetch_options === void 0 ? void 0 : fetch_options.headers);
|
|
21825
21989
|
headers.set("Accept", "text/event-stream");
|
|
@@ -24431,7 +24595,6 @@ class GoogleGenAI {
|
|
|
24431
24595
|
if (this._interactions !== undefined) {
|
|
24432
24596
|
return this._interactions;
|
|
24433
24597
|
}
|
|
24434
|
-
console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
|
|
24435
24598
|
this._interactions = new GeminiNextGenInteractions(this.apiClient);
|
|
24436
24599
|
return this._interactions;
|
|
24437
24600
|
}
|
|
@@ -24556,5 +24719,5 @@ function getApiKeyFromEnv() {
|
|
|
24556
24719
|
return envGoogleApiKey || envGeminiApiKey || undefined;
|
|
24557
24720
|
}
|
|
24558
24721
|
|
|
24559
|
-
export { ActivityHandling, AdapterSize, AggregationMetric, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EmbeddingApiType, EndSensitivity, Environment, EvaluateDatasetResponse, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImageResizeMode, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MatchOperation, MediaModality, MediaResolution, Modality, ModelStage, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PairwiseChoice, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, ProminentPeople, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReinforcementTuningAutoraterScorerParsedResponseConversionScorer, ReinforcementTuningParseResponseConfig, ReinforcementTuningThinkingLevel, ReplayResponse, ResourceScope, ResponseParseType, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, ServiceTier, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, ToolResponse, ToolType, TrafficType, TuningJobState, TuningMethod, TuningMode, TuningSpeed, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, ValidateRewardResponse, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VideoOrientation, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
24722
|
+
export { ActivityHandling, AdapterSize, AggregationMetric, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EmbeddingApiType, EndSensitivity, Environment, EvaluateDatasetResponse, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImageResizeMode, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MatchOperation, MediaModality, MediaResolution, Modality, ModelStage, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PairwiseChoice, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, ProminentPeople, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReinforcementTuningAutoraterScorerParsedResponseConversionScorer, ReinforcementTuningParseResponseConfig, ReinforcementTuningThinkingLevel, ReplayResponse, ResourceScope, ResponseParseType, SafetyFilterLevel, SafetyPolicy, Scale, SegmentImageResponse, SegmentMode, ServiceTier, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, ToolResponse, ToolType, TrafficType, TuningJobState, TuningMethod, TuningMode, TuningSpeed, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, ValidateRewardResponse, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VideoOrientation, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
24560
24723
|
//# sourceMappingURL=index.mjs.map
|