@openclaw/ai 2026.11.3 → 2026.11.5-beta.2

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 (140) hide show
  1. package/README.md +11 -8
  2. package/dist/.source-module-urls/fe058cc430242ce2ab0dfbcbe153e240a52cf9c3072c3dc0a73e5f956b6ba49b.json +1 -0
  3. package/dist/anthropic-DEKgalVg.mjs +182 -0
  4. package/dist/{anthropic-payload-policy-C0ki72BT.d.mts → anthropic-payload-policy-CXCJ5Pmj.d.mts} +21 -4
  5. package/dist/{anthropic-stream-reducer-yWDb5Cct.mjs → anthropic-stream-lifecycle-DF2qVvg1.mjs} +845 -649
  6. package/dist/{anthropic-tool-projection-C2-d1eZ3.d.mts → anthropic-tool-projection-D5DyrL6C.d.mts} +6 -7
  7. package/dist/{anthropic-tool-projection-DZOKfAmL.mjs → anthropic-tool-projection-dGRfr4iT.mjs} +22 -32
  8. package/dist/{api-registry-gDt0faai.d.mts → api-registry-DY2MLUyg.d.mts} +2 -2
  9. package/dist/assistant-output-CD4kY9gu.mjs +16 -0
  10. package/dist/{azure-openai-responses-BvvXzZbi.mjs → azure-openai-responses-DbQV5RTx.mjs} +47 -53
  11. package/dist/{cloudflare-Dttf8jKq.mjs → cloudflare-BJ2_Xabx.mjs} +1 -1
  12. package/dist/{credential-redaction-XvsPf7Yi.d.mts → credential-redaction-DrgndwTJ.d.mts} +5 -3
  13. package/dist/{deferred-event-buffer-DAvyP7qA.mjs → deferred-event-buffer-tIGkTkTm.mjs} +1 -2
  14. package/dist/{diagnostics-v7oVEW59.mjs → diagnostics-CloVGQiK.mjs} +27 -20
  15. package/dist/{diagnostics-DzrF1h4J.mjs → diagnostics-o1PrVNQb.mjs} +11 -4
  16. package/dist/diagnostics.d.mts +6 -7
  17. package/dist/diagnostics.mjs +4 -4
  18. package/dist/{env-api-keys-Xd8dm_aV.mjs → env-api-keys-BuHc86ya.mjs} +1 -26
  19. package/dist/event-stream-B4ZcSvsu.d.mts +1 -0
  20. package/dist/{event-stream-CzpE1g_o.d.mts → event-stream-BYmtRe8-.d.mts} +1 -1
  21. package/dist/event-stream.d.mts +2 -2
  22. package/dist/event-stream.mjs +1 -2
  23. package/dist/expect-lbe3Hgrh.mjs +8 -0
  24. package/dist/{github-copilot-request-facts-F-EmvkpW.mjs → github-copilot-request-facts-BZ_EMo7X.mjs} +1 -1
  25. package/dist/{google-Cpi_cLKZ.mjs → google-B1g82bn4.mjs} +7 -8
  26. package/dist/{google-interactions-CGINbsjO.mjs → google-interactions-Ckr0Z99Z.mjs} +243 -269
  27. package/dist/{google-messages-DQMgG5yG.mjs → google-messages-A-9d3y5V.mjs} +52 -18
  28. package/dist/{google-provider-stream-BHd0cST9.mjs → google-provider-stream-CNVh4gpm.mjs} +19 -11
  29. package/dist/{google-shared-vtag8bj5.mjs → google-shared-WNM86ZcW.mjs} +72 -42
  30. package/dist/{google-vertex-eKoUnW7N.mjs → google-vertex-CXjleC6g.mjs} +3 -3
  31. package/dist/{google-video-slots-D8tPH8wX.mjs → google-video-slots-Bxt-OXO8.mjs} +1 -1
  32. package/dist/{host-CWt55nnF.mjs → host-DX7ORpeH.mjs} +46 -39
  33. package/dist/{host-jJOffdlW.d.mts → host-ccbwPC3A.d.mts} +17 -9
  34. package/dist/{host-policy-Dm7PM6AD.mjs → host-policy-jCZebuXx.mjs} +2 -2
  35. package/dist/index-Bczt0MnO.d.mts +17 -0
  36. package/dist/index.d.mts +8 -7
  37. package/dist/index.mjs +9 -7
  38. package/dist/internal/anthropic.d.mts +21 -26
  39. package/dist/internal/anthropic.mjs +6 -6
  40. package/dist/internal/google-model-family.mjs +1 -1
  41. package/dist/internal/google.d.mts +15 -0
  42. package/dist/internal/google.mjs +1 -0
  43. package/dist/internal/model-request-body.d.mts +37 -0
  44. package/dist/internal/model-request-body.mjs +106 -0
  45. package/dist/internal/openai-completions-compat.d.mts +1 -1
  46. package/dist/internal/openai-completions-compat.mjs +1 -1
  47. package/dist/internal/openai-responses-payload-policy.d.mts +2 -2
  48. package/dist/internal/openai-responses-payload-policy.mjs +2 -2
  49. package/dist/internal/openai.d.mts +14 -12
  50. package/dist/internal/openai.mjs +11 -10
  51. package/dist/internal/reasoning-tag-text-partitioner.d.mts +26 -0
  52. package/dist/{reasoning-tag-text-partitioner-CU9A4Lg8.mjs → internal/reasoning-tag-text-partitioner.mjs} +313 -111
  53. package/dist/internal/retry-after.d.mts +2 -2
  54. package/dist/internal/retry-after.mjs +96 -32
  55. package/dist/internal/runtime.d.mts +15 -41
  56. package/dist/internal/runtime.mjs +9 -10
  57. package/dist/internal/shared.d.mts +21 -25
  58. package/dist/internal/shared.mjs +9 -98
  59. package/dist/internal/tool-schema.d.mts +10 -10
  60. package/dist/internal/tool-schema.mjs +4 -4
  61. package/dist/{llm-request-activity-CfMuh5cC.mjs → llm-request-activity-DzaHoRAU.mjs} +2 -2
  62. package/dist/mistral-CjHkvsqR.mjs +3741 -0
  63. package/dist/{openai.LICENSE → mistral.LICENSE} +1 -1
  64. package/dist/{model-transport-url-BrsjjdjR.d.mts → model-transport-url-BdksnBqu.d.mts} +6 -8
  65. package/dist/{number-coercion-37gmNkuA.mjs → number-coercion-C7HsBgUL.mjs} +7 -2
  66. package/dist/observe-async-iterator-AlARO5wS.d.mts +178 -0
  67. package/dist/observe-async-iterator-DgmegcZR.mjs +181 -0
  68. package/dist/{openai-chatgpt-responses-BZa3SySh.mjs → openai-chatgpt-responses-CwS5JP7A.mjs} +61 -80
  69. package/dist/{openai-completions-compat-CBvb2eld.d.mts → openai-completions-compat-CJ-NsDzg.d.mts} +12 -6
  70. package/dist/{openai-completions-compat-bNQXF1y9.mjs → openai-completions-compat-CstlTQuF.mjs} +74 -50
  71. package/dist/{openai-completions-CCZ_UHCk.mjs → openai-completions-sj4S-RXQ.mjs} +5 -5
  72. package/dist/openai-completions-transport-BDAIA0_P.mjs +3406 -0
  73. package/dist/{openai-prompt-cache-DgjD-UL5.d.mts → openai-prompt-cache-BZGaIWYh.d.mts} +4 -4
  74. package/dist/{openai-prompt-cache-B9AvdoEo.mjs → openai-prompt-cache-CgDoFhO0.mjs} +5 -4
  75. package/dist/{openai-responses-compaction-replay-_sUXtcwU.d.mts → openai-responses-compaction-replay-CNHk6k53.d.mts} +4 -4
  76. package/dist/{openai-responses-contracts-B1nkeLL6.d.mts → openai-responses-contracts-BXMcvO7F.d.mts} +4 -10
  77. package/dist/{openai-responses-contracts-B5mGAbR6.mjs → openai-responses-contracts-xU-n9AJJ.mjs} +36 -37
  78. package/dist/{openai-responses-endpoint-CfKR6N5f.mjs → openai-responses-endpoint-DCkURKS0.mjs} +55 -8
  79. package/dist/openai-responses-ev_c6oTy.mjs +89 -0
  80. package/dist/{openai-responses-payload-policy-BzM52TTH.d.mts → openai-responses-payload-policy-DyE30gdD.d.mts} +7 -7
  81. package/dist/{openai-responses-request-lifecycle-CTqHc02t.mjs → openai-responses-request-lifecycle-BuOs0mwI.mjs} +12 -26
  82. package/dist/{openai-responses-shared-wx9v1MCn.mjs → openai-responses-shared-BmRQnUPP.mjs} +633 -1493
  83. package/dist/{openai-responses-terminal-usage-CpVjkqn-.d.mts → openai-responses-terminal-usage-D7IhRA6i.d.mts} +9 -3
  84. package/dist/{openai-tool-schema-BTEU2xmN.mjs → openai-tool-schema-CsoYgnWy.mjs} +97 -122
  85. package/dist/otel-Buswj0Mf.mjs +766 -0
  86. package/dist/{overflow-OF3PgPbw.mjs → overflow-CpApyjG2.mjs} +1 -1
  87. package/dist/{positive-integer-Bb4Evc7L.mjs → positive-integer-DiqE5vNi.mjs} +2 -3
  88. package/dist/{prompt-cache-stability-D_MeCQFI.mjs → prompt-cache-stability-w-ICeyOI.mjs} +1 -1
  89. package/dist/{provider-error-qtZD2inE.mjs → provider-error-DD-fo4Rz.mjs} +71 -234
  90. package/dist/{provider-options-DAzsyi49.d.mts → provider-options-Mo8NM5d1.d.mts} +16 -5
  91. package/dist/{provider-replay-context-4vxI7p4V.mjs → provider-replay-context-xyU7-CiT.mjs} +2 -2
  92. package/dist/provider-transcript-transform-DtaxNcC1.mjs +32 -0
  93. package/dist/{provider-transport-turn-state-D_GjPJHe.mjs → provider-transport-turn-state-BIS8maBK.mjs} +4 -4
  94. package/dist/{provider-types-CWl4VXvE.d.mts → provider-types-B1e98js5.d.mts} +3 -3
  95. package/dist/provider-types.d.mts +7 -6
  96. package/dist/providers.d.mts +2 -2
  97. package/dist/providers.mjs +26 -29
  98. package/dist/{record-coerce-CNDovvft.mjs → record-coerce-BQaoiN3r.mjs} +4 -1
  99. package/dist/request-headers-DO4Mqhw1.mjs +10 -0
  100. package/dist/{required-api-key-D088S4Cd.mjs → required-api-key-2zZTkmsi.mjs} +1 -1
  101. package/dist/{retry-after-BrmTv0jL.d.mts → retry-after-DnHBlFS2.d.mts} +21 -1
  102. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  103. package/dist/{sanitize-unicode-ZqVLLEKC.d.mts → sanitize-unicode-BISmUlUv.d.mts} +2 -2
  104. package/dist/{simple-options-xJkqrG_E.mjs → simple-options-tLSeECry.mjs} +108 -82
  105. package/dist/src-BUsVkrNt.mjs +105 -0
  106. package/dist/{src-CyA0zJnt.mjs → src-CQ7nH2mL.mjs} +4 -7
  107. package/dist/stable-stringify-CchQEmeA.mjs +84 -0
  108. package/dist/{stream-C4YDqhFj.mjs → stream-DrtAWu7c.mjs} +2 -6
  109. package/dist/{stream-first-event-timeout-D_TfJHRJ.mjs → stream-first-event-timeout-B7RcufAV.mjs} +16 -13
  110. package/dist/{string-coerce-Cj8sqWHx.mjs → string-coerce-BCuWMIrk.mjs} +1 -1
  111. package/dist/string-normalization-B8TDDBX_.mjs +32 -0
  112. package/dist/telemetry-CvK1yQg7.mjs +582 -0
  113. package/dist/{tool-schema-json-projection-B1sTYwfH.mjs → tool-schema-json-projection-BQpiJlXJ.mjs} +53 -69
  114. package/dist/{transport-stream-shared-lhgkTOz3.mjs → transport-stream-shared-D2uFMhMc.mjs} +177 -93
  115. package/dist/{transport-stream-shared-8ru8eX4s.d.mts → transport-stream-shared-D3IAU4jn.d.mts} +29 -15
  116. package/dist/{transport-utils-DwOpuTjL.mjs → transport-utils-Da_39MYi.mjs} +23 -38
  117. package/dist/transports.d.mts +42 -39
  118. package/dist/transports.mjs +215 -296
  119. package/dist/{types-CVYzKrMl.d.mts → types-BVdTf0YV.d.mts} +38 -3
  120. package/dist/types-Cb3-5WM9.d.mts +1 -0
  121. package/dist/{types-BXd0kI8-.mjs → types-OVEWUaDh.mjs} +3 -1
  122. package/dist/types.d.mts +7 -6
  123. package/dist/types.mjs +7 -5
  124. package/dist/{validation-9FSkE8T-.mjs → validation-DGXqfvkj.mjs} +45 -27
  125. package/dist/{validation-BQ5u20Ru.d.mts → validation-QmyD0E5A.d.mts} +1 -1
  126. package/dist/validation.d.mts +1 -1
  127. package/dist/validation.mjs +1 -2
  128. package/package.json +40 -6
  129. package/dist/anthropic-lueA8LUg.mjs +0 -221
  130. package/dist/assistant-output-BnQm3fov.mjs +0 -47
  131. package/dist/event-stream-CDpFza-M.d.mts +0 -1
  132. package/dist/index-DSprYWaz.d.mts +0 -185
  133. package/dist/mistral-CQ7aoWg2.mjs +0 -512
  134. package/dist/model-request-body-BD5vy4rP.d.mts +0 -17
  135. package/dist/openai-CiRi-nVE.mjs +0 -20077
  136. package/dist/openai-completions-transport-DFvSBbUT.mjs +0 -10881
  137. package/dist/openai-responses-DQsZKUoI.mjs +0 -87
  138. package/dist/rolldown-runtime-B4iAMlE-.mjs +0 -35
  139. package/dist/types-CBJthzJX.d.mts +0 -1
  140. package/dist/ws.LICENSE +0 -20
