@ai-sdk/google 4.0.63 → 4.0.64

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "4.0.63",
3
+ "version": "4.0.64",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -91,6 +91,8 @@ function convertJSONSchemaDefinition(
91
91
  format,
92
92
  const: constValue,
93
93
  minLength,
94
+ minItems,
95
+ maxItems,
94
96
  enum: enumValues,
95
97
  } = jsonSchema;
96
98
 
@@ -196,6 +198,14 @@ function convertJSONSchemaDefinition(
196
198
  result.minLength = minLength;
197
199
  }
198
200
 
201
+ if (minItems !== undefined) {
202
+ result.minItems = minItems;
203
+ }
204
+
205
+ if (maxItems !== undefined) {
206
+ result.maxItems = maxItems;
207
+ }
208
+
199
209
  return result;
200
210
  }
201
211
 
@@ -13,6 +13,7 @@ import type {
13
13
  } from '@ai-sdk/provider';
14
14
  import {
15
15
  combineHeaders,
16
+ createToolNameMapping,
16
17
  createEventSourceResponseHandler,
17
18
  createJsonResponseHandler,
18
19
  generateId,
@@ -297,6 +298,12 @@ export class GoogleLanguageModel implements LanguageModelV4 {
297
298
  modelId: this.modelId,
298
299
  isVertexProvider,
299
300
  });
301
+ const toolNameMapping = createToolNameMapping({
302
+ tools,
303
+ providerToolNames: {
304
+ 'google.code_execution': 'code_execution',
305
+ },
306
+ });
300
307
 
301
308
  const resolvedThinking = resolveThinkingConfig({
302
309
  reasoning,
@@ -394,6 +401,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
394
401
  warnings: [...warnings, ...toolWarnings],
395
402
  providerOptionsNames,
396
403
  extraHeaders: vertexPaygoHeaders,
404
+ toolNameMapping,
397
405
  };
398
406
  }
399
407
 
@@ -401,10 +409,12 @@ export class GoogleLanguageModel implements LanguageModelV4 {
401
409
  response,
402
410
  warnings,
403
411
  providerOptionsNames,
412
+ toolNameMapping,
404
413
  }: {
405
414
  response: InferSchema<typeof responseSchema>;
406
415
  warnings: SharedV4Warning[];
407
416
  providerOptionsNames: readonly string[];
417
+ toolNameMapping?: ReturnType<typeof createToolNameMapping>;
408
418
  }): LanguageModelV4GenerateResult {
409
419
  const wrapProviderMetadata = (payload: Record<string, unknown>) =>
410
420
  Object.fromEntries(
@@ -437,7 +447,9 @@ export class GoogleLanguageModel implements LanguageModelV4 {
437
447
  content.push({
438
448
  type: 'tool-call',
439
449
  toolCallId,
440
- toolName: 'code_execution',
450
+ toolName:
451
+ toolNameMapping?.toCustomToolName('code_execution') ??
452
+ 'code_execution',
441
453
  input: JSON.stringify(part.executableCode),
442
454
  providerExecuted: true,
443
455
  });
@@ -446,7 +458,9 @@ export class GoogleLanguageModel implements LanguageModelV4 {
446
458
  type: 'tool-result',
447
459
  // Results correspond to the most recent executable code part.
448
460
  toolCallId: lastCodeExecutionToolCallId!,
449
- toolName: 'code_execution',
461
+ toolName:
462
+ toolNameMapping?.toCustomToolName('code_execution') ??
463
+ 'code_execution',
450
464
  result: {
451
465
  outcome: part.codeExecutionResult.outcome,
452
466
  output: part.codeExecutionResult.output ?? '',
@@ -586,8 +600,13 @@ export class GoogleLanguageModel implements LanguageModelV4 {
586
600
  async doGenerate(
587
601
  options: LanguageModelV4CallOptions,
588
602
  ): Promise<LanguageModelV4GenerateResult> {
589
- const { args, warnings, providerOptionsNames, extraHeaders } =
590
- await this.getArgs(options);
603
+ const {
604
+ args,
605
+ warnings,
606
+ providerOptionsNames,
607
+ extraHeaders,
608
+ toolNameMapping,
609
+ } = await this.getArgs(options);
591
610
 
592
611
  const mergedHeaders = combineHeaders(
593
612
  this.config.headers ? await resolve(this.config.headers) : undefined,
@@ -615,6 +634,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
615
634
  response,
616
635
  warnings,
617
636
  providerOptionsNames,
637
+ toolNameMapping,
618
638
  });
619
639
 
620
640
  return {
@@ -631,8 +651,13 @@ export class GoogleLanguageModel implements LanguageModelV4 {
631
651
  async doStream(
632
652
  options: LanguageModelV4CallOptions,
633
653
  ): Promise<LanguageModelV4StreamResult> {
634
- const { args, warnings, providerOptionsNames, extraHeaders } =
635
- await this.getArgs(options, { isStreaming: true });
654
+ const {
655
+ args,
656
+ warnings,
657
+ providerOptionsNames,
658
+ extraHeaders,
659
+ toolNameMapping,
660
+ } = await this.getArgs(options, { isStreaming: true });
636
661
  const wrapProviderMetadata = (payload: Record<string, unknown>) =>
637
662
  Object.fromEntries(
638
663
  providerOptionsNames.map(name => [name, payload]),
@@ -820,7 +845,8 @@ export class GoogleLanguageModel implements LanguageModelV4 {
820
845
  controller.enqueue({
821
846
  type: 'tool-call',
822
847
  toolCallId,
823
- toolName: 'code_execution',
848
+ toolName:
849
+ toolNameMapping.toCustomToolName('code_execution'),
824
850
  input: JSON.stringify(part.executableCode),
825
851
  providerExecuted: true,
826
852
  });
@@ -835,7 +861,8 @@ export class GoogleLanguageModel implements LanguageModelV4 {
835
861
  controller.enqueue({
836
862
  type: 'tool-result',
837
863
  toolCallId,
838
- toolName: 'code_execution',
864
+ toolName:
865
+ toolNameMapping.toCustomToolName('code_execution'),
839
866
  result: {
840
867
  outcome: part.codeExecutionResult.outcome,
841
868
  output: part.codeExecutionResult.output ?? '',