@openclaw/ai 2026.7.2-beta.4 → 2026.7.2-beta.6
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-CrUDIBpM.mjs → anthropic-CH4UUnZr.mjs} +26 -441
- package/dist/{anthropic-BoTnz8cv.d.mts → anthropic-SrGtwsJu.d.mts} +27 -1
- package/dist/anthropic-usage-DWU-x8MI.mjs +459 -0
- package/dist/{api-registry-BMphkFf1.d.mts → api-registry-DlMgPR39.d.mts} +1 -1
- package/dist/{azure-openai-responses-CbrpVeEv.mjs → azure-openai-responses-CImcwB83.mjs} +4 -4
- package/dist/cache-retention-0x979a5V.mjs +12 -0
- package/dist/deferred-event-buffer-DAvyP7qA.mjs +19 -0
- package/dist/error-coercion-DgxlWC0n.mjs +15 -0
- package/dist/{event-stream-Douf9dob.d.mts → event-stream-YjaPW20U.d.mts} +1 -1
- package/dist/event-stream.d.mts +1 -1
- package/dist/{github-copilot-headers-BsH5cqGj.mjs → github-copilot-headers-NCJtz9i0.mjs} +1 -12
- package/dist/{google-Cs62KA7t.mjs → google-CtSg0iTS.mjs} +3 -3
- package/dist/{google-shared-CMLI-tCZ.mjs → google-shared-DNBz5rcD.mjs} +7 -4
- package/dist/{google-vertex-B4SD3U0f.mjs → google-vertex-31f1uS9L.mjs} +3 -3
- package/dist/{host-WvWBo4h8.d.mts → host-B9GUmcra.d.mts} +2 -2
- package/dist/host-Dog2WQiR.mjs +369 -0
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +3 -3
- package/dist/internal/anthropic.d.mts +16 -62
- package/dist/internal/anthropic.mjs +5 -4
- package/dist/internal/openai.d.mts +260 -2
- package/dist/internal/openai.mjs +7 -5
- package/dist/internal/runtime.d.mts +8 -32
- package/dist/internal/runtime.mjs +7 -6
- package/dist/internal/shared.d.mts +14 -9
- package/dist/internal/shared.mjs +6 -2
- package/dist/{llm-request-activity-CehVkZP-.mjs → llm-request-activity-BjtkplhG.mjs} +1 -19
- package/dist/{mistral-D5Ps7Led.mjs → mistral-CWmpvWYh.mjs} +7 -4
- package/dist/number-coercion-DvG7SNMg.mjs +129 -0
- package/dist/{openai-chatgpt-responses-h0o5yV8Y.mjs → openai-chatgpt-responses-B84Ibtrd.mjs} +33 -29
- package/dist/{openai-completions-exO8NFQf.mjs → openai-completions-DsOxhOD1.mjs} +28 -482
- package/dist/openai-completions-compat-DBWjXoMZ.d.mts +43 -0
- package/dist/openai-prompt-cache-2uo_1OR1.d.mts +7 -0
- package/dist/openai-prompt-cache-mZTCdRPo.mjs +12 -0
- package/dist/openai-reasoning-compat-YgeLncHw.mjs +396 -0
- package/dist/{openai-responses-BHpmtUKo.mjs → openai-responses-BT7A3sLu.mjs} +7 -5
- package/dist/openai-responses-shared-pXl6Wd8S.mjs +392 -0
- package/dist/{openai-responses-shared-CzCurmY1.mjs → openai-responses-stream-internal-Cw5txaGW.mjs} +1609 -1037
- package/dist/{openai-tool-projection-ITOU9bG1.mjs → openai-tool-projection-OhX64DoP.mjs} +26 -11
- package/dist/prompt-cache-stability-Cwcjv_fx.d.mts +13 -0
- package/dist/{provider-error-C4VvV_3t.mjs → provider-error-CAEvRjry.mjs} +8 -2
- package/dist/provider-options-D8bB3z9b.d.mts +144 -0
- package/dist/providers.d.mts +3 -2
- package/dist/providers.mjs +10 -9
- package/dist/reasoning-tag-text-partitioner-CGDyLWUR.mjs +12209 -0
- package/dist/simple-options-9lhRrN73.mjs +50 -0
- package/dist/{src-CXno1H5g.mjs → src-QkygScBs.mjs} +23 -4
- package/dist/stream-first-event-timeout-BBys9hSb.mjs +86 -0
- package/dist/stream-first-event-timeout-DvDeSucC.d.mts +29 -0
- package/dist/tls-certificate-errors-DXSpluKI.mjs +93 -0
- package/dist/tool-result-text-CTpIRbYd.mjs +225 -0
- package/dist/transform-messages-C8mBqZxF.mjs +2 -0
- package/dist/transport-stream-shared-D81p90xq.mjs +297 -0
- package/dist/transports.d.mts +115 -132
- package/dist/transports.mjs +400 -1991
- package/dist/{types-AFwwWium.d.mts → types-bzp5k29J.d.mts} +7 -0
- package/dist/types.d.mts +5 -5
- package/dist/types.mjs +2 -2
- package/dist/{validation-sxvxC8J-.d.mts → validation-B-j7cOYp.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/package.json +4 -5
- package/dist/host-XYGZcgO8.mjs +0 -98
- package/dist/model-utils-1GiZ2_rr.mjs +0 -64
- package/dist/openai-CoGicoDt.d.mts +0 -332
- package/dist/reasoning-tag-text-partitioner-BlVe67g6.mjs +0 -400
- package/dist/stream-first-event-timeout-DP4xEyBY.mjs +0 -150
- package/dist/system-prompt-cache-boundary-CbHeV4_l.mjs +0 -526
- package/npm-shrinkwrap.json +0 -638
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { r as createAssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
|
|
2
|
+
import { m as normalizeOptionalString, n as getAiTransportHost } from "./host-Dog2WQiR.mjs";
|
|
3
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-DT5o51ur.mjs";
|
|
4
|
+
import { o as truncateUtf16Safe } from "./tool-result-text-CTpIRbYd.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, visibleToolNames) {
|
|
58
|
+
return visibleToolNames.has(name);
|
|
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 };
|
package/dist/transports.d.mts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { E as Model, L as StreamFn, O as OpenAICompletionsCompat, X as Usage, n as Api, u as Context } from "./types-
|
|
2
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
3
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
1
|
+
import { E as Model, L as StreamFn, O as OpenAICompletionsCompat, X as Usage, a as AssistantMessageEvent, i as AssistantMessage, n as Api, u as Context } from "./types-bzp5k29J.mjs";
|
|
2
|
+
import { t as AssistantMessageEventStream } from "./event-stream-YjaPW20U.mjs";
|
|
3
|
+
import { n as ApiRegistry } from "./api-registry-DlMgPR39.mjs";
|
|
4
|
+
import { a as OpenAICompletionsOptions, d as OpenAIApiReasoningEffort, f as OpenAIReasoningEffort, i as BaseOpenAIStreamOptions, s as OpenAIToolProjection } from "./provider-options-D8bB3z9b.mjs";
|
|
5
|
+
import { n as detectOpenAICompletionsCompat, r as resolveOpenAICompletionsCompat, t as ResolvedOpenAICompletionsCompat } from "./openai-completions-compat-DBWjXoMZ.mjs";
|
|
6
|
+
import { n as FirstStreamEventInternalOptions } from "./stream-first-event-timeout-DvDeSucC.mjs";
|
|
7
|
+
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-Cwcjv_fx.mjs";
|
|
6
8
|
import OpenAI from "openai";
|
|
7
|
-
import { ChatCompletionChunk } from "openai/resources/chat/completions.js";
|
|
8
9
|
import { FunctionTool, ResponseCreateParamsStreaming, ResponseInput, ResponseReasoningItem } from "openai/resources/responses/responses.js";
|
|
10
|
+
import { ChatCompletionChunk } from "openai/resources/chat/completions.js";
|
|
9
11
|
|
|
10
12
|
//#region packages/ai/src/transports/anthropic-payload-policy.d.ts
|
|
11
13
|
/** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
|
|
@@ -111,31 +113,6 @@ declare function formatModelTransportDebugBaseUrl(rawUrl: string | undefined): s
|
|
|
111
113
|
/** Returns whether an OpenAI-compatible messages payload contains a usable turn. */
|
|
112
114
|
declare function hasOpenAICompatibleConversationTurn(messages: unknown): boolean;
|
|
113
115
|
//#endregion
|
|
114
|
-
//#region packages/ai/src/transports/openai-completions-compat.d.ts
|
|
115
|
-
type ProviderRequestCapabilities = AiProviderRequestCapabilities;
|
|
116
|
-
type OpenAICompletionsCompatDefaults = {
|
|
117
|
-
supportsStore: boolean;
|
|
118
|
-
supportsDeveloperRole: boolean;
|
|
119
|
-
supportsReasoningEffort: boolean;
|
|
120
|
-
supportsUsageInStreaming: boolean;
|
|
121
|
-
maxTokensField: "max_completion_tokens" | "max_tokens";
|
|
122
|
-
thinkingFormat: "openai" | "openrouter" | "deepseek" | "together" | "zai";
|
|
123
|
-
visibleReasoningDetailTypes: string[];
|
|
124
|
-
supportsStrictMode: boolean;
|
|
125
|
-
requiresReasoningContentOnAssistantMessages: boolean;
|
|
126
|
-
requiresNonEmptyUserOrAssistantMessage: boolean;
|
|
127
|
-
};
|
|
128
|
-
type DetectedOpenAICompletionsCompat = {
|
|
129
|
-
capabilities: ProviderRequestCapabilities;
|
|
130
|
-
defaults: OpenAICompletionsCompatDefaults;
|
|
131
|
-
};
|
|
132
|
-
/** Detects endpoint capabilities and defaults for an OpenAI-completions model. */
|
|
133
|
-
declare function detectOpenAICompletionsCompat(model: Pick<Model<"openai-completions">, "provider" | "baseUrl" | "id"> & {
|
|
134
|
-
compat?: {
|
|
135
|
-
supportsStore?: boolean;
|
|
136
|
-
} | null;
|
|
137
|
-
}, resolveCapabilities?: (input: AiProviderRequestPolicyInput) => ProviderRequestCapabilities): DetectedOpenAICompletionsCompat;
|
|
138
|
-
//#endregion
|
|
139
116
|
//#region packages/ai/src/transports/openai-completions-string-content.d.ts
|
|
140
117
|
/** Flatten string-only text block content arrays into newline-joined strings. */
|
|
141
118
|
declare function flattenCompletionMessagesToStringContent(messages: unknown[]): unknown[];
|
|
@@ -149,32 +126,6 @@ declare const log: {
|
|
|
149
126
|
info(message: string, data?: Record<string, unknown>): void;
|
|
150
127
|
warn(message: string, data?: Record<string, unknown>): void;
|
|
151
128
|
};
|
|
152
|
-
type BaseOpenAIStreamOptions = {
|
|
153
|
-
temperature?: number;
|
|
154
|
-
topP?: number;
|
|
155
|
-
maxTokens?: number;
|
|
156
|
-
stop?: string[];
|
|
157
|
-
signal?: AbortSignal;
|
|
158
|
-
apiKey?: string;
|
|
159
|
-
cacheRetention?: "none" | "short" | "long";
|
|
160
|
-
sessionId?: string;
|
|
161
|
-
promptCacheKey?: string;
|
|
162
|
-
authProfileId?: string;
|
|
163
|
-
onPayload?: (payload: unknown, model: Model) => unknown;
|
|
164
|
-
headers?: Record<string, string>;
|
|
165
|
-
firstEventTimeoutMs?: number;
|
|
166
|
-
onFirstEventTimeout?: (reason: Error) => void;
|
|
167
|
-
openclawCodeModeToolSurface?: boolean;
|
|
168
|
-
responseFormat?: Record<string, unknown>;
|
|
169
|
-
frequencyPenalty?: number;
|
|
170
|
-
presencePenalty?: number;
|
|
171
|
-
seed?: number;
|
|
172
|
-
};
|
|
173
|
-
type OpenAICompletionsOptions = BaseOpenAIStreamOptions & {
|
|
174
|
-
toolChoice?: OpenAICompletionsToolChoice;
|
|
175
|
-
reasoning?: OpenAIReasoningEffort;
|
|
176
|
-
reasoningEffort?: OpenAIReasoningEffort;
|
|
177
|
-
};
|
|
178
129
|
type OpenAIModeCompatInput = Omit<OpenAICompletionsCompat, "thinkingFormat"> & {
|
|
179
130
|
thinkingFormat?: string;
|
|
180
131
|
requiresStringContent?: boolean;
|
|
@@ -214,16 +165,14 @@ type ModelStreamCooperativeScheduler = {
|
|
|
214
165
|
};
|
|
215
166
|
declare function throwIfModelStreamAborted(signal?: AbortSignal): void;
|
|
216
167
|
declare function createModelStreamCooperativeScheduler(signal?: AbortSignal): ModelStreamCooperativeScheduler;
|
|
217
|
-
declare function resolveCacheRetention(cacheRetention: string | undefined): "short" | "long" | "none";
|
|
218
168
|
declare function resolvePromptCacheKey(options: Pick<BaseOpenAIStreamOptions, "promptCacheKey" | "sessionId"> | undefined, cacheRetention: "short" | "long" | "none"): string | undefined;
|
|
219
|
-
declare function sortTransportToolsByName<T extends {
|
|
220
|
-
name?: string;
|
|
221
|
-
description?: string;
|
|
222
|
-
}>(tools: readonly T[]): T[];
|
|
223
169
|
//#endregion
|
|
224
170
|
//#region packages/ai/src/transports/openai-transport-params.d.ts
|
|
225
|
-
declare function
|
|
226
|
-
declare function
|
|
171
|
+
declare function readCodeModePayloadToolName(tool: unknown): string | undefined;
|
|
172
|
+
declare function filterCodeModePayloadTools(payload: unknown, visibleToolNames: ReadonlySet<string>): void;
|
|
173
|
+
declare function resolveCodeModeResponsesVisibleToolNames(context: Pick<Context, "tools">): ReadonlySet<string>;
|
|
174
|
+
declare function enforceCodeModeResponsesToolSurface(payload: unknown, visibleToolNames: ReadonlySet<string>): void;
|
|
175
|
+
declare function assertCodeModeResponsesToolSurface(payload: unknown, visibleToolNames: ReadonlySet<string>): void;
|
|
227
176
|
declare function resolveOpenAIStrictToolFlagWithDiagnostics(projection: OpenAIToolProjection, strictSetting: boolean | null | undefined, context: {
|
|
228
177
|
transport: "responses" | "completions";
|
|
229
178
|
model: OpenAIModeModel;
|
|
@@ -236,31 +185,38 @@ declare function buildOpenAISdkClientOptions(model: Model): {
|
|
|
236
185
|
};
|
|
237
186
|
declare function buildOpenAISdkRequestOptions(model: Model, signal?: AbortSignal, options?: {
|
|
238
187
|
stream?: boolean;
|
|
188
|
+
timeoutMs?: number;
|
|
189
|
+
maxRetries?: number;
|
|
239
190
|
}): {
|
|
240
191
|
signal?: AbortSignal;
|
|
241
192
|
timeout?: number;
|
|
193
|
+
maxRetries?: number;
|
|
242
194
|
headers?: Record<string, string>;
|
|
243
195
|
} | undefined;
|
|
244
196
|
declare function getCompat(model: OpenAIModeModel): {
|
|
197
|
+
cacheControlFormat: "anthropic" | undefined;
|
|
198
|
+
reasoningEffortMap: Record<string, string>;
|
|
199
|
+
openRouterRouting: Record<string, unknown>;
|
|
200
|
+
vercelGatewayRouting: Record<string, unknown>;
|
|
201
|
+
requiresStringContent: boolean;
|
|
202
|
+
strictMessageKeys: boolean;
|
|
245
203
|
supportsStore: boolean;
|
|
246
204
|
supportsDeveloperRole: boolean;
|
|
247
205
|
supportsReasoningEffort: boolean;
|
|
248
|
-
reasoningEffortMap: Record<string, string>;
|
|
249
206
|
supportsUsageInStreaming: boolean;
|
|
250
|
-
maxTokensField:
|
|
207
|
+
maxTokensField: "max_completion_tokens" | "max_tokens";
|
|
251
208
|
requiresToolResultName: boolean;
|
|
252
209
|
requiresAssistantAfterToolResult: boolean;
|
|
253
210
|
requiresThinkingAsText: boolean;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
211
|
+
requiresReasoningContentOnAssistantMessages: boolean;
|
|
212
|
+
thinkingFormat: "openai" | "openrouter" | "deepseek" | "together" | "zai" | "qwen" | "qwen-chat-template";
|
|
213
|
+
zaiToolStream: boolean;
|
|
257
214
|
supportsStrictMode: boolean;
|
|
215
|
+
supportsJsonSchemaResponseFormat: boolean;
|
|
258
216
|
supportsPromptCacheKey: boolean;
|
|
259
217
|
supportsLongCacheRetention: boolean;
|
|
260
|
-
|
|
261
|
-
strictMessageKeys: boolean;
|
|
218
|
+
sessionAffinity: "openai" | "openrouter" | "none";
|
|
262
219
|
visibleReasoningDetailTypes: string[];
|
|
263
|
-
requiresReasoningContentOnAssistantMessages: boolean;
|
|
264
220
|
requiresNonEmptyUserOrAssistantMessage: boolean;
|
|
265
221
|
};
|
|
266
222
|
//#endregion
|
|
@@ -360,7 +316,42 @@ declare function resolveReplayableResponsesMessageId(params: {
|
|
|
360
316
|
previousReplayItemWasReasoning: boolean;
|
|
361
317
|
}): string | undefined;
|
|
362
318
|
//#endregion
|
|
363
|
-
//#region packages/ai/src/transports/openai-responses-
|
|
319
|
+
//#region packages/ai/src/transports/openai-responses-client.d.ts
|
|
320
|
+
declare function createOpenAIResponsesClient(model: Model, context: Context, apiKey: string, optionHeaders?: Record<string, string>, turnHeaders?: Record<string, string>, sessionId?: string): OpenAI;
|
|
321
|
+
declare function createOpenAIResponsesTransportStreamFn(): StreamFn;
|
|
322
|
+
declare function createAzureOpenAIResponsesTransportStreamFn(): StreamFn;
|
|
323
|
+
declare function createAzureOpenAIClient(model: Model, context: Context, apiKey: string, optionHeaders?: Record<string, string>, turnHeaders?: Record<string, string>): OpenAI;
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region packages/ai/src/transports/openai-responses-debug.d.ts
|
|
326
|
+
declare function summarizeResponsesTools(tools: unknown): string;
|
|
327
|
+
declare function stringifyRedactedPayload(value: unknown): string;
|
|
328
|
+
declare function stringifyRedactedEvent(value: unknown): string;
|
|
329
|
+
type ResponsesFailedNoDetailsObservation = {
|
|
330
|
+
event: "openai_responses_response_failed_without_details";
|
|
331
|
+
provider: string;
|
|
332
|
+
api: Api;
|
|
333
|
+
transportModel: string;
|
|
334
|
+
providerRuntimeFailureKind: "no_error_details";
|
|
335
|
+
responseId: string;
|
|
336
|
+
responseStatus: string;
|
|
337
|
+
responseModel: string;
|
|
338
|
+
responseObject: string;
|
|
339
|
+
metadataKeys: string[];
|
|
340
|
+
requestIdHashes: string[];
|
|
341
|
+
failureFieldsPreview: string;
|
|
342
|
+
responsePreview: string;
|
|
343
|
+
};
|
|
344
|
+
type ResponsesFailedEventSummary = {
|
|
345
|
+
message: string;
|
|
346
|
+
responseId?: string;
|
|
347
|
+
observation?: ResponsesFailedNoDetailsObservation;
|
|
348
|
+
};
|
|
349
|
+
declare function buildResponsesFailedNoDetailsObservation(event: Record<string, unknown>, model: Model, response?: Record<string, unknown> | undefined): ResponsesFailedNoDetailsObservation;
|
|
350
|
+
declare function summarizeResponsesFailedNoDetailsObservation(observation: ResponsesFailedNoDetailsObservation): string;
|
|
351
|
+
declare function normalizeResponsesFailedEvent(event: Record<string, unknown>, model: Model): ResponsesFailedEventSummary;
|
|
352
|
+
declare function summarizeResponsesPayload(params: unknown): string;
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region packages/ai/src/transports/openai-responses-contracts.d.ts
|
|
364
355
|
declare const OPENAI_RESPONSES_REASONING_REPLAY_META_KEY = "__openclaw_replay";
|
|
365
356
|
type OpenAIResponsesReasoningReplayMetadata = {
|
|
366
357
|
v: 1;
|
|
@@ -376,7 +367,6 @@ type ReplayableResponseReasoningItem = Omit<ResponseReasoningItem, "id"> & {
|
|
|
376
367
|
id?: string;
|
|
377
368
|
[OPENAI_RESPONSES_REASONING_REPLAY_META_KEY]?: OpenAIResponsesReasoningReplayMetadata;
|
|
378
369
|
};
|
|
379
|
-
type ResponsesClientLike = ReturnType<typeof createOpenAIResponsesClient>;
|
|
380
370
|
type OpenAIResponsesOptions = BaseOpenAIStreamOptions & {
|
|
381
371
|
reasoning?: OpenAIReasoningEffort;
|
|
382
372
|
reasoningEffort?: OpenAIReasoningEffort;
|
|
@@ -393,63 +383,6 @@ type OpenAIResponsesReplayContext = {
|
|
|
393
383
|
sessionHash?: string;
|
|
394
384
|
authProfileHash?: string;
|
|
395
385
|
};
|
|
396
|
-
declare function summarizeResponsesTools(tools: unknown): string;
|
|
397
|
-
declare function stringifyRedactedPayload(value: unknown): string;
|
|
398
|
-
declare function stringifyRedactedEvent(value: unknown): string;
|
|
399
|
-
type ResponsesFailedNoDetailsObservation = {
|
|
400
|
-
event: "openai_responses_response_failed_without_details";
|
|
401
|
-
provider: string;
|
|
402
|
-
api: Api;
|
|
403
|
-
transportModel: string;
|
|
404
|
-
providerRuntimeFailureKind: "no_error_details";
|
|
405
|
-
responseId: string;
|
|
406
|
-
responseStatus: string;
|
|
407
|
-
responseModel: string;
|
|
408
|
-
responseObject: string;
|
|
409
|
-
metadataKeys: string[];
|
|
410
|
-
requestIdHashes: string[];
|
|
411
|
-
failureFieldsPreview: string;
|
|
412
|
-
responsePreview: string;
|
|
413
|
-
};
|
|
414
|
-
type ResponsesFailedEventSummary = {
|
|
415
|
-
message: string;
|
|
416
|
-
responseId?: string;
|
|
417
|
-
observation?: ResponsesFailedNoDetailsObservation;
|
|
418
|
-
};
|
|
419
|
-
declare function buildResponsesFailedNoDetailsObservation(event: Record<string, unknown>, model: Model, response?: Record<string, unknown> | undefined): ResponsesFailedNoDetailsObservation;
|
|
420
|
-
declare function summarizeResponsesFailedNoDetailsObservation(observation: ResponsesFailedNoDetailsObservation): string;
|
|
421
|
-
declare function normalizeResponsesFailedEvent(event: Record<string, unknown>, model: Model): ResponsesFailedEventSummary;
|
|
422
|
-
declare function summarizeResponsesPayload(params: unknown): string;
|
|
423
|
-
declare function isInvalidEncryptedContentError(error: unknown): boolean;
|
|
424
|
-
declare function stripResponsesRequestEncryptedContent(params: OpenAIResponsesRequestParams): OpenAIResponsesRequestParams;
|
|
425
|
-
declare function buildOpenAIResponsesReasoningReplayMetadata(model: Model, options?: Pick<BaseOpenAIStreamOptions, "authProfileId" | "sessionId">): OpenAIResponsesReasoningReplayMetadata;
|
|
426
|
-
declare function tagOpenAIResponsesReasoningReplayItem(item: Record<string, unknown>, model: Model, options?: Pick<BaseOpenAIStreamOptions, "authProfileId" | "sessionId">): Record<string, unknown>;
|
|
427
|
-
declare function prepareOpenAIResponsesReasoningItemForReplay(item: ReplayableResponseReasoningItem, context: OpenAIResponsesReplayContext, blockMetadata?: OpenAIResponsesReasoningReplayMetadata): ReplayableResponseReasoningItem;
|
|
428
|
-
declare function createResponsesStreamWithEncryptedContentRetry(params: {
|
|
429
|
-
client: ResponsesClientLike;
|
|
430
|
-
request: OpenAIResponsesRequestParams;
|
|
431
|
-
requestOptions: unknown;
|
|
432
|
-
model: Model;
|
|
433
|
-
}): Promise<AsyncIterable<unknown>>;
|
|
434
|
-
declare function resolveAzureOpenAIApiVersion(env?: NodeJS.ProcessEnv): string;
|
|
435
|
-
declare function processResponsesStream(openaiStream: AsyncIterable<unknown>, output: MutableAssistantOutput, stream: {
|
|
436
|
-
push(event: unknown): void;
|
|
437
|
-
}, model: Model, options?: {
|
|
438
|
-
serviceTier?: ResponseCreateParamsStreaming["service_tier"];
|
|
439
|
-
applyServiceTierPricing?: (usage: MutableAssistantOutput["usage"], serviceTier?: ResponseCreateParamsStreaming["service_tier"]) => void;
|
|
440
|
-
firstEventTimeoutMs?: number;
|
|
441
|
-
abortFirstEventStream?: (reason: Error) => void;
|
|
442
|
-
onFirstEventTimeout?: (reason: Error) => void;
|
|
443
|
-
signal?: AbortSignal;
|
|
444
|
-
sessionId?: string;
|
|
445
|
-
authProfileId?: string;
|
|
446
|
-
}): Promise<void>;
|
|
447
|
-
declare function createOpenAIResponsesClient(model: Model, context: Context, apiKey: string, optionHeaders?: Record<string, string>, turnHeaders?: Record<string, string>, sessionId?: string): OpenAI;
|
|
448
|
-
declare function createOpenAIResponsesTransportStreamFn(): StreamFn;
|
|
449
|
-
declare function sanitizeOpenAICodexResponsesParams<T extends Record<string, unknown>>(model: Model, params: T): T;
|
|
450
|
-
declare function buildOpenAIResponsesParams(model: Model, context: Context, options: OpenAIResponsesOptions | undefined, metadata?: Record<string, string>): OpenAIResponsesRequestParams;
|
|
451
|
-
declare function createAzureOpenAIResponsesTransportStreamFn(): StreamFn;
|
|
452
|
-
declare function createAzureOpenAIClient(model: Model, context: Context, apiKey: string, optionHeaders?: Record<string, string>, turnHeaders?: Record<string, string>): OpenAI;
|
|
453
386
|
type OpenAIResponsesRequestParams = {
|
|
454
387
|
model: string;
|
|
455
388
|
input: ResponseInput;
|
|
@@ -474,6 +407,42 @@ type OpenAIResponsesRequestParams = {
|
|
|
474
407
|
};
|
|
475
408
|
include?: string[];
|
|
476
409
|
};
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region packages/ai/src/transports/openai-responses-params-internal.d.ts
|
|
412
|
+
declare function sanitizeOpenAICodexResponsesParams<T extends Record<string, unknown>>(model: Model, params: T): T;
|
|
413
|
+
declare function buildOpenAIResponsesParams(model: Model, context: Context, options: OpenAIResponsesOptions | undefined, metadata?: Record<string, string>): OpenAIResponsesRequestParams;
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region packages/ai/src/transports/openai-responses-replay-internal.d.ts
|
|
416
|
+
type ResponsesClientLike = ReturnType<typeof createOpenAIResponsesClient>;
|
|
417
|
+
declare function isInvalidEncryptedContentError(error: unknown): boolean;
|
|
418
|
+
declare function stripResponsesRequestEncryptedContent(params: OpenAIResponsesRequestParams): OpenAIResponsesRequestParams;
|
|
419
|
+
declare function buildOpenAIResponsesReasoningReplayMetadata(model: Model, options?: Pick<BaseOpenAIStreamOptions, "authProfileId" | "sessionId">): OpenAIResponsesReasoningReplayMetadata;
|
|
420
|
+
declare function tagOpenAIResponsesReasoningReplayItem(item: Record<string, unknown>, model: Model, options?: Pick<BaseOpenAIStreamOptions, "authProfileId" | "sessionId">): Record<string, unknown>;
|
|
421
|
+
declare function prepareOpenAIResponsesReasoningItemForReplay(item: ReplayableResponseReasoningItem, context: OpenAIResponsesReplayContext, blockMetadata?: OpenAIResponsesReasoningReplayMetadata): ReplayableResponseReasoningItem;
|
|
422
|
+
declare function createResponsesStreamWithEncryptedContentRetry(params: {
|
|
423
|
+
client: ResponsesClientLike;
|
|
424
|
+
request: OpenAIResponsesRequestParams;
|
|
425
|
+
requestOptions: unknown;
|
|
426
|
+
model: Model;
|
|
427
|
+
}): Promise<AsyncIterable<unknown>>;
|
|
428
|
+
declare function resolveAzureOpenAIApiVersion(env?: NodeJS.ProcessEnv): string;
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region packages/ai/src/transports/openai-responses-stream-terminal-internal.d.ts
|
|
431
|
+
type ResponsesEventSink = {
|
|
432
|
+
push(event: AssistantMessageEvent): void;
|
|
433
|
+
};
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region packages/ai/src/transports/openai-responses-stream-internal.d.ts
|
|
436
|
+
type ResponsesStreamOptions = FirstStreamEventInternalOptions & {
|
|
437
|
+
serviceTier?: ResponseCreateParamsStreaming["service_tier"];
|
|
438
|
+
resolveServiceTier?: (responseServiceTier: ResponseCreateParamsStreaming["service_tier"] | undefined, requestServiceTier: ResponseCreateParamsStreaming["service_tier"] | undefined) => ResponseCreateParamsStreaming["service_tier"] | undefined;
|
|
439
|
+
applyServiceTierPricing?: (usage: Usage, serviceTier: ResponseCreateParamsStreaming["service_tier"] | undefined) => void;
|
|
440
|
+
signal?: AbortSignal;
|
|
441
|
+
reasoningReplayMetadata?: OpenAIResponsesReasoningReplayMetadata;
|
|
442
|
+
};
|
|
443
|
+
declare function processResponsesStream<TApi extends Api>(openaiStream: AsyncIterable<unknown>, output: AssistantMessage, stream: ResponsesEventSink, model: Model<TApi>, options?: ResponsesStreamOptions): Promise<void>;
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region packages/ai/src/transports/openai-responses-transport.d.ts
|
|
477
446
|
declare const responsesTesting: {
|
|
478
447
|
getCompat: typeof getCompat;
|
|
479
448
|
assertCodeModeResponsesToolSurface: typeof assertCodeModeResponsesToolSurface;
|
|
@@ -573,6 +542,17 @@ declare function createWritableTransportEventStream(): {
|
|
|
573
542
|
eventStream: AssistantMessageEventStream;
|
|
574
543
|
stream: WritableTransportStream;
|
|
575
544
|
};
|
|
545
|
+
/**
|
|
546
|
+
* Abort error to surface for an aborted `signal`.
|
|
547
|
+
*
|
|
548
|
+
* Rethrows the caller's abort reason only when it carries a `code`, so that code
|
|
549
|
+
* survives into `errorCode` on the persisted assistant message and consumers can
|
|
550
|
+
* recognize an abort's origin without matching error text. A default
|
|
551
|
+
* `abort()` reason is an uncoded DOMException that carries nothing the synthetic
|
|
552
|
+
* error does not, so it keeps the "Request was aborted" text every transport
|
|
553
|
+
* already emits rather than churning it.
|
|
554
|
+
*/
|
|
555
|
+
declare function transportAbortError(signal?: AbortSignal): Error;
|
|
576
556
|
declare function finalizeTransportStream(params: {
|
|
577
557
|
stream: WritableTransportStream;
|
|
578
558
|
output: TransportOutputShape;
|
|
@@ -587,4 +567,7 @@ declare function failTransportStream(params: {
|
|
|
587
567
|
cleanup?: () => void;
|
|
588
568
|
}): void;
|
|
589
569
|
//#endregion
|
|
590
|
-
|
|
570
|
+
//#region packages/ai/src/transports/transport-utils.d.ts
|
|
571
|
+
declare function isCodeModeModelVisibleToolName(name: string, visibleToolNames: ReadonlySet<string>): boolean;
|
|
572
|
+
//#endregion
|
|
573
|
+
export { GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, MutableAssistantOutput, type OpenAICompletionsOptions, OpenAIModeModel, ResolvedOpenAICompletionsCompat, WritableTransportStream, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyOpenAIResponsesPayloadPolicy, assertCodeModeResponsesToolSurface, assignTransportErrorDetails, buildOpenAIClientHeaders, buildOpenAICompletionsParams, buildOpenAISdkClientOptions, buildOpenAISdkRequestOptions, buildTransportAwareSimpleStreamFn, canonicalizeMaxTokensParam, coerceTransportToolCallArguments, createAnthropicMessagesTransportStreamFn, createAzureOpenAIResponsesTransportStreamFn, createBoundaryAwareStreamFnForModel, createDeepSeekTextFilter, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createOpenAICompletionsTransportStreamFn, createOpenAIResponsesTransportStreamFn, createOpenClawTransportStreamFnForModel, createTransportAwareStreamFnForModel, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, enforceCodeModeResponsesToolSurface, failTransportStream, filterCodeModePayloadTools, finalizeTransportStream, flattenCompletionMessagesToStringContent, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, getCompat, hasOpenAICompatibleConversationTurn, isCodeModeModelVisibleToolName, isOpenAICodexResponsesModel, log, mergeTransportHeaders, mergeTransportMetadata, normalizeCodexResponsesBaseUrlForOpenAISdk, parseJsonObjectPreservingUnsafeIntegers, parseJsonPreservingUnsafeIntegers, prepareModelForSimpleCompletion, prepareTransportAwareSimpleModel, quoteUnsafeIntegerLiterals, readCodeModePayloadToolName, resolveAnthropicEphemeralCacheControl, resolveAnthropicMessagesUrl, resolveAnthropicPayloadPolicy, resolveCodeModeResponsesVisibleToolNames, resolveMaxTokensParam, resolveModelPayloadDebugMode, resolveModelSseDebugMode, resolveOpenAICompletionsCompat, resolveOpenAIReasoningEffortMap, resolveOpenAIResponsesPayloadPolicy, resolveOpenAIStrictToolFlagWithDiagnostics, resolvePromptCacheKey, resolveReplayableResponsesMessageId, resolveTransportAwareSimpleApi, sanitizeNonEmptyTransportPayloadText, sanitizeResponsesImagePayload, sanitizeTransportPayloadText, sortPromptCacheToolsByName as sortTransportToolsByName, stripCompletionMessagesToRoleContent, throwIfModelStreamAborted, transportAbortError, usesNativeOpenAICodexResponsesBackend };
|