@qwen-code/web-shell 0.26.7-nightly.20261104.b9e20830f7 → 0.26.8

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