@google/genai 1.44.0 → 1.46.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.
@@ -616,6 +616,18 @@ function videoFromVertex$1(fromObject) {
616
616
  * Copyright 2025 Google LLC
617
617
  * SPDX-License-Identifier: Apache-2.0
618
618
  */
619
+ /** Programming language of the `code`. */
620
+ exports.Language = void 0;
621
+ (function (Language) {
622
+ /**
623
+ * Unspecified language. This value should not be used.
624
+ */
625
+ Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
626
+ /**
627
+ * Python >= 3.10, with numpy and simpy available.
628
+ */
629
+ Language["PYTHON"] = "PYTHON";
630
+ })(exports.Language || (exports.Language = {}));
619
631
  /** Outcome of the code execution. */
620
632
  exports.Outcome = void 0;
621
633
  (function (Outcome) {
@@ -636,18 +648,6 @@ exports.Outcome = void 0;
636
648
  */
637
649
  Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
638
650
  })(exports.Outcome || (exports.Outcome = {}));
639
- /** Programming language of the `code`. */
640
- exports.Language = void 0;
641
- (function (Language) {
642
- /**
643
- * Unspecified language. This value should not be used.
644
- */
645
- Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
646
- /**
647
- * Python >= 3.10, with numpy and simpy available.
648
- */
649
- Language["PYTHON"] = "PYTHON";
650
- })(exports.Language || (exports.Language = {}));
651
651
  /** Specifies how the response should be scheduled in the conversation. */
652
652
  exports.FunctionResponseScheduling = void 0;
653
653
  (function (FunctionResponseScheduling) {
@@ -1476,6 +1476,34 @@ exports.PartMediaResolutionLevel = void 0;
1476
1476
  */
1477
1477
  PartMediaResolutionLevel["MEDIA_RESOLUTION_ULTRA_HIGH"] = "MEDIA_RESOLUTION_ULTRA_HIGH";
1478
1478
  })(exports.PartMediaResolutionLevel || (exports.PartMediaResolutionLevel = {}));
1479
+ /** The type of tool in the function call. */
1480
+ exports.ToolType = void 0;
1481
+ (function (ToolType) {
1482
+ /**
1483
+ * Unspecified tool type.
1484
+ */
1485
+ ToolType["TOOL_TYPE_UNSPECIFIED"] = "TOOL_TYPE_UNSPECIFIED";
1486
+ /**
1487
+ * Google search tool, maps to Tool.google_search.search_types.web_search.
1488
+ */
1489
+ ToolType["GOOGLE_SEARCH_WEB"] = "GOOGLE_SEARCH_WEB";
1490
+ /**
1491
+ * Image search tool, maps to Tool.google_search.search_types.image_search.
1492
+ */
1493
+ ToolType["GOOGLE_SEARCH_IMAGE"] = "GOOGLE_SEARCH_IMAGE";
1494
+ /**
1495
+ * URL context tool, maps to Tool.url_context.
1496
+ */
1497
+ ToolType["URL_CONTEXT"] = "URL_CONTEXT";
1498
+ /**
1499
+ * Google maps tool, maps to Tool.google_maps.
1500
+ */
1501
+ ToolType["GOOGLE_MAPS"] = "GOOGLE_MAPS";
1502
+ /**
1503
+ * File search tool, maps to Tool.file_search.
1504
+ */
1505
+ ToolType["FILE_SEARCH"] = "FILE_SEARCH";
1506
+ })(exports.ToolType || (exports.ToolType = {}));
1479
1507
  /** Resource scope. */
1480
1508
  exports.ResourceScope = void 0;
1481
1509
  (function (ResourceScope) {
@@ -1971,6 +1999,14 @@ exports.LiveMusicPlaybackControl = void 0;
1971
1999
  */
1972
2000
  LiveMusicPlaybackControl["RESET_CONTEXT"] = "RESET_CONTEXT";
1973
2001
  })(exports.LiveMusicPlaybackControl || (exports.LiveMusicPlaybackControl = {}));
2002
+ /** The output from a server-side `ToolCall` execution.
2003
+
2004
+ This message contains the results of a tool invocation that was initiated by a
2005
+ `ToolCall` from the model. The client should pass this `ToolResponse` back to
2006
+ the API in a subsequent turn within a `Content` message, along with the
2007
+ corresponding `ToolCall`. */
2008
+ class ToolResponse {
2009
+ }
1974
2010
  /** Raw media bytes for function response.
1975
2011
 
1976
2012
  Text should not be sent as raw bytes, use the FunctionResponse.response
@@ -4699,6 +4735,14 @@ function partToMldev$4(fromObject) {
4699
4735
  if (fromVideoMetadata != null) {
4700
4736
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
4701
4737
  }
4738
+ const fromToolCall = getValueByPath(fromObject, ['toolCall']);
4739
+ if (fromToolCall != null) {
4740
+ setValueByPath(toObject, ['toolCall'], fromToolCall);
4741
+ }
4742
+ const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
4743
+ if (fromToolResponse != null) {
4744
+ setValueByPath(toObject, ['toolResponse'], fromToolResponse);
4745
+ }
4702
4746
  return toObject;
4703
4747
  }
4704
4748
  function safetySettingToMldev$1(fromObject) {
@@ -4730,6 +4774,10 @@ function toolConfigToMldev$2(fromObject) {
4730
4774
  if (fromFunctionCallingConfig != null) {
4731
4775
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$2(fromFunctionCallingConfig));
4732
4776
  }
4777
+ const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
4778
+ if (fromIncludeServerSideToolInvocations != null) {
4779
+ setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
4780
+ }
4733
4781
  return toObject;
4734
4782
  }
4735
4783
  function toolToMldev$4(fromObject) {
@@ -5552,6 +5600,24 @@ function contentToMldev$3(fromObject) {
5552
5600
  }
5553
5601
  return toObject;
5554
5602
  }
5603
+ function contentToVertex$2(fromObject) {
5604
+ const toObject = {};
5605
+ const fromParts = getValueByPath(fromObject, ['parts']);
5606
+ if (fromParts != null) {
5607
+ let transformedList = fromParts;
5608
+ if (Array.isArray(transformedList)) {
5609
+ transformedList = transformedList.map((item) => {
5610
+ return partToVertex$2(item);
5611
+ });
5612
+ }
5613
+ setValueByPath(toObject, ['parts'], transformedList);
5614
+ }
5615
+ const fromRole = getValueByPath(fromObject, ['role']);
5616
+ if (fromRole != null) {
5617
+ setValueByPath(toObject, ['role'], fromRole);
5618
+ }
5619
+ return toObject;
5620
+ }
5555
5621
  function createCachedContentConfigToMldev(fromObject, parentObject) {
5556
5622
  const toObject = {};
5557
5623
  const fromTtl = getValueByPath(fromObject, ['ttl']);
@@ -5620,7 +5686,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
5620
5686
  let transformedList = tContents(fromContents);
5621
5687
  if (Array.isArray(transformedList)) {
5622
5688
  transformedList = transformedList.map((item) => {
5623
- return item;
5689
+ return contentToVertex$2(item);
5624
5690
  });
5625
5691
  }
5626
5692
  setValueByPath(parentObject, ['contents'], transformedList);
@@ -5629,7 +5695,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
5629
5695
  'systemInstruction',
5630
5696
  ]);
5631
5697
  if (parentObject !== undefined && fromSystemInstruction != null) {
5632
- setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
5698
+ setValueByPath(parentObject, ['systemInstruction'], contentToVertex$2(tContent(fromSystemInstruction)));
5633
5699
  }
5634
5700
  const fromTools = getValueByPath(fromObject, ['tools']);
5635
5701
  if (parentObject !== undefined && fromTools != null) {
@@ -5643,7 +5709,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
5643
5709
  }
5644
5710
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
5645
5711
  if (parentObject !== undefined && fromToolConfig != null) {
5646
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
5712
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex$1(fromToolConfig));
5647
5713
  }
5648
5714
  const fromKmsKeyName = getValueByPath(fromObject, ['kmsKeyName']);
5649
5715
  if (parentObject !== undefined && fromKmsKeyName != null) {
@@ -6003,6 +6069,80 @@ function partToMldev$3(fromObject) {
6003
6069
  if (fromVideoMetadata != null) {
6004
6070
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
6005
6071
  }
6072
+ const fromToolCall = getValueByPath(fromObject, ['toolCall']);
6073
+ if (fromToolCall != null) {
6074
+ setValueByPath(toObject, ['toolCall'], fromToolCall);
6075
+ }
6076
+ const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
6077
+ if (fromToolResponse != null) {
6078
+ setValueByPath(toObject, ['toolResponse'], fromToolResponse);
6079
+ }
6080
+ return toObject;
6081
+ }
6082
+ function partToVertex$2(fromObject) {
6083
+ const toObject = {};
6084
+ const fromMediaResolution = getValueByPath(fromObject, [
6085
+ 'mediaResolution',
6086
+ ]);
6087
+ if (fromMediaResolution != null) {
6088
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
6089
+ }
6090
+ const fromCodeExecutionResult = getValueByPath(fromObject, [
6091
+ 'codeExecutionResult',
6092
+ ]);
6093
+ if (fromCodeExecutionResult != null) {
6094
+ setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
6095
+ }
6096
+ const fromExecutableCode = getValueByPath(fromObject, [
6097
+ 'executableCode',
6098
+ ]);
6099
+ if (fromExecutableCode != null) {
6100
+ setValueByPath(toObject, ['executableCode'], fromExecutableCode);
6101
+ }
6102
+ const fromFileData = getValueByPath(fromObject, ['fileData']);
6103
+ if (fromFileData != null) {
6104
+ setValueByPath(toObject, ['fileData'], fromFileData);
6105
+ }
6106
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
6107
+ if (fromFunctionCall != null) {
6108
+ setValueByPath(toObject, ['functionCall'], fromFunctionCall);
6109
+ }
6110
+ const fromFunctionResponse = getValueByPath(fromObject, [
6111
+ 'functionResponse',
6112
+ ]);
6113
+ if (fromFunctionResponse != null) {
6114
+ setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
6115
+ }
6116
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
6117
+ if (fromInlineData != null) {
6118
+ setValueByPath(toObject, ['inlineData'], fromInlineData);
6119
+ }
6120
+ const fromText = getValueByPath(fromObject, ['text']);
6121
+ if (fromText != null) {
6122
+ setValueByPath(toObject, ['text'], fromText);
6123
+ }
6124
+ const fromThought = getValueByPath(fromObject, ['thought']);
6125
+ if (fromThought != null) {
6126
+ setValueByPath(toObject, ['thought'], fromThought);
6127
+ }
6128
+ const fromThoughtSignature = getValueByPath(fromObject, [
6129
+ 'thoughtSignature',
6130
+ ]);
6131
+ if (fromThoughtSignature != null) {
6132
+ setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
6133
+ }
6134
+ const fromVideoMetadata = getValueByPath(fromObject, [
6135
+ 'videoMetadata',
6136
+ ]);
6137
+ if (fromVideoMetadata != null) {
6138
+ setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
6139
+ }
6140
+ if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
6141
+ throw new Error('toolCall parameter is not supported in Vertex AI.');
6142
+ }
6143
+ if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
6144
+ throw new Error('toolResponse parameter is not supported in Vertex AI.');
6145
+ }
6006
6146
  return toObject;
6007
6147
  }
6008
6148
  function toolConfigToMldev$1(fromObject) {
@@ -6019,6 +6159,30 @@ function toolConfigToMldev$1(fromObject) {
6019
6159
  if (fromFunctionCallingConfig != null) {
6020
6160
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(fromFunctionCallingConfig));
6021
6161
  }
6162
+ const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
6163
+ if (fromIncludeServerSideToolInvocations != null) {
6164
+ setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
6165
+ }
6166
+ return toObject;
6167
+ }
6168
+ function toolConfigToVertex$1(fromObject) {
6169
+ const toObject = {};
6170
+ const fromRetrievalConfig = getValueByPath(fromObject, [
6171
+ 'retrievalConfig',
6172
+ ]);
6173
+ if (fromRetrievalConfig != null) {
6174
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
6175
+ }
6176
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
6177
+ 'functionCallingConfig',
6178
+ ]);
6179
+ if (fromFunctionCallingConfig != null) {
6180
+ setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
6181
+ }
6182
+ if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
6183
+ undefined) {
6184
+ throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
6185
+ }
6022
6186
  return toObject;
6023
6187
  }
6024
6188
  function toolToMldev$3(fromObject) {
@@ -7439,6 +7603,13 @@ class Files extends BaseModule {
7439
7603
  * Copyright 2025 Google LLC
7440
7604
  * SPDX-License-Identifier: Apache-2.0
7441
7605
  */
7606
+ function audioTranscriptionConfigToMldev$1(fromObject) {
7607
+ const toObject = {};
7608
+ if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
7609
+ throw new Error('languageCodes parameter is not supported in Gemini API.');
7610
+ }
7611
+ return toObject;
7612
+ }
7442
7613
  function authConfigToMldev$2(fromObject) {
7443
7614
  const toObject = {};
7444
7615
  const fromApiKey = getValueByPath(fromObject, ['apiKey']);
@@ -7499,6 +7670,24 @@ function contentToMldev$2(fromObject) {
7499
7670
  }
7500
7671
  return toObject;
7501
7672
  }
