@ai-sdk/google 3.0.75 → 3.0.78

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/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.75" : "0.0.0-test";
33
+ var VERSION = true ? "3.0.78" : "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 = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _r : null
1681
1715
  }
1682
1716
  },
1683
1717
  request: { body: args },
@@ -1689,13 +1723,11 @@ 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
+ const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
1696
1727
  const headers = (0, import_provider_utils6.combineHeaders)(
1697
1728
  await (0, import_provider_utils6.resolve)(this.config.headers),
1698
- options.headers
1729
+ options.headers,
1730
+ extraHeaders
1699
1731
  );
1700
1732
  const { responseHeaders, value: response } = await (0, import_provider_utils6.postJsonToApi)({
1701
1733
  url: `${this.config.baseURL}/${getModelPath(
@@ -1716,7 +1748,6 @@ var GoogleGenerativeAILanguageModel = class {
1716
1748
  let providerMetadata = void 0;
1717
1749
  let lastGroundingMetadata = null;
1718
1750
  let lastUrlContextMetadata = null;
1719
- let serviceTier = null;
1720
1751
  const generateId3 = this.config.generateId;
1721
1752
  let hasToolCalls = false;
1722
1753
  let currentTextBlockId = null;
@@ -1726,6 +1757,34 @@ var GoogleGenerativeAILanguageModel = class {
1726
1757
  let lastCodeExecutionToolCallId;
1727
1758
  let lastServerToolCallId;
1728
1759
  const activeStreamingToolCalls = [];
1760
+ const finishActiveStreamingToolCall = (controller) => {
1761
+ const active = activeStreamingToolCalls.pop();
1762
+ if (active == null) {
1763
+ return;
1764
+ }
1765
+ const { finalJSON, closingDelta } = active.accumulator.finalize();
1766
+ if (closingDelta.length > 0) {
1767
+ controller.enqueue({
1768
+ type: "tool-input-delta",
1769
+ id: active.toolCallId,
1770
+ delta: closingDelta,
1771
+ providerMetadata: active.providerMetadata
1772
+ });
1773
+ }
1774
+ controller.enqueue({
1775
+ type: "tool-input-end",
1776
+ id: active.toolCallId,
1777
+ providerMetadata: active.providerMetadata
1778
+ });
1779
+ controller.enqueue({
1780
+ type: "tool-call",
1781
+ toolCallId: active.toolCallId,
1782
+ toolName: active.toolName,
1783
+ input: finalJSON,
1784
+ providerMetadata: active.providerMetadata
1785
+ });
1786
+ hasToolCalls = true;
1787
+ };
1729
1788
  return {
1730
1789
  stream: response.pipeThrough(
1731
1790
  new TransformStream({
@@ -1733,7 +1792,7 @@ var GoogleGenerativeAILanguageModel = class {
1733
1792
  controller.enqueue({ type: "stream-start", warnings });
1734
1793
  },
1735
1794
  transform(chunk, controller) {
1736
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1795
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1737
1796
  if (options.includeRawChunks) {
1738
1797
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1739
1798
  }
@@ -1746,9 +1805,6 @@ var GoogleGenerativeAILanguageModel = class {
1746
1805
  if (usageMetadata != null) {
1747
1806
  usage = usageMetadata;
1748
1807
  }
1749
- if (value.serviceTier != null) {
1750
- serviceTier = value.serviceTier;
1751
- }
1752
1808
  const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
1753
1809
  if (candidate == null) {
1754
1810
  return;
@@ -1938,7 +1994,7 @@ var GoogleGenerativeAILanguageModel = class {
1938
1994
  const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
1939
1995
  const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
1940
1996
  if (isStreamingChunk) {
1941
- if (part.functionCall.name != null && part.functionCall.willContinue === true) {
1997
+ if (part.functionCall.name != null) {
1942
1998
  const toolCallId = (_i = part.functionCall.id) != null ? _i : generateId3();
1943
1999
  const accumulator = new GoogleJSONAccumulator();
1944
2000
  activeStreamingToolCalls.push({
@@ -1954,9 +2010,8 @@ var GoogleGenerativeAILanguageModel = class {
1954
2010
  providerMetadata: providerMeta
1955
2011
  });
1956
2012
  if (part.functionCall.partialArgs != null) {
1957
- const { textDelta } = accumulator.processPartialArgs(
1958
- part.functionCall.partialArgs
1959
- );
2013
+ const partialArgs = part.functionCall.partialArgs;
2014
+ const { textDelta } = accumulator.processPartialArgs(partialArgs);
1960
2015
  if (textDelta.length > 0) {
1961
2016
  controller.enqueue({
1962
2017
  type: "tool-input-delta",
@@ -1965,12 +2020,14 @@ var GoogleGenerativeAILanguageModel = class {
1965
2020
  providerMetadata: providerMeta
1966
2021
  });
1967
2022
  }
2023
+ if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
2024
+ finishActiveStreamingToolCall(controller);
2025
+ }
1968
2026
  }
1969
2027
  } else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
1970
2028
  const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
1971
- const { textDelta } = active.accumulator.processPartialArgs(
1972
- part.functionCall.partialArgs
1973
- );
2029
+ const partialArgs = part.functionCall.partialArgs;
2030
+ const { textDelta } = active.accumulator.processPartialArgs(partialArgs);
1974
2031
  if (textDelta.length > 0) {
1975
2032
  controller.enqueue({
1976
2033
  type: "tool-input-delta",
@@ -1979,31 +2036,12 @@ var GoogleGenerativeAILanguageModel = class {
1979
2036
  providerMetadata: providerMeta
1980
2037
  });
1981
2038
  }
2039
+ if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
2040
+ finishActiveStreamingToolCall(controller);
2041
+ }
1982
2042
  }
1983
2043
  } 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;
2044
+ finishActiveStreamingToolCall(controller);
2007
2045
  } else if (isCompleteCall) {
2008
2046
  const toolCallId = (_j = part.functionCall.id) != null ? _j : generateId3();
2009
2047
  const toolName = part.functionCall.name;
@@ -2074,7 +2112,7 @@ var GoogleGenerativeAILanguageModel = class {
2074
2112
  safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
2075
2113
  usageMetadata: usageMetadata != null ? usageMetadata : null,
2076
2114
  finishMessage: (_o = candidate.finishMessage) != null ? _o : null,
2077
- serviceTier
2115
+ serviceTier: (_p = usage == null ? void 0 : usage.serviceTier) != null ? _p : null
2078
2116
  }
2079
2117
  };
2080
2118
  }
@@ -2333,6 +2371,7 @@ var usageSchema = import_v45.z.object({
2333
2371
  totalTokenCount: import_v45.z.number().nullish(),
2334
2372
  // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
2335
2373
  trafficType: import_v45.z.string().nullish(),
2374
+ serviceTier: import_v45.z.string().nullish(),
2336
2375
  // https://ai.google.dev/api/generate-content#Modality
2337
2376
  promptTokensDetails: tokenDetailsSchema,
2338
2377
  candidatesTokensDetails: tokenDetailsSchema
@@ -2362,8 +2401,7 @@ var responseSchema = (0, import_provider_utils6.lazySchema)(
2362
2401
  promptFeedback: import_v45.z.object({
2363
2402
  blockReason: import_v45.z.string().nullish(),
2364
2403
  safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish()
2365
- }).nullish(),
2366
- serviceTier: import_v45.z.string().nullish()
2404
+ }).nullish()
2367
2405
  })
2368
2406
  )
2369
2407
  );
@@ -2384,8 +2422,7 @@ var chunkSchema = (0, import_provider_utils6.lazySchema)(
2384
2422
  promptFeedback: import_v45.z.object({
2385
2423
  blockReason: import_v45.z.string().nullish(),
2386
2424
  safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish()
2387
- }).nullish(),
2388
- serviceTier: import_v45.z.string().nullish()
2425
+ }).nullish()
2389
2426
  })
2390
2427
  )
2391
2428
  );
@@ -4601,7 +4638,61 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
4601
4638
  * call) before giving up. Defaults to 30 minutes. Long-running agents
4602
4639
  * such as deep research can take tens of minutes — increase if needed.
4603
4640
  */
4604
- pollingTimeoutMs: import_v416.z.number().int().positive().nullish()
4641
+ pollingTimeoutMs: import_v416.z.number().int().positive().nullish(),
4642
+ /**
4643
+ * Run the interaction in the background. Required for agents whose
4644
+ * server-side workflow cannot complete within a single request/response.
4645
+ * When `true`, the POST returns with a non-terminal status and the SDK
4646
+ * polls `GET /interactions/{id}` until the work completes. Some agents
4647
+ * reject `true`; see the agent's documentation for which mode it
4648
+ * requires.
4649
+ */
4650
+ background: import_v416.z.boolean().nullish(),
4651
+ /**
4652
+ * Environment configuration for the agent sandbox. Only applies to agent
4653
+ * calls (`google.interactions({ agent })`); ignored on model-id calls.
4654
+ *
4655
+ * - `"remote"`: provision a fresh sandbox for this call.
4656
+ * - any other string: an existing `environment_id` to reuse.
4657
+ * - object: provision a fresh sandbox and optionally preload `sources`
4658
+ * and/or constrain outbound traffic via `network`.
4659
+ */
4660
+ environment: import_v416.z.union([
4661
+ import_v416.z.string(),
4662
+ import_v416.z.object({
4663
+ type: import_v416.z.literal("remote"),
4664
+ sources: import_v416.z.array(
4665
+ import_v416.z.union([
4666
+ import_v416.z.object({
4667
+ type: import_v416.z.literal("gcs"),
4668
+ source: import_v416.z.string(),
4669
+ target: import_v416.z.string().nullish()
4670
+ }),
4671
+ import_v416.z.object({
4672
+ type: import_v416.z.literal("repository"),
4673
+ source: import_v416.z.string(),
4674
+ target: import_v416.z.string().nullish()
4675
+ }),
4676
+ import_v416.z.object({
4677
+ type: import_v416.z.literal("inline"),
4678
+ content: import_v416.z.string(),
4679
+ target: import_v416.z.string()
4680
+ })
4681
+ ])
4682
+ ).nullish(),
4683
+ network: import_v416.z.union([
4684
+ import_v416.z.literal("disabled"),
4685
+ import_v416.z.object({
4686
+ allowlist: import_v416.z.array(
4687
+ import_v416.z.object({
4688
+ domain: import_v416.z.string(),
4689
+ transform: import_v416.z.array(import_v416.z.record(import_v416.z.string(), import_v416.z.string())).nullish()
4690
+ })
4691
+ )
4692
+ })
4693
+ ]).nullish()
4694
+ })
4695
+ ]).nullish()
4605
4696
  })
4606
4697
  )
4607
4698
  );
@@ -5329,6 +5420,9 @@ var GoogleInteractionsLanguageModel = class {
5329
5420
  if (typeof modelOrAgent === "string") {
5330
5421
  this.modelId = modelOrAgent;
5331
5422
  this.agent = void 0;
5423
+ } else if ("managedAgent" in modelOrAgent) {
5424
+ this.modelId = modelOrAgent.managedAgent;
5425
+ this.agent = modelOrAgent.managedAgent;
5332
5426
  } else {
5333
5427
  this.modelId = modelOrAgent.agent;
5334
5428
  this.agent = modelOrAgent.agent;
@@ -5354,7 +5448,7 @@ var GoogleInteractionsLanguageModel = class {
5354
5448
  };
5355
5449
  }
5356
5450
  async getArgs(options) {
5357
- 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;
5451
+ 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;
5358
5452
  const warnings = [];
5359
5453
  const opts = await (0, import_provider_utils22.parseProviderOptions)({
5360
5454
  provider: "google",
@@ -5511,6 +5605,55 @@ var GoogleInteractionsLanguageModel = class {
5511
5605
  agentConfig = { type: "dynamic" };
5512
5606
  }
5513
5607
  }
5608
+ let environment;
5609
+ if ((opts == null ? void 0 : opts.environment) != null) {
5610
+ if (!isAgent) {
5611
+ warnings.push({
5612
+ type: "other",
5613
+ message: "google.interactions: environment is only supported when an agent is set; environment will be omitted from the request body."
5614
+ });
5615
+ } else if (typeof opts.environment === "string") {
5616
+ environment = opts.environment;
5617
+ } else {
5618
+ const env = opts.environment;
5619
+ const sources = (_u = env.sources) == null ? void 0 : _u.map((s) => {
5620
+ var _a2;
5621
+ if (s.type === "inline") {
5622
+ return {
5623
+ type: "inline",
5624
+ content: s.content,
5625
+ target: s.target
5626
+ };
5627
+ }
5628
+ return pruneUndefined({
5629
+ type: s.type,
5630
+ source: s.source,
5631
+ target: (_a2 = s.target) != null ? _a2 : void 0
5632
+ });
5633
+ });
5634
+ let network;
5635
+ if (env.network === "disabled") {
5636
+ network = "disabled";
5637
+ } else if (env.network != null) {
5638
+ network = {
5639
+ allowlist: env.network.allowlist.map(
5640
+ (entry) => {
5641
+ var _a2;
5642
+ return pruneUndefined({
5643
+ domain: entry.domain,
5644
+ transform: (_a2 = entry.transform) != null ? _a2 : void 0
5645
+ });
5646
+ }
5647
+ )
5648
+ };
5649
+ }
5650
+ environment = pruneUndefined({
5651
+ type: "remote",
5652
+ sources: sources != null && sources.length > 0 ? sources : void 0,
5653
+ network
5654
+ });
5655
+ }
5656
+ }
5514
5657
  const args = pruneUndefined({
5515
5658
  ...isAgent ? { agent: this.agent } : { model: this.modelId },
5516
5659
  input,
@@ -5518,18 +5661,20 @@ var GoogleInteractionsLanguageModel = class {
5518
5661
  tools: toolsForBody,
5519
5662
  response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
5520
5663
  response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
5521
- previous_interaction_id: (_u = opts == null ? void 0 : opts.previousInteractionId) != null ? _u : void 0,
5522
- service_tier: (_v = opts == null ? void 0 : opts.serviceTier) != null ? _v : void 0,
5523
- store: (_w = opts == null ? void 0 : opts.store) != null ? _w : void 0,
5664
+ previous_interaction_id: (_v = opts == null ? void 0 : opts.previousInteractionId) != null ? _v : void 0,
5665
+ service_tier: (_w = opts == null ? void 0 : opts.serviceTier) != null ? _w : void 0,
5666
+ store: (_x = opts == null ? void 0 : opts.store) != null ? _x : void 0,
5524
5667
  generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
5525
5668
  agent_config: agentConfig,
5526
- ...isAgent ? { background: true } : {}
5669
+ environment,
5670
+ background: (_y = opts == null ? void 0 : opts.background) != null ? _y : void 0
5527
5671
  });
5528
5672
  return {
5529
5673
  args,
5530
5674
  warnings,
5531
5675
  isAgent,
5532
- pollingTimeoutMs: (_x = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _x : void 0
5676
+ isBackground: (opts == null ? void 0 : opts.background) === true,
5677
+ pollingTimeoutMs: (_z = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _z : void 0
5533
5678
  };
5534
5679
  }
5535
5680
  async doGenerate(options) {
@@ -5615,14 +5760,14 @@ var GoogleInteractionsLanguageModel = class {
5615
5760
  }
5616
5761
  async doStream(options) {
5617
5762
  var _a;
5618
- const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
5763
+ const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
5619
5764
  const url = `${this.config.baseURL}/interactions`;
5620
5765
  const mergedHeaders = (0, import_provider_utils22.combineHeaders)(
5621
5766
  INTERACTIONS_API_REVISION_HEADER,
5622
5767
  this.config.headers ? await (0, import_provider_utils22.resolve)(this.config.headers) : void 0,
5623
5768
  options.headers
5624
5769
  );
5625
- if (isAgent) {
5770
+ if (isBackground) {
5626
5771
  return this.doStreamBackground({
5627
5772
  args,
5628
5773
  warnings,