@google/genai 1.10.0 → 1.12.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
@@ -160,6 +160,20 @@ function getValueByPath(data, keys) {
160
160
  * Copyright 2025 Google LLC
161
161
  * SPDX-License-Identifier: Apache-2.0
162
162
  */
163
+ function tBytes$1(fromBytes) {
164
+ if (typeof fromBytes !== 'string') {
165
+ throw new Error('fromImageBytes must be a string');
166
+ }
167
+ // TODO(b/389133914): Remove dummy bytes converter.
168
+ return fromBytes;
169
+ }
170
+
171
+ /**
172
+ * @license
173
+ * Copyright 2025 Google LLC
174
+ * SPDX-License-Identifier: Apache-2.0
175
+ */
176
+ // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
163
177
  /** Required. Outcome of the code execution. */
164
178
  var Outcome;
165
179
  (function (Outcome) {
@@ -1653,6 +1667,65 @@ class LiveServerMessage {
1653
1667
  return data.length > 0 ? btoa(data) : undefined;
1654
1668
  }
1655
1669
  }
1670
+ /** A video generation long-running operation. */
1671
+ class GenerateVideosOperation {
1672
+ /**
1673
+ * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
1674
+ * @internal
1675
+ */
1676
+ _fromAPIResponse({ apiResponse, isVertexAI, }) {
1677
+ const operation = new GenerateVideosOperation();
1678
+ operation.name = apiResponse['name'];
1679
+ operation.metadata = apiResponse['metadata'];
1680
+ operation.done = apiResponse['done'];
1681
+ operation.error = apiResponse['error'];
1682
+ if (isVertexAI) {
1683
+ const response = apiResponse['response'];
1684
+ if (response) {
1685
+ const operationResponse = new GenerateVideosResponse();
1686
+ const responseVideos = response['videos'];
1687
+ operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1688
+ return {
1689
+ video: {
1690
+ uri: generatedVideo['gcsUri'],
1691
+ videoBytes: generatedVideo['bytesBase64Encoded']
1692
+ ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1693
+ : undefined,
1694
+ mimeType: generatedVideo['mimeType'],
1695
+ },
1696
+ };
1697
+ });
1698
+ operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1699
+ operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1700
+ operation.response = operationResponse;
1701
+ }
1702
+ }
1703
+ else {
1704
+ const response = apiResponse['response'];
1705
+ if (response) {
1706
+ const operationResponse = new GenerateVideosResponse();
1707
+ const generatedVideoResponse = response['generateVideoResponse'];
1708
+ const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1709
+ operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1710
+ const video = generatedVideo['video'];
1711
+ return {
1712
+ video: {
1713
+ uri: video === null || video === void 0 ? void 0 : video['uri'],
1714
+ videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1715
+ ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1716
+ : undefined,
1717
+ mimeType: generatedVideo['encoding'],
1718
+ },
1719
+ };
1720
+ });
1721
+ operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1722
+ operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1723
+ operation.response = operationResponse;
1724
+ }
1725
+ }
1726
+ return operation;
1727
+ }
1728
+ }
1656
1729
  /** Client generated response to a `ToolCall` received from the server.
1657
1730
 
1658
1731
  Individual `FunctionResponse` objects are matched to the respective
@@ -2214,11 +2287,7 @@ function tTuningJobStatus(status) {
2214
2287
  }
2215
2288
  }
2216
2289
  function tBytes(fromImageBytes) {
2217
- if (typeof fromImageBytes !== 'string') {
2218
- throw new Error('fromImageBytes must be a string');
2219
- }
2220
- // TODO(b/389133914): Remove dummy bytes converter.
2221
- return fromImageBytes;
2290
+ return tBytes$1(fromImageBytes);
2222
2291
  }
2223
2292
  function _isFile(origin) {
2224
2293
  return (origin !== null &&
@@ -3706,6 +3775,12 @@ function batchJobFromMldev(fromObject) {
3706
3775
  }
3707
3776
  function listBatchJobsResponseFromMldev(fromObject) {
3708
3777
  const toObject = {};
3778
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
3779
+ 'sdkHttpResponse',
3780
+ ]);
3781
+ if (fromSdkHttpResponse != null) {
3782
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
3783
+ }
3709
3784
  const fromNextPageToken = getValueByPath(fromObject, [
3710
3785
  'nextPageToken',
3711
3786
  ]);
@@ -3847,6 +3922,12 @@ function batchJobFromVertex(fromObject) {
3847
3922
  }
3848
3923
  function listBatchJobsResponseFromVertex(fromObject) {
3849
3924
  const toObject = {};
3925
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
3926
+ 'sdkHttpResponse',
3927
+ ]);
3928
+ if (fromSdkHttpResponse != null) {
3929
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
3930
+ }
3850
3931
  const fromNextPageToken = getValueByPath(fromObject, [
3851
3932
  'nextPageToken',
3852
3933
  ]);
@@ -3889,9 +3970,6 @@ function deleteResourceJobFromVertex(fromObject) {
3889
3970
  * Copyright 2025 Google LLC
3890
3971
  * SPDX-License-Identifier: Apache-2.0
3891
3972
  */
3892
- /**
3893
- * Pagers for the GenAI List APIs.
3894
- */
3895
3973
  var PagedItem;
