@openclaw/ai 2026.9.2 → 2026.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +3 -2
  2. package/dist/anthropic-C4Qu4H0Z.mjs +377 -0
  3. package/dist/{anthropic-payload-policy-d46X2pR0.d.mts → anthropic-payload-policy-BZ8umAbk.d.mts} +16 -6
  4. package/dist/{anthropic-compaction-replay-DB2FGLQc.mjs → anthropic-stream-reducer-CILWF7JD.mjs} +931 -184
  5. package/dist/{api-registry-DWtPjzyn.d.mts → api-registry-ByUwIR0e.d.mts} +2 -2
  6. package/dist/assistant-output-tLt4H-iQ.mjs +16 -0
  7. package/dist/assistant-text-phase-C20rxWwP.mjs +55 -0
  8. package/dist/{azure-openai-responses-C5bZRfAP.mjs → azure-openai-responses-BAlqlKKc.mjs} +5 -5
  9. package/dist/{base64-CEFBpSkN.mjs → base64-D-su8YVo.mjs} +1 -27
  10. package/dist/{diagnostics-DfFyKeX_.mjs → diagnostics-QuErwCIl.mjs} +96 -21
  11. package/dist/diagnostics.d.mts +3 -1
  12. package/dist/diagnostics.mjs +3 -3
  13. package/dist/{event-stream-BhT5T1Ay.d.mts → event-stream-Bt5Y4Pav.d.mts} +11 -3
  14. package/dist/event-stream-C3WGFsum.d.mts +1 -0
  15. package/dist/{event-stream-BgDvQeum.mjs → event-stream-D8PARQfL.mjs} +45 -1
  16. package/dist/event-stream.d.mts +2 -2
  17. package/dist/event-stream.mjs +1 -1
  18. package/dist/{github-copilot-headers-NCJtz9i0.mjs → github-copilot-headers-B37TB3rB.mjs} +3 -10
  19. package/dist/github-copilot-request-facts-BTEBMeOv.mjs +16 -0
  20. package/dist/{google-4qeuE8iX.mjs → google-DPBAOaOW.mjs} +10 -10
  21. package/dist/google-messages-6JkpHrhJ.mjs +448 -0
  22. package/dist/google-shared-BvBeW9aq.mjs +185 -0
  23. package/dist/{google-vertex-O9BcnB6X.mjs → google-vertex-k-TMCAYD.mjs} +7 -6
  24. package/dist/{host-DjzGmdZ2.d.mts → host-4atIX-2V.d.mts} +5 -3
  25. package/dist/{host-CEvLw30U.mjs → host-B8YfDGd4.mjs} +181 -41
  26. package/dist/host-policy-Zcg_cNz8.mjs +37 -0
  27. package/dist/{index-FnHM2FcI.d.mts → index-DdD3qerf.d.mts} +4 -4
  28. package/dist/index.d.mts +7 -7
  29. package/dist/index.mjs +7 -6
  30. package/dist/internal/anthropic.d.mts +7 -7
  31. package/dist/internal/anthropic.mjs +4 -4
  32. package/dist/internal/google-model-family.d.mts +5 -0
  33. package/dist/internal/google-model-family.mjs +15 -0
  34. package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
  35. package/dist/internal/openai-responses-payload-policy.mjs +3 -2
  36. package/dist/internal/openai.d.mts +8 -103
  37. package/dist/internal/openai.mjs +9 -10
  38. package/dist/internal/retry-after.d.mts +2 -4
  39. package/dist/internal/retry-after.mjs +57 -8
  40. package/dist/internal/runtime.d.mts +43 -7
  41. package/dist/internal/runtime.mjs +6 -7
  42. package/dist/internal/shared.d.mts +43 -3
  43. package/dist/internal/shared.mjs +5 -4
  44. package/dist/internal/tool-schema.d.mts +63 -0
  45. package/dist/internal/tool-schema.mjs +3 -0
  46. package/dist/{mistral-Tb6oalqH.mjs → mistral-CxUZ1jUb.mjs} +10 -37
  47. package/dist/model-transport-url-DKocrEsb.d.mts +28 -0
  48. package/dist/{openai-chatgpt-responses-yUXjPNfu.mjs → openai-chatgpt-responses-CgO6kZfo.mjs} +50 -41
  49. package/dist/{openai-completions-compat-CpjYUArk.d.mts → openai-completions-compat-eHgh5UPE.d.mts} +26 -4
  50. package/dist/{openai-completions-stream-BsrBe3Gg.mjs → openai-completions-stream-Da2vvl-S.mjs} +654 -453
  51. package/dist/openai-completions-yJuk7eis.mjs +187 -0
  52. package/dist/openai-prompt-cache-B4eYo2-I.d.mts +16 -0
  53. package/dist/openai-prompt-cache-Bds-n_9Q.mjs +220 -0
  54. package/dist/openai-provider-client-S2gCrM2Z.mjs +24 -0
  55. package/dist/{openai-responses-CCL41ALM.mjs → openai-responses-DaYwH05E.mjs} +14 -29
  56. package/dist/{openai-responses-compaction-window-BMVHFOtq.mjs → openai-responses-compaction-window-CIhBAkkq.mjs} +6 -246
  57. package/dist/{openai-responses-contracts-rF5DDRNS.d.mts → openai-responses-contracts-BjBAqAg_.d.mts} +5 -38
  58. package/dist/openai-responses-contracts-DDOHA62Y.mjs +245 -0
  59. package/dist/{openai-responses-prompt-observer-internal-D0bhBfgL.mjs → openai-responses-prompt-observer-internal-f8J7wpsk.mjs} +3 -3
  60. package/dist/{openai-responses-shared-Bmma_3Qc.mjs → openai-responses-shared-B8RdBPCv.mjs} +47 -118
  61. package/dist/openai-tool-projection-793cE3QX.d.mts +37 -0
  62. package/dist/{openai-tool-schema-_pTAJqKF.mjs → openai-tool-schema-CzjyYXun.mjs} +38 -556
  63. package/dist/openai-tool-schema-ynZBgqW-.d.mts +38 -0
  64. package/dist/openai-transport-params-9aPuV5YY.mjs +675 -0
  65. package/dist/positive-integer-41zhOdcV.mjs +8 -0
  66. package/dist/{provider-error-9TraxGvt.mjs → provider-error-BA-v_tKd.mjs} +70 -11
  67. package/dist/{provider-options-Bcc_p-TU.d.mts → provider-options-Ceqv1OKk.d.mts} +4 -39
  68. package/dist/{provider-replay-context-BuSUaAk5.mjs → provider-replay-context-CJ_YvcEW.mjs} +1 -1
  69. package/dist/{provider-transcript-transform-BaMbI1hr.mjs → provider-transcript-transform-V5YzU9zh.mjs} +1 -1
  70. package/dist/provider-transport-turn-state-D5EXOFL2.mjs +42 -0
  71. package/dist/provider-types-CVjKjsuq.d.mts +29 -0
  72. package/dist/provider-types.d.mts +6 -31
  73. package/dist/providers.d.mts +2 -2
  74. package/dist/providers.mjs +11 -11
  75. package/dist/{reasoning-tag-text-partitioner-DLCNXki6.mjs → reasoning-tag-text-partitioner-BcR5pztD.mjs} +19 -19
  76. package/dist/record-coerce-DwRYMj3t.mjs +32 -0
  77. package/dist/retry-after-CdCURCVg.d.mts +15 -0
  78. package/dist/session-affinity-Bcunsn4I.mjs +23 -0
  79. package/dist/{simple-options-BjHCCh4v.mjs → simple-options-BQbb4yQL.mjs} +24 -5
  80. package/dist/src-DDmEryvj.mjs +2 -0
  81. package/dist/{stream-first-event-timeout-DcNjoFQE.mjs → stream-first-event-timeout-2hfrquuz.mjs} +1 -1
  82. package/dist/string-coerce-fsri9iCu.mjs +34 -0
  83. package/dist/{string-normalization--fwJ4S2q.mjs → string-normalization-CmLIasuf.mjs} +1 -1
  84. package/dist/{tool-schema-json-projection-mJhXDcyz.mjs → tool-schema-json-projection-ClptDdAO.mjs} +2 -38
  85. package/dist/{transport-stream-shared-xnaqxmbP.d.mts → transport-stream-shared-DNvmoWnv.d.mts} +20 -36
  86. package/dist/{transport-stream-shared-CZqMhfIw.mjs → transport-stream-shared-zHll9BxO.mjs} +225 -13
  87. package/dist/transport-utils-zrYjICLZ.mjs +118 -0
  88. package/dist/transports.d.mts +137 -193
  89. package/dist/transports.mjs +204 -1334
  90. package/dist/types-DlfwzH3T.d.mts +1 -0
  91. package/dist/types-LFWwv0cF.mjs +8 -0
  92. package/dist/{types-CJ1-Ht7A.d.mts → types-Ntv5z2g2.d.mts} +74 -57
  93. package/dist/types.d.mts +6 -6
  94. package/dist/types.mjs +6 -5
  95. package/dist/{src-2qBGKg8O.mjs → usage-cost-BNWbbXav.mjs} +0 -1
  96. package/dist/utf16-slice-CvGodqok.mjs +29 -0
  97. package/dist/{validation-AKZBDGQd.d.mts → validation-B0t_G2H6.d.mts} +1 -1
  98. package/dist/{validation-CJZtym2g.mjs → validation-BDzVDnTs.mjs} +9 -1
  99. package/dist/validation.d.mts +1 -1
  100. package/dist/validation.mjs +1 -1
  101. package/package.json +13 -3
  102. package/dist/anthropic-BDdqdVLK.mjs +0 -886
  103. package/dist/event-stream-zctLx0yr.d.mts +0 -1
  104. package/dist/google-shared-CWeG8RIl.mjs +0 -636
  105. package/dist/google-thinking-level-C-V3tecN.mjs +0 -9
  106. package/dist/hash-CHgqbJmD.mjs +0 -16
  107. package/dist/json-parse-BuAJEbdW.mjs +0 -146
  108. package/dist/openai-completions-BIUV3RDT.mjs +0 -403
  109. package/dist/openai-prompt-cache-CGnVB74a.mjs +0 -21
  110. package/dist/openai-prompt-cache-CNoIfHYC.d.mts +0 -16
  111. package/dist/sanitize-unicode-D6xUvZaS.mjs +0 -83
  112. package/dist/transport-utils-7il795_9.mjs +0 -138
  113. package/dist/types-3Lnm-QSJ.d.mts +0 -1
  114. package/dist/types-BDdaOVi2.mjs +0 -6
  115. package/dist/utf16-slice-qz3nsy87.mjs +0 -84
