@qwen-code/web-shell 0.26.7 → 0.26.8

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.
Files changed (36) hide show
  1. package/README.md +2 -1
  2. package/dist/{PierreFilePreview-CUfIRw63.js → PierreFilePreview-BFgHDFfb.js} +1 -1
  3. package/dist/{SpreadsheetPreview-CFnRo-Yk.js → SpreadsheetPreview-CeMwcgfx.js} +2 -2
  4. package/dist/{WorkspaceFileBrowser-C0YJRw5U.js → WorkspaceFileBrowser-C5R9bwVy.js} +2 -2
  5. package/dist/agents-route-BGwI44Wi.js +1727 -0
  6. package/dist/daemon-react-sdk.js +1 -1
  7. package/dist/{index-Bgo2d7hn.js → index-BurR4Gb3.js} +67400 -65760
  8. package/dist/index.js +42 -40
  9. package/dist/sw.js +1 -1
  10. package/dist/transcript.js +5992 -5736
  11. package/dist/types/App.d.ts +4 -1
  12. package/dist/types/components/ProjectHooksApprovalCard.d.ts +13 -0
  13. package/dist/types/components/WorkspaceSessionProvider.d.ts +1 -0
  14. package/dist/types/components/channels/channel-editor-state.d.ts +9 -1
  15. package/dist/types/components/channels/channel-platform.d.ts +26 -0
  16. package/dist/types/components/messages/AuthMessage.d.ts +3 -1
  17. package/dist/types/components/messages/QwenSubscriptionEntry.d.ts +10 -0
  18. package/dist/types/components/messages/QwenSubscriptionPanel.d.ts +29 -0
  19. package/dist/types/components/messages/QwenSubscriptionSidebarStatus.d.ts +2 -0
  20. package/dist/types/components/messages/QwenSubscriptionStatus.d.ts +36 -0
  21. package/dist/types/components/messages/ToolApproval.d.ts +10 -1
  22. package/dist/types/components/messages/use-subscription.d.ts +21 -0
  23. package/dist/types/components/sidebar/workspaceOverviewModel.d.ts +2 -0
  24. package/dist/types/components/ui/collapsible.d.ts +5 -0
  25. package/dist/types/components/workspace-agents/ThreadsPage.d.ts +6 -4
  26. package/dist/types/components/workspace-agents/add-runtime-dialog.d.ts +30 -2
  27. package/dist/types/components/workspace-agents/squads-section.d.ts +6 -1
  28. package/dist/types/constants/localCommands.d.ts +1 -0
  29. package/dist/types/daemon/session/types.d.ts +3 -1
  30. package/dist/types/daemon/workspace/actions.d.ts +1 -1
  31. package/dist/types/daemon/workspace/types.d.ts +6 -2
  32. package/dist/types/hooks/useSubscriptionLogout.d.ts +15 -0
  33. package/dist/types/index.d.ts +3 -0
  34. package/dist/{useDaemonMidTurnInjected-Bsza8bIn.js → useDaemonMidTurnInjected-DjE4i35e.js} +7008 -6658
  35. package/package.json +2 -1
  36. package/dist/agents-route-Ce70dXW4.js +0 -1552
