@hintergrund/ui 0.3.4 → 0.3.7
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/BuilderAgentPane-Vj3NCGvZ.js +25916 -0
- package/dist/IntegrationHealth-D1HcBrQn.js +218 -0
- package/dist/admin.js +22766 -28480
- package/dist/anthropic-messages-D8Vp-Ncs.js +3772 -0
- package/dist/azure-openai-responses-DnjyYuiz.js +168 -0
- package/dist/builder.js +27 -22
- package/dist/config.types-DZ5yfeqq.js +20 -0
- package/dist/deferred-tools-nxpq94I4.js +34 -0
- package/dist/diagnostics-x5QOwca_.js +91 -0
- package/dist/error-body-pXgvw5vV.js +68 -0
- package/dist/font-pool/LICENSES.txt +22 -0
- package/dist/font-pool/inter.ttf +0 -0
- package/dist/font-pool/inter.woff2 +0 -0
- package/dist/font-pool/jetbrains-mono.ttf +0 -0
- package/dist/font-pool/jetbrains-mono.woff2 +0 -0
- package/dist/font-pool/lora.ttf +0 -0
- package/dist/font-pool/lora.woff2 +0 -0
- package/dist/font-pool/merriweather.ttf +0 -0
- package/dist/font-pool/merriweather.woff2 +0 -0
- package/dist/font-pool/montserrat.ttf +0 -0
- package/dist/font-pool/montserrat.woff2 +0 -0
- package/dist/font-pool/playfair-display.ttf +0 -0
- package/dist/font-pool/playfair-display.woff2 +0 -0
- package/dist/font-pool/poppins.ttf +0 -0
- package/dist/font-pool/poppins.woff2 +0 -0
- package/dist/font-pool/roboto.ttf +0 -0
- package/dist/font-pool/roboto.woff2 +0 -0
- package/dist/font-pool/space-grotesk.ttf +0 -0
- package/dist/font-pool/space-grotesk.woff2 +0 -0
- package/dist/font-pool/work-sans.ttf +0 -0
- package/dist/font-pool/work-sans.woff2 +0 -0
- package/dist/github-copilot-headers-pRo3v4t7.js +27 -0
- package/dist/global-xsR9gLDa.js +30568 -0
- package/dist/google-generative-ai-BmzNjEvl.js +291 -0
- package/dist/google-shared-CG2Lbh1z.js +8746 -0
- package/dist/google-vertex-Dfla93V_.js +329 -0
- package/dist/hash-BixfZjoG.js +21 -0
- package/dist/headers-CnTiKpOL.js +24 -0
- package/dist/json-parse-CxjAnWaM.js +231 -0
- package/dist/legacy-Zmnk-v81.js +14 -0
- package/dist/login.js +131 -146
- package/dist/mail.js +694 -789
- package/dist/mistral-conversations-DeDb7Gbd.js +558 -0
- package/dist/openai-ClxLHXsh.js +5371 -0
- package/dist/openai-codex-responses-usgOtWUT.js +909 -0
- package/dist/openai-completions-D_nFQy7A.js +730 -0
- package/dist/openai-prompt-cache-Bm8Re6Vv.js +17 -0
- package/dist/openai-responses-BqL3PFsb.js +192 -0
- package/dist/openai-responses-shared-BhQj78KM.js +481 -0
- package/dist/pi-messages-CRx0yqMp.js +268 -0
- package/dist/pi-user-agent-CsXkkH60.js +20 -0
- package/dist/provider-env-Cj6X7Wly.js +35 -0
- package/dist/provider-retry-BGImU1PV.js +68 -0
- package/dist/rolldown-runtime-nTTD767F.js +37 -0
- package/dist/setup.js +391 -418
- package/dist/transform-messages-DvxSeyBQ.js +383 -0
- package/dist/ui.css +2 -1
- package/package.json +5 -5
- package/dist/BuilderAgentPane-CwG29LOX.js +0 -13938
- package/dist/IntegrationHealth-G_4vzV66.js +0 -209
- package/dist/anthropic-messages-BmLfYiwX.js +0 -5605
- package/dist/azure-openai-responses-yf2M6GVe.js +0 -222
- package/dist/client-Cd7yMX39.js +0 -7860
- package/dist/config.types-iZoywORE.js +0 -15
- package/dist/deferred-tools-BZWMWBYN.js +0 -28
- package/dist/error-body-BUPcH4GF.js +0 -71
- package/dist/github-copilot-headers-B1RBGoZi.js +0 -21
- package/dist/global-CTQcFve1.js +0 -36177
- package/dist/google-generative-ai-DkzwUYzL.js +0 -264
- package/dist/google-shared-DTgKMtfJ.js +0 -11710
- package/dist/google-vertex-D2IzqvQM.js +0 -305
- package/dist/hash-DFlR084x.js +0 -14
- package/dist/headers-D4iLzGaS.js +0 -21
- package/dist/json-parse-LZdWp-Nd.js +0 -232
- package/dist/legacy-CckexQcJ.js +0 -5
- package/dist/mistral-conversations-CNfKG0tU.js +0 -513
- package/dist/openai-codex-responses-BLNjExaC.js +0 -947
- package/dist/openai-completions-46IVoF2N.js +0 -741
- package/dist/openai-prompt-cache-BJwqbEDx.js +0 -13
- package/dist/openai-responses-BfHoZFHI.js +0 -184
- package/dist/openai-responses-shared-DOTQAbCj.js +0 -477
- package/dist/pi-messages-fnW87Z4Z.js +0 -251
- package/dist/pi-user-agent-CUqx-qiX.js +0 -13
- package/dist/provider-env-D2VjEV3S.js +0 -26
- package/dist/provider-retry-BsigVlMg.js +0 -67
- package/dist/select-Cke4DYH1.js +0 -78
- package/dist/transform-messages-CsKsy6b4.js +0 -398
|
@@ -1,741 +0,0 @@
|
|
|
1
|
-
import { O as ee } from "./client-Cd7yMX39.js";
|
|
2
|
-
import { D as te, G as ne, H as se } from "./BuilderAgentPane-CwG29LOX.js";
|
|
3
|
-
import { f as re, n as oe } from "./error-body-BUPcH4GF.js";
|
|
4
|
-
import { s as ie } from "./hash-DFlR084x.js";
|
|
5
|
-
import { h as ae } from "./headers-D4iLzGaS.js";
|
|
6
|
-
import { p as N } from "./json-parse-LZdWp-Nd.js";
|
|
7
|
-
import { g as fe } from "./provider-env-D2VjEV3S.js";
|
|
8
|
-
import { r as ue } from "./provider-retry-BsigVlMg.js";
|
|
9
|
-
import { t as le, s as w, g as ce, c as K, a as pe, b as ge, r as de, d as he, e as me, f as ye, M as ke } from "./transform-messages-CsKsy6b4.js";
|
|
10
|
-
import { h as Te, b as Re } from "./github-copilot-headers-B1RBGoZi.js";
|
|
11
|
-
import { c as _e } from "./openai-prompt-cache-BJwqbEDx.js";
|
|
12
|
-
typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(e) {
|
|
13
|
-
return Promise.resolve().then(e);
|
|
14
|
-
} });
|
|
15
|
-
function D(e, n) {
|
|
16
|
-
if (!e)
|
|
17
|
-
return !1;
|
|
18
|
-
const t = n.toLowerCase();
|
|
19
|
-
for (const [s, r] of Object.entries(e))
|
|
20
|
-
if (s.toLowerCase() === t && r !== null && r.trim().length > 0)
|
|
21
|
-
return !0;
|
|
22
|
-
return !1;
|
|
23
|
-
}
|
|
24
|
-
function H(e, n, t) {
|
|
25
|
-
if (n)
|
|
26
|
-
return n;
|
|
27
|
-
if (D(t, "authorization") || D(t, "cf-aig-authorization"))
|
|
28
|
-
return "unused";
|
|
29
|
-
throw new Error(`No API key for provider: ${e}`);
|
|
30
|
-
}
|
|
31
|
-
function xe(e) {
|
|
32
|
-
for (const n of e)
|
|
33
|
-
if (n.role === "toolResult" || n.role === "assistant" && n.content.some((t) => t.type === "toolCall"))
|
|
34
|
-
return !0;
|
|
35
|
-
return !1;
|
|
36
|
-
}
|
|
37
|
-
function ve(e) {
|
|
38
|
-
const n = /* @__PURE__ */ new Set();
|
|
39
|
-
for (const t of e)
|
|
40
|
-
if (t.role === "toolResult")
|
|
41
|
-
for (const s of t.addedToolNames ?? [])
|
|
42
|
-
n.add(s);
|
|
43
|
-
return n;
|
|
44
|
-
}
|
|
45
|
-
function Ae(e, n) {
|
|
46
|
-
if (!e)
|
|
47
|
-
return [];
|
|
48
|
-
const t = new Map(e.map((s) => [s.name, s]));
|
|
49
|
-
return Array.from(n).map((s) => t.get(s)).filter((s) => s !== void 0);
|
|
50
|
-
}
|
|
51
|
-
function z(e) {
|
|
52
|
-
return e.type === "text";
|
|
53
|
-
}
|
|
54
|
-
function Me(e) {
|
|
55
|
-
return e.type === "thinking";
|
|
56
|
-
}
|
|
57
|
-
function Ce(e) {
|
|
58
|
-
return e.type === "toolCall";
|
|
59
|
-
}
|
|
60
|
-
function Ie(e) {
|
|
61
|
-
return e.type === "image";
|
|
62
|
-
}
|
|
63
|
-
function Ee(e) {
|
|
64
|
-
if (typeof e != "object" || e === null)
|
|
65
|
-
return !1;
|
|
66
|
-
const n = e;
|
|
67
|
-
return n.type === "reasoning.encrypted" && typeof n.id == "string" && n.id.length > 0 && typeof n.data == "string" && n.data.length > 0;
|
|
68
|
-
}
|
|
69
|
-
function $(e, n) {
|
|
70
|
-
return e || (fe("PI_CACHE_RETENTION", n) === "long" ? "long" : "short");
|
|
71
|
-
}
|
|
72
|
-
const we = (e, n, t) => {
|
|
73
|
-
const s = new te();
|
|
74
|
-
return (async () => {
|
|
75
|
-
const r = {
|
|
76
|
-
role: "assistant",
|
|
77
|
-
content: [],
|
|
78
|
-
api: e.api,
|
|
79
|
-
provider: e.provider,
|
|
80
|
-
model: e.id,
|
|
81
|
-
usage: {
|
|
82
|
-
input: 0,
|
|
83
|
-
output: 0,
|
|
84
|
-
cacheRead: 0,
|
|
85
|
-
cacheWrite: 0,
|
|
86
|
-
totalTokens: 0,
|
|
87
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
88
|
-
},
|
|
89
|
-
stopReason: "pending",
|
|
90
|
-
timestamp: Date.now()
|
|
91
|
-
};
|
|
92
|
-
try {
|
|
93
|
-
const h = H(e.provider, t?.apiKey, t?.headers), u = B(e), g = K(n.tools, u.supportsOpenAIGrammarTools), i = $(t?.cacheRetention, t?.env), m = i === "none" ? void 0 : t?.sessionId, l = Se(e, n, h, t?.headers, t?.fetch, m, u);
|
|
94
|
-
let a = be(e, n, t, u, i, g);
|
|
95
|
-
const c = await t?.onPayload?.(a, e);
|
|
96
|
-
c !== void 0 && (a = c);
|
|
97
|
-
const p = {
|
|
98
|
-
...t?.signal ? { signal: t.signal } : {},
|
|
99
|
-
...t?.timeoutMs !== void 0 ? { timeout: t.timeoutMs } : {},
|
|
100
|
-
maxRetries: 0
|
|
101
|
-
}, { data: _, response: v } = await ue(() => l.chat.completions.create(a, p).withResponse(), {
|
|
102
|
-
maxRetries: t?.maxRetries,
|
|
103
|
-
maxRetryDelayMs: t?.maxRetryDelayMs,
|
|
104
|
-
signal: t?.signal
|
|
105
|
-
});
|
|
106
|
-
await t?.onResponse?.({ status: v.status, headers: ae(v.headers) }, e), s.push({ type: "start", partial: r });
|
|
107
|
-
let C = null, k = null, T = !1;
|
|
108
|
-
const A = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), F = r.content, E = (o) => F.indexOf(o), L = (o) => {
|
|
109
|
-
const f = o.customInput?.property;
|
|
110
|
-
if (f === void 0)
|
|
111
|
-
return "";
|
|
112
|
-
const x = o.arguments[f];
|
|
113
|
-
return typeof x == "string" ? x : "";
|
|
114
|
-
}, q = (o, f, x) => {
|
|
115
|
-
const d = o.customInput;
|
|
116
|
-
if (!d)
|
|
117
|
-
return;
|
|
118
|
-
const M = pe(d.jsonBuffer, d.property, f, x);
|
|
119
|
-
return o.arguments = { [d.property]: f }, M;
|
|
120
|
-
}, J = (o) => {
|
|
121
|
-
const f = E(o);
|
|
122
|
-
if (f !== -1) {
|
|
123
|
-
if (o.type === "text")
|
|
124
|
-
s.push({
|
|
125
|
-
type: "text_end",
|
|
126
|
-
contentIndex: f,
|
|
127
|
-
content: o.text,
|
|
128
|
-
partial: r
|
|
129
|
-
});
|
|
130
|
-
else if (o.type === "thinking")
|
|
131
|
-
s.push({
|
|
132
|
-
type: "thinking_end",
|
|
133
|
-
contentIndex: f,
|
|
134
|
-
content: o.thinking,
|
|
135
|
-
partial: r
|
|
136
|
-
});
|
|
137
|
-
else if (o.type === "toolCall") {
|
|
138
|
-
if (o.customInput) {
|
|
139
|
-
const x = q(o, L(o), !0);
|
|
140
|
-
x !== void 0 && s.push({
|
|
141
|
-
type: "toolcall_delta",
|
|
142
|
-
contentIndex: f,
|
|
143
|
-
delta: x,
|
|
144
|
-
partial: r
|
|
145
|
-
});
|
|
146
|
-
} else
|
|
147
|
-
o.arguments = N(o.partialArgs);
|
|
148
|
-
delete o.partialArgs, delete o.customInput, delete o.streamIndex, s.push({
|
|
149
|
-
type: "toolcall_end",
|
|
150
|
-
contentIndex: f,
|
|
151
|
-
toolCall: o,
|
|
152
|
-
partial: r
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}, V = () => (C || (C = { type: "text", text: "" }, F.push(C), s.push({ type: "text_start", contentIndex: E(C), partial: r })), C), Z = (o) => (k || (k = {
|
|
157
|
-
type: "thinking",
|
|
158
|
-
thinking: "",
|
|
159
|
-
thinkingSignature: o
|
|
160
|
-
}, F.push(k), s.push({ type: "thinking_start", contentIndex: E(k), partial: r })), k), Q = (o) => {
|
|
161
|
-
if (!o.id)
|
|
162
|
-
return;
|
|
163
|
-
const f = O.get(o.id);
|
|
164
|
-
f && (o.thoughtSignature = f, O.delete(o.id));
|
|
165
|
-
}, X = (o) => {
|
|
166
|
-
const f = typeof o.index == "number" ? o.index : void 0, x = o.function?.name ?? o.custom?.name ?? "";
|
|
167
|
-
let d = f !== void 0 ? A.get(f) : void 0;
|
|
168
|
-
if (!d && o.id && (d = b.get(o.id)), !d) {
|
|
169
|
-
const M = o.custom && !o.function ? g.get(x) ?? "input" : void 0, S = M !== void 0;
|
|
170
|
-
d = {
|
|
171
|
-
type: "toolCall",
|
|
172
|
-
id: o.id || "",
|
|
173
|
-
name: x,
|
|
174
|
-
arguments: S ? { [M]: "" } : {},
|
|
175
|
-
partialArgs: S ? void 0 : "",
|
|
176
|
-
customInput: S ? { property: M, jsonBuffer: { input: "", started: !1, closed: !1 } } : void 0,
|
|
177
|
-
streamIndex: f
|
|
178
|
-
}, f !== void 0 && A.set(f, d), o.id && b.set(o.id, d), F.push(d), s.push({
|
|
179
|
-
type: "toolcall_start",
|
|
180
|
-
contentIndex: E(d),
|
|
181
|
-
partial: r
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
if (f !== void 0 && d.streamIndex === void 0 && (d.streamIndex = f, A.set(f, d)), o.id && b.set(o.id, d), !d.name && x && (d.name = x), o.custom && !o.function && !d.customInput) {
|
|
185
|
-
const M = g.get(d.name) ?? "input";
|
|
186
|
-
d.arguments = { [M]: "" }, d.customInput = {
|
|
187
|
-
property: M,
|
|
188
|
-
jsonBuffer: { input: "", started: !1, closed: !1 }
|
|
189
|
-
}, delete d.partialArgs;
|
|
190
|
-
}
|
|
191
|
-
return Q(d), d;
|
|
192
|
-
};
|
|
193
|
-
for await (const o of _) {
|
|
194
|
-
if (!o || typeof o != "object")
|
|
195
|
-
continue;
|
|
196
|
-
r.responseId ||= o.id, typeof o.model == "string" && o.model.length > 0 && o.model !== e.id && (r.responseModel ||= o.model), o.usage && (r.usage = j(o.usage, e));
|
|
197
|
-
const f = Array.isArray(o.choices) ? o.choices[0] : void 0;
|
|
198
|
-
if (f) {
|
|
199
|
-
if (!o.usage && f.usage && (r.usage = j(f.usage, e)), f.finish_reason) {
|
|
200
|
-
r.rawStopReason = f.finish_reason;
|
|
201
|
-
const x = Ge(f.finish_reason);
|
|
202
|
-
r.stopReason = x.stopReason, x.errorMessage && (r.errorMessage = x.errorMessage), T = !0;
|
|
203
|
-
}
|
|
204
|
-
if (f.delta) {
|
|
205
|
-
if (f.delta.content !== null && f.delta.content !== void 0 && f.delta.content.length > 0) {
|
|
206
|
-
const y = V();
|
|
207
|
-
y.text += f.delta.content, s.push({
|
|
208
|
-
type: "text_delta",
|
|
209
|
-
contentIndex: E(y),
|
|
210
|
-
delta: f.delta.content,
|
|
211
|
-
partial: r
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
const x = ["reasoning_content", "reasoning", "reasoning_text"], d = f.delta;
|
|
215
|
-
let M = null;
|
|
216
|
-
for (const y of x) {
|
|
217
|
-
const R = d[y];
|
|
218
|
-
if (typeof R == "string" && R.length > 0) {
|
|
219
|
-
M = y;
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
if (M) {
|
|
224
|
-
const y = d[M];
|
|
225
|
-
if (typeof y == "string" && y.length > 0) {
|
|
226
|
-
const R = e.provider === "opencode-go" && M === "reasoning" ? "reasoning_content" : M, I = Z(R);
|
|
227
|
-
I.thinking += y, s.push({
|
|
228
|
-
type: "thinking_delta",
|
|
229
|
-
contentIndex: E(I),
|
|
230
|
-
delta: y,
|
|
231
|
-
partial: r
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
if (f?.delta?.tool_calls)
|
|
236
|
-
for (const y of f.delta.tool_calls) {
|
|
237
|
-
const R = X(y);
|
|
238
|
-
!R.id && y.id && (R.id = y.id, b.set(y.id, R));
|
|
239
|
-
const I = y.function?.name ?? y.custom?.name;
|
|
240
|
-
!R.name && I && (R.name = I);
|
|
241
|
-
let P = "";
|
|
242
|
-
if (y.function?.arguments)
|
|
243
|
-
P = y.function.arguments, R.partialArgs = (R.partialArgs ?? "") + y.function.arguments, R.arguments = N(R.partialArgs);
|
|
244
|
-
else if (y.custom?.input) {
|
|
245
|
-
const Y = L(R) + y.custom.input;
|
|
246
|
-
P = q(R, Y, !1) ?? "";
|
|
247
|
-
}
|
|
248
|
-
s.push({
|
|
249
|
-
type: "toolcall_delta",
|
|
250
|
-
contentIndex: E(R),
|
|
251
|
-
delta: P,
|
|
252
|
-
partial: r
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
const S = f.delta.reasoning_details;
|
|
256
|
-
if (Array.isArray(S)) {
|
|
257
|
-
for (const y of S)
|
|
258
|
-
if (Ee(y)) {
|
|
259
|
-
const R = JSON.stringify(y), I = b.get(y.id);
|
|
260
|
-
I ? I.thoughtSignature = R : O.set(y.id, R);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
for (const o of F)
|
|
267
|
-
J(o);
|
|
268
|
-
if (t?.signal?.aborted)
|
|
269
|
-
throw new Error("Request was aborted");
|
|
270
|
-
if (r.stopReason === "aborted")
|
|
271
|
-
throw new Error("Request was aborted");
|
|
272
|
-
if (!T && !u.supportsFinishReason && (r.stopReason = r.content.some((o) => o.type === "toolCall") ? "toolUse" : "stop"), r.stopReason === "error")
|
|
273
|
-
throw new Error(r.errorMessage || "Provider returned an error stop reason");
|
|
274
|
-
if (u.supportsFinishReason && !T || r.stopReason === "pending")
|
|
275
|
-
throw new Error("Stream ended without finish_reason");
|
|
276
|
-
s.push({ type: "done", reason: r.stopReason, message: r }), s.end();
|
|
277
|
-
} catch (h) {
|
|
278
|
-
for (const g of r.content)
|
|
279
|
-
delete g.index, delete g.partialArgs, delete g.customInput, delete g.streamIndex;
|
|
280
|
-
r.stopReason = t?.signal?.aborted ? "aborted" : "error", r.errorMessage = re(oe(h));
|
|
281
|
-
const u = h?.error?.metadata?.raw;
|
|
282
|
-
u && !r.errorMessage.includes(String(u)) && (r.errorMessage += `
|
|
283
|
-
${u}`), s.push({ type: "error", reason: r.stopReason, error: r }), s.end();
|
|
284
|
-
}
|
|
285
|
-
})(), s;
|
|
286
|
-
}, et = (e, n, t) => {
|
|
287
|
-
H(e.provider, t?.apiKey, t?.headers);
|
|
288
|
-
const s = ge(e, n, t, t?.apiKey), r = t?.reasoning ? ne(e, t.reasoning) : void 0, h = r === "off" ? void 0 : r, u = t?.toolChoice;
|
|
289
|
-
return we(e, n, {
|
|
290
|
-
...s,
|
|
291
|
-
reasoningEffort: h,
|
|
292
|
-
toolChoice: u,
|
|
293
|
-
thinkingBudgets: t?.thinkingBudgets
|
|
294
|
-
});
|
|
295
|
-
};
|
|
296
|
-
function Se(e, n, t, s, r, h, u = B(e)) {
|
|
297
|
-
const g = { ...e.headers };
|
|
298
|
-
if (e.provider === "github-copilot") {
|
|
299
|
-
const i = Te(n.messages), m = Re({
|
|
300
|
-
messages: n.messages,
|
|
301
|
-
hasImages: i
|
|
302
|
-
});
|
|
303
|
-
Object.assign(g, m);
|
|
304
|
-
}
|
|
305
|
-
return h && u.sendSessionAffinityHeaders && (u.sessionAffinityFormat === "openrouter" ? g["x-session-id"] = h : (u.sessionAffinityFormat === "openai" && (g.session_id = h), g["x-client-request-id"] = h, g["x-session-affinity"] = h)), s && Object.assign(g, s), new ee({
|
|
306
|
-
apiKey: t,
|
|
307
|
-
baseURL: e.baseUrl,
|
|
308
|
-
dangerouslyAllowBrowser: !0,
|
|
309
|
-
fetch: r,
|
|
310
|
-
defaultHeaders: g
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
function be(e, n, t, s = B(e), r = $(t?.cacheRetention, t?.env), h = K(n.tools, s.supportsOpenAIGrammarTools)) {
|
|
314
|
-
const u = ze(e, n, s, { grammarToolInputProperties: h }), g = Oe(s, r), i = {
|
|
315
|
-
model: e.id,
|
|
316
|
-
messages: u,
|
|
317
|
-
stream: !0,
|
|
318
|
-
prompt_cache_key: e.baseUrl.includes("api.openai.com") && r !== "none" || r === "long" && s.supportsLongCacheRetention ? _e(t?.sessionId) : void 0,
|
|
319
|
-
prompt_cache_retention: r === "long" && s.supportsLongCacheRetention ? "24h" : void 0
|
|
320
|
-
};
|
|
321
|
-
s.supportsUsageInStreaming !== !1 && (i.stream_options = { include_usage: !0 }), s.supportsStore && (i.store = !1), t?.maxTokens && (s.maxTokensField === "max_tokens" ? i.max_tokens = t.maxTokens : i.max_completion_tokens = t.maxTokens), t?.temperature !== void 0 && (i.temperature = t.temperature);
|
|
322
|
-
const m = s.deferredToolsMode === "kimi" ? ve(n.messages) : /* @__PURE__ */ new Set(), l = n.tools?.filter((a) => !m.has(a.name));
|
|
323
|
-
if (l && l.length > 0 ? (i.tools = U(l, s), s.zaiToolStream && (i.tool_stream = !0)) : xe(n.messages) && (i.tools = []), g && Pe(u, i.tools, g), t?.toolChoice && (i.tool_choice = t.toolChoice), s.thinkingFormat === "zai" && e.reasoning) {
|
|
324
|
-
const a = i;
|
|
325
|
-
if (a.thinking = t?.reasoningEffort ? { type: "enabled", clear_thinking: !1 } : { type: "disabled" }, t?.reasoningEffort && s.supportsReasoningEffort) {
|
|
326
|
-
const c = e.thinkingLevelMap?.[t.reasoningEffort], p = c === void 0 ? t.reasoningEffort : c;
|
|
327
|
-
typeof p == "string" && (a.reasoning_effort = p);
|
|
328
|
-
}
|
|
329
|
-
} else if (s.thinkingFormat === "qwen" && e.reasoning) {
|
|
330
|
-
if (i.enable_thinking = !!t?.reasoningEffort, t?.reasoningEffort && s.supportsReasoningEffort) {
|
|
331
|
-
const a = e.thinkingLevelMap?.[t.reasoningEffort] ?? t.reasoningEffort;
|
|
332
|
-
typeof a == "string" && (i.reasoning_effort = a);
|
|
333
|
-
}
|
|
334
|
-
} else if (s.thinkingFormat === "qwen-chat-template" && e.reasoning)
|
|
335
|
-
i.chat_template_kwargs = {
|
|
336
|
-
enable_thinking: !!t?.reasoningEffort,
|
|
337
|
-
preserve_thinking: !0
|
|
338
|
-
};
|
|
339
|
-
else if (s.thinkingFormat === "chat-template" && e.reasoning) {
|
|
340
|
-
const a = G(e, t, s.chatTemplateKwargs);
|
|
341
|
-
a && (i.chat_template_kwargs = a);
|
|
342
|
-
} else if (s.thinkingFormat === "baseten" && e.reasoning) {
|
|
343
|
-
const a = i, c = G(e, t, s.chatTemplateArgs);
|
|
344
|
-
if (c && (a.chat_template_args = c), s.supportsReasoningEffort) {
|
|
345
|
-
const p = t?.reasoningEffort, _ = p ? e.thinkingLevelMap?.[p] : e.thinkingLevelMap?.off, v = _ === void 0 ? p : _;
|
|
346
|
-
typeof v == "string" && (a.reasoning_effort = v);
|
|
347
|
-
}
|
|
348
|
-
} else if (s.thinkingFormat === "deepseek" && e.reasoning)
|
|
349
|
-
t?.reasoningEffort ? i.thinking = { type: "enabled" } : e.thinkingLevelMap?.off !== null && (i.thinking = { type: "disabled" }), t?.reasoningEffort && s.supportsReasoningEffort && (i.reasoning_effort = e.thinkingLevelMap?.[t.reasoningEffort] ?? t.reasoningEffort);
|
|
350
|
-
else if (s.thinkingFormat === "openrouter" && e.reasoning) {
|
|
351
|
-
const a = i;
|
|
352
|
-
t?.reasoningEffort ? a.reasoning = {
|
|
353
|
-
effort: e.thinkingLevelMap?.[t.reasoningEffort] ?? t.reasoningEffort
|
|
354
|
-
} : e.thinkingLevelMap?.off !== null && (a.reasoning = { effort: e.thinkingLevelMap?.off ?? "none" });
|
|
355
|
-
} else if (s.thinkingFormat === "ant-ling" && e.reasoning && t?.reasoningEffort) {
|
|
356
|
-
const a = e.thinkingLevelMap?.[t.reasoningEffort];
|
|
357
|
-
typeof a == "string" && (i.reasoning = { effort: a });
|
|
358
|
-
} else if (s.thinkingFormat === "together" && e.reasoning) {
|
|
359
|
-
const a = i;
|
|
360
|
-
a.reasoning = { enabled: !!t?.reasoningEffort }, t?.reasoningEffort && s.supportsReasoningEffort && (a.reasoning_effort = e.thinkingLevelMap?.[t.reasoningEffort] ?? t.reasoningEffort);
|
|
361
|
-
} else if (s.thinkingFormat === "string-thinking" && e.reasoning) {
|
|
362
|
-
const a = i;
|
|
363
|
-
t?.reasoningEffort ? a.thinking = e.thinkingLevelMap?.[t.reasoningEffort] ?? t.reasoningEffort : e.thinkingLevelMap?.off !== null && (a.thinking = e.thinkingLevelMap?.off ?? "none");
|
|
364
|
-
} else if (t?.reasoningEffort && e.reasoning && s.supportsReasoningEffort)
|
|
365
|
-
i.reasoning_effort = e.thinkingLevelMap?.[t.reasoningEffort] ?? t.reasoningEffort;
|
|
366
|
-
else if (!t?.reasoningEffort && e.reasoning && s.supportsReasoningEffort) {
|
|
367
|
-
const a = e.thinkingLevelMap?.off;
|
|
368
|
-
typeof a == "string" && (i.reasoning_effort = a);
|
|
369
|
-
}
|
|
370
|
-
if (s.supportsThinkingTokenBudget && t?.reasoningEffort && e.reasoning) {
|
|
371
|
-
const a = ye(t.reasoningEffort), c = {
|
|
372
|
-
minimal: 1024,
|
|
373
|
-
low: 2048,
|
|
374
|
-
medium: 8192,
|
|
375
|
-
high: 16384,
|
|
376
|
-
...t.thinkingBudgets
|
|
377
|
-
}, p = i.max_tokens ?? i.max_completion_tokens ?? e.maxTokens, _ = Math.min(c[a], Math.max(0, p - ke));
|
|
378
|
-
_ > 0 && (i.thinking_token_budget = _);
|
|
379
|
-
}
|
|
380
|
-
if (e.compat?.openRouterRouting && (i.provider = e.compat.openRouterRouting), e.compat?.vercelGatewayRouting) {
|
|
381
|
-
const a = e.compat.vercelGatewayRouting;
|
|
382
|
-
if (a.only || a.order) {
|
|
383
|
-
const c = {};
|
|
384
|
-
a.only && (c.only = a.only), a.order && (c.order = a.order), i.providerOptions = { gateway: c };
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
return t?.samplingParams && Object.assign(i, t.samplingParams), i;
|
|
388
|
-
}
|
|
389
|
-
function G(e, n, t) {
|
|
390
|
-
const s = {};
|
|
391
|
-
for (const [r, h] of Object.entries(t)) {
|
|
392
|
-
const u = Fe(e, n, h);
|
|
393
|
-
u !== void 0 && (s[r] = u);
|
|
394
|
-
}
|
|
395
|
-
return Object.keys(s).length > 0 ? s : void 0;
|
|
396
|
-
}
|
|
397
|
-
function Fe(e, n, t) {
|
|
398
|
-
if (typeof t != "object" || t === null)
|
|
399
|
-
return t;
|
|
400
|
-
const s = n?.reasoningEffort;
|
|
401
|
-
if (!s && t.omitWhenOff)
|
|
402
|
-
return;
|
|
403
|
-
if (t.$var === "thinking.enabled")
|
|
404
|
-
return !!s;
|
|
405
|
-
const r = s ? e.thinkingLevelMap?.[s] : e.thinkingLevelMap?.off;
|
|
406
|
-
return r === void 0 ? s : typeof r == "string" ? r : void 0;
|
|
407
|
-
}
|
|
408
|
-
function Oe(e, n) {
|
|
409
|
-
if (e.cacheControlFormat !== "anthropic" || n === "none")
|
|
410
|
-
return;
|
|
411
|
-
const t = n === "long" && e.supportsLongCacheRetention ? "1h" : void 0;
|
|
412
|
-
return { type: "ephemeral", ...t ? { ttl: t } : {} };
|
|
413
|
-
}
|
|
414
|
-
function Pe(e, n, t) {
|
|
415
|
-
Be(e, t), qe(n, t), Le(e, t);
|
|
416
|
-
}
|
|
417
|
-
function Be(e, n) {
|
|
418
|
-
for (const t of e)
|
|
419
|
-
if (t.role === "system" || t.role === "developer") {
|
|
420
|
-
Ne(t, n);
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
function Le(e, n) {
|
|
425
|
-
for (let t = e.length - 1; t >= 0; t--) {
|
|
426
|
-
const s = e[t];
|
|
427
|
-
if ((s.role === "user" || s.role === "assistant" || s.role === "tool") && De(s, n))
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
function qe(e, n) {
|
|
432
|
-
if (!e || e.length === 0)
|
|
433
|
-
return;
|
|
434
|
-
const t = e[e.length - 1];
|
|
435
|
-
t.cache_control = n;
|
|
436
|
-
}
|
|
437
|
-
function Ne(e, n) {
|
|
438
|
-
return W(e, n);
|
|
439
|
-
}
|
|
440
|
-
function De(e, n) {
|
|
441
|
-
return e.role === "user" || e.role === "assistant" || e.role === "tool" ? W(e, n) : !1;
|
|
442
|
-
}
|
|
443
|
-
function W(e, n) {
|
|
444
|
-
const t = e.content;
|
|
445
|
-
if (typeof t == "string")
|
|
446
|
-
return t.length === 0 ? !1 : (e.content = [
|
|
447
|
-
{
|
|
448
|
-
type: "text",
|
|
449
|
-
text: t,
|
|
450
|
-
cache_control: n
|
|
451
|
-
}
|
|
452
|
-
], !0);
|
|
453
|
-
if (!Array.isArray(t))
|
|
454
|
-
return !1;
|
|
455
|
-
for (let s = t.length - 1; s >= 0; s--) {
|
|
456
|
-
const r = t[s];
|
|
457
|
-
if (r?.type === "text") {
|
|
458
|
-
const h = r;
|
|
459
|
-
return h.cache_control = n, !0;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
return !1;
|
|
463
|
-
}
|
|
464
|
-
function ze(e, n, t, s) {
|
|
465
|
-
const r = [], h = (i) => {
|
|
466
|
-
if (i.includes("|")) {
|
|
467
|
-
const m = i.indexOf("|"), l = i.slice(0, m).replace(/[^a-zA-Z0-9_-]/g, "_"), a = i.slice(m + 1).replace(/[^a-zA-Z0-9_-]/g, "_"), c = a.length > 0 ? `${l}_${a}` : l;
|
|
468
|
-
if (c.length <= 40)
|
|
469
|
-
return c;
|
|
470
|
-
const p = ie(i).slice(0, 8);
|
|
471
|
-
return `${l.slice(0, Math.max(1, 40 - p.length - 1))}_${p}`;
|
|
472
|
-
}
|
|
473
|
-
return e.provider === "openai" && i.length > 40 ? i.slice(0, 40) : i;
|
|
474
|
-
}, u = le(n.messages, e, (i) => h(i));
|
|
475
|
-
if (n.systemPrompt) {
|
|
476
|
-
const m = e.reasoning && t.supportsDeveloperRole ? "developer" : "system";
|
|
477
|
-
r.push({ role: m, content: w(n.systemPrompt) });
|
|
478
|
-
}
|
|
479
|
-
let g = null;
|
|
480
|
-
for (let i = 0; i < u.length; i++) {
|
|
481
|
-
const m = u[i];
|
|
482
|
-
if (t.requiresAssistantAfterToolResult && g === "toolResult" && m.role === "user" && r.push({
|
|
483
|
-
role: "assistant",
|
|
484
|
-
content: "I have processed the tool results."
|
|
485
|
-
}), m.role === "user")
|
|
486
|
-
if (typeof m.content == "string")
|
|
487
|
-
r.push({
|
|
488
|
-
role: "user",
|
|
489
|
-
content: w(m.content)
|
|
490
|
-
});
|
|
491
|
-
else {
|
|
492
|
-
const l = m.content.map((a) => a.type === "text" ? {
|
|
493
|
-
type: "text",
|
|
494
|
-
text: w(a.text)
|
|
495
|
-
} : {
|
|
496
|
-
type: "image_url",
|
|
497
|
-
image_url: {
|
|
498
|
-
url: `data:${a.mimeType};base64,${a.data}`
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
if (l.length === 0)
|
|
502
|
-
continue;
|
|
503
|
-
r.push({
|
|
504
|
-
role: "user",
|
|
505
|
-
content: l
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
else if (m.role === "assistant") {
|
|
509
|
-
const l = {
|
|
510
|
-
role: "assistant",
|
|
511
|
-
content: t.requiresAssistantAfterToolResult ? "" : null
|
|
512
|
-
}, a = m.content.filter(z).filter((k) => k.text.trim().length > 0).map((k) => ({
|
|
513
|
-
type: "text",
|
|
514
|
-
text: w(k.text)
|
|
515
|
-
})), c = a.map((k) => k.text).join(""), p = m.content.filter(Me).filter((k) => k.thinking.trim().length > 0);
|
|
516
|
-
if (p.length > 0)
|
|
517
|
-
if (t.requiresThinkingAsText) {
|
|
518
|
-
const k = p.map((T) => w(T.thinking)).join(`
|
|
519
|
-
|
|
520
|
-
`);
|
|
521
|
-
l.content = [{ type: "text", text: k }, ...a];
|
|
522
|
-
} else {
|
|
523
|
-
c.length > 0 && (l.content = c);
|
|
524
|
-
let k = p[0].thinkingSignature;
|
|
525
|
-
e.provider === "opencode-go" && k === "reasoning" && (k = "reasoning_content"), k && k.length > 0 && (l[k] = p.map((T) => T.thinking).join(`
|
|
526
|
-
`));
|
|
527
|
-
}
|
|
528
|
-
else c.length > 0 && (l.content = c);
|
|
529
|
-
const _ = m.content.filter(Ce);
|
|
530
|
-
if (_.length > 0) {
|
|
531
|
-
l.tool_calls = _.map((T) => {
|
|
532
|
-
const A = s?.grammarToolInputProperties?.get(T.name);
|
|
533
|
-
return A !== void 0 ? {
|
|
534
|
-
id: T.id,
|
|
535
|
-
type: "custom",
|
|
536
|
-
custom: {
|
|
537
|
-
name: T.name,
|
|
538
|
-
input: w(ce(T.name, T.arguments, A))
|
|
539
|
-
}
|
|
540
|
-
} : {
|
|
541
|
-
id: T.id,
|
|
542
|
-
type: "function",
|
|
543
|
-
function: {
|
|
544
|
-
name: T.name,
|
|
545
|
-
arguments: JSON.stringify(T.arguments)
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
});
|
|
549
|
-
const k = _.filter((T) => T.thoughtSignature).map((T) => {
|
|
550
|
-
try {
|
|
551
|
-
return JSON.parse(T.thoughtSignature);
|
|
552
|
-
} catch {
|
|
553
|
-
return null;
|
|
554
|
-
}
|
|
555
|
-
}).filter(Boolean);
|
|
556
|
-
k.length > 0 && (l.reasoning_details = k);
|
|
557
|
-
}
|
|
558
|
-
t.requiresReasoningContentOnAssistantMessages && e.reasoning && l.reasoning_content === void 0 && (l.reasoning_content = "");
|
|
559
|
-
const v = l.content;
|
|
560
|
-
if (!(v != null && v.length > 0) && !l.tool_calls)
|
|
561
|
-
continue;
|
|
562
|
-
r.push(l);
|
|
563
|
-
} else if (m.role === "toolResult") {
|
|
564
|
-
const l = [], a = /* @__PURE__ */ new Set();
|
|
565
|
-
let c = i;
|
|
566
|
-
for (; c < u.length && u[c].role === "toolResult"; c++) {
|
|
567
|
-
const p = u[c], _ = p.content.filter(z).map((A) => A.text).join(`
|
|
568
|
-
`), v = p.content.some((A) => A.type === "image"), k = _.length > 0 ? _ : v ? "(see attached image)" : "(no tool output)", T = {
|
|
569
|
-
role: "tool",
|
|
570
|
-
content: w(k),
|
|
571
|
-
tool_call_id: p.toolCallId
|
|
572
|
-
};
|
|
573
|
-
if (t.requiresToolResultName && p.toolName && (T.name = p.toolName), r.push(T), t.deferredToolsMode === "kimi")
|
|
574
|
-
for (const A of p.addedToolNames ?? [])
|
|
575
|
-
a.add(A);
|
|
576
|
-
if (v && e.input.includes("image"))
|
|
577
|
-
for (const A of p.content)
|
|
578
|
-
Ie(A) && l.push({
|
|
579
|
-
type: "image_url",
|
|
580
|
-
image_url: {
|
|
581
|
-
url: `data:${A.mimeType};base64,${A.data}`
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
if (i = c - 1, l.length > 0 ? (t.requiresAssistantAfterToolResult && r.push({
|
|
586
|
-
role: "assistant",
|
|
587
|
-
content: "I have processed the tool results."
|
|
588
|
-
}), r.push({
|
|
589
|
-
role: "user",
|
|
590
|
-
content: [
|
|
591
|
-
{
|
|
592
|
-
type: "text",
|
|
593
|
-
text: "Attached image(s) from tool result:"
|
|
594
|
-
},
|
|
595
|
-
...l
|
|
596
|
-
]
|
|
597
|
-
}), g = "user") : g = "toolResult", a.size > 0) {
|
|
598
|
-
const p = Ae(n.tools, a);
|
|
599
|
-
if (p.length > 0) {
|
|
600
|
-
const _ = {
|
|
601
|
-
role: "system",
|
|
602
|
-
tools: U(p, t)
|
|
603
|
-
};
|
|
604
|
-
r.push(_);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
continue;
|
|
608
|
-
}
|
|
609
|
-
g = m.role;
|
|
610
|
-
}
|
|
611
|
-
return r;
|
|
612
|
-
}
|
|
613
|
-
function U(e, n) {
|
|
614
|
-
return e.map((t) => {
|
|
615
|
-
const s = de(t, n.supportsOpenAIGrammarTools);
|
|
616
|
-
if (s)
|
|
617
|
-
return {
|
|
618
|
-
type: "custom",
|
|
619
|
-
custom: {
|
|
620
|
-
name: t.name,
|
|
621
|
-
description: t.description,
|
|
622
|
-
format: {
|
|
623
|
-
type: "grammar",
|
|
624
|
-
grammar: {
|
|
625
|
-
syntax: s.format,
|
|
626
|
-
definition: s.definition
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
};
|
|
631
|
-
const r = he(t, n.supportsStrictMode !== !1);
|
|
632
|
-
return {
|
|
633
|
-
type: "function",
|
|
634
|
-
function: {
|
|
635
|
-
name: t.name,
|
|
636
|
-
description: t.description,
|
|
637
|
-
parameters: me(t, r),
|
|
638
|
-
// Only include strict if provider supports it. Some reject unknown fields.
|
|
639
|
-
...n.supportsStrictMode !== !1 && { strict: r ?? !1 }
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
function j(e, n) {
|
|
645
|
-
const t = e.prompt_tokens || 0, s = e.prompt_tokens_details?.cached_tokens ?? e.prompt_cache_hit_tokens ?? 0, r = e.prompt_tokens_details?.cache_write_tokens || 0, h = Math.max(0, t - s - r), u = e.completion_tokens || 0, g = {
|
|
646
|
-
input: h,
|
|
647
|
-
output: u,
|
|
648
|
-
cacheRead: s,
|
|
649
|
-
cacheWrite: r,
|
|
650
|
-
reasoning: e.completion_tokens_details?.reasoning_tokens || 0,
|
|
651
|
-
totalTokens: h + u + s + r,
|
|
652
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
653
|
-
};
|
|
654
|
-
return se(n, g), g;
|
|
655
|
-
}
|
|
656
|
-
function Ge(e) {
|
|
657
|
-
if (e === null)
|
|
658
|
-
return { stopReason: "stop" };
|
|
659
|
-
switch (e) {
|
|
660
|
-
case "stop":
|
|
661
|
-
case "end":
|
|
662
|
-
return { stopReason: "stop" };
|
|
663
|
-
case "length":
|
|
664
|
-
return { stopReason: "length" };
|
|
665
|
-
case "function_call":
|
|
666
|
-
case "tool_calls":
|
|
667
|
-
return { stopReason: "toolUse" };
|
|
668
|
-
case "content_filter":
|
|
669
|
-
return { stopReason: "error", errorMessage: "Provider finish_reason: content_filter" };
|
|
670
|
-
case "network_error":
|
|
671
|
-
return { stopReason: "error", errorMessage: "Provider finish_reason: network_error" };
|
|
672
|
-
default:
|
|
673
|
-
return {
|
|
674
|
-
stopReason: "error",
|
|
675
|
-
errorMessage: `Provider finish_reason: ${e}`
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
function je(e) {
|
|
680
|
-
const n = e.provider, t = e.baseUrl, s = n === "zai" || n === "zai-coding-cn" || t.includes("api.z.ai") || t.includes("open.bigmodel.cn"), r = n === "together" || t.includes("api.together.ai") || t.includes("api.together.xyz"), h = n === "moonshotai" || n === "moonshotai-cn" || t.includes("api.moonshot."), u = n === "openrouter" || t.includes("openrouter.ai"), g = n === "cloudflare-workers-ai" || t.includes("api.cloudflare.com"), i = n === "cloudflare-ai-gateway" || t.includes("gateway.ai.cloudflare.com"), m = n === "nvidia" || t.includes("integrate.api.nvidia.com"), l = n === "ant-ling" || t.includes("api.ant-ling.com"), a = n === "deepseek" || t.toLowerCase().includes("deepseek.com"), c = m || n === "cerebras" || t.includes("cerebras.ai") || n === "xai" || t.includes("api.x.ai") || r || t.includes("chutes.ai") || a || s || h || n === "opencode" || t.includes("opencode.ai") || g || i || l, p = t.includes("chutes.ai") || a || h || i || r || m || l || s, _ = n === "xai" || t.includes("api.x.ai"), v = u && (e.id.startsWith("anthropic/") || e.id.startsWith("openai/")), C = n === "openrouter" && e.id.startsWith("anthropic/") ? "anthropic" : void 0;
|
|
681
|
-
return {
|
|
682
|
-
supportsStore: !c,
|
|
683
|
-
supportsDeveloperRole: v || !c && !u,
|
|
684
|
-
supportsReasoningEffort: !_ && !s && !h && !r && !i && !m && !l,
|
|
685
|
-
supportsUsageInStreaming: !0,
|
|
686
|
-
supportsFinishReason: !0,
|
|
687
|
-
maxTokensField: p ? "max_tokens" : "max_completion_tokens",
|
|
688
|
-
requiresToolResultName: !1,
|
|
689
|
-
requiresAssistantAfterToolResult: !1,
|
|
690
|
-
requiresThinkingAsText: !1,
|
|
691
|
-
requiresReasoningContentOnAssistantMessages: a,
|
|
692
|
-
thinkingFormat: a ? "deepseek" : s ? "zai" : r ? "together" : l ? "ant-ling" : u ? "openrouter" : "openai",
|
|
693
|
-
openRouterRouting: {},
|
|
694
|
-
vercelGatewayRouting: {},
|
|
695
|
-
chatTemplateKwargs: {},
|
|
696
|
-
chatTemplateArgs: {},
|
|
697
|
-
zaiToolStream: !1,
|
|
698
|
-
supportsThinkingTokenBudget: !1,
|
|
699
|
-
supportsStrictMode: !h && !r && !i && !m,
|
|
700
|
-
supportsOpenAIGrammarTools: !1,
|
|
701
|
-
cacheControlFormat: C,
|
|
702
|
-
sendSessionAffinityHeaders: !1,
|
|
703
|
-
deferredToolsMode: void 0,
|
|
704
|
-
sessionAffinityFormat: u ? "openrouter" : "openai",
|
|
705
|
-
supportsLongCacheRetention: !(r || g || i || m || l)
|
|
706
|
-
};
|
|
707
|
-
}
|
|
708
|
-
function B(e) {
|
|
709
|
-
const n = je(e);
|
|
710
|
-
return e.compat ? {
|
|
711
|
-
supportsStore: e.compat.supportsStore ?? n.supportsStore,
|
|
712
|
-
supportsDeveloperRole: e.compat.supportsDeveloperRole ?? n.supportsDeveloperRole,
|
|
713
|
-
supportsReasoningEffort: e.compat.supportsReasoningEffort ?? n.supportsReasoningEffort,
|
|
714
|
-
supportsUsageInStreaming: e.compat.supportsUsageInStreaming ?? n.supportsUsageInStreaming,
|
|
715
|
-
supportsFinishReason: e.compat.supportsFinishReason ?? n.supportsFinishReason,
|
|
716
|
-
maxTokensField: e.compat.maxTokensField ?? n.maxTokensField,
|
|
717
|
-
requiresToolResultName: e.compat.requiresToolResultName ?? n.requiresToolResultName,
|
|
718
|
-
requiresAssistantAfterToolResult: e.compat.requiresAssistantAfterToolResult ?? n.requiresAssistantAfterToolResult,
|
|
719
|
-
requiresThinkingAsText: e.compat.requiresThinkingAsText ?? n.requiresThinkingAsText,
|
|
720
|
-
requiresReasoningContentOnAssistantMessages: e.compat.requiresReasoningContentOnAssistantMessages ?? n.requiresReasoningContentOnAssistantMessages,
|
|
721
|
-
thinkingFormat: e.compat.thinkingFormat ?? n.thinkingFormat,
|
|
722
|
-
openRouterRouting: e.compat.openRouterRouting ?? {},
|
|
723
|
-
vercelGatewayRouting: e.compat.vercelGatewayRouting ?? n.vercelGatewayRouting,
|
|
724
|
-
chatTemplateKwargs: e.compat.chatTemplateKwargs ?? n.chatTemplateKwargs,
|
|
725
|
-
chatTemplateArgs: e.compat.chatTemplateArgs ?? n.chatTemplateArgs,
|
|
726
|
-
zaiToolStream: e.compat.zaiToolStream ?? n.zaiToolStream,
|
|
727
|
-
supportsThinkingTokenBudget: e.compat.supportsThinkingTokenBudget ?? n.supportsThinkingTokenBudget,
|
|
728
|
-
supportsStrictMode: e.compat.supportsStrictMode ?? n.supportsStrictMode,
|
|
729
|
-
supportsOpenAIGrammarTools: e.compat.supportsOpenAIGrammarTools ?? n.supportsOpenAIGrammarTools,
|
|
730
|
-
cacheControlFormat: e.compat.cacheControlFormat ?? n.cacheControlFormat,
|
|
731
|
-
sendSessionAffinityHeaders: e.compat.sendSessionAffinityHeaders ?? n.sendSessionAffinityHeaders,
|
|
732
|
-
deferredToolsMode: e.compat.deferredToolsMode ?? n.deferredToolsMode,
|
|
733
|
-
sessionAffinityFormat: e.compat.sessionAffinityFormat ?? n.sessionAffinityFormat,
|
|
734
|
-
supportsLongCacheRetention: e.compat.supportsLongCacheRetention ?? n.supportsLongCacheRetention
|
|
735
|
-
} : n;
|
|
736
|
-
}
|
|
737
|
-
export {
|
|
738
|
-
ze as convertMessages,
|
|
739
|
-
we as stream,
|
|
740
|
-
et as streamSimple
|
|
741
|
-
};
|