@hintergrund/ui 0.2.3 → 0.3.1

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.
@@ -1,8 +1,8 @@
1
- import { d as L, e as j, f as N } from "./Builder-H8tY8V9I.js";
2
- import { s as D } from "./hash-DFlR084x.js";
1
+ import { D as L, G as j, H as D } from "./BuilderAgentPane-B7-K-t7-.js";
2
+ import { s as N } from "./hash-DFlR084x.js";
3
3
  import { h as U } from "./headers-D4iLzGaS.js";
4
4
  import { p as T } from "./json-parse-LZdWp-Nd.js";
5
- import { t as B, b as J, s as g, d as H, e as z } from "./transform-messages-CsKsy6b4.js";
5
+ import { t as B, b as H, s as g, d as J, e as z } from "./transform-messages-CsKsy6b4.js";
6
6
  typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(t) {
7
7
  return Promise.resolve().then(t);
8
8
  } });
@@ -29,14 +29,14 @@ const C = 9, K = 4e3, W = (t, e, n) => {
29
29
  } catch (l) {
30
30
  for (const i of o.content)
31
31
  delete i.partialArgs;
32
- o.stopReason = n?.signal?.aborted ? "aborted" : "error", o.errorMessage = Z(l), r.push({ type: "error", reason: o.stopReason, error: o }), r.end();
32
+ o.stopReason = n?.signal?.aborted ? "aborted" : "error", o.errorMessage = G(l), r.push({ type: "error", reason: o.stopReason, error: o }), r.end();
33
33
  }
34
34
  })(), r;