7673
+ function contentToVertex$1(fromObject) {
7674
+ const toObject = {};
7675
+ const fromParts = getValueByPath(fromObject, ['parts']);
7676
+ if (fromParts != null) {
7677
+ let transformedList = fromParts;
7678
+ if (Array.isArray(transformedList)) {
7679
+ transformedList = transformedList.map((item) => {
7680
+ return partToVertex$1(item);
7681
+ });
7682
+ }
7683
+ setValueByPath(toObject, ['parts'], transformedList);
7684
+ }
7685
+ const fromRole = getValueByPath(fromObject, ['role']);
7686
+ if (fromRole != null) {
7687
+ setValueByPath(toObject, ['role'], fromRole);
7688
+ }
7689
+ return toObject;
7690
+ }
7502
7691
  function fileDataToMldev$2(fromObject) {
7503
7692
  const toObject = {};
7504
7693
  if (getValueByPath(fromObject, ['displayName']) !== undefined) {
@@ -7815,13 +8004,13 @@ function liveConnectConfigToMldev$1(fromObject, parentObject) {
7815
8004
  'inputAudioTranscription',
7816
8005
  ]);
7817
8006
  if (parentObject !== undefined && fromInputAudioTranscription != null) {
7818
- setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
8007
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromInputAudioTranscription));
7819
8008
  }
