@ai-sdk/google 2.0.90 → 2.0.94

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,34 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 2.0.94
4
+
5
+ ### Patch Changes
6
+
7
+ - c43ba7d: Surface prompt-level Google safety blocks without candidates as content-filter results with prompt feedback metadata.
8
+ - 7a292cd: Omit unsupported frequency and presence penalties from Gemini 2.5 requests and return warnings instead.
9
+
10
+ ## 2.0.93
11
+
12
+ ### Patch Changes
13
+
14
+ - a3fe2a8: fix(google): convert enum values to the Gemini schema format
15
+
16
+ ## 2.0.92
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [77d33c0]
21
+ - @ai-sdk/provider-utils@3.0.35
22
+
23
+ ## 2.0.91
24
+
25
+ ### Patch Changes
26
+
27
+ - b616db6: Preserve recursive tool input schemas without aborting Google model calls.
28
+ - Updated dependencies [2fff9f1]
29
+ - Updated dependencies [f364ea0]
30
+ - @ai-sdk/provider-utils@3.0.34
31
+
3
32
  ## 2.0.90
4
33
 
5
34
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -51,7 +51,7 @@ declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySche
51
51
  type GoogleGenerativeAIProviderOptions = InferValidator<typeof googleGenerativeAIProviderOptions>;
52
52
 
53
53
  declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
