@openclaw/ai 2026.7.2-beta.4 → 2026.7.2-beta.6
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-CrUDIBpM.mjs → anthropic-CH4UUnZr.mjs} +26 -441
- package/dist/{anthropic-BoTnz8cv.d.mts → anthropic-SrGtwsJu.d.mts} +27 -1
- package/dist/anthropic-usage-DWU-x8MI.mjs +459 -0
- package/dist/{api-registry-BMphkFf1.d.mts → api-registry-DlMgPR39.d.mts} +1 -1
- package/dist/{azure-openai-responses-CbrpVeEv.mjs → azure-openai-responses-CImcwB83.mjs} +4 -4
- package/dist/cache-retention-0x979a5V.mjs +12 -0
- package/dist/deferred-event-buffer-DAvyP7qA.mjs +19 -0
- package/dist/error-coercion-DgxlWC0n.mjs +15 -0
- package/dist/{event-stream-Douf9dob.d.mts → event-stream-YjaPW20U.d.mts} +1 -1
- package/dist/event-stream.d.mts +1 -1
- package/dist/{github-copilot-headers-BsH5cqGj.mjs → github-copilot-headers-NCJtz9i0.mjs} +1 -12
- package/dist/{google-Cs62KA7t.mjs → google-CtSg0iTS.mjs} +3 -3
- package/dist/{google-shared-CMLI-tCZ.mjs → google-shared-DNBz5rcD.mjs} +7 -4
- package/dist/{google-vertex-B4SD3U0f.mjs → google-vertex-31f1uS9L.mjs} +3 -3
- package/dist/{host-WvWBo4h8.d.mts → host-B9GUmcra.d.mts} +2 -2
- package/dist/host-Dog2WQiR.mjs +369 -0
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +3 -3
- package/dist/internal/anthropic.d.mts +16 -62
- package/dist/internal/anthropic.mjs +5 -4
- package/dist/internal/openai.d.mts +260 -2
- package/dist/internal/openai.mjs +7 -5
- package/dist/internal/runtime.d.mts +8 -32
- package/dist/internal/runtime.mjs +7 -6
- package/dist/internal/shared.d.mts +14 -9
- package/dist/internal/shared.mjs +6 -2
- package/dist/{llm-request-activity-CehVkZP-.mjs → llm-request-activity-BjtkplhG.mjs} +1 -19
- package/dist/{mistral-D5Ps7Led.mjs → mistral-CWmpvWYh.mjs} +7 -4
- package/dist/number-coercion-DvG7SNMg.mjs +129 -0
- package/dist/{openai-chatgpt-responses-h0o5yV8Y.mjs → openai-chatgpt-responses-B84Ibtrd.mjs} +33 -29
- package/dist/{openai-completions-exO8NFQf.mjs → openai-completions-DsOxhOD1.mjs} +28 -482
- package/dist/openai-completions-compat-DBWjXoMZ.d.mts +43 -0
- package/dist/openai-prompt-cache-2uo_1OR1.d.mts +7 -0
- package/dist/openai-prompt-cache-mZTCdRPo.mjs +12 -0
- package/dist/openai-reasoning-compat-YgeLncHw.mjs +396 -0
- package/dist/{openai-responses-BHpmtUKo.mjs → openai-responses-BT7A3sLu.mjs} +7 -5
- package/dist/openai-responses-shared-pXl6Wd8S.mjs +392 -0
- package/dist/{openai-responses-shared-CzCurmY1.mjs → openai-responses-stream-internal-Cw5txaGW.mjs} +1609 -1037
- package/dist/{openai-tool-projection-ITOU9bG1.mjs → openai-tool-projection-OhX64DoP.mjs} +26 -11
- package/dist/prompt-cache-stability-Cwcjv_fx.d.mts +13 -0
- package/dist/{provider-error-C4VvV_3t.mjs → provider-error-CAEvRjry.mjs} +8 -2
- package/dist/provider-options-D8bB3z9b.d.mts +144 -0
- package/dist/providers.d.mts +3 -2
- package/dist/providers.mjs +10 -9
- package/dist/reasoning-tag-text-partitioner-CGDyLWUR.mjs +12209 -0
- package/dist/simple-options-9lhRrN73.mjs +50 -0
- package/dist/{src-CXno1H5g.mjs → src-QkygScBs.mjs} +23 -4
- package/dist/stream-first-event-timeout-BBys9hSb.mjs +86 -0
- package/dist/stream-first-event-timeout-DvDeSucC.d.mts +29 -0
- package/dist/tls-certificate-errors-DXSpluKI.mjs +93 -0
- package/dist/tool-result-text-CTpIRbYd.mjs +225 -0
- package/dist/transform-messages-C8mBqZxF.mjs +2 -0
- package/dist/transport-stream-shared-D81p90xq.mjs +297 -0
- package/dist/transports.d.mts +115 -132
- package/dist/transports.mjs +400 -1991
- package/dist/{types-AFwwWium.d.mts → types-bzp5k29J.d.mts} +7 -0
- package/dist/types.d.mts +5 -5
- package/dist/types.mjs +2 -2
- package/dist/{validation-sxvxC8J-.d.mts → validation-B-j7cOYp.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/package.json +4 -5
- package/dist/host-XYGZcgO8.mjs +0 -98
- package/dist/model-utils-1GiZ2_rr.mjs +0 -64
- package/dist/openai-CoGicoDt.d.mts +0 -332
- package/dist/reasoning-tag-text-partitioner-BlVe67g6.mjs +0 -400
- package/dist/stream-first-event-timeout-DP4xEyBY.mjs +0 -150
- package/dist/system-prompt-cache-boundary-CbHeV4_l.mjs +0 -526
- package/npm-shrinkwrap.json +0 -638
|
@@ -45,6 +45,11 @@ interface ProviderResponse {
|
|
|
45
45
|
interface StreamOptions {
|
|
46
46
|
temperature?: number;
|
|
47
47
|
maxTokens?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Optional JSON Schema for the generated response. Providers that support
|
|
50
|
+
* constrained decoding map it to their native request shape; others ignore it.
|
|
51
|
+
*/
|
|
52
|
+
responseFormat?: Record<string, unknown>;
|
|
48
53
|
/**
|
|
49
54
|
* Stop sequences forwarded to providers that support them. Providers map this
|
|
50
55
|
* to their native request field, such as OpenAI `stop` or Anthropic
|
|
@@ -427,6 +432,8 @@ interface OpenAICompletionsCompat {
|
|
|
427
432
|
zaiToolStream?: boolean;
|
|
428
433
|
/** Whether the provider supports the `strict` field in tool definitions. Default: true. */
|
|
429
434
|
supportsStrictMode?: boolean;
|
|
435
|
+
/** Whether the provider supports JSON Schema through `response_format`. Default: false for unknown compatible endpoints. */
|
|
436
|
+
supportsJsonSchemaResponseFormat?: boolean;
|
|
430
437
|
/** Cache control convention for prompt caching. "anthropic" applies Anthropic-style `cache_control` markers to the system prompt, last tool definition, and last user/assistant text content. */
|
|
431
438
|
cacheControlFormat?: "anthropic";
|
|
432
439
|
/** Whether to send known session-affinity headers (`session_id`, `x-client-request-id`, `x-session-affinity`) from `options.sessionId` when caching is enabled. Default: false. */
|
package/dist/types.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, f as supportsClaude1MContext, g as supportsClaudeNativeXhighEffort, h as supportsClaudeNativeMaxEffort, i as requiresClaudeDefaultSampling, l as resolveClaudeNativeThinkingLevelMap, m as supportsClaudeFastMode, n as CLAUDE_OPUS_5_THINKING_PROFILE, o as resolveClaudeFable5ModelIdentity, p as supportsClaudeAdaptiveThinking, r as CLAUDE_SONNET_5_THINKING_PROFILE, s as resolveClaudeModelIdentity, t as CLAUDE_FABLE_5_THINKING_PROFILE, u as resolveClaudeOpus5ModelIdentity } from "./anthropic-SrGtwsJu.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 VercelGatewayRouting, A as OpenRouterRouting, B as TextContent, C as KnownImagesProvider, D as ModelThinkingLevel, E as Model, F as SimpleStreamOptions, G as ThinkingLevelMap, H as ThinkingBudgets, I as StopReason, J as ToolResultMessage, K as Tool, L as StreamFn, M as ProviderImagesOptions, N as ProviderResponse, O as OpenAICompletionsCompat, P as ProviderStreamOptions, Q as ValidateToolArgumentsFn, R as StreamFunction, S as KnownImagesApi, T as Message, U as ThinkingContent, V as TextSignatureV1, W as ThinkingLevel, X as Usage, Y as Transport, Z as UserMessage, _ as ImagesOptions, a as AssistantMessageEvent, b as ImagesStopReason, c as CacheRetention, d as ImageContent, f as ImagesApi, g as ImagesModel, h as ImagesInputContent, i as AssistantMessage, j as Provider, k as OpenAIResponsesCompat, l as CompleteSimpleFn, m as ImagesFunction, n as Api, o as AssistantMessageEventStreamContract, p as ImagesContext, q as ToolCall, r as AssistantImages, s as AssistantMessageEventStreamLike, t as AnthropicMessagesCompat, u as Context, v as ImagesOutputContent, w as MaybePromise, x as KnownApi, y as ImagesProvider, z as StreamOptions } 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
|
-
export { AnthropicMessagesCompat, Api, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, CacheRetention, CompleteSimpleFn, Context, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, MaybePromise, Message, Model, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, Provider, ProviderImagesOptions, ProviderResponse, ProviderStreamOptions, SimpleStreamOptions, StopReason, StreamFn, StreamFunction, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeSonnet5ModelIdentity, supportsClaudeAdaptiveThinking, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
|
3
|
+
import { $ as VercelGatewayRouting, A as OpenRouterRouting, B as TextContent, C as KnownImagesProvider, D as ModelThinkingLevel, E as Model, F as SimpleStreamOptions, G as ThinkingLevelMap, H as ThinkingBudgets, I as StopReason, J as ToolResultMessage, K as Tool, L as StreamFn, M as ProviderImagesOptions, N as ProviderResponse, O as OpenAICompletionsCompat, P as ProviderStreamOptions, Q as ValidateToolArgumentsFn, R as StreamFunction, S as KnownImagesApi, T as Message, U as ThinkingContent, V as TextSignatureV1, W as ThinkingLevel, X as Usage, Y as Transport, Z as UserMessage, _ as ImagesOptions, a as AssistantMessageEvent, b as ImagesStopReason, c as CacheRetention, d as ImageContent, f as ImagesApi, g as ImagesModel, h as ImagesInputContent, i as AssistantMessage, j as Provider, k as OpenAIResponsesCompat, l as CompleteSimpleFn, m as ImagesFunction, n as Api, o as AssistantMessageEventStreamContract, p as ImagesContext, q as ToolCall, r as AssistantImages, s as AssistantMessageEventStreamLike, t as AnthropicMessagesCompat, u as Context, v as ImagesOutputContent, w as MaybePromise, x as KnownApi, y as ImagesProvider, z as StreamOptions } from "./types-bzp5k29J.mjs";
|
|
4
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-YjaPW20U.mjs";
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-B-j7cOYp.mjs";
|
|
6
|
+
export { AnthropicMessagesCompat, Api, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, CacheRetention, CompleteSimpleFn, Context, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, MaybePromise, Message, Model, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, Provider, ProviderImagesOptions, ProviderResponse, ProviderStreamOptions, SimpleStreamOptions, StopReason, StreamFn, StreamFunction, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
package/dist/types.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, f as supportsClaude1MContext, g as supportsClaudeNativeXhighEffort, h as supportsClaudeNativeMaxEffort, i as requiresClaudeDefaultSampling, l as resolveClaudeNativeThinkingLevelMap, m as supportsClaudeFastMode, n as CLAUDE_OPUS_5_THINKING_PROFILE, o as resolveClaudeFable5ModelIdentity, p as supportsClaudeAdaptiveThinking, r as CLAUDE_SONNET_5_THINKING_PROFILE, s as resolveClaudeModelIdentity, t as CLAUDE_FABLE_5_THINKING_PROFILE, u as resolveClaudeOpus5ModelIdentity } from "./src-QkygScBs.mjs";
|
|
2
2
|
import { i as formatThrownValue, n as createAssistantMessageDiagnostic, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-COpOtRwq.mjs";
|
|
3
3
|
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
|
|
4
4
|
import { n as validateToolCall, t as validateToolArguments } from "./validation-DAa_yFOM.mjs";
|
|
5
|
-
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, EventStream, appendAssistantMessageDiagnostic, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeSonnet5ModelIdentity, supportsClaudeAdaptiveThinking, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
|
5
|
+
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, EventStream, appendAssistantMessageDiagnostic, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
package/dist/validation.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
1
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-B-j7cOYp.mjs";
|
|
2
2
|
export { validateToolArguments, validateToolCall };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/ai",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.6",
|
|
4
4
|
"description": "Reusable model provider adapters and streaming runtime from OpenClaw",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
27
|
-
"npm-shrinkwrap.json",
|
|
28
27
|
"LICENSE",
|
|
29
28
|
"README.md"
|
|
30
29
|
],
|
|
@@ -94,10 +93,10 @@
|
|
|
94
93
|
}
|
|
95
94
|
},
|
|
96
95
|
"dependencies": {
|
|
97
|
-
"@anthropic-ai/sdk": "0.
|
|
98
|
-
"@google/genai": "2.
|
|
96
|
+
"@anthropic-ai/sdk": "0.115.0",
|
|
97
|
+
"@google/genai": "2.13.0",
|
|
99
98
|
"@mistralai/mistralai": "2.5.0",
|
|
100
|
-
"openai": "6.
|
|
99
|
+
"openai": "6.49.0",
|
|
101
100
|
"partial-json": "0.1.7",
|
|
102
101
|
"typebox": "1.3.6"
|
|
103
102
|
},
|
package/dist/host-XYGZcgO8.mjs
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
//#region packages/ai/src/host.ts
|
|
2
|
-
const MAX_PENDING_CUSTOM_API_REGISTRATIONS = 32;
|
|
3
|
-
const pendingCustomApiRegistrations = [];
|
|
4
|
-
function queueCustomApiRegistration(registry, api, streamFn) {
|
|
5
|
-
const existing = pendingCustomApiRegistrations.find((registration) => registration.registry === registry && registration.api === api);
|
|
6
|
-
if (existing) {
|
|
7
|
-
existing.streamFn = streamFn;
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
if (pendingCustomApiRegistrations.length >= MAX_PENDING_CUSTOM_API_REGISTRATIONS) throw new Error("Too many custom transport APIs were registered before host configuration");
|
|
11
|
-
pendingCustomApiRegistrations.push({
|
|
12
|
-
registry,
|
|
13
|
-
api,
|
|
14
|
-
streamFn
|
|
15
|
-
});
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const inertAiTransportHost = {
|
|
19
|
-
buildModelFetch: () => void 0,
|
|
20
|
-
resolveSecretSentinel: (value) => value,
|
|
21
|
-
redactSecrets: (value) => value,
|
|
22
|
-
redactToolPayloadText: (text) => text,
|
|
23
|
-
normalizeAnthropicInlineContentBlocks: async (content) => [...content],
|
|
24
|
-
resolveOpenAIStrictToolSetting: (_model, options) => options?.supportsStrictMode ? false : void 0,
|
|
25
|
-
plugin: {
|
|
26
|
-
resolveProviderStream: () => void 0,
|
|
27
|
-
resolveTransportTurnState: () => void 0,
|
|
28
|
-
wrapSimpleCompletionStream: () => void 0,
|
|
29
|
-
createAnthropicVertexStream: () => {
|
|
30
|
-
throw new Error("Anthropic Vertex transport is not configured by the embedding host");
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
buildCopilotDynamicHeaders: () => ({}),
|
|
34
|
-
resolveProviderEndpointClass: () => "default",
|
|
35
|
-
resolveProviderRequestCapabilities: () => ({
|
|
36
|
-
endpointClass: "default",
|
|
37
|
-
knownProviderFamily: "",
|
|
38
|
-
supportsNativeStreamingUsageCompat: false,
|
|
39
|
-
supportsOpenAICompletionsStreamingUsageCompat: false,
|
|
40
|
-
usesExplicitProxyLikeEndpoint: false,
|
|
41
|
-
allowsAnthropicServiceTier: false
|
|
42
|
-
}),
|
|
43
|
-
resolveProviderRequestHeaders: ({ providerHeaders, callerHeaders, precedence }) => ({
|
|
44
|
-
...precedence === "caller-wins" ? providerHeaders : callerHeaders,
|
|
45
|
-
...precedence === "caller-wins" ? callerHeaders : providerHeaders
|
|
46
|
-
}),
|
|
47
|
-
resolveModelRequestTimeoutMs: () => void 0,
|
|
48
|
-
requiresManagedTransport: () => false,
|
|
49
|
-
inheritManagedTransport: (_source, target) => target,
|
|
50
|
-
transformTransportMessages: (messages) => messages,
|
|
51
|
-
registerCustomApi: queueCustomApiRegistration,
|
|
52
|
-
prepareGoogleSimpleCompletionModel: (_registry, model) => model,
|
|
53
|
-
logDebug: () => {},
|
|
54
|
-
logInfo: () => {},
|
|
55
|
-
logWarn: () => {}
|
|
56
|
-
};
|
|
57
|
-
let activeAiTransportHost = inertAiTransportHost;
|
|
58
|
-
/** Installs host implementations for the transport policy ports. */
|
|
59
|
-
function configureAiTransportHost(host) {
|
|
60
|
-
activeAiTransportHost = {
|
|
61
|
-
...inertAiTransportHost,
|
|
62
|
-
...host,
|
|
63
|
-
normalizeAnthropicInlineContentBlocks: host.normalizeAnthropicInlineContentBlocks ?? inertAiTransportHost.normalizeAnthropicInlineContentBlocks,
|
|
64
|
-
plugin: {
|
|
65
|
-
...inertAiTransportHost.plugin,
|
|
66
|
-
...host.plugin
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const transportHost = activeAiTransportHost;
|
|
70
|
-
if (transportHost.registerCustomApi === inertAiTransportHost.registerCustomApi || pendingCustomApiRegistrations.length === 0) return;
|
|
71
|
-
const pending = pendingCustomApiRegistrations.splice(0);
|
|
72
|
-
for (const [index, registration] of pending.entries()) try {
|
|
73
|
-
transportHost.registerCustomApi(registration.registry, registration.api, registration.streamFn);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
pendingCustomApiRegistrations.unshift(...pending.slice(index));
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/** Returns the active transport host (inert defaults unless configured). */
|
|
80
|
-
function getAiTransportHost() {
|
|
81
|
-
return activeAiTransportHost;
|
|
82
|
-
}
|
|
83
|
-
/** Resolves sentinel substrings in custom headers at a no-fetch adapter boundary. */
|
|
84
|
-
function resolveAiTransportHeaderSentinels(headers) {
|
|
85
|
-
if (!headers) return;
|
|
86
|
-
const host = getAiTransportHost();
|
|
87
|
-
let resolvedHeaders;
|
|
88
|
-
for (const [name, value] of Object.entries(headers)) {
|
|
89
|
-
const resolved = host.resolveSecretSentinel(value);
|
|
90
|
-
if (resolved !== value) {
|
|
91
|
-
resolvedHeaders ??= { ...headers };
|
|
92
|
-
resolvedHeaders[name] = resolved;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return resolvedHeaders ?? headers;
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
export { getAiTransportHost as n, resolveAiTransportHeaderSentinels as r, configureAiTransportHost as t };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { c as resolveClaudeNativeThinkingLevelMap, i as requiresClaudeMandatoryAdaptiveThinking } from "./src-CXno1H5g.mjs";
|
|
2
|
-
//#region packages/ai/src/model-utils.ts
|
|
3
|
-
/** Calculates and stores model cost fields from token usage and per-million pricing. */
|
|
4
|
-
function calculateCost(model, usage) {
|
|
5
|
-
const cacheWrite1h = Math.min(usage.cacheWrite, Math.max(0, usage.cacheWrite1h ?? 0));
|
|
6
|
-
const cacheWrite5m = usage.cacheWrite - cacheWrite1h;
|
|
7
|
-
usage.cost.input = model.cost.input / 1e6 * usage.input;
|
|
8
|
-
usage.cost.output = model.cost.output / 1e6 * usage.output;
|
|
9
|
-
usage.cost.cacheRead = model.cost.cacheRead / 1e6 * usage.cacheRead;
|
|
10
|
-
usage.cost.cacheWrite = (model.cost.cacheWrite * cacheWrite5m + model.cost.input * 2 * cacheWrite1h) / 1e6;
|
|
11
|
-
usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;
|
|
12
|
-
return usage.cost;
|
|
13
|
-
}
|
|
14
|
-
/** Replaces the catalog estimate when the provider reports an authoritative billed total. */
|
|
15
|
-
function applyProviderReportedUsageCost(usage, reportedCost) {
|
|
16
|
-
if (typeof reportedCost !== "number" || !Number.isFinite(reportedCost) || reportedCost < 0) return;
|
|
17
|
-
usage.cost.total = reportedCost;
|
|
18
|
-
usage.cost.totalOrigin = "provider-billed";
|
|
19
|
-
}
|
|
20
|
-
const EXTENDED_THINKING_LEVELS = [
|
|
21
|
-
"off",
|
|
22
|
-
"minimal",
|
|
23
|
-
"low",
|
|
24
|
-
"medium",
|
|
25
|
-
"high",
|
|
26
|
-
"xhigh",
|
|
27
|
-
"max"
|
|
28
|
-
];
|
|
29
|
-
function resolveThinkingLevelMap(model) {
|
|
30
|
-
return model.api === "anthropic-messages" ? resolveClaudeNativeThinkingLevelMap(model) ?? model.thinkingLevelMap : model.thinkingLevelMap;
|
|
31
|
-
}
|
|
32
|
-
/** Returns thinking levels exposed by a reasoning-capable model. */
|
|
33
|
-
function getSupportedThinkingLevels(model) {
|
|
34
|
-
const mandatoryAdaptiveContract = model.api === "anthropic-messages" && requiresClaudeMandatoryAdaptiveThinking(model);
|
|
35
|
-
if (!model.reasoning && !mandatoryAdaptiveContract) return ["off"];
|
|
36
|
-
const thinkingLevelMap = resolveThinkingLevelMap(model);
|
|
37
|
-
return EXTENDED_THINKING_LEVELS.filter((level) => {
|
|
38
|
-
const mapped = thinkingLevelMap?.[level];
|
|
39
|
-
if (mapped === null) return false;
|
|
40
|
-
if (level === "xhigh" || level === "max") return mapped !== void 0;
|
|
41
|
-
return true;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/** Clamps a requested thinking level to the closest supported level for a model. */
|
|
45
|
-
function clampThinkingLevel(model, level) {
|
|
46
|
-
const availableLevels = getSupportedThinkingLevels(model);
|
|
47
|
-
if (availableLevels.includes(level)) return level;
|
|
48
|
-
const requestedIndex = EXTENDED_THINKING_LEVELS.indexOf(level);
|
|
49
|
-
if (requestedIndex === -1) return availableLevels[0] ?? "off";
|
|
50
|
-
const thinkingLevelMap = resolveThinkingLevelMap(model);
|
|
51
|
-
if ((level === "xhigh" || level === "max") && thinkingLevelMap?.[level] === null) {
|
|
52
|
-
for (const candidate of EXTENDED_THINKING_LEVELS.slice(0, requestedIndex).toReversed()) if (availableLevels.includes(candidate)) return candidate;
|
|
53
|
-
}
|
|
54
|
-
for (const candidate of EXTENDED_THINKING_LEVELS.slice(requestedIndex)) if (availableLevels.includes(candidate)) return candidate;
|
|
55
|
-
for (const candidate of EXTENDED_THINKING_LEVELS.slice(0, requestedIndex).toReversed()) if (availableLevels.includes(candidate)) return candidate;
|
|
56
|
-
return availableLevels[0] ?? "off";
|
|
57
|
-
}
|
|
58
|
-
/** Compares model identity by provider and id. */
|
|
59
|
-
function modelsAreEqual(a, b) {
|
|
60
|
-
if (!a || !b) return false;
|
|
61
|
-
return a.id === b.id && a.provider === b.provider;
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
export { modelsAreEqual as a, getSupportedThinkingLevels as i, calculateCost as n, clampThinkingLevel as r, applyProviderReportedUsageCost as t };
|
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { E as Model, F as SimpleStreamOptions, I as StopReason, O as OpenAICompletionsCompat, R as StreamFunction, X as Usage, u as Context, z as StreamOptions } from "./types-AFwwWium.mjs";
|
|
2
|
-
import OpenAI from "openai";
|
|
3
|
-
import { TSchema } from "typebox";
|
|
4
|
-
import { ChatCompletionMessageParam } from "openai/resources/chat/completions.js";
|
|
5
|
-
import { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
|
|
6
|
-
|
|
7
|
-
//#region packages/ai/src/providers/agent-tools-parameter-schema.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Narrow structural view of the host's model compat config. packages/ai must stay
|
|
10
|
-
* config-agnostic, so only tool-schema-relevant fields are modeled here; the host's
|
|
11
|
-
* ModelCompatConfig remains structurally assignable.
|
|
12
|
-
*/
|
|
13
|
-
type ToolSchemaModelCompat = {
|
|
14
|
-
toolSchemaProfile?: string;
|
|
15
|
-
unsupportedToolSchemaKeywords?: string[];
|
|
16
|
-
omitEmptyArrayItems?: boolean;
|
|
17
|
-
};
|
|
18
|
-
/** Extracts the compat record whether callers pass a model (`{ compat }`) or the compat itself. */
|
|
19
|
-
declare function extractToolSchemaModelCompat(modelOrCompat: {
|
|
20
|
-
compat?: unknown;
|
|
21
|
-
} | ToolSchemaModelCompat | undefined): ToolSchemaModelCompat | undefined;
|
|
22
|
-
/** JSON Schema keywords this model/provider rejects in tool schemas. */
|
|
23
|
-
declare function resolveUnsupportedToolSchemaKeywords(modelOrCompat: {
|
|
24
|
-
compat?: unknown;
|
|
25
|
-
} | ToolSchemaModelCompat | undefined): ReadonlySet<string>;
|
|
26
|
-
/** Whether empty `items: {}` on array schemas must be omitted for this model/provider. */
|
|
27
|
-
declare function shouldOmitEmptyArrayItems(modelOrCompat: {
|
|
28
|
-
compat?: unknown;
|
|
29
|
-
} | ToolSchemaModelCompat | undefined): boolean;
|
|
30
|
-
type ToolParameterSchemaOptions = {
|
|
31
|
-
modelProvider?: string;
|
|
32
|
-
modelId?: string;
|
|
33
|
-
modelCompat?: ToolSchemaModelCompat;
|
|
34
|
-
};
|
|
35
|
-
/** Return a provider-compatible JSON schema for a model-facing tool. */
|
|
36
|
-
declare function normalizeToolParameterSchema(schema: unknown, options?: ToolParameterSchemaOptions): TSchema;
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region packages/ai/src/providers/azure-deployment-map.d.ts
|
|
39
|
-
/** Parses AZURE_OPENAI_DEPLOYMENT_MAP-style model=deployment entries. */
|
|
40
|
-
declare function parseAzureDeploymentNameMap(value: string | undefined): Map<string, string>;
|
|
41
|
-
/**
|
|
42
|
-
* Resolves the Azure deployment name for a model id, falling back to the model id.
|
|
43
|
-
*
|
|
44
|
-
* An exact-case match always wins, so configs that intentionally distinguish keys by
|
|
45
|
-
* case keep their exact mappings; a case-insensitive match is only used as a fallback
|
|
46
|
-
* (e.g. `GPT-4o` against a `gpt-4o=...` map) to avoid 404s from casing differences.
|
|
47
|
-
*/
|
|
48
|
-
declare function resolveAzureDeploymentNameFromMap(params: {
|
|
49
|
-
modelId: string;
|
|
50
|
-
deploymentMap?: string;
|
|
51
|
-
}): string;
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region packages/ai/src/providers/azure-openai-responses-client-compat.d.ts
|
|
54
|
-
declare function isTraditionalAzureOpenAIHost(hostname: string): boolean;
|
|
55
|
-
declare function isOpenAICompatibleAzureResponsesBaseUrl(baseUrl: string): boolean;
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region packages/ai/src/providers/clean-for-gemini.d.ts
|
|
58
|
-
declare const GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS: Set<string>;
|
|
59
|
-
declare function cleanSchemaForGemini(schema: unknown): TSchema;
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region packages/ai/src/providers/openai-completions-compat.d.ts
|
|
62
|
-
type OpenAICompletionsSessionAffinity = "none" | "openai" | "openrouter";
|
|
63
|
-
type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCompat>, "cacheControlFormat" | "openRouterRouting" | "sendSessionAffinityHeaders"> & {
|
|
64
|
-
cacheControlFormat?: OpenAICompletionsCompat["cacheControlFormat"];
|
|
65
|
-
openRouterRouting?: OpenAICompletionsCompat["openRouterRouting"];
|
|
66
|
-
sessionAffinity: OpenAICompletionsSessionAffinity;
|
|
67
|
-
};
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region packages/ai/src/providers/openai-tool-projection.d.ts
|
|
70
|
-
type OpenAIToolDescriptor = {
|
|
71
|
-
readonly name?: unknown;
|
|
72
|
-
readonly description?: unknown;
|
|
73
|
-
readonly parameters: unknown;
|
|
74
|
-
};
|
|
75
|
-
type OpenAIProjectedTool = {
|
|
76
|
-
readonly toolIndex: number;
|
|
77
|
-
readonly name: string;
|
|
78
|
-
readonly description?: string;
|
|
79
|
-
readonly parameters: Record<string, unknown>;
|
|
80
|
-
};
|
|
81
|
-
type OpenAIToolProjectionDiagnostic = {
|
|
82
|
-
readonly toolIndex: number;
|
|
83
|
-
readonly toolName?: string;
|
|
84
|
-
readonly violations: readonly string[];
|
|
85
|
-
};
|
|
86
|
-
type OpenAIToolProjection = {
|
|
87
|
-
readonly inputToolCount: number;
|
|
88
|
-
readonly tools: readonly OpenAIProjectedTool[];
|
|
89
|
-
readonly diagnostics: readonly OpenAIToolProjectionDiagnostic[];
|
|
90
|
-
};
|
|
91
|
-
type OpenAIResponsesToolChoice = ResponseCreateParamsStreaming["tool_choice"];
|
|
92
|
-
type OpenAICompletionsSdkToolChoice = OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming["tool_choice"];
|
|
93
|
-
type OpenAICompletionsToolChoice = Exclude<OpenAICompletionsSdkToolChoice, {
|
|
94
|
-
type: "custom";
|
|
95
|
-
}>;
|
|
96
|
-
/** Snapshots direct/custom tool descriptors before OpenAI payload construction. */
|
|
97
|
-
declare function projectOpenAITools(tools: readonly OpenAIToolDescriptor[]): OpenAIToolProjection;
|
|
98
|
-
/** Keeps Responses tool choices aligned with surviving function schemas. */
|
|
99
|
-
declare function reconcileOpenAIResponsesToolChoice(choice: OpenAIResponsesToolChoice, projection: OpenAIToolProjection): OpenAIResponsesToolChoice | undefined;
|
|
100
|
-
/** Keeps Chat Completions tool choices aligned with surviving function schemas. */
|
|
101
|
-
declare function reconcileOpenAICompletionsToolChoice(choice: OpenAICompletionsSdkToolChoice, projection: OpenAIToolProjection): OpenAICompletionsSdkToolChoice | undefined;
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region packages/ai/src/providers/openai-completions.d.ts
|
|
104
|
-
interface OpenAICompletionsOptions extends StreamOptions {
|
|
105
|
-
toolChoice?: OpenAICompletionsToolChoice;
|
|
106
|
-
reasoningEffort?: "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
107
|
-
}
|
|
108
|
-
declare const streamOpenAICompletions: StreamFunction<"openai-completions", OpenAICompletionsOptions>;
|
|
109
|
-
declare const streamSimpleOpenAICompletions: StreamFunction<"openai-completions", SimpleStreamOptions>;
|
|
110
|
-
declare function convertMessages(model: Model<"openai-completions">, context: Context, compat: ResolvedOpenAICompletionsCompat, options?: {
|
|
111
|
-
cacheOptOutIndexes?: Set<number>;
|
|
112
|
-
preserveSystemPromptCacheBoundary?: boolean;
|
|
113
|
-
}): ChatCompletionMessageParam[];
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region packages/ai/src/providers/openai-prompt-cache.d.ts
|
|
116
|
-
/** Maximum prompt cache key length accepted by OpenAI-compatible request metadata. */
|
|
117
|
-
declare const OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH = 64;
|
|
118
|
-
/** Truncates a prompt cache key by Unicode code point count. */
|
|
119
|
-
declare function clampOpenAIPromptCacheKey(key: string | undefined): string | undefined;
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region packages/ai/src/providers/openai-reasoning-effort.d.ts
|
|
122
|
-
type OpenAIReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
123
|
-
type OpenAIApiReasoningEffort = OpenAIReasoningEffort | (string & {});
|
|
124
|
-
type OpenAIReasoningModel = {
|
|
125
|
-
provider?: unknown;
|
|
126
|
-
id?: unknown;
|
|
127
|
-
name?: unknown;
|
|
128
|
-
api?: unknown;
|
|
129
|
-
baseUrl?: unknown;
|
|
130
|
-
compat?: unknown;
|
|
131
|
-
};
|
|
132
|
-
/** Return whether a model is the GPT-5.4 mini family. */
|
|
133
|
-
declare function isOpenAIGpt54MiniModel(model: OpenAIReasoningModel): boolean;
|
|
134
|
-
/** Return whether a model is the GPT-5.5 family. */
|
|
135
|
-
declare function isOpenAIGpt55Model(model: OpenAIReasoningModel): boolean;
|
|
136
|
-
/** Return whether a model is the GPT-5.6 family. */
|
|
137
|
-
declare function isOpenAIGpt56Model(model: OpenAIReasoningModel): boolean;
|
|
138
|
-
/** Normalize user-facing reasoning effort names to API effort names. */
|
|
139
|
-
declare function normalizeOpenAIReasoningEffort(effort: string): string;
|
|
140
|
-
/** Resolve the reasoning efforts accepted by a specific OpenAI-compatible model. */
|
|
141
|
-
declare function resolveOpenAISupportedReasoningEfforts(model: OpenAIReasoningModel): readonly OpenAIApiReasoningEffort[];
|
|
142
|
-
/**
|
|
143
|
-
* Return whether a model accepts the temperature parameter. The GPT-5.6
|
|
144
|
-
* family rejects it with a 400; catalog compat can override per model.
|
|
145
|
-
*/
|
|
146
|
-
declare function supportsOpenAITemperature(model: OpenAIReasoningModel): boolean;
|
|
147
|
-
/** Return whether a model accepts a requested reasoning effort. */
|
|
148
|
-
declare function supportsOpenAIReasoningEffort(model: OpenAIReasoningModel, effort: string): boolean;
|
|
149
|
-
/** Resolve a requested reasoning effort to the closest value supported by the model. */
|
|
150
|
-
declare function resolveOpenAIReasoningEffortForModel(params: {
|
|
151
|
-
model: OpenAIReasoningModel;
|
|
152
|
-
effort: string;
|
|
153
|
-
fallbackMap?: Record<string, string>;
|
|
154
|
-
}): OpenAIApiReasoningEffort | undefined;
|
|
155
|
-
//#endregion
|
|
156
|
-
//#region packages/ai/src/providers/openai-responses.d.ts
|
|
157
|
-
interface OpenAIResponsesOptions extends StreamOptions {
|
|
158
|
-
reasoningEffort?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
159
|
-
reasoningSummary?: "auto" | "detailed" | "concise" | null;
|
|
160
|
-
replayResponsesItemIds?: boolean;
|
|
161
|
-
serviceTier?: ResponseCreateParamsStreaming["service_tier"];
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Generate function for OpenAI Responses API
|
|
165
|
-
*/
|
|
166
|
-
declare const streamOpenAIResponses: StreamFunction<"openai-responses", OpenAIResponsesOptions>;
|
|
167
|
-
declare const streamSimpleOpenAIResponses: StreamFunction<"openai-responses", SimpleStreamOptions>;
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region packages/ai/src/providers/openai-responses-stream-compat.d.ts
|
|
170
|
-
declare const OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE = "output_text";
|
|
171
|
-
declare const AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE = "text";
|
|
172
|
-
declare const OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE = "response.output_text.delta";
|
|
173
|
-
declare const AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE = "response.text.delta";
|
|
174
|
-
type ResponsesTextContentPartType = typeof OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE | typeof AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE;
|
|
175
|
-
type ResponsesTextDeltaEventType = typeof OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE | typeof AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE;
|
|
176
|
-
type AzureResponsesTextContentPart = {
|
|
177
|
-
type: typeof AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE;
|
|
178
|
-
text: string;
|
|
179
|
-
};
|
|
180
|
-
type AzureResponsesTextDeltaEvent = {
|
|
181
|
-
type: typeof AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE;
|
|
182
|
-
delta: string;
|
|
183
|
-
};
|
|
184
|
-
declare function isResponsesTextContentPartType(type: unknown): type is ResponsesTextContentPartType;
|
|
185
|
-
declare function isResponsesTextDeltaEventType(type: unknown): type is ResponsesTextDeltaEventType;
|
|
186
|
-
declare function isAzureResponsesTextDeltaEventType(type: unknown): type is typeof AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE;
|
|
187
|
-
declare function isAzureResponsesTextDeltaEvent(event: {
|
|
188
|
-
type?: unknown;
|
|
189
|
-
delta?: unknown;
|
|
190
|
-
}): event is AzureResponsesTextDeltaEvent;
|
|
191
|
-
type ResponsesMessageSnapshotCollapse = {
|
|
192
|
-
kind: "extend";
|
|
193
|
-
text: string;
|
|
194
|
-
} | {
|
|
195
|
-
kind: "keep";
|
|
196
|
-
};
|
|
197
|
-
declare function resolveResponsesMessageSnapshotCollapse(params: {
|
|
198
|
-
prior: {
|
|
199
|
-
text: string;
|
|
200
|
-
phase: string | undefined;
|
|
201
|
-
} | null;
|
|
202
|
-
nextText: string;
|
|
203
|
-
nextPhase: string | undefined;
|
|
204
|
-
}): ResponsesMessageSnapshotCollapse;
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region packages/ai/src/providers/openai-responses-terminal-usage.d.ts
|
|
207
|
-
/** Terminal usage payload, modeled structurally so untyped callers can pass raw records. */
|
|
208
|
-
type ResponsesTerminalUsagePayload = {
|
|
209
|
-
input_tokens?: number | null;
|
|
210
|
-
output_tokens?: number | null;
|
|
211
|
-
total_tokens?: number | null;
|
|
212
|
-
input_tokens_details?: {
|
|
213
|
-
cached_tokens?: number | null;
|
|
214
|
-
cache_write_tokens?: number | null;
|
|
215
|
-
} | null;
|
|
216
|
-
output_tokens_details?: {
|
|
217
|
-
reasoning_tokens?: number | null;
|
|
218
|
-
} | null;
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* Split a terminal usage payload into the priced buckets.
|
|
222
|
-
*
|
|
223
|
-
* OpenAI includes cache reads and writes in `input_tokens`, so both are subtracted out of the
|
|
224
|
-
* billable input bucket. `total_tokens` comes from the payload, but never below the sum of the
|
|
225
|
-
* split buckets: proxies routinely omit it (reporting 0 would understate the turn), and a payload
|
|
226
|
-
* whose `cached_tokens` exceeds `input_tokens` clamps the input bucket, leaving the reported total
|
|
227
|
-
* short of what the buckets actually price.
|
|
228
|
-
*/
|
|
229
|
-
declare function mapResponsesTerminalUsage(usage: ResponsesTerminalUsagePayload | undefined | null): Pick<Usage, "input" | "output" | "cacheRead" | "cacheWrite" | "totalTokens"> | undefined;
|
|
230
|
-
/** Reasoning tokens are reported by the agent path only; the package path does not track them. */
|
|
231
|
-
declare function readResponsesReasoningTokens(usage: ResponsesTerminalUsagePayload | undefined | null): number | undefined;
|
|
232
|
-
/**
|
|
233
|
-
* Resolve the terminal stop reason, including the two overrides every Responses path shares: a
|
|
234
|
-
* content-filtered turn is a provider error rather than a truncated answer, and a turn that
|
|
235
|
-
* produced tool calls reports `toolUse` instead of a plain stop.
|
|
236
|
-
*/
|
|
237
|
-
declare function resolveResponsesTerminalStopReason(params: {
|
|
238
|
-
status: OpenAI.Responses.ResponseStatus | undefined;
|
|
239
|
-
incompleteReason?: string;
|
|
240
|
-
hasToolCall: boolean;
|
|
241
|
-
}): {
|
|
242
|
-
stopReason: StopReason;
|
|
243
|
-
errorMessage?: string;
|
|
244
|
-
};
|
|
245
|
-
//#endregion
|
|
246
|
-
//#region packages/ai/src/providers/openai-responses-tool-call-tracker.d.ts
|
|
247
|
-
type ResponsesToolCallIdentity = {
|
|
248
|
-
itemId?: string;
|
|
249
|
-
callId?: string;
|
|
250
|
-
};
|
|
251
|
-
type ResponsesToolCallState = ResponsesToolCallIdentity & {
|
|
252
|
-
argumentStreamReliable: boolean;
|
|
253
|
-
};
|
|
254
|
-
type ResponsesToolCallEvent = {
|
|
255
|
-
output_index?: unknown;
|
|
256
|
-
item_id?: unknown;
|
|
257
|
-
};
|
|
258
|
-
declare function readResponsesToolCallItemIdentity(item: {
|
|
259
|
-
id?: unknown;
|
|
260
|
-
call_id?: unknown;
|
|
261
|
-
}): ResponsesToolCallIdentity;
|
|
262
|
-
declare function createResponsesToolCallTracker<TState extends ResponsesToolCallState>(): {
|
|
263
|
-
register(event: ResponsesToolCallEvent, state: TState): void;
|
|
264
|
-
resolve(event: ResponsesToolCallEvent, identity?: ResponsesToolCallIdentity): TState | undefined;
|
|
265
|
-
forget(toolCall: TState): void;
|
|
266
|
-
markArgumentsUnreliable(): void;
|
|
267
|
-
hasActive(): boolean;
|
|
268
|
-
};
|
|
269
|
-
//#endregion
|
|
270
|
-
//#region packages/ai/src/providers/openai-stop-reason.d.ts
|
|
271
|
-
type OpenAIStopReasonResult = {
|
|
272
|
-
stopReason: StopReason;
|
|
273
|
-
errorMessage?: string;
|
|
274
|
-
};
|
|
275
|
-
declare function mapOpenAIStopReason(reason: string | null, options?: {
|
|
276
|
-
allowSingularToolCall?: boolean;
|
|
277
|
-
}): OpenAIStopReasonResult;
|
|
278
|
-
//#endregion
|
|
279
|
-
//#region packages/ai/src/providers/openai-tool-schema-compat.d.ts
|
|
280
|
-
/** Repairs recoverable OpenAI tool-schema shapes before canonical normalization. */
|
|
281
|
-
declare function normalizeOpenAIStrictCompatSchema(schema: unknown): TSchema;
|
|
282
|
-
/** Finds schema paths that violate OpenAI strict tool-schema requirements. */
|
|
283
|
-
declare function findOpenAIStrictSchemaViolations(schema: unknown, path: string, options?: {
|
|
284
|
-
requireObjectRoot?: boolean;
|
|
285
|
-
}): string[];
|
|
286
|
-
//#endregion
|
|
287
|
-
//#region packages/ai/src/providers/openai-tool-schema.d.ts
|
|
288
|
-
/**
|
|
289
|
-
* OpenAI strict-tool-schema normalization and diagnostics.
|
|
290
|
-
*
|
|
291
|
-
* Strict schemas need all object properties required and `additionalProperties: false`; model
|
|
292
|
-
* compatibility settings can also remove unsupported schema constructs before strict checks run.
|
|
293
|
-
*/
|
|
294
|
-
type ToolSchemaCompatInput = {
|
|
295
|
-
unsupportedToolSchemaKeywords?: unknown;
|
|
296
|
-
omitEmptyArrayItems?: unknown;
|
|
297
|
-
};
|
|
298
|
-
declare function clearOpenAIToolSchemaCacheForTest(): void;
|
|
299
|
-
/** Normalizes a tool parameter schema into the OpenAI strict JSON-schema subset. */
|
|
300
|
-
declare function normalizeStrictOpenAIJsonSchema(schema: unknown, modelCompat?: ToolSchemaCompatInput | null): unknown;
|
|
301
|
-
/** Normalizes tool parameters using strict OpenAI rules only when strict mode is active. */
|
|
302
|
-
declare function normalizeOpenAIStrictToolParameters<T>(schema: T, strict: boolean, modelCompat?: ToolSchemaCompatInput | null): T;
|
|
303
|
-
/** Returns whether a schema already satisfies OpenAI strict tool-schema constraints. */
|
|
304
|
-
declare function isStrictOpenAIJsonSchemaCompatible(schema: unknown): boolean;
|
|
305
|
-
type OpenAIStrictToolSchemaDiagnostic = {
|
|
306
|
-
toolIndex: number;
|
|
307
|
-
toolName?: string;
|
|
308
|
-
violations: string[];
|
|
309
|
-
};
|
|
310
|
-
/** Returns strict-schema diagnostics for an already materialized OpenAI tool projection. */
|
|
311
|
-
declare function findOpenAIStrictToolProjectionDiagnostics(projection: OpenAIToolProjection): OpenAIStrictToolSchemaDiagnostic[];
|
|
312
|
-
/** Resolves strict mode for the projected tools that will be emitted in the request payload. */
|
|
313
|
-
declare function resolveOpenAIProjectedToolsStrictToolFlag(projection: OpenAIToolProjection, strict: boolean | null | undefined): boolean | undefined;
|
|
314
|
-
//#endregion
|
|
315
|
-
//#region packages/ai/src/providers/schema-keyword-strip.d.ts
|
|
316
|
-
/** Recursively remove schema keywords unsupported by a target provider/tool surface. */
|
|
317
|
-
declare function stripUnsupportedSchemaKeywords(schema: unknown, unsupportedKeywords: ReadonlySet<string>): unknown;
|
|
318
|
-
//#endregion
|
|
319
|
-
//#region packages/ai/src/providers/tool-schema-json-projection.d.ts
|
|
320
|
-
/** JSON-safe schema value used when projecting runtime tool parameters. */
|
|
321
|
-
type RuntimeToolInputSchemaJson = null | boolean | number | string | RuntimeToolInputSchemaJson[] | {
|
|
322
|
-
[key: string]: RuntimeToolInputSchemaJson;
|
|
323
|
-
};
|
|
324
|
-
/** Projected runtime tool schema plus validation violations. */
|
|
325
|
-
type RuntimeToolInputSchemaProjection = {
|
|
326
|
-
readonly schema: RuntimeToolInputSchemaJson;
|
|
327
|
-
readonly violations: readonly string[];
|
|
328
|
-
};
|
|
329
|
-
/** Projects one runtime tool input schema to JSON and reports runtime incompatibilities. */
|
|
330
|
-
declare function projectRuntimeToolInputSchema(schema: unknown, path?: string): RuntimeToolInputSchemaProjection;
|
|
331
|
-
//#endregion
|
|
332
|
-
export { convertMessages as $, ResponsesTextContentPartType as A, OpenAIApiReasoningEffort as B, AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE as C, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE as D, AzureResponsesTextDeltaEvent as E, isResponsesTextDeltaEventType as F, normalizeOpenAIReasoningEffort as G, isOpenAIGpt54MiniModel as H, resolveResponsesMessageSnapshotCollapse as I, supportsOpenAIReasoningEffort as J, resolveOpenAIReasoningEffortForModel as K, OpenAIResponsesOptions as L, isAzureResponsesTextDeltaEvent as M, isAzureResponsesTextDeltaEventType as N, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE as O, isResponsesTextContentPartType as P, OpenAICompletionsOptions as Q, streamOpenAIResponses as R, resolveResponsesTerminalStopReason as S, AzureResponsesTextContentPart as T, isOpenAIGpt55Model as U, OpenAIReasoningEffort as V, isOpenAIGpt56Model as W, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH as X, supportsOpenAITemperature as Y, clampOpenAIPromptCacheKey as Z, createResponsesToolCallTracker as _, resolveUnsupportedToolSchemaKeywords as _t, clearOpenAIToolSchemaCacheForTest as a, reconcileOpenAICompletionsToolChoice as at, mapResponsesTerminalUsage as b, normalizeOpenAIStrictToolParameters as c, cleanSchemaForGemini as ct, findOpenAIStrictSchemaViolations as d, parseAzureDeploymentNameMap as dt, streamOpenAICompletions as et, normalizeOpenAIStrictCompatSchema as f, resolveAzureDeploymentNameFromMap as ft, ResponsesToolCallState as g, normalizeToolParameterSchema as gt, ResponsesToolCallIdentity as h, extractToolSchemaModelCompat as ht, stripUnsupportedSchemaKeywords as i, projectOpenAITools as it, ResponsesTextDeltaEventType as j, ResponsesMessageSnapshotCollapse as k, normalizeStrictOpenAIJsonSchema as l, isOpenAICompatibleAzureResponsesBaseUrl as lt, mapOpenAIStopReason as m, ToolSchemaModelCompat as mt, RuntimeToolInputSchemaProjection as n, OpenAICompletionsToolChoice as nt, findOpenAIStrictToolProjectionDiagnostics as o, reconcileOpenAIResponsesToolChoice as ot, OpenAIStopReasonResult as p, ToolParameterSchemaOptions as pt, resolveOpenAISupportedReasoningEfforts as q, projectRuntimeToolInputSchema as r, OpenAIToolProjection as rt, isStrictOpenAIJsonSchemaCompatible as s, GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS as st, RuntimeToolInputSchemaJson as t, streamSimpleOpenAICompletions as tt, resolveOpenAIProjectedToolsStrictToolFlag as u, isTraditionalAzureOpenAIHost as ut, readResponsesToolCallItemIdentity as v, shouldOmitEmptyArrayItems as vt, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE as w, readResponsesReasoningTokens as x, ResponsesTerminalUsagePayload as y, streamSimpleOpenAIResponses as z };
|