7820
8009
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
7821
8010
  'outputAudioTranscription',
7822
8011
  ]);
7823
8012
  if (parentObject !== undefined && fromOutputAudioTranscription != null) {
7824
- setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
8013
+ setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromOutputAudioTranscription));
7825
8014
  }
7826
8015
  const fromRealtimeInputConfig = getValueByPath(fromObject, [
7827
8016
  'realtimeInputConfig',
@@ -7906,7 +8095,7 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
7906
8095
  'systemInstruction',
7907
8096
  ]);
7908
8097
  if (parentObject !== undefined && fromSystemInstruction != null) {
7909
- setValueByPath(parentObject, ['setup', 'systemInstruction'], tContent(fromSystemInstruction));
8098
+ setValueByPath(parentObject, ['setup', 'systemInstruction'], contentToVertex$1(tContent(fromSystemInstruction)));
7910
8099
  }
7911
8100
  const fromTools = getValueByPath(fromObject, ['tools']);
7912
8101
  if (parentObject !== undefined && fromTools != null) {
@@ -8206,6 +8395,80 @@ function partToMldev$2(fromObject) {
8206
8395
  if (fromVideoMetadata != null) {
8207
8396
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
8208
8397
  }
8398
+ const fromToolCall = getValueByPath(fromObject, ['toolCall']);
8399
+ if (fromToolCall != null) {
8400
+ setValueByPath(toObject, ['toolCall'], fromToolCall);
8401
+ }
8402
+ const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
8403
+ if (fromToolResponse != null) {
8404
+ setValueByPath(toObject, ['toolResponse'], fromToolResponse);
8405
+ }
8406
+ return toObject;
8407
+ }
8408
+ function partToVertex$1(fromObject) {
8409
+ const toObject = {};
8410
+ const fromMediaResolution = getValueByPath(fromObject, [
8411
+ 'mediaResolution',
8412
+ ]);
8413
+ if (fromMediaResolution != null) {
8414
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
8415
+ }
8416
+ const fromCodeExecutionResult = getValueByPath(fromObject, [
8417
+ 'codeExecutionResult',
8418
+ ]);
8419
+ if (fromCodeExecutionResult != null) {
8420
+ setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
8421
+ }
8422
+ const fromExecutableCode = getValueByPath(fromObject, [
8423
+ 'executableCode',
8424
+ ]);
8425
+ if (fromExecutableCode != null) {
8426
+ setValueByPath(toObject, ['executableCode'], fromExecutableCode);
8427
+ }
8428
+ const fromFileData = getValueByPath(fromObject, ['fileData']);
8429
+ if (fromFileData != null) {
8430
+ setValueByPath(toObject, ['fileData'], fromFileData);
8431
+ }
8432
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8433
+ if (fromFunctionCall != null) {
8434
+ setValueByPath(toObject, ['functionCall'], fromFunctionCall);
8435
+ }
8436
+ const fromFunctionResponse = getValueByPath(fromObject, [
8437
+ 'functionResponse',
8438
+ ]);
8439
+ if (fromFunctionResponse != null) {
8440
+ setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
8441
+ }
8442
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
8443
+ if (fromInlineData != null) {
8444
+ setValueByPath(toObject, ['inlineData'], fromInlineData);
8445
+ }
8446
+ const fromText = getValueByPath(fromObject, ['text']);
8447
+ if (fromText != null) {
8448
+ setValueByPath(toObject, ['text'], fromText);
8449
+ }
8450
+ const fromThought = getValueByPath(fromObject, ['thought']);
8451
+ if (fromThought != null) {
8452
+ setValueByPath(toObject, ['thought'], fromThought);
8453
+ }
8454
+ const fromThoughtSignature = getValueByPath(fromObject, [
8455
+ 'thoughtSignature',
8456
+ ]);
8457
+ if (fromThoughtSignature != null) {
8458
+ setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
8459
+ }
8460
+ const fromVideoMetadata = getValueByPath(fromObject, [
8461
+ 'videoMetadata',
8462
+ ]);
8463
+ if (fromVideoMetadata != null) {
8464
+ setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
8465
+ }
8466
+ if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
8467
+ throw new Error('toolCall parameter is not supported in Vertex AI.');
8468
+ }
8469
+ if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
8470
+ throw new Error('toolResponse parameter is not supported in Vertex AI.');
8471
+ }
8209
8472
  return toObject;
