@ai-sdk/google 3.0.23 → 3.0.25

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.
@@ -385,7 +385,7 @@ var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResp
385
385
  // src/google-generative-ai-options.ts
386
386
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
387
387
  var import_v42 = require("zod/v4");
388
- var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
388
+ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
389
389
  () => (0, import_provider_utils3.zodSchema)(
390
390
  import_v42.z.object({
391
391
  responseModalities: import_v42.z.array(import_v42.z.enum(["TEXT", "IMAGE"])).optional(),
@@ -767,13 +767,13 @@ var GoogleGenerativeAILanguageModel = class {
767
767
  let googleOptions = await (0, import_provider_utils4.parseProviderOptions)({
768
768
  provider: providerOptionsName,
769
769
  providerOptions,
770
- schema: googleGenerativeAIProviderOptions
770
+ schema: googleLanguageModelOptions
771
771
  });
772
772
  if (googleOptions == null && providerOptionsName !== "google") {
773
773
  googleOptions = await (0, import_provider_utils4.parseProviderOptions)({
774
774
  provider: "google",
775
775
  providerOptions,
776
- schema: googleGenerativeAIProviderOptions
776
+ schema: googleLanguageModelOptions
777
777
  });
778
778
  }
779
779
  if ((tools == null ? void 0 : tools.some(
@@ -894,16 +894,24 @@ var GoogleGenerativeAILanguageModel = class {
894
894
  }
895
895
  });
896
896
  lastCodeExecutionToolCallId = void 0;
897
- } else if ("text" in part && part.text != null && part.text.length > 0) {
898
- content.push({
899
- type: part.thought === true ? "reasoning" : "text",
900
- text: part.text,
901
- providerMetadata: part.thoughtSignature ? {
902
- [providerOptionsName]: {
903
- thoughtSignature: part.thoughtSignature
904
- }
905
- } : void 0
906
- });
897
+ } else if ("text" in part && part.text != null) {
898
+ const thoughtSignatureMetadata = part.thoughtSignature ? {
899
+ [providerOptionsName]: {
900
+ thoughtSignature: part.thoughtSignature
901
+ }
902
+ } : void 0;
903
+ if (part.text.length === 0) {
904
+ if (thoughtSignatureMetadata != null && content.length > 0) {
905
+ const lastContent = content[content.length - 1];
906
+ lastContent.providerMetadata = thoughtSignatureMetadata;
907
+ }
908
+ } else {
909
+ content.push({
910
+ type: part.thought === true ? "reasoning" : "text",
911
+ text: part.text,
912
+ providerMetadata: thoughtSignatureMetadata
913
+ });
914
+ }
907
915
  } else if ("functionCall" in part) {
908
916
  content.push({
909
917
  type: "tool-call",
@@ -1061,8 +1069,22 @@ var GoogleGenerativeAILanguageModel = class {
1061
1069
  });
1062
1070
  lastCodeExecutionToolCallId = void 0;
1063
1071
  }
1064
- } else if ("text" in part && part.text != null && part.text.length > 0) {
1065
- if (part.thought === true) {
1072
+ } else if ("text" in part && part.text != null) {
1073
+ const thoughtSignatureMetadata = part.thoughtSignature ? {
1074
+ [providerOptionsName]: {
1075
+ thoughtSignature: part.thoughtSignature
1076
+ }
1077
+ } : void 0;
1078
+ if (part.text.length === 0) {
1079
+ if (thoughtSignatureMetadata != null && currentTextBlockId !== null) {
1080
+ controller.enqueue({
1081
+ type: "text-delta",
1082
+ id: currentTextBlockId,
1083
+ delta: "",
1084
+ providerMetadata: thoughtSignatureMetadata
1085
+ });
1086
+ }
1087
+ } else if (part.thought === true) {
1066
1088
  if (currentTextBlockId !== null) {
1067
1089
  controller.enqueue({
1068
1090
  type: "text-end",
@@ -1075,22 +1097,14 @@ var GoogleGenerativeAILanguageModel = class {
1075
1097
  controller.enqueue({
1076
1098
  type: "reasoning-start",
1077
1099
  id: currentReasoningBlockId,
1078
- providerMetadata: part.thoughtSignature ? {
1079
- [providerOptionsName]: {
1080
- thoughtSignature: part.thoughtSignature
1081
- }
1082
- } : void 0
1100
+ providerMetadata: thoughtSignatureMetadata
1083
1101
  });
1084
1102
  }
1085
1103
  controller.enqueue({
1086
1104
  type: "reasoning-delta",
1087
1105
  id: currentReasoningBlockId,
1088
1106
  delta: part.text,
1089
- providerMetadata: part.thoughtSignature ? {
1090
- [providerOptionsName]: {
1091
- thoughtSignature: part.thoughtSignature
1092
- }
1093
- } : void 0
1107
+ providerMetadata: thoughtSignatureMetadata
1094
1108
  });
1095
1109
  } else {
1096
1110
  if (currentReasoningBlockId !== null) {
@@ -1105,22 +1119,14 @@ var GoogleGenerativeAILanguageModel = class {
1105
1119
  controller.enqueue({
1106
1120
  type: "text-start",
1107
1121
  id: currentTextBlockId,
1108
- providerMetadata: part.thoughtSignature ? {
1109
- [providerOptionsName]: {
1110
- thoughtSignature: part.thoughtSignature
1111
- }
1112
- } : void 0
1122
+ providerMetadata: thoughtSignatureMetadata
1113
1123
  });
1114
1124
  }
1115
1125
  controller.enqueue({
1116
1126
  type: "text-delta",
1117
1127
  id: currentTextBlockId,
1118
1128
  delta: part.text,
1119
- providerMetadata: part.thoughtSignature ? {
1120
- [providerOptionsName]: {
1121
- thoughtSignature: part.thoughtSignature
1122
- }
1123
- } : void 0
1129
+ providerMetadata: thoughtSignatureMetadata
1124
1130
  });
1125
1131
  }
1126
1132
  } else if ("inlineData" in part) {