@openclaw/ai 2026.7.2-beta.7 → 2026.7.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/dist/{anthropic-CH4UUnZr.mjs → anthropic-Bcdbq-l5.mjs} +467 -100
- package/dist/{api-registry-DlMgPR39.d.mts → api-registry-BXYnCOIR.d.mts} +2 -1
- package/dist/{azure-openai-responses-CImcwB83.mjs → azure-openai-responses-2xhpNPWg.mjs} +13 -11
- package/dist/{azure-openai-responses-client-compat-C7K7QfUE.mjs → azure-openai-responses-client-compat-a_O_GVQV.mjs} +2 -23
- package/dist/{env-api-keys-DrgeBuva.mjs → env-api-keys-CtMlqaQ4.mjs} +4 -5
- package/dist/{event-stream-YjaPW20U.d.mts → event-stream-0nZeBKl2.d.mts} +1 -1
- package/dist/{event-stream-D8n2uFee.mjs → event-stream-ReMmOTzX.mjs} +6 -14
- package/dist/event-stream.d.mts +1 -1
- package/dist/event-stream.mjs +1 -1
- package/dist/{github-copilot-headers-NCJtz9i0.mjs → github-copilot-headers-BsH5cqGj.mjs} +12 -1
- package/dist/{google-CtSg0iTS.mjs → google-C6P31moq.mjs} +5 -5
- package/dist/{google-shared-DNBz5rcD.mjs → google-shared-BeyXFAcf.mjs} +26 -34
- package/dist/{google-vertex-31f1uS9L.mjs → google-vertex--9_gT74B.mjs} +19 -6
- package/dist/host-4t713IeR.mjs +37 -0
- package/dist/{anthropic-SrGtwsJu.d.mts → index-CGDEoorl.d.mts} +2 -6
- package/dist/index.d.mts +50 -7
- package/dist/index.mjs +5 -5
- package/dist/internal/anthropic.d.mts +61 -21
- package/dist/internal/anthropic.mjs +4 -5
- package/dist/internal/openai.d.mts +89 -98
- package/dist/internal/openai.mjs +6 -8
- package/dist/internal/runtime.d.mts +34 -13
- package/dist/internal/runtime.mjs +14 -26
- package/dist/internal/shared.d.mts +9 -26
- package/dist/internal/shared.mjs +2 -6
- package/dist/{json-parse-BvXNt1-7.mjs → json-parse-DzNSIQBq.mjs} +6 -4
- package/dist/{llm-request-activity-BjtkplhG.mjs → llm-request-activity-CehVkZP-.mjs} +19 -1
- package/dist/{mistral-CWmpvWYh.mjs → mistral-CBm3OQWD.mjs} +39 -141
- package/dist/model-utils-Cn9KAz3z.mjs +69 -0
- package/dist/{openai-chatgpt-responses-B84Ibtrd.mjs → openai-chatgpt-responses-M2RVpycr.mjs} +154 -101
- package/dist/{openai-completions-DsOxhOD1.mjs → openai-completions-BUlMEeBc.mjs} +295 -81
- package/dist/{openai-responses-BT7A3sLu.mjs → openai-responses-DW61C22l.mjs} +9 -14
- package/dist/openai-responses-shared-BhYsVkwW.mjs +1949 -0
- package/dist/{openai-tool-projection-OhX64DoP.mjs → openai-tool-projection-g4HuxD26.mjs} +20 -31
- package/dist/providers.d.mts +2 -3
- package/dist/providers.mjs +10 -11
- package/dist/reasoning-tag-text-partitioner-axhAdUwg.mjs +394 -0
- package/dist/{src-QkygScBs.mjs → src-CjOfhrH3.mjs} +6 -17
- package/dist/{stream-first-event-timeout-BBys9hSb.mjs → stream-first-event-timeout-RjWszj8c.mjs} +22 -2
- package/dist/transform-messages-DoWx35pj.mjs +509 -0
- package/dist/{types-bzp5k29J.d.mts → types-DRgdPqaZ.d.mts} +0 -19
- package/dist/types.d.mts +5 -5
- package/dist/types.mjs +4 -4
- package/dist/{validation-B-j7cOYp.d.mts → validation-BDMWOr8d.d.mts} +1 -1
- package/dist/{validation-DAa_yFOM.mjs → validation-FrchoOlv.mjs} +7 -2
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/npm-shrinkwrap.json +645 -0
- package/package.json +11 -36
- package/dist/anthropic-usage-DWU-x8MI.mjs +0 -459
- package/dist/cache-retention-0x979a5V.mjs +0 -12
- package/dist/deferred-event-buffer-DAvyP7qA.mjs +0 -19
- package/dist/error-coercion-DgxlWC0n.mjs +0 -15
- package/dist/host-B9GUmcra.d.mts +0 -173
- package/dist/host-Dog2WQiR.mjs +0 -369
- package/dist/index-BVVgDSdq.d.mts +0 -1
- package/dist/internal/retry-after.d.mts +0 -5
- package/dist/internal/retry-after.mjs +0 -101
- package/dist/number-coercion-DvG7SNMg.mjs +0 -129
- package/dist/openai-completions-compat-DBWjXoMZ.d.mts +0 -43
- package/dist/openai-prompt-cache-2uo_1OR1.d.mts +0 -7
- package/dist/openai-prompt-cache-mZTCdRPo.mjs +0 -12
- package/dist/openai-reasoning-compat-YgeLncHw.mjs +0 -396
- package/dist/openai-responses-shared-pXl6Wd8S.mjs +0 -392
- package/dist/openai-responses-stream-internal-Cw5txaGW.mjs +0 -2964
- package/dist/prompt-cache-stability-Cwcjv_fx.d.mts +0 -13
- package/dist/provider-error-CAEvRjry.mjs +0 -47
- package/dist/provider-options-D8bB3z9b.d.mts +0 -144
- package/dist/reasoning-tag-text-partitioner-CGDyLWUR.mjs +0 -12209
- package/dist/simple-options-9lhRrN73.mjs +0 -50
- package/dist/stream-first-event-timeout-DvDeSucC.d.mts +0 -29
- package/dist/tls-certificate-errors-DXSpluKI.mjs +0 -93
- package/dist/tool-result-text-CTpIRbYd.mjs +0 -225
- package/dist/transform-messages-C8mBqZxF.mjs +0 -2
- package/dist/transport-stream-shared-D81p90xq.mjs +0 -297
- package/dist/transports.d.mts +0 -573
- package/dist/transports.mjs +0 -4110
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { E as Model, F as SimpleStreamOptions, R as StreamFunction, n as Api, o as AssistantMessageEventStreamContract, u as Context, z as StreamOptions } from "./types-
|
|
1
|
+
import { E as Model, F as SimpleStreamOptions, R as StreamFunction, n as Api, o as AssistantMessageEventStreamContract, u as Context, z as StreamOptions } from "./types-DRgdPqaZ.mjs";
|
|
2
|
+
|
|
2
3
|
//#region packages/ai/src/api-registry.d.ts
|
|
3
4
|
/** Runtime stream adapter signature stored in the API provider registry. */
|
|
4
5
|
type ApiStreamFunction = (model: Model, context: Context, options?: StreamOptions) => AssistantMessageEventStreamContract;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { n as getEnvApiKey } from "./env-api-keys-
|
|
2
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
3
|
-
import { n as getAiTransportHost } from "./host-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { a as
|
|
1
|
+
import { n as getEnvApiKey } from "./env-api-keys-CtMlqaQ4.mjs";
|
|
2
|
+
import { t as AssistantMessageEventStream } from "./event-stream-ReMmOTzX.mjs";
|
|
3
|
+
import { n as getAiTransportHost } from "./host-4t713IeR.mjs";
|
|
4
|
+
import { o as buildBaseOptions } from "./transform-messages-DoWx35pj.mjs";
|
|
5
|
+
import { a as resolveResponsesReasoningEffort, n as convertResponsesMessages, o as runResponsesStreamLifecycle, r as createResponsesAssistantOutput, t as applyCommonResponsesParams } from "./openai-responses-shared-BhYsVkwW.mjs";
|
|
6
|
+
import { i as resolveAzureDeploymentNameFromMap, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-a_O_GVQV.mjs";
|
|
7
|
+
import { a as clampOpenAIPromptCacheKey } from "./openai-tool-projection-g4HuxD26.mjs";
|
|
8
8
|
import OpenAI, { AzureOpenAI } from "openai";
|
|
9
9
|
//#region packages/ai/src/providers/azure-openai-responses.ts
|
|
10
10
|
const DEFAULT_AZURE_API_VERSION = "v1";
|
|
@@ -94,8 +94,11 @@ function resolveAzureConfig(model, options) {
|
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
function createClient(model, apiKeyInput, options) {
|
|
97
|
-
|
|
98
|
-
if (!apiKey)
|
|
97
|
+
let apiKey = apiKeyInput;
|
|
98
|
+
if (!apiKey) {
|
|
99
|
+
if (!process.env.AZURE_OPENAI_API_KEY) throw new Error("Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.");
|
|
100
|
+
apiKey = process.env.AZURE_OPENAI_API_KEY;
|
|
101
|
+
}
|
|
99
102
|
const headers = { ...model.headers };
|
|
100
103
|
if (options?.headers) Object.assign(headers, options.headers);
|
|
101
104
|
const { baseUrl, apiVersion } = resolveAzureConfig(model, options);
|
|
@@ -124,8 +127,7 @@ function buildParams(model, context, options, deploymentName) {
|
|
|
124
127
|
model: deploymentName,
|
|
125
128
|
input: convertResponsesMessages(model, context, AZURE_TOOL_CALL_PROVIDERS),
|
|
126
129
|
stream: true,
|
|
127
|
-
prompt_cache_key: options?.cacheRetention === "none" ? void 0 : clampOpenAIPromptCacheKey(options?.promptCacheKey ?? options?.sessionId)
|
|
128
|
-
store: false
|
|
130
|
+
prompt_cache_key: options?.cacheRetention === "none" ? void 0 : clampOpenAIPromptCacheKey(options?.promptCacheKey ?? options?.sessionId)
|
|
129
131
|
};
|
|
130
132
|
applyCommonResponsesParams(params, model, context, options);
|
|
131
133
|
return params;
|
|
@@ -15,30 +15,9 @@ function parseAzureDeploymentNameMap(value) {
|
|
|
15
15
|
}
|
|
16
16
|
return map;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
function getDeploymentLookup(source) {
|
|
20
|
-
const cached = cachedDeploymentLookup;
|
|
21
|
-
if (cached && cached.source === source) return cached;
|
|
22
|
-
const exact = parseAzureDeploymentNameMap(source);
|
|
23
|
-
const folded = /* @__PURE__ */ new Map();
|
|
24
|
-
for (const [modelId, deploymentName] of exact) folded.set(modelId.toLowerCase(), deploymentName);
|
|
25
|
-
cachedDeploymentLookup = {
|
|
26
|
-
source,
|
|
27
|
-
exact,
|
|
28
|
-
folded
|
|
29
|
-
};
|
|
30
|
-
return cachedDeploymentLookup;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Resolves the Azure deployment name for a model id, falling back to the model id.
|
|
34
|
-
*
|
|
35
|
-
* An exact-case match always wins, so configs that intentionally distinguish keys by
|
|
36
|
-
* case keep their exact mappings; a case-insensitive match is only used as a fallback
|
|
37
|
-
* (e.g. `GPT-4o` against a `gpt-4o=...` map) to avoid 404s from casing differences.
|
|
38
|
-
*/
|
|
18
|
+
/** Resolves the Azure deployment name for a model id, falling back to the model id. */
|
|
39
19
|
function resolveAzureDeploymentNameFromMap(params) {
|
|
40
|
-
|
|
41
|
-
return exact.get(params.modelId) ?? folded.get(params.modelId.toLowerCase()) ?? params.modelId;
|
|
20
|
+
return parseAzureDeploymentNameMap(params.deploymentMap).get(params.modelId) || params.modelId;
|
|
42
21
|
}
|
|
43
22
|
//#endregion
|
|
44
23
|
//#region packages/ai/src/providers/azure-openai-responses-client-compat.ts
|
|
@@ -70,9 +70,8 @@ function getProcEnv(key) {
|
|
|
70
70
|
if (procEnvCache === null) {
|
|
71
71
|
procEnvCache = /* @__PURE__ */ new Map();
|
|
72
72
|
try {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const data = fsModule.readFileSync("/proc/self/environ", "utf-8");
|
|
73
|
+
const { readFileSync } = __require("node:fs");
|
|
74
|
+
const data = readFileSync("/proc/self/environ", "utf-8");
|
|
76
75
|
for (const entry of data.split("\0")) {
|
|
77
76
|
const idx = entry.indexOf("=");
|
|
78
77
|
if (idx > 0) procEnvCache.set(entry.slice(0, idx), entry.slice(idx + 1));
|
|
@@ -82,7 +81,7 @@ function getProcEnv(key) {
|
|
|
82
81
|
return procEnvCache.get(key);
|
|
83
82
|
}
|
|
84
83
|
function getEnvValue(key) {
|
|
85
|
-
return
|
|
84
|
+
return getProcessEnv()?.[key] || getProcEnv(key);
|
|
86
85
|
}
|
|
87
86
|
let cachedVertexAdcCredentialsExists = null;
|
|
88
87
|
function hasVertexAdcCredentials() {
|
|
@@ -107,7 +106,7 @@ function getApiKeyEnvVars(provider) {
|
|
|
107
106
|
if (provider === "kimi" || provider === "kimi-coding") return ["KIMI_API_KEY", "KIMICODE_API_KEY"];
|
|
108
107
|
const envVar = {
|
|
109
108
|
openai: "OPENAI_API_KEY",
|
|
110
|
-
meta: "MODEL_API_KEY",
|
|
109
|
+
"meta": "MODEL_API_KEY",
|
|
111
110
|
"azure-openai-responses": "AZURE_OPENAI_API_KEY",
|
|
112
111
|
deepseek: "DEEPSEEK_API_KEY",
|
|
113
112
|
google: "GEMINI_API_KEY",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AssistantMessageEvent, i as AssistantMessage, o as AssistantMessageEventStreamContract } from "./types-
|
|
1
|
+
import { a as AssistantMessageEvent, i as AssistantMessage, o as AssistantMessageEventStreamContract } from "./types-DRgdPqaZ.mjs";
|
|
2
2
|
|
|
3
3
|
//#region packages/llm-core/src/utils/event-stream.d.ts
|
|
4
4
|
/** Generic async-iterable event stream with a separately awaited final result. */
|
|
@@ -7,13 +7,9 @@ var EventStream = class {
|
|
|
7
7
|
this.done = false;
|
|
8
8
|
this.isComplete = isComplete;
|
|
9
9
|
this.extractResult = extractResult;
|
|
10
|
-
const resolvers = [];
|
|
11
10
|
this.finalResultPromise = new Promise((resolve) => {
|
|
12
|
-
|
|
11
|
+
this.resolveFinalResult = resolve;
|
|
13
12
|
});
|
|
14
|
-
const resolveFinalResult = resolvers.at(0);
|
|
15
|
-
if (!resolveFinalResult) throw new Error("event stream result promise did not initialize its resolver");
|
|
16
|
-
this.resolveFinalResult = resolveFinalResult;
|
|
17
13
|
}
|
|
18
14
|
push(event) {
|
|
19
15
|
if (this.done) return;
|
|
@@ -31,17 +27,13 @@ var EventStream = class {
|
|
|
31
27
|
end(result) {
|
|
32
28
|
this.done = true;
|
|
33
29
|
if (result !== void 0) this.resolveFinalResult(result);
|
|
34
|
-
while (this.waiting.length > 0) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
value: void 0,
|
|
39
|
-
done: true
|
|
40
|
-
});
|
|
41
|
-
}
|
|
30
|
+
while (this.waiting.length > 0) this.waiting.shift()({
|
|
31
|
+
value: void 0,
|
|
32
|
+
done: true
|
|
33
|
+
});
|
|
42
34
|
}
|
|
43
35
|
async *[Symbol.asyncIterator]() {
|
|
44
|
-
while (true) if (this.queue.length > 0)
|
|
36
|
+
while (true) if (this.queue.length > 0) yield this.queue.shift();
|
|
45
37
|
else if (this.done) return;
|
|
46
38
|
else {
|
|
47
39
|
const result = await new Promise((resolve) => {
|
package/dist/event-stream.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
1
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-0nZeBKl2.mjs";
|
|
2
2
|
export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
|
package/dist/event-stream.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
1
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-ReMmOTzX.mjs";
|
|
2
2
|
export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
//#region packages/ai/src/providers/cache-retention.ts
|
|
2
|
+
/**
|
|
3
|
+
* Resolve cache retention preference.
|
|
4
|
+
* Defaults to "short" and uses OPENCLAW_CACHE_RETENTION for backward compatibility.
|
|
5
|
+
*/
|
|
6
|
+
function resolveCacheRetention(cacheRetention) {
|
|
7
|
+
if (cacheRetention) return cacheRetention;
|
|
8
|
+
if (typeof process !== "undefined" && process.env.OPENCLAW_CACHE_RETENTION === "long") return "long";
|
|
9
|
+
return "short";
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
1
12
|
//#region packages/ai/src/providers/cloudflare.ts
|
|
2
13
|
function isCloudflareProvider(provider) {
|
|
3
14
|
return provider === "cloudflare-workers-ai" || provider === "cloudflare-ai-gateway";
|
|
@@ -34,4 +45,4 @@ function buildCopilotDynamicHeaders(params) {
|
|
|
34
45
|
return headers;
|
|
35
46
|
}
|
|
36
47
|
//#endregion
|
|
37
|
-
export { resolveCloudflareBaseUrl as i, hasCopilotVisionInput as n, isCloudflareProvider as r, buildCopilotDynamicHeaders as t };
|
|
48
|
+
export { resolveCacheRetention as a, resolveCloudflareBaseUrl as i, hasCopilotVisionInput as n, isCloudflareProvider as r, buildCopilotDynamicHeaders as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as getEnvApiKey } from "./env-api-keys-
|
|
2
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
3
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-
|
|
4
|
-
import {
|
|
5
|
-
import { a as runGoogleGenerateContentLifecycle, i as getDisabledGoogleThinkingConfig, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-
|
|
1
|
+
import { n as getEnvApiKey } from "./env-api-keys-CtMlqaQ4.mjs";
|
|
2
|
+
import { t as AssistantMessageEventStream } from "./event-stream-ReMmOTzX.mjs";
|
|
3
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-4t713IeR.mjs";
|
|
4
|
+
import { o as buildBaseOptions } from "./transform-messages-DoWx35pj.mjs";
|
|
5
|
+
import { a as runGoogleGenerateContentLifecycle, i as getDisabledGoogleThinkingConfig, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-BeyXFAcf.mjs";
|
|
6
6
|
import { GoogleGenAI } from "@google/genai";
|
|
7
7
|
//#region packages/ai/src/providers/google.ts
|
|
8
8
|
let toolCallCounter = 0;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as calculateCost, r as clampThinkingLevel } from "./model-utils-Cn9KAz3z.mjs";
|
|
2
2
|
import { t as sanitizeSurrogates } from "./sanitize-unicode-DT5o51ur.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { d as transportAbortError } from "./transport-stream-shared-D81p90xq.mjs";
|
|
6
|
-
import { t as formatProviderError } from "./provider-error-CAEvRjry.mjs";
|
|
7
|
-
import "./transform-messages-C8mBqZxF.mjs";
|
|
8
|
-
import { FinishReason, FunctionCallingConfigMode, ThinkingLevel } from "@google/genai";
|
|
3
|
+
import { b as stripSystemPromptCacheBoundary, i as extractToolResultText, n as describeToolResultMediaPlaceholder, t as transformMessages } from "./transform-messages-DoWx35pj.mjs";
|
|
4
|
+
import { FinishReason, FunctionCallingConfigMode } from "@google/genai";
|
|
9
5
|
//#region packages/ai/src/providers/google-shared.ts
|
|
10
6
|
/**
|
|
11
7
|
* Shared utilities for Google Generative AI and Google Vertex providers.
|
|
@@ -36,7 +32,6 @@ function isThinkingPart(part) {
|
|
|
36
32
|
*
|
|
37
33
|
* Note: this does NOT merge or move signatures across distinct response parts. It only prevents
|
|
38
34
|
* a signature from being overwritten with `undefined` within the same streamed block.
|
|
39
|
-
* @internal Directly tested provider implementation detail.
|
|
40
35
|
*/
|
|
41
36
|
function retainThoughtSignature(existing, incoming) {
|
|
42
37
|
if (typeof incoming === "string" && incoming.length > 0) return incoming;
|
|
@@ -56,16 +51,14 @@ function resolveThoughtSignature(isSameProviderAndModel, signature) {
|
|
|
56
51
|
}
|
|
57
52
|
/**
|
|
58
53
|
* Models via Google APIs that require explicit tool call IDs in function calls/responses.
|
|
59
|
-
* @internal Directly tested provider implementation detail.
|
|
60
54
|
*/
|
|
61
55
|
function requiresToolCallId(modelId) {
|
|
62
56
|
return modelId.startsWith("claude-") || modelId.startsWith("gpt-oss-");
|
|
63
57
|
}
|
|
64
58
|
function getGeminiMajorVersion(modelId) {
|
|
65
|
-
const match = modelId.toLowerCase().match(
|
|
59
|
+
const match = modelId.toLowerCase().match(/^gemini(?:-live)?-(\d+)/);
|
|
66
60
|
if (!match) return;
|
|
67
|
-
|
|
68
|
-
return majorVersion === void 0 ? void 0 : Number.parseInt(majorVersion, 10);
|
|
61
|
+
return Number.parseInt(match[1], 10);
|
|
69
62
|
}
|
|
70
63
|
function supportsMultimodalFunctionResponse(modelId) {
|
|
71
64
|
const geminiMajorVersion = getGeminiMajorVersion(modelId);
|
|
@@ -74,7 +67,6 @@ function supportsMultimodalFunctionResponse(modelId) {
|
|
|
74
67
|
}
|
|
75
68
|
/**
|
|
76
69
|
* Convert internal messages to Gemini Content[] format.
|
|
77
|
-
* @internal Directly tested provider implementation detail.
|
|
78
70
|
*/
|
|
79
71
|
function convertMessages(model, context) {
|
|
80
72
|
const contents = [];
|
|
@@ -149,7 +141,7 @@ function convertMessages(model, context) {
|
|
|
149
141
|
});
|
|
150
142
|
} else if (msg.role === "toolResult") {
|
|
151
143
|
const textResult = extractToolResultText(msg.content);
|
|
152
|
-
const imageContent = model.input.includes("image") ? msg.content.filter(
|
|
144
|
+
const imageContent = model.input.includes("image") ? msg.content.filter((c) => c.type === "image") : [];
|
|
153
145
|
const hasText = textResult.length > 0;
|
|
154
146
|
const hasImages = imageContent.length > 0;
|
|
155
147
|
const mediaPlaceholder = describeToolResultMediaPlaceholder(msg.content);
|
|
@@ -212,7 +204,6 @@ function sanitizeForOpenApi(schema) {
|
|
|
212
204
|
* anyOf, oneOf, const, etc.). Set `useParameters` to true to use the legacy `parameters`
|
|
213
205
|
* field instead (OpenAPI 3.03 Schema). This is needed for Cloud Code Assist with Claude
|
|
214
206
|
* models, where the API translates `parameters` into Anthropic's `input_schema`.
|
|
215
|
-
* @internal Directly tested provider implementation detail.
|
|
216
207
|
*/
|
|
217
208
|
function convertTools(tools, useParameters = false) {
|
|
218
209
|
if (tools.length === 0) return;
|
|
@@ -224,7 +215,6 @@ function convertTools(tools, useParameters = false) {
|
|
|
224
215
|
}
|
|
225
216
|
/**
|
|
226
217
|
* Map tool choice string to Gemini FunctionCallingConfigMode.
|
|
227
|
-
* @internal Directly tested provider implementation detail.
|
|
228
218
|
*/
|
|
229
219
|
function mapToolChoice(choice) {
|
|
230
220
|
switch (choice) {
|
|
@@ -277,7 +267,7 @@ async function runGoogleGenerateContentLifecycle(params) {
|
|
|
277
267
|
} catch (error) {
|
|
278
268
|
for (const block of output.content) if ("index" in block) delete block.index;
|
|
279
269
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
280
|
-
output.errorMessage =
|
|
270
|
+
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
281
271
|
stream.push({
|
|
282
272
|
type: "error",
|
|
283
273
|
reason: output.stopReason,
|
|
@@ -301,7 +291,7 @@ function buildGoogleGenerateContentParams(model, context, options = {}, configHo
|
|
|
301
291
|
else config.toolConfig = void 0;
|
|
302
292
|
if (options.thinking?.enabled && model.reasoning) {
|
|
303
293
|
const thinkingConfig = { includeThoughts: true };
|
|
304
|
-
if (options.thinking.level !== void 0) thinkingConfig.thinkingLevel =
|
|
294
|
+
if (options.thinking.level !== void 0) thinkingConfig.thinkingLevel = configHooks?.mapThinkingLevel ? configHooks.mapThinkingLevel(options.thinking.level) : options.thinking.level;
|
|
305
295
|
else if (options.thinking.budgetTokens !== void 0) thinkingConfig.thinkingBudget = options.thinking.budgetTokens;
|
|
306
296
|
config.thinkingConfig = thinkingConfig;
|
|
307
297
|
} else if (model.reasoning && options.thinking && !options.thinking.enabled) config.thinkingConfig = configHooks?.getDisabledThinkingConfig ? configHooks.getDisabledThinkingConfig(model) : getDisabledGoogleThinkingConfig(model);
|
|
@@ -330,12 +320,12 @@ function buildGoogleSimpleThinking(model, options, config) {
|
|
|
330
320
|
};
|
|
331
321
|
}
|
|
332
322
|
function getDisabledGoogleThinkingConfig(model, config) {
|
|
333
|
-
|
|
334
|
-
if (
|
|
335
|
-
if (
|
|
323
|
+
const mapThinkingLevel = (level) => config?.mapThinkingLevel ? config.mapThinkingLevel(level) : level;
|
|
324
|
+
if (isGemini3ProModel(model)) return { thinkingLevel: mapThinkingLevel("LOW") };
|
|
325
|
+
if (isGemini3FlashModel(model)) return { thinkingLevel: mapThinkingLevel(googleFlashSupportsMinimalThinking(model.id) ? "MINIMAL" : "LOW") };
|
|
326
|
+
if (config?.includeGemma4 && isGemma4Model(model)) return { thinkingLevel: mapThinkingLevel("MINIMAL") };
|
|
336
327
|
return { thinkingBudget: 0 };
|
|
337
328
|
}
|
|
338
|
-
/** @internal Directly tested provider implementation detail. */
|
|
339
329
|
function isGemma4Model(model) {
|
|
340
330
|
return /gemma-?4/.test(model.id.toLowerCase());
|
|
341
331
|
}
|
|
@@ -345,26 +335,30 @@ function isGemini3ProModel(model) {
|
|
|
345
335
|
function isGemini3FlashModel(model) {
|
|
346
336
|
return /gemini-3(?:\.\d+)?-flash/.test(model.id.toLowerCase());
|
|
347
337
|
}
|
|
338
|
+
function googleFlashSupportsMinimalThinking(modelId) {
|
|
339
|
+
const match = modelId.toLowerCase().match(/(?:^|\/)gemini-3\.(\d+)-flash(?:-|$)/);
|
|
340
|
+
return !match || Number.parseInt(match[1] ?? "0", 10) < 7;
|
|
341
|
+
}
|
|
348
342
|
function getGoogleThinkingLevel(effort, model, config) {
|
|
349
343
|
if (isGemini3ProModel(model)) switch (effort) {
|
|
350
344
|
case "minimal":
|
|
351
|
-
case "low": return
|
|
345
|
+
case "low": return "LOW";
|
|
352
346
|
case "medium":
|
|
353
|
-
case "high": return
|
|
347
|
+
case "high": return "HIGH";
|
|
354
348
|
}
|
|
355
349
|
if (config?.includeGemma4 && isGemma4Model(model)) switch (effort) {
|
|
356
350
|
case "minimal":
|
|
357
|
-
case "low": return
|
|
351
|
+
case "low": return "MINIMAL";
|
|
358
352
|
case "medium":
|
|
359
|
-
case "high": return
|
|
353
|
+
case "high": return "HIGH";
|
|
360
354
|
}
|
|
361
355
|
switch (effort) {
|
|
362
|
-
case "minimal": return
|
|
363
|
-
case "low": return
|
|
364
|
-
case "medium": return
|
|
365
|
-
case "high": return
|
|
356
|
+
case "minimal": return isGemini3FlashModel(model) && !googleFlashSupportsMinimalThinking(model.id) ? "LOW" : "MINIMAL";
|
|
357
|
+
case "low": return "LOW";
|
|
358
|
+
case "medium": return "MEDIUM";
|
|
359
|
+
case "high": return "HIGH";
|
|
366
360
|
}
|
|
367
|
-
return
|
|
361
|
+
return "HIGH";
|
|
368
362
|
}
|
|
369
363
|
function getGoogleBudget(model, effort, customBudgets, config) {
|
|
370
364
|
if (customBudgets?.[effort] !== void 0) return customBudgets[effort];
|
|
@@ -390,7 +384,6 @@ function getGoogleBudget(model, effort, customBudgets, config) {
|
|
|
390
384
|
}
|
|
391
385
|
/**
|
|
392
386
|
* Map Gemini FinishReason to our StopReason.
|
|
393
|
-
* @internal Directly tested provider implementation detail.
|
|
394
387
|
*/
|
|
395
388
|
function mapStopReason(reason) {
|
|
396
389
|
switch (reason) {
|
|
@@ -414,7 +407,6 @@ function mapStopReason(reason) {
|
|
|
414
407
|
default: throw new Error(`Unhandled stop reason: ${String(reason)}`);
|
|
415
408
|
}
|
|
416
409
|
}
|
|
417
|
-
/** @internal Directly tested provider implementation detail. */
|
|
418
410
|
async function consumeGoogleGenerateContentStream(params) {
|
|
419
411
|
params.stream.push({
|
|
420
412
|
type: "start",
|
|
@@ -548,7 +540,7 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
548
540
|
}
|
|
549
541
|
}
|
|
550
542
|
endCurrentBlock();
|
|
551
|
-
if (params.signal?.aborted) throw
|
|
543
|
+
if (params.signal?.aborted) throw new Error("Request was aborted");
|
|
552
544
|
if (params.output.stopReason === "aborted" || params.output.stopReason === "error") throw new Error("An unknown error occurred");
|
|
553
545
|
params.stream.push({
|
|
554
546
|
type: "done",
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
2
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-
|
|
3
|
-
import {
|
|
4
|
-
import { a as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-
|
|
5
|
-
import { GoogleGenAI, ResourceScope } from "@google/genai";
|
|
1
|
+
import { t as AssistantMessageEventStream } from "./event-stream-ReMmOTzX.mjs";
|
|
2
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-4t713IeR.mjs";
|
|
3
|
+
import { o as buildBaseOptions } from "./transform-messages-DoWx35pj.mjs";
|
|
4
|
+
import { a as runGoogleGenerateContentLifecycle, i as getDisabledGoogleThinkingConfig, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-BeyXFAcf.mjs";
|
|
5
|
+
import { GoogleGenAI, ResourceScope, ThinkingLevel } from "@google/genai";
|
|
6
6
|
//#region packages/ai/src/providers/google-vertex.ts
|
|
7
7
|
const API_VERSION = "v1";
|
|
8
8
|
const GCP_VERTEX_CREDENTIALS_MARKER = "gcp-vertex-credentials";
|
|
9
|
+
const THINKING_LEVEL_MAP = {
|
|
10
|
+
THINKING_LEVEL_UNSPECIFIED: ThinkingLevel.THINKING_LEVEL_UNSPECIFIED,
|
|
11
|
+
MINIMAL: ThinkingLevel.MINIMAL,
|
|
12
|
+
LOW: ThinkingLevel.LOW,
|
|
13
|
+
MEDIUM: ThinkingLevel.MEDIUM,
|
|
14
|
+
HIGH: ThinkingLevel.HIGH
|
|
15
|
+
};
|
|
9
16
|
let toolCallCounter = 0;
|
|
10
17
|
const streamGoogleVertex = (model, context, options) => {
|
|
11
18
|
const stream = new AssistantMessageEventStream();
|
|
@@ -92,7 +99,13 @@ function resolveLocation(options) {
|
|
|
92
99
|
return location;
|
|
93
100
|
}
|
|
94
101
|
function buildParams(model, context, options = {}) {
|
|
95
|
-
return buildGoogleGenerateContentParams(model, context, options
|
|
102
|
+
return buildGoogleGenerateContentParams(model, context, options, {
|
|
103
|
+
mapThinkingLevel: mapVertexThinkingLevel,
|
|
104
|
+
getDisabledThinkingConfig: (modelLocal) => getDisabledGoogleThinkingConfig(modelLocal, { mapThinkingLevel: mapVertexThinkingLevel })
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function mapVertexThinkingLevel(level) {
|
|
108
|
+
return THINKING_LEVEL_MAP[level];
|
|
96
109
|
}
|
|
97
110
|
//#endregion
|
|
98
111
|
export { streamGoogleVertex, streamSimpleGoogleVertex };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region packages/ai/src/host.ts
|
|
2
|
+
const inertAiTransportHost = {
|
|
3
|
+
buildModelFetch: () => void 0,
|
|
4
|
+
resolveSecretSentinel: (value) => value,
|
|
5
|
+
redactSecrets: (value) => value,
|
|
6
|
+
redactToolPayloadText: (text) => text,
|
|
7
|
+
resolveOpenAIStrictToolSetting: (_model, options) => options?.supportsStrictMode ? false : void 0,
|
|
8
|
+
logDebug: () => {}
|
|
9
|
+
};
|
|
10
|
+
let activeAiTransportHost = inertAiTransportHost;
|
|
11
|
+
/** Installs host implementations for the transport policy ports. */
|
|
12
|
+
function configureAiTransportHost(host) {
|
|
13
|
+
activeAiTransportHost = {
|
|
14
|
+
...inertAiTransportHost,
|
|
15
|
+
...host
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Returns the active transport host (inert defaults unless configured). */
|
|
19
|
+
function getAiTransportHost() {
|
|
20
|
+
return activeAiTransportHost;
|
|
21
|
+
}
|
|
22
|
+
/** Resolves sentinel substrings in custom headers at a no-fetch adapter boundary. */
|
|
23
|
+
function resolveAiTransportHeaderSentinels(headers) {
|
|
24
|
+
if (!headers) return;
|
|
25
|
+
const host = getAiTransportHost();
|
|
26
|
+
let resolvedHeaders;
|
|
27
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
28
|
+
const resolved = host.resolveSecretSentinel(value);
|
|
29
|
+
if (resolved !== value) {
|
|
30
|
+
resolvedHeaders ??= { ...headers };
|
|
31
|
+
resolvedHeaders[name] = resolved;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return resolvedHeaders ?? headers;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { getAiTransportHost as n, resolveAiTransportHeaderSentinels as r, configureAiTransportHost as t };
|
|
@@ -77,14 +77,10 @@ declare function resolveClaudeMythos5ModelIdentity(ref: ClaudeModelRef): string
|
|
|
77
77
|
declare function requiresClaudeMandatoryAdaptiveThinking(ref: ClaudeModelRef): boolean;
|
|
78
78
|
/** Resolve Claude Sonnet 5 through direct ids, cloud ids, or deployment metadata. */
|
|
79
79
|
declare function resolveClaudeSonnet5ModelIdentity(ref: ClaudeModelRef): string | undefined;
|
|
80
|
-
/** Resolve Claude Opus 5 through
|
|
80
|
+
/** Resolve Claude Opus 5 through direct ids, cloud ids, or deployment metadata. */
|
|
81
81
|
declare function resolveClaudeOpus5ModelIdentity(ref: ClaudeModelRef): string | undefined;
|
|
82
82
|
/** Return whether a Claude model supports adaptive thinking. */
|
|
83
83
|
declare function supportsClaudeAdaptiveThinking(ref: ClaudeModelRef): boolean;
|
|
84
|
-
/** Return whether a Claude model has a native 1M-token context window. */
|
|
85
|
-
declare function supportsClaude1MContext(ref: ClaudeModelRef): boolean;
|
|
86
|
-
/** Return whether a Claude model supports Anthropic's native fast mode. */
|
|
87
|
-
declare function supportsClaudeFastMode(ref: ClaudeModelRef): boolean;
|
|
88
84
|
/** Return whether a Claude model supports native max effort. */
|
|
89
85
|
declare function supportsClaudeNativeMaxEffort(ref: ClaudeModelRef): boolean;
|
|
90
86
|
/** Return whether a Claude model supports native xhigh effort. */
|
|
@@ -97,4 +93,4 @@ declare function requiresClaudeDefaultSampling(ref: ClaudeModelRef): boolean;
|
|
|
97
93
|
*/
|
|
98
94
|
declare function resolveClaudeNativeThinkingLevelMap(ref: ClaudeEffortModelRef): Record<string, string | null | undefined> | undefined;
|
|
99
95
|
//#endregion
|
|
100
|
-
export { requiresClaudeMandatoryAdaptiveThinking as a, resolveClaudeMythos5ModelIdentity as c, resolveClaudeSonnet5ModelIdentity as d,
|
|
96
|
+
export { requiresClaudeMandatoryAdaptiveThinking as a, resolveClaudeMythos5ModelIdentity as c, resolveClaudeSonnet5ModelIdentity as d, supportsClaudeAdaptiveThinking as f, requiresClaudeDefaultSampling as i, resolveClaudeNativeThinkingLevelMap as l, supportsClaudeNativeXhighEffort as m, CLAUDE_OPUS_5_THINKING_PROFILE as n, resolveClaudeFable5ModelIdentity as o, supportsClaudeNativeMaxEffort as p, CLAUDE_SONNET_5_THINKING_PROFILE as r, resolveClaudeModelIdentity as s, CLAUDE_FABLE_5_THINKING_PROFILE as t, resolveClaudeOpus5ModelIdentity as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,54 @@
|
|
|
1
|
-
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, f as
|
|
1
|
+
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, f as supportsClaudeAdaptiveThinking, i as requiresClaudeDefaultSampling, l as resolveClaudeNativeThinkingLevelMap, m as supportsClaudeNativeXhighEffort, n as CLAUDE_OPUS_5_THINKING_PROFILE, o as resolveClaudeFable5ModelIdentity, p as supportsClaudeNativeMaxEffort, r as CLAUDE_SONNET_5_THINKING_PROFILE, s as resolveClaudeModelIdentity, t as CLAUDE_FABLE_5_THINKING_PROFILE, u as resolveClaudeOpus5ModelIdentity } from "./index-CGDEoorl.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 VercelGatewayRouting, A as OpenRouterRouting, B as TextContent, C as KnownImagesProvider, D as ModelThinkingLevel, E as Model, F as SimpleStreamOptions, G as ThinkingLevelMap, H as ThinkingBudgets, I as StopReason, J as ToolResultMessage, K as Tool, L as StreamFn, M as ProviderImagesOptions, N as ProviderResponse, O as OpenAICompletionsCompat, P as ProviderStreamOptions, Q as ValidateToolArgumentsFn, R as StreamFunction, S as KnownImagesApi, T as Message, U as ThinkingContent, V as TextSignatureV1, W as ThinkingLevel, X as Usage, Y as Transport, Z as UserMessage, _ as ImagesOptions, a as AssistantMessageEvent, b as ImagesStopReason, c as CacheRetention, d as ImageContent, f as ImagesApi, g as ImagesModel, h as ImagesInputContent, i as AssistantMessage, j as Provider, k as OpenAIResponsesCompat, l as CompleteSimpleFn, m as ImagesFunction, n as Api, o as AssistantMessageEventStreamContract, p as ImagesContext, q as ToolCall, r as AssistantImages, s as AssistantMessageEventStreamLike, t as AnthropicMessagesCompat, u as Context, v as ImagesOutputContent, w as MaybePromise, x as KnownApi, y as ImagesProvider, z as StreamOptions } 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-
|
|
6
|
-
import { a as RegisteredApiProvider, i as ApiStreamSimpleFunction, n as ApiRegistry, o as createApiRegistry, r as ApiStreamFunction, t as ApiProvider } from "./api-registry-
|
|
7
|
-
import { a as AiProviderRequestPolicyInput, c as AiTransportHost, d as configureAiTransportHost, f as getAiTransportHost, i as AiProviderRequestCapabilities, l as AiTransportPluginHost, n as AiInlineImageBlock, o as AiProviderStreamHookContext, p as resolveAiTransportHeaderSentinels, r as AiInlineTextBlock, s as AiTransformTransportMessages, t as AiInlineContentBlock, u as OpenAIStrictToolSettingOptions } from "./host-B9GUmcra.mjs";
|
|
3
|
+
import { $ as VercelGatewayRouting, A as OpenRouterRouting, B as TextContent, C as KnownImagesProvider, D as ModelThinkingLevel, E as Model, F as SimpleStreamOptions, G as ThinkingLevelMap, H as ThinkingBudgets, I as StopReason, J as ToolResultMessage, K as Tool, L as StreamFn, M as ProviderImagesOptions, N as ProviderResponse, O as OpenAICompletionsCompat, P as ProviderStreamOptions, Q as ValidateToolArgumentsFn, R as StreamFunction, S as KnownImagesApi, T as Message, U as ThinkingContent, V as TextSignatureV1, W as ThinkingLevel, X as Usage, Y as Transport, Z as UserMessage, _ as ImagesOptions, a as AssistantMessageEvent, b as ImagesStopReason, c as CacheRetention, d as ImageContent, f as ImagesApi, g as ImagesModel, h as ImagesInputContent, i as AssistantMessage, j as Provider, k as OpenAIResponsesCompat, l as CompleteSimpleFn, m as ImagesFunction, n as Api, o as AssistantMessageEventStreamContract, p as ImagesContext, q as ToolCall, r as AssistantImages, s as AssistantMessageEventStreamLike, t as AnthropicMessagesCompat, u as Context, v as ImagesOutputContent, w as MaybePromise, x as KnownApi, y as ImagesProvider, z as StreamOptions } from "./types-DRgdPqaZ.mjs";
|
|
4
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-0nZeBKl2.mjs";
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-BDMWOr8d.mjs";
|
|
6
|
+
import { a as RegisteredApiProvider, i as ApiStreamSimpleFunction, n as ApiRegistry, o as createApiRegistry, r as ApiStreamFunction, t as ApiProvider } from "./api-registry-BXYnCOIR.mjs";
|
|
8
7
|
|
|
8
|
+
//#region packages/ai/src/host.d.ts
|
|
9
|
+
/** Strict-tool policy inputs for OpenAI-compatible routes. */
|
|
10
|
+
interface OpenAIStrictToolSettingOptions {
|
|
11
|
+
transport?: "stream" | "websocket";
|
|
12
|
+
supportsStrictMode?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Narrow host ports consumed by the built-in provider adapters. */
|
|
15
|
+
interface AiTransportHost {
|
|
16
|
+
/**
|
|
17
|
+
* Builds a policy-guarded fetch for one model request.
|
|
18
|
+
* Returning undefined keeps the provider SDK's default fetch.
|
|
19
|
+
*/
|
|
20
|
+
buildModelFetch(model: Model, timeoutMs?: number, options?: {
|
|
21
|
+
sanitizeSse?: boolean;
|
|
22
|
+
}): typeof fetch | undefined;
|
|
23
|
+
/** Resolves host-owned process-local secret sentinel substrings immediately before egress. */
|
|
24
|
+
resolveSecretSentinel(value: string): string;
|
|
25
|
+
/** Redacts secrets inside structured tool-result payloads. */
|
|
26
|
+
redactSecrets<T>(value: T): T;
|
|
27
|
+
/** Redacts secret-bearing text in tool payload strings. */
|
|
28
|
+
redactToolPayloadText(text: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the host strict-tool default for OpenAI-compatible routes.
|
|
31
|
+
* undefined lets the request omit the strict flag entirely.
|
|
32
|
+
*/
|
|
33
|
+
resolveOpenAIStrictToolSetting(model: Pick<Model, "provider" | "api" | "baseUrl" | "id"> & {
|
|
34
|
+
compat?: unknown;
|
|
35
|
+
}, options?: OpenAIStrictToolSettingOptions): boolean | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Emits one transport diagnostic; build runs only when the host logs it and
|
|
38
|
+
* may return null to suppress the entry (e.g. de-duplication).
|
|
39
|
+
*/
|
|
40
|
+
logDebug(subsystem: string, build: () => {
|
|
41
|
+
message: string;
|
|
42
|
+
data?: Record<string, unknown>;
|
|
43
|
+
} | null): void;
|
|
44
|
+
}
|
|
45
|
+
/** Installs host implementations for the transport policy ports. */
|
|
46
|
+
declare function configureAiTransportHost(host: Partial<AiTransportHost>): void;
|
|
47
|
+
/** Returns the active transport host (inert defaults unless configured). */
|
|
48
|
+
declare function getAiTransportHost(): AiTransportHost;
|
|
49
|
+
/** Resolves sentinel substrings in custom headers at a no-fetch adapter boundary. */
|
|
50
|
+
declare function resolveAiTransportHeaderSentinels(headers: Record<string, string> | undefined): Record<string, string> | undefined;
|
|
51
|
+
//#endregion
|
|
9
52
|
//#region packages/ai/src/stream.d.ts
|
|
10
53
|
/** Creates an isolated LLM runtime backed by the supplied provider registry. */
|
|
11
54
|
declare function createLlmRuntime(registry?: ApiRegistry): {
|
|
@@ -23,4 +66,4 @@ declare function createLlmRuntime(registry?: ApiRegistry): {
|
|
|
23
66
|
};
|
|
24
67
|
type LlmRuntime = ReturnType<typeof createLlmRuntime>;
|
|
25
68
|
//#endregion
|
|
26
|
-
export {
|
|
69
|
+
export { AiTransportHost, AnthropicMessagesCompat, Api, ApiProvider, ApiRegistry, ApiStreamFunction, ApiStreamSimpleFunction, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, CacheRetention, CompleteSimpleFn, Context, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, LlmRuntime, MaybePromise, Message, Model, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenAIStrictToolSettingOptions, OpenRouterRouting, Provider, ProviderImagesOptions, ProviderResponse, ProviderStreamOptions, RegisteredApiProvider, SimpleStreamOptions, StopReason, StreamFn, StreamFunction, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, configureAiTransportHost, createApiRegistry, createAssistantMessageDiagnostic, createAssistantMessageEventStream, createLlmRuntime, extractDiagnosticError, formatThrownValue, getAiTransportHost, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveAiTransportHeaderSentinels, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaudeAdaptiveThinking, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, f as
|
|
1
|
+
import { a as requiresClaudeMandatoryAdaptiveThinking, c as resolveClaudeMythos5ModelIdentity, d as resolveClaudeSonnet5ModelIdentity, f as supportsClaudeAdaptiveThinking, i as requiresClaudeDefaultSampling, l as resolveClaudeNativeThinkingLevelMap, m as supportsClaudeNativeXhighEffort, n as CLAUDE_OPUS_5_THINKING_PROFILE, o as resolveClaudeFable5ModelIdentity, p as supportsClaudeNativeMaxEffort, r as CLAUDE_SONNET_5_THINKING_PROFILE, s as resolveClaudeModelIdentity, t as CLAUDE_FABLE_5_THINKING_PROFILE, u as resolveClaudeOpus5ModelIdentity } from "./src-CjOfhrH3.mjs";
|
|
2
2
|
import { i as formatThrownValue, n as createAssistantMessageDiagnostic, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-COpOtRwq.mjs";
|
|
3
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
4
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
3
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-ReMmOTzX.mjs";
|
|
4
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-FrchoOlv.mjs";
|
|
5
5
|
import { n as createApiRegistry, t as createLlmRuntime } from "./stream-CREqxHgU.mjs";
|
|
6
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels, t as configureAiTransportHost } from "./host-
|
|
7
|
-
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, EventStream, appendAssistantMessageDiagnostic, configureAiTransportHost, createApiRegistry, createAssistantMessageDiagnostic, createAssistantMessageEventStream, createLlmRuntime, extractDiagnosticError, formatThrownValue, getAiTransportHost, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveAiTransportHeaderSentinels, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity,
|
|
6
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels, t as configureAiTransportHost } from "./host-4t713IeR.mjs";
|
|
7
|
+
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, EventStream, appendAssistantMessageDiagnostic, configureAiTransportHost, createApiRegistry, createAssistantMessageDiagnostic, createAssistantMessageEventStream, createLlmRuntime, extractDiagnosticError, formatThrownValue, getAiTransportHost, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveAiTransportHeaderSentinels, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaudeAdaptiveThinking, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|