@openclaw/ai 2026.7.2-beta.3 → 2026.7.2-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/{anthropic-D7SyZQ5v.mjs → anthropic-CQVj3le6.mjs} +174 -33
- package/dist/{index-BoTnz8cv.d.mts → anthropic-SrGtwsJu.d.mts} +27 -1
- package/dist/{api-registry-DXBIXISf.d.mts → api-registry-DlMgPR39.d.mts} +1 -2
- package/dist/{azure-openai-responses-BkZgyZ3I.mjs → azure-openai-responses-DIYgsqFM.mjs} +7 -11
- package/dist/{env-api-keys-DnhYpc27.mjs → env-api-keys-DrgeBuva.mjs} +1 -1
- package/dist/error-coercion-DgxlWC0n.mjs +15 -0
- package/dist/{event-stream-BPemFrFW.d.mts → event-stream-YjaPW20U.d.mts} +1 -1
- package/dist/event-stream.d.mts +1 -1
- package/dist/{tool-schema-json-projection-BwNu3nDi.mjs → github-copilot-headers-BCoBNmL7.mjs} +48 -1
- package/dist/{google-C_biGbV7.mjs → google-f-A8xrae.mjs} +4 -4
- package/dist/{google-shared-BK-NoHl8.mjs → google-shared-J6qvYINH.mjs} +5 -4
- package/dist/{google-vertex-CvdzF1U7.mjs → google-vertex-D3yMVXIY.mjs} +3 -3
- package/dist/host-B9GUmcra.d.mts +173 -0
- package/dist/host-XYGZcgO8.mjs +98 -0
- package/dist/index-BVVgDSdq.d.mts +1 -0
- package/dist/index.d.mts +7 -50
- package/dist/index.mjs +3 -3
- package/dist/internal/anthropic.d.mts +15 -11
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/openai.d.mts +3 -280
- package/dist/internal/openai.mjs +5 -7
- package/dist/internal/runtime.d.mts +13 -34
- package/dist/internal/runtime.mjs +19 -11
- package/dist/internal/shared.d.mts +13 -8
- package/dist/internal/shared.mjs +2 -2
- package/dist/{mistral-BdrQmDWp.mjs → mistral-CKV-TOQj.mjs} +7 -6
- package/dist/number-coercion-DvG7SNMg.mjs +129 -0
- package/dist/openai-BPor_3WI.d.mts +358 -0
- package/dist/{openai-responses-shared-CwnGU0KW.mjs → openai-D3PD6PE-.mjs} +1890 -705
- package/dist/{openai-chatgpt-responses-DP63Qt01.mjs → openai-chatgpt-responses-CedIj0hk.mjs} +54 -58
- package/dist/{openai-completions-zLDfebnN.mjs → openai-completions-CiSutyu0.mjs} +459 -104
- package/dist/openai-prompt-cache-2uo_1OR1.d.mts +7 -0
- package/dist/openai-prompt-cache-mZTCdRPo.mjs +12 -0
- package/dist/prompt-cache-stability-Cwcjv_fx.d.mts +13 -0
- package/dist/{provider-error-LMfTEkfO.mjs → provider-error-apVOZI6G.mjs} +9 -2
- package/dist/providers.d.mts +3 -2
- package/dist/providers.mjs +10 -9
- package/dist/{transform-messages-eb6lxDLB.mjs → shared-CdjNZd35.mjs} +273 -161
- package/dist/{src-CXno1H5g.mjs → src-QkygScBs.mjs} +23 -4
- package/dist/stream-first-event-timeout-C3OgBjIk.mjs +12294 -0
- package/dist/stream-first-event-timeout-DvDeSucC.d.mts +29 -0
- package/dist/transport-stream-shared-BbMELSI4.mjs +297 -0
- package/dist/transports.d.mts +593 -0
- package/dist/transports.mjs +4069 -0
- package/dist/{types-CYORveZ7.d.mts → types-bzp5k29J.d.mts} +8 -0
- package/dist/types.d.mts +5 -5
- package/dist/types.mjs +2 -2
- package/dist/{validation-BX8euiDv.d.mts → validation-B-j7cOYp.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/package.json +36 -11
- package/dist/azure-openai-responses-client-compat-C7K7QfUE.mjs +0 -62
- package/dist/github-copilot-headers-BsH5cqGj.mjs +0 -48
- package/dist/host-4t713IeR.mjs +0 -37
- package/dist/model-utils-1GiZ2_rr.mjs +0 -64
- package/dist/openai-responses-ClspWt4I.mjs +0 -136
- package/dist/openai-tool-projection-WHf2nuOI.mjs +0 -200
- package/dist/reasoning-tag-text-partitioner-BlVe67g6.mjs +0 -400
- package/dist/stream-first-event-timeout-RjWszj8c.mjs +0 -106
- package/npm-shrinkwrap.json +0 -645
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region packages/ai/src/utils/stream-first-event-timeout.d.ts
|
|
2
|
+
type StreamStage = "responses" | "completions";
|
|
3
|
+
type FirstStreamEventTimeoutContext = {
|
|
4
|
+
provider?: string;
|
|
5
|
+
api?: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
timeoutMs: number;
|
|
8
|
+
stage?: StreamStage;
|
|
9
|
+
hint?: string;
|
|
10
|
+
abort?: (reason: Error) => void;
|
|
11
|
+
onTimeout?: (reason: Error) => void;
|
|
12
|
+
};
|
|
13
|
+
type FirstStreamEventInternalOptions = {
|
|
14
|
+
firstEventTimeoutMs?: number;
|
|
15
|
+
abortFirstEventStream?: (reason: Error) => void;
|
|
16
|
+
onFirstEventTimeout?: (reason: Error) => void;
|
|
17
|
+
};
|
|
18
|
+
type FirstStreamEventAbortController = {
|
|
19
|
+
signal: AbortSignal;
|
|
20
|
+
abort: (reason: Error) => void;
|
|
21
|
+
dispose: () => void;
|
|
22
|
+
};
|
|
23
|
+
declare function getFirstStreamEventTimeoutMs(options: unknown): number | undefined;
|
|
24
|
+
declare function getFirstStreamEventTimeoutHandler(options: unknown): ((reason: Error) => void) | undefined;
|
|
25
|
+
declare function createFirstStreamEventTimeoutError(context: FirstStreamEventTimeoutContext): Error;
|
|
26
|
+
declare function createFirstStreamEventAbortController(parentSignal?: AbortSignal): FirstStreamEventAbortController;
|
|
27
|
+
declare function withFirstStreamEventTimeout<T>(stream: AsyncIterable<T>, context: FirstStreamEventTimeoutContext): AsyncIterable<T>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { createFirstStreamEventTimeoutError as a, withFirstStreamEventTimeout as c, createFirstStreamEventAbortController as i, FirstStreamEventInternalOptions as n, getFirstStreamEventTimeoutHandler as o, FirstStreamEventTimeoutContext as r, getFirstStreamEventTimeoutMs as s, FirstStreamEventAbortController as t };
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { r as createAssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
|
|
2
|
+
import { n as getAiTransportHost } from "./host-XYGZcgO8.mjs";
|
|
3
|
+
import { D as truncateUtf16Safe, b as normalizeOptionalString } from "./shared-CdjNZd35.mjs";
|
|
4
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-DT5o51ur.mjs";
|
|
5
|
+
import { i as parseStrictNonNegativeInteger, r as parseStrictFiniteNumber, t as asFiniteNumberInRange } from "./number-coercion-DvG7SNMg.mjs";
|
|
6
|
+
import { parseRetryAfterHttpDateMs } from "./internal/retry-after.mjs";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
//#region packages/ai/src/transports/transport-utils.ts
|
|
9
|
+
const MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE = "OpenClaw transport error: malformed_streaming_fragment";
|
|
10
|
+
const NON_LATIN_RE = /[\u2E80-\u9FFF\uA000-\uA4FF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFF60\uFFE0-\uFFE6\u{20000}-\u{2FA1F}]/gu;
|
|
11
|
+
const CJK_SURROGATE_HIGH_RE = /[\uD840-\uD87E][\uDC00-\uDFFF]/g;
|
|
12
|
+
function sha256Hex(value) {
|
|
13
|
+
return createHash("sha256").update(value).digest("hex");
|
|
14
|
+
}
|
|
15
|
+
function sha256HexPrefix(value, length) {
|
|
16
|
+
return sha256Hex(value).slice(0, length);
|
|
17
|
+
}
|
|
18
|
+
function redactIdentifier(value, opts) {
|
|
19
|
+
const trimmed = normalizeOptionalString(value);
|
|
20
|
+
if (!trimmed) return "-";
|
|
21
|
+
return `sha256:${sha256HexPrefix(trimmed, Number.isFinite(opts?.len) ? Math.max(1, Math.floor(opts?.len ?? 12)) : 12)}`;
|
|
22
|
+
}
|
|
23
|
+
function redactSensitiveText(text, _options) {
|
|
24
|
+
return getAiTransportHost().redactToolPayloadText(text);
|
|
25
|
+
}
|
|
26
|
+
function resolveSecretSentinel(value) {
|
|
27
|
+
return getAiTransportHost().resolveSecretSentinel(value);
|
|
28
|
+
}
|
|
29
|
+
function resolveModelHeaderSentinels(model) {
|
|
30
|
+
if (!model.headers) return model;
|
|
31
|
+
let headers;
|
|
32
|
+
for (const [name, value] of Object.entries(model.headers)) {
|
|
33
|
+
const resolved = resolveSecretSentinel(value);
|
|
34
|
+
if (resolved !== value) {
|
|
35
|
+
headers ??= { ...model.headers };
|
|
36
|
+
headers[name] = resolved;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return headers ? {
|
|
40
|
+
...model,
|
|
41
|
+
headers
|
|
42
|
+
} : model;
|
|
43
|
+
}
|
|
44
|
+
function createAbortError(message, options) {
|
|
45
|
+
const error = new Error(message, options);
|
|
46
|
+
error.name = "AbortError";
|
|
47
|
+
return error;
|
|
48
|
+
}
|
|
49
|
+
function estimateStringChars(text) {
|
|
50
|
+
if (!text) return 0;
|
|
51
|
+
const nonLatinCount = (text.match(NON_LATIN_RE) ?? []).length;
|
|
52
|
+
return (nonLatinCount === 0 ? text.length : text.length - (text.match(CJK_SURROGATE_HIGH_RE) ?? []).length) + nonLatinCount * 3;
|
|
53
|
+
}
|
|
54
|
+
function supportsModelTools(model) {
|
|
55
|
+
return (model.compat && typeof model.compat === "object" ? model.compat : void 0)?.supportsTools !== false;
|
|
56
|
+
}
|
|
57
|
+
function isCodeModeModelVisibleToolName(name) {
|
|
58
|
+
return name === "exec" || name === "wait" || name === "computer" || name === "image" || name === "message";
|
|
59
|
+
}
|
|
60
|
+
function isGoogleGemini3Model(modelId, family) {
|
|
61
|
+
const normalized = modelId.trim().toLowerCase();
|
|
62
|
+
const suffix = family === "pro" ? "pro" : "flash";
|
|
63
|
+
return new RegExp(`(?:^|/)gemini-(?:3(?:\\.\\d+)?-${suffix}|${suffix}${family === "flash" ? "(?:-lite)?" : ""}-latest)(?:-|$)`).test(normalized);
|
|
64
|
+
}
|
|
65
|
+
function isGoogleGemini3ProModel(modelId) {
|
|
66
|
+
return isGoogleGemini3Model(modelId, "pro");
|
|
67
|
+
}
|
|
68
|
+
function isGoogleGemini3FlashModel(modelId) {
|
|
69
|
+
return isGoogleGemini3Model(modelId, "flash");
|
|
70
|
+
}
|
|
71
|
+
function parseRetryAfterSeconds(headers) {
|
|
72
|
+
const retryAfterMs = headers.get("retry-after-ms");
|
|
73
|
+
if (retryAfterMs) {
|
|
74
|
+
const trimmed = retryAfterMs.trim();
|
|
75
|
+
if (/^\d+(?:\.\d+)?$/.test(trimmed)) {
|
|
76
|
+
const milliseconds = asFiniteNumberInRange(parseStrictFiniteNumber(trimmed), {
|
|
77
|
+
min: 0,
|
|
78
|
+
max: Number.MAX_SAFE_INTEGER
|
|
79
|
+
});
|
|
80
|
+
return milliseconds === void 0 ? Number.POSITIVE_INFINITY : milliseconds / 1e3;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const retryAfter = headers.get("retry-after")?.trim();
|
|
84
|
+
if (!retryAfter) return;
|
|
85
|
+
if (/^\d+$/.test(retryAfter)) return parseStrictNonNegativeInteger(retryAfter) ?? Number.POSITIVE_INFINITY;
|
|
86
|
+
const retryAt = parseRetryAfterHttpDateMs(retryAfter);
|
|
87
|
+
return retryAt === void 0 ? void 0 : Math.max(0, (retryAt - Date.now()) / 1e3);
|
|
88
|
+
}
|
|
89
|
+
async function readChunkWithIdleTimeout(reader, timeoutMs, onIdleTimeout) {
|
|
90
|
+
let timer;
|
|
91
|
+
try {
|
|
92
|
+
return await Promise.race([reader.read(), new Promise((_resolve, reject) => {
|
|
93
|
+
timer = setTimeout(() => reject(onIdleTimeout?.({ chunkTimeoutMs: timeoutMs }) ?? /* @__PURE__ */ new Error("Read timed out")), timeoutMs);
|
|
94
|
+
})]);
|
|
95
|
+
} finally {
|
|
96
|
+
if (timer) clearTimeout(timer);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async function readResponseTextSnippet(response, options) {
|
|
100
|
+
const maxBytes = options?.maxBytes ?? 8 * 1024;
|
|
101
|
+
const maxChars = options?.maxChars ?? 200;
|
|
102
|
+
const reader = response.body?.getReader();
|
|
103
|
+
if (!reader) return;
|
|
104
|
+
const chunks = [];
|
|
105
|
+
let bytes = 0;
|
|
106
|
+
let truncated = false;
|
|
107
|
+
try {
|
|
108
|
+
while (bytes < maxBytes) {
|
|
109
|
+
const result = options?.chunkTimeoutMs ? await readChunkWithIdleTimeout(reader, options.chunkTimeoutMs, options.onIdleTimeout) : await reader.read();
|
|
110
|
+
if (result.done) break;
|
|
111
|
+
if (!result.value?.length) continue;
|
|
112
|
+
const remaining = maxBytes - bytes;
|
|
113
|
+
chunks.push(result.value.subarray(0, remaining));
|
|
114
|
+
bytes += Math.min(result.value.length, remaining);
|
|
115
|
+
if (result.value.length >= remaining) {
|
|
116
|
+
truncated = true;
|
|
117
|
+
await reader.cancel().catch(() => void 0);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
} catch (error) {
|
|
122
|
+
await reader.cancel(error).catch(() => void 0);
|
|
123
|
+
throw error;
|
|
124
|
+
} finally {
|
|
125
|
+
reader.releaseLock();
|
|
126
|
+
}
|
|
127
|
+
const merged = new Uint8Array(bytes);
|
|
128
|
+
let offset = 0;
|
|
129
|
+
for (const chunk of chunks) {
|
|
130
|
+
merged.set(chunk, offset);
|
|
131
|
+
offset += chunk.length;
|
|
132
|
+
}
|
|
133
|
+
const collapsed = new TextDecoder().decode(merged).replace(/\s+/g, " ").trim();
|
|
134
|
+
if (!collapsed) return;
|
|
135
|
+
if (collapsed.length > maxChars) return `${truncateUtf16Safe(collapsed, maxChars)}…`;
|
|
136
|
+
return truncated ? `${collapsed}…` : collapsed;
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region packages/ai/src/transports/transport-stream-shared.ts
|
|
140
|
+
const EMPTY_TOOL_RESULT_TEXT = "(no output)";
|
|
141
|
+
function sanitizeTransportPayloadText(text) {
|
|
142
|
+
if (typeof text !== "string") return "";
|
|
143
|
+
return sanitizeSurrogates(text);
|
|
144
|
+
}
|
|
145
|
+
function sanitizeNonEmptyTransportPayloadText(text, fallback = EMPTY_TOOL_RESULT_TEXT) {
|
|
146
|
+
const sanitized = sanitizeTransportPayloadText(text);
|
|
147
|
+
return sanitized.trim().length > 0 ? sanitized : fallback;
|
|
148
|
+
}
|
|
149
|
+
function coerceTransportToolCallArguments(argumentsValue) {
|
|
150
|
+
if (argumentsValue && typeof argumentsValue === "object" && !Array.isArray(argumentsValue)) return argumentsValue;
|
|
151
|
+
if (typeof argumentsValue === "string") try {
|
|
152
|
+
const parsed = JSON.parse(argumentsValue);
|
|
153
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
|
|
154
|
+
} catch {}
|
|
155
|
+
return {};
|
|
156
|
+
}
|
|
157
|
+
function mergeTransportHeaders(...headerSources) {
|
|
158
|
+
const merged = {};
|
|
159
|
+
for (const headers of headerSources) if (headers) Object.assign(merged, headers);
|
|
160
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
161
|
+
}
|
|
162
|
+
function mergeTransportMetadata(payload, metadata) {
|
|
163
|
+
if (!metadata || Object.keys(metadata).length === 0) return payload;
|
|
164
|
+
const existingMetadata = payload.metadata && typeof payload.metadata === "object" && !Array.isArray(payload.metadata) ? payload.metadata : void 0;
|
|
165
|
+
return {
|
|
166
|
+
...payload,
|
|
167
|
+
metadata: {
|
|
168
|
+
...existingMetadata,
|
|
169
|
+
...metadata
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function createEmptyTransportUsage() {
|
|
174
|
+
return {
|
|
175
|
+
input: 0,
|
|
176
|
+
output: 0,
|
|
177
|
+
cacheRead: 0,
|
|
178
|
+
cacheWrite: 0,
|
|
179
|
+
totalTokens: 0,
|
|
180
|
+
cost: {
|
|
181
|
+
input: 0,
|
|
182
|
+
output: 0,
|
|
183
|
+
cacheRead: 0,
|
|
184
|
+
cacheWrite: 0,
|
|
185
|
+
total: 0
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function createWritableTransportEventStream() {
|
|
190
|
+
const eventStream = createAssistantMessageEventStream();
|
|
191
|
+
return {
|
|
192
|
+
eventStream,
|
|
193
|
+
stream: eventStream
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Abort error to surface for an aborted `signal`.
|
|
198
|
+
*
|
|
199
|
+
* Rethrows the caller's abort reason only when it carries a `code`, so that code
|
|
200
|
+
* survives into `errorCode` on the persisted assistant message and consumers can
|
|
201
|
+
* recognize an abort's origin without matching error text. A default
|
|
202
|
+
* `abort()` reason is an uncoded DOMException that carries nothing the synthetic
|
|
203
|
+
* error does not, so it keeps the "Request was aborted" text every transport
|
|
204
|
+
* already emits rather than churning it.
|
|
205
|
+
*/
|
|
206
|
+
function transportAbortError(signal) {
|
|
207
|
+
const reason = signal?.reason;
|
|
208
|
+
return reason instanceof Error && typeof reason.code === "string" ? reason : /* @__PURE__ */ new Error("Request was aborted");
|
|
209
|
+
}
|
|
210
|
+
function finalizeTransportStream(params) {
|
|
211
|
+
const { stream, output, signal } = params;
|
|
212
|
+
if (signal?.aborted) throw transportAbortError(signal);
|
|
213
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") throw new Error(output.errorMessage ?? "An unknown error occurred");
|
|
214
|
+
stream.push({
|
|
215
|
+
type: "done",
|
|
216
|
+
reason: output.stopReason,
|
|
217
|
+
message: output
|
|
218
|
+
});
|
|
219
|
+
stream.end();
|
|
220
|
+
}
|
|
221
|
+
const MAX_TRANSPORT_ERROR_CAUSE_DEPTH = 8;
|
|
222
|
+
function readStringLikeProperty(value, key) {
|
|
223
|
+
if (!value || typeof value !== "object") return;
|
|
224
|
+
const raw = value[key];
|
|
225
|
+
if (typeof raw === "string") return raw.trim() || void 0;
|
|
226
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
227
|
+
}
|
|
228
|
+
function readObjectProperty(value, key) {
|
|
229
|
+
if (!value || typeof value !== "object") return;
|
|
230
|
+
const raw = value[key];
|
|
231
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
|
|
232
|
+
}
|
|
233
|
+
function readCauseChainErrorCode(value) {
|
|
234
|
+
const seen = /* @__PURE__ */ new Set();
|
|
235
|
+
let cause = readObjectProperty(value, "cause");
|
|
236
|
+
for (let depth = 0; cause && depth < MAX_TRANSPORT_ERROR_CAUSE_DEPTH && !seen.has(cause); depth += 1) {
|
|
237
|
+
seen.add(cause);
|
|
238
|
+
const code = readStringLikeProperty(cause, "code");
|
|
239
|
+
if (code) return code;
|
|
240
|
+
cause = readObjectProperty(cause, "cause");
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function stringifyErrorBody(value) {
|
|
244
|
+
if (typeof value === "string") return value;
|
|
245
|
+
if (value === void 0 || value === null) return;
|
|
246
|
+
try {
|
|
247
|
+
return JSON.stringify(value);
|
|
248
|
+
} catch {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function stringifyTransportErrorMessage(value) {
|
|
253
|
+
if (value instanceof Error) return value.message;
|
|
254
|
+
const encoded = stringifyErrorBody(value);
|
|
255
|
+
if (encoded !== void 0) return encoded;
|
|
256
|
+
try {
|
|
257
|
+
return String(value);
|
|
258
|
+
} catch {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function normalizeTransportErrorBody(value) {
|
|
263
|
+
const text = stringifyErrorBody(value);
|
|
264
|
+
if (!text?.trim()) return;
|
|
265
|
+
const redacted = redactSensitiveText(text);
|
|
266
|
+
return redacted.length > 500 ? `${truncateUtf16Safe(redacted, 499)}…` : redacted;
|
|
267
|
+
}
|
|
268
|
+
function extractTransportErrorDetails(error) {
|
|
269
|
+
const errorObject = error && typeof error === "object" ? error : void 0;
|
|
270
|
+
const nestedError = readObjectProperty(errorObject, "error");
|
|
271
|
+
const errorCode = readStringLikeProperty(errorObject, "errorCode") ?? readStringLikeProperty(errorObject, "code") ?? readStringLikeProperty(nestedError, "code") ?? readCauseChainErrorCode(errorObject);
|
|
272
|
+
const errorType = readStringLikeProperty(errorObject, "errorType") ?? readStringLikeProperty(errorObject, "type") ?? readStringLikeProperty(nestedError, "type");
|
|
273
|
+
const errorBody = normalizeTransportErrorBody(readStringLikeProperty(errorObject, "errorBody")) ?? normalizeTransportErrorBody(readStringLikeProperty(errorObject, "body")) ?? normalizeTransportErrorBody(readObjectProperty(errorObject, "body")) ?? normalizeTransportErrorBody(nestedError);
|
|
274
|
+
return {
|
|
275
|
+
...errorCode ? { errorCode } : {},
|
|
276
|
+
...errorType ? { errorType } : {},
|
|
277
|
+
...errorBody ? { errorBody } : {}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function assignTransportErrorDetails(output, error, signal) {
|
|
281
|
+
output.stopReason = signal?.aborted ? "aborted" : "error";
|
|
282
|
+
output.errorMessage = stringifyTransportErrorMessage(error);
|
|
283
|
+
Object.assign(output, extractTransportErrorDetails(error));
|
|
284
|
+
}
|
|
285
|
+
function failTransportStream(params) {
|
|
286
|
+
const { stream, output, signal, error, cleanup } = params;
|
|
287
|
+
cleanup?.();
|
|
288
|
+
assignTransportErrorDetails(output, error, signal);
|
|
289
|
+
stream.push({
|
|
290
|
+
type: "error",
|
|
291
|
+
reason: output.stopReason,
|
|
292
|
+
error: output
|
|
293
|
+
});
|
|
294
|
+
stream.end();
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
export { resolveSecretSentinel as C, resolveModelHeaderSentinels as S, supportsModelTools as T, isGoogleGemini3ProModel as _, failTransportStream as a, redactIdentifier as b, mergeTransportMetadata as c, transportAbortError as d, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE as f, isGoogleGemini3FlashModel as g, isCodeModeModelVisibleToolName as h, createWritableTransportEventStream as i, sanitizeNonEmptyTransportPayloadText as l, estimateStringChars as m, coerceTransportToolCallArguments as n, finalizeTransportStream as o, createAbortError as p, createEmptyTransportUsage as r, mergeTransportHeaders as s, assignTransportErrorDetails as t, sanitizeTransportPayloadText as u, parseRetryAfterSeconds as v, sha256Hex as w, redactSensitiveText as x, readResponseTextSnippet as y };
|