@openclaw/ai 2026.10.1-beta.2 → 2026.10.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +6 -0
  2. package/dist/{anthropic-CZv6XFER.mjs → anthropic-BAHKgWam.mjs} +30 -59
  3. package/dist/{anthropic-payload-policy-BhCcgNdm.d.mts → anthropic-payload-policy-DGblkHL5.d.mts} +19 -16
  4. package/dist/{anthropic-stream-reducer-BQ1tjd7x.mjs → anthropic-stream-reducer-g6w1YVii.mjs} +197 -285
  5. package/dist/{api-registry-DpU0Rj-I.d.mts → api-registry-BhXXYdRA.d.mts} +2 -2
  6. package/dist/assistant-message-events-CHMJgbhs.mjs +18 -0
  7. package/dist/{assistant-output-OLm-Oln0.mjs → assistant-output-CUEeSotf.mjs} +2 -2
  8. package/dist/{assistant-text-phase-Bl1aDCB7.mjs → assistant-text-phase-BrV8KdFO.mjs} +7 -6
  9. package/dist/{azure-openai-responses-DH7bd3QT.mjs → azure-openai-responses-C7qBuR23.mjs} +8 -9
  10. package/dist/{credential-redaction-BKv49aiv.d.mts → credential-redaction-BHxruEH6.d.mts} +3 -1
  11. package/dist/{diagnostics-Caj-4RBA.mjs → diagnostics-tQasYct1.mjs} +10 -3
  12. package/dist/diagnostics.d.mts +7 -7
  13. package/dist/diagnostics.mjs +3 -3
  14. package/dist/{env-api-keys-CyX4VKGO.mjs → env-api-keys-CrxwdylR.mjs} +24 -35
  15. package/dist/event-stream-6UNs-AhN.d.mts +1 -0
  16. package/dist/{event-stream-DrRM_90c.d.mts → event-stream-BcqWLo_u.d.mts} +1 -1
  17. package/dist/{event-stream-C5AbCAaZ.mjs → event-stream-X2gmsUWv.mjs} +5 -8
  18. package/dist/event-stream.d.mts +2 -2
  19. package/dist/event-stream.mjs +1 -1
  20. package/dist/google-Boz2QcpK.mjs +20 -0
  21. package/dist/{google-interactions-wrnE6MLw.mjs → google-interactions-tjAb1mc5.mjs} +52 -84
  22. package/dist/{google-messages-BwPPycw6.mjs → google-messages-C-RZzloH.mjs} +25 -35
  23. package/dist/google-provider-stream-CMImyxbX.mjs +58 -0
  24. package/dist/{google-shared-Eql1OMPU.mjs → google-shared-OyAtMTZv.mjs} +6 -15
  25. package/dist/google-vertex-hCxTJea7.mjs +40 -0
  26. package/dist/{host-BinBeGcQ.d.mts → host-CTDz7LXD.d.mts} +6 -3
  27. package/dist/{host-DCW52iHe.mjs → host-JWXZWa-c.mjs} +12 -8
  28. package/dist/{host-policy-B3jc4Rpn.mjs → host-policy-q4Azym9F.mjs} +1 -1
  29. package/dist/{index-a8e_oKnu.d.mts → index-BYDvopUB.d.mts} +27 -6
  30. package/dist/index.d.mts +7 -7
  31. package/dist/index.mjs +7 -6
  32. package/dist/internal/anthropic.d.mts +6 -6
  33. package/dist/internal/anthropic.mjs +5 -5
  34. package/dist/internal/openai-completions-compat.d.mts +1 -1
  35. package/dist/internal/openai-completions-compat.mjs +1 -1
  36. package/dist/internal/openai-responses-payload-policy.d.mts +8 -1
  37. package/dist/internal/openai-responses-payload-policy.mjs +3 -3
  38. package/dist/internal/openai.d.mts +9 -9
  39. package/dist/internal/openai.mjs +9 -11
  40. package/dist/internal/runtime.d.mts +14 -11
  41. package/dist/internal/runtime.mjs +10 -13
  42. package/dist/internal/shared.d.mts +5 -5
  43. package/dist/internal/shared.mjs +6 -7
  44. package/dist/internal/tool-schema.mjs +2 -2
  45. package/dist/{llm-request-activity-D8f_oxHj.mjs → llm-request-activity-CfMuh5cC.mjs} +2 -2
  46. package/dist/{mistral-DSt4vQAO.mjs → mistral-DUveP4hF.mjs} +71 -146
  47. package/dist/{model-transport-url-C5f59L3Y.d.mts → model-transport-url-BrsjjdjR.d.mts} +5 -1
  48. package/dist/{number-coercion-V8-BhME4.mjs → number-coercion-C3hztWoY.mjs} +5 -4
  49. package/dist/{openai-chatgpt-responses-BC2x0Oqx.mjs → openai-chatgpt-responses-OCwckGhY.mjs} +173 -242
  50. package/dist/{openai-completions-DNyHnXKg.mjs → openai-completions-DOltBUe9.mjs} +7 -6
  51. package/dist/{openai-completions-compat-BYdYpXhU.d.mts → openai-completions-compat-i-nLZxFy.d.mts} +10 -11
  52. package/dist/{openai-completions-compat-BdmlhD4u.mjs → openai-completions-compat-pg1q4uNG.mjs} +10 -6
  53. package/dist/openai-completions-transport-OMrn7gnZ.mjs +3319 -0
  54. package/dist/{openai-prompt-cache-I8YQTzf8.mjs → openai-prompt-cache-Cr2xKVrS.mjs} +1 -1
  55. package/dist/{openai-prompt-cache-45-AH_xv.d.mts → openai-prompt-cache-DIPMrMFy.d.mts} +2 -2
  56. package/dist/{openai-responses-uZ5oWSp7.mjs → openai-responses-BSBJUA19.mjs} +9 -10
  57. package/dist/{openai-responses-compaction-replay-BClApUIf.d.mts → openai-responses-compaction-replay-B2FE4Nw8.d.mts} +4 -4
  58. package/dist/{openai-responses-contracts-Br5IIw_h.d.mts → openai-responses-contracts-DKqMJ1Ct.d.mts} +9 -4
  59. package/dist/{openai-responses-contracts-BKu8O7l4.mjs → openai-responses-contracts-DlKMMTxK.mjs} +26 -6
  60. package/dist/{openai-responses-compaction-window-m878aVpU.mjs → openai-responses-endpoint-CinGh4VZ.mjs} +14 -4
  61. package/dist/{openai-responses-prompt-observer-internal-CCg7B6l4.mjs → openai-responses-request-lifecycle-D2IFiI0-.mjs} +39 -4
  62. package/dist/{openai-responses-shared-C7oVyjED.mjs → openai-responses-shared-DVGhq5xF.mjs} +1036 -327
  63. package/dist/{openai-responses-terminal-usage-DgImcyJu.d.mts → openai-responses-terminal-usage-BygjiAdi.d.mts} +2 -2
  64. package/dist/{openai-tool-schema-DYNePiF8.mjs → openai-tool-schema-DDPXsvJP.mjs} +236 -399
  65. package/dist/{positive-integer-CwLi8LUL.mjs → positive-integer-CqWjqSi9.mjs} +1 -1
  66. package/dist/{provider-error-DQBE1bUQ.mjs → provider-error-CF9GWCs2.mjs} +5 -3
  67. package/dist/{provider-options-D5ABCV_l.d.mts → provider-options-CVrXZBtA.d.mts} +3 -2
  68. package/dist/{provider-transport-turn-state-_M2kLdUE.mjs → provider-transport-turn-state-LuCaTsSO.mjs} +2 -2
  69. package/dist/{provider-types-F8Mqc9Ma.d.mts → provider-types-CHtRx0dI.d.mts} +3 -3
  70. package/dist/provider-types.d.mts +6 -6
  71. package/dist/providers.d.mts +2 -2
  72. package/dist/providers.mjs +12 -12
  73. package/dist/{reasoning-tag-text-partitioner-Ju9VpUGl.mjs → reasoning-tag-text-partitioner-0-Rsezog.mjs} +13 -12
  74. package/dist/{required-api-key-D4kn3252.mjs → required-api-key-CFJvcFy_.mjs} +1 -1
  75. package/dist/{simple-options-BkKTXxhp.mjs → simple-options-BARFAzk9.mjs} +9 -11
  76. package/dist/{src-B0NIt2UK.mjs → src-C_wfIUmV.mjs} +35 -10
  77. package/dist/{stream-DSdzKsDK.mjs → stream-DwrETW0_.mjs} +12 -21
  78. package/dist/{stream-first-event-timeout-D9ZmL_s9.mjs → stream-first-event-timeout-Dc42hKv6.mjs} +8 -21
  79. package/dist/{streaming-byte-guard-CC-HMn_u.mjs → streaming-byte-guard-DBXr1XYn.mjs} +16 -1
  80. package/dist/{string-normalization-PN10hf6d.mjs → string-normalization-I3ux50s9.mjs} +1 -1
  81. package/dist/{text-signature-MLwfi6fq.mjs → text-signature-B_MB6U_9.mjs} +32 -5
  82. package/dist/{tool-schema-json-projection-Ct8SeBeJ.mjs → tool-schema-json-projection-B8sG1I9v.mjs} +29 -23
  83. package/dist/{transport-stream-shared-BcAKh2XH.d.mts → transport-stream-shared-BmpzDtdQ.d.mts} +4 -4
  84. package/dist/{transport-stream-shared-CxXXz_Dd.mjs → transport-stream-shared-DH08b7Il.mjs} +31 -20
  85. package/dist/transports.d.mts +33 -22
  86. package/dist/transports.mjs +73 -1234
  87. package/dist/{types-DvzmWW8J.d.mts → types-Bd2T86VJ.d.mts} +5 -23
  88. package/dist/types-Kdfw_04V.d.mts +1 -0
  89. package/dist/types.d.mts +6 -6
  90. package/dist/types.mjs +5 -4
  91. package/dist/{validation-B3lQt_VE.d.mts → validation-DdGB1yy3.d.mts} +1 -1
  92. package/dist/{validation-DbqlIfDn.mjs → validation-opC2pjk9.mjs} +2 -3
  93. package/dist/validation.d.mts +1 -1
  94. package/dist/validation.mjs +1 -1
  95. package/package.json +4 -4
  96. package/dist/event-stream-DqDQWqiy.d.mts +0 -1
  97. package/dist/google-1WLOtb8w.mjs +0 -54
  98. package/dist/google-vertex-0LrlRoO3.mjs +0 -88
  99. package/dist/openai-completions-transport-DWM2mQDB.mjs +0 -2081
  100. package/dist/openai-responses-request-lifecycle-Fsag-IGZ.mjs +0 -36
  101. package/dist/openai-transport-params-JFsnIyto.mjs +0 -735
  102. package/dist/openai-web-search-tools-Cfu0uLyN.mjs +0 -14
  103. package/dist/provider-replay-context-C7Bmi84a.mjs +0 -25
  104. package/dist/types-BuiEBM3u.d.mts +0 -1
