@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index-C25RT6bP.mjs";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { t as AssistantMessageDiagnostic } from "./diagnostics-DnPnOui6.mjs";
|
|
2
1
|
import { TSchema } from "typebox";
|
|
3
2
|
//#region packages/llm-core/src/model-data.d.ts
|
|
4
3
|
declare const MODEL_DATA_THINKING_FORMATS: readonly ["openai", "openrouter", "deepseek", "together", "qwen", "qwen-chat-template", "zai"];
|
|
@@ -59,6 +58,34 @@ type ModelRoutingPercentiles = {
|
|
|
59
58
|
p99?: number;
|
|
60
59
|
};
|
|
61
60
|
//#endregion
|
|
61
|
+
//#region packages/llm-core/src/utils/diagnostics.d.ts
|
|
62
|
+
interface DiagnosticErrorInfo {
|
|
63
|
+
name?: string;
|
|
64
|
+
message: string;
|
|
65
|
+
stack?: string;
|
|
66
|
+
code?: string | number;
|
|
67
|
+
}
|
|
68
|
+
interface AssistantMessageDiagnostic {
|
|
69
|
+
type: string;
|
|
70
|
+
timestamp: number;
|
|
71
|
+
error?: DiagnosticErrorInfo;
|
|
72
|
+
details?: Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
/** True when the provider explicitly refused the request payload. */
|
|
75
|
+
declare function isProviderRefusalAssistantError(message: {
|
|
76
|
+
diagnostics?: AssistantMessageDiagnostic[];
|
|
77
|
+
} | null | undefined): boolean;
|
|
78
|
+
/** Formats arbitrary thrown values into diagnostic-safe text. */
|
|
79
|
+
declare function formatThrownValue(value: unknown): string;
|
|
80
|
+
/** Extracts serializable diagnostic error fields from Error and non-Error throws. */
|
|
81
|
+
declare function extractDiagnosticError(error: unknown): DiagnosticErrorInfo;
|
|
82
|
+
/** Creates a timestamped assistant-message diagnostic entry. */
|
|
83
|
+
declare function createAssistantMessageDiagnostic(type: string, error: unknown, details?: Record<string, unknown>): AssistantMessageDiagnostic;
|
|
84
|
+
/** Appends a diagnostic while preserving existing message diagnostics. */
|
|
85
|
+
declare function appendAssistantMessageDiagnostic(message: {
|
|
86
|
+
diagnostics?: AssistantMessageDiagnostic[];
|
|
87
|
+
}, diagnostic: AssistantMessageDiagnostic): void;
|
|
88
|
+
//#endregion
|
|
62
89
|
//#region packages/llm-core/src/types.d.ts
|
|
63
90
|
/** Provider API families with first-class request/stream adapters in OpenClaw. */
|
|
64
91
|
type KnownApi = "openai-completions" | "mistral-conversations" | "openai-responses" | "azure-openai-responses" | "openai-chatgpt-responses" | "anthropic-messages" | "bedrock-converse-stream" | "google-generative-ai" | "google-vertex";
|
|
@@ -241,6 +268,8 @@ interface ImagesOptions {
|
|
|
241
268
|
type ProviderImagesOptions = ImagesOptions & Record<string, unknown>;
|
|
242
269
|
/** Unified text options used by simple completion helpers. */
|
|
243
270
|
interface SimpleStreamOptions extends StreamOptions {
|
|
271
|
+
/** Optional processing tier; only providers supporting these tiers apply it. */
|
|
272
|
+
serviceTier?: "default" | "priority";
|
|
244
273
|
reasoning?: ModelThinkingLevel;
|
|
245
274
|
/** Custom token budgets for thinking levels (token-based providers only) */
|
|
246
275
|
thinkingBudgets?: ThinkingBudgets;
|
|
@@ -397,6 +426,8 @@ interface AssistantMessage {
|
|
|
397
426
|
diagnostics?: AssistantMessageDiagnostic[];
|
|
398
427
|
usage: Usage;
|
|
399
428
|
stopReason: StopReason;
|
|
429
|
+
/** A completed provider response can explicitly request another inference with false. */
|
|
430
|
+
endTurn?: boolean;
|
|
400
431
|
errorMessage?: string;
|
|
401
432
|
errorCode?: string;
|
|
402
433
|
errorType?: string;
|
|
@@ -540,6 +571,8 @@ interface OpenAICompletionsCompat {
|
|
|
540
571
|
supportsDeveloperRole?: boolean;
|
|
541
572
|
/** Whether the provider supports `reasoning_effort`. Default: auto-detected from URL. */
|
|
542
573
|
supportsReasoningEffort?: boolean;
|
|
574
|
+
/** Provider-native reasoning efforts accepted by the model. Overrides known model defaults. */
|
|
575
|
+
supportedReasoningEfforts?: string[];
|
|
543
576
|
/** Per-level reasoning effort overrides, e.g. map "off" to "low" for models that cannot disable thinking. */
|
|
544
577
|
reasoningEffortMap?: Record<string, string>;
|
|
545
578
|
/** Whether the provider supports `stream_options: { include_usage: true }` for token usage in streaming responses. Default: true. */
|
|
@@ -577,12 +610,16 @@ interface OpenAICompletionsCompat {
|
|
|
577
610
|
}
|
|
578
611
|
/** Compatibility settings for OpenAI Responses APIs. */
|
|
579
612
|
interface OpenAIResponsesCompat {
|
|
613
|
+
/** Whether a compatible provider accepts the `strict` tool field. Default: auto-detected from the endpoint. */
|
|
614
|
+
supportsStrictMode?: boolean;
|
|
580
615
|
/** Whether the provider supports the `developer` role (vs `system`). Default: true. */
|
|
581
616
|
supportsDeveloperRole?: boolean;
|
|
582
617
|
/** Whether to send reasoning effort settings. Defaults to the model's known capabilities. */
|
|
583
618
|
supportsReasoningEffort?: boolean;
|
|
584
619
|
/** Provider-native reasoning efforts accepted by the model. Overrides known model defaults. */
|
|
585
620
|
supportedReasoningEfforts?: string[];
|
|
621
|
+
/** Per-level reasoning effort overrides, e.g. map "off" to "low" for models that cannot disable thinking. */
|
|
622
|
+
reasoningEffortMap?: Record<string, string>;
|
|
586
623
|
/** Whether the model accepts the `temperature` parameter. Default: true. */
|
|
587
624
|
supportsTemperature?: boolean;
|
|
588
625
|
/** Whether to send the OpenAI `session_id` cache-affinity header from `options.sessionId` when caching is enabled. Default: true. */
|
|
@@ -591,6 +628,15 @@ interface OpenAIResponsesCompat {
|
|
|
591
628
|
supportsLongCacheRetention?: boolean;
|
|
592
629
|
/** Whether the provider honors top-level `instructions`. Defaults to true only for verified native routes (OpenAI, xAI); every other route defaults to false and embeds the system prompt in `input` unless set true here after verifying against that endpoint. */
|
|
593
630
|
supportsInstructions?: boolean;
|
|
631
|
+
/**
|
|
632
|
+
* Explicit opt-in for HTTP continuation (client-side delta + `previous_response_id`)
|
|
633
|
+
* on a custom/proxy OpenAI-Responses-compatible endpoint. A native `api.openai.com`
|
|
634
|
+
* connection is eligible by default; a custom endpoint carries no trust signal of
|
|
635
|
+
* its own, so this is the only path to eligibility there — set it once you've
|
|
636
|
+
* verified the backend correctly resolves `previous_response_id` and persists
|
|
637
|
+
* `store: true` turns. Default: false.
|
|
638
|
+
*/
|
|
639
|
+
supportsResponsesContinuation?: boolean;
|
|
594
640
|
}
|
|
595
641
|
/** Compatibility settings for Anthropic Messages-compatible APIs. */
|
|
596
642
|
interface AnthropicMessagesCompat {
|
|
@@ -697,7 +743,7 @@ interface Model<TApi extends Api = Api> {
|
|
|
697
743
|
/** Sends runtime credentials as Authorization: Bearer instead of provider-specific key headers. */
|
|
698
744
|
authHeader?: boolean;
|
|
699
745
|
/** Compatibility overrides for OpenAI-compatible APIs. If not set, auto-detected from baseUrl. */
|
|
700
|
-
compat?: TApi extends "openai-completions" ? OpenAICompletionsCompat : TApi extends "openai-responses" | "azure-openai-responses" | "openai-codex-responses" ? OpenAIResponsesCompat : TApi extends "anthropic-messages" ? AnthropicMessagesCompat : never;
|
|
746
|
+
compat?: TApi extends "openai-completions" ? OpenAICompletionsCompat : TApi extends "openai-responses" | "azure-openai-responses" | "openai-chatgpt-responses" | "openai-codex-responses" ? OpenAIResponsesCompat : TApi extends "anthropic-messages" ? AnthropicMessagesCompat : never;
|
|
701
747
|
/** Provider-documented media input limits used by attachment preprocessing. */
|
|
702
748
|
mediaInput?: ModelDataMediaInputConfig;
|
|
703
749
|
}
|
|
@@ -710,4 +756,4 @@ type StreamFn = (model: Model, context: Context, options?: SimpleStreamOptions)
|
|
|
710
756
|
type CompleteSimpleFn = (model: Model, context: Pick<Context, "systemPrompt" | "messages">, options?: SimpleStreamOptions) => Promise<AssistantMessage>;
|
|
711
757
|
type ValidateToolArgumentsFn = (tool: Tool, toolCall: ToolCall) => unknown;
|
|
712
758
|
//#endregion
|
|
713
|
-
export { ThinkingContent as $, ModelCostRates as A, ProviderReplayState as B, KnownImagesApi as C, Message as D, MaybePromise as E, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE as F, SimpleStreamOptions as G, ProviderStreamOptions as H, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE as I, StreamFunction as J, StopReason as K, PricingTier as L, OpenAICompletionsCompat as M, OpenAIResponsesCompat as N, Model as O, OpenRouterRouting as P, ThinkingBudgets as Q, Provider as R, KnownApi as S, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE as T, RawModelCostConfig as U, ProviderResponse as V, RawPricingTier as W, TextContent as X, StreamOptions as Y, TextSignatureV1 as Z, ImagesModel as _, AssistantMessage as a, Transport as at, ImagesProvider as b, AssistantMessageEventStreamLike as c, ValidateToolArgumentsFn as ct, Context as d, ThinkingLevel as et, ImageContent as f, ImagesInputContent as g, ImagesFunction as h, AssistantImages as i, ToolResultMessage as it, ModelThinkingLevel as j, ModelCostConfig as k, CacheRetention as l, VercelGatewayRouting as lt, ImagesContext as m, Api as n, Tool as nt, AssistantMessageEvent as o, Usage as ot, ImagesApi as p, StreamFn as q, AssistantDeliveryTtsFacts as r, ToolCall as rt, AssistantMessageEventStreamContract as s, UserMessage as st, AnthropicMessagesCompat as t, ThinkingLevelMap as tt, CompleteSimpleFn as u,
|
|
759
|
+
export { ThinkingContent as $, ModelCostRates as A, ProviderReplayState as B, KnownImagesApi as C, Message as D, MaybePromise as E, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE as F, SimpleStreamOptions as G, ProviderStreamOptions as H, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE as I, StreamFunction as J, StopReason as K, PricingTier as L, OpenAICompletionsCompat as M, OpenAIResponsesCompat as N, Model as O, OpenRouterRouting as P, ThinkingBudgets as Q, Provider as R, KnownApi as S, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE as T, RawModelCostConfig as U, ProviderResponse as V, RawPricingTier as W, TextContent as X, StreamOptions as Y, TextSignatureV1 as Z, ImagesModel as _, ModelDataThinkingFormat as _t, AssistantMessage as a, Transport as at, ImagesProvider as b, AssistantMessageEventStreamLike as c, ValidateToolArgumentsFn as ct, Context as d, DiagnosticErrorInfo as dt, ThinkingLevel as et, ImageContent as f, appendAssistantMessageDiagnostic as ft, ImagesInputContent as g, isProviderRefusalAssistantError as gt, ImagesFunction as h, formatThrownValue as ht, AssistantImages as i, ToolResultMessage as it, ModelThinkingLevel as j, ModelCostConfig as k, CacheRetention as l, VercelGatewayRouting as lt, ImagesContext as m, extractDiagnosticError as mt, Api as n, Tool as nt, AssistantMessageEvent as o, Usage as ot, ImagesApi as p, createAssistantMessageDiagnostic as pt, StreamFn as q, AssistantDeliveryTtsFacts as r, ToolCall as rt, AssistantMessageEventStreamContract as s, UserMessage as st, AnthropicMessagesCompat as t, ThinkingLevelMap as tt, CompleteSimpleFn as u, AssistantMessageDiagnostic as ut, ImagesOptions as v, KnownImagesProvider as w, ImagesStopReason as x, ImagesOutputContent as y, ProviderImagesOptions as z };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { $ as ThinkingContent, A as ModelCostRates, B as ProviderReplayState, C as KnownImagesApi, D as Message, E as MaybePromise, F as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, G as SimpleStreamOptions, H as ProviderStreamOptions, I as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, J as StreamFunction, K as StopReason, L as PricingTier, M as OpenAICompletionsCompat, N as OpenAIResponsesCompat, O as Model, 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, d as Context, 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
|
|
6
|
-
|
|
7
|
-
export { 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, Context, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, MaybePromise, Message, Model, ModelCostConfig, ModelCostRates, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, PricingTier, Provider, ProviderImagesOptions, ProviderReplayState, ProviderResponse, ProviderStreamOptions, RawModelCostConfig, RawPricingTier, SimpleStreamOptions, StopReason, StreamFn, StreamFunction, 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 };
|
|
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, D as Message, E as MaybePromise, F as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, G as SimpleStreamOptions, H as ProviderStreamOptions, I as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, J as StreamFunction, K as StopReason, L as PricingTier, M as OpenAICompletionsCompat, N as OpenAIResponsesCompat, O as Model, 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, d as Context, 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 "./types-DTvddOfm.mjs";
|
|
6
|
+
export { AnthropicMessagesCompat, Api, AssistantDeliveryTtsFacts, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_55_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, CacheRetention, CompleteSimpleFn, Context, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, MaybePromise, Message, Model, ModelCostConfig, ModelCostRates, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, PricingTier, Provider, ProviderImagesOptions, type ProviderRefusalReview, ProviderReplayState, ProviderResponse, ProviderStreamOptions, RawModelCostConfig, RawPricingTier, SimpleStreamOptions, StopReason, StreamFn, StreamFunction, 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, readProviderRefusalReview, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus55ModelIdentity, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
package/dist/types.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { S as supportsClaudeNativeXhighEffort, _ as resolveClaudeSonnet5ModelIdentity, a as CLAUDE_OPUS_55_THINKING_PROFILE, b as supportsClaudeFastMode, c as bindsClaudeThinkingPrefix, d as resolveClaudeFable5ModelIdentity, f as resolveClaudeModelIdentity, g as resolveClaudeOpus5ModelIdentity, h as resolveClaudeOpus55ModelIdentity, i as CLAUDE_FABLE_5_THINKING_PROFILE, l as requiresClaudeDefaultSampling, m as resolveClaudeNativeThinkingLevelMap, n as normalizeModelCostConfig, o as CLAUDE_OPUS_5_THINKING_PROFILE, p as resolveClaudeMythos5ModelIdentity, r as normalizeResolvedPricing, s as CLAUDE_SONNET_5_THINKING_PROFILE, t as calculateUsageCost, u as requiresClaudeMandatoryAdaptiveThinking, v as supportsClaude1MContext, x as supportsClaudeNativeMaxEffort, y as supportsClaudeAdaptiveThinking } from "./src-DwGYYyZp.mjs";
|
|
2
2
|
import { n as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, r as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, t as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE } from "./types-LFWwv0cF.mjs";
|
|
3
|
-
import { a as isProviderRefusalAssistantError, i as formatThrownValue, n as createAssistantMessageDiagnostic, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-
|
|
3
|
+
import { a as isProviderRefusalAssistantError, i as formatThrownValue, n as createAssistantMessageDiagnostic, o as readProviderRefusalReview, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
|
|
4
4
|
import { i as createAssistantMessageEventStream, n as EventStream, t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
5
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
6
|
-
|
|
7
|
-
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, EventStream, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, 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 };
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-Dw7cb6BV.mjs";
|
|
6
|
+
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_55_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, EventStream, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, appendAssistantMessageDiagnostic, bindsClaudeThinkingPrefix, calculateUsageCost, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, isProviderRefusalAssistantError, normalizeModelCostConfig, normalizeResolvedPricing, readProviderRefusalReview, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus55ModelIdentity, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { nt as Tool, rt as ToolCall } from "./types-
|
|
1
|
+
import { nt as Tool, rt as ToolCall } from "./types-qZFbaDbK.mjs";
|
|
2
2
|
//#region packages/llm-core/src/validation.d.ts
|
|
3
3
|
/** Finds the target tool and validates/coerces a model-emitted tool call. */
|
|
4
4
|
declare function validateToolCall(tools: Tool[], toolCall: ToolCall): unknown;
|
|
@@ -142,6 +142,7 @@ function coerceWithJsonSchema(value, schema) {
|
|
|
142
142
|
const schemaTypes = getSchemaTypes(schema);
|
|
143
143
|
const matchesUnionMember = schemaTypes.length > 1 && schemaTypes.some((schemaType) => matchesJsonType(nextValue, schemaType));
|
|
144
144
|
if (schemaTypes.length > 0 && !matchesUnionMember) for (const schemaType of schemaTypes) {
|
|
145
|
+
if (schemaType === "null" && nextValue !== null && schemaTypes.length > 1) continue;
|
|
145
146
|
const candidate = coercePrimitiveByType(nextValue, schemaType);
|
|
146
147
|
if (candidate !== nextValue) {
|
|
147
148
|
nextValue = candidate;
|
package/dist/validation.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
1
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-DhQhmt6t.mjs";
|
|
2
2
|
export { validateToolArguments, validateToolCall };
|
package/dist/validation.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
1
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-Dw7cb6BV.mjs";
|
|
2
2
|
export { validateToolArguments, validateToolCall };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/ai",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.6",
|
|
4
4
|
"description": "Reusable model provider adapters and streaming runtime from OpenClaw",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -86,6 +86,11 @@
|
|
|
86
86
|
"import": "./dist/internal/openai.mjs",
|
|
87
87
|
"default": "./dist/internal/openai.mjs"
|
|
88
88
|
},
|
|
89
|
+
"./internal/openai-completions-compat": {
|
|
90
|
+
"types": "./dist/internal/openai-completions-compat.d.mts",
|
|
91
|
+
"import": "./dist/internal/openai-completions-compat.mjs",
|
|
92
|
+
"default": "./dist/internal/openai-completions-compat.mjs"
|
|
93
|
+
},
|
|
89
94
|
"./internal/openai-responses-payload-policy": {
|
|
90
95
|
"types": "./dist/internal/openai-responses-payload-policy.d.mts",
|
|
91
96
|
"import": "./dist/internal/openai-responses-payload-policy.mjs",
|
|
@@ -113,12 +118,12 @@
|
|
|
113
118
|
}
|
|
114
119
|
},
|
|
115
120
|
"dependencies": {
|
|
116
|
-
"@anthropic-ai/sdk": "0.
|
|
117
|
-
"@google/genai": "2.
|
|
118
|
-
"@mistralai/mistralai": "2.
|
|
119
|
-
"openai": "7.
|
|
121
|
+
"@anthropic-ai/sdk": "0.125.0",
|
|
122
|
+
"@google/genai": "2.22.0",
|
|
123
|
+
"@mistralai/mistralai": "2.7.0",
|
|
124
|
+
"openai": "7.15.0",
|
|
120
125
|
"partial-json": "0.1.7",
|
|
121
|
-
"typebox": "1.3.
|
|
126
|
+
"typebox": "1.3.30"
|
|
122
127
|
},
|
|
123
128
|
"devDependencies": {
|
|
124
129
|
"@openclaw/model-catalog-core": "0.0.0-private",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//#region packages/llm-core/src/utils/diagnostics.d.ts
|
|
2
|
-
interface DiagnosticErrorInfo {
|
|
3
|
-
name?: string;
|
|
4
|
-
message: string;
|
|
5
|
-
stack?: string;
|
|
6
|
-
code?: string | number;
|
|
7
|
-
}
|
|
8
|
-
interface AssistantMessageDiagnostic {
|
|
9
|
-
type: string;
|
|
10
|
-
timestamp: number;
|
|
11
|
-
error?: DiagnosticErrorInfo;
|
|
12
|
-
details?: Record<string, unknown>;
|
|
13
|
-
}
|
|
14
|
-
/** True when the provider explicitly refused the request payload. */
|
|
15
|
-
declare function isProviderRefusalAssistantError(message: {
|
|
16
|
-
diagnostics?: AssistantMessageDiagnostic[];
|
|
17
|
-
} | null | undefined): boolean;
|
|
18
|
-
/** Formats arbitrary thrown values into diagnostic-safe text. */
|
|
19
|
-
declare function formatThrownValue(value: unknown): string;
|
|
20
|
-
/** Extracts serializable diagnostic error fields from Error and non-Error throws. */
|
|
21
|
-
declare function extractDiagnosticError(error: unknown): DiagnosticErrorInfo;
|
|
22
|
-
/** Creates a timestamped assistant-message diagnostic entry. */
|
|
23
|
-
declare function createAssistantMessageDiagnostic(type: string, error: unknown, details?: Record<string, unknown>): AssistantMessageDiagnostic;
|
|
24
|
-
/** Appends a diagnostic while preserving existing message diagnostics. */
|
|
25
|
-
declare function appendAssistantMessageDiagnostic(message: {
|
|
26
|
-
diagnostics?: AssistantMessageDiagnostic[];
|
|
27
|
-
}, diagnostic: AssistantMessageDiagnostic): void;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { extractDiagnosticError as a, createAssistantMessageDiagnostic as i, DiagnosticErrorInfo as n, formatThrownValue as o, appendAssistantMessageDiagnostic as r, isProviderRefusalAssistantError as s, AssistantMessageDiagnostic as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./event-stream-Bt5Y4Pav.mjs";
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { r as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE } from "./types-LFWwv0cF.mjs";
|
|
2
|
-
import "./src-DDmEryvj.mjs";
|
|
3
|
-
import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.mjs";
|
|
4
|
-
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
5
|
-
import { n as uniqueStrings, t as normalizeStringEntries } from "./string-normalization-CmLIasuf.mjs";
|
|
6
|
-
//#region packages/ai/src/providers/openai-reasoning-effort.ts
|
|
7
|
-
/**
|
|
8
|
-
* OpenAI-compatible reasoning-effort normalization. Different GPT families
|
|
9
|
-
* expose different accepted effort enums, so callers map requested values here
|
|
10
|
-
* before constructing provider payloads.
|
|
11
|
-
*/
|
|
12
|
-
const GPT_5_REASONING_EFFORTS = [
|
|
13
|
-
"minimal",
|
|
14
|
-
"low",
|
|
15
|
-
"medium",
|
|
16
|
-
"high"
|
|
17
|
-
];
|
|
18
|
-
const GPT_51_REASONING_EFFORTS = [
|
|
19
|
-
"none",
|
|
20
|
-
"low",
|
|
21
|
-
"medium",
|
|
22
|
-
"high"
|
|
23
|
-
];
|
|
24
|
-
const GPT_52_REASONING_EFFORTS = [
|
|
25
|
-
"none",
|
|
26
|
-
"low",
|
|
27
|
-
"medium",
|
|
28
|
-
"high",
|
|
29
|
-
"xhigh"
|
|
30
|
-
];
|
|
31
|
-
const GPT_56_REASONING_EFFORTS = [
|
|
32
|
-
"none",
|
|
33
|
-
"low",
|
|
34
|
-
"medium",
|
|
35
|
-
"high",
|
|
36
|
-
"xhigh",
|
|
37
|
-
"max"
|
|
38
|
-
];
|
|
39
|
-
const GPT_6_ASTRA_REASONING_EFFORTS = [
|
|
40
|
-
"low",
|
|
41
|
-
"medium",
|
|
42
|
-
"high",
|
|
43
|
-
"xhigh",
|
|
44
|
-
"max"
|
|
45
|
-
];
|
|
46
|
-
const GPT_CODEX_REASONING_EFFORTS = [
|
|
47
|
-
"low",
|
|
48
|
-
"medium",
|
|
49
|
-
"high",
|
|
50
|
-
"xhigh"
|
|
51
|
-
];
|
|
52
|
-
const GPT_PRO_REASONING_EFFORTS = [
|
|
53
|
-
"medium",
|
|
54
|
-
"high",
|
|
55
|
-
"xhigh"
|
|
56
|
-
];
|
|
57
|
-
const GPT_5_PRO_REASONING_EFFORTS = ["high"];
|
|
58
|
-
const GPT_51_CODEX_MAX_REASONING_EFFORTS = [
|
|
59
|
-
"none",
|
|
60
|
-
"medium",
|
|
61
|
-
"high",
|
|
62
|
-
"xhigh"
|
|
63
|
-
];
|
|
64
|
-
const GPT_51_CODEX_MINI_REASONING_EFFORTS = ["medium"];
|
|
65
|
-
const GENERIC_REASONING_EFFORTS = [
|
|
66
|
-
"low",
|
|
67
|
-
"medium",
|
|
68
|
-
"high"
|
|
69
|
-
];
|
|
70
|
-
const CANONICAL_REASONING_EFFORTS = /* @__PURE__ */ new Set([
|
|
71
|
-
"none",
|
|
72
|
-
"minimal",
|
|
73
|
-
"low",
|
|
74
|
-
"medium",
|
|
75
|
-
"high",
|
|
76
|
-
"xhigh",
|
|
77
|
-
"max",
|
|
78
|
-
"off"
|
|
79
|
-
]);
|
|
80
|
-
function normalizeModelId(id) {
|
|
81
|
-
return normalizeLowercaseStringOrEmpty(id ?? "").replace(/-\d{4}-\d{2}-\d{2}$/u, "");
|
|
82
|
-
}
|
|
83
|
-
/** Return whether a model is the GPT-5.4 mini family. */
|
|
84
|
-
function isOpenAIGpt54MiniModel(model) {
|
|
85
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
86
|
-
return /^gpt-5\.4-mini(?:-|$)/u.test(id);
|
|
87
|
-
}
|
|
88
|
-
/** Return whether a model is the GPT-5.5 family. */
|
|
89
|
-
function isOpenAIGpt55Model(model) {
|
|
90
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
91
|
-
const name = normalizeModelId(typeof model.name === "string" ? model.name : void 0);
|
|
92
|
-
return /^gpt-5\.5(?:-|$)/u.test(id) || /^gpt-5\.5(?:\s|\(|-|$)/u.test(name);
|
|
93
|
-
}
|
|
94
|
-
/** Return whether a model is the GPT-5.6 family. */
|
|
95
|
-
function isOpenAIGpt56Model(model) {
|
|
96
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
97
|
-
const name = normalizeModelId(typeof model.name === "string" ? model.name : void 0);
|
|
98
|
-
return /^gpt-5\.6(?:-|$)/u.test(id) || /^gpt-5\.6(?:\s|\(|-|$)/u.test(name);
|
|
99
|
-
}
|
|
100
|
-
/** Normalize user-facing reasoning effort names to API effort names. */
|
|
101
|
-
function normalizeOpenAIReasoningEffort(effort) {
|
|
102
|
-
const trimmed = effort.trim();
|
|
103
|
-
const folded = trimmed.toLowerCase();
|
|
104
|
-
return CANONICAL_REASONING_EFFORTS.has(folded) ? folded : trimmed;
|
|
105
|
-
}
|
|
106
|
-
function readCompatReasoningEfforts(compat) {
|
|
107
|
-
if (!compat || typeof compat !== "object") return;
|
|
108
|
-
if (compat.supportsReasoningEffort === false) return [];
|
|
109
|
-
const raw = compat.supportedReasoningEfforts;
|
|
110
|
-
if (!Array.isArray(raw)) return;
|
|
111
|
-
const supported = uniqueStrings(normalizeStringEntries(raw.filter((value) => typeof value === "string")));
|
|
112
|
-
return supported.length > 0 ? supported : void 0;
|
|
113
|
-
}
|
|
114
|
-
function isDisabledReasoningEffort(effort) {
|
|
115
|
-
return effort === "none" || effort === "off";
|
|
116
|
-
}
|
|
117
|
-
/** Resolve the reasoning efforts accepted by a specific OpenAI-compatible model. */
|
|
118
|
-
function resolveOpenAISupportedReasoningEfforts(model) {
|
|
119
|
-
return resolveOpenAIModelReasoningEfforts(model) ?? GENERIC_REASONING_EFFORTS;
|
|
120
|
-
}
|
|
121
|
-
/** Read a declared or known model contract, leaving unknown compatible models unspecified. */
|
|
122
|
-
function resolveOpenAIModelReasoningEfforts(model) {
|
|
123
|
-
const compatEfforts = readCompatReasoningEfforts(model.compat);
|
|
124
|
-
if (compatEfforts) return compatEfforts;
|
|
125
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
126
|
-
if (id === "gpt-6-astra" && model.api !== "azure-openai-responses") return GPT_6_ASTRA_REASONING_EFFORTS;
|
|
127
|
-
if (/^gpt-5\.6(?:-|$)/u.test(id)) return GPT_56_REASONING_EFFORTS;
|
|
128
|
-
if (id === "gpt-5.1-codex-mini") return GPT_51_CODEX_MINI_REASONING_EFFORTS;
|
|
129
|
-
if (id === "gpt-5.1-codex-max") return GPT_51_CODEX_MAX_REASONING_EFFORTS;
|
|
130
|
-
if (/^gpt-5(?:\.\d+)?-codex(?:-|$)/u.test(id)) return GPT_CODEX_REASONING_EFFORTS;
|
|
131
|
-
if (id === "gpt-5-pro") return GPT_5_PRO_REASONING_EFFORTS;
|
|
132
|
-
if (/^gpt-5\.[2-9](?:\.\d+)?-pro(?:-|$)/u.test(id)) return GPT_PRO_REASONING_EFFORTS;
|
|
133
|
-
if (/^gpt-5\.[2-9](?:\.\d+)?(?:-|$)/u.test(id)) return GPT_52_REASONING_EFFORTS;
|
|
134
|
-
if (/^gpt-5\.1(?:-|$)/u.test(id)) return GPT_51_REASONING_EFFORTS;
|
|
135
|
-
if (/^gpt-5(?:-|$)/u.test(id)) return GPT_5_REASONING_EFFORTS;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Return whether a model accepts temperature. GPT-5.6 and GPT-6 Astra
|
|
139
|
-
* reject it with a 400; catalog compat can override per model.
|
|
140
|
-
*/
|
|
141
|
-
function supportsOpenAITemperature(model) {
|
|
142
|
-
const compat = model.compat;
|
|
143
|
-
if (compat && typeof compat === "object") {
|
|
144
|
-
const declared = compat.supportsTemperature;
|
|
145
|
-
if (typeof declared === "boolean") return declared;
|
|
146
|
-
}
|
|
147
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
148
|
-
return (id !== "gpt-6-astra" || model.api === "azure-openai-responses") && !/^gpt-5\.6(?:-|$)/u.test(id);
|
|
149
|
-
}
|
|
150
|
-
/** Return whether a model accepts a requested reasoning effort. */
|
|
151
|
-
function supportsOpenAIReasoningEffort(model, effort) {
|
|
152
|
-
return resolveOpenAISupportedReasoningEfforts(model).includes(normalizeOpenAIReasoningEffort(effort));
|
|
153
|
-
}
|
|
154
|
-
/** Resolve a requested reasoning effort to the closest value supported by the model. */
|
|
155
|
-
function resolveOpenAIReasoningEffortForModel(params) {
|
|
156
|
-
const requested = normalizeOpenAIReasoningEffort(params.effort);
|
|
157
|
-
const mapped = params.fallbackMap?.[requested] ?? (params.fallbackMap && CANONICAL_REASONING_EFFORTS.has(requested) ? Object.entries(params.fallbackMap).find(([effort]) => normalizeOpenAIReasoningEffort(effort) === requested)?.[1] : void 0);
|
|
158
|
-
const normalized = mapped === void 0 ? requested : mapped.trim();
|
|
159
|
-
const supported = resolveOpenAISupportedReasoningEfforts(params.model);
|
|
160
|
-
if (supported.includes(normalized)) return normalized;
|
|
161
|
-
if (requested === "off" && supported.includes("none")) return "none";
|
|
162
|
-
if (isDisabledReasoningEffort(requested) || isDisabledReasoningEffort(normalized)) return;
|
|
163
|
-
if (requested === "minimal" && supported.includes("low")) return "low";
|
|
164
|
-
if ((requested === "minimal" || requested === "low") && supported.includes("medium")) return "medium";
|
|
165
|
-
if (requested === "xhigh" && supported.includes("high")) return "high";
|
|
166
|
-
if (requested === "max" && supported.includes("xhigh")) return "xhigh";
|
|
167
|
-
return supported.find((effort) => !isDisabledReasoningEffort(normalizeOpenAIReasoningEffort(effort)));
|
|
168
|
-
}
|
|
169
|
-
//#endregion
|
|
170
|
-
//#region packages/ai/src/transports/openai-responses-contracts.ts
|
|
171
|
-
const DEFAULT_AZURE_OPENAI_API_VERSION = "preview";
|
|
172
|
-
const OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS = "Follow the user request.";
|
|
173
|
-
const AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS = 3e4;
|
|
174
|
-
const RESPONSE_FAILED_NO_DETAILS_MESSAGE = "Unknown error (no error details in response)";
|
|
175
|
-
const OPENAI_RESPONSES_REASONING_REPLAY_META_KEY = "__openclaw_replay";
|
|
176
|
-
const OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY = "openclawReasoningReplay";
|
|
177
|
-
const OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE = "openai-responses-compaction";
|
|
178
|
-
const OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE = "openai-responses-retained-compaction";
|
|
179
|
-
const OPENAI_RESPONSES_APIS = /* @__PURE__ */ new Set([
|
|
180
|
-
"openai-responses",
|
|
181
|
-
"azure-openai-responses",
|
|
182
|
-
"openai-chatgpt-responses",
|
|
183
|
-
"openclaw-openai-responses-transport",
|
|
184
|
-
"openclaw-openai-chatgpt-responses-transport",
|
|
185
|
-
"openclaw-azure-openai-responses-transport"
|
|
186
|
-
]);
|
|
187
|
-
var OpenAIResponsesWebSocketPreDispatchError = class extends Error {
|
|
188
|
-
constructor(cause) {
|
|
189
|
-
super("OpenAI Responses WebSocket failed before request dispatch", { cause });
|
|
190
|
-
this.name = "OpenAIResponsesWebSocketPreDispatchError";
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
var OpenAIResponsesWebSocketPostDispatchError = class extends Error {
|
|
194
|
-
constructor(cause) {
|
|
195
|
-
super("OpenAI Responses WebSocket failed after request dispatch; outcome is unknown", { cause });
|
|
196
|
-
this.code = PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE;
|
|
197
|
-
this.name = "OpenAIResponsesWebSocketPostDispatchError";
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
var OpenAIResponsesWebSocketServerError = class extends Error {
|
|
201
|
-
constructor(code, status, param, message, cause) {
|
|
202
|
-
super(message, { cause });
|
|
203
|
-
this.code = code;
|
|
204
|
-
this.status = status;
|
|
205
|
-
this.param = param;
|
|
206
|
-
this.name = "OpenAIResponsesWebSocketServerError";
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
var OpenAIResponsesWebSocketSafeRetryError = class extends OpenAIResponsesWebSocketServerError {};
|
|
210
|
-
function readWebSocketServerError(value) {
|
|
211
|
-
if (!isRecord(value) || value.type !== "error") return;
|
|
212
|
-
const details = isRecord(value.error) ? value.error : value;
|
|
213
|
-
if (typeof details.code !== "string" || typeof details.message !== "string") return;
|
|
214
|
-
const rawStatus = value.status ?? value.status_code;
|
|
215
|
-
return {
|
|
216
|
-
code: details.code,
|
|
217
|
-
message: details.message,
|
|
218
|
-
param: typeof details.param === "string" ? details.param : null,
|
|
219
|
-
status: typeof rawStatus === "number" ? rawStatus : void 0
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
function parseOpenAIResponsesWebSocketServerError(cause) {
|
|
223
|
-
if (!isRecord(cause)) return;
|
|
224
|
-
let details = readWebSocketServerError(cause.error) ?? readWebSocketServerError(cause);
|
|
225
|
-
if (!details && typeof cause.message === "string") try {
|
|
226
|
-
details = readWebSocketServerError(JSON.parse(cause.message));
|
|
227
|
-
} catch {}
|
|
228
|
-
if (!details) return;
|
|
229
|
-
return new (details.code === "previous_response_not_found" || details.code === "websocket_connection_limit_reached" || details.code === "invalid_encrypted_content" || details.code === "thinking_signature_invalid" ? OpenAIResponsesWebSocketSafeRetryError : OpenAIResponsesWebSocketServerError)(details.code, details.status, details.param, details.message, cause);
|
|
230
|
-
}
|
|
231
|
-
const PROMPT_OBSERVER = Symbol("openaiResponsesPromptObserver");
|
|
232
|
-
const responsesPromptObserver = {
|
|
233
|
-
set(options, observer) {
|
|
234
|
-
Reflect.set(options, PROMPT_OBSERVER, observer);
|
|
235
|
-
},
|
|
236
|
-
get(options) {
|
|
237
|
-
return Reflect.get(options, PROMPT_OBSERVER);
|
|
238
|
-
},
|
|
239
|
-
copy(source, target) {
|
|
240
|
-
const observer = source && responsesPromptObserver.get(source);
|
|
241
|
-
if (observer) responsesPromptObserver.set(target, observer);
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
//#endregion
|
|
245
|
-
export { supportsOpenAITemperature as C, supportsOpenAIReasoningEffort as S, isOpenAIGpt56Model as _, OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE as a, resolveOpenAIReasoningEffortForModel as b, OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE as c, OpenAIResponsesWebSocketSafeRetryError as d, RESPONSE_FAILED_NO_DETAILS_MESSAGE as f, isOpenAIGpt55Model as g, isOpenAIGpt54MiniModel as h, OPENAI_RESPONSES_APIS as i, OpenAIResponsesWebSocketPostDispatchError as l, responsesPromptObserver as m, DEFAULT_AZURE_OPENAI_API_VERSION as n, OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY as o, parseOpenAIResponsesWebSocketServerError as p, OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS as r, OPENAI_RESPONSES_REASONING_REPLAY_META_KEY as s, AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS as t, OpenAIResponsesWebSocketPreDispatchError as u, normalizeOpenAIReasoningEffort as v, resolveOpenAISupportedReasoningEfforts as x, resolveOpenAIModelReasoningEfforts as y };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { m as stripSystemPromptCacheBoundary } from "./simple-options-BQbb4yQL.mjs";
|
|
2
|
-
import { _ as sanitizeTransportPayloadText } from "./transport-stream-shared-zHll9BxO.mjs";
|
|
3
|
-
import { m as responsesPromptObserver } from "./openai-responses-contracts-DDOHA62Y.mjs";
|
|
4
|
-
//#region packages/ai/src/transports/openai-responses-prompt-observer-internal.ts
|
|
5
|
-
function readFinalResponsesPrompt(request) {
|
|
6
|
-
if (typeof request.instructions === "string") return ["instructions", request.instructions];
|
|
7
|
-
const message = (Array.isArray(request.input) ? request.input : []).find((item) => {
|
|
8
|
-
const role = item.role;
|
|
9
|
-
return role === "developer" || role === "system";
|
|
10
|
-
});
|
|
11
|
-
if (!message) return ["missing", ""];
|
|
12
|
-
const content = message.content;
|
|
13
|
-
const observedPrompt = typeof content === "string" ? content : Array.isArray(content) ? content.flatMap((part) => part.type === "input_text" ? [part.text] : []).join("") : "";
|
|
14
|
-
return [message.role === "developer" ? "input.developer" : "input.system", observedPrompt];
|
|
15
|
-
}
|
|
16
|
-
function createResponsesPromptEgressObserver(options, assembledPrompt) {
|
|
17
|
-
const observer = options ? responsesPromptObserver.get(options) : void 0;
|
|
18
|
-
if (!observer) return;
|
|
19
|
-
const expectedPrompt = sanitizeTransportPayloadText(stripSystemPromptCacheBoundary(assembledPrompt ?? ""));
|
|
20
|
-
return (request, metadata) => {
|
|
21
|
-
const [promptSource, observedPrompt] = readFinalResponsesPrompt(request);
|
|
22
|
-
observer({
|
|
23
|
-
...metadata,
|
|
24
|
-
promptSource,
|
|
25
|
-
expectedChars: expectedPrompt.length,
|
|
26
|
-
observedChars: observedPrompt.length,
|
|
27
|
-
matchesAssembledPrompt: promptSource !== "missing" && observedPrompt === expectedPrompt
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
export { createResponsesPromptEgressObserver as t };
|
package/dist/src-DDmEryvj.mjs
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
2
|
-
import { types } from "node:util";
|
|
3
|
-
//#region packages/ai/src/providers/tool-schema-json-projection.ts
|
|
4
|
-
function isNonFiniteNumberValue(value) {
|
|
5
|
-
if (typeof value === "number") return !Number.isFinite(value);
|
|
6
|
-
if (value === null || typeof value !== "object" || !types.isNumberObject(value)) return false;
|
|
7
|
-
return !Number.isFinite(Number.prototype.valueOf.call(value));
|
|
8
|
-
}
|
|
9
|
-
function serializeToolInputSchema(value, path) {
|
|
10
|
-
const nonFiniteNumber = { path: null };
|
|
11
|
-
const paths = /* @__PURE__ */ new WeakMap();
|
|
12
|
-
let isRoot = true;
|
|
13
|
-
let text;
|
|
14
|
-
try {
|
|
15
|
-
text = JSON.stringify(value, function(key, entry) {
|
|
16
|
-
const invalidNumber = nonFiniteNumber.path === null && isNonFiniteNumberValue(entry);
|
|
17
|
-
if (invalidNumber || entry && typeof entry === "object") {
|
|
18
|
-
const holderPath = paths.get(this);
|
|
19
|
-
const entryPath = isRoot ? path : holderPath === void 0 ? `${path}.${key}` : Array.isArray(this) ? `${holderPath}[${key}]` : `${holderPath}.${key}`;
|
|
20
|
-
if (invalidNumber) nonFiniteNumber.path = entryPath;
|
|
21
|
-
else paths.set(entry, entryPath);
|
|
22
|
-
}
|
|
23
|
-
isRoot = false;
|
|
24
|
-
return entry;
|
|
25
|
-
});
|
|
26
|
-
} catch {
|
|
27
|
-
return {
|
|
28
|
-
schema: {},
|
|
29
|
-
violations: [`${path} is not JSON-serializable`]
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
if (!text) return {
|
|
33
|
-
schema: {},
|
|
34
|
-
violations: [`${path} is not JSON-serializable`]
|
|
35
|
-
};
|
|
36
|
-
if (nonFiniteNumber.path !== null) return {
|
|
37
|
-
schema: {},
|
|
38
|
-
violations: [`${nonFiniteNumber.path} is not JSON-serializable`]
|
|
39
|
-
};
|
|
40
|
-
return {
|
|
41
|
-
schema: JSON.parse(text),
|
|
42
|
-
violations: []
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
const schemaMapKeywords = /* @__PURE__ */ new Set([
|
|
46
|
-
"$defs",
|
|
47
|
-
"definitions",
|
|
48
|
-
"dependencies",
|
|
49
|
-
"dependentSchemas",
|
|
50
|
-
"patternProperties",
|
|
51
|
-
"properties"
|
|
52
|
-
]);
|
|
53
|
-
function inspectJsonSchema(schema, path, violations) {
|
|
54
|
-
if (Array.isArray(schema)) return schema.every((entry, index) => inspectJsonSchema(entry, `${path}[${index}]`, violations));
|
|
55
|
-
if (!isRecord(schema)) return typeof schema !== "number" || Number.isFinite(schema);
|
|
56
|
-
for (const key of ["$dynamicRef", "$dynamicAnchor"]) if (key in schema) violations.push(`${path}.${key}`);
|
|
57
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
58
|
-
if (typeof value === "number" && !Number.isFinite(value)) return false;
|
|
59
|
-
if (!value || typeof value !== "object") continue;
|
|
60
|
-
if (schemaMapKeywords.has(key) && isRecord(value)) {
|
|
61
|
-
for (const [schemaName, childSchema] of Object.entries(value)) if (!inspectJsonSchema(childSchema, `${path}.${key}.${schemaName}`, violations)) return false;
|
|
62
|
-
} else if (!inspectJsonSchema(value, `${path}.${key}`, violations)) return false;
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
/** Projects one runtime tool input schema to JSON and reports runtime incompatibilities. */
|
|
67
|
-
function projectRuntimeToolInputSchema(schema, path = "parameters") {
|
|
68
|
-
const projection = serializeToolInputSchema(schema, path);
|
|
69
|
-
const violations = [...projection.violations];
|
|
70
|
-
if (!isRecord(projection.schema)) violations.push(`${path} must be a JSON object schema`);
|
|
71
|
-
else if (projection.schema.type !== void 0 && projection.schema.type !== "object") violations.push(`${path}.type must be "object"`);
|
|
72
|
-
if (!inspectJsonSchema(projection.schema, path, violations)) return {
|
|
73
|
-
schema: {},
|
|
74
|
-
violations: [`${path} is not a JSON value`]
|
|
75
|
-
};
|
|
76
|
-
return {
|
|
77
|
-
schema: projection.schema,
|
|
78
|
-
violations
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
//#endregion
|
|
82
|
-
export { projectRuntimeToolInputSchema as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./index-DdD3qerf.mjs";
|