@openclaw/ai 2026.9.4 → 2026.9.6
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 +1 -1
- package/dist/{anthropic-C4Qu4H0Z.mjs → anthropic-DZQ_7gD1.mjs} +37 -38
- package/dist/{anthropic-payload-policy-BZ8umAbk.d.mts → anthropic-payload-policy-DyfwikYJ.d.mts} +4 -4
- package/dist/{anthropic-stream-reducer-CILWF7JD.mjs → anthropic-stream-reducer-D6ZI1wwj.mjs} +70 -50
- package/dist/{api-registry-ByUwIR0e.d.mts → api-registry-C2T3lTV7.d.mts} +2 -2
- package/dist/{assistant-output-tLt4H-iQ.mjs → assistant-output-DM1JBNs1.mjs} +1 -1
- package/dist/{azure-openai-responses-BAlqlKKc.mjs → azure-openai-responses-DS86GYzq.mjs} +6 -9
- package/dist/{base64-D-su8YVo.mjs → base64-CPmadnUf.mjs} +12 -12
- package/dist/credential-redaction-BKv49aiv.d.mts +24 -0
- package/dist/{diagnostics-QuErwCIl.mjs → diagnostics-CH8j2wIG.mjs} +139 -7
- package/dist/{diagnostics-CPeq9F7y.mjs → diagnostics-DzrF1h4J.mjs} +18 -1
- package/dist/diagnostics.d.mts +11 -24
- package/dist/diagnostics.mjs +4 -4
- package/dist/event-stream-C0nsgbj2.d.mts +1 -0
- package/dist/{event-stream-Bt5Y4Pav.d.mts → event-stream-CjnIZZst.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/expect-lbe3Hgrh.mjs +8 -0
- package/dist/{google-DPBAOaOW.mjs → google-BZJFjhuC.mjs} +6 -9
- package/dist/{google-messages-6JkpHrhJ.mjs → google-messages-DB7GKkDk.mjs} +3 -3
- package/dist/{google-shared-BvBeW9aq.mjs → google-shared-Bok4I6zB.mjs} +13 -13
- package/dist/{google-vertex-k-TMCAYD.mjs → google-vertex-3eVNR2qW.mjs} +5 -8
- package/dist/{host-4atIX-2V.d.mts → host-DH-Z-LDb.d.mts} +5 -3
- package/dist/{host-policy-Zcg_cNz8.mjs → host-policy-DZO3oPPk.mjs} +1 -1
- package/dist/{host-B8YfDGd4.mjs → host-yTvBrYM2.mjs} +63 -31
- package/dist/{index-DdD3qerf.d.mts → index-C25RT6bP.d.mts} +37 -14
- package/dist/index.d.mts +7 -8
- package/dist/index.mjs +5 -6
- package/dist/internal/anthropic.d.mts +13 -10
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-completions-compat.d.mts +2 -0
- package/dist/internal/openai-completions-compat.mjs +2 -0
- package/dist/internal/openai-responses-payload-policy.d.mts +2 -2
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +24 -53
- package/dist/internal/openai.mjs +12 -9
- package/dist/internal/runtime.d.mts +6 -8
- package/dist/internal/runtime.mjs +6 -10
- package/dist/internal/shared.d.mts +7 -5
- package/dist/internal/shared.mjs +4 -3
- package/dist/internal/tool-schema.d.mts +4 -4
- package/dist/internal/tool-schema.mjs +2 -2
- package/dist/{mistral-CxUZ1jUb.mjs → mistral-C_13dVBn.mjs} +9 -13
- package/dist/{model-transport-url-DKocrEsb.d.mts → model-transport-url-C5f59L3Y.d.mts} +1 -1
- package/dist/{openai-chatgpt-responses-CgO6kZfo.mjs → openai-chatgpt-responses-sTxPl4zM.mjs} +150 -83
- package/dist/{openai-completions-yJuk7eis.mjs → openai-completions-BO6D_hrB.mjs} +11 -12
- package/dist/{openai-prompt-cache-Bds-n_9Q.mjs → openai-completions-compat-CUollwl6.mjs} +5 -50
- package/dist/{openai-completions-compat-eHgh5UPE.d.mts → openai-completions-compat-DfJG1wSO.d.mts} +4 -4
- package/dist/{openai-completions-stream-Da2vvl-S.mjs → openai-completions-stream-BpuJ0ZOA.mjs} +117 -106
- package/dist/{openai-prompt-cache-B4eYo2-I.d.mts → openai-prompt-cache-C4RHdN4n.d.mts} +2 -2
- package/dist/openai-prompt-cache-CjV_2IRI.mjs +46 -0
- package/dist/{openai-provider-client-S2gCrM2Z.mjs → openai-provider-client-BP8J1aeg.mjs} +2 -2
- package/dist/openai-reasoning-effort-ash8dPrd.mjs +243 -0
- package/dist/{openai-responses-DaYwH05E.mjs → openai-responses-BJ_IEoMU.mjs} +8 -12
- package/dist/{openai-responses-compaction-window-CIhBAkkq.mjs → openai-responses-compaction-window-BiNCT0bS.mjs} +20 -62
- package/dist/{openai-responses-contracts-BjBAqAg_.d.mts → openai-responses-contracts-B1ENJFpI.d.mts} +9 -5
- package/dist/openai-responses-contracts-DWrfMODE.mjs +81 -0
- package/dist/{openai-responses-payload-policy-rLRPsSmB.d.mts → openai-responses-payload-policy-C7GsA1y0.d.mts} +5 -3
- package/dist/openai-responses-prompt-observer-internal-DPHWgbBH.mjs +198 -0
- package/dist/openai-responses-request-lifecycle-DFuyO1pQ.mjs +36 -0
- package/dist/{openai-responses-shared-B8RdBPCv.mjs → openai-responses-shared-DvSqtJ6_.mjs} +859 -581
- package/dist/openai-responses-terminal-usage-BNFbvY9f.d.mts +47 -0
- package/dist/{openai-tool-schema-CzjyYXun.mjs → openai-tool-schema-D4BMcj2D.mjs} +262 -162
- package/dist/{openai-transport-params-9aPuV5YY.mjs → openai-transport-params-DZKOTSfH.mjs} +157 -47
- package/dist/{positive-integer-41zhOdcV.mjs → positive-integer-BiUxrd71.mjs} +1 -1
- package/dist/{provider-error-BA-v_tKd.mjs → provider-error-CRhW7lkJ.mjs} +139 -44
- package/dist/{provider-error-CzNw4BWX.d.mts → provider-error-xumb1V3F.d.mts} +3 -1
- package/dist/{provider-options-Ceqv1OKk.d.mts → provider-options-DZYq53lj.d.mts} +12 -7
- package/dist/{provider-replay-context-CJ_YvcEW.mjs → provider-replay-context-DPr3w20a.mjs} +1 -1
- package/dist/{provider-transcript-transform-V5YzU9zh.mjs → provider-transcript-transform-BTocjCRs.mjs} +1 -1
- package/dist/{provider-transport-turn-state-D5EXOFL2.mjs → provider-transport-turn-state-lrXEFkYr.mjs} +1 -1
- package/dist/{provider-types-CVjKjsuq.d.mts → provider-types-w1rEqrGP.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -7
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +10 -10
- package/dist/{reasoning-tag-text-partitioner-BcR5pztD.mjs → reasoning-tag-text-partitioner-Di38crhI.mjs} +167 -40
- package/dist/{simple-options-BQbb4yQL.mjs → simple-options-np1XPuhm.mjs} +5 -3
- package/dist/{usage-cost-BNWbbXav.mjs → src-DwGYYyZp.mjs} +18 -11
- package/dist/{stream-first-event-timeout-2hfrquuz.mjs → stream-first-event-timeout-BeptfRL6.mjs} +1 -1
- package/dist/{string-normalization-CmLIasuf.mjs → string-normalization-J9ZiLfGO.mjs} +13 -1
- package/dist/tool-schema-json-projection-CD9c_fK8.mjs +134 -0
- package/dist/{transport-stream-shared-zHll9BxO.mjs → transport-stream-shared-B5RioB_Q.mjs} +16 -24
- package/dist/{transport-stream-shared-DNvmoWnv.d.mts → transport-stream-shared-B7Z9oCYg.d.mts} +5 -5
- package/dist/{transport-utils-zrYjICLZ.mjs → transport-utils-03Qi0CN2.mjs} +3 -3
- package/dist/transports.d.mts +27 -13
- package/dist/transports.mjs +168 -462
- package/dist/types-DTvddOfm.d.mts +1 -0
- package/dist/{types-Ntv5z2g2.d.mts → types-qZFbaDbK.d.mts} +49 -3
- package/dist/types.d.mts +6 -7
- package/dist/types.mjs +4 -5
- package/dist/{validation-B0t_G2H6.d.mts → validation-DhQhmt6t.d.mts} +1 -1
- package/dist/{validation-BDzVDnTs.mjs → validation-Dw7cb6BV.mjs} +1 -0
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +11 -6
- package/dist/diagnostics-DnPnOui6.d.mts +0 -29
- package/dist/event-stream-C3WGFsum.d.mts +0 -1
- package/dist/openai-responses-contracts-DDOHA62Y.mjs +0 -245
- package/dist/openai-responses-prompt-observer-internal-f8J7wpsk.mjs +0 -32
- package/dist/src-DDmEryvj.mjs +0 -2
- package/dist/tool-schema-json-projection-ClptDdAO.mjs +0 -82
- package/dist/types-DlfwzH3T.d.mts +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Y as StreamOptions } from "./types-
|
|
1
|
+
import { Y as StreamOptions } from "./types-qZFbaDbK.mjs";
|
|
2
2
|
import { t as OpenAICompletionsToolChoice } from "./openai-tool-projection-793cE3QX.mjs";
|
|
3
|
-
import "./types-
|
|
3
|
+
import "./types-DTvddOfm.mjs";
|
|
4
4
|
import Anthropic from "@anthropic-ai/sdk";
|
|
5
5
|
//#region packages/ai/src/providers/openai-reasoning-effort.d.ts
|
|
6
|
-
|
|
6
|
+
declare const ENABLED_REASONING_EFFORTS: readonly ["minimal", "low", "medium", "high", "xhigh", "max"];
|
|
7
|
+
type OpenAIReasoningEffort = "none" | (typeof ENABLED_REASONING_EFFORTS)[number];
|
|
7
8
|
type OpenAIApiReasoningEffort = OpenAIReasoningEffort | (string & {});
|
|
8
9
|
type OpenAIReasoningModel = {
|
|
9
10
|
provider?: unknown;
|
|
@@ -19,6 +20,8 @@ declare function isOpenAIGpt54MiniModel(model: OpenAIReasoningModel): boolean;
|
|
|
19
20
|
declare function isOpenAIGpt55Model(model: OpenAIReasoningModel): boolean;
|
|
20
21
|
/** Return whether a model is the GPT-5.6 family. */
|
|
21
22
|
declare function isOpenAIGpt56Model(model: OpenAIReasoningModel): boolean;
|
|
23
|
+
/** Return whether a model has a known GPT-6 reasoning and sampling contract. */
|
|
24
|
+
declare function isOpenAIGpt6Model(model: OpenAIReasoningModel): boolean;
|
|
22
25
|
/** Normalize user-facing reasoning effort names to API effort names. */
|
|
23
26
|
declare function normalizeOpenAIReasoningEffort(effort: string): string;
|
|
24
27
|
/** Resolve the reasoning efforts accepted by a specific OpenAI-compatible model. */
|
|
@@ -26,12 +29,14 @@ declare function resolveOpenAISupportedReasoningEfforts(model: OpenAIReasoningMo
|
|
|
26
29
|
/** Read a declared or known model contract, leaving unknown compatible models unspecified. */
|
|
27
30
|
declare function resolveOpenAIModelReasoningEfforts(model: OpenAIReasoningModel): readonly OpenAIApiReasoningEffort[] | undefined;
|
|
28
31
|
/**
|
|
29
|
-
* Return whether a model accepts temperature. GPT-5.6 and GPT-6
|
|
32
|
+
* Return whether a model accepts temperature. GPT-5.6 and known GPT-6 models
|
|
30
33
|
* reject it with a 400; catalog compat can override per model.
|
|
31
34
|
*/
|
|
32
35
|
declare function supportsOpenAITemperature(model: OpenAIReasoningModel): boolean;
|
|
33
36
|
/** Return whether a model accepts a requested reasoning effort. */
|
|
34
37
|
declare function supportsOpenAIReasoningEffort(model: OpenAIReasoningModel, effort: string): boolean;
|
|
38
|
+
/** Read provider mappings without folding provider-native labels. */
|
|
39
|
+
declare function resolveOpenAIReasoningEffortMapping(effort: string, mapping: Record<string, string> | undefined): string | undefined;
|
|
35
40
|
/** Resolve a requested reasoning effort to the closest value supported by the model. */
|
|
36
41
|
declare function resolveOpenAIReasoningEffortForModel(params: {
|
|
37
42
|
model: OpenAIReasoningModel;
|
|
@@ -139,8 +144,8 @@ type BaseOpenAIStreamOptions = StreamOptions & {
|
|
|
139
144
|
/** Superset retained under the provider's published compatibility type name. */
|
|
140
145
|
type OpenAICompletionsOptions = BaseOpenAIStreamOptions & {
|
|
141
146
|
toolChoice?: OpenAICompletionsToolChoice;
|
|
142
|
-
reasoning?: OpenAIReasoningEffort;
|
|
143
|
-
reasoningEffort?: OpenAIReasoningEffort;
|
|
147
|
+
reasoning?: OpenAIReasoningEffort | "off";
|
|
148
|
+
reasoningEffort?: OpenAIReasoningEffort | "off";
|
|
144
149
|
};
|
|
145
150
|
//#endregion
|
|
146
|
-
export {
|
|
151
|
+
export { supportsOpenAITemperature as C, supportsOpenAIReasoningEffort as S, normalizeOpenAIReasoningEffort as _, BaseOpenAIStreamOptions as a, resolveOpenAIReasoningEffortMapping as b, OpenAIResponsesCompactionRejection as c, OpenAIApiReasoningEffort as d, OpenAIReasoningEffort as f, isOpenAIGpt6Model 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, resolveOpenAIModelReasoningEfforts as v, resolveOpenAISupportedReasoningEfforts as x, resolveOpenAIReasoningEffortForModel as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { O as shortHash } from "./transport-stream-shared-B5RioB_Q.mjs";
|
|
2
2
|
//#region packages/ai/src/transports/provider-replay-context.ts
|
|
3
3
|
function hashReplayContextValue(value) {
|
|
4
4
|
const normalized = value?.trim();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as transformMessages } from "./host-
|
|
1
|
+
import { i as transformMessages } from "./host-yTvBrYM2.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)";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as getAiTransportHost } from "./host-
|
|
1
|
+
import { n as getAiTransportHost } from "./host-yTvBrYM2.mjs";
|
|
2
2
|
import { n as resolveOpencodeSessionHeaders, t as hasOpencodeSessionHeader } from "./session-affinity-Bcunsn4I.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
//#region packages/ai/src/transports/provider-transport-turn-state.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as index_d_exports } from "./index-
|
|
2
|
-
import { O as Model, X as TextContent, Y as StreamOptions, a as AssistantMessage, d as Context, f as ImageContent, it as ToolResultMessage, n as Api, s as AssistantMessageEventStreamContract, st as UserMessage } from "./types-
|
|
3
|
-
import "./types-
|
|
1
|
+
import { t as index_d_exports } from "./index-C25RT6bP.mjs";
|
|
2
|
+
import { O as Model, X as TextContent, Y as StreamOptions, a as AssistantMessage, d as Context, f as ImageContent, it as ToolResultMessage, n as Api, s as AssistantMessageEventStreamContract, st as UserMessage } from "./types-qZFbaDbK.mjs";
|
|
3
|
+
import "./types-DTvddOfm.mjs";
|
|
4
4
|
//#region packages/ai/src/provider-types.d.ts
|
|
5
5
|
declare const PROVIDER_CONTEXT_HANDOFF: unique symbol;
|
|
6
6
|
type VideoContent = Omit<ImageContent, "type"> & {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { $ as ThinkingContent, A as ModelCostRates, B as ProviderReplayState, C as KnownImagesApi, E as MaybePromise, F as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, G as SimpleStreamOptions, I as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, K as StopReason, L as PricingTier, M as OpenAICompletionsCompat, N as OpenAIResponsesCompat, P as OpenRouterRouting, Q as ThinkingBudgets, R as Provider, S as KnownApi, T as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, U as RawModelCostConfig, V as ProviderResponse, W as RawPricingTier, X as TextContent, Y as StreamOptions, Z as TextSignatureV1, _ as ImagesModel, a as AssistantMessage, at as Transport, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as ValidateToolArgumentsFn, et as ThinkingLevel, f as ImageContent, g as ImagesInputContent, h as ImagesFunction, i as AssistantImages, it as ToolResultMessage, j as ModelThinkingLevel, k as ModelCostConfig, l as CacheRetention, lt as VercelGatewayRouting, m as ImagesContext, n as Api, nt as Tool, o as AssistantMessageEvent, ot as Usage, p as ImagesApi, q as StreamFn, r as AssistantDeliveryTtsFacts, rt as ToolCall, s as AssistantMessageEventStreamContract, st as UserMessage, t as AnthropicMessagesCompat, tt as ThinkingLevelMap, u as CompleteSimpleFn, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderImagesOptions } from "./types-
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import { n as
|
|
6
|
-
|
|
7
|
-
export { type AnthropicMessagesCompat, type Api, type AssistantDeliveryTtsFacts, type AssistantImages, type AssistantMessage, type AssistantMessageDiagnostic, type AssistantMessageEvent, type AssistantMessageEventStream, type AssistantMessageEventStreamContract, type AssistantMessageEventStreamLike, type CLAUDE_FABLE_5_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DiagnosticErrorInfo, type EventStream, type ImageContent, type ImagesApi, type ImagesContext, type ImagesFunction, type ImagesInputContent, type ImagesModel, type ImagesOptions, type ImagesOutputContent, type ImagesProvider, type ImagesStopReason, type KnownApi, type KnownImagesApi, type KnownImagesProvider, type MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, type MaybePromise, MediaContent, type ProviderMessage as Message, ProviderMessage, type ProviderModel as Model, ProviderModel, type ModelCostConfig, type ModelCostRates, ModelInputContent, type ModelThinkingLevel, type OpenAICompletionsCompat, type OpenAIResponsesCompat, type OpenRouterRouting, PROVIDER_CONTEXT_HANDOFF, type PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, type PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, type PricingTier, type Provider, ProviderContextHandoff, type ProviderImagesOptions, type ProviderReplayState, type ProviderResponse, ProviderStreamFunction, type ProviderStreamFunction as StreamFunction, ProviderStreamOptions, ProviderUserMessage, type RawModelCostConfig, type RawPricingTier, type SimpleStreamOptions, type StopReason, type StreamFn, type StreamOptions, type TextContent, type TextSignatureV1, type ThinkingBudgets, type ThinkingContent, type ThinkingLevel, type ThinkingLevelMap, type Tool, type ToolCall, type ToolResultMessage, type Transport, type Usage, type UserMessage, type ValidateToolArgumentsFn, type VercelGatewayRouting, VideoContent, type appendAssistantMessageDiagnostic, type bindsClaudeThinkingPrefix, type calculateUsageCost, type createAssistantMessageDiagnostic, type createAssistantMessageEventStream, type extractDiagnosticError, type formatThrownValue, type isProviderRefusalAssistantError, type normalizeModelCostConfig, type normalizeResolvedPricing, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeNativeMaxEffort, type supportsClaudeNativeXhighEffort, type validateToolArguments, type validateToolCall };
|
|
1
|
+
import { C as supportsClaudeFastMode, S as supportsClaudeAdaptiveThinking, T as supportsClaudeNativeXhighEffort, _ as resolveClaudeNativeThinkingLevelMap, a as ProviderRefusalReview, b as resolveClaudeSonnet5ModelIdentity, c as CLAUDE_OPUS_55_THINKING_PROFILE, d as bindsClaudeThinkingPrefix, f as requiresClaudeDefaultSampling, g as resolveClaudeMythos5ModelIdentity, h as resolveClaudeModelIdentity, i as normalizeResolvedPricing, l as CLAUDE_OPUS_5_THINKING_PROFILE, m as resolveClaudeFable5ModelIdentity, n as calculateUsageCost, o as readProviderRefusalReview, p as requiresClaudeMandatoryAdaptiveThinking, r as normalizeModelCostConfig, s as CLAUDE_FABLE_5_THINKING_PROFILE, u as CLAUDE_SONNET_5_THINKING_PROFILE, v as resolveClaudeOpus55ModelIdentity, w as supportsClaudeNativeMaxEffort, x as supportsClaude1MContext, y as resolveClaudeOpus5ModelIdentity } from "./index-C25RT6bP.mjs";
|
|
2
|
+
import { $ as ThinkingContent, A as ModelCostRates, B as ProviderReplayState, C as KnownImagesApi, E as MaybePromise, F as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, G as SimpleStreamOptions, I as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, K as StopReason, L as PricingTier, M as OpenAICompletionsCompat, N as OpenAIResponsesCompat, P as OpenRouterRouting, Q as ThinkingBudgets, R as Provider, S as KnownApi, T as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, U as RawModelCostConfig, V as ProviderResponse, W as RawPricingTier, X as TextContent, Y as StreamOptions, Z as TextSignatureV1, _ as ImagesModel, a as AssistantMessage, at as Transport, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as ValidateToolArgumentsFn, dt as DiagnosticErrorInfo, et as ThinkingLevel, f as ImageContent, ft as appendAssistantMessageDiagnostic, g as ImagesInputContent, gt as isProviderRefusalAssistantError, h as ImagesFunction, ht as formatThrownValue, i as AssistantImages, it as ToolResultMessage, j as ModelThinkingLevel, k as ModelCostConfig, l as CacheRetention, lt as VercelGatewayRouting, m as ImagesContext, mt as extractDiagnosticError, n as Api, nt as Tool, o as AssistantMessageEvent, ot as Usage, p as ImagesApi, pt as createAssistantMessageDiagnostic, q as StreamFn, r as AssistantDeliveryTtsFacts, rt as ToolCall, s as AssistantMessageEventStreamContract, st as UserMessage, t as AnthropicMessagesCompat, tt as ThinkingLevelMap, u as CompleteSimpleFn, ut as AssistantMessageDiagnostic, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderImagesOptions } from "./types-qZFbaDbK.mjs";
|
|
3
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-CjnIZZst.mjs";
|
|
4
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-DhQhmt6t.mjs";
|
|
5
|
+
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-w1rEqrGP.mjs";
|
|
6
|
+
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_55_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DiagnosticErrorInfo, type EventStream, type ImageContent, type ImagesApi, type ImagesContext, type ImagesFunction, type ImagesInputContent, type ImagesModel, type ImagesOptions, type ImagesOutputContent, type ImagesProvider, type ImagesStopReason, type KnownApi, type KnownImagesApi, type KnownImagesProvider, type MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, type MaybePromise, MediaContent, type ProviderMessage as Message, ProviderMessage, type ProviderModel as Model, ProviderModel, type ModelCostConfig, type ModelCostRates, ModelInputContent, type ModelThinkingLevel, type OpenAICompletionsCompat, type OpenAIResponsesCompat, type OpenRouterRouting, PROVIDER_CONTEXT_HANDOFF, type PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, type PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, type PricingTier, type Provider, ProviderContextHandoff, type ProviderImagesOptions, type ProviderRefusalReview, 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 readProviderRefusalReview, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus55ModelIdentity, 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-C2T3lTV7.mjs";
|
|
2
|
+
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-C4RHdN4n.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
1
|
import { t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
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-
|
|
2
|
+
import { n as projectProviderError } from "./provider-error-CRhW7lkJ.mjs";
|
|
3
|
+
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-CjV_2IRI.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-DZQ_7gD1.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-BO6D_hrB.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-C_13dVBn.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-BJ_IEoMU.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-DS86GYzq.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-sTxPl4zM.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-BZJFjhuC.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-3eVNR2qW.mjs"), (module) => ({
|
|
94
94
|
stream: module.streamGoogleVertex,
|
|
95
95
|
streamSimple: module.streamSimpleGoogleVertex
|
|
96
96
|
}))
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import
|
|
2
|
+
import "./provider-error-CRhW7lkJ.mjs";
|
|
3
|
+
import { t as expectDefined } from "./expect-lbe3Hgrh.mjs";
|
|
3
4
|
//#region node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
|
|
4
5
|
/**
|
|
5
6
|
* @typedef {import('mdast').Nodes} Nodes
|
|
@@ -10750,7 +10751,7 @@ function replace($0, $1) {
|
|
|
10750
10751
|
return $1 === "|" ? $1 : $0;
|
|
10751
10752
|
}
|
|
10752
10753
|
//#endregion
|
|
10753
|
-
//#region node_modules/.pnpm/micromark-extension-gfm-table@2.1.
|
|
10754
|
+
//#region node_modules/.pnpm/micromark-extension-gfm-table@2.1.2/node_modules/micromark-extension-gfm-table/lib/edit-map.js
|
|
10754
10755
|
/**
|
|
10755
10756
|
* @import {Event} from 'micromark-util-types'
|
|
10756
10757
|
*/
|
|
@@ -10772,14 +10773,25 @@ var EditMap = class {
|
|
|
10772
10773
|
* @type {Array<Change>}
|
|
10773
10774
|
*/
|
|
10774
10775
|
this.map = [];
|
|
10776
|
+
/**
|
|
10777
|
+
* Changes by index, so `add` does not scan `map` (quadratic on
|
|
10778
|
+
* table-heavy documents).
|
|
10779
|
+
*
|
|
10780
|
+
* @type {Map<number, Change>}
|
|
10781
|
+
*/
|
|
10782
|
+
this.index = /* @__PURE__ */ new Map();
|
|
10775
10783
|
}
|
|
10776
10784
|
/**
|
|
10777
10785
|
* Create an edit: a remove and/or add at a certain place.
|
|
10778
10786
|
*
|
|
10779
10787
|
* @param {number} index
|
|
10788
|
+
* Index at which to apply the edit.
|
|
10780
10789
|
* @param {number} remove
|
|
10790
|
+
* Count of items to remove at the index.
|
|
10781
10791
|
* @param {Array<Event>} add
|
|
10792
|
+
* Items to add at the index.
|
|
10782
10793
|
* @returns {undefined}
|
|
10794
|
+
* Nothing.
|
|
10783
10795
|
*/
|
|
10784
10796
|
add(index, remove, add) {
|
|
10785
10797
|
addImplementation(this, index, remove, add);
|
|
@@ -10788,7 +10800,9 @@ var EditMap = class {
|
|
|
10788
10800
|
* Done, change the events.
|
|
10789
10801
|
*
|
|
10790
10802
|
* @param {Array<Event>} events
|
|
10803
|
+
* List of events to apply the edits to.
|
|
10791
10804
|
* @returns {undefined}
|
|
10805
|
+
* Nothing.
|
|
10792
10806
|
*/
|
|
10793
10807
|
consume(events) {
|
|
10794
10808
|
this.map.sort(function(a, b) {
|
|
@@ -10812,37 +10826,43 @@ var EditMap = class {
|
|
|
10812
10826
|
slice = vecs.pop();
|
|
10813
10827
|
}
|
|
10814
10828
|
this.map.length = 0;
|
|
10829
|
+
this.index.clear();
|
|
10815
10830
|
}
|
|
10816
10831
|
};
|
|
10817
10832
|
/**
|
|
10818
10833
|
* Create an edit.
|
|
10819
10834
|
*
|
|
10820
10835
|
* @param {EditMap} editMap
|
|
10836
|
+
* Edit map to apply to.
|
|
10821
10837
|
* @param {number} at
|
|
10838
|
+
* Index at which to apply the edit.
|
|
10822
10839
|
* @param {number} remove
|
|
10840
|
+
* Count of items to remove at the index.
|
|
10823
10841
|
* @param {Array<Event>} add
|
|
10842
|
+
* Items to add at the index.
|
|
10824
10843
|
* @returns {undefined}
|
|
10844
|
+
* Nothing.
|
|
10825
10845
|
*/
|
|
10826
10846
|
function addImplementation(editMap, at, remove, add) {
|
|
10827
|
-
let index = 0;
|
|
10828
10847
|
/* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */
|
|
10829
10848
|
if (remove === 0 && add.length === 0) return;
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
editMap.map.push([
|
|
10849
|
+
const existing = editMap.index.get(at);
|
|
10850
|
+
if (existing) {
|
|
10851
|
+
existing[1] += remove;
|
|
10852
|
+
existing[2].push(...add);
|
|
10853
|
+
return;
|
|
10854
|
+
}
|
|
10855
|
+
/** @type {Change} */
|
|
10856
|
+
const change = [
|
|
10839
10857
|
at,
|
|
10840
10858
|
remove,
|
|
10841
10859
|
add
|
|
10842
|
-
]
|
|
10860
|
+
];
|
|
10861
|
+
editMap.map.push(change);
|
|
10862
|
+
editMap.index.set(at, change);
|
|
10843
10863
|
}
|
|
10844
10864
|
//#endregion
|
|
10845
|
-
//#region node_modules/.pnpm/micromark-extension-gfm-table@2.1.
|
|
10865
|
+
//#region node_modules/.pnpm/micromark-extension-gfm-table@2.1.2/node_modules/micromark-extension-gfm-table/lib/infer.js
|
|
10846
10866
|
/**
|
|
10847
10867
|
* @import {Event} from 'micromark-util-types'
|
|
10848
10868
|
*/
|
|
@@ -10880,7 +10900,7 @@ function gfmTableAlign(events, index) {
|
|
|
10880
10900
|
return align;
|
|
10881
10901
|
}
|
|
10882
10902
|
//#endregion
|
|
10883
|
-
//#region node_modules/.pnpm/micromark-extension-gfm-table@2.1.
|
|
10903
|
+
//#region node_modules/.pnpm/micromark-extension-gfm-table@2.1.2/node_modules/micromark-extension-gfm-table/lib/syntax.js
|
|
10884
10904
|
/**
|
|
10885
10905
|
* @import {Event, Extension, Point, Resolver, State, Token, TokenizeContext, Tokenizer} from 'micromark-util-types'
|
|
10886
10906
|
*/
|
|
@@ -10906,6 +10926,8 @@ function gfmTable() {
|
|
|
10906
10926
|
} } };
|
|
10907
10927
|
}
|
|
10908
10928
|
/**
|
|
10929
|
+
* Tokenizer for GFM tables.
|
|
10930
|
+
*
|
|
10909
10931
|
* @this {TokenizeContext}
|
|
10910
10932
|
* @type {Tokenizer}
|
|
10911
10933
|
*/
|
|
@@ -10935,7 +10957,7 @@ function tokenizeTable(effects, ok, nok) {
|
|
|
10935
10957
|
function start(code) {
|
|
10936
10958
|
let index = self.events.length - 1;
|
|
10937
10959
|
while (index > -1) {
|
|
10938
|
-
const type = self.events[index][1]
|
|
10960
|
+
const { type } = self.events[index][1];
|
|
10939
10961
|
if (type === "lineEnding" || type === "linePrefix") index--;
|
|
10940
10962
|
else break;
|
|
10941
10963
|
}
|
|
@@ -11464,12 +11486,19 @@ function resolveTable(events, context) {
|
|
|
11464
11486
|
* Generate a cell.
|
|
11465
11487
|
*
|
|
11466
11488
|
* @param {EditMap} map
|
|
11489
|
+
* Edit map to apply to.
|
|
11467
11490
|
* @param {Readonly<TokenizeContext>} context
|
|
11491
|
+
* Tokenize context.
|
|
11468
11492
|
* @param {Readonly<Range>} range
|
|
11493
|
+
* Range of the cell within events.
|
|
11469
11494
|
* @param {RowKind} rowKind
|
|
11495
|
+
* Type of row.
|
|
11470
11496
|
* @param {number | undefined} rowEnd
|
|
11497
|
+
* Index of the end of the row, if known.
|
|
11471
11498
|
* @param {Token | undefined} previousCell
|
|
11499
|
+
* Previous cell token, if any.
|
|
11472
11500
|
* @returns {Token | undefined}
|
|
11501
|
+
* Current cell token after flushing, if any.
|
|
11473
11502
|
*/
|
|
11474
11503
|
function flushCell(map, context, range, rowKind, rowEnd, previousCell) {
|
|
11475
11504
|
const groupName = rowKind === 1 ? "tableHeader" : rowKind === 2 ? "tableDelimiter" : "tableData";
|
|
@@ -11540,10 +11569,17 @@ function flushCell(map, context, range, rowKind, rowEnd, previousCell) {
|
|
|
11540
11569
|
* Generate table end (and table body end).
|
|
11541
11570
|
*
|
|
11542
11571
|
* @param {Readonly<EditMap>} map
|
|
11572
|
+
* Edit map to apply to.
|
|
11543
11573
|
* @param {Readonly<TokenizeContext>} context
|
|
11574
|
+
* Tokenize context.
|
|
11544
11575
|
* @param {number} index
|
|
11576
|
+
* Index within the events where the table end should be inserted.
|
|
11545
11577
|
* @param {Token} table
|
|
11578
|
+
* Table token.
|
|
11546
11579
|
* @param {Token | undefined} tableBody
|
|
11580
|
+
* Table body token, if any.
|
|
11581
|
+
* @returns {undefined}
|
|
11582
|
+
* Nothing.
|
|
11547
11583
|
*/
|
|
11548
11584
|
function flushTableEnd(map, context, index, table, tableBody) {
|
|
11549
11585
|
/** @type {Array<Event>} */
|
|
@@ -11566,9 +11602,14 @@ function flushTableEnd(map, context, index, table, tableBody) {
|
|
|
11566
11602
|
map.add(index + 1, 0, exits);
|
|
11567
11603
|
}
|
|
11568
11604
|
/**
|
|
11605
|
+
* Get the point (start or end) for a given event in the list of events.
|
|
11606
|
+
*
|
|
11569
11607
|
* @param {Readonly<Array<Event>>} events
|
|
11608
|
+
* List of events.
|
|
11570
11609
|
* @param {number} index
|
|
11610
|
+
* Index of the event to get the point for.
|
|
11571
11611
|
* @returns {Readonly<Point>}
|
|
11612
|
+
* Start point for enter and end point for exit.
|
|
11572
11613
|
*/
|
|
11573
11614
|
function getPoint(events, index) {
|
|
11574
11615
|
const event = events[index];
|
|
@@ -11728,41 +11769,124 @@ function captureInlineSources(text, sources) {
|
|
|
11728
11769
|
lineEnding: observe
|
|
11729
11770
|
} };
|
|
11730
11771
|
}
|
|
11772
|
+
function captureIndentedSources(text, sources, observeInlineLineEnding) {
|
|
11773
|
+
const observe = function(token) {
|
|
11774
|
+
if (!this.tokenStack.some(([parent]) => parent.type === "codeIndented")) return;
|
|
11775
|
+
const start = this.stack.findLast((entry) => entry.type === "code")?.position?.start.offset;
|
|
11776
|
+
if (start === void 0) return;
|
|
11777
|
+
let source = sources.get(start);
|
|
11778
|
+
if (!source) {
|
|
11779
|
+
const owner = this.stack.find((entry) => entry.type === "listItem" || entry.type === "blockquote");
|
|
11780
|
+
source = {
|
|
11781
|
+
value: "",
|
|
11782
|
+
offsets: [],
|
|
11783
|
+
context: text.slice(owner?.position?.start.offset ?? start, token.start.offset),
|
|
11784
|
+
ownerStart: owner?.position?.start.offset ?? start,
|
|
11785
|
+
nested: owner !== void 0
|
|
11786
|
+
};
|
|
11787
|
+
sources.set(start, source);
|
|
11788
|
+
}
|
|
11789
|
+
const value = this.sliceSerialize(token);
|
|
11790
|
+
const extra = value.length - (token.end.offset - token.start.offset);
|
|
11791
|
+
for (let cursor = start + source.offsets.length; cursor < token.end.offset; cursor += 1) {
|
|
11792
|
+
const consumed = cursor - token.start.offset;
|
|
11793
|
+
source.offsets.push(source.value.length + (consumed > 0 ? consumed + extra : 0));
|
|
11794
|
+
}
|
|
11795
|
+
source.value += value;
|
|
11796
|
+
};
|
|
11797
|
+
return { enter: {
|
|
11798
|
+
codeFlowValue(token) {
|
|
11799
|
+
observe.call(this, token);
|
|
11800
|
+
expectDefined(this.config.enter.data, "Markdown data handler").call(this, token);
|
|
11801
|
+
},
|
|
11802
|
+
lineEnding(token) {
|
|
11803
|
+
observeInlineLineEnding?.call(this, token);
|
|
11804
|
+
observe.call(this, token);
|
|
11805
|
+
}
|
|
11806
|
+
} };
|
|
11807
|
+
}
|
|
11731
11808
|
function parseMarkdownOwnership(text, options) {
|
|
11809
|
+
const paragraphs = options?.includeIndentedSource ? [] : void 0;
|
|
11732
11810
|
if (!text) return {
|
|
11733
11811
|
regions: [],
|
|
11734
11812
|
codeSpans: [],
|
|
11735
|
-
|
|
11813
|
+
textSpans: [],
|
|
11814
|
+
retainStart: 0,
|
|
11815
|
+
completedParagraphs: [],
|
|
11816
|
+
...paragraphs ? { paragraphs } : {}
|
|
11736
11817
|
};
|
|
11737
11818
|
const sources = /* @__PURE__ */ new Map();
|
|
11819
|
+
const indentedSources = options?.includeIndentedSource ? /* @__PURE__ */ new Map() : void 0;
|
|
11820
|
+
const inlineSourceExtension = options?.includeSource ? captureInlineSources(text, sources) : void 0;
|
|
11738
11821
|
const tables = options?.syntax !== "commonmark";
|
|
11739
11822
|
const tree = fromMarkdown(text, {
|
|
11740
11823
|
extensions: [DISABLE_HTML_MARKDOWN, ...tables ? [gfmTable()] : []],
|
|
11741
|
-
mdastExtensions: [
|
|
11824
|
+
mdastExtensions: [
|
|
11825
|
+
...tables ? [gfmTableFromMarkdown()] : [],
|
|
11826
|
+
...inlineSourceExtension ? [inlineSourceExtension] : [],
|
|
11827
|
+
...indentedSources ? [captureIndentedSources(text, indentedSources, inlineSourceExtension?.enter?.lineEnding)] : []
|
|
11828
|
+
]
|
|
11742
11829
|
});
|
|
11830
|
+
const completedParagraphs = [];
|
|
11743
11831
|
const regions = [];
|
|
11744
|
-
const
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
const
|
|
11748
|
-
const
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11832
|
+
const textSpans = [];
|
|
11833
|
+
const blocks = tree.children ?? [];
|
|
11834
|
+
for (let index = 0; index < blocks.length; index += 1) {
|
|
11835
|
+
const block = expectDefined(blocks[index], "Markdown block");
|
|
11836
|
+
const next = blocks[index + 1]?.position?.start;
|
|
11837
|
+
const blockStart = block.position?.start?.offset;
|
|
11838
|
+
const endLine = block.position?.end?.line;
|
|
11839
|
+
const blockEnd = block.position?.end?.offset;
|
|
11840
|
+
if (paragraphs && block.type === "paragraph" && blockStart !== void 0 && blockEnd !== void 0) paragraphs.push({
|
|
11841
|
+
start: blockStart,
|
|
11842
|
+
end: blockEnd
|
|
11843
|
+
});
|
|
11844
|
+
let paragraph;
|
|
11845
|
+
if (block.type === "paragraph" && blockStart !== void 0 && endLine !== void 0 && next?.offset !== void 0 && next.line !== void 0 && next.line > endLine + 1) {
|
|
11846
|
+
paragraph = {
|
|
11847
|
+
start: blockStart,
|
|
11848
|
+
end: next.offset,
|
|
11849
|
+
hasReferenceCandidate: false
|
|
11850
|
+
};
|
|
11851
|
+
completedParagraphs.push(paragraph);
|
|
11852
|
+
}
|
|
11853
|
+
const pending = [block];
|
|
11854
|
+
while (pending.length > 0) {
|
|
11855
|
+
const node = expectDefined(pending.pop(), "Markdown ownership node");
|
|
11856
|
+
if (paragraph && node.type === "text" && node.value?.includes("[")) paragraph.hasReferenceCandidate = true;
|
|
11857
|
+
const start = node.position?.start?.offset;
|
|
11858
|
+
const end = node.position?.end?.offset;
|
|
11859
|
+
if (options?.includeText && node.type === "text" && start !== void 0 && end !== void 0) textSpans.push([start, end]);
|
|
11860
|
+
if ((node.type === "code" || node.type === "inlineCode") && start !== void 0 && end !== void 0) {
|
|
11861
|
+
const source = sources.get(start);
|
|
11862
|
+
if (source) while (source.offsets.length <= end - start) source.offsets.push(source.value.length);
|
|
11863
|
+
const indentedSource = indentedSources?.get(start);
|
|
11864
|
+
if (indentedSource) {
|
|
11865
|
+
indentedSource.value = node.value ?? "";
|
|
11866
|
+
while (indentedSource.offsets.length <= end - start) indentedSource.offsets.push(indentedSource.value.length);
|
|
11867
|
+
indentedSource.offsets.forEach((offset, sourceIndex) => {
|
|
11868
|
+
indentedSource.offsets[sourceIndex] = Math.min(offset, indentedSource.value.length);
|
|
11869
|
+
});
|
|
11870
|
+
}
|
|
11871
|
+
regions.push({
|
|
11872
|
+
start,
|
|
11873
|
+
end,
|
|
11874
|
+
block: node.type === "code",
|
|
11875
|
+
...source ? { source } : {},
|
|
11876
|
+
...indentedSource ? { indentedSource } : {}
|
|
11877
|
+
});
|
|
11878
|
+
}
|
|
11879
|
+
for (const child of node.children?.toReversed() ?? []) pending.push(child);
|
|
11758
11880
|
}
|
|
11759
|
-
for (const child of node.children?.toReversed() ?? []) pending.push(child);
|
|
11760
11881
|
}
|
|
11761
11882
|
regions.sort((left, right) => left.start - right.start);
|
|
11762
11883
|
return {
|
|
11763
11884
|
regions,
|
|
11764
11885
|
codeSpans: regions.map(({ start, end }) => [start, end]),
|
|
11765
|
-
|
|
11886
|
+
textSpans,
|
|
11887
|
+
retainStart: tree.children?.at(-1)?.position?.start?.offset ?? text.length,
|
|
11888
|
+
completedParagraphs,
|
|
11889
|
+
...paragraphs ? { paragraphs } : {}
|
|
11766
11890
|
};
|
|
11767
11891
|
}
|
|
11768
11892
|
function isInsideCode(index, spans) {
|
|
@@ -11967,7 +12091,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
11967
12091
|
else target.push({ ...addition });
|
|
11968
12092
|
}
|
|
11969
12093
|
};
|
|
11970
|
-
const emitSafePrefix = (limit, output) => {
|
|
12094
|
+
const emitSafePrefix = (limit, output, appended) => {
|
|
11971
12095
|
if (strictMode) {
|
|
11972
12096
|
holdStart ??= emitted;
|
|
11973
12097
|
return;
|
|
@@ -11998,10 +12122,14 @@ function createReasoningTagTextPartitioner() {
|
|
|
11998
12122
|
return;
|
|
11999
12123
|
}
|
|
12000
12124
|
if (holdStart !== void 0 || emitted >= limit) return;
|
|
12125
|
+
const appendedStart = source.length - (appended?.length ?? 0);
|
|
12126
|
+
const useAppended = appended !== void 0 && emitted >= appendedStart;
|
|
12127
|
+
const scanSource = useAppended ? appended : source;
|
|
12128
|
+
const scanOffset = useAppended ? appendedStart : 0;
|
|
12001
12129
|
while (emitted < limit && holdStart === void 0) {
|
|
12002
12130
|
let special = -1;
|
|
12003
12131
|
for (let index = emitted; index < limit; index += 1) {
|
|
12004
|
-
const char =
|
|
12132
|
+
const char = scanSource.charAt(index - scanOffset);
|
|
12005
12133
|
if (char === "<" || char === "`") {
|
|
12006
12134
|
special = index;
|
|
12007
12135
|
break;
|
|
@@ -12013,7 +12141,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
12013
12141
|
holdStart = emitted;
|
|
12014
12142
|
return;
|
|
12015
12143
|
}
|
|
12016
|
-
const text =
|
|
12144
|
+
const text = scanSource.slice(emitted - scanOffset, end - scanOffset);
|
|
12017
12145
|
if (text) {
|
|
12018
12146
|
merge(output, [{
|
|
12019
12147
|
kind: "text",
|
|
@@ -12186,14 +12314,13 @@ function createReasoningTagTextPartitioner() {
|
|
|
12186
12314
|
const output = [];
|
|
12187
12315
|
if (final) processBlock(source.length, true, output);
|
|
12188
12316
|
else {
|
|
12189
|
-
emitSafePrefix(source.length, output);
|
|
12317
|
+
emitSafePrefix(source.length, output, appended);
|
|
12190
12318
|
if (!strictMode && holdStart !== void 0 && holdStart < source.length) {
|
|
12191
12319
|
const ownershipStart = heldBacktickStart ?? holdStart;
|
|
12192
12320
|
const heldLineStart = Math.max(source.lastIndexOf("\n", Math.max(0, ownershipStart - 1)), source.lastIndexOf("\r", Math.max(0, ownershipStart - 1))) + 1;
|
|
12193
12321
|
const heldLineEnd = findNextLineEnding(source, ownershipStart);
|
|
12194
12322
|
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);
|
|
12195
12323
|
const completedBlankBlock = endedBlankBlock;
|
|
12196
|
-
const retainedContainerContext = MARKDOWN_CONTAINER_LINE_RE.test(source.slice(nonFinalRetainStart));
|
|
12197
12324
|
const heldBacktick = heldBacktickStart !== void 0;
|
|
12198
12325
|
let openingRunEnd = ownershipStart;
|
|
12199
12326
|
while (source.charAt(openingRunEnd) === "`") openingRunEnd += 1;
|
|
@@ -12202,7 +12329,7 @@ function createReasoningTagTextPartitioner() {
|
|
|
12202
12329
|
const shouldTryParser = pendingTagProbe ? pendingTagProbe.resolved : reduction.depth > 0 ? appended.includes("<") : !heldBacktick || hasLaterBacktick && terminatedBacktickTail || completedBlankBlock;
|
|
12203
12330
|
const mayResolveHeldReasoning = reduction.depth > 0 && !nonFinalCloseReparseUsed && (appended.includes("<") || appended.includes(">")) && scanReasoningTags(source.slice(holdStart), false).tags.some((tag) => tag.isClose);
|
|
12204
12331
|
const reusableCodeSpans = nonFinalCodeSpansEnd === source.length ? nonFinalCodeSpans : void 0;
|
|
12205
|
-
const mayCloseTopLevelBlock = completedBlankBlock &&
|
|
12332
|
+
const mayCloseTopLevelBlock = completedBlankBlock && !nonFinalOpenEndedCode && (appendedStartsTopLevelBlock || !MARKDOWN_CONTAINER_LINE_RE.test(source.slice(nonFinalRetainStart)));
|
|
12206
12333
|
if ((shouldTryParser || mayResolveHeldReasoning) && !tableLookaheadPending && (reusableCodeSpans !== void 0 || nonFinalFullParses < 1 || mayCloseTopLevelBlock || mayResolveHeldReasoning)) {
|
|
12207
12334
|
if (!reusableCodeSpans) nonFinalFullParses += 1;
|
|
12208
12335
|
const ownership = reusableCodeSpans ? void 0 : parseMarkdownOwnership(source);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.mjs";
|
|
2
|
-
import { v as sanitizeSurrogates } from "./host-
|
|
3
|
-
import { i as copyProviderAcceptanceObserver } from "./transport-stream-shared-
|
|
2
|
+
import { v as sanitizeSurrogates } from "./host-yTvBrYM2.mjs";
|
|
3
|
+
import { i as copyProviderAcceptanceObserver } from "./transport-stream-shared-B5RioB_Q.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
|
|
@@ -125,7 +125,9 @@ function buildBaseOptions(model, options, apiKey) {
|
|
|
125
125
|
const firstEventOptions = options;
|
|
126
126
|
const baseOptions = {
|
|
127
127
|
temperature: options?.temperature,
|
|
128
|
+
...options?.serviceTier ? { serviceTier: options.serviceTier } : {},
|
|
128
129
|
maxTokens: options?.maxTokens,
|
|
130
|
+
responseFormat: options?.responseFormat,
|
|
129
131
|
stop: options?.stop,
|
|
130
132
|
signal: options?.signal,
|
|
131
133
|
apiKey: apiKey || options?.apiKey,
|
|
@@ -146,7 +148,7 @@ function buildBaseOptions(model, options, apiKey) {
|
|
|
146
148
|
return copyProviderAcceptanceObserver(options, baseOptions);
|
|
147
149
|
}
|
|
148
150
|
function clampMaxTokensToModel(model, requestedMaxTokens) {
|
|
149
|
-
return requestedMaxTokens === void 0 ? void 0 : Math.max(1, Math.min(requestedMaxTokens, model.maxTokens));
|
|
151
|
+
return requestedMaxTokens === void 0 ? void 0 : Math.max(1, Math.min(requestedMaxTokens, model.maxTokens ?? requestedMaxTokens));
|
|
150
152
|
}
|
|
151
153
|
function clampReasoning(effort) {
|
|
152
154
|
return effort === "xhigh" ? "high" : effort;
|