@hachej/boring-workspace 0.1.47 → 0.1.48

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/app-front.js CHANGED
@@ -1,16 +1,16 @@
1
- import { jsx as d, jsxs as ye, Fragment as ue } from "react/jsx-runtime";
2
- import { useEffect as E, useSyncExternalStore as Nr, useMemo as F, useState as O, useCallback as w, useRef as J, useLayoutEffect as Dr } from "react";
3
- import { PiChatPanel as _r, usePiSessions as Lr } from "@hachej/boring-agent/front";
4
- import { aj as Or, at as ke, au as wn, av as Rn, aw as Tn, ax as Nn, ay as Xe, az as St, aA as yt, aB as Dn, aC as xr, aD as Ye, aE as Mr, U as pn, aF as Cr, q as Fr, aG as Wr, u as _n, aH as Gr, ag as Ir, aI as $r } from "./WorkspaceProvider-CSwoKjTp.js";
5
- import { T as Ur, C as Kr, r as hn, w as Hr, W as vn } from "./WorkspaceLoadingState-BoFzsDji.js";
6
- import { Sun as Jr, Moon as jr } from "lucide-react";
7
- import { IconButton as Br, ErrorState as qr } from "@hachej/boring-ui-kit";
8
- function zr() {
9
- const { theme: e, toggleTheme: n } = Or(), r = e === "dark";
10
- return E(() => {
1
+ import { jsx as d, jsxs as Pe, Fragment as de } from "react/jsx-runtime";
2
+ import { useEffect as A, useSyncExternalStore as xr, useMemo as O, useState as x, useCallback as E, useRef as H, useLayoutEffect as Mr } from "react";
3
+ import { PiChatPanel as Fr, usePiSessions as Cr } from "@hachej/boring-agent/front";
4
+ import { aj as Wr, at as Ve, au as Dn, av as _n, aw as Ln, ax as On, ay as ke, az as St, aA as bt, aB as xn, aC as Gr, aD as ze, aE as Sn, aF as Ir, U as bn, aG as $r, q as Ur, u as Mn, aH as Kr, ag as Hr, aI as Jr } from "./WorkspaceProvider-CRd7lb76.js";
5
+ import { T as jr, C as qr, r as yn, w as Br, W as Pn } from "./WorkspaceLoadingState-CjXix_Fa.js";
6
+ import { Sun as zr, Moon as Vr } from "lucide-react";
7
+ import { IconButton as kr, ErrorState as Yr } from "@hachej/boring-ui-kit";
8
+ function Xr() {
9
+ const { theme: e, toggleTheme: n } = Wr(), r = e === "dark";
10
+ return A(() => {
11
11
  typeof document > "u" || document.documentElement.classList.toggle("dark", r);
12
12
  }, [r]), /* @__PURE__ */ d(
13
- Br,
13
+ kr,
14
14
  {
15
15
  type: "button",
16
16
  variant: "ghost",
@@ -18,18 +18,18 @@ function zr() {
18
18
  onClick: n,
19
19
  "aria-label": "Toggle theme",
20
20
  title: r ? "Switch to light theme" : "Switch to dark theme",
21
- children: r ? /* @__PURE__ */ d(Jr, { className: "h-4 w-4" }) : /* @__PURE__ */ d(jr, { className: "h-4 w-4" })
21
+ children: r ? /* @__PURE__ */ d(zr, { className: "h-4 w-4" }) : /* @__PURE__ */ d(Vr, { className: "h-4 w-4" })
22
22
  }
23
23
  );
24
24
  }
25
- function Vr() {
25
+ function Qr() {
26
26
  const e = `s${Date.now()}`;
27
27
  return {
28
28
  sessions: [{ id: e, title: "New session", updatedAt: Date.now() }],
29
29
  activeId: e
30
30
  };
31
31
  }
32
- function Yr(e, n) {
32
+ function Zr(e, n) {
33
33
  var r;
34
34
  if (typeof localStorage > "u") return n();
35
35
  try {
@@ -43,18 +43,18 @@ function Yr(e, n) {
43
43
  }
44
44
  return n();
45
45
  }
46
- function kr(e, n) {
46
+ function ei(e, n) {
47
47
  if (!(typeof localStorage > "u"))
48
48
  try {
49
49
  localStorage.setItem(e, JSON.stringify(n));
50
50
  } catch {
51
51
  }
52
52
  }
53
- function Xr(e = {}) {
54
- const n = e.storageKey ?? "workspace:sessions", r = e.initial ?? Vr;
55
- let i = Yr(n, r);
53
+ function ti(e = {}) {
54
+ const n = e.storageKey ?? "workspace:sessions", r = e.initial ?? Qr;
55
+ let i = Zr(n, r);
56
56
  const s = /* @__PURE__ */ new Set(), o = (c) => {
57
- i = c, kr(n, i), s.forEach((u) => u());
57
+ i = c, ei(n, i), s.forEach((u) => u());
58
58
  };
59
59
  return {
60
60
  getState: () => i,
@@ -76,16 +76,16 @@ function Xr(e = {}) {
76
76
  },
77
77
  remove(c) {
78
78
  var y;
79
- const u = i.sessions.filter((S) => S.id !== c), b = i.activeId === c ? ((y = u[0]) == null ? void 0 : y.id) ?? "" : i.activeId;
80
- o({ sessions: u, activeId: b });
79
+ const u = i.sessions.filter((b) => b.id !== c), S = i.activeId === c ? ((y = u[0]) == null ? void 0 : y.id) ?? "" : i.activeId;
80
+ o({ sessions: u, activeId: S });
81
81
  }
82
82
  };
83
83
  }
84
- function Qr(e) {
85
- return Nr(e.subscribe, e.getState, e.getState);
84
+ function ni(e) {
85
+ return xr(e.subscribe, e.getState, e.getState);
86
86
  }
87
- const Zr = 500, ei = 1e4;
88
- function bn(e) {
87
+ const ri = 500, ii = 1e4;
88
+ function En(e) {
89
89
  return new Promise((n, r) => {
90
90
  let i;
91
91
  const s = () => {
@@ -99,12 +99,12 @@ function bn(e) {
99
99
  }
100
100
  i = globalThis.setTimeout(() => {
101
101
  s(), n();
102
- }, Zr), e.addEventListener("abort", o, { once: !0 });
102
+ }, ri), e.addEventListener("abort", o, { once: !0 });
103
103
  });
104
104
  }
105
- async function ti(e) {
105
+ async function si(e) {
106
106
  const n = e.body;
107
- if (!n) return Ye(await Xe(e));
107
+ if (!n) return ze(await ke(e));
108
108
  const r = n.getReader(), i = new TextDecoder();
109
109
  let s = "";
110
110
  try {
@@ -112,18 +112,18 @@ async function ti(e) {
112
112
  const { done: o, value: c } = await r.read();
113
113
  if (c) {
114
114
  s += i.decode(c, { stream: !o });
115
- const u = Ye(s);
115
+ const u = ze(s);
116
116
  if (u) return u;
117
117
  }
118
118
  if (o)
119
- return s += i.decode(), Ye(s);
119
+ return s += i.decode(), ze(s);
120
120
  }
121
121
  } finally {
122
122
  await r.cancel().catch(() => {
123
123
  });
124
124
  }
125
125
  }
126
- function ni(e) {
126
+ function oi(e) {
127
127
  if (!((e == null ? void 0 : e.runtimeDependenciesState) !== "preparing" && (e == null ? void 0 : e.runtimeDependenciesState) !== "ready" && (e == null ? void 0 : e.runtimeDependenciesState) !== "failed"))
128
128
  return {
129
129
  state: e.runtimeDependenciesState,
@@ -131,13 +131,13 @@ function ni(e) {
131
131
  ...e.runtimeDependenciesRequirement ? { requirement: e.runtimeDependenciesRequirement } : {}
132
132
  };
133
133
  }
134
- async function ri(e) {
134
+ async function ai(e) {
135
135
  if (!e.ok) {
136
- const s = await Xe(e);
136
+ const s = await ke(e);
137
137
  if (St(s)) return { status: "preparing" };
138
- throw new Error(yt(s) ?? `/api/v1/ready-status failed with ${e.status}`);
138
+ throw new Error(bt(s) ?? `/api/v1/ready-status failed with ${e.status}`);
139
139
  }
140
- const n = await ti(e), r = ni(n), i = xr(n);
140
+ const n = await si(e), r = oi(n), i = Gr(n);
141
141
  if ((n == null ? void 0 : n.state) === "degraded" || (n == null ? void 0 : n.state) === "failed") {
142
142
  if (i && (r == null ? void 0 : r.state) === "failed")
143
143
  return { status: "ready", runtimeDependencies: r };
@@ -145,70 +145,70 @@ async function ri(e) {
145
145
  }
146
146
  return i ? { status: "ready", ...r ? { runtimeDependencies: r } : {} } : { status: "preparing", ...r ? { runtimeDependencies: r } : {} };
147
147
  }
148
- async function ii({
148
+ async function li({
149
149
  apiBaseUrl: e,
150
150
  path: n,
151
151
  headers: r,
152
152
  signal: i,
153
153
  workspaceId: s
154
154
  }) {
155
- const o = new AbortController(), c = globalThis.setTimeout(() => o.abort(new DOMException("Warmup attempt timed out", "TimeoutError")), ei), u = () => o.abort(i.reason);
155
+ const o = new AbortController(), c = globalThis.setTimeout(() => o.abort(new DOMException("Warmup attempt timed out", "TimeoutError")), ii), u = () => o.abort(i.reason);
156
156
  i.aborted && u(), i.addEventListener("abort", u, { once: !0 });
157
157
  try {
158
- const b = await fetch(Tn(e, n), { headers: r, signal: o.signal });
159
- if (Nn(n)) return await ri(b);
160
- const y = await Xe(b);
161
- if (!b.ok) {
162
- const S = St(y);
163
- if (S) return { status: "preparing", ...S };
164
- throw new Error(yt(y) ?? `${n} failed with ${b.status}`);
158
+ const S = await fetch(Ln(e, n), { headers: r, signal: o.signal });
159
+ if (On(n)) return await ai(S);
160
+ const y = await ke(S);
161
+ if (!S.ok) {
162
+ const b = St(y);
163
+ if (b) return { status: "preparing", ...b };
164
+ throw new Error(bt(y) ?? `${n} failed with ${S.status}`);
165
165
  }
166
- return y && typeof y == "object" && Dn(e, r["x-boring-workspace-id"] ?? s, n, y), { status: "ready" };
167
- } catch (b) {
168
- if (i.aborted) throw b;
169
- if (o.signal.aborted || b instanceof TypeError) return { status: "preparing" };
170
- throw b;
166
+ return y && typeof y == "object" && xn(e, r["x-boring-workspace-id"] ?? s, n, y), { status: "ready" };
167
+ } catch (S) {
168
+ if (i.aborted) throw S;
169
+ if (o.signal.aborted || S instanceof TypeError) return { status: "preparing" };
170
+ throw S;
171
171
  } finally {
172
172
  globalThis.clearTimeout(c), i.removeEventListener("abort", u);
173
173
  }
174
174
  }
175
- function si({
175
+ function ci({
176
176
  workspaceId: e,
177
177
  requestHeaders: n,
178
178
  apiBaseUrl: r,
179
- preloadPaths: i = wn,
179
+ preloadPaths: i = Dn,
180
180
  provisionWorkspace: s = !0,
181
181
  onStatusChange: o
182
182
  }) {
183
- return E(() => {
183
+ return A(() => {
184
184
  let c = !1;
185
- const u = new AbortController(), b = ke(e, n);
185
+ const u = new AbortController(), S = Ve(e, n);
186
186
  async function y() {
187
- var S, j;
187
+ var b, j;
188
188
  o == null || o({ status: "preparing" });
189
189
  try {
190
- const W = Rn(i, s), V = (p) => ii({
190
+ const W = _n(i, s), V = (p) => li({
191
191
  apiBaseUrl: r,
192
192
  path: p,
193
- headers: b,
193
+ headers: S,
194
194
  signal: u.signal,
195
195
  workspaceId: e
196
196
  });
197
- let R = await Promise.all(W.map(async (p) => ({ path: p, result: await V(p) })));
197
+ let T = await Promise.all(W.map(async (p) => ({ path: p, result: await V(p) })));
198
198
  if (c || u.signal.aborted) return;
199
- let h = (S = R.find((p) => p.result.runtimeDependencies)) == null ? void 0 : S.result.runtimeDependencies, T = R.filter((p) => p.result.status === "preparing");
200
- for (; T.length > 0; ) {
199
+ let h = (b = T.find((p) => p.result.runtimeDependencies)) == null ? void 0 : b.result.runtimeDependencies, w = T.filter((p) => p.result.status === "preparing");
200
+ for (; w.length > 0; ) {
201
201
  let p;
202
- for (const N of T)
202
+ for (const N of w)
203
203
  if (N.result.status === "preparing" && N.result.requirement) {
204
204
  p = N.result.requirement;
205
205
  break;
206
206
  }
207
- if (o == null || o({ status: "preparing", message: "Workspace is still preparing", ...p ? { requirement: p } : {} }), await bn(u.signal), c || u.signal.aborted || (R = await Promise.all(T.map(async (N) => ({ path: N.path, result: await V(N.path) }))), c || u.signal.aborted)) return;
208
- h = ((j = R.find((N) => N.result.runtimeDependencies)) == null ? void 0 : j.result.runtimeDependencies) ?? h, T = R.filter((N) => N.result.status === "preparing");
207
+ if (o == null || o({ status: "preparing", message: "Workspace is still preparing", ...p ? { requirement: p } : {} }), await En(u.signal), c || u.signal.aborted || (T = await Promise.all(w.map(async (N) => ({ path: N.path, result: await V(N.path) }))), c || u.signal.aborted)) return;
208
+ h = ((j = T.find((N) => N.result.runtimeDependencies)) == null ? void 0 : j.result.runtimeDependencies) ?? h, w = T.filter((N) => N.result.status === "preparing");
209
209
  }
210
210
  for (o == null || o({ status: "ready", ...h ? { runtimeDependencies: h } : {} }); (h == null ? void 0 : h.state) === "preparing"; ) {
211
- if (await bn(u.signal), c || u.signal.aborted) return;
211
+ if (await En(u.signal), c || u.signal.aborted) return;
212
212
  const p = await V("/api/v1/ready-status");
213
213
  if (c || u.signal.aborted) return;
214
214
  h = p.runtimeDependencies, h && (o == null || o({ status: "ready", runtimeDependencies: h }));
@@ -226,51 +226,51 @@ function si({
226
226
  };
227
227
  }, [r, o, i, s, n, e]), null;
228
228
  }
229
- function oi(e) {
229
+ function ui(e) {
230
230
  return typeof (e == null ? void 0 : e.id) == "string" ? e.id : null;
231
231
  }
232
- function Ve(e, n, r) {
232
+ function Be(e, n, r) {
233
233
  if (e.includes(r)) return e;
234
234
  const i = n ? e.indexOf(n) : -1, s = i >= 0 ? i + 1 : e.length;
235
235
  return [...e.slice(0, s), r, ...e.slice(s)];
236
236
  }
237
- function Sn(e, n, r) {
237
+ function An(e, n, r) {
238
238
  if (e.includes(r)) return e;
239
239
  if (e.length === 0) return [r];
240
240
  const i = n ? e.indexOf(n) : -1, s = i >= 0 ? i : 0;
241
241
  return e.map((o, c) => c === s ? r : o);
242
242
  }
243
- function ai(e, n) {
243
+ function di(e, n) {
244
244
  return e.endsWith(":surface") ? e.slice(0, -8) : n;
245
245
  }
246
- function ht(e, n, r) {
247
- const [i, s] = O(() => hn(e, n, r));
248
- E(() => {
249
- s(hn(e, n, r));
246
+ function pt(e, n, r) {
247
+ const [i, s] = x(() => yn(e, n, r));
248
+ A(() => {
249
+ s(yn(e, n, r));
250
250
  }, [e, n, r]);
251
- const o = w(
251
+ const o = E(
252
252
  (c) => {
253
- s(c), Hr(e, c, r);
253
+ s(c), Br(e, c, r);
254
254
  },
255
255
  [r, e]
256
256
  );
257
257
  return [i, o];
258
258
  }
259
- const vt = {}, li = [], yn = { status: "preparing" }, Pn = {
259
+ const ht = {}, fi = [], Rn = { status: "preparing" }, Tn = {
260
260
  openTabs: [],
261
261
  activeTab: null
262
262
  };
263
- function ci({ status: e }) {
263
+ function gi({ status: e }) {
264
264
  const n = e.status === "ready" ? void 0 : e.requirement, r = e.status !== "failed", i = r ? n === "workspace-fs" ? "Preparing files…" : n === "sandbox-exec" ? "Preparing secure runtime…" : n === "ui-bridge" ? "Connecting workspace…" : "Preparing workspace…" : "Workspace workbench failed", s = e.status === "failed" ? e.message : "Chat is ready while files, tools, and workspace panels finish warming up.";
265
- return /* @__PURE__ */ d("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ ye("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
265
+ return /* @__PURE__ */ d("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ Pe("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
266
266
  r ? /* @__PURE__ */ d("div", { className: "mx-auto mb-3 h-7 w-7 rounded-full border-2 border-muted-foreground/20 border-t-foreground animate-spin", "aria-hidden": "true" }) : null,
267
267
  /* @__PURE__ */ d("div", { className: "text-sm font-semibold text-foreground", children: i }),
268
268
  /* @__PURE__ */ d("p", { className: "mt-2 text-sm text-muted-foreground", children: s }),
269
269
  e.status === "failed" ? /* @__PURE__ */ d("p", { className: "mt-3 text-xs text-muted-foreground", children: "Reload the workspace to retry." }) : null
270
270
  ] }) });
271
271
  }
272
- function ui(e) {
273
- const n = e.workspaceId ?? di(e.requestHeaders) ?? e.storageKey, r = Lr({
272
+ function mi(e) {
273
+ const n = e.workspaceId ?? pi(e.requestHeaders) ?? e.storageKey, r = Cr({
274
274
  apiBaseUrl: e.apiBaseUrl,
275
275
  workspaceId: n,
276
276
  storageScope: n,
@@ -281,10 +281,10 @@ function ui(e) {
281
281
  });
282
282
  return { ...r, workspaceId: r.dataStorageScope };
283
283
  }
284
- function di(e) {
284
+ function pi(e) {
285
285
  return (e == null ? void 0 : e["x-boring-workspace-id"]) ?? (e == null ? void 0 : e["X-Boring-Workspace-Id"]) ?? null;
286
286
  }
287
- function fi(e) {
287
+ function hi(e) {
288
288
  const n = e.reloaded ? "Extensions reloaded." : "Extensions will reload on the next message.", r = Array.isArray(e.diagnostics) ? e.diagnostics.map((i) => i.message).filter((i) => !!i) : [];
289
289
  return r.length > 0 ? `${n}
290
290
 
@@ -292,7 +292,7 @@ Warnings:
292
292
  ${r.join(`
293
293
  `)}` : n;
294
294
  }
295
- function gi(e) {
295
+ function vi(e) {
296
296
  var n;
297
297
  try {
298
298
  return ((n = globalThis.localStorage) == null ? void 0 : n.getItem(e)) ?? null;
@@ -300,7 +300,7 @@ function gi(e) {
300
300
  return null;
301
301
  }
302
302
  }
303
- function En(e, n) {
303
+ function wn(e, n) {
304
304
  var r;
305
305
  try {
306
306
  const i = (r = globalThis.localStorage) == null ? void 0 : r.getItem(e);
@@ -313,7 +313,7 @@ function En(e, n) {
313
313
  return null;
314
314
  }
315
315
  }
316
- function mi(e, n) {
316
+ function Si(e, n) {
317
317
  var r, i;
318
318
  try {
319
319
  if (n.ids.length === 0) {
@@ -327,7 +327,7 @@ function mi(e, n) {
327
327
  } catch {
328
328
  }
329
329
  }
330
- function An(e, n) {
330
+ function Nn(e, n) {
331
331
  var r;
332
332
  try {
333
333
  const i = (r = globalThis.localStorage) == null ? void 0 : r.getItem(e);
@@ -338,7 +338,7 @@ function An(e, n) {
338
338
  return null;
339
339
  }
340
340
  }
341
- function pi(e, n) {
341
+ function bi(e, n) {
342
342
  var r, i;
343
343
  try {
344
344
  if (n.length === 0) {
@@ -349,27 +349,27 @@ function pi(e, n) {
349
349
  } catch {
350
350
  }
351
351
  }
352
- function hi() {
353
- return /* @__PURE__ */ d("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ ye("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
352
+ function yi() {
353
+ return /* @__PURE__ */ d("div", { className: "flex h-full min-h-0 items-center justify-center bg-background px-6 text-center", children: /* @__PURE__ */ Pe("div", { className: "max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm", children: [
354
354
  /* @__PURE__ */ d("div", { className: "mx-auto mb-3 h-7 w-7 rounded-full border-2 border-muted-foreground/20 border-t-foreground animate-spin", "aria-hidden": "true" }),
355
355
  /* @__PURE__ */ d("div", { className: "text-sm font-semibold text-foreground", children: "Loading sessions…" }),
356
356
  /* @__PURE__ */ d("p", { className: "mt-2 text-sm text-muted-foreground", children: "Finding this workspace’s saved chats." })
357
357
  ] }) });
358
358
  }
359
- function vi(e) {
359
+ function Pi(e) {
360
360
  if (!e) return "/api/v1/ui";
361
361
  const n = e.replace(/\/$/, ""), r = "/api/v1/ui";
362
362
  return n.endsWith(r) ? n : `${n}${r}`;
363
363
  }
364
- function bi(e) {
365
- return `${vi(e)}/state`;
364
+ function Ei(e) {
365
+ return `${Pi(e)}/state`;
366
366
  }
367
- function Si(e) {
367
+ function Ai(e) {
368
368
  var i;
369
369
  const n = e.openTabs.find((s) => s.id === e.activeTab), r = (i = n == null ? void 0 : n.params) == null ? void 0 : i.path;
370
370
  return typeof r == "string" ? r : null;
371
371
  }
372
- function yi({
372
+ function Ri({
373
373
  bridgeEndpoint: e,
374
374
  requestHeaders: n,
375
375
  navOpen: r,
@@ -377,34 +377,34 @@ function yi({
377
377
  surfaceReady: s,
378
378
  snapshot: o
379
379
  }) {
380
- const c = _n(), u = J(null);
381
- return E(() => {
382
- var S;
380
+ const c = Mn(), u = H(null);
381
+ return A(() => {
382
+ var b;
383
383
  if (e === null || i && !s) return;
384
- (S = u.current) == null || S.abort();
385
- const b = new AbortController();
386
- u.current = b;
384
+ (b = u.current) == null || b.abort();
385
+ const S = new AbortController();
386
+ u.current = S;
387
387
  const y = {
388
388
  v: 1,
389
389
  drawerOpen: r,
390
390
  workbenchOpen: i,
391
391
  openTabs: o.openTabs,
392
392
  activeTab: o.activeTab,
393
- activeFile: Si(o),
393
+ activeFile: Ai(o),
394
394
  availablePanels: c.list().map((j) => j.id)
395
395
  };
396
- return fetch(bi(e), {
396
+ return fetch(Ei(e), {
397
397
  method: "PUT",
398
398
  headers: { ...n, "Content-Type": "application/json" },
399
399
  body: JSON.stringify({ state: y, causedBy: "user" }),
400
- signal: b.signal
400
+ signal: S.signal
401
401
  }).catch(() => {
402
402
  }), () => {
403
- b.abort();
403
+ S.abort();
404
404
  };
405
405
  }, [e, r, c, n, o, i, s]), null;
406
406
  }
407
- function Ji({
407
+ function zi({
408
408
  workspaceId: e,
409
409
  chatPanel: n,
410
410
  useSessions: r,
@@ -413,118 +413,118 @@ function Ji({
413
413
  providerStorageKey: o,
414
414
  surfaceStorageKey: c,
415
415
  beforeShell: u,
416
- afterShell: b,
416
+ afterShell: S,
417
417
  panels: y,
418
- commands: S,
418
+ commands: b,
419
419
  catalogs: j,
420
420
  plugins: W,
421
421
  excludeDefaults: V,
422
- capabilities: R,
422
+ capabilities: T,
423
423
  apiBaseUrl: h,
424
- authHeaders: T,
424
+ authHeaders: w,
425
425
  apiTimeout: p,
426
426
  defaultTheme: N,
427
- onThemeChange: Ln,
428
- persistenceEnabled: Pt,
429
- debug: On,
430
- bridgeEndpoint: Qe,
431
- fullPageBasePath: xn,
432
- onAuthError: Mn,
433
- sessions: Et,
434
- activeSessionId: At,
435
- onSwitchSession: wt,
436
- onCreateSession: Ze,
427
+ onThemeChange: Fn,
428
+ persistenceEnabled: yt,
429
+ debug: Cn,
430
+ bridgeEndpoint: Ye,
431
+ fullPageBasePath: Wn,
432
+ onAuthError: Gn,
433
+ sessions: Pt,
434
+ activeSessionId: Et,
435
+ onSwitchSession: At,
436
+ onCreateSession: Xe,
437
437
  onDeleteSession: Rt,
438
- onActiveSessionIdChange: Pe,
439
- appTitle: Cn = "Sovereign Workspace",
440
- workspaceLabel: Fn,
441
- defaultSessionTitle: Y = "New session",
438
+ onActiveSessionIdChange: Ee,
439
+ appTitle: In = "Sovereign Workspace",
440
+ workspaceLabel: $n,
441
+ defaultSessionTitle: k = "New session",
442
442
  navEnabled: Tt = !0,
443
- defaultNavOpen: Wn = !1,
444
- defaultSurfaceOpen: Gn,
445
- defaultWorkbenchLeftTab: Ee,
446
- defaultWorkbenchLeftOpen: et,
447
- surfaceInitialPanels: Nt,
448
- topBarLeft: In,
449
- topBarRight: $n,
450
- showThemeToggle: Un = !0,
443
+ defaultNavOpen: Un = !1,
444
+ defaultSurfaceOpen: Kn,
445
+ defaultWorkbenchLeftTab: Ae,
446
+ defaultWorkbenchLeftOpen: Qe,
447
+ surfaceInitialPanels: wt,
448
+ topBarLeft: Hn,
449
+ topBarRight: Jn,
450
+ showThemeToggle: jn = !0,
451
451
  chatParams: L,
452
- externalPlugins: Kn,
453
- hotReloadEnabled: Hn,
454
- frontPluginHotReload: Jn,
455
- extraPanels: Dt,
456
- extraCommands: _t,
457
- provisionWorkspace: tt,
458
- bootPreloadPaths: jn,
459
- onWorkspaceWarmupStatusChange: Ae,
460
- onOpenNav: nt,
461
- onOpenSurface: rt,
462
- surfaceButtonBottomOffset: Bn,
463
- className: qn
452
+ externalPlugins: qn,
453
+ hotReloadEnabled: Bn,
454
+ frontPluginHotReload: zn,
455
+ extraPanels: Nt,
456
+ extraCommands: Dt,
457
+ provisionWorkspace: Ze,
458
+ bootPreloadPaths: Vn,
459
+ onWorkspaceWarmupStatusChange: Re,
460
+ onOpenNav: et,
461
+ onOpenSurface: tt,
462
+ surfaceButtonBottomOffset: kn,
463
+ className: Yn
464
464
  }) {
465
- var ln, cn;
466
- const Lt = Kn !== !1, zn = Lt ? Jn : !1, it = Lt ? Hn : !1, st = o ?? `boring-ui-v2:layout:${e}`, G = c ?? `${st}:surface`, we = ai(
465
+ var dn, fn;
466
+ const _t = qn !== !1, Xn = _t ? zn : !1, nt = _t ? Bn : !1, rt = o ?? `boring-ui-v2:layout:${e}`, G = c ?? `${rt}:surface`, Te = di(
467
467
  G,
468
- st
469
- ), M = Pt !== !1, Re = s ?? `boring-workspace:sessions:${e}`, k = F(
470
- () => ke(e, i ?? vt),
468
+ rt
469
+ ), F = yt !== !1, we = s ?? `boring-workspace:sessions:${e}`, Y = O(
470
+ () => Ve(e, i ?? ht),
471
471
  [i, e]
472
- ), Vn = F(
473
- () => ke(e, { ...i ?? vt, ...T ?? vt }),
474
- [T, i, e]
475
- ), Te = F(
476
- () => Xr({ storageKey: Re }),
477
- [Re]
478
- ), Ot = Qr(Te), [xt, Yn] = O(() => ({
472
+ ), Qn = O(
473
+ () => Ve(e, { ...i ?? ht, ...w ?? ht }),
474
+ [w, i, e]
475
+ ), Ne = O(
476
+ () => ti({ storageKey: we }),
477
+ [we]
478
+ ), Lt = ni(Ne), [Ot, Zn] = x(() => ({
479
479
  workspaceId: e,
480
- status: yn
481
- })), [Ne, ot] = O(() => ({
480
+ status: Rn
481
+ })), [De, it] = x(() => ({
482
482
  workspaceId: e,
483
483
  expired: !1
484
- })), [Mt, De] = O(() => ({
484
+ })), [xt, _e] = x(() => ({
485
485
  workspaceId: e,
486
486
  creating: !1
487
- })), [Ct, _e] = O(() => ({
487
+ })), [Mt, Le] = x(() => ({
488
488
  workspaceId: e,
489
489
  failed: !1
490
- })), [at, Ft] = O(null), de = `boring-workspace:chat-panes:${e}`, [D, q] = O(
491
- () => (M ? En(de, e) : null) ?? { workspaceId: e, ids: [], activeId: null }
492
- ), [ie, Wt] = O(null);
493
- E(() => {
490
+ })), [st, Ft] = x(null), fe = `boring-workspace:chat-panes:${e}`, [D, B] = x(
491
+ () => (F ? wn(fe, e) : null) ?? { workspaceId: e, ids: [], activeId: null }
492
+ ), [ie, Ct] = x(null);
493
+ A(() => {
494
494
  if (!ie) return;
495
- const t = setTimeout(() => Wt(null), 700);
495
+ const t = setTimeout(() => Ct(null), 700);
496
496
  return () => clearTimeout(t);
497
497
  }, [ie]);
498
- const fe = `boring-workspace:pinned-sessions:${e}`, [Gt, It] = O(
499
- () => (M ? An(fe, e) : null) ?? { workspaceId: e, ids: [] }
500
- ), kn = Gt.workspaceId === e ? Gt.ids : li;
501
- E(() => {
502
- It((t) => t.workspaceId === e ? t : (M ? An(fe, e) : null) ?? { workspaceId: e, ids: [] });
503
- }, [fe, M, e]);
504
- const Xn = w((t) => {
505
- It((a) => {
498
+ const ge = `boring-workspace:pinned-sessions:${e}`, [Wt, Gt] = x(
499
+ () => (F ? Nn(ge, e) : null) ?? { workspaceId: e, ids: [] }
500
+ ), er = Wt.workspaceId === e ? Wt.ids : fi;
501
+ A(() => {
502
+ Gt((t) => t.workspaceId === e ? t : (F ? Nn(ge, e) : null) ?? { workspaceId: e, ids: [] });
503
+ }, [ge, F, e]);
504
+ const tr = E((t) => {
505
+ Gt((a) => {
506
506
  const l = a.workspaceId === e ? a.ids : [], g = l.includes(t) ? l.filter((v) => v !== t) : [t, ...l];
507
- return M && pi(fe, g), { workspaceId: e, ids: g };
507
+ return F && bi(ge, g), { workspaceId: e, ids: g };
508
508
  });
509
- }, [fe, M, e]);
510
- E(() => {
511
- M && D.workspaceId === e && mi(de, D);
512
- }, [D, de, M, e]), E(() => {
513
- q((t) => t.workspaceId === e ? t : (M ? En(de, e) : null) ?? { workspaceId: e, ids: [], activeId: null });
514
- }, [de, M, e]);
515
- const Le = xt.workspaceId === e ? xt.status : yn, Qn = n ?? _r, Zn = r ?? ui, X = !n || !!r, Oe = X && tt !== !1, lt = () => {
516
- }, _ = Zn({
517
- requestHeaders: k,
518
- storageKey: Re,
509
+ }, [ge, F, e]);
510
+ A(() => {
511
+ F && D.workspaceId === e && Si(fe, D);
512
+ }, [D, fe, F, e]), A(() => {
513
+ B((t) => t.workspaceId === e ? t : (F ? wn(fe, e) : null) ?? { workspaceId: e, ids: [], activeId: null });
514
+ }, [fe, F, e]);
515
+ const Oe = Ot.workspaceId === e ? Ot.status : Rn, nr = n ?? Fr, rr = r ?? mi, X = !n || !!r, xe = X && Ze !== !1, ot = () => {
516
+ }, _ = rr({
517
+ requestHeaders: Y,
518
+ storageKey: we,
519
519
  workspaceId: e,
520
520
  apiBaseUrl: h,
521
- enabled: Oe
522
- }), [ge, er] = O(() => ({ workspaceId: e, sessions: [], activeSessionId: null })), $t = Oe && _.workspaceId != null && _.workspaceId !== e, z = Oe && !_.loading && !_.error && !$t, C = Oe && !z;
523
- E(() => {
524
- z && er((t) => {
525
- const a = t.workspaceId === e, l = t.activeSessionId === _.activeSessionId, g = t.sessions.length === _.sessions.length && t.sessions.every((v, A) => {
521
+ enabled: xe
522
+ }), [me, ir] = x(() => ({ workspaceId: e, sessions: [], activeSessionId: null })), It = xe && _.workspaceId != null && _.workspaceId !== e, z = xe && !_.loading && !_.error && !It, C = xe && !z;
523
+ A(() => {
524
+ z && ir((t) => {
525
+ const a = t.workspaceId === e, l = t.activeSessionId === _.activeSessionId, g = t.sessions.length === _.sessions.length && t.sessions.every((v, R) => {
526
526
  var ne;
527
- return v.id === ((ne = _.sessions[A]) == null ? void 0 : ne.id);
527
+ return v.id === ((ne = _.sessions[R]) == null ? void 0 : ne.id);
528
528
  });
529
529
  return a && l && g ? t : {
530
530
  workspaceId: e,
@@ -533,357 +533,367 @@ function Ji({
533
533
  };
534
534
  });
535
535
  }, [_.activeSessionId, _.sessions, z, e]);
536
- const xe = C && ge.workspaceId === e && ge.sessions.length > 0, Me = C ? gi(Re) : null, Ut = C && !$t ? _.activeSessionId ?? null : null, Q = z ? _.sessions : xe ? ge.sessions : [], tr = z ? _.activeSessionId : xe ? ge.activeSessionId : null, f = X && (z || xe) ? _ : void 0, se = Et !== void 0 || At !== void 0 || wt !== void 0 || Ze !== void 0 || Rt !== void 0, Kt = Ne.workspaceId === e && Ne.expired, me = J(!1), pe = !!(z && f && !se && Q.length === 0 && !Kt), nr = Mt.workspaceId === e && Mt.creating, rr = Ct.workspaceId === e && Ct.failed, ir = !!(z && f && !se && Q.length === 0 && Kt && !me.current && !rr), Ce = !!(C && _.loading && !_.error && X && !se && !xe && !Me && !Ut) || pe || nr || ir;
537
- E(() => {
538
- if (!pe) {
539
- Ne.workspaceId !== e && ot({ workspaceId: e, expired: !1 });
536
+ const Me = C && me.workspaceId === e && me.sessions.length > 0, Fe = C ? vi(we) : null, $t = C && !It ? _.activeSessionId ?? null : null, Q = z ? _.sessions : Me ? me.sessions : [], sr = z ? _.activeSessionId : Me ? me.activeSessionId : null, f = X && (z || Me) ? _ : void 0, se = Pt !== void 0 || Et !== void 0 || At !== void 0 || Xe !== void 0 || Rt !== void 0, Ut = De.workspaceId === e && De.expired, pe = H(!1), he = !!(z && f && !se && Q.length === 0 && !Ut), or = xt.workspaceId === e && xt.creating, ar = Mt.workspaceId === e && Mt.failed, lr = !!(z && f && !se && Q.length === 0 && Ut && !pe.current && !ar), Ce = !!(C && _.loading && !_.error && X && !se && !Me && !Fe && !$t) || he || or || lr;
537
+ A(() => {
538
+ if (!he) {
539
+ De.workspaceId !== e && it({ workspaceId: e, expired: !1 });
540
540
  return;
541
541
  }
542
- ot({ workspaceId: e, expired: !1 });
542
+ it({ workspaceId: e, expired: !1 });
543
543
  const t = globalThis.setTimeout(() => {
544
- ot({ workspaceId: e, expired: !0 });
544
+ it({ workspaceId: e, expired: !0 });
545
545
  }, 2e3);
546
546
  return () => globalThis.clearTimeout(t);
547
- }, [Ne.workspaceId, pe, e]);
548
- const sr = f ? Q.map((t) => ({
547
+ }, [De.workspaceId, he, e]);
548
+ const cr = f ? Q.map((t) => ({
549
549
  ...t,
550
550
  title: t.title ?? "New session"
551
- })) : void 0, or = Me ? [{
552
- id: Me,
551
+ })) : void 0, ur = Fe ? [{
552
+ id: Fe,
553
553
  title: "Loading sessions…",
554
554
  createdAt: (/* @__PURE__ */ new Date(0)).toISOString(),
555
555
  updatedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
556
556
  turnCount: 0
557
- }] : [], $ = f ? sr ?? [] : C ? or : se ? Et ?? [] : Ot.sessions, ar = f ? tr ?? null : C ? Me ?? Ut : se ? At ?? null : Ot.activeId, oe = (L == null ? void 0 : L.autoSubmitInitialDraft) === !0, Fe = oe && X && !se, [U, he] = O(() => Fe ? null : void 0), Ht = J(e), ae = J(!1);
558
- E(() => {
559
- if (Ht.current !== e) {
560
- Ht.current = e, ae.current = !1, he(Fe ? null : void 0);
557
+ }] : [], $ = f ? cr ?? [] : C ? ur : se ? Pt ?? [] : Lt.sessions, dr = f ? sr ?? null : C ? Fe ?? $t : se ? Et ?? null : Lt.activeId, oe = (L == null ? void 0 : L.autoSubmitInitialDraft) === !0, We = oe && X && !se, [U, ve] = x(() => We ? null : void 0), Kt = H(e), ae = H(!1);
558
+ A(() => {
559
+ if (Kt.current !== e) {
560
+ Kt.current = e, ae.current = !1, ve(We ? null : void 0);
561
561
  return;
562
562
  }
563
- Fe && U === void 0 && (ae.current = !1, he(null));
564
- }, [U, Fe, e]), E(() => {
565
- !f || U !== null || ae.current || (ae.current = !0, Promise.resolve(f.create({ title: Y })).then((t) => {
563
+ We && U === void 0 && (ae.current = !1, ve(null));
564
+ }, [U, We, e]), A(() => {
565
+ !f || U !== null || ae.current || (ae.current = !0, Promise.resolve(f.create({ title: k })).then((t) => {
566
566
  if (typeof (t == null ? void 0 : t.id) != "string")
567
567
  throw new Error("auto_submit_session_create_failed");
568
- he(t.id);
568
+ ve(t.id);
569
569
  }).catch(() => {
570
- ae.current = !1, he(void 0);
570
+ ae.current = !1, ve(void 0);
571
571
  }));
572
- }, [U, Y, f]);
573
- const I = U !== void 0 ? U ?? null : ar, H = C ? lt : (f == null ? void 0 : f.switch) ?? wt ?? Te.switchTo, We = w((t) => (I && t !== I && window.dispatchEvent(new CustomEvent("boring:workspace-composer-stop", { detail: { sessionId: I } })), H(t)), [I, H]), ct = C ? lt : f ? () => f.create() : Ze ? () => Ze() : () => Te.create(), Jt = C ? lt : (f == null ? void 0 : f.delete) ?? Rt ?? Te.remove, jt = w((t) => (f && Q.length <= 1 && (me.current = !0), Jt(t)), [Q.length, Jt, f]), lr = ((ln = $.find((t) => t.id === I)) == null ? void 0 : ln.title) ?? void 0, [cr, Bt] = ht(
574
- `${we}:drawer`,
575
- Wn,
576
- M
577
- ), qt = Tt && cr, [Z, B] = ht(
572
+ }, [U, k, f]);
573
+ const I = U !== void 0 ? U ?? null : dr, J = C ? ot : (f == null ? void 0 : f.switch) ?? At ?? Ne.switchTo, Ge = E((t) => (I && t !== I && window.dispatchEvent(new CustomEvent("boring:workspace-composer-stop", { detail: { sessionId: I } })), J(t)), [I, J]), at = C ? ot : f ? () => f.create() : Xe ? () => Xe() : () => Ne.create(), Ht = C ? ot : (f == null ? void 0 : f.delete) ?? Rt ?? Ne.remove, Jt = E((t) => (f && Q.length <= 1 && (pe.current = !0), Ht(t)), [Q.length, Ht, f]), fr = ((dn = $.find((t) => t.id === I)) == null ? void 0 : dn.title) ?? void 0, [gr, jt] = pt(
574
+ `${Te}:drawer`,
575
+ Un,
576
+ F
577
+ ), qt = Tt && gr, [Z, q] = pt(
578
578
  // Key must NOT match resolvedSurfaceStorageKey (which stores the dockview
579
579
  // layout JSON at the same ":surface" suffix). Writing "1"/"0" to the same
580
580
  // key corrupts the JSON and drops the persisted workbench layout on reload.
581
- `${we}:workbenchOpen`,
582
- Gn ?? !1,
583
- M
584
- ), [ur, ut] = O(!1), [dr, ve] = ht(
585
- `${we}:workbenchLeftOpen`,
586
- et ?? !1,
587
- M
588
- ), [fr, Ge] = O(() => et ?? !1), gr = et === !1 ? fr : dr, be = J(!1), ee = J(null), te = J(Z), zt = J(G), dt = J(null);
589
- zt.current = G;
590
- const [Vt, Yt] = O(() => ({
581
+ `${Te}:workbenchOpen`,
582
+ Kn ?? !1,
583
+ F
584
+ ), [mr, lt] = x(!1), [pr, Se] = pt(
585
+ `${Te}:workbenchLeftOpen`,
586
+ Qe ?? !1,
587
+ F
588
+ ), [hr, Ie] = x(() => Qe ?? !1), vr = Qe === !1 ? hr : pr, be = H(!1), ee = H(null), te = H(Z), Bt = H(G), ct = H(null), ut = H([]);
589
+ Bt.current = G;
590
+ const [zt, Vt] = x(() => ({
591
591
  key: G,
592
- snapshot: Pn
593
- })), mr = Vt.key === G ? Vt.snapshot : Pn;
594
- E(() => {
595
- be.current = !1, me.current = !1, De({ workspaceId: e, creating: !1 }), _e({ workspaceId: e, failed: !1 }), Ft(null);
596
- }, [e]), E(() => {
597
- ut(!1);
598
- }, [G]), E(() => {
599
- if (!(!f || f.loading) && !pe && U === void 0) {
592
+ snapshot: Tn
593
+ })), Sr = zt.key === G ? zt.snapshot : Tn;
594
+ A(() => {
595
+ be.current = !1, pe.current = !1, _e({ workspaceId: e, creating: !1 }), Le({ workspaceId: e, failed: !1 }), Ft(null);
596
+ }, [e]), A(() => {
597
+ lt(!1), ut.current = [];
598
+ }, [G]), A(() => {
599
+ if (!(!f || f.loading) && !he && U === void 0) {
600
600
  if (Q.length > 0) {
601
- be.current = !1, me.current = !1, De((t) => t.workspaceId === e && t.creating ? { workspaceId: e, creating: !1 } : t), _e((t) => t.workspaceId === e && t.failed ? { workspaceId: e, failed: !1 } : t);
601
+ be.current = !1, pe.current = !1, _e((t) => t.workspaceId === e && t.creating ? { workspaceId: e, creating: !1 } : t), Le((t) => t.workspaceId === e && t.failed ? { workspaceId: e, failed: !1 } : t);
602
602
  return;
603
603
  }
604
- me.current || be.current || (be.current = !0, De({ workspaceId: e, creating: !0 }), _e({ workspaceId: e, failed: !1 }), Promise.resolve(f.create({ title: Y })).then((t) => {
604
+ pe.current || be.current || (be.current = !0, _e({ workspaceId: e, creating: !0 }), Le({ workspaceId: e, failed: !1 }), Promise.resolve(f.create({ title: k })).then((t) => {
605
605
  const a = t == null ? void 0 : t.id;
606
606
  typeof a == "string" && Ft({ workspaceId: e, id: a });
607
607
  }).catch(() => {
608
- be.current = !1, De({ workspaceId: e, creating: !1 }), _e({ workspaceId: e, failed: !0 });
608
+ be.current = !1, _e({ workspaceId: e, creating: !1 }), Le({ workspaceId: e, failed: !0 });
609
609
  }));
610
610
  }
611
- }, [Q.length, U, Y, pe, f, e]), E(() => {
611
+ }, [Q.length, U, k, he, f, e]), A(() => {
612
612
  te.current = Z;
613
613
  }, [Z]);
614
- const kt = w((t) => {
615
- dt.current = { key: G, api: t }, ut(!0), Yt({
614
+ const kt = E((t) => {
615
+ ct.current = { key: G, api: t }, lt(!0), Vt({
616
616
  key: G,
617
617
  snapshot: t.getSnapshot()
618
618
  });
619
- }, [G]), Xt = w((t) => {
620
- Yt({
619
+ const a = ut.current.splice(0);
620
+ for (const l of a) l(t);
621
+ }, [G]), Yt = E((t) => {
622
+ ut.current.push(t);
623
+ }, []), Xt = E((t) => {
624
+ Vt({
621
625
  key: G,
622
626
  snapshot: t
623
627
  });
624
- }, [G]), Ie = w(() => {
625
- const t = dt.current;
626
- return (t == null ? void 0 : t.key) === zt.current ? t.api : null;
627
- }, []), $e = w(() => te.current, []), Ue = w(() => {
628
- te.current = !0, B(!0);
629
- }, [B]), Ke = w(() => {
630
- te.current = !0, B(!0), ve(!0), Ge(!0);
631
- }, [B, ve]), He = w(() => {
632
- te.current = !1, dt.current = null, ut(!1), B(!1);
633
- }, [B]), le = F(
634
- () => (W == null ? void 0 : W.map(Mr)) ?? [],
628
+ }, [G]), $e = E(() => {
629
+ const t = ct.current;
630
+ return (t == null ? void 0 : t.key) === Bt.current ? t.api : null;
631
+ }, []), Qt = E(() => te.current, []), Zt = E(() => {
632
+ te.current = !0, q(!0);
633
+ }, [q]), en = E(() => {
634
+ te.current = !0, q(!0), Se(!0), Ie(!0);
635
+ }, [q, Se]), Ue = E(() => {
636
+ te.current = !1, ct.current = null, lt(!1), q(!1);
637
+ }, [q]), le = O(() => ({
638
+ surface: $e,
639
+ isWorkbenchOpen: Qt,
640
+ openWorkbench: Zt,
641
+ openWorkbenchSources: en,
642
+ closeWorkbench: Ue,
643
+ enqueue: Yt
644
+ }), [$e, Qt, Zt, en, Ue, Yt]), br = O(() => ({
645
+ openFile: async (t) => (Sn({ kind: "openFile", params: { path: t } }, le), { seq: 0, status: "ok" }),
646
+ getActiveFile: () => {
647
+ var t;
648
+ return ((t = $e()) == null ? void 0 : t.getSnapshot().activeTab) ?? null;
649
+ },
650
+ select: () => () => {
651
+ }
652
+ }), [$e, le]), ce = O(
653
+ () => (W == null ? void 0 : W.map(Ir)) ?? [],
635
654
  [W]
636
- ), ft = F(
637
- () => le.some((t) => t.registrations.leftTabs.length > 0),
638
- [le]
639
- ), Qt = F(
640
- () => le.flatMap((t) => t.registrations.panels.map((a) => a.id)),
641
- [le]
642
- ), Zt = F(() => {
655
+ ), dt = O(
656
+ () => ce.some((t) => t.registrations.leftTabs.length > 0),
657
+ [ce]
658
+ ), tn = O(
659
+ () => ce.flatMap((t) => t.registrations.panels.map((a) => a.id)),
660
+ [ce]
661
+ ), nn = O(() => {
643
662
  const t = {};
644
- for (const a of le)
663
+ for (const a of ce)
645
664
  for (const l of a.registrations.toolRenderers)
646
665
  t[l.id] = l.render;
647
666
  return t;
648
- }, [le]), en = F(
649
- () => [...Dt ?? [], ...Qt],
650
- [Dt, Qt]
651
- ), m = X && !r && ge.workspaceId !== e ? "default" : I ?? (U !== void 0 ? "default" : ((cn = $[0]) == null ? void 0 : cn.id) ?? "default"), tn = !(f != null && f.hasMore) && !C;
652
- E(() => {
653
- var ne, un;
667
+ }, [ce]), rn = O(
668
+ () => [...Nt ?? [], ...tn],
669
+ [Nt, tn]
670
+ ), m = X && !r && me.workspaceId !== e ? "default" : I ?? (U !== void 0 ? "default" : ((fn = $[0]) == null ? void 0 : fn.id) ?? "default"), sn = !(f != null && f.hasMore) && !C;
671
+ A(() => {
672
+ var ne, gn;
654
673
  if (Ce) return;
655
674
  const t = ee.current, a = new Set($.map((K) => K.id)), l = t ? t.createdId ?? (a.has(m) && !t.knownIds.has(m) ? m : ((ne = $.find((K) => !t.knownIds.has(K.id))) == null ? void 0 : ne.id) ?? null) : null;
656
675
  l && a.has(l) && (ee.current = null);
657
- const g = m === "default" && U !== void 0, v = tn && a.size > 0 && !g, A = l ?? (v && !a.has(m) ? ((un = $[0]) == null ? void 0 : un.id) ?? m : m);
658
- q((K) => {
676
+ const g = m === "default" && U !== void 0, v = sn && a.size > 0 && !g, R = l ?? (v && !a.has(m) ? ((gn = $[0]) == null ? void 0 : gn.id) ?? m : m);
677
+ B((K) => {
659
678
  const re = K.workspaceId === e ? K : { workspaceId: e, ids: [], activeId: null };
660
679
  if (C && re.ids.length > 0 && !l) return re;
661
- const dn = re.ids.length > 0 ? re.ids : [A], fn = v ? dn.filter((ze) => a.has(ze) || ze === l) : dn, ce = fn.length > 0 ? fn : [A], gn = re.activeId && ce.includes(re.activeId) ? re.activeId : ce[0] ?? A, Se = l ? Ve(ce, t == null ? void 0 : t.afterId, l) : A === gn || ce.includes(A) ? ce : Sn(ce, gn, A), mn = Se.includes(A) ? A : Se[0] ?? A;
662
- return K.workspaceId === e && K.activeId === mn && K.ids.length === Se.length && K.ids.every((ze, Tr) => ze === Se[Tr]) ? K : { workspaceId: e, ids: Se, activeId: mn };
680
+ const mn = re.ids.length > 0 ? re.ids : [R], pn = v ? mn.filter((qe) => a.has(qe) || qe === l) : mn, ue = pn.length > 0 ? pn : [R], hn = re.activeId && ue.includes(re.activeId) ? re.activeId : ue[0] ?? R, ye = l ? Be(ue, t == null ? void 0 : t.afterId, l) : R === hn || ue.includes(R) ? ue : An(ue, hn, R), vn = ye.includes(R) ? R : ye[0] ?? R;
681
+ return K.workspaceId === e && K.activeId === vn && K.ids.length === ye.length && K.ids.every((qe, Or) => qe === ye[Or]) ? K : { workspaceId: e, ids: ye, activeId: vn };
663
682
  });
664
- }, [U, m, C, Ce, $, tn, e]);
665
- const nn = F(() => {
683
+ }, [U, m, C, Ce, $, sn, e]);
684
+ const on = O(() => {
666
685
  const t = /* @__PURE__ */ new Map();
667
686
  for (const a of $) t.set(a.id, a.title);
668
687
  return t;
669
- }, [$]), gt = D.workspaceId === e ? D : { ids: [], activeId: null }, Je = gt.ids.length > 0 ? gt.ids : [m], je = gt.activeId ?? Je[0] ?? m, pr = w((t) => {
688
+ }, [$]), ft = D.workspaceId === e ? D : { ids: [], activeId: null }, Ke = ft.ids.length > 0 ? ft.ids : [m], He = ft.activeId ?? Ke[0] ?? m, yr = E((t) => {
670
689
  const l = (D.workspaceId === e ? D : { ids: [m] }).ids.includes(t);
671
- return q((g) => {
672
- const v = g.workspaceId === e ? g : { ids: [m], activeId: m }, A = v.ids.includes(t) ? v.ids : Sn(v.ids, v.activeId, t);
673
- return { workspaceId: e, ids: A, activeId: t };
674
- }), l ? H(t) : We(t);
675
- }, [D, m, H, We, e]), hr = w((t) => (q((a) => {
690
+ return B((g) => {
691
+ const v = g.workspaceId === e ? g : { ids: [m], activeId: m }, R = v.ids.includes(t) ? v.ids : An(v.ids, v.activeId, t);
692
+ return { workspaceId: e, ids: R, activeId: t };
693
+ }), l ? J(t) : Ge(t);
694
+ }, [D, m, J, Ge, e]), Pr = E((t) => (B((a) => {
676
695
  const l = a.workspaceId === e ? a : { ids: [m], activeId: m };
677
696
  return {
678
697
  workspaceId: e,
679
- ids: l.ids.includes(t) ? l.ids : Ve(l.ids, l.activeId, t),
698
+ ids: l.ids.includes(t) ? l.ids : Be(l.ids, l.activeId, t),
680
699
  activeId: t
681
700
  };
682
- }), H(t)), [m, H, e]), rn = w((t) => ((D.workspaceId === e ? D : { ids: [m] }).ids.includes(t) && Wt({ workspaceId: e, id: t }), q((l) => {
701
+ }), J(t)), [m, J, e]), an = E((t) => ((D.workspaceId === e ? D : { ids: [m] }).ids.includes(t) && Ct({ workspaceId: e, id: t }), B((l) => {
683
702
  const g = l.workspaceId === e ? l : { ids: [m], activeId: m };
684
703
  return {
685
704
  workspaceId: e,
686
- ids: Ve(g.ids, g.activeId, t),
705
+ ids: Be(g.ids, g.activeId, t),
687
706
  activeId: t
688
707
  };
689
- }), H(t)), [D, m, H, e]), vr = w((t) => {
708
+ }), J(t)), [D, m, J, e]), Er = E((t) => {
690
709
  const a = D.workspaceId === e ? D : { ids: [m], activeId: m };
691
710
  if (a.ids.length <= 1) return;
692
711
  const l = a.ids.indexOf(t);
693
712
  if (l < 0) return;
694
- const g = a.ids.filter((A) => A !== t), v = a.activeId === t ? g[Math.max(0, l - 1)] ?? g[0] ?? null : a.activeId;
695
- q({ workspaceId: e, ids: g, activeId: v }), v && a.activeId === t && H(v);
696
- }, [D, m, H, e]), br = w((t) => {
713
+ const g = a.ids.filter((R) => R !== t), v = a.activeId === t ? g[Math.max(0, l - 1)] ?? g[0] ?? null : a.activeId;
714
+ B({ workspaceId: e, ids: g, activeId: v }), v && a.activeId === t && J(v);
715
+ }, [D, m, J, e]), Ar = E((t) => {
697
716
  const a = {
698
717
  afterId: t,
699
718
  knownIds: new Set($.map((g) => g.id))
700
719
  };
701
720
  ee.current = a;
702
- const l = ct();
721
+ const l = at();
703
722
  return Promise.resolve(l).then((g) => {
704
- const v = oi(g);
705
- v && (ee.current === a && (ee.current = { ...a, createdId: v }), q((A) => {
706
- const ne = A.workspaceId === e ? A : { ids: [m] };
723
+ const v = ui(g);
724
+ v && (ee.current === a && (ee.current = { ...a, createdId: v }), B((R) => {
725
+ const ne = R.workspaceId === e ? R : { ids: [m] };
707
726
  return {
708
727
  workspaceId: e,
709
- ids: Ve(ne.ids, t, v),
728
+ ids: Be(ne.ids, t, v),
710
729
  activeId: v
711
730
  };
712
731
  }));
713
732
  }).catch(() => {
714
733
  ee.current === a && (ee.current = null);
715
734
  }), l;
716
- }, [m, ct, $, e]), Sr = w((t) => {
735
+ }, [m, at, $, e]), Rr = E((t) => {
717
736
  const a = D.workspaceId === e ? D : { ids: [m], activeId: m }, l = a.ids.indexOf(t);
718
737
  let g = a.activeId;
719
738
  if (l >= 0) {
720
- const v = a.ids.filter((A) => A !== t);
721
- g = a.activeId === t ? v[Math.max(0, l - 1)] ?? v[0] ?? null : a.activeId, q({ workspaceId: e, ids: v, activeId: g }), g && a.activeId === t && We(g);
739
+ const v = a.ids.filter((R) => R !== t);
740
+ g = a.activeId === t ? v[Math.max(0, l - 1)] ?? v[0] ?? null : a.activeId, B({ workspaceId: e, ids: v, activeId: g }), g && a.activeId === t && Ge(g);
722
741
  }
723
- return jt(t);
724
- }, [D, m, jt, We, e]), [yr, mt] = O(oe), sn = J(e);
725
- E(() => {
726
- if (sn.current !== e) {
727
- sn.current = e, mt(oe);
742
+ return Jt(t);
743
+ }, [D, m, Jt, Ge, e]), [Tr, gt] = x(oe), ln = H(e);
744
+ A(() => {
745
+ if (ln.current !== e) {
746
+ ln.current = e, gt(oe);
728
747
  return;
729
748
  }
730
- oe && mt(!0);
749
+ oe && gt(!0);
731
750
  }, [oe, e]);
732
- const on = oe && X && !I, an = !!!(at && at.workspaceId === e && at.id === I) && !yr && tt !== !1 && (X ? !!I : !0), Pr = w((t) => {
733
- Yn({ workspaceId: e, status: t }), Ae == null || Ae(t);
734
- }, [Ae, e]);
735
- E(() => {
751
+ const cn = oe && X && !I, un = !!!(st && st.workspaceId === e && st.id === I) && !Tr && Ze !== !1 && (X ? !!I : !0), wr = E((t) => {
752
+ Zn({ workspaceId: e, status: t }), Re == null || Re(t);
753
+ }, [Re, e]);
754
+ A(() => {
736
755
  var a;
737
756
  const t = (l) => {
738
757
  const g = l.detail;
739
- !g || typeof g != "object" || Wr(g, {
740
- surface: Ie,
741
- isWorkbenchOpen: $e,
742
- openWorkbench: Ue,
743
- openWorkbenchSources: Ke
744
- });
758
+ !g || typeof g != "object" || Sn(g, le);
745
759
  };
746
- return (a = globalThis.addEventListener) == null || a.call(globalThis, pn, t), () => {
760
+ return (a = globalThis.addEventListener) == null || a.call(globalThis, bn, t), () => {
747
761
  var l;
748
- return (l = globalThis.removeEventListener) == null ? void 0 : l.call(globalThis, pn, t);
762
+ return (l = globalThis.removeEventListener) == null ? void 0 : l.call(globalThis, bn, t);
749
763
  };
750
- }, [Ie, $e, Ue, Ke]), E(() => {
751
- C || Pe == null || Pe(I ?? null);
752
- }, [I, Pe, C]);
753
- const pt = Le.status !== "ready", Er = pt ? /* @__PURE__ */ d(ci, { status: Le }) : void 0, Be = w(async (t) => {
764
+ }, [le]), A(() => {
765
+ C || Ee == null || Ee(I ?? null);
766
+ }, [I, Ee, C]);
767
+ const mt = Oe.status !== "ready", Nr = mt ? /* @__PURE__ */ d(gi, { status: Oe }) : void 0, Je = E(async (t) => {
754
768
  const a = `${(h == null ? void 0 : h.replace(/\/$/, "")) ?? ""}/api/v1/agent/reload`;
755
769
  try {
756
770
  const l = await fetch(a, {
757
771
  method: "POST",
758
- headers: { ...k, "content-type": "application/json" },
772
+ headers: { ...Y, "content-type": "application/json" },
759
773
  body: JSON.stringify({ sessionId: t })
760
774
  });
761
775
  if (!l.ok)
762
776
  return (await l.json().catch(() => ({}))).error || `reload failed (${l.status})`;
763
777
  const g = await l.json().catch(() => ({}));
764
- return window.dispatchEvent(new CustomEvent(Cr, { detail: g })), fi(g);
778
+ return window.dispatchEvent(new CustomEvent($r, { detail: g })), hi(g);
765
779
  } catch (l) {
766
780
  return l instanceof Error ? l.message : "Agent plugin reload failed.";
767
781
  }
768
- }, [h, k]), qe = w(
782
+ }, [h, Y]), je = E(
769
783
  (t, a = {}) => {
770
784
  const l = a.bridgeEnabled ?? !0, g = L != null && L.toolRenderers && typeof L.toolRenderers == "object" ? L.toolRenderers : void 0;
771
785
  return {
772
786
  ...L,
773
- ...on ? { autoSubmitInitialDraft: !1, initialDraft: void 0 } : {},
787
+ ...cn ? { autoSubmitInitialDraft: !1, initialDraft: void 0 } : {},
774
788
  sessionId: t,
775
789
  apiBaseUrl: h,
776
790
  workspaceId: e,
777
791
  storageScope: e,
778
- requestHeaders: k,
792
+ requestHeaders: Y,
779
793
  showSessions: !1,
780
- onReloadAgentPlugins: (L == null ? void 0 : L.onReloadAgentPlugins) ?? (() => Be(t)),
781
- toolRenderers: { ...Zt, ...g ?? {} },
782
- bridgeEndpoint: l ? Qe : null,
783
- getSurface: Ie,
784
- isWorkbenchOpen: $e,
785
- openWorkbench: Ue,
786
- openWorkbenchSources: Ke,
787
- closeWorkbench: He,
788
- extraCommands: _t,
789
- workspaceWarmupStatus: Le,
790
- hydrateMessages: an,
794
+ onReloadAgentPlugins: (L == null ? void 0 : L.onReloadAgentPlugins) ?? (() => Je(t)),
795
+ toolRenderers: { ...nn, ...g ?? {} },
796
+ bridgeEndpoint: l ? Ye : null,
797
+ surfaceDispatch: le,
798
+ extraCommands: Dt,
799
+ workspaceWarmupStatus: Oe,
800
+ hydrateMessages: un,
791
801
  onAutoSubmitInitialDraftSettled: () => {
792
- ae.current = !1, mt(!1), he(void 0);
802
+ ae.current = !1, gt(!1), ve(void 0);
793
803
  const v = L == null ? void 0 : L.onAutoSubmitInitialDraftSettled;
794
804
  typeof v == "function" && v();
795
805
  },
796
806
  // Forward the explicit prop when set. Omitting the key (when undefined)
797
807
  // lets ChatPanel apply its own default (true) and avoids overriding a
798
808
  // value passed through chatParams.
799
- ...it !== void 0 ? { hotReloadEnabled: it } : {}
809
+ ...nt !== void 0 ? { hotReloadEnabled: nt } : {}
800
810
  };
801
811
  },
802
- [h, L, on, k, Qe, Ie, $e, Ue, Ke, He, _t, Le, an, it, Zt, Be, e]
803
- ), Ar = F(
804
- () => qe(m),
805
- [m, qe]
806
- ), wr = F(() => Je.map((t) => ({
812
+ [h, L, cn, Y, Ye, le, Dt, Oe, un, nt, nn, Je, e]
813
+ ), Dr = O(
814
+ () => je(m),
815
+ [m, je]
816
+ ), _r = O(() => Ke.map((t) => ({
807
817
  id: t,
808
- title: nn.get(t) ?? (t === "default" ? Y : t),
818
+ title: on.get(t) ?? (t === "default" ? k : t),
809
819
  panel: "chat",
810
- params: qe(t, { bridgeEnabled: t === je })
811
- })), [je, Je, Y, qe, nn]), Rr = F(() => ({
820
+ params: je(t, { bridgeEnabled: t === He })
821
+ })), [He, Ke, k, je, on]), Lr = O(() => ({
812
822
  storageKey: G,
813
- defaultLeftTab: Ee,
814
- initialPanels: Nt,
815
- extraPanels: en,
816
- onReloadAgentPlugins: () => Be(I ?? m),
823
+ defaultLeftTab: Ae,
824
+ initialPanels: wt,
825
+ extraPanels: rn,
826
+ onReloadAgentPlugins: () => Je(I ?? m),
817
827
  onReady: kt,
818
828
  onChange: Xt,
819
- onClose: He
829
+ onClose: Ue
820
830
  }), [
821
- He,
822
- Ee,
823
- Nt,
824
- Be,
831
+ Ue,
832
+ Ae,
833
+ wt,
834
+ Je,
825
835
  I,
826
836
  m,
827
837
  Xt,
828
838
  kt,
829
839
  G,
830
- en,
831
- B
840
+ rn,
841
+ q
832
842
  ]);
833
- return /* @__PURE__ */ d("div", { className: "h-full bg-background text-foreground", children: /* @__PURE__ */ ye(
834
- Fr,
843
+ return /* @__PURE__ */ d("div", { className: "h-full bg-background text-foreground", children: /* @__PURE__ */ Pe(
844
+ Ur,
835
845
  {
836
- chatPanel: Qn,
846
+ chatPanel: nr,
837
847
  panels: y,
838
- commands: S,
848
+ commands: b,
839
849
  catalogs: j,
840
850
  plugins: W,
841
851
  excludeDefaults: V,
842
- capabilities: R,
852
+ capabilities: T,
843
853
  apiBaseUrl: h,
844
- authHeaders: Vn,
854
+ authHeaders: Qn,
845
855
  apiTimeout: p,
846
856
  defaultTheme: N,
847
- onThemeChange: Ln,
857
+ onThemeChange: Fn,
848
858
  workspaceId: e,
849
- workspaceLabel: Fn,
850
- storageKey: st,
851
- persistenceEnabled: Pt,
852
- debug: On,
859
+ workspaceLabel: $n,
860
+ storageKey: rt,
861
+ persistenceEnabled: yt,
862
+ debug: Cn,
853
863
  bridgeEndpoint: null,
854
- onAuthError: Mn,
855
- frontPluginHotReload: zn,
856
- fullPageBasePath: xn,
864
+ onAuthError: Gn,
865
+ frontPluginHotReload: Xn,
866
+ fullPageBasePath: Wn,
857
867
  children: [
858
868
  u,
859
869
  /* @__PURE__ */ d(
860
- si,
870
+ ci,
861
871
  {
862
872
  workspaceId: e,
863
- requestHeaders: k,
873
+ requestHeaders: Y,
864
874
  apiBaseUrl: h,
865
- preloadPaths: jn,
866
- provisionWorkspace: tt,
867
- onStatusChange: Pr
875
+ preloadPaths: Vn,
876
+ provisionWorkspace: Ze,
877
+ onStatusChange: wr
868
878
  }
869
879
  ),
870
880
  /* @__PURE__ */ d(
871
- yi,
881
+ Ri,
872
882
  {
873
- bridgeEndpoint: Qe,
874
- requestHeaders: k,
883
+ bridgeEndpoint: Ye,
884
+ requestHeaders: Y,
875
885
  navOpen: qt,
876
886
  surfaceOpen: Z,
877
- surfaceReady: ur,
878
- snapshot: mr
887
+ surfaceReady: mr,
888
+ snapshot: Sr
879
889
  }
880
890
  ),
881
- /* @__PURE__ */ ye("div", { className: "flex h-full min-h-0 flex-col", children: [
891
+ /* @__PURE__ */ Pe("div", { className: "flex h-full min-h-0 flex-col", children: [
882
892
  /* @__PURE__ */ d(
883
- Ur,
893
+ jr,
884
894
  {
885
- appTitle: Cn,
886
- sessionTitle: Ce ? "Loading sessions…" : lr ?? Y,
895
+ appTitle: In,
896
+ sessionTitle: Ce ? "Loading sessions…" : fr ?? k,
887
897
  onCommandPalette: () => {
888
898
  document.dispatchEvent(new KeyboardEvent("keydown", {
889
899
  key: "k",
@@ -893,76 +903,77 @@ function Ji({
893
903
  cancelable: !0
894
904
  }));
895
905
  },
896
- topBarLeft: In,
897
- topBarRight: /* @__PURE__ */ ye(ue, { children: [
898
- Un ? /* @__PURE__ */ d(zr, {}) : null,
899
- $n
906
+ topBarLeft: Hn,
907
+ topBarRight: /* @__PURE__ */ Pe(de, { children: [
908
+ jn ? /* @__PURE__ */ d(Xr, {}) : null,
909
+ Jn
900
910
  ] })
901
911
  }
902
912
  ),
903
- Ce ? /* @__PURE__ */ d(hi, {}) : /* @__PURE__ */ d(
904
- Kr,
913
+ Ce ? /* @__PURE__ */ d(yi, {}) : /* @__PURE__ */ d(
914
+ qr,
905
915
  {
906
- className: qn,
916
+ className: Yn,
907
917
  nav: qt ? "session-list" : null,
908
918
  navParams: {
909
919
  sessions: $,
910
- activeId: je,
911
- openIds: Je,
912
- pinnedIds: kn,
913
- onTogglePin: Xn,
914
- onSwitch: pr,
915
- onOpenAsTab: rn,
916
- onCreate: ct,
917
- onDelete: Sr,
920
+ activeId: He,
921
+ openIds: Ke,
922
+ pinnedIds: er,
923
+ onTogglePin: tr,
924
+ onSwitch: yr,
925
+ onOpenAsTab: an,
926
+ onCreate: at,
927
+ onDelete: Rr,
918
928
  onLoadMore: f == null ? void 0 : f.loadMore,
919
929
  hasMore: f == null ? void 0 : f.hasMore,
920
930
  loadingMore: f == null ? void 0 : f.loadingMore,
921
- onClose: () => Bt(!1)
931
+ onClose: () => jt(!1)
922
932
  },
923
933
  center: "chat",
924
- centerParams: Ar,
925
- chatPanes: wr,
926
- activeChatPaneId: je,
927
- onActiveChatPaneChange: hr,
928
- onCloseChatPane: vr,
929
- onCreateChatPaneAfter: br,
930
- onDropChatSession: rn,
934
+ centerParams: Dr,
935
+ chatPanes: _r,
936
+ activeChatPaneId: He,
937
+ onActiveChatPaneChange: Pr,
938
+ onCloseChatPane: Er,
939
+ onCreateChatPaneAfter: Ar,
940
+ onDropChatSession: an,
931
941
  flashChatPaneId: (ie == null ? void 0 : ie.workspaceId) === e ? ie.id : null,
932
942
  surface: Z ? "artifact-surface" : null,
933
- surfaceParams: Rr,
934
- surfaceOverlay: Er,
935
- sidebar: Z && !pt && ft && gr ? "workbench-left" : null,
936
- sidebarParams: Z && !pt && ft ? {
937
- ...Ee ? { defaultTab: Ee } : {},
943
+ surfaceParams: Lr,
944
+ surfaceOverlay: Nr,
945
+ sidebar: Z && !mt && dt && vr ? "workbench-left" : null,
946
+ sidebarParams: Z && !mt && dt ? {
947
+ ...Ae ? { defaultTab: Ae } : {},
948
+ bridge: br,
938
949
  onClose: () => {
939
- ve(!1), Ge(!1);
950
+ Se(!1), Ie(!1);
940
951
  },
941
952
  onCollapse: () => {
942
- ve(!1), Ge(!1);
953
+ Se(!1), Ie(!1);
943
954
  }
944
955
  } : void 0,
945
- storageKey: M ? we : void 0,
956
+ storageKey: F ? Te : void 0,
946
957
  onOpenNav: Tt ? () => {
947
- Bt(!0), nt == null || nt();
958
+ jt(!0), et == null || et();
948
959
  } : void 0,
949
960
  onOpenSurface: () => {
950
- te.current = !0, B(!0), rt == null || rt();
961
+ te.current = !0, q(!0), tt == null || tt();
951
962
  },
952
- surfaceButtonBottomOffset: Bn,
953
- onOpenSidebar: ft ? () => {
954
- te.current = !0, B(!0), ve(!0), Ge(!0);
963
+ surfaceButtonBottomOffset: kn,
964
+ onOpenSidebar: dt ? () => {
965
+ te.current = !0, q(!0), Se(!0), Ie(!0);
955
966
  } : void 0
956
967
  }
957
968
  )
958
969
  ] }),
959
- b
970
+ S
960
971
  ]
961
972
  }
962
973
  ) });
963
974
  }
964
- const Pi = 500;
965
- function Ei(e) {
975
+ const Ti = 500;
976
+ function wi(e) {
966
977
  return new Promise((n, r) => {
967
978
  let i;
968
979
  const s = () => {
@@ -976,80 +987,80 @@ function Ei(e) {
976
987
  }
977
988
  i = globalThis.setTimeout(() => {
978
989
  s(), n();
979
- }, Pi), e.addEventListener("abort", o, { once: !0 });
990
+ }, Ti), e.addEventListener("abort", o, { once: !0 });
980
991
  });
981
992
  }
982
- function ji({
993
+ function Vi({
983
994
  workspaceId: e,
984
995
  requestHeaders: n,
985
996
  apiBaseUrl: r,
986
- preloadPaths: i = wn,
997
+ preloadPaths: i = Dn,
987
998
  provisionWorkspace: s = !0,
988
999
  loadingFallback: o,
989
1000
  errorFallback: c,
990
1001
  children: u
991
1002
  }) {
992
- const [b, y] = O({
1003
+ const [S, y] = x({
993
1004
  status: "loading",
994
1005
  label: "Waking workspace runtime"
995
1006
  });
996
- return E(() => {
997
- const S = new AbortController(), j = ke(e, n);
998
- async function W(R) {
999
- const h = await fetch(Tn(r, R), {
1007
+ return A(() => {
1008
+ const b = new AbortController(), j = Ve(e, n);
1009
+ async function W(T) {
1010
+ const h = await fetch(Ln(r, T), {
1000
1011
  headers: j,
1001
- signal: S.signal
1002
- }), T = await Xe(h);
1012
+ signal: b.signal
1013
+ }), w = await ke(h);
1003
1014
  if (!h.ok) {
1004
- if (St(T)) return "preparing";
1005
- throw new Error(yt(T) ?? `${R} failed with ${h.status}`);
1015
+ if (St(w)) return "preparing";
1016
+ throw new Error(bt(w) ?? `${T} failed with ${h.status}`);
1006
1017
  }
1007
- if (Nn(R)) {
1008
- const N = Ye(T);
1018
+ if (On(T)) {
1019
+ const N = ze(w);
1009
1020
  if ((N == null ? void 0 : N.state) === "degraded") throw new Error(N.message ?? "Workspace failed to prepare");
1010
1021
  }
1011
- return Gr(R) !== null && T && typeof T == "object" && Dn(r, j["x-boring-workspace-id"] ?? e, R, T), "ready";
1022
+ return Kr(T) !== null && w && typeof w == "object" && xn(r, j["x-boring-workspace-id"] ?? e, T, w), "ready";
1012
1023
  }
1013
1024
  async function V() {
1014
1025
  y({ status: "loading", label: "Waking workspace runtime" });
1015
1026
  try {
1016
- const R = Rn(i, s);
1017
- let h = await Promise.all(R.map(async (p) => ({ path: p, status: await W(p) }))), T = h.filter((p) => p.status === "preparing").map((p) => p.path);
1018
- for (; T.length > 0; ) {
1019
- if (y({ status: "loading", label: "Workspace is still preparing" }), await Ei(S.signal), S.signal.aborted) return;
1020
- h = await Promise.all(T.map(async (p) => ({ path: p, status: await W(p) }))), T = h.filter((p) => p.status === "preparing").map((p) => p.path);
1027
+ const T = _n(i, s);
1028
+ let h = await Promise.all(T.map(async (p) => ({ path: p, status: await W(p) }))), w = h.filter((p) => p.status === "preparing").map((p) => p.path);
1029
+ for (; w.length > 0; ) {
1030
+ if (y({ status: "loading", label: "Workspace is still preparing" }), await wi(b.signal), b.signal.aborted) return;
1031
+ h = await Promise.all(w.map(async (p) => ({ path: p, status: await W(p) }))), w = h.filter((p) => p.status === "preparing").map((p) => p.path);
1021
1032
  }
1022
- S.signal.aborted || y({ status: "ready" });
1023
- } catch (R) {
1024
- if (S.signal.aborted) return;
1033
+ b.signal.aborted || y({ status: "ready" });
1034
+ } catch (T) {
1035
+ if (b.signal.aborted) return;
1025
1036
  y({
1026
1037
  status: "error",
1027
- message: R instanceof Error ? R.message : "Unknown workspace boot error"
1038
+ message: T instanceof Error ? T.message : "Unknown workspace boot error"
1028
1039
  });
1029
1040
  }
1030
1041
  }
1031
- return V(), () => S.abort();
1032
- }, [r, i, s, n, e]), b.status === "ready" ? /* @__PURE__ */ d(ue, { children: u }) : b.status === "error" ? typeof c == "function" ? /* @__PURE__ */ d(ue, { children: c(b.message) }) : c ? /* @__PURE__ */ d(ue, { children: c }) : /* @__PURE__ */ d(
1033
- vn,
1042
+ return V(), () => b.abort();
1043
+ }, [r, i, s, n, e]), S.status === "ready" ? /* @__PURE__ */ d(de, { children: u }) : S.status === "error" ? typeof c == "function" ? /* @__PURE__ */ d(de, { children: c(S.message) }) : c ? /* @__PURE__ */ d(de, { children: c }) : /* @__PURE__ */ d(
1044
+ Pn,
1034
1045
  {
1035
1046
  title: "Workspace failed to open",
1036
- description: b.message,
1047
+ description: S.message,
1037
1048
  status: "Retry by reloading the page"
1038
1049
  }
1039
- ) : typeof o == "function" ? /* @__PURE__ */ d(ue, { children: o(b.label) }) : o ? /* @__PURE__ */ d(ue, { children: o }) : /* @__PURE__ */ d(
1040
- vn,
1050
+ ) : typeof o == "function" ? /* @__PURE__ */ d(de, { children: o(S.label) }) : o ? /* @__PURE__ */ d(de, { children: o }) : /* @__PURE__ */ d(
1051
+ Pn,
1041
1052
  {
1042
1053
  title: "Opening workspace",
1043
1054
  description: "Preparing secure runtime, files, sessions, and layout.",
1044
- status: b.label
1055
+ status: S.label
1045
1056
  }
1046
1057
  );
1047
1058
  }
1048
- const Ai = "FULL_PAGE_PANEL_MISSING_COMPONENT", wi = "FULL_PAGE_PANEL_INVALID_PARAMS_JSON", Ri = "FULL_PAGE_PANEL_PARAMS_NOT_OBJECT", Ti = "FULL_PAGE_PANEL_UNKNOWN_COMPONENT", Ni = "FULL_PAGE_PANEL_NOT_SUPPORTED", Di = "FULL_PAGE_PANEL_RENDER_FAILED";
1049
- function x() {
1059
+ const Ni = "FULL_PAGE_PANEL_MISSING_COMPONENT", Di = "FULL_PAGE_PANEL_INVALID_PARAMS_JSON", _i = "FULL_PAGE_PANEL_PARAMS_NOT_OBJECT", Li = "FULL_PAGE_PANEL_UNKNOWN_COMPONENT", Oi = "FULL_PAGE_PANEL_NOT_SUPPORTED", xi = "FULL_PAGE_PANEL_RENDER_FAILED";
1060
+ function M() {
1050
1061
  }
1051
- const _i = { dispose: x }, P = () => _i;
1052
- function Li(e) {
1062
+ const Mi = { dispose: M }, P = () => Mi;
1063
+ function Fi(e) {
1053
1064
  return {
1054
1065
  id: `full-page:${e}`,
1055
1066
  title: e,
@@ -1059,19 +1070,19 @@ function Li(e) {
1059
1070
  width: 0,
1060
1071
  height: 0,
1061
1072
  location: { type: "grid", referenceGroup: void 0 },
1062
- setActive: x,
1073
+ setActive: M,
1063
1074
  setTitle: (n) => {
1064
1075
  document.title = n;
1065
1076
  },
1066
- setSize: x,
1077
+ setSize: M,
1067
1078
  close: () => {
1068
1079
  window.close();
1069
1080
  },
1070
- moveTo: x,
1071
- maximize: x,
1072
- exitMaximized: x,
1081
+ moveTo: M,
1082
+ maximize: M,
1083
+ exitMaximized: M,
1073
1084
  isMaximized: () => !1,
1074
- minimize: x,
1085
+ minimize: M,
1075
1086
  onDidActiveChange: P,
1076
1087
  onDidVisibilityChange: P,
1077
1088
  onDidDimensionsChange: P,
@@ -1083,7 +1094,7 @@ function Li(e) {
1083
1094
  onWillFocus: P
1084
1095
  };
1085
1096
  }
1086
- function Oi() {
1097
+ function Ci() {
1087
1098
  return {
1088
1099
  width: window.innerWidth,
1089
1100
  height: window.innerHeight,
@@ -1095,20 +1106,20 @@ function Oi() {
1095
1106
  panels: [],
1096
1107
  groups: [],
1097
1108
  activeGroup: void 0,
1098
- addPanel: x,
1099
- addGroup: x,
1100
- removePanel: x,
1101
- removeGroup: x,
1109
+ addPanel: M,
1110
+ addGroup: M,
1111
+ removePanel: M,
1112
+ removeGroup: M,
1102
1113
  getPanel: () => {
1103
1114
  },
1104
1115
  getGroup: () => {
1105
1116
  },
1106
- moveGroupOrPanel: x,
1107
- fromJSON: x,
1117
+ moveGroupOrPanel: M,
1118
+ fromJSON: M,
1108
1119
  toJSON: () => ({}),
1109
- clear: x,
1110
- focus: x,
1111
- layout: x,
1120
+ clear: M,
1121
+ focus: M,
1122
+ layout: M,
1112
1123
  onDidLayoutChange: P,
1113
1124
  onDidLayoutFromJSON: P,
1114
1125
  onDidAddPanel: P,
@@ -1125,61 +1136,61 @@ function Oi() {
1125
1136
  onDidActivePanelChange_: P
1126
1137
  };
1127
1138
  }
1128
- function bt({ code: e, title: n, description: r }) {
1139
+ function vt({ code: e, title: n, description: r }) {
1129
1140
  return /* @__PURE__ */ d(
1130
1141
  "div",
1131
1142
  {
1132
1143
  className: "flex min-h-screen items-center justify-center bg-background p-6 text-foreground",
1133
1144
  "data-testid": "full-page-error-state",
1134
1145
  "data-full-page-error-code": e,
1135
- children: /* @__PURE__ */ d(qr, { className: "w-full max-w-lg", title: n, description: r })
1146
+ children: /* @__PURE__ */ d(Yr, { className: "w-full max-w-lg", title: n, description: r })
1136
1147
  }
1137
1148
  );
1138
1149
  }
1139
- function Bi({ componentId: e, params: n = {} }) {
1140
- const r = _n(), { errors: i } = Ir(), s = r.get(e), o = r.getComponents()[e];
1141
- Dr(() => {
1150
+ function ki({ componentId: e, params: n = {} }) {
1151
+ const r = Mn(), { errors: i } = Hr(), s = r.get(e), o = r.getComponents()[e];
1152
+ Mr(() => {
1142
1153
  document.title = (s == null ? void 0 : s.title) ?? e;
1143
1154
  }, [e, s == null ? void 0 : s.title]);
1144
- const c = F(() => ({
1155
+ const c = O(() => ({
1145
1156
  params: n,
1146
- api: Li(e),
1147
- containerApi: Oi(),
1157
+ api: Fi(e),
1158
+ containerApi: Ci(),
1148
1159
  className: "h-full"
1149
- }), [e, n]), u = F(() => {
1160
+ }), [e, n]), u = O(() => {
1150
1161
  if (!s) return null;
1151
- const b = s.pluginId ?? s.id;
1162
+ const S = s.pluginId ?? s.id;
1152
1163
  for (let y = i.length - 1; y >= 0; y -= 1) {
1153
- const S = i[y];
1154
- if (S.contributionKind === "panel" && S.contributionId === e && S.pluginId === b)
1155
- return S;
1164
+ const b = i[y];
1165
+ if (b.contributionKind === "panel" && b.contributionId === e && b.pluginId === S)
1166
+ return b;
1156
1167
  }
1157
1168
  return null;
1158
1169
  }, [e, i, s]);
1159
1170
  return s ? !s.supportsFullPage || !o ? /* @__PURE__ */ d(
1160
- bt,
1171
+ vt,
1161
1172
  {
1162
- code: Ni,
1173
+ code: Oi,
1163
1174
  title: "Panel does not support full-page mode",
1164
1175
  description: `Panel "${e}" can render in the workspace, but it has not opted into the dedicated full-page pane route.`
1165
1176
  }
1166
1177
  ) : u ? /* @__PURE__ */ d(
1167
- bt,
1178
+ vt,
1168
1179
  {
1169
- code: Di,
1180
+ code: xi,
1170
1181
  title: "Panel failed to render",
1171
1182
  description: `Panel "${e}" crashed while rendering in full-page mode: ${u.error.message}`
1172
1183
  }
1173
- ) : /* @__PURE__ */ d("div", { className: "min-h-screen bg-background text-foreground", children: /* @__PURE__ */ d($r, { mode: "full-page", children: /* @__PURE__ */ d(o, { ...c }) }) }) : /* @__PURE__ */ d(
1174
- bt,
1184
+ ) : /* @__PURE__ */ d("div", { className: "min-h-screen bg-background text-foreground", children: /* @__PURE__ */ d(Jr, { mode: "full-page", children: /* @__PURE__ */ d(o, { ...c }) }) }) : /* @__PURE__ */ d(
1185
+ vt,
1175
1186
  {
1176
- code: Ti,
1187
+ code: Li,
1177
1188
  title: "Unknown panel",
1178
1189
  description: `No full-page panel component is registered as "${e}".`
1179
1190
  }
1180
1191
  );
1181
1192
  }
1182
- function qi(e) {
1193
+ function Yi(e) {
1183
1194
  var o;
1184
1195
  const n = new URLSearchParams(e), r = ((o = n.get("component")) == null ? void 0 : o.trim()) ?? "";
1185
1196
  if (!r)
@@ -1187,7 +1198,7 @@ function qi(e) {
1187
1198
  componentId: null,
1188
1199
  params: {},
1189
1200
  error: {
1190
- code: Ai,
1201
+ code: Ni,
1191
1202
  message: "Missing full-page panel component id."
1192
1203
  }
1193
1204
  };
@@ -1202,7 +1213,7 @@ function qi(e) {
1202
1213
  componentId: null,
1203
1214
  params: {},
1204
1215
  error: {
1205
- code: wi,
1216
+ code: Di,
1206
1217
  message: "Invalid full-page panel params JSON."
1207
1218
  }
1208
1219
  };
@@ -1211,23 +1222,23 @@ function qi(e) {
1211
1222
  componentId: null,
1212
1223
  params: {},
1213
1224
  error: {
1214
- code: Ri,
1225
+ code: _i,
1215
1226
  message: "Full-page panel params must be a JSON object."
1216
1227
  }
1217
1228
  } : { componentId: r, params: s };
1218
1229
  }
1219
1230
  export {
1220
- wi as FULL_PAGE_PANEL_INVALID_PARAMS_JSON,
1221
- Ai as FULL_PAGE_PANEL_MISSING_COMPONENT,
1222
- Ni as FULL_PAGE_PANEL_NOT_SUPPORTED,
1223
- Ri as FULL_PAGE_PANEL_PARAMS_NOT_OBJECT,
1224
- Di as FULL_PAGE_PANEL_RENDER_FAILED,
1225
- Ti as FULL_PAGE_PANEL_UNKNOWN_COMPONENT,
1226
- Ji as WorkspaceAgentFront,
1227
- si as WorkspaceBackgroundBoot,
1228
- ji as WorkspaceBootGate,
1229
- Bi as WorkspaceFullPagePanel,
1230
- Xr as createLocalStorageSessions,
1231
- qi as parseFullPagePanelLocation,
1232
- Qr as useLocalStorageSessions
1231
+ Di as FULL_PAGE_PANEL_INVALID_PARAMS_JSON,
1232
+ Ni as FULL_PAGE_PANEL_MISSING_COMPONENT,
1233
+ Oi as FULL_PAGE_PANEL_NOT_SUPPORTED,
1234
+ _i as FULL_PAGE_PANEL_PARAMS_NOT_OBJECT,
1235
+ xi as FULL_PAGE_PANEL_RENDER_FAILED,
1236
+ Li as FULL_PAGE_PANEL_UNKNOWN_COMPONENT,
1237
+ zi as WorkspaceAgentFront,
1238
+ ci as WorkspaceBackgroundBoot,
1239
+ Vi as WorkspaceBootGate,
1240
+ ki as WorkspaceFullPagePanel,
1241
+ ti as createLocalStorageSessions,
1242
+ Yi as parseFullPagePanelLocation,
1243
+ ni as useLocalStorageSessions
1233
1244
  };