54
- candidates: {
54
+ candidates?: {
55
55
  content?: Record<string, never> | {
56
56
  parts?: ({
57
57
  functionCall: {
@@ -141,7 +141,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
141
141
  urlRetrievalStatus: string;
142
142
  }[];
143
143
  } | null | undefined;
144
- }[];
144
+ }[] | null | undefined;
145
145
  usageMetadata?: {
146
146
  cachedContentTokenCount?: number | null | undefined;
147
147
  thoughtsTokenCount?: number | null | undefined;
@@ -171,9 +171,10 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
171
171
  } | null | undefined;
172
172
  serviceTier?: string | null | undefined;
173
173
  }>;
174
- type GroundingMetadataSchema = NonNullable<InferValidator<typeof responseSchema>['candidates'][number]['groundingMetadata']>;
175
- type UrlContextMetadataSchema = NonNullable<InferValidator<typeof responseSchema>['candidates'][number]['urlContextMetadata']>;
176
- type SafetyRatingSchema = NonNullable<InferValidator<typeof responseSchema>['candidates'][number]['safetyRatings']>[number];
174
+ type CandidateSchema = NonNullable<InferValidator<typeof responseSchema>['candidates']>[number];
175
+ type GroundingMetadataSchema = NonNullable<CandidateSchema['groundingMetadata']>;
176
+ type UrlContextMetadataSchema = NonNullable<CandidateSchema['urlContextMetadata']>;
177
+ type SafetyRatingSchema = NonNullable<CandidateSchema['safetyRatings']>[number];
177
178
 
178
179
  type GoogleGenerativeAIGroundingMetadata = GroundingMetadataSchema;
179
180
  type GoogleGenerativeAIUrlContextMetadata = UrlContextMetadataSchema;
package/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySche
51
51
  type GoogleGenerativeAIProviderOptions = InferValidator<typeof googleGenerativeAIProviderOptions>;
52
52
 
53
53
  declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
54
- candidates: {
54
+ candidates?: {
55
55
  content?: Record<string, never> | {
56
56
  parts?: ({
57
57
  functionCall: {
@@ -141,7 +141,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
141
141
  urlRetrievalStatus: string;
142
142
  }[];
143
143
  } | null | undefined;
144
- }[];
144
+ }[] | null | undefined;
145
145
  usageMetadata?: {
146
146
  cachedContentTokenCount?: number | null | undefined;
147
147
  thoughtsTokenCount?: number | null | undefined;
@@ -171,9 +171,10 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
171
171
  } | null | undefined;
172
172
  serviceTier?: string | null | undefined;
173
173
  }>;
174
- type GroundingMetadataSchema = NonNullable<InferValidator<typeof responseSchema>['candidates'][number]['groundingMetadata']>;
175
- type UrlContextMetadataSchema = NonNullable<InferValidator<typeof responseSchema>['candidates'][number]['urlContextMetadata']>;
176
- type SafetyRatingSchema = NonNullable<InferValidator<typeof responseSchema>['candidates'][number]['safetyRatings']>[number];
174
+ type CandidateSchema = NonNullable<InferValidator<typeof responseSchema>['candidates']>[number];
175
+ type GroundingMetadataSchema = NonNullable<CandidateSchema['groundingMetadata']>;
176
+ type UrlContextMetadataSchema = NonNullable<CandidateSchema['urlContextMetadata']>;
177
+ type SafetyRatingSchema = NonNullable<CandidateSchema['safetyRatings']>[number];
177
178
 
178
179
  type GoogleGenerativeAIGroundingMetadata = GroundingMetadataSchema;
179
180
  type GoogleGenerativeAIUrlContextMetadata = UrlContextMetadataSchema;
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
30
30
  var import_provider_utils15 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "2.0.90" : "0.0.0-test";
33
+ var VERSION = true ? "2.0.94" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -243,6 +243,10 @@ var import_v45 = require("zod/v4");
243
243
 
244
244
  // src/convert-json-schema-to-openapi-schema.ts
245
245
  var import_provider2 = require("@ai-sdk/provider");
246
+ var recursiveReferenceFunctionalityPrefix = "recursive JSON Schema reference:";
247
+ function isRecursiveJSONSchemaReferenceError(error) {
248
+ return import_provider2.UnsupportedFunctionalityError.isInstance(error) && error.functionality.startsWith(recursiveReferenceFunctionalityPrefix);
249
+ }
246
250
  function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
247
251
  const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
248
252
  return convertJSONSchemaDefinition(jsonSchema, isRoot, {
@@ -293,9 +297,6 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
293
297
  if (description) result.description = description;
294
298
  if (required) result.required = required;
295
299
  if (format) result.format = format;
296
- if (constValue !== void 0) {
297
- result.enum = [constValue];
298
- }
299
300
  if (type) {
300
301
  if (Array.isArray(type)) {
301
302
  const hasNull = type.includes("null");
@@ -312,8 +313,9 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
312
313
  result.type = type;
313
314
  }
314
315
  }
315
- if (enumValues !== void 0) {
316
- result.enum = enumValues;
316
+ const values = enumValues != null ? enumValues : constValue !== void 0 ? [constValue] : void 0;
317
+ if (values !== void 0) {
318
+ addEnumToSchema({ values, type, result });
317
319
  }
318
320
  if (properties != null) {
319
321
  result.properties = Object.entries(properties).reduce(
@@ -373,6 +375,68 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
373
375
  }
374
376
  return result;
375
377
  }
378
+ function addEnumToSchema({
379
+ values,
380
+ type,
381
+ result
382
+ }) {
383
+ const nullable = Array.isArray(type) && type.includes("null") || type === void 0 && values.includes(null);
384
+ const enumValues = nullable ? values.filter((value) => value !== null) : values;
385
+ if (values.length > 0 && values.every((value) => value === null)) {
386
+ const typeAllowsNull = type === void 0 || type === "null" || Array.isArray(type) && type.includes("null");
387
+ if (typeAllowsNull) {
388
+ result.type = "null";
389
+ if (Array.isArray(type)) {
390
+ delete result.anyOf;
391
+ }
392
+ return;
393
+ }
394
+ }
395
+ const enumType = getEnumType({ values: enumValues, type });
396
+ if (enumType === void 0) {
397
+ throw new import_provider2.UnsupportedFunctionalityError({
398
+ functionality: "JSON Schema enum with mixed or unsupported values",
399
+ message: "Google does not support this JSON Schema enum. Enum values must share one supported primitive type and match the schema type."
400
+ });
401
+ }
402
+ result.type = enumType;
403
+ if (Array.isArray(type)) {
404
+ delete result.anyOf;
405
+ }
406
+ if (nullable) {
407
+ result.nullable = true;
408
+ }
409
+ if (enumType === "string") {
410
+ result.enum = enumValues;
411
+ } else {
412
+ result.format = "enum";
413
+ result.enum = enumValues.map(String);
414
+ }
415
+ }
416
+ function getEnumType({
417
+ values,
418
+ type
419
+ }) {
420
+ if (values.length === 0) {
421
+ return void 0;
422
+ }
423
+ const typeAllows = (enumType) => type === void 0 || type === enumType || Array.isArray(type) && type.includes(enumType);
424
+ if (typeAllows("string") && values.every((value) => typeof value === "string")) {
425
+ return "string";
426
+ }
427
+ if ((typeAllows("number") || typeAllows("integer")) && values.every((value) => typeof value === "number" && Number.isFinite(value))) {
428
+ if (typeAllows("number")) {
429
+ return "number";
430
+ }
431
+ if (values.every((value) => Number.isInteger(value))) {
432
+ return "integer";
433
+ }
434
+ }
435
+ if (typeAllows("boolean") && values.every((value) => typeof value === "boolean")) {
436
+ return "boolean";
437
+ }
438
+ return void 0;
439
+ }
376
440
  function convertJSONSchemaReference({
377
441
  jsonSchema,
378
442
  reference,
@@ -385,7 +449,7 @@ function convertJSONSchemaReference({
385
449
  );
386
450
  if (referenceContext.resolvingReferences.has(referenceKey)) {
387
451
  throw new import_provider2.UnsupportedFunctionalityError({
388
- functionality: `recursive JSON Schema reference: ${reference}`,
452
+ functionality: `${recursiveReferenceFunctionalityPrefix} ${reference}`,
389
453
  message: "Google schema conversion does not support recursive JSON Schema references."
390
454
  });
391
455
  }
@@ -871,7 +935,6 @@ function prepareTools({
871
935
  modelId,
872
936
  isVertexProvider = false
873
937
  }) {
874
- var _a, _b;
875
938
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
876
939
  const toolWarnings = [];
877
940
  const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
@@ -992,11 +1055,7 @@ function prepareTools({
992
1055
  const functionDeclarations2 = [];
993
1056
  for (const tool of tools) {
994
1057
  if (tool.type === "function") {
995
- functionDeclarations2.push({
996
- name: tool.name,
997
- description: (_a = tool.description) != null ? _a : "",
998
- parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
999
- });
1058
+ functionDeclarations2.push(prepareFunctionDeclaration(tool));
1000
1059
  }
1001
1060
  }
1002
1061
  const combinedToolConfig = {
@@ -1040,11 +1099,7 @@ function prepareTools({
1040
1099
  for (const tool of tools) {
1041
1100
  switch (tool.type) {
1042
1101
  case "function":
1043
- functionDeclarations.push({
1044
- name: tool.name,
1045
- description: (_b = tool.description) != null ? _b : "",
1046
- parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
1047
- });
1102
+ functionDeclarations.push(prepareFunctionDeclaration(tool));
1048
1103
  if (tool.strict === true) {
1049
1104
  hasStrictTools = true;
1050
1105
  }
@@ -1108,6 +1163,27 @@ function prepareTools({
1108
1163
  }
1109
1164
  }
1110
1165
  }
1166
+ function prepareFunctionDeclaration(tool) {
1167
+ var _a;
1168
+ const declaration = {
1169
+ name: tool.name,
1170
+ description: (_a = tool.description) != null ? _a : ""
1171
+ };
1172
+ try {
1173
+ return {
1174
+ ...declaration,
1175
+ parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
1176
+ };
1177
+ } catch (error) {
1178
+ if (!isRecursiveJSONSchemaReferenceError(error)) {
1179
+ throw error;
1180
+ }
1181
+ return {
1182
+ ...declaration,
1183
+ parametersJsonSchema: tool.inputSchema
1184
+ };
1185
+ }
1186
+ }
1111
1187
 
1112
1188
  // src/map-google-generative-ai-finish-reason.ts
1113
1189
  function mapGoogleGenerativeAIFinishReason({
@@ -1143,6 +1219,7 @@ var configurableSafetySettingCategories = [
1143
1219
  "HARM_CATEGORY_HARASSMENT",
1144
1220
  "HARM_CATEGORY_SEXUALLY_EXPLICIT"
1145
1221
  ];
1222
+ var gemini25ModelPattern2 = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
1146
1223
  var GoogleGenerativeAILanguageModel = class {
1147
1224
  constructor(modelId, config) {
1148
1225
  this.specificationVersion = "v2";
@@ -1220,6 +1297,19 @@ var GoogleGenerativeAILanguageModel = class {
1220
1297
  threshold: safetyThreshold
1221
1298
  })) : void 0;
1222
1299
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
1300
+ const isGemini25DeveloperApiModel = !isVertexProvider && gemini25ModelPattern2.test(this.modelId);
1301
+ if (isGemini25DeveloperApiModel && frequencyPenalty != null) {
1302
+ warnings.push({
1303
+ type: "unsupported-setting",
1304
+ setting: "frequencyPenalty"
1305
+ });
1306
+ }
1307
+ if (isGemini25DeveloperApiModel && presencePenalty != null) {
1308
+ warnings.push({
1309
+ type: "unsupported-setting",
1310
+ setting: "presencePenalty"
1311
+ });
1312
+ }
1223
1313
  const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
1224
1314
  const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
1225
1315
  prompt,
@@ -1247,8 +1337,8 @@ var GoogleGenerativeAILanguageModel = class {
1247
1337
  temperature,
1248
1338
  topK,
1249
1339
  topP,
1250
- frequencyPenalty,
1251
- presencePenalty,
1340
+ frequencyPenalty: isGemini25DeveloperApiModel ? void 0 : frequencyPenalty,
1341
+ presencePenalty: isGemini25DeveloperApiModel ? void 0 : presencePenalty,
1252
1342
  stopSequences,
1253
1343
  seed,
1254
1344
  // response format:
@@ -1284,7 +1374,7 @@ var GoogleGenerativeAILanguageModel = class {
1284
1374
  };
1285
1375
  }
1286
1376
  async doGenerate(options) {
1287
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1377
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1288
1378
  const { args, warnings } = await this.getArgs(options);
1289
1379
  const body = JSON.stringify(args);
1290
1380
  const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
@@ -1306,13 +1396,15 @@ var GoogleGenerativeAILanguageModel = class {
1306
1396
  abortSignal: options.abortSignal,
1307
1397
  fetch: this.config.fetch
1308
1398
  });
1309
- const candidate = response.candidates[0];
1399
+ const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
1400
+ const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
1401
+ const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && promptBlockReason != null;
1310
1402
  const content = [];
1311
- const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
1403
+ const parts = (_d = (_c = candidate == null ? void 0 : candidate.content) == null ? void 0 : _c.parts) != null ? _d : [];
1312
1404
  const usageMetadata = response.usageMetadata;
1313
1405
  let lastCodeExecutionToolCallId;
1314
1406
  for (const part of parts) {
1315
- if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
1407
+ if ("executableCode" in part && ((_e = part.executableCode) == null ? void 0 : _e.code)) {
1316
1408
  const toolCallId = this.config.generateId();
1317
1409
  lastCodeExecutionToolCallId = toolCallId;
1318
1410
  content.push({
@@ -1353,7 +1445,7 @@ var GoogleGenerativeAILanguageModel = class {
1353
1445
  } else if ("functionCall" in part) {
1354
1446
  content.push({
1355
1447
  type: "tool-call",
1356
- toolCallId: (_d = part.functionCall.id) != null ? _d : this.config.generateId(),
1448
+ toolCallId: (_f = part.functionCall.id) != null ? _f : this.config.generateId(),
1357
1449
  toolName: part.functionCall.name,
1358
1450
  input: JSON.stringify(part.functionCall.args),
1359
1451
  providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
@@ -1366,34 +1458,34 @@ var GoogleGenerativeAILanguageModel = class {
1366
1458
  });
1367
1459
  }
1368
1460
  }
1369
- const sources = (_e = extractSources({
1370
- groundingMetadata: candidate.groundingMetadata,
1461
+ const sources = (_g = extractSources({
1462
+ groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
1371
1463
  generateId: this.config.generateId
1372
- })) != null ? _e : [];
1464
+ })) != null ? _g : [];
1373
1465
  for (const source of sources) {
1374
1466
  content.push(source);
1375
1467
  }
1376
1468
  return {
1377
1469
  content,
1378
- finishReason: mapGoogleGenerativeAIFinishReason({
1379
- finishReason: candidate.finishReason,
1470
+ finishReason: isPromptBlocked ? "content-filter" : mapGoogleGenerativeAIFinishReason({
1471
+ finishReason: candidate == null ? void 0 : candidate.finishReason,
1380
1472
  hasToolCalls: content.some((part) => part.type === "tool-call")
1381
1473
  }),
1382
1474
  usage: {
1383
- inputTokens: (_f = usageMetadata == null ? void 0 : usageMetadata.promptTokenCount) != null ? _f : void 0,
1384
- outputTokens: (_g = usageMetadata == null ? void 0 : usageMetadata.candidatesTokenCount) != null ? _g : void 0,
1385
- totalTokens: (_h = usageMetadata == null ? void 0 : usageMetadata.totalTokenCount) != null ? _h : void 0,
1386
- reasoningTokens: (_i = usageMetadata == null ? void 0 : usageMetadata.thoughtsTokenCount) != null ? _i : void 0,
1387
- cachedInputTokens: (_j = usageMetadata == null ? void 0 : usageMetadata.cachedContentTokenCount) != null ? _j : void 0
1475
+ inputTokens: (_h = usageMetadata == null ? void 0 : usageMetadata.promptTokenCount) != null ? _h : void 0,
1476
+ outputTokens: (_i = usageMetadata == null ? void 0 : usageMetadata.candidatesTokenCount) != null ? _i : void 0,
1477
+ totalTokens: (_j = usageMetadata == null ? void 0 : usageMetadata.totalTokenCount) != null ? _j : void 0,
1478
+ reasoningTokens: (_k = usageMetadata == null ? void 0 : usageMetadata.thoughtsTokenCount) != null ? _k : void 0,
1479
+ cachedInputTokens: (_l = usageMetadata == null ? void 0 : usageMetadata.cachedContentTokenCount) != null ? _l : void 0
1388
1480
  },
1389
1481
  warnings,
1390
1482
  providerMetadata: {
1391
1483
  google: {
1392
- promptFeedback: (_k = response.promptFeedback) != null ? _k : null,
1393
- groundingMetadata: (_l = candidate.groundingMetadata) != null ? _l : null,
1394
- urlContextMetadata: (_m = candidate.urlContextMetadata) != null ? _m : null,
1395
- safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
1396
- serviceTier: (_o = response.serviceTier) != null ? _o : null,
1484
+ promptFeedback: (_m = response.promptFeedback) != null ? _m : null,
1485
+ groundingMetadata: (_n = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _n : null,
1486
+ urlContextMetadata: (_o = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _o : null,
1487
+ safetyRatings: (_p = candidate == null ? void 0 : candidate.safetyRatings) != null ? _p : null,
1488
+ serviceTier: (_q = response.serviceTier) != null ? _q : null,
1397
1489
  usageMetadata: usageMetadata != null ? usageMetadata : null
1398
1490
  }
1399
1491
  },
@@ -1447,7 +1539,7 @@ var GoogleGenerativeAILanguageModel = class {
1447
1539
  controller.enqueue({ type: "stream-start", warnings });
1448
1540
  },
1449
1541
  transform(chunk, controller) {
1450
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1542
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1451
1543
  if (options.includeRawChunks) {
1452
1544
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1453
1545
  }
@@ -1469,6 +1561,22 @@ var GoogleGenerativeAILanguageModel = class {
1469
1561
  }
1470
1562
  const candidate = (_f = value.candidates) == null ? void 0 : _f[0];
1471
1563
  if (candidate == null) {
1564
+ const promptBlockReason2 = (_g = value.promptFeedback) == null ? void 0 : _g.blockReason;
1565
+ if (promptBlockReason2 != null) {
1566
+ finishReason = "content-filter";
1567
+ providerMetadata = {
1568
+ google: {
1569
+ promptFeedback: (_h = value.promptFeedback) != null ? _h : null,
1570
+ groundingMetadata: lastGroundingMetadata,
1571
+ urlContextMetadata: lastUrlContextMetadata,
1572
+ safetyRatings: null,
1573
+ serviceTier
1574
+ }
1575
+ };
1576
+ if (usageMetadata != null) {
1577
+ providerMetadata.google.usageMetadata = usageMetadata;
1578
+ }
1579
+ }
1472
1580
  return;
1473
1581
  }
1474
1582
  const content = candidate.content;
@@ -1491,9 +1599,9 @@ var GoogleGenerativeAILanguageModel = class {
1491
1599
  }
1492
1600
  }
1493
1601
  if (content != null) {
1494
- const parts = (_g = content.parts) != null ? _g : [];
1602
+ const parts = (_i = content.parts) != null ? _i : [];
1495
1603
  for (const part of parts) {
1496
- if ("executableCode" in part && ((_h = part.executableCode) == null ? void 0 : _h.code)) {
1604
+ if ("executableCode" in part && ((_j = part.executableCode) == null ? void 0 : _j.code)) {
1497
1605
  const toolCallId = generateId3();
1498
1606
  lastCodeExecutionToolCallId = toolCallId;
1499
1607
  controller.enqueue({
@@ -1620,17 +1728,20 @@ var GoogleGenerativeAILanguageModel = class {
1620
1728
  }
1621
1729
  }
1622
1730
  }
1623
- if (candidate.finishReason != null) {
1624
- finishReason = mapGoogleGenerativeAIFinishReason({
1625
- finishReason: candidate.finishReason,
1731
+ const promptBlockReason = (_k = value.promptFeedback) == null ? void 0 : _k.blockReason;
1732
+ const isPromptBlocked = candidate.finishReason == null && promptBlockReason != null;
1733
+ const rawFinishReason = (_m = (_l = candidate.finishReason) != null ? _l : promptBlockReason) != null ? _m : void 0;
1734
+ if (rawFinishReason != null) {
1735
+ finishReason = isPromptBlocked ? "content-filter" : mapGoogleGenerativeAIFinishReason({
1736
+ finishReason: rawFinishReason,
1626
1737
  hasToolCalls
1627
1738
  });
1628
1739
  providerMetadata = {
1629
1740
  google: {
1630
- promptFeedback: (_i = value.promptFeedback) != null ? _i : null,
1741
+ promptFeedback: (_n = value.promptFeedback) != null ? _n : null,
1631
1742
  groundingMetadata: lastGroundingMetadata,
1632
1743
  urlContextMetadata: lastUrlContextMetadata,
1633
- safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null,
1744
+ safetyRatings: (_o = candidate.safetyRatings) != null ? _o : null,
1634
1745
  serviceTier
1635
1746
  }
1636
1747
  };
@@ -1906,7 +2017,7 @@ var responseSchema = (0, import_provider_utils6.lazySchema)(
1906
2017
  groundingMetadata: getGroundingMetadataSchema().nullish(),
1907
2018
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
1908
2019
  })
1909
- ),
2020
+ ).nullish(),
1910
2021
  usageMetadata: usageSchema.nullish(),
1911
2022
  promptFeedback: import_v45.z.object({
1912
2023
  blockReason: import_v45.z.string().nullish(),