@openclaw/ai 2026.8.1-beta.1 → 2026.8.1-beta.3
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-CE-7SkF6.mjs → anthropic-B8KwTtlb.mjs} +62 -37
- package/dist/{anthropic-SrGtwsJu.d.mts → anthropic-BECQCNdF.d.mts} +0 -2
- package/dist/{src-QkygScBs.mjs → anthropic-BQXQudmA.mjs} +0 -2
- package/dist/{anthropic-usage-Ma4iX6uG.mjs → anthropic-compaction-replay-4Zx7-aCr.mjs} +225 -103
- package/dist/anthropic-payload-policy-CSx7MoKH.d.mts +50 -0
- package/dist/{api-registry-EpJoVwM1.d.mts → api-registry-DFxSnFqG.d.mts} +1 -1
- package/dist/{azure-openai-responses-Cc_kasye.mjs → azure-openai-responses-Aa4mVcYG.mjs} +23 -29
- package/dist/diagnostics.d.mts +24 -1
- package/dist/diagnostics.mjs +2 -1
- package/dist/event-stream-BVVgDSdq.d.mts +1 -0
- package/dist/{event-stream-DRmDMRHH.d.mts → event-stream-D91-ohD_.d.mts} +3 -1
- package/dist/{event-stream-CEV9t6da.mjs → event-stream-uSMZJ3FA.mjs} +16 -3
- package/dist/event-stream.d.mts +1 -1
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-shared-Cq2UKx1l.mjs → google-shared-M1dl64nz.mjs} +17 -19
- package/dist/google-thinking-level-C-V3tecN.mjs +9 -0
- package/dist/{google-vertex-CusxWzvE.mjs → google-vertex-DCJHM_a5.mjs} +5 -4
- package/dist/{google-CGQu21aw.mjs → google-yDRnipeq.mjs} +4 -4
- package/dist/host-DF_yxOsA.mjs +477 -0
- package/dist/{host-Dn4_SZI2.d.mts → host-DJq_FGcz.d.mts} +13 -8
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +7 -5
- package/dist/internal/anthropic.d.mts +21 -7
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -0
- package/dist/internal/openai-responses-payload-policy.mjs +3 -0
- package/dist/internal/openai.d.mts +6 -6
- package/dist/internal/openai.mjs +9 -7
- package/dist/internal/runtime.d.mts +19 -5
- package/dist/internal/runtime.mjs +85 -72
- package/dist/internal/shared.d.mts +17 -8
- package/dist/internal/shared.mjs +4 -5
- package/dist/{json-parse-BvXNt1-7.mjs → json-parse-CDnesDM_.mjs} +4 -6
- package/dist/{mistral-Dx6VzNjf.mjs → mistral-D6hRXI7A.mjs} +67 -72
- package/dist/{number-coercion-1Miyb5MO.mjs → number-coercion-H9qHik3g.mjs} +7 -2
- package/dist/openai-chatgpt-jwt-KWcgd0d_.mjs +19 -0
- package/dist/{openai-chatgpt-responses-SC9m0FSf.mjs → openai-chatgpt-responses-C339VIfT.mjs} +235 -146
- package/dist/{openai-completions-BaIpl93j.mjs → openai-completions-D88orSJ9.mjs} +88 -67
- package/dist/openai-completions-compat-B0KTleXp.d.mts +43 -0
- package/dist/{openai-responses-Bdx3V_Yu.mjs → openai-responses-BXEcr-Tp.mjs} +17 -24
- package/dist/openai-responses-contracts-CD75pQ0m.d.mts +68 -0
- package/dist/openai-responses-contracts-DvILoqBk.mjs +247 -0
- package/dist/openai-responses-payload-policy-BDo8CQsx.mjs +208 -0
- package/dist/openai-responses-payload-policy-CNGFT9zr.d.mts +41 -0
- package/dist/{openai-responses-prompt-observer-internal-DDZPxRfr.mjs → openai-responses-prompt-observer-internal-BG-1AsBI.mjs} +2 -3
- package/dist/{openai-responses-stream-internal-Bl8YyVtF.mjs → openai-responses-shared-Cvt5MgEm.mjs} +1287 -1039
- package/dist/{openai-reasoning-compat-DKebnIBL.mjs → openai-stop-reason-9OONKyAm.mjs} +222 -180
- package/dist/{openai-transport-shared-Cipt7egQ.mjs → openai-tool-projection-CHGLt03m.mjs} +239 -128
- package/dist/provider-error-C8mBRJDl.mjs +424 -0
- package/dist/provider-error-CzNw4BWX.d.mts +12 -0
- package/dist/provider-options-AvldWZt8.mjs +21 -0
- package/dist/{provider-options-C5kYML7i.d.mts → provider-options-Cc5ZQ6Aa.d.mts} +19 -3
- package/dist/provider-transcript-transform--gtf0ZbR.mjs +32 -0
- package/dist/provider-types.d.mts +31 -0
- package/dist/provider-types.mjs +8 -0
- package/dist/providers.d.mts +1 -1
- package/dist/providers.mjs +17 -19
- package/dist/{reasoning-tag-text-partitioner-CGDyLWUR.mjs → reasoning-tag-text-partitioner-5ygO2rZc.mjs} +17 -8
- package/dist/record-coerce-DdXsgUd_.mjs +23 -0
- package/dist/{model-utils-Dau5dlgm.mjs → sanitize-unicode-BP7HLLZn.mjs} +28 -2
- package/dist/session-resources-CkR4WWy1.mjs +21 -0
- package/dist/simple-options-oqsXB6U3.mjs +450 -0
- package/dist/src-D2H6yKkH.mjs +2 -0
- package/dist/{stream-first-event-timeout-BIBomOGq.mjs → stream-first-event-timeout-MK28puvq.mjs} +2 -2
- package/dist/string-coerce-fsri9iCu.mjs +34 -0
- package/dist/{tool-schema-json-projection-B1b-XCn5.mjs → tool-schema-json-projection-FEr-jOoZ.mjs} +20 -13
- package/dist/transport-utils-Bv0FHkd0.mjs +138 -0
- package/dist/transports.d.mts +199 -209
- package/dist/transports.mjs +1842 -1364
- package/dist/types-BDdaOVi2.mjs +6 -0
- package/dist/{types-CH7ReIcU.d.mts → types-DTAP49HF.d.mts} +35 -2
- package/dist/types.d.mts +5 -5
- package/dist/types.mjs +6 -4
- package/dist/utf16-slice-CvGodqok.mjs +29 -0
- package/dist/{validation-DAa_yFOM.mjs → validation-B61OhAio.mjs} +6 -6
- package/dist/{validation-CcPcuEbR.d.mts → validation-DYNNrU9u.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +15 -1
- package/dist/host-Bl7Kgddo.mjs +0 -407
- package/dist/openai-chatgpt-jwt-DhAAzLkj.mjs +0 -39
- package/dist/openai-responses-contracts-BBKBfAqR.d.mts +0 -116
- package/dist/openai-responses-shared-CCyMvg7M.mjs +0 -403
- package/dist/provider-error-DI0Ts28U.mjs +0 -47
- package/dist/sanitize-unicode-DT5o51ur.mjs +0 -26
- package/dist/tool-result-text-Dvkp2Dus.mjs +0 -274
- package/dist/transform-messages-DfjpNXNQ.mjs +0 -2
- package/dist/transport-stream-shared-CPNv7A3r.mjs +0 -297
|
@@ -0,0 +1,477 @@
|
|
|
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, u as resolveClaudeOpus5ModelIdentity } from "./anthropic-BQXQudmA.mjs";
|
|
2
|
+
import "./src-D2H6yKkH.mjs";
|
|
3
|
+
import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.mjs";
|
|
4
|
+
import { i as clampThinkingLevel, t as sanitizeSurrogates } from "./sanitize-unicode-BP7HLLZn.mjs";
|
|
5
|
+
import { a as isRecord } from "./record-coerce-DdXsgUd_.mjs";
|
|
6
|
+
import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
|
|
7
|
+
//#region packages/ai/src/providers/anthropic-model-contract.ts
|
|
8
|
+
const ANTHROPIC_CLAUDE_CODE_VERSION = "2.1.75";
|
|
9
|
+
const ANTHROPIC_CLAUDE_CODE_BILLING_SYSTEM_BLOCK = `x-anthropic-billing-header: cc_version=${ANTHROPIC_CLAUDE_CODE_VERSION}; cc_entrypoint=sdk-cli;`;
|
|
10
|
+
function normalizeModelId(modelId) {
|
|
11
|
+
const normalized = normalizeLowercaseStringOrEmpty(modelId);
|
|
12
|
+
return (normalized.startsWith("anthropic/") ? normalized.slice(10) : normalized).replace(/[._\s]+/g, "-");
|
|
13
|
+
}
|
|
14
|
+
function normalizeApi(api) {
|
|
15
|
+
const normalized = normalizeLowercaseStringOrEmpty(api);
|
|
16
|
+
return normalized === "openclaw-anthropic-messages-transport" ? "anthropic-messages" : normalized;
|
|
17
|
+
}
|
|
18
|
+
function hasConcreteResponseModel(ref) {
|
|
19
|
+
const responseModelId = normalizeModelId(ref.responseModelId);
|
|
20
|
+
return responseModelId.length > 0 && responseModelId !== normalizeModelId(ref.modelId);
|
|
21
|
+
}
|
|
22
|
+
function usesClaudeFable5MessagesContract(model) {
|
|
23
|
+
return normalizeApi(model.api) === "anthropic-messages" && resolveClaudeFable5ModelIdentity(model) !== void 0;
|
|
24
|
+
}
|
|
25
|
+
/** Return whether streamed output must wait for the terminal refusal decision. */
|
|
26
|
+
function usesClaudeStreamingRefusalContract(model) {
|
|
27
|
+
if (normalizeApi(model.api) !== "anthropic-messages") return false;
|
|
28
|
+
return resolveClaudeFable5ModelIdentity(model) !== void 0 || resolveClaudeMythos5ModelIdentity(model) !== void 0 || resolveClaudeOpus5ModelIdentity(model) !== void 0 || resolveClaudeSonnet5ModelIdentity(model) !== void 0;
|
|
29
|
+
}
|
|
30
|
+
function requiresClaudeAdaptiveThinking(model) {
|
|
31
|
+
if (normalizeApi(model.api) !== "anthropic-messages") return false;
|
|
32
|
+
return requiresClaudeMandatoryAdaptiveThinking(model);
|
|
33
|
+
}
|
|
34
|
+
/** Return whether omitted thinking should default to adaptive/high. */
|
|
35
|
+
function defaultsClaudeAdaptiveThinking(model) {
|
|
36
|
+
return requiresClaudeAdaptiveThinking(model) || normalizeApi(model.api) === "anthropic-messages" && (resolveClaudeOpus5ModelIdentity(model) !== void 0 || resolveClaudeSonnet5ModelIdentity(model) !== void 0);
|
|
37
|
+
}
|
|
38
|
+
/** Resolve provider-native effort once for direct and managed Claude requests. */
|
|
39
|
+
function resolveAnthropicThinkingEffort(model, level) {
|
|
40
|
+
const requestedLevel = level;
|
|
41
|
+
const thinkingLevelMap = resolveClaudeNativeThinkingLevelMap(model);
|
|
42
|
+
const clampModel = {
|
|
43
|
+
...model,
|
|
44
|
+
...typeof model.params?.canonicalModelId === "string" ? { reasoning: true } : {},
|
|
45
|
+
...thinkingLevelMap ? { thinkingLevelMap } : {}
|
|
46
|
+
};
|
|
47
|
+
const resolvedLevel = requestedLevel ? clampThinkingLevel(clampModel, requestedLevel) : void 0;
|
|
48
|
+
const mapped = resolvedLevel ? thinkingLevelMap?.[resolvedLevel] : void 0;
|
|
49
|
+
if (typeof mapped === "string") return mapped;
|
|
50
|
+
switch (resolvedLevel) {
|
|
51
|
+
case "off":
|
|
52
|
+
case "minimal":
|
|
53
|
+
case "low": return "low";
|
|
54
|
+
case "medium": return "medium";
|
|
55
|
+
case "xhigh": return supportsClaudeNativeXhighEffort(model) ? "xhigh" : "high";
|
|
56
|
+
case "max": return supportsClaudeNativeMaxEffort(model) ? "max" : "high";
|
|
57
|
+
default: return "high";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Normalize Anthropic and Anthropic-compatible terminal reasons identically. */
|
|
61
|
+
function mapAnthropicStopReason(reason) {
|
|
62
|
+
switch (reason) {
|
|
63
|
+
case "end_turn":
|
|
64
|
+
case "pause_turn":
|
|
65
|
+
case "compaction":
|
|
66
|
+
case "stop_sequence": return "stop";
|
|
67
|
+
case "max_tokens": return "length";
|
|
68
|
+
case "tool_use": return "toolUse";
|
|
69
|
+
case "refusal":
|
|
70
|
+
case "sensitive": return "error";
|
|
71
|
+
default: throw new Error(`Unhandled stop reason: ${String(reason)}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Remove unsupported assistant prefills while preserving completed tool-use turns. */
|
|
75
|
+
function prepareClaudeNoPrefillRequestContext(model, context) {
|
|
76
|
+
if (!resolveClaudeOpus5ModelIdentity(model) && !resolveClaudeSonnet5ModelIdentity(model)) return context;
|
|
77
|
+
let end = context.messages.length;
|
|
78
|
+
while (end > 0) {
|
|
79
|
+
const message = context.messages[end - 1];
|
|
80
|
+
if (message?.role !== "assistant" || Array.isArray(message.content) && message.content.some((block) => block.type === "toolCall")) break;
|
|
81
|
+
end -= 1;
|
|
82
|
+
}
|
|
83
|
+
return end === context.messages.length ? context : {
|
|
84
|
+
...context,
|
|
85
|
+
messages: context.messages.slice(0, end)
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function applyClaudeRequestContract(params, model) {
|
|
89
|
+
if (normalizeApi(model.api) !== "anthropic-messages") return;
|
|
90
|
+
const opus5 = resolveClaudeOpus5ModelIdentity(model) !== void 0;
|
|
91
|
+
const sonnet5 = resolveClaudeSonnet5ModelIdentity(model) !== void 0;
|
|
92
|
+
if (!requiresClaudeDefaultSampling(model) && !opus5 && !sonnet5) return;
|
|
93
|
+
delete params.temperature;
|
|
94
|
+
delete params.top_p;
|
|
95
|
+
delete params.top_k;
|
|
96
|
+
if (opus5 || sonnet5) delete params.service_tier;
|
|
97
|
+
}
|
|
98
|
+
function resolveReplayModelBoundIdentity(ref) {
|
|
99
|
+
if (normalizeApi(ref.api) !== "anthropic-messages") return;
|
|
100
|
+
const modelRef = hasConcreteResponseModel(ref) ? { id: ref.responseModelId } : {
|
|
101
|
+
id: ref.modelId,
|
|
102
|
+
params: ref.modelParams
|
|
103
|
+
};
|
|
104
|
+
const fableIdentity = resolveClaudeFable5ModelIdentity(modelRef);
|
|
105
|
+
if (fableIdentity) return `fable:${fableIdentity}`;
|
|
106
|
+
const mythosIdentity = resolveClaudeMythos5ModelIdentity(modelRef);
|
|
107
|
+
if (mythosIdentity) return `mythos:${mythosIdentity}`;
|
|
108
|
+
const opusIdentity = resolveClaudeOpus5ModelIdentity(modelRef);
|
|
109
|
+
if (opusIdentity) return `opus:${opusIdentity}`;
|
|
110
|
+
const sonnetIdentity = resolveClaudeSonnet5ModelIdentity(modelRef);
|
|
111
|
+
return sonnetIdentity ? `sonnet:${sonnetIdentity}` : void 0;
|
|
112
|
+
}
|
|
113
|
+
function resolveModelBoundThinkingReplayMode(params) {
|
|
114
|
+
const sourceApi = normalizeApi(params.source.api);
|
|
115
|
+
const targetApi = normalizeApi(params.target.api);
|
|
116
|
+
const sourceIdentity = resolveReplayModelBoundIdentity(params.source);
|
|
117
|
+
const targetIdentity = resolveReplayModelBoundIdentity(params.target);
|
|
118
|
+
const sameRoute = normalizeLowercaseStringOrEmpty(params.source.provider) === normalizeLowercaseStringOrEmpty(params.target.provider) && sourceApi === targetApi && normalizeModelId(params.source.modelId) === normalizeModelId(params.target.modelId);
|
|
119
|
+
if (!sourceIdentity && !targetIdentity) return "default";
|
|
120
|
+
if (!sourceIdentity && !hasConcreteResponseModel(params.source) && targetIdentity && sameRoute) return "preserve";
|
|
121
|
+
return sourceApi === targetApi && sourceIdentity === targetIdentity ? "preserve" : "drop";
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region packages/ai/src/providers/tool-result-text.ts
|
|
125
|
+
const PROVIDER_TOOL_RESULT_MAX_CHARS = 8e3;
|
|
126
|
+
const IMAGE_TOOL_RESULT_TYPES = /* @__PURE__ */ new Set([
|
|
127
|
+
"image",
|
|
128
|
+
"image_url",
|
|
129
|
+
"input_image"
|
|
130
|
+
]);
|
|
131
|
+
const AUDIO_TOOL_RESULT_TYPES = /* @__PURE__ */ new Set([
|
|
132
|
+
"audio",
|
|
133
|
+
"input_audio",
|
|
134
|
+
"output_audio"
|
|
135
|
+
]);
|
|
136
|
+
const MEDIA_ONLY_TOOL_RESULT_TYPES = /* @__PURE__ */ new Set([...IMAGE_TOOL_RESULT_TYPES, ...AUDIO_TOOL_RESULT_TYPES]);
|
|
137
|
+
const INLINE_DATA_URI_PATTERN = /(^|[^A-Za-z0-9_])data:([a-z][a-z0-9.+-]*\/[a-z0-9.+-]+(?:;[a-z0-9.+-]+=[^,;"'\s]+|;base64)*,[^\s"'<>)]+)/gi;
|
|
138
|
+
const MIME_KEY_CANDIDATES = [
|
|
139
|
+
"mimeType",
|
|
140
|
+
"mime_type",
|
|
141
|
+
"mediaType",
|
|
142
|
+
"media_type",
|
|
143
|
+
"contentType",
|
|
144
|
+
"content_type"
|
|
145
|
+
];
|
|
146
|
+
const TEXTUAL_MIME_PATTERN = /^(?:text\/|application\/(?:json|ld\+json|x-ndjson|xml|javascript|x-www-form-urlencoded)|[^/]+\/[^+]+\+(?:json|xml)$)/i;
|
|
147
|
+
const OPAQUE_OR_BINARY_FIELD_RE = /^(?:blob|buffer|bytes|encrypted_content|encrypted_stdout)$/i;
|
|
148
|
+
function readMimeType(value) {
|
|
149
|
+
if (!isRecord(value)) return;
|
|
150
|
+
for (const key of MIME_KEY_CANDIDATES) {
|
|
151
|
+
const mimeType = value[key];
|
|
152
|
+
if (typeof mimeType === "string" && mimeType.trim().length > 0) return mimeType;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function isBinaryMimeType(mimeType) {
|
|
156
|
+
const normalized = mimeType.split(";", 1)[0]?.trim().toLowerCase();
|
|
157
|
+
return normalized ? !TEXTUAL_MIME_PATTERN.test(normalized) : false;
|
|
158
|
+
}
|
|
159
|
+
function describeOmittedValue(value, label) {
|
|
160
|
+
const length = typeof value === "string" ? value.length : JSON.stringify(value)?.length;
|
|
161
|
+
return length ? `[${label} omitted: ${length} chars]` : `[${label} omitted]`;
|
|
162
|
+
}
|
|
163
|
+
function redactInlineDataUris(value) {
|
|
164
|
+
return value.replace(INLINE_DATA_URI_PATTERN, (_match, prefix, uri) => `${prefix}[inline data URI: ${uri.length} chars]`);
|
|
165
|
+
}
|
|
166
|
+
function stringifyStructuredBlock(block) {
|
|
167
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
168
|
+
try {
|
|
169
|
+
const host = getAiTransportHost();
|
|
170
|
+
const redactedBlock = host.redactModelVisibleSecrets({ structuredToolResult: block }).structuredToolResult;
|
|
171
|
+
const serialized = JSON.stringify(redactedBlock, function structuredToolResultReplacer(key, value) {
|
|
172
|
+
if (OPAQUE_OR_BINARY_FIELD_RE.test(key)) return `[omitted ${key}]`;
|
|
173
|
+
if (key === "data") {
|
|
174
|
+
const mimeType = readMimeType(this);
|
|
175
|
+
if (mimeType && isBinaryMimeType(mimeType)) return describeOmittedValue(value, "binary data");
|
|
176
|
+
}
|
|
177
|
+
if (typeof value === "bigint") return value.toString();
|
|
178
|
+
if (typeof value === "string") return redactInlineDataUris(host.redactModelVisibleSecrets(value));
|
|
179
|
+
if (typeof value === "function" || typeof value === "symbol" || value === void 0) return;
|
|
180
|
+
if (!value || typeof value !== "object") return value;
|
|
181
|
+
if (seen.has(value)) return "[Circular]";
|
|
182
|
+
seen.add(value);
|
|
183
|
+
return value;
|
|
184
|
+
});
|
|
185
|
+
if (!serialized || serialized === "{}") return;
|
|
186
|
+
return serialized;
|
|
187
|
+
} catch {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function truncateProviderToolText(text) {
|
|
192
|
+
if (text.length <= PROVIDER_TOOL_RESULT_MAX_CHARS) return text;
|
|
193
|
+
return `${truncateUtf16Safe(text, PROVIDER_TOOL_RESULT_MAX_CHARS)}\n…(truncated)…`;
|
|
194
|
+
}
|
|
195
|
+
/** Media metadata alone is not an attachment; provider emitters need inline bytes. */
|
|
196
|
+
function hasMediaPayload(block) {
|
|
197
|
+
return isRecord(block) && typeof block.data === "string" && block.data.trim().length > 0;
|
|
198
|
+
}
|
|
199
|
+
/** Image metadata alone is not an attachment; provider emitters need inline bytes. */
|
|
200
|
+
function isImageWithMediaPayload(block) {
|
|
201
|
+
return isRecord(block) && block.type === "image" && hasMediaPayload(block);
|
|
202
|
+
}
|
|
203
|
+
function classifyToolResultMedia(blocks) {
|
|
204
|
+
let hasImage = false;
|
|
205
|
+
let hasAudio = false;
|
|
206
|
+
for (const block of blocks) {
|
|
207
|
+
if (!hasMediaPayload(block) || block.type === "text") continue;
|
|
208
|
+
const type = typeof block.type === "string" ? block.type : void 0;
|
|
209
|
+
const mimeType = readMimeType(block)?.toLowerCase();
|
|
210
|
+
hasImage ||= Boolean(type && IMAGE_TOOL_RESULT_TYPES.has(type) || mimeType?.startsWith("image/"));
|
|
211
|
+
hasAudio ||= Boolean(type && AUDIO_TOOL_RESULT_TYPES.has(type) || mimeType?.startsWith("audio/"));
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
hasImage,
|
|
215
|
+
hasAudio
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function describeToolResultMediaPlaceholder(blocks) {
|
|
219
|
+
const { hasImage, hasAudio } = classifyToolResultMedia(blocks);
|
|
220
|
+
if (hasImage && hasAudio) return "(see attached media)";
|
|
221
|
+
if (hasAudio) return "(see attached audio)";
|
|
222
|
+
return hasImage ? "(see attached image)" : void 0;
|
|
223
|
+
}
|
|
224
|
+
function extractToolResultBlockText(block) {
|
|
225
|
+
if (!block || typeof block !== "object") return;
|
|
226
|
+
const record = block;
|
|
227
|
+
if (typeof record.type === "string" && MEDIA_ONLY_TOOL_RESULT_TYPES.has(record.type)) return;
|
|
228
|
+
if (record.type === "text") {
|
|
229
|
+
const text = typeof record.text === "string" ? record.text : "";
|
|
230
|
+
return text ? sanitizeSurrogates(text) : void 0;
|
|
231
|
+
}
|
|
232
|
+
const structured = stringifyStructuredBlock(record);
|
|
233
|
+
return structured ? sanitizeSurrogates(truncateProviderToolText(structured)) : void 0;
|
|
234
|
+
}
|
|
235
|
+
function extractToolResultText(blocks, options) {
|
|
236
|
+
const explicitTexts = [];
|
|
237
|
+
const structuredTexts = [];
|
|
238
|
+
for (const block of blocks) {
|
|
239
|
+
const text = extractToolResultBlockText(block);
|
|
240
|
+
if (!text) continue;
|
|
241
|
+
if (block.type === "text") explicitTexts.push(text);
|
|
242
|
+
else structuredTexts.push(text);
|
|
243
|
+
}
|
|
244
|
+
if (explicitTexts.length > 0) {
|
|
245
|
+
const text = (options?.includeStructured ? [...explicitTexts, ...structuredTexts] : explicitTexts).join("\n");
|
|
246
|
+
return sanitizeSurrogates(options?.includeStructured ? truncateProviderToolText(text) : text);
|
|
247
|
+
}
|
|
248
|
+
return sanitizeSurrogates(truncateProviderToolText(structuredTexts.join("\n")));
|
|
249
|
+
}
|
|
250
|
+
/** Describe media that cannot be represented on the target provider wire. */
|
|
251
|
+
function describeUnsupportedToolResultMedia(blocks, support) {
|
|
252
|
+
const { hasImage, hasAudio } = classifyToolResultMedia(blocks);
|
|
253
|
+
const omittedImage = hasImage && !support.images;
|
|
254
|
+
const omittedAudio = hasAudio && !support.audio;
|
|
255
|
+
if (omittedImage && omittedAudio) return "[unsupported tool-result media omitted]";
|
|
256
|
+
if (omittedAudio) return "[unsupported tool-result audio omitted]";
|
|
257
|
+
return omittedImage ? "[unsupported tool-result image omitted]" : void 0;
|
|
258
|
+
}
|
|
259
|
+
function formatToolResultText(params) {
|
|
260
|
+
const trimmed = params.text.trim();
|
|
261
|
+
const body = trimmed ? `${trimmed}${params.omittedMediaPlaceholder ? `\n${params.omittedMediaPlaceholder}` : ""}` : params.omittedMediaPlaceholder ?? params.mediaPlaceholder ?? "(no tool output)";
|
|
262
|
+
return `${params.isError ? "[tool error] " : ""}${body}`;
|
|
263
|
+
}
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region packages/ai/src/transcript-transform.ts
|
|
266
|
+
const NON_VISION_USER_IMAGE_PLACEHOLDER = "(image omitted: model does not support images)";
|
|
267
|
+
const NON_VISION_TOOL_IMAGE_PLACEHOLDER = "(tool image omitted: model does not support images)";
|
|
268
|
+
function replaceImagesWithPlaceholder(content, placeholder) {
|
|
269
|
+
const result = [];
|
|
270
|
+
for (const block of content) {
|
|
271
|
+
if (block.type !== "image") {
|
|
272
|
+
result.push(block);
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
const previous = result.at(-1);
|
|
276
|
+
const repeated = previous?.type === "text" && previous.text === placeholder;
|
|
277
|
+
if (isImageWithMediaPayload(block) && !repeated) result.push({
|
|
278
|
+
type: "text",
|
|
279
|
+
text: placeholder
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
function downgradeUnsupportedImages(messages, model) {
|
|
285
|
+
if (model.input.includes("image")) return messages;
|
|
286
|
+
return messages.map((message) => {
|
|
287
|
+
if (message.role === "assistant" || typeof message.content === "string") return message;
|
|
288
|
+
const placeholder = message.role === "user" ? NON_VISION_USER_IMAGE_PLACEHOLDER : NON_VISION_TOOL_IMAGE_PLACEHOLDER;
|
|
289
|
+
return {
|
|
290
|
+
...message,
|
|
291
|
+
content: replaceImagesWithPlaceholder(message.content, placeholder)
|
|
292
|
+
};
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
function transformAssistant(message, model, toolCallIdMap, normalizeToolCallId) {
|
|
296
|
+
const replayMode = resolveModelBoundThinkingReplayMode({
|
|
297
|
+
source: {
|
|
298
|
+
provider: message.provider,
|
|
299
|
+
api: message.api,
|
|
300
|
+
modelId: message.model,
|
|
301
|
+
responseModelId: message.responseModel
|
|
302
|
+
},
|
|
303
|
+
target: {
|
|
304
|
+
provider: model.provider,
|
|
305
|
+
api: model.api,
|
|
306
|
+
modelId: model.id,
|
|
307
|
+
modelParams: model.params
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
const sameModel = replayMode === "preserve" || message.provider === model.provider && message.api === model.api && message.model === model.id;
|
|
311
|
+
const content = (typeof message.content === "string" ? [{
|
|
312
|
+
type: "text",
|
|
313
|
+
text: message.content
|
|
314
|
+
}] : message.content).flatMap((block) => {
|
|
315
|
+
if (block.type === "thinking") {
|
|
316
|
+
if (replayMode === "drop") return [];
|
|
317
|
+
if (block.redacted) return sameModel ? block : [];
|
|
318
|
+
if (sameModel && block.thinkingSignature) return block;
|
|
319
|
+
if (!block.thinking?.trim()) return [];
|
|
320
|
+
return sameModel ? block : {
|
|
321
|
+
type: "text",
|
|
322
|
+
text: block.thinking
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
if (block.type === "text") return sameModel ? block : {
|
|
326
|
+
type: "text",
|
|
327
|
+
text: block.text
|
|
328
|
+
};
|
|
329
|
+
const { thoughtSignature: _, ...unsigned } = block;
|
|
330
|
+
const trimmedId = block.id.trim();
|
|
331
|
+
if (sameModel) return trimmedId === block.id ? block : Object.assign({}, block, { id: trimmedId });
|
|
332
|
+
const id = normalizeToolCallId?.(trimmedId, model, message) ?? trimmedId;
|
|
333
|
+
if (id !== trimmedId) toolCallIdMap.set(trimmedId, id);
|
|
334
|
+
return id === block.id ? unsigned : Object.assign({}, unsigned, { id });
|
|
335
|
+
});
|
|
336
|
+
return {
|
|
337
|
+
...message,
|
|
338
|
+
content
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
function transformMessages(messages, model, normalizeToolCallId) {
|
|
342
|
+
const toolCallIdMap = /* @__PURE__ */ new Map();
|
|
343
|
+
const transformed = downgradeUnsupportedImages(messages.map((message) => message.content == null ? Object.assign({}, message, { content: [] }) : message), model).map((message) => {
|
|
344
|
+
if (message.role === "assistant") return transformAssistant(message, model, toolCallIdMap, normalizeToolCallId);
|
|
345
|
+
if (message.role !== "toolResult") return message;
|
|
346
|
+
const trimmedId = message.toolCallId.trim();
|
|
347
|
+
const toolCallId = toolCallIdMap.get(trimmedId) ?? trimmedId;
|
|
348
|
+
return toolCallId === message.toolCallId ? message : Object.assign({}, message, { toolCallId });
|
|
349
|
+
});
|
|
350
|
+
const result = [];
|
|
351
|
+
let pendingToolCalls = [];
|
|
352
|
+
let existingToolResultIds = /* @__PURE__ */ new Set();
|
|
353
|
+
const flushToolCalls = () => {
|
|
354
|
+
for (const call of pendingToolCalls) if (!existingToolResultIds.has(call.id)) result.push({
|
|
355
|
+
role: "toolResult",
|
|
356
|
+
toolCallId: call.id,
|
|
357
|
+
toolName: call.name,
|
|
358
|
+
content: [{
|
|
359
|
+
type: "text",
|
|
360
|
+
text: "No result provided"
|
|
361
|
+
}],
|
|
362
|
+
isError: true,
|
|
363
|
+
timestamp: Date.now()
|
|
364
|
+
});
|
|
365
|
+
pendingToolCalls = [];
|
|
366
|
+
existingToolResultIds = /* @__PURE__ */ new Set();
|
|
367
|
+
};
|
|
368
|
+
for (const message of transformed) {
|
|
369
|
+
if (message.role === "assistant") {
|
|
370
|
+
flushToolCalls();
|
|
371
|
+
if (message.stopReason === "error" || message.stopReason === "aborted") continue;
|
|
372
|
+
pendingToolCalls = message.content.filter((block) => block.type === "toolCall");
|
|
373
|
+
} else if (message.role === "toolResult") existingToolResultIds.add(message.toolCallId);
|
|
374
|
+
else flushToolCalls();
|
|
375
|
+
result.push(message);
|
|
376
|
+
}
|
|
377
|
+
flushToolCalls();
|
|
378
|
+
return result;
|
|
379
|
+
}
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region packages/ai/src/host.ts
|
|
382
|
+
const MAX_PENDING_CUSTOM_API_REGISTRATIONS = 32;
|
|
383
|
+
const pendingCustomApiRegistrations = [];
|
|
384
|
+
function queueCustomApiRegistration(registry, api, streamFn) {
|
|
385
|
+
const existing = pendingCustomApiRegistrations.find((registration) => registration.registry === registry && registration.api === api);
|
|
386
|
+
if (existing) {
|
|
387
|
+
existing.streamFn = streamFn;
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
if (pendingCustomApiRegistrations.length >= MAX_PENDING_CUSTOM_API_REGISTRATIONS) throw new Error("Too many custom transport APIs were registered before host configuration");
|
|
391
|
+
pendingCustomApiRegistrations.push({
|
|
392
|
+
registry,
|
|
393
|
+
api,
|
|
394
|
+
streamFn
|
|
395
|
+
});
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
const inertAiTransportHost = {
|
|
399
|
+
buildModelFetch: () => void 0,
|
|
400
|
+
resolveSecretSentinel: (value) => value,
|
|
401
|
+
redactModelVisibleSecrets: (value) => value,
|
|
402
|
+
redactToolPayloadText: (text) => text,
|
|
403
|
+
normalizeAnthropicInlineContentBlocks: async (content) => [...content],
|
|
404
|
+
resolveOpenAIStrictToolSetting: (_model, options) => options?.supportsStrictMode ? false : void 0,
|
|
405
|
+
plugin: {
|
|
406
|
+
resolveProviderStream: () => void 0,
|
|
407
|
+
resolveTransportTurnState: () => void 0,
|
|
408
|
+
wrapSimpleCompletionStream: () => void 0,
|
|
409
|
+
createAnthropicVertexStream: () => {
|
|
410
|
+
throw new Error("Anthropic Vertex transport is not configured by the embedding host");
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
buildCopilotDynamicHeaders: () => ({}),
|
|
414
|
+
resolveProviderRequestCapabilities: () => ({
|
|
415
|
+
endpointClass: "default",
|
|
416
|
+
knownProviderFamily: "",
|
|
417
|
+
supportsNativeStreamingUsageCompat: false,
|
|
418
|
+
supportsOpenAICompletionsStreamingUsageCompat: false,
|
|
419
|
+
usesExplicitProxyLikeEndpoint: false,
|
|
420
|
+
allowsAnthropicServiceTier: false
|
|
421
|
+
}),
|
|
422
|
+
resolveProviderRequestHeaders: ({ providerHeaders, callerHeaders, precedence }) => ({
|
|
423
|
+
...precedence === "caller-wins" ? providerHeaders : callerHeaders,
|
|
424
|
+
...precedence === "caller-wins" ? callerHeaders : providerHeaders
|
|
425
|
+
}),
|
|
426
|
+
resolveModelRequestTimeoutMs: () => void 0,
|
|
427
|
+
requiresManagedTransport: () => false,
|
|
428
|
+
inheritManagedTransport: (_source, target) => target,
|
|
429
|
+
transformTransportMessages: (messages, model, normalizeToolCallId) => transformMessages(messages, model, normalizeToolCallId),
|
|
430
|
+
registerCustomApi: queueCustomApiRegistration,
|
|
431
|
+
logDebug: () => {},
|
|
432
|
+
logInfo: () => {},
|
|
433
|
+
logWarn: () => {}
|
|
434
|
+
};
|
|
435
|
+
let activeAiTransportHost = inertAiTransportHost;
|
|
436
|
+
/** Installs host implementations for the transport policy ports. */
|
|
437
|
+
function configureAiTransportHost(host) {
|
|
438
|
+
activeAiTransportHost = {
|
|
439
|
+
...inertAiTransportHost,
|
|
440
|
+
...host,
|
|
441
|
+
normalizeAnthropicInlineContentBlocks: host.normalizeAnthropicInlineContentBlocks ?? inertAiTransportHost.normalizeAnthropicInlineContentBlocks,
|
|
442
|
+
plugin: {
|
|
443
|
+
...inertAiTransportHost.plugin,
|
|
444
|
+
...host.plugin
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
const transportHost = activeAiTransportHost;
|
|
448
|
+
if (transportHost.registerCustomApi === inertAiTransportHost.registerCustomApi || pendingCustomApiRegistrations.length === 0) return;
|
|
449
|
+
const pending = pendingCustomApiRegistrations.splice(0);
|
|
450
|
+
for (const [index, registration] of pending.entries()) try {
|
|
451
|
+
transportHost.registerCustomApi(registration.registry, registration.api, registration.streamFn);
|
|
452
|
+
} catch (error) {
|
|
453
|
+
pendingCustomApiRegistrations.unshift(...pending.slice(index));
|
|
454
|
+
throw error;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
/** Returns the active transport host (inert defaults unless configured). */
|
|
458
|
+
function getAiTransportHost() {
|
|
459
|
+
return activeAiTransportHost;
|
|
460
|
+
}
|
|
461
|
+
/** Resolves sentinel substrings in custom headers at a no-fetch adapter boundary. */
|
|
462
|
+
function resolveAiTransportHeaderSentinels(headers) {
|
|
463
|
+
if (!headers) return;
|
|
464
|
+
const host = getAiTransportHost();
|
|
465
|
+
let resolvedHeaders;
|
|
466
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
467
|
+
if (value === null) continue;
|
|
468
|
+
const resolved = host.resolveSecretSentinel(value);
|
|
469
|
+
if (resolved !== value) {
|
|
470
|
+
resolvedHeaders ??= { ...headers };
|
|
471
|
+
resolvedHeaders[name] = resolved;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return resolvedHeaders ?? headers;
|
|
475
|
+
}
|
|
476
|
+
//#endregion
|
|
477
|
+
export { usesClaudeStreamingRefusalContract as S, prepareClaudeNoPrefillRequestContext as _, describeToolResultMediaPlaceholder as a, resolveModelBoundThinkingReplayMode as b, extractToolResultText as c, isImageWithMediaPayload as d, ANTHROPIC_CLAUDE_CODE_BILLING_SYSTEM_BLOCK as f, mapAnthropicStopReason as g, defaultsClaudeAdaptiveThinking as h, transformMessages as i, formatToolResultText as l, applyClaudeRequestContract as m, getAiTransportHost as n, describeUnsupportedToolResultMedia as o, ANTHROPIC_CLAUDE_CODE_VERSION as p, resolveAiTransportHeaderSentinels as r, extractToolResultBlockText as s, configureAiTransportHost as t, hasMediaPayload as u, requiresClaudeAdaptiveThinking as v, usesClaudeFable5MessagesContract as x, resolveAnthropicThinkingEffort as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
1
|
+
import { D as Model, V as StreamFn, d as Context, n as Api } from "./types-DTAP49HF.mjs";
|
|
2
|
+
import { n as ApiRegistry } from "./api-registry-DFxSnFqG.mjs";
|
|
3
3
|
|
|
4
4
|
//#region packages/ai/src/host.d.ts
|
|
5
5
|
/** Provider capability facts needed by the package-owned transports. */
|
|
@@ -20,6 +20,7 @@ interface AiProviderRequestPolicyInput {
|
|
|
20
20
|
transport?: "stream" | "websocket" | "http" | "media-understanding";
|
|
21
21
|
modelId?: string | null;
|
|
22
22
|
compat?: unknown;
|
|
23
|
+
model?: object;
|
|
23
24
|
}
|
|
24
25
|
/** Context shared by plugin-owned provider stream hooks. */
|
|
25
26
|
interface AiProviderStreamHookContext {
|
|
@@ -29,6 +30,8 @@ interface AiProviderStreamHookContext {
|
|
|
29
30
|
provider: string;
|
|
30
31
|
modelId: string;
|
|
31
32
|
model: Model;
|
|
33
|
+
/** Wire-format API before simple completion projects an internal transport alias. */
|
|
34
|
+
sourceApi?: Api;
|
|
32
35
|
}
|
|
33
36
|
/** Narrow plugin-runtime port used by package-owned transports. */
|
|
34
37
|
interface AiTransportPluginHost {
|
|
@@ -59,6 +62,10 @@ interface AiTransportPluginHost {
|
|
|
59
62
|
}): {
|
|
60
63
|
headers?: Record<string, string>;
|
|
61
64
|
metadata?: Record<string, string>;
|
|
65
|
+
websocket?: {
|
|
66
|
+
headers?: Record<string, string>;
|
|
67
|
+
degradeCooldownMs?: number;
|
|
68
|
+
};
|
|
62
69
|
} | undefined;
|
|
63
70
|
wrapSimpleCompletionStream(this: void, params: {
|
|
64
71
|
provider: string;
|
|
@@ -77,6 +84,7 @@ type AiTransformTransportMessages = (messages: Context["messages"], model: Model
|
|
|
77
84
|
}) => string, options?: {
|
|
78
85
|
normalizeSameModelToolCallIds?: boolean;
|
|
79
86
|
preserveCrossModelToolCallThoughtSignature?: boolean;
|
|
87
|
+
preserveUnframedToolResults?: boolean;
|
|
80
88
|
}) => Context["messages"];
|
|
81
89
|
/** Strict-tool policy inputs for OpenAI-compatible routes. */
|
|
82
90
|
interface OpenAIStrictToolSettingOptions {
|
|
@@ -105,8 +113,8 @@ interface AiTransportHost {
|
|
|
105
113
|
}): typeof fetch | undefined;
|
|
106
114
|
/** Resolves host-owned process-local secret sentinel substrings immediately before egress. */
|
|
107
115
|
resolveSecretSentinel(value: string): string;
|
|
108
|
-
/** Redacts
|
|
109
|
-
|
|
116
|
+
/** Redacts model-visible tool results without treating ordinary source assignments as secrets. */
|
|
117
|
+
redactModelVisibleSecrets<T>(value: T): T;
|
|
110
118
|
/** Redacts secret-bearing text in tool payload strings. */
|
|
111
119
|
redactToolPayloadText(text: string): string;
|
|
112
120
|
/** Normalizes Anthropic inline image blocks before provider payload construction. */
|
|
@@ -122,8 +130,6 @@ interface AiTransportHost {
|
|
|
122
130
|
plugin: AiTransportPluginHost;
|
|
123
131
|
/** Builds provider-owned Copilot compatibility headers for one message turn. */
|
|
124
132
|
buildCopilotDynamicHeaders(messages: Context["messages"]): Record<string, string>;
|
|
125
|
-
/** Resolves endpoint classification without importing core provider registries. */
|
|
126
|
-
resolveProviderEndpointClass(baseUrl?: string): string;
|
|
127
133
|
/** Resolves provider capability flags used by payload compatibility policy. */
|
|
128
134
|
resolveProviderRequestCapabilities(input: AiProviderRequestPolicyInput): AiProviderRequestCapabilities;
|
|
129
135
|
/** Merges host-owned provider request headers and attribution policy. */
|
|
@@ -134,6 +140,7 @@ interface AiTransportHost {
|
|
|
134
140
|
providerHeaders?: Record<string, string>;
|
|
135
141
|
callerHeaders?: Record<string, string>;
|
|
136
142
|
precedence?: "caller-wins" | "defaults-win";
|
|
143
|
+
model?: object;
|
|
137
144
|
}): Record<string, string> | undefined;
|
|
138
145
|
/** Returns the host-configured request timeout attached to a model. */
|
|
139
146
|
resolveModelRequestTimeoutMs(model: Model): number | undefined;
|
|
@@ -145,8 +152,6 @@ interface AiTransportHost {
|
|
|
145
152
|
transformTransportMessages: AiTransformTransportMessages;
|
|
146
153
|
/** Registers a custom transport API with the host's stream error bridge. */
|
|
147
154
|
registerCustomApi(registry: ApiRegistry, api: Api, streamFn: StreamFn): boolean;
|
|
148
|
-
/** Prepares the provider-owned Google simple-completion alias when needed. */
|
|
149
|
-
prepareGoogleSimpleCompletionModel(registry: ApiRegistry, model: Model): Model;
|
|
150
155
|
/**
|
|
151
156
|
* Emits one transport diagnostic; build runs only when the host logs it and
|
|
152
157
|
* may return null to suppress the entry (e.g. de-duplication).
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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-
|
|
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-BECQCNdF.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
|
|
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 Transport, A as OpenAIResponsesCompat, B as StopReason, C as KnownImagesApi, D as Model, E as Message, F as ProviderImagesOptions, G as TextSignatureV1, H as StreamFunction, I as ProviderReplayState, J as ThinkingLevel, K as ThinkingBudgets, L as ProviderResponse, M as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, N as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, O as ModelThinkingLevel, P as Provider, Q as ToolResultMessage, R as ProviderStreamOptions, S as KnownApi, T as MaybePromise, U as StreamOptions, V as StreamFn, W as TextContent, X as Tool, Y as ThinkingLevelMap, Z as ToolCall, _ as ImagesModel, a as AssistantMessage, b as ImagesProvider, c as AssistantMessageEventStreamLike, d as Context, et as Usage, f as ImageContent, g as ImagesInputContent, h as ImagesFunction, i as AssistantImages, j as OpenRouterRouting, k as OpenAICompletionsCompat, l as CacheRetention, m as ImagesContext, n as Api, nt as ValidateToolArgumentsFn, o as AssistantMessageEvent, p as ImagesApi, q as ThinkingContent, r as AssistantDeliveryTtsFacts, rt as VercelGatewayRouting, s as AssistantMessageEventStreamContract, t as AnthropicMessagesCompat, tt as UserMessage, u as CompleteSimpleFn, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as SimpleStreamOptions } from "./types-DTAP49HF.mjs";
|
|
4
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-D91-ohD_.mjs";
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-DYNNrU9u.mjs";
|
|
6
|
+
import { a as RegisteredApiProvider, i as ApiStreamSimpleFunction, n as ApiRegistry, o as createApiRegistry, r as ApiStreamFunction, t as ApiProvider } from "./api-registry-DFxSnFqG.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-DJq_FGcz.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_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 };
|
|
26
|
+
export { AiInlineContentBlock, AiInlineImageBlock, AiInlineTextBlock, AiProviderRequestCapabilities, AiProviderRequestPolicyInput, AiProviderStreamHookContext, AiTransformTransportMessages, AiTransportHost, AiTransportPluginHost, AnthropicMessagesCompat, Api, ApiProvider, ApiRegistry, ApiStreamFunction, ApiStreamSimpleFunction, AssistantDeliveryTtsFacts, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, CacheRetention, CompleteSimpleFn, Context, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, LlmRuntime, MaybePromise, Message, Model, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenAIStrictToolSettingOptions, OpenRouterRouting, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, Provider, ProviderImagesOptions, ProviderReplayState, 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,9 @@
|
|
|
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 "./
|
|
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-BQXQudmA.mjs";
|
|
2
|
+
import { n as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, t as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE } from "./types-BDdaOVi2.mjs";
|
|
2
3
|
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-
|
|
4
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
4
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-B61OhAio.mjs";
|
|
6
|
+
import "./src-D2H6yKkH.mjs";
|
|
5
7
|
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_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 };
|
|
8
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels, t as configureAiTransportHost } from "./host-DF_yxOsA.mjs";
|
|
9
|
+
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, EventStream, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, 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 };
|