@openclaw/ai 2026.9.3 → 2026.9.4

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 (80) hide show
  1. package/dist/{anthropic-CZy5U0NY.mjs → anthropic-C4Qu4H0Z.mjs} +14 -13
  2. package/dist/{anthropic-payload-policy-wuRCb6MH.d.mts → anthropic-payload-policy-BZ8umAbk.d.mts} +3 -3
  3. package/dist/{anthropic-stream-reducer-B_yo_7pf.mjs → anthropic-stream-reducer-CILWF7JD.mjs} +17 -12
  4. package/dist/{api-registry-CB1-1oQ2.d.mts → api-registry-ByUwIR0e.d.mts} +2 -2
  5. package/dist/{assistant-output-iqnlJCV2.mjs → assistant-output-tLt4H-iQ.mjs} +1 -1
  6. package/dist/{azure-openai-responses-Crpa40QR.mjs → azure-openai-responses-BAlqlKKc.mjs} +4 -4
  7. package/dist/{diagnostics-dV98PqIy.mjs → diagnostics-QuErwCIl.mjs} +1 -1
  8. package/dist/diagnostics.mjs +2 -2
  9. package/dist/{event-stream-C1Z2piyk.d.mts → event-stream-Bt5Y4Pav.d.mts} +1 -1
  10. package/dist/event-stream-C3WGFsum.d.mts +1 -0
  11. package/dist/event-stream.d.mts +2 -2
  12. package/dist/{google-BDPriaVe.mjs → google-DPBAOaOW.mjs} +6 -6
  13. package/dist/{google-messages-CVn9eFpF.mjs → google-messages-6JkpHrhJ.mjs} +3 -4
  14. package/dist/{google-shared-BedY23XS.mjs → google-shared-BvBeW9aq.mjs} +5 -5
  15. package/dist/{google-vertex-DMz8XQCn.mjs → google-vertex-k-TMCAYD.mjs} +4 -4
  16. package/dist/{host-DK3wmS3e.d.mts → host-4atIX-2V.d.mts} +5 -3
  17. package/dist/{host-CWuF-sS3.mjs → host-B8YfDGd4.mjs} +140 -5
  18. package/dist/{host-policy-CAopLRKA.mjs → host-policy-Zcg_cNz8.mjs} +1 -1
  19. package/dist/{index-CQ6LTHw8.d.mts → index-DdD3qerf.d.mts} +4 -4
  20. package/dist/index.d.mts +7 -7
  21. package/dist/index.mjs +5 -4
  22. package/dist/internal/anthropic.d.mts +5 -5
  23. package/dist/internal/anthropic.mjs +4 -4
  24. package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
  25. package/dist/internal/openai-responses-payload-policy.mjs +3 -2
  26. package/dist/internal/openai.d.mts +6 -6
  27. package/dist/internal/openai.mjs +8 -9
  28. package/dist/internal/runtime.d.mts +43 -8
  29. package/dist/internal/runtime.mjs +3 -5
  30. package/dist/internal/shared.d.mts +32 -3
  31. package/dist/internal/shared.mjs +3 -4
  32. package/dist/{mistral--m-Jm6VZ.mjs → mistral-CxUZ1jUb.mjs} +5 -8
  33. package/dist/{openai-chatgpt-responses-nDZccFW-.mjs → openai-chatgpt-responses-CgO6kZfo.mjs} +13 -14
  34. package/dist/{openai-completions-compat-CXn3T1we.d.mts → openai-completions-compat-eHgh5UPE.d.mts} +3 -3
  35. package/dist/{openai-completions-stream-BQk3SkLD.mjs → openai-completions-stream-Da2vvl-S.mjs} +45 -14
  36. package/dist/{openai-completions-KuoZyx0d.mjs → openai-completions-yJuk7eis.mjs} +10 -10
  37. package/dist/{openai-prompt-cache-rrutvqxq.d.mts → openai-prompt-cache-B4eYo2-I.d.mts} +2 -2
  38. package/dist/{openai-prompt-cache-BI0rkM-5.mjs → openai-prompt-cache-Bds-n_9Q.mjs} +1 -1
  39. package/dist/{openai-provider-client-ha_WxTyj.mjs → openai-provider-client-S2gCrM2Z.mjs} +2 -2
  40. package/dist/{openai-responses-D99dOzKI.mjs → openai-responses-DaYwH05E.mjs} +7 -7
  41. package/dist/{openai-responses-compaction-window-D5jbzCi3.mjs → openai-responses-compaction-window-CIhBAkkq.mjs} +3 -80
  42. package/dist/{openai-responses-contracts-B55afwRo.d.mts → openai-responses-contracts-BjBAqAg_.d.mts} +5 -38
  43. package/dist/{openai-reasoning-effort-BK7FbcLT.mjs → openai-responses-contracts-DDOHA62Y.mjs} +79 -1
  44. package/dist/{openai-responses-prompt-observer-internal-tApyTLVu.mjs → openai-responses-prompt-observer-internal-f8J7wpsk.mjs} +3 -3
  45. package/dist/{openai-responses-shared-ZyQEzS5i.mjs → openai-responses-shared-B8RdBPCv.mjs} +18 -18
  46. package/dist/{openai-transport-params-DNasp2fU.mjs → openai-transport-params-9aPuV5YY.mjs} +11 -10
  47. package/dist/positive-integer-41zhOdcV.mjs +8 -0
  48. package/dist/{provider-error-C6TbKiey.mjs → provider-error-BA-v_tKd.mjs} +47 -5
  49. package/dist/{provider-options-BXr9Ec83.d.mts → provider-options-Ceqv1OKk.d.mts} +2 -2
  50. package/dist/{provider-replay-context-BuSUaAk5.mjs → provider-replay-context-CJ_YvcEW.mjs} +1 -1
  51. package/dist/{provider-transcript-transform-pPmUIwKt.mjs → provider-transcript-transform-V5YzU9zh.mjs} +1 -1
  52. package/dist/provider-transport-turn-state-D5EXOFL2.mjs +42 -0
  53. package/dist/{provider-types-CAV0Og3m.d.mts → provider-types-CVjKjsuq.d.mts} +3 -3
  54. package/dist/provider-types.d.mts +6 -6
  55. package/dist/providers.d.mts +2 -2
  56. package/dist/providers.mjs +10 -10
  57. package/dist/{reasoning-tag-text-partitioner-BQBi4B9d.mjs → reasoning-tag-text-partitioner-BcR5pztD.mjs} +1 -8
  58. package/dist/{session-affinity-CCH7eYdB.mjs → session-affinity-Bcunsn4I.mjs} +5 -2
  59. package/dist/{simple-options-tcKOqnpF.mjs → simple-options-BQbb4yQL.mjs} +23 -4
  60. package/dist/src-DDmEryvj.mjs +2 -0
  61. package/dist/{transport-stream-shared-DOxpGJ-H.d.mts → transport-stream-shared-DNvmoWnv.d.mts} +20 -36
  62. package/dist/{transport-stream-shared-Cu3ZPhNW.mjs → transport-stream-shared-zHll9BxO.mjs} +223 -11
  63. package/dist/{transport-utils-CCooe-cr.mjs → transport-utils-zrYjICLZ.mjs} +4 -7
  64. package/dist/transports.d.mts +35 -163
  65. package/dist/transports.mjs +66 -82
  66. package/dist/types-DlfwzH3T.d.mts +1 -0
  67. package/dist/types-LFWwv0cF.mjs +8 -0
  68. package/dist/{types-Dy1q0CSu.d.mts → types-Ntv5z2g2.d.mts} +3 -1
  69. package/dist/types.d.mts +6 -6
  70. package/dist/types.mjs +4 -3
  71. package/dist/{src-B2Q_6G8V.mjs → usage-cost-BNWbbXav.mjs} +0 -1
  72. package/dist/{validation-CaFUZN9B.d.mts → validation-B0t_G2H6.d.mts} +1 -1
  73. package/dist/validation.d.mts +1 -1
  74. package/package.json +1 -1
  75. package/dist/event-stream-I_GlBsuZ.d.mts +0 -1
  76. package/dist/hash-CHgqbJmD.mjs +0 -16
  77. package/dist/json-parse-Dw_hnxsA.mjs +0 -146
  78. package/dist/sanitize-unicode-Bb-v9meu.mjs +0 -83
  79. package/dist/types-BADKjDBI.d.mts +0 -1
  80. package/dist/types-BDdaOVi2.mjs +0 -6