@@ -1,11 +1,12 @@
1
- import { f as hasRuntimeContextMarker } from "./types-BXd0kI8-.mjs";
1
+ import { p as hasRuntimeContextMarker } from "./types-OVEWUaDh.mjs";
2
2
  import { r as appendAssistantThinking } from "./event-stream-X2gmsUWv.mjs";
3
- import { N as isImageWithMediaPayload, O as calculateCost } from "./host-CWt55nnF.mjs";
3
+ import { a as asRecord, s as isStringArray } from "./record-coerce-BQaoiN3r.mjs";
4
+ import { N as isImageWithMediaPayload, O as calculateCost } from "./host-DX7ORpeH.mjs";
4
5
  import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
5
- import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-D_MeCQFI.mjs";
6
- import { f as extractToolResultText, l as describeToolResultMediaPlaceholder } from "./simple-options-xJkqrG_E.mjs";
7
- import { a as createEmptyTransportUsage, b as transportAbortError, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-lhgkTOz3.mjs";
8
- import { t as notifyLlmRequestActivity } from "./llm-request-activity-CfMuh5cC.mjs";
6
+ import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-w-ICeyOI.mjs";
7
+ import { a as describeToolResultMediaPlaceholder, c as extractToolResultText } from "./simple-options-tLSeECry.mjs";
8
+ import { a as createEmptyTransportUsage, r as coerceTransportToolCallArguments, x as transportAbortError, y as sanitizeTransportPayloadText } from "./transport-stream-shared-D2uFMhMc.mjs";
9
+ import { t as notifyLlmRequestActivity } from "./llm-request-activity-DzaHoRAU.mjs";
9
10
  import { isGoogleGemini4Model } from "./internal/google-model-family.mjs";
10
11
  import "./types.mjs";
11
12
  //#region packages/ai/src/transports/google-thinking-level.ts
@@ -17,6 +18,42 @@ function googleFlashSupportsMinimalThinking(modelId) {
17
18
  return Number.parseInt(match[1] ?? "0", 10) < 7;
18
19
  }
19
20
  //#endregion
21
+ //#region packages/ai/src/providers/google-tool-parameters.ts
22
+ const PYTHON_KEYWORDS = new Set("False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield".split(" "));
23
+ function parameterNames(parameters) {
24
+ const properties = asRecord(parameters.properties);
25
+ const names = /* @__PURE__ */ new Map();
26
+ for (const name of Object.keys(properties)) {
27
+ if (!PYTHON_KEYWORDS.has(name)) continue;
28
+ let alias = `${name}_`;
29
+ while (Object.hasOwn(properties, alias)) alias += "_";
30
+ names.set(name, alias);
31
+ }
32
+ return names;
33
+ }
34
+ function googleToolParameters(parameters) {
35
+ const schema = asRecord(parameters);
36
+ const names = parameterNames(schema);
37
+ if (names.size === 0) return schema;
38
+ const projected = {
39
+ ...schema,
40
+ properties: Object.fromEntries(Object.entries(asRecord(schema.properties)).map(([name, propertySchema]) => [names.get(name) ?? name, propertySchema]))
41
+ };
42
+ for (const key of ["required", "propertyOrdering"]) {
43
+ const value = schema[key];
44
+ if (isStringArray(value)) projected[key] = value.map((name) => names.get(name) ?? name);
45
+ }
46
+ return projected;
47
+ }
48
+ function mapGoogleToolArguments(tools, toolName, args, direction) {
49
+ const tool = tools?.find((candidate) => candidate.name === toolName);
50
+ if (!tool) return args;
51
+ const names = parameterNames(asRecord(tool.parameters));
52
+ if (names.size === 0) return args;
53
+ const mapping = direction === "encode" ? names : new Map([...names].map(([name, alias]) => [alias, name]));
54
+ return Object.fromEntries(Object.entries(args).map(([name, value]) => [mapping.get(name) ?? name, value]));
55
+ }
56
+ //#endregion
20
57
  //#region packages/ai/src/providers/google-stream.ts
21
58
  const GOOGLE_MODEL_RESOURCE_PREFIX = /^(?:(?:projects\/[^/]+\/locations\/[^/]+\/)?publishers\/google\/models\/|google\/|models\/)/u;
22
59
  function retainThoughtSignature(existing, incoming) {
@@ -186,7 +223,7 @@ async function consumeGoogleGenerateContentStream(params) {
186
223
  type: "toolCall",
187
224
  id: !providedId || toolCallIds.has(providedId) ? params.nextToolCallId(part.functionCall.name) : providedId,
188
225
  name: part.functionCall.name || "",
189
- arguments: part.functionCall.args ?? {},
226
+ arguments: mapGoogleToolArguments(params.tools, part.functionCall.name || "", part.functionCall.args ?? {}, "decode"),
190
227
  ...part.thoughtSignature && { thoughtSignature: part.thoughtSignature }
191
228
  };
192
229
  params.output.content.push(toolCall);
@@ -267,13 +304,6 @@ function sanitizeGeminiThoughtSignature(value) {
267
304
  const trimmed = value.trim();
268
305
  return trimmed && /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(trimmed) ? trimmed : void 0;
269
306
  }
270
- function toolCallThoughtSignatureReplayKey(id, name, args) {
271
- return [
272
- id,
273
- name,
274
- stableStringifyGoogleToolCallValue(args)
275
- ].join("\0");
276
- }
277
307
  function requiresGoogleToolCallId(modelId) {
278
308
  return modelId.startsWith("claude-") || modelId.startsWith("gpt-oss-");
279
309
  }
@@ -337,9 +367,13 @@ function projectGoogleMessages(params) {
337
367
  });
338
368
  } else if (block.type === "toolCall") {
339
369
  if (isSameProviderAndModel && (managed || model.provider !== "google-gemini-cli")) sameRouteToolCallIds.add(block.id);
340
- const args = coerceTransportToolCallArguments(block.arguments);
370
+ const args = mapGoogleToolArguments(params.tools, block.name, coerceTransportToolCallArguments(block.arguments), "encode");
341
371
  const ownSignature = isSameProviderAndModel ? signature(block.thoughtSignature) : void 0;
342
- const replayKey = managed && (ownSignature || params.requiresToolCallSignature && isSameProviderAndModel && replaySignatures.size > 0) ? toolCallThoughtSignatureReplayKey(block.id, block.name, args) : "";
372
+ const replayKey = managed && (ownSignature || params.requiresToolCallSignature && isSameProviderAndModel && replaySignatures.size > 0) ? [
373
+ block.id,
374
+ block.name,
375
+ stableStringifyGoogleToolCallValue(args)
376
+ ].join("\0") : "";
343
377
  if (managed && ownSignature) nextReplaySignatures.set(replayKey, ownSignature);
344
378
  const thoughtSignature = ownSignature ?? (managed && params.requiresToolCallSignature && isSameProviderAndModel ? replaySignatures.get(replayKey) : void 0) ?? (params.requiresToolCallSignature && (managed || !sawFunctionCall) ? GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP : void 0);
345
379
  sawFunctionCall = true;
@@ -408,8 +442,8 @@ function convertGoogleTools(tools) {
408
442
  return [{ functionDeclarations: sortPromptCacheToolsByName(tools).map((tool) => ({
409
443
  name: tool.name,
410
444
  description: tool.description,
411
- parametersJsonSchema: tool.parameters
445
+ parametersJsonSchema: googleToolParameters(tool.parameters)
412
446
  })) }];
413
447
  }
414
448
  //#endregion
415
- export { googleFlashSupportsMinimalThinking as a, consumeGoogleGenerateContentStream as i, projectGoogleMessages as n, requiresGoogleToolCallId as r, convertGoogleTools as t };
449
+ export { googleToolParameters as a, consumeGoogleGenerateContentStream as i, projectGoogleMessages as n, mapGoogleToolArguments as o, requiresGoogleToolCallId as r, googleFlashSupportsMinimalThinking as s, convertGoogleTools as t };
@@ -1,11 +1,13 @@
1
+ import "./src-CQ7nH2mL.mjs";
2
+ import { t as omitNullRequestHeaders } from "./request-headers-DO4Mqhw1.mjs";
1
3
  import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
2
- import { a as asRecord } from "./record-coerce-CNDovvft.mjs";
3
- import { a as resolveAiTransportHeaderSentinels } from "./host-CWt55nnF.mjs";
4
- import { n as buildManagedModelFetch } from "./host-policy-Dm7PM6AD.mjs";
5
- import { n as buildBaseOptions } from "./simple-options-xJkqrG_E.mjs";
6
- import { f as mergeTransportHeaders } from "./transport-stream-shared-lhgkTOz3.mjs";
7
- import { t as createAssistantOutput } from "./assistant-output-BnQm3fov.mjs";
8
- import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-vtag8bj5.mjs";
4
+ import { a as asRecord } from "./record-coerce-BQaoiN3r.mjs";
5
+ import { a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-DX7ORpeH.mjs";
6
+ import { n as buildManagedModelFetch } from "./host-policy-jCZebuXx.mjs";
7
+ import { n as buildBaseOptions } from "./simple-options-tLSeECry.mjs";
8
+ import { p as mergeTransportHeaders } from "./transport-stream-shared-D2uFMhMc.mjs";
9
+ import { t as createAssistantOutput } from "./assistant-output-CD4kY9gu.mjs";
10
+ import { a as runGoogleGenerateContentLifecycle, i as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-WNM86ZcW.mjs";
9
11
  import { ResourceScope } from "@google/genai";
10
12
  //#region packages/ai/src/providers/google-http-options.ts
11
13
  function buildGoogleHttpOptions(model, optionsHeaders, profile) {
@@ -24,10 +26,15 @@ function buildGoogleHttpOptions(model, optionsHeaders, profile) {
24
26
  httpOptions.baseUrl = model.baseUrl;
25
27
  httpOptions.apiVersion = "";
26
28
  } else httpOptions.apiVersion = "v1beta";
27
- if (model.headers || optionsHeaders) httpOptions.headers = resolveAiTransportHeaderSentinels(profile === "vertex" ? {
28
- ...model.headers,
29
- ...optionsHeaders
30
- } : mergeTransportHeaders(model.headers, optionsHeaders));
29
+ const headers = profile === "vertex" ? mergeTransportHeaders(model.headers, optionsHeaders) : getAiTransportHost().resolveProviderRequestHeaders({
30
+ provider: model.provider,
31
+ api: model.api,
32
+ baseUrl: model.baseUrl,
33
+ callerHeaders: mergeTransportHeaders(model.headers, optionsHeaders),
34
+ precedence: "caller-wins",
35
+ model
36
+ });
37
+ if (headers) httpOptions.headers = omitNullRequestHeaders(resolveAiTransportHeaderSentinels(headers));
31
38
  return Object.keys(httpOptions).length > 0 ? httpOptions : void 0;
32
39
  }
33
40
  //#endregion
@@ -39,6 +46,7 @@ function createGoogleGenerateContentStreams(api, createClient, resolveSimpleApiK
39
46
  runGoogleGenerateContentLifecycle({
40
47
  stream: events,
41
48
  model,
49
+ tools: context.tools,
42
50
  output: createAssistantOutput(model, api),
43
51
  options,
44
52
  createClient: () => createClient(model, options),
@@ -1,23 +1,12 @@
1
- import { k as clampThinkingLevel } from "./host-CWt55nnF.mjs";
1
+ import { k as clampThinkingLevel } from "./host-DX7ORpeH.mjs";
2
2
  import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
3
- import { w as stripSystemPromptCacheBoundary } from "./simple-options-xJkqrG_E.mjs";
4
- import { b as transportAbortError, c as failTransportStream, h as notifyProviderStreamOpened } from "./transport-stream-shared-lhgkTOz3.mjs";
5
- import { n as transformProviderMessages } from "./assistant-output-BnQm3fov.mjs";
3
+ import { C as stripSystemPromptCacheBoundary, t as adjustMaxTokensForThinking } from "./simple-options-tLSeECry.mjs";
4
+ import { c as failTransportStream, g as notifyProviderStreamOpened, x as transportAbortError } from "./transport-stream-shared-D2uFMhMc.mjs";
5
+ import { t as transformProviderMessages } from "./provider-transcript-transform-DtaxNcC1.mjs";
6
6
  import { isGoogleGemini3ProModel, isGoogleGemini3ThinkingLevelModel } from "./internal/google-model-family.mjs";
7
- import { a as googleFlashSupportsMinimalThinking, i as consumeGoogleGenerateContentStream, n as projectGoogleMessages, r as requiresGoogleToolCallId, t as convertGoogleTools } from "./google-messages-DQMgG5yG.mjs";
7
+ import { i as consumeGoogleGenerateContentStream, n as projectGoogleMessages, r as requiresGoogleToolCallId, s as googleFlashSupportsMinimalThinking, t as convertGoogleTools } from "./google-messages-A-9d3y5V.mjs";
8
8
  import { FunctionCallingConfigMode, ThinkingLevel } from "@google/genai";
9
9
  //#region packages/ai/src/providers/google-shared.ts
10
- function convertMessages(model, context) {
11
- return projectGoogleMessages({
12
- model,
13
- messages: transformProviderMessages(context.messages, model, (id) => requiresGoogleToolCallId(model.id) ? id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64) : id),
14
- replay: "signed-parts",
15
- requiresToolCallSignature: model.provider !== "google-gemini-cli" && isGoogleGemini3ThinkingLevelModel(model.id)
16
- });
17
- }
18
- function mapToolChoice(choice) {
19
- return choice === "none" ? FunctionCallingConfigMode.NONE : choice === "any" ? FunctionCallingConfigMode.ANY : FunctionCallingConfigMode.AUTO;
20
- }
21
10
  async function runGoogleGenerateContentLifecycle(params) {
22
11
  const { stream, model, output, options } = params;
23
12
  try {
@@ -36,6 +25,7 @@ async function runGoogleGenerateContentLifecycle(params) {
36
25
  chunks: { [Symbol.asyncIterator]: () => googleIterator },
37
26
  model,
38
27
  output,
28
+ tools: params.tools,
39
29
  stream,
40
30
  signal: options?.signal,
41
31
  nextToolCallId: params.nextToolCallId
@@ -51,26 +41,25 @@ async function runGoogleGenerateContentLifecycle(params) {
51
41
  }
52
42
  }
53
43
  function buildGoogleGenerateContentParams(model, context, options = {}) {
54
- const contents = convertMessages(model, context);
44
+ const contents = projectGoogleMessages({
45
+ model,
46
+ messages: transformProviderMessages(context.messages, model, (id) => requiresGoogleToolCallId(model.id) ? id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64) : id),
47
+ tools: context.tools,
48
+ replay: "signed-parts",
49
+ requiresToolCallSignature: model.provider !== "google-gemini-cli" && isGoogleGemini3ThinkingLevelModel(model.id)
50
+ });
55
51
  const config = {
56
52
  ...options.temperature !== void 0 && { temperature: options.temperature },
57
53
  ...options.topP !== void 0 && { topP: options.topP },
58
- ...options.maxTokens !== void 0 && { maxOutputTokens: options.maxTokens },
54
+ ...buildGoogleGenerationConfig(model, options.thinking, options.maxTokens),
59
55
  ...options.stop !== void 0 && options.stop.length > 0 && { stopSequences: options.stop },
60
56
  ...context.systemPrompt && { systemInstruction: sanitizeSurrogates(stripSystemPromptCacheBoundary(context.systemPrompt)) },
61
57
  ...context.tools && context.tools.length > 0 && { tools: convertGoogleTools(context.tools) }
62
58
  };
63
- if (context.tools && context.tools.length > 0 && options.toolChoice) config.toolConfig = { functionCallingConfig: { mode: mapToolChoice(options.toolChoice) } };
64
- else config.toolConfig = void 0;
65
- if (options.thinking?.enabled && model.reasoning) {
66
- const thinkingConfig = { includeThoughts: true };
67
- if (options.thinking.level !== void 0) thinkingConfig.thinkingLevel = ThinkingLevel[options.thinking.level];
68
- else if (options.thinking.budgetTokens !== void 0) thinkingConfig.thinkingBudget = options.thinking.budgetTokens;
69
- config.thinkingConfig = thinkingConfig;
70
- } else if (model.reasoning && options.thinking && !options.thinking.enabled) {
71
- const disabledThinkingConfig = getDisabledGoogleThinkingConfig(model);
72
- if (Object.keys(disabledThinkingConfig).length > 0) config.thinkingConfig = disabledThinkingConfig;
73
- }
59
+ if (context.tools && context.tools.length > 0 && options.toolChoice) {
60
+ const choice = options.toolChoice;
61
+ config.toolConfig = { functionCallingConfig: { mode: choice === "none" ? FunctionCallingConfigMode.NONE : choice === "any" ? FunctionCallingConfigMode.ANY : FunctionCallingConfigMode.AUTO } };
62
+ } else config.toolConfig = void 0;
74
63
  if (options.signal) {
75
64
  if (options.signal.aborted) throw new Error("Request aborted");
76
65
  config.abortSignal = options.signal;
@@ -81,6 +70,46 @@ function buildGoogleGenerateContentParams(model, context, options = {}) {
81
70
  config
82
71
  };
83
72
  }
73
+ /** Shared wire policy for the Gemini API and Vertex, with or without the Google SDK. */
74
+ function buildGoogleGenerationConfig(model, thinking, maxTokens) {
75
+ let thinkingConfig;
76
+ if (model.reasoning && thinking) {
77
+ if (thinking.enabled) {
78
+ thinkingConfig = { includeThoughts: true };
79
+ if (thinking.level !== void 0) {
80
+ const level = {
81
+ MINIMAL: "minimal",
82
+ LOW: "low",
83
+ MEDIUM: "medium",
84
+ HIGH: "high",
85
+ THINKING_LEVEL_UNSPECIFIED: void 0
86
+ }[thinking.level];
87
+ thinkingConfig.thinkingLevel = level ? getGoogleThinkingLevel(level, model) : ThinkingLevel.THINKING_LEVEL_UNSPECIFIED;
88
+ } else if (thinking.budgetTokens !== void 0) {
89
+ if (isGoogleGemini3ThinkingLevelModel(model.id) && thinking.budgetTokens >= 0) {
90
+ const budget = thinking.budgetTokens;
91
+ thinkingConfig.thinkingLevel = getGoogleThinkingLevel(budget === 0 ? "minimal" : budget <= 2048 ? "low" : budget <= 8192 ? "medium" : "high", model);
92
+ } else thinkingConfig.thinkingBudget = thinking.budgetTokens;
93
+ }
94
+ } else thinkingConfig = getDisabledGoogleThinkingConfig(model);
95
+ if (model.id.toLowerCase().includes("gemini-2.5-pro") && thinkingConfig.thinkingBudget === 0) delete thinkingConfig.thinkingBudget;
96
+ }
97
+ let maxOutputTokens = maxTokens;
98
+ if (maxTokens !== void 0 && model.reasoning) {
99
+ if (model.id.toLowerCase().includes("gemini-2.5-pro") && thinking?.enabled === false) thinkingConfig = { thinkingBudget: 128 };
100
+ else if (model.id.toLowerCase().includes("gemini-2.5-pro") && thinking?.budgetTokens === 0 && thinkingConfig) thinkingConfig.thinkingBudget = 128;
101
+ const budget = thinkingConfig?.thinkingBudget;
102
+ if (thinkingConfig && budget !== void 0 && budget >= 0) {
103
+ const adjusted = adjustMaxTokensForThinking(maxTokens, model.maxTokens, "low", { low: budget });
104
+ maxOutputTokens = adjusted.maxTokens;
105
+ thinkingConfig.thinkingBudget = adjusted.thinkingBudget;
106
+ }
107
+ }
108
+ return {
109
+ ...maxOutputTokens !== void 0 && { maxOutputTokens },
110
+ ...thinkingConfig && Object.keys(thinkingConfig).length > 0 && { thinkingConfig }
111
+ };
112
+ }
84
113
  function isAdaptiveGoogleReasoningLevel(value) {
85
114
  return value === "adaptive";
86
115
  }
@@ -111,9 +140,21 @@ function buildGoogleThinking(model, options, interactions) {
111
140
  enabled: true,
112
141
  level: getGoogleThinkingLevel(effort, model)
113
142
  };
143
+ const customBudgets = options.thinkingBudgets;
144
+ let budgetTokens;
145
+ if (customBudgets?.[effort] !== void 0) budgetTokens = customBudgets[effort];
146
+ else {
147
+ const isPro = model.id.includes("2.5-pro");
148
+ if (isPro || model.id.includes("2.5-flash")) budgetTokens = {
149
+ minimal: !isPro && model.id.includes("2.5-flash-lite") ? 512 : 128,
150
+ low: 2048,
151
+ medium: 8192,
152
+ high: isPro ? 32768 : 24576
153
+ }[effort];
154
+ }
114
155
  return {
115
156
  enabled: true,
116
- budgetTokens: getGoogleBudget(model, effort, options.thinkingBudgets)
157
+ budgetTokens
117
158
  };
118
159
  }
119
160
  function buildGoogleSimpleThinking(model, options) {
@@ -144,16 +185,5 @@ function getGoogleThinkingLevel(effort, model) {
144
185
  }
145
186
  return ThinkingLevel.HIGH;
146
187
  }
147
- function getGoogleBudget(model, effort, customBudgets) {
148
- if (customBudgets?.[effort] !== void 0) return customBudgets[effort];
149
- const isPro = model.id.includes("2.5-pro");
150
- if (isPro || model.id.includes("2.5-flash")) return {
151
- minimal: !isPro && model.id.includes("2.5-flash-lite") ? 512 : 128,
152
- low: 2048,
153
- medium: 8192,
154
- high: isPro ? 32768 : 24576
155
- }[effort];
156
- return -1;
157
- }
158
188
  //#endregion
159
- export { runGoogleGenerateContentLifecycle as i, buildGoogleInteractionsSimpleThinking as n, buildGoogleSimpleThinking as r, buildGoogleGenerateContentParams as t };
189
+ export { runGoogleGenerateContentLifecycle as a, buildGoogleSimpleThinking as i, buildGoogleGenerationConfig as n, buildGoogleInteractionsSimpleThinking as r, buildGoogleGenerateContentParams as t };
@@ -1,6 +1,6 @@
1
- import { o as normalizeOptionalString } from "./string-coerce-Cj8sqWHx.mjs";
2
- import { r as getAiTransportHost } from "./host-CWt55nnF.mjs";
3
- import { n as buildGoogleHttpOptions, t as createGoogleGenerateContentStreams } from "./google-provider-stream-BHd0cST9.mjs";
1
+ import { o as normalizeOptionalString } from "./string-coerce-BCuWMIrk.mjs";
2
+ import { r as getAiTransportHost } from "./host-DX7ORpeH.mjs";
3
+ import { n as buildGoogleHttpOptions, t as createGoogleGenerateContentStreams } from "./google-provider-stream-CNVh4gpm.mjs";
4
4
  import { GoogleGenAI } from "@google/genai";
5
5
  //#region packages/ai/src/providers/google-vertex.ts
6
6
  const API_VERSION = "v1";
@@ -1,4 +1,4 @@
1
- import { i as asOptionalRecord } from "./record-coerce-CNDovvft.mjs";
1
+ import { i as asOptionalRecord } from "./record-coerce-BQaoiN3r.mjs";
2
2
  //#region packages/ai/src/providers/google-video-slots.ts
3
3
  const GOOGLE_VIDEO_SLOT_OMISSION = "(video omitted: native video slot unavailable)";
4
4
  function createGoogleVideoPlaceholder(video, slots, placeholder) {
@@ -1,8 +1,8 @@
1
- import { D as supportsClaudeNativeMaxEffort, O as supportsClaudeNativeXhighEffort, S as resolveClaudeSonnet5ModelIdentity, _ as resolveClaudeMythos5ModelIdentity, a as CLAUDE_HAIKU_55_THINKING_PROFILE, b as resolveClaudeOpus5ModelIdentity, c as CLAUDE_SONNET_55_THINKING_PROFILE, f as requiresClaudeDefaultSampling, h as resolveClaudeHaiku55ModelIdentity, i as CLAUDE_FABLE_5_THINKING_PROFILE, m as resolveClaudeFable5ModelIdentity, o as CLAUDE_OPUS_55_THINKING_PROFILE, p as requiresClaudeMandatoryAdaptiveThinking, t as calculateUsageCost, v as resolveClaudeNativeThinkingLevelMap, x as resolveClaudeSonnet55ModelIdentity, y as resolveClaudeOpus55ModelIdentity } from "./src-CyA0zJnt.mjs";
2
- import { t as DEFAULT_MISSING_TOOL_RESULT_TEXT } from "./types-BXd0kI8-.mjs";
3
- import { i as asOptionalRecord, o as isRecord } from "./record-coerce-CNDovvft.mjs";
4
- import { r as normalizeLowercaseStringOrEmpty } from "./string-coerce-Cj8sqWHx.mjs";
5
- import { E as resolveOpenAIModelReasoningEfforts, F as listMappedModelThinkingLevels, L as resolveOpenAIThinkingApi, P as MODEL_CATALOG_THINKING_LEVELS, i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-B5mGAbR6.mjs";
1
+ import { D as supportsClaudeNativeMaxEffort, O as supportsClaudeNativeXhighEffort, S as resolveClaudeSonnet5ModelIdentity, _ as resolveClaudeMythos5ModelIdentity, a as CLAUDE_HAIKU_55_THINKING_PROFILE, b as resolveClaudeOpus5ModelIdentity, c as CLAUDE_SONNET_55_THINKING_PROFILE, f as requiresClaudeDefaultSampling, h as resolveClaudeHaiku55ModelIdentity, i as CLAUDE_FABLE_5_THINKING_PROFILE, m as resolveClaudeFable5ModelIdentity, o as CLAUDE_OPUS_55_THINKING_PROFILE, p as requiresClaudeMandatoryAdaptiveThinking, t as calculateUsageCost, v as resolveClaudeNativeThinkingLevelMap, x as resolveClaudeSonnet55ModelIdentity, y as resolveClaudeOpus55ModelIdentity } from "./src-CQ7nH2mL.mjs";
2
+ import { t as DEFAULT_MISSING_TOOL_RESULT_TEXT } from "./types-OVEWUaDh.mjs";
3
+ import { i as asOptionalRecord, o as isRecord } from "./record-coerce-BQaoiN3r.mjs";
4
+ import { r as normalizeLowercaseStringOrEmpty } from "./string-coerce-BCuWMIrk.mjs";
5
+ import { F as MODEL_CATALOG_THINKING_LEVELS, I as listMappedModelThinkingLevels, O as resolveOpenAIModelReasoningEfforts, R as resolveOpenAIThinkingApi, i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-xU-n9AJJ.mjs";
6
6
  //#region packages/ai/src/media-payload.ts
7
7
  /** Media metadata alone is not an attachment; provider emitters need inline bytes. */
8
8
  function hasMediaPayload(block) {
@@ -78,7 +78,8 @@ function buildAnthropicClaudeCodeIdentity(betaHeader, ...headerSources) {
78
78
  ...betaHeader ? { "anthropic-beta": betaHeader } : {},
79
79
  "x-app": "cli"
80
80
  });
81
- for (const source of headerSources) for (const [name, value] of Object.entries(source ?? {})) headers.set(name, value);
81
+ for (const source of headerSources) for (const [name, value] of Object.entries(source ?? {})) if (value === null) headers.delete(name);
82
+ else headers.set(name, value);
82
83
  let version = ANTHROPIC_CLAUDE_CODE_VERSION;
83
84
  const candidate = headers.get("user-agent")?.match(/^claude-cli\/(\d+\.\d+\.\d+)$/)?.[1];
84
85
  if (candidate) {
@@ -221,16 +222,24 @@ function isClaudeReplaySource(ref) {
221
222
  const modelId = hasConcreteResponseModel(ref) ? ref.responseModelId : ref.modelId;
222
223
  return /(?:^|[-/])claude-/.test(normalizeModelId(modelId));
223
224
  }
224
- function resolveModelBoundThinkingReplayMode(params) {
225
- const sourceApi = normalizeApi(params.source.api);
226
- const targetApi = normalizeApi(params.target.api);
227
- const sourceIdentity = resolveReplayModelBoundIdentity(params.source);
228
- const targetIdentity = resolveReplayModelBoundIdentity(params.target);
229
- const sameRoute = normalizeLowercaseStringOrEmpty(params.source.provider) === normalizeLowercaseStringOrEmpty(params.target.provider) && sourceApi === targetApi && normalizeModelId(params.source.modelId) === normalizeModelId(params.target.modelId);
230
- if (!sourceIdentity && !targetIdentity) return "default";
231
- if (sourceApi === targetApi && readsPriorClaudeThinking(targetIdentity, sourceIdentity) && isClaudeReplaySource(params.source)) return "preserve";
232
- if (!sourceIdentity && !hasConcreteResponseModel(params.source) && targetIdentity && sameRoute) return "preserve";
233
- return sourceApi === targetApi && sourceIdentity === targetIdentity ? "preserve" : "drop";
225
+ /** The destination is fixed during one synchronous history transform. */
226
+ function prepareModelBoundThinkingReplay(target) {
227
+ const targetApi = normalizeApi(target.api);
228
+ const targetIdentity = resolveReplayModelBoundIdentity({
229
+ api: target.api,
230
+ modelId: target.id,
231
+ modelParams: target.params
232
+ });
233
+ const targetProvider = normalizeLowercaseStringOrEmpty(target.provider);
234
+ const targetModelId = normalizeModelId(target.id);
235
+ return (source) => {
236
+ const sourceApi = normalizeApi(source.api);
237
+ const sourceIdentity = resolveReplayModelBoundIdentity(source);
238
+ if (!sourceIdentity && !targetIdentity) return "default";
239
+ if (sourceApi === targetApi && readsPriorClaudeThinking(targetIdentity, sourceIdentity) && isClaudeReplaySource(source)) return "preserve";
240
+ if (!sourceIdentity && !hasConcreteResponseModel(source) && targetIdentity && normalizeLowercaseStringOrEmpty(source.provider) === targetProvider && sourceApi === targetApi && normalizeModelId(source.modelId) === targetModelId) return "preserve";
241
+ return sourceApi === targetApi && sourceIdentity === targetIdentity ? "preserve" : "drop";
242
+ };
234
243
  }
235
244
  //#endregion
236
245
  //#region packages/ai/src/replay-turn-classification.ts
@@ -268,6 +277,7 @@ const FAILED_ASSISTANT_REPLAY_TEXT = "[This turn failed before it completed. Do
268
277
  /** Classify failed source content before model-specific thinking or tool projection. */
269
278
  function resolveFailedAssistantReplay(message, options) {
270
279
  if (message.role !== "assistant" || message.stopReason !== "error" && message.stopReason !== "aborted") return "keep";
280
+ if (message.errorCode === "openclaw_repetitive_output") return "keep";
271
281
  const content = Array.isArray(message.content) ? message.content : [];
272
282
  if (content.some((block) => asOptionalRecord(block)?.type === "toolCall")) return options.pairingAware ? "keep" : "drop";
273
283
  return content.some((block) => {
@@ -293,22 +303,14 @@ function replaceImagesWithPlaceholder(content, placeholder) {
293
303
  text: placeholder
294
304
  });
295
305
  }
296
- return result;
297
- }
298
- function transformAssistant(message, model, toolCallIdMap, normalizeToolCallId) {
299
- const replayMode = resolveModelBoundThinkingReplayMode({
300
- source: {
301
- provider: message.provider,
302
- api: message.api,
303
- modelId: message.model,
304
- responseModelId: message.responseModel
305
- },
306
- target: {
307
- provider: model.provider,
308
- api: model.api,
309
- modelId: model.id,
310
- modelParams: model.params
311
- }
306
+ return Object.isFrozen(content) && result.length === content.length && result.every((block, index) => block === content[index]) ? content : result;
307
+ }
308
+ function transformAssistant(message, model, toolCallIdMap, thinkingReplay, normalizeToolCallId) {
309
+ const replayMode = thinkingReplay({
310
+ provider: message.provider,
311
+ api: message.api,
312
+ modelId: message.model,
313
+ responseModelId: message.responseModel
312
314
  });
313
315
  const sameModel = replayMode === "preserve" || message.provider === model.provider && message.api === model.api && message.model === model.id;
314
316
  const content = (typeof message.content === "string" ? [{
@@ -336,13 +338,14 @@ function transformAssistant(message, model, toolCallIdMap, normalizeToolCallId)
336
338
  if (id !== trimmedId) toolCallIdMap.set(trimmedId, id);
337
339
  return id === block.id ? unsigned : Object.assign({}, unsigned, { id });
338
340
  });
339
- return {
341
+ return Array.isArray(message.content) && Object.isFrozen(message) && Object.isFrozen(message.content) && content.length === message.content.length && content.every((block, index) => block === message.content[index]) ? message : {
340
342
  ...message,
341
343
  content
342
344
  };
343
345
  }
344
346
  function transformMessages(messages, model, normalizeToolCallId) {
345
347
  const toolCallIdMap = /* @__PURE__ */ new Map();
348
+ const thinkingReplay = prepareModelBoundThinkingReplay(model);
346
349
  const asyncOwners = /* @__PURE__ */ new Map();
347
350
  const relocated = /* @__PURE__ */ new Map();
348
351
  const movedResults = /* @__PURE__ */ new Set();
@@ -394,7 +397,7 @@ function transformMessages(messages, model, normalizeToolCallId) {
394
397
  };
395
398
  if (message.role === "assistant") {
396
399
  const failedReplay = resolveFailedAssistantReplay(message, { pairingAware: false });
397
- message = transformAssistant(message, model, toolCallIdMap, normalizeToolCallId);
400
+ message = transformAssistant(message, model, toolCallIdMap, thinkingReplay, normalizeToolCallId);
398
401
  flushToolCalls();
399
402
  if (failedReplay === "drop") continue;
400
403
  if (failedReplay === "marker") {
@@ -420,10 +423,13 @@ function transformMessages(messages, model, normalizeToolCallId) {
420
423
  return [pending];
421
424
  });
422
425
  } else {
423
- if (!supportsImages && typeof message.content !== "string") message = {
424
- ...message,
425
- content: replaceImagesWithPlaceholder(message.content, message.role === "user" ? NON_VISION_USER_IMAGE_PLACEHOLDER : NON_VISION_TOOL_IMAGE_PLACEHOLDER)
426
- };
426
+ if (!supportsImages && typeof message.content !== "string") {
427
+ const content = replaceImagesWithPlaceholder(message.content, message.role === "user" ? NON_VISION_USER_IMAGE_PLACEHOLDER : NON_VISION_TOOL_IMAGE_PLACEHOLDER);
428
+ if (!Object.isFrozen(message) || content !== message.content) message = {
429
+ ...message,
430
+ content
431
+ };
432
+ }
427
433
  if (message.role === "toolResult") {
428
434
  const trimmedId = message.toolCallId.trim();
429
435
  const toolCallId = toolCallIdMap.get(trimmedId) ?? trimmedId;
@@ -492,6 +498,7 @@ const inertAiTransportHost = {
492
498
  inheritManagedTransport: (_source, target) => target,
493
499
  transformTransportMessages: (messages, model, normalizeToolCallId) => transformMessages(messages, model, normalizeToolCallId),
494
500
  registerCustomApi: queueCustomApiRegistration,
501
+ isLogEnabled: () => true,
495
502
  logDebug: () => {},
496
503
  logInfo: () => {},
497
504
  logWarn: () => {}
@@ -578,4 +585,4 @@ function resolveAiTransportHeaderSentinels(headers) {
578
585
  return resolvedHeaders ?? headers;
579
586
  }
580
587
  //#endregion
581
- export { getSupportedThinkingLevels as A, resolveModelBoundThinkingReplayMode as C, applyProviderReportedUsageCost as D, headersToRecord as E, hasMediaPayload as M, isImageWithMediaPayload as N, calculateCost as O, resolveAnthropicThinkingEffort as S, usesClaudeStreamingRefusalContract as T, buildAnthropicClaudeCodeIdentity as _, resolveAiTransportHeaderSentinels as a, prepareClaudeNoPrefillRequestContext as b, transformMessages as c, hasOnlyAssistantReasoningContent as d, isReasoningOnlyLengthAssistantTurn as f, applyClaudeRequestContract as g, ANTHROPIC_CLAUDE_CODE_VERSION as h, getDefaultAiTransportHost as i, modelsAreEqual as j, clampThinkingLevel as k, FAILED_ASSISTANT_REPLAY_TEXT as l, resolveFailedAssistantReplay as m, createAiTransportHost as n, runWithAiTransportHost as o, isStreamErrorFallbackContent as p, getAiTransportHost as r, supportsScopedAiTransportHosts as s, configureAiTransportHost as t, STREAM_ERROR_FALLBACK_TEXT as u, defaultsClaudeAdaptiveThinking as v, usesClaudeFable5MessagesContract as w, requiresClaudeAdaptiveThinking as x, mapAnthropicStopReason as y };
588
+ export { getSupportedThinkingLevels as A, resolveAnthropicThinkingEffort as C, applyProviderReportedUsageCost as D, headersToRecord as E, hasMediaPayload as M, isImageWithMediaPayload as N, calculateCost as O, requiresClaudeAdaptiveThinking as S, usesClaudeStreamingRefusalContract as T, buildAnthropicClaudeCodeIdentity as _, resolveAiTransportHeaderSentinels as a, prepareClaudeNoPrefillRequestContext as b, transformMessages as c, hasOnlyAssistantReasoningContent as d, isReasoningOnlyLengthAssistantTurn as f, applyClaudeRequestContract as g, ANTHROPIC_CLAUDE_CODE_VERSION as h, getDefaultAiTransportHost as i, modelsAreEqual as j, clampThinkingLevel as k, FAILED_ASSISTANT_REPLAY_TEXT as l, resolveFailedAssistantReplay as m, createAiTransportHost as n, runWithAiTransportHost as o, isStreamErrorFallbackContent as p, getAiTransportHost as r, supportsScopedAiTransportHosts as s, configureAiTransportHost as t, STREAM_ERROR_FALLBACK_TEXT as u, defaultsClaudeAdaptiveThinking as v, usesClaudeFable5MessagesContract as w, prepareModelBoundThinkingReplay as x, mapAnthropicStopReason as y };
@@ -1,6 +1,6 @@
1
- import "./index-DSprYWaz.mjs";
2
- import { d as Context, et as StreamFn, k as Model, n as Api } from "./types-CVYzKrMl.mjs";
3
- import { n as ApiRegistry } from "./api-registry-gDt0faai.mjs";
1
+ import { M as ModelRequestHeaders, d as Context, k as Model, n as Api, rt as StreamFn } from "./types-BVdTf0YV.mjs";
2
+ import "./index-Bczt0MnO.mjs";
3
+ import { n as ApiRegistry } from "./api-registry-DY2MLUyg.mjs";
4
4
  //#region packages/ai/src/host.d.ts
5
5
  /** Provider capability facts needed by the package-owned transports. */
6
6
  interface AiProviderRequestCapabilities {
@@ -148,21 +148,29 @@ interface AiTransportHost {
148
148
  provider?: string;
149
149
  api?: string;
150
150
  baseUrl?: string;
151
- providerHeaders?: Record<string, string>;
152
- callerHeaders?: Record<string, string>;
151
+ providerHeaders?: ModelRequestHeaders;
152
+ callerHeaders?: ModelRequestHeaders;
153
153
  precedence?: "caller-wins" | "defaults-win";
154
154
  model?: object;
155
- }): Record<string, string> | undefined;
155
+ }): ModelRequestHeaders | undefined;
156
156
  /** Returns the host-configured request timeout attached to a model. */
157
157
  resolveModelRequestTimeoutMs(model: Model): number | undefined;
158
- /** Reports whether the model carries host-managed proxy, TLS, or local-service state. */
159
- requiresManagedTransport(model: Model): boolean;
158
+ /** With scope "fetch", requires guarded fetch dispatch; native WebSockets must also exclude it. */
159
+ requiresManagedTransport(model: Model, scope?: "fetch"): boolean;
160
160
  /** Copies host-owned managed-transport state onto a projected model. */
161
161
  inheritManagedTransport(source: Model, target: Model): Model;
162
+ /** Host-owned deep-immutability proof; absent hosts simply convert each request. */
163
+ immutableData?: {
164
+ isPlainData?(this: void, value: unknown): boolean;
165
+ isDeeplyFrozenPlainData(value: unknown): boolean;
166
+ freezeJsonSnapshot<T>(value: T): T;
167
+ };
162
168
  /** Applies host-owned transcript replay and pairing rules. */
163
169
  transformTransportMessages: AiTransformTransportMessages;
164
170
  /** Registers a custom transport API with the host's stream error bridge. */
165
171
  registerCustomApi(registry: ApiRegistry, api: Api, streamFn: StreamFn): boolean;
172
+ /** Optional for existing embedding hosts; omitted means the host decides at emission. */
173
+ isLogEnabled?(subsystem: string, level: "debug" | "info" | "warn"): boolean;
166
174
  /**
167
175
  * Emits one transport diagnostic; build runs only when the host logs it and
168
176
  * may return null to suppress the entry (e.g. de-duplication).
@@ -192,6 +200,6 @@ declare function configureAiTransportHost(host: Partial<AiTransportHost>): void;
192
200
  /** Returns the active transport host (inert defaults unless configured). */
193
201
  declare function getAiTransportHost(): ActiveAiTransportHost;
194
202
  /** Resolves sentinel substrings in custom headers at a no-fetch adapter boundary. */
195
- declare function resolveAiTransportHeaderSentinels(headers: Record<string, string> | undefined): Record<string, string> | undefined;
203
+ declare function resolveAiTransportHeaderSentinels(headers: ModelRequestHeaders | undefined): ModelRequestHeaders | undefined;
196
204
  //#endregion
197
205
  export { supportsScopedAiTransportHosts as _, AiProviderRequestPolicyInput as a, AiTransportHost as c, configureAiTransportHost as d, createAiTransportHost as f, runWithAiTransportHost as g, resolveAiTransportHeaderSentinels as h, AiProviderRequestCapabilities as i, AiTransportPluginHost as l, getDefaultAiTransportHost as m, AiInlineImageBlock as n, AiProviderStreamHookContext as o, getAiTransportHost as p, AiInlineTextBlock as r, AiTransformTransportMessages as s, AiInlineContentBlock as t, OpenAIStrictToolSettingOptions as u };
@@ -1,4 +1,4 @@
1
- import { r as getAiTransportHost } from "./host-CWt55nnF.mjs";
1
+ import { r as getAiTransportHost } from "./host-DX7ORpeH.mjs";
2
2
  //#region packages/ai/src/transports/host-policy.ts
3
3
  function buildGuardedModelFetch(model, timeoutMs, options) {
4
4
  const host = getAiTransportHost();
@@ -8,7 +8,7 @@ function buildGuardedModelFetch(model, timeoutMs, options) {
8
8
  }
9
9
  /** SDKs keep their default transport unless their embedding owner requires an explicit one. */
10
10
  function buildManagedModelFetch(model, host = getAiTransportHost()) {
11
- if (!host.requiresManagedTransport(model)) return;
11
+ if (!host.requiresManagedTransport(model, "fetch")) return;
12
12
  const fetcher = host.buildModelFetch(model);
13
13
  if (!fetcher) throw new Error("The embedding host requires a managed provider transport");
14
14
  return fetcher;
@@ -0,0 +1,17 @@
1
+ import { A as ModelCostConfig, M as ModelRequestHeaders, Q as RawModelCostConfig, a as AssistantMessage, gt as Usage } from "./types-BVdTf0YV.mjs";
2
+ import "./event-stream-BYmtRe8-.mjs";
3
+ import "./validation-QmyD0E5A.mjs";
4
+ //#region packages/llm-core/src/usage-cost.d.ts
5
+ declare function normalizeModelCostConfig(cost: RawModelCostConfig): ModelCostConfig;
6
+ declare function normalizeResolvedPricing(cost: Partial<RawModelCostConfig>): ModelCostConfig;
7
+ /** Price one model call, selecting its tier before billing the separate token buckets. */
8
+ declare function calculateUsageCost(usage: Partial<Pick<Usage, "input" | "output" | "cacheRead" | "cacheWrite" | "cacheWrite1h">>, pricing: RawModelCostConfig): Usage["cost"];
9
+ //#endregion
10
+ //#region packages/llm-core/src/utils/assistant-message-events.d.ts
11
+ declare function appendTextDeltaToAssistantMessage(message: AssistantMessage, contentIndex: number, delta: string): AssistantMessage;
12
+ //#endregion
13
+ //#region packages/llm-core/src/utils/request-headers.d.ts
14
+ /** Materialize merged overrides for HTTP clients that cannot consume SDK deletion sentinels. */
15
+ declare function omitNullRequestHeaders(headers: ModelRequestHeaders | undefined): Record<string, string> | undefined;
16
+ //#endregion
17
+ export { normalizeResolvedPricing as a, normalizeModelCostConfig as i, appendTextDeltaToAssistantMessage as n, calculateUsageCost as r, omitNullRequestHeaders as t };