@openclaw/ai 2026.9.2 → 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-d46X2pR0.d.mts → anthropic-payload-policy-wuRCb6MH.d.mts} +16 -6
- package/dist/{anthropic-compaction-replay-DB2FGLQc.mjs → anthropic-stream-reducer-B_yo_7pf.mjs} +923 -181
- package/dist/{api-registry-DWtPjzyn.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-C5bZRfAP.mjs → azure-openai-responses-Crpa40QR.mjs} +5 -5
- package/dist/{base64-CEFBpSkN.mjs → base64-D-su8YVo.mjs} +1 -27
- package/dist/{diagnostics-DfFyKeX_.mjs → diagnostics-dV98PqIy.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-C1Z2piyk.d.mts} +11 -3
- package/dist/{event-stream-BgDvQeum.mjs → event-stream-D8PARQfL.mjs} +45 -1
- 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-4qeuE8iX.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-O9BcnB6X.mjs → google-vertex-DMz8XQCn.mjs} +7 -6
- package/dist/{host-CEvLw30U.mjs → host-CWuF-sS3.mjs} +44 -39
- package/dist/{host-DjzGmdZ2.d.mts → host-DK3wmS3e.d.mts} +3 -3
- package/dist/host-policy-CAopLRKA.mjs +37 -0
- package/dist/{index-FnHM2FcI.d.mts → index-CQ6LTHw8.d.mts} +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- 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 +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-Tb6oalqH.mjs → mistral--m-Jm6VZ.mjs} +13 -37
- package/dist/model-transport-url-DKocrEsb.d.mts +28 -0
- package/dist/{openai-chatgpt-responses-yUXjPNfu.mjs → openai-chatgpt-responses-nDZccFW-.mjs} +48 -38
- package/dist/openai-completions-KuoZyx0d.mjs +187 -0
- package/dist/{openai-completions-compat-CpjYUArk.d.mts → openai-completions-compat-CXn3T1we.d.mts} +26 -4
- package/dist/{openai-completions-stream-BsrBe3Gg.mjs → openai-completions-stream-BQk3SkLD.mjs} +622 -452
- 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-CCL41ALM.mjs → openai-responses-D99dOzKI.mjs} +14 -29
- package/dist/{openai-responses-compaction-window-BMVHFOtq.mjs → openai-responses-compaction-window-D5jbzCi3.mjs} +7 -170
- package/dist/{openai-responses-contracts-rF5DDRNS.d.mts → openai-responses-contracts-B55afwRo.d.mts} +3 -3
- package/dist/{openai-responses-prompt-observer-internal-D0bhBfgL.mjs → openai-responses-prompt-observer-internal-tApyTLVu.mjs} +3 -3
- package/dist/{openai-responses-shared-Bmma_3Qc.mjs → openai-responses-shared-ZyQEzS5i.mjs} +44 -115
- 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-DNasp2fU.mjs +674 -0
- package/dist/{provider-error-9TraxGvt.mjs → provider-error-C6TbKiey.mjs} +23 -6
- package/dist/{provider-options-Bcc_p-TU.d.mts → provider-options-BXr9Ec83.d.mts} +4 -39
- package/dist/{provider-transcript-transform-BaMbI1hr.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-DLCNXki6.mjs → reasoning-tag-text-partitioner-BQBi4B9d.mjs} +19 -12
- package/dist/record-coerce-DwRYMj3t.mjs +32 -0
- package/dist/retry-after-CdCURCVg.d.mts +15 -0
- package/dist/{sanitize-unicode-D6xUvZaS.mjs → sanitize-unicode-Bb-v9meu.mjs} +1 -1
- package/dist/session-affinity-CCH7eYdB.mjs +20 -0
- package/dist/{simple-options-BjHCCh4v.mjs → simple-options-tcKOqnpF.mjs} +3 -3
- package/dist/{src-2qBGKg8O.mjs → src-B2Q_6G8V.mjs} +1 -1
- 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-CZqMhfIw.mjs → transport-stream-shared-Cu3ZPhNW.mjs} +5 -5
- package/dist/{transport-stream-shared-xnaqxmbP.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 +113 -41
- package/dist/transports.mjs +162 -1276
- package/dist/types-BADKjDBI.d.mts +1 -0
- package/dist/{types-CJ1-Ht7A.d.mts → types-Dy1q0CSu.d.mts} +72 -57
- package/dist/types.d.mts +5 -5
- package/dist/types.mjs +3 -3
- package/dist/utf16-slice-CvGodqok.mjs +29 -0
- package/dist/{validation-CJZtym2g.mjs → validation-BDzVDnTs.mjs} +9 -1
- package/dist/{validation-AKZBDGQd.d.mts → validation-CaFUZN9B.d.mts} +1 -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/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/transport-utils-7il795_9.mjs +0 -138
- package/dist/types-3Lnm-QSJ.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),
|
|
@@ -199,6 +204,12 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
|
|
|
199
204
|
state.changed = true;
|
|
200
205
|
return "[Truncated]";
|
|
201
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 {}
|
|
202
213
|
const keys = Reflect.ownKeys(value).slice(0, 65);
|
|
203
214
|
const descriptors = Object.fromEntries(keys.slice(0, 64).flatMap((key) => {
|
|
204
215
|
const descriptor = typeof key === "string" && Object.getOwnPropertyDescriptor(value, key);
|
|
@@ -338,7 +349,13 @@ function projectProviderError(error, signal) {
|
|
|
338
349
|
try {
|
|
339
350
|
snapshot = providerErrorRedactor?.(localSnapshot) ?? localSnapshot;
|
|
340
351
|
} catch {}
|
|
341
|
-
|
|
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;
|
|
342
359
|
} catch {
|
|
343
360
|
return {
|
|
344
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 & {});
|
|
@@ -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 { 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 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-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, 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-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,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import "./
|
|
2
|
+
import "./base64-D-su8YVo.mjs";
|
|
3
3
|
//#region packages/normalization-core/src/expect.ts
|
|
4
4
|
/** Returns the value or throws with the named context; use for genuine invariants only. */
|
|
5
5
|
function expectDefined(value, context) {
|
|
@@ -11895,7 +11895,14 @@ function reduceReasoningText(text, codeSpans, state, options) {
|
|
|
11895
11895
|
//#endregion
|
|
11896
11896
|
//#region packages/markdown-core/src/reasoning-tags.ts
|
|
11897
11897
|
const MARKDOWN_CONTAINER_LINE_RE = /^(?: {0,3}(?:>|[-+*][\t ]|\d{1,9}[.)][\t ]))/mu;
|
|
11898
|
-
|
|
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
|
+
}
|
|
11899
11906
|
function reasoningTagNameStatus(text) {
|
|
11900
11907
|
let cursor = skipTagWhitespace(text, 1);
|
|
11901
11908
|
if (text.charAt(cursor) === "/") cursor = skipTagWhitespace(text, cursor + 1);
|
|
@@ -11928,6 +11935,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
11928
11935
|
visibleEver: false
|
|
11929
11936
|
};
|
|
11930
11937
|
let source = "";
|
|
11938
|
+
let endedBlankBlock = false;
|
|
11931
11939
|
let blockStart = 0;
|
|
11932
11940
|
let emitted = 0;
|
|
11933
11941
|
let holdStart;
|
|
@@ -11944,6 +11952,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
11944
11952
|
let nonFinalCloseReparseUsed = false;
|
|
11945
11953
|
const compactCommittedSource = (retainStart) => {
|
|
11946
11954
|
source = source.slice(retainStart);
|
|
11955
|
+
endedBlankBlock = endsBlankBlock(source);
|
|
11947
11956
|
blockStart = source.length;
|
|
11948
11957
|
emitted = source.length;
|
|
11949
11958
|
holdStart = void 0;
|
|
@@ -12157,15 +12166,14 @@ function createReasoningTagTextPartitioner() {
|
|
|
12157
12166
|
pendingTagProbe = void 0;
|
|
12158
12167
|
fastPathCheckedThrough = end;
|
|
12159
12168
|
fastPathCodeSafe = !final && !crossedLineBoundary && emitted === source.length && !blockCodeSpans?.some(([, spanEnd]) => spanEnd === source.length);
|
|
12160
|
-
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);
|
|
12161
12170
|
return true;
|
|
12162
12171
|
};
|
|
12163
|
-
const consume = (
|
|
12172
|
+
const consume = (appended, strict, final) => {
|
|
12164
12173
|
strictMode ||= strict;
|
|
12165
|
-
const
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
const appended = source.slice(previousLength);
|
|
12174
|
+
const previousEndedBlankBlock = endedBlankBlock;
|
|
12175
|
+
source += appended;
|
|
12176
|
+
if (appended) endedBlankBlock = (appended.endsWith("\n") || appended.endsWith("\r")) && endsBlankBlock(source);
|
|
12169
12177
|
const appendedBlock = appended.replace(/^(?:\r\n|\r|\n)+/u, "");
|
|
12170
12178
|
const appendedStartsTopLevelBlock = previousEndedBlankBlock && /^[^\t \r\n]/u.test(appendedBlock) && !MARKDOWN_CONTAINER_LINE_RE.test(appendedBlock);
|
|
12171
12179
|
if (pendingTagProbe && !pendingTagProbe.resolved) {
|
|
@@ -12191,7 +12199,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
12191
12199
|
const heldLineStart = Math.max(source.lastIndexOf("\n", Math.max(0, ownershipStart - 1)), source.lastIndexOf("\r", Math.max(0, ownershipStart - 1))) + 1;
|
|
12192
12200
|
const heldLineEnd = findNextLineEnding(source, ownershipStart);
|
|
12193
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);
|
|
12194
|
-
const completedBlankBlock =
|
|
12202
|
+
const completedBlankBlock = endedBlankBlock;
|
|
12195
12203
|
const retainedContainerContext = MARKDOWN_CONTAINER_LINE_RE.test(source.slice(nonFinalRetainStart));
|
|
12196
12204
|
const heldBacktick = heldBacktickStart !== void 0;
|
|
12197
12205
|
let openingRunEnd = ownershipStart;
|
|
@@ -12216,8 +12224,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
12216
12224
|
const stableNonDelimiter = heldBacktick && heldCodeSpan === void 0 && completedBlankBlock;
|
|
12217
12225
|
if (!heldBacktick && !heldInOpenEndedCode || stableCode || stableNonDelimiter) {
|
|
12218
12226
|
let processEnd = source.length;
|
|
12219
|
-
if (stableNonDelimiter) processEnd = source.length;
|
|
12220
|
-
else if (mayCloseTopLevelBlock) processEnd = source.length;
|
|
12227
|
+
if (stableNonDelimiter || mayCloseTopLevelBlock) processEnd = source.length;
|
|
12221
12228
|
else if (stableCode && heldCodeSpan) {
|
|
12222
12229
|
processEnd = heldCodeSpan[1];
|
|
12223
12230
|
while (processEnd < source.length) {
|
|
@@ -12241,7 +12248,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
12241
12248
|
}
|
|
12242
12249
|
}
|
|
12243
12250
|
}
|
|
12244
|
-
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) {
|
|
12245
12252
|
nonFinalFullParses += 1;
|
|
12246
12253
|
const ownership = parseMarkdownOwnership(source);
|
|
12247
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 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as requiresClaudeMandatoryAdaptiveThinking, p as resolveClaudeNativeThinkingLevelMap, t as calculateUsageCost } from "./src-
|
|
1
|
+
import { l as requiresClaudeMandatoryAdaptiveThinking, p as resolveClaudeNativeThinkingLevelMap, t as calculateUsageCost } from "./src-B2Q_6G8V.mjs";
|
|
2
2
|
//#region packages/ai/src/model-utils.ts
|
|
3
3
|
/** Calculates and stores model cost fields from token usage and per-million pricing. */
|
|
4
4
|
function calculateCost(model, usage) {
|
|
@@ -0,0 +1,20 @@
|
|
|
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 ([model.headers, options.headers].some((headers) => Object.keys(headers ?? {}).some((name) => name.toLowerCase() === "x-opencode-session"))) return options.headers;
|
|
14
|
+
return {
|
|
15
|
+
...options.headers,
|
|
16
|
+
"x-opencode-session": options.sessionId
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { resolveOpencodeSessionHeaders as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as sanitizeSurrogates } from "./sanitize-unicode-
|
|
3
|
-
import { r as copyProviderAcceptanceObserver } from "./transport-stream-shared-
|
|
1
|
+
import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.mjs";
|
|
2
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-Bb-v9meu.mjs";
|
|
3
|
+
import { r as copyProviderAcceptanceObserver } from "./transport-stream-shared-Cu3ZPhNW.mjs";
|
|
4
4
|
//#region packages/ai/src/utils/prompt-cache-stability.ts
|
|
5
5
|
/**
|
|
6
6
|
* Prompt-cache normalization helpers. They keep generated prompt sections
|
package/dist/{stream-first-event-timeout-DcNjoFQE.mjs → stream-first-event-timeout-2hfrquuz.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as clampTimerTimeoutMs } from "./base64-D-su8YVo.mjs";
|
|
2
2
|
//#region packages/ai/src/utils/stream-first-event-timeout.ts
|
|
3
3
|
function getFirstStreamEventTimeoutMs(options) {
|
|
4
4
|
return options?.firstEventTimeoutMs;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region packages/normalization-core/src/string-coerce.ts
|
|
2
|
+
/** Reads a value only when it is already a string, preserving whitespace. */
|
|
3
|
+
function readStringValue(value) {
|
|
4
|
+
return typeof value === "string" ? value : void 0;
|
|
5
|
+
}
|
|
6
|
+
/** Trims string input and returns null for non-strings or empty strings. */
|
|
7
|
+
function normalizeNullableString(value) {
|
|
8
|
+
if (typeof value !== "string") return null;
|
|
9
|
+
const trimmed = value.trim();
|
|
10
|
+
return trimmed ? trimmed : null;
|
|
11
|
+
}
|
|
12
|
+
/** Trims string input and returns undefined for non-strings or empty strings. */
|
|
13
|
+
function normalizeOptionalString(value) {
|
|
14
|
+
return normalizeNullableString(value) ?? void 0;
|
|
15
|
+
}
|
|
16
|
+
/** Stringifies primitive ids/flags before applying optional string normalization. */
|
|
17
|
+
function normalizeStringifiedOptionalString(value) {
|
|
18
|
+
if (typeof value === "string") return normalizeOptionalString(value);
|
|
19
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return normalizeOptionalString(String(value));
|
|
20
|
+
}
|
|
21
|
+
/** Lowercases a normalized optional string. */
|
|
22
|
+
function normalizeOptionalLowercaseString(value) {
|
|
23
|
+
return normalizeOptionalString(value)?.toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
/** Lowercases a normalized string or returns an empty string when absent. */
|
|
26
|
+
function normalizeLowercaseStringOrEmpty(value) {
|
|
27
|
+
return normalizeOptionalLowercaseString(value) ?? "";
|
|
28
|
+
}
|
|
29
|
+
/** Type guard for strings that remain non-empty after trimming. */
|
|
30
|
+
function hasNonEmptyString(value) {
|
|
31
|
+
return normalizeOptionalString(value) !== void 0;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { normalizeOptionalString as a, normalizeOptionalLowercaseString as i, normalizeLowercaseStringOrEmpty as n, normalizeStringifiedOptionalString as o, normalizeNullableString as r, readStringValue as s, hasNonEmptyString as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as normalizeOptionalString } from "./string-coerce-fsri9iCu.mjs";
|
|
2
2
|
//#region packages/normalization-core/src/string-normalization.ts
|
|
3
3
|
/** Coerces entries to strings, trims them, and drops empty results. */
|
|
4
4
|
function normalizeStringEntries(list) {
|
package/dist/{tool-schema-json-projection-mJhXDcyz.mjs → tool-schema-json-projection-ClptDdAO.mjs}
RENAMED
|
@@ -1,41 +1,5 @@
|
|
|
1
|
-
import { o as isRecord } from "./
|
|
2
|
-
import { n as getAiTransportHost } from "./host-CEvLw30U.mjs";
|
|
1
|
+
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
3
2
|
import { types } from "node:util";
|
|
4
|
-
//#region packages/ai/src/transports/host-policy.ts
|
|
5
|
-
function buildGuardedModelFetch(model, timeoutMs, options) {
|
|
6
|
-
const host = getAiTransportHost();
|
|
7
|
-
if (options !== void 0) return host.buildModelFetch(model, timeoutMs, options) ?? globalThis.fetch;
|
|
8
|
-
if (timeoutMs !== void 0) return host.buildModelFetch(model, timeoutMs) ?? globalThis.fetch;
|
|
9
|
-
return host.buildModelFetch(model) ?? globalThis.fetch;
|
|
10
|
-
}
|
|
11
|
-
function resolveProviderEndpoint(model) {
|
|
12
|
-
return { endpointClass: getAiTransportHost().resolveProviderRequestCapabilities({
|
|
13
|
-
baseUrl: model.baseUrl,
|
|
14
|
-
model
|
|
15
|
-
}).endpointClass };
|
|
16
|
-
}
|
|
17
|
-
function resolveProviderRequestCapabilities(input, model) {
|
|
18
|
-
return getAiTransportHost().resolveProviderRequestCapabilities({
|
|
19
|
-
...input,
|
|
20
|
-
model
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function resolveProviderRequestPolicyConfig(model, input) {
|
|
24
|
-
return { headers: getAiTransportHost().resolveProviderRequestHeaders({
|
|
25
|
-
...input,
|
|
26
|
-
model
|
|
27
|
-
}) };
|
|
28
|
-
}
|
|
29
|
-
function resolveModelRequestTimeoutMs(model, timeoutMs) {
|
|
30
|
-
return timeoutMs ?? getAiTransportHost().resolveModelRequestTimeoutMs(model);
|
|
31
|
-
}
|
|
32
|
-
function resolveOpenAIStrictToolSetting(model, options) {
|
|
33
|
-
return getAiTransportHost().resolveOpenAIStrictToolSetting(model, options);
|
|
34
|
-
}
|
|
35
|
-
function transformTransportMessages(messages, model, normalizeToolCallId, options) {
|
|
36
|
-
return getAiTransportHost().transformTransportMessages(messages, model, normalizeToolCallId, options);
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
3
|
//#region packages/ai/src/providers/tool-schema-json-projection.ts
|
|
40
4
|
function isNonFiniteNumberValue(value) {
|
|
41
5
|
if (typeof value === "number") return !Number.isFinite(value);
|
|
@@ -115,4 +79,4 @@ function projectRuntimeToolInputSchema(schema, path = "parameters") {
|
|
|
115
79
|
};
|
|
116
80
|
}
|
|
117
81
|
//#endregion
|
|
118
|
-
export {
|
|
82
|
+
export { projectRuntimeToolInputSchema as t };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-CPeq9F7y.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { n as projectProviderError, r as projectDiagnosticValue } from "./provider-error-
|
|
6
|
-
import {
|
|
2
|
+
import { i as createAssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
3
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-Bb-v9meu.mjs";
|
|
4
|
+
import { i as asOptionalRecord, n as asNullableRecord, t as asNonArrayRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
5
|
+
import { n as projectProviderError, r as projectDiagnosticValue } from "./provider-error-C6TbKiey.mjs";
|
|
6
|
+
import { c as isTransientNetworkError } from "./diagnostics-dV98PqIy.mjs";
|
|
7
7
|
//#region packages/ai/src/utils/headers.ts
|
|
8
8
|
/** Converts a Headers object to a plain record for provider request handling. */
|
|
9
9
|
function headersToRecord(headers) {
|
package/dist/{transport-stream-shared-xnaqxmbP.d.mts → transport-stream-shared-DOxpGJ-H.d.mts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { B as ProviderResponse, D as Model, J as StreamOptions, a as AssistantMessage, at as Usage } from "./types-
|
|
3
|
-
import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
4
|
-
import "./event-stream-
|
|
1
|
+
import "./index-CQ6LTHw8.mjs";
|
|
2
|
+
import { B as ProviderResponse, D as Model, J as StreamOptions, a as AssistantMessage, at as Usage } from "./types-Dy1q0CSu.mjs";
|
|
3
|
+
import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-C1Z2piyk.mjs";
|
|
4
|
+
import "./event-stream-I_GlBsuZ.mjs";
|
|
5
5
|
import { t as ProviderErrorProjection } from "./provider-error-CzNw4BWX.mjs";
|
|
6
6
|
//#region packages/ai/src/utils/stream-first-event-timeout.d.ts
|
|
7
7
|
type StreamStage = "responses" | "completions";
|