@openclaw/ai 2026.9.6 → 2026.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{anthropic-DZQ_7gD1.mjs → anthropic-CTXJlfnS.mjs} +37 -66
- package/dist/{anthropic-payload-policy-DyfwikYJ.d.mts → anthropic-payload-policy-NIPVYXPq.d.mts} +7 -5
- package/dist/{anthropic-stream-reducer-D6ZI1wwj.mjs → anthropic-stream-reducer-DrsBCsFY.mjs} +192 -261
- package/dist/{api-registry-C2T3lTV7.d.mts → api-registry-D-nbmSqr.d.mts} +2 -2
- package/dist/{azure-openai-responses-DS86GYzq.mjs → azure-openai-responses-BBxv4QVI.mjs} +22 -33
- package/dist/{base64-CPmadnUf.mjs → base64-C1PsYcRQ.mjs} +15 -9
- package/dist/{diagnostics-CH8j2wIG.mjs → diagnostics-CJaB6g8J.mjs} +3 -3
- package/dist/diagnostics.d.mts +4 -4
- package/dist/diagnostics.mjs +2 -2
- package/dist/{env-api-keys-bktO00EJ.mjs → env-api-keys-CyX4VKGO.mjs} +7 -5
- package/dist/event-stream-CMQfX_yr.d.mts +1 -0
- package/dist/{event-stream-CjnIZZst.d.mts → event-stream-DOPFYVqs.d.mts} +2 -2
- package/dist/{event-stream-D8PARQfL.mjs → event-stream-vd9UnCAU.mjs} +10 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-BZJFjhuC.mjs → google-B3HEK0Ag.mjs} +8 -11
- package/dist/google-interactions-vMlEfPAA.mjs +574 -0
- package/dist/{google-messages-DB7GKkDk.mjs → google-messages-Dz2dAnGo.mjs} +35 -71
- package/dist/{google-shared-Bok4I6zB.mjs → google-shared-B58i3c8H.mjs} +43 -47
- package/dist/{google-vertex-3eVNR2qW.mjs → google-vertex-DYFXzEbh.mjs} +16 -30
- package/dist/{host-yTvBrYM2.mjs → host-DwBmNMCC.mjs} +29 -188
- package/dist/{host-policy-DZO3oPPk.mjs → host-policy-wK-ay_RK.mjs} +2 -14
- package/dist/{host-DH-Z-LDb.d.mts → host-rxlNaBwm.d.mts} +9 -3
- package/dist/{index-C25RT6bP.d.mts → index-D6KsSE74.d.mts} +28 -8
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +6 -6
- package/dist/internal/anthropic.d.mts +8 -7
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +31 -8
- package/dist/internal/openai.mjs +13 -13
- package/dist/internal/runtime.d.mts +31 -70
- package/dist/internal/runtime.mjs +10 -65
- package/dist/internal/shared.d.mts +14 -12
- package/dist/internal/shared.mjs +5 -4
- package/dist/internal/tool-schema.d.mts +1 -1
- package/dist/internal/tool-schema.mjs +2 -2
- package/dist/{mistral-C_13dVBn.mjs → mistral-7wDWcjfF.mjs} +46 -93
- package/dist/{openai-chatgpt-responses-sTxPl4zM.mjs → openai-chatgpt-responses-Bc7NZrQR.mjs} +26 -30
- package/dist/{openai-completions-BO6D_hrB.mjs → openai-completions-CHnwIV-W.mjs} +14 -12
- package/dist/{openai-completions-compat-CUollwl6.mjs → openai-completions-compat-BJf57ZxN.mjs} +3 -5
- package/dist/{openai-completions-compat-DfJG1wSO.d.mts → openai-completions-compat-qJjmqQ71.d.mts} +3 -3
- package/dist/{openai-completions-stream-BpuJ0ZOA.mjs → openai-completions-stream-dju_5F3P.mjs} +101 -173
- package/dist/{openai-prompt-cache-CjV_2IRI.mjs → openai-prompt-cache-BTMs80_O.mjs} +1 -1
- package/dist/{openai-prompt-cache-C4RHdN4n.d.mts → openai-prompt-cache-CouErLh7.d.mts} +2 -2
- package/dist/{openai-provider-client-BP8J1aeg.mjs → openai-provider-client-G8Otsq2Q.mjs} +2 -2
- package/dist/{openai-reasoning-effort-ash8dPrd.mjs → openai-reasoning-effort-C_0p3psG.mjs} +5 -4
- package/dist/{openai-responses-BJ_IEoMU.mjs → openai-responses-DbPe3-Py.mjs} +12 -11
- package/dist/openai-responses-compaction-replay-DiYn-gFM.d.mts +12 -0
- package/dist/{openai-responses-compaction-window-BiNCT0bS.mjs → openai-responses-compaction-window-CYGCjAQz.mjs} +5 -5
- package/dist/{openai-responses-contracts-DWrfMODE.mjs → openai-responses-contracts-CLxnqS9p.mjs} +1 -1
- package/dist/{openai-responses-contracts-B1ENJFpI.d.mts → openai-responses-contracts-D1iZ0njF.d.mts} +4 -4
- package/dist/{openai-responses-prompt-observer-internal-DPHWgbBH.mjs → openai-responses-prompt-observer-internal-BX3QTNSv.mjs} +12 -12
- package/dist/{openai-responses-request-lifecycle-DFuyO1pQ.mjs → openai-responses-request-lifecycle-Fsag-IGZ.mjs} +1 -1
- package/dist/{openai-responses-shared-DvSqtJ6_.mjs → openai-responses-shared-CIEHiKx7.mjs} +312 -122
- package/dist/{openai-responses-terminal-usage-BNFbvY9f.d.mts → openai-responses-terminal-usage-BE7lf7nW.d.mts} +2 -2
- package/dist/{openai-stop-reason-Drnn_6Qj.mjs → openai-stop-reason-8s70vDXj.mjs} +2 -12
- package/dist/{openai-tool-schema-ynZBgqW-.d.mts → openai-tool-schema-a5ysBBga.d.mts} +0 -6
- package/dist/{openai-tool-schema-D4BMcj2D.mjs → openai-tool-schema-vsl-cE-n.mjs} +243 -383
- package/dist/{openai-transport-params-DZKOTSfH.mjs → openai-transport-params-DyFJ4cgR.mjs} +60 -105
- package/dist/{positive-integer-BiUxrd71.mjs → positive-integer-CjN5OJbH.mjs} +1 -1
- package/dist/{provider-error-CRhW7lkJ.mjs → provider-error-CwT_j2v0.mjs} +43 -4
- package/dist/{provider-options-DZYq53lj.d.mts → provider-options-Df7ov0K1.d.mts} +2 -2
- package/dist/{provider-replay-context-DPr3w20a.mjs → provider-replay-context-Bs5aWE1d.mjs} +1 -1
- package/dist/{provider-transcript-transform-BTocjCRs.mjs → provider-transcript-transform-DjA5Fk2P.mjs} +17 -2
- package/dist/{provider-transport-turn-state-lrXEFkYr.mjs → provider-transport-turn-state-Dw7OtYUs.mjs} +1 -1
- package/dist/{provider-types-w1rEqrGP.d.mts → provider-types-d4XnoZMd.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +15 -11
- package/dist/{reasoning-tag-text-partitioner-Di38crhI.mjs → reasoning-tag-text-partitioner-B6FIIBt6.mjs} +47 -71
- package/dist/{record-coerce-DwRYMj3t.mjs → record-coerce-CNDovvft.mjs} +1 -1
- package/dist/simple-options-BkDPMuxw.mjs +349 -0
- package/dist/{src-DwGYYyZp.mjs → src-H4aXcFuX.mjs} +43 -25
- package/dist/{stream-CREqxHgU.mjs → stream-DDsCBgd-.mjs} +1 -7
- package/dist/{stream-first-event-timeout-BeptfRL6.mjs → stream-first-event-timeout-B9o0S4SZ.mjs} +1 -1
- package/dist/{tool-schema-json-projection-CD9c_fK8.mjs → tool-schema-json-projection-Ct8SeBeJ.mjs} +63 -23
- package/dist/{transport-stream-shared-B5RioB_Q.mjs → transport-stream-shared-BU5pwY6W.mjs} +62 -28
- package/dist/{transport-stream-shared-B7Z9oCYg.d.mts → transport-stream-shared-yYhXa4kX.d.mts} +12 -6
- package/dist/{transport-utils-03Qi0CN2.mjs → transport-utils-CqXzku3R.mjs} +3 -4
- package/dist/transports.d.mts +36 -32
- package/dist/transports.mjs +160 -216
- package/dist/types-CB-_vNyI.d.mts +1 -0
- package/dist/{types-qZFbaDbK.d.mts → types-CLLR3eB4.d.mts} +3 -1
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +4 -4
- package/dist/{validation-Dw7cb6BV.mjs → validation-BFZc40Ig.mjs} +80 -54
- package/dist/{validation-DhQhmt6t.d.mts → validation-Cat2wQsc.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +5 -5
- package/dist/assistant-output-DM1JBNs1.mjs +0 -16
- package/dist/event-stream-C0nsgbj2.d.mts +0 -1
- package/dist/simple-options-np1XPuhm.mjs +0 -175
- package/dist/types-DTvddOfm.d.mts +0 -1
- package/dist/utf16-slice-CvGodqok.mjs +0 -29
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./diagnostics-DzrF1h4J.mjs";
|
|
2
|
-
import "./validation-
|
|
2
|
+
import "./validation-BFZc40Ig.mjs";
|
|
3
3
|
//#region packages/llm-core/src/model-contracts/anthropic.ts
|
|
4
4
|
function normalizeClaudeModelId(modelId) {
|
|
5
5
|
const normalized = modelId?.trim().toLowerCase() ?? "";
|
|
@@ -31,43 +31,63 @@ const CLAUDE_SONNET_5_THINKING_PROFILE = {
|
|
|
31
31
|
};
|
|
32
32
|
const CLAUDE_OPUS_5_THINKING_PROFILE = CLAUDE_SONNET_5_THINKING_PROFILE;
|
|
33
33
|
const CLAUDE_OPUS_55_THINKING_PROFILE = CLAUDE_FABLE_5_THINKING_PROFILE;
|
|
34
|
+
const CLAUDE_SONNET_55_THINKING_PROFILE = {
|
|
35
|
+
levels: [
|
|
36
|
+
{ id: "off" },
|
|
37
|
+
{ id: "low" },
|
|
38
|
+
{ id: "medium" },
|
|
39
|
+
{ id: "high" },
|
|
40
|
+
{ id: "xhigh" },
|
|
41
|
+
{ id: "max" }
|
|
42
|
+
],
|
|
43
|
+
defaultLevel: "high"
|
|
44
|
+
};
|
|
34
45
|
/** Resolve the canonical normalized Claude model id for one runtime model ref. */
|
|
35
46
|
function resolveClaudeModelIdentity(ref) {
|
|
36
47
|
const normalized = normalizeClaudeModelId((typeof ref.params?.canonicalModelId === "string" ? ref.params.canonicalModelId : void 0) ?? ref.id);
|
|
37
48
|
return /(?:^|[-/])(claude-[^/]+)$/.exec(normalized)?.[1] ?? normalized;
|
|
38
49
|
}
|
|
50
|
+
function matchClaudeModelIdentity(normalized, pattern) {
|
|
51
|
+
const match = pattern.exec(normalized);
|
|
52
|
+
return match ? normalized.slice(match.index + (match[0].startsWith("-") ? 1 : 0)) : void 0;
|
|
53
|
+
}
|
|
39
54
|
/** Resolve Claude Fable 5 through direct ids, cloud ids, or deployment metadata. */
|
|
40
55
|
function resolveClaudeFable5ModelIdentity(ref) {
|
|
41
|
-
|
|
42
|
-
const match = /(?:^|-)claude-fable-5(?=$|[^a-z0-9])/.exec(normalized);
|
|
43
|
-
if (!match) return;
|
|
44
|
-
return normalized.slice((match.index ?? 0) + (match[0].startsWith("-") ? 1 : 0));
|
|
56
|
+
return matchClaudeModelIdentity(resolveClaudeModelIdentity(ref), /(?:^|-)claude-fable-5(?=$|[^a-z0-9])/);
|
|
45
57
|
}
|
|
46
58
|
/** Resolve Claude Mythos 5 through direct ids, cloud ids, or deployment metadata. */
|
|
47
59
|
function resolveClaudeMythos5ModelIdentity(ref) {
|
|
48
|
-
|
|
49
|
-
const match = /(?:^|-)claude-mythos-5(?=$|[^a-z0-9])/.exec(normalized);
|
|
50
|
-
if (!match) return;
|
|
51
|
-
return normalized.slice((match.index ?? 0) + (match[0].startsWith("-") ? 1 : 0));
|
|
60
|
+
return matchClaudeModelIdentity(resolveClaudeModelIdentity(ref), /(?:^|-)claude-mythos-5(?=$|[^a-z0-9])/);
|
|
52
61
|
}
|
|
53
62
|
/**
|
|
54
|
-
*
|
|
55
|
-
* only with live replay proof
|
|
63
|
+
* Opus 5.5, Sonnet 5.5, and Fable 5.1 require append-only runtime context.
|
|
64
|
+
* Extend only with live replay proof (Mythos 5.1 remains unproven).
|
|
56
65
|
*/
|
|
57
66
|
function bindsClaudeThinkingPrefix(ref) {
|
|
58
|
-
return resolveClaudeOpus55ModelIdentity(ref) !== void 0 || /^claude-fable-5-1(?=$|[^a-z0-9])/.test(resolveClaudeModelIdentity(ref));
|
|
67
|
+
return resolveClaudeOpus55ModelIdentity(ref) !== void 0 || resolveClaudeSonnet55ModelIdentity(ref) !== void 0 || /^claude-fable-5-1(?=$|[^a-z0-9])/.test(resolveClaudeModelIdentity(ref));
|
|
59
68
|
}
|
|
60
69
|
/** Return whether a Claude model requires adaptive thinking instead of manual budgets. */
|
|
61
70
|
function requiresClaudeMandatoryAdaptiveThinking(ref) {
|
|
62
71
|
const modelId = resolveClaudeModelIdentity(ref);
|
|
63
72
|
return resolveClaudeOpus55ModelIdentity(ref) !== void 0 || resolveClaudeFable5ModelIdentity(ref) !== void 0 || resolveClaudeMythos5ModelIdentity(ref) !== void 0 || /(?:^|-)claude-mythos-preview(?=$|[^a-z0-9])/.test(modelId);
|
|
64
73
|
}
|
|
65
|
-
/** Resolve Claude Sonnet 5 through direct ids, cloud ids, or deployment metadata. */
|
|
74
|
+
/** Resolve Claude Sonnet 5 through aliases, direct ids, cloud ids, or deployment metadata. */
|
|
66
75
|
function resolveClaudeSonnet5ModelIdentity(ref) {
|
|
67
76
|
const normalized = resolveClaudeModelIdentity(ref);
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
|
|
77
|
+
const sonnet55Identity = resolveClaudeSonnet55ModelIdentity(ref);
|
|
78
|
+
if (sonnet55Identity) return sonnet55Identity;
|
|
79
|
+
if (normalized === "sonnet-5") return "claude-sonnet-5";
|
|
80
|
+
return matchClaudeModelIdentity(normalized, /(?:^|-)claude-sonnet-5(?=$|[^a-z0-9])/);
|
|
81
|
+
}
|
|
82
|
+
/** Resolve the Sonnet 5.5 contract without matching other Sonnet 5 generations. */
|
|
83
|
+
function resolveClaudeSonnet55ModelIdentity(ref) {
|
|
84
|
+
const normalized = resolveClaudeModelIdentity(ref);
|
|
85
|
+
if (normalized === "sonnet" || normalized === "sonnet-5-5") return "claude-sonnet-5-5";
|
|
86
|
+
return /^claude-sonnet-5-5(?=$|[^a-z0-9])/.test(normalized) ? normalized : void 0;
|
|
87
|
+
}
|
|
88
|
+
/** Sonnet 5.5 replaces disabled thinking with between-tool progress updates. */
|
|
89
|
+
function requiresClaudeBetweenToolsThinking(ref) {
|
|
90
|
+
return resolveClaudeSonnet55ModelIdentity(ref) !== void 0;
|
|
71
91
|
}
|
|
72
92
|
/** Resolve Claude Opus 5 through aliases, direct ids, cloud ids, or deployment metadata. */
|
|
73
93
|
function resolveClaudeOpus5ModelIdentity(ref) {
|
|
@@ -75,25 +95,23 @@ function resolveClaudeOpus5ModelIdentity(ref) {
|
|
|
75
95
|
const opus55Identity = resolveClaudeOpus55ModelIdentity(ref);
|
|
76
96
|
if (opus55Identity) return opus55Identity;
|
|
77
97
|
if (normalized === "opus" || normalized === "opus-5") return "claude-opus-5";
|
|
78
|
-
|
|
79
|
-
if (!match) return;
|
|
80
|
-
return normalized.slice((match.index ?? 0) + (match[0].startsWith("-") ? 1 : 0));
|
|
98
|
+
return matchClaudeModelIdentity(normalized, /(?:^|-)claude-opus-5(?=$|[^a-z0-9])/);
|
|
81
99
|
}
|
|
82
100
|
/** Resolve the Opus 5.5 contract without matching other Opus 5 generations. */
|
|
83
101
|
function resolveClaudeOpus55ModelIdentity(ref) {
|
|
84
102
|
const normalized = resolveClaudeModelIdentity(ref);
|
|
85
|
-
if (normalized === "opus-5-5") return "claude-opus-5-5";
|
|
103
|
+
if (normalized === "opus" || normalized === "opus-5-5") return "claude-opus-5-5";
|
|
86
104
|
return /^claude-opus-5-5(?=$|[^a-z0-9])/.test(normalized) ? normalized : void 0;
|
|
87
105
|
}
|
|
88
106
|
/** Return whether a Claude model supports adaptive thinking. */
|
|
89
107
|
function supportsClaudeAdaptiveThinking(ref) {
|
|
90
108
|
const modelId = resolveClaudeModelIdentity(ref);
|
|
91
|
-
return resolveClaudeOpus5ModelIdentity(ref) !== void 0 || /(?:^|-)claude-(?:fable-5|mythos-(?:5|preview)|opus-4-(?:6|7|8)|sonnet-
|
|
109
|
+
return resolveClaudeOpus5ModelIdentity(ref) !== void 0 || resolveClaudeSonnet5ModelIdentity(ref) !== void 0 || /(?:^|-)claude-(?:fable-5|mythos-(?:5|preview)|opus-4-(?:6|7|8)|sonnet-4-6)(?=$|[^a-z0-9])/.test(modelId);
|
|
92
110
|
}
|
|
93
111
|
/** Return whether a Claude model has a native 1M-token context window. */
|
|
94
112
|
function supportsClaude1MContext(ref) {
|
|
95
113
|
const modelId = resolveClaudeModelIdentity(ref);
|
|
96
|
-
return resolveClaudeOpus5ModelIdentity(ref) !== void 0 || /(?:^|-)claude-(?:fable-5|mythos-(?:5|preview)|opus-4-(?:6|7|8)|sonnet-
|
|
114
|
+
return resolveClaudeOpus5ModelIdentity(ref) !== void 0 || resolveClaudeSonnet5ModelIdentity(ref) !== void 0 || /(?:^|-)claude-(?:fable-5|mythos-(?:5|preview)|opus-4-(?:6|7|8)|sonnet-4-6)(?=$|[^a-z0-9])/.test(modelId);
|
|
97
115
|
}
|
|
98
116
|
/** Return whether a Claude model supports Anthropic's native fast mode. */
|
|
99
117
|
function supportsClaudeFastMode(ref) {
|
|
@@ -103,12 +121,12 @@ function supportsClaudeFastMode(ref) {
|
|
|
103
121
|
/** Return whether a Claude model supports native max effort. */
|
|
104
122
|
function supportsClaudeNativeMaxEffort(ref) {
|
|
105
123
|
const modelId = resolveClaudeModelIdentity(ref);
|
|
106
|
-
return resolveClaudeOpus5ModelIdentity(ref) !== void 0 || /(?:^|-)claude-(?:fable-5|mythos-5|opus-4-(?:6|7|8)|sonnet-
|
|
124
|
+
return resolveClaudeOpus5ModelIdentity(ref) !== void 0 || resolveClaudeSonnet5ModelIdentity(ref) !== void 0 || /(?:^|-)claude-(?:fable-5|mythos-5|opus-4-(?:6|7|8)|sonnet-4-6)(?=$|[^a-z0-9])/.test(modelId);
|
|
107
125
|
}
|
|
108
126
|
/** Return whether a Claude model supports native xhigh effort. */
|
|
109
127
|
function supportsClaudeNativeXhighEffort(ref) {
|
|
110
128
|
const modelId = resolveClaudeModelIdentity(ref);
|
|
111
|
-
return resolveClaudeOpus5ModelIdentity(ref) !== void 0 || /(?:^|-)claude-(?:fable-5|mythos-5|opus-4-(?:7|8)
|
|
129
|
+
return resolveClaudeOpus5ModelIdentity(ref) !== void 0 || resolveClaudeSonnet5ModelIdentity(ref) !== void 0 || /(?:^|-)claude-(?:fable-5|mythos-5|opus-4-(?:7|8))(?=$|[^a-z0-9])/.test(modelId);
|
|
112
130
|
}
|
|
113
131
|
/** Return whether a Claude model rejects caller-selected sampling parameters. */
|
|
114
132
|
function requiresClaudeDefaultSampling(ref) {
|
|
@@ -201,4 +219,4 @@ function calculateUsageCost(usage, pricing) {
|
|
|
201
219
|
return cost;
|
|
202
220
|
}
|
|
203
221
|
//#endregion
|
|
204
|
-
export {
|
|
222
|
+
export { supportsClaudeFastMode as C, supportsClaudeAdaptiveThinking as S, supportsClaudeNativeXhighEffort as T, resolveClaudeOpus55ModelIdentity as _, CLAUDE_OPUS_55_THINKING_PROFILE as a, resolveClaudeSonnet5ModelIdentity as b, CLAUDE_SONNET_5_THINKING_PROFILE as c, requiresClaudeDefaultSampling as d, requiresClaudeMandatoryAdaptiveThinking as f, resolveClaudeNativeThinkingLevelMap as g, resolveClaudeMythos5ModelIdentity as h, CLAUDE_FABLE_5_THINKING_PROFILE as i, bindsClaudeThinkingPrefix as l, resolveClaudeModelIdentity as m, normalizeModelCostConfig as n, CLAUDE_OPUS_5_THINKING_PROFILE as o, resolveClaudeFable5ModelIdentity as p, normalizeResolvedPricing as r, CLAUDE_SONNET_55_THINKING_PROFILE as s, calculateUsageCost as t, requiresClaudeBetweenToolsThinking as u, resolveClaudeOpus5ModelIdentity as v, supportsClaudeNativeMaxEffort as w, supportsClaude1MContext as x, resolveClaudeSonnet55ModelIdentity as y };
|
|
@@ -5,12 +5,6 @@ function wrapStream(api, stream) {
|
|
|
5
5
|
return stream(model, context, options);
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
-
function wrapStreamSimple(api, streamSimple) {
|
|
9
|
-
return (model, context, options) => {
|
|
10
|
-
if (model.api !== api) throw new Error(`Mismatched api: ${model.api} expected ${api}`);
|
|
11
|
-
return streamSimple(model, context, options);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
8
|
/** Creates an isolated provider registry for one runtime or tenant. */
|
|
15
9
|
function createApiRegistry() {
|
|
16
10
|
const providers = /* @__PURE__ */ new Map();
|
|
@@ -19,7 +13,7 @@ function createApiRegistry() {
|
|
|
19
13
|
provider: {
|
|
20
14
|
api: provider.api,
|
|
21
15
|
stream: wrapStream(provider.api, provider.stream),
|
|
22
|
-
streamSimple:
|
|
16
|
+
streamSimple: wrapStream(provider.api, provider.streamSimple)
|
|
23
17
|
},
|
|
24
18
|
sourceId
|
|
25
19
|
});
|
package/dist/{stream-first-event-timeout-BeptfRL6.mjs → stream-first-event-timeout-B9o0S4SZ.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as clampTimerTimeoutMs } from "./base64-
|
|
1
|
+
import { a as clampTimerTimeoutMs } from "./base64-C1PsYcRQ.mjs";
|
|
2
2
|
//#region packages/ai/src/utils/stream-first-event-timeout.ts
|
|
3
3
|
function getFirstStreamEventTimeoutMs(options) {
|
|
4
4
|
return options?.firstEventTimeoutMs;
|
package/dist/{tool-schema-json-projection-CD9c_fK8.mjs → tool-schema-json-projection-Ct8SeBeJ.mjs}
RENAMED
|
@@ -1,6 +1,63 @@
|
|
|
1
|
-
import { o as isRecord } from "./record-coerce-
|
|
1
|
+
import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
2
|
import { t as expectDefined } from "./expect-lbe3Hgrh.mjs";
|
|
3
3
|
import { types } from "node:util";
|
|
4
|
+
//#region packages/ai/src/providers/schema-walk.ts
|
|
5
|
+
const SCHEMA_MAP_KEYS = /* @__PURE__ */ new Set([
|
|
6
|
+
"$defs",
|
|
7
|
+
"definitions",
|
|
8
|
+
"dependentSchemas",
|
|
9
|
+
"dependencies",
|
|
10
|
+
"patternProperties",
|
|
11
|
+
"properties"
|
|
12
|
+
]);
|
|
13
|
+
/** Containers whose value is a single nested schema. */
|
|
14
|
+
const SCHEMA_OBJECT_KEYS = /* @__PURE__ */ new Set([
|
|
15
|
+
"additionalItems",
|
|
16
|
+
"additionalProperties",
|
|
17
|
+
"contains",
|
|
18
|
+
"contentSchema",
|
|
19
|
+
"else",
|
|
20
|
+
"if",
|
|
21
|
+
"items",
|
|
22
|
+
"not",
|
|
23
|
+
"propertyNames",
|
|
24
|
+
"then",
|
|
25
|
+
"unevaluatedItems",
|
|
26
|
+
"unevaluatedProperties"
|
|
27
|
+
]);
|
|
28
|
+
/** Containers whose value is a list of nested schemas. */
|
|
29
|
+
const SCHEMA_ARRAY_KEYS = /* @__PURE__ */ new Set([
|
|
30
|
+
"allOf",
|
|
31
|
+
"anyOf",
|
|
32
|
+
"items",
|
|
33
|
+
"oneOf",
|
|
34
|
+
"prefixItems"
|
|
35
|
+
]);
|
|
36
|
+
/** Resume child schema walks on a heap stack, never through recursive yield delegation. */
|
|
37
|
+
function evaluateSchemaWalk(walk) {
|
|
38
|
+
const parents = [];
|
|
39
|
+
let current = walk;
|
|
40
|
+
let value;
|
|
41
|
+
try {
|
|
42
|
+
while (true) {
|
|
43
|
+
const step = current.next(value);
|
|
44
|
+
if (!step.done) {
|
|
45
|
+
parents.push(current);
|
|
46
|
+
current = step.value;
|
|
47
|
+
value = void 0;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
value = step.value;
|
|
51
|
+
const parent = parents.pop();
|
|
52
|
+
if (!parent) return value;
|
|
53
|
+
current = parent;
|
|
54
|
+
}
|
|
55
|
+
} finally {
|
|
56
|
+
let parent;
|
|
57
|
+
while (parent = parents.pop()) parent.return(void 0);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
4
61
|
//#region packages/ai/src/providers/tool-schema-json-projection.ts
|
|
5
62
|
function isNonFiniteNumberValue(value) {
|
|
6
63
|
if (typeof value === "number") return !Number.isFinite(value);
|
|
@@ -38,19 +95,10 @@ function serializeToolInputSchema(value, path, captureJson) {
|
|
|
38
95
|
isRoot = false;
|
|
39
96
|
return entry;
|
|
40
97
|
});
|
|
41
|
-
} catch {
|
|
42
|
-
|
|
43
|
-
schema: {},
|
|
44
|
-
violations: [`${path} is not JSON-serializable`]
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
if (!text) return {
|
|
98
|
+
} catch {}
|
|
99
|
+
if (!text || nonFiniteNumber.path !== null) return {
|
|
48
100
|
schema: {},
|
|
49
|
-
violations: [`${path} is not JSON-serializable`]
|
|
50
|
-
};
|
|
51
|
-
if (nonFiniteNumber.path !== null) return {
|
|
52
|
-
schema: {},
|
|
53
|
-
violations: [`${nonFiniteNumber.path} is not JSON-serializable`]
|
|
101
|
+
violations: [`${text ? nonFiniteNumber.path : path} is not JSON-serializable`]
|
|
54
102
|
};
|
|
55
103
|
const schema = JSON.parse(text);
|
|
56
104
|
captureJson?.(text);
|
|
@@ -59,14 +107,6 @@ function serializeToolInputSchema(value, path, captureJson) {
|
|
|
59
107
|
violations: []
|
|
60
108
|
};
|
|
61
109
|
}
|
|
62
|
-
const schemaMapKeywords = /* @__PURE__ */ new Set([
|
|
63
|
-
"$defs",
|
|
64
|
-
"definitions",
|
|
65
|
-
"dependencies",
|
|
66
|
-
"dependentSchemas",
|
|
67
|
-
"patternProperties",
|
|
68
|
-
"properties"
|
|
69
|
-
]);
|
|
70
110
|
function inspectJsonSchema(schema, path, violations) {
|
|
71
111
|
if (Array.isArray(schema)) {
|
|
72
112
|
let index = 0;
|
|
@@ -85,7 +125,7 @@ function inspectJsonSchema(schema, path, violations) {
|
|
|
85
125
|
if (typeof value === "number" && !Number.isFinite(value)) return false;
|
|
86
126
|
if (!value || typeof value !== "object") continue;
|
|
87
127
|
path.push(".", key);
|
|
88
|
-
if (
|
|
128
|
+
if (SCHEMA_MAP_KEYS.has(key) && isRecord(value)) for (const schemaName of Object.keys(value)) {
|
|
89
129
|
const childSchema = value[schemaName];
|
|
90
130
|
if (childSchema === void 0) return false;
|
|
91
131
|
path.push(".", schemaName);
|
|
@@ -131,4 +171,4 @@ function projectToolInputSchema(schema, path, captureJson) {
|
|
|
131
171
|
};
|
|
132
172
|
}
|
|
133
173
|
//#endregion
|
|
134
|
-
export { projectRuntimeToolInputSchema as n, prepareRuntimeToolInputSchema as t };
|
|
174
|
+
export { SCHEMA_OBJECT_KEYS as a, SCHEMA_MAP_KEYS as i, projectRuntimeToolInputSchema as n, evaluateSchemaWalk as o, SCHEMA_ARRAY_KEYS as r, prepareRuntimeToolInputSchema as t };
|
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
import { n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
|
|
2
|
-
import { i as createAssistantMessageEventStream } from "./event-stream-
|
|
3
|
-
import { i as asOptionalRecord, n as asNullableRecord, t as asNonArrayRecord } from "./record-coerce-
|
|
4
|
-
import {
|
|
5
|
-
import { i as projectDiagnosticValue, n as projectProviderError } from "./provider-error-
|
|
6
|
-
import { c as isTransientNetworkError } from "./diagnostics-
|
|
2
|
+
import { i as createAssistantMessageEventStream } from "./event-stream-vd9UnCAU.mjs";
|
|
3
|
+
import { i as asOptionalRecord, n as asNullableRecord, t as asNonArrayRecord } from "./record-coerce-CNDovvft.mjs";
|
|
4
|
+
import { S as headersToRecord, n as getAiTransportHost } from "./host-DwBmNMCC.mjs";
|
|
5
|
+
import { i as projectDiagnosticValue, n as projectProviderError } from "./provider-error-CwT_j2v0.mjs";
|
|
6
|
+
import { c as isTransientNetworkError } from "./diagnostics-CJaB6g8J.mjs";
|
|
7
7
|
import { parse } from "partial-json";
|
|
8
|
+
//#region packages/ai/src/utils/sanitize-unicode.ts
|
|
9
|
+
/**
|
|
10
|
+
* Removes unpaired Unicode surrogate characters from a string.
|
|
11
|
+
*
|
|
12
|
+
* Unpaired surrogates (high surrogates 0xD800-0xDBFF without matching low surrogates 0xDC00-0xDFFF,
|
|
13
|
+
* or vice versa) cause JSON serialization errors in many API providers.
|
|
14
|
+
*
|
|
15
|
+
* Valid emoji and other characters outside the Basic Multilingual Plane use properly paired
|
|
16
|
+
* surrogates and will NOT be affected by this function.
|
|
17
|
+
*
|
|
18
|
+
* @param text - The text to sanitize
|
|
19
|
+
* @returns The sanitized text with unpaired surrogates removed
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Valid emoji (properly paired surrogates) are preserved
|
|
23
|
+
* sanitizeSurrogates("Hello 🙈 World") // => "Hello 🙈 World"
|
|
24
|
+
*
|
|
25
|
+
* // Unpaired high surrogate is removed
|
|
26
|
+
* const unpaired = String.fromCharCode(0xD83D); // high surrogate without low
|
|
27
|
+
* sanitizeSurrogates(`Text ${unpaired} here`) // => "Text here"
|
|
28
|
+
*/
|
|
29
|
+
function sanitizeSurrogates(text) {
|
|
30
|
+
if (text.isWellFormed()) return text;
|
|
31
|
+
return text.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "");
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
8
34
|
//#region packages/ai/src/utils/hash.ts
|
|
9
35
|
/** Fast deterministic hash to shorten long strings */
|
|
10
36
|
function shortHash(str) {
|
|
@@ -43,16 +69,6 @@ function isControlCharacter(char) {
|
|
|
43
69
|
const codePoint = char.codePointAt(0);
|
|
44
70
|
return codePoint !== void 0 && codePoint >= 0 && codePoint <= 31;
|
|
45
71
|
}
|
|
46
|
-
function escapeControlCharacter(char) {
|
|
47
|
-
switch (char) {
|
|
48
|
-
case "\b": return "\\b";
|
|
49
|
-
case "\f": return "\\f";
|
|
50
|
-
case "\n": return "\\n";
|
|
51
|
-
case "\r": return "\\r";
|
|
52
|
-
case " ": return "\\t";
|
|
53
|
-
default: return `\\u${char.codePointAt(0)?.toString(16).padStart(4, "0") ?? "0000"}`;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
72
|
/**
|
|
57
73
|
* Repairs malformed JSON string literals by:
|
|
58
74
|
* - escaping raw control characters inside strings
|
|
@@ -121,7 +137,7 @@ function repairJson(json, options) {
|
|
|
121
137
|
stringValuePrefix += "\\";
|
|
122
138
|
continue;
|
|
123
139
|
}
|
|
124
|
-
repaired += isControlCharacter(char) ?
|
|
140
|
+
repaired += isControlCharacter(char) ? JSON.stringify(char).slice(1, -1) : char;
|
|
125
141
|
stringValuePrefix += char;
|
|
126
142
|
}
|
|
127
143
|
return repaired;
|
|
@@ -347,17 +363,6 @@ function mergeTransportHeaders(...headerSources) {
|
|
|
347
363
|
}
|
|
348
364
|
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
349
365
|
}
|
|
350
|
-
function mergeTransportMetadata(payload, metadata) {
|
|
351
|
-
if (!metadata || Object.keys(metadata).length === 0) return payload;
|
|
352
|
-
const existingMetadata = asOptionalRecord(payload.metadata);
|
|
353
|
-
return {
|
|
354
|
-
...payload,
|
|
355
|
-
metadata: {
|
|
356
|
-
...existingMetadata,
|
|
357
|
-
...metadata
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
366
|
function createEmptyTransportUsage() {
|
|
362
367
|
return {
|
|
363
368
|
input: 0,
|
|
@@ -395,6 +400,35 @@ function transportAbortError(signal) {
|
|
|
395
400
|
const reason = signal?.reason;
|
|
396
401
|
return reason instanceof Error && typeof reason.code === "string" ? reason : /* @__PURE__ */ new Error("Request was aborted");
|
|
397
402
|
}
|
|
403
|
+
const MODEL_STREAM_COOPERATIVE_YIELD_INTERVAL_MS = 12;
|
|
404
|
+
const MODEL_STREAM_COOPERATIVE_YIELD_MAX_EVENTS = 64;
|
|
405
|
+
function throwIfModelStreamAborted(signal) {
|
|
406
|
+
if (signal?.aborted) throw transportAbortError(signal);
|
|
407
|
+
}
|
|
408
|
+
function createModelStreamCooperativeScheduler(signal) {
|
|
409
|
+
let lastYieldedAt = Date.now();
|
|
410
|
+
let eventsSinceYield = 0;
|
|
411
|
+
return { async afterEvent() {
|
|
412
|
+
throwIfModelStreamAborted(signal);
|
|
413
|
+
eventsSinceYield += 1;
|
|
414
|
+
if (eventsSinceYield < MODEL_STREAM_COOPERATIVE_YIELD_MAX_EVENTS && Date.now() - lastYieldedAt < MODEL_STREAM_COOPERATIVE_YIELD_INTERVAL_MS) return;
|
|
415
|
+
eventsSinceYield = 0;
|
|
416
|
+
await new Promise((resolve) => {
|
|
417
|
+
setTimeout(resolve, 0);
|
|
418
|
+
});
|
|
419
|
+
throwIfModelStreamAborted(signal);
|
|
420
|
+
lastYieldedAt = Date.now();
|
|
421
|
+
} };
|
|
422
|
+
}
|
|
423
|
+
/** Keep ready provider events from monopolizing the main loop, including ignored events. */
|
|
424
|
+
async function* iterateModelStream(events, signal) {
|
|
425
|
+
const scheduler = createModelStreamCooperativeScheduler(signal);
|
|
426
|
+
for await (const event of events) {
|
|
427
|
+
throwIfModelStreamAborted(signal);
|
|
428
|
+
yield event;
|
|
429
|
+
await scheduler.afterEvent();
|
|
430
|
+
}
|
|
431
|
+
}
|
|
398
432
|
const providerAcceptanceObserver = Symbol("openclaw.providerAcceptanceObserver");
|
|
399
433
|
function readProviderAcceptanceObserver(options) {
|
|
400
434
|
if (options === null || typeof options !== "object") return;
|
|
@@ -556,4 +590,4 @@ function failTransportStream(params) {
|
|
|
556
590
|
stream.end();
|
|
557
591
|
}
|
|
558
592
|
//#endregion
|
|
559
|
-
export {
|
|
593
|
+
export { shortHash as A, parseJsonObjectPreservingUnsafeIntegers as C, parseJsonWithRepair as D, createToolArgumentPreviewSchedule as E, 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, sanitizeSurrogates 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/{transport-stream-shared-B7Z9oCYg.d.mts → transport-stream-shared-yYhXa4kX.d.mts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { O as Model, V as ProviderResponse, Y as StreamOptions, a as AssistantMessage, ot as Usage } from "./types-
|
|
3
|
-
import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
4
|
-
import "./event-stream-
|
|
1
|
+
import "./index-D6KsSE74.mjs";
|
|
2
|
+
import { O as Model, V as ProviderResponse, Y as StreamOptions, a as AssistantMessage, ot as Usage } from "./types-CLLR3eB4.mjs";
|
|
3
|
+
import { r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-DOPFYVqs.mjs";
|
|
4
|
+
import "./event-stream-CMQfX_yr.mjs";
|
|
5
5
|
import { t as ProviderErrorProjection } from "./provider-error-xumb1V3F.mjs";
|
|
6
6
|
//#region packages/ai/src/transports/transport-stream-shared.d.ts
|
|
7
7
|
type ContextUsage = NonNullable<Usage["contextUsage"]>;
|
|
@@ -43,7 +43,6 @@ declare function finalizeTerminalToolCallArguments<T extends {
|
|
|
43
43
|
repairStringLiterals?: boolean;
|
|
44
44
|
}): void;
|
|
45
45
|
declare function mergeTransportHeaders(...headerSources: Array<Record<string, string> | undefined>): Record<string, string> | undefined;
|
|
46
|
-
declare function mergeTransportMetadata<T extends Record<string, unknown>>(payload: T, metadata?: Record<string, string>): T;
|
|
47
46
|
declare function createEmptyTransportUsage(): TransportUsage;
|
|
48
47
|
declare function createWritableTransportEventStream(): {
|
|
49
48
|
eventStream: AssistantMessageEventStream;
|
|
@@ -60,6 +59,13 @@ declare function createWritableTransportEventStream(): {
|
|
|
60
59
|
* already emits rather than churning it.
|
|
61
60
|
*/
|
|
62
61
|
declare function transportAbortError(signal?: AbortSignal): Error;
|
|
62
|
+
type ModelStreamCooperativeScheduler = {
|
|
63
|
+
afterEvent: () => Promise<void>;
|
|
64
|
+
};
|
|
65
|
+
declare function throwIfModelStreamAborted(signal?: AbortSignal): void;
|
|
66
|
+
declare function createModelStreamCooperativeScheduler(signal?: AbortSignal): ModelStreamCooperativeScheduler;
|
|
67
|
+
/** Keep ready provider events from monopolizing the main loop, including ignored events. */
|
|
68
|
+
declare function iterateModelStream<T>(events: AsyncIterable<T> | Iterable<T>, signal?: AbortSignal): AsyncGenerator<T>;
|
|
63
69
|
type ProviderAcceptance = {
|
|
64
70
|
kind: "http_response";
|
|
65
71
|
status: number;
|
|
@@ -119,4 +125,4 @@ declare function failTransportStream(params: {
|
|
|
119
125
|
cleanup?: () => void;
|
|
120
126
|
}): void;
|
|
121
127
|
//#endregion
|
|
122
|
-
export {
|
|
128
|
+
export { withProviderAcceptanceObserver as C, transportAbortError as S, notifyProviderStreamOpened as _, coerceTransportToolCallArguments as a, sanitizeTransportPayloadText as b, createModelStreamCooperativeScheduler as c, finalizeTerminalToolCallArguments as d, finalizeTransportStream as f, notifyProviderHttpResponse as g, notifyProviderHttpMetadata as h, assignTransportErrorDetails as i, createWritableTransportEventStream as l, mergeTransportHeaders as m, ProviderAcceptance as n, copyProviderAcceptanceObserver as o, iterateModelStream as p, WritableTransportStream as r, createEmptyTransportUsage as s, IncompleteToolCallError as t, failTransportStream as u, parseTerminalToolCallArguments as v, withProviderResponseHook as w, throwIfModelStreamAborted as x, sanitizeNonEmptyTransportPayloadText as y };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { n as getAiTransportHost } from "./host-
|
|
2
|
-
import {
|
|
3
|
-
import "./provider-error-CRhW7lkJ.mjs";
|
|
1
|
+
import { n as getAiTransportHost } from "./host-DwBmNMCC.mjs";
|
|
2
|
+
import { o as truncateUtf16Safe } from "./provider-error-CwT_j2v0.mjs";
|
|
4
3
|
import "./internal/retry-after.mjs";
|
|
5
|
-
import "./positive-integer-
|
|
4
|
+
import "./positive-integer-CjN5OJbH.mjs";
|
|
6
5
|
//#region packages/normalization-core/src/response-bytes.ts
|
|
7
6
|
async function consumeResponseBytes(options) {
|
|
8
7
|
let size = 0;
|
package/dist/transports.d.mts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { $ as ThinkingContent, B as ProviderReplayState, K as StopReason, M as OpenAICompletionsCompat, O as Model, X as TextContent, Y as StreamOptions, _t as ModelDataThinkingFormat, a as AssistantMessage, d as Context, l as CacheRetention, n as Api, nt as Tool, ot as Usage, q as StreamFn, rt as ToolCall } from "./types-
|
|
3
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
4
|
-
import {
|
|
1
|
+
import "./index-D6KsSE74.mjs";
|
|
2
|
+
import { $ as ThinkingContent, B as ProviderReplayState, K as StopReason, M as OpenAICompletionsCompat, O as Model, X as TextContent, Y as StreamOptions, _t as ModelDataThinkingFormat, a as AssistantMessage, d as Context, l as CacheRetention, n as Api, nt as Tool, ot as Usage, q as StreamFn, rt as ToolCall } from "./types-CLLR3eB4.mjs";
|
|
3
|
+
import { n as ApiRegistry } from "./api-registry-D-nbmSqr.mjs";
|
|
4
|
+
import { o as AiProviderStreamHookContext } from "./host-rxlNaBwm.mjs";
|
|
5
|
+
import { a as BaseOpenAIStreamOptions, c as OpenAIResponsesCompactionRejection, o as CodeModeToolSurfaceObservation, s as OpenAICompletionsOptions } from "./provider-options-Df7ov0K1.mjs";
|
|
5
6
|
import { n as OpenAIToolProjection } from "./openai-tool-projection-793cE3QX.mjs";
|
|
6
|
-
import "./types-
|
|
7
|
-
import { a as buildAnthropicSystemBlocks, c as logAnthropicContextEdits, d as
|
|
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-
|
|
9
|
-
import {
|
|
7
|
+
import "./types-CB-_vNyI.mjs";
|
|
8
|
+
import { a as buildAnthropicSystemBlocks, c as logAnthropicContextEdits, d as resolveAnthropicPayloadPolicy, f as resolveAnthropicRequestBetaHeader, i as applyAnthropicRequestCacheControl, l as resolveAnthropicCacheOptions, 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-NIPVYXPq.mjs";
|
|
9
|
+
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-qJjmqQ71.mjs";
|
|
10
|
+
import { n as OpenAIResponsesOptions, r as OpenAIResponsesReasoningReplayMetadata, s as OpenAIResponsesCompactionOutput } from "./openai-responses-contracts-D1iZ0njF.mjs";
|
|
10
11
|
import { i as resolveOpenAIResponsesServerCompactionPlan, n as resolveOpenAIResponsesCompactEndpointPlan, r as resolveOpenAIResponsesPayloadPolicy, t as applyOpenAIResponsesPayloadPolicy } from "./openai-responses-payload-policy-C7GsA1y0.mjs";
|
|
11
|
-
import {
|
|
12
|
+
import { n as captureOpenAIResponsesCompaction, t as CompactionReplayRefreshRequiredError } from "./openai-responses-compaction-replay-DiYn-gFM.mjs";
|
|
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-yYhXa4kX.mjs";
|
|
12
14
|
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-Cwcjv_fx.mjs";
|
|
13
|
-
import { r as normalizeOpenAIStrictToolParameters } from "./openai-tool-schema-
|
|
14
|
-
import { d as VideoContent, i as ProviderContext, s as ProviderModel } from "./provider-types-
|
|
15
|
+
import { r as normalizeOpenAIStrictToolParameters } from "./openai-tool-schema-a5ysBBga.mjs";
|
|
16
|
+
import { d as VideoContent, i as ProviderContext, s as ProviderModel } from "./provider-types-d4XnoZMd.mjs";
|
|
15
17
|
import { a as resolveModelSseDebugMode, i as resolveModelPayloadDebugMode, n as formatModelTransportDebugUrl, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./model-transport-url-C5f59L3Y.mjs";
|
|
16
18
|
import OpenAI from "openai";
|
|
17
19
|
import { Part } from "@google/genai";
|
|
18
|
-
import "openai/resources/responses/responses.js";
|
|
19
20
|
import { ChatCompletionChunk } from "openai/resources/chat/completions.js";
|
|
20
21
|
//#region packages/ai/src/transports/anthropic-transport-stream.d.ts
|
|
21
22
|
/** Resolve the Anthropic Messages endpoint URL for the effective base URL. */
|
|
@@ -143,16 +144,11 @@ export declare function parseOpenAICompletionsUsage(rawUsage: NonNullable<ChatCo
|
|
|
143
144
|
}): MutableAssistantOutput["usage"];
|
|
144
145
|
export declare function createOpenAIResponseHook(onResponse: BaseOpenAIStreamOptions["onResponse"], response: Response, model: Model): (() => void | Promise<void>) | undefined;
|
|
145
146
|
export declare function createOpenAIProviderAcceptanceHook(options: Pick<BaseOpenAIStreamOptions, "onResponse" | "signal"> | undefined, response: Response, model: Model): () => Promise<void>;
|
|
146
|
-
type ModelStreamCooperativeScheduler = {
|
|
147
|
-
afterEvent: () => Promise<void>;
|
|
148
|
-
};
|
|
149
|
-
export declare function throwIfModelStreamAborted(signal?: AbortSignal): void;
|
|
150
147
|
/** Measure one UTF-8 append without double-counting a surrogate pair split across chunks. */
|
|
151
148
|
export declare function measureUtf8AppendBytes(bufferEndsWithHighSurrogate: boolean, chunk: string): {
|
|
152
149
|
bytes: number;
|
|
153
150
|
endsWithHighSurrogate: boolean;
|
|
154
151
|
};
|
|
155
|
-
export declare function createModelStreamCooperativeScheduler(signal?: AbortSignal): ModelStreamCooperativeScheduler;
|
|
156
152
|
export declare function resolvePromptCacheKey(options: Pick<BaseOpenAIStreamOptions, "promptCacheKey" | "sessionId"> | undefined, cacheRetention: "short" | "long" | "none"): string | undefined;
|
|
157
153
|
export declare function isOpenAICompletionsThinkingEnabled(effort: string): boolean;
|
|
158
154
|
export declare function readOpenAICompletionsContentDeltas(content: unknown, topLevelRefusal?: unknown, mirroredThinking?: readonly string[]): OpenAICompletionsContentDelta[];
|
|
@@ -201,6 +197,18 @@ export declare function resolveReplayableResponsesMessageId(params: {
|
|
|
201
197
|
previousReplayItemWasReasoning: boolean;
|
|
202
198
|
}): string | undefined;
|
|
203
199
|
//#endregion
|
|
200
|
+
//#region packages/ai/src/transports/openai-responses-tool-call-id-shape.d.ts
|
|
201
|
+
export declare const OPENAI_RESPONSES_ID_MAX_LENGTH = 64;
|
|
202
|
+
export declare const OPENAI_RESPONSES_CALL_ID_RE: RegExp;
|
|
203
|
+
export declare const OPENAI_RESPONSES_FUNCTION_CALL_ITEM_ID_RE: RegExp;
|
|
204
|
+
export declare function splitOpenAIFunctionCallPairing(id: string): {
|
|
205
|
+
callId: string;
|
|
206
|
+
itemId?: string;
|
|
207
|
+
};
|
|
208
|
+
/** Same shaping `normalizeOpenAIResponsesToolCallIds` applies to a replayed `call_id`/`call_id|fc_id` pair. */
|
|
209
|
+
export declare function normalizeOpenAIResponsesFunctionCallId(id: string): string;
|
|
210
|
+
export declare function shouldNormalizeOpenAIResponsesToolCallId(id: string): boolean;
|
|
211
|
+
//#endregion
|
|
204
212
|
//#region packages/ai/src/transports/openai-responses-client.d.ts
|
|
205
213
|
export declare function createOpenAIResponsesTransportStreamFn(): StreamFn;
|
|
206
214
|
export declare function createAzureOpenAIResponsesTransportStreamFn(): StreamFn;
|
|
@@ -224,12 +232,6 @@ type OpenAIResponsesCompactEndpointResult = {
|
|
|
224
232
|
/** Run a compact-endpoint request through the session's prepared stream stack. */
|
|
225
233
|
export declare function requestPreparedOpenAIResponsesCompaction(streamFn: StreamFn, model: Model, context: Context, options: OpenAIResponsesOptions): Promise<OpenAIResponsesCompactEndpointResult>;
|
|
226
234
|
//#endregion
|
|
227
|
-
//#region packages/ai/src/transports/openai-responses-compaction-replay.d.ts
|
|
228
|
-
export declare function captureOpenAIResponsesCompaction(output: Pick<AssistantMessage, "providerReplay">, item: ReplayableResponseCompactionItem, boundary: number | "retained-users", model: Model, captureMetadata?: OpenAIResponsesReasoningReplayMetadata, compactedOutput?: OpenAIResponsesCompactionOutput): void;
|
|
229
|
-
export declare class CompactionReplayRefreshRequiredError extends Error {
|
|
230
|
-
constructor();
|
|
231
|
-
}
|
|
232
|
-
//#endregion
|
|
233
235
|
//#region packages/ai/src/transports/openai-transport-params.d.ts
|
|
234
236
|
export declare function readCodeModePayloadToolName(tool: unknown): string | undefined;
|
|
235
237
|
export declare function filterCodeModePayloadTools(payload: unknown, visibleToolNames: ReadonlySet<string>, allowedHostedToolTypes?: ReadonlySet<string>, observer?: (observation: CodeModeToolSurfaceObservation) => void): void;
|
|
@@ -255,15 +257,10 @@ export declare function buildOpenAISdkRequestOptions(model: Model, signal?: Abor
|
|
|
255
257
|
headers?: Record<string, string>;
|
|
256
258
|
} | undefined;
|
|
257
259
|
export declare function getCompat(model: OpenAIModeModel): {
|
|
258
|
-
cacheControlFormat: "anthropic" | undefined;
|
|
259
|
-
reasoningEffortMap: Record<string, string>;
|
|
260
|
-
openRouterRouting: Record<string, unknown>;
|
|
261
|
-
vercelGatewayRouting: Record<string, unknown>;
|
|
262
|
-
requiresStringContent: boolean;
|
|
263
|
-
strictMessageKeys: boolean;
|
|
264
260
|
supportsStore: boolean;
|
|
265
261
|
supportsDeveloperRole: boolean;
|
|
266
262
|
supportsReasoningEffort: boolean;
|
|
263
|
+
supportedReasoningEfforts?: string[];
|
|
267
264
|
supportsUsageInStreaming: boolean;
|
|
268
265
|
maxTokensField: "max_completion_tokens" | "max_tokens";
|
|
269
266
|
requiresToolResultName: boolean;
|
|
@@ -276,11 +273,16 @@ export declare function getCompat(model: OpenAIModeModel): {
|
|
|
276
273
|
supportsJsonSchemaResponseFormat: boolean;
|
|
277
274
|
supportsPromptCacheKey: boolean;
|
|
278
275
|
supportsLongCacheRetention: boolean;
|
|
279
|
-
|
|
280
|
-
sessionAffinity: "openai" | "openrouter" | "none";
|
|
276
|
+
sessionAffinity: "none" | "openai" | "openrouter";
|
|
281
277
|
visibleReasoningDetailTypes: string[];
|
|
282
278
|
requiresNonEmptyUserOrAssistantMessage: boolean;
|
|
283
279
|
configuredSupportsLongCacheRetention?: boolean;
|
|
280
|
+
cacheControlFormat: "anthropic" | undefined;
|
|
281
|
+
reasoningEffortMap: Record<string, string>;
|
|
282
|
+
openRouterRouting: Record<string, unknown>;
|
|
283
|
+
vercelGatewayRouting: Record<string, unknown>;
|
|
284
|
+
requiresStringContent: boolean;
|
|
285
|
+
strictMessageKeys: boolean;
|
|
284
286
|
};
|
|
285
287
|
//#endregion
|
|
286
288
|
//#region packages/ai/src/transports/provider-compaction-replay.d.ts
|
|
@@ -353,6 +355,8 @@ export declare function prepareModelForSimpleCompletion<TApi extends Api>(params
|
|
|
353
355
|
apiRegistry: ApiRegistry;
|
|
354
356
|
model: Model<TApi>;
|
|
355
357
|
cfg?: unknown;
|
|
358
|
+
auth?: AiProviderStreamHookContext["auth"];
|
|
359
|
+
agentId?: string;
|
|
356
360
|
}): Model;
|
|
357
361
|
//#endregion
|
|
358
362
|
//#region packages/ai/src/transports/transport-utils.d.ts
|
|
@@ -428,4 +432,4 @@ export declare function convertGoogleTools(tools: Tool[]): {
|
|
|
428
432
|
functionDeclarations: Record<string, unknown>[];
|
|
429
433
|
}[] | undefined;
|
|
430
434
|
//#endregion
|
|
431
|
-
export { type GoogleStreamChunk, IncompleteToolCallError, type OpenAICompletionsOptions, type OpenAIResponsesCompactionRejection, ProviderAcceptance, ResolvedOpenAICompletionsCompat, WritableTransportStream, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyOpenAIResponsesPayloadPolicy, assignTransportErrorDetails, buildAnthropicSystemBlocks, coerceTransportToolCallArguments, copyProviderAcceptanceObserver, createEmptyTransportUsage, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, failTransportStream, finalizeTerminalToolCallArguments, finalizeTransportStream, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, isAnthropicServerToolClearingEnabled, isDirectAnthropicModel, isNativeOpenAIEndpoint, isOpenAICodexResponsesModel, logAnthropicContextEdits, mergeTransportHeaders,
|
|
435
|
+
export { CompactionReplayRefreshRequiredError, type GoogleStreamChunk, IncompleteToolCallError, type OpenAICompletionsOptions, type OpenAIResponsesCompactionRejection, ProviderAcceptance, ResolvedOpenAICompletionsCompat, WritableTransportStream, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyOpenAIResponsesPayloadPolicy, assignTransportErrorDetails, buildAnthropicSystemBlocks, captureOpenAIResponsesCompaction, coerceTransportToolCallArguments, copyProviderAcceptanceObserver, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, 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, throwIfModelStreamAborted, transportAbortError, usesNativeOpenAICodexResponsesBackend, withProviderAcceptanceObserver, withProviderResponseHook };
|