@qwen-code/web-shell 0.24.6 → 0.24.7-nightly.20260930.57e720bc97

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 (65) hide show
  1. package/README.md +10 -0
  2. package/dist/ThreadsRoute-B5WfAa5o.js +1896 -0
  3. package/dist/daemon-react-sdk.js +1 -1
  4. package/dist/index-BAkajV4Z.js +121676 -0
  5. package/dist/index.js +69 -118171
  6. package/dist/sw.js +1 -1
  7. package/dist/{toolNames-C6S4xtsA.js → toolNames-DHN3_HCf.js} +5591 -4691
  8. package/dist/transcript.js +9483 -9267
  9. package/dist/types/adapters/messageTypes.d.ts +11 -0
  10. package/dist/types/components/BranchPickerPopover.d.ts +2 -1
  11. package/dist/types/components/ChatEditor.d.ts +1 -0
  12. package/dist/types/components/DesktopRelayControl.d.ts +51 -0
  13. package/dist/types/components/MessageList.d.ts +1 -0
  14. package/dist/types/components/agents/AgentCreatePage.d.ts +10 -1
  15. package/dist/types/components/agents/AgentsManagerPage.d.ts +5 -1
  16. package/dist/types/components/artifacts/ArtifactPanel.d.ts +8 -1
  17. package/dist/types/components/artifacts/TrajectoryInspector.d.ts +17 -0
  18. package/dist/types/components/artifacts/TrajectoryOverview.d.ts +3 -1
  19. package/dist/types/components/artifacts/TrajectoryWaterfallCell.d.ts +15 -0
  20. package/dist/types/components/composer/AddMenu.d.ts +5 -1
  21. package/dist/types/components/dialogs/BranchSessionDialog.d.ts +6 -0
  22. package/dist/types/components/dialogs/GitDiffDialog.d.ts +2 -1
  23. package/dist/types/components/dialogs/GitLogDialog.d.ts +2 -1
  24. package/dist/types/components/managed/WorkspaceBindingCreator.d.ts +6 -0
  25. package/dist/types/components/managed/generated/managed-agent-api.d.ts +1346 -0
  26. package/dist/types/components/managed/java-managed-agent-client.d.ts +32 -113
  27. package/dist/types/components/managed/java-managed-agent-provider.d.ts +1 -0
  28. package/dist/types/components/managed/managed-agent-provider.d.ts +31 -1
  29. package/dist/types/components/messages/AssistantMessage.d.ts +3 -0
  30. package/dist/types/components/messages/AuthorAvatar.d.ts +16 -0
  31. package/dist/types/components/messages/ContextUsageMessage.d.ts +5 -1
  32. package/dist/types/components/messages/McpApp.d.ts +1 -1
  33. package/dist/types/components/messages/StatsMessage.d.ts +6 -1
  34. package/dist/types/components/messages/toolFormatting.d.ts +2 -0
  35. package/dist/types/components/panels/EnvironmentPanel.d.ts +2 -1
  36. package/dist/types/components/sidebar/UpdateControl.d.ts +10 -0
  37. package/dist/types/components/sidebar/WebShellSidebar.d.ts +6 -3
  38. package/dist/types/components/sidebar/WorkspaceSection.d.ts +2 -1
  39. package/dist/types/components/sidebar/sessionSearch.d.ts +2 -1
  40. package/dist/types/components/workspace-agents/LazyThreadsRoute.d.ts +7 -0
  41. package/dist/types/components/workspace-agents/ThreadChat.d.ts +30 -0
  42. package/dist/types/components/workspace-agents/ThreadView.d.ts +65 -0
  43. package/dist/types/components/workspace-agents/ThreadsPage.d.ts +104 -0
  44. package/dist/types/components/workspace-agents/ThreadsRoute.d.ts +23 -0
  45. package/dist/types/components/workspace-agents/agent-events.d.ts +50 -0
  46. package/dist/types/components/workspace-agents/agents-view-logic.d.ts +176 -0
  47. package/dist/types/components/workspace-agents/messages.d.ts +16 -0
  48. package/dist/types/components/workspace-agents/messages.transcript-stub.d.ts +12 -0
  49. package/dist/types/components/workspace-agents/share-agent-dialog.d.ts +33 -0
  50. package/dist/types/components/workspace-agents/threads-api.d.ts +49 -0
  51. package/dist/types/components/workspace-agents/useAgentChatEntry.d.ts +36 -0
  52. package/dist/types/components/workspace-agents/useProjectConversations.d.ts +10 -0
  53. package/dist/types/customization.d.ts +10 -0
  54. package/dist/types/daemon/session/transcript-page-table.d.ts +10 -1
  55. package/dist/types/daemon/session/types.d.ts +2 -2
  56. package/dist/types/desktop-relay/desktop-relay-client.d.ts +63 -0
  57. package/dist/types/mcpAppHostContext.d.ts +7 -0
  58. package/dist/types/settings/messages.d.ts +16 -0
  59. package/dist/types/settings/messages.transcript-stub.d.ts +12 -0
  60. package/dist/types/settings.d.ts +1 -0
  61. package/dist/types/trajectory/buildTrajectoryLayout.d.ts +27 -0
  62. package/dist/types/trajectory/summarizeTrajectory.d.ts +20 -0
  63. package/dist/types/trajectory/types.d.ts +2 -1
  64. package/dist/types/trajectory/useTimelineViewport.d.ts +19 -0
  65. package/package.json +3 -1
@@ -0,0 +1,1896 @@
1
+ import { jsx as e, jsxs as n, Fragment as xe } from "react/jsx-runtime";
2
+ import { useState as x, useRef as de, useEffect as se, useMemo as le, useContext as dt, createContext as mt, useCallback as Ce } from "react";
3
+ import { CopyIcon as ut, PlusIcon as Se, MoreHorizontalIcon as Xe, MessagesSquareIcon as gt, ChevronRightIcon as Je, Check as we, UsersRound as We, ArrowLeftIcon as Qe, LoaderCircle as Pe, X as pt } from "lucide-react";
4
+ import { W as ae, T as ht, m as bt } from "./toolNames-DHN3_HCf.js";
5
+ import "@qwen-code/sdk/daemon";
6
+ import { D as Ye, a as Ze, b as et, c as tt, d as at, B as C, e as ft, w as _t, f as vt, g as Nt, T as xt, h as wt, s as yt, i as Le, E as Oe, j as je, k as Fe, l as Ue, C as kt, A as he, m as Tt, n as Ve, o as Ct, p as Ie, q as $e, r as De, t as me, u as nt, v as St, x as ye, y as At, z as be, M as Rt, F as Lt, G as It, H as He, I as Ae, J as $t, K as T, W as Ge, L as Dt, N as Ht, O as Et, P as zt, Q as qt, R as Bt } from "./index-BAkajV4Z.js";
7
+ import { createPortal as Mt } from "react-dom";
8
+ const Wt = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
9
+ function Pt(t) {
10
+ try {
11
+ return Wt.has(new URL(t).hostname);
12
+ } catch {
13
+ return !1;
14
+ }
15
+ }
16
+ function Ot(t) {
17
+ const d = JSON.stringify({
18
+ jsonrpc: "2.0",
19
+ id: 1,
20
+ method: "SendMessage",
21
+ params: {
22
+ message: {
23
+ role: "ROLE_USER",
24
+ messageId: "hello-1",
25
+ parts: [{ text: "Hello! What can you help with?" }]
26
+ }
27
+ }
28
+ });
29
+ return [
30
+ `curl -s ${t.endpoint}`,
31
+ "-H 'A2A-Version: 1.0'",
32
+ `-H 'Authorization: Bearer ${t.secret}'`,
33
+ `-H 'x-qwen-workspace-id: ${t.workspaceId}'`,
34
+ `-H 'x-qwen-caller-id: ${t.callerId}'`,
35
+ `-H 'x-qwen-agent-id: ${t.agentId}'`,
36
+ "-H 'content-type: application/json'",
37
+ `-d '${d}'`
38
+ ].join(" ");
39
+ }
40
+ function Re({ label: t, text: d }) {
41
+ const { t: r } = ae(), [u, l] = x(!1);
42
+ return /* @__PURE__ */ n("div", { className: "flex flex-col gap-1.5 text-sm", children: [
43
+ /* @__PURE__ */ e("span", { className: "font-medium", children: t }),
44
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-2 rounded-md border border-border bg-muted/40 py-1.5 pr-1.5 pl-3", children: [
45
+ /* @__PURE__ */ e("code", { className: "min-w-0 flex-1 truncate font-mono text-xs", children: d }),
46
+ /* @__PURE__ */ n(
47
+ C,
48
+ {
49
+ size: "sm",
50
+ variant: "outline",
51
+ onClick: () => void _t(d).then(
52
+ () => l(!0),
53
+ (_) => vt(_)
54
+ ),
55
+ children: [
56
+ /* @__PURE__ */ e(ut, { "aria-hidden": "true" }),
57
+ r(u ? "collab.share.copied" : "collab.share.copy")
58
+ ]
59
+ }
60
+ )
61
+ ] })
62
+ ] });
63
+ }
64
+ function jt({
65
+ agentName: t,
66
+ open: d,
67
+ onOpenChange: r,
68
+ onCreate: u,
69
+ onList: l,
70
+ onRevoke: _
71
+ }) {
72
+ const { t: m } = ae(), [g, I] = x(), [H, R] = x([]), [k, M] = x(), [E, W] = x(!1), y = de(l);
73
+ y.current = l, se(() => {
74
+ d && (I(void 0), M(void 0), y.current().then(R, () => R([])));
75
+ }, [d]);
76
+ const o = async (p) => {
77
+ W(!0), M(void 0);
78
+ try {
79
+ await p(), R(await y.current());
80
+ } catch (P) {
81
+ M(P instanceof Error ? P.message : String(P));
82
+ } finally {
83
+ W(!1);
84
+ }
85
+ };
86
+ return /* @__PURE__ */ e(Ye, { open: d, onOpenChange: r, children: /* @__PURE__ */ n(Ze, { className: "grid-cols-[minmax(0,1fr)] sm:max-w-xl", children: [
87
+ /* @__PURE__ */ n(et, { children: [
88
+ /* @__PURE__ */ e(tt, { children: m("collab.share.title", { name: t }) }),
89
+ /* @__PURE__ */ e(at, { children: m("collab.share.description") })
90
+ ] }),
91
+ g && /* @__PURE__ */ n("div", { className: "flex flex-col gap-3", children: [
92
+ /* @__PURE__ */ e(
93
+ Re,
94
+ {
95
+ label: m("collab.share.endpoint"),
96
+ text: g.endpoint
97
+ }
98
+ ),
99
+ /* @__PURE__ */ e(Re, { label: m("collab.share.token"), text: g.secret }),
100
+ /* @__PURE__ */ e(Re, { label: m("collab.share.try"), text: Ot(g) }),
101
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: g.expiresAt ? m("collab.share.onceUntil", {
102
+ date: new Date(g.expiresAt).toLocaleDateString()
103
+ }) : m("collab.share.once") }),
104
+ Pt(g.endpoint) && /* @__PURE__ */ e("p", { role: "alert", className: "text-xs text-destructive", children: m("collab.share.loopback") })
105
+ ] }),
106
+ H.length > 0 && /* @__PURE__ */ n("div", { className: "flex flex-col gap-1 text-sm", children: [
107
+ /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground", children: m("collab.share.active", { count: H.length }) }),
108
+ H.map((p) => /* @__PURE__ */ n(
109
+ "div",
110
+ {
111
+ className: "flex items-center gap-2 rounded-md px-2 py-1 hover:bg-muted",
112
+ children: [
113
+ /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate", children: [
114
+ p.callerId,
115
+ /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-muted-foreground", children: p.expiresAt ? m("collab.share.until", {
116
+ date: new Date(p.expiresAt).toLocaleDateString()
117
+ }) : "" })
118
+ ] }),
119
+ /* @__PURE__ */ e(
120
+ C,
121
+ {
122
+ size: "sm",
123
+ variant: "ghost",
124
+ disabled: E,
125
+ onClick: () => void o(() => _(p.callerId)),
126
+ children: m("collab.share.revoke")
127
+ }
128
+ )
129
+ ]
130
+ },
131
+ p.callerId
132
+ ))
133
+ ] }),
134
+ k && /* @__PURE__ */ e("p", { role: "alert", className: "text-sm text-destructive", children: k }),
135
+ /* @__PURE__ */ e(ft, { children: g ? /* @__PURE__ */ e(C, { onClick: () => r(!1), children: m("collab.share.done") }) : /* @__PURE__ */ e(
136
+ C,
137
+ {
138
+ disabled: E,
139
+ onClick: () => void o(async () => I(await u())),
140
+ children: m("collab.share.create")
141
+ }
142
+ ) })
143
+ ] }) });
144
+ }
145
+ const Ft = "_formActions_i822m_4", Ut = "_field_i822m_11", Vt = "_roster_i822m_33", Gt = "_agentCard_i822m_39", Kt = "_agentRow_i822m_44", Xt = "_agentRowDisabled_i822m_51", Jt = "_agentMain_i822m_55", Qt = "_agentTitleLine_i822m_63", Yt = "_agentName_i822m_70", Zt = "_statusBadge_i822m_89", ea = "_agentActivityLink_i822m_104", ta = "_agentActions_i822m_126", aa = "_emptyRoster_i822m_133", na = "_agentConfig_i822m_141", sa = "_agentWorkspace_i822m_142", la = "_agentWorkspaceHeader_i822m_154", ra = "_configLabel_i822m_169", oa = "_configNote_i822m_176", ia = "_ceiling_i822m_184", ca = "_ceilingTitle_i822m_193", da = "_ceilingText_i822m_200", ma = "_ceilingTools_i822m_208", ua = "_group_i822m_217", ga = "_groupHeading_i822m_225", pa = "_groupHeadingToggle_i822m_241", ha = "_groupCount_i822m_249", ba = "_list_i822m_256", fa = "_row_i822m_265", _a = "_rowText_i822m_291", va = "_rowTitle_i822m_299", Na = "_rowReason_i822m_310", xa = "_rowChevron_i822m_326", f = {
146
+ formActions: Ft,
147
+ field: Ut,
148
+ roster: Vt,
149
+ agentCard: Gt,
150
+ agentRow: Kt,
151
+ agentRowDisabled: Xt,
152
+ agentMain: Jt,
153
+ agentTitleLine: Qt,
154
+ agentName: Yt,
155
+ statusBadge: Zt,
156
+ agentActivityLink: ea,
157
+ agentActions: ta,
158
+ emptyRoster: aa,
159
+ agentConfig: na,
160
+ agentWorkspace: sa,
161
+ agentWorkspaceHeader: la,
162
+ configLabel: ra,
163
+ configNote: oa,
164
+ ceiling: ia,
165
+ ceilingTitle: ca,
166
+ ceilingText: da,
167
+ ceilingTools: ma,
168
+ group: ua,
169
+ groupHeading: ga,
170
+ groupHeadingToggle: pa,
171
+ groupCount: ha,
172
+ list: ba,
173
+ row: fa,
174
+ rowText: _a,
175
+ rowTitle: va,
176
+ rowReason: Na,
177
+ rowChevron: xa
178
+ }, wa = /* @__PURE__ */ new Set([
179
+ "idle",
180
+ "working",
181
+ "blocked",
182
+ "offline",
183
+ "error",
184
+ "finishing",
185
+ "stopping"
186
+ ]);
187
+ function st({
188
+ thread: t,
189
+ onOpen: d
190
+ }) {
191
+ const { t: r } = ae();
192
+ return /* @__PURE__ */ n(
193
+ "button",
194
+ {
195
+ type: "button",
196
+ className: f.row,
197
+ "data-attention": At(t) || void 0,
198
+ onClick: () => d(t.id),
199
+ children: [
200
+ /* @__PURE__ */ n("span", { className: f.rowText, children: [
201
+ /* @__PURE__ */ e("span", { className: f.rowTitle, children: t.title }),
202
+ /* @__PURE__ */ e("span", { className: f.rowReason, children: ye(t.reason, r) })
203
+ ] }),
204
+ /* @__PURE__ */ e(Je, { "aria-hidden": "true", className: f.rowChevron })
205
+ ]
206
+ }
207
+ );
208
+ }
209
+ function ya({
210
+ group: t,
211
+ onOpenThread: d,
212
+ hidden: r
213
+ }) {
214
+ const { t: u } = ae(), [l, _] = x(t.collapsedByDefault), m = t.collapsedByDefault;
215
+ return /* @__PURE__ */ n("section", { className: f.group, hidden: r, children: [
216
+ /* @__PURE__ */ n(
217
+ "button",
218
+ {
219
+ type: "button",
220
+ className: m ? `${f.groupHeading} ${f.groupHeadingToggle}` : f.groupHeading,
221
+ onClick: m ? () => _((g) => !g) : void 0,
222
+ "aria-expanded": m ? !l : void 0,
223
+ disabled: !m,
224
+ children: [
225
+ u(`collab.group.${t.key}`),
226
+ /* @__PURE__ */ e("span", { className: f.groupCount, children: t.threads.length })
227
+ ]
228
+ }
229
+ ),
230
+ !l && /* @__PURE__ */ e("div", { className: f.list, children: t.threads.map((g) => /* @__PURE__ */ e(st, { thread: g, onOpen: d }, g.id)) })
231
+ ] });
232
+ }
233
+ function ka({
234
+ agents: t,
235
+ threads: d,
236
+ view: r,
237
+ onViewChange: u,
238
+ onOpenThread: l,
239
+ onDeleteAgent: _,
240
+ onSetAgentEnabled: m,
241
+ onUpdateAgent: g,
242
+ onOpenAgentBuilder: I,
243
+ onOpenDefinitions: H,
244
+ shares: R,
245
+ capabilities: k,
246
+ onCreateThread: M,
247
+ workspaceCwd: E,
248
+ workspaces: W,
249
+ onWorkspaceChange: y,
250
+ createError: o,
251
+ onPreviewThread: p,
252
+ createPreview: P,
253
+ pending: $
254
+ }) {
255
+ const U = le(() => Nt(d), [d]), [X, z] = x(), [V, Y] = x(), [re, L] = x(), { t: i } = ae(), [S, G] = x(), [K, O] = x(""), oe = (a) => wa.has(a) ? i(`collab.agentStatus.${a}`) : a, Z = (a) => (w) => {
256
+ if (w.preventDefault(), !g) return;
257
+ const j = new FormData(w.currentTarget), F = (ie) => {
258
+ const c = String(j.get(ie) ?? "").trim();
259
+ return c === "" ? null : c;
260
+ }, Q = String(j.get("maxConcurrentRuns") ?? "").trim();
261
+ g(a, {
262
+ description: F("description"),
263
+ model: F("model"),
264
+ agentType: F("agentType"),
265
+ instructions: F("instructions"),
266
+ maxConcurrentRuns: Q === "" ? null : Number(Q)
267
+ }), Y(void 0);
268
+ }, ue = async (a) => {
269
+ a.preventDefault();
270
+ const w = new FormData(a.currentTarget), j = String(w.get("assignee") ?? ""), F = String(
271
+ w.get("acceptanceCriteria") ?? ""
272
+ ).trim(), Q = String(w.get("priority") ?? "");
273
+ await M({
274
+ title: String(w.get("title") ?? "").trim(),
275
+ body: String(w.get("body") ?? "").trim(),
276
+ // Left out when blank or ordinary, so the thread records a decision
277
+ // only where one was made.
278
+ ...F ? { acceptanceCriteria: F } : {},
279
+ ...Q && Q !== "normal" ? { priority: Q } : {},
280
+ ...j ? { assignee: j } : {}
281
+ }) !== !1 && (p?.(void 0), z(void 0));
282
+ }, J = (a) => {
283
+ u(a), z(void 0), Y(void 0), L(void 0), p?.(void 0);
284
+ };
285
+ return /* @__PURE__ */ n("div", { className: "flex w-full flex-col gap-6", children: [
286
+ /* @__PURE__ */ n("div", { className: "flex items-start justify-between gap-4", children: [
287
+ /* @__PURE__ */ n("div", { className: "min-w-0", children: [
288
+ /* @__PURE__ */ e("h1", { className: "text-xl font-semibold text-balance", children: i("agents.title") }),
289
+ /* @__PURE__ */ e("p", { className: "mt-1 text-sm text-muted-foreground", children: i(`collab.tabs.${r}Hint`) })
290
+ ] }),
291
+ /* @__PURE__ */ n("div", { className: "flex shrink-0 gap-2", children: [
292
+ r === "agents" && H ? /* @__PURE__ */ e(C, { variant: "outline", onClick: H, children: i("collab.agent.roles") }) : null,
293
+ r === "agents" && I ? /* @__PURE__ */ n(C, { onClick: () => I(), children: [
294
+ /* @__PURE__ */ e(Se, { "data-icon": "inline-start" }),
295
+ i("collab.agent.new")
296
+ ] }) : null,
297
+ r === "tasks" ? /* @__PURE__ */ n(
298
+ C,
299
+ {
300
+ onClick: () => {
301
+ z("thread"), O(""), p?.(void 0);
302
+ },
303
+ children: [
304
+ /* @__PURE__ */ e(Se, { "data-icon": "inline-start" }),
305
+ i("collab.thread.new")
306
+ ]
307
+ }
308
+ ) : null
309
+ ] })
310
+ ] }),
311
+ /* @__PURE__ */ e(
312
+ xt,
313
+ {
314
+ type: "single",
315
+ value: r,
316
+ onValueChange: (a) => {
317
+ a && J(a);
318
+ },
319
+ variant: "outline",
320
+ size: "sm",
321
+ "aria-label": i("agents.title"),
322
+ children: ["agents", "tasks"].map((a) => /* @__PURE__ */ e(wt, { value: a, children: i(`collab.tabs.${a}`) }, a))
323
+ }
324
+ ),
325
+ /* @__PURE__ */ n("div", { className: "contents", children: [
326
+ /* @__PURE__ */ e(
327
+ Ye,
328
+ {
329
+ open: r === "tasks" && X === "thread",
330
+ onOpenChange: (a) => {
331
+ !a && !$ && z(void 0);
332
+ },
333
+ children: /* @__PURE__ */ n(Ze, { className: "sm:max-w-2xl", children: [
334
+ /* @__PURE__ */ n(et, { children: [
335
+ /* @__PURE__ */ e(tt, { children: i("collab.thread.new") }),
336
+ /* @__PURE__ */ e(at, { children: i("collab.thread.newHint") })
337
+ ] }),
338
+ /* @__PURE__ */ n(
339
+ "form",
340
+ {
341
+ className: "flex flex-col gap-4",
342
+ onSubmit: (a) => void ue(a),
343
+ children: [
344
+ o && /* @__PURE__ */ e("p", { role: "alert", className: "text-sm text-destructive", children: o }),
345
+ /* @__PURE__ */ n("label", { className: "text-xs text-muted-foreground", children: [
346
+ i("collab.form.project"),
347
+ /* @__PURE__ */ n(
348
+ "select",
349
+ {
350
+ className: f.field,
351
+ value: E ?? "",
352
+ disabled: $,
353
+ onChange: (a) => {
354
+ O(""), y?.(a.target.value);
355
+ },
356
+ children: [
357
+ E && !W?.some(
358
+ (a) => a.cwd === E
359
+ ) && /* @__PURE__ */ e("option", { value: E, children: E.split(/[\\/]/).filter(Boolean).at(-1) }),
360
+ W?.map((a) => /* @__PURE__ */ e("option", { value: a.cwd, children: a.cwd.split(/[\\/]/).filter(Boolean).at(-1) }, a.cwd))
361
+ ]
362
+ }
363
+ )
364
+ ] }),
365
+ /* @__PURE__ */ n("p", { className: "text-xs text-muted-foreground", children: [
366
+ /* @__PURE__ */ e("span", { className: "block break-all", children: E }),
367
+ i("collab.form.projectHint")
368
+ ] }),
369
+ /* @__PURE__ */ e(
370
+ "input",
371
+ {
372
+ className: "w-full border-0 bg-transparent text-xl font-medium outline-none",
373
+ name: "title",
374
+ "aria-label": i("collab.form.titleLabel"),
375
+ placeholder: i("collab.form.title"),
376
+ required: !0
377
+ }
378
+ ),
379
+ /* @__PURE__ */ e(
380
+ "textarea",
381
+ {
382
+ className: f.field,
383
+ name: "body",
384
+ "aria-label": i("collab.form.bodyLabel"),
385
+ rows: 6,
386
+ placeholder: i("collab.form.body"),
387
+ required: !0
388
+ }
389
+ ),
390
+ /* @__PURE__ */ e(
391
+ "textarea",
392
+ {
393
+ className: f.field,
394
+ name: "acceptanceCriteria",
395
+ "aria-label": i("collab.form.criteriaLabel"),
396
+ placeholder: i("collab.form.criteria")
397
+ }
398
+ ),
399
+ /* @__PURE__ */ e(
400
+ "select",
401
+ {
402
+ className: f.field,
403
+ name: "priority",
404
+ "aria-label": i("collab.form.priority"),
405
+ defaultValue: "normal",
406
+ children: ["urgent", "high", "normal", "low"].map((a) => /* @__PURE__ */ e("option", { value: a, children: i(`collab.priority.${a}`) }, a))
407
+ }
408
+ ),
409
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: i("collab.form.priorityHint") }),
410
+ /* @__PURE__ */ n(
411
+ "select",
412
+ {
413
+ className: f.field,
414
+ name: "assignee",
415
+ "aria-label": i("collab.form.assignee"),
416
+ defaultValue: K,
417
+ onChange: (a) => {
418
+ O(a.target.value), p?.(a.target.value || void 0);
419
+ },
420
+ children: [
421
+ /* @__PURE__ */ e("option", { value: "", children: i("collab.form.noAssignee") }),
422
+ t.filter((a) => a.enabled && !a.retiredAt).map((a) => /* @__PURE__ */ e("option", { value: a.name, children: a.name }, a.id))
423
+ ]
424
+ },
425
+ E
426
+ ),
427
+ !K && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: i("collab.form.noAssigneeHint") }),
428
+ P ? /* @__PURE__ */ n(
429
+ "div",
430
+ {
431
+ role: "status",
432
+ className: "space-y-1 text-xs text-muted-foreground",
433
+ children: [
434
+ /* @__PURE__ */ e("strong", { children: K ? yt(P, i) : i("collab.form.saveOnly") }),
435
+ P.filter((a) => !a.willWake).map((a) => {
436
+ const w = Le(
437
+ a.reason ?? "",
438
+ a.agentName,
439
+ i
440
+ );
441
+ return /* @__PURE__ */ e(
442
+ "p",
443
+ {
444
+ children: w
445
+ },
446
+ `${a.agentName}:${a.reason ?? "unknown"}`
447
+ );
448
+ })
449
+ ]
450
+ }
451
+ ) : null,
452
+ /* @__PURE__ */ n("div", { className: f.formActions, children: [
453
+ /* @__PURE__ */ e(
454
+ C,
455
+ {
456
+ type: "button",
457
+ variant: "ghost",
458
+ size: "sm",
459
+ onClick: () => {
460
+ z(void 0), p?.(void 0);
461
+ },
462
+ children: i("collab.form.cancel")
463
+ }
464
+ ),
465
+ /* @__PURE__ */ e(C, { type: "submit", size: "sm", disabled: $, children: i($ ? "collab.form.creating" : "collab.form.create") })
466
+ ] })
467
+ ]
468
+ }
469
+ )
470
+ ] })
471
+ }
472
+ ),
473
+ /* @__PURE__ */ n("section", { className: f.roster, hidden: r !== "agents", children: [
474
+ t.length === 0 ? /* @__PURE__ */ e(Oe, { className: "border", children: /* @__PURE__ */ n(je, { children: [
475
+ /* @__PURE__ */ e(Fe, { variant: "icon", children: /* @__PURE__ */ e(Se, {}) }),
476
+ /* @__PURE__ */ e(Ue, { children: i("collab.agent.empty") })
477
+ ] }) }) : t.map((a) => /* @__PURE__ */ n(
478
+ kt,
479
+ {
480
+ size: "sm",
481
+ className: a.enabled && !a.retiredAt ? f.agentCard : `${f.agentCard} ${f.agentRowDisabled}`,
482
+ children: [
483
+ /* @__PURE__ */ n("div", { className: f.agentRow, children: [
484
+ /* @__PURE__ */ e(
485
+ he,
486
+ {
487
+ name: a.name,
488
+ color: a.color,
489
+ size: "md"
490
+ }
491
+ ),
492
+ /* @__PURE__ */ n("div", { className: f.agentMain, children: [
493
+ /* @__PURE__ */ n("div", { className: f.agentTitleLine, children: [
494
+ /* @__PURE__ */ e(Tt, { className: "min-w-0 truncate", children: /* @__PURE__ */ e(
495
+ "button",
496
+ {
497
+ type: "button",
498
+ className: f.agentName,
499
+ "aria-expanded": re === a.id,
500
+ onClick: () => L(
501
+ re === a.id ? void 0 : a.id
502
+ ),
503
+ children: a.name
504
+ }
505
+ ) }),
506
+ /* @__PURE__ */ e(
507
+ Ve,
508
+ {
509
+ variant: "secondary",
510
+ className: f.statusBadge,
511
+ "data-status": a.retiredAt || !a.enabled ? "off" : a.workingOn ? "working" : a.status,
512
+ children: a.retiredAt ? i("collab.agentStatus.retired") : a.enabled ? a.workingOn ? oe(a.workingOn.state) : oe(a.status) : i("collab.agentStatus.paused")
513
+ }
514
+ ),
515
+ a.waiting ? /* @__PURE__ */ e(Ve, { variant: "outline", className: "text-[10px]", children: i("collab.agent.waiting", { count: a.waiting }) }) : null
516
+ ] }),
517
+ /* @__PURE__ */ e(Ct, { className: "truncate text-xs", children: a.description || "—" }),
518
+ a.workingOn ? /* @__PURE__ */ e(
519
+ "button",
520
+ {
521
+ type: "button",
522
+ className: f.agentActivityLink,
523
+ onClick: () => l(a.workingOn.id),
524
+ children: i("collab.agent.workingOn", {
525
+ title: a.workingOn.title
526
+ })
527
+ }
528
+ ) : null
529
+ ] }),
530
+ a.retiredAt ? null : /* @__PURE__ */ n("div", { className: f.agentActions, children: [
531
+ /* @__PURE__ */ e(
532
+ C,
533
+ {
534
+ variant: "outline",
535
+ size: "sm",
536
+ disabled: !a.enabled || $,
537
+ onClick: () => {
538
+ J("tasks"), O(a.name), z("thread"), p?.(a.name);
539
+ },
540
+ children: i("collab.agent.mentionIt")
541
+ }
542
+ ),
543
+ /* @__PURE__ */ n(Ie, { children: [
544
+ /* @__PURE__ */ e($e, { asChild: !0, children: /* @__PURE__ */ e(
545
+ C,
546
+ {
547
+ variant: "ghost",
548
+ size: "icon-sm",
549
+ "aria-label": i("collab.agent.more", {
550
+ name: a.name
551
+ }),
552
+ children: /* @__PURE__ */ e(Xe, { "aria-hidden": "true" })
553
+ }
554
+ ) }),
555
+ /* @__PURE__ */ n(De, { align: "end", className: "min-w-40", children: [
556
+ g ? /* @__PURE__ */ e(
557
+ me,
558
+ {
559
+ onSelect: () => Y(a.id),
560
+ children: i("collab.agent.configure")
561
+ }
562
+ ) : null,
563
+ R ? /* @__PURE__ */ e(
564
+ me,
565
+ {
566
+ onSelect: () => G({ id: a.id, name: a.name }),
567
+ children: i("collab.agent.share")
568
+ }
569
+ ) : null,
570
+ /* @__PURE__ */ e(
571
+ me,
572
+ {
573
+ disabled: $,
574
+ onSelect: () => m(a.id, !a.enabled),
575
+ children: a.enabled ? i("collab.agent.pause") : i("collab.agent.resume")
576
+ }
577
+ ),
578
+ /* @__PURE__ */ e(nt, {}),
579
+ /* @__PURE__ */ e(
580
+ me,
581
+ {
582
+ variant: "destructive",
583
+ disabled: !!(a.workingOn || a.waiting),
584
+ onSelect: () => {
585
+ window.confirm(
586
+ i("collab.agent.retireConfirm", {
587
+ name: a.name
588
+ })
589
+ ) && _(a.id);
590
+ },
591
+ children: i("collab.agent.retire")
592
+ }
593
+ )
594
+ ] })
595
+ ] })
596
+ ] })
597
+ ] }),
598
+ V === a.id && g ? /* @__PURE__ */ n(
599
+ "form",
600
+ {
601
+ className: f.agentConfig,
602
+ onSubmit: Z(a.id),
603
+ children: [
604
+ /* @__PURE__ */ n("label", { className: f.configLabel, children: [
605
+ i("collab.config.description"),
606
+ /* @__PURE__ */ e(
607
+ "input",
608
+ {
609
+ className: f.field,
610
+ name: "description",
611
+ defaultValue: a.description ?? "",
612
+ placeholder: i("collab.config.descriptionHint")
613
+ }
614
+ )
615
+ ] }),
616
+ /* @__PURE__ */ n("label", { className: f.configLabel, children: [
617
+ i("collab.config.instructions"),
618
+ /* @__PURE__ */ e(
619
+ "textarea",
620
+ {
621
+ className: f.field,
622
+ name: "instructions",
623
+ rows: 4,
624
+ defaultValue: a.instructions ?? "",
625
+ placeholder: i("collab.config.instructionsHint")
626
+ }
627
+ )
628
+ ] }),
629
+ /* @__PURE__ */ n("label", { className: f.configLabel, children: [
630
+ i("collab.config.agentType"),
631
+ /* @__PURE__ */ e(
632
+ "input",
633
+ {
634
+ className: f.field,
635
+ name: "agentType",
636
+ defaultValue: a.agentType ?? "",
637
+ placeholder: i("collab.config.workspaceDefault")
638
+ }
639
+ )
640
+ ] }),
641
+ /* @__PURE__ */ n("label", { className: f.configLabel, children: [
642
+ i("collab.config.model"),
643
+ /* @__PURE__ */ e(
644
+ "input",
645
+ {
646
+ className: f.field,
647
+ name: "model",
648
+ defaultValue: a.model ?? "",
649
+ placeholder: i("collab.config.workspaceDefault")
650
+ }
651
+ )
652
+ ] }),
653
+ /* @__PURE__ */ n("label", { className: f.configLabel, children: [
654
+ i("collab.config.maxRuns"),
655
+ /* @__PURE__ */ e(
656
+ "input",
657
+ {
658
+ className: f.field,
659
+ name: "maxConcurrentRuns",
660
+ type: "number",
661
+ min: 1,
662
+ max: 8,
663
+ defaultValue: a.maxConcurrentRuns ?? 1
664
+ }
665
+ )
666
+ ] }),
667
+ /* @__PURE__ */ e("p", { className: f.configNote, children: i("collab.config.note") }),
668
+ /* @__PURE__ */ n("div", { className: f.formActions, children: [
669
+ /* @__PURE__ */ e(
670
+ C,
671
+ {
672
+ type: "button",
673
+ variant: "ghost",
674
+ size: "sm",
675
+ onClick: () => Y(void 0),
676
+ children: i("collab.form.cancel")
677
+ }
678
+ ),
679
+ /* @__PURE__ */ e(C, { type: "submit", size: "sm", disabled: $, children: i("collab.config.save") })
680
+ ] })
681
+ ]
682
+ }
683
+ ) : null,
684
+ re === a.id ? /* @__PURE__ */ n("section", { className: f.agentWorkspace, children: [
685
+ /* @__PURE__ */ n("div", { className: f.agentWorkspaceHeader, children: [
686
+ /* @__PURE__ */ e("strong", { children: i("collab.agent.assigned") }),
687
+ /* @__PURE__ */ e("span", { children: oe(a.status) })
688
+ ] }),
689
+ d.some(
690
+ (w) => w.assigneeName === a.name
691
+ ) ? d.filter((w) => w.assigneeName === a.name).sort((w, j) => j.updatedAt - w.updatedAt).map((w) => /* @__PURE__ */ e(
692
+ st,
693
+ {
694
+ thread: w,
695
+ onOpen: l
696
+ },
697
+ w.id
698
+ )) : /* @__PURE__ */ e("p", { className: f.emptyRoster, children: i("collab.agent.noneAssigned") })
699
+ ] }) : null
700
+ ]
701
+ },
702
+ a.id
703
+ )),
704
+ k ? /* @__PURE__ */ n("div", { className: f.ceiling, children: [
705
+ /* @__PURE__ */ e("h3", { className: f.ceilingTitle, children: i("collab.ceiling.title") }),
706
+ /* @__PURE__ */ e("p", { className: f.ceilingText, children: k.readOnly ? i("collab.ceiling.readOnly") : i("collab.ceiling.open") }),
707
+ /* @__PURE__ */ n("details", { children: [
708
+ /* @__PURE__ */ e("summary", { className: "cursor-pointer text-xs text-muted-foreground", children: i("collab.ceiling.tools") }),
709
+ /* @__PURE__ */ e("p", { className: f.ceilingTools, children: k.allowed.join(", ") })
710
+ ] })
711
+ ] }) : null
712
+ ] }),
713
+ U.length === 0 ? /* @__PURE__ */ e(Oe, { className: "border", hidden: r !== "tasks", children: /* @__PURE__ */ n(je, { children: [
714
+ /* @__PURE__ */ e(Fe, { variant: "icon", children: /* @__PURE__ */ e(gt, {}) }),
715
+ /* @__PURE__ */ e(Ue, { children: i("collab.empty.lead") }),
716
+ /* @__PURE__ */ e(St, { children: i("collab.empty.hint") })
717
+ ] }) }) : U.map((a) => /* @__PURE__ */ e(
718
+ ya,
719
+ {
720
+ group: a,
721
+ onOpenThread: l,
722
+ hidden: r !== "tasks"
723
+ },
724
+ a.key
725
+ ))
726
+ ] }),
727
+ R && S && /* @__PURE__ */ e(
728
+ jt,
729
+ {
730
+ agentName: S.name,
731
+ open: !0,
732
+ onOpenChange: (a) => {
733
+ a || G(void 0);
734
+ },
735
+ onCreate: () => R.create(S.id),
736
+ onList: () => R.list(S.id),
737
+ onRevoke: (a) => R.revoke(S.id, a)
738
+ }
739
+ )
740
+ ] });
741
+ }
742
+ const Ta = "_runRow_1vx3b_3", Ca = "_runAgent_1vx3b_12", Sa = "_runState_1vx3b_23", Aa = "_runStateOutstanding_1vx3b_33", Ra = "_runStateLive_1vx3b_37", La = "_runProgress_1vx3b_41", Ia = "_runTrigger_1vx3b_58", $a = "_runLink_1vx3b_67", Da = "_runCancel_1vx3b_68", Ha = "_runError_1vx3b_91", B = {
743
+ runRow: Ta,
744
+ runAgent: Ca,
745
+ runState: Sa,
746
+ runStateOutstanding: Aa,
747
+ runStateLive: Ra,
748
+ runProgress: La,
749
+ runTrigger: Ia,
750
+ runLink: $a,
751
+ runCancel: Da,
752
+ runError: Ha
753
+ }, Ea = /* @__PURE__ */ new Set([
754
+ "starting",
755
+ "resuming",
756
+ "waiting",
757
+ "thinking",
758
+ "tool",
759
+ "responding"
760
+ ]);
761
+ function Ke({
762
+ row: t,
763
+ hideAgent: d = !1,
764
+ onOpenAgentSession: r,
765
+ onCancelRun: u
766
+ }) {
767
+ const { t: l } = ae(), _ = t.run.sessionId, m = t.run.progress, [g, I] = x(Date.now);
768
+ se(() => {
769
+ if (!t.live) return;
770
+ const M = setInterval(() => I(Date.now()), 1e3);
771
+ return () => clearInterval(M);
772
+ }, [t.live]);
773
+ const H = m && g - m.activityAt > 15e3, R = t.run.status === "queued" ? l("collab.runRow.queued") : t.run.status === "running" ? m ? m.stage === "awaiting_approval" ? l("collab.runRow.stage.awaiting_approval") : H ? l("collab.runRow.quiet") : Ea.has(m.stage) ? l(`collab.runRow.stage.${m.stage}`) : l("collab.runRow.working") : l("collab.runRow.unconfirmed") : t.state, k = t.outstanding ? `${B.runState} ${B.runStateOutstanding}` : t.live ? `${B.runState} ${B.runStateLive}` : B.runState;
774
+ return /* @__PURE__ */ n("div", { className: B.runRow, "data-compact": d || void 0, children: [
775
+ d ? null : /* @__PURE__ */ e("span", { className: B.runAgent, children: t.run.agentName }),
776
+ /* @__PURE__ */ n("span", { className: k, children: [
777
+ R,
778
+ t.live && t.run.status !== "cancelling" && u ? /* @__PURE__ */ e(
779
+ "button",
780
+ {
781
+ type: "button",
782
+ className: B.runCancel,
783
+ onClick: () => u(t.run.id),
784
+ children: l("collab.runRow.cancel")
785
+ }
786
+ ) : null
787
+ ] }),
788
+ t.live && /* @__PURE__ */ n("div", { className: B.runProgress, role: "status", children: [
789
+ t.run.startedAt && /* @__PURE__ */ e("div", { children: l("collab.runRow.elapsed", {
790
+ elapsed: be(g - t.run.startedAt, l)
791
+ }) }),
792
+ m ? /* @__PURE__ */ e("div", { children: l("collab.runRow.lastActivity", {
793
+ elapsed: be(g - m.activityAt, l)
794
+ }) }) : /* @__PURE__ */ e("div", { children: t.run.status === "queued" ? l("collab.runRow.queuedHint") : l("collab.runRow.unconfirmedHint") })
795
+ ] }),
796
+ m?.detail && /* @__PURE__ */ n("details", { className: B.runProgress, open: t.live, children: [
797
+ /* @__PURE__ */ e("summary", { children: l("collab.runRow.activity") }),
798
+ /* @__PURE__ */ e("div", { children: m.detail })
799
+ ] }),
800
+ m?.thoughtText && /* @__PURE__ */ n("details", { className: B.runProgress, open: t.live, children: [
801
+ /* @__PURE__ */ e("summary", { children: l("collab.runRow.thinking") }),
802
+ /* @__PURE__ */ e("div", { className: "max-h-64 overflow-y-auto whitespace-pre-wrap break-words", children: m.thoughtText }),
803
+ m.thoughtText.length >= 65536 && /* @__PURE__ */ e("p", { children: l("collab.runRow.thinkingCap") })
804
+ ] }),
805
+ m?.outputText && /* @__PURE__ */ n("details", { className: B.runProgress, children: [
806
+ /* @__PURE__ */ e("summary", { children: l("collab.runRow.output") }),
807
+ /* @__PURE__ */ e(
808
+ Rt,
809
+ {
810
+ content: m.outputText,
811
+ isStreaming: t.run.status === "running"
812
+ }
813
+ ),
814
+ m.outputText.length >= 262144 && /* @__PURE__ */ e("p", { children: l("collab.runRow.outputCap") })
815
+ ] }),
816
+ /* @__PURE__ */ n("span", { className: B.runTrigger, children: [
817
+ Lt(t.run.trigger, l),
818
+ _ && r ? /* @__PURE__ */ n(xe, { children: [
819
+ " · ",
820
+ /* @__PURE__ */ e(
821
+ "button",
822
+ {
823
+ type: "button",
824
+ className: B.runLink,
825
+ onClick: () => r(_),
826
+ children: l("collab.runRow.openSession", { agent: t.run.agentName })
827
+ }
828
+ )
829
+ ] }) : null
830
+ ] }),
831
+ t.run.error ? /* @__PURE__ */ e("span", { className: B.runError, children: t.run.error === "agent_run_stalled" ? l("collab.runRow.stalled") : t.run.error }) : null
832
+ ] });
833
+ }
834
+ const za = "_context_dl3fu_6", qa = "_chevronShown_dl3fu_11", Ba = "_contextBody_dl3fu_15", Ma = "_dock_dl3fu_27", Wa = "_row_dl3fu_36", Pa = "_rowText_dl3fu_44", Oa = "_attention_dl3fu_48", ja = "_steps_dl3fu_52", Fa = "_step_dl3fu_52", Ua = "_stepText_dl3fu_70", Va = "_approval_dl3fu_77", Ga = "_approvalCaption_dl3fu_83", Ka = "_note_dl3fu_91", Xa = "_composerHint_dl3fu_107", Ja = "_team_dl3fu_119", Qa = "_teamHeader_dl3fu_128", Ya = "_teamTitle_dl3fu_135", Za = "_teamReason_dl3fu_144", en = "_muted_dl3fu_145", tn = "_teamLink_dl3fu_150", an = "_sectionTitle_dl3fu_167", nn = "_criteria_dl3fu_174", sn = "_criteriaText_dl3fu_178", ln = "_memberList_dl3fu_185", rn = "_member_dl3fu_185", on = "_memberHead_dl3fu_198", cn = "_memberToggle_dl3fu_204", dn = "_childRow_dl3fu_205", mn = "_memberText_dl3fu_236", un = "_memberName_dl3fu_243", gn = "_memberStatus_dl3fu_256", pn = "_memberStatusAttention_dl3fu_267", hn = "_memberStatusRunning_dl3fu_271", bn = "_leadBadge_dl3fu_275", fn = "_memberChevron_dl3fu_285", _n = "_memberDetail_dl3fu_304", vn = "_history_dl3fu_311", Nn = "_budget_dl3fu_315", b = {
835
+ context: za,
836
+ chevronShown: qa,
837
+ contextBody: Ba,
838
+ dock: Ma,
839
+ row: Wa,
840
+ rowText: Pa,
841
+ attention: Oa,
842
+ steps: ja,
843
+ step: Fa,
844
+ stepText: Ua,
845
+ approval: Va,
846
+ approvalCaption: Ga,
847
+ note: Ka,
848
+ composerHint: Xa,
849
+ team: Ja,
850
+ teamHeader: Qa,
851
+ teamTitle: Ya,
852
+ teamReason: Za,
853
+ muted: en,
854
+ teamLink: tn,
855
+ sectionTitle: an,
856
+ criteria: nn,
857
+ criteriaText: sn,
858
+ memberList: ln,
859
+ member: rn,
860
+ memberHead: on,
861
+ memberToggle: cn,
862
+ childRow: dn,
863
+ memberText: mn,
864
+ memberName: un,
865
+ memberStatus: gn,
866
+ memberStatusAttention: pn,
867
+ memberStatusRunning: hn,
868
+ leadBadge: bn,
869
+ memberChevron: fn,
870
+ memberDetail: _n,
871
+ history: vn,
872
+ budget: Nn
873
+ }, Ee = 5 * 6e4;
874
+ function lt(t) {
875
+ const [d, r] = x(() => Date.now());
876
+ return se(() => {
877
+ if (!t) return;
878
+ const u = setInterval(() => r(Date.now()), 1e3);
879
+ return () => clearInterval(u);
880
+ }, [t]), d;
881
+ }
882
+ function xn(t, d, r) {
883
+ const u = t.agentName;
884
+ if (t.status === "queued")
885
+ return {
886
+ text: t.queueAhead ? r("collab.run.queuedBehind", { agent: u, count: t.queueAhead }) : r("collab.run.queued", { agent: u }),
887
+ stalled: !1
888
+ };
889
+ if (t.status === "cancelling")
890
+ return { text: r("collab.run.stopping", { agent: u }), stalled: !1 };
891
+ const l = t.progress;
892
+ if (!l)
893
+ return { text: r("collab.run.starting", { agent: u }), stalled: !1 };
894
+ const _ = d - l.activityAt;
895
+ if (_ >= Ee)
896
+ return {
897
+ text: r("collab.run.stalled", { agent: u, elapsed: be(_, r) }),
898
+ stalled: !0
899
+ };
900
+ const m = be(d - (t.startedAt ?? d), r);
901
+ switch (l.stage) {
902
+ case "starting":
903
+ return { text: r("collab.run.starting", { agent: u }), stalled: !1 };
904
+ case "resuming":
905
+ return { text: r("collab.run.resuming", { agent: u }), stalled: !1 };
906
+ case "thinking":
907
+ return {
908
+ text: r("collab.run.thinking", { agent: u, elapsed: m }),
909
+ stalled: !1
910
+ };
911
+ case "responding":
912
+ return {
913
+ text: r("collab.run.responding", { agent: u, elapsed: m }),
914
+ stalled: !1
915
+ };
916
+ case "tool":
917
+ return {
918
+ text: l.detail ? r("collab.run.toolNamed", { agent: u, tool: l.detail, elapsed: m }) : r("collab.run.tool", { agent: u, elapsed: m }),
919
+ stalled: !1
920
+ };
921
+ case "stream_lost":
922
+ return { text: r("collab.run.streamLost", { agent: u }), stalled: !1 };
923
+ default:
924
+ return {
925
+ text: r("collab.run.working", { agent: u, elapsed: m }),
926
+ stalled: !1
927
+ };
928
+ }
929
+ }
930
+ const wn = /* @__PURE__ */ new Set(["queued", "running", "finishing", "cancelling"]), Ne = (t) => t !== void 0 && wn.has(t.status), ke = (t) => t.endedAt ?? t.startedAt ?? 0;
931
+ function yn(t, d, r) {
932
+ const u = t.filter((_) => _.willWake).map((_) => _.agentName);
933
+ return u.length === 0 ? r("collab.preview.nobody") : d.filter((_) => !u.includes(_.name)).length > 0 ? r("collab.preview.only", { names: u.join(", ") }) : r("collab.preview.to", { names: u.join(", ") });
934
+ }
935
+ function rt(t, d) {
936
+ const r = /* @__PURE__ */ new Map(), u = (l, _ = {}) => {
937
+ const m = r.get(l) ?? { name: l, lead: !1 };
938
+ r.set(l, { ...m, ..._ });
939
+ };
940
+ t.assigneeName && u(t.assigneeName, { lead: !0 });
941
+ for (const l of t.posts)
942
+ l.authorKind === "agent" && u(l.authorName);
943
+ for (const l of t.runs) {
944
+ const _ = r.get(l.agentName)?.run, m = !_ || Ne(l) && !Ne(_) || Ne(l) === Ne(_) && ke(l) >= ke(_);
945
+ u(l.agentName, {
946
+ ...l.agentColor ? { color: l.agentColor } : {},
947
+ ...m ? { run: l } : {}
948
+ });
949
+ }
950
+ for (const l of r.values()) {
951
+ const _ = d.find((m) => m.name === l.name);
952
+ l.color ??= _?.color;
953
+ }
954
+ return [...r.values()].sort((l, _) => Number(_.lead) - Number(l.lead));
955
+ }
956
+ function kn(t, d, r) {
957
+ const u = t.run, l = "", _ = b.memberStatusAttention, m = b.memberStatusRunning;
958
+ if (!u) return { text: r("collab.member.idle"), tone: l };
959
+ switch (u.status) {
960
+ case "queued":
961
+ return { text: r("collab.member.queued"), tone: l };
962
+ case "running":
963
+ case "finishing":
964
+ case "cancelling": {
965
+ const g = u.progress;
966
+ return g?.permission ? { text: r("collab.member.approval"), tone: _ } : g && d - g.activityAt >= Ee ? { text: r("collab.member.stalled"), tone: _ } : g?.stage === "tool" && g.detail ? {
967
+ text: r("collab.member.tool", { tool: g.detail }),
968
+ tone: m
969
+ } : g?.stage === "thinking" ? { text: r("collab.member.thinking"), tone: m } : g?.stage === "responding" ? { text: r("collab.member.responding"), tone: m } : { text: r("collab.member.starting"), tone: m };
970
+ }
971
+ case "cancelled":
972
+ return { text: r("collab.member.cancelled"), tone: _ };
973
+ case "failed":
974
+ return {
975
+ text: u.error === "agent_run_stalled" ? r("collab.member.timedOut") : r("collab.member.failed"),
976
+ tone: _
977
+ };
978
+ default:
979
+ return { text: r("collab.member.done"), tone: l };
980
+ }
981
+ }
982
+ const ot = mt(null);
983
+ function Tn() {
984
+ const t = dt(ot);
985
+ return t ? /* @__PURE__ */ e("span", { className: b.composerHint, children: t }) : null;
986
+ }
987
+ function Cn(t, d, r) {
988
+ const { description: u } = zt(t.title);
989
+ return {
990
+ id: t.requestId,
991
+ title: t.title || r("collab.approval.title", { agent: d }),
992
+ content: [],
993
+ ...u ? { rawInput: { description: u } } : {},
994
+ options: t.options.map(
995
+ (l) => ({
996
+ id: l.optionId,
997
+ label: l.name,
998
+ ...l.kind ? { kind: l.kind } : {}
999
+ })
1000
+ )
1001
+ };
1002
+ }
1003
+ function Sn({
1004
+ thread: t,
1005
+ agents: d,
1006
+ pending: r,
1007
+ onOpenAgentSession: u,
1008
+ onCancelRun: l,
1009
+ onOpenThread: _,
1010
+ onAssign: m
1011
+ }) {
1012
+ const { t: g } = ae(), { live: I, past: H } = He(t.runs, g), R = lt(I.length > 0), k = rt(t, d), [M, E] = x({}), W = Et(t.budget, g), y = t.status === "done" || t.status === "cancelled";
1013
+ return /* @__PURE__ */ n("section", { className: b.team, "aria-label": g("collab.team.title"), children: [
1014
+ /* @__PURE__ */ n("header", { className: b.teamHeader, children: [
1015
+ /* @__PURE__ */ e("h2", { className: b.teamTitle, children: t.title }),
1016
+ /* @__PURE__ */ e("p", { className: b.teamReason, children: ye(t.reason, g) }),
1017
+ m ? /* @__PURE__ */ n("div", { className: "mt-2 flex items-center gap-2", children: [
1018
+ /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground", children: g("collab.form.assignee") }),
1019
+ /* @__PURE__ */ n(Ie, { children: [
1020
+ /* @__PURE__ */ e($e, { asChild: !0, children: /* @__PURE__ */ e(
1021
+ C,
1022
+ {
1023
+ variant: "outline",
1024
+ size: "sm",
1025
+ disabled: r || y,
1026
+ "aria-label": g("collab.form.assignee"),
1027
+ children: t.assigneeName ?? g("collab.team.noLead")
1028
+ }
1029
+ ) }),
1030
+ /* @__PURE__ */ n(De, { align: "start", className: "min-w-40", children: [
1031
+ /* @__PURE__ */ n(me, { onSelect: () => m(void 0), children: [
1032
+ t.assigneeName ? null : /* @__PURE__ */ e(we, { className: "size-4" }),
1033
+ g("collab.team.noLead")
1034
+ ] }),
1035
+ /* @__PURE__ */ e(nt, {}),
1036
+ d.filter((o) => o.enabled && !o.retiredAt).map((o) => /* @__PURE__ */ n(
1037
+ me,
1038
+ {
1039
+ onSelect: () => m(o.name),
1040
+ children: [
1041
+ t.assigneeName === o.name ? /* @__PURE__ */ e(we, { className: "size-4" }) : null,
1042
+ o.name
1043
+ ]
1044
+ },
1045
+ o.id
1046
+ ))
1047
+ ] })
1048
+ ] })
1049
+ ] }) : null,
1050
+ t.parent && /* @__PURE__ */ e(
1051
+ "button",
1052
+ {
1053
+ type: "button",
1054
+ className: b.teamLink,
1055
+ onClick: () => _(t.parent.id),
1056
+ children: g("collab.team.parent", { title: t.parent.title })
1057
+ }
1058
+ )
1059
+ ] }),
1060
+ t.acceptanceCriteria ? /* @__PURE__ */ n("div", { className: b.criteria, children: [
1061
+ /* @__PURE__ */ e("h3", { className: b.sectionTitle, children: g("collab.detail.doneWhen") }),
1062
+ /* @__PURE__ */ e("p", { className: b.criteriaText, children: t.acceptanceCriteria })
1063
+ ] }) : null,
1064
+ /* @__PURE__ */ e("h3", { className: b.sectionTitle, children: g("collab.team.members", { count: k.length }) }),
1065
+ k.length === 0 && /* @__PURE__ */ e("p", { className: b.muted, children: g("collab.team.empty") }),
1066
+ /* @__PURE__ */ e("ul", { className: b.memberList, children: k.map((o) => {
1067
+ const { text: p, tone: P } = kn(o, R, g), $ = I.filter((V) => V.run.agentName === o.name), U = $.length > 0 || o.run !== void 0, X = U && (M[o.name] ?? $.length > 0), z = o.run?.sessionId;
1068
+ return /* @__PURE__ */ n("li", { className: b.member, children: [
1069
+ /* @__PURE__ */ n("div", { className: b.memberHead, children: [
1070
+ /* @__PURE__ */ n(
1071
+ "button",
1072
+ {
1073
+ type: "button",
1074
+ className: b.memberToggle,
1075
+ "aria-expanded": U ? X : void 0,
1076
+ disabled: !U,
1077
+ onClick: () => E((V) => ({
1078
+ ...V,
1079
+ [o.name]: !X
1080
+ })),
1081
+ children: [
1082
+ /* @__PURE__ */ e(he, { name: o.name, color: o.color }),
1083
+ /* @__PURE__ */ n("span", { className: b.memberText, children: [
1084
+ /* @__PURE__ */ n("span", { className: b.memberName, children: [
1085
+ o.name,
1086
+ o.lead && /* @__PURE__ */ e("span", { className: b.leadBadge, children: g("collab.team.lead") })
1087
+ ] }),
1088
+ /* @__PURE__ */ e(
1089
+ "span",
1090
+ {
1091
+ className: [b.memberStatus, P].filter(Boolean).join(" "),
1092
+ children: p
1093
+ }
1094
+ )
1095
+ ] }),
1096
+ U && /* @__PURE__ */ e(
1097
+ Je,
1098
+ {
1099
+ "aria-hidden": "true",
1100
+ className: b.memberChevron
1101
+ }
1102
+ )
1103
+ ]
1104
+ }
1105
+ ),
1106
+ z && u ? /* @__PURE__ */ n(Ie, { children: [
1107
+ /* @__PURE__ */ e($e, { asChild: !0, children: /* @__PURE__ */ e(
1108
+ C,
1109
+ {
1110
+ variant: "ghost",
1111
+ size: "icon-xs",
1112
+ "aria-label": g("collab.agent.more", {
1113
+ name: o.name
1114
+ }),
1115
+ children: /* @__PURE__ */ e(Xe, {})
1116
+ }
1117
+ ) }),
1118
+ /* @__PURE__ */ e(De, { align: "end", className: "min-w-40", children: /* @__PURE__ */ e(
1119
+ me,
1120
+ {
1121
+ onSelect: () => u(z),
1122
+ children: g("collab.runRow.openSession", {
1123
+ agent: o.name
1124
+ })
1125
+ }
1126
+ ) })
1127
+ ] }) : null
1128
+ ] }),
1129
+ X && /* @__PURE__ */ e("div", { className: b.memberDetail, children: ($.length > 0 ? $ : He([o.run], g).past).map((V) => /* @__PURE__ */ e(
1130
+ Ke,
1131
+ {
1132
+ row: V,
1133
+ hideAgent: !0,
1134
+ onOpenAgentSession: u,
1135
+ onCancelRun: r ? void 0 : l
1136
+ },
1137
+ V.run.id
1138
+ )) })
1139
+ ] }, o.name);
1140
+ }) }),
1141
+ !!t.children?.length && /* @__PURE__ */ n(xe, { children: [
1142
+ /* @__PURE__ */ e("h3", { className: b.sectionTitle, children: g("collab.team.tasks", { count: t.children.length }) }),
1143
+ /* @__PURE__ */ e("ul", { className: b.memberList, children: t.children.map((o) => /* @__PURE__ */ e("li", { children: /* @__PURE__ */ n(
1144
+ "button",
1145
+ {
1146
+ type: "button",
1147
+ className: b.childRow,
1148
+ onClick: () => _(o.id),
1149
+ children: [
1150
+ /* @__PURE__ */ e("span", { className: b.memberName, children: o.title }),
1151
+ /* @__PURE__ */ e("span", { className: b.memberStatus, children: [o.assigneeName, ye(o.reason, g)].filter(Boolean).join(" · ") })
1152
+ ]
1153
+ }
1154
+ ) }, o.id)) })
1155
+ ] }),
1156
+ H.length > 0 && /* @__PURE__ */ n("details", { className: b.history, children: [
1157
+ /* @__PURE__ */ e("summary", { className: b.sectionTitle, children: g("collab.team.history", { count: H.length }) }),
1158
+ H.map((o) => /* @__PURE__ */ e(
1159
+ Ke,
1160
+ {
1161
+ row: o,
1162
+ onOpenAgentSession: u
1163
+ },
1164
+ o.run.id
1165
+ ))
1166
+ ] }),
1167
+ /* @__PURE__ */ n("footer", { className: b.budget, children: [
1168
+ /* @__PURE__ */ e("span", { children: W.turns }),
1169
+ /* @__PURE__ */ e("span", { children: W.tokens }),
1170
+ /* @__PURE__ */ e("span", { children: W.scope })
1171
+ ] })
1172
+ ] });
1173
+ }
1174
+ function An({
1175
+ thread: t,
1176
+ agents: d,
1177
+ preview: r,
1178
+ pending: u,
1179
+ onSend: l,
1180
+ onDraftChange: _,
1181
+ onOpenAgentSession: m,
1182
+ onCancelRun: g,
1183
+ onMarkDone: I,
1184
+ onOpenThread: H,
1185
+ onRespondPermission: R,
1186
+ onAssign: k,
1187
+ onBack: M,
1188
+ activityOnly: E = !1,
1189
+ onOpenActivity: W,
1190
+ headerActionsContainer: y
1191
+ }) {
1192
+ const o = It(), { t: p } = ae(), [P, $] = x(!1), [U, X] = x(/* @__PURE__ */ new Set()), [z, V] = x(!1), [Y, re] = x(!0), [L, i] = x({}), { live: S } = He(t.runs, p), G = lt(S.length > 0), K = le(() => {
1193
+ const c = /* @__PURE__ */ new Map();
1194
+ for (const s of t.runs) {
1195
+ const N = c.get(s.agentId);
1196
+ (!N || ke(s) >= ke(N)) && c.set(s.agentId, s);
1197
+ }
1198
+ return [...c.values()].filter((s) => {
1199
+ if (s.status !== "failed" || t.status === "done" || t.status === "cancelled")
1200
+ return !1;
1201
+ const N = d.find(
1202
+ (A) => A.id === s.agentId || A.name === s.agentName
1203
+ );
1204
+ return !N || !N.enabled || N.retiredAt !== void 0 ? !1 : !S.some(
1205
+ (A) => A.run.agentId === N.id || A.run.agentName === N.name
1206
+ );
1207
+ });
1208
+ }, [t.runs, t.status, S, d]), O = le(() => {
1209
+ const c = /* @__PURE__ */ new Map();
1210
+ for (const s of d)
1211
+ s.color && c.set(s.name, s.color);
1212
+ for (const s of t.runs)
1213
+ s.agentColor && c.set(s.agentName, s.agentColor);
1214
+ return (s) => c.get(s);
1215
+ }, [d, t.runs]), oe = le(() => {
1216
+ const c = (s, N = s) => {
1217
+ const A = O(s);
1218
+ return { name: N, ...A ? { color: A } : {} };
1219
+ };
1220
+ return [
1221
+ ...t.body && !t.body.startsWith(Ae) ? [
1222
+ {
1223
+ id: `${t.id}:description`,
1224
+ role: "user",
1225
+ content: t.body
1226
+ }
1227
+ ] : [],
1228
+ ...t.posts.flatMap((s) => {
1229
+ const N = s.authorKind === "human" ? {
1230
+ id: s.id,
1231
+ role: "user",
1232
+ content: s.text,
1233
+ timestamp: s.at
1234
+ } : s.authorKind === "agent" ? {
1235
+ id: s.id,
1236
+ role: "assistant",
1237
+ content: s.text,
1238
+ author: c(
1239
+ s.authorName,
1240
+ s.authorDeleted ? p("collab.author.removed", {
1241
+ name: s.authorName
1242
+ }) : s.authorName
1243
+ ),
1244
+ timestamp: s.at
1245
+ } : {
1246
+ id: s.id,
1247
+ role: "system",
1248
+ content: s.text,
1249
+ variant: "info",
1250
+ source: "agent_collaboration",
1251
+ timestamp: s.at
1252
+ }, A = (s.outcomes ?? []).filter(
1253
+ (q) => q.kind === "skip"
1254
+ );
1255
+ return [
1256
+ N,
1257
+ ...A.map(
1258
+ (q, D) => ({
1259
+ id: `${s.id}:routing:${D}`,
1260
+ role: "system",
1261
+ content: Le(
1262
+ q.reason ?? "",
1263
+ q.agentName ?? "",
1264
+ p
1265
+ ),
1266
+ variant: "warning",
1267
+ source: "agent_collaboration_routing",
1268
+ timestamp: s.at
1269
+ })
1270
+ )
1271
+ ];
1272
+ }),
1273
+ ...t.runs.filter((s) => s.progress?.thoughtText).map(
1274
+ (s) => ({
1275
+ id: `${s.id}:thought`,
1276
+ role: "thinking",
1277
+ content: s.progress.thoughtText,
1278
+ author: c(s.agentName),
1279
+ // Last update, not start: text being written now belongs
1280
+ // after anything the run posted along the way.
1281
+ timestamp: s.progress?.receivedAt ?? s.startedAt,
1282
+ isStreaming: s.status === "running" && s.progress?.stage === "thinking"
1283
+ })
1284
+ ),
1285
+ ...t.runs.filter(
1286
+ (s) => s.progress?.outputText && !t.posts.some(
1287
+ (N) => N.sourceRunId === s.id && N.text.trim() === s.progress?.outputText?.trim()
1288
+ )
1289
+ ).map(
1290
+ (s) => ({
1291
+ id: `${s.id}:output`,
1292
+ role: "assistant",
1293
+ content: s.progress.outputText,
1294
+ author: c(s.agentName),
1295
+ // Last update, not start: text being written now belongs
1296
+ // after anything the run posted along the way.
1297
+ timestamp: s.progress?.receivedAt ?? s.startedAt,
1298
+ isStreaming: s.status === "running"
1299
+ })
1300
+ )
1301
+ ].sort((s, N) => (s.timestamp ?? 0) - (N.timestamp ?? 0));
1302
+ }, [t.id, t.body, t.posts, t.runs, O, p]), Z = le(() => rt(t, d), [t, d]), ue = le(
1303
+ () => ({ ...o, renderComposerToolbarStart: Tn }),
1304
+ [o]
1305
+ );
1306
+ if (E)
1307
+ return /* @__PURE__ */ e(
1308
+ Sn,
1309
+ {
1310
+ thread: t,
1311
+ agents: d,
1312
+ pending: u,
1313
+ onOpenAgentSession: m,
1314
+ onCancelRun: g,
1315
+ onOpenThread: H,
1316
+ ...k ? { onAssign: k } : {}
1317
+ }
1318
+ );
1319
+ const J = /* @__PURE__ */ n("div", { className: "flex shrink-0 items-center gap-1", children: [
1320
+ t.status !== "done" && /* @__PURE__ */ e(
1321
+ C,
1322
+ {
1323
+ variant: "ghost",
1324
+ size: "icon",
1325
+ title: p("collab.markDone"),
1326
+ "aria-label": p("collab.markDone"),
1327
+ disabled: u,
1328
+ onClick: I,
1329
+ children: /* @__PURE__ */ e(we, { className: "size-4" })
1330
+ }
1331
+ ),
1332
+ W && /* @__PURE__ */ e(
1333
+ C,
1334
+ {
1335
+ variant: "ghost",
1336
+ size: "icon",
1337
+ title: p("collab.team.title"),
1338
+ "aria-label": p("collab.team.title"),
1339
+ onClick: W,
1340
+ children: /* @__PURE__ */ e(We, { className: "size-4" })
1341
+ }
1342
+ )
1343
+ ] }), a = S.flatMap(({ run: c }) => {
1344
+ const s = c.progress?.permission;
1345
+ if (!s || !c.sessionId || !R || U.has(s.requestId))
1346
+ return [];
1347
+ const N = c.sessionId;
1348
+ return [
1349
+ /* @__PURE__ */ n(
1350
+ "div",
1351
+ {
1352
+ role: "group",
1353
+ "aria-label": p("collab.approval.title", { agent: c.agentName }),
1354
+ className: b.approval,
1355
+ children: [
1356
+ /* @__PURE__ */ n("div", { className: b.approvalCaption, children: [
1357
+ /* @__PURE__ */ e(he, { name: c.agentName, color: O(c.agentName) }),
1358
+ p("collab.approval.title", { agent: c.agentName })
1359
+ ] }),
1360
+ /* @__PURE__ */ e(
1361
+ $t,
1362
+ {
1363
+ request: Cn(s, c.agentName, p),
1364
+ keyboardActive: !1,
1365
+ onConfirm: (A, q) => {
1366
+ X((ee) => /* @__PURE__ */ new Set([...ee, A]));
1367
+ const D = () => X((ee) => {
1368
+ const fe = new Set(ee);
1369
+ return fe.delete(A), fe;
1370
+ });
1371
+ R(N, A, q).then(
1372
+ (ee) => ee === !1 && D(),
1373
+ D
1374
+ );
1375
+ }
1376
+ }
1377
+ )
1378
+ ]
1379
+ },
1380
+ c.id
1381
+ )
1382
+ ];
1383
+ }), w = S.filter(
1384
+ ({ run: c }) => !(c.progress?.permission && c.sessionId && R && !U.has(c.progress.permission.requestId))
1385
+ ), j = w.length > 0 || K.length > 0, F = t.status === "blocked" || t.status === "in_review", Q = r?.filter((c) => !c.willWake) ?? [], ie = r ? yn(r, Z, p) : t.assigneeName ? p("collab.composer.hint", { name: t.assigneeName }) : null;
1386
+ return /* @__PURE__ */ n("div", { className: "flex min-h-0 flex-1 flex-col overflow-hidden", children: [
1387
+ y ? Mt(J, y) : /* @__PURE__ */ n("header", { className: "flex items-center gap-2 border-b border-border px-4 py-2", children: [
1388
+ M && /* @__PURE__ */ e(
1389
+ C,
1390
+ {
1391
+ variant: "ghost",
1392
+ size: "icon-sm",
1393
+ "aria-label": p("collab.thread.back"),
1394
+ onClick: M,
1395
+ children: /* @__PURE__ */ e(Qe, {})
1396
+ }
1397
+ ),
1398
+ /* @__PURE__ */ e("h1", { className: "min-w-0 flex-1 truncate text-sm font-semibold", children: t.title }),
1399
+ J
1400
+ ] }),
1401
+ t.body.startsWith(Ae) && /* @__PURE__ */ n("div", { className: b.context, children: [
1402
+ /* @__PURE__ */ n(
1403
+ "button",
1404
+ {
1405
+ type: "button",
1406
+ className: T.summary,
1407
+ "aria-expanded": z,
1408
+ onClick: () => V((c) => !c),
1409
+ children: [
1410
+ /* @__PURE__ */ e("span", { className: T.summaryText, children: p("collab.thread.context") }),
1411
+ /* @__PURE__ */ e(
1412
+ "span",
1413
+ {
1414
+ className: `${z ? T.chevronDown : T.chevronRight} ${b.chevronShown}`,
1415
+ "aria-hidden": "true"
1416
+ }
1417
+ )
1418
+ ]
1419
+ }
1420
+ ),
1421
+ z && /* @__PURE__ */ e("div", { className: `${T.group} ${b.contextBody}`, children: t.body.slice(Ae.length) })
1422
+ ] }),
1423
+ /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ e(
1424
+ Ge,
1425
+ {
1426
+ value: { ...o, collapseCompletedTurns: !1 },
1427
+ children: /* @__PURE__ */ e(
1428
+ Dt,
1429
+ {
1430
+ messages: oe,
1431
+ pendingApproval: null,
1432
+ sessionKey: t.id,
1433
+ hideSessionTimeline: !0
1434
+ }
1435
+ )
1436
+ }
1437
+ ) }),
1438
+ /* @__PURE__ */ n("div", { className: b.dock, children: [
1439
+ /* @__PURE__ */ n("div", { className: T.wrap, children: [
1440
+ /* @__PURE__ */ n(
1441
+ "button",
1442
+ {
1443
+ type: "button",
1444
+ className: T.summary,
1445
+ "aria-expanded": j ? Y : void 0,
1446
+ "aria-disabled": j ? void 0 : !0,
1447
+ onClick: j ? () => re((c) => !c) : void 0,
1448
+ children: [
1449
+ /* @__PURE__ */ e("span", { className: T.summaryIcon, "aria-hidden": "true", children: /* @__PURE__ */ e(We, { className: "size-3.5" }) }),
1450
+ /* @__PURE__ */ e(
1451
+ "span",
1452
+ {
1453
+ className: w.length > 0 ? `${T.summaryText} ${T.summaryTextActive}` : F ? `${T.summaryText} ${b.attention}` : T.summaryText,
1454
+ children: ye(t.reason, p)
1455
+ }
1456
+ ),
1457
+ /* @__PURE__ */ e(
1458
+ "span",
1459
+ {
1460
+ className: Y ? T.chevronDown : T.chevronRight,
1461
+ "aria-hidden": "true"
1462
+ }
1463
+ )
1464
+ ]
1465
+ }
1466
+ ),
1467
+ j && Y && /* @__PURE__ */ e("div", { className: T.group, children: /* @__PURE__ */ n("div", { className: T.list, children: [
1468
+ w.map(({ run: c }) => {
1469
+ const s = xn(c, G, p), N = s.stalled && G >= (L[c.id] ?? 0), A = N ? s.text : s.stalled ? p("collab.run.working", {
1470
+ agent: c.agentName,
1471
+ elapsed: be(
1472
+ G - (c.startedAt ?? G),
1473
+ p
1474
+ )
1475
+ }) : s.text, q = c.progress?.steps ?? [];
1476
+ return /* @__PURE__ */ n("div", { children: [
1477
+ /* @__PURE__ */ n(
1478
+ "div",
1479
+ {
1480
+ role: "status",
1481
+ className: `${T.row} ${b.row}`,
1482
+ "data-agent-status": N ? "failed" : "active",
1483
+ children: [
1484
+ /* @__PURE__ */ e(
1485
+ he,
1486
+ {
1487
+ name: c.agentName,
1488
+ color: O(c.agentName)
1489
+ }
1490
+ ),
1491
+ /* @__PURE__ */ e("span", { className: T.rowText, children: /* @__PURE__ */ e(
1492
+ "span",
1493
+ {
1494
+ className: `${T.rowActivity} ${N ? b.attention : b.rowText}`,
1495
+ children: A
1496
+ }
1497
+ ) }),
1498
+ N && /* @__PURE__ */ e(
1499
+ C,
1500
+ {
1501
+ size: "xs",
1502
+ variant: "ghost",
1503
+ onClick: () => i((D) => ({
1504
+ ...D,
1505
+ [c.id]: G + Ee
1506
+ })),
1507
+ children: p("collab.run.keepWaiting")
1508
+ }
1509
+ ),
1510
+ (N || c.status === "queued") && !u && /* @__PURE__ */ e(
1511
+ C,
1512
+ {
1513
+ size: "xs",
1514
+ variant: "ghost",
1515
+ onClick: () => g(c.id),
1516
+ children: p("collab.run.stop")
1517
+ }
1518
+ )
1519
+ ]
1520
+ }
1521
+ ),
1522
+ q.length > 0 && // One line per tool call, like a CI job's step list.
1523
+ /* @__PURE__ */ e(
1524
+ "ol",
1525
+ {
1526
+ "aria-label": p("collab.run.steps", {
1527
+ agent: c.agentName
1528
+ }),
1529
+ className: b.steps,
1530
+ children: q.map((D) => /* @__PURE__ */ n("li", { className: b.step, children: [
1531
+ D.status === "running" ? /* @__PURE__ */ e(
1532
+ Pe,
1533
+ {
1534
+ "aria-label": p("collab.step.running"),
1535
+ className: "size-3 shrink-0 animate-spin motion-reduce:animate-none"
1536
+ }
1537
+ ) : D.status === "done" ? /* @__PURE__ */ e(
1538
+ we,
1539
+ {
1540
+ "aria-label": p("collab.step.done"),
1541
+ className: "size-3 shrink-0 text-[var(--success-color)]"
1542
+ }
1543
+ ) : /* @__PURE__ */ e(
1544
+ pt,
1545
+ {
1546
+ "aria-label": p("collab.step.failed"),
1547
+ className: "size-3 shrink-0 text-destructive"
1548
+ }
1549
+ ),
1550
+ /* @__PURE__ */ e(
1551
+ "span",
1552
+ {
1553
+ className: D.status === "running" ? `${b.stepText} text-foreground` : b.stepText,
1554
+ children: D.title || p("collab.step.untitled")
1555
+ }
1556
+ )
1557
+ ] }, D.id))
1558
+ }
1559
+ )
1560
+ ] }, c.id);
1561
+ }),
1562
+ K.map((c) => /* @__PURE__ */ n(
1563
+ "div",
1564
+ {
1565
+ role: "status",
1566
+ className: `${T.row} ${b.row}`,
1567
+ "data-agent-status": "failed",
1568
+ children: [
1569
+ /* @__PURE__ */ e(
1570
+ he,
1571
+ {
1572
+ name: c.agentName,
1573
+ color: O(c.agentName)
1574
+ }
1575
+ ),
1576
+ /* @__PURE__ */ e("span", { className: T.rowText, children: /* @__PURE__ */ e(
1577
+ "span",
1578
+ {
1579
+ className: `${T.rowActivity} ${b.attention}`,
1580
+ children: c.error === "agent_run_stalled" ? p("collab.run.timedOut", { agent: c.agentName }) : p("collab.run.failed", { agent: c.agentName })
1581
+ }
1582
+ ) }),
1583
+ !u && /* @__PURE__ */ e(
1584
+ C,
1585
+ {
1586
+ size: "xs",
1587
+ variant: "ghost",
1588
+ onClick: () => void l(
1589
+ `@${c.agentName} ${p("collab.run.retryPrompt")}`
1590
+ ),
1591
+ children: p("collab.run.retry")
1592
+ }
1593
+ )
1594
+ ]
1595
+ },
1596
+ c.id
1597
+ ))
1598
+ ] }) })
1599
+ ] }),
1600
+ a,
1601
+ P && /* @__PURE__ */ n("div", { role: "status", className: b.note, children: [
1602
+ /* @__PURE__ */ e(
1603
+ Pe,
1604
+ {
1605
+ "aria-hidden": "true",
1606
+ className: "size-3.5 animate-spin motion-reduce:animate-none"
1607
+ }
1608
+ ),
1609
+ p("collab.sending")
1610
+ ] }),
1611
+ Q.length > 0 && /* @__PURE__ */ e("div", { role: "status", className: b.note, children: Q.map((c) => /* @__PURE__ */ e("p", { children: Le(c.reason ?? "", c.agentName, p) }, `${c.agentName}:${c.reason}`)) }),
1612
+ /* @__PURE__ */ e(ot.Provider, { value: ie, children: /* @__PURE__ */ e(Ge, { value: ue, children: /* @__PURE__ */ e(
1613
+ Ht,
1614
+ {
1615
+ commands: [],
1616
+ builtinAtProviders: !1,
1617
+ visibleToolbarActions: [],
1618
+ atProviders: [
1619
+ {
1620
+ id: "agents",
1621
+ label: p("collab.mention.provider"),
1622
+ search: async ({ query: c }) => d.filter(
1623
+ (s) => s.enabled && !s.retiredAt && s.name.toLowerCase().includes(c.toLowerCase())
1624
+ ).map((s) => ({
1625
+ id: s.id,
1626
+ label: s.name,
1627
+ insertText: `@${s.name} `
1628
+ }))
1629
+ }
1630
+ ],
1631
+ placeholderText: p("collab.composer.placeholder"),
1632
+ disabled: u || t.status === "done" || t.status === "cancelled",
1633
+ onInputTextChange: _,
1634
+ onSubmit: (c, s, N, A) => (s?.length || N?.length || !c.trim() || ($(!0), l(c).then((q) => {
1635
+ q && A?.();
1636
+ }).finally(() => $(!1))), !1)
1637
+ }
1638
+ ) }) })
1639
+ ] })
1640
+ ] });
1641
+ }
1642
+ function Rn(t, d) {
1643
+ if (!t || t.id !== d.threadId) return t;
1644
+ let r = !1;
1645
+ const u = t.runs.map((l) => l.id !== d.runId || (l.progress?.attempt ?? 0) > d.attempt ? l : (r = !0, {
1646
+ ...l,
1647
+ status: l.status === "queued" ? "running" : l.status,
1648
+ progress: {
1649
+ attempt: d.attempt,
1650
+ // The daemon stamps `receivedAt` with its own clock and `ThreadChat`
1651
+ // sorts it against daemon-written `post.at` / `run.startedAt`. Using the
1652
+ // browser clock here would order one transcript by two clocks, which a
1653
+ // remote daemon makes visible. `activityAt` is refreshed by the daemon
1654
+ // on exactly this frame, so it is the same instant on the same clock.
1655
+ receivedAt: d.activityAt,
1656
+ activityAt: d.activityAt,
1657
+ stage: d.stage,
1658
+ detail: d.detail,
1659
+ outputText: d.outputText,
1660
+ thoughtText: d.thoughtText,
1661
+ ...d.permission ? { permission: d.permission } : {},
1662
+ ...d.steps ? { steps: d.steps } : {}
1663
+ }
1664
+ }));
1665
+ return r ? { ...t, runs: u } : t;
1666
+ }
1667
+ const Ln = 250, In = 1e3, $n = 150;
1668
+ function Wn({
1669
+ initialView: t,
1670
+ initialThreadId: d,
1671
+ workspaceCwd: r,
1672
+ chat: u = !1,
1673
+ activityOnly: l = !1,
1674
+ onOpenActivity: _,
1675
+ headerActionsContainer: m,
1676
+ onTitleChange: g,
1677
+ onOpenThreadChat: I,
1678
+ onOpenAgentSession: H,
1679
+ onOpenDefinitions: R
1680
+ }) {
1681
+ const k = ht(), M = bt(), [E, W] = x(), y = r ?? E ?? M.workspaceCwd ?? k.capabilities?.workspaces?.find((h) => h.primary)?.cwd, o = le(
1682
+ () => y ? qt(k.baseUrl, k.token, y) : void 0,
1683
+ [k.baseUrl, k.token, y]
1684
+ ), { t: p } = ae(), [P, $] = x([]), [U, X] = x(
1685
+ t === void 0 || t === "new-agent" ? "agents" : t
1686
+ ), [z, V] = x(), [Y, re] = x([]), [L, i] = x(d), [S, G] = x();
1687
+ se(() => {
1688
+ u && !l && S && g?.(S.id, S.title);
1689
+ }, [u, l, S, g]);
1690
+ const [K, O] = x(""), [oe, Z] = x(), [ue, J] = x(), [a, w] = x(!1), [j, F] = x(
1691
+ t === "new-agent"
1692
+ ), [Q, ie] = x(), [c, s] = x(), N = c ?? Q, A = de(K);
1693
+ A.current = K;
1694
+ const q = de(void 0), D = le(() => ({ client: o, openId: L }), [o, L]), ee = de(D);
1695
+ ee.current = D;
1696
+ const fe = de(0), _e = de(0);
1697
+ se(() => {
1698
+ t && t !== "new-agent" && X(t);
1699
+ }, [t]);
1700
+ const ge = (h) => {
1701
+ i(h), G(void 0), O(""), Z(void 0), s(void 0);
1702
+ }, ce = Ce(async () => {
1703
+ if (!o) return;
1704
+ const h = ++fe.current;
1705
+ try {
1706
+ const [v, ne, pe] = await Promise.all([
1707
+ o.listAgents(),
1708
+ o.listThreads(),
1709
+ L ? o.getThread(L) : void 0
1710
+ ]);
1711
+ if (ee.current !== D || h < _e.current)
1712
+ return;
1713
+ _e.current = h, $(v.agents), v.capabilities && V(v.capabilities), re(ne.threads), G(pe), ie(void 0);
1714
+ } catch (v) {
1715
+ if (ee.current !== D || h < _e.current)
1716
+ return;
1717
+ _e.current = h, ie(v instanceof Error ? v.message : String(v));
1718
+ }
1719
+ }, [o, L, D]), Te = de(ce);
1720
+ Te.current = ce, se(() => {
1721
+ ce();
1722
+ }, [ce]), se(() => {
1723
+ if (!o) return;
1724
+ let h, v;
1725
+ const ne = () => {
1726
+ h ??= setInterval(() => void Te.current(), In);
1727
+ };
1728
+ if (!o.subscribe)
1729
+ return ne(), () => clearInterval(h);
1730
+ const pe = o.subscribe(
1731
+ (ve) => {
1732
+ if (ve.type === "progress") {
1733
+ G((ct) => Rn(ct, ve));
1734
+ return;
1735
+ }
1736
+ v ??= setTimeout(() => {
1737
+ v = void 0, Te.current();
1738
+ }, $n);
1739
+ },
1740
+ (ve) => {
1741
+ if (ve === "closed") {
1742
+ ne();
1743
+ return;
1744
+ }
1745
+ clearInterval(h), h = void 0;
1746
+ }
1747
+ );
1748
+ return () => {
1749
+ pe(), clearInterval(h), clearTimeout(v);
1750
+ };
1751
+ }, [o]), se(() => {
1752
+ if (!o || !L || !K.trim()) {
1753
+ Z(void 0);
1754
+ return;
1755
+ }
1756
+ const h = K;
1757
+ let v = !1;
1758
+ const ne = setTimeout(() => {
1759
+ o.previewReply(L, h).then((pe) => {
1760
+ !v && A.current === h && Z(pe.targets);
1761
+ }).catch(() => {
1762
+ v || Z(void 0);
1763
+ });
1764
+ }, Ln);
1765
+ return () => {
1766
+ v = !0, clearTimeout(ne);
1767
+ };
1768
+ }, [o, K, L]);
1769
+ const it = Ce(
1770
+ (h) => {
1771
+ q.current = h, J(void 0), o && o.previewThread(h).then((v) => {
1772
+ q.current === h && J(v.targets);
1773
+ }).catch(() => {
1774
+ q.current === h && J(void 0);
1775
+ });
1776
+ },
1777
+ [o]
1778
+ ), te = Ce(
1779
+ async (h) => {
1780
+ w(!0), s(void 0);
1781
+ try {
1782
+ const v = await h();
1783
+ await ce(), v !== null && typeof v == "object" && "dispatchError" in v && typeof v.dispatchError == "string" && s(
1784
+ p("collab.error.dispatchAfterSave", {
1785
+ error: v.dispatchError
1786
+ })
1787
+ );
1788
+ } catch (v) {
1789
+ return s(v instanceof Error ? v.message : String(v)), !1;
1790
+ } finally {
1791
+ w(!1);
1792
+ }
1793
+ return !0;
1794
+ },
1795
+ [ce, p]
1796
+ );
1797
+ if (!o)
1798
+ return /* @__PURE__ */ e("p", { role: "alert", children: p("collab.noWorkspace") });
1799
+ if (j)
1800
+ return /* @__PURE__ */ e(
1801
+ Bt,
1802
+ {
1803
+ initialScope: "workspace",
1804
+ workspaceCwd: y,
1805
+ onCancel: () => F(!1),
1806
+ onCreated: () => F(!1),
1807
+ onSaveWorkspaceAgent: async (h) => {
1808
+ await o.createAgent(h), await ce();
1809
+ }
1810
+ }
1811
+ );
1812
+ if (L && S?.id !== L)
1813
+ return /* @__PURE__ */ n("div", { className: "flex flex-col items-start gap-2 p-4", children: [
1814
+ u ? null : /* @__PURE__ */ n(C, { variant: "ghost", size: "sm", onClick: () => ge(), children: [
1815
+ /* @__PURE__ */ e(Qe, { "data-icon": "inline-start" }),
1816
+ p("collab.thread.back")
1817
+ ] }),
1818
+ /* @__PURE__ */ e("p", { role: "status", className: "text-sm text-muted-foreground", children: N ?? p("collab.thread.loading") })
1819
+ ] });
1820
+ const { createShare: ze, listShares: qe, revokeShare: Be } = o, Me = ze && qe && Be ? {
1821
+ create: ze,
1822
+ list: async (h) => (await qe(h)).shares,
1823
+ revoke: Be
1824
+ } : void 0;
1825
+ return L && S ? /* @__PURE__ */ n(xe, { children: [
1826
+ N && /* @__PURE__ */ e("p", { role: "alert", className: "px-4 py-2 text-sm text-destructive", children: N }),
1827
+ /* @__PURE__ */ e(
1828
+ An,
1829
+ {
1830
+ activityOnly: l,
1831
+ headerActionsContainer: m,
1832
+ ...u ? {} : { onBack: () => ge() },
1833
+ onOpenActivity: _ && y ? () => _(S.id, y) : void 0,
1834
+ thread: S,
1835
+ agents: P,
1836
+ preview: oe,
1837
+ pending: a,
1838
+ onDraftChange: O,
1839
+ onAssign: (h) => void te(() => o.assignThread(L, h)),
1840
+ onOpenAgentSession: H,
1841
+ onCancelRun: (h) => void te(() => o.cancelRun(L, h)),
1842
+ onMarkDone: () => void te(() => o.markDone(L)),
1843
+ ...o.respondToPermission ? {
1844
+ onRespondPermission: (h, v, ne) => te(
1845
+ () => o.respondToPermission(h, v, ne)
1846
+ )
1847
+ } : {},
1848
+ onOpenThread: (h) => {
1849
+ y && I ? I(h, y) : ge(h);
1850
+ },
1851
+ onSend: (h) => te(async () => {
1852
+ const v = await o.postReply(L, h);
1853
+ return O(""), Z(void 0), v;
1854
+ })
1855
+ },
1856
+ S.id
1857
+ )
1858
+ ] }) : /* @__PURE__ */ n(xe, { children: [
1859
+ N ? /* @__PURE__ */ e("p", { role: "alert", className: "mb-3 text-sm text-destructive", children: N }) : null,
1860
+ /* @__PURE__ */ e(
1861
+ ka,
1862
+ {
1863
+ agents: P,
1864
+ threads: Y,
1865
+ view: U,
1866
+ onViewChange: X,
1867
+ createPreview: ue,
1868
+ pending: a,
1869
+ onOpenThread: (h) => {
1870
+ y && I ? I(h, y) : ge(h);
1871
+ },
1872
+ onDeleteAgent: (h) => void te(() => o.deleteAgent(h)),
1873
+ onSetAgentEnabled: (h, v) => void te(() => o.setAgentEnabled(h, v)),
1874
+ onUpdateAgent: (h, v) => void te(() => o.updateAgent(h, v)),
1875
+ onOpenAgentBuilder: () => F(!0),
1876
+ ...Me ? { shares: Me } : {},
1877
+ ...R ? { onOpenDefinitions: R } : {},
1878
+ ...z ? { capabilities: z } : {},
1879
+ workspaceCwd: y,
1880
+ workspaces: k.capabilities?.workspaces ?? [],
1881
+ onWorkspaceChange: (h) => {
1882
+ W(h), $([]), J(void 0), q.current = void 0;
1883
+ },
1884
+ createError: N,
1885
+ onCreateThread: (h) => te(async () => {
1886
+ const v = await o.createThread(h);
1887
+ return J(void 0), ge(v.id), y && I?.(v.id, y), v;
1888
+ }),
1889
+ onPreviewThread: it
1890
+ }
1891
+ )
1892
+ ] });
1893
+ }
1894
+ export {
1895
+ Wn as ThreadsRoute
1896
+ };