@@ -1,7 +1,7 @@
1
- import { _ as supportsClaude1MContext, a as CLAUDE_FABLE_5_THINKING_PROFILE, b as supportsClaudeNativeMaxEffort, c as bindsClaudeThinkingPrefix, d as resolveClaudeFable5ModelIdentity, f as resolveClaudeModelIdentity, g as resolveClaudeSonnet5ModelIdentity, h as resolveClaudeOpus5ModelIdentity, i as normalizeResolvedPricing, l as requiresClaudeDefaultSampling, m as resolveClaudeNativeThinkingLevelMap, n as calculateUsageCost, o as CLAUDE_OPUS_5_THINKING_PROFILE, p as resolveClaudeMythos5ModelIdentity, r as normalizeModelCostConfig, s as CLAUDE_SONNET_5_THINKING_PROFILE, u as requiresClaudeMandatoryAdaptiveThinking, v as supportsClaudeAdaptiveThinking, x as supportsClaudeNativeXhighEffort, y as supportsClaudeFastMode } from "./index-CQ6LTHw8.mjs";
2
- import { $ as ThinkingLevel, A as ModelThinkingLevel, B as ProviderResponse, C as KnownImagesApi, F as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, G as StopReason, H as RawModelCostConfig, I as PricingTier, J as StreamOptions, K as StreamFn, L as Provider, M as OpenAIResponsesCompat, N as OpenRouterRouting, O as ModelCostConfig, P as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, Q as ThinkingContent, R as ProviderImagesOptions, S as KnownApi, T as MaybePromise, U as RawPricingTier, W as SimpleStreamOptions, X as TextSignatureV1, Y as TextContent, Z as ThinkingBudgets, _ as ImagesModel, a as AssistantMessage, at as Usage, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as VercelGatewayRouting, et as ThinkingLevelMap, f as ImageContent, g as ImagesInputContent, h as ImagesFunction, i as AssistantImages, it as Transport, j as OpenAICompletionsCompat, k as ModelCostRates, l as CacheRetention, m as ImagesContext, n as Api, nt as ToolCall, o as AssistantMessageEvent, ot as UserMessage, p as ImagesApi, r as AssistantDeliveryTtsFacts, rt as ToolResultMessage, s as AssistantMessageEventStreamContract, st as ValidateToolArgumentsFn, t as AnthropicMessagesCompat, tt as Tool, u as CompleteSimpleFn, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderReplayState } from "./types-Dy1q0CSu.mjs";
1
+ import { _ as supportsClaude1MContext, a as CLAUDE_FABLE_5_THINKING_PROFILE, b as supportsClaudeNativeMaxEffort, c as bindsClaudeThinkingPrefix, d as resolveClaudeFable5ModelIdentity, f as resolveClaudeModelIdentity, g as resolveClaudeSonnet5ModelIdentity, h as resolveClaudeOpus5ModelIdentity, i as normalizeResolvedPricing, l as requiresClaudeDefaultSampling, m as resolveClaudeNativeThinkingLevelMap, n as calculateUsageCost, o as CLAUDE_OPUS_5_THINKING_PROFILE, p as resolveClaudeMythos5ModelIdentity, r as normalizeModelCostConfig, s as CLAUDE_SONNET_5_THINKING_PROFILE, u as requiresClaudeMandatoryAdaptiveThinking, v as supportsClaudeAdaptiveThinking, x as supportsClaudeNativeXhighEffort, y as supportsClaudeFastMode } from "./index-DdD3qerf.mjs";
2
+ import { $ as ThinkingContent, A as ModelCostRates, B as ProviderReplayState, C as KnownImagesApi, E as MaybePromise, F as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, G as SimpleStreamOptions, I as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, K as StopReason, L as PricingTier, M as OpenAICompletionsCompat, N as OpenAIResponsesCompat, P as OpenRouterRouting, Q as ThinkingBudgets, R as Provider, S as KnownApi, T as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, U as RawModelCostConfig, V as ProviderResponse, W as RawPricingTier, X as TextContent, Y as StreamOptions, Z as TextSignatureV1, _ as ImagesModel, a as AssistantMessage, at as Transport, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as ValidateToolArgumentsFn, et as ThinkingLevel, f as ImageContent, g as ImagesInputContent, h as ImagesFunction, i as AssistantImages, it as ToolResultMessage, j as ModelThinkingLevel, k as ModelCostConfig, l as CacheRetention, lt as VercelGatewayRouting, m as ImagesContext, n as Api, nt as Tool, o as AssistantMessageEvent, ot as Usage, p as ImagesApi, q as StreamFn, r as AssistantDeliveryTtsFacts, rt as ToolCall, s as AssistantMessageEventStreamContract, st as UserMessage, t as AnthropicMessagesCompat, tt as ThinkingLevelMap, u as CompleteSimpleFn, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderImagesOptions } from "./types-Ntv5z2g2.mjs";
3
3
  import { a as extractDiagnosticError, i as createAssistantMessageDiagnostic, n as DiagnosticErrorInfo, o as formatThrownValue, r as appendAssistantMessageDiagnostic, s as isProviderRefusalAssistantError, t as AssistantMessageDiagnostic } from "./diagnostics-DnPnOui6.mjs";
