@openclaw/ai 2026.10.5 → 2026.10.10-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +11 -0
  2. package/dist/{anthropic-DIIiiz99.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-DfMVFm-r.mjs → anthropic-stream-reducer-CzPXOaLM.mjs} +55 -227
  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-DGQnXRMs.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-zIz70M2e.mjs → google-interactions-DVQ7AaSF.mjs} +29 -50
  21. package/dist/{google-messages-CNbUJK5E.mjs → google-messages-DfpHVTaD.mjs} +15 -5
  22. package/dist/{google-provider-stream-Cn0XF1MG.mjs → google-provider-stream-DJ8ANfsS.mjs} +6 -6
  23. package/dist/{google-shared-BPnWP4tT.mjs → google-shared-VTcCJLW3.mjs} +21 -29
  24. package/dist/{google-vertex-XQ7OQtaM.mjs → google-vertex-Bkfizj7M.mjs} +3 -3
  25. package/dist/{google-BlbTC1Xp.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.mjs +1 -1
  35. package/dist/internal/openai-completions-compat.d.mts +1 -1
  36. package/dist/internal/openai-completions-compat.mjs +1 -1
  37. package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
  38. package/dist/internal/openai-responses-payload-policy.mjs +3 -3
  39. package/dist/internal/openai.d.mts +17 -26
  40. package/dist/internal/openai.mjs +10 -10
  41. package/dist/internal/retry-after.d.mts +1 -1
  42. package/dist/internal/retry-after.mjs +80 -55
  43. package/dist/internal/runtime.d.mts +9 -31
  44. package/dist/internal/runtime.mjs +10 -116
  45. package/dist/internal/shared.d.mts +9 -7
  46. package/dist/internal/shared.mjs +8 -6
  47. package/dist/internal/tool-schema.d.mts +83 -5
  48. package/dist/internal/tool-schema.mjs +4 -3
  49. package/dist/{mistral-dCDCR5ur.mjs → mistral-CATJrwne.mjs} +32 -35
  50. package/dist/model-request-body-BD5vy4rP.d.mts +17 -0
  51. package/dist/{number-coercion-C3hztWoY.mjs → number-coercion-37gmNkuA.mjs} +1 -1
  52. package/dist/{openai-chatgpt-responses-D8-q7cgy.mjs → openai-chatgpt-responses-CtdnpWwe.mjs} +95 -63
  53. package/dist/{openai-completions-CMN24pza.mjs → openai-completions-B6sET3oI.mjs} +10 -8
  54. package/dist/{openai-completions-compat-i-nLZxFy.d.mts → openai-completions-compat-1gsjP-KO.d.mts} +6 -3
  55. package/dist/{openai-completions-compat-CYX18uDk.mjs → openai-completions-compat-CFhQ3UVU.mjs} +7 -2
  56. package/dist/{openai-completions-transport-DuXQOxrH.mjs → openai-completions-transport-DviPEqw3.mjs} +369 -237
  57. package/dist/{openai-prompt-cache-r93BJhjm.mjs → openai-prompt-cache-DJ_P143P.mjs} +1 -1
  58. package/dist/{openai-prompt-cache-DIPMrMFy.d.mts → openai-prompt-cache-DgjD-UL5.d.mts} +2 -2
  59. package/dist/{openai-responses-BMxoJdTC.mjs → openai-responses-BXsJK-mD.mjs} +13 -15
  60. package/dist/{openai-responses-compaction-replay-B2FE4Nw8.d.mts → openai-responses-compaction-replay-Cvnl_nCq.d.mts} +5 -5
  61. package/dist/{openai-responses-contracts-DlKMMTxK.mjs → openai-responses-contracts-Bx-16mnf.mjs} +45 -6
  62. package/dist/{openai-responses-contracts-DKqMJ1Ct.d.mts → openai-responses-contracts-CQ4_AWjL.d.mts} +20 -8
  63. package/dist/{openai-responses-endpoint-CinGh4VZ.mjs → openai-responses-endpoint-D4v-eeYy.mjs} +55 -22
  64. package/dist/{openai-responses-payload-policy-C7GsA1y0.d.mts → openai-responses-payload-policy-BzM52TTH.d.mts} +9 -3
  65. package/dist/openai-responses-request-lifecycle-CTdAb2v1.mjs +246 -0
  66. package/dist/{openai-responses-shared-afo9-s16.mjs → openai-responses-shared-Bv_1NtH9.mjs} +284 -173
  67. package/dist/{openai-responses-terminal-usage-BygjiAdi.d.mts → openai-responses-terminal-usage-CpVjkqn-.d.mts} +2 -2
  68. package/dist/{openai-tool-schema-DDPXsvJP.mjs → openai-tool-schema-Buv0GXFb.mjs} +170 -237
  69. package/dist/overflow-DJHXTNBQ.mjs +117 -0
  70. package/dist/{positive-integer-CqWjqSi9.mjs → positive-integer-Bb4Evc7L.mjs} +1 -1
  71. package/dist/prompt-cache-stability-D_MeCQFI.mjs +32 -0
  72. package/dist/{provider-error-xumb1V3F.d.mts → provider-error-CnaWYTRY.d.mts} +1 -0
  73. package/dist/{provider-error-CF9GWCs2.mjs → provider-error-qtZD2inE.mjs} +75 -13
  74. package/dist/{provider-options-CVrXZBtA.d.mts → provider-options-DeYeaflL.d.mts} +52 -6
  75. package/dist/{transport-utils-34BQoXq3.mjs → provider-replay-context-J6CfU3m1.mjs} +28 -5
  76. package/dist/{provider-transport-turn-state-BYrELw8H.mjs → provider-transport-turn-state-Jxppzuc2.mjs} +5 -5
  77. package/dist/{provider-types-CHtRx0dI.d.mts → provider-types-ODq57rG_.d.mts} +3 -3
  78. package/dist/provider-types.d.mts +6 -6
  79. package/dist/providers.d.mts +2 -2
  80. package/dist/providers.mjs +11 -11
  81. package/dist/{reasoning-tag-text-partitioner-CpOy9-IQ.mjs → reasoning-tag-text-partitioner-DzlRubwU.mjs} +134 -47
  82. package/dist/{required-api-key-CFJvcFy_.mjs → required-api-key-D088S4Cd.mjs} +1 -1
  83. package/dist/{retry-after-CdCURCVg.d.mts → retry-after-sw-XX8aC.d.mts} +1 -1
  84. package/dist/sanitize-unicode-CRGuMONI.mjs +8 -0
  85. package/dist/sanitize-unicode-ZqVLLEKC.d.mts +27 -0
  86. package/dist/{session-resources-D1wgDQ8C.mjs → session-resources-vKvGIE3J.mjs} +1 -10
  87. package/dist/{simple-options-BAu4B54D.mjs → simple-options-BYgC6kse.mjs} +68 -79
  88. package/dist/{src-C44MKrW5.mjs → src-CyA0zJnt.mjs} +6 -2
  89. package/dist/{stream-Dd8DwRFL.mjs → stream-DLBirT0e.mjs} +8 -47
  90. package/dist/{stream-first-event-timeout-Dc42hKv6.mjs → stream-first-event-timeout-D_TfJHRJ.mjs} +1 -1
  91. package/dist/{string-coerce-CtgOVOSv.mjs → string-coerce-Cj8sqWHx.mjs} +26 -1
  92. package/dist/tool-schema-json-projection-B0hHDV7N.mjs +492 -0
  93. package/dist/{transport-stream-shared-BmpzDtdQ.d.mts → transport-stream-shared-8ru8eX4s.d.mts} +5 -5
  94. package/dist/{transport-stream-shared-CWGOuLcA.mjs → transport-stream-shared-CzQlAzJH.mjs} +27 -75
  95. package/dist/transports.d.mts +33 -28
  96. package/dist/transports.mjs +42 -48
  97. package/dist/{types-CQc6JNG4.mjs → types-BXd0kI8-.mjs} +1 -1
  98. package/dist/types-CBJthzJX.d.mts +1 -0
  99. package/dist/{types-Bd2T86VJ.d.mts → types-CVYzKrMl.d.mts} +20 -3
  100. package/dist/types.d.mts +6 -6
  101. package/dist/types.mjs +4 -4
  102. package/dist/{validation-ZX_sPVV0.mjs → validation-9FSkE8T-.mjs} +22 -3
  103. package/dist/{validation-DdGB1yy3.d.mts → validation-BQ5u20Ru.d.mts} +1 -1
  104. package/dist/validation.d.mts +1 -1
  105. package/dist/validation.mjs +1 -1
  106. package/package.json +3 -3
  107. package/dist/assistant-text-phase-mvdMcrY-.mjs +0 -50
  108. package/dist/event-stream-6UNs-AhN.d.mts +0 -1
  109. package/dist/expect-lbe3Hgrh.mjs +0 -8
  110. package/dist/json-schema-Bp07Qui3.mjs +0 -22
  111. package/dist/openai-responses-request-lifecycle-NSIJo9jY.mjs +0 -67
  112. package/dist/openai-tool-projection-793cE3QX.d.mts +0 -37
  113. package/dist/openai-tool-schema-a5ysBBga.d.mts +0 -32
  114. package/dist/rolldown-runtime-BhDjJH2R.mjs +0 -15
  115. package/dist/sanitize-unicode-CjDG6jJx.d.mts +0 -5
  116. package/dist/string-normalization-I3ux50s9.mjs +0 -28
  117. package/dist/text-signature-CUXnvk_c.mjs +0 -34
  118. package/dist/tool-schema-json-projection-B8sG1I9v.mjs +0 -180
  119. package/dist/types-Kdfw_04V.d.mts +0 -1
@@ -0,0 +1,117 @@
1
+ import { a as isProviderRefusalAssistantError } from "./diagnostics-DzrF1h4J.mjs";
2
+ //#region packages/ai/src/utils/overflow.ts
3
+ const CONFIGURED_CONTEXT_SIZE_OVERFLOW_RE = /prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i;
4
+ const REQUEST_BUDGET_OVERFLOW_RE = /context window exceeded: estimated input \d+ leaves only \d+ output tokens within the \d+-token context\./i;
5
+ const CONTEXT_OVERFLOW_PATTERN_SCOPES = {
6
+ "assistant-error": [
7
+ REQUEST_BUDGET_OVERFLOW_RE,
8
+ /prompt is too long/i,
9
+ /request_too_large/i,
10
+ /input length and `?max_tokens`? exceed context limit: [\d,]+ \+ [\d,]+ > [\d,]+/i,
11
+ /input is too long for requested model/i,
12
+ /exceeds the context window/i,
13
+ /exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,
14
+ /input token count.*exceeds the maximum/i,
15
+ /maximum prompt length is \d+/i,
16
+ /reduce the length of the messages/i,
17
+ /maximum context length is \d+ tokens/i,
18
+ /exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,
19
+ /input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,
20
+ /exceeds the limit of \d+/i,
21
+ /(?:exceeds the available context size|context size has been exceeded)/i,
22
+ /`?inputs`? tokens \+ `?max_new_tokens`? must be <= [\d,]+/i,
23
+ /`?inputs`? must have less than [\d,]+ tokens/i,
24
+ /greater than the context length|model is loaded with context length of only \d[\d,]* tokens, which is not enough/i,
25
+ /context window exceeds limit/i,
26
+ /exceeded model token limit/i,
27
+ /tokens? in request more than max tokens? allowed/i,
28
+ /prompt exceeds max(?:imum)? length/i,
29
+ /range of input length should be \[1, [\d,]+\]/i,
30
+ /too large for model with \d+ maximum context length/i,
31
+ CONFIGURED_CONTEXT_SIZE_OVERFLOW_RE,
32
+ /model_context_window_exceeded/i,
33
+ /prompt too long; exceeded (?:max )?context length/i,
34
+ /context[_ ]length[_ ]exceeded/i,
35
+ /too many tokens/i,
36
+ /token limit exceeded/i,
37
+ /^413\s*(?:status code)?\s*\(no body\)/i
38
+ ],
39
+ "failover-explicit": [
40
+ REQUEST_BUDGET_OVERFLOW_RE,
41
+ /request_too_large/i,
42
+ /context_overflow/i,
43
+ CONFIGURED_CONTEXT_SIZE_OVERFLOW_RE,
44
+ /invalid_argument[\s\S]*maximum number of tokens/i,
45
+ /request exceeds the maximum size/i,
46
+ /context length exceeded/i,
47
+ /maximum context length/i,
48
+ /prompt is too long/i,
49
+ /prompt too long/i,
50
+ /exceeds model context window/i,
51
+ /model token limit/i,
52
+ /input exceeds[\s\S]*maximum number of tokens/i,
53
+ /^(?=[\s\S]*context window)(?=[\s\S]*ran out of (?:room|space))/i,
54
+ /request size exceeds[\s\S]*context window/i,
55
+ /context overflow:/i,
56
+ /exceed context limit/i,
57
+ /exceeds the model'?s maximum context/i,
58
+ /max_tokens[\s\S]*exceed[\s\S]*context/i,
59
+ /input(?: length[\s\S]*exceed[\s\S]*context| \([\d,]+\s*tokens?\) is longer than (?:the )?model'?s context length)/i,
60
+ /413[\s\S]*too large/i,
61
+ /context_window_exceeded/i,
62
+ /input length [\d,]+\s+tokens? exceeds the model limit/i,
63
+ /`?inputs`? tokens \+ `?max_new_tokens`? must be <= [\d,]+/i,
64
+ /`?inputs`? must have less than [\d,]+ tokens/i,
65
+ /上下文过长|上下文超出|上下文长度超|超出最大上下文|请压缩上下文/
66
+ ],
67
+ "provider-fallback": [
68
+ /\binput token count exceeds the maximum number of input tokens\b/i,
69
+ /\binput is too long for this model\b/i,
70
+ /\binput exceeds the maximum number of tokens\b/i,
71
+ /\bollama error:\s*context length exceeded(?:,\s*too many tokens)?\b/i,
72
+ /\btotal tokens?.*exceeds? (?:the )?(?:model(?:'s)? )?(?:max|maximum|limit)/i,
73
+ /\b(?:(?:request|prompt) \(\d[\d,]*\s*tokens?\) exceeds (?:the )?available context size|context size has been exceeded)\b/i,
74
+ /\binput (?:is )?too long for (?:the )?model\b/i
75
+ ],
76
+ "failover-hint": [/context.*overflow|context window.*(too (?:large|long)|exceed|over|limit|max(?:imum)?|requested|sent|tokens)|prompt.*(too (?:large|long)|exceed|over|limit|max(?:imum)?)|(?:request|input).*(?:context|window|length|token).*(too (?:large|long)|exceed|over|limit|max(?:imum)?)/i],
77
+ "context-window-too-small": [/context window.*(too small|minimum is)/i],
78
+ "tpm-rate-limit-hint": [/\btpm\b|tokens per minute/i],
79
+ "rate-limit-hint": [/rate limit|too many requests|requests per (?:minute|hour|day)|quota|throttl|429\b|tokens per day/i]
80
+ };
81
+ /** Match one canonical context-overflow wording scope without applying caller policy. */
82
+ function matchesContextOverflowMessage(errorMessage, scope) {
83
+ return CONTEXT_OVERFLOW_PATTERN_SCOPES[scope].some((pattern) => pattern.test(errorMessage));
84
+ }
85
+ const NON_OVERFLOW_PATTERNS = [
86
+ /^(Throttling error|Service unavailable):/i,
87
+ /rate limit/i,
88
+ /too many requests/i
89
+ ];
90
+ function resolveContextInputTokens(message) {
91
+ if (message.usage.contextUsage?.state === "available") return message.usage.contextUsage.promptTokens;
92
+ if (message.usage.contextUsage?.state === "unavailable") return;
93
+ return message.usage.input + message.usage.cacheRead + message.usage.cacheWrite;
94
+ }
95
+ /**
96
+ * Match provider overflow errors, or infer overflow from reported context usage.
97
+ * A context window enables silent-overflow detection; silent truncation without
98
+ * a length stop remains undetectable because the original token count is unknown.
99
+ */
100
+ function isContextOverflow(message, contextWindow) {
101
+ if (isProviderRefusalAssistantError(message)) return false;
102
+ if (message.stopReason === "error" && message.errorMessage) {
103
+ const errorMessage = message.errorMessage;
104
+ if (!NON_OVERFLOW_PATTERNS.some((p) => p.test(errorMessage)) && matchesContextOverflowMessage(errorMessage, "assistant-error")) return true;
105
+ }
106
+ if (contextWindow && message.stopReason === "stop") {
107
+ const inputTokens = resolveContextInputTokens(message);
108
+ if (inputTokens !== void 0 && inputTokens > contextWindow) return true;
109
+ }
110
+ if (contextWindow && message.stopReason === "length" && message.usage.output === 0) {
111
+ const inputTokens = resolveContextInputTokens(message);
112
+ if (inputTokens !== void 0 && inputTokens >= contextWindow * .99) return true;
113
+ }
114
+ return false;
115
+ }
116
+ //#endregion
117
+ export { matchesContextOverflowMessage as n, isContextOverflow as t };
@@ -1,4 +1,4 @@
1
- import { s as parseStrictPositiveInteger } from "./number-coercion-C3hztWoY.mjs";
1
+ import { s as parseStrictPositiveInteger } from "./number-coercion-37gmNkuA.mjs";
2
2
  //#region packages/ai/src/transports/positive-integer.ts
3
3
  function parsePositiveInteger(value) {
4
4
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value);
@@ -0,0 +1,32 @@
1
+ import { r as normalizeLowercaseStringOrEmpty } from "./string-coerce-Cj8sqWHx.mjs";
2
+ import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
3
+ //#region packages/ai/src/utils/prompt-cache-stability.ts
4
+ /**
5
+ * Prompt-cache normalization helpers. They keep generated prompt sections
6
+ * deterministic across platform newlines, trailing whitespace, and input
7
+ * ordering.
8
+ */
9
+ /** Canonicalizes provider tool order without relying on host locale settings. */
10
+ function sortPromptCacheToolsByName(tools) {
11
+ const compareText = (left, right) => {
12
+ const leftText = left ?? "";
13
+ const rightText = right ?? "";
14
+ return leftText < rightText ? -1 : leftText > rightText ? 1 : 0;
15
+ };
16
+ return tools.toSorted((left, right) => compareText(left.wireName ?? left.name, right.wireName ?? right.name) || compareText(left.description, right.description));
17
+ }
18
+ /** Normalize structured prompt text before hashing or snapshot comparison. */
19
+ function normalizeStructuredPromptSection(text) {
20
+ return sanitizeSurrogates(text).replace(/\r\n?/g, "\n").replace(/[ \t]+$/gm, "").trim();
21
+ }
22
+ /** Normalize, de-dupe, and sort capability ids for stable prompt payloads. */
23
+ function normalizePromptCapabilityIds(capabilities) {
24
+ const seen = /* @__PURE__ */ new Set();
25
+ for (const capability of capabilities) {
26
+ const value = normalizeLowercaseStringOrEmpty(normalizeStructuredPromptSection(capability));
27
+ if (value) seen.add(value);
28
+ }
29
+ return [...seen].toSorted((left, right) => left.localeCompare(right));
30
+ }
31
+ //#endregion
32
+ export { normalizeStructuredPromptSection as n, sortPromptCacheToolsByName as r, normalizePromptCapabilityIds as t };
@@ -5,6 +5,7 @@ type ProviderErrorProjection = {
5
5
  errorCode?: string;
6
6
  errorType?: string;
7
7
  errorBody?: string;
8
+ retryAfterMs?: number | null;
8
9
  };
9
10
  type ProviderErrorRedactor = (value: unknown) => unknown;
10
11
  declare function configureProviderErrorRedactor(redactor: ProviderErrorRedactor | undefined): ProviderErrorRedactor | undefined;
@@ -1,7 +1,6 @@
1
1
  import { i as asOptionalRecord } from "./record-coerce-CNDovvft.mjs";
2
- import { o as normalizeStringifiedOptionalString } from "./string-coerce-CtgOVOSv.mjs";
3
- import "./number-coercion-C3hztWoY.mjs";
4
- import { t as expectDefined } from "./expect-lbe3Hgrh.mjs";
2
+ import { s as normalizeStringifiedOptionalString } from "./string-coerce-Cj8sqWHx.mjs";
3
+ import "./number-coercion-37gmNkuA.mjs";
5
4
  import { parseRetryAfterErrorSeconds, parseRetryAfterHeadersSeconds } from "./internal/retry-after.mjs";
6
5
  import { n as estimateBase64DecodedBytes } from "./base64-C8CdcsjU.mjs";
7
6
  //#region packages/normalization-core/src/balanced-json.ts
@@ -47,8 +46,8 @@ function extractBalancedJsonFragments(raw, opts = {}) {
47
46
  }
48
47
  return fragments;
49
48
  }
50
- //#endregion
51
- //#region packages/normalization-core/src/cjk-chars.ts
49
+ const DEFAULT_BUDGET_OPTIONS = {};
50
+ const ASCII_RUN_OR_NON_ASCII_CODE_POINT_RE = /[\p{ASCII}]+|[^\p{ASCII}]/gu;
52
51
  const WEIGHTED_CJK_RANGES = [
53
52
  [
54
53
  [183, 183],
@@ -89,13 +88,73 @@ const WEIGHTED_CJK_RANGES = [
89
88
  [196608, 210047]
90
89
  ]
91
90
  ];
92
- new RegExp(`[${WEIGHTED_CJK_RANGES.flatMap((ranges) => ranges.map(([start, end]) => `\\u{${start.toString(16)}}-\\u{${end.toString(16)}}`)).join("")}]`, "u");
93
- (() => {
91
+ const WEIGHTED_CJK_RE = new RegExp(`[${WEIGHTED_CJK_RANGES.flatMap((ranges) => ranges.map(([start, end]) => `\\u{${start.toString(16)}}-\\u{${end.toString(16)}}`)).join("")}]`, "u");
92
+ const CJK_CATEGORY = (() => {
94
93
  const maxCodePoint = Math.max(...WEIGHTED_CJK_RANGES.flatMap((ranges) => ranges.map(([, end]) => end)));
95
94
  const categories = new Uint8Array(maxCodePoint + 1);
96
95
  for (const [bucket, ranges] of WEIGHTED_CJK_RANGES.entries()) for (const [start, end] of ranges) categories.fill(bucket + 1, start, end + 1);
97
96
  return categories;
98
97
  })();
98
+ function estimateStringChars(text) {
99
+ return estimateStringCharsWithMinimumRawWeight(text);
100
+ }
101
+ /** Apply a raw-text safety floor without multiplying CJK adjustments twice. */
102
+ function estimateStringCharsWithMinimumRawWeight(text, options = DEFAULT_BUDGET_OPTIONS) {
103
+ const minimumRawWeight = Math.max(1, options.minimumRawWeight ?? 1);
104
+ if (minimumRawWeight !== 1 && minimumRawWeight !== 2) {
105
+ let chars = 0;
106
+ for (const match of text.matchAll(ASCII_RUN_OR_NON_ASCII_CODE_POINT_RE)) {
107
+ const segment = match[0];
108
+ const minimumChars = Math.ceil(segment.length * minimumRawWeight);
109
+ chars += segment.charCodeAt(0) <= 127 ? minimumChars : Math.max(estimateStringChars(segment), minimumChars);
110
+ }
111
+ return chars;
112
+ }
113
+ const firstWeighted = text.search(WEIGHTED_CJK_RE);
114
+ if (firstWeighted < 0) return text.length * minimumRawWeight;
115
+ let common = 0;
116
+ let rareBmp = 0;
117
+ let twoToken = 0;
118
+ let threeTokenSupplementary = 0;
119
+ let supplementary = 0;
120
+ for (let index = firstWeighted; index < text.length; index += 1) {
121
+ let codePoint = text.charCodeAt(index);
122
+ if (codePoint < 128) continue;
123
+ if (codePoint >= 55296 && codePoint <= 56319) {
124
+ const low = text.charCodeAt(index + 1);
125
+ if (low >= 56320 && low <= 57343) {
126
+ codePoint = 65536 + (codePoint - 55296) * 1024 + low - 56320;
127
+ index += 1;
128
+ }
129
+ }
130
+ switch (CJK_CATEGORY[codePoint]) {
131
+ case 1:
132
+ common += 1;
133
+ break;
134
+ case 2:
135
+ rareBmp += 1;
136
+ break;
137
+ case 3:
138
+ twoToken += 1;
139
+ break;
140
+ case 4:
141
+ threeTokenSupplementary += 1;
142
+ break;
143
+ case 5: supplementary += 1;
144
+ }
145
+ }
146
+ return text.length * minimumRawWeight + common * (4 - minimumRawWeight) + rareBmp * (12 - minimumRawWeight) + twoToken * (8 - minimumRawWeight) + threeTokenSupplementary * (12 - 2 * minimumRawWeight) + supplementary * (16 - 2 * minimumRawWeight);
147
+ }
148
+ function estimateTokensFromChars(chars) {
149
+ return Math.ceil(Math.max(0, chars) / 4);
150
+ }
151
+ //#endregion
152
+ //#region packages/normalization-core/src/expect.ts
153
+ /** Returns the value or throws with the named context; use for genuine invariants only. */
154
+ function expectDefined(value, context) {
155
+ if (value === null || value === void 0) throw new Error("expected " + context + " to be defined");
156
+ return value;
157
+ }
99
158
  //#endregion
100
159
  //#region packages/normalization-core/src/stable-stringify.ts
101
160
  const preserveString = (value) => value;
@@ -329,7 +388,7 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
329
388
  }) {
330
389
  try {
331
390
  if (typeof value === "string") {
332
- const projected = redactDiagnosticText(value);
391
+ const projected = policy.redactCredentials === false ? value.replace(MEDIA_DATA_URL_RE, "<redacted>") : redactDiagnosticText(value);
333
392
  state.changed ||= projected !== value;
334
393
  return projected;
335
394
  }
@@ -365,7 +424,7 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
365
424
  seen.add(value);
366
425
  const out = Array.isArray(value) ? [] : {};
367
426
  const rawName = typeof descriptors.name?.value === "string" ? descriptors.name.value : descriptors.key?.value;
368
- const redactValueField = keys.length > 64 || typeof rawName === "string" && isCredentialFieldName(normalizeDiagnosticFieldName(rawName));
427
+ const redactValueField = policy.redactCredentials !== false && (keys.length > 64 || typeof rawName === "string" && isCredentialFieldName(normalizeDiagnosticFieldName(rawName)));
369
428
  const redactMedia = mediaPayload || keys.length > 64 || isDiagnosticMediaPayload(descriptors);
370
429
  for (const key in descriptors) {
371
430
  const descriptor = expectDefined(descriptors[key], "diagnostic descriptor");
@@ -378,7 +437,7 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
378
437
  ].includes(key)) || key === "length") continue;
379
438
  const child = descriptor.value;
380
439
  const normalized = policy.omitField?.(key) ? void 0 : normalizeDiagnosticFieldName(key);
381
- if (normalized === void 0 || isCredentialFieldName(normalized)) {
440
+ if (normalized === void 0 || policy.redactCredentials !== false && isCredentialFieldName(normalized)) {
382
441
  state.changed = true;
383
442
  continue;
384
443
  }
@@ -483,8 +542,8 @@ function stringifyField(value, maxLength) {
483
542
  }
484
543
  function buildProjection(snapshot, signal) {
485
544
  const error = asOptionalRecord(snapshot);
486
- const nestedError = asOptionalRecord(error?.error);
487
545
  const response = asOptionalRecord(error?.response);
546
+ const nestedError = asOptionalRecord(error?.error) ?? asOptionalRecord(response?.error) ?? asOptionalRecord(asOptionalRecord(error?.payload)?.error);
488
547
  const status = [
489
548
  error?.status,
490
549
  error?.statusCode,
@@ -511,14 +570,17 @@ function buildProjection(snapshot, signal) {
511
570
  /** Projects one hostile provider throw into final, bounded assistant terminal fields. */
512
571
  function projectProviderError(error, signal) {
513
572
  try {
573
+ const retryAfterSeconds = parseRetryAfterErrorSeconds(error);
514
574
  const localSnapshot = projectDiagnosticValue(error);
515
575
  let snapshot = localSnapshot;
516
576
  try {
517
577
  snapshot = providerErrorRedactor?.(localSnapshot) ?? localSnapshot;
518
578
  } catch {}
519
579
  const projection = buildProjection(snapshot, signal);
520
- const retryAfterSeconds = parseRetryAfterErrorSeconds(localSnapshot);
521
580
  if (retryAfterSeconds !== void 0) {
581
+ const retryAfterMs = Math.ceil(retryAfterSeconds * 1e3);
582
+ if (Number.isSafeInteger(retryAfterMs)) projection.retryAfterMs = retryAfterMs;
583
+ else projection.retryAfterMs = null;
522
584
  const suffix = `; Retry-After: ${retryAfterSeconds} seconds`;
523
585
  projection.errorMessage = `${truncateUtf16Safe(projection.errorMessage, 4096 - suffix.length)}${suffix}`;
524
586
  }
@@ -531,4 +593,4 @@ function projectProviderError(error, signal) {
531
593
  }
532
594
  }
533
595
  //#endregion
534
- export { projectDiagnosticValue as a, stableStringify as c, isCredentialFieldName as i, projectProviderError as n, redactDiagnosticText as o, createDiagnosticRecord as r, truncateUtf16Safe as s, configureProviderErrorRedactor as t };
596
+ export { projectDiagnosticValue as a, stableStringify as c, estimateTokensFromChars as d, isCredentialFieldName as i, expectDefined as l, projectProviderError as n, redactDiagnosticText as o, createDiagnosticRecord as r, truncateUtf16Safe as s, configureProviderErrorRedactor as t, estimateStringChars as u };
@@ -1,7 +1,8 @@
1
- import { nt as StreamOptions } from "./types-Bd2T86VJ.mjs";
2
- import { t as OpenAICompletionsToolChoice } from "./openai-tool-projection-793cE3QX.mjs";
3
- import "./types-Kdfw_04V.mjs";
1
+ import { nt as StreamOptions } from "./types-CVYzKrMl.mjs";
2
+ import "./types-CBJthzJX.mjs";
3
+ import OpenAI from "openai";
4
4
  import Anthropic from "@anthropic-ai/sdk";
5
+ import { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
5
6
  //#region packages/ai/src/providers/openai-reasoning-effort.d.ts
6
7
  declare const ENABLED_REASONING_EFFORTS: readonly ["minimal", "low", "medium", "high", "xhigh", "max"];
7
8
  type OpenAIReasoningEffort = "none" | (typeof ENABLED_REASONING_EFFORTS)[number];
@@ -44,11 +45,48 @@ declare function resolveOpenAIReasoningEffortForModel(params: {
44
45
  fallbackMap?: Record<string, string>;
45
46
  }): OpenAIApiReasoningEffort | undefined;
46
47
  //#endregion
48
+ //#region packages/ai/src/providers/openai-tool-projection.d.ts
49
+ type OpenAIToolDescriptor = {
50
+ readonly name?: unknown;
51
+ readonly description?: unknown;
52
+ readonly parameters: unknown;
53
+ };
54
+ type OpenAIProjectedTool = {
55
+ readonly toolIndex: number;
56
+ readonly name: string;
57
+ readonly description?: string;
58
+ readonly parameters: Record<string, unknown>;
59
+ };
60
+ type OpenAIToolProjectionDiagnostic = {
61
+ readonly toolIndex: number;
62
+ readonly toolName?: string;
63
+ readonly violations: readonly string[];
64
+ };
65
+ type OpenAIToolProjection = {
66
+ readonly inputToolCount: number;
67
+ readonly tools: readonly OpenAIProjectedTool[];
68
+ readonly diagnostics: readonly OpenAIToolProjectionDiagnostic[];
69
+ };
70
+ type OpenAIResponsesToolChoice = ResponseCreateParamsStreaming["tool_choice"];
71
+ type OpenAICompletionsSdkToolChoice = OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming["tool_choice"];
72
+ type OpenAICompletionsToolChoice = Exclude<OpenAICompletionsSdkToolChoice, {
73
+ type: "custom";
74
+ }>;
75
+ /** Snapshots direct/custom tool descriptors before OpenAI payload construction. */
76
+ declare function projectOpenAITools(tools: readonly OpenAIToolDescriptor[]): OpenAIToolProjection;
77
+ /** Keeps Responses tool choices aligned with surviving function schemas. */
78
+ declare function reconcileOpenAIResponsesToolChoice(choice: OpenAIResponsesToolChoice, projection: OpenAIToolProjection): OpenAIResponsesToolChoice | undefined;
79
+ /** Keeps Chat Completions tool choices aligned with surviving function schemas. */
80
+ declare function reconcileOpenAICompletionsToolChoice(choice: OpenAICompletionsSdkToolChoice, projection: OpenAIToolProjection): OpenAICompletionsSdkToolChoice | undefined;
81
+ //#endregion
47
82
  //#region packages/ai/src/provider-options.d.ts
48
- type OpenAIResponsesCompactionRejection = {
83
+ /** Identity of a provider compaction checkpoint the server rejected on replay. */
84
+ type CompactionReplayRejection = {
49
85
  data: string;
50
86
  id?: string;
51
87
  };
88
+ /** @deprecated Use CompactionReplayRejection. */
89
+ type OpenAIResponsesCompactionRejection = CompactionReplayRejection;
52
90
  type CodeModeToolSurfaceObservation = {
53
91
  beforeToolIdentities: readonly string[];
54
92
  afterToolIdentities: readonly string[];
@@ -67,6 +105,12 @@ declare const reasoningTagTextPolicy: {
67
105
  isStrict: typeof isStrictReasoningTagText;
68
106
  copy(source: object | undefined, target: object): void;
69
107
  };
108
+ /** The caller supplies a captured wire prefix; transport repair must retain its late tool results. */
109
+ declare const preparedRequestSuffix: {
110
+ mark(context: object, toolCallIds: ReadonlySet<string>): void;
111
+ has(context: object): boolean;
112
+ toolCallId(context: object, id: string, normalized: string): string;
113
+ };
70
114
  type AnthropicEffort = "low" | "medium" | "high" | "xhigh" | "max";
71
115
  type AnthropicThinkingDisplay = "summarized" | "omitted";
72
116
  type AnthropicContextManagementOptions = {
@@ -78,6 +122,8 @@ type AnthropicContextManagementOptions = {
78
122
  deny?: string[];
79
123
  };
80
124
  };
125
+ /** Internal owner notification after Anthropic rejects a replayed compaction checkpoint. */
126
+ onCompactionRejected?: (checkpoint: CompactionReplayRejection) => void;
81
127
  };
82
128
  /** Provider options shared by the Anthropic provider and canonical transport. */
83
129
  interface AnthropicOptions extends StreamOptions, AnthropicContextManagementOptions {
@@ -134,7 +180,7 @@ type BaseOpenAIStreamOptions = StreamOptions & {
134
180
  firstEventTimeoutMs?: number;
135
181
  onFirstEventTimeout?: (reason: Error) => void;
136
182
  /** Internal owner notification after a server rejects a persisted compaction checkpoint. */
137
- onCompactionRejected?: (checkpoint: OpenAIResponsesCompactionRejection) => void;
183
+ onCompactionRejected?: (checkpoint: CompactionReplayRejection) => void;
138
184
  openclawCodeModeToolSurface?: boolean;
139
185
  openclawCodeModeAllowedHostedToolTypes?: Set<string>;
140
186
  frequencyPenalty?: number;
@@ -149,4 +195,4 @@ type OpenAICompletionsOptions = BaseOpenAIStreamOptions & {
149
195
  reasoningEffort?: OpenAIReasoningEffort | "off";
150
196
  };
151
197
  //#endregion
152
- export { supportsOpenAITemperature as C, supportsOpenAIReasoningEffort as S, normalizeOpenAIReasoningEffort as _, BaseOpenAIStreamOptions as a, resolveOpenAIReasoningEffortMapping as b, OpenAIResponsesCompactionRejection as c, OpenAIApiReasoningEffort as d, OpenAIReasoningEffort as f, isOpenAIGpt6Model as g, isOpenAIGpt56Model as h, AnthropicThinkingDisplay as i, codeModeToolSurfaceObserver as l, isOpenAIGpt55Model as m, AnthropicEffort as n, CodeModeToolSurfaceObservation as o, isOpenAIGpt54MiniModel as p, AnthropicOptions as r, OpenAICompletionsOptions as s, AnthropicContextManagementOptions as t, reasoningTagTextPolicy as u, resolveOpenAIModelReasoningEfforts as v, resolveOpenAISupportedReasoningEfforts as x, resolveOpenAIReasoningEffortForModel as y };
198
+ export { supportsOpenAITemperature as A, isOpenAIGpt6Model as C, resolveOpenAIReasoningEffortMapping as D, resolveOpenAIReasoningEffortForModel as E, resolveOpenAISupportedReasoningEfforts as O, isOpenAIGpt56Model as S, resolveOpenAIModelReasoningEfforts as T, reconcileOpenAIResponsesToolChoice as _, BaseOpenAIStreamOptions as a, isOpenAIGpt54MiniModel as b, OpenAICompletionsOptions as c, preparedRequestSuffix as d, reasoningTagTextPolicy as f, reconcileOpenAICompletionsToolChoice as g, projectOpenAITools as h, AnthropicThinkingDisplay as i, supportsOpenAIReasoningEffort as k, OpenAIResponsesCompactionRejection as l, OpenAIToolProjection as m, AnthropicEffort as n, CodeModeToolSurfaceObservation as o, OpenAICompletionsToolChoice as p, AnthropicOptions as r, CompactionReplayRejection as s, AnthropicContextManagementOptions as t, codeModeToolSurfaceObserver as u, OpenAIApiReasoningEffort as v, normalizeOpenAIReasoningEffort as w, isOpenAIGpt55Model as x, OpenAIReasoningEffort as y };
@@ -1,8 +1,9 @@
1
- import { r as getAiTransportHost } from "./host-Bf3NjYNj.mjs";
2
- import { s as truncateUtf16Safe } from "./provider-error-CF9GWCs2.mjs";
1
+ import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
2
+ import { r as getAiTransportHost } from "./host-B2gk-d1H.mjs";
3
+ import { s as truncateUtf16Safe } from "./provider-error-qtZD2inE.mjs";
3
4
  import "./internal/retry-after.mjs";
4
- import { N as raceWithTimeout } from "./transport-stream-shared-CWGOuLcA.mjs";
5
- import "./positive-integer-CqWjqSi9.mjs";
5
+ import { A as shortHash, N as raceWithTimeout } from "./transport-stream-shared-CzQlAzJH.mjs";
6
+ import "./positive-integer-Bb4Evc7L.mjs";
6
7
  //#region packages/normalization-core/src/response-bytes.ts
7
8
  async function consumeResponseBytes(options) {
8
9
  let size = 0;
@@ -109,4 +110,26 @@ async function readResponseTextSnippet(response, options) {
109
110
  return truncated ? `${collapsed}…` : collapsed;
110
111
  }
111
112
  //#endregion
112
- export { redactSensitiveText as a, supportsModelTools as c, readResponseTextSnippet as i, consumeResponseBytes as l, estimateStringChars as n, resolveModelHeaderSentinels as o, isCodeModeModelVisibleToolName as r, streamFragmentError as s, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as t };
113
+ //#region packages/ai/src/transports/provider-replay-context.ts
114
+ function isProviderReplayContext(value) {
115
+ return isRecord(value) && typeof value.provider === "string" && typeof value.api === "string" && typeof value.model === "string" && (value.baseUrlHash === void 0 || typeof value.baseUrlHash === "string") && (value.sessionHash === void 0 || typeof value.sessionHash === "string") && (value.authProfileHash === void 0 || typeof value.authProfileHash === "string");
116
+ }
117
+ function hashReplayContextValue(value) {
118
+ const normalized = value?.trim();
119
+ return normalized ? shortHash(normalized) : void 0;
120
+ }
121
+ function buildProviderReplayContext(model, options) {
122
+ return {
123
+ provider: model.provider,
124
+ api: model.api,
125
+ model: model.id,
126
+ baseUrlHash: hashReplayContextValue(model.baseUrl),
127
+ sessionHash: hashReplayContextValue(options?.sessionId),
128
+ authProfileHash: hashReplayContextValue(options?.authProfileId)
129
+ };
130
+ }
131
+ function providerReplayContextMatches(state, context) {
132
+ return state.provider === context.provider && state.api === context.api && state.model === context.model && state.baseUrlHash === context.baseUrlHash && state.sessionHash === context.sessionHash && state.authProfileHash === context.authProfileHash;
133
+ }
134
+ //#endregion
135
+ export { estimateStringChars as a, redactSensitiveText as c, supportsModelTools as d, consumeResponseBytes as f, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as i, resolveModelHeaderSentinels as l, isProviderReplayContext as n, isCodeModeModelVisibleToolName as o, providerReplayContextMatches as r, readResponseTextSnippet as s, buildProviderReplayContext as t, streamFragmentError as u };
@@ -1,11 +1,11 @@
1
- import { r as getAiTransportHost } from "./host-Bf3NjYNj.mjs";
2
- import { n as resolveCloudflareBaseUrl, t as isCloudflareProvider } from "./cloudflare-5qSGvIUH.mjs";
3
- import { Ft as resolveOpenAIClientBaseUrl } from "./openai-responses-shared-afo9-s16.mjs";
1
+ import { r as getAiTransportHost } from "./host-B2gk-d1H.mjs";
2
+ import { n as resolveCloudflareBaseUrl, t as isCloudflareProvider } from "./cloudflare-Dttf8jKq.mjs";
4
3
  import { n as resolveOpencodeSessionHeaders, t as hasOpencodeSessionHeader } from "./session-affinity-DA4WHv1h.mjs";
4
+ import { Ft as resolveOpenAIClientBaseUrl, Lt as withOpenAIErrorResponseHook } from "./openai-responses-shared-Bv_1NtH9.mjs";
5
5
  import { randomUUID } from "node:crypto";
6
6
  import OpenAI from "openai";
7
7
  //#region packages/ai/src/providers/openai-provider-client.ts
8
- function createOpenAIProviderClient(model, apiKey, headers, optionsHeaders) {
8
+ function createOpenAIProviderClient(model, apiKey, headers, optionsHeaders, onResponse) {
9
9
  if (optionsHeaders) Object.assign(headers, optionsHeaders);
10
10
  const defaultHeaders = model.provider === "cloudflare-ai-gateway" ? {
11
11
  ...headers,
@@ -19,7 +19,7 @@ function createOpenAIProviderClient(model, apiKey, headers, optionsHeaders) {
19
19
  dangerouslyAllowBrowser: true,
20
20
  defaultHeaders,
21
21
  maxRetries: 0,
22
- fetch: getAiTransportHost().buildModelFetch(model)
22
+ fetch: withOpenAIErrorResponseHook(getAiTransportHost().buildModelFetch(model) ?? globalThis.fetch, onResponse, model)
23
23
  });
24
24
  }
25
25
  //#endregion
@@ -1,6 +1,6 @@
1
- import { t as index_d_exports } from "./index-BYDvopUB.mjs";
2
- import { a as AssistantMessage, d as Context, dt as ToolResultMessage, k as Model, mt as UserMessage, n as Api, nt as StreamOptions, p as ImageContent, rt as TextContent, s as AssistantMessageEventStreamContract } from "./types-Bd2T86VJ.mjs";
3
- import "./types-Kdfw_04V.mjs";
1
+ import { t as index_d_exports } from "./index-DSprYWaz.mjs";
2
+ import { a as AssistantMessage, d as Context, dt as ToolResultMessage, k as Model, mt as UserMessage, n as Api, nt as StreamOptions, p as ImageContent, rt as TextContent, s as AssistantMessageEventStreamContract } from "./types-CVYzKrMl.mjs";
3
+ import "./types-CBJthzJX.mjs";
4
4
  //#region packages/ai/src/provider-types.d.ts
5
5
  declare const PROVIDER_CONTEXT_HANDOFF: unique symbol;
6
6
  type VideoContent = Omit<ImageContent, "type"> & {
@@ -1,6 +1,6 @@
1
- import { A as supportsClaudeInHistorySystemMessages, C as resolveClaudeOpus55ModelIdentity, D as supportsClaude1MContext, E as resolveClaudeSonnet5ModelIdentity, M as supportsClaudeNativeXhighEffort, O as supportsClaudeAdaptiveThinking, S as resolveClaudeNativeThinkingLevelMap, T as resolveClaudeSonnet55ModelIdentity, _ as requiresClaudeMandatoryAdaptiveThinking, a as normalizeResolvedPricing, b as resolveClaudeModelIdentity, c as CLAUDE_FABLE_5_THINKING_PROFILE, d as CLAUDE_OPUS_5_THINKING_PROFILE, f as CLAUDE_SONNET_55_THINKING_PROFILE, g as requiresClaudeDefaultSampling, h as requiresClaudeBetweenToolsThinking, i as normalizeModelCostConfig, j as supportsClaudeNativeMaxEffort, k as supportsClaudeFastMode, l as CLAUDE_HAIKU_55_THINKING_PROFILE, m as bindsClaudeThinkingPrefix, n as appendTextDeltaToAssistantMessage, o as ProviderRefusalReview, p as CLAUDE_SONNET_5_THINKING_PROFILE, r as calculateUsageCost, s as readProviderRefusalReview, u as CLAUDE_OPUS_55_THINKING_PROFILE, v as resolveClaudeFable5ModelIdentity, w as resolveClaudeOpus5ModelIdentity, x as resolveClaudeMythos5ModelIdentity, y as resolveClaudeHaiku55ModelIdentity } from "./index-BYDvopUB.mjs";
2
- import { $ as StopReason, A as ModelCostConfig, At as extractDiagnosticError, B as ProviderImagesOptions, C as KnownApi, Ct as readRuntimeContextMetadata, D as MaybePromise, Dt as DiagnosticErrorInfo, E as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, Et as AssistantMessageDiagnostic, F as OpenRouterRouting, G as RUNTIME_CONTEXT_CUSTOM_TYPE, H as ProviderResponse, I as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, J as RUNTIME_CONTEXT_HEADER, K as RUNTIME_CONTEXT_END_MARKER, L as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, M as ModelThinkingLevel, Mt as isProviderRefusalAssistantError, N as OpenAICompletionsCompat, Ot as appendAssistantMessageDiagnostic, P as OpenAIResponsesCompat, Q as SimpleStreamOptions, R as PricingTier, S as ImagesStopReason, St as labelRuntimeContextText, T as KnownImagesProvider, Tt as setRuntimeContextRetention, V as ProviderReplayState, W as RUNTIME_CONTEXT_BEGIN_MARKER, X as RawPricingTier, Y as RawModelCostConfig, Z as RuntimeContextMessage, _ as ImagesInputContent, _t as escapeRuntimeContextFooter, a as AssistantMessage, at as ThinkingBudgets, b as ImagesOutputContent, bt as isRuntimeContextMessage, c as AssistantMessageEventStreamLike, ct as ThinkingLevelMap, dt as ToolResultMessage, et as StreamFn, f as DEFAULT_MISSING_TOOL_RESULT_TEXT, ft as Transport, g as ImagesFunction, gt as VercelGatewayRouting, h as ImagesContext, ht as ValidateToolArgumentsFn, i as AssistantImages, it as TextSignatureV1, j as ModelCostRates, jt as formatThrownValue, kt as createAssistantMessageDiagnostic, l as CacheRetention, lt as Tool, m as ImagesApi, mt as UserMessage, n as Api, nt as StreamOptions, o as AssistantMessageEvent, ot as ThinkingContent, p as ImageContent, pt as Usage, q as RUNTIME_CONTEXT_FOOTER, r as AssistantDeliveryTtsFacts, rt as TextContent, s as AssistantMessageEventStreamContract, st as ThinkingLevel, t as AnthropicMessagesCompat, u as CompleteSimpleFn, ut as ToolCall, v as ImagesModel, vt as hasLegacyRuntimeContextEnvelope, w as KnownImagesApi, wt as runtimeContextContentToText, x as ImagesProvider, xt as labelRuntimeContextContent, y as ImagesOptions, yt as hasRuntimeContextMarker, z as Provider } from "./types-Bd2T86VJ.mjs";
3
- import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-BcqWLo_u.mjs";
4
- import { n as validateToolCall, t as validateToolArguments } from "./validation-DdGB1yy3.mjs";
5
- 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-CHtRx0dI.mjs";
6
- 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_HAIKU_55_THINKING_PROFILE, type CLAUDE_OPUS_55_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_55_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DEFAULT_MISSING_TOOL_RESULT_TEXT, 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 ProviderRefusalReview, type ProviderReplayState, type ProviderResponse, ProviderStreamFunction, type ProviderStreamFunction as StreamFunction, ProviderStreamOptions, ProviderUserMessage, type RUNTIME_CONTEXT_BEGIN_MARKER, type RUNTIME_CONTEXT_CUSTOM_TYPE, type RUNTIME_CONTEXT_END_MARKER, type RUNTIME_CONTEXT_FOOTER, type RUNTIME_CONTEXT_HEADER, type RawModelCostConfig, type RawPricingTier, type RuntimeContextMessage, 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 appendTextDeltaToAssistantMessage, type bindsClaudeThinkingPrefix, type calculateUsageCost, type createAssistantMessageDiagnostic, type createAssistantMessageEventStream, type escapeRuntimeContextFooter, type extractDiagnosticError, type formatThrownValue, type hasLegacyRuntimeContextEnvelope, type hasRuntimeContextMarker, type isProviderRefusalAssistantError, type isRuntimeContextMessage, type labelRuntimeContextContent, type labelRuntimeContextText, type normalizeModelCostConfig, type normalizeResolvedPricing, type readProviderRefusalReview, type readRuntimeContextMetadata, type requiresClaudeBetweenToolsThinking, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeHaiku55ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus55ModelIdentity, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet55ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type runtimeContextContentToText, type setRuntimeContextRetention, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeInHistorySystemMessages, type supportsClaudeNativeMaxEffort, type supportsClaudeNativeXhighEffort, type validateToolArguments, type validateToolCall };
1
+ import { A as supportsClaudeInHistorySystemMessages, C as resolveClaudeOpus55ModelIdentity, D as supportsClaude1MContext, E as resolveClaudeSonnet5ModelIdentity, M as supportsClaudeNativeXhighEffort, N as supportsClaudeServerCompaction, O as supportsClaudeAdaptiveThinking, S as resolveClaudeNativeThinkingLevelMap, T as resolveClaudeSonnet55ModelIdentity, _ as requiresClaudeMandatoryAdaptiveThinking, a as normalizeResolvedPricing, b as resolveClaudeModelIdentity, c as CLAUDE_FABLE_5_THINKING_PROFILE, d as CLAUDE_OPUS_5_THINKING_PROFILE, f as CLAUDE_SONNET_55_THINKING_PROFILE, g as requiresClaudeDefaultSampling, h as requiresClaudeBetweenToolsThinking, i as normalizeModelCostConfig, j as supportsClaudeNativeMaxEffort, k as supportsClaudeFastMode, l as CLAUDE_HAIKU_55_THINKING_PROFILE, m as bindsClaudeThinkingPrefix, n as appendTextDeltaToAssistantMessage, o as ProviderRefusalReview, p as CLAUDE_SONNET_5_THINKING_PROFILE, r as calculateUsageCost, s as readProviderRefusalReview, u as CLAUDE_OPUS_55_THINKING_PROFILE, v as resolveClaudeFable5ModelIdentity, w as resolveClaudeOpus5ModelIdentity, x as resolveClaudeMythos5ModelIdentity, y as resolveClaudeHaiku55ModelIdentity } from "./index-DSprYWaz.mjs";
2
+ import { $ as StopReason, A as ModelCostConfig, At as extractDiagnosticError, B as ProviderImagesOptions, C as KnownApi, Ct as readRuntimeContextMetadata, D as MaybePromise, Dt as DiagnosticErrorInfo, E as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, Et as AssistantMessageDiagnostic, F as OpenRouterRouting, G as RUNTIME_CONTEXT_CUSTOM_TYPE, H as ProviderResponse, I as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, J as RUNTIME_CONTEXT_HEADER, K as RUNTIME_CONTEXT_END_MARKER, L as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, M as ModelThinkingLevel, Mt as isProviderRefusalAssistantError, N as OpenAICompletionsCompat, Ot as appendAssistantMessageDiagnostic, P as OpenAIResponsesCompat, Q as SimpleStreamOptions, R as PricingTier, S as ImagesStopReason, St as labelRuntimeContextText, T as KnownImagesProvider, Tt as setRuntimeContextRetention, V as ProviderReplayState, W as RUNTIME_CONTEXT_BEGIN_MARKER, X as RawPricingTier, Y as RawModelCostConfig, Z as RuntimeContextMessage, _ as ImagesInputContent, _t as escapeRuntimeContextFooter, a as AssistantMessage, at as ThinkingBudgets, b as ImagesOutputContent, bt as isRuntimeContextMessage, c as AssistantMessageEventStreamLike, ct as ThinkingLevelMap, dt as ToolResultMessage, et as StreamFn, f as DEFAULT_MISSING_TOOL_RESULT_TEXT, ft as Transport, g as ImagesFunction, gt as VercelGatewayRouting, h as ImagesContext, ht as ValidateToolArgumentsFn, i as AssistantImages, it as TextSignatureV1, j as ModelCostRates, jt as formatThrownValue, kt as createAssistantMessageDiagnostic, l as CacheRetention, lt as Tool, m as ImagesApi, mt as UserMessage, n as Api, nt as StreamOptions, o as AssistantMessageEvent, ot as ThinkingContent, p as ImageContent, pt as Usage, q as RUNTIME_CONTEXT_FOOTER, r as AssistantDeliveryTtsFacts, rt as TextContent, s as AssistantMessageEventStreamContract, st as ThinkingLevel, t as AnthropicMessagesCompat, u as CompleteSimpleFn, ut as ToolCall, v as ImagesModel, vt as hasLegacyRuntimeContextEnvelope, w as KnownImagesApi, wt as runtimeContextContentToText, x as ImagesProvider, xt as labelRuntimeContextContent, y as ImagesOptions, yt as hasRuntimeContextMarker, z as Provider } from "./types-CVYzKrMl.mjs";
3
+ import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-CzpE1g_o.mjs";
4
+ import { n as validateToolCall, t as validateToolArguments } from "./validation-BQ5u20Ru.mjs";
5
+ 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-ODq57rG_.mjs";
6
+ 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_HAIKU_55_THINKING_PROFILE, type CLAUDE_OPUS_55_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_55_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DEFAULT_MISSING_TOOL_RESULT_TEXT, 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 ProviderRefusalReview, type ProviderReplayState, type ProviderResponse, ProviderStreamFunction, type ProviderStreamFunction as StreamFunction, ProviderStreamOptions, ProviderUserMessage, type RUNTIME_CONTEXT_BEGIN_MARKER, type RUNTIME_CONTEXT_CUSTOM_TYPE, type RUNTIME_CONTEXT_END_MARKER, type RUNTIME_CONTEXT_FOOTER, type RUNTIME_CONTEXT_HEADER, type RawModelCostConfig, type RawPricingTier, type RuntimeContextMessage, 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 appendTextDeltaToAssistantMessage, type bindsClaudeThinkingPrefix, type calculateUsageCost, type createAssistantMessageDiagnostic, type createAssistantMessageEventStream, type escapeRuntimeContextFooter, type extractDiagnosticError, type formatThrownValue, type hasLegacyRuntimeContextEnvelope, type hasRuntimeContextMarker, type isProviderRefusalAssistantError, type isRuntimeContextMessage, type labelRuntimeContextContent, type labelRuntimeContextText, type normalizeModelCostConfig, type normalizeResolvedPricing, type readProviderRefusalReview, type readRuntimeContextMetadata, type requiresClaudeBetweenToolsThinking, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeHaiku55ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus55ModelIdentity, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet55ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type runtimeContextContentToText, type setRuntimeContextRetention, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeInHistorySystemMessages, type supportsClaudeNativeMaxEffort, type supportsClaudeNativeXhighEffort, type supportsClaudeServerCompaction, type validateToolArguments, type validateToolCall };
@@ -1,5 +1,5 @@
1
- import { n as ApiRegistry } from "./api-registry-BhXXYdRA.mjs";
2
- import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-DIPMrMFy.mjs";
1
+ import { n as ApiRegistry } from "./api-registry-gDt0faai.mjs";
2
+ import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-DgjD-UL5.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-X2gmsUWv.mjs";
2
- import { n as projectProviderError } from "./provider-error-CF9GWCs2.mjs";
3
- import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-r93BJhjm.mjs";
2
+ import { n as projectProviderError } from "./provider-error-qtZD2inE.mjs";
3
+ import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-DJ_P143P.mjs";
4
4
  import { t as createZeroUsage } from "./usage-CJH5D6Ea.mjs";
5
5
  //#region packages/ai/src/providers/register-builtins.ts
6
6
  /** Source id used for built-in API provider registrations. */
@@ -50,39 +50,39 @@ function createLazyRegistration(api, importModule, select) {
50
50
  };
51
51
  }
52
52
  const registerBuiltIns = [
53
- createLazyRegistration("anthropic-messages", () => import("./anthropic-DIIiiz99.mjs").then((n) => n.t), (module) => ({
53
+ createLazyRegistration("anthropic-messages", () => import("./anthropic-D6spfBri.mjs").then((n) => n.t), (module) => ({
54
54
  stream: module.streamAnthropic,
55
55
  streamSimple: module.streamSimpleAnthropic
56
56
  })),
57
- createLazyRegistration("openai-completions", () => import("./openai-completions-CMN24pza.mjs").then((n) => n.t), (module) => ({
57
+ createLazyRegistration("openai-completions", () => import("./openai-completions-B6sET3oI.mjs").then((n) => n.t), (module) => ({
58
58
  stream: module.streamOpenAICompletions,
59
59
  streamSimple: module.streamSimpleOpenAICompletions
60
60
  })),
61
- createLazyRegistration("mistral-conversations", () => import("./mistral-dCDCR5ur.mjs"), (module) => ({
61
+ createLazyRegistration("mistral-conversations", () => import("./mistral-CATJrwne.mjs"), (module) => ({
62
62
  stream: module.streamMistral,
63
63
  streamSimple: module.streamSimpleMistral
64
64
  })),
65
- createLazyRegistration("openai-responses", () => import("./openai-responses-BMxoJdTC.mjs").then((n) => n.t), (module) => ({
65
+ createLazyRegistration("openai-responses", () => import("./openai-responses-BXsJK-mD.mjs").then((n) => n.t), (module) => ({
66
66
  stream: module.streamOpenAIResponses,
67
67
  streamSimple: module.streamSimpleOpenAIResponses
68
68
  })),
69
- createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-DGQnXRMs.mjs"), (module) => ({
69
+ createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-0TqHwnlD.mjs"), (module) => ({
70
70
  stream: module.streamAzureOpenAIResponses,
71
71
  streamSimple: module.streamSimpleAzureOpenAIResponses
72
72
  })),
73
- createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-D8-q7cgy.mjs"), (module) => ({
73
+ createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-CtdnpWwe.mjs"), (module) => ({
74
74
  stream: module.streamOpenAICodexResponses,
75
75
  streamSimple: module.streamSimpleOpenAICodexResponses
76
76
  })),
77
- createLazyRegistration("google-generative-ai", () => import("./google-BlbTC1Xp.mjs"), (module) => ({
77
+ createLazyRegistration("google-generative-ai", () => import("./google-zWpkDSeN.mjs"), (module) => ({
78
78
  stream: module.streamGoogle,
79
79
  streamSimple: module.streamSimpleGoogle
80
80
  })),
81
- createLazyRegistration("google-interactions", () => import("./google-interactions-zIz70M2e.mjs"), (module) => ({
81
+ createLazyRegistration("google-interactions", () => import("./google-interactions-DVQ7AaSF.mjs"), (module) => ({
82
82
  stream: module.streamGoogleInteractions,
83
83
  streamSimple: module.streamSimpleGoogleInteractions
84
84
  })),
85
- createLazyRegistration("google-vertex", () => import("./google-vertex-XQ7OQtaM.mjs"), (module) => ({
85
+ createLazyRegistration("google-vertex", () => import("./google-vertex-Bkfizj7M.mjs"), (module) => ({
86
86
  stream: module.streamGoogleVertex,
87
87
  streamSimple: module.streamSimpleGoogleVertex
88
88
  }))