@hintergrund/ui 0.2.1 → 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 +11160 -9739
  3. package/dist/{anthropic-UhrJpH25.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-CFcrkAa3.js → global-Bk9T4Af5.js} +17896 -16508
  11. package/dist/google-generative-ai-6ZG79NDC.js +264 -0
  12. package/dist/{google-shared-BmdaIInh.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 +79 -75
  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 +275 -188
  28. package/dist/transform-messages-CsKsy6b4.js +398 -0
  29. package/package.json +4 -5
  30. package/dist/Builder-B0XYsyXe.js +0 -163449
  31. package/dist/azure-openai-responses-DAC03Qw1.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-CVz_TaG6.js +0 -248
  35. package/dist/google-vertex-C6GE41DE.js +0 -285
  36. package/dist/json-parse-DmJ6NiZE.js +0 -93
  37. package/dist/mistral-DqYbzWvv.js +0 -22932
  38. package/dist/openai-codex-responses-ZWuD9ryk.js +0 -700
  39. package/dist/openai-completions-B6B2OwYj.js +0 -535
  40. package/dist/openai-responses-D9Ip2Wgd.js +0 -142
  41. package/dist/openai-responses-shared-eUUJSL4D.js +0 -324
  42. package/dist/transform-messages-CkpQp6fJ.js +0 -132
@@ -1,203 +0,0 @@
1
- import { O as E, a as c, r as p, i as h, b as _ } from "./client-Sh7wNjbG.js";
2
- import { d as f, h as R, e as y } from "./Builder-B0XYsyXe.js";
3
- import { h as g } from "./headers-u7rXGJ9f.js";
4
- import { p as I, c as v, a as O } from "./openai-responses-shared-eUUJSL4D.js";
5
- import { b } from "./transform-messages-CkpQp6fJ.js";
6
- typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(r) {
7
- return Promise.resolve().then(r);
8
- } });
9
- class N extends E {
10
- /**
11
- * API Client for interfacing with the Azure OpenAI API.
12
- *
13
- * @param {string | undefined} [opts.apiVersion=process.env['OPENAI_API_VERSION'] ?? undefined]
14
- * @param {string | undefined} [opts.endpoint=process.env['AZURE_OPENAI_ENDPOINT'] ?? undefined] - Your Azure endpoint, including the resource, e.g. `https://example-resource.azure.openai.com/`
15
- * @param {string | undefined} [opts.apiKey=process.env['AZURE_OPENAI_API_KEY'] ?? undefined]
16
- * @param {string | undefined} opts.deployment - A model deployment, if given, sets the base client URL to include `/deployments/{deployment}`.
17
- * @param {string | null | undefined} [opts.organization=process.env['OPENAI_ORG_ID'] ?? null]
18
- * @param {string} [opts.baseURL=process.env['OPENAI_BASE_URL']] - Sets the base URL for the API, e.g. `https://example-resource.azure.openai.com/openai/`.
19
- * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
20
- * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
21
- * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
22
- * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
23
- * @param {Headers} opts.defaultHeaders - Default headers to include with every request to the API.
24
- * @param {DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
25
- * @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
26
- */
27
- constructor({ baseURL: n = p("OPENAI_BASE_URL"), apiKey: e = p("AZURE_OPENAI_API_KEY"), apiVersion: a = p("OPENAI_API_VERSION"), endpoint: t, deployment: s, azureADTokenProvider: o, dangerouslyAllowBrowser: i, ...u } = {}) {
28
- if (!a)
29
- throw new c("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");
30
- if (typeof o == "function" && (i = !0), !o && !e)
31
- throw new c("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");
32
- if (o && e)
33
- throw new c("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");
34
- if (u.defaultQuery = { ...u.defaultQuery, "api-version": a }, n) {
35
- if (t)
36
- throw new c("baseURL and endpoint are mutually exclusive");
37
- } else {
38
- if (t || (t = process.env.AZURE_OPENAI_ENDPOINT), !t)
39
- throw new c("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");
40
- n = `${t}/openai`;
41
- }
42
- super({
43
- apiKey: o ?? e,
44
- baseURL: n,
45
- ...u,
46
- ...i !== void 0 ? { dangerouslyAllowBrowser: i } : {}
47
- }), this.apiVersion = "", this.apiVersion = a, this.deploymentName = s;
48
- }
49
- async buildRequest(n, e = {}) {
50
- if (w.has(n.path) && n.method === "post" && n.body !== void 0) {
51
- if (!h(n.body))
52
- throw new Error("Expected request body to be an object");
53
- const a = this.deploymentName || n.body.model || n.__metadata?.model;
54
- a !== void 0 && !this.baseURL.includes("/deployments") && (n.path = `/deployments/${a}${n.path}`);
55
- }
56
- return super.buildRequest(n, e);
57
- }
58
- async authHeaders(n) {
59
- return typeof this._options.apiKey == "string" ? _([{ "api-key": this.apiKey }]) : super.authHeaders(n);
60
- }
61
- }
62
- const w = /* @__PURE__ */ new Set([
63
- "/completions",
64
- "/chat/completions",
65
- "/embeddings",
66
- "/audio/transcriptions",
67
- "/audio/translations",
68
- "/audio/speech",
69
- "/images/generations",
70
- "/batches",
71
- "/images/edits"
72
- ]), P = "v1", U = /* @__PURE__ */ new Set(["openai", "openai-codex", "opencode", "azure-openai-responses"]);
73
- function z(r) {
74
- const n = /* @__PURE__ */ new Map();
75
- if (!r)
76
- return n;
77
- for (const e of r.split(",")) {
78
- const a = e.trim();
79
- if (!a)
80
- continue;
81
- const [t, s] = a.split("=", 2);
82
- !t || !s || n.set(t.trim(), s.trim());
83
- }
84
- return n;
85
- }
86
- function S(r, n) {
87
- return n?.azureDeploymentName ? n.azureDeploymentName : z(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(r.id) || r.id;
88
- }
89
- const M = (r, n, e) => {
90
- const a = new y();
91
- return (async () => {
92
- const t = S(r, e), s = {
93
- role: "assistant",
94
- content: [],
95
- api: "azure-openai-responses",
96
- provider: r.provider,
97
- model: r.id,
98
- usage: {
99
- input: 0,
100
- output: 0,
101
- cacheRead: 0,
102
- cacheWrite: 0,
103
- totalTokens: 0,
104
- cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
105
- },
106
- stopReason: "stop",
107
- timestamp: Date.now()
108
- };
109
- try {
110
- const o = e?.apiKey || f(r.provider) || "", i = Z(r, o, e);
111
- let u = x(r, n, e, t);
112
- const m = await e?.onPayload?.(u, r);
113
- m !== void 0 && (u = m);
114
- const l = {
115
- ...e?.signal ? { signal: e.signal } : {},
116
- ...e?.timeoutMs !== void 0 ? { timeout: e.timeoutMs } : {},
117
- ...e?.maxRetries !== void 0 ? { maxRetries: e.maxRetries } : {}
118
- }, { data: A, response: d } = await i.responses.create(u, l).withResponse();
119
- if (await e?.onResponse?.({ status: d.status, headers: g(d.headers) }, r), a.push({ type: "start", partial: s }), await I(A, s, a, r), e?.signal?.aborted)
120
- throw new Error("Request was aborted");
121
- if (s.stopReason === "aborted" || s.stopReason === "error")
122
- throw new Error("An unknown error occurred");
123
- a.push({ type: "done", reason: s.stopReason, message: s }), a.end();
124
- } catch (o) {
125
- for (const i of s.content)
126
- delete i.index, delete i.partialJson;
127
- s.stopReason = e?.signal?.aborted ? "aborted" : "error", s.errorMessage = o instanceof Error ? o.message : JSON.stringify(o), a.push({ type: "error", reason: s.stopReason, error: s }), a.end();
128
- }
129
- })(), a;
130
- }, q = (r, n, e) => {
131
- const a = e?.apiKey || f(r.provider);
132
- if (!a)
133
- throw new Error(`No API key for provider: ${r.provider}`);
134
- const t = b(r, e, a), s = e?.reasoning ? R(r, e.reasoning) : void 0;
135
- return M(r, n, {
136
- ...t,
137
- reasoningEffort: s === "off" ? void 0 : s
138
- });
139
- };
140
- function L(r) {
141
- const n = r.trim().replace(/\/+$/, "");
142
- let e;
143
- try {
144
- e = new URL(n);
145
- } catch {
146
- throw new Error(`Invalid Azure OpenAI base URL: ${r}`);
147
- }
148
- const a = e.hostname.endsWith(".openai.azure.com") || e.hostname.endsWith(".cognitiveservices.azure.com"), t = e.pathname.replace(/\/+$/, "");
149
- return a && (t === "" || t === "/" || t === "/openai") && (e.pathname = "/openai/v1", e.search = ""), e.toString().replace(/\/+$/, "");
150
- }
151
- function k(r) {
152
- return `https://${r}.openai.azure.com/openai/v1`;
153
- }
154
- function T(r, n) {
155
- const e = n?.azureApiVersion || process.env.AZURE_OPENAI_API_VERSION || P, a = n?.azureBaseUrl?.trim() || process.env.AZURE_OPENAI_BASE_URL?.trim() || void 0, t = n?.azureResourceName || process.env.AZURE_OPENAI_RESOURCE_NAME;
156
- let s = a;
157
- if (!s && t && (s = k(t)), !s && r.baseUrl && (s = r.baseUrl), !s)
158
- throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");
159
- return {
160
- baseUrl: L(s),
161
- apiVersion: e
162
- };
163
- }
164
- function Z(r, n, e) {
165
- if (!n) {
166
- if (!process.env.AZURE_OPENAI_API_KEY)
167
- throw new Error("Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.");
168
- n = process.env.AZURE_OPENAI_API_KEY;
169
- }
170
- const a = { ...r.headers };
171
- e?.headers && Object.assign(a, e.headers);
172
- const { baseUrl: t, apiVersion: s } = T(r, e);
173
- return new N({
174
- apiKey: n,
175
- apiVersion: s,
176
- dangerouslyAllowBrowser: !0,
177
- defaultHeaders: a,
178
- baseURL: t
179
- });
180
- }
181
- function x(r, n, e, a) {
182
- const t = v(r, n, U), s = {
183
- model: a,
184
- input: t,
185
- stream: !0,
186
- prompt_cache_key: e?.sessionId
187
- };
188
- if (e?.maxTokens && (s.max_output_tokens = e?.maxTokens), e?.temperature !== void 0 && (s.temperature = e?.temperature), n.tools && n.tools.length > 0 && (s.tools = O(n.tools)), r.reasoning)
189
- if (e?.reasoningEffort || e?.reasoningSummary) {
190
- const o = e?.reasoningEffort ? r.thinkingLevelMap?.[e.reasoningEffort] ?? e.reasoningEffort : "medium";
191
- s.reasoning = {
192
- effort: o,
193
- summary: e?.reasoningSummary || "auto"
194
- }, s.include = ["reasoning.encrypted_content"];
195
- } else r.thinkingLevelMap?.off !== null && (s.reasoning = {
196
- effort: r.thinkingLevelMap?.off ?? "none"
197
- });
198
- return s;
199
- }
200
- export {
201
- M as streamAzureOpenAIResponses,
202
- q as streamSimpleAzureOpenAIResponses
203
- };