@ai-sdk/google 3.0.114 → 3.0.118

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.
@@ -82,7 +82,8 @@ declare const getUrlContextMetadataSchema: () => z.ZodObject<{
82
82
  }, z.core.$strip>>>>;
83
83
  }, z.core.$strip>;
84
84
  declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
85
- candidates: {
85
+ responseId?: string | null | undefined;
86
+ candidates?: {
86
87
  content?: Record<string, never> | {
87
88
  parts?: ({
88
89
  functionCall: {
@@ -198,8 +199,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
198
199
  urlRetrievalStatus: string;
199
200
  }[] | null | undefined;
200
201
  } | null | undefined;
201
- }[];
202
- responseId?: string | null | undefined;
202
+ }[] | null | undefined;
203
203
  usageMetadata?: {
204
204
  cachedContentTokenCount?: number | null | undefined;
205
205
  thoughtsTokenCount?: number | null | undefined;
@@ -229,9 +229,10 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
229
229
  }[] | null | undefined;
230
230
  } | null | undefined;
231
231
  }>;
232
- type GroundingMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['groundingMetadata']>;
233
- type UrlContextMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['urlContextMetadata']>;
234
- type SafetyRatingSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['safetyRatings']>[number];
232
+ type CandidateSchema = NonNullable<InferSchema<typeof responseSchema>['candidates']>[number];
233
+ type GroundingMetadataSchema = NonNullable<CandidateSchema['groundingMetadata']>;
234
+ type UrlContextMetadataSchema = NonNullable<CandidateSchema['urlContextMetadata']>;
235
+ type SafetyRatingSchema = NonNullable<CandidateSchema['safetyRatings']>[number];
235
236
  type PromptFeedbackSchema = NonNullable<InferSchema<typeof responseSchema>['promptFeedback']>;
236
237
  type UsageMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['usageMetadata']>;
237
238
 
@@ -82,7 +82,8 @@ declare const getUrlContextMetadataSchema: () => z.ZodObject<{
82
82
  }, z.core.$strip>>>>;
83
83
  }, z.core.$strip>;
84
84
  declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
85
- candidates: {
85
+ responseId?: string | null | undefined;
86
+ candidates?: {
86
87
  content?: Record<string, never> | {
87
88
  parts?: ({
88
89
  functionCall: {
@@ -198,8 +199,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
198
199
  urlRetrievalStatus: string;
199
200
  }[] | null | undefined;
200
201
  } | null | undefined;
201
- }[];
202
- responseId?: string | null | undefined;
202
+ }[] | null | undefined;
203
203
  usageMetadata?: {
204
204
  cachedContentTokenCount?: number | null | undefined;
205
205
  thoughtsTokenCount?: number | null | undefined;
@@ -229,9 +229,10 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
229
229
  }[] | null | undefined;
230
230
  } | null | undefined;
231
231
  }>;
232
- type GroundingMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['groundingMetadata']>;
233
- type UrlContextMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['urlContextMetadata']>;
234
- type SafetyRatingSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['safetyRatings']>[number];
232
+ type CandidateSchema = NonNullable<InferSchema<typeof responseSchema>['candidates']>[number];
233
+ type GroundingMetadataSchema = NonNullable<CandidateSchema['groundingMetadata']>;
234
+ type UrlContextMetadataSchema = NonNullable<CandidateSchema['urlContextMetadata']>;
235
+ type SafetyRatingSchema = NonNullable<CandidateSchema['safetyRatings']>[number];
235
236
  type PromptFeedbackSchema = NonNullable<InferSchema<typeof responseSchema>['promptFeedback']>;
236
237
  type UsageMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['usageMetadata']>;
237
238
 
@@ -127,9 +127,6 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
127
127
  if (description) result.description = description;
128
128
  if (required) result.required = required;
129
129
  if (format) result.format = format;
130
- if (constValue !== void 0) {
131
- result.enum = [constValue];
132
- }
133
130
  if (type) {
134
131
  if (Array.isArray(type)) {
135
132
  const hasNull = type.includes("null");
@@ -146,8 +143,9 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
146
143
  result.type = type;
147
144
  }
148
145
  }
