@ai-sdk/google 3.0.96 → 3.0.97

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": "3.0.96",
3
+ "version": "3.0.97",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -548,7 +548,8 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
548
548
  },
549
549
  request: { body: args },
550
550
  response: {
551
- // TODO timestamp, model id, id
551
+ // TODO timestamp, model id
552
+ id: response.responseId ?? undefined,
552
553
  headers: responseHeaders,
553
554
  body: rawResponse,
554
555
  },
@@ -590,6 +591,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
590
591
 
591
592
  const generateId = this.config.generateId;
592
593
  let hasToolCalls = false;
594
+ let hasEmittedResponseMetadata = false;
593
595
 
594
596
  // Track active blocks to group consecutive parts of same type
595
597
  let currentTextBlockId: string | null = null;
@@ -668,6 +670,14 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
668
670
 
669
671
  const value = chunk.value;
670
672
 
673
+ if (!hasEmittedResponseMetadata && value.responseId != null) {
674
+ hasEmittedResponseMetadata = true;
675
+ controller.enqueue({
676
+ type: 'response-metadata',
677
+ id: value.responseId,
678
+ });
679
+ }
680
+
671
681
  const usageMetadata = value.usageMetadata;
672
682
 
673
683
  if (usageMetadata != null) {
@@ -1452,6 +1462,7 @@ export const getUrlContextMetadataSchema = () =>
1452
1462
  const responseSchema = lazySchema(() =>
1453
1463
  zodSchema(
1454
1464
  z.object({
1465
+ responseId: z.string().nullish(),
1455
1466
  candidates: z.array(
1456
1467
  z.object({
1457
1468
  content: getContentSchema().nullish().or(z.object({}).strict()),
@@ -1505,6 +1516,7 @@ export type UsageMetadataSchema = NonNullable<
1505
1516
  const chunkSchema = lazySchema(() =>
1506
1517
  zodSchema(
1507
1518
  z.object({
1519
+ responseId: z.string().nullish(),
1508
1520
  candidates: z
1509
1521
  .array(
1510
1522
  z.object({