3896
3974
  (function (PagedItem) {
3897
3975
  PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
@@ -3914,9 +3992,10 @@ class Pager {
3914
3992
  var _a, _b;
3915
3993
  this.nameInternal = name;
3916
3994
  this.pageInternal = response[this.nameInternal] || [];
3995
+ this.sdkHttpResponseInternal = response === null || response === void 0 ? void 0 : response.sdkHttpResponse;
3917
3996
  this.idxInternal = 0;
3918
3997
  let requestParams = { config: {} };
3919
- if (!params) {
3998
+ if (!params || Object.keys(params).length === 0) {
3920
3999
  requestParams = { config: {} };
3921
4000
  }
3922
4001
  else if (typeof params === 'object') {
@@ -3960,6 +4039,12 @@ class Pager {
3960
4039
  get pageSize() {
3961
4040
  return this.pageInternalSize;
3962
4041
  }
4042
+ /**
4043
+ * Returns the headers of the API response.
4044
+ */
4045
+ get sdkHttpResponse() {
4046
+ return this.sdkHttpResponseInternal;
4047
+ }
3963
4048
  /**
3964
4049
  * Returns the parameters when making the API request for the next page.
3965
4050
  *
@@ -4329,7 +4414,13 @@ class Batches extends BaseModule {
4329
4414
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4330
4415
  })
4331
4416
  .then((httpResponse) => {
4332
- return httpResponse.json();
4417
+ return httpResponse.json().then((jsonResponse) => {
4418
+ const response = jsonResponse;
4419
+ response.sdkHttpResponse = {
4420
+ headers: httpResponse.headers,
4421
+ };
4422
+ return response;
4423
+ });
4333
4424
  });
4334
4425
  return response.then((apiResponse) => {
4335
4426
  const resp = listBatchJobsResponseFromVertex(apiResponse);
@@ -4355,7 +4446,13 @@ class Batches extends BaseModule {
4355
4446
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4356
4447
  })
4357
4448
  .then((httpResponse) => {
4358
- return httpResponse.json();
4449
+ return httpResponse.json().then((jsonResponse) => {
4450
+ const response = jsonResponse;
4451
+ response.sdkHttpResponse = {
4452
+ headers: httpResponse.headers,
4453
+ };
4454
+ return response;
4455
+ });
4359
4456
  });
4360
4457
  return response.then((apiResponse) => {
4361
4458
  const resp = listBatchJobsResponseFromMldev(apiResponse);
@@ -5408,6 +5505,12 @@ function deleteCachedContentResponseFromMldev() {
5408
5505
  }
5409
5506
  function listCachedContentsResponseFromMldev(fromObject) {
5410
5507
  const toObject = {};
5508
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
5509
+ 'sdkHttpResponse',
5510
+ ]);
5511
+ if (fromSdkHttpResponse != null) {
5512
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
5513
+ }
5411
5514
  const fromNextPageToken = getValueByPath(fromObject, [
5412
5515
  'nextPageToken',
5413
5516
  ]);
@@ -5468,6 +5571,12 @@ function deleteCachedContentResponseFromVertex() {
5468
5571
  }
5469
5572
  function listCachedContentsResponseFromVertex(fromObject) {
5470
5573
  const toObject = {};
5574
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
5575
+ 'sdkHttpResponse',
5576
+ ]);
5577
+ if (fromSdkHttpResponse != null) {
5578
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
5579
+ }
5471
5580
  const fromNextPageToken = getValueByPath(fromObject, [
5472
5581
  'nextPageToken',
5473
5582
  ]);
@@ -5820,7 +5929,13 @@ class Caches extends BaseModule {
5820
5929
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
5821
5930
  })
5822
5931
  .then((httpResponse) => {
5823
- return httpResponse.json();
5932
+ return httpResponse.json().then((jsonResponse) => {
5933
+ const response = jsonResponse;
5934
+ response.sdkHttpResponse = {
5935
+ headers: httpResponse.headers,
5936
+ };
5937
+ return response;
5938
+ });
5824
5939
  });
5825
5940
  return response.then((apiResponse) => {
5826
5941
  const resp = listCachedContentsResponseFromVertex(apiResponse);
@@ -5846,7 +5961,13 @@ class Caches extends BaseModule {
5846
5961
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
5847
5962
  })
5848
5963
  .then((httpResponse) => {
5849
- return httpResponse.json();
5964
+ return httpResponse.json().then((jsonResponse) => {
5965
+ const response = jsonResponse;
5966
+ response.sdkHttpResponse = {
5967
+ headers: httpResponse.headers,
5968
+ };
5969
+ return response;
5970
+ });
5850
5971
  });
5851
5972
  return response.then((apiResponse) => {
5852
5973
  const resp = listCachedContentsResponseFromMldev(apiResponse);
@@ -6269,7 +6390,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
6269
6390
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
6270
6391
  const USER_AGENT_HEADER = 'User-Agent';
6271
6392
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
6272
- const SDK_VERSION = '1.10.0'; // x-release-please-version
6393
+ const SDK_VERSION = '1.12.0'; // x-release-please-version
6273
6394
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
6274
6395
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
6275
6396
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -7181,6 +7302,12 @@ function fileFromMldev(fromObject) {
7181
7302
  }
7182
7303
  function listFilesResponseFromMldev(fromObject) {
7183
7304
  const toObject = {};
7305
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
7306
+ 'sdkHttpResponse',
7307
+ ]);
7308
+ if (fromSdkHttpResponse != null) {
7309
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
7310
+ }
7184
7311
  const fromNextPageToken = getValueByPath(fromObject, [
7185
7312
  'nextPageToken',
7186
7313
  ]);
@@ -7342,7 +7469,13 @@ class Files extends BaseModule {
7342
7469
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
7343
7470
  })
7344
7471
  .then((httpResponse) => {
7345
- return httpResponse.json();
7472
+ return httpResponse.json().then((jsonResponse) => {
7473
+ const response = jsonResponse;
7474
+ response.sdkHttpResponse = {
7475
+ headers: httpResponse.headers,
7476
+ };
7477
+ return response;
7478
+ });
7346
7479
  });
7347
7480
  return response.then((apiResponse) => {
7348
7481
  const resp = listFilesResponseFromMldev(apiResponse);
@@ -10568,6 +10701,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
10568
10701
  if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
10569
10702
  throw new Error('addWatermark parameter is not supported in Gemini API.');
10570
10703
  }
10704
+ if (getValueByPath(fromObject, ['imageSize']) !== undefined) {
10705
+ throw new Error('imageSize parameter is not supported in Gemini API.');
10706
+ }
10571
10707
  if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
10572
10708
  throw new Error('enhancePrompt parameter is not supported in Gemini API.');
10573
10709
  }
@@ -11644,6 +11780,10 @@ function generateImagesConfigToVertex(fromObject, parentObject) {
11644
11780
  if (parentObject !== undefined && fromAddWatermark != null) {
11645
11781
  setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
11646
11782
  }
11783
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
11784
+ if (parentObject !== undefined && fromImageSize != null) {
11785
+ setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
11786
+ }
11647
11787
  const fromEnhancePrompt = getValueByPath(fromObject, [
11648
11788
  'enhancePrompt',
11649
11789
  ]);
@@ -12482,6 +12622,12 @@ function embedContentMetadataFromMldev() {
12482
12622
  }
12483
12623
  function embedContentResponseFromMldev(fromObject) {
12484
12624
  const toObject = {};
12625
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12626
+ 'sdkHttpResponse',
12627
+ ]);
12628
+ if (fromSdkHttpResponse != null) {
12629
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12630
+ }
12485
12631
  const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
12486
12632
  if (fromEmbeddings != null) {
12487
12633
  let transformedList = fromEmbeddings;
@@ -12554,6 +12700,12 @@ function generatedImageFromMldev(fromObject) {
12554
12700
  }
12555
12701
  function generateImagesResponseFromMldev(fromObject) {
12556
12702
  const toObject = {};
12703
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12704
+ 'sdkHttpResponse',
12705
+ ]);
12706
+ if (fromSdkHttpResponse != null) {
12707
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12708
+ }
12557
12709
  const fromGeneratedImages = getValueByPath(fromObject, [
12558
12710
  'predictions',
12559
12711
  ]);
@@ -12634,6 +12786,12 @@ function modelFromMldev(fromObject) {
12634
12786
  }
12635
12787
  function listModelsResponseFromMldev(fromObject) {
12636
12788
  const toObject = {};
12789
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12790
+ 'sdkHttpResponse',
12791
+ ]);
12792
+ if (fromSdkHttpResponse != null) {
12793
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12794
+ }
12637
12795
  const fromNextPageToken = getValueByPath(fromObject, [
12638
12796
  'nextPageToken',
12639
12797
  ]);
@@ -12658,6 +12816,12 @@ function deleteModelResponseFromMldev() {
12658
12816
  }
12659
12817
  function countTokensResponseFromMldev(fromObject) {
12660
12818
  const toObject = {};
12819
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12820
+ 'sdkHttpResponse',
12821
+ ]);
12822
+ if (fromSdkHttpResponse != null) {
12823
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12824
+ }
12661
12825
  const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
12662
12826
  if (fromTotalTokens != null) {
12663
12827
  setValueByPath(toObject, ['totalTokens'], fromTotalTokens);
@@ -12670,7 +12834,7 @@ function countTokensResponseFromMldev(fromObject) {
12670
12834
  }
12671
12835
  return toObject;
12672
12836
  }
12673
- function videoFromMldev$1(fromObject) {
12837
+ function videoFromMldev(fromObject) {
12674
12838
  const toObject = {};
12675
12839
  const fromUri = getValueByPath(fromObject, ['video', 'uri']);
12676
12840
  if (fromUri != null) {
@@ -12689,15 +12853,15 @@ function videoFromMldev$1(fromObject) {
12689
12853
  }
12690
12854
  return toObject;
12691
12855
  }
12692
- function generatedVideoFromMldev$1(fromObject) {
12856
+ function generatedVideoFromMldev(fromObject) {
12693
12857
  const toObject = {};
12694
12858
  const fromVideo = getValueByPath(fromObject, ['_self']);
12695
12859
  if (fromVideo != null) {
12696
- setValueByPath(toObject, ['video'], videoFromMldev$1(fromVideo));
12860
+ setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
12697
12861
  }
12698
12862
  return toObject;
12699
12863
  }
12700
- function generateVideosResponseFromMldev$1(fromObject) {
12864
+ function generateVideosResponseFromMldev(fromObject) {
12701
12865
  const toObject = {};
12702
12866
  const fromGeneratedVideos = getValueByPath(fromObject, [
12703
12867
  'generatedSamples',
@@ -12706,7 +12870,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
12706
12870
  let transformedList = fromGeneratedVideos;
12707
12871
  if (Array.isArray(transformedList)) {
12708
12872
  transformedList = transformedList.map((item) => {
12709
- return generatedVideoFromMldev$1(item);
12873
+ return generatedVideoFromMldev(item);
12710
12874
  });
12711
12875
  }
12712
12876
  setValueByPath(toObject, ['generatedVideos'], transformedList);
@@ -12725,7 +12889,7 @@ function generateVideosResponseFromMldev$1(fromObject) {
12725
12889
  }
12726
12890
  return toObject;
12727
12891
  }
12728
- function generateVideosOperationFromMldev$1(fromObject) {
12892
+ function generateVideosOperationFromMldev(fromObject) {
12729
12893
  const toObject = {};
12730
12894
  const fromName = getValueByPath(fromObject, ['name']);
12731
12895
  if (fromName != null) {
@@ -12748,7 +12912,7 @@ function generateVideosOperationFromMldev$1(fromObject) {
12748
12912
  'generateVideoResponse',
12749
12913
  ]);
12750
12914
  if (fromResponse != null) {
12751
- setValueByPath(toObject, ['response'], generateVideosResponseFromMldev$1(fromResponse));
12915
+ setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
12752
12916
  }
12753
12917
  return toObject;
12754
12918
  }
@@ -13044,6 +13208,12 @@ function embedContentMetadataFromVertex(fromObject) {
13044
13208
  }
13045
13209
  function embedContentResponseFromVertex(fromObject) {
13046
13210
  const toObject = {};
13211
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13212
+ 'sdkHttpResponse',
13213
+ ]);
13214
+ if (fromSdkHttpResponse != null) {
13215
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13216
+ }
13047
13217
  const fromEmbeddings = getValueByPath(fromObject, [
13048
13218
  'predictions[]',
13049
13219
  'embeddings',
@@ -13127,6 +13297,12 @@ function generatedImageFromVertex(fromObject) {
13127
13297
  }
13128
13298
  function generateImagesResponseFromVertex(fromObject) {
13129
13299
  const toObject = {};
13300
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13301
+ 'sdkHttpResponse',
13302
+ ]);
13303
+ if (fromSdkHttpResponse != null) {
13304
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13305
+ }
13130
13306
  const fromGeneratedImages = getValueByPath(fromObject, [
13131
13307
  'predictions',
13132
13308
  ]);
@@ -13149,6 +13325,12 @@ function generateImagesResponseFromVertex(fromObject) {
13149
13325
  }
13150
13326
  function editImageResponseFromVertex(fromObject) {
13151
13327
  const toObject = {};
13328
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13329
+ 'sdkHttpResponse',
13330
+ ]);
13331
+ if (fromSdkHttpResponse != null) {
13332
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13333
+ }
13152
13334
  const fromGeneratedImages = getValueByPath(fromObject, [
13153
13335
  'predictions',
13154
13336
  ]);
@@ -13165,6 +13347,12 @@ function editImageResponseFromVertex(fromObject) {
13165
13347
  }
13166
13348
  function upscaleImageResponseFromVertex(fromObject) {
13167
13349
  const toObject = {};
13350
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13351
+ 'sdkHttpResponse',
13352
+ ]);
13353
+ if (fromSdkHttpResponse != null) {
13354
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13355
+ }
13168
13356
  const fromGeneratedImages = getValueByPath(fromObject, [
13169
13357
  'predictions',
13170
13358
  ]);
@@ -13284,6 +13472,12 @@ function modelFromVertex(fromObject) {
13284
13472
  }
13285
13473
  function listModelsResponseFromVertex(fromObject) {
13286
13474
  const toObject = {};
13475
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13476
+ 'sdkHttpResponse',
13477
+ ]);
13478
+ if (fromSdkHttpResponse != null) {
13479
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13480
+ }
13287
13481
  const fromNextPageToken = getValueByPath(fromObject, [
13288
13482
  'nextPageToken',
13289
13483
  ]);
@@ -13308,6 +13502,12 @@ function deleteModelResponseFromVertex() {
13308
13502
  }
13309
13503
  function countTokensResponseFromVertex(fromObject) {
13310
13504
  const toObject = {};
13505
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13506
+ 'sdkHttpResponse',
13507
+ ]);
13508
+ if (fromSdkHttpResponse != null) {
13509
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13510
+ }
13311
13511
  const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
13312
13512
  if (fromTotalTokens != null) {
13313
13513
  setValueByPath(toObject, ['totalTokens'], fromTotalTokens);
@@ -13316,13 +13516,19 @@ function countTokensResponseFromVertex(fromObject) {
13316
13516
  }
13317
13517
  function computeTokensResponseFromVertex(fromObject) {
13318
13518
  const toObject = {};
13519
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13520
+ 'sdkHttpResponse',
13521
+ ]);
13522
+ if (fromSdkHttpResponse != null) {
13523
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13524
+ }
13319
13525
  const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
13320
13526
  if (fromTokensInfo != null) {
13321
13527
  setValueByPath(toObject, ['tokensInfo'], fromTokensInfo);
13322
13528
  }
13323
13529
  return toObject;
13324
13530
  }
13325
- function videoFromVertex$1(fromObject) {
13531
+ function videoFromVertex(fromObject) {
13326
13532
  const toObject = {};
13327
13533
  const fromUri = getValueByPath(fromObject, ['gcsUri']);
13328
13534
  if (fromUri != null) {
@@ -13340,22 +13546,22 @@ function videoFromVertex$1(fromObject) {
13340
13546
  }
13341
13547
  return toObject;
13342
13548
  }
13343
- function generatedVideoFromVertex$1(fromObject) {
13549
+ function generatedVideoFromVertex(fromObject) {
13344
13550
  const toObject = {};
13345
13551
  const fromVideo = getValueByPath(fromObject, ['_self']);
13346
13552
  if (fromVideo != null) {
13347
- setValueByPath(toObject, ['video'], videoFromVertex$1(fromVideo));
13553
+ setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
13348
13554
  }
13349
13555
  return toObject;
13350
13556
  }
13351
- function generateVideosResponseFromVertex$1(fromObject) {
13557
+ function generateVideosResponseFromVertex(fromObject) {
13352
13558
  const toObject = {};
13353
13559
  const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
13354
13560
  if (fromGeneratedVideos != null) {
13355
13561
  let transformedList = fromGeneratedVideos;
13356
13562
  if (Array.isArray(transformedList)) {
13357
13563
  transformedList = transformedList.map((item) => {
13358
- return generatedVideoFromVertex$1(item);
13564
+ return generatedVideoFromVertex(item);
13359
13565
  });
13360
13566
  }
13361
13567
  setValueByPath(toObject, ['generatedVideos'], transformedList);
@@ -13374,7 +13580,7 @@ function generateVideosResponseFromVertex$1(fromObject) {
13374
13580
  }
13375
13581
  return toObject;
13376
13582
  }
13377
- function generateVideosOperationFromVertex$1(fromObject) {
13583
+ function generateVideosOperationFromVertex(fromObject) {
13378
13584
  const toObject = {};
13379
13585
  const fromName = getValueByPath(fromObject, ['name']);
13380
13586
  if (fromName != null) {
@@ -13394,7 +13600,7 @@ function generateVideosOperationFromVertex$1(fromObject) {
13394
13600
  }
13395
13601
  const fromResponse = getValueByPath(fromObject, ['response']);
13396
13602
  if (fromResponse != null) {
13397
- setValueByPath(toObject, ['response'], generateVideosResponseFromVertex$1(fromResponse));
13603
+ setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
13398
13604
  }
13399
13605
  return toObject;
13400
13606
  }
@@ -13427,18 +13633,6 @@ function setMcpUsageHeader(headers) {
13427
13633
  const existingHeader = (_a = headers[GOOGLE_API_CLIENT_HEADER]) !== null && _a !== void 0 ? _a : '';
13428
13634
  headers[GOOGLE_API_CLIENT_HEADER] = (existingHeader + ` ${MCP_LABEL}`).trimStart();
13429
13635
  }
13430
- // Checks whether the list of tools contains any MCP clients. Will return true
13431
- // if there is at least one MCP client.
13432
- function hasMcpClientTools(params) {
13433
- var _a, _b, _c;
13434
- return (_c = (_b = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools) === null || _b === void 0 ? void 0 : _b.some((tool) => isMcpCallableTool(tool))) !== null && _c !== void 0 ? _c : false;
13435
- }
13436
- // Checks whether the list of tools contains any non-MCP tools. Will return true
13437
- // if there is at least one non-MCP tool.
13438
- function hasNonMcpTools(params) {
13439
- var _a, _b, _c;
13440
- return ((_c = (_b = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools) === null || _b === void 0 ? void 0 : _b.some((tool) => !isMcpCallableTool(tool))) !== null && _c !== void 0 ? _c : false);
13441
- }
13442
13636
  // Returns true if the object is a MCP CallableTool, otherwise false.
13443
13637
  function isMcpCallableTool(object) {
13444
13638
  return (object !== null &&
@@ -13932,13 +14126,13 @@ class Live {
13932
14126
  const websocketBaseUrl = this.apiClient.getWebsocketBaseUrl();
13933
14127
  const apiVersion = this.apiClient.getApiVersion();
13934
14128
  let url;
13935
- const defaultHeaders = this.apiClient.getDefaultHeaders();
14129
+ const clientHeaders = this.apiClient.getHeaders();
13936
14130
  if (params.config &&
13937
14131
  params.config.tools &&
13938
14132
  hasMcpToolUsage(params.config.tools)) {
13939
- setMcpUsageHeader(defaultHeaders);
14133
+ setMcpUsageHeader(clientHeaders);
13940
14134
  }
13941
- const headers = mapToHeaders(defaultHeaders);
14135
+ const headers = mapToHeaders(clientHeaders);
13942
14136
  if (this.apiClient.isVertexAI()) {
13943
14137
  url = `${websocketBaseUrl}/ws/google.cloud.aiplatform.${apiVersion}.LlmBidiService/BidiGenerateContent`;
13944
14138
  await this.auth.addAuthHeaders(headers);
@@ -14297,6 +14491,18 @@ function shouldDisableAfc(config) {
14297
14491
  function isCallableTool(tool) {
14298
14492
  return 'callTool' in tool && typeof tool.callTool === 'function';
14299
14493
  }
14494
+ // Checks whether the list of tools contains any CallableTools. Will return true
14495
+ // if there is at least one CallableTool.
14496
+ function hasCallableTools(params) {
14497
+ var _a, _b, _c;
14498
+ return (_c = (_b = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools) === null || _b === void 0 ? void 0 : _b.some((tool) => isCallableTool(tool))) !== null && _c !== void 0 ? _c : false;
14499
+ }
14500
+ // Checks whether the list of tools contains any non-callable tools. Will return
14501
+ // true if there is at least one non-Callable tool.
14502
+ function hasNonCallableTools(params) {
14503
+ var _a, _b, _c;
14504
+ return (_c = (_b = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools) === null || _b === void 0 ? void 0 : _b.some((tool) => !isCallableTool(tool))) !== null && _c !== void 0 ? _c : false;
14505
+ }
14300
14506
  /**
14301
14507
  * Returns whether to append automatic function calling history to the
14302
14508
  * response.
@@ -14355,12 +14561,12 @@ class Models extends BaseModule {
14355
14561
  */
14356
14562
  this.generateContent = async (params) => {
14357
14563
  var _a, _b, _c, _d, _e;
14358
- const transformedParams = await this.processParamsForMcpUsage(params);
14564
+ const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
14359
14565
  this.maybeMoveToResponseJsonSchem(params);
14360
- if (!hasMcpClientTools(params) || shouldDisableAfc(params.config)) {
14566
+ if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
14361
14567
  return await this.generateContentInternal(transformedParams);
14362
14568
  }
14363
- if (hasNonMcpTools(params)) {
14569
+ if (hasNonCallableTools(params)) {
14364
14570
  throw new Error('Automatic function calling with CallableTools and Tools is not yet supported.');
14365
14571
  }
14366
14572
  let response;
@@ -14445,7 +14651,7 @@ class Models extends BaseModule {
14445
14651
  this.generateContentStream = async (params) => {
14446
14652
  this.maybeMoveToResponseJsonSchem(params);
14447
14653
  if (shouldDisableAfc(params.config)) {
14448
- const transformedParams = await this.processParamsForMcpUsage(params);
14654
+ const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
14449
14655
  return await this.generateContentStreamInternal(transformedParams);
14450
14656
  }
14451
14657
  else {
@@ -14493,11 +14699,13 @@ class Models extends BaseModule {
14493
14699
  response = {
14494
14700
  generatedImages: generatedImages,
14495
14701
  positivePromptSafetyAttributes: positivePromptSafetyAttributes,
14702
+ sdkHttpResponse: apiResponse.sdkHttpResponse,
14496
14703
  };
14497
14704
  }
14498
14705
  else {
14499
14706
  response = {
14500
14707
  generatedImages: generatedImages,
14708
+ sdkHttpResponse: apiResponse.sdkHttpResponse,
14501
14709
  };
14502
14710
  }
14503
14711
  return response;
@@ -14594,6 +14802,32 @@ class Models extends BaseModule {
14594
14802
  };
14595
14803
  return await this.upscaleImageInternal(apiParams);
14596
14804
  };
14805
+ /**
14806
+ * Generates videos based on a text description and configuration.
14807
+ *
14808
+ * @param params - The parameters for generating videos.
14809
+ * @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
14810
+ *
14811
+ * @example
14812
+ * ```ts
14813
+ * const operation = await ai.models.generateVideos({
14814
+ * model: 'veo-2.0-generate-001',
14815
+ * prompt: 'A neon hologram of a cat driving at top speed',
14816
+ * config: {
14817
+ * numberOfVideos: 1
14818
+ * });
14819
+ *
14820
+ * while (!operation.done) {
14821
+ * await new Promise(resolve => setTimeout(resolve, 10000));
14822
+ * operation = await ai.operations.getVideosOperation({operation: operation});
14823
+ * }
14824
+ *
14825
+ * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
14826
+ * ```
14827
+ */
14828
+ this.generateVideos = async (params) => {
14829
+ return await this.generateVideosInternal(params);
14830
+ };
14597
14831
  }
14598
14832
  /**
14599
14833
  * This logic is needed for GenerateContentConfig only.
@@ -14619,7 +14853,7 @@ class Models extends BaseModule {
14619
14853
  * modify the original params. Also sets the MCP usage header if there are
14620
14854
  * MCP tools in the parameters.
14621
14855
  */
14622
- async processParamsForMcpUsage(params) {
14856
+ async processParamsMaybeAddMcpUsage(params) {
14623
14857
  var _a, _b, _c;
14624
14858
  const tools = (_a = params.config) === null || _a === void 0 ? void 0 : _a.tools;
14625
14859
  if (!tools) {
@@ -14686,7 +14920,7 @@ class Models extends BaseModule {
14686
14920
  remoteCallCount++;
14687
14921
  wereFunctionsCalled = false;
14688
14922
  }
14689
- const transformedParams = yield __await(models.processParamsForMcpUsage(params));
14923
+ const transformedParams = yield __await(models.processParamsMaybeAddMcpUsage(params));
14690
14924
  const response = yield __await(models.generateContentStreamInternal(transformedParams));
14691
14925
  const functionResponses = [];
14692
14926
  const responseContents = [];
@@ -14957,7 +15191,13 @@ class Models extends BaseModule {
14957
15191
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
14958
15192
  })
14959
15193
  .then((httpResponse) => {
14960
- return httpResponse.json();
15194
+ return httpResponse.json().then((jsonResponse) => {
15195
+ const response = jsonResponse;
15196
+ response.sdkHttpResponse = {
15197
+ headers: httpResponse.headers,
15198
+ };
15199
+ return response;
15200
+ });
14961
15201
  });
14962
15202
  return response.then((apiResponse) => {
14963
15203
  const resp = embedContentResponseFromVertex(apiResponse);
@@ -14983,7 +15223,13 @@ class Models extends BaseModule {
14983
15223
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
14984
15224
  })
14985
15225
  .then((httpResponse) => {
14986
- return httpResponse.json();
15226
+ return httpResponse.json().then((jsonResponse) => {
15227
+ const response = jsonResponse;
15228
+ response.sdkHttpResponse = {
15229
+ headers: httpResponse.headers,
15230
+ };
15231
+ return response;
15232
+ });
14987
15233
  });
14988
15234
  return response.then((apiResponse) => {
14989
15235
  const resp = embedContentResponseFromMldev(apiResponse);
@@ -15034,7 +15280,13 @@ class Models extends BaseModule {
15034
15280
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15035
15281
  })
15036
15282
  .then((httpResponse) => {
15037
- return httpResponse.json();
15283
+ return httpResponse.json().then((jsonResponse) => {
15284
+ const response = jsonResponse;
15285
+ response.sdkHttpResponse = {
15286
+ headers: httpResponse.headers,
15287
+ };
15288
+ return response;
15289
+ });
15038
15290
  });
15039
15291
  return response.then((apiResponse) => {
15040
15292
  const resp = generateImagesResponseFromVertex(apiResponse);
@@ -15060,7 +15312,13 @@ class Models extends BaseModule {
15060
15312
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
15061
15313
  })
15062
15314
  .then((httpResponse) => {
15063
- return httpResponse.json();
15315
+ return httpResponse.json().then((jsonResponse) => {
15316
+ const response = jsonResponse;
15317
+ response.sdkHttpResponse = {
15318
+ headers: httpResponse.headers,
15319
+ };
15320
+ return response;
15321
+ });
15064
15322
  });
15065
15323
  return response.then((apiResponse) => {
15066
15324
  const resp = generateImagesResponseFromMldev(apiResponse);
@@ -15092,7 +15350,13 @@ class Models extends BaseModule {
15092
15350
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15093
15351
  })
15094
15352
  .then((httpResponse) => {
15095
- return httpResponse.json();
15353
+ return httpResponse.json().then((jsonResponse) => {
15354
+ const response = jsonResponse;
15355
+ response.sdkHttpResponse = {
15356
+ headers: httpResponse.headers,
15357
+ };
15358
+ return response;
15359
+ });
15096
15360
  });
15097
15361
  return response.then((apiResponse) => {
15098
15362
  const resp = editImageResponseFromVertex(apiResponse);
@@ -15127,7 +15391,13 @@ class Models extends BaseModule {
15127
15391
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15128
15392
  })
15129
15393
  .then((httpResponse) => {
15130
- return httpResponse.json();
15394
+ return httpResponse.json().then((jsonResponse) => {
15395
+ const response = jsonResponse;
15396
+ response.sdkHttpResponse = {
15397
+ headers: httpResponse.headers,
15398
+ };
15399
+ return response;
15400
+ });
15131
15401
  });
15132
15402
  return response.then((apiResponse) => {
15133
15403
  const resp = upscaleImageResponseFromVertex(apiResponse);
@@ -15224,9 +15494,15 @@ class Models extends BaseModule {
15224
15494
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15225
15495
  })
15226
15496
  .then((httpResponse) => {
15227
- return httpResponse.json();
15228
- });
15229
- return response.then((apiResponse) => {
15497
+ return httpResponse.json().then((jsonResponse) => {
15498
+ const response = jsonResponse;
15499
+ response.sdkHttpResponse = {
15500
+ headers: httpResponse.headers,
15501
+ };
15502
+ return response;
15503
+ });
15504
+ });
15505
+ return response.then((apiResponse) => {
15230
15506
  const resp = listModelsResponseFromVertex(apiResponse);
15231
15507
  const typedResp = new ListModelsResponse();
15232
15508
  Object.assign(typedResp, resp);
@@ -15250,7 +15526,13 @@ class Models extends BaseModule {
15250
15526
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
15251
15527
  })
15252
15528
  .then((httpResponse) => {
15253
- return httpResponse.json();
15529
+ return httpResponse.json().then((jsonResponse) => {
15530
+ const response = jsonResponse;
15531
+ response.sdkHttpResponse = {
15532
+ headers: httpResponse.headers,
15533
+ };
15534
+ return response;
15535
+ });
15254
15536
  });
15255
15537
  return response.then((apiResponse) => {
15256
15538
  const resp = listModelsResponseFromMldev(apiResponse);
@@ -15438,7 +15720,13 @@ class Models extends BaseModule {
15438
15720
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15439
15721
  })
15440
15722
  .then((httpResponse) => {
15441
- return httpResponse.json();
15723
+ return httpResponse.json().then((jsonResponse) => {
15724
+ const response = jsonResponse;
15725
+ response.sdkHttpResponse = {
15726
+ headers: httpResponse.headers,
15727
+ };
15728
+ return response;
15729
+ });
15442
15730
  });
15443
15731
  return response.then((apiResponse) => {
15444
15732
  const resp = countTokensResponseFromVertex(apiResponse);
@@ -15464,7 +15752,13 @@ class Models extends BaseModule {
15464
15752
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
15465
15753
  })
15466
15754
  .then((httpResponse) => {
15467
- return httpResponse.json();
15755
+ return httpResponse.json().then((jsonResponse) => {
15756
+ const response = jsonResponse;
15757
+ response.sdkHttpResponse = {
15758
+ headers: httpResponse.headers,
15759
+ };
15760
+ return response;
15761
+ });
15468
15762
  });
15469
15763
  return response.then((apiResponse) => {
15470
15764
  const resp = countTokensResponseFromMldev(apiResponse);
@@ -15514,7 +15808,13 @@ class Models extends BaseModule {
15514
15808
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15515
15809
  })
15516
15810
  .then((httpResponse) => {
15517
- return httpResponse.json();
15811
+ return httpResponse.json().then((jsonResponse) => {
15812
+ const response = jsonResponse;
15813
+ response.sdkHttpResponse = {
15814
+ headers: httpResponse.headers,
15815
+ };
15816
+ return response;
15817
+ });
15518
15818
  });
15519
15819
  return response.then((apiResponse) => {
15520
15820
  const resp = computeTokensResponseFromVertex(apiResponse);
@@ -15550,7 +15850,7 @@ class Models extends BaseModule {
15550
15850
  * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
15551
15851
  * ```
15552
15852
  */
15553
- async generateVideos(params) {
15853
+ async generateVideosInternal(params) {
15554
15854
  var _a, _b, _c, _d;
15555
15855
  let response;
15556
15856
  let path = '';
@@ -15575,8 +15875,10 @@ class Models extends BaseModule {
15575
15875
  return httpResponse.json();
15576
15876
  });
15577
15877
  return response.then((apiResponse) => {
15578
- const resp = generateVideosOperationFromVertex$1(apiResponse);
15579
- return resp;
15878
+ const resp = generateVideosOperationFromVertex(apiResponse);
15879
+ const typedResp = new GenerateVideosOperation();
15880
+ Object.assign(typedResp, resp);
15881
+ return typedResp;
15580
15882
  });
15581
15883
  }
15582
15884
  else {
@@ -15599,8 +15901,10 @@ class Models extends BaseModule {
15599
15901
  return httpResponse.json();
15600
15902
  });
15601
15903
  return response.then((apiResponse) => {
15602
- const resp = generateVideosOperationFromMldev$1(apiResponse);
15603
- return resp;
15904
+ const resp = generateVideosOperationFromMldev(apiResponse);
15905
+ const typedResp = new GenerateVideosOperation();
15906
+ Object.assign(typedResp, resp);
15907
+ return typedResp;
15604
15908
  });
15605
15909
  }
15606
15910
  }
@@ -15658,164 +15962,6 @@ function fetchPredictOperationParametersToVertex(fromObject) {
15658
15962
  }
15659
15963
  return toObject;
15660
15964
  }
15661
- function videoFromMldev(fromObject) {
15662
- const toObject = {};
15663
- const fromUri = getValueByPath(fromObject, ['video', 'uri']);
15664
- if (fromUri != null) {
15665
- setValueByPath(toObject, ['uri'], fromUri);
15666
- }
15667
- const fromVideoBytes = getValueByPath(fromObject, [
15668
- 'video',
15669
- 'encodedVideo',
15670
- ]);
15671
- if (fromVideoBytes != null) {
15672
- setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
15673
- }
15674
- const fromMimeType = getValueByPath(fromObject, ['encoding']);
15675
- if (fromMimeType != null) {
15676
- setValueByPath(toObject, ['mimeType'], fromMimeType);
15677
- }
15678
- return toObject;
15679
- }
15680
- function generatedVideoFromMldev(fromObject) {
15681
- const toObject = {};
15682
- const fromVideo = getValueByPath(fromObject, ['_self']);
15683
- if (fromVideo != null) {
15684
- setValueByPath(toObject, ['video'], videoFromMldev(fromVideo));
15685
- }
15686
- return toObject;
15687
- }
15688
- function generateVideosResponseFromMldev(fromObject) {
15689
- const toObject = {};
15690
- const fromGeneratedVideos = getValueByPath(fromObject, [
15691
- 'generatedSamples',
15692
- ]);
15693
- if (fromGeneratedVideos != null) {
15694
- let transformedList = fromGeneratedVideos;
15695
- if (Array.isArray(transformedList)) {
15696
- transformedList = transformedList.map((item) => {
15697
- return generatedVideoFromMldev(item);
15698
- });
15699
- }
15700
- setValueByPath(toObject, ['generatedVideos'], transformedList);
15701
- }
15702
- const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
15703
- 'raiMediaFilteredCount',
15704
- ]);
15705
- if (fromRaiMediaFilteredCount != null) {
15706
- setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
15707
- }
15708
- const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
15709
- 'raiMediaFilteredReasons',
15710
- ]);
15711
- if (fromRaiMediaFilteredReasons != null) {
15712
- setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
15713
- }
15714
- return toObject;
15715
- }
15716
- function generateVideosOperationFromMldev(fromObject) {
15717
- const toObject = {};
15718
- const fromName = getValueByPath(fromObject, ['name']);
15719
- if (fromName != null) {
15720
- setValueByPath(toObject, ['name'], fromName);
15721
- }
15722
- const fromMetadata = getValueByPath(fromObject, ['metadata']);
15723
- if (fromMetadata != null) {
15724
- setValueByPath(toObject, ['metadata'], fromMetadata);
15725
- }
15726
- const fromDone = getValueByPath(fromObject, ['done']);
15727
- if (fromDone != null) {
15728
- setValueByPath(toObject, ['done'], fromDone);
15729
- }
15730
- const fromError = getValueByPath(fromObject, ['error']);
15731
- if (fromError != null) {
15732
- setValueByPath(toObject, ['error'], fromError);
15733
- }
15734
- const fromResponse = getValueByPath(fromObject, [
15735
- 'response',
15736
- 'generateVideoResponse',
15737
- ]);
15738
- if (fromResponse != null) {
15739
- setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(fromResponse));
15740
- }
15741
- return toObject;
15742
- }
15743
- function videoFromVertex(fromObject) {
15744
- const toObject = {};
15745
- const fromUri = getValueByPath(fromObject, ['gcsUri']);
15746
- if (fromUri != null) {
15747
- setValueByPath(toObject, ['uri'], fromUri);
15748
- }
15749
- const fromVideoBytes = getValueByPath(fromObject, [
15750
- 'bytesBase64Encoded',
15751
- ]);
15752
- if (fromVideoBytes != null) {
15753
- setValueByPath(toObject, ['videoBytes'], tBytes(fromVideoBytes));
15754
- }
15755
- const fromMimeType = getValueByPath(fromObject, ['mimeType']);
15756
- if (fromMimeType != null) {
15757
- setValueByPath(toObject, ['mimeType'], fromMimeType);
15758
- }
15759
- return toObject;
15760
- }
15761
- function generatedVideoFromVertex(fromObject) {
15762
- const toObject = {};
15763
- const fromVideo = getValueByPath(fromObject, ['_self']);
15764
- if (fromVideo != null) {
15765
- setValueByPath(toObject, ['video'], videoFromVertex(fromVideo));
15766
- }
15767
- return toObject;
15768
- }
15769
- function generateVideosResponseFromVertex(fromObject) {
15770
- const toObject = {};
15771
- const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
15772
- if (fromGeneratedVideos != null) {
15773
- let transformedList = fromGeneratedVideos;
15774
- if (Array.isArray(transformedList)) {
15775
- transformedList = transformedList.map((item) => {
15776
- return generatedVideoFromVertex(item);
15777
- });
15778
- }
15779
- setValueByPath(toObject, ['generatedVideos'], transformedList);
15780
- }
15781
- const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
15782
- 'raiMediaFilteredCount',
15783
- ]);
15784
- if (fromRaiMediaFilteredCount != null) {
15785
- setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
15786
- }
15787
- const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
15788
- 'raiMediaFilteredReasons',
15789
- ]);
15790
- if (fromRaiMediaFilteredReasons != null) {
15791
- setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
15792
- }
15793
- return toObject;
15794
- }
15795
- function generateVideosOperationFromVertex(fromObject) {
15796
- const toObject = {};
15797
- const fromName = getValueByPath(fromObject, ['name']);
15798
- if (fromName != null) {
15799
- setValueByPath(toObject, ['name'], fromName);
15800
- }
15801
- const fromMetadata = getValueByPath(fromObject, ['metadata']);
15802
- if (fromMetadata != null) {
15803
- setValueByPath(toObject, ['metadata'], fromMetadata);
15804
- }
15805
- const fromDone = getValueByPath(fromObject, ['done']);
15806
- if (fromDone != null) {
15807
- setValueByPath(toObject, ['done'], fromDone);
15808
- }
15809
- const fromError = getValueByPath(fromObject, ['error']);
15810
- if (fromError != null) {
15811
- setValueByPath(toObject, ['error'], fromError);
15812
- }
15813
- const fromResponse = getValueByPath(fromObject, ['response']);
15814
- if (fromResponse != null) {
15815
- setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(fromResponse));
15816
- }
15817
- return toObject;
15818
- }
15819
15965
 
15820
15966
  /**
15821
15967
  * @license
@@ -15845,17 +15991,64 @@ class Operations extends BaseModule {
15845
15991
  if (config && 'httpOptions' in config) {
15846
15992
  httpOptions = config.httpOptions;
15847
15993
  }
15848
- return this.fetchPredictVideosOperationInternal({
15994
+ const rawOperation = await this.fetchPredictVideosOperationInternal({
15849
15995
  operationName: operation.name,
15850
15996
  resourceName: resourceName,
15851
15997
  config: { httpOptions: httpOptions },
15852
15998
  });
15999
+ return operation._fromAPIResponse({
16000
+ apiResponse: rawOperation,
16001
+ isVertexAI: true,
16002
+ });
15853
16003
  }
15854
16004
  else {
15855
- return this.getVideosOperationInternal({
16005
+ const rawOperation = await this.getVideosOperationInternal({
15856
16006
  operationName: operation.name,
15857
16007
  config: config,
15858
16008
  });
16009
+ return operation._fromAPIResponse({
16010
+ apiResponse: rawOperation,
16011
+ isVertexAI: false,
16012
+ });
16013
+ }
16014
+ }
16015
+ /**
16016
+ * Gets the status of a long-running operation.
16017
+ *
16018
+ * @param parameters The parameters for the get operation request.
16019
+ * @return The updated Operation object, with the latest status or result.
16020
+ */
16021
+ async get(parameters) {
16022
+ const operation = parameters.operation;
16023
+ const config = parameters.config;
16024
+ if (operation.name === undefined || operation.name === '') {
16025
+ throw new Error('Operation name is required.');
16026
+ }
16027
+ if (this.apiClient.isVertexAI()) {
16028
+ const resourceName = operation.name.split('/operations/')[0];
16029
+ let httpOptions = undefined;
16030
+ if (config && 'httpOptions' in config) {
16031
+ httpOptions = config.httpOptions;
16032
+ }
16033
+ const rawOperation = await this.fetchPredictVideosOperationInternal({
16034
+ operationName: operation.name,
16035
+ resourceName: resourceName,
16036
+ config: { httpOptions: httpOptions },
16037
+ });
16038
+ return operation._fromAPIResponse({
16039
+ apiResponse: rawOperation,
16040
+ isVertexAI: true,
16041
+ });
16042
+ }
16043
+ else {
16044
+ const rawOperation = await this.getVideosOperationInternal({
16045
+ operationName: operation.name,
16046
+ config: config,
16047
+ });
16048
+ return operation._fromAPIResponse({
16049
+ apiResponse: rawOperation,
16050
+ isVertexAI: false,
16051
+ });
15859
16052
  }
15860
16053
  }
15861
16054
  async getVideosOperationInternal(params) {
@@ -15882,10 +16075,7 @@ class Operations extends BaseModule {
15882
16075
  .then((httpResponse) => {
15883
16076
  return httpResponse.json();
15884
16077
  });
15885
- return response.then((apiResponse) => {
15886
- const resp = generateVideosOperationFromVertex(apiResponse);
15887
- return resp;
15888
- });
16078
+ return response;
15889
16079
  }
15890
16080
  else {
15891
16081
  const body = getOperationParametersToMldev(params);
@@ -15906,10 +16096,7 @@ class Operations extends BaseModule {
15906
16096
  .then((httpResponse) => {
15907
16097
  return httpResponse.json();
15908
16098
  });
15909
- return response.then((apiResponse) => {
15910
- const resp = generateVideosOperationFromMldev(apiResponse);
15911
- return resp;
15912
- });
16099
+ return response;
15913
16100
  }
15914
16101
  }
15915
16102
  async fetchPredictVideosOperationInternal(params) {
@@ -15936,10 +16123,7 @@ class Operations extends BaseModule {
15936
16123
  .then((httpResponse) => {
15937
16124
  return httpResponse.json();
15938
16125
  });
15939
- return response.then((apiResponse) => {
15940
- const resp = generateVideosOperationFromVertex(apiResponse);
15941
- return resp;
15942
- });
16126
+ return response;
15943
16127
  }
15944
16128
  else {
15945
16129
  throw new Error('This method is only supported by the Vertex AI.');
@@ -17082,6 +17266,12 @@ function tunedModelFromMldev(fromObject) {
17082
17266
  }
17083
17267
  function tuningJobFromMldev(fromObject) {
17084
17268
  const toObject = {};
17269
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
17270
+ 'sdkHttpResponse',
17271
+ ]);
17272
+ if (fromSdkHttpResponse != null) {
17273
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
17274
+ }
17085
17275
  const fromName = getValueByPath(fromObject, ['name']);
17086
17276
  if (fromName != null) {
17087
17277
  setValueByPath(toObject, ['name'], fromName);
@@ -17166,6 +17356,12 @@ function tuningJobFromMldev(fromObject) {
17166
17356
  }
17167
17357
  function listTuningJobsResponseFromMldev(fromObject) {
17168
17358
  const toObject = {};
17359
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
17360
+ 'sdkHttpResponse',
17361
+ ]);
17362
+ if (fromSdkHttpResponse != null) {
17363
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
17364
+ }
17169
17365
  const fromNextPageToken = getValueByPath(fromObject, [
17170
17366
  'nextPageToken',
17171
17367
  ]);
@@ -17186,6 +17382,12 @@ function listTuningJobsResponseFromMldev(fromObject) {
17186
17382
  }
17187
17383
  function tuningOperationFromMldev(fromObject) {
17188
17384
  const toObject = {};
17385
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
17386
+ 'sdkHttpResponse',
17387
+ ]);
17388
+ if (fromSdkHttpResponse != null) {
17389
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
17390
+ }
17189
17391
  const fromName = getValueByPath(fromObject, ['name']);
17190
17392
  if (fromName != null) {
17191
17393
  setValueByPath(toObject, ['name'], fromName);
@@ -17248,6 +17450,12 @@ function tunedModelFromVertex(fromObject) {
17248
17450
  }
17249
17451
  function tuningJobFromVertex(fromObject) {
17250
17452
  const toObject = {};
17453
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
17454
+ 'sdkHttpResponse',
17455
+ ]);
17456
+ if (fromSdkHttpResponse != null) {
17457
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
17458
+ }
17251
17459
  const fromName = getValueByPath(fromObject, ['name']);
17252
17460
  if (fromName != null) {
17253
17461
  setValueByPath(toObject, ['name'], fromName);
@@ -17354,6 +17562,12 @@ function tuningJobFromVertex(fromObject) {
17354
17562
  }
17355
17563
  function listTuningJobsResponseFromVertex(fromObject) {
17356
17564
  const toObject = {};
17565
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
17566
+ 'sdkHttpResponse',
17567
+ ]);
17568
+ if (fromSdkHttpResponse != null) {
17569
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
17570
+ }
17357
17571
  const fromNextPageToken = getValueByPath(fromObject, [
17358
17572
  'nextPageToken',
17359
17573
  ]);
@@ -17460,7 +17674,13 @@ class Tunings extends BaseModule {
17460
17674
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
17461
17675
  })
17462
17676
  .then((httpResponse) => {
17463
- return httpResponse.json();
17677
+ return httpResponse.json().then((jsonResponse) => {
17678
+ const response = jsonResponse;
17679
+ response.sdkHttpResponse = {
17680
+ headers: httpResponse.headers,
17681
+ };
17682
+ return response;
17683
+ });
17464
17684
  });
17465
17685
  return response.then((apiResponse) => {
17466
17686
  const resp = tuningJobFromVertex(apiResponse);
@@ -17484,7 +17704,13 @@ class Tunings extends BaseModule {
17484
17704
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
17485
17705
  })
17486
17706
  .then((httpResponse) => {
17487
- return httpResponse.json();
17707
+ return httpResponse.json().then((jsonResponse) => {
17708
+ const response = jsonResponse;
17709
+ response.sdkHttpResponse = {
17710
+ headers: httpResponse.headers,
17711
+ };
17712
+ return response;
17713
+ });
17488
17714
  });
17489
17715
  return response.then((apiResponse) => {
17490
17716
  const resp = tuningJobFromMldev(apiResponse);
@@ -17514,7 +17740,13 @@ class Tunings extends BaseModule {
17514
17740
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
17515
17741
  })
17516
17742
  .then((httpResponse) => {
17517
- return httpResponse.json();
17743
+ return httpResponse.json().then((jsonResponse) => {
17744
+ const response = jsonResponse;
17745
+ response.sdkHttpResponse = {
17746
+ headers: httpResponse.headers,
17747
+ };
17748
+ return response;
17749
+ });
17518
17750
  });
17519
17751
  return response.then((apiResponse) => {
17520
17752
  const resp = listTuningJobsResponseFromVertex(apiResponse);
@@ -17540,7 +17772,13 @@ class Tunings extends BaseModule {
17540
17772
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
17541
17773
  })
17542
17774
  .then((httpResponse) => {
17543
- return httpResponse.json();
17775
+ return httpResponse.json().then((jsonResponse) => {
17776
+ const response = jsonResponse;
17777
+ response.sdkHttpResponse = {
17778
+ headers: httpResponse.headers,
17779
+ };
17780
+ return response;
17781
+ });
17544
17782
  });
17545
17783
  return response.then((apiResponse) => {
17546
17784
  const resp = listTuningJobsResponseFromMldev(apiResponse);
@@ -17572,7 +17810,13 @@ class Tunings extends BaseModule {
17572
17810
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
17573
17811
  })
17574
17812
  .then((httpResponse) => {
17575
- return httpResponse.json();
17813
+ return httpResponse.json().then((jsonResponse) => {
17814
+ const response = jsonResponse;
17815
+ response.sdkHttpResponse = {
17816
+ headers: httpResponse.headers,
17817
+ };
17818
+ return response;
17819
+ });
17576
17820
  });
17577
17821
  return response.then((apiResponse) => {
17578
17822
  const resp = tuningJobFromVertex(apiResponse);
@@ -17608,7 +17852,13 @@ class Tunings extends BaseModule {
17608
17852
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
17609
17853
  })
17610
17854
  .then((httpResponse) => {
17611
- return httpResponse.json();
17855
+ return httpResponse.json().then((jsonResponse) => {
17856
+ const response = jsonResponse;
17857
+ response.sdkHttpResponse = {
17858
+ headers: httpResponse.headers,
17859
+ };
17860
+ return response;
17861
+ });
17612
17862
  });
17613
17863
  return response.then((apiResponse) => {
17614
17864
  const resp = tuningOperationFromMldev(apiResponse);
@@ -17713,5 +17963,5 @@ class GoogleGenAI {
17713
17963
  }
17714
17964
  }
17715
17965
 
17716
- export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
17966
+ export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
17717
17967
  //# sourceMappingURL=index.mjs.map