@ai-sdk/google 3.0.74 → 3.0.77

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/index.d.mts +55 -12
  3. package/dist/index.d.ts +55 -12
  4. package/dist/index.js +687 -375
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +687 -375
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/internal/index.d.mts +1 -2
  9. package/dist/internal/index.d.ts +1 -2
  10. package/dist/internal/index.js +97 -59
  11. package/dist/internal/index.js.map +1 -1
  12. package/dist/internal/index.mjs +97 -59
  13. package/dist/internal/index.mjs.map +1 -1
  14. package/docs/15-google-generative-ai.mdx +73 -16
  15. package/package.json +1 -1
  16. package/src/google-generative-ai-language-model.ts +104 -56
  17. package/src/google-generative-ai-options.ts +24 -8
  18. package/src/google-provider.ts +9 -4
  19. package/src/interactions/build-google-interactions-stream-transform.ts +285 -154
  20. package/src/interactions/convert-to-google-interactions-input.ts +57 -133
  21. package/src/interactions/extract-google-interactions-sources.ts +3 -3
  22. package/src/interactions/google-interactions-agent.ts +6 -7
  23. package/src/interactions/google-interactions-api.ts +179 -115
  24. package/src/interactions/google-interactions-language-model-options.ts +126 -0
  25. package/src/interactions/google-interactions-language-model.ts +173 -60
  26. package/src/interactions/google-interactions-prompt.ts +239 -114
  27. package/src/interactions/map-google-interactions-finish-reason.ts +3 -5
  28. package/src/interactions/parse-google-interactions-outputs.ts +80 -74
  29. package/src/interactions/prepare-google-interactions-tools.ts +1 -1
  30. package/src/interactions/stream-google-interactions.ts +2 -2
  31. package/src/interactions/synthesize-google-interactions-agent-stream.ts +1 -1
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
30
30
  var import_provider_utils23 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "3.0.74" : "0.0.0-test";
33
+ var VERSION = true ? "3.0.77" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -851,17 +851,32 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
851
851
  */
852
852
  streamFunctionCallArguments: import_v44.z.boolean().optional(),
853
853
  /**
854
- * Optional. The service tier to use for the request.
854
+ * Optional. The service tier to use for the request. Sent as the
855
+ * `serviceTier` body field. Gemini API only.
855
856
  */
856
- serviceTier: import_v44.z.enum(["standard", "flex", "priority"]).optional()
857
+ serviceTier: import_v44.z.enum(["standard", "flex", "priority"]).optional(),
858
+ /**
859
+ * Optional. Vertex AI only. Sent as the
860
+ * `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
861
+ * shared (PayGo) tier. With Provisioned Throughput allocated and
862
+ * `requestType` unset, the request falls back to this tier only if
863
+ * PT capacity is exhausted.
864
+ *
865
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
866
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
867
+ */
868
+ sharedRequestType: import_v44.z.enum(["priority", "flex", "standard"]).optional(),
869
+ /**
870
+ * Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
871
+ * request header. Set to `'shared'` together with `sharedRequestType`
872
+ * to bypass Provisioned Throughput entirely.
873
+ *
874
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
875
+ */
876
+ requestType: import_v44.z.enum(["shared"]).optional()
857
877
  })
858
878
  )
859
879
  );
860
- var VertexServiceTierMap = {
861
- standard: "SERVICE_TIER_STANDARD",
862
- flex: "SERVICE_TIER_FLEX",
863
- priority: "SERVICE_TIER_PRIORITY"
864
- };
865
880
 
866
881
  // src/google-prepare-tools.ts
867
882
  var import_provider3 = require("@ai-sdk/provider");
@@ -1426,10 +1441,27 @@ var GoogleGenerativeAILanguageModel = class {
1426
1441
  message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${this.config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
1427
1442
  });
1428
1443
  }
1429
- let sanitizedServiceTier = googleOptions == null ? void 0 : googleOptions.serviceTier;
1430
1444
  if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
