@openclaw/ai 2026.10.5-beta.4 → 2026.10.10-beta.1

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 (119) hide show
  1. package/README.md +11 -0
  2. package/dist/{anthropic-BalhAzs-.mjs → anthropic-D6spfBri.mjs} +16 -18
  3. package/dist/{anthropic-payload-policy-DGblkHL5.d.mts → anthropic-payload-policy-Cr8xjazC.d.mts} +6 -3
  4. package/dist/{anthropic-stream-reducer-DkKeXXx4.mjs → anthropic-stream-reducer-CzPXOaLM.mjs} +59 -226
  5. package/dist/anthropic-tool-projection-BdAS3rtJ.mjs +165 -0
  6. package/dist/anthropic-tool-projection-DKH-aEWU.d.mts +51 -0
  7. package/dist/{api-registry-BhXXYdRA.d.mts → api-registry-gDt0faai.d.mts} +2 -2
  8. package/dist/{assistant-output-BuhRpLeD.mjs → assistant-output-6iFA1nbC.mjs} +2 -2
  9. package/dist/{azure-openai-responses-DfT9Ndd8.mjs → azure-openai-responses-0TqHwnlD.mjs} +8 -8
  10. package/dist/{cloudflare-5qSGvIUH.mjs → cloudflare-Dttf8jKq.mjs} +1 -1
  11. package/dist/{credential-redaction-BHxruEH6.d.mts → credential-redaction-XvsPf7Yi.d.mts} +1 -0
  12. package/dist/{diagnostics-tQasYct1.mjs → diagnostics-Cv7cW3pS.mjs} +3 -3
  13. package/dist/diagnostics.d.mts +6 -6
  14. package/dist/diagnostics.mjs +2 -2
  15. package/dist/{env-api-keys-CrxwdylR.mjs → env-api-keys-Xd8dm_aV.mjs} +10 -34
  16. package/dist/event-stream-CDpFza-M.d.mts +1 -0
  17. package/dist/{event-stream-BcqWLo_u.d.mts → event-stream-CzpE1g_o.d.mts} +1 -1
  18. package/dist/event-stream.d.mts +2 -2
  19. package/dist/{github-copilot-request-facts-DEE6gcB9.mjs → github-copilot-request-facts-F-EmvkpW.mjs} +1 -1
  20. package/dist/{google-interactions-9SSqsJg9.mjs → google-interactions-CTEBy9od.mjs} +19 -37
  21. package/dist/{google-messages-DsB7fmoQ.mjs → google-messages-DfpHVTaD.mjs} +18 -6
  22. package/dist/{google-provider-stream-CcEI2-MC.mjs → google-provider-stream-DJ8ANfsS.mjs} +6 -6
  23. package/dist/{google-shared-zGR0QUyS.mjs → google-shared-VTcCJLW3.mjs} +28 -41
  24. package/dist/{google-vertex-Dw_abY1w.mjs → google-vertex-Bkfizj7M.mjs} +3 -3
  25. package/dist/{google-sYI2wnY6.mjs → google-zWpkDSeN.mjs} +4 -4
  26. package/dist/{host-Bf3NjYNj.mjs → host-B2gk-d1H.mjs} +5 -11
  27. package/dist/{host-CTDz7LXD.d.mts → host-jJOffdlW.d.mts} +4 -6
  28. package/dist/{host-policy-BzZluO6_.mjs → host-policy-mpqGhbeM.mjs} +1 -1
  29. package/dist/{index-BYDvopUB.d.mts → index-DSprYWaz.d.mts} +7 -5
  30. package/dist/index.d.mts +7 -7
  31. package/dist/index.mjs +6 -6
  32. package/dist/internal/anthropic.d.mts +7 -53
  33. package/dist/internal/anthropic.mjs +6 -5
  34. package/dist/internal/google-model-family.d.mts +2 -0
  35. package/dist/internal/google-model-family.mjs +7 -3
  36. package/dist/internal/openai-completions-compat.d.mts +1 -1
  37. package/dist/internal/openai-completions-compat.mjs +1 -1
  38. package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
  39. package/dist/internal/openai-responses-payload-policy.mjs +3 -3
  40. package/dist/internal/openai.d.mts +17 -26
  41. package/dist/internal/openai.mjs +10 -10
  42. package/dist/internal/retry-after.d.mts +1 -1
  43. package/dist/internal/retry-after.mjs +80 -55
  44. package/dist/internal/runtime.d.mts +9 -31
  45. package/dist/internal/runtime.mjs +10 -116
  46. package/dist/internal/shared.d.mts +9 -7
  47. package/dist/internal/shared.mjs +8 -6
  48. package/dist/internal/tool-schema.d.mts +83 -5
  49. package/dist/internal/tool-schema.mjs +4 -3
  50. package/dist/{mistral-dCDCR5ur.mjs → mistral-CATJrwne.mjs} +32 -35
  51. package/dist/model-request-body-BD5vy4rP.d.mts +17 -0
  52. package/dist/{number-coercion-C3hztWoY.mjs → number-coercion-37gmNkuA.mjs} +1 -1
  53. package/dist/{openai-chatgpt-responses-BHI3uCcA.mjs → openai-chatgpt-responses-CtdnpWwe.mjs} +95 -63
  54. package/dist/{openai-completions-CrVgnFrV.mjs → openai-completions-B6sET3oI.mjs} +10 -8
  55. package/dist/{openai-completions-compat-i-nLZxFy.d.mts → openai-completions-compat-1gsjP-KO.d.mts} +6 -3
  56. package/dist/{openai-completions-compat-CYX18uDk.mjs → openai-completions-compat-CFhQ3UVU.mjs} +7 -2
  57. package/dist/{openai-completions-transport-Dy4CZo9Q.mjs → openai-completions-transport-DviPEqw3.mjs} +370 -237
  58. package/dist/{openai-prompt-cache-r93BJhjm.mjs → openai-prompt-cache-DJ_P143P.mjs} +1 -1
  59. package/dist/{openai-prompt-cache-DIPMrMFy.d.mts → openai-prompt-cache-DgjD-UL5.d.mts} +2 -2
  60. package/dist/{openai-responses-D5oiAUOG.mjs → openai-responses-BXsJK-mD.mjs} +13 -15
  61. package/dist/{openai-responses-compaction-replay-B2FE4Nw8.d.mts → openai-responses-compaction-replay-Cvnl_nCq.d.mts} +5 -5
  62. package/dist/{openai-responses-contracts-DlKMMTxK.mjs → openai-responses-contracts-Bx-16mnf.mjs} +45 -6
  63. package/dist/{openai-responses-contracts-DKqMJ1Ct.d.mts → openai-responses-contracts-CQ4_AWjL.d.mts} +20 -8
  64. package/dist/{openai-responses-endpoint-CinGh4VZ.mjs → openai-responses-endpoint-D4v-eeYy.mjs} +55 -22
  65. package/dist/{openai-responses-payload-policy-C7GsA1y0.d.mts → openai-responses-payload-policy-BzM52TTH.d.mts} +9 -3
  66. package/dist/openai-responses-request-lifecycle-CTdAb2v1.mjs +246 -0
  67. package/dist/{openai-responses-shared-D-aDYAkJ.mjs → openai-responses-shared-Bv_1NtH9.mjs} +284 -160
  68. package/dist/{openai-responses-terminal-usage-BygjiAdi.d.mts → openai-responses-terminal-usage-CpVjkqn-.d.mts} +2 -2
  69. package/dist/{openai-tool-schema-DDPXsvJP.mjs → openai-tool-schema-Buv0GXFb.mjs} +170 -237
  70. package/dist/overflow-DJHXTNBQ.mjs +117 -0
  71. package/dist/{positive-integer-CqWjqSi9.mjs → positive-integer-Bb4Evc7L.mjs} +1 -1
  72. package/dist/prompt-cache-stability-D_MeCQFI.mjs +32 -0
  73. package/dist/{provider-error-xumb1V3F.d.mts → provider-error-CnaWYTRY.d.mts} +1 -0
  74. package/dist/{provider-error-CF9GWCs2.mjs → provider-error-qtZD2inE.mjs} +75 -13
  75. package/dist/{provider-options-CVrXZBtA.d.mts → provider-options-DeYeaflL.d.mts} +52 -6
  76. package/dist/{text-signature-Drb4Erb8.mjs → provider-replay-context-J6CfU3m1.mjs} +5 -14
  77. package/dist/{provider-transport-turn-state-BOpxgm-J.mjs → provider-transport-turn-state-Jxppzuc2.mjs} +5 -5
  78. package/dist/{provider-types-CHtRx0dI.d.mts → provider-types-ODq57rG_.d.mts} +3 -3
  79. package/dist/provider-types.d.mts +6 -6
  80. package/dist/providers.d.mts +2 -2
  81. package/dist/providers.mjs +11 -11
  82. package/dist/{reasoning-tag-text-partitioner-CpOy9-IQ.mjs → reasoning-tag-text-partitioner-DzlRubwU.mjs} +134 -47
  83. package/dist/{required-api-key-CFJvcFy_.mjs → required-api-key-D088S4Cd.mjs} +1 -1
  84. package/dist/{retry-after-CdCURCVg.d.mts → retry-after-sw-XX8aC.d.mts} +1 -1
  85. package/dist/sanitize-unicode-CRGuMONI.mjs +8 -0
  86. package/dist/sanitize-unicode-ZqVLLEKC.d.mts +27 -0
  87. package/dist/{session-resources-D1wgDQ8C.mjs → session-resources-vKvGIE3J.mjs} +1 -10
  88. package/dist/{simple-options-BAu4B54D.mjs → simple-options-BYgC6kse.mjs} +68 -79
  89. package/dist/{src-C44MKrW5.mjs → src-CyA0zJnt.mjs} +6 -2
  90. package/dist/{stream-Dd8DwRFL.mjs → stream-DLBirT0e.mjs} +8 -47
  91. package/dist/{stream-first-event-timeout-Dc42hKv6.mjs → stream-first-event-timeout-D_TfJHRJ.mjs} +1 -1
  92. package/dist/{string-coerce-CtgOVOSv.mjs → string-coerce-Cj8sqWHx.mjs} +26 -1
  93. package/dist/tool-schema-json-projection-B0hHDV7N.mjs +492 -0
  94. package/dist/{transport-stream-shared-BmpzDtdQ.d.mts → transport-stream-shared-8ru8eX4s.d.mts} +5 -5
  95. package/dist/{transport-stream-shared-CWGOuLcA.mjs → transport-stream-shared-CzQlAzJH.mjs} +27 -75
  96. package/dist/transports.d.mts +34 -28
  97. package/dist/transports.mjs +42 -48
  98. package/dist/{types-CQc6JNG4.mjs → types-BXd0kI8-.mjs} +1 -1
  99. package/dist/types-CBJthzJX.d.mts +1 -0
  100. package/dist/{types-Bd2T86VJ.d.mts → types-CVYzKrMl.d.mts} +20 -3
  101. package/dist/types.d.mts +6 -6
  102. package/dist/types.mjs +4 -4
  103. package/dist/{validation-ZX_sPVV0.mjs → validation-9FSkE8T-.mjs} +22 -3
  104. package/dist/{validation-DdGB1yy3.d.mts → validation-BQ5u20Ru.d.mts} +1 -1
  105. package/dist/validation.d.mts +1 -1
  106. package/dist/validation.mjs +1 -1
  107. package/package.json +3 -3
  108. package/dist/assistant-text-phase-Bn1hbvK9.mjs +0 -50
  109. package/dist/event-stream-6UNs-AhN.d.mts +0 -1
  110. package/dist/expect-lbe3Hgrh.mjs +0 -8
  111. package/dist/json-schema-Bp07Qui3.mjs +0 -22
  112. package/dist/openai-responses-request-lifecycle-NSIJo9jY.mjs +0 -67
  113. package/dist/openai-tool-projection-793cE3QX.d.mts +0 -37
  114. package/dist/openai-tool-schema-a5ysBBga.d.mts +0 -32
  115. package/dist/rolldown-runtime-BhDjJH2R.mjs +0 -15
  116. package/dist/sanitize-unicode-CjDG6jJx.d.mts +0 -5
  117. package/dist/string-normalization-I3ux50s9.mjs +0 -28
  118. package/dist/tool-schema-json-projection-B8sG1I9v.mjs +0 -180
  119. package/dist/types-Kdfw_04V.d.mts +0 -1
