@ai-sdk/google 2.0.58 → 2.0.60

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.
@@ -60,11 +60,11 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
60
60
  }, z.core.$strip>>>;
61
61
  }, z.core.$strip>>>>;
62
62
  groundingSupports: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
63
- segment: z.ZodObject<{
63
+ segment: z.ZodOptional<z.ZodNullable<z.ZodObject<{
64
64
  startIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
65
65
  endIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
66
66
  text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
67
- }, z.core.$strip>;
67
+ }, z.core.$strip>>>;
68
68
  segment_text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
69
69
  groundingChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
70
70
  supportChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
@@ -150,11 +150,11 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
150
150
  } | null | undefined;
151
151
  }[] | null | undefined;
152
152
  groundingSupports?: {
153
- segment: {
153
+ segment?: {
154
154
  startIndex?: number | null | undefined;
155
155
  endIndex?: number | null | undefined;
156
156
  text?: string | null | undefined;
157
- };
157
+ } | null | undefined;
158
158
  segment_text?: string | null | undefined;
159
159
  groundingChunkIndices?: number[] | null | undefined;
160
160
  supportChunkIndices?: number[] | null | undefined;
@@ -60,11 +60,11 @@ declare const getGroundingMetadataSchema: () => z.ZodObject<{
60
60
  }, z.core.$strip>>>;
61
61
  }, z.core.$strip>>>>;
62
62
  groundingSupports: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
63
- segment: z.ZodObject<{
63
+ segment: z.ZodOptional<z.ZodNullable<z.ZodObject<{
64
64
  startIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
65
65
  endIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
66
66
  text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
67
- }, z.core.$strip>;
67
+ }, z.core.$strip>>>;
68
68
  segment_text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
69
69
  groundingChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
70
70
  supportChunkIndices: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
@@ -150,11 +150,11 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
150
150
  } | null | undefined;
151
151
  }[] | null | undefined;
152
152
  groundingSupports?: {
153
- segment: {
153
+ segment?: {
154
154
  startIndex?: number | null | undefined;
155
155
  endIndex?: number | null | undefined;
156
156
  text?: string | null | undefined;
157
- };
157
+ } | null | undefined;
158
158
  segment_text?: string | null | undefined;
159
159
  groundingChunkIndices?: number[] | null | undefined;
160
160
  supportChunkIndices?: number[] | null | undefined;
@@ -941,6 +941,8 @@ var GoogleGenerativeAILanguageModel = class {
941
941
  totalTokens: void 0
942
942
  };
943
943
  let providerMetadata = void 0;
944
+ let lastGroundingMetadata = null;
945
+ let lastUrlContextMetadata = null;
944
946
  const generateId2 = this.config.generateId;
945
947
  let hasToolCalls = false;
946
948
  let currentTextBlockId = null;
@@ -955,7 +957,7 @@ var GoogleGenerativeAILanguageModel = class {
955
957
  controller.enqueue({ type: "stream-start", warnings });
956
958
  },
957
959
  transform(chunk, controller) {
958
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
960
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
959
961
  if (options.includeRawChunks) {
960
962
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
961
963
  }
@@ -977,6 +979,12 @@ var GoogleGenerativeAILanguageModel = class {
977
979
  return;
978
980
  }
979
981
  const content = candidate.content;
982
+ if (candidate.groundingMetadata != null) {
983
+ lastGroundingMetadata = candidate.groundingMetadata;
984
+ }
985
+ if (candidate.urlContextMetadata != null) {
986
+ lastUrlContextMetadata = candidate.urlContextMetadata;
987
+ }
980
988
  const sources = extractSources({
981
989
  groundingMetadata: candidate.groundingMetadata,
982
990
  generateId: generateId2
@@ -1128,9 +1136,9 @@ var GoogleGenerativeAILanguageModel = class {
1128
1136
  providerMetadata = {
1129
1137
  google: {
1130
1138
  promptFeedback: (_i = value.promptFeedback) != null ? _i : null,
1131
- groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
1132
- urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
1133
- safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null
1139
+ groundingMetadata: lastGroundingMetadata,
1140
+ urlContextMetadata: lastUrlContextMetadata,
1141
+ safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null
1134
1142
  }
1135
1143
  };
1136
1144
  if (usageMetadata != null) {
@@ -1308,7 +1316,7 @@ var getGroundingMetadataSchema = () => import_v43.z.object({
1308
1316
  startIndex: import_v43.z.number().nullish(),
1309
1317
  endIndex: import_v43.z.number().nullish(),
1310
1318
  text: import_v43.z.string().nullish()
1311
- }),
1319
+ }).nullish(),
1312
1320
  segment_text: import_v43.z.string().nullish(),
1313
1321
  groundingChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
1314
1322
  supportChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),