8210
8473
  }
8211
8474
  function sessionResumptionConfigToMldev$1(fromObject) {
@@ -8574,7 +8837,7 @@ function citationMetadataFromMldev(fromObject, _rootObject) {
8574
8837
  }
8575
8838
  return toObject;
8576
8839
  }
8577
- function computeTokensParametersToVertex(apiClient, fromObject, _rootObject) {
8840
+ function computeTokensParametersToVertex(apiClient, fromObject, rootObject) {
8578
8841
  const toObject = {};
8579
8842
  const fromModel = getValueByPath(fromObject, ['model']);
8580
8843
  if (fromModel != null) {
@@ -8585,7 +8848,7 @@ function computeTokensParametersToVertex(apiClient, fromObject, _rootObject) {
8585
8848
  let transformedList = tContents(fromContents);
8586
8849
  if (Array.isArray(transformedList)) {
8587
8850
  transformedList = transformedList.map((item) => {
8588
- return item;
8851
+ return contentToVertex(item);
8589
8852
  });
8590
8853
  }
8591
8854
  setValueByPath(toObject, ['contents'], transformedList);
@@ -8654,6 +8917,24 @@ function contentToMldev$1(fromObject, rootObject) {
8654
8917
  }
8655
8918
  return toObject;
8656
8919
  }
8920
+ function contentToVertex(fromObject, rootObject) {
8921
+ const toObject = {};
8922
+ const fromParts = getValueByPath(fromObject, ['parts']);
8923
+ if (fromParts != null) {
8924
+ let transformedList = fromParts;
8925
+ if (Array.isArray(transformedList)) {
8926
+ transformedList = transformedList.map((item) => {
8927
+ return partToVertex(item);
8928
+ });
8929
+ }
8930
+ setValueByPath(toObject, ['parts'], transformedList);
8931
+ }
8932
+ const fromRole = getValueByPath(fromObject, ['role']);
8933
+ if (fromRole != null) {
8934
+ setValueByPath(toObject, ['role'], fromRole);
8935
+ }
8936
+ return toObject;
8937
+ }
8657
8938
  function controlReferenceConfigToVertex(fromObject, _rootObject) {
8658
8939
  const toObject = {};
8659
8940
  const fromControlType = getValueByPath(fromObject, ['controlType']);
@@ -8687,7 +8968,7 @@ function countTokensConfigToVertex(fromObject, parentObject, rootObject) {
8687
8968
  'systemInstruction',
8688
8969
  ]);
8689
8970
  if (parentObject !== undefined && fromSystemInstruction != null) {
8690
- setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
8971
+ setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
8691
8972
  }
8692
8973
  const fromTools = getValueByPath(fromObject, ['tools']);
8693
8974
  if (parentObject !== undefined && fromTools != null) {
@@ -8740,7 +9021,7 @@ function countTokensParametersToVertex(apiClient, fromObject, rootObject) {
8740
9021
  let transformedList = tContents(fromContents);
8741
9022
  if (Array.isArray(transformedList)) {
8742
9023
  transformedList = transformedList.map((item) => {
8743
- return item;
9024
+ return contentToVertex(item);
8744
9025
  });
8745
9026
  }
8746
9027
  setValueByPath(toObject, ['contents'], transformedList);
@@ -9144,7 +9425,7 @@ function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject
9144
9425
  if (discriminatorContent === 'EMBED_CONTENT') {
9145
9426
  const fromContent = getValueByPath(fromObject, ['content']);
9146
9427
  if (fromContent != null) {
9147
- setValueByPath(toObject, ['content'], tContent(fromContent));
9428
+ setValueByPath(toObject, ['content'], contentToVertex(tContent(fromContent)));
9148
9429
  }
9149
9430
  }
9150
9431
  const fromConfig = getValueByPath(fromObject, ['config']);
@@ -9495,7 +9776,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
9495
9776
  'systemInstruction',
9496
9777
  ]);
9497
9778
  if (parentObject !== undefined && fromSystemInstruction != null) {
9498
- setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
9779
+ setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
9499
9780
  }
9500
9781
  const fromTemperature = getValueByPath(fromObject, ['temperature']);
9501
9782
  if (fromTemperature != null) {
@@ -9607,7 +9888,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
9607
9888
  }
9608
9889
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
9609
9890
  if (parentObject !== undefined && fromToolConfig != null) {
9610
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
9891
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex(fromToolConfig));
9611
9892
  }
9612
9893
  const fromLabels = getValueByPath(fromObject, ['labels']);
9613
9894
  if (parentObject !== undefined && fromLabels != null) {
@@ -9696,7 +9977,7 @@ function generateContentParametersToVertex(apiClient, fromObject, rootObject) {
9696
9977
  let transformedList = tContents(fromContents);
9697
9978
  if (Array.isArray(transformedList)) {
9698
9979
  transformedList = transformedList.map((item) => {
9699
- return item;
9980
+ return contentToVertex(item);
9700
9981
  });
9701
9982
  }
9702
9983
  setValueByPath(toObject, ['contents'], transformedList);
@@ -11100,6 +11381,80 @@ function partToMldev$1(fromObject, rootObject) {
11100
11381
  if (fromVideoMetadata != null) {
11101
11382
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
11102
11383
  }
11384
+ const fromToolCall = getValueByPath(fromObject, ['toolCall']);
11385
+ if (fromToolCall != null) {
11386
+ setValueByPath(toObject, ['toolCall'], fromToolCall);
11387
+ }
11388
+ const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
11389
+ if (fromToolResponse != null) {
11390
+ setValueByPath(toObject, ['toolResponse'], fromToolResponse);
11391
+ }
11392
+ return toObject;
11393
+ }
11394
+ function partToVertex(fromObject, _rootObject) {
11395
+ const toObject = {};
11396
+ const fromMediaResolution = getValueByPath(fromObject, [
11397
+ 'mediaResolution',
11398
+ ]);
11399
+ if (fromMediaResolution != null) {
11400
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
11401
+ }
11402
+ const fromCodeExecutionResult = getValueByPath(fromObject, [
11403
+ 'codeExecutionResult',
11404
+ ]);
11405
+ if (fromCodeExecutionResult != null) {
11406
+ setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
11407
+ }
11408
+ const fromExecutableCode = getValueByPath(fromObject, [
11409
+ 'executableCode',
11410
+ ]);
11411
+ if (fromExecutableCode != null) {
11412
+ setValueByPath(toObject, ['executableCode'], fromExecutableCode);
11413
+ }
11414
+ const fromFileData = getValueByPath(fromObject, ['fileData']);
11415
+ if (fromFileData != null) {
11416
+ setValueByPath(toObject, ['fileData'], fromFileData);
11417
+ }
11418
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
11419
+ if (fromFunctionCall != null) {
11420
+ setValueByPath(toObject, ['functionCall'], fromFunctionCall);
11421
+ }
11422
+ const fromFunctionResponse = getValueByPath(fromObject, [
11423
+ 'functionResponse',
11424
+ ]);
11425
+ if (fromFunctionResponse != null) {
11426
+ setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
11427
+ }
11428
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
11429
+ if (fromInlineData != null) {
11430
+ setValueByPath(toObject, ['inlineData'], fromInlineData);
11431
+ }
11432
+ const fromText = getValueByPath(fromObject, ['text']);
11433
+ if (fromText != null) {
11434
+ setValueByPath(toObject, ['text'], fromText);
11435
+ }
11436
+ const fromThought = getValueByPath(fromObject, ['thought']);
11437
+ if (fromThought != null) {
11438
+ setValueByPath(toObject, ['thought'], fromThought);
11439
+ }
11440
+ const fromThoughtSignature = getValueByPath(fromObject, [
11441
+ 'thoughtSignature',
11442
+ ]);
11443
+ if (fromThoughtSignature != null) {
11444
+ setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
11445
+ }
11446
+ const fromVideoMetadata = getValueByPath(fromObject, [
11447
+ 'videoMetadata',
11448
+ ]);
11449
+ if (fromVideoMetadata != null) {
11450
+ setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
11451
+ }
11452
+ if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
11453
+ throw new Error('toolCall parameter is not supported in Vertex AI.');
11454
+ }
11455
+ if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
11456
+ throw new Error('toolResponse parameter is not supported in Vertex AI.');
11457
+ }
11103
11458
  return toObject;
11104
11459
  }
11105
11460
  function productImageToVertex(fromObject, rootObject) {
@@ -11433,6 +11788,30 @@ function toolConfigToMldev(fromObject, rootObject) {
11433
11788
  if (fromFunctionCallingConfig != null) {
11434
11789
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(fromFunctionCallingConfig));
11435
11790
  }
11791
+ const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
11792
+ if (fromIncludeServerSideToolInvocations != null) {
11793
+ setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
11794
+ }
11795
+ return toObject;
11796
+ }
11797
+ function toolConfigToVertex(fromObject, _rootObject) {
11798
+ const toObject = {};
11799
+ const fromRetrievalConfig = getValueByPath(fromObject, [
11800
+ 'retrievalConfig',
11801
+ ]);
11802
+ if (fromRetrievalConfig != null) {
11803
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
11804
+ }
11805
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
11806
+ 'functionCallingConfig',
11807
+ ]);
11808
+ if (fromFunctionCallingConfig != null) {
11809
+ setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
11810
+ }
11811
+ if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
11812
+ undefined) {
11813
+ throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
11814
+ }
11436
11815
  return toObject;
