@openclaw/ai 2026.7.2-beta.4 → 2026.7.2-beta.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/dist/{anthropic-CrUDIBpM.mjs → anthropic-CH4UUnZr.mjs} +26 -441
- package/dist/{anthropic-BoTnz8cv.d.mts → anthropic-SrGtwsJu.d.mts} +27 -1
- package/dist/anthropic-usage-DWU-x8MI.mjs +459 -0
- package/dist/{api-registry-BMphkFf1.d.mts → api-registry-DlMgPR39.d.mts} +1 -1
- package/dist/{azure-openai-responses-CbrpVeEv.mjs → azure-openai-responses-CImcwB83.mjs} +4 -4
- package/dist/cache-retention-0x979a5V.mjs +12 -0
- package/dist/deferred-event-buffer-DAvyP7qA.mjs +19 -0
- package/dist/error-coercion-DgxlWC0n.mjs +15 -0
- package/dist/{event-stream-Douf9dob.d.mts → event-stream-YjaPW20U.d.mts} +1 -1
- package/dist/event-stream.d.mts +1 -1
- package/dist/{github-copilot-headers-BsH5cqGj.mjs → github-copilot-headers-NCJtz9i0.mjs} +1 -12
- package/dist/{google-Cs62KA7t.mjs → google-CtSg0iTS.mjs} +3 -3
- package/dist/{google-shared-CMLI-tCZ.mjs → google-shared-DNBz5rcD.mjs} +7 -4
- package/dist/{google-vertex-B4SD3U0f.mjs → google-vertex-31f1uS9L.mjs} +3 -3
- package/dist/{host-WvWBo4h8.d.mts → host-B9GUmcra.d.mts} +2 -2
- package/dist/host-Dog2WQiR.mjs +369 -0
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +3 -3
- package/dist/internal/anthropic.d.mts +16 -62
- package/dist/internal/anthropic.mjs +5 -4
- package/dist/internal/openai.d.mts +260 -2
- package/dist/internal/openai.mjs +7 -5
- package/dist/internal/runtime.d.mts +8 -32
- package/dist/internal/runtime.mjs +7 -6
- package/dist/internal/shared.d.mts +14 -9
- package/dist/internal/shared.mjs +6 -2
- package/dist/{llm-request-activity-CehVkZP-.mjs → llm-request-activity-BjtkplhG.mjs} +1 -19
- package/dist/{mistral-D5Ps7Led.mjs → mistral-CWmpvWYh.mjs} +7 -4
- package/dist/number-coercion-DvG7SNMg.mjs +129 -0
- package/dist/{openai-chatgpt-responses-h0o5yV8Y.mjs → openai-chatgpt-responses-B84Ibtrd.mjs} +33 -29
- package/dist/{openai-completions-exO8NFQf.mjs → openai-completions-DsOxhOD1.mjs} +28 -482
- package/dist/openai-completions-compat-DBWjXoMZ.d.mts +43 -0
- package/dist/openai-prompt-cache-2uo_1OR1.d.mts +7 -0
- package/dist/openai-prompt-cache-mZTCdRPo.mjs +12 -0
- package/dist/openai-reasoning-compat-YgeLncHw.mjs +396 -0
- package/dist/{openai-responses-BHpmtUKo.mjs → openai-responses-BT7A3sLu.mjs} +7 -5
- package/dist/openai-responses-shared-pXl6Wd8S.mjs +392 -0
- package/dist/{openai-responses-shared-CzCurmY1.mjs → openai-responses-stream-internal-Cw5txaGW.mjs} +1609 -1037
- package/dist/{openai-tool-projection-ITOU9bG1.mjs → openai-tool-projection-OhX64DoP.mjs} +26 -11
- package/dist/prompt-cache-stability-Cwcjv_fx.d.mts +13 -0
- package/dist/{provider-error-C4VvV_3t.mjs → provider-error-CAEvRjry.mjs} +8 -2
- package/dist/provider-options-D8bB3z9b.d.mts +144 -0
- package/dist/providers.d.mts +3 -2
- package/dist/providers.mjs +10 -9
- package/dist/reasoning-tag-text-partitioner-CGDyLWUR.mjs +12209 -0
- package/dist/simple-options-9lhRrN73.mjs +50 -0
- package/dist/{src-CXno1H5g.mjs → src-QkygScBs.mjs} +23 -4
- package/dist/stream-first-event-timeout-BBys9hSb.mjs +86 -0
- package/dist/stream-first-event-timeout-DvDeSucC.d.mts +29 -0
- package/dist/tls-certificate-errors-DXSpluKI.mjs +93 -0
- package/dist/tool-result-text-CTpIRbYd.mjs +225 -0
- package/dist/transform-messages-C8mBqZxF.mjs +2 -0
- package/dist/transport-stream-shared-D81p90xq.mjs +297 -0
- package/dist/transports.d.mts +115 -132
- package/dist/transports.mjs +400 -1991
- package/dist/{types-AFwwWium.d.mts → types-bzp5k29J.d.mts} +7 -0
- package/dist/types.d.mts +5 -5
- package/dist/types.mjs +2 -2
- package/dist/{validation-sxvxC8J-.d.mts → validation-B-j7cOYp.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/package.json +4 -5
- package/dist/host-XYGZcgO8.mjs +0 -98
- package/dist/model-utils-1GiZ2_rr.mjs +0 -64
- package/dist/openai-CoGicoDt.d.mts +0 -332
- package/dist/reasoning-tag-text-partitioner-BlVe67g6.mjs +0 -400
- package/dist/stream-first-event-timeout-DP4xEyBY.mjs +0 -150
- package/dist/system-prompt-cache-boundary-CbHeV4_l.mjs +0 -526
- package/npm-shrinkwrap.json +0 -638
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, i as requiresClaudeDefaultSampling, o as resolveClaudeFable5ModelIdentity, u as resolveClaudeOpus5ModelIdentity } from "./src-QkygScBs.mjs";
|
|
2
|
+
//#region packages/normalization-core/src/record-coerce.ts
|
|
3
|
+
/** Type guard for non-array object records at browser-safe boundaries. */
|
|
4
|
+
function isRecord(value) {
|
|
5
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region packages/normalization-core/src/string-coerce.ts
|
|
9
|
+
/** Reads a value only when it is already a string, preserving whitespace. */
|
|
10
|
+
function readStringValue(value) {
|
|
11
|
+
return typeof value === "string" ? value : void 0;
|
|
12
|
+
}
|
|
13
|
+
/** Trims string input and returns null for non-strings or empty strings. */
|
|
14
|
+
function normalizeNullableString(value) {
|
|
15
|
+
if (typeof value !== "string") return null;
|
|
16
|
+
const trimmed = value.trim();
|
|
17
|
+
return trimmed ? trimmed : null;
|
|
18
|
+
}
|
|
19
|
+
/** Trims string input and returns undefined for non-strings or empty strings. */
|
|
20
|
+
function normalizeOptionalString(value) {
|
|
21
|
+
return normalizeNullableString(value) ?? void 0;
|
|
22
|
+
}
|
|
23
|
+
/** Lowercases a normalized optional string. */
|
|
24
|
+
function normalizeOptionalLowercaseString(value) {
|
|
25
|
+
return normalizeOptionalString(value)?.toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
/** Lowercases a normalized string or returns an empty string when absent. */
|
|
28
|
+
function normalizeLowercaseStringOrEmpty(value) {
|
|
29
|
+
return normalizeOptionalLowercaseString(value) ?? "";
|
|
30
|
+
}
|
|
31
|
+
/** Type guard for strings that remain non-empty after trimming. */
|
|
32
|
+
function hasNonEmptyString(value) {
|
|
33
|
+
return normalizeOptionalString(value) !== void 0;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region packages/ai/src/providers/anthropic-model-contract.ts
|
|
37
|
+
function normalizeModelId(modelId) {
|
|
38
|
+
const normalized = normalizeLowercaseStringOrEmpty(modelId);
|
|
39
|
+
return (normalized.startsWith("anthropic/") ? normalized.slice(10) : normalized).replace(/[._\s]+/g, "-");
|
|
40
|
+
}
|
|
41
|
+
function normalizeApi(api) {
|
|
42
|
+
const normalized = normalizeLowercaseStringOrEmpty(api);
|
|
43
|
+
return normalized === "openclaw-anthropic-messages-transport" ? "anthropic-messages" : normalized;
|
|
44
|
+
}
|
|
45
|
+
function hasConcreteResponseModel(ref) {
|
|
46
|
+
const responseModelId = normalizeModelId(ref.responseModelId);
|
|
47
|
+
return responseModelId.length > 0 && responseModelId !== normalizeModelId(ref.modelId);
|
|
48
|
+
}
|
|
49
|
+
function usesClaudeFable5MessagesContract(model) {
|
|
50
|
+
return normalizeApi(model.api) === "anthropic-messages" && resolveClaudeFable5ModelIdentity(model) !== void 0;
|
|
51
|
+
}
|
|
52
|
+
/** Return whether streamed output must wait for the terminal refusal decision. */
|
|
53
|
+
function usesClaudeStreamingRefusalContract(model) {
|
|
54
|
+
if (normalizeApi(model.api) !== "anthropic-messages") return false;
|
|
55
|
+
return resolveClaudeFable5ModelIdentity(model) !== void 0 || resolveClaudeMythos5ModelIdentity(model) !== void 0 || resolveClaudeOpus5ModelIdentity(model) !== void 0 || resolveClaudeSonnet5ModelIdentity(model) !== void 0;
|
|
56
|
+
}
|
|
57
|
+
function requiresClaudeAdaptiveThinking(model) {
|
|
58
|
+
if (normalizeApi(model.api) !== "anthropic-messages") return false;
|
|
59
|
+
return requiresClaudeMandatoryAdaptiveThinking(model);
|
|
60
|
+
}
|
|
61
|
+
/** Return whether omitted thinking should default to adaptive/high. */
|
|
62
|
+
function defaultsClaudeAdaptiveThinking(model) {
|
|
63
|
+
return requiresClaudeAdaptiveThinking(model) || normalizeApi(model.api) === "anthropic-messages" && (resolveClaudeOpus5ModelIdentity(model) !== void 0 || resolveClaudeSonnet5ModelIdentity(model) !== void 0);
|
|
64
|
+
}
|
|
65
|
+
/** Remove unsupported assistant prefills while preserving completed tool-use turns. */
|
|
66
|
+
function prepareClaudeNoPrefillRequestContext(model, context) {
|
|
67
|
+
if (!resolveClaudeOpus5ModelIdentity(model) && !resolveClaudeSonnet5ModelIdentity(model)) return context;
|
|
68
|
+
let end = context.messages.length;
|
|
69
|
+
while (end > 0) {
|
|
70
|
+
const message = context.messages[end - 1];
|
|
71
|
+
if (message?.role !== "assistant" || Array.isArray(message.content) && message.content.some((block) => block.type === "toolCall")) break;
|
|
72
|
+
end -= 1;
|
|
73
|
+
}
|
|
74
|
+
return end === context.messages.length ? context : {
|
|
75
|
+
...context,
|
|
76
|
+
messages: context.messages.slice(0, end)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function applyClaudeRequestContract(params, model) {
|
|
80
|
+
if (normalizeApi(model.api) !== "anthropic-messages") return;
|
|
81
|
+
const opus5 = resolveClaudeOpus5ModelIdentity(model) !== void 0;
|
|
82
|
+
const sonnet5 = resolveClaudeSonnet5ModelIdentity(model) !== void 0;
|
|
83
|
+
if (!requiresClaudeDefaultSampling(model) && !opus5 && !sonnet5) return;
|
|
84
|
+
delete params.temperature;
|
|
85
|
+
delete params.top_p;
|
|
86
|
+
delete params.top_k;
|
|
87
|
+
if (opus5 || sonnet5) delete params.service_tier;
|
|
88
|
+
}
|
|
89
|
+
function resolveReplayModelBoundIdentity(ref) {
|
|
90
|
+
if (normalizeApi(ref.api) !== "anthropic-messages") return;
|
|
91
|
+
const modelRef = hasConcreteResponseModel(ref) ? { id: ref.responseModelId } : {
|
|
92
|
+
id: ref.modelId,
|
|
93
|
+
params: ref.modelParams
|
|
94
|
+
};
|
|
95
|
+
const fableIdentity = resolveClaudeFable5ModelIdentity(modelRef);
|
|
96
|
+
if (fableIdentity) return `fable:${fableIdentity}`;
|
|
97
|
+
const mythosIdentity = resolveClaudeMythos5ModelIdentity(modelRef);
|
|
98
|
+
if (mythosIdentity) return `mythos:${mythosIdentity}`;
|
|
99
|
+
const opusIdentity = resolveClaudeOpus5ModelIdentity(modelRef);
|
|
100
|
+
if (opusIdentity) return `opus:${opusIdentity}`;
|
|
101
|
+
const sonnetIdentity = resolveClaudeSonnet5ModelIdentity(modelRef);
|
|
102
|
+
return sonnetIdentity ? `sonnet:${sonnetIdentity}` : void 0;
|
|
103
|
+
}
|
|
104
|
+
function resolveModelBoundThinkingReplayMode(params) {
|
|
105
|
+
const sourceApi = normalizeApi(params.source.api);
|
|
106
|
+
const targetApi = normalizeApi(params.target.api);
|
|
107
|
+
const sourceIdentity = resolveReplayModelBoundIdentity(params.source);
|
|
108
|
+
const targetIdentity = resolveReplayModelBoundIdentity(params.target);
|
|
109
|
+
const sameRoute = normalizeLowercaseStringOrEmpty(params.source.provider) === normalizeLowercaseStringOrEmpty(params.target.provider) && sourceApi === targetApi && normalizeModelId(params.source.modelId) === normalizeModelId(params.target.modelId);
|
|
110
|
+
if (!sourceIdentity && !targetIdentity) return "default";
|
|
111
|
+
if (!sourceIdentity && !hasConcreteResponseModel(params.source) && targetIdentity && sameRoute) return "preserve";
|
|
112
|
+
return sourceApi === targetApi && sourceIdentity === targetIdentity ? "preserve" : "drop";
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region packages/ai/src/transcript-transform.ts
|
|
116
|
+
const NON_VISION_USER_IMAGE_PLACEHOLDER = "(image omitted: model does not support images)";
|
|
117
|
+
const NON_VISION_TOOL_IMAGE_PLACEHOLDER = "(tool image omitted: model does not support images)";
|
|
118
|
+
function isImageWithMediaPayload(block) {
|
|
119
|
+
return isRecord(block) && block.type === "image" && typeof block.data === "string" && block.data.trim().length > 0;
|
|
120
|
+
}
|
|
121
|
+
function replaceImagesWithPlaceholder(content, placeholder) {
|
|
122
|
+
const result = [];
|
|
123
|
+
let previousWasPlaceholder = false;
|
|
124
|
+
for (const block of content) {
|
|
125
|
+
if (block.type === "image") {
|
|
126
|
+
if (!isImageWithMediaPayload(block)) continue;
|
|
127
|
+
if (!previousWasPlaceholder) result.push({
|
|
128
|
+
type: "text",
|
|
129
|
+
text: placeholder
|
|
130
|
+
});
|
|
131
|
+
previousWasPlaceholder = true;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
result.push(block);
|
|
135
|
+
previousWasPlaceholder = block.text === placeholder;
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
function downgradeUnsupportedImages(messages, model) {
|
|
140
|
+
if (model.input.includes("image")) return messages;
|
|
141
|
+
return messages.map((msg) => {
|
|
142
|
+
if (msg.role === "user" && Array.isArray(msg.content)) return {
|
|
143
|
+
...msg,
|
|
144
|
+
content: replaceImagesWithPlaceholder(msg.content, NON_VISION_USER_IMAGE_PLACEHOLDER)
|
|
145
|
+
};
|
|
146
|
+
if (msg.role === "toolResult") return {
|
|
147
|
+
...msg,
|
|
148
|
+
content: replaceImagesWithPlaceholder(msg.content, NON_VISION_TOOL_IMAGE_PLACEHOLDER)
|
|
149
|
+
};
|
|
150
|
+
return msg;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Normalize tool call ID for cross-provider compatibility.
|
|
155
|
+
* OpenAI Responses API generates IDs that are 450+ chars with special characters like `|`.
|
|
156
|
+
* Anthropic APIs require IDs matching ^[a-zA-Z0-9_-]+$ (max 64 chars).
|
|
157
|
+
*/
|
|
158
|
+
function transformMessages(messages, model, normalizeToolCallId) {
|
|
159
|
+
const toolCallIdMap = /* @__PURE__ */ new Map();
|
|
160
|
+
const transformed = downgradeUnsupportedImages(messages.map((msg) => msg.content == null ? {
|
|
161
|
+
...msg,
|
|
162
|
+
content: []
|
|
163
|
+
} : msg), model).map((msg) => {
|
|
164
|
+
if (msg.role === "user") return msg;
|
|
165
|
+
if (msg.role === "toolResult") {
|
|
166
|
+
const normalizedId = toolCallIdMap.get(msg.toolCallId);
|
|
167
|
+
if (normalizedId && normalizedId !== msg.toolCallId) return Object.assign({}, msg, { toolCallId: normalizedId });
|
|
168
|
+
return msg;
|
|
169
|
+
}
|
|
170
|
+
if (msg.role === "assistant") {
|
|
171
|
+
const assistantMsg = msg;
|
|
172
|
+
const modelBoundThinkingReplayMode = resolveModelBoundThinkingReplayMode({
|
|
173
|
+
source: {
|
|
174
|
+
provider: assistantMsg.provider,
|
|
175
|
+
api: assistantMsg.api,
|
|
176
|
+
modelId: assistantMsg.model,
|
|
177
|
+
responseModelId: assistantMsg.responseModel
|
|
178
|
+
},
|
|
179
|
+
target: {
|
|
180
|
+
provider: model.provider,
|
|
181
|
+
api: model.api,
|
|
182
|
+
modelId: model.id,
|
|
183
|
+
modelParams: model.params
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
const isSameModel = modelBoundThinkingReplayMode === "preserve" || assistantMsg.provider === model.provider && assistantMsg.api === model.api && assistantMsg.model === model.id;
|
|
187
|
+
const transformedContent = (typeof assistantMsg.content === "string" ? [{
|
|
188
|
+
type: "text",
|
|
189
|
+
text: assistantMsg.content
|
|
190
|
+
}] : assistantMsg.content).flatMap((block) => {
|
|
191
|
+
if (block.type === "thinking") {
|
|
192
|
+
if (modelBoundThinkingReplayMode === "drop") return [];
|
|
193
|
+
if (block.redacted) return isSameModel ? block : [];
|
|
194
|
+
if (isSameModel && block.thinkingSignature) return block;
|
|
195
|
+
if (!block.thinking || block.thinking.trim() === "") return [];
|
|
196
|
+
if (isSameModel) return block;
|
|
197
|
+
return {
|
|
198
|
+
type: "text",
|
|
199
|
+
text: block.thinking
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
if (block.type === "text") {
|
|
203
|
+
if (isSameModel) return block;
|
|
204
|
+
return {
|
|
205
|
+
type: "text",
|
|
206
|
+
text: block.text
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (block.type === "toolCall") {
|
|
210
|
+
const toolCall = block;
|
|
211
|
+
let normalizedToolCall = toolCall;
|
|
212
|
+
if (!isSameModel && toolCall.thoughtSignature) {
|
|
213
|
+
normalizedToolCall = Object.assign({}, toolCall);
|
|
214
|
+
delete normalizedToolCall.thoughtSignature;
|
|
215
|
+
}
|
|
216
|
+
if (!isSameModel && normalizeToolCallId) {
|
|
217
|
+
const normalizedId = normalizeToolCallId(toolCall.id, model, assistantMsg);
|
|
218
|
+
if (normalizedId !== toolCall.id) {
|
|
219
|
+
toolCallIdMap.set(toolCall.id, normalizedId);
|
|
220
|
+
normalizedToolCall = Object.assign({}, normalizedToolCall, { id: normalizedId });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return normalizedToolCall;
|
|
224
|
+
}
|
|
225
|
+
return block;
|
|
226
|
+
});
|
|
227
|
+
return Object.assign({}, assistantMsg, { content: transformedContent });
|
|
228
|
+
}
|
|
229
|
+
return msg;
|
|
230
|
+
});
|
|
231
|
+
const result = [];
|
|
232
|
+
let pendingToolCalls = [];
|
|
233
|
+
let existingToolResultIds = /* @__PURE__ */ new Set();
|
|
234
|
+
const insertSyntheticToolResults = () => {
|
|
235
|
+
if (pendingToolCalls.length > 0) {
|
|
236
|
+
for (const tc of pendingToolCalls) if (!existingToolResultIds.has(tc.id)) result.push({
|
|
237
|
+
role: "toolResult",
|
|
238
|
+
toolCallId: tc.id,
|
|
239
|
+
toolName: tc.name,
|
|
240
|
+
content: [{
|
|
241
|
+
type: "text",
|
|
242
|
+
text: "No result provided"
|
|
243
|
+
}],
|
|
244
|
+
isError: true,
|
|
245
|
+
timestamp: Date.now()
|
|
246
|
+
});
|
|
247
|
+
pendingToolCalls = [];
|
|
248
|
+
existingToolResultIds = /* @__PURE__ */ new Set();
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
for (const msg of transformed) if (msg.role === "assistant") {
|
|
252
|
+
insertSyntheticToolResults();
|
|
253
|
+
const assistantMsg = msg;
|
|
254
|
+
if (assistantMsg.stopReason === "error" || assistantMsg.stopReason === "aborted") continue;
|
|
255
|
+
const toolCalls = assistantMsg.content.filter((b) => b.type === "toolCall");
|
|
256
|
+
if (toolCalls.length > 0) {
|
|
257
|
+
pendingToolCalls = toolCalls;
|
|
258
|
+
existingToolResultIds = /* @__PURE__ */ new Set();
|
|
259
|
+
}
|
|
260
|
+
result.push(msg);
|
|
261
|
+
} else if (msg.role === "toolResult") {
|
|
262
|
+
existingToolResultIds.add(msg.toolCallId);
|
|
263
|
+
result.push(msg);
|
|
264
|
+
} else if (msg.role === "user") {
|
|
265
|
+
insertSyntheticToolResults();
|
|
266
|
+
result.push(msg);
|
|
267
|
+
} else result.push(msg);
|
|
268
|
+
insertSyntheticToolResults();
|
|
269
|
+
return result;
|
|
270
|
+
}
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region packages/ai/src/host.ts
|
|
273
|
+
const MAX_PENDING_CUSTOM_API_REGISTRATIONS = 32;
|
|
274
|
+
const pendingCustomApiRegistrations = [];
|
|
275
|
+
function queueCustomApiRegistration(registry, api, streamFn) {
|
|
276
|
+
const existing = pendingCustomApiRegistrations.find((registration) => registration.registry === registry && registration.api === api);
|
|
277
|
+
if (existing) {
|
|
278
|
+
existing.streamFn = streamFn;
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
if (pendingCustomApiRegistrations.length >= MAX_PENDING_CUSTOM_API_REGISTRATIONS) throw new Error("Too many custom transport APIs were registered before host configuration");
|
|
282
|
+
pendingCustomApiRegistrations.push({
|
|
283
|
+
registry,
|
|
284
|
+
api,
|
|
285
|
+
streamFn
|
|
286
|
+
});
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
const inertAiTransportHost = {
|
|
290
|
+
buildModelFetch: () => void 0,
|
|
291
|
+
resolveSecretSentinel: (value) => value,
|
|
292
|
+
redactSecrets: (value) => value,
|
|
293
|
+
redactToolPayloadText: (text) => text,
|
|
294
|
+
normalizeAnthropicInlineContentBlocks: async (content) => [...content],
|
|
295
|
+
resolveOpenAIStrictToolSetting: (_model, options) => options?.supportsStrictMode ? false : void 0,
|
|
296
|
+
plugin: {
|
|
297
|
+
resolveProviderStream: () => void 0,
|
|
298
|
+
resolveTransportTurnState: () => void 0,
|
|
299
|
+
wrapSimpleCompletionStream: () => void 0,
|
|
300
|
+
createAnthropicVertexStream: () => {
|
|
301
|
+
throw new Error("Anthropic Vertex transport is not configured by the embedding host");
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
buildCopilotDynamicHeaders: () => ({}),
|
|
305
|
+
resolveProviderEndpointClass: () => "default",
|
|
306
|
+
resolveProviderRequestCapabilities: () => ({
|
|
307
|
+
endpointClass: "default",
|
|
308
|
+
knownProviderFamily: "",
|
|
309
|
+
supportsNativeStreamingUsageCompat: false,
|
|
310
|
+
supportsOpenAICompletionsStreamingUsageCompat: false,
|
|
311
|
+
usesExplicitProxyLikeEndpoint: false,
|
|
312
|
+
allowsAnthropicServiceTier: false
|
|
313
|
+
}),
|
|
314
|
+
resolveProviderRequestHeaders: ({ providerHeaders, callerHeaders, precedence }) => ({
|
|
315
|
+
...precedence === "caller-wins" ? providerHeaders : callerHeaders,
|
|
316
|
+
...precedence === "caller-wins" ? callerHeaders : providerHeaders
|
|
317
|
+
}),
|
|
318
|
+
resolveModelRequestTimeoutMs: () => void 0,
|
|
319
|
+
requiresManagedTransport: () => false,
|
|
320
|
+
inheritManagedTransport: (_source, target) => target,
|
|
321
|
+
transformTransportMessages: (messages, model, normalizeToolCallId) => transformMessages(messages, model, normalizeToolCallId),
|
|
322
|
+
registerCustomApi: queueCustomApiRegistration,
|
|
323
|
+
prepareGoogleSimpleCompletionModel: (_registry, model) => model,
|
|
324
|
+
logDebug: () => {},
|
|
325
|
+
logInfo: () => {},
|
|
326
|
+
logWarn: () => {}
|
|
327
|
+
};
|
|
328
|
+
let activeAiTransportHost = inertAiTransportHost;
|
|
329
|
+
/** Installs host implementations for the transport policy ports. */
|
|
330
|
+
function configureAiTransportHost(host) {
|
|
331
|
+
activeAiTransportHost = {
|
|
332
|
+
...inertAiTransportHost,
|
|
333
|
+
...host,
|
|
334
|
+
normalizeAnthropicInlineContentBlocks: host.normalizeAnthropicInlineContentBlocks ?? inertAiTransportHost.normalizeAnthropicInlineContentBlocks,
|
|
335
|
+
plugin: {
|
|
336
|
+
...inertAiTransportHost.plugin,
|
|
337
|
+
...host.plugin
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
const transportHost = activeAiTransportHost;
|
|
341
|
+
if (transportHost.registerCustomApi === inertAiTransportHost.registerCustomApi || pendingCustomApiRegistrations.length === 0) return;
|
|
342
|
+
const pending = pendingCustomApiRegistrations.splice(0);
|
|
343
|
+
for (const [index, registration] of pending.entries()) try {
|
|
344
|
+
transportHost.registerCustomApi(registration.registry, registration.api, registration.streamFn);
|
|
345
|
+
} catch (error) {
|
|
346
|
+
pendingCustomApiRegistrations.unshift(...pending.slice(index));
|
|
347
|
+
throw error;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/** Returns the active transport host (inert defaults unless configured). */
|
|
351
|
+
function getAiTransportHost() {
|
|
352
|
+
return activeAiTransportHost;
|
|
353
|
+
}
|
|
354
|
+
/** Resolves sentinel substrings in custom headers at a no-fetch adapter boundary. */
|
|
355
|
+
function resolveAiTransportHeaderSentinels(headers) {
|
|
356
|
+
if (!headers) return;
|
|
357
|
+
const host = getAiTransportHost();
|
|
358
|
+
let resolvedHeaders;
|
|
359
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
360
|
+
const resolved = host.resolveSecretSentinel(value);
|
|
361
|
+
if (resolved !== value) {
|
|
362
|
+
resolvedHeaders ??= { ...headers };
|
|
363
|
+
resolvedHeaders[name] = resolved;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return resolvedHeaders ?? headers;
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
369
|
+
export { applyClaudeRequestContract as a, requiresClaudeAdaptiveThinking as c, usesClaudeStreamingRefusalContract as d, hasNonEmptyString as f, isRecord as g, readStringValue as h, transformMessages as i, resolveModelBoundThinkingReplayMode as l, normalizeOptionalString as m, getAiTransportHost as n, defaultsClaudeAdaptiveThinking as o, normalizeLowercaseStringOrEmpty as p, resolveAiTransportHeaderSentinels as r, prepareClaudeNoPrefillRequestContext as s, configureAiTransportHost as t, usesClaudeFable5MessagesContract as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as
|
|
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-
|
|
6
|
-
import { a as RegisteredApiProvider, i as ApiStreamSimpleFunction, n as ApiRegistry, o as createApiRegistry, r as ApiStreamFunction, t as ApiProvider } from "./api-registry-
|
|
7
|
-
import { a as AiProviderRequestPolicyInput, c as AiTransportHost, d as configureAiTransportHost, f as getAiTransportHost, i as AiProviderRequestCapabilities, l as AiTransportPluginHost, n as AiInlineImageBlock, o as AiProviderStreamHookContext, p as resolveAiTransportHeaderSentinels, r as AiInlineTextBlock, s as AiTransformTransportMessages, t as AiInlineContentBlock, u as OpenAIStrictToolSettingOptions } from "./host-
|
|
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-bzp5k29J.mjs";
|
|
4
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-YjaPW20U.mjs";
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-B-j7cOYp.mjs";
|
|
6
|
+
import { a as RegisteredApiProvider, i as ApiStreamSimpleFunction, n as ApiRegistry, o as createApiRegistry, r as ApiStreamFunction, t as ApiProvider } from "./api-registry-DlMgPR39.mjs";
|
|
7
|
+
import { a as AiProviderRequestPolicyInput, c as AiTransportHost, d as configureAiTransportHost, f as getAiTransportHost, i as AiProviderRequestCapabilities, l as AiTransportPluginHost, n as AiInlineImageBlock, o as AiProviderStreamHookContext, p as resolveAiTransportHeaderSentinels, r as AiInlineTextBlock, s as AiTransformTransportMessages, t as AiInlineContentBlock, u as OpenAIStrictToolSettingOptions } from "./host-B9GUmcra.mjs";
|
|
8
8
|
|
|
9
9
|
//#region packages/ai/src/stream.d.ts
|
|
10
10
|
/** Creates an isolated LLM runtime backed by the supplied provider registry. */
|
|
@@ -23,4 +23,4 @@ declare function createLlmRuntime(registry?: ApiRegistry): {
|
|
|
23
23
|
};
|
|
24
24
|
type LlmRuntime = ReturnType<typeof createLlmRuntime>;
|
|
25
25
|
//#endregion
|
|
26
|
-
export { AiInlineContentBlock, AiInlineImageBlock, AiInlineTextBlock, AiProviderRequestCapabilities, AiProviderRequestPolicyInput, AiProviderStreamHookContext, AiTransformTransportMessages, AiTransportHost, AiTransportPluginHost, AnthropicMessagesCompat, Api, ApiProvider, ApiRegistry, ApiStreamFunction, ApiStreamSimpleFunction, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_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, LlmRuntime, MaybePromise, Message, Model, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenAIStrictToolSettingOptions, OpenRouterRouting, Provider, ProviderImagesOptions, ProviderResponse, ProviderStreamOptions, RegisteredApiProvider, SimpleStreamOptions, StopReason, StreamFn, StreamFunction, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, configureAiTransportHost, createApiRegistry, createAssistantMessageDiagnostic, createAssistantMessageEventStream, createLlmRuntime, extractDiagnosticError, formatThrownValue, getAiTransportHost, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveAiTransportHeaderSentinels, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeSonnet5ModelIdentity, supportsClaudeAdaptiveThinking, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
|
26
|
+
export { AiInlineContentBlock, AiInlineImageBlock, AiInlineTextBlock, AiProviderRequestCapabilities, AiProviderRequestPolicyInput, AiProviderStreamHookContext, AiTransformTransportMessages, AiTransportHost, AiTransportPluginHost, AnthropicMessagesCompat, Api, ApiProvider, ApiRegistry, ApiStreamFunction, ApiStreamSimpleFunction, 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, LlmRuntime, MaybePromise, Message, Model, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenAIStrictToolSettingOptions, OpenRouterRouting, Provider, ProviderImagesOptions, ProviderResponse, ProviderStreamOptions, RegisteredApiProvider, SimpleStreamOptions, StopReason, StreamFn, StreamFunction, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, configureAiTransportHost, createApiRegistry, createAssistantMessageDiagnostic, createAssistantMessageEventStream, createLlmRuntime, extractDiagnosticError, formatThrownValue, getAiTransportHost, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveAiTransportHeaderSentinels, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
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
3
|
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
|
|
4
4
|
import { n as validateToolCall, t as validateToolArguments } from "./validation-DAa_yFOM.mjs";
|
|
5
5
|
import { n as createApiRegistry, t as createLlmRuntime } from "./stream-CREqxHgU.mjs";
|
|
6
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels, t as configureAiTransportHost } from "./host-
|
|
7
|
-
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, EventStream, appendAssistantMessageDiagnostic, configureAiTransportHost, createApiRegistry, createAssistantMessageDiagnostic, createAssistantMessageEventStream, createLlmRuntime, extractDiagnosticError, formatThrownValue, getAiTransportHost, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveAiTransportHeaderSentinels, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeSonnet5ModelIdentity, supportsClaudeAdaptiveThinking, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
|
6
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels, t as configureAiTransportHost } from "./host-Dog2WQiR.mjs";
|
|
7
|
+
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, EventStream, appendAssistantMessageDiagnostic, configureAiTransportHost, createApiRegistry, createAssistantMessageDiagnostic, createAssistantMessageEventStream, createLlmRuntime, extractDiagnosticError, formatThrownValue, getAiTransportHost, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveAiTransportHeaderSentinels, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
|
@@ -1,58 +1,8 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, g as supportsClaudeNativeXhighEffort, h as supportsClaudeNativeMaxEffort, i as requiresClaudeDefaultSampling, l as resolveClaudeNativeThinkingLevelMap, o as resolveClaudeFable5ModelIdentity, p as supportsClaudeAdaptiveThinking, s as resolveClaudeModelIdentity, u as resolveClaudeOpus5ModelIdentity } from "../anthropic-SrGtwsJu.mjs";
|
|
2
2
|
import { t as AssistantMessageDiagnostic } from "../diagnostics-BaTA9eVl.mjs";
|
|
3
|
-
import { E as Model, F as SimpleStreamOptions, R as StreamFunction, u as Context
|
|
4
|
-
import
|
|
5
|
-
|
|
3
|
+
import { E as Model, F as SimpleStreamOptions, R as StreamFunction, u as Context } from "../types-bzp5k29J.mjs";
|
|
4
|
+
import { n as AnthropicOptions, r as AnthropicThinkingDisplay, t as AnthropicEffort } from "../provider-options-D8bB3z9b.mjs";
|
|
6
5
|
//#region packages/ai/src/providers/anthropic.d.ts
|
|
7
|
-
type AnthropicEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
8
|
-
type AnthropicThinkingDisplay = "summarized" | "omitted";
|
|
9
|
-
interface AnthropicOptions extends StreamOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Enable extended thinking.
|
|
12
|
-
* For Opus 4.6+ and Sonnet 4.6: uses adaptive thinking (model decides when/how much to think).
|
|
13
|
-
* For older models: uses budget-based thinking with thinkingBudgetTokens.
|
|
14
|
-
*/
|
|
15
|
-
thinkingEnabled?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Token budget for extended thinking (older models only).
|
|
18
|
-
* Ignored for Opus 4.6+ and Sonnet 4.6, which use adaptive thinking.
|
|
19
|
-
*/
|
|
20
|
-
thinkingBudgetTokens?: number;
|
|
21
|
-
/**
|
|
22
|
-
* Effort level for adaptive thinking (Opus 4.6+ and Sonnet 4.6).
|
|
23
|
-
* Controls how much thinking Claude allocates:
|
|
24
|
-
* - "max": Always thinks with no constraints (Opus 4.6 only)
|
|
25
|
-
* - "xhigh": Highest reasoning level (Opus 4.7+)
|
|
26
|
-
* - "high": Always thinks, deep reasoning (default)
|
|
27
|
-
* - "medium": Moderate thinking, may skip for simple queries
|
|
28
|
-
* - "low": Minimal thinking, skips for simple tasks
|
|
29
|
-
* Ignored for older models.
|
|
30
|
-
*/
|
|
31
|
-
effort?: AnthropicEffort;
|
|
32
|
-
/**
|
|
33
|
-
* Controls how thinking content is returned in API responses.
|
|
34
|
-
* - "summarized": Thinking blocks contain summarized thinking text (default here).
|
|
35
|
-
* - "omitted": Thinking blocks return an empty thinking field; the encrypted
|
|
36
|
-
* signature still travels back for multi-turn continuity. Use for faster
|
|
37
|
-
* time-to-first-text-token when your UI does not surface thinking.
|
|
38
|
-
*
|
|
39
|
-
* Note: Anthropic's API default for Claude Opus 4.7+ and Claude Mythos Preview
|
|
40
|
-
* is "omitted". We default to "summarized" here to keep behavior consistent
|
|
41
|
-
* with older Claude 4 models. Set this explicitly to "omitted" to opt in.
|
|
42
|
-
*/
|
|
43
|
-
thinkingDisplay?: AnthropicThinkingDisplay;
|
|
44
|
-
interleavedThinking?: boolean;
|
|
45
|
-
toolChoice?: "auto" | "any" | "none" | {
|
|
46
|
-
type: "tool";
|
|
47
|
-
name: string;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Pre-built Anthropic client instance. When provided, skips internal client
|
|
51
|
-
* construction entirely. Use this to inject alternative SDK clients such as
|
|
52
|
-
* `AnthropicVertex` that shares the same messaging API.
|
|
53
|
-
*/
|
|
54
|
-
client?: Anthropic;
|
|
55
|
-
}
|
|
56
6
|
declare const streamAnthropic: StreamFunction<"anthropic-messages", AnthropicOptions>;
|
|
57
7
|
type AnthropicSimpleStreamOptions = SimpleStreamOptions & {
|
|
58
8
|
toolChoice?: AnthropicOptions["toolChoice"];
|
|
@@ -98,8 +48,8 @@ declare function defaultsClaudeAdaptiveThinking(model: {
|
|
|
98
48
|
params?: Record<string, unknown>;
|
|
99
49
|
api?: string;
|
|
100
50
|
}): boolean;
|
|
101
|
-
/** Remove
|
|
102
|
-
declare function
|
|
51
|
+
/** Remove unsupported assistant prefills while preserving completed tool-use turns. */
|
|
52
|
+
declare function prepareClaudeNoPrefillRequestContext(model: Model, context: Context): Context;
|
|
103
53
|
declare function applyClaudeRequestContract(params: Record<string, unknown>, model: {
|
|
104
54
|
id?: string;
|
|
105
55
|
params?: Record<string, unknown>;
|
|
@@ -120,21 +70,25 @@ declare function applyAnthropicRefusal(output: AnthropicRefusalOutput, stopDetai
|
|
|
120
70
|
//#endregion
|
|
121
71
|
//#region packages/ai/src/providers/anthropic-server-fallback.d.ts
|
|
122
72
|
/** Anthropic beta that re-serves safety refusals on an allowed fallback model. */
|
|
123
|
-
declare const ANTHROPIC_SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-
|
|
124
|
-
|
|
125
|
-
declare const
|
|
73
|
+
declare const ANTHROPIC_SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-07-01";
|
|
74
|
+
/** Let Anthropic select the recommended model for each refusal category. */
|
|
75
|
+
declare const ANTHROPIC_SERVER_SIDE_FALLBACKS: "default";
|
|
76
|
+
declare const CLAUDE_OPUS_FALLBACK_MODEL_COST: {
|
|
126
77
|
readonly input: 5;
|
|
127
78
|
readonly output: 25;
|
|
128
79
|
readonly cacheRead: 0.5;
|
|
129
80
|
readonly cacheWrite: 6.25;
|
|
130
81
|
};
|
|
131
|
-
declare function buildAnthropicServerSideFallbacks(): Array<{
|
|
132
|
-
model: string;
|
|
133
|
-
}>;
|
|
134
82
|
type AnthropicFallbackBoundary = {
|
|
135
83
|
fromModel: string | null;
|
|
136
84
|
toModel: string | null;
|
|
137
85
|
};
|
|
86
|
+
/** Resolve billed rates from the serving model reported by Anthropic's fallback stream. */
|
|
87
|
+
declare function resolveAnthropicFallbackServingModelCost(params: {
|
|
88
|
+
requestedModelId: string;
|
|
89
|
+
servingModelId: string | null;
|
|
90
|
+
requestedCost: Model["cost"];
|
|
91
|
+
}): Model["cost"];
|
|
138
92
|
/** Reads a `fallback` content block marking where one model's output gives way to the next. */
|
|
139
93
|
declare function readAnthropicFallbackBoundary(block: unknown): AnthropicFallbackBoundary | null;
|
|
140
94
|
/**
|
|
@@ -237,4 +191,4 @@ declare function readAnthropicCacheWriteUsage(usage: AnthropicUsagePayload): Ant
|
|
|
237
191
|
declare function readAnthropicPromptUsageSnapshot(usage: AnthropicUsagePayload): AnthropicPromptUsageSnapshot | undefined;
|
|
238
192
|
declare function readLastAnthropicIterationUsage(usage: AnthropicUsagePayload): AnthropicIterationUsageResult;
|
|
239
193
|
//#endregion
|
|
240
|
-
export { ANTHROPIC_OMITTED_REASONING_TEXT, ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, AnthropicCacheWriteUsage, AnthropicEffort, AnthropicFallbackBoundary, AnthropicIterationUsageResult, AnthropicIterationUsageSnapshot, AnthropicOptions, AnthropicProjectedToolChoice, AnthropicPromptUsageSnapshot, AnthropicThinkingDisplay, AnthropicToolProjection,
|
|
194
|
+
export { ANTHROPIC_OMITTED_REASONING_TEXT, ANTHROPIC_SERVER_SIDE_FALLBACKS, ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, AnthropicCacheWriteUsage, type AnthropicEffort, AnthropicFallbackBoundary, AnthropicIterationUsageResult, AnthropicIterationUsageSnapshot, type AnthropicOptions, AnthropicProjectedToolChoice, AnthropicPromptUsageSnapshot, type AnthropicThinkingDisplay, AnthropicToolProjection, CLAUDE_OPUS_FALLBACK_MODEL_COST, applyAnthropicFallbackBoundary, applyAnthropicRefusal, applyClaudeRequestContract, defaultsClaudeAdaptiveThinking, findActiveAnthropicToolTurnAssistantIndex, omitFoundryBearerCredentialHeaders, prepareClaudeNoPrefillRequestContext, projectAnthropicTools, readAnthropicCacheWriteUsage, readAnthropicFallbackBoundary, readAnthropicPromptUsageSnapshot, readAnthropicUsageTokenCount, readLastAnthropicIterationUsage, reconcileAnthropicToolChoice, requiresClaudeAdaptiveThinking, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveAnthropicFallbackServingModelCost, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, resolveModelBoundThinkingReplayMode, resolveOriginalAnthropicToolName, streamAnthropic, streamSimpleAnthropic, supportsClaudeAdaptiveThinking, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, usesClaudeFable5MessagesContract, usesClaudeStreamingRefusalContract, usesFoundryBearerAuth };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import { _ as
|
|
4
|
-
|
|
1
|
+
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, g as supportsClaudeNativeXhighEffort, h as supportsClaudeNativeMaxEffort, i as requiresClaudeDefaultSampling, l as resolveClaudeNativeThinkingLevelMap, o as resolveClaudeFable5ModelIdentity, p as supportsClaudeAdaptiveThinking, s as resolveClaudeModelIdentity, u as resolveClaudeOpus5ModelIdentity } from "../src-QkygScBs.mjs";
|
|
2
|
+
import { a as applyClaudeRequestContract, c as requiresClaudeAdaptiveThinking, d as usesClaudeStreamingRefusalContract, l as resolveModelBoundThinkingReplayMode, o as defaultsClaudeAdaptiveThinking, s as prepareClaudeNoPrefillRequestContext, u as usesClaudeFable5MessagesContract } from "../host-Dog2WQiR.mjs";
|
|
3
|
+
import { _ as omitFoundryBearerCredentialHeaders, a as projectAnthropicTools, c as ANTHROPIC_OMITTED_REASONING_TEXT, d as ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, f as CLAUDE_OPUS_FALLBACK_MODEL_COST, g as applyAnthropicRefusal, h as resolveAnthropicFallbackServingModelCost, i as readLastAnthropicIterationUsage, l as findActiveAnthropicToolTurnAssistantIndex, m as readAnthropicFallbackBoundary, n as readAnthropicPromptUsageSnapshot, o as reconcileAnthropicToolChoice, p as applyAnthropicFallbackBoundary, r as readAnthropicUsageTokenCount, s as resolveOriginalAnthropicToolName, t as readAnthropicCacheWriteUsage, u as ANTHROPIC_SERVER_SIDE_FALLBACKS, v as usesFoundryBearerAuth } from "../anthropic-usage-DWU-x8MI.mjs";
|
|
4
|
+
import { n as streamAnthropic, r as streamSimpleAnthropic } from "../anthropic-CH4UUnZr.mjs";
|
|
5
|
+
export { ANTHROPIC_OMITTED_REASONING_TEXT, ANTHROPIC_SERVER_SIDE_FALLBACKS, ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, CLAUDE_OPUS_FALLBACK_MODEL_COST, applyAnthropicFallbackBoundary, applyAnthropicRefusal, applyClaudeRequestContract, defaultsClaudeAdaptiveThinking, findActiveAnthropicToolTurnAssistantIndex, omitFoundryBearerCredentialHeaders, prepareClaudeNoPrefillRequestContext, projectAnthropicTools, readAnthropicCacheWriteUsage, readAnthropicFallbackBoundary, readAnthropicPromptUsageSnapshot, readAnthropicUsageTokenCount, readLastAnthropicIterationUsage, reconcileAnthropicToolChoice, requiresClaudeAdaptiveThinking, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveAnthropicFallbackServingModelCost, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, resolveModelBoundThinkingReplayMode, resolveOriginalAnthropicToolName, streamAnthropic, streamSimpleAnthropic, supportsClaudeAdaptiveThinking, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, usesClaudeFable5MessagesContract, usesClaudeStreamingRefusalContract, usesFoundryBearerAuth };
|