@ai-sdk/google 4.0.0-beta.37 → 4.0.0-beta.38

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,23 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.0-beta.38
4
+
5
+ ### Patch Changes
6
+
7
+ - b3976a2: Add workflow serialization support to all provider models.
8
+
9
+ **`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
10
+
11
+ **All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
12
+
13
+ All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
14
+
15
+ - ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
16
+ - Updated dependencies [b3976a2]
17
+ - Updated dependencies [ff5eba1]
18
+ - @ai-sdk/provider-utils@5.0.0-beta.20
19
+ - @ai-sdk/provider@4.0.0-beta.12
20
+
3
21
  ## 4.0.0-beta.37
4
22
 
5
23
  ### Major Changes
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from "@ai-sdk/provider-utils";
8
8
 
9
9
  // src/version.ts
10
- var VERSION = true ? "4.0.0-beta.37" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.0-beta.38" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -20,6 +20,9 @@ import {
20
20
  parseProviderOptions,
21
21
  postJsonToApi,
22
22
  resolve,
23
+ serializeModelOptions,
24
+ WORKFLOW_SERIALIZE,
25
+ WORKFLOW_DESERIALIZE,
23
26
  zodSchema as zodSchema3
24
27
  } from "@ai-sdk/provider-utils";
25
28
  import { z as z3 } from "zod/v4";
@@ -107,7 +110,7 @@ var googleEmbeddingModelOptions = lazySchema2(
107
110
  );
108
111
 
109
112
  // src/google-generative-ai-embedding-model.ts
110
- var GoogleGenerativeAIEmbeddingModel = class {
113
+ var GoogleGenerativeAIEmbeddingModel = class _GoogleGenerativeAIEmbeddingModel {
111
114
  constructor(modelId, config) {
112
115
  this.specificationVersion = "v4";
113
116
  this.maxEmbeddingsPerCall = 2048;
@@ -115,6 +118,18 @@ var GoogleGenerativeAIEmbeddingModel = class {
115
118
  this.modelId = modelId;
116
119
  this.config = config;
117
120
  }
121
+ static [WORKFLOW_SERIALIZE](model) {
122
+ return serializeModelOptions({
123
+ modelId: model.modelId,
124
+ config: model.config
125
+ });
126
+ }
127
+ static [WORKFLOW_DESERIALIZE](options) {
128
+ return new _GoogleGenerativeAIEmbeddingModel(
129
+ options.modelId,
130
+ options.config
131
+ );
132
+ }
118
133
  get provider() {
119
134
  return this.config.provider;
120
135
  }
@@ -138,7 +153,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
138
153
  });
139
154
  }
140
155
  const mergedHeaders = combineHeaders(
141
- await resolve(this.config.headers),
156
+ this.config.headers ? await resolve(this.config.headers) : void 0,
142
157
  headers
143
158
  );
144
159
  const multimodalContent = googleOptions == null ? void 0 : googleOptions.content;
@@ -245,6 +260,9 @@ import {
245
260
  parseProviderOptions as parseProviderOptions2,
246
261
  postJsonToApi as postJsonToApi2,
247
262
  resolve as resolve2,
263
+ serializeModelOptions as serializeModelOptions2,
264
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
265
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2,
248
266
  zodSchema as zodSchema5
249
267
  } from "@ai-sdk/provider-utils";
250
268
  import { z as z5 } from "zod/v4";
@@ -445,7 +463,6 @@ function appendToolResultParts(parts, toolName, outputValue) {
445
463
  responseTextParts.push(contentPart.text);
446
464
  break;
447
465
  }
448
- case "image-data":
449
466
  case "file-data": {
450
467
  functionResponseParts.push({
451
468
  inlineData: {
@@ -455,7 +472,6 @@ function appendToolResultParts(parts, toolName, outputValue) {
455
472
  });
456
473
  break;
457
474
  }
458
- case "image-url":
459
475
  case "file-url": {
460
476
  const functionResponsePart = convertUrlToolResultPart(
461
477
  contentPart.url
@@ -498,18 +514,22 @@ function appendLegacyToolResultParts(parts, toolName, outputValue) {
498
514
  }
499
515
  });
500
516
  break;
501
- case "image-data":
502
- parts.push(
503
- {
504
- inlineData: {
505
- mimeType: String(contentPart.mediaType),
506
- data: String(contentPart.data)
517
+ case "file-data":
518
+ if (contentPart.mediaType.startsWith("image/")) {
519
+ parts.push(
520
+ {
521
+ inlineData: {
522
+ mimeType: contentPart.mediaType,
523
+ data: contentPart.data
524
+ }
525
+ },
526
+ {
527
+ text: "Tool executed successfully and returned this image as a response"
507
528
  }
508
- },
509
- {
510
- text: "Tool executed successfully and returned this image as a response"
511
- }
512
- );
529
+ );
530
+ } else {
531
+ parts.push({ text: JSON.stringify(contentPart) });
532
+ }
513
533
  break;
514
534
  default:
515
535
  parts.push({ text: JSON.stringify(contentPart) });
@@ -1408,7 +1428,7 @@ function mapGoogleGenerativeAIFinishReason({
1408
1428
  }
1409
1429
 
1410
1430
  // src/google-generative-ai-language-model.ts
1411
- var GoogleGenerativeAILanguageModel = class {
1431
+ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
1412
1432
  constructor(modelId, config) {
1413
1433
  this.specificationVersion = "v4";
1414
1434
  var _a;
@@ -1416,6 +1436,15 @@ var GoogleGenerativeAILanguageModel = class {
1416
1436
  this.config = config;
1417
1437
  this.generateId = (_a = config.generateId) != null ? _a : generateId;
1418
1438
  }
1439
+ static [WORKFLOW_SERIALIZE2](model) {
1440
+ return serializeModelOptions2({
1441
+ modelId: model.modelId,
1442
+ config: model.config
1443
+ });
1444
+ }
1445
+ static [WORKFLOW_DESERIALIZE2](options) {
1446
+ return new _GoogleGenerativeAILanguageModel(options.modelId, options.config);
1447
+ }
1419
1448
  get provider() {
1420
1449
  return this.config.provider;
1421
1450
  }
@@ -1559,7 +1588,7 @@ var GoogleGenerativeAILanguageModel = class {
1559
1588
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1560
1589
  const { args, warnings, providerOptionsName } = await this.getArgs(options);
1561
1590
  const mergedHeaders = combineHeaders2(
1562
- await resolve2(this.config.headers),
1591
+ this.config.headers ? await resolve2(this.config.headers) : void 0,
1563
1592
  options.headers
1564
1593
  );
1565
1594
  const {
@@ -1741,7 +1770,7 @@ var GoogleGenerativeAILanguageModel = class {
1741
1770
  { isStreaming: true }
1742
1771
  );
1743
1772
  const headers = combineHeaders2(
1744
- await resolve2(this.config.headers),
1773
+ this.config.headers ? await resolve2(this.config.headers) : void 0,
1745
1774
  options.headers
1746
1775
  );
1747
1776
  const { responseHeaders, value: response } = await postJsonToApi2({
@@ -2671,16 +2700,32 @@ import {
2671
2700
  parseProviderOptions as parseProviderOptions3,
2672
2701
  postJsonToApi as postJsonToApi3,
2673
2702
  resolve as resolve3,
2703
+ serializeModelOptions as serializeModelOptions3,
2704
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
2705
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3,
2674
2706
  zodSchema as zodSchema11
2675
2707
  } from "@ai-sdk/provider-utils";
2676
2708
  import { z as z13 } from "zod/v4";
2677
- var GoogleGenerativeAIImageModel = class {
2709
+ var GoogleGenerativeAIImageModel = class _GoogleGenerativeAIImageModel {
2678
2710
  constructor(modelId, settings, config) {
2679
2711
  this.modelId = modelId;
2680
2712
  this.settings = settings;
2681
2713
  this.config = config;
2682
2714
  this.specificationVersion = "v4";
2683
2715
  }
2716
+ static [WORKFLOW_SERIALIZE3](model) {
2717
+ return serializeModelOptions3({
2718
+ modelId: model.modelId,
2719
+ config: model.config
2720
+ });
2721
+ }
2722
+ static [WORKFLOW_DESERIALIZE3](options) {
2723
+ return new _GoogleGenerativeAIImageModel(
2724
+ options.modelId,
2725
+ {},
2726
+ options.config
2727
+ );
2728
+ }
2684
2729
  get maxImagesPerCall() {
2685
2730
  if (this.settings.maxImagesPerCall != null) {
2686
2731
  return this.settings.maxImagesPerCall;
@@ -2759,7 +2804,10 @@ var GoogleGenerativeAIImageModel = class {
2759
2804
  };
2760
2805
  const { responseHeaders, value: response } = await postJsonToApi3({
2761
2806
  url: `${this.config.baseURL}/models/${this.modelId}:predict`,
2762
- headers: combineHeaders3(await resolve3(this.config.headers), headers),
2807
+ headers: combineHeaders3(
2808
+ this.config.headers ? await resolve3(this.config.headers) : void 0,
2809
+ headers
2810
+ ),
2763
2811
  body,
2764
2812
  failedResponseHandler: googleFailedResponseHandler,
2765
2813
  successfulResponseHandler: createJsonResponseHandler3(