11437
11816
  }
11438
11817
  function toolToMldev$1(fromObject, rootObject) {
@@ -12122,7 +12501,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
12122
12501
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
12123
12502
  const USER_AGENT_HEADER = 'User-Agent';
12124
12503
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
12125
- const SDK_VERSION = '1.44.0'; // x-release-please-version
12504
+ const SDK_VERSION = '1.46.0'; // x-release-please-version
12126
12505
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
12127
12506
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
12128
12507
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -13481,7 +13860,7 @@ class Session {
13481
13860
  }
13482
13861
  }
13483
13862
  const clientMessage = {
13484
- toolResponse: { functionResponses: functionResponses },
13863
+ toolResponse: { 'functionResponses': functionResponses },
13485
13864
  };
13486
13865
  return clientMessage;
13487
13866
  }
@@ -15454,6 +15833,13 @@ class Operations extends BaseModule {
15454
15833
  * Copyright 2025 Google LLC
15455
15834
  * SPDX-License-Identifier: Apache-2.0
15456
15835
  */
15836
+ function audioTranscriptionConfigToMldev(fromObject) {
15837
+ const toObject = {};
15838
+ if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
15839
+ throw new Error('languageCodes parameter is not supported in Gemini API.');
15840
+ }
15841
+ return toObject;
15842
+ }
15457
15843
  function authConfigToMldev(fromObject) {
15458
15844
  const toObject = {};
15459
15845
  const fromApiKey = getValueByPath(fromObject, ['apiKey']);
@@ -15705,13 +16091,13 @@ function liveConnectConfigToMldev(fromObject, parentObject) {
15705
16091
  'inputAudioTranscription',
15706
16092
  ]);
