@openclaw/ai 2026.8.1-beta.2 → 2026.9.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{anthropic-SrGtwsJu.d.mts → anthropic-BECQCNdF.d.mts} +0 -2
- package/dist/{anthropic-B6dLpq5L.mjs → anthropic-DI4PZKKB.mjs} +46 -34
- package/dist/{anthropic-compaction-replay-8lJNKXOE.mjs → anthropic-compaction-replay-nhKaCXu6.mjs} +17 -22
- package/dist/{anthropic-payload-policy-CiEuQS72.d.mts → anthropic-payload-policy-B_0n0enE.d.mts} +3 -1
- package/dist/{api-registry-k3zTz0cV.d.mts → api-registry-CTd8NzcD.d.mts} +2 -1
- package/dist/{azure-openai-responses-mxIOtUnn.mjs → azure-openai-responses-D8dI0ekg.mjs} +3 -3
- package/dist/diagnostics.d.mts +0 -1
- package/dist/diagnostics.mjs +1 -1
- package/dist/event-stream-BKp4fOt_.d.mts +1 -0
- package/dist/{event-stream-BP6AWT8j.d.mts → event-stream-LiXePESD.d.mts} +1 -2
- package/dist/event-stream.d.mts +2 -1
- package/dist/{google-C7h2QzDX.mjs → google-Od-LLdVK.mjs} +3 -3
- package/dist/{google-shared-B0Qr9OR7.mjs → google-shared-Bgr9lFPw.mjs} +22 -8
- package/dist/{google-vertex-Bhc3TjDl.mjs → google-vertex-aerRSXc4.mjs} +4 -4
- package/dist/{host-DTqNc7ad.mjs → host-D51fmkH6.mjs} +40 -33
- package/dist/{host-vWgMMhiJ.d.mts → host-DsbPMFU6.d.mts} +7 -7
- package/dist/index-Qbej8io0.d.mts +3 -0
- package/dist/index.d.mts +8 -8
- package/dist/index.mjs +2 -3
- package/dist/internal/anthropic.d.mts +13 -6
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/openai-responses-payload-policy.d.mts +2 -2
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +6 -6
- package/dist/internal/openai.mjs +10 -8
- package/dist/internal/runtime.d.mts +18 -5
- package/dist/internal/runtime.mjs +8 -7
- package/dist/internal/shared.d.mts +18 -4
- package/dist/internal/shared.mjs +4 -4
- package/dist/{json-parse-CDnesDM_.mjs → json-parse-BuAJEbdW.mjs} +18 -2
- package/dist/{headers-DdOQtGuU.mjs → llm-request-activity-BjtkplhG.mjs} +1 -9
- package/dist/{mistral-CEWoQI_g.mjs → mistral-EiHdymeb.mjs} +59 -49
- package/dist/{openai-chatgpt-responses-CrPmqERt.mjs → openai-chatgpt-responses-DHpF9o1e.mjs} +42 -17
- package/dist/{openai-completions-BPnt4Sml.mjs → openai-completions-EFPiUGfS.mjs} +60 -257
- package/dist/{openai-completions-compat-Dt3dcawL.d.mts → openai-completions-compat-BefmHT26.d.mts} +3 -3
- package/dist/openai-completions-stream-DUlGwRMz.mjs +1621 -0
- package/dist/{openai-responses-DhIKtOup.mjs → openai-responses-BogP8OjX.mjs} +6 -5
- package/dist/{openai-responses-contracts-XpZJxrRG.d.mts → openai-responses-contracts-Dvj_UtPy.d.mts} +3 -3
- package/dist/{openai-responses-contracts-CyfIkQi5.mjs → openai-responses-contracts-QUY12X0B.mjs} +6 -26
- package/dist/{openai-responses-payload-policy-BSs371VM.d.mts → openai-responses-payload-policy-CNGFT9zr.d.mts} +1 -0
- package/dist/{openai-responses-payload-policy-BDxV-W0c.mjs → openai-responses-payload-policy-D8EdimYe.mjs} +6 -8
- package/dist/{openai-responses-prompt-observer-internal-DgNTYnRY.mjs → openai-responses-prompt-observer-internal-Cd4hJG-S.mjs} +3 -3
- package/dist/{openai-responses-shared-DXIt3iY5.mjs → openai-responses-shared-DJThc6jW.mjs} +205 -1472
- package/dist/openai-stop-reason-Drnn_6Qj.mjs +28 -0
- package/dist/openai-tool-schema-ho-hIkQf.mjs +1695 -0
- package/dist/{provider-error-BUwEnjXq.mjs → provider-error-DDOs_Bz0.mjs} +20 -27
- package/dist/provider-options-AvldWZt8.mjs +21 -0
- package/dist/{provider-options-B96RdNpH.d.mts → provider-options-MdMBLzlU.d.mts} +15 -4
- package/dist/provider-transcript-transform-C01bQ5a3.mjs +32 -0
- package/dist/provider-types.d.mts +7 -5
- package/dist/providers.d.mts +1 -2
- package/dist/providers.mjs +9 -9
- package/dist/{reasoning-tag-text-partitioner-rnPwX2pg.mjs → reasoning-tag-text-partitioner-5ygO2rZc.mjs} +3 -0
- package/dist/{sanitize-unicode-BYqrYtC_.mjs → sanitize-unicode-DCkltN94.mjs} +1 -2
- package/dist/{simple-options-D58D5Kvw.mjs → simple-options-CFj7x3J4.mjs} +5 -4
- package/dist/{anthropic-JsNA5KCu.mjs → src-Bu3FiFAG.mjs} +1 -1
- package/dist/{streaming-byte-guard-BrbkbwUu.mjs → streaming-byte-guard-CC-HMn_u.mjs} +5 -6
- package/dist/string-normalization--fwJ4S2q.mjs +16 -0
- package/dist/{tool-schema-json-projection-q5d7QX5c.mjs → tool-schema-json-projection-qvTEs5Am.mjs} +17 -8
- package/dist/transport-stream-shared-ljShVIZB.mjs +342 -0
- package/dist/transport-stream-shared-rvaCyFYt.d.mts +138 -0
- package/dist/{transport-utils-DJqkxbhC.mjs → transport-utils-LJ1_rbi-.mjs} +8 -5
- package/dist/transports.d.mts +45 -106
- package/dist/transports.mjs +134 -1089
- package/dist/{types-BHNrPS1l.d.mts → types-DhLoJbFm.d.mts} +49 -17
- package/dist/types-GiAjXatj.d.mts +1 -0
- package/dist/types.d.mts +6 -5
- package/dist/types.mjs +1 -2
- package/dist/utf16-slice-qz3nsy87.mjs +84 -0
- package/dist/{validation-DT9SrFn3.d.mts → validation-Dk7q7NMN.d.mts} +1 -2
- package/dist/validation.d.mts +1 -1
- package/package.json +5 -5
- package/dist/index-BVVgDSdq.d.mts +0 -1
- package/dist/openai-stop-reason-BkFkqqK0.mjs +0 -563
- package/dist/openai-tool-projection-CY04OcvQ.mjs +0 -338
- package/dist/provider-transcript-transform-ePx-Bbfr.mjs +0 -155
- package/dist/record-coerce-DdXsgUd_.mjs +0 -23
- package/dist/src-D2H6yKkH.mjs +0 -2
- package/dist/stream-first-event-timeout-DvDeSucC.d.mts +0 -29
- package/dist/string-coerce-fsri9iCu.mjs +0 -34
- package/dist/types-BVVgDSdq.d.mts +0 -1
- package/dist/utf16-slice-CvGodqok.mjs +0 -29
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { n as getEnvApiKey, r as __exportAll } from "./env-api-keys-DrgeBuva.mjs";
|
|
2
|
-
import { d as resolveClaudeSonnet5ModelIdentity, g as supportsClaudeNativeXhighEffort, p as supportsClaudeAdaptiveThinking, u as resolveClaudeOpus5ModelIdentity } from "./
|
|
2
|
+
import { d as resolveClaudeSonnet5ModelIdentity, g as supportsClaudeNativeXhighEffort, p as supportsClaudeAdaptiveThinking, u as resolveClaudeOpus5ModelIdentity } from "./src-Bu3FiFAG.mjs";
|
|
3
3
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { n as
|
|
4
|
+
import { o as isRecord } from "./utf16-slice-qz3nsy87.mjs";
|
|
5
|
+
import { r as calculateCost, t as sanitizeSurrogates } from "./sanitize-unicode-DCkltN94.mjs";
|
|
6
|
+
import { S as usesClaudeStreamingRefusalContract, _ as prepareClaudeNoPrefillRequestContext, a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, f as ANTHROPIC_CLAUDE_CODE_BILLING_SYSTEM_BLOCK, g as mapAnthropicStopReason, m as applyClaudeRequestContract, n as getAiTransportHost, p as ANTHROPIC_CLAUDE_CODE_VERSION, r as resolveAiTransportHeaderSentinels, s as extractToolResultBlockText, v as requiresClaudeAdaptiveThinking, x as usesClaudeFable5MessagesContract, y as resolveAnthropicThinkingEffort } from "./host-D51fmkH6.mjs";
|
|
7
|
+
import { n as projectProviderError } from "./provider-error-DDOs_Bz0.mjs";
|
|
7
8
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
8
|
-
import { c as splitSystemPromptCacheBoundary, l as stripSystemPromptCacheBoundary, n as buildBaseOptions, r as clampMaxTokensToModel, t as adjustMaxTokensForThinking } from "./simple-options-
|
|
9
|
-
import {
|
|
9
|
+
import { c as splitSystemPromptCacheBoundary, l as stripSystemPromptCacheBoundary, n as buildBaseOptions, r as clampMaxTokensToModel, t as adjustMaxTokensForThinking } from "./simple-options-CFj7x3J4.mjs";
|
|
10
|
+
import { t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./transport-utils-LJ1_rbi-.mjs";
|
|
11
|
+
import { A as resolveAnthropicImageMediaType, C as readAnthropicFallbackBoundary, D as usesFoundryBearerAuth, E as omitFoundryBearerCredentialHeaders, O as createAnthropicInlineImageBudget, S as applyAnthropicFallbackBoundary, T as applyAnthropicRefusal, _ as ANTHROPIC_OMITTED_REASONING_TEXT, a as applyAnthropicMessageDeltaUsage, b as ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, d as normalizeAnthropicToolCallId, f as normalizeAnthropicToolChoice, g as toClaudeCodeToolName, h as resolveOriginalAnthropicToolName, i as suppressAnthropicCompaction, j as applyAnthropicCacheControlToMessages, k as normalizeAnthropicInlineContent, m as reconcileAnthropicToolChoice, n as createCompactionCapture, o as applyAnthropicMessageStartUsage, p as projectAnthropicTools, r as isAnthropicReplayRejection, t as buildAnthropicReplayPlan, v as findActiveAnthropicToolTurnAssistantIndex, w as resolveAnthropicFallbackServingModelCost, y as ANTHROPIC_SERVER_SIDE_FALLBACKS } from "./anthropic-compaction-replay-nhKaCXu6.mjs";
|
|
12
|
+
import { _ as transportAbortError, f as notifyProviderHttpResponse, s as finalizeTerminalToolCallArguments } from "./transport-stream-shared-ljShVIZB.mjs";
|
|
10
13
|
import { t as createDeferredEventBuffer } from "./deferred-event-buffer-DAvyP7qA.mjs";
|
|
11
|
-
import { n as parseStreamingJson, t as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./transport-utils-DJqkxbhC.mjs";
|
|
14
|
+
import { n as parseJsonWithRepair, r as parseStreamingJson, t as createToolArgumentPreviewSchedule } from "./json-parse-BuAJEbdW.mjs";
|
|
15
|
+
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
16
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-C01bQ5a3.mjs";
|
|
15
17
|
import { i as resolveCloudflareBaseUrl, n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-NCJtz9i0.mjs";
|
|
16
18
|
import Anthropic from "@anthropic-ai/sdk";
|
|
17
19
|
import { Stream } from "@anthropic-ai/sdk/core/streaming.js";
|
|
@@ -108,22 +110,20 @@ const ANTHROPIC_MESSAGE_EVENTS = /* @__PURE__ */ new Set([
|
|
|
108
110
|
]);
|
|
109
111
|
async function* iterateAnthropicEvents(response, requireMessageStop = false) {
|
|
110
112
|
if (!response.body) throw new Error("Attempted to iterate over an Anthropic response with no body");
|
|
111
|
-
let sawMessageStart = false;
|
|
112
113
|
let sawMessageEnd = false;
|
|
113
114
|
for await (const sse of Stream.rawEvents(response)) {
|
|
114
115
|
if (sse.event === "error") throw new Error(sse.data);
|
|
115
116
|
if (!ANTHROPIC_MESSAGE_EVENTS.has(sse.event ?? "")) continue;
|
|
116
117
|
try {
|
|
117
118
|
const event = parseJsonWithRepair(sse.data);
|
|
118
|
-
if (event.type === "
|
|
119
|
-
else if (event.type === "message_stop") sawMessageEnd = true;
|
|
119
|
+
if (event.type === "message_stop") sawMessageEnd = true;
|
|
120
120
|
yield event;
|
|
121
121
|
} catch (error) {
|
|
122
122
|
if (error instanceof SyntaxError) throw new Error(MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, { cause: error });
|
|
123
123
|
throw error;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
if (
|
|
126
|
+
if (requireMessageStop && !sawMessageEnd) throw new Error("Anthropic stream ended before message_stop");
|
|
127
127
|
}
|
|
128
128
|
const streamAnthropic = (model, context, options) => {
|
|
129
129
|
const stream = new AssistantMessageEventStream();
|
|
@@ -197,14 +197,18 @@ const streamAnthropic = (model, context, options) => {
|
|
|
197
197
|
...params,
|
|
198
198
|
stream: true
|
|
199
199
|
}, sdkRequestOptions).asResponse();
|
|
200
|
-
await
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
await notifyProviderHttpResponse({
|
|
201
|
+
options: requestOptions,
|
|
202
|
+
response,
|
|
203
|
+
model
|
|
204
|
+
});
|
|
204
205
|
const blocks = output.content;
|
|
205
206
|
const blockIndexes = /* @__PURE__ */ new Map();
|
|
207
|
+
const toolArgumentPreviewSchedules = /* @__PURE__ */ new WeakMap();
|
|
208
|
+
const sealedToolCalls = [];
|
|
206
209
|
const compactionCapture = createCompactionCapture(output, model, requestOptions);
|
|
207
|
-
|
|
210
|
+
const requireMessageStop = refusalBuffer !== void 0 || model.provider === "anthropic" && isAnthropicPublicEndpoint(model.baseUrl);
|
|
211
|
+
for await (const event of iterateAnthropicEvents(response, requireMessageStop)) if (event.type === "message_start") {
|
|
208
212
|
output.responseId = event.message.id;
|
|
209
213
|
output.responseModel = event.message.model;
|
|
210
214
|
messageStartPromptUsage = applyAnthropicMessageStartUsage(output.usage, event.message.usage);
|
|
@@ -214,11 +218,12 @@ const streamAnthropic = (model, context, options) => {
|
|
|
214
218
|
partial: output
|
|
215
219
|
});
|
|
216
220
|
} else if (event.type === "content_block_start") {
|
|
217
|
-
const rawContentBlock = event.content_block;
|
|
221
|
+
const rawContentBlock = isRecord(event.content_block) ? event.content_block : void 0;
|
|
218
222
|
if (requestOptions?.anthropicServerCompaction === true && compactionCapture.begin(event.index, rawContentBlock, output.content.length)) continue;
|
|
219
223
|
const fallbackBoundary = refusalBuffer ? readAnthropicFallbackBoundary(event.content_block) : null;
|
|
220
224
|
if (fallbackBoundary) {
|
|
221
225
|
refusalBuffer?.discard();
|
|
226
|
+
sealedToolCalls.length = 0;
|
|
222
227
|
blockIndexes.clear();
|
|
223
228
|
applyAnthropicFallbackBoundary({
|
|
224
229
|
output,
|
|
@@ -312,6 +317,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
312
317
|
};
|
|
313
318
|
output.content.push(block);
|
|
314
319
|
blockIndexes.set(event.index, output.content.length - 1);
|
|
320
|
+
toolArgumentPreviewSchedules.set(block, createToolArgumentPreviewSchedule());
|
|
315
321
|
eventSink.push({
|
|
316
322
|
type: "toolcall_start",
|
|
317
323
|
contentIndex: output.content.length - 1,
|
|
@@ -319,7 +325,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
319
325
|
});
|
|
320
326
|
}
|
|
321
327
|
} else if (event.type === "content_block_delta") {
|
|
322
|
-
const rawDelta = event.delta;
|
|
328
|
+
const rawDelta = isRecord(event.delta) ? event.delta : void 0;
|
|
323
329
|
if (compactionCapture.delta(event.index, rawDelta)) continue;
|
|
324
330
|
else if (event.delta.type === "text_delta") {
|
|
325
331
|
const index = blockIndexes.get(event.index);
|
|
@@ -349,8 +355,8 @@ const streamAnthropic = (model, context, options) => {
|
|
|
349
355
|
const index = blockIndexes.get(event.index);
|
|
350
356
|
const block = index === void 0 ? void 0 : blocks[index];
|
|
351
357
|
if (index !== void 0 && block?.type === "toolCall") {
|
|
352
|
-
block.partialJson
|
|
353
|
-
block.arguments = parseStreamingJson(block.partialJson);
|
|
358
|
+
block.partialJson = (block.partialJson ?? "") + event.delta.partial_json;
|
|
359
|
+
if (toolArgumentPreviewSchedules.get(block)?.(block.partialJson.length)) block.arguments = parseStreamingJson(block.partialJson);
|
|
354
360
|
eventSink.push({
|
|
355
361
|
type: "toolcall_delta",
|
|
356
362
|
contentIndex: index,
|
|
@@ -385,16 +391,10 @@ const streamAnthropic = (model, context, options) => {
|
|
|
385
391
|
content: block.thinking,
|
|
386
392
|
partial: output
|
|
387
393
|
});
|
|
388
|
-
else if (block.type === "toolCall") {
|
|
389
|
-
block
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
type: "toolcall_end",
|
|
393
|
-
contentIndex: index,
|
|
394
|
-
toolCall: block,
|
|
395
|
-
partial: output
|
|
396
|
-
});
|
|
397
|
-
}
|
|
394
|
+
else if (block.type === "toolCall") sealedToolCalls.push({
|
|
395
|
+
block,
|
|
396
|
+
contentIndex: index
|
|
397
|
+
});
|
|
398
398
|
}
|
|
399
399
|
} else if (event.type === "message_delta") {
|
|
400
400
|
if (event.delta.stop_reason) if (event.delta.stop_reason === "refusal") applyAnthropicRefusal(output, event.delta.stop_details, model.provider);
|
|
@@ -404,6 +404,17 @@ const streamAnthropic = (model, context, options) => {
|
|
|
404
404
|
}
|
|
405
405
|
if (requestOptions?.signal?.aborted) throw transportAbortError(requestOptions.signal);
|
|
406
406
|
if (output.stopReason === "aborted" || output.stopReason === "error") throw new Error(output.errorMessage ?? "An unknown error occurred");
|
|
407
|
+
if ([...blockIndexes.values()].some((index) => blocks[index]?.type === "toolCall")) throw new Error("Provider completed stream with an incomplete tool call");
|
|
408
|
+
finalizeTerminalToolCallArguments(sealedToolCalls.map(({ block }) => block), (block) => block.partialJson && block.partialJson.length > 0 ? block.partialJson : block.arguments);
|
|
409
|
+
for (const sealed of sealedToolCalls) {
|
|
410
|
+
delete sealed.block.partialJson;
|
|
411
|
+
eventSink.push({
|
|
412
|
+
type: "toolcall_end",
|
|
413
|
+
contentIndex: sealed.contentIndex,
|
|
414
|
+
toolCall: sealed.block,
|
|
415
|
+
partial: output
|
|
416
|
+
});
|
|
417
|
+
}
|
|
407
418
|
refusalBuffer?.flush();
|
|
408
419
|
stream.push({
|
|
409
420
|
type: "done",
|
|
@@ -412,6 +423,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
412
423
|
});
|
|
413
424
|
stream.end();
|
|
414
425
|
} catch (error) {
|
|
426
|
+
output.content = output.content.filter((block) => block.type !== "toolCall");
|
|
415
427
|
for (const block of output.content) {
|
|
416
428
|
delete block.index;
|
|
417
429
|
delete block.partialJson;
|
|
@@ -646,7 +658,7 @@ async function buildParams(model, context, isOAuthTokenResult, options, serverSi
|
|
|
646
658
|
display
|
|
647
659
|
};
|
|
648
660
|
const effort = options?.effort ?? (mandatoryAdaptiveThinking ? "high" : void 0);
|
|
649
|
-
if (effort) params.output_config =
|
|
661
|
+
if (effort) params.output_config = { effort };
|
|
650
662
|
} else params.thinking = {
|
|
651
663
|
type: "enabled",
|
|
652
664
|
budget_tokens: options?.thinkingBudgetTokens ?? ANTHROPIC_MIN_THINKING_BUDGET_TOKENS,
|
package/dist/{anthropic-compaction-replay-8lJNKXOE.mjs → anthropic-compaction-replay-nhKaCXu6.mjs}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { o as resolveClaudeFable5ModelIdentity, s as resolveClaudeModelIdentity, u as resolveClaudeOpus5ModelIdentity } from "./
|
|
2
|
-
import {
|
|
3
|
-
import { n as getAiTransportHost } from "./host-
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
6
|
-
import { r as asNonNegativeFiniteNumber, s as parseStrictPositiveInteger } from "./number-coercion-H9qHik3g.mjs";
|
|
1
|
+
import { o as resolveClaudeFable5ModelIdentity, s as resolveClaudeModelIdentity, u as resolveClaudeOpus5ModelIdentity } from "./src-Bu3FiFAG.mjs";
|
|
2
|
+
import { l as normalizeNullableString, o as isRecord, u as normalizeOptionalLowercaseString } from "./utf16-slice-qz3nsy87.mjs";
|
|
3
|
+
import { n as getAiTransportHost } from "./host-D51fmkH6.mjs";
|
|
4
|
+
import { a as estimateBase64DecodedBytes } from "./provider-error-DDOs_Bz0.mjs";
|
|
5
|
+
import { r as asNonNegativeFiniteNumber } from "./number-coercion-H9qHik3g.mjs";
|
|
7
6
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
8
|
-
import { c as splitSystemPromptCacheBoundary, f as sortPromptCacheToolsByName, l as stripSystemPromptCacheBoundary } from "./simple-options-
|
|
9
|
-
import { a as resolveProviderEndpoint, o as resolveProviderRequestCapabilities, t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-
|
|
7
|
+
import { c as splitSystemPromptCacheBoundary, f as sortPromptCacheToolsByName, l as stripSystemPromptCacheBoundary } from "./simple-options-CFj7x3J4.mjs";
|
|
8
|
+
import { a as resolveProviderEndpoint, o as resolveProviderRequestCapabilities, t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-qvTEs5Am.mjs";
|
|
9
|
+
import { s as parsePositiveInteger } from "./transport-utils-LJ1_rbi-.mjs";
|
|
10
10
|
import { t as shortHash } from "./hash-CHgqbJmD.mjs";
|
|
11
11
|
//#region packages/ai/src/transports/anthropic-payload-policy.ts
|
|
12
12
|
/**
|
|
@@ -16,10 +16,6 @@ import { t as shortHash } from "./hash-CHgqbJmD.mjs";
|
|
|
16
16
|
*/
|
|
17
17
|
const ANTHROPIC_CACHE_CONTROL_LIMIT = 4;
|
|
18
18
|
const ANTHROPIC_COMPACT_THRESHOLD_MIN = 5e4;
|
|
19
|
-
function parsePositiveInteger(value) {
|
|
20
|
-
if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value);
|
|
21
|
-
return typeof value === "string" ? parseStrictPositiveInteger(value) : void 0;
|
|
22
|
-
}
|
|
23
19
|
/** Resolve the Anthropic input-token trigger, including the API's minimum. */
|
|
24
20
|
function resolveAnthropicCompactThreshold(contextWindow, configured) {
|
|
25
21
|
const configuredThreshold = parsePositiveInteger(configured);
|
|
@@ -31,7 +27,7 @@ function resolveAnthropicCompactThreshold(contextWindow, configured) {
|
|
|
31
27
|
function resolveAnthropicServerCompactionPlan(model, extraParams) {
|
|
32
28
|
const provider = normalizeOptionalLowercaseString(model.provider);
|
|
33
29
|
const api = normalizeOptionalLowercaseString(model.api);
|
|
34
|
-
const endpointClass = resolveProviderEndpoint(model
|
|
30
|
+
const endpointClass = resolveProviderEndpoint(model).endpointClass;
|
|
35
31
|
const enabled = extraParams?.anthropicServerCompaction === true && provider === "anthropic" && api === "anthropic-messages" && (endpointClass === "default" || endpointClass === "anthropic-public");
|
|
36
32
|
return {
|
|
37
33
|
enabled,
|
|
@@ -150,14 +146,14 @@ function countAnthropicCacheControlMarkers(blocks) {
|
|
|
150
146
|
return count;
|
|
151
147
|
}
|
|
152
148
|
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
153
|
-
function resolveAnthropicPayloadPolicy(input) {
|
|
149
|
+
function resolveAnthropicPayloadPolicy(input, model) {
|
|
154
150
|
const capabilities = resolveProviderRequestCapabilities({
|
|
155
151
|
provider: input.provider,
|
|
156
152
|
api: input.api,
|
|
157
153
|
baseUrl: input.baseUrl,
|
|
158
154
|
capability: "llm",
|
|
159
155
|
transport: "stream"
|
|
160
|
-
});
|
|
156
|
+
}, model);
|
|
161
157
|
const serverCompactionPlan = resolveAnthropicServerCompactionPlan(input, input.extraParams);
|
|
162
158
|
return {
|
|
163
159
|
allowsServiceTier: capabilities.allowsAnthropicServiceTier,
|
|
@@ -752,14 +748,13 @@ function buildAnthropicReplayContext(model, options) {
|
|
|
752
748
|
authProfileHash: hashReplayValue(options?.authProfileId)
|
|
753
749
|
};
|
|
754
750
|
}
|
|
751
|
+
function isAnthropicCompactionState(state) {
|
|
752
|
+
if (state.v !== 1 || typeof state.data !== "string" || typeof state.provider !== "string" || typeof state.api !== "string" || typeof state.model !== "string" || typeof state.baseUrlHash !== "string" || state.sessionHash !== void 0 && typeof state.sessionHash !== "string" || state.authProfileHash !== void 0 && typeof state.authProfileHash !== "string") return false;
|
|
753
|
+
if (state.type === ANTHROPIC_COMPACTION_SUPPRESSION_TYPE) return state.data === ANTHROPIC_COMPACTION_SUPPRESSION_DATA;
|
|
754
|
+
return state.type === ANTHROPIC_COMPACTION_REPLAY_TYPE && state.data.length > 0 && (state.replayIndex === void 0 || typeof state.replayIndex === "number" && Number.isSafeInteger(state.replayIndex) && state.replayIndex >= 0);
|
|
755
|
+
}
|
|
755
756
|
function readAnthropicCompactionState(value) {
|
|
756
|
-
|
|
757
|
-
const state = value;
|
|
758
|
-
if (!(state.v === 1 && typeof state.data === "string" && typeof state.provider === "string" && typeof state.api === "string" && typeof state.model === "string" && typeof state.baseUrlHash === "string" && (state.sessionHash === void 0 || typeof state.sessionHash === "string") && (state.authProfileHash === void 0 || typeof state.authProfileHash === "string"))) return;
|
|
759
|
-
const replayState = state;
|
|
760
|
-
if (replayState.type === ANTHROPIC_COMPACTION_SUPPRESSION_TYPE) return replayState.data === ANTHROPIC_COMPACTION_SUPPRESSION_DATA ? replayState : void 0;
|
|
761
|
-
if (replayState.type !== ANTHROPIC_COMPACTION_REPLAY_TYPE || replayState.data.length === 0 || replayState.replayIndex !== void 0 && (!Number.isSafeInteger(replayState.replayIndex) || replayState.replayIndex < 0)) return;
|
|
762
|
-
return replayState;
|
|
757
|
+
return isRecord(value) && isAnthropicCompactionState(value) ? value : void 0;
|
|
763
758
|
}
|
|
764
759
|
function replayContextMatches(state, context) {
|
|
765
760
|
return state.provider === context.provider && state.api === context.api && state.model === context.model && state.baseUrlHash === context.baseUrlHash && state.sessionHash === context.sessionHash && state.authProfileHash === context.authProfileHash;
|
package/dist/{anthropic-payload-policy-CiEuQS72.d.mts → anthropic-payload-policy-B_0n0enE.d.mts}
RENAMED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { D as Model } from "./types-DhLoJbFm.mjs";
|
|
2
|
+
import "./index-Qbej8io0.mjs";
|
|
1
3
|
//#region packages/ai/src/transports/anthropic-payload-policy.d.ts
|
|
2
4
|
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
3
5
|
type AnthropicServiceTier = "auto" | "standard_only";
|
|
@@ -40,7 +42,7 @@ declare function resolveAnthropicEphemeralCacheControl(baseUrl: string | undefin
|
|
|
40
42
|
/** Apply one shared deepest-stable-message cache breakpoint policy. */
|
|
41
43
|
declare function applyAnthropicCacheControlToMessages(messages: unknown, cacheControl: AnthropicEphemeralCacheControl, markerLimit: number, cacheBreakpointOptOutMessageIndexes: ReadonlySet<number>): void;
|
|
42
44
|
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
43
|
-
declare function resolveAnthropicPayloadPolicy(input: AnthropicPayloadPolicyInput): AnthropicPayloadPolicy;
|
|
45
|
+
declare function resolveAnthropicPayloadPolicy(input: AnthropicPayloadPolicyInput, model?: Model): AnthropicPayloadPolicy;
|
|
44
46
|
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
45
47
|
declare function applyAnthropicPayloadPolicyToParams(payloadObj: Record<string, unknown>, policy: AnthropicPayloadPolicy, cacheBreakpointOptOutMessageIndexes: ReadonlySet<number>): void;
|
|
46
48
|
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as Model, H as StreamFunction, U as StreamOptions, d as Context, n as Api, s as AssistantMessageEventStreamContract, z as SimpleStreamOptions } from "./types-DhLoJbFm.mjs";
|
|
2
|
+
import "./index-Qbej8io0.mjs";
|
|
2
3
|
//#region packages/ai/src/api-registry.d.ts
|
|
3
4
|
/** Runtime stream adapter signature stored in the API provider registry. */
|
|
4
5
|
type ApiStreamFunction = (model: Model, context: Context, options?: StreamOptions) => AssistantMessageEventStreamContract;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as getEnvApiKey } from "./env-api-keys-DrgeBuva.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
3
|
-
import { n as getAiTransportHost } from "./host-
|
|
3
|
+
import { n as getAiTransportHost } from "./host-D51fmkH6.mjs";
|
|
4
4
|
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
5
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
6
|
-
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, o as runResponsesStreamLifecycle, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-
|
|
5
|
+
import { n as buildBaseOptions } from "./simple-options-CFj7x3J4.mjs";
|
|
6
|
+
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, o as runResponsesStreamLifecycle, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-DJThc6jW.mjs";
|
|
7
7
|
import { i as resolveAzureDeploymentNameFromMap, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-C7K7QfUE.mjs";
|
|
8
8
|
import OpenAI, { AzureOpenAI } from "openai";
|
|
9
9
|
//#region packages/ai/src/providers/azure-openai-responses.ts
|
package/dist/diagnostics.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { a as extractDiagnosticError, i as createAssistantMessageDiagnostic, n as DiagnosticErrorInfo, o as formatThrownValue, r as appendAssistantMessageDiagnostic, t as AssistantMessageDiagnostic } from "./diagnostics-BaTA9eVl.mjs";
|
|
2
2
|
import { n as ProviderErrorRedactor, r as configureProviderErrorRedactor } from "./provider-error-CzNw4BWX.mjs";
|
|
3
|
-
|
|
4
3
|
//#region packages/ai/src/utils/credential-redaction.d.ts
|
|
5
4
|
type DiagnosticMediaField = {
|
|
6
5
|
kind: "context";
|
package/dist/diagnostics.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { i as formatThrownValue, n as createAssistantMessageDiagnostic, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-COpOtRwq.mjs";
|
|
2
|
-
import { r as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-
|
|
2
|
+
import { r as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-DDOs_Bz0.mjs";
|
|
3
3
|
export { appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, extractDiagnosticError, formatThrownValue, projectDiagnosticValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./event-stream-LiXePESD.mjs";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
|
|
1
|
+
import { a as AssistantMessage, o as AssistantMessageEvent, s as AssistantMessageEventStreamContract } from "./types-DhLoJbFm.mjs";
|
|
3
2
|
//#region packages/llm-core/src/utils/event-stream.d.ts
|
|
4
3
|
/** Generic async-iterable event stream with a separately awaited final result. */
|
|
5
4
|
declare class EventStream<T, R = T> implements AsyncIterable<T> {
|
package/dist/event-stream.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
1
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-LiXePESD.mjs";
|
|
2
|
+
import "./event-stream-BKp4fOt_.mjs";
|
|
2
3
|
export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as getEnvApiKey } from "./env-api-keys-DrgeBuva.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
3
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-
|
|
4
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
5
|
-
import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-
|
|
3
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-D51fmkH6.mjs";
|
|
4
|
+
import { n as buildBaseOptions } from "./simple-options-CFj7x3J4.mjs";
|
|
5
|
+
import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-Bgr9lFPw.mjs";
|
|
6
6
|
import { GoogleGenAI } from "@google/genai";
|
|
7
7
|
//#region packages/ai/src/providers/google.ts
|
|
8
8
|
let toolCallCounter = 0;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { i as clampThinkingLevel, r as calculateCost, t as sanitizeSurrogates } from "./sanitize-unicode-
|
|
2
|
-
import { a as describeToolResultMediaPlaceholder,
|
|
3
|
-
import { f as sortPromptCacheToolsByName, l as stripSystemPromptCacheBoundary } from "./simple-options-
|
|
4
|
-
import {
|
|
1
|
+
import { i as clampThinkingLevel, r as calculateCost, t as sanitizeSurrogates } from "./sanitize-unicode-DCkltN94.mjs";
|
|
2
|
+
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload } from "./host-D51fmkH6.mjs";
|
|
3
|
+
import { f as sortPromptCacheToolsByName, l as stripSystemPromptCacheBoundary } from "./simple-options-CFj7x3J4.mjs";
|
|
4
|
+
import { _ as transportAbortError, n as coerceTransportToolCallArguments, p as notifyProviderStreamOpened, t as assignTransportErrorDetails } from "./transport-stream-shared-ljShVIZB.mjs";
|
|
5
5
|
import { t as googleFlashSupportsMinimalThinking } from "./google-thinking-level-C-V3tecN.mjs";
|
|
6
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-C01bQ5a3.mjs";
|
|
6
7
|
import { FinishReason, FunctionCallingConfigMode, ThinkingLevel } from "@google/genai";
|
|
7
8
|
//#region packages/ai/src/providers/google-shared.ts
|
|
8
9
|
/**
|
|
9
10
|
* Shared utilities for Google Generative AI and Google Vertex providers.
|
|
10
11
|
*/
|
|
12
|
+
const GOOGLE_MODEL_RESOURCE_PREFIX = /^(?:(?:projects\/[^/]+\/locations\/[^/]+\/)?publishers\/google\/models\/|google\/|models\/)/u;
|
|
11
13
|
/**
|
|
12
14
|
* Determines whether a streamed Gemini `Part` should be treated as "thinking".
|
|
13
15
|
*
|
|
@@ -83,6 +85,7 @@ function convertMessages(model, context) {
|
|
|
83
85
|
const transformedMessages = transformProviderMessages(context.messages, model, normalizeToolCallId);
|
|
84
86
|
const requiresToolCallThoughtSignature = model.provider !== "google-gemini-cli" && (isGemini3ProModel(model) || isGemini3FlashModel(model));
|
|
85
87
|
const pendingToolResultImageTurns = [];
|
|
88
|
+
const sameRouteToolCallIds = /* @__PURE__ */ new Set();
|
|
86
89
|
let activeToolResultParts;
|
|
87
90
|
const flushToolResultRun = () => {
|
|
88
91
|
contents.push(...pendingToolResultImageTurns);
|
|
@@ -130,6 +133,7 @@ function convertMessages(model, context) {
|
|
|
130
133
|
});
|
|
131
134
|
else parts.push({ text: sanitizeSurrogates(block.thinking) });
|
|
132
135
|
} else if (block.type === "toolCall") {
|
|
136
|
+
if (isSameProviderAndModel && model.provider !== "google-gemini-cli") sameRouteToolCallIds.add(block.id);
|
|
133
137
|
const args = coerceTransportToolCallArguments(block.arguments);
|
|
134
138
|
const thoughtSignature = resolveThoughtSignature(isSameProviderAndModel, block.thoughtSignature) ?? (!sawFunctionCall && requiresToolCallThoughtSignature ? "skip_thought_signature_validator" : void 0);
|
|
135
139
|
sawFunctionCall = true;
|
|
@@ -137,7 +141,7 @@ function convertMessages(model, context) {
|
|
|
137
141
|
functionCall: {
|
|
138
142
|
name: block.name,
|
|
139
143
|
args,
|
|
140
|
-
...requiresToolCallId(model.id) ? { id: block.id } : {}
|
|
144
|
+
...sameRouteToolCallIds.has(block.id) || requiresToolCallId(model.id) ? { id: block.id } : {}
|
|
141
145
|
},
|
|
142
146
|
...thoughtSignature && { thoughtSignature }
|
|
143
147
|
};
|
|
@@ -160,7 +164,7 @@ function convertMessages(model, context) {
|
|
|
160
164
|
mimeType: imageBlock.mimeType,
|
|
161
165
|
data: imageBlock.data
|
|
162
166
|
} }));
|
|
163
|
-
const includeId = requiresToolCallId(model.id);
|
|
167
|
+
const includeId = sameRouteToolCallIds.has(msg.toolCallId) || requiresToolCallId(model.id);
|
|
164
168
|
const functionResponsePart = { functionResponse: {
|
|
165
169
|
name: msg.toolName,
|
|
166
170
|
response: msg.isError ? { error: responseValue } : { output: responseValue },
|
|
@@ -244,8 +248,15 @@ async function runGoogleGenerateContentLifecycle(params) {
|
|
|
244
248
|
let requestParams = params.buildParams();
|
|
245
249
|
const nextParams = await options?.onPayload?.(requestParams, model);
|
|
246
250
|
if (nextParams !== void 0) requestParams = nextParams;
|
|
251
|
+
const googleIterator = (await client.models.generateContentStream(requestParams))[Symbol.asyncIterator]();
|
|
252
|
+
await notifyProviderStreamOpened({
|
|
253
|
+
options,
|
|
254
|
+
cancelStream: async () => {
|
|
255
|
+
await googleIterator.return?.();
|
|
256
|
+
}
|
|
257
|
+
});
|
|
247
258
|
await consumeGoogleGenerateContentStream({
|
|
248
|
-
chunks:
|
|
259
|
+
chunks: { [Symbol.asyncIterator]: () => googleIterator },
|
|
249
260
|
model,
|
|
250
261
|
output,
|
|
251
262
|
stream,
|
|
@@ -403,6 +414,7 @@ function mapStopReason(reason) {
|
|
|
403
414
|
case FinishReason.OTHER:
|
|
404
415
|
case FinishReason.LANGUAGE:
|
|
405
416
|
case FinishReason.MALFORMED_FUNCTION_CALL:
|
|
417
|
+
case FinishReason.TOO_MANY_TOOL_CALLS:
|
|
406
418
|
case FinishReason.UNEXPECTED_TOOL_CALL:
|
|
407
419
|
case FinishReason.NO_IMAGE: return "error";
|
|
408
420
|
default: throw new Error(`Unhandled stop reason: ${String(reason)}`);
|
|
@@ -446,6 +458,8 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
446
458
|
};
|
|
447
459
|
for await (const chunk of params.chunks) {
|
|
448
460
|
params.output.responseId ||= chunk.responseId;
|
|
461
|
+
const responseModel = chunk.modelVersion?.trim();
|
|
462
|
+
if (responseModel && params.model.id.replace(GOOGLE_MODEL_RESOURCE_PREFIX, "") !== responseModel.replace(GOOGLE_MODEL_RESOURCE_PREFIX, "")) params.output.responseModel ||= responseModel;
|
|
449
463
|
if (chunk.usageMetadata) {
|
|
450
464
|
for (const field of Object.keys(knownUsage)) {
|
|
451
465
|
const value = chunk.usageMetadata[field];
|
|
@@ -581,7 +595,7 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
581
595
|
});
|
|
582
596
|
}
|
|
583
597
|
}
|
|
584
|
-
if (candidate?.finishReason) {
|
|
598
|
+
if (candidate?.finishReason && candidate.finishReason !== FinishReason.FINISH_REASON_UNSPECIFIED) {
|
|
585
599
|
sawTerminalReason = true;
|
|
586
600
|
params.output.stopReason = mapStopReason(candidate.finishReason);
|
|
587
601
|
if (params.output.stopReason === "error") {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-
|
|
4
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
5
|
-
import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-
|
|
2
|
+
import { d as normalizeOptionalString } from "./utf16-slice-qz3nsy87.mjs";
|
|
3
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-D51fmkH6.mjs";
|
|
4
|
+
import { n as buildBaseOptions } from "./simple-options-CFj7x3J4.mjs";
|
|
5
|
+
import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-Bgr9lFPw.mjs";
|
|
6
6
|
import { GoogleGenAI, ResourceScope } from "@google/genai";
|
|
7
7
|
//#region packages/ai/src/providers/google-vertex.ts
|
|
8
8
|
const API_VERSION = "v1";
|
|
@@ -1,9 +1,6 @@
|
|
|
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 "./
|
|
2
|
-
import "./
|
|
3
|
-
import {
|
|
4
|
-
import { i as clampThinkingLevel, t as sanitizeSurrogates } from "./sanitize-unicode-BYqrYtC_.mjs";
|
|
5
|
-
import { a as isRecord } from "./record-coerce-DdXsgUd_.mjs";
|
|
6
|
-
import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
|
|
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 "./src-Bu3FiFAG.mjs";
|
|
2
|
+
import { c as normalizeLowercaseStringOrEmpty, o as isRecord, t as truncateUtf16Safe } from "./utf16-slice-qz3nsy87.mjs";
|
|
3
|
+
import { i as clampThinkingLevel, t as sanitizeSurrogates } from "./sanitize-unicode-DCkltN94.mjs";
|
|
7
4
|
//#region packages/ai/src/providers/anthropic-model-contract.ts
|
|
8
5
|
const ANTHROPIC_CLAUDE_CODE_VERSION = "2.1.75";
|
|
9
6
|
const ANTHROPIC_CLAUDE_CODE_BILLING_SYSTEM_BLOCK = `x-anthropic-billing-header: cc_version=${ANTHROPIC_CLAUDE_CODE_VERSION}; cc_entrypoint=sdk-cli;`;
|
|
@@ -163,22 +160,11 @@ function describeOmittedValue(value, label) {
|
|
|
163
160
|
function redactInlineDataUris(value) {
|
|
164
161
|
return value.replace(INLINE_DATA_URI_PATTERN, (_match, prefix, uri) => `${prefix}[inline data URI: ${uri.length} chars]`);
|
|
165
162
|
}
|
|
166
|
-
function redactStructuredTextValue(value) {
|
|
167
|
-
const host = getAiTransportHost();
|
|
168
|
-
const redacted = host.redactToolPayloadText(value);
|
|
169
|
-
const trimmed = redacted.trim();
|
|
170
|
-
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return redacted;
|
|
171
|
-
try {
|
|
172
|
-
const redactedWrapper = host.redactSecrets({ structuredTextValue: JSON.parse(redacted) });
|
|
173
|
-
return JSON.stringify(redactedWrapper.structuredTextValue);
|
|
174
|
-
} catch {
|
|
175
|
-
return redacted;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
163
|
function stringifyStructuredBlock(block) {
|
|
179
164
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
180
165
|
try {
|
|
181
|
-
const
|
|
166
|
+
const host = getAiTransportHost();
|
|
167
|
+
const redactedBlock = host.redactModelVisibleSecrets({ structuredToolResult: block }).structuredToolResult;
|
|
182
168
|
const serialized = JSON.stringify(redactedBlock, function structuredToolResultReplacer(key, value) {
|
|
183
169
|
if (OPAQUE_OR_BINARY_FIELD_RE.test(key)) return `[omitted ${key}]`;
|
|
184
170
|
if (key === "data") {
|
|
@@ -186,7 +172,7 @@ function stringifyStructuredBlock(block) {
|
|
|
186
172
|
if (mimeType && isBinaryMimeType(mimeType)) return describeOmittedValue(value, "binary data");
|
|
187
173
|
}
|
|
188
174
|
if (typeof value === "bigint") return value.toString();
|
|
189
|
-
if (typeof value === "string") return redactInlineDataUris(
|
|
175
|
+
if (typeof value === "string") return redactInlineDataUris(host.redactModelVisibleSecrets(value));
|
|
190
176
|
if (typeof value === "function" || typeof value === "symbol" || value === void 0) return;
|
|
191
177
|
if (!value || typeof value !== "object") return value;
|
|
192
178
|
if (seen.has(value)) return "[Circular]";
|
|
@@ -211,20 +197,26 @@ function hasMediaPayload(block) {
|
|
|
211
197
|
function isImageWithMediaPayload(block) {
|
|
212
198
|
return isRecord(block) && block.type === "image" && hasMediaPayload(block);
|
|
213
199
|
}
|
|
214
|
-
function
|
|
200
|
+
function classifyToolResultMedia(blocks) {
|
|
215
201
|
let hasImage = false;
|
|
216
202
|
let hasAudio = false;
|
|
217
203
|
for (const block of blocks) {
|
|
218
|
-
if (!hasMediaPayload(block)) continue;
|
|
219
|
-
const
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (type && AUDIO_TOOL_RESULT_TYPES.has(type) || mimeType?.toLowerCase().startsWith("audio/")) hasAudio = true;
|
|
204
|
+
if (!hasMediaPayload(block) || block.type === "text") continue;
|
|
205
|
+
const type = typeof block.type === "string" ? block.type : void 0;
|
|
206
|
+
const mimeType = readMimeType(block)?.toLowerCase();
|
|
207
|
+
hasImage ||= Boolean(type && IMAGE_TOOL_RESULT_TYPES.has(type) || mimeType?.startsWith("image/"));
|
|
208
|
+
hasAudio ||= Boolean(type && AUDIO_TOOL_RESULT_TYPES.has(type) || mimeType?.startsWith("audio/"));
|
|
224
209
|
}
|
|
210
|
+
return {
|
|
211
|
+
hasImage,
|
|
212
|
+
hasAudio
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function describeToolResultMediaPlaceholder(blocks) {
|
|
216
|
+
const { hasImage, hasAudio } = classifyToolResultMedia(blocks);
|
|
225
217
|
if (hasImage && hasAudio) return "(see attached media)";
|
|
226
218
|
if (hasAudio) return "(see attached audio)";
|
|
227
|
-
|
|
219
|
+
return hasImage ? "(see attached image)" : void 0;
|
|
228
220
|
}
|
|
229
221
|
function extractToolResultBlockText(block) {
|
|
230
222
|
if (!block || typeof block !== "object") return;
|
|
@@ -237,7 +229,7 @@ function extractToolResultBlockText(block) {
|
|
|
237
229
|
const structured = stringifyStructuredBlock(record);
|
|
238
230
|
return structured ? sanitizeSurrogates(truncateProviderToolText(structured)) : void 0;
|
|
239
231
|
}
|
|
240
|
-
function extractToolResultText(blocks) {
|
|
232
|
+
function extractToolResultText(blocks, options) {
|
|
241
233
|
const explicitTexts = [];
|
|
242
234
|
const structuredTexts = [];
|
|
243
235
|
for (const block of blocks) {
|
|
@@ -246,9 +238,25 @@ function extractToolResultText(blocks) {
|
|
|
246
238
|
if (block.type === "text") explicitTexts.push(text);
|
|
247
239
|
else structuredTexts.push(text);
|
|
248
240
|
}
|
|
249
|
-
if (explicitTexts.length > 0)
|
|
241
|
+
if (explicitTexts.length > 0) {
|
|
242
|
+
const text = (options?.includeStructured ? [...explicitTexts, ...structuredTexts] : explicitTexts).join("\n");
|
|
243
|
+
return sanitizeSurrogates(options?.includeStructured ? truncateProviderToolText(text) : text);
|
|
244
|
+
}
|
|
250
245
|
return sanitizeSurrogates(truncateProviderToolText(structuredTexts.join("\n")));
|
|
251
246
|
}
|
|
247
|
+
/** Describe media that cannot be represented on the target provider wire. */
|
|
248
|
+
function describeUnsupportedToolResultMedia(blocks, support) {
|
|
249
|
+
const { hasImage, hasAudio } = classifyToolResultMedia(blocks);
|
|
250
|
+
const omittedImage = hasImage && !support.images;
|
|
251
|
+
const omittedAudio = hasAudio && !support.audio;
|
|
252
|
+
if (omittedImage && omittedAudio) return "[unsupported tool-result media omitted]";
|
|
253
|
+
if (omittedAudio) return "[unsupported tool-result audio omitted]";
|
|
254
|
+
return omittedImage ? "[unsupported tool-result image omitted]" : void 0;
|
|
255
|
+
}
|
|
256
|
+
function formatToolResultText(params) {
|
|
257
|
+
const body = params.text.trim() ? `${params.text}${params.omittedMediaPlaceholder ? `\n${params.omittedMediaPlaceholder}` : ""}` : params.omittedMediaPlaceholder ?? params.mediaPlaceholder ?? "(no tool output)";
|
|
258
|
+
return `${params.isError ? "[tool error] " : ""}${body}`;
|
|
259
|
+
}
|
|
252
260
|
//#endregion
|
|
253
261
|
//#region packages/ai/src/transcript-transform.ts
|
|
254
262
|
const NON_VISION_USER_IMAGE_PLACEHOLDER = "(image omitted: model does not support images)";
|
|
@@ -386,7 +394,7 @@ function queueCustomApiRegistration(registry, api, streamFn) {
|
|
|
386
394
|
const inertAiTransportHost = {
|
|
387
395
|
buildModelFetch: () => void 0,
|
|
388
396
|
resolveSecretSentinel: (value) => value,
|
|
389
|
-
|
|
397
|
+
redactModelVisibleSecrets: (value) => value,
|
|
390
398
|
redactToolPayloadText: (text) => text,
|
|
391
399
|
normalizeAnthropicInlineContentBlocks: async (content) => [...content],
|
|
392
400
|
resolveOpenAIStrictToolSetting: (_model, options) => options?.supportsStrictMode ? false : void 0,
|
|
@@ -399,7 +407,6 @@ const inertAiTransportHost = {
|
|
|
399
407
|
}
|
|
400
408
|
},
|
|
401
409
|
buildCopilotDynamicHeaders: () => ({}),
|
|
402
|
-
resolveProviderEndpointClass: () => "default",
|
|
403
410
|
resolveProviderRequestCapabilities: () => ({
|
|
404
411
|
endpointClass: "default",
|
|
405
412
|
knownProviderFamily: "",
|
|
@@ -463,4 +470,4 @@ function resolveAiTransportHeaderSentinels(headers) {
|
|
|
463
470
|
return resolvedHeaders ?? headers;
|
|
464
471
|
}
|
|
465
472
|
//#endregion
|
|
466
|
-
export {
|
|
473
|
+
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 };
|