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