@@ -0,0 +1,165 @@
1
+ import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
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-B0hHDV7N.mjs";
4
+ //#region packages/ai/src/providers/anthropic-tool-projection.ts
5
+ const CLAUDE_CODE_TOOL_LOOKUP = new Map([
6
+ "Read",
7
+ "Write",
8
+ "Edit",
9
+ "Bash",
10
+ "Grep",
11
+ "Glob",
12
+ "AskUserQuestion",
13
+ "EnterPlanMode",
14
+ "ExitPlanMode",
15
+ "KillShell",
16
+ "NotebookEdit",
17
+ "Skill",
18
+ "Task",
19
+ "TaskOutput",
20
+ "TodoWrite",
21
+ "WebFetch",
22
+ "WebSearch"
23
+ ].map((name) => [name.toLowerCase(), name]));
24
+ /** Preserve Claude Code's canonical tool casing for subscription OAuth requests. */
25
+ function toClaudeCodeToolName(name) {
26
+ return CLAUDE_CODE_TOOL_LOOKUP.get(name.toLowerCase()) ?? name;
27
+ }
28
+ /** Anthropic rejects forced tools while extended thinking is enabled. */
29
+ function normalizeAnthropicToolChoice(thinkingEnabled, toolChoice) {
30
+ if (thinkingEnabled && (toolChoice === "any" || typeof toolChoice === "object" && toolChoice.type === "tool")) return { type: "auto" };
31
+ return typeof toolChoice === "string" ? { type: toolChoice } : toolChoice;
32
+ }
33
+ /** Anthropic tool identifiers accept only ASCII word characters and dashes. */
34
+ function normalizeAnthropicToolCallId(id) {
35
+ return id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
36
+ }
37
+ function isProviderSupportedViolation(violation) {
38
+ return violation.endsWith(".$dynamicRef") || violation.endsWith(".$dynamicAnchor");
39
+ }
40
+ /** Normalize the detached JSON projection and report tuple changes to enclosing schemas. */
41
+ function normalizeAnthropicJsonSchema(schema) {
42
+ if (!isRecord(schema)) return false;
43
+ let changed = false;
44
+ for (const [key, value] of Object.entries(schema)) {
45
+ if (key !== "additionalItems" && SCHEMA_OBJECT_KEYS.has(key) && !Array.isArray(value)) {
46
+ changed = normalizeAnthropicJsonSchema(value) || changed;
47
+ continue;
48
+ }
49
+ if (key !== "items" && SCHEMA_ARRAY_KEYS.has(key) && Array.isArray(value)) {
50
+ for (const entry of value) changed = normalizeAnthropicJsonSchema(entry) || changed;
51
+ continue;
52
+ }
53
+ if (SCHEMA_MAP_KEYS.has(key) && isRecord(value)) for (const entry of Object.values(value)) changed = normalizeAnthropicJsonSchema(entry) || changed;
54
+ }
55
+ if (Array.isArray(schema.items)) {
56
+ for (const entry of schema.items) normalizeAnthropicJsonSchema(entry);
57
+ schema.prefixItems = schema.items;
58
+ const additionalItems = schema.additionalItems;
59
+ if (typeof additionalItems === "boolean" || isRecord(additionalItems)) {
60
+ normalizeAnthropicJsonSchema(additionalItems);
61
+ schema.items = additionalItems;
62
+ } else delete schema.items;
63
+ delete schema.additionalItems;
64
+ changed = true;
65
+ }
66
+ if (changed) delete schema.$schema;
67
+ return changed;
68
+ }
69
+ const publishedAnthropicSchemas = /* @__PURE__ */ new WeakMap();
70
+ /** Prepare a detached JSON projection for Anthropic's tuple dialect. */
71
+ function prepareAnthropicInputSchema(schema) {
72
+ const published = getPublishedRuntimeToolInputSchema(schema);
73
+ const cached = published ? publishedAnthropicSchemas.get(schema) : void 0;
74
+ if (cached !== void 0) return cached;
75
+ const normalized = published ? JSON.parse(published.json) : schema;
76
+ normalizeAnthropicJsonSchema(normalized);
77
+ const properties = normalized.properties;
78
+ const required = normalized.required;
79
+ if (properties !== void 0 && properties !== null && !isRecord(properties) || required !== void 0 && required !== null && (!Array.isArray(required) || required.some((entry) => typeof entry !== "string"))) {
80
+ if (published) publishedAnthropicSchemas.set(schema, null);
81
+ return null;
82
+ }
83
+ const inputSchema = {
84
+ ...normalized,
85
+ type: "object",
86
+ properties: properties ?? {},
87
+ required: required ?? []
88
+ };
89
+ inheritToolSchemaTruncation(schema, inputSchema);
90
+ if (!published) return inputSchema;
91
+ const result = publishRuntimeToolInputSchema(inputSchema).schema;
92
+ publishedAnthropicSchemas.set(schema, result);
93
+ return result;
94
+ }
95
+ /** Snapshots direct/custom tool descriptors before Anthropic payload construction. */
96
+ function projectAnthropicTools(tools, toWireName) {
97
+ const projectedTools = [];
98
+ const originalNameByWireName = /* @__PURE__ */ new Map();
99
+ const unavailableOriginalNames = /* @__PURE__ */ new Set();
100
+ for (const tool of tools) {
101
+ let projectedTool;
102
+ let originalName;
103
+ try {
104
+ const name = tool.name;
105
+ originalName = name;
106
+ if (!name) continue;
107
+ const schemaProjection = projectRuntimeToolInputSchema(tool.parameters, `${name}.parameters`, name);
108
+ if (!isRecord(schemaProjection.schema) || schemaProjection.violations.some((violation) => !isProviderSupportedViolation(violation))) {
109
+ unavailableOriginalNames.add(name);
110
+ continue;
111
+ }
112
+ const inputSchema = prepareAnthropicInputSchema(schemaProjection.schema);
113
+ if (!inputSchema) {
114
+ unavailableOriginalNames.add(name);
115
+ continue;
116
+ }
117
+ let description;
118
+ try {
119
+ description = typeof tool.description === "string" ? tool.description : void 0;
120
+ } catch {}
121
+ projectedTool = {
122
+ originalName: name,
123
+ wireName: toWireName(name),
124
+ ...description ? { description } : {},
125
+ inputSchema
126
+ };
127
+ } catch {
128
+ if (originalName) unavailableOriginalNames.add(originalName);
129
+ continue;
130
+ }
131
+ const conflictingName = originalNameByWireName.get(projectedTool.wireName);
132
+ if (conflictingName !== void 0 && conflictingName !== projectedTool.originalName) throw new Error(`Anthropic tool names "${conflictingName}" and "${projectedTool.originalName}" both map to "${projectedTool.wireName}"`);
133
+ originalNameByWireName.set(projectedTool.wireName, projectedTool.originalName);
134
+ projectedTools.push(projectedTool);
135
+ }
136
+ return {
137
+ inputToolCount: tools.length,
138
+ unavailableOriginalNames,
139
+ tools: sortPromptCacheToolsByName(projectedTools)
140
+ };
141
+ }
142
+ /** Keeps forced Anthropic tool choices aligned with the projected wire names. */
143
+ function reconcileAnthropicToolChoice(choice, projection) {
144
+ if (projection.inputToolCount === 0) return choice;
145
+ if (choice.type === "tool") {
146
+ const requestedName = choice.name;
147
+ const matchedTool = projection.tools.find((tool) => tool.originalName === requestedName) ?? (projection.unavailableOriginalNames.has(requestedName) ? void 0 : projection.tools.find((tool) => tool.wireName === requestedName));
148
+ if (!matchedTool) throw new Error(`Anthropic tool_choice requested unavailable tool "${requestedName}" after schema conversion`);
149
+ return {
150
+ ...choice,
151
+ name: matchedTool.wireName
152
+ };
153
+ }
154
+ if (projection.tools.length === 0) {
155
+ if (choice.type === "auto") return;
156
+ if (choice.type === "any") throw new Error("Anthropic tool_choice requires a tool, but no tools survived schema conversion");
157
+ }
158
+ return choice;
159
+ }
160
+ /** Maps Claude Code wire names without trusting every direct/custom descriptor. */
161
+ function resolveOriginalAnthropicToolName(name, projection) {
162
+ return projection?.tools.find((tool) => tool.wireName === name)?.originalName ?? name;
163
+ }
164
+ //#endregion
165
+ export { reconcileAnthropicToolChoice as a, projectAnthropicTools as i, normalizeAnthropicToolChoice as n, resolveOriginalAnthropicToolName as o, prepareAnthropicInputSchema as r, toClaudeCodeToolName as s, normalizeAnthropicToolCallId as t };
@@ -0,0 +1,51 @@
1
+ import { r as AnthropicOptions } from "./provider-options-DeYeaflL.mjs";
2
+ import { Tool } from "@anthropic-ai/sdk/resources/messages.js";
3
+ //#region packages/ai/src/providers/anthropic-tool-projection.d.ts
4
+ type AnthropicToolDescriptor = {
5
+ readonly name: string;
6
+ readonly description: string;
7
+ readonly parameters: unknown;
8
+ };
9
+ type AnthropicProjectedTool = {
10
+ readonly originalName: string;
11
+ readonly wireName: string;
12
+ readonly description?: string;
13
+ readonly inputSchema: Tool["input_schema"] & {
14
+ readonly properties: Record<string, unknown>;
15
+ readonly required: string[];
16
+ };
17
+ };
18
+ type AnthropicToolProjection = {
19
+ readonly inputToolCount: number;
20
+ readonly unavailableOriginalNames: ReadonlySet<string>;
21
+ readonly tools: readonly AnthropicProjectedTool[];
22
+ };
23
+ type AnthropicParallelToolChoice = {
24
+ readonly disable_parallel_tool_use?: boolean;
25
+ };
26
+ type AnthropicProjectedToolChoice = ({
27
+ readonly type: "auto";
28
+ } & AnthropicParallelToolChoice) | ({
29
+ readonly type: "any";
30
+ } & AnthropicParallelToolChoice) | {
31
+ readonly type: "none";
32
+ } | ({
33
+ readonly type: "tool";
34
+ readonly name: string;
35
+ } & AnthropicParallelToolChoice);
36
+ /** Preserve Claude Code's canonical tool casing for subscription OAuth requests. */
37
+ declare function toClaudeCodeToolName(name: string): string;
38
+ /** Anthropic rejects forced tools while extended thinking is enabled. */
39
+ declare function normalizeAnthropicToolChoice(thinkingEnabled: boolean, toolChoice: NonNullable<AnthropicOptions["toolChoice"]>): AnthropicProjectedToolChoice;
40
+ /** Anthropic tool identifiers accept only ASCII word characters and dashes. */
41
+ declare function normalizeAnthropicToolCallId(id: string): string;
42
+ /** Prepare a detached JSON projection for Anthropic's tuple dialect. */
43
+ declare function prepareAnthropicInputSchema(schema: Record<string, unknown>): AnthropicProjectedTool["inputSchema"] | null;
44
+ /** Snapshots direct/custom tool descriptors before Anthropic payload construction. */
45
+ declare function projectAnthropicTools(tools: readonly AnthropicToolDescriptor[], toWireName: (name: string) => string): AnthropicToolProjection;
46
+ /** Keeps forced Anthropic tool choices aligned with the projected wire names. */
47
+ declare function reconcileAnthropicToolChoice(choice: AnthropicProjectedToolChoice, projection: AnthropicToolProjection): AnthropicProjectedToolChoice | undefined;
48
+ /** Maps Claude Code wire names without trusting every direct/custom descriptor. */
49
+ declare function resolveOriginalAnthropicToolName(name: string, projection: AnthropicToolProjection | undefined): string;
50
+ //#endregion
51
+ export { prepareAnthropicInputSchema as a, resolveOriginalAnthropicToolName as c, normalizeAnthropicToolChoice as i, toClaudeCodeToolName as l, AnthropicToolProjection as n, projectAnthropicTools as o, normalizeAnthropicToolCallId as r, reconcileAnthropicToolChoice as s, AnthropicProjectedToolChoice as t };
@@ -1,5 +1,5 @@
1
- import "./index-BYDvopUB.mjs";
2
- import { Q as SimpleStreamOptions, n as Api, nt as StreamOptions, tt as StreamFunction } from "./types-Bd2T86VJ.mjs";
1
+ import "./index-DSprYWaz.mjs";
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. */
5
5
  type ApiStreamFunction = StreamFunction;
