@openclaw/ai 2026.9.5 → 2026.9.7
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-COtDvgtt.mjs → anthropic-Cw2pgccz.mjs} +59 -88
- package/dist/{anthropic-payload-policy-5Erq1Nzy.d.mts → anthropic-payload-policy-NIPVYXPq.d.mts} +8 -6
- package/dist/{anthropic-stream-reducer-BvdYYWL8.mjs → anthropic-stream-reducer-D9MCkl8Z.mjs} +194 -247
- package/dist/{api-registry-Ba2Cv-ut.d.mts → api-registry-D-nbmSqr.d.mts} +2 -2
- package/dist/{azure-openai-responses-YrgnD583.mjs → azure-openai-responses-BwT3-X8P.mjs} +22 -33
- package/dist/{base64-BQOzsvUH.mjs → base64-C1PsYcRQ.mjs} +22 -16
- package/dist/{diagnostics-Dm4bisWG.mjs → diagnostics-CJaB6g8J.mjs} +55 -10
- package/dist/{diagnostics-CPeq9F7y.mjs → diagnostics-DzrF1h4J.mjs} +18 -1
- package/dist/diagnostics.d.mts +11 -5
- package/dist/diagnostics.mjs +4 -4
- package/dist/{env-api-keys-bktO00EJ.mjs → env-api-keys-CyX4VKGO.mjs} +7 -5
- package/dist/event-stream-CMQfX_yr.d.mts +1 -0
- package/dist/{event-stream-CCoa-qSI.d.mts → event-stream-DOPFYVqs.d.mts} +2 -2
- package/dist/{event-stream-D8PARQfL.mjs → event-stream-vd9UnCAU.mjs} +10 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-BuhpRO9r.mjs → google-BfapkS_K.mjs} +8 -11
- package/dist/google-interactions-DW3iXzjc.mjs +574 -0
- package/dist/{google-messages-CyWnYlh0.mjs → google-messages-CtjVtVot.mjs} +35 -71
- package/dist/{google-shared-BT5ZeNer.mjs → google-shared-Y2YfotEu.mjs} +43 -47
- package/dist/{google-vertex-C7EplRvt.mjs → google-vertex-Dov4kBWu.mjs} +16 -30
- package/dist/{host-B4MeUNBc.mjs → host-CHi3X87F.mjs} +64 -189
- package/dist/{host-policy-DUnXSx0I.mjs → host-policy-BOAwRg_M.mjs} +2 -14
- package/dist/{host-FZ1RA_qD.d.mts → host-rxlNaBwm.d.mts} +9 -3
- package/dist/{index-DaF2QbwS.d.mts → index-D6KsSE74.d.mts} +57 -9
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +7 -7
- package/dist/internal/anthropic.d.mts +13 -8
- package/dist/internal/anthropic.mjs +5 -5
- 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 +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +46 -9
- package/dist/internal/openai.mjs +13 -12
- package/dist/internal/runtime.d.mts +31 -70
- package/dist/internal/runtime.mjs +11 -66
- package/dist/internal/shared.d.mts +16 -13
- package/dist/internal/shared.mjs +6 -5
- package/dist/internal/tool-schema.d.mts +2 -2
- package/dist/internal/tool-schema.mjs +2 -2
- package/dist/{mistral-moA-mbwl.mjs → mistral-RS6mboC-.mjs} +46 -93
- package/dist/{model-transport-url-DKocrEsb.d.mts → model-transport-url-C5f59L3Y.d.mts} +1 -1
- package/dist/{openai-chatgpt-responses-DWID3EFO.mjs → openai-chatgpt-responses-CYbidtrn.mjs} +118 -99
- package/dist/{openai-completions-DJ1Vm-CD.mjs → openai-completions-D14ihPYk.mjs} +14 -12
- package/dist/{openai-completions-compat-CkwdxTZx.mjs → openai-completions-compat-BOVWBZDn.mjs} +3 -5
- package/dist/{openai-completions-compat-JE7gqxb9.d.mts → openai-completions-compat-qJjmqQ71.d.mts} +3 -3
- package/dist/{openai-completions-stream-Bu98b0Hv.mjs → openai-completions-stream-CDCuw3DP.mjs} +124 -183
- package/dist/{openai-prompt-cache-CJ_xEevu.d.mts → openai-prompt-cache-CouErLh7.d.mts} +2 -2
- package/dist/{openai-prompt-cache-1wfaIszn.mjs → openai-prompt-cache-D2V7MqR7.mjs} +1 -1
- package/dist/{openai-provider-client-DPo0Hmak.mjs → openai-provider-client-CwfsGBbA.mjs} +2 -2
- package/dist/{openai-reasoning-effort-NlFZmfEu.mjs → openai-reasoning-effort-ConhwkeX.mjs} +14 -5
- package/dist/{openai-responses-BejZzQCP.mjs → openai-responses-CKCBEc2W.mjs} +12 -11
- package/dist/openai-responses-compaction-replay-DiYn-gFM.d.mts +12 -0
- package/dist/{openai-responses-compaction-window-D6P5oZP5.mjs → openai-responses-compaction-window-UNK1GDpy.mjs} +5 -5
- package/dist/{openai-responses-contracts-DWrfMODE.mjs → openai-responses-contracts-CLxnqS9p.mjs} +1 -1
- package/dist/{openai-responses-contracts-Dflvrfa8.d.mts → openai-responses-contracts-D1iZ0njF.d.mts} +4 -4
- package/dist/{openai-responses-prompt-observer-internal-C15_-OwV.mjs → openai-responses-prompt-observer-internal-iAqLb4tk.mjs} +16 -13
- package/dist/openai-responses-request-lifecycle-Fsag-IGZ.mjs +36 -0
- package/dist/{openai-responses-shared-CwsziD_m.mjs → openai-responses-shared-DL4ulQn7.mjs} +838 -577
- package/dist/{openai-responses-terminal-usage-Dl3J6zrf.d.mts → openai-responses-terminal-usage-BE7lf7nW.d.mts} +2 -2
- package/dist/{openai-stop-reason-Drnn_6Qj.mjs → openai-stop-reason-8s70vDXj.mjs} +2 -12
- package/dist/{openai-tool-schema-ynZBgqW-.d.mts → openai-tool-schema-a5ysBBga.d.mts} +0 -6
- package/dist/{openai-tool-schema-BO8rwyAD.mjs → openai-tool-schema-vsl-cE-n.mjs} +365 -429
- package/dist/{openai-transport-params-DQeuAvBl.mjs → openai-transport-params-BwlpzX-2.mjs} +61 -106
- package/dist/{positive-integer-DtjCkbue.mjs → positive-integer-CjN5OJbH.mjs} +1 -1
- package/dist/{provider-error-DDqw9Qda.mjs → provider-error-CwT_j2v0.mjs} +82 -10
- package/dist/{provider-error-CzNw4BWX.d.mts → provider-error-xumb1V3F.d.mts} +3 -1
- package/dist/{provider-options-DprLsWh9.d.mts → provider-options-Df7ov0K1.d.mts} +6 -4
- package/dist/{provider-replay-context-CnUSOwhr.mjs → provider-replay-context-DsyI5jOP.mjs} +1 -1
- package/dist/{provider-transcript-transform-BsRAhuWJ.mjs → provider-transcript-transform-JbFbHV8h.mjs} +17 -2
- package/dist/{provider-transport-turn-state-CkGToCD2.mjs → provider-transport-turn-state-BheUi_hl.mjs} +1 -1
- package/dist/{provider-types-CAKRC7N5.d.mts → provider-types-d4XnoZMd.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +15 -11
- package/dist/{reasoning-tag-text-partitioner-Dy9IO8Dc.mjs → reasoning-tag-text-partitioner-B6FIIBt6.mjs} +193 -98
- package/dist/{record-coerce-DwRYMj3t.mjs → record-coerce-CNDovvft.mjs} +1 -1
- package/dist/simple-options-CGAkCwtM.mjs +349 -0
- package/dist/{src-DeKjbE8I.mjs → src-H4aXcFuX.mjs} +53 -26
- package/dist/{stream-CREqxHgU.mjs → stream-DDsCBgd-.mjs} +1 -7
- package/dist/{stream-first-event-timeout-C9ZadkJW.mjs → stream-first-event-timeout-B9o0S4SZ.mjs} +1 -1
- package/dist/{tool-schema-json-projection-CD9c_fK8.mjs → tool-schema-json-projection-Ct8SeBeJ.mjs} +63 -23
- package/dist/{transport-stream-shared-D-6FQSHm.mjs → transport-stream-shared-Dh5qKJ8e.mjs} +63 -37
- package/dist/{transport-stream-shared-BbUkFaHi.d.mts → transport-stream-shared-yYhXa4kX.d.mts} +13 -7
- package/dist/{transport-utils-1cyq5Y7x.mjs → transport-utils-C-4bf2Ok.mjs} +3 -4
- package/dist/transports.d.mts +37 -33
- package/dist/transports.mjs +208 -239
- package/dist/types-CB-_vNyI.d.mts +1 -0
- package/dist/{types-4_uVs5WH.d.mts → types-CLLR3eB4.d.mts} +5 -1
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +5 -5
- package/dist/{validation-Dw7cb6BV.mjs → validation-BFZc40Ig.mjs} +80 -54
- package/dist/{validation-Ctzu2DhF.d.mts → validation-Cat2wQsc.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +6 -6
- package/dist/assistant-output-BsEkB-vU.mjs +0 -16
- package/dist/event-stream-DmSCpi1T.d.mts +0 -1
- package/dist/simple-options-C6cFWj_f.mjs +0 -175
- package/dist/types-DkJfb4W3.d.mts +0 -1
- package/dist/utf16-slice-CvGodqok.mjs +0 -29
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
4
|
-
import {
|
|
5
|
-
import { t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./transport-utils-
|
|
6
|
-
import {
|
|
2
|
+
import { S as supportsClaudeAdaptiveThinking, b as resolveClaudeSonnet5ModelIdentity, v as resolveClaudeOpus5ModelIdentity, y as resolveClaudeSonnet55ModelIdentity } from "./src-H4aXcFuX.mjs";
|
|
3
|
+
import { t as AssistantMessageEventStream } from "./event-stream-vd9UnCAU.mjs";
|
|
4
|
+
import { _ as requiresClaudeAdaptiveThinking, b as usesClaudeFable5MessagesContract, f as applyClaudeRequestContract, g as prepareClaudeNoPrefillRequestContext, n as getAiTransportHost, p as buildAnthropicClaudeCodeIdentity, r as resolveAiTransportHeaderSentinels, v as resolveAnthropicThinkingEffort, x as usesClaudeStreamingRefusalContract } from "./host-CHi3X87F.mjs";
|
|
5
|
+
import { t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./transport-utils-C-4bf2Ok.mjs";
|
|
6
|
+
import { A as applyAnthropicRequestCacheControl, B as ANTHROPIC_SERVER_SIDE_FALLBACKS, C as applyAnthropicThinkingBindingControls, D as applyAnthropicContextManagementToRequest, F as resolveAnthropicCacheOptions, J as usesFoundryBearerAuth, K as isAnthropicOAuthApiKey, N as isDirectAnthropicModel, R as resolveAnthropicRequestBetaHeader, d as convertAnthropicTools, f as buildAnthropicReplayPlan, g as normalizeAnthropicToolCallId, h as suppressAnthropicCompaction, j as buildAnthropicSystemBlocks, l as buildAnthropicGenerationParams, p as isAnthropicReplayRejection, q as omitFoundryBearerCredentialHeaders, t as consumeAnthropicStream, u as convertAnthropicMessages } from "./anthropic-stream-reducer-D9MCkl8Z.mjs";
|
|
7
7
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { n as
|
|
10
|
-
import {
|
|
8
|
+
import { D as parseJsonWithRepair, m as notifyProviderHttpResponse, n as assignTransportErrorDetails, u as finalizeTransportStream } from "./transport-stream-shared-Dh5qKJ8e.mjs";
|
|
9
|
+
import { n as buildBaseOptions, r as clampMaxTokensToModel, t as adjustMaxTokensForThinking } from "./simple-options-CGAkCwtM.mjs";
|
|
10
|
+
import { n as getEnvApiKey } from "./env-api-keys-CyX4VKGO.mjs";
|
|
11
11
|
import { t as createDeferredEventBuffer } from "./deferred-event-buffer-DAvyP7qA.mjs";
|
|
12
12
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
13
|
-
import {
|
|
13
|
+
import { n as createAssistantOutput, t as transformProviderMessages } from "./provider-transcript-transform-JbFbHV8h.mjs";
|
|
14
14
|
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-Bcunsn4I.mjs";
|
|
15
|
-
import { t as transformProviderMessages } from "./provider-transcript-transform-BsRAhuWJ.mjs";
|
|
16
15
|
import { i as resolveCloudflareBaseUrl, n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-B37TB3rB.mjs";
|
|
17
16
|
import Anthropic from "@anthropic-ai/sdk";
|
|
18
17
|
import { Stream } from "@anthropic-ai/sdk/core/streaming.js";
|
|
@@ -34,9 +33,7 @@ function getAnthropicCompat(model) {
|
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
35
|
function mergeHeaders(...headerSources) {
|
|
37
|
-
|
|
38
|
-
for (const headers of headerSources) if (headers) Object.assign(merged, headers);
|
|
39
|
-
return merged;
|
|
36
|
+
return Object.assign({}, ...headerSources);
|
|
40
37
|
}
|
|
41
38
|
const ANTHROPIC_MESSAGE_EVENTS = /* @__PURE__ */ new Set([
|
|
42
39
|
"message_start",
|
|
@@ -73,6 +70,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
73
70
|
let isOAuth;
|
|
74
71
|
let serverSideFallback = false;
|
|
75
72
|
let directApiKeyBetaHeader;
|
|
73
|
+
let claudeCodeVersion;
|
|
76
74
|
if (requestOptions?.client) {
|
|
77
75
|
client = requestOptions.client;
|
|
78
76
|
isOAuth = false;
|
|
@@ -92,8 +90,9 @@ const streamAnthropic = (model, context, options) => {
|
|
|
92
90
|
isOAuth = created.isOAuthToken;
|
|
93
91
|
serverSideFallback = created.serverSideFallback;
|
|
94
92
|
directApiKeyBetaHeader = created.directApiKeyBetaHeader;
|
|
93
|
+
claudeCodeVersion = created.claudeCodeVersion;
|
|
95
94
|
}
|
|
96
|
-
const builtParams = await buildParams(model, requestContext, isOAuth, requestOptions, serverSideFallback);
|
|
95
|
+
const builtParams = await buildParams(model, requestContext, isOAuth, requestOptions, serverSideFallback, claudeCodeVersion);
|
|
97
96
|
usedCompactionReplay = builtParams.usedCompactionReplay;
|
|
98
97
|
let params = builtParams.params;
|
|
99
98
|
const toolProjection = builtParams.toolProjection;
|
|
@@ -101,7 +100,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
101
100
|
const nextParams = await requestOptions?.onPayload?.(params, model);
|
|
102
101
|
if (nextParams !== void 0) params = nextParams;
|
|
103
102
|
applyClaudeRequestContract(params, model);
|
|
104
|
-
const betaHeader =
|
|
103
|
+
const betaHeader = resolveAnthropicRequestBetaHeader(params, directApiKeyBetaHeader);
|
|
105
104
|
const sdkRequestOptions = {
|
|
106
105
|
...requestOptions?.signal ? { signal: requestOptions.signal } : {},
|
|
107
106
|
...requestOptions?.timeoutMs !== void 0 ? { timeout: requestOptions.timeoutMs } : {},
|
|
@@ -175,7 +174,8 @@ const streamSimpleAnthropic = (model, context, options) => {
|
|
|
175
174
|
cacheTtlPruning: options?.cacheTtlPruning,
|
|
176
175
|
authProfileId: options?.authProfileId,
|
|
177
176
|
maxTokens: clampMaxTokensToModel(model, options?.maxTokens ?? model.maxTokens),
|
|
178
|
-
toolChoice: options?.toolChoice
|
|
177
|
+
toolChoice: options?.toolChoice,
|
|
178
|
+
thinkingDisplay: options?.thinkingDisplay
|
|
179
179
|
};
|
|
180
180
|
const mandatoryAdaptiveThinking = requiresClaudeAdaptiveThinking(model);
|
|
181
181
|
if (options?.reasoning === "off" && !mandatoryAdaptiveThinking) return streamAnthropic(model, context, {
|
|
@@ -186,7 +186,7 @@ const streamSimpleAnthropic = (model, context, options) => {
|
|
|
186
186
|
if (resolveClaudeOpus5ModelIdentity(model) || resolveClaudeSonnet5ModelIdentity(model)) return streamAnthropic(model, context, {
|
|
187
187
|
...base,
|
|
188
188
|
thinkingEnabled: true,
|
|
189
|
-
effort: resolveAnthropicThinkingEffort(model, reasoning
|
|
189
|
+
effort: resolveAnthropicThinkingEffort(model, reasoning)
|
|
190
190
|
});
|
|
191
191
|
if (!reasoning) return streamAnthropic(model, context, {
|
|
192
192
|
...base,
|
|
@@ -216,7 +216,7 @@ const streamSimpleAnthropic = (model, context, options) => {
|
|
|
216
216
|
* identity) requests are excluded until the beta is verified there.
|
|
217
217
|
*/
|
|
218
218
|
function supportsAnthropicServerSideFallback(model) {
|
|
219
|
-
if (!usesClaudeFable5MessagesContract(model) && resolveClaudeOpus5ModelIdentity(model) === void 0 || model.provider !== "anthropic") return false;
|
|
219
|
+
if (!usesClaudeFable5MessagesContract(model) && resolveClaudeOpus5ModelIdentity(model) === void 0 && resolveClaudeSonnet55ModelIdentity(model) === void 0 || model.provider !== "anthropic") return false;
|
|
220
220
|
return isDirectAnthropicModel(model);
|
|
221
221
|
}
|
|
222
222
|
function createClient(model, apiKey, thinkingEnabled, interleavedThinking, useFineGrainedToolStreamingBeta, optionsHeaders, dynamicHeaders, sessionId) {
|
|
@@ -225,112 +225,83 @@ function createClient(model, apiKey, thinkingEnabled, interleavedThinking, useFi
|
|
|
225
225
|
if (useFineGrainedToolStreamingBeta) betaFeatures.push(FINE_GRAINED_TOOL_STREAMING_BETA);
|
|
226
226
|
if (needsInterleavedBeta) betaFeatures.push(INTERLEAVED_THINKING_BETA);
|
|
227
227
|
const fetchOptions = /^kimi(?:-|$)/.test(model.provider) && thinkingEnabled ? { sanitizeSse: false } : void 0;
|
|
228
|
-
const
|
|
228
|
+
const clientOptions = {
|
|
229
|
+
baseURL: model.baseUrl,
|
|
230
|
+
dangerouslyAllowBrowser: true,
|
|
231
|
+
fetch: getAiTransportHost().buildModelFetch(model, void 0, fetchOptions),
|
|
232
|
+
maxRetries: 0
|
|
233
|
+
};
|
|
234
|
+
const baseHeaders = {
|
|
235
|
+
accept: "application/json",
|
|
236
|
+
"anthropic-dangerous-direct-browser-access": "true",
|
|
237
|
+
...betaFeatures.length > 0 ? { "anthropic-beta": betaFeatures.join(",") } : {}
|
|
238
|
+
};
|
|
229
239
|
if (model.provider === "cloudflare-ai-gateway") return {
|
|
230
240
|
client: new Anthropic({
|
|
241
|
+
...clientOptions,
|
|
231
242
|
apiKey,
|
|
232
243
|
authToken: null,
|
|
233
244
|
baseURL: resolveCloudflareBaseUrl(model),
|
|
234
|
-
dangerouslyAllowBrowser: true,
|
|
235
245
|
defaultHeaders: mergeHeaders({
|
|
236
|
-
accept:
|
|
246
|
+
accept: baseHeaders.accept,
|
|
237
247
|
"anthropic-dangerous-direct-browser-access": "true",
|
|
238
248
|
Authorization: null,
|
|
239
249
|
...betaFeatures.length > 0 ? { "anthropic-beta": betaFeatures.join(",") } : {}
|
|
240
|
-
}, model.headers, optionsHeaders)
|
|
241
|
-
fetch,
|
|
242
|
-
maxRetries: 0
|
|
243
|
-
}),
|
|
244
|
-
isOAuthToken: false,
|
|
245
|
-
serverSideFallback: false
|
|
246
|
-
};
|
|
247
|
-
if (model.provider === "github-copilot") return {
|
|
248
|
-
client: new Anthropic({
|
|
249
|
-
apiKey: null,
|
|
250
|
-
authToken: apiKey,
|
|
251
|
-
baseURL: model.baseUrl,
|
|
252
|
-
dangerouslyAllowBrowser: true,
|
|
253
|
-
defaultHeaders: mergeHeaders({
|
|
254
|
-
accept: "application/json",
|
|
255
|
-
"anthropic-dangerous-direct-browser-access": "true",
|
|
256
|
-
...betaFeatures.length > 0 ? { "anthropic-beta": betaFeatures.join(",") } : {}
|
|
257
|
-
}, model.headers, dynamicHeaders, optionsHeaders),
|
|
258
|
-
fetch,
|
|
259
|
-
maxRetries: 0
|
|
250
|
+
}, model.headers, optionsHeaders)
|
|
260
251
|
}),
|
|
261
252
|
isOAuthToken: false,
|
|
262
253
|
serverSideFallback: false
|
|
263
254
|
};
|
|
264
|
-
|
|
255
|
+
const isCopilot = model.provider === "github-copilot";
|
|
256
|
+
if (isCopilot || usesFoundryBearerAuth({
|
|
265
257
|
...model,
|
|
266
258
|
headers: resolveAiTransportHeaderSentinels(model.headers)
|
|
267
259
|
})) return {
|
|
268
260
|
client: new Anthropic({
|
|
261
|
+
...clientOptions,
|
|
269
262
|
apiKey: null,
|
|
270
263
|
authToken: apiKey,
|
|
271
|
-
|
|
272
|
-
dangerouslyAllowBrowser: true,
|
|
273
|
-
defaultHeaders: mergeHeaders({
|
|
274
|
-
accept: "application/json",
|
|
275
|
-
"anthropic-dangerous-direct-browser-access": "true",
|
|
276
|
-
...betaFeatures.length > 0 ? { "anthropic-beta": betaFeatures.join(",") } : {}
|
|
277
|
-
}, omitFoundryBearerCredentialHeaders(model.headers), dynamicHeaders, optionsHeaders),
|
|
278
|
-
fetch,
|
|
279
|
-
maxRetries: 0
|
|
264
|
+
defaultHeaders: mergeHeaders(baseHeaders, isCopilot ? model.headers : omitFoundryBearerCredentialHeaders(model.headers), dynamicHeaders, optionsHeaders)
|
|
280
265
|
}),
|
|
281
266
|
isOAuthToken: false,
|
|
282
267
|
serverSideFallback: false
|
|
283
268
|
};
|
|
284
|
-
if (isAnthropicOAuthApiKey(apiKey))
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
maxRetries: 0
|
|
303
|
-
}),
|
|
304
|
-
isOAuthToken: true,
|
|
305
|
-
serverSideFallback: false
|
|
306
|
-
};
|
|
269
|
+
if (isAnthropicOAuthApiKey(apiKey)) {
|
|
270
|
+
const identity = buildAnthropicClaudeCodeIdentity([
|
|
271
|
+
"claude-code-20250219",
|
|
272
|
+
"oauth-2025-04-20",
|
|
273
|
+
...betaFeatures
|
|
274
|
+
].join(","), model.headers, optionsHeaders);
|
|
275
|
+
return {
|
|
276
|
+
client: new Anthropic({
|
|
277
|
+
...clientOptions,
|
|
278
|
+
apiKey: null,
|
|
279
|
+
authToken: apiKey,
|
|
280
|
+
defaultHeaders: identity.headers
|
|
281
|
+
}),
|
|
282
|
+
isOAuthToken: true,
|
|
283
|
+
serverSideFallback: false,
|
|
284
|
+
claudeCodeVersion: identity.version
|
|
285
|
+
};
|
|
286
|
+
}
|
|
307
287
|
const serverSideFallback = supportsAnthropicServerSideFallback(model);
|
|
308
|
-
|
|
309
|
-
const sessionAffinityHeaders = sessionId && getAnthropicCompat(model).sendSessionAffinityHeaders ? { "x-session-affinity": sessionId } : {};
|
|
310
|
-
const defaultHeaders = mergeHeaders({
|
|
311
|
-
accept: "application/json",
|
|
312
|
-
"anthropic-dangerous-direct-browser-access": "true",
|
|
313
|
-
...betaFeatures.length > 0 ? { "anthropic-beta": betaFeatures.join(",") } : {}
|
|
314
|
-
}, sessionAffinityHeaders, model.headers, optionsHeaders);
|
|
288
|
+
const defaultHeaders = mergeHeaders(baseHeaders, sessionId && getAnthropicCompat(model).sendSessionAffinityHeaders ? { "x-session-affinity": sessionId } : {}, model.headers, optionsHeaders);
|
|
315
289
|
return {
|
|
316
290
|
client: new Anthropic({
|
|
291
|
+
...clientOptions,
|
|
317
292
|
apiKey,
|
|
318
293
|
authToken: null,
|
|
319
|
-
|
|
320
|
-
dangerouslyAllowBrowser: true,
|
|
321
|
-
defaultHeaders,
|
|
322
|
-
fetch,
|
|
323
|
-
maxRetries: 0
|
|
294
|
+
defaultHeaders
|
|
324
295
|
}),
|
|
325
296
|
isOAuthToken: false,
|
|
326
297
|
serverSideFallback,
|
|
327
298
|
directApiKeyBetaHeader: isDirectAnthropicModel(model) ? Object.entries(defaultHeaders).findLast(([name]) => name.toLowerCase() === "anthropic-beta")?.[1] ?? "" : void 0
|
|
328
299
|
};
|
|
329
300
|
}
|
|
330
|
-
async function buildParams(model, context, isOAuthTokenResult, options, serverSideFallback = false) {
|
|
301
|
+
async function buildParams(model, context, isOAuthTokenResult, options, serverSideFallback = false, claudeCodeVersion) {
|
|
331
302
|
const replayThinkingEnabled = requiresClaudeAdaptiveThinking(model) || options?.thinkingEnabled === true;
|
|
332
303
|
const { cacheControl, supportsCacheControlOnTools } = resolveAnthropicCacheOptions(model, options?.cacheRetention);
|
|
333
|
-
const system = buildAnthropicSystemBlocks(context.systemPrompt, isOAuthTokenResult, cacheControl);
|
|
304
|
+
const system = buildAnthropicSystemBlocks(context.systemPrompt, isOAuthTokenResult, cacheControl, claudeCodeVersion);
|
|
334
305
|
const compat = getAnthropicCompat(model);
|
|
335
306
|
const convertedTools = context.tools ? convertAnthropicTools(context.tools, isOAuthTokenResult, compat.supportsEagerToolInputStreaming) : void 0;
|
|
336
307
|
const tools = convertedTools?.tools;
|
package/dist/{anthropic-payload-policy-5Erq1Nzy.d.mts → anthropic-payload-policy-NIPVYXPq.d.mts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { O as Model } from "./types-
|
|
3
|
-
import { t as AnthropicContextManagementOptions } from "./provider-options-
|
|
1
|
+
import "./index-D6KsSE74.mjs";
|
|
2
|
+
import { O as Model } from "./types-CLLR3eB4.mjs";
|
|
3
|
+
import { t as AnthropicContextManagementOptions } from "./provider-options-Df7ov0K1.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. */
|
|
@@ -60,7 +60,7 @@ declare function resolveAnthropicCacheOptions(model: Model<"anthropic-messages">
|
|
|
60
60
|
cacheControl: AnthropicEphemeralCacheControl | undefined;
|
|
61
61
|
supportsCacheControlOnTools: boolean;
|
|
62
62
|
};
|
|
63
|
-
declare function buildAnthropicSystemBlocks(systemPrompt: string | undefined, isOAuthToken: boolean, cacheControl: AnthropicEphemeralCacheControl | undefined): TextBlockParam[] | undefined;
|
|
63
|
+
declare function buildAnthropicSystemBlocks(systemPrompt: string | undefined, isOAuthToken: boolean, cacheControl: AnthropicEphemeralCacheControl | undefined, claudeCodeVersion?: string): TextBlockParam[] | undefined;
|
|
64
64
|
/** Allocate tool and history checkpoints around the prepared stable system blocks. */
|
|
65
65
|
declare function applyAnthropicRequestCacheControl(payload: {
|
|
66
66
|
system?: unknown;
|
|
@@ -75,11 +75,13 @@ type AnthropicContextManagementPayload = {
|
|
|
75
75
|
messages?: unknown;
|
|
76
76
|
};
|
|
77
77
|
declare function applyAnthropicContextManagementToRequest(payload: AnthropicContextManagementPayload, model: Model, options: AnthropicContextManagementOptions | undefined, directApiKeyBetaHeader: string | undefined): void;
|
|
78
|
-
declare function
|
|
78
|
+
declare function resolveAnthropicRequestBetaHeader(payload: AnthropicContextManagementPayload & {
|
|
79
|
+
fallbacks?: unknown;
|
|
80
|
+
}, directApiKeyBetaHeader: string | undefined): string | undefined;
|
|
79
81
|
declare function logAnthropicContextEdits(event: unknown): void;
|
|
80
82
|
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
81
83
|
declare function applyAnthropicPayloadPolicyToParams(payloadObj: Record<string, unknown>, policy: AnthropicPayloadPolicy, cacheBreakpointOptOutMessageIndexes: ReadonlySet<number>): void;
|
|
82
84
|
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
83
85
|
declare function applyAnthropicEphemeralCacheControlMarkers(payloadObj: Record<string, unknown>, cacheControl?: AnthropicEphemeralCacheControl | null): void;
|
|
84
86
|
//#endregion
|
|
85
|
-
export { buildAnthropicSystemBlocks as a, logAnthropicContextEdits as c,
|
|
87
|
+
export { buildAnthropicSystemBlocks as a, logAnthropicContextEdits as c, resolveAnthropicPayloadPolicy as d, resolveAnthropicRequestBetaHeader as f, applyAnthropicRequestCacheControl as i, resolveAnthropicCacheOptions as l, applyAnthropicEphemeralCacheControlMarkers as n, isAnthropicServerToolClearingEnabled as o, resolveAnthropicServerCompactionPlan as p, applyAnthropicPayloadPolicyToParams as r, isDirectAnthropicModel as s, applyAnthropicContextManagementToRequest as t, resolveAnthropicEphemeralCacheControl as u };
|