1431
- sanitizedServiceTier = VertexServiceTierMap[googleOptions.serviceTier];
1445
+ warnings.push({
1446
+ type: "other",
1447
+ message: "'serviceTier' is a Gemini API option and is not supported on Vertex AI. Use 'sharedRequestType' (and optionally 'requestType') instead. See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo"
1448
+ });
1449
+ }
1450
+ if (((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) && !isVertexProvider) {
1451
+ warnings.push({
1452
+ type: "other",
1453
+ message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${this.config.provider}).`
1454
+ });
1432
1455
  }
1456
+ const vertexPaygoHeaders = isVertexProvider && ((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) ? {
1457
+ ...googleOptions.sharedRequestType && {
1458
+ "X-Vertex-AI-LLM-Shared-Request-Type": googleOptions.sharedRequestType
1459
+ },
1460
+ ...googleOptions.requestType && {
1461
+ "X-Vertex-AI-LLM-Request-Type": googleOptions.requestType
1462
+ }
1463
+ } : void 0;
1464
+ const bodyServiceTier = isVertexProvider ? void 0 : googleOptions == null ? void 0 : googleOptions.serviceTier;
1433
1465
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
1434
1466
  const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
1435
1467
  const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
@@ -1501,18 +1533,20 @@ var GoogleGenerativeAILanguageModel = class {
1501
1533
  toolConfig,
1502
1534
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
1503
1535
  labels: googleOptions == null ? void 0 : googleOptions.labels,
1504
- serviceTier: sanitizedServiceTier
1536
+ serviceTier: bodyServiceTier
1505
1537
  },
1506
1538
  warnings: [...warnings, ...toolWarnings],
1507
- providerOptionsName
1539
+ providerOptionsName,
1540
+ extraHeaders: vertexPaygoHeaders
1508
1541
  };
1509
1542
  }
1510
1543
  async doGenerate(options) {
1511
1544
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1512
- const { args, warnings, providerOptionsName } = await this.getArgs(options);
1545
+ const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
1513
1546
  const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
1514
1547
  await (0, import_provider_utils6.resolve)(this.config.headers),
1515
- options.headers
1548
+ options.headers,
1549
+ extraHeaders
1516
1550
  );
1517
1551
  const {
1518
1552
  responseHeaders,
@@ -1677,7 +1711,7 @@ var GoogleGenerativeAILanguageModel = class {
1677
1711
  safetyRatings: (_p = candidate.safetyRatings) != null ? _p : null,
1678
1712
  usageMetadata: usageMetadata != null ? usageMetadata : null,
1679
1713
  finishMessage: (_q = candidate.finishMessage) != null ? _q : null,
1680
- serviceTier: (_r = response.serviceTier) != null ? _r : null
1714
+ serviceTier: (_r = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _r : null
1681
1715
  }
1682
1716
  },
1683
1717
  request: { body: args },
@@ -1689,13 +1723,12 @@ var GoogleGenerativeAILanguageModel = class {
1689
1723
  };
1690
1724
  }
1691
1725
  async doStream(options) {
1692
- const { args, warnings, providerOptionsName } = await this.getArgs(
1693
- options,
1694
- { isStreaming: true }
1695
- );
1726
+ var _a;
1727
+ const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
1696
1728
  const headers = (0, import_provider_utils6.combineHeaders)(
1697
1729
  await (0, import_provider_utils6.resolve)(this.config.headers),
1698
- options.headers
1730
+ options.headers,
1731
+ extraHeaders
1699
1732
  );
1700
1733
  const { responseHeaders, value: response } = await (0, import_provider_utils6.postJsonToApi)({
1701
1734
  url: `${this.config.baseURL}/${getModelPath(
@@ -1716,7 +1749,7 @@ var GoogleGenerativeAILanguageModel = class {
1716
1749
  let providerMetadata = void 0;
1717
1750
  let lastGroundingMetadata = null;
1718
1751
  let lastUrlContextMetadata = null;
1719
- let serviceTier = null;
1752
+ const serviceTier = (_a = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _a : null;
1720
1753
  const generateId3 = this.config.generateId;
1721
1754
  let hasToolCalls = false;
1722
1755
  let currentTextBlockId = null;
@@ -1726,6 +1759,34 @@ var GoogleGenerativeAILanguageModel = class {
1726
1759
  let lastCodeExecutionToolCallId;
1727
1760
  let lastServerToolCallId;
1728
1761
  const activeStreamingToolCalls = [];
1762
+ const finishActiveStreamingToolCall = (controller) => {
1763
+ const active = activeStreamingToolCalls.pop();
1764
+ if (active == null) {
1765
+ return;
1766
+ }
1767
+ const { finalJSON, closingDelta } = active.accumulator.finalize();
1768
+ if (closingDelta.length > 0) {
1769
+ controller.enqueue({
1770
+ type: "tool-input-delta",
1771
+ id: active.toolCallId,
1772
+ delta: closingDelta,
1773
+ providerMetadata: active.providerMetadata
1774
+ });
1775
+ }
1776
+ controller.enqueue({
1777
+ type: "tool-input-end",
1778
+ id: active.toolCallId,
1779
+ providerMetadata: active.providerMetadata
1780
+ });
1781
+ controller.enqueue({
1782
+ type: "tool-call",
1783
+ toolCallId: active.toolCallId,
1784
+ toolName: active.toolName,
1785
+ input: finalJSON,
1786
+ providerMetadata: active.providerMetadata
1787
+ });
1788
+ hasToolCalls = true;
1789
+ };
1729
1790
  return {
1730
1791
  stream: response.pipeThrough(
1731
1792
  new TransformStream({
@@ -1733,7 +1794,7 @@ var GoogleGenerativeAILanguageModel = class {
1733
1794
  controller.enqueue({ type: "stream-start", warnings });
1734
1795
  },
1735
1796
  transform(chunk, controller) {
1736
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1797
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1737
1798
  if (options.includeRawChunks) {
1738
1799
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1739
1800
  }
@@ -1746,10 +1807,7 @@ var GoogleGenerativeAILanguageModel = class {
1746
1807
  if (usageMetadata != null) {
1747
1808
  usage = usageMetadata;
1748
1809
  }
1749
- if (value.serviceTier != null) {
1750
- serviceTier = value.serviceTier;
1751
- }
1752
- const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
1810
+ const candidate = (_a2 = value.candidates) == null ? void 0 : _a2[0];
1753
1811
  if (candidate == null) {
1754
1812
  return;
1755
1813
  }
@@ -1938,7 +1996,7 @@ var GoogleGenerativeAILanguageModel = class {
1938
1996
  const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
1939
1997
  const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
1940
1998
  if (isStreamingChunk) {
1941
- if (part.functionCall.name != null && part.functionCall.willContinue === true) {
1999
+ if (part.functionCall.name != null) {
1942
2000
  const toolCallId = (_i = part.functionCall.id) != null ? _i : generateId3();
1943
2001
  const accumulator = new GoogleJSONAccumulator();
1944
2002
  activeStreamingToolCalls.push({
@@ -1954,9 +2012,8 @@ var GoogleGenerativeAILanguageModel = class {
1954
2012
  providerMetadata: providerMeta
1955
2013
  });
1956
2014
  if (part.functionCall.partialArgs != null) {
1957
- const { textDelta } = accumulator.processPartialArgs(
1958
- part.functionCall.partialArgs
1959
- );
2015
+ const partialArgs = part.functionCall.partialArgs;
2016
+ const { textDelta } = accumulator.processPartialArgs(partialArgs);
1960
2017
  if (textDelta.length > 0) {
1961
2018
  controller.enqueue({
1962
2019
  type: "tool-input-delta",
@@ -1965,12 +2022,14 @@ var GoogleGenerativeAILanguageModel = class {
1965
2022
  providerMetadata: providerMeta
1966
2023
  });
1967
2024
  }
2025
+ if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
2026
+ finishActiveStreamingToolCall(controller);
2027
+ }
1968
2028
  }
1969
2029
  } else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
1970
2030
  const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
1971
- const { textDelta } = active.accumulator.processPartialArgs(
1972
- part.functionCall.partialArgs
1973
- );
2031
+ const partialArgs = part.functionCall.partialArgs;
2032
+ const { textDelta } = active.accumulator.processPartialArgs(partialArgs);
1974
2033
  if (textDelta.length > 0) {
1975
2034
  controller.enqueue({
1976
2035
  type: "tool-input-delta",
@@ -1979,31 +2038,12 @@ var GoogleGenerativeAILanguageModel = class {
1979
2038
  providerMetadata: providerMeta
1980
2039
  });
1981
2040
  }
2041
+ if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
2042
+ finishActiveStreamingToolCall(controller);
2043
+ }
1982
2044
  }
1983
2045
  } else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
1984
- const active = activeStreamingToolCalls.pop();
1985
- const { finalJSON, closingDelta } = active.accumulator.finalize();
1986
- if (closingDelta.length > 0) {
1987
- controller.enqueue({
1988
- type: "tool-input-delta",
1989
- id: active.toolCallId,
1990
- delta: closingDelta,
1991
- providerMetadata: active.providerMetadata
1992
- });
1993
- }
1994
- controller.enqueue({
1995
- type: "tool-input-end",
1996
- id: active.toolCallId,
1997
- providerMetadata: active.providerMetadata
1998
- });
1999
- controller.enqueue({
2000
- type: "tool-call",
2001
- toolCallId: active.toolCallId,
2002
- toolName: active.toolName,
2003
- input: finalJSON,
2004
- providerMetadata: active.providerMetadata
2005
- });
2006
- hasToolCalls = true;
2046
+ finishActiveStreamingToolCall(controller);
2007
2047
  } else if (isCompleteCall) {
2008
2048
  const toolCallId = (_j = part.functionCall.id) != null ? _j : generateId3();
2009
2049
  const toolName = part.functionCall.name;
@@ -2362,8 +2402,7 @@ var responseSchema = (0, import_provider_utils6.lazySchema)(
2362
2402
  promptFeedback: import_v45.z.object({
2363
2403
  blockReason: import_v45.z.string().nullish(),
2364
2404
  safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish()
2365
- }).nullish(),
2366
- serviceTier: import_v45.z.string().nullish()
2405
+ }).nullish()
2367
2406
  })
2368
2407
  )
2369
2408
  );
@@ -2384,8 +2423,7 @@ var chunkSchema = (0, import_provider_utils6.lazySchema)(
2384
2423
  promptFeedback: import_v45.z.object({
2385
2424
  blockReason: import_v45.z.string().nullish(),
2386
2425
  safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish()
2387
- }).nullish(),
2388
- serviceTier: import_v45.z.string().nullish()
2426
+ }).nullish()
2389
2427
  })
2390
2428
  )
2391
2429
  );
@@ -3125,7 +3163,7 @@ function annotationToSource({
3125
3163
  }
3126
3164
  case "file_citation": {
3127
3165
  const a = annotation;
3128
- const uri = (_b = (_a = a.document_uri) != null ? _a : a.source) != null ? _b : a.file_name;
3166
+ const uri = (_b = (_a = a.url) != null ? _a : a.document_uri) != null ? _b : a.file_name;
3129
3167
  if (uri == null || uri.length === 0) return void 0;
3130
3168
  if (uri.startsWith("http://") || uri.startsWith("https://")) {
3131
3169
  return {
@@ -3219,7 +3257,7 @@ function builtinToolResultToSources({
3219
3257
  for (const raw of result) {
3220
3258
  if (raw == null || typeof raw !== "object") continue;
3221
3259
  const entry = raw;
3222
- const uri = (_g = (_f = entry.document_uri) != null ? _f : entry.source) != null ? _g : entry.file_name;
3260
+ const uri = (_g = (_f = entry.url) != null ? _f : entry.document_uri) != null ? _g : entry.file_name;
3223
3261
  if (uri == null || uri.length === 0) continue;
3224
3262
  if (uri.startsWith("http://") || uri.startsWith("https://")) {
3225
3263
  sources.push({
@@ -3335,7 +3373,7 @@ function buildGoogleInteractionsStreamTransform({
3335
3373
  controller.enqueue({ type: "stream-start", warnings });
3336
3374
  },
3337
3375
  transform(chunk, controller) {
3338
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
3376
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
3339
3377
  if (includeRawChunks) {
3340
3378
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3341
3379
  }
@@ -3347,7 +3385,7 @@ function buildGoogleInteractionsStreamTransform({
3347
3385
  const value = chunk.value;
3348
3386
  const eventType = value.event_type;
3349
3387
  switch (eventType) {
3350
- case "interaction.start": {
3388
+ case "interaction.created": {
3351
3389
  const event = value;
3352
3390
  const interaction = event.interaction;
3353
3391
  interactionId = (interaction == null ? void 0 : interaction.id) != null && interaction.id.length > 0 ? interaction.id : void 0;
@@ -3367,91 +3405,106 @@ function buildGoogleInteractionsStreamTransform({
3367
3405
  });
3368
3406
  break;
3369
3407
  }
3370
- case "content.start": {
3408
+ case "step.start": {
3371
3409
  const event = value;
3372
- const block = event.content;
3410
+ const step = event.step;
3373
3411
  const index = event.index;
3374
3412
  const blockId = `${interactionId != null ? interactionId : "interaction"}:${index}`;
3375
- if ((block == null ? void 0 : block.type) === "text") {
3376
- openBlocks.set(index, {
3377
- kind: "text",
3378
- id: blockId,
3379
- emittedSourceKeys: /* @__PURE__ */ new Set()
3380
- });
3381
- controller.enqueue({ type: "text-start", id: blockId });
3382
- const initialSources = annotationsToSources({
3383
- annotations: block.annotations,
3384
- generateId: generateId3
3385
- });
3386
- for (const source of initialSources) {
3387
- const key = sourceKey(source);
3388
- if (emittedSourceKeys.has(key)) continue;
3389
- emittedSourceKeys.add(key);
3390
- controller.enqueue(source);
3413
+ const stepType = step == null ? void 0 : step.type;
3414
+ if (stepType === "model_output") {
3415
+ const initial = (_a = step == null ? void 0 : step.content) == null ? void 0 : _a[0];
3416
+ if ((initial == null ? void 0 : initial.type) === "text") {
3417
+ openBlocks.set(index, {
3418
+ kind: "text",
3419
+ id: blockId,
3420
+ emittedSourceKeys: /* @__PURE__ */ new Set()
3421
+ });
3422
+ controller.enqueue({ type: "text-start", id: blockId });
3423
+ const initialSources = annotationsToSources({
3424
+ annotations: initial.annotations,
3425
+ generateId: generateId3
3426
+ });
3427
+ for (const source of initialSources) {
3428
+ const key = sourceKey(source);
3429
+ if (emittedSourceKeys.has(key)) continue;
3430
+ emittedSourceKeys.add(key);
3431
+ controller.enqueue(source);
3432
+ }
3433
+ } else if ((initial == null ? void 0 : initial.type) === "image") {
3434
+ openBlocks.set(index, {
3435
+ kind: "image",
3436
+ id: blockId,
3437
+ ...initial.data != null ? { data: initial.data } : {},
3438
+ ...initial.mime_type != null ? { mimeType: initial.mime_type } : {},
3439
+ ...initial.uri != null ? { uri: initial.uri } : {}
3440
+ });
3441
+ } else {
3442
+ openBlocks.set(index, {
3443
+ kind: "pending_model_output",
3444
+ id: blockId
3445
+ });
3391
3446
  }
3392
- } else if ((block == null ? void 0 : block.type) === "image") {
3393
- const img = block;
3394
- openBlocks.set(index, {
3395
- kind: "image",
3396
- id: blockId,
3397
- ...img.data != null ? { data: img.data } : {},
3398
- ...img.mime_type != null ? { mimeType: img.mime_type } : {},
3399
- ...img.uri != null ? { uri: img.uri } : {}
3400
- });
3401
- } else if ((block == null ? void 0 : block.type) === "thought") {
3402
- const signature = block.signature;
3447
+ } else if (stepType === "thought") {
3448
+ const signature = step == null ? void 0 : step.signature;
3403
3449
  openBlocks.set(index, {
3404
3450
  kind: "reasoning",
3405
3451
  id: blockId,
3406
3452
  ...signature != null ? { signature } : {}
3407
3453
  });
3408
3454
  controller.enqueue({ type: "reasoning-start", id: blockId });
3409
- } else if ((block == null ? void 0 : block.type) === "function_call") {
3410
- const fc = block;
3411
- const toolCallId = (_a = fc.id) != null ? _a : blockId;
3455
+ if (Array.isArray(step == null ? void 0 : step.summary)) {
3456
+ for (const item of step.summary) {
3457
+ if ((item == null ? void 0 : item.type) === "text" && typeof item.text === "string") {
3458
+ controller.enqueue({
3459
+ type: "reasoning-delta",
3460
+ id: blockId,
3461
+ delta: item.text
3462
+ });
3463
+ }
3464
+ }
3465
+ }
3466
+ } else if (stepType === "function_call") {
3467
+ const toolCallId = (_b = step == null ? void 0 : step.id) != null ? _b : blockId;
3468
+ const toolName = (_c = step == null ? void 0 : step.name) != null ? _c : "unknown";
3412
3469
  hasFunctionCall = true;
3413
3470
  const state = {
3414
3471
  kind: "function_call",
3415
3472
  id: blockId,
3416
3473
  toolCallId,
3417
- toolName: fc.name,
3418
- arguments: (_b = fc.arguments) != null ? _b : {},
3419
- ...fc.signature != null ? { signature: fc.signature } : {},
3420
- startEmitted: false
3474
+ toolName,
3475
+ argumentsAccum: "",
3476
+ ...(step == null ? void 0 : step.signature) != null ? { signature: step.signature } : {}
3421
3477
  };
3422
3478
  openBlocks.set(index, state);
3423
- if (state.toolName != null) {
3424
- controller.enqueue({
3425
- type: "tool-input-start",
3426
- id: toolCallId,
3427
- toolName: state.toolName
3428
- });
3429
- state.startEmitted = true;
3430
- }
3431
- } else if ((block == null ? void 0 : block.type) != null && BUILTIN_TOOL_CALL_TYPES.has(block.type)) {
3432
- const toolName = block.type === "mcp_server_tool_call" ? (_c = block.name) != null ? _c : "mcp_server_tool" : builtinToolNameFromCallType(block.type);
3433
- const toolCallId = (_d = block.id) != null ? _d : blockId;
3479
+ controller.enqueue({
3480
+ type: "tool-input-start",
3481
+ id: toolCallId,
3482
+ toolName
3483
+ });
3484
+ } else if (stepType != null && BUILTIN_TOOL_CALL_TYPES.has(stepType)) {
3485
+ const toolName = stepType === "mcp_server_tool_call" ? (_d = step == null ? void 0 : step.name) != null ? _d : "mcp_server_tool" : builtinToolNameFromCallType(stepType);
3486
+ const toolCallId = (_e = step == null ? void 0 : step.id) != null ? _e : blockId;
3434
3487
  const state = {
3435
3488
  kind: "builtin_tool_call",
3436
3489
  id: blockId,
3437
- blockType: block.type,
3490
+ blockType: stepType,
3438
3491
  toolCallId,
3439
3492
  toolName,
3440
- arguments: (_e = block.arguments) != null ? _e : {},
3493
+ arguments: (_f = step == null ? void 0 : step.arguments) != null ? _f : {},
3441
3494
  callEmitted: false
3442
3495
  };
3443
3496
  openBlocks.set(index, state);
3444
- } else if ((block == null ? void 0 : block.type) != null && BUILTIN_TOOL_RESULT_TYPES.has(block.type)) {
3445
- const toolName = block.type === "mcp_server_tool_result" ? (_f = block.name) != null ? _f : "mcp_server_tool" : builtinToolNameFromResultType(block.type);
3446
- const callId = (_g = block.call_id) != null ? _g : blockId;
3497
+ } else if (stepType != null && BUILTIN_TOOL_RESULT_TYPES.has(stepType)) {
3498
+ const toolName = stepType === "mcp_server_tool_result" ? (_g = step == null ? void 0 : step.name) != null ? _g : "mcp_server_tool" : builtinToolNameFromResultType(stepType);
3499
+ const callId = (_h = step == null ? void 0 : step.call_id) != null ? _h : blockId;
3447
3500
  const state = {
3448
3501
  kind: "builtin_tool_result",
3449
3502
  id: blockId,
3450
- blockType: block.type,
3503
+ blockType: stepType,
3451
3504
  callId,
3452
3505
  toolName,
3453
- result: (_h = block.result) != null ? _h : null,
3454
- ...block.is_error != null ? { isError: block.is_error } : {},
3506
+ result: (_i = step == null ? void 0 : step.result) != null ? _i : null,
3507
+ ...(step == null ? void 0 : step.is_error) != null ? { isError: step.is_error } : {},
3455
3508
  resultEmitted: false
3456
3509
  };
3457
3510
  openBlocks.set(index, state);
@@ -3460,13 +3513,58 @@ function buildGoogleInteractionsStreamTransform({
3460
3513
  }
3461
3514
  break;
3462
3515
  }
3463
- case "content.delta": {
3516
+ case "step.delta": {
3464
3517
  const event = value;
3465
- const open = openBlocks.get(event.index);
3518
+ let open = openBlocks.get(event.index);
3466
3519
  if (open == null) break;
3520
+ const dtype = (_j = event.delta) == null ? void 0 : _j.type;
3521
+ if (open.kind === "pending_model_output") {
3522
+ if (dtype === "text" || dtype === "text_annotation" || dtype === "text_annotation_delta") {
3523
+ const promoted = {
3524
+ kind: "text",
3525
+ id: open.id,
3526
+ emittedSourceKeys: /* @__PURE__ */ new Set()
3527
+ };
3528
+ openBlocks.set(event.index, promoted);
3529
+ open = promoted;
3530
+ controller.enqueue({ type: "text-start", id: promoted.id });
3531
+ }
3532
+ }
3533
+ if (dtype === "image" && (open.kind === "pending_model_output" || open.kind === "text" || open.kind === "image")) {
3534
+ const img = event.delta;
3535
+ const google2 = {};
3536
+ if (interactionId != null) google2.interactionId = interactionId;
3537
+ const providerMetadata = Object.keys(google2).length > 0 ? { google: google2 } : void 0;
3538
+ if ((img == null ? void 0 : img.data) != null && img.data.length > 0) {
3539
+ controller.enqueue({
3540
+ type: "file",
3541
+ mediaType: (_k = img.mime_type) != null ? _k : "image/png",
3542
+ data: img.data,
3543
+ ...providerMetadata ? { providerMetadata } : {}
3544
+ });
3545
+ } else if ((img == null ? void 0 : img.uri) != null && img.uri.length > 0) {
3546
+ const uriProviderMetadata = {
3547
+ google: {
3548
+ ...interactionId != null ? { interactionId } : {},
3549
+ imageUri: img.uri
3550
+ }
3551
+ };
3552
+ controller.enqueue({
3553
+ type: "file",
3554
+ mediaType: (_l = img.mime_type) != null ? _l : "image/png",
3555
+ data: "",
3556
+ providerMetadata: uriProviderMetadata
3557
+ });
3558
+ }
3559
+ if (open.kind === "image") {
3560
+ open.data = void 0;
3561
+ open.uri = void 0;
3562
+ }
3563
+ break;
3564
+ }
3467
3565
  const delta = event.delta;
3468
3566
  if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
3469
- const text = (_i = delta.text) != null ? _i : "";
3567
+ const text = (_m = delta.text) != null ? _m : "";
3470
3568
  if (text.length > 0) {
3471
3569
  controller.enqueue({
3472
3570
  type: "text-delta",
@@ -3474,7 +3572,7 @@ function buildGoogleInteractionsStreamTransform({
3474
3572
  delta: text
3475
3573
  });
3476
3574
  }
3477
- } else if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text_annotation") {
3575
+ } else if (open.kind === "text" && ((delta == null ? void 0 : delta.type) === "text_annotation" || (delta == null ? void 0 : delta.type) === "text_annotation_delta")) {
3478
3576
  const sources = annotationsToSources({
3479
3577
  annotations: delta.annotations,
3480
3578
  generateId: generateId3
@@ -3506,31 +3604,28 @@ function buildGoogleInteractionsStreamTransform({
3506
3604
  open.signature = signature;
3507
3605
  }
3508
3606
  }
3509
- } else if (open.kind === "function_call" && (delta == null ? void 0 : delta.type) === "function_call") {
3607
+ } else if (open.kind === "function_call" && (delta == null ? void 0 : delta.type) === "arguments_delta") {
3608
+ const slice = typeof delta.arguments === "string" ? delta.arguments : "";
3609
+ if (slice.length > 0) {
3610
+ open.argumentsAccum += slice;
3611
+ controller.enqueue({
3612
+ type: "tool-input-delta",
3613
+ id: open.toolCallId,
3614
+ delta: slice
3615
+ });
3616
+ }
3510
3617
  if (delta.id != null) {
3511
3618
  open.toolCallId = delta.id;
3512
3619
  }
3513
- if (delta.name != null) {
3514
- open.toolName = delta.name;
3515
- }
3516
- if (delta.arguments != null) {
3517
- open.arguments = delta.arguments;
3518
- }
3519
3620
  if (delta.signature != null) {
3520
3621
  open.signature = delta.signature;
3521
3622
  }
3522
- if (!open.startEmitted && open.toolName != null) {
3523
- controller.enqueue({
3524
- type: "tool-input-start",
3525
- id: open.toolCallId,
3526
- toolName: open.toolName
3527
- });
3528
- open.startEmitted = true;
3529
- }
3530
3623
  hasFunctionCall = true;
3531
3624
  } else if (open.kind === "builtin_tool_call" && (delta == null ? void 0 : delta.type) === open.blockType) {
3532
3625
  if (delta.id != null) open.toolCallId = delta.id;
3533
- if (delta.arguments != null) open.arguments = delta.arguments;
3626
+ if (delta.arguments != null && typeof delta.arguments === "object") {
3627
+ open.arguments = delta.arguments;
3628
+ }
3534
3629
  if (delta.name != null && open.blockType === "mcp_server_tool_call") {
3535
3630
  open.toolName = delta.name;
3536
3631
  }
@@ -3544,7 +3639,7 @@ function buildGoogleInteractionsStreamTransform({
3544
3639
  }
3545
3640
  break;
3546
3641
  }
3547
- case "content.stop": {
3642
+ case "step.stop": {
3548
3643
  const event = value;
3549
3644
  const open = openBlocks.get(event.index);
3550
3645
  if (open == null) break;
@@ -3572,7 +3667,7 @@ function buildGoogleInteractionsStreamTransform({
3572
3667
  if (open.data != null && open.data.length > 0) {
3573
3668
  controller.enqueue({
3574
3669
  type: "file",
3575
- mediaType: (_j = open.mimeType) != null ? _j : "image/png",
3670
+ mediaType: (_n = open.mimeType) != null ? _n : "image/png",
3576
3671
  data: open.data,
3577
3672
  ...providerMetadata ? { providerMetadata } : {}
3578
3673
  });
@@ -3585,26 +3680,13 @@ function buildGoogleInteractionsStreamTransform({
3585
3680
  };
3586
3681
  controller.enqueue({
3587
3682
  type: "file",
3588
- mediaType: (_k = open.mimeType) != null ? _k : "image/png",
3683
+ mediaType: (_o = open.mimeType) != null ? _o : "image/png",
3589
3684
  data: "",
3590
3685
  providerMetadata: uriProviderMetadata
3591
3686
  });
3592
3687
  }
3593
3688
  } else if (open.kind === "function_call") {
3594
- const toolName = (_l = open.toolName) != null ? _l : "unknown";
3595
- const argsJson = JSON.stringify((_m = open.arguments) != null ? _m : {});
3596
- if (!open.startEmitted) {
3597
- controller.enqueue({
3598
- type: "tool-input-start",
3599
- id: open.toolCallId,
3600
- toolName
3601
- });
3602
- }
3603
- controller.enqueue({
3604
- type: "tool-input-delta",
3605
- id: open.toolCallId,
3606
- delta: argsJson
3607
- });
3689
+ const accumulated = open.argumentsAccum.length > 0 ? open.argumentsAccum : "{}";
3608
3690
  controller.enqueue({
3609
3691
  type: "tool-input-end",
3610
3692
  id: open.toolCallId
@@ -3616,8 +3698,8 @@ function buildGoogleInteractionsStreamTransform({
3616
3698
  controller.enqueue({
3617
3699
  type: "tool-call",
3618
3700
  toolCallId: open.toolCallId,
3619
- toolName,
3620
- input: argsJson,
3701
+ toolName: open.toolName,
3702
+ input: accumulated,
3621
3703
  ...providerMetadata ? { providerMetadata } : {}
3622
3704
  });
3623
3705
  } else if (open.kind === "builtin_tool_call" && !open.callEmitted) {
@@ -3625,7 +3707,7 @@ function buildGoogleInteractionsStreamTransform({
3625
3707
  type: "tool-call",
3626
3708
  toolCallId: open.toolCallId,
3627
3709
  toolName: open.toolName,
3628
- input: JSON.stringify((_n = open.arguments) != null ? _n : {}),
3710
+ input: JSON.stringify((_p = open.arguments) != null ? _p : {}),
3629
3711
  providerExecuted: true
3630
3712
  });
3631
3713
  open.callEmitted = true;
@@ -3634,7 +3716,7 @@ function buildGoogleInteractionsStreamTransform({
3634
3716
  type: "tool-result",
3635
3717
  toolCallId: open.callId,
3636
3718
  toolName: open.toolName,
3637
- result: (_o = open.result) != null ? _o : null
3719
+ result: (_q = open.result) != null ? _q : null
3638
3720
  });
3639
3721
  open.resultEmitted = true;
3640
3722
  const sources = builtinToolResultToSources({
@@ -3655,12 +3737,20 @@ function buildGoogleInteractionsStreamTransform({
3655
3737
  openBlocks.delete(event.index);
3656
3738
  break;
3657
3739
  }
3658
- case "interaction.status_update": {
3740
+ case "interaction.status_update":
3741
+ case "interaction.in_progress":
3742
+ case "interaction.requires_action": {
3659
3743
  const event = value;
3660
- finishStatus = event.status;
3744
+ if (event.status != null) {
3745
+ finishStatus = event.status;
3746
+ } else if (eventType === "interaction.requires_action") {
3747
+ finishStatus = "requires_action";
3748
+ } else {
3749
+ finishStatus = "in_progress";
3750
+ }
3661
3751
  break;
3662
3752
  }
3663
- case "interaction.complete": {
3753
+ case "interaction.completed": {
3664
3754
  const event = value;
3665
3755
  const interaction = event.interaction;
3666
3756
  if ((interaction == null ? void 0 : interaction.id) != null && interaction.id.length > 0) {
@@ -3680,7 +3770,7 @@ function buildGoogleInteractionsStreamTransform({
3680
3770
  case "error": {
3681
3771
  const event = value;
3682
3772
  finishStatus = "failed";
3683
- const errorPayload = (_p = event.error) != null ? _p : {
3773
+ const errorPayload = (_r = event.error) != null ? _r : {
3684
3774
  message: "Unknown interaction error"
3685
3775
  };
3686
3776
  controller.enqueue({ type: "error", error: errorPayload });
@@ -3749,7 +3839,7 @@ function convertToGoogleInteractionsInput({
3749
3839
  previousInteractionId
3750
3840
  }) : prompt;
3751
3841
  const systemTexts = [];
3752
- const turns = [];
3842
+ const steps = [];
3753
3843
  for (const message of compactedPrompt) {
3754
3844
  switch (message.role) {
3755
3845
  case "system": {
@@ -3760,11 +3850,7 @@ function convertToGoogleInteractionsInput({
3760
3850
  const content = [];
3761
3851
  for (const part of message.content) {
3762
3852
  if (part.type === "text") {
3763
- const block = {
3764
- type: "text",
3765
- text: part.text
3766
- };
3767
- content.push(block);
3853
+ content.push({ type: "text", text: part.text });
3768
3854
  } else if (part.type === "file") {
3769
3855
  const fileBlock = convertFilePartToContent({
3770
3856
  part,
@@ -3778,18 +3864,25 @@ function convertToGoogleInteractionsInput({
3778
3864
  }
3779
3865
  const merged = mergeAdjacentTextContent(content);
3780
3866
  if (merged.length > 0) {
3781
- turns.push({ role: "user", content: merged });
3867
+ steps.push({ type: "user_input", content: merged });
3782
3868
  }
3783
3869
  break;
3784
3870
  }
3785
3871
  case "assistant": {
3786
- const content = [];
3872
+ let pendingModelOutput = [];
3873
+ const flushModelOutput = () => {
3874
+ if (pendingModelOutput.length > 0) {
3875
+ steps.push({ type: "model_output", content: pendingModelOutput });
3876
+ pendingModelOutput = [];
3877
+ }
3878
+ };
3787
3879
  for (const part of message.content) {
3788
3880
  if (part.type === "text") {
3789
- content.push({ type: "text", text: part.text });
3881
+ pendingModelOutput.push({ type: "text", text: part.text });
3790
3882
  } else if (part.type === "reasoning") {
3883
+ flushModelOutput();
3791
3884
  const signature = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.signature;
3792
- content.push({
3885
+ steps.push({
3793
3886
  type: "thought",
3794
3887
  ...signature != null ? { signature } : {},
3795
3888
  summary: part.text.length > 0 ? [{ type: "text", text: part.text }] : void 0
@@ -3801,12 +3894,13 @@ function convertToGoogleInteractionsInput({
3801
3894
  mediaResolution
3802
3895
  });
3803
3896
  if (fileBlock != null) {
3804
- content.push(fileBlock);
3897
+ pendingModelOutput.push(fileBlock);
3805
3898
  }
3806
3899
  } else if (part.type === "tool-call") {
3900
+ flushModelOutput();
3807
3901
  const signature = (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.signature;
3808
3902
  const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : (_e = part.input) != null ? _e : {};
3809
- content.push({
3903
+ steps.push({
3810
3904
  type: "function_call",
3811
3905
  id: part.toolCallId,
3812
3906
  name: part.toolName,
@@ -3820,9 +3914,7 @@ function convertToGoogleInteractionsInput({
3820
3914
  });
3821
3915
  }
3822
3916
  }
3823
- if (content.length > 0) {
3824
- turns.push({ role: "model", content });
3825
- }
3917
+ flushModelOutput();
3826
3918
  break;
3827
3919
  }
3828
3920
  case "tool": {
@@ -3845,22 +3937,14 @@ function convertToGoogleInteractionsInput({
3845
3937
  content.push(block);
3846
3938
  }
3847
3939
  if (content.length > 0) {
3848
- turns.push({ role: "user", content });
3940
+ steps.push({ type: "user_input", content });
3849
3941
  }
3850
3942
  break;
3851
3943
  }
3852
3944
  }
3853
3945
  }
3854
3946
  const systemInstruction = systemTexts.length > 0 ? systemTexts.join("\n\n") : void 0;
3855
- let input;
3856
- if (turns.length === 0) {
3857
- input = "";
3858
- } else if (turns.length === 1 && turns[0].role === "user" && Array.isArray(turns[0].content)) {
3859
- input = turns[0].content;
3860
- } else {
3861
- input = turns;
3862
- }
3863
- return { input, systemInstruction, warnings };
3947
+ return { input: steps, systemInstruction, warnings };
3864
3948
  }
3865
3949
  function convertFilePartToContent({
3866
3950
  part,
@@ -4155,7 +4239,7 @@ var annotationSchema = () => {
4155
4239
  type: import_v415.z.literal("file_citation"),
4156
4240
  file_name: import_v415.z.string().nullish(),
4157
4241
  document_uri: import_v415.z.string().nullish(),
4158
- source: import_v415.z.string().nullish(),
4242
+ url: import_v415.z.string().nullish(),
4159
4243
  page_number: import_v415.z.number().nullish(),
4160
4244
  media_id: import_v415.z.string().nullish(),
4161
4245
  start_index: import_v415.z.number().nullish(),
@@ -4189,34 +4273,58 @@ var contentBlockSchema = () => {
4189
4273
  text: import_v415.z.string(),
4190
4274
  annotations: import_v415.z.array(annotationSchema()).nullish()
4191
4275
  }).loose();
4192
- const thoughtContent = import_v415.z.object({
4193
- type: import_v415.z.literal("thought"),
4194
- signature: import_v415.z.string().nullish(),
4195
- summary: import_v415.z.array(thoughtSummaryItemSchema()).nullish()
4276
+ const imageContent = import_v415.z.object({
4277
+ type: import_v415.z.literal("image"),
4278
+ data: import_v415.z.string().nullish(),
4279
+ mime_type: import_v415.z.string().nullish(),
4280
+ resolution: import_v415.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
4281
+ uri: import_v415.z.string().nullish()
4282
+ }).loose();
4283
+ return import_v415.z.union([
4284
+ textContent,
4285
+ imageContent,
4286
+ import_v415.z.object({ type: import_v415.z.string() }).loose()
4287
+ ]);
4288
+ };
4289
+ var BUILTIN_TOOL_CALL_STEP_TYPES = [
4290
+ "google_search_call",
4291
+ "code_execution_call",
4292
+ "url_context_call",
4293
+ "file_search_call",
4294
+ "google_maps_call",
4295
+ "mcp_server_tool_call"
4296
+ ];
4297
+ var BUILTIN_TOOL_RESULT_STEP_TYPES = [
4298
+ "google_search_result",
4299
+ "code_execution_result",
4300
+ "url_context_result",
4301
+ "file_search_result",
4302
+ "google_maps_result",
4303
+ "mcp_server_tool_result"
4304
+ ];
4305
+ var stepSchema = () => {
4306
+ const userInputStep = import_v415.z.object({
4307
+ type: import_v415.z.literal("user_input"),
4308
+ content: import_v415.z.array(contentBlockSchema()).nullish()
4309
+ }).loose();
4310
+ const modelOutputStep = import_v415.z.object({
4311
+ type: import_v415.z.literal("model_output"),
4312
+ content: import_v415.z.array(contentBlockSchema()).nullish()
4196
4313
  }).loose();
4197
- const functionCallContent = import_v415.z.object({
4314
+ const functionCallStep = import_v415.z.object({
4198
4315
  type: import_v415.z.literal("function_call"),
4199
4316
  id: import_v415.z.string(),
4200
4317
  name: import_v415.z.string(),
4201
4318
  arguments: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()).nullish(),
4202
4319
  signature: import_v415.z.string().nullish()
4203
4320
  }).loose();
4204
- const imageContent = import_v415.z.object({
4205
- type: import_v415.z.literal("image"),
4206
- data: import_v415.z.string().nullish(),
4207
- mime_type: import_v415.z.string().nullish(),
4208
- resolution: import_v415.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
4209
- uri: import_v415.z.string().nullish()
4321
+ const thoughtStep = import_v415.z.object({
4322
+ type: import_v415.z.literal("thought"),
4323
+ signature: import_v415.z.string().nullish(),
4324
+ summary: import_v415.z.array(thoughtSummaryItemSchema()).nullish()
4210
4325
  }).loose();
4211
- const builtinToolCall = import_v415.z.object({
4212
- type: import_v415.z.enum([
4213
- "google_search_call",
4214
- "code_execution_call",
4215
- "url_context_call",
4216
- "file_search_call",
4217
- "google_maps_call",
4218
- "mcp_server_tool_call"
4219
- ]),
4326
+ const builtinToolCallStep = import_v415.z.object({
4327
+ type: import_v415.z.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
4220
4328
  id: import_v415.z.string(),
4221
4329
  arguments: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()).nullish(),
4222
4330
  name: import_v415.z.string().nullish(),
@@ -4224,15 +4332,8 @@ var contentBlockSchema = () => {
4224
4332
  search_type: import_v415.z.string().nullish(),
4225
4333
  signature: import_v415.z.string().nullish()
4226
4334
  }).loose();
4227
- const builtinToolResult = import_v415.z.object({
4228
- type: import_v415.z.enum([
4229
- "google_search_result",
4230
- "code_execution_result",
4231
- "url_context_result",
4232
- "file_search_result",
4233
- "google_maps_result",
4234
- "mcp_server_tool_result"
4235
- ]),
4335
+ const builtinToolResultStep = import_v415.z.object({
4336
+ type: import_v415.z.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
4236
4337
  call_id: import_v415.z.string(),
4237
4338
  result: import_v415.z.unknown().nullish(),
4238
4339
  is_error: import_v415.z.boolean().nullish(),
@@ -4241,12 +4342,12 @@ var contentBlockSchema = () => {
4241
4342
  signature: import_v415.z.string().nullish()
4242
4343
  }).loose();
4243
4344
  return import_v415.z.union([
4244
- textContent,
4245
- imageContent,
4246
- thoughtContent,
4247
- functionCallContent,
4248
- builtinToolCall,
4249
- builtinToolResult,
4345
+ userInputStep,
4346
+ modelOutputStep,
4347
+ functionCallStep,
4348
+ thoughtStep,
4349
+ builtinToolCallStep,
4350
+ builtinToolResultStep,
4250
4351
  import_v415.z.object({ type: import_v415.z.string() }).loose()
4251
4352
  ]);
4252
4353
  };
@@ -4264,7 +4365,7 @@ var googleInteractionsResponseSchema = (0, import_provider_utils17.lazySchema)(
4264
4365
  status: interactionStatusSchema(),
4265
4366
  model: import_v415.z.string().nullish(),
4266
4367
  agent: import_v415.z.string().nullish(),
4267
- outputs: import_v415.z.array(contentBlockSchema()).nullish(),
4368
+ steps: import_v415.z.array(stepSchema()).nullish(),
4268
4369
  usage: usageSchema2().nullish(),
4269
4370
  service_tier: import_v415.z.string().nullish(),
4270
4371
  previous_interaction_id: import_v415.z.string().nullish(),
@@ -4278,8 +4379,8 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
4278
4379
  const status = interactionStatusSchema();
4279
4380
  const annotation = annotationSchema();
4280
4381
  const thoughtSummaryItem = thoughtSummaryItemSchema();
4281
- const interactionStartEvent = import_v415.z.object({
4282
- event_type: import_v415.z.literal("interaction.start"),
4382
+ const interactionCreatedEvent = import_v415.z.object({
4383
+ event_type: import_v415.z.literal("interaction.created"),
4283
4384
  event_id: import_v415.z.string().nullish(),
4284
4385
  interaction: import_v415.z.object({
4285
4386
  /*
@@ -4293,94 +4394,79 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
4293
4394
  status: status.nullish()
4294
4395
  }).loose()
4295
4396
  }).loose();
4296
- const contentStartEvent = import_v415.z.object({
4297
- event_type: import_v415.z.literal("content.start"),
4397
+ const stepStartEvent = import_v415.z.object({
4398
+ event_type: import_v415.z.literal("step.start"),
4298
4399
  event_id: import_v415.z.string().nullish(),
4299
4400
  index: import_v415.z.number(),
4300
- content: contentBlockSchema()
4401
+ step: stepSchema()
4301
4402
  }).loose();
4302
- const contentDeltaText = import_v415.z.object({
4403
+ const stepDeltaText = import_v415.z.object({
4303
4404
  type: import_v415.z.literal("text"),
4304
4405
  text: import_v415.z.string()
4305
4406
  }).loose();
4306
- const contentDeltaThoughtSummary = import_v415.z.object({
4407
+ const stepDeltaThoughtSummary = import_v415.z.object({
4307
4408
  type: import_v415.z.literal("thought_summary"),
4308
4409
  content: thoughtSummaryItem.nullish()
4309
4410
  }).loose();
4310
- const contentDeltaThoughtSignature = import_v415.z.object({
4411
+ const stepDeltaThoughtSignature = import_v415.z.object({
4311
4412
  type: import_v415.z.literal("thought_signature"),
4312
4413
  signature: import_v415.z.string().nullish()
4313
4414
  }).loose();
4314
- const contentDeltaFunctionCall = import_v415.z.object({
4315
- type: import_v415.z.literal("function_call"),
4316
- id: import_v415.z.string(),
4317
- name: import_v415.z.string(),
4318
- arguments: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()).nullish(),
4415
+ const stepDeltaArgumentsDelta = import_v415.z.object({
4416
+ type: import_v415.z.literal("arguments_delta"),
4417
+ arguments: import_v415.z.string().nullish(),
4418
+ id: import_v415.z.string().nullish(),
4319
4419
  signature: import_v415.z.string().nullish()
4320
4420
  }).loose();
4321
- const contentDeltaTextAnnotation = import_v415.z.object({
4322
- type: import_v415.z.literal("text_annotation"),
4421
+ const stepDeltaTextAnnotation = import_v415.z.object({
4422
+ type: import_v415.z.enum(["text_annotation_delta", "text_annotation"]),
4323
4423
  annotations: import_v415.z.array(annotation).nullish()
4324
4424
  }).loose();
4325
- const contentDeltaImage = import_v415.z.object({
4425
+ const stepDeltaImage = import_v415.z.object({
4326
4426
  type: import_v415.z.literal("image"),
4327
4427
  data: import_v415.z.string().nullish(),
4328
4428
  mime_type: import_v415.z.string().nullish(),
4329
4429
  resolution: import_v415.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
4330
4430
  uri: import_v415.z.string().nullish()
4331
4431
  }).loose();
4332
- const contentDeltaBuiltinToolCall = import_v415.z.object({
4333
- type: import_v415.z.enum([
4334
- "google_search_call",
4335
- "code_execution_call",
4336
- "url_context_call",
4337
- "file_search_call",
4338
- "google_maps_call",
4339
- "mcp_server_tool_call"
4340
- ]),
4341
- id: import_v415.z.string(),
4432
+ const stepDeltaBuiltinToolCall = import_v415.z.object({
4433
+ type: import_v415.z.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
4434
+ id: import_v415.z.string().nullish(),
4342
4435
  arguments: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()).nullish(),
4343
4436
  name: import_v415.z.string().nullish(),
4344
4437
  server_name: import_v415.z.string().nullish(),
4345
4438
  search_type: import_v415.z.string().nullish(),
4346
4439
  signature: import_v415.z.string().nullish()
4347
4440
  }).loose();
4348
- const contentDeltaBuiltinToolResult = import_v415.z.object({
4349
- type: import_v415.z.enum([
4350
- "google_search_result",
4351
- "code_execution_result",
4352
- "url_context_result",
4353
- "file_search_result",
4354
- "google_maps_result",
4355
- "mcp_server_tool_result"
4356
- ]),
4357
- call_id: import_v415.z.string(),
4441
+ const stepDeltaBuiltinToolResult = import_v415.z.object({
4442
+ type: import_v415.z.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
4443
+ call_id: import_v415.z.string().nullish(),
4358
4444
  result: import_v415.z.unknown().nullish(),
4359
4445
  is_error: import_v415.z.boolean().nullish(),
4360
4446
  name: import_v415.z.string().nullish(),
4361
4447
  server_name: import_v415.z.string().nullish(),
4362
4448
  signature: import_v415.z.string().nullish()
4363
4449
  }).loose();
4364
- const contentDeltaUnknown = import_v415.z.object({ type: import_v415.z.string() }).loose();
4365
- const contentDeltaUnion = import_v415.z.union([
4366
- contentDeltaText,
4367
- contentDeltaImage,
4368
- contentDeltaThoughtSummary,
4369
- contentDeltaThoughtSignature,
4370
- contentDeltaFunctionCall,
4371
- contentDeltaTextAnnotation,
4372
- contentDeltaBuiltinToolCall,
4373
- contentDeltaBuiltinToolResult,
4374
- contentDeltaUnknown
4450
+ const stepDeltaUnknown = import_v415.z.object({ type: import_v415.z.string() }).loose();
4451
+ const stepDeltaUnion = import_v415.z.union([
4452
+ stepDeltaText,
4453
+ stepDeltaImage,
4454
+ stepDeltaThoughtSummary,
4455
+ stepDeltaThoughtSignature,
4456
+ stepDeltaArgumentsDelta,
4457
+ stepDeltaTextAnnotation,
4458
+ stepDeltaBuiltinToolCall,
4459
+ stepDeltaBuiltinToolResult,
4460
+ stepDeltaUnknown
4375
4461
  ]);
4376
- const contentDeltaEvent = import_v415.z.object({
4377
- event_type: import_v415.z.literal("content.delta"),
4462
+ const stepDeltaEvent = import_v415.z.object({
4463
+ event_type: import_v415.z.literal("step.delta"),
4378
4464
  event_id: import_v415.z.string().nullish(),
4379
4465
  index: import_v415.z.number(),
4380
- delta: contentDeltaUnion
4466
+ delta: stepDeltaUnion
4381
4467
  }).loose();
4382
- const contentStopEvent = import_v415.z.object({
4383
- event_type: import_v415.z.literal("content.stop"),
4468
+ const stepStopEvent = import_v415.z.object({
4469
+ event_type: import_v415.z.literal("step.stop"),
4384
4470
  event_id: import_v415.z.string().nullish(),
4385
4471
  index: import_v415.z.number()
4386
4472
  }).loose();
@@ -4388,10 +4474,22 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
4388
4474
  event_type: import_v415.z.literal("interaction.status_update"),
4389
4475
  event_id: import_v415.z.string().nullish(),
4390
4476
  interaction_id: import_v415.z.string().nullish(),
4391
- status
4477
+ status: status.nullish()
4392
4478
  }).loose();
4393
- const interactionCompleteEvent = import_v415.z.object({
4394
- event_type: import_v415.z.literal("interaction.complete"),
4479
+ const interactionInProgressEvent = import_v415.z.object({
4480
+ event_type: import_v415.z.literal("interaction.in_progress"),
4481
+ event_id: import_v415.z.string().nullish(),
4482
+ interaction_id: import_v415.z.string().nullish(),
4483
+ status: status.nullish()
4484
+ }).loose();
4485
+ const interactionRequiresActionEvent = import_v415.z.object({
4486
+ event_type: import_v415.z.literal("interaction.requires_action"),
4487
+ event_id: import_v415.z.string().nullish(),
4488
+ interaction_id: import_v415.z.string().nullish(),
4489
+ status: status.nullish()
4490
+ }).loose();
4491
+ const interactionCompletedEvent = import_v415.z.object({
4492
+ event_type: import_v415.z.literal("interaction.completed"),
4395
4493
  event_id: import_v415.z.string().nullish(),
4396
4494
  interaction: import_v415.z.object({
4397
4495
  id: import_v415.z.string().nullish(),
@@ -4410,12 +4508,14 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
4410
4508
  }).loose();
4411
4509
  const unknownEvent = import_v415.z.object({ event_type: import_v415.z.string() }).loose();
4412
4510
  return import_v415.z.union([
4413
- interactionStartEvent,
4414
- contentStartEvent,
4415
- contentDeltaEvent,
4416
- contentStopEvent,
4511
+ interactionCreatedEvent,
4512
+ stepStartEvent,
4513
+ stepDeltaEvent,
4514
+ stepStopEvent,
4417
4515
  interactionStatusUpdateEvent,
4418
- interactionCompleteEvent,
4516
+ interactionInProgressEvent,
4517
+ interactionRequiresActionEvent,
4518
+ interactionCompletedEvent,
4419
4519
  errorEvent,
4420
4520
  unknownEvent
4421
4521
  ]);
@@ -4445,6 +4545,55 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
4445
4545
  ]).nullish(),
4446
4546
  thinkingLevel: import_v416.z.enum(["minimal", "low", "medium", "high"]).nullish(),
4447
4547
  thinkingSummaries: import_v416.z.enum(["auto", "none"]).nullish(),
4548
+ /**
4549
+ * Output-format entries that map directly to the API's `response_format`
4550
+ * array. Use this to request image, audio, or non-JSON text outputs
4551
+ * with full control over `mime_type`, `aspect_ratio`, and `image_size`.
4552
+ *
4553
+ * Entries are sent in order. The AI SDK call-level `responseFormat: {
4554
+ * type: 'json', schema }` still drives JSON-mode and adds a matching
4555
+ * text entry automatically; entries listed here are appended.
4556
+ */
4557
+ responseFormat: import_v416.z.array(
4558
+ import_v416.z.union([
4559
+ import_v416.z.object({
4560
+ type: import_v416.z.literal("text"),
4561
+ mimeType: import_v416.z.string().nullish(),
4562
+ schema: import_v416.z.unknown().nullish()
4563
+ }).loose(),
4564
+ import_v416.z.object({
4565
+ type: import_v416.z.literal("image"),
4566
+ mimeType: import_v416.z.string().nullish(),
4567
+ aspectRatio: import_v416.z.enum([
4568
+ "1:1",
4569
+ "2:3",
4570
+ "3:2",
4571
+ "3:4",
4572
+ "4:3",
4573
+ "4:5",
4574
+ "5:4",
4575
+ "9:16",
4576
+ "16:9",
4577
+ "21:9",
4578
+ "1:8",
4579
+ "8:1",
4580
+ "1:4",
4581
+ "4:1"
4582
+ ]).nullish(),
4583
+ imageSize: import_v416.z.enum(["1K", "2K", "4K", "512"]).nullish()
4584
+ }).loose(),
4585
+ import_v416.z.object({
4586
+ type: import_v416.z.literal("audio"),
4587
+ mimeType: import_v416.z.string().nullish()
4588
+ }).loose()
4589
+ ])
4590
+ ).nullish(),
4591
+ /**
4592
+ * @deprecated Use `responseFormat` with a `{ type: 'image', ... }`
4593
+ * entry instead. Retained for backwards compatibility; the SDK
4594
+ * translates it into a matching `response_format` image entry and
4595
+ * emits a warning when set.
4596
+ */
4448
4597
  imageConfig: import_v416.z.object({
4449
4598
  aspectRatio: import_v416.z.enum([
4450
4599
  "1:1",
@@ -4490,7 +4639,61 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
4490
4639
  * call) before giving up. Defaults to 30 minutes. Long-running agents
4491
4640
  * such as deep research can take tens of minutes — increase if needed.
4492
4641
  */
4493
- pollingTimeoutMs: import_v416.z.number().int().positive().nullish()
4642
+ pollingTimeoutMs: import_v416.z.number().int().positive().nullish(),
4643
+ /**
4644
+ * Run the interaction in the background. Required for agents whose
4645
+ * server-side workflow cannot complete within a single request/response.
4646
+ * When `true`, the POST returns with a non-terminal status and the SDK
4647
+ * polls `GET /interactions/{id}` until the work completes. Some agents
4648
+ * reject `true`; see the agent's documentation for which mode it
4649
+ * requires.
4650
+ */
4651
+ background: import_v416.z.boolean().nullish(),
4652
+ /**
4653
+ * Environment configuration for the agent sandbox. Only applies to agent
4654
+ * calls (`google.interactions({ agent })`); ignored on model-id calls.
4655
+ *
4656
+ * - `"remote"`: provision a fresh sandbox for this call.
4657
+ * - any other string: an existing `environment_id` to reuse.
4658
+ * - object: provision a fresh sandbox and optionally preload `sources`
4659
+ * and/or constrain outbound traffic via `network`.
4660
+ */
4661
+ environment: import_v416.z.union([
4662
+ import_v416.z.string(),
4663
+ import_v416.z.object({
4664
+ type: import_v416.z.literal("remote"),
4665
+ sources: import_v416.z.array(
4666
+ import_v416.z.union([
4667
+ import_v416.z.object({
4668
+ type: import_v416.z.literal("gcs"),
4669
+ source: import_v416.z.string(),
4670
+ target: import_v416.z.string().nullish()
4671
+ }),
4672
+ import_v416.z.object({
4673
+ type: import_v416.z.literal("repository"),
4674
+ source: import_v416.z.string(),
4675
+ target: import_v416.z.string().nullish()
4676
+ }),
4677
+ import_v416.z.object({
4678
+ type: import_v416.z.literal("inline"),
4679
+ content: import_v416.z.string(),
4680
+ target: import_v416.z.string()
4681
+ })
4682
+ ])
4683
+ ).nullish(),
4684
+ network: import_v416.z.union([
4685
+ import_v416.z.literal("disabled"),
4686
+ import_v416.z.object({
4687
+ allowlist: import_v416.z.array(
4688
+ import_v416.z.object({
4689
+ domain: import_v416.z.string(),
4690
+ transform: import_v416.z.array(import_v416.z.record(import_v416.z.string(), import_v416.z.string())).nullish()
4691
+ })
4692
+ )
4693
+ })
4694
+ ]).nullish()
4695
+ })
4696
+ ]).nullish()
4494
4697
  })
4495
4698
  )
4496
4699
  );
@@ -4532,37 +4735,69 @@ function builtinToolNameFromResultType2(type) {
4532
4735
  return type.replace(/_result$/, "");
4533
4736
  }
4534
4737
  function parseGoogleInteractionsOutputs({
4535
- outputs,
4738
+ steps,
4536
4739
  generateId: generateId3,
4537
4740
  interactionId
4538
4741
  }) {
4539
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4742
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4540
4743
  const content = [];
4541
4744
  let hasFunctionCall = false;
4542
- if (outputs == null) {
4745
+ if (steps == null) {
4543
4746
  return { content, hasFunctionCall };
4544
4747
  }
4545
- for (const block of outputs) {
4546
- if (block == null || typeof block !== "object") continue;
4547
- const type = block.type;
4748
+ for (const step of steps) {
4749
+ if (step == null || typeof step !== "object") continue;
4750
+ const type = step.type;
4548
4751
  if (typeof type !== "string") continue;
4549
4752
  switch (type) {
4550
- case "text": {
4551
- const text = (_a = block.text) != null ? _a : "";
4552
- const annotations = block.annotations;
4553
- content.push({
4554
- type: "text",
4555
- text,
4556
- ...googleProviderMetadata({ interactionId })
4557
- });
4558
- const sources = annotationsToSources({ annotations, generateId: generateId3 });
4559
- for (const source of sources) {
4560
- content.push(source);
4753
+ case "user_input": {
4754
+ break;
4755
+ }
4756
+ case "model_output": {
4757
+ const blocks = (_a = step.content) != null ? _a : [];
4758
+ for (const block of blocks) {
4759
+ if (block == null || typeof block !== "object") continue;
4760
+ const blockType = block.type;
4761
+ if (blockType === "text") {
4762
+ const text = (_b = block.text) != null ? _b : "";
4763
+ const annotations = block.annotations;
4764
+ content.push({
4765
+ type: "text",
4766
+ text,
4767
+ ...googleProviderMetadata({ interactionId })
4768
+ });
4769
+ const sources = annotationsToSources({ annotations, generateId: generateId3 });
4770
+ for (const source of sources) {
4771
+ content.push(source);
4772
+ }
4773
+ } else if (blockType === "image") {
4774
+ const image = block;
4775
+ if (image.data != null && image.data.length > 0) {
4776
+ content.push({
4777
+ type: "file",
4778
+ mediaType: (_c = image.mime_type) != null ? _c : "image/png",
4779
+ data: image.data,
4780
+ ...googleProviderMetadata({ interactionId })
4781
+ });
4782
+ } else if (image.uri != null && image.uri.length > 0) {
4783
+ content.push({
4784
+ type: "file",
4785
+ mediaType: (_d = image.mime_type) != null ? _d : "image/png",
4786
+ data: "",
4787
+ providerMetadata: {
4788
+ google: {
4789
+ ...interactionId != null ? { interactionId } : {},
4790
+ imageUri: image.uri
4791
+ }
4792
+ }
4793
+ });
4794
+ }
4795
+ }
4561
4796
  }
4562
4797
  break;
4563
4798
  }
4564
4799
  case "thought": {
4565
- const thought = block;
4800
+ const thought = step;
4566
4801
  const summary = Array.isArray(thought.summary) ? thought.summary : [];
4567
4802
  const text = summary.filter(
4568
4803
  (item) => (item == null ? void 0 : item.type) === "text" && typeof item.text === "string"
@@ -4577,38 +4812,14 @@ function parseGoogleInteractionsOutputs({
4577
4812
  });
4578
4813
  break;
4579
4814
  }
4580
- case "image": {
4581
- const image = block;
4582
- if (image.data != null && image.data.length > 0) {
4583
- content.push({
4584
- type: "file",
4585
- mediaType: (_b = image.mime_type) != null ? _b : "image/png",
4586
- data: image.data,
4587
- ...googleProviderMetadata({ interactionId })
4588
- });
4589
- } else if (image.uri != null && image.uri.length > 0) {
4590
- content.push({
4591
- type: "file",
4592
- mediaType: (_c = image.mime_type) != null ? _c : "image/png",
4593
- data: "",
4594
- providerMetadata: {
4595
- google: {
4596
- ...interactionId != null ? { interactionId } : {},
4597
- imageUri: image.uri
4598
- }
4599
- }
4600
- });
4601
- }
4602
- break;
4603
- }
4604
4815
  case "function_call": {
4605
4816
  hasFunctionCall = true;
4606
- const call = block;
4817
+ const call = step;
4607
4818
  content.push({
4608
4819
  type: "tool-call",
4609
4820
  toolCallId: call.id,
4610
4821
  toolName: call.name,
4611
- input: JSON.stringify((_d = call.arguments) != null ? _d : {}),
4822
+ input: JSON.stringify((_e = call.arguments) != null ? _e : {}),
4612
4823
  ...googleProviderMetadata({
4613
4824
  signature: call.signature,
4614
4825
  interactionId
@@ -4618,27 +4829,27 @@ function parseGoogleInteractionsOutputs({
4618
4829
  }
4619
4830
  default: {
4620
4831
  if (BUILTIN_TOOL_CALL_TYPES2.has(type)) {
4621
- const call = block;
4622
- const toolName = type === "mcp_server_tool_call" ? (_e = call.name) != null ? _e : "mcp_server_tool" : builtinToolNameFromCallType2(type);
4623
- const input = JSON.stringify((_f = call.arguments) != null ? _f : {});
4832
+ const call = step;
4833
+ const toolName = type === "mcp_server_tool_call" ? (_f = call.name) != null ? _f : "mcp_server_tool" : builtinToolNameFromCallType2(type);
4834
+ const input = JSON.stringify((_g = call.arguments) != null ? _g : {});
4624
4835
  content.push({
4625
4836
  type: "tool-call",
4626
- toolCallId: (_g = call.id) != null ? _g : generateId3(),
4837
+ toolCallId: (_h = call.id) != null ? _h : generateId3(),
4627
4838
  toolName,
4628
4839
  input,
4629
4840
  providerExecuted: true
4630
4841
  });
4631
4842
  } else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
4632
- const result = block;
4633
- const toolName = type === "mcp_server_tool_result" ? (_h = result.name) != null ? _h : "mcp_server_tool" : builtinToolNameFromResultType2(type);
4843
+ const result = step;
4844
+ const toolName = type === "mcp_server_tool_result" ? (_i = result.name) != null ? _i : "mcp_server_tool" : builtinToolNameFromResultType2(type);
4634
4845
  content.push({
4635
4846
  type: "tool-result",
4636
- toolCallId: (_i = result.call_id) != null ? _i : generateId3(),
4847
+ toolCallId: (_j = result.call_id) != null ? _j : generateId3(),
4637
4848
  toolName,
4638
- result: (_j = result.result) != null ? _j : null
4849
+ result: (_k = result.result) != null ? _k : null
4639
4850
  });
4640
4851
  const sources = builtinToolResultToSources({
4641
- block,
4852
+ block: step,
4642
4853
  generateId: generateId3
4643
4854
  });
4644
4855
  for (const source of sources) {
@@ -5012,7 +5223,7 @@ function streamGoogleInteractionEvents({
5012
5223
  if (typeof ev.event_id === "string" && ev.event_id.length > 0) {
5013
5224
  lastEventId = ev.event_id;
5014
5225
  }
5015
- if (ev.event_type === "interaction.complete" || ev.event_type === "error") {
5226
+ if (ev.event_type === "interaction.completed" || ev.event_type === "error") {
5016
5227
  complete = true;
5017
5228
  }
5018
5229
  }
@@ -5093,7 +5304,7 @@ function synthesizeGoogleInteractionsAgentStream({
5093
5304
  controller.enqueue({ type: "raw", rawValue: response });
5094
5305
  }
5095
5306
  const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
5096
- outputs: (_b = response.outputs) != null ? _b : null,
5307
+ steps: (_b = response.steps) != null ? _b : null,
5097
5308
  generateId: generateId3,
5098
5309
  interactionId
5099
5310
  });
@@ -5210,6 +5421,9 @@ var GoogleInteractionsLanguageModel = class {
5210
5421
  if (typeof modelOrAgent === "string") {
5211
5422
  this.modelId = modelOrAgent;
5212
5423
  this.agent = void 0;
5424
+ } else if ("managedAgent" in modelOrAgent) {
5425
+ this.modelId = modelOrAgent.managedAgent;
5426
+ this.agent = modelOrAgent.managedAgent;
5213
5427
  } else {
5214
5428
  this.modelId = modelOrAgent.agent;
5215
5429
  this.agent = modelOrAgent.agent;
@@ -5235,7 +5449,7 @@ var GoogleInteractionsLanguageModel = class {
5235
5449
  };
5236
5450
  }
5237
5451
  async getArgs(options) {
5238
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
5452
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
5239
5453
  const warnings = [];
5240
5454
  const opts = await (0, import_provider_utils22.parseProviderOptions)({
5241
5455
  provider: "google",
@@ -5260,8 +5474,7 @@ var GoogleInteractionsLanguageModel = class {
5260
5474
  toolChoiceForBody = prepared.toolChoice;
5261
5475
  warnings.push(...prepared.toolWarnings);
5262
5476
  }
5263
- let responseMimeType;
5264
- let responseFormat;
5477
+ const responseFormatEntries = [];
5265
5478
  if (((_a = options.responseFormat) == null ? void 0 : _a.type) === "json") {
5266
5479
  if (isAgent) {
5267
5480
  warnings.push({
@@ -5269,9 +5482,40 @@ var GoogleInteractionsLanguageModel = class {
5269
5482
  message: "google.interactions: structured output (responseFormat) is not supported when an agent is set; responseFormat will be ignored."
5270
5483
  });
5271
5484
  } else {
5272
- responseMimeType = "application/json";
5273
- if (options.responseFormat.schema != null) {
5274
- responseFormat = options.responseFormat.schema;
5485
+ const entry = {
5486
+ type: "text",
5487
+ mime_type: "application/json",
5488
+ ...options.responseFormat.schema != null ? { schema: options.responseFormat.schema } : {}
5489
+ };
5490
+ responseFormatEntries.push(entry);
5491
+ }
5492
+ }
5493
+ if ((opts == null ? void 0 : opts.responseFormat) != null) {
5494
+ for (const entry of opts.responseFormat) {
5495
+ if (entry.type === "text") {
5496
+ responseFormatEntries.push(
5497
+ pruneUndefined({
5498
+ type: "text",
5499
+ mime_type: (_b = entry.mimeType) != null ? _b : void 0,
5500
+ schema: (_c = entry.schema) != null ? _c : void 0
5501
+ })
5502
+ );
5503
+ } else if (entry.type === "image") {
5504
+ responseFormatEntries.push(
5505
+ pruneUndefined({
5506
+ type: "image",
5507
+ mime_type: (_d = entry.mimeType) != null ? _d : void 0,
5508
+ aspect_ratio: (_e = entry.aspectRatio) != null ? _e : void 0,
5509
+ image_size: (_f = entry.imageSize) != null ? _f : void 0
5510
+ })
5511
+ );
5512
+ } else if (entry.type === "audio") {
5513
+ responseFormatEntries.push(
5514
+ pruneUndefined({
5515
+ type: "audio",
5516
+ mime_type: (_g = entry.mimeType) != null ? _g : void 0
5517
+ })
5518
+ );
5275
5519
  }
5276
5520
  }
5277
5521
  }
@@ -5281,13 +5525,13 @@ var GoogleInteractionsLanguageModel = class {
5281
5525
  warnings: convWarnings
5282
5526
  } = convertToGoogleInteractionsInput({
5283
5527
  prompt: options.prompt,
5284
- previousInteractionId: (_b = opts == null ? void 0 : opts.previousInteractionId) != null ? _b : void 0,
5285
- store: (_c = opts == null ? void 0 : opts.store) != null ? _c : void 0,
5286
- mediaResolution: (_d = opts == null ? void 0 : opts.mediaResolution) != null ? _d : void 0
5528
+ previousInteractionId: (_h = opts == null ? void 0 : opts.previousInteractionId) != null ? _h : void 0,
5529
+ store: (_i = opts == null ? void 0 : opts.store) != null ? _i : void 0,
5530
+ mediaResolution: (_j = opts == null ? void 0 : opts.mediaResolution) != null ? _j : void 0
5287
5531
  });
5288
5532
  warnings.push(...convWarnings);
5289
5533
  let systemInstruction = convertedSystemInstruction;
5290
- const optionSystemInstruction = (_e = opts == null ? void 0 : opts.systemInstruction) != null ? _e : void 0;
5534
+ const optionSystemInstruction = (_k = opts == null ? void 0 : opts.systemInstruction) != null ? _k : void 0;
5291
5535
  if (systemInstruction != null && optionSystemInstruction != null) {
5292
5536
  warnings.push({
5293
5537
  type: "other",
@@ -5321,19 +5565,32 @@ var GoogleInteractionsLanguageModel = class {
5321
5565
  generationConfig = void 0;
5322
5566
  } else {
5323
5567
  generationConfig = pruneUndefined({
5324
- temperature: (_f = options.temperature) != null ? _f : void 0,
5325
- top_p: (_g = options.topP) != null ? _g : void 0,
5326
- seed: (_h = options.seed) != null ? _h : void 0,
5568
+ temperature: (_l = options.temperature) != null ? _l : void 0,
5569
+ top_p: (_m = options.topP) != null ? _m : void 0,
5570
+ seed: (_n = options.seed) != null ? _n : void 0,
5327
5571
  stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
5328
- max_output_tokens: (_i = options.maxOutputTokens) != null ? _i : void 0,
5329
- thinking_level: (_j = opts == null ? void 0 : opts.thinkingLevel) != null ? _j : void 0,
5330
- thinking_summaries: (_k = opts == null ? void 0 : opts.thinkingSummaries) != null ? _k : void 0,
5331
- image_config: (opts == null ? void 0 : opts.imageConfig) != null ? pruneUndefined({
5332
- aspect_ratio: (_l = opts.imageConfig.aspectRatio) != null ? _l : void 0,
5333
- image_size: (_m = opts.imageConfig.imageSize) != null ? _m : void 0
5334
- }) : void 0,
5572
+ max_output_tokens: (_o = options.maxOutputTokens) != null ? _o : void 0,
5573
+ thinking_level: (_p = opts == null ? void 0 : opts.thinkingLevel) != null ? _p : void 0,
5574
+ thinking_summaries: (_q = opts == null ? void 0 : opts.thinkingSummaries) != null ? _q : void 0,
5335
5575
  tool_choice: toolChoiceForBody
5336
5576
  });
5577
+ if ((opts == null ? void 0 : opts.imageConfig) != null) {
5578
+ const alreadyHasImageEntry = responseFormatEntries.some(
5579
+ (entry) => entry.type === "image"
5580
+ );
5581
+ warnings.push({
5582
+ type: "other",
5583
+ message: alreadyHasImageEntry ? "google.interactions: providerOptions.google.imageConfig is deprecated and was ignored because providerOptions.google.responseFormat already supplies an image entry. Use responseFormat exclusively." : 'google.interactions: providerOptions.google.imageConfig is deprecated. Use providerOptions.google.responseFormat with a { type: "image", ... } entry instead.'
5584
+ });
5585
+ if (!alreadyHasImageEntry) {
5586
+ responseFormatEntries.push({
5587
+ type: "image",
5588
+ mime_type: "image/png",
5589
+ ...opts.imageConfig.aspectRatio != null ? { aspect_ratio: opts.imageConfig.aspectRatio } : {},
5590
+ ...opts.imageConfig.imageSize != null ? { image_size: opts.imageConfig.imageSize } : {}
5591
+ });
5592
+ }
5593
+ }
5337
5594
  }
5338
5595
  let agentConfig;
5339
5596
  if (isAgent && (opts == null ? void 0 : opts.agentConfig) != null) {
@@ -5341,34 +5598,84 @@ var GoogleInteractionsLanguageModel = class {
5341
5598
  if (ac.type === "deep-research") {
5342
5599
  agentConfig = pruneUndefined({
5343
5600
  type: "deep-research",
5344
- thinking_summaries: (_n = ac.thinkingSummaries) != null ? _n : void 0,
5345
- visualization: (_o = ac.visualization) != null ? _o : void 0,
5346
- collaborative_planning: (_p = ac.collaborativePlanning) != null ? _p : void 0
5601
+ thinking_summaries: (_r = ac.thinkingSummaries) != null ? _r : void 0,
5602
+ visualization: (_s = ac.visualization) != null ? _s : void 0,
5603
+ collaborative_planning: (_t = ac.collaborativePlanning) != null ? _t : void 0
5347
5604
  });
5348
5605
  } else if (ac.type === "dynamic") {
5349
5606
  agentConfig = { type: "dynamic" };
5350
5607
  }
5351
5608
  }
5609
+ let environment;
5610
+ if ((opts == null ? void 0 : opts.environment) != null) {
5611
+ if (!isAgent) {
5612
+ warnings.push({
5613
+ type: "other",
5614
+ message: "google.interactions: environment is only supported when an agent is set; environment will be omitted from the request body."
5615
+ });
5616
+ } else if (typeof opts.environment === "string") {
5617
+ environment = opts.environment;
5618
+ } else {
5619
+ const env = opts.environment;
5620
+ const sources = (_u = env.sources) == null ? void 0 : _u.map((s) => {
5621
+ var _a2;
5622
+ if (s.type === "inline") {
5623
+ return {
5624
+ type: "inline",
5625
+ content: s.content,
5626
+ target: s.target
5627
+ };
5628
+ }
5629
+ return pruneUndefined({
5630
+ type: s.type,
5631
+ source: s.source,
5632
+ target: (_a2 = s.target) != null ? _a2 : void 0
5633
+ });
5634
+ });
5635
+ let network;
5636
+ if (env.network === "disabled") {
5637
+ network = "disabled";
5638
+ } else if (env.network != null) {
5639
+ network = {
5640
+ allowlist: env.network.allowlist.map(
5641
+ (entry) => {
5642
+ var _a2;
5643
+ return pruneUndefined({
5644
+ domain: entry.domain,
5645
+ transform: (_a2 = entry.transform) != null ? _a2 : void 0
5646
+ });
5647
+ }
5648
+ )
5649
+ };
5650
+ }
5651
+ environment = pruneUndefined({
5652
+ type: "remote",
5653
+ sources: sources != null && sources.length > 0 ? sources : void 0,
5654
+ network
5655
+ });
5656
+ }
5657
+ }
5352
5658
  const args = pruneUndefined({
5353
5659
  ...isAgent ? { agent: this.agent } : { model: this.modelId },
5354
5660
  input,
5355
5661
  system_instruction: systemInstruction,
5356
5662
  tools: toolsForBody,
5357
- response_format: responseFormat,
5358
- response_mime_type: responseMimeType,
5663
+ response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
5359
5664
  response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
5360
- previous_interaction_id: (_q = opts == null ? void 0 : opts.previousInteractionId) != null ? _q : void 0,
5361
- service_tier: (_r = opts == null ? void 0 : opts.serviceTier) != null ? _r : void 0,
5362
- store: (_s = opts == null ? void 0 : opts.store) != null ? _s : void 0,
5665
+ previous_interaction_id: (_v = opts == null ? void 0 : opts.previousInteractionId) != null ? _v : void 0,
5666
+ service_tier: (_w = opts == null ? void 0 : opts.serviceTier) != null ? _w : void 0,
5667
+ store: (_x = opts == null ? void 0 : opts.store) != null ? _x : void 0,
5363
5668
  generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
5364
5669
  agent_config: agentConfig,
5365
- ...isAgent ? { background: true } : {}
5670
+ environment,
5671
+ background: (_y = opts == null ? void 0 : opts.background) != null ? _y : void 0
5366
5672
  });
5367
5673
  return {
5368
5674
  args,
5369
5675
  warnings,
5370
5676
  isAgent,
5371
- pollingTimeoutMs: (_t = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _t : void 0
5677
+ isBackground: (opts == null ? void 0 : opts.background) === true,
5678
+ pollingTimeoutMs: (_z = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _z : void 0
5372
5679
  };
5373
5680
  }
5374
5681
  async doGenerate(options) {
@@ -5376,6 +5683,7 @@ var GoogleInteractionsLanguageModel = class {
5376
5683
  const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
5377
5684
  const url = `${this.config.baseURL}/interactions`;
5378
5685
  const mergedHeaders = (0, import_provider_utils22.combineHeaders)(
5686
+ INTERACTIONS_API_REVISION_HEADER,
5379
5687
  this.config.headers ? await (0, import_provider_utils22.resolve)(this.config.headers) : void 0,
5380
5688
  options.headers
5381
5689
  );
@@ -5410,7 +5718,7 @@ var GoogleInteractionsLanguageModel = class {
5410
5718
  }
5411
5719
  const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
5412
5720
  const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
5413
- outputs: (_b = response.outputs) != null ? _b : null,
5721
+ steps: (_b = response.steps) != null ? _b : null,
5414
5722
  generateId: (_c = this.config.generateId) != null ? _c : import_provider_utils22.generateId,
5415
5723
  interactionId
5416
5724
  });
@@ -5453,13 +5761,14 @@ var GoogleInteractionsLanguageModel = class {
5453
5761
  }
5454
5762
  async doStream(options) {
5455
5763
  var _a;
5456
- const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
5764
+ const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
5457
5765
  const url = `${this.config.baseURL}/interactions`;
5458
5766
  const mergedHeaders = (0, import_provider_utils22.combineHeaders)(
5767
+ INTERACTIONS_API_REVISION_HEADER,
5459
5768
  this.config.headers ? await (0, import_provider_utils22.resolve)(this.config.headers) : void 0,
5460
5769
  options.headers
5461
5770
  );
5462
- if (isAgent) {
5771
+ if (isBackground) {
5463
5772
  return this.doStreamBackground({
5464
5773
  args,
5465
5774
  warnings,
@@ -5575,6 +5884,9 @@ var GoogleInteractionsLanguageModel = class {
5575
5884
  };
5576
5885
  }
5577
5886
  };
5887
+ var INTERACTIONS_API_REVISION_HEADER = {
5888
+ "Api-Revision": "2026-05-20"
5889
+ };
5578
5890
  function pruneUndefined(obj) {
5579
5891
  const result = {};
5580
5892
  for (const [key, value] of Object.entries(obj)) {