4
- import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-C1Z2piyk.mjs";
5
- import { n as validateToolCall, t as validateToolArguments } from "./validation-CaFUZN9B.mjs";
6
- import { a as ProviderContextHandoff, c as ProviderStreamFunction, d as VideoContent, f as resolveProviderContext, i as ProviderContext, l as ProviderStreamOptions, n as ModelInputContent, o as ProviderMessage, r as PROVIDER_CONTEXT_HANDOFF, s as ProviderModel, t as MediaContent, u as ProviderUserMessage } from "./provider-types-CAV0Og3m.mjs";
7
- export { type AnthropicMessagesCompat, type Api, type AssistantDeliveryTtsFacts, type AssistantImages, type AssistantMessage, type AssistantMessageDiagnostic, type AssistantMessageEvent, type AssistantMessageEventStream, type AssistantMessageEventStreamContract, type AssistantMessageEventStreamLike, type CLAUDE_FABLE_5_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DiagnosticErrorInfo, type EventStream, type ImageContent, type ImagesApi, type ImagesContext, type ImagesFunction, type ImagesInputContent, type ImagesModel, type ImagesOptions, type ImagesOutputContent, type ImagesProvider, type ImagesStopReason, type KnownApi, type KnownImagesApi, type KnownImagesProvider, type MaybePromise, MediaContent, type ProviderMessage as Message, ProviderMessage, type ProviderModel as Model, ProviderModel, type ModelCostConfig, type ModelCostRates, ModelInputContent, type ModelThinkingLevel, type OpenAICompletionsCompat, type OpenAIResponsesCompat, type OpenRouterRouting, PROVIDER_CONTEXT_HANDOFF, type PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, type PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, type PricingTier, type Provider, ProviderContextHandoff, type ProviderImagesOptions, type ProviderReplayState, type ProviderResponse, ProviderStreamFunction, type ProviderStreamFunction as StreamFunction, ProviderStreamOptions, ProviderUserMessage, type RawModelCostConfig, type RawPricingTier, type SimpleStreamOptions, type StopReason, type StreamFn, type StreamOptions, type TextContent, type TextSignatureV1, type ThinkingBudgets, type ThinkingContent, type ThinkingLevel, type ThinkingLevelMap, type Tool, type ToolCall, type ToolResultMessage, type Transport, type Usage, type UserMessage, type ValidateToolArgumentsFn, type VercelGatewayRouting, VideoContent, type appendAssistantMessageDiagnostic, type bindsClaudeThinkingPrefix, type calculateUsageCost, type createAssistantMessageDiagnostic, type createAssistantMessageEventStream, type extractDiagnosticError, type formatThrownValue, type isProviderRefusalAssistantError, type normalizeModelCostConfig, type normalizeResolvedPricing, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeNativeMaxEffort, type supportsClaudeNativeXhighEffort, type validateToolArguments, type validateToolCall };
4
+ import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-Bt5Y4Pav.mjs";
5
+ import { n as validateToolCall, t as validateToolArguments } from "./validation-B0t_G2H6.mjs";
6
+ import { a as ProviderContextHandoff, c as ProviderStreamFunction, d as VideoContent, f as resolveProviderContext, i as ProviderContext, l as ProviderStreamOptions, n as ModelInputContent, o as ProviderMessage, r as PROVIDER_CONTEXT_HANDOFF, s as ProviderModel, t as MediaContent, u as ProviderUserMessage } from "./provider-types-CVjKjsuq.mjs";
7
+ export { type AnthropicMessagesCompat, type Api, type AssistantDeliveryTtsFacts, type AssistantImages, type AssistantMessage, type AssistantMessageDiagnostic, type AssistantMessageEvent, type AssistantMessageEventStream, type AssistantMessageEventStreamContract, type AssistantMessageEventStreamLike, type CLAUDE_FABLE_5_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DiagnosticErrorInfo, type EventStream, type ImageContent, type ImagesApi, type ImagesContext, type ImagesFunction, type ImagesInputContent, type ImagesModel, type ImagesOptions, type ImagesOutputContent, type ImagesProvider, type ImagesStopReason, type KnownApi, type KnownImagesApi, type KnownImagesProvider, type MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, type MaybePromise, MediaContent, type ProviderMessage as Message, ProviderMessage, type ProviderModel as Model, ProviderModel, type ModelCostConfig, type ModelCostRates, ModelInputContent, type ModelThinkingLevel, type OpenAICompletionsCompat, type OpenAIResponsesCompat, type OpenRouterRouting, PROVIDER_CONTEXT_HANDOFF, type PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, type PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, type PricingTier, type Provider, ProviderContextHandoff, type ProviderImagesOptions, type ProviderReplayState, type ProviderResponse, ProviderStreamFunction, type ProviderStreamFunction as StreamFunction, ProviderStreamOptions, ProviderUserMessage, type RawModelCostConfig, type RawPricingTier, type SimpleStreamOptions, type StopReason, type StreamFn, type StreamOptions, type TextContent, type TextSignatureV1, type ThinkingBudgets, type ThinkingContent, type ThinkingLevel, type ThinkingLevelMap, type Tool, type ToolCall, type ToolResultMessage, type Transport, type Usage, type UserMessage, type ValidateToolArgumentsFn, type VercelGatewayRouting, VideoContent, type appendAssistantMessageDiagnostic, type bindsClaudeThinkingPrefix, type calculateUsageCost, type createAssistantMessageDiagnostic, type createAssistantMessageEventStream, type extractDiagnosticError, type formatThrownValue, type isProviderRefusalAssistantError, type normalizeModelCostConfig, type normalizeResolvedPricing, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeNativeMaxEffort, type supportsClaudeNativeXhighEffort, type validateToolArguments, type validateToolCall };
@@ -1,5 +1,5 @@
1
- import { n as ApiRegistry } from "./api-registry-CB1-1oQ2.mjs";
2
- import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-rrutvqxq.mjs";
1
+ import { n as ApiRegistry } from "./api-registry-ByUwIR0e.mjs";
2
+ import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-B4eYo2-I.mjs";
3
3
  //#region packages/ai/src/providers/register-builtins.d.ts
4
4
  /** Source id used for built-in API provider registrations. */
5
5
  export declare const BUILT_IN_API_PROVIDER_SOURCE_ID = "core:built-in";
@@ -1,6 +1,6 @@
1
1
  import { t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
2
- import { n as projectProviderError } from "./provider-error-C6TbKiey.mjs";
3
- import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-BI0rkM-5.mjs";
2
+ import { n as projectProviderError } from "./provider-error-BA-v_tKd.mjs";
3
+ import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-Bds-n_9Q.mjs";
4
4
  //#region packages/ai/src/providers/register-builtins.ts
5
5
  /** Source id used for built-in API provider registrations. */
6
6
  const BUILT_IN_API_PROVIDER_SOURCE_ID = "core:built-in";
@@ -62,35 +62,35 @@ function createLazyRegistration(api, importModule, select) {
62
62
  };
63
63
  }
