@openclaw/ai 2026.8.1-beta.3 → 2026.9.1-beta.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-DI4PZKKB.mjs} +18 -16
- package/dist/{anthropic-compaction-replay-4Zx7-aCr.mjs → anthropic-compaction-replay-nhKaCXu6.mjs} +8 -12
- package/dist/{anthropic-payload-policy-CSx7MoKH.d.mts → anthropic-payload-policy-B_0n0enE.d.mts} +2 -1
- package/dist/{api-registry-DFxSnFqG.d.mts → api-registry-CTd8NzcD.d.mts} +2 -1
- package/dist/{azure-openai-responses-Aa4mVcYG.mjs → azure-openai-responses-D8dI0ekg.mjs} +3 -3
- package/dist/diagnostics.d.mts +0 -1
- package/dist/diagnostics.mjs +1 -1
- package/dist/event-stream-BKp4fOt_.d.mts +1 -0
- package/dist/{event-stream-D91-ohD_.d.mts → event-stream-LiXePESD.d.mts} +1 -2
- package/dist/event-stream.d.mts +2 -1
- package/dist/{google-yDRnipeq.mjs → google-Od-LLdVK.mjs} +3 -3
- package/dist/{google-shared-M1dl64nz.mjs → google-shared-Bgr9lFPw.mjs} +14 -7
- package/dist/{google-vertex-DCJHM_a5.mjs → google-vertex-aerRSXc4.mjs} +4 -4
- package/dist/{host-DF_yxOsA.mjs → host-D51fmkH6.mjs} +4 -8
- package/dist/{host-DJq_FGcz.d.mts → host-DsbPMFU6.d.mts} +3 -3
- package/dist/index-Qbej8io0.d.mts +3 -0
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +2 -3
- package/dist/internal/anthropic.d.mts +5 -4
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/openai-responses-payload-policy.d.mts +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +5 -5
- package/dist/internal/openai.mjs +8 -7
- package/dist/internal/runtime.d.mts +16 -5
- package/dist/internal/runtime.mjs +6 -6
- package/dist/internal/shared.d.mts +2 -2
- 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-EiHdymeb.mjs} +17 -21
- package/dist/{openai-chatgpt-responses-C339VIfT.mjs → openai-chatgpt-responses-DHpF9o1e.mjs} +28 -11
- package/dist/openai-completions-EFPiUGfS.mjs +399 -0
- package/dist/{openai-completions-compat-B0KTleXp.d.mts → openai-completions-compat-BefmHT26.d.mts} +3 -3
- package/dist/openai-completions-stream-DUlGwRMz.mjs +1621 -0
- package/dist/{openai-responses-BXEcr-Tp.mjs → openai-responses-BogP8OjX.mjs} +6 -5
- package/dist/{openai-responses-contracts-CD75pQ0m.d.mts → openai-responses-contracts-Dvj_UtPy.d.mts} +3 -3
- package/dist/{openai-responses-contracts-DvILoqBk.mjs → openai-responses-contracts-QUY12X0B.mjs} +4 -18
- package/dist/{openai-responses-payload-policy-BDo8CQsx.mjs → openai-responses-payload-policy-D8EdimYe.mjs} +3 -7
- package/dist/{openai-responses-prompt-observer-internal-BG-1AsBI.mjs → openai-responses-prompt-observer-internal-Cd4hJG-S.mjs} +3 -2
- package/dist/{openai-responses-shared-Cvt5MgEm.mjs → openai-responses-shared-DJThc6jW.mjs} +150 -1362
- package/dist/openai-stop-reason-Drnn_6Qj.mjs +28 -0
- package/dist/openai-tool-schema-ho-hIkQf.mjs +1695 -0
- package/dist/{provider-error-C8mBRJDl.mjs → provider-error-DDOs_Bz0.mjs} +1 -3
- package/dist/{provider-options-Cc5ZQ6Aa.d.mts → provider-options-MdMBLzlU.d.mts} +4 -3
- package/dist/{provider-transcript-transform--gtf0ZbR.mjs → provider-transcript-transform-C01bQ5a3.mjs} +1 -1
- package/dist/provider-types.d.mts +5 -3
- package/dist/providers.d.mts +1 -2
- package/dist/providers.mjs +9 -9
- package/dist/{sanitize-unicode-BP7HLLZn.mjs → sanitize-unicode-DCkltN94.mjs} +1 -2
- package/dist/simple-options-CFj7x3J4.mjs +118 -0
- package/dist/{anthropic-BQXQudmA.mjs → src-Bu3FiFAG.mjs} +1 -0
- 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-ljShVIZB.mjs} +10 -118
- package/dist/transport-stream-shared-rvaCyFYt.d.mts +138 -0
- package/dist/{transport-utils-Bv0FHkd0.mjs → transport-utils-LJ1_rbi-.mjs} +8 -5
- package/dist/transports.d.mts +23 -117
- package/dist/transports.mjs +43 -1038
- package/dist/{types-DTAP49HF.d.mts → types-DhLoJbFm.d.mts} +34 -17
- package/dist/types-GiAjXatj.d.mts +1 -0
- package/dist/types.d.mts +4 -3
- package/dist/types.mjs +1 -2
- package/dist/utf16-slice-qz3nsy87.mjs +84 -0
- package/dist/{validation-DYNNrU9u.d.mts → validation-Dk7q7NMN.d.mts} +1 -2
- package/dist/validation.d.mts +1 -1
- package/package.json +5 -5
- 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-stop-reason-9OONKyAm.mjs +0 -579
- package/dist/openai-tool-projection-CHGLt03m.mjs +0 -426
- 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,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as asOptionalRecord } from "./record-coerce-DdXsgUd_.mjs";
|
|
3
|
-
import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
|
|
1
|
+
import { a as asOptionalRecord, f as normalizeStringifiedOptionalString, t as truncateUtf16Safe } from "./utf16-slice-qz3nsy87.mjs";
|
|
4
2
|
import "./number-coercion-H9qHik3g.mjs";
|
|
5
3
|
//#region packages/normalization-core/src/balanced-json.ts
|
|
6
4
|
function isJsonOpeningDelimiter(char, openers) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { U as StreamOptions } from "./types-
|
|
1
|
+
import { U as StreamOptions } from "./types-DhLoJbFm.mjs";
|
|
2
|
+
import "./types-GiAjXatj.mjs";
|
|
2
3
|
import OpenAI from "openai";
|
|
3
4
|
import Anthropic from "@anthropic-ai/sdk";
|
|
4
5
|
import { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
|
|
5
|
-
|
|
6
6
|
//#region packages/ai/src/providers/openai-reasoning-effort.d.ts
|
|
7
7
|
type OpenAIReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
8
8
|
type OpenAIApiReasoningEffort = OpenAIReasoningEffort | (string & {});
|
|
@@ -142,7 +142,8 @@ type BaseOpenAIStreamOptions = StreamOptions & {
|
|
|
142
142
|
topP?: number;
|
|
143
143
|
authProfileId?: string;
|
|
144
144
|
firstEventTimeoutMs?: number;
|
|
145
|
-
onFirstEventTimeout?: (reason: Error) => void;
|
|
145
|
+
onFirstEventTimeout?: (reason: Error) => void;
|
|
146
|
+
/** Internal owner notification after a server rejects a persisted compaction checkpoint. */
|
|
146
147
|
onCompactionRejected?: (checkpoint: OpenAIResponsesCompactionRejection) => void;
|
|
147
148
|
openclawCodeModeToolSurface?: boolean;
|
|
148
149
|
openclawCodeModeAllowedHostedToolTypes?: Set<string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as transformMessages } from "./host-
|
|
1
|
+
import { i as transformMessages } from "./host-D51fmkH6.mjs";
|
|
2
2
|
//#region packages/ai/src/provider-transcript-transform.ts
|
|
3
3
|
const IMAGE_OMISSION = "(image omitted: model does not support images)";
|
|
4
4
|
const VIDEO_OMISSION = "(video omitted: provider does not support video input)";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, f as supportsClaude1MContext, g as supportsClaudeNativeXhighEffort, h as supportsClaudeNativeMaxEffort, i as requiresClaudeDefaultSampling, l as resolveClaudeNativeThinkingLevelMap, m as supportsClaudeFastMode, n as CLAUDE_OPUS_5_THINKING_PROFILE, o as resolveClaudeFable5ModelIdentity, p as supportsClaudeAdaptiveThinking, r as CLAUDE_SONNET_5_THINKING_PROFILE, s as resolveClaudeModelIdentity, t as CLAUDE_FABLE_5_THINKING_PROFILE, u as resolveClaudeOpus5ModelIdentity } from "./anthropic-BECQCNdF.mjs";
|
|
2
2
|
import { a as extractDiagnosticError, i as createAssistantMessageDiagnostic, n as DiagnosticErrorInfo, o as formatThrownValue, r as appendAssistantMessageDiagnostic, t as AssistantMessageDiagnostic } from "./diagnostics-BaTA9eVl.mjs";
|
|
3
|
-
import { $ as Transport, A as OpenAIResponsesCompat, B as StopReason, C as KnownImagesApi, D as Model, F as ProviderImagesOptions, G as TextSignatureV1, I as ProviderReplayState, J as ThinkingLevel, K as ThinkingBudgets, L as ProviderResponse, M as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, N as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, O as ModelThinkingLevel, P as Provider, Q as ToolResultMessage, S as KnownApi, T as MaybePromise, U as StreamOptions, V as StreamFn, W as TextContent, X as Tool, Y as ThinkingLevelMap, Z as ToolCall, _ as ImagesModel, a as AssistantMessage, b as ImagesProvider, c as AssistantMessageEventStreamLike, d as Context, et as Usage, f as ImageContent, g as ImagesInputContent, h as ImagesFunction, i as AssistantImages, j as OpenRouterRouting, k as OpenAICompletionsCompat, l as CacheRetention, m as ImagesContext, n as Api, nt as ValidateToolArgumentsFn, o as AssistantMessageEvent, p as ImagesApi, q as ThinkingContent, r as AssistantDeliveryTtsFacts, rt as VercelGatewayRouting, s as AssistantMessageEventStreamContract, t as AnthropicMessagesCompat, tt as UserMessage, u as CompleteSimpleFn, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as SimpleStreamOptions } from "./types-
|
|
4
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
5
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
3
|
+
import { $ as Transport, A as OpenAIResponsesCompat, B as StopReason, C as KnownImagesApi, D as Model, F as ProviderImagesOptions, G as TextSignatureV1, I as ProviderReplayState, J as ThinkingLevel, K as ThinkingBudgets, L as ProviderResponse, M as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, N as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, O as ModelThinkingLevel, P as Provider, Q as ToolResultMessage, S as KnownApi, T as MaybePromise, U as StreamOptions, V as StreamFn, W as TextContent, X as Tool, Y as ThinkingLevelMap, Z as ToolCall, _ as ImagesModel, a as AssistantMessage, b as ImagesProvider, c as AssistantMessageEventStreamLike, d as Context, et as Usage, f as ImageContent, g as ImagesInputContent, h as ImagesFunction, i as AssistantImages, j as OpenRouterRouting, k as OpenAICompletionsCompat, l as CacheRetention, m as ImagesContext, n as Api, nt as ValidateToolArgumentsFn, o as AssistantMessageEvent, p as ImagesApi, q as ThinkingContent, r as AssistantDeliveryTtsFacts, rt as VercelGatewayRouting, s as AssistantMessageEventStreamContract, t as AnthropicMessagesCompat, tt as UserMessage, u as CompleteSimpleFn, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as SimpleStreamOptions } from "./types-DhLoJbFm.mjs";
|
|
4
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-LiXePESD.mjs";
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-Dk7q7NMN.mjs";
|
|
6
|
+
import "./index-Qbej8io0.mjs";
|
|
7
|
+
import "./types-GiAjXatj.mjs";
|
|
6
8
|
//#region packages/ai/src/provider-types.d.ts
|
|
7
9
|
declare const PROVIDER_CONTEXT_HANDOFF: unique symbol;
|
|
8
10
|
type VideoContent = Omit<ImageContent, "type"> & {
|
package/dist/providers.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
1
|
+
import { n as ApiRegistry } from "./api-registry-CTd8NzcD.mjs";
|
|
2
2
|
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-2uo_1OR1.mjs";
|
|
3
|
-
|
|
4
3
|
//#region packages/ai/src/providers/register-builtins.d.ts
|
|
5
4
|
/** Source id used for built-in API provider registrations. */
|
|
6
5
|
declare const BUILT_IN_API_PROVIDER_SOURCE_ID = "core:built-in";
|
package/dist/providers.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
2
|
-
import { n as projectProviderError } from "./provider-error-
|
|
2
|
+
import { n as projectProviderError } from "./provider-error-DDOs_Bz0.mjs";
|
|
3
3
|
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
4
4
|
//#region packages/ai/src/providers/register-builtins.ts
|
|
5
5
|
/** Source id used for built-in API provider registrations. */
|
|
@@ -62,35 +62,35 @@ function createLazyRegistration(api, importModule, select) {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
const registerBuiltIns = [
|
|
65
|
-
createLazyRegistration("anthropic-messages", () => import("./anthropic-
|
|
65
|
+
createLazyRegistration("anthropic-messages", () => import("./anthropic-DI4PZKKB.mjs").then((n) => n.t), (module) => ({
|
|
66
66
|
stream: module.streamAnthropic,
|
|
67
67
|
streamSimple: module.streamSimpleAnthropic
|
|
68
68
|
})),
|
|
69
|
-
createLazyRegistration("openai-completions", () => import("./openai-completions-
|
|
69
|
+
createLazyRegistration("openai-completions", () => import("./openai-completions-EFPiUGfS.mjs").then((n) => n.t), (module) => ({
|
|
70
70
|
stream: module.streamOpenAICompletions,
|
|
71
71
|
streamSimple: module.streamSimpleOpenAICompletions
|
|
72
72
|
})),
|
|
73
|
-
createLazyRegistration("mistral-conversations", () => import("./mistral-
|
|
73
|
+
createLazyRegistration("mistral-conversations", () => import("./mistral-EiHdymeb.mjs"), (module) => ({
|
|
74
74
|
stream: module.streamMistral,
|
|
75
75
|
streamSimple: module.streamSimpleMistral
|
|
76
76
|
})),
|
|
77
|
-
createLazyRegistration("openai-responses", () => import("./openai-responses-
|
|
77
|
+
createLazyRegistration("openai-responses", () => import("./openai-responses-BogP8OjX.mjs").then((n) => n.t), (module) => ({
|
|
78
78
|
stream: module.streamOpenAIResponses,
|
|
79
79
|
streamSimple: module.streamSimpleOpenAIResponses
|
|
80
80
|
})),
|
|
81
|
-
createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-
|
|
81
|
+
createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-D8dI0ekg.mjs"), (module) => ({
|
|
82
82
|
stream: module.streamAzureOpenAIResponses,
|
|
83
83
|
streamSimple: module.streamSimpleAzureOpenAIResponses
|
|
84
84
|
})),
|
|
85
|
-
createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-
|
|
85
|
+
createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-DHpF9o1e.mjs"), (module) => ({
|
|
86
86
|
stream: module.streamOpenAICodexResponses,
|
|
87
87
|
streamSimple: module.streamSimpleOpenAICodexResponses
|
|
88
88
|
})),
|
|
89
|
-
createLazyRegistration("google-generative-ai", () => import("./google-
|
|
89
|
+
createLazyRegistration("google-generative-ai", () => import("./google-Od-LLdVK.mjs"), (module) => ({
|
|
90
90
|
stream: module.streamGoogle,
|
|
91
91
|
streamSimple: module.streamSimpleGoogle
|
|
92
92
|
})),
|
|
93
|
-
createLazyRegistration("google-vertex", () => import("./google-vertex-
|
|
93
|
+
createLazyRegistration("google-vertex", () => import("./google-vertex-aerRSXc4.mjs"), (module) => ({
|
|
94
94
|
stream: module.streamGoogleVertex,
|
|
95
95
|
streamSimple: module.streamSimpleGoogleVertex
|
|
96
96
|
}))
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { a as requiresClaudeMandatoryAdaptiveThinking, l as resolveClaudeNativeThinkingLevelMap } from "./
|
|
2
|
-
import "./src-D2H6yKkH.mjs";
|
|
1
|
+
import { a as requiresClaudeMandatoryAdaptiveThinking, l as resolveClaudeNativeThinkingLevelMap } from "./src-Bu3FiFAG.mjs";
|
|
3
2
|
//#region packages/ai/src/model-utils.ts
|
|
4
3
|
/** Calculates and stores model cost fields from token usage and per-million pricing. */
|
|
5
4
|
function calculateCost(model, usage) {
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { c as normalizeLowercaseStringOrEmpty } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-DCkltN94.mjs";
|
|
3
|
+
import { r as copyProviderAcceptanceObserver } from "./transport-stream-shared-ljShVIZB.mjs";
|
|
4
|
+
//#region packages/ai/src/utils/prompt-cache-stability.ts
|
|
5
|
+
/**
|
|
6
|
+
* Prompt-cache normalization helpers. They keep generated prompt sections
|
|
7
|
+
* deterministic across platform newlines, trailing whitespace, and input
|
|
8
|
+
* ordering.
|
|
9
|
+
*/
|
|
10
|
+
/** Canonicalizes provider tool order without relying on host locale settings. */
|
|
11
|
+
function sortPromptCacheToolsByName(tools) {
|
|
12
|
+
const compareText = (left, right) => {
|
|
13
|
+
const leftText = left ?? "";
|
|
14
|
+
const rightText = right ?? "";
|
|
15
|
+
return leftText < rightText ? -1 : leftText > rightText ? 1 : 0;
|
|
16
|
+
};
|
|
17
|
+
return tools.toSorted((left, right) => compareText(left.wireName ?? left.name, right.wireName ?? right.name) || compareText(left.description, right.description));
|
|
18
|
+
}
|
|
19
|
+
/** Normalize structured prompt text before hashing or snapshot comparison. */
|
|
20
|
+
function normalizeStructuredPromptSection(text) {
|
|
21
|
+
return sanitizeSurrogates(text).replace(/\r\n?/g, "\n").replace(/[ \t]+$/gm, "").trim();
|
|
22
|
+
}
|
|
23
|
+
/** Normalize, de-dupe, and sort capability ids for stable prompt payloads. */
|
|
24
|
+
function normalizePromptCapabilityIds(capabilities) {
|
|
25
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26
|
+
const normalized = [];
|
|
27
|
+
for (const capability of capabilities) {
|
|
28
|
+
const value = normalizeLowercaseStringOrEmpty(normalizeStructuredPromptSection(capability));
|
|
29
|
+
if (!value || seen.has(value)) continue;
|
|
30
|
+
seen.add(value);
|
|
31
|
+
normalized.push(value);
|
|
32
|
+
}
|
|
33
|
+
return normalized.toSorted((left, right) => left.localeCompare(right));
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region packages/ai/src/utils/system-prompt-cache-boundary.ts
|
|
37
|
+
/**
|
|
38
|
+
* System prompt cache-boundary helpers.
|
|
39
|
+
*
|
|
40
|
+
* Keeps stable prompt prefixes separate from dynamic runtime additions for provider prompt caching.
|
|
41
|
+
*/
|
|
42
|
+
const SYSTEM_PROMPT_CACHE_BOUNDARY = "\n<!-- OPENCLAW_CACHE_BOUNDARY -->\n";
|
|
43
|
+
function stripSystemPromptCacheBoundary(text) {
|
|
44
|
+
return text.replaceAll(SYSTEM_PROMPT_CACHE_BOUNDARY, "\n");
|
|
45
|
+
}
|
|
46
|
+
function ensureSystemPromptCacheBoundary(systemPrompt) {
|
|
47
|
+
if (systemPrompt.trim().length === 0) return systemPrompt;
|
|
48
|
+
return systemPrompt.includes("\n<!-- OPENCLAW_CACHE_BOUNDARY -->\n") ? systemPrompt : `${systemPrompt}${SYSTEM_PROMPT_CACHE_BOUNDARY}`;
|
|
49
|
+
}
|
|
50
|
+
function splitSystemPromptCacheBoundary(text) {
|
|
51
|
+
const boundaryIndex = text.indexOf(SYSTEM_PROMPT_CACHE_BOUNDARY);
|
|
52
|
+
if (boundaryIndex === -1) return;
|
|
53
|
+
return {
|
|
54
|
+
stablePrefix: text.slice(0, boundaryIndex).trimEnd(),
|
|
55
|
+
dynamicSuffix: text.slice(boundaryIndex + 34).trimStart()
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function prependSystemPromptAdditionAfterCacheBoundary(params) {
|
|
59
|
+
const systemPromptAddition = typeof params.systemPromptAddition === "string" ? normalizeStructuredPromptSection(params.systemPromptAddition) : "";
|
|
60
|
+
if (!systemPromptAddition) return params.systemPrompt;
|
|
61
|
+
if (params.systemPrompt.trim().length === 0) return systemPromptAddition;
|
|
62
|
+
const split = splitSystemPromptCacheBoundary(params.systemPrompt);
|
|
63
|
+
if (!split) return `${systemPromptAddition}\n\n${params.systemPrompt}`;
|
|
64
|
+
const dynamicSuffix = split.dynamicSuffix ? normalizeStructuredPromptSection(split.dynamicSuffix) : "";
|
|
65
|
+
if (!dynamicSuffix) return `${split.stablePrefix}${SYSTEM_PROMPT_CACHE_BOUNDARY}${systemPromptAddition}`;
|
|
66
|
+
return `${split.stablePrefix}${SYSTEM_PROMPT_CACHE_BOUNDARY}${systemPromptAddition}\n\n${dynamicSuffix}`;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region packages/ai/src/providers/simple-options.ts
|
|
70
|
+
function buildBaseOptions(model, options, apiKey) {
|
|
71
|
+
const firstEventOptions = options;
|
|
72
|
+
return copyProviderAcceptanceObserver(options, {
|
|
73
|
+
temperature: options?.temperature,
|
|
74
|
+
maxTokens: options?.maxTokens,
|
|
75
|
+
stop: options?.stop,
|
|
76
|
+
signal: options?.signal,
|
|
77
|
+
apiKey: apiKey || options?.apiKey,
|
|
78
|
+
transport: options?.transport,
|
|
79
|
+
cacheRetention: options?.cacheRetention,
|
|
80
|
+
sessionId: options?.sessionId,
|
|
81
|
+
promptCacheKey: options?.promptCacheKey,
|
|
82
|
+
headers: options?.headers,
|
|
83
|
+
onPayload: options?.onPayload,
|
|
84
|
+
onResponse: options?.onResponse,
|
|
85
|
+
timeoutMs: options?.timeoutMs,
|
|
86
|
+
firstEventTimeoutMs: firstEventOptions?.firstEventTimeoutMs,
|
|
87
|
+
onFirstEventTimeout: firstEventOptions?.onFirstEventTimeout,
|
|
88
|
+
maxRetries: options?.maxRetries,
|
|
89
|
+
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
90
|
+
metadata: options?.metadata
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function clampMaxTokensToModel(model, requestedMaxTokens) {
|
|
94
|
+
return requestedMaxTokens === void 0 ? void 0 : Math.max(1, Math.min(requestedMaxTokens, model.maxTokens));
|
|
95
|
+
}
|
|
96
|
+
function clampReasoning(effort) {
|
|
97
|
+
return effort === "xhigh" ? "high" : effort;
|
|
98
|
+
}
|
|
99
|
+
function adjustMaxTokensForThinking(baseMaxTokens, modelMaxTokens, reasoningLevel, customBudgets) {
|
|
100
|
+
const budgets = {
|
|
101
|
+
minimal: 1024,
|
|
102
|
+
low: 2048,
|
|
103
|
+
medium: 8192,
|
|
104
|
+
high: 16384,
|
|
105
|
+
max: 32768,
|
|
106
|
+
...customBudgets
|
|
107
|
+
};
|
|
108
|
+
const minOutputTokens = 1024;
|
|
109
|
+
let thinkingBudget = budgets[clampReasoning(reasoningLevel)];
|
|
110
|
+
const maxTokens = baseMaxTokens === void 0 ? modelMaxTokens : Math.min(baseMaxTokens + thinkingBudget, modelMaxTokens);
|
|
111
|
+
if (maxTokens <= thinkingBudget) thinkingBudget = Math.max(0, maxTokens - minOutputTokens);
|
|
112
|
+
return {
|
|
113
|
+
maxTokens,
|
|
114
|
+
thinkingBudget
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { SYSTEM_PROMPT_CACHE_BOUNDARY as a, splitSystemPromptCacheBoundary as c, normalizeStructuredPromptSection as d, sortPromptCacheToolsByName as f, clampReasoning as i, stripSystemPromptCacheBoundary as l, buildBaseOptions as n, ensureSystemPromptCacheBoundary as o, clampMaxTokensToModel as r, prependSystemPromptAdditionAfterCacheBoundary as s, adjustMaxTokensForThinking as t, normalizePromptCapabilityIds as u };
|
|
@@ -5,6 +5,9 @@ function createSseByteGuard(reader, opts) {
|
|
|
5
5
|
let total = 0;
|
|
6
6
|
let overflowedFlag = false;
|
|
7
7
|
let cancelledFlag = false;
|
|
8
|
+
const cancelReaderBestEffort = (reason) => {
|
|
9
|
+
reader.cancel(reason).catch(() => void 0);
|
|
10
|
+
};
|
|
8
11
|
return {
|
|
9
12
|
read: async () => {
|
|
10
13
|
if (overflowedFlag || cancelledFlag) return {
|
|
@@ -22,9 +25,7 @@ function createSseByteGuard(reader, opts) {
|
|
|
22
25
|
size: next,
|
|
23
26
|
maxBytes: opts.maxBytes
|
|
24
27
|
});
|
|
25
|
-
|
|
26
|
-
await reader.cancel(err);
|
|
27
|
-
} catch {}
|
|
28
|
+
cancelReaderBestEffort(err);
|
|
28
29
|
throw err;
|
|
29
30
|
}
|
|
30
31
|
total = next;
|
|
@@ -33,9 +34,7 @@ function createSseByteGuard(reader, opts) {
|
|
|
33
34
|
cancel: async (reason) => {
|
|
34
35
|
if (overflowedFlag) return;
|
|
35
36
|
cancelledFlag = true;
|
|
36
|
-
|
|
37
|
-
await reader.cancel(reason);
|
|
38
|
-
} catch {}
|
|
37
|
+
cancelReaderBestEffort(reason);
|
|
39
38
|
},
|
|
40
39
|
totalBytes: () => total,
|
|
41
40
|
overflowed: () => overflowedFlag,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { d as normalizeOptionalString } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
+
//#region packages/normalization-core/src/string-normalization.ts
|
|
3
|
+
/** Coerces entries to strings, trims them, and drops empty results. */
|
|
4
|
+
function normalizeStringEntries(list) {
|
|
5
|
+
return (list ?? []).map((entry) => normalizeOptionalString(String(entry)) ?? "").filter(Boolean);
|
|
6
|
+
}
|
|
7
|
+
/** Returns first-seen unique values while preserving insertion order. */
|
|
8
|
+
function uniqueValues(values) {
|
|
9
|
+
return [...new Set(values)];
|
|
10
|
+
}
|
|
11
|
+
/** Returns first-seen unique strings while preserving insertion order. */
|
|
12
|
+
function uniqueStrings(values) {
|
|
13
|
+
return uniqueValues(values);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { uniqueStrings as n, uniqueValues as r, normalizeStringEntries as t };
|
package/dist/{tool-schema-json-projection-FEr-jOoZ.mjs → tool-schema-json-projection-qvTEs5Am.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { o as isRecord } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
+
import { n as getAiTransportHost } from "./host-D51fmkH6.mjs";
|
|
3
3
|
import { types } from "node:util";
|
|
4
4
|
//#region packages/ai/src/transports/host-policy.ts
|
|
5
5
|
function buildGuardedModelFetch(model, timeoutMs, options) {
|
|
@@ -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-DDOs_Bz0.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 { D as Model, L as ProviderResponse, U as StreamOptions, a as AssistantMessage, et as Usage } from "./types-DhLoJbFm.mjs";
|
|
2
|
+
import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-LiXePESD.mjs";
|
|
3
|
+
import "./index-Qbej8io0.mjs";
|
|
4
|
+
import "./event-stream-BKp4fOt_.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 { a as parseStrictFiniteNumber, n as asFiniteNumberInRange, o as parseStrictNonNegativeInteger, s as parseStrictPositiveInteger } from "./number-coercion-H9qHik3g.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
|
}
|
|
@@ -135,4 +138,4 @@ async function readResponseTextSnippet(response, options) {
|
|
|
135
138
|
return truncated ? `${collapsed}…` : collapsed;
|
|
136
139
|
}
|
|
137
140
|
//#endregion
|
|
138
|
-
export { isGoogleGemini3FlashModel as a,
|
|
141
|
+
export { isGoogleGemini3FlashModel as a, parseRetryAfterSeconds as c, redactSensitiveText as d, resolveModelHeaderSentinels as f, supportsModelTools as h, isCodeModeModelVisibleToolName as i, readResponseTextSnippet as l, sha256Hex as m, createAbortError as n, isGoogleGemini3ProModel as o, resolveSecretSentinel as p, estimateStringChars as r, parsePositiveInteger as s, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as t, redactIdentifier as u };
|