@openclaw/ai 2026.7.2-beta.7 → 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-CH4UUnZr.mjs → anthropic-B6dLpq5L.mjs} +55 -203
- package/dist/{src-QkygScBs.mjs → anthropic-JsNA5KCu.mjs} +0 -1
- package/dist/anthropic-compaction-replay-8lJNKXOE.mjs +840 -0
- package/dist/anthropic-payload-policy-CiEuQS72.d.mts +49 -0
- package/dist/{api-registry-DlMgPR39.d.mts → api-registry-k3zTz0cV.d.mts} +1 -1
- package/dist/{azure-openai-responses-CImcwB83.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-YjaPW20U.d.mts → event-stream-BP6AWT8j.d.mts} +4 -1
- package/dist/{event-stream-D8n2uFee.mjs → event-stream-uSMZJ3FA.mjs} +26 -5
- package/dist/event-stream.d.mts +1 -1
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-CtSg0iTS.mjs → google-C7h2QzDX.mjs} +5 -5
- package/dist/{google-shared-DNBz5rcD.mjs → google-shared-B0Qr9OR7.mjs} +146 -89
- package/dist/google-thinking-level-C-V3tecN.mjs +9 -0
- package/dist/{google-vertex-31f1uS9L.mjs → google-vertex-Bhc3TjDl.mjs} +11 -7
- package/dist/{llm-request-activity-BjtkplhG.mjs → headers-DdOQtGuU.mjs} +9 -1
- package/dist/host-DTqNc7ad.mjs +466 -0
- package/dist/{host-B9GUmcra.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 +29 -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 -5
- package/dist/{json-parse-BvXNt1-7.mjs → json-parse-CDnesDM_.mjs} +4 -6
- package/dist/{mistral-CWmpvWYh.mjs → mistral-CEWoQI_g.mjs} +45 -48
- package/dist/number-coercion-H9qHik3g.mjs +71 -0
- package/dist/openai-chatgpt-jwt-KWcgd0d_.mjs +19 -0
- package/dist/{openai-chatgpt-responses-B84Ibtrd.mjs → openai-chatgpt-responses-CrPmqERt.mjs} +284 -240
- package/dist/{openai-completions-DsOxhOD1.mjs → openai-completions-BPnt4Sml.mjs} +65 -99
- package/dist/{openai-completions-compat-DBWjXoMZ.d.mts → openai-completions-compat-Dt3dcawL.d.mts} +2 -2
- package/dist/{openai-responses-BT7A3sLu.mjs → openai-responses-DhIKtOup.mjs} +18 -41
- 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-DgNTYnRY.mjs +46 -0
- package/dist/{openai-responses-stream-internal-Cw5txaGW.mjs → openai-responses-shared-DXIt3iY5.mjs} +1406 -940
- package/dist/{openai-reasoning-compat-YgeLncHw.mjs → openai-stop-reason-BkFkqqK0.mjs} +204 -37
- package/dist/openai-tool-projection-CY04OcvQ.mjs +338 -0
- package/dist/provider-error-BUwEnjXq.mjs +429 -0
- package/dist/provider-error-CzNw4BWX.d.mts +12 -0
- package/dist/{provider-options-D8bB3z9b.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/sanitize-unicode-BYqrYtC_.mjs +90 -0
- 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-BBys9hSb.mjs → stream-first-event-timeout-MK28puvq.mjs} +2 -2
- package/dist/string-coerce-fsri9iCu.mjs +34 -0
- package/dist/{tool-schema-json-projection-BwNu3nDi.mjs → tool-schema-json-projection-q5d7QX5c.mjs} +32 -7
- package/dist/transport-utils-DJqkxbhC.mjs +138 -0
- package/dist/transports.d.mts +166 -241
- package/dist/transports.mjs +1979 -1825
- package/dist/types-BDdaOVi2.mjs +6 -0
- package/dist/{types-bzp5k29J.d.mts → types-BHNrPS1l.d.mts} +23 -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-B-j7cOYp.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/anthropic-usage-DWU-x8MI.mjs +0 -459
- package/dist/error-coercion-DgxlWC0n.mjs +0 -15
- package/dist/headers-B_e4-1J0.mjs +0 -9
- package/dist/host-Dog2WQiR.mjs +0 -369
- package/dist/number-coercion-DvG7SNMg.mjs +0 -129
- package/dist/openai-chatgpt-jwt-DhAAzLkj.mjs +0 -39
- package/dist/openai-responses-shared-pXl6Wd8S.mjs +0 -392
- package/dist/openai-tool-projection-OhX64DoP.mjs +0 -215
- package/dist/provider-error-CAEvRjry.mjs +0 -47
- package/dist/sanitize-unicode-DT5o51ur.mjs +0 -26
- package/dist/simple-options-9lhRrN73.mjs +0 -50
- 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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region packages/ai/src/transports/anthropic-payload-policy.d.ts
|
|
2
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
3
|
+
type AnthropicServiceTier = "auto" | "standard_only";
|
|
4
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
5
|
+
type AnthropicEphemeralCacheControl = {
|
|
6
|
+
type: "ephemeral";
|
|
7
|
+
ttl?: "1h" | "5m";
|
|
8
|
+
};
|
|
9
|
+
type AnthropicPayloadPolicyInput = {
|
|
10
|
+
api?: string;
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
cacheRetention?: "short" | "long" | "none";
|
|
13
|
+
contextWindow?: unknown;
|
|
14
|
+
enableCacheControl?: boolean;
|
|
15
|
+
enableServerCompaction?: boolean;
|
|
16
|
+
extraParams?: Record<string, unknown>;
|
|
17
|
+
provider?: string;
|
|
18
|
+
serviceTier?: AnthropicServiceTier;
|
|
19
|
+
};
|
|
20
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
21
|
+
type AnthropicPayloadPolicy = {
|
|
22
|
+
allowsServiceTier: boolean;
|
|
23
|
+
cacheControl: AnthropicEphemeralCacheControl | undefined;
|
|
24
|
+
compactThreshold: number;
|
|
25
|
+
serviceTier: AnthropicServiceTier | undefined;
|
|
26
|
+
useServerCompaction: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** Resolve the server-compaction gate and effective threshold for an Anthropic route. */
|
|
29
|
+
declare function resolveAnthropicServerCompactionPlan(model: {
|
|
30
|
+
provider?: unknown;
|
|
31
|
+
api?: unknown;
|
|
32
|
+
baseUrl?: string;
|
|
33
|
+
contextWindow?: unknown;
|
|
34
|
+
}, extraParams?: Record<string, unknown>): {
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
threshold?: number;
|
|
37
|
+
};
|
|
38
|
+
/** Resolve Anthropic cache-control marker retention for a request endpoint. */
|
|
39
|
+
declare function resolveAnthropicEphemeralCacheControl(baseUrl: string | undefined, cacheRetention: AnthropicPayloadPolicyInput["cacheRetention"]): AnthropicEphemeralCacheControl | undefined;
|
|
40
|
+
/** Apply one shared deepest-stable-message cache breakpoint policy. */
|
|
41
|
+
declare function applyAnthropicCacheControlToMessages(messages: unknown, cacheControl: AnthropicEphemeralCacheControl, markerLimit: number, cacheBreakpointOptOutMessageIndexes: ReadonlySet<number>): void;
|
|
42
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
43
|
+
declare function resolveAnthropicPayloadPolicy(input: AnthropicPayloadPolicyInput): AnthropicPayloadPolicy;
|
|
44
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
45
|
+
declare function applyAnthropicPayloadPolicyToParams(payloadObj: Record<string, unknown>, policy: AnthropicPayloadPolicy, cacheBreakpointOptOutMessageIndexes: ReadonlySet<number>): void;
|
|
46
|
+
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
47
|
+
declare function applyAnthropicEphemeralCacheControlMarkers(payloadObj: Record<string, unknown>, cacheControl?: AnthropicEphemeralCacheControl | null): void;
|
|
48
|
+
//#endregion
|
|
49
|
+
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 { E as Model,
|
|
1
|
+
import { E as Model, H as StreamOptions, R as SimpleStreamOptions, V as StreamFunction, n as Api, o as AssistantMessageEventStreamContract, u as Context } from "./types-BHNrPS1l.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-DTqNc7ad.mjs";
|
|
4
4
|
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-mZTCdRPo.mjs";
|
|
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";
|
|
5
7
|
import { i as resolveAzureDeploymentNameFromMap, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-C7K7QfUE.mjs";
|
|
6
|
-
import { n as buildBaseOptions } from "./simple-options-9lhRrN73.mjs";
|
|
7
|
-
import { a as runResponsesStreamLifecycle, i as resolveResponsesReasoningEffort, n as convertResponsesMessages, r as createResponsesAssistantOutput, t as applyCommonResponsesParams } from "./openai-responses-shared-pXl6Wd8S.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,13 +1,16 @@
|
|
|
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. */
|
|
5
5
|
declare class EventStream<T, R = T> implements AsyncIterable<T> {
|
|
6
6
|
private queue;
|
|
7
|
+
private queueHead;
|
|
7
8
|
private waiting;
|
|
8
9
|
private done;
|
|
10
|
+
private resultSettled;
|
|
9
11
|
private finalResultPromise;
|
|
10
12
|
private resolveFinalResult;
|
|
13
|
+
private rejectFinalResult;
|
|
11
14
|
private isComplete;
|
|
12
15
|
private extractResult;
|
|
13
16
|
constructor(isComplete: (event: T) => boolean, extractResult: (event: T) => R);
|
|
@@ -3,22 +3,29 @@
|
|
|
3
3
|
var EventStream = class {
|
|
4
4
|
constructor(isComplete, extractResult) {
|
|
5
5
|
this.queue = [];
|
|
6
|
+
this.queueHead = 0;
|
|
6
7
|
this.waiting = [];
|
|
7
8
|
this.done = false;
|
|
9
|
+
this.resultSettled = false;
|
|
8
10
|
this.isComplete = isComplete;
|
|
9
11
|
this.extractResult = extractResult;
|
|
10
12
|
const resolvers = [];
|
|
11
|
-
|
|
13
|
+
const rejecters = [];
|
|
14
|
+
this.finalResultPromise = new Promise((resolve, reject) => {
|
|
12
15
|
resolvers.push(resolve);
|
|
16
|
+
rejecters.push(reject);
|
|
13
17
|
});
|
|
14
18
|
const resolveFinalResult = resolvers.at(0);
|
|
15
|
-
|
|
19
|
+
const rejectFinalResult = rejecters.at(0);
|
|
20
|
+
if (!resolveFinalResult || !rejectFinalResult) throw new Error("event stream result promise did not initialize its resolver");
|
|
16
21
|
this.resolveFinalResult = resolveFinalResult;
|
|
22
|
+
this.rejectFinalResult = rejectFinalResult;
|
|
17
23
|
}
|
|
18
24
|
push(event) {
|
|
19
25
|
if (this.done) return;
|
|
20
26
|
if (this.isComplete(event)) {
|
|
21
27
|
this.done = true;
|
|
28
|
+
this.resultSettled = true;
|
|
22
29
|
this.resolveFinalResult(this.extractResult(event));
|
|
23
30
|
}
|
|
24
31
|
const waiter = this.waiting.shift();
|
|
@@ -30,7 +37,14 @@ var EventStream = class {
|
|
|
30
37
|
}
|
|
31
38
|
end(result) {
|
|
32
39
|
this.done = true;
|
|
33
|
-
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
|
+
}
|
|
34
48
|
while (this.waiting.length > 0) {
|
|
35
49
|
const waiter = this.waiting.shift();
|
|
36
50
|
if (!waiter) break;
|
|
@@ -41,8 +55,15 @@ var EventStream = class {
|
|
|
41
55
|
}
|
|
42
56
|
}
|
|
43
57
|
async *[Symbol.asyncIterator]() {
|
|
44
|
-
while (true) if (this.
|
|
45
|
-
|
|
58
|
+
while (true) if (this.queueHead < this.queue.length) {
|
|
59
|
+
const event = this.queue[this.queueHead];
|
|
60
|
+
this.queueHead += 1;
|
|
61
|
+
if (this.queueHead >= 1024 && this.queueHead * 2 >= this.queue.length) {
|
|
62
|
+
this.queue = this.queue.slice(this.queueHead);
|
|
63
|
+
this.queueHead = 0;
|
|
64
|
+
}
|
|
65
|
+
yield event;
|
|
66
|
+
} else if (this.done) return;
|
|
46
67
|
else {
|
|
47
68
|
const result = await new Promise((resolve) => {
|
|
48
69
|
this.waiting.push(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-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 { n as buildBaseOptions } from "./simple-options-
|
|
5
|
-
import {
|
|
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;
|
|
@@ -49,7 +49,7 @@ function createClient(model, apiKey, optionsHeaders) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
function buildParams(model, context, options = {}) {
|
|
52
|
-
return buildGoogleGenerateContentParams(model, context, options
|
|
52
|
+
return buildGoogleGenerateContentParams(model, context, options);
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
export { streamGoogle, streamSimpleGoogle };
|