149
- if (enumValues !== void 0) {
150
- result.enum = enumValues;
146
+ const values = enumValues != null ? enumValues : constValue !== void 0 ? [constValue] : void 0;
147
+ if (values !== void 0) {
148
+ addEnumToSchema({ values, type, result });
151
149
  }
152
150
  if (properties != null) {
153
151
  result.properties = Object.entries(properties).reduce(
@@ -207,6 +205,68 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
207
205
  }
208
206
  return result;
209
207
  }
208
+ function addEnumToSchema({
209
+ values,
210
+ type,
211
+ result
212
+ }) {
213
+ const nullable = Array.isArray(type) && type.includes("null") || type === void 0 && values.includes(null);
214
+ const enumValues = nullable ? values.filter((value) => value !== null) : values;
215
+ if (values.length > 0 && values.every((value) => value === null)) {
216
+ const typeAllowsNull = type === void 0 || type === "null" || Array.isArray(type) && type.includes("null");
217
+ if (typeAllowsNull) {
218
+ result.type = "null";
219
+ if (Array.isArray(type)) {
220
+ delete result.anyOf;
221
+ }
222
+ return;
223
+ }
224
+ }
225
+ const enumType = getEnumType({ values: enumValues, type });
226
+ if (enumType === void 0) {
227
+ throw new import_provider.UnsupportedFunctionalityError({
228
+ functionality: "JSON Schema enum with mixed or unsupported values",
229
+ message: "Google does not support this JSON Schema enum. Enum values must share one supported primitive type and match the schema type."
230
+ });
231
+ }
232
+ result.type = enumType;
233
+ if (Array.isArray(type)) {
234
+ delete result.anyOf;
235
+ }
236
+ if (nullable) {
237
+ result.nullable = true;
238
+ }
239
+ if (enumType === "string") {
240
+ result.enum = enumValues;
241
+ } else {
242
+ result.format = "enum";
243
+ result.enum = enumValues.map(String);
244
+ }
245
+ }
246
+ function getEnumType({
247
+ values,
248
+ type
249
+ }) {
250
+ if (values.length === 0) {
251
+ return void 0;
252
+ }
253
+ const typeAllows = (enumType) => type === void 0 || type === enumType || Array.isArray(type) && type.includes(enumType);
254
+ if (typeAllows("string") && values.every((value) => typeof value === "string")) {
255
+ return "string";
256
+ }
257
+ if ((typeAllows("number") || typeAllows("integer")) && values.every((value) => typeof value === "number" && Number.isFinite(value))) {
258
+ if (typeAllows("number")) {
259
+ return "number";
260
+ }
261
+ if (values.every((value) => Number.isInteger(value))) {
262
+ return "integer";
263
+ }
264
+ }
265
+ if (typeAllows("boolean") && values.every((value) => typeof value === "boolean")) {
266
+ return "boolean";
267
+ }
268
+ return void 0;
269
+ }
210
270
  function convertJSONSchemaReference({
211
271
  jsonSchema,
212
272
  reference,
@@ -1413,6 +1473,7 @@ var configurableSafetySettingCategories = [
1413
1473
  "HARM_CATEGORY_HARASSMENT",
1414
1474
  "HARM_CATEGORY_SEXUALLY_EXPLICIT"
1415
1475
  ];
1476
+ var gemini25ModelPattern2 = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
1416
1477
  var GoogleGenerativeAILanguageModel = class {
1417
1478
  constructor(modelId, config) {
1418
1479
  this.specificationVersion = "v3";
@@ -1516,6 +1577,19 @@ var GoogleGenerativeAILanguageModel = class {
1516
1577
  }
1517
1578
  }
1518
1579
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
1580
+ const isGemini25DeveloperApiModel = !isVertexProvider && gemini25ModelPattern2.test(this.modelId);
1581
+ if (isGemini25DeveloperApiModel && frequencyPenalty != null) {
1582
+ warnings.push({
1583
+ type: "unsupported",
1584
+ feature: "frequencyPenalty"
1585
+ });
1586
+ }
1587
+ if (isGemini25DeveloperApiModel && presencePenalty != null) {
1588
+ warnings.push({
1589
+ type: "unsupported",
1590
+ feature: "presencePenalty"
1591
+ });
1592
+ }
1519
1593
  const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
1520
1594
  const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
1521
1595
  prompt,
@@ -1564,8 +1638,8 @@ var GoogleGenerativeAILanguageModel = class {
1564
1638
  temperature,
1565
1639
  topK,
1566
1640
  topP,
1567
- frequencyPenalty,
1568
- presencePenalty,
1641
+ frequencyPenalty: isGemini25DeveloperApiModel ? void 0 : frequencyPenalty,
1642
+ presencePenalty: isGemini25DeveloperApiModel ? void 0 : presencePenalty,
1569
1643
  stopSequences,
1570
1644
  seed,
1571
1645
  // response format:
@@ -1600,7 +1674,7 @@ var GoogleGenerativeAILanguageModel = class {
1600
1674
  };
1601
1675
  }
1602
1676
  async doGenerate(options) {
1603
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1677
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
1604
1678
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
1605
1679
  const mergedHeaders = (0, import_provider_utils4.combineHeaders)(
1606
1680
  await (0, import_provider_utils4.resolve)(this.config.headers),
@@ -1622,14 +1696,17 @@ var GoogleGenerativeAILanguageModel = class {
1622
1696
  abortSignal: options.abortSignal,
1623
1697
  fetch: this.config.fetch
1624
1698
  });
1625
- const candidate = response.candidates[0];
1699
+ const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
1700
+ const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
1701
+ const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && promptBlockReason != null;
1702
+ const rawFinishReason = (_d = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : promptBlockReason) != null ? _d : void 0;
1626
1703
  const content = [];
1627
- const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
1704
+ const parts = (_f = (_e = candidate == null ? void 0 : candidate.content) == null ? void 0 : _e.parts) != null ? _f : [];
1628
1705
  const usageMetadata = response.usageMetadata;
1629
1706
  let lastCodeExecutionToolCallId;
1630
1707
  let lastServerToolCallId;
1631
1708
  for (const part of parts) {
1632
- if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
1709
+ if ("executableCode" in part && ((_g = part.executableCode) == null ? void 0 : _g.code)) {
1633
1710
  const toolCallId = this.config.generateId();
1634
1711
  lastCodeExecutionToolCallId = toolCallId;
1635
1712
  content.push({
@@ -1647,7 +1724,7 @@ var GoogleGenerativeAILanguageModel = class {
1647
1724
  toolName: "code_execution",
1648
1725
  result: {
1649
1726
  outcome: part.codeExecutionResult.outcome,
1650
- output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1727
+ output: (_h = part.codeExecutionResult.output) != null ? _h : ""
1651
1728
  }
1652
1729
  });
1653
1730
  } else if ("text" in part && part.text != null) {
@@ -1671,9 +1748,9 @@ var GoogleGenerativeAILanguageModel = class {
1671
1748
  } else if ("functionCall" in part && part.functionCall.name != null) {
1672
1749
  content.push({
1673
1750
  type: "tool-call",
1674
- toolCallId: (_e = part.functionCall.id) != null ? _e : this.config.generateId(),
1751
+ toolCallId: (_i = part.functionCall.id) != null ? _i : this.config.generateId(),
1675
1752
  toolName: part.functionCall.name,
1676
- input: JSON.stringify((_f = part.functionCall.args) != null ? _f : {}),
1753
+ input: JSON.stringify((_j = part.functionCall.args) != null ? _j : {}),
1677
1754
  providerMetadata: part.thoughtSignature ? {
1678
1755
  [providerOptionsName]: {
1679
1756
  thoughtSignature: part.thoughtSignature
@@ -1695,13 +1772,13 @@ var GoogleGenerativeAILanguageModel = class {
1695
1772
  } : void 0
1696
1773
  });
1697
1774
  } else if ("toolCall" in part && part.toolCall) {
1698
- const toolCallId = (_g = part.toolCall.id) != null ? _g : this.config.generateId();
1775
+ const toolCallId = (_k = part.toolCall.id) != null ? _k : this.config.generateId();
1699
1776
  lastServerToolCallId = toolCallId;
1700
1777
  content.push({
1701
1778
  type: "tool-call",
1702
1779
  toolCallId,
1703
1780
  toolName: `server:${part.toolCall.toolType}`,
1704
- input: JSON.stringify((_h = part.toolCall.args) != null ? _h : {}),
1781
+ input: JSON.stringify((_l = part.toolCall.args) != null ? _l : {}),
1705
1782
  providerExecuted: true,
1706
1783
  dynamic: true,
1707
1784
  providerMetadata: part.thoughtSignature ? {
@@ -1718,12 +1795,12 @@ var GoogleGenerativeAILanguageModel = class {
1718
1795
  }
1719
1796
  });
1720
1797
  } else if ("toolResponse" in part && part.toolResponse) {
1721
- const responseToolCallId = (_i = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _i : this.config.generateId();
1798
+ const responseToolCallId = (_m = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _m : this.config.generateId();
1722
1799
  content.push({
1723
1800
  type: "tool-result",
1724
1801
  toolCallId: responseToolCallId,
1725
1802
  toolName: `server:${part.toolResponse.toolType}`,
1726
- result: (_j = part.toolResponse.response) != null ? _j : {},
1803
+ result: (_n = part.toolResponse.response) != null ? _n : {},
1727
1804
  providerMetadata: part.thoughtSignature ? {
1728
1805
  [providerOptionsName]: {
1729
1806
  thoughtSignature: part.thoughtSignature,
@@ -1740,42 +1817,42 @@ var GoogleGenerativeAILanguageModel = class {
1740
1817
  lastServerToolCallId = void 0;
1741
1818
  }
1742
1819
  }
1743
- const sources = (_k = extractSources({
1744
- groundingMetadata: candidate.groundingMetadata,
1820
+ const sources = (_o = extractSources({
1821
+ groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
1745
1822
  generateId: this.config.generateId
1746
- })) != null ? _k : [];
1823
+ })) != null ? _o : [];
1747
1824
  for (const source of sources) {
1748
1825
  content.push(source);
1749
1826
  }
1750
1827
  return {
1751
1828
  content,
1752
1829
  finishReason: {
1753
- unified: mapGoogleGenerativeAIFinishReason({
1754
- finishReason: candidate.finishReason,
1830
+ unified: isPromptBlocked ? "content-filter" : mapGoogleGenerativeAIFinishReason({
1831
+ finishReason: rawFinishReason,
1755
1832
  // Only count client-executed tool calls for finish reason determination.
1756
1833
  hasToolCalls: content.some(
1757
1834
  (part) => part.type === "tool-call" && !part.providerExecuted
1758
1835
  )
1759
1836
  }),
1760
- raw: (_l = candidate.finishReason) != null ? _l : void 0
1837
+ raw: rawFinishReason
1761
1838
  },
1762
1839
  usage: convertGoogleGenerativeAIUsage(usageMetadata),
1763
1840
  warnings,
1764
1841
  providerMetadata: {
1765
1842
  [providerOptionsName]: {
1766
- promptFeedback: (_m = response.promptFeedback) != null ? _m : null,
1767
- groundingMetadata: (_n = candidate.groundingMetadata) != null ? _n : null,
1768
- urlContextMetadata: (_o = candidate.urlContextMetadata) != null ? _o : null,
1769
- safetyRatings: (_p = candidate.safetyRatings) != null ? _p : null,
1843
+ promptFeedback: (_p = response.promptFeedback) != null ? _p : null,
1844
+ groundingMetadata: (_q = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _q : null,
1845
+ urlContextMetadata: (_r = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _r : null,
1846
+ safetyRatings: (_s = candidate == null ? void 0 : candidate.safetyRatings) != null ? _s : null,
1770
1847
  usageMetadata: usageMetadata != null ? usageMetadata : null,
1771
- finishMessage: (_q = candidate.finishMessage) != null ? _q : null,
1772
- serviceTier: (_r = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _r : null
1848
+ finishMessage: (_t = candidate == null ? void 0 : candidate.finishMessage) != null ? _t : null,
1849
+ serviceTier: (_u = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _u : null
1773
1850
  }
1774
1851
  },
1775
1852
  request: { body: args },
1776
1853
  response: {
1777
1854
  // TODO timestamp, model id
1778
- id: (_s = response.responseId) != null ? _s : void 0,
1855
+ id: (_v = response.responseId) != null ? _v : void 0,
1779
1856
  headers: responseHeaders,
1780
1857
  body: rawResponse
1781
1858
  }
@@ -1852,7 +1929,7 @@ var GoogleGenerativeAILanguageModel = class {
1852
1929
  controller.enqueue({ type: "stream-start", warnings });
1853
1930
  },
1854
1931
  transform(chunk, controller) {
1855
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1932
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
1856
1933
  if (options.includeRawChunks) {
1857
1934
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1858
1935
  }
@@ -1874,6 +1951,24 @@ var GoogleGenerativeAILanguageModel = class {
1874
1951
  }
1875
1952
  const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
1876
1953
  if (candidate == null) {
1954
+ const promptBlockReason2 = (_b = value.promptFeedback) == null ? void 0 : _b.blockReason;
1955
+ if (promptBlockReason2 != null) {
1956
+ finishReason = {
1957
+ unified: "content-filter",
1958
+ raw: promptBlockReason2
1959
+ };
1960
+ providerMetadata = {
1961
+ [providerOptionsName]: {
1962
+ promptFeedback: (_c = value.promptFeedback) != null ? _c : null,
1963
+ groundingMetadata: lastGroundingMetadata,
1964
+ urlContextMetadata: lastUrlContextMetadata,
1965
+ safetyRatings: null,
1966
+ usageMetadata: usageMetadata != null ? usageMetadata : null,
1967
+ finishMessage: null,
1968
+ serviceTier: (_d = usage == null ? void 0 : usage.serviceTier) != null ? _d : null
1969
+ }
1970
+ };
1971
+ }
1877
1972
  return;
1878
1973
  }
1879
1974
  const content = candidate.content;
@@ -1896,9 +1991,9 @@ var GoogleGenerativeAILanguageModel = class {
1896
1991
  }
1897
1992
  }
1898
1993
  if (content != null) {
1899
- const parts = (_b = content.parts) != null ? _b : [];
1994
+ const parts = (_e = content.parts) != null ? _e : [];
1900
1995
  for (const part of parts) {
1901
- if ("executableCode" in part && ((_c = part.executableCode) == null ? void 0 : _c.code)) {
1996
+ if ("executableCode" in part && ((_f = part.executableCode) == null ? void 0 : _f.code)) {
1902
1997
  const toolCallId = generateId2();
1903
1998
  lastCodeExecutionToolCallId = toolCallId;
1904
1999
  controller.enqueue({
@@ -1917,7 +2012,7 @@ var GoogleGenerativeAILanguageModel = class {
1917
2012
  toolName: "code_execution",
1918
2013
  result: {
1919
2014
  outcome: part.codeExecutionResult.outcome,
1920
- output: (_d = part.codeExecutionResult.output) != null ? _d : ""
2015
+ output: (_g = part.codeExecutionResult.output) != null ? _g : ""
1921
2016
  }
1922
2017
  });
1923
2018
  }
@@ -2011,7 +2106,7 @@ var GoogleGenerativeAILanguageModel = class {
2011
2106
  providerMetadata: fileMeta
2012
2107
  });
2013
2108
  } else if ("toolCall" in part && part.toolCall) {
2014
- const toolCallId = (_e = part.toolCall.id) != null ? _e : generateId2();
2109
+ const toolCallId = (_h = part.toolCall.id) != null ? _h : generateId2();
2015
2110
  lastServerToolCallId = toolCallId;
2016
2111
  const serverMeta = {
2017
2112
  [providerOptionsName]: {
@@ -2024,13 +2119,13 @@ var GoogleGenerativeAILanguageModel = class {
2024
2119
  type: "tool-call",
2025
2120
  toolCallId,
2026
2121
  toolName: `server:${part.toolCall.toolType}`,
2027
- input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
2122
+ input: JSON.stringify((_i = part.toolCall.args) != null ? _i : {}),
2028
2123
  providerExecuted: true,
2029
2124
  dynamic: true,
2030
2125
  providerMetadata: serverMeta
2031
2126
  });
2032
2127
  } else if ("toolResponse" in part && part.toolResponse) {
2033
- const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : generateId2();
2128
+ const responseToolCallId = (_j = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _j : generateId2();
2034
2129
  const serverMeta = {
2035
2130
  [providerOptionsName]: {
2036
2131
  ...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
@@ -2042,7 +2137,7 @@ var GoogleGenerativeAILanguageModel = class {
2042
2137
  type: "tool-result",
2043
2138
  toolCallId: responseToolCallId,
2044
2139
  toolName: `server:${part.toolResponse.toolType}`,
2045
- result: (_h = part.toolResponse.response) != null ? _h : {},
2140
+ result: (_k = part.toolResponse.response) != null ? _k : {},
2046
2141
  providerMetadata: serverMeta
2047
2142
  });
2048
2143
  lastServerToolCallId = void 0;
@@ -2061,7 +2156,7 @@ var GoogleGenerativeAILanguageModel = class {
2061
2156
  const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
2062
2157
  if (isStreamingChunk) {
2063
2158
  if (part.functionCall.name != null) {
2064
- const toolCallId = (_i = part.functionCall.id) != null ? _i : generateId2();
2159
+ const toolCallId = (_l = part.functionCall.id) != null ? _l : generateId2();
2065
2160
  const accumulator = new GoogleJSONAccumulator();
2066
2161
  activeStreamingToolCalls.push({
2067
2162
  toolCallId,
@@ -2109,9 +2204,9 @@ var GoogleGenerativeAILanguageModel = class {
2109
2204
  } else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
2110
2205
  finishActiveStreamingToolCall(controller);
2111
2206
  } else if (isCompleteCall) {
2112
- const toolCallId = (_j = part.functionCall.id) != null ? _j : generateId2();
2207
+ const toolCallId = (_m = part.functionCall.id) != null ? _m : generateId2();
2113
2208
  const toolName = part.functionCall.name;
2114
- const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_k = part.functionCall.args) != null ? _k : {});
2209
+ const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_n = part.functionCall.args) != null ? _n : {});
2115
2210
  controller.enqueue({
2116
2211
  type: "tool-input-start",
2117
2212
  id: toolCallId,
@@ -2138,7 +2233,7 @@ var GoogleGenerativeAILanguageModel = class {
2138
2233
  });
2139
2234
  hasToolCalls = true;
2140
2235
  } else if (isNoArgsCompleteCall) {
2141
- const toolCallId = (_l = part.functionCall.id) != null ? _l : generateId2();
2236
+ const toolCallId = (_o = part.functionCall.id) != null ? _o : generateId2();
2142
2237
  const toolName = part.functionCall.name;
2143
2238
  controller.enqueue({
2144
2239
  type: "tool-input-start",
@@ -2162,23 +2257,26 @@ var GoogleGenerativeAILanguageModel = class {
2162
2257
  }
2163
2258
  }
2164
2259
  }
2165
- if (candidate.finishReason != null) {
2260
+ const promptBlockReason = (_p = value.promptFeedback) == null ? void 0 : _p.blockReason;
2261
+ const isPromptBlocked = candidate.finishReason == null && promptBlockReason != null;
2262
+ const rawFinishReason = (_r = (_q = candidate.finishReason) != null ? _q : promptBlockReason) != null ? _r : void 0;
2263
+ if (rawFinishReason != null) {
2166
2264
  finishReason = {
2167
- unified: mapGoogleGenerativeAIFinishReason({
2168
- finishReason: candidate.finishReason,
2265
+ unified: isPromptBlocked ? "content-filter" : mapGoogleGenerativeAIFinishReason({
2266
+ finishReason: rawFinishReason,
2169
2267
  hasToolCalls
2170
2268
  }),
2171
- raw: candidate.finishReason
2269
+ raw: rawFinishReason
2172
2270
  };
2173
2271
  providerMetadata = {
2174
2272
  [providerOptionsName]: {
2175
- promptFeedback: (_m = value.promptFeedback) != null ? _m : null,
2273
+ promptFeedback: (_s = value.promptFeedback) != null ? _s : null,
2176
2274
  groundingMetadata: lastGroundingMetadata,
2177
2275
  urlContextMetadata: lastUrlContextMetadata,
2178
- safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
2276
+ safetyRatings: (_t = candidate.safetyRatings) != null ? _t : null,
2179
2277
  usageMetadata: usageMetadata != null ? usageMetadata : null,
2180
- finishMessage: (_o = candidate.finishMessage) != null ? _o : null,
2181
- serviceTier: (_p = usage == null ? void 0 : usage.serviceTier) != null ? _p : null
2278
+ finishMessage: (_u = candidate.finishMessage) != null ? _u : null,
2279
+ serviceTier: (_v = usage == null ? void 0 : usage.serviceTier) != null ? _v : null
2182
2280
  }
2183
2281
  };
2184
2282
  }
@@ -2463,7 +2561,7 @@ var responseSchema = (0, import_provider_utils4.lazySchema)(
2463
2561
  groundingMetadata: getGroundingMetadataSchema().nullish(),
2464
2562
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
2465
2563
  })
2466
- ),
2564
+ ).nullish(),
2467
2565
  usageMetadata: usageSchema.nullish(),
2468
2566
  promptFeedback: import_v43.z.object({
2469
2567
  blockReason: import_v43.z.string().nullish(),