@openclaw/ai 2026.10.5 → 2026.10.10-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/{anthropic-DIIiiz99.mjs → anthropic-D6spfBri.mjs} +16 -18
- package/dist/{anthropic-payload-policy-DGblkHL5.d.mts → anthropic-payload-policy-Cr8xjazC.d.mts} +6 -3
- package/dist/{anthropic-stream-reducer-DfMVFm-r.mjs → anthropic-stream-reducer-CzPXOaLM.mjs} +55 -227
- package/dist/anthropic-tool-projection-BdAS3rtJ.mjs +165 -0
- package/dist/anthropic-tool-projection-DKH-aEWU.d.mts +51 -0
- package/dist/{api-registry-BhXXYdRA.d.mts → api-registry-gDt0faai.d.mts} +2 -2
- package/dist/{assistant-output-BuhRpLeD.mjs → assistant-output-6iFA1nbC.mjs} +2 -2
- package/dist/{azure-openai-responses-DGQnXRMs.mjs → azure-openai-responses-0TqHwnlD.mjs} +8 -8
- package/dist/{cloudflare-5qSGvIUH.mjs → cloudflare-Dttf8jKq.mjs} +1 -1
- package/dist/{credential-redaction-BHxruEH6.d.mts → credential-redaction-XvsPf7Yi.d.mts} +1 -0
- package/dist/{diagnostics-tQasYct1.mjs → diagnostics-Cv7cW3pS.mjs} +3 -3
- package/dist/diagnostics.d.mts +6 -6
- package/dist/diagnostics.mjs +2 -2
- package/dist/{env-api-keys-CrxwdylR.mjs → env-api-keys-Xd8dm_aV.mjs} +10 -34
- package/dist/event-stream-CDpFza-M.d.mts +1 -0
- package/dist/{event-stream-BcqWLo_u.d.mts → event-stream-CzpE1g_o.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/{github-copilot-request-facts-DEE6gcB9.mjs → github-copilot-request-facts-F-EmvkpW.mjs} +1 -1
- package/dist/{google-interactions-zIz70M2e.mjs → google-interactions-DVQ7AaSF.mjs} +29 -50
- package/dist/{google-messages-CNbUJK5E.mjs → google-messages-DfpHVTaD.mjs} +15 -5
- package/dist/{google-provider-stream-Cn0XF1MG.mjs → google-provider-stream-DJ8ANfsS.mjs} +6 -6
- package/dist/{google-shared-BPnWP4tT.mjs → google-shared-VTcCJLW3.mjs} +21 -29
- package/dist/{google-vertex-XQ7OQtaM.mjs → google-vertex-Bkfizj7M.mjs} +3 -3
- package/dist/{google-BlbTC1Xp.mjs → google-zWpkDSeN.mjs} +4 -4
- package/dist/{host-Bf3NjYNj.mjs → host-B2gk-d1H.mjs} +5 -11
- package/dist/{host-CTDz7LXD.d.mts → host-jJOffdlW.d.mts} +4 -6
- package/dist/{host-policy-BzZluO6_.mjs → host-policy-mpqGhbeM.mjs} +1 -1
- package/dist/{index-BYDvopUB.d.mts → index-DSprYWaz.d.mts} +7 -5
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +6 -6
- package/dist/internal/anthropic.d.mts +7 -53
- package/dist/internal/anthropic.mjs +6 -5
- package/dist/internal/google-model-family.mjs +1 -1
- 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 +3 -3
- package/dist/internal/openai-responses-payload-policy.mjs +3 -3
- package/dist/internal/openai.d.mts +17 -26
- package/dist/internal/openai.mjs +10 -10
- package/dist/internal/retry-after.d.mts +1 -1
- package/dist/internal/retry-after.mjs +80 -55
- package/dist/internal/runtime.d.mts +9 -31
- package/dist/internal/runtime.mjs +10 -116
- package/dist/internal/shared.d.mts +9 -7
- package/dist/internal/shared.mjs +8 -6
- package/dist/internal/tool-schema.d.mts +83 -5
- package/dist/internal/tool-schema.mjs +4 -3
- package/dist/{mistral-dCDCR5ur.mjs → mistral-CATJrwne.mjs} +32 -35
- package/dist/model-request-body-BD5vy4rP.d.mts +17 -0
- package/dist/{number-coercion-C3hztWoY.mjs → number-coercion-37gmNkuA.mjs} +1 -1
- package/dist/{openai-chatgpt-responses-D8-q7cgy.mjs → openai-chatgpt-responses-CtdnpWwe.mjs} +95 -63
- package/dist/{openai-completions-CMN24pza.mjs → openai-completions-B6sET3oI.mjs} +10 -8
- package/dist/{openai-completions-compat-i-nLZxFy.d.mts → openai-completions-compat-1gsjP-KO.d.mts} +6 -3
- package/dist/{openai-completions-compat-CYX18uDk.mjs → openai-completions-compat-CFhQ3UVU.mjs} +7 -2
- package/dist/{openai-completions-transport-DuXQOxrH.mjs → openai-completions-transport-DviPEqw3.mjs} +369 -237
- package/dist/{openai-prompt-cache-r93BJhjm.mjs → openai-prompt-cache-DJ_P143P.mjs} +1 -1
- package/dist/{openai-prompt-cache-DIPMrMFy.d.mts → openai-prompt-cache-DgjD-UL5.d.mts} +2 -2
- package/dist/{openai-responses-BMxoJdTC.mjs → openai-responses-BXsJK-mD.mjs} +13 -15
- package/dist/{openai-responses-compaction-replay-B2FE4Nw8.d.mts → openai-responses-compaction-replay-Cvnl_nCq.d.mts} +5 -5
- package/dist/{openai-responses-contracts-DlKMMTxK.mjs → openai-responses-contracts-Bx-16mnf.mjs} +45 -6
- package/dist/{openai-responses-contracts-DKqMJ1Ct.d.mts → openai-responses-contracts-CQ4_AWjL.d.mts} +20 -8
- package/dist/{openai-responses-endpoint-CinGh4VZ.mjs → openai-responses-endpoint-D4v-eeYy.mjs} +55 -22
- package/dist/{openai-responses-payload-policy-C7GsA1y0.d.mts → openai-responses-payload-policy-BzM52TTH.d.mts} +9 -3
- package/dist/openai-responses-request-lifecycle-CTdAb2v1.mjs +246 -0
- package/dist/{openai-responses-shared-afo9-s16.mjs → openai-responses-shared-Bv_1NtH9.mjs} +284 -173
- package/dist/{openai-responses-terminal-usage-BygjiAdi.d.mts → openai-responses-terminal-usage-CpVjkqn-.d.mts} +2 -2
- package/dist/{openai-tool-schema-DDPXsvJP.mjs → openai-tool-schema-Buv0GXFb.mjs} +170 -237
- package/dist/overflow-DJHXTNBQ.mjs +117 -0
- package/dist/{positive-integer-CqWjqSi9.mjs → positive-integer-Bb4Evc7L.mjs} +1 -1
- package/dist/prompt-cache-stability-D_MeCQFI.mjs +32 -0
- package/dist/{provider-error-xumb1V3F.d.mts → provider-error-CnaWYTRY.d.mts} +1 -0
- package/dist/{provider-error-CF9GWCs2.mjs → provider-error-qtZD2inE.mjs} +75 -13
- package/dist/{provider-options-CVrXZBtA.d.mts → provider-options-DeYeaflL.d.mts} +52 -6
- package/dist/{transport-utils-34BQoXq3.mjs → provider-replay-context-J6CfU3m1.mjs} +28 -5
- package/dist/{provider-transport-turn-state-BYrELw8H.mjs → provider-transport-turn-state-Jxppzuc2.mjs} +5 -5
- package/dist/{provider-types-CHtRx0dI.d.mts → provider-types-ODq57rG_.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +11 -11
- package/dist/{reasoning-tag-text-partitioner-CpOy9-IQ.mjs → reasoning-tag-text-partitioner-DzlRubwU.mjs} +134 -47
- package/dist/{required-api-key-CFJvcFy_.mjs → required-api-key-D088S4Cd.mjs} +1 -1
- package/dist/{retry-after-CdCURCVg.d.mts → retry-after-sw-XX8aC.d.mts} +1 -1
- package/dist/sanitize-unicode-CRGuMONI.mjs +8 -0
- package/dist/sanitize-unicode-ZqVLLEKC.d.mts +27 -0
- package/dist/{session-resources-D1wgDQ8C.mjs → session-resources-vKvGIE3J.mjs} +1 -10
- package/dist/{simple-options-BAu4B54D.mjs → simple-options-BYgC6kse.mjs} +68 -79
- package/dist/{src-C44MKrW5.mjs → src-CyA0zJnt.mjs} +6 -2
- package/dist/{stream-Dd8DwRFL.mjs → stream-DLBirT0e.mjs} +8 -47
- package/dist/{stream-first-event-timeout-Dc42hKv6.mjs → stream-first-event-timeout-D_TfJHRJ.mjs} +1 -1
- package/dist/{string-coerce-CtgOVOSv.mjs → string-coerce-Cj8sqWHx.mjs} +26 -1
- package/dist/tool-schema-json-projection-B0hHDV7N.mjs +492 -0
- package/dist/{transport-stream-shared-BmpzDtdQ.d.mts → transport-stream-shared-8ru8eX4s.d.mts} +5 -5
- package/dist/{transport-stream-shared-CWGOuLcA.mjs → transport-stream-shared-CzQlAzJH.mjs} +27 -75
- package/dist/transports.d.mts +33 -28
- package/dist/transports.mjs +42 -48
- package/dist/{types-CQc6JNG4.mjs → types-BXd0kI8-.mjs} +1 -1
- package/dist/types-CBJthzJX.d.mts +1 -0
- package/dist/{types-Bd2T86VJ.d.mts → types-CVYzKrMl.d.mts} +20 -3
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +4 -4
- package/dist/{validation-ZX_sPVV0.mjs → validation-9FSkE8T-.mjs} +22 -3
- package/dist/{validation-DdGB1yy3.d.mts → validation-BQ5u20Ru.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +3 -3
- package/dist/assistant-text-phase-mvdMcrY-.mjs +0 -50
- package/dist/event-stream-6UNs-AhN.d.mts +0 -1
- package/dist/expect-lbe3Hgrh.mjs +0 -8
- package/dist/json-schema-Bp07Qui3.mjs +0 -22
- package/dist/openai-responses-request-lifecycle-NSIJo9jY.mjs +0 -67
- package/dist/openai-tool-projection-793cE3QX.d.mts +0 -37
- package/dist/openai-tool-schema-a5ysBBga.d.mts +0 -32
- package/dist/rolldown-runtime-BhDjJH2R.mjs +0 -15
- package/dist/sanitize-unicode-CjDG6jJx.d.mts +0 -5
- package/dist/string-normalization-I3ux50s9.mjs +0 -28
- package/dist/text-signature-CUXnvk_c.mjs +0 -34
- package/dist/tool-schema-json-projection-B8sG1I9v.mjs +0 -180
- package/dist/types-Kdfw_04V.d.mts +0 -1
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
|
|
2
2
|
import { a as createAssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
|
|
3
3
|
import { i as asOptionalRecord, n as asNullableRecord, t as asNonArrayRecord } from "./record-coerce-CNDovvft.mjs";
|
|
4
|
-
import { E as headersToRecord, r as getAiTransportHost } from "./host-
|
|
5
|
-
import { a as projectDiagnosticValue, n as projectProviderError } from "./provider-error-
|
|
6
|
-
import { l as isTransientNetworkError } from "./diagnostics-
|
|
4
|
+
import { E as headersToRecord, r as getAiTransportHost } from "./host-B2gk-d1H.mjs";
|
|
5
|
+
import { a as projectDiagnosticValue, n as projectProviderError } from "./provider-error-qtZD2inE.mjs";
|
|
6
|
+
import { l as isTransientNetworkError } from "./diagnostics-Cv7cW3pS.mjs";
|
|
7
7
|
import { t as createZeroUsage } from "./usage-CJH5D6Ea.mjs";
|
|
8
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
|
|
8
9
|
import { parse } from "partial-json";
|
|
9
|
-
//#region packages/ai/src/utils/sanitize-unicode.ts
|
|
10
|
-
/** Remove unpaired surrogates rejected by providers; preserve valid Unicode pairs. */
|
|
11
|
-
function sanitizeSurrogates(text) {
|
|
12
|
-
if (text.isWellFormed()) return text;
|
|
13
|
-
return text.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "");
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
10
|
//#region packages/retry/src/index.ts
|
|
17
11
|
const MAX_TIMER_TIMEOUT_MS = 2147e6;
|
|
18
12
|
function createAbortError(message, options) {
|
|
@@ -38,7 +32,6 @@ function racePromiseWithAbortSignal(operation, signal, createError = (abortedSig
|
|
|
38
32
|
const aborted = new Promise((_, reject) => {
|
|
39
33
|
onAbort = () => reject(abortError());
|
|
40
34
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
41
|
-
if (signal.aborted) onAbort();
|
|
42
35
|
});
|
|
43
36
|
return Promise.race([run(), aborted]).finally(() => {
|
|
44
37
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -343,36 +336,7 @@ function createToolArgumentPreviewSchedule() {
|
|
|
343
336
|
* Number.MAX_SAFE_INTEGER as strings before JSON.parse can round them.
|
|
344
337
|
*/
|
|
345
338
|
const MAX_SAFE_INTEGER_ABS_STR = String(Number.MAX_SAFE_INTEGER);
|
|
346
|
-
|
|
347
|
-
return ch !== void 0 && ch >= "0" && ch <= "9";
|
|
348
|
-
}
|
|
349
|
-
function parseJsonNumberToken(input, start) {
|
|
350
|
-
let idx = start;
|
|
351
|
-
if (input[idx] === "-") idx += 1;
|
|
352
|
-
if (idx >= input.length) return null;
|
|
353
|
-
if (input[idx] === "0") idx += 1;
|
|
354
|
-
else if (isAsciiDigit(input[idx]) && input[idx] !== "0") while (isAsciiDigit(input[idx])) idx += 1;
|
|
355
|
-
else return null;
|
|
356
|
-
let isInteger = true;
|
|
357
|
-
if (input[idx] === ".") {
|
|
358
|
-
isInteger = false;
|
|
359
|
-
idx += 1;
|
|
360
|
-
if (!isAsciiDigit(input[idx])) return null;
|
|
361
|
-
while (isAsciiDigit(input[idx])) idx += 1;
|
|
362
|
-
}
|
|
363
|
-
if (input[idx] === "e" || input[idx] === "E") {
|
|
364
|
-
isInteger = false;
|
|
365
|
-
idx += 1;
|
|
366
|
-
if (input[idx] === "+" || input[idx] === "-") idx += 1;
|
|
367
|
-
if (!isAsciiDigit(input[idx])) return null;
|
|
368
|
-
while (isAsciiDigit(input[idx])) idx += 1;
|
|
369
|
-
}
|
|
370
|
-
return {
|
|
371
|
-
token: input.slice(start, idx),
|
|
372
|
-
end: idx,
|
|
373
|
-
isInteger
|
|
374
|
-
};
|
|
375
|
-
}
|
|
339
|
+
const JSON_STRING_OR_NUMBER_RE = /"(?:\\[\s\S]|[^"\\])*"?|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/g;
|
|
376
340
|
function isUnsafeIntegerLiteral(token) {
|
|
377
341
|
const digits = token[0] === "-" ? token.slice(1) : token;
|
|
378
342
|
return digits.length > MAX_SAFE_INTEGER_ABS_STR.length || digits.length === MAX_SAFE_INTEGER_ABS_STR.length && digits > MAX_SAFE_INTEGER_ABS_STR;
|
|
@@ -380,39 +344,7 @@ function isUnsafeIntegerLiteral(token) {
|
|
|
380
344
|
/** Quotes integer literals above Number.MAX_SAFE_INTEGER before JSON.parse. */
|
|
381
345
|
function quoteUnsafeIntegerLiterals(input) {
|
|
382
346
|
if (!/(?:^|\D)\d{16}/.test(input)) return input;
|
|
383
|
-
|
|
384
|
-
let inString = false;
|
|
385
|
-
let escaped = false;
|
|
386
|
-
let idx = 0;
|
|
387
|
-
while (idx < input.length) {
|
|
388
|
-
const ch = input[idx] ?? "";
|
|
389
|
-
if (inString) {
|
|
390
|
-
out += ch;
|
|
391
|
-
if (escaped) escaped = false;
|
|
392
|
-
else if (ch === "\\") escaped = true;
|
|
393
|
-
else if (ch === "\"") inString = false;
|
|
394
|
-
idx += 1;
|
|
395
|
-
continue;
|
|
396
|
-
}
|
|
397
|
-
if (ch === "\"") {
|
|
398
|
-
inString = true;
|
|
399
|
-
out += ch;
|
|
400
|
-
idx += 1;
|
|
401
|
-
continue;
|
|
402
|
-
}
|
|
403
|
-
if (ch === "-" || isAsciiDigit(ch)) {
|
|
404
|
-
const parsed = parseJsonNumberToken(input, idx);
|
|
405
|
-
if (parsed) {
|
|
406
|
-
if (parsed.isInteger && isUnsafeIntegerLiteral(parsed.token)) out += `"${parsed.token}"`;
|
|
407
|
-
else out += parsed.token;
|
|
408
|
-
idx = parsed.end;
|
|
409
|
-
continue;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
out += ch;
|
|
413
|
-
idx += 1;
|
|
414
|
-
}
|
|
415
|
-
return out;
|
|
347
|
+
return input.replace(JSON_STRING_OR_NUMBER_RE, (token, offset) => token[0] !== "\"" && !/[.eE]/.test(token) && !/[.eE]/.test(input.charAt(offset + token.length)) && isUnsafeIntegerLiteral(token) ? `"${token}"` : token);
|
|
416
348
|
}
|
|
417
349
|
/** Parses JSON while preserving unsafe integer literals as strings. */
|
|
418
350
|
function parseJsonPreservingUnsafeIntegers(input) {
|
|
@@ -696,8 +628,28 @@ function finalizeTransportStream(params) {
|
|
|
696
628
|
}
|
|
697
629
|
/** Assign terminal fields and record silent transport failures before partial-call cleanup. */
|
|
698
630
|
function assignTransportErrorDetails(output, error, signal) {
|
|
631
|
+
if (!signal?.aborted) try {
|
|
632
|
+
const record = asOptionalRecord(error);
|
|
633
|
+
const response = asOptionalRecord(record?.response);
|
|
634
|
+
const detail = asOptionalRecord(record?.error) ?? asOptionalRecord(response?.error) ?? asOptionalRecord(asOptionalRecord(record?.payload)?.error);
|
|
635
|
+
getAiTransportHost().logWarn("provider-error", "Model request failed", {
|
|
636
|
+
provider: output.provider,
|
|
637
|
+
model: output.model,
|
|
638
|
+
status: record?.status ?? record?.statusCode ?? response?.status,
|
|
639
|
+
code: record?.errorCode ?? record?.code ?? detail?.code,
|
|
640
|
+
type: record?.errorType ?? detail?.type ?? record?.type,
|
|
641
|
+
message: record?.message ?? detail?.message ?? (typeof error === "string" ? error : void 0),
|
|
642
|
+
body: record?.errorBody ?? record?.body ?? response?.body ?? response?.data ?? detail,
|
|
643
|
+
requestId: record?.request_id ?? record?.requestId,
|
|
644
|
+
responseId: record?.responseId ?? response?.id ?? output.responseId
|
|
645
|
+
});
|
|
646
|
+
} catch {}
|
|
699
647
|
const projection = projectProviderError(error, signal);
|
|
700
648
|
Object.assign(output, projection);
|
|
649
|
+
if (output.usage.usageReport?.state !== "available") {
|
|
650
|
+
output.usage.usageReport = { state: "unavailable" };
|
|
651
|
+
output.usage.contextUsage = { state: "unavailable" };
|
|
652
|
+
}
|
|
701
653
|
if (projection.stopReason === "error" && output.content.length === 0 && isTransientNetworkError(projectDiagnosticValue(error)) && !output.diagnostics?.some((diagnostic) => diagnostic.type === "provider_transport_failure")) appendAssistantMessageDiagnostic(output, createAssistantMessageDiagnostic("provider_transport_failure", projection.errorMessage, {
|
|
702
654
|
eventsEmitted: false,
|
|
703
655
|
phase: "before_message_stream_start"
|
|
@@ -716,4 +668,4 @@ function failTransportStream(params) {
|
|
|
716
668
|
stream.end();
|
|
717
669
|
}
|
|
718
670
|
//#endregion
|
|
719
|
-
export { shortHash as A, parseJsonObjectPreservingUnsafeIntegers as C, parseJsonWithRepair as D, createToolArgumentPreviewSchedule as E, racePromiseWithAbortSignal as M, raceWithTimeout as N, parseStreamingJson as O,
|
|
671
|
+
export { shortHash as A, parseJsonObjectPreservingUnsafeIntegers as C, parseJsonWithRepair as D, createToolArgumentPreviewSchedule as E, racePromiseWithAbortSignal as M, raceWithTimeout as N, parseStreamingJson as O, withProviderResponseHook as S, quoteUnsafeIntegerLiterals as T, sanitizeNonEmptyTransportPayloadText as _, createEmptyTransportUsage as a, transportAbortError as b, failTransportStream as c, iterateModelStream as d, mergeTransportHeaders as f, parseTerminalToolCallArguments as g, notifyProviderStreamOpened as h, copyProviderAcceptanceObserver as i, createAbortError as j, repairJson as k, finalizeTerminalToolCallArguments as l, notifyProviderHttpResponse as m, assignTransportErrorDetails as n, createModelStreamCooperativeScheduler as o, notifyProviderHttpMetadata as p, coerceTransportToolCallArguments as r, createWritableTransportEventStream as s, IncompleteToolCallError as t, finalizeTransportStream as u, sanitizeTransportPayloadText as v, parseJsonPreservingUnsafeIntegers as w, withProviderAcceptanceObserver as x, throwIfModelStreamAborted as y };
|
package/dist/transports.d.mts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { $ as StopReason, N as OpenAICompletionsCompat, Nt as ModelDataThinkingFormat, Q as SimpleStreamOptions, V as ProviderReplayState, a as AssistantMessage, d as Context, et as StreamFn, gt as VercelGatewayRouting, k as Model, l as CacheRetention, lt as Tool, n as Api, nt as StreamOptions, ot as ThinkingContent, pt as Usage, rt as TextContent, ut as ToolCall } from "./types-
|
|
3
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
4
|
-
import { o as AiProviderStreamHookContext } from "./host-
|
|
5
|
-
import { a as BaseOpenAIStreamOptions, c as OpenAIResponsesCompactionRejection, o as CodeModeToolSurfaceObservation, s as
|
|
6
|
-
import
|
|
7
|
-
import "./
|
|
8
|
-
import { a as
|
|
9
|
-
import { a as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { n as
|
|
13
|
-
import { C as withProviderAcceptanceObserver, S as transportAbortError, _ as notifyProviderStreamOpened, a as coerceTransportToolCallArguments, b as sanitizeTransportPayloadText, c as createModelStreamCooperativeScheduler, d as finalizeTerminalToolCallArguments, f as finalizeTransportStream, g as notifyProviderHttpResponse, h as notifyProviderHttpMetadata, i as assignTransportErrorDetails, l as createWritableTransportEventStream, m as mergeTransportHeaders, n as ProviderAcceptance, o as copyProviderAcceptanceObserver, p as iterateModelStream, r as WritableTransportStream, s as createEmptyTransportUsage, t as IncompleteToolCallError, u as failTransportStream, v as parseTerminalToolCallArguments, w as withProviderResponseHook, x as throwIfModelStreamAborted, y as sanitizeNonEmptyTransportPayloadText } from "./transport-stream-shared-BmpzDtdQ.mjs";
|
|
1
|
+
import "./index-DSprYWaz.mjs";
|
|
2
|
+
import { $ as StopReason, N as OpenAICompletionsCompat, Nt as ModelDataThinkingFormat, Q as SimpleStreamOptions, V as ProviderReplayState, a as AssistantMessage, d as Context, et as StreamFn, gt as VercelGatewayRouting, k as Model, l as CacheRetention, lt as Tool, n as Api, nt as StreamOptions, ot as ThinkingContent, pt as Usage, rt as TextContent, ut as ToolCall } from "./types-CVYzKrMl.mjs";
|
|
3
|
+
import { n as ApiRegistry } from "./api-registry-gDt0faai.mjs";
|
|
4
|
+
import { o as AiProviderStreamHookContext } from "./host-jJOffdlW.mjs";
|
|
5
|
+
import { a as BaseOpenAIStreamOptions, c as OpenAICompletionsOptions, l as OpenAIResponsesCompactionRejection, m as OpenAIToolProjection, o as CodeModeToolSurfaceObservation, s as CompactionReplayRejection } from "./provider-options-DeYeaflL.mjs";
|
|
6
|
+
import "./types-CBJthzJX.mjs";
|
|
7
|
+
import { a as buildAnthropicSystemBlocks, c as logAnthropicContextEdits, d as resolveAnthropicPayloadPolicy, f as resolveAnthropicRequestBetaHeader, i as applyAnthropicRequestCacheControl, l as resolveAnthropicCacheOptions, m as supportsAnthropicServerSideFallback, n as applyAnthropicEphemeralCacheControlMarkers, o as isAnthropicServerToolClearingEnabled, p as resolveAnthropicServerCompactionPlan, r as applyAnthropicPayloadPolicyToParams, s as isDirectAnthropicModel, t as applyAnthropicContextManagementToRequest, u as resolveAnthropicEphemeralCacheControl } from "./anthropic-payload-policy-Cr8xjazC.mjs";
|
|
8
|
+
import { a as resolveOpenAICompletionsCompat, i as isOpenAICodexResponsesModel, n as detectOpenAICompletionsCompat, o as resolveOpenAIPromptCacheKeySupport, r as isNativeOpenAIEndpoint, s as usesNativeOpenAICodexResponsesBackend, t as ResolvedOpenAICompletionsCompat } from "./openai-completions-compat-1gsjP-KO.mjs";
|
|
9
|
+
import { a as ReplayableResponseReasoningItem, n as OpenAIResponsesOptions, r as OpenAIResponsesReasoningReplayMetadata, u as OpenAIResponsesCompactionOutput } from "./openai-responses-contracts-CQ4_AWjL.mjs";
|
|
10
|
+
import { a as resolveOpenAIResponsesPayloadPolicy, i as resolveOpenAIResponsesCompactEndpointPlan, n as applyOpenAIResponsesPayloadPolicy, o as resolveOpenAIResponsesRequestContextTokens, r as normalizeOpenAIServiceTier, s as resolveOpenAIResponsesServerCompactionPlan, t as OpenAIServiceTier } from "./openai-responses-payload-policy-BzM52TTH.mjs";
|
|
11
|
+
import { n as captureOpenAIResponsesCompaction, t as CompactionReplayRefreshRequiredError } from "./openai-responses-compaction-replay-Cvnl_nCq.mjs";
|
|
12
|
+
import { C as withProviderAcceptanceObserver, S as transportAbortError, _ as notifyProviderStreamOpened, a as coerceTransportToolCallArguments, b as sanitizeTransportPayloadText, c as createModelStreamCooperativeScheduler, d as finalizeTerminalToolCallArguments, f as finalizeTransportStream, g as notifyProviderHttpResponse, h as notifyProviderHttpMetadata, i as assignTransportErrorDetails, l as createWritableTransportEventStream, m as mergeTransportHeaders, n as ProviderAcceptance, o as copyProviderAcceptanceObserver, p as iterateModelStream, r as WritableTransportStream, s as createEmptyTransportUsage, t as IncompleteToolCallError, u as failTransportStream, v as parseTerminalToolCallArguments, w as withProviderResponseHook, x as throwIfModelStreamAborted, y as sanitizeNonEmptyTransportPayloadText } from "./transport-stream-shared-8ru8eX4s.mjs";
|
|
14
13
|
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-Cwcjv_fx.mjs";
|
|
15
|
-
import {
|
|
16
|
-
import { d as VideoContent, i as ProviderContext, s as ProviderModel } from "./provider-types-CHtRx0dI.mjs";
|
|
14
|
+
import { d as VideoContent, i as ProviderContext, s as ProviderModel } from "./provider-types-ODq57rG_.mjs";
|
|
17
15
|
import { a as resolveModelPayloadDebugMode, i as emitModelTransportError, n as formatModelTransportDebugUrl, o as resolveModelSseDebugMode, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./model-transport-url-BrsjjdjR.mjs";
|
|
18
16
|
import OpenAI from "openai";
|
|
19
17
|
import { Part } from "@google/genai";
|
|
@@ -133,19 +131,16 @@ type OpenAIModeCompatInput = Omit<OpenAICompletionsCompat, "thinkingFormat"> & {
|
|
|
133
131
|
export type OpenAIModeModel = Omit<Model, "compat"> & {
|
|
134
132
|
compat?: OpenAIModeCompatInput | null;
|
|
135
133
|
};
|
|
136
|
-
type MutableToolCall = ToolCall & {
|
|
137
|
-
partialArgs?: string;
|
|
138
|
-
};
|
|
139
134
|
export type MutableAssistantOutput = Omit<AssistantMessage, "content" | "usage"> & {
|
|
140
|
-
content: Array<TextContent | ThinkingContent |
|
|
135
|
+
content: Array<TextContent | ThinkingContent | ToolCall>;
|
|
141
136
|
usage: Usage & {
|
|
142
137
|
reasoningTokens?: number;
|
|
143
138
|
};
|
|
144
139
|
};
|
|
145
|
-
export declare function detachPartialSnapshot<TEvent>(event: TEvent): TEvent;
|
|
146
140
|
export declare function parseOpenAICompletionsUsage(rawUsage: NonNullable<ChatCompletionChunk["usage"]> & {
|
|
147
141
|
cost?: unknown;
|
|
148
142
|
cache_creation_input_tokens?: number;
|
|
143
|
+
cached_tokens?: number;
|
|
149
144
|
prompt_cache_hit_tokens?: number;
|
|
150
145
|
prompt_tokens_details?: {
|
|
151
146
|
cache_creation_input_tokens?: number;
|
|
@@ -155,6 +150,7 @@ export declare function parseOpenAICompletionsUsage(rawUsage: NonNullable<ChatCo
|
|
|
155
150
|
}): MutableAssistantOutput["usage"];
|
|
156
151
|
export declare function createOpenAIResponseHook(onResponse: BaseOpenAIStreamOptions["onResponse"], response: Response, model: Model): (() => void | Promise<void>) | undefined;
|
|
157
152
|
export declare function createOpenAIProviderAcceptanceHook(options: Pick<BaseOpenAIStreamOptions, "onResponse" | "signal"> | undefined, response: Response, model: Model): () => Promise<void>;
|
|
153
|
+
export declare function withOpenAIErrorResponseHook(fetch: typeof globalThis.fetch, onResponse: BaseOpenAIStreamOptions["onResponse"], model: Model): typeof globalThis.fetch;
|
|
158
154
|
/** Measure one UTF-8 append without double-counting a surrogate pair split across chunks. */
|
|
159
155
|
export declare function measureUtf8AppendBytes(bufferEndsWithHighSurrogate: boolean, chunk: string): {
|
|
160
156
|
bytes: number;
|
|
@@ -172,7 +168,7 @@ declare function convertTools(tools: NonNullable<Context["tools"]>, compat: Reso
|
|
|
172
168
|
function: {
|
|
173
169
|
name: string;
|
|
174
170
|
description: string | undefined;
|
|
175
|
-
parameters:
|
|
171
|
+
parameters: Record<string, unknown>;
|
|
176
172
|
strict?: boolean;
|
|
177
173
|
};
|
|
178
174
|
}[];
|
|
@@ -207,6 +203,7 @@ export declare function resolveReplayableResponsesMessageId(params: {
|
|
|
207
203
|
fallbackOrdinal: number;
|
|
208
204
|
previousReplayItemWasReasoning: boolean;
|
|
209
205
|
}): string | undefined;
|
|
206
|
+
export declare function normalizeOpenAIResponsesReasoningReplayItem(item: ReplayableResponseReasoningItem, api: Api): ReplayableResponseReasoningItem;
|
|
210
207
|
//#endregion
|
|
211
208
|
//#region packages/ai/src/transports/openai-responses-tool-call-id-shape.d.ts
|
|
212
209
|
export declare const OPENAI_RESPONSES_ID_MAX_LENGTH = 64;
|
|
@@ -237,11 +234,17 @@ type OpenAIResponsesCompactEndpointResult = {
|
|
|
237
234
|
input_tokens: number;
|
|
238
235
|
output_tokens: number;
|
|
239
236
|
};
|
|
237
|
+
/** Normal Responses accounting, including cache splits and service-tier pricing. */
|
|
238
|
+
modelUsage?: Usage;
|
|
240
239
|
model: Model;
|
|
241
240
|
replayMetadata: OpenAIResponsesReasoningReplayMetadata;
|
|
242
241
|
};
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
type OpenAIResponsesV2ReplayBudget = {
|
|
243
|
+
maxTokens: number;
|
|
244
|
+
estimateTokens(output: OpenAIResponsesCompactionOutput, outputTokens: number): number;
|
|
245
|
+
};
|
|
246
|
+
/** Run provider compaction through the session's prepared stream stack. */
|
|
247
|
+
export declare function requestPreparedOpenAIResponsesCompaction(streamFn: StreamFn, model: Model, context: Context, options: OpenAIResponsesOptions, mode?: "endpoint" | "v2", replayBudget?: OpenAIResponsesV2ReplayBudget): Promise<OpenAIResponsesCompactEndpointResult>;
|
|
245
248
|
//#endregion
|
|
246
249
|
//#region packages/ai/src/transports/openai-transport-params.d.ts
|
|
247
250
|
export declare function readCodeModePayloadToolName(tool: unknown): string | undefined;
|
|
@@ -289,8 +292,10 @@ export declare function getCompat(model: OpenAIModeModel): {
|
|
|
289
292
|
sessionAffinity: "none" | "openai" | "openrouter";
|
|
290
293
|
visibleReasoningDetailTypes: string[];
|
|
291
294
|
requiresNonEmptyUserOrAssistantMessage: boolean;
|
|
295
|
+
requiresTypedUnionBranches: boolean;
|
|
292
296
|
configuredSupportsLongCacheRetention?: boolean;
|
|
293
297
|
reasoningEffortForOff: "none" | null;
|
|
298
|
+
thinkingOffControlUndeclared: boolean;
|
|
294
299
|
reasoningEffortMap: Record<string, string>;
|
|
295
300
|
openRouterRouting: Record<string, unknown>;
|
|
296
301
|
requiresStringContent: boolean;
|
|
@@ -300,6 +305,10 @@ export declare function getCompat(model: OpenAIModeModel): {
|
|
|
300
305
|
//#region packages/ai/src/transports/provider-compaction-checkpoint.d.ts
|
|
301
306
|
/** Whether provider replay state is a prefix-bound server compaction checkpoint. */
|
|
302
307
|
export declare function isCompactionReplayCheckpoint(replay: unknown): replay is ProviderReplayState;
|
|
308
|
+
/** Strip prefix-bound checkpoint state from an in-place message rewrite. */
|
|
309
|
+
export declare function stripCompactionReplayCheckpointInPlace(message: {
|
|
310
|
+
providerReplay?: unknown;
|
|
311
|
+
}): void;
|
|
303
312
|
/** Strip prefix-bound checkpoints after local history rewrites. */
|
|
304
313
|
export declare function stripCompactionReplayCheckpoint(message: AssistantMessage): AssistantMessage;
|
|
305
314
|
//#endregion
|
|
@@ -333,10 +342,6 @@ export declare function resolveCompactionReplayPressure<T extends ReplayMessage>
|
|
|
333
342
|
prefixTokens: number;
|
|
334
343
|
measuredTokens?: number;
|
|
335
344
|
} | undefined;
|
|
336
|
-
/** Strip prefix-bound checkpoint state from an in-place message rewrite. */
|
|
337
|
-
export declare function stripCompactionReplayCheckpointInPlace(message: {
|
|
338
|
-
providerReplay?: unknown;
|
|
339
|
-
}): void;
|
|
340
345
|
/** Preserve the covered prefix and reindex checkpoints after known content removals. */
|
|
341
346
|
export declare function replaceCompactionReplayOwnerContent(message: AssistantMessage, content: AssistantMessage["content"]): AssistantMessage;
|
|
342
347
|
//#endregion
|
|
@@ -443,4 +448,4 @@ export declare function convertGoogleTools(tools: Tool[]): {
|
|
|
443
448
|
functionDeclarations: Record<string, unknown>[];
|
|
444
449
|
}[] | undefined;
|
|
445
450
|
//#endregion
|
|
446
|
-
export { CompactionReplayRefreshRequiredError, type GoogleStreamChunk, IncompleteToolCallError, type OpenAICompletionsOptions, type OpenAIResponsesCompactionRejection, ProviderAcceptance, ResolvedOpenAICompletionsCompat, WritableTransportStream, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyOpenAIResponsesPayloadPolicy, assignTransportErrorDetails, buildAnthropicSystemBlocks, createTransportAwareStreamFnForModel as buildTransportAwareSimpleStreamFn, captureOpenAIResponsesCompaction, coerceTransportToolCallArguments, copyProviderAcceptanceObserver, createSupportedTransportStreamFn as createBoundaryAwareStreamFnForModel, createSupportedTransportStreamFn as createOpenClawTransportStreamFnForModel, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, emitModelTransportError, failTransportStream, finalizeTerminalToolCallArguments, finalizeTransportStream, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, isAnthropicServerToolClearingEnabled, isDirectAnthropicModel, isNativeOpenAIEndpoint, isOpenAICodexResponsesModel, iterateModelStream, logAnthropicContextEdits, mergeTransportHeaders, notifyProviderHttpMetadata, notifyProviderHttpResponse, notifyProviderStreamOpened, parseTerminalToolCallArguments, resolveAnthropicCacheOptions, resolveAnthropicEphemeralCacheControl, resolveAnthropicPayloadPolicy, resolveAnthropicRequestBetaHeader, resolveAnthropicServerCompactionPlan, resolveModelPayloadDebugMode, resolveModelSseDebugMode, resolveOpenAICompletionsCompat, resolveOpenAIPromptCacheKeySupport, resolveOpenAIResponsesCompactEndpointPlan, resolveOpenAIResponsesPayloadPolicy, resolveOpenAIResponsesServerCompactionPlan, sanitizeNonEmptyTransportPayloadText, sanitizeTransportPayloadText, sortPromptCacheToolsByName as sortTransportToolsByName, supportsAnthropicServerSideFallback, throwIfModelStreamAborted, transportAbortError, usesNativeOpenAICodexResponsesBackend, withProviderAcceptanceObserver, withProviderResponseHook };
|
|
451
|
+
export { CompactionReplayRefreshRequiredError, type CompactionReplayRejection, type GoogleStreamChunk, IncompleteToolCallError, type OpenAICompletionsOptions, type OpenAIResponsesCompactionRejection, OpenAIServiceTier, ProviderAcceptance, ResolvedOpenAICompletionsCompat, WritableTransportStream, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyOpenAIResponsesPayloadPolicy, assignTransportErrorDetails, buildAnthropicSystemBlocks, createTransportAwareStreamFnForModel as buildTransportAwareSimpleStreamFn, captureOpenAIResponsesCompaction, coerceTransportToolCallArguments, copyProviderAcceptanceObserver, createSupportedTransportStreamFn as createBoundaryAwareStreamFnForModel, createSupportedTransportStreamFn as createOpenClawTransportStreamFnForModel, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, emitModelTransportError, failTransportStream, finalizeTerminalToolCallArguments, finalizeTransportStream, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, isAnthropicServerToolClearingEnabled, isDirectAnthropicModel, isNativeOpenAIEndpoint, isOpenAICodexResponsesModel, iterateModelStream, logAnthropicContextEdits, mergeTransportHeaders, normalizeOpenAIServiceTier, notifyProviderHttpMetadata, notifyProviderHttpResponse, notifyProviderStreamOpened, parseTerminalToolCallArguments, resolveAnthropicCacheOptions, resolveAnthropicEphemeralCacheControl, resolveAnthropicPayloadPolicy, resolveAnthropicRequestBetaHeader, resolveAnthropicServerCompactionPlan, resolveModelPayloadDebugMode, resolveModelSseDebugMode, resolveOpenAICompletionsCompat, resolveOpenAIPromptCacheKeySupport, resolveOpenAIResponsesCompactEndpointPlan, resolveOpenAIResponsesPayloadPolicy, resolveOpenAIResponsesRequestContextTokens, resolveOpenAIResponsesServerCompactionPlan, sanitizeNonEmptyTransportPayloadText, sanitizeTransportPayloadText, sortPromptCacheToolsByName as sortTransportToolsByName, supportsAnthropicServerSideFallback, throwIfModelStreamAborted, transportAbortError, usesNativeOpenAICodexResponsesBackend, withProviderAcceptanceObserver, withProviderResponseHook };
|
package/dist/transports.mjs
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { w as supportsClaudeAdaptiveThinking } from "./src-
|
|
1
|
+
import { w as supportsClaudeAdaptiveThinking } from "./src-CyA0zJnt.mjs";
|
|
2
2
|
import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { T as usesClaudeStreamingRefusalContract, _ as buildAnthropicClaudeCodeIdentity, a as resolveAiTransportHeaderSentinels, b as prepareClaudeNoPrefillRequestContext, r as getAiTransportHost } from "./host-
|
|
5
|
-
import { i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-
|
|
6
|
-
import { o as redactDiagnosticText, s as truncateUtf16Safe } from "./provider-error-
|
|
7
|
-
import { a as resolveModelPayloadDebugMode, i as emitModelTransportError, n as formatModelTransportDebugUrl, o as resolveModelSseDebugMode, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl, y as toErrorObject } from "./diagnostics-
|
|
8
|
-
import { i as
|
|
9
|
-
import { a as resolveOpenAIPromptCacheKeySupport, i as resolveOpenAICompletionsCompat, n as isNativeOpenAIEndpoint, o as usesNativeOpenAICodexResponsesBackend, r as isOpenAICodexResponsesModel, t as detectOpenAICompletionsCompat } from "./openai-completions-compat-
|
|
10
|
-
import { t as buildGuardedModelFetch } from "./host-policy-
|
|
11
|
-
import { A as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { n as getEnvApiKey } from "./env-api-keys-CrxwdylR.mjs";
|
|
3
|
+
import { r as normalizeLowercaseStringOrEmpty } from "./string-coerce-Cj8sqWHx.mjs";
|
|
4
|
+
import { T as usesClaudeStreamingRefusalContract, _ as buildAnthropicClaudeCodeIdentity, a as resolveAiTransportHeaderSentinels, b as prepareClaudeNoPrefillRequestContext, r as getAiTransportHost } from "./host-B2gk-d1H.mjs";
|
|
5
|
+
import { i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-Bx-16mnf.mjs";
|
|
6
|
+
import { o as redactDiagnosticText, s as truncateUtf16Safe } from "./provider-error-qtZD2inE.mjs";
|
|
7
|
+
import { a as resolveModelPayloadDebugMode, i as emitModelTransportError, n as formatModelTransportDebugUrl, o as resolveModelSseDebugMode, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl, y as toErrorObject } from "./diagnostics-Cv7cW3pS.mjs";
|
|
8
|
+
import { i as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, l as resolveModelHeaderSentinels, o as isCodeModeModelVisibleToolName, s as readResponseTextSnippet, u as streamFragmentError } from "./provider-replay-context-J6CfU3m1.mjs";
|
|
9
|
+
import { a as resolveOpenAIPromptCacheKeySupport, i as resolveOpenAICompletionsCompat, n as isNativeOpenAIEndpoint, o as usesNativeOpenAICodexResponsesBackend, r as isOpenAICodexResponsesModel, t as detectOpenAICompletionsCompat } from "./openai-completions-compat-CFhQ3UVU.mjs";
|
|
10
|
+
import { t as buildGuardedModelFetch } from "./host-policy-mpqGhbeM.mjs";
|
|
11
|
+
import { A as resolveAnthropicCacheOptions, C as applyAnthropicEphemeralCacheControlMarkers, D as isAnthropicServerToolClearingEnabled, E as buildAnthropicSystemBlocks, F as supportsAnthropicServerSideFallback, H as isAnthropicOAuthApiKey, M as resolveAnthropicPayloadPolicy, N as resolveAnthropicRequestBetaHeader, O as isDirectAnthropicModel, P as resolveAnthropicServerCompactionPlan, S as applyAnthropicContextManagementToRequest, T as applyAnthropicRequestCacheControl, U as omitFoundryBearerCredentialHeaders, W as usesFoundryBearerAuth, b as resolveNewestAnthropicCompaction, f as resolveAnthropicTransportOptions, j as resolveAnthropicEphemeralCacheControl, k as logAnthropicContextEdits, l as buildAnthropicRequest, p as resolveCompletionTokenReservation, t as consumeAnthropicStream, u as prepareAnthropicRequest, w as applyAnthropicPayloadPolicyToParams, x as suppressAnthropicCompaction, y as isAnthropicReplayRejection } from "./anthropic-stream-reducer-CzPXOaLM.mjs";
|
|
12
|
+
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-D_MeCQFI.mjs";
|
|
13
|
+
import { C as parseJsonObjectPreservingUnsafeIntegers, S as withProviderResponseHook, T as quoteUnsafeIntegerLiterals, _ as sanitizeNonEmptyTransportPayloadText, a as createEmptyTransportUsage, b as transportAbortError, c as failTransportStream, d as iterateModelStream, f as mergeTransportHeaders, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, i as copyProviderAcceptanceObserver, j as createAbortError$1, l as finalizeTerminalToolCallArguments, m as notifyProviderHttpResponse, n as assignTransportErrorDetails, o as createModelStreamCooperativeScheduler, p as notifyProviderHttpMetadata, r as coerceTransportToolCallArguments, s as createWritableTransportEventStream, t as IncompleteToolCallError, u as finalizeTransportStream, v as sanitizeTransportPayloadText, w as parseJsonPreservingUnsafeIntegers, x as withProviderAcceptanceObserver, y as throwIfModelStreamAborted } from "./transport-stream-shared-CzQlAzJH.mjs";
|
|
14
|
+
import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
|
|
16
15
|
import { t as createDeferredEventBuffer } from "./deferred-event-buffer-DAvyP7qA.mjs";
|
|
17
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
16
|
+
import { t as createAssistantOutput } from "./assistant-output-6iFA1nbC.mjs";
|
|
18
17
|
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-DA4WHv1h.mjs";
|
|
19
|
-
import {
|
|
20
|
-
import { a as googleFlashSupportsMinimalThinking, i as consumeGoogleGenerateContentStream, n as projectGoogleMessages, r as requiresGoogleToolCallId, t as convertGoogleTools } from "./google-messages-
|
|
21
|
-
import {
|
|
18
|
+
import { c as flattenCompletionMessagesToStringContent, d as hasOpenAICompatibleConversationTurn, f as canonicalizeMaxTokensParam, i as createOpenAIResponsesTransportStreamFn, l as stripCompletionMessagesToRoleContent, m as createDeepSeekTextFilter, o as buildOpenAICompletionsParams, p as resolveMaxTokensParam, r as createAzureOpenAIResponsesTransportStreamFn, t as createOpenAICompletionsTransportStreamFn, u as applyCompletionsAnthropicCacheControl } from "./openai-completions-transport-DviPEqw3.mjs";
|
|
19
|
+
import { a as googleFlashSupportsMinimalThinking, i as consumeGoogleGenerateContentStream, n as projectGoogleMessages, r as requiresGoogleToolCallId, t as convertGoogleTools } from "./google-messages-DfpHVTaD.mjs";
|
|
20
|
+
import { At as log, Dt as createOpenAIResponseHook, Et as createOpenAIProviderAcceptanceHook, Ft as resolveOpenAIClientBaseUrl, It as resolvePromptCacheKey, J as OPENAI_RESPONSES_FUNCTION_CALL_ITEM_ID_RE, L as normalizeOpenAIResponsesReasoningReplayItem, Lt as withOpenAIErrorResponseHook, M as resolveResponsesContextUsageBoundary, Mt as parseOpenAICompletionsUsage, Nt as readOpenAICompletionsContentDeltas, Ot as createResponseModelTracker, Pt as readOpenAICompletionsReasoningBatch, Q as splitOpenAIFunctionCallPairing, R as resolveReplayableResponsesMessageId, Tt as GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, X as normalizeOpenAIResponsesFunctionCallId, Y as OPENAI_RESPONSES_ID_MAX_LENGTH, Z as shouldNormalizeOpenAIResponsesToolCallId, at as resolveNewestOpenAIResponsesCompactionReplay, ct as buildOpenAIClientHeaders, dt as enforceCodeModeResponsesToolSurface, ft as filterCodeModePayloadTools, gt as resolveOpenAIStrictToolFlagWithDiagnostics, ht as resolveCodeModeResponsesVisibleToolNames, it as captureOpenAIResponsesCompaction, jt as measureUtf8AppendBytes, kt as isOpenAICompletionsThinkingEnabled, lt as buildOpenAISdkClientOptions, mt as readCodeModePayloadToolName, nt as CompactionReplayRefreshRequiredError, pt as getCompat, q as OPENAI_RESPONSES_CALL_ID_RE, st as assertCodeModeResponsesToolSurface, ut as buildOpenAISdkRequestOptions, yt as resolveOpenAIReasoningEffortMap } from "./openai-responses-shared-Bv_1NtH9.mjs";
|
|
21
|
+
import { c as applyOpenAIResponsesPayloadPolicy, d as resolveOpenAIResponsesPayloadPolicy, f as resolveOpenAIResponsesRequestContextTokens, l as normalizeOpenAIServiceTier, p as resolveOpenAIResponsesServerCompactionPlan, s as sanitizeResponsesImagePayload, u as resolveOpenAIResponsesCompactEndpointPlan } from "./openai-responses-endpoint-D4v-eeYy.mjs";
|
|
22
|
+
import { c as requestPreparedOpenAIResponsesCompaction } from "./openai-responses-request-lifecycle-CTdAb2v1.mjs";
|
|
22
23
|
import { randomUUID } from "node:crypto";
|
|
23
24
|
//#region packages/ai/src/transports/anthropic-transport-stream.ts
|
|
24
25
|
const ANTHROPIC_MESSAGES_ERROR_BODY_MAX_BYTES = 8192;
|
|
@@ -221,7 +222,7 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
221
222
|
(async () => {
|
|
222
223
|
const output = createAssistantOutput(model, "anthropic-messages");
|
|
223
224
|
const refusalBuffer = usesClaudeStreamingRefusalContract(model) ? createDeferredEventBuffer(stream) : void 0;
|
|
224
|
-
let
|
|
225
|
+
let replayedCompaction;
|
|
225
226
|
try {
|
|
226
227
|
const apiKey = options?.apiKey ?? getEnvApiKey(model.provider) ?? "";
|
|
227
228
|
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
@@ -234,7 +235,7 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
234
235
|
options: transportOptions
|
|
235
236
|
});
|
|
236
237
|
const builtParams = await buildAnthropicRequest(model, requestContext, transportOptions, "transport", isOAuthToken, !isOAuthToken && supportsAnthropicServerSideFallback(model), claudeCodeVersion);
|
|
237
|
-
|
|
238
|
+
replayedCompaction = builtParams.replayedCompaction;
|
|
238
239
|
const { params, headers } = await prepareAnthropicRequest(builtParams.params, model, transportOptions, directApiKeyBetaHeader);
|
|
239
240
|
const { response, stream: anthropicStream } = await request({
|
|
240
241
|
...params,
|
|
@@ -282,7 +283,7 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
282
283
|
refusalBuffer.discard();
|
|
283
284
|
output.content = [];
|
|
284
285
|
} else output.content = output.content.filter((block) => block.type !== "toolCall");
|
|
285
|
-
if (
|
|
286
|
+
if (replayedCompaction && isAnthropicReplayRejection(output)) suppressAnthropicCompaction(output, model, options, replayedCompaction);
|
|
286
287
|
for (const block of output.content) delete block.index;
|
|
287
288
|
}
|
|
288
289
|
});
|
|
@@ -298,6 +299,10 @@ function isCompactionReplayCheckpoint(replay) {
|
|
|
298
299
|
const type = replay && typeof replay === "object" ? replay.type : void 0;
|
|
299
300
|
return type === "anthropic-compaction" || type === "openai-responses-compaction" || type === "openai-responses-retained-compaction";
|
|
300
301
|
}
|
|
302
|
+
/** Strip prefix-bound checkpoint state from an in-place message rewrite. */
|
|
303
|
+
function stripCompactionReplayCheckpointInPlace(message) {
|
|
304
|
+
if (isCompactionReplayCheckpoint(message.providerReplay)) delete message.providerReplay;
|
|
305
|
+
}
|
|
301
306
|
/** Strip prefix-bound checkpoints after local history rewrites. */
|
|
302
307
|
function stripCompactionReplayCheckpoint(message) {
|
|
303
308
|
if (!isCompactionReplayCheckpoint(message.providerReplay)) return message;
|
|
@@ -378,12 +383,12 @@ function estimateResponsesContent(content, estimate, text) {
|
|
|
378
383
|
return tokens + estimate.json(block);
|
|
379
384
|
}, 0);
|
|
380
385
|
}
|
|
381
|
-
function estimateResponsesInput(input, estimate) {
|
|
386
|
+
function estimateResponsesInput(input, estimate, compactionOutputTokens) {
|
|
382
387
|
return input.reduce((tokens, entry) => {
|
|
383
388
|
if (!isRecord(entry)) return tokens + estimate.json(entry);
|
|
384
389
|
if (entry.type === "compaction" && typeof entry.encrypted_content === "string") {
|
|
385
390
|
const { encrypted_content, ...metadata } = entry;
|
|
386
|
-
return tokens + estimate.text(encrypted_content) + estimate.json(metadata);
|
|
391
|
+
return tokens + (compactionOutputTokens ?? estimate.text(encrypted_content)) + estimate.json(metadata);
|
|
387
392
|
}
|
|
388
393
|
if (entry.type === "message") {
|
|
389
394
|
const { content, ...metadata } = entry;
|
|
@@ -404,7 +409,7 @@ function resolveCompactionReplayPressure(messages, model, identity, estimate, sy
|
|
|
404
409
|
const ownerIndex = messages.findIndex((message) => message === checkpoint.owner);
|
|
405
410
|
const owner = messages[ownerIndex];
|
|
406
411
|
if (!owner) return;
|
|
407
|
-
const prefixTokens = checkpoint.family === "anthropic" ? estimate.text(checkpoint.summary) : checkpoint.mode === "complete-window" ? estimateResponsesInput(checkpoint.output, estimate) : estimate.text(checkpoint.item.encrypted_content);
|
|
412
|
+
const prefixTokens = checkpoint.family === "anthropic" ? estimate.text(checkpoint.summary) : checkpoint.mode === "complete-window" ? estimateResponsesInput(checkpoint.output, estimate, checkpoint.outputTokens) : estimate.text(checkpoint.item.encrypted_content);
|
|
408
413
|
const measuredBoundary = checkpoint.family === "responses" ? resolveResponsesContextUsageBoundary(messages, model, identity, systemPrompt) : void 0;
|
|
409
414
|
if (measuredBoundary) return {
|
|
410
415
|
messages: [],
|
|
@@ -433,10 +438,6 @@ function resolveCompactionReplayPressure(messages, model, identity, estimate, sy
|
|
|
433
438
|
prefixTokens
|
|
434
439
|
};
|
|
435
440
|
}
|
|
436
|
-
/** Strip prefix-bound checkpoint state from an in-place message rewrite. */
|
|
437
|
-
function stripCompactionReplayCheckpointInPlace(message) {
|
|
438
|
-
if (isCompactionReplayCheckpoint(message.providerReplay)) delete message.providerReplay;
|
|
439
|
-
}
|
|
440
441
|
/** Preserve the covered prefix and reindex checkpoints after known content removals. */
|
|
441
442
|
function replaceCompactionReplayOwnerContent(message, content) {
|
|
442
443
|
const next = {
|
|
@@ -467,14 +468,6 @@ function replaceCompactionReplayOwnerContent(message, content) {
|
|
|
467
468
|
}
|
|
468
469
|
//#endregion
|
|
469
470
|
//#region packages/ai/src/transports/provider-transport-stream.ts
|
|
470
|
-
const SUPPORTED_TRANSPORT_APIS = /* @__PURE__ */ new Set([
|
|
471
|
-
"openai-responses",
|
|
472
|
-
"openai-chatgpt-responses",
|
|
473
|
-
"openai-completions",
|
|
474
|
-
"azure-openai-responses",
|
|
475
|
-
"anthropic-messages",
|
|
476
|
-
"google-generative-ai"
|
|
477
|
-
]);
|
|
478
471
|
const SIMPLE_TRANSPORT_API_ALIAS = {
|
|
479
472
|
"openai-completions": "openclaw-openai-completions-transport",
|
|
480
473
|
"anthropic-messages": "openclaw-anthropic-messages-transport",
|
|
@@ -501,16 +494,16 @@ function createProviderOwnedGoogleTransportStreamFn(model, ctx) {
|
|
|
501
494
|
headers: resolveOpencodeSessionHeaders(requestModel, options)
|
|
502
495
|
}) : void 0;
|
|
503
496
|
}
|
|
497
|
+
const TRANSPORT_STREAM_FACTORIES = /* @__PURE__ */ new Map([
|
|
498
|
+
["openai-responses", createOpenAIResponsesTransportStreamFn],
|
|
499
|
+
["openai-chatgpt-responses", createOpenAIResponsesTransportStreamFn],
|
|
500
|
+
["openai-completions", createOpenAICompletionsTransportStreamFn],
|
|
501
|
+
["azure-openai-responses", createAzureOpenAIResponsesTransportStreamFn],
|
|
502
|
+
["anthropic-messages", createAnthropicMessagesTransportStreamFn],
|
|
503
|
+
["google-generative-ai", createProviderOwnedGoogleTransportStreamFn]
|
|
504
|
+
]);
|
|
504
505
|
function createSupportedTransportStreamFn(model, ctx) {
|
|
505
|
-
|
|
506
|
-
case "openai-responses":
|
|
507
|
-
case "openai-chatgpt-responses": return createOpenAIResponsesTransportStreamFn();
|
|
508
|
-
case "openai-completions": return createOpenAICompletionsTransportStreamFn();
|
|
509
|
-
case "azure-openai-responses": return createAzureOpenAIResponsesTransportStreamFn();
|
|
510
|
-
case "anthropic-messages": return createAnthropicMessagesTransportStreamFn();
|
|
511
|
-
case "google-generative-ai": return createProviderOwnedGoogleTransportStreamFn(model, ctx);
|
|
512
|
-
default: return;
|
|
513
|
-
}
|
|
506
|
+
return TRANSPORT_STREAM_FACTORIES.get(model.api)?.(model, ctx);
|
|
514
507
|
}
|
|
515
508
|
/** Maps public model APIs to the internal transport API id used by simple runtime dispatch. */
|
|
516
509
|
function resolveTransportAwareSimpleApi(api) {
|
|
@@ -523,8 +516,9 @@ function resolveTransportAwareSimpleApi(api) {
|
|
|
523
516
|
/** Creates a managed transport stream only when request overrides require it. */
|
|
524
517
|
function createTransportAwareStreamFnForModel(model, ctx) {
|
|
525
518
|
if (!getAiTransportHost().requiresManagedTransport(model)) return;
|
|
526
|
-
|
|
527
|
-
|
|
519
|
+
const createStream = TRANSPORT_STREAM_FACTORIES.get(model.api);
|
|
520
|
+
if (!createStream) throw new Error(`Model-provider request.proxy/request.tls/localService is not yet supported for api "${model.api}"`);
|
|
521
|
+
const streamFn = createStream(model, ctx);
|
|
528
522
|
if (!streamFn) throw new Error(`Managed transport stream is unavailable for api "${model.api}"`);
|
|
529
523
|
return streamFn;
|
|
530
524
|
}
|
|
@@ -704,4 +698,4 @@ function prepareModelForSimpleCompletion(params) {
|
|
|
704
698
|
return wrap(model);
|
|
705
699
|
}
|
|
706
700
|
//#endregion
|
|
707
|
-
export { CompactionReplayRefreshRequiredError, GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, IncompleteToolCallError, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, OPENAI_RESPONSES_CALL_ID_RE, OPENAI_RESPONSES_FUNCTION_CALL_ITEM_ID_RE, OPENAI_RESPONSES_ID_MAX_LENGTH, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyCompletionsAnthropicCacheControl, applyOpenAIResponsesPayloadPolicy, assertCodeModeResponsesToolSurface, assignTransportErrorDetails, buildAnthropicSystemBlocks, buildOpenAIClientHeaders, buildOpenAICompletionsParams, buildOpenAISdkClientOptions, buildOpenAISdkRequestOptions, createTransportAwareStreamFnForModel as buildTransportAwareSimpleStreamFn, createTransportAwareStreamFnForModel, canonicalizeMaxTokensParam, captureOpenAIResponsesCompaction, coerceTransportToolCallArguments, consumeGoogleGenerateContentStream, convertGoogleTools, copyProviderAcceptanceObserver, createAnthropicMessagesTransportStreamFn, createAzureOpenAIResponsesTransportStreamFn, createSupportedTransportStreamFn as createBoundaryAwareStreamFnForModel, createSupportedTransportStreamFn as createOpenClawTransportStreamFnForModel, createDeepSeekTextFilter, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createOpenAICompletionsTransportStreamFn, createOpenAIProviderAcceptanceHook, createOpenAIResponseHook, createOpenAIResponsesTransportStreamFn, createResponseModelTracker, createWritableTransportEventStream,
|
|
701
|
+
export { CompactionReplayRefreshRequiredError, GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, IncompleteToolCallError, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, OPENAI_RESPONSES_CALL_ID_RE, OPENAI_RESPONSES_FUNCTION_CALL_ITEM_ID_RE, OPENAI_RESPONSES_ID_MAX_LENGTH, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyCompletionsAnthropicCacheControl, applyOpenAIResponsesPayloadPolicy, assertCodeModeResponsesToolSurface, assignTransportErrorDetails, buildAnthropicSystemBlocks, buildOpenAIClientHeaders, buildOpenAICompletionsParams, buildOpenAISdkClientOptions, buildOpenAISdkRequestOptions, createTransportAwareStreamFnForModel as buildTransportAwareSimpleStreamFn, createTransportAwareStreamFnForModel, canonicalizeMaxTokensParam, captureOpenAIResponsesCompaction, coerceTransportToolCallArguments, consumeGoogleGenerateContentStream, convertGoogleTools, copyProviderAcceptanceObserver, createAnthropicMessagesTransportStreamFn, createAzureOpenAIResponsesTransportStreamFn, createSupportedTransportStreamFn as createBoundaryAwareStreamFnForModel, createSupportedTransportStreamFn as createOpenClawTransportStreamFnForModel, createDeepSeekTextFilter, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createOpenAICompletionsTransportStreamFn, createOpenAIProviderAcceptanceHook, createOpenAIResponseHook, createOpenAIResponsesTransportStreamFn, createResponseModelTracker, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, emitModelTransportError, enforceCodeModeResponsesToolSurface, failTransportStream, filterCodeModePayloadTools, finalizeTerminalToolCallArguments, finalizeTransportStream, flattenCompletionMessagesToStringContent, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, getCompat, googleFlashSupportsMinimalThinking, hasOpenAICompatibleConversationTurn, isAnthropicServerToolClearingEnabled, isCodeModeModelVisibleToolName, isCompactionReplayCheckpoint, isDirectAnthropicModel, isNativeOpenAIEndpoint, isOpenAICodexResponsesModel, isOpenAICompletionsThinkingEnabled, iterateModelStream, log, logAnthropicContextEdits, measureUtf8AppendBytes, mergeTransportHeaders, normalizeCodexResponsesBaseUrlForOpenAISdk, normalizeOpenAIResponsesFunctionCallId, normalizeOpenAIResponsesReasoningReplayItem, normalizeOpenAIServiceTier, notifyProviderHttpMetadata, notifyProviderHttpResponse, notifyProviderStreamOpened, parseJsonObjectPreservingUnsafeIntegers, parseJsonPreservingUnsafeIntegers, parseOpenAICompletionsUsage, parseTerminalToolCallArguments, prepareHeadersForSimpleCompletion, prepareModelForSimpleCompletion, prepareTransportAwareSimpleModel, preserveCompactionReplayWindow, projectGoogleMessages, quoteUnsafeIntegerLiterals, readCodeModePayloadToolName, readOpenAICompletionsContentDeltas, readOpenAICompletionsReasoningBatch, replaceCompactionReplayOwnerContent, requestPreparedOpenAIResponsesCompaction, requiresCompactionReplayRefresh, requiresGoogleToolCallId, resolveAnthropicCacheOptions, resolveAnthropicEphemeralCacheControl, resolveAnthropicMessagesUrl, resolveAnthropicPayloadPolicy, resolveAnthropicRequestBetaHeader, resolveAnthropicServerCompactionPlan, resolveCodeModeResponsesVisibleToolNames, resolveCompactionReplayEligibility, resolveCompactionReplayPressure, resolveCompletionTokenReservation, resolveMaxTokensParam, resolveModelPayloadDebugMode, resolveModelSseDebugMode, resolveOpenAIClientBaseUrl, resolveOpenAICompletionsCompat, resolveOpenAIPromptCacheKeySupport, resolveOpenAIReasoningEffortMap, resolveOpenAIResponsesCompactEndpointPlan, resolveOpenAIResponsesPayloadPolicy, resolveOpenAIResponsesRequestContextTokens, resolveOpenAIResponsesServerCompactionPlan, resolveOpenAIStrictToolFlagWithDiagnostics, resolvePromptCacheKey, resolveReplayableResponsesMessageId, resolveTransportAwareSimpleApi, sanitizeNonEmptyTransportPayloadText, sanitizeResponsesImagePayload, sanitizeTransportPayloadText, shouldNormalizeOpenAIResponsesToolCallId, sortPromptCacheToolsByName as sortTransportToolsByName, splitOpenAIFunctionCallPairing, stripCompactionReplayCheckpoint, stripCompactionReplayCheckpointInPlace, stripCompletionMessagesToRoleContent, supportsAnthropicServerSideFallback, throwIfModelStreamAborted, transportAbortError, usesNativeOpenAICodexResponsesBackend, withOpenAIErrorResponseHook, withProviderAcceptanceObserver, withProviderResponseHook };
|
|
@@ -4,7 +4,7 @@ const PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE = "PROVIDER_POST_DISPATCH_AMBI
|
|
|
4
4
|
const PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE = "PROVIDER_FAILURE_WITH_OUTPUT";
|
|
5
5
|
/** Pre-dispatch argument rejection; callers still enforce output and effect guards. */
|
|
6
6
|
const MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE = "malformed_tool_call_arguments";
|
|
7
|
-
const DEFAULT_MISSING_TOOL_RESULT_TEXT = "Tool call interrupted before a result was recorded; its outcome is unknown. Retry only if the operation is read-only or
|
|
7
|
+
const DEFAULT_MISSING_TOOL_RESULT_TEXT = "Tool call interrupted before a result was recorded; its outcome is unknown. Retry only if the operation is read-only or safe to repeat. If it may have had side effects, verify the current state first instead of repeating it.";
|
|
8
8
|
const RUNTIME_CONTEXT_CUSTOM_TYPE = "openclaw.runtime-context";
|
|
9
9
|
const RUNTIME_CONTEXT_BEGIN_MARKER = "<<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>";
|
|
10
10
|
const RUNTIME_CONTEXT_END_MARKER = "<<<END_OPENCLAW_INTERNAL_CONTEXT>>>";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index-DSprYWaz.mjs";
|
|
@@ -316,6 +316,11 @@ interface ToolCall {
|
|
|
316
316
|
id: string;
|
|
317
317
|
name: string;
|
|
318
318
|
arguments: Record<string, unknown>;
|
|
319
|
+
/**
|
|
320
|
+
* Producer-only cumulative argument JSON while the call streams. Producers remove it before
|
|
321
|
+
* `toolcall_end` or terminal cleanup; it never appears in final messages or transcripts.
|
|
322
|
+
*/
|
|
323
|
+
partialJson?: string;
|
|
319
324
|
thoughtSignature?: string;
|
|
320
325
|
executionMode?: "sequential" | "parallel";
|
|
321
326
|
}
|
|
@@ -330,6 +335,14 @@ interface Usage {
|
|
|
330
335
|
};
|
|
331
336
|
/** Subset of `cacheWrite` written with 1-hour retention when reported. */
|
|
332
337
|
cacheWrite1h?: number;
|
|
338
|
+
/**
|
|
339
|
+
* Whether usage is complete for this provider response. Missing terminal usage
|
|
340
|
+
* and provisional stream counters are unavailable, including after interruption.
|
|
341
|
+
* Omitted on older transcripts and adapters that do not report completeness.
|
|
342
|
+
*/
|
|
343
|
+
usageReport?: {
|
|
344
|
+
state: "available" | "unavailable";
|
|
345
|
+
};
|
|
333
346
|
/** Exact context snapshot for the final provider iteration. */
|
|
334
347
|
contextUsage?: {
|
|
335
348
|
state: "available";
|
|
@@ -370,9 +383,11 @@ declare const PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE = "PROVIDER_POST_DISPA
|
|
|
370
383
|
declare const PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE = "PROVIDER_FAILURE_WITH_OUTPUT";
|
|
371
384
|
/** Pre-dispatch argument rejection; callers still enforce output and effect guards. */
|
|
372
385
|
declare const MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE = "malformed_tool_call_arguments";
|
|
373
|
-
declare const DEFAULT_MISSING_TOOL_RESULT_TEXT = "Tool call interrupted before a result was recorded; its outcome is unknown. Retry only if the operation is read-only or
|
|
386
|
+
declare const DEFAULT_MISSING_TOOL_RESULT_TEXT = "Tool call interrupted before a result was recorded; its outcome is unknown. Retry only if the operation is read-only or safe to repeat. If it may have had side effects, verify the current state first instead of repeating it.";
|
|
374
387
|
interface UserMessage {
|
|
375
388
|
role: "user";
|
|
389
|
+
/** Host-generated context projected as a user message, not a human-authored turn. */
|
|
390
|
+
synthetic?: true;
|
|
376
391
|
content: string | (TextContent | ImageContent)[];
|
|
377
392
|
timestamp: number;
|
|
378
393
|
/** Trusted runtime-context metadata; ordinary user messages omit it. */
|
|
@@ -452,7 +467,7 @@ interface AssistantMessage {
|
|
|
452
467
|
mediaUrls?: string[];
|
|
453
468
|
replyToCurrent?: true;
|
|
454
469
|
replyToId?: string;
|
|
455
|
-
/**
|
|
470
|
+
/** @deprecated Ignored; omit this field. Retained until the next Plugin SDK major. */
|
|
456
471
|
textPhaseRequiresTerminal?: true;
|
|
457
472
|
/** Parsed once at the assistant write boundary; delivery resolves policy from these facts. */
|
|
458
473
|
tts?: AssistantDeliveryTtsFacts;
|
|
@@ -473,6 +488,8 @@ interface AssistantMessage {
|
|
|
473
488
|
errorCode?: string;
|
|
474
489
|
errorType?: string;
|
|
475
490
|
errorBody?: string;
|
|
491
|
+
/** Provider retry floor before diagnostic clipping; null means too large to represent. */
|
|
492
|
+
retryAfterMs?: number | null;
|
|
476
493
|
timestamp: number;
|
|
477
494
|
}
|
|
478
495
|
interface ToolResultMessage<TDetails = unknown> {
|
|
@@ -623,7 +640,7 @@ interface OpenAICompletionsCompat {
|
|
|
623
640
|
requiresThinkingAsText?: boolean;
|
|
624
641
|
/** Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL. */
|
|
625
642
|
requiresReasoningContentOnAssistantMessages?: boolean;
|
|
626
|
-
/** Format for reasoning/thinking parameter. "openai" uses reasoning_effort, "openrouter" uses reasoning: { effort }, "deepseek" uses thinking: { type } plus reasoning_effort, "together" uses reasoning: { enabled } plus reasoning_effort when supported, "zai" uses top-level enable_thinking: boolean, "qwen" uses top-level enable_thinking: boolean, and "qwen-chat-template" uses chat_template_kwargs.enable_thinking. Default: "openai". */
|
|
643
|
+
/** Format for reasoning/thinking parameter. "openai" uses reasoning_effort, "openrouter" uses reasoning: { effort }, "deepseek" uses thinking: { type } plus reasoning_effort, "together" uses reasoning: { enabled } plus reasoning_effort when supported, "zai" uses top-level enable_thinking: boolean, "qwen" uses top-level enable_thinking: boolean, and "qwen-chat-template" uses chat_template_kwargs.enable_thinking, plus chat_template_kwargs.reasoning_effort for selected enabled levels when supportedReasoningEfforts is declared. Default: "openai". */
|
|
627
644
|
thinkingFormat?: ModelDataThinkingFormat;
|
|
628
645
|
/** OpenRouter-specific routing preferences. Only used when baseUrl points to OpenRouter. */
|
|
629
646
|
openRouterRouting?: OpenRouterRouting;
|