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