@hachej/boring-workspace 0.1.42 → 0.1.43

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