@openclaw/ai 2026.8.1-beta.3 → 2026.8.1
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/dist/{anthropic-B8KwTtlb.mjs → anthropic-Djj7L1rx.mjs} +21 -21
- package/dist/{anthropic-compaction-replay-4Zx7-aCr.mjs → anthropic-compaction-replay-CY4tkD4V.mjs} +33 -34
- package/dist/{anthropic-payload-policy-CSx7MoKH.d.mts → anthropic-payload-policy-i_5_inWe.d.mts} +3 -2
- package/dist/{api-registry-DFxSnFqG.d.mts → api-registry-C9-wZd_W.d.mts} +2 -1
- package/dist/{azure-openai-responses-Aa4mVcYG.mjs → azure-openai-responses-Bj3czHNa.mjs} +4 -4
- package/dist/{number-coercion-H9qHik3g.mjs → base64-CEFBpSkN.mjs} +73 -1
- package/dist/diagnostics.d.mts +2 -3
- package/dist/diagnostics.mjs +1 -1
- package/dist/{env-api-keys-DrgeBuva.mjs → env-api-keys-bktO00EJ.mjs} +2 -15
- package/dist/event-stream-C988TSLe.d.mts +1 -0
- package/dist/{event-stream-D91-ohD_.d.mts → event-stream-UhnxHuqt.d.mts} +1 -2
- package/dist/event-stream.d.mts +2 -1
- package/dist/{google-yDRnipeq.mjs → google-0Ca6TYbw.mjs} +4 -4
- package/dist/{google-shared-M1dl64nz.mjs → google-shared-DVfL9COU.mjs} +14 -7
- package/dist/{google-vertex-DCJHM_a5.mjs → google-vertex-5dAMxprN.mjs} +4 -4
- package/dist/{host-DF_yxOsA.mjs → host-D51fmkH6.mjs} +4 -8
- package/dist/{host-DJq_FGcz.d.mts → host-DoPJJ1KD.d.mts} +3 -3
- package/dist/index-N3zr6__t.d.mts +105 -0
- package/dist/index.d.mts +9 -10
- package/dist/index.mjs +2 -3
- package/dist/internal/anthropic.d.mts +51 -49
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
- package/dist/internal/openai-responses-payload-policy.mjs +2 -3
- package/dist/internal/openai.d.mts +65 -63
- package/dist/internal/openai.mjs +10 -9
- package/dist/internal/retry-after.d.mts +2 -3
- package/dist/internal/runtime.d.mts +51 -40
- package/dist/internal/runtime.mjs +9 -9
- package/dist/internal/shared.d.mts +25 -25
- package/dist/internal/shared.mjs +3 -3
- package/dist/{json-parse-CDnesDM_.mjs → json-parse-BuAJEbdW.mjs} +18 -2
- package/dist/{mistral-D6hRXI7A.mjs → mistral-BCnrI-kV.mjs} +22 -25
- package/dist/{openai-chatgpt-responses-C339VIfT.mjs → openai-chatgpt-responses-CGBGWSqr.mjs} +31 -14
- package/dist/openai-completions-BaTuwID7.mjs +401 -0
- package/dist/{openai-completions-compat-B0KTleXp.d.mts → openai-completions-compat-DB7FFq7k.d.mts} +3 -3
- package/dist/openai-completions-stream-Bpns6uNc.mjs +1622 -0
- package/dist/{openai-responses-BXEcr-Tp.mjs → openai-responses-1GBcQujk.mjs} +8 -6
- package/dist/openai-responses-compaction-window-DwydGZI8.mjs +686 -0
- package/dist/{openai-responses-contracts-CD75pQ0m.d.mts → openai-responses-contracts-DgaR3t5T.d.mts} +14 -5
- package/dist/{openai-responses-payload-policy-CNGFT9zr.d.mts → openai-responses-payload-policy-rLRPsSmB.d.mts} +1 -0
- package/dist/{openai-responses-prompt-observer-internal-BG-1AsBI.mjs → openai-responses-prompt-observer-internal-_nhGTn2b.mjs} +3 -2
- package/dist/{openai-responses-shared-Cvt5MgEm.mjs → openai-responses-shared-zPmKnhF5.mjs} +315 -1468
- package/dist/openai-stop-reason-Drnn_6Qj.mjs +28 -0
- package/dist/openai-tool-schema-Dgl4H2MU.mjs +1695 -0
- package/dist/{provider-error-C8mBRJDl.mjs → provider-error-jZP5NMTZ.mjs} +3 -77
- package/dist/{provider-options-Cc5ZQ6Aa.d.mts → provider-options-HvA_slFa.d.mts} +13 -4
- package/dist/{provider-transcript-transform--gtf0ZbR.mjs → provider-transcript-transform-C01bQ5a3.mjs} +1 -1
- package/dist/provider-types.d.mts +18 -17
- package/dist/providers.d.mts +5 -6
- package/dist/providers.mjs +9 -9
- package/dist/{reasoning-tag-text-partitioner-5ygO2rZc.mjs → reasoning-tag-text-partitioner-CwzKb0bA.mjs} +1 -1
- package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
- package/dist/{sanitize-unicode-BP7HLLZn.mjs → sanitize-unicode-DCkltN94.mjs} +1 -2
- package/dist/simple-options-DKx86yX9.mjs +155 -0
- package/dist/{anthropic-BQXQudmA.mjs → src-Bu3FiFAG.mjs} +1 -0
- package/dist/{stream-first-event-timeout-MK28puvq.mjs → stream-first-event-timeout-DcNjoFQE.mjs} +1 -1
- package/dist/{streaming-byte-guard-BrbkbwUu.mjs → streaming-byte-guard-CC-HMn_u.mjs} +5 -6
- package/dist/string-normalization--fwJ4S2q.mjs +16 -0
- package/dist/{tool-schema-json-projection-FEr-jOoZ.mjs → tool-schema-json-projection-qvTEs5Am.mjs} +2 -2
- package/dist/{simple-options-oqsXB6U3.mjs → transport-stream-shared-CT5ycdzn.mjs} +10 -118
- package/dist/transport-stream-shared-NjwWNaRY.d.mts +138 -0
- package/dist/{transport-utils-Bv0FHkd0.mjs → transport-utils-BHx9z8Cl.mjs} +9 -9
- package/dist/transports.d.mts +127 -189
- package/dist/transports.mjs +181 -1214
- package/dist/types-DtGu2d3C.d.mts +1 -0
- package/dist/{types-DTAP49HF.d.mts → types-h38Azne1.d.mts} +38 -17
- package/dist/types.d.mts +5 -4
- package/dist/types.mjs +1 -2
- package/dist/utf16-slice-qz3nsy87.mjs +84 -0
- package/dist/{validation-DYNNrU9u.d.mts → validation-C68lP2uy.d.mts} +1 -2
- package/dist/validation.d.mts +1 -1
- package/package.json +6 -6
- package/dist/anthropic-BECQCNdF.d.mts +0 -98
- package/dist/event-stream-BVVgDSdq.d.mts +0 -1
- package/dist/headers-B_e4-1J0.mjs +0 -9
- package/dist/index-BVVgDSdq.d.mts +0 -1
- package/dist/openai-completions-D88orSJ9.mjs +0 -632
- package/dist/openai-responses-contracts-DvILoqBk.mjs +0 -247
- package/dist/openai-responses-payload-policy-BDo8CQsx.mjs +0 -208
- package/dist/openai-stop-reason-9OONKyAm.mjs +0 -579
- package/dist/openai-tool-projection-CHGLt03m.mjs +0 -426
- package/dist/provider-options-AvldWZt8.mjs +0 -21
- package/dist/record-coerce-DdXsgUd_.mjs +0 -23
- package/dist/src-D2H6yKkH.mjs +0 -2
- package/dist/stream-first-event-timeout-DvDeSucC.d.mts +0 -29
- package/dist/string-coerce-fsri9iCu.mjs +0 -34
- package/dist/types-BVVgDSdq.d.mts +0 -1
- package/dist/utf16-slice-CvGodqok.mjs +0 -29
|
@@ -1,72 +1,13 @@
|
|
|
1
1
|
import { r as createAssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as sanitizeSurrogates } from "./sanitize-unicode-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* ordering.
|
|
12
|
-
*/
|
|
13
|
-
/** Canonicalizes provider tool order without relying on host locale settings. */
|
|
14
|
-
function sortPromptCacheToolsByName(tools) {
|
|
15
|
-
const compareText = (left, right) => {
|
|
16
|
-
const leftText = left ?? "";
|
|
17
|
-
const rightText = right ?? "";
|
|
18
|
-
return leftText < rightText ? -1 : leftText > rightText ? 1 : 0;
|
|
19
|
-
};
|
|
20
|
-
return tools.toSorted((left, right) => compareText(left.wireName ?? left.name, right.wireName ?? right.name) || compareText(left.description, right.description));
|
|
21
|
-
}
|
|
22
|
-
/** Normalize structured prompt text before hashing or snapshot comparison. */
|
|
23
|
-
function normalizeStructuredPromptSection(text) {
|
|
24
|
-
return sanitizeSurrogates(text).replace(/\r\n?/g, "\n").replace(/[ \t]+$/gm, "").trim();
|
|
25
|
-
}
|
|
26
|
-
/** Normalize, de-dupe, and sort capability ids for stable prompt payloads. */
|
|
27
|
-
function normalizePromptCapabilityIds(capabilities) {
|
|
28
|
-
const seen = /* @__PURE__ */ new Set();
|
|
29
|
-
const normalized = [];
|
|
30
|
-
for (const capability of capabilities) {
|
|
31
|
-
const value = normalizeLowercaseStringOrEmpty(normalizeStructuredPromptSection(capability));
|
|
32
|
-
if (!value || seen.has(value)) continue;
|
|
33
|
-
seen.add(value);
|
|
34
|
-
normalized.push(value);
|
|
35
|
-
}
|
|
36
|
-
return normalized.toSorted((left, right) => left.localeCompare(right));
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region packages/ai/src/utils/system-prompt-cache-boundary.ts
|
|
40
|
-
/**
|
|
41
|
-
* System prompt cache-boundary helpers.
|
|
42
|
-
*
|
|
43
|
-
* Keeps stable prompt prefixes separate from dynamic runtime additions for provider prompt caching.
|
|
44
|
-
*/
|
|
45
|
-
const SYSTEM_PROMPT_CACHE_BOUNDARY = "\n<!-- OPENCLAW_CACHE_BOUNDARY -->\n";
|
|
46
|
-
function stripSystemPromptCacheBoundary(text) {
|
|
47
|
-
return text.replaceAll(SYSTEM_PROMPT_CACHE_BOUNDARY, "\n");
|
|
48
|
-
}
|
|
49
|
-
function ensureSystemPromptCacheBoundary(systemPrompt) {
|
|
50
|
-
if (systemPrompt.trim().length === 0) return systemPrompt;
|
|
51
|
-
return systemPrompt.includes("\n<!-- OPENCLAW_CACHE_BOUNDARY -->\n") ? systemPrompt : `${systemPrompt}${SYSTEM_PROMPT_CACHE_BOUNDARY}`;
|
|
52
|
-
}
|
|
53
|
-
function splitSystemPromptCacheBoundary(text) {
|
|
54
|
-
const boundaryIndex = text.indexOf(SYSTEM_PROMPT_CACHE_BOUNDARY);
|
|
55
|
-
if (boundaryIndex === -1) return;
|
|
56
|
-
return {
|
|
57
|
-
stablePrefix: text.slice(0, boundaryIndex).trimEnd(),
|
|
58
|
-
dynamicSuffix: text.slice(boundaryIndex + 34).trimStart()
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function prependSystemPromptAdditionAfterCacheBoundary(params) {
|
|
62
|
-
const systemPromptAddition = typeof params.systemPromptAddition === "string" ? normalizeStructuredPromptSection(params.systemPromptAddition) : "";
|
|
63
|
-
if (!systemPromptAddition) return params.systemPrompt;
|
|
64
|
-
if (params.systemPrompt.trim().length === 0) return systemPromptAddition;
|
|
65
|
-
const split = splitSystemPromptCacheBoundary(params.systemPrompt);
|
|
66
|
-
if (!split) return `${systemPromptAddition}\n\n${params.systemPrompt}`;
|
|
67
|
-
const dynamicSuffix = split.dynamicSuffix ? normalizeStructuredPromptSection(split.dynamicSuffix) : "";
|
|
68
|
-
if (!dynamicSuffix) return `${split.stablePrefix}${SYSTEM_PROMPT_CACHE_BOUNDARY}${systemPromptAddition}`;
|
|
69
|
-
return `${split.stablePrefix}${SYSTEM_PROMPT_CACHE_BOUNDARY}${systemPromptAddition}\n\n${dynamicSuffix}`;
|
|
2
|
+
import { a as asOptionalRecord, n as asNonArrayRecord, r as asNullableRecord } from "./utf16-slice-qz3nsy87.mjs";
|
|
3
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-DCkltN94.mjs";
|
|
4
|
+
import { n as projectProviderError } from "./provider-error-jZP5NMTZ.mjs";
|
|
5
|
+
//#region packages/ai/src/utils/headers.ts
|
|
6
|
+
/** Converts a Headers object to a plain record for provider request handling. */
|
|
7
|
+
function headersToRecord(headers) {
|
|
8
|
+
const result = {};
|
|
9
|
+
for (const [key, value] of headers.entries()) result[key] = value;
|
|
10
|
+
return result;
|
|
70
11
|
}
|
|
71
12
|
//#endregion
|
|
72
13
|
//#region packages/ai/src/transports/json-unsafe-integers.ts
|
|
@@ -398,53 +339,4 @@ function failTransportStream(params) {
|
|
|
398
339
|
stream.end();
|
|
399
340
|
}
|
|
400
341
|
//#endregion
|
|
401
|
-
|
|
402
|
-
function buildBaseOptions(model, options, apiKey) {
|
|
403
|
-
const firstEventOptions = options;
|
|
404
|
-
return copyProviderAcceptanceObserver(options, {
|
|
405
|
-
temperature: options?.temperature,
|
|
406
|
-
maxTokens: options?.maxTokens,
|
|
407
|
-
stop: options?.stop,
|
|
408
|
-
signal: options?.signal,
|
|
409
|
-
apiKey: apiKey || options?.apiKey,
|
|
410
|
-
transport: options?.transport,
|
|
411
|
-
cacheRetention: options?.cacheRetention,
|
|
412
|
-
sessionId: options?.sessionId,
|
|
413
|
-
promptCacheKey: options?.promptCacheKey,
|
|
414
|
-
headers: options?.headers,
|
|
415
|
-
onPayload: options?.onPayload,
|
|
416
|
-
onResponse: options?.onResponse,
|
|
417
|
-
timeoutMs: options?.timeoutMs,
|
|
418
|
-
firstEventTimeoutMs: firstEventOptions?.firstEventTimeoutMs,
|
|
419
|
-
onFirstEventTimeout: firstEventOptions?.onFirstEventTimeout,
|
|
420
|
-
maxRetries: options?.maxRetries,
|
|
421
|
-
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
422
|
-
metadata: options?.metadata
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
function clampMaxTokensToModel(model, requestedMaxTokens) {
|
|
426
|
-
return requestedMaxTokens === void 0 ? void 0 : Math.max(1, Math.min(requestedMaxTokens, model.maxTokens));
|
|
427
|
-
}
|
|
428
|
-
function clampReasoning(effort) {
|
|
429
|
-
return effort === "xhigh" ? "high" : effort;
|
|
430
|
-
}
|
|
431
|
-
function adjustMaxTokensForThinking(baseMaxTokens, modelMaxTokens, reasoningLevel, customBudgets) {
|
|
432
|
-
const budgets = {
|
|
433
|
-
minimal: 1024,
|
|
434
|
-
low: 2048,
|
|
435
|
-
medium: 8192,
|
|
436
|
-
high: 16384,
|
|
437
|
-
max: 32768,
|
|
438
|
-
...customBudgets
|
|
439
|
-
};
|
|
440
|
-
const minOutputTokens = 1024;
|
|
441
|
-
let thinkingBudget = budgets[clampReasoning(reasoningLevel)];
|
|
442
|
-
const maxTokens = baseMaxTokens === void 0 ? modelMaxTokens : Math.min(baseMaxTokens + thinkingBudget, modelMaxTokens);
|
|
443
|
-
if (maxTokens <= thinkingBudget) thinkingBudget = Math.max(0, maxTokens - minOutputTokens);
|
|
444
|
-
return {
|
|
445
|
-
maxTokens,
|
|
446
|
-
thinkingBudget
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
//#endregion
|
|
450
|
-
export { splitSystemPromptCacheBoundary as A, withProviderResponseHook as C, SYSTEM_PROMPT_CACHE_BOUNDARY as D, quoteUnsafeIntegerLiterals as E, normalizePromptCapabilityIds as M, normalizeStructuredPromptSection as N, ensureSystemPromptCacheBoundary as O, sortPromptCacheToolsByName as P, withProviderAcceptanceObserver as S, parseJsonPreservingUnsafeIntegers as T, notifyProviderStreamOpened as _, assignTransportErrorDetails as a, sanitizeTransportPayloadText as b, createEmptyTransportUsage as c, finalizeTerminalToolCallArguments as d, finalizeTransportStream as f, notifyProviderHttpResponse as g, notifyProviderHttpMetadata as h, clampReasoning as i, stripSystemPromptCacheBoundary as j, prependSystemPromptAdditionAfterCacheBoundary as k, createWritableTransportEventStream as l, mergeTransportMetadata as m, buildBaseOptions as n, coerceTransportToolCallArguments as o, mergeTransportHeaders as p, clampMaxTokensToModel as r, copyProviderAcceptanceObserver as s, adjustMaxTokensForThinking as t, failTransportStream as u, parseTerminalToolCallArguments as v, parseJsonObjectPreservingUnsafeIntegers as w, transportAbortError as x, sanitizeNonEmptyTransportPayloadText as y };
|
|
342
|
+
export { headersToRecord as C, quoteUnsafeIntegerLiterals as S, transportAbortError as _, createWritableTransportEventStream as a, parseJsonObjectPreservingUnsafeIntegers as b, finalizeTransportStream as c, notifyProviderHttpMetadata as d, notifyProviderHttpResponse as f, sanitizeTransportPayloadText as g, sanitizeNonEmptyTransportPayloadText as h, createEmptyTransportUsage as i, mergeTransportHeaders as l, parseTerminalToolCallArguments as m, coerceTransportToolCallArguments as n, failTransportStream as o, notifyProviderStreamOpened as p, copyProviderAcceptanceObserver as r, finalizeTerminalToolCallArguments as s, assignTransportErrorDetails as t, mergeTransportMetadata as u, withProviderAcceptanceObserver as v, parseJsonPreservingUnsafeIntegers as x, withProviderResponseHook as y };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import "./index-N3zr6__t.mjs";
|
|
2
|
+
import { D as Model, L as ProviderResponse, U as StreamOptions, a as AssistantMessage, et as Usage } from "./types-h38Azne1.mjs";
|
|
3
|
+
import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-UhnxHuqt.mjs";
|
|
4
|
+
import "./event-stream-C988TSLe.mjs";
|
|
5
|
+
import { t as ProviderErrorProjection } from "./provider-error-CzNw4BWX.mjs";
|
|
6
|
+
//#region packages/ai/src/utils/stream-first-event-timeout.d.ts
|
|
7
|
+
type StreamStage = "responses" | "completions";
|
|
8
|
+
type FirstStreamEventTimeoutContext = {
|
|
9
|
+
provider?: string;
|
|
10
|
+
api?: string;
|
|
11
|
+
model?: string;
|
|
12
|
+
timeoutMs: number;
|
|
13
|
+
stage?: StreamStage;
|
|
14
|
+
hint?: string;
|
|
15
|
+
abort?: (reason: Error) => void;
|
|
16
|
+
onTimeout?: (reason: Error) => void;
|
|
17
|
+
};
|
|
18
|
+
type FirstStreamEventInternalOptions = {
|
|
19
|
+
firstEventTimeoutMs?: number;
|
|
20
|
+
abortFirstEventStream?: (reason: Error) => void;
|
|
21
|
+
onFirstEventTimeout?: (reason: Error) => void;
|
|
22
|
+
};
|
|
23
|
+
type FirstStreamEventAbortController = {
|
|
24
|
+
signal: AbortSignal;
|
|
25
|
+
abort: (reason: Error) => void;
|
|
26
|
+
dispose: () => void;
|
|
27
|
+
};
|
|
28
|
+
declare function getFirstStreamEventTimeoutMs(options: unknown): number | undefined;
|
|
29
|
+
declare function getFirstStreamEventTimeoutHandler(options: unknown): ((reason: Error) => void) | undefined;
|
|
30
|
+
declare function createFirstStreamEventTimeoutError(context: FirstStreamEventTimeoutContext): Error;
|
|
31
|
+
declare function createFirstStreamEventAbortController(parentSignal?: AbortSignal): FirstStreamEventAbortController;
|
|
32
|
+
declare function withFirstStreamEventTimeout<T>(stream: AsyncIterable<T>, context: FirstStreamEventTimeoutContext): AsyncIterable<T>;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region packages/ai/src/transports/transport-stream-shared.d.ts
|
|
35
|
+
type ContextUsage = NonNullable<Usage["contextUsage"]>;
|
|
36
|
+
type TransportUsage = {
|
|
37
|
+
input: number;
|
|
38
|
+
output: number;
|
|
39
|
+
cacheRead: number;
|
|
40
|
+
cacheWrite: number;
|
|
41
|
+
contextUsage?: ContextUsage;
|
|
42
|
+
totalTokens: number;
|
|
43
|
+
cost: {
|
|
44
|
+
input: number;
|
|
45
|
+
output: number;
|
|
46
|
+
cacheRead: number;
|
|
47
|
+
cacheWrite: number;
|
|
48
|
+
total: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
type WritableTransportStream = Pick<ReturnType<typeof createAssistantMessageEventStream>, "push" | "end">;
|
|
52
|
+
declare function sanitizeTransportPayloadText(text: string): string;
|
|
53
|
+
declare function sanitizeNonEmptyTransportPayloadText(text: string, fallback?: string): string;
|
|
54
|
+
declare function coerceTransportToolCallArguments(argumentsValue: unknown): Record<string, unknown>;
|
|
55
|
+
/** Admit only complete object-shaped terminal tool arguments; partial parsing is preview-only. */
|
|
56
|
+
declare function parseTerminalToolCallArguments(value: unknown, errorMessage?: string): Record<string, unknown>;
|
|
57
|
+
/** Validate a complete sibling set before mutating any call into executable state. */
|
|
58
|
+
declare function finalizeTerminalToolCallArguments<T extends {
|
|
59
|
+
arguments: Record<string, unknown>;
|
|
60
|
+
}>(calls: readonly T[], readArguments: (call: T) => unknown, errorMessage?: string): void;
|
|
61
|
+
declare function mergeTransportHeaders(...headerSources: Array<Record<string, string> | undefined>): Record<string, string> | undefined;
|
|
62
|
+
declare function mergeTransportMetadata<T extends Record<string, unknown>>(payload: T, metadata?: Record<string, string>): T;
|
|
63
|
+
declare function createEmptyTransportUsage(): TransportUsage;
|
|
64
|
+
declare function createWritableTransportEventStream(): {
|
|
65
|
+
eventStream: AssistantMessageEventStream;
|
|
66
|
+
stream: AssistantMessageEventStream;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Abort error to surface for an aborted `signal`.
|
|
70
|
+
*
|
|
71
|
+
* Rethrows the caller's abort reason only when it carries a `code`, so that code
|
|
72
|
+
* survives into `errorCode` on the persisted assistant message and consumers can
|
|
73
|
+
* recognize an abort's origin without matching error text. A default
|
|
74
|
+
* `abort()` reason is an uncoded DOMException that carries nothing the synthetic
|
|
75
|
+
* error does not, so it keeps the "Request was aborted" text every transport
|
|
76
|
+
* already emits rather than churning it.
|
|
77
|
+
*/
|
|
78
|
+
declare function transportAbortError(signal?: AbortSignal): Error;
|
|
79
|
+
type ProviderAcceptance = {
|
|
80
|
+
kind: "http_response";
|
|
81
|
+
status: number;
|
|
82
|
+
headers: Record<string, string>;
|
|
83
|
+
} | {
|
|
84
|
+
kind: "provider_stream_opened";
|
|
85
|
+
};
|
|
86
|
+
type ProviderAcceptanceObserver = (acceptance: ProviderAcceptance) => void;
|
|
87
|
+
type ProviderAcceptanceOptions = Pick<StreamOptions, "onResponse" | "signal">;
|
|
88
|
+
type ProviderStreamCancel = (reason: Error) => void | Promise<void>;
|
|
89
|
+
/** Attach an OpenClaw-internal provider acceptance observer to one model call. */
|
|
90
|
+
declare function withProviderAcceptanceObserver<T extends object>(options: T, observer: ProviderAcceptanceObserver): T;
|
|
91
|
+
/** Preserve the private provider acceptance observer when a built-in wrapper rebuilds options. */
|
|
92
|
+
declare function copyProviderAcceptanceObserver<T extends object>(source: unknown, target: T): T;
|
|
93
|
+
/** Report observed HTTP metadata; rejected responses use only onResponse. */
|
|
94
|
+
declare function notifyProviderHttpMetadata(params: {
|
|
95
|
+
options?: ProviderAcceptanceOptions;
|
|
96
|
+
response: ProviderResponse;
|
|
97
|
+
model: Model;
|
|
98
|
+
cancelStream: ProviderStreamCancel;
|
|
99
|
+
signal?: AbortSignal;
|
|
100
|
+
}): Promise<void>;
|
|
101
|
+
/** Report a real HTTP response before body consumption. */
|
|
102
|
+
declare function notifyProviderHttpResponse(params: {
|
|
103
|
+
options?: ProviderAcceptanceOptions;
|
|
104
|
+
response: Response;
|
|
105
|
+
model: Model;
|
|
106
|
+
cancelStream?: ProviderStreamCancel;
|
|
107
|
+
signal?: AbortSignal;
|
|
108
|
+
}): Promise<void>;
|
|
109
|
+
/** Report an accepted SDK stream when the SDK does not expose HTTP metadata. */
|
|
110
|
+
declare function notifyProviderStreamOpened(params: {
|
|
111
|
+
options?: Pick<StreamOptions, "signal">;
|
|
112
|
+
cancelStream: ProviderStreamCancel;
|
|
113
|
+
signal?: AbortSignal;
|
|
114
|
+
}): Promise<void>;
|
|
115
|
+
/** Run a provider-response hook before start/body consumption inside the first-event deadline. */
|
|
116
|
+
declare function withProviderResponseHook<T = never>(params: {
|
|
117
|
+
stream?: AsyncIterable<T>;
|
|
118
|
+
signal: AbortSignal;
|
|
119
|
+
abort: (reason: Error) => void;
|
|
120
|
+
hook?: () => void | Promise<void>;
|
|
121
|
+
onReady?: () => void;
|
|
122
|
+
}): AsyncIterable<T>;
|
|
123
|
+
declare function finalizeTransportStream(params: {
|
|
124
|
+
stream: WritableTransportStream;
|
|
125
|
+
output: AssistantMessage;
|
|
126
|
+
signal?: AbortSignal;
|
|
127
|
+
}): void;
|
|
128
|
+
/** @deprecated Use projectProviderError. v2026.7.2-beta.5 compatibility; remove after 2026.10. */
|
|
129
|
+
declare function assignTransportErrorDetails(output: AssistantMessage, error: unknown, signal?: AbortSignal): ProviderErrorProjection;
|
|
130
|
+
declare function failTransportStream(params: {
|
|
131
|
+
stream: WritableTransportStream;
|
|
132
|
+
output: AssistantMessage;
|
|
133
|
+
signal?: AbortSignal;
|
|
134
|
+
error: unknown;
|
|
135
|
+
cleanup?: () => void;
|
|
136
|
+
}): void;
|
|
137
|
+
//#endregion
|
|
138
|
+
export { FirstStreamEventInternalOptions as C, getFirstStreamEventTimeoutHandler as D, createFirstStreamEventTimeoutError as E, getFirstStreamEventTimeoutMs as O, FirstStreamEventAbortController as S, createFirstStreamEventAbortController as T, sanitizeNonEmptyTransportPayloadText as _, copyProviderAcceptanceObserver as a, withProviderAcceptanceObserver as b, failTransportStream as c, mergeTransportHeaders as d, mergeTransportMetadata as f, parseTerminalToolCallArguments as g, notifyProviderStreamOpened as h, coerceTransportToolCallArguments as i, withFirstStreamEventTimeout as k, finalizeTerminalToolCallArguments as l, notifyProviderHttpResponse as m, WritableTransportStream as n, createEmptyTransportUsage as o, notifyProviderHttpMetadata as p, assignTransportErrorDetails as r, createWritableTransportEventStream as s, ProviderAcceptance as t, finalizeTransportStream as u, sanitizeTransportPayloadText as v, FirstStreamEventTimeoutContext as w, withProviderResponseHook as x, transportAbortError as y };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as getAiTransportHost } from "./host-
|
|
3
|
-
import {
|
|
4
|
-
import { a as parseStrictFiniteNumber, n as asFiniteNumberInRange, o as parseStrictNonNegativeInteger } from "./number-coercion-H9qHik3g.mjs";
|
|
1
|
+
import { d as normalizeOptionalString, t as truncateUtf16Safe } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
+
import { n as getAiTransportHost } from "./host-D51fmkH6.mjs";
|
|
3
|
+
import { c as parseStrictNonNegativeInteger, i as asFiniteNumberInRange, l as parseStrictPositiveInteger, s as parseStrictFiniteNumber } from "./base64-CEFBpSkN.mjs";
|
|
5
4
|
import { parseRetryAfterHttpDateMs } from "./internal/retry-after.mjs";
|
|
6
5
|
import { createHash } from "node:crypto";
|
|
7
6
|
//#region packages/ai/src/transports/transport-utils.ts
|
|
8
7
|
const MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE = "OpenClaw transport error: malformed_streaming_fragment";
|
|
9
8
|
const NON_LATIN_RE = /[\u2E80-\u9FFF\uA000-\uA4FF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFF60\uFFE0-\uFFE6\u{20000}-\u{2FA1F}]/gu;
|
|
10
9
|
const CJK_SURROGATE_HIGH_RE = /[\uD840-\uD87E][\uDC00-\uDFFF]/g;
|
|
10
|
+
function parsePositiveInteger(value) {
|
|
11
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value);
|
|
12
|
+
return typeof value === "string" ? parseStrictPositiveInteger(value) : void 0;
|
|
13
|
+
}
|
|
11
14
|
function sha256Hex(value) {
|
|
12
15
|
return createHash("sha256").update(value).digest("hex");
|
|
13
16
|
}
|
|
@@ -22,14 +25,11 @@ function redactIdentifier(value, opts) {
|
|
|
22
25
|
function redactSensitiveText(text, _options) {
|
|
23
26
|
return getAiTransportHost().redactToolPayloadText(text);
|
|
24
27
|
}
|
|
25
|
-
function resolveSecretSentinel(value) {
|
|
26
|
-
return getAiTransportHost().resolveSecretSentinel(value);
|
|
27
|
-
}
|
|
28
28
|
function resolveModelHeaderSentinels(model) {
|
|
29
29
|
if (!model.headers) return model;
|
|
30
30
|
let headers;
|
|
31
31
|
for (const [name, value] of Object.entries(model.headers)) {
|
|
32
|
-
const resolved = resolveSecretSentinel(value);
|
|
32
|
+
const resolved = getAiTransportHost().resolveSecretSentinel(value);
|
|
33
33
|
if (resolved !== value) {
|
|
34
34
|
headers ??= { ...model.headers };
|
|
35
35
|
headers[name] = resolved;
|
|
@@ -135,4 +135,4 @@ async function readResponseTextSnippet(response, options) {
|
|
|
135
135
|
return truncated ? `${collapsed}…` : collapsed;
|
|
136
136
|
}
|
|
137
137
|
//#endregion
|
|
138
|
-
export { isGoogleGemini3FlashModel as a,
|
|
138
|
+
export { isGoogleGemini3FlashModel as a, parseRetryAfterSeconds as c, redactSensitiveText as d, resolveModelHeaderSentinels as f, isCodeModeModelVisibleToolName as i, readResponseTextSnippet as l, supportsModelTools as m, createAbortError as n, isGoogleGemini3ProModel as o, sha256Hex as p, estimateStringChars as r, parsePositiveInteger as s, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as t, redactIdentifier as u };
|