@hintergrund/ui 0.2.2 → 0.2.3

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.
Files changed (42) hide show
  1. package/dist/Builder-H8tY8V9I.js +14172 -0
  2. package/dist/admin.js +11084 -9645
  3. package/dist/{anthropic-CwpwmW2G.js → anthropic-messages-C3hIUlsA.js} +1134 -1055
  4. package/dist/azure-openai-responses-t7u41KMr.js +222 -0
  5. package/dist/builder.js +2 -2
  6. package/dist/client-Cd7yMX39.js +7860 -0
  7. package/dist/deferred-tools-BZWMWBYN.js +28 -0
  8. package/dist/error-body-BUPcH4GF.js +71 -0
  9. package/dist/github-copilot-headers-B1RBGoZi.js +21 -0
  10. package/dist/{global-DdaMTl90.js → global-Bk9T4Af5.js} +17850 -16460
  11. package/dist/google-generative-ai-6ZG79NDC.js +264 -0
  12. package/dist/{google-shared-zl4aoTwW.js → google-shared-C6y4fA42.js} +1135 -1104
  13. package/dist/google-vertex-f2myaAmm.js +305 -0
  14. package/dist/headers-D4iLzGaS.js +21 -0
  15. package/dist/json-parse-LZdWp-Nd.js +232 -0
  16. package/dist/login.js +48 -48
  17. package/dist/mistral-conversations-D16H8Mgq.js +513 -0
  18. package/dist/openai-codex-responses-DIHPbnIS.js +947 -0
  19. package/dist/openai-completions-vDHGFsWV.js +741 -0
  20. package/dist/{headers-u7rXGJ9f.js → openai-prompt-cache-BJwqbEDx.js} +7 -6
  21. package/dist/openai-responses-B0rjAJxx.js +184 -0
  22. package/dist/openai-responses-shared-DqdzMfa_.js +477 -0
  23. package/dist/pi-messages-DB2BtH-g.js +251 -0
  24. package/dist/pi-user-agent-CUqx-qiX.js +13 -0
  25. package/dist/provider-env-D2VjEV3S.js +26 -0
  26. package/dist/provider-retry-BsigVlMg.js +67 -0
  27. package/dist/setup.js +230 -228
  28. package/dist/transform-messages-CsKsy6b4.js +398 -0
  29. package/package.json +4 -5
  30. package/dist/Builder-BhGmzNTC.js +0 -163449
  31. package/dist/azure-openai-responses-yWEFYMG1.js +0 -203
  32. package/dist/client-Sh7wNjbG.js +0 -5277
  33. package/dist/github-copilot-headers-DWh_6bE3.js +0 -35
  34. package/dist/google-BgPPfrTM.js +0 -248
  35. package/dist/google-vertex-D7kAAkZn.js +0 -285
  36. package/dist/json-parse-Dk_xwHcS.js +0 -93
  37. package/dist/mistral-BJWDROjc.js +0 -22932
  38. package/dist/openai-codex-responses-rzy0Aqwg.js +0 -700
  39. package/dist/openai-completions-CUEO2YVR.js +0 -535
  40. package/dist/openai-responses-k6plMvd9.js +0 -142
  41. package/dist/openai-responses-shared-CCD7nRqy.js +0 -324
  42. package/dist/transform-messages-CkpQp6fJ.js +0 -132
