@openclaw/ai 2026.8.2 → 2026.8.33
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-DTGZ4VMY.mjs → anthropic-BNeFhAh3.mjs} +196 -186
- package/dist/{anthropic-compaction-replay-CKCDrZJv.mjs → anthropic-compaction-replay-B6sEzXhr.mjs} +23 -6
- package/dist/{anthropic-payload-policy-BTzmNC14.d.mts → anthropic-payload-policy-kkq8L7tJ.d.mts} +2 -2
- package/dist/{api-registry-BbUHEKER.d.mts → api-registry-CAK4bNkq.d.mts} +2 -2
- package/dist/{azure-openai-responses-BmqaDXM1.mjs → azure-openai-responses-CPvqFff1.mjs} +4 -4
- package/dist/event-stream-CDHaMazK.d.mts +1 -0
- package/dist/{event-stream-DcvAPSBe.d.mts → event-stream-DcQzYRWO.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/{google-CqjVZMwo.mjs → google-B6pXyWB0.mjs} +3 -3
- package/dist/{google-shared-Bnqni5j3.mjs → google-shared-C_3CT37v.mjs} +5 -5
- package/dist/{google-vertex-D_WREEJi.mjs → google-vertex-BA2c1toq.mjs} +3 -3
- package/dist/{host-DKFUAmCn.d.mts → host-DL2Zd9ep.d.mts} +3 -3
- package/dist/{host-BIaiBURL.mjs → host-DhlhmyR6.mjs} +17 -2
- package/dist/{index-CefaUGSS.d.mts → index-DcGDVDnC.d.mts} +12 -5
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +3 -3
- package/dist/internal/anthropic.d.mts +11 -6
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-responses-payload-policy.d.mts +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +1 -1
- package/dist/internal/openai.d.mts +7 -7
- package/dist/internal/openai.mjs +10 -10
- package/dist/internal/runtime.d.mts +5 -5
- package/dist/internal/runtime.mjs +2 -2
- package/dist/internal/shared.d.mts +2 -2
- package/dist/internal/shared.mjs +3 -3
- package/dist/{mistral-C24jVd6f.mjs → mistral-CTcM9TGz.mjs} +5 -5
- package/dist/{openai-chatgpt-responses-Czum0oXz.mjs → openai-chatgpt-responses-QqHf1o9v.mjs} +9 -9
- package/dist/{openai-completions-BfFwac6f.mjs → openai-completions-BCmKwgsc.mjs} +7 -7
- package/dist/{openai-completions-compat-SZhi0Lf4.d.mts → openai-completions-compat-BJE92duO.d.mts} +3 -3
- package/dist/{openai-completions-stream-DGOvau4J.mjs → openai-completions-stream-0mm4YUag.mjs} +9 -9
- package/dist/openai-prompt-cache-BUJI5cW-.d.mts +16 -0
- package/dist/openai-prompt-cache-CGnVB74a.mjs +21 -0
- package/dist/{openai-responses-compaction-window-DO7yV7az.mjs → openai-responses-compaction-window-vuCaZYLS.mjs} +2 -2
- package/dist/{openai-responses-contracts-BthRXano.d.mts → openai-responses-contracts-DFJOyjd1.d.mts} +6 -3
- package/dist/{openai-responses-BAryVEJM.mjs → openai-responses-pMJVxhHW.mjs} +7 -10
- package/dist/{openai-responses-prompt-observer-internal--R0kZLOZ.mjs → openai-responses-prompt-observer-internal-COaImuDp.mjs} +3 -3
- package/dist/{openai-responses-shared-CxgdGBvm.mjs → openai-responses-shared-CZTRmOFP.mjs} +9 -9
- package/dist/{openai-tool-schema-CSMh5e9O.mjs → openai-tool-schema-DjS9-DHe.mjs} +5 -5
- package/dist/{provider-options-DJd_9euj.d.mts → provider-options-CedgbINH.d.mts} +2 -2
- package/dist/{provider-transcript-transform-WvJmFUAf.mjs → provider-transcript-transform-BnsgCK8K.mjs} +1 -1
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +9 -9
- package/dist/{sanitize-unicode-S6binQG-.mjs → sanitize-unicode-Cfcaqa9V.mjs} +1 -1
- package/dist/{simple-options-rdOPzr7Z.mjs → simple-options-Bwi0x0bX.mjs} +2 -2
- package/dist/{src-C8U7lkoa.mjs → src-BhgSqnbz.mjs} +14 -1
- package/dist/{tool-schema-json-projection-BtZiml7r.mjs → tool-schema-json-projection-_gcOC21Y.mjs} +1 -1
- package/dist/{transport-stream-shared-BbG7PThh.d.mts → transport-stream-shared-B38NWYTa.d.mts} +4 -4
- package/dist/{transport-stream-shared-D8nQWCUo.mjs → transport-stream-shared-y1YR1k5K.mjs} +1 -1
- package/dist/{transport-utils-CtuS1Upe.mjs → transport-utils-DdLjoPMb.mjs} +1 -1
- package/dist/transports.d.mts +9 -9
- package/dist/transports.mjs +43 -36
- package/dist/types-DmdQ-xcq.d.mts +1 -0
- package/dist/{types-Beemor2E.d.mts → types-DmeScJQe.d.mts} +5 -6
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +2 -2
- package/dist/{validation-CC6s7Smp.d.mts → validation-DPDgbaD3.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/package.json +1 -1
- package/dist/event-stream-pXT3FI6X.d.mts +0 -1
- package/dist/openai-prompt-cache-2uo_1OR1.d.mts +0 -7
- package/dist/openai-prompt-cache-mZTCdRPo.mjs +0 -12
- package/dist/types-COdhCX0U.d.mts +0 -1
package/dist/{openai-responses-contracts-BthRXano.d.mts → openai-responses-contracts-DFJOyjd1.d.mts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { D as Model, n as Api } from "./types-
|
|
3
|
-
import { g as OpenAIReasoningEffort, h as OpenAIApiReasoningEffort, i as BaseOpenAIStreamOptions } from "./provider-options-
|
|
1
|
+
import "./index-DcGDVDnC.mjs";
|
|
2
|
+
import { D as Model, n as Api } from "./types-DmeScJQe.mjs";
|
|
3
|
+
import { g as OpenAIReasoningEffort, h as OpenAIApiReasoningEffort, i as BaseOpenAIStreamOptions } from "./provider-options-CedgbINH.mjs";
|
|
4
4
|
import { FunctionTool, ResponseCompactionItem, ResponseCreateParamsStreaming, ResponseInput, ResponseInputItem } from "openai/resources/responses/responses.js";
|
|
5
5
|
//#region packages/ai/src/transports/openai-responses-compaction-window.d.ts
|
|
6
6
|
type OpenAIResponsesCompactionOutput = Array<ResponseInputItem.Message | ReplayableResponseCompactionItem>;
|
|
@@ -55,6 +55,9 @@ type OpenAIResponsesRequestParams = {
|
|
|
55
55
|
instructions?: string;
|
|
56
56
|
prompt_cache_key?: string;
|
|
57
57
|
prompt_cache_retention?: "24h";
|
|
58
|
+
prompt_cache_options?: {
|
|
59
|
+
ttl: "30m";
|
|
60
|
+
};
|
|
58
61
|
metadata?: Record<string, string>;
|
|
59
62
|
previous_response_id?: string;
|
|
60
63
|
store?: boolean;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
3
|
-
import { n as getAiTransportHost } from "./host-
|
|
4
|
-
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-
|
|
3
|
+
import { n as getAiTransportHost } from "./host-DhlhmyR6.mjs";
|
|
4
|
+
import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIResponsesCacheParams } from "./openai-prompt-cache-CGnVB74a.mjs";
|
|
5
5
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
6
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
6
|
+
import { n as buildBaseOptions } from "./simple-options-Bwi0x0bX.mjs";
|
|
7
7
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
8
|
-
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, o as runResponsesStreamLifecycle, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-
|
|
9
|
-
import { j as resolveOpenAIClientBaseUrl } from "./openai-tool-schema-
|
|
10
|
-
import { A as supportsOpenAITemperature } from "./openai-responses-compaction-window-
|
|
8
|
+
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, o as runResponsesStreamLifecycle, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-CZTRmOFP.mjs";
|
|
9
|
+
import { j as resolveOpenAIClientBaseUrl } from "./openai-tool-schema-DjS9-DHe.mjs";
|
|
10
|
+
import { A as supportsOpenAITemperature } from "./openai-responses-compaction-window-vuCaZYLS.mjs";
|
|
11
11
|
import { i as resolveCloudflareBaseUrl, n as hasCopilotVisionInput, r as isCloudflareProvider, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-NCJtz9i0.mjs";
|
|
12
12
|
import OpenAI from "openai";
|
|
13
13
|
//#region packages/ai/src/providers/openai-responses.ts
|
|
@@ -22,9 +22,6 @@ function getCompat(model) {
|
|
|
22
22
|
supportsLongCacheRetention: model.compat?.supportsLongCacheRetention ?? true
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function getPromptCacheRetention(compat, cacheRetention) {
|
|
26
|
-
return cacheRetention === "long" && compat.supportsLongCacheRetention ? "24h" : void 0;
|
|
27
|
-
}
|
|
28
25
|
/**
|
|
29
26
|
* Generate function for OpenAI Responses API
|
|
30
27
|
*/
|
|
@@ -106,7 +103,7 @@ function buildParams(model, context, options, replayMode = "checkpoint") {
|
|
|
106
103
|
input: messages,
|
|
107
104
|
stream: true,
|
|
108
105
|
prompt_cache_key: cacheRetention === "none" ? void 0 : clampOpenAIPromptCacheKey(options?.promptCacheKey ?? options?.sessionId),
|
|
109
|
-
|
|
106
|
+
...resolveOpenAIResponsesCacheParams(model, cacheRetention, compat.supportsLongCacheRetention),
|
|
110
107
|
store: false
|
|
111
108
|
};
|
|
112
109
|
if (options?.maxTokens) params.max_output_tokens = options?.maxTokens;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as stripSystemPromptCacheBoundary } from "./simple-options-
|
|
2
|
-
import { g as sanitizeTransportPayloadText } from "./transport-stream-shared-
|
|
3
|
-
import { S as responsesPromptObserver } from "./openai-responses-compaction-window-
|
|
1
|
+
import { d as stripSystemPromptCacheBoundary } from "./simple-options-Bwi0x0bX.mjs";
|
|
2
|
+
import { g as sanitizeTransportPayloadText } from "./transport-stream-shared-y1YR1k5K.mjs";
|
|
3
|
+
import { S as responsesPromptObserver } from "./openai-responses-compaction-window-vuCaZYLS.mjs";
|
|
4
4
|
//#region packages/normalization-core/src/error-coercion.ts
|
|
5
5
|
/**
|
|
6
6
|
* Normalizes an unknown thrown value into an Error. Non-Error objects become
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { c as normalizeLowercaseStringOrEmpty, d as normalizeOptionalString, o as isRecord, t as truncateUtf16Safe } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { i as clampThinkingLevel, r as calculateCost } from "./sanitize-unicode-
|
|
3
|
-
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, n as getAiTransportHost } from "./host-
|
|
2
|
+
import { i as clampThinkingLevel, r as calculateCost } from "./sanitize-unicode-Cfcaqa9V.mjs";
|
|
3
|
+
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, n as getAiTransportHost } from "./host-DhlhmyR6.mjs";
|
|
4
4
|
import { n as projectProviderError } from "./provider-error-BI8kIViN.mjs";
|
|
5
5
|
import { r as asFiniteNumber } from "./base64-CEFBpSkN.mjs";
|
|
6
|
-
import { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName } from "./simple-options-
|
|
7
|
-
import { c as transformTransportMessages } from "./tool-schema-json-projection-
|
|
8
|
-
import { d as redactSensitiveText, u as redactIdentifier } from "./transport-utils-
|
|
9
|
-
import { _ as transportAbortError, g as sanitizeTransportPayloadText, h as sanitizeNonEmptyTransportPayloadText, m as parseTerminalToolCallArguments, y as withProviderResponseHook } from "./transport-stream-shared-
|
|
6
|
+
import { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName } from "./simple-options-Bwi0x0bX.mjs";
|
|
7
|
+
import { c as transformTransportMessages } from "./tool-schema-json-projection-_gcOC21Y.mjs";
|
|
8
|
+
import { d as redactSensitiveText, u as redactIdentifier } from "./transport-utils-DdLjoPMb.mjs";
|
|
9
|
+
import { _ as transportAbortError, g as sanitizeTransportPayloadText, h as sanitizeNonEmptyTransportPayloadText, m as parseTerminalToolCallArguments, y as withProviderResponseHook } from "./transport-stream-shared-y1YR1k5K.mjs";
|
|
10
10
|
import { r as parseStreamingJson, t as createToolArgumentPreviewSchedule } from "./json-parse-BuAJEbdW.mjs";
|
|
11
11
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
12
12
|
import { t as shortHash } from "./hash-CHgqbJmD.mjs";
|
|
13
|
-
import { C as createOpenAIProviderAcceptanceHook, E as log, S as createModelStreamCooperativeScheduler, a as resolveOpenAIProjectedToolsStrictToolFlag, r as normalizeOpenAIStrictToolParameters, t as findOpenAIStrictToolProjectionDiagnostics, v as projectOpenAITools } from "./openai-tool-schema-
|
|
13
|
+
import { C as createOpenAIProviderAcceptanceHook, E as log, S as createModelStreamCooperativeScheduler, a as resolveOpenAIProjectedToolsStrictToolFlag, r as normalizeOpenAIStrictToolParameters, t as findOpenAIStrictToolProjectionDiagnostics, v as projectOpenAITools } from "./openai-tool-schema-DjS9-DHe.mjs";
|
|
14
14
|
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-DcNjoFQE.mjs";
|
|
15
|
-
import { t as transformProviderMessages } from "./provider-transcript-transform-
|
|
16
|
-
import { A as supportsOpenAITemperature, D as resolveOpenAIReasoningEffortForModel, b as RESPONSE_FAILED_NO_DETAILS_MESSAGE, g as OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE, h as OPENAI_RESPONSES_REASONING_REPLAY_META_KEY, k as supportsOpenAIReasoningEffort, m as OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY, n as isOpenAIResponsesCompactionOutput, p as OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE, r as readOpenAIResponsesCompactionWindow } from "./openai-responses-compaction-window-
|
|
15
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-BnsgCK8K.mjs";
|
|
16
|
+
import { A as supportsOpenAITemperature, D as resolveOpenAIReasoningEffortForModel, b as RESPONSE_FAILED_NO_DETAILS_MESSAGE, g as OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE, h as OPENAI_RESPONSES_REASONING_REPLAY_META_KEY, k as supportsOpenAIReasoningEffort, m as OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY, n as isOpenAIResponsesCompactionOutput, p as OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE, r as readOpenAIResponsesCompactionWindow } from "./openai-responses-compaction-window-vuCaZYLS.mjs";
|
|
17
17
|
import { createHash, randomUUID } from "node:crypto";
|
|
18
18
|
//#region packages/ai/src/transports/model-transport-debug.ts
|
|
19
19
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { c as normalizeLowercaseStringOrEmpty, o as isRecord } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { n as applyProviderReportedUsageCost, r as calculateCost } from "./sanitize-unicode-
|
|
3
|
-
import { n as getAiTransportHost } from "./host-
|
|
2
|
+
import { n as applyProviderReportedUsageCost, r as calculateCost } from "./sanitize-unicode-Cfcaqa9V.mjs";
|
|
3
|
+
import { n as getAiTransportHost } from "./host-DhlhmyR6.mjs";
|
|
4
4
|
import { r as uniqueValues, t as normalizeStringEntries } from "./string-normalization--fwJ4S2q.mjs";
|
|
5
|
-
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-
|
|
6
|
-
import { t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-
|
|
7
|
-
import { C as headersToRecord, _ as transportAbortError, f as notifyProviderHttpResponse } from "./transport-stream-shared-
|
|
5
|
+
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-CGnVB74a.mjs";
|
|
6
|
+
import { t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-_gcOC21Y.mjs";
|
|
7
|
+
import { C as headersToRecord, _ as transportAbortError, f as notifyProviderHttpResponse } from "./transport-stream-shared-y1YR1k5K.mjs";
|
|
8
8
|
//#region packages/ai/src/transports/openai-transport-shared.ts
|
|
9
9
|
/** Shared options, usage shape, cache identity, ordering, and stream scheduling for OpenAI APIs. */
|
|
10
10
|
const MODEL_STREAM_COOPERATIVE_YIELD_INTERVAL_MS = 12;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { J as StreamOptions } from "./types-
|
|
2
|
-
import "./types-
|
|
1
|
+
import { J as StreamOptions } from "./types-DmeScJQe.mjs";
|
|
2
|
+
import "./types-DmdQ-xcq.mjs";
|
|
3
3
|
import OpenAI from "openai";
|
|
4
4
|
import Anthropic from "@anthropic-ai/sdk";
|
|
5
5
|
import { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as transformMessages } from "./host-
|
|
1
|
+
import { i as transformMessages } from "./host-DhlhmyR6.mjs";
|
|
2
2
|
//#region packages/ai/src/provider-transcript-transform.ts
|
|
3
3
|
const IMAGE_OMISSION = "(image omitted: model does not support images)";
|
|
4
4
|
const VIDEO_OMISSION = "(video omitted: provider does not support video input)";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { S as supportsClaudeNativeXhighEffort, _ as resolveClaudeSonnet5ModelIdentity, a as CLAUDE_FABLE_5_THINKING_PROFILE, b as supportsClaudeFastMode, c as bindsClaudeThinkingPrefix, d as resolveClaudeFable5ModelIdentity, f as resolveClaudeModelIdentity, g as resolveClaudeOpus5ModelIdentity, h as resolveClaudeOpus55ModelIdentity, i as normalizeResolvedPricing, l as requiresClaudeDefaultSampling, m as resolveClaudeNativeThinkingLevelMap, n as calculateUsageCost, o as CLAUDE_OPUS_5_THINKING_PROFILE, p as resolveClaudeMythos5ModelIdentity, r as normalizeModelCostConfig, s as CLAUDE_SONNET_5_THINKING_PROFILE, t as index_d_exports, u as requiresClaudeMandatoryAdaptiveThinking, v as supportsClaude1MContext, x as supportsClaudeNativeMaxEffort, y as supportsClaudeAdaptiveThinking } from "./index-DcGDVDnC.mjs";
|
|
2
2
|
import { a as extractDiagnosticError, i as createAssistantMessageDiagnostic, n as DiagnosticErrorInfo, o as formatThrownValue, r as appendAssistantMessageDiagnostic, t as AssistantMessageDiagnostic } from "./diagnostics-BaTA9eVl.mjs";
|
|
3
|
-
import { $ as ThinkingLevel, A as ModelThinkingLevel, B as ProviderResponse, C as KnownImagesApi, D as Model, F as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, G as StopReason, H as RawModelCostConfig, I as PricingTier, J as StreamOptions, K as StreamFn, L as Provider, M as OpenAIResponsesCompat, N as OpenRouterRouting, O as ModelCostConfig, P as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, Q as ThinkingContent, R as ProviderImagesOptions, S as KnownApi, T as MaybePromise, U as RawPricingTier, W as SimpleStreamOptions, X as TextSignatureV1, Y as TextContent, Z as ThinkingBudgets, _ as ImagesModel, a as AssistantMessage, at as Usage, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as VercelGatewayRouting, d as Context, et as ThinkingLevelMap, f as ImageContent, g as ImagesInputContent, h as ImagesFunction, i as AssistantImages, it as Transport, j as OpenAICompletionsCompat, k as ModelCostRates, l as CacheRetention, m as ImagesContext, n as Api, nt as ToolCall, o as AssistantMessageEvent, ot as UserMessage, p as ImagesApi, r as AssistantDeliveryTtsFacts, rt as ToolResultMessage, s as AssistantMessageEventStreamContract, st as ValidateToolArgumentsFn, t as AnthropicMessagesCompat, tt as Tool, u as CompleteSimpleFn, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderReplayState } from "./types-
|
|
4
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
5
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
6
|
-
import "./types-
|
|
3
|
+
import { $ as ThinkingLevel, A as ModelThinkingLevel, B as ProviderResponse, C as KnownImagesApi, D as Model, F as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, G as StopReason, H as RawModelCostConfig, I as PricingTier, J as StreamOptions, K as StreamFn, L as Provider, M as OpenAIResponsesCompat, N as OpenRouterRouting, O as ModelCostConfig, P as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, Q as ThinkingContent, R as ProviderImagesOptions, S as KnownApi, T as MaybePromise, U as RawPricingTier, W as SimpleStreamOptions, X as TextSignatureV1, Y as TextContent, Z as ThinkingBudgets, _ as ImagesModel, a as AssistantMessage, at as Usage, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as VercelGatewayRouting, d as Context, et as ThinkingLevelMap, f as ImageContent, g as ImagesInputContent, h as ImagesFunction, i as AssistantImages, it as Transport, j as OpenAICompletionsCompat, k as ModelCostRates, l as CacheRetention, m as ImagesContext, n as Api, nt as ToolCall, o as AssistantMessageEvent, ot as UserMessage, p as ImagesApi, r as AssistantDeliveryTtsFacts, rt as ToolResultMessage, s as AssistantMessageEventStreamContract, st as ValidateToolArgumentsFn, t as AnthropicMessagesCompat, tt as Tool, u as CompleteSimpleFn, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderReplayState } from "./types-DmeScJQe.mjs";
|
|
4
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-DcQzYRWO.mjs";
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-DPDgbaD3.mjs";
|
|
6
|
+
import "./types-DmdQ-xcq.mjs";
|
|
7
7
|
//#region packages/ai/src/provider-types.d.ts
|
|
8
8
|
export declare const PROVIDER_CONTEXT_HANDOFF: unique symbol;
|
|
9
9
|
export type VideoContent = Omit<ImageContent, "type"> & {
|
|
@@ -29,4 +29,4 @@ export type ProviderStreamFunction<TApi extends Api = Api, TOptions extends Stre
|
|
|
29
29
|
/** Resolves provider-only context without widening the canonical call contract. */
|
|
30
30
|
export declare function resolveProviderContext(context: Context | ProviderContext, options?: ProviderStreamOptions): Promise<ProviderContext>;
|
|
31
31
|
//#endregion
|
|
32
|
-
export type { AnthropicMessagesCompat, Api, AssistantDeliveryTtsFacts, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, CacheRetention, CompleteSimpleFn, ProviderContext as Context, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, MaybePromise, ProviderMessage as Message, ProviderModel as Model, ModelCostConfig, ModelCostRates, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, PricingTier, Provider, ProviderImagesOptions, ProviderReplayState, ProviderResponse, ProviderStreamFunction as StreamFunction, RawModelCostConfig, RawPricingTier, SimpleStreamOptions, StopReason, StreamFn, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, calculateUsageCost, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, normalizeModelCostConfig, normalizeResolvedPricing, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
|
32
|
+
export type { AnthropicMessagesCompat, Api, AssistantDeliveryTtsFacts, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, CacheRetention, CompleteSimpleFn, ProviderContext as Context, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, MaybePromise, ProviderMessage as Message, ProviderModel as Model, ModelCostConfig, ModelCostRates, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, PricingTier, Provider, ProviderImagesOptions, ProviderReplayState, ProviderResponse, ProviderStreamFunction as StreamFunction, RawModelCostConfig, RawPricingTier, SimpleStreamOptions, StopReason, StreamFn, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, bindsClaudeThinkingPrefix, calculateUsageCost, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, normalizeModelCostConfig, normalizeResolvedPricing, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus55ModelIdentity, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
package/dist/providers.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
2
|
-
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-
|
|
1
|
+
import { n as ApiRegistry } from "./api-registry-CAK4bNkq.mjs";
|
|
2
|
+
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-BUJI5cW-.mjs";
|
|
3
3
|
//#region packages/ai/src/providers/register-builtins.d.ts
|
|
4
4
|
/** Source id used for built-in API provider registrations. */
|
|
5
5
|
export declare const BUILT_IN_API_PROVIDER_SOURCE_ID = "core:built-in";
|
package/dist/providers.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
2
2
|
import { n as projectProviderError } from "./provider-error-BI8kIViN.mjs";
|
|
3
|
-
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-
|
|
3
|
+
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-CGnVB74a.mjs";
|
|
4
4
|
//#region packages/ai/src/providers/register-builtins.ts
|
|
5
5
|
/** Source id used for built-in API provider registrations. */
|
|
6
6
|
const BUILT_IN_API_PROVIDER_SOURCE_ID = "core:built-in";
|
|
@@ -62,35 +62,35 @@ function createLazyRegistration(api, importModule, select) {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
const registerBuiltIns = [
|
|
65
|
-
createLazyRegistration("anthropic-messages", () => import("./anthropic-
|
|
65
|
+
createLazyRegistration("anthropic-messages", () => import("./anthropic-BNeFhAh3.mjs").then((n) => n.t), (module) => ({
|
|
66
66
|
stream: module.streamAnthropic,
|
|
67
67
|
streamSimple: module.streamSimpleAnthropic
|
|
68
68
|
})),
|
|
69
|
-
createLazyRegistration("openai-completions", () => import("./openai-completions-
|
|
69
|
+
createLazyRegistration("openai-completions", () => import("./openai-completions-BCmKwgsc.mjs").then((n) => n.t), (module) => ({
|
|
70
70
|
stream: module.streamOpenAICompletions,
|
|
71
71
|
streamSimple: module.streamSimpleOpenAICompletions
|
|
72
72
|
})),
|
|
73
|
-
createLazyRegistration("mistral-conversations", () => import("./mistral-
|
|
73
|
+
createLazyRegistration("mistral-conversations", () => import("./mistral-CTcM9TGz.mjs"), (module) => ({
|
|
74
74
|
stream: module.streamMistral,
|
|
75
75
|
streamSimple: module.streamSimpleMistral
|
|
76
76
|
})),
|
|
77
|
-
createLazyRegistration("openai-responses", () => import("./openai-responses-
|
|
77
|
+
createLazyRegistration("openai-responses", () => import("./openai-responses-pMJVxhHW.mjs").then((n) => n.t), (module) => ({
|
|
78
78
|
stream: module.streamOpenAIResponses,
|
|
79
79
|
streamSimple: module.streamSimpleOpenAIResponses
|
|
80
80
|
})),
|
|
81
|
-
createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-
|
|
81
|
+
createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-CPvqFff1.mjs"), (module) => ({
|
|
82
82
|
stream: module.streamAzureOpenAIResponses,
|
|
83
83
|
streamSimple: module.streamSimpleAzureOpenAIResponses
|
|
84
84
|
})),
|
|
85
|
-
createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-
|
|
85
|
+
createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-QqHf1o9v.mjs"), (module) => ({
|
|
86
86
|
stream: module.streamOpenAICodexResponses,
|
|
87
87
|
streamSimple: module.streamSimpleOpenAICodexResponses
|
|
88
88
|
})),
|
|
89
|
-
createLazyRegistration("google-generative-ai", () => import("./google-
|
|
89
|
+
createLazyRegistration("google-generative-ai", () => import("./google-B6pXyWB0.mjs"), (module) => ({
|
|
90
90
|
stream: module.streamGoogle,
|
|
91
91
|
streamSimple: module.streamSimpleGoogle
|
|
92
92
|
})),
|
|
93
|
-
createLazyRegistration("google-vertex", () => import("./google-vertex-
|
|
93
|
+
createLazyRegistration("google-vertex", () => import("./google-vertex-BA2c1toq.mjs"), (module) => ({
|
|
94
94
|
stream: module.streamGoogleVertex,
|
|
95
95
|
streamSimple: module.streamSimpleGoogleVertex
|
|
96
96
|
}))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as requiresClaudeMandatoryAdaptiveThinking, p as resolveClaudeNativeThinkingLevelMap, t as calculateUsageCost } from "./src-BhgSqnbz.mjs";
|
|
2
2
|
//#region packages/ai/src/model-utils.ts
|
|
3
3
|
/** Calculates and stores model cost fields from token usage and per-million pricing. */
|
|
4
4
|
function calculateCost(model, usage) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as normalizeLowercaseStringOrEmpty } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { t as sanitizeSurrogates } from "./sanitize-unicode-
|
|
3
|
-
import { r as copyProviderAcceptanceObserver } from "./transport-stream-shared-
|
|
2
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-Cfcaqa9V.mjs";
|
|
3
|
+
import { r as copyProviderAcceptanceObserver } from "./transport-stream-shared-y1YR1k5K.mjs";
|
|
4
4
|
//#region packages/ai/src/utils/prompt-cache-stability.ts
|
|
5
5
|
/**
|
|
6
6
|
* Prompt-cache normalization helpers. They keep generated prompt sections
|
|
@@ -51,6 +51,19 @@ function resolveClaudeMythos5ModelIdentity(ref) {
|
|
|
51
51
|
if (!match) return;
|
|
52
52
|
return normalized.slice((match.index ?? 0) + (match[0].startsWith("-") ? 1 : 0));
|
|
53
53
|
}
|
|
54
|
+
/** Resolve the Opus 5.5 contract without matching other Opus 5 generations. */
|
|
55
|
+
function resolveClaudeOpus55ModelIdentity(ref) {
|
|
56
|
+
const normalized = resolveClaudeModelIdentity(ref);
|
|
57
|
+
if (normalized === "opus-5-5") return "claude-opus-5-5";
|
|
58
|
+
return /^claude-opus-5-5(?=$|[^a-z0-9])/.test(normalized) ? normalized : void 0;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Prefix-bound thinking requires append-only runtime context. Extend this list
|
|
62
|
+
* only with live replay proof for the model (Mythos 5.1 remains unproven).
|
|
63
|
+
*/
|
|
64
|
+
function bindsClaudeThinkingPrefix(ref) {
|
|
65
|
+
return resolveClaudeOpus55ModelIdentity(ref) !== void 0 || /^claude-fable-5-1(?=$|[^a-z0-9])/.test(resolveClaudeModelIdentity(ref));
|
|
66
|
+
}
|
|
54
67
|
/** Return whether a Claude model requires adaptive thinking instead of manual budgets. */
|
|
55
68
|
function requiresClaudeMandatoryAdaptiveThinking(ref) {
|
|
56
69
|
const modelId = resolveClaudeModelIdentity(ref);
|
|
@@ -187,4 +200,4 @@ function calculateUsageCost(usage, pricing) {
|
|
|
187
200
|
return cost;
|
|
188
201
|
}
|
|
189
202
|
//#endregion
|
|
190
|
-
export {
|
|
203
|
+
export { supportsClaude1MContext as _, CLAUDE_OPUS_5_THINKING_PROFILE as a, supportsClaudeNativeMaxEffort as b, requiresClaudeDefaultSampling as c, resolveClaudeModelIdentity as d, resolveClaudeMythos5ModelIdentity as f, resolveClaudeSonnet5ModelIdentity as g, resolveClaudeOpus5ModelIdentity as h, CLAUDE_FABLE_5_THINKING_PROFILE as i, requiresClaudeMandatoryAdaptiveThinking as l, resolveClaudeOpus55ModelIdentity as m, normalizeModelCostConfig as n, CLAUDE_SONNET_5_THINKING_PROFILE as o, resolveClaudeNativeThinkingLevelMap as p, normalizeResolvedPricing as r, bindsClaudeThinkingPrefix as s, calculateUsageCost as t, resolveClaudeFable5ModelIdentity as u, supportsClaudeAdaptiveThinking as v, supportsClaudeNativeXhighEffort as x, supportsClaudeFastMode as y };
|
package/dist/{tool-schema-json-projection-BtZiml7r.mjs → tool-schema-json-projection-_gcOC21Y.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as isRecord } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { n as getAiTransportHost } from "./host-
|
|
2
|
+
import { n as getAiTransportHost } from "./host-DhlhmyR6.mjs";
|
|
3
3
|
import { types } from "node:util";
|
|
4
4
|
//#region packages/ai/src/transports/host-policy.ts
|
|
5
5
|
function buildGuardedModelFetch(model, timeoutMs, options) {
|
package/dist/{transport-stream-shared-BbG7PThh.d.mts → transport-stream-shared-B38NWYTa.d.mts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { B as ProviderResponse, D as Model, J as StreamOptions, a as AssistantMessage, at as Usage } from "./types-
|
|
3
|
-
import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
4
|
-
import "./event-stream-
|
|
1
|
+
import "./index-DcGDVDnC.mjs";
|
|
2
|
+
import { B as ProviderResponse, D as Model, J as StreamOptions, a as AssistantMessage, at as Usage } from "./types-DmeScJQe.mjs";
|
|
3
|
+
import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-DcQzYRWO.mjs";
|
|
4
|
+
import "./event-stream-CDHaMazK.mjs";
|
|
5
5
|
import { t as ProviderErrorProjection } from "./provider-error-CzNw4BWX.mjs";
|
|
6
6
|
//#region packages/ai/src/utils/stream-first-event-timeout.d.ts
|
|
7
7
|
type StreamStage = "responses" | "completions";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as createAssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
2
2
|
import { a as asOptionalRecord, n as asNonArrayRecord, r as asNullableRecord } from "./utf16-slice-qz3nsy87.mjs";
|
|
3
|
-
import { t as sanitizeSurrogates } from "./sanitize-unicode-
|
|
3
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-Cfcaqa9V.mjs";
|
|
4
4
|
import { n as projectProviderError } from "./provider-error-BI8kIViN.mjs";
|
|
5
5
|
//#region packages/ai/src/utils/headers.ts
|
|
6
6
|
/** Converts a Headers object to a plain record for provider request handling. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as normalizeOptionalString, t as truncateUtf16Safe } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { n as getAiTransportHost } from "./host-
|
|
2
|
+
import { n as getAiTransportHost } from "./host-DhlhmyR6.mjs";
|
|
3
3
|
import { c as parseStrictNonNegativeInteger, i as asFiniteNumberInRange, l as parseStrictPositiveInteger, s as parseStrictFiniteNumber } from "./base64-CEFBpSkN.mjs";
|
|
4
4
|
import { parseRetryAfterHttpDateMs } from "./internal/retry-after.mjs";
|
|
5
5
|
import { createHash } from "node:crypto";
|
package/dist/transports.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { D as Model, K as StreamFn, Q as ThinkingContent, Y as TextContent, a as AssistantMessage, at as Usage, d as Context, j as OpenAICompletionsCompat, n as Api, nt as ToolCall, o as AssistantMessageEvent, z as ProviderReplayState } from "./types-
|
|
3
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
4
|
-
import { a as CodeModeToolSurfaceObservation, d as OpenAIToolProjection, i as BaseOpenAIStreamOptions, o as OpenAICompletionsOptions, s as OpenAIResponsesCompactionRejection } from "./provider-options-
|
|
5
|
-
import "./types-
|
|
6
|
-
import { a as resolveAnthropicPayloadPolicy, i as resolveAnthropicEphemeralCacheControl, n as applyAnthropicEphemeralCacheControlMarkers, o as resolveAnthropicServerCompactionPlan, r as applyAnthropicPayloadPolicyToParams, t as applyAnthropicCacheControlToMessages } from "./anthropic-payload-policy-
|
|
7
|
-
import { a as ReplayableResponseCompactionItem, c as OpenAIResponsesCompactionOutput, i as OpenAIResponsesRequestParams, n as OpenAIResponsesOptions, o as ResponsesPromptObservation, r as OpenAIResponsesReasoningReplayMetadata } from "./openai-responses-contracts-
|
|
1
|
+
import "./index-DcGDVDnC.mjs";
|
|
2
|
+
import { D as Model, K as StreamFn, Q as ThinkingContent, Y as TextContent, a as AssistantMessage, at as Usage, d as Context, j as OpenAICompletionsCompat, n as Api, nt as ToolCall, o as AssistantMessageEvent, z as ProviderReplayState } from "./types-DmeScJQe.mjs";
|
|
3
|
+
import { n as ApiRegistry } from "./api-registry-CAK4bNkq.mjs";
|
|
4
|
+
import { a as CodeModeToolSurfaceObservation, d as OpenAIToolProjection, i as BaseOpenAIStreamOptions, o as OpenAICompletionsOptions, s as OpenAIResponsesCompactionRejection } from "./provider-options-CedgbINH.mjs";
|
|
5
|
+
import "./types-DmdQ-xcq.mjs";
|
|
6
|
+
import { a as resolveAnthropicPayloadPolicy, i as resolveAnthropicEphemeralCacheControl, n as applyAnthropicEphemeralCacheControlMarkers, o as resolveAnthropicServerCompactionPlan, r as applyAnthropicPayloadPolicyToParams, t as applyAnthropicCacheControlToMessages } from "./anthropic-payload-policy-kkq8L7tJ.mjs";
|
|
7
|
+
import { a as ReplayableResponseCompactionItem, c as OpenAIResponsesCompactionOutput, i as OpenAIResponsesRequestParams, n as OpenAIResponsesOptions, o as ResponsesPromptObservation, r as OpenAIResponsesReasoningReplayMetadata } from "./openai-responses-contracts-DFJOyjd1.mjs";
|
|
8
8
|
import { i as resolveOpenAIResponsesServerCompactionPlan, n as resolveOpenAIResponsesCompactEndpointPlan, r as resolveOpenAIResponsesPayloadPolicy, t as applyOpenAIResponsesPayloadPolicy } from "./openai-responses-payload-policy-rLRPsSmB.mjs";
|
|
9
|
-
import { n as detectOpenAICompletionsCompat, r as resolveOpenAICompletionsCompat, t as ResolvedOpenAICompletionsCompat } from "./openai-completions-compat-
|
|
10
|
-
import { C as FirstStreamEventInternalOptions, _ as sanitizeNonEmptyTransportPayloadText, a as copyProviderAcceptanceObserver, b as withProviderAcceptanceObserver, c as failTransportStream, d as mergeTransportHeaders, f as mergeTransportMetadata, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, i as coerceTransportToolCallArguments, l as finalizeTerminalToolCallArguments, m as notifyProviderHttpResponse, n as WritableTransportStream, o as createEmptyTransportUsage, p as notifyProviderHttpMetadata, r as assignTransportErrorDetails, s as createWritableTransportEventStream, t as ProviderAcceptance, u as finalizeTransportStream, v as sanitizeTransportPayloadText, x as withProviderResponseHook, y as transportAbortError } from "./transport-stream-shared-
|
|
9
|
+
import { n as detectOpenAICompletionsCompat, r as resolveOpenAICompletionsCompat, t as ResolvedOpenAICompletionsCompat } from "./openai-completions-compat-BJE92duO.mjs";
|
|
10
|
+
import { C as FirstStreamEventInternalOptions, _ as sanitizeNonEmptyTransportPayloadText, a as copyProviderAcceptanceObserver, b as withProviderAcceptanceObserver, c as failTransportStream, d as mergeTransportHeaders, f as mergeTransportMetadata, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, i as coerceTransportToolCallArguments, l as finalizeTerminalToolCallArguments, m as notifyProviderHttpResponse, n as WritableTransportStream, o as createEmptyTransportUsage, p as notifyProviderHttpMetadata, r as assignTransportErrorDetails, s as createWritableTransportEventStream, t as ProviderAcceptance, u as finalizeTransportStream, v as sanitizeTransportPayloadText, x as withProviderResponseHook, y as transportAbortError } from "./transport-stream-shared-B38NWYTa.mjs";
|
|
11
11
|
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-Cwcjv_fx.mjs";
|
|
12
12
|
import OpenAI from "openai";
|
|
13
13
|
import { ResponseCreateParamsStreaming, ResponseInput, ResponseInputItem as ResponseInputItem$1 } from "openai/resources/responses/responses.js";
|
package/dist/transports.mjs
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { g as
|
|
1
|
+
import { g as resolveClaudeSonnet5ModelIdentity, h as resolveClaudeOpus5ModelIdentity, v as supportsClaudeAdaptiveThinking, x as supportsClaudeNativeXhighEffort } from "./src-BhgSqnbz.mjs";
|
|
2
2
|
import { c as normalizeLowercaseStringOrEmpty, o as isRecord, s as hasNonEmptyString } from "./utf16-slice-qz3nsy87.mjs";
|
|
3
|
-
import { r as calculateCost } from "./sanitize-unicode-
|
|
4
|
-
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, h as defaultsClaudeAdaptiveThinking, 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-
|
|
3
|
+
import { r as calculateCost } from "./sanitize-unicode-Cfcaqa9V.mjs";
|
|
4
|
+
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, h as defaultsClaudeAdaptiveThinking, 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-DhlhmyR6.mjs";
|
|
5
5
|
import { i as stableStringify } from "./provider-error-BI8kIViN.mjs";
|
|
6
|
-
import { n as toErrorObject, t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal
|
|
6
|
+
import { n as toErrorObject, t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal-COaImuDp.mjs";
|
|
7
7
|
import { a as asNonNegativeFiniteNumber } from "./base64-CEFBpSkN.mjs";
|
|
8
8
|
import { n as uniqueStrings } from "./string-normalization--fwJ4S2q.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { r as resolveOpenAIResponsesCacheParams } from "./openai-prompt-cache-CGnVB74a.mjs";
|
|
10
|
+
import { A as createAnthropicInlineImageBudget, B as omitFoundryBearerCredentialHeaders, C as ANTHROPIC_SERVER_SIDE_FALLBACKS, D as readAnthropicFallbackBoundary, E as applyAnthropicFallbackBoundary, F as applyAnthropicPayloadPolicyToParams, I as resolveAnthropicEphemeralCacheControl, L as resolveAnthropicPayloadPolicy, M as resolveAnthropicImageMediaType, N as applyAnthropicCacheControlToMessages, O as resolveAnthropicFallbackServingModelCost, P as applyAnthropicEphemeralCacheControlMarkers, R as resolveAnthropicServerCompactionPlan, S as readAnthropicInputTransformations, V as usesFoundryBearerAuth, _ as toClaudeCodeToolName, a as suppressAnthropicCompaction, b as findActiveAnthropicToolTurnAssistantIndex, f as normalizeAnthropicToolCallId, g as resolveOriginalAnthropicToolName, h as reconcileAnthropicToolChoice, i as resolveNewestAnthropicCompaction, j as normalizeAnthropicInlineContent, k as applyAnthropicRefusal, 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 ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, x as logAnthropicThinkingDrops, y as applyAnthropicThinkingBindingControls, z as isAnthropicOAuthApiKey } from "./anthropic-compaction-replay-B6sEzXhr.mjs";
|
|
10
11
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
11
|
-
import { a as codeModeToolSurfaceObserver, d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName, o as reasoningTagTextPolicy, t as adjustMaxTokensForThinking } from "./simple-options-
|
|
12
|
-
import { a as resolveProviderEndpoint, c as transformTransportMessages, i as resolveOpenAIStrictToolSetting, n as buildGuardedModelFetch } from "./tool-schema-json-projection-
|
|
13
|
-
import { a as isGoogleGemini3FlashModel, c as parseRetryAfterSeconds, f as resolveModelHeaderSentinels$1, i as isCodeModeModelVisibleToolName, l as readResponseTextSnippet, m as supportsModelTools, n as createAbortError$1, o as isGoogleGemini3ProModel, p as sha256Hex, r as estimateStringChars, t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, u as redactIdentifier } from "./transport-utils-
|
|
12
|
+
import { a as codeModeToolSurfaceObserver, d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName, o as reasoningTagTextPolicy, t as adjustMaxTokensForThinking } from "./simple-options-Bwi0x0bX.mjs";
|
|
13
|
+
import { a as resolveProviderEndpoint, c as transformTransportMessages, i as resolveOpenAIStrictToolSetting, n as buildGuardedModelFetch } from "./tool-schema-json-projection-_gcOC21Y.mjs";
|
|
14
|
+
import { a as isGoogleGemini3FlashModel, c as parseRetryAfterSeconds, f as resolveModelHeaderSentinels$1, i as isCodeModeModelVisibleToolName, l as readResponseTextSnippet, m as supportsModelTools, n as createAbortError$1, o as isGoogleGemini3ProModel, p as sha256Hex, r as estimateStringChars, t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, u as redactIdentifier } from "./transport-utils-DdLjoPMb.mjs";
|
|
14
15
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
15
|
-
import { S as quoteUnsafeIntegerLiterals, _ as transportAbortError, a as createWritableTransportEventStream, b as parseJsonObjectPreservingUnsafeIntegers, c as finalizeTransportStream, d as notifyProviderHttpMetadata, f as notifyProviderHttpResponse, g as sanitizeTransportPayloadText, h as sanitizeNonEmptyTransportPayloadText, i as createEmptyTransportUsage, l as mergeTransportHeaders, m as parseTerminalToolCallArguments, n as coerceTransportToolCallArguments, o as failTransportStream, p as notifyProviderStreamOpened, r as copyProviderAcceptanceObserver, s as finalizeTerminalToolCallArguments, t as assignTransportErrorDetails, u as mergeTransportMetadata, v as withProviderAcceptanceObserver, x as parseJsonPreservingUnsafeIntegers, y as withProviderResponseHook } from "./transport-stream-shared-
|
|
16
|
-
import { C as createDeepSeekTextFilter, E as tagUnresolvedTextAsCommentary, S as shouldOmitOllamaCompatResponseFormat, T as tagPendingCommentaryText, _ as hasToolCallHistory, a as buildOpenAISdkClientOptions, b as resolveOpenAICompletionsCompat, c as filterCodeModePayloadTools, d as readCodeModePayloadToolName, f as resolveCodeModeResponsesVisibleToolNames, g as convertMessages, h as resolveOpenAIReasoningEffortMap, i as buildOpenAIClientHeaders, l as getCompat, m as usesNativeOpenAICodexResponsesBackend, n as shouldEmitOpenAICompletionsReasoning, o as buildOpenAISdkRequestOptions, p as resolveOpenAIStrictToolFlagWithDiagnostics, r as assertCodeModeResponsesToolSurface, s as enforceCodeModeResponsesToolSurface, t as processCompletionsStream, u as isOpenAICodexResponsesModel, v as finalizeOpenAICompletionsToolCalls, x as resolveOpenAICompletionsResponseFormat, y as detectOpenAICompletionsCompat } from "./openai-completions-stream-
|
|
16
|
+
import { S as quoteUnsafeIntegerLiterals, _ as transportAbortError, a as createWritableTransportEventStream, b as parseJsonObjectPreservingUnsafeIntegers, c as finalizeTransportStream, d as notifyProviderHttpMetadata, f as notifyProviderHttpResponse, g as sanitizeTransportPayloadText, h as sanitizeNonEmptyTransportPayloadText, i as createEmptyTransportUsage, l as mergeTransportHeaders, m as parseTerminalToolCallArguments, n as coerceTransportToolCallArguments, o as failTransportStream, p as notifyProviderStreamOpened, r as copyProviderAcceptanceObserver, s as finalizeTerminalToolCallArguments, t as assignTransportErrorDetails, u as mergeTransportMetadata, v as withProviderAcceptanceObserver, x as parseJsonPreservingUnsafeIntegers, y as withProviderResponseHook } from "./transport-stream-shared-y1YR1k5K.mjs";
|
|
17
|
+
import { C as createDeepSeekTextFilter, E as tagUnresolvedTextAsCommentary, S as shouldOmitOllamaCompatResponseFormat, T as tagPendingCommentaryText, _ as hasToolCallHistory, a as buildOpenAISdkClientOptions, b as resolveOpenAICompletionsCompat, c as filterCodeModePayloadTools, d as readCodeModePayloadToolName, f as resolveCodeModeResponsesVisibleToolNames, g as convertMessages, h as resolveOpenAIReasoningEffortMap, i as buildOpenAIClientHeaders, l as getCompat, m as usesNativeOpenAICodexResponsesBackend, n as shouldEmitOpenAICompletionsReasoning, o as buildOpenAISdkRequestOptions, p as resolveOpenAIStrictToolFlagWithDiagnostics, r as assertCodeModeResponsesToolSurface, s as enforceCodeModeResponsesToolSurface, t as processCompletionsStream, u as isOpenAICodexResponsesModel, v as finalizeOpenAICompletionsToolCalls, x as resolveOpenAICompletionsResponseFormat, y as detectOpenAICompletionsCompat } from "./openai-completions-stream-0mm4YUag.mjs";
|
|
17
18
|
import { t as createDeferredEventBuffer } from "./deferred-event-buffer-DAvyP7qA.mjs";
|
|
18
19
|
import { r as parseStreamingJson, t as createToolArgumentPreviewSchedule } from "./json-parse-BuAJEbdW.mjs";
|
|
19
20
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
20
21
|
import { t as googleFlashSupportsMinimalThinking } from "./google-thinking-level-C-V3tecN.mjs";
|
|
21
|
-
import { B as buildResponsesInputMessage, C as summarizeResponsesTools, G as captureOpenAIResponsesCompaction, H as createOpenAIResponsesAssistantOutput, I as createResponsesStreamWithEncryptedContentRetry, J as resolveReplayableResponsesMessageId, K as resolveNewestOpenAIResponsesCompactionReplay, L as isInvalidEncryptedContentError, R as resolveAzureOpenAIApiVersion, S as summarizeResponsesPayload, U as CompactionReplayRefreshRequiredError, V as convertResponsesMessages, W as buildOpenAIResponsesReasoningReplayMetadata, X as resolveModelPayloadDebugMode, Y as emitModelTransportDebug, Z as resolveModelSseDebugMode, _ as safeDebugValue, b as summarizeOpenAITransportError, c as processResponsesStream, f as observeResponsesStream, g as normalizeResponsesFailedEvent, h as logResponsesFailedNoDetails, m as buildResponsesFailedNoDetailsObservation, n as applyResponsesServiceTierPricing, p as ResponsesStreamFailure, q as suppressOpenAIResponsesCompaction, v as stringifyRedactedEvent, x as summarizeResponsesFailedNoDetailsObservation, y as stringifyRedactedPayload, z as resolveNextResponsesEncryptedContentAttempt } from "./openai-responses-shared-
|
|
22
|
-
import { A as readOpenAICompletionsReasoningBatch, C as createOpenAIProviderAcceptanceHook, D as measureUtf8AppendBytes, E as log, M as resolvePromptCacheKey, N as throwIfModelStreamAborted, O as parseOpenAICompletionsUsage, S as createModelStreamCooperativeScheduler, T as isOpenAICompletionsThinkingEnabled, b as reconcileOpenAIResponsesToolChoice, j as resolveOpenAIClientBaseUrl, k as readOpenAICompletionsContentDeltas, r as normalizeOpenAIStrictToolParameters, v as projectOpenAITools, w as createOpenAIResponseHook, x as GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, y as reconcileOpenAICompletionsToolChoice } from "./openai-tool-schema-
|
|
22
|
+
import { B as buildResponsesInputMessage, C as summarizeResponsesTools, G as captureOpenAIResponsesCompaction, H as createOpenAIResponsesAssistantOutput, I as createResponsesStreamWithEncryptedContentRetry, J as resolveReplayableResponsesMessageId, K as resolveNewestOpenAIResponsesCompactionReplay, L as isInvalidEncryptedContentError, R as resolveAzureOpenAIApiVersion, S as summarizeResponsesPayload, U as CompactionReplayRefreshRequiredError, V as convertResponsesMessages, W as buildOpenAIResponsesReasoningReplayMetadata, X as resolveModelPayloadDebugMode, Y as emitModelTransportDebug, Z as resolveModelSseDebugMode, _ as safeDebugValue, b as summarizeOpenAITransportError, c as processResponsesStream, f as observeResponsesStream, g as normalizeResponsesFailedEvent, h as logResponsesFailedNoDetails, m as buildResponsesFailedNoDetailsObservation, n as applyResponsesServiceTierPricing, p as ResponsesStreamFailure, q as suppressOpenAIResponsesCompaction, v as stringifyRedactedEvent, x as summarizeResponsesFailedNoDetailsObservation, y as stringifyRedactedPayload, z as resolveNextResponsesEncryptedContentAttempt } from "./openai-responses-shared-CZTRmOFP.mjs";
|
|
23
|
+
import { A as readOpenAICompletionsReasoningBatch, C as createOpenAIProviderAcceptanceHook, D as measureUtf8AppendBytes, E as log, M as resolvePromptCacheKey, N as throwIfModelStreamAborted, O as parseOpenAICompletionsUsage, S as createModelStreamCooperativeScheduler, T as isOpenAICompletionsThinkingEnabled, b as reconcileOpenAIResponsesToolChoice, j as resolveOpenAIClientBaseUrl, k as readOpenAICompletionsContentDeltas, r as normalizeOpenAIStrictToolParameters, v as projectOpenAITools, w as createOpenAIResponseHook, x as GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, y as reconcileOpenAICompletionsToolChoice } from "./openai-tool-schema-DjS9-DHe.mjs";
|
|
23
24
|
import { i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-DcNjoFQE.mjs";
|
|
24
|
-
import { C as isOpenAIGpt54MiniModel, D as resolveOpenAIReasoningEffortForModel, E as normalizeOpenAIReasoningEffort, T as isOpenAIGpt56Model, _ as OpenAIResponsesWebSocketPostDispatchError, a as applyOpenAIResponsesPayloadPolicy, c as resolveOpenAIResponsesServerCompactionPlan, d as OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS, f as OPENAI_RESPONSES_APIS, i as sanitizeResponsesImagePayload, l as AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS, n as isOpenAIResponsesCompactionOutput, o as resolveOpenAIResponsesCompactEndpointPlan, s as resolveOpenAIResponsesPayloadPolicy, t as createBoundedOpenAIResponsesCompactionFetch, v as OpenAIResponsesWebSocketPreDispatchError, w as isOpenAIGpt55Model, x as parseOpenAIResponsesWebSocketServerError, y as OpenAIResponsesWebSocketSafeRetryError } from "./openai-responses-compaction-window-
|
|
25
|
+
import { A as supportsOpenAITemperature, C as isOpenAIGpt54MiniModel, D as resolveOpenAIReasoningEffortForModel, E as normalizeOpenAIReasoningEffort, T as isOpenAIGpt56Model, _ as OpenAIResponsesWebSocketPostDispatchError, a as applyOpenAIResponsesPayloadPolicy, c as resolveOpenAIResponsesServerCompactionPlan, d as OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS, f as OPENAI_RESPONSES_APIS, i as sanitizeResponsesImagePayload, l as AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS, n as isOpenAIResponsesCompactionOutput, o as resolveOpenAIResponsesCompactEndpointPlan, s as resolveOpenAIResponsesPayloadPolicy, t as createBoundedOpenAIResponsesCompactionFetch, v as OpenAIResponsesWebSocketPreDispatchError, w as isOpenAIGpt55Model, x as parseOpenAIResponsesWebSocketServerError, y as OpenAIResponsesWebSocketSafeRetryError } from "./openai-responses-compaction-window-vuCaZYLS.mjs";
|
|
25
26
|
import { i as resolveAzureDeploymentNameFromMap, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-C7K7QfUE.mjs";
|
|
26
27
|
import { n as registerSessionResourceCleanup } from "./session-resources-CkR4WWy1.mjs";
|
|
27
28
|
import { randomUUID } from "node:crypto";
|
|
@@ -132,14 +133,13 @@ async function convertAnthropicMessages(messages, model, isOAuthToken, options)
|
|
|
132
133
|
const msg = transformedMessages[i];
|
|
133
134
|
if (!msg) continue;
|
|
134
135
|
if (msg.role === "user") {
|
|
135
|
-
const isRuntimeContextCarrier = msg.runtimeContextCarrier === true;
|
|
136
136
|
if (typeof msg.content === "string") {
|
|
137
137
|
if (msg.content.trim().length > 0) {
|
|
138
|
+
if (msg.runtimeContextCarrier && !msg.runtimeContextCarrierRetained) options.cacheBreakpointOptOutMessageIndexes?.add(params.length);
|
|
138
139
|
const userParam = {
|
|
139
140
|
role: "user",
|
|
140
141
|
content: sanitizeTransportPayloadText(msg.content)
|
|
141
142
|
};
|
|
142
|
-
if (isRuntimeContextCarrier) options.cacheBreakpointOptOutMessageIndexes.add(params.length);
|
|
143
143
|
params.push(userParam);
|
|
144
144
|
}
|
|
145
145
|
continue;
|
|
@@ -161,11 +161,11 @@ async function convertAnthropicMessages(messages, model, isOAuthToken, options)
|
|
|
161
161
|
let filteredBlocks = model.input.includes("image") ? blocks : blocks.filter((block) => block.type !== "image");
|
|
162
162
|
filteredBlocks = filteredBlocks.filter((block) => block.type !== "text" || block.text.trim().length > 0);
|
|
163
163
|
if (filteredBlocks.length === 0) continue;
|
|
164
|
+
if (msg.runtimeContextCarrier && !msg.runtimeContextCarrierRetained) options.cacheBreakpointOptOutMessageIndexes?.add(params.length);
|
|
164
165
|
const userParam = {
|
|
165
166
|
role: "user",
|
|
166
167
|
content: filteredBlocks
|
|
167
168
|
};
|
|
168
|
-
if (isRuntimeContextCarrier) options.cacheBreakpointOptOutMessageIndexes.add(params.length);
|
|
169
169
|
params.push(userParam);
|
|
170
170
|
continue;
|
|
171
171
|
}
|
|
@@ -401,12 +401,13 @@ async function* parseAnthropicSseBody(body, signal) {
|
|
|
401
401
|
function createAnthropicMessagesClient(params) {
|
|
402
402
|
const url = resolveAnthropicMessagesUrl(params.baseURL);
|
|
403
403
|
return { messages: { async stream(body, options) {
|
|
404
|
-
const headers = mergeTransportHeaders({
|
|
404
|
+
const headers = new Headers(mergeTransportHeaders({
|
|
405
405
|
"content-type": "application/json",
|
|
406
406
|
"anthropic-version": "2023-06-01",
|
|
407
407
|
...params.apiKey ? { "x-api-key": params.apiKey } : {},
|
|
408
408
|
...params.authToken ? { authorization: `Bearer ${params.authToken}` } : {}
|
|
409
|
-
}, params.defaultHeaders);
|
|
409
|
+
}, params.defaultHeaders));
|
|
410
|
+
for (const [name, value] of Object.entries(options?.headers ?? {})) headers.set(name, value);
|
|
410
411
|
const response = await params.fetch(url, {
|
|
411
412
|
method: "POST",
|
|
412
413
|
headers,
|
|
@@ -498,18 +499,20 @@ function createAnthropicTransportClient(params) {
|
|
|
498
499
|
}
|
|
499
500
|
if (useAnthropicServerSideFallback(model)) betaFeatures.push(ANTHROPIC_SERVER_SIDE_FALLBACK_BETA);
|
|
500
501
|
const betaHeader = buildAnthropicBetaHeader(model, betaFeatures, { oauth: false });
|
|
502
|
+
const defaultHeaders = mergeTransportHeaders({
|
|
503
|
+
accept: "application/json",
|
|
504
|
+
"anthropic-dangerous-direct-browser-access": "true",
|
|
505
|
+
...betaHeader ? { "anthropic-beta": betaHeader } : {}
|
|
506
|
+
}, model.headers, options?.headers);
|
|
501
507
|
return {
|
|
502
508
|
client: createAnthropicMessagesClient({
|
|
503
509
|
apiKey,
|
|
504
510
|
baseURL: model.baseUrl,
|
|
505
|
-
defaultHeaders
|
|
506
|
-
accept: "application/json",
|
|
507
|
-
"anthropic-dangerous-direct-browser-access": "true",
|
|
508
|
-
...betaHeader ? { "anthropic-beta": betaHeader } : {}
|
|
509
|
-
}, model.headers, options?.headers),
|
|
511
|
+
defaultHeaders,
|
|
510
512
|
fetch
|
|
511
513
|
}),
|
|
512
|
-
isOAuthToken: false
|
|
514
|
+
isOAuthToken: false,
|
|
515
|
+
directApiKeyBetaHeader: isDirectAnthropicModel(model) ? new Headers(defaultHeaders).get("anthropic-beta") ?? "" : void 0
|
|
513
516
|
};
|
|
514
517
|
}
|
|
515
518
|
async function buildAnthropicParams(model, context, isOAuthToken, options) {
|
|
@@ -528,17 +531,17 @@ async function buildAnthropicParams(model, context, isOAuthToken, options) {
|
|
|
528
531
|
cacheRetention: options?.cacheRetention,
|
|
529
532
|
enableCacheControl: true
|
|
530
533
|
}, model);
|
|
531
|
-
const cacheBreakpointOptOutMessageIndexes = /* @__PURE__ */ new Set();
|
|
532
534
|
const replayPlan = buildAnthropicReplayPlan(context.messages, model, {
|
|
533
535
|
enabled: !isOAuthToken && options?.anthropicServerCompaction === true,
|
|
534
536
|
authProfileId: options?.authProfileId,
|
|
535
537
|
sessionId: options?.sessionId
|
|
536
538
|
});
|
|
539
|
+
const cacheBreakpointOptOutMessageIndexes = /* @__PURE__ */ new Set();
|
|
537
540
|
const messages = await convertAnthropicMessages(replayPlan.messages, model, isOAuthToken, {
|
|
538
541
|
allowReasoningContentReplay: supportsReasoningContentReplay(model),
|
|
539
|
-
cacheBreakpointOptOutMessageIndexes,
|
|
540
542
|
compaction: replayPlan.compaction,
|
|
541
|
-
replayThinkingEnabled
|
|
543
|
+
replayThinkingEnabled,
|
|
544
|
+
cacheBreakpointOptOutMessageIndexes
|
|
542
545
|
});
|
|
543
546
|
const params = {
|
|
544
547
|
model: resolveAnthropicRequestModelId(model),
|
|
@@ -675,12 +678,13 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
675
678
|
let costModel = model;
|
|
676
679
|
let messageStartPromptUsage;
|
|
677
680
|
let usedCompactionReplay = false;
|
|
681
|
+
let inputTransformations;
|
|
678
682
|
try {
|
|
679
683
|
const apiKey = options?.apiKey ?? getEnvApiKey(model.provider) ?? "";
|
|
680
684
|
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
681
685
|
const transportOptions = resolveAnthropicTransportOptions(model, options, apiKey);
|
|
682
686
|
const requestContext = prepareClaudeNoPrefillRequestContext(model, context);
|
|
683
|
-
const { client, isOAuthToken } = createAnthropicTransportClient({
|
|
687
|
+
const { client, isOAuthToken, directApiKeyBetaHeader } = createAnthropicTransportClient({
|
|
684
688
|
model,
|
|
685
689
|
context: requestContext,
|
|
686
690
|
apiKey,
|
|
@@ -693,10 +697,14 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
693
697
|
const nextParams = await transportOptions.onPayload?.(params, model);
|
|
694
698
|
if (nextParams !== void 0) params = nextParams;
|
|
695
699
|
applyClaudeRequestContract(params, model);
|
|
700
|
+
const bindingHeaders = applyAnthropicThinkingBindingControls(params, directApiKeyBetaHeader);
|
|
696
701
|
const { response, stream: anthropicStream } = await client.messages.stream({
|
|
697
702
|
...params,
|
|
698
703
|
stream: true
|
|
699
|
-
},
|
|
704
|
+
}, {
|
|
705
|
+
signal: transportOptions.signal,
|
|
706
|
+
headers: bindingHeaders
|
|
707
|
+
});
|
|
700
708
|
await notifyProviderHttpResponse({
|
|
701
709
|
options: transportOptions,
|
|
702
710
|
response,
|
|
@@ -811,6 +819,7 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
811
819
|
});
|
|
812
820
|
};
|
|
813
821
|
for await (const event of anthropicStream) {
|
|
822
|
+
inputTransformations = readAnthropicInputTransformations(event) ?? inputTransformations;
|
|
814
823
|
if (event.type === "error") {
|
|
815
824
|
const error = event.error;
|
|
816
825
|
throw new Error(error?.message || "Anthropic Messages stream failed");
|
|
@@ -1148,6 +1157,8 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
1148
1157
|
for (const block of output.content) delete block.index;
|
|
1149
1158
|
}
|
|
1150
1159
|
});
|
|
1160
|
+
} finally {
|
|
1161
|
+
logAnthropicThinkingDrops(inputTransformations);
|
|
1151
1162
|
}
|
|
1152
1163
|
})();
|
|
1153
1164
|
return eventStream;
|
|
@@ -2063,10 +2074,6 @@ function convertResponsesTools(tools, model, options) {
|
|
|
2063
2074
|
})
|
|
2064
2075
|
};
|
|
2065
2076
|
}
|
|
2066
|
-
function getPromptCacheRetention(baseUrl, cacheRetention) {
|
|
2067
|
-
if (cacheRetention !== "long") return;
|
|
2068
|
-
return baseUrl?.includes("api.openai.com") ? "24h" : void 0;
|
|
2069
|
-
}
|
|
2070
2077
|
function resolveOpenAIReasoningEffort(options) {
|
|
2071
2078
|
return normalizeOpenAIReasoningEffort(options?.reasoningEffort ?? options?.reasoning ?? "high");
|
|
2072
2079
|
}
|
|
@@ -2177,14 +2184,14 @@ function buildOpenAIResponsesParams(model, context, options, metadata, replayMod
|
|
|
2177
2184
|
input: messages,
|
|
2178
2185
|
stream: true,
|
|
2179
2186
|
prompt_cache_key: promptCacheKey,
|
|
2180
|
-
|
|
2187
|
+
...resolveOpenAIResponsesCacheParams(model, cacheRetention, model.baseUrl?.includes("api.openai.com")),
|
|
2181
2188
|
...instructions ? { instructions } : {},
|
|
2182
2189
|
...metadata ? { metadata } : {}
|
|
2183
2190
|
};
|
|
2184
2191
|
const effectiveMaxTokens = options?.maxTokens || model.maxTokens;
|
|
2185
2192
|
if (effectiveMaxTokens) params.max_output_tokens = effectiveMaxTokens;
|
|
2186
|
-
if (options?.temperature !== void 0) params.temperature = options.temperature;
|
|
2187
|
-
if (options?.topP !== void 0) params.top_p = options.topP;
|
|
2193
|
+
if (options?.temperature !== void 0 && supportsOpenAITemperature(model)) params.temperature = options.temperature;
|
|
2194
|
+
if (options?.topP !== void 0 && model.id !== "gpt-6-astra") params.top_p = options.topP;
|
|
2188
2195
|
if (options?.responseFormat !== void 0) params.text = {
|
|
2189
2196
|
...params.text,
|
|
2190
2197
|
format: resolveOpenAIResponsesTextFormat(options.responseFormat)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index-DcGDVDnC.mjs";
|