@openclaw/ai 2026.8.1-beta.1 → 2026.8.1-beta.2
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-CE-7SkF6.mjs → anthropic-B6dLpq5L.mjs} +37 -22
- package/dist/{src-QkygScBs.mjs → anthropic-JsNA5KCu.mjs} +0 -1
- package/dist/{anthropic-usage-Ma4iX6uG.mjs → anthropic-compaction-replay-8lJNKXOE.mjs} +225 -102
- package/dist/anthropic-payload-policy-CiEuQS72.d.mts +49 -0
- package/dist/{api-registry-EpJoVwM1.d.mts → api-registry-k3zTz0cV.d.mts} +1 -1
- package/dist/{azure-openai-responses-Cc_kasye.mjs → azure-openai-responses-mxIOtUnn.mjs} +23 -29
- package/dist/diagnostics.d.mts +24 -1
- package/dist/diagnostics.mjs +2 -1
- package/dist/{event-stream-DRmDMRHH.d.mts → event-stream-BP6AWT8j.d.mts} +3 -1
- package/dist/{event-stream-CEV9t6da.mjs → event-stream-uSMZJ3FA.mjs} +16 -3
- package/dist/event-stream.d.mts +1 -1
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-CGQu21aw.mjs → google-C7h2QzDX.mjs} +4 -4
- package/dist/{google-shared-Cq2UKx1l.mjs → google-shared-B0Qr9OR7.mjs} +9 -18
- package/dist/google-thinking-level-C-V3tecN.mjs +9 -0
- package/dist/{google-vertex-CusxWzvE.mjs → google-vertex-Bhc3TjDl.mjs} +5 -4
- package/dist/{llm-request-activity-BjtkplhG.mjs → headers-DdOQtGuU.mjs} +9 -1
- package/dist/{host-Bl7Kgddo.mjs → host-DTqNc7ad.mjs} +227 -168
- package/dist/{host-Dn4_SZI2.d.mts → host-vWgMMhiJ.d.mts} +9 -4
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +7 -5
- package/dist/internal/anthropic.d.mts +13 -5
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -0
- package/dist/internal/openai-responses-payload-policy.mjs +3 -0
- package/dist/internal/openai.d.mts +6 -6
- package/dist/internal/openai.mjs +8 -7
- package/dist/internal/runtime.d.mts +17 -5
- package/dist/internal/runtime.mjs +85 -73
- package/dist/internal/shared.d.mts +1 -6
- package/dist/internal/shared.mjs +3 -4
- package/dist/{json-parse-BvXNt1-7.mjs → json-parse-CDnesDM_.mjs} +4 -6
- package/dist/{mistral-Dx6VzNjf.mjs → mistral-CEWoQI_g.mjs} +26 -45
- package/dist/{number-coercion-1Miyb5MO.mjs → number-coercion-H9qHik3g.mjs} +7 -2
- package/dist/openai-chatgpt-jwt-KWcgd0d_.mjs +19 -0
- package/dist/{openai-chatgpt-responses-SC9m0FSf.mjs → openai-chatgpt-responses-CrPmqERt.mjs} +225 -144
- package/dist/{openai-completions-BaIpl93j.mjs → openai-completions-BPnt4Sml.mjs} +28 -43
- package/dist/openai-completions-compat-Dt3dcawL.d.mts +43 -0
- package/dist/{openai-responses-Bdx3V_Yu.mjs → openai-responses-DhIKtOup.mjs} +17 -24
- package/dist/openai-responses-contracts-CyfIkQi5.mjs +253 -0
- package/dist/openai-responses-contracts-XpZJxrRG.d.mts +68 -0
- package/dist/openai-responses-payload-policy-BDxV-W0c.mjs +206 -0
- package/dist/openai-responses-payload-policy-BSs371VM.d.mts +40 -0
- package/dist/{openai-responses-prompt-observer-internal-DDZPxRfr.mjs → openai-responses-prompt-observer-internal-DgNTYnRY.mjs} +3 -3
- package/dist/{openai-responses-stream-internal-Bl8YyVtF.mjs → openai-responses-shared-DXIt3iY5.mjs} +1211 -908
- package/dist/{openai-reasoning-compat-DKebnIBL.mjs → openai-stop-reason-BkFkqqK0.mjs} +198 -172
- package/dist/{openai-transport-shared-Cipt7egQ.mjs → openai-tool-projection-CY04OcvQ.mjs} +151 -128
- package/dist/provider-error-BUwEnjXq.mjs +429 -0
- package/dist/provider-error-CzNw4BWX.d.mts +12 -0
- package/dist/{provider-options-C5kYML7i.d.mts → provider-options-B96RdNpH.d.mts} +9 -3
- package/dist/provider-transcript-transform-ePx-Bbfr.mjs +155 -0
- package/dist/provider-types.d.mts +31 -0
- package/dist/provider-types.mjs +8 -0
- package/dist/providers.d.mts +1 -1
- package/dist/providers.mjs +17 -19
- package/dist/{reasoning-tag-text-partitioner-CGDyLWUR.mjs → reasoning-tag-text-partitioner-rnPwX2pg.mjs} +14 -8
- package/dist/record-coerce-DdXsgUd_.mjs +23 -0
- package/dist/{model-utils-Dau5dlgm.mjs → sanitize-unicode-BYqrYtC_.mjs} +28 -2
- package/dist/session-resources-CkR4WWy1.mjs +21 -0
- package/dist/simple-options-D58D5Kvw.mjs +117 -0
- package/dist/src-D2H6yKkH.mjs +2 -0
- package/dist/{stream-first-event-timeout-BIBomOGq.mjs → stream-first-event-timeout-MK28puvq.mjs} +2 -2
- package/dist/string-coerce-fsri9iCu.mjs +34 -0
- package/dist/{tool-schema-json-projection-B1b-XCn5.mjs → tool-schema-json-projection-q5d7QX5c.mjs} +5 -7
- package/dist/transport-utils-DJqkxbhC.mjs +138 -0
- package/dist/transports.d.mts +135 -178
- package/dist/transports.mjs +1732 -1294
- package/dist/types-BDdaOVi2.mjs +6 -0
- package/dist/{types-CH7ReIcU.d.mts → types-BHNrPS1l.d.mts} +19 -1
- package/dist/types.d.mts +4 -4
- package/dist/types.mjs +6 -4
- package/dist/utf16-slice-CvGodqok.mjs +29 -0
- package/dist/{validation-DAa_yFOM.mjs → validation-B61OhAio.mjs} +6 -6
- package/dist/{validation-CcPcuEbR.d.mts → validation-DT9SrFn3.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +15 -1
- package/dist/headers-B_e4-1J0.mjs +0 -9
- package/dist/openai-chatgpt-jwt-DhAAzLkj.mjs +0 -39
- package/dist/openai-responses-contracts-BBKBfAqR.d.mts +0 -116
- package/dist/openai-responses-shared-CCyMvg7M.mjs +0 -403
- package/dist/provider-error-DI0Ts28U.mjs +0 -47
- package/dist/sanitize-unicode-DT5o51ur.mjs +0 -26
- package/dist/tool-result-text-Dvkp2Dus.mjs +0 -274
- package/dist/transform-messages-DfjpNXNQ.mjs +0 -2
- package/dist/transport-stream-shared-CPNv7A3r.mjs +0 -297
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { n as getEnvApiKey } from "./env-api-keys-DrgeBuva.mjs";
|
|
2
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
3
|
-
import { n as getAiTransportHost } from "./host-
|
|
2
|
+
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
3
|
+
import { n as getAiTransportHost } from "./host-DTqNc7ad.mjs";
|
|
4
4
|
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { n as buildBaseOptions } from "./simple-options-D58D5Kvw.mjs";
|
|
6
|
+
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, o as runResponsesStreamLifecycle, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-DXIt3iY5.mjs";
|
|
6
7
|
import { i as resolveAzureDeploymentNameFromMap, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-C7K7QfUE.mjs";
|
|
7
|
-
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, o as runResponsesStreamLifecycle, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-CCyMvg7M.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";
|
|
@@ -20,19 +20,6 @@ function resolveDeploymentName(model, options) {
|
|
|
20
20
|
deploymentMap: process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
function formatAzureOpenAIError(error) {
|
|
24
|
-
if (error instanceof Error) {
|
|
25
|
-
const status = error.status;
|
|
26
|
-
const statusCode = typeof status === "number" ? status : void 0;
|
|
27
|
-
if (statusCode !== void 0) return `Azure OpenAI API error (${statusCode}): ${error.message}`;
|
|
28
|
-
return error.message;
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
return JSON.stringify(error);
|
|
32
|
-
} catch {
|
|
33
|
-
return String(error);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
23
|
/**
|
|
37
24
|
* Generate function for Azure OpenAI Responses API
|
|
38
25
|
*/
|
|
@@ -43,11 +30,17 @@ const streamAzureOpenAIResponses = (model, context, options) => {
|
|
|
43
30
|
model,
|
|
44
31
|
output: createResponsesAssistantOutput(model, "azure-openai-responses"),
|
|
45
32
|
options,
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
resolveRequestModel: (requestModel) => {
|
|
34
|
+
const { baseUrl } = resolveAzureConfig(requestModel, options);
|
|
35
|
+
return baseUrl === requestModel.baseUrl ? requestModel : {
|
|
36
|
+
...requestModel,
|
|
37
|
+
baseUrl
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
createClient: (requestModel) => {
|
|
41
|
+
return createClient(requestModel, options?.apiKey || getEnvApiKey(model.provider) || "", options);
|
|
48
42
|
},
|
|
49
|
-
buildParams: () => buildParams(
|
|
50
|
-
formatError: formatAzureOpenAIError
|
|
43
|
+
buildParams: (requestModel, replayMode) => buildParams(requestModel, context, options, resolveDeploymentName(model, options), replayMode)
|
|
51
44
|
});
|
|
52
45
|
return stream;
|
|
53
46
|
};
|
|
@@ -55,9 +48,11 @@ const streamSimpleAzureOpenAIResponses = (model, context, options) => {
|
|
|
55
48
|
const apiKey = options?.apiKey || getEnvApiKey(model.provider);
|
|
56
49
|
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
57
50
|
const base = buildBaseOptions(model, options, apiKey);
|
|
51
|
+
const authProfileId = options?.authProfileId;
|
|
58
52
|
const reasoningEffort = resolveResponsesReasoningEffort(model, options?.reasoning);
|
|
59
53
|
return streamAzureOpenAIResponses(model, context, {
|
|
60
54
|
...base,
|
|
55
|
+
authProfileId,
|
|
61
56
|
reasoningEffort: reasoningEffort === "max" ? "xhigh" : reasoningEffort
|
|
62
57
|
});
|
|
63
58
|
};
|
|
@@ -119,10 +114,14 @@ function createClient(model, apiKeyInput, options) {
|
|
|
119
114
|
fetch: guardedFetch
|
|
120
115
|
});
|
|
121
116
|
}
|
|
122
|
-
function buildParams(model, context, options, deploymentName) {
|
|
117
|
+
function buildParams(model, context, options, deploymentName, replayMode = "checkpoint") {
|
|
123
118
|
const params = {
|
|
124
119
|
model: deploymentName,
|
|
125
|
-
input: convertResponsesMessages(model, context, AZURE_TOOL_CALL_PROVIDERS
|
|
120
|
+
input: convertResponsesMessages(model, context, AZURE_TOOL_CALL_PROVIDERS, {
|
|
121
|
+
sessionId: options?.sessionId,
|
|
122
|
+
authProfileId: options?.authProfileId,
|
|
123
|
+
replayMode
|
|
124
|
+
}),
|
|
126
125
|
stream: true,
|
|
127
126
|
prompt_cache_key: options?.cacheRetention === "none" ? void 0 : clampOpenAIPromptCacheKey(options?.promptCacheKey ?? options?.sessionId),
|
|
128
127
|
store: false
|
|
@@ -130,10 +129,5 @@ function buildParams(model, context, options, deploymentName) {
|
|
|
130
129
|
applyCommonResponsesParams(params, model, context, options);
|
|
131
130
|
return params;
|
|
132
131
|
}
|
|
133
|
-
const testing = {
|
|
134
|
-
isOpenAICompatibleAzureResponsesBaseUrl,
|
|
135
|
-
normalizeAzureBaseUrl,
|
|
136
|
-
resolveAzureConfig
|
|
137
|
-
};
|
|
138
132
|
//#endregion
|
|
139
|
-
export { streamAzureOpenAIResponses, streamSimpleAzureOpenAIResponses
|
|
133
|
+
export { streamAzureOpenAIResponses, streamSimpleAzureOpenAIResponses };
|
package/dist/diagnostics.d.mts
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
1
|
import { a as extractDiagnosticError, i as createAssistantMessageDiagnostic, n as DiagnosticErrorInfo, o as formatThrownValue, r as appendAssistantMessageDiagnostic, t as AssistantMessageDiagnostic } from "./diagnostics-BaTA9eVl.mjs";
|
|
2
|
-
|
|
2
|
+
import { n as ProviderErrorRedactor, r as configureProviderErrorRedactor } from "./provider-error-CzNw4BWX.mjs";
|
|
3
|
+
|
|
4
|
+
//#region packages/ai/src/utils/credential-redaction.d.ts
|
|
5
|
+
type DiagnosticMediaField = {
|
|
6
|
+
kind: "context";
|
|
7
|
+
} | {
|
|
8
|
+
kind: "redacted";
|
|
9
|
+
bytes?: number;
|
|
10
|
+
source?: string | Uint8Array;
|
|
11
|
+
};
|
|
12
|
+
type DiagnosticProjectionPolicy = {
|
|
13
|
+
omitField?: (key: string) => boolean;
|
|
14
|
+
propertyScope?: "enumerable" | "error";
|
|
15
|
+
projectBinary?: (binary: Uint8Array) => unknown;
|
|
16
|
+
projectMedia?: (key: string, media: Extract<DiagnosticMediaField, {
|
|
17
|
+
kind: "redacted";
|
|
18
|
+
}>) => Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
declare function projectDiagnosticValue(value: unknown, policy?: DiagnosticProjectionPolicy, seen?: WeakSet<object>, mediaPayload?: boolean, state?: {
|
|
21
|
+
changed: boolean;
|
|
22
|
+
nodesRemaining: number;
|
|
23
|
+
}): unknown;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { AssistantMessageDiagnostic, DiagnosticErrorInfo, type DiagnosticProjectionPolicy, type ProviderErrorRedactor, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, extractDiagnosticError, formatThrownValue, projectDiagnosticValue };
|
package/dist/diagnostics.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { i as formatThrownValue, n as createAssistantMessageDiagnostic, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-COpOtRwq.mjs";
|
|
2
|
-
|
|
2
|
+
import { r as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-BUwEnjXq.mjs";
|
|
3
|
+
export { appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, extractDiagnosticError, formatThrownValue, projectDiagnosticValue };
|
|
@@ -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-BHNrPS1l.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,8 +7,10 @@ declare class EventStream<T, R = T> implements AsyncIterable<T> {
|
|
|
7
7
|
private queueHead;
|
|
8
8
|
private waiting;
|
|
9
9
|
private done;
|
|
10
|
+
private resultSettled;
|
|
10
11
|
private finalResultPromise;
|
|
11
12
|
private resolveFinalResult;
|
|
13
|
+
private rejectFinalResult;
|
|
12
14
|
private isComplete;
|
|
13
15
|
private extractResult;
|
|
14
16
|
constructor(isComplete: (event: T) => boolean, extractResult: (event: T) => R);
|
|
@@ -6,20 +6,26 @@ var EventStream = class {
|
|
|
6
6
|
this.queueHead = 0;
|
|
7
7
|
this.waiting = [];
|
|
8
8
|
this.done = false;
|
|
9
|
+
this.resultSettled = false;
|
|
9
10
|
this.isComplete = isComplete;
|
|
10
11
|
this.extractResult = extractResult;
|
|
11
12
|
const resolvers = [];
|
|
12
|
-
|
|
13
|
+
const rejecters = [];
|
|
14
|
+
this.finalResultPromise = new Promise((resolve, reject) => {
|
|
13
15
|
resolvers.push(resolve);
|
|
16
|
+
rejecters.push(reject);
|
|
14
17
|
});
|
|
15
18
|
const resolveFinalResult = resolvers.at(0);
|
|
16
|
-
|
|
19
|
+
const rejectFinalResult = rejecters.at(0);
|
|
20
|
+
if (!resolveFinalResult || !rejectFinalResult) throw new Error("event stream result promise did not initialize its resolver");
|
|
17
21
|
this.resolveFinalResult = resolveFinalResult;
|
|
22
|
+
this.rejectFinalResult = rejectFinalResult;
|
|
18
23
|
}
|
|
19
24
|
push(event) {
|
|
20
25
|
if (this.done) return;
|
|
21
26
|
if (this.isComplete(event)) {
|
|
22
27
|
this.done = true;
|
|
28
|
+
this.resultSettled = true;
|
|
23
29
|
this.resolveFinalResult(this.extractResult(event));
|
|
24
30
|
}
|
|
25
31
|
const waiter = this.waiting.shift();
|
|
@@ -31,7 +37,14 @@ var EventStream = class {
|
|
|
31
37
|
}
|
|
32
38
|
end(result) {
|
|
33
39
|
this.done = true;
|
|
34
|
-
if (result !== void 0)
|
|
40
|
+
if (result !== void 0) {
|
|
41
|
+
this.resultSettled = true;
|
|
42
|
+
this.resolveFinalResult(result);
|
|
43
|
+
} else if (!this.resultSettled) {
|
|
44
|
+
this.resultSettled = true;
|
|
45
|
+
this.finalResultPromise.catch(() => {});
|
|
46
|
+
this.rejectFinalResult(/* @__PURE__ */ new Error("event stream ended without a terminal event or final result"));
|
|
47
|
+
}
|
|
35
48
|
while (this.waiting.length > 0) {
|
|
36
49
|
const waiter = this.waiting.shift();
|
|
37
50
|
if (!waiter) break;
|
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-BP6AWT8j.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-uSMZJ3FA.mjs";
|
|
2
2
|
export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as getEnvApiKey } from "./env-api-keys-DrgeBuva.mjs";
|
|
2
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
3
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-
|
|
4
|
-
import {
|
|
5
|
-
import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-
|
|
2
|
+
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
3
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-DTqNc7ad.mjs";
|
|
4
|
+
import { n as buildBaseOptions } from "./simple-options-D58D5Kvw.mjs";
|
|
5
|
+
import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-B0Qr9OR7.mjs";
|
|
6
6
|
import { GoogleGenAI } from "@google/genai";
|
|
7
7
|
//#region packages/ai/src/providers/google.ts
|
|
8
8
|
let toolCallCounter = 0;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as formatProviderError } from "./provider-error-DI0Ts28U.mjs";
|
|
7
|
-
import "./transform-messages-DfjpNXNQ.mjs";
|
|
1
|
+
import { i as clampThinkingLevel, r as calculateCost, t as sanitizeSurrogates } from "./sanitize-unicode-BYqrYtC_.mjs";
|
|
2
|
+
import { a as describeToolResultMediaPlaceholder, l as isImageWithMediaPayload, s as extractToolResultText } from "./host-DTqNc7ad.mjs";
|
|
3
|
+
import { f as sortPromptCacheToolsByName, l as stripSystemPromptCacheBoundary } from "./simple-options-D58D5Kvw.mjs";
|
|
4
|
+
import { f as transportAbortError, n as assignTransportErrorDetails, r as coerceTransportToolCallArguments, t as transformProviderMessages } from "./provider-transcript-transform-ePx-Bbfr.mjs";
|
|
5
|
+
import { t as googleFlashSupportsMinimalThinking } from "./google-thinking-level-C-V3tecN.mjs";
|
|
8
6
|
import { FinishReason, FunctionCallingConfigMode, ThinkingLevel } from "@google/genai";
|
|
9
7
|
//#region packages/ai/src/providers/google-shared.ts
|
|
10
8
|
/**
|
|
@@ -82,7 +80,7 @@ function convertMessages(model, context) {
|
|
|
82
80
|
if (!requiresToolCallId(model.id)) return id;
|
|
83
81
|
return id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
|
|
84
82
|
};
|
|
85
|
-
const transformedMessages =
|
|
83
|
+
const transformedMessages = transformProviderMessages(context.messages, model, normalizeToolCallId);
|
|
86
84
|
const requiresToolCallThoughtSignature = model.provider !== "google-gemini-cli" && (isGemini3ProModel(model) || isGemini3FlashModel(model));
|
|
87
85
|
const pendingToolResultImageTurns = [];
|
|
88
86
|
let activeToolResultParts;
|
|
@@ -256,14 +254,7 @@ async function runGoogleGenerateContentLifecycle(params) {
|
|
|
256
254
|
});
|
|
257
255
|
} catch (error) {
|
|
258
256
|
for (const block of output.content) if ("index" in block) delete block.index;
|
|
259
|
-
|
|
260
|
-
assignTransportErrorDetails(output, failure, options?.signal);
|
|
261
|
-
const formattedError = formatProviderError(failure);
|
|
262
|
-
const status = failure instanceof Error && "status" in failure ? failure.status : void 0;
|
|
263
|
-
if (typeof status === "number" && Number.isFinite(status)) {
|
|
264
|
-
output.errorCode ||= String(status);
|
|
265
|
-
output.errorMessage = formattedError.startsWith(`${status}:`) ? formattedError : `${status}: ${formattedError}`;
|
|
266
|
-
} else output.errorMessage = formattedError;
|
|
257
|
+
assignTransportErrorDetails(output, options?.signal?.aborted ? transportAbortError(options.signal) : error, options?.signal);
|
|
267
258
|
stream.push({
|
|
268
259
|
type: "error",
|
|
269
260
|
reason: output.stopReason === "aborted" ? "aborted" : "error",
|
|
@@ -334,7 +325,7 @@ function buildGoogleSimpleThinking(model, options, config) {
|
|
|
334
325
|
}
|
|
335
326
|
function getDisabledGoogleThinkingConfig(model) {
|
|
336
327
|
if (isGemini3ProModel(model)) return { thinkingLevel: ThinkingLevel.LOW };
|
|
337
|
-
if (isGemini3FlashModel(model)) return { thinkingLevel: ThinkingLevel.MINIMAL };
|
|
328
|
+
if (isGemini3FlashModel(model)) return { thinkingLevel: googleFlashSupportsMinimalThinking(model.id) ? ThinkingLevel.MINIMAL : ThinkingLevel.LOW };
|
|
338
329
|
if (isGemma4Model(model) || model.id.toLowerCase().includes("gemini-2.5-pro")) return {};
|
|
339
330
|
return { thinkingBudget: 0 };
|
|
340
331
|
}
|
|
@@ -362,7 +353,7 @@ function getGoogleThinkingLevel(effort, model, config) {
|
|
|
362
353
|
case "high": return ThinkingLevel.HIGH;
|
|
363
354
|
}
|
|
364
355
|
switch (effort) {
|
|
365
|
-
case "minimal": return ThinkingLevel.MINIMAL;
|
|
356
|
+
case "minimal": return isGemini3FlashModel(model) && !googleFlashSupportsMinimalThinking(model.id) ? ThinkingLevel.LOW : ThinkingLevel.MINIMAL;
|
|
366
357
|
case "low": return ThinkingLevel.LOW;
|
|
367
358
|
case "medium": return ThinkingLevel.MEDIUM;
|
|
368
359
|
case "high": return ThinkingLevel.HIGH;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region packages/ai/src/transports/google-thinking-level.ts
|
|
2
|
+
/** Returns whether a Gemini Flash model accepts the MINIMAL thinking level. */
|
|
3
|
+
function googleFlashSupportsMinimalThinking(modelId) {
|
|
4
|
+
const match = modelId.toLowerCase().match(/(?:^|\/)gemini-3\.(\d+)-flash(?:-|$)/);
|
|
5
|
+
if (!match) return true;
|
|
6
|
+
return Number.parseInt(match[1] ?? "0", 10) < 7;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { googleFlashSupportsMinimalThinking as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { t as AssistantMessageEventStream } from "./event-stream-uSMZJ3FA.mjs";
|
|
2
|
+
import { a as normalizeOptionalString } from "./string-coerce-fsri9iCu.mjs";
|
|
3
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-DTqNc7ad.mjs";
|
|
4
|
+
import { n as buildBaseOptions } from "./simple-options-D58D5Kvw.mjs";
|
|
5
|
+
import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-B0Qr9OR7.mjs";
|
|
5
6
|
import { GoogleGenAI, ResourceScope } from "@google/genai";
|
|
6
7
|
//#region packages/ai/src/providers/google-vertex.ts
|
|
7
8
|
const API_VERSION = "v1";
|
|
@@ -14,4 +14,12 @@ function onLlmRequestActivity(signal, listener) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
//#endregion
|
|
17
|
-
|
|
17
|
+
//#region packages/ai/src/utils/headers.ts
|
|
18
|
+
/** Converts a Headers object to a plain record for provider request handling. */
|
|
19
|
+
function headersToRecord(headers) {
|
|
20
|
+
const result = {};
|
|
21
|
+
for (const [key, value] of headers.entries()) result[key] = value;
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { notifyLlmRequestActivity as n, onLlmRequestActivity as r, headersToRecord as t };
|