@openclaw/ai 2026.7.2-beta.7 → 2026.8.1-beta.1
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/dist/{anthropic-CH4UUnZr.mjs → anthropic-CE-7SkF6.mjs} +28 -191
- package/dist/{anthropic-usage-DWU-x8MI.mjs → anthropic-usage-Ma4iX6uG.mjs} +262 -4
- package/dist/{api-registry-DlMgPR39.d.mts → api-registry-EpJoVwM1.d.mts} +1 -1
- package/dist/{azure-openai-responses-CImcwB83.mjs → azure-openai-responses-Cc_kasye.mjs} +4 -4
- package/dist/{event-stream-D8n2uFee.mjs → event-stream-CEV9t6da.mjs} +10 -2
- package/dist/{event-stream-YjaPW20U.d.mts → event-stream-DRmDMRHH.d.mts} +2 -1
- package/dist/event-stream.d.mts +1 -1
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-CtSg0iTS.mjs → google-CGQu21aw.mjs} +5 -5
- package/dist/{google-shared-DNBz5rcD.mjs → google-shared-Cq2UKx1l.mjs} +151 -85
- package/dist/{google-vertex-31f1uS9L.mjs → google-vertex-CusxWzvE.mjs} +10 -7
- package/dist/{host-Dog2WQiR.mjs → host-Bl7Kgddo.mjs} +40 -2
- package/dist/{host-B9GUmcra.d.mts → host-Dn4_SZI2.d.mts} +2 -2
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +2 -2
- package/dist/internal/anthropic.d.mts +19 -3
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/openai.d.mts +4 -4
- package/dist/internal/openai.mjs +7 -7
- package/dist/internal/runtime.d.mts +2 -2
- package/dist/internal/runtime.mjs +3 -3
- package/dist/internal/shared.d.mts +1 -1
- package/dist/internal/shared.mjs +3 -4
- package/dist/{mistral-CWmpvWYh.mjs → mistral-Dx6VzNjf.mjs} +25 -9
- package/dist/model-utils-Dau5dlgm.mjs +64 -0
- package/dist/number-coercion-1Miyb5MO.mjs +66 -0
- package/dist/{openai-chatgpt-responses-B84Ibtrd.mjs → openai-chatgpt-responses-SC9m0FSf.mjs} +94 -131
- package/dist/{openai-completions-DsOxhOD1.mjs → openai-completions-BaIpl93j.mjs} +47 -66
- package/dist/{openai-reasoning-compat-YgeLncHw.mjs → openai-reasoning-compat-DKebnIBL.mjs} +147 -6
- package/dist/{openai-responses-BT7A3sLu.mjs → openai-responses-Bdx3V_Yu.mjs} +6 -22
- package/dist/openai-responses-contracts-BBKBfAqR.d.mts +116 -0
- package/dist/openai-responses-prompt-observer-internal-DDZPxRfr.mjs +46 -0
- package/dist/{openai-responses-shared-pXl6Wd8S.mjs → openai-responses-shared-CCyMvg7M.mjs} +21 -10
- package/dist/{openai-responses-stream-internal-Cw5txaGW.mjs → openai-responses-stream-internal-Bl8YyVtF.mjs} +244 -81
- package/dist/{openai-tool-projection-OhX64DoP.mjs → openai-transport-shared-Cipt7egQ.mjs} +129 -29
- package/dist/{provider-error-CAEvRjry.mjs → provider-error-DI0Ts28U.mjs} +1 -1
- package/dist/{provider-options-D8bB3z9b.d.mts → provider-options-C5kYML7i.d.mts} +1 -1
- package/dist/providers.d.mts +1 -1
- package/dist/providers.mjs +9 -9
- package/dist/{stream-first-event-timeout-BBys9hSb.mjs → stream-first-event-timeout-BIBomOGq.mjs} +1 -1
- package/dist/{tool-result-text-CTpIRbYd.mjs → tool-result-text-Dvkp2Dus.mjs} +51 -2
- package/dist/{tool-schema-json-projection-BwNu3nDi.mjs → tool-schema-json-projection-B1b-XCn5.mjs} +28 -1
- package/dist/transform-messages-DfjpNXNQ.mjs +2 -0
- package/dist/{transport-stream-shared-D81p90xq.mjs → transport-stream-shared-CPNv7A3r.mjs} +4 -4
- package/dist/transports.d.mts +41 -73
- package/dist/transports.mjs +317 -601
- package/dist/{types-bzp5k29J.d.mts → types-CH7ReIcU.d.mts} +4 -0
- package/dist/types.d.mts +3 -3
- package/dist/types.mjs +1 -1
- package/dist/{validation-B-j7cOYp.d.mts → validation-CcPcuEbR.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/package.json +1 -1
- package/dist/error-coercion-DgxlWC0n.mjs +0 -15
- package/dist/number-coercion-DvG7SNMg.mjs +0 -129
- package/dist/openai-completions-compat-DBWjXoMZ.d.mts +0 -43
- package/dist/simple-options-9lhRrN73.mjs +0 -50
- package/dist/transform-messages-C8mBqZxF.mjs +0 -2
|
@@ -217,6 +217,10 @@ interface Usage {
|
|
|
217
217
|
output: number;
|
|
218
218
|
cacheRead: number;
|
|
219
219
|
cacheWrite: number;
|
|
220
|
+
/** Whether the provider reported a cache-read/write token split. */
|
|
221
|
+
cacheTelemetry?: {
|
|
222
|
+
state: "available" | "unavailable";
|
|
223
|
+
};
|
|
220
224
|
/** Subset of `cacheWrite` written with 1-hour retention when reported. */
|
|
221
225
|
cacheWrite1h?: number;
|
|
222
226
|
/** Exact context snapshot for the final provider iteration. */
|
package/dist/types.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, f as supportsClaude1MContext, g as supportsClaudeNativeXhighEffort, h as supportsClaudeNativeMaxEffort, i as requiresClaudeDefaultSampling, l as resolveClaudeNativeThinkingLevelMap, m as supportsClaudeFastMode, n as CLAUDE_OPUS_5_THINKING_PROFILE, o as resolveClaudeFable5ModelIdentity, p as supportsClaudeAdaptiveThinking, r as CLAUDE_SONNET_5_THINKING_PROFILE, s as resolveClaudeModelIdentity, t as CLAUDE_FABLE_5_THINKING_PROFILE, u as resolveClaudeOpus5ModelIdentity } from "./anthropic-SrGtwsJu.mjs";
|
|
2
2
|
import { a as extractDiagnosticError, i as createAssistantMessageDiagnostic, n as DiagnosticErrorInfo, o as formatThrownValue, r as appendAssistantMessageDiagnostic, t as AssistantMessageDiagnostic } from "./diagnostics-BaTA9eVl.mjs";
|
|
3
|
-
import { $ as VercelGatewayRouting, A as OpenRouterRouting, B as TextContent, C as KnownImagesProvider, D as ModelThinkingLevel, E as Model, F as SimpleStreamOptions, G as ThinkingLevelMap, H as ThinkingBudgets, I as StopReason, J as ToolResultMessage, K as Tool, L as StreamFn, M as ProviderImagesOptions, N as ProviderResponse, O as OpenAICompletionsCompat, P as ProviderStreamOptions, Q as ValidateToolArgumentsFn, R as StreamFunction, S as KnownImagesApi, T as Message, U as ThinkingContent, V as TextSignatureV1, W as ThinkingLevel, X as Usage, Y as Transport, Z as UserMessage, _ as ImagesOptions, a as AssistantMessageEvent, b as ImagesStopReason, c as CacheRetention, d as ImageContent, f as ImagesApi, g as ImagesModel, h as ImagesInputContent, i as AssistantMessage, j as Provider, k as OpenAIResponsesCompat, l as CompleteSimpleFn, m as ImagesFunction, n as Api, o as AssistantMessageEventStreamContract, p as ImagesContext, q as ToolCall, r as AssistantImages, s as AssistantMessageEventStreamLike, t as AnthropicMessagesCompat, u as Context, v as ImagesOutputContent, w as MaybePromise, x as KnownApi, y as ImagesProvider, z as StreamOptions } from "./types-
|
|
4
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
5
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
3
|
+
import { $ as VercelGatewayRouting, A as OpenRouterRouting, B as TextContent, C as KnownImagesProvider, D as ModelThinkingLevel, E as Model, F as SimpleStreamOptions, G as ThinkingLevelMap, H as ThinkingBudgets, I as StopReason, J as ToolResultMessage, K as Tool, L as StreamFn, M as ProviderImagesOptions, N as ProviderResponse, O as OpenAICompletionsCompat, P as ProviderStreamOptions, Q as ValidateToolArgumentsFn, R as StreamFunction, S as KnownImagesApi, T as Message, U as ThinkingContent, V as TextSignatureV1, W as ThinkingLevel, X as Usage, Y as Transport, Z as UserMessage, _ as ImagesOptions, a as AssistantMessageEvent, b as ImagesStopReason, c as CacheRetention, d as ImageContent, f as ImagesApi, g as ImagesModel, h as ImagesInputContent, i as AssistantMessage, j as Provider, k as OpenAIResponsesCompat, l as CompleteSimpleFn, m as ImagesFunction, n as Api, o as AssistantMessageEventStreamContract, p as ImagesContext, q as ToolCall, r as AssistantImages, s as AssistantMessageEventStreamLike, t as AnthropicMessagesCompat, u as Context, v as ImagesOutputContent, w as MaybePromise, x as KnownApi, y as ImagesProvider, z as StreamOptions } from "./types-CH7ReIcU.mjs";
|
|
4
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-DRmDMRHH.mjs";
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-CcPcuEbR.mjs";
|
|
6
6
|
export { AnthropicMessagesCompat, Api, 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, MaybePromise, Message, Model, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, Provider, ProviderImagesOptions, ProviderResponse, ProviderStreamOptions, SimpleStreamOptions, StopReason, StreamFn, StreamFunction, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
package/dist/types.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, f as supportsClaude1MContext, g as supportsClaudeNativeXhighEffort, h as supportsClaudeNativeMaxEffort, i as requiresClaudeDefaultSampling, l as resolveClaudeNativeThinkingLevelMap, m as supportsClaudeFastMode, n as CLAUDE_OPUS_5_THINKING_PROFILE, o as resolveClaudeFable5ModelIdentity, p as supportsClaudeAdaptiveThinking, r as CLAUDE_SONNET_5_THINKING_PROFILE, s as resolveClaudeModelIdentity, t as CLAUDE_FABLE_5_THINKING_PROFILE, u as resolveClaudeOpus5ModelIdentity } from "./src-QkygScBs.mjs";
|
|
2
2
|
import { i as formatThrownValue, n as createAssistantMessageDiagnostic, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-COpOtRwq.mjs";
|
|
3
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
3
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-CEV9t6da.mjs";
|
|
4
4
|
import { n as validateToolCall, t as validateToolArguments } from "./validation-DAa_yFOM.mjs";
|
|
5
5
|
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, EventStream, appendAssistantMessageDiagnostic, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
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-CcPcuEbR.mjs";
|
|
2
2
|
export { validateToolArguments, validateToolCall };
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region packages/normalization-core/src/error-coercion.ts
|
|
2
|
-
/**
|
|
3
|
-
* Normalizes an unknown thrown value into an Error. Non-Error objects become
|
|
4
|
-
* the `cause` and have their enumerable fields copied so structured details
|
|
5
|
-
* (codes, statuses) survive the coercion.
|
|
6
|
-
*/
|
|
7
|
-
function toErrorObject(value, fallbackMessage) {
|
|
8
|
-
if (value instanceof Error) return value;
|
|
9
|
-
if (typeof value === "string") return new Error(value);
|
|
10
|
-
const error = new Error(fallbackMessage, { cause: value });
|
|
11
|
-
if (typeof value === "object" && value !== null || typeof value === "function") Object.assign(error, value);
|
|
12
|
-
return error;
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { toErrorObject as t };
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { a as requiresClaudeMandatoryAdaptiveThinking, l as resolveClaudeNativeThinkingLevelMap } from "./src-QkygScBs.mjs";
|
|
2
|
-
//#region packages/ai/src/model-utils.ts
|
|
3
|
-
/** Calculates and stores model cost fields from token usage and per-million pricing. */
|
|
4
|
-
function calculateCost(model, usage) {
|
|
5
|
-
const cacheWrite1h = Math.min(usage.cacheWrite, Math.max(0, usage.cacheWrite1h ?? 0));
|
|
6
|
-
const cacheWrite5m = usage.cacheWrite - cacheWrite1h;
|
|
7
|
-
usage.cost.input = model.cost.input / 1e6 * usage.input;
|
|
8
|
-
usage.cost.output = model.cost.output / 1e6 * usage.output;
|
|
9
|
-
usage.cost.cacheRead = model.cost.cacheRead / 1e6 * usage.cacheRead;
|
|
10
|
-
usage.cost.cacheWrite = (model.cost.cacheWrite * cacheWrite5m + model.cost.input * 2 * cacheWrite1h) / 1e6;
|
|
11
|
-
usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;
|
|
12
|
-
return usage.cost;
|
|
13
|
-
}
|
|
14
|
-
/** Replaces the catalog estimate when the provider reports an authoritative billed total. */
|
|
15
|
-
function applyProviderReportedUsageCost(usage, reportedCost) {
|
|
16
|
-
if (typeof reportedCost !== "number" || !Number.isFinite(reportedCost) || reportedCost < 0) return;
|
|
17
|
-
usage.cost.total = reportedCost;
|
|
18
|
-
usage.cost.totalOrigin = "provider-billed";
|
|
19
|
-
}
|
|
20
|
-
const EXTENDED_THINKING_LEVELS = [
|
|
21
|
-
"off",
|
|
22
|
-
"minimal",
|
|
23
|
-
"low",
|
|
24
|
-
"medium",
|
|
25
|
-
"high",
|
|
26
|
-
"xhigh",
|
|
27
|
-
"max"
|
|
28
|
-
];
|
|
29
|
-
function resolveThinkingLevelMap(model) {
|
|
30
|
-
return model.api === "anthropic-messages" ? resolveClaudeNativeThinkingLevelMap(model) ?? model.thinkingLevelMap : model.thinkingLevelMap;
|
|
31
|
-
}
|
|
32
|
-
/** Returns thinking levels exposed by a reasoning-capable model. */
|
|
33
|
-
function getSupportedThinkingLevels(model) {
|
|
34
|
-
const mandatoryAdaptiveContract = model.api === "anthropic-messages" && requiresClaudeMandatoryAdaptiveThinking(model);
|
|
35
|
-
if (!model.reasoning && !mandatoryAdaptiveContract) return ["off"];
|
|
36
|
-
const thinkingLevelMap = resolveThinkingLevelMap(model);
|
|
37
|
-
return EXTENDED_THINKING_LEVELS.filter((level) => {
|
|
38
|
-
const mapped = thinkingLevelMap?.[level];
|
|
39
|
-
if (mapped === null) return false;
|
|
40
|
-
if (level === "xhigh" || level === "max") return mapped !== void 0;
|
|
41
|
-
return true;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/** Clamps a requested thinking level to the closest supported level for a model. */
|
|
45
|
-
function clampThinkingLevel(model, level) {
|
|
46
|
-
const availableLevels = getSupportedThinkingLevels(model);
|
|
47
|
-
if (availableLevels.includes(level)) return level;
|
|
48
|
-
const requestedIndex = EXTENDED_THINKING_LEVELS.indexOf(level);
|
|
49
|
-
if (requestedIndex === -1) return availableLevels[0] ?? "off";
|
|
50
|
-
const thinkingLevelMap = resolveThinkingLevelMap(model);
|
|
51
|
-
if ((level === "xhigh" || level === "max") && thinkingLevelMap?.[level] === null) {
|
|
52
|
-
for (const candidate of EXTENDED_THINKING_LEVELS.slice(0, requestedIndex).toReversed()) if (availableLevels.includes(candidate)) return candidate;
|
|
53
|
-
}
|
|
54
|
-
for (const candidate of EXTENDED_THINKING_LEVELS.slice(requestedIndex)) if (availableLevels.includes(candidate)) return candidate;
|
|
55
|
-
for (const candidate of EXTENDED_THINKING_LEVELS.slice(0, requestedIndex).toReversed()) if (availableLevels.includes(candidate)) return candidate;
|
|
56
|
-
return availableLevels[0] ?? "off";
|
|
57
|
-
}
|
|
58
|
-
/** Compares model identity by provider and id. */
|
|
59
|
-
function modelsAreEqual(a, b) {
|
|
60
|
-
if (!a || !b) return false;
|
|
61
|
-
return a.id === b.id && a.provider === b.provider;
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region packages/normalization-core/src/number-coercion.ts
|
|
65
|
-
/** Returns a number only when the input is already finite. */
|
|
66
|
-
function asFiniteNumber(value) {
|
|
67
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
68
|
-
}
|
|
69
|
-
/** Returns a finite number only when it satisfies the supplied inclusive/exclusive bounds. */
|
|
70
|
-
function asFiniteNumberInRange(value, range) {
|
|
71
|
-
const number = asFiniteNumber(value);
|
|
72
|
-
if (number === void 0) return;
|
|
73
|
-
if (range.min !== void 0) {
|
|
74
|
-
if (range.minExclusive ? number <= range.min : number < range.min) return;
|
|
75
|
-
}
|
|
76
|
-
if (range.max !== void 0) {
|
|
77
|
-
if (range.maxExclusive ? number >= range.max : number > range.max) return;
|
|
78
|
-
}
|
|
79
|
-
return number;
|
|
80
|
-
}
|
|
81
|
-
function normalizeNumericString(value) {
|
|
82
|
-
const trimmed = value.trim();
|
|
83
|
-
return trimmed ? trimmed : void 0;
|
|
84
|
-
}
|
|
85
|
-
/** Parses only safe integer numbers or base-10 integer strings. */
|
|
86
|
-
function parseStrictInteger(value) {
|
|
87
|
-
if (typeof value === "number") return Number.isSafeInteger(value) ? value : void 0;
|
|
88
|
-
if (typeof value !== "string") return;
|
|
89
|
-
const normalized = normalizeNumericString(value);
|
|
90
|
-
if (!normalized || !/^[+-]?\d+$/.test(normalized)) return;
|
|
91
|
-
const parsed = Number(normalized);
|
|
92
|
-
return Number.isSafeInteger(parsed) ? parsed : void 0;
|
|
93
|
-
}
|
|
94
|
-
/** Parses only finite decimal/scientific string tokens, rejecting partial numbers. */
|
|
95
|
-
function parseStrictFiniteNumber(value) {
|
|
96
|
-
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
97
|
-
if (typeof value !== "string") return;
|
|
98
|
-
const normalized = normalizeNumericString(value);
|
|
99
|
-
if (!normalized || !/^[+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:e[+-]?\d+)?$/i.test(normalized)) return;
|
|
100
|
-
const parsed = Number(normalized);
|
|
101
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
102
|
-
}
|
|
103
|
-
/** Conservative upper bound for Node timer delays. */
|
|
104
|
-
const MAX_TIMER_TIMEOUT_MS = 2147e6;
|
|
105
|
-
/** Clamps finite millisecond values into the Node-safe timer range. */
|
|
106
|
-
function clampTimerTimeoutMs(valueMs, minMs = 1) {
|
|
107
|
-
const value = asFiniteNumber(valueMs);
|
|
108
|
-
if (value === void 0) return;
|
|
109
|
-
return Math.min(Math.max(Math.floor(value), Math.max(1, Math.floor(minMs))), MAX_TIMER_TIMEOUT_MS);
|
|
110
|
-
}
|
|
111
|
-
/** Resolves arbitrary timeout input with fallback and minimum timer bounds. */
|
|
112
|
-
function resolveTimerTimeoutMs(valueMs, fallbackMs, minMs = 1) {
|
|
113
|
-
const value = asFiniteNumber(valueMs) ?? asFiniteNumber(fallbackMs);
|
|
114
|
-
const min = Math.max(0, Math.floor(minMs));
|
|
115
|
-
if (value === void 0) return min;
|
|
116
|
-
return Math.min(Math.max(Math.floor(value), min), MAX_TIMER_TIMEOUT_MS);
|
|
117
|
-
}
|
|
118
|
-
/** Parses strict positive integer values from numbers or strings. */
|
|
119
|
-
function parseStrictPositiveInteger(value) {
|
|
120
|
-
const parsed = parseStrictInteger(value);
|
|
121
|
-
return parsed !== void 0 && parsed > 0 ? parsed : void 0;
|
|
122
|
-
}
|
|
123
|
-
/** Parses strict non-negative integer values from numbers or strings. */
|
|
124
|
-
function parseStrictNonNegativeInteger(value) {
|
|
125
|
-
const parsed = parseStrictInteger(value);
|
|
126
|
-
return parsed !== void 0 && parsed >= 0 ? parsed : void 0;
|
|
127
|
-
}
|
|
128
|
-
//#endregion
|
|
129
|
-
export { parseStrictPositiveInteger as a, calculateCost as c, modelsAreEqual as d, parseStrictNonNegativeInteger as i, clampThinkingLevel as l, clampTimerTimeoutMs as n, resolveTimerTimeoutMs as o, parseStrictFiniteNumber as r, applyProviderReportedUsageCost as s, asFiniteNumberInRange as t, getSupportedThinkingLevels as u };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { E as Model, O as OpenAICompletionsCompat } from "./types-bzp5k29J.mjs";
|
|
2
|
-
import { a as AiProviderRequestPolicyInput, i as AiProviderRequestCapabilities } from "./host-B9GUmcra.mjs";
|
|
3
|
-
|
|
4
|
-
//#region packages/ai/src/transports/openai-completions-compat.d.ts
|
|
5
|
-
type ProviderRequestCapabilities = AiProviderRequestCapabilities;
|
|
6
|
-
type OpenAICompletionsSessionAffinity = "none" | "openai" | "openrouter";
|
|
7
|
-
type OpenAICompletionsCompatDefaults = {
|
|
8
|
-
supportsStore: boolean;
|
|
9
|
-
supportsDeveloperRole: boolean;
|
|
10
|
-
supportsReasoningEffort: boolean;
|
|
11
|
-
supportsUsageInStreaming: boolean;
|
|
12
|
-
maxTokensField: "max_completion_tokens" | "max_tokens";
|
|
13
|
-
thinkingFormat: "openai" | "openrouter" | "deepseek" | "together" | "zai";
|
|
14
|
-
visibleReasoningDetailTypes: string[];
|
|
15
|
-
supportsStrictMode: boolean;
|
|
16
|
-
supportsJsonSchemaResponseFormat: boolean;
|
|
17
|
-
requiresReasoningContentOnAssistantMessages: boolean;
|
|
18
|
-
requiresNonEmptyUserOrAssistantMessage: boolean;
|
|
19
|
-
cacheControlFormat?: OpenAICompletionsCompat["cacheControlFormat"];
|
|
20
|
-
sessionAffinityFormat: Exclude<OpenAICompletionsSessionAffinity, "none">;
|
|
21
|
-
supportsLongCacheRetention: boolean;
|
|
22
|
-
};
|
|
23
|
-
type DetectedOpenAICompletionsCompat = {
|
|
24
|
-
capabilities: ProviderRequestCapabilities;
|
|
25
|
-
defaults: OpenAICompletionsCompatDefaults;
|
|
26
|
-
};
|
|
27
|
-
type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCompat>, "cacheControlFormat" | "openRouterRouting" | "sendSessionAffinityHeaders"> & {
|
|
28
|
-
cacheControlFormat?: OpenAICompletionsCompat["cacheControlFormat"];
|
|
29
|
-
openRouterRouting?: OpenAICompletionsCompat["openRouterRouting"];
|
|
30
|
-
sessionAffinity: OpenAICompletionsSessionAffinity;
|
|
31
|
-
visibleReasoningDetailTypes: string[];
|
|
32
|
-
requiresNonEmptyUserOrAssistantMessage: boolean;
|
|
33
|
-
};
|
|
34
|
-
/** Detects endpoint capabilities and defaults for an OpenAI-completions model. */
|
|
35
|
-
declare function detectOpenAICompletionsCompat(model: Pick<Model<"openai-completions">, "provider" | "baseUrl" | "id"> & {
|
|
36
|
-
compat?: {
|
|
37
|
-
supportsStore?: boolean;
|
|
38
|
-
} | null;
|
|
39
|
-
}, resolveCapabilities?: (input: AiProviderRequestPolicyInput) => ProviderRequestCapabilities): DetectedOpenAICompletionsCompat;
|
|
40
|
-
/** Applies explicit model overrides once on top of the canonical transport defaults. */
|
|
41
|
-
declare function resolveOpenAICompletionsCompat(model: Model<"openai-completions">, resolveCapabilities?: (input: AiProviderRequestPolicyInput) => ProviderRequestCapabilities): ResolvedOpenAICompletionsCompat;
|
|
42
|
-
//#endregion
|
|
43
|
-
export { detectOpenAICompletionsCompat as n, resolveOpenAICompletionsCompat as r, ResolvedOpenAICompletionsCompat as t };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
//#region packages/ai/src/providers/simple-options.ts
|
|
2
|
-
function buildBaseOptions(model, options, apiKey) {
|
|
3
|
-
const firstEventOptions = options;
|
|
4
|
-
return {
|
|
5
|
-
temperature: options?.temperature,
|
|
6
|
-
maxTokens: options?.maxTokens,
|
|
7
|
-
stop: options?.stop,
|
|
8
|
-
signal: options?.signal,
|
|
9
|
-
apiKey: apiKey || options?.apiKey,
|
|
10
|
-
transport: options?.transport,
|
|
11
|
-
cacheRetention: options?.cacheRetention,
|
|
12
|
-
sessionId: options?.sessionId,
|
|
13
|
-
promptCacheKey: options?.promptCacheKey,
|
|
14
|
-
headers: options?.headers,
|
|
15
|
-
onPayload: options?.onPayload,
|
|
16
|
-
onResponse: options?.onResponse,
|
|
17
|
-
timeoutMs: options?.timeoutMs,
|
|
18
|
-
firstEventTimeoutMs: firstEventOptions?.firstEventTimeoutMs,
|
|
19
|
-
onFirstEventTimeout: firstEventOptions?.onFirstEventTimeout,
|
|
20
|
-
maxRetries: options?.maxRetries,
|
|
21
|
-
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
22
|
-
metadata: options?.metadata
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function clampMaxTokensToModel(model, requestedMaxTokens) {
|
|
26
|
-
return requestedMaxTokens === void 0 ? void 0 : Math.max(1, Math.min(requestedMaxTokens, model.maxTokens));
|
|
27
|
-
}
|
|
28
|
-
function clampReasoning(effort) {
|
|
29
|
-
return effort === "xhigh" ? "high" : effort;
|
|
30
|
-
}
|
|
31
|
-
function adjustMaxTokensForThinking(baseMaxTokens, modelMaxTokens, reasoningLevel, customBudgets) {
|
|
32
|
-
const budgets = {
|
|
33
|
-
minimal: 1024,
|
|
34
|
-
low: 2048,
|
|
35
|
-
medium: 8192,
|
|
36
|
-
high: 16384,
|
|
37
|
-
max: 32768,
|
|
38
|
-
...customBudgets
|
|
39
|
-
};
|
|
40
|
-
const minOutputTokens = 1024;
|
|
41
|
-
let thinkingBudget = budgets[clampReasoning(reasoningLevel)];
|
|
42
|
-
const maxTokens = baseMaxTokens === void 0 ? modelMaxTokens : Math.min(baseMaxTokens + thinkingBudget, modelMaxTokens);
|
|
43
|
-
if (maxTokens <= thinkingBudget) thinkingBudget = Math.max(0, maxTokens - minOutputTokens);
|
|
44
|
-
return {
|
|
45
|
-
maxTokens,
|
|
46
|
-
thinkingBudget
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
|
-
export { clampReasoning as i, buildBaseOptions as n, clampMaxTokensToModel as r, adjustMaxTokensForThinking as t };
|