@openclaw/ai 2026.10.10-beta.5 → 2026.10.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/README.md +9 -1
- package/dist/{anthropic-B54Ts1tV.mjs → anthropic-B58ec88k.mjs} +46 -26
- package/dist/{anthropic-payload-policy-rqCq9sT_.d.mts → anthropic-payload-policy-BCp4dUJR.d.mts} +2 -2
- package/dist/{anthropic-stream-reducer-C__ByTq1.mjs → anthropic-stream-reducer-BTcDHWGM.mjs} +11 -11
- package/dist/{anthropic-tool-projection-DA_KeluM.mjs → anthropic-tool-projection-CrsCkF4k.mjs} +1 -1
- package/dist/{anthropic-tool-projection-JTvMo4KG.d.mts → anthropic-tool-projection-CzSSQzZL.d.mts} +1 -1
- package/dist/{api-registry-gDt0faai.d.mts → api-registry-CkmxPPac.d.mts} +1 -1
- package/dist/{assistant-output-DbgdWAhJ.mjs → assistant-output-Hl3b-ViJ.mjs} +3 -3
- package/dist/{azure-openai-responses-DHzTwi-y.mjs → azure-openai-responses-B0Hi9cAV.mjs} +5 -6
- package/dist/{diagnostics-Cv7cW3pS.mjs → diagnostics-v7oVEW59.mjs} +17 -1
- package/dist/diagnostics.d.mts +3 -3
- package/dist/diagnostics.mjs +1 -1
- package/dist/{google-CZ6uGVkV.mjs → google-DuI8TLy0.mjs} +2 -2
- package/dist/{google-interactions-1XAHjAQo.mjs → google-interactions-9Jd_049M.mjs} +91 -30
- package/dist/{google-messages-B-svbJuN.mjs → google-messages-BWhsZ167.mjs} +9 -3
- package/dist/{google-provider-stream-DlhaCvCf.mjs → google-provider-stream-DL0bXgX5.mjs} +16 -11
- package/dist/{google-shared-Cif7nve-.mjs → google-shared-DXizMtnG.mjs} +6 -5
- package/dist/{google-vertex-BZTcYnWU.mjs → google-vertex-DnjRWo-M.mjs} +2 -2
- package/dist/google-video-slots-D8tPH8wX.mjs +29 -0
- package/dist/{host-jJOffdlW.d.mts → host-B03VqZdH.d.mts} +2 -2
- package/dist/{host-rCxf5Tjd.mjs → host-CyGba3M8.mjs} +111 -88
- package/dist/{host-policy-Ci1cKluf.mjs → host-policy-CNQztzZm.mjs} +1 -1
- package/dist/{index-DSprYWaz.d.mts → index-B8ODIVmA.d.mts} +15 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/internal/anthropic.d.mts +16 -6
- package/dist/internal/anthropic.mjs +6 -6
- package/dist/internal/openai-completions-compat.d.mts +5 -1
- package/dist/internal/openai-completions-compat.mjs +3 -2
- package/dist/internal/openai-responses-payload-policy.d.mts +2 -2
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +8 -8
- package/dist/internal/openai.mjs +9 -9
- package/dist/internal/retry-after.d.mts +2 -2
- package/dist/internal/retry-after.mjs +75 -1
- package/dist/internal/runtime.d.mts +6 -6
- package/dist/internal/runtime.mjs +4 -4
- package/dist/internal/shared.d.mts +3 -3
- package/dist/internal/shared.mjs +2 -2
- package/dist/internal/tool-schema.d.mts +2 -2
- package/dist/internal/tool-schema.mjs +3 -3
- package/dist/{mistral-C_ImzxlK.mjs → mistral-BgamhpFG.mjs} +4 -4
- package/dist/openai-BfFy1nvf.mjs +20077 -0
- package/dist/{openai-chatgpt-responses-BHkSHjkO.mjs → openai-chatgpt-responses-Biu_I7p4.mjs} +14 -19
- package/dist/{openai-completions-CB-wfbsI.mjs → openai-completions-Cbwde_Dr.mjs} +4 -4
- package/dist/{openai-completions-compat-CJ0OXZgi.mjs → openai-completions-compat-D9KEUevM.mjs} +2 -2
- package/dist/{openai-completions-compat-CBvb2eld.d.mts → openai-completions-compat-DTe2EXPi.d.mts} +2 -2
- package/dist/openai-completions-reasoning-replay-BwT1xwRI.mjs +45 -0
- package/dist/openai-completions-transport-RCOvvBq_.mjs +10874 -0
- package/dist/{openai-prompt-cache-h8vXRiaH.mjs → openai-prompt-cache-CAo-Mah6.mjs} +1 -1
- package/dist/{openai-prompt-cache-DgjD-UL5.d.mts → openai-prompt-cache-k7EPMLa0.d.mts} +1 -1
- package/dist/{openai-responses-Cp2QPq7K.mjs → openai-responses-DOgBvvca.mjs} +7 -8
- package/dist/{openai-responses-compaction-replay-C-yvB5g5.d.mts → openai-responses-compaction-replay-DOJaDCUl.d.mts} +3 -3
- package/dist/{openai-responses-contracts-DCG51Us0.mjs → openai-responses-contracts-B5mGAbR6.mjs} +1 -1
- package/dist/{openai-responses-contracts-D-VwWWjx.d.mts → openai-responses-contracts-DHtim7d_.d.mts} +9 -3
- package/dist/{openai-responses-endpoint-JbBT8IDv.mjs → openai-responses-endpoint-DJwbSy3n.mjs} +4 -2
- package/dist/{openai-responses-payload-policy-BzM52TTH.d.mts → openai-responses-payload-policy-cIaYG5ZQ.d.mts} +1 -0
- package/dist/{openai-responses-request-lifecycle-DQDyzE6F.mjs → openai-responses-request-lifecycle-bJ24Q_OK.mjs} +22 -8
- package/dist/{openai-responses-shared-CNfHudFg.mjs → openai-responses-shared-BDGaQxiw.mjs} +1130 -30
- package/dist/{openai-responses-terminal-usage-CpVjkqn-.d.mts → openai-responses-terminal-usage-BDGDBGuA.d.mts} +1 -1
- package/dist/{openai-tool-schema-CGhEl7ao.mjs → openai-tool-schema-D913am3I.mjs} +4 -3
- package/dist/openai.LICENSE +201 -0
- package/dist/{provider-options-Bo8GzTGX.d.mts → provider-options-DFjnfImJ.d.mts} +8 -2
- package/dist/{provider-replay-context-BC23HyZo.mjs → provider-replay-context-C5uMjBz4.mjs} +3 -4
- package/dist/{provider-transport-turn-state-B11rmZpv.mjs → provider-transport-turn-state-CfUfU9v1.mjs} +3 -3
- package/dist/{provider-types-ODq57rG_.d.mts → provider-types-C-67EZr8.d.mts} +5 -3
- package/dist/provider-types.d.mts +3 -3
- package/dist/provider-types.mjs +2 -1
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +10 -10
- package/dist/{reasoning-tag-text-partitioner-DzlRubwU.mjs → reasoning-tag-text-partitioner-CU9A4Lg8.mjs} +2 -13
- package/dist/retry-after-BrmTv0jL.d.mts +25 -0
- package/dist/rolldown-runtime-B4iAMlE-.mjs +35 -0
- package/dist/{sanitize-unicode-ZqVLLEKC.d.mts → sanitize-unicode-CkejzD2f.d.mts} +1 -1
- package/dist/{simple-options-BdJJbzZk.mjs → simple-options-Bd0STwu7.mjs} +3 -3
- package/dist/{src-CyA0zJnt.mjs → src--qsViR3j.mjs} +60 -12
- package/dist/{stream-DQqGjhbq.mjs → stream-BRecd0FZ.mjs} +1 -1
- package/dist/{tool-schema-json-projection-Cvq69Ajp.mjs → tool-schema-json-projection-DU-FFSa7.mjs} +1 -1
- package/dist/{transport-stream-shared-DdnJGEj0.mjs → transport-stream-shared-C1AtJhZA.mjs} +2 -2
- package/dist/{transport-stream-shared-8ru8eX4s.d.mts → transport-stream-shared-Dhx_37f1.d.mts} +1 -1
- package/dist/{transport-utils-CcCAuFVS.mjs → transport-utils-4xPfuKp2.mjs} +2 -2
- package/dist/transports.d.mts +23 -15
- package/dist/transports.mjs +65 -44
- package/dist/types-BFfXm_Jr.d.mts +1 -0
- package/dist/types.d.mts +3 -3
- package/dist/types.mjs +2 -2
- package/dist/ws.LICENSE +20 -0
- package/package.json +1 -1
- package/dist/openai-completions-transport-CqomHW1O.mjs +0 -3468
- package/dist/retry-after-sw-XX8aC.d.mts +0 -15
- package/dist/types-CBJthzJX.d.mts +0 -1
package/README.md
CHANGED
|
@@ -17,6 +17,13 @@ available from the package root and focused subpaths such as
|
|
|
17
17
|
`@openclaw/ai/event-stream`, `@openclaw/ai/transports`, and
|
|
18
18
|
`@openclaw/ai/validation`. No second OpenClaw runtime package is required.
|
|
19
19
|
|
|
20
|
+
The Node package bundles the reachable OpenAI and `ws` runtime code to reduce
|
|
21
|
+
startup module-file loading. Their licenses ship in `dist/openai.LICENSE` and
|
|
22
|
+
`dist/ws.LICENSE`. Other provider SDKs and TypeBox retain their existing external
|
|
23
|
+
dependency identities.
|
|
24
|
+
OpenAI types resolve through the declared `openai` dependency, preserving its
|
|
25
|
+
namespace aliases without flattening them into the bundled declarations.
|
|
26
|
+
|
|
20
27
|
Provider ids, credentials, model catalogs, retries, and failover remain
|
|
21
28
|
application concerns. OpenClaw supplies those policies around this package.
|
|
22
29
|
Host policy (request fetch guarding, secret redaction, strict-tool defaults,
|
|
@@ -24,7 +31,8 @@ provider plugin hooks, and diagnostics logging) can be injected with
|
|
|
24
31
|
`configureAiTransportHost`; the defaults are inert. Node callers that need
|
|
25
32
|
runtime-local policy can use `createNodeLlmRuntime`; it preserves that host across
|
|
26
33
|
provider work without replacing the process default. `createLlmRuntime` continues
|
|
27
|
-
to use the process-default host.
|
|
34
|
+
to use the process-default host. The default host and its asynchronous scope are
|
|
35
|
+
shared across duplicate package module instances, including native plugins.
|
|
28
36
|
|
|
29
37
|
OpenAI HTTP adapters report rejected response status and headers through
|
|
30
38
|
`onResponse` before consuming the error body. Successful streaming responses
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { n as __exportAll } from "./
|
|
2
|
-
import {
|
|
1
|
+
import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.mjs";
|
|
2
|
+
import { E as supportsClaudeAdaptiveThinking } from "./src--qsViR3j.mjs";
|
|
3
3
|
import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { s as streamFragmentError } from "./transport-utils-
|
|
6
|
-
import { F as supportsAnthropicServerSideFallback, H as isAnthropicOAuthApiKey, O as isDirectAnthropicModel, U as omitFoundryBearerCredentialHeaders, W as usesFoundryBearerAuth, d as applyAnthropicThinkingOptions, l as buildAnthropicRequest, t as consumeAnthropicStream, u as prepareAnthropicRequest, x as suppressAnthropicCompaction, y as isAnthropicReplayRejection } from "./anthropic-stream-reducer-
|
|
4
|
+
import { O as usesClaudeStreamingRefusalContract, S as readRequiredClaudeCodeVersion, _ as buildAnthropicClaudeCodeIdentity, a as resolveAiTransportHeaderSentinels, b as prepareClaudeNoPrefillRequestContext, r as getAiTransportHost, x as raiseClaudeCodeVersionFloor } from "./host-CyGba3M8.mjs";
|
|
5
|
+
import { s as streamFragmentError } from "./transport-utils-4xPfuKp2.mjs";
|
|
6
|
+
import { F as supportsAnthropicServerSideFallback, H as isAnthropicOAuthApiKey, O as isDirectAnthropicModel, U as omitFoundryBearerCredentialHeaders, W as usesFoundryBearerAuth, d as applyAnthropicThinkingOptions, l as buildAnthropicRequest, t as consumeAnthropicStream, u as prepareAnthropicRequest, x as suppressAnthropicCompaction, y as isAnthropicReplayRejection } from "./anthropic-stream-reducer-BTcDHWGM.mjs";
|
|
7
7
|
import { i as resolveCacheRetention, n as resolveCloudflareBaseUrl, r as buildCopilotDynamicHeaders } from "./cloudflare-Dttf8jKq.mjs";
|
|
8
|
-
import { n as buildBaseOptions, r as clampMaxTokensToModel } from "./simple-options-
|
|
9
|
-
import { D as parseJsonWithRepair, m as notifyProviderHttpResponse, n as assignTransportErrorDetails, u as finalizeTransportStream } from "./transport-stream-shared-
|
|
8
|
+
import { n as buildBaseOptions, r as clampMaxTokensToModel } from "./simple-options-Bd0STwu7.mjs";
|
|
9
|
+
import { D as parseJsonWithRepair, m as notifyProviderHttpResponse, n as assignTransportErrorDetails, u as finalizeTransportStream } from "./transport-stream-shared-C1AtJhZA.mjs";
|
|
10
10
|
import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
|
|
11
11
|
import { t as createDeferredEventBuffer } from "./deferred-event-buffer-DAvyP7qA.mjs";
|
|
12
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
12
|
+
import { t as createAssistantOutput } from "./assistant-output-Hl3b-ViJ.mjs";
|
|
13
13
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-CfMuh5cC.mjs";
|
|
14
14
|
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-DA4WHv1h.mjs";
|
|
15
15
|
import { t as requireApiKey } from "./required-api-key-D088S4Cd.mjs";
|
|
@@ -61,25 +61,44 @@ const streamAnthropic = (model, context, options) => {
|
|
|
61
61
|
const refusalBuffer = usesClaudeStreamingRefusalContract(model) ? createDeferredEventBuffer(stream) : void 0;
|
|
62
62
|
let replayedCompaction;
|
|
63
63
|
try {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
const send = async (canRetry) => {
|
|
65
|
+
const { client, isOAuthToken, serverSideFallback, directApiKeyBetaHeader, claudeCodeVersion } = createClient(model, requestContext, requestOptions);
|
|
66
|
+
const builtParams = await buildAnthropicRequest(model, requestContext, requestOptions, "provider", isOAuthToken, serverSideFallback, claudeCodeVersion);
|
|
67
|
+
replayedCompaction = builtParams.replayedCompaction;
|
|
68
|
+
const { params, headers } = await prepareAnthropicRequest(builtParams.params, model, requestOptions, directApiKeyBetaHeader);
|
|
69
|
+
const sdkRequestOptions = {
|
|
70
|
+
...requestOptions?.signal ? { signal: requestOptions.signal } : {},
|
|
71
|
+
...requestOptions?.timeoutMs !== void 0 ? { timeout: requestOptions.timeoutMs } : {},
|
|
72
|
+
maxRetries: 0,
|
|
73
|
+
headers
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
const response = await client.messages.create({
|
|
77
|
+
...params,
|
|
78
|
+
stream: true
|
|
79
|
+
}, sdkRequestOptions).asResponse();
|
|
80
|
+
await notifyProviderHttpResponse({
|
|
81
|
+
options: requestOptions,
|
|
82
|
+
response,
|
|
83
|
+
model
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
response,
|
|
87
|
+
isOAuthToken,
|
|
88
|
+
builtParams
|
|
89
|
+
};
|
|
90
|
+
} catch (error) {
|
|
91
|
+
const required = isOAuthToken ? readRequiredClaudeCodeVersion(error) : void 0;
|
|
92
|
+
if (canRetry && required && raiseClaudeCodeVersionFloor(required)) {
|
|
93
|
+
try {
|
|
94
|
+
requestOptions?.onClaudeCodeVersionRequired?.(required);
|
|
95
|
+
} catch {}
|
|
96
|
+
return send(false);
|
|
97
|
+
}
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
73
100
|
};
|
|
74
|
-
const response = await
|
|
75
|
-
...params,
|
|
76
|
-
stream: true
|
|
77
|
-
}, sdkRequestOptions).asResponse();
|
|
78
|
-
await notifyProviderHttpResponse({
|
|
79
|
-
options: requestOptions,
|
|
80
|
-
response,
|
|
81
|
-
model
|
|
82
|
-
});
|
|
101
|
+
const { response, isOAuthToken, builtParams } = await send(true);
|
|
83
102
|
await consumeAnthropicStream({
|
|
84
103
|
events: iterateAnthropicEvents(response, requestOptions?.signal),
|
|
85
104
|
model,
|
|
@@ -133,6 +152,7 @@ const streamSimpleAnthropic = (model, context, options) => {
|
|
|
133
152
|
anthropicCompactThreshold: options?.anthropicCompactThreshold,
|
|
134
153
|
cacheTtlPruning: options?.cacheTtlPruning,
|
|
135
154
|
onCompactionRejected: options?.onCompactionRejected,
|
|
155
|
+
onClaudeCodeVersionRequired: options?.onClaudeCodeVersionRequired,
|
|
136
156
|
authProfileId: options?.authProfileId,
|
|
137
157
|
maxTokens: clampMaxTokensToModel(model, options?.maxTokens ?? model.maxTokens),
|
|
138
158
|
toolChoice: options?.toolChoice,
|
package/dist/{anthropic-payload-policy-rqCq9sT_.d.mts → anthropic-payload-policy-BCp4dUJR.d.mts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
1
|
+
import "./index-B8ODIVmA.mjs";
|
|
2
2
|
import { k as Model } from "./types-CVYzKrMl.mjs";
|
|
3
|
-
import { t as AnthropicContextManagementOptions } from "./provider-options-
|
|
3
|
+
import { t as AnthropicContextManagementOptions } from "./provider-options-DFjnfImJ.mjs";
|
|
4
4
|
import { TextBlockParam } from "@anthropic-ai/sdk/resources/messages.js";
|
|
5
5
|
//#region packages/ai/src/transports/anthropic-payload-policy.d.ts
|
|
6
6
|
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
package/dist/{anthropic-stream-reducer-C__ByTq1.mjs → anthropic-stream-reducer-BTcDHWGM.mjs}
RENAMED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as supportsClaudeNativeXhighEffort, C as resolveClaudeSonnet55ModelIdentity, E as supportsClaudeAdaptiveThinking, M as usesClaude5RequestContract, O as supportsClaudeInHistorySystemMessages, S as resolveClaudeOpus5ModelIdentity, _ as resolveClaudeHaiku55ModelIdentity, g as resolveClaudeFable5ModelIdentity, j as supportsClaudeServerCompaction, p as requiresClaudeBetweenToolsThinking, u as bindsClaudeThinkingPrefix, v as resolveClaudeModelIdentity, x as resolveClaudeOpus55ModelIdentity } from "./src--qsViR3j.mjs";
|
|
2
2
|
import { f as hasRuntimeContextMarker } from "./types-BXd0kI8-.mjs";
|
|
3
3
|
import { r as appendAssistantThinking } from "./event-stream-X2gmsUWv.mjs";
|
|
4
4
|
import { a as asRecord, o as isRecord, r as asOptionalObjectRecord, s as readStringField } from "./record-coerce-CNDovvft.mjs";
|
|
5
5
|
import { a as normalizeOptionalLowercaseString, i as normalizeNullableString } from "./string-coerce-Cj8sqWHx.mjs";
|
|
6
6
|
import { n as asNonNegativeFiniteNumber } from "./number-coercion-37gmNkuA.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import "./transport-utils-
|
|
7
|
+
import { C as requiresClaudeAdaptiveThinking, D as usesClaudeFable5MessagesContract, I as isImageWithMediaPayload, T as resolveAnthropicThinkingEffort, g as applyClaudeRequestContract, h as ANTHROPIC_CLAUDE_CODE_VERSION, j as calculateCost, r as getAiTransportHost, u as STREAM_ERROR_FALLBACK_TEXT, v as defaultsClaudeAdaptiveThinking, y as mapAnthropicStopReason } from "./host-CyGba3M8.mjs";
|
|
8
|
+
import "./transport-utils-4xPfuKp2.mjs";
|
|
9
9
|
import { n as estimateBase64DecodedBytes } from "./base64-C8CdcsjU.mjs";
|
|
10
|
-
import { a as resolveProviderRequestCapabilities, i as resolveProviderEndpoint } from "./host-policy-
|
|
10
|
+
import { a as resolveProviderRequestCapabilities, i as resolveProviderEndpoint } from "./host-policy-CNQztzZm.mjs";
|
|
11
11
|
import { i as resolveCacheRetention } from "./cloudflare-Dttf8jKq.mjs";
|
|
12
12
|
import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
|
|
13
|
-
import { S as splitSystemPromptCacheBoundary, T as stripSystemPromptRelocatableBoundary, d as extractToolResultBlockText, f as extractToolResultText, h as preparedRequestSuffix, l as describeToolResultMediaPlaceholder, t as adjustMaxTokensForThinking, w as stripSystemPromptCacheBoundary } from "./simple-options-
|
|
14
|
-
import { C as parseJsonObjectPreservingUnsafeIntegers, E as createToolArgumentPreviewSchedule, O as parseStreamingJson, b as transportAbortError, d as iterateModelStream, i as copyProviderAcceptanceObserver, l as finalizeTerminalToolCallArguments, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-
|
|
13
|
+
import { S as splitSystemPromptCacheBoundary, T as stripSystemPromptRelocatableBoundary, d as extractToolResultBlockText, f as extractToolResultText, h as preparedRequestSuffix, l as describeToolResultMediaPlaceholder, t as adjustMaxTokensForThinking, w as stripSystemPromptCacheBoundary } from "./simple-options-Bd0STwu7.mjs";
|
|
14
|
+
import { C as parseJsonObjectPreservingUnsafeIntegers, E as createToolArgumentPreviewSchedule, O as parseStreamingJson, b as transportAbortError, d as iterateModelStream, i as copyProviderAcceptanceObserver, l as finalizeTerminalToolCallArguments, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-C1AtJhZA.mjs";
|
|
15
15
|
import { t as parsePositiveInteger } from "./positive-integer-Bb4Evc7L.mjs";
|
|
16
|
-
import { n as isProviderReplayContext, r as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-
|
|
17
|
-
import { n as transformProviderMessages } from "./assistant-output-
|
|
18
|
-
import { a as reconcileAnthropicToolChoice, i as projectAnthropicTools, n as normalizeAnthropicToolChoice, o as resolveOriginalAnthropicToolName, s as toClaudeCodeToolName, t as normalizeAnthropicToolCallId } from "./anthropic-tool-projection-
|
|
16
|
+
import { n as isProviderReplayContext, r as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-C5uMjBz4.mjs";
|
|
17
|
+
import { n as transformProviderMessages } from "./assistant-output-Hl3b-ViJ.mjs";
|
|
18
|
+
import { a as reconcileAnthropicToolChoice, i as projectAnthropicTools, n as normalizeAnthropicToolChoice, o as resolveOriginalAnthropicToolName, s as toClaudeCodeToolName, t as normalizeAnthropicToolCallId } from "./anthropic-tool-projection-CrsCkF4k.mjs";
|
|
19
19
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-CfMuh5cC.mjs";
|
|
20
20
|
//#region packages/ai/src/providers/anthropic-auth-headers.ts
|
|
21
21
|
/** Inspect resolved credential shape for auth routing without exposing its value. */
|
|
@@ -660,7 +660,7 @@ function resolveAnthropicTransportOptions(model, options, apiKey) {
|
|
|
660
660
|
modelContextWindow: model.contextWindow,
|
|
661
661
|
modelMaxTokens: model.maxTokens,
|
|
662
662
|
requestedMaxTokens: options?.maxTokens,
|
|
663
|
-
useModelDefault:
|
|
663
|
+
useModelDefault: usesClaude5RequestContract(model)
|
|
664
664
|
});
|
|
665
665
|
if (baseMaxTokens === void 0) throw new Error(`Anthropic Messages transport requires a positive maxTokens value for ${model.provider}/${model.id}`);
|
|
666
666
|
const resolved = copyProviderAcceptanceObserver(options, {
|
|
@@ -684,6 +684,7 @@ function resolveAnthropicTransportOptions(model, options, apiKey) {
|
|
|
684
684
|
anthropicServerCompaction: options?.anthropicServerCompaction,
|
|
685
685
|
anthropicCompactThreshold: options?.anthropicCompactThreshold,
|
|
686
686
|
cacheTtlPruning: options?.cacheTtlPruning,
|
|
687
|
+
onClaudeCodeVersionRequired: options?.onClaudeCodeVersionRequired,
|
|
687
688
|
...options?.authProfileId ? { authProfileId: options.authProfileId } : {}
|
|
688
689
|
});
|
|
689
690
|
resolved.reasoning = applyAnthropicThinkingOptions(model, resolved, options, "transport");
|
|
@@ -978,7 +979,6 @@ async function buildAnthropicRequest(model, context, options, profile, isOAuthTo
|
|
|
978
979
|
}
|
|
979
980
|
const replayPlan = buildAnthropicReplayPlan(context.messages, model, {
|
|
980
981
|
enabled: !isOAuthToken && options?.anthropicServerCompaction === true,
|
|
981
|
-
authProfileId: options?.authProfileId,
|
|
982
982
|
sessionId: options?.sessionId
|
|
983
983
|
});
|
|
984
984
|
const cacheBreakpointOptOutMessageIndexes = /* @__PURE__ */ new Set();
|
package/dist/{anthropic-tool-projection-DA_KeluM.mjs → anthropic-tool-projection-CrsCkF4k.mjs}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
2
|
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-D_MeCQFI.mjs";
|
|
3
|
-
import { _ as SCHEMA_MAP_KEYS, d as inheritToolSchemaTruncation, g as SCHEMA_ARRAY_KEYS, i as publishRuntimeToolInputSchema, r as projectRuntimeToolInputSchema, t as getPublishedRuntimeToolInputSchema, y as SCHEMA_OBJECT_KEYS } from "./tool-schema-json-projection-
|
|
3
|
+
import { _ as SCHEMA_MAP_KEYS, d as inheritToolSchemaTruncation, g as SCHEMA_ARRAY_KEYS, i as publishRuntimeToolInputSchema, r as projectRuntimeToolInputSchema, t as getPublishedRuntimeToolInputSchema, y as SCHEMA_OBJECT_KEYS } from "./tool-schema-json-projection-DU-FFSa7.mjs";
|
|
4
4
|
//#region packages/ai/src/providers/anthropic-tool-projection.ts
|
|
5
5
|
const CLAUDE_CODE_TOOL_LOOKUP = new Map([
|
|
6
6
|
"Read",
|
package/dist/{anthropic-tool-projection-JTvMo4KG.d.mts → anthropic-tool-projection-CzSSQzZL.d.mts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as AnthropicOptions } from "./provider-options-
|
|
1
|
+
import { r as AnthropicOptions } from "./provider-options-DFjnfImJ.mjs";
|
|
2
2
|
import { Tool } from "@anthropic-ai/sdk/resources/messages.js";
|
|
3
3
|
//#region packages/ai/src/providers/anthropic-tool-projection.d.ts
|
|
4
4
|
type AnthropicToolDescriptor = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./index-
|
|
1
|
+
import "./index-B8ODIVmA.mjs";
|
|
2
2
|
import { Q as SimpleStreamOptions, n as Api, nt as StreamOptions, tt as StreamFunction } from "./types-CVYzKrMl.mjs";
|
|
3
3
|
//#region packages/ai/src/api-registry.d.ts
|
|
4
4
|
/** Runtime stream adapter signature stored in the API provider registry. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as transformMessages } from "./host-
|
|
2
|
-
import { a as createEmptyTransportUsage } from "./transport-stream-shared-
|
|
1
|
+
import { c as transformMessages } from "./host-CyGba3M8.mjs";
|
|
2
|
+
import { a as createEmptyTransportUsage } from "./transport-stream-shared-C1AtJhZA.mjs";
|
|
3
3
|
//#region packages/ai/src/provider-transcript-transform.ts
|
|
4
4
|
const IMAGE_OMISSION = "(image omitted: model does not support images)";
|
|
5
5
|
const VIDEO_OMISSION = "(video omitted: provider does not support video input)";
|
|
@@ -26,7 +26,7 @@ function transformProviderMessages(messages, model, normalizeToolCallId) {
|
|
|
26
26
|
};
|
|
27
27
|
return transformMessages(messages.map((message) => {
|
|
28
28
|
if (message.role !== "user" || !Array.isArray(message.content)) return message;
|
|
29
|
-
return Object.assign({}, message, { content: projectUserMediaForTransport(message.content, model.input.includes("image"), model.api === "openai-completions" && model.input.includes("video")) });
|
|
29
|
+
return Object.assign({}, message, { content: projectUserMediaForTransport(message.content, model.input.includes("image"), (model.api === "openai-completions" || model.api === "google-interactions") && model.input.includes("video")) });
|
|
30
30
|
}), target, normalizeToolCallId);
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
|
|
2
|
-
import { r as getAiTransportHost } from "./host-
|
|
3
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
2
|
+
import { r as getAiTransportHost } from "./host-CyGba3M8.mjs";
|
|
3
|
+
import { n as buildBaseOptions } from "./simple-options-Bd0STwu7.mjs";
|
|
4
4
|
import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
|
|
5
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
6
|
-
import { F as convertProviderResponsesMessages, Lt as resolvePromptCacheKey, Rt as withOpenAIErrorResponseHook, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams, vt as resolveOpenAISimpleReasoningEffort } from "./openai-responses-shared-
|
|
5
|
+
import { t as createAssistantOutput } from "./assistant-output-Hl3b-ViJ.mjs";
|
|
6
|
+
import { F as convertProviderResponsesMessages, Lt as resolvePromptCacheKey, Rt as withOpenAIErrorResponseHook, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams, vt as resolveOpenAISimpleReasoningEffort } from "./openai-responses-shared-BDGaQxiw.mjs";
|
|
7
|
+
import { n as OpenAI, t as AzureOpenAI } from "./openai-BfFy1nvf.mjs";
|
|
7
8
|
import { i as resolveAzureDeploymentNameFromMap, n as isTraditionalAzureOpenAIHost, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-D0dvJMbZ.mjs";
|
|
8
9
|
import { t as requireApiKey } from "./required-api-key-D088S4Cd.mjs";
|
|
9
|
-
import OpenAI, { AzureOpenAI } from "openai";
|
|
10
10
|
//#region packages/ai/src/providers/azure-openai-responses.ts
|
|
11
11
|
const DEFAULT_AZURE_API_VERSION = "v1";
|
|
12
12
|
const AZURE_TOOL_CALL_PROVIDERS = /* @__PURE__ */ new Set([
|
|
@@ -102,7 +102,6 @@ function buildParams(model, context, options, deploymentName, replayMode) {
|
|
|
102
102
|
model: deploymentName,
|
|
103
103
|
input: convertProviderResponsesMessages(model, context, AZURE_TOOL_CALL_PROVIDERS, {
|
|
104
104
|
sessionId: options?.sessionId,
|
|
105
|
-
authProfileId: options?.authProfileId,
|
|
106
105
|
replayMode
|
|
107
106
|
}),
|
|
108
107
|
stream: true,
|
|
@@ -167,6 +167,22 @@ function resolveResponsesTerminalStopReason(params) {
|
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region packages/ai/src/transports/openai-responses-stream-errors.ts
|
|
169
169
|
const OUTPUT_IDENTITY_ERROR_CODE = "responses_output_identity_conflict";
|
|
170
|
+
const TOOL_CALL_WHITESPACE = /\s/u;
|
|
171
|
+
var DegenerateToolCallArgumentsError = class extends Error {
|
|
172
|
+
constructor() {
|
|
173
|
+
super("Tool-call argument stream exceeded the consecutive whitespace limit");
|
|
174
|
+
this.code = "degenerate_output";
|
|
175
|
+
this.name = "DegenerateToolCallArgumentsError";
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
function countToolCallTrailingWhitespace(delta, previous = 0) {
|
|
179
|
+
const limit = 32768;
|
|
180
|
+
let tail = 0;
|
|
181
|
+
for (let index = delta.length - 1; index >= 0 && tail < limit && TOOL_CALL_WHITESPACE.test(delta.charAt(index)); index--) tail += 1;
|
|
182
|
+
const count = tail === delta.length ? previous + tail : tail;
|
|
183
|
+
if (count >= limit) throw new DegenerateToolCallArgumentsError();
|
|
184
|
+
return count;
|
|
185
|
+
}
|
|
170
186
|
function outputType(type) {
|
|
171
187
|
return type === "reasoning" || type === "message" || type === "function_call" || type === "compaction" ? type : "other";
|
|
172
188
|
}
|
|
@@ -329,4 +345,4 @@ function formatModelTransportDebugBaseUrl(rawUrl) {
|
|
|
329
345
|
return rawUrl ? formatModelTransportDebugUrl(rawUrl) : "default";
|
|
330
346
|
}
|
|
331
347
|
//#endregion
|
|
332
|
-
export {
|
|
348
|
+
export { mapResponsesTerminalUsage as _, resolveModelPayloadDebugMode as a, extractErrorCodeOrErrno as b, hasRetryableConnectionErrorCode as c, ResponsesOutputIdentityError as d, countToolCallTrailingWhitespace as f, isResponsesOutputLimitToolCallError as g, resolveResponsesOutputIdentityRetry as h, emitModelTransportError as i, isTransientNetworkError as l, isResponsesProviderTool as m, formatModelTransportDebugUrl as n, resolveModelSseDebugMode as o, hasOnlyResponsesFunctionTools as p, emitModelTransportDebug as r, WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE as s, formatModelTransportDebugBaseUrl as t, DegenerateToolCallArgumentsError as u, readResponsesReasoningTokens as v, toErrorObject as x, resolveResponsesTerminalStopReason as y };
|
package/dist/diagnostics.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { o as ProviderRefusalReview, s as readProviderRefusalReview } from "./index-
|
|
1
|
+
import { o as ProviderRefusalReview, s as readProviderRefusalReview } from "./index-B8ODIVmA.mjs";
|
|
2
2
|
import { At as extractDiagnosticError, Dt as DiagnosticErrorInfo, Et as AssistantMessageDiagnostic, Mt as isProviderRefusalAssistantError, Ot as appendAssistantMessageDiagnostic, a as AssistantMessage, jt as formatThrownValue, kt as createAssistantMessageDiagnostic } from "./types-CVYzKrMl.mjs";
|
|
3
|
-
import "./types-
|
|
4
|
-
import { n as isResponsesOutputLimitToolCallError } from "./openai-responses-terminal-usage-
|
|
3
|
+
import "./types-BFfXm_Jr.mjs";
|
|
4
|
+
import { n as isResponsesOutputLimitToolCallError } from "./openai-responses-terminal-usage-BDGDBGuA.mjs";
|
|
5
5
|
import { n as ProviderErrorRedactor, r as configureProviderErrorRedactor } from "./provider-error-CnaWYTRY.mjs";
|
|
6
6
|
import { i as projectDiagnosticValue, t as DiagnosticProjectionPolicy } from "./credential-redaction-XvsPf7Yi.mjs";
|
|
7
7
|
import { i as emitModelTransportError, n as formatModelTransportDebugUrl, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./model-transport-url-BrsjjdjR.mjs";
|
package/dist/diagnostics.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as isProviderRefusalAssistantError, i as formatThrownValue, n as createAssistantMessageDiagnostic, o as readProviderRefusalReview, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
|
|
2
2
|
import { a as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-qtZD2inE.mjs";
|
|
3
|
-
import { c as hasRetryableConnectionErrorCode,
|
|
3
|
+
import { c as hasRetryableConnectionErrorCode, g as isResponsesOutputLimitToolCallError, h as resolveResponsesOutputIdentityRetry, i as emitModelTransportError, l as isTransientNetworkError, n as formatModelTransportDebugUrl, r as emitModelTransportDebug, s as WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, t as formatModelTransportDebugBaseUrl } from "./diagnostics-v7oVEW59.mjs";
|
|
4
4
|
export { WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, emitModelTransportDebug, emitModelTransportError, extractDiagnosticError, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, formatThrownValue, hasRetryableConnectionErrorCode, isProviderRefusalAssistantError, isResponsesOutputLimitToolCallError, isTransientNetworkError, projectDiagnosticValue, readProviderRefusalReview, resolveResponsesOutputIdentityRetry };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as getAiTransportHost } from "./host-
|
|
1
|
+
import { r as getAiTransportHost } from "./host-CyGba3M8.mjs";
|
|
2
2
|
import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
|
|
3
3
|
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-DA4WHv1h.mjs";
|
|
4
4
|
import { t as requireApiKey } from "./required-api-key-D088S4Cd.mjs";
|
|
5
|
-
import { n as buildGoogleHttpOptions, t as createGoogleGenerateContentStreams } from "./google-provider-stream-
|
|
5
|
+
import { n as buildGoogleHttpOptions, t as createGoogleGenerateContentStreams } from "./google-provider-stream-DL0bXgX5.mjs";
|
|
6
6
|
import { GoogleGenAI } from "@google/genai";
|
|
7
7
|
//#region packages/ai/src/providers/google.ts
|
|
8
8
|
const { stream: streamGoogle, streamSimple: streamSimpleGoogle } = createGoogleGenerateContentStreams("google-generative-ai", (model, options) => {
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
|
|
2
2
|
import { a as asRecord, i as asOptionalRecord, s as readStringField } from "./record-coerce-CNDovvft.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { s as streamFragmentError } from "./transport-utils-
|
|
5
|
-
import { t as buildGuardedModelFetch } from "./host-policy-
|
|
3
|
+
import { a as resolveAiTransportHeaderSentinels, j as calculateCost, r as getAiTransportHost } from "./host-CyGba3M8.mjs";
|
|
4
|
+
import { s as streamFragmentError } from "./transport-utils-4xPfuKp2.mjs";
|
|
5
|
+
import { t as buildGuardedModelFetch } from "./host-policy-CNQztzZm.mjs";
|
|
6
6
|
import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
|
|
7
|
-
import { n as buildBaseOptions, w as stripSystemPromptCacheBoundary } from "./simple-options-
|
|
8
|
-
import { b as transportAbortError, c as failTransportStream, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, m as notifyProviderHttpResponse, w as parseJsonPreservingUnsafeIntegers } from "./transport-stream-shared-
|
|
7
|
+
import { n as buildBaseOptions, w as stripSystemPromptCacheBoundary } from "./simple-options-Bd0STwu7.mjs";
|
|
8
|
+
import { b as transportAbortError, c as failTransportStream, f as mergeTransportHeaders, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, m as notifyProviderHttpResponse, w as parseJsonPreservingUnsafeIntegers } from "./transport-stream-shared-C1AtJhZA.mjs";
|
|
9
9
|
import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
|
|
10
|
-
import { n as transformProviderMessages, t as createAssistantOutput } from "./assistant-output-
|
|
11
|
-
import { n as
|
|
10
|
+
import { n as transformProviderMessages, t as createAssistantOutput } from "./assistant-output-Hl3b-ViJ.mjs";
|
|
11
|
+
import { n as createGoogleVideoPlaceholder, r as materializeGoogleVideoSlots, t as GOOGLE_VIDEO_SLOT_OMISSION } from "./google-video-slots-D8tPH8wX.mjs";
|
|
12
|
+
import { PROVIDER_CONTEXT_HANDOFF, PROVIDER_MODEL_INPUT, resolveProviderContext } from "./provider-types.mjs";
|
|
13
|
+
import { n as buildGoogleInteractionsSimpleThinking } from "./google-shared-DXizMtnG.mjs";
|
|
12
14
|
//#region packages/ai/package.json
|
|
13
|
-
var version = "2026.10.
|
|
15
|
+
var version = "2026.10.33";
|
|
14
16
|
//#endregion
|
|
15
17
|
//#region packages/ai/src/providers/google-interactions-request.ts
|
|
16
18
|
const DEFAULT_GOOGLE_API_BASE_URL = "https://generativelanguage.googleapis.com";
|
|
@@ -32,7 +34,7 @@ function resolveGoogleApiClientHeaders(params) {
|
|
|
32
34
|
"x-goog-api-client": `openclaw/${resolvePackageVersion()}`
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
|
-
function convertMessages(model, context) {
|
|
37
|
+
function convertMessages(model, context, videoSlots) {
|
|
36
38
|
const steps = [];
|
|
37
39
|
const messages = transformProviderMessages(context.messages, model);
|
|
38
40
|
for (const message of messages) {
|
|
@@ -41,13 +43,20 @@ function convertMessages(model, context) {
|
|
|
41
43
|
const content = (typeof sourceContent === "string" ? [{
|
|
42
44
|
type: "text",
|
|
43
45
|
text: sourceContent
|
|
44
|
-
}] : sourceContent).map((item) =>
|
|
45
|
-
type
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
}] : sourceContent).map((item) => {
|
|
47
|
+
if (item.type === "text") return {
|
|
48
|
+
type: "text",
|
|
49
|
+
text: sanitizeSurrogates(item.text) || " "
|
|
50
|
+
};
|
|
51
|
+
if (item.type === "video") return createGoogleVideoPlaceholder(item, videoSlots, {
|
|
52
|
+
type: "text",
|
|
53
|
+
text: GOOGLE_VIDEO_SLOT_OMISSION
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
type: "image",
|
|
57
|
+
mime_type: item.mimeType,
|
|
58
|
+
data: item.data
|
|
59
|
+
};
|
|
51
60
|
});
|
|
52
61
|
steps.push({
|
|
53
62
|
type: "user_input",
|
|
@@ -122,12 +131,20 @@ function convertMessages(model, context) {
|
|
|
122
131
|
}
|
|
123
132
|
return steps;
|
|
124
133
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
if (
|
|
134
|
+
/** Maps the shared tool-choice vocabulary (as GenerateContent does) to Interactions. */
|
|
135
|
+
function normalizeGoogleInteractionsToolChoice(choice) {
|
|
136
|
+
if (choice === "auto" || choice === "none" || choice === "any") return choice;
|
|
137
|
+
if (choice === "required") return "any";
|
|
138
|
+
const name = asRecord(asRecord(choice).function).name;
|
|
139
|
+
return asRecord(choice).type === "function" && typeof name === "string" && name ? { allowed_tools: {
|
|
140
|
+
mode: "any",
|
|
141
|
+
tools: [name]
|
|
142
|
+
} } : void 0;
|
|
143
|
+
}
|
|
144
|
+
function buildGoogleInteractionsParams(model, context, options = {}, videoSlots) {
|
|
129
145
|
const generationConfig = {};
|
|
130
146
|
if (options.temperature !== void 0) generationConfig.temperature = options.temperature;
|
|
147
|
+
if (options.topP !== void 0) generationConfig.top_p = options.topP;
|
|
131
148
|
if (options.maxTokens !== void 0) generationConfig.max_output_tokens = options.maxTokens;
|
|
132
149
|
if (options.stop && options.stop.length > 0) generationConfig.stop_sequences = options.stop;
|
|
133
150
|
if (options.thinking) {
|
|
@@ -144,7 +161,10 @@ function buildGoogleInteractionsParams(model, context, options = {}) {
|
|
|
144
161
|
}));
|
|
145
162
|
return {
|
|
146
163
|
model: model.id,
|
|
147
|
-
input: convertMessages(
|
|
164
|
+
input: convertMessages({
|
|
165
|
+
...model,
|
|
166
|
+
input: options[PROVIDER_MODEL_INPUT] ?? model.input
|
|
167
|
+
}, context, videoSlots),
|
|
148
168
|
...context.systemPrompt ? { system_instruction: sanitizeSurrogates(stripSystemPromptCacheBoundary(context.systemPrompt)) } : {},
|
|
149
169
|
...tools && tools.length > 0 ? { tools } : {},
|
|
150
170
|
...Object.keys(generationConfig).length > 0 ? { generation_config: generationConfig } : {},
|
|
@@ -183,12 +203,44 @@ async function runGoogleInteractionsLifecycle(params) {
|
|
|
183
203
|
const unresolvedApiKey = resolveGoogleInteractionsApiKey(model, options);
|
|
184
204
|
const apiKey = host.resolveSecretSentinel(unresolvedApiKey);
|
|
185
205
|
if (!apiKey.trim()) throw new Error(`No API key for provider: ${model.provider}`);
|
|
186
|
-
|
|
206
|
+
const providerContext = (options?.[PROVIDER_MODEL_INPUT] ?? model.input).includes("video") ? await resolveProviderContext(context, options) : context;
|
|
207
|
+
const videoSlots = /* @__PURE__ */ new Map();
|
|
208
|
+
let body = buildGoogleInteractionsParams(model, providerContext, options, videoSlots);
|
|
187
209
|
const nextBody = await options?.onPayload?.(body, model);
|
|
188
210
|
if (nextBody !== void 0) {
|
|
189
211
|
if (!isGoogleInteractionsRequestBody(nextBody)) throw new Error("Google Interactions onPayload returned an invalid request body");
|
|
190
212
|
body = nextBody;
|
|
191
213
|
}
|
|
214
|
+
const optionRecord = asRecord(options);
|
|
215
|
+
const metadata = asRecord(optionRecord.videoMetadata ?? optionRecord.video_metadata);
|
|
216
|
+
const processing = {};
|
|
217
|
+
for (const [camel, snake] of [
|
|
218
|
+
["startOffset", "start_offset"],
|
|
219
|
+
["endOffset", "end_offset"],
|
|
220
|
+
["fps", "fps"]
|
|
221
|
+
]) {
|
|
222
|
+
const value = metadata[camel] ?? metadata[snake];
|
|
223
|
+
if (value !== void 0) processing[snake] = value;
|
|
224
|
+
}
|
|
225
|
+
materializeGoogleVideoSlots(body, videoSlots, (slot, video) => {
|
|
226
|
+
Object.assign(slot, {
|
|
227
|
+
type: "video",
|
|
228
|
+
mime_type: video.mimeType,
|
|
229
|
+
data: video.data,
|
|
230
|
+
...Object.keys(processing).length > 0 ? { processing: {
|
|
231
|
+
type: "static",
|
|
232
|
+
...processing
|
|
233
|
+
} } : {}
|
|
234
|
+
});
|
|
235
|
+
}, (part) => {
|
|
236
|
+
if (part.type === "video") {
|
|
237
|
+
Object.keys(part).forEach((key) => Reflect.deleteProperty(part, key));
|
|
238
|
+
Object.assign(part, {
|
|
239
|
+
type: "text",
|
|
240
|
+
text: GOOGLE_VIDEO_SLOT_OMISSION
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
});
|
|
192
244
|
let baseUrl = (model.baseUrl || "https://generativelanguage.googleapis.com/v1beta").trim().replace(/\/+$/, "");
|
|
193
245
|
if (/^https:\/\/generativelanguage\.googleapis\.com$/i.test(baseUrl)) baseUrl = "https://generativelanguage.googleapis.com/v1beta";
|
|
194
246
|
const url = `${baseUrl}/interactions?alt=sse`;
|
|
@@ -197,14 +249,14 @@ async function runGoogleInteractionsLifecycle(params) {
|
|
|
197
249
|
api: "google-generative-ai",
|
|
198
250
|
model
|
|
199
251
|
});
|
|
200
|
-
const headers = resolveAiTransportHeaderSentinels({
|
|
252
|
+
const headers = resolveAiTransportHeaderSentinels(mergeTransportHeaders({
|
|
201
253
|
"Content-Type": "application/json",
|
|
202
|
-
"
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}) ?? {
|
|
254
|
+
...apiKey.trimStart().startsWith("{") && Object.keys({
|
|
255
|
+
...model.headers,
|
|
256
|
+
...options?.headers
|
|
257
|
+
}).some((name) => name.toLowerCase() === "authorization") ? {} : { "x-goog-api-key": apiKey },
|
|
258
|
+
"Api-Revision": "2026-05-20"
|
|
259
|
+
}, googleClientHeaders, model.headers, options?.headers)) ?? {
|
|
208
260
|
"Content-Type": "application/json",
|
|
209
261
|
"x-goog-api-key": apiKey
|
|
210
262
|
};
|
|
@@ -508,9 +560,18 @@ const streamSimpleGoogleInteractions = (model, context, options) => {
|
|
|
508
560
|
const apiKey = resolveGoogleInteractionsApiKey(model, options);
|
|
509
561
|
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
510
562
|
const base = buildBaseOptions(model, options, apiKey);
|
|
563
|
+
const providerOptions = options;
|
|
564
|
+
const record = asRecord(options);
|
|
565
|
+
const toolChoice = normalizeGoogleInteractionsToolChoice(record.toolChoice);
|
|
566
|
+
const videoMetadata = record.videoMetadata ?? record.video_metadata;
|
|
511
567
|
return streamGoogleInteractions(model, context, {
|
|
512
568
|
...base,
|
|
513
|
-
|
|
569
|
+
...typeof record.topP === "number" ? { topP: record.topP } : {},
|
|
570
|
+
[PROVIDER_MODEL_INPUT]: providerOptions?.[PROVIDER_MODEL_INPUT],
|
|
571
|
+
[PROVIDER_CONTEXT_HANDOFF]: providerOptions?.[PROVIDER_CONTEXT_HANDOFF],
|
|
572
|
+
thinking: buildGoogleInteractionsSimpleThinking(model, options),
|
|
573
|
+
...toolChoice ? { toolChoice } : {},
|
|
574
|
+
...videoMetadata !== void 0 ? { videoMetadata } : {}
|
|
514
575
|
});
|
|
515
576
|
};
|
|
516
577
|
//#endregion
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { f as hasRuntimeContextMarker } from "./types-BXd0kI8-.mjs";
|
|
1
2
|
import { r as appendAssistantThinking } from "./event-stream-X2gmsUWv.mjs";
|
|
2
|
-
import {
|
|
3
|
+
import { I as isImageWithMediaPayload, j as calculateCost } from "./host-CyGba3M8.mjs";
|
|
3
4
|
import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
|
|
4
5
|
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-D_MeCQFI.mjs";
|
|
5
|
-
import { f as extractToolResultText, l as describeToolResultMediaPlaceholder } from "./simple-options-
|
|
6
|
-
import { a as createEmptyTransportUsage, b as transportAbortError, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-
|
|
6
|
+
import { f as extractToolResultText, l as describeToolResultMediaPlaceholder } from "./simple-options-Bd0STwu7.mjs";
|
|
7
|
+
import { a as createEmptyTransportUsage, b as transportAbortError, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-C1AtJhZA.mjs";
|
|
7
8
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-CfMuh5cC.mjs";
|
|
8
9
|
import { isGoogleGemini4Model } from "./internal/google-model-family.mjs";
|
|
10
|
+
import "./types.mjs";
|
|
9
11
|
//#region packages/ai/src/transports/google-thinking-level.ts
|
|
10
12
|
/** Reports MINIMAL support for Gemini Flash and Gemini 4 models. */
|
|
11
13
|
function googleFlashSupportsMinimalThinking(modelId) {
|
|
@@ -311,6 +313,10 @@ function projectGoogleMessages(params) {
|
|
|
311
313
|
});
|
|
312
314
|
const visibleParts = managed && !model.input.includes("image") ? parts.filter((part) => !part.inlineData) : parts;
|
|
313
315
|
if (visibleParts.length === 0) visibleParts.push({ text: " " });
|
|
316
|
+
if (hasRuntimeContextMarker(msg)) {
|
|
317
|
+
visibleParts.unshift({ text: "The following is runtime context, not a user request. Do not respond to or acknowledge this context." });
|
|
318
|
+
visibleParts.push({ text: "Use this context to continue responding to the user's request." });
|
|
319
|
+
}
|
|
314
320
|
contents.push({
|
|
315
321
|
role: "user",
|
|
316
322
|
parts: visibleParts
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { a as asRecord } from "./record-coerce-CNDovvft.mjs";
|
|
3
|
+
import { a as resolveAiTransportHeaderSentinels } from "./host-CyGba3M8.mjs";
|
|
4
|
+
import { n as buildManagedModelFetch } from "./host-policy-CNQztzZm.mjs";
|
|
5
|
+
import { n as buildBaseOptions } from "./simple-options-Bd0STwu7.mjs";
|
|
6
|
+
import { f as mergeTransportHeaders } from "./transport-stream-shared-C1AtJhZA.mjs";
|
|
7
|
+
import { t as createAssistantOutput } from "./assistant-output-Hl3b-ViJ.mjs";
|
|
8
|
+
import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-DXizMtnG.mjs";
|
|
8
9
|
import { ResourceScope } from "@google/genai";
|
|
9
10
|
//#region packages/ai/src/providers/google-http-options.ts
|
|
10
11
|
function buildGoogleHttpOptions(model, optionsHeaders, profile) {
|
|
@@ -22,7 +23,7 @@ function buildGoogleHttpOptions(model, optionsHeaders, profile) {
|
|
|
22
23
|
} else if (model.baseUrl) {
|
|
23
24
|
httpOptions.baseUrl = model.baseUrl;
|
|
24
25
|
httpOptions.apiVersion = "";
|
|
25
|
-
}
|
|
26
|
+
} else httpOptions.apiVersion = "v1beta";
|
|
26
27
|
if (model.headers || optionsHeaders) httpOptions.headers = resolveAiTransportHeaderSentinels(profile === "vertex" ? {
|
|
27
28
|
...model.headers,
|
|
28
29
|
...optionsHeaders
|
|
@@ -48,10 +49,14 @@ function createGoogleGenerateContentStreams(api, createClient, resolveSimpleApiK
|
|
|
48
49
|
};
|
|
49
50
|
return {
|
|
50
51
|
stream,
|
|
51
|
-
streamSimple: (model, context, options) =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
streamSimple: (model, context, options) => {
|
|
53
|
+
const topP = asRecord(options).topP;
|
|
54
|
+
return stream(model, context, {
|
|
55
|
+
...buildBaseOptions(model, options, resolveSimpleApiKey?.(model, options)),
|
|
56
|
+
...typeof topP === "number" ? { topP } : {},
|
|
57
|
+
thinking: buildGoogleSimpleThinking(model, options)
|
|
58
|
+
});
|
|
59
|
+
}
|
|
55
60
|
};
|
|
56
61
|
}
|
|
57
62
|
//#endregion
|