@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
|
@@ -22,15 +22,6 @@ const HTTP_DATE_SHORT_WEEKDAY_INDEX = new Map([
|
|
|
22
22
|
"Fri",
|
|
23
23
|
"Sat"
|
|
24
24
|
].map((weekday, index) => [weekday, index]));
|
|
25
|
-
const HTTP_DATE_LONG_WEEKDAY_INDEX = new Map([
|
|
26
|
-
"Sunday",
|
|
27
|
-
"Monday",
|
|
28
|
-
"Tuesday",
|
|
29
|
-
"Wednesday",
|
|
30
|
-
"Thursday",
|
|
31
|
-
"Friday",
|
|
32
|
-
"Saturday"
|
|
33
|
-
].map((weekday, index) => [weekday, index]));
|
|
34
25
|
const IMF_FIXDATE_RE = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/;
|
|
35
26
|
const OBSOLETE_RFC850_DATE_RE = /^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d{2}) (\d{2}):(\d{2}):(\d{2}) GMT$/;
|
|
36
27
|
const OBSOLETE_ASCTIME_DATE_RE = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{2}| \d) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/;
|
|
@@ -38,20 +29,30 @@ function ownDataValue(value, key) {
|
|
|
38
29
|
return value && typeof value === "object" ? Object.getOwnPropertyDescriptor(value, key)?.value : void 0;
|
|
39
30
|
}
|
|
40
31
|
/** Reads only retry timing metadata, without invoking provider getters or serialization hooks. */
|
|
41
|
-
function parseRetryAfterHeadersSeconds(headers, nowMs = Date.now()) {
|
|
32
|
+
function parseRetryAfterHeadersSeconds(headers, nowMs = Date.now(), status) {
|
|
42
33
|
if (!headers || typeof headers !== "object") return;
|
|
43
34
|
try {
|
|
44
35
|
let entries;
|
|
45
36
|
try {
|
|
46
|
-
entries = [
|
|
37
|
+
entries = [
|
|
38
|
+
"retry-after",
|
|
39
|
+
"retry-after-ms",
|
|
40
|
+
"x-ratelimit-remaining-tokens",
|
|
41
|
+
"x-ratelimit-reset-tokens",
|
|
42
|
+
"x-ratelimit-remaining-requests",
|
|
43
|
+
"x-ratelimit-reset-requests",
|
|
44
|
+
"x-ratelimit-remaining-project-tokens",
|
|
45
|
+
"x-ratelimit-reset-project-tokens"
|
|
46
|
+
].map((key) => [key, Headers.prototype.get.call(headers, key)]);
|
|
47
47
|
} catch {
|
|
48
48
|
entries = Object.getOwnPropertyNames(headers).flatMap((key) => {
|
|
49
49
|
const name = key.toLowerCase();
|
|
50
|
-
return name === "retry-after" || name === "retry-after-ms" ? [[name, ownDataValue(headers, key)]] : [];
|
|
50
|
+
return name === "retry-after" || name === "retry-after-ms" || /^x-ratelimit-(?:remaining|reset)-(?:tokens|requests|project-tokens)$/.test(name) ? [[name, ownDataValue(headers, key)]] : [];
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
let floor;
|
|
54
54
|
for (const [key, value] of entries) {
|
|
55
|
+
if (key.startsWith("x-ratelimit-")) continue;
|
|
55
56
|
const text = typeof value === "string" ? value.trim() : typeof value === "number" ? String(value) : "";
|
|
56
57
|
const milliseconds = key === "retry-after-ms";
|
|
57
58
|
const numeric = typeof value === "number" ? value >= 0 && (milliseconds || Number.isInteger(value) || value === Infinity) : (milliseconds ? /^\d+(?:\.\d+)?$/ : /^\d+$/).test(text);
|
|
@@ -60,17 +61,51 @@ function parseRetryAfterHeadersSeconds(headers, nowMs = Date.now()) {
|
|
|
60
61
|
const seconds = numeric ? Number.isFinite(number) && number <= Number.MAX_SAFE_INTEGER ? number / (milliseconds ? 1e3 : 1) : Infinity : retryAt === void 0 ? void 0 : Math.max(0, (retryAt - nowMs) / 1e3);
|
|
61
62
|
if (seconds !== void 0) floor = Math.max(floor ?? 0, seconds);
|
|
62
63
|
}
|
|
64
|
+
if (status === 429) {
|
|
65
|
+
const values = new Map(entries);
|
|
66
|
+
for (const dimension of [
|
|
67
|
+
"tokens",
|
|
68
|
+
"requests",
|
|
69
|
+
"project-tokens"
|
|
70
|
+
]) {
|
|
71
|
+
const remaining = values.get(`x-ratelimit-remaining-${dimension}`);
|
|
72
|
+
const numericRemaining = typeof remaining === "number" ? remaining : typeof remaining === "string" && /^-?\d+(?:\.\d+)?$/.test(remaining.trim()) ? Number(remaining) : NaN;
|
|
73
|
+
if (!Number.isFinite(numericRemaining) || numericRemaining > 0) continue;
|
|
74
|
+
const reset = values.get(`x-ratelimit-reset-${dimension}`);
|
|
75
|
+
const seconds = typeof reset === "string" ? parseQuotaResetSeconds(reset) : void 0;
|
|
76
|
+
if (seconds !== void 0) floor = Math.max(floor ?? 0, seconds);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
63
79
|
return floor;
|
|
64
80
|
} catch {
|
|
65
81
|
return;
|
|
66
82
|
}
|
|
67
83
|
}
|
|
84
|
+
function parseQuotaResetSeconds(value) {
|
|
85
|
+
if (!/^(?:\d+(?:\.\d+)?(?:ms|s|m|h))+$/.test(value)) return;
|
|
86
|
+
const scales = {
|
|
87
|
+
ms: .001,
|
|
88
|
+
s: 1,
|
|
89
|
+
m: 60,
|
|
90
|
+
h: 3600
|
|
91
|
+
};
|
|
92
|
+
let seconds = 0;
|
|
93
|
+
for (const match of value.matchAll(/(\d+(?:\.\d+)?)(ms|s|m|h)/g)) {
|
|
94
|
+
const scale = scales[match[2] ?? ""];
|
|
95
|
+
if (scale === void 0) return;
|
|
96
|
+
seconds += Number(match[1]) * scale;
|
|
97
|
+
}
|
|
98
|
+
return Number.isFinite(seconds) && seconds <= Number.MAX_SAFE_INTEGER ? seconds : Infinity;
|
|
99
|
+
}
|
|
68
100
|
/** SDK errors carry native response headers separately from their error body. */
|
|
69
101
|
function parseRetryAfterErrorSeconds(error, nowMs = Date.now()) {
|
|
70
102
|
try {
|
|
71
|
-
const
|
|
72
|
-
const response =
|
|
73
|
-
|
|
103
|
+
const status = ownDataValue(error, "status") ?? ownDataValue(error, "statusCode");
|
|
104
|
+
const response = ownDataValue(error, "response");
|
|
105
|
+
const responseStatus = ownDataValue(response, "status") ?? ownDataValue(response, "statusCode");
|
|
106
|
+
const direct = parseRetryAfterHeadersSeconds(ownDataValue(error, "headers"), nowMs, typeof status === "number" ? status : void 0);
|
|
107
|
+
const responseSeconds = parseRetryAfterHeadersSeconds(ownDataValue(response, "headers"), nowMs, typeof responseStatus === "number" ? responseStatus : typeof status === "number" ? status : void 0);
|
|
108
|
+
return direct === void 0 && responseSeconds === void 0 ? void 0 : Math.max(direct ?? 0, responseSeconds ?? 0);
|
|
74
109
|
} catch {
|
|
75
110
|
return;
|
|
76
111
|
}
|
|
@@ -81,50 +116,40 @@ function parseRetryAfterHttpDateMs(value, nowMs = Date.now()) {
|
|
|
81
116
|
}
|
|
82
117
|
/** Parse all three HTTP-date forms while retaining leap-second ordering. */
|
|
83
118
|
function parseHttpDateInstant(value, nowMs = Date.now()) {
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
month
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
119
|
+
let fields = (IMF_FIXDATE_RE.exec(value) ?? OBSOLETE_RFC850_DATE_RE.exec(value))?.slice(1);
|
|
120
|
+
if (!fields) {
|
|
121
|
+
const asctimeDate = OBSOLETE_ASCTIME_DATE_RE.exec(value);
|
|
122
|
+
if (!asctimeDate) return;
|
|
123
|
+
const [, weekday, month, day, hours, minutes, seconds, year] = asctimeDate;
|
|
124
|
+
fields = [
|
|
125
|
+
weekday,
|
|
126
|
+
day,
|
|
127
|
+
month,
|
|
128
|
+
year,
|
|
129
|
+
hours,
|
|
130
|
+
minutes,
|
|
131
|
+
seconds
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
const [weekday, day, month, year, hours, minutes, seconds] = fields;
|
|
135
|
+
const components = {
|
|
136
|
+
weekday: HTTP_DATE_SHORT_WEEKDAY_INDEX.get((weekday ?? "").slice(0, 3)),
|
|
137
|
+
year: Number.parseInt(year ?? "", 10),
|
|
138
|
+
month: HTTP_DATE_MONTH_INDEX.get(month ?? ""),
|
|
139
|
+
day: Number.parseInt(day ?? "", 10),
|
|
140
|
+
hours: Number.parseInt(hours ?? "", 10),
|
|
141
|
+
minutes: Number.parseInt(minutes ?? "", 10),
|
|
142
|
+
seconds: Number.parseInt(seconds ?? "", 10)
|
|
143
|
+
};
|
|
144
|
+
if (year?.length === 2) {
|
|
96
145
|
const now = new Date(nowMs);
|
|
97
146
|
if (Number.isNaN(now.getTime())) return;
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
const components = {
|
|
101
|
-
weekday: HTTP_DATE_LONG_WEEKDAY_INDEX.get(rfc850Date[1] ?? ""),
|
|
102
|
-
month: HTTP_DATE_MONTH_INDEX.get(rfc850Date[3] ?? ""),
|
|
103
|
-
day: Number.parseInt(rfc850Date[2] ?? "", 10),
|
|
104
|
-
hours: Number.parseInt(rfc850Date[5] ?? "", 10),
|
|
105
|
-
minutes: Number.parseInt(rfc850Date[6] ?? "", 10),
|
|
106
|
-
seconds: Number.parseInt(rfc850Date[7] ?? "", 10)
|
|
107
|
-
};
|
|
108
|
-
const candidate = parseHttpDateCalendarMs({
|
|
109
|
-
year: candidateYear,
|
|
110
|
-
...components
|
|
111
|
-
});
|
|
147
|
+
components.year += Math.floor(now.getUTCFullYear() / 100) * 100;
|
|
148
|
+
const candidate = parseHttpDateCalendarMs(components);
|
|
112
149
|
if (candidate === void 0) return;
|
|
113
|
-
|
|
114
|
-
year: candidate > Date.UTC(now.getUTCFullYear() + 50, now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()) ? candidateYear - 100 : candidateYear,
|
|
115
|
-
...components
|
|
116
|
-
});
|
|
150
|
+
if (candidate > Date.UTC(now.getUTCFullYear() + 50, now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds())) components.year -= 100;
|
|
117
151
|
}
|
|
118
|
-
|
|
119
|
-
if (asctimeDate) return parseHttpDateComponents({
|
|
120
|
-
weekday: HTTP_DATE_SHORT_WEEKDAY_INDEX.get(asctimeDate[1] ?? ""),
|
|
121
|
-
year: Number.parseInt(asctimeDate[7] ?? "", 10),
|
|
122
|
-
month: HTTP_DATE_MONTH_INDEX.get(asctimeDate[2] ?? ""),
|
|
123
|
-
day: Number.parseInt((asctimeDate[3] ?? "").trim(), 10),
|
|
124
|
-
hours: Number.parseInt(asctimeDate[4] ?? "", 10),
|
|
125
|
-
minutes: Number.parseInt(asctimeDate[5] ?? "", 10),
|
|
126
|
-
seconds: Number.parseInt(asctimeDate[6] ?? "", 10)
|
|
127
|
-
});
|
|
152
|
+
return parseHttpDateComponents(components);
|
|
128
153
|
}
|
|
129
154
|
function parseHttpDateComponents(components) {
|
|
130
155
|
const timestamp = parseHttpDateCalendarMs(components);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import "../index-
|
|
2
|
-
import { M as ModelThinkingLevel, Q as SimpleStreamOptions, U as ProviderStreamOptions, a as AssistantMessage, d as Context, k as Model, n as Api, nt as StreamOptions, pt as Usage, s as AssistantMessageEventStreamContract } from "../types-
|
|
3
|
-
import { i as getEventStreamCompletion } from "../event-stream-
|
|
4
|
-
import { a as RegisteredApiProvider, t as ApiProvider } from "../api-registry-
|
|
5
|
-
import { m as getDefaultAiTransportHost } from "../host-
|
|
6
|
-
import "../types-
|
|
7
|
-
import { t as sanitizeSurrogates } from "../sanitize-unicode-
|
|
8
|
-
import { v as parseTerminalToolCallArguments } from "../transport-stream-shared-
|
|
1
|
+
import "../index-DSprYWaz.mjs";
|
|
2
|
+
import { M as ModelThinkingLevel, Q as SimpleStreamOptions, U as ProviderStreamOptions, a as AssistantMessage, d as Context, k as Model, n as Api, nt as StreamOptions, pt as Usage, s as AssistantMessageEventStreamContract } from "../types-CVYzKrMl.mjs";
|
|
3
|
+
import { i as getEventStreamCompletion } from "../event-stream-CzpE1g_o.mjs";
|
|
4
|
+
import { a as RegisteredApiProvider, t as ApiProvider } from "../api-registry-gDt0faai.mjs";
|
|
5
|
+
import { m as getDefaultAiTransportHost } from "../host-jJOffdlW.mjs";
|
|
6
|
+
import "../types-CBJthzJX.mjs";
|
|
7
|
+
import { n as isContextOverflow, t as sanitizeSurrogates } from "../sanitize-unicode-ZqVLLEKC.mjs";
|
|
8
|
+
import { v as parseTerminalToolCallArguments } from "../transport-stream-shared-8ru8eX4s.mjs";
|
|
9
9
|
//#region packages/ai/src/internal/default-runtime.d.ts
|
|
10
10
|
export declare const defaultApiRegistry: {
|
|
11
11
|
registerApiProvider: <TApi extends Api, TOptions extends StreamOptions>(provider: ApiProvider<TApi, TOptions>, sourceId?: string) => void;
|
|
@@ -87,8 +87,6 @@ export type SessionResourceCleanup = (sessionId?: string, owner?: SessionResourc
|
|
|
87
87
|
export declare function getSessionResourceOwnerId(owner: SessionResourceOwner): number;
|
|
88
88
|
/** Registers a session-resource cleanup hook and returns an unregister function. */
|
|
89
89
|
export declare function registerSessionResourceCleanup(cleanup: SessionResourceCleanup): () => void;
|
|
90
|
-
/** Registers metadata cleanup that runs only after every resource cleanup succeeds. */
|
|
91
|
-
export declare function registerSessionResourceCleanupObserver(observer: SessionResourceCleanup): () => void;
|
|
92
90
|
/** Runs all registered cleanup hooks, aggregating failures after every hook has run. */
|
|
93
91
|
export declare function cleanupSessionResources(sessionId?: string, owner?: SessionResourceOwner): void;
|
|
94
92
|
//#endregion
|
|
@@ -159,26 +157,6 @@ export type OpenAICodexJwtPayload = {
|
|
|
159
157
|
export declare function decodeOpenAICodexJwtPayload(token: string): OpenAICodexJwtPayload | null;
|
|
160
158
|
export declare function resolveOpenAICodexAccountId(token: string): string | null;
|
|
161
159
|
//#endregion
|
|
162
|
-
//#region packages/ai/src/utils/overflow.d.ts
|
|
163
|
-
declare const CONTEXT_OVERFLOW_PATTERN_SCOPES: {
|
|
164
|
-
readonly "assistant-error": RegExp[];
|
|
165
|
-
readonly "failover-explicit": RegExp[];
|
|
166
|
-
readonly "provider-fallback": RegExp[];
|
|
167
|
-
readonly "failover-hint": readonly [RegExp];
|
|
168
|
-
readonly "context-window-too-small": readonly [RegExp];
|
|
169
|
-
readonly "tpm-rate-limit-hint": readonly [RegExp];
|
|
170
|
-
readonly "rate-limit-hint": readonly [RegExp];
|
|
171
|
-
};
|
|
172
|
-
export type ContextOverflowMessageScope = keyof typeof CONTEXT_OVERFLOW_PATTERN_SCOPES;
|
|
173
|
-
/** Match one canonical context-overflow wording scope without applying caller policy. */
|
|
174
|
-
export declare function matchesContextOverflowMessage(errorMessage: string, scope: ContextOverflowMessageScope): boolean;
|
|
175
|
-
/**
|
|
176
|
-
* Match provider overflow errors, or infer overflow from reported context usage.
|
|
177
|
-
* A context window enables silent-overflow detection; silent truncation without
|
|
178
|
-
* a length stop remains undetectable because the original token count is unknown.
|
|
179
|
-
*/
|
|
180
|
-
export declare function isContextOverflow(message: AssistantMessage, contextWindow?: number): boolean;
|
|
181
|
-
//#endregion
|
|
182
160
|
//#region packages/markdown-core/src/reasoning-tag-parser.d.ts
|
|
183
161
|
type ReasoningTagTextDelta = {
|
|
184
162
|
kind: "text";
|
|
@@ -253,4 +231,4 @@ export declare function createSseByteGuard(reader: ReadableStreamDefaultReader<U
|
|
|
253
231
|
/** Lazily bound an SDK response while preserving upstream cancellation. */
|
|
254
232
|
export declare function boundResponseBody(response: Response, options: ReadSseStreamWithLimitOptions): Response;
|
|
255
233
|
//#endregion
|
|
256
|
-
export { type ReasoningTagTextDelta, type ReasoningTagTextPartitioner, complete, completeSimple, getApiProvider, getApiProviders, getEventStreamCompletion, parseTerminalToolCallArguments, sanitizeSurrogates, stream, streamSimple };
|
|
234
|
+
export { type ReasoningTagTextDelta, type ReasoningTagTextPartitioner, complete, completeSimple, getApiProvider, getApiProviders, getEventStreamCompletion, isContextOverflow, parseTerminalToolCallArguments, sanitizeSurrogates, stream, streamSimple };
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as createReasoningTagTextPartitioner } from "../reasoning-tag-text-partitioner-DzlRubwU.mjs";
|
|
2
2
|
import { o as getEventStreamCompletion } from "../event-stream-X2gmsUWv.mjs";
|
|
3
|
-
import { r as createApiRegistry, t as createLlmRuntime } from "../stream-
|
|
4
|
-
import { A as getSupportedThinkingLevels, D as applyProviderReportedUsageCost, E as headersToRecord, O as calculateCost, j as modelsAreEqual, k as clampThinkingLevel } from "../host-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { r as createApiRegistry, t as createLlmRuntime } from "../stream-DLBirT0e.mjs";
|
|
4
|
+
import { A as getSupportedThinkingLevels, D as applyProviderReportedUsageCost, E as headersToRecord, O as calculateCost, j as modelsAreEqual, k as clampThinkingLevel } from "../host-B2gk-d1H.mjs";
|
|
5
|
+
import { n as getSessionResourceOwnerId, r as registerSessionResourceCleanup, t as cleanupSessionResources } from "../session-resources-vKvGIE3J.mjs";
|
|
6
|
+
import { t as sanitizeSurrogates } from "../sanitize-unicode-CRGuMONI.mjs";
|
|
7
|
+
import { A as shortHash, D as parseJsonWithRepair, E as createToolArgumentPreviewSchedule, O as parseStreamingJson, g as parseTerminalToolCallArguments, k as repairJson } from "../transport-stream-shared-CzQlAzJH.mjs";
|
|
8
|
+
import { n as getEnvApiKey, t as findEnvKeys } from "../env-api-keys-Xd8dm_aV.mjs";
|
|
8
9
|
import { t as createDeferredEventBuffer } from "../deferred-event-buffer-DAvyP7qA.mjs";
|
|
9
10
|
import { n as onLlmRequestActivity, t as notifyLlmRequestActivity } from "../llm-request-activity-CfMuh5cC.mjs";
|
|
10
|
-
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, n as createFirstStreamEventTimeoutError, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "../stream-first-event-timeout-
|
|
11
|
+
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, n as createFirstStreamEventTimeoutError, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "../stream-first-event-timeout-D_TfJHRJ.mjs";
|
|
11
12
|
import { n as createSseByteGuard, t as boundResponseBody } from "../streaming-byte-guard-DBXr1XYn.mjs";
|
|
12
|
-
import { t as createReasoningTagTextPartitioner } from "../reasoning-tag-text-partitioner-CpOy9-IQ.mjs";
|
|
13
13
|
import { n as resolveOpenAICodexAccountId, t as decodeOpenAICodexJwtPayload } from "../openai-chatgpt-jwt-KWcgd0d_.mjs";
|
|
14
|
+
import { t as isContextOverflow } from "../overflow-DJHXTNBQ.mjs";
|
|
14
15
|
//#region packages/ai/src/internal/default-runtime.ts
|
|
15
16
|
const DEFAULT_RUNTIME_KEY = Symbol.for("openclaw.ai.defaultRuntime");
|
|
16
17
|
function resolveDefaultRuntime() {
|
|
@@ -30,111 +31,4 @@ const defaultLlmRuntime = defaultRuntime.runtime;
|
|
|
30
31
|
const { getApiProvider, getApiProviders } = defaultApiRegistry;
|
|
31
32
|
const { stream, complete, streamSimple, completeSimple } = defaultLlmRuntime;
|
|
32
33
|
//#endregion
|
|
33
|
-
|
|
34
|
-
const CONFIGURED_CONTEXT_SIZE_OVERFLOW_RE = /prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i;
|
|
35
|
-
const CONTEXT_OVERFLOW_PATTERN_SCOPES = {
|
|
36
|
-
"assistant-error": [
|
|
37
|
-
/prompt is too long/i,
|
|
38
|
-
/request_too_large/i,
|
|
39
|
-
/input length and `?max_tokens`? exceed context limit: [\d,]+ \+ [\d,]+ > [\d,]+/i,
|
|
40
|
-
/input is too long for requested model/i,
|
|
41
|
-
/exceeds the context window/i,
|
|
42
|
-
/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,
|
|
43
|
-
/input token count.*exceeds the maximum/i,
|
|
44
|
-
/maximum prompt length is \d+/i,
|
|
45
|
-
/reduce the length of the messages/i,
|
|
46
|
-
/maximum context length is \d+ tokens/i,
|
|
47
|
-
/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,
|
|
48
|
-
/input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,
|
|
49
|
-
/exceeds the limit of \d+/i,
|
|
50
|
-
/(?:exceeds the available context size|context size has been exceeded)/i,
|
|
51
|
-
/greater than the context length/i,
|
|
52
|
-
/context window exceeds limit/i,
|
|
53
|
-
/exceeded model token limit/i,
|
|
54
|
-
/tokens? in request more than max tokens? allowed/i,
|
|
55
|
-
/prompt exceeds max(?:imum)? length/i,
|
|
56
|
-
/too large for model with \d+ maximum context length/i,
|
|
57
|
-
CONFIGURED_CONTEXT_SIZE_OVERFLOW_RE,
|
|
58
|
-
/model_context_window_exceeded/i,
|
|
59
|
-
/prompt too long; exceeded (?:max )?context length/i,
|
|
60
|
-
/context[_ ]length[_ ]exceeded/i,
|
|
61
|
-
/too many tokens/i,
|
|
62
|
-
/token limit exceeded/i,
|
|
63
|
-
/^413\s*(?:status code)?\s*\(no body\)/i
|
|
64
|
-
],
|
|
65
|
-
"failover-explicit": [
|
|
66
|
-
/request_too_large/i,
|
|
67
|
-
/context_overflow/i,
|
|
68
|
-
CONFIGURED_CONTEXT_SIZE_OVERFLOW_RE,
|
|
69
|
-
/invalid_argument[\s\S]*maximum number of tokens/i,
|
|
70
|
-
/request exceeds the maximum size/i,
|
|
71
|
-
/context length exceeded/i,
|
|
72
|
-
/maximum context length/i,
|
|
73
|
-
/prompt is too long/i,
|
|
74
|
-
/prompt too long/i,
|
|
75
|
-
/exceeds model context window/i,
|
|
76
|
-
/model token limit/i,
|
|
77
|
-
/input exceeds[\s\S]*maximum number of tokens/i,
|
|
78
|
-
/^(?=[\s\S]*context window)(?=[\s\S]*ran out of (?:room|space))/i,
|
|
79
|
-
/request size exceeds[\s\S]*context window/i,
|
|
80
|
-
/context overflow:/i,
|
|
81
|
-
/exceed context limit/i,
|
|
82
|
-
/exceeds the model'?s maximum context/i,
|
|
83
|
-
/max_tokens[\s\S]*exceed[\s\S]*context/i,
|
|
84
|
-
/input(?: length[\s\S]*exceed[\s\S]*context| \([\d,]+\s*tokens?\) is longer than (?:the )?model'?s context length)/i,
|
|
85
|
-
/413[\s\S]*too large/i,
|
|
86
|
-
/context_window_exceeded/i,
|
|
87
|
-
/input length [\d,]+\s+tokens? exceeds the model limit/i,
|
|
88
|
-
/上下文过长|上下文超出|上下文长度超|超出最大上下文|请压缩上下文/
|
|
89
|
-
],
|
|
90
|
-
"provider-fallback": [
|
|
91
|
-
/\binput token count exceeds the maximum number of input tokens\b/i,
|
|
92
|
-
/\binput is too long for this model\b/i,
|
|
93
|
-
/\binput exceeds the maximum number of tokens\b/i,
|
|
94
|
-
/\bollama error:\s*context length exceeded(?:,\s*too many tokens)?\b/i,
|
|
95
|
-
/\btotal tokens?.*exceeds? (?:the )?(?:model(?:'s)? )?(?:max|maximum|limit)/i,
|
|
96
|
-
/\b(?:(?:request|prompt) \(\d[\d,]*\s*tokens?\) exceeds (?:the )?available context size|context size has been exceeded)\b/i,
|
|
97
|
-
/\binput (?:is )?too long for (?:the )?model\b/i
|
|
98
|
-
],
|
|
99
|
-
"failover-hint": [/context.*overflow|context window.*(too (?:large|long)|exceed|over|limit|max(?:imum)?|requested|sent|tokens)|prompt.*(too (?:large|long)|exceed|over|limit|max(?:imum)?)|(?:request|input).*(?:context|window|length|token).*(too (?:large|long)|exceed|over|limit|max(?:imum)?)/i],
|
|
100
|
-
"context-window-too-small": [/context window.*(too small|minimum is)/i],
|
|
101
|
-
"tpm-rate-limit-hint": [/\btpm\b|tokens per minute/i],
|
|
102
|
-
"rate-limit-hint": [/rate limit|too many requests|requests per (?:minute|hour|day)|quota|throttl|429\b|tokens per day/i]
|
|
103
|
-
};
|
|
104
|
-
/** Match one canonical context-overflow wording scope without applying caller policy. */
|
|
105
|
-
function matchesContextOverflowMessage(errorMessage, scope) {
|
|
106
|
-
return CONTEXT_OVERFLOW_PATTERN_SCOPES[scope].some((pattern) => pattern.test(errorMessage));
|
|
107
|
-
}
|
|
108
|
-
const NON_OVERFLOW_PATTERNS = [
|
|
109
|
-
/^(Throttling error|Service unavailable):/i,
|
|
110
|
-
/rate limit/i,
|
|
111
|
-
/too many requests/i
|
|
112
|
-
];
|
|
113
|
-
function resolveContextInputTokens(message) {
|
|
114
|
-
if (message.usage.contextUsage?.state === "available") return message.usage.contextUsage.promptTokens;
|
|
115
|
-
if (message.usage.contextUsage?.state === "unavailable") return;
|
|
116
|
-
return message.usage.input + message.usage.cacheRead + message.usage.cacheWrite;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Match provider overflow errors, or infer overflow from reported context usage.
|
|
120
|
-
* A context window enables silent-overflow detection; silent truncation without
|
|
121
|
-
* a length stop remains undetectable because the original token count is unknown.
|
|
122
|
-
*/
|
|
123
|
-
function isContextOverflow(message, contextWindow) {
|
|
124
|
-
if (isProviderRefusalAssistantError(message)) return false;
|
|
125
|
-
if (message.stopReason === "error" && message.errorMessage) {
|
|
126
|
-
const errorMessage = message.errorMessage;
|
|
127
|
-
if (!NON_OVERFLOW_PATTERNS.some((p) => p.test(errorMessage)) && matchesContextOverflowMessage(errorMessage, "assistant-error")) return true;
|
|
128
|
-
}
|
|
129
|
-
if (contextWindow && message.stopReason === "stop") {
|
|
130
|
-
const inputTokens = resolveContextInputTokens(message);
|
|
131
|
-
if (inputTokens !== void 0 && inputTokens > contextWindow) return true;
|
|
132
|
-
}
|
|
133
|
-
if (contextWindow && message.stopReason === "length" && message.usage.output === 0) {
|
|
134
|
-
const inputTokens = resolveContextInputTokens(message);
|
|
135
|
-
if (inputTokens !== void 0 && inputTokens >= contextWindow * .99) return true;
|
|
136
|
-
}
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
|
-
export { applyProviderReportedUsageCost, boundResponseBody, calculateCost, clampThinkingLevel, cleanupSessionResources, complete, completeSimple, createDeferredEventBuffer, createFirstStreamEventAbortController, createFirstStreamEventTimeoutError, createReasoningTagTextPartitioner, createSseByteGuard, createToolArgumentPreviewSchedule, decodeOpenAICodexJwtPayload, defaultApiRegistry, defaultLlmRuntime, findEnvKeys, getApiProvider, getApiProviders, getEnvApiKey, getEventStreamCompletion, getFirstStreamEventTimeoutHandler, getFirstStreamEventTimeoutMs, getSessionResourceOwnerId, getSupportedThinkingLevels, headersToRecord, isContextOverflow, matchesContextOverflowMessage, modelsAreEqual, notifyLlmRequestActivity, onLlmRequestActivity, parseJsonWithRepair, parseStreamingJson, parseTerminalToolCallArguments, registerSessionResourceCleanup, registerSessionResourceCleanupObserver, repairJson, resolveOpenAICodexAccountId, sanitizeSurrogates, shortHash, stream, streamSimple, withFirstStreamEventTimeout };
|
|
34
|
+
export { applyProviderReportedUsageCost, boundResponseBody, calculateCost, clampThinkingLevel, cleanupSessionResources, complete, completeSimple, createDeferredEventBuffer, createFirstStreamEventAbortController, createFirstStreamEventTimeoutError, createReasoningTagTextPartitioner, createSseByteGuard, createToolArgumentPreviewSchedule, decodeOpenAICodexJwtPayload, defaultApiRegistry, defaultLlmRuntime, findEnvKeys, getApiProvider, getApiProviders, getEnvApiKey, getEventStreamCompletion, getFirstStreamEventTimeoutHandler, getFirstStreamEventTimeoutMs, getSessionResourceOwnerId, getSupportedThinkingLevels, headersToRecord, isContextOverflow, modelsAreEqual, notifyLlmRequestActivity, onLlmRequestActivity, parseJsonWithRepair, parseStreamingJson, parseTerminalToolCallArguments, registerSessionResourceCleanup, repairJson, resolveOpenAICodexAccountId, sanitizeSurrogates, shortHash, stream, streamSimple, withFirstStreamEventTimeout };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { O as Message, Q as SimpleStreamOptions, a as AssistantMessage, at as ThinkingBudgets, k as Model, n as Api, nt as StreamOptions, st as ThinkingLevel } from "../types-
|
|
2
|
-
import { a as readAssistantThinkingAppend } from "../event-stream-
|
|
3
|
-
import "../
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { O as Message, Q as SimpleStreamOptions, a as AssistantMessage, at as ThinkingBudgets, k as Model, n as Api, nt as StreamOptions, st as ThinkingLevel } from "../types-CVYzKrMl.mjs";
|
|
2
|
+
import { a as readAssistantThinkingAppend } from "../event-stream-CzpE1g_o.mjs";
|
|
3
|
+
import { d as preparedRequestSuffix } from "../provider-options-DeYeaflL.mjs";
|
|
4
|
+
import "../types-CBJthzJX.mjs";
|
|
5
|
+
import { r as serializeModelRequestBody } from "../model-request-body-BD5vy4rP.mjs";
|
|
6
|
+
import { r as matchesContextOverflowMessage, t as sanitizeSurrogates } from "../sanitize-unicode-ZqVLLEKC.mjs";
|
|
7
|
+
import { i as projectProviderError } from "../provider-error-CnaWYTRY.mjs";
|
|
8
|
+
import { n as createDiagnosticRecord, r as isCredentialFieldName } from "../credential-redaction-XvsPf7Yi.mjs";
|
|
7
9
|
import { n as normalizeStructuredPromptSection, r as sortPromptCacheToolsByName, t as normalizePromptCapabilityIds } from "../prompt-cache-stability-Cwcjv_fx.mjs";
|
|
8
10
|
//#region packages/ai/src/providers/simple-options.d.ts
|
|
9
11
|
type FirstEventStreamOptions = {
|
|
@@ -117,4 +119,4 @@ export declare function projectCopilotRequestFacts(messages: readonly {
|
|
|
117
119
|
hasImages: boolean;
|
|
118
120
|
};
|
|
119
121
|
//#endregion
|
|
120
|
-
export { createDiagnosticRecord, isCredentialFieldName, normalizePromptCapabilityIds, normalizeStructuredPromptSection, projectProviderError, readAssistantThinkingAppend, sanitizeSurrogates, sortPromptCacheToolsByName };
|
|
122
|
+
export { createDiagnosticRecord, isCredentialFieldName, matchesContextOverflowMessage, normalizePromptCapabilityIds, normalizeStructuredPromptSection, preparedRequestSuffix, projectProviderError, readAssistantThinkingAppend, sanitizeSurrogates, serializeModelRequestBody, sortPromptCacheToolsByName };
|
package/dist/internal/shared.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { s as readAssistantThinkingAppend } from "../event-stream-X2gmsUWv.mjs";
|
|
2
|
-
import { M as hasMediaPayload, N as isImageWithMediaPayload, c as transformMessages, d as hasOnlyAssistantReasoningContent, f as isReasoningOnlyLengthAssistantTurn, l as FAILED_ASSISTANT_REPLAY_TEXT, m as resolveFailedAssistantReplay, p as isStreamErrorFallbackContent, u as STREAM_ERROR_FALLBACK_TEXT } from "../host-
|
|
3
|
-
import { i as isCredentialFieldName, n as projectProviderError, r as createDiagnosticRecord } from "../provider-error-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
2
|
+
import { M as hasMediaPayload, N as isImageWithMediaPayload, c as transformMessages, d as hasOnlyAssistantReasoningContent, f as isReasoningOnlyLengthAssistantTurn, l as FAILED_ASSISTANT_REPLAY_TEXT, m as resolveFailedAssistantReplay, p as isStreamErrorFallbackContent, u as STREAM_ERROR_FALLBACK_TEXT } from "../host-B2gk-d1H.mjs";
|
|
3
|
+
import { i as isCredentialFieldName, n as projectProviderError, r as createDiagnosticRecord } from "../provider-error-qtZD2inE.mjs";
|
|
4
|
+
import { t as sanitizeSurrogates } from "../sanitize-unicode-CRGuMONI.mjs";
|
|
5
|
+
import { n as normalizeStructuredPromptSection, r as sortPromptCacheToolsByName, t as normalizePromptCapabilityIds } from "../prompt-cache-stability-D_MeCQFI.mjs";
|
|
6
|
+
import { C as splitSystemPromptRelocatableBoundary, S as splitSystemPromptCacheBoundary, T as stripSystemPromptRelocatableBoundary, _ as SYSTEM_PROMPT_CACHE_BOUNDARY, b as ensureSystemPromptCacheBoundary, c as serializeModelRequestBody, d as extractToolResultBlockText, f as extractToolResultText, h as preparedRequestSuffix, i as clampReasoning, l as describeToolResultMediaPlaceholder, n as buildBaseOptions, p as formatToolResultText, r as clampMaxTokensToModel, t as adjustMaxTokensForThinking, u as describeUnsupportedToolResultMedia, v as SYSTEM_PROMPT_RELOCATABLE_BOUNDARY, w as stripSystemPromptCacheBoundary, x as prependSystemPromptAdditionAfterCacheBoundary, y as SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END } from "../simple-options-BYgC6kse.mjs";
|
|
7
|
+
import { t as projectCopilotRequestFacts } from "../github-copilot-request-facts-F-EmvkpW.mjs";
|
|
8
|
+
import { n as matchesContextOverflowMessage } from "../overflow-DJHXTNBQ.mjs";
|
|
7
9
|
//#region packages/ai/src/utils/tls-certificate-errors.ts
|
|
8
10
|
const HOSTNAME_MISMATCH_CODES = /* @__PURE__ */ new Set(["ERR_TLS_CERT_ALTNAME_INVALID", "HOSTNAME_MISMATCH"]);
|
|
9
11
|
const CERTIFICATE_INVALID_CODES = /* @__PURE__ */ new Set([
|
|
@@ -95,4 +97,4 @@ function inspectTlsCertificateError(error) {
|
|
|
95
97
|
return inspectTlsCertificateErrorInternal(error, /* @__PURE__ */ new Set(), 0);
|
|
96
98
|
}
|
|
97
99
|
//#endregion
|
|
98
|
-
export { FAILED_ASSISTANT_REPLAY_TEXT, STREAM_ERROR_FALLBACK_TEXT, SYSTEM_PROMPT_CACHE_BOUNDARY, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END, adjustMaxTokensForThinking, buildBaseOptions, clampMaxTokensToModel, clampReasoning, createDiagnosticRecord, describeToolResultMediaPlaceholder, describeUnsupportedToolResultMedia, ensureSystemPromptCacheBoundary, extractToolResultBlockText, extractToolResultText, formatToolResultText, hasMediaPayload, hasOnlyAssistantReasoningContent, inspectTlsCertificateError, isCredentialFieldName, isImageWithMediaPayload, isReasoningOnlyLengthAssistantTurn, isStreamErrorFallbackContent, normalizePromptCapabilityIds, normalizeStructuredPromptSection, prependSystemPromptAdditionAfterCacheBoundary, projectCopilotRequestFacts, projectProviderError, readAssistantThinkingAppend, resolveFailedAssistantReplay, sanitizeSurrogates, sortPromptCacheToolsByName, splitSystemPromptCacheBoundary, splitSystemPromptRelocatableBoundary, stripSystemPromptCacheBoundary, stripSystemPromptRelocatableBoundary, transformMessages };
|
|
100
|
+
export { FAILED_ASSISTANT_REPLAY_TEXT, STREAM_ERROR_FALLBACK_TEXT, SYSTEM_PROMPT_CACHE_BOUNDARY, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END, adjustMaxTokensForThinking, buildBaseOptions, clampMaxTokensToModel, clampReasoning, createDiagnosticRecord, describeToolResultMediaPlaceholder, describeUnsupportedToolResultMedia, ensureSystemPromptCacheBoundary, extractToolResultBlockText, extractToolResultText, formatToolResultText, hasMediaPayload, hasOnlyAssistantReasoningContent, inspectTlsCertificateError, isCredentialFieldName, isImageWithMediaPayload, isReasoningOnlyLengthAssistantTurn, isStreamErrorFallbackContent, matchesContextOverflowMessage, normalizePromptCapabilityIds, normalizeStructuredPromptSection, preparedRequestSuffix, prependSystemPromptAdditionAfterCacheBoundary, projectCopilotRequestFacts, projectProviderError, readAssistantThinkingAppend, resolveFailedAssistantReplay, sanitizeSurrogates, serializeModelRequestBody, sortPromptCacheToolsByName, splitSystemPromptCacheBoundary, splitSystemPromptRelocatableBoundary, stripSystemPromptCacheBoundary, stripSystemPromptRelocatableBoundary, transformMessages };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as OpenAIToolProjection } from "../provider-options-DeYeaflL.mjs";
|
|
2
|
+
import { a as prepareAnthropicInputSchema } from "../anthropic-tool-projection-DKH-aEWU.mjs";
|
|
2
3
|
import { TSchema } from "typebox";
|
|
3
4
|
//#region packages/ai/src/providers/agent-tools-parameter-schema.d.ts
|
|
4
5
|
/**
|
|
@@ -24,6 +25,7 @@ export declare function shouldOmitEmptyArrayItems(modelOrCompat: {
|
|
|
24
25
|
compat?: unknown;
|
|
25
26
|
} | ToolSchemaModelCompat | undefined): boolean;
|
|
26
27
|
export type ToolParameterSchemaOptions = {
|
|
28
|
+
toolName?: string;
|
|
27
29
|
modelProvider?: string;
|
|
28
30
|
modelId?: string;
|
|
29
31
|
modelCompat?: ToolSchemaModelCompat;
|
|
@@ -33,20 +35,88 @@ export declare function normalizeToolParameterSchema(schema: unknown, options?:
|
|
|
33
35
|
//#endregion
|
|
34
36
|
//#region packages/ai/src/providers/clean-for-gemini.d.ts
|
|
35
37
|
export declare const GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS: Set<string>;
|
|
36
|
-
export declare function cleanSchemaForGemini(schema: unknown): TSchema;
|
|
38
|
+
export declare function cleanSchemaForGemini(schema: unknown, toolName?: string): TSchema;
|
|
37
39
|
//#endregion
|
|
38
40
|
//#region packages/ai/src/providers/clean-for-llamacpp-gbnf.d.ts
|
|
39
41
|
/** llama.cpp rejects grammar repetitions whose expanded rule count reaches 2000. */
|
|
40
42
|
export declare const LLAMACPP_GBNF_MAX_REPETITION_THRESHOLD = 2000;
|
|
41
43
|
/** Removes JSON Schema constraints that llama.cpp cannot compile into GBNF. */
|
|
42
|
-
export declare function cleanSchemaForLlamacppGbnf(schema: unknown): unknown;
|
|
44
|
+
export declare function cleanSchemaForLlamacppGbnf(schema: unknown, toolName?: string): unknown;
|
|
43
45
|
/** Reports schema paths that llama.cpp cannot compile into GBNF. */
|
|
44
46
|
export declare function findLlamacppGbnfSchemaViolations(schema: unknown, path: string): string[];
|
|
45
47
|
//#endregion
|
|
48
|
+
//#region packages/ai/src/providers/openai-tool-schema-compat.d.ts
|
|
49
|
+
/** Repairs recoverable OpenAI tool-schema shapes before canonical normalization. */
|
|
50
|
+
export declare function normalizeOpenAIStrictCompatSchema(schema: unknown): TSchema;
|
|
51
|
+
/** Finds schema paths that violate OpenAI strict tool-schema requirements. */
|
|
52
|
+
export declare function findOpenAIStrictSchemaViolations(schema: unknown, path: string, options?: {
|
|
53
|
+
requireObjectRoot?: boolean;
|
|
54
|
+
}): string[];
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region packages/ai/src/providers/openai-tool-schema.d.ts
|
|
57
|
+
type ToolSchemaCompatInput = {
|
|
58
|
+
unsupportedToolSchemaKeywords?: unknown;
|
|
59
|
+
omitEmptyArrayItems?: unknown;
|
|
60
|
+
};
|
|
61
|
+
/** Normalizes a tool parameter schema into the OpenAI strict JSON-schema subset. */
|
|
62
|
+
export declare function normalizeStrictOpenAIJsonSchema(schema: unknown, modelCompat?: ToolSchemaCompatInput | null): unknown;
|
|
63
|
+
/** Normalizes tool parameters using strict OpenAI rules only when strict mode is active. */
|
|
64
|
+
export declare function normalizeOpenAIStrictToolParameters<T>(schema: T, strict: boolean, modelCompat?: ToolSchemaCompatInput | null): T;
|
|
65
|
+
/** Returns whether a schema already satisfies OpenAI strict tool-schema constraints. */
|
|
66
|
+
export declare function isStrictOpenAIJsonSchemaCompatible(schema: unknown): boolean;
|
|
67
|
+
type OpenAIStrictToolSchemaDiagnostic = {
|
|
68
|
+
toolIndex: number;
|
|
69
|
+
toolName?: string;
|
|
70
|
+
violations: string[];
|
|
71
|
+
};
|
|
72
|
+
/** Returns strict-schema diagnostics for an already materialized OpenAI tool projection. */
|
|
73
|
+
export declare function findOpenAIStrictToolProjectionDiagnostics(projection: OpenAIToolProjection): OpenAIStrictToolSchemaDiagnostic[];
|
|
74
|
+
/** Resolves strict mode for the projected tools that will be emitted in the request payload. */
|
|
75
|
+
export declare function resolveOpenAIProjectedToolsStrictToolFlag(projection: OpenAIToolProjection, strict: boolean | null | undefined): boolean | undefined;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region packages/ai/src/providers/openai-function-tool.d.ts
|
|
78
|
+
type OpenAIFunctionDescriptor = {
|
|
79
|
+
name: string;
|
|
80
|
+
description: string | undefined;
|
|
81
|
+
parameters: Record<string, unknown>;
|
|
82
|
+
strict?: boolean;
|
|
83
|
+
};
|
|
84
|
+
type PreparedOpenAIFunctionTool = {
|
|
85
|
+
responses: OpenAIFunctionDescriptor & {
|
|
86
|
+
type: "function";
|
|
87
|
+
};
|
|
88
|
+
completions: {
|
|
89
|
+
type: "function";
|
|
90
|
+
function: OpenAIFunctionDescriptor;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/** Reuse wire descriptors only when their parameter owner published immutable JSON. */
|
|
94
|
+
export declare function prepareOpenAIFunctionTool(name: string, description: string | undefined, parameters: Record<string, unknown>, strict: boolean | undefined): PreparedOpenAIFunctionTool;
|
|
95
|
+
//#endregion
|
|
46
96
|
//#region packages/ai/src/providers/schema-keyword-strip.d.ts
|
|
47
97
|
/** Remove schema keywords unsupported by a target provider/tool surface. */
|
|
48
98
|
export declare function stripUnsupportedSchemaKeywords(schema: unknown, unsupportedKeywords: ReadonlySet<string>): unknown;
|
|
49
99
|
//#endregion
|
|
100
|
+
//#region packages/ai/src/providers/tool-schema-depth.d.ts
|
|
101
|
+
/** Schema nodes and expanded references share this budget; containers are transparent. */
|
|
102
|
+
export declare const MAX_TOOL_SCHEMA_DEPTH = 128;
|
|
103
|
+
export type ToolSchemaPosition = {
|
|
104
|
+
kind: "schema" | "map" | "array" | "dependencies";
|
|
105
|
+
depth: number;
|
|
106
|
+
};
|
|
107
|
+
/** Classify children after toJSON when serializing, or directly when normalizing. */
|
|
108
|
+
export declare function toolSchemaChildPosition(position: ToolSchemaPosition | undefined, parent: object, key: string, child: unknown): ToolSchemaPosition | undefined;
|
|
109
|
+
export declare function wasToolSchemaTruncated(schema: unknown): boolean;
|
|
110
|
+
/** Preserve reduced-validation provenance across schema copies without repeating diagnostics. */
|
|
111
|
+
export declare function inheritToolSchemaTruncation<T>(source: unknown, result: T, truncated?: boolean): T;
|
|
112
|
+
export declare function reportToolSchemaTruncation(schema: unknown, toolName?: string): void;
|
|
113
|
+
/** Bound schema structure without changing literal data or caching mutable provider inputs. */
|
|
114
|
+
export declare function truncateToolSchemaDepth(schema: unknown, toolName?: string): unknown;
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region packages/ai/src/providers/schema-walk.d.ts
|
|
117
|
+
export declare const SCHEMA_MAP_KEYS: Set<string>;
|
|
118
|
+
export declare const SCHEMA_NESTED_KEYS: Set<string>;
|
|
119
|
+
//#endregion
|
|
50
120
|
//#region packages/ai/src/providers/tool-schema-json-projection.d.ts
|
|
51
121
|
/** JSON-safe schema value used when projecting runtime tool parameters. */
|
|
52
122
|
type RuntimeToolInputSchemaJson = null | boolean | number | string | RuntimeToolInputSchemaJson[] | {
|
|
@@ -57,7 +127,15 @@ type RuntimeToolInputSchemaProjection = {
|
|
|
57
127
|
readonly schema: RuntimeToolInputSchemaJson;
|
|
58
128
|
readonly violations: readonly string[];
|
|
59
129
|
};
|
|
130
|
+
type PublishedRuntimeToolInputSchema = {
|
|
131
|
+
readonly projection: RuntimeToolInputSchemaProjection;
|
|
132
|
+
readonly json: string;
|
|
133
|
+
readonly fingerprint: string;
|
|
134
|
+
};
|
|
135
|
+
export declare function getPublishedRuntimeToolInputSchema(schema: unknown): PublishedRuntimeToolInputSchema | undefined;
|
|
136
|
+
/** Only an owner's detached JSON publication can bypass later schema traversals. */
|
|
137
|
+
export declare function publishRuntimeToolInputSchema(schema: unknown, path?: string, toolName?: string): RuntimeToolInputSchemaProjection;
|
|
60
138
|
/** Projects one runtime tool input schema to JSON and reports runtime incompatibilities. */
|
|
61
|
-
export declare function projectRuntimeToolInputSchema(schema: unknown, path?: string): RuntimeToolInputSchemaProjection;
|
|
139
|
+
export declare function projectRuntimeToolInputSchema(schema: unknown, path?: string, toolName?: string): RuntimeToolInputSchemaProjection;
|
|
62
140
|
//#endregion
|
|
63
|
-
export { type RuntimeToolInputSchemaJson, type RuntimeToolInputSchemaProjection,
|
|
141
|
+
export { type RuntimeToolInputSchemaJson, type RuntimeToolInputSchemaProjection, prepareAnthropicInputSchema };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { _ as SCHEMA_MAP_KEYS, d as inheritToolSchemaTruncation, f as reportToolSchemaTruncation, h as wasToolSchemaTruncated, i as publishRuntimeToolInputSchema, m as truncateToolSchemaDepth, p as toolSchemaChildPosition, r as projectRuntimeToolInputSchema, t as getPublishedRuntimeToolInputSchema, u as MAX_TOOL_SCHEMA_DEPTH, v as SCHEMA_NESTED_KEYS } from "../tool-schema-json-projection-B0hHDV7N.mjs";
|
|
2
|
+
import { r as prepareAnthropicInputSchema } from "../anthropic-tool-projection-BdAS3rtJ.mjs";
|
|
3
|
+
import { _ as findLlamacppGbnfSchemaViolations, a as resolveOpenAIProjectedToolsStrictToolFlag, b as prepareOpenAIFunctionTool, c as extractToolSchemaModelCompat, d as shouldOmitEmptyArrayItems, g as cleanSchemaForLlamacppGbnf, h as LLAMACPP_GBNF_MAX_REPETITION_THRESHOLD, i as normalizeStrictOpenAIJsonSchema, l as normalizeToolParameterSchema, m as stripUnsupportedSchemaKeywords, n as isStrictOpenAIJsonSchemaCompatible, o as findOpenAIStrictSchemaViolations, r as normalizeOpenAIStrictToolParameters, s as normalizeOpenAIStrictCompatSchema, t as findOpenAIStrictToolProjectionDiagnostics, u as resolveUnsupportedToolSchemaKeywords, v as GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS, y as cleanSchemaForGemini } from "../openai-tool-schema-Buv0GXFb.mjs";
|
|
4
|
+
export { GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS, LLAMACPP_GBNF_MAX_REPETITION_THRESHOLD, MAX_TOOL_SCHEMA_DEPTH, SCHEMA_MAP_KEYS, SCHEMA_NESTED_KEYS, cleanSchemaForGemini, cleanSchemaForLlamacppGbnf, extractToolSchemaModelCompat, findLlamacppGbnfSchemaViolations, findOpenAIStrictSchemaViolations, findOpenAIStrictToolProjectionDiagnostics, getPublishedRuntimeToolInputSchema, inheritToolSchemaTruncation, isStrictOpenAIJsonSchemaCompatible, normalizeOpenAIStrictCompatSchema, normalizeOpenAIStrictToolParameters, normalizeStrictOpenAIJsonSchema, normalizeToolParameterSchema, prepareAnthropicInputSchema, prepareOpenAIFunctionTool, projectRuntimeToolInputSchema, publishRuntimeToolInputSchema, reportToolSchemaTruncation, resolveOpenAIProjectedToolsStrictToolFlag, resolveUnsupportedToolSchemaKeywords, shouldOmitEmptyArrayItems, stripUnsupportedSchemaKeywords, toolSchemaChildPosition, truncateToolSchemaDepth, wasToolSchemaTruncated };
|