@openclaw/ai 2026.10.10-beta.5 → 2026.10.33

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 (91) hide show
  1. package/README.md +9 -1
  2. package/dist/{anthropic-B54Ts1tV.mjs → anthropic-B58ec88k.mjs} +46 -26
  3. package/dist/{anthropic-payload-policy-rqCq9sT_.d.mts → anthropic-payload-policy-BCp4dUJR.d.mts} +2 -2
  4. package/dist/{anthropic-stream-reducer-C__ByTq1.mjs → anthropic-stream-reducer-BTcDHWGM.mjs} +11 -11
  5. package/dist/{anthropic-tool-projection-DA_KeluM.mjs → anthropic-tool-projection-CrsCkF4k.mjs} +1 -1
  6. package/dist/{anthropic-tool-projection-JTvMo4KG.d.mts → anthropic-tool-projection-CzSSQzZL.d.mts} +1 -1
  7. package/dist/{api-registry-gDt0faai.d.mts → api-registry-CkmxPPac.d.mts} +1 -1
  8. package/dist/{assistant-output-DbgdWAhJ.mjs → assistant-output-Hl3b-ViJ.mjs} +3 -3
  9. package/dist/{azure-openai-responses-DHzTwi-y.mjs → azure-openai-responses-B0Hi9cAV.mjs} +5 -6
  10. package/dist/{diagnostics-Cv7cW3pS.mjs → diagnostics-v7oVEW59.mjs} +17 -1
  11. package/dist/diagnostics.d.mts +3 -3
  12. package/dist/diagnostics.mjs +1 -1
  13. package/dist/{google-CZ6uGVkV.mjs → google-DuI8TLy0.mjs} +2 -2
  14. package/dist/{google-interactions-1XAHjAQo.mjs → google-interactions-9Jd_049M.mjs} +91 -30
  15. package/dist/{google-messages-B-svbJuN.mjs → google-messages-BWhsZ167.mjs} +9 -3
  16. package/dist/{google-provider-stream-DlhaCvCf.mjs → google-provider-stream-DL0bXgX5.mjs} +16 -11
  17. package/dist/{google-shared-Cif7nve-.mjs → google-shared-DXizMtnG.mjs} +6 -5
  18. package/dist/{google-vertex-BZTcYnWU.mjs → google-vertex-DnjRWo-M.mjs} +2 -2
  19. package/dist/google-video-slots-D8tPH8wX.mjs +29 -0
  20. package/dist/{host-jJOffdlW.d.mts → host-B03VqZdH.d.mts} +2 -2
  21. package/dist/{host-rCxf5Tjd.mjs → host-CyGba3M8.mjs} +111 -88
  22. package/dist/{host-policy-Ci1cKluf.mjs → host-policy-CNQztzZm.mjs} +1 -1
  23. package/dist/{index-DSprYWaz.d.mts → index-B8ODIVmA.d.mts} +15 -4
  24. package/dist/index.d.mts +4 -4
  25. package/dist/index.mjs +4 -4
  26. package/dist/internal/anthropic.d.mts +16 -6
  27. package/dist/internal/anthropic.mjs +6 -6
  28. package/dist/internal/openai-completions-compat.d.mts +5 -1
  29. package/dist/internal/openai-completions-compat.mjs +3 -2
  30. package/dist/internal/openai-responses-payload-policy.d.mts +2 -2
  31. package/dist/internal/openai-responses-payload-policy.mjs +2 -2
  32. package/dist/internal/openai.d.mts +8 -8
  33. package/dist/internal/openai.mjs +9 -9
  34. package/dist/internal/retry-after.d.mts +2 -2
  35. package/dist/internal/retry-after.mjs +75 -1
  36. package/dist/internal/runtime.d.mts +6 -6
  37. package/dist/internal/runtime.mjs +4 -4
  38. package/dist/internal/shared.d.mts +3 -3
  39. package/dist/internal/shared.mjs +2 -2
  40. package/dist/internal/tool-schema.d.mts +2 -2
  41. package/dist/internal/tool-schema.mjs +3 -3
  42. package/dist/{mistral-C_ImzxlK.mjs → mistral-BgamhpFG.mjs} +4 -4
  43. package/dist/openai-BfFy1nvf.mjs +20077 -0
  44. package/dist/{openai-chatgpt-responses-BHkSHjkO.mjs → openai-chatgpt-responses-Biu_I7p4.mjs} +14 -19
  45. package/dist/{openai-completions-CB-wfbsI.mjs → openai-completions-Cbwde_Dr.mjs} +4 -4
  46. package/dist/{openai-completions-compat-CJ0OXZgi.mjs → openai-completions-compat-D9KEUevM.mjs} +2 -2
  47. package/dist/{openai-completions-compat-CBvb2eld.d.mts → openai-completions-compat-DTe2EXPi.d.mts} +2 -2
  48. package/dist/openai-completions-reasoning-replay-BwT1xwRI.mjs +45 -0
  49. package/dist/openai-completions-transport-RCOvvBq_.mjs +10874 -0
  50. package/dist/{openai-prompt-cache-h8vXRiaH.mjs → openai-prompt-cache-CAo-Mah6.mjs} +1 -1
  51. package/dist/{openai-prompt-cache-DgjD-UL5.d.mts → openai-prompt-cache-k7EPMLa0.d.mts} +1 -1
  52. package/dist/{openai-responses-Cp2QPq7K.mjs → openai-responses-DOgBvvca.mjs} +7 -8
  53. package/dist/{openai-responses-compaction-replay-C-yvB5g5.d.mts → openai-responses-compaction-replay-DOJaDCUl.d.mts} +3 -3
  54. package/dist/{openai-responses-contracts-DCG51Us0.mjs → openai-responses-contracts-B5mGAbR6.mjs} +1 -1
  55. package/dist/{openai-responses-contracts-D-VwWWjx.d.mts → openai-responses-contracts-DHtim7d_.d.mts} +9 -3
  56. package/dist/{openai-responses-endpoint-JbBT8IDv.mjs → openai-responses-endpoint-DJwbSy3n.mjs} +4 -2
  57. package/dist/{openai-responses-payload-policy-BzM52TTH.d.mts → openai-responses-payload-policy-cIaYG5ZQ.d.mts} +1 -0
  58. package/dist/{openai-responses-request-lifecycle-DQDyzE6F.mjs → openai-responses-request-lifecycle-bJ24Q_OK.mjs} +22 -8
  59. package/dist/{openai-responses-shared-CNfHudFg.mjs → openai-responses-shared-BDGaQxiw.mjs} +1130 -30
  60. package/dist/{openai-responses-terminal-usage-CpVjkqn-.d.mts → openai-responses-terminal-usage-BDGDBGuA.d.mts} +1 -1
  61. package/dist/{openai-tool-schema-CGhEl7ao.mjs → openai-tool-schema-D913am3I.mjs} +4 -3
  62. package/dist/openai.LICENSE +201 -0
  63. package/dist/{provider-options-Bo8GzTGX.d.mts → provider-options-DFjnfImJ.d.mts} +8 -2
  64. package/dist/{provider-replay-context-BC23HyZo.mjs → provider-replay-context-C5uMjBz4.mjs} +3 -4
  65. package/dist/{provider-transport-turn-state-B11rmZpv.mjs → provider-transport-turn-state-CfUfU9v1.mjs} +3 -3
  66. package/dist/{provider-types-ODq57rG_.d.mts → provider-types-C-67EZr8.d.mts} +5 -3
  67. package/dist/provider-types.d.mts +3 -3
  68. package/dist/provider-types.mjs +2 -1
  69. package/dist/providers.d.mts +2 -2
  70. package/dist/providers.mjs +10 -10
  71. package/dist/{reasoning-tag-text-partitioner-DzlRubwU.mjs → reasoning-tag-text-partitioner-CU9A4Lg8.mjs} +2 -13
  72. package/dist/retry-after-BrmTv0jL.d.mts +25 -0
  73. package/dist/rolldown-runtime-B4iAMlE-.mjs +35 -0
  74. package/dist/{sanitize-unicode-ZqVLLEKC.d.mts → sanitize-unicode-CkejzD2f.d.mts} +1 -1
  75. package/dist/{simple-options-BdJJbzZk.mjs → simple-options-Bd0STwu7.mjs} +3 -3
  76. package/dist/{src-CyA0zJnt.mjs → src--qsViR3j.mjs} +60 -12
  77. package/dist/{stream-DQqGjhbq.mjs → stream-BRecd0FZ.mjs} +1 -1
  78. package/dist/{tool-schema-json-projection-Cvq69Ajp.mjs → tool-schema-json-projection-DU-FFSa7.mjs} +1 -1
  79. package/dist/{transport-stream-shared-DdnJGEj0.mjs → transport-stream-shared-C1AtJhZA.mjs} +2 -2
  80. package/dist/{transport-stream-shared-8ru8eX4s.d.mts → transport-stream-shared-Dhx_37f1.d.mts} +1 -1
  81. package/dist/{transport-utils-CcCAuFVS.mjs → transport-utils-4xPfuKp2.mjs} +2 -2
  82. package/dist/transports.d.mts +23 -15
  83. package/dist/transports.mjs +65 -44
  84. package/dist/types-BFfXm_Jr.d.mts +1 -0
  85. package/dist/types.d.mts +3 -3
  86. package/dist/types.mjs +2 -2
  87. package/dist/ws.LICENSE +20 -0
  88. package/package.json +1 -1
  89. package/dist/openai-completions-transport-CqomHW1O.mjs +0 -3468
  90. package/dist/retry-after-sw-XX8aC.d.mts +0 -15
  91. package/dist/types-CBJthzJX.d.mts +0 -1