@@ -1,5 +1,5 @@
1
- import { c as transformMessages } from "./host-Bf3NjYNj.mjs";
2
- import { a as createEmptyTransportUsage } from "./transport-stream-shared-CWGOuLcA.mjs";
1
+ import { c as transformMessages } from "./host-B2gk-d1H.mjs";
2
+ import { a as createEmptyTransportUsage } from "./transport-stream-shared-CzQlAzJH.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)";
@@ -1,11 +1,11 @@
1
1
  import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
2
- import { r as getAiTransportHost } from "./host-Bf3NjYNj.mjs";
3
- import { n as buildBaseOptions } from "./simple-options-BAu4B54D.mjs";
4
- import { F as convertProviderResponsesMessages, Ft as resolvePromptCacheKey, _t as resolveOpenAISimpleReasoningEffort, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams } from "./openai-responses-shared-D-aDYAkJ.mjs";
5
- import { n as getEnvApiKey } from "./env-api-keys-CrxwdylR.mjs";
6
- import { t as createAssistantOutput } from "./assistant-output-BuhRpLeD.mjs";
2
+ import { r as getAiTransportHost } from "./host-B2gk-d1H.mjs";
3
+ import { n as buildBaseOptions } from "./simple-options-BYgC6kse.mjs";
4
+ import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
5
+ import { t as createAssistantOutput } from "./assistant-output-6iFA1nbC.mjs";
6
+ import { F as convertProviderResponsesMessages, It as resolvePromptCacheKey, Lt as withOpenAIErrorResponseHook, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams, vt as resolveOpenAISimpleReasoningEffort } from "./openai-responses-shared-Bv_1NtH9.mjs";
7
7
  import { i as resolveAzureDeploymentNameFromMap, n as isTraditionalAzureOpenAIHost, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-D0dvJMbZ.mjs";
8
- import { t as requireApiKey } from "./required-api-key-CFJvcFy_.mjs";
8
+ import { t as requireApiKey } from "./required-api-key-D088S4Cd.mjs";
9
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";
@@ -86,10 +86,10 @@ function createClient(model, apiKeyInput, options) {
86
86
  dangerouslyAllowBrowser: true,
87
87
  defaultHeaders: headers,
88
88
  baseURL: baseUrl,
89
- fetch: getAiTransportHost().buildModelFetch({
89
+ fetch: withOpenAIErrorResponseHook(getAiTransportHost().buildModelFetch({
90
90
  ...model,
91
91
  baseUrl
92
- }),
92
+ }) ?? globalThis.fetch, options?.onResponse, model),
93
93
  maxRetries: 0
94
94
  };
95
95
  return isOpenAICompatibleAzureResponsesBaseUrl(baseUrl) ? new OpenAI(clientOptions) : new AzureOpenAI({
@@ -1,4 +1,4 @@
1
- import { t as projectCopilotRequestFacts } from "./github-copilot-request-facts-DEE6gcB9.mjs";
1
+ import { t as projectCopilotRequestFacts } from "./github-copilot-request-facts-F-EmvkpW.mjs";
2
2
  //#region packages/ai/src/providers/cache-retention.ts
3
3
  /**
4
4
  * Resolve cache retention preference.
@@ -9,6 +9,7 @@ type DiagnosticMediaField = {
9
9
  source?: string | Uint8Array;
10
10
  };
11
11
  type DiagnosticProjectionPolicy = {
12
+ redactCredentials?: boolean;
12
13
  omitField?: (key: string) => boolean;
13
14
  propertyScope?: "enumerable" | "error";
14
15
  projectBinary?: (binary: Uint8Array) => unknown;
@@ -1,8 +1,8 @@
1
1
  import { a as isProviderRefusalAssistantError } from "./diagnostics-DzrF1h4J.mjs";
2
2
  import { i as asOptionalRecord, o as isRecord } from "./record-coerce-CNDovvft.mjs";
3
- import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-CtgOVOSv.mjs";
4
- import { n as asNonNegativeFiniteNumber, t as asFiniteNumber } from "./number-coercion-C3hztWoY.mjs";
5
- import "./provider-error-CF9GWCs2.mjs";
3
+ import { r as normalizeLowercaseStringOrEmpty } from "./string-coerce-Cj8sqWHx.mjs";
4
+ import { n as asNonNegativeFiniteNumber, t as asFiniteNumber } from "./number-coercion-37gmNkuA.mjs";
5
+ import "./provider-error-qtZD2inE.mjs";
6
6
  //#region packages/normalization-core/src/error-coercion.ts
7
7
  function readProperty(value, key) {
8
8
  try {
@@ -1,9 +1,9 @@
1
- import { o as ProviderRefusalReview, s as readProviderRefusalReview } from "./index-BYDvopUB.mjs";
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-Bd2T86VJ.mjs";
3
- import "./types-Kdfw_04V.mjs";
4
- import { n as isResponsesOutputLimitToolCallError } from "./openai-responses-terminal-usage-BygjiAdi.mjs";
5
- import { n as ProviderErrorRedactor, r as configureProviderErrorRedactor } from "./provider-error-xumb1V3F.mjs";
6
- import { i as projectDiagnosticValue, t as DiagnosticProjectionPolicy } from "./credential-redaction-BHxruEH6.mjs";
1
+ import { o as ProviderRefusalReview, s as readProviderRefusalReview } from "./index-DSprYWaz.mjs";
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";
5
+ import { n as ProviderErrorRedactor, r as configureProviderErrorRedactor } from "./provider-error-CnaWYTRY.mjs";
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";
8
8
  //#region packages/ai/src/transports/openai-responses-stream-errors.d.ts
9
9
  /** Resume only a response that could not have completed tools or exposed visible output. */
@@ -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
- import { a as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-CF9GWCs2.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-tQasYct1.mjs";
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";
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,42 +1,19 @@
1
- import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
2
1
  //#region packages/ai/src/env-api-keys.ts
3
2
  let nodeHelpers;
4
- const dynamicImport = (specifier) => import(specifier);
5
- const NODE_FS_SPECIFIER = "node:fs";
6
- const NODE_OS_SPECIFIER = "node:os";
7
- const NODE_PATH_SPECIFIER = "node:path";
8
- function loadNodeBuiltinModule(specifier) {
9
- const getBuiltinModule = typeof process !== "undefined" ? process : void 0;
10
- if (typeof getBuiltinModule?.getBuiltinModule === "function") return getBuiltinModule.getBuiltinModule(specifier);
11
- if (typeof __require === "function") return __require(specifier);
12
- return null;
13
- }
14
3
  function loadNodeHelpersSync() {
15
4
  try {
16
- const fsModule = loadNodeBuiltinModule(NODE_FS_SPECIFIER);
17
- const osModule = loadNodeBuiltinModule(NODE_OS_SPECIFIER);
18
- const pathModule = loadNodeBuiltinModule(NODE_PATH_SPECIFIER);
19
- if (fsModule && osModule && pathModule) nodeHelpers = {
20
- existsSync: fsModule.existsSync,
21
- homedir: osModule.homedir,
22
- join: pathModule.join
5
+ const { existsSync } = process.getBuiltinModule("node:fs");
6
+ const { homedir } = process.getBuiltinModule("node:os");
7
+ const { join } = process.getBuiltinModule("node:path");
8
+ nodeHelpers = {
9
+ existsSync,
10
+ homedir,
11
+ join
23
12
  };
24
13
  } catch {}
25
14
  return nodeHelpers;
26
15
  }
27
- if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) {
28
- if (!loadNodeHelpersSync()) Promise.all([
29
- dynamicImport(NODE_FS_SPECIFIER),
30
- dynamicImport(NODE_OS_SPECIFIER),
31
- dynamicImport(NODE_PATH_SPECIFIER)
32
- ]).then(([fsModule, osModule, pathModule]) => {
33
- nodeHelpers = {
34
- existsSync: fsModule.existsSync,
35
- homedir: osModule.homedir,
36
- join: pathModule.join
37
- };
38
- });
39
- }
16
+ if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) loadNodeHelpersSync();
40
17
  let procEnvCache = null;
41
18
  function getProcessEnv() {
42
19
  return typeof process === "undefined" ? void 0 : process.env;
@@ -52,9 +29,8 @@ function getProcEnv(key) {
52
29
  if (procEnvCache === null) {
53
30
  procEnvCache = /* @__PURE__ */ new Map();
54
31
  try {
55
- const fsModule = loadNodeBuiltinModule(NODE_FS_SPECIFIER);
56
- if (!fsModule) return;
57
- const data = fsModule.readFileSync("/proc/self/environ", "utf-8");
32
+ const { readFileSync } = process.getBuiltinModule("node:fs");
33
+ const data = readFileSync("/proc/self/environ", "utf-8");
58
34
  for (const entry of data.split("\0")) {
59
35
  const idx = entry.indexOf("=");
60
36
  if (idx > 0) procEnvCache.set(entry.slice(0, idx), entry.slice(idx + 1));
@@ -0,0 +1 @@
1
+ import "./event-stream-CzpE1g_o.mjs";
@@ -1,4 +1,4 @@
1
- import { a as AssistantMessage, o as AssistantMessageEvent, ot as ThinkingContent, s as AssistantMessageEventStreamContract } from "./types-Bd2T86VJ.mjs";
1
+ import { a as AssistantMessage, o as AssistantMessageEvent, ot as ThinkingContent, s as AssistantMessageEventStreamContract } from "./types-CVYzKrMl.mjs";
2
2
  //#region packages/llm-core/src/utils/event-stream.d.ts
3
3
  /** Returns only an append whose current and previously observed snapshots still match. */
4
4
  declare function readAssistantThinkingAppend(block: ThinkingContent, previous: string): string | undefined;
@@ -1,3 +1,3 @@
1
- import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-BcqWLo_u.mjs";
2
- import "./event-stream-6UNs-AhN.mjs";
1
+ import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-CzpE1g_o.mjs";
2
+ import "./event-stream-CDpFza-M.mjs";
3
3
  export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
@@ -1,4 +1,4 @@
1
- import { f as hasRuntimeContextMarker } from "./types-CQc6JNG4.mjs";
1
+ import { f as hasRuntimeContextMarker } from "./types-BXd0kI8-.mjs";
2
2
  import "./types.mjs";
3
3
  //#region packages/ai/src/providers/github-copilot-request-facts.ts
4
4
  /** Request facts shared by Copilot transports; identity headers remain plugin-owned. */
@@ -1,40 +1,21 @@
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-Bf3NjYNj.mjs";
4
- import { t as buildGuardedModelFetch } from "./host-policy-BzZluO6_.mjs";
5
- import { P as sanitizeSurrogates, b as transportAbortError, c as failTransportStream, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, m as notifyProviderHttpResponse, w as parseJsonPreservingUnsafeIntegers } from "./transport-stream-shared-CWGOuLcA.mjs";
6
- import { C as stripSystemPromptCacheBoundary, n as buildBaseOptions } from "./simple-options-BAu4B54D.mjs";
7
- import { n as getEnvApiKey } from "./env-api-keys-CrxwdylR.mjs";
8
- import { n as transformProviderMessages, t as createAssistantOutput } from "./assistant-output-BuhRpLeD.mjs";
9
- import { n as buildGoogleInteractionsSimpleThinking } from "./google-shared-zGR0QUyS.mjs";
10
- import { createRequire } from "node:module";
3
+ import { O as calculateCost, a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-B2gk-d1H.mjs";
4
+ import { t as buildGuardedModelFetch } from "./host-policy-mpqGhbeM.mjs";
5
+ import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
6
+ import { n as buildBaseOptions, w as stripSystemPromptCacheBoundary } from "./simple-options-BYgC6kse.mjs";
7
+ import { b as transportAbortError, c as failTransportStream, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, m as notifyProviderHttpResponse, w as parseJsonPreservingUnsafeIntegers } from "./transport-stream-shared-CzQlAzJH.mjs";
8
+ import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
9
+ import { n as transformProviderMessages, t as createAssistantOutput } from "./assistant-output-6iFA1nbC.mjs";
10
+ import { n as buildGoogleInteractionsSimpleThinking } from "./google-shared-VTcCJLW3.mjs";
11
+ //#region packages/ai/package.json
12
+ var version = "2026.10.10-beta.1";
13
+ //#endregion
11
14
  //#region packages/ai/src/providers/google-interactions-request.ts
12
15
  const DEFAULT_GOOGLE_API_BASE_URL = "https://generativelanguage.googleapis.com";
13
16
  let packageVersionMemo;
14
17
  function resolvePackageVersion() {
15
- if (packageVersionMemo) return packageVersionMemo;
16
- if (typeof process !== "undefined" && process.env?.OPENCLAW_VERSION) {
17
- packageVersionMemo = process.env.OPENCLAW_VERSION;
18
- return packageVersionMemo;
19
- }
20
- try {
21
- const require = createRequire(import.meta.url);
22
- for (const candidate of [
23
- "../package.json",
24
- "../../package.json",
25
- "../../../package.json",
26
- "../../../../package.json"
27
- ]) try {
28
- const parsed = asRecord(require(candidate));
29
- const name = readStringField(parsed, "name");
30
- const version = readStringField(parsed, "version");
31
- if (version && (name === "openclaw" || name === "@openclaw/ai")) {
32
- packageVersionMemo = version;
33
- return packageVersionMemo;
34
- }
35
- } catch {}
36
- } catch {}
37
- packageVersionMemo = "0.0";
18
+ if (!packageVersionMemo) packageVersionMemo = typeof process !== "undefined" && process.env?.OPENCLAW_VERSION || version;
38
19
  return packageVersionMemo;
39
20
  }
40
21
  function resolveGoogleApiClientHeaders(params) {
@@ -270,20 +251,19 @@ async function runGoogleInteractionsLifecycle(params) {
270
251
  let buffer = "";
271
252
  let currentBlock = null;
272
253
  let currentBlockIndex = -1;
273
- let currentToolArgs = "";
274
254
  let latestThoughtSignature;
275
255
  let latestUsage;
276
256
  const endCurrentBlock = () => {
277
257
  if (!currentBlock) return;
278
258
  if (currentBlock.type === "toolCall") {
279
- if (currentToolArgs.trim()) currentBlock.arguments = parseTerminalToolCallArguments(currentToolArgs);
259
+ if (currentBlock.partialJson?.trim()) currentBlock.arguments = parseTerminalToolCallArguments(currentBlock.partialJson);
260
+ delete currentBlock.partialJson;
280
261
  stream.push({
281
262
  type: "toolcall_end",
282
263
  contentIndex: currentBlockIndex,
283
264
  toolCall: currentBlock,
284
265
  partial: output
285
266
  });
286
- currentToolArgs = "";
287
267
  } else {
288
268
  if (currentBlock.type === "thinking") {
289
269
  if (!currentBlock.thinkingSignature && latestThoughtSignature) currentBlock.thinkingSignature = latestThoughtSignature;
@@ -344,9 +324,9 @@ async function runGoogleInteractionsLifecycle(params) {
344
324
  type: "toolCall",
345
325
  id: readStringField(source, "id") ?? nextToolCallId(name),
346
326
  name,
347
- arguments: args
327
+ arguments: args,
328
+ partialJson: Object.keys(args).length > 0 ? JSON.stringify(args) : ""
348
329
  };
349
- currentToolArgs = Object.keys(args).length > 0 ? JSON.stringify(args) : "";
350
330
  output.content.push(toolCall);
351
331
  stream.push({
352
332
  type: "toolcall_start",
@@ -419,7 +399,7 @@ async function runGoogleInteractionsLifecycle(params) {
419
399
  if (streamedToolName && (!currentBlock.name || currentBlock.name === "tool")) currentBlock.name = streamedToolName;
420
400
  const streamedToolCallId = readStringField(delta, "id");
421
401
  if (streamedToolCallId) currentBlock.id = streamedToolCallId;
422
- currentToolArgs += argText;
402
+ currentBlock.partialJson = (currentBlock.partialJson ?? "") + argText;
423
403
  stream.push({
424
404
  type: "toolcall_delta",
425
405
  contentIndex: currentBlockIndex,
@@ -451,6 +431,7 @@ async function runGoogleInteractionsLifecycle(params) {
451
431
  const outputTokens = candidatesTokens + thoughtTokens;
452
432
  const totalTokens = Number(usage.total_tokens ?? promptTokens + outputTokens + toolUseTokens);
453
433
  output.usage = {
434
+ usageReport: { state: typeof usage.total_input_tokens === "number" && typeof usage.total_output_tokens === "number" ? "available" : "unavailable" },
454
435
  input: Math.max(0, promptTokens - cacheRead) + toolUseTokens,
455
436
  output: outputTokens,
456
437
  cacheRead,
@@ -490,6 +471,7 @@ async function runGoogleInteractionsLifecycle(params) {
490
471
  stream.end();
491
472
  } catch (error) {
492
473
  const failure = options?.signal?.aborted ? transportAbortError(options.signal) : error;
474
+ for (const block of output.content) if (block.type === "toolCall") delete block.partialJson;
493
475
  failTransportStream({
494
476
  stream,
495
477
  output,
@@ -1,11 +1,15 @@
1
1
  import { r as appendAssistantThinking } from "./event-stream-X2gmsUWv.mjs";
2
- import { N as isImageWithMediaPayload, O as calculateCost } from "./host-Bf3NjYNj.mjs";
3
- import { P as sanitizeSurrogates, a as createEmptyTransportUsage, b as transportAbortError, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-CWGOuLcA.mjs";
4
- import { D as sortPromptCacheToolsByName, d as describeToolResultMediaPlaceholder, m as extractToolResultText } from "./simple-options-BAu4B54D.mjs";
2
+ import { N as isImageWithMediaPayload, O as calculateCost } from "./host-B2gk-d1H.mjs";
3
+ import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
4
+ import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-D_MeCQFI.mjs";
5
+ import { f as extractToolResultText, l as describeToolResultMediaPlaceholder } from "./simple-options-BYgC6kse.mjs";
6
+ import { a as createEmptyTransportUsage, b as transportAbortError, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-CzQlAzJH.mjs";
5
7
  import { t as notifyLlmRequestActivity } from "./llm-request-activity-CfMuh5cC.mjs";
8
+ import { isGoogleGemini4Model } from "./internal/google-model-family.mjs";
6
9
  //#region packages/ai/src/transports/google-thinking-level.ts
7
- /** Returns whether a Gemini Flash model accepts the MINIMAL thinking level. */
10
+ /** Reports MINIMAL support for Gemini Flash and Gemini 4 models. */
8
11
  function googleFlashSupportsMinimalThinking(modelId) {
12
+ if (isGoogleGemini4Model(modelId)) return false;
9
13
  const match = modelId.toLowerCase().match(/(?:^|\/)gemini-3\.(\d+)-flash(?:-|$)/);
10
14
  if (!match) return true;
11
15
  return Number.parseInt(match[1] ?? "0", 10) < 7;
@@ -97,6 +101,7 @@ async function consumeGoogleGenerateContentStream(params) {
97
101
  const outputTokens = knownUsage.candidatesTokenCount + knownUsage.thoughtsTokenCount;
98
102
  params.output.usage = {
99
103
  ...createEmptyTransportUsage(),
104
+ usageReport: { state: sawTerminalReason || chunk.candidates?.some((candidate) => candidate.finishReason && candidate.finishReason !== "FINISH_REASON_UNSPECIFIED") ? "available" : "unavailable" },
100
105
  input: Math.max(0, promptTokens - cacheRead) + toolUsePromptTokens,
101
106
  output: outputTokens,
102
107
  cacheRead,
@@ -189,11 +194,18 @@ async function consumeGoogleGenerateContentStream(params) {
189
194
  contentIndex: blockIndex(),
190
195
  partial: params.output
191
196
  });
197
+ const streamingCall = {
198
+ ...toolCall,
199
+ partialJson: JSON.stringify(toolCall.arguments)
200
+ };
192
201
  params.stream.push({
193
202
  type: "toolcall_delta",
194
203
  contentIndex: blockIndex(),
195
- delta: JSON.stringify(toolCall.arguments),
196
- partial: params.output
204
+ delta: streamingCall.partialJson,
205
+ partial: {
206
+ ...params.output,
207
+ content: [...params.output.content.slice(0, -1), streamingCall]
208
+ }
197
209
  });
198
210
  params.stream.push({
199
211
  type: "toolcall_end",
@@ -1,10 +1,10 @@
1
1
  import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
2
- import { a as resolveAiTransportHeaderSentinels } from "./host-Bf3NjYNj.mjs";
3
- import { n as buildManagedModelFetch } from "./host-policy-BzZluO6_.mjs";
4
- import { f as mergeTransportHeaders } from "./transport-stream-shared-CWGOuLcA.mjs";
5
- import { n as buildBaseOptions } from "./simple-options-BAu4B54D.mjs";
6
- import { t as createAssistantOutput } from "./assistant-output-BuhRpLeD.mjs";
7
- import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-zGR0QUyS.mjs";
2
+ import { a as resolveAiTransportHeaderSentinels } from "./host-B2gk-d1H.mjs";
3
+ import { n as buildManagedModelFetch } from "./host-policy-mpqGhbeM.mjs";
4
+ import { n as buildBaseOptions } from "./simple-options-BYgC6kse.mjs";
5
+ import { f as mergeTransportHeaders } from "./transport-stream-shared-CzQlAzJH.mjs";
6
+ import { t as createAssistantOutput } from "./assistant-output-6iFA1nbC.mjs";
7
+ import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-VTcCJLW3.mjs";
8
8
  import { ResourceScope } from "@google/genai";
9
9
  //#region packages/ai/src/providers/google-http-options.ts
10
10
  function buildGoogleHttpOptions(model, optionsHeaders, profile) {