@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.
- package/README.md +3 -2
- package/dist/anthropic-C4Qu4H0Z.mjs +377 -0
- package/dist/{anthropic-payload-policy-d46X2pR0.d.mts → anthropic-payload-policy-BZ8umAbk.d.mts} +16 -6
- package/dist/{anthropic-compaction-replay-DB2FGLQc.mjs → anthropic-stream-reducer-CILWF7JD.mjs} +931 -184
- package/dist/{api-registry-DWtPjzyn.d.mts → api-registry-ByUwIR0e.d.mts} +2 -2
- package/dist/assistant-output-tLt4H-iQ.mjs +16 -0
- package/dist/assistant-text-phase-C20rxWwP.mjs +55 -0
- package/dist/{azure-openai-responses-C5bZRfAP.mjs → azure-openai-responses-BAlqlKKc.mjs} +5 -5
- package/dist/{base64-CEFBpSkN.mjs → base64-D-su8YVo.mjs} +1 -27
- package/dist/{diagnostics-DfFyKeX_.mjs → diagnostics-QuErwCIl.mjs} +96 -21
- package/dist/diagnostics.d.mts +3 -1
- package/dist/diagnostics.mjs +3 -3
- package/dist/{event-stream-BhT5T1Ay.d.mts → event-stream-Bt5Y4Pav.d.mts} +11 -3
- package/dist/event-stream-C3WGFsum.d.mts +1 -0
- package/dist/{event-stream-BgDvQeum.mjs → event-stream-D8PARQfL.mjs} +45 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{github-copilot-headers-NCJtz9i0.mjs → github-copilot-headers-B37TB3rB.mjs} +3 -10
- package/dist/github-copilot-request-facts-BTEBMeOv.mjs +16 -0
- package/dist/{google-4qeuE8iX.mjs → google-DPBAOaOW.mjs} +10 -10
- package/dist/google-messages-6JkpHrhJ.mjs +448 -0
- package/dist/google-shared-BvBeW9aq.mjs +185 -0
- package/dist/{google-vertex-O9BcnB6X.mjs → google-vertex-k-TMCAYD.mjs} +7 -6
- package/dist/{host-DjzGmdZ2.d.mts → host-4atIX-2V.d.mts} +5 -3
- package/dist/{host-CEvLw30U.mjs → host-B8YfDGd4.mjs} +181 -41
- package/dist/host-policy-Zcg_cNz8.mjs +37 -0
- package/dist/{index-FnHM2FcI.d.mts → index-DdD3qerf.d.mts} +4 -4
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +7 -6
- package/dist/internal/anthropic.d.mts +7 -7
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/google-model-family.d.mts +5 -0
- package/dist/internal/google-model-family.mjs +15 -0
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
- package/dist/internal/openai-responses-payload-policy.mjs +3 -2
- package/dist/internal/openai.d.mts +8 -103
- package/dist/internal/openai.mjs +9 -10
- package/dist/internal/retry-after.d.mts +2 -4
- package/dist/internal/retry-after.mjs +57 -8
- package/dist/internal/runtime.d.mts +43 -7
- package/dist/internal/runtime.mjs +6 -7
- package/dist/internal/shared.d.mts +43 -3
- package/dist/internal/shared.mjs +5 -4
- package/dist/internal/tool-schema.d.mts +63 -0
- package/dist/internal/tool-schema.mjs +3 -0
- package/dist/{mistral-Tb6oalqH.mjs → mistral-CxUZ1jUb.mjs} +10 -37
- package/dist/model-transport-url-DKocrEsb.d.mts +28 -0
- package/dist/{openai-chatgpt-responses-yUXjPNfu.mjs → openai-chatgpt-responses-CgO6kZfo.mjs} +50 -41
- package/dist/{openai-completions-compat-CpjYUArk.d.mts → openai-completions-compat-eHgh5UPE.d.mts} +26 -4
- package/dist/{openai-completions-stream-BsrBe3Gg.mjs → openai-completions-stream-Da2vvl-S.mjs} +654 -453
- package/dist/openai-completions-yJuk7eis.mjs +187 -0
- package/dist/openai-prompt-cache-B4eYo2-I.d.mts +16 -0
- package/dist/openai-prompt-cache-Bds-n_9Q.mjs +220 -0
- package/dist/openai-provider-client-S2gCrM2Z.mjs +24 -0
- package/dist/{openai-responses-CCL41ALM.mjs → openai-responses-DaYwH05E.mjs} +14 -29
- package/dist/{openai-responses-compaction-window-BMVHFOtq.mjs → openai-responses-compaction-window-CIhBAkkq.mjs} +6 -246
- package/dist/{openai-responses-contracts-rF5DDRNS.d.mts → openai-responses-contracts-BjBAqAg_.d.mts} +5 -38
- package/dist/openai-responses-contracts-DDOHA62Y.mjs +245 -0
- package/dist/{openai-responses-prompt-observer-internal-D0bhBfgL.mjs → openai-responses-prompt-observer-internal-f8J7wpsk.mjs} +3 -3
- package/dist/{openai-responses-shared-Bmma_3Qc.mjs → openai-responses-shared-B8RdBPCv.mjs} +47 -118
- package/dist/openai-tool-projection-793cE3QX.d.mts +37 -0
- package/dist/{openai-tool-schema-_pTAJqKF.mjs → openai-tool-schema-CzjyYXun.mjs} +38 -556
- package/dist/openai-tool-schema-ynZBgqW-.d.mts +38 -0
- package/dist/openai-transport-params-9aPuV5YY.mjs +675 -0
- package/dist/positive-integer-41zhOdcV.mjs +8 -0
- package/dist/{provider-error-9TraxGvt.mjs → provider-error-BA-v_tKd.mjs} +70 -11
- package/dist/{provider-options-Bcc_p-TU.d.mts → provider-options-Ceqv1OKk.d.mts} +4 -39
- package/dist/{provider-replay-context-BuSUaAk5.mjs → provider-replay-context-CJ_YvcEW.mjs} +1 -1
- package/dist/{provider-transcript-transform-BaMbI1hr.mjs → provider-transcript-transform-V5YzU9zh.mjs} +1 -1
- package/dist/provider-transport-turn-state-D5EXOFL2.mjs +42 -0
- package/dist/provider-types-CVjKjsuq.d.mts +29 -0
- package/dist/provider-types.d.mts +6 -31
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +11 -11
- package/dist/{reasoning-tag-text-partitioner-DLCNXki6.mjs → reasoning-tag-text-partitioner-BcR5pztD.mjs} +19 -19
- package/dist/record-coerce-DwRYMj3t.mjs +32 -0
- package/dist/retry-after-CdCURCVg.d.mts +15 -0
- package/dist/session-affinity-Bcunsn4I.mjs +23 -0
- package/dist/{simple-options-BjHCCh4v.mjs → simple-options-BQbb4yQL.mjs} +24 -5
- package/dist/src-DDmEryvj.mjs +2 -0
- package/dist/{stream-first-event-timeout-DcNjoFQE.mjs → stream-first-event-timeout-2hfrquuz.mjs} +1 -1
- package/dist/string-coerce-fsri9iCu.mjs +34 -0
- package/dist/{string-normalization--fwJ4S2q.mjs → string-normalization-CmLIasuf.mjs} +1 -1
- package/dist/{tool-schema-json-projection-mJhXDcyz.mjs → tool-schema-json-projection-ClptDdAO.mjs} +2 -38
- package/dist/{transport-stream-shared-xnaqxmbP.d.mts → transport-stream-shared-DNvmoWnv.d.mts} +20 -36
- package/dist/{transport-stream-shared-CZqMhfIw.mjs → transport-stream-shared-zHll9BxO.mjs} +225 -13
- package/dist/transport-utils-zrYjICLZ.mjs +118 -0
- package/dist/transports.d.mts +137 -193
- package/dist/transports.mjs +204 -1334
- package/dist/types-DlfwzH3T.d.mts +1 -0
- package/dist/types-LFWwv0cF.mjs +8 -0
- package/dist/{types-CJ1-Ht7A.d.mts → types-Ntv5z2g2.d.mts} +74 -57
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +6 -5
- package/dist/{src-2qBGKg8O.mjs → usage-cost-BNWbbXav.mjs} +0 -1
- package/dist/utf16-slice-CvGodqok.mjs +29 -0
- package/dist/{validation-AKZBDGQd.d.mts → validation-B0t_G2H6.d.mts} +1 -1
- package/dist/{validation-CJZtym2g.mjs → validation-BDzVDnTs.mjs} +9 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +13 -3
- package/dist/anthropic-BDdqdVLK.mjs +0 -886
- package/dist/event-stream-zctLx0yr.d.mts +0 -1
- package/dist/google-shared-CWeG8RIl.mjs +0 -636
- package/dist/google-thinking-level-C-V3tecN.mjs +0 -9
- package/dist/hash-CHgqbJmD.mjs +0 -16
- package/dist/json-parse-BuAJEbdW.mjs +0 -146
- package/dist/openai-completions-BIUV3RDT.mjs +0 -403
- package/dist/openai-prompt-cache-CGnVB74a.mjs +0 -21
- package/dist/openai-prompt-cache-CNoIfHYC.d.mts +0 -16
- package/dist/sanitize-unicode-D6xUvZaS.mjs +0 -83
- package/dist/transport-utils-7il795_9.mjs +0 -138
- package/dist/types-3Lnm-QSJ.d.mts +0 -1
- package/dist/types-BDdaOVi2.mjs +0 -6
- package/dist/utf16-slice-qz3nsy87.mjs +0 -84
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { o as normalizeStringifiedOptionalString } from "./string-coerce-fsri9iCu.mjs";
|
|
2
|
+
import { i as asOptionalRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
3
|
+
import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
|
|
4
|
+
import { n as estimateBase64DecodedBytes } from "./base64-D-su8YVo.mjs";
|
|
5
|
+
import { parseRetryAfterErrorSeconds, parseRetryAfterHeadersSeconds } from "./internal/retry-after.mjs";
|
|
3
6
|
//#region packages/normalization-core/src/balanced-json.ts
|
|
4
7
|
function isJsonOpeningDelimiter(char, openers) {
|
|
5
8
|
return (char === "{" || char === "[") && openers.includes(char);
|
|
@@ -7,7 +10,7 @@ function isJsonOpeningDelimiter(char, openers) {
|
|
|
7
10
|
function extractBalancedJsonAt(raw, opts, offset) {
|
|
8
11
|
const openers = opts.openers ?? ["{", "["];
|
|
9
12
|
let start = offset;
|
|
10
|
-
while (start < raw.length && !isJsonOpeningDelimiter(raw[start], openers)) start += 1;
|
|
13
|
+
if (!opts.skipQuotedOpeners) while (start < raw.length && !isJsonOpeningDelimiter(raw[start], openers)) start += 1;
|
|
11
14
|
const stack = [];
|
|
12
15
|
let inString = false;
|
|
13
16
|
let escaped = false;
|
|
@@ -18,8 +21,10 @@ function extractBalancedJsonAt(raw, opts, offset) {
|
|
|
18
21
|
else if (char === "\\") escaped = true;
|
|
19
22
|
else if (char === "\"") inString = false;
|
|
20
23
|
} else if (char === "\"") inString = true;
|
|
21
|
-
else if (isJsonOpeningDelimiter(char, openers))
|
|
22
|
-
|
|
24
|
+
else if (isJsonOpeningDelimiter(char, openers)) {
|
|
25
|
+
if (stack.length === 0) start = index;
|
|
26
|
+
stack.push(char);
|
|
27
|
+
} else if (stack.length > 0 && char === (stack.at(-1) === "{" ? "}" : "]")) {
|
|
23
28
|
stack.pop();
|
|
24
29
|
if (stack.length === 0) return {
|
|
25
30
|
json: raw.slice(start, index + 1),
|
|
@@ -42,6 +47,13 @@ function extractBalancedJsonFragments(raw, opts = {}) {
|
|
|
42
47
|
return fragments;
|
|
43
48
|
}
|
|
44
49
|
//#endregion
|
|
50
|
+
//#region packages/normalization-core/src/expect.ts
|
|
51
|
+
/** Returns the value or throws with the named context; use for genuine invariants only. */
|
|
52
|
+
function expectDefined(value, context) {
|
|
53
|
+
if (value === null || value === void 0) throw new Error("expected " + context + " to be defined");
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
45
57
|
//#region packages/normalization-core/src/stable-stringify.ts
|
|
46
58
|
const preserveString = (value) => value;
|
|
47
59
|
/** Deterministically stringifies values, optionally normalizing strings before key ordering. */
|
|
@@ -125,12 +137,38 @@ const LOOSE_QUOTED_CREDENTIAL_PAIR_RE = /\b((?!(?:api|endpoint|method|model|prov
|
|
|
125
137
|
const LOOSE_CREDENTIAL_PAIR_RE = /\b((?!(?:api|endpoint|method|model|provider|status|type)=)[A-Za-z][A-Za-z0-9_.-]{0,64})=([A-Za-z0-9+/._~%=-]{16,})(?=[;&#'"\s]|$)/giu;
|
|
126
138
|
const MEDIA_DATA_URL_RE = /data:(?:audio|image|video)\/[a-z0-9.+-]+(?:;[^,;\s]+)*;base64,[ \t]*(?:\r?\n[ \t]*)?[a-z0-9+/_=-]+(?:[ \t]*\r?\n[ \t]*[a-z0-9+/_=-]+)*/giu;
|
|
127
139
|
const MAX_DIAGNOSTIC_JSON_LENGTH = 16384;
|
|
128
|
-
const
|
|
140
|
+
const BRACKET_PROSE_PATTERN = String.raw`(\[+)([A-Za-z][A-Za-z0-9 _.-]*|\s*\d+\s+(?!(?:true|false|null)(?![\w-]))[A-Za-z][A-Za-z0-9 _.=-]*)(\]+)`;
|
|
141
|
+
const BRACKET_PROSE_RE = new RegExp(`^${BRACKET_PROSE_PATTERN}$`, "u");
|
|
142
|
+
const BRACKET_PROSE_PART_RE = new RegExp(String.raw`(?<!\[)${BRACKET_PROSE_PATTERN}`, "gu");
|
|
143
|
+
const JSON_LITERAL_PROSE_START_RE = /^(?:true|false|null)\b(?!-)/u;
|
|
144
|
+
const PROSE_ASSIGNMENT_RE = /(?<![A-Za-z0-9_.-])([A-Za-z0-9_.-]+)\s*(?:=\s*)+(?=([^=;&\s\]'"},]+))/gu;
|
|
145
|
+
const PRIVATE_KEY_HEADER_RE = /-----BEGIN [A-Z ]*PRIVATE KEY/iu;
|
|
129
146
|
const JSON_ARRAY_START_RE = /\[\s*(?:[{"\d\]-]|true\b|false\b|null\b)/u;
|
|
130
147
|
const MALFORMED_JSON_RE = /\{|(?:"[^"]+"|\b(?:b64_json|data|(?:input|output)?(?:audio|image|video)[\w-]*))\s*:/iu;
|
|
131
148
|
function looksLikeDiagnosticJson(value) {
|
|
132
149
|
return JSON_ARRAY_START_RE.test(value) || MALFORMED_JSON_RE.test(value);
|
|
133
150
|
}
|
|
151
|
+
function isPlainBracketProse(value) {
|
|
152
|
+
const match = BRACKET_PROSE_RE.exec(value);
|
|
153
|
+
return match !== null && expectDefined(match[1], "opening brackets").length === expectDefined(match[3], "closing brackets").length && !JSON_LITERAL_PROSE_START_RE.test(expectDefined(match[2], "bracket prose"));
|
|
154
|
+
}
|
|
155
|
+
function hasSensitiveProseContent(value) {
|
|
156
|
+
if (PRIVATE_KEY_HEADER_RE.test(value)) return true;
|
|
157
|
+
let mediaContext = false;
|
|
158
|
+
let contextualPayload = false;
|
|
159
|
+
for (const match of value.matchAll(PROSE_ASSIGNMENT_RE)) {
|
|
160
|
+
const assigned = expectDefined(match[2], "diagnostic assignment value");
|
|
161
|
+
const valueEnd = match.index + match[0].length + assigned.length;
|
|
162
|
+
if (assigned === "<redacted>" && value[valueEnd] !== "=") continue;
|
|
163
|
+
const key = expectDefined(match[1], "diagnostic assignment field");
|
|
164
|
+
const normalized = normalizeDiagnosticFieldName(key);
|
|
165
|
+
if (isCredentialFieldName(normalized) || extractDiagnosticMediaField(key, normalized, void 0, false)) return true;
|
|
166
|
+
mediaContext ||= isDiagnosticMediaPayload({ [key]: { value: assigned } });
|
|
167
|
+
contextualPayload ||= Boolean(extractDiagnosticMediaField(key, normalized, void 0, true));
|
|
168
|
+
if (mediaContext && contextualPayload) return true;
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
134
172
|
function normalizeDiagnosticFieldName(value) {
|
|
135
173
|
return value.toLowerCase().replaceAll(/[^a-z0-9]/g, "");
|
|
136
174
|
}
|
|
@@ -199,6 +237,12 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
|
|
|
199
237
|
state.changed = true;
|
|
200
238
|
return "[Truncated]";
|
|
201
239
|
}
|
|
240
|
+
try {
|
|
241
|
+
Headers.prototype.has.call(value, "retry-after");
|
|
242
|
+
const seconds = parseRetryAfterHeadersSeconds(value);
|
|
243
|
+
state.changed = true;
|
|
244
|
+
return seconds === void 0 ? {} : { "retry-after-ms": seconds * 1e3 };
|
|
245
|
+
} catch {}
|
|
202
246
|
const keys = Reflect.ownKeys(value).slice(0, 65);
|
|
203
247
|
const descriptors = Object.fromEntries(keys.slice(0, 64).flatMap((key) => {
|
|
204
248
|
const descriptor = typeof key === "string" && Object.getOwnPropertyDescriptor(value, key);
|
|
@@ -251,7 +295,12 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
|
|
|
251
295
|
function redactDiagnosticText(value) {
|
|
252
296
|
const text = redactCredentialText(value).replace(MEDIA_DATA_URL_RE, "<redacted>");
|
|
253
297
|
if (!looksLikeDiagnosticJson(text)) return text;
|
|
254
|
-
|
|
298
|
+
const allowProse = !hasSensitiveProseContent(text);
|
|
299
|
+
if (text.length > MAX_DIAGNOSTIC_JSON_LENGTH) {
|
|
300
|
+
const remaining = allowProse && !MALFORMED_JSON_RE.test(text) ? text.replace(BRACKET_PROSE_PART_RE, (part) => isPlainBracketProse(part) ? "" : part) : text;
|
|
301
|
+
if (allowProse && !/[[\]{}]/u.test(remaining) && !MALFORMED_JSON_RE.test(text)) return text;
|
|
302
|
+
return "[Oversized diagnostic JSON redacted]";
|
|
303
|
+
}
|
|
255
304
|
let cursor = 0;
|
|
256
305
|
let redacted = "";
|
|
257
306
|
let unstructured = "";
|
|
@@ -259,6 +308,11 @@ function redactDiagnosticText(value) {
|
|
|
259
308
|
const plainText = text.slice(cursor, fragment.startIndex);
|
|
260
309
|
unstructured += plainText;
|
|
261
310
|
redacted += plainText;
|
|
311
|
+
if (allowProse && isPlainBracketProse(fragment.json)) {
|
|
312
|
+
redacted += fragment.json;
|
|
313
|
+
cursor = fragment.endIndex + 1;
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
262
316
|
try {
|
|
263
317
|
const state = {
|
|
264
318
|
changed: false,
|
|
@@ -267,8 +321,7 @@ function redactDiagnosticText(value) {
|
|
|
267
321
|
const projected = projectDiagnosticValue(JSON.parse(fragment.json), {}, /* @__PURE__ */ new WeakSet(), false, state);
|
|
268
322
|
redacted += state.changed ? stableStringify(projected) : fragment.json;
|
|
269
323
|
} catch {
|
|
270
|
-
|
|
271
|
-
redacted += fragment.json;
|
|
324
|
+
return "[Malformed diagnostic JSON redacted]";
|
|
272
325
|
}
|
|
273
326
|
cursor = fragment.endIndex + 1;
|
|
274
327
|
}
|
|
@@ -338,7 +391,13 @@ function projectProviderError(error, signal) {
|
|
|
338
391
|
try {
|
|
339
392
|
snapshot = providerErrorRedactor?.(localSnapshot) ?? localSnapshot;
|
|
340
393
|
} catch {}
|
|
341
|
-
|
|
394
|
+
const projection = buildProjection(snapshot, signal);
|
|
395
|
+
const retryAfterSeconds = parseRetryAfterErrorSeconds(localSnapshot);
|
|
396
|
+
if (retryAfterSeconds !== void 0) {
|
|
397
|
+
const suffix = `; Retry-After: ${retryAfterSeconds} seconds`;
|
|
398
|
+
projection.errorMessage = `${truncateUtf16Safe(projection.errorMessage, 4096 - suffix.length)}${suffix}`;
|
|
399
|
+
}
|
|
400
|
+
return projection;
|
|
342
401
|
} catch {
|
|
343
402
|
return {
|
|
344
403
|
stopReason: signal?.aborted ? "aborted" : "error",
|
|
@@ -347,4 +406,4 @@ function projectProviderError(error, signal) {
|
|
|
347
406
|
}
|
|
348
407
|
}
|
|
349
408
|
//#endregion
|
|
350
|
-
export { stableStringify as i, projectProviderError as n, projectDiagnosticValue as r, configureProviderErrorRedactor as t };
|
|
409
|
+
export { expectDefined as a, stableStringify as i, projectProviderError as n, projectDiagnosticValue as r, configureProviderErrorRedactor as t };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
1
|
+
import { Y as StreamOptions } from "./types-Ntv5z2g2.mjs";
|
|
2
|
+
import { t as OpenAICompletionsToolChoice } from "./openai-tool-projection-793cE3QX.mjs";
|
|
3
|
+
import "./types-DlfwzH3T.mjs";
|
|
4
4
|
import Anthropic from "@anthropic-ai/sdk";
|
|
5
|
-
import { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
|
|
6
5
|
//#region packages/ai/src/providers/openai-reasoning-effort.d.ts
|
|
7
6
|
type OpenAIReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
8
7
|
type OpenAIApiReasoningEffort = OpenAIReasoningEffort | (string & {});
|
|
@@ -40,40 +39,6 @@ declare function resolveOpenAIReasoningEffortForModel(params: {
|
|
|
40
39
|
fallbackMap?: Record<string, string>;
|
|
41
40
|
}): OpenAIApiReasoningEffort | undefined;
|
|
42
41
|
//#endregion
|
|
43
|
-
//#region packages/ai/src/providers/openai-tool-projection.d.ts
|
|
44
|
-
type OpenAIToolDescriptor = {
|
|
45
|
-
readonly name?: unknown;
|
|
46
|
-
readonly description?: unknown;
|
|
47
|
-
readonly parameters: unknown;
|
|
48
|
-
};
|
|
49
|
-
type OpenAIProjectedTool = {
|
|
50
|
-
readonly toolIndex: number;
|
|
51
|
-
readonly name: string;
|
|
52
|
-
readonly description?: string;
|
|
53
|
-
readonly parameters: Record<string, unknown>;
|
|
54
|
-
};
|
|
55
|
-
type OpenAIToolProjectionDiagnostic = {
|
|
56
|
-
readonly toolIndex: number;
|
|
57
|
-
readonly toolName?: string;
|
|
58
|
-
readonly violations: readonly string[];
|
|
59
|
-
};
|
|
60
|
-
type OpenAIToolProjection = {
|
|
61
|
-
readonly inputToolCount: number;
|
|
62
|
-
readonly tools: readonly OpenAIProjectedTool[];
|
|
63
|
-
readonly diagnostics: readonly OpenAIToolProjectionDiagnostic[];
|
|
64
|
-
};
|
|
65
|
-
type OpenAIResponsesToolChoice = ResponseCreateParamsStreaming["tool_choice"];
|
|
66
|
-
type OpenAICompletionsSdkToolChoice = OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming["tool_choice"];
|
|
67
|
-
type OpenAICompletionsToolChoice = Exclude<OpenAICompletionsSdkToolChoice, {
|
|
68
|
-
type: "custom";
|
|
69
|
-
}>;
|
|
70
|
-
/** Snapshots direct/custom tool descriptors before OpenAI payload construction. */
|
|
71
|
-
declare function projectOpenAITools(tools: readonly OpenAIToolDescriptor[]): OpenAIToolProjection;
|
|
72
|
-
/** Keeps Responses tool choices aligned with surviving function schemas. */
|
|
73
|
-
declare function reconcileOpenAIResponsesToolChoice(choice: OpenAIResponsesToolChoice, projection: OpenAIToolProjection): OpenAIResponsesToolChoice | undefined;
|
|
74
|
-
/** Keeps Chat Completions tool choices aligned with surviving function schemas. */
|
|
75
|
-
declare function reconcileOpenAICompletionsToolChoice(choice: OpenAICompletionsSdkToolChoice, projection: OpenAIToolProjection): OpenAICompletionsSdkToolChoice | undefined;
|
|
76
|
-
//#endregion
|
|
77
42
|
//#region packages/ai/src/provider-options.d.ts
|
|
78
43
|
type OpenAIResponsesCompactionRejection = {
|
|
79
44
|
data: string;
|
|
@@ -178,4 +143,4 @@ type OpenAICompletionsOptions = BaseOpenAIStreamOptions & {
|
|
|
178
143
|
reasoningEffort?: OpenAIReasoningEffort;
|
|
179
144
|
};
|
|
180
145
|
//#endregion
|
|
181
|
-
export {
|
|
146
|
+
export { resolveOpenAIModelReasoningEfforts as _, BaseOpenAIStreamOptions as a, supportsOpenAIReasoningEffort as b, OpenAIResponsesCompactionRejection as c, OpenAIApiReasoningEffort as d, OpenAIReasoningEffort as f, normalizeOpenAIReasoningEffort 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, resolveOpenAIReasoningEffortForModel as v, supportsOpenAITemperature as x, resolveOpenAISupportedReasoningEfforts as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as shortHash } from "./transport-stream-shared-zHll9BxO.mjs";
|
|
2
2
|
//#region packages/ai/src/transports/provider-replay-context.ts
|
|
3
3
|
function hashReplayContextValue(value) {
|
|
4
4
|
const normalized = value?.trim();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as transformMessages } from "./host-
|
|
1
|
+
import { i as transformMessages } from "./host-B8YfDGd4.mjs";
|
|
2
2
|
//#region packages/ai/src/provider-transcript-transform.ts
|
|
3
3
|
const IMAGE_OMISSION = "(image omitted: model does not support images)";
|
|
4
4
|
const VIDEO_OMISSION = "(video omitted: provider does not support video input)";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { n as getAiTransportHost } from "./host-B8YfDGd4.mjs";
|
|
2
|
+
import { n as resolveOpencodeSessionHeaders, t as hasOpencodeSessionHeader } from "./session-affinity-Bcunsn4I.mjs";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
//#region packages/ai/src/transports/provider-transport-turn-state.ts
|
|
5
|
+
function resolveProviderTransportTurnState(model, params) {
|
|
6
|
+
const normalizedProvider = model.provider.trim().toLowerCase();
|
|
7
|
+
const allowRuntimePluginLoad = normalizedProvider === "openai" || normalizedProvider === "azure-openai" || normalizedProvider === "azure-openai-responses";
|
|
8
|
+
return getAiTransportHost().plugin.resolveTransportTurnState({
|
|
9
|
+
provider: model.provider,
|
|
10
|
+
modelId: model.id,
|
|
11
|
+
allowRuntimePluginLoad,
|
|
12
|
+
context: {
|
|
13
|
+
provider: model.provider,
|
|
14
|
+
modelId: model.id,
|
|
15
|
+
model,
|
|
16
|
+
sessionId: params.sessionId,
|
|
17
|
+
turnId: params.turnId,
|
|
18
|
+
attempt: params.attempt,
|
|
19
|
+
transport: params.transport
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function filterProviderTurnHeadersForExplicitOpencodeSession(model, options, turnHeaders) {
|
|
24
|
+
if (!turnHeaders || !hasOpencodeSessionHeader(model, options)) return turnHeaders;
|
|
25
|
+
const filtered = Object.fromEntries(Object.entries(turnHeaders).filter(([name]) => name.toLowerCase() !== "x-opencode-session"));
|
|
26
|
+
return Object.keys(filtered).length > 0 ? filtered : void 0;
|
|
27
|
+
}
|
|
28
|
+
function resolveProviderSimpleCompletionHeaders(model, options) {
|
|
29
|
+
const optionHeaders = resolveOpencodeSessionHeaders(model, options);
|
|
30
|
+
const turnState = resolveProviderTransportTurnState(model, {
|
|
31
|
+
sessionId: options?.sessionId,
|
|
32
|
+
turnId: randomUUID(),
|
|
33
|
+
attempt: 1,
|
|
34
|
+
transport: "stream"
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
...filterProviderTurnHeadersForExplicitOpencodeSession(model, { headers: optionHeaders }, turnState?.headers),
|
|
38
|
+
...optionHeaders
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { resolveProviderSimpleCompletionHeaders as n, resolveProviderTransportTurnState as r, filterProviderTurnHeadersForExplicitOpencodeSession as t };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { t as index_d_exports } from "./index-DdD3qerf.mjs";
|
|
2
|
+
import { O as Model, X as TextContent, Y as StreamOptions, a as AssistantMessage, d as Context, f as ImageContent, it as ToolResultMessage, n as Api, s as AssistantMessageEventStreamContract, st as UserMessage } from "./types-Ntv5z2g2.mjs";
|
|
3
|
+
import "./types-DlfwzH3T.mjs";
|
|
4
|
+
//#region packages/ai/src/provider-types.d.ts
|
|
5
|
+
declare const PROVIDER_CONTEXT_HANDOFF: unique symbol;
|
|
6
|
+
type VideoContent = Omit<ImageContent, "type"> & {
|
|
7
|
+
type: "video";
|
|
8
|
+
};
|
|
9
|
+
type MediaContent = ImageContent | VideoContent;
|
|
10
|
+
type ModelInputContent = TextContent | MediaContent;
|
|
11
|
+
type ProviderUserMessage = Omit<UserMessage, "content"> & {
|
|
12
|
+
content: string | ModelInputContent[];
|
|
13
|
+
};
|
|
14
|
+
type ProviderMessage = ProviderUserMessage | AssistantMessage | ToolResultMessage;
|
|
15
|
+
type ProviderContext = Omit<Context, "messages"> & {
|
|
16
|
+
messages: ProviderMessage[];
|
|
17
|
+
};
|
|
18
|
+
type ProviderModel<TApi extends Api = Api> = Omit<Model<TApi>, "input"> & {
|
|
19
|
+
input: ModelInputContent["type"][];
|
|
20
|
+
};
|
|
21
|
+
type ProviderContextHandoff = () => Promise<ProviderContext>;
|
|
22
|
+
type ProviderStreamOptions = StreamOptions & {
|
|
23
|
+
[PROVIDER_CONTEXT_HANDOFF]?: ProviderContextHandoff;
|
|
24
|
+
};
|
|
25
|
+
type ProviderStreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = ProviderStreamOptions> = (model: ProviderModel<TApi>, context: ProviderContext, options?: TOptions) => AssistantMessageEventStreamContract;
|
|
26
|
+
/** Resolves provider-only context without widening the canonical call contract. */
|
|
27
|
+
declare function resolveProviderContext(context: Context | ProviderContext, options?: ProviderStreamOptions): Promise<ProviderContext>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { ProviderContextHandoff as a, ProviderStreamFunction as c, VideoContent as d, resolveProviderContext as f, ProviderContext as i, ProviderStreamOptions as l, ModelInputContent as n, ProviderMessage as o, PROVIDER_CONTEXT_HANDOFF as r, ProviderModel as s, MediaContent as t, ProviderUserMessage as u };
|
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import { _ as supportsClaude1MContext, a as CLAUDE_FABLE_5_THINKING_PROFILE, b as supportsClaudeNativeMaxEffort, c as bindsClaudeThinkingPrefix, d as resolveClaudeFable5ModelIdentity, f as resolveClaudeModelIdentity, g as resolveClaudeSonnet5ModelIdentity, h as resolveClaudeOpus5ModelIdentity, i as normalizeResolvedPricing, l as requiresClaudeDefaultSampling, m as resolveClaudeNativeThinkingLevelMap, n as calculateUsageCost, o as CLAUDE_OPUS_5_THINKING_PROFILE, p as resolveClaudeMythos5ModelIdentity, r as normalizeModelCostConfig, s as CLAUDE_SONNET_5_THINKING_PROFILE,
|
|
1
|
+
import { _ as supportsClaude1MContext, a as CLAUDE_FABLE_5_THINKING_PROFILE, b as supportsClaudeNativeMaxEffort, c as bindsClaudeThinkingPrefix, d as resolveClaudeFable5ModelIdentity, f as resolveClaudeModelIdentity, g as resolveClaudeSonnet5ModelIdentity, h as resolveClaudeOpus5ModelIdentity, i as normalizeResolvedPricing, l as requiresClaudeDefaultSampling, m as resolveClaudeNativeThinkingLevelMap, n as calculateUsageCost, o as CLAUDE_OPUS_5_THINKING_PROFILE, p as resolveClaudeMythos5ModelIdentity, r as normalizeModelCostConfig, s as CLAUDE_SONNET_5_THINKING_PROFILE, u as requiresClaudeMandatoryAdaptiveThinking, v as supportsClaudeAdaptiveThinking, x as supportsClaudeNativeXhighEffort, y as supportsClaudeFastMode } from "./index-DdD3qerf.mjs";
|
|
2
|
+
import { $ as ThinkingContent, A as ModelCostRates, B as ProviderReplayState, C as KnownImagesApi, E as MaybePromise, F as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, G as SimpleStreamOptions, I as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, K as StopReason, L as PricingTier, M as OpenAICompletionsCompat, N as OpenAIResponsesCompat, P as OpenRouterRouting, Q as ThinkingBudgets, R as Provider, S as KnownApi, T as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, U as RawModelCostConfig, V as ProviderResponse, W as RawPricingTier, X as TextContent, Y as StreamOptions, Z as TextSignatureV1, _ as ImagesModel, a as AssistantMessage, at as Transport, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as ValidateToolArgumentsFn, et as ThinkingLevel, f as ImageContent, g as ImagesInputContent, h as ImagesFunction, i as AssistantImages, it as ToolResultMessage, j as ModelThinkingLevel, k as ModelCostConfig, l as CacheRetention, lt as VercelGatewayRouting, m as ImagesContext, n as Api, nt as Tool, o as AssistantMessageEvent, ot as Usage, p as ImagesApi, q as StreamFn, r as AssistantDeliveryTtsFacts, rt as ToolCall, s as AssistantMessageEventStreamContract, st as UserMessage, t as AnthropicMessagesCompat, tt as ThinkingLevelMap, u as CompleteSimpleFn, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderImagesOptions } from "./types-Ntv5z2g2.mjs";
|
|
2
3
|
import { a as extractDiagnosticError, i as createAssistantMessageDiagnostic, n as DiagnosticErrorInfo, o as formatThrownValue, r as appendAssistantMessageDiagnostic, s as isProviderRefusalAssistantError, t as AssistantMessageDiagnostic } from "./diagnostics-DnPnOui6.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import { n as
|
|
6
|
-
|
|
7
|
-
//#region packages/ai/src/provider-types.d.ts
|
|
8
|
-
export declare const PROVIDER_CONTEXT_HANDOFF: unique symbol;
|
|
9
|
-
export type VideoContent = Omit<ImageContent, "type"> & {
|
|
10
|
-
type: "video";
|
|
11
|
-
};
|
|
12
|
-
export type MediaContent = ImageContent | VideoContent;
|
|
13
|
-
export type ModelInputContent = TextContent | MediaContent;
|
|
14
|
-
export type ProviderUserMessage = Omit<UserMessage, "content"> & {
|
|
15
|
-
content: string | ModelInputContent[];
|
|
16
|
-
};
|
|
17
|
-
export type ProviderMessage = ProviderUserMessage | AssistantMessage | ToolResultMessage;
|
|
18
|
-
export type ProviderContext = Omit<Context, "messages"> & {
|
|
19
|
-
messages: ProviderMessage[];
|
|
20
|
-
};
|
|
21
|
-
export type ProviderModel<TApi extends Api = Api> = Omit<Model<TApi>, "input"> & {
|
|
22
|
-
input: ModelInputContent["type"][];
|
|
23
|
-
};
|
|
24
|
-
export type ProviderContextHandoff = () => Promise<ProviderContext>;
|
|
25
|
-
export type ProviderStreamOptions = StreamOptions & {
|
|
26
|
-
[PROVIDER_CONTEXT_HANDOFF]?: ProviderContextHandoff;
|
|
27
|
-
};
|
|
28
|
-
export type ProviderStreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = ProviderStreamOptions> = (model: ProviderModel<TApi>, context: ProviderContext, options?: TOptions) => AssistantMessageEventStreamContract;
|
|
29
|
-
/** Resolves provider-only context without widening the canonical call contract. */
|
|
30
|
-
export declare function resolveProviderContext(context: Context | ProviderContext, options?: ProviderStreamOptions): Promise<ProviderContext>;
|
|
31
|
-
//#endregion
|
|
32
|
-
export type { AnthropicMessagesCompat, Api, AssistantDeliveryTtsFacts, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, CacheRetention, CompleteSimpleFn, ProviderContext as Context, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, MaybePromise, ProviderMessage as Message, ProviderModel as Model, ModelCostConfig, ModelCostRates, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, PricingTier, Provider, ProviderImagesOptions, ProviderReplayState, ProviderResponse, ProviderStreamFunction as StreamFunction, RawModelCostConfig, RawPricingTier, SimpleStreamOptions, StopReason, StreamFn, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, bindsClaudeThinkingPrefix, calculateUsageCost, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, isProviderRefusalAssistantError, normalizeModelCostConfig, normalizeResolvedPricing, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
|
4
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-Bt5Y4Pav.mjs";
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-B0t_G2H6.mjs";
|
|
6
|
+
import { a as ProviderContextHandoff, c as ProviderStreamFunction, d as VideoContent, f as resolveProviderContext, i as ProviderContext, l as ProviderStreamOptions, n as ModelInputContent, o as ProviderMessage, r as PROVIDER_CONTEXT_HANDOFF, s as ProviderModel, t as MediaContent, u as ProviderUserMessage } from "./provider-types-CVjKjsuq.mjs";
|
|
7
|
+
export { type AnthropicMessagesCompat, type Api, type AssistantDeliveryTtsFacts, type AssistantImages, type AssistantMessage, type AssistantMessageDiagnostic, type AssistantMessageEvent, type AssistantMessageEventStream, type AssistantMessageEventStreamContract, type AssistantMessageEventStreamLike, type CLAUDE_FABLE_5_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DiagnosticErrorInfo, type EventStream, type ImageContent, type ImagesApi, type ImagesContext, type ImagesFunction, type ImagesInputContent, type ImagesModel, type ImagesOptions, type ImagesOutputContent, type ImagesProvider, type ImagesStopReason, type KnownApi, type KnownImagesApi, type KnownImagesProvider, type MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, type MaybePromise, MediaContent, type ProviderMessage as Message, ProviderMessage, type ProviderModel as Model, ProviderModel, type ModelCostConfig, type ModelCostRates, ModelInputContent, type ModelThinkingLevel, type OpenAICompletionsCompat, type OpenAIResponsesCompat, type OpenRouterRouting, PROVIDER_CONTEXT_HANDOFF, type PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, type PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, type PricingTier, type Provider, ProviderContextHandoff, type ProviderImagesOptions, type ProviderReplayState, type ProviderResponse, ProviderStreamFunction, type ProviderStreamFunction as StreamFunction, ProviderStreamOptions, ProviderUserMessage, type RawModelCostConfig, type RawPricingTier, type SimpleStreamOptions, type StopReason, type StreamFn, type StreamOptions, type TextContent, type TextSignatureV1, type ThinkingBudgets, type ThinkingContent, type ThinkingLevel, type ThinkingLevelMap, type Tool, type ToolCall, type ToolResultMessage, type Transport, type Usage, type UserMessage, type ValidateToolArgumentsFn, type VercelGatewayRouting, VideoContent, type appendAssistantMessageDiagnostic, type bindsClaudeThinkingPrefix, type calculateUsageCost, type createAssistantMessageDiagnostic, type createAssistantMessageEventStream, type extractDiagnosticError, type formatThrownValue, type isProviderRefusalAssistantError, type normalizeModelCostConfig, type normalizeResolvedPricing, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeNativeMaxEffort, type supportsClaudeNativeXhighEffort, type validateToolArguments, type validateToolCall };
|
package/dist/providers.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
2
|
-
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-
|
|
1
|
+
import { n as ApiRegistry } from "./api-registry-ByUwIR0e.mjs";
|
|
2
|
+
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-B4eYo2-I.mjs";
|
|
3
3
|
//#region packages/ai/src/providers/register-builtins.d.ts
|
|
4
4
|
/** Source id used for built-in API provider registrations. */
|
|
5
5
|
export declare const BUILT_IN_API_PROVIDER_SOURCE_ID = "core:built-in";
|
package/dist/providers.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
2
|
-
import { n as projectProviderError } from "./provider-error-
|
|
3
|
-
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-
|
|
1
|
+
import { t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
2
|
+
import { n as projectProviderError } from "./provider-error-BA-v_tKd.mjs";
|
|
3
|
+
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-Bds-n_9Q.mjs";
|
|
4
4
|
//#region packages/ai/src/providers/register-builtins.ts
|
|
5
5
|
/** Source id used for built-in API provider registrations. */
|
|
6
6
|
const BUILT_IN_API_PROVIDER_SOURCE_ID = "core:built-in";
|
|
@@ -62,35 +62,35 @@ function createLazyRegistration(api, importModule, select) {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
const registerBuiltIns = [
|
|
65
|
-
createLazyRegistration("anthropic-messages", () => import("./anthropic-
|
|
65
|
+
createLazyRegistration("anthropic-messages", () => import("./anthropic-C4Qu4H0Z.mjs").then((n) => n.t), (module) => ({
|
|
66
66
|
stream: module.streamAnthropic,
|
|
67
67
|
streamSimple: module.streamSimpleAnthropic
|
|
68
68
|
})),
|
|
69
|
-
createLazyRegistration("openai-completions", () => import("./openai-completions-
|
|
69
|
+
createLazyRegistration("openai-completions", () => import("./openai-completions-yJuk7eis.mjs").then((n) => n.t), (module) => ({
|
|
70
70
|
stream: module.streamOpenAICompletions,
|
|
71
71
|
streamSimple: module.streamSimpleOpenAICompletions
|
|
72
72
|
})),
|
|
73
|
-
createLazyRegistration("mistral-conversations", () => import("./mistral-
|
|
73
|
+
createLazyRegistration("mistral-conversations", () => import("./mistral-CxUZ1jUb.mjs"), (module) => ({
|
|
74
74
|
stream: module.streamMistral,
|
|
75
75
|
streamSimple: module.streamSimpleMistral
|
|
76
76
|
})),
|
|
77
|
-
createLazyRegistration("openai-responses", () => import("./openai-responses-
|
|
77
|
+
createLazyRegistration("openai-responses", () => import("./openai-responses-DaYwH05E.mjs").then((n) => n.t), (module) => ({
|
|
78
78
|
stream: module.streamOpenAIResponses,
|
|
79
79
|
streamSimple: module.streamSimpleOpenAIResponses
|
|
80
80
|
})),
|
|
81
|
-
createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-
|
|
81
|
+
createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-BAlqlKKc.mjs"), (module) => ({
|
|
82
82
|
stream: module.streamAzureOpenAIResponses,
|
|
83
83
|
streamSimple: module.streamSimpleAzureOpenAIResponses
|
|
84
84
|
})),
|
|
85
|
-
createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-
|
|
85
|
+
createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-CgO6kZfo.mjs"), (module) => ({
|
|
86
86
|
stream: module.streamOpenAICodexResponses,
|
|
87
87
|
streamSimple: module.streamSimpleOpenAICodexResponses
|
|
88
88
|
})),
|
|
89
|
-
createLazyRegistration("google-generative-ai", () => import("./google-
|
|
89
|
+
createLazyRegistration("google-generative-ai", () => import("./google-DPBAOaOW.mjs"), (module) => ({
|
|
90
90
|
stream: module.streamGoogle,
|
|
91
91
|
streamSimple: module.streamSimpleGoogle
|
|
92
92
|
})),
|
|
93
|
-
createLazyRegistration("google-vertex", () => import("./google-vertex-
|
|
93
|
+
createLazyRegistration("google-vertex", () => import("./google-vertex-k-TMCAYD.mjs"), (module) => ({
|
|
94
94
|
stream: module.streamGoogleVertex,
|
|
95
95
|
streamSimple: module.streamSimpleGoogleVertex
|
|
96
96
|
}))
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import "./provider-error-
|
|
3
|
-
//#region packages/normalization-core/src/expect.ts
|
|
4
|
-
/** Returns the value or throws with the named context; use for genuine invariants only. */
|
|
5
|
-
function expectDefined(value, context) {
|
|
6
|
-
if (value === null || value === void 0) throw new Error("expected " + context + " to be defined");
|
|
7
|
-
return value;
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
2
|
+
import { a as expectDefined } from "./provider-error-BA-v_tKd.mjs";
|
|
10
3
|
//#region node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
|
|
11
4
|
/**
|
|
12
5
|
* @typedef {import('mdast').Nodes} Nodes
|
|
@@ -11895,7 +11888,14 @@ function reduceReasoningText(text, codeSpans, state, options) {
|
|
|
11895
11888
|
//#endregion
|
|
11896
11889
|
//#region packages/markdown-core/src/reasoning-tags.ts
|
|
11897
11890
|
const MARKDOWN_CONTAINER_LINE_RE = /^(?: {0,3}(?:>|[-+*][\t ]|\d{1,9}[.)][\t ]))/mu;
|
|
11898
|
-
|
|
11891
|
+
function endsBlankBlock(text) {
|
|
11892
|
+
let cursor = text.length - 1;
|
|
11893
|
+
if (text[cursor] === "\n") cursor -= text[cursor - 1] === "\r" ? 2 : 1;
|
|
11894
|
+
else if (text[cursor] === "\r") cursor -= 1;
|
|
11895
|
+
else return false;
|
|
11896
|
+
while (text[cursor] === " " || text[cursor] === " ") cursor -= 1;
|
|
11897
|
+
return text[cursor] === "\n" || text[cursor] === "\r";
|
|
11898
|
+
}
|
|
11899
11899
|
function reasoningTagNameStatus(text) {
|
|
11900
11900
|
let cursor = skipTagWhitespace(text, 1);
|
|
11901
11901
|
if (text.charAt(cursor) === "/") cursor = skipTagWhitespace(text, cursor + 1);
|
|
@@ -11928,6 +11928,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
11928
11928
|
visibleEver: false
|
|
11929
11929
|
};
|
|
11930
11930
|
let source = "";
|
|
11931
|
+
let endedBlankBlock = false;
|
|
11931
11932
|
let blockStart = 0;
|
|
11932
11933
|
let emitted = 0;
|
|
11933
11934
|
let holdStart;
|
|
@@ -11944,6 +11945,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
11944
11945
|
let nonFinalCloseReparseUsed = false;
|
|
11945
11946
|
const compactCommittedSource = (retainStart) => {
|
|
11946
11947
|
source = source.slice(retainStart);
|
|
11948
|
+
endedBlankBlock = endsBlankBlock(source);
|
|
11947
11949
|
blockStart = source.length;
|
|
11948
11950
|
emitted = source.length;
|
|
11949
11951
|
holdStart = void 0;
|
|
@@ -12157,15 +12159,14 @@ function createReasoningTagTextPartitioner() {
|
|
|
12157
12159
|
pendingTagProbe = void 0;
|
|
12158
12160
|
fastPathCheckedThrough = end;
|
|
12159
12161
|
fastPathCodeSafe = !final && !crossedLineBoundary && emitted === source.length && !blockCodeSpans?.some(([, spanEnd]) => spanEnd === source.length);
|
|
12160
|
-
if (!final && reduction.depth === 0 && emitted === source.length &&
|
|
12162
|
+
if (!final && reduction.depth === 0 && emitted === source.length && endedBlankBlock && !MARKDOWN_CONTAINER_LINE_RE.test(source.slice(blockRetainStart ?? 0)) && !blockCodeSpans?.some(([, spanEnd]) => spanEnd === source.length)) compactCommittedSource(blockRetainStart ?? 0);
|
|
12161
12163
|
return true;
|
|
12162
12164
|
};
|
|
12163
|
-
const consume = (
|
|
12165
|
+
const consume = (appended, strict, final) => {
|
|
12164
12166
|
strictMode ||= strict;
|
|
12165
|
-
const
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
const appended = source.slice(previousLength);
|
|
12167
|
+
const previousEndedBlankBlock = endedBlankBlock;
|
|
12168
|
+
source += appended;
|
|
12169
|
+
if (appended) endedBlankBlock = (appended.endsWith("\n") || appended.endsWith("\r")) && endsBlankBlock(source);
|
|
12169
12170
|
const appendedBlock = appended.replace(/^(?:\r\n|\r|\n)+/u, "");
|
|
12170
12171
|
const appendedStartsTopLevelBlock = previousEndedBlankBlock && /^[^\t \r\n]/u.test(appendedBlock) && !MARKDOWN_CONTAINER_LINE_RE.test(appendedBlock);
|
|
12171
12172
|
if (pendingTagProbe && !pendingTagProbe.resolved) {
|
|
@@ -12191,7 +12192,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
12191
12192
|
const heldLineStart = Math.max(source.lastIndexOf("\n", Math.max(0, ownershipStart - 1)), source.lastIndexOf("\r", Math.max(0, ownershipStart - 1))) + 1;
|
|
12192
12193
|
const heldLineEnd = findNextLineEnding(source, ownershipStart);
|
|
12193
12194
|
const tableLookaheadPending = source.slice(heldLineStart, heldLineEnd === -1 ? source.length : heldLineEnd).includes("|") && (heldLineEnd === -1 || findNextLineEnding(source, heldLineEnd + (source.charAt(heldLineEnd) === "\r" && source.charAt(heldLineEnd + 1) === "\n" ? 2 : 1)) === -1);
|
|
12194
|
-
const completedBlankBlock =
|
|
12195
|
+
const completedBlankBlock = endedBlankBlock;
|
|
12195
12196
|
const retainedContainerContext = MARKDOWN_CONTAINER_LINE_RE.test(source.slice(nonFinalRetainStart));
|
|
12196
12197
|
const heldBacktick = heldBacktickStart !== void 0;
|
|
12197
12198
|
let openingRunEnd = ownershipStart;
|
|
@@ -12216,8 +12217,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
12216
12217
|
const stableNonDelimiter = heldBacktick && heldCodeSpan === void 0 && completedBlankBlock;
|
|
12217
12218
|
if (!heldBacktick && !heldInOpenEndedCode || stableCode || stableNonDelimiter) {
|
|
12218
12219
|
let processEnd = source.length;
|
|
12219
|
-
if (stableNonDelimiter) processEnd = source.length;
|
|
12220
|
-
else if (mayCloseTopLevelBlock) processEnd = source.length;
|
|
12220
|
+
if (stableNonDelimiter || mayCloseTopLevelBlock) processEnd = source.length;
|
|
12221
12221
|
else if (stableCode && heldCodeSpan) {
|
|
12222
12222
|
processEnd = heldCodeSpan[1];
|
|
12223
12223
|
while (processEnd < source.length) {
|
|
@@ -12241,7 +12241,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
12241
12241
|
}
|
|
12242
12242
|
}
|
|
12243
12243
|
}
|
|
12244
|
-
if (holdStart === void 0 && reduction.depth === 0 && emitted === source.length &&
|
|
12244
|
+
if (holdStart === void 0 && reduction.depth === 0 && emitted === source.length && endedBlankBlock && (!MARKDOWN_CONTAINER_LINE_RE.test(source.slice(nonFinalRetainStart)) || appendedStartsTopLevelBlock) && nonFinalFullParses < 1) {
|
|
12245
12245
|
nonFinalFullParses += 1;
|
|
12246
12246
|
const ownership = parseMarkdownOwnership(source);
|
|
12247
12247
|
const codeSpans = ownership.codeSpans;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region packages/normalization-core/src/record-coerce.ts
|
|
2
|
+
/** Type guard for non-array object records at browser-safe boundaries. */
|
|
3
|
+
function isRecord(value) {
|
|
4
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
/** Coerces object-like values to records, falling back to an empty record. */
|
|
7
|
+
function asRecord(value) {
|
|
8
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
9
|
+
}
|
|
10
|
+
/** Reads a field only when it exists as a string. */
|
|
11
|
+
function readStringField(record, key) {
|
|
12
|
+
const value = record?.[key];
|
|
13
|
+
return typeof value === "string" ? value : void 0;
|
|
14
|
+
}
|
|
15
|
+
/** Returns a non-array record or undefined. */
|
|
16
|
+
function asOptionalRecord(value) {
|
|
17
|
+
return isRecord(value) ? value : void 0;
|
|
18
|
+
}
|
|
19
|
+
/** Returns a non-array record or a fresh ordinary empty record. */
|
|
20
|
+
function asNonArrayRecord(value) {
|
|
21
|
+
return asOptionalRecord(value) ?? {};
|
|
22
|
+
}
|
|
23
|
+
/** Returns a non-array record or null. */
|
|
24
|
+
function asNullableRecord(value) {
|
|
25
|
+
return isRecord(value) ? value : null;
|
|
26
|
+
}
|
|
27
|
+
/** Returns any object-backed record, including arrays, or undefined. */
|
|
28
|
+
function asOptionalObjectRecord(value) {
|
|
29
|
+
return value && typeof value === "object" ? value : void 0;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { asRecord as a, asOptionalRecord as i, asNullableRecord as n, isRecord as o, asOptionalObjectRecord as r, readStringField as s, asNonArrayRecord as t };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region packages/ai/src/internal/retry-after.d.ts
|
|
2
|
+
type HttpDateInstant = {
|
|
3
|
+
timestampMs: number;
|
|
4
|
+
leapSecond: boolean;
|
|
5
|
+
};
|
|
6
|
+
/** Reads only retry timing metadata, without invoking provider getters or serialization hooks. */
|
|
7
|
+
declare function parseRetryAfterHeadersSeconds(headers: unknown, nowMs?: number): number | undefined;
|
|
8
|
+
/** SDK errors carry native response headers separately from their error body. */
|
|
9
|
+
declare function parseRetryAfterErrorSeconds(error: unknown, nowMs?: number): number | undefined;
|
|
10
|
+
/** Round leap seconds forward for Retry-After so an unrepresentable instant cannot retry early. */
|
|
11
|
+
declare function parseRetryAfterHttpDateMs(value: string, nowMs?: number): number | undefined;
|
|
12
|
+
/** Parse all three HTTP-date forms while retaining leap-second ordering. */
|
|
13
|
+
declare function parseHttpDateInstant(value: string, nowMs?: number): HttpDateInstant | undefined;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { parseRetryAfterHttpDateMs as i, parseRetryAfterErrorSeconds as n, parseRetryAfterHeadersSeconds as r, parseHttpDateInstant as t };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region packages/ai/src/transports/session-affinity.ts
|
|
2
|
+
function isOpencodeEndpoint(baseUrl) {
|
|
3
|
+
try {
|
|
4
|
+
const url = new URL(baseUrl);
|
|
5
|
+
return url.protocol === "https:" && url.hostname.replace(/\.$/, "") === "opencode.ai";
|
|
6
|
+
} catch {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Required conversation identity is independent of optional prompt caching. */
|
|
11
|
+
function resolveOpencodeSessionHeaders(model, options) {
|
|
12
|
+
if (!options?.sessionId || !isOpencodeEndpoint(model.baseUrl)) return options?.headers;
|
|
13
|
+
if (hasOpencodeSessionHeader(model, options)) return options.headers;
|
|
14
|
+
return {
|
|
15
|
+
...options.headers,
|
|
16
|
+
"x-opencode-session": options.sessionId
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function hasOpencodeSessionHeader(model, options) {
|
|
20
|
+
return [model.headers, options?.headers].some((headers) => Object.keys(headers ?? {}).some((name) => name.toLowerCase() === "x-opencode-session"));
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { resolveOpencodeSessionHeaders as n, hasOpencodeSessionHeader as t };
|