package/README.md CHANGED
@@ -17,6 +17,13 @@ available from the package root and focused subpaths such as
17
17
  `@openclaw/ai/event-stream`, `@openclaw/ai/transports`, and
18
18
  `@openclaw/ai/validation`. No second OpenClaw runtime package is required.
19
19
 
20
+ The Node package bundles the reachable OpenAI and `ws` runtime code to reduce
21
+ startup module-file loading. Their licenses ship in `dist/openai.LICENSE` and
22
+ `dist/ws.LICENSE`. Other provider SDKs and TypeBox retain their existing external
23
+ dependency identities.
24
+ OpenAI types resolve through the declared `openai` dependency, preserving its
25
+ namespace aliases without flattening them into the bundled declarations.
26
+
20
27
  Provider ids, credentials, model catalogs, retries, and failover remain
21
28
  application concerns. OpenClaw supplies those policies around this package.
22
29
  Host policy (request fetch guarding, secret redaction, strict-tool defaults,
@@ -24,7 +31,8 @@ provider plugin hooks, and diagnostics logging) can be injected with
24
31
  `configureAiTransportHost`; the defaults are inert. Node callers that need
25
32
  runtime-local policy can use `createNodeLlmRuntime`; it preserves that host across
26
33
  provider work without replacing the process default. `createLlmRuntime` continues
27
- to use the process-default host.
34
+ to use the process-default host. The default host and its asynchronous scope are
35
+ shared across duplicate package module instances, including native plugins.
28
36
 
29
37
  OpenAI HTTP adapters report rejected response status and headers through
30
38
  `onResponse` before consuming the error body. Successful streaming responses
@@ -1,15 +1,15 @@
1
- import { n as __exportAll } from "./reasoning-tag-text-partitioner-DzlRubwU.mjs";
2
- import { w as supportsClaudeAdaptiveThinking } from "./src-CyA0zJnt.mjs";
1
+ import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.mjs";
2
+ import { E as supportsClaudeAdaptiveThinking } from "./src--qsViR3j.mjs";
3
3
  import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
4
- import { T as usesClaudeStreamingRefusalContract, _ as buildAnthropicClaudeCodeIdentity, a as resolveAiTransportHeaderSentinels, b as prepareClaudeNoPrefillRequestContext, r as getAiTransportHost } from "./host-rCxf5Tjd.mjs";
5
- import { s as streamFragmentError } from "./transport-utils-CcCAuFVS.mjs";
6
- import { F as supportsAnthropicServerSideFallback, H as isAnthropicOAuthApiKey, O as isDirectAnthropicModel, U as omitFoundryBearerCredentialHeaders, W as usesFoundryBearerAuth, d as applyAnthropicThinkingOptions, l as buildAnthropicRequest, t as consumeAnthropicStream, u as prepareAnthropicRequest, x as suppressAnthropicCompaction, y as isAnthropicReplayRejection } from "./anthropic-stream-reducer-C__ByTq1.mjs";
4
+ import { O as usesClaudeStreamingRefusalContract, S as readRequiredClaudeCodeVersion, _ as buildAnthropicClaudeCodeIdentity, a as resolveAiTransportHeaderSentinels, b as prepareClaudeNoPrefillRequestContext, r as getAiTransportHost, x as raiseClaudeCodeVersionFloor } from "./host-CyGba3M8.mjs";
5
+ import { s as streamFragmentError } from "./transport-utils-4xPfuKp2.mjs";
6
+ import { F as supportsAnthropicServerSideFallback, H as isAnthropicOAuthApiKey, O as isDirectAnthropicModel, U as omitFoundryBearerCredentialHeaders, W as usesFoundryBearerAuth, d as applyAnthropicThinkingOptions, l as buildAnthropicRequest, t as consumeAnthropicStream, u as prepareAnthropicRequest, x as suppressAnthropicCompaction, y as isAnthropicReplayRejection } from "./anthropic-stream-reducer-BTcDHWGM.mjs";
7
7
  import { i as resolveCacheRetention, n as resolveCloudflareBaseUrl, r as buildCopilotDynamicHeaders } from "./cloudflare-Dttf8jKq.mjs";
8
- import { n as buildBaseOptions, r as clampMaxTokensToModel } from "./simple-options-BdJJbzZk.mjs";
9
- import { D as parseJsonWithRepair, m as notifyProviderHttpResponse, n as assignTransportErrorDetails, u as finalizeTransportStream } from "./transport-stream-shared-DdnJGEj0.mjs";
8
+ import { n as buildBaseOptions, r as clampMaxTokensToModel } from "./simple-options-Bd0STwu7.mjs";
9
+ import { D as parseJsonWithRepair, m as notifyProviderHttpResponse, n as assignTransportErrorDetails, u as finalizeTransportStream } from "./transport-stream-shared-C1AtJhZA.mjs";
10
10
  import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