@@ -1,35 +0,0 @@
1
- typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(r) {
2
- return Promise.resolve().then(r);
3
- } });
4
- function a(r) {
5
- return r === "cloudflare-workers-ai" || r === "cloudflare-ai-gateway";
6
- }
7
- function u(r) {
8
- const e = r.baseUrl;
9
- return e.includes("{") ? e.replace(/\{([A-Z_][A-Z0-9_]*)\}/g, (s, o) => {
10
- const n = process.env[o];
11
- if (!n)
12
- throw new Error(`${o} is required for provider ${r.provider} but is not set.`);
13
- return n;
14
- }) : e;
15
- }
16
- function i(r) {
17
- const e = r[r.length - 1];
18
- return e && e.role !== "user" ? "agent" : "user";
19
- }
20
- function l(r) {
21
- return r.some((e) => e.role === "user" && Array.isArray(e.content) ? e.content.some((t) => t.type === "image") : e.role === "toolResult" && Array.isArray(e.content) ? e.content.some((t) => t.type === "image") : !1);
22
- }
23
- function c(r) {
24
- const e = {
25
- "X-Initiator": i(r.messages),
26
- "Openai-Intent": "conversation-edits"
27
- };
28
- return r.hasImages && (e["Copilot-Vision-Request"] = "true"), e;
29
- }
30
- export {
31
- c as b,
32
- l as h,
33
- a as i,
34
- u as r
35
- };
@@ -1,248 +0,0 @@
1
- import { i as v, r as I, m as M, G as S, c as R, a as L, b as _ } from "./google-shared-zl4aoTwW.js";
2
- import { d as x, h as G, e as O, f as A } from "./Builder-BhGmzNTC.js";
3
- import { b as N, s as P } from "./transform-messages-CkpQp6fJ.js";
4
- typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(e) {
5
- return Promise.resolve().then(e);
6
- } });
7
- let E = 0;
8
- const f = (e, s, n) => {
9
- const i = new O();
10
- return (async () => {
11
- const t = {
12
- role: "assistant",
13
- content: [],
14
- api: "google-generative-ai",
15
- provider: e.provider,
16
- model: e.id,
17
- usage: {
18
- input: 0,
19
- output: 0,
20
- cacheRead: 0,
21
- cacheWrite: 0,
22
- totalTokens: 0,
23
- cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
24
- },
25
- stopReason: "stop",
26
- timestamp: Date.now()
27
- };
28
- try {
29
- const r = n?.apiKey || x(e.provider) || "", c = W(e, r, n?.headers);
30
- let u = B(e, s, n);
31
- const y = await n?.onPayload?.(u, e);
32
- y !== void 0 && (u = y);
33
- const T = await c.models.generateContentStream(u);
34
- i.push({ type: "start", partial: t });
35
- let a = null;
36
- const b = t.content, l = () => b.length - 1;
37
- for await (const g of T) {
38
- t.responseId ||= g.responseId;
39
- const d = g.candidates?.[0];
40
- if (d?.content?.parts)
41
- for (const o of d.content.parts) {
42
- if (o.text !== void 0) {
43
- const h = v(o);
44
- (!a || h && a.type !== "thinking" || !h && a.type !== "text") && (a && (a.type === "text" ? i.push({
45
- type: "text_end",
46
- contentIndex: b.length - 1,
47
- content: a.text,
48
- partial: t
49
- }) : i.push({
50
- type: "thinking_end",
51
- contentIndex: l(),
52
- content: a.thinking,
53
- partial: t
54
- })), h ? (a = { type: "thinking", thinking: "", thinkingSignature: void 0 }, t.content.push(a), i.push({ type: "thinking_start", contentIndex: l(), partial: t })) : (a = { type: "text", text: "" }, t.content.push(a), i.push({ type: "text_start", contentIndex: l(), partial: t }))), a.type === "thinking" ? (a.thinking += o.text, a.thinkingSignature = I(a.thinkingSignature, o.thoughtSignature), i.push({
55
- type: "thinking_delta",
56
- contentIndex: l(),
57
- delta: o.text,
58
- partial: t
59
- })) : (a.text += o.text, a.textSignature = I(a.textSignature, o.thoughtSignature), i.push({
60
- type: "text_delta",
61
- contentIndex: l(),
62
- delta: o.text,
63
- partial: t
64
- }));
65
- }
66
- if (o.functionCall) {
67
- a && (a.type === "text" ? i.push({
68
- type: "text_end",
69
- contentIndex: l(),
70
- content: a.text,
71
- partial: t
72
- }) : i.push({
73
- type: "thinking_end",
74
- contentIndex: l(),
75
- content: a.thinking,
76
- partial: t
77
- }), a = null);
78
- const h = o.functionCall.id, p = {
79
- type: "toolCall",
80
- id: !h || t.content.some((C) => C.type === "toolCall" && C.id === h) ? `${o.functionCall.name}_${Date.now()}_${++E}` : h,
81
- name: o.functionCall.name || "",
82
- arguments: o.functionCall.args ?? {},
83
- ...o.thoughtSignature && { thoughtSignature: o.thoughtSignature }
84
- };
85
- t.content.push(p), i.push({ type: "toolcall_start", contentIndex: l(), partial: t }), i.push({
86
- type: "toolcall_delta",
87
- contentIndex: l(),
88
- delta: JSON.stringify(p.arguments),
89
- partial: t
90
- }), i.push({ type: "toolcall_end", contentIndex: l(), toolCall: p, partial: t });
91
- }
92
- }
93
- d?.finishReason && (t.stopReason = M(d.finishReason), t.content.some((o) => o.type === "toolCall") && (t.stopReason = "toolUse")), g.usageMetadata && (t.usage = {
94
- input: (g.usageMetadata.promptTokenCount || 0) - (g.usageMetadata.cachedContentTokenCount || 0),
95
- output: (g.usageMetadata.candidatesTokenCount || 0) + (g.usageMetadata.thoughtsTokenCount || 0),
96
- cacheRead: g.usageMetadata.cachedContentTokenCount || 0,
97
- cacheWrite: 0,
98
- totalTokens: g.usageMetadata.totalTokenCount || 0,
99
- cost: {
100
- input: 0,
101
- output: 0,
102
- cacheRead: 0,
103
- cacheWrite: 0,
104
- total: 0
105
- }
106
- }, A(e, t.usage));
107
- }
108
- if (a && (a.type === "text" ? i.push({
109
- type: "text_end",
110
- contentIndex: l(),
111
- content: a.text,
112
- partial: t
113
- }) : i.push({
114
- type: "thinking_end",
115
- contentIndex: l(),
116
- content: a.thinking,
117
- partial: t
118
- })), n?.signal?.aborted)
119
- throw new Error("Request was aborted");
120
- if (t.stopReason === "aborted" || t.stopReason === "error")
121
- throw new Error("An unknown error occurred");
122
- i.push({ type: "done", reason: t.stopReason, message: t }), i.end();
123
- } catch (r) {
124
- for (const c of t.content)
125
- "index" in c && delete c.index;
126
- t.stopReason = n?.signal?.aborted ? "aborted" : "error", t.errorMessage = r instanceof Error ? r.message : JSON.stringify(r), i.push({ type: "error", reason: t.stopReason, error: t }), i.end();
127
- }
128
- })(), i;
129
- }, z = (e, s, n) => {
130
- const i = n?.apiKey || x(e.provider);
131
- if (!i)
132
- throw new Error(`No API key for provider: ${e.provider}`);
133
- const t = N(e, n, i);
134
- if (!n?.reasoning)
135
- return f(e, s, { ...t, thinking: { enabled: !1 } });
136
- const r = G(e, n.reasoning), c = r === "off" ? "high" : r, u = e;
137
- return m(u) || w(u) || k(u) ? f(e, s, {
138
- ...t,
139
- thinking: {
140
- enabled: !0,
141
- level: K(c, u)
142
- }
143
- }) : f(e, s, {
144
- ...t,
145
- thinking: {
146
- enabled: !0,
147
- budgetTokens: U(u, c, n.thinkingBudgets)
148
- }
149
- });
150
- };
151
- function W(e, s, n) {
152
- const i = {};
153
- return e.baseUrl && (i.baseUrl = e.baseUrl, i.apiVersion = ""), (e.headers || n) && (i.headers = { ...e.headers, ...n }), new S({
154
- apiKey: s,
155
- httpOptions: Object.keys(i).length > 0 ? i : void 0
156
- });
157
- }
158
- function B(e, s, n = {}) {
159
- const i = R(e, s), t = {};
160
- n.temperature !== void 0 && (t.temperature = n.temperature), n.maxTokens !== void 0 && (t.maxOutputTokens = n.maxTokens);
161
- const r = {
162
- ...Object.keys(t).length > 0 && t,
163
- ...s.systemPrompt && { systemInstruction: P(s.systemPrompt) },
164
- ...s.tools && s.tools.length > 0 && { tools: L(s.tools) }
165
- };
166
- if (s.tools && s.tools.length > 0 && n.toolChoice ? r.toolConfig = {
167
- functionCallingConfig: {
168
- mode: _(n.toolChoice)
169
- }
170
- } : r.toolConfig = void 0, n.thinking?.enabled && e.reasoning) {
171
- const u = { includeThoughts: !0 };
172
- n.thinking.level !== void 0 ? u.thinkingLevel = n.thinking.level : n.thinking.budgetTokens !== void 0 && (u.thinkingBudget = n.thinking.budgetTokens), r.thinkingConfig = u;
173
- } else e.reasoning && n.thinking && !n.thinking.enabled && (r.thinkingConfig = H(e));
174
- if (n.signal) {
175
- if (n.signal.aborted)
176
- throw new Error("Request aborted");
177
- r.abortSignal = n.signal;
178
- }
179
- return {
180
- model: e.id,
181
- contents: i,
182
- config: r
183
- };
184
- }
185
- function k(e) {
186
- return /gemma-?4/.test(e.id.toLowerCase());
187
- }
188
- function m(e) {
189
- return /gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase());
190
- }
191
- function w(e) {
192
- return /gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase());
193
- }
194
- function H(e) {
195
- return m(e) ? { thinkingLevel: "LOW" } : w(e) ? { thinkingLevel: "MINIMAL" } : k(e) ? { thinkingLevel: "MINIMAL" } : { thinkingBudget: 0 };
196
- }
197
- function K(e, s) {
198
- if (m(s))
199
- switch (e) {
200
- case "minimal":
201
- case "low":
202
- return "LOW";
203
- case "medium":
204
- case "high":
205
- return "HIGH";
206
- }
207
- if (k(s))
208
- switch (e) {
209
- case "minimal":
210
- case "low":
211
- return "MINIMAL";
212
- case "medium":
213
- case "high":
214
- return "HIGH";
215
- }
216
- switch (e) {
217
- case "minimal":
218
- return "MINIMAL";
219
- case "low":
220
- return "LOW";
221
- case "medium":
222
- return "MEDIUM";
223
- case "high":
224
- return "HIGH";
225
- }
226
- }
227
- function U(e, s, n) {
228
- return n?.[s] !== void 0 ? n[s] : e.id.includes("2.5-pro") ? {
229
- minimal: 128,
230
- low: 2048,
231
- medium: 8192,
232
- high: 32768
233
- }[s] : e.id.includes("2.5-flash-lite") ? {
234
- minimal: 512,
235
- low: 2048,
236
- medium: 8192,
237
- high: 24576
238
- }[s] : e.id.includes("2.5-flash") ? {
239
- minimal: 128,
240
- low: 2048,
241
- medium: 8192,
242
- high: 24576
243
- }[s] : -1;
244
- }
245
- export {
246
- f as streamGoogle,
247
- z as streamSimpleGoogle
248
- };
@@ -1,285 +0,0 @@
1
- import { i as E, r as x, m as v, G as O, c as w, a as R, b as M, T as h, R as G } from "./google-shared-zl4aoTwW.js";
2
- import { h as S, e as N, f as A } from "./Builder-BhGmzNTC.js";
3
- import { b as P, s as U } from "./transform-messages-CkpQp6fJ.js";
4
- typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(e) {
5
- return Promise.resolve().then(e);
6
- } });
7
- const L = "v1", D = "gcp-vertex-credentials", V = {
8
- THINKING_LEVEL_UNSPECIFIED: h.THINKING_LEVEL_UNSPECIFIED,
9
- MINIMAL: h.MINIMAL,
10
- LOW: h.LOW,
11
- MEDIUM: h.MEDIUM,
12
- HIGH: h.HIGH
13
- };
14
- let H = 0;
15
- const k = (e, t, n) => {
16
- const a = new N();
17
- return (async () => {
18
- const i = {
19
- role: "assistant",
20
- content: [],
21
- api: "google-vertex",
22
- provider: e.provider,
23
- model: e.id,
24
- usage: {
25
- input: 0,
26
- output: 0,
27
- cacheRead: 0,
28
- cacheWrite: 0,
29
- totalTokens: 0,
30
- cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
31
- },
32
- stopReason: "stop",
33
- timestamp: Date.now()
34
- };
35
- try {
36
- const s = J(n), c = s ? W(e, s, n?.headers) : K(e, q(n), F(n), n?.headers);
37
- let d = z(e, t, n);
38
- const C = await n?.onPayload?.(d, e);
39
- C !== void 0 && (d = C);
40
- const _ = await c.models.generateContentStream(d);
41
- a.push({ type: "start", partial: i });
42
- let o = null;
43
- const I = i.content, u = () => I.length - 1;
44
- for await (const l of _) {
45
- i.responseId ||= l.responseId;
46
- const p = l.candidates?.[0];
47
- if (p?.content?.parts)
48
- for (const r of p.content.parts) {
49
- if (r.text !== void 0) {
50
- const g = E(r);
51
- (!o || g && o.type !== "thinking" || !g && o.type !== "text") && (o && (o.type === "text" ? a.push({
52
- type: "text_end",
53
- contentIndex: I.length - 1,
54
- content: o.text,
55
- partial: i
56
- }) : a.push({
57
- type: "thinking_end",
58
- contentIndex: u(),
59
- content: o.thinking,
60
- partial: i
61
- })), g ? (o = { type: "thinking", thinking: "", thinkingSignature: void 0 }, i.content.push(o), a.push({ type: "thinking_start", contentIndex: u(), partial: i })) : (o = { type: "text", text: "" }, i.content.push(o), a.push({ type: "text_start", contentIndex: u(), partial: i }))), o.type === "thinking" ? (o.thinking += r.text, o.thinkingSignature = x(o.thinkingSignature, r.thoughtSignature), a.push({
62
- type: "thinking_delta",
63
- contentIndex: u(),
64
- delta: r.text,
65
- partial: i
66
- })) : (o.text += r.text, o.textSignature = x(o.textSignature, r.thoughtSignature), a.push({
67
- type: "text_delta",
68
- contentIndex: u(),
69
- delta: r.text,
70
- partial: i
71
- }));
72
- }
73
- if (r.functionCall) {
74
- o && (o.type === "text" ? a.push({
75
- type: "text_end",
76
- contentIndex: u(),
77
- content: o.text,
78
- partial: i
79
- }) : a.push({
80
- type: "thinking_end",
81
- contentIndex: u(),
82
- content: o.thinking,
83
- partial: i
84
- }), o = null);
85
- const g = r.functionCall.id, f = {
86
- type: "toolCall",
87
- id: !g || i.content.some((y) => y.type === "toolCall" && y.id === g) ? `${r.functionCall.name}_${Date.now()}_${++H}` : g,
88
- name: r.functionCall.name || "",
89
- arguments: r.functionCall.args ?? {},
90
- ...r.thoughtSignature && { thoughtSignature: r.thoughtSignature }
91
- };
92
- i.content.push(f), a.push({ type: "toolcall_start", contentIndex: u(), partial: i }), a.push({
93
- type: "toolcall_delta",
94
- contentIndex: u(),
95
- delta: JSON.stringify(f.arguments),
96
- partial: i
97
- }), a.push({ type: "toolcall_end", contentIndex: u(), toolCall: f, partial: i });
98
- }
99
- }
100
- p?.finishReason && (i.stopReason = v(p.finishReason), i.content.some((r) => r.type === "toolCall") && (i.stopReason = "toolUse")), l.usageMetadata && (i.usage = {
101
- input: (l.usageMetadata.promptTokenCount || 0) - (l.usageMetadata.cachedContentTokenCount || 0),
102
- output: (l.usageMetadata.candidatesTokenCount || 0) + (l.usageMetadata.thoughtsTokenCount || 0),
103
- cacheRead: l.usageMetadata.cachedContentTokenCount || 0,
104
- cacheWrite: 0,
105
- totalTokens: l.usageMetadata.totalTokenCount || 0,
106
- cost: {
107
- input: 0,
108
- output: 0,
109
- cacheRead: 0,
110
- cacheWrite: 0,
111
- total: 0
112
- }
113
- }, A(e, i.usage));
114
- }
115
- if (o && (o.type === "text" ? a.push({
116
- type: "text_end",
117
- contentIndex: u(),
118
- content: o.text,
119
- partial: i
120
- }) : a.push({
121
- type: "thinking_end",
122
- contentIndex: u(),
123
- content: o.thinking,
124
- partial: i
125
- })), n?.signal?.aborted)
126
- throw new Error("Request was aborted");
127
- if (i.stopReason === "aborted" || i.stopReason === "error")
128
- throw new Error("An unknown error occurred");
129
- a.push({ type: "done", reason: i.stopReason, message: i }), a.end();
130
- } catch (s) {
131
- for (const c of i.content)
132
- "index" in c && delete c.index;
133
- i.stopReason = n?.signal?.aborted ? "aborted" : "error", i.errorMessage = s instanceof Error ? s.message : JSON.stringify(s), a.push({ type: "error", reason: i.stopReason, error: i }), a.end();
134
- }
135
- })(), a;
136
- }, ae = (e, t, n) => {
137
- const a = P(e, n, void 0);
138
- if (!n?.reasoning)
139
- return k(e, t, {
140
- ...a,
141
- thinking: { enabled: !1 }
142
- });
143
- const i = S(e, n.reasoning), s = i === "off" ? "high" : i, c = e;
144
- return m(c) || T(c) ? k(e, t, {
145
- ...a,
146
- thinking: {
147
- enabled: !0,
148
- level: Y(s, c)
149
- }
150
- }) : k(e, t, {
151
- ...a,
152
- thinking: {
153
- enabled: !0,
154
- budgetTokens: Q(c, s, n.thinkingBudgets)
155
- }
156
- });
157
- };
158
- function K(e, t, n, a) {
159
- return new O({
160
- vertexai: !0,
161
- project: t,
162
- location: n,
163
- apiVersion: L,
164
- httpOptions: b(e, a)
165
- });
166
- }
167
- function W(e, t, n) {
168
- return new O({
169
- vertexai: !0,
170
- apiKey: t,
171
- apiVersion: L,
172
- httpOptions: b(e, n)
173
- });
174
- }
175
- function b(e, t) {
176
- const n = {}, a = j(e.baseUrl);
177
- return a && (n.baseUrl = a, n.baseUrlResourceScope = G.COLLECTION, B(a) && (n.apiVersion = "")), (e.headers || t) && (n.headers = { ...e.headers, ...t }), Object.keys(n).length > 0 ? n : void 0;
178
- }
179
- function j(e) {
180
- const t = e.trim();
181
- if (!(!t || t.includes("{location}")))
182
- return t;
183
- }
184
- function B(e) {
185
- try {
186
- return new URL(e).pathname.split("/").some((n) => /^v\d+(?:beta\d*)?$/.test(n));
187
- } catch {
188
- return /(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e);
189
- }
190
- }
191
- function J(e) {
192
- const t = e?.apiKey?.trim() || process.env.GOOGLE_CLOUD_API_KEY?.trim();
193
- if (!(!t || t === D || $(t)))
194
- return t;
195
- }
196
- function $(e) {
197
- return /^<[^>]+>$/.test(e);
198
- }
199
- function q(e) {
200
- const t = e?.project || process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT;
201
- if (!t)
202
- throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");
203
- return t;
204
- }
205
- function F(e) {
206
- const t = e?.location || process.env.GOOGLE_CLOUD_LOCATION;
207
- if (!t)
208
- throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");
209
- return t;
210
- }
211
- function z(e, t, n = {}) {
212
- const a = w(e, t), i = {};
213
- n.temperature !== void 0 && (i.temperature = n.temperature), n.maxTokens !== void 0 && (i.maxOutputTokens = n.maxTokens);
214
- const s = {
215
- ...Object.keys(i).length > 0 && i,
216
- ...t.systemPrompt && { systemInstruction: U(t.systemPrompt) },
217
- ...t.tools && t.tools.length > 0 && { tools: R(t.tools) }
218
- };
219
- if (t.tools && t.tools.length > 0 && n.toolChoice ? s.toolConfig = {
220
- functionCallingConfig: {
221
- mode: M(n.toolChoice)
222
- }
223
- } : s.toolConfig = void 0, n.thinking?.enabled && e.reasoning) {
224
- const d = { includeThoughts: !0 };
225
- n.thinking.level !== void 0 ? d.thinkingLevel = V[n.thinking.level] : n.thinking.budgetTokens !== void 0 && (d.thinkingBudget = n.thinking.budgetTokens), s.thinkingConfig = d;
226
- } else e.reasoning && n.thinking && !n.thinking.enabled && (s.thinkingConfig = X(e));
227
- if (n.signal) {
228
- if (n.signal.aborted)
229
- throw new Error("Request aborted");
230
- s.abortSignal = n.signal;
231
- }
232
- return {
233
- model: e.id,
234
- contents: a,
235
- config: s
236
- };
237
- }
238
- function m(e) {
239
- return /gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase());
240
- }
241
- function T(e) {
242
- return /gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase());
243
- }
244
- function X(e) {
245
- const t = e;
246
- return m(t) ? { thinkingLevel: h.LOW } : T(t) ? { thinkingLevel: h.MINIMAL } : { thinkingBudget: 0 };
247
- }
248
- function Y(e, t) {
249
- if (m(t))
250
- switch (e) {
251
- case "minimal":
252
- case "low":
253
- return "LOW";
254
- case "medium":
255
- case "high":
256
- return "HIGH";
257
- }
258
- switch (e) {
259
- case "minimal":
260
- return "MINIMAL";
261
- case "low":
262
- return "LOW";
263
- case "medium":
264
- return "MEDIUM";
265
- case "high":
266
- return "HIGH";
267
- }
268
- }
269
- function Q(e, t, n) {
270
- return n?.[t] !== void 0 ? n[t] : e.id.includes("2.5-pro") ? {
271
- minimal: 128,
272
- low: 2048,
273
- medium: 8192,
274
- high: 32768
275
- }[t] : e.id.includes("2.5-flash") ? {
276
- minimal: 128,
277
- low: 2048,
278
- medium: 8192,
279
- high: 24576
280
- }[t] : -1;
281
- }
282
- export {
283
- k as streamGoogleVertex,
284
- ae as streamSimpleGoogleVertex
285
- };
@@ -1,93 +0,0 @@
1
- import { i as s } from "./Builder-BhGmzNTC.js";
2
- typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(e) {
3
- return Promise.resolve().then(e);
4
- } });
5
- const a = /* @__PURE__ */ new Set(['"', "\\", "/", "b", "f", "n", "r", "t", "u"]);
6
- function f(e) {
7
- const r = e.codePointAt(0);
8
- return r !== void 0 && r >= 0 && r <= 31;
9
- }
10
- function d(e) {
11
- switch (e) {
12
- case "\b":
13
- return "\\b";
14
- case "\f":
15
- return "\\f";
16
- case `
17
- `:
18
- return "\\n";
19
- case "\r":
20
- return "\\r";
21
- case " ":
22
- return "\\t";
23
- default:
24
- return `\\u${e.codePointAt(0)?.toString(16).padStart(4, "0") ?? "0000"}`;
25
- }
26
- }
27
- function u(e) {
28
- let r = "", i = !1;
29
- for (let t = 0; t < e.length; t++) {
30
- const n = e[t];
31
- if (!i) {
32
- r += n, n === '"' && (i = !0);
33
- continue;
34
- }
35
- if (n === '"') {
36
- r += n, i = !1;
37
- continue;
38
- }
39
- if (n === "\\") {
40
- const o = e[t + 1];
41
- if (o === void 0) {
42
- r += "\\\\";
43
- continue;
44
- }
45
- if (o === "u") {
46
- const c = e.slice(t + 2, t + 6);
47
- if (/^[0-9a-fA-F]{4}$/.test(c)) {
48
- r += `\\u${c}`, t += 5;
49
- continue;
50
- }
51
- }
52
- if (a.has(o)) {
53
- r += `\\${o}`, t += 1;
54
- continue;
55
- }
56
- r += "\\\\";
57
- continue;
58
- }
59
- r += f(n) ? d(n) : n;
60
- }
61
- return r;
62
- }
63
- function l(e) {
64
- try {
65
- return JSON.parse(e);
66
- } catch (r) {
67
- const i = u(e);
68
- if (i !== e)
69
- return JSON.parse(i);
70
- throw r;
71
- }
72
- }
73
- function h(e) {
74
- if (!e || e.trim() === "")
75
- return {};
76
- try {
77
- return l(e);
78
- } catch {
79
- try {
80
- return s.parse(e) ?? {};
81
- } catch {
82
- try {
83
- return s.parse(u(e)) ?? {};
84
- } catch {
85
- return {};
86
- }
87
- }
88
- }
89
- }
90
- export {
91
- l as a,
92
- h as p
93
- };