@openclaw/ai 2026.8.1-beta.3 → 2026.8.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-B8KwTtlb.mjs → anthropic-Djj7L1rx.mjs} +21 -21
- package/dist/{anthropic-compaction-replay-4Zx7-aCr.mjs → anthropic-compaction-replay-CY4tkD4V.mjs} +33 -34
- package/dist/{anthropic-payload-policy-CSx7MoKH.d.mts → anthropic-payload-policy-i_5_inWe.d.mts} +3 -2
- package/dist/{api-registry-DFxSnFqG.d.mts → api-registry-C9-wZd_W.d.mts} +2 -1
- package/dist/{azure-openai-responses-Aa4mVcYG.mjs → azure-openai-responses-Bj3czHNa.mjs} +4 -4
- package/dist/{number-coercion-H9qHik3g.mjs → base64-CEFBpSkN.mjs} +73 -1
- package/dist/diagnostics.d.mts +2 -3
- package/dist/diagnostics.mjs +1 -1
- package/dist/{env-api-keys-DrgeBuva.mjs → env-api-keys-bktO00EJ.mjs} +2 -15
- package/dist/event-stream-C988TSLe.d.mts +1 -0
- package/dist/{event-stream-D91-ohD_.d.mts → event-stream-UhnxHuqt.d.mts} +1 -2
- package/dist/event-stream.d.mts +2 -1
- package/dist/{google-yDRnipeq.mjs → google-0Ca6TYbw.mjs} +4 -4
- package/dist/{google-shared-M1dl64nz.mjs → google-shared-DVfL9COU.mjs} +14 -7
- package/dist/{google-vertex-DCJHM_a5.mjs → google-vertex-5dAMxprN.mjs} +4 -4
- package/dist/{host-DF_yxOsA.mjs → host-D51fmkH6.mjs} +4 -8
- package/dist/{host-DJq_FGcz.d.mts → host-DoPJJ1KD.d.mts} +3 -3
- package/dist/index-N3zr6__t.d.mts +105 -0
- package/dist/index.d.mts +9 -10
- package/dist/index.mjs +2 -3
- package/dist/internal/anthropic.d.mts +51 -49
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
- package/dist/internal/openai-responses-payload-policy.mjs +2 -3
- package/dist/internal/openai.d.mts +65 -63
- package/dist/internal/openai.mjs +10 -9
- package/dist/internal/retry-after.d.mts +2 -3
- package/dist/internal/runtime.d.mts +51 -40
- package/dist/internal/runtime.mjs +9 -9
- package/dist/internal/shared.d.mts +25 -25
- package/dist/internal/shared.mjs +3 -3
- package/dist/{json-parse-CDnesDM_.mjs → json-parse-BuAJEbdW.mjs} +18 -2
- package/dist/{mistral-D6hRXI7A.mjs → mistral-BCnrI-kV.mjs} +22 -25
- package/dist/{openai-chatgpt-responses-C339VIfT.mjs → openai-chatgpt-responses-CGBGWSqr.mjs} +31 -14
- package/dist/openai-completions-BaTuwID7.mjs +401 -0
- package/dist/{openai-completions-compat-B0KTleXp.d.mts → openai-completions-compat-DB7FFq7k.d.mts} +3 -3
- package/dist/openai-completions-stream-Bpns6uNc.mjs +1622 -0
- package/dist/{openai-responses-BXEcr-Tp.mjs → openai-responses-1GBcQujk.mjs} +8 -6
- package/dist/openai-responses-compaction-window-DwydGZI8.mjs +686 -0
- package/dist/{openai-responses-contracts-CD75pQ0m.d.mts → openai-responses-contracts-DgaR3t5T.d.mts} +14 -5
- package/dist/{openai-responses-payload-policy-CNGFT9zr.d.mts → openai-responses-payload-policy-rLRPsSmB.d.mts} +1 -0
- package/dist/{openai-responses-prompt-observer-internal-BG-1AsBI.mjs → openai-responses-prompt-observer-internal-_nhGTn2b.mjs} +3 -2
- package/dist/{openai-responses-shared-Cvt5MgEm.mjs → openai-responses-shared-zPmKnhF5.mjs} +315 -1468
- package/dist/openai-stop-reason-Drnn_6Qj.mjs +28 -0
- package/dist/openai-tool-schema-Dgl4H2MU.mjs +1695 -0
- package/dist/{provider-error-C8mBRJDl.mjs → provider-error-jZP5NMTZ.mjs} +3 -77
- package/dist/{provider-options-Cc5ZQ6Aa.d.mts → provider-options-HvA_slFa.d.mts} +13 -4
- package/dist/{provider-transcript-transform--gtf0ZbR.mjs → provider-transcript-transform-C01bQ5a3.mjs} +1 -1
- package/dist/provider-types.d.mts +18 -17
- package/dist/providers.d.mts +5 -6
- package/dist/providers.mjs +9 -9
- package/dist/{reasoning-tag-text-partitioner-5ygO2rZc.mjs → reasoning-tag-text-partitioner-CwzKb0bA.mjs} +1 -1
- package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
- package/dist/{sanitize-unicode-BP7HLLZn.mjs → sanitize-unicode-DCkltN94.mjs} +1 -2
- package/dist/simple-options-DKx86yX9.mjs +155 -0
- package/dist/{anthropic-BQXQudmA.mjs → src-Bu3FiFAG.mjs} +1 -0
- package/dist/{stream-first-event-timeout-MK28puvq.mjs → stream-first-event-timeout-DcNjoFQE.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-FEr-jOoZ.mjs → tool-schema-json-projection-qvTEs5Am.mjs} +2 -2
- package/dist/{simple-options-oqsXB6U3.mjs → transport-stream-shared-CT5ycdzn.mjs} +10 -118
- package/dist/transport-stream-shared-NjwWNaRY.d.mts +138 -0
- package/dist/{transport-utils-Bv0FHkd0.mjs → transport-utils-BHx9z8Cl.mjs} +9 -9
- package/dist/transports.d.mts +127 -189
- package/dist/transports.mjs +181 -1214
- package/dist/types-DtGu2d3C.d.mts +1 -0
- package/dist/{types-DTAP49HF.d.mts → types-h38Azne1.d.mts} +38 -17
- package/dist/types.d.mts +5 -4
- package/dist/types.mjs +1 -2
- package/dist/utf16-slice-qz3nsy87.mjs +84 -0
- package/dist/{validation-DYNNrU9u.d.mts → validation-C68lP2uy.d.mts} +1 -2
- package/dist/validation.d.mts +1 -1
- package/package.json +6 -6
- package/dist/anthropic-BECQCNdF.d.mts +0 -98
- package/dist/event-stream-BVVgDSdq.d.mts +0 -1
- package/dist/headers-B_e4-1J0.mjs +0 -9
- package/dist/index-BVVgDSdq.d.mts +0 -1
- package/dist/openai-completions-D88orSJ9.mjs +0 -632
- package/dist/openai-responses-contracts-DvILoqBk.mjs +0 -247
- package/dist/openai-responses-payload-policy-BDo8CQsx.mjs +0 -208
- package/dist/openai-stop-reason-9OONKyAm.mjs +0 -579
- package/dist/openai-tool-projection-CHGLt03m.mjs +0 -426
- package/dist/provider-options-AvldWZt8.mjs +0 -21
- 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,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as resolveClaudeSonnet5ModelIdentity, g as supportsClaudeNativeXhighEffort, p as supportsClaudeAdaptiveThinking, u as resolveClaudeOpus5ModelIdentity } from "./
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
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 { a as
|
|
7
|
-
import { n as projectProviderError } from "./provider-error-
|
|
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-jZP5NMTZ.mjs";
|
|
8
|
+
import { A as applyAnthropicCacheControlToMessages, C as applyAnthropicFallbackBoundary, D as createAnthropicInlineImageBudget, E as applyAnthropicRefusal, I as isAnthropicOAuthApiKey, L as omitFoundryBearerCredentialHeaders, O as normalizeAnthropicInlineContent, R as usesFoundryBearerAuth, T as resolveAnthropicFallbackServingModelCost, _ as toClaudeCodeToolName, a as suppressAnthropicCompaction, b as ANTHROPIC_SERVER_SIDE_FALLBACKS, f as normalizeAnthropicToolCallId, g as resolveOriginalAnthropicToolName, h as reconcileAnthropicToolChoice, k as resolveAnthropicImageMediaType, m as projectAnthropicTools, n as createCompactionCapture, o as applyAnthropicMessageDeltaUsage, p as normalizeAnthropicToolChoice, r as isAnthropicReplayRejection, s as applyAnthropicMessageStartUsage, t as buildAnthropicReplayPlan, v as ANTHROPIC_OMITTED_REASONING_TEXT, w as readAnthropicFallbackBoundary, x as ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, y as findActiveAnthropicToolTurnAssistantIndex } from "./anthropic-compaction-replay-CY4tkD4V.mjs";
|
|
8
9
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
10
|
+
import { d as stripSystemPromptCacheBoundary, n as buildBaseOptions, r as clampMaxTokensToModel, t as adjustMaxTokensForThinking, u as splitSystemPromptCacheBoundary } from "./simple-options-DKx86yX9.mjs";
|
|
11
|
+
import { t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./transport-utils-BHx9z8Cl.mjs";
|
|
12
|
+
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
13
|
+
import { _ as transportAbortError, f as notifyProviderHttpResponse, s as finalizeTerminalToolCallArguments } from "./transport-stream-shared-CT5ycdzn.mjs";
|
|
11
14
|
import { t as createDeferredEventBuffer } from "./deferred-event-buffer-DAvyP7qA.mjs";
|
|
12
|
-
import { n as parseStreamingJson, t as
|
|
15
|
+
import { n as parseJsonWithRepair, r as parseStreamingJson, t as createToolArgumentPreviewSchedule } from "./json-parse-BuAJEbdW.mjs";
|
|
13
16
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
14
|
-
import { t as
|
|
15
|
-
import { t as transformProviderMessages } from "./provider-transcript-transform--gtf0ZbR.mjs";
|
|
17
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-C01bQ5a3.mjs";
|
|
16
18
|
import { i as resolveCloudflareBaseUrl, n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-NCJtz9i0.mjs";
|
|
17
19
|
import Anthropic from "@anthropic-ai/sdk";
|
|
18
20
|
import { Stream } from "@anthropic-ai/sdk/core/streaming.js";
|
|
@@ -109,22 +111,20 @@ const ANTHROPIC_MESSAGE_EVENTS = /* @__PURE__ */ new Set([
|
|
|
109
111
|
]);
|
|
110
112
|
async function* iterateAnthropicEvents(response, requireMessageStop = false) {
|
|
111
113
|
if (!response.body) throw new Error("Attempted to iterate over an Anthropic response with no body");
|
|
112
|
-
let sawMessageStart = false;
|
|
113
114
|
let sawMessageEnd = false;
|
|
114
115
|
for await (const sse of Stream.rawEvents(response)) {
|
|
115
116
|
if (sse.event === "error") throw new Error(sse.data);
|
|
116
117
|
if (!ANTHROPIC_MESSAGE_EVENTS.has(sse.event ?? "")) continue;
|
|
117
118
|
try {
|
|
118
119
|
const event = parseJsonWithRepair(sse.data);
|
|
119
|
-
if (event.type === "
|
|
120
|
-
else if (event.type === "message_stop") sawMessageEnd = true;
|
|
120
|
+
if (event.type === "message_stop") sawMessageEnd = true;
|
|
121
121
|
yield event;
|
|
122
122
|
} catch (error) {
|
|
123
123
|
if (error instanceof SyntaxError) throw new Error(MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, { cause: error });
|
|
124
124
|
throw error;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
if (
|
|
127
|
+
if (requireMessageStop && !sawMessageEnd) throw new Error("Anthropic stream ended before message_stop");
|
|
128
128
|
}
|
|
129
129
|
const streamAnthropic = (model, context, options) => {
|
|
130
130
|
const stream = new AssistantMessageEventStream();
|
|
@@ -205,9 +205,11 @@ const streamAnthropic = (model, context, options) => {
|
|
|
205
205
|
});
|
|
206
206
|
const blocks = output.content;
|
|
207
207
|
const blockIndexes = /* @__PURE__ */ new Map();
|
|
208
|
+
const toolArgumentPreviewSchedules = /* @__PURE__ */ new WeakMap();
|
|
208
209
|
const sealedToolCalls = [];
|
|
209
210
|
const compactionCapture = createCompactionCapture(output, model, requestOptions);
|
|
210
|
-
|
|
211
|
+
const requireMessageStop = refusalBuffer !== void 0 || model.provider === "anthropic" && isAnthropicPublicEndpoint(model.baseUrl);
|
|
212
|
+
for await (const event of iterateAnthropicEvents(response, requireMessageStop)) if (event.type === "message_start") {
|
|
211
213
|
output.responseId = event.message.id;
|
|
212
214
|
output.responseModel = event.message.model;
|
|
213
215
|
messageStartPromptUsage = applyAnthropicMessageStartUsage(output.usage, event.message.usage);
|
|
@@ -316,6 +318,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
316
318
|
};
|
|
317
319
|
output.content.push(block);
|
|
318
320
|
blockIndexes.set(event.index, output.content.length - 1);
|
|
321
|
+
toolArgumentPreviewSchedules.set(block, createToolArgumentPreviewSchedule());
|
|
319
322
|
eventSink.push({
|
|
320
323
|
type: "toolcall_start",
|
|
321
324
|
contentIndex: output.content.length - 1,
|
|
@@ -354,7 +357,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
354
357
|
const block = index === void 0 ? void 0 : blocks[index];
|
|
355
358
|
if (index !== void 0 && block?.type === "toolCall") {
|
|
356
359
|
block.partialJson = (block.partialJson ?? "") + event.delta.partial_json;
|
|
357
|
-
block.arguments = parseStreamingJson(block.partialJson);
|
|
360
|
+
if (toolArgumentPreviewSchedules.get(block)?.(block.partialJson.length)) block.arguments = parseStreamingJson(block.partialJson);
|
|
358
361
|
eventSink.push({
|
|
359
362
|
type: "toolcall_delta",
|
|
360
363
|
contentIndex: index,
|
|
@@ -498,9 +501,6 @@ const streamSimpleAnthropic = (model, context, options) => {
|
|
|
498
501
|
thinkingBudgetTokens: thinkingEnabled ? adjusted.thinkingBudget : void 0
|
|
499
502
|
});
|
|
500
503
|
};
|
|
501
|
-
function isOAuthToken(apiKey) {
|
|
502
|
-
return getAiTransportHost().resolveSecretSentinel(apiKey).includes("sk-ant-oat");
|
|
503
|
-
}
|
|
504
504
|
function isAnthropicPublicEndpoint(baseUrl) {
|
|
505
505
|
if (!baseUrl) return true;
|
|
506
506
|
try {
|
|
@@ -577,7 +577,7 @@ function createClient(model, apiKey, thinkingEnabled, interleavedThinking, useFi
|
|
|
577
577
|
isOAuthToken: false,
|
|
578
578
|
serverSideFallback: false
|
|
579
579
|
};
|
|
580
|
-
if (
|
|
580
|
+
if (isAnthropicOAuthApiKey(apiKey)) return {
|
|
581
581
|
client: new Anthropic({
|
|
582
582
|
apiKey: null,
|
|
583
583
|
authToken: apiKey,
|
package/dist/{anthropic-compaction-replay-4Zx7-aCr.mjs → anthropic-compaction-replay-CY4tkD4V.mjs}
RENAMED
|
@@ -1,13 +1,35 @@
|
|
|
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 { a as estimateBase64DecodedBytes } from "./provider-error-C8mBRJDl.mjs";
|
|
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 asNonNegativeFiniteNumber, n as estimateBase64DecodedBytes } from "./base64-CEFBpSkN.mjs";
|
|
7
5
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { a as resolveProviderEndpoint, o as resolveProviderRequestCapabilities, t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-
|
|
6
|
+
import { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName, u as splitSystemPromptCacheBoundary } from "./simple-options-DKx86yX9.mjs";
|
|
7
|
+
import { a as resolveProviderEndpoint, o as resolveProviderRequestCapabilities, t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-qvTEs5Am.mjs";
|
|
8
|
+
import { s as parsePositiveInteger } from "./transport-utils-BHx9z8Cl.mjs";
|
|
10
9
|
import { t as shortHash } from "./hash-CHgqbJmD.mjs";
|
|
10
|
+
//#region packages/ai/src/providers/anthropic-auth-headers.ts
|
|
11
|
+
/** Inspect resolved credential shape for auth routing without exposing its value. */
|
|
12
|
+
function isAnthropicOAuthApiKey(apiKey) {
|
|
13
|
+
return typeof apiKey === "string" && getAiTransportHost().resolveSecretSentinel(apiKey).includes("sk-ant-oat");
|
|
14
|
+
}
|
|
15
|
+
function usesFoundryBearerAuth(model) {
|
|
16
|
+
return model.provider === "microsoft-foundry" && (model.authHeader === true || hasBearerAuthorizationHeader(model.headers));
|
|
17
|
+
}
|
|
18
|
+
function hasBearerAuthorizationHeader(headers) {
|
|
19
|
+
if (!headers) return false;
|
|
20
|
+
return Object.entries(headers).some(([key, value]) => key.toLowerCase() === "authorization" && /^bearer\s+\S+/i.test(value.trim()));
|
|
21
|
+
}
|
|
22
|
+
function omitFoundryBearerCredentialHeaders(headers) {
|
|
23
|
+
if (!headers) return;
|
|
24
|
+
const next = {};
|
|
25
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
26
|
+
const lower = key.toLowerCase();
|
|
27
|
+
if (lower === "authorization" || lower === "x-api-key" || lower === "api-key") continue;
|
|
28
|
+
next[key] = value;
|
|
29
|
+
}
|
|
30
|
+
return Object.keys(next).length > 0 ? next : void 0;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
11
33
|
//#region packages/ai/src/transports/anthropic-payload-policy.ts
|
|
12
34
|
/**
|
|
13
35
|
* Anthropic-family request payload policy helpers.
|
|
@@ -16,10 +38,6 @@ import { t as shortHash } from "./hash-CHgqbJmD.mjs";
|
|
|
16
38
|
*/
|
|
17
39
|
const ANTHROPIC_CACHE_CONTROL_LIMIT = 4;
|
|
18
40
|
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
41
|
/** Resolve the Anthropic input-token trigger, including the API's minimum. */
|
|
24
42
|
function resolveAnthropicCompactThreshold(contextWindow, configured) {
|
|
25
43
|
const configuredThreshold = parsePositiveInteger(configured);
|
|
@@ -28,11 +46,11 @@ function resolveAnthropicCompactThreshold(contextWindow, configured) {
|
|
|
28
46
|
return Math.max(ANTHROPIC_COMPACT_THRESHOLD_MIN, resolvedContextWindow === void 0 ? ANTHROPIC_COMPACT_THRESHOLD_MIN : Math.floor(resolvedContextWindow * .7));
|
|
29
47
|
}
|
|
30
48
|
/** Resolve the server-compaction gate and effective threshold for an Anthropic route. */
|
|
31
|
-
function resolveAnthropicServerCompactionPlan(model, extraParams) {
|
|
49
|
+
function resolveAnthropicServerCompactionPlan(model, extraParams, apiKey) {
|
|
32
50
|
const provider = normalizeOptionalLowercaseString(model.provider);
|
|
33
51
|
const api = normalizeOptionalLowercaseString(model.api);
|
|
34
52
|
const endpointClass = resolveProviderEndpoint(model).endpointClass;
|
|
35
|
-
const enabled = extraParams?.anthropicServerCompaction === true && provider === "anthropic" && api === "anthropic-messages" && (endpointClass === "default" || endpointClass === "anthropic-public");
|
|
53
|
+
const enabled = extraParams?.anthropicServerCompaction === true && !isAnthropicOAuthApiKey(apiKey) && provider === "anthropic" && api === "anthropic-messages" && (endpointClass === "default" || endpointClass === "anthropic-public");
|
|
36
54
|
return {
|
|
37
55
|
enabled,
|
|
38
56
|
...enabled ? { threshold: resolveAnthropicCompactThreshold(model.contextWindow, extraParams?.anthropicCompactThreshold) } : {}
|
|
@@ -249,25 +267,6 @@ async function normalizeAnthropicInlineContent(content, budget) {
|
|
|
249
267
|
return normalized;
|
|
250
268
|
}
|
|
251
269
|
//#endregion
|
|
252
|
-
//#region packages/ai/src/providers/anthropic-auth-headers.ts
|
|
253
|
-
function usesFoundryBearerAuth(model) {
|
|
254
|
-
return model.provider === "microsoft-foundry" && (model.authHeader === true || hasBearerAuthorizationHeader(model.headers));
|
|
255
|
-
}
|
|
256
|
-
function hasBearerAuthorizationHeader(headers) {
|
|
257
|
-
if (!headers) return false;
|
|
258
|
-
return Object.entries(headers).some(([key, value]) => key.toLowerCase() === "authorization" && /^bearer\s+\S+/i.test(value.trim()));
|
|
259
|
-
}
|
|
260
|
-
function omitFoundryBearerCredentialHeaders(headers) {
|
|
261
|
-
if (!headers) return;
|
|
262
|
-
const next = {};
|
|
263
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
264
|
-
const lower = key.toLowerCase();
|
|
265
|
-
if (lower === "authorization" || lower === "x-api-key" || lower === "api-key") continue;
|
|
266
|
-
next[key] = value;
|
|
267
|
-
}
|
|
268
|
-
return Object.keys(next).length > 0 ? next : void 0;
|
|
269
|
-
}
|
|
270
|
-
//#endregion
|
|
271
270
|
//#region packages/ai/src/providers/anthropic-refusal.ts
|
|
272
271
|
function readAnthropicRefusalDetails(value) {
|
|
273
272
|
if (!value || typeof value !== "object") return {
|
|
@@ -836,4 +835,4 @@ function isAnthropicReplayRejection(error) {
|
|
|
836
835
|
return (record.status === 400 || text.startsWith("http 400:")) && (text.includes("compaction") || text.includes("context_management"));
|
|
837
836
|
}
|
|
838
837
|
//#endregion
|
|
839
|
-
export {
|
|
838
|
+
export { applyAnthropicCacheControlToMessages as A, applyAnthropicFallbackBoundary as C, createAnthropicInlineImageBudget as D, applyAnthropicRefusal as E, resolveAnthropicServerCompactionPlan as F, isAnthropicOAuthApiKey as I, omitFoundryBearerCredentialHeaders as L, applyAnthropicPayloadPolicyToParams as M, resolveAnthropicEphemeralCacheControl as N, normalizeAnthropicInlineContent as O, resolveAnthropicPayloadPolicy as P, usesFoundryBearerAuth as R, CLAUDE_OPUS_FALLBACK_MODEL_COST as S, resolveAnthropicFallbackServingModelCost as T, toClaudeCodeToolName as _, suppressAnthropicCompaction as a, ANTHROPIC_SERVER_SIDE_FALLBACKS as b, readAnthropicCacheWriteUsage as c, readLastAnthropicIterationUsage as d, normalizeAnthropicToolCallId as f, resolveOriginalAnthropicToolName as g, reconcileAnthropicToolChoice as h, resolveNewestAnthropicCompaction as i, applyAnthropicEphemeralCacheControlMarkers as j, resolveAnthropicImageMediaType as k, readAnthropicPromptUsageSnapshot as l, projectAnthropicTools as m, createCompactionCapture as n, applyAnthropicMessageDeltaUsage as o, normalizeAnthropicToolChoice as p, isAnthropicReplayRejection as r, applyAnthropicMessageStartUsage as s, buildAnthropicReplayPlan as t, readAnthropicUsageTokenCount as u, ANTHROPIC_OMITTED_REASONING_TEXT as v, readAnthropicFallbackBoundary as w, ANTHROPIC_SERVER_SIDE_FALLBACK_BETA as x, findActiveAnthropicToolTurnAssistantIndex as y };
|
package/dist/{anthropic-payload-policy-CSx7MoKH.d.mts → anthropic-payload-policy-i_5_inWe.d.mts}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./index-N3zr6__t.mjs";
|
|
2
|
+
import { D as Model } from "./types-h38Azne1.mjs";
|
|
2
3
|
//#region packages/ai/src/transports/anthropic-payload-policy.d.ts
|
|
3
4
|
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
4
5
|
type AnthropicServiceTier = "auto" | "standard_only";
|
|
@@ -32,7 +33,7 @@ declare function resolveAnthropicServerCompactionPlan(model: {
|
|
|
32
33
|
api?: unknown;
|
|
33
34
|
baseUrl?: string;
|
|
34
35
|
contextWindow?: unknown;
|
|
35
|
-
}, extraParams?: Record<string, unknown
|
|
36
|
+
}, extraParams?: Record<string, unknown>, apiKey?: string): {
|
|
36
37
|
enabled: boolean;
|
|
37
38
|
threshold?: number;
|
|
38
39
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./index-N3zr6__t.mjs";
|
|
2
|
+
import { D as Model, H as StreamFunction, U as StreamOptions, d as Context, n as Api, s as AssistantMessageEventStreamContract, z as SimpleStreamOptions } from "./types-h38Azne1.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
|
-
import { n as getEnvApiKey } from "./env-api-keys-DrgeBuva.mjs";
|
|
2
1
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
3
|
-
import { n as getAiTransportHost } from "./host-
|
|
2
|
+
import { n as getAiTransportHost } from "./host-D51fmkH6.mjs";
|
|
4
3
|
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
5
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
6
|
-
import {
|
|
4
|
+
import { n as buildBaseOptions } from "./simple-options-DKx86yX9.mjs";
|
|
5
|
+
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
6
|
+
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, o as runResponsesStreamLifecycle, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-zPmKnhF5.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
|
|
@@ -68,4 +68,76 @@ function parseStrictNonNegativeInteger(value) {
|
|
|
68
68
|
return parsed !== void 0 && parsed >= 0 ? parsed : void 0;
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
|
-
|
|
71
|
+
//#region packages/media-core/src/base64.ts
|
|
72
|
+
/** Estimates decoded bytes without allocating a cleaned copy of the base64 payload. */
|
|
73
|
+
function estimateBase64DecodedBytes(base64) {
|
|
74
|
+
let effectiveLen = 0;
|
|
75
|
+
for (let i = 0; i < base64.length; i += 1) {
|
|
76
|
+
if (base64.charCodeAt(i) <= 32) continue;
|
|
77
|
+
effectiveLen += 1;
|
|
78
|
+
}
|
|
79
|
+
if (effectiveLen === 0) return 0;
|
|
80
|
+
let padding = 0;
|
|
81
|
+
let end = base64.length - 1;
|
|
82
|
+
while (end >= 0 && base64.charCodeAt(end) <= 32) end -= 1;
|
|
83
|
+
if (end >= 0 && base64[end] === "=") {
|
|
84
|
+
padding = 1;
|
|
85
|
+
end -= 1;
|
|
86
|
+
while (end >= 0 && base64.charCodeAt(end) <= 32) end -= 1;
|
|
87
|
+
if (end >= 0 && base64[end] === "=") padding = 2;
|
|
88
|
+
}
|
|
89
|
+
const estimated = Math.floor(effectiveLen * 3 / 4) - padding;
|
|
90
|
+
return Math.max(0, estimated);
|
|
91
|
+
}
|
|
92
|
+
function isBase64DataChar(code) {
|
|
93
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 43 || code === 47;
|
|
94
|
+
}
|
|
95
|
+
function base64DataValue(code) {
|
|
96
|
+
if (code >= 65 && code <= 90) return code - 65;
|
|
97
|
+
if (code >= 97 && code <= 122) return code - 97 + 26;
|
|
98
|
+
if (code >= 48 && code <= 57) return code - 48 + 52;
|
|
99
|
+
return code === 43 ? 62 : 63;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Normalizes and validates a base64 string, returning canonical no-whitespace
|
|
103
|
+
* base64 only when the input has valid alphabet, padding, and length.
|
|
104
|
+
*/
|
|
105
|
+
function canonicalizeBase64(base64) {
|
|
106
|
+
let out;
|
|
107
|
+
let outLen = 0;
|
|
108
|
+
let padding = 0;
|
|
109
|
+
let sawPadding = false;
|
|
110
|
+
let lastDataCode = 0;
|
|
111
|
+
for (let i = 0; i < base64.length; i += 1) {
|
|
112
|
+
const code = base64.charCodeAt(i);
|
|
113
|
+
if (code <= 32) {
|
|
114
|
+
if (out === void 0) {
|
|
115
|
+
out = Buffer.allocUnsafe(base64.length - 1);
|
|
116
|
+
for (let j = 0; j < i; j += 1) out[j] = base64.charCodeAt(j);
|
|
117
|
+
outLen = i;
|
|
118
|
+
}
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (code === 61) {
|
|
122
|
+
padding += 1;
|
|
123
|
+
if (padding > 2) return;
|
|
124
|
+
sawPadding = true;
|
|
125
|
+
} else if (sawPadding || !isBase64DataChar(code)) return;
|
|
126
|
+
else lastDataCode = code;
|
|
127
|
+
if (out !== void 0) {
|
|
128
|
+
out[outLen] = code;
|
|
129
|
+
outLen += 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const cleanedLength = out === void 0 ? base64.length : outLen;
|
|
133
|
+
if (cleanedLength === 0) return;
|
|
134
|
+
const remainder = cleanedLength % 4;
|
|
135
|
+
if (remainder !== 0 && (sawPadding || remainder === 1)) return;
|
|
136
|
+
const effectivePadding = remainder === 0 ? padding : 4 - remainder;
|
|
137
|
+
const padBitMask = effectivePadding === 2 ? 15 : effectivePadding === 1 ? 3 : 0;
|
|
138
|
+
if (padBitMask !== 0 && (base64DataValue(lastDataCode) & padBitMask) !== 0) return;
|
|
139
|
+
const cleaned = out === void 0 ? base64 : out.subarray(0, outLen).toString("latin1");
|
|
140
|
+
return remainder === 0 ? cleaned : cleaned + "=".repeat(4 - remainder);
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { asNonNegativeFiniteNumber as a, parseStrictNonNegativeInteger as c, asFiniteNumberInRange as i, parseStrictPositiveInteger as l, estimateBase64DecodedBytes as n, clampTimerTimeoutMs as o, asFiniteNumber as r, parseStrictFiniteNumber as s, canonicalizeBase64 as t, resolveTimerTimeoutMs as u };
|
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";
|
|
@@ -17,9 +16,9 @@ type DiagnosticProjectionPolicy = {
|
|
|
17
16
|
kind: "redacted";
|
|
18
17
|
}>) => Record<string, unknown>;
|
|
19
18
|
};
|
|
20
|
-
declare function projectDiagnosticValue(value: unknown, policy?: DiagnosticProjectionPolicy, seen?: WeakSet<object>, mediaPayload?: boolean, state?: {
|
|
19
|
+
export declare function projectDiagnosticValue(value: unknown, policy?: DiagnosticProjectionPolicy, seen?: WeakSet<object>, mediaPayload?: boolean, state?: {
|
|
21
20
|
changed: boolean;
|
|
22
21
|
nodesRemaining: number;
|
|
23
22
|
}): unknown;
|
|
24
23
|
//#endregion
|
|
25
|
-
export { AssistantMessageDiagnostic, DiagnosticErrorInfo, type DiagnosticProjectionPolicy, type ProviderErrorRedactor, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, extractDiagnosticError, formatThrownValue
|
|
24
|
+
export { AssistantMessageDiagnostic, DiagnosticErrorInfo, type DiagnosticProjectionPolicy, type ProviderErrorRedactor, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, extractDiagnosticError, formatThrownValue };
|
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-jZP5NMTZ.mjs";
|
|
3
3
|
export { appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, extractDiagnosticError, formatThrownValue, projectDiagnosticValue };
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __exportAll = (all, no_symbols) => {
|
|
5
|
-
let target = {};
|
|
6
|
-
for (var name in all) __defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
-
return target;
|
|
12
|
-
};
|
|
13
|
-
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
14
|
-
//#endregion
|
|
1
|
+
import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
15
2
|
//#region packages/ai/src/env-api-keys.ts
|
|
16
3
|
let existsSync = null;
|
|
17
4
|
let homedir = null;
|
|
@@ -169,4 +156,4 @@ function getEnvApiKey(provider) {
|
|
|
169
156
|
}
|
|
170
157
|
}
|
|
171
158
|
//#endregion
|
|
172
|
-
export { getEnvApiKey as n,
|
|
159
|
+
export { getEnvApiKey as n, findEnvKeys as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./event-stream-UhnxHuqt.mjs";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { a as AssistantMessage, o as AssistantMessageEvent, s as AssistantMessageEventStreamContract } from "./types-
|
|
2
|
-
|
|
1
|
+
import { a as AssistantMessage, o as AssistantMessageEvent, s as AssistantMessageEventStreamContract } from "./types-h38Azne1.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-UhnxHuqt.mjs";
|
|
2
|
+
import "./event-stream-C988TSLe.mjs";
|
|
2
3
|
export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as getEnvApiKey } from "./env-api-keys-DrgeBuva.mjs";
|
|
2
1
|
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 {
|
|
2
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-D51fmkH6.mjs";
|
|
3
|
+
import { n as buildBaseOptions } from "./simple-options-DKx86yX9.mjs";
|
|
4
|
+
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
5
|
+
import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-DVfL9COU.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, c as extractToolResultText, d as isImageWithMediaPayload } from "./host-
|
|
3
|
-
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 { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName } from "./simple-options-DKx86yX9.mjs";
|
|
4
|
+
import { _ as transportAbortError, n as coerceTransportToolCallArguments, p as notifyProviderStreamOpened, t as assignTransportErrorDetails } from "./transport-stream-shared-CT5ycdzn.mjs";
|
|
4
5
|
import { t as googleFlashSupportsMinimalThinking } from "./google-thinking-level-C-V3tecN.mjs";
|
|
5
|
-
import { t as transformProviderMessages } from "./provider-transcript-transform
|
|
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 },
|
|
@@ -410,6 +414,7 @@ function mapStopReason(reason) {
|
|
|
410
414
|
case FinishReason.OTHER:
|
|
411
415
|
case FinishReason.LANGUAGE:
|
|
412
416
|
case FinishReason.MALFORMED_FUNCTION_CALL:
|
|
417
|
+
case FinishReason.TOO_MANY_TOOL_CALLS:
|
|
413
418
|
case FinishReason.UNEXPECTED_TOOL_CALL:
|
|
414
419
|
case FinishReason.NO_IMAGE: return "error";
|
|
415
420
|
default: throw new Error(`Unhandled stop reason: ${String(reason)}`);
|
|
@@ -453,6 +458,8 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
453
458
|
};
|
|
454
459
|
for await (const chunk of params.chunks) {
|
|
455
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;
|
|
456
463
|
if (chunk.usageMetadata) {
|
|
457
464
|
for (const field of Object.keys(knownUsage)) {
|
|
458
465
|
const value = chunk.usageMetadata[field];
|
|
@@ -588,7 +595,7 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
588
595
|
});
|
|
589
596
|
}
|
|
590
597
|
}
|
|
591
|
-
if (candidate?.finishReason) {
|
|
598
|
+
if (candidate?.finishReason && candidate.finishReason !== FinishReason.FINISH_REASON_UNSPECIFIED) {
|
|
592
599
|
sawTerminalReason = true;
|
|
593
600
|
params.output.stopReason = mapStopReason(candidate.finishReason);
|
|
594
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-DKx86yX9.mjs";
|
|
5
|
+
import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-DVfL9COU.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-BP7HLLZn.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;`;
|
|
@@ -257,8 +254,7 @@ function describeUnsupportedToolResultMedia(blocks, support) {
|
|
|
257
254
|
return omittedImage ? "[unsupported tool-result image omitted]" : void 0;
|
|
258
255
|
}
|
|
259
256
|
function formatToolResultText(params) {
|
|
260
|
-
const
|
|
261
|
-
const body = trimmed ? `${trimmed}${params.omittedMediaPlaceholder ? `\n${params.omittedMediaPlaceholder}` : ""}` : params.omittedMediaPlaceholder ?? params.mediaPlaceholder ?? "(no tool output)";
|
|
257
|
+
const body = params.text.trim() ? `${params.text}${params.omittedMediaPlaceholder ? `\n${params.omittedMediaPlaceholder}` : ""}` : params.omittedMediaPlaceholder ?? params.mediaPlaceholder ?? "(no tool output)";
|
|
262
258
|
return `${params.isError ? "[tool error] " : ""}${body}`;
|
|
263
259
|
}
|
|
264
260
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { n as
|
|
3
|
-
|
|
1
|
+
import "./index-N3zr6__t.mjs";
|
|
2
|
+
import { D as Model, V as StreamFn, d as Context, n as Api } from "./types-h38Azne1.mjs";
|
|
3
|
+
import { n as ApiRegistry } from "./api-registry-C9-wZd_W.mjs";
|
|
4
4
|
//#region packages/ai/src/host.d.ts
|
|
5
5
|
/** Provider capability facts needed by the package-owned transports. */
|
|
6
6
|
interface AiProviderRequestCapabilities {
|