11
11
  import { t as createDeferredEventBuffer } from "./deferred-event-buffer-DAvyP7qA.mjs";
12
- import { t as createAssistantOutput } from "./assistant-output-DbgdWAhJ.mjs";
12
+ import { t as createAssistantOutput } from "./assistant-output-Hl3b-ViJ.mjs";
13
13
  import { t as notifyLlmRequestActivity } from "./llm-request-activity-CfMuh5cC.mjs";
14
14
  import { n as resolveOpencodeSessionHeaders } from "./session-affinity-DA4WHv1h.mjs";
15
15
  import { t as requireApiKey } from "./required-api-key-D088S4Cd.mjs";
@@ -61,25 +61,44 @@ const streamAnthropic = (model, context, options) => {
61
61
  const refusalBuffer = usesClaudeStreamingRefusalContract(model) ? createDeferredEventBuffer(stream) : void 0;
62
62
  let replayedCompaction;
63
63
  try {
64
- const { client, isOAuthToken, serverSideFallback, directApiKeyBetaHeader, claudeCodeVersion } = createClient(model, requestContext, requestOptions);
65
- const builtParams = await buildAnthropicRequest(model, requestContext, requestOptions, "provider", isOAuthToken, serverSideFallback, claudeCodeVersion);
66
- replayedCompaction = builtParams.replayedCompaction;
67
- const { params, headers } = await prepareAnthropicRequest(builtParams.params, model, requestOptions, directApiKeyBetaHeader);
68
- const sdkRequestOptions = {
69
- ...requestOptions?.signal ? { signal: requestOptions.signal } : {},
70
- ...requestOptions?.timeoutMs !== void 0 ? { timeout: requestOptions.timeoutMs } : {},
71
- maxRetries: 0,
72
- headers
64
+ const send = async (canRetry) => {
65
+ const { client, isOAuthToken, serverSideFallback, directApiKeyBetaHeader, claudeCodeVersion } = createClient(model, requestContext, requestOptions);
66
+ const builtParams = await buildAnthropicRequest(model, requestContext, requestOptions, "provider", isOAuthToken, serverSideFallback, claudeCodeVersion);
67
+ replayedCompaction = builtParams.replayedCompaction;
68
+ const { params, headers } = await prepareAnthropicRequest(builtParams.params, model, requestOptions, directApiKeyBetaHeader);
69
+ const sdkRequestOptions = {
70
+ ...requestOptions?.signal ? { signal: requestOptions.signal } : {},
71
+ ...requestOptions?.timeoutMs !== void 0 ? { timeout: requestOptions.timeoutMs } : {},
72
+ maxRetries: 0,
73
+ headers
74
+ };
75
+ try {
76
+ const response = await client.messages.create({
77
+ ...params,
78
+ stream: true
79
+ }, sdkRequestOptions).asResponse();
80
+ await notifyProviderHttpResponse({
81
+ options: requestOptions,
82
+ response,
83
+ model
84
+ });
85
+ return {
86
+ response,
87
+ isOAuthToken,
88
+ builtParams
89
+ };
90
+ } catch (error) {
91
+ const required = isOAuthToken ? readRequiredClaudeCodeVersion(error) : void 0;
92
+ if (canRetry && required && raiseClaudeCodeVersionFloor(required)) {
93
+ try {
94
+ requestOptions?.onClaudeCodeVersionRequired?.(required);
95
+ } catch {}
96
+ return send(false);
97
+ }
98
+ throw error;
99
+ }
73
100
  };
74
- const response = await client.messages.create({
75
- ...params,
76
- stream: true
77
- }, sdkRequestOptions).asResponse();
78
- await notifyProviderHttpResponse({
79
- options: requestOptions,
80
- response,
81
- model
82
- });
101
+ const { response, isOAuthToken, builtParams } = await send(true);
83
102
  await consumeAnthropicStream({
84
103
  events: iterateAnthropicEvents(response, requestOptions?.signal),
85
104
  model,
@@ -133,6 +152,7 @@ const streamSimpleAnthropic = (model, context, options) => {
133
152
  anthropicCompactThreshold: options?.anthropicCompactThreshold,
134
153
  cacheTtlPruning: options?.cacheTtlPruning,
135
154
  onCompactionRejected: options?.onCompactionRejected,
155
+ onClaudeCodeVersionRequired: options?.onClaudeCodeVersionRequired,
136
156
  authProfileId: options?.authProfileId,
137
157
  maxTokens: clampMaxTokensToModel(model, options?.maxTokens ?? model.maxTokens),
138
158
  toolChoice: options?.toolChoice,
@@ -1,6 +1,6 @@
1
- import "./index-DSprYWaz.mjs";
1
+ import "./index-B8ODIVmA.mjs";
2
2
  import { k as Model } from "./types-CVYzKrMl.mjs";
3
- import { t as AnthropicContextManagementOptions } from "./provider-options-Bo8GzTGX.mjs";
3
+ import { t as AnthropicContextManagementOptions } from "./provider-options-DFjnfImJ.mjs";
4
4
  import { TextBlockParam } from "@anthropic-ai/sdk/resources/messages.js";
5
5
  //#region packages/ai/src/transports/anthropic-payload-policy.d.ts
6
6
  /** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
@@ -1,21 +1,21 @@
1
- import { E as supportsClaudeInHistorySystemMessages, O as supportsClaudeNativeXhighEffort, S as resolveClaudeSonnet5ModelIdentity, b as resolveClaudeOpus5ModelIdentity, d as requiresClaudeBetweenToolsThinking, g as resolveClaudeModelIdentity, h as resolveClaudeHaiku55ModelIdentity, k as supportsClaudeServerCompaction, m as resolveClaudeFable5ModelIdentity, u as bindsClaudeThinkingPrefix, w as supportsClaudeAdaptiveThinking, x as resolveClaudeSonnet55ModelIdentity, y as resolveClaudeOpus55ModelIdentity } from "./src-CyA0zJnt.mjs";
1
+ import { A as supportsClaudeNativeXhighEffort, C as resolveClaudeSonnet55ModelIdentity, E as supportsClaudeAdaptiveThinking, M as usesClaude5RequestContract, O as supportsClaudeInHistorySystemMessages, S as resolveClaudeOpus5ModelIdentity, _ as resolveClaudeHaiku55ModelIdentity, g as resolveClaudeFable5ModelIdentity, j as supportsClaudeServerCompaction, p as requiresClaudeBetweenToolsThinking, u as bindsClaudeThinkingPrefix, v as resolveClaudeModelIdentity, x as resolveClaudeOpus55ModelIdentity } from "./src--qsViR3j.mjs";
2
2
  import { f as hasRuntimeContextMarker } from "./types-BXd0kI8-.mjs";
3
3
  import { r as appendAssistantThinking } from "./event-stream-X2gmsUWv.mjs";
4
4
  import { a as asRecord, o as isRecord, r as asOptionalObjectRecord, s as readStringField } from "./record-coerce-CNDovvft.mjs";
5
5
  import { a as normalizeOptionalLowercaseString, i as normalizeNullableString } from "./string-coerce-Cj8sqWHx.mjs";
6
6
  import { n as asNonNegativeFiniteNumber } from "./number-coercion-37gmNkuA.mjs";
7
- import { N as isImageWithMediaPayload, O as calculateCost, S as resolveAnthropicThinkingEffort, g as applyClaudeRequestContract, h as ANTHROPIC_CLAUDE_CODE_VERSION, r as getAiTransportHost, u as STREAM_ERROR_FALLBACK_TEXT, v as defaultsClaudeAdaptiveThinking, w as usesClaudeFable5MessagesContract, x as requiresClaudeAdaptiveThinking, y as mapAnthropicStopReason } from "./host-rCxf5Tjd.mjs";
8
- import "./transport-utils-CcCAuFVS.mjs";
7
+ import { C as requiresClaudeAdaptiveThinking, D as usesClaudeFable5MessagesContract, I as isImageWithMediaPayload, T as resolveAnthropicThinkingEffort, g as applyClaudeRequestContract, h as ANTHROPIC_CLAUDE_CODE_VERSION, j as calculateCost, r as getAiTransportHost, u as STREAM_ERROR_FALLBACK_TEXT, v as defaultsClaudeAdaptiveThinking, y as mapAnthropicStopReason } from "./host-CyGba3M8.mjs";
8
+ import "./transport-utils-4xPfuKp2.mjs";
9
9
  import { n as estimateBase64DecodedBytes } from "./base64-C8CdcsjU.mjs";
10
- import { a as resolveProviderRequestCapabilities, i as resolveProviderEndpoint } from "./host-policy-Ci1cKluf.mjs";
10
+ import { a as resolveProviderRequestCapabilities, i as resolveProviderEndpoint } from "./host-policy-CNQztzZm.mjs";
11
11
  import { i as resolveCacheRetention } from "./cloudflare-Dttf8jKq.mjs";
12
12
  import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
13
- import { S as splitSystemPromptCacheBoundary, T as stripSystemPromptRelocatableBoundary, d as extractToolResultBlockText, f as extractToolResultText, h as preparedRequestSuffix, l as describeToolResultMediaPlaceholder, t as adjustMaxTokensForThinking, w as stripSystemPromptCacheBoundary } from "./simple-options-BdJJbzZk.mjs";
14
- import { C as parseJsonObjectPreservingUnsafeIntegers, E as createToolArgumentPreviewSchedule, O as parseStreamingJson, b as transportAbortError, d as iterateModelStream, i as copyProviderAcceptanceObserver, l as finalizeTerminalToolCallArguments, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-DdnJGEj0.mjs";
13
+ import { S as splitSystemPromptCacheBoundary, T as stripSystemPromptRelocatableBoundary, d as extractToolResultBlockText, f as extractToolResultText, h as preparedRequestSuffix, l as describeToolResultMediaPlaceholder, t as adjustMaxTokensForThinking, w as stripSystemPromptCacheBoundary } from "./simple-options-Bd0STwu7.mjs";
14
+ import { C as parseJsonObjectPreservingUnsafeIntegers, E as createToolArgumentPreviewSchedule, O as parseStreamingJson, b as transportAbortError, d as iterateModelStream, i as copyProviderAcceptanceObserver, l as finalizeTerminalToolCallArguments, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-C1AtJhZA.mjs";
15
15
  import { t as parsePositiveInteger } from "./positive-integer-Bb4Evc7L.mjs";
16
- import { n as isProviderReplayContext, r as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-BC23HyZo.mjs";
17
- import { n as transformProviderMessages } from "./assistant-output-DbgdWAhJ.mjs";
18
- import { a as reconcileAnthropicToolChoice, i as projectAnthropicTools, n as normalizeAnthropicToolChoice, o as resolveOriginalAnthropicToolName, s as toClaudeCodeToolName, t as normalizeAnthropicToolCallId } from "./anthropic-tool-projection-DA_KeluM.mjs";
16
+ import { n as isProviderReplayContext, r as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-C5uMjBz4.mjs";
17
+ import { n as transformProviderMessages } from "./assistant-output-Hl3b-ViJ.mjs";
18
+ import { a as reconcileAnthropicToolChoice, i as projectAnthropicTools, n as normalizeAnthropicToolChoice, o as resolveOriginalAnthropicToolName, s as toClaudeCodeToolName, t as normalizeAnthropicToolCallId } from "./anthropic-tool-projection-CrsCkF4k.mjs";
19
19
  import { t as notifyLlmRequestActivity } from "./llm-request-activity-CfMuh5cC.mjs";
20
20
  //#region packages/ai/src/providers/anthropic-auth-headers.ts
21
21
  /** Inspect resolved credential shape for auth routing without exposing its value. */
@@ -660,7 +660,7 @@ function resolveAnthropicTransportOptions(model, options, apiKey) {
660
660
  modelContextWindow: model.contextWindow,
661
661
  modelMaxTokens: model.maxTokens,
662
662
  requestedMaxTokens: options?.maxTokens,
663
- useModelDefault: resolveClaudeHaiku55ModelIdentity(model) !== void 0 || resolveClaudeSonnet5ModelIdentity(model) !== void 0 || resolveClaudeOpus5ModelIdentity(model) !== void 0
663
+ useModelDefault: usesClaude5RequestContract(model)
664
664
  });
665
665
  if (baseMaxTokens === void 0) throw new Error(`Anthropic Messages transport requires a positive maxTokens value for ${model.provider}/${model.id}`);
666
666
  const resolved = copyProviderAcceptanceObserver(options, {
@@ -684,6 +684,7 @@ function resolveAnthropicTransportOptions(model, options, apiKey) {
684
684
  anthropicServerCompaction: options?.anthropicServerCompaction,
685
685
  anthropicCompactThreshold: options?.anthropicCompactThreshold,
686
686
  cacheTtlPruning: options?.cacheTtlPruning,
687
+ onClaudeCodeVersionRequired: options?.onClaudeCodeVersionRequired,
687
688
  ...options?.authProfileId ? { authProfileId: options.authProfileId } : {}
688
689
  });
689
690
  resolved.reasoning = applyAnthropicThinkingOptions(model, resolved, options, "transport");
@@ -978,7 +979,6 @@ async function buildAnthropicRequest(model, context, options, profile, isOAuthTo
978
979
  }
979
980
  const replayPlan = buildAnthropicReplayPlan(context.messages, model, {
980
981
  enabled: !isOAuthToken && options?.anthropicServerCompaction === true,
981
- authProfileId: options?.authProfileId,
982
982
  sessionId: options?.sessionId
983
983
  });
984
984
  const cacheBreakpointOptOutMessageIndexes = /* @__PURE__ */ new Set();
@@ -1,6 +1,6 @@
1
1
  import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
2
2
  import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-D_MeCQFI.mjs";
3
- import { _ as SCHEMA_MAP_KEYS, d as inheritToolSchemaTruncation, g as SCHEMA_ARRAY_KEYS, i as publishRuntimeToolInputSchema, r as projectRuntimeToolInputSchema, t as getPublishedRuntimeToolInputSchema, y as SCHEMA_OBJECT_KEYS } from "./tool-schema-json-projection-Cvq69Ajp.mjs";
3
+ import { _ as SCHEMA_MAP_KEYS, d as inheritToolSchemaTruncation, g as SCHEMA_ARRAY_KEYS, i as publishRuntimeToolInputSchema, r as projectRuntimeToolInputSchema, t as getPublishedRuntimeToolInputSchema, y as SCHEMA_OBJECT_KEYS } from "./tool-schema-json-projection-DU-FFSa7.mjs";
4
4
  //#region packages/ai/src/providers/anthropic-tool-projection.ts
5
5
  const CLAUDE_CODE_TOOL_LOOKUP = new Map([
6
6
  "Read",
@@ -1,4 +1,4 @@
1
- import { r as AnthropicOptions } from "./provider-options-Bo8GzTGX.mjs";
1
+ import { r as AnthropicOptions } from "./provider-options-DFjnfImJ.mjs";
2
2
  import { Tool } from "@anthropic-ai/sdk/resources/messages.js";
3
3
  //#region packages/ai/src/providers/anthropic-tool-projection.d.ts
4
4
  type AnthropicToolDescriptor = {
@@ -1,4 +1,4 @@
1
- import "./index-DSprYWaz.mjs";
1
+ import "./index-B8ODIVmA.mjs";
2
2
  import { Q as SimpleStreamOptions, n as Api, nt as StreamOptions, tt as StreamFunction } from "./types-CVYzKrMl.mjs";
3
3
  //#region packages/ai/src/api-registry.d.ts
4
4
  /** Runtime stream adapter signature stored in the API provider registry. */
@@ -1,5 +1,5 @@
1
- import { c as transformMessages } from "./host-rCxf5Tjd.mjs";
2
- import { a as createEmptyTransportUsage } from "./transport-stream-shared-DdnJGEj0.mjs";
1
+ import { c as transformMessages } from "./host-CyGba3M8.mjs";
2
+ import { a as createEmptyTransportUsage } from "./transport-stream-shared-C1AtJhZA.mjs";
3
3
  //#region packages/ai/src/provider-transcript-transform.ts
4
4
  const IMAGE_OMISSION = "(image omitted: model does not support images)";
5
5
  const VIDEO_OMISSION = "(video omitted: provider does not support video input)";
@@ -26,7 +26,7 @@ function transformProviderMessages(messages, model, normalizeToolCallId) {
26
26
  };
27
27
  return transformMessages(messages.map((message) => {
28
28
  if (message.role !== "user" || !Array.isArray(message.content)) return message;
29
- return Object.assign({}, message, { content: projectUserMediaForTransport(message.content, model.input.includes("image"), model.api === "openai-completions" && model.input.includes("video")) });
29
+ return Object.assign({}, message, { content: projectUserMediaForTransport(message.content, model.input.includes("image"), (model.api === "openai-completions" || model.api === "google-interactions") && model.input.includes("video")) });
30
30
  }), target, normalizeToolCallId);
31
31
  }
32
32
  //#endregion
@@ -1,12 +1,12 @@
1
1
  import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
2
- import { r as getAiTransportHost } from "./host-rCxf5Tjd.mjs";
3
- import { n as buildBaseOptions } from "./simple-options-BdJJbzZk.mjs";
2
+ import { r as getAiTransportHost } from "./host-CyGba3M8.mjs";
3
+ import { n as buildBaseOptions } from "./simple-options-Bd0STwu7.mjs";
4
4
  import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
5
- import { t as createAssistantOutput } from "./assistant-output-DbgdWAhJ.mjs";
6
- import { F as convertProviderResponsesMessages, Lt as resolvePromptCacheKey, Rt as withOpenAIErrorResponseHook, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams, vt as resolveOpenAISimpleReasoningEffort } from "./openai-responses-shared-CNfHudFg.mjs";
5
+ import { t as createAssistantOutput } from "./assistant-output-Hl3b-ViJ.mjs";
6
+ import { F as convertProviderResponsesMessages, Lt as resolvePromptCacheKey, Rt as withOpenAIErrorResponseHook, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams, vt as resolveOpenAISimpleReasoningEffort } from "./openai-responses-shared-BDGaQxiw.mjs";
7
+ import { n as OpenAI, t as AzureOpenAI } from "./openai-BfFy1nvf.mjs";
7
8
  import { i as resolveAzureDeploymentNameFromMap, n as isTraditionalAzureOpenAIHost, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-D0dvJMbZ.mjs";
8
9
  import { t as requireApiKey } from "./required-api-key-D088S4Cd.mjs";
9
- import OpenAI, { AzureOpenAI } from "openai";
10
10
  //#region packages/ai/src/providers/azure-openai-responses.ts
11
11
  const DEFAULT_AZURE_API_VERSION = "v1";
12
12
  const AZURE_TOOL_CALL_PROVIDERS = /* @__PURE__ */ new Set([
@@ -102,7 +102,6 @@ function buildParams(model, context, options, deploymentName, replayMode) {
102
102
  model: deploymentName,
103
103
  input: convertProviderResponsesMessages(model, context, AZURE_TOOL_CALL_PROVIDERS, {
104
104
  sessionId: options?.sessionId,
105
- authProfileId: options?.authProfileId,
106
105
  replayMode
107
106
  }),
108
107
  stream: true,
@@ -167,6 +167,22 @@ function resolveResponsesTerminalStopReason(params) {
167
167
  //#endregion
168
168
  //#region packages/ai/src/transports/openai-responses-stream-errors.ts
169
169
  const OUTPUT_IDENTITY_ERROR_CODE = "responses_output_identity_conflict";
170
+ const TOOL_CALL_WHITESPACE = /\s/u;
171
+ var DegenerateToolCallArgumentsError = class extends Error {
172
+ constructor() {
173
+ super("Tool-call argument stream exceeded the consecutive whitespace limit");
174
+ this.code = "degenerate_output";
175
+ this.name = "DegenerateToolCallArgumentsError";
176
+ }
177
+ };
178
+ function countToolCallTrailingWhitespace(delta, previous = 0) {
179
+ const limit = 32768;
180
+ let tail = 0;
181
+ for (let index = delta.length - 1; index >= 0 && tail < limit && TOOL_CALL_WHITESPACE.test(delta.charAt(index)); index--) tail += 1;
182
+ const count = tail === delta.length ? previous + tail : tail;
183
+ if (count >= limit) throw new DegenerateToolCallArgumentsError();
184
+ return count;
185
+ }
170
186
  function outputType(type) {
171
187
  return type === "reasoning" || type === "message" || type === "function_call" || type === "compaction" ? type : "other";
172
188
  }
@@ -329,4 +345,4 @@ function formatModelTransportDebugBaseUrl(rawUrl) {
329
345
  return rawUrl ? formatModelTransportDebugUrl(rawUrl) : "default";
330
346
  }
331
347
  //#endregion
332
- export { resolveResponsesTerminalStopReason as _, resolveModelPayloadDebugMode as a, hasRetryableConnectionErrorCode as c, hasOnlyResponsesFunctionTools as d, isResponsesProviderTool as f, readResponsesReasoningTokens as g, mapResponsesTerminalUsage as h, emitModelTransportError as i, isTransientNetworkError as l, isResponsesOutputLimitToolCallError as m, formatModelTransportDebugUrl as n, resolveModelSseDebugMode as o, resolveResponsesOutputIdentityRetry as p, emitModelTransportDebug as r, WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE as s, formatModelTransportDebugBaseUrl as t, ResponsesOutputIdentityError as u, extractErrorCodeOrErrno as v, toErrorObject as y };
348
+ export { mapResponsesTerminalUsage as _, resolveModelPayloadDebugMode as a, extractErrorCodeOrErrno as b, hasRetryableConnectionErrorCode as c, ResponsesOutputIdentityError as d, countToolCallTrailingWhitespace as f, isResponsesOutputLimitToolCallError as g, resolveResponsesOutputIdentityRetry as h, emitModelTransportError as i, isTransientNetworkError as l, isResponsesProviderTool as m, formatModelTransportDebugUrl as n, resolveModelSseDebugMode as o, hasOnlyResponsesFunctionTools as p, emitModelTransportDebug as r, WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE as s, formatModelTransportDebugBaseUrl as t, DegenerateToolCallArgumentsError as u, readResponsesReasoningTokens as v, toErrorObject as x, resolveResponsesTerminalStopReason as y };
@@ -1,7 +1,7 @@
1
- import { o as ProviderRefusalReview, s as readProviderRefusalReview } from "./index-DSprYWaz.mjs";
1
+ import { o as ProviderRefusalReview, s as readProviderRefusalReview } from "./index-B8ODIVmA.mjs";
2
2
  import { At as extractDiagnosticError, Dt as DiagnosticErrorInfo, Et as AssistantMessageDiagnostic, Mt as isProviderRefusalAssistantError, Ot as appendAssistantMessageDiagnostic, a as AssistantMessage, jt as formatThrownValue, kt as createAssistantMessageDiagnostic } from "./types-CVYzKrMl.mjs";
3
- import "./types-CBJthzJX.mjs";
4
- import { n as isResponsesOutputLimitToolCallError } from "./openai-responses-terminal-usage-CpVjkqn-.mjs";
3
+ import "./types-BFfXm_Jr.mjs";
4
+ import { n as isResponsesOutputLimitToolCallError } from "./openai-responses-terminal-usage-BDGDBGuA.mjs";
5
5
  import { n as ProviderErrorRedactor, r as configureProviderErrorRedactor } from "./provider-error-CnaWYTRY.mjs";
6
6
  import { i as projectDiagnosticValue, t as DiagnosticProjectionPolicy } from "./credential-redaction-XvsPf7Yi.mjs";
7
7
  import { i as emitModelTransportError, n as formatModelTransportDebugUrl, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./model-transport-url-BrsjjdjR.mjs";
@@ -1,4 +1,4 @@
1
1
  import { a as isProviderRefusalAssistantError, i as formatThrownValue, n as createAssistantMessageDiagnostic, o as readProviderRefusalReview, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
2
2
  import { a as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-qtZD2inE.mjs";
3
- import { c as hasRetryableConnectionErrorCode, i as emitModelTransportError, l as isTransientNetworkError, m as isResponsesOutputLimitToolCallError, n as formatModelTransportDebugUrl, p as resolveResponsesOutputIdentityRetry, r as emitModelTransportDebug, s as WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, t as formatModelTransportDebugBaseUrl } from "./diagnostics-Cv7cW3pS.mjs";
3
+ import { c as hasRetryableConnectionErrorCode, g as isResponsesOutputLimitToolCallError, h as resolveResponsesOutputIdentityRetry, i as emitModelTransportError, l as isTransientNetworkError, n as formatModelTransportDebugUrl, r as emitModelTransportDebug, s as WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, t as formatModelTransportDebugBaseUrl } from "./diagnostics-v7oVEW59.mjs";
4
4
  export { WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, emitModelTransportDebug, emitModelTransportError, extractDiagnosticError, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, formatThrownValue, hasRetryableConnectionErrorCode, isProviderRefusalAssistantError, isResponsesOutputLimitToolCallError, isTransientNetworkError, projectDiagnosticValue, readProviderRefusalReview, resolveResponsesOutputIdentityRetry };
@@ -1,8 +1,8 @@
1
- import { r as getAiTransportHost } from "./host-rCxf5Tjd.mjs";
1
+ import { r as getAiTransportHost } from "./host-CyGba3M8.mjs";
2
2
  import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
3
3
  import { n as resolveOpencodeSessionHeaders } from "./session-affinity-DA4WHv1h.mjs";
4
4
  import { t as requireApiKey } from "./required-api-key-D088S4Cd.mjs";
5
- import { n as buildGoogleHttpOptions, t as createGoogleGenerateContentStreams } from "./google-provider-stream-DlhaCvCf.mjs";
5
+ import { n as buildGoogleHttpOptions, t as createGoogleGenerateContentStreams } from "./google-provider-stream-DL0bXgX5.mjs";
6
6
  import { GoogleGenAI } from "@google/genai";
7
7
  //#region packages/ai/src/providers/google.ts
8
8
  const { stream: streamGoogle, streamSimple: streamSimpleGoogle } = createGoogleGenerateContentStreams("google-generative-ai", (model, options) => {
@@ -1,16 +1,18 @@
1
1
  import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
2
2
  import { a as asRecord, i as asOptionalRecord, s as readStringField } from "./record-coerce-CNDovvft.mjs";
3
- import { O as calculateCost, a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-rCxf5Tjd.mjs";
4
- import { s as streamFragmentError } from "./transport-utils-CcCAuFVS.mjs";
5
- import { t as buildGuardedModelFetch } from "./host-policy-Ci1cKluf.mjs";
3
+ import { a as resolveAiTransportHeaderSentinels, j as calculateCost, r as getAiTransportHost } from "./host-CyGba3M8.mjs";
4
+ import { s as streamFragmentError } from "./transport-utils-4xPfuKp2.mjs";
5
+ import { t as buildGuardedModelFetch } from "./host-policy-CNQztzZm.mjs";
6
6
  import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
7
- import { n as buildBaseOptions, w as stripSystemPromptCacheBoundary } from "./simple-options-BdJJbzZk.mjs";
8
- import { b as transportAbortError, c as failTransportStream, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, m as notifyProviderHttpResponse, w as parseJsonPreservingUnsafeIntegers } from "./transport-stream-shared-DdnJGEj0.mjs";
7
+ import { n as buildBaseOptions, w as stripSystemPromptCacheBoundary } from "./simple-options-Bd0STwu7.mjs";
8
+ import { b as transportAbortError, c as failTransportStream, f as mergeTransportHeaders, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, m as notifyProviderHttpResponse, w as parseJsonPreservingUnsafeIntegers } from "./transport-stream-shared-C1AtJhZA.mjs";
9
9
  import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
10
- import { n as transformProviderMessages, t as createAssistantOutput } from "./assistant-output-DbgdWAhJ.mjs";
11
- import { n as buildGoogleInteractionsSimpleThinking } from "./google-shared-Cif7nve-.mjs";
10
+ import { n as transformProviderMessages, t as createAssistantOutput } from "./assistant-output-Hl3b-ViJ.mjs";
11
+ import { n as createGoogleVideoPlaceholder, r as materializeGoogleVideoSlots, t as GOOGLE_VIDEO_SLOT_OMISSION } from "./google-video-slots-D8tPH8wX.mjs";
12
+ import { PROVIDER_CONTEXT_HANDOFF, PROVIDER_MODEL_INPUT, resolveProviderContext } from "./provider-types.mjs";
13
+ import { n as buildGoogleInteractionsSimpleThinking } from "./google-shared-DXizMtnG.mjs";
12
14
  //#region packages/ai/package.json
13
- var version = "2026.10.10-beta.5";
15
+ var version = "2026.10.33";
14
16
  //#endregion
15
17
  //#region packages/ai/src/providers/google-interactions-request.ts
16
18
  const DEFAULT_GOOGLE_API_BASE_URL = "https://generativelanguage.googleapis.com";
@@ -32,7 +34,7 @@ function resolveGoogleApiClientHeaders(params) {
32
34
  "x-goog-api-client": `openclaw/${resolvePackageVersion()}`
33
35
  };
34
36
  }
35
- function convertMessages(model, context) {
37
+ function convertMessages(model, context, videoSlots) {
36
38
  const steps = [];
37
39
  const messages = transformProviderMessages(context.messages, model);
38
40
  for (const message of messages) {
@@ -41,13 +43,20 @@ function convertMessages(model, context) {
41
43
  const content = (typeof sourceContent === "string" ? [{
42
44
  type: "text",
43
45
  text: sourceContent
44
- }] : sourceContent).map((item) => item.type === "text" ? {
45
- type: "text",
46
- text: sanitizeSurrogates(item.text) || " "
47
- } : {
48
- type: "image",
49
- mime_type: item.mimeType,
50
- data: item.data
46
+ }] : sourceContent).map((item) => {
47
+ if (item.type === "text") return {
48
+ type: "text",
49
+ text: sanitizeSurrogates(item.text) || " "
50
+ };
51
+ if (item.type === "video") return createGoogleVideoPlaceholder(item, videoSlots, {
52
+ type: "text",
53
+ text: GOOGLE_VIDEO_SLOT_OMISSION
54
+ });
55
+ return {
56
+ type: "image",
57
+ mime_type: item.mimeType,
58
+ data: item.data
59
+ };
51
60
  });
52
61
  steps.push({
53
62
  type: "user_input",
@@ -122,12 +131,20 @@ function convertMessages(model, context) {
122
131
  }
123
132
  return steps;
124
133
  }
125
- function buildGoogleInteractionsParams(model, context, options = {}) {
126
- const optionRecord = asRecord(options);
127
- if (optionRecord.cachedContent || optionRecord.cached_content) throw new Error("Explicit prompt caching ('cachedContent') is not supported with the Gemini Interactions API. The Interactions API handles caching implicitly on the server.");
128
- if (optionRecord.videoMetadata || optionRecord.video_metadata) throw new Error("video_metadata clipping offsets are not supported with the Gemini Interactions API.");
134
+ /** Maps the shared tool-choice vocabulary (as GenerateContent does) to Interactions. */
135
+ function normalizeGoogleInteractionsToolChoice(choice) {
136
+ if (choice === "auto" || choice === "none" || choice === "any") return choice;
137
+ if (choice === "required") return "any";
138
+ const name = asRecord(asRecord(choice).function).name;
139
+ return asRecord(choice).type === "function" && typeof name === "string" && name ? { allowed_tools: {
140
+ mode: "any",
141
+ tools: [name]
142
+ } } : void 0;
143
+ }
144
+ function buildGoogleInteractionsParams(model, context, options = {}, videoSlots) {
129
145
  const generationConfig = {};
130
146
  if (options.temperature !== void 0) generationConfig.temperature = options.temperature;
147
+ if (options.topP !== void 0) generationConfig.top_p = options.topP;
131
148
  if (options.maxTokens !== void 0) generationConfig.max_output_tokens = options.maxTokens;
132
149
  if (options.stop && options.stop.length > 0) generationConfig.stop_sequences = options.stop;
133
150
  if (options.thinking) {
@@ -144,7 +161,10 @@ function buildGoogleInteractionsParams(model, context, options = {}) {
144
161
  }));
145
162
  return {
146
163
  model: model.id,
147
- input: convertMessages(model, context),
164
+ input: convertMessages({
165
+ ...model,
166
+ input: options[PROVIDER_MODEL_INPUT] ?? model.input
167
+ }, context, videoSlots),
148
168
  ...context.systemPrompt ? { system_instruction: sanitizeSurrogates(stripSystemPromptCacheBoundary(context.systemPrompt)) } : {},
149
169
  ...tools && tools.length > 0 ? { tools } : {},
150
170
  ...Object.keys(generationConfig).length > 0 ? { generation_config: generationConfig } : {},
@@ -183,12 +203,44 @@ async function runGoogleInteractionsLifecycle(params) {
183
203
  const unresolvedApiKey = resolveGoogleInteractionsApiKey(model, options);
184
204
  const apiKey = host.resolveSecretSentinel(unresolvedApiKey);
185
205
  if (!apiKey.trim()) throw new Error(`No API key for provider: ${model.provider}`);
186
- let body = buildGoogleInteractionsParams(model, context, options);
206
+ const providerContext = (options?.[PROVIDER_MODEL_INPUT] ?? model.input).includes("video") ? await resolveProviderContext(context, options) : context;
207
+ const videoSlots = /* @__PURE__ */ new Map();
208
+ let body = buildGoogleInteractionsParams(model, providerContext, options, videoSlots);
187
209
  const nextBody = await options?.onPayload?.(body, model);
188
210
  if (nextBody !== void 0) {
189
211
  if (!isGoogleInteractionsRequestBody(nextBody)) throw new Error("Google Interactions onPayload returned an invalid request body");
190
212
  body = nextBody;
191
213
  }
214
+ const optionRecord = asRecord(options);
215
+ const metadata = asRecord(optionRecord.videoMetadata ?? optionRecord.video_metadata);
216
+ const processing = {};
217
+ for (const [camel, snake] of [
218
+ ["startOffset", "start_offset"],
219
+ ["endOffset", "end_offset"],
220
+ ["fps", "fps"]
221
+ ]) {
222
+ const value = metadata[camel] ?? metadata[snake];
223
+ if (value !== void 0) processing[snake] = value;
224
+ }
225
+ materializeGoogleVideoSlots(body, videoSlots, (slot, video) => {
226
+ Object.assign(slot, {
227
+ type: "video",
228
+ mime_type: video.mimeType,
229
+ data: video.data,
230
+ ...Object.keys(processing).length > 0 ? { processing: {
231
+ type: "static",
232
+ ...processing
233
+ } } : {}
234
+ });
235
+ }, (part) => {
236
+ if (part.type === "video") {
237
+ Object.keys(part).forEach((key) => Reflect.deleteProperty(part, key));
238
+ Object.assign(part, {
239
+ type: "text",
240
+ text: GOOGLE_VIDEO_SLOT_OMISSION
241
+ });
242
+ }
243
+ });
192
244
  let baseUrl = (model.baseUrl || "https://generativelanguage.googleapis.com/v1beta").trim().replace(/\/+$/, "");
193
245
  if (/^https:\/\/generativelanguage\.googleapis\.com$/i.test(baseUrl)) baseUrl = "https://generativelanguage.googleapis.com/v1beta";
194
246
  const url = `${baseUrl}/interactions?alt=sse`;
@@ -197,14 +249,14 @@ async function runGoogleInteractionsLifecycle(params) {
197
249
  api: "google-generative-ai",
198
250
  model
199
251
  });
200
- const headers = resolveAiTransportHeaderSentinels({
252
+ const headers = resolveAiTransportHeaderSentinels(mergeTransportHeaders({
201
253
  "Content-Type": "application/json",
202
- "x-goog-api-key": apiKey,
203
- "Api-Revision": "2026-05-20",
204
- ...googleClientHeaders,
205
- ...model.headers,
206
- ...options?.headers
207
- }) ?? {
254
+ ...apiKey.trimStart().startsWith("{") && Object.keys({
255
+ ...model.headers,
256
+ ...options?.headers
257
+ }).some((name) => name.toLowerCase() === "authorization") ? {} : { "x-goog-api-key": apiKey },
258
+ "Api-Revision": "2026-05-20"
259
+ }, googleClientHeaders, model.headers, options?.headers)) ?? {
208
260
  "Content-Type": "application/json",
209
261
  "x-goog-api-key": apiKey
210
262
  };
@@ -508,9 +560,18 @@ const streamSimpleGoogleInteractions = (model, context, options) => {
508
560
  const apiKey = resolveGoogleInteractionsApiKey(model, options);
509
561
  if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
510
562
  const base = buildBaseOptions(model, options, apiKey);
563
+ const providerOptions = options;
564
+ const record = asRecord(options);
565
+ const toolChoice = normalizeGoogleInteractionsToolChoice(record.toolChoice);
566
+ const videoMetadata = record.videoMetadata ?? record.video_metadata;
511
567
  return streamGoogleInteractions(model, context, {
512
568
  ...base,
513
- thinking: buildGoogleInteractionsSimpleThinking(model, options)
569
+ ...typeof record.topP === "number" ? { topP: record.topP } : {},
570
+ [PROVIDER_MODEL_INPUT]: providerOptions?.[PROVIDER_MODEL_INPUT],
571
+ [PROVIDER_CONTEXT_HANDOFF]: providerOptions?.[PROVIDER_CONTEXT_HANDOFF],
572
+ thinking: buildGoogleInteractionsSimpleThinking(model, options),
573
+ ...toolChoice ? { toolChoice } : {},
574
+ ...videoMetadata !== void 0 ? { videoMetadata } : {}
514
575
  });
515
576
  };
516
577
  //#endregion
@@ -1,11 +1,13 @@
1
+ import { f as hasRuntimeContextMarker } from "./types-BXd0kI8-.mjs";
1
2
  import { r as appendAssistantThinking } from "./event-stream-X2gmsUWv.mjs";
2
- import { N as isImageWithMediaPayload, O as calculateCost } from "./host-rCxf5Tjd.mjs";
3
+ import { I as isImageWithMediaPayload, j as calculateCost } from "./host-CyGba3M8.mjs";
3
4
  import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
4
5
  import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-D_MeCQFI.mjs";
5
- import { f as extractToolResultText, l as describeToolResultMediaPlaceholder } from "./simple-options-BdJJbzZk.mjs";
6
- import { a as createEmptyTransportUsage, b as transportAbortError, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-DdnJGEj0.mjs";
6
+ import { f as extractToolResultText, l as describeToolResultMediaPlaceholder } from "./simple-options-Bd0STwu7.mjs";
7
+ import { a as createEmptyTransportUsage, b as transportAbortError, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-C1AtJhZA.mjs";
7
8
  import { t as notifyLlmRequestActivity } from "./llm-request-activity-CfMuh5cC.mjs";
8
9
  import { isGoogleGemini4Model } from "./internal/google-model-family.mjs";
10
+ import "./types.mjs";
9
11
  //#region packages/ai/src/transports/google-thinking-level.ts
10
12
  /** Reports MINIMAL support for Gemini Flash and Gemini 4 models. */
11
13
  function googleFlashSupportsMinimalThinking(modelId) {
@@ -311,6 +313,10 @@ function projectGoogleMessages(params) {
311
313
  });
312
314
  const visibleParts = managed && !model.input.includes("image") ? parts.filter((part) => !part.inlineData) : parts;
313
315
  if (visibleParts.length === 0) visibleParts.push({ text: " " });
316
+ if (hasRuntimeContextMarker(msg)) {
317
+ visibleParts.unshift({ text: "The following is runtime context, not a user request. Do not respond to or acknowledge this context." });
318
+ visibleParts.push({ text: "Use this context to continue responding to the user's request." });
319
+ }
314
320
  contents.push({
315
321
  role: "user",
316
322
  parts: visibleParts
@@ -1,10 +1,11 @@
1
1
  import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
2
- import { a as resolveAiTransportHeaderSentinels } from "./host-rCxf5Tjd.mjs";
3
- import { n as buildManagedModelFetch } from "./host-policy-Ci1cKluf.mjs";
4
- import { n as buildBaseOptions } from "./simple-options-BdJJbzZk.mjs";
5
- import { f as mergeTransportHeaders } from "./transport-stream-shared-DdnJGEj0.mjs";
6
- import { t as createAssistantOutput } from "./assistant-output-DbgdWAhJ.mjs";
7
- import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-Cif7nve-.mjs";
2
+ import { a as asRecord } from "./record-coerce-CNDovvft.mjs";
3
+ import { a as resolveAiTransportHeaderSentinels } from "./host-CyGba3M8.mjs";
4
+ import { n as buildManagedModelFetch } from "./host-policy-CNQztzZm.mjs";
5
+ import { n as buildBaseOptions } from "./simple-options-Bd0STwu7.mjs";
6
+ import { f as mergeTransportHeaders } from "./transport-stream-shared-C1AtJhZA.mjs";
7
+ import { t as createAssistantOutput } from "./assistant-output-Hl3b-ViJ.mjs";
8
+ import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-DXizMtnG.mjs";
8
9
  import { ResourceScope } from "@google/genai";
9
10
  //#region packages/ai/src/providers/google-http-options.ts
10
11
  function buildGoogleHttpOptions(model, optionsHeaders, profile) {
@@ -22,7 +23,7 @@ function buildGoogleHttpOptions(model, optionsHeaders, profile) {
22
23
  } else if (model.baseUrl) {
23
24
  httpOptions.baseUrl = model.baseUrl;
24
25
  httpOptions.apiVersion = "";
25
- }
26
+ } else httpOptions.apiVersion = "v1beta";
26
27
  if (model.headers || optionsHeaders) httpOptions.headers = resolveAiTransportHeaderSentinels(profile === "vertex" ? {
27
28
  ...model.headers,
28
29
  ...optionsHeaders
@@ -48,10 +49,14 @@ function createGoogleGenerateContentStreams(api, createClient, resolveSimpleApiK
48
49
  };
49
50
  return {
50
51
  stream,
51
- streamSimple: (model, context, options) => stream(model, context, {
52
- ...buildBaseOptions(model, options, resolveSimpleApiKey?.(model, options)),
53
- thinking: buildGoogleSimpleThinking(model, options)
54
- })
52
+ streamSimple: (model, context, options) => {
53
+ const topP = asRecord(options).topP;
54
+ return stream(model, context, {
55
+ ...buildBaseOptions(model, options, resolveSimpleApiKey?.(model, options)),
56
+ ...typeof topP === "number" ? { topP } : {},
57
+ thinking: buildGoogleSimpleThinking(model, options)
58
+ });
59
+ }
55
60
  };
56
61
  }
57
62
  //#endregion