@openclaw/ai 2026.10.1-beta.2 → 2026.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{anthropic-CZv6XFER.mjs → anthropic-C4qygbtf.mjs} +12 -11
- package/dist/{anthropic-payload-policy-BhCcgNdm.d.mts → anthropic-payload-policy-DD7vzpxE.d.mts} +5 -2
- package/dist/{anthropic-stream-reducer-BQ1tjd7x.mjs → anthropic-stream-reducer-CWyWE21W.mjs} +48 -54
- package/dist/{api-registry-DpU0Rj-I.d.mts → api-registry-B3rC2qu3.d.mts} +1 -1
- package/dist/{assistant-output-OLm-Oln0.mjs → assistant-output-D5762GPH.mjs} +2 -2
- package/dist/{assistant-text-phase-Bl1aDCB7.mjs → assistant-text-phase-DVZOxbuR.mjs} +1 -1
- package/dist/{azure-openai-responses-DH7bd3QT.mjs → azure-openai-responses-DO-Fv8ha.mjs} +5 -5
- package/dist/diagnostics.d.mts +3 -3
- package/dist/env-api-keys-BR0MUYYD.d.mts +17 -0
- package/dist/{google-1WLOtb8w.mjs → google-B2g_Xn4d.mjs} +6 -6
- package/dist/{google-interactions-wrnE6MLw.mjs → google-interactions-DNXzPPwQ.mjs} +6 -6
- package/dist/{google-messages-BwPPycw6.mjs → google-messages-l7wgIF5I.mjs} +3 -3
- package/dist/{google-shared-Eql1OMPU.mjs → google-shared-V8jogVPq.mjs} +5 -5
- package/dist/{google-vertex-0LrlRoO3.mjs → google-vertex-_khoip47.mjs} +5 -5
- package/dist/{host-BinBeGcQ.d.mts → host-DiPhRjrc.d.mts} +2 -2
- package/dist/{host-policy-B3jc4Rpn.mjs → host-policy-BwhNNGQR.mjs} +1 -1
- package/dist/{host-DCW52iHe.mjs → host-u3o8XiAp.mjs} +10 -7
- package/dist/{index-a8e_oKnu.d.mts → index-D27wAoOr.d.mts} +23 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/internal/anthropic.d.mts +5 -5
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/env-api-keys.d.mts +2 -0
- package/dist/internal/env-api-keys.mjs +2 -0
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +9 -2
- package/dist/internal/openai-responses-payload-policy.mjs +3 -2
- package/dist/internal/openai.d.mts +8 -8
- package/dist/internal/openai.mjs +7 -7
- package/dist/internal/runtime.d.mts +7 -22
- package/dist/internal/runtime.mjs +3 -3
- package/dist/internal/shared.d.mts +1 -1
- package/dist/internal/shared.mjs +3 -3
- package/dist/internal/tool-schema.mjs +1 -1
- package/dist/{mistral-DSt4vQAO.mjs → mistral-cnoBDSIg.mjs} +4 -4
- package/dist/{openai-chatgpt-responses-BC2x0Oqx.mjs → openai-chatgpt-responses-CHdn8YJ_.mjs} +70 -63
- package/dist/{openai-completions-DNyHnXKg.mjs → openai-completions-BZfHIaZ7.mjs} +3 -3
- package/dist/{openai-completions-compat-BYdYpXhU.d.mts → openai-completions-compat-BgPg1BRs.d.mts} +2 -2
- package/dist/{openai-completions-compat-BdmlhD4u.mjs → openai-completions-compat-GMN8A0fm.mjs} +1 -1
- package/dist/{openai-completions-transport-DWM2mQDB.mjs → openai-completions-transport-CuoQfnKV.mjs} +123 -20
- package/dist/{openai-prompt-cache-I8YQTzf8.mjs → openai-prompt-cache-BK6E2g4Q.mjs} +1 -1
- package/dist/{openai-prompt-cache-45-AH_xv.d.mts → openai-prompt-cache-CFviG_D4.d.mts} +1 -1
- package/dist/{openai-responses-uZ5oWSp7.mjs → openai-responses-BhAZFsL9.mjs} +7 -7
- package/dist/{openai-responses-compaction-replay-BClApUIf.d.mts → openai-responses-compaction-replay-BBNo098-.d.mts} +3 -3
- package/dist/{openai-responses-compaction-window-m878aVpU.mjs → openai-responses-compaction-window-tA4QkU0o.mjs} +3 -3
- package/dist/{openai-responses-contracts-Br5IIw_h.d.mts → openai-responses-contracts-D5yVZBp-.d.mts} +3 -3
- package/dist/openai-responses-endpoint-TV0y50fb.mjs +11 -0
- package/dist/{openai-responses-payload-policy-C7GsA1y0.d.mts → openai-responses-payload-policy-s1apQlZZ.d.mts} +4 -2
- package/dist/{openai-responses-prompt-observer-internal-CCg7B6l4.mjs → openai-responses-prompt-observer-internal-CefUzh8M.mjs} +2 -2
- package/dist/{openai-responses-shared-C7oVyjED.mjs → openai-responses-shared-CKNmC3vC.mjs} +11 -11
- package/dist/{openai-responses-terminal-usage-DgImcyJu.d.mts → openai-responses-terminal-usage-CempLedn.d.mts} +1 -1
- package/dist/{openai-tool-schema-DYNePiF8.mjs → openai-tool-schema-BIrI0mrA.mjs} +18 -1
- package/dist/{openai-transport-params-JFsnIyto.mjs → openai-transport-params-D7JMUPjf.mjs} +7 -7
- package/dist/{provider-options-D5ABCV_l.d.mts → provider-options-CkieKvNJ.d.mts} +9 -4
- package/dist/{provider-replay-context-C7Bmi84a.mjs → provider-replay-context-CO_Eplnc.mjs} +1 -1
- package/dist/{provider-transport-turn-state-_M2kLdUE.mjs → provider-transport-turn-state-BX6TfCyW.mjs} +2 -2
- package/dist/{provider-types-F8Mqc9Ma.d.mts → provider-types-v3bmqsfg.d.mts} +2 -2
- package/dist/provider-types.d.mts +3 -3
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +10 -10
- package/dist/{simple-options-BkKTXxhp.mjs → simple-options-7QuSKriJ.mjs} +2 -2
- package/dist/{src-B0NIt2UK.mjs → src-VWy9E7DZ.mjs} +21 -7
- package/dist/{stream-DSdzKsDK.mjs → stream-DFaRxi2D.mjs} +1 -1
- package/dist/{text-signature-MLwfi6fq.mjs → text-signature-D_vRrx-z.mjs} +2 -2
- package/dist/{transport-stream-shared-CxXXz_Dd.mjs → transport-stream-shared-CCR7hSW0.mjs} +24 -5
- package/dist/{transport-stream-shared-BcAKh2XH.d.mts → transport-stream-shared-DW-7-qLR.d.mts} +1 -1
- package/dist/transports.d.mts +13 -13
- package/dist/transports.mjs +170 -172
- package/dist/types-UlNana-2.d.mts +1 -0
- package/dist/types.d.mts +3 -3
- package/dist/types.mjs +2 -2
- package/package.json +6 -1
- package/dist/types-BuiEBM3u.d.mts +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { w as supportsClaudeAdaptiveThinking } from "./src-VWy9E7DZ.mjs";
|
|
3
3
|
import { t as AssistantMessageEventStream } from "./event-stream-C5AbCAaZ.mjs";
|
|
4
|
-
import { S as resolveAnthropicThinkingEffort, T as usesClaudeStreamingRefusalContract, _ as buildAnthropicClaudeCodeIdentity, a as resolveAiTransportHeaderSentinels, b as prepareClaudeNoPrefillRequestContext, r as getAiTransportHost, x as requiresClaudeAdaptiveThinking } from "./host-
|
|
5
|
-
import { n as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./text-signature-
|
|
6
|
-
import { C as isAnthropicReplayRejection, J as usesFoundryBearerAuth, K as isAnthropicOAuthApiKey, M as isDirectAnthropicModel, T as suppressAnthropicCompaction, l as buildAnthropicRequest, q as omitFoundryBearerCredentialHeaders, t as consumeAnthropicStream, u as prepareAnthropicRequest, z as supportsAnthropicServerSideFallback } from "./anthropic-stream-reducer-
|
|
4
|
+
import { S as resolveAnthropicThinkingEffort, T as usesClaudeStreamingRefusalContract, _ as buildAnthropicClaudeCodeIdentity, a as resolveAiTransportHeaderSentinels, b as prepareClaudeNoPrefillRequestContext, r as getAiTransportHost, v as defaultsClaudeAdaptiveThinking, x as requiresClaudeAdaptiveThinking } from "./host-u3o8XiAp.mjs";
|
|
5
|
+
import { n as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./text-signature-D_vRrx-z.mjs";
|
|
6
|
+
import { C as isAnthropicReplayRejection, J as usesFoundryBearerAuth, K as isAnthropicOAuthApiKey, M as isDirectAnthropicModel, T as suppressAnthropicCompaction, l as buildAnthropicRequest, q as omitFoundryBearerCredentialHeaders, t as consumeAnthropicStream, u as prepareAnthropicRequest, z as supportsAnthropicServerSideFallback } from "./anthropic-stream-reducer-CWyWE21W.mjs";
|
|
7
7
|
import { i as resolveCacheRetention, n as resolveCloudflareBaseUrl, r as buildCopilotDynamicHeaders } from "./cloudflare-5qSGvIUH.mjs";
|
|
8
|
-
import { D as parseJsonWithRepair, m as notifyProviderHttpResponse, n as assignTransportErrorDetails, u as finalizeTransportStream } from "./transport-stream-shared-
|
|
9
|
-
import { n as buildBaseOptions, r as clampMaxTokensToModel, t as adjustMaxTokensForThinking } from "./simple-options-
|
|
8
|
+
import { D as parseJsonWithRepair, m as notifyProviderHttpResponse, n as assignTransportErrorDetails, u as finalizeTransportStream } from "./transport-stream-shared-CCR7hSW0.mjs";
|
|
9
|
+
import { n as buildBaseOptions, r as clampMaxTokensToModel, t as adjustMaxTokensForThinking } from "./simple-options-7QuSKriJ.mjs";
|
|
10
10
|
import { n as getEnvApiKey } from "./env-api-keys-CyX4VKGO.mjs";
|
|
11
11
|
import { t as createDeferredEventBuffer } from "./deferred-event-buffer-DAvyP7qA.mjs";
|
|
12
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
12
|
+
import { t as createAssistantOutput } from "./assistant-output-D5762GPH.mjs";
|
|
13
13
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-D8f_oxHj.mjs";
|
|
14
14
|
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-DA4WHv1h.mjs";
|
|
15
15
|
import { t as requireApiKey } from "./required-api-key-D4kn3252.mjs";
|
|
@@ -60,7 +60,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
60
60
|
(async () => {
|
|
61
61
|
const output = createAssistantOutput(model);
|
|
62
62
|
const refusalBuffer = usesClaudeStreamingRefusalContract(model) ? createDeferredEventBuffer(stream) : void 0;
|
|
63
|
-
let
|
|
63
|
+
let replayedCompaction;
|
|
64
64
|
try {
|
|
65
65
|
let client;
|
|
66
66
|
let isOAuth;
|
|
@@ -82,7 +82,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
82
82
|
claudeCodeVersion = created.claudeCodeVersion;
|
|
83
83
|
}
|
|
84
84
|
const builtParams = await buildAnthropicRequest(model, requestContext, requestOptions, "provider", isOAuth, serverSideFallback, claudeCodeVersion);
|
|
85
|
-
|
|
85
|
+
replayedCompaction = builtParams.replayedCompaction;
|
|
86
86
|
const { params, headers } = await prepareAnthropicRequest(builtParams.params, model, requestOptions, directApiKeyBetaHeader);
|
|
87
87
|
const sdkRequestOptions = {
|
|
88
88
|
...requestOptions?.signal ? { signal: requestOptions.signal } : {},
|
|
@@ -125,7 +125,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
125
125
|
refusalBuffer.discard();
|
|
126
126
|
output.content = [];
|
|
127
127
|
}
|
|
128
|
-
if (
|
|
128
|
+
if (replayedCompaction && isAnthropicReplayRejection(error)) suppressAnthropicCompaction(output, model, requestOptions, replayedCompaction);
|
|
129
129
|
stream.push({
|
|
130
130
|
type: "error",
|
|
131
131
|
reason: terminal.stopReason,
|
|
@@ -154,6 +154,7 @@ const streamSimpleAnthropic = (model, context, options) => {
|
|
|
154
154
|
anthropicServerCompaction: options?.anthropicServerCompaction,
|
|
155
155
|
anthropicCompactThreshold: options?.anthropicCompactThreshold,
|
|
156
156
|
cacheTtlPruning: options?.cacheTtlPruning,
|
|
157
|
+
onCompactionRejected: options?.onCompactionRejected,
|
|
157
158
|
authProfileId: options?.authProfileId,
|
|
158
159
|
maxTokens: clampMaxTokensToModel(model, options?.maxTokens ?? model.maxTokens),
|
|
159
160
|
toolChoice: options?.toolChoice,
|
|
@@ -165,7 +166,7 @@ const streamSimpleAnthropic = (model, context, options) => {
|
|
|
165
166
|
thinkingEnabled: false
|
|
166
167
|
});
|
|
167
168
|
const reasoning = options?.reasoning === "off" ? "low" : options?.reasoning;
|
|
168
|
-
if (
|
|
169
|
+
if (defaultsClaudeAdaptiveThinking(model) || reasoning && supportsClaudeAdaptiveThinking(model)) return streamAnthropic(model, context, {
|
|
169
170
|
...base,
|
|
170
171
|
thinkingEnabled: true,
|
|
171
172
|
effort: resolveAnthropicThinkingEffort(model, reasoning)
|
package/dist/{anthropic-payload-policy-BhCcgNdm.d.mts → anthropic-payload-policy-DD7vzpxE.d.mts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
1
|
+
import "./index-D27wAoOr.mjs";
|
|
2
2
|
import { k as Model } from "./types-DvzmWW8J.mjs";
|
|
3
|
-
import { t as AnthropicContextManagementOptions } from "./provider-options-
|
|
3
|
+
import { t as AnthropicContextManagementOptions } from "./provider-options-CkieKvNJ.mjs";
|
|
4
4
|
import { TextBlockParam } from "@anthropic-ai/sdk/resources/messages.js";
|
|
5
5
|
//#region packages/ai/src/transports/anthropic-payload-policy.d.ts
|
|
6
6
|
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
@@ -37,9 +37,12 @@ type AnthropicPayloadPolicy = {
|
|
|
37
37
|
};
|
|
38
38
|
/** Resolve the server-compaction gate and effective threshold for an Anthropic route. */
|
|
39
39
|
declare function resolveAnthropicServerCompactionPlan(model: {
|
|
40
|
+
id?: string;
|
|
41
|
+
params?: Record<string, unknown>;
|
|
40
42
|
provider?: unknown;
|
|
41
43
|
api?: unknown;
|
|
42
44
|
baseUrl?: string;
|
|
45
|
+
contextTokens?: unknown;
|
|
43
46
|
contextWindow?: unknown;
|
|
44
47
|
}, extraParams?: Record<string, unknown>, apiKey?: string): {
|
|
45
48
|
enabled: boolean;
|
package/dist/{anthropic-stream-reducer-BQ1tjd7x.mjs → anthropic-stream-reducer-CWyWE21W.mjs}
RENAMED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { E as
|
|
1
|
+
import { E as supportsClaudeInHistorySystemMessages, O as supportsClaudeNativeXhighEffort, S as resolveClaudeSonnet5ModelIdentity, b as resolveClaudeOpus5ModelIdentity, d as requiresClaudeBetweenToolsThinking, g as resolveClaudeModelIdentity, h as resolveClaudeHaiku55ModelIdentity, k as supportsClaudeServerCompaction, m as resolveClaudeFable5ModelIdentity, u as bindsClaudeThinkingPrefix, w as supportsClaudeAdaptiveThinking, x as resolveClaudeSonnet55ModelIdentity, y as resolveClaudeOpus55ModelIdentity } from "./src-VWy9E7DZ.mjs";
|
|
2
2
|
import { f as hasRuntimeContextMarker } from "./types-CQc6JNG4.mjs";
|
|
3
3
|
import { r as appendAssistantThinking } from "./event-stream-C5AbCAaZ.mjs";
|
|
4
4
|
import { a as asRecord, o as isRecord, r as asOptionalObjectRecord, s as readStringField } from "./record-coerce-CNDovvft.mjs";
|
|
5
5
|
import { i as normalizeOptionalLowercaseString, r as normalizeNullableString } from "./string-coerce-CtgOVOSv.mjs";
|
|
6
6
|
import { n as asNonNegativeFiniteNumber } from "./number-coercion-V8-BhME4.mjs";
|
|
7
|
-
import { N as isImageWithMediaPayload, O as calculateCost, S as resolveAnthropicThinkingEffort, g as applyClaudeRequestContract, h as ANTHROPIC_CLAUDE_CODE_VERSION, r as getAiTransportHost, u as STREAM_ERROR_FALLBACK_TEXT, v as defaultsClaudeAdaptiveThinking, w as usesClaudeFable5MessagesContract, x as requiresClaudeAdaptiveThinking, y as mapAnthropicStopReason } from "./host-
|
|
8
|
-
import "./text-signature-
|
|
7
|
+
import { N as isImageWithMediaPayload, O as calculateCost, S as resolveAnthropicThinkingEffort, g as applyClaudeRequestContract, h as ANTHROPIC_CLAUDE_CODE_VERSION, r as getAiTransportHost, u as STREAM_ERROR_FALLBACK_TEXT, v as defaultsClaudeAdaptiveThinking, w as usesClaudeFable5MessagesContract, x as requiresClaudeAdaptiveThinking, y as mapAnthropicStopReason } from "./host-u3o8XiAp.mjs";
|
|
8
|
+
import "./text-signature-D_vRrx-z.mjs";
|
|
9
9
|
import { n as estimateBase64DecodedBytes } from "./base64-C8CdcsjU.mjs";
|
|
10
|
-
import { a as resolveProviderRequestCapabilities, i as resolveProviderEndpoint } from "./host-policy-
|
|
10
|
+
import { a as resolveProviderRequestCapabilities, i as resolveProviderEndpoint } from "./host-policy-BwhNNGQR.mjs";
|
|
11
11
|
import { i as resolveCacheRetention } from "./cloudflare-5qSGvIUH.mjs";
|
|
12
|
-
import { C as parseJsonObjectPreservingUnsafeIntegers, E as createToolArgumentPreviewSchedule, O as parseStreamingJson, P as sanitizeSurrogates, _ as sanitizeNonEmptyTransportPayloadText, b as transportAbortError, d as iterateModelStream, i as copyProviderAcceptanceObserver, l as finalizeTerminalToolCallArguments, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-
|
|
13
|
-
import { C as stripSystemPromptCacheBoundary, D as sortPromptCacheToolsByName, d as describeToolResultMediaPlaceholder, m as extractToolResultText, p as extractToolResultBlockText, t as adjustMaxTokensForThinking, w as stripSystemPromptRelocatableBoundary, x as splitSystemPromptCacheBoundary } from "./simple-options-
|
|
12
|
+
import { C as parseJsonObjectPreservingUnsafeIntegers, E as createToolArgumentPreviewSchedule, O as parseStreamingJson, P as sanitizeSurrogates, _ as sanitizeNonEmptyTransportPayloadText, b as transportAbortError, d as iterateModelStream, i as copyProviderAcceptanceObserver, l as finalizeTerminalToolCallArguments, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-CCR7hSW0.mjs";
|
|
13
|
+
import { C as stripSystemPromptCacheBoundary, D as sortPromptCacheToolsByName, d as describeToolResultMediaPlaceholder, m as extractToolResultText, p as extractToolResultBlockText, t as adjustMaxTokensForThinking, w as stripSystemPromptRelocatableBoundary, x as splitSystemPromptCacheBoundary } from "./simple-options-7QuSKriJ.mjs";
|
|
14
14
|
import { t as parsePositiveInteger } from "./positive-integer-CwLi8LUL.mjs";
|
|
15
|
-
import { n as isProviderReplayContext, r as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-
|
|
16
|
-
import { n as transformProviderMessages } from "./assistant-output-
|
|
15
|
+
import { n as isProviderReplayContext, r as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-CO_Eplnc.mjs";
|
|
16
|
+
import { n as transformProviderMessages } from "./assistant-output-D5762GPH.mjs";
|
|
17
17
|
import { i as SCHEMA_MAP_KEYS, n as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-Ct8SeBeJ.mjs";
|
|
18
|
-
import { i as tagPendingCommentaryText } from "./assistant-text-phase-
|
|
18
|
+
import { i as tagPendingCommentaryText } from "./assistant-text-phase-DVZOxbuR.mjs";
|
|
19
19
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-D8f_oxHj.mjs";
|
|
20
20
|
//#region packages/ai/src/providers/anthropic-auth-headers.ts
|
|
21
21
|
/** Inspect resolved credential shape for auth routing without exposing its value. */
|
|
@@ -126,19 +126,22 @@ function applyAnthropicFallbackBoundary(params) {
|
|
|
126
126
|
//#region packages/ai/src/transports/anthropic-payload-policy.ts
|
|
127
127
|
const ANTHROPIC_CACHE_CONTROL_LIMIT = 4;
|
|
128
128
|
const ANTHROPIC_COMPACT_THRESHOLD_MIN = 5e4;
|
|
129
|
+
const ANTHROPIC_COMPACTION_INSTRUCTIONS = "Summarize the transcript inside <summary></summary> tags. Include the current state, decisions, and next steps needed to continue the task in the next context window. Do not call any tools while writing this summary; respond with text only.";
|
|
129
130
|
/** Resolve the Anthropic input-token trigger, including the API's minimum. */
|
|
130
|
-
function resolveAnthropicCompactThreshold(
|
|
131
|
+
function resolveAnthropicCompactThreshold(model, configured) {
|
|
131
132
|
const configuredThreshold = parsePositiveInteger(configured);
|
|
132
133
|
if (configuredThreshold !== void 0) return Math.max(ANTHROPIC_COMPACT_THRESHOLD_MIN, configuredThreshold);
|
|
133
|
-
const
|
|
134
|
-
|
|
134
|
+
const contextTokens = parsePositiveInteger(model.contextTokens);
|
|
135
|
+
const contextWindow = parsePositiveInteger(model.contextWindow);
|
|
136
|
+
return Math.max(ANTHROPIC_COMPACT_THRESHOLD_MIN, Math.floor((contextTokens && contextWindow ? Math.min(contextTokens, contextWindow) : contextTokens ?? contextWindow ?? 0) * .7));
|
|
135
137
|
}
|
|
136
138
|
/** Resolve the server-compaction gate and effective threshold for an Anthropic route. */
|
|
137
139
|
function resolveAnthropicServerCompactionPlan(model, extraParams, apiKey) {
|
|
138
|
-
const
|
|
140
|
+
const configured = extraParams?.anthropicServerCompaction;
|
|
141
|
+
const enabled = configured !== false && (configured === true || supportsClaudeServerCompaction(model)) && !isAnthropicOAuthApiKey(apiKey) && normalizeOptionalLowercaseString(model.api) === "anthropic-messages" && isDirectAnthropicModel(model);
|
|
139
142
|
return {
|
|
140
143
|
enabled,
|
|
141
|
-
...enabled ? { threshold: resolveAnthropicCompactThreshold(model
|
|
144
|
+
...enabled ? { threshold: resolveAnthropicCompactThreshold(model, extraParams?.anthropicCompactThreshold) } : {}
|
|
142
145
|
};
|
|
143
146
|
}
|
|
144
147
|
function isDirectAnthropicModel(model, env = process.env) {
|
|
@@ -264,44 +267,29 @@ function stripAnthropicSystemPromptBoundary(system) {
|
|
|
264
267
|
/** Apply one shared deepest-stable-message cache breakpoint policy. */
|
|
265
268
|
function applyAnthropicCacheControlToMessages(messages, cacheControl, markerLimit, cacheBreakpointOptOutMessageIndexes) {
|
|
266
269
|
if (!Array.isArray(messages) || messages.length === 0 || markerLimit <= 0) return;
|
|
267
|
-
let
|
|
268
|
-
for (
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const record =
|
|
272
|
-
if (record.role !== "user"
|
|
270
|
+
let stableEnd = messages.length;
|
|
271
|
+
for (const index of cacheBreakpointOptOutMessageIndexes) stableEnd = Math.min(stableEnd, index);
|
|
272
|
+
let marked = 0;
|
|
273
|
+
for (let i = stableEnd - 1; i >= 0 && marked < Math.min(markerLimit, 2); i--) {
|
|
274
|
+
const record = messages[i];
|
|
275
|
+
if (!isRecord(record) || record.role !== "user") continue;
|
|
273
276
|
const content = record.content;
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}];
|
|
284
|
-
if (fallbackToolResult && markerLimit > 1) fallbackToolResult.cache_control = cacheControl;
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
if (!Array.isArray(content)) continue;
|
|
288
|
-
for (let j = content.length - 1; j >= 0; j--) {
|
|
289
|
-
const block = content[j];
|
|
290
|
-
if (!block || typeof block !== "object") continue;
|
|
291
|
-
const blockRecord = block;
|
|
292
|
-
if (blockRecord.type === "text" || blockRecord.type === "image") {
|
|
293
|
-
if (fallbackToolResult && markerLimit === 1) {
|
|
294
|
-
fallbackToolResult.cache_control = cacheControl;
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
277
|
+
const blocks = typeof content === "string" ? [{
|
|
278
|
+
type: "text",
|
|
279
|
+
text: content
|
|
280
|
+
}] : content;
|
|
281
|
+
if (!Array.isArray(blocks)) continue;
|
|
282
|
+
for (let j = blocks.length - 1; j >= 0; j--) {
|
|
283
|
+
const blockRecord = blocks[j];
|
|
284
|
+
if (!isRecord(blockRecord)) continue;
|
|
285
|
+
if (blockRecord.type === "text" || blockRecord.type === "image" || blockRecord.type === "tool_result") {
|
|
297
286
|
blockRecord.cache_control = cacheControl;
|
|
298
|
-
if (
|
|
299
|
-
|
|
287
|
+
if (typeof content === "string") record.content = blocks;
|
|
288
|
+
marked++;
|
|
289
|
+
break;
|
|
300
290
|
}
|
|
301
|
-
if (blockRecord.type === "tool_result" && fallbackToolResult === void 0) fallbackToolResult = blockRecord;
|
|
302
291
|
}
|
|
303
292
|
}
|
|
304
|
-
if (fallbackToolResult) fallbackToolResult.cache_control = cacheControl;
|
|
305
293
|
}
|
|
306
294
|
function countAnthropicCacheControlMarkers(blocks) {
|
|
307
295
|
if (!Array.isArray(blocks)) return 0;
|
|
@@ -322,7 +310,7 @@ function resolveAnthropicPayloadPolicy(input, model) {
|
|
|
322
310
|
return {
|
|
323
311
|
allowsServiceTier: capabilities.allowsAnthropicServiceTier,
|
|
324
312
|
cacheControl: input.enableCacheControl === true ? resolveAnthropicEphemeralCacheControl(input.baseUrl, input.cacheRetention) : void 0,
|
|
325
|
-
compactThreshold: serverCompactionPlan.threshold ?? resolveAnthropicCompactThreshold(input
|
|
313
|
+
compactThreshold: serverCompactionPlan.threshold ?? resolveAnthropicCompactThreshold(input, input.extraParams?.anthropicCompactThreshold),
|
|
326
314
|
serviceTier: input.serviceTier,
|
|
327
315
|
useServerCompaction: input.enableServerCompaction === true && serverCompactionPlan.enabled,
|
|
328
316
|
...input.cacheTtlPruning && normalizeOptionalLowercaseString(input.api) === "anthropic-messages" && isDirectAnthropicModel(input) ? { toolClearing: {
|
|
@@ -375,7 +363,8 @@ function applyAnthropicContextManagementEdits(payload, policy) {
|
|
|
375
363
|
trigger: {
|
|
376
364
|
type: "input_tokens",
|
|
377
365
|
value: policy.compactThreshold
|
|
378
|
-
}
|
|
366
|
+
},
|
|
367
|
+
instructions: ANTHROPIC_COMPACTION_INSTRUCTIONS
|
|
379
368
|
});
|
|
380
369
|
if (edits.length > 0) payload.context_management = { edits };
|
|
381
370
|
}
|
|
@@ -384,7 +373,7 @@ function applyAnthropicContextManagementToRequest(payload, model, options, direc
|
|
|
384
373
|
applyAnthropicContextManagementEdits(payload, resolveAnthropicPayloadPolicy({
|
|
385
374
|
...model,
|
|
386
375
|
api: "anthropic-messages",
|
|
387
|
-
enableServerCompaction: true,
|
|
376
|
+
enableServerCompaction: options?.anthropicServerCompaction === true,
|
|
388
377
|
extraParams: { ...options },
|
|
389
378
|
cacheTtlPruning: options?.cacheTtlPruning
|
|
390
379
|
}));
|
|
@@ -509,7 +498,11 @@ function captureAnthropicCompaction(output, capture, model, options) {
|
|
|
509
498
|
baseUrlHash: context.baseUrlHash
|
|
510
499
|
};
|
|
511
500
|
}
|
|
512
|
-
|
|
501
|
+
/**
|
|
502
|
+
* Record a rejected replay on the failed output and notify the transcript owner, which must
|
|
503
|
+
* durably strip the checkpoint: hosts may persist failed turns without their replay state.
|
|
504
|
+
*/
|
|
505
|
+
function suppressAnthropicCompaction(output, model, options, rejected) {
|
|
513
506
|
const context = buildProviderReplayContext(model, options);
|
|
514
507
|
if (!context.baseUrlHash) return;
|
|
515
508
|
output.providerReplay = {
|
|
@@ -519,6 +512,7 @@ function suppressAnthropicCompaction(output, model, options) {
|
|
|
519
512
|
...context,
|
|
520
513
|
baseUrlHash: context.baseUrlHash
|
|
521
514
|
};
|
|
515
|
+
options?.onCompactionRejected?.({ data: rejected.content });
|
|
522
516
|
}
|
|
523
517
|
function resolveNewestAnthropicCompaction(messages, model, options) {
|
|
524
518
|
const context = buildProviderReplayContext(model, options);
|
|
@@ -849,7 +843,7 @@ function resolveAnthropicTransportOptions(model, options, apiKey) {
|
|
|
849
843
|
modelContextWindow: model.contextWindow,
|
|
850
844
|
modelMaxTokens: model.maxTokens,
|
|
851
845
|
requestedMaxTokens: options?.maxTokens,
|
|
852
|
-
useModelDefault: resolveClaudeSonnet5ModelIdentity(model) !== void 0 || resolveClaudeOpus5ModelIdentity(model) !== void 0
|
|
846
|
+
useModelDefault: resolveClaudeHaiku55ModelIdentity(model) !== void 0 || resolveClaudeSonnet5ModelIdentity(model) !== void 0 || resolveClaudeOpus5ModelIdentity(model) !== void 0
|
|
853
847
|
});
|
|
854
848
|
if (baseMaxTokens === void 0) throw new Error(`Anthropic Messages transport requires a positive maxTokens value for ${model.provider}/${model.id}`);
|
|
855
849
|
const reasoningModelMaxTokens = resolvePositiveAnthropicTokenLimit(model.maxTokens) ?? baseMaxTokens;
|
|
@@ -1120,7 +1114,7 @@ function buildAnthropicGenerationParams({ model, options, tools, toolProjection,
|
|
|
1120
1114
|
if (typeof userId === "string") params.metadata = { user_id: userId };
|
|
1121
1115
|
}
|
|
1122
1116
|
if (options?.toolChoice) {
|
|
1123
|
-
const normalizedToolChoice = normalizeAnthropicToolChoice(mandatoryAdaptiveThinking || options?.thinkingEnabled === true || resolveClaudeSonnet55ModelIdentity(model) !== void 0, options.toolChoice);
|
|
1117
|
+
const normalizedToolChoice = normalizeAnthropicToolChoice(resolveClaudeHaiku55ModelIdentity(model) === void 0 && (mandatoryAdaptiveThinking || options?.thinkingEnabled === true || resolveClaudeSonnet55ModelIdentity(model) !== void 0), options.toolChoice);
|
|
1124
1118
|
const projectedToolChoice = toolProjection ? reconcileAnthropicToolChoice(normalizedToolChoice, toolProjection) : normalizedToolChoice;
|
|
1125
1119
|
if (projectedToolChoice) params.tool_choice = projectedToolChoice;
|
|
1126
1120
|
}
|
|
@@ -1191,7 +1185,7 @@ async function buildAnthropicRequest(model, context, options, profile, isOAuthTo
|
|
|
1191
1185
|
return {
|
|
1192
1186
|
params,
|
|
1193
1187
|
toolProjection,
|
|
1194
|
-
|
|
1188
|
+
replayedCompaction: replayPlan.compaction
|
|
1195
1189
|
};
|
|
1196
1190
|
}
|
|
1197
1191
|
/** Apply caller payload edits before restoring required request contracts and beta headers. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./index-
|
|
1
|
+
import "./index-D27wAoOr.mjs";
|
|
2
2
|
import { Q as SimpleStreamOptions, n as Api, nt as StreamOptions, tt as StreamFunction } from "./types-DvzmWW8J.mjs";
|
|
3
3
|
//#region packages/ai/src/api-registry.d.ts
|
|
4
4
|
/** Runtime stream adapter signature stored in the API provider registry. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as transformMessages } from "./host-
|
|
2
|
-
import { a as createEmptyTransportUsage } from "./transport-stream-shared-
|
|
1
|
+
import { c as transformMessages } from "./host-u3o8XiAp.mjs";
|
|
2
|
+
import { a as createEmptyTransportUsage } from "./transport-stream-shared-CCR7hSW0.mjs";
|
|
3
3
|
//#region packages/ai/src/provider-transcript-transform.ts
|
|
4
4
|
const IMAGE_OMISSION = "(image omitted: model does not support images)";
|
|
5
5
|
const VIDEO_OMISSION = "(video omitted: provider does not support video input)";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as encodeTextSignatureV1 } from "./text-signature-
|
|
1
|
+
import { t as encodeTextSignatureV1 } from "./text-signature-D_vRrx-z.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
//#region packages/ai/src/utils/assistant-text-phase.ts
|
|
4
4
|
const EMPTY_ASSISTANT_TEXT_BLOCK_SET = /* @__PURE__ */ new Set();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-C5AbCAaZ.mjs";
|
|
2
|
-
import { r as getAiTransportHost } from "./host-
|
|
3
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
4
|
-
import { g as resolveOpenAISimpleReasoningEffort, k as resolvePromptCacheKey } from "./openai-transport-params-
|
|
2
|
+
import { r as getAiTransportHost } from "./host-u3o8XiAp.mjs";
|
|
3
|
+
import { n as buildBaseOptions } from "./simple-options-7QuSKriJ.mjs";
|
|
4
|
+
import { g as resolveOpenAISimpleReasoningEffort, k as resolvePromptCacheKey } from "./openai-transport-params-D7JMUPjf.mjs";
|
|
5
5
|
import { n as getEnvApiKey } from "./env-api-keys-CyX4VKGO.mjs";
|
|
6
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
7
|
-
import { P as convertProviderResponsesMessages, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams } from "./openai-responses-shared-
|
|
6
|
+
import { t as createAssistantOutput } from "./assistant-output-D5762GPH.mjs";
|
|
7
|
+
import { P as convertProviderResponsesMessages, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams } from "./openai-responses-shared-CKNmC3vC.mjs";
|
|
8
8
|
import { i as resolveAzureDeploymentNameFromMap, n as isTraditionalAzureOpenAIHost, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-D0dvJMbZ.mjs";
|
|
9
9
|
import { t as requireApiKey } from "./required-api-key-D4kn3252.mjs";
|
|
10
10
|
import OpenAI, { AzureOpenAI } from "openai";
|
package/dist/diagnostics.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as ProviderRefusalReview, o as readProviderRefusalReview } from "./index-
|
|
1
|
+
import { a as ProviderRefusalReview, o as readProviderRefusalReview } from "./index-D27wAoOr.mjs";
|
|
2
2
|
import { At as extractDiagnosticError, Dt as DiagnosticErrorInfo, Et as AssistantMessageDiagnostic, Mt as isProviderRefusalAssistantError, Ot as appendAssistantMessageDiagnostic, a as AssistantMessage, jt as formatThrownValue, kt as createAssistantMessageDiagnostic } from "./types-DvzmWW8J.mjs";
|
|
3
|
-
import "./types-
|
|
4
|
-
import { n as isResponsesOutputLimitToolCallError } from "./openai-responses-terminal-usage-
|
|
3
|
+
import "./types-UlNana-2.mjs";
|
|
4
|
+
import { n as isResponsesOutputLimitToolCallError } from "./openai-responses-terminal-usage-CempLedn.mjs";
|
|
5
5
|
import { n as ProviderErrorRedactor, r as configureProviderErrorRedactor } from "./provider-error-xumb1V3F.mjs";
|
|
6
6
|
import { r as projectDiagnosticValue, t as DiagnosticProjectionPolicy } from "./credential-redaction-BKv49aiv.mjs";
|
|
7
7
|
import { n as formatModelTransportDebugUrl, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./model-transport-url-C5f59L3Y.mjs";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region packages/ai/src/env-api-keys.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Find configured environment variables that can provide an API key for a provider.
|
|
4
|
+
*
|
|
5
|
+
* This only reports actual API key variables. It intentionally excludes ambient
|
|
6
|
+
* credential sources such as AWS profiles, AWS IAM credentials, and Google
|
|
7
|
+
* Application Default Credentials.
|
|
8
|
+
*/
|
|
9
|
+
declare function findEnvKeys(provider: string): string[] | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Get API key for provider from known environment variables, e.g. OPENAI_API_KEY.
|
|
12
|
+
*
|
|
13
|
+
* Will not return API keys for providers that require OAuth tokens.
|
|
14
|
+
*/
|
|
15
|
+
declare function getEnvApiKey(provider: string): string | undefined;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { getEnvApiKey as n, findEnvKeys as t };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-C5AbCAaZ.mjs";
|
|
2
|
-
import { a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-
|
|
3
|
-
import { n as buildManagedModelFetch } from "./host-policy-
|
|
4
|
-
import { f as mergeTransportHeaders } from "./transport-stream-shared-
|
|
5
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
2
|
+
import { a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-u3o8XiAp.mjs";
|
|
3
|
+
import { n as buildManagedModelFetch } from "./host-policy-BwhNNGQR.mjs";
|
|
4
|
+
import { f as mergeTransportHeaders } from "./transport-stream-shared-CCR7hSW0.mjs";
|
|
5
|
+
import { n as buildBaseOptions } from "./simple-options-7QuSKriJ.mjs";
|
|
6
6
|
import { n as getEnvApiKey } from "./env-api-keys-CyX4VKGO.mjs";
|
|
7
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
7
|
+
import { t as createAssistantOutput } from "./assistant-output-D5762GPH.mjs";
|
|
8
8
|
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-DA4WHv1h.mjs";
|
|
9
9
|
import { t as requireApiKey } from "./required-api-key-D4kn3252.mjs";
|
|
10
|
-
import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-
|
|
10
|
+
import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-V8jogVPq.mjs";
|
|
11
11
|
import { GoogleGenAI } from "@google/genai";
|
|
12
12
|
//#region packages/ai/src/providers/google.ts
|
|
13
13
|
let toolCallCounter = 0;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-C5AbCAaZ.mjs";
|
|
2
2
|
import { a as asRecord, i as asOptionalRecord, s as readStringField } from "./record-coerce-CNDovvft.mjs";
|
|
3
|
-
import { O as calculateCost, a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-
|
|
4
|
-
import { t as buildGuardedModelFetch } from "./host-policy-
|
|
5
|
-
import { P as sanitizeSurrogates, b as transportAbortError, c as failTransportStream, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, m as notifyProviderHttpResponse, w as parseJsonPreservingUnsafeIntegers } from "./transport-stream-shared-
|
|
6
|
-
import { C as stripSystemPromptCacheBoundary, n as buildBaseOptions } from "./simple-options-
|
|
3
|
+
import { O as calculateCost, a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-u3o8XiAp.mjs";
|
|
4
|
+
import { t as buildGuardedModelFetch } from "./host-policy-BwhNNGQR.mjs";
|
|
5
|
+
import { P as sanitizeSurrogates, b as transportAbortError, c as failTransportStream, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, m as notifyProviderHttpResponse, w as parseJsonPreservingUnsafeIntegers } from "./transport-stream-shared-CCR7hSW0.mjs";
|
|
6
|
+
import { C as stripSystemPromptCacheBoundary, n as buildBaseOptions } from "./simple-options-7QuSKriJ.mjs";
|
|
7
7
|
import { n as getEnvApiKey } from "./env-api-keys-CyX4VKGO.mjs";
|
|
8
|
-
import { n as transformProviderMessages, t as createAssistantOutput } from "./assistant-output-
|
|
9
|
-
import { n as buildGoogleInteractionsSimpleThinking } from "./google-shared-
|
|
8
|
+
import { n as transformProviderMessages, t as createAssistantOutput } from "./assistant-output-D5762GPH.mjs";
|
|
9
|
+
import { n as buildGoogleInteractionsSimpleThinking } from "./google-shared-V8jogVPq.mjs";
|
|
10
10
|
import { createRequire } from "node:module";
|
|
11
11
|
//#region packages/ai/src/providers/google-interactions-request.ts
|
|
12
12
|
const DEFAULT_GOOGLE_API_BASE_URL = "https://generativelanguage.googleapis.com";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as appendAssistantThinking } from "./event-stream-C5AbCAaZ.mjs";
|
|
2
|
-
import { N as isImageWithMediaPayload, O as calculateCost } from "./host-
|
|
3
|
-
import { P as sanitizeSurrogates, a as createEmptyTransportUsage, b as transportAbortError, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-
|
|
4
|
-
import { D as sortPromptCacheToolsByName, d as describeToolResultMediaPlaceholder, m as extractToolResultText } from "./simple-options-
|
|
2
|
+
import { N as isImageWithMediaPayload, O as calculateCost } from "./host-u3o8XiAp.mjs";
|
|
3
|
+
import { P as sanitizeSurrogates, a as createEmptyTransportUsage, b as transportAbortError, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-CCR7hSW0.mjs";
|
|
4
|
+
import { D as sortPromptCacheToolsByName, d as describeToolResultMediaPlaceholder, m as extractToolResultText } from "./simple-options-7QuSKriJ.mjs";
|
|
5
5
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-D8f_oxHj.mjs";
|
|
6
6
|
//#region packages/ai/src/transports/google-thinking-level.ts
|
|
7
7
|
/** Returns whether a Gemini Flash model accepts the MINIMAL thinking level. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { k as clampThinkingLevel } from "./host-
|
|
2
|
-
import { P as sanitizeSurrogates, b as transportAbortError, c as failTransportStream, h as notifyProviderStreamOpened } from "./transport-stream-shared-
|
|
3
|
-
import { C as stripSystemPromptCacheBoundary } from "./simple-options-
|
|
4
|
-
import { n as transformProviderMessages } from "./assistant-output-
|
|
5
|
-
import { a as googleFlashSupportsMinimalThinking, i as consumeGoogleGenerateContentStream, n as projectGoogleMessages, r as requiresGoogleToolCallId, t as convertGoogleTools } from "./google-messages-
|
|
1
|
+
import { k as clampThinkingLevel } from "./host-u3o8XiAp.mjs";
|
|
2
|
+
import { P as sanitizeSurrogates, b as transportAbortError, c as failTransportStream, h as notifyProviderStreamOpened } from "./transport-stream-shared-CCR7hSW0.mjs";
|
|
3
|
+
import { C as stripSystemPromptCacheBoundary } from "./simple-options-7QuSKriJ.mjs";
|
|
4
|
+
import { n as transformProviderMessages } from "./assistant-output-D5762GPH.mjs";
|
|
5
|
+
import { a as googleFlashSupportsMinimalThinking, i as consumeGoogleGenerateContentStream, n as projectGoogleMessages, r as requiresGoogleToolCallId, t as convertGoogleTools } from "./google-messages-l7wgIF5I.mjs";
|
|
6
6
|
import { FunctionCallingConfigMode, ThinkingLevel } from "@google/genai";
|
|
7
7
|
//#region packages/ai/src/providers/google-shared.ts
|
|
8
8
|
function convertMessages(model, context) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-C5AbCAaZ.mjs";
|
|
2
2
|
import { a as normalizeOptionalString } from "./string-coerce-CtgOVOSv.mjs";
|
|
3
|
-
import { a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-
|
|
4
|
-
import { n as buildManagedModelFetch } from "./host-policy-
|
|
5
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
6
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
7
|
-
import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-
|
|
3
|
+
import { a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-u3o8XiAp.mjs";
|
|
4
|
+
import { n as buildManagedModelFetch } from "./host-policy-BwhNNGQR.mjs";
|
|
5
|
+
import { n as buildBaseOptions } from "./simple-options-7QuSKriJ.mjs";
|
|
6
|
+
import { t as createAssistantOutput } from "./assistant-output-D5762GPH.mjs";
|
|
7
|
+
import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-V8jogVPq.mjs";
|
|
8
8
|
import { GoogleGenAI, ResourceScope } from "@google/genai";
|
|
9
9
|
//#region packages/ai/src/providers/google-vertex.ts
|
|
10
10
|
const API_VERSION = "v1";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
1
|
+
import "./index-D27wAoOr.mjs";
|
|
2
2
|
import { d as Context, et as StreamFn, k as Model, n as Api } from "./types-DvzmWW8J.mjs";
|
|
3
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
3
|
+
import { n as ApiRegistry } from "./api-registry-B3rC2qu3.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 {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as getAiTransportHost } from "./host-
|
|
1
|
+
import { r as getAiTransportHost } from "./host-u3o8XiAp.mjs";
|
|
2
2
|
//#region packages/ai/src/transports/host-policy.ts
|
|
3
3
|
function buildGuardedModelFetch(model, timeoutMs, options) {
|
|
4
4
|
const host = getAiTransportHost();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as supportsClaudeNativeMaxEffort, O as supportsClaudeNativeXhighEffort, S as resolveClaudeSonnet5ModelIdentity, _ as resolveClaudeMythos5ModelIdentity, a as CLAUDE_HAIKU_55_THINKING_PROFILE, b as resolveClaudeOpus5ModelIdentity, c as CLAUDE_SONNET_55_THINKING_PROFILE, f as requiresClaudeDefaultSampling, h as resolveClaudeHaiku55ModelIdentity, i as CLAUDE_FABLE_5_THINKING_PROFILE, m as resolveClaudeFable5ModelIdentity, o as CLAUDE_OPUS_55_THINKING_PROFILE, p as requiresClaudeMandatoryAdaptiveThinking, t as calculateUsageCost, v as resolveClaudeNativeThinkingLevelMap, x as resolveClaudeSonnet55ModelIdentity, y as resolveClaudeOpus55ModelIdentity } from "./src-VWy9E7DZ.mjs";
|
|
2
2
|
import { t as DEFAULT_MISSING_TOOL_RESULT_TEXT } from "./types-CQc6JNG4.mjs";
|
|
3
3
|
import { i as asOptionalRecord, o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
4
4
|
import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-CtgOVOSv.mjs";
|
|
@@ -113,7 +113,7 @@ function usesClaudeFable5MessagesContract(model) {
|
|
|
113
113
|
/** Return whether streamed output must wait for the terminal refusal decision. */
|
|
114
114
|
function usesClaudeStreamingRefusalContract(model) {
|
|
115
115
|
if (normalizeApi(model.api) !== "anthropic-messages") return false;
|
|
116
|
-
return resolveClaudeFable5ModelIdentity(model) !== void 0 || resolveClaudeMythos5ModelIdentity(model) !== void 0 || resolveClaudeOpus5ModelIdentity(model) !== void 0 || resolveClaudeSonnet5ModelIdentity(model) !== void 0;
|
|
116
|
+
return resolveClaudeHaiku55ModelIdentity(model) !== void 0 || resolveClaudeFable5ModelIdentity(model) !== void 0 || resolveClaudeMythos5ModelIdentity(model) !== void 0 || resolveClaudeOpus5ModelIdentity(model) !== void 0 || resolveClaudeSonnet5ModelIdentity(model) !== void 0;
|
|
117
117
|
}
|
|
118
118
|
function requiresClaudeAdaptiveThinking(model) {
|
|
119
119
|
if (normalizeApi(model.api) !== "anthropic-messages") return false;
|
|
@@ -121,11 +121,11 @@ function requiresClaudeAdaptiveThinking(model) {
|
|
|
121
121
|
}
|
|
122
122
|
/** Return whether omitted thinking should default to adaptive mode. */
|
|
123
123
|
function defaultsClaudeAdaptiveThinking(model) {
|
|
124
|
-
return requiresClaudeAdaptiveThinking(model) || normalizeApi(model.api) === "anthropic-messages" && (resolveClaudeOpus5ModelIdentity(model) !== void 0 || resolveClaudeSonnet5ModelIdentity(model) !== void 0);
|
|
124
|
+
return requiresClaudeAdaptiveThinking(model) || normalizeApi(model.api) === "anthropic-messages" && (resolveClaudeOpus5ModelIdentity(model) !== void 0 || resolveClaudeHaiku55ModelIdentity(model) !== void 0 || resolveClaudeSonnet5ModelIdentity(model) !== void 0);
|
|
125
125
|
}
|
|
126
126
|
/** Resolve provider-native effort once for direct and managed Claude requests. */
|
|
127
127
|
function resolveAnthropicThinkingEffort(model, level) {
|
|
128
|
-
const requestedLevel = level ?? (resolveClaudeOpus55ModelIdentity(model) ? CLAUDE_OPUS_55_THINKING_PROFILE.defaultLevel : resolveClaudeSonnet55ModelIdentity(model) ? CLAUDE_SONNET_55_THINKING_PROFILE.defaultLevel : resolveClaudeFable5ModelIdentity(model) ? CLAUDE_FABLE_5_THINKING_PROFILE.defaultLevel : void 0);
|
|
128
|
+
const requestedLevel = level ?? (resolveClaudeHaiku55ModelIdentity(model) ? CLAUDE_HAIKU_55_THINKING_PROFILE.defaultLevel : resolveClaudeOpus55ModelIdentity(model) ? CLAUDE_OPUS_55_THINKING_PROFILE.defaultLevel : resolveClaudeSonnet55ModelIdentity(model) ? CLAUDE_SONNET_55_THINKING_PROFILE.defaultLevel : resolveClaudeFable5ModelIdentity(model) ? CLAUDE_FABLE_5_THINKING_PROFILE.defaultLevel : void 0);
|
|
129
129
|
const thinkingLevelMap = resolveClaudeNativeThinkingLevelMap(model);
|
|
130
130
|
const clampModel = {
|
|
131
131
|
...model,
|
|
@@ -162,7 +162,7 @@ function mapAnthropicStopReason(reason) {
|
|
|
162
162
|
}
|
|
163
163
|
/** Remove unsupported assistant prefills while preserving completed tool-use turns. */
|
|
164
164
|
function prepareClaudeNoPrefillRequestContext(model, context) {
|
|
165
|
-
if (!resolveClaudeOpus5ModelIdentity(model) && !resolveClaudeSonnet5ModelIdentity(model)) return context;
|
|
165
|
+
if (!resolveClaudeOpus5ModelIdentity(model) && !resolveClaudeSonnet5ModelIdentity(model) && !resolveClaudeHaiku55ModelIdentity(model)) return context;
|
|
166
166
|
let end = context.messages.length;
|
|
167
167
|
while (end > 0) {
|
|
168
168
|
const message = context.messages[end - 1];
|
|
@@ -178,11 +178,12 @@ function applyClaudeRequestContract(params, model) {
|
|
|
178
178
|
if (normalizeApi(model.api) !== "anthropic-messages") return;
|
|
179
179
|
const opus5 = resolveClaudeOpus5ModelIdentity(model) !== void 0;
|
|
180
180
|
const sonnet5 = resolveClaudeSonnet5ModelIdentity(model) !== void 0;
|
|
181
|
+
const haiku55 = resolveClaudeHaiku55ModelIdentity(model) !== void 0;
|
|
181
182
|
if (!requiresClaudeDefaultSampling(model) && !opus5 && !sonnet5) return;
|
|
182
183
|
delete params.temperature;
|
|
183
184
|
delete params.top_p;
|
|
184
185
|
delete params.top_k;
|
|
185
|
-
if (opus5 || sonnet5) delete params.service_tier;
|
|
186
|
+
if (opus5 || sonnet5 || haiku55) delete params.service_tier;
|
|
186
187
|
}
|
|
187
188
|
function resolveReplayModelBoundIdentity(ref) {
|
|
188
189
|
if (normalizeApi(ref.api) !== "anthropic-messages") return;
|
|
@@ -191,6 +192,8 @@ function resolveReplayModelBoundIdentity(ref) {
|
|
|
191
192
|
params: ref.modelParams
|
|
192
193
|
};
|
|
193
194
|
const fableIdentity = resolveClaudeFable5ModelIdentity(modelRef);
|
|
195
|
+
const haikuIdentity = resolveClaudeHaiku55ModelIdentity(modelRef);
|
|
196
|
+
if (haikuIdentity) return `haiku:${haikuIdentity}`;
|
|
194
197
|
if (fableIdentity) return `fable:${fableIdentity}`;
|
|
195
198
|
const mythosIdentity = resolveClaudeMythos5ModelIdentity(modelRef);
|
|
196
199
|
if (mythosIdentity) return `mythos:${mythosIdentity}`;
|
|
@@ -210,7 +213,7 @@ const SONNET_55_REPLAY_IDENTITY = /^sonnet:claude-sonnet-5-5(?=$|[^a-z0-9])/;
|
|
|
210
213
|
*/
|
|
211
214
|
function readsPriorClaudeThinking(targetIdentity, sourceIdentity) {
|
|
212
215
|
if (targetIdentity === void 0) return false;
|
|
213
|
-
if (FABLE_51_REPLAY_IDENTITY.test(targetIdentity)) return sourceIdentity === void 0 || !SONNET_55_REPLAY_IDENTITY.test(sourceIdentity);
|
|
216
|
+
if (FABLE_51_REPLAY_IDENTITY.test(targetIdentity)) return sourceIdentity === void 0 || !SONNET_55_REPLAY_IDENTITY.test(sourceIdentity) && !sourceIdentity.startsWith("haiku:");
|
|
214
217
|
if (SONNET_55_REPLAY_IDENTITY.test(targetIdentity)) return sourceIdentity === void 0 || sourceIdentity.startsWith("sonnet:");
|
|
215
218
|
return false;
|
|
216
219
|
}
|