@hintergrund/ui 0.2.3 → 0.3.0

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";
1
+ import { x as L, y as j, z as N } from "./BuilderAgentPane-EOT6JCrB.js";
2
2
  import { s as D } 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 J, s as g, d as z, e as H } 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
  } });
@@ -388,13 +388,13 @@ 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 = z(e, !0);
392
392
  return {
393
393
  type: "function",
394
394
  function: {
395
395
  name: e.name,
396
396
  description: e.description,
397
- parameters: w(z(e, n)),
397
+ parameters: w(H(e, n)),
398
398
  strict: n ?? !1
399
399
  }
400
400
  };
@@ -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 { x as he, D as we, G as ge, y as Ee, H as z } from "./BuilderAgentPane-EOT6JCrB.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-DGHcHw_F.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 { x as te, y as ne, z as se } from "./BuilderAgentPane-EOT6JCrB.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";
@@ -12,7 +12,7 @@ import { c as _e } from "./openai-prompt-cache-BJwqbEDx.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
  } });
15
- function D(e, n) {
15
+ function z(e, n) {
16
16
  if (!e)
17
17
  return !1;
18
18
  const t = n.toLowerCase();
@@ -24,7 +24,7 @@ function D(e, n) {
24
24
  function $(e, n, t) {
25
25
  if (n)
26
26
  return n;
27
- if (D(t, "authorization") || D(t, "cf-aig-authorization"))
27
+ if (z(t, "authorization") || z(t, "cf-aig-authorization"))
28
28
  return "unused";
29
29
  throw new Error(`No API key for provider: ${e}`);
30
30
  }
@@ -48,7 +48,7 @@ function Ae(e, n) {
48
48
  const t = new Map(e.map((s) => [s.name, s]));
49
49
  return Array.from(n).map((s) => t.get(s)).filter((s) => s !== void 0);
50
50
  }
51
- function z(e) {
51
+ function D(e) {
52
52
  return e.type === "text";
53
53
  }
54
54
  function Me(e) {
@@ -311,7 +311,7 @@ function Se(e, n, t, s, r, h, u = B(e)) {
311
311
  });
312
312
  }
313
313
  function be(e, n, t, s = B(e), r = H(t?.cacheRetention, t?.env), h = K(n.tools, s.supportsOpenAIGrammarTools)) {
314
- const u = ze(e, n, s, { grammarToolInputProperties: h }), g = Oe(s, r), i = {
314
+ const u = De(e, n, s, { grammarToolInputProperties: h }), g = Oe(s, r), i = {
315
315
  model: e.id,
316
316
  messages: u,
317
317
  stream: !0,
@@ -424,7 +424,7 @@ function Be(e, n) {
424
424
  function Le(e, n) {
425
425
  for (let t = e.length - 1; t >= 0; t--) {
426
426
  const s = e[t];
427
- if ((s.role === "user" || s.role === "assistant" || s.role === "tool") && De(s, n))
427
+ if ((s.role === "user" || s.role === "assistant" || s.role === "tool") && ze(s, n))
428
428
  return;
429
429
  }
430
430
  }
@@ -437,7 +437,7 @@ function qe(e, n) {
437
437
  function Ne(e, n) {
438
438
  return W(e, n);
439
439
  }
440
- function De(e, n) {
440
+ function ze(e, n) {
441
441
  return e.role === "user" || e.role === "assistant" || e.role === "tool" ? W(e, n) : !1;
442
442
  }
443
443
  function W(e, n) {
@@ -461,7 +461,7 @@ function W(e, n) {
461
461
  }
462
462
  return !1;
463
463
  }
464
- function ze(e, n, t, s) {
464
+ function De(e, n, t, s) {
465
465
  const r = [], h = (i) => {
466
466
  if (i.includes("|")) {
467
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;
@@ -509,7 +509,7 @@ function ze(e, n, t, s) {
509
509
  const l = {
510
510
  role: "assistant",
511
511
  content: t.requiresAssistantAfterToolResult ? "" : null
512
- }, a = m.content.filter(z).filter((k) => k.text.trim().length > 0).map((k) => ({
512
+ }, a = m.content.filter(D).filter((k) => k.text.trim().length > 0).map((k) => ({
513
513
  type: "text",
514
514
  text: w(k.text)
515
515
  })), c = a.map((k) => k.text).join(""), p = m.content.filter(Me).filter((k) => k.thinking.trim().length > 0);
@@ -564,7 +564,7 @@ function ze(e, n, t, s) {
564
564
  const l = [], a = /* @__PURE__ */ new Set();
565
565
  let c = i;
566
566
  for (; c < u.length && u[c].role === "toolResult"; c++) {
567
- const p = u[c], _ = p.content.filter(z).map((A) => A.text).join(`
567
+ const p = u[c], _ = p.content.filter(D).map((A) => A.text).join(`
568
568
  `), v = p.content.some((A) => A.type === "image"), k = _.length > 0 ? _ : v ? "(see attached image)" : "(no tool output)", T = {
569
569
  role: "tool",
570
570
  content: w(k),
@@ -735,7 +735,7 @@ function B(e) {
735
735
  } : n;
736
736
  }
737
737
  export {
738
- ze as convertMessages,
738
+ De as convertMessages,
739
739
  we as stream,
740
740
  et as streamSimple
741
741
  };
@@ -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 { x as w, y as E } from "./BuilderAgentPane-EOT6JCrB.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-DGHcHw_F.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 { z as P } from "./BuilderAgentPane-EOT6JCrB.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,4 +1,4 @@
1
- import { d as x, h as f, i as y } from "./Builder-H8tY8V9I.js";
1
+ import { x as m, D as f, G as y } from "./BuilderAgentPane-EOT6JCrB.js";
2
2
  import { p as b, h as w } from "./headers-D4iLzGaS.js";
3
3
  import { p as k } from "./json-parse-LZdWp-Nd.js";
4
4
  import { g as I } from "./provider-env-D2VjEV3S.js";
@@ -41,7 +41,7 @@ function M(r, t, n, e) {
41
41
  timestampMs: Date.now()
42
42
  });
43
43
  }
44
- function m() {
44
+ function x() {
45
45
  return {
46
46
  input: 0,
47
47
  output: 0,
@@ -65,7 +65,7 @@ function S(r) {
65
65
  api: r.api,
66
66
  provider: r.provider,
67
67
  model: r.id,
68
- usage: m(),
68
+ usage: x(),
69
69
  stopReason: "pending",
70
70
  timestamp: Date.now()
71
71
  }, n = /* @__PURE__ */ new Map();
@@ -175,18 +175,18 @@ function P(r, t, n) {
175
175
  api: r.api,
176
176
  provider: r.provider,
177
177
  model: r.id,
178
- usage: m(),
178
+ usage: x(),
179
179
  stopReason: e,
180
180
  errorMessage: t instanceof Error ? t.message : String(t),
181
181
  timestamp: Date.now()
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) {
185
+ function D(r, t) {
186
186
  return r || (I("PI_CACHE_RETENTION", t) === "long" ? "long" : void 0);
187
187
  }
188
- const D = (r, t, n) => {
189
- const e = new x(), s = S(r);
188
+ const $ = (r, t, n) => {
189
+ const e = new m(), s = S(r);
190
190
  return (async () => {
191
191
  try {
192
192
  const a = n?.apiKey;
@@ -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 { t as _, bi as d, bD as b, bE as c, bF as m, bG as s, j as h } from "./global-1QvFLK43.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
+ m(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
+ }), h(() => {
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
+ };