@qwen-code/web-shell 0.25.0 → 0.25.1-preview.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2407 @@
1
+ import { jsx as e, jsxs as a, Fragment as Ne } from "react/jsx-runtime";
2
+ import { useState as _, useMemo as se, useEffect as he, useRef as xe, useContext as Rt, createContext as At, useCallback as Le } from "react";
3
+ import { CheckCircle2 as It, LoaderCircle as We, CopyIcon as ht, PlusIcon as Se, MoreHorizontalIcon as pt, MessagesSquareIcon as Ht, ServerIcon as $t, ChevronRightIcon as bt, Check as Ie, UsersRound as at, ArrowLeftIcon as gt, X as Lt } from "lucide-react";
4
+ import { W as oe, T as Dt, m as zt } from "./toolNames-CDhDlFnq.js";
5
+ import "@qwen-code/sdk/daemon";
6
+ import { D as Ke, a as Ve, b as Ge, c as Qe, d as Xe, I as Re, e as ft, B as R, w as xt, f as vt, g as qt, T as Et, h as Mt, s as Ot, i as Be, E as De, j as ze, k as qe, l as Ee, C as Wt, A as ke, m as Bt, n as lt, o as Pt, p as Pe, q as Ue, r as je, t as ve, u as Nt, v as st, x as Ut, y as He, z as jt, F as Ce, M as Ft, G as Kt, H as Vt, J as Fe, K as Me, L as Gt, N as D, W as ot, O as Qt, P as Xt, Q as Jt, R as Yt, S as rt, U as Zt, V as en } from "./index-D9Bc2Hcz.js";
7
+ import { createPortal as tn } from "react-dom";
8
+ function nn(t, c, b, l) {
9
+ if (!t.some((i) => i.id === b))
10
+ return t.find(
11
+ (i) => i.kind === "external" && i.status === "online" && (l ? i.id === l : !c.has(i.id))
12
+ );
13
+ }
14
+ function it(t) {
15
+ return new Set(
16
+ t.filter((c) => c.status === "online").map((c) => c.id)
17
+ );
18
+ }
19
+ const _t = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
20
+ function ct(t) {
21
+ return `'${t.replaceAll("'", `'"'"'`)}'`;
22
+ }
23
+ function wt(t) {
24
+ const c = new URL(t);
25
+ if (!["http:", "https:"].includes(c.protocol) || c.username || c.password || c.search || c.hash)
26
+ throw new Error("Invalid coordinator address.");
27
+ return c;
28
+ }
29
+ function an(t, c) {
30
+ const b = wt(t), i = `${`${b.origin}${b.pathname.replace(/\/+$/, "")}`}/join/${encodeURIComponent(c.workspaceId)}`, d = b.protocol === "http:" && !_t.has(b.hostname), x = `QWEN_AGENT_HOST_ENROLLMENT_TOKEN=${ct(c.token)}`, o = `serve --no-web --port 0 --join ${ct(i)}${d ? " --agent-host-allow-http" : ""}`;
31
+ return {
32
+ qwen: `${x} qwen ${o}`,
33
+ npx: `${x} npx -y @qwen-code/qwen-code@latest ${o}`,
34
+ insecure: d
35
+ };
36
+ }
37
+ function dt({ text: t }) {
38
+ const { t: c } = oe(), [b, l] = _(!1);
39
+ return /* @__PURE__ */ a("div", { className: "flex items-center gap-2 rounded-md border border-border bg-muted/40 py-1.5 pr-1.5 pl-3", children: [
40
+ /* @__PURE__ */ e("code", { className: "min-w-0 flex-1 truncate font-mono text-xs", children: t }),
41
+ /* @__PURE__ */ a(
42
+ R,
43
+ {
44
+ size: "sm",
45
+ variant: "outline",
46
+ onClick: () => {
47
+ xt(t).then(
48
+ () => l(!0),
49
+ (i) => vt(i)
50
+ );
51
+ },
52
+ children: [
53
+ /* @__PURE__ */ e(ht, { "aria-hidden": "true" }),
54
+ c(b ? "collab.runtime.copied" : "collab.runtime.copy")
55
+ ]
56
+ }
57
+ )
58
+ ] });
59
+ }
60
+ function ln({
61
+ open: t,
62
+ onOpenChange: c,
63
+ serverUrl: b,
64
+ runtimes: l,
65
+ onCreateJoinToken: i,
66
+ onConnectExisting: d,
67
+ onCreateAgentOn: x,
68
+ replacementTarget: o
69
+ }) {
70
+ const { t: h } = oe(), [L, q] = _("command"), [T, O] = _(b), [$, P] = _(), [A, v] = _(), [u, f] = _(), [E, B] = _(!1), [U, W] = _(() => Date.now()), z = o?.id, y = se(() => {
71
+ if (A)
72
+ return z ? nn(
73
+ l,
74
+ A.known,
75
+ z,
76
+ $?.replacementHostId
77
+ ) : l.find(
78
+ (w) => w.kind === "external" && w.status === "online" && !A.known.has(w.id)
79
+ );
80
+ }, [z, l, A, $?.replacementHostId]), re = t && A !== void 0 && !y;
81
+ he(() => {
82
+ if (!re) return;
83
+ const w = setInterval(() => W(Date.now()), 1e3);
84
+ return () => clearInterval(w);
85
+ }, [re]);
86
+ const F = se(() => {
87
+ if ($)
88
+ try {
89
+ return an(T, $);
90
+ } catch {
91
+ return;
92
+ }
93
+ }, [T, $]), ge = async () => {
94
+ B(!0), f(void 0);
95
+ try {
96
+ if (!mt(T)) throw new Error(h("collab.runtime.badAddress"));
97
+ P(await i(z)), v({
98
+ at: Date.now(),
99
+ known: z ? new Set(l.map((w) => w.id)) : it(l)
100
+ });
101
+ } catch (w) {
102
+ f(w instanceof Error ? w.message : String(w));
103
+ } finally {
104
+ B(!1);
105
+ }
106
+ }, j = async (w) => {
107
+ if (w.preventDefault(), !d) return;
108
+ const s = new FormData(w.currentTarget);
109
+ B(!0), f(void 0);
110
+ const ne = it(l);
111
+ try {
112
+ await d({
113
+ remoteUrl: String(s.get("remoteUrl")),
114
+ remoteToken: String(s.get("remoteToken")),
115
+ remoteCwd: String(s.get("remoteCwd")),
116
+ serverUrl: T,
117
+ provider: "qwen",
118
+ allowHttp: s.get("allowHttp") === "on"
119
+ }) && v({ at: Date.now(), known: ne });
120
+ } finally {
121
+ B(!1);
122
+ }
123
+ }, M = $ ? Math.max(0, Math.ceil(($.expiresAt - U) / 6e4)) : 0, I = $ && M > 0 ? $ : void 0, K = (w) => {
124
+ !w && y && (P(void 0), v(void 0)), c(w);
125
+ };
126
+ return /* @__PURE__ */ e(Ke, { open: t, onOpenChange: K, children: /* @__PURE__ */ a(Ve, { className: "grid-cols-[minmax(0,1fr)] sm:max-w-xl", children: [
127
+ /* @__PURE__ */ a(Ge, { children: [
128
+ /* @__PURE__ */ e(Qe, { children: o ? h("collab.runtime.replaceTitle", {
129
+ name: o.label
130
+ }) : h("collab.runtime.addTitle") }),
131
+ /* @__PURE__ */ e(Xe, { children: o ? h("collab.runtime.replaceDescription", {
132
+ name: o.label
133
+ }) : h("collab.runtime.addDescription") })
134
+ ] }),
135
+ o ? /* @__PURE__ */ e("p", { className: "rounded-md border border-amber-500/30 bg-amber-500/10 p-3 text-sm text-muted-foreground", children: h("collab.runtime.replaceEffects") }) : null,
136
+ !y && o && $?.replacementHostId ? /* @__PURE__ */ e("p", { role: "status", className: "text-sm text-muted-foreground", children: h("collab.runtime.replaceRecovery", {
137
+ name: o.label,
138
+ id: o.id
139
+ }) }) : null,
140
+ y ? /* @__PURE__ */ e("div", { className: "flex flex-col gap-3", children: /* @__PURE__ */ a("div", { className: "flex items-center gap-3 rounded-md border border-[var(--status-done-fg)]/30 bg-[var(--status-done-bg)] p-3", children: [
141
+ /* @__PURE__ */ e(
142
+ It,
143
+ {
144
+ "aria-hidden": "true",
145
+ className: "size-5 shrink-0 text-[var(--status-done-fg)]"
146
+ }
147
+ ),
148
+ /* @__PURE__ */ a("div", { className: "min-w-0", children: [
149
+ /* @__PURE__ */ e("p", { className: "font-medium", children: o ? h("collab.runtime.replaced", {
150
+ oldName: o.label,
151
+ name: y.label
152
+ }) : h("collab.runtime.connected", {
153
+ name: y.label
154
+ }) }),
155
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: h("collab.runtime.offers", {
156
+ programs: (y.providers?.length ? y.providers : [y.provider]).join(", ")
157
+ }) }),
158
+ o ? /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: h("collab.runtime.replaceCompleted") }) : null
159
+ ] })
160
+ ] }) }) : /* @__PURE__ */ a(Ne, { children: [
161
+ o ? null : /* @__PURE__ */ e(
162
+ "div",
163
+ {
164
+ role: "tablist",
165
+ className: "flex gap-4 border-b border-border text-sm",
166
+ children: ["command", "existing"].map((w) => /* @__PURE__ */ e(
167
+ "button",
168
+ {
169
+ type: "button",
170
+ role: "tab",
171
+ "aria-selected": L === w,
172
+ onClick: () => q(w),
173
+ className: `-mb-px border-b-2 pb-2 ${L === w ? "border-foreground font-medium" : "border-transparent text-muted-foreground"}`,
174
+ children: h(w === "command" ? "collab.runtime.methodCommand" : "collab.runtime.methodExisting")
175
+ },
176
+ w
177
+ ))
178
+ }
179
+ ),
180
+ /* @__PURE__ */ a("label", { className: "flex flex-col gap-1.5 text-sm", children: [
181
+ /* @__PURE__ */ e("span", { className: "font-medium", children: h("collab.runtime.address") }),
182
+ /* @__PURE__ */ e(
183
+ Re,
184
+ {
185
+ value: T,
186
+ onChange: (w) => O(w.target.value),
187
+ disabled: $ !== void 0
188
+ }
189
+ ),
190
+ /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground", children: _t.has(mt(T)) ? h("collab.runtime.loopbackHint") : h("collab.runtime.addressHint") })
191
+ ] }),
192
+ o || L === "command" ? I && F ? /* @__PURE__ */ a("div", { className: "flex flex-col gap-3 text-sm", children: [
193
+ /* @__PURE__ */ e("p", { className: "font-medium", children: h("collab.runtime.runThis") }),
194
+ /* @__PURE__ */ e(dt, { text: F.qwen }),
195
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: h("collab.runtime.noQwen") }),
196
+ /* @__PURE__ */ e(dt, { text: F.npx }),
197
+ /* @__PURE__ */ a("p", { className: "text-xs text-muted-foreground", children: [
198
+ h("collab.runtime.expires", { minutes: M }),
199
+ F.insecure && ` ${h("collab.runtime.httpHint")}`
200
+ ] }),
201
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-3 rounded-md border border-dashed border-border p-3", children: [
202
+ /* @__PURE__ */ e(
203
+ We,
204
+ {
205
+ "aria-hidden": "true",
206
+ className: "size-4 shrink-0 animate-spin text-muted-foreground motion-reduce:animate-none"
207
+ }
208
+ ),
209
+ /* @__PURE__ */ a("div", { children: [
210
+ /* @__PURE__ */ e("p", { className: "font-medium", children: h("collab.runtime.waiting") }),
211
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: h("collab.runtime.waitingFor", {
212
+ seconds: Math.max(
213
+ 0,
214
+ Math.floor((U - (A?.at ?? U)) / 1e3)
215
+ )
216
+ }) })
217
+ ] })
218
+ ] })
219
+ ] }) : null : /* @__PURE__ */ a(
220
+ "form",
221
+ {
222
+ id: "connect-existing-runtime",
223
+ className: "flex flex-col gap-3 text-sm",
224
+ onSubmit: (w) => void j(w),
225
+ children: [
226
+ /* @__PURE__ */ a("label", { className: "flex flex-col gap-1.5", children: [
227
+ h("collab.runtime.remoteUrl"),
228
+ /* @__PURE__ */ e(
229
+ Re,
230
+ {
231
+ name: "remoteUrl",
232
+ type: "url",
233
+ required: !0,
234
+ placeholder: "http://192.168.1.20:4170"
235
+ }
236
+ )
237
+ ] }),
238
+ /* @__PURE__ */ a("label", { className: "flex flex-col gap-1.5", children: [
239
+ h("collab.runtime.remoteToken"),
240
+ /* @__PURE__ */ e(
241
+ Re,
242
+ {
243
+ name: "remoteToken",
244
+ type: "password",
245
+ autoComplete: "off",
246
+ required: !0
247
+ }
248
+ )
249
+ ] }),
250
+ /* @__PURE__ */ a("label", { className: "flex flex-col gap-1.5", children: [
251
+ h("collab.runtime.remoteCwd"),
252
+ /* @__PURE__ */ e(
253
+ Re,
254
+ {
255
+ name: "remoteCwd",
256
+ required: !0,
257
+ placeholder: "/home/me/project"
258
+ }
259
+ )
260
+ ] }),
261
+ /* @__PURE__ */ a("label", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
262
+ /* @__PURE__ */ e("input", { type: "checkbox", name: "allowHttp" }),
263
+ h("collab.runtime.allowHttp")
264
+ ] })
265
+ ]
266
+ }
267
+ )
268
+ ] }),
269
+ u && /* @__PURE__ */ e("p", { role: "alert", className: "text-sm text-destructive", children: u }),
270
+ /* @__PURE__ */ e(ft, { children: y ? /* @__PURE__ */ a(Ne, { children: [
271
+ /* @__PURE__ */ e(R, { variant: "outline", onClick: () => K(!1), children: h("collab.runtime.done") }),
272
+ x && /* @__PURE__ */ e(
273
+ R,
274
+ {
275
+ onClick: () => {
276
+ K(!1), x(y.id);
277
+ },
278
+ children: h("collab.runtime.createAgentOn", { name: y.label })
279
+ }
280
+ )
281
+ ] }) : o || L === "command" ? I ? /* @__PURE__ */ e(R, { variant: "outline", onClick: () => c(!1), children: h("collab.runtime.closeKeepLink") }) : /* @__PURE__ */ e(R, { disabled: E, onClick: () => void ge(), children: h(
282
+ o && $ ? "collab.runtime.refreshReplacement" : "collab.runtime.generate"
283
+ ) }) : /* @__PURE__ */ e(
284
+ R,
285
+ {
286
+ type: "submit",
287
+ form: "connect-existing-runtime",
288
+ disabled: E || !d,
289
+ children: h("collab.runtime.connect")
290
+ }
291
+ ) })
292
+ ] }) });
293
+ }
294
+ function mt(t) {
295
+ try {
296
+ return wt(t).hostname;
297
+ } catch {
298
+ return "";
299
+ }
300
+ }
301
+ const sn = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
302
+ function on(t) {
303
+ try {
304
+ return sn.has(new URL(t).hostname);
305
+ } catch {
306
+ return !1;
307
+ }
308
+ }
309
+ function rn(t) {
310
+ const c = JSON.stringify({
311
+ jsonrpc: "2.0",
312
+ id: 1,
313
+ method: "SendMessage",
314
+ params: {
315
+ message: {
316
+ role: "ROLE_USER",
317
+ messageId: "hello-1",
318
+ parts: [{ text: "Hello! What can you help with?" }]
319
+ }
320
+ }
321
+ });
322
+ return [
323
+ `curl -s ${t.endpoint}`,
324
+ "-H 'A2A-Version: 1.0'",
325
+ `-H 'Authorization: Bearer ${t.secret}'`,
326
+ `-H 'x-qwen-workspace-id: ${t.workspaceId}'`,
327
+ `-H 'x-qwen-caller-id: ${t.callerId}'`,
328
+ `-H 'x-qwen-agent-id: ${t.agentId}'`,
329
+ "-H 'content-type: application/json'",
330
+ `-d '${c}'`
331
+ ].join(" ");
332
+ }
333
+ function Oe({ label: t, text: c }) {
334
+ const { t: b } = oe(), [l, i] = _(!1);
335
+ return /* @__PURE__ */ a("div", { className: "flex flex-col gap-1.5 text-sm", children: [
336
+ /* @__PURE__ */ e("span", { className: "font-medium", children: t }),
337
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-2 rounded-md border border-border bg-muted/40 py-1.5 pr-1.5 pl-3", children: [
338
+ /* @__PURE__ */ e("code", { className: "min-w-0 flex-1 truncate font-mono text-xs", children: c }),
339
+ /* @__PURE__ */ a(
340
+ R,
341
+ {
342
+ size: "sm",
343
+ variant: "outline",
344
+ onClick: () => void xt(c).then(
345
+ () => i(!0),
346
+ (d) => vt(d)
347
+ ),
348
+ children: [
349
+ /* @__PURE__ */ e(ht, { "aria-hidden": "true" }),
350
+ b(l ? "collab.share.copied" : "collab.share.copy")
351
+ ]
352
+ }
353
+ )
354
+ ] })
355
+ ] });
356
+ }
357
+ function cn({
358
+ agentName: t,
359
+ open: c,
360
+ onOpenChange: b,
361
+ onCreate: l,
362
+ onList: i,
363
+ onRevoke: d
364
+ }) {
365
+ const { t: x } = oe(), [o, h] = _(), [L, q] = _([]), [T, O] = _(), [$, P] = _(!1), A = xe(i);
366
+ A.current = i, he(() => {
367
+ c && (h(void 0), O(void 0), A.current().then(q, () => q([])));
368
+ }, [c]);
369
+ const v = async (u) => {
370
+ P(!0), O(void 0);
371
+ try {
372
+ await u(), q(await A.current());
373
+ } catch (f) {
374
+ O(f instanceof Error ? f.message : String(f));
375
+ } finally {
376
+ P(!1);
377
+ }
378
+ };
379
+ return /* @__PURE__ */ e(Ke, { open: c, onOpenChange: b, children: /* @__PURE__ */ a(Ve, { className: "grid-cols-[minmax(0,1fr)] sm:max-w-xl", children: [
380
+ /* @__PURE__ */ a(Ge, { children: [
381
+ /* @__PURE__ */ e(Qe, { children: x("collab.share.title", { name: t }) }),
382
+ /* @__PURE__ */ e(Xe, { children: x("collab.share.description") })
383
+ ] }),
384
+ o && /* @__PURE__ */ a("div", { className: "flex flex-col gap-3", children: [
385
+ /* @__PURE__ */ e(
386
+ Oe,
387
+ {
388
+ label: x("collab.share.endpoint"),
389
+ text: o.endpoint
390
+ }
391
+ ),
392
+ /* @__PURE__ */ e(Oe, { label: x("collab.share.token"), text: o.secret }),
393
+ /* @__PURE__ */ e(Oe, { label: x("collab.share.try"), text: rn(o) }),
394
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: o.expiresAt ? x("collab.share.onceUntil", {
395
+ date: new Date(o.expiresAt).toLocaleDateString()
396
+ }) : x("collab.share.once") }),
397
+ on(o.endpoint) && /* @__PURE__ */ e("p", { role: "alert", className: "text-xs text-destructive", children: x("collab.share.loopback") })
398
+ ] }),
399
+ L.length > 0 && /* @__PURE__ */ a("div", { className: "flex flex-col gap-1 text-sm", children: [
400
+ /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground", children: x("collab.share.active", { count: L.length }) }),
401
+ L.map((u) => /* @__PURE__ */ a(
402
+ "div",
403
+ {
404
+ className: "flex items-center gap-2 rounded-md px-2 py-1 hover:bg-muted",
405
+ children: [
406
+ /* @__PURE__ */ a("span", { className: "min-w-0 flex-1 truncate", children: [
407
+ u.callerId,
408
+ /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-muted-foreground", children: u.expiresAt ? x("collab.share.until", {
409
+ date: new Date(u.expiresAt).toLocaleDateString()
410
+ }) : "" })
411
+ ] }),
412
+ /* @__PURE__ */ e(
413
+ R,
414
+ {
415
+ size: "sm",
416
+ variant: "ghost",
417
+ disabled: $,
418
+ onClick: () => void v(() => d(u.callerId)),
419
+ children: x("collab.share.revoke")
420
+ }
421
+ )
422
+ ]
423
+ },
424
+ u.callerId
425
+ ))
426
+ ] }),
427
+ T && /* @__PURE__ */ e("p", { role: "alert", className: "text-sm text-destructive", children: T }),
428
+ /* @__PURE__ */ e(ft, { children: o ? /* @__PURE__ */ e(R, { onClick: () => b(!1), children: x("collab.share.done") }) : /* @__PURE__ */ e(
429
+ R,
430
+ {
431
+ disabled: $,
432
+ onClick: () => void v(async () => h(await l())),
433
+ children: x("collab.share.create")
434
+ }
435
+ ) })
436
+ ] }) });
437
+ }
438
+ const dn = "_formActions_38txb_4", mn = "_field_38txb_11", un = "_roster_38txb_33", hn = "_agentCard_38txb_39", pn = "_agentRow_38txb_44", bn = "_agentRowDisabled_38txb_51", gn = "_agentMain_38txb_55", fn = "_agentTitleLine_38txb_63", xn = "_agentName_38txb_70", vn = "_statusBadge_38txb_89", Nn = "_agentActivityLink_38txb_104", _n = "_agentActions_38txb_126", wn = "_emptyRoster_38txb_133", kn = "_agentConfig_38txb_141", Cn = "_agentWorkspace_38txb_142", Tn = "_agentWorkspaceHeader_38txb_154", yn = "_configLabel_38txb_169", Sn = "_configNote_38txb_176", Rn = "_ceiling_38txb_184", An = "_ceilingTitle_38txb_193", In = "_ceilingText_38txb_200", Hn = "_ceilingTools_38txb_208", $n = "_group_38txb_217", Ln = "_groupHeading_38txb_225", Dn = "_groupHeadingToggle_38txb_241", zn = "_groupCount_38txb_249", qn = "_list_38txb_256", En = "_row_38txb_265", Mn = "_rowText_38txb_291", On = "_rowTitle_38txb_299", Wn = "_rowReason_38txb_310", Bn = "_rowChevron_38txb_326", Pn = "_runtimeCard_38txb_335", Un = "_runtimeHeader_38txb_346", jn = "_runtimeTitle_38txb_350", Fn = "_runtimeStatus_38txb_356", Kn = "_runtimeFacts_38txb_366", g = {
439
+ formActions: dn,
440
+ field: mn,
441
+ roster: un,
442
+ agentCard: hn,
443
+ agentRow: pn,
444
+ agentRowDisabled: bn,
445
+ agentMain: gn,
446
+ agentTitleLine: fn,
447
+ agentName: xn,
448
+ statusBadge: vn,
449
+ agentActivityLink: Nn,
450
+ agentActions: _n,
451
+ emptyRoster: wn,
452
+ agentConfig: kn,
453
+ agentWorkspace: Cn,
454
+ agentWorkspaceHeader: Tn,
455
+ configLabel: yn,
456
+ configNote: Sn,
457
+ ceiling: Rn,
458
+ ceilingTitle: An,
459
+ ceilingText: In,
460
+ ceilingTools: Hn,
461
+ group: $n,
462
+ groupHeading: Ln,
463
+ groupHeadingToggle: Dn,
464
+ groupCount: zn,
465
+ list: qn,
466
+ row: En,
467
+ rowText: Mn,
468
+ rowTitle: On,
469
+ rowReason: Wn,
470
+ rowChevron: Bn,
471
+ runtimeCard: Pn,
472
+ runtimeHeader: Un,
473
+ runtimeTitle: jn,
474
+ runtimeStatus: Fn,
475
+ runtimeFacts: Kn
476
+ }, Vn = /* @__PURE__ */ new Set([
477
+ "online",
478
+ "idle",
479
+ "working",
480
+ "blocked",
481
+ "offline",
482
+ "error",
483
+ "finishing",
484
+ "stopping"
485
+ ]);
486
+ function kt({
487
+ thread: t,
488
+ onOpen: c
489
+ }) {
490
+ const { t: b } = oe();
491
+ return /* @__PURE__ */ a(
492
+ "button",
493
+ {
494
+ type: "button",
495
+ className: g.row,
496
+ "data-attention": jt(t) || void 0,
497
+ onClick: () => c(t.id),
498
+ children: [
499
+ /* @__PURE__ */ a("span", { className: g.rowText, children: [
500
+ /* @__PURE__ */ e("span", { className: g.rowTitle, children: t.title }),
501
+ /* @__PURE__ */ e("span", { className: g.rowReason, children: He(t.reason, b) })
502
+ ] }),
503
+ /* @__PURE__ */ e(bt, { "aria-hidden": "true", className: g.rowChevron })
504
+ ]
505
+ }
506
+ );
507
+ }
508
+ function Gn({
509
+ group: t,
510
+ onOpenThread: c,
511
+ hidden: b
512
+ }) {
513
+ const { t: l } = oe(), [i, d] = _(t.collapsedByDefault), x = t.collapsedByDefault;
514
+ return /* @__PURE__ */ a("section", { className: g.group, hidden: b, children: [
515
+ /* @__PURE__ */ a(
516
+ "button",
517
+ {
518
+ type: "button",
519
+ className: x ? `${g.groupHeading} ${g.groupHeadingToggle}` : g.groupHeading,
520
+ onClick: x ? () => d((o) => !o) : void 0,
521
+ "aria-expanded": x ? !i : void 0,
522
+ disabled: !x,
523
+ children: [
524
+ l(`collab.group.${t.key}`),
525
+ /* @__PURE__ */ e("span", { className: g.groupCount, children: t.threads.length })
526
+ ]
527
+ }
528
+ ),
529
+ !i && /* @__PURE__ */ e("div", { className: g.list, children: t.threads.map((o) => /* @__PURE__ */ e(kt, { thread: o, onOpen: c }, o.id)) })
530
+ ] });
531
+ }
532
+ function Qn({
533
+ agents: t,
534
+ threads: c,
535
+ runtimes: b,
536
+ view: l,
537
+ onViewChange: i,
538
+ onOpenThread: d,
539
+ onDeleteAgent: x,
540
+ onSetAgentEnabled: o,
541
+ onUpdateAgent: h,
542
+ onOpenAgentBuilder: L,
543
+ onOpenDefinitions: q,
544
+ onCreateJoinToken: T,
545
+ onRemoveRuntime: O,
546
+ onConnectRemoteHost: $,
547
+ hostServerUrl: P,
548
+ shares: A,
549
+ capabilities: v,
550
+ onCreateThread: u,
551
+ workspaceCwd: f,
552
+ workspaces: E,
553
+ onWorkspaceChange: B,
554
+ createError: U,
555
+ onPreviewThread: W,
556
+ createPreview: z,
557
+ pending: y
558
+ }) {
559
+ const re = se(() => qt(c), [c]), F = b ?? [], [ge, j] = _(), [M, I] = _(), [K, w] = _(), { t: s } = oe(), [ne, Z] = _(!1), [_e, Y] = _(), [ee, ie] = _(), [de, me] = _(""), m = (n) => Vn.has(n) ? s(`collab.agentStatus.${n}`) : n, r = (n) => !n || n.kind === "local" ? s("collab.agent.thisComputer") : n.label, S = (n) => `${Ut(
560
+ n.execution?.mode === "managed-host" ? n.execution.provider : void 0
561
+ )} · ${r(n.runtime)}`, H = (n) => (C) => {
562
+ if (C.preventDefault(), !h) return;
563
+ const G = new FormData(C.currentTarget), Q = (ae) => {
564
+ const Te = String(G.get(ae) ?? "").trim();
565
+ return Te === "" ? null : Te;
566
+ }, te = String(G.get("maxConcurrentRuns") ?? "").trim(), fe = G.getAll("executionHostId").map((ae) => String(ae)), ce = t.find((ae) => ae.id === n), pe = ce?.execution?.mode === "managed-host" ? ce.execution.hostIds : [], ue = fe.length !== pe.length || fe.some((ae) => !pe.includes(ae));
567
+ h(n, {
568
+ description: Q("description"),
569
+ model: Q("model"),
570
+ agentType: Q("agentType"),
571
+ instructions: Q("instructions"),
572
+ maxConcurrentRuns: te === "" ? null : Number(te),
573
+ ...ue ? {
574
+ execution: fe.length > 0 ? {
575
+ mode: "managed-host",
576
+ hostIds: fe,
577
+ // Moving an agent keeps the program it is bound to.
578
+ ...ce?.execution?.mode === "managed-host" && ce.execution.provider ? { provider: ce.execution.provider } : {}
579
+ } : { mode: "local" }
580
+ } : {}
581
+ }), I(void 0);
582
+ }, J = async (n) => {
583
+ n.preventDefault();
584
+ const C = new FormData(n.currentTarget), G = String(C.get("assignee") ?? ""), Q = String(
585
+ C.get("acceptanceCriteria") ?? ""
586
+ ).trim(), te = String(C.get("priority") ?? "");
587
+ await u({
588
+ title: String(C.get("title") ?? "").trim(),
589
+ body: String(C.get("body") ?? "").trim(),
590
+ // Left out when blank or ordinary, so the thread records a decision
591
+ // only where one was made.
592
+ ...Q ? { acceptanceCriteria: Q } : {},
593
+ ...te && te !== "normal" ? { priority: te } : {},
594
+ ...G ? { assignee: G } : {}
595
+ }) !== !1 && (W?.(void 0), j(void 0));
596
+ }, V = (n) => {
597
+ i(n), j(void 0), I(void 0), w(void 0), W?.(void 0);
598
+ };
599
+ return /* @__PURE__ */ a("div", { className: "flex w-full flex-col gap-6", children: [
600
+ /* @__PURE__ */ a("div", { className: "flex items-start justify-between gap-4", children: [
601
+ /* @__PURE__ */ a("div", { className: "min-w-0", children: [
602
+ /* @__PURE__ */ e("h1", { className: "text-xl font-semibold text-balance", children: s("agents.title") }),
603
+ /* @__PURE__ */ e("p", { className: "mt-1 text-sm text-muted-foreground", children: s(`collab.tabs.${l}Hint`) })
604
+ ] }),
605
+ /* @__PURE__ */ a("div", { className: "flex shrink-0 gap-2", children: [
606
+ l === "agents" && q ? /* @__PURE__ */ e(R, { variant: "outline", onClick: q, children: s("collab.agent.roles") }) : null,
607
+ l === "agents" && L ? /* @__PURE__ */ a(R, { onClick: () => L(), children: [
608
+ /* @__PURE__ */ e(Se, { "data-icon": "inline-start" }),
609
+ s("collab.agent.new")
610
+ ] }) : null,
611
+ l === "runtime" && T ? /* @__PURE__ */ a(
612
+ R,
613
+ {
614
+ variant: "outline",
615
+ disabled: y,
616
+ onClick: () => {
617
+ Y(void 0), Z(!0);
618
+ },
619
+ children: [
620
+ /* @__PURE__ */ e(Se, { "data-icon": "inline-start" }),
621
+ s("collab.runtime.addTitle")
622
+ ]
623
+ }
624
+ ) : null,
625
+ l === "tasks" ? /* @__PURE__ */ a(
626
+ R,
627
+ {
628
+ onClick: () => {
629
+ j("thread"), me(""), W?.(void 0);
630
+ },
631
+ children: [
632
+ /* @__PURE__ */ e(Se, { "data-icon": "inline-start" }),
633
+ s("collab.thread.new")
634
+ ]
635
+ }
636
+ ) : null
637
+ ] })
638
+ ] }),
639
+ /* @__PURE__ */ e(
640
+ Et,
641
+ {
642
+ type: "single",
643
+ value: l,
644
+ onValueChange: (n) => {
645
+ n && V(n);
646
+ },
647
+ variant: "outline",
648
+ size: "sm",
649
+ "aria-label": s("agents.title"),
650
+ children: ["agents", "tasks", "runtime"].map((n) => /* @__PURE__ */ e(Mt, { value: n, children: s(`collab.tabs.${n}`) }, n))
651
+ }
652
+ ),
653
+ /* @__PURE__ */ a("div", { className: "contents", children: [
654
+ /* @__PURE__ */ e(
655
+ Ke,
656
+ {
657
+ open: l === "tasks" && ge === "thread",
658
+ onOpenChange: (n) => {
659
+ !n && !y && j(void 0);
660
+ },
661
+ children: /* @__PURE__ */ a(Ve, { className: "sm:max-w-2xl", children: [
662
+ /* @__PURE__ */ a(Ge, { children: [
663
+ /* @__PURE__ */ e(Qe, { children: s("collab.thread.new") }),
664
+ /* @__PURE__ */ e(Xe, { children: s("collab.thread.newHint") })
665
+ ] }),
666
+ /* @__PURE__ */ a(
667
+ "form",
668
+ {
669
+ className: "flex flex-col gap-4",
670
+ onSubmit: (n) => void J(n),
671
+ children: [
672
+ U && /* @__PURE__ */ e("p", { role: "alert", className: "text-sm text-destructive", children: U }),
673
+ /* @__PURE__ */ a("label", { className: "text-xs text-muted-foreground", children: [
674
+ s("collab.form.project"),
675
+ /* @__PURE__ */ a(
676
+ "select",
677
+ {
678
+ className: g.field,
679
+ value: f ?? "",
680
+ disabled: y,
681
+ onChange: (n) => {
682
+ me(""), B?.(n.target.value);
683
+ },
684
+ children: [
685
+ f && !E?.some(
686
+ (n) => n.cwd === f
687
+ ) && /* @__PURE__ */ e("option", { value: f, children: f.split(/[\\/]/).filter(Boolean).at(-1) }),
688
+ E?.map((n) => /* @__PURE__ */ e("option", { value: n.cwd, children: n.cwd.split(/[\\/]/).filter(Boolean).at(-1) }, n.cwd))
689
+ ]
690
+ }
691
+ )
692
+ ] }),
693
+ /* @__PURE__ */ a("p", { className: "text-xs text-muted-foreground", children: [
694
+ /* @__PURE__ */ e("span", { className: "block break-all", children: f }),
695
+ s("collab.form.projectHint")
696
+ ] }),
697
+ /* @__PURE__ */ e(
698
+ "input",
699
+ {
700
+ className: "w-full border-0 bg-transparent text-xl font-medium outline-none",
701
+ name: "title",
702
+ "aria-label": s("collab.form.titleLabel"),
703
+ placeholder: s("collab.form.title"),
704
+ required: !0
705
+ }
706
+ ),
707
+ /* @__PURE__ */ e(
708
+ "textarea",
709
+ {
710
+ className: g.field,
711
+ name: "body",
712
+ "aria-label": s("collab.form.bodyLabel"),
713
+ rows: 6,
714
+ placeholder: s("collab.form.body"),
715
+ required: !0
716
+ }
717
+ ),
718
+ /* @__PURE__ */ e(
719
+ "textarea",
720
+ {
721
+ className: g.field,
722
+ name: "acceptanceCriteria",
723
+ "aria-label": s("collab.form.criteriaLabel"),
724
+ placeholder: s("collab.form.criteria")
725
+ }
726
+ ),
727
+ /* @__PURE__ */ e(
728
+ "select",
729
+ {
730
+ className: g.field,
731
+ name: "priority",
732
+ "aria-label": s("collab.form.priority"),
733
+ defaultValue: "normal",
734
+ children: ["urgent", "high", "normal", "low"].map((n) => /* @__PURE__ */ e("option", { value: n, children: s(`collab.priority.${n}`) }, n))
735
+ }
736
+ ),
737
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: s("collab.form.priorityHint") }),
738
+ /* @__PURE__ */ a(
739
+ "select",
740
+ {
741
+ className: g.field,
742
+ name: "assignee",
743
+ "aria-label": s("collab.form.assignee"),
744
+ defaultValue: de,
745
+ onChange: (n) => {
746
+ me(n.target.value), W?.(n.target.value || void 0);
747
+ },
748
+ children: [
749
+ /* @__PURE__ */ e("option", { value: "", children: s("collab.form.noAssignee") }),
750
+ t.filter((n) => n.enabled && !n.retiredAt).map((n) => /* @__PURE__ */ a("option", { value: n.name, children: [
751
+ n.name,
752
+ " · ",
753
+ S(n)
754
+ ] }, n.id))
755
+ ]
756
+ },
757
+ f
758
+ ),
759
+ !de && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: s("collab.form.noAssigneeHint") }),
760
+ z ? /* @__PURE__ */ a(
761
+ "div",
762
+ {
763
+ role: "status",
764
+ className: "space-y-1 text-xs text-muted-foreground",
765
+ children: [
766
+ /* @__PURE__ */ e("strong", { children: de ? Ot(z, s) : s("collab.form.saveOnly") }),
767
+ z.filter((n) => !n.willWake).map((n) => {
768
+ const C = Be(
769
+ n.reason ?? "",
770
+ n.agentName,
771
+ s
772
+ );
773
+ return /* @__PURE__ */ e(
774
+ "p",
775
+ {
776
+ children: C
777
+ },
778
+ `${n.agentName}:${n.reason ?? "unknown"}`
779
+ );
780
+ })
781
+ ]
782
+ }
783
+ ) : null,
784
+ /* @__PURE__ */ a("div", { className: g.formActions, children: [
785
+ /* @__PURE__ */ e(
786
+ R,
787
+ {
788
+ type: "button",
789
+ variant: "ghost",
790
+ size: "sm",
791
+ onClick: () => {
792
+ j(void 0), W?.(void 0);
793
+ },
794
+ children: s("collab.form.cancel")
795
+ }
796
+ ),
797
+ /* @__PURE__ */ e(R, { type: "submit", size: "sm", disabled: y, children: s(y ? "collab.form.creating" : "collab.form.create") })
798
+ ] })
799
+ ]
800
+ }
801
+ )
802
+ ] })
803
+ }
804
+ ),
805
+ /* @__PURE__ */ a("section", { className: g.roster, hidden: l !== "agents", children: [
806
+ t.length === 0 ? /* @__PURE__ */ e(De, { className: "border", children: /* @__PURE__ */ a(ze, { children: [
807
+ /* @__PURE__ */ e(qe, { variant: "icon", children: /* @__PURE__ */ e(Se, {}) }),
808
+ /* @__PURE__ */ e(Ee, { children: s("collab.agent.empty") })
809
+ ] }) }) : t.map((n) => /* @__PURE__ */ a(
810
+ Wt,
811
+ {
812
+ size: "sm",
813
+ className: n.enabled && !n.retiredAt ? g.agentCard : `${g.agentCard} ${g.agentRowDisabled}`,
814
+ children: [
815
+ /* @__PURE__ */ a("div", { className: g.agentRow, children: [
816
+ /* @__PURE__ */ e(
817
+ ke,
818
+ {
819
+ name: n.name,
820
+ color: n.color,
821
+ size: "md"
822
+ }
823
+ ),
824
+ /* @__PURE__ */ a("div", { className: g.agentMain, children: [
825
+ /* @__PURE__ */ a("div", { className: g.agentTitleLine, children: [
826
+ /* @__PURE__ */ e(Bt, { className: "min-w-0 truncate", children: /* @__PURE__ */ e(
827
+ "button",
828
+ {
829
+ type: "button",
830
+ className: g.agentName,
831
+ "aria-expanded": K === n.id,
832
+ onClick: () => w(
833
+ K === n.id ? void 0 : n.id
834
+ ),
835
+ children: n.name
836
+ }
837
+ ) }),
838
+ /* @__PURE__ */ e(
839
+ lt,
840
+ {
841
+ variant: "secondary",
842
+ className: g.statusBadge,
843
+ "data-status": n.retiredAt || !n.enabled ? "off" : n.workingOn ? "working" : n.status,
844
+ children: n.retiredAt ? s("collab.agentStatus.retired") : n.enabled ? n.workingOn ? m(n.workingOn.state) : m(n.status) : s("collab.agentStatus.paused")
845
+ }
846
+ ),
847
+ n.waiting ? /* @__PURE__ */ e(lt, { variant: "outline", className: "text-[10px]", children: s("collab.agent.waiting", { count: n.waiting }) }) : null
848
+ ] }),
849
+ /* @__PURE__ */ e(Pt, { className: "truncate text-xs", children: n.description || "—" }),
850
+ /* @__PURE__ */ e("span", { className: "truncate text-xs text-muted-foreground", children: S(n) }),
851
+ n.workingOn ? /* @__PURE__ */ e(
852
+ "button",
853
+ {
854
+ type: "button",
855
+ className: g.agentActivityLink,
856
+ onClick: () => d(n.workingOn.id),
857
+ children: s("collab.agent.workingOn", {
858
+ title: n.workingOn.title
859
+ })
860
+ }
861
+ ) : null
862
+ ] }),
863
+ n.retiredAt ? null : /* @__PURE__ */ a("div", { className: g.agentActions, children: [
864
+ /* @__PURE__ */ e(
865
+ R,
866
+ {
867
+ variant: "outline",
868
+ size: "sm",
869
+ disabled: !n.enabled || y,
870
+ onClick: () => {
871
+ V("tasks"), me(n.name), j("thread"), W?.(n.name);
872
+ },
873
+ children: s("collab.agent.mentionIt")
874
+ }
875
+ ),
876
+ /* @__PURE__ */ a(Pe, { children: [
877
+ /* @__PURE__ */ e(Ue, { asChild: !0, children: /* @__PURE__ */ e(
878
+ R,
879
+ {
880
+ variant: "ghost",
881
+ size: "icon-sm",
882
+ "aria-label": s("collab.agent.more", {
883
+ name: n.name
884
+ }),
885
+ children: /* @__PURE__ */ e(pt, { "aria-hidden": "true" })
886
+ }
887
+ ) }),
888
+ /* @__PURE__ */ a(je, { align: "end", className: "min-w-40", children: [
889
+ h ? /* @__PURE__ */ e(
890
+ ve,
891
+ {
892
+ onSelect: () => I({
893
+ id: n.id,
894
+ hostIds: n.execution?.mode === "managed-host" ? [...n.execution.hostIds] : []
895
+ }),
896
+ children: s("collab.agent.configure")
897
+ }
898
+ ) : null,
899
+ A ? /* @__PURE__ */ e(
900
+ ve,
901
+ {
902
+ onSelect: () => ie({ id: n.id, name: n.name }),
903
+ children: s("collab.agent.share")
904
+ }
905
+ ) : null,
906
+ /* @__PURE__ */ e(
907
+ ve,
908
+ {
909
+ disabled: y,
910
+ onSelect: () => o(n.id, !n.enabled),
911
+ children: n.enabled ? s("collab.agent.pause") : s("collab.agent.resume")
912
+ }
913
+ ),
914
+ /* @__PURE__ */ e(Nt, {}),
915
+ /* @__PURE__ */ e(
916
+ ve,
917
+ {
918
+ variant: "destructive",
919
+ disabled: !!(n.workingOn || n.waiting),
920
+ onSelect: () => {
921
+ window.confirm(
922
+ s("collab.agent.retireConfirm", {
923
+ name: n.name
924
+ })
925
+ ) && x(n.id);
926
+ },
927
+ children: s("collab.agent.retire")
928
+ }
929
+ )
930
+ ] })
931
+ ] })
932
+ ] })
933
+ ] }),
934
+ M?.id === n.id && h ? /* @__PURE__ */ a(
935
+ "form",
936
+ {
937
+ className: g.agentConfig,
938
+ onSubmit: H(n.id),
939
+ children: [
940
+ /* @__PURE__ */ a("label", { className: g.configLabel, children: [
941
+ s("collab.config.description"),
942
+ /* @__PURE__ */ e(
943
+ "input",
944
+ {
945
+ className: g.field,
946
+ name: "description",
947
+ defaultValue: n.description ?? "",
948
+ placeholder: s("collab.config.descriptionHint")
949
+ }
950
+ )
951
+ ] }),
952
+ /* @__PURE__ */ a("label", { className: g.configLabel, children: [
953
+ s("collab.config.instructions"),
954
+ /* @__PURE__ */ e(
955
+ "textarea",
956
+ {
957
+ className: g.field,
958
+ name: "instructions",
959
+ rows: 4,
960
+ defaultValue: n.instructions ?? "",
961
+ placeholder: s("collab.config.instructionsHint")
962
+ }
963
+ )
964
+ ] }),
965
+ /* @__PURE__ */ a("label", { className: g.configLabel, children: [
966
+ s("collab.config.agentType"),
967
+ /* @__PURE__ */ e(
968
+ "input",
969
+ {
970
+ className: g.field,
971
+ name: "agentType",
972
+ disabled: M.hostIds.length > 0,
973
+ defaultValue: n.agentType ?? "",
974
+ placeholder: s("collab.config.workspaceDefault")
975
+ }
976
+ )
977
+ ] }),
978
+ /* @__PURE__ */ a("label", { className: g.configLabel, children: [
979
+ s("collab.config.model"),
980
+ /* @__PURE__ */ e(
981
+ "input",
982
+ {
983
+ className: g.field,
984
+ name: "model",
985
+ disabled: M.hostIds.length > 0,
986
+ defaultValue: n.model ?? "",
987
+ placeholder: s("collab.config.workspaceDefault")
988
+ }
989
+ )
990
+ ] }),
991
+ /* @__PURE__ */ a("label", { className: g.configLabel, children: [
992
+ s("collab.config.maxRuns"),
993
+ /* @__PURE__ */ e(
994
+ "input",
995
+ {
996
+ className: g.field,
997
+ name: "maxConcurrentRuns",
998
+ type: "number",
999
+ min: 1,
1000
+ max: 8,
1001
+ defaultValue: n.maxConcurrentRuns ?? 1
1002
+ }
1003
+ )
1004
+ ] }),
1005
+ F.some(
1006
+ (C) => C.kind === "external"
1007
+ ) ? /* @__PURE__ */ a("fieldset", { className: g.configLabel, children: [
1008
+ /* @__PURE__ */ e("legend", { children: s("collab.config.runtimes") }),
1009
+ F.filter((C) => C.kind === "external").map((C) => /* @__PURE__ */ a("label", { children: [
1010
+ /* @__PURE__ */ e(
1011
+ "input",
1012
+ {
1013
+ name: "executionHostId",
1014
+ type: "checkbox",
1015
+ value: C.id,
1016
+ checked: M.hostIds.includes(C.id),
1017
+ disabled: !M.hostIds.includes(C.id) && !C.programs?.includes(
1018
+ n.execution?.mode === "managed-host" ? n.execution.provider ?? "qwen" : "qwen"
1019
+ ),
1020
+ onChange: (G) => {
1021
+ const Q = G.target.checked ? [...M.hostIds, C.id] : M.hostIds.filter(
1022
+ (te) => te !== C.id
1023
+ );
1024
+ I({ id: n.id, hostIds: Q });
1025
+ }
1026
+ }
1027
+ ),
1028
+ " ",
1029
+ r(C),
1030
+ " · ",
1031
+ C.provider,
1032
+ " ·",
1033
+ " ",
1034
+ m(C.status)
1035
+ ] }, C.id)),
1036
+ /* @__PURE__ */ e("span", { className: g.configNote, children: s(
1037
+ M.hostIds.length > 0 ? "collab.agent.hostPersona" : "collab.config.runtimesHint"
1038
+ ) })
1039
+ ] }) : null,
1040
+ /* @__PURE__ */ e("p", { className: g.configNote, children: s("collab.config.note") }),
1041
+ /* @__PURE__ */ a("div", { className: g.formActions, children: [
1042
+ /* @__PURE__ */ e(
1043
+ R,
1044
+ {
1045
+ type: "button",
1046
+ variant: "ghost",
1047
+ size: "sm",
1048
+ onClick: () => I(void 0),
1049
+ children: s("collab.form.cancel")
1050
+ }
1051
+ ),
1052
+ /* @__PURE__ */ e(R, { type: "submit", size: "sm", disabled: y, children: s("collab.config.save") })
1053
+ ] })
1054
+ ]
1055
+ }
1056
+ ) : null,
1057
+ K === n.id ? /* @__PURE__ */ a("section", { className: g.agentWorkspace, children: [
1058
+ /* @__PURE__ */ a("div", { className: g.agentWorkspaceHeader, children: [
1059
+ /* @__PURE__ */ e("strong", { children: s("collab.agent.assigned") }),
1060
+ /* @__PURE__ */ a("span", { children: [
1061
+ r(n.runtime),
1062
+ " · ",
1063
+ m(n.status)
1064
+ ] })
1065
+ ] }),
1066
+ c.some(
1067
+ (C) => C.assigneeName === n.name
1068
+ ) ? c.filter((C) => C.assigneeName === n.name).sort((C, G) => G.updatedAt - C.updatedAt).map((C) => /* @__PURE__ */ e(
1069
+ kt,
1070
+ {
1071
+ thread: C,
1072
+ onOpen: d
1073
+ },
1074
+ C.id
1075
+ )) : /* @__PURE__ */ e("p", { className: g.emptyRoster, children: s("collab.agent.noneAssigned") })
1076
+ ] }) : null
1077
+ ]
1078
+ },
1079
+ n.id
1080
+ )),
1081
+ v ? /* @__PURE__ */ a("div", { className: g.ceiling, children: [
1082
+ /* @__PURE__ */ e("h3", { className: g.ceilingTitle, children: s("collab.ceiling.title") }),
1083
+ /* @__PURE__ */ e("p", { className: g.ceilingText, children: v.readOnly ? s("collab.ceiling.readOnly") : s("collab.ceiling.open") }),
1084
+ /* @__PURE__ */ a("details", { children: [
1085
+ /* @__PURE__ */ e("summary", { className: "cursor-pointer text-xs text-muted-foreground", children: s("collab.ceiling.tools") }),
1086
+ /* @__PURE__ */ e("p", { className: g.ceilingTools, children: v.allowed.join(", ") })
1087
+ ] })
1088
+ ] }) : null
1089
+ ] }),
1090
+ re.length === 0 ? /* @__PURE__ */ e(De, { className: "border", hidden: l !== "tasks", children: /* @__PURE__ */ a(ze, { children: [
1091
+ /* @__PURE__ */ e(qe, { variant: "icon", children: /* @__PURE__ */ e(Ht, {}) }),
1092
+ /* @__PURE__ */ e(Ee, { children: s("collab.empty.lead") }),
1093
+ /* @__PURE__ */ e(st, { children: s("collab.empty.hint") })
1094
+ ] }) }) : re.map((n) => /* @__PURE__ */ e(
1095
+ Gn,
1096
+ {
1097
+ group: n,
1098
+ onOpenThread: d,
1099
+ hidden: l !== "tasks"
1100
+ },
1101
+ n.key
1102
+ )),
1103
+ l === "runtime" && F.length > 0 ? F.map((n) => /* @__PURE__ */ a("section", { className: g.runtimeCard, children: [
1104
+ /* @__PURE__ */ a("div", { className: g.runtimeHeader, children: [
1105
+ /* @__PURE__ */ e("h2", { className: g.runtimeTitle, children: r(n) }),
1106
+ /* @__PURE__ */ e("p", { className: g.configNote, children: n.kind === "local" ? s("collab.runtime.localNote") : s("collab.runtime.remoteNote") })
1107
+ ] }),
1108
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
1109
+ /* @__PURE__ */ e(
1110
+ "strong",
1111
+ {
1112
+ className: g.runtimeStatus,
1113
+ "data-runtime-status": n.status,
1114
+ children: m(n.status)
1115
+ }
1116
+ ),
1117
+ n.kind === "external" && (O || T) ? /* @__PURE__ */ a(Ne, { children: [
1118
+ T ? /* @__PURE__ */ e(
1119
+ R,
1120
+ {
1121
+ size: "sm",
1122
+ variant: "outline",
1123
+ disabled: y,
1124
+ onClick: () => {
1125
+ Y(n), Z(!0);
1126
+ },
1127
+ children: s("collab.runtime.replace")
1128
+ }
1129
+ ) : null,
1130
+ O ? /* @__PURE__ */ e(
1131
+ R,
1132
+ {
1133
+ size: "sm",
1134
+ variant: "ghost",
1135
+ disabled: y,
1136
+ onClick: () => {
1137
+ window.confirm(
1138
+ s("collab.runtime.removeConfirm", {
1139
+ name: n.label
1140
+ })
1141
+ ) && O(n.id);
1142
+ },
1143
+ children: s("collab.runtime.remove")
1144
+ }
1145
+ ) : null
1146
+ ] }) : null
1147
+ ] }),
1148
+ /* @__PURE__ */ a("dl", { className: g.runtimeFacts, children: [
1149
+ /* @__PURE__ */ a("div", { children: [
1150
+ /* @__PURE__ */ e("dt", { children: s("collab.runtime.programs") }),
1151
+ /* @__PURE__ */ e("dd", { children: n.provider })
1152
+ ] }),
1153
+ n.workspaceCwd ? /* @__PURE__ */ a("div", { children: [
1154
+ /* @__PURE__ */ e("dt", { children: s("collab.runtime.folder") }),
1155
+ /* @__PURE__ */ e("dd", { children: /* @__PURE__ */ e("code", { children: n.workspaceCwd }) })
1156
+ ] }) : null,
1157
+ /* @__PURE__ */ a("div", { children: [
1158
+ /* @__PURE__ */ e("dt", { children: s("collab.runtime.agents") }),
1159
+ /* @__PURE__ */ e("dd", { children: n.agentCount ?? 0 })
1160
+ ] }),
1161
+ /* @__PURE__ */ a("div", { children: [
1162
+ /* @__PURE__ */ e("dt", { children: s("collab.runtime.running") }),
1163
+ /* @__PURE__ */ e("dd", { children: n.runningTaskCount ?? 0 })
1164
+ ] }),
1165
+ /* @__PURE__ */ a("div", { children: [
1166
+ /* @__PURE__ */ e("dt", { children: s("collab.runtime.queued") }),
1167
+ /* @__PURE__ */ e("dd", { children: n.queuedTaskCount ?? 0 })
1168
+ ] })
1169
+ ] }),
1170
+ /* @__PURE__ */ a("details", { className: "mt-4 text-xs text-muted-foreground", children: [
1171
+ /* @__PURE__ */ e("summary", { className: "cursor-pointer", children: s("collab.runtime.technical") }),
1172
+ /* @__PURE__ */ e("p", { children: s("collab.runtime.id", { id: n.id }) }),
1173
+ n.hostSessionId && /* @__PURE__ */ e("p", { children: s("collab.runtime.hostSession", {
1174
+ id: n.hostSessionId
1175
+ }) }),
1176
+ /* @__PURE__ */ e("p", { children: s("collab.runtime.sessions", {
1177
+ count: n.sessionCount ?? 0
1178
+ }) }),
1179
+ n.lastSeenAt && /* @__PURE__ */ e("p", { children: s("collab.runtime.lastSeen", {
1180
+ time: new Date(
1181
+ n.lastSeenAt
1182
+ ).toLocaleTimeString()
1183
+ }) })
1184
+ ] })
1185
+ ] }, n.id)) : l === "runtime" ? /* @__PURE__ */ e(De, { className: "border", children: /* @__PURE__ */ a(ze, { children: [
1186
+ /* @__PURE__ */ e(qe, { variant: "icon", children: /* @__PURE__ */ e($t, {}) }),
1187
+ /* @__PURE__ */ e(Ee, { children: s("collab.runtime.empty") }),
1188
+ /* @__PURE__ */ e(st, { children: s("collab.runtime.emptyHint") })
1189
+ ] }) }) : null
1190
+ ] }),
1191
+ T && /* @__PURE__ */ e(
1192
+ ln,
1193
+ {
1194
+ open: ne,
1195
+ onOpenChange: (n) => {
1196
+ Z(n), n || Y(void 0);
1197
+ },
1198
+ serverUrl: P ?? "",
1199
+ runtimes: F,
1200
+ onCreateJoinToken: T,
1201
+ replacementTarget: _e,
1202
+ ...$ ? { onConnectExisting: $ } : {},
1203
+ ...L ? {
1204
+ onCreateAgentOn: (n) => {
1205
+ Z(!1), L(n);
1206
+ }
1207
+ } : {}
1208
+ },
1209
+ _e?.id ?? "add-host"
1210
+ ),
1211
+ A && ee && /* @__PURE__ */ e(
1212
+ cn,
1213
+ {
1214
+ agentName: ee.name,
1215
+ open: !0,
1216
+ onOpenChange: (n) => {
1217
+ n || ie(void 0);
1218
+ },
1219
+ onCreate: () => A.create(ee.id),
1220
+ onList: () => A.list(ee.id),
1221
+ onRevoke: (n) => A.revoke(ee.id, n)
1222
+ }
1223
+ )
1224
+ ] });
1225
+ }
1226
+ const Xn = "_runRow_1vx3b_3", Jn = "_runAgent_1vx3b_12", Yn = "_runState_1vx3b_23", Zn = "_runStateOutstanding_1vx3b_33", ea = "_runStateLive_1vx3b_37", ta = "_runProgress_1vx3b_41", na = "_runTrigger_1vx3b_58", aa = "_runLink_1vx3b_67", la = "_runCancel_1vx3b_68", sa = "_runError_1vx3b_91", X = {
1227
+ runRow: Xn,
1228
+ runAgent: Jn,
1229
+ runState: Yn,
1230
+ runStateOutstanding: Zn,
1231
+ runStateLive: ea,
1232
+ runProgress: ta,
1233
+ runTrigger: na,
1234
+ runLink: aa,
1235
+ runCancel: la,
1236
+ runError: sa
1237
+ }, oa = /* @__PURE__ */ new Set([
1238
+ "starting",
1239
+ "resuming",
1240
+ "waiting",
1241
+ "thinking",
1242
+ "tool",
1243
+ "responding"
1244
+ ]);
1245
+ function ut({
1246
+ row: t,
1247
+ agent: c,
1248
+ hideAgent: b = !1,
1249
+ onOpenAgentSession: l,
1250
+ onCancelRun: i
1251
+ }) {
1252
+ const { t: d } = oe(), x = t.run.sessionId, o = t.run.progress, [h, L] = _(Date.now);
1253
+ he(() => {
1254
+ if (!t.live) return;
1255
+ const $ = setInterval(() => L(Date.now()), 1e3);
1256
+ return () => clearInterval($);
1257
+ }, [t.live]);
1258
+ const q = o && h - o.activityAt > 15e3, T = t.run.status === "queued" ? c?.status === "offline" || c?.runtime?.status === "offline" ? d("collab.runRow.hostOffline", { host: c.runtime?.label ?? "" }) : d("collab.runRow.queued") : t.run.status === "running" ? o ? o.stage === "awaiting_approval" ? d("collab.runRow.stage.awaiting_approval") : q ? d("collab.runRow.quiet") : oa.has(o.stage) ? d(`collab.runRow.stage.${o.stage}`) : d("collab.runRow.working") : d("collab.runRow.unconfirmed") : t.state, O = t.outstanding ? `${X.runState} ${X.runStateOutstanding}` : t.live ? `${X.runState} ${X.runStateLive}` : X.runState;
1259
+ return /* @__PURE__ */ a("div", { className: X.runRow, "data-compact": b || void 0, children: [
1260
+ b ? null : /* @__PURE__ */ e("span", { className: X.runAgent, children: t.run.agentName }),
1261
+ /* @__PURE__ */ a("span", { className: O, children: [
1262
+ T,
1263
+ t.live && t.run.status !== "cancelling" && i ? /* @__PURE__ */ e(
1264
+ "button",
1265
+ {
1266
+ type: "button",
1267
+ className: X.runCancel,
1268
+ onClick: () => i(t.run.id),
1269
+ children: d("collab.runRow.cancel")
1270
+ }
1271
+ ) : null
1272
+ ] }),
1273
+ t.live && /* @__PURE__ */ a("div", { className: X.runProgress, role: "status", children: [
1274
+ t.run.startedAt && /* @__PURE__ */ e("div", { children: d("collab.runRow.elapsed", {
1275
+ elapsed: Ce(h - t.run.startedAt, d)
1276
+ }) }),
1277
+ o ? /* @__PURE__ */ e("div", { children: d("collab.runRow.lastActivity", {
1278
+ elapsed: Ce(h - o.activityAt, d)
1279
+ }) }) : /* @__PURE__ */ e("div", { children: t.run.status === "queued" ? d("collab.runRow.queuedHint") : d("collab.runRow.unconfirmedHint") })
1280
+ ] }),
1281
+ o?.detail && /* @__PURE__ */ a("details", { className: X.runProgress, open: t.live, children: [
1282
+ /* @__PURE__ */ e("summary", { children: d("collab.runRow.activity") }),
1283
+ /* @__PURE__ */ e("div", { children: o.detail })
1284
+ ] }),
1285
+ o?.thoughtText && /* @__PURE__ */ a("details", { className: X.runProgress, open: t.live, children: [
1286
+ /* @__PURE__ */ e("summary", { children: d("collab.runRow.thinking") }),
1287
+ /* @__PURE__ */ e("div", { className: "max-h-64 overflow-y-auto whitespace-pre-wrap break-words", children: o.thoughtText }),
1288
+ o.thoughtText.length >= 65536 && /* @__PURE__ */ e("p", { children: d("collab.runRow.thinkingCap") })
1289
+ ] }),
1290
+ o?.outputText && /* @__PURE__ */ a("details", { className: X.runProgress, children: [
1291
+ /* @__PURE__ */ e("summary", { children: d("collab.runRow.output") }),
1292
+ /* @__PURE__ */ e(
1293
+ Ft,
1294
+ {
1295
+ content: o.outputText,
1296
+ isStreaming: t.run.status === "running"
1297
+ }
1298
+ ),
1299
+ o.outputText.length >= 262144 && /* @__PURE__ */ e("p", { children: d("collab.runRow.outputCap") })
1300
+ ] }),
1301
+ /* @__PURE__ */ a("span", { className: X.runTrigger, children: [
1302
+ Kt(t.run.trigger, d),
1303
+ x && l ? /* @__PURE__ */ a(Ne, { children: [
1304
+ " · ",
1305
+ /* @__PURE__ */ e(
1306
+ "button",
1307
+ {
1308
+ type: "button",
1309
+ className: X.runLink,
1310
+ onClick: () => l(x),
1311
+ children: d("collab.runRow.openSession", { agent: t.run.agentName })
1312
+ }
1313
+ )
1314
+ ] }) : null
1315
+ ] }),
1316
+ t.run.error ? /* @__PURE__ */ e("span", { className: X.runError, children: t.run.error === "agent_run_stalled" ? d("collab.runRow.stalled") : t.run.error === "agent_program_unavailable" ? d("collab.runRow.programUnavailable") : t.run.error }) : null
1317
+ ] });
1318
+ }
1319
+ const ra = "_context_dl3fu_6", ia = "_chevronShown_dl3fu_11", ca = "_contextBody_dl3fu_15", da = "_dock_dl3fu_27", ma = "_row_dl3fu_36", ua = "_rowText_dl3fu_44", ha = "_attention_dl3fu_48", pa = "_steps_dl3fu_52", ba = "_step_dl3fu_52", ga = "_stepText_dl3fu_70", fa = "_approval_dl3fu_77", xa = "_approvalCaption_dl3fu_83", va = "_note_dl3fu_91", Na = "_composerHint_dl3fu_107", _a = "_team_dl3fu_119", wa = "_teamHeader_dl3fu_128", ka = "_teamTitle_dl3fu_135", Ca = "_teamReason_dl3fu_144", Ta = "_muted_dl3fu_145", ya = "_teamLink_dl3fu_150", Sa = "_sectionTitle_dl3fu_167", Ra = "_criteria_dl3fu_174", Aa = "_criteriaText_dl3fu_178", Ia = "_memberList_dl3fu_185", Ha = "_member_dl3fu_185", $a = "_memberHead_dl3fu_198", La = "_memberToggle_dl3fu_204", Da = "_childRow_dl3fu_205", za = "_memberText_dl3fu_236", qa = "_memberName_dl3fu_243", Ea = "_memberStatus_dl3fu_256", Ma = "_memberStatusAttention_dl3fu_267", Oa = "_memberStatusRunning_dl3fu_271", Wa = "_leadBadge_dl3fu_275", Ba = "_memberChevron_dl3fu_285", Pa = "_memberDetail_dl3fu_304", Ua = "_history_dl3fu_311", ja = "_budget_dl3fu_315", N = {
1320
+ context: ra,
1321
+ chevronShown: ia,
1322
+ contextBody: ca,
1323
+ dock: da,
1324
+ row: ma,
1325
+ rowText: ua,
1326
+ attention: ha,
1327
+ steps: pa,
1328
+ step: ba,
1329
+ stepText: ga,
1330
+ approval: fa,
1331
+ approvalCaption: xa,
1332
+ note: va,
1333
+ composerHint: Na,
1334
+ team: _a,
1335
+ teamHeader: wa,
1336
+ teamTitle: ka,
1337
+ teamReason: Ca,
1338
+ muted: Ta,
1339
+ teamLink: ya,
1340
+ sectionTitle: Sa,
1341
+ criteria: Ra,
1342
+ criteriaText: Aa,
1343
+ memberList: Ia,
1344
+ member: Ha,
1345
+ memberHead: $a,
1346
+ memberToggle: La,
1347
+ childRow: Da,
1348
+ memberText: za,
1349
+ memberName: qa,
1350
+ memberStatus: Ea,
1351
+ memberStatusAttention: Ma,
1352
+ memberStatusRunning: Oa,
1353
+ leadBadge: Wa,
1354
+ memberChevron: Ba,
1355
+ memberDetail: Pa,
1356
+ history: Ua,
1357
+ budget: ja
1358
+ }, Je = 5 * 6e4;
1359
+ function Ct(t) {
1360
+ const [c, b] = _(() => Date.now());
1361
+ return he(() => {
1362
+ if (!t) return;
1363
+ const l = setInterval(() => b(Date.now()), 1e3);
1364
+ return () => clearInterval(l);
1365
+ }, [t]), c;
1366
+ }
1367
+ function Fa(t, c, b, l) {
1368
+ const i = t.agentName;
1369
+ if (t.status === "queued")
1370
+ return {
1371
+ text: c ? l("collab.run.hostOffline", { agent: i }) : t.queueAhead ? l("collab.run.queuedBehind", { agent: i, count: t.queueAhead }) : l("collab.run.queued", { agent: i }),
1372
+ stalled: !1
1373
+ };
1374
+ if (t.status === "cancelling")
1375
+ return { text: l("collab.run.stopping", { agent: i }), stalled: !1 };
1376
+ const d = t.progress;
1377
+ if (!d)
1378
+ return { text: l("collab.run.starting", { agent: i }), stalled: !1 };
1379
+ const x = b - d.activityAt;
1380
+ if (x >= Je)
1381
+ return {
1382
+ text: l("collab.run.stalled", { agent: i, elapsed: Ce(x, l) }),
1383
+ stalled: !0
1384
+ };
1385
+ const o = Ce(b - (t.startedAt ?? b), l);
1386
+ switch (d.stage) {
1387
+ case "starting":
1388
+ return { text: l("collab.run.starting", { agent: i }), stalled: !1 };
1389
+ case "resuming":
1390
+ return { text: l("collab.run.resuming", { agent: i }), stalled: !1 };
1391
+ case "thinking":
1392
+ return {
1393
+ text: l("collab.run.thinking", { agent: i, elapsed: o }),
1394
+ stalled: !1
1395
+ };
1396
+ case "responding":
1397
+ return {
1398
+ text: l("collab.run.responding", { agent: i, elapsed: o }),
1399
+ stalled: !1
1400
+ };
1401
+ case "tool":
1402
+ return {
1403
+ text: d.detail ? l("collab.run.toolNamed", { agent: i, tool: d.detail, elapsed: o }) : l("collab.run.tool", { agent: i, elapsed: o }),
1404
+ stalled: !1
1405
+ };
1406
+ case "stream_lost":
1407
+ return { text: l("collab.run.streamLost", { agent: i }), stalled: !1 };
1408
+ default:
1409
+ return {
1410
+ text: l("collab.run.working", { agent: i, elapsed: o }),
1411
+ stalled: !1
1412
+ };
1413
+ }
1414
+ }
1415
+ const Ka = /* @__PURE__ */ new Set(["queued", "running", "finishing", "cancelling"]), Ae = (t) => t !== void 0 && Ka.has(t.status), $e = (t) => t.endedAt ?? t.startedAt ?? 0;
1416
+ function Va(t, c, b) {
1417
+ const l = t.filter((d) => d.willWake).map((d) => d.agentName);
1418
+ return l.length === 0 ? b("collab.preview.nobody") : c.filter((d) => !l.includes(d.name)).length > 0 ? b("collab.preview.only", { names: l.join(", ") }) : b("collab.preview.to", { names: l.join(", ") });
1419
+ }
1420
+ function Tt(t, c) {
1421
+ const b = /* @__PURE__ */ new Map(), l = (i, d = {}) => {
1422
+ const x = b.get(i) ?? { name: i, lead: !1 };
1423
+ b.set(i, { ...x, ...d });
1424
+ };
1425
+ t.assigneeName && l(t.assigneeName, { lead: !0 });
1426
+ for (const i of t.posts)
1427
+ i.authorKind === "agent" && l(i.authorName);
1428
+ for (const i of t.runs) {
1429
+ const d = b.get(i.agentName)?.run, x = !d || Ae(i) && !Ae(d) || Ae(i) === Ae(d) && $e(i) >= $e(d);
1430
+ l(i.agentName, {
1431
+ ...i.agentColor ? { color: i.agentColor } : {},
1432
+ ...x ? { run: i } : {}
1433
+ });
1434
+ }
1435
+ for (const i of b.values()) {
1436
+ const d = c.find((x) => x.name === i.name);
1437
+ i.color ??= d?.color;
1438
+ }
1439
+ return [...b.values()].sort((i, d) => Number(d.lead) - Number(i.lead));
1440
+ }
1441
+ function Ga(t, c, b, l) {
1442
+ const i = t.run, d = "", x = N.memberStatusAttention, o = N.memberStatusRunning;
1443
+ if (!i) return { text: l("collab.member.idle"), tone: d };
1444
+ switch (i.status) {
1445
+ case "queued":
1446
+ return c.find((h) => h.id === i.agentId)?.runtime?.status === "offline" ? { text: l("collab.member.offline"), tone: x } : { text: l("collab.member.queued"), tone: d };
1447
+ case "running":
1448
+ case "finishing":
1449
+ case "cancelling": {
1450
+ const h = i.progress;
1451
+ return h?.permission ? { text: l("collab.member.approval"), tone: x } : h && b - h.activityAt >= Je ? { text: l("collab.member.stalled"), tone: x } : h?.stage === "tool" && h.detail ? {
1452
+ text: l("collab.member.tool", { tool: h.detail }),
1453
+ tone: o
1454
+ } : h?.stage === "thinking" ? { text: l("collab.member.thinking"), tone: o } : h?.stage === "responding" ? { text: l("collab.member.responding"), tone: o } : { text: l("collab.member.starting"), tone: o };
1455
+ }
1456
+ case "cancelled":
1457
+ return { text: l("collab.member.cancelled"), tone: x };
1458
+ case "failed":
1459
+ return {
1460
+ text: i.error === "agent_run_stalled" ? l("collab.member.timedOut") : l("collab.member.failed"),
1461
+ tone: x
1462
+ };
1463
+ default:
1464
+ return { text: l("collab.member.done"), tone: d };
1465
+ }
1466
+ }
1467
+ const yt = At(null);
1468
+ function Qa() {
1469
+ const t = Rt(yt);
1470
+ return t ? /* @__PURE__ */ e("span", { className: N.composerHint, children: t }) : null;
1471
+ }
1472
+ function Xa(t, c, b) {
1473
+ const { description: l } = Yt(t.title);
1474
+ return {
1475
+ id: t.requestId,
1476
+ title: t.title || b("collab.approval.title", { agent: c }),
1477
+ content: [],
1478
+ ...l ? { rawInput: { description: l } } : {},
1479
+ options: t.options.map(
1480
+ (i) => ({
1481
+ id: i.optionId,
1482
+ label: i.name,
1483
+ ...i.kind ? { kind: i.kind } : {}
1484
+ })
1485
+ )
1486
+ };
1487
+ }
1488
+ function Ja({
1489
+ thread: t,
1490
+ agents: c,
1491
+ pending: b,
1492
+ onOpenAgentSession: l,
1493
+ onCancelRun: i,
1494
+ onOpenThread: d,
1495
+ onAssign: x
1496
+ }) {
1497
+ const { t: o } = oe(), { live: h, past: L } = Fe(t.runs, o), q = Ct(h.length > 0), T = Tt(t, c), [O, $] = _({}), P = Jt(t.budget, o), A = t.status === "done" || t.status === "cancelled";
1498
+ return /* @__PURE__ */ a("section", { className: N.team, "aria-label": o("collab.team.title"), children: [
1499
+ /* @__PURE__ */ a("header", { className: N.teamHeader, children: [
1500
+ /* @__PURE__ */ e("h2", { className: N.teamTitle, children: t.title }),
1501
+ /* @__PURE__ */ e("p", { className: N.teamReason, children: He(t.reason, o) }),
1502
+ x ? /* @__PURE__ */ a("div", { className: "mt-2 flex items-center gap-2", children: [
1503
+ /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground", children: o("collab.form.assignee") }),
1504
+ /* @__PURE__ */ a(Pe, { children: [
1505
+ /* @__PURE__ */ e(Ue, { asChild: !0, children: /* @__PURE__ */ e(
1506
+ R,
1507
+ {
1508
+ variant: "outline",
1509
+ size: "sm",
1510
+ disabled: b || A,
1511
+ "aria-label": o("collab.form.assignee"),
1512
+ children: t.assigneeName ?? o("collab.team.noLead")
1513
+ }
1514
+ ) }),
1515
+ /* @__PURE__ */ a(je, { align: "start", className: "min-w-40", children: [
1516
+ /* @__PURE__ */ a(ve, { onSelect: () => x(void 0), children: [
1517
+ t.assigneeName ? null : /* @__PURE__ */ e(Ie, { className: "size-4" }),
1518
+ o("collab.team.noLead")
1519
+ ] }),
1520
+ /* @__PURE__ */ e(Nt, {}),
1521
+ c.filter((v) => v.enabled && !v.retiredAt).map((v) => /* @__PURE__ */ a(
1522
+ ve,
1523
+ {
1524
+ onSelect: () => x(v.name),
1525
+ children: [
1526
+ t.assigneeName === v.name ? /* @__PURE__ */ e(Ie, { className: "size-4" }) : null,
1527
+ v.name
1528
+ ]
1529
+ },
1530
+ v.id
1531
+ ))
1532
+ ] })
1533
+ ] })
1534
+ ] }) : null,
1535
+ t.parent && /* @__PURE__ */ e(
1536
+ "button",
1537
+ {
1538
+ type: "button",
1539
+ className: N.teamLink,
1540
+ onClick: () => d(t.parent.id),
1541
+ children: o("collab.team.parent", { title: t.parent.title })
1542
+ }
1543
+ )
1544
+ ] }),
1545
+ t.acceptanceCriteria ? /* @__PURE__ */ a("div", { className: N.criteria, children: [
1546
+ /* @__PURE__ */ e("h3", { className: N.sectionTitle, children: o("collab.detail.doneWhen") }),
1547
+ /* @__PURE__ */ e("p", { className: N.criteriaText, children: t.acceptanceCriteria })
1548
+ ] }) : null,
1549
+ /* @__PURE__ */ e("h3", { className: N.sectionTitle, children: o("collab.team.members", { count: T.length }) }),
1550
+ T.length === 0 && /* @__PURE__ */ e("p", { className: N.muted, children: o("collab.team.empty") }),
1551
+ /* @__PURE__ */ e("ul", { className: N.memberList, children: T.map((v) => {
1552
+ const { text: u, tone: f } = Ga(v, c, q, o), E = h.filter((z) => z.run.agentName === v.name), B = E.length > 0 || v.run !== void 0, U = B && (O[v.name] ?? E.length > 0), W = v.run?.sessionId;
1553
+ return /* @__PURE__ */ a("li", { className: N.member, children: [
1554
+ /* @__PURE__ */ a("div", { className: N.memberHead, children: [
1555
+ /* @__PURE__ */ a(
1556
+ "button",
1557
+ {
1558
+ type: "button",
1559
+ className: N.memberToggle,
1560
+ "aria-expanded": B ? U : void 0,
1561
+ disabled: !B,
1562
+ onClick: () => $((z) => ({
1563
+ ...z,
1564
+ [v.name]: !U
1565
+ })),
1566
+ children: [
1567
+ /* @__PURE__ */ e(ke, { name: v.name, color: v.color }),
1568
+ /* @__PURE__ */ a("span", { className: N.memberText, children: [
1569
+ /* @__PURE__ */ a("span", { className: N.memberName, children: [
1570
+ v.name,
1571
+ v.lead && /* @__PURE__ */ e("span", { className: N.leadBadge, children: o("collab.team.lead") })
1572
+ ] }),
1573
+ /* @__PURE__ */ e(
1574
+ "span",
1575
+ {
1576
+ className: [N.memberStatus, f].filter(Boolean).join(" "),
1577
+ children: u
1578
+ }
1579
+ )
1580
+ ] }),
1581
+ B && /* @__PURE__ */ e(
1582
+ bt,
1583
+ {
1584
+ "aria-hidden": "true",
1585
+ className: N.memberChevron
1586
+ }
1587
+ )
1588
+ ]
1589
+ }
1590
+ ),
1591
+ W && l ? /* @__PURE__ */ a(Pe, { children: [
1592
+ /* @__PURE__ */ e(Ue, { asChild: !0, children: /* @__PURE__ */ e(
1593
+ R,
1594
+ {
1595
+ variant: "ghost",
1596
+ size: "icon-xs",
1597
+ "aria-label": o("collab.agent.more", {
1598
+ name: v.name
1599
+ }),
1600
+ children: /* @__PURE__ */ e(pt, {})
1601
+ }
1602
+ ) }),
1603
+ /* @__PURE__ */ e(je, { align: "end", className: "min-w-40", children: /* @__PURE__ */ e(
1604
+ ve,
1605
+ {
1606
+ onSelect: () => l(W),
1607
+ children: o("collab.runRow.openSession", {
1608
+ agent: v.name
1609
+ })
1610
+ }
1611
+ ) })
1612
+ ] }) : null
1613
+ ] }),
1614
+ U && /* @__PURE__ */ e("div", { className: N.memberDetail, children: (E.length > 0 ? E : Fe([v.run], o).past).map((z) => /* @__PURE__ */ e(
1615
+ ut,
1616
+ {
1617
+ row: z,
1618
+ agent: c.find(
1619
+ (y) => y.id === z.run.agentId
1620
+ ),
1621
+ hideAgent: !0,
1622
+ onOpenAgentSession: l,
1623
+ onCancelRun: b ? void 0 : i
1624
+ },
1625
+ z.run.id
1626
+ )) })
1627
+ ] }, v.name);
1628
+ }) }),
1629
+ !!t.children?.length && /* @__PURE__ */ a(Ne, { children: [
1630
+ /* @__PURE__ */ e("h3", { className: N.sectionTitle, children: o("collab.team.tasks", { count: t.children.length }) }),
1631
+ /* @__PURE__ */ e("ul", { className: N.memberList, children: t.children.map((v) => /* @__PURE__ */ e("li", { children: /* @__PURE__ */ a(
1632
+ "button",
1633
+ {
1634
+ type: "button",
1635
+ className: N.childRow,
1636
+ onClick: () => d(v.id),
1637
+ children: [
1638
+ /* @__PURE__ */ e("span", { className: N.memberName, children: v.title }),
1639
+ /* @__PURE__ */ e("span", { className: N.memberStatus, children: [v.assigneeName, He(v.reason, o)].filter(Boolean).join(" · ") })
1640
+ ]
1641
+ }
1642
+ ) }, v.id)) })
1643
+ ] }),
1644
+ L.length > 0 && /* @__PURE__ */ a("details", { className: N.history, children: [
1645
+ /* @__PURE__ */ e("summary", { className: N.sectionTitle, children: o("collab.team.history", { count: L.length }) }),
1646
+ L.map((v) => /* @__PURE__ */ e(
1647
+ ut,
1648
+ {
1649
+ row: v,
1650
+ agent: c.find((u) => u.id === v.run.agentId),
1651
+ onOpenAgentSession: l
1652
+ },
1653
+ v.run.id
1654
+ ))
1655
+ ] }),
1656
+ /* @__PURE__ */ a("footer", { className: N.budget, children: [
1657
+ /* @__PURE__ */ e("span", { children: P.turns }),
1658
+ /* @__PURE__ */ e("span", { children: P.tokens }),
1659
+ /* @__PURE__ */ e("span", { children: P.scope })
1660
+ ] })
1661
+ ] });
1662
+ }
1663
+ function Ya({
1664
+ thread: t,
1665
+ agents: c,
1666
+ preview: b,
1667
+ pending: l,
1668
+ onSend: i,
1669
+ onDraftChange: d,
1670
+ onOpenAgentSession: x,
1671
+ onCancelRun: o,
1672
+ onMarkDone: h,
1673
+ onOpenThread: L,
1674
+ onRespondPermission: q,
1675
+ onAssign: T,
1676
+ onBack: O,
1677
+ activityOnly: $ = !1,
1678
+ onOpenActivity: P,
1679
+ headerActionsContainer: A
1680
+ }) {
1681
+ const v = Vt(), { t: u } = oe(), [f, E] = _(!1), [B, U] = _(/* @__PURE__ */ new Set()), [W, z] = _(!1), [y, re] = _(!0), [F, ge] = _({}), { live: j } = Fe(t.runs, u), M = Ct(j.length > 0), I = se(() => {
1682
+ const m = /* @__PURE__ */ new Map();
1683
+ for (const r of t.runs) {
1684
+ const S = m.get(r.agentId);
1685
+ (!S || $e(r) >= $e(S)) && m.set(r.agentId, r);
1686
+ }
1687
+ return [...m.values()].filter((r) => {
1688
+ if (r.status !== "failed" || t.status === "done" || t.status === "cancelled")
1689
+ return !1;
1690
+ const S = c.find(
1691
+ (H) => H.id === r.agentId || H.name === r.agentName
1692
+ );
1693
+ return !S || !S.enabled || S.retiredAt !== void 0 ? !1 : !j.some(
1694
+ (H) => H.run.agentId === S.id || H.run.agentName === S.name
1695
+ );
1696
+ });
1697
+ }, [t.runs, t.status, j, c]), K = se(() => {
1698
+ const m = /* @__PURE__ */ new Map();
1699
+ for (const r of c)
1700
+ r.color && m.set(r.name, r.color);
1701
+ for (const r of t.runs)
1702
+ r.agentColor && m.set(r.agentName, r.agentColor);
1703
+ return (r) => m.get(r);
1704
+ }, [c, t.runs]), w = se(() => {
1705
+ const m = (r, S = r) => {
1706
+ const H = K(r);
1707
+ return { name: S, ...H ? { color: H } : {} };
1708
+ };
1709
+ return [
1710
+ ...t.body && !t.body.startsWith(Me) ? [
1711
+ {
1712
+ id: `${t.id}:description`,
1713
+ role: "user",
1714
+ content: t.body
1715
+ }
1716
+ ] : [],
1717
+ ...t.posts.flatMap((r) => {
1718
+ const S = r.authorKind === "human" ? {
1719
+ id: r.id,
1720
+ role: "user",
1721
+ content: r.text,
1722
+ timestamp: r.at
1723
+ } : r.authorKind === "agent" ? {
1724
+ id: r.id,
1725
+ role: "assistant",
1726
+ content: r.text,
1727
+ author: m(
1728
+ r.authorName,
1729
+ r.authorDeleted ? u("collab.author.removed", {
1730
+ name: r.authorName
1731
+ }) : r.authorName
1732
+ ),
1733
+ timestamp: r.at
1734
+ } : {
1735
+ id: r.id,
1736
+ role: "system",
1737
+ content: r.text,
1738
+ variant: "info",
1739
+ source: "agent_collaboration",
1740
+ timestamp: r.at
1741
+ }, H = (r.outcomes ?? []).filter(
1742
+ (J) => J.kind === "skip"
1743
+ );
1744
+ return [
1745
+ S,
1746
+ ...H.map(
1747
+ (J, V) => ({
1748
+ id: `${r.id}:routing:${V}`,
1749
+ role: "system",
1750
+ content: Be(
1751
+ J.reason ?? "",
1752
+ J.agentName ?? "",
1753
+ u
1754
+ ),
1755
+ variant: "warning",
1756
+ source: "agent_collaboration_routing",
1757
+ timestamp: r.at
1758
+ })
1759
+ )
1760
+ ];
1761
+ }),
1762
+ ...t.runs.filter((r) => r.progress?.thoughtText).map(
1763
+ (r) => ({
1764
+ id: `${r.id}:thought`,
1765
+ role: "thinking",
1766
+ content: r.progress.thoughtText,
1767
+ author: m(r.agentName),
1768
+ // Last update, not start: text being written now belongs
1769
+ // after anything the run posted along the way.
1770
+ timestamp: r.progress?.receivedAt ?? r.startedAt,
1771
+ isStreaming: r.status === "running" && r.progress?.stage === "thinking"
1772
+ })
1773
+ ),
1774
+ ...t.runs.filter(
1775
+ (r) => r.progress?.outputText && !t.posts.some(
1776
+ (S) => S.sourceRunId === r.id && (r.closeKind === "review" || r.closeKind === "blocked" || S.text.trim() === r.progress?.outputText?.trim())
1777
+ )
1778
+ ).map(
1779
+ (r) => ({
1780
+ id: `${r.id}:output`,
1781
+ role: "assistant",
1782
+ content: r.progress.outputText,
1783
+ author: m(r.agentName),
1784
+ // Last update, not start: text being written now belongs
1785
+ // after anything the run posted along the way.
1786
+ timestamp: r.progress?.receivedAt ?? r.startedAt,
1787
+ isStreaming: r.status === "running"
1788
+ })
1789
+ )
1790
+ ].sort((r, S) => (r.timestamp ?? 0) - (S.timestamp ?? 0));
1791
+ }, [t.id, t.body, t.posts, t.runs, K, u]), s = se(() => Tt(t, c), [t, c]), ne = se(
1792
+ () => ({ ...v, renderComposerToolbarStart: Qa }),
1793
+ [v]
1794
+ );
1795
+ if ($)
1796
+ return /* @__PURE__ */ e(
1797
+ Ja,
1798
+ {
1799
+ thread: t,
1800
+ agents: c,
1801
+ pending: l,
1802
+ onOpenAgentSession: x,
1803
+ onCancelRun: o,
1804
+ onOpenThread: L,
1805
+ ...T ? { onAssign: T } : {}
1806
+ }
1807
+ );
1808
+ const Z = /* @__PURE__ */ a("div", { className: "flex shrink-0 items-center gap-1", children: [
1809
+ t.status !== "done" && /* @__PURE__ */ e(
1810
+ R,
1811
+ {
1812
+ variant: "ghost",
1813
+ size: "icon",
1814
+ title: u("collab.markDone"),
1815
+ "aria-label": u("collab.markDone"),
1816
+ disabled: l,
1817
+ onClick: h,
1818
+ children: /* @__PURE__ */ e(Ie, { className: "size-4" })
1819
+ }
1820
+ ),
1821
+ P && /* @__PURE__ */ e(
1822
+ R,
1823
+ {
1824
+ variant: "ghost",
1825
+ size: "icon",
1826
+ title: u("collab.team.title"),
1827
+ "aria-label": u("collab.team.title"),
1828
+ onClick: P,
1829
+ children: /* @__PURE__ */ e(at, { className: "size-4" })
1830
+ }
1831
+ )
1832
+ ] }), _e = j.flatMap(({ run: m }) => {
1833
+ const r = m.progress?.permission;
1834
+ if (!r || !m.sessionId || !q || B.has(r.requestId))
1835
+ return [];
1836
+ const S = m.sessionId;
1837
+ return [
1838
+ /* @__PURE__ */ a(
1839
+ "div",
1840
+ {
1841
+ role: "group",
1842
+ "aria-label": u("collab.approval.title", { agent: m.agentName }),
1843
+ className: N.approval,
1844
+ children: [
1845
+ /* @__PURE__ */ a("div", { className: N.approvalCaption, children: [
1846
+ /* @__PURE__ */ e(ke, { name: m.agentName, color: K(m.agentName) }),
1847
+ u("collab.approval.title", { agent: m.agentName })
1848
+ ] }),
1849
+ /* @__PURE__ */ e(
1850
+ Gt,
1851
+ {
1852
+ request: Xa(r, m.agentName, u),
1853
+ keyboardActive: !1,
1854
+ onConfirm: (H, J) => {
1855
+ U((n) => /* @__PURE__ */ new Set([...n, H]));
1856
+ const V = () => U((n) => {
1857
+ const C = new Set(n);
1858
+ return C.delete(H), C;
1859
+ });
1860
+ q(S, H, J).then(
1861
+ (n) => n === !1 && V(),
1862
+ V
1863
+ );
1864
+ }
1865
+ }
1866
+ )
1867
+ ]
1868
+ },
1869
+ m.id
1870
+ )
1871
+ ];
1872
+ }), Y = j.filter(
1873
+ ({ run: m }) => !(m.progress?.permission && m.sessionId && q && !B.has(m.progress.permission.requestId))
1874
+ ), ee = Y.length > 0 || I.length > 0, ie = t.status === "blocked" || t.status === "in_review", de = b?.filter((m) => !m.willWake) ?? [], me = b ? Va(b, s, u) : t.assigneeName ? u("collab.composer.hint", { name: t.assigneeName }) : null;
1875
+ return /* @__PURE__ */ a("div", { className: "flex min-h-0 flex-1 flex-col overflow-hidden", children: [
1876
+ A ? tn(Z, A) : /* @__PURE__ */ a("header", { className: "flex items-center gap-2 border-b border-border px-4 py-2", children: [
1877
+ O && /* @__PURE__ */ e(
1878
+ R,
1879
+ {
1880
+ variant: "ghost",
1881
+ size: "icon-sm",
1882
+ "aria-label": u("collab.thread.back"),
1883
+ onClick: O,
1884
+ children: /* @__PURE__ */ e(gt, {})
1885
+ }
1886
+ ),
1887
+ /* @__PURE__ */ e("h1", { className: "min-w-0 flex-1 truncate text-sm font-semibold", children: t.title }),
1888
+ Z
1889
+ ] }),
1890
+ t.body.startsWith(Me) && /* @__PURE__ */ a("div", { className: N.context, children: [
1891
+ /* @__PURE__ */ a(
1892
+ "button",
1893
+ {
1894
+ type: "button",
1895
+ className: D.summary,
1896
+ "aria-expanded": W,
1897
+ onClick: () => z((m) => !m),
1898
+ children: [
1899
+ /* @__PURE__ */ e("span", { className: D.summaryText, children: u("collab.thread.context") }),
1900
+ /* @__PURE__ */ e(
1901
+ "span",
1902
+ {
1903
+ className: `${W ? D.chevronDown : D.chevronRight} ${N.chevronShown}`,
1904
+ "aria-hidden": "true"
1905
+ }
1906
+ )
1907
+ ]
1908
+ }
1909
+ ),
1910
+ W && /* @__PURE__ */ e("div", { className: `${D.group} ${N.contextBody}`, children: t.body.slice(Me.length) })
1911
+ ] }),
1912
+ /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ e(
1913
+ ot,
1914
+ {
1915
+ value: { ...v, collapseCompletedTurns: !1 },
1916
+ children: /* @__PURE__ */ e(
1917
+ Qt,
1918
+ {
1919
+ messages: w,
1920
+ pendingApproval: null,
1921
+ sessionKey: t.id,
1922
+ hideSessionTimeline: !0
1923
+ }
1924
+ )
1925
+ }
1926
+ ) }),
1927
+ /* @__PURE__ */ a("div", { className: N.dock, children: [
1928
+ /* @__PURE__ */ a("div", { className: D.wrap, children: [
1929
+ /* @__PURE__ */ a(
1930
+ "button",
1931
+ {
1932
+ type: "button",
1933
+ className: D.summary,
1934
+ "aria-expanded": ee ? y : void 0,
1935
+ "aria-disabled": ee ? void 0 : !0,
1936
+ onClick: ee ? () => re((m) => !m) : void 0,
1937
+ children: [
1938
+ /* @__PURE__ */ e("span", { className: D.summaryIcon, "aria-hidden": "true", children: /* @__PURE__ */ e(at, { className: "size-3.5" }) }),
1939
+ /* @__PURE__ */ e(
1940
+ "span",
1941
+ {
1942
+ className: Y.length > 0 ? `${D.summaryText} ${D.summaryTextActive}` : ie ? `${D.summaryText} ${N.attention}` : D.summaryText,
1943
+ children: He(t.reason, u)
1944
+ }
1945
+ ),
1946
+ /* @__PURE__ */ e(
1947
+ "span",
1948
+ {
1949
+ className: y ? D.chevronDown : D.chevronRight,
1950
+ "aria-hidden": "true"
1951
+ }
1952
+ )
1953
+ ]
1954
+ }
1955
+ ),
1956
+ ee && y && /* @__PURE__ */ e("div", { className: D.group, children: /* @__PURE__ */ a("div", { className: D.list, children: [
1957
+ Y.map(({ run: m }) => {
1958
+ const r = c.find((n) => n.id === m.agentId)?.runtime?.status === "offline", S = Fa(m, r, M, u), H = S.stalled && M >= (F[m.id] ?? 0), J = H ? S.text : S.stalled ? u("collab.run.working", {
1959
+ agent: m.agentName,
1960
+ elapsed: Ce(
1961
+ M - (m.startedAt ?? M),
1962
+ u
1963
+ )
1964
+ }) : S.text, V = m.progress?.steps ?? [];
1965
+ return /* @__PURE__ */ a("div", { children: [
1966
+ /* @__PURE__ */ a(
1967
+ "div",
1968
+ {
1969
+ role: "status",
1970
+ className: `${D.row} ${N.row}`,
1971
+ "data-agent-status": H ? "failed" : "active",
1972
+ children: [
1973
+ /* @__PURE__ */ e(
1974
+ ke,
1975
+ {
1976
+ name: m.agentName,
1977
+ color: K(m.agentName)
1978
+ }
1979
+ ),
1980
+ /* @__PURE__ */ e("span", { className: D.rowText, children: /* @__PURE__ */ e(
1981
+ "span",
1982
+ {
1983
+ className: `${D.rowActivity} ${H ? N.attention : N.rowText}`,
1984
+ children: J
1985
+ }
1986
+ ) }),
1987
+ H && /* @__PURE__ */ e(
1988
+ R,
1989
+ {
1990
+ size: "xs",
1991
+ variant: "ghost",
1992
+ onClick: () => ge((n) => ({
1993
+ ...n,
1994
+ [m.id]: M + Je
1995
+ })),
1996
+ children: u("collab.run.keepWaiting")
1997
+ }
1998
+ ),
1999
+ (H || m.status === "queued") && !l && /* @__PURE__ */ e(
2000
+ R,
2001
+ {
2002
+ size: "xs",
2003
+ variant: "ghost",
2004
+ onClick: () => o(m.id),
2005
+ children: u("collab.run.stop")
2006
+ }
2007
+ )
2008
+ ]
2009
+ }
2010
+ ),
2011
+ V.length > 0 && // One line per tool call, like a CI job's step list.
2012
+ /* @__PURE__ */ e(
2013
+ "ol",
2014
+ {
2015
+ "aria-label": u("collab.run.steps", {
2016
+ agent: m.agentName
2017
+ }),
2018
+ className: N.steps,
2019
+ children: V.map((n) => /* @__PURE__ */ a("li", { className: N.step, children: [
2020
+ n.status === "running" ? /* @__PURE__ */ e(
2021
+ We,
2022
+ {
2023
+ "aria-label": u("collab.step.running"),
2024
+ className: "size-3 shrink-0 animate-spin motion-reduce:animate-none"
2025
+ }
2026
+ ) : n.status === "done" ? /* @__PURE__ */ e(
2027
+ Ie,
2028
+ {
2029
+ "aria-label": u("collab.step.done"),
2030
+ className: "size-3 shrink-0 text-[var(--success-color)]"
2031
+ }
2032
+ ) : /* @__PURE__ */ e(
2033
+ Lt,
2034
+ {
2035
+ "aria-label": u("collab.step.failed"),
2036
+ className: "size-3 shrink-0 text-destructive"
2037
+ }
2038
+ ),
2039
+ /* @__PURE__ */ e(
2040
+ "span",
2041
+ {
2042
+ className: n.status === "running" ? `${N.stepText} text-foreground` : N.stepText,
2043
+ children: n.title || u("collab.step.untitled")
2044
+ }
2045
+ )
2046
+ ] }, n.id))
2047
+ }
2048
+ )
2049
+ ] }, m.id);
2050
+ }),
2051
+ I.map((m) => /* @__PURE__ */ a(
2052
+ "div",
2053
+ {
2054
+ role: "status",
2055
+ className: `${D.row} ${N.row}`,
2056
+ "data-agent-status": "failed",
2057
+ children: [
2058
+ /* @__PURE__ */ e(
2059
+ ke,
2060
+ {
2061
+ name: m.agentName,
2062
+ color: K(m.agentName)
2063
+ }
2064
+ ),
2065
+ /* @__PURE__ */ e("span", { className: D.rowText, children: /* @__PURE__ */ e(
2066
+ "span",
2067
+ {
2068
+ className: `${D.rowActivity} ${N.attention}`,
2069
+ children: m.error === "agent_run_stalled" ? u("collab.run.timedOut", { agent: m.agentName }) : m.error === "agent_program_unavailable" ? u("collab.run.programUnavailable", {
2070
+ agent: m.agentName
2071
+ }) : u("collab.run.failed", { agent: m.agentName })
2072
+ }
2073
+ ) }),
2074
+ !l && /* @__PURE__ */ e(
2075
+ R,
2076
+ {
2077
+ size: "xs",
2078
+ variant: "ghost",
2079
+ onClick: () => void i(
2080
+ `@${m.agentName} ${u("collab.run.retryPrompt")}`
2081
+ ),
2082
+ children: u("collab.run.retry")
2083
+ }
2084
+ )
2085
+ ]
2086
+ },
2087
+ m.id
2088
+ ))
2089
+ ] }) })
2090
+ ] }),
2091
+ _e,
2092
+ f && /* @__PURE__ */ a("div", { role: "status", className: N.note, children: [
2093
+ /* @__PURE__ */ e(
2094
+ We,
2095
+ {
2096
+ "aria-hidden": "true",
2097
+ className: "size-3.5 animate-spin motion-reduce:animate-none"
2098
+ }
2099
+ ),
2100
+ u("collab.sending")
2101
+ ] }),
2102
+ de.length > 0 && /* @__PURE__ */ e("div", { role: "status", className: N.note, children: de.map((m) => /* @__PURE__ */ e("p", { children: Be(m.reason ?? "", m.agentName, u) }, `${m.agentName}:${m.reason}`)) }),
2103
+ /* @__PURE__ */ e(yt.Provider, { value: me, children: /* @__PURE__ */ e(ot, { value: ne, children: /* @__PURE__ */ e(
2104
+ Xt,
2105
+ {
2106
+ commands: [],
2107
+ builtinAtProviders: !1,
2108
+ visibleToolbarActions: [],
2109
+ atProviders: [
2110
+ {
2111
+ id: "agents",
2112
+ label: u("collab.mention.provider"),
2113
+ search: async ({ query: m }) => c.filter(
2114
+ (r) => r.enabled && !r.retiredAt && r.name.toLowerCase().includes(m.toLowerCase())
2115
+ ).map((r) => ({
2116
+ id: r.id,
2117
+ label: r.name,
2118
+ insertText: `@${r.name} `
2119
+ }))
2120
+ }
2121
+ ],
2122
+ placeholderText: u("collab.composer.placeholder"),
2123
+ disabled: l || t.status === "done" || t.status === "cancelled",
2124
+ onInputTextChange: d,
2125
+ onSubmit: (m, r, S, H) => (r?.length || S?.length || !m.trim() || (E(!0), i(m).then((J) => {
2126
+ J && H?.();
2127
+ }).finally(() => E(!1))), !1)
2128
+ }
2129
+ ) }) })
2130
+ ] })
2131
+ ] });
2132
+ }
2133
+ function Za(t, c) {
2134
+ if (!t || t.id !== c.threadId) return t;
2135
+ let b = !1;
2136
+ const l = t.runs.map((i) => i.id !== c.runId || (i.progress?.attempt ?? 0) > c.attempt ? i : (b = !0, {
2137
+ ...i,
2138
+ status: i.status === "queued" ? "running" : i.status,
2139
+ progress: {
2140
+ attempt: c.attempt,
2141
+ // The daemon stamps `receivedAt` with its own clock and `ThreadChat`
2142
+ // sorts it against daemon-written `post.at` / `run.startedAt`. Using the
2143
+ // browser clock here would order one transcript by two clocks, which a
2144
+ // remote daemon makes visible. `activityAt` is refreshed by the daemon
2145
+ // on exactly this frame, so it is the same instant on the same clock.
2146
+ receivedAt: c.activityAt,
2147
+ activityAt: c.activityAt,
2148
+ stage: c.stage,
2149
+ detail: c.detail,
2150
+ outputText: c.outputText,
2151
+ thoughtText: c.thoughtText,
2152
+ ...c.permission ? { permission: c.permission } : {},
2153
+ ...c.steps ? { steps: c.steps } : {}
2154
+ }
2155
+ }));
2156
+ return b ? { ...t, runs: l } : t;
2157
+ }
2158
+ const el = 250, tl = 1e3, nl = 150;
2159
+ function dl({
2160
+ initialView: t,
2161
+ initialThreadId: c,
2162
+ workspaceCwd: b,
2163
+ chat: l = !1,
2164
+ activityOnly: i = !1,
2165
+ onOpenActivity: d,
2166
+ headerActionsContainer: x,
2167
+ onTitleChange: o,
2168
+ onOpenThreadChat: h,
2169
+ onOpenAgentSession: L,
2170
+ onOpenDefinitions: q
2171
+ }) {
2172
+ const T = Dt(), O = zt(), [$, P] = _(), A = se(
2173
+ () => (T.capabilities?.workspaces ?? []).filter(
2174
+ (p) => rt(
2175
+ T.capabilities,
2176
+ p.cwd
2177
+ )
2178
+ ),
2179
+ [T.capabilities]
2180
+ ), v = b ?? $ ?? O.workspaceCwd ?? A.find((p) => p.primary)?.cwd ?? A[0]?.cwd, u = rt(
2181
+ T.capabilities,
2182
+ v
2183
+ ) ? v : b ? void 0 : A.find((p) => p.primary)?.cwd ?? A[0]?.cwd, f = se(
2184
+ () => u ? Zt(T.baseUrl, T.token, u) : void 0,
2185
+ [T.baseUrl, T.token, u]
2186
+ ), { t: E } = oe(), [B, U] = _([]), [W, z] = _([]), [y, re] = _(
2187
+ t === void 0 || t === "new-agent" ? "agents" : t
2188
+ ), [F, ge] = _(), [j, M] = _([]), [I, K] = _(c), [w, s] = _();
2189
+ he(() => {
2190
+ l && !i && w && o?.(w.id, w.title);
2191
+ }, [l, i, w, o]);
2192
+ const [ne, Z] = _(""), [_e, Y] = _(), [ee, ie] = _(), [de, me] = _(!1), [m, r] = _(t === "new-agent" ? {} : void 0), [S, H] = _(), [J, V] = _(), n = J ?? S, C = xe(ne);
2193
+ C.current = ne;
2194
+ const G = xe(void 0), Q = se(() => ({ client: f, openId: I }), [f, I]), te = xe(Q);
2195
+ te.current = Q;
2196
+ const fe = xe(0), ce = xe(0);
2197
+ he(() => {
2198
+ t && t !== "new-agent" && re(t);
2199
+ }, [t]);
2200
+ const pe = (p) => {
2201
+ K(p), s(void 0), Z(""), Y(void 0), V(void 0);
2202
+ }, ue = Le(async () => {
2203
+ if (!f) return;
2204
+ const p = ++fe.current;
2205
+ try {
2206
+ const [k, be, we] = await Promise.all([
2207
+ f.listAgents(),
2208
+ f.listThreads(),
2209
+ I ? f.getThread(I) : void 0
2210
+ ]);
2211
+ if (te.current !== Q || p < ce.current)
2212
+ return;
2213
+ ce.current = p, U(k.agents), z(
2214
+ k.runtimes ?? (k.runtime ? [k.runtime] : [])
2215
+ ), k.capabilities && ge(k.capabilities), M(be.threads), s(we), H(void 0);
2216
+ } catch (k) {
2217
+ if (te.current !== Q || p < ce.current)
2218
+ return;
2219
+ ce.current = p, H(k instanceof Error ? k.message : String(k));
2220
+ }
2221
+ }, [f, I, Q]), ae = xe(ue);
2222
+ ae.current = ue, he(() => {
2223
+ ue();
2224
+ }, [ue]), he(() => {
2225
+ if (!f) return;
2226
+ let p, k;
2227
+ const be = () => {
2228
+ p ??= setInterval(() => void ae.current(), tl);
2229
+ };
2230
+ if (!f.subscribe)
2231
+ return be(), () => clearInterval(p);
2232
+ const we = f.subscribe(
2233
+ (ye) => {
2234
+ if (ye.type === "progress") {
2235
+ s((St) => Za(St, ye));
2236
+ return;
2237
+ }
2238
+ k ??= setTimeout(() => {
2239
+ k = void 0, ae.current();
2240
+ }, nl);
2241
+ },
2242
+ (ye) => {
2243
+ if (ye === "closed") {
2244
+ be();
2245
+ return;
2246
+ }
2247
+ clearInterval(p), p = void 0;
2248
+ }
2249
+ );
2250
+ return () => {
2251
+ we(), clearInterval(p), clearTimeout(k);
2252
+ };
2253
+ }, [f]), he(() => {
2254
+ if (!f || !I || !ne.trim()) {
2255
+ Y(void 0);
2256
+ return;
2257
+ }
2258
+ const p = ne;
2259
+ let k = !1;
2260
+ const be = setTimeout(() => {
2261
+ f.previewReply(I, p).then((we) => {
2262
+ !k && C.current === p && Y(we.targets);
2263
+ }).catch(() => {
2264
+ k || Y(void 0);
2265
+ });
2266
+ }, el);
2267
+ return () => {
2268
+ k = !0, clearTimeout(be);
2269
+ };
2270
+ }, [f, ne, I]);
2271
+ const Te = Le(
2272
+ (p) => {
2273
+ G.current = p, ie(void 0), f && f.previewThread(p).then((k) => {
2274
+ G.current === p && ie(k.targets);
2275
+ }).catch(() => {
2276
+ G.current === p && ie(void 0);
2277
+ });
2278
+ },
2279
+ [f]
2280
+ ), le = Le(
2281
+ async (p) => {
2282
+ me(!0), V(void 0);
2283
+ try {
2284
+ const k = await p();
2285
+ await ue(), k !== null && typeof k == "object" && "dispatchError" in k && typeof k.dispatchError == "string" && V(
2286
+ E("collab.error.dispatchAfterSave", {
2287
+ error: k.dispatchError
2288
+ })
2289
+ );
2290
+ } catch (k) {
2291
+ return V(k instanceof Error ? k.message : String(k)), !1;
2292
+ } finally {
2293
+ me(!1);
2294
+ }
2295
+ return !0;
2296
+ },
2297
+ [ue, E]
2298
+ );
2299
+ if (!f)
2300
+ return /* @__PURE__ */ e("p", { role: "alert", children: E("collab.noWorkspace") });
2301
+ if (m)
2302
+ return /* @__PURE__ */ e(
2303
+ en,
2304
+ {
2305
+ initialScope: "workspace",
2306
+ workspaceCwd: u,
2307
+ executionHosts: W.filter((p) => p.kind === "external"),
2308
+ ...m.hostId ? { initialHostId: m.hostId } : {},
2309
+ onCancel: () => r(void 0),
2310
+ onCreated: () => r(void 0),
2311
+ onSaveWorkspaceAgent: async (p) => {
2312
+ await f.createAgent(p), await ue();
2313
+ }
2314
+ }
2315
+ );
2316
+ if (I && w?.id !== I)
2317
+ return /* @__PURE__ */ a("div", { className: "flex flex-col items-start gap-2 p-4", children: [
2318
+ l ? null : /* @__PURE__ */ a(R, { variant: "ghost", size: "sm", onClick: () => pe(), children: [
2319
+ /* @__PURE__ */ e(gt, { "data-icon": "inline-start" }),
2320
+ E("collab.thread.back")
2321
+ ] }),
2322
+ /* @__PURE__ */ e("p", { role: "status", className: "text-sm text-muted-foreground", children: n ?? E("collab.thread.loading") })
2323
+ ] });
2324
+ const { createShare: Ye, listShares: Ze, revokeShare: et, removeHost: tt } = f, nt = Ye && Ze && et ? {
2325
+ create: Ye,
2326
+ list: async (p) => (await Ze(p)).shares,
2327
+ revoke: et
2328
+ } : void 0;
2329
+ return I && w ? /* @__PURE__ */ a(Ne, { children: [
2330
+ n && /* @__PURE__ */ e("p", { role: "alert", className: "px-4 py-2 text-sm text-destructive", children: n }),
2331
+ /* @__PURE__ */ e(
2332
+ Ya,
2333
+ {
2334
+ activityOnly: i,
2335
+ headerActionsContainer: x,
2336
+ ...l ? {} : { onBack: () => pe() },
2337
+ onOpenActivity: d && u ? () => d(w.id, u) : void 0,
2338
+ thread: w,
2339
+ agents: B,
2340
+ preview: _e,
2341
+ pending: de,
2342
+ onDraftChange: Z,
2343
+ onAssign: (p) => void le(() => f.assignThread(I, p)),
2344
+ onOpenAgentSession: L,
2345
+ onCancelRun: (p) => void le(() => f.cancelRun(I, p)),
2346
+ onMarkDone: () => void le(() => f.markDone(I)),
2347
+ ...f.respondToPermission ? {
2348
+ onRespondPermission: (p, k, be) => le(
2349
+ () => f.respondToPermission(p, k, be)
2350
+ )
2351
+ } : {},
2352
+ onOpenThread: (p) => {
2353
+ u && h ? h(p, u) : pe(p);
2354
+ },
2355
+ onSend: (p) => le(async () => {
2356
+ const k = await f.postReply(I, p);
2357
+ return Z(""), Y(void 0), k;
2358
+ })
2359
+ },
2360
+ w.id
2361
+ )
2362
+ ] }) : /* @__PURE__ */ a(Ne, { children: [
2363
+ n ? /* @__PURE__ */ e("p", { role: "alert", className: "mb-3 text-sm text-destructive", children: n }) : null,
2364
+ /* @__PURE__ */ e(
2365
+ Qn,
2366
+ {
2367
+ agents: B,
2368
+ threads: j,
2369
+ view: y,
2370
+ onViewChange: re,
2371
+ runtimes: W,
2372
+ onConnectRemoteHost: f.connectRemoteHost ? (p) => le(() => f.connectRemoteHost(p)) : void 0,
2373
+ createPreview: ee,
2374
+ pending: de,
2375
+ onOpenThread: (p) => {
2376
+ u && h ? h(p, u) : pe(p);
2377
+ },
2378
+ onDeleteAgent: (p) => void le(() => f.deleteAgent(p)),
2379
+ onSetAgentEnabled: (p, k) => void le(() => f.setAgentEnabled(p, k)),
2380
+ onUpdateAgent: (p, k) => void le(() => f.updateAgent(p, k)),
2381
+ onOpenAgentBuilder: (p) => r({ hostId: p }),
2382
+ ...f.createJoinToken ? { onCreateJoinToken: f.createJoinToken } : {},
2383
+ ...tt ? {
2384
+ onRemoveRuntime: (p) => void le(() => tt(p))
2385
+ } : {},
2386
+ ...nt ? { shares: nt } : {},
2387
+ ...q ? { onOpenDefinitions: q } : {},
2388
+ ...F ? { capabilities: F } : {},
2389
+ workspaceCwd: u,
2390
+ hostServerUrl: T.baseUrl,
2391
+ workspaces: A,
2392
+ onWorkspaceChange: (p) => {
2393
+ P(p), U([]), ie(void 0), G.current = void 0;
2394
+ },
2395
+ createError: n,
2396
+ onCreateThread: (p) => le(async () => {
2397
+ const k = await f.createThread(p);
2398
+ return ie(void 0), pe(k.id), u && h?.(k.id, u), k;
2399
+ }),
2400
+ onPreviewThread: Te
2401
+ }
2402
+ )
2403
+ ] });
2404
+ }
2405
+ export {
2406
+ dl as ThreadsRoute
2407
+ };