@openclaw/ai 2026.7.2-beta.3 → 2026.7.2-beta.5
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 +6 -5
- package/dist/{anthropic-D7SyZQ5v.mjs → anthropic-CQVj3le6.mjs} +174 -33
- package/dist/{index-BoTnz8cv.d.mts → anthropic-SrGtwsJu.d.mts} +27 -1
- package/dist/{api-registry-DXBIXISf.d.mts → api-registry-DlMgPR39.d.mts} +1 -2
- package/dist/{azure-openai-responses-BkZgyZ3I.mjs → azure-openai-responses-DIYgsqFM.mjs} +7 -11
- package/dist/{env-api-keys-DnhYpc27.mjs → env-api-keys-DrgeBuva.mjs} +1 -1
- package/dist/error-coercion-DgxlWC0n.mjs +15 -0
- package/dist/{event-stream-BPemFrFW.d.mts → event-stream-YjaPW20U.d.mts} +1 -1
- package/dist/event-stream.d.mts +1 -1
- package/dist/{tool-schema-json-projection-BwNu3nDi.mjs → github-copilot-headers-BCoBNmL7.mjs} +48 -1
- package/dist/{google-C_biGbV7.mjs → google-f-A8xrae.mjs} +4 -4
- package/dist/{google-shared-BK-NoHl8.mjs → google-shared-J6qvYINH.mjs} +5 -4
- package/dist/{google-vertex-CvdzF1U7.mjs → google-vertex-D3yMVXIY.mjs} +3 -3
- package/dist/host-B9GUmcra.d.mts +173 -0
- package/dist/host-XYGZcgO8.mjs +98 -0
- package/dist/index-BVVgDSdq.d.mts +1 -0
- package/dist/index.d.mts +7 -50
- package/dist/index.mjs +3 -3
- package/dist/internal/anthropic.d.mts +15 -11
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/openai.d.mts +3 -280
- package/dist/internal/openai.mjs +5 -7
- package/dist/internal/runtime.d.mts +13 -34
- package/dist/internal/runtime.mjs +19 -11
- package/dist/internal/shared.d.mts +13 -8
- package/dist/internal/shared.mjs +2 -2
- package/dist/{mistral-BdrQmDWp.mjs → mistral-CKV-TOQj.mjs} +7 -6
- package/dist/number-coercion-DvG7SNMg.mjs +129 -0
- package/dist/openai-BPor_3WI.d.mts +358 -0
- package/dist/{openai-responses-shared-CwnGU0KW.mjs → openai-D3PD6PE-.mjs} +1890 -705
- package/dist/{openai-chatgpt-responses-DP63Qt01.mjs → openai-chatgpt-responses-CedIj0hk.mjs} +54 -58
- package/dist/{openai-completions-zLDfebnN.mjs → openai-completions-CiSutyu0.mjs} +459 -104
- package/dist/openai-prompt-cache-2uo_1OR1.d.mts +7 -0
- package/dist/openai-prompt-cache-mZTCdRPo.mjs +12 -0
- package/dist/prompt-cache-stability-Cwcjv_fx.d.mts +13 -0
- package/dist/{provider-error-LMfTEkfO.mjs → provider-error-apVOZI6G.mjs} +9 -2
- package/dist/providers.d.mts +3 -2
- package/dist/providers.mjs +10 -9
- package/dist/{transform-messages-eb6lxDLB.mjs → shared-CdjNZd35.mjs} +273 -161
- package/dist/{src-CXno1H5g.mjs → src-QkygScBs.mjs} +23 -4
- package/dist/stream-first-event-timeout-C3OgBjIk.mjs +12294 -0
- package/dist/stream-first-event-timeout-DvDeSucC.d.mts +29 -0
- package/dist/transport-stream-shared-BbMELSI4.mjs +297 -0
- package/dist/transports.d.mts +593 -0
- package/dist/transports.mjs +4069 -0
- package/dist/{types-CYORveZ7.d.mts → types-bzp5k29J.d.mts} +8 -0
- package/dist/types.d.mts +5 -5
- package/dist/types.mjs +2 -2
- package/dist/{validation-BX8euiDv.d.mts → validation-B-j7cOYp.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/package.json +36 -11
- package/dist/azure-openai-responses-client-compat-C7K7QfUE.mjs +0 -62
- package/dist/github-copilot-headers-BsH5cqGj.mjs +0 -48
- package/dist/host-4t713IeR.mjs +0 -37
- package/dist/model-utils-1GiZ2_rr.mjs +0 -64
- package/dist/openai-responses-ClspWt4I.mjs +0 -136
- package/dist/openai-tool-projection-WHf2nuOI.mjs +0 -200
- package/dist/reasoning-tag-text-partitioner-BlVe67g6.mjs +0 -400
- package/dist/stream-first-event-timeout-RjWszj8c.mjs +0 -106
- package/npm-shrinkwrap.json +0 -645
package/README.md
CHANGED
|
@@ -14,15 +14,16 @@ registerBuiltInApiProviders(runtime.registry);
|
|
|
14
14
|
|
|
15
15
|
Provider-neutral contracts, validation, diagnostics, and event streams are
|
|
16
16
|
available from the package root and focused subpaths such as
|
|
17
|
-
`@openclaw/ai/event-stream
|
|
18
|
-
runtime package is required.
|
|
17
|
+
`@openclaw/ai/event-stream`, `@openclaw/ai/transports`, and
|
|
18
|
+
`@openclaw/ai/validation`. No second OpenClaw runtime package is required.
|
|
19
19
|
|
|
20
20
|
Provider ids, credentials, model catalogs, retries, and failover remain
|
|
21
21
|
application concerns. OpenClaw supplies those policies around this package.
|
|
22
22
|
Host policy (request fetch guarding, secret redaction, strict-tool defaults,
|
|
23
|
-
diagnostics logging) can be injected with
|
|
24
|
-
defaults are inert.
|
|
23
|
+
provider plugin hooks, and diagnostics logging) can be injected with
|
|
24
|
+
`configureAiTransportHost`; the defaults are inert.
|
|
25
25
|
|
|
26
|
-
`@openclaw/ai/internal
|
|
26
|
+
The explicit `@openclaw/ai/internal/anthropic`, `openai`, `retry-after`,
|
|
27
|
+
`runtime`, and `shared` subpaths exist for the OpenClaw application itself.
|
|
27
28
|
They carry no semver guarantee and can change or disappear in any release; do
|
|
28
29
|
not depend on them outside OpenClaw.
|
|
@@ -1,17 +1,129 @@
|
|
|
1
|
-
import { n as getEnvApiKey, r as __exportAll } from "./env-api-keys-
|
|
2
|
-
import {
|
|
1
|
+
import { n as getEnvApiKey, r as __exportAll } from "./env-api-keys-DrgeBuva.mjs";
|
|
2
|
+
import { d as resolveClaudeSonnet5ModelIdentity, g as supportsClaudeNativeXhighEffort, h as supportsClaudeNativeMaxEffort, l as resolveClaudeNativeThinkingLevelMap, o as resolveClaudeFable5ModelIdentity, p as supportsClaudeAdaptiveThinking, s as resolveClaudeModelIdentity, u as resolveClaudeOpus5ModelIdentity } from "./src-QkygScBs.mjs";
|
|
3
3
|
import { t as AssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
|
|
4
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-
|
|
5
|
-
import {
|
|
4
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-XYGZcgO8.mjs";
|
|
5
|
+
import { A as buildBaseOptions, C as extractToolResultBlockText, E as isImageWithMediaPayload, O as isRecord, S as describeToolResultMediaPlaceholder, _ as usesClaudeStreamingRefusalContract, a as splitSystemPromptCacheBoundary, d as applyClaudeRequestContract, g as usesClaudeFable5MessagesContract, j as clampMaxTokensToModel, k as adjustMaxTokensForThinking, l as sortPromptCacheToolsByName, m as requiresClaudeAdaptiveThinking, o as stripSystemPromptCacheBoundary, p as prepareClaudeNoPrefillRequestContext, u as transformMessages, w as extractToolResultText } from "./shared-CdjNZd35.mjs";
|
|
6
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-DT5o51ur.mjs";
|
|
7
|
+
import { c as calculateCost, l as clampThinkingLevel } from "./number-coercion-DvG7SNMg.mjs";
|
|
8
|
+
import { d as transportAbortError } from "./transport-stream-shared-BbMELSI4.mjs";
|
|
6
9
|
import { r as createDeferredEventBuffer, t as notifyLlmRequestActivity } from "./llm-request-activity-CehVkZP-.mjs";
|
|
7
10
|
import { t as headersToRecord } from "./headers-B_e4-1J0.mjs";
|
|
8
11
|
import { n as parseStreamingJson, t as parseJsonWithRepair } from "./json-parse-BvXNt1-7.mjs";
|
|
9
|
-
import { t as
|
|
10
|
-
import {
|
|
11
|
-
import { t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-BwNu3nDi.mjs";
|
|
12
|
-
import { a as resolveCacheRetention, i as resolveCloudflareBaseUrl, n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-BsH5cqGj.mjs";
|
|
12
|
+
import { t as formatProviderError } from "./provider-error-apVOZI6G.mjs";
|
|
13
|
+
import { a as resolveCacheRetention, i as resolveCloudflareBaseUrl, n as hasCopilotVisionInput, o as projectRuntimeToolInputSchema, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-BCoBNmL7.mjs";
|
|
13
14
|
import Anthropic from "@anthropic-ai/sdk";
|
|
14
15
|
import { Stream } from "@anthropic-ai/sdk/core/streaming.js";
|
|
16
|
+
//#region packages/media-core/src/base64.ts
|
|
17
|
+
/** Estimates decoded bytes without allocating a cleaned copy of the base64 payload. */
|
|
18
|
+
function estimateBase64DecodedBytes(base64) {
|
|
19
|
+
let effectiveLen = 0;
|
|
20
|
+
for (let i = 0; i < base64.length; i += 1) {
|
|
21
|
+
if (base64.charCodeAt(i) <= 32) continue;
|
|
22
|
+
effectiveLen += 1;
|
|
23
|
+
}
|
|
24
|
+
if (effectiveLen === 0) return 0;
|
|
25
|
+
let padding = 0;
|
|
26
|
+
let end = base64.length - 1;
|
|
27
|
+
while (end >= 0 && base64.charCodeAt(end) <= 32) end -= 1;
|
|
28
|
+
if (end >= 0 && base64[end] === "=") {
|
|
29
|
+
padding = 1;
|
|
30
|
+
end -= 1;
|
|
31
|
+
while (end >= 0 && base64.charCodeAt(end) <= 32) end -= 1;
|
|
32
|
+
if (end >= 0 && base64[end] === "=") padding = 2;
|
|
33
|
+
}
|
|
34
|
+
const estimated = Math.floor(effectiveLen * 3 / 4) - padding;
|
|
35
|
+
return Math.max(0, estimated);
|
|
36
|
+
}
|
|
37
|
+
const CANONICALIZE_BASE64_CHUNK_SIZE = 8192;
|
|
38
|
+
function isBase64DataChar(code) {
|
|
39
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 43 || code === 47;
|
|
40
|
+
}
|
|
41
|
+
function base64DataValue(code) {
|
|
42
|
+
if (code >= 65 && code <= 90) return code - 65;
|
|
43
|
+
if (code >= 97 && code <= 122) return code - 97 + 26;
|
|
44
|
+
if (code >= 48 && code <= 57) return code - 48 + 52;
|
|
45
|
+
return code === 43 ? 62 : 63;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Normalizes and validates a base64 string, returning canonical no-whitespace
|
|
49
|
+
* base64 only when the input has valid alphabet, padding, and length.
|
|
50
|
+
*/
|
|
51
|
+
function canonicalizeBase64(base64) {
|
|
52
|
+
const chunks = [];
|
|
53
|
+
let current = "";
|
|
54
|
+
let cleanedLength = 0;
|
|
55
|
+
let padding = 0;
|
|
56
|
+
let sawPadding = false;
|
|
57
|
+
let lastDataCode = 0;
|
|
58
|
+
const append = (char) => {
|
|
59
|
+
current += char;
|
|
60
|
+
cleanedLength += 1;
|
|
61
|
+
if (current.length >= CANONICALIZE_BASE64_CHUNK_SIZE) {
|
|
62
|
+
chunks.push(current);
|
|
63
|
+
current = "";
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
for (let i = 0; i < base64.length; i += 1) {
|
|
67
|
+
const code = base64.charCodeAt(i);
|
|
68
|
+
if (code <= 32) continue;
|
|
69
|
+
if (code === 61) {
|
|
70
|
+
padding += 1;
|
|
71
|
+
if (padding > 2) return;
|
|
72
|
+
sawPadding = true;
|
|
73
|
+
append("=");
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (sawPadding || !isBase64DataChar(code)) return;
|
|
77
|
+
lastDataCode = code;
|
|
78
|
+
append(base64[i] ?? "");
|
|
79
|
+
}
|
|
80
|
+
if (cleanedLength === 0) return;
|
|
81
|
+
const remainder = cleanedLength % 4;
|
|
82
|
+
if (remainder !== 0) {
|
|
83
|
+
if (sawPadding || remainder === 1) return;
|
|
84
|
+
current += "=".repeat(4 - remainder);
|
|
85
|
+
}
|
|
86
|
+
const effectivePadding = remainder === 0 ? padding : 4 - remainder;
|
|
87
|
+
const padBitMask = effectivePadding === 2 ? 15 : effectivePadding === 1 ? 3 : 0;
|
|
88
|
+
if (padBitMask !== 0 && (base64DataValue(lastDataCode) & padBitMask) !== 0) return;
|
|
89
|
+
if (current) chunks.push(current);
|
|
90
|
+
return chunks.join("");
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region packages/ai/src/internal/anthropic-inline-images.ts
|
|
94
|
+
const ANTHROPIC_IMAGE_MEDIA_TYPE_SET = /* @__PURE__ */ new Set([
|
|
95
|
+
"image/jpeg",
|
|
96
|
+
"image/png",
|
|
97
|
+
"image/gif",
|
|
98
|
+
"image/webp"
|
|
99
|
+
]);
|
|
100
|
+
const ANTHROPIC_INLINE_IMAGES_DECODE_SAFETY_BYTES = 64 * 1024 * 1024;
|
|
101
|
+
function createAnthropicInlineImageBudget() {
|
|
102
|
+
return { totalBytes: 0 };
|
|
103
|
+
}
|
|
104
|
+
function resolveAnthropicImageMediaType(value) {
|
|
105
|
+
if (ANTHROPIC_IMAGE_MEDIA_TYPE_SET.has(value)) return value;
|
|
106
|
+
throw new Error(`Unsupported Anthropic image media type after normalization: ${value}`);
|
|
107
|
+
}
|
|
108
|
+
async function normalizeAnthropicInlineContent(content, budget) {
|
|
109
|
+
if (!content.some((block) => block.type === "image")) return content.filter((block) => block.type === "text");
|
|
110
|
+
const inputBytes = content.reduce((total, block) => block.type === "image" ? total + estimateBase64DecodedBytes(block.data) : total, 0);
|
|
111
|
+
if (budget.totalBytes + inputBytes > ANTHROPIC_INLINE_IMAGES_DECODE_SAFETY_BYTES) throw new Error("Anthropic inline images exceed the 64 MB aggregate decoded safety limit.");
|
|
112
|
+
const normalized = [];
|
|
113
|
+
for (const block of content) {
|
|
114
|
+
if (block.type !== "image") {
|
|
115
|
+
normalized.push(block);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const normalizedBlocks = await getAiTransportHost().normalizeAnthropicInlineContentBlocks([block]);
|
|
119
|
+
const outputBytes = normalizedBlocks.reduce((total, normalizedBlock) => normalizedBlock.type === "image" ? total + estimateBase64DecodedBytes(normalizedBlock.data) : total, 0);
|
|
120
|
+
if (budget.totalBytes + outputBytes > ANTHROPIC_INLINE_IMAGES_DECODE_SAFETY_BYTES) throw new Error("Anthropic inline images exceed the 64 MB aggregate decoded safety limit.");
|
|
121
|
+
budget.totalBytes += outputBytes;
|
|
122
|
+
normalized.push(...normalizedBlocks);
|
|
123
|
+
}
|
|
124
|
+
return normalized;
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
15
127
|
//#region packages/ai/src/providers/anthropic-auth-headers.ts
|
|
16
128
|
function usesFoundryBearerAuth(model) {
|
|
17
129
|
return model.provider === "microsoft-foundry" && (model.authHeader === true || hasBearerAuthorizationHeader(model.headers));
|
|
@@ -66,16 +178,34 @@ function applyAnthropicRefusal(output, stopDetails, provider) {
|
|
|
66
178
|
//#endregion
|
|
67
179
|
//#region packages/ai/src/providers/anthropic-server-fallback.ts
|
|
68
180
|
/** Anthropic beta that re-serves safety refusals on an allowed fallback model. */
|
|
69
|
-
const ANTHROPIC_SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-
|
|
70
|
-
|
|
71
|
-
const
|
|
181
|
+
const ANTHROPIC_SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-07-01";
|
|
182
|
+
/** Let Anthropic select the recommended model for each refusal category. */
|
|
183
|
+
const ANTHROPIC_SERVER_SIDE_FALLBACKS = "default";
|
|
184
|
+
const CLAUDE_OPUS_FALLBACK_MODEL_COST = {
|
|
72
185
|
input: 5,
|
|
73
186
|
output: 25,
|
|
74
187
|
cacheRead: .5,
|
|
75
188
|
cacheWrite: 6.25
|
|
76
189
|
};
|
|
77
|
-
function
|
|
78
|
-
|
|
190
|
+
function resolveFallbackModelIdentity(modelId) {
|
|
191
|
+
if (!modelId?.trim()) return null;
|
|
192
|
+
const ref = { id: modelId };
|
|
193
|
+
const normalized = resolveClaudeModelIdentity(ref);
|
|
194
|
+
if (normalized === "opus" || normalized === "opus-5" || resolveClaudeOpus5ModelIdentity(ref)) return "claude-opus-5";
|
|
195
|
+
if (resolveClaudeFable5ModelIdentity(ref)) return "claude-fable-5";
|
|
196
|
+
if (/^claude-opus-4-8(?=$|[^a-z0-9])/.test(normalized)) return "claude-opus-4-8";
|
|
197
|
+
return normalized || null;
|
|
198
|
+
}
|
|
199
|
+
function isClaudeOpusFallbackModel(modelId) {
|
|
200
|
+
return modelId === "claude-opus-5" || modelId === "claude-opus-4-8";
|
|
201
|
+
}
|
|
202
|
+
/** Resolve billed rates from the serving model reported by Anthropic's fallback stream. */
|
|
203
|
+
function resolveAnthropicFallbackServingModelCost(params) {
|
|
204
|
+
const requestedModelId = resolveFallbackModelIdentity(params.requestedModelId);
|
|
205
|
+
const servingModelId = resolveFallbackModelIdentity(params.servingModelId);
|
|
206
|
+
if (!servingModelId || servingModelId === requestedModelId || !isClaudeOpusFallbackModel(servingModelId)) return params.requestedCost;
|
|
207
|
+
if (requestedModelId && isClaudeOpusFallbackModel(requestedModelId)) return params.requestedCost;
|
|
208
|
+
return CLAUDE_OPUS_FALLBACK_MODEL_COST;
|
|
79
209
|
}
|
|
80
210
|
function readBoundaryModel(value) {
|
|
81
211
|
if (!value || typeof value !== "object") return null;
|
|
@@ -259,7 +389,7 @@ function projectAnthropicTools(tools, toWireName) {
|
|
|
259
389
|
return {
|
|
260
390
|
inputToolCount: tools.length,
|
|
261
391
|
unavailableOriginalNames,
|
|
262
|
-
tools: projectedTools
|
|
392
|
+
tools: sortPromptCacheToolsByName(projectedTools)
|
|
263
393
|
};
|
|
264
394
|
}
|
|
265
395
|
/** Keeps forced Anthropic tool choices aligned with the projected wire names. */
|
|
@@ -381,7 +511,7 @@ const toClaudeCodeName = (name) => ccToolLookup.get(name.toLowerCase()) ?? name;
|
|
|
381
511
|
/**
|
|
382
512
|
* Convert content blocks to Anthropic API format
|
|
383
513
|
*/
|
|
384
|
-
function convertContentBlocks(content, isError) {
|
|
514
|
+
async function convertContentBlocks(content, isError, imageBudget) {
|
|
385
515
|
const text = extractToolResultText(content);
|
|
386
516
|
const mediaPlaceholder = describeToolResultMediaPlaceholder(content);
|
|
387
517
|
if (!content.some(isImageWithMediaPayload)) {
|
|
@@ -402,12 +532,18 @@ function convertContentBlocks(content, isError) {
|
|
|
402
532
|
hasTextBlock = true;
|
|
403
533
|
}
|
|
404
534
|
if (!isImageWithMediaPayload(record)) continue;
|
|
535
|
+
const [normalizedImage] = await normalizeAnthropicInlineContent([{
|
|
536
|
+
type: "image",
|
|
537
|
+
data: typeof record.data === "string" ? record.data : "",
|
|
538
|
+
mimeType: typeof record.mimeType === "string" ? record.mimeType : "image/jpeg"
|
|
539
|
+
}], imageBudget);
|
|
540
|
+
if (normalizedImage?.type !== "image") continue;
|
|
405
541
|
blocks.push({
|
|
406
542
|
type: "image",
|
|
407
543
|
source: {
|
|
408
544
|
type: "base64",
|
|
409
|
-
media_type:
|
|
410
|
-
data:
|
|
545
|
+
media_type: resolveAnthropicImageMediaType(normalizedImage.mimeType),
|
|
546
|
+
data: normalizedImage.data
|
|
411
547
|
}
|
|
412
548
|
});
|
|
413
549
|
}
|
|
@@ -465,7 +601,7 @@ async function* iterateAnthropicEvents(response, requireMessageStop = false) {
|
|
|
465
601
|
}
|
|
466
602
|
const streamAnthropic = (model, context, options) => {
|
|
467
603
|
const stream = new AssistantMessageEventStream();
|
|
468
|
-
const requestContext =
|
|
604
|
+
const requestContext = prepareClaudeNoPrefillRequestContext(model, context);
|
|
469
605
|
const requestOptions = normalizeAnthropicThinkingOptions(model, options);
|
|
470
606
|
(async () => {
|
|
471
607
|
const output = {
|
|
@@ -518,7 +654,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
518
654
|
isOAuth = created.isOAuthToken;
|
|
519
655
|
serverSideFallback = created.serverSideFallback;
|
|
520
656
|
}
|
|
521
|
-
const builtParams = buildParams(model, requestContext, isOAuth, requestOptions, serverSideFallback);
|
|
657
|
+
const builtParams = await buildParams(model, requestContext, isOAuth, requestOptions, serverSideFallback);
|
|
522
658
|
let params = builtParams.params;
|
|
523
659
|
const toolProjection = builtParams.toolProjection;
|
|
524
660
|
const nextParams = await requestOptions?.onPayload?.(params, model);
|
|
@@ -578,7 +714,11 @@ const streamAnthropic = (model, context, options) => {
|
|
|
578
714
|
});
|
|
579
715
|
costModel = {
|
|
580
716
|
...model,
|
|
581
|
-
cost:
|
|
717
|
+
cost: resolveAnthropicFallbackServingModelCost({
|
|
718
|
+
requestedModelId: model.id,
|
|
719
|
+
servingModelId: fallbackBoundary.toModel,
|
|
720
|
+
requestedCost: model.cost
|
|
721
|
+
})
|
|
582
722
|
};
|
|
583
723
|
calculateCost(costModel, output.usage);
|
|
584
724
|
eventSink.push({
|
|
@@ -773,7 +913,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
773
913
|
}
|
|
774
914
|
calculateCost(costModel, output.usage);
|
|
775
915
|
}
|
|
776
|
-
if (requestOptions?.signal?.aborted) throw
|
|
916
|
+
if (requestOptions?.signal?.aborted) throw transportAbortError(requestOptions.signal);
|
|
777
917
|
if (output.stopReason === "aborted" || output.stopReason === "error") throw new Error(output.errorMessage ?? "An unknown error occurred");
|
|
778
918
|
refusalBuffer?.flush();
|
|
779
919
|
stream.push({
|
|
@@ -792,7 +932,7 @@ const streamAnthropic = (model, context, options) => {
|
|
|
792
932
|
output.content = [];
|
|
793
933
|
}
|
|
794
934
|
output.stopReason = requestOptions?.signal?.aborted ? "aborted" : "error";
|
|
795
|
-
output.errorMessage =
|
|
935
|
+
output.errorMessage = formatProviderError(error);
|
|
796
936
|
stream.push({
|
|
797
937
|
type: "error",
|
|
798
938
|
reason: output.stopReason,
|
|
@@ -868,7 +1008,7 @@ const streamSimpleAnthropic = (model, context, options) => {
|
|
|
868
1008
|
thinkingEnabled: false
|
|
869
1009
|
});
|
|
870
1010
|
const reasoning = options?.reasoning === "off" ? mandatoryAdaptiveThinking ? "low" : "high" : options?.reasoning;
|
|
871
|
-
if (resolveClaudeSonnet5ModelIdentity(model)) return streamAnthropic(model, context, {
|
|
1011
|
+
if (resolveClaudeOpus5ModelIdentity(model) || resolveClaudeSonnet5ModelIdentity(model)) return streamAnthropic(model, context, {
|
|
872
1012
|
...base,
|
|
873
1013
|
thinkingEnabled: true,
|
|
874
1014
|
effort: mapThinkingLevelToEffort(model, reasoning ?? "high")
|
|
@@ -913,7 +1053,7 @@ function isAnthropicPublicEndpoint(baseUrl) {
|
|
|
913
1053
|
* identity) requests are excluded until the beta is verified there.
|
|
914
1054
|
*/
|
|
915
1055
|
function supportsAnthropicServerSideFallback(model) {
|
|
916
|
-
if (!usesClaudeFable5MessagesContract(model) || model.provider !== "anthropic") return false;
|
|
1056
|
+
if (!usesClaudeFable5MessagesContract(model) && resolveClaudeOpus5ModelIdentity(model) === void 0 || model.provider !== "anthropic") return false;
|
|
917
1057
|
return isAnthropicPublicEndpoint(model.baseUrl);
|
|
918
1058
|
}
|
|
919
1059
|
function createClient(model, apiKey, thinkingEnabled, interleavedThinking, useFineGrainedToolStreamingBeta, optionsHeaders, dynamicHeaders, sessionId) {
|
|
@@ -1017,7 +1157,7 @@ function createClient(model, apiKey, thinkingEnabled, interleavedThinking, useFi
|
|
|
1017
1157
|
serverSideFallback
|
|
1018
1158
|
};
|
|
1019
1159
|
}
|
|
1020
|
-
function buildParams(model, context, isOAuthTokenResult, options, serverSideFallback = false) {
|
|
1160
|
+
async function buildParams(model, context, isOAuthTokenResult, options, serverSideFallback = false) {
|
|
1021
1161
|
const mandatoryAdaptiveThinking = requiresClaudeAdaptiveThinking(model);
|
|
1022
1162
|
const replayThinkingEnabled = mandatoryAdaptiveThinking || options?.thinkingEnabled === true;
|
|
1023
1163
|
const { cacheControl } = getCacheControl(model, options?.cacheRetention);
|
|
@@ -1031,12 +1171,12 @@ function buildParams(model, context, isOAuthTokenResult, options, serverSideFall
|
|
|
1031
1171
|
const messageCacheControlLimit = Math.max(0, ANTHROPIC_CACHE_CONTROL_LIMIT - systemCacheControlCount - toolCacheControlCount);
|
|
1032
1172
|
const params = {
|
|
1033
1173
|
model: model.id,
|
|
1034
|
-
messages: convertMessages(context.messages, model, isOAuthTokenResult, cacheControl, messageCacheControlLimit, replayThinkingEnabled, compat.allowEmptySignature),
|
|
1174
|
+
messages: await convertMessages(context.messages, model, isOAuthTokenResult, cacheControl, messageCacheControlLimit, replayThinkingEnabled, compat.allowEmptySignature),
|
|
1035
1175
|
max_tokens: options?.maxTokens ?? model.maxTokens,
|
|
1036
1176
|
stream: true
|
|
1037
1177
|
};
|
|
1038
1178
|
if (system) params.system = system;
|
|
1039
|
-
if (serverSideFallback) params.fallbacks =
|
|
1179
|
+
if (serverSideFallback) params.fallbacks = ANTHROPIC_SERVER_SIDE_FALLBACKS;
|
|
1040
1180
|
if (options?.temperature !== void 0 && !options?.thinkingEnabled && !supportsNativeXhighEffort(model)) params.temperature = options.temperature;
|
|
1041
1181
|
if (options?.stop !== void 0 && options.stop.length > 0) params.stop_sequences = options.stop;
|
|
1042
1182
|
if (tools && tools.length > 0) params.tools = tools;
|
|
@@ -1074,8 +1214,9 @@ function buildParams(model, context, isOAuthTokenResult, options, serverSideFall
|
|
|
1074
1214
|
function normalizeToolCallId(id) {
|
|
1075
1215
|
return id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
|
|
1076
1216
|
}
|
|
1077
|
-
function convertMessages(messages, model, isOAuthTokenValue, cacheControl, messageCacheControlLimit = 4, replayThinkingEnabled = true, allowEmptySignature = false) {
|
|
1217
|
+
async function convertMessages(messages, model, isOAuthTokenValue, cacheControl, messageCacheControlLimit = 4, replayThinkingEnabled = true, allowEmptySignature = false) {
|
|
1078
1218
|
const params = [];
|
|
1219
|
+
const imageBudget = createAnthropicInlineImageBudget();
|
|
1079
1220
|
const cacheBreakpointOptOutParamIndexes = /* @__PURE__ */ new Set();
|
|
1080
1221
|
const transformedMessages = transformMessages(messages, model, normalizeToolCallId);
|
|
1081
1222
|
const activeToolTurnAssistantIndex = replayThinkingEnabled ? -1 : findActiveAnthropicToolTurnAssistantIndex(transformedMessages);
|
|
@@ -1093,7 +1234,7 @@ function convertMessages(messages, model, isOAuthTokenValue, cacheControl, messa
|
|
|
1093
1234
|
});
|
|
1094
1235
|
}
|
|
1095
1236
|
} else {
|
|
1096
|
-
const filteredBlocks = msg.content.map((item) => {
|
|
1237
|
+
const filteredBlocks = (await normalizeAnthropicInlineContent(msg.content, imageBudget)).map((item) => {
|
|
1097
1238
|
if (item.type === "text") return {
|
|
1098
1239
|
type: "text",
|
|
1099
1240
|
text: sanitizeSurrogates(item.text)
|
|
@@ -1102,7 +1243,7 @@ function convertMessages(messages, model, isOAuthTokenValue, cacheControl, messa
|
|
|
1102
1243
|
type: "image",
|
|
1103
1244
|
source: {
|
|
1104
1245
|
type: "base64",
|
|
1105
|
-
media_type: item.mimeType,
|
|
1246
|
+
media_type: resolveAnthropicImageMediaType(item.mimeType),
|
|
1106
1247
|
data: item.data
|
|
1107
1248
|
}
|
|
1108
1249
|
};
|
|
@@ -1174,7 +1315,7 @@ function convertMessages(messages, model, isOAuthTokenValue, cacheControl, messa
|
|
|
1174
1315
|
toolResults.push({
|
|
1175
1316
|
type: "tool_result",
|
|
1176
1317
|
tool_use_id: msg.toolCallId,
|
|
1177
|
-
content: convertContentBlocks(msg.content, msg.isError),
|
|
1318
|
+
content: await convertContentBlocks(msg.content, msg.isError, imageBudget),
|
|
1178
1319
|
is_error: msg.isError
|
|
1179
1320
|
});
|
|
1180
1321
|
let j = i + 1;
|
|
@@ -1184,7 +1325,7 @@ function convertMessages(messages, model, isOAuthTokenValue, cacheControl, messa
|
|
|
1184
1325
|
toolResults.push({
|
|
1185
1326
|
type: "tool_result",
|
|
1186
1327
|
tool_use_id: nextMsg.toolCallId,
|
|
1187
|
-
content: convertContentBlocks(nextMsg.content, nextMsg.isError),
|
|
1328
|
+
content: await convertContentBlocks(nextMsg.content, nextMsg.isError, imageBudget),
|
|
1188
1329
|
is_error: nextMsg.isError
|
|
1189
1330
|
});
|
|
1190
1331
|
j++;
|
|
@@ -1321,4 +1462,4 @@ function mapStopReason(reason) {
|
|
|
1321
1462
|
}
|
|
1322
1463
|
}
|
|
1323
1464
|
//#endregion
|
|
1324
|
-
export {
|
|
1465
|
+
export { normalizeAnthropicInlineContent as C, createAnthropicInlineImageBudget as S, canonicalizeBase64 as T, readAnthropicFallbackBoundary as _, readAnthropicPromptUsageSnapshot as a, omitFoundryBearerCredentialHeaders as b, projectAnthropicTools as c, ANTHROPIC_OMITTED_REASONING_TEXT as d, findActiveAnthropicToolTurnAssistantIndex as f, applyAnthropicFallbackBoundary as g, CLAUDE_OPUS_FALLBACK_MODEL_COST as h, readAnthropicCacheWriteUsage as i, reconcileAnthropicToolChoice as l, ANTHROPIC_SERVER_SIDE_FALLBACK_BETA as m, streamAnthropic as n, readAnthropicUsageTokenCount as o, ANTHROPIC_SERVER_SIDE_FALLBACKS as p, streamSimpleAnthropic as r, readLastAnthropicIterationUsage as s, anthropic_exports as t, resolveOriginalAnthropicToolName as u, resolveAnthropicFallbackServingModelCost as v, resolveAnthropicImageMediaType as w, usesFoundryBearerAuth as x, applyAnthropicRefusal as y };
|
|
@@ -47,6 +47,26 @@ declare const CLAUDE_SONNET_5_THINKING_PROFILE: {
|
|
|
47
47
|
}];
|
|
48
48
|
readonly defaultLevel: "high";
|
|
49
49
|
};
|
|
50
|
+
declare const CLAUDE_OPUS_5_THINKING_PROFILE: {
|
|
51
|
+
readonly levels: readonly [{
|
|
52
|
+
readonly id: "off";
|
|
53
|
+
}, {
|
|
54
|
+
readonly id: "minimal";
|
|
55
|
+
}, {
|
|
56
|
+
readonly id: "low";
|
|
57
|
+
}, {
|
|
58
|
+
readonly id: "medium";
|
|
59
|
+
}, {
|
|
60
|
+
readonly id: "high";
|
|
61
|
+
}, {
|
|
62
|
+
readonly id: "xhigh";
|
|
63
|
+
}, {
|
|
64
|
+
readonly id: "adaptive";
|
|
65
|
+
}, {
|
|
66
|
+
readonly id: "max";
|
|
67
|
+
}];
|
|
68
|
+
readonly defaultLevel: "high";
|
|
69
|
+
};
|
|
50
70
|
/** Resolve the canonical normalized Claude model id for one runtime model ref. */
|
|
51
71
|
declare function resolveClaudeModelIdentity(ref: ClaudeModelRef): string;
|
|
52
72
|
/** Resolve Claude Fable 5 through direct ids, cloud ids, or deployment metadata. */
|
|
@@ -57,8 +77,14 @@ declare function resolveClaudeMythos5ModelIdentity(ref: ClaudeModelRef): string
|
|
|
57
77
|
declare function requiresClaudeMandatoryAdaptiveThinking(ref: ClaudeModelRef): boolean;
|
|
58
78
|
/** Resolve Claude Sonnet 5 through direct ids, cloud ids, or deployment metadata. */
|
|
59
79
|
declare function resolveClaudeSonnet5ModelIdentity(ref: ClaudeModelRef): string | undefined;
|
|
80
|
+
/** Resolve Claude Opus 5 through aliases, direct ids, cloud ids, or deployment metadata. */
|
|
81
|
+
declare function resolveClaudeOpus5ModelIdentity(ref: ClaudeModelRef): string | undefined;
|
|
60
82
|
/** Return whether a Claude model supports adaptive thinking. */
|
|
61
83
|
declare function supportsClaudeAdaptiveThinking(ref: ClaudeModelRef): boolean;
|
|
84
|
+
/** Return whether a Claude model has a native 1M-token context window. */
|
|
85
|
+
declare function supportsClaude1MContext(ref: ClaudeModelRef): boolean;
|
|
86
|
+
/** Return whether a Claude model supports Anthropic's native fast mode. */
|
|
87
|
+
declare function supportsClaudeFastMode(ref: ClaudeModelRef): boolean;
|
|
62
88
|
/** Return whether a Claude model supports native max effort. */
|
|
63
89
|
declare function supportsClaudeNativeMaxEffort(ref: ClaudeModelRef): boolean;
|
|
64
90
|
/** Return whether a Claude model supports native xhigh effort. */
|
|
@@ -71,4 +97,4 @@ declare function requiresClaudeDefaultSampling(ref: ClaudeModelRef): boolean;
|
|
|
71
97
|
*/
|
|
72
98
|
declare function resolveClaudeNativeThinkingLevelMap(ref: ClaudeEffortModelRef): Record<string, string | null | undefined> | undefined;
|
|
73
99
|
//#endregion
|
|
74
|
-
export {
|
|
100
|
+
export { requiresClaudeMandatoryAdaptiveThinking as a, resolveClaudeMythos5ModelIdentity as c, resolveClaudeSonnet5ModelIdentity as d, supportsClaude1MContext as f, supportsClaudeNativeXhighEffort as g, supportsClaudeNativeMaxEffort as h, requiresClaudeDefaultSampling as i, resolveClaudeNativeThinkingLevelMap as l, supportsClaudeFastMode as m, CLAUDE_OPUS_5_THINKING_PROFILE as n, resolveClaudeFable5ModelIdentity as o, supportsClaudeAdaptiveThinking as p, CLAUDE_SONNET_5_THINKING_PROFILE as r, resolveClaudeModelIdentity as s, CLAUDE_FABLE_5_THINKING_PROFILE as t, resolveClaudeOpus5ModelIdentity as u };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { E as Model, F as SimpleStreamOptions, R as StreamFunction, n as Api, o as AssistantMessageEventStreamContract, u as Context, z as StreamOptions } from "./types-
|
|
2
|
-
|
|
1
|
+
import { E as Model, F as SimpleStreamOptions, R as StreamFunction, n as Api, o as AssistantMessageEventStreamContract, u as Context, z as StreamOptions } from "./types-bzp5k29J.mjs";
|
|
3
2
|
//#region packages/ai/src/api-registry.d.ts
|
|
4
3
|
/** Runtime stream adapter signature stored in the API provider registry. */
|
|
5
4
|
type ApiStreamFunction = (model: Model, context: Context, options?: StreamOptions) => AssistantMessageEventStreamContract;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { n as getEnvApiKey } from "./env-api-keys-
|
|
1
|
+
import { n as getEnvApiKey } from "./env-api-keys-DrgeBuva.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
|
|
3
|
-
import { n as getAiTransportHost } from "./host-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { i as
|
|
7
|
-
import { a as clampOpenAIPromptCacheKey } from "./openai-tool-projection-WHf2nuOI.mjs";
|
|
3
|
+
import { n as getAiTransportHost } from "./host-XYGZcgO8.mjs";
|
|
4
|
+
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
5
|
+
import { A as buildBaseOptions } from "./shared-CdjNZd35.mjs";
|
|
6
|
+
import { a as convertResponsesMessages, c as runResponsesStreamLifecycle, i as applyCommonResponsesParams, o as createResponsesAssistantOutput, s as resolveResponsesReasoningEffort, vt as isOpenAICompatibleAzureResponsesBaseUrl, xt as resolveAzureDeploymentNameFromMap } from "./openai-D3PD6PE-.mjs";
|
|
8
7
|
import OpenAI, { AzureOpenAI } from "openai";
|
|
9
8
|
//#region packages/ai/src/providers/azure-openai-responses.ts
|
|
10
9
|
const DEFAULT_AZURE_API_VERSION = "v1";
|
|
@@ -94,11 +93,8 @@ function resolveAzureConfig(model, options) {
|
|
|
94
93
|
};
|
|
95
94
|
}
|
|
96
95
|
function createClient(model, apiKeyInput, options) {
|
|
97
|
-
|
|
98
|
-
if (!apiKey)
|
|
99
|
-
if (!process.env.AZURE_OPENAI_API_KEY) throw new Error("Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.");
|
|
100
|
-
apiKey = process.env.AZURE_OPENAI_API_KEY;
|
|
101
|
-
}
|
|
96
|
+
const apiKey = apiKeyInput.trim();
|
|
97
|
+
if (!apiKey) throw new Error("Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.");
|
|
102
98
|
const headers = { ...model.headers };
|
|
103
99
|
if (options?.headers) Object.assign(headers, options.headers);
|
|
104
100
|
const { baseUrl, apiVersion } = resolveAzureConfig(model, options);
|
|
@@ -82,7 +82,7 @@ function getProcEnv(key) {
|
|
|
82
82
|
return procEnvCache.get(key);
|
|
83
83
|
}
|
|
84
84
|
function getEnvValue(key) {
|
|
85
|
-
return getProcessEnv()?.[key] || getProcEnv(key);
|
|
85
|
+
return (getProcessEnv()?.[key] || getProcEnv(key))?.trim() || void 0;
|
|
86
86
|
}
|
|
87
87
|
let cachedVertexAdcCredentialsExists = null;
|
|
88
88
|
function hasVertexAdcCredentials() {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region packages/normalization-core/src/error-coercion.ts
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes an unknown thrown value into an Error. Non-Error objects become
|
|
4
|
+
* the `cause` and have their enumerable fields copied so structured details
|
|
5
|
+
* (codes, statuses) survive the coercion.
|
|
6
|
+
*/
|
|
7
|
+
function toErrorObject(value, fallbackMessage) {
|
|
8
|
+
if (value instanceof Error) return value;
|
|
9
|
+
if (typeof value === "string") return new Error(value);
|
|
10
|
+
const error = new Error(fallbackMessage, { cause: value });
|
|
11
|
+
if (typeof value === "object" && value !== null || typeof value === "function") Object.assign(error, value);
|
|
12
|
+
return error;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { toErrorObject as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AssistantMessageEvent, i as AssistantMessage, o as AssistantMessageEventStreamContract } from "./types-
|
|
1
|
+
import { a as AssistantMessageEvent, i as AssistantMessage, o as AssistantMessageEventStreamContract } from "./types-bzp5k29J.mjs";
|
|
2
2
|
|
|
3
3
|
//#region packages/llm-core/src/utils/event-stream.d.ts
|
|
4
4
|
/** Generic async-iterable event stream with a separately awaited final result. */
|
package/dist/event-stream.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
1
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-YjaPW20U.mjs";
|
|
2
2
|
export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
|
package/dist/{tool-schema-json-projection-BwNu3nDi.mjs → github-copilot-headers-BCoBNmL7.mjs}
RENAMED
|
@@ -91,4 +91,51 @@ function projectRuntimeToolInputSchema(schema, path = "parameters") {
|
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
//#endregion
|
|
94
|
-
|
|
94
|
+
//#region packages/ai/src/providers/cache-retention.ts
|
|
95
|
+
/**
|
|
96
|
+
* Resolve cache retention preference.
|
|
97
|
+
* Defaults to "short" and uses OPENCLAW_CACHE_RETENTION for backward compatibility.
|
|
98
|
+
*/
|
|
99
|
+
function resolveCacheRetention(cacheRetention) {
|
|
100
|
+
if (cacheRetention) return cacheRetention;
|
|
101
|
+
if (typeof process !== "undefined" && process.env.OPENCLAW_CACHE_RETENTION === "long") return "long";
|
|
102
|
+
return "short";
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region packages/ai/src/providers/cloudflare.ts
|
|
106
|
+
function isCloudflareProvider(provider) {
|
|
107
|
+
return provider === "cloudflare-workers-ai" || provider === "cloudflare-ai-gateway";
|
|
108
|
+
}
|
|
109
|
+
/** Substitute `{VAR}` placeholders in a Cloudflare baseUrl from process.env. */
|
|
110
|
+
function resolveCloudflareBaseUrl(model) {
|
|
111
|
+
const url = model.baseUrl;
|
|
112
|
+
if (!url.includes("{")) return url;
|
|
113
|
+
return url.replace(/\{([A-Z_][A-Z0-9_]*)\}/g, (_match, name) => {
|
|
114
|
+
const value = process.env[name];
|
|
115
|
+
if (!value) throw new Error(`${name} is required for provider ${model.provider} but is not set.`);
|
|
116
|
+
return value;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region packages/ai/src/providers/github-copilot-headers.ts
|
|
121
|
+
function inferCopilotInitiator(messages) {
|
|
122
|
+
const last = messages[messages.length - 1];
|
|
123
|
+
return last && last.role !== "user" ? "agent" : "user";
|
|
124
|
+
}
|
|
125
|
+
function hasCopilotVisionInput(messages) {
|
|
126
|
+
return messages.some((msg) => {
|
|
127
|
+
if (msg.role === "user" && Array.isArray(msg.content)) return msg.content.some((c) => c.type === "image");
|
|
128
|
+
if (msg.role === "toolResult" && Array.isArray(msg.content)) return msg.content.some((c) => c.type === "image");
|
|
129
|
+
return false;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function buildCopilotDynamicHeaders(params) {
|
|
133
|
+
const headers = {
|
|
134
|
+
"X-Initiator": inferCopilotInitiator(params.messages),
|
|
135
|
+
"Openai-Intent": "conversation-edits"
|
|
136
|
+
};
|
|
137
|
+
if (params.hasImages) headers["Copilot-Vision-Request"] = "true";
|
|
138
|
+
return headers;
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
export { resolveCacheRetention as a, resolveCloudflareBaseUrl as i, hasCopilotVisionInput as n, projectRuntimeToolInputSchema as o, isCloudflareProvider as r, buildCopilotDynamicHeaders as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as getEnvApiKey } from "./env-api-keys-
|
|
1
|
+
import { n as getEnvApiKey } from "./env-api-keys-DrgeBuva.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
|
|
3
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-
|
|
4
|
-
import {
|
|
5
|
-
import { a as runGoogleGenerateContentLifecycle, i as getDisabledGoogleThinkingConfig, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-
|
|
3
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-XYGZcgO8.mjs";
|
|
4
|
+
import { A as buildBaseOptions } from "./shared-CdjNZd35.mjs";
|
|
5
|
+
import { a as runGoogleGenerateContentLifecycle, i as getDisabledGoogleThinkingConfig, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-J6qvYINH.mjs";
|
|
6
6
|
import { GoogleGenAI } from "@google/genai";
|
|
7
7
|
//#region packages/ai/src/providers/google.ts
|
|
8
8
|
let toolCallCounter = 0;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as isImageWithMediaPayload, S as describeToolResultMediaPlaceholder, o as stripSystemPromptCacheBoundary, u as transformMessages, w as extractToolResultText } from "./shared-CdjNZd35.mjs";
|
|
2
2
|
import { t as sanitizeSurrogates } from "./sanitize-unicode-DT5o51ur.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { c as calculateCost, l as clampThinkingLevel } from "./number-coercion-DvG7SNMg.mjs";
|
|
4
|
+
import { d as transportAbortError } from "./transport-stream-shared-BbMELSI4.mjs";
|
|
5
|
+
import { t as formatProviderError } from "./provider-error-apVOZI6G.mjs";
|
|
5
6
|
import { FinishReason, FunctionCallingConfigMode, ThinkingLevel } from "@google/genai";
|
|
6
7
|
//#region packages/ai/src/providers/google-shared.ts
|
|
7
8
|
/**
|
|
@@ -545,7 +546,7 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
545
546
|
}
|
|
546
547
|
}
|
|
547
548
|
endCurrentBlock();
|
|
548
|
-
if (params.signal?.aborted) throw
|
|
549
|
+
if (params.signal?.aborted) throw transportAbortError(params.signal);
|
|
549
550
|
if (params.output.stopReason === "aborted" || params.output.stopReason === "error") throw new Error("An unknown error occurred");
|
|
550
551
|
params.stream.push({
|
|
551
552
|
type: "done",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
|
|
2
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-
|
|
3
|
-
import {
|
|
4
|
-
import { a as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-
|
|
2
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-XYGZcgO8.mjs";
|
|
3
|
+
import { A as buildBaseOptions } from "./shared-CdjNZd35.mjs";
|
|
4
|
+
import { a as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-J6qvYINH.mjs";
|
|
5
5
|
import { GoogleGenAI, ResourceScope } from "@google/genai";
|
|
6
6
|
//#region packages/ai/src/providers/google-vertex.ts
|
|
7
7
|
const API_VERSION = "v1";
|