@openclaw/ai 2026.7.2-beta.5 → 2026.7.2-beta.7
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-CQVj3le6.mjs → anthropic-CH4UUnZr.mjs} +14 -463
- package/dist/anthropic-usage-DWU-x8MI.mjs +459 -0
- package/dist/{azure-openai-responses-DIYgsqFM.mjs → azure-openai-responses-CImcwB83.mjs} +4 -3
- package/dist/azure-openai-responses-client-compat-C7K7QfUE.mjs +62 -0
- package/dist/cache-retention-0x979a5V.mjs +12 -0
- package/dist/deferred-event-buffer-DAvyP7qA.mjs +19 -0
- package/dist/github-copilot-headers-NCJtz9i0.mjs +37 -0
- package/dist/{google-f-A8xrae.mjs → google-CtSg0iTS.mjs} +3 -3
- package/dist/{google-shared-J6qvYINH.mjs → google-shared-DNBz5rcD.mjs} +5 -3
- package/dist/{google-vertex-D3yMVXIY.mjs → google-vertex-31f1uS9L.mjs} +3 -3
- package/dist/host-Dog2WQiR.mjs +369 -0
- package/dist/index.mjs +1 -1
- package/dist/internal/anthropic.d.mts +3 -53
- package/dist/internal/anthropic.mjs +3 -2
- package/dist/internal/openai.d.mts +259 -2
- package/dist/internal/openai.mjs +8 -4
- package/dist/internal/runtime.mjs +6 -4
- package/dist/internal/shared.d.mts +1 -1
- package/dist/internal/shared.mjs +5 -1
- package/dist/{llm-request-activity-CehVkZP-.mjs → llm-request-activity-BjtkplhG.mjs} +1 -19
- package/dist/{mistral-CKV-TOQj.mjs → mistral-CWmpvWYh.mjs} +5 -3
- package/dist/{openai-chatgpt-responses-CedIj0hk.mjs → openai-chatgpt-responses-B84Ibtrd.mjs} +18 -13
- package/dist/openai-completions-DsOxhOD1.mjs +630 -0
- package/dist/openai-completions-compat-DBWjXoMZ.d.mts +43 -0
- package/dist/openai-reasoning-compat-YgeLncHw.mjs +396 -0
- package/dist/openai-responses-BT7A3sLu.mjs +138 -0
- package/dist/openai-responses-shared-pXl6Wd8S.mjs +392 -0
- package/dist/{openai-D3PD6PE-.mjs → openai-responses-stream-internal-Cw5txaGW.mjs} +1409 -1863
- package/dist/openai-tool-projection-OhX64DoP.mjs +215 -0
- package/dist/{provider-error-apVOZI6G.mjs → provider-error-CAEvRjry.mjs} +1 -1
- package/dist/provider-options-D8bB3z9b.d.mts +144 -0
- package/dist/providers.mjs +8 -8
- package/dist/{stream-first-event-timeout-C3OgBjIk.mjs → reasoning-tag-text-partitioner-CGDyLWUR.mjs} +1 -86
- package/dist/simple-options-9lhRrN73.mjs +50 -0
- package/dist/stream-first-event-timeout-BBys9hSb.mjs +86 -0
- package/dist/tls-certificate-errors-DXSpluKI.mjs +93 -0
- package/dist/tool-result-text-CTpIRbYd.mjs +225 -0
- package/dist/{github-copilot-headers-BCoBNmL7.mjs → tool-schema-json-projection-BwNu3nDi.mjs} +1 -48
- package/dist/transform-messages-C8mBqZxF.mjs +2 -0
- package/dist/{transport-stream-shared-BbMELSI4.mjs → transport-stream-shared-D81p90xq.mjs} +4 -4
- package/dist/transports.d.mts +13 -33
- package/dist/transports.mjs +75 -34
- package/package.json +4 -4
- package/dist/host-XYGZcgO8.mjs +0 -98
- package/dist/openai-BPor_3WI.d.mts +0 -358
- package/dist/openai-completions-CiSutyu0.mjs +0 -1223
- package/dist/shared-CdjNZd35.mjs +0 -634
package/dist/transports.mjs
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { n as getEnvApiKey } from "./env-api-keys-DrgeBuva.mjs";
|
|
2
2
|
import { d as resolveClaudeSonnet5ModelIdentity, g as supportsClaudeNativeXhighEffort, h as supportsClaudeNativeMaxEffort, l as resolveClaudeNativeThinkingLevelMap, p as supportsClaudeAdaptiveThinking, u as resolveClaudeOpus5ModelIdentity } from "./src-QkygScBs.mjs";
|
|
3
3
|
import { r as createAssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
|
|
4
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-
|
|
4
|
+
import { a as applyClaudeRequestContract, c as requiresClaudeAdaptiveThinking, d as usesClaudeStreamingRefusalContract, f as hasNonEmptyString, g as isRecord, h as readStringValue, n as getAiTransportHost, o as defaultsClaudeAdaptiveThinking, p as normalizeLowercaseStringOrEmpty, r as resolveAiTransportHeaderSentinels, s as prepareClaudeNoPrefillRequestContext, u as usesClaudeFable5MessagesContract } from "./host-Dog2WQiR.mjs";
|
|
5
5
|
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
7
|
+
import { a as isImageWithMediaPayload, d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName, n as extractToolResultBlockText, r as extractToolResultText, t as describeToolResultMediaPlaceholder, u as splitSystemPromptCacheBoundary } from "./tool-result-text-CTpIRbYd.mjs";
|
|
8
|
+
import { a as resolveModelRequestTimeoutMs, c as resolveProviderRequestCapabilities, i as buildGuardedModelFetch, l as resolveProviderRequestPolicyConfig, n as reconcileOpenAICompletionsToolChoice, o as resolveOpenAIStrictToolSetting, r as reconcileOpenAIResponsesToolChoice, s as resolveProviderEndpoint, t as projectOpenAITools, u as transformTransportMessages } from "./openai-tool-projection-OhX64DoP.mjs";
|
|
8
9
|
import { t as toErrorObject } from "./error-coercion-DgxlWC0n.mjs";
|
|
9
|
-
import {
|
|
10
|
+
import { S as canonicalizeBase64, _ as omitFoundryBearerCredentialHeaders, a as projectAnthropicTools, b as normalizeAnthropicInlineContent, c as ANTHROPIC_OMITTED_REASONING_TEXT, d as ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, g as applyAnthropicRefusal, h as resolveAnthropicFallbackServingModelCost, i as readLastAnthropicIterationUsage, l as findActiveAnthropicToolTurnAssistantIndex, m as readAnthropicFallbackBoundary, n as readAnthropicPromptUsageSnapshot, o as reconcileAnthropicToolChoice, p as applyAnthropicFallbackBoundary, r as readAnthropicUsageTokenCount, s as resolveOriginalAnthropicToolName, u as ANTHROPIC_SERVER_SIDE_FALLBACKS, v as usesFoundryBearerAuth, x as resolveAnthropicImageMediaType, y as createAnthropicInlineImageBudget } from "./anthropic-usage-DWU-x8MI.mjs";
|
|
10
11
|
import { a as parseStrictPositiveInteger, c as calculateCost, l as clampThinkingLevel, s as applyProviderReportedUsageCost } from "./number-coercion-DvG7SNMg.mjs";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
12
|
+
import { a as resolveOpenAICompletionsCompat, c as clearPendingCommentaryText, i as detectOpenAICompletionsCompat, l as rememberPendingCommentaryTags, n as mapOpenAIStopReason, o as resolveOpenAICompletionsResponseFormat, r as convertMessages, s as shouldOmitOllamaCompatResponseFormat, t as resolveOpenAIReasoningEffortMap, u as tagPendingCommentaryText } from "./openai-reasoning-compat-YgeLncHw.mjs";
|
|
13
|
+
import { t as createDeferredEventBuffer } from "./deferred-event-buffer-DAvyP7qA.mjs";
|
|
13
14
|
import { n as parseStreamingJson } from "./json-parse-BvXNt1-7.mjs";
|
|
14
|
-
import "./
|
|
15
|
-
import { a as
|
|
16
|
-
import "./internal
|
|
17
|
-
import {
|
|
15
|
+
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
16
|
+
import { C as resolveSecretSentinel, S as resolveModelHeaderSentinels$1, T as supportsModelTools, _ as isGoogleGemini3ProModel, a as failTransportStream, c as mergeTransportMetadata, d as transportAbortError, f as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, g as isGoogleGemini3FlashModel, h as isCodeModeModelVisibleToolName, i as createWritableTransportEventStream, l as sanitizeNonEmptyTransportPayloadText, m as estimateStringChars, n as coerceTransportToolCallArguments, o as finalizeTransportStream, p as createAbortError$1, r as createEmptyTransportUsage, s as mergeTransportHeaders, t as assignTransportErrorDetails, u as sanitizeTransportPayloadText, v as parseRetryAfterSeconds, w as sha256Hex, y as readResponseTextSnippet } from "./transport-stream-shared-D81p90xq.mjs";
|
|
17
|
+
import { A as normalizeResponsesFailedEvent, B as resolveReplayableResponsesMessageId, C as prepareOpenAIResponsesReasoningItemForReplay, D as applyServiceTierPricing, E as tagOpenAIResponsesReasoningReplayItem, F as summarizeResponsesFailedNoDetailsObservation, G as throwIfModelStreamAborted, H as createModelStreamCooperativeScheduler, I as summarizeResponsesPayload, L as summarizeResponsesTools, M as stringifyRedactedEvent, N as stringifyRedactedPayload, O as buildResponsesFailedNoDetailsObservation, P as summarizeOpenAITransportError, R as AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS, S as isInvalidEncryptedContentError, T as stripResponsesRequestEncryptedContent, U as log, V as GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, W as resolvePromptCacheKey, Y as normalizeOpenAIStrictToolParameters, Z as resolveOpenAIProjectedToolsStrictToolFlag, b as convertResponsesMessages, bt as resolveModelPayloadDebugMode, dt as isOpenAIGpt55Model, ft as isOpenAIGpt56Model, gt as supportsOpenAIReasoningEffort, j as safeDebugValue, k as logResponsesFailedNoDetails, mt as resolveOpenAIReasoningEffortForModel, n as processResponsesStream, o as observeResponsesStream, pt as normalizeOpenAIReasoningEffort, q as findOpenAIStrictToolProjectionDiagnostics, t as ResponsesStreamFailure, ut as isOpenAIGpt54MiniModel, v as buildOpenAIResponsesReasoningReplayMetadata, vt as uniqueStrings, w as resolveAzureOpenAIApiVersion, x as createResponsesStreamWithEncryptedContentRetry, xt as resolveModelSseDebugMode, y as buildResponsesInputMessage, yt as emitModelTransportDebug, z as OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS } from "./openai-responses-stream-internal-Cw5txaGW.mjs";
|
|
18
|
+
import { t as createReasoningTagTextPartitioner } from "./reasoning-tag-text-partitioner-CGDyLWUR.mjs";
|
|
19
|
+
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-BBys9hSb.mjs";
|
|
20
|
+
import { i as resolveAzureDeploymentNameFromMap, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-C7K7QfUE.mjs";
|
|
18
21
|
import { randomUUID } from "node:crypto";
|
|
19
22
|
import OpenAI, { AzureOpenAI } from "openai";
|
|
20
23
|
//#region packages/ai/src/transports/anthropic-payload-policy.ts
|
|
@@ -39,7 +42,7 @@ function isLongTtlEligibleEndpoint(baseUrl) {
|
|
|
39
42
|
}
|
|
40
43
|
/** Resolve Anthropic cache-control marker retention for a request endpoint. */
|
|
41
44
|
function resolveAnthropicEphemeralCacheControl(baseUrl, cacheRetention) {
|
|
42
|
-
const retention = cacheRetention
|
|
45
|
+
const retention = resolveCacheRetention(cacheRetention);
|
|
43
46
|
if (retention === "none") return;
|
|
44
47
|
const ttl = retention === "long" && (cacheRetention === "long" || isLongTtlEligibleEndpoint(baseUrl)) ? "1h" : void 0;
|
|
45
48
|
return {
|
|
@@ -1736,12 +1739,12 @@ const OPENAI_CODEX_RESPONSES_PROVIDERS = /* @__PURE__ */ new Set(["openai"]);
|
|
|
1736
1739
|
const loggedOpenAIStrictToolDowngradeDiagnosticKeys = /* @__PURE__ */ new Set();
|
|
1737
1740
|
function readToolPayloadField(record, field) {
|
|
1738
1741
|
try {
|
|
1739
|
-
return record[field];
|
|
1742
|
+
return Object.hasOwn(record, field) ? record[field] : void 0;
|
|
1740
1743
|
} catch {
|
|
1741
1744
|
return;
|
|
1742
1745
|
}
|
|
1743
1746
|
}
|
|
1744
|
-
function
|
|
1747
|
+
function readCodeModePayloadToolName(tool) {
|
|
1745
1748
|
if (!isRecord(tool)) return;
|
|
1746
1749
|
const name = readToolPayloadField(tool, "name");
|
|
1747
1750
|
if (typeof name === "string") return name;
|
|
@@ -1750,17 +1753,44 @@ function transportPayloadToolName(tool) {
|
|
|
1750
1753
|
const fnName = readToolPayloadField(fn, "name");
|
|
1751
1754
|
return typeof fnName === "string" ? fnName : void 0;
|
|
1752
1755
|
}
|
|
1753
|
-
function
|
|
1754
|
-
if (!isRecord(payload)
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1756
|
+
function filterCodeModePayloadTools(payload, visibleToolNames) {
|
|
1757
|
+
if (!isRecord(payload)) return;
|
|
1758
|
+
const tools = readToolPayloadField(payload, "tools");
|
|
1759
|
+
if (!Array.isArray(tools)) return;
|
|
1760
|
+
payload.tools = tools.flatMap((tool) => {
|
|
1761
|
+
const name = readCodeModePayloadToolName(tool);
|
|
1762
|
+
if (typeof name === "string" && isCodeModeModelVisibleToolName(name, visibleToolNames)) return [tool];
|
|
1763
|
+
if (!isRecord(tool)) return [];
|
|
1764
|
+
const filteredGroups = {};
|
|
1765
|
+
for (const key of ["functionDeclarations", "function_declarations"]) {
|
|
1766
|
+
const declarations = readToolPayloadField(tool, key);
|
|
1767
|
+
if (!Array.isArray(declarations)) continue;
|
|
1768
|
+
const filtered = declarations.filter((declaration) => {
|
|
1769
|
+
const declarationName = readCodeModePayloadToolName(declaration);
|
|
1770
|
+
return typeof declarationName === "string" && isCodeModeModelVisibleToolName(declarationName, visibleToolNames);
|
|
1771
|
+
});
|
|
1772
|
+
if (filtered.length > 0) filteredGroups[key] = filtered;
|
|
1773
|
+
}
|
|
1774
|
+
return Object.keys(filteredGroups).length > 0 ? [filteredGroups] : [];
|
|
1758
1775
|
});
|
|
1759
1776
|
}
|
|
1760
|
-
function
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1777
|
+
function resolveCodeModeResponsesVisibleToolNames(context) {
|
|
1778
|
+
return new Set((context.tools ?? []).map(readCodeModePayloadToolName).filter((name) => typeof name === "string"));
|
|
1779
|
+
}
|
|
1780
|
+
function enforceCodeModeResponsesToolSurface(payload, visibleToolNames) {
|
|
1781
|
+
if (!isRecord(payload)) return;
|
|
1782
|
+
const tools = readToolPayloadField(payload, "tools");
|
|
1783
|
+
if (!Array.isArray(tools)) return;
|
|
1784
|
+
payload.tools = tools.filter((tool) => {
|
|
1785
|
+
const name = readCodeModePayloadToolName(tool);
|
|
1786
|
+
return typeof name === "string" && isCodeModeModelVisibleToolName(name, visibleToolNames);
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
function assertCodeModeResponsesToolSurface(payload, visibleToolNames) {
|
|
1790
|
+
const tools = isRecord(payload) ? readToolPayloadField(payload, "tools") : void 0;
|
|
1791
|
+
if (!Array.isArray(tools)) throw new Error("Code mode payload tool surface violation: expected exec,wait; got no tools");
|
|
1792
|
+
const names = tools.map(readCodeModePayloadToolName).filter((name) => typeof name === "string" && name.length > 0).toSorted((left, right) => left.localeCompare(right));
|
|
1793
|
+
if (names.length >= 2 && names.length === tools.length && new Set(names).size === names.length && names.includes("exec") && names.includes("wait") && names.every((name) => isCodeModeModelVisibleToolName(name, visibleToolNames))) return;
|
|
1764
1794
|
throw new Error(`Code mode payload tool surface violation: expected exec,wait plus direct-only tools; got ${names.length > 0 ? names.join(",") : "none"}`);
|
|
1765
1795
|
}
|
|
1766
1796
|
function buildOpenAIStrictToolDowngradeDiagnosticKey(diagnostics, context) {
|
|
@@ -1850,21 +1880,22 @@ function buildOpenAIClientHeaders(model, context, optionHeaders, turnHeaders, se
|
|
|
1850
1880
|
if (sessionId && !Object.keys(resolvedHeaders).some((key) => normalizeLowercaseStringOrEmpty(key) === "session_id") && usesNativeOpenAICodexResponsesBackend(model)) resolvedHeaders.session_id = clampOpenAIPromptCacheKey(sessionId) ?? sessionId;
|
|
1851
1881
|
return resolvedHeaders;
|
|
1852
1882
|
}
|
|
1853
|
-
function resolveOpenAISdkTimeoutMs(model) {
|
|
1854
|
-
return resolveModelRequestTimeoutMs(model,
|
|
1883
|
+
function resolveOpenAISdkTimeoutMs(model, timeoutMs) {
|
|
1884
|
+
return resolveModelRequestTimeoutMs(model, timeoutMs);
|
|
1855
1885
|
}
|
|
1856
1886
|
function buildOpenAISdkClientOptions(model) {
|
|
1857
1887
|
const timeout = resolveOpenAISdkTimeoutMs(model);
|
|
1858
1888
|
return timeout === void 0 ? {} : { timeout };
|
|
1859
1889
|
}
|
|
1860
1890
|
function buildOpenAISdkRequestOptions(model, signal, options) {
|
|
1861
|
-
const timeout = resolveOpenAISdkTimeoutMs(model);
|
|
1891
|
+
const timeout = resolveOpenAISdkTimeoutMs(model, options?.timeoutMs);
|
|
1862
1892
|
const headers = options?.stream === true && usesNativeOpenAICodexResponsesBackend(model) ? { Accept: "text/event-stream" } : void 0;
|
|
1863
|
-
if (timeout === void 0 && !signal && !headers) return;
|
|
1893
|
+
if (timeout === void 0 && options?.maxRetries === void 0 && !signal && !headers) return;
|
|
1864
1894
|
return {
|
|
1865
1895
|
...headers ? { headers } : {},
|
|
1866
1896
|
...signal ? { signal } : {},
|
|
1867
|
-
...timeout !== void 0 ? { timeout } : {}
|
|
1897
|
+
...timeout !== void 0 ? { timeout } : {},
|
|
1898
|
+
...options?.maxRetries !== void 0 ? { maxRetries: options.maxRetries } : {}
|
|
1868
1899
|
};
|
|
1869
1900
|
}
|
|
1870
1901
|
function getCompat(model) {
|
|
@@ -2034,13 +2065,17 @@ function createOpenAICompletionsTransportStreamFn() {
|
|
|
2034
2065
|
const nextParams = await options?.onPayload?.(params, model);
|
|
2035
2066
|
if (nextParams !== void 0) params = nextParams;
|
|
2036
2067
|
if (options?.openclawCodeModeToolSurface === true) {
|
|
2037
|
-
|
|
2038
|
-
|
|
2068
|
+
const visibleToolNames = resolveCodeModeResponsesVisibleToolNames(context);
|
|
2069
|
+
enforceCodeModeResponsesToolSurface(params, visibleToolNames);
|
|
2070
|
+
assertCodeModeResponsesToolSurface(params, visibleToolNames);
|
|
2039
2071
|
}
|
|
2040
2072
|
if (getCompat(model).requiresNonEmptyUserOrAssistantMessage) assertOpenAICompletionsPayloadHasConversationTurn(params, model);
|
|
2041
2073
|
const emitReasoning = shouldEmitOpenAICompletionsReasoning(model, options);
|
|
2042
2074
|
firstEventAbort = createFirstStreamEventAbortController(options?.signal);
|
|
2043
|
-
const responseStream = await client.chat.completions.create(params, buildOpenAISdkRequestOptions(model, firstEventAbort.signal
|
|
2075
|
+
const responseStream = await client.chat.completions.create(params, buildOpenAISdkRequestOptions(model, firstEventAbort.signal, {
|
|
2076
|
+
timeoutMs: options?.timeoutMs,
|
|
2077
|
+
maxRetries: options?.maxRetries
|
|
2078
|
+
}));
|
|
2044
2079
|
stream.push({
|
|
2045
2080
|
type: "start",
|
|
2046
2081
|
partial: output
|
|
@@ -2287,6 +2322,7 @@ async function processOpenAICompletionsStream(responseStream, output, model, str
|
|
|
2287
2322
|
await cooperativeScheduler.afterEvent();
|
|
2288
2323
|
continue;
|
|
2289
2324
|
}
|
|
2325
|
+
notifyLlmRequestActivity(options?.signal);
|
|
2290
2326
|
const chunk = rawChunk;
|
|
2291
2327
|
output.responseId ||= chunk.id;
|
|
2292
2328
|
let hasReasoningUsageActivity = false;
|
|
@@ -3691,12 +3727,17 @@ function createResponsesTransportExecutor(config) {
|
|
|
3691
3727
|
params = sanitizeOpenAICodexResponsesParams(model, params);
|
|
3692
3728
|
params = sanitizeResponsesImagePayload(params);
|
|
3693
3729
|
if (options?.openclawCodeModeToolSurface === true) {
|
|
3694
|
-
|
|
3695
|
-
|
|
3730
|
+
const visibleToolNames = resolveCodeModeResponsesVisibleToolNames(context);
|
|
3731
|
+
enforceCodeModeResponsesToolSurface(params, visibleToolNames);
|
|
3732
|
+
assertCodeModeResponsesToolSurface(params, visibleToolNames);
|
|
3696
3733
|
}
|
|
3697
3734
|
const requestStartedAt = Date.now();
|
|
3698
3735
|
firstEventAbort = createFirstStreamEventAbortController(options?.signal);
|
|
3699
|
-
const requestOptions = buildOpenAISdkRequestOptions(model, firstEventAbort.signal,
|
|
3736
|
+
const requestOptions = buildOpenAISdkRequestOptions(model, firstEventAbort.signal, {
|
|
3737
|
+
stream: config.streamRequest,
|
|
3738
|
+
timeoutMs: options?.timeoutMs,
|
|
3739
|
+
maxRetries: options?.maxRetries
|
|
3740
|
+
});
|
|
3700
3741
|
emitModelTransportDebug(log, `[responses] start provider=${model.provider} api=${model.api} model=${model.id} baseUrl=${formatModelTransportDebugBaseUrl(model.baseUrl)} timeoutMs=${safeDebugValue(requestOptions?.timeout)} apiKey=${apiKey ? "present" : "missing"} ${summarizeResponsesPayload(params)}`);
|
|
3701
3742
|
const responseStream = await config.createResponseStream({
|
|
3702
3743
|
client,
|
|
@@ -4066,4 +4107,4 @@ function prepareModelForSimpleCompletion(params) {
|
|
|
4066
4107
|
return applyProviderSimpleCompletionWrapper(apiRegistry, model, cfg);
|
|
4067
4108
|
}
|
|
4068
4109
|
//#endregion
|
|
4069
|
-
export { GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyOpenAIResponsesPayloadPolicy, assertCodeModeResponsesToolSurface, assignTransportErrorDetails, buildOpenAIClientHeaders, buildOpenAICompletionsParams, buildOpenAISdkClientOptions, buildOpenAISdkRequestOptions, buildTransportAwareSimpleStreamFn, canonicalizeMaxTokensParam, coerceTransportToolCallArguments, createAnthropicMessagesTransportStreamFn, createAzureOpenAIResponsesTransportStreamFn, createBoundaryAwareStreamFnForModel, createDeepSeekTextFilter, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createOpenAICompletionsTransportStreamFn, createOpenAIResponsesTransportStreamFn, createOpenClawTransportStreamFnForModel, createTransportAwareStreamFnForModel, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, enforceCodeModeResponsesToolSurface, failTransportStream, finalizeTransportStream, flattenCompletionMessagesToStringContent, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, getCompat, hasOpenAICompatibleConversationTurn, isCodeModeModelVisibleToolName, isOpenAICodexResponsesModel, log, mergeTransportHeaders, mergeTransportMetadata, normalizeCodexResponsesBaseUrlForOpenAISdk, parseJsonObjectPreservingUnsafeIntegers, parseJsonPreservingUnsafeIntegers, prepareModelForSimpleCompletion, prepareTransportAwareSimpleModel, quoteUnsafeIntegerLiterals, resolveAnthropicEphemeralCacheControl, resolveAnthropicMessagesUrl, resolveAnthropicPayloadPolicy,
|
|
4110
|
+
export { GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyOpenAIResponsesPayloadPolicy, assertCodeModeResponsesToolSurface, assignTransportErrorDetails, buildOpenAIClientHeaders, buildOpenAICompletionsParams, buildOpenAISdkClientOptions, buildOpenAISdkRequestOptions, buildTransportAwareSimpleStreamFn, canonicalizeMaxTokensParam, coerceTransportToolCallArguments, createAnthropicMessagesTransportStreamFn, createAzureOpenAIResponsesTransportStreamFn, createBoundaryAwareStreamFnForModel, createDeepSeekTextFilter, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createOpenAICompletionsTransportStreamFn, createOpenAIResponsesTransportStreamFn, createOpenClawTransportStreamFnForModel, createTransportAwareStreamFnForModel, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, enforceCodeModeResponsesToolSurface, failTransportStream, filterCodeModePayloadTools, finalizeTransportStream, flattenCompletionMessagesToStringContent, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, getCompat, hasOpenAICompatibleConversationTurn, isCodeModeModelVisibleToolName, isOpenAICodexResponsesModel, log, mergeTransportHeaders, mergeTransportMetadata, normalizeCodexResponsesBaseUrlForOpenAISdk, parseJsonObjectPreservingUnsafeIntegers, parseJsonPreservingUnsafeIntegers, prepareModelForSimpleCompletion, prepareTransportAwareSimpleModel, quoteUnsafeIntegerLiterals, readCodeModePayloadToolName, resolveAnthropicEphemeralCacheControl, resolveAnthropicMessagesUrl, resolveAnthropicPayloadPolicy, resolveCodeModeResponsesVisibleToolNames, resolveMaxTokensParam, resolveModelPayloadDebugMode, resolveModelSseDebugMode, resolveOpenAICompletionsCompat, resolveOpenAIReasoningEffortMap, resolveOpenAIResponsesPayloadPolicy, resolveOpenAIStrictToolFlagWithDiagnostics, resolvePromptCacheKey, resolveReplayableResponsesMessageId, resolveTransportAwareSimpleApi, sanitizeNonEmptyTransportPayloadText, sanitizeResponsesImagePayload, sanitizeTransportPayloadText, sortPromptCacheToolsByName as sortTransportToolsByName, stripCompletionMessagesToRoleContent, throwIfModelStreamAborted, transportAbortError, usesNativeOpenAICodexResponsesBackend };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/ai",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.7",
|
|
4
4
|
"description": "Reusable model provider adapters and streaming runtime from OpenClaw",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -93,10 +93,10 @@
|
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"@anthropic-ai/sdk": "0.
|
|
97
|
-
"@google/genai": "2.
|
|
96
|
+
"@anthropic-ai/sdk": "0.115.0",
|
|
97
|
+
"@google/genai": "2.13.0",
|
|
98
98
|
"@mistralai/mistralai": "2.5.0",
|
|
99
|
-
"openai": "6.
|
|
99
|
+
"openai": "6.49.0",
|
|
100
100
|
"partial-json": "0.1.7",
|
|
101
101
|
"typebox": "1.3.6"
|
|
102
102
|
},
|
package/dist/host-XYGZcgO8.mjs
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
//#region packages/ai/src/host.ts
|
|
2
|
-
const MAX_PENDING_CUSTOM_API_REGISTRATIONS = 32;
|
|
3
|
-
const pendingCustomApiRegistrations = [];
|
|
4
|
-
function queueCustomApiRegistration(registry, api, streamFn) {
|
|
5
|
-
const existing = pendingCustomApiRegistrations.find((registration) => registration.registry === registry && registration.api === api);
|
|
6
|
-
if (existing) {
|
|
7
|
-
existing.streamFn = streamFn;
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
if (pendingCustomApiRegistrations.length >= MAX_PENDING_CUSTOM_API_REGISTRATIONS) throw new Error("Too many custom transport APIs were registered before host configuration");
|
|
11
|
-
pendingCustomApiRegistrations.push({
|
|
12
|
-
registry,
|
|
13
|
-
api,
|
|
14
|
-
streamFn
|
|
15
|
-
});
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const inertAiTransportHost = {
|
|
19
|
-
buildModelFetch: () => void 0,
|
|
20
|
-
resolveSecretSentinel: (value) => value,
|
|
21
|
-
redactSecrets: (value) => value,
|
|
22
|
-
redactToolPayloadText: (text) => text,
|
|
23
|
-
normalizeAnthropicInlineContentBlocks: async (content) => [...content],
|
|
24
|
-
resolveOpenAIStrictToolSetting: (_model, options) => options?.supportsStrictMode ? false : void 0,
|
|
25
|
-
plugin: {
|
|
26
|
-
resolveProviderStream: () => void 0,
|
|
27
|
-
resolveTransportTurnState: () => void 0,
|
|
28
|
-
wrapSimpleCompletionStream: () => void 0,
|
|
29
|
-
createAnthropicVertexStream: () => {
|
|
30
|
-
throw new Error("Anthropic Vertex transport is not configured by the embedding host");
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
buildCopilotDynamicHeaders: () => ({}),
|
|
34
|
-
resolveProviderEndpointClass: () => "default",
|
|
35
|
-
resolveProviderRequestCapabilities: () => ({
|
|
36
|
-
endpointClass: "default",
|
|
37
|
-
knownProviderFamily: "",
|
|
38
|
-
supportsNativeStreamingUsageCompat: false,
|
|
39
|
-
supportsOpenAICompletionsStreamingUsageCompat: false,
|
|
40
|
-
usesExplicitProxyLikeEndpoint: false,
|
|
41
|
-
allowsAnthropicServiceTier: false
|
|
42
|
-
}),
|
|
43
|
-
resolveProviderRequestHeaders: ({ providerHeaders, callerHeaders, precedence }) => ({
|
|
44
|
-
...precedence === "caller-wins" ? providerHeaders : callerHeaders,
|
|
45
|
-
...precedence === "caller-wins" ? callerHeaders : providerHeaders
|
|
46
|
-
}),
|
|
47
|
-
resolveModelRequestTimeoutMs: () => void 0,
|
|
48
|
-
requiresManagedTransport: () => false,
|
|
49
|
-
inheritManagedTransport: (_source, target) => target,
|
|
50
|
-
transformTransportMessages: (messages) => messages,
|
|
51
|
-
registerCustomApi: queueCustomApiRegistration,
|
|
52
|
-
prepareGoogleSimpleCompletionModel: (_registry, model) => model,
|
|
53
|
-
logDebug: () => {},
|
|
54
|
-
logInfo: () => {},
|
|
55
|
-
logWarn: () => {}
|
|
56
|
-
};
|
|
57
|
-
let activeAiTransportHost = inertAiTransportHost;
|
|
58
|
-
/** Installs host implementations for the transport policy ports. */
|
|
59
|
-
function configureAiTransportHost(host) {
|
|
60
|
-
activeAiTransportHost = {
|
|
61
|
-
...inertAiTransportHost,
|
|
62
|
-
...host,
|
|
63
|
-
normalizeAnthropicInlineContentBlocks: host.normalizeAnthropicInlineContentBlocks ?? inertAiTransportHost.normalizeAnthropicInlineContentBlocks,
|
|
64
|
-
plugin: {
|
|
65
|
-
...inertAiTransportHost.plugin,
|
|
66
|
-
...host.plugin
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const transportHost = activeAiTransportHost;
|
|
70
|
-
if (transportHost.registerCustomApi === inertAiTransportHost.registerCustomApi || pendingCustomApiRegistrations.length === 0) return;
|
|
71
|
-
const pending = pendingCustomApiRegistrations.splice(0);
|
|
72
|
-
for (const [index, registration] of pending.entries()) try {
|
|
73
|
-
transportHost.registerCustomApi(registration.registry, registration.api, registration.streamFn);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
pendingCustomApiRegistrations.unshift(...pending.slice(index));
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/** Returns the active transport host (inert defaults unless configured). */
|
|
80
|
-
function getAiTransportHost() {
|
|
81
|
-
return activeAiTransportHost;
|
|
82
|
-
}
|
|
83
|
-
/** Resolves sentinel substrings in custom headers at a no-fetch adapter boundary. */
|
|
84
|
-
function resolveAiTransportHeaderSentinels(headers) {
|
|
85
|
-
if (!headers) return;
|
|
86
|
-
const host = getAiTransportHost();
|
|
87
|
-
let resolvedHeaders;
|
|
88
|
-
for (const [name, value] of Object.entries(headers)) {
|
|
89
|
-
const resolved = host.resolveSecretSentinel(value);
|
|
90
|
-
if (resolved !== value) {
|
|
91
|
-
resolvedHeaders ??= { ...headers };
|
|
92
|
-
resolvedHeaders[name] = resolved;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return resolvedHeaders ?? headers;
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
export { getAiTransportHost as n, resolveAiTransportHeaderSentinels as r, configureAiTransportHost as t };
|