@openclaw/ai 2026.8.1-beta.1 → 2026.8.1-beta.3
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-B8KwTtlb.mjs} +62 -37
- package/dist/{anthropic-SrGtwsJu.d.mts → anthropic-BECQCNdF.d.mts} +0 -2
- package/dist/{src-QkygScBs.mjs → anthropic-BQXQudmA.mjs} +0 -2
- package/dist/{anthropic-usage-Ma4iX6uG.mjs → anthropic-compaction-replay-4Zx7-aCr.mjs} +225 -103
- package/dist/anthropic-payload-policy-CSx7MoKH.d.mts +50 -0
- package/dist/{api-registry-EpJoVwM1.d.mts → api-registry-DFxSnFqG.d.mts} +1 -1
- package/dist/{azure-openai-responses-Cc_kasye.mjs → azure-openai-responses-Aa4mVcYG.mjs} +23 -29
- package/dist/diagnostics.d.mts +24 -1
- package/dist/diagnostics.mjs +2 -1
- package/dist/event-stream-BVVgDSdq.d.mts +1 -0
- package/dist/{event-stream-DRmDMRHH.d.mts → event-stream-D91-ohD_.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-shared-Cq2UKx1l.mjs → google-shared-M1dl64nz.mjs} +17 -19
- package/dist/google-thinking-level-C-V3tecN.mjs +9 -0
- package/dist/{google-vertex-CusxWzvE.mjs → google-vertex-DCJHM_a5.mjs} +5 -4
- package/dist/{google-CGQu21aw.mjs → google-yDRnipeq.mjs} +4 -4
- package/dist/host-DF_yxOsA.mjs +477 -0
- package/dist/{host-Dn4_SZI2.d.mts → host-DJq_FGcz.d.mts} +13 -8
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +7 -5
- package/dist/internal/anthropic.d.mts +21 -7
- 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 +9 -7
- package/dist/internal/runtime.d.mts +19 -5
- package/dist/internal/runtime.mjs +85 -72
- package/dist/internal/shared.d.mts +17 -8
- package/dist/internal/shared.mjs +4 -5
- package/dist/{json-parse-BvXNt1-7.mjs → json-parse-CDnesDM_.mjs} +4 -6
- package/dist/{mistral-Dx6VzNjf.mjs → mistral-D6hRXI7A.mjs} +67 -72
- 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-C339VIfT.mjs} +235 -146
- package/dist/{openai-completions-BaIpl93j.mjs → openai-completions-D88orSJ9.mjs} +88 -67
- package/dist/openai-completions-compat-B0KTleXp.d.mts +43 -0
- package/dist/{openai-responses-Bdx3V_Yu.mjs → openai-responses-BXEcr-Tp.mjs} +17 -24
- package/dist/openai-responses-contracts-CD75pQ0m.d.mts +68 -0
- package/dist/openai-responses-contracts-DvILoqBk.mjs +247 -0
- package/dist/openai-responses-payload-policy-BDo8CQsx.mjs +208 -0
- package/dist/openai-responses-payload-policy-CNGFT9zr.d.mts +41 -0
- package/dist/{openai-responses-prompt-observer-internal-DDZPxRfr.mjs → openai-responses-prompt-observer-internal-BG-1AsBI.mjs} +2 -3
- package/dist/{openai-responses-stream-internal-Bl8YyVtF.mjs → openai-responses-shared-Cvt5MgEm.mjs} +1287 -1039
- package/dist/{openai-reasoning-compat-DKebnIBL.mjs → openai-stop-reason-9OONKyAm.mjs} +222 -180
- package/dist/{openai-transport-shared-Cipt7egQ.mjs → openai-tool-projection-CHGLt03m.mjs} +239 -128
- package/dist/provider-error-C8mBRJDl.mjs +424 -0
- package/dist/provider-error-CzNw4BWX.d.mts +12 -0
- package/dist/provider-options-AvldWZt8.mjs +21 -0
- package/dist/{provider-options-C5kYML7i.d.mts → provider-options-Cc5ZQ6Aa.d.mts} +19 -3
- package/dist/provider-transcript-transform--gtf0ZbR.mjs +32 -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-5ygO2rZc.mjs} +17 -8
- package/dist/record-coerce-DdXsgUd_.mjs +23 -0
- package/dist/{model-utils-Dau5dlgm.mjs → sanitize-unicode-BP7HLLZn.mjs} +28 -2
- package/dist/session-resources-CkR4WWy1.mjs +21 -0
- package/dist/simple-options-oqsXB6U3.mjs +450 -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-FEr-jOoZ.mjs} +20 -13
- package/dist/transport-utils-Bv0FHkd0.mjs +138 -0
- package/dist/transports.d.mts +199 -209
- package/dist/transports.mjs +1842 -1364
- package/dist/types-BDdaOVi2.mjs +6 -0
- package/dist/{types-CH7ReIcU.d.mts → types-DTAP49HF.d.mts} +35 -2
- package/dist/types.d.mts +5 -5
- 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-DYNNrU9u.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +15 -1
- package/dist/host-Bl7Kgddo.mjs +0 -407
- 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
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { D as Model } from "./types-DTAP49HF.mjs";
|
|
2
|
+
//#region packages/ai/src/transports/anthropic-payload-policy.d.ts
|
|
3
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
4
|
+
type AnthropicServiceTier = "auto" | "standard_only";
|
|
5
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
6
|
+
type AnthropicEphemeralCacheControl = {
|
|
7
|
+
type: "ephemeral";
|
|
8
|
+
ttl?: "1h" | "5m";
|
|
9
|
+
};
|
|
10
|
+
type AnthropicPayloadPolicyInput = {
|
|
11
|
+
api?: string;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
cacheRetention?: "short" | "long" | "none";
|
|
14
|
+
contextWindow?: unknown;
|
|
15
|
+
enableCacheControl?: boolean;
|
|
16
|
+
enableServerCompaction?: boolean;
|
|
17
|
+
extraParams?: Record<string, unknown>;
|
|
18
|
+
provider?: string;
|
|
19
|
+
serviceTier?: AnthropicServiceTier;
|
|
20
|
+
};
|
|
21
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
22
|
+
type AnthropicPayloadPolicy = {
|
|
23
|
+
allowsServiceTier: boolean;
|
|
24
|
+
cacheControl: AnthropicEphemeralCacheControl | undefined;
|
|
25
|
+
compactThreshold: number;
|
|
26
|
+
serviceTier: AnthropicServiceTier | undefined;
|
|
27
|
+
useServerCompaction: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** Resolve the server-compaction gate and effective threshold for an Anthropic route. */
|
|
30
|
+
declare function resolveAnthropicServerCompactionPlan(model: {
|
|
31
|
+
provider?: unknown;
|
|
32
|
+
api?: unknown;
|
|
33
|
+
baseUrl?: string;
|
|
34
|
+
contextWindow?: unknown;
|
|
35
|
+
}, extraParams?: Record<string, unknown>): {
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
threshold?: number;
|
|
38
|
+
};
|
|
39
|
+
/** Resolve Anthropic cache-control marker retention for a request endpoint. */
|
|
40
|
+
declare function resolveAnthropicEphemeralCacheControl(baseUrl: string | undefined, cacheRetention: AnthropicPayloadPolicyInput["cacheRetention"]): AnthropicEphemeralCacheControl | undefined;
|
|
41
|
+
/** Apply one shared deepest-stable-message cache breakpoint policy. */
|
|
42
|
+
declare function applyAnthropicCacheControlToMessages(messages: unknown, cacheControl: AnthropicEphemeralCacheControl, markerLimit: number, cacheBreakpointOptOutMessageIndexes: ReadonlySet<number>): void;
|
|
43
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
44
|
+
declare function resolveAnthropicPayloadPolicy(input: AnthropicPayloadPolicyInput, model?: Model): AnthropicPayloadPolicy;
|
|
45
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
46
|
+
declare function applyAnthropicPayloadPolicyToParams(payloadObj: Record<string, unknown>, policy: AnthropicPayloadPolicy, cacheBreakpointOptOutMessageIndexes: ReadonlySet<number>): void;
|
|
47
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
48
|
+
declare function applyAnthropicEphemeralCacheControlMarkers(payloadObj: Record<string, unknown>, cacheControl?: AnthropicEphemeralCacheControl | null): void;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { resolveAnthropicPayloadPolicy as a, resolveAnthropicEphemeralCacheControl as i, applyAnthropicEphemeralCacheControlMarkers as n, resolveAnthropicServerCompactionPlan as o, applyAnthropicPayloadPolicyToParams as r, applyAnthropicCacheControlToMessages as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as Model, H as StreamFunction, U as StreamOptions, d as Context, n as Api, s as AssistantMessageEventStreamContract, z as SimpleStreamOptions } from "./types-DTAP49HF.mjs";
|
|
2
2
|
//#region packages/ai/src/api-registry.d.ts
|
|
3
3
|
/** Runtime stream adapter signature stored in the API provider registry. */
|
|
4
4
|
type ApiStreamFunction = (model: Model, context: Context, options?: StreamOptions) => AssistantMessageEventStreamContract;
|
|
@@ -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-DF_yxOsA.mjs";
|
|
4
4
|
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { n as buildBaseOptions } from "./simple-options-oqsXB6U3.mjs";
|
|
6
|
+
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, o as runResponsesStreamLifecycle, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-Cvt5MgEm.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-C8mBRJDl.mjs";
|
|
3
|
+
export { appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, extractDiagnosticError, formatThrownValue, projectDiagnosticValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as AssistantMessage, o as AssistantMessageEvent, s as AssistantMessageEventStreamContract } from "./types-DTAP49HF.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-D91-ohD_.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,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-BP7HLLZn.mjs";
|
|
2
|
+
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload } from "./host-DF_yxOsA.mjs";
|
|
3
|
+
import { P as sortPromptCacheToolsByName, _ as notifyProviderStreamOpened, a as assignTransportErrorDetails, j as stripSystemPromptCacheBoundary, o as coerceTransportToolCallArguments, x as transportAbortError } from "./simple-options-oqsXB6U3.mjs";
|
|
4
|
+
import { t as googleFlashSupportsMinimalThinking } from "./google-thinking-level-C-V3tecN.mjs";
|
|
5
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform--gtf0ZbR.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;
|
|
@@ -246,8 +244,15 @@ async function runGoogleGenerateContentLifecycle(params) {
|
|
|
246
244
|
let requestParams = params.buildParams();
|
|
247
245
|
const nextParams = await options?.onPayload?.(requestParams, model);
|
|
248
246
|
if (nextParams !== void 0) requestParams = nextParams;
|
|
247
|
+
const googleIterator = (await client.models.generateContentStream(requestParams))[Symbol.asyncIterator]();
|
|
248
|
+
await notifyProviderStreamOpened({
|
|
249
|
+
options,
|
|
250
|
+
cancelStream: async () => {
|
|
251
|
+
await googleIterator.return?.();
|
|
252
|
+
}
|
|
253
|
+
});
|
|
249
254
|
await consumeGoogleGenerateContentStream({
|
|
250
|
-
chunks:
|
|
255
|
+
chunks: { [Symbol.asyncIterator]: () => googleIterator },
|
|
251
256
|
model,
|
|
252
257
|
output,
|
|
253
258
|
stream,
|
|
@@ -256,14 +261,7 @@ async function runGoogleGenerateContentLifecycle(params) {
|
|
|
256
261
|
});
|
|
257
262
|
} catch (error) {
|
|
258
263
|
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;
|
|
264
|
+
assignTransportErrorDetails(output, options?.signal?.aborted ? transportAbortError(options.signal) : error, options?.signal);
|
|
267
265
|
stream.push({
|
|
268
266
|
type: "error",
|
|
269
267
|
reason: output.stopReason === "aborted" ? "aborted" : "error",
|
|
@@ -334,7 +332,7 @@ function buildGoogleSimpleThinking(model, options, config) {
|
|
|
334
332
|
}
|
|
335
333
|
function getDisabledGoogleThinkingConfig(model) {
|
|
336
334
|
if (isGemini3ProModel(model)) return { thinkingLevel: ThinkingLevel.LOW };
|
|
337
|
-
if (isGemini3FlashModel(model)) return { thinkingLevel: ThinkingLevel.MINIMAL };
|
|
335
|
+
if (isGemini3FlashModel(model)) return { thinkingLevel: googleFlashSupportsMinimalThinking(model.id) ? ThinkingLevel.MINIMAL : ThinkingLevel.LOW };
|
|
338
336
|
if (isGemma4Model(model) || model.id.toLowerCase().includes("gemini-2.5-pro")) return {};
|
|
339
337
|
return { thinkingBudget: 0 };
|
|
340
338
|
}
|
|
@@ -362,7 +360,7 @@ function getGoogleThinkingLevel(effort, model, config) {
|
|
|
362
360
|
case "high": return ThinkingLevel.HIGH;
|
|
363
361
|
}
|
|
364
362
|
switch (effort) {
|
|
365
|
-
case "minimal": return ThinkingLevel.MINIMAL;
|
|
363
|
+
case "minimal": return isGemini3FlashModel(model) && !googleFlashSupportsMinimalThinking(model.id) ? ThinkingLevel.LOW : ThinkingLevel.MINIMAL;
|
|
366
364
|
case "low": return ThinkingLevel.LOW;
|
|
367
365
|
case "medium": return ThinkingLevel.MEDIUM;
|
|
368
366
|
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-DF_yxOsA.mjs";
|
|
4
|
+
import { n as buildBaseOptions } from "./simple-options-oqsXB6U3.mjs";
|
|
5
|
+
import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-M1dl64nz.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";
|
|
@@ -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-DF_yxOsA.mjs";
|
|
4
|
+
import { n as buildBaseOptions } from "./simple-options-oqsXB6U3.mjs";
|
|
5
|
+
import { i as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-M1dl64nz.mjs";
|
|
6
6
|
import { GoogleGenAI } from "@google/genai";
|
|
7
7
|
//#region packages/ai/src/providers/google.ts
|
|
8
8
|
let toolCallCounter = 0;
|