@@ -1,8 +1,9 @@
1
- import { r as getAiTransportHost } from "./host-DCW52iHe.mjs";
2
- import { o as truncateUtf16Safe } from "./provider-error-DQBE1bUQ.mjs";
1
+ import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
2
+ import { r as getAiTransportHost } from "./host-JWXZWa-c.mjs";
3
+ import { s as truncateUtf16Safe } from "./provider-error-CF9GWCs2.mjs";
3
4
  import "./internal/retry-after.mjs";
4
- import { N as raceWithTimeout } from "./transport-stream-shared-CxXXz_Dd.mjs";
5
- import "./positive-integer-CwLi8LUL.mjs";
5
+ import { A as shortHash, N as raceWithTimeout } from "./transport-stream-shared-DH08b7Il.mjs";
6
+ import "./positive-integer-CqWjqSi9.mjs";
6
7
  //#region packages/normalization-core/src/response-bytes.ts
7
8
  async function consumeResponseBytes(options) {
8
9
  let size = 0;
@@ -31,6 +32,10 @@ async function consumeResponseBytes(options) {
31
32
  const MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE = "OpenClaw transport error: malformed_streaming_fragment";
32
33
  const NON_LATIN_RE = /[\u2E80-\u9FFF\uA000-\uA4FF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFF60\uFFE0-\uFFE6\u{20000}-\u{2FA1F}]/gu;
33
34
  const CJK_SURROGATE_HIGH_RE = /[\uD840-\uD87E][\uDC00-\uDFFF]/g;
35
+ /** Keep provider payloads out of parse errors without replacing unrelated failures. */
36
+ function streamFragmentError(cause, ErrorType = Error) {
37
+ return cause instanceof SyntaxError ? new ErrorType(MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, { cause }) : cause;
38
+ }
34
39
  function redactSensitiveText(text) {
35
40
  return getAiTransportHost().redactToolPayloadText(text);
36
41
  }
@@ -105,6 +110,28 @@ async function readResponseTextSnippet(response, options) {
105
110
  return truncated ? `${collapsed}…` : collapsed;
106
111
  }
107
112
  //#endregion
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
108
135
  //#region packages/ai/src/utils/text-signature.ts
109
136
  function encodeTextSignatureV1(id, phase) {
110
137
  return JSON.stringify({
@@ -114,4 +141,4 @@ function encodeTextSignatureV1(id, phase) {
114
141
  });
115
142
  }
116
143
  //#endregion
117
- export { readResponseTextSnippet as a, supportsModelTools as c, isCodeModeModelVisibleToolName as i, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as n, redactSensitiveText as o, estimateStringChars as r, resolveModelHeaderSentinels as s, encodeTextSignatureV1 as t };
144
+ export { MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as a, readResponseTextSnippet as c, streamFragmentError as d, supportsModelTools as f, providerReplayContextMatches as i, redactSensitiveText as l, buildProviderReplayContext as n, estimateStringChars as o, consumeResponseBytes as p, isProviderReplayContext as r, isCodeModeModelVisibleToolName as s, encodeTextSignatureV1 as t, resolveModelHeaderSentinels as u };
@@ -1,4 +1,4 @@
1
- import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
1
+ import { a as asRecord, o as isRecord } from "./record-coerce-CNDovvft.mjs";
2
2
  import { t as expectDefined } from "./expect-lbe3Hgrh.mjs";
3
3
  import { types } from "node:util";
4
4
  //#region packages/ai/src/providers/schema-walk.ts
@@ -33,6 +33,22 @@ const SCHEMA_ARRAY_KEYS = /* @__PURE__ */ new Set([
33
33
  "oneOf",
34
34
  "prefixItems"
35
35
  ]);
36
+ const SCHEMA_NESTED_KEYS = new Set([...SCHEMA_OBJECT_KEYS, ...SCHEMA_ARRAY_KEYS].toSorted());
37
+ function* walkSchemaArray(schemas, visit, result = []) {
38
+ result.length = schemas.length;
39
+ for (let index = 0; index < result.length; index += 1) if (index in schemas) result[index] = yield visit(schemas[index]);
40
+ return result;
41
+ }
42
+ function* walkSchemaValue(schema, ancestors, visitObject) {
43
+ if (!schema || typeof schema !== "object") return schema;
44
+ if (ancestors.has(schema)) throw new TypeError("Tool schema contains a circular reference.");
45
+ ancestors.add(schema);
46
+ try {
47
+ return yield Array.isArray(schema) ? walkSchemaArray(schema, (entry) => walkSchemaValue(entry, ancestors, visitObject)) : visitObject(asRecord(schema));
48
+ } finally {
49
+ ancestors.delete(schema);
50
+ }
51
+ }
36
52
  /** Resume child schema walks on a heap stack, never through recursive yield delegation. */
37
53
  function evaluateSchemaWalk(walk) {
38
54
  const parents = [];
@@ -64,7 +80,7 @@ function isNonFiniteNumberValue(value) {
64
80
  if (value === null || typeof value !== "object" || !types.isNumberObject(value)) return false;
65
81
  return !Number.isFinite(Number.prototype.valueOf.call(value));
66
82
  }
67
- function serializeToolInputSchema(value, path, captureJson) {
83
+ function projectToolInputSchema(value, path, captureJson) {
68
84
  const nonFiniteNumber = { path: null };
69
85
  const ancestors = [];
70
86
  const pathLengths = [];
@@ -102,9 +118,16 @@ function serializeToolInputSchema(value, path, captureJson) {
102
118
  };
103
119
  const schema = JSON.parse(text);
104
120
  captureJson?.(text);
121
+ const violations = [];
122
+ if (!isRecord(schema)) violations.push(`${path} must be a JSON object schema`);
123
+ else if (schema.type !== void 0 && schema.type !== "object") violations.push(`${path}.type must be "object"`);
124
+ if (!inspectJsonSchema(schema, [path], violations)) return {
125
+ schema: {},
126
+ violations: [`${path} is not a JSON value`]
127
+ };
105
128
  return {
106
129
  schema,
107
- violations: []
130
+ violations
108
131
  };
109
132
  }
110
133
  function inspectJsonSchema(schema, path, violations) {
@@ -120,14 +143,11 @@ function inspectJsonSchema(schema, path, violations) {
120
143
  }
121
144
  if (!isRecord(schema)) return typeof schema !== "number" || Number.isFinite(schema);
122
145
  for (const key of ["$dynamicRef", "$dynamicAnchor"]) if (key in schema) violations.push(`${path.join("")}.${key}`);
123
- for (const key of Object.keys(schema)) {
124
- const value = schema[key];
146
+ for (const [key, value] of Object.entries(schema)) {
125
147
  if (typeof value === "number" && !Number.isFinite(value)) return false;
126
148
  if (!value || typeof value !== "object") continue;
127
149
  path.push(".", key);
128
- if (SCHEMA_MAP_KEYS.has(key) && isRecord(value)) for (const schemaName of Object.keys(value)) {
129
- const childSchema = value[schemaName];
130
- if (childSchema === void 0) return false;
150
+ if (SCHEMA_MAP_KEYS.has(key) && isRecord(value)) for (const [schemaName, childSchema] of Object.entries(value)) {
131
151
  path.push(".", schemaName);
132
152
  const valid = inspectJsonSchema(childSchema, path, violations);
133
153
  path.length -= 2;
@@ -156,19 +176,5 @@ function prepareRuntimeToolInputSchema(schema, path) {
156
176
  } } : {}
157
177
  };
158
178
  }
159
- function projectToolInputSchema(schema, path, captureJson) {
160
- const projection = serializeToolInputSchema(schema, path, captureJson);
161
- const violations = [...projection.violations];
162
- if (!isRecord(projection.schema)) violations.push(`${path} must be a JSON object schema`);
163
- else if (projection.schema.type !== void 0 && projection.schema.type !== "object") violations.push(`${path}.type must be "object"`);
164
- if (!inspectJsonSchema(projection.schema, [path], violations)) return {
165
- schema: {},
166
- violations: [`${path} is not a JSON value`]
167
- };
168
- return {
169
- schema: projection.schema,
170
- violations
171
- };
172
- }
173
179
  //#endregion
174
- export { SCHEMA_OBJECT_KEYS as a, SCHEMA_MAP_KEYS as i, projectRuntimeToolInputSchema as n, evaluateSchemaWalk as o, SCHEMA_ARRAY_KEYS as r, prepareRuntimeToolInputSchema as t };
180
+ export { SCHEMA_NESTED_KEYS as a, walkSchemaArray as c, SCHEMA_MAP_KEYS as i, walkSchemaValue as l, projectRuntimeToolInputSchema as n, SCHEMA_OBJECT_KEYS as o, SCHEMA_ARRAY_KEYS as r, evaluateSchemaWalk as s, prepareRuntimeToolInputSchema as t };
@@ -1,7 +1,7 @@
1
- import "./index-a8e_oKnu.mjs";
2
- import { H as ProviderResponse, a as AssistantMessage, k as Model, nt as StreamOptions, pt as Usage } from "./types-DvzmWW8J.mjs";
3
- import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-DrRM_90c.mjs";
4
- import "./event-stream-DqDQWqiy.mjs";
1
+ import "./index-BYDvopUB.mjs";
2
+ import { H as ProviderResponse, a as AssistantMessage, k as Model, nt as StreamOptions, pt as Usage } from "./types-Bd2T86VJ.mjs";
3
+ import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-BcqWLo_u.mjs";
4
+ import "./event-stream-6UNs-AhN.mjs";
5
5
  import { t as ProviderErrorProjection } from "./provider-error-xumb1V3F.mjs";
6
6
  //#region packages/ai/src/transports/transport-stream-shared.d.ts
7
7
  type TransportUsage = Pick<Usage, "input" | "output" | "cacheRead" | "cacheWrite" | "contextUsage" | "totalTokens"> & {
@@ -1,9 +1,9 @@
1
1
  import { n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
2
- import { a as createAssistantMessageEventStream } from "./event-stream-C5AbCAaZ.mjs";
2
+ import { a as createAssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
3
3
  import { i as asOptionalRecord, n as asNullableRecord, t as asNonArrayRecord } from "./record-coerce-CNDovvft.mjs";
4
- import { E as headersToRecord, r as getAiTransportHost } from "./host-DCW52iHe.mjs";
5
- import { i as projectDiagnosticValue, n as projectProviderError } from "./provider-error-DQBE1bUQ.mjs";
6
- import { c as isTransientNetworkError } from "./diagnostics-Caj-4RBA.mjs";
4
+ import { E as headersToRecord, r as getAiTransportHost } from "./host-JWXZWa-c.mjs";
5
+ import { a as projectDiagnosticValue, n as projectProviderError } from "./provider-error-CF9GWCs2.mjs";
6
+ import { l as isTransientNetworkError } from "./diagnostics-tQasYct1.mjs";
7
7
  import { t as createZeroUsage } from "./usage-CJH5D6Ea.mjs";
8
8
  import { parse } from "partial-json";
9
9
  //#region packages/ai/src/utils/sanitize-unicode.ts
@@ -47,20 +47,39 @@ function racePromiseWithAbortSignal(operation, signal, createError = (abortedSig
47
47
  /** Bounds observation without cancelling work; a factory starts only after the timer is armed. */
48
48
  async function raceWithTimeout(operation, timeoutMs, onTimeout, options = {}) {
49
49
  let timer;
50
+ let onAbort;
50
51
  try {
51
52
  const deadline = new Promise((resolve, reject) => {
52
- timer = setTimeout(() => {
53
+ const settle = (result) => {
53
54
  try {
54
- resolve(onTimeout());
55
+ resolve(result());
55
56
  } catch (error) {
56
57
  reject(error);
57
58
  }
58
- }, timeoutMs);
59
+ };
60
+ timer = setTimeout(() => settle(onTimeout), timeoutMs);
59
61
  if (options.ref === false) timer.unref?.();
62
+ const signal = options.signal;
63
+ if (signal) {
64
+ onAbort = () => settle(() => {
65
+ if (options.onAbort) return options.onAbort(signal);
66
+ throw createAbortError("Operation aborted", { cause: signal.reason });
67
+ });
68
+ signal.addEventListener("abort", onAbort, { once: true });
69
+ if (signal.aborted) onAbort();
70
+ }
60
71
  });
61
- return await Promise.race([typeof operation === "function" ? operation() : operation, deadline]);
72
+ let source;
73
+ try {
74
+ source = typeof operation === "function" ? operation() : operation;
75
+ } catch (error) {
76
+ deadline.catch(() => {});
77
+ throw error;
78
+ }
79
+ return await Promise.race([source, deadline]);
62
80
  } finally {
63
81
  clearTimeout(timer);
82
+ if (onAbort) options.signal?.removeEventListener("abort", onAbort);
64
83
  }
65
84
  }
66
85
  const DEFAULT_RETRY_CONFIG = {
@@ -189,7 +208,7 @@ function shortHash(str) {
189
208
  }
190
209
  //#endregion
191
210
  //#region packages/ai/src/utils/json-parse.ts
192
- const VALID_JSON_ESCAPES = /* @__PURE__ */ new Set([
211
+ const SIMPLE_JSON_ESCAPES = /* @__PURE__ */ new Set([
193
212
  "\"",
194
213
  "\\",
195
214
  "/",
@@ -197,8 +216,7 @@ const VALID_JSON_ESCAPES = /* @__PURE__ */ new Set([
197
216
  "f",
198
217
  "n",
199
218
  "r",
200
- "t",
201
- "u"
219
+ "t"
202
220
  ]);
203
221
  const JSON_CONTROL_ESCAPES = /* @__PURE__ */ new Set([
204
222
  "b",
@@ -207,10 +225,6 @@ const JSON_CONTROL_ESCAPES = /* @__PURE__ */ new Set([
207
225
  "r",
208
226
  "t"
209
227
  ]);
210
- function isControlCharacter(char) {
211
- const codePoint = char.codePointAt(0);
212
- return codePoint !== void 0 && codePoint >= 0 && codePoint <= 31;
213
- }
214
228
  /**
215
229
  * Repairs malformed JSON string literals by:
216
230
  * - escaping raw control characters inside strings
@@ -257,9 +271,6 @@ function repairJson(json, options) {
257
271
  index += 5;
258
272
  continue;
259
273
  }
260
- repaired += "\\\\";
261
- stringValuePrefix += "\\";
262
- continue;
263
274
  }
264
275
  if (!preserveValidControlEscapes && JSON_CONTROL_ESCAPES.has(nextChar)) {
265
276
  stringValuePrefix = stringValuePrefix.slice(-160);
@@ -269,7 +280,7 @@ function repairJson(json, options) {
269
280
  continue;
270
281
  }
271
282
  }
272
- if (VALID_JSON_ESCAPES.has(nextChar)) {
283
+ if (SIMPLE_JSON_ESCAPES.has(nextChar)) {
273
284
  repaired += `\\${nextChar}`;
274
285
  stringValuePrefix += nextChar === "\\" ? "\\" : `\\${nextChar}`;
275
286
  index += 1;
@@ -279,7 +290,7 @@ function repairJson(json, options) {
279
290
  stringValuePrefix += "\\";
280
291
  continue;
281
292
  }
282
- repaired += isControlCharacter(char) ? JSON.stringify(char).slice(1, -1) : char;
293
+ repaired += char.charCodeAt(0) <= 31 ? JSON.stringify(char).slice(1, -1) : char;
283
294
  stringValuePrefix += char;
284
295
  }
285
296
  return repaired;
@@ -1,20 +1,20 @@
1
- import "./index-a8e_oKnu.mjs";
2
- import { $ as StopReason, N as OpenAICompletionsCompat, Nt as ModelDataThinkingFormat, V as ProviderReplayState, a as AssistantMessage, d as Context, et as StreamFn, k as Model, l as CacheRetention, lt as Tool, n as Api, nt as StreamOptions, ot as ThinkingContent, pt as Usage, rt as TextContent, ut as ToolCall } from "./types-DvzmWW8J.mjs";
3
- import { n as ApiRegistry } from "./api-registry-DpU0Rj-I.mjs";
4
- import { o as AiProviderStreamHookContext } from "./host-BinBeGcQ.mjs";
5
- import { a as BaseOpenAIStreamOptions, c as OpenAIResponsesCompactionRejection, o as CodeModeToolSurfaceObservation, s as OpenAICompletionsOptions } from "./provider-options-D5ABCV_l.mjs";
1
+ import "./index-BYDvopUB.mjs";
2
+ import { $ as StopReason, N as OpenAICompletionsCompat, Nt as ModelDataThinkingFormat, Q as SimpleStreamOptions, V as ProviderReplayState, a as AssistantMessage, d as Context, et as StreamFn, gt as VercelGatewayRouting, k as Model, l as CacheRetention, lt as Tool, n as Api, nt as StreamOptions, ot as ThinkingContent, pt as Usage, rt as TextContent, ut as ToolCall } from "./types-Bd2T86VJ.mjs";
3
+ import { n as ApiRegistry } from "./api-registry-BhXXYdRA.mjs";
4
+ import { o as AiProviderStreamHookContext } from "./host-CTDz7LXD.mjs";
5
+ import { a as BaseOpenAIStreamOptions, c as OpenAIResponsesCompactionRejection, o as CodeModeToolSurfaceObservation, s as OpenAICompletionsOptions } from "./provider-options-CVrXZBtA.mjs";
6
6
  import { n as OpenAIToolProjection } from "./openai-tool-projection-793cE3QX.mjs";
7
- import "./types-BuiEBM3u.mjs";
8
- import { a as buildAnthropicSystemBlocks, c as logAnthropicContextEdits, d as resolveAnthropicPayloadPolicy, f as resolveAnthropicRequestBetaHeader, i as applyAnthropicRequestCacheControl, l as resolveAnthropicCacheOptions, m as supportsAnthropicServerSideFallback, n as applyAnthropicEphemeralCacheControlMarkers, o as isAnthropicServerToolClearingEnabled, p as resolveAnthropicServerCompactionPlan, r as applyAnthropicPayloadPolicyToParams, s as isDirectAnthropicModel, t as applyAnthropicContextManagementToRequest, u as resolveAnthropicEphemeralCacheControl } from "./anthropic-payload-policy-BhCcgNdm.mjs";
9
- import { a as resolveOpenAICompletionsCompat, i as isOpenAICodexResponsesModel, n as detectOpenAICompletionsCompat, o as resolveOpenAIPromptCacheKeySupport, r as isNativeOpenAIEndpoint, s as usesNativeOpenAICodexResponsesBackend, t as ResolvedOpenAICompletionsCompat } from "./openai-completions-compat-BYdYpXhU.mjs";
10
- import { l as OpenAIResponsesCompactionOutput, n as OpenAIResponsesOptions, r as OpenAIResponsesReasoningReplayMetadata } from "./openai-responses-contracts-Br5IIw_h.mjs";
7
+ import "./types-Kdfw_04V.mjs";
8
+ import { a as buildAnthropicSystemBlocks, c as logAnthropicContextEdits, d as resolveAnthropicPayloadPolicy, f as resolveAnthropicRequestBetaHeader, i as applyAnthropicRequestCacheControl, l as resolveAnthropicCacheOptions, m as supportsAnthropicServerSideFallback, n as applyAnthropicEphemeralCacheControlMarkers, o as isAnthropicServerToolClearingEnabled, p as resolveAnthropicServerCompactionPlan, r as applyAnthropicPayloadPolicyToParams, s as isDirectAnthropicModel, t as applyAnthropicContextManagementToRequest, u as resolveAnthropicEphemeralCacheControl } from "./anthropic-payload-policy-DGblkHL5.mjs";
9
+ import { a as resolveOpenAICompletionsCompat, i as isOpenAICodexResponsesModel, n as detectOpenAICompletionsCompat, o as resolveOpenAIPromptCacheKeySupport, r as isNativeOpenAIEndpoint, s as usesNativeOpenAICodexResponsesBackend, t as ResolvedOpenAICompletionsCompat } from "./openai-completions-compat-i-nLZxFy.mjs";
10
+ import { l as OpenAIResponsesCompactionOutput, n as OpenAIResponsesOptions, r as OpenAIResponsesReasoningReplayMetadata } from "./openai-responses-contracts-DKqMJ1Ct.mjs";
11
11
  import { i as resolveOpenAIResponsesServerCompactionPlan, n as resolveOpenAIResponsesCompactEndpointPlan, r as resolveOpenAIResponsesPayloadPolicy, t as applyOpenAIResponsesPayloadPolicy } from "./openai-responses-payload-policy-C7GsA1y0.mjs";
12
- import { n as captureOpenAIResponsesCompaction, t as CompactionReplayRefreshRequiredError } from "./openai-responses-compaction-replay-BClApUIf.mjs";
13
- import { C as withProviderAcceptanceObserver, S as transportAbortError, _ as notifyProviderStreamOpened, a as coerceTransportToolCallArguments, b as sanitizeTransportPayloadText, c as createModelStreamCooperativeScheduler, d as finalizeTerminalToolCallArguments, f as finalizeTransportStream, g as notifyProviderHttpResponse, h as notifyProviderHttpMetadata, i as assignTransportErrorDetails, l as createWritableTransportEventStream, m as mergeTransportHeaders, n as ProviderAcceptance, o as copyProviderAcceptanceObserver, p as iterateModelStream, r as WritableTransportStream, s as createEmptyTransportUsage, t as IncompleteToolCallError, u as failTransportStream, v as parseTerminalToolCallArguments, w as withProviderResponseHook, x as throwIfModelStreamAborted, y as sanitizeNonEmptyTransportPayloadText } from "./transport-stream-shared-BcAKh2XH.mjs";
12
+ import { n as captureOpenAIResponsesCompaction, t as CompactionReplayRefreshRequiredError } from "./openai-responses-compaction-replay-B2FE4Nw8.mjs";
13
+ import { C as withProviderAcceptanceObserver, S as transportAbortError, _ as notifyProviderStreamOpened, a as coerceTransportToolCallArguments, b as sanitizeTransportPayloadText, c as createModelStreamCooperativeScheduler, d as finalizeTerminalToolCallArguments, f as finalizeTransportStream, g as notifyProviderHttpResponse, h as notifyProviderHttpMetadata, i as assignTransportErrorDetails, l as createWritableTransportEventStream, m as mergeTransportHeaders, n as ProviderAcceptance, o as copyProviderAcceptanceObserver, p as iterateModelStream, r as WritableTransportStream, s as createEmptyTransportUsage, t as IncompleteToolCallError, u as failTransportStream, v as parseTerminalToolCallArguments, w as withProviderResponseHook, x as throwIfModelStreamAborted, y as sanitizeNonEmptyTransportPayloadText } from "./transport-stream-shared-BmpzDtdQ.mjs";
14
14
  import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-Cwcjv_fx.mjs";
15
15
  import { r as normalizeOpenAIStrictToolParameters } from "./openai-tool-schema-a5ysBBga.mjs";
16
- import { d as VideoContent, i as ProviderContext, s as ProviderModel } from "./provider-types-F8Mqc9Ma.mjs";
17
- import { a as resolveModelSseDebugMode, i as resolveModelPayloadDebugMode, n as formatModelTransportDebugUrl, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./model-transport-url-C5f59L3Y.mjs";
16
+ import { d as VideoContent, i as ProviderContext, s as ProviderModel } from "./provider-types-CHtRx0dI.mjs";
17
+ import { a as resolveModelPayloadDebugMode, i as emitModelTransportError, n as formatModelTransportDebugUrl, o as resolveModelSseDebugMode, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./model-transport-url-BrsjjdjR.mjs";
18
18
  import OpenAI from "openai";
19
19
  import { Part } from "@google/genai";
20
20
  import { ChatCompletionChunk } from "openai/resources/chat/completions.js";
@@ -24,15 +24,25 @@ export declare function resolveAnthropicMessagesUrl(baseUrl?: string): string;
24
24
  /** Create the stream function used by Anthropic Messages transport models. */
25
25
  export declare function createAnthropicMessagesTransportStreamFn(): StreamFn;
26
26
  //#endregion
27
+ //#region packages/ai/src/transports/anthropic-transport-options.d.ts
28
+ /**
29
+ * Largest completion a request may ask for once transport thinking options
30
+ * apply, for callers that size the prompt before dispatch. Claude transports
31
+ * (Anthropic Messages, Vertex, Bedrock, Bedrock Mantle) may add a thinking
32
+ * budget to `maxTokens`, capped at the model's output limit; some add it even
33
+ * for adaptive models, and their Claude detection is plugin-owned, so every
34
+ * request on these APIs reserves the default budget for its level. Other
35
+ * transports keep `maxTokens` as the total output limit. Over-reserving only
36
+ * shrinks the prompt; it never overflows the window.
37
+ */
38
+ export declare function resolveCompletionTokenReservation(model: Model, maxTokens: number, reasoning: SimpleStreamOptions["reasoning"]): number;
39
+ //#endregion
27
40
  //#region packages/ai/src/transports/deepseek-text-filter.d.ts
28
- interface DeepSeekTextFilter {
29
- /** Push one streamed text chunk and receive any safe visible text segments. */
41
+ /** Create an incremental text filter that strips DeepSeek DSML tool blocks. */
42
+ export declare function createDeepSeekTextFilter(): {
30
43
  push(chunk: string): string[];
31
- /** Flush buffered text at stream end, dropping any unterminated DSML block. */
32
44
  flush(): string[];
33
- }
34
- /** Create an incremental text filter that strips DeepSeek DSML tool blocks. */
35
- export declare function createDeepSeekTextFilter(): DeepSeekTextFilter;
45
+ };
36
46
  //#endregion
37
47
  //#region packages/ai/src/transports/google-thinking-level.d.ts
38
48
  /** Returns whether a Gemini Flash model accepts the MINIMAL thinking level. */
@@ -170,7 +180,7 @@ export declare function buildOpenAICompletionsParams(model: OpenAIModeModel, con
170
180
  type CompletionsRequest = Record<string, unknown> & {
171
181
  model: string;
172
182
  messages: unknown[];
173
- stream: true;
183
+ stream: boolean;
174
184
  tools?: ReturnType<typeof convertTools>["tools"];
175
185
  };
176
186
  //#endregion
@@ -268,6 +278,7 @@ export declare function getCompat(model: OpenAIModeModel): {
268
278
  requiresThinkingAsText: boolean;
269
279
  requiresReasoningContentOnAssistantMessages: boolean;
270
280
  thinkingFormat: ModelDataThinkingFormat;
281
+ vercelGatewayRouting: VercelGatewayRouting;
271
282
  zaiToolStream: boolean;
272
283
  supportsStrictMode: boolean;
273
284
  supportsJsonSchemaResponseFormat: boolean;
@@ -278,9 +289,9 @@ export declare function getCompat(model: OpenAIModeModel): {
278
289
  visibleReasoningDetailTypes: string[];
279
290
  requiresNonEmptyUserOrAssistantMessage: boolean;
280
291
  configuredSupportsLongCacheRetention?: boolean;
292
+ reasoningEffortForOff: "none" | null;
281
293
  reasoningEffortMap: Record<string, string>;
282
294
  openRouterRouting: Record<string, unknown>;
283
- vercelGatewayRouting: Record<string, unknown>;
284
295
  requiresStringContent: boolean;
285
296
  strictMessageKeys: boolean;
286
297
  };
@@ -431,4 +442,4 @@ export declare function convertGoogleTools(tools: Tool[]): {
431
442
  functionDeclarations: Record<string, unknown>[];
432
443
  }[] | undefined;
433
444
  //#endregion
434
- export { CompactionReplayRefreshRequiredError, type GoogleStreamChunk, IncompleteToolCallError, type OpenAICompletionsOptions, type OpenAIResponsesCompactionRejection, ProviderAcceptance, ResolvedOpenAICompletionsCompat, WritableTransportStream, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyOpenAIResponsesPayloadPolicy, assignTransportErrorDetails, buildAnthropicSystemBlocks, createTransportAwareStreamFnForModel as buildTransportAwareSimpleStreamFn, captureOpenAIResponsesCompaction, coerceTransportToolCallArguments, copyProviderAcceptanceObserver, createSupportedTransportStreamFn as createBoundaryAwareStreamFnForModel, createSupportedTransportStreamFn as createOpenClawTransportStreamFnForModel, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, failTransportStream, finalizeTerminalToolCallArguments, finalizeTransportStream, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, isAnthropicServerToolClearingEnabled, isDirectAnthropicModel, isNativeOpenAIEndpoint, isOpenAICodexResponsesModel, iterateModelStream, logAnthropicContextEdits, mergeTransportHeaders, notifyProviderHttpMetadata, notifyProviderHttpResponse, notifyProviderStreamOpened, parseTerminalToolCallArguments, resolveAnthropicCacheOptions, resolveAnthropicEphemeralCacheControl, resolveAnthropicPayloadPolicy, resolveAnthropicRequestBetaHeader, resolveAnthropicServerCompactionPlan, resolveModelPayloadDebugMode, resolveModelSseDebugMode, resolveOpenAICompletionsCompat, resolveOpenAIPromptCacheKeySupport, resolveOpenAIResponsesCompactEndpointPlan, resolveOpenAIResponsesPayloadPolicy, resolveOpenAIResponsesServerCompactionPlan, sanitizeNonEmptyTransportPayloadText, sanitizeTransportPayloadText, sortPromptCacheToolsByName as sortTransportToolsByName, supportsAnthropicServerSideFallback, throwIfModelStreamAborted, transportAbortError, usesNativeOpenAICodexResponsesBackend, withProviderAcceptanceObserver, withProviderResponseHook };
445
+ export { CompactionReplayRefreshRequiredError, type GoogleStreamChunk, IncompleteToolCallError, type OpenAICompletionsOptions, type OpenAIResponsesCompactionRejection, ProviderAcceptance, ResolvedOpenAICompletionsCompat, WritableTransportStream, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyOpenAIResponsesPayloadPolicy, assignTransportErrorDetails, buildAnthropicSystemBlocks, createTransportAwareStreamFnForModel as buildTransportAwareSimpleStreamFn, captureOpenAIResponsesCompaction, coerceTransportToolCallArguments, copyProviderAcceptanceObserver, createSupportedTransportStreamFn as createBoundaryAwareStreamFnForModel, createSupportedTransportStreamFn as createOpenClawTransportStreamFnForModel, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, emitModelTransportError, failTransportStream, finalizeTerminalToolCallArguments, finalizeTransportStream, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, isAnthropicServerToolClearingEnabled, isDirectAnthropicModel, isNativeOpenAIEndpoint, isOpenAICodexResponsesModel, iterateModelStream, logAnthropicContextEdits, mergeTransportHeaders, notifyProviderHttpMetadata, notifyProviderHttpResponse, notifyProviderStreamOpened, parseTerminalToolCallArguments, resolveAnthropicCacheOptions, resolveAnthropicEphemeralCacheControl, resolveAnthropicPayloadPolicy, resolveAnthropicRequestBetaHeader, resolveAnthropicServerCompactionPlan, resolveModelPayloadDebugMode, resolveModelSseDebugMode, resolveOpenAICompletionsCompat, resolveOpenAIPromptCacheKeySupport, resolveOpenAIResponsesCompactEndpointPlan, resolveOpenAIResponsesPayloadPolicy, resolveOpenAIResponsesServerCompactionPlan, sanitizeNonEmptyTransportPayloadText, sanitizeTransportPayloadText, sortPromptCacheToolsByName as sortTransportToolsByName, supportsAnthropicServerSideFallback, throwIfModelStreamAborted, transportAbortError, usesNativeOpenAICodexResponsesBackend, withProviderAcceptanceObserver, withProviderResponseHook };