@ai-sdk/google 4.0.110 → 4.0.112

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["_$__google_prompt0.GoogleContent","_$__google_prompt0.GoogleSystemInstruction"],"sources":["../../src/google-prompt.ts","../../src/google-language-model-options.ts","../../src/google-language-model.ts","../../src/google-speech-model-options.ts","../../src/google-speech-model.ts","../../src/google-speech-input.ts","../../src/google-tools.ts","../../src/interactions/google-interactions-language-model-options.ts","../../src/interactions/google-interactions-language-model.ts","../../src/interactions/google-interactions-agent.ts"],"mappings":";;;;KAcY;EACV,OAAO;IAAQ;;;KAGL;EACV;EACA,OAAO,MAAM;;cAGF,2BAAyB,EAAA;;;;GAOpC,EAAA,KAAA;;KAGU,sBAAsB,EAAE,aAAa;KAErC;EACN;EAAc;EAAmB;;EAEjC;IAAc;IAAkB;;EAChC,gBAAgB;EAChB;EACA;;EAGA;IAAgB;IAAa;IAAc;;EAC3C;;EAGA;IACE;IACA;IACA;IACA,QAAQ,MAAM;;;EAIhB;IAAY;IAAkB;;EAC9B,gBAAgB;EAChB;EACA;;EAGA;IACE;IACA;IACA;;EAEF;;EAGA;IACE;IACA;IACA;;EAEF;;EAGA;IACE;IACA;;;EAIF;IACE;IACA;;;KAII;EAEN;IAAc;IAAkB;;;EAGhC;IAAY;IAAkB;;;;;KCxFxB;;;YC8EA;EACV;EACA;EACA,UAAU,WAAW;EACrB,QAAQ;EACR;;;;EAKA,sBAAsB;;;;EAKtB;IACE;IACA;;;qBAIS,+BAA+B;WACjC;WAEA,SAAS;mBAED;mBACA;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B;IACA,QAAQ;MACT;EAIW,YAAA,SAAS,eAAe,QAAQ;MAMxC;MAIA,iBAAa,eAAA,YAAA,YAAA,eAAA;SAIJ,iBACX,SACA,QACA,WACE,QACA,iBACA,aACA,MACA,MACA,kBACA,i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Q,WAAW;;;;;;;;;wBCnRhB,uBACd,MACA,OACA;EAEA;EACA;EACA,kBAAkB;;EACd;EAAc;;;;qBCLP;;;;;;;;kBAAA;oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KCQD;;;KC2CA;EACV;EACA;EACA,UAAU,WAAW;EACrB,QAAQ;EACR;EACA,sBAAsB;;KAGZ,+BACR;EACE;;EACA;;qBAEO,2CAA2C;WAC7C;WAEA;;;;;WAMA;mBAEQ;UAET,oBAAoB,OAAO;;;;;UAU3B,sBAAsB;IAC5B;IACA;IACA,QAAQ;MACT;EAQC,YAAA,cAAc,8BACd,QAAQ;MAeN;MAIA,iBAAa,eAAA,YAAA,YAAA,eAAA;UAgBH;EAiVR,WACJ,SAAS,6BACR,QAAQ;EAiIL,SACJ,SAAS,6BACR,QAAQ;UAkFG;;;;;;;;;;;;;KC9qBJ"}
1
+ {"version":3,"file":"index.d.ts","names":["_$__google_prompt0.GoogleContent","_$__google_prompt0.GoogleSystemInstruction"],"sources":["../../src/google-prompt.ts","../../src/google-language-model-options.ts","../../src/google-language-model.ts","../../src/google-speech-model-options.ts","../../src/google-speech-model.ts","../../src/google-speech-input.ts","../../src/google-tools.ts","../../src/interactions/google-interactions-language-model-options.ts","../../src/interactions/google-interactions-language-model.ts","../../src/interactions/google-interactions-agent.ts"],"mappings":";;;;KAcY;EACV,OAAO;IAAQ;;;KAGL;EACV;EACA,OAAO,MAAM;;cAGF,2BAAyB,EAAA;;;;GAOpC,EAAA,KAAA;;KAGU,sBAAsB,EAAE,aAAa;KAErC;EACN;EAAc;EAAmB;;EAEjC;IAAc;IAAkB;;EAChC,gBAAgB;EAChB;EACA;;EAGA;IAAgB;IAAa;IAAc;;EAC3C;;EAGA;IACE;IACA;IACA;IACA,QAAQ,MAAM;;;EAIhB;IAAY;IAAkB;;EAC9B,gBAAgB;EAChB;EACA;;EAGA;I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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BR,kBAAkB,YACrB,mBAAmB;YAGT,0BAA0B,YACpC;YAGU,2BAA2B,YACrC;YAGU,qBAAqB,YAC/B;YAGU,uBAAuB,YACjC,mBAAmB;YAGT,sBAAsB,YAChC,mBAAmB;;;KCliET;;;UCoBF;EACR;EACA;EACA,UAAU,WAAW;EACrB,QAAQ;EACR;IACE,oBAAoB;;;qBAQX,6BAA6B;WAsB7B,SAAS;mBACD;WAtBV;UAED,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;MAIG;EAKO,YAAA,SAAS,qBACD,QAAQ;UAGb;EAgNR,WACJ,SAAS,WAAW,kCACnB,QAAQ,QAAQ,WAAW;;;;;;;;;wBChRhB,uBACd,MACA,OACA;EAEA;EACA;EACA,kBAAkB;;EACd;EAAc;;;;qBCLP;;;;;;;;kBAAA;oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KCQD;;;KC2CA;EACV;EACA;EACA,UAAU,WAAW;EACrB,QAAQ;EACR;EACA,sBAAsB;;KAGZ,+BACR;EACE;;EACA;;qBAEO,2CAA2C;WAC7C;WAEA;;;;;WAMA;mBAEQ;UAET,oBAAoB,OAAO;;;;;UAU3B,sBAAsB;IAC5B;IACA;IACA,QAAQ;MACT;EAQC,YAAA,cAAc,8BACd,QAAQ;MAeN;MAIA,iBAAa,eAAA,YAAA,YAAA,eAAA;UAgBH;EAiVR,WACJ,SAAS,6BACR,QAAQ;EAiIL,SACJ,SAAS,6BACR,QAAQ;UAkFG;;;;;;;;;;;;;KC9qBJ"}
@@ -362,11 +362,11 @@ function convertToGoogleMessages(prompt, options) {
362
362
  const providerOpts = readProviderOpts(part);
363
363
  const thoughtSignature = providerOpts?.thoughtSignature != null ? String(providerOpts.thoughtSignature) : void 0;
364
364
  switch (part.type) {
365
- case "text": return part.text.length === 0 ? void 0 : {
365
+ case "text": return part.text.length === 0 && thoughtSignature == null ? void 0 : {
366
366
  text: part.text,
367
367
  thoughtSignature
368
368
  };
369
- case "reasoning": return part.text.length === 0 ? void 0 : {
369
+ case "reasoning": return part.text.length === 0 && thoughtSignature == null ? void 0 : {
370
370
  text: part.text,
371
371
  thought: true,
372
372
  thoughtSignature
@@ -2019,6 +2019,20 @@ var GoogleLanguageModel = class GoogleLanguageModel {
2019
2019
  const finishActiveStreamingToolCall = (controller) => {
2020
2020
  const active = activeStreamingToolCalls.pop();
2021
2021
  if (active == null) return;
2022
+ if (currentTextBlockId !== null) {
2023
+ controller.enqueue({
2024
+ type: "text-end",
2025
+ id: currentTextBlockId
2026
+ });
2027
+ currentTextBlockId = null;
2028
+ }
2029
+ if (currentReasoningBlockId !== null) {
2030
+ controller.enqueue({
2031
+ type: "reasoning-end",
2032
+ id: currentReasoningBlockId
2033
+ });
2034
+ currentReasoningBlockId = null;
2035
+ }
2022
2036
  const { finalJSON, closingDelta } = active.accumulator.finalize();
2023
2037
  if (closingDelta.length > 0) controller.enqueue({
2024
2038
  type: "tool-input-delta",
@@ -2157,12 +2171,40 @@ var GoogleLanguageModel = class GoogleLanguageModel {
2157
2171
  } else if ("text" in part && part.text != null) {
2158
2172
  const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({ thoughtSignature: part.thoughtSignature }) : void 0;
2159
2173
  if (part.text.length === 0) {
2160
- if (thoughtSignatureMetadata != null && currentTextBlockId !== null) controller.enqueue({
2161
- type: "text-delta",
2162
- id: currentTextBlockId,
2163
- delta: "",
2164
- providerMetadata: thoughtSignatureMetadata
2165
- });
2174
+ if (thoughtSignatureMetadata != null) {
2175
+ if (currentTextBlockId !== null) controller.enqueue({
2176
+ type: "text-delta",
2177
+ id: currentTextBlockId,
2178
+ delta: "",
2179
+ providerMetadata: thoughtSignatureMetadata
2180
+ });
2181
+ else {
2182
+ if (currentReasoningBlockId !== null) {
2183
+ controller.enqueue({
2184
+ type: "reasoning-end",
2185
+ id: currentReasoningBlockId
2186
+ });
2187
+ currentReasoningBlockId = null;
2188
+ }
2189
+ const id = String(blockCounter++);
2190
+ const type = part.thought === true ? "reasoning" : "text";
2191
+ controller.enqueue({
2192
+ type: `${type}-start`,
2193
+ id,
2194
+ providerMetadata: thoughtSignatureMetadata
2195
+ });
2196
+ controller.enqueue({
2197
+ type: `${type}-delta`,
2198
+ id,
2199
+ delta: "",
2200
+ providerMetadata: thoughtSignatureMetadata
2201
+ });
2202
+ controller.enqueue({
2203
+ type: `${type}-end`,
2204
+ id
2205
+ });
2206
+ }
2207
+ }
2166
2208
  } else if (part.thought === true) {
2167
2209
  if (currentTextBlockId !== null) {
2168
2210
  controller.enqueue({
@@ -2266,14 +2308,28 @@ var GoogleLanguageModel = class GoogleLanguageModel {
2266
2308
  providerMetadata: serverMeta
2267
2309
  });
2268
2310
  lastServerToolCallId = void 0;
2269
- }
2270
- for (const part of parts) {
2271
- if (!("functionCall" in part)) continue;
2311
+ } else if ("functionCall" in part) {
2272
2312
  const providerMeta = part.thoughtSignature ? wrapProviderMetadata({ thoughtSignature: part.thoughtSignature }) : void 0;
2273
2313
  const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
2274
2314
  const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
2275
2315
  const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
2276
2316
  const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
2317
+ if (!isStreamingChunk && (isCompleteCall || isNoArgsCompleteCall)) {
2318
+ if (currentTextBlockId !== null) {
2319
+ controller.enqueue({
2320
+ type: "text-end",
2321
+ id: currentTextBlockId
2322
+ });
2323
+ currentTextBlockId = null;
2324
+ }
2325
+ if (currentReasoningBlockId !== null) {
2326
+ controller.enqueue({
2327
+ type: "reasoning-end",
2328
+ id: currentReasoningBlockId
2329
+ });
2330
+ currentReasoningBlockId = null;
2331
+ }
2332
+ }
2277
2333
  if (isStreamingChunk) {
2278
2334
  if (part.functionCall.name != null) {
2279
2335
  const toolCallId = part.functionCall.id || generateId();
@@ -2837,7 +2893,14 @@ var GoogleSpeechModel = class GoogleSpeechModel {
2837
2893
  message: "Custom voices are not supported. Use a prebuilt voice instead."
2838
2894
  });
2839
2895
  const multiSpeakerVoiceConfig = googleOptions?.multiSpeakerVoiceConfig;
2840
- const speechConfig = multiSpeakerVoiceConfig ? { multiSpeakerVoiceConfig } : { voiceConfig: { prebuiltVoiceConfig: { voiceName: voice } } };
2896
+ const languageCode = language === "auto" ? void 0 : language;
2897
+ const speechConfig = multiSpeakerVoiceConfig ? {
2898
+ multiSpeakerVoiceConfig,
2899
+ ...languageCode != null && { languageCode }
2900
+ } : {
2901
+ voiceConfig: { prebuiltVoiceConfig: { voiceName: voice } },
2902
+ ...languageCode != null && { languageCode }
2903
+ };
2841
2904
  let promptText = text;
2842
2905
  if (instructions != null && !usesStructuredSpeech) {
2843
2906
  if (multiSpeakerVoiceConfig) warnings.push({
@@ -2889,11 +2952,6 @@ var GoogleSpeechModel = class GoogleSpeechModel {
2889
2952
  feature: "speed",
2890
2953
  details: "Google Gemini TTS models do not support the `speed` option. It was ignored."
2891
2954
  });
2892
- if (language != null) warnings.push({
2893
- type: "unsupported",
2894
- feature: "language",
2895
- details: "Google Gemini TTS models do not support the `language` option. Language is detected automatically from the input text."
2896
- });
2897
2955
  const formats = usesStructuredSpeech ? {
2898
2956
  wav: "AUDIO_WAV",
2899
2957
  "audio/wav": "AUDIO_WAV",
@@ -5128,7 +5186,7 @@ async function pollGoogleInteractionUntilTerminal({ baseURL, interactionId, head
5128
5186
  * `toolChoice` shapes:
5129
5187
  * - `'auto'` -> `'auto'`
5130
5188
  * - `'required'` -> `'any'`
5131
- * - `'none'` -> `'none'`
5189
+ * - `'none'` -> omit all tools and `tool_choice`
5132
5190
  * - `{ type: 'tool', toolName }` -> `{ allowed_tools: { mode: 'validated', tools: [name] } }`
5133
5191
  * (Interactions `AllowedTools.tools` is an `Array<string>` of function
5134
5192
  * names, not tool descriptors -- see `src/interactions/resources/interactions.ts`
@@ -5136,6 +5194,11 @@ async function pollGoogleInteractionUntilTerminal({ baseURL, interactionId, head
5136
5194
  */
5137
5195
  function prepareGoogleInteractionsTools({ tools, toolChoice }) {
5138
5196
  const toolWarnings = [];
5197
+ if (toolChoice?.type === "none") return {
5198
+ tools: void 0,
5199
+ toolChoice: void 0,
5200
+ toolWarnings
5201
+ };
5139
5202
  const normalized = tools?.length ? tools : void 0;
5140
5203
  if (normalized == null) return {
5141
5204
  tools: void 0,
@@ -5241,9 +5304,6 @@ function prepareGoogleInteractionsTools({ tools, toolChoice }) {
5241
5304
  case "required":
5242
5305
  mappedToolChoice = "any";
5243
5306
  break;
5244
- case "none":
5245
- mappedToolChoice = "none";
5246
- break;
5247
5307
  case "tool": mappedToolChoice = { allowed_tools: {
5248
5308
  mode: "validated",
5249
5309
  tools: [toolChoice.toolName]