@openclaw/ai 2026.9.1-beta.1 → 2026.9.2
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-DI4PZKKB.mjs → anthropic-BDdqdVLK.mjs} +222 -216
- package/dist/{anthropic-compaction-replay-nhKaCXu6.mjs → anthropic-compaction-replay-DB2FGLQc.mjs} +160 -68
- package/dist/{anthropic-payload-policy-B_0n0enE.d.mts → anthropic-payload-policy-d46X2pR0.d.mts} +28 -4
- package/dist/{api-registry-CTd8NzcD.d.mts → api-registry-DWtPjzyn.d.mts} +2 -2
- package/dist/{azure-openai-responses-D8dI0ekg.mjs → azure-openai-responses-C5bZRfAP.mjs} +12 -9
- package/dist/{number-coercion-H9qHik3g.mjs → base64-CEFBpSkN.mjs} +73 -1
- package/dist/{diagnostics-COpOtRwq.mjs → diagnostics-CPeq9F7y.mjs} +5 -1
- package/dist/diagnostics-DfFyKeX_.mjs +136 -0
- package/dist/{diagnostics-BaTA9eVl.d.mts → diagnostics-DnPnOui6.d.mts} +5 -1
- package/dist/diagnostics.d.mts +8 -3
- package/dist/diagnostics.mjs +4 -3
- package/dist/{env-api-keys-DrgeBuva.mjs → env-api-keys-bktO00EJ.mjs} +2 -15
- package/dist/{event-stream-uSMZJ3FA.mjs → event-stream-BgDvQeum.mjs} +3 -9
- package/dist/{event-stream-LiXePESD.d.mts → event-stream-BhT5T1Ay.d.mts} +1 -1
- package/dist/event-stream-zctLx0yr.d.mts +1 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-Od-LLdVK.mjs → google-4qeuE8iX.mjs} +9 -7
- package/dist/{google-shared-Bgr9lFPw.mjs → google-shared-CWeG8RIl.mjs} +27 -23
- package/dist/{google-vertex-aerRSXc4.mjs → google-vertex-O9BcnB6X.mjs} +8 -6
- package/dist/{host-D51fmkH6.mjs → host-CEvLw30U.mjs} +54 -9
- package/dist/{host-DsbPMFU6.d.mts → host-DjzGmdZ2.d.mts} +3 -3
- package/dist/index-FnHM2FcI.d.mts +117 -0
- package/dist/index.d.mts +10 -11
- package/dist/index.mjs +6 -6
- package/dist/internal/anthropic.d.mts +59 -55
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
- package/dist/internal/openai-responses-payload-policy.mjs +2 -3
- package/dist/internal/openai.d.mts +66 -64
- package/dist/internal/openai.mjs +10 -10
- package/dist/internal/retry-after.d.mts +2 -3
- package/dist/internal/runtime.d.mts +43 -43
- package/dist/internal/runtime.mjs +10 -8
- package/dist/internal/shared.d.mts +25 -25
- package/dist/internal/shared.mjs +95 -4
- package/dist/{mistral-EiHdymeb.mjs → mistral-Tb6oalqH.mjs} +30 -23
- package/dist/{openai-chatgpt-responses-DHpF9o1e.mjs → openai-chatgpt-responses-yUXjPNfu.mjs} +76 -137
- package/dist/{openai-completions-EFPiUGfS.mjs → openai-completions-BIUV3RDT.mjs} +26 -22
- package/dist/{openai-completions-compat-BefmHT26.d.mts → openai-completions-compat-CpjYUArk.d.mts} +5 -5
- package/dist/{openai-completions-stream-DUlGwRMz.mjs → openai-completions-stream-BsrBe3Gg.mjs} +103 -96
- package/dist/openai-prompt-cache-CGnVB74a.mjs +21 -0
- package/dist/openai-prompt-cache-CNoIfHYC.d.mts +16 -0
- package/dist/{openai-responses-BogP8OjX.mjs → openai-responses-CCL41ALM.mjs} +15 -14
- package/dist/openai-responses-compaction-window-BMVHFOtq.mjs +697 -0
- package/dist/{openai-responses-contracts-Dvj_UtPy.d.mts → openai-responses-contracts-rF5DDRNS.d.mts} +23 -6
- package/dist/{openai-responses-payload-policy-CNGFT9zr.d.mts → openai-responses-payload-policy-rLRPsSmB.d.mts} +1 -0
- package/dist/{openai-responses-prompt-observer-internal-Cd4hJG-S.mjs → openai-responses-prompt-observer-internal-D0bhBfgL.mjs} +4 -18
- package/dist/{openai-responses-shared-DJThc6jW.mjs → openai-responses-shared-Bmma_3Qc.mjs} +438 -309
- package/dist/{openai-tool-schema-ho-hIkQf.mjs → openai-tool-schema-_pTAJqKF.mjs} +30 -40
- package/dist/{provider-error-DDOs_Bz0.mjs → provider-error-9TraxGvt.mjs} +20 -92
- package/dist/{provider-options-MdMBLzlU.d.mts → provider-options-Bcc_p-TU.d.mts} +26 -6
- package/dist/provider-replay-context-BuSUaAk5.mjs +21 -0
- package/dist/{provider-transcript-transform-C01bQ5a3.mjs → provider-transcript-transform-BaMbI1hr.mjs} +1 -1
- package/dist/provider-types.d.mts +19 -20
- package/dist/providers.d.mts +6 -6
- package/dist/providers.mjs +11 -11
- package/dist/{reasoning-tag-text-partitioner-5ygO2rZc.mjs → reasoning-tag-text-partitioner-DLCNXki6.mjs} +158 -94
- package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
- package/dist/{sanitize-unicode-DCkltN94.mjs → sanitize-unicode-D6xUvZaS.mjs} +2 -8
- package/dist/{simple-options-CFj7x3J4.mjs → simple-options-BjHCCh4v.mjs} +42 -6
- package/dist/{src-Bu3FiFAG.mjs → src-2qBGKg8O.mjs} +83 -2
- package/dist/{stream-first-event-timeout-MK28puvq.mjs → stream-first-event-timeout-DcNjoFQE.mjs} +1 -1
- package/dist/{tool-schema-json-projection-qvTEs5Am.mjs → tool-schema-json-projection-mJhXDcyz.mjs} +21 -31
- package/dist/{transport-stream-shared-ljShVIZB.mjs → transport-stream-shared-CZqMhfIw.mjs} +19 -6
- package/dist/{transport-stream-shared-rvaCyFYt.d.mts → transport-stream-shared-xnaqxmbP.d.mts} +5 -5
- package/dist/{transport-utils-LJ1_rbi-.mjs → transport-utils-7il795_9.mjs} +5 -8
- package/dist/transports.d.mts +121 -85
- package/dist/transports.mjs +747 -464
- package/dist/types-3Lnm-QSJ.d.mts +1 -0
- package/dist/{types-DhLoJbFm.d.mts → types-CJ1-Ht7A.d.mts} +55 -19
- package/dist/types.d.mts +7 -7
- package/dist/types.mjs +5 -5
- package/dist/{validation-Dk7q7NMN.d.mts → validation-AKZBDGQd.d.mts} +1 -1
- package/dist/{validation-B61OhAio.mjs → validation-CJZtym2g.mjs} +7 -5
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +5 -5
- package/dist/anthropic-BECQCNdF.d.mts +0 -98
- package/dist/event-stream-BKp4fOt_.d.mts +0 -1
- package/dist/index-Qbej8io0.d.mts +0 -3
- package/dist/openai-prompt-cache-2uo_1OR1.d.mts +0 -7
- package/dist/openai-prompt-cache-mZTCdRPo.mjs +0 -12
- package/dist/openai-responses-contracts-QUY12X0B.mjs +0 -233
- package/dist/openai-responses-payload-policy-D8EdimYe.mjs +0 -204
- package/dist/provider-options-AvldWZt8.mjs +0 -21
- package/dist/tls-certificate-errors-DXSpluKI.mjs +0 -93
- package/dist/types-GiAjXatj.d.mts +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __exportAll = (all, no_symbols) => {
|
|
5
|
+
let target = {};
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
14
|
+
//#endregion
|
|
15
|
+
export { __require as n, __exportAll as t };
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as requiresClaudeMandatoryAdaptiveThinking, p as resolveClaudeNativeThinkingLevelMap, t as calculateUsageCost } from "./src-2qBGKg8O.mjs";
|
|
2
2
|
//#region packages/ai/src/model-utils.ts
|
|
3
3
|
/** Calculates and stores model cost fields from token usage and per-million pricing. */
|
|
4
4
|
function calculateCost(model, usage) {
|
|
5
|
-
|
|
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;
|
|
5
|
+
Object.assign(usage.cost, calculateUsageCost(usage, model.cost));
|
|
12
6
|
return usage.cost;
|
|
13
7
|
}
|
|
14
8
|
/** Replaces the catalog estimate when the provider reports an authoritative billed total. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as normalizeLowercaseStringOrEmpty } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { t as sanitizeSurrogates } from "./sanitize-unicode-
|
|
3
|
-
import { r as copyProviderAcceptanceObserver } from "./transport-stream-shared-
|
|
2
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-D6xUvZaS.mjs";
|
|
3
|
+
import { r as copyProviderAcceptanceObserver } from "./transport-stream-shared-CZqMhfIw.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
|
|
@@ -66,10 +66,45 @@ function prependSystemPromptAdditionAfterCacheBoundary(params) {
|
|
|
66
66
|
return `${split.stablePrefix}${SYSTEM_PROMPT_CACHE_BOUNDARY}${systemPromptAddition}\n\n${dynamicSuffix}`;
|
|
67
67
|
}
|
|
68
68
|
//#endregion
|
|
69
|
+
//#region packages/ai/src/provider-options.ts
|
|
70
|
+
const CODE_MODE_TOOL_SURFACE_OBSERVER = Symbol("openaiCodeModeToolSurfaceObserver");
|
|
71
|
+
const CODE_MODE_TOOL_SURFACE_COLLECTOR = Symbol("openaiCodeModeToolSurfaceCollector");
|
|
72
|
+
const STRICT_REASONING_TAG_TEXT = Symbol("openaiStrictReasoningTagText");
|
|
73
|
+
function markStrictReasoningTagText(options) {
|
|
74
|
+
Reflect.set(options, STRICT_REASONING_TAG_TEXT, true);
|
|
75
|
+
}
|
|
76
|
+
function isStrictReasoningTagText(options) {
|
|
77
|
+
return options ? Reflect.get(options, STRICT_REASONING_TAG_TEXT) === true : false;
|
|
78
|
+
}
|
|
79
|
+
const codeModeToolSurfaceObserver = {
|
|
80
|
+
set(options, observer, collector) {
|
|
81
|
+
Reflect.set(options, CODE_MODE_TOOL_SURFACE_OBSERVER, observer);
|
|
82
|
+
if (collector) Reflect.set(options, CODE_MODE_TOOL_SURFACE_COLLECTOR, collector);
|
|
83
|
+
},
|
|
84
|
+
get(options) {
|
|
85
|
+
if (!options) return;
|
|
86
|
+
const observer = Reflect.get(options, CODE_MODE_TOOL_SURFACE_OBSERVER);
|
|
87
|
+
return typeof observer === "function" ? (observation) => observer(observation) : void 0;
|
|
88
|
+
},
|
|
89
|
+
getCollector(options) {
|
|
90
|
+
if (!options) return;
|
|
91
|
+
const collector = Reflect.get(options, CODE_MODE_TOOL_SURFACE_COLLECTOR);
|
|
92
|
+
return typeof collector === "function" ? (observation) => collector(observation) : void 0;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/** Internal output policy for callers that must not recover ambiguous reasoning as visible text. */
|
|
96
|
+
const reasoningTagTextPolicy = {
|
|
97
|
+
markStrict: markStrictReasoningTagText,
|
|
98
|
+
isStrict: isStrictReasoningTagText,
|
|
99
|
+
copy(source, target) {
|
|
100
|
+
if (isStrictReasoningTagText(source)) markStrictReasoningTagText(target);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
//#endregion
|
|
69
104
|
//#region packages/ai/src/providers/simple-options.ts
|
|
70
105
|
function buildBaseOptions(model, options, apiKey) {
|
|
71
106
|
const firstEventOptions = options;
|
|
72
|
-
|
|
107
|
+
const baseOptions = {
|
|
73
108
|
temperature: options?.temperature,
|
|
74
109
|
maxTokens: options?.maxTokens,
|
|
75
110
|
stop: options?.stop,
|
|
@@ -85,10 +120,11 @@ function buildBaseOptions(model, options, apiKey) {
|
|
|
85
120
|
timeoutMs: options?.timeoutMs,
|
|
86
121
|
firstEventTimeoutMs: firstEventOptions?.firstEventTimeoutMs,
|
|
87
122
|
onFirstEventTimeout: firstEventOptions?.onFirstEventTimeout,
|
|
88
|
-
maxRetries: options?.maxRetries,
|
|
89
123
|
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
90
124
|
metadata: options?.metadata
|
|
91
|
-
}
|
|
125
|
+
};
|
|
126
|
+
reasoningTagTextPolicy.copy(options, baseOptions);
|
|
127
|
+
return copyProviderAcceptanceObserver(options, baseOptions);
|
|
92
128
|
}
|
|
93
129
|
function clampMaxTokensToModel(model, requestedMaxTokens) {
|
|
94
130
|
return requestedMaxTokens === void 0 ? void 0 : Math.max(1, Math.min(requestedMaxTokens, model.maxTokens));
|
|
@@ -115,4 +151,4 @@ function adjustMaxTokensForThinking(baseMaxTokens, modelMaxTokens, reasoningLeve
|
|
|
115
151
|
};
|
|
116
152
|
}
|
|
117
153
|
//#endregion
|
|
118
|
-
export {
|
|
154
|
+
export { codeModeToolSurfaceObserver as a, ensureSystemPromptCacheBoundary as c, stripSystemPromptCacheBoundary as d, normalizePromptCapabilityIds as f, clampReasoning as i, prependSystemPromptAdditionAfterCacheBoundary as l, sortPromptCacheToolsByName as m, buildBaseOptions as n, reasoningTagTextPolicy as o, normalizeStructuredPromptSection as p, clampMaxTokensToModel as r, SYSTEM_PROMPT_CACHE_BOUNDARY as s, adjustMaxTokensForThinking as t, splitSystemPromptCacheBoundary as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./validation-
|
|
1
|
+
import "./validation-CJZtym2g.mjs";
|
|
2
2
|
//#region packages/llm-core/src/model-contracts/anthropic.ts
|
|
3
3
|
function normalizeClaudeModelId(modelId) {
|
|
4
4
|
const normalized = modelId?.trim().toLowerCase() ?? "";
|
|
@@ -51,6 +51,14 @@ function resolveClaudeMythos5ModelIdentity(ref) {
|
|
|
51
51
|
if (!match) return;
|
|
52
52
|
return normalized.slice((match.index ?? 0) + (match[0].startsWith("-") ? 1 : 0));
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Anthropic binds thinking to the conversation prefix starting with Fable 5.1 and
|
|
56
|
+
* plans to enforce it on later models. Extend only with live replay proof for the
|
|
57
|
+
* new model (Mythos 5.1 is unregistered here and unproven).
|
|
58
|
+
*/
|
|
59
|
+
function bindsClaudeThinkingPrefix(ref) {
|
|
60
|
+
return /^claude-fable-5-1(?=$|[^a-z0-9])/.test(resolveClaudeModelIdentity(ref));
|
|
61
|
+
}
|
|
54
62
|
/** Return whether a Claude model requires adaptive thinking instead of manual budgets. */
|
|
55
63
|
function requiresClaudeMandatoryAdaptiveThinking(ref) {
|
|
56
64
|
const modelId = resolveClaudeModelIdentity(ref);
|
|
@@ -114,4 +122,77 @@ function resolveClaudeNativeThinkingLevelMap(ref) {
|
|
|
114
122
|
};
|
|
115
123
|
}
|
|
116
124
|
//#endregion
|
|
117
|
-
|
|
125
|
+
//#region packages/llm-core/src/usage-cost.ts
|
|
126
|
+
const sortedPricingTiers = /* @__PURE__ */ new WeakMap();
|
|
127
|
+
const finiteOrZero = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
128
|
+
function normalizeTieredPricing(raw) {
|
|
129
|
+
if (!raw || raw.length === 0) return;
|
|
130
|
+
const result = [];
|
|
131
|
+
for (const tier of raw) {
|
|
132
|
+
const range = tier.range;
|
|
133
|
+
const start = Array.isArray(range) && typeof range[0] === "number" ? range[0] : NaN;
|
|
134
|
+
if (!Number.isFinite(start)) continue;
|
|
135
|
+
const rawEnd = range.length >= 2 ? range[1] : null;
|
|
136
|
+
const end = typeof rawEnd === "number" && Number.isFinite(rawEnd) && rawEnd > start ? rawEnd : Infinity;
|
|
137
|
+
if (!Number.isFinite(tier.input) || !Number.isFinite(tier.output) || !Number.isFinite(tier.cacheRead) || !Number.isFinite(tier.cacheWrite)) continue;
|
|
138
|
+
result.push({
|
|
139
|
+
input: tier.input,
|
|
140
|
+
output: tier.output,
|
|
141
|
+
cacheRead: tier.cacheRead,
|
|
142
|
+
cacheWrite: tier.cacheWrite,
|
|
143
|
+
range: [start, end]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return result.length > 0 ? result.toSorted((a, b) => a.range[0] - b.range[0]) : void 0;
|
|
147
|
+
}
|
|
148
|
+
function normalizeModelCostConfig(cost) {
|
|
149
|
+
const normalizedTiers = normalizeTieredPricing(cost.tieredPricing);
|
|
150
|
+
return {
|
|
151
|
+
input: cost.input,
|
|
152
|
+
output: cost.output,
|
|
153
|
+
cacheRead: cost.cacheRead,
|
|
154
|
+
cacheWrite: cost.cacheWrite,
|
|
155
|
+
...normalizedTiers ? { tieredPricing: normalizedTiers } : {}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function normalizeResolvedPricing(cost) {
|
|
159
|
+
return normalizeModelCostConfig({
|
|
160
|
+
input: finiteOrZero(cost.input),
|
|
161
|
+
output: finiteOrZero(cost.output),
|
|
162
|
+
cacheRead: finiteOrZero(cost.cacheRead),
|
|
163
|
+
cacheWrite: finiteOrZero(cost.cacheWrite),
|
|
164
|
+
...cost.tieredPricing ? { tieredPricing: cost.tieredPricing } : {}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function selectPricingRates(cost, promptTokens) {
|
|
168
|
+
const tiers = cost.tieredPricing;
|
|
169
|
+
if (!tiers?.length) return cost;
|
|
170
|
+
let sorted = sortedPricingTiers.get(tiers);
|
|
171
|
+
if (!sorted) {
|
|
172
|
+
sorted = normalizeTieredPricing(tiers) ?? [];
|
|
173
|
+
sortedPricingTiers.set(tiers, sorted);
|
|
174
|
+
}
|
|
175
|
+
if (promptTokens <= 0) return sorted[0] ?? cost;
|
|
176
|
+
return sorted.find((tier) => promptTokens >= tier.range[0] && promptTokens < tier.range[1]) ?? sorted.findLast((tier) => promptTokens >= tier.range[0]) ?? sorted[0] ?? cost;
|
|
177
|
+
}
|
|
178
|
+
/** Price one model call, selecting its tier before billing the separate token buckets. */
|
|
179
|
+
function calculateUsageCost(usage, pricing) {
|
|
180
|
+
const input = finiteOrZero(usage.input);
|
|
181
|
+
const output = finiteOrZero(usage.output);
|
|
182
|
+
const cacheRead = finiteOrZero(usage.cacheRead);
|
|
183
|
+
const cacheWrite = finiteOrZero(usage.cacheWrite);
|
|
184
|
+
const rates = selectPricingRates(pricing, input + cacheRead + cacheWrite);
|
|
185
|
+
const cacheWrite1h = Math.min(cacheWrite, Math.max(0, finiteOrZero(usage.cacheWrite1h)));
|
|
186
|
+
const cacheWrite5m = cacheWrite - cacheWrite1h;
|
|
187
|
+
const cost = {
|
|
188
|
+
input: input * rates.input / 1e6,
|
|
189
|
+
output: output * rates.output / 1e6,
|
|
190
|
+
cacheRead: cacheRead * rates.cacheRead / 1e6,
|
|
191
|
+
cacheWrite: (cacheWrite5m * rates.cacheWrite + cacheWrite1h * rates.input * 2) / 1e6,
|
|
192
|
+
total: 0
|
|
193
|
+
};
|
|
194
|
+
cost.total = cost.input + cost.output + cost.cacheRead + cost.cacheWrite;
|
|
195
|
+
return cost;
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
export { supportsClaudeAdaptiveThinking as _, CLAUDE_OPUS_5_THINKING_PROFILE as a, supportsClaudeNativeXhighEffort as b, requiresClaudeDefaultSampling as c, resolveClaudeModelIdentity as d, resolveClaudeMythos5ModelIdentity as f, supportsClaude1MContext as g, resolveClaudeSonnet5ModelIdentity as h, CLAUDE_FABLE_5_THINKING_PROFILE as i, requiresClaudeMandatoryAdaptiveThinking as l, resolveClaudeOpus5ModelIdentity as m, normalizeModelCostConfig as n, CLAUDE_SONNET_5_THINKING_PROFILE as o, resolveClaudeNativeThinkingLevelMap as p, normalizeResolvedPricing as r, bindsClaudeThinkingPrefix as s, calculateUsageCost as t, resolveClaudeFable5ModelIdentity as u, supportsClaudeFastMode as v, supportsClaudeNativeMaxEffort as y };
|
package/dist/{stream-first-event-timeout-MK28puvq.mjs → stream-first-event-timeout-DcNjoFQE.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as clampTimerTimeoutMs } from "./base64-CEFBpSkN.mjs";
|
|
2
2
|
//#region packages/ai/src/utils/stream-first-event-timeout.ts
|
|
3
3
|
function getFirstStreamEventTimeoutMs(options) {
|
|
4
4
|
return options?.firstEventTimeoutMs;
|
package/dist/{tool-schema-json-projection-qvTEs5Am.mjs → tool-schema-json-projection-mJhXDcyz.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as isRecord } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { n as getAiTransportHost } from "./host-
|
|
2
|
+
import { n as getAiTransportHost } from "./host-CEvLw30U.mjs";
|
|
3
3
|
import { types } from "node:util";
|
|
4
4
|
//#region packages/ai/src/transports/host-policy.ts
|
|
5
5
|
function buildGuardedModelFetch(model, timeoutMs, options) {
|
|
@@ -37,18 +37,6 @@ function transformTransportMessages(messages, model, normalizeToolCallId, option
|
|
|
37
37
|
}
|
|
38
38
|
//#endregion
|
|
39
39
|
//#region packages/ai/src/providers/tool-schema-json-projection.ts
|
|
40
|
-
function isJsonValue(value) {
|
|
41
|
-
if (value === null) return true;
|
|
42
|
-
switch (typeof value) {
|
|
43
|
-
case "boolean":
|
|
44
|
-
case "string": return true;
|
|
45
|
-
case "number": return Number.isFinite(value);
|
|
46
|
-
case "object":
|
|
47
|
-
if (Array.isArray(value)) return value.every(isJsonValue);
|
|
48
|
-
return Object.values(value).every(isJsonValue);
|
|
49
|
-
default: return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
40
|
function isNonFiniteNumberValue(value) {
|
|
53
41
|
if (typeof value === "number") return !Number.isFinite(value);
|
|
54
42
|
if (value === null || typeof value !== "object" || !types.isNumberObject(value)) return false;
|
|
@@ -61,11 +49,14 @@ function serializeToolInputSchema(value, path) {
|
|
|
61
49
|
let text;
|
|
62
50
|
try {
|
|
63
51
|
text = JSON.stringify(value, function(key, entry) {
|
|
64
|
-
const
|
|
65
|
-
|
|
52
|
+
const invalidNumber = nonFiniteNumber.path === null && isNonFiniteNumberValue(entry);
|
|
53
|
+
if (invalidNumber || entry && typeof entry === "object") {
|
|
54
|
+
const holderPath = paths.get(this);
|
|
55
|
+
const entryPath = isRoot ? path : holderPath === void 0 ? `${path}.${key}` : Array.isArray(this) ? `${holderPath}[${key}]` : `${holderPath}.${key}`;
|
|
56
|
+
if (invalidNumber) nonFiniteNumber.path = entryPath;
|
|
57
|
+
else paths.set(entry, entryPath);
|
|
58
|
+
}
|
|
66
59
|
isRoot = false;
|
|
67
|
-
if (nonFiniteNumber.path === null && isNonFiniteNumberValue(entry)) nonFiniteNumber.path = entryPath;
|
|
68
|
-
else if (entry && typeof entry === "object") paths.set(entry, entryPath);
|
|
69
60
|
return entry;
|
|
70
61
|
});
|
|
71
62
|
} catch {
|
|
@@ -82,13 +73,8 @@ function serializeToolInputSchema(value, path) {
|
|
|
82
73
|
schema: {},
|
|
83
74
|
violations: [`${nonFiniteNumber.path} is not JSON-serializable`]
|
|
84
75
|
};
|
|
85
|
-
const parsed = JSON.parse(text);
|
|
86
|
-
if (!isJsonValue(parsed)) return {
|
|
87
|
-
schema: {},
|
|
88
|
-
violations: [`${path} is not a JSON value`]
|
|
89
|
-
};
|
|
90
76
|
return {
|
|
91
|
-
schema:
|
|
77
|
+
schema: JSON.parse(text),
|
|
92
78
|
violations: []
|
|
93
79
|
};
|
|
94
80
|
}
|
|
@@ -100,17 +86,18 @@ const schemaMapKeywords = /* @__PURE__ */ new Set([
|
|
|
100
86
|
"patternProperties",
|
|
101
87
|
"properties"
|
|
102
88
|
]);
|
|
103
|
-
function
|
|
104
|
-
if (Array.isArray(schema)) return schema.
|
|
105
|
-
if (!isRecord(schema)) return
|
|
106
|
-
const violations = [];
|
|
89
|
+
function inspectJsonSchema(schema, path, violations) {
|
|
90
|
+
if (Array.isArray(schema)) return schema.every((entry, index) => inspectJsonSchema(entry, `${path}[${index}]`, violations));
|
|
91
|
+
if (!isRecord(schema)) return typeof schema !== "number" || Number.isFinite(schema);
|
|
107
92
|
for (const key of ["$dynamicRef", "$dynamicAnchor"]) if (key in schema) violations.push(`${path}.${key}`);
|
|
108
93
|
for (const [key, value] of Object.entries(schema)) {
|
|
94
|
+
if (typeof value === "number" && !Number.isFinite(value)) return false;
|
|
109
95
|
if (!value || typeof value !== "object") continue;
|
|
110
|
-
if (schemaMapKeywords.has(key) && isRecord(value))
|
|
111
|
-
|
|
96
|
+
if (schemaMapKeywords.has(key) && isRecord(value)) {
|
|
97
|
+
for (const [schemaName, childSchema] of Object.entries(value)) if (!inspectJsonSchema(childSchema, `${path}.${key}.${schemaName}`, violations)) return false;
|
|
98
|
+
} else if (!inspectJsonSchema(value, `${path}.${key}`, violations)) return false;
|
|
112
99
|
}
|
|
113
|
-
return
|
|
100
|
+
return true;
|
|
114
101
|
}
|
|
115
102
|
/** Projects one runtime tool input schema to JSON and reports runtime incompatibilities. */
|
|
116
103
|
function projectRuntimeToolInputSchema(schema, path = "parameters") {
|
|
@@ -118,7 +105,10 @@ function projectRuntimeToolInputSchema(schema, path = "parameters") {
|
|
|
118
105
|
const violations = [...projection.violations];
|
|
119
106
|
if (!isRecord(projection.schema)) violations.push(`${path} must be a JSON object schema`);
|
|
120
107
|
else if (projection.schema.type !== void 0 && projection.schema.type !== "object") violations.push(`${path}.type must be "object"`);
|
|
121
|
-
|
|
108
|
+
if (!inspectJsonSchema(projection.schema, path, violations)) return {
|
|
109
|
+
schema: {},
|
|
110
|
+
violations: [`${path} is not a JSON value`]
|
|
111
|
+
};
|
|
122
112
|
return {
|
|
123
113
|
schema: projection.schema,
|
|
124
114
|
violations
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-CPeq9F7y.mjs";
|
|
2
|
+
import { r as createAssistantMessageEventStream } from "./event-stream-BgDvQeum.mjs";
|
|
2
3
|
import { a as asOptionalRecord, n as asNonArrayRecord, r as asNullableRecord } from "./utf16-slice-qz3nsy87.mjs";
|
|
3
|
-
import { t as sanitizeSurrogates } from "./sanitize-unicode-
|
|
4
|
-
import { n as projectProviderError } from "./provider-error-
|
|
4
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-D6xUvZaS.mjs";
|
|
5
|
+
import { n as projectProviderError, r as projectDiagnosticValue } from "./provider-error-9TraxGvt.mjs";
|
|
6
|
+
import { n as isTransientNetworkError } from "./diagnostics-DfFyKeX_.mjs";
|
|
5
7
|
//#region packages/ai/src/utils/headers.ts
|
|
6
8
|
/** Converts a Headers object to a plain record for provider request handling. */
|
|
7
9
|
function headersToRecord(headers) {
|
|
@@ -134,7 +136,14 @@ function finalizeTerminalToolCallArguments(calls, readArguments, errorMessage) {
|
|
|
134
136
|
}
|
|
135
137
|
function mergeTransportHeaders(...headerSources) {
|
|
136
138
|
const merged = {};
|
|
137
|
-
|
|
139
|
+
const namesByLowercase = /* @__PURE__ */ new Map();
|
|
140
|
+
for (const headers of headerSources) for (const [name, value] of Object.entries(headers ?? {})) {
|
|
141
|
+
const lowercaseName = name.toLowerCase();
|
|
142
|
+
const previousName = namesByLowercase.get(lowercaseName);
|
|
143
|
+
if (previousName && previousName !== name) delete merged[previousName];
|
|
144
|
+
merged[name] = value;
|
|
145
|
+
namesByLowercase.set(lowercaseName, name);
|
|
146
|
+
}
|
|
138
147
|
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
139
148
|
}
|
|
140
149
|
function mergeTransportMetadata(payload, metadata) {
|
|
@@ -321,16 +330,20 @@ function finalizeTransportStream(params) {
|
|
|
321
330
|
});
|
|
322
331
|
stream.end();
|
|
323
332
|
}
|
|
324
|
-
/**
|
|
333
|
+
/** Assign terminal fields and record silent transport failures before partial-call cleanup. */
|
|
325
334
|
function assignTransportErrorDetails(output, error, signal) {
|
|
326
335
|
const projection = projectProviderError(error, signal);
|
|
327
336
|
Object.assign(output, projection);
|
|
337
|
+
if (projection.stopReason === "error" && output.content.length === 0 && isTransientNetworkError(projectDiagnosticValue(error)) && !output.diagnostics?.some((diagnostic) => diagnostic.type === "provider_transport_failure")) appendAssistantMessageDiagnostic(output, createAssistantMessageDiagnostic("provider_transport_failure", projection.errorMessage, {
|
|
338
|
+
eventsEmitted: false,
|
|
339
|
+
phase: "before_message_stream_start"
|
|
340
|
+
}));
|
|
328
341
|
return projection;
|
|
329
342
|
}
|
|
330
343
|
function failTransportStream(params) {
|
|
331
344
|
const { stream, output, signal, error, cleanup } = params;
|
|
332
|
-
cleanup?.();
|
|
333
345
|
const projection = assignTransportErrorDetails(output, error, signal);
|
|
346
|
+
cleanup?.();
|
|
334
347
|
stream.push({
|
|
335
348
|
type: "error",
|
|
336
349
|
reason: projection.stopReason,
|
package/dist/{transport-stream-shared-rvaCyFYt.d.mts → transport-stream-shared-xnaqxmbP.d.mts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
import "./event-stream-
|
|
1
|
+
import "./index-FnHM2FcI.mjs";
|
|
2
|
+
import { B as ProviderResponse, D as Model, J as StreamOptions, a as AssistantMessage, at as Usage } from "./types-CJ1-Ht7A.mjs";
|
|
3
|
+
import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-BhT5T1Ay.mjs";
|
|
4
|
+
import "./event-stream-zctLx0yr.mjs";
|
|
5
5
|
import { t as ProviderErrorProjection } from "./provider-error-CzNw4BWX.mjs";
|
|
6
6
|
//#region packages/ai/src/utils/stream-first-event-timeout.d.ts
|
|
7
7
|
type StreamStage = "responses" | "completions";
|
|
@@ -125,7 +125,7 @@ declare function finalizeTransportStream(params: {
|
|
|
125
125
|
output: AssistantMessage;
|
|
126
126
|
signal?: AbortSignal;
|
|
127
127
|
}): void;
|
|
128
|
-
/**
|
|
128
|
+
/** Assign terminal fields and record silent transport failures before partial-call cleanup. */
|
|
129
129
|
declare function assignTransportErrorDetails(output: AssistantMessage, error: unknown, signal?: AbortSignal): ProviderErrorProjection;
|
|
130
130
|
declare function failTransportStream(params: {
|
|
131
131
|
stream: WritableTransportStream;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as normalizeOptionalString, t as truncateUtf16Safe } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { n as getAiTransportHost } from "./host-
|
|
3
|
-
import {
|
|
2
|
+
import { n as getAiTransportHost } from "./host-CEvLw30U.mjs";
|
|
3
|
+
import { c as parseStrictNonNegativeInteger, i as asFiniteNumberInRange, l as parseStrictPositiveInteger, s as parseStrictFiniteNumber } from "./base64-CEFBpSkN.mjs";
|
|
4
4
|
import { parseRetryAfterHttpDateMs } from "./internal/retry-after.mjs";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
//#region packages/ai/src/transports/transport-utils.ts
|
|
@@ -25,14 +25,11 @@ function redactIdentifier(value, opts) {
|
|
|
25
25
|
function redactSensitiveText(text, _options) {
|
|
26
26
|
return getAiTransportHost().redactToolPayloadText(text);
|
|
27
27
|
}
|
|
28
|
-
function resolveSecretSentinel(value) {
|
|
29
|
-
return getAiTransportHost().resolveSecretSentinel(value);
|
|
30
|
-
}
|
|
31
28
|
function resolveModelHeaderSentinels(model) {
|
|
32
29
|
if (!model.headers) return model;
|
|
33
30
|
let headers;
|
|
34
31
|
for (const [name, value] of Object.entries(model.headers)) {
|
|
35
|
-
const resolved = resolveSecretSentinel(value);
|
|
32
|
+
const resolved = getAiTransportHost().resolveSecretSentinel(value);
|
|
36
33
|
if (resolved !== value) {
|
|
37
34
|
headers ??= { ...model.headers };
|
|
38
35
|
headers[name] = resolved;
|
|
@@ -99,7 +96,7 @@ async function readChunkWithIdleTimeout(reader, timeoutMs, onIdleTimeout) {
|
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
98
|
async function readResponseTextSnippet(response, options) {
|
|
102
|
-
const maxBytes = options?.maxBytes ??
|
|
99
|
+
const maxBytes = options?.maxBytes ?? 8192;
|
|
103
100
|
const maxChars = options?.maxChars ?? 200;
|
|
104
101
|
const reader = response.body?.getReader();
|
|
105
102
|
if (!reader) return;
|
|
@@ -138,4 +135,4 @@ async function readResponseTextSnippet(response, options) {
|
|
|
138
135
|
return truncated ? `${collapsed}…` : collapsed;
|
|
139
136
|
}
|
|
140
137
|
//#endregion
|
|
141
|
-
export { isGoogleGemini3FlashModel as a, parseRetryAfterSeconds as c, redactSensitiveText as d, resolveModelHeaderSentinels as f,
|
|
138
|
+
export { isGoogleGemini3FlashModel as a, parseRetryAfterSeconds as c, redactSensitiveText as d, resolveModelHeaderSentinels as f, isCodeModeModelVisibleToolName as i, readResponseTextSnippet as l, supportsModelTools as m, createAbortError as n, isGoogleGemini3ProModel as o, sha256Hex as p, estimateStringChars as r, parsePositiveInteger as s, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as t, redactIdentifier as u };
|