@@ -0,0 +1,1727 @@
1
+ import { jsx as e, jsxs as n, Fragment as ge } from "react/jsx-runtime";
2
+ import { X as ee, Y as We, Z as ht, _ as bt, U as ft, n as pt } from "./useDaemonMidTurnInjected-DjE4i35e.js";
3
+ import { useState as v, useMemo as ce, useRef as de, useEffect as pe, useId as gt, useCallback as Ce } from "react";
4
+ import "@qwen-code/sdk/daemon";
5
+ import { CheckCircle2 as $e, LoaderCircle as Be, CopyIcon as Je, UsersIcon as Ge, MoreHorizontalIcon as Ke, PlusIcon as we, ServerIcon as xt } from "lucide-react";
6
+ import { D as Ve, f as Qe, g as Ze, h as Xe, i as Ye, j as fe, p as Ne, I as se, k as et, B as q, w as tt, l as nt, C as qe, m as at, n as ye, o as lt, q as rt, s as ot, t as it, v as me, x as st, E as Ae, y as Ie, z as Le, A as je, F as He, G as vt, H as wt, J as Nt, K as Me, L as kt, M as Ct } from "./index-BurR4Gb3.js";
7
+ const _t = /^[A-Za-z0-9_-]{1,256}$/;
8
+ function St(a) {
9
+ let l;
10
+ try {
11
+ l = new URL(a.trim());
12
+ } catch {
13
+ return;
14
+ }
15
+ const s = l.pathname.lastIndexOf("/join/"), [x, ...b] = s >= 0 ? l.pathname.slice(s + 6).split("/") : [];
16
+ if (l.protocol !== "http:" && l.protocol !== "https:" || l.username || l.password || l.search || l.hash || !x || b.some(Boolean) || !_t.test(x))
17
+ return;
18
+ const f = l.pathname.slice(0, s).replace(/\/+$/, "");
19
+ return { serverUrl: `${l.origin}${f}`, workspaceId: x };
20
+ }
21
+ function Rt(a, l, s) {
22
+ return `QWEN_AGENT_HOST_ENROLLMENT_TOKEN=${ke("<token>")} qwen agents join ${ke(a.trim())}${s ? " --allow-http" : ""}`;
23
+ }
24
+ function qt(a, l, s, x) {
25
+ if (!a.some((b) => b.id === s))
26
+ return a.find(
27
+ (b) => b.kind === "external" && b.status === "online" && (x ? b.id === x : !l.has(b.id))
28
+ );
29
+ }
30
+ function _e(a) {
31
+ return a?.remote?.workspaceCwd !== void 0 && !a.remote.mayBeOnline;
32
+ }
33
+ function Ee(a, l) {
34
+ return a.remote !== void 0 && (a.remote.workspaceCwd === void 0 || l.workspaceCwd === a.remote.workspaceCwd);
35
+ }
36
+ function ze(a) {
37
+ return new Set(
38
+ a.filter((l) => l.status === "online").map((l) => l.id)
39
+ );
40
+ }
41
+ const De = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
42
+ function yt(a) {
43
+ const { protocol: l, hostname: s } = new URL(a);
44
+ return l === "http:" && !De.has(s) && !/^127(\.\d{1,3}){3}$/.test(s);
45
+ }
46
+ function ke(a) {
47
+ return `'${a.replaceAll("'", `'"'"'`)}'`;
48
+ }
49
+ function ct(a) {
50
+ const l = new URL(a);
51
+ if (!["http:", "https:"].includes(l.protocol) || l.username || l.password || l.search || l.hash)
52
+ throw new Error("Invalid coordinator address.");
53
+ return l;
54
+ }
55
+ function At(a, l) {
56
+ const s = ct(a), b = `${`${s.origin}${s.pathname.replace(/\/+$/, "")}`}/join/${encodeURIComponent(l.workspaceId)}`, f = s.protocol === "http:" && !De.has(s.hostname), h = `QWEN_AGENT_HOST_ENROLLMENT_TOKEN=${ke(l.token)}`, _ = `serve --no-web --port 0 --join ${ke(b)}${f ? " --agent-host-allow-http" : ""}`;
57
+ return {
58
+ qwen: `${h} qwen ${_}`,
59
+ npx: `${h} npx -y @qwen-code/qwen-code@latest ${_}`,
60
+ insecure: f
61
+ };
62
+ }
63
+ function Se({ text: a }) {
64
+ const { t: l } = ee(), [s, x] = v(!1);
65
+ return /* @__PURE__ */ n("div", { className: "flex items-center gap-2 rounded-md border border-border bg-muted/40 py-1.5 pr-1.5 pl-3", children: [
66
+ /* @__PURE__ */ e("code", { className: "min-w-0 flex-1 truncate font-mono text-xs", children: a }),
67
+ /* @__PURE__ */ n(
68
+ q,
69
+ {
70
+ size: "sm",
71
+ variant: "outline",
72
+ onClick: () => {
73
+ tt(a).then(
74
+ () => x(!0),
75
+ (b) => nt(b)
76
+ );
77
+ },
78
+ children: [
79
+ /* @__PURE__ */ e(Je, { "aria-hidden": "true" }),
80
+ l(s ? "collab.runtime.copied" : "collab.runtime.copy")
81
+ ]
82
+ }
83
+ )
84
+ ] });
85
+ }
86
+ function dt(a) {
87
+ if (typeof a != "object" || a === null || a.saved !== !1)
88
+ return {};
89
+ const l = a.saveError;
90
+ return { saveError: typeof l == "string" ? l : "" };
91
+ }
92
+ function It(a, l, s) {
93
+ return async (x) => {
94
+ let b;
95
+ s?.(!0);
96
+ try {
97
+ const f = await a(async () => (b = await l(x), b)), h = b?.workspaceCwd;
98
+ return f && {
99
+ ...dt(b),
100
+ ...typeof h == "string" ? { workspaceCwd: h } : {}
101
+ };
102
+ } finally {
103
+ s?.(!1);
104
+ }
105
+ };
106
+ }
107
+ function Lt(a, l) {
108
+ return async (s) => {
109
+ l?.(!0);
110
+ try {
111
+ return dt(await a(s));
112
+ } finally {
113
+ l?.(!1);
114
+ }
115
+ };
116
+ }
117
+ function Oe({
118
+ open: a,
119
+ onOpenChange: l,
120
+ serverUrl: s,
121
+ runtimes: x,
122
+ onCreateJoinToken: b,
123
+ onConnectExisting: f,
124
+ onJoinCoordinator: h,
125
+ onCreateAgentOn: _,
126
+ replacementTarget: g
127
+ }) {
128
+ const { t: i } = ee(), [p, w] = v(
129
+ "command"
130
+ ), [R, $] = v(""), [E, m] = v(""), [y, I] = v(!1), [c, D] = v(), k = ce(() => St(R), [R]), H = h ? ["command", "existing", "join"] : ["command", "existing"], [r, oe] = v(s), [L, P] = v(), [A, B] = v(), [G, ue] = v({}), z = (d, C, J = !1) => ue((Y) => ({
131
+ ...Y,
132
+ [d]: C,
133
+ ...d === "join" ? { joinSent: J } : {}
134
+ })), [te, F] = v(
135
+ {}
136
+ ), V = de(!1), [T, M] = v(!1), [Q, t] = v(() => Date.now()), N = g?.id, W = ce(
137
+ () => A ? x.filter(
138
+ (d) => d.kind === "external" && d.status === "online" && !A.known.has(d.id)
139
+ ) : [],
140
+ [x, A]
141
+ ), j = ce(() => {
142
+ if (A)
143
+ return N ? qt(
144
+ x,
145
+ A.known,
146
+ N,
147
+ L?.replacementHostId
148
+ ) : _e(A) && !L ? W.find((d) => Ee(A, d)) : W[0];
149
+ }, [N, x, A, L, W]), K = A !== void 0 && j !== void 0 && Ee(A, j), O = j !== void 0 && !T, ne = a && A !== void 0 && !O;
150
+ pe(() => {
151
+ if (!ne) return;
152
+ const d = setInterval(() => t(Date.now()), 1e3);
153
+ return () => clearInterval(d);
154
+ }, [ne]);
155
+ const Z = ce(() => {
156
+ if (L)
157
+ try {
158
+ return At(r, L);
159
+ } catch {
160
+ return;
161
+ }
162
+ }, [r, L]), ie = async () => {
163
+ M(!0), z("command");
164
+ try {
165
+ if (!Ue(r)) throw new Error(i("collab.runtime.badAddress"));
166
+ P(await b(N)), B((d) => ({
167
+ at: Date.now(),
168
+ known: N ? new Set(x.map((C) => C.id)) : ze(x),
169
+ // A remote connected from the other form that has not shown up yet.
170
+ ..._e(d) ? { remote: d.remote } : {}
171
+ }));
172
+ } catch (d) {
173
+ z(
174
+ "command",
175
+ d instanceof Error ? d.message : String(d)
176
+ );
177
+ } finally {
178
+ M(!1);
179
+ }
180
+ }, X = async (d) => {
181
+ if (d.preventDefault(), !f || V.current) return;
182
+ const C = new FormData(d.currentTarget);
183
+ V.current = !0, M(!0), F((Y) => ({ ...Y, there: void 0 })), P(void 0);
184
+ const J = ze(x);
185
+ try {
186
+ const Y = await f({
187
+ remoteUrl: String(C.get("remoteUrl")),
188
+ remoteToken: String(C.get("remoteToken")),
189
+ remoteCwd: String(C.get("remoteCwd")),
190
+ serverUrl: r,
191
+ allowHttp: C.get("allowHttp") === "on"
192
+ });
193
+ if (Y) {
194
+ const { saveError: Te, workspaceCwd: ve } = Y, ut = ve !== void 0 && x.some(
195
+ (be) => be.kind === "external" && J.has(be.id) && be.workspaceCwd === ve
196
+ );
197
+ B({
198
+ at: Date.now(),
199
+ known: J,
200
+ remote: {
201
+ ...ve !== void 0 ? { workspaceCwd: ve } : {},
202
+ ...ut ? { mayBeOnline: !0 } : {}
203
+ }
204
+ }), Te !== void 0 && F((be) => ({ ...be, there: Te }));
205
+ }
206
+ } finally {
207
+ V.current = !1, M(!1);
208
+ }
209
+ }, re = async (d) => {
210
+ if (d.preventDefault(), !(!h || V.current)) {
211
+ if (F((C) => ({ ...C, here: void 0 })), !k) {
212
+ z("join", i("collab.runtime.joinBadLink"));
213
+ return;
214
+ }
215
+ if (!y && yt(k.serverUrl)) {
216
+ z("join", i("collab.runtime.joinNeedsHttp"));
217
+ return;
218
+ }
219
+ V.current = !0, M(!0), z("join");
220
+ try {
221
+ const C = await h({
222
+ serverUrl: k.serverUrl,
223
+ workspaceId: k.workspaceId,
224
+ enrollmentToken: E.trim(),
225
+ allowHttp: y
226
+ });
227
+ if (C && (D(k.serverUrl), m(""), C.saveError !== void 0)) {
228
+ const J = C.saveError;
229
+ F((Y) => ({ ...Y, here: J }));
230
+ }
231
+ } catch (C) {
232
+ We(C) || m("");
233
+ const J = C?.name;
234
+ z(
235
+ "join",
236
+ J === "TimeoutError" || J === "TypeError" ? (
237
+ // With what the browser said, in case it was something else.
238
+ i("collab.runtime.joinTimedOut", {
239
+ error: C.message
240
+ })
241
+ ) : C instanceof Error ? C.message : String(C),
242
+ !0
243
+ );
244
+ } finally {
245
+ V.current = !1, M(!1);
246
+ }
247
+ }
248
+ }, U = L ? Math.max(0, Math.ceil((L.expiresAt - Q) / 6e4)) : 0, ae = L && U > 0 ? L : void 0, u = c !== void 0 ? te.here : void 0, S = !c && (O ? K : p === "existing") ? te.there : void 0, le = c ? void 0 : O ? (
249
+ // Not one from checking the form: what it points at is not there.
250
+ G.join !== void 0 && G.joinSent ? "join" : void 0
251
+ ) : p !== "existing" && G[p] !== void 0 ? p : void 0, xe = le === void 0 ? void 0 : O ? i("collab.runtime.joinFailed", { error: G.join ?? "" }) : G[le], he = (d) => {
252
+ if (!d && O && !c) {
253
+ const C = _e(A) && !K, J = K && L !== void 0 && (L.expiresAt > Date.now() || W.some((Y) => Y.id !== j?.id));
254
+ A && j && (C || J) ? (B({
255
+ at: A.at,
256
+ known: /* @__PURE__ */ new Set([...A.known, j.id]),
257
+ ...C ? { remote: A.remote } : {}
258
+ }), J || P(void 0)) : (P(void 0), B(void 0));
259
+ }
260
+ !d && c && (D(void 0), $("")), !d && le !== void 0 && z(le), d || F((C) => ({
261
+ ...u === void 0 ? { here: C.here } : {},
262
+ ...S === void 0 ? { there: C.there } : {}
263
+ })), l(d);
264
+ };
265
+ return /* @__PURE__ */ e(Ve, { open: a, onOpenChange: he, children: /* @__PURE__ */ n(Qe, { className: "grid-cols-[minmax(0,1fr)] sm:max-w-xl", children: [
266
+ /* @__PURE__ */ n(Ze, { children: [
267
+ /* @__PURE__ */ e(Xe, { children: g ? i("collab.runtime.replaceTitle", {
268
+ name: g.label
269
+ }) : i("collab.runtime.addTitle") }),
270
+ /* @__PURE__ */ e(Ye, { children: g ? i("collab.runtime.replaceDescription", {
271
+ name: g.label
272
+ }) : i("collab.runtime.addDescription") })
273
+ ] }),
274
+ g ? /* @__PURE__ */ e("p", { className: "rounded-md border border-amber-500/30 bg-amber-500/10 p-3 text-sm text-muted-foreground", children: i("collab.runtime.replaceEffects") }) : null,
275
+ !j && g && L?.replacementHostId ? /* @__PURE__ */ e("p", { role: "status", className: "text-sm text-muted-foreground", children: i("collab.runtime.replaceRecovery", {
276
+ name: g.label,
277
+ id: g.id
278
+ }) }) : null,
279
+ c ? /* @__PURE__ */ n(
280
+ "div",
281
+ {
282
+ role: "status",
283
+ className: "flex items-center gap-3 rounded-md border border-[var(--status-done-fg)]/30 bg-[var(--status-done-bg)] p-3",
284
+ children: [
285
+ /* @__PURE__ */ e(
286
+ $e,
287
+ {
288
+ "aria-hidden": "true",
289
+ className: "size-5 shrink-0 text-[var(--status-done-fg)]"
290
+ }
291
+ ),
292
+ /* @__PURE__ */ e("p", { className: "min-w-0 font-medium break-all", children: i("collab.runtime.joinConnected", { server: c }) })
293
+ ]
294
+ }
295
+ ) : O && j ? /* @__PURE__ */ e("div", { className: "flex flex-col gap-3", children: /* @__PURE__ */ n("div", { className: "flex items-center gap-3 rounded-md border border-[var(--status-done-fg)]/30 bg-[var(--status-done-bg)] p-3", children: [
296
+ /* @__PURE__ */ e(
297
+ $e,
298
+ {
299
+ "aria-hidden": "true",
300
+ className: "size-5 shrink-0 text-[var(--status-done-fg)]"
301
+ }
302
+ ),
303
+ /* @__PURE__ */ n("div", { className: "min-w-0", children: [
304
+ /* @__PURE__ */ e("p", { className: "font-medium", children: g ? i("collab.runtime.replaced", {
305
+ oldName: g.label,
306
+ name: j.label
307
+ }) : i("collab.runtime.connected", {
308
+ name: j.label
309
+ }) }),
310
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: i("collab.runtime.offers", {
311
+ programs: fe(j).map(Ne).join(", ")
312
+ }) }),
313
+ g ? /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: i("collab.runtime.replaceCompleted") }) : null
314
+ ] })
315
+ ] }) }) : /* @__PURE__ */ n(ge, { children: [
316
+ g ? null : /* @__PURE__ */ e(
317
+ "div",
318
+ {
319
+ role: "tablist",
320
+ className: "flex gap-4 border-b border-border text-sm",
321
+ children: H.map((d) => /* @__PURE__ */ e(
322
+ "button",
323
+ {
324
+ type: "button",
325
+ role: "tab",
326
+ "aria-selected": p === d,
327
+ onClick: () => w(d),
328
+ className: `-mb-px border-b-2 pb-2 ${p === d ? "border-foreground font-medium" : "border-transparent text-muted-foreground"}`,
329
+ children: i(d === "command" ? "collab.runtime.methodCommand" : d === "existing" ? "collab.runtime.methodExisting" : "collab.runtime.methodJoin")
330
+ },
331
+ d
332
+ ))
333
+ }
334
+ ),
335
+ p === "join" && !g ? null : /* @__PURE__ */ n("label", { className: "flex flex-col gap-1.5 text-sm", children: [
336
+ /* @__PURE__ */ e("span", { className: "font-medium", children: i("collab.runtime.address") }),
337
+ /* @__PURE__ */ e(
338
+ se,
339
+ {
340
+ value: r,
341
+ onChange: (d) => oe(d.target.value),
342
+ disabled: L !== void 0
343
+ }
344
+ ),
345
+ /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground", children: De.has(Ue(r)) ? i("collab.runtime.loopbackHint") : i("collab.runtime.addressHint") })
346
+ ] }),
347
+ g || p === "command" ? ae && Z ? /* @__PURE__ */ n("div", { className: "flex flex-col gap-3 text-sm", children: [
348
+ /* @__PURE__ */ e("p", { className: "font-medium", children: i("collab.runtime.runThis") }),
349
+ /* @__PURE__ */ e(Se, { text: Z.qwen }),
350
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: i("collab.runtime.noQwen") }),
351
+ /* @__PURE__ */ e(Se, { text: Z.npx }),
352
+ /* @__PURE__ */ n("p", { className: "text-xs text-muted-foreground", children: [
353
+ i("collab.runtime.expires", { minutes: U }),
354
+ Z.insecure && ` ${i("collab.runtime.httpHint")}`
355
+ ] }),
356
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-3 rounded-md border border-dashed border-border p-3", children: [
357
+ /* @__PURE__ */ e(
358
+ Be,
359
+ {
360
+ "aria-hidden": "true",
361
+ className: "size-4 shrink-0 animate-spin text-muted-foreground motion-reduce:animate-none"
362
+ }
363
+ ),
364
+ /* @__PURE__ */ n("div", { children: [
365
+ /* @__PURE__ */ e("p", { className: "font-medium", children: i("collab.runtime.waiting") }),
366
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: i("collab.runtime.waitingFor", {
367
+ seconds: Math.max(
368
+ 0,
369
+ Math.floor((Q - (A?.at ?? Q)) / 1e3)
370
+ )
371
+ }) })
372
+ ] })
373
+ ] })
374
+ ] }) : null : p === "join" ? (
375
+ // Its own key, like the form below: both sit in the same
376
+ // place, and React would otherwise reuse one's inputs for the
377
+ // other, carrying a typed token into a visible field. Both are
378
+ // read-only while a request is in flight, so what it answers is
379
+ // about the fields on screen.
380
+ /* @__PURE__ */ n(
381
+ "form",
382
+ {
383
+ id: "join-coordinator",
384
+ className: "flex flex-col gap-3 text-sm",
385
+ onSubmit: (d) => void re(d),
386
+ children: [
387
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: i("collab.runtime.joinDescription") }),
388
+ /* @__PURE__ */ n("label", { className: "flex flex-col gap-1.5", children: [
389
+ i("collab.runtime.joinLink"),
390
+ /* @__PURE__ */ e(
391
+ se,
392
+ {
393
+ name: "joinLink",
394
+ required: !0,
395
+ readOnly: T,
396
+ value: R,
397
+ onChange: (d) => $(d.target.value),
398
+ placeholder: "https://coordinator:4170/join/<workspace>",
399
+ "aria-invalid": R.trim() !== "" && !k ? !0 : void 0
400
+ }
401
+ )
402
+ ] }),
403
+ /* @__PURE__ */ n("label", { className: "flex flex-col gap-1.5", children: [
404
+ i("collab.runtime.joinToken"),
405
+ /* @__PURE__ */ e(
406
+ se,
407
+ {
408
+ name: "enrollmentToken",
409
+ type: "password",
410
+ autoComplete: "off",
411
+ required: !0,
412
+ readOnly: T,
413
+ value: E,
414
+ onChange: (d) => m(d.target.value)
415
+ }
416
+ )
417
+ ] }),
418
+ /* @__PURE__ */ n("label", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
419
+ /* @__PURE__ */ e(
420
+ "input",
421
+ {
422
+ type: "checkbox",
423
+ name: "allowHttp",
424
+ disabled: T,
425
+ checked: y,
426
+ onChange: (d) => I(d.target.checked)
427
+ }
428
+ ),
429
+ i("collab.runtime.allowHttp")
430
+ ] }),
431
+ k ? /* @__PURE__ */ n("div", { className: "flex flex-col gap-1.5", children: [
432
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: i("collab.runtime.joinCli") }),
433
+ /* @__PURE__ */ e(
434
+ Se,
435
+ {
436
+ text: Rt(R, "", y)
437
+ }
438
+ )
439
+ ] }) : null
440
+ ]
441
+ },
442
+ "join-coordinator"
443
+ )
444
+ ) : /* @__PURE__ */ n(
445
+ "form",
446
+ {
447
+ id: "connect-existing-runtime",
448
+ className: "flex flex-col gap-3 text-sm",
449
+ onSubmit: (d) => void X(d),
450
+ children: [
451
+ /* @__PURE__ */ n("label", { className: "flex flex-col gap-1.5", children: [
452
+ i("collab.runtime.remoteUrl"),
453
+ /* @__PURE__ */ e(
454
+ se,
455
+ {
456
+ name: "remoteUrl",
457
+ type: "url",
458
+ required: !0,
459
+ readOnly: T,
460
+ placeholder: "http://192.168.1.20:4170"
461
+ }
462
+ )
463
+ ] }),
464
+ /* @__PURE__ */ n("label", { className: "flex flex-col gap-1.5", children: [
465
+ i("collab.runtime.remoteToken"),
466
+ /* @__PURE__ */ e(
467
+ se,
468
+ {
469
+ name: "remoteToken",
470
+ type: "password",
471
+ autoComplete: "off",
472
+ required: !0,
473
+ readOnly: T
474
+ }
475
+ )
476
+ ] }),
477
+ /* @__PURE__ */ n("label", { className: "flex flex-col gap-1.5", children: [
478
+ i("collab.runtime.remoteCwd"),
479
+ /* @__PURE__ */ e(
480
+ se,
481
+ {
482
+ name: "remoteCwd",
483
+ required: !0,
484
+ readOnly: T,
485
+ placeholder: "/home/me/project"
486
+ }
487
+ )
488
+ ] }),
489
+ /* @__PURE__ */ n("label", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
490
+ /* @__PURE__ */ e("input", { type: "checkbox", name: "allowHttp", disabled: T }),
491
+ i("collab.runtime.allowHttp")
492
+ ] })
493
+ ]
494
+ },
495
+ "connect-existing-runtime"
496
+ )
497
+ ] }),
498
+ [
499
+ ["collab.runtime.notSavedHere", u],
500
+ ["collab.runtime.notSavedThere", S]
501
+ ].map(
502
+ ([d, C]) => C === void 0 ? null : /* @__PURE__ */ e(
503
+ "p",
504
+ {
505
+ role: "status",
506
+ className: "rounded-md border border-amber-500/30 bg-amber-500/10 p-3 text-sm text-muted-foreground break-words",
507
+ children: i(d, { error: C })
508
+ },
509
+ d
510
+ )
511
+ ),
512
+ xe && /* @__PURE__ */ e("p", { role: "alert", className: "text-sm text-destructive", children: xe }),
513
+ /* @__PURE__ */ e(et, { children: c ? /* @__PURE__ */ e(q, { variant: "outline", onClick: () => he(!1), children: i("collab.runtime.done") }) : O && j ? /* @__PURE__ */ n(ge, { children: [
514
+ /* @__PURE__ */ e(q, { variant: "outline", onClick: () => he(!1), children: i("collab.runtime.done") }),
515
+ _ && /* @__PURE__ */ e(
516
+ q,
517
+ {
518
+ onClick: () => {
519
+ he(!1), _(j.id);
520
+ },
521
+ children: i("collab.runtime.createAgentOn", { name: j.label })
522
+ }
523
+ )
524
+ ] }) : g || p === "command" ? ae ? /* @__PURE__ */ e(q, { variant: "outline", onClick: () => he(!1), children: i("collab.runtime.closeKeepLink") }) : /* @__PURE__ */ e(q, { disabled: T, onClick: () => void ie(), children: i(
525
+ g && L ? "collab.runtime.refreshReplacement" : "collab.runtime.generate"
526
+ ) }) : p === "join" ? /* @__PURE__ */ e(
527
+ q,
528
+ {
529
+ type: "submit",
530
+ form: "join-coordinator",
531
+ disabled: T || !k || !E.trim(),
532
+ children: i("collab.runtime.connect")
533
+ }
534
+ ) : /* @__PURE__ */ e(
535
+ q,
536
+ {
537
+ type: "submit",
538
+ form: "connect-existing-runtime",
539
+ disabled: T || !f,
540
+ children: i("collab.runtime.connect")
541
+ }
542
+ ) })
543
+ ] }) });
544
+ }
545
+ function Ue(a) {
546
+ try {
547
+ return ct(a).hostname;
548
+ } catch {
549
+ return "";
550
+ }
551
+ }
552
+ const jt = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
553
+ function Ht(a) {
554
+ try {
555
+ return jt.has(new URL(a).hostname);
556
+ } catch {
557
+ return !1;
558
+ }
559
+ }
560
+ function Dt(a) {
561
+ const l = JSON.stringify({
562
+ jsonrpc: "2.0",
563
+ id: 1,
564
+ method: "SendMessage",
565
+ params: {
566
+ message: {
567
+ role: "ROLE_USER",
568
+ messageId: "hello-1",
569
+ parts: [{ text: "Hello! What can you help with?" }]
570
+ }
571
+ }
572
+ });
573
+ return [
574
+ `curl -s ${a.endpoint}`,
575
+ "-H 'A2A-Version: 1.0'",
576
+ `-H 'Authorization: Bearer ${a.secret}'`,
577
+ `-H 'x-qwen-workspace-id: ${a.workspaceId}'`,
578
+ `-H 'x-qwen-caller-id: ${a.callerId}'`,
579
+ `-H 'x-qwen-agent-id: ${a.agentId}'`,
580
+ "-H 'content-type: application/json'",
581
+ `-d '${l}'`
582
+ ].join(" ");
583
+ }
584
+ function Re({ label: a, text: l }) {
585
+ const { t: s } = ee(), [x, b] = v(!1);
586
+ return /* @__PURE__ */ n("div", { className: "flex flex-col gap-1.5 text-sm", children: [
587
+ /* @__PURE__ */ e("span", { className: "font-medium", children: a }),
588
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-2 rounded-md border border-border bg-muted/40 py-1.5 pr-1.5 pl-3", children: [
589
+ /* @__PURE__ */ e("code", { className: "min-w-0 flex-1 truncate font-mono text-xs", children: l }),
590
+ /* @__PURE__ */ n(
591
+ q,
592
+ {
593
+ size: "sm",
594
+ variant: "outline",
595
+ onClick: () => void tt(l).then(
596
+ () => b(!0),
597
+ (f) => nt(f)
598
+ ),
599
+ children: [
600
+ /* @__PURE__ */ e(Je, { "aria-hidden": "true" }),
601
+ s(x ? "collab.share.copied" : "collab.share.copy")
602
+ ]
603
+ }
604
+ )
605
+ ] })
606
+ ] });
607
+ }
608
+ function Tt({
609
+ agentName: a,
610
+ open: l,
611
+ onOpenChange: s,
612
+ onCreate: x,
613
+ onList: b,
614
+ onRevoke: f
615
+ }) {
616
+ const { t: h } = ee(), [_, g] = v(), [i, p] = v([]), [w, R] = v(), [$, E] = v(!1), m = de(b);
617
+ m.current = b, pe(() => {
618
+ l && (g(void 0), R(void 0), m.current().then(p, () => p([])));
619
+ }, [l]);
620
+ const y = async (I) => {
621
+ E(!0), R(void 0);
622
+ try {
623
+ await I(), p(await m.current());
624
+ } catch (c) {
625
+ R(c instanceof Error ? c.message : String(c));
626
+ } finally {
627
+ E(!1);
628
+ }
629
+ };
630
+ return /* @__PURE__ */ e(Ve, { open: l, onOpenChange: s, children: /* @__PURE__ */ n(Qe, { className: "grid-cols-[minmax(0,1fr)] sm:max-w-xl", children: [
631
+ /* @__PURE__ */ n(Ze, { children: [
632
+ /* @__PURE__ */ e(Xe, { children: h("collab.share.title", { name: a }) }),
633
+ /* @__PURE__ */ e(Ye, { children: h("collab.share.description") })
634
+ ] }),
635
+ _ && /* @__PURE__ */ n("div", { className: "flex flex-col gap-3", children: [
636
+ /* @__PURE__ */ e(
637
+ Re,
638
+ {
639
+ label: h("collab.share.endpoint"),
640
+ text: _.endpoint
641
+ }
642
+ ),
643
+ /* @__PURE__ */ e(Re, { label: h("collab.share.token"), text: _.secret }),
644
+ /* @__PURE__ */ e(Re, { label: h("collab.share.try"), text: Dt(_) }),
645
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: _.expiresAt ? h("collab.share.onceUntil", {
646
+ date: new Date(_.expiresAt).toLocaleDateString()
647
+ }) : h("collab.share.once") }),
648
+ Ht(_.endpoint) && /* @__PURE__ */ e("p", { role: "alert", className: "text-xs text-destructive", children: h("collab.share.loopback") })
649
+ ] }),
650
+ i.length > 0 && /* @__PURE__ */ n("div", { className: "flex flex-col gap-1 text-sm", children: [
651
+ /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground", children: h("collab.share.active", { count: i.length }) }),
652
+ i.map((I) => /* @__PURE__ */ n(
653
+ "div",
654
+ {
655
+ className: "flex items-center gap-2 rounded-md px-2 py-1 hover:bg-muted",
656
+ children: [
657
+ /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate", children: [
658
+ I.callerId,
659
+ /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-muted-foreground", children: I.expiresAt ? h("collab.share.until", {
660
+ date: new Date(I.expiresAt).toLocaleDateString()
661
+ }) : "" })
662
+ ] }),
663
+ /* @__PURE__ */ e(
664
+ q,
665
+ {
666
+ size: "sm",
667
+ variant: "ghost",
668
+ disabled: $,
669
+ onClick: () => void y(() => f(I.callerId)),
670
+ children: h("collab.share.revoke")
671
+ }
672
+ )
673
+ ]
674
+ },
675
+ I.callerId
676
+ ))
677
+ ] }),
678
+ w && /* @__PURE__ */ e("p", { role: "alert", className: "text-sm text-destructive", children: w }),
679
+ /* @__PURE__ */ e(et, { children: _ ? /* @__PURE__ */ e(q, { onClick: () => s(!1), children: h("collab.share.done") }) : /* @__PURE__ */ e(
680
+ q,
681
+ {
682
+ disabled: $,
683
+ onClick: () => void y(async () => g(await x())),
684
+ children: h("collab.share.create")
685
+ }
686
+ ) })
687
+ ] }) });
688
+ }
689
+ const $t = "_formActions_1dh4x_4", Mt = "_field_1dh4x_11", Et = "_roster_1dh4x_33", zt = "_agentCard_1dh4x_39", Ot = "_agentRow_1dh4x_44", Ut = "_agentRowDisabled_1dh4x_51", Pt = "_agentMain_1dh4x_55", Ft = "_agentTitleLine_1dh4x_63", Wt = "_statusBadge_1dh4x_70", Bt = "_agentActions_1dh4x_84", Jt = "_agentConfig_1dh4x_93", Gt = "_configLabel_1dh4x_101", Kt = "_configNote_1dh4x_108", Vt = "_runtimeCard_1dh4x_116", Qt = "_runtimeHeader_1dh4x_127", Zt = "_runtimeTitle_1dh4x_131", Xt = "_runtimeStatus_1dh4x_137", Yt = "_runtimeFacts_1dh4x_147", en = "_fieldHint_1dh4x_182", tn = "_squadTile_1dh4x_188", nn = "_squadRoster_1dh4x_208", an = "_squadRosterRow_1dh4x_223", ln = "_squadRosterWho_1dh4x_231", rn = "_squadRosterName_1dh4x_267", on = "_squadRosterRole_1dh4x_275", sn = "_squadMemberPicker_1dh4x_282", cn = "_squadMemberLegend_1dh4x_292", dn = "_squadMemberRow_1dh4x_301", mn = "_squadMemberName_1dh4x_309", o = {
690
+ formActions: $t,
691
+ field: Mt,
692
+ roster: Et,
693
+ agentCard: zt,
694
+ agentRow: Ot,
695
+ agentRowDisabled: Ut,
696
+ agentMain: Pt,
697
+ agentTitleLine: Ft,
698
+ statusBadge: Wt,
699
+ agentActions: Bt,
700
+ agentConfig: Jt,
701
+ configLabel: Gt,
702
+ configNote: Kt,
703
+ runtimeCard: Vt,
704
+ runtimeHeader: Qt,
705
+ runtimeTitle: Zt,
706
+ runtimeStatus: Xt,
707
+ runtimeFacts: Yt,
708
+ fieldHint: en,
709
+ squadTile: tn,
710
+ squadRoster: nn,
711
+ squadRosterRow: an,
712
+ squadRosterWho: ln,
713
+ squadRosterName: rn,
714
+ squadRosterRole: on,
715
+ squadMemberPicker: sn,
716
+ squadMemberLegend: cn,
717
+ squadMemberRow: dn,
718
+ squadMemberName: mn
719
+ };
720
+ function un(a) {
721
+ return a.filter((l) => !l.retiredAt);
722
+ }
723
+ function Pe({
724
+ squad: a,
725
+ agents: l,
726
+ pending: s,
727
+ onSubmit: x,
728
+ onCancel: b
729
+ }) {
730
+ const { t: f } = ee(), h = un(l), _ = gt(), [g, i] = v(a?.name ?? ""), [p, w] = v(
731
+ a && !a.leaderIssue ? a.leaderAgentId : ""
732
+ ), [R, $] = v(
733
+ () => new Map(
734
+ (a?.members ?? []).map((c) => [
735
+ c.agentId,
736
+ c.role ?? ""
737
+ ])
738
+ )
739
+ ), E = h.filter(
740
+ (c) => c.id !== p
741
+ ), m = (c) => {
742
+ c.preventDefault();
743
+ const D = new FormData(c.currentTarget), k = (H) => {
744
+ const r = String(D.get(H) ?? "").trim();
745
+ return r === "" ? null : r;
746
+ };
747
+ x({
748
+ name: g.trim(),
749
+ description: k("description"),
750
+ instructions: k("instructions"),
751
+ leaderAgentId: p,
752
+ // A squad saved before leaders were kept out of the member list may
753
+ // still name its leader there.
754
+ members: [...R].filter(([H]) => H !== p).map(([H, r]) => ({
755
+ agentId: H,
756
+ ...r.trim() ? { role: r.trim() } : {}
757
+ }))
758
+ });
759
+ }, y = `${_}-name-hint`, I = g.trim();
760
+ return /* @__PURE__ */ n(
761
+ "form",
762
+ {
763
+ className: o.agentConfig,
764
+ onSubmit: m,
765
+ "data-testid": "squad-form",
766
+ children: [
767
+ /* @__PURE__ */ n("div", { className: o.configLabel, children: [
768
+ /* @__PURE__ */ e("label", { htmlFor: `${_}-name`, children: f("collab.squad.name") }),
769
+ /* @__PURE__ */ e(
770
+ "input",
771
+ {
772
+ id: `${_}-name`,
773
+ className: o.field,
774
+ name: "name",
775
+ required: !0,
776
+ maxLength: 48,
777
+ "aria-describedby": y,
778
+ value: g,
779
+ onChange: (c) => i(c.target.value)
780
+ }
781
+ ),
782
+ /* @__PURE__ */ e("span", { id: y, className: o.fieldHint, children: I ? f("collab.squad.calledAs", { name: I }) : f("collab.squad.nameHint") })
783
+ ] }),
784
+ /* @__PURE__ */ n("label", { className: o.configLabel, children: [
785
+ f("collab.squad.leader"),
786
+ /* @__PURE__ */ n(
787
+ "select",
788
+ {
789
+ className: o.field,
790
+ required: !0,
791
+ value: p,
792
+ onChange: (c) => {
793
+ const D = c.target.value;
794
+ if (w(D), R.has(D)) {
795
+ const k = new Map(R);
796
+ k.delete(D), $(k);
797
+ }
798
+ },
799
+ children: [
800
+ /* @__PURE__ */ e("option", { value: "", disabled: !0, children: f("collab.squad.leaderPick") }),
801
+ h.filter((c) => c.enabled).map((c) => /* @__PURE__ */ e("option", { value: c.id, children: c.name }, c.id))
802
+ ]
803
+ }
804
+ )
805
+ ] }),
806
+ /* @__PURE__ */ n("fieldset", { className: o.squadMemberPicker, children: [
807
+ /* @__PURE__ */ e("legend", { className: o.squadMemberLegend, children: f("collab.squad.members") }),
808
+ E.map((c) => {
809
+ const D = R.has(c.id);
810
+ return /* @__PURE__ */ n("div", { className: o.squadMemberRow, children: [
811
+ /* @__PURE__ */ e(
812
+ "input",
813
+ {
814
+ id: `${_}-member-${c.id}`,
815
+ type: "checkbox",
816
+ checked: D,
817
+ onChange: (k) => {
818
+ const H = new Map(R);
819
+ k.target.checked ? H.set(c.id, "") : H.delete(c.id), $(H);
820
+ }
821
+ }
822
+ ),
823
+ /* @__PURE__ */ e(He, { name: c.name, color: c.color }),
824
+ /* @__PURE__ */ e(
825
+ "label",
826
+ {
827
+ htmlFor: `${_}-member-${c.id}`,
828
+ className: o.squadMemberName,
829
+ children: c.name
830
+ }
831
+ ),
832
+ D ? /* @__PURE__ */ e(
833
+ "input",
834
+ {
835
+ className: o.field,
836
+ "aria-label": `${c.name} ${f("collab.squad.role")}`,
837
+ placeholder: f("collab.squad.role"),
838
+ maxLength: 200,
839
+ value: R.get(c.id) ?? "",
840
+ onChange: (k) => {
841
+ const H = new Map(R);
842
+ H.set(c.id, k.target.value), $(H);
843
+ }
844
+ }
845
+ ) : null
846
+ ] }, c.id);
847
+ })
848
+ ] }),
849
+ /* @__PURE__ */ n("label", { className: o.configLabel, children: [
850
+ f("collab.squad.instructions"),
851
+ /* @__PURE__ */ e(
852
+ "textarea",
853
+ {
854
+ className: o.field,
855
+ name: "instructions",
856
+ rows: 3,
857
+ defaultValue: a?.instructions ?? ""
858
+ }
859
+ )
860
+ ] }),
861
+ /* @__PURE__ */ n("label", { className: o.configLabel, children: [
862
+ f("collab.squad.description"),
863
+ /* @__PURE__ */ e(
864
+ "input",
865
+ {
866
+ className: o.field,
867
+ name: "description",
868
+ defaultValue: a?.description ?? ""
869
+ }
870
+ )
871
+ ] }),
872
+ /* @__PURE__ */ n("div", { className: o.formActions, children: [
873
+ /* @__PURE__ */ e(q, { type: "button", variant: "ghost", size: "sm", onClick: b, children: f("collab.form.cancel") }),
874
+ /* @__PURE__ */ e(
875
+ q,
876
+ {
877
+ type: "submit",
878
+ size: "sm",
879
+ disabled: s || p === "",
880
+ children: f("collab.squad.save")
881
+ }
882
+ )
883
+ ] })
884
+ ]
885
+ }
886
+ );
887
+ }
888
+ function mt() {
889
+ const { t: a } = ee();
890
+ return /* @__PURE__ */ e(Ae, { className: "border", children: /* @__PURE__ */ n(Ie, { children: [
891
+ /* @__PURE__ */ e(Le, { variant: "icon", children: /* @__PURE__ */ e(Ge, {}) }),
892
+ /* @__PURE__ */ e(je, { children: a("collab.squad.empty") })
893
+ ] }) });
894
+ }
895
+ function Fe({
896
+ name: a,
897
+ color: l,
898
+ role: s,
899
+ leader: x
900
+ }) {
901
+ const { t: b } = ee(), f = x ? b("collab.squad.leads") : s;
902
+ return /* @__PURE__ */ n(
903
+ "li",
904
+ {
905
+ className: o.squadRosterRow,
906
+ "data-squad-role": x ? "leader" : "member",
907
+ children: [
908
+ /* @__PURE__ */ n("span", { className: o.squadRosterWho, children: [
909
+ /* @__PURE__ */ e(He, { name: a, color: l }),
910
+ /* @__PURE__ */ e("span", { className: o.squadRosterName, children: a })
911
+ ] }),
912
+ f ? /* @__PURE__ */ e("span", { className: o.squadRosterRole, children: f }) : null
913
+ ]
914
+ }
915
+ );
916
+ }
917
+ function hn({
918
+ squads: a,
919
+ agents: l,
920
+ pending: s,
921
+ creating: x,
922
+ onCreatingChange: b,
923
+ onCreate: f,
924
+ onUpdate: h,
925
+ onRetire: _,
926
+ onMention: g,
927
+ connecting: i = !1
928
+ }) {
929
+ const { t: p } = ee(), [w, R] = v(), $ = a.filter((m) => !m.retiredAt), E = (m) => l.find((y) => y.id === m)?.color;
930
+ return /* @__PURE__ */ n("section", { className: o.roster, "data-testid": "squads-section", children: [
931
+ x ? /* @__PURE__ */ e(qe, { size: "sm", className: o.agentCard, children: /* @__PURE__ */ e(
932
+ Pe,
933
+ {
934
+ agents: l,
935
+ pending: s,
936
+ onCancel: () => b(!1),
937
+ onSubmit: async (m) => {
938
+ await f(m) && b(!1);
939
+ }
940
+ }
941
+ ) }) : null,
942
+ $.length === 0 && !x ? /* @__PURE__ */ e(mt, {}) : null,
943
+ $.map((m) => /* @__PURE__ */ n(
944
+ qe,
945
+ {
946
+ size: "sm",
947
+ className: m.leaderIssue ? `${o.agentCard} ${o.agentRowDisabled}` : o.agentCard,
948
+ "data-testid": "squad-card",
949
+ children: [
950
+ /* @__PURE__ */ n("div", { className: o.agentRow, children: [
951
+ /* @__PURE__ */ e("span", { className: o.squadTile, "aria-hidden": "true", children: /* @__PURE__ */ e(Ge, {}) }),
952
+ /* @__PURE__ */ n("div", { className: o.agentMain, children: [
953
+ /* @__PURE__ */ n("div", { className: o.agentTitleLine, children: [
954
+ /* @__PURE__ */ e(at, { className: "min-w-0 truncate", children: m.name }),
955
+ m.leaderIssue ? /* @__PURE__ */ e(
956
+ ye,
957
+ {
958
+ variant: "secondary",
959
+ className: o.statusBadge,
960
+ "data-status": "error",
961
+ children: m.leaderIssue === "disabled" ? p("collab.squad.leaderPaused") : p("collab.squad.needsLeader")
962
+ }
963
+ ) : null
964
+ ] }),
965
+ m.description ? /* @__PURE__ */ e(lt, { className: "truncate text-xs", children: m.description }) : null,
966
+ /* @__PURE__ */ n("ul", { className: o.squadRoster, children: [
967
+ m.leaderName ? /* @__PURE__ */ e(
968
+ Fe,
969
+ {
970
+ name: m.leaderName,
971
+ color: E(m.leaderAgentId),
972
+ leader: !0
973
+ }
974
+ ) : null,
975
+ m.members.map((y) => /* @__PURE__ */ e(
976
+ Fe,
977
+ {
978
+ name: y.name,
979
+ color: E(y.agentId),
980
+ role: y.role
981
+ },
982
+ y.agentId
983
+ ))
984
+ ] })
985
+ ] }),
986
+ /* @__PURE__ */ n("div", { className: o.agentActions, children: [
987
+ g ? /* @__PURE__ */ e(
988
+ q,
989
+ {
990
+ variant: "outline",
991
+ size: "sm",
992
+ disabled: !!m.leaderIssue || s || i,
993
+ onClick: () => g(m.name),
994
+ children: p("collab.agent.mentionIt")
995
+ }
996
+ ) : null,
997
+ /* @__PURE__ */ n(rt, { children: [
998
+ /* @__PURE__ */ e(ot, { asChild: !0, children: /* @__PURE__ */ e(
999
+ q,
1000
+ {
1001
+ variant: "ghost",
1002
+ size: "icon-sm",
1003
+ "aria-label": p("collab.agent.more", { name: m.name }),
1004
+ children: /* @__PURE__ */ e(Ke, { "aria-hidden": "true" })
1005
+ }
1006
+ ) }),
1007
+ /* @__PURE__ */ n(it, { align: "end", className: "min-w-40", children: [
1008
+ /* @__PURE__ */ e(
1009
+ me,
1010
+ {
1011
+ disabled: s,
1012
+ onSelect: () => R(m.id),
1013
+ children: p("collab.squad.edit")
1014
+ }
1015
+ ),
1016
+ /* @__PURE__ */ e(st, {}),
1017
+ /* @__PURE__ */ e(
1018
+ me,
1019
+ {
1020
+ variant: "destructive",
1021
+ disabled: s,
1022
+ onSelect: () => {
1023
+ window.confirm(
1024
+ p("collab.squad.retireConfirm", {
1025
+ name: m.name
1026
+ })
1027
+ ) && _(m.id);
1028
+ },
1029
+ children: p("collab.squad.retire")
1030
+ }
1031
+ )
1032
+ ] })
1033
+ ] })
1034
+ ] })
1035
+ ] }),
1036
+ w === m.id ? /* @__PURE__ */ e(
1037
+ Pe,
1038
+ {
1039
+ squad: m,
1040
+ agents: l,
1041
+ pending: s,
1042
+ onCancel: () => R(void 0),
1043
+ onSubmit: async (y) => {
1044
+ await h(m.id, y) && R(void 0);
1045
+ }
1046
+ }
1047
+ ) : null
1048
+ ]
1049
+ },
1050
+ m.id
1051
+ ))
1052
+ ] });
1053
+ }
1054
+ const bn = /* @__PURE__ */ new Set([
1055
+ "online",
1056
+ "idle",
1057
+ "working",
1058
+ "offline",
1059
+ "error"
1060
+ ]);
1061
+ function fn({
1062
+ agents: a,
1063
+ runtimes: l,
1064
+ view: s,
1065
+ onViewChange: x,
1066
+ onMentionAgent: b,
1067
+ onDeleteAgent: f,
1068
+ onSetAgentEnabled: h,
1069
+ onUpdateAgent: _,
1070
+ onOpenAgentBuilder: g,
1071
+ onOpenDefinitions: i,
1072
+ onCreateJoinToken: p,
1073
+ onRemoveRuntime: w,
1074
+ onConnectRemoteHost: R,
1075
+ onJoinCoordinator: $,
1076
+ hostServerUrl: E,
1077
+ shares: m,
1078
+ squads: y,
1079
+ pending: I,
1080
+ connecting: c = !1
1081
+ }) {
1082
+ const D = l ?? [], [k, H] = v(), { t: r } = ee(), [oe, L] = v(!1), [P, A] = v(), [B, G] = v(), [ue, z] = v(!1), te = (t) => bn.has(t) ? r(`collab.agentStatus.${t}`) : t, F = (t) => !t || t.kind === "local" ? r("collab.agent.thisComputer") : t.label, V = (t) => `${Ne(t.execution?.provider)} · ${F(t.runtime)}`, T = (t) => (N) => {
1083
+ if (N.preventDefault(), !_) return;
1084
+ const W = new FormData(N.currentTarget), j = (U) => {
1085
+ const ae = String(W.get(U) ?? "").trim();
1086
+ return ae === "" ? null : ae;
1087
+ }, K = String(W.get("maxConcurrentRuns") ?? "").trim(), O = W.getAll("executionHostId").map((U) => String(U)), ne = a.find((U) => U.id === t), Z = ne?.execution?.mode === "managed-host" ? ne.execution.hostIds : [], ie = O.length !== Z.length || O.some((U) => !Z.includes(U)), X = ne?.execution?.provider, re = D.find(
1088
+ (U) => U.kind === "local"
1089
+ );
1090
+ _(t, {
1091
+ description: j("description"),
1092
+ model: j("model"),
1093
+ agentType: j("agentType"),
1094
+ instructions: j("instructions"),
1095
+ maxConcurrentRuns: K === "" ? null : Number(K),
1096
+ ...ie ? {
1097
+ execution: O.length > 0 ? {
1098
+ mode: "managed-host",
1099
+ hostIds: O,
1100
+ ...X ? { provider: X } : {}
1101
+ } : {
1102
+ mode: "local",
1103
+ ...X && re && fe(re).includes(X) ? { provider: X } : {}
1104
+ }
1105
+ } : {}
1106
+ }), H(void 0);
1107
+ }, M = (t) => {
1108
+ x(t), H(void 0), z(!1);
1109
+ }, Q = p ? {
1110
+ serverUrl: E ?? "",
1111
+ runtimes: D,
1112
+ onCreateJoinToken: p,
1113
+ ...R ? { onConnectExisting: R } : {},
1114
+ ...$ ? { onJoinCoordinator: $ } : {},
1115
+ ...g && !c ? {
1116
+ onCreateAgentOn: (t) => {
1117
+ L(!1), g(t);
1118
+ }
1119
+ } : {}
1120
+ } : void 0;
1121
+ return /* @__PURE__ */ n("div", { className: "flex w-full flex-col gap-6", children: [
1122
+ /* @__PURE__ */ n("div", { className: "flex items-start justify-between gap-4", children: [
1123
+ /* @__PURE__ */ n("div", { className: "min-w-0", children: [
1124
+ /* @__PURE__ */ e("h1", { className: "text-xl font-semibold text-balance", children: r("agents.title") }),
1125
+ /* @__PURE__ */ e("p", { className: "mt-1 text-sm text-muted-foreground", children: r(`collab.tabs.${s}Hint`) }),
1126
+ c ? /* @__PURE__ */ n(
1127
+ "p",
1128
+ {
1129
+ role: "status",
1130
+ className: "mt-2 flex items-center gap-1.5 text-xs text-muted-foreground",
1131
+ children: [
1132
+ /* @__PURE__ */ e(
1133
+ Be,
1134
+ {
1135
+ "aria-hidden": "true",
1136
+ className: "size-3.5 shrink-0 animate-spin motion-reduce:animate-none"
1137
+ }
1138
+ ),
1139
+ r("collab.runtime.connectingHint")
1140
+ ]
1141
+ }
1142
+ ) : null
1143
+ ] }),
1144
+ /* @__PURE__ */ n("div", { className: "flex shrink-0 gap-2", children: [
1145
+ s === "agents" && i ? /* @__PURE__ */ e(
1146
+ q,
1147
+ {
1148
+ variant: "outline",
1149
+ disabled: c,
1150
+ onClick: i,
1151
+ children: r("collab.agent.roles")
1152
+ }
1153
+ ) : null,
1154
+ s === "agents" && g ? /* @__PURE__ */ n(q, { disabled: c, onClick: () => g(), children: [
1155
+ /* @__PURE__ */ e(we, { "data-icon": "inline-start" }),
1156
+ r("collab.agent.new")
1157
+ ] }) : null,
1158
+ s === "squads" && y ? /* @__PURE__ */ n(q, { disabled: I, onClick: () => z(!0), children: [
1159
+ /* @__PURE__ */ e(we, { "data-icon": "inline-start" }),
1160
+ r("collab.squad.new")
1161
+ ] }) : null,
1162
+ s === "runtime" && p ? /* @__PURE__ */ n(
1163
+ q,
1164
+ {
1165
+ variant: "outline",
1166
+ disabled: I,
1167
+ onClick: () => {
1168
+ A(void 0), L(!0);
1169
+ },
1170
+ children: [
1171
+ /* @__PURE__ */ e(we, { "data-icon": "inline-start" }),
1172
+ r("collab.runtime.addTitle")
1173
+ ]
1174
+ }
1175
+ ) : null
1176
+ ] })
1177
+ ] }),
1178
+ /* @__PURE__ */ e(
1179
+ vt,
1180
+ {
1181
+ type: "single",
1182
+ value: s,
1183
+ onValueChange: (t) => {
1184
+ t && M(t);
1185
+ },
1186
+ variant: "outline",
1187
+ size: "sm",
1188
+ "aria-label": r("agents.title"),
1189
+ children: ["agents", "squads", "runtime"].map((t) => /* @__PURE__ */ e(wt, { value: t, children: r(`collab.tabs.${t}`) }, t))
1190
+ }
1191
+ ),
1192
+ /* @__PURE__ */ n("div", { className: "contents", children: [
1193
+ /* @__PURE__ */ e("section", { className: o.roster, hidden: s !== "agents", children: a.length === 0 ? /* @__PURE__ */ e(Ae, { className: "border", children: /* @__PURE__ */ n(Ie, { children: [
1194
+ /* @__PURE__ */ e(Le, { variant: "icon", children: /* @__PURE__ */ e(we, {}) }),
1195
+ /* @__PURE__ */ e(je, { children: r("collab.agent.empty") })
1196
+ ] }) }) : a.map((t) => /* @__PURE__ */ n(
1197
+ qe,
1198
+ {
1199
+ size: "sm",
1200
+ className: t.enabled && !t.retiredAt ? o.agentCard : `${o.agentCard} ${o.agentRowDisabled}`,
1201
+ children: [
1202
+ /* @__PURE__ */ n("div", { className: o.agentRow, children: [
1203
+ /* @__PURE__ */ e(
1204
+ He,
1205
+ {
1206
+ name: t.name,
1207
+ color: t.color,
1208
+ size: "md"
1209
+ }
1210
+ ),
1211
+ /* @__PURE__ */ n("div", { className: o.agentMain, children: [
1212
+ /* @__PURE__ */ n("div", { className: o.agentTitleLine, children: [
1213
+ /* @__PURE__ */ e(at, { className: "min-w-0 truncate", children: t.name }),
1214
+ /* @__PURE__ */ e(
1215
+ ye,
1216
+ {
1217
+ variant: "secondary",
1218
+ className: o.statusBadge,
1219
+ "data-status": t.retiredAt || !t.enabled ? "off" : t.status,
1220
+ children: t.retiredAt ? r("collab.agentStatus.retired") : t.enabled ? te(t.status) : r("collab.agentStatus.paused")
1221
+ }
1222
+ ),
1223
+ t.waiting ? /* @__PURE__ */ e(ye, { variant: "outline", className: "text-[10px]", children: r("collab.agent.waiting", { count: t.waiting }) }) : null
1224
+ ] }),
1225
+ /* @__PURE__ */ e(lt, { className: "truncate text-xs", children: t.description || "—" }),
1226
+ /* @__PURE__ */ e("span", { className: "truncate text-xs text-muted-foreground", children: V(t) })
1227
+ ] }),
1228
+ t.retiredAt ? null : /* @__PURE__ */ n("div", { className: o.agentActions, children: [
1229
+ b ? /* @__PURE__ */ e(
1230
+ q,
1231
+ {
1232
+ variant: "outline",
1233
+ size: "sm",
1234
+ disabled: !t.enabled || I || c,
1235
+ onClick: () => b(t.name),
1236
+ children: r("collab.agent.mentionIt")
1237
+ }
1238
+ ) : null,
1239
+ /* @__PURE__ */ n(rt, { children: [
1240
+ /* @__PURE__ */ e(ot, { asChild: !0, children: /* @__PURE__ */ e(
1241
+ q,
1242
+ {
1243
+ variant: "ghost",
1244
+ size: "icon-sm",
1245
+ "aria-label": r("collab.agent.more", {
1246
+ name: t.name
1247
+ }),
1248
+ children: /* @__PURE__ */ e(Ke, { "aria-hidden": "true" })
1249
+ }
1250
+ ) }),
1251
+ /* @__PURE__ */ n(it, { align: "end", className: "min-w-40", children: [
1252
+ _ ? /* @__PURE__ */ e(
1253
+ me,
1254
+ {
1255
+ onSelect: () => H({
1256
+ id: t.id,
1257
+ hostIds: t.execution?.mode === "managed-host" ? [...t.execution.hostIds] : []
1258
+ }),
1259
+ children: r("collab.agent.configure")
1260
+ }
1261
+ ) : null,
1262
+ m ? /* @__PURE__ */ e(
1263
+ me,
1264
+ {
1265
+ onSelect: () => G({ id: t.id, name: t.name }),
1266
+ children: r("collab.agent.share")
1267
+ }
1268
+ ) : null,
1269
+ /* @__PURE__ */ e(
1270
+ me,
1271
+ {
1272
+ disabled: I,
1273
+ onSelect: () => h(t.id, !t.enabled),
1274
+ children: t.enabled ? r("collab.agent.pause") : r("collab.agent.resume")
1275
+ }
1276
+ ),
1277
+ /* @__PURE__ */ e(st, {}),
1278
+ /* @__PURE__ */ e(
1279
+ me,
1280
+ {
1281
+ variant: "destructive",
1282
+ disabled: t.status === "working" || t.waiting > 0,
1283
+ onSelect: () => {
1284
+ window.confirm(
1285
+ r("collab.agent.retireConfirm", {
1286
+ name: t.name
1287
+ })
1288
+ ) && f(t.id);
1289
+ },
1290
+ children: r("collab.agent.retire")
1291
+ }
1292
+ )
1293
+ ] })
1294
+ ] })
1295
+ ] })
1296
+ ] }),
1297
+ k?.id === t.id && _ ? /* @__PURE__ */ n(
1298
+ "form",
1299
+ {
1300
+ className: o.agentConfig,
1301
+ onSubmit: T(t.id),
1302
+ children: [
1303
+ /* @__PURE__ */ n("label", { className: o.configLabel, children: [
1304
+ r("collab.config.description"),
1305
+ /* @__PURE__ */ e(
1306
+ "input",
1307
+ {
1308
+ className: o.field,
1309
+ name: "description",
1310
+ defaultValue: t.description ?? "",
1311
+ placeholder: r("collab.config.descriptionHint")
1312
+ }
1313
+ )
1314
+ ] }),
1315
+ /* @__PURE__ */ n("label", { className: o.configLabel, children: [
1316
+ r("collab.config.instructions"),
1317
+ /* @__PURE__ */ e(
1318
+ "textarea",
1319
+ {
1320
+ className: o.field,
1321
+ name: "instructions",
1322
+ rows: 4,
1323
+ defaultValue: t.instructions ?? "",
1324
+ placeholder: r("collab.config.instructionsHint")
1325
+ }
1326
+ )
1327
+ ] }),
1328
+ /* @__PURE__ */ n("label", { className: o.configLabel, children: [
1329
+ r("collab.config.agentType"),
1330
+ /* @__PURE__ */ e(
1331
+ "input",
1332
+ {
1333
+ className: o.field,
1334
+ name: "agentType",
1335
+ disabled: k.hostIds.length > 0,
1336
+ defaultValue: t.agentType ?? "",
1337
+ placeholder: r("collab.config.workspaceDefault")
1338
+ }
1339
+ )
1340
+ ] }),
1341
+ /* @__PURE__ */ n("label", { className: o.configLabel, children: [
1342
+ r("collab.config.model"),
1343
+ /* @__PURE__ */ e(
1344
+ "input",
1345
+ {
1346
+ className: o.field,
1347
+ name: "model",
1348
+ disabled: k.hostIds.length > 0,
1349
+ defaultValue: t.model ?? "",
1350
+ placeholder: r("collab.config.workspaceDefault")
1351
+ }
1352
+ )
1353
+ ] }),
1354
+ /* @__PURE__ */ n("label", { className: o.configLabel, children: [
1355
+ r("collab.config.maxRuns"),
1356
+ /* @__PURE__ */ e(
1357
+ "input",
1358
+ {
1359
+ className: o.field,
1360
+ name: "maxConcurrentRuns",
1361
+ type: "number",
1362
+ min: 1,
1363
+ max: 8,
1364
+ defaultValue: t.maxConcurrentRuns ?? 1
1365
+ }
1366
+ )
1367
+ ] }),
1368
+ D.some(
1369
+ (N) => N.kind === "external"
1370
+ ) ? /* @__PURE__ */ n("fieldset", { className: o.configLabel, children: [
1371
+ /* @__PURE__ */ e("legend", { children: r("collab.config.runtimes") }),
1372
+ D.filter((N) => N.kind === "external").map((N) => /* @__PURE__ */ n("label", { children: [
1373
+ /* @__PURE__ */ e(
1374
+ "input",
1375
+ {
1376
+ name: "executionHostId",
1377
+ type: "checkbox",
1378
+ value: N.id,
1379
+ checked: k.hostIds.includes(N.id),
1380
+ disabled: !k.hostIds.includes(N.id) && !fe(N).includes(
1381
+ t.execution?.provider ?? "qwen"
1382
+ ),
1383
+ onChange: (W) => {
1384
+ const j = W.target.checked ? [...k.hostIds, N.id] : k.hostIds.filter(
1385
+ (K) => K !== N.id
1386
+ );
1387
+ H({ id: t.id, hostIds: j });
1388
+ }
1389
+ }
1390
+ ),
1391
+ " ",
1392
+ F(N),
1393
+ " ·",
1394
+ " ",
1395
+ fe(N).map(Ne).join(", "),
1396
+ " ",
1397
+ "· ",
1398
+ te(N.status)
1399
+ ] }, N.id)),
1400
+ /* @__PURE__ */ e("span", { className: o.configNote, children: r(
1401
+ k.hostIds.length > 0 ? "collab.agent.hostPersona" : "collab.config.runtimesHint"
1402
+ ) })
1403
+ ] }) : null,
1404
+ /* @__PURE__ */ e("p", { className: o.configNote, children: r("collab.config.note") }),
1405
+ /* @__PURE__ */ n("div", { className: o.formActions, children: [
1406
+ /* @__PURE__ */ e(
1407
+ q,
1408
+ {
1409
+ type: "button",
1410
+ variant: "ghost",
1411
+ size: "sm",
1412
+ onClick: () => H(void 0),
1413
+ children: r("collab.form.cancel")
1414
+ }
1415
+ ),
1416
+ /* @__PURE__ */ e(q, { type: "submit", size: "sm", disabled: I, children: r("collab.config.save") })
1417
+ ] })
1418
+ ]
1419
+ }
1420
+ ) : null
1421
+ ]
1422
+ },
1423
+ t.id
1424
+ )) }),
1425
+ s === "squads" ? y ? /* @__PURE__ */ e(
1426
+ hn,
1427
+ {
1428
+ ...y,
1429
+ agents: a,
1430
+ pending: I,
1431
+ connecting: c,
1432
+ creating: ue,
1433
+ onCreatingChange: z,
1434
+ ...b ? { onMention: b } : {}
1435
+ }
1436
+ ) : /* @__PURE__ */ e(mt, {}) : null,
1437
+ s === "runtime" && D.length > 0 ? D.map((t) => /* @__PURE__ */ n("section", { className: o.runtimeCard, children: [
1438
+ /* @__PURE__ */ n("div", { className: o.runtimeHeader, children: [
1439
+ /* @__PURE__ */ e("h2", { className: o.runtimeTitle, children: F(t) }),
1440
+ /* @__PURE__ */ e("p", { className: o.configNote, children: t.kind === "local" ? r("collab.runtime.localNote") : r("collab.runtime.remoteNote") })
1441
+ ] }),
1442
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
1443
+ /* @__PURE__ */ e(
1444
+ "strong",
1445
+ {
1446
+ className: o.runtimeStatus,
1447
+ "data-runtime-status": t.status,
1448
+ children: te(t.status)
1449
+ }
1450
+ ),
1451
+ t.kind === "external" && (w || p) ? /* @__PURE__ */ n(ge, { children: [
1452
+ p ? /* @__PURE__ */ e(
1453
+ q,
1454
+ {
1455
+ size: "sm",
1456
+ variant: "outline",
1457
+ disabled: I,
1458
+ onClick: () => {
1459
+ A(t), L(!0);
1460
+ },
1461
+ children: r("collab.runtime.replace")
1462
+ }
1463
+ ) : null,
1464
+ w ? /* @__PURE__ */ e(
1465
+ q,
1466
+ {
1467
+ size: "sm",
1468
+ variant: "ghost",
1469
+ disabled: I,
1470
+ onClick: () => {
1471
+ window.confirm(
1472
+ r("collab.runtime.removeConfirm", {
1473
+ name: t.label
1474
+ })
1475
+ ) && w(t.id);
1476
+ },
1477
+ children: r("collab.runtime.remove")
1478
+ }
1479
+ ) : null
1480
+ ] }) : null
1481
+ ] }),
1482
+ /* @__PURE__ */ n("dl", { className: o.runtimeFacts, children: [
1483
+ /* @__PURE__ */ n("div", { children: [
1484
+ /* @__PURE__ */ e("dt", { children: r("collab.runtime.programs") }),
1485
+ /* @__PURE__ */ e("dd", { children: fe(t).map(Ne).join(", ") })
1486
+ ] }),
1487
+ t.workspaceCwd ? /* @__PURE__ */ n("div", { children: [
1488
+ /* @__PURE__ */ e("dt", { children: r("collab.runtime.folder") }),
1489
+ /* @__PURE__ */ e("dd", { children: /* @__PURE__ */ e("code", { children: t.workspaceCwd }) })
1490
+ ] }) : null,
1491
+ /* @__PURE__ */ n("div", { children: [
1492
+ /* @__PURE__ */ e("dt", { children: r("collab.runtime.agents") }),
1493
+ /* @__PURE__ */ e("dd", { children: t.agentCount ?? 0 })
1494
+ ] }),
1495
+ /* @__PURE__ */ n("div", { children: [
1496
+ /* @__PURE__ */ e("dt", { children: r("collab.runtime.running") }),
1497
+ /* @__PURE__ */ e("dd", { children: t.runningTaskCount ?? 0 })
1498
+ ] }),
1499
+ /* @__PURE__ */ n("div", { children: [
1500
+ /* @__PURE__ */ e("dt", { children: r("collab.runtime.queued") }),
1501
+ /* @__PURE__ */ e("dd", { children: t.queuedTaskCount ?? 0 })
1502
+ ] })
1503
+ ] }),
1504
+ /* @__PURE__ */ n("details", { className: "mt-4 text-xs text-muted-foreground", children: [
1505
+ /* @__PURE__ */ e("summary", { className: "cursor-pointer", children: r("collab.runtime.technical") }),
1506
+ /* @__PURE__ */ e("p", { children: r("collab.runtime.id", { id: t.id }) }),
1507
+ /* @__PURE__ */ e("p", { children: r("collab.runtime.sessions", {
1508
+ count: t.sessionCount ?? 0
1509
+ }) }),
1510
+ t.lastSeenAt && /* @__PURE__ */ e("p", { children: r("collab.runtime.lastSeen", {
1511
+ time: new Date(
1512
+ t.lastSeenAt
1513
+ ).toLocaleTimeString()
1514
+ }) })
1515
+ ] })
1516
+ ] }, t.id)) : s === "runtime" ? /* @__PURE__ */ e(Ae, { className: "border", children: /* @__PURE__ */ n(Ie, { children: [
1517
+ /* @__PURE__ */ e(Le, { variant: "icon", children: /* @__PURE__ */ e(xt, {}) }),
1518
+ /* @__PURE__ */ e(je, { children: r("collab.runtime.empty") }),
1519
+ /* @__PURE__ */ e(Nt, { children: r("collab.runtime.emptyHint") })
1520
+ ] }) }) : null
1521
+ ] }),
1522
+ Q && /* @__PURE__ */ n(ge, { children: [
1523
+ /* @__PURE__ */ e(
1524
+ Oe,
1525
+ {
1526
+ open: oe && !P,
1527
+ onOpenChange: L,
1528
+ ...Q
1529
+ },
1530
+ "add-host"
1531
+ ),
1532
+ P ? /* @__PURE__ */ e(
1533
+ Oe,
1534
+ {
1535
+ open: oe,
1536
+ onOpenChange: (t) => {
1537
+ L(t), t || A(void 0);
1538
+ },
1539
+ replacementTarget: P,
1540
+ ...Q
1541
+ },
1542
+ P.id
1543
+ ) : null
1544
+ ] }),
1545
+ m && B && /* @__PURE__ */ e(
1546
+ Tt,
1547
+ {
1548
+ agentName: B.name,
1549
+ open: !0,
1550
+ onOpenChange: (t) => {
1551
+ t || G(void 0);
1552
+ },
1553
+ onCreate: () => m.create(B.id),
1554
+ onList: () => m.list(B.id),
1555
+ onRevoke: (t) => m.revoke(B.id, t)
1556
+ }
1557
+ )
1558
+ ] });
1559
+ }
1560
+ const pn = 2e3;
1561
+ function Cn({
1562
+ initialView: a,
1563
+ workspaceCwd: l,
1564
+ onOpenDefinitions: s,
1565
+ onMentionAgent: x
1566
+ }) {
1567
+ const b = ht() === "available", f = bt(), h = ft(), _ = pt(), g = ce(
1568
+ () => (h.capabilities?.workspaces ?? []).filter(
1569
+ (u) => Me(
1570
+ h.capabilities,
1571
+ u.cwd
1572
+ )
1573
+ ),
1574
+ [h.capabilities]
1575
+ ), i = l ?? _.workspaceCwd ?? g.find((u) => u.primary)?.cwd ?? g[0]?.cwd, p = Me(
1576
+ h.capabilities,
1577
+ i
1578
+ ) ? i : l ? void 0 : g.find((u) => u.primary)?.cwd ?? g[0]?.cwd, w = ce(
1579
+ () => p ? kt(
1580
+ h.baseUrl,
1581
+ h.token,
1582
+ p,
1583
+ h.client
1584
+ ) : void 0,
1585
+ [h.baseUrl, h.token, h.client, p]
1586
+ ), { t: R } = ee(), [$, E] = v([]), [m, y] = v([]), [I, c] = v(), [D, k] = v(
1587
+ a === void 0 || a === "new-agent" ? "agents" : a
1588
+ ), [H, r] = v(!1), [oe, L] = v(!1), [P, A] = v(a === "new-agent" ? {} : void 0), [B, G] = v(), [ue, z] = v(), te = ue ?? B, F = de(w);
1589
+ F.current = w;
1590
+ const V = de(0), T = de(0);
1591
+ pe(() => {
1592
+ a && a !== "new-agent" && k(a);
1593
+ }, [a]);
1594
+ const M = Ce(async () => {
1595
+ if (!b || !w || f && f.getSnapshot() !== "available")
1596
+ return;
1597
+ const u = ++V.current;
1598
+ try {
1599
+ const [S, le] = await Promise.all([
1600
+ w.listAgents(),
1601
+ // An older daemon has no squad routes: the Squads view shows empty.
1602
+ // A failed poll is not "no squads": keep the list (and an open form)
1603
+ // already on screen until a poll succeeds.
1604
+ w.listSquads ? w.listSquads().then(
1605
+ (xe) => ({ list: xe }),
1606
+ () => ({ failed: !0 })
1607
+ ) : Promise.resolve(void 0)
1608
+ ]);
1609
+ if (F.current !== w || u < T.current)
1610
+ return;
1611
+ T.current = u, E(S.agents), y(S.runtimes ?? (S.runtime ? [S.runtime] : [])), le ? "list" in le && c(le.list?.squads) : c(void 0), G(void 0);
1612
+ } catch (S) {
1613
+ if (We(S) || f && f.getSnapshot() !== "available" || F.current !== w || u < T.current)
1614
+ return;
1615
+ T.current = u, G(S instanceof Error ? S.message : String(S));
1616
+ }
1617
+ }, [f, b, w]), Q = de(M);
1618
+ Q.current = M, pe(() => {
1619
+ M();
1620
+ }, [M]), pe(() => {
1621
+ if (!b || !w) return;
1622
+ const u = setInterval(() => void Q.current(), pn);
1623
+ return () => clearInterval(u);
1624
+ }, [b, w]);
1625
+ const t = Ce(
1626
+ (u) => {
1627
+ const S = u !== null && typeof u == "object" ? u.dispatchError : void 0;
1628
+ typeof S == "string" && z(
1629
+ R("collab.error.dispatchAfterSave", { error: S })
1630
+ );
1631
+ },
1632
+ [R]
1633
+ ), N = Ce(
1634
+ async (u) => {
1635
+ r(!0), z(void 0);
1636
+ try {
1637
+ const S = await u();
1638
+ await M(), t(S);
1639
+ } catch (S) {
1640
+ return z(S instanceof Error ? S.message : String(S)), !1;
1641
+ } finally {
1642
+ r(!1);
1643
+ }
1644
+ return !0;
1645
+ },
1646
+ [M, t]
1647
+ );
1648
+ if (!w)
1649
+ return /* @__PURE__ */ e("p", { role: "alert", children: R("collab.noWorkspace") });
1650
+ const W = m.find(
1651
+ (u) => u.kind === "local"
1652
+ )?.programs;
1653
+ if (P)
1654
+ return /* @__PURE__ */ e(
1655
+ Ct,
1656
+ {
1657
+ initialScope: "workspace",
1658
+ workspaceCwd: p,
1659
+ executionHosts: m.filter((u) => u.kind === "external"),
1660
+ ...W ? { localPrograms: W } : {},
1661
+ ...P.hostId ? { initialHostId: P.hostId } : {},
1662
+ onCancel: () => A(void 0),
1663
+ onCreated: () => A(void 0),
1664
+ onSaveWorkspaceAgent: async (u) => {
1665
+ const S = await w.createAgent(u);
1666
+ await M(), t(S);
1667
+ }
1668
+ }
1669
+ );
1670
+ const {
1671
+ createShare: j,
1672
+ listShares: K,
1673
+ revokeShare: O,
1674
+ removeHost: ne,
1675
+ connectRemoteHost: Z,
1676
+ joinCoordinator: ie,
1677
+ createSquad: X,
1678
+ updateSquad: re,
1679
+ retireSquad: U
1680
+ } = w, ae = j && K && O ? {
1681
+ create: j,
1682
+ list: async (u) => (await K(u)).shares,
1683
+ revoke: O
1684
+ } : void 0;
1685
+ return /* @__PURE__ */ n(ge, { children: [
1686
+ te ? /* @__PURE__ */ e("p", { role: "alert", className: "mb-3 text-sm text-destructive", children: te }) : null,
1687
+ /* @__PURE__ */ e(
1688
+ fn,
1689
+ {
1690
+ agents: $,
1691
+ view: D,
1692
+ onViewChange: k,
1693
+ runtimes: m,
1694
+ onConnectRemoteHost: Z ? It(N, Z, L) : void 0,
1695
+ onJoinCoordinator: (
1696
+ // Errors stay in the dialog, beside the link that caused them.
1697
+ ie ? Lt(ie, L) : void 0
1698
+ ),
1699
+ onMentionAgent: x,
1700
+ pending: H,
1701
+ connecting: oe,
1702
+ onDeleteAgent: (u) => void N(() => w.deleteAgent(u)),
1703
+ onSetAgentEnabled: (u, S) => void N(() => w.setAgentEnabled(u, S)),
1704
+ onUpdateAgent: (u, S) => void N(() => w.updateAgent(u, S)),
1705
+ onOpenAgentBuilder: (u) => A({ hostId: u }),
1706
+ ...w.createJoinToken ? { onCreateJoinToken: w.createJoinToken } : {},
1707
+ ...ne ? {
1708
+ onRemoveRuntime: (u) => void N(() => ne(u))
1709
+ } : {},
1710
+ ...ae ? { shares: ae } : {},
1711
+ ...I && X && re && U ? {
1712
+ squads: {
1713
+ squads: I,
1714
+ onCreate: (u) => N(() => X(u)),
1715
+ onUpdate: (u, S) => N(() => re(u, S)),
1716
+ onRetire: (u) => void N(() => U(u))
1717
+ }
1718
+ } : {},
1719
+ ...s ? { onOpenDefinitions: s } : {},
1720
+ hostServerUrl: h.baseUrl
1721
+ }
1722
+ )
1723
+ ] });
1724
+ }
1725
+ export {
1726
+ Cn as AgentsRoute
1727
+ };