64
64
  const registerBuiltIns = [
65
- createLazyRegistration("anthropic-messages", () => import("./anthropic-CZy5U0NY.mjs").then((n) => n.t), (module) => ({
65
+ createLazyRegistration("anthropic-messages", () => import("./anthropic-C4Qu4H0Z.mjs").then((n) => n.t), (module) => ({
66
66
  stream: module.streamAnthropic,
67
67
  streamSimple: module.streamSimpleAnthropic
68
68
  })),
69
- createLazyRegistration("openai-completions", () => import("./openai-completions-KuoZyx0d.mjs").then((n) => n.t), (module) => ({
69
+ createLazyRegistration("openai-completions", () => import("./openai-completions-yJuk7eis.mjs").then((n) => n.t), (module) => ({
70
70
  stream: module.streamOpenAICompletions,
71
71
  streamSimple: module.streamSimpleOpenAICompletions
72
72
  })),
73
- createLazyRegistration("mistral-conversations", () => import("./mistral--m-Jm6VZ.mjs"), (module) => ({
73
+ createLazyRegistration("mistral-conversations", () => import("./mistral-CxUZ1jUb.mjs"), (module) => ({
74
74
  stream: module.streamMistral,
75
75
  streamSimple: module.streamSimpleMistral
76
76
  })),
77
- createLazyRegistration("openai-responses", () => import("./openai-responses-D99dOzKI.mjs").then((n) => n.t), (module) => ({
77
+ createLazyRegistration("openai-responses", () => import("./openai-responses-DaYwH05E.mjs").then((n) => n.t), (module) => ({
78
78
  stream: module.streamOpenAIResponses,
79
79
  streamSimple: module.streamSimpleOpenAIResponses
80
80
  })),
81
- createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-Crpa40QR.mjs"), (module) => ({
81
+ createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-BAlqlKKc.mjs"), (module) => ({
82
82
  stream: module.streamAzureOpenAIResponses,
83
83
  streamSimple: module.streamSimpleAzureOpenAIResponses
84
84
  })),
85
- createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-nDZccFW-.mjs"), (module) => ({
85
+ createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-CgO6kZfo.mjs"), (module) => ({
86
86
  stream: module.streamOpenAICodexResponses,
87
87
  streamSimple: module.streamSimpleOpenAICodexResponses
88
88
  })),
89
- createLazyRegistration("google-generative-ai", () => import("./google-BDPriaVe.mjs"), (module) => ({
89
+ createLazyRegistration("google-generative-ai", () => import("./google-DPBAOaOW.mjs"), (module) => ({
90
90
  stream: module.streamGoogle,
91
91
  streamSimple: module.streamSimpleGoogle
92
92
  })),
93
- createLazyRegistration("google-vertex", () => import("./google-vertex-DMz8XQCn.mjs"), (module) => ({
93
+ createLazyRegistration("google-vertex", () => import("./google-vertex-k-TMCAYD.mjs"), (module) => ({
94
94
  stream: module.streamGoogleVertex,
95
95
  streamSimple: module.streamSimpleGoogleVertex
96
96
  }))
@@ -1,12 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
- import "./base64-D-su8YVo.mjs";
3
- //#region packages/normalization-core/src/expect.ts
4
- /** Returns the value or throws with the named context; use for genuine invariants only. */
5
- function expectDefined(value, context) {
6
- if (value === null || value === void 0) throw new Error("expected " + context + " to be defined");
7
- return value;
8
- }
9
- //#endregion
2
+ import { a as expectDefined } from "./provider-error-BA-v_tKd.mjs";
10
3
  //#region node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
11
4
  /**
12
5
  * @typedef {import('mdast').Nodes} Nodes
@@ -10,11 +10,14 @@ function isOpencodeEndpoint(baseUrl) {
10
10
  /** Required conversation identity is independent of optional prompt caching. */
11
11
  function resolveOpencodeSessionHeaders(model, options) {
12
12
  if (!options?.sessionId || !isOpencodeEndpoint(model.baseUrl)) return options?.headers;
13
- if ([model.headers, options.headers].some((headers) => Object.keys(headers ?? {}).some((name) => name.toLowerCase() === "x-opencode-session"))) return options.headers;
13
+ if (hasOpencodeSessionHeader(model, options)) return options.headers;
14
14
  return {
15
15
  ...options.headers,
16
16
  "x-opencode-session": options.sessionId
17
17
  };
18
18
  }
19
+ function hasOpencodeSessionHeader(model, options) {
20
+ return [model.headers, options?.headers].some((headers) => Object.keys(headers ?? {}).some((name) => name.toLowerCase() === "x-opencode-session"));
21
+ }
19
22
  //#endregion
20
- export { resolveOpencodeSessionHeaders as t };
23
+ export { resolveOpencodeSessionHeaders as n, hasOpencodeSessionHeader as t };
@@ -1,6 +1,6 @@
1
1
  import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.mjs";
2
- import { t as sanitizeSurrogates } from "./sanitize-unicode-Bb-v9meu.mjs";
3
- import { r as copyProviderAcceptanceObserver } from "./transport-stream-shared-Cu3ZPhNW.mjs";
2
+ import { v as sanitizeSurrogates } from "./host-B8YfDGd4.mjs";
3
+ import { i as copyProviderAcceptanceObserver } from "./transport-stream-shared-zHll9BxO.mjs";
4
4
  //#region packages/ai/src/utils/prompt-cache-stability.ts
5
5
  /**
6
6
  * Prompt-cache normalization helpers. They keep generated prompt sections
@@ -40,8 +40,23 @@ function normalizePromptCapabilityIds(capabilities) {
40
40
  * Keeps stable prompt prefixes separate from dynamic runtime additions for provider prompt caching.
41
41
  */
42
42
  const SYSTEM_PROMPT_CACHE_BOUNDARY = "\n<!-- OPENCLAW_CACHE_BOUNDARY -->\n";
43
+ /** Producer-delimited Runtime facts; instructions must remain outside this region. */
44
+ const SYSTEM_PROMPT_RELOCATABLE_BOUNDARY = "\n<!-- OPENCLAW-RELOCATABLE-BOUNDARY -->\n";
45
+ const SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END = "\n<!-- /OPENCLAW-RELOCATABLE-BOUNDARY -->";
43
46
  function stripSystemPromptCacheBoundary(text) {
44
- return text.replaceAll(SYSTEM_PROMPT_CACHE_BOUNDARY, "\n");
47
+ return stripSystemPromptRelocatableBoundary(text.replaceAll(SYSTEM_PROMPT_CACHE_BOUNDARY, "\n").replaceAll(SYSTEM_PROMPT_CACHE_BOUNDARY.trim(), ""));
48
+ }
49
+ /** Reject ambiguous markers from workspace or hook text instead of moving instructions. */
50
+ function splitSystemPromptRelocatableBoundary(text) {
51
+ const opening = SYSTEM_PROMPT_RELOCATABLE_BOUNDARY.trim();
52
+ const closing = SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END.trim();
53
+ const start = text.indexOf(opening);
54
+ const end = text.indexOf(closing);
55
+ if (start === -1 || end < start || text.includes(opening, start + 38) || text.includes(closing, end + 39)) return;
56
+ return {
57
+ remainingPrompt: [text.slice(0, start).trimEnd(), text.slice(end + 39).trimStart()].filter(Boolean).join("\n"),
58
+ relocatable: text.slice(start + 38, end).trim()
59
+ };
45
60
  }
46
61
  function ensureSystemPromptCacheBoundary(systemPrompt) {
47
62
  if (systemPrompt.trim().length === 0) return systemPrompt;
@@ -55,6 +70,10 @@ function splitSystemPromptCacheBoundary(text) {
55
70
  dynamicSuffix: text.slice(boundaryIndex + 34).trimStart()
56
71
  };
57
72
  }
73
+ /** Keep explicit cache breakpoints while removing relocation metadata. */
74
+ function stripSystemPromptRelocatableBoundary(text) {
75
+ return text.replaceAll(SYSTEM_PROMPT_RELOCATABLE_BOUNDARY, "\n").replaceAll(SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END, "").replaceAll(SYSTEM_PROMPT_RELOCATABLE_BOUNDARY.trim(), "").replaceAll(SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END.trim(), "");
76
+ }
58
77
  function prependSystemPromptAdditionAfterCacheBoundary(params) {
59
78
  const systemPromptAddition = typeof params.systemPromptAddition === "string" ? normalizeStructuredPromptSection(params.systemPromptAddition) : "";
60
79
  if (!systemPromptAddition) return params.systemPrompt;
@@ -151,4 +170,4 @@ function adjustMaxTokensForThinking(baseMaxTokens, modelMaxTokens, reasoningLeve
151
170
  };
152
171
  }
153
172
  //#endregion
154
- export { codeModeToolSurfaceObserver as a, ensureSystemPromptCacheBoundary as c, stripSystemPromptCacheBoundary as d, normalizePromptCapabilityIds as f, clampReasoning as i, prependSystemPromptAdditionAfterCacheBoundary as l, sortPromptCacheToolsByName as m, buildBaseOptions as n, reasoningTagTextPolicy as o, normalizeStructuredPromptSection as p, clampMaxTokensToModel as r, SYSTEM_PROMPT_CACHE_BOUNDARY as s, adjustMaxTokensForThinking as t, splitSystemPromptCacheBoundary as u };
173
+ export { normalizeStructuredPromptSection as _, codeModeToolSurfaceObserver as a, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY as c, prependSystemPromptAdditionAfterCacheBoundary as d, splitSystemPromptCacheBoundary as f, normalizePromptCapabilityIds as g, stripSystemPromptRelocatableBoundary as h, clampReasoning as i, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END as l, stripSystemPromptCacheBoundary as m, buildBaseOptions as n, reasoningTagTextPolicy as o, splitSystemPromptRelocatableBoundary as p, clampMaxTokensToModel as r, SYSTEM_PROMPT_CACHE_BOUNDARY as s, adjustMaxTokensForThinking as t, ensureSystemPromptCacheBoundary as u, sortPromptCacheToolsByName as v };
@@ -0,0 +1,2 @@
1
+ import "./validation-BDzVDnTs.mjs";
2
+ export {};
@@ -1,36 +1,8 @@
1
- import "./index-CQ6LTHw8.mjs";
2
- import { B as ProviderResponse, D as Model, J as StreamOptions, a as AssistantMessage, at as Usage } from "./types-Dy1q0CSu.mjs";
3
- import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-C1Z2piyk.mjs";
4
- import "./event-stream-I_GlBsuZ.mjs";
1
+ import "./index-DdD3qerf.mjs";
2
+ import { O as Model, V as ProviderResponse, Y as StreamOptions, a as AssistantMessage, ot as Usage } from "./types-Ntv5z2g2.mjs";
3
+ import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-Bt5Y4Pav.mjs";
4
+ import "./event-stream-C3WGFsum.mjs";
5
5
  import { t as ProviderErrorProjection } from "./provider-error-CzNw4BWX.mjs";
6
- //#region packages/ai/src/utils/stream-first-event-timeout.d.ts
7
- type StreamStage = "responses" | "completions";
8
- type FirstStreamEventTimeoutContext = {
9
- provider?: string;
10
- api?: string;
11
- model?: string;
12
- timeoutMs: number;
13
- stage?: StreamStage;
14
- hint?: string;
15
- abort?: (reason: Error) => void;
16
- onTimeout?: (reason: Error) => void;
17
- };
18
- type FirstStreamEventInternalOptions = {
19
- firstEventTimeoutMs?: number;
20
- abortFirstEventStream?: (reason: Error) => void;
21
- onFirstEventTimeout?: (reason: Error) => void;
22
- };
23
- type FirstStreamEventAbortController = {
24
- signal: AbortSignal;
25
- abort: (reason: Error) => void;
26
- dispose: () => void;
27
- };
28
- declare function getFirstStreamEventTimeoutMs(options: unknown): number | undefined;
29
- declare function getFirstStreamEventTimeoutHandler(options: unknown): ((reason: Error) => void) | undefined;
30
- declare function createFirstStreamEventTimeoutError(context: FirstStreamEventTimeoutContext): Error;
31
- declare function createFirstStreamEventAbortController(parentSignal?: AbortSignal): FirstStreamEventAbortController;
32
- declare function withFirstStreamEventTimeout<T>(stream: AsyncIterable<T>, context: FirstStreamEventTimeoutContext): AsyncIterable<T>;
33
- //#endregion
34
6
  //#region packages/ai/src/transports/transport-stream-shared.d.ts
35
7
  type ContextUsage = NonNullable<Usage["contextUsage"]>;
36
8
  type TransportUsage = {
@@ -52,12 +24,24 @@ type WritableTransportStream = Pick<ReturnType<typeof createAssistantMessageEven
52
24
  declare function sanitizeTransportPayloadText(text: string): string;
53
25
  declare function sanitizeNonEmptyTransportPayloadText(text: string, fallback?: string): string;
54
26
  declare function coerceTransportToolCallArguments(argumentsValue: unknown): Record<string, unknown>;
55
- /** Admit only complete object-shaped terminal tool arguments; partial parsing is preview-only. */
56
- declare function parseTerminalToolCallArguments(value: unknown, errorMessage?: string): Record<string, unknown>;
27
+ /** Stable terminal fact: presentation must not infer unfinished calls from provider prose. */
28
+ declare class IncompleteToolCallError extends Error {
29
+ readonly code = "incomplete_tool_call";
30
+ }
31
+ /**
32
+ * Admit only complete object-shaped terminal tool arguments; partial parsing is preview-only.
33
+ * `repairStringLiterals` opts a stream whose provider may deliver unvalidated tool input into
34
+ * string-literal repair before rejection.
35
+ */
36
+ declare function parseTerminalToolCallArguments(value: unknown, errorMessage?: string, options?: {
37
+ repairStringLiterals?: boolean;
38
+ }): Record<string, unknown>;
57
39
  /** Validate a complete sibling set before mutating any call into executable state. */
58
40
  declare function finalizeTerminalToolCallArguments<T extends {
59
41
  arguments: Record<string, unknown>;
60
- }>(calls: readonly T[], readArguments: (call: T) => unknown, errorMessage?: string): void;
42
+ }>(calls: readonly T[], readArguments: (call: T) => unknown, errorMessage?: string, options?: {
43
+ repairStringLiterals?: boolean;
44
+ }): void;
61
45
  declare function mergeTransportHeaders(...headerSources: Array<Record<string, string> | undefined>): Record<string, string> | undefined;
62
46
  declare function mergeTransportMetadata<T extends Record<string, unknown>>(payload: T, metadata?: Record<string, string>): T;
63
47
  declare function createEmptyTransportUsage(): TransportUsage;
@@ -135,4 +119,4 @@ declare function failTransportStream(params: {
135
119
  cleanup?: () => void;
136
120
  }): void;
137
121
  //#endregion
138
- export { FirstStreamEventInternalOptions as C, getFirstStreamEventTimeoutHandler as D, createFirstStreamEventTimeoutError as E, getFirstStreamEventTimeoutMs as O, FirstStreamEventAbortController as S, createFirstStreamEventAbortController as T, sanitizeNonEmptyTransportPayloadText as _, copyProviderAcceptanceObserver as a, withProviderAcceptanceObserver as b, failTransportStream as c, mergeTransportHeaders as d, mergeTransportMetadata as f, parseTerminalToolCallArguments as g, notifyProviderStreamOpened as h, coerceTransportToolCallArguments as i, withFirstStreamEventTimeout as k, finalizeTerminalToolCallArguments as l, notifyProviderHttpResponse as m, WritableTransportStream as n, createEmptyTransportUsage as o, notifyProviderHttpMetadata as p, assignTransportErrorDetails as r, createWritableTransportEventStream as s, ProviderAcceptance as t, finalizeTransportStream as u, sanitizeTransportPayloadText as v, FirstStreamEventTimeoutContext as w, withProviderResponseHook as x, transportAbortError as y };
122
+ export { withProviderResponseHook as S, parseTerminalToolCallArguments as _, coerceTransportToolCallArguments as a, transportAbortError as b, createWritableTransportEventStream as c, finalizeTransportStream as d, mergeTransportHeaders as f, notifyProviderStreamOpened as g, notifyProviderHttpResponse as h, assignTransportErrorDetails as i, failTransportStream as l, notifyProviderHttpMetadata as m, ProviderAcceptance as n, copyProviderAcceptanceObserver as o, mergeTransportMetadata as p, WritableTransportStream as r, createEmptyTransportUsage as s, IncompleteToolCallError as t, finalizeTerminalToolCallArguments as u, sanitizeNonEmptyTransportPayloadText as v, withProviderAcceptanceObserver as x, sanitizeTransportPayloadText as y };
@@ -1,9 +1,25 @@
1
1
  import { n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-CPeq9F7y.mjs";
2
2
  import { i as createAssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
3
- import { t as sanitizeSurrogates } from "./sanitize-unicode-Bb-v9meu.mjs";
3
+ import { n as getAiTransportHost, v as sanitizeSurrogates } from "./host-B8YfDGd4.mjs";
4
4
  import { i as asOptionalRecord, n as asNullableRecord, t as asNonArrayRecord } from "./record-coerce-DwRYMj3t.mjs";
5
- import { n as projectProviderError, r as projectDiagnosticValue } from "./provider-error-C6TbKiey.mjs";
6
- import { c as isTransientNetworkError } from "./diagnostics-dV98PqIy.mjs";
5
+ import { n as projectProviderError, r as projectDiagnosticValue } from "./provider-error-BA-v_tKd.mjs";
6
+ import { c as isTransientNetworkError } from "./diagnostics-QuErwCIl.mjs";
7
+ import { parse } from "partial-json";
8
+ //#region packages/ai/src/utils/hash.ts
9
+ /** Fast deterministic hash to shorten long strings */
10
+ function shortHash(str) {
11
+ let h1 = 3735928559;
12
+ let h2 = 1103547991;
13
+ for (let i = 0; i < str.length; i++) {
14
+ const ch = str.charCodeAt(i);
15
+ h1 = Math.imul(h1 ^ ch, 2654435761);
16
+ h2 = Math.imul(h2 ^ ch, 1597334677);
17
+ }
18
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
19
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
20
+ return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36);
21
+ }
22
+ //#endregion
7
23
  //#region packages/ai/src/utils/headers.ts
8
24
  /** Converts a Headers object to a plain record for provider request handling. */
9
25
  function headersToRecord(headers) {
@@ -12,6 +28,155 @@ function headersToRecord(headers) {
12
28
  return result;
13
29
  }
14
30
  //#endregion
31
+ //#region packages/ai/src/utils/json-parse.ts
32
+ const VALID_JSON_ESCAPES = /* @__PURE__ */ new Set([
33
+ "\"",
34
+ "\\",
35
+ "/",
36
+ "b",
37
+ "f",
38
+ "n",
39
+ "r",
40
+ "t",
41
+ "u"
42
+ ]);
43
+ const JSON_CONTROL_ESCAPES = /* @__PURE__ */ new Set([
44
+ "b",
45
+ "f",
46
+ "n",
47
+ "r",
48
+ "t"
49
+ ]);
50
+ function isControlCharacter(char) {
51
+ const codePoint = char.codePointAt(0);
52
+ return codePoint !== void 0 && codePoint >= 0 && codePoint <= 31;
53
+ }
54
+ function escapeControlCharacter(char) {
55
+ switch (char) {
56
+ case "\b": return "\\b";
57
+ case "\f": return "\\f";
58
+ case "\n": return "\\n";
59
+ case "\r": return "\\r";
60
+ case " ": return "\\t";
61
+ default: return `\\u${char.codePointAt(0)?.toString(16).padStart(4, "0") ?? "0000"}`;
62
+ }
63
+ }
64
+ /**
65
+ * Repairs malformed JSON string literals by:
66
+ * - escaping raw control characters inside strings
67
+ * - doubling backslashes before invalid escape characters
68
+ *
69
+ * By default a valid control escape (`\n`, `\t`, ...) that follows a Windows-path-looking
70
+ * prefix is treated as an unescaped path separator and doubled. Pass
71
+ * `preserveValidControlEscapes` when the text is authoritative (for example a completed
72
+ * tool-call argument buffer) and every valid escape must survive as written.
73
+ */
74
+ function repairJson(json, options) {
75
+ const preserveValidControlEscapes = options?.preserveValidControlEscapes === true;
76
+ let repaired = "";
77
+ let inString = false;
78
+ let stringValuePrefix = "";
79
+ for (let index = 0; index < json.length; index++) {
80
+ const char = json.charAt(index);
81
+ if (!inString) {
82
+ repaired += char;
83
+ if (char === "\"") {
84
+ inString = true;
85
+ stringValuePrefix = "";
86
+ }
87
+ continue;
88
+ }
89
+ if (char === "\"") {
90
+ repaired += char;
91
+ inString = false;
92
+ stringValuePrefix = "";
93
+ continue;
94
+ }
95
+ if (char === "\\") {
96
+ const nextChar = json.charAt(index + 1);
97
+ if (!nextChar) {
98
+ repaired += "\\\\";
99
+ continue;
100
+ }
101
+ if (nextChar === "u") {
102
+ const unicodeDigits = json.slice(index + 2, index + 6);
103
+ if (/^[0-9a-fA-F]{4}$/.test(unicodeDigits)) {
104
+ repaired += `\\u${unicodeDigits}`;
105
+ stringValuePrefix += `\\u${unicodeDigits}`;
106
+ index += 5;
107
+ continue;
108
+ }
109
+ repaired += "\\\\";
110
+ stringValuePrefix += "\\";
111
+ continue;
112
+ }
113
+ if (!preserveValidControlEscapes && JSON_CONTROL_ESCAPES.has(nextChar) && looksLikeWindowsPathPrefix(stringValuePrefix)) {
114
+ repaired += "\\\\";
115
+ stringValuePrefix += "\\";
116
+ continue;
117
+ }
118
+ if (VALID_JSON_ESCAPES.has(nextChar)) {
119
+ repaired += `\\${nextChar}`;
120
+ stringValuePrefix += nextChar === "\\" ? "\\" : `\\${nextChar}`;
121
+ index += 1;
122
+ continue;
123
+ }
124
+ repaired += "\\\\";
125
+ stringValuePrefix += "\\";
126
+ continue;
127
+ }
128
+ repaired += isControlCharacter(char) ? escapeControlCharacter(char) : char;
129
+ stringValuePrefix += char;
130
+ }
131
+ return repaired;
132
+ }
133
+ function parseJsonWithRepair(json) {
134
+ return JSON.parse(repairJson(json));
135
+ }
136
+ function looksLikeWindowsPathPrefix(prefix) {
137
+ const tail = prefix.slice(-160);
138
+ return /(?:^|[^A-Za-z0-9])[A-Za-z]:(?:[\\/][^"\\/:*?<>|\r\n]*)*$/.test(tail);
139
+ }
140
+ /**
141
+ * Attempts to parse potentially incomplete JSON during streaming.
142
+ * Always returns a valid object, even if the JSON is incomplete.
143
+ *
144
+ * @param partialJson The partial JSON string from streaming
145
+ * @returns Parsed object or empty object if parsing fails
146
+ */
147
+ function parseStreamingJson(partialJson) {
148
+ if (!partialJson || partialJson.trim() === "") return {};
149
+ try {
150
+ return asNonArrayRecord(parseJsonWithRepair(partialJson));
151
+ } catch {
152
+ try {
153
+ return asNonArrayRecord(parse(partialJson));
154
+ } catch {
155
+ try {
156
+ return asNonArrayRecord(parse(repairJson(partialJson)));
157
+ } catch {
158
+ return {};
159
+ }
160
+ }
161
+ }
162
+ }
163
+ const TOOL_ARGUMENT_PREVIEW_FIRST_CHECKPOINT_CHARS = 512;
164
+ /**
165
+ * Streamed tool-call arguments are preview-only; the terminal parse re-reads
166
+ * the full buffer authoritatively at content_block_stop. Reparsing every delta
167
+ * scans an ever-growing buffer and makes assembly quadratic in the argument
168
+ * size, so refresh previews on a geometric length schedule instead — bounded
169
+ * staleness, linear total parse work.
170
+ */
171
+ function createToolArgumentPreviewSchedule() {
172
+ let nextCheckpointChars = TOOL_ARGUMENT_PREVIEW_FIRST_CHECKPOINT_CHARS;
173
+ return (accumulatedChars) => {
174
+ if (accumulatedChars < nextCheckpointChars) return false;
175
+ nextCheckpointChars = accumulatedChars * 2;
176
+ return true;
177
+ };
178
+ }
179
+ //#endregion
15
180
  //#region packages/ai/src/transports/json-unsafe-integers.ts
16
181
  /**
17
182
  * JSON parsing helpers that preserve integer literals larger than
@@ -123,15 +288,59 @@ function coerceTransportToolCallArguments(argumentsValue) {
123
288
  } catch {}
124
289
  return {};
125
290
  }
126
- /** Admit only complete object-shaped terminal tool arguments; partial parsing is preview-only. */
127
- function parseTerminalToolCallArguments(value, errorMessage = MALFORMED_TOOL_CALL_TERMINAL_ERROR_MESSAGE) {
291
+ /** Stable terminal fact: presentation must not infer unfinished calls from provider prose. */
292
+ var IncompleteToolCallError = class extends Error {
293
+ constructor(..._args) {
294
+ super(..._args);
295
+ this.code = "incomplete_tool_call";
296
+ }
297
+ };
298
+ const MALFORMED_TOOL_CALL_TERMINAL_ERROR_CODE = "malformed_tool_call_arguments";
299
+ function createMalformedToolCallArgumentsError(value, errorMessage, repairAttempted) {
300
+ const text = typeof value === "string" ? value : void 0;
301
+ const diagnostics = {
302
+ code: MALFORMED_TOOL_CALL_TERMINAL_ERROR_CODE,
303
+ argumentChars: text?.length ?? 0,
304
+ argumentHash: text === void 0 ? "" : shortHash(text),
305
+ repairAttempted
306
+ };
307
+ const error = new Error(errorMessage, { cause: diagnostics });
308
+ Object.assign(error, {
309
+ errorCode: MALFORMED_TOOL_CALL_TERMINAL_ERROR_CODE,
310
+ errorBody: JSON.stringify(diagnostics)
311
+ });
312
+ return error;
313
+ }
314
+ /**
315
+ * Repair a complete-but-invalid terminal argument buffer. Anthropic fine-grained tool
316
+ * streaming skips server-side JSON validation, so a finished tool_use block can carry raw
317
+ * control characters or invalid escapes inside string values. Only string-literal repairs
318
+ * are applied and every valid escape is preserved as written; truncated or non-object
319
+ * buffers stay rejected so a cut-off write never executes with partial arguments.
320
+ */
321
+ function repairTerminalToolCallArguments(value) {
322
+ const repaired = repairJson(value, { preserveValidControlEscapes: true });
323
+ if (repaired === value) return null;
324
+ return parseJsonObjectPreservingUnsafeIntegers(repaired);
325
+ }
326
+ /**
327
+ * Admit only complete object-shaped terminal tool arguments; partial parsing is preview-only.
328
+ * `repairStringLiterals` opts a stream whose provider may deliver unvalidated tool input into
329
+ * string-literal repair before rejection.
330
+ */
331
+ function parseTerminalToolCallArguments(value, errorMessage = MALFORMED_TOOL_CALL_TERMINAL_ERROR_MESSAGE, options) {
128
332
  const parsed = parseJsonObjectPreservingUnsafeIntegers(value);
129
- if (!parsed) throw new Error(errorMessage);
130
- return parsed;
333
+ if (parsed) return parsed;
334
+ const repairStringLiterals = options?.repairStringLiterals === true && typeof value === "string";
335
+ if (repairStringLiterals) {
336
+ const repaired = repairTerminalToolCallArguments(value);
337
+ if (repaired) return repaired;
338
+ }
339
+ throw createMalformedToolCallArgumentsError(value, errorMessage, repairStringLiterals);
131
340
  }
132
341
  /** Validate a complete sibling set before mutating any call into executable state. */
133
- function finalizeTerminalToolCallArguments(calls, readArguments, errorMessage) {
134
- const validated = calls.map((call) => [call, parseTerminalToolCallArguments(readArguments(call), errorMessage)]);
342
+ function finalizeTerminalToolCallArguments(calls, readArguments, errorMessage, options) {
343
+ const validated = calls.map((call) => [call, parseTerminalToolCallArguments(readArguments(call), errorMessage, options)]);
135
344
  for (const [call, argumentsValue] of validated) call.arguments = argumentsValue;
136
345
  }
137
346
  function mergeTransportHeaders(...headerSources) {
@@ -229,6 +438,7 @@ async function awaitProviderLifecycleCallback(callback, signal) {
229
438
  if (signal?.aborted) throw transportAbortError(signal);
230
439
  if (!callback) return;
231
440
  const callbackPromise = Promise.resolve().then(callback);
441
+ getAiTransportHost().observePendingProviderWork?.(callbackPromise);
232
442
  if (!signal) {
233
443
  await callbackPromise;
234
444
  return;
@@ -247,7 +457,9 @@ async function awaitProviderLifecycleCallback(callback, signal) {
247
457
  function startProviderStreamCancellation(cancelStream, error) {
248
458
  const reason = error instanceof Error ? error : new Error(String(error));
249
459
  try {
250
- Promise.resolve(cancelStream(reason)).catch(() => void 0);
460
+ const pending = Promise.resolve(cancelStream(reason));
461
+ pending.catch(() => void 0);
462
+ getAiTransportHost().observePendingProviderWork?.(pending);
251
463
  } catch {}
252
464
  }
253
465
  async function awaitProviderLifecycleWithCleanup(params) {
@@ -352,4 +564,4 @@ function failTransportStream(params) {
352
564
  stream.end();
353
565
  }
354
566
  //#endregion
355
- export { headersToRecord as C, quoteUnsafeIntegerLiterals as S, transportAbortError as _, createWritableTransportEventStream as a, parseJsonObjectPreservingUnsafeIntegers as b, finalizeTransportStream as c, notifyProviderHttpMetadata as d, notifyProviderHttpResponse as f, sanitizeTransportPayloadText as g, sanitizeNonEmptyTransportPayloadText as h, createEmptyTransportUsage as i, mergeTransportHeaders as l, parseTerminalToolCallArguments as m, coerceTransportToolCallArguments as n, failTransportStream as o, notifyProviderStreamOpened as p, copyProviderAcceptanceObserver as r, finalizeTerminalToolCallArguments as s, assignTransportErrorDetails as t, mergeTransportMetadata as u, withProviderAcceptanceObserver as v, parseJsonPreservingUnsafeIntegers as x, withProviderResponseHook as y };
567
+ export { quoteUnsafeIntegerLiterals as C, repairJson as D, parseStreamingJson as E, headersToRecord as O, parseJsonPreservingUnsafeIntegers as S, parseJsonWithRepair as T, sanitizeTransportPayloadText as _, createEmptyTransportUsage as a, withProviderResponseHook as b, finalizeTerminalToolCallArguments as c, mergeTransportMetadata as d, notifyProviderHttpMetadata as f, sanitizeNonEmptyTransportPayloadText as g, parseTerminalToolCallArguments as h, copyProviderAcceptanceObserver as i, shortHash as k, finalizeTransportStream as l, notifyProviderStreamOpened as m, assignTransportErrorDetails as n, createWritableTransportEventStream as o, notifyProviderHttpResponse as p, coerceTransportToolCallArguments as r, failTransportStream as s, IncompleteToolCallError as t, mergeTransportHeaders as u, transportAbortError as v, createToolArgumentPreviewSchedule as w, parseJsonObjectPreservingUnsafeIntegers as x, withProviderAcceptanceObserver as y };
@@ -1,7 +1,8 @@
1
- import { n as getAiTransportHost } from "./host-CWuF-sS3.mjs";
1
+ import { n as getAiTransportHost } from "./host-B8YfDGd4.mjs";
2
2
  import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
3
- import { o as parseStrictPositiveInteger } from "./base64-D-su8YVo.mjs";
3
+ import "./provider-error-BA-v_tKd.mjs";
4
4
  import "./internal/retry-after.mjs";
5
+ import "./positive-integer-41zhOdcV.mjs";
5
6
  //#region packages/normalization-core/src/response-bytes.ts
6
7
  async function consumeResponseBytes(options) {
7
8
  let size = 0;
@@ -30,10 +31,6 @@ async function consumeResponseBytes(options) {
30
31
  const MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE = "OpenClaw transport error: malformed_streaming_fragment";
31
32
  const NON_LATIN_RE = /[\u2E80-\u9FFF\uA000-\uA4FF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFF60\uFFE0-\uFFE6\u{20000}-\u{2FA1F}]/gu;
32
33
  const CJK_SURROGATE_HIGH_RE = /[\uD840-\uD87E][\uDC00-\uDFFF]/g;
33
- function parsePositiveInteger(value) {
34
- if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value);
35
- return typeof value === "string" ? parseStrictPositiveInteger(value) : void 0;
36
- }
37
34
  function redactSensitiveText(text, _options) {
38
35
  return getAiTransportHost().redactToolPayloadText(text);
39
36
  }
@@ -118,4 +115,4 @@ async function readResponseTextSnippet(response, options) {
118
115
  return truncated ? `${collapsed}…` : collapsed;
119
116
  }
120
117
  //#endregion
121
- export { parsePositiveInteger as a, resolveModelHeaderSentinels as c, isCodeModeModelVisibleToolName as i, supportsModelTools as l, createAbortError as n, readResponseTextSnippet as o, estimateStringChars as r, redactSensitiveText as s, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as t };
118
+ export { readResponseTextSnippet as a, supportsModelTools as c, isCodeModeModelVisibleToolName as i, createAbortError as n, redactSensitiveText as o, estimateStringChars as r, resolveModelHeaderSentinels as s, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as t };