15707
16093
  if (parentObject !== undefined && fromInputAudioTranscription != null) {
15708
- setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
16094
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev(fromInputAudioTranscription));
15709
16095
  }
15710
16096
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
15711
16097
  'outputAudioTranscription',
15712
16098
  ]);
15713
16099
  if (parentObject !== undefined && fromOutputAudioTranscription != null) {
15714
- setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
16100
+ setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev(fromOutputAudioTranscription));
15715
16101
  }
15716
16102
  const fromRealtimeInputConfig = getValueByPath(fromObject, [
15717
16103
  'realtimeInputConfig',
@@ -15804,6 +16190,14 @@ function partToMldev(fromObject) {
15804
16190
  if (fromVideoMetadata != null) {
15805
16191
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
15806
16192
  }
16193
+ const fromToolCall = getValueByPath(fromObject, ['toolCall']);
16194
+ if (fromToolCall != null) {
16195
+ setValueByPath(toObject, ['toolCall'], fromToolCall);
16196
+ }
16197
+ const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
16198
+ if (fromToolResponse != null) {
16199
+ setValueByPath(toObject, ['toolResponse'], fromToolResponse);
16200
+ }
15807
16201
  return toObject;
15808
16202
  }
15809
16203
  function sessionResumptionConfigToMldev(fromObject) {
@@ -16973,6 +17367,30 @@ const FallbackEncoder = ({ headers, body }) => {
16973
17367
  };
16974
17368
  };
16975
17369
 
17370
+ /**
17371
+ * @license
17372
+ * Copyright 2025 Google LLC
17373
+ * SPDX-License-Identifier: Apache-2.0
17374
+ */
17375
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
17376
+ /**
17377
+ * Basic re-implementation of `qs.stringify` for primitive types.
17378
+ */
17379
+ function stringifyQuery(query) {
17380
+ return Object.entries(query)
17381
+ .filter(([_, value]) => typeof value !== 'undefined')
17382
+ .map(([key, value]) => {
17383
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
17384
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
17385
+ }
17386
+ if (value === null) {
17387
+ return `${encodeURIComponent(key)}=`;
17388
+ }
17389
+ throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
17390
+ })
17391
+ .join('&');
17392
+ }
17393
+
16976
17394
  /**
16977
17395
  * @license
16978
17396
  * Copyright 2025 Google LLC
@@ -18116,18 +18534,7 @@ class BaseGeminiNextGenAPIClient {
18116
18534
  * Basic re-implementation of `qs.stringify` for primitive types.
18117
18535
  */
18118
18536
  stringifyQuery(query) {
18119
- return Object.entries(query)
18120
- .filter(([_, value]) => typeof value !== 'undefined')
18121
- .map(([key, value]) => {
18122
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
18123
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
18124
- }
18125
- if (value === null) {
18126
- return `${encodeURIComponent(key)}=`;
18127
- }
18128
- throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
18129
- })
18130
- .join('&');
18537
+ return stringifyQuery(query);
18131
18538
  }
