@ai-sdk/google-vertex 4.0.231 → 4.0.233

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @ai-sdk/google-vertex
2
2
 
3
+ ## 4.0.233
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [271ca50]
8
+ - @ai-sdk/google@3.0.146
9
+
10
+ ## 4.0.232
11
+
12
+ ### Patch Changes
13
+
14
+ - 3ea9b26: Reject invalid Cloud Speech transcription regions and default locations before resolving credentials or sending requests, preventing URL delimiters from redirecting bearer tokens and audio to another host.
15
+
3
16
  ## 4.0.231
4
17
 
5
18
  ### Patch Changes
@@ -32,7 +32,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
32
32
  var import_provider_utils = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "4.0.231" : "0.0.0-test";
35
+ var VERSION = true ? "4.0.233" : "0.0.0-test";
36
36
 
37
37
  // src/edge/google-vertex-auth-edge.ts
38
38
  var loadCredentials = async () => {
@@ -10,7 +10,7 @@ import {
10
10
  } from "@ai-sdk/provider-utils";
11
11
 
12
12
  // src/version.ts
13
- var VERSION = true ? "4.0.231" : "0.0.0-test";
13
+ var VERSION = true ? "4.0.233" : "0.0.0-test";
14
14
 
15
15
  // src/edge/google-vertex-auth-edge.ts
16
16
  var loadCredentials = async () => {
@@ -33,7 +33,7 @@ var import_internal3 = require("@ai-sdk/google/internal");
33
33
  var import_provider_utils10 = require("@ai-sdk/provider-utils");
34
34
 
35
35
  // src/version.ts
36
- var VERSION = true ? "4.0.231" : "0.0.0-test";
36
+ var VERSION = true ? "4.0.233" : "0.0.0-test";
37
37
 
38
38
  // src/google-vertex-embedding-model.ts
39
39
  var import_provider = require("@ai-sdk/provider");
@@ -622,6 +622,7 @@ var googleVertexTools = {
622
622
  };
623
623
 
624
624
  // src/google-vertex-transcription-model.ts
625
+ var import_provider2 = require("@ai-sdk/provider");
625
626
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
626
627
  var import_v46 = require("zod/v4");
627
628
 
@@ -651,7 +652,8 @@ var googleVertexTranscriptionProviderOptionsSchema = (0, import_provider_utils5.
651
652
  enableWordTimeOffsets: import_v45.z.boolean().optional(),
652
653
  /**
653
654
  * The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
654
- * `'us-central1'`). Defaults to the provider `location`.
655
+ * `'us-central1'`). Defaults to the provider `location`. Must be a single
656
+ * DNS label (letters, digits, and hyphens).
655
657
  *
656
658
  * Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
657
659
  * available in specific Speech-to-Text regions and is not available in the
@@ -691,7 +693,7 @@ var GoogleVertexTranscriptionModel = class {
691
693
  return this.config.provider;
692
694
  }
693
695
  async doGenerate(options) {
694
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
696
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
695
697
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
696
698
  const warnings = [];
697
699
  let googleOptions;
@@ -706,7 +708,13 @@ var GoogleVertexTranscriptionModel = class {
706
708
  }
707
709
  }
708
710
  const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
709
- const languageCodes = (_e = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _e : ["auto"];
711
+ if (((_e = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.exec(region)) == null ? void 0 : _e[0]) !== region) {
712
+ throw new import_provider2.InvalidArgumentError({
713
+ argument: (googleOptions == null ? void 0 : googleOptions.region) != null ? "region" : "location",
714
+ message: "Invalid Google Cloud Speech-to-Text region. Expected a single DNS label (letters, digits, and hyphens)."
715
+ });
716
+ }
717
+ const languageCodes = (_f = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _f : ["auto"];
710
718
  const content = typeof options.audio === "string" ? options.audio : (0, import_provider_utils6.convertUint8ArrayToBase64)(options.audio);
711
719
  const requestBody = {
712
720
  config: {
@@ -716,14 +724,20 @@ var GoogleVertexTranscriptionModel = class {
716
724
  autoDecodingConfig: {},
717
725
  features: {
718
726
  // Word timing populates `segments`.
719
- enableWordTimeOffsets: (_f = googleOptions == null ? void 0 : googleOptions.enableWordTimeOffsets) != null ? _f : true,
720
- enableAutomaticPunctuation: (_g = googleOptions == null ? void 0 : googleOptions.enableAutomaticPunctuation) != null ? _g : true
727
+ enableWordTimeOffsets: (_g = googleOptions == null ? void 0 : googleOptions.enableWordTimeOffsets) != null ? _g : true,
728
+ enableAutomaticPunctuation: (_h = googleOptions == null ? void 0 : googleOptions.enableAutomaticPunctuation) != null ? _h : true
721
729
  }
722
730
  },
723
731
  content
724
732
  };
725
733
  const host = region === "global" ? "speech.googleapis.com" : `${region}-speech.googleapis.com`;
726
734
  const url = `https://${host}/v2/projects/${this.config.project}/locations/${region}/recognizers/_:recognize`;
735
+ if (new URL(url).origin !== `https://${host.toLowerCase()}`) {
736
+ throw new import_provider2.InvalidArgumentError({
737
+ argument: (googleOptions == null ? void 0 : googleOptions.region) != null ? "region" : "location",
738
+ message: "Invalid Google Cloud Speech-to-Text endpoint origin."
739
+ });
740
+ }
727
741
  const {
728
742
  value: response,
729
743
  responseHeaders,
@@ -742,7 +756,7 @@ var GoogleVertexTranscriptionModel = class {
742
756
  abortSignal: options.abortSignal,
743
757
  fetch: this.config.fetch
744
758
  });
745
- const results = (_h = response.results) != null ? _h : [];
759
+ const results = (_i = response.results) != null ? _i : [];
746
760
  const text = results.map((result) => {
747
761
  var _a2, _b2, _c2;
748
762
  return (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.transcript) != null ? _c2 : "";
@@ -757,13 +771,13 @@ var GoogleVertexTranscriptionModel = class {
757
771
  })) != null ? _d2 : [];
758
772
  }
759
773
  );
760
- const language = convertBcp47ToIso6391((_i = results[0]) == null ? void 0 : _i.languageCode);
774
+ const language = convertBcp47ToIso6391((_j = results[0]) == null ? void 0 : _j.languageCode);
761
775
  return {
762
776
  text,
763
777
  segments,
764
778
  language,
765
779
  durationInSeconds: parseDurationSeconds(
766
- (_j = response.metadata) == null ? void 0 : _j.totalBilledDuration
780
+ (_k = response.metadata) == null ? void 0 : _k.totalBilledDuration
767
781
  ),
768
782
  warnings,
769
783
  response: {
@@ -803,7 +817,7 @@ var googleVertexTranscriptionResponseSchema = (0, import_provider_utils6.lazySch
803
817
  );
804
818
 
805
819
  // src/gemini-transcription/google-vertex-gemini-transcription-model.ts
806
- var import_provider2 = require("@ai-sdk/provider");
820
+ var import_provider3 = require("@ai-sdk/provider");
807
821
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
808
822
  var import_v48 = require("zod/v4");
809
823
 
@@ -872,7 +886,7 @@ var GoogleVertexGeminiTranscriptionModel = class {
872
886
  async doGenerate(options) {
873
887
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
874
888
  if (isLiveTranscriptionModelId(this.modelId)) {
875
- throw new import_provider2.InvalidArgumentError({
889
+ throw new import_provider3.InvalidArgumentError({
876
890
  argument: "modelId",
877
891
  message: `Model '${this.modelId}' only supports streaming transcription, which requires AI SDK v7. Use a unary model such as 'gemini-3.5-transcribe'.`
878
892
  });
@@ -1016,7 +1030,7 @@ var googleVertexGeminiTranscriptionResponseSchema = (0, import_provider_utils8.l
1016
1030
  );
1017
1031
 
1018
1032
  // src/google-vertex-video-model.ts
1019
- var import_provider3 = require("@ai-sdk/provider");
1033
+ var import_provider4 = require("@ai-sdk/provider");
1020
1034
  var import_provider_utils9 = require("@ai-sdk/provider-utils");
1021
1035
  var import_v49 = require("zod/v4");
1022
1036
  function getFirstFrameImage(options) {
@@ -1179,7 +1193,7 @@ var GoogleVertexVideoModel = class {
1179
1193
  });
1180
1194
  const operationName = operation.name;
1181
1195
  if (!operationName) {
1182
- throw new import_provider3.AISDKError({
1196
+ throw new import_provider4.AISDKError({
1183
1197
  name: "VERTEX_VIDEO_GENERATION_ERROR",
1184
1198
  message: "No operation name returned from API"
1185
1199
  });
@@ -1191,14 +1205,14 @@ var GoogleVertexVideoModel = class {
1191
1205
  let responseHeaders;
1192
1206
  while (!finalOperation.done) {
1193
1207
  if (Date.now() - startTime > pollTimeoutMs) {
1194
- throw new import_provider3.AISDKError({
1208
+ throw new import_provider4.AISDKError({
1195
1209
  name: "VERTEX_VIDEO_GENERATION_TIMEOUT",
1196
1210
  message: `Video generation timed out after ${pollTimeoutMs}ms`
1197
1211
  });
1198
1212
  }
1199
1213
  await (0, import_provider_utils9.delay)(pollIntervalMs);
1200
1214
  if ((_g = options.abortSignal) == null ? void 0 : _g.aborted) {
1201
- throw new import_provider3.AISDKError({
1215
+ throw new import_provider4.AISDKError({
1202
1216
  name: "VERTEX_VIDEO_GENERATION_ABORTED",
1203
1217
  message: "Video generation request was aborted"
1204
1218
  });
@@ -1223,14 +1237,14 @@ var GoogleVertexVideoModel = class {
1223
1237
  responseHeaders = pollHeaders;
1224
1238
  }
1225
1239
  if (finalOperation.error) {
1226
- throw new import_provider3.AISDKError({
1240
+ throw new import_provider4.AISDKError({
1227
1241
  name: "VERTEX_VIDEO_GENERATION_FAILED",
1228
1242
  message: `Video generation failed: ${finalOperation.error.message}`
1229
1243
  });
1230
1244
  }
1231
1245
  const response = finalOperation.response;
1232
1246
  if (!(response == null ? void 0 : response.videos) || response.videos.length === 0) {
1233
- throw new import_provider3.AISDKError({
1247
+ throw new import_provider4.AISDKError({
1234
1248
  name: "VERTEX_VIDEO_GENERATION_ERROR",
1235
1249
  message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
1236
1250
  });
@@ -1260,7 +1274,7 @@ var GoogleVertexVideoModel = class {
1260
1274
  }
1261
1275
  }
1262
1276
  if (videos.length === 0) {
1263
- throw new import_provider3.AISDKError({
1277
+ throw new import_provider4.AISDKError({
1264
1278
  name: "VERTEX_VIDEO_GENERATION_ERROR",
1265
1279
  message: "No valid videos in response"
1266
1280
  });