@openclaw/ai 2026.9.1 → 2026.9.3
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 +3 -2
- package/dist/anthropic-CZy5U0NY.mjs +376 -0
- package/dist/anthropic-payload-policy-wuRCb6MH.d.mts +85 -0
- package/dist/anthropic-stream-reducer-B_yo_7pf.mjs +1669 -0
- package/dist/{api-registry-Cs6HGNqY.d.mts → api-registry-CB1-1oQ2.d.mts} +2 -2
- package/dist/assistant-output-iqnlJCV2.mjs +16 -0
- package/dist/assistant-text-phase-C20rxWwP.mjs +55 -0
- package/dist/{azure-openai-responses-CN4Fy5zV.mjs → azure-openai-responses-Crpa40QR.mjs} +5 -5
- package/dist/{base64-CEFBpSkN.mjs → base64-D-su8YVo.mjs} +1 -27
- package/dist/{diagnostics-KhXK-QJI.mjs → diagnostics-dV98PqIy.mjs} +96 -21
- package/dist/diagnostics.d.mts +3 -1
- package/dist/diagnostics.mjs +3 -3
- package/dist/{event-stream-vK_7r3bj.d.mts → event-stream-C1Z2piyk.d.mts} +11 -3
- package/dist/{event-stream-uSMZJ3FA.mjs → event-stream-D8PARQfL.mjs} +48 -10
- package/dist/event-stream-I_GlBsuZ.d.mts +1 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{github-copilot-headers-NCJtz9i0.mjs → github-copilot-headers-B37TB3rB.mjs} +3 -10
- package/dist/github-copilot-request-facts-BTEBMeOv.mjs +16 -0
- package/dist/{google-CC-nrwXg.mjs → google-BDPriaVe.mjs} +10 -10
- package/dist/google-messages-CVn9eFpF.mjs +449 -0
- package/dist/google-shared-BedY23XS.mjs +185 -0
- package/dist/{google-vertex-DCr0pyzQ.mjs → google-vertex-DMz8XQCn.mjs} +7 -6
- package/dist/{host-BIaiBURL.mjs → host-CWuF-sS3.mjs} +84 -34
- package/dist/{host-BztR4tQj.d.mts → host-DK3wmS3e.d.mts} +3 -3
- package/dist/host-policy-CAopLRKA.mjs +37 -0
- package/dist/{index-AfaxKT8w.d.mts → index-CQ6LTHw8.d.mts} +11 -5
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +5 -5
- package/dist/internal/anthropic.d.mts +14 -11
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/google-model-family.d.mts +5 -0
- package/dist/internal/google-model-family.mjs +15 -0
- package/dist/internal/openai-responses-payload-policy.d.mts +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +1 -1
- package/dist/internal/openai.d.mts +8 -103
- package/dist/internal/openai.mjs +10 -10
- package/dist/internal/retry-after.d.mts +2 -4
- package/dist/internal/retry-after.mjs +57 -8
- package/dist/internal/runtime.d.mts +7 -6
- package/dist/internal/runtime.mjs +8 -7
- package/dist/internal/shared.d.mts +14 -3
- package/dist/internal/shared.mjs +6 -4
- package/dist/internal/tool-schema.d.mts +63 -0
- package/dist/internal/tool-schema.mjs +3 -0
- package/dist/{json-parse-BuAJEbdW.mjs → json-parse-Dw_hnxsA.mjs} +1 -1
- package/dist/{mistral-B7etBd_H.mjs → mistral--m-Jm6VZ.mjs} +16 -38
- package/dist/model-transport-url-DKocrEsb.d.mts +28 -0
- package/dist/{openai-chatgpt-responses-BAJ4gq3i.mjs → openai-chatgpt-responses-nDZccFW-.mjs} +62 -54
- package/dist/openai-completions-KuoZyx0d.mjs +187 -0
- package/dist/{openai-completions-compat-4IjSBpr6.d.mts → openai-completions-compat-CXn3T1we.d.mts} +26 -4
- package/dist/{openai-completions-stream-DZjwK8vp.mjs → openai-completions-stream-BQk3SkLD.mjs} +621 -451
- package/dist/openai-prompt-cache-BI0rkM-5.mjs +220 -0
- package/dist/openai-prompt-cache-rrutvqxq.d.mts +16 -0
- package/dist/openai-provider-client-ha_WxTyj.mjs +24 -0
- package/dist/openai-reasoning-effort-BK7FbcLT.mjs +167 -0
- package/dist/{openai-responses-BEUlxfDu.mjs → openai-responses-D99dOzKI.mjs} +14 -32
- package/dist/{openai-responses-compaction-window-DO7yV7az.mjs → openai-responses-compaction-window-D5jbzCi3.mjs} +7 -159
- package/dist/{openai-responses-contracts-bPzSN_Ba.d.mts → openai-responses-contracts-B55afwRo.d.mts} +12 -4
- package/dist/{openai-responses-prompt-observer-internal-C7x4IK7r.mjs → openai-responses-prompt-observer-internal-tApyTLVu.mjs} +3 -3
- package/dist/{openai-responses-shared-DiAdpNAM.mjs → openai-responses-shared-ZyQEzS5i.mjs} +217 -212
- package/dist/openai-tool-projection-793cE3QX.d.mts +37 -0
- package/dist/{openai-tool-schema-BMiHFH36.mjs → openai-tool-schema-CzjyYXun.mjs} +53 -583
- package/dist/openai-tool-schema-ynZBgqW-.d.mts +38 -0
- package/dist/openai-transport-params-DNasp2fU.mjs +674 -0
- package/dist/{provider-error-B6EGq6gg.mjs → provider-error-C6TbKiey.mjs} +29 -13
- package/dist/{provider-options-CxFPtvh7.d.mts → provider-options-BXr9Ec83.d.mts} +19 -42
- package/dist/provider-replay-context-BuSUaAk5.mjs +21 -0
- package/dist/{provider-transcript-transform-WvJmFUAf.mjs → provider-transcript-transform-pPmUIwKt.mjs} +1 -1
- package/dist/provider-types-CAV0Og3m.d.mts +29 -0
- package/dist/provider-types.d.mts +6 -31
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +11 -11
- package/dist/{reasoning-tag-text-partitioner-C-4uedDb.mjs → reasoning-tag-text-partitioner-BQBi4B9d.mjs} +90 -35
- package/dist/record-coerce-DwRYMj3t.mjs +32 -0
- package/dist/retry-after-CdCURCVg.d.mts +15 -0
- package/dist/{sanitize-unicode-S6binQG-.mjs → sanitize-unicode-Bb-v9meu.mjs} +1 -1
- package/dist/session-affinity-CCH7eYdB.mjs +20 -0
- package/dist/{simple-options-0PLDyJ-d.mjs → simple-options-tcKOqnpF.mjs} +3 -3
- package/dist/{src-C8U7lkoa.mjs → src-B2Q_6G8V.mjs} +10 -2
- package/dist/{stream-first-event-timeout-DcNjoFQE.mjs → stream-first-event-timeout-2hfrquuz.mjs} +1 -1
- package/dist/string-coerce-fsri9iCu.mjs +34 -0
- package/dist/{string-normalization--fwJ4S2q.mjs → string-normalization-CmLIasuf.mjs} +1 -1
- package/dist/{tool-schema-json-projection-BtZiml7r.mjs → tool-schema-json-projection-ClptDdAO.mjs} +2 -38
- package/dist/{transport-stream-shared-CytPVLIg.mjs → transport-stream-shared-Cu3ZPhNW.mjs} +5 -5
- package/dist/{transport-stream-shared-BrvFTkoO.d.mts → transport-stream-shared-DOxpGJ-H.d.mts} +4 -4
- package/dist/transport-utils-CCooe-cr.mjs +121 -0
- package/dist/transports.d.mts +114 -41
- package/dist/transports.mjs +796 -1596
- package/dist/types-BADKjDBI.d.mts +1 -0
- package/dist/{types-DbrhszyQ.d.mts → types-Dy1q0CSu.d.mts} +101 -64
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +4 -4
- package/dist/utf16-slice-CvGodqok.mjs +29 -0
- package/dist/{validation-CJZtym2g.mjs → validation-BDzVDnTs.mjs} +9 -1
- package/dist/{validation-BOwtcl9X.d.mts → validation-CaFUZN9B.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +14 -4
- package/dist/anthropic-compaction-replay-OMJZ0uyo.mjs +0 -838
- package/dist/anthropic-hk7F7ptG.mjs +0 -883
- package/dist/anthropic-payload-policy-DBT1itQ-.d.mts +0 -51
- package/dist/event-stream-DeDhbCc5.d.mts +0 -1
- package/dist/google-shared-CjPY0hZM.mjs +0 -634
- package/dist/google-thinking-level-C-V3tecN.mjs +0 -9
- package/dist/openai-completions-D0QZ0AyB.mjs +0 -403
- package/dist/openai-prompt-cache-2uo_1OR1.d.mts +0 -7
- package/dist/openai-prompt-cache-mZTCdRPo.mjs +0 -12
- package/dist/transport-utils-CtuS1Upe.mjs +0 -138
- package/dist/types-B5EFUmXs.d.mts +0 -1
- package/dist/utf16-slice-qz3nsy87.mjs +0 -84
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as requiresClaudeMandatoryAdaptiveThinking, p as resolveClaudeNativeThinkingLevelMap, t as calculateUsageCost } from "./src-B2Q_6G8V.mjs";
|
|
2
2
|
//#region packages/ai/src/model-utils.ts
|
|
3
3
|
/** Calculates and stores model cost fields from token usage and per-million pricing. */
|
|
4
4
|
function calculateCost(model, usage) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region packages/ai/src/transports/session-affinity.ts
|
|
2
|
+
function isOpencodeEndpoint(baseUrl) {
|
|
3
|
+
try {
|
|
4
|
+
const url = new URL(baseUrl);
|
|
5
|
+
return url.protocol === "https:" && url.hostname.replace(/\.$/, "") === "opencode.ai";
|
|
6
|
+
} catch {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Required conversation identity is independent of optional prompt caching. */
|
|
11
|
+
function resolveOpencodeSessionHeaders(model, options) {
|
|
12
|
+
if (!options?.sessionId || !isOpencodeEndpoint(model.baseUrl)) return options?.headers;
|
|
13
|
+
if ([model.headers, options.headers].some((headers) => Object.keys(headers ?? {}).some((name) => name.toLowerCase() === "x-opencode-session"))) return options.headers;
|
|
14
|
+
return {
|
|
15
|
+
...options.headers,
|
|
16
|
+
"x-opencode-session": options.sessionId
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { resolveOpencodeSessionHeaders as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as sanitizeSurrogates } from "./sanitize-unicode-
|
|
3
|
-
import { r as copyProviderAcceptanceObserver } from "./transport-stream-shared-
|
|
1
|
+
import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.mjs";
|
|
2
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-Bb-v9meu.mjs";
|
|
3
|
+
import { r as copyProviderAcceptanceObserver } from "./transport-stream-shared-Cu3ZPhNW.mjs";
|
|
4
4
|
//#region packages/ai/src/utils/prompt-cache-stability.ts
|
|
5
5
|
/**
|
|
6
6
|
* Prompt-cache normalization helpers. They keep generated prompt sections
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./validation-
|
|
1
|
+
import "./validation-BDzVDnTs.mjs";
|
|
2
2
|
//#region packages/llm-core/src/model-contracts/anthropic.ts
|
|
3
3
|
function normalizeClaudeModelId(modelId) {
|
|
4
4
|
const normalized = modelId?.trim().toLowerCase() ?? "";
|
|
@@ -51,6 +51,14 @@ function resolveClaudeMythos5ModelIdentity(ref) {
|
|
|
51
51
|
if (!match) return;
|
|
52
52
|
return normalized.slice((match.index ?? 0) + (match[0].startsWith("-") ? 1 : 0));
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Anthropic binds thinking to the conversation prefix starting with Fable 5.1 and
|
|
56
|
+
* plans to enforce it on later models. Extend only with live replay proof for the
|
|
57
|
+
* new model (Mythos 5.1 is unregistered here and unproven).
|
|
58
|
+
*/
|
|
59
|
+
function bindsClaudeThinkingPrefix(ref) {
|
|
60
|
+
return /^claude-fable-5-1(?=$|[^a-z0-9])/.test(resolveClaudeModelIdentity(ref));
|
|
61
|
+
}
|
|
54
62
|
/** Return whether a Claude model requires adaptive thinking instead of manual budgets. */
|
|
55
63
|
function requiresClaudeMandatoryAdaptiveThinking(ref) {
|
|
56
64
|
const modelId = resolveClaudeModelIdentity(ref);
|
|
@@ -187,4 +195,4 @@ function calculateUsageCost(usage, pricing) {
|
|
|
187
195
|
return cost;
|
|
188
196
|
}
|
|
189
197
|
//#endregion
|
|
190
|
-
export {
|
|
198
|
+
export { supportsClaudeAdaptiveThinking as _, CLAUDE_OPUS_5_THINKING_PROFILE as a, supportsClaudeNativeXhighEffort as b, requiresClaudeDefaultSampling as c, resolveClaudeModelIdentity as d, resolveClaudeMythos5ModelIdentity as f, supportsClaude1MContext as g, resolveClaudeSonnet5ModelIdentity as h, CLAUDE_FABLE_5_THINKING_PROFILE as i, requiresClaudeMandatoryAdaptiveThinking as l, resolveClaudeOpus5ModelIdentity as m, normalizeModelCostConfig as n, CLAUDE_SONNET_5_THINKING_PROFILE as o, resolveClaudeNativeThinkingLevelMap as p, normalizeResolvedPricing as r, bindsClaudeThinkingPrefix as s, calculateUsageCost as t, resolveClaudeFable5ModelIdentity as u, supportsClaudeFastMode as v, supportsClaudeNativeMaxEffort as y };
|
package/dist/{stream-first-event-timeout-DcNjoFQE.mjs → stream-first-event-timeout-2hfrquuz.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as clampTimerTimeoutMs } from "./base64-D-su8YVo.mjs";
|
|
2
2
|
//#region packages/ai/src/utils/stream-first-event-timeout.ts
|
|
3
3
|
function getFirstStreamEventTimeoutMs(options) {
|
|
4
4
|
return options?.firstEventTimeoutMs;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region packages/normalization-core/src/string-coerce.ts
|
|
2
|
+
/** Reads a value only when it is already a string, preserving whitespace. */
|
|
3
|
+
function readStringValue(value) {
|
|
4
|
+
return typeof value === "string" ? value : void 0;
|
|
5
|
+
}
|
|
6
|
+
/** Trims string input and returns null for non-strings or empty strings. */
|
|
7
|
+
function normalizeNullableString(value) {
|
|
8
|
+
if (typeof value !== "string") return null;
|
|
9
|
+
const trimmed = value.trim();
|
|
10
|
+
return trimmed ? trimmed : null;
|
|
11
|
+
}
|
|
12
|
+
/** Trims string input and returns undefined for non-strings or empty strings. */
|
|
13
|
+
function normalizeOptionalString(value) {
|
|
14
|
+
return normalizeNullableString(value) ?? void 0;
|
|
15
|
+
}
|
|
16
|
+
/** Stringifies primitive ids/flags before applying optional string normalization. */
|
|
17
|
+
function normalizeStringifiedOptionalString(value) {
|
|
18
|
+
if (typeof value === "string") return normalizeOptionalString(value);
|
|
19
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return normalizeOptionalString(String(value));
|
|
20
|
+
}
|
|
21
|
+
/** Lowercases a normalized optional string. */
|
|
22
|
+
function normalizeOptionalLowercaseString(value) {
|
|
23
|
+
return normalizeOptionalString(value)?.toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
/** Lowercases a normalized string or returns an empty string when absent. */
|
|
26
|
+
function normalizeLowercaseStringOrEmpty(value) {
|
|
27
|
+
return normalizeOptionalLowercaseString(value) ?? "";
|
|
28
|
+
}
|
|
29
|
+
/** Type guard for strings that remain non-empty after trimming. */
|
|
30
|
+
function hasNonEmptyString(value) {
|
|
31
|
+
return normalizeOptionalString(value) !== void 0;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { normalizeOptionalString as a, normalizeOptionalLowercaseString as i, normalizeLowercaseStringOrEmpty as n, normalizeStringifiedOptionalString as o, normalizeNullableString as r, readStringValue as s, hasNonEmptyString as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as normalizeOptionalString } from "./string-coerce-fsri9iCu.mjs";
|
|
2
2
|
//#region packages/normalization-core/src/string-normalization.ts
|
|
3
3
|
/** Coerces entries to strings, trims them, and drops empty results. */
|
|
4
4
|
function normalizeStringEntries(list) {
|
package/dist/{tool-schema-json-projection-BtZiml7r.mjs → tool-schema-json-projection-ClptDdAO.mjs}
RENAMED
|
@@ -1,41 +1,5 @@
|
|
|
1
|
-
import { o as isRecord } from "./
|
|
2
|
-
import { n as getAiTransportHost } from "./host-BIaiBURL.mjs";
|
|
1
|
+
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
3
2
|
import { types } from "node:util";
|
|
4
|
-
//#region packages/ai/src/transports/host-policy.ts
|
|
5
|
-
function buildGuardedModelFetch(model, timeoutMs, options) {
|
|
6
|
-
const host = getAiTransportHost();
|
|
7
|
-
if (options !== void 0) return host.buildModelFetch(model, timeoutMs, options) ?? globalThis.fetch;
|
|
8
|
-
if (timeoutMs !== void 0) return host.buildModelFetch(model, timeoutMs) ?? globalThis.fetch;
|
|
9
|
-
return host.buildModelFetch(model) ?? globalThis.fetch;
|
|
10
|
-
}
|
|
11
|
-
function resolveProviderEndpoint(model) {
|
|
12
|
-
return { endpointClass: getAiTransportHost().resolveProviderRequestCapabilities({
|
|
13
|
-
baseUrl: model.baseUrl,
|
|
14
|
-
model
|
|
15
|
-
}).endpointClass };
|
|
16
|
-
}
|
|
17
|
-
function resolveProviderRequestCapabilities(input, model) {
|
|
18
|
-
return getAiTransportHost().resolveProviderRequestCapabilities({
|
|
19
|
-
...input,
|
|
20
|
-
model
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function resolveProviderRequestPolicyConfig(model, input) {
|
|
24
|
-
return { headers: getAiTransportHost().resolveProviderRequestHeaders({
|
|
25
|
-
...input,
|
|
26
|
-
model
|
|
27
|
-
}) };
|
|
28
|
-
}
|
|
29
|
-
function resolveModelRequestTimeoutMs(model, timeoutMs) {
|
|
30
|
-
return timeoutMs ?? getAiTransportHost().resolveModelRequestTimeoutMs(model);
|
|
31
|
-
}
|
|
32
|
-
function resolveOpenAIStrictToolSetting(model, options) {
|
|
33
|
-
return getAiTransportHost().resolveOpenAIStrictToolSetting(model, options);
|
|
34
|
-
}
|
|
35
|
-
function transformTransportMessages(messages, model, normalizeToolCallId, options) {
|
|
36
|
-
return getAiTransportHost().transformTransportMessages(messages, model, normalizeToolCallId, options);
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
3
|
//#region packages/ai/src/providers/tool-schema-json-projection.ts
|
|
40
4
|
function isNonFiniteNumberValue(value) {
|
|
41
5
|
if (typeof value === "number") return !Number.isFinite(value);
|
|
@@ -115,4 +79,4 @@ function projectRuntimeToolInputSchema(schema, path = "parameters") {
|
|
|
115
79
|
};
|
|
116
80
|
}
|
|
117
81
|
//#endregion
|
|
118
|
-
export {
|
|
82
|
+
export { projectRuntimeToolInputSchema as t };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-CPeq9F7y.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { n as projectProviderError, r as projectDiagnosticValue } from "./provider-error-
|
|
6
|
-
import {
|
|
2
|
+
import { i as createAssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
3
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-Bb-v9meu.mjs";
|
|
4
|
+
import { i as asOptionalRecord, n as asNullableRecord, t as asNonArrayRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
5
|
+
import { n as projectProviderError, r as projectDiagnosticValue } from "./provider-error-C6TbKiey.mjs";
|
|
6
|
+
import { c as isTransientNetworkError } from "./diagnostics-dV98PqIy.mjs";
|
|
7
7
|
//#region packages/ai/src/utils/headers.ts
|
|
8
8
|
/** Converts a Headers object to a plain record for provider request handling. */
|
|
9
9
|
function headersToRecord(headers) {
|
package/dist/{transport-stream-shared-BrvFTkoO.d.mts → transport-stream-shared-DOxpGJ-H.d.mts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { B as ProviderResponse, D as Model, J as StreamOptions, a as AssistantMessage, at as Usage } from "./types-
|
|
3
|
-
import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
4
|
-
import "./event-stream-
|
|
1
|
+
import "./index-CQ6LTHw8.mjs";
|
|
2
|
+
import { B as ProviderResponse, D as Model, J as StreamOptions, a as AssistantMessage, at as Usage } from "./types-Dy1q0CSu.mjs";
|
|
3
|
+
import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-C1Z2piyk.mjs";
|
|
4
|
+
import "./event-stream-I_GlBsuZ.mjs";
|
|
5
5
|
import { t as ProviderErrorProjection } from "./provider-error-CzNw4BWX.mjs";
|
|
6
6
|
//#region packages/ai/src/utils/stream-first-event-timeout.d.ts
|
|
7
7
|
type StreamStage = "responses" | "completions";
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { n as getAiTransportHost } from "./host-CWuF-sS3.mjs";
|
|
2
|
+
import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
|
|
3
|
+
import { o as parseStrictPositiveInteger } from "./base64-D-su8YVo.mjs";
|
|
4
|
+
import "./internal/retry-after.mjs";
|
|
5
|
+
//#region packages/normalization-core/src/response-bytes.ts
|
|
6
|
+
async function consumeResponseBytes(options) {
|
|
7
|
+
let size = 0;
|
|
8
|
+
while (true) {
|
|
9
|
+
const { done, value } = await options.read();
|
|
10
|
+
if (done) return {
|
|
11
|
+
size,
|
|
12
|
+
truncated: false
|
|
13
|
+
};
|
|
14
|
+
if (options.skipEmptyChunks !== false && !value?.length) continue;
|
|
15
|
+
const remaining = options.maxBytes - size;
|
|
16
|
+
size += value.length;
|
|
17
|
+
if (size > options.maxBytes || options.stopAtLimit && size === options.maxBytes) {
|
|
18
|
+
if (remaining > 0) options.onChunk(value.subarray(0, remaining));
|
|
19
|
+
await options.onLimit(size);
|
|
20
|
+
return {
|
|
21
|
+
size,
|
|
22
|
+
truncated: true
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
options.onChunk(value);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region packages/ai/src/transports/transport-utils.ts
|
|
30
|
+
const MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE = "OpenClaw transport error: malformed_streaming_fragment";
|
|
31
|
+
const NON_LATIN_RE = /[\u2E80-\u9FFF\uA000-\uA4FF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFF60\uFFE0-\uFFE6\u{20000}-\u{2FA1F}]/gu;
|
|
32
|
+
const CJK_SURROGATE_HIGH_RE = /[\uD840-\uD87E][\uDC00-\uDFFF]/g;
|
|
33
|
+
function parsePositiveInteger(value) {
|
|
34
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value);
|
|
35
|
+
return typeof value === "string" ? parseStrictPositiveInteger(value) : void 0;
|
|
36
|
+
}
|
|
37
|
+
function redactSensitiveText(text, _options) {
|
|
38
|
+
return getAiTransportHost().redactToolPayloadText(text);
|
|
39
|
+
}
|
|
40
|
+
function resolveModelHeaderSentinels(model) {
|
|
41
|
+
if (!model.headers) return model;
|
|
42
|
+
let headers;
|
|
43
|
+
for (const [name, value] of Object.entries(model.headers)) {
|
|
44
|
+
const resolved = getAiTransportHost().resolveSecretSentinel(value);
|
|
45
|
+
if (resolved !== value) {
|
|
46
|
+
headers ??= { ...model.headers };
|
|
47
|
+
headers[name] = resolved;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return headers ? {
|
|
51
|
+
...model,
|
|
52
|
+
headers
|
|
53
|
+
} : model;
|
|
54
|
+
}
|
|
55
|
+
function createAbortError(message, options) {
|
|
56
|
+
const error = new Error(message, options);
|
|
57
|
+
error.name = "AbortError";
|
|
58
|
+
return error;
|
|
59
|
+
}
|
|
60
|
+
function estimateStringChars(text) {
|
|
61
|
+
if (!text) return 0;
|
|
62
|
+
const nonLatinCount = (text.match(NON_LATIN_RE) ?? []).length;
|
|
63
|
+
return (nonLatinCount === 0 ? text.length : text.length - (text.match(CJK_SURROGATE_HIGH_RE) ?? []).length) + nonLatinCount * 3;
|
|
64
|
+
}
|
|
65
|
+
function supportsModelTools(model) {
|
|
66
|
+
return (model.compat && typeof model.compat === "object" ? model.compat : void 0)?.supportsTools !== false;
|
|
67
|
+
}
|
|
68
|
+
function isCodeModeModelVisibleToolName(name, visibleToolNames) {
|
|
69
|
+
return visibleToolNames.has(name);
|
|
70
|
+
}
|
|
71
|
+
async function readChunkWithIdleTimeout(reader, timeoutMs, onIdleTimeout) {
|
|
72
|
+
let timer;
|
|
73
|
+
try {
|
|
74
|
+
return await Promise.race([reader.read(), new Promise((_resolve, reject) => {
|
|
75
|
+
timer = setTimeout(() => reject(onIdleTimeout?.({ chunkTimeoutMs: timeoutMs }) ?? /* @__PURE__ */ new Error("Read timed out")), timeoutMs);
|
|
76
|
+
})]);
|
|
77
|
+
} finally {
|
|
78
|
+
if (timer) clearTimeout(timer);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function readResponseTextSnippet(response, options) {
|
|
82
|
+
const maxBytes = options?.maxBytes ?? 8192;
|
|
83
|
+
const maxChars = options?.maxChars ?? 200;
|
|
84
|
+
const reader = response.body?.getReader();
|
|
85
|
+
if (!reader) return;
|
|
86
|
+
const chunks = [];
|
|
87
|
+
let bytes = 0;
|
|
88
|
+
let truncated = false;
|
|
89
|
+
try {
|
|
90
|
+
if (bytes < maxBytes) {
|
|
91
|
+
const result = await consumeResponseBytes({
|
|
92
|
+
maxBytes,
|
|
93
|
+
stopAtLimit: true,
|
|
94
|
+
read: () => options?.chunkTimeoutMs ? readChunkWithIdleTimeout(reader, options.chunkTimeoutMs, options.onIdleTimeout) : reader.read(),
|
|
95
|
+
onChunk: (chunk) => chunks.push(chunk),
|
|
96
|
+
onLimit: async () => {
|
|
97
|
+
await reader.cancel().catch(() => void 0);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
bytes = Math.min(result.size, maxBytes);
|
|
101
|
+
truncated = result.truncated;
|
|
102
|
+
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
await reader.cancel(error).catch(() => void 0);
|
|
105
|
+
throw error;
|
|
106
|
+
} finally {
|
|
107
|
+
reader.releaseLock();
|
|
108
|
+
}
|
|
109
|
+
const merged = new Uint8Array(bytes);
|
|
110
|
+
let offset = 0;
|
|
111
|
+
for (const chunk of chunks) {
|
|
112
|
+
merged.set(chunk, offset);
|
|
113
|
+
offset += chunk.length;
|
|
114
|
+
}
|
|
115
|
+
const collapsed = new TextDecoder().decode(merged).replace(/\s+/g, " ").trim();
|
|
116
|
+
if (!collapsed) return;
|
|
117
|
+
if (collapsed.length > maxChars) return `${truncateUtf16Safe(collapsed, maxChars)}…`;
|
|
118
|
+
return truncated ? `${collapsed}…` : collapsed;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { parsePositiveInteger as a, resolveModelHeaderSentinels as c, isCodeModeModelVisibleToolName as i, supportsModelTools as l, createAbortError as n, readResponseTextSnippet as o, estimateStringChars as r, redactSensitiveText as s, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as t };
|
package/dist/transports.d.mts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { D as Model, K as StreamFn, Q as ThinkingContent, Y as TextContent, a as AssistantMessage, at as Usage, d as Context, j as OpenAICompletionsCompat, n as Api, nt as ToolCall, o as AssistantMessageEvent, z as ProviderReplayState } from "./types-
|
|
3
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
4
|
-
import { a as
|
|
5
|
-
import "./
|
|
6
|
-
import
|
|
7
|
-
import { a as
|
|
1
|
+
import "./index-CQ6LTHw8.mjs";
|
|
2
|
+
import { D as Model, G as StopReason, K as StreamFn, Q as ThinkingContent, Y as TextContent, a as AssistantMessage, at as Usage, d as Context, j as OpenAICompletionsCompat, lt as ModelDataThinkingFormat, n as Api, nt as ToolCall, o as AssistantMessageEvent, tt as Tool, z as ProviderReplayState } from "./types-Dy1q0CSu.mjs";
|
|
3
|
+
import { n as ApiRegistry } from "./api-registry-CB1-1oQ2.mjs";
|
|
4
|
+
import { a as BaseOpenAIStreamOptions, c as OpenAIResponsesCompactionRejection, o as CodeModeToolSurfaceObservation, s as OpenAICompletionsOptions } from "./provider-options-BXr9Ec83.mjs";
|
|
5
|
+
import { n as OpenAIToolProjection } from "./openai-tool-projection-793cE3QX.mjs";
|
|
6
|
+
import "./types-BADKjDBI.mjs";
|
|
7
|
+
import { a as buildAnthropicSystemBlocks, c as logAnthropicContextEdits, d as resolveAnthropicEphemeralCacheControl, f as resolveAnthropicPayloadPolicy, i as applyAnthropicRequestCacheControl, l as resolveAnthropicCacheOptions, n as applyAnthropicEphemeralCacheControlMarkers, o as isAnthropicServerToolClearingEnabled, p as resolveAnthropicServerCompactionPlan, r as applyAnthropicPayloadPolicyToParams, s as isDirectAnthropicModel, t as applyAnthropicContextManagementToRequest, u as resolveAnthropicContextManagementBetaHeader } from "./anthropic-payload-policy-wuRCb6MH.mjs";
|
|
8
|
+
import { a as ReplayableResponseCompactionItem, c as OpenAIResponsesCompactionOutput, i as OpenAIResponsesRequestParams, n as OpenAIResponsesOptions, o as ResponsesPromptObservation, r as OpenAIResponsesReasoningReplayMetadata } from "./openai-responses-contracts-B55afwRo.mjs";
|
|
8
9
|
import { i as resolveOpenAIResponsesServerCompactionPlan, n as resolveOpenAIResponsesCompactEndpointPlan, r as resolveOpenAIResponsesPayloadPolicy, t as applyOpenAIResponsesPayloadPolicy } from "./openai-responses-payload-policy-rLRPsSmB.mjs";
|
|
9
|
-
import { n as detectOpenAICompletionsCompat, r as
|
|
10
|
-
import { C as FirstStreamEventInternalOptions, _ as sanitizeNonEmptyTransportPayloadText, a as copyProviderAcceptanceObserver, b as withProviderAcceptanceObserver, c as failTransportStream, d as mergeTransportHeaders, f as mergeTransportMetadata, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, i as coerceTransportToolCallArguments, l as finalizeTerminalToolCallArguments, m as notifyProviderHttpResponse, n as WritableTransportStream, o as createEmptyTransportUsage, p as notifyProviderHttpMetadata, r as assignTransportErrorDetails, s as createWritableTransportEventStream, t as ProviderAcceptance, u as finalizeTransportStream, v as sanitizeTransportPayloadText, x as withProviderResponseHook, y as transportAbortError } from "./transport-stream-shared-
|
|
10
|
+
import { a as resolveOpenAICompletionsCompat, i as isOpenAICodexResponsesModel, n as detectOpenAICompletionsCompat, o as resolveOpenAIPromptCacheKeySupport, r as isNativeOpenAIEndpoint, s as usesNativeOpenAICodexResponsesBackend, t as ResolvedOpenAICompletionsCompat } from "./openai-completions-compat-CXn3T1we.mjs";
|
|
11
|
+
import { C as FirstStreamEventInternalOptions, _ as sanitizeNonEmptyTransportPayloadText, a as copyProviderAcceptanceObserver, b as withProviderAcceptanceObserver, c as failTransportStream, d as mergeTransportHeaders, f as mergeTransportMetadata, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, i as coerceTransportToolCallArguments, l as finalizeTerminalToolCallArguments, m as notifyProviderHttpResponse, n as WritableTransportStream, o as createEmptyTransportUsage, p as notifyProviderHttpMetadata, r as assignTransportErrorDetails, s as createWritableTransportEventStream, t as ProviderAcceptance, u as finalizeTransportStream, v as sanitizeTransportPayloadText, x as withProviderResponseHook, y as transportAbortError } from "./transport-stream-shared-DOxpGJ-H.mjs";
|
|
11
12
|
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-Cwcjv_fx.mjs";
|
|
13
|
+
import { r as normalizeOpenAIStrictToolParameters } from "./openai-tool-schema-ynZBgqW-.mjs";
|
|
14
|
+
import { d as VideoContent, i as ProviderContext, s as ProviderModel } from "./provider-types-CAV0Og3m.mjs";
|
|
15
|
+
import { a as resolveModelSseDebugMode, i as resolveModelPayloadDebugMode, n as formatModelTransportDebugUrl, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./model-transport-url-DKocrEsb.mjs";
|
|
12
16
|
import OpenAI from "openai";
|
|
17
|
+
import { Part } from "@google/genai";
|
|
13
18
|
import { ResponseCreateParamsStreaming, ResponseInput, ResponseInputItem as ResponseInputItem$1 } from "openai/resources/responses/responses.js";
|
|
14
19
|
import { ChatCompletionChunk } from "openai/resources/chat/completions.js";
|
|
15
20
|
//#region packages/ai/src/transports/anthropic-transport-stream.d.ts
|
|
@@ -52,37 +57,18 @@ export declare function canonicalizeMaxTokensParam(params: {
|
|
|
52
57
|
sources: Array<Record<string, unknown> | undefined>;
|
|
53
58
|
}): void;
|
|
54
59
|
//#endregion
|
|
55
|
-
//#region packages/ai/src/transports/model-transport-debug.d.ts
|
|
56
|
-
type SubsystemLogger = {
|
|
57
|
-
info(message: string): void;
|
|
58
|
-
debug(message: string): void;
|
|
59
|
-
};
|
|
60
|
-
type ModelTransportDebugEnv = NodeJS.ProcessEnv;
|
|
61
|
-
/** Payload debug detail levels accepted by `OPENCLAW_DEBUG_MODEL_PAYLOAD`. */
|
|
62
|
-
type ModelPayloadDebugMode = "off" | "summary" | "tools" | "full-redacted";
|
|
63
|
-
/** SSE debug detail levels accepted by `OPENCLAW_DEBUG_SSE`. */
|
|
64
|
-
type ModelSseDebugMode = "off" | "events" | "peek";
|
|
65
|
-
/** Resolves model payload debug verbosity from `OPENCLAW_DEBUG_MODEL_PAYLOAD`. */
|
|
66
|
-
export declare function resolveModelPayloadDebugMode(env?: ModelTransportDebugEnv): ModelPayloadDebugMode;
|
|
67
|
-
/** Resolves SSE stream debug verbosity from `OPENCLAW_DEBUG_SSE`. */
|
|
68
|
-
export declare function resolveModelSseDebugMode(env?: ModelTransportDebugEnv): ModelSseDebugMode;
|
|
69
|
-
/** Emits model-fetch metadata at info level by default; other diagnostics require debug env. */
|
|
70
|
-
export declare function emitModelTransportDebug(log: SubsystemLogger, message: string): void;
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region packages/ai/src/transports/model-transport-url.d.ts
|
|
73
|
-
/**
|
|
74
|
-
* Debug formatting helpers for model transport endpoints.
|
|
75
|
-
* Keeps logs useful without exposing credentials, request params, or fragments.
|
|
76
|
-
*/
|
|
77
|
-
/** Return a sanitized URL suitable for logs and diagnostics. */
|
|
78
|
-
export declare function formatModelTransportDebugUrl(rawUrl: string): string;
|
|
79
|
-
/** Format a configured base URL for debug output, or the implicit default. */
|
|
80
|
-
export declare function formatModelTransportDebugBaseUrl(rawUrl: string | undefined): string;
|
|
81
|
-
//#endregion
|
|
82
60
|
//#region packages/ai/src/transports/openai-compatible-conversation-turn.d.ts
|
|
83
61
|
/** Returns whether an OpenAI-compatible messages payload contains a usable turn. */
|
|
84
62
|
export declare function hasOpenAICompatibleConversationTurn(messages: unknown): boolean;
|
|
85
63
|
//#endregion
|
|
64
|
+
//#region packages/ai/src/transports/openai-completions-cache-control.d.ts
|
|
65
|
+
type CacheControl = {
|
|
66
|
+
type: "ephemeral";
|
|
67
|
+
ttl?: "1h" | "5m";
|
|
68
|
+
};
|
|
69
|
+
/** Shared Chat Completions policy; repeated wrapper application preserves existing checkpoints. */
|
|
70
|
+
export declare function applyCompletionsAnthropicCacheControl(payload: Record<string, unknown>, cacheControl?: CacheControl | null, cacheOptOutIndexes?: ReadonlySet<number>, markTools?: boolean, markMessages?: boolean): void;
|
|
71
|
+
//#endregion
|
|
86
72
|
//#region packages/ai/src/transports/openai-completions-string-content.d.ts
|
|
87
73
|
/** Flatten string-only text block content arrays into newline-joined strings. */
|
|
88
74
|
export declare function flattenCompletionMessagesToStringContent(messages: unknown[]): unknown[];
|
|
@@ -160,7 +146,25 @@ export declare function isOpenAICompletionsThinkingEnabled(effort: string): bool
|
|
|
160
146
|
export declare function readOpenAICompletionsContentDeltas(content: unknown, topLevelRefusal?: unknown, mirroredThinking?: readonly string[]): OpenAICompletionsContentDelta[];
|
|
161
147
|
//#endregion
|
|
162
148
|
//#region packages/ai/src/transports/openai-completions-params.d.ts
|
|
163
|
-
|
|
149
|
+
declare function convertTools(tools: NonNullable<Context["tools"]>, compat: ResolvedOpenAICompletionsCompat, model: OpenAIModeModel, mode: "direct" | "managed"): {
|
|
150
|
+
projection: OpenAIToolProjection;
|
|
151
|
+
tools: {
|
|
152
|
+
type: "function";
|
|
153
|
+
function: {
|
|
154
|
+
name: string;
|
|
155
|
+
description: string | undefined;
|
|
156
|
+
parameters: ReturnType<typeof normalizeOpenAIStrictToolParameters>;
|
|
157
|
+
strict?: boolean;
|
|
158
|
+
};
|
|
159
|
+
}[];
|
|
160
|
+
};
|
|
161
|
+
export declare function buildOpenAICompletionsParams(model: OpenAIModeModel, context: Context, options: OpenAICompletionsOptions | undefined): CompletionsRequest;
|
|
162
|
+
type CompletionsRequest = Record<string, unknown> & {
|
|
163
|
+
model: string;
|
|
164
|
+
messages: unknown[];
|
|
165
|
+
stream: true;
|
|
166
|
+
tools?: ReturnType<typeof convertTools>["tools"];
|
|
167
|
+
};
|
|
164
168
|
//#endregion
|
|
165
169
|
//#region packages/ai/src/transports/openai-completions-transport.d.ts
|
|
166
170
|
export declare function createOpenAICompletionsTransportStreamFn(): StreamFn;
|
|
@@ -285,6 +289,7 @@ type ResponsesEventSink = {
|
|
|
285
289
|
//#endregion
|
|
286
290
|
//#region packages/ai/src/transports/openai-responses-stream-types-internal.d.ts
|
|
287
291
|
type ResponsesStreamOptions = FirstStreamEventInternalOptions & {
|
|
292
|
+
asyncToolExecution?: boolean;
|
|
288
293
|
serviceTier?: ResponseCreateParamsStreaming["service_tier"];
|
|
289
294
|
resolveServiceTier?: (responseServiceTier: ResponseCreateParamsStreaming["service_tier"] | undefined, requestServiceTier: ResponseCreateParamsStreaming["service_tier"] | undefined) => ResponseCreateParamsStreaming["service_tier"] | undefined;
|
|
290
295
|
applyServiceTierPricing?: (usage: Usage, serviceTier: ResponseCreateParamsStreaming["service_tier"] | undefined) => void;
|
|
@@ -305,8 +310,6 @@ export declare function resolveOpenAIStrictToolFlagWithDiagnostics(projection: O
|
|
|
305
310
|
transport: "responses" | "completions";
|
|
306
311
|
model: OpenAIModeModel;
|
|
307
312
|
}): boolean | undefined;
|
|
308
|
-
export declare function isOpenAICodexResponsesModel(model: Model): boolean;
|
|
309
|
-
export declare function usesNativeOpenAICodexResponsesBackend(model: Model): boolean;
|
|
310
313
|
export declare function buildOpenAIClientHeaders(model: Model, context: Context, optionHeaders?: Record<string, string>, turnHeaders?: Record<string, string>, sessionId?: string): Record<string, string>;
|
|
311
314
|
export declare function buildOpenAISdkClientOptions(model: Model): {
|
|
312
315
|
timeout?: number;
|
|
@@ -337,7 +340,7 @@ export declare function getCompat(model: OpenAIModeModel): {
|
|
|
337
340
|
requiresAssistantAfterToolResult: boolean;
|
|
338
341
|
requiresThinkingAsText: boolean;
|
|
339
342
|
requiresReasoningContentOnAssistantMessages: boolean;
|
|
340
|
-
thinkingFormat:
|
|
343
|
+
thinkingFormat: ModelDataThinkingFormat;
|
|
341
344
|
zaiToolStream: boolean;
|
|
342
345
|
supportsStrictMode: boolean;
|
|
343
346
|
supportsJsonSchemaResponseFormat: boolean;
|
|
@@ -346,6 +349,7 @@ export declare function getCompat(model: OpenAIModeModel): {
|
|
|
346
349
|
sessionAffinity: "openai" | "openrouter" | "none";
|
|
347
350
|
visibleReasoningDetailTypes: string[];
|
|
348
351
|
requiresNonEmptyUserOrAssistantMessage: boolean;
|
|
352
|
+
configuredSupportsLongCacheRetention?: boolean;
|
|
349
353
|
};
|
|
350
354
|
//#endregion
|
|
351
355
|
//#region packages/ai/src/transports/openai-responses-compact-request.d.ts
|
|
@@ -469,4 +473,73 @@ export declare function prepareModelForSimpleCompletion<TApi extends Api>(params
|
|
|
469
473
|
export declare const MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE = "OpenClaw transport error: malformed_streaming_fragment";
|
|
470
474
|
export declare function isCodeModeModelVisibleToolName(name: string, visibleToolNames: ReadonlySet<string>): boolean;
|
|
471
475
|
//#endregion
|
|
472
|
-
|
|
476
|
+
//#region packages/ai/src/providers/google-stream.d.ts
|
|
477
|
+
type GoogleStreamChunk = {
|
|
478
|
+
responseId?: string;
|
|
479
|
+
modelVersion?: string;
|
|
480
|
+
promptFeedback?: {
|
|
481
|
+
blockReason?: string;
|
|
482
|
+
blockReasonMessage?: string;
|
|
483
|
+
};
|
|
484
|
+
candidates?: Array<{
|
|
485
|
+
content?: {
|
|
486
|
+
parts?: Array<{
|
|
487
|
+
text?: string;
|
|
488
|
+
thought?: boolean;
|
|
489
|
+
thoughtSignature?: string;
|
|
490
|
+
functionCall?: {
|
|
491
|
+
id?: string;
|
|
492
|
+
name?: string;
|
|
493
|
+
args?: Record<string, unknown>;
|
|
494
|
+
};
|
|
495
|
+
}>;
|
|
496
|
+
};
|
|
497
|
+
finishReason?: string;
|
|
498
|
+
finishMessage?: string;
|
|
499
|
+
}>;
|
|
500
|
+
usageMetadata?: {
|
|
501
|
+
promptTokenCount?: number;
|
|
502
|
+
cachedContentTokenCount?: number;
|
|
503
|
+
candidatesTokenCount?: number;
|
|
504
|
+
thoughtsTokenCount?: number;
|
|
505
|
+
toolUsePromptTokenCount?: number;
|
|
506
|
+
totalTokenCount?: number;
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
/** @internal Directly tested provider implementation detail. */
|
|
510
|
+
export declare function consumeGoogleGenerateContentStream(params: {
|
|
511
|
+
chunks: AsyncIterable<GoogleStreamChunk>;
|
|
512
|
+
model: Model;
|
|
513
|
+
output: AssistantMessage;
|
|
514
|
+
stream: WritableTransportStream;
|
|
515
|
+
signal?: AbortSignal;
|
|
516
|
+
nextToolCallId: (name: string | undefined) => string;
|
|
517
|
+
profile?: "sdk" | "managed";
|
|
518
|
+
normalizeModelId?: (id: string) => string;
|
|
519
|
+
resolveStopReason?: (reason: string) => StopReason;
|
|
520
|
+
}): Promise<void>;
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region packages/ai/src/providers/google-messages.d.ts
|
|
523
|
+
type GoogleContentPart = Part & Record<string, unknown>;
|
|
524
|
+
type GoogleContent = {
|
|
525
|
+
role: string;
|
|
526
|
+
parts: GoogleContentPart[];
|
|
527
|
+
};
|
|
528
|
+
export declare function requiresGoogleToolCallId(modelId: string): boolean;
|
|
529
|
+
/** Project a prepared transcript; route repair and trusted video admission remain caller-owned. */
|
|
530
|
+
export declare function projectGoogleMessages(params: {
|
|
531
|
+
model: Pick<ProviderModel, "id" | "api" | "provider" | "input">;
|
|
532
|
+
messages: ProviderContext["messages"];
|
|
533
|
+
replay: "signed-parts" | "managed";
|
|
534
|
+
requiresToolCallSignature: boolean;
|
|
535
|
+
videoPart?: (video: VideoContent) => GoogleContentPart;
|
|
536
|
+
}): GoogleContent[];
|
|
537
|
+
/**
|
|
538
|
+
* Convert tools to Gemini function declarations format.
|
|
539
|
+
* @internal Directly tested provider implementation detail.
|
|
540
|
+
*/
|
|
541
|
+
export declare function convertGoogleTools(tools: Tool[]): {
|
|
542
|
+
functionDeclarations: Record<string, unknown>[];
|
|
543
|
+
}[] | undefined;
|
|
544
|
+
//#endregion
|
|
545
|
+
export { type GoogleStreamChunk, type OpenAICompletionsOptions, type OpenAIResponsesCompactionRejection, ProviderAcceptance, ResolvedOpenAICompletionsCompat, WritableTransportStream, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyOpenAIResponsesPayloadPolicy, assignTransportErrorDetails, buildAnthropicSystemBlocks, coerceTransportToolCallArguments, copyProviderAcceptanceObserver, createEmptyTransportUsage, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, failTransportStream, finalizeTerminalToolCallArguments, finalizeTransportStream, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, isAnthropicServerToolClearingEnabled, isDirectAnthropicModel, isNativeOpenAIEndpoint, isOpenAICodexResponsesModel, logAnthropicContextEdits, mergeTransportHeaders, mergeTransportMetadata, notifyProviderHttpMetadata, notifyProviderHttpResponse, notifyProviderStreamOpened, parseTerminalToolCallArguments, resolveAnthropicCacheOptions, resolveAnthropicContextManagementBetaHeader, resolveAnthropicEphemeralCacheControl, resolveAnthropicPayloadPolicy, resolveAnthropicServerCompactionPlan, resolveModelPayloadDebugMode, resolveModelSseDebugMode, resolveOpenAICompletionsCompat, resolveOpenAIPromptCacheKeySupport, resolveOpenAIResponsesCompactEndpointPlan, resolveOpenAIResponsesPayloadPolicy, resolveOpenAIResponsesServerCompactionPlan, sanitizeNonEmptyTransportPayloadText, sanitizeTransportPayloadText, sortPromptCacheToolsByName as sortTransportToolsByName, transportAbortError, usesNativeOpenAICodexResponsesBackend, withProviderAcceptanceObserver, withProviderResponseHook };
|