18132
18539
  getUserAgent() {
18133
18540
  return `${this.constructor.name}/JS ${VERSION}`;
@@ -18144,8 +18551,9 @@ class BaseGeminiNextGenAPIClient {
18144
18551
  new URL(path)
18145
18552
  : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
18146
18553
  const defaultQuery = this.defaultQuery();
18147
- if (!isEmptyObj(defaultQuery)) {
18148
- query = Object.assign(Object.assign({}, defaultQuery), query);
18554
+ const pathQuery = Object.fromEntries(url.searchParams);
18555
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
18556
+ query = Object.assign(Object.assign(Object.assign({}, pathQuery), defaultQuery), query);
18149
18557
  }
18150
18558
  if (typeof query === 'object' && query && !Array.isArray(query)) {
18151
18559
  url.search = this.stringifyQuery(query);
@@ -18366,9 +18774,9 @@ class BaseGeminiNextGenAPIClient {
18366
18774
  timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
18367
18775
  }
18368
18776
  }
18369
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
18370
- // just do what it says, but otherwise calculate a default
18371
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
18777
+ // If the API asks us to wait a certain amount of time, just do what it
18778
+ // says, but otherwise calculate a default
18779
+ if (timeoutMillis === undefined) {
18372
18780
  const maxRetries = (_b = options.maxRetries) !== null && _b !== void 0 ? _b : this.maxRetries;
18373
18781
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
18374
18782
  }
@@ -19913,18 +20321,18 @@ const MAX_RETRY_COUNT = 3;
19913
20321
  const INITIAL_RETRY_DELAY_MS = 1000;
19914
20322
  const DELAY_MULTIPLIER = 2;
19915
20323
  const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
19916
- async function uploadBlob(file, uploadUrl, apiClient) {
20324
+ async function uploadBlob(file, uploadUrl, apiClient, httpOptions) {
19917
20325
  var _a;
19918
- const response = await uploadBlobInternal(file, uploadUrl, apiClient);
20326
+ const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
19919
20327
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
19920
20328
  if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
19921
20329
  throw new Error('Failed to upload file: Upload status is not finalized.');
19922
20330
  }
19923
20331
  return responseJson['file'];
19924
20332
  }
19925
- async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
20333
+ async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
19926
20334
  var _a;
19927
- const response = await uploadBlobInternal(file, uploadUrl, apiClient);
20335
+ const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
19928
20336
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
19929
20337
  if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
19930
20338
  throw new Error('Failed to upload file: Upload status is not finalized.');
@@ -19934,8 +20342,18 @@ async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
19934
20342
  Object.assign(typedResp, resp);
19935
20343
  return typedResp;
19936
20344
  }
19937
- async function uploadBlobInternal(file, uploadUrl, apiClient) {
19938
- var _a, _b;
20345
+ async function uploadBlobInternal(file, uploadUrl, apiClient, httpOptions) {
20346
+ var _a, _b, _c;
20347
+ let finalUrl = uploadUrl;
20348
+ const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
20349
+ if (effectiveBaseUrl) {
20350
+ const baseUri = new URL(effectiveBaseUrl);
20351
+ const uploadUri = new URL(uploadUrl);
20352
+ uploadUri.protocol = baseUri.protocol;
20353
+ uploadUri.host = baseUri.host;
20354
+ uploadUri.port = baseUri.port;
20355
+ finalUrl = uploadUri.toString();
20356
+ }
19939
20357
  let fileSize = 0;
19940
20358
  let offset = 0;
19941
20359
  let response = new HttpResponse(new Response());
@@ -19950,21 +20368,14 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
19950
20368
  let retryCount = 0;
19951
20369
  let currentDelayMs = INITIAL_RETRY_DELAY_MS;
19952
20370
  while (retryCount < MAX_RETRY_COUNT) {
20371
+ const mergedHeaders = Object.assign(Object.assign({}, ((httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.headers) || {})), { 'X-Goog-Upload-Command': uploadCommand, 'X-Goog-Upload-Offset': String(offset), 'Content-Length': String(chunkSize) });
19953
20372
  response = await apiClient.request({
19954
20373
  path: '',
19955
20374
  body: chunk,
19956
20375
  httpMethod: 'POST',
19957
- httpOptions: {
19958
- apiVersion: '',
19959
- baseUrl: uploadUrl,
19960
- headers: {
19961
- 'X-Goog-Upload-Command': uploadCommand,
19962
- 'X-Goog-Upload-Offset': String(offset),
19963
- 'Content-Length': String(chunkSize),
19964
- },
19965
- },
20376
+ httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
19966
20377
  });
19967
- if ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
20378
+ if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
19968
20379
  break;
19969
20380
  }
19970
20381
  retryCount++;
@@ -19974,7 +20385,7 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
19974
20385
  offset += chunkSize;
19975
20386
  // The `x-goog-upload-status` header field can be `active`, `final` and
19976
20387
  //`cancelled` in resposne.
19977
- if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'active') {
20388
+ if (((_c = response === null || response === void 0 ? void 0 : response.headers) === null || _c === void 0 ? void 0 : _c[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'active') {
19978
20389
  break;
19979
20390
  }
19980
20391
  // TODO(b/401391430) Investigate why the upload status is not finalized
@@ -20011,20 +20422,20 @@ class NodeUploader {
20011
20422
  return await getBlobStat(file);
20012
20423
  }
20013
20424
  }
20014
- async upload(file, uploadUrl, apiClient) {
20425
+ async upload(file, uploadUrl, apiClient, httpOptions) {
20015
20426
  if (typeof file === 'string') {
20016
- return await this.uploadFileFromPath(file, uploadUrl, apiClient);
20427
+ return await this.uploadFileFromPath(file, uploadUrl, apiClient, httpOptions);
20017
20428
  }
20018
20429
  else {
20019
- return uploadBlob(file, uploadUrl, apiClient);
20430
+ return uploadBlob(file, uploadUrl, apiClient, httpOptions);
20020
20431
  }
20021
20432
  }
20022
- async uploadToFileSearchStore(file, uploadUrl, apiClient) {
20433
+ async uploadToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
20023
20434
  if (typeof file === 'string') {
20024
- return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient);
20435
+ return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient, httpOptions);
20025
20436
  }
20026
20437
  else {
20027
- return uploadBlobToFileSearchStore(file, uploadUrl, apiClient);
20438
+ return uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions);
20028
20439
  }
20029
20440
  }
20030
20441
  /**
@@ -20117,18 +20528,18 @@ class NodeUploader {
20117
20528
  // Return the MIME type.
20118
20529
  return mimeType;
20119
20530
  }
20120
- async uploadFileFromPath(file, uploadUrl, apiClient) {
20531
+ async uploadFileFromPath(file, uploadUrl, apiClient, httpOptions) {
20121
20532
  var _a;
20122
- const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
20533
+ const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions);
20123
20534
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
20124
20535
  if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
20125
20536
  throw new Error('Failed to upload file: Upload status is not finalized.');
20126
20537
  }
20127
20538
  return responseJson['file'];
20128
20539
  }
20129
- async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient) {
20540
+ async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient, httpOptions) {
20130
20541
  var _a;
20131
- const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
20542
+ const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions);
20132
20543
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
20133
20544
  if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
20134
20545
  throw new Error('Failed to upload file: Upload status is not finalized.');
@@ -20138,8 +20549,18 @@ class NodeUploader {
20138
20549
  Object.assign(typedResp, resp);
20139
20550
  return typedResp;
20140
20551
  }
20141
- async uploadFileFromPathInternal(file, uploadUrl, apiClient) {
20142
- var _a, _b;
20552
+ async uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions) {
20553
+ var _a, _b, _c;
20554
+ let finalUrl = uploadUrl;
20555
+ const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
20556
+ if (effectiveBaseUrl) {
20557
+ const baseUri = new URL(effectiveBaseUrl);
20558
+ const uploadUri = new URL(uploadUrl);
20559
+ uploadUri.protocol = baseUri.protocol;
20560
+ uploadUri.host = baseUri.host;
20561
+ uploadUri.port = baseUri.port;
20562
+ finalUrl = uploadUri.toString();
20563
+ }
20143
20564
  let fileSize = 0;
20144
20565
  let offset = 0;
20145
20566
  let response = new HttpResponse(new Response());
@@ -20166,22 +20587,14 @@ class NodeUploader {
20166
20587
  let retryCount = 0;
20167
20588
  let currentDelayMs = INITIAL_RETRY_DELAY_MS;
20168
20589
  while (retryCount < MAX_RETRY_COUNT) {
20590
+ const mergedHeaders = Object.assign(Object.assign({}, ((httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.headers) || {})), { 'X-Goog-Upload-Command': uploadCommand, 'X-Goog-Upload-Offset': String(offset), 'Content-Length': String(bytesRead), 'X-Goog-Upload-File-Name': fileName });
20169
20591
  response = await apiClient.request({
20170
20592
  path: '',
20171
20593
  body: chunk,
20172
20594
  httpMethod: 'POST',
20173
- httpOptions: {
20174
- apiVersion: '',
20175
- baseUrl: uploadUrl,
20176
- headers: {
20177
- 'X-Goog-Upload-Command': uploadCommand,
20178
- 'X-Goog-Upload-Offset': String(offset),
20179
- 'Content-Length': String(bytesRead),
20180
- 'X-Goog-Upload-File-Name': fileName,
20181
- },
20182
- },
20595
+ httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
20183
20596
  });
20184
- if ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
20597
+ if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
20185
20598
  break;
20186
20599
  }
20187
20600
  retryCount++;
@@ -20191,7 +20604,7 @@ class NodeUploader {
20191
20604
  offset += bytesRead;
20192
20605
  // The `x-goog-upload-status` header field can be `active`, `final` and
20193
20606
  //`cancelled` in resposne.
20194
- if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'active') {
20607
+ if (((_c = response === null || response === void 0 ? void 0 : response.headers) === null || _c === void 0 ? void 0 : _c[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'active') {
20195
20608
  break;
20196
20609
  }
20197
20610
  if (fileSize <= offset) {
@@ -20491,6 +20904,7 @@ exports.SingleEmbedContentResponse = SingleEmbedContentResponse;
20491
20904
  exports.StyleReferenceImage = StyleReferenceImage;
20492
20905
  exports.SubjectReferenceImage = SubjectReferenceImage;
20493
20906
  exports.Tokens = Tokens;
20907
+ exports.ToolResponse = ToolResponse;
20494
20908
  exports.UploadToFileSearchStoreOperation = UploadToFileSearchStoreOperation;
20495
20909
  exports.UploadToFileSearchStoreResponse = UploadToFileSearchStoreResponse;
20496
20910
  exports.UploadToFileSearchStoreResumableResponse = UploadToFileSearchStoreResumableResponse;