@openclaw/ai 2026.9.5 → 2026.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{anthropic-COtDvgtt.mjs → anthropic-Cw2pgccz.mjs} +59 -88
- package/dist/{anthropic-payload-policy-5Erq1Nzy.d.mts → anthropic-payload-policy-NIPVYXPq.d.mts} +8 -6
- package/dist/{anthropic-stream-reducer-BvdYYWL8.mjs → anthropic-stream-reducer-D9MCkl8Z.mjs} +194 -247
- package/dist/{api-registry-Ba2Cv-ut.d.mts → api-registry-D-nbmSqr.d.mts} +2 -2
- package/dist/{azure-openai-responses-YrgnD583.mjs → azure-openai-responses-BwT3-X8P.mjs} +22 -33
- package/dist/{base64-BQOzsvUH.mjs → base64-C1PsYcRQ.mjs} +22 -16
- package/dist/{diagnostics-Dm4bisWG.mjs → diagnostics-CJaB6g8J.mjs} +55 -10
- package/dist/{diagnostics-CPeq9F7y.mjs → diagnostics-DzrF1h4J.mjs} +18 -1
- package/dist/diagnostics.d.mts +11 -5
- package/dist/diagnostics.mjs +4 -4
- package/dist/{env-api-keys-bktO00EJ.mjs → env-api-keys-CyX4VKGO.mjs} +7 -5
- package/dist/event-stream-CMQfX_yr.d.mts +1 -0
- package/dist/{event-stream-CCoa-qSI.d.mts → event-stream-DOPFYVqs.d.mts} +2 -2
- package/dist/{event-stream-D8PARQfL.mjs → event-stream-vd9UnCAU.mjs} +10 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-BuhpRO9r.mjs → google-BfapkS_K.mjs} +8 -11
- package/dist/google-interactions-DW3iXzjc.mjs +574 -0
- package/dist/{google-messages-CyWnYlh0.mjs → google-messages-CtjVtVot.mjs} +35 -71
- package/dist/{google-shared-BT5ZeNer.mjs → google-shared-Y2YfotEu.mjs} +43 -47
- package/dist/{google-vertex-C7EplRvt.mjs → google-vertex-Dov4kBWu.mjs} +16 -30
- package/dist/{host-B4MeUNBc.mjs → host-CHi3X87F.mjs} +64 -189
- package/dist/{host-policy-DUnXSx0I.mjs → host-policy-BOAwRg_M.mjs} +2 -14
- package/dist/{host-FZ1RA_qD.d.mts → host-rxlNaBwm.d.mts} +9 -3
- package/dist/{index-DaF2QbwS.d.mts → index-D6KsSE74.d.mts} +57 -9
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +7 -7
- package/dist/internal/anthropic.d.mts +13 -8
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +46 -9
- package/dist/internal/openai.mjs +13 -12
- package/dist/internal/runtime.d.mts +31 -70
- package/dist/internal/runtime.mjs +11 -66
- package/dist/internal/shared.d.mts +16 -13
- package/dist/internal/shared.mjs +6 -5
- package/dist/internal/tool-schema.d.mts +2 -2
- package/dist/internal/tool-schema.mjs +2 -2
- package/dist/{mistral-moA-mbwl.mjs → mistral-RS6mboC-.mjs} +46 -93
- package/dist/{model-transport-url-DKocrEsb.d.mts → model-transport-url-C5f59L3Y.d.mts} +1 -1
- package/dist/{openai-chatgpt-responses-DWID3EFO.mjs → openai-chatgpt-responses-CYbidtrn.mjs} +118 -99
- package/dist/{openai-completions-DJ1Vm-CD.mjs → openai-completions-D14ihPYk.mjs} +14 -12
- package/dist/{openai-completions-compat-CkwdxTZx.mjs → openai-completions-compat-BOVWBZDn.mjs} +3 -5
- package/dist/{openai-completions-compat-JE7gqxb9.d.mts → openai-completions-compat-qJjmqQ71.d.mts} +3 -3
- package/dist/{openai-completions-stream-Bu98b0Hv.mjs → openai-completions-stream-CDCuw3DP.mjs} +124 -183
- package/dist/{openai-prompt-cache-CJ_xEevu.d.mts → openai-prompt-cache-CouErLh7.d.mts} +2 -2
- package/dist/{openai-prompt-cache-1wfaIszn.mjs → openai-prompt-cache-D2V7MqR7.mjs} +1 -1
- package/dist/{openai-provider-client-DPo0Hmak.mjs → openai-provider-client-CwfsGBbA.mjs} +2 -2
- package/dist/{openai-reasoning-effort-NlFZmfEu.mjs → openai-reasoning-effort-ConhwkeX.mjs} +14 -5
- package/dist/{openai-responses-BejZzQCP.mjs → openai-responses-CKCBEc2W.mjs} +12 -11
- package/dist/openai-responses-compaction-replay-DiYn-gFM.d.mts +12 -0
- package/dist/{openai-responses-compaction-window-D6P5oZP5.mjs → openai-responses-compaction-window-UNK1GDpy.mjs} +5 -5
- package/dist/{openai-responses-contracts-DWrfMODE.mjs → openai-responses-contracts-CLxnqS9p.mjs} +1 -1
- package/dist/{openai-responses-contracts-Dflvrfa8.d.mts → openai-responses-contracts-D1iZ0njF.d.mts} +4 -4
- package/dist/{openai-responses-prompt-observer-internal-C15_-OwV.mjs → openai-responses-prompt-observer-internal-iAqLb4tk.mjs} +16 -13
- package/dist/openai-responses-request-lifecycle-Fsag-IGZ.mjs +36 -0
- package/dist/{openai-responses-shared-CwsziD_m.mjs → openai-responses-shared-DL4ulQn7.mjs} +838 -577
- package/dist/{openai-responses-terminal-usage-Dl3J6zrf.d.mts → openai-responses-terminal-usage-BE7lf7nW.d.mts} +2 -2
- package/dist/{openai-stop-reason-Drnn_6Qj.mjs → openai-stop-reason-8s70vDXj.mjs} +2 -12
- package/dist/{openai-tool-schema-ynZBgqW-.d.mts → openai-tool-schema-a5ysBBga.d.mts} +0 -6
- package/dist/{openai-tool-schema-BO8rwyAD.mjs → openai-tool-schema-vsl-cE-n.mjs} +365 -429
- package/dist/{openai-transport-params-DQeuAvBl.mjs → openai-transport-params-BwlpzX-2.mjs} +61 -106
- package/dist/{positive-integer-DtjCkbue.mjs → positive-integer-CjN5OJbH.mjs} +1 -1
- package/dist/{provider-error-DDqw9Qda.mjs → provider-error-CwT_j2v0.mjs} +82 -10
- package/dist/{provider-error-CzNw4BWX.d.mts → provider-error-xumb1V3F.d.mts} +3 -1
- package/dist/{provider-options-DprLsWh9.d.mts → provider-options-Df7ov0K1.d.mts} +6 -4
- package/dist/{provider-replay-context-CnUSOwhr.mjs → provider-replay-context-DsyI5jOP.mjs} +1 -1
- package/dist/{provider-transcript-transform-BsRAhuWJ.mjs → provider-transcript-transform-JbFbHV8h.mjs} +17 -2
- package/dist/{provider-transport-turn-state-CkGToCD2.mjs → provider-transport-turn-state-BheUi_hl.mjs} +1 -1
- package/dist/{provider-types-CAKRC7N5.d.mts → provider-types-d4XnoZMd.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +15 -11
- package/dist/{reasoning-tag-text-partitioner-Dy9IO8Dc.mjs → reasoning-tag-text-partitioner-B6FIIBt6.mjs} +193 -98
- package/dist/{record-coerce-DwRYMj3t.mjs → record-coerce-CNDovvft.mjs} +1 -1
- package/dist/simple-options-CGAkCwtM.mjs +349 -0
- package/dist/{src-DeKjbE8I.mjs → src-H4aXcFuX.mjs} +53 -26
- package/dist/{stream-CREqxHgU.mjs → stream-DDsCBgd-.mjs} +1 -7
- package/dist/{stream-first-event-timeout-C9ZadkJW.mjs → stream-first-event-timeout-B9o0S4SZ.mjs} +1 -1
- package/dist/{tool-schema-json-projection-CD9c_fK8.mjs → tool-schema-json-projection-Ct8SeBeJ.mjs} +63 -23
- package/dist/{transport-stream-shared-D-6FQSHm.mjs → transport-stream-shared-Dh5qKJ8e.mjs} +63 -37
- package/dist/{transport-stream-shared-BbUkFaHi.d.mts → transport-stream-shared-yYhXa4kX.d.mts} +13 -7
- package/dist/{transport-utils-1cyq5Y7x.mjs → transport-utils-C-4bf2Ok.mjs} +3 -4
- package/dist/transports.d.mts +37 -33
- package/dist/transports.mjs +208 -239
- package/dist/types-CB-_vNyI.d.mts +1 -0
- package/dist/{types-4_uVs5WH.d.mts → types-CLLR3eB4.d.mts} +5 -1
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +5 -5
- package/dist/{validation-Dw7cb6BV.mjs → validation-BFZc40Ig.mjs} +80 -54
- package/dist/{validation-Ctzu2DhF.d.mts → validation-Cat2wQsc.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +6 -6
- package/dist/assistant-output-BsEkB-vU.mjs +0 -16
- package/dist/event-stream-DmSCpi1T.d.mts +0 -1
- package/dist/simple-options-C6cFWj_f.mjs +0 -175
- package/dist/types-DkJfb4W3.d.mts +0 -1
- package/dist/utf16-slice-CvGodqok.mjs +0 -29
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { G as SimpleStreamOptions, J as StreamFunction, O as Model, Y as StreamOptions, d as Context, n as Api, s as AssistantMessageEventStreamContract } from "./types-
|
|
1
|
+
import "./index-D6KsSE74.mjs";
|
|
2
|
+
import { G as SimpleStreamOptions, J as StreamFunction, O as Model, Y as StreamOptions, d as Context, n as Api, s as AssistantMessageEventStreamContract } from "./types-CLLR3eB4.mjs";
|
|
3
3
|
//#region packages/ai/src/api-registry.d.ts
|
|
4
4
|
/** Runtime stream adapter signature stored in the API provider registry. */
|
|
5
5
|
type ApiStreamFunction = (model: Model, context: Context, options?: StreamOptions) => AssistantMessageEventStreamContract;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
2
|
-
import { n as getAiTransportHost } from "./host-
|
|
3
|
-
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-
|
|
4
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
5
|
-
import { g as resolveOpenAISimpleReasoningEffort } from "./openai-transport-params-
|
|
6
|
-
import { n as getEnvApiKey } from "./env-api-keys-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { t as AssistantMessageEventStream } from "./event-stream-vd9UnCAU.mjs";
|
|
2
|
+
import { n as getAiTransportHost } from "./host-CHi3X87F.mjs";
|
|
3
|
+
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-D2V7MqR7.mjs";
|
|
4
|
+
import { n as buildBaseOptions } from "./simple-options-CGAkCwtM.mjs";
|
|
5
|
+
import { g as resolveOpenAISimpleReasoningEffort } from "./openai-transport-params-BwlpzX-2.mjs";
|
|
6
|
+
import { n as getEnvApiKey } from "./env-api-keys-CyX4VKGO.mjs";
|
|
7
|
+
import { n as createAssistantOutput } from "./provider-transcript-transform-JbFbHV8h.mjs";
|
|
8
|
+
import { P as convertProviderResponsesMessages, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams } from "./openai-responses-shared-DL4ulQn7.mjs";
|
|
9
|
+
import { i as resolveAzureDeploymentNameFromMap, n as isTraditionalAzureOpenAIHost, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-C7K7QfUE.mjs";
|
|
9
10
|
import OpenAI, { AzureOpenAI } from "openai";
|
|
10
11
|
//#region packages/ai/src/providers/azure-openai-responses.ts
|
|
11
12
|
const DEFAULT_AZURE_API_VERSION = "v1";
|
|
@@ -23,7 +24,7 @@ function resolveDeploymentName(model, options) {
|
|
|
23
24
|
}
|
|
24
25
|
const streamAzureOpenAIResponses = (model, context, options) => {
|
|
25
26
|
const stream = new AssistantMessageEventStream();
|
|
26
|
-
const output =
|
|
27
|
+
const output = createAssistantOutput(model, "azure-openai-responses");
|
|
27
28
|
runResponsesStreamLifecycle({
|
|
28
29
|
stream,
|
|
29
30
|
model,
|
|
@@ -62,24 +63,18 @@ function normalizeAzureBaseUrl(baseUrl) {
|
|
|
62
63
|
} catch {
|
|
63
64
|
throw new Error(`Invalid Azure OpenAI base URL: ${baseUrl}`);
|
|
64
65
|
}
|
|
65
|
-
const isAzureHost = url.hostname.endsWith(".openai.azure.com") || url.hostname.endsWith(".cognitiveservices.azure.com");
|
|
66
66
|
const normalizedPath = url.pathname.replace(/\/+$/, "");
|
|
67
|
-
if (
|
|
67
|
+
if (isTraditionalAzureOpenAIHost(url.hostname) && (normalizedPath === "" || normalizedPath === "/" || normalizedPath === "/openai")) {
|
|
68
68
|
url.pathname = "/openai/v1";
|
|
69
69
|
url.search = "";
|
|
70
70
|
}
|
|
71
71
|
return url.toString().replace(/\/+$/, "");
|
|
72
72
|
}
|
|
73
|
-
function buildDefaultBaseUrl(resourceName) {
|
|
74
|
-
return `https://${resourceName}.openai.azure.com/openai/v1`;
|
|
75
|
-
}
|
|
76
73
|
function resolveAzureConfig(model, options) {
|
|
77
74
|
const apiVersion = options?.azureApiVersion || process.env.AZURE_OPENAI_API_VERSION || DEFAULT_AZURE_API_VERSION;
|
|
78
75
|
const baseUrl = options?.azureBaseUrl?.trim() || process.env.AZURE_OPENAI_BASE_URL?.trim() || void 0;
|
|
79
76
|
const resourceName = options?.azureResourceName || process.env.AZURE_OPENAI_RESOURCE_NAME;
|
|
80
|
-
|
|
81
|
-
if (!resolvedBaseUrl && resourceName) resolvedBaseUrl = buildDefaultBaseUrl(resourceName);
|
|
82
|
-
if (!resolvedBaseUrl && model.baseUrl) resolvedBaseUrl = model.baseUrl;
|
|
77
|
+
const resolvedBaseUrl = baseUrl || (resourceName ? `https://${resourceName}.openai.azure.com/openai/v1` : model.baseUrl);
|
|
83
78
|
if (!resolvedBaseUrl) throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");
|
|
84
79
|
return {
|
|
85
80
|
baseUrl: normalizeAzureBaseUrl(resolvedBaseUrl),
|
|
@@ -92,32 +87,26 @@ function createClient(model, apiKeyInput, options) {
|
|
|
92
87
|
const headers = { ...model.headers };
|
|
93
88
|
if (options?.headers) Object.assign(headers, options.headers);
|
|
94
89
|
const { baseUrl, apiVersion } = resolveAzureConfig(model, options);
|
|
95
|
-
const
|
|
96
|
-
...model,
|
|
97
|
-
baseUrl
|
|
98
|
-
});
|
|
99
|
-
if (isOpenAICompatibleAzureResponsesBaseUrl(baseUrl)) return new OpenAI({
|
|
90
|
+
const clientOptions = {
|
|
100
91
|
apiKey,
|
|
101
92
|
dangerouslyAllowBrowser: true,
|
|
102
93
|
defaultHeaders: headers,
|
|
103
94
|
baseURL: baseUrl,
|
|
104
|
-
fetch:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
apiKey,
|
|
109
|
-
apiVersion,
|
|
110
|
-
dangerouslyAllowBrowser: true,
|
|
111
|
-
defaultHeaders: headers,
|
|
112
|
-
baseURL: baseUrl,
|
|
113
|
-
fetch: guardedFetch,
|
|
95
|
+
fetch: getAiTransportHost().buildModelFetch({
|
|
96
|
+
...model,
|
|
97
|
+
baseUrl
|
|
98
|
+
}),
|
|
114
99
|
maxRetries: 0
|
|
100
|
+
};
|
|
101
|
+
return isOpenAICompatibleAzureResponsesBaseUrl(baseUrl) ? new OpenAI(clientOptions) : new AzureOpenAI({
|
|
102
|
+
...clientOptions,
|
|
103
|
+
apiVersion
|
|
115
104
|
});
|
|
116
105
|
}
|
|
117
106
|
function buildParams(model, context, options, deploymentName, replayMode = "checkpoint") {
|
|
118
107
|
const params = {
|
|
119
108
|
model: deploymentName,
|
|
120
|
-
input:
|
|
109
|
+
input: convertProviderResponsesMessages(model, context, AZURE_TOOL_CALL_PROVIDERS, {
|
|
121
110
|
sessionId: options?.sessionId,
|
|
122
111
|
authProfileId: options?.authProfileId,
|
|
123
112
|
replayMode
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
+
import { a as normalizeOptionalString } from "./string-coerce-fsri9iCu.mjs";
|
|
1
2
|
//#region packages/normalization-core/src/number-coercion.ts
|
|
2
3
|
/** Returns a number only when the input is already finite. */
|
|
3
4
|
function asFiniteNumber(value) {
|
|
4
|
-
return Number.isFinite(value) ? value : void 0;
|
|
5
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
5
6
|
}
|
|
6
7
|
/** Returns a finite number only when it is zero or greater. */
|
|
7
8
|
function asNonNegativeFiniteNumber(value) {
|
|
8
9
|
const number = asFiniteNumber(value);
|
|
9
10
|
return number && number < 0 ? void 0 : number;
|
|
10
11
|
}
|
|
11
|
-
function normalizeNumericString(value) {
|
|
12
|
-
const trimmed = value.trim();
|
|
13
|
-
return trimmed ? trimmed : void 0;
|
|
14
|
-
}
|
|
15
12
|
/** Parses only safe integer numbers or base-10 integer strings. */
|
|
16
13
|
function parseStrictInteger(value) {
|
|
17
14
|
if (typeof value === "number") return Number.isSafeInteger(value) ? value : void 0;
|
|
18
|
-
|
|
19
|
-
const normalized = normalizeNumericString(value);
|
|
15
|
+
const normalized = normalizeOptionalString(value);
|
|
20
16
|
if (!normalized || !/^[+-]?\d+$/.test(normalized)) return;
|
|
21
17
|
const parsed = Number(normalized);
|
|
22
18
|
return Number.isSafeInteger(parsed) ? parsed : void 0;
|
|
@@ -63,28 +59,32 @@ function estimateBase64DecodedBytes(base64) {
|
|
|
63
59
|
const estimated = Math.floor(effectiveLen * 3 / 4) - padding;
|
|
64
60
|
return Math.max(0, estimated);
|
|
65
61
|
}
|
|
66
|
-
function isBase64DataChar(code) {
|
|
67
|
-
return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 43 || code === 47;
|
|
68
|
-
}
|
|
69
62
|
function base64DataValue(code) {
|
|
70
63
|
if (code >= 65 && code <= 90) return code - 65;
|
|
71
64
|
if (code >= 97 && code <= 122) return code - 97 + 26;
|
|
72
65
|
if (code >= 48 && code <= 57) return code - 48 + 52;
|
|
73
|
-
return code === 43 ? 62 : 63;
|
|
66
|
+
return code === 43 ? 62 : code === 47 ? 63 : -1;
|
|
74
67
|
}
|
|
75
68
|
/**
|
|
76
69
|
* Normalizes and validates a base64 string, returning canonical no-whitespace
|
|
77
70
|
* base64 only when the input has valid alphabet, padding, and length.
|
|
78
71
|
*/
|
|
79
72
|
function canonicalizeBase64(base64) {
|
|
73
|
+
const facts = inspectBase64(base64, "canonical");
|
|
74
|
+
return facts?.canonicalPadBits ? facts.base64 : void 0;
|
|
75
|
+
}
|
|
76
|
+
/** One validating pass for the canonical and strict attachment dialects. */
|
|
77
|
+
function inspectBase64(base64, dialect) {
|
|
78
|
+
if (dialect === "attachment" && (base64.length === 0 || base64.length % 4 !== 0)) return;
|
|
80
79
|
let out;
|
|
81
80
|
let outLen = 0;
|
|
82
81
|
let padding = 0;
|
|
83
82
|
let sawPadding = false;
|
|
84
|
-
let
|
|
83
|
+
let lastDataValue = 0;
|
|
85
84
|
for (let i = 0; i < base64.length; i += 1) {
|
|
86
85
|
const code = base64.charCodeAt(i);
|
|
87
86
|
if (code <= 32) {
|
|
87
|
+
if (dialect === "attachment") return;
|
|
88
88
|
if (out === void 0) {
|
|
89
89
|
out = Buffer.allocUnsafe(base64.length - 1);
|
|
90
90
|
for (let j = 0; j < i; j += 1) out[j] = base64.charCodeAt(j);
|
|
@@ -96,8 +96,11 @@ function canonicalizeBase64(base64) {
|
|
|
96
96
|
padding += 1;
|
|
97
97
|
if (padding > 2) return;
|
|
98
98
|
sawPadding = true;
|
|
99
|
-
} else
|
|
100
|
-
|
|
99
|
+
} else {
|
|
100
|
+
const value = base64DataValue(code);
|
|
101
|
+
if (sawPadding || value < 0) return;
|
|
102
|
+
lastDataValue = value;
|
|
103
|
+
}
|
|
101
104
|
if (out !== void 0) {
|
|
102
105
|
out[outLen] = code;
|
|
103
106
|
outLen += 1;
|
|
@@ -109,9 +112,12 @@ function canonicalizeBase64(base64) {
|
|
|
109
112
|
if (remainder !== 0 && (sawPadding || remainder === 1)) return;
|
|
110
113
|
const effectivePadding = remainder === 0 ? padding : 4 - remainder;
|
|
111
114
|
const padBitMask = effectivePadding === 2 ? 15 : effectivePadding === 1 ? 3 : 0;
|
|
112
|
-
if (padBitMask !== 0 && (base64DataValue(lastDataCode) & padBitMask) !== 0) return;
|
|
113
115
|
const cleaned = out === void 0 ? base64 : out.subarray(0, outLen).toString("latin1");
|
|
114
|
-
return
|
|
116
|
+
return {
|
|
117
|
+
base64: remainder === 0 ? cleaned : cleaned + "=".repeat(4 - remainder),
|
|
118
|
+
decodedBytes: Math.floor(cleanedLength * 3 / 4) - padding,
|
|
119
|
+
canonicalPadBits: (lastDataValue & padBitMask) === 0
|
|
120
|
+
};
|
|
115
121
|
}
|
|
116
122
|
//#endregion
|
|
117
123
|
export { clampTimerTimeoutMs as a, asNonNegativeFiniteNumber as i, estimateBase64DecodedBytes as n, parseStrictPositiveInteger as o, asFiniteNumber as r, resolveTimerTimeoutMs as s, canonicalizeBase64 as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { a as isProviderRefusalAssistantError } from "./diagnostics-
|
|
1
|
+
import { a as isProviderRefusalAssistantError } from "./diagnostics-DzrF1h4J.mjs";
|
|
2
|
+
import { i as asOptionalRecord, o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
3
|
import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.mjs";
|
|
3
|
-
import "./provider-error-
|
|
4
|
-
import { r as asFiniteNumber } from "./base64-
|
|
4
|
+
import "./provider-error-CwT_j2v0.mjs";
|
|
5
|
+
import { r as asFiniteNumber } from "./base64-C1PsYcRQ.mjs";
|
|
5
6
|
//#region packages/normalization-core/src/error-coercion.ts
|
|
6
7
|
function readProperty(value, key) {
|
|
7
8
|
try {
|
|
@@ -70,6 +71,20 @@ function collectNestedErrorCandidates(err) {
|
|
|
70
71
|
});
|
|
71
72
|
}
|
|
72
73
|
//#endregion
|
|
74
|
+
//#region packages/normalization-core/src/json-coercion.ts
|
|
75
|
+
/** Parses JSON without throwing, returning undefined for invalid input. */
|
|
76
|
+
function safeParseJson(value) {
|
|
77
|
+
try {
|
|
78
|
+
return JSON.parse(value);
|
|
79
|
+
} catch {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Parses JSON into a non-array record, returning undefined for every other result. */
|
|
84
|
+
function safeParseJsonRecord(value) {
|
|
85
|
+
return /^[\t\n\r ]*\{/.test(value) ? asOptionalRecord(safeParseJson(value)) : void 0;
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
73
88
|
//#region packages/ai/src/providers/openai-responses-terminal-usage.ts
|
|
74
89
|
/**
|
|
75
90
|
* Canonical mapping for terminal OpenAI Responses events.
|
|
@@ -81,7 +96,7 @@ function collectNestedErrorCandidates(err) {
|
|
|
81
96
|
*/
|
|
82
97
|
/** A known output ceiling can resume sampling after admitted tools have settled. */
|
|
83
98
|
function isResponsesOutputLimitToolCallError(message) {
|
|
84
|
-
return message.stopReason === "error" && message.errorCode === "incomplete_tool_call" && !isProviderRefusalAssistantError(message) && message.diagnostics?.some(({ type, details }) => type === "openai_responses_terminal" && details?.eventType === "response.incomplete" && details.incompleteReason === "max_output_tokens") === true;
|
|
99
|
+
return message.stopReason === "error" && message.errorCode === "incomplete_tool_call" && !isProviderRefusalAssistantError(message) && message.diagnostics?.some(({ type, details }) => type === "openai_responses_terminal" && details?.eventType === "response.incomplete" && details.stopReason === "length" && details.incompleteReason === "max_output_tokens") === true;
|
|
85
100
|
}
|
|
86
101
|
function readReportedCount(value) {
|
|
87
102
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
@@ -154,6 +169,39 @@ function resolveResponsesTerminalStopReason(params) {
|
|
|
154
169
|
return { stopReason };
|
|
155
170
|
}
|
|
156
171
|
//#endregion
|
|
172
|
+
//#region packages/ai/src/transports/openai-responses-stream-errors.ts
|
|
173
|
+
const OUTPUT_IDENTITY_ERROR_CODE = "responses_output_identity_conflict";
|
|
174
|
+
function outputType(type) {
|
|
175
|
+
return type === "reasoning" || type === "message" || type === "function_call" || type === "compaction" ? type : "other";
|
|
176
|
+
}
|
|
177
|
+
function isResponsesProviderTool(item) {
|
|
178
|
+
return outputType(item.type) === "other";
|
|
179
|
+
}
|
|
180
|
+
/** Inspect the admitted request, including payload-hook changes and transport retries. */
|
|
181
|
+
function hasOnlyResponsesFunctionTools(request) {
|
|
182
|
+
return request !== void 0 && (request.tools === void 0 || Array.isArray(request.tools) && request.tools.every((tool) => isRecord(tool) && tool.type === "function"));
|
|
183
|
+
}
|
|
184
|
+
var ResponsesOutputIdentityError = class extends Error {
|
|
185
|
+
constructor(details) {
|
|
186
|
+
super("Responses stream changed output item identity");
|
|
187
|
+
this.code = OUTPUT_IDENTITY_ERROR_CODE;
|
|
188
|
+
this.name = "ResponsesOutputIdentityError";
|
|
189
|
+
this.errorBody = JSON.stringify({
|
|
190
|
+
...details,
|
|
191
|
+
expectedType: outputType(details.expectedType),
|
|
192
|
+
actualType: outputType(details.actualType),
|
|
193
|
+
mismatch: details.expectedType !== details.actualType ? "type" : "call_id",
|
|
194
|
+
eventType: details.eventType === "response.output_item.added" || details.eventType === "response.output_item.done" || details.eventType === "response.completed" || details.eventType === "response.incomplete" ? details.eventType : "unknown",
|
|
195
|
+
retrySafe: details.retrySafe && !details.completedToolCall
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
/** Resume only a response that could not have completed tools or exposed visible output. */
|
|
200
|
+
function resolveResponsesOutputIdentityRetry(message) {
|
|
201
|
+
if (message.errorCode !== OUTPUT_IDENTITY_ERROR_CODE) return;
|
|
202
|
+
return message.stopReason === "error" && message.content?.every((block) => block.type === "thinking" || block.type === "text" && block.text.length === 0) === true && safeParseJsonRecord(message.errorBody ?? "")?.retrySafe === true ? "retry" : "stop";
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
157
205
|
//#region packages/ai/src/utils/retryable-network-errors.ts
|
|
158
206
|
const WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE = "ERR_WEBSOCKET_NON_RETRYABLE_CLOSE";
|
|
159
207
|
const TRANSIENT_NETWORK_CODES = /* @__PURE__ */ new Set([
|
|
@@ -260,12 +308,9 @@ function resolveModelSseDebugMode(env = process.env) {
|
|
|
260
308
|
function isModelTransportDebugEnabled(env = process.env) {
|
|
261
309
|
return isTruthyEnv(env.OPENCLAW_DEBUG_MODEL_TRANSPORT) || resolveModelPayloadDebugMode(env) !== "off" || resolveModelSseDebugMode(env) !== "off" || isTruthyEnv(env.OPENCLAW_DEBUG_CODE_MODE);
|
|
262
310
|
}
|
|
263
|
-
|
|
264
|
-
return message.startsWith("[model-fetch]");
|
|
265
|
-
}
|
|
266
|
-
/** Emits model-fetch metadata at info level by default; other diagnostics require debug env. */
|
|
311
|
+
/** Emits transport diagnostics at debug, promoted to info by explicit debug flags. */
|
|
267
312
|
function emitModelTransportDebug(log, message) {
|
|
268
|
-
if (
|
|
313
|
+
if (isModelTransportDebugEnabled()) {
|
|
269
314
|
log.info(message);
|
|
270
315
|
return;
|
|
271
316
|
}
|
|
@@ -295,4 +340,4 @@ function formatModelTransportDebugBaseUrl(rawUrl) {
|
|
|
295
340
|
return rawUrl ? formatModelTransportDebugUrl(rawUrl) : "default";
|
|
296
341
|
}
|
|
297
342
|
//#endregion
|
|
298
|
-
export { resolveModelSseDebugMode as a, isTransientNetworkError as c,
|
|
343
|
+
export { extractErrorCodeOrErrno as _, resolveModelSseDebugMode as a, isTransientNetworkError as c, isResponsesProviderTool as d, resolveResponsesOutputIdentityRetry as f, resolveResponsesTerminalStopReason as g, readResponsesReasoningTokens as h, resolveModelPayloadDebugMode as i, ResponsesOutputIdentityError as l, mapResponsesTerminalUsage as m, formatModelTransportDebugUrl as n, WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE as o, isResponsesOutputLimitToolCallError as p, emitModelTransportDebug as r, hasRetryableConnectionErrorCode as s, formatModelTransportDebugBaseUrl as t, hasOnlyResponsesFunctionTools as u, toErrorObject as v };
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
import { Guard } from "typebox/guard";
|
|
2
|
+
//#region packages/llm-core/src/utils/provider-refusal.ts
|
|
3
|
+
const encoder = new TextEncoder();
|
|
4
|
+
function isBoundedText(value, maxBytes) {
|
|
5
|
+
return typeof value === "string" && value.length <= maxBytes && value.trim().length > 0 && encoder.encode(value).byteLength <= maxBytes;
|
|
6
|
+
}
|
|
7
|
+
/** Keep exact provider text. Truncation must never make an invalid continuation usable. */
|
|
8
|
+
function readProviderRefusalReview(value) {
|
|
9
|
+
if (!Guard.IsObjectNotArray(value) || !isBoundedText(value.explanation, 65536)) return;
|
|
10
|
+
const continuation = Guard.IsObjectNotArray(value.continuation) ? value.continuation.message : void 0;
|
|
11
|
+
return {
|
|
12
|
+
explanation: value.explanation,
|
|
13
|
+
...isBoundedText(continuation, 1024) ? { continuation: { message: continuation } } : {},
|
|
14
|
+
...typeof value.errorType === "string" && value.errorType.trim() ? { errorType: value.errorType } : {}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
1
18
|
//#region packages/llm-core/src/utils/diagnostics.ts
|
|
2
19
|
/** True when the provider explicitly refused the request payload. */
|
|
3
20
|
function isProviderRefusalAssistantError(message) {
|
|
@@ -37,4 +54,4 @@ function appendAssistantMessageDiagnostic(message, diagnostic) {
|
|
|
37
54
|
message.diagnostics = [...message.diagnostics ?? [], diagnostic];
|
|
38
55
|
}
|
|
39
56
|
//#endregion
|
|
40
|
-
export { isProviderRefusalAssistantError as a, formatThrownValue as i, createAssistantMessageDiagnostic as n, extractDiagnosticError as r, appendAssistantMessageDiagnostic as t };
|
|
57
|
+
export { isProviderRefusalAssistantError as a, formatThrownValue as i, createAssistantMessageDiagnostic as n, readProviderRefusalReview as o, extractDiagnosticError as r, appendAssistantMessageDiagnostic as t };
|
package/dist/diagnostics.d.mts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { a as ProviderRefusalReview, o as readProviderRefusalReview } from "./index-D6KsSE74.mjs";
|
|
2
|
+
import { a as AssistantMessage, dt as DiagnosticErrorInfo, ft as appendAssistantMessageDiagnostic, gt as isProviderRefusalAssistantError, ht as formatThrownValue, mt as extractDiagnosticError, pt as createAssistantMessageDiagnostic, ut as AssistantMessageDiagnostic } from "./types-CLLR3eB4.mjs";
|
|
3
|
+
import "./types-CB-_vNyI.mjs";
|
|
4
|
+
import { n as isResponsesOutputLimitToolCallError } from "./openai-responses-terminal-usage-BE7lf7nW.mjs";
|
|
5
|
+
import { n as ProviderErrorRedactor, r as configureProviderErrorRedactor } from "./provider-error-xumb1V3F.mjs";
|
|
4
6
|
import { r as projectDiagnosticValue, t as DiagnosticProjectionPolicy } from "./credential-redaction-BKv49aiv.mjs";
|
|
5
|
-
import { n as formatModelTransportDebugUrl, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./model-transport-url-
|
|
7
|
+
import { n as formatModelTransportDebugUrl, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./model-transport-url-C5f59L3Y.mjs";
|
|
8
|
+
//#region packages/ai/src/transports/openai-responses-stream-errors.d.ts
|
|
9
|
+
/** Resume only a response that could not have completed tools or exposed visible output. */
|
|
10
|
+
export declare function resolveResponsesOutputIdentityRetry(message: Pick<AssistantMessage, "errorCode"> & Partial<Pick<AssistantMessage, "stopReason" | "errorBody" | "content">>): "retry" | "stop" | undefined;
|
|
11
|
+
//#endregion
|
|
6
12
|
//#region packages/ai/src/utils/retryable-network-errors.d.ts
|
|
7
13
|
export declare const WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE = "ERR_WEBSOCKET_NON_RETRYABLE_CLOSE";
|
|
8
14
|
export declare function hasRetryableConnectionErrorCode(message: string): boolean;
|
|
9
15
|
/** Returns true when any nested error proves a transient network failure. */
|
|
10
16
|
export declare function isTransientNetworkError(err: unknown): boolean;
|
|
11
17
|
//#endregion
|
|
12
|
-
export { AssistantMessageDiagnostic, DiagnosticErrorInfo, type DiagnosticProjectionPolicy, type ProviderErrorRedactor, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, emitModelTransportDebug, extractDiagnosticError, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, formatThrownValue, isProviderRefusalAssistantError, isResponsesOutputLimitToolCallError, projectDiagnosticValue };
|
|
18
|
+
export { AssistantMessageDiagnostic, DiagnosticErrorInfo, type DiagnosticProjectionPolicy, type ProviderErrorRedactor, type ProviderRefusalReview, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, emitModelTransportDebug, extractDiagnosticError, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, formatThrownValue, isProviderRefusalAssistantError, isResponsesOutputLimitToolCallError, projectDiagnosticValue, readProviderRefusalReview };
|
package/dist/diagnostics.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isProviderRefusalAssistantError, i as formatThrownValue, n as createAssistantMessageDiagnostic, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-
|
|
2
|
-
import { i as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-
|
|
3
|
-
import { c as isTransientNetworkError,
|
|
4
|
-
export { WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, emitModelTransportDebug, extractDiagnosticError, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, formatThrownValue, hasRetryableConnectionErrorCode, isProviderRefusalAssistantError, isResponsesOutputLimitToolCallError, isTransientNetworkError, projectDiagnosticValue };
|
|
1
|
+
import { a as isProviderRefusalAssistantError, i as formatThrownValue, n as createAssistantMessageDiagnostic, o as readProviderRefusalReview, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
|
|
2
|
+
import { i as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-CwT_j2v0.mjs";
|
|
3
|
+
import { c as isTransientNetworkError, f as resolveResponsesOutputIdentityRetry, n as formatModelTransportDebugUrl, o as WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, p as isResponsesOutputLimitToolCallError, r as emitModelTransportDebug, s as hasRetryableConnectionErrorCode, t as formatModelTransportDebugBaseUrl } from "./diagnostics-CJaB6g8J.mjs";
|
|
4
|
+
export { WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, emitModelTransportDebug, extractDiagnosticError, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, formatThrownValue, hasRetryableConnectionErrorCode, isProviderRefusalAssistantError, isResponsesOutputLimitToolCallError, isTransientNetworkError, projectDiagnosticValue, readProviderRefusalReview, resolveResponsesOutputIdentityRetry };
|
|
@@ -88,16 +88,18 @@ function hasVertexAdcCredentials() {
|
|
|
88
88
|
return cachedVertexAdcCredentialsExists === true;
|
|
89
89
|
}
|
|
90
90
|
function getApiKeyEnvVars(provider) {
|
|
91
|
-
if (provider === "github-copilot") return ["COPILOT_GITHUB_TOKEN"];
|
|
92
|
-
if (provider === "anthropic") return ["ANTHROPIC_OAUTH_TOKEN", "ANTHROPIC_API_KEY"];
|
|
93
|
-
if (provider === "moonshot") return ["MOONSHOT_API_KEY", "KIMI_API_KEY"];
|
|
94
|
-
if (provider === "kimi" || provider === "kimi-coding") return ["KIMI_API_KEY", "KIMICODE_API_KEY"];
|
|
95
91
|
const envVar = {
|
|
92
|
+
"github-copilot": "COPILOT_GITHUB_TOKEN",
|
|
93
|
+
anthropic: ["ANTHROPIC_OAUTH_TOKEN", "ANTHROPIC_API_KEY"],
|
|
94
|
+
moonshot: ["MOONSHOT_API_KEY", "KIMI_API_KEY"],
|
|
95
|
+
kimi: ["KIMI_API_KEY", "KIMICODE_API_KEY"],
|
|
96
|
+
"kimi-coding": ["KIMI_API_KEY", "KIMICODE_API_KEY"],
|
|
96
97
|
openai: "OPENAI_API_KEY",
|
|
97
98
|
meta: "MODEL_API_KEY",
|
|
98
99
|
"azure-openai-responses": "AZURE_OPENAI_API_KEY",
|
|
99
100
|
deepseek: "DEEPSEEK_API_KEY",
|
|
100
101
|
google: "GEMINI_API_KEY",
|
|
102
|
+
"google-interactions": "GEMINI_API_KEY",
|
|
101
103
|
"google-vertex": "GOOGLE_CLOUD_API_KEY",
|
|
102
104
|
groq: "GROQ_API_KEY",
|
|
103
105
|
cerebras: "CEREBRAS_API_KEY",
|
|
@@ -122,7 +124,7 @@ function getApiKeyEnvVars(provider) {
|
|
|
122
124
|
"xiaomi-token-plan-ams": "XIAOMI_TOKEN_PLAN_AMS_API_KEY",
|
|
123
125
|
"xiaomi-token-plan-sgp": "XIAOMI_TOKEN_PLAN_SGP_API_KEY"
|
|
124
126
|
}[provider];
|
|
125
|
-
return envVar ? [envVar] : void 0;
|
|
127
|
+
return Array.isArray(envVar) ? envVar : envVar ? [envVar] : void 0;
|
|
126
128
|
}
|
|
127
129
|
/**
|
|
128
130
|
* Find configured environment variables that can provide an API key for a provider.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./event-stream-DOPFYVqs.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as ThinkingContent, a as AssistantMessage, o as AssistantMessageEvent, s as AssistantMessageEventStreamContract } from "./types-
|
|
1
|
+
import { $ as ThinkingContent, a as AssistantMessage, o as AssistantMessageEvent, s as AssistantMessageEventStreamContract } from "./types-CLLR3eB4.mjs";
|
|
2
2
|
//#region packages/llm-core/src/utils/event-stream.d.ts
|
|
3
3
|
/** Returns only an append whose current and previously observed snapshots still match. */
|
|
4
4
|
declare function readAssistantThinkingAppend(block: ThinkingContent, previous: string): string | undefined;
|
|
@@ -6,7 +6,7 @@ declare function readAssistantThinkingAppend(block: ThinkingContent, previous: s
|
|
|
6
6
|
declare function getEventStreamCompletion(stream: object): Promise<unknown> | undefined;
|
|
7
7
|
/** Generic async-iterable event stream with a separately awaited final result. */
|
|
8
8
|
declare class EventStream<T, R = T> implements AsyncIterable<T> {
|
|
9
|
-
|
|
9
|
+
protected queue: (T | undefined)[];
|
|
10
10
|
private queueHead;
|
|
11
11
|
private waiting;
|
|
12
12
|
protected done: boolean;
|
|
@@ -95,6 +95,16 @@ var EventStream = class {
|
|
|
95
95
|
/** Assistant-message event stream that resolves on done/error terminal events. */
|
|
96
96
|
var AssistantMessageEventStream = class extends EventStream {
|
|
97
97
|
push(event) {
|
|
98
|
+
if (!this.done && event.type === "text_delta" && !event.partial) {
|
|
99
|
+
const previous = this.queue[this.queue.length - 1];
|
|
100
|
+
if (previous?.type === "text_delta" && !previous.partial && previous.contentIndex === event.contentIndex) {
|
|
101
|
+
this.queue[this.queue.length - 1] = {
|
|
102
|
+
...event,
|
|
103
|
+
delta: previous.delta + event.delta
|
|
104
|
+
};
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
98
108
|
if (event.type === "thinking_delta" || event.type === "thinking_end") {
|
|
99
109
|
const block = event.partial.content[event.contentIndex];
|
|
100
110
|
if (block?.type === "thinking") {
|
package/dist/event-stream.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
2
|
-
import "./event-stream-
|
|
1
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-DOPFYVqs.mjs";
|
|
2
|
+
import "./event-stream-CMQfX_yr.mjs";
|
|
3
3
|
export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
|
package/dist/event-stream.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as createAssistantMessageEventStream, n as EventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
1
|
+
import { i as createAssistantMessageEventStream, n as EventStream, t as AssistantMessageEventStream } from "./event-stream-vd9UnCAU.mjs";
|
|
2
2
|
export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
2
|
-
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { t as AssistantMessageEventStream } from "./event-stream-vd9UnCAU.mjs";
|
|
2
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-CHi3X87F.mjs";
|
|
3
|
+
import { f as mergeTransportHeaders } from "./transport-stream-shared-Dh5qKJ8e.mjs";
|
|
4
|
+
import { n as buildBaseOptions } from "./simple-options-CGAkCwtM.mjs";
|
|
5
|
+
import { n as getEnvApiKey } from "./env-api-keys-CyX4VKGO.mjs";
|
|
6
|
+
import { n as createAssistantOutput } from "./provider-transcript-transform-JbFbHV8h.mjs";
|
|
7
7
|
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-Bcunsn4I.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-Y2YfotEu.mjs";
|
|
9
9
|
import { GoogleGenAI } from "@google/genai";
|
|
10
10
|
//#region packages/ai/src/providers/google.ts
|
|
11
11
|
let toolCallCounter = 0;
|
|
@@ -20,7 +20,7 @@ const streamGoogle = (model, context, options) => {
|
|
|
20
20
|
createClient: () => {
|
|
21
21
|
return createClient(model, options?.apiKey || getEnvApiKey(model.provider) || "", resolveOpencodeSessionHeaders(model, options));
|
|
22
22
|
},
|
|
23
|
-
buildParams: () =>
|
|
23
|
+
buildParams: () => buildGoogleGenerateContentParams(model, context, options),
|
|
24
24
|
nextToolCallId: (name) => `${name}_${Date.now()}_${++toolCallCounter}`
|
|
25
25
|
});
|
|
26
26
|
return stream;
|
|
@@ -47,8 +47,5 @@ function createClient(model, apiKey, optionsHeaders) {
|
|
|
47
47
|
httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : void 0
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
function buildParams(model, context, options = {}) {
|
|
51
|
-
return buildGoogleGenerateContentParams(model, context, options);
|
|
52
|
-
}
|
|
53
50
|
//#endregion
|
|
54
51
|
export { streamGoogle, streamSimpleGoogle };
|