@google/genai 2.9.0-rc.0 → 2.9.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/dist/index.mjs CHANGED
@@ -7739,7 +7739,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
7739
7739
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
7740
7740
  const USER_AGENT_HEADER = 'User-Agent';
7741
7741
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
7742
- const SDK_VERSION = '2.9.0-rc.0'; // x-release-please-version
7742
+ const SDK_VERSION = '2.9.0'; // x-release-please-version
7743
7743
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
7744
7744
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
7745
7745
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -9880,15 +9880,6 @@ class GoogleGenAiError extends Error {
9880
9880
  * g3-prettier-ignore-file
9881
9881
  */
9882
9882
  class GeminiNextGenAPIClientError extends Error {
9883
- static [Symbol.hasInstance](instance) {
9884
- if (Function.prototype[Symbol.hasInstance].call(this, instance)) {
9885
- return true;
9886
- }
9887
- if (this === GeminiNextGenAPIClientError) {
9888
- return isKnownLegacyErrorLike(instance);
9889
- }
9890
- return isNamedLegacyErrorLike(instance, this.name);
9891
- }
9892
9883
  }
9893
9884
  /** General errors raised by the GenAI API. */
9894
9885
  class APIError extends GeminiNextGenAPIClientError {
@@ -9903,6 +9894,7 @@ class APIError extends GeminiNextGenAPIClientError {
9903
9894
  this.rawResponse = undefined;
9904
9895
  this.cause = undefined;
9905
9896
  this.name = this.constructor.name;
9897
+ Object.setPrototypeOf(this, new.target.prototype);
9906
9898
  }
9907
9899
  static makeMessage(status, error, message) {
9908
9900
  var _a;
@@ -9914,15 +9906,6 @@ class APIError extends GeminiNextGenAPIClientError {
9914
9906
  const statusText = status ? `${status} ` : "";
9915
9907
  return `${statusText}${msg}`;
9916
9908
  }
9917
- static [Symbol.hasInstance](instance) {
9918
- if (Function.prototype[Symbol.hasInstance].call(this, instance)) {
9919
- return true;
9920
- }
9921
- if (this === APIError) {
9922
- return isAPIErrorLike(instance);
9923
- }
9924
- return isNamedLegacyErrorLike(instance, this.name);
9925
- }
9926
9909
  static generate(status, errorResponse, message, headers) {
9927
9910
  if (!status || !headers) {
9928
9911
  return new APIConnectionError({
@@ -10063,57 +10046,12 @@ function stringifyErrorBody(error) {
10063
10046
  function isPlainObject$2(value) {
10064
10047
  return value !== null && typeof value === "object" && !Array.isArray(value);
10065
10048
  }
10066
- function isLegacyErrorLike(value) {
10067
- if (!(value instanceof Error) || !isPlainObject$2(value)) {
10068
- return false;
10069
- }
10070
- return ("status" in value ||
10071
- "statusCode" in value ||
10072
- "error" in value ||
10073
- "headers" in value);
10074
- }
10075
- function isAPIErrorLike(value) {
10076
- return isLegacyErrorLike(value) && "error" in value;
10077
- }
10078
10049
  function isCompatAPIErrorInstance(value) {
10050
+ // Avoid instanceof here so this guard never depends on Symbol.hasInstance.
10079
10051
  return typeof value === "object" && value !== null
10080
10052
  ? APIError.prototype.isPrototypeOf(value)
10081
10053
  : false;
10082
10054
  }
10083
- const knownLegacyErrorNames = [
10084
- "GeminiNextGenAPIClientError",
10085
- "APIError",
10086
- "APIUserAbortError",
10087
- "APIConnectionError",
10088
- "APIConnectionTimeoutError",
10089
- "BadRequestError",
10090
- "AuthenticationError",
10091
- "PermissionDeniedError",
10092
- "NotFoundError",
10093
- "ConflictError",
10094
- "UnprocessableEntityError",
10095
- "RateLimitError",
10096
- "InternalServerError",
10097
- ];
10098
- const legacySubclassNamesByBaseName = {
10099
- GeminiNextGenAPIClientError: knownLegacyErrorNames,
10100
- APIConnectionError: ["APIConnectionTimeoutError"],
10101
- };
10102
- function isKnownLegacyErrorLike(value) {
10103
- if (!isLegacyErrorLike(value)) {
10104
- return false;
10105
- }
10106
- return knownLegacyErrorNames.includes(value.name);
10107
- }
10108
- function isNamedLegacyErrorLike(value, name) {
10109
- var _a, _b;
10110
- if (!isLegacyErrorLike(value)) {
10111
- return false;
10112
- }
10113
- const valueName = value.name;
10114
- return (valueName === name ||
10115
- ((_b = (_a = legacySubclassNamesByBaseName[name]) === null || _a === void 0 ? void 0 : _a.includes(valueName)) !== null && _b !== void 0 ? _b : false));
10116
- }
10117
10055
  function defineReadonly(target, key, value) {
10118
10056
  Object.defineProperty(target, key, {
10119
10057
  configurable: true,
@@ -10323,7 +10261,7 @@ function serverURLFromOptions(options) {
10323
10261
  return new URL(u);
10324
10262
  }
10325
10263
  const SDK_METADATA = {
10326
- userAgent: "speakeasy-sdk/typescript 2.4.1-preview.4 2.904.2 v1beta @google/genai",
10264
+ userAgent: "speakeasy-sdk/typescript 2.4.1-preview.4 2.911.0 v1beta @google/genai",
10327
10265
  };
10328
10266
 
10329
10267
  /**
@@ -10872,14 +10810,19 @@ async function retry(fetchFn, options) {
10872
10810
  statusCodes: options.statusCodes,
10873
10811
  retryConnectionErrors: !!options.config.retryConnectionErrors,
10874
10812
  }), (_a = options.config.backoff) !== null && _a !== void 0 ? _a : defaultBackoff);
10813
+ case "attempt-count-backoff":
10814
+ return retryAttemptCountBackoff(wrapFetcher(fetchFn, {
10815
+ statusCodes: options.statusCodes,
10816
+ retryConnectionErrors: !!options.config.retryConnectionErrors,
10817
+ }), Object.assign(Object.assign({}, defaultBackoff), options.config.backoff), options.config);
10875
10818
  default:
10876
- return await fetchFn();
10819
+ return await fetchFn(0);
10877
10820
  }
10878
10821
  }
10879
10822
  function wrapFetcher(fn, options) {
10880
- return async () => {
10823
+ return async (attempt) => {
10881
10824
  try {
10882
- const res = await fn();
10825
+ const res = await fn(attempt);
10883
10826
  if (isRetryableResponse(res, options.statusCodes)) {
10884
10827
  throw new TemporaryError("Response failed with retryable status code", res);
10885
10828
  }
@@ -10921,7 +10864,7 @@ async function retryBackoff(fn, strategy) {
10921
10864
  let x = 0;
10922
10865
  while (true) {
10923
10866
  try {
10924
- const res = await fn();
10867
+ const res = await fn(x);
10925
10868
  return res;
10926
10869
  }
10927
10870
  catch (err) {
@@ -10949,7 +10892,46 @@ async function retryBackoff(fn, strategy) {
10949
10892
  }
10950
10893
  }
10951
10894
  }
10895
+ async function retryAttemptCountBackoff(fn, strategy, config) {
10896
+ let attempt = 0;
10897
+ while (true) {
10898
+ try {
10899
+ return await fn(attempt);
10900
+ }
10901
+ catch (err) {
10902
+ if (err instanceof PermanentError) {
10903
+ throw err.cause;
10904
+ }
10905
+ if (attempt >= config.maxRetries) {
10906
+ if (err instanceof TemporaryError) {
10907
+ return err.response;
10908
+ }
10909
+ throw err;
10910
+ }
10911
+ let retryInterval = 0;
10912
+ if (err instanceof TemporaryError) {
10913
+ retryInterval = retryIntervalFromResponse(err.response);
10914
+ }
10915
+ if (retryInterval <= 0) {
10916
+ retryInterval =
10917
+ strategy.initialInterval *
10918
+ Math.pow(strategy.exponent, attempt) *
10919
+ (1 - Math.random() * 0.25);
10920
+ }
10921
+ const d = Math.min(retryInterval, strategy.maxInterval);
10922
+ await delay(d);
10923
+ attempt++;
10924
+ }
10925
+ }
10926
+ }
10952
10927
  function retryIntervalFromResponse(res) {
10928
+ const retryAfterMsVal = res.headers.get("retry-after-ms");
10929
+ if (retryAfterMsVal) {
10930
+ const parsedMs = Number(retryAfterMsVal);
10931
+ if (Number.isFinite(parsedMs) && parsedMs >= 0) {
10932
+ return parsedMs;
10933
+ }
10934
+ }
10953
10935
  const retryVal = res.headers.get("retry-after") || "";
10954
10936
  if (!retryVal) {
10955
10937
  return 0;
@@ -11404,13 +11386,12 @@ class Stream extends ReadableStream {
11404
11386
  cancel: reason => upstream.cancel(reason),
11405
11387
  });
11406
11388
  }
11407
- // Polyfill for older browsers
11408
- [Symbol.asyncIterator]() {
11389
+ [Symbol.asyncIterator](options) {
11409
11390
  const fn = ReadableStream.prototype[Symbol.asyncIterator];
11410
11391
  if (typeof fn === "function")
11411
- return fn.call(this);
11392
+ return fn.call(this, options);
11412
11393
  const reader = this.getReader();
11413
- return {
11394
+ const iterator = {
11414
11395
  next: async () => {
11415
11396
  const r = await reader.read();
11416
11397
  if (r.done) {
@@ -11433,6 +11414,17 @@ class Stream extends ReadableStream {
11433
11414
  return this;
11434
11415
  },
11435
11416
  };
11417
+ const asyncDispose = Symbol.asyncDispose;
11418
+ if (asyncDispose) {
11419
+ iterator[asyncDispose] = async () => {
11420
+ var _a;
11421
+ await ((_a = iterator.return) === null || _a === void 0 ? void 0 : _a.call(iterator));
11422
+ };
11423
+ }
11424
+ return iterator;
11425
+ }
11426
+ values(options) {
11427
+ return this[Symbol.asyncIterator](options);
11436
11428
  }
11437
11429
  }
11438
11430
  const CR = 13;
@@ -11573,7 +11565,16 @@ function match(...matchers) {
11573
11565
  switch (encoding) {
11574
11566
  case "json":
11575
11567
  body = await response.text();
11576
- raw = JSON.parse(body);
11568
+ try {
11569
+ raw = JSON.parse(body);
11570
+ }
11571
+ catch (err) {
11572
+ // Passthrough for malformed error bodies; success bodies must be valid.
11573
+ if (!("err" in matcher)) {
11574
+ throw err;
11575
+ }
11576
+ raw = body;
11577
+ }
11577
11578
  break;
11578
11579
  case "jsonl":
11579
11580
  raw = response.body;
@@ -11931,7 +11932,7 @@ async function $do$e(client, body, api_version, options) {
11931
11932
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
11932
11933
  || client._options.retry_config
11933
11934
  || {
11934
- strategy: "backoff",
11935
+ strategy: "attempt-count-backoff",
11935
11936
  backoff: {
11936
11937
  initialInterval: 500,
11937
11938
  maxInterval: 8000,
@@ -11939,6 +11940,7 @@ async function $do$e(client, body, api_version, options) {
11939
11940
  maxElapsedTime: 30000,
11940
11941
  },
11941
11942
  retryConnectionErrors: true,
11943
+ maxRetries: 4,
11942
11944
  }
11943
11945
  || { strategy: "none" },
11944
11946
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -12018,7 +12020,7 @@ async function $do$d(client, id, api_version, options) {
12018
12020
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
12019
12021
  || client._options.retry_config
12020
12022
  || {
12021
- strategy: "backoff",
12023
+ strategy: "attempt-count-backoff",
12022
12024
  backoff: {
12023
12025
  initialInterval: 500,
12024
12026
  maxInterval: 8000,
@@ -12026,6 +12028,7 @@ async function $do$d(client, id, api_version, options) {
12026
12028
  maxElapsedTime: 30000,
12027
12029
  },
12028
12030
  retryConnectionErrors: true,
12031
+ maxRetries: 4,
12029
12032
  }
12030
12033
  || { strategy: "none" },
12031
12034
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -12105,7 +12108,7 @@ async function $do$c(client, id, api_version, options) {
12105
12108
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
12106
12109
  || client._options.retry_config
12107
12110
  || {
12108
- strategy: "backoff",
12111
+ strategy: "attempt-count-backoff",
12109
12112
  backoff: {
12110
12113
  initialInterval: 500,
12111
12114
  maxInterval: 8000,
@@ -12113,6 +12116,7 @@ async function $do$c(client, id, api_version, options) {
12113
12116
  maxElapsedTime: 30000,
12114
12117
  },
12115
12118
  retryConnectionErrors: true,
12119
+ maxRetries: 4,
12116
12120
  }
12117
12121
  || { strategy: "none" },
12118
12122
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -12195,7 +12199,7 @@ async function $do$b(client, api_version, page_size, page_token, parent, options
12195
12199
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
12196
12200
  || client._options.retry_config
12197
12201
  || {
12198
- strategy: "backoff",
12202
+ strategy: "attempt-count-backoff",
12199
12203
  backoff: {
12200
12204
  initialInterval: 500,
12201
12205
  maxInterval: 8000,
@@ -12203,6 +12207,7 @@ async function $do$b(client, api_version, page_size, page_token, parent, options
12203
12207
  maxElapsedTime: 30000,
12204
12208
  },
12205
12209
  retryConnectionErrors: true,
12210
+ maxRetries: 4,
12206
12211
  }
12207
12212
  || { strategy: "none" },
12208
12213
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -12465,7 +12470,7 @@ async function $do$a(client, id, api_version, options) {
12465
12470
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
12466
12471
  || client._options.retry_config
12467
12472
  || {
12468
- strategy: "backoff",
12473
+ strategy: "attempt-count-backoff",
12469
12474
  backoff: {
12470
12475
  initialInterval: 500,
12471
12476
  maxInterval: 8000,
@@ -12473,6 +12478,7 @@ async function $do$a(client, id, api_version, options) {
12473
12478
  maxElapsedTime: 30000,
12474
12479
  },
12475
12480
  retryConnectionErrors: true,
12481
+ maxRetries: 4,
12476
12482
  }
12477
12483
  || { strategy: "none" },
12478
12484
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -12549,7 +12555,7 @@ async function $do$9(client, body, api_version, options) {
12549
12555
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
12550
12556
  || client._options.retry_config
12551
12557
  || {
12552
- strategy: "backoff",
12558
+ strategy: "attempt-count-backoff",
12553
12559
  backoff: {
12554
12560
  initialInterval: 500,
12555
12561
  maxInterval: 8000,
@@ -12557,6 +12563,7 @@ async function $do$9(client, body, api_version, options) {
12557
12563
  maxElapsedTime: 30000,
12558
12564
  },
12559
12565
  retryConnectionErrors: true,
12566
+ maxRetries: 4,
12560
12567
  }
12561
12568
  || { strategy: "none" },
12562
12569
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -12645,7 +12652,7 @@ async function $do$8(client, id, api_version, options) {
12645
12652
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
12646
12653
  || client._options.retry_config
12647
12654
  || {
12648
- strategy: "backoff",
12655
+ strategy: "attempt-count-backoff",
12649
12656
  backoff: {
12650
12657
  initialInterval: 500,
12651
12658
  maxInterval: 8000,
@@ -12653,6 +12660,7 @@ async function $do$8(client, id, api_version, options) {
12653
12660
  maxElapsedTime: 30000,
12654
12661
  },
12655
12662
  retryConnectionErrors: true,
12663
+ maxRetries: 4,
12656
12664
  }
12657
12665
  || { strategy: "none" },
12658
12666
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -12740,7 +12748,7 @@ async function $do$7(client, id, stream, last_event_id, include_input, api_versi
12740
12748
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
12741
12749
  || client._options.retry_config
12742
12750
  || {
12743
- strategy: "backoff",
12751
+ strategy: "attempt-count-backoff",
12744
12752
  backoff: {
12745
12753
  initialInterval: 500,
12746
12754
  maxInterval: 8000,
@@ -12748,6 +12756,7 @@ async function $do$7(client, id, stream, last_event_id, include_input, api_versi
12748
12756
  maxElapsedTime: 30000,
12749
12757
  },
12750
12758
  retryConnectionErrors: true,
12759
+ maxRetries: 4,
12751
12760
  }
12752
12761
  || { strategy: "none" },
12753
12762
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -12866,7 +12875,7 @@ async function $do$6(client, body, api_version, options) {
12866
12875
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
12867
12876
  || client._options.retry_config
12868
12877
  || {
12869
- strategy: "backoff",
12878
+ strategy: "attempt-count-backoff",
12870
12879
  backoff: {
12871
12880
  initialInterval: 500,
12872
12881
  maxInterval: 8000,
@@ -12874,6 +12883,7 @@ async function $do$6(client, body, api_version, options) {
12874
12883
  maxElapsedTime: 30000,
12875
12884
  },
12876
12885
  retryConnectionErrors: true,
12886
+ maxRetries: 4,
12877
12887
  }
12878
12888
  || { strategy: "none" },
12879
12889
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -12953,7 +12963,7 @@ async function $do$5(client, id, api_version, options) {
12953
12963
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
12954
12964
  || client._options.retry_config
12955
12965
  || {
12956
- strategy: "backoff",
12966
+ strategy: "attempt-count-backoff",
12957
12967
  backoff: {
12958
12968
  initialInterval: 500,
12959
12969
  maxInterval: 8000,
@@ -12961,6 +12971,7 @@ async function $do$5(client, id, api_version, options) {
12961
12971
  maxElapsedTime: 30000,
12962
12972
  },
12963
12973
  retryConnectionErrors: true,
12974
+ maxRetries: 4,
12964
12975
  }
12965
12976
  || { strategy: "none" },
12966
12977
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -13040,7 +13051,7 @@ async function $do$4(client, id, api_version, options) {
13040
13051
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
13041
13052
  || client._options.retry_config
13042
13053
  || {
13043
- strategy: "backoff",
13054
+ strategy: "attempt-count-backoff",
13044
13055
  backoff: {
13045
13056
  initialInterval: 500,
13046
13057
  maxInterval: 8000,
@@ -13048,6 +13059,7 @@ async function $do$4(client, id, api_version, options) {
13048
13059
  maxElapsedTime: 30000,
13049
13060
  },
13050
13061
  retryConnectionErrors: true,
13062
+ maxRetries: 4,
13051
13063
  }
13052
13064
  || { strategy: "none" },
13053
13065
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -13128,7 +13140,7 @@ async function $do$3(client, api_version, page_size, page_token, options) {
13128
13140
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
13129
13141
  || client._options.retry_config
13130
13142
  || {
13131
- strategy: "backoff",
13143
+ strategy: "attempt-count-backoff",
13132
13144
  backoff: {
13133
13145
  initialInterval: 500,
13134
13146
  maxInterval: 8000,
@@ -13136,6 +13148,7 @@ async function $do$3(client, api_version, page_size, page_token, options) {
13136
13148
  maxElapsedTime: 30000,
13137
13149
  },
13138
13150
  retryConnectionErrors: true,
13151
+ maxRetries: 4,
13139
13152
  }
13140
13153
  || { strategy: "none" },
13141
13154
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -13218,7 +13231,7 @@ async function $do$2(client, id, api_version, body, options) {
13218
13231
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
13219
13232
  || client._options.retry_config
13220
13233
  || {
13221
- strategy: "backoff",
13234
+ strategy: "attempt-count-backoff",
13222
13235
  backoff: {
13223
13236
  initialInterval: 500,
13224
13237
  maxInterval: 8000,
@@ -13226,6 +13239,7 @@ async function $do$2(client, id, api_version, body, options) {
13226
13239
  maxElapsedTime: 30000,
13227
13240
  },
13228
13241
  retryConnectionErrors: true,
13242
+ maxRetries: 4,
13229
13243
  }
13230
13244
  || { strategy: "none" },
13231
13245
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -13307,7 +13321,7 @@ async function $do$1(client, id, api_version, body, options) {
13307
13321
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
13308
13322
  || client._options.retry_config
13309
13323
  || {
13310
- strategy: "backoff",
13324
+ strategy: "attempt-count-backoff",
13311
13325
  backoff: {
13312
13326
  initialInterval: 500,
13313
13327
  maxInterval: 8000,
@@ -13315,6 +13329,7 @@ async function $do$1(client, id, api_version, body, options) {
13315
13329
  maxElapsedTime: 30000,
13316
13330
  },
13317
13331
  retryConnectionErrors: true,
13332
+ maxRetries: 4,
13318
13333
  }
13319
13334
  || { strategy: "none" },
13320
13335
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -13400,7 +13415,7 @@ async function $do(client, id, api_version, update_mask, body, options) {
13400
13415
  retry_config: (options === null || options === void 0 ? void 0 : options.retries)
13401
13416
  || client._options.retry_config
13402
13417
  || {
13403
- strategy: "backoff",
13418
+ strategy: "attempt-count-backoff",
13404
13419
  backoff: {
13405
13420
  initialInterval: 500,
13406
13421
  maxInterval: 8000,
@@ -13408,6 +13423,7 @@ async function $do(client, id, api_version, update_mask, body, options) {
13408
13423
  maxElapsedTime: 30000,
13409
13424
  },
13410
13425
  retryConnectionErrors: true,
13426
+ maxRetries: 4,
13411
13427
  }
13412
13428
  || { strategy: "none" },
13413
13429
  retry_codes: (options === null || options === void 0 ? void 0 : options.retry_codes) || ["408", "409", "429", "5XX"],
@@ -13674,7 +13690,7 @@ function toGoogleGenAIRequestOptions(options, streaming = false) {
13674
13690
  if (!options && !streaming) {
13675
13691
  return undefined;
13676
13692
  }
13677
- const _e = options !== null && options !== void 0 ? options : {}, { timeout, maxRetries: _maxRetries, defaultBaseURL, query, body, fetchOptions } = _e, rest = __rest(_e, ["timeout", "maxRetries", "defaultBaseURL", "query", "body", "fetchOptions"]);
13693
+ const _e = options !== null && options !== void 0 ? options : {}, { timeout, maxRetries, defaultBaseURL, query, body, fetchOptions } = _e, rest = __rest(_e, ["timeout", "maxRetries", "defaultBaseURL", "query", "body", "fetchOptions"]);
13678
13694
  const nextOptions = Object.assign({}, rest);
13679
13695
  if (isPlainObject(query)) {
13680
13696
  nextOptions.extra_query = query;
@@ -13700,6 +13716,13 @@ function toGoogleGenAIRequestOptions(options, streaming = false) {
13700
13716
  if (timeout_ms !== undefined) {
13701
13717
  nextOptions.timeout_ms = timeout_ms;
13702
13718
  }
13719
+ if (maxRetries !== undefined) {
13720
+ nextOptions.retries = {
13721
+ strategy: "attempt-count-backoff",
13722
+ retryConnectionErrors: true,
13723
+ maxRetries,
13724
+ };
13725
+ }
13703
13726
  if (streaming) {
13704
13727
  const headers = new Headers((_d = nextOptions.headers) !== null && _d !== void 0 ? _d : fetch_options === null || fetch_options === void 0 ? void 0 : fetch_options.headers);
13705
13728
  headers.set("Accept", "text/event-stream");
@@ -13897,6 +13920,22 @@ function audioTranscriptionConfigToMldev$1(fromObject) {
13897
13920
  if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
13898
13921
  throw new Error('languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
13899
13922
  }
13923
+ const fromLanguageAuto = getValueByPath(fromObject, ['languageAuto']);
13924
+ if (fromLanguageAuto != null) {
13925
+ setValueByPath(toObject, ['languageAuto'], fromLanguageAuto);
13926
+ }
13927
+ const fromLanguageHints = getValueByPath(fromObject, [
13928
+ 'languageHints',
13929
+ ]);
13930
+ if (fromLanguageHints != null) {
13931
+ setValueByPath(toObject, ['languageHints'], fromLanguageHints);
13932
+ }
13933
+ const fromAdaptationPhrases = getValueByPath(fromObject, [
13934
+ 'adaptationPhrases',
13935
+ ]);
13936
+ if (fromAdaptationPhrases != null) {
13937
+ setValueByPath(toObject, ['adaptationPhrases'], fromAdaptationPhrases);
13938
+ }
13900
13939
  return toObject;
13901
13940
  }
13902
13941
  function authConfigToMldev$2(fromObject) {
@@ -15077,6 +15116,10 @@ function voiceActivityFromVertex(fromObject) {
15077
15116
  if (fromVoiceActivityType != null) {
15078
15117
  setValueByPath(toObject, ['voiceActivityType'], fromVoiceActivityType);
15079
15118
  }
15119
+ const fromAudioOffset = getValueByPath(fromObject, ['audioOffset']);
15120
+ if (fromAudioOffset != null) {
15121
+ setValueByPath(toObject, ['audioOffset'], fromAudioOffset);
15122
+ }
15080
15123
  return toObject;
15081
15124
  }
15082
15125
 
@@ -21368,6 +21411,22 @@ function audioTranscriptionConfigToMldev(fromObject) {
21368
21411
  if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
21369
21412
  throw new Error('languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.');
21370
21413
  }
21414
+ const fromLanguageAuto = getValueByPath(fromObject, ['languageAuto']);
21415
+ if (fromLanguageAuto != null) {
21416
+ setValueByPath(toObject, ['languageAuto'], fromLanguageAuto);
21417
+ }
21418
+ const fromLanguageHints = getValueByPath(fromObject, [
21419
+ 'languageHints',
21420
+ ]);
21421
+ if (fromLanguageHints != null) {
21422
+ setValueByPath(toObject, ['languageHints'], fromLanguageHints);
21423
+ }
21424
+ const fromAdaptationPhrases = getValueByPath(fromObject, [
21425
+ 'adaptationPhrases',
21426
+ ]);
21427
+ if (fromAdaptationPhrases != null) {
21428
+ setValueByPath(toObject, ['adaptationPhrases'], fromAdaptationPhrases);
21429
+ }
21371
21430
  return toObject;
21372
21431
  }
21373
21432
  function authConfigToMldev(fromObject) {
@@ -24008,7 +24067,6 @@ class GoogleGenAI {
24008
24067
  if (this._interactions !== undefined) {
24009
24068
  return this._interactions;
24010
24069
  }
24011
- console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
24012
24070
  this._interactions = new GeminiNextGenInteractions(this.apiClient);
24013
24071
  return this._interactions;
24014
24072
  }