35
35
  }, _e = (t, e, n) => {
36
36
  const r = n?.apiKey;
37
37
  if (!r)
38
38
  throw new Error(`No API key for provider: ${t.provider}`);
39
- const o = J(t, e, n, r), l = n?.reasoning ? j(t, n.reasoning) : void 0, i = l === "off" ? void 0 : l, u = t.reasoning && i !== void 0;
39
+ const o = H(t, e, n, r), l = n?.reasoning ? j(t, n.reasoning) : void 0, i = l === "off" ? void 0 : l, u = t.reasoning && i !== void 0;
40
40
  return W(t, e, {
41
41
  ...o,
42
42
  promptMode: u && fe(t) ? "reasoning" : void 0,
@@ -82,16 +82,16 @@ function P(t, e) {
82
82
  if (e === 0 && n.length === C)
83
83
  return n;
84
84
  const r = n || t, o = e === 0 ? r : `${r}:${e}`;
85
- return D(o).replace(/[^a-zA-Z0-9]/g, "").slice(0, C);
85
+ return N(o).replace(/[^a-zA-Z0-9]/g, "").slice(0, C);
86
86
  }
87
- function Z(t) {
87
+ function G(t) {
88
88
  if (t instanceof Error) {
89
89
  const e = t, n = typeof e.statusCode == "number" ? e.statusCode : void 0, r = typeof e.body == "string" ? e.body.trim() : void 0;
90
- return n !== void 0 && r ? `Mistral API error (${n}): ${G(r, K)}` : n !== void 0 ? `Mistral API error (${n}): ${t.message}` : t.message;
90
+ return n !== void 0 && r ? `Mistral API error (${n}): ${Z(r, K)}` : n !== void 0 ? `Mistral API error (${n}): ${t.message}` : t.message;
91
91
  }
92
92
  return X(t);
93
93
  }
94
- function G(t, e) {
94
+ function Z(t, e) {
95
95
  return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
96
96
  }
97
97
  function X(t) {
@@ -300,7 +300,7 @@ async function ae(t, e, n, r) {
300
300
  const c = a.data;
301
301
  if (e.responseId ||= c.id, c.usage) {
302
302
  const d = c.usage.prompt_tokens || 0, p = se(c.usage, d);
303
- e.usage.input = Math.max(0, d - p), e.usage.output = c.usage.completion_tokens || 0, e.usage.cacheRead = p, e.usage.cacheWrite = 0, e.usage.totalTokens = c.usage.total_tokens || e.usage.input + e.usage.output + e.usage.cacheRead + e.usage.cacheWrite, N(t, e.usage);
303
+ e.usage.input = Math.max(0, d - p), e.usage.output = c.usage.completion_tokens || 0, e.usage.cacheRead = p, e.usage.cacheWrite = 0, e.usage.totalTokens = c.usage.total_tokens || e.usage.input + e.usage.output + e.usage.cacheRead + e.usage.cacheWrite, D(t, e.usage);
304
304
  }
305
305
  const f = c.choices[0];
306
306
  if (!f)
@@ -388,7 +388,7 @@ async function ae(t, e, n, r) {
388
388
  }
389
389
  function ie(t) {
390
390
  return t.map((e) => {
391
- const n = H(e, !0);
391
+ const n = J(e, !0);
392
392
  return {
393
393
  type: "function",
394
394
  function: {
@@ -1,19 +1,19 @@
1
- import { d as he, h as we, i as ge, e as Ee, j as z } from "./Builder-H8tY8V9I.js";
1
+ import { D as he, I as we, J as ge, G as Ee, K as z } from "./BuilderAgentPane-B7-K-t7-.js";
2
2
  import { s as Se } from "./deferred-tools-BZWMWBYN.js";
3
3
  import { f as ve, n as xe } from "./error-body-BUPcH4GF.js";
4
4
  import { h as re } from "./headers-D4iLzGaS.js";
5
- import { g as j } from "./provider-env-D2VjEV3S.js";
5
+ import { g as G } from "./provider-env-D2VjEV3S.js";
6
6
  import { g as _e } from "./pi-user-agent-CUqx-qiX.js";
7
7
  import { c as oe, b as Te } from "./transform-messages-CsKsy6b4.js";
8
8
  import { c as ke } from "./openai-prompt-cache-BJwqbEDx.js";
9
- import { c as se, a as Re, p as ne } from "./openai-responses-shared-DqdzMfa_.js";
9
+ import { c as se, a as Re, p as ne } from "./openai-responses-shared-C_oYyHxW.js";
10
10
  typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(e) {
11
11
  return Promise.resolve().then(e);
12
12
  } });
13
- const G = /* @__PURE__ */ new Set();
13
+ const j = /* @__PURE__ */ new Set();
14
14
  function Ce(e) {
15
- return G.add(e), () => {
16
- G.delete(e);
15
+ return j.add(e), () => {
16
+ j.delete(e);
17
17
  };
18
18
  }
19
19
  let C = -1 / 0, O = 0;
@@ -72,7 +72,7 @@ const We = {
72
72
  };
73
73
  function J(e, r) {
74
74
  const t = e.toLowerCase(), o = e.toUpperCase();
75
- return r?.[t] || r?.[o] || j(t) || j(o) || "";
75
+ return r?.[t] || r?.[o] || G(t) || G(o) || "";
76
76
  }
77
77
  function Pe(e) {
78
78
  if (e instanceof URL)
@@ -119,7 +119,7 @@ function qe(e, r) {
119
119
  throw new Error(`${Ne} Got ${o.protocol}`);
120
120
  return o;
121
121
  }
122
- const Be = "https://chatgpt.com/backend-api", Ue = "https://api.openai.com/auth", $e = 0, V = 1e3, Ie = 6e4, Fe = 15e3, Je = 3, ie = /* @__PURE__ */ new Set(["openai", "openai-codex", "opencode"]), ze = 1009, He = "websocket_connection_limit_reached", Ke = "previous_response_not_found", je = /* @__PURE__ */ new Set([
122
+ const Be = "https://chatgpt.com/backend-api", Ue = "https://api.openai.com/auth", $e = 0, V = 1e3, Ie = 6e4, Fe = 15e3, Je = 3, ie = /* @__PURE__ */ new Set(["openai", "openai-codex", "opencode"]), ze = 1009, He = "websocket_connection_limit_reached", Ke = "previous_response_not_found", Ge = /* @__PURE__ */ new Set([
123
123
  "completed",
124
124
  "incomplete",
125
125
  "failed",
@@ -133,11 +133,11 @@ function X(e) {
133
133
  if (e.stopReason === "error" || e.stopReason === "aborted")
134
134
  throw new Error(e.errorMessage || "An unknown error occurred");
135
135
  }
136
- function Ge(e) {
136
+ function je(e) {
137
137
  return /GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(e);
138
138
  }
139
139
  function Ve(e, r) {
140
- return e === 429 && Ge(r) ? !1 : e === 429 || e === 500 || e === 502 || e === 503 || e === 504 ? !0 : /rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(r);
140
+ return e === 429 && je(r) ? !1 : e === 429 || e === 500 || e === 502 || e === 503 || e === 504 ? !0 : /rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(r);
141
141
  }
142
142
  function Xe(e) {
143
143
  const r = e.get("retry-after-ms");
@@ -463,7 +463,7 @@ async function* fe(e, r) {
463
463
  }
464
464
  function lt(e) {
465
465
  if (typeof e == "string")
466
- return je.has(e) ? e : void 0;
466
+ return Ge.has(e) ? e : void 0;
467
467
  }
468
468
  async function* ut(e, r) {
469
469
  if (!e.body)
@@ -1,5 +1,5 @@
1
1
  import { O as ee } from "./client-Cd7yMX39.js";
2
- import { d as te, e as ne, f as se } from "./Builder-H8tY8V9I.js";
2
+ import { D as te, G as ne, H as se } from "./BuilderAgentPane-B7-K-t7-.js";
3
3
  import { f as re, n as oe } from "./error-body-BUPcH4GF.js";
4
4
  import { s as ie } from "./hash-DFlR084x.js";
5
5
  import { h as ae } from "./headers-D4iLzGaS.js";
@@ -21,7 +21,7 @@ function D(e, n) {
21
21
  return !0;
22
22
  return !1;
23
23
  }
24
- function $(e, n, t) {
24
+ function H(e, n, t) {
25
25
  if (n)
26
26
  return n;
27
27
  if (D(t, "authorization") || D(t, "cf-aig-authorization"))
@@ -66,7 +66,7 @@ function Ee(e) {
66
66
  const n = e;
67
67
  return n.type === "reasoning.encrypted" && typeof n.id == "string" && n.id.length > 0 && typeof n.data == "string" && n.data.length > 0;
68
68
  }
69
- function H(e, n) {
69
+ function $(e, n) {
70
70
  return e || (fe("PI_CACHE_RETENTION", n) === "long" ? "long" : "short");
71
71
  }
72
72
  const we = (e, n, t) => {
@@ -90,7 +90,7 @@ const we = (e, n, t) => {
90
90
  timestamp: Date.now()
91
91
  };
92
92
  try {
93
- const h = $(e.provider, t?.apiKey, t?.headers), u = B(e), g = K(n.tools, u.supportsOpenAIGrammarTools), i = H(t?.cacheRetention, t?.env), m = i === "none" ? void 0 : t?.sessionId, l = Se(e, n, h, t?.headers, t?.fetch, m, u);
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
94
  let a = be(e, n, t, u, i, g);
95
95
  const c = await t?.onPayload?.(a, e);
96
96
  c !== void 0 && (a = c);
@@ -284,7 +284,7 @@ ${u}`), s.push({ type: "error", reason: r.stopReason, error: r }), s.end();
284
284
  }
285
285
  })(), s;
286
286
  }, et = (e, n, t) => {
287
- $(e.provider, t?.apiKey, t?.headers);
287
+ H(e.provider, t?.apiKey, t?.headers);
288
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
289
  return we(e, n, {
290
290
  ...s,
@@ -310,7 +310,7 @@ function Se(e, n, t, s, r, h, u = B(e)) {
310
310
  defaultHeaders: g
311
311
  });
312
312
  }
313
- function be(e, n, t, s = B(e), r = H(t?.cacheRetention, t?.env), h = K(n.tools, s.supportsOpenAIGrammarTools)) {
313
+ function be(e, n, t, s = B(e), r = $(t?.cacheRetention, t?.env), h = K(n.tools, s.supportsOpenAIGrammarTools)) {
314
314
  const u = ze(e, n, s, { grammarToolInputProperties: h }), g = Oe(s, r), i = {
315
315
  model: e.id,
316
316
  messages: u,
@@ -1,5 +1,5 @@
1
1
  import { O as P } from "./client-Cd7yMX39.js";
2
- import { d as w, e as E } from "./Builder-H8tY8V9I.js";
2
+ import { D as w, G as E } from "./BuilderAgentPane-B7-K-t7-.js";
3
3
  import { s as I } from "./deferred-tools-BZWMWBYN.js";
4
4
  import { f as b, n as S } from "./error-body-BUPcH4GF.js";
5
5
  import { h as M } from "./headers-D4iLzGaS.js";
@@ -8,7 +8,7 @@ import { r as _ } from "./provider-retry-BsigVlMg.js";
8
8
  import { c as g, b as x } from "./transform-messages-CsKsy6b4.js";
9
9
  import { h as k, b as L } from "./github-copilot-headers-B1RBGoZi.js";
10
10
  import { c as G } from "./openai-prompt-cache-BJwqbEDx.js";
11
- import { p as D, c as N, a as K } from "./openai-responses-shared-DqdzMfa_.js";
11
+ import { p as D, c as N, a as K } from "./openai-responses-shared-C_oYyHxW.js";
12
12
  typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(e) {
13
13
  return Promise.resolve().then(e);
14
14
  } });
@@ -1,4 +1,4 @@
1
- import { f as P } from "./Builder-H8tY8V9I.js";
1
+ import { H as P } from "./BuilderAgentPane-B7-K-t7-.js";
2
2
  import { s as R } from "./hash-DFlR084x.js";
3
3
  import { p as C } from "./json-parse-LZdWp-Nd.js";
4
4
  import { t as O, s as k, g as z, r as N, d as j, e as W, a as A } from "./transform-messages-CsKsy6b4.js";
@@ -1,7 +1,7 @@
1
- import { d as x, h as f, i as y } from "./Builder-H8tY8V9I.js";
1
+ import { D as x, I as f, J as y } from "./BuilderAgentPane-B7-K-t7-.js";
2
2
  import { p as b, h as w } from "./headers-D4iLzGaS.js";
3
- import { p as k } from "./json-parse-LZdWp-Nd.js";
4
- import { g as I } from "./provider-env-D2VjEV3S.js";
3
+ import { p as I } from "./json-parse-LZdWp-Nd.js";
4
+ import { g as k } from "./provider-env-D2VjEV3S.js";
5
5
  typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(r) {
6
6
  return Promise.resolve().then(r);
7
7
  } });
@@ -121,7 +121,7 @@ function S(r) {
121
121
  break;
122
122
  case "toolcall_delta": {
123
123
  const s = `${n.get(e.contentIndex) ?? ""}${e.delta}`;
124
- n.set(e.contentIndex, s), t.content[e.contentIndex].arguments = k(s);
124
+ n.set(e.contentIndex, s), t.content[e.contentIndex].arguments = I(s);
125
125
  break;
126
126
  }
127
127
  case "toolcall_end":
@@ -182,10 +182,10 @@ function P(r, t, n) {
182
182
  };
183
183
  return !n && t instanceof h && f(s, y("pi_messages_response_failure", t, t.diagnosticDetails)), { type: "error", reason: e, error: s };
184
184
  }
185
- function $(r, t) {
186
- return r || (I("PI_CACHE_RETENTION", t) === "long" ? "long" : void 0);
185
+ function D(r, t) {
186
+ return r || (k("PI_CACHE_RETENTION", t) === "long" ? "long" : void 0);
187
187
  }
188
- const D = (r, t, n) => {
188
+ const $ = (r, t, n) => {
189
189
  const e = new x(), s = S(r);
190
190
  return (async () => {
191
191
  try {
@@ -201,7 +201,7 @@ const D = (r, t, n) => {
201
201
  temperature: n?.temperature,
202
202
  maxTokens: n?.maxTokens,
203
203
  reasoning: n?.reasoning,
204
- cacheRetention: $(n?.cacheRetention, n?.env),
204
+ cacheRetention: D(n?.cacheRetention, n?.env),
205
205
  sessionId: n?.sessionId,
206
206
  toolChoice: n?.toolChoice
207
207
  }
@@ -237,7 +237,7 @@ const D = (r, t, n) => {
237
237
  })(), e;
238
238
  }, A = (r, t, n) => {
239
239
  const e = n;
240
- return D(r, t, {
240
+ return $(r, t, {
241
241
  ...n,
242
242
  reasoning: n?.reasoning,
243
243
  toolChoice: e?.toolChoice,
@@ -246,6 +246,6 @@ const D = (r, t, n) => {
246
246
  };
247
247
  export {
248
248
  h as PiMessagesResponseError,
249
- D as stream,
249
+ $ as stream,
250
250
  A as streamSimple
251
251
  };
@@ -0,0 +1,78 @@
1
+ import { x as _, bh as d, bI as b, bJ as c, bK as h, bL as s, j as m } from "./global-CGPq4E9I.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
+ function v(e, r, f = !1) {
6
+ if (e.multiple) {
7
+ if (r == null)
8
+ return;
9
+ if (!d(r))
10
+ return b();
11
+ for (var n of e.options)
12
+ n.selected = r.includes(t(n));
13
+ return;
14
+ }
15
+ for (n of e.options) {
16
+ var u = t(n);
17
+ if (c(u, r)) {
18
+ n.selected = !0;
19
+ return;
20
+ }
21
+ }
22
+ (!f || r !== void 0) && (e.selectedIndex = -1);
23
+ }
24
+ function p(e) {
25
+ var r = new MutationObserver(() => {
26
+ "__value" in e && v(e, e.__value);
27
+ });
28
+ r.observe(e, {
29
+ // Listen to option element changes
30
+ childList: !0,
31
+ subtree: !0,
32
+ // because of <optgroup>
33
+ // Listen to option element value attribute changes
34
+ // (doesn't get notified of select value changes,
35
+ // because that property is not reflected as an attribute)
36
+ attributes: !0,
37
+ attributeFilter: ["value"]
38
+ }), _(() => {
39
+ r.disconnect();
40
+ });
41
+ }
42
+ function q(e, r, f = r) {
43
+ var n = /* @__PURE__ */ new WeakSet(), u = !0;
44
+ h(e, "change", (a) => {
45
+ var l = a ? "[selected]" : ":checked", i;
46
+ if (e.multiple)
47
+ i = [].map.call(e.querySelectorAll(l), t);
48
+ else {
49
+ var o = e.querySelector(l) ?? // will fall back to first non-disabled option if no option is selected
50
+ e.querySelector("option:not([disabled])");
51
+ i = o && t(o);
52
+ }
53
+ f(i), e.__value = i, s !== null && n.add(s);
54
+ }), m(() => {
55
+ var a = r();
56
+ if (e === document.activeElement) {
57
+ var l = (
58
+ /** @type {Batch} */
59
+ s
60
+ );
61
+ if (n.has(l))
62
+ return;
63
+ }
64
+ if (v(e, a, u), u && a === void 0) {
65
+ var i = e.querySelector(":checked");
66
+ i !== null && (a = t(i), f(a));
67
+ }
68
+ e.__value = a, u = !1;
69
+ }), p(e);
70
+ }
71
+ function t(e) {
72
+ return "__value" in e ? e.__value : e.value;
73
+ }
74
+ export {
75
+ q as b,
76
+ p as i,
77
+ v as s
78
+ };