@@ -1,138 +0,0 @@
1
- import { d as normalizeOptionalString, t as truncateUtf16Safe } from "./utf16-slice-qz3nsy87.mjs";
2
- import { n as getAiTransportHost } from "./host-CEvLw30U.mjs";
3
- import { c as parseStrictNonNegativeInteger, i as asFiniteNumberInRange, l as parseStrictPositiveInteger, s as parseStrictFiniteNumber } from "./base64-CEFBpSkN.mjs";
4
- import { parseRetryAfterHttpDateMs } from "./internal/retry-after.mjs";
5
- import { createHash } from "node:crypto";
6
- //#region packages/ai/src/transports/transport-utils.ts
7
- const MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE = "OpenClaw transport error: malformed_streaming_fragment";
8
- const NON_LATIN_RE = /[\u2E80-\u9FFF\uA000-\uA4FF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFF60\uFFE0-\uFFE6\u{20000}-\u{2FA1F}]/gu;
9
- const CJK_SURROGATE_HIGH_RE = /[\uD840-\uD87E][\uDC00-\uDFFF]/g;
10
- function parsePositiveInteger(value) {
11
- if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value);
12
- return typeof value === "string" ? parseStrictPositiveInteger(value) : void 0;
13
- }
14
- function sha256Hex(value) {
15
- return createHash("sha256").update(value).digest("hex");
16
- }
17
- function sha256HexPrefix(value, length) {
18
- return sha256Hex(value).slice(0, length);
19
- }
20
- function redactIdentifier(value, opts) {
21
- const trimmed = normalizeOptionalString(value);
22
- if (!trimmed) return "-";
23
- return `sha256:${sha256HexPrefix(trimmed, Number.isFinite(opts?.len) ? Math.max(1, Math.floor(opts?.len ?? 12)) : 12)}`;
24
- }
25
- function redactSensitiveText(text, _options) {
26
- return getAiTransportHost().redactToolPayloadText(text);
27
- }
28
- function resolveModelHeaderSentinels(model) {
29
- if (!model.headers) return model;
30
- let headers;
31
- for (const [name, value] of Object.entries(model.headers)) {
32
- const resolved = getAiTransportHost().resolveSecretSentinel(value);
33
- if (resolved !== value) {
34
- headers ??= { ...model.headers };
35
- headers[name] = resolved;
36
- }
37
- }
38
- return headers ? {
39
- ...model,
40
- headers
41
- } : model;
42
- }
43
- function createAbortError(message, options) {
44
- const error = new Error(message, options);
45
- error.name = "AbortError";
46
- return error;
47
- }
48
- function estimateStringChars(text) {
49
- if (!text) return 0;
50
- const nonLatinCount = (text.match(NON_LATIN_RE) ?? []).length;
51
- return (nonLatinCount === 0 ? text.length : text.length - (text.match(CJK_SURROGATE_HIGH_RE) ?? []).length) + nonLatinCount * 3;
52
- }
53
- function supportsModelTools(model) {
54
- return (model.compat && typeof model.compat === "object" ? model.compat : void 0)?.supportsTools !== false;
55
- }
56
- function isCodeModeModelVisibleToolName(name, visibleToolNames) {
57
- return visibleToolNames.has(name);
58
- }
59
- function isGoogleGemini3Model(modelId, family) {
60
- const normalized = modelId.trim().toLowerCase();
61
- const suffix = family === "pro" ? "pro" : "flash";
62
- return new RegExp(`(?:^|/)gemini-(?:3(?:\\.\\d+)?-${suffix}|${suffix}${family === "flash" ? "(?:-lite)?" : ""}-latest)(?:-|$)`).test(normalized);
63
- }
64
- function isGoogleGemini3ProModel(modelId) {
65
- return isGoogleGemini3Model(modelId, "pro");
66
- }
67
- function isGoogleGemini3FlashModel(modelId) {
68
- return isGoogleGemini3Model(modelId, "flash");
69
- }
70
- function parseRetryAfterSeconds(headers) {
71
- const retryAfterMs = headers.get("retry-after-ms");
72
- if (retryAfterMs) {
73
- const trimmed = retryAfterMs.trim();
74
- if (/^\d+(?:\.\d+)?$/.test(trimmed)) {
75
- const milliseconds = asFiniteNumberInRange(parseStrictFiniteNumber(trimmed), {
76
- min: 0,
77
- max: Number.MAX_SAFE_INTEGER
78
- });
79
- return milliseconds === void 0 ? Number.POSITIVE_INFINITY : milliseconds / 1e3;
80
- }
81
- }
82
- const retryAfter = headers.get("retry-after")?.trim();
83
- if (!retryAfter) return;
84
- if (/^\d+$/.test(retryAfter)) return parseStrictNonNegativeInteger(retryAfter) ?? Number.POSITIVE_INFINITY;
85
- const retryAt = parseRetryAfterHttpDateMs(retryAfter);
86
- return retryAt === void 0 ? void 0 : Math.max(0, (retryAt - Date.now()) / 1e3);
87
- }
88
- async function readChunkWithIdleTimeout(reader, timeoutMs, onIdleTimeout) {
89
- let timer;
90
- try {
91
- return await Promise.race([reader.read(), new Promise((_resolve, reject) => {
92
- timer = setTimeout(() => reject(onIdleTimeout?.({ chunkTimeoutMs: timeoutMs }) ?? /* @__PURE__ */ new Error("Read timed out")), timeoutMs);
93
- })]);
94
- } finally {
95
- if (timer) clearTimeout(timer);
96
- }
97
- }
98
- async function readResponseTextSnippet(response, options) {
99
- const maxBytes = options?.maxBytes ?? 8192;
100
- const maxChars = options?.maxChars ?? 200;
101
- const reader = response.body?.getReader();
102
- if (!reader) return;
103
- const chunks = [];
104
- let bytes = 0;
105
- let truncated = false;
106
- try {
107
- while (bytes < maxBytes) {
108
- const result = options?.chunkTimeoutMs ? await readChunkWithIdleTimeout(reader, options.chunkTimeoutMs, options.onIdleTimeout) : await reader.read();
109
- if (result.done) break;
110
- if (!result.value?.length) continue;
111
- const remaining = maxBytes - bytes;
112
- chunks.push(result.value.subarray(0, remaining));
113
- bytes += Math.min(result.value.length, remaining);
114
- if (result.value.length >= remaining) {
115
- truncated = true;
116
- await reader.cancel().catch(() => void 0);
117
- break;
118
- }
119
- }
120
- } catch (error) {
121
- await reader.cancel(error).catch(() => void 0);
122
- throw error;
123
- } finally {
124
- reader.releaseLock();
125
- }
126
- const merged = new Uint8Array(bytes);
127
- let offset = 0;
128
- for (const chunk of chunks) {
129
- merged.set(chunk, offset);
130
- offset += chunk.length;
131
- }
132
- const collapsed = new TextDecoder().decode(merged).replace(/\s+/g, " ").trim();
133
- if (!collapsed) return;
134
- if (collapsed.length > maxChars) return `${truncateUtf16Safe(collapsed, maxChars)}…`;
135
- return truncated ? `${collapsed}…` : collapsed;
136
- }
137
- //#endregion
138
- export { isGoogleGemini3FlashModel as a, parseRetryAfterSeconds as c, redactSensitiveText as d, resolveModelHeaderSentinels as f, isCodeModeModelVisibleToolName as i, readResponseTextSnippet as l, supportsModelTools as m, createAbortError as n, isGoogleGemini3ProModel as o, sha256Hex as p, estimateStringChars as r, parsePositiveInteger as s, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as t, redactIdentifier as u };
@@ -1 +0,0 @@
1
- import "./index-FnHM2FcI.mjs";
@@ -1,6 +0,0 @@
1
- //#region packages/llm-core/src/types.ts
2
- /** Stable error codes for provider outcomes that cannot be replayed safely. */
3
- const PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE = "PROVIDER_POST_DISPATCH_AMBIGUITY";
4
- const PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE = "PROVIDER_FAILURE_WITH_OUTPUT";
5
- //#endregion
6
- export { PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE as n, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE as t };
@@ -1,84 +0,0 @@
1
- //#region packages/normalization-core/src/string-coerce.ts
2
- /** Reads a value only when it is already a string, preserving whitespace. */
3
- function readStringValue(value) {
4
- return typeof value === "string" ? value : void 0;
5
- }
6
- /** Trims string input and returns null for non-strings or empty strings. */
7
- function normalizeNullableString(value) {
8
- if (typeof value !== "string") return null;
9
- const trimmed = value.trim();
10
- return trimmed ? trimmed : null;
11
- }
12
- /** Trims string input and returns undefined for non-strings or empty strings. */
13
- function normalizeOptionalString(value) {
14
- return normalizeNullableString(value) ?? void 0;
15
- }
16
- /** Stringifies primitive ids/flags before applying optional string normalization. */
17
- function normalizeStringifiedOptionalString(value) {
18
- if (typeof value === "string") return normalizeOptionalString(value);
19
- if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return normalizeOptionalString(String(value));
20
- }
21
- /** Lowercases a normalized optional string. */
22
- function normalizeOptionalLowercaseString(value) {
23
- return normalizeOptionalString(value)?.toLowerCase();
24
- }
25
- /** Lowercases a normalized string or returns an empty string when absent. */
26
- function normalizeLowercaseStringOrEmpty(value) {
27
- return normalizeOptionalLowercaseString(value) ?? "";
28
- }
29
- /** Type guard for strings that remain non-empty after trimming. */
30
- function hasNonEmptyString(value) {
31
- return normalizeOptionalString(value) !== void 0;
32
- }
33
- //#endregion
34
- //#region packages/normalization-core/src/record-coerce.ts
35
- /** Type guard for non-array object records at browser-safe boundaries. */
36
- function isRecord(value) {
37
- return value !== null && typeof value === "object" && !Array.isArray(value);
38
- }
39
- /** Returns a non-array record or undefined. */
40
- function asOptionalRecord(value) {
41
- return isRecord(value) ? value : void 0;
42
- }
43
- /** Returns a non-array record or a fresh ordinary empty record. */
44
- function asNonArrayRecord(value) {
45
- return asOptionalRecord(value) ?? {};
46
- }
47
- /** Returns a non-array record or null. */
48
- function asNullableRecord(value) {
49
- return isRecord(value) ? value : null;
50
- }
51
- /** Returns any object-backed record, including arrays, or undefined. */
52
- function asOptionalObjectRecord(value) {
53
- return value && typeof value === "object" ? value : void 0;
54
- }
55
- //#endregion
56
- //#region packages/normalization-core/src/utf16-slice.ts
57
- function isHighSurrogate(codeUnit) {
58
- return codeUnit >= 55296 && codeUnit <= 56319;
59
- }
60
- function isLowSurrogate(codeUnit) {
61
- return codeUnit >= 56320 && codeUnit <= 57343;
62
- }
63
- /** Slices a UTF-16 string without returning dangling surrogate halves at either edge. */
64
- function sliceUtf16Safe(input, start, end) {
65
- const len = input.length;
66
- let from = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
67
- let to = end === void 0 ? len : end < 0 ? Math.max(len + end, 0) : Math.min(end, len);
68
- if (to <= from) return "";
69
- if (from > 0 && from < len) {
70
- if (isLowSurrogate(input.charCodeAt(from)) && isHighSurrogate(input.charCodeAt(from - 1))) from += 1;
71
- }
72
- if (to > 0 && to < len) {
73
- if (isHighSurrogate(input.charCodeAt(to - 1)) && isLowSurrogate(input.charCodeAt(to))) to -= 1;
74
- }
75
- return input.slice(from, to);
76
- }
77
- /** Truncates a UTF-16 string without cutting a surrogate pair in half. */
78
- function truncateUtf16Safe(input, maxLen) {
79
- const limit = Math.max(0, Math.floor(maxLen));
80
- if (input.length <= limit) return input;
81
- return sliceUtf16Safe(input, 0, limit);
82
- }
83
- //#endregion
84
- export { asOptionalRecord as a, normalizeLowercaseStringOrEmpty as c, normalizeOptionalString as d, normalizeStringifiedOptionalString as f, asOptionalObjectRecord as i, normalizeNullableString as l, asNonArrayRecord as n, isRecord as o, readStringValue as p, asNullableRecord as r, hasNonEmptyString as s, truncateUtf16Safe as t, normalizeOptionalLowercaseString as u };