@openclaw/ai 2026.9.1 → 2026.9.3
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-CZy5U0NY.mjs +376 -0
- package/dist/anthropic-payload-policy-wuRCb6MH.d.mts +85 -0
- package/dist/anthropic-stream-reducer-B_yo_7pf.mjs +1669 -0
- package/dist/{api-registry-Cs6HGNqY.d.mts → api-registry-CB1-1oQ2.d.mts} +2 -2
- package/dist/assistant-output-iqnlJCV2.mjs +16 -0
- package/dist/assistant-text-phase-C20rxWwP.mjs +55 -0
- package/dist/{azure-openai-responses-CN4Fy5zV.mjs → azure-openai-responses-Crpa40QR.mjs} +5 -5
- package/dist/{base64-CEFBpSkN.mjs → base64-D-su8YVo.mjs} +1 -27
- package/dist/{diagnostics-KhXK-QJI.mjs → diagnostics-dV98PqIy.mjs} +96 -21
- package/dist/diagnostics.d.mts +3 -1
- package/dist/diagnostics.mjs +3 -3
- package/dist/{event-stream-vK_7r3bj.d.mts → event-stream-C1Z2piyk.d.mts} +11 -3
- package/dist/{event-stream-uSMZJ3FA.mjs → event-stream-D8PARQfL.mjs} +48 -10
- package/dist/event-stream-I_GlBsuZ.d.mts +1 -0
- 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-CC-nrwXg.mjs → google-BDPriaVe.mjs} +10 -10
- package/dist/google-messages-CVn9eFpF.mjs +449 -0
- package/dist/google-shared-BedY23XS.mjs +185 -0
- package/dist/{google-vertex-DCr0pyzQ.mjs → google-vertex-DMz8XQCn.mjs} +7 -6
- package/dist/{host-BIaiBURL.mjs → host-CWuF-sS3.mjs} +84 -34
- package/dist/{host-BztR4tQj.d.mts → host-DK3wmS3e.d.mts} +3 -3
- package/dist/host-policy-CAopLRKA.mjs +37 -0
- package/dist/{index-AfaxKT8w.d.mts → index-CQ6LTHw8.d.mts} +11 -5
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +5 -5
- package/dist/internal/anthropic.d.mts +14 -11
- package/dist/internal/anthropic.mjs +5 -5
- 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 +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +1 -1
- package/dist/internal/openai.d.mts +8 -103
- package/dist/internal/openai.mjs +10 -10
- package/dist/internal/retry-after.d.mts +2 -4
- package/dist/internal/retry-after.mjs +57 -8
- package/dist/internal/runtime.d.mts +7 -6
- package/dist/internal/runtime.mjs +8 -7
- package/dist/internal/shared.d.mts +14 -3
- package/dist/internal/shared.mjs +6 -4
- package/dist/internal/tool-schema.d.mts +63 -0
- package/dist/internal/tool-schema.mjs +3 -0
- package/dist/{json-parse-BuAJEbdW.mjs → json-parse-Dw_hnxsA.mjs} +1 -1
- package/dist/{mistral-B7etBd_H.mjs → mistral--m-Jm6VZ.mjs} +16 -38
- package/dist/model-transport-url-DKocrEsb.d.mts +28 -0
- package/dist/{openai-chatgpt-responses-BAJ4gq3i.mjs → openai-chatgpt-responses-nDZccFW-.mjs} +62 -54
- package/dist/openai-completions-KuoZyx0d.mjs +187 -0
- package/dist/{openai-completions-compat-4IjSBpr6.d.mts → openai-completions-compat-CXn3T1we.d.mts} +26 -4
- package/dist/{openai-completions-stream-DZjwK8vp.mjs → openai-completions-stream-BQk3SkLD.mjs} +621 -451
- package/dist/openai-prompt-cache-BI0rkM-5.mjs +220 -0
- package/dist/openai-prompt-cache-rrutvqxq.d.mts +16 -0
- package/dist/openai-provider-client-ha_WxTyj.mjs +24 -0
- package/dist/openai-reasoning-effort-BK7FbcLT.mjs +167 -0
- package/dist/{openai-responses-BEUlxfDu.mjs → openai-responses-D99dOzKI.mjs} +14 -32
- package/dist/{openai-responses-compaction-window-DO7yV7az.mjs → openai-responses-compaction-window-D5jbzCi3.mjs} +7 -159
- package/dist/{openai-responses-contracts-bPzSN_Ba.d.mts → openai-responses-contracts-B55afwRo.d.mts} +12 -4
- package/dist/{openai-responses-prompt-observer-internal-C7x4IK7r.mjs → openai-responses-prompt-observer-internal-tApyTLVu.mjs} +3 -3
- package/dist/{openai-responses-shared-DiAdpNAM.mjs → openai-responses-shared-ZyQEzS5i.mjs} +217 -212
- package/dist/openai-tool-projection-793cE3QX.d.mts +37 -0
- package/dist/{openai-tool-schema-BMiHFH36.mjs → openai-tool-schema-CzjyYXun.mjs} +53 -583
- package/dist/openai-tool-schema-ynZBgqW-.d.mts +38 -0
- package/dist/openai-transport-params-DNasp2fU.mjs +674 -0
- package/dist/{provider-error-B6EGq6gg.mjs → provider-error-C6TbKiey.mjs} +29 -13
- package/dist/{provider-options-CxFPtvh7.d.mts → provider-options-BXr9Ec83.d.mts} +19 -42
- package/dist/provider-replay-context-BuSUaAk5.mjs +21 -0
- package/dist/{provider-transcript-transform-WvJmFUAf.mjs → provider-transcript-transform-pPmUIwKt.mjs} +1 -1
- package/dist/provider-types-CAV0Og3m.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-C-4uedDb.mjs → reasoning-tag-text-partitioner-BQBi4B9d.mjs} +90 -35
- package/dist/record-coerce-DwRYMj3t.mjs +32 -0
- package/dist/retry-after-CdCURCVg.d.mts +15 -0
- package/dist/{sanitize-unicode-S6binQG-.mjs → sanitize-unicode-Bb-v9meu.mjs} +1 -1
- package/dist/session-affinity-CCH7eYdB.mjs +20 -0
- package/dist/{simple-options-0PLDyJ-d.mjs → simple-options-tcKOqnpF.mjs} +3 -3
- package/dist/{src-C8U7lkoa.mjs → src-B2Q_6G8V.mjs} +10 -2
- 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-BtZiml7r.mjs → tool-schema-json-projection-ClptDdAO.mjs} +2 -38
- package/dist/{transport-stream-shared-CytPVLIg.mjs → transport-stream-shared-Cu3ZPhNW.mjs} +5 -5
- package/dist/{transport-stream-shared-BrvFTkoO.d.mts → transport-stream-shared-DOxpGJ-H.d.mts} +4 -4
- package/dist/transport-utils-CCooe-cr.mjs +121 -0
- package/dist/transports.d.mts +114 -41
- package/dist/transports.mjs +796 -1596
- package/dist/types-BADKjDBI.d.mts +1 -0
- package/dist/{types-DbrhszyQ.d.mts → types-Dy1q0CSu.d.mts} +101 -64
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +4 -4
- package/dist/utf16-slice-CvGodqok.mjs +29 -0
- package/dist/{validation-CJZtym2g.mjs → validation-BDzVDnTs.mjs} +9 -1
- package/dist/{validation-BOwtcl9X.d.mts → validation-CaFUZN9B.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +14 -4
- package/dist/anthropic-compaction-replay-OMJZ0uyo.mjs +0 -838
- package/dist/anthropic-hk7F7ptG.mjs +0 -883
- package/dist/anthropic-payload-policy-DBT1itQ-.d.mts +0 -51
- package/dist/event-stream-DeDhbCc5.d.mts +0 -1
- package/dist/google-shared-CjPY0hZM.mjs +0 -634
- package/dist/google-thinking-level-C-V3tecN.mjs +0 -9
- package/dist/openai-completions-D0QZ0AyB.mjs +0 -403
- package/dist/openai-prompt-cache-2uo_1OR1.d.mts +0 -7
- package/dist/openai-prompt-cache-mZTCdRPo.mjs +0 -12
- package/dist/transport-utils-CtuS1Upe.mjs +0 -138
- package/dist/types-B5EFUmXs.d.mts +0 -1
- 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),
|
|
@@ -134,8 +139,7 @@ function looksLikeDiagnosticJson(value) {
|
|
|
134
139
|
function normalizeDiagnosticFieldName(value) {
|
|
135
140
|
return value.toLowerCase().replaceAll(/[^a-z0-9]/g, "");
|
|
136
141
|
}
|
|
137
|
-
function isCredentialFieldName(
|
|
138
|
-
const normalized = normalizeDiagnosticFieldName(key);
|
|
142
|
+
function isCredentialFieldName(normalized) {
|
|
139
143
|
if (!normalized || NON_CREDENTIAL_FIELD_NAMES.has(normalized)) return false;
|
|
140
144
|
return normalized === "authorization" || normalized === "proxyauthorization" || CREDENTIAL_FIELD_SUFFIX_RE.test(normalized);
|
|
141
145
|
}
|
|
@@ -159,8 +163,7 @@ function isDiagnosticMediaPayload(descriptors) {
|
|
|
159
163
|
return typeof mime === "string" && /^(?:audio|image|video)\//iu.test(mime);
|
|
160
164
|
});
|
|
161
165
|
}
|
|
162
|
-
function extractDiagnosticMediaField(key, value, parentMedia) {
|
|
163
|
-
const normalized = normalizeDiagnosticFieldName(key);
|
|
166
|
+
function extractDiagnosticMediaField(key, normalized, value, parentMedia) {
|
|
164
167
|
const privateField = normalized === "b64json";
|
|
165
168
|
const mediaField = MEDIA_FIELD_NAME_RE.test(normalized) || MEDIA_WRAPPER_NAME_RE.test(key);
|
|
166
169
|
const contextualPayload = parentMedia && MEDIA_PAYLOAD_SUFFIX_RE.test(normalized);
|
|
@@ -201,6 +204,12 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
|
|
|
201
204
|
state.changed = true;
|
|
202
205
|
return "[Truncated]";
|
|
203
206
|
}
|
|
207
|
+
try {
|
|
208
|
+
Headers.prototype.has.call(value, "retry-after");
|
|
209
|
+
const seconds = parseRetryAfterHeadersSeconds(value);
|
|
210
|
+
state.changed = true;
|
|
211
|
+
return seconds === void 0 ? {} : { "retry-after-ms": seconds * 1e3 };
|
|
212
|
+
} catch {}
|
|
204
213
|
const keys = Reflect.ownKeys(value).slice(0, 65);
|
|
205
214
|
const descriptors = Object.fromEntries(keys.slice(0, 64).flatMap((key) => {
|
|
206
215
|
const descriptor = typeof key === "string" && Object.getOwnPropertyDescriptor(value, key);
|
|
@@ -210,7 +219,7 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
|
|
|
210
219
|
seen.add(value);
|
|
211
220
|
const out = Array.isArray(value) ? [] : {};
|
|
212
221
|
const rawName = typeof descriptors.name?.value === "string" ? descriptors.name.value : descriptors.key?.value;
|
|
213
|
-
const redactValueField = keys.length > 64 || typeof rawName === "string" && isCredentialFieldName(rawName);
|
|
222
|
+
const redactValueField = keys.length > 64 || typeof rawName === "string" && isCredentialFieldName(normalizeDiagnosticFieldName(rawName));
|
|
214
223
|
const redactMedia = mediaPayload || keys.length > 64 || isDiagnosticMediaPayload(descriptors);
|
|
215
224
|
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
216
225
|
if (!("value" in descriptor) || !descriptor.enumerable && (policy.propertyScope === "enumerable" || ![
|
|
@@ -221,7 +230,8 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
|
|
|
221
230
|
"stack"
|
|
222
231
|
].includes(key)) || key === "length") continue;
|
|
223
232
|
const child = descriptor.value;
|
|
224
|
-
|
|
233
|
+
const normalized = policy.omitField?.(key) ? void 0 : normalizeDiagnosticFieldName(key);
|
|
234
|
+
if (normalized === void 0 || isCredentialFieldName(normalized)) {
|
|
225
235
|
state.changed = true;
|
|
226
236
|
continue;
|
|
227
237
|
}
|
|
@@ -230,7 +240,7 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
|
|
|
230
240
|
state.changed = true;
|
|
231
241
|
continue;
|
|
232
242
|
}
|
|
233
|
-
const media = extractDiagnosticMediaField(key, child, redactMedia);
|
|
243
|
+
const media = extractDiagnosticMediaField(key, normalized, child, redactMedia);
|
|
234
244
|
if (media?.kind === "redacted") {
|
|
235
245
|
const redacted = media.bytes === void 0 ? "<redacted>" : {
|
|
236
246
|
redacted: "<redacted>",
|
|
@@ -339,7 +349,13 @@ function projectProviderError(error, signal) {
|
|
|
339
349
|
try {
|
|
340
350
|
snapshot = providerErrorRedactor?.(localSnapshot) ?? localSnapshot;
|
|
341
351
|
} catch {}
|
|
342
|
-
|
|
352
|
+
const projection = buildProjection(snapshot, signal);
|
|
353
|
+
const retryAfterSeconds = parseRetryAfterErrorSeconds(localSnapshot);
|
|
354
|
+
if (retryAfterSeconds !== void 0) {
|
|
355
|
+
const suffix = `; Retry-After: ${retryAfterSeconds} seconds`;
|
|
356
|
+
projection.errorMessage = `${truncateUtf16Safe(projection.errorMessage, 4096 - suffix.length)}${suffix}`;
|
|
357
|
+
}
|
|
358
|
+
return projection;
|
|
343
359
|
} catch {
|
|
344
360
|
return {
|
|
345
361
|
stopReason: signal?.aborted ? "aborted" : "error",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { J as StreamOptions } from "./types-
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
1
|
+
import { J as StreamOptions } from "./types-Dy1q0CSu.mjs";
|
|
2
|
+
import { t as OpenAICompletionsToolChoice } from "./openai-tool-projection-793cE3QX.mjs";
|
|
3
|
+
import "./types-BADKjDBI.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 & {});
|
|
@@ -24,9 +23,11 @@ declare function isOpenAIGpt56Model(model: OpenAIReasoningModel): boolean;
|
|
|
24
23
|
declare function normalizeOpenAIReasoningEffort(effort: string): string;
|
|
25
24
|
/** Resolve the reasoning efforts accepted by a specific OpenAI-compatible model. */
|
|
26
25
|
declare function resolveOpenAISupportedReasoningEfforts(model: OpenAIReasoningModel): readonly OpenAIApiReasoningEffort[];
|
|
26
|
+
/** Read a declared or known model contract, leaving unknown compatible models unspecified. */
|
|
27
|
+
declare function resolveOpenAIModelReasoningEfforts(model: OpenAIReasoningModel): readonly OpenAIApiReasoningEffort[] | undefined;
|
|
27
28
|
/**
|
|
28
|
-
* Return whether a model accepts
|
|
29
|
-
*
|
|
29
|
+
* Return whether a model accepts temperature. GPT-5.6 and GPT-6 Astra
|
|
30
|
+
* reject it with a 400; catalog compat can override per model.
|
|
30
31
|
*/
|
|
31
32
|
declare function supportsOpenAITemperature(model: OpenAIReasoningModel): boolean;
|
|
32
33
|
/** Return whether a model accepts a requested reasoning effort. */
|
|
@@ -38,40 +39,6 @@ declare function resolveOpenAIReasoningEffortForModel(params: {
|
|
|
38
39
|
fallbackMap?: Record<string, string>;
|
|
39
40
|
}): OpenAIApiReasoningEffort | undefined;
|
|
40
41
|
//#endregion
|
|
41
|
-
//#region packages/ai/src/providers/openai-tool-projection.d.ts
|
|
42
|
-
type OpenAIToolDescriptor = {
|
|
43
|
-
readonly name?: unknown;
|
|
44
|
-
readonly description?: unknown;
|
|
45
|
-
readonly parameters: unknown;
|
|
46
|
-
};
|
|
47
|
-
type OpenAIProjectedTool = {
|
|
48
|
-
readonly toolIndex: number;
|
|
49
|
-
readonly name: string;
|
|
50
|
-
readonly description?: string;
|
|
51
|
-
readonly parameters: Record<string, unknown>;
|
|
52
|
-
};
|
|
53
|
-
type OpenAIToolProjectionDiagnostic = {
|
|
54
|
-
readonly toolIndex: number;
|
|
55
|
-
readonly toolName?: string;
|
|
56
|
-
readonly violations: readonly string[];
|
|
57
|
-
};
|
|
58
|
-
type OpenAIToolProjection = {
|
|
59
|
-
readonly inputToolCount: number;
|
|
60
|
-
readonly tools: readonly OpenAIProjectedTool[];
|
|
61
|
-
readonly diagnostics: readonly OpenAIToolProjectionDiagnostic[];
|
|
62
|
-
};
|
|
63
|
-
type OpenAIResponsesToolChoice = ResponseCreateParamsStreaming["tool_choice"];
|
|
64
|
-
type OpenAICompletionsSdkToolChoice = OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming["tool_choice"];
|
|
65
|
-
type OpenAICompletionsToolChoice = Exclude<OpenAICompletionsSdkToolChoice, {
|
|
66
|
-
type: "custom";
|
|
67
|
-
}>;
|
|
68
|
-
/** Snapshots direct/custom tool descriptors before OpenAI payload construction. */
|
|
69
|
-
declare function projectOpenAITools(tools: readonly OpenAIToolDescriptor[]): OpenAIToolProjection;
|
|
70
|
-
/** Keeps Responses tool choices aligned with surviving function schemas. */
|
|
71
|
-
declare function reconcileOpenAIResponsesToolChoice(choice: OpenAIResponsesToolChoice, projection: OpenAIToolProjection): OpenAIResponsesToolChoice | undefined;
|
|
72
|
-
/** Keeps Chat Completions tool choices aligned with surviving function schemas. */
|
|
73
|
-
declare function reconcileOpenAICompletionsToolChoice(choice: OpenAICompletionsSdkToolChoice, projection: OpenAIToolProjection): OpenAICompletionsSdkToolChoice | undefined;
|
|
74
|
-
//#endregion
|
|
75
42
|
//#region packages/ai/src/provider-options.d.ts
|
|
76
43
|
type OpenAIResponsesCompactionRejection = {
|
|
77
44
|
data: string;
|
|
@@ -97,8 +64,18 @@ declare const reasoningTagTextPolicy: {
|
|
|
97
64
|
};
|
|
98
65
|
type AnthropicEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
99
66
|
type AnthropicThinkingDisplay = "summarized" | "omitted";
|
|
67
|
+
type AnthropicContextManagementOptions = {
|
|
68
|
+
anthropicServerCompaction?: boolean;
|
|
69
|
+
anthropicCompactThreshold?: number;
|
|
70
|
+
cacheTtlPruning?: {
|
|
71
|
+
tools?: {
|
|
72
|
+
allow?: string[];
|
|
73
|
+
deny?: string[];
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
100
77
|
/** Provider options shared by the Anthropic provider and canonical transport. */
|
|
101
|
-
interface AnthropicOptions extends StreamOptions {
|
|
78
|
+
interface AnthropicOptions extends StreamOptions, AnthropicContextManagementOptions {
|
|
102
79
|
/**
|
|
103
80
|
* Enable extended thinking.
|
|
104
81
|
* For Opus 4.6+ and Sonnet 4.6: uses adaptive thinking (model decides when/how much to think).
|
|
@@ -166,4 +143,4 @@ type OpenAICompletionsOptions = BaseOpenAIStreamOptions & {
|
|
|
166
143
|
reasoningEffort?: OpenAIReasoningEffort;
|
|
167
144
|
};
|
|
168
145
|
//#endregion
|
|
169
|
-
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 };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { t as shortHash } from "./hash-CHgqbJmD.mjs";
|
|
2
|
+
//#region packages/ai/src/transports/provider-replay-context.ts
|
|
3
|
+
function hashReplayContextValue(value) {
|
|
4
|
+
const normalized = value?.trim();
|
|
5
|
+
return normalized ? shortHash(normalized) : void 0;
|
|
6
|
+
}
|
|
7
|
+
function buildProviderReplayContext(model, options) {
|
|
8
|
+
return {
|
|
9
|
+
provider: model.provider,
|
|
10
|
+
api: model.api,
|
|
11
|
+
model: model.id,
|
|
12
|
+
baseUrlHash: hashReplayContextValue(model.baseUrl),
|
|
13
|
+
sessionHash: hashReplayContextValue(options?.sessionId),
|
|
14
|
+
authProfileHash: hashReplayContextValue(options?.authProfileId)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function providerReplayContextMatches(state, context) {
|
|
18
|
+
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;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { providerReplayContextMatches as n, buildProviderReplayContext as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as transformMessages } from "./host-
|
|
1
|
+
import { i as transformMessages } from "./host-CWuF-sS3.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,29 @@
|
|
|
1
|
+
import { t as index_d_exports } from "./index-CQ6LTHw8.mjs";
|
|
2
|
+
import { D as Model, J as StreamOptions, Y as TextContent, a as AssistantMessage, d as Context, f as ImageContent, n as Api, ot as UserMessage, rt as ToolResultMessage, s as AssistantMessageEventStreamContract } from "./types-Dy1q0CSu.mjs";
|
|
3
|
+
import "./types-BADKjDBI.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
|
|
1
|
+
import { _ as supportsClaude1MContext, a as CLAUDE_FABLE_5_THINKING_PROFILE, b as supportsClaudeNativeMaxEffort, c as bindsClaudeThinkingPrefix, d as resolveClaudeFable5ModelIdentity, f as resolveClaudeModelIdentity, g as resolveClaudeSonnet5ModelIdentity, h as resolveClaudeOpus5ModelIdentity, i as normalizeResolvedPricing, l as requiresClaudeDefaultSampling, m as resolveClaudeNativeThinkingLevelMap, n as calculateUsageCost, o as CLAUDE_OPUS_5_THINKING_PROFILE, p as resolveClaudeMythos5ModelIdentity, r as normalizeModelCostConfig, s as CLAUDE_SONNET_5_THINKING_PROFILE, u as requiresClaudeMandatoryAdaptiveThinking, v as supportsClaudeAdaptiveThinking, x as supportsClaudeNativeXhighEffort, y as supportsClaudeFastMode } from "./index-CQ6LTHw8.mjs";
|
|
2
|
+
import { $ as ThinkingLevel, A as ModelThinkingLevel, B as ProviderResponse, C as KnownImagesApi, F as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, G as StopReason, H as RawModelCostConfig, I as PricingTier, J as StreamOptions, K as StreamFn, L as Provider, M as OpenAIResponsesCompat, N as OpenRouterRouting, O as ModelCostConfig, P as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, Q as ThinkingContent, R as ProviderImagesOptions, S as KnownApi, T as MaybePromise, U as RawPricingTier, W as SimpleStreamOptions, X as TextSignatureV1, Y as TextContent, Z as ThinkingBudgets, _ as ImagesModel, a as AssistantMessage, at as Usage, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as VercelGatewayRouting, et as ThinkingLevelMap, f as ImageContent, g as ImagesInputContent, h as ImagesFunction, i as AssistantImages, it as Transport, j as OpenAICompletionsCompat, k as ModelCostRates, l as CacheRetention, m as ImagesContext, n as Api, nt as ToolCall, o as AssistantMessageEvent, ot as UserMessage, p as ImagesApi, r as AssistantDeliveryTtsFacts, rt as ToolResultMessage, s as AssistantMessageEventStreamContract, st as ValidateToolArgumentsFn, t as AnthropicMessagesCompat, tt as Tool, u as CompleteSimpleFn, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderReplayState } from "./types-Dy1q0CSu.mjs";
|
|
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, 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-C1Z2piyk.mjs";
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-CaFUZN9B.mjs";
|
|
6
|
+
import { a as ProviderContextHandoff, c as ProviderStreamFunction, d as VideoContent, f as resolveProviderContext, i as ProviderContext, l as ProviderStreamOptions, n as ModelInputContent, o as ProviderMessage, r as PROVIDER_CONTEXT_HANDOFF, s as ProviderModel, t as MediaContent, u as ProviderUserMessage } from "./provider-types-CAV0Og3m.mjs";
|
|
7
|
+
export { type AnthropicMessagesCompat, type Api, type AssistantDeliveryTtsFacts, type AssistantImages, type AssistantMessage, type AssistantMessageDiagnostic, type AssistantMessageEvent, type AssistantMessageEventStream, type AssistantMessageEventStreamContract, type AssistantMessageEventStreamLike, type CLAUDE_FABLE_5_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DiagnosticErrorInfo, type EventStream, type ImageContent, type ImagesApi, type ImagesContext, type ImagesFunction, type ImagesInputContent, type ImagesModel, type ImagesOptions, type ImagesOutputContent, type ImagesProvider, type ImagesStopReason, type KnownApi, type KnownImagesApi, type KnownImagesProvider, type MaybePromise, MediaContent, type ProviderMessage as Message, ProviderMessage, type ProviderModel as Model, ProviderModel, type ModelCostConfig, type ModelCostRates, ModelInputContent, type ModelThinkingLevel, type OpenAICompletionsCompat, type OpenAIResponsesCompat, type OpenRouterRouting, PROVIDER_CONTEXT_HANDOFF, type PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, type PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, type PricingTier, type Provider, ProviderContextHandoff, type ProviderImagesOptions, type ProviderReplayState, type ProviderResponse, ProviderStreamFunction, type ProviderStreamFunction as StreamFunction, ProviderStreamOptions, ProviderUserMessage, type RawModelCostConfig, type RawPricingTier, type SimpleStreamOptions, type StopReason, type StreamFn, type StreamOptions, type TextContent, type TextSignatureV1, type ThinkingBudgets, type ThinkingContent, type ThinkingLevel, type ThinkingLevelMap, type Tool, type ToolCall, type ToolResultMessage, type Transport, type Usage, type UserMessage, type ValidateToolArgumentsFn, type VercelGatewayRouting, VideoContent, type appendAssistantMessageDiagnostic, type bindsClaudeThinkingPrefix, type calculateUsageCost, type createAssistantMessageDiagnostic, type createAssistantMessageEventStream, type extractDiagnosticError, type formatThrownValue, type isProviderRefusalAssistantError, type normalizeModelCostConfig, type normalizeResolvedPricing, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeNativeMaxEffort, type supportsClaudeNativeXhighEffort, type validateToolArguments, type validateToolCall };
|
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-CB1-1oQ2.mjs";
|
|
2
|
+
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-rrutvqxq.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-C6TbKiey.mjs";
|
|
3
|
+
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-BI0rkM-5.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-CZy5U0NY.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-KuoZyx0d.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--m-Jm6VZ.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-D99dOzKI.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-Crpa40QR.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-nDZccFW-.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-BDPriaVe.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-DMz8XQCn.mjs"), (module) => ({
|
|
94
94
|
stream: module.streamGoogleVertex,
|
|
95
95
|
streamSimple: module.streamSimpleGoogleVertex
|
|
96
96
|
}))
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
+
import "./base64-D-su8YVo.mjs";
|
|
3
|
+
//#region packages/normalization-core/src/expect.ts
|
|
4
|
+
/** Returns the value or throws with the named context; use for genuine invariants only. */
|
|
5
|
+
function expectDefined(value, context) {
|
|
6
|
+
if (value === null || value === void 0) throw new Error("expected " + context + " to be defined");
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
2
10
|
//#region node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
|
|
3
11
|
/**
|
|
4
12
|
* @typedef {import('mdast').Nodes} Nodes
|
|
@@ -11687,41 +11695,81 @@ function findNextLineEnding(text, start) {
|
|
|
11687
11695
|
if (carriageReturn === -1) return lineFeed;
|
|
11688
11696
|
return lineFeed === -1 ? carriageReturn : Math.min(carriageReturn, lineFeed);
|
|
11689
11697
|
}
|
|
11690
|
-
function
|
|
11698
|
+
function captureInlineSources(text, sources) {
|
|
11699
|
+
const observe = function(token) {
|
|
11700
|
+
const start = this.stack.findLast((entry) => entry.type === "inlineCode")?.position?.start.offset;
|
|
11701
|
+
if (start === void 0) return;
|
|
11702
|
+
let source = sources.get(start);
|
|
11703
|
+
if (!source) {
|
|
11704
|
+
const inlineBlock = this.stack.findLast((entry) => entry.type === "paragraph" || entry.type === "heading");
|
|
11705
|
+
const begin = inlineBlock?.children[0]?.position?.start.offset;
|
|
11706
|
+
const containers = this.stack.filter((entry) => entry.type === "listItem" || entry.type === "blockquote");
|
|
11707
|
+
const prefixEnd = begin !== void 0 && containers.length ? begin : start;
|
|
11708
|
+
const prefixStart = containers.length ? Math.max(text.lastIndexOf("\n", prefixEnd - 1), text.lastIndexOf("\r", prefixEnd - 1)) + 1 : start;
|
|
11709
|
+
const prefix = containers.map((entry) => text.slice(entry.position?.start.offset, entry.children[0]?.position?.start.offset)).join("");
|
|
11710
|
+
source = {
|
|
11711
|
+
prefix: {
|
|
11712
|
+
start: prefixStart,
|
|
11713
|
+
end: prefixEnd,
|
|
11714
|
+
ownerStart: containers[0]?.position?.start.offset ?? start,
|
|
11715
|
+
text: prefix + (containers.length && inlineBlock?.type === "heading" ? text.slice(inlineBlock.position?.start.offset, begin) : "")
|
|
11716
|
+
},
|
|
11717
|
+
value: "",
|
|
11718
|
+
offsets: []
|
|
11719
|
+
};
|
|
11720
|
+
sources.set(start, source);
|
|
11721
|
+
}
|
|
11722
|
+
const value = this.sliceSerialize(token);
|
|
11723
|
+
const extra = value.length - (token.end.offset - token.start.offset);
|
|
11724
|
+
for (let cursor = start + source.offsets.length; cursor < token.end.offset; cursor += 1) {
|
|
11725
|
+
const consumed = cursor - token.start.offset;
|
|
11726
|
+
source.offsets.push(source.value.length + (consumed > 0 ? consumed + extra : 0));
|
|
11727
|
+
}
|
|
11728
|
+
source.value += value;
|
|
11729
|
+
};
|
|
11730
|
+
return { enter: {
|
|
11731
|
+
codeTextData(token) {
|
|
11732
|
+
observe.call(this, token);
|
|
11733
|
+
expectDefined(this.config.enter.data, "Markdown data handler").call(this, token);
|
|
11734
|
+
},
|
|
11735
|
+
lineEnding: observe
|
|
11736
|
+
} };
|
|
11737
|
+
}
|
|
11738
|
+
function parseMarkdownOwnership(text, options) {
|
|
11691
11739
|
if (!text) return {
|
|
11692
|
-
|
|
11740
|
+
regions: [],
|
|
11693
11741
|
codeSpans: [],
|
|
11694
11742
|
retainStart: 0
|
|
11695
11743
|
};
|
|
11744
|
+
const sources = /* @__PURE__ */ new Map();
|
|
11745
|
+
const tables = options?.syntax !== "commonmark";
|
|
11696
11746
|
const tree = fromMarkdown(text, {
|
|
11697
|
-
extensions: [DISABLE_HTML_MARKDOWN, gfmTable()],
|
|
11698
|
-
mdastExtensions: [gfmTableFromMarkdown()]
|
|
11747
|
+
extensions: [DISABLE_HTML_MARKDOWN, ...tables ? [gfmTable()] : []],
|
|
11748
|
+
mdastExtensions: [...tables ? [gfmTableFromMarkdown()] : [], ...options?.includeSource ? [captureInlineSources(text, sources)] : []]
|
|
11699
11749
|
});
|
|
11700
|
-
const
|
|
11701
|
-
const blockSpans = [];
|
|
11750
|
+
const regions = [];
|
|
11702
11751
|
const pending = [tree];
|
|
11703
11752
|
while (pending.length > 0) {
|
|
11704
|
-
const node = pending.pop();
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
const
|
|
11709
|
-
if (
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
const child = children[index];
|
|
11717
|
-
if (child) pending.push(child);
|
|
11753
|
+
const node = expectDefined(pending.pop(), "Markdown ownership node");
|
|
11754
|
+
const start = node.position?.start?.offset;
|
|
11755
|
+
const end = node.position?.end?.offset;
|
|
11756
|
+
if ((node.type === "code" || node.type === "inlineCode") && start !== void 0 && end !== void 0) {
|
|
11757
|
+
const source = sources.get(start);
|
|
11758
|
+
if (source) while (source.offsets.length <= end - start) source.offsets.push(source.value.length);
|
|
11759
|
+
regions.push({
|
|
11760
|
+
start,
|
|
11761
|
+
end,
|
|
11762
|
+
block: node.type === "code",
|
|
11763
|
+
...source ? { source } : {}
|
|
11764
|
+
});
|
|
11718
11765
|
}
|
|
11766
|
+
for (const child of node.children?.toReversed() ?? []) pending.push(child);
|
|
11719
11767
|
}
|
|
11720
|
-
|
|
11768
|
+
regions.sort((left, right) => left.start - right.start);
|
|
11721
11769
|
return {
|
|
11722
|
-
|
|
11723
|
-
codeSpans:
|
|
11724
|
-
retainStart:
|
|
11770
|
+
regions,
|
|
11771
|
+
codeSpans: regions.map(({ start, end }) => [start, end]),
|
|
11772
|
+
retainStart: tree.children?.at(-1)?.position?.start?.offset ?? text.length
|
|
11725
11773
|
};
|
|
11726
11774
|
}
|
|
11727
11775
|
function isInsideCode(index, spans) {
|
|
@@ -11847,7 +11895,14 @@ function reduceReasoningText(text, codeSpans, state, options) {
|
|
|
11847
11895
|
//#endregion
|
|
11848
11896
|
//#region packages/markdown-core/src/reasoning-tags.ts
|
|
11849
11897
|
const MARKDOWN_CONTAINER_LINE_RE = /^(?: {0,3}(?:>|[-+*][\t ]|\d{1,9}[.)][\t ]))/mu;
|
|
11850
|
-
|
|
11898
|
+
function endsBlankBlock(text) {
|
|
11899
|
+
let cursor = text.length - 1;
|
|
11900
|
+
if (text[cursor] === "\n") cursor -= text[cursor - 1] === "\r" ? 2 : 1;
|
|
11901
|
+
else if (text[cursor] === "\r") cursor -= 1;
|
|
11902
|
+
else return false;
|
|
11903
|
+
while (text[cursor] === " " || text[cursor] === " ") cursor -= 1;
|
|
11904
|
+
return text[cursor] === "\n" || text[cursor] === "\r";
|
|
11905
|
+
}
|
|
11851
11906
|
function reasoningTagNameStatus(text) {
|
|
11852
11907
|
let cursor = skipTagWhitespace(text, 1);
|
|
11853
11908
|
if (text.charAt(cursor) === "/") cursor = skipTagWhitespace(text, cursor + 1);
|
|
@@ -11880,6 +11935,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
11880
11935
|
visibleEver: false
|
|
11881
11936
|
};
|
|
11882
11937
|
let source = "";
|
|
11938
|
+
let endedBlankBlock = false;
|
|
11883
11939
|
let blockStart = 0;
|
|
11884
11940
|
let emitted = 0;
|
|
11885
11941
|
let holdStart;
|
|
@@ -11896,6 +11952,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
11896
11952
|
let nonFinalCloseReparseUsed = false;
|
|
11897
11953
|
const compactCommittedSource = (retainStart) => {
|
|
11898
11954
|
source = source.slice(retainStart);
|
|
11955
|
+
endedBlankBlock = endsBlankBlock(source);
|
|
11899
11956
|
blockStart = source.length;
|
|
11900
11957
|
emitted = source.length;
|
|
11901
11958
|
holdStart = void 0;
|
|
@@ -12109,15 +12166,14 @@ function createReasoningTagTextPartitioner() {
|
|
|
12109
12166
|
pendingTagProbe = void 0;
|
|
12110
12167
|
fastPathCheckedThrough = end;
|
|
12111
12168
|
fastPathCodeSafe = !final && !crossedLineBoundary && emitted === source.length && !blockCodeSpans?.some(([, spanEnd]) => spanEnd === source.length);
|
|
12112
|
-
if (!final && reduction.depth === 0 && emitted === source.length &&
|
|
12169
|
+
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);
|
|
12113
12170
|
return true;
|
|
12114
12171
|
};
|
|
12115
|
-
const consume = (
|
|
12172
|
+
const consume = (appended, strict, final) => {
|
|
12116
12173
|
strictMode ||= strict;
|
|
12117
|
-
const
|
|
12118
|
-
|
|
12119
|
-
|
|
12120
|
-
const appended = source.slice(previousLength);
|
|
12174
|
+
const previousEndedBlankBlock = endedBlankBlock;
|
|
12175
|
+
source += appended;
|
|
12176
|
+
if (appended) endedBlankBlock = (appended.endsWith("\n") || appended.endsWith("\r")) && endsBlankBlock(source);
|
|
12121
12177
|
const appendedBlock = appended.replace(/^(?:\r\n|\r|\n)+/u, "");
|
|
12122
12178
|
const appendedStartsTopLevelBlock = previousEndedBlankBlock && /^[^\t \r\n]/u.test(appendedBlock) && !MARKDOWN_CONTAINER_LINE_RE.test(appendedBlock);
|
|
12123
12179
|
if (pendingTagProbe && !pendingTagProbe.resolved) {
|
|
@@ -12143,7 +12199,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
12143
12199
|
const heldLineStart = Math.max(source.lastIndexOf("\n", Math.max(0, ownershipStart - 1)), source.lastIndexOf("\r", Math.max(0, ownershipStart - 1))) + 1;
|
|
12144
12200
|
const heldLineEnd = findNextLineEnding(source, ownershipStart);
|
|
12145
12201
|
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);
|
|
12146
|
-
const completedBlankBlock =
|
|
12202
|
+
const completedBlankBlock = endedBlankBlock;
|
|
12147
12203
|
const retainedContainerContext = MARKDOWN_CONTAINER_LINE_RE.test(source.slice(nonFinalRetainStart));
|
|
12148
12204
|
const heldBacktick = heldBacktickStart !== void 0;
|
|
12149
12205
|
let openingRunEnd = ownershipStart;
|
|
@@ -12168,8 +12224,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
12168
12224
|
const stableNonDelimiter = heldBacktick && heldCodeSpan === void 0 && completedBlankBlock;
|
|
12169
12225
|
if (!heldBacktick && !heldInOpenEndedCode || stableCode || stableNonDelimiter) {
|
|
12170
12226
|
let processEnd = source.length;
|
|
12171
|
-
if (stableNonDelimiter) processEnd = source.length;
|
|
12172
|
-
else if (mayCloseTopLevelBlock) processEnd = source.length;
|
|
12227
|
+
if (stableNonDelimiter || mayCloseTopLevelBlock) processEnd = source.length;
|
|
12173
12228
|
else if (stableCode && heldCodeSpan) {
|
|
12174
12229
|
processEnd = heldCodeSpan[1];
|
|
12175
12230
|
while (processEnd < source.length) {
|
|
@@ -12193,7 +12248,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
12193
12248
|
}
|
|
12194
12249
|
}
|
|
12195
12250
|
}
|
|
12196
|
-
if (holdStart === void 0 && reduction.depth === 0 && emitted === source.length &&
|
|
12251
|
+
if (holdStart === void 0 && reduction.depth === 0 && emitted === source.length && endedBlankBlock && (!MARKDOWN_CONTAINER_LINE_RE.test(source.slice(nonFinalRetainStart)) || appendedStartsTopLevelBlock) && nonFinalFullParses < 1) {
|
|
12197
12252
|
nonFinalFullParses += 1;
|
|
12198
12253
|
const ownership = parseMarkdownOwnership(source);
|
|
12199
12254
|
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 };
|