@openclaw/ai 2026.11.3 → 2026.11.5-beta.2
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 +11 -8
- package/dist/.source-module-urls/fe058cc430242ce2ab0dfbcbe153e240a52cf9c3072c3dc0a73e5f956b6ba49b.json +1 -0
- package/dist/anthropic-DEKgalVg.mjs +182 -0
- package/dist/{anthropic-payload-policy-C0ki72BT.d.mts → anthropic-payload-policy-CXCJ5Pmj.d.mts} +21 -4
- package/dist/{anthropic-stream-reducer-yWDb5Cct.mjs → anthropic-stream-lifecycle-DF2qVvg1.mjs} +845 -649
- package/dist/{anthropic-tool-projection-C2-d1eZ3.d.mts → anthropic-tool-projection-D5DyrL6C.d.mts} +6 -7
- package/dist/{anthropic-tool-projection-DZOKfAmL.mjs → anthropic-tool-projection-dGRfr4iT.mjs} +22 -32
- package/dist/{api-registry-gDt0faai.d.mts → api-registry-DY2MLUyg.d.mts} +2 -2
- package/dist/assistant-output-CD4kY9gu.mjs +16 -0
- package/dist/{azure-openai-responses-BvvXzZbi.mjs → azure-openai-responses-DbQV5RTx.mjs} +47 -53
- package/dist/{cloudflare-Dttf8jKq.mjs → cloudflare-BJ2_Xabx.mjs} +1 -1
- package/dist/{credential-redaction-XvsPf7Yi.d.mts → credential-redaction-DrgndwTJ.d.mts} +5 -3
- package/dist/{deferred-event-buffer-DAvyP7qA.mjs → deferred-event-buffer-tIGkTkTm.mjs} +1 -2
- package/dist/{diagnostics-v7oVEW59.mjs → diagnostics-CloVGQiK.mjs} +27 -20
- package/dist/{diagnostics-DzrF1h4J.mjs → diagnostics-o1PrVNQb.mjs} +11 -4
- package/dist/diagnostics.d.mts +6 -7
- package/dist/diagnostics.mjs +4 -4
- package/dist/{env-api-keys-Xd8dm_aV.mjs → env-api-keys-BuHc86ya.mjs} +1 -26
- package/dist/event-stream-B4ZcSvsu.d.mts +1 -0
- package/dist/{event-stream-CzpE1g_o.d.mts → event-stream-BYmtRe8-.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -2
- package/dist/expect-lbe3Hgrh.mjs +8 -0
- package/dist/{github-copilot-request-facts-F-EmvkpW.mjs → github-copilot-request-facts-BZ_EMo7X.mjs} +1 -1
- package/dist/{google-Cpi_cLKZ.mjs → google-B1g82bn4.mjs} +7 -8
- package/dist/{google-interactions-CGINbsjO.mjs → google-interactions-Ckr0Z99Z.mjs} +243 -269
- package/dist/{google-messages-DQMgG5yG.mjs → google-messages-A-9d3y5V.mjs} +52 -18
- package/dist/{google-provider-stream-BHd0cST9.mjs → google-provider-stream-CNVh4gpm.mjs} +19 -11
- package/dist/{google-shared-vtag8bj5.mjs → google-shared-WNM86ZcW.mjs} +72 -42
- package/dist/{google-vertex-eKoUnW7N.mjs → google-vertex-CXjleC6g.mjs} +3 -3
- package/dist/{google-video-slots-D8tPH8wX.mjs → google-video-slots-Bxt-OXO8.mjs} +1 -1
- package/dist/{host-CWt55nnF.mjs → host-DX7ORpeH.mjs} +46 -39
- package/dist/{host-jJOffdlW.d.mts → host-ccbwPC3A.d.mts} +17 -9
- package/dist/{host-policy-Dm7PM6AD.mjs → host-policy-jCZebuXx.mjs} +2 -2
- package/dist/index-Bczt0MnO.d.mts +17 -0
- package/dist/index.d.mts +8 -7
- package/dist/index.mjs +9 -7
- package/dist/internal/anthropic.d.mts +21 -26
- package/dist/internal/anthropic.mjs +6 -6
- package/dist/internal/google-model-family.mjs +1 -1
- package/dist/internal/google.d.mts +15 -0
- package/dist/internal/google.mjs +1 -0
- package/dist/internal/model-request-body.d.mts +37 -0
- package/dist/internal/model-request-body.mjs +106 -0
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +2 -2
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +14 -12
- package/dist/internal/openai.mjs +11 -10
- package/dist/internal/reasoning-tag-text-partitioner.d.mts +26 -0
- package/dist/{reasoning-tag-text-partitioner-CU9A4Lg8.mjs → internal/reasoning-tag-text-partitioner.mjs} +313 -111
- package/dist/internal/retry-after.d.mts +2 -2
- package/dist/internal/retry-after.mjs +96 -32
- package/dist/internal/runtime.d.mts +15 -41
- package/dist/internal/runtime.mjs +9 -10
- package/dist/internal/shared.d.mts +21 -25
- package/dist/internal/shared.mjs +9 -98
- package/dist/internal/tool-schema.d.mts +10 -10
- package/dist/internal/tool-schema.mjs +4 -4
- package/dist/{llm-request-activity-CfMuh5cC.mjs → llm-request-activity-DzaHoRAU.mjs} +2 -2
- package/dist/mistral-CjHkvsqR.mjs +3741 -0
- package/dist/{openai.LICENSE → mistral.LICENSE} +1 -1
- package/dist/{model-transport-url-BrsjjdjR.d.mts → model-transport-url-BdksnBqu.d.mts} +6 -8
- package/dist/{number-coercion-37gmNkuA.mjs → number-coercion-C7HsBgUL.mjs} +7 -2
- package/dist/observe-async-iterator-AlARO5wS.d.mts +178 -0
- package/dist/observe-async-iterator-DgmegcZR.mjs +181 -0
- package/dist/{openai-chatgpt-responses-BZa3SySh.mjs → openai-chatgpt-responses-CwS5JP7A.mjs} +61 -80
- package/dist/{openai-completions-compat-CBvb2eld.d.mts → openai-completions-compat-CJ-NsDzg.d.mts} +12 -6
- package/dist/{openai-completions-compat-bNQXF1y9.mjs → openai-completions-compat-CstlTQuF.mjs} +74 -50
- package/dist/{openai-completions-CCZ_UHCk.mjs → openai-completions-sj4S-RXQ.mjs} +5 -5
- package/dist/openai-completions-transport-BDAIA0_P.mjs +3406 -0
- package/dist/{openai-prompt-cache-DgjD-UL5.d.mts → openai-prompt-cache-BZGaIWYh.d.mts} +4 -4
- package/dist/{openai-prompt-cache-B9AvdoEo.mjs → openai-prompt-cache-CgDoFhO0.mjs} +5 -4
- package/dist/{openai-responses-compaction-replay-_sUXtcwU.d.mts → openai-responses-compaction-replay-CNHk6k53.d.mts} +4 -4
- package/dist/{openai-responses-contracts-B1nkeLL6.d.mts → openai-responses-contracts-BXMcvO7F.d.mts} +4 -10
- package/dist/{openai-responses-contracts-B5mGAbR6.mjs → openai-responses-contracts-xU-n9AJJ.mjs} +36 -37
- package/dist/{openai-responses-endpoint-CfKR6N5f.mjs → openai-responses-endpoint-DCkURKS0.mjs} +55 -8
- package/dist/openai-responses-ev_c6oTy.mjs +89 -0
- package/dist/{openai-responses-payload-policy-BzM52TTH.d.mts → openai-responses-payload-policy-DyE30gdD.d.mts} +7 -7
- package/dist/{openai-responses-request-lifecycle-CTqHc02t.mjs → openai-responses-request-lifecycle-BuOs0mwI.mjs} +12 -26
- package/dist/{openai-responses-shared-wx9v1MCn.mjs → openai-responses-shared-BmRQnUPP.mjs} +633 -1493
- package/dist/{openai-responses-terminal-usage-CpVjkqn-.d.mts → openai-responses-terminal-usage-D7IhRA6i.d.mts} +9 -3
- package/dist/{openai-tool-schema-BTEU2xmN.mjs → openai-tool-schema-CsoYgnWy.mjs} +97 -122
- package/dist/otel-Buswj0Mf.mjs +766 -0
- package/dist/{overflow-OF3PgPbw.mjs → overflow-CpApyjG2.mjs} +1 -1
- package/dist/{positive-integer-Bb4Evc7L.mjs → positive-integer-DiqE5vNi.mjs} +2 -3
- package/dist/{prompt-cache-stability-D_MeCQFI.mjs → prompt-cache-stability-w-ICeyOI.mjs} +1 -1
- package/dist/{provider-error-qtZD2inE.mjs → provider-error-DD-fo4Rz.mjs} +71 -234
- package/dist/{provider-options-DAzsyi49.d.mts → provider-options-Mo8NM5d1.d.mts} +16 -5
- package/dist/{provider-replay-context-4vxI7p4V.mjs → provider-replay-context-xyU7-CiT.mjs} +2 -2
- package/dist/provider-transcript-transform-DtaxNcC1.mjs +32 -0
- package/dist/{provider-transport-turn-state-D_GjPJHe.mjs → provider-transport-turn-state-BIS8maBK.mjs} +4 -4
- package/dist/{provider-types-CWl4VXvE.d.mts → provider-types-B1e98js5.d.mts} +3 -3
- package/dist/provider-types.d.mts +7 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +26 -29
- package/dist/{record-coerce-CNDovvft.mjs → record-coerce-BQaoiN3r.mjs} +4 -1
- package/dist/request-headers-DO4Mqhw1.mjs +10 -0
- package/dist/{required-api-key-D088S4Cd.mjs → required-api-key-2zZTkmsi.mjs} +1 -1
- package/dist/{retry-after-BrmTv0jL.d.mts → retry-after-DnHBlFS2.d.mts} +21 -1
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/{sanitize-unicode-ZqVLLEKC.d.mts → sanitize-unicode-BISmUlUv.d.mts} +2 -2
- package/dist/{simple-options-xJkqrG_E.mjs → simple-options-tLSeECry.mjs} +108 -82
- package/dist/src-BUsVkrNt.mjs +105 -0
- package/dist/{src-CyA0zJnt.mjs → src-CQ7nH2mL.mjs} +4 -7
- package/dist/stable-stringify-CchQEmeA.mjs +84 -0
- package/dist/{stream-C4YDqhFj.mjs → stream-DrtAWu7c.mjs} +2 -6
- package/dist/{stream-first-event-timeout-D_TfJHRJ.mjs → stream-first-event-timeout-B7RcufAV.mjs} +16 -13
- package/dist/{string-coerce-Cj8sqWHx.mjs → string-coerce-BCuWMIrk.mjs} +1 -1
- package/dist/string-normalization-B8TDDBX_.mjs +32 -0
- package/dist/telemetry-CvK1yQg7.mjs +582 -0
- package/dist/{tool-schema-json-projection-B1sTYwfH.mjs → tool-schema-json-projection-BQpiJlXJ.mjs} +53 -69
- package/dist/{transport-stream-shared-lhgkTOz3.mjs → transport-stream-shared-D2uFMhMc.mjs} +177 -93
- package/dist/{transport-stream-shared-8ru8eX4s.d.mts → transport-stream-shared-D3IAU4jn.d.mts} +29 -15
- package/dist/{transport-utils-DwOpuTjL.mjs → transport-utils-Da_39MYi.mjs} +23 -38
- package/dist/transports.d.mts +42 -39
- package/dist/transports.mjs +215 -296
- package/dist/{types-CVYzKrMl.d.mts → types-BVdTf0YV.d.mts} +38 -3
- package/dist/types-Cb3-5WM9.d.mts +1 -0
- package/dist/{types-BXd0kI8-.mjs → types-OVEWUaDh.mjs} +3 -1
- package/dist/types.d.mts +7 -6
- package/dist/types.mjs +7 -5
- package/dist/{validation-9FSkE8T-.mjs → validation-DGXqfvkj.mjs} +45 -27
- package/dist/{validation-BQ5u20Ru.d.mts → validation-QmyD0E5A.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -2
- package/package.json +40 -6
- package/dist/anthropic-lueA8LUg.mjs +0 -221
- package/dist/assistant-output-BnQm3fov.mjs +0 -47
- package/dist/event-stream-CDpFza-M.d.mts +0 -1
- package/dist/index-DSprYWaz.d.mts +0 -185
- package/dist/mistral-CQ7aoWg2.mjs +0 -512
- package/dist/model-request-body-BD5vy4rP.d.mts +0 -17
- package/dist/openai-CiRi-nVE.mjs +0 -20077
- package/dist/openai-completions-transport-DFvSBbUT.mjs +0 -10881
- package/dist/openai-responses-DQsZKUoI.mjs +0 -87
- package/dist/rolldown-runtime-B4iAMlE-.mjs +0 -35
- package/dist/types-CBJthzJX.d.mts +0 -1
- package/dist/ws.LICENSE +0 -20
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { p as hasRuntimeContextMarker } from "./types-OVEWUaDh.mjs";
|
|
2
2
|
import { r as appendAssistantThinking } from "./event-stream-X2gmsUWv.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { a as asRecord, s as isStringArray } from "./record-coerce-BQaoiN3r.mjs";
|
|
4
|
+
import { N as isImageWithMediaPayload, O as calculateCost } from "./host-DX7ORpeH.mjs";
|
|
4
5
|
import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
|
|
5
|
-
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-
|
|
6
|
-
import {
|
|
7
|
-
import { a as createEmptyTransportUsage,
|
|
8
|
-
import { t as notifyLlmRequestActivity } from "./llm-request-activity-
|
|
6
|
+
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-w-ICeyOI.mjs";
|
|
7
|
+
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText } from "./simple-options-tLSeECry.mjs";
|
|
8
|
+
import { a as createEmptyTransportUsage, r as coerceTransportToolCallArguments, x as transportAbortError, y as sanitizeTransportPayloadText } from "./transport-stream-shared-D2uFMhMc.mjs";
|
|
9
|
+
import { t as notifyLlmRequestActivity } from "./llm-request-activity-DzaHoRAU.mjs";
|
|
9
10
|
import { isGoogleGemini4Model } from "./internal/google-model-family.mjs";
|
|
10
11
|
import "./types.mjs";
|
|
11
12
|
//#region packages/ai/src/transports/google-thinking-level.ts
|
|
@@ -17,6 +18,42 @@ function googleFlashSupportsMinimalThinking(modelId) {
|
|
|
17
18
|
return Number.parseInt(match[1] ?? "0", 10) < 7;
|
|
18
19
|
}
|
|
19
20
|
//#endregion
|
|
21
|
+
//#region packages/ai/src/providers/google-tool-parameters.ts
|
|
22
|
+
const PYTHON_KEYWORDS = new Set("False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield".split(" "));
|
|
23
|
+
function parameterNames(parameters) {
|
|
24
|
+
const properties = asRecord(parameters.properties);
|
|
25
|
+
const names = /* @__PURE__ */ new Map();
|
|
26
|
+
for (const name of Object.keys(properties)) {
|
|
27
|
+
if (!PYTHON_KEYWORDS.has(name)) continue;
|
|
28
|
+
let alias = `${name}_`;
|
|
29
|
+
while (Object.hasOwn(properties, alias)) alias += "_";
|
|
30
|
+
names.set(name, alias);
|
|
31
|
+
}
|
|
32
|
+
return names;
|
|
33
|
+
}
|
|
34
|
+
function googleToolParameters(parameters) {
|
|
35
|
+
const schema = asRecord(parameters);
|
|
36
|
+
const names = parameterNames(schema);
|
|
37
|
+
if (names.size === 0) return schema;
|
|
38
|
+
const projected = {
|
|
39
|
+
...schema,
|
|
40
|
+
properties: Object.fromEntries(Object.entries(asRecord(schema.properties)).map(([name, propertySchema]) => [names.get(name) ?? name, propertySchema]))
|
|
41
|
+
};
|
|
42
|
+
for (const key of ["required", "propertyOrdering"]) {
|
|
43
|
+
const value = schema[key];
|
|
44
|
+
if (isStringArray(value)) projected[key] = value.map((name) => names.get(name) ?? name);
|
|
45
|
+
}
|
|
46
|
+
return projected;
|
|
47
|
+
}
|
|
48
|
+
function mapGoogleToolArguments(tools, toolName, args, direction) {
|
|
49
|
+
const tool = tools?.find((candidate) => candidate.name === toolName);
|
|
50
|
+
if (!tool) return args;
|
|
51
|
+
const names = parameterNames(asRecord(tool.parameters));
|
|
52
|
+
if (names.size === 0) return args;
|
|
53
|
+
const mapping = direction === "encode" ? names : new Map([...names].map(([name, alias]) => [alias, name]));
|
|
54
|
+
return Object.fromEntries(Object.entries(args).map(([name, value]) => [mapping.get(name) ?? name, value]));
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
20
57
|
//#region packages/ai/src/providers/google-stream.ts
|
|
21
58
|
const GOOGLE_MODEL_RESOURCE_PREFIX = /^(?:(?:projects\/[^/]+\/locations\/[^/]+\/)?publishers\/google\/models\/|google\/|models\/)/u;
|
|
22
59
|
function retainThoughtSignature(existing, incoming) {
|
|
@@ -186,7 +223,7 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
186
223
|
type: "toolCall",
|
|
187
224
|
id: !providedId || toolCallIds.has(providedId) ? params.nextToolCallId(part.functionCall.name) : providedId,
|
|
188
225
|
name: part.functionCall.name || "",
|
|
189
|
-
arguments: part.functionCall.args ?? {},
|
|
226
|
+
arguments: mapGoogleToolArguments(params.tools, part.functionCall.name || "", part.functionCall.args ?? {}, "decode"),
|
|
190
227
|
...part.thoughtSignature && { thoughtSignature: part.thoughtSignature }
|
|
191
228
|
};
|
|
192
229
|
params.output.content.push(toolCall);
|
|
@@ -267,13 +304,6 @@ function sanitizeGeminiThoughtSignature(value) {
|
|
|
267
304
|
const trimmed = value.trim();
|
|
268
305
|
return trimmed && /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(trimmed) ? trimmed : void 0;
|
|
269
306
|
}
|
|
270
|
-
function toolCallThoughtSignatureReplayKey(id, name, args) {
|
|
271
|
-
return [
|
|
272
|
-
id,
|
|
273
|
-
name,
|
|
274
|
-
stableStringifyGoogleToolCallValue(args)
|
|
275
|
-
].join("\0");
|
|
276
|
-
}
|
|
277
307
|
function requiresGoogleToolCallId(modelId) {
|
|
278
308
|
return modelId.startsWith("claude-") || modelId.startsWith("gpt-oss-");
|
|
279
309
|
}
|
|
@@ -337,9 +367,13 @@ function projectGoogleMessages(params) {
|
|
|
337
367
|
});
|
|
338
368
|
} else if (block.type === "toolCall") {
|
|
339
369
|
if (isSameProviderAndModel && (managed || model.provider !== "google-gemini-cli")) sameRouteToolCallIds.add(block.id);
|
|
340
|
-
const args = coerceTransportToolCallArguments(block.arguments);
|
|
370
|
+
const args = mapGoogleToolArguments(params.tools, block.name, coerceTransportToolCallArguments(block.arguments), "encode");
|
|
341
371
|
const ownSignature = isSameProviderAndModel ? signature(block.thoughtSignature) : void 0;
|
|
342
|
-
const replayKey = managed && (ownSignature || params.requiresToolCallSignature && isSameProviderAndModel && replaySignatures.size > 0) ?
|
|
372
|
+
const replayKey = managed && (ownSignature || params.requiresToolCallSignature && isSameProviderAndModel && replaySignatures.size > 0) ? [
|
|
373
|
+
block.id,
|
|
374
|
+
block.name,
|
|
375
|
+
stableStringifyGoogleToolCallValue(args)
|
|
376
|
+
].join("\0") : "";
|
|
343
377
|
if (managed && ownSignature) nextReplaySignatures.set(replayKey, ownSignature);
|
|
344
378
|
const thoughtSignature = ownSignature ?? (managed && params.requiresToolCallSignature && isSameProviderAndModel ? replaySignatures.get(replayKey) : void 0) ?? (params.requiresToolCallSignature && (managed || !sawFunctionCall) ? GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP : void 0);
|
|
345
379
|
sawFunctionCall = true;
|
|
@@ -408,8 +442,8 @@ function convertGoogleTools(tools) {
|
|
|
408
442
|
return [{ functionDeclarations: sortPromptCacheToolsByName(tools).map((tool) => ({
|
|
409
443
|
name: tool.name,
|
|
410
444
|
description: tool.description,
|
|
411
|
-
parametersJsonSchema: tool.parameters
|
|
445
|
+
parametersJsonSchema: googleToolParameters(tool.parameters)
|
|
412
446
|
})) }];
|
|
413
447
|
}
|
|
414
448
|
//#endregion
|
|
415
|
-
export {
|
|
449
|
+
export { googleToolParameters as a, consumeGoogleGenerateContentStream as i, projectGoogleMessages as n, mapGoogleToolArguments as o, requiresGoogleToolCallId as r, googleFlashSupportsMinimalThinking as s, convertGoogleTools as t };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import "./src-CQ7nH2mL.mjs";
|
|
2
|
+
import { t as omitNullRequestHeaders } from "./request-headers-DO4Mqhw1.mjs";
|
|
1
3
|
import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
|
|
2
|
-
import { a as asRecord } from "./record-coerce-
|
|
3
|
-
import { a as resolveAiTransportHeaderSentinels } from "./host-
|
|
4
|
-
import { n as buildManagedModelFetch } from "./host-policy-
|
|
5
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
6
|
-
import {
|
|
7
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
8
|
-
import {
|
|
4
|
+
import { a as asRecord } from "./record-coerce-BQaoiN3r.mjs";
|
|
5
|
+
import { a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-DX7ORpeH.mjs";
|
|
6
|
+
import { n as buildManagedModelFetch } from "./host-policy-jCZebuXx.mjs";
|
|
7
|
+
import { n as buildBaseOptions } from "./simple-options-tLSeECry.mjs";
|
|
8
|
+
import { p as mergeTransportHeaders } from "./transport-stream-shared-D2uFMhMc.mjs";
|
|
9
|
+
import { t as createAssistantOutput } from "./assistant-output-CD4kY9gu.mjs";
|
|
10
|
+
import { a as runGoogleGenerateContentLifecycle, i as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-WNM86ZcW.mjs";
|
|
9
11
|
import { ResourceScope } from "@google/genai";
|
|
10
12
|
//#region packages/ai/src/providers/google-http-options.ts
|
|
11
13
|
function buildGoogleHttpOptions(model, optionsHeaders, profile) {
|
|
@@ -24,10 +26,15 @@ function buildGoogleHttpOptions(model, optionsHeaders, profile) {
|
|
|
24
26
|
httpOptions.baseUrl = model.baseUrl;
|
|
25
27
|
httpOptions.apiVersion = "";
|
|
26
28
|
} else httpOptions.apiVersion = "v1beta";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const headers = profile === "vertex" ? mergeTransportHeaders(model.headers, optionsHeaders) : getAiTransportHost().resolveProviderRequestHeaders({
|
|
30
|
+
provider: model.provider,
|
|
31
|
+
api: model.api,
|
|
32
|
+
baseUrl: model.baseUrl,
|
|
33
|
+
callerHeaders: mergeTransportHeaders(model.headers, optionsHeaders),
|
|
34
|
+
precedence: "caller-wins",
|
|
35
|
+
model
|
|
36
|
+
});
|
|
37
|
+
if (headers) httpOptions.headers = omitNullRequestHeaders(resolveAiTransportHeaderSentinels(headers));
|
|
31
38
|
return Object.keys(httpOptions).length > 0 ? httpOptions : void 0;
|
|
32
39
|
}
|
|
33
40
|
//#endregion
|
|
@@ -39,6 +46,7 @@ function createGoogleGenerateContentStreams(api, createClient, resolveSimpleApiK
|
|
|
39
46
|
runGoogleGenerateContentLifecycle({
|
|
40
47
|
stream: events,
|
|
41
48
|
model,
|
|
49
|
+
tools: context.tools,
|
|
42
50
|
output: createAssistantOutput(model, api),
|
|
43
51
|
options,
|
|
44
52
|
createClient: () => createClient(model, options),
|
|
@@ -1,23 +1,12 @@
|
|
|
1
|
-
import { k as clampThinkingLevel } from "./host-
|
|
1
|
+
import { k as clampThinkingLevel } from "./host-DX7ORpeH.mjs";
|
|
2
2
|
import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { C as stripSystemPromptCacheBoundary, t as adjustMaxTokensForThinking } from "./simple-options-tLSeECry.mjs";
|
|
4
|
+
import { c as failTransportStream, g as notifyProviderStreamOpened, x as transportAbortError } from "./transport-stream-shared-D2uFMhMc.mjs";
|
|
5
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-DtaxNcC1.mjs";
|
|
6
6
|
import { isGoogleGemini3ProModel, isGoogleGemini3ThinkingLevelModel } from "./internal/google-model-family.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { i as consumeGoogleGenerateContentStream, n as projectGoogleMessages, r as requiresGoogleToolCallId, s as googleFlashSupportsMinimalThinking, t as convertGoogleTools } from "./google-messages-A-9d3y5V.mjs";
|
|
8
8
|
import { FunctionCallingConfigMode, ThinkingLevel } from "@google/genai";
|
|
9
9
|
//#region packages/ai/src/providers/google-shared.ts
|
|
10
|
-
function convertMessages(model, context) {
|
|
11
|
-
return projectGoogleMessages({
|
|
12
|
-
model,
|
|
13
|
-
messages: transformProviderMessages(context.messages, model, (id) => requiresGoogleToolCallId(model.id) ? id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64) : id),
|
|
14
|
-
replay: "signed-parts",
|
|
15
|
-
requiresToolCallSignature: model.provider !== "google-gemini-cli" && isGoogleGemini3ThinkingLevelModel(model.id)
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
function mapToolChoice(choice) {
|
|
19
|
-
return choice === "none" ? FunctionCallingConfigMode.NONE : choice === "any" ? FunctionCallingConfigMode.ANY : FunctionCallingConfigMode.AUTO;
|
|
20
|
-
}
|
|
21
10
|
async function runGoogleGenerateContentLifecycle(params) {
|
|
22
11
|
const { stream, model, output, options } = params;
|
|
23
12
|
try {
|
|
@@ -36,6 +25,7 @@ async function runGoogleGenerateContentLifecycle(params) {
|
|
|
36
25
|
chunks: { [Symbol.asyncIterator]: () => googleIterator },
|
|
37
26
|
model,
|
|
38
27
|
output,
|
|
28
|
+
tools: params.tools,
|
|
39
29
|
stream,
|
|
40
30
|
signal: options?.signal,
|
|
41
31
|
nextToolCallId: params.nextToolCallId
|
|
@@ -51,26 +41,25 @@ async function runGoogleGenerateContentLifecycle(params) {
|
|
|
51
41
|
}
|
|
52
42
|
}
|
|
53
43
|
function buildGoogleGenerateContentParams(model, context, options = {}) {
|
|
54
|
-
const contents =
|
|
44
|
+
const contents = projectGoogleMessages({
|
|
45
|
+
model,
|
|
46
|
+
messages: transformProviderMessages(context.messages, model, (id) => requiresGoogleToolCallId(model.id) ? id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64) : id),
|
|
47
|
+
tools: context.tools,
|
|
48
|
+
replay: "signed-parts",
|
|
49
|
+
requiresToolCallSignature: model.provider !== "google-gemini-cli" && isGoogleGemini3ThinkingLevelModel(model.id)
|
|
50
|
+
});
|
|
55
51
|
const config = {
|
|
56
52
|
...options.temperature !== void 0 && { temperature: options.temperature },
|
|
57
53
|
...options.topP !== void 0 && { topP: options.topP },
|
|
58
|
-
...options.
|
|
54
|
+
...buildGoogleGenerationConfig(model, options.thinking, options.maxTokens),
|
|
59
55
|
...options.stop !== void 0 && options.stop.length > 0 && { stopSequences: options.stop },
|
|
60
56
|
...context.systemPrompt && { systemInstruction: sanitizeSurrogates(stripSystemPromptCacheBoundary(context.systemPrompt)) },
|
|
61
57
|
...context.tools && context.tools.length > 0 && { tools: convertGoogleTools(context.tools) }
|
|
62
58
|
};
|
|
63
|
-
if (context.tools && context.tools.length > 0 && options.toolChoice)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (options.thinking.level !== void 0) thinkingConfig.thinkingLevel = ThinkingLevel[options.thinking.level];
|
|
68
|
-
else if (options.thinking.budgetTokens !== void 0) thinkingConfig.thinkingBudget = options.thinking.budgetTokens;
|
|
69
|
-
config.thinkingConfig = thinkingConfig;
|
|
70
|
-
} else if (model.reasoning && options.thinking && !options.thinking.enabled) {
|
|
71
|
-
const disabledThinkingConfig = getDisabledGoogleThinkingConfig(model);
|
|
72
|
-
if (Object.keys(disabledThinkingConfig).length > 0) config.thinkingConfig = disabledThinkingConfig;
|
|
73
|
-
}
|
|
59
|
+
if (context.tools && context.tools.length > 0 && options.toolChoice) {
|
|
60
|
+
const choice = options.toolChoice;
|
|
61
|
+
config.toolConfig = { functionCallingConfig: { mode: choice === "none" ? FunctionCallingConfigMode.NONE : choice === "any" ? FunctionCallingConfigMode.ANY : FunctionCallingConfigMode.AUTO } };
|
|
62
|
+
} else config.toolConfig = void 0;
|
|
74
63
|
if (options.signal) {
|
|
75
64
|
if (options.signal.aborted) throw new Error("Request aborted");
|
|
76
65
|
config.abortSignal = options.signal;
|
|
@@ -81,6 +70,46 @@ function buildGoogleGenerateContentParams(model, context, options = {}) {
|
|
|
81
70
|
config
|
|
82
71
|
};
|
|
83
72
|
}
|
|
73
|
+
/** Shared wire policy for the Gemini API and Vertex, with or without the Google SDK. */
|
|
74
|
+
function buildGoogleGenerationConfig(model, thinking, maxTokens) {
|
|
75
|
+
let thinkingConfig;
|
|
76
|
+
if (model.reasoning && thinking) {
|
|
77
|
+
if (thinking.enabled) {
|
|
78
|
+
thinkingConfig = { includeThoughts: true };
|
|
79
|
+
if (thinking.level !== void 0) {
|
|
80
|
+
const level = {
|
|
81
|
+
MINIMAL: "minimal",
|
|
82
|
+
LOW: "low",
|
|
83
|
+
MEDIUM: "medium",
|
|
84
|
+
HIGH: "high",
|
|
85
|
+
THINKING_LEVEL_UNSPECIFIED: void 0
|
|
86
|
+
}[thinking.level];
|
|
87
|
+
thinkingConfig.thinkingLevel = level ? getGoogleThinkingLevel(level, model) : ThinkingLevel.THINKING_LEVEL_UNSPECIFIED;
|
|
88
|
+
} else if (thinking.budgetTokens !== void 0) {
|
|
89
|
+
if (isGoogleGemini3ThinkingLevelModel(model.id) && thinking.budgetTokens >= 0) {
|
|
90
|
+
const budget = thinking.budgetTokens;
|
|
91
|
+
thinkingConfig.thinkingLevel = getGoogleThinkingLevel(budget === 0 ? "minimal" : budget <= 2048 ? "low" : budget <= 8192 ? "medium" : "high", model);
|
|
92
|
+
} else thinkingConfig.thinkingBudget = thinking.budgetTokens;
|
|
93
|
+
}
|
|
94
|
+
} else thinkingConfig = getDisabledGoogleThinkingConfig(model);
|
|
95
|
+
if (model.id.toLowerCase().includes("gemini-2.5-pro") && thinkingConfig.thinkingBudget === 0) delete thinkingConfig.thinkingBudget;
|
|
96
|
+
}
|
|
97
|
+
let maxOutputTokens = maxTokens;
|
|
98
|
+
if (maxTokens !== void 0 && model.reasoning) {
|
|
99
|
+
if (model.id.toLowerCase().includes("gemini-2.5-pro") && thinking?.enabled === false) thinkingConfig = { thinkingBudget: 128 };
|
|
100
|
+
else if (model.id.toLowerCase().includes("gemini-2.5-pro") && thinking?.budgetTokens === 0 && thinkingConfig) thinkingConfig.thinkingBudget = 128;
|
|
101
|
+
const budget = thinkingConfig?.thinkingBudget;
|
|
102
|
+
if (thinkingConfig && budget !== void 0 && budget >= 0) {
|
|
103
|
+
const adjusted = adjustMaxTokensForThinking(maxTokens, model.maxTokens, "low", { low: budget });
|
|
104
|
+
maxOutputTokens = adjusted.maxTokens;
|
|
105
|
+
thinkingConfig.thinkingBudget = adjusted.thinkingBudget;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
...maxOutputTokens !== void 0 && { maxOutputTokens },
|
|
110
|
+
...thinkingConfig && Object.keys(thinkingConfig).length > 0 && { thinkingConfig }
|
|
111
|
+
};
|
|
112
|
+
}
|
|
84
113
|
function isAdaptiveGoogleReasoningLevel(value) {
|
|
85
114
|
return value === "adaptive";
|
|
86
115
|
}
|
|
@@ -111,9 +140,21 @@ function buildGoogleThinking(model, options, interactions) {
|
|
|
111
140
|
enabled: true,
|
|
112
141
|
level: getGoogleThinkingLevel(effort, model)
|
|
113
142
|
};
|
|
143
|
+
const customBudgets = options.thinkingBudgets;
|
|
144
|
+
let budgetTokens;
|
|
145
|
+
if (customBudgets?.[effort] !== void 0) budgetTokens = customBudgets[effort];
|
|
146
|
+
else {
|
|
147
|
+
const isPro = model.id.includes("2.5-pro");
|
|
148
|
+
if (isPro || model.id.includes("2.5-flash")) budgetTokens = {
|
|
149
|
+
minimal: !isPro && model.id.includes("2.5-flash-lite") ? 512 : 128,
|
|
150
|
+
low: 2048,
|
|
151
|
+
medium: 8192,
|
|
152
|
+
high: isPro ? 32768 : 24576
|
|
153
|
+
}[effort];
|
|
154
|
+
}
|
|
114
155
|
return {
|
|
115
156
|
enabled: true,
|
|
116
|
-
budgetTokens
|
|
157
|
+
budgetTokens
|
|
117
158
|
};
|
|
118
159
|
}
|
|
119
160
|
function buildGoogleSimpleThinking(model, options) {
|
|
@@ -144,16 +185,5 @@ function getGoogleThinkingLevel(effort, model) {
|
|
|
144
185
|
}
|
|
145
186
|
return ThinkingLevel.HIGH;
|
|
146
187
|
}
|
|
147
|
-
function getGoogleBudget(model, effort, customBudgets) {
|
|
148
|
-
if (customBudgets?.[effort] !== void 0) return customBudgets[effort];
|
|
149
|
-
const isPro = model.id.includes("2.5-pro");
|
|
150
|
-
if (isPro || model.id.includes("2.5-flash")) return {
|
|
151
|
-
minimal: !isPro && model.id.includes("2.5-flash-lite") ? 512 : 128,
|
|
152
|
-
low: 2048,
|
|
153
|
-
medium: 8192,
|
|
154
|
-
high: isPro ? 32768 : 24576
|
|
155
|
-
}[effort];
|
|
156
|
-
return -1;
|
|
157
|
-
}
|
|
158
188
|
//#endregion
|
|
159
|
-
export { runGoogleGenerateContentLifecycle as i,
|
|
189
|
+
export { runGoogleGenerateContentLifecycle as a, buildGoogleSimpleThinking as i, buildGoogleGenerationConfig as n, buildGoogleInteractionsSimpleThinking as r, buildGoogleGenerateContentParams as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as normalizeOptionalString } from "./string-coerce-
|
|
2
|
-
import { r as getAiTransportHost } from "./host-
|
|
3
|
-
import { n as buildGoogleHttpOptions, t as createGoogleGenerateContentStreams } from "./google-provider-stream-
|
|
1
|
+
import { o as normalizeOptionalString } from "./string-coerce-BCuWMIrk.mjs";
|
|
2
|
+
import { r as getAiTransportHost } from "./host-DX7ORpeH.mjs";
|
|
3
|
+
import { n as buildGoogleHttpOptions, t as createGoogleGenerateContentStreams } from "./google-provider-stream-CNVh4gpm.mjs";
|
|
4
4
|
import { GoogleGenAI } from "@google/genai";
|
|
5
5
|
//#region packages/ai/src/providers/google-vertex.ts
|
|
6
6
|
const API_VERSION = "v1";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as asOptionalRecord } from "./record-coerce-
|
|
1
|
+
import { i as asOptionalRecord } from "./record-coerce-BQaoiN3r.mjs";
|
|
2
2
|
//#region packages/ai/src/providers/google-video-slots.ts
|
|
3
3
|
const GOOGLE_VIDEO_SLOT_OMISSION = "(video omitted: native video slot unavailable)";
|
|
4
4
|
function createGoogleVideoPlaceholder(video, slots, placeholder) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { D as supportsClaudeNativeMaxEffort, O as supportsClaudeNativeXhighEffort, S as resolveClaudeSonnet5ModelIdentity, _ as resolveClaudeMythos5ModelIdentity, a as CLAUDE_HAIKU_55_THINKING_PROFILE, b as resolveClaudeOpus5ModelIdentity, c as CLAUDE_SONNET_55_THINKING_PROFILE, f as requiresClaudeDefaultSampling, h as resolveClaudeHaiku55ModelIdentity, i as CLAUDE_FABLE_5_THINKING_PROFILE, m as resolveClaudeFable5ModelIdentity, o as CLAUDE_OPUS_55_THINKING_PROFILE, p as requiresClaudeMandatoryAdaptiveThinking, t as calculateUsageCost, v as resolveClaudeNativeThinkingLevelMap, x as resolveClaudeSonnet55ModelIdentity, y as resolveClaudeOpus55ModelIdentity } from "./src-
|
|
2
|
-
import { t as DEFAULT_MISSING_TOOL_RESULT_TEXT } from "./types-
|
|
3
|
-
import { i as asOptionalRecord, o as isRecord } from "./record-coerce-
|
|
4
|
-
import { r as normalizeLowercaseStringOrEmpty } from "./string-coerce-
|
|
5
|
-
import {
|
|
1
|
+
import { D as supportsClaudeNativeMaxEffort, O as supportsClaudeNativeXhighEffort, S as resolveClaudeSonnet5ModelIdentity, _ as resolveClaudeMythos5ModelIdentity, a as CLAUDE_HAIKU_55_THINKING_PROFILE, b as resolveClaudeOpus5ModelIdentity, c as CLAUDE_SONNET_55_THINKING_PROFILE, f as requiresClaudeDefaultSampling, h as resolveClaudeHaiku55ModelIdentity, i as CLAUDE_FABLE_5_THINKING_PROFILE, m as resolveClaudeFable5ModelIdentity, o as CLAUDE_OPUS_55_THINKING_PROFILE, p as requiresClaudeMandatoryAdaptiveThinking, t as calculateUsageCost, v as resolveClaudeNativeThinkingLevelMap, x as resolveClaudeSonnet55ModelIdentity, y as resolveClaudeOpus55ModelIdentity } from "./src-CQ7nH2mL.mjs";
|
|
2
|
+
import { t as DEFAULT_MISSING_TOOL_RESULT_TEXT } from "./types-OVEWUaDh.mjs";
|
|
3
|
+
import { i as asOptionalRecord, o as isRecord } from "./record-coerce-BQaoiN3r.mjs";
|
|
4
|
+
import { r as normalizeLowercaseStringOrEmpty } from "./string-coerce-BCuWMIrk.mjs";
|
|
5
|
+
import { F as MODEL_CATALOG_THINKING_LEVELS, I as listMappedModelThinkingLevels, O as resolveOpenAIModelReasoningEfforts, R as resolveOpenAIThinkingApi, i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-xU-n9AJJ.mjs";
|
|
6
6
|
//#region packages/ai/src/media-payload.ts
|
|
7
7
|
/** Media metadata alone is not an attachment; provider emitters need inline bytes. */
|
|
8
8
|
function hasMediaPayload(block) {
|
|
@@ -78,7 +78,8 @@ function buildAnthropicClaudeCodeIdentity(betaHeader, ...headerSources) {
|
|
|
78
78
|
...betaHeader ? { "anthropic-beta": betaHeader } : {},
|
|
79
79
|
"x-app": "cli"
|
|
80
80
|
});
|
|
81
|
-
for (const source of headerSources) for (const [name, value] of Object.entries(source ?? {})) headers.
|
|
81
|
+
for (const source of headerSources) for (const [name, value] of Object.entries(source ?? {})) if (value === null) headers.delete(name);
|
|
82
|
+
else headers.set(name, value);
|
|
82
83
|
let version = ANTHROPIC_CLAUDE_CODE_VERSION;
|
|
83
84
|
const candidate = headers.get("user-agent")?.match(/^claude-cli\/(\d+\.\d+\.\d+)$/)?.[1];
|
|
84
85
|
if (candidate) {
|
|
@@ -221,16 +222,24 @@ function isClaudeReplaySource(ref) {
|
|
|
221
222
|
const modelId = hasConcreteResponseModel(ref) ? ref.responseModelId : ref.modelId;
|
|
222
223
|
return /(?:^|[-/])claude-/.test(normalizeModelId(modelId));
|
|
223
224
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const targetApi = normalizeApi(
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
225
|
+
/** The destination is fixed during one synchronous history transform. */
|
|
226
|
+
function prepareModelBoundThinkingReplay(target) {
|
|
227
|
+
const targetApi = normalizeApi(target.api);
|
|
228
|
+
const targetIdentity = resolveReplayModelBoundIdentity({
|
|
229
|
+
api: target.api,
|
|
230
|
+
modelId: target.id,
|
|
231
|
+
modelParams: target.params
|
|
232
|
+
});
|
|
233
|
+
const targetProvider = normalizeLowercaseStringOrEmpty(target.provider);
|
|
234
|
+
const targetModelId = normalizeModelId(target.id);
|
|
235
|
+
return (source) => {
|
|
236
|
+
const sourceApi = normalizeApi(source.api);
|
|
237
|
+
const sourceIdentity = resolveReplayModelBoundIdentity(source);
|
|
238
|
+
if (!sourceIdentity && !targetIdentity) return "default";
|
|
239
|
+
if (sourceApi === targetApi && readsPriorClaudeThinking(targetIdentity, sourceIdentity) && isClaudeReplaySource(source)) return "preserve";
|
|
240
|
+
if (!sourceIdentity && !hasConcreteResponseModel(source) && targetIdentity && normalizeLowercaseStringOrEmpty(source.provider) === targetProvider && sourceApi === targetApi && normalizeModelId(source.modelId) === targetModelId) return "preserve";
|
|
241
|
+
return sourceApi === targetApi && sourceIdentity === targetIdentity ? "preserve" : "drop";
|
|
242
|
+
};
|
|
234
243
|
}
|
|
235
244
|
//#endregion
|
|
236
245
|
//#region packages/ai/src/replay-turn-classification.ts
|
|
@@ -268,6 +277,7 @@ const FAILED_ASSISTANT_REPLAY_TEXT = "[This turn failed before it completed. Do
|
|
|
268
277
|
/** Classify failed source content before model-specific thinking or tool projection. */
|
|
269
278
|
function resolveFailedAssistantReplay(message, options) {
|
|
270
279
|
if (message.role !== "assistant" || message.stopReason !== "error" && message.stopReason !== "aborted") return "keep";
|
|
280
|
+
if (message.errorCode === "openclaw_repetitive_output") return "keep";
|
|
271
281
|
const content = Array.isArray(message.content) ? message.content : [];
|
|
272
282
|
if (content.some((block) => asOptionalRecord(block)?.type === "toolCall")) return options.pairingAware ? "keep" : "drop";
|
|
273
283
|
return content.some((block) => {
|
|
@@ -293,22 +303,14 @@ function replaceImagesWithPlaceholder(content, placeholder) {
|
|
|
293
303
|
text: placeholder
|
|
294
304
|
});
|
|
295
305
|
}
|
|
296
|
-
return result;
|
|
297
|
-
}
|
|
298
|
-
function transformAssistant(message, model, toolCallIdMap, normalizeToolCallId) {
|
|
299
|
-
const replayMode =
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
responseModelId: message.responseModel
|
|
305
|
-
},
|
|
306
|
-
target: {
|
|
307
|
-
provider: model.provider,
|
|
308
|
-
api: model.api,
|
|
309
|
-
modelId: model.id,
|
|
310
|
-
modelParams: model.params
|
|
311
|
-
}
|
|
306
|
+
return Object.isFrozen(content) && result.length === content.length && result.every((block, index) => block === content[index]) ? content : result;
|
|
307
|
+
}
|
|
308
|
+
function transformAssistant(message, model, toolCallIdMap, thinkingReplay, normalizeToolCallId) {
|
|
309
|
+
const replayMode = thinkingReplay({
|
|
310
|
+
provider: message.provider,
|
|
311
|
+
api: message.api,
|
|
312
|
+
modelId: message.model,
|
|
313
|
+
responseModelId: message.responseModel
|
|
312
314
|
});
|
|
313
315
|
const sameModel = replayMode === "preserve" || message.provider === model.provider && message.api === model.api && message.model === model.id;
|
|
314
316
|
const content = (typeof message.content === "string" ? [{
|
|
@@ -336,13 +338,14 @@ function transformAssistant(message, model, toolCallIdMap, normalizeToolCallId)
|
|
|
336
338
|
if (id !== trimmedId) toolCallIdMap.set(trimmedId, id);
|
|
337
339
|
return id === block.id ? unsigned : Object.assign({}, unsigned, { id });
|
|
338
340
|
});
|
|
339
|
-
return {
|
|
341
|
+
return Array.isArray(message.content) && Object.isFrozen(message) && Object.isFrozen(message.content) && content.length === message.content.length && content.every((block, index) => block === message.content[index]) ? message : {
|
|
340
342
|
...message,
|
|
341
343
|
content
|
|
342
344
|
};
|
|
343
345
|
}
|
|
344
346
|
function transformMessages(messages, model, normalizeToolCallId) {
|
|
345
347
|
const toolCallIdMap = /* @__PURE__ */ new Map();
|
|
348
|
+
const thinkingReplay = prepareModelBoundThinkingReplay(model);
|
|
346
349
|
const asyncOwners = /* @__PURE__ */ new Map();
|
|
347
350
|
const relocated = /* @__PURE__ */ new Map();
|
|
348
351
|
const movedResults = /* @__PURE__ */ new Set();
|
|
@@ -394,7 +397,7 @@ function transformMessages(messages, model, normalizeToolCallId) {
|
|
|
394
397
|
};
|
|
395
398
|
if (message.role === "assistant") {
|
|
396
399
|
const failedReplay = resolveFailedAssistantReplay(message, { pairingAware: false });
|
|
397
|
-
message = transformAssistant(message, model, toolCallIdMap, normalizeToolCallId);
|
|
400
|
+
message = transformAssistant(message, model, toolCallIdMap, thinkingReplay, normalizeToolCallId);
|
|
398
401
|
flushToolCalls();
|
|
399
402
|
if (failedReplay === "drop") continue;
|
|
400
403
|
if (failedReplay === "marker") {
|
|
@@ -420,10 +423,13 @@ function transformMessages(messages, model, normalizeToolCallId) {
|
|
|
420
423
|
return [pending];
|
|
421
424
|
});
|
|
422
425
|
} else {
|
|
423
|
-
if (!supportsImages && typeof message.content !== "string")
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
426
|
+
if (!supportsImages && typeof message.content !== "string") {
|
|
427
|
+
const content = replaceImagesWithPlaceholder(message.content, message.role === "user" ? NON_VISION_USER_IMAGE_PLACEHOLDER : NON_VISION_TOOL_IMAGE_PLACEHOLDER);
|
|
428
|
+
if (!Object.isFrozen(message) || content !== message.content) message = {
|
|
429
|
+
...message,
|
|
430
|
+
content
|
|
431
|
+
};
|
|
432
|
+
}
|
|
427
433
|
if (message.role === "toolResult") {
|
|
428
434
|
const trimmedId = message.toolCallId.trim();
|
|
429
435
|
const toolCallId = toolCallIdMap.get(trimmedId) ?? trimmedId;
|
|
@@ -492,6 +498,7 @@ const inertAiTransportHost = {
|
|
|
492
498
|
inheritManagedTransport: (_source, target) => target,
|
|
493
499
|
transformTransportMessages: (messages, model, normalizeToolCallId) => transformMessages(messages, model, normalizeToolCallId),
|
|
494
500
|
registerCustomApi: queueCustomApiRegistration,
|
|
501
|
+
isLogEnabled: () => true,
|
|
495
502
|
logDebug: () => {},
|
|
496
503
|
logInfo: () => {},
|
|
497
504
|
logWarn: () => {}
|
|
@@ -578,4 +585,4 @@ function resolveAiTransportHeaderSentinels(headers) {
|
|
|
578
585
|
return resolvedHeaders ?? headers;
|
|
579
586
|
}
|
|
580
587
|
//#endregion
|
|
581
|
-
export { getSupportedThinkingLevels as A,
|
|
588
|
+
export { getSupportedThinkingLevels as A, resolveAnthropicThinkingEffort as C, applyProviderReportedUsageCost as D, headersToRecord as E, hasMediaPayload as M, isImageWithMediaPayload as N, calculateCost as O, requiresClaudeAdaptiveThinking as S, usesClaudeStreamingRefusalContract as T, buildAnthropicClaudeCodeIdentity as _, resolveAiTransportHeaderSentinels as a, prepareClaudeNoPrefillRequestContext as b, transformMessages as c, hasOnlyAssistantReasoningContent as d, isReasoningOnlyLengthAssistantTurn as f, applyClaudeRequestContract as g, ANTHROPIC_CLAUDE_CODE_VERSION as h, getDefaultAiTransportHost as i, modelsAreEqual as j, clampThinkingLevel as k, FAILED_ASSISTANT_REPLAY_TEXT as l, resolveFailedAssistantReplay as m, createAiTransportHost as n, runWithAiTransportHost as o, isStreamErrorFallbackContent as p, getAiTransportHost as r, supportsScopedAiTransportHosts as s, configureAiTransportHost as t, STREAM_ERROR_FALLBACK_TEXT as u, defaultsClaudeAdaptiveThinking as v, usesClaudeFable5MessagesContract as w, prepareModelBoundThinkingReplay as x, mapAnthropicStopReason as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
3
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
1
|
+
import { M as ModelRequestHeaders, d as Context, k as Model, n as Api, rt as StreamFn } from "./types-BVdTf0YV.mjs";
|
|
2
|
+
import "./index-Bczt0MnO.mjs";
|
|
3
|
+
import { n as ApiRegistry } from "./api-registry-DY2MLUyg.mjs";
|
|
4
4
|
//#region packages/ai/src/host.d.ts
|
|
5
5
|
/** Provider capability facts needed by the package-owned transports. */
|
|
6
6
|
interface AiProviderRequestCapabilities {
|
|
@@ -148,21 +148,29 @@ interface AiTransportHost {
|
|
|
148
148
|
provider?: string;
|
|
149
149
|
api?: string;
|
|
150
150
|
baseUrl?: string;
|
|
151
|
-
providerHeaders?:
|
|
152
|
-
callerHeaders?:
|
|
151
|
+
providerHeaders?: ModelRequestHeaders;
|
|
152
|
+
callerHeaders?: ModelRequestHeaders;
|
|
153
153
|
precedence?: "caller-wins" | "defaults-win";
|
|
154
154
|
model?: object;
|
|
155
|
-
}):
|
|
155
|
+
}): ModelRequestHeaders | undefined;
|
|
156
156
|
/** Returns the host-configured request timeout attached to a model. */
|
|
157
157
|
resolveModelRequestTimeoutMs(model: Model): number | undefined;
|
|
158
|
-
/**
|
|
159
|
-
requiresManagedTransport(model: Model): boolean;
|
|
158
|
+
/** With scope "fetch", requires guarded fetch dispatch; native WebSockets must also exclude it. */
|
|
159
|
+
requiresManagedTransport(model: Model, scope?: "fetch"): boolean;
|
|
160
160
|
/** Copies host-owned managed-transport state onto a projected model. */
|
|
161
161
|
inheritManagedTransport(source: Model, target: Model): Model;
|
|
162
|
+
/** Host-owned deep-immutability proof; absent hosts simply convert each request. */
|
|
163
|
+
immutableData?: {
|
|
164
|
+
isPlainData?(this: void, value: unknown): boolean;
|
|
165
|
+
isDeeplyFrozenPlainData(value: unknown): boolean;
|
|
166
|
+
freezeJsonSnapshot<T>(value: T): T;
|
|
167
|
+
};
|
|
162
168
|
/** Applies host-owned transcript replay and pairing rules. */
|
|
163
169
|
transformTransportMessages: AiTransformTransportMessages;
|
|
164
170
|
/** Registers a custom transport API with the host's stream error bridge. */
|
|
165
171
|
registerCustomApi(registry: ApiRegistry, api: Api, streamFn: StreamFn): boolean;
|
|
172
|
+
/** Optional for existing embedding hosts; omitted means the host decides at emission. */
|
|
173
|
+
isLogEnabled?(subsystem: string, level: "debug" | "info" | "warn"): boolean;
|
|
166
174
|
/**
|
|
167
175
|
* Emits one transport diagnostic; build runs only when the host logs it and
|
|
168
176
|
* may return null to suppress the entry (e.g. de-duplication).
|
|
@@ -192,6 +200,6 @@ declare function configureAiTransportHost(host: Partial<AiTransportHost>): void;
|
|
|
192
200
|
/** Returns the active transport host (inert defaults unless configured). */
|
|
193
201
|
declare function getAiTransportHost(): ActiveAiTransportHost;
|
|
194
202
|
/** Resolves sentinel substrings in custom headers at a no-fetch adapter boundary. */
|
|
195
|
-
declare function resolveAiTransportHeaderSentinels(headers:
|
|
203
|
+
declare function resolveAiTransportHeaderSentinels(headers: ModelRequestHeaders | undefined): ModelRequestHeaders | undefined;
|
|
196
204
|
//#endregion
|
|
197
205
|
export { supportsScopedAiTransportHosts as _, AiProviderRequestPolicyInput as a, AiTransportHost as c, configureAiTransportHost as d, createAiTransportHost as f, runWithAiTransportHost as g, resolveAiTransportHeaderSentinels as h, AiProviderRequestCapabilities as i, AiTransportPluginHost as l, getDefaultAiTransportHost as m, AiInlineImageBlock as n, AiProviderStreamHookContext as o, getAiTransportHost as p, AiInlineTextBlock as r, AiTransformTransportMessages as s, AiInlineContentBlock as t, OpenAIStrictToolSettingOptions as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as getAiTransportHost } from "./host-
|
|
1
|
+
import { r as getAiTransportHost } from "./host-DX7ORpeH.mjs";
|
|
2
2
|
//#region packages/ai/src/transports/host-policy.ts
|
|
3
3
|
function buildGuardedModelFetch(model, timeoutMs, options) {
|
|
4
4
|
const host = getAiTransportHost();
|
|
@@ -8,7 +8,7 @@ function buildGuardedModelFetch(model, timeoutMs, options) {
|
|
|
8
8
|
}
|
|
9
9
|
/** SDKs keep their default transport unless their embedding owner requires an explicit one. */
|
|
10
10
|
function buildManagedModelFetch(model, host = getAiTransportHost()) {
|
|
11
|
-
if (!host.requiresManagedTransport(model)) return;
|
|
11
|
+
if (!host.requiresManagedTransport(model, "fetch")) return;
|
|
12
12
|
const fetcher = host.buildModelFetch(model);
|
|
13
13
|
if (!fetcher) throw new Error("The embedding host requires a managed provider transport");
|
|
14
14
|
return fetcher;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { A as ModelCostConfig, M as ModelRequestHeaders, Q as RawModelCostConfig, a as AssistantMessage, gt as Usage } from "./types-BVdTf0YV.mjs";
|
|
2
|
+
import "./event-stream-BYmtRe8-.mjs";
|
|
3
|
+
import "./validation-QmyD0E5A.mjs";
|
|
4
|
+
//#region packages/llm-core/src/usage-cost.d.ts
|
|
5
|
+
declare function normalizeModelCostConfig(cost: RawModelCostConfig): ModelCostConfig;
|
|
6
|
+
declare function normalizeResolvedPricing(cost: Partial<RawModelCostConfig>): ModelCostConfig;
|
|
7
|
+
/** Price one model call, selecting its tier before billing the separate token buckets. */
|
|
8
|
+
declare function calculateUsageCost(usage: Partial<Pick<Usage, "input" | "output" | "cacheRead" | "cacheWrite" | "cacheWrite1h">>, pricing: RawModelCostConfig): Usage["cost"];
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region packages/llm-core/src/utils/assistant-message-events.d.ts
|
|
11
|
+
declare function appendTextDeltaToAssistantMessage(message: AssistantMessage, contentIndex: number, delta: string): AssistantMessage;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region packages/llm-core/src/utils/request-headers.d.ts
|
|
14
|
+
/** Materialize merged overrides for HTTP clients that cannot consume SDK deletion sentinels. */
|
|
15
|
+
declare function omitNullRequestHeaders(headers: ModelRequestHeaders | undefined): Record<string, string> | undefined;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { normalizeResolvedPricing as a, normalizeModelCostConfig as i, appendTextDeltaToAssistantMessage as n, calculateUsageCost as r, omitNullRequestHeaders as t };
|