@openclaw/ai 2026.9.2 → 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-d46X2pR0.d.mts → anthropic-payload-policy-wuRCb6MH.d.mts} +16 -6
- package/dist/{anthropic-compaction-replay-DB2FGLQc.mjs → anthropic-stream-reducer-B_yo_7pf.mjs} +923 -181
- package/dist/{api-registry-DWtPjzyn.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-C5bZRfAP.mjs → azure-openai-responses-Crpa40QR.mjs} +5 -5
- package/dist/{base64-CEFBpSkN.mjs → base64-D-su8YVo.mjs} +1 -27
- package/dist/{diagnostics-DfFyKeX_.mjs → diagnostics-dV98PqIy.mjs} +96 -21
- package/dist/diagnostics.d.mts +3 -1
- package/dist/diagnostics.mjs +3 -3
- package/dist/{event-stream-BhT5T1Ay.d.mts → event-stream-C1Z2piyk.d.mts} +11 -3
- package/dist/{event-stream-BgDvQeum.mjs → event-stream-D8PARQfL.mjs} +45 -1
- 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-4qeuE8iX.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-O9BcnB6X.mjs → google-vertex-DMz8XQCn.mjs} +7 -6
- package/dist/{host-CEvLw30U.mjs → host-CWuF-sS3.mjs} +44 -39
- package/dist/{host-DjzGmdZ2.d.mts → host-DK3wmS3e.d.mts} +3 -3
- package/dist/host-policy-CAopLRKA.mjs +37 -0
- package/dist/{index-FnHM2FcI.d.mts → index-CQ6LTHw8.d.mts} +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/internal/anthropic.d.mts +7 -7
- package/dist/internal/anthropic.mjs +4 -4
- 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-Tb6oalqH.mjs → mistral--m-Jm6VZ.mjs} +13 -37
- package/dist/model-transport-url-DKocrEsb.d.mts +28 -0
- package/dist/{openai-chatgpt-responses-yUXjPNfu.mjs → openai-chatgpt-responses-nDZccFW-.mjs} +48 -38
- package/dist/openai-completions-KuoZyx0d.mjs +187 -0
- package/dist/{openai-completions-compat-CpjYUArk.d.mts → openai-completions-compat-CXn3T1we.d.mts} +26 -4
- package/dist/{openai-completions-stream-BsrBe3Gg.mjs → openai-completions-stream-BQk3SkLD.mjs} +622 -452
- 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-CCL41ALM.mjs → openai-responses-D99dOzKI.mjs} +14 -29
- package/dist/{openai-responses-compaction-window-BMVHFOtq.mjs → openai-responses-compaction-window-D5jbzCi3.mjs} +7 -170
- package/dist/{openai-responses-contracts-rF5DDRNS.d.mts → openai-responses-contracts-B55afwRo.d.mts} +3 -3
- package/dist/{openai-responses-prompt-observer-internal-D0bhBfgL.mjs → openai-responses-prompt-observer-internal-tApyTLVu.mjs} +3 -3
- package/dist/{openai-responses-shared-Bmma_3Qc.mjs → openai-responses-shared-ZyQEzS5i.mjs} +44 -115
- package/dist/openai-tool-projection-793cE3QX.d.mts +37 -0
- package/dist/{openai-tool-schema-_pTAJqKF.mjs → openai-tool-schema-CzjyYXun.mjs} +38 -556
- package/dist/openai-tool-schema-ynZBgqW-.d.mts +38 -0
- package/dist/openai-transport-params-DNasp2fU.mjs +674 -0
- package/dist/{provider-error-9TraxGvt.mjs → provider-error-C6TbKiey.mjs} +23 -6
- package/dist/{provider-options-Bcc_p-TU.d.mts → provider-options-BXr9Ec83.d.mts} +4 -39
- package/dist/{provider-transcript-transform-BaMbI1hr.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-DLCNXki6.mjs → reasoning-tag-text-partitioner-BQBi4B9d.mjs} +19 -12
- package/dist/record-coerce-DwRYMj3t.mjs +32 -0
- package/dist/retry-after-CdCURCVg.d.mts +15 -0
- package/dist/{sanitize-unicode-D6xUvZaS.mjs → sanitize-unicode-Bb-v9meu.mjs} +1 -1
- package/dist/session-affinity-CCH7eYdB.mjs +20 -0
- package/dist/{simple-options-BjHCCh4v.mjs → simple-options-tcKOqnpF.mjs} +3 -3
- package/dist/{src-2qBGKg8O.mjs → src-B2Q_6G8V.mjs} +1 -1
- 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-mJhXDcyz.mjs → tool-schema-json-projection-ClptDdAO.mjs} +2 -38
- package/dist/{transport-stream-shared-CZqMhfIw.mjs → transport-stream-shared-Cu3ZPhNW.mjs} +5 -5
- package/dist/{transport-stream-shared-xnaqxmbP.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 +113 -41
- package/dist/transports.mjs +162 -1276
- package/dist/types-BADKjDBI.d.mts +1 -0
- package/dist/{types-CJ1-Ht7A.d.mts → types-Dy1q0CSu.d.mts} +72 -57
- package/dist/types.d.mts +5 -5
- package/dist/types.mjs +3 -3
- package/dist/utf16-slice-CvGodqok.mjs +29 -0
- package/dist/{validation-CJZtym2g.mjs → validation-BDzVDnTs.mjs} +9 -1
- package/dist/{validation-AKZBDGQd.d.mts → validation-CaFUZN9B.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +13 -3
- package/dist/anthropic-BDdqdVLK.mjs +0 -886
- package/dist/event-stream-zctLx0yr.d.mts +0 -1
- package/dist/google-shared-CWeG8RIl.mjs +0 -636
- package/dist/google-thinking-level-C-V3tecN.mjs +0 -9
- package/dist/openai-completions-BIUV3RDT.mjs +0 -403
- package/dist/openai-prompt-cache-CGnVB74a.mjs +0 -21
- package/dist/openai-prompt-cache-CNoIfHYC.d.mts +0 -16
- package/dist/transport-utils-7il795_9.mjs +0 -138
- package/dist/types-3Lnm-QSJ.d.mts +0 -1
- package/dist/utf16-slice-qz3nsy87.mjs +0 -84
|
@@ -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 BaseOpenAIStreamOptions, c as OpenAIResponsesCompactionRejection,
|
|
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;
|
|
@@ -306,8 +310,6 @@ export declare function resolveOpenAIStrictToolFlagWithDiagnostics(projection: O
|
|
|
306
310
|
transport: "responses" | "completions";
|
|
307
311
|
model: OpenAIModeModel;
|
|
308
312
|
}): boolean | undefined;
|
|
309
|
-
export declare function isOpenAICodexResponsesModel(model: Model): boolean;
|
|
310
|
-
export declare function usesNativeOpenAICodexResponsesBackend(model: Model): boolean;
|
|
311
313
|
export declare function buildOpenAIClientHeaders(model: Model, context: Context, optionHeaders?: Record<string, string>, turnHeaders?: Record<string, string>, sessionId?: string): Record<string, string>;
|
|
312
314
|
export declare function buildOpenAISdkClientOptions(model: Model): {
|
|
313
315
|
timeout?: number;
|
|
@@ -338,7 +340,7 @@ export declare function getCompat(model: OpenAIModeModel): {
|
|
|
338
340
|
requiresAssistantAfterToolResult: boolean;
|
|
339
341
|
requiresThinkingAsText: boolean;
|
|
340
342
|
requiresReasoningContentOnAssistantMessages: boolean;
|
|
341
|
-
thinkingFormat:
|
|
343
|
+
thinkingFormat: ModelDataThinkingFormat;
|
|
342
344
|
zaiToolStream: boolean;
|
|
343
345
|
supportsStrictMode: boolean;
|
|
344
346
|
supportsJsonSchemaResponseFormat: boolean;
|
|
@@ -347,6 +349,7 @@ export declare function getCompat(model: OpenAIModeModel): {
|
|
|
347
349
|
sessionAffinity: "openai" | "openrouter" | "none";
|
|
348
350
|
visibleReasoningDetailTypes: string[];
|
|
349
351
|
requiresNonEmptyUserOrAssistantMessage: boolean;
|
|
352
|
+
configuredSupportsLongCacheRetention?: boolean;
|
|
350
353
|
};
|
|
351
354
|
//#endregion
|
|
352
355
|
//#region packages/ai/src/transports/openai-responses-compact-request.d.ts
|
|
@@ -470,4 +473,73 @@ export declare function prepareModelForSimpleCompletion<TApi extends Api>(params
|
|
|
470
473
|
export declare const MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE = "OpenClaw transport error: malformed_streaming_fragment";
|
|
471
474
|
export declare function isCodeModeModelVisibleToolName(name: string, visibleToolNames: ReadonlySet<string>): boolean;
|
|
472
475
|
//#endregion
|
|
473
|
-
|
|
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 };
|