@qwen-code/web-shell 0.27.4 → 0.28.1-preview.0

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