@yuku123/z-team-component 0.2.59 → 0.2.61

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 (52) hide show
  1. package/dist/{ChangeLogView-Cstbioyw.js → ChangeLogView-VRWVzP0r.js} +1 -1
  2. package/dist/{ComponentDoc-Bx6NAJlK.js → ComponentDoc-CZGpQekc.js} +1497 -1387
  3. package/dist/{InvitationManagementPage-Gkqisq4C.js → InvitationManagementPage-Dvhu6OWP.js} +1 -1
  4. package/dist/{OnboardingPage-C7C4PEjn.js → OnboardingPage-CF_ECLv7.js} +2 -2
  5. package/dist/{ScheduledTasks-BQRcjBOd.js → ScheduledTasks-Cec22jf4.js} +8 -8
  6. package/dist/SystemShell-D8uLAhd8.js +670 -0
  7. package/dist/{admin-logs-B9KS6VJz.js → admin-logs-DCYof_u5.js} +2 -2
  8. package/dist/{api-CALqShkO.js → api-DWt94BcM.js} +584 -572
  9. package/dist/{api-Y-52Ejhz.js → api-Dxw9Ajfn.js} +1 -1
  10. package/dist/{createWorkspaceWsHandler-DP30xvug.js → createWorkspaceWsHandler-3aHkBZE9.js} +4 -4
  11. package/dist/{index-4YxdJwFm.js → index-4LNRkvy6.js} +3 -3
  12. package/dist/index-B5dPYPuA.js +93 -0
  13. package/dist/{index-C2Wkg1b5.js → index-BIdcTXZW.js} +3 -3
  14. package/dist/{index-m8V5TniT.js → index-BVh0W8ck.js} +15861 -15586
  15. package/dist/{index-Gt21FARO.js → index-BdGXRcf4.js} +3 -3
  16. package/dist/index-BgR7NlYr.js +118 -0
  17. package/dist/{index-8gCovDDT.js → index-C6jp_1-U.js} +6 -6
  18. package/dist/{index-DJ0FV74Y.js → index-CKtjapcc.js} +3 -3
  19. package/dist/{index-lftFkqfI.js → index-CTKf6h2u.js} +4 -4
  20. package/dist/{index-DKeYG0Fu.js → index-CrIIInfs.js} +4 -4
  21. package/dist/{index-63ovR-_x.js → index-DF4ZWJfp.js} +1 -1
  22. package/dist/index-DepaHnKP.js +2858 -0
  23. package/dist/{index-CO6WYRIS.js → index-Dfce6-jv.js} +3 -3
  24. package/dist/{index-Bpn6x1So.js → index-Dr8elYjm.js} +12 -12
  25. package/dist/{index-CLWgeKwr.js → index-DtVBFjaJ.js} +2 -2
  26. package/dist/{index-CGWttFLb.js → index-Dvhocfyo.js} +4 -4
  27. package/dist/{index-aw72ID7y.js → index-NPxrK-81.js} +1 -1
  28. package/dist/{index-CinRd7Nz.js → index-VY-pgcyl.js} +1 -1
  29. package/dist/{index-DJOyOVn_.js → index-VxO9i5r6.js} +1 -1
  30. package/dist/{index-C3B7CbHo.js → index-bsGAZKaU.js} +624 -613
  31. package/dist/index-gMeWspFX.js +112 -0
  32. package/dist/{index-DET70T3j.js → index-i6Ejgpao.js} +1 -1
  33. package/dist/{index-BvTYVEEv.js → index-nxjdN-Fp.js} +20 -16
  34. package/dist/{index-DfQCaS0z.js → index-tipx38MZ.js} +248 -244
  35. package/dist/{index-CN9NsUQ6.js → index-yRDgpDx1.js} +5 -5
  36. package/dist/index.js +1 -1
  37. package/dist/{instance-f3C-1qYl.js → instance-CbkHlDr4.js} +1 -1
  38. package/dist/menuPermission-BvgoOn21.js +60 -0
  39. package/dist/pages.js +1 -1
  40. package/dist/schedule-BRvmKoDG.js +587 -0
  41. package/dist/{send-default-agent-team-message-d_ECdczr.js → send-default-agent-team-message-8wnVWO7H.js} +1 -1
  42. package/dist/{sso-user-HcsSzg8P.js → sso-user-QZNVhjpR.js} +1 -1
  43. package/dist/{training-DnNQN0An.js → training-DYo1pvX7.js} +1 -1
  44. package/dist/{useAppStore-kRZEA5WZ.js → useAppStore-BGOxWep2.js} +6 -2
  45. package/dist/{webide-BcRzJX-h.js → webide-CWTbQs4I.js} +4 -4
  46. package/dist/z-team-component.css +2 -2
  47. package/package.json +1 -1
  48. package/dist/SystemShell-Df9PZzLO.js +0 -907
  49. package/dist/index-Bw9yypc4.js +0 -2841
  50. package/dist/index-C0EIMJI2.js +0 -112
  51. package/dist/index-DRrBkbr_.js +0 -100
  52. package/dist/schedule-DfkgwPdE.js +0 -497
@@ -0,0 +1,2858 @@
1
+ import { jsx as e, jsxs as i, Fragment as Me } from "react/jsx-runtime";
2
+ import { S as Et, T as Ot, P as $t } from "./webide-CWTbQs4I.js";
3
+ import { RightOutlined as Ht, PlusOutlined as sn, LeftOutlined as an, CheckOutlined as Pt, LoadingOutlined as Tt, EditOutlined as wt, DeleteOutlined as ln, UpOutlined as It, RedoOutlined as cn, DownOutlined as on, StopOutlined as rn, CopyOutlined as dn, MessageOutlined as Ft, MoreOutlined as un, DashboardOutlined as jt, MenuUnfoldOutlined as mn, MenuFoldOutlined as pn, SettingOutlined as hn, TeamOutlined as gn, FolderOpenOutlined as _n, BarChartOutlined as fn, PieChartOutlined as yn, CodeOutlined as vn, LinkOutlined as bn, UnorderedListOutlined as Nn, FileTextOutlined as Wt, ReadOutlined as Cn, ConsoleSqlOutlined as kn, PlayCircleOutlined as Tn } from "@ant-design/icons";
4
+ import { useState as p, useRef as O, useMemo as De, useEffect as M, useCallback as U } from "react";
5
+ import { x as wn, y as Kt, k as tt, z as In, A as Sn, C as An, D as Bn, E as Ln, F as Dn, G as St } from "./api-DWt94BcM.js";
6
+ import { f as Ut, c as _t, a as Mn, b as xn, r as Rn, s as En, t as On, d as Vt, e as bt, g as $n, h as Hn, i as Gt, j as Pn, p as Fn, k as h, R as ut, D as ft, l as jn, m as Wn, F as yt, L as Kn, A as Un, C as Vn, W as Gn, n as zn, S as qn, o as Qn, U as Xn, T as Jn, q as Yn, u as Zn, P as es } from "./index-tipx38MZ.js";
7
+ import { u as zt, i as qt, T as ts, a as ns, s as ss } from "./createWorkspaceWsHandler-3aHkBZE9.js";
8
+ import { u as Ke } from "./useAppStore-BGOxWep2.js";
9
+ import { h as Qt, f as as } from "./schedule-BRvmKoDG.js";
10
+ import ls from "react-markdown";
11
+ import is from "rehype-highlight";
12
+ import cs from "remark-gfm";
13
+ import { W as Nt, b as mt, T as Xt, c as Jt, a as Yt, P as Zt, S as os, E as rs, C as ds } from "./ScheduledTasks-Cec22jf4.js";
14
+ import { message as rt, Tooltip as Ct } from "antd";
15
+ const us = "_container_3gc15_1", ms = "_sessionPanel_3gc15_9", ps = "_sessionHeader_3gc15_19", hs = "_sessionHeaderActions_3gc15_32", gs = "_sessionBtnSm_3gc15_37", _s = "_sessionList_3gc15_55", fs = "_sessionItem_3gc15_61", ys = "_sessionItemActive_3gc15_79", vs = "_sessionItemTitle_3gc15_84", bs = "_sessionLiveDot_3gc15_93", Ns = "_sessionItemTime_3gc15_100", Cs = "_sessionDeleteBtn_3gc15_106", ks = "_sessionRenameBtn_3gc15_127", Ts = "_sessionRenameInput_3gc15_148", ws = "_sessionCreateRow_3gc15_160", Is = "_sessionCreateInput_3gc15_166", Ss = "_sessionCreateConfirm_3gc15_180", As = "_sessionCreateCancel_3gc15_181", Bs = "_sessionSearchRow_3gc15_203", Ls = "_sessionSearchInput_3gc15_209", Ds = "_sessionSearchClear_3gc15_224", Ms = "_sessionEmpty_3gc15_245", xs = "_sessionExpandBtn_3gc15_255", Rs = "_chatPanel_3gc15_275", Es = "_chatHeader_3gc15_284", Os = "_agentAvatar_3gc15_296", $s = "_chatHeaderMeta_3gc15_309", Hs = "_chatHeaderName_3gc15_317", Ps = "_chatHeaderSession_3gc15_324", Fs = "_chatHeaderBadge_3gc15_332", js = "_streamingIndicator_3gc15_342", Ws = "_threadScroll_3gc15_351", Ks = "_threadInner_3gc15_357", Us = "_landing_3gc15_368", Vs = "_landingLogo_3gc15_378", Gs = "_landingTitle_3gc15_392", zs = "_landingHint_3gc15_398", qs = "_newChatLanding_3gc15_404", Qs = "_landingComposer_3gc15_415", Xs = "_landingInput_3gc15_432", Js = "_chatEmpty_3gc15_448", Ys = "_userRow_3gc15_459", Zs = "_userBubble_3gc15_464", ea = "_assistantBlock_3gc15_478", ta = "_md_3gc15_488", na = "_mdPreWrap_3gc15_546", sa = "_mdPreCopy_3gc15_550", aa = "_caretCursor_3gc15_585", la = "_errorBar_3gc15_602", ia = "_errorRetryBtn_3gc15_611", ca = "_stoppedBar_3gc15_626", oa = "_scrollTopBtn_3gc15_636", ra = "_scrollTopBtnVisible_3gc15_658", da = "_composerWrap_3gc15_669", ua = "_composer_3gc15_669", ma = "_composerInput_3gc15_691", pa = "_sendBtn_3gc15_709", ha = "_stopBtn_3gc15_710", ga = "_sendBtnReady_3gc15_730", _a = "_composerHint_3gc15_748", fa = "_msgMeta_3gc15_758", ya = "_copyBtn_3gc15_769", va = "_copyBtnInline_3gc15_799", ba = "_copyBtnDone_3gc15_806", Na = "_landingChips_3gc15_811", Ca = "_landingChip_3gc15_811", ka = "_userActions_3gc15_838", Ta = "_userActionBtn_3gc15_851", wa = "_editingBar_3gc15_874", Ia = "_pendingBar_3gc15_889", Sa = "_editingCancel_3gc15_910", c = {
16
+ container: us,
17
+ sessionPanel: ms,
18
+ sessionHeader: ps,
19
+ sessionHeaderActions: hs,
20
+ sessionBtnSm: gs,
21
+ sessionList: _s,
22
+ sessionItem: fs,
23
+ sessionItemActive: ys,
24
+ sessionItemTitle: vs,
25
+ sessionLiveDot: bs,
26
+ sessionItemTime: Ns,
27
+ sessionDeleteBtn: Cs,
28
+ sessionRenameBtn: ks,
29
+ sessionRenameInput: Ts,
30
+ sessionCreateRow: ws,
31
+ sessionCreateInput: Is,
32
+ sessionCreateConfirm: Ss,
33
+ sessionCreateCancel: As,
34
+ sessionSearchRow: Bs,
35
+ sessionSearchInput: Ls,
36
+ sessionSearchClear: Ds,
37
+ sessionEmpty: Ms,
38
+ sessionExpandBtn: xs,
39
+ chatPanel: Rs,
40
+ chatHeader: Es,
41
+ agentAvatar: Os,
42
+ chatHeaderMeta: $s,
43
+ chatHeaderName: Hs,
44
+ chatHeaderSession: Ps,
45
+ chatHeaderBadge: Fs,
46
+ streamingIndicator: js,
47
+ threadScroll: Ws,
48
+ threadInner: Ks,
49
+ landing: Us,
50
+ landingLogo: Vs,
51
+ landingTitle: Gs,
52
+ landingHint: zs,
53
+ newChatLanding: qs,
54
+ landingComposer: Qs,
55
+ landingInput: Xs,
56
+ chatEmpty: Js,
57
+ userRow: Ys,
58
+ userBubble: Zs,
59
+ assistantBlock: ea,
60
+ md: ta,
61
+ mdPreWrap: na,
62
+ mdPreCopy: sa,
63
+ caretCursor: aa,
64
+ errorBar: la,
65
+ errorRetryBtn: ia,
66
+ stoppedBar: ca,
67
+ scrollTopBtn: oa,
68
+ scrollTopBtnVisible: ra,
69
+ composerWrap: da,
70
+ composer: ua,
71
+ composerInput: ma,
72
+ sendBtn: pa,
73
+ stopBtn: ha,
74
+ sendBtnReady: ga,
75
+ composerHint: _a,
76
+ msgMeta: fa,
77
+ copyBtn: ya,
78
+ copyBtnInline: va,
79
+ copyBtnDone: ba,
80
+ landingChips: Na,
81
+ landingChip: Ca,
82
+ userActions: ka,
83
+ userActionBtn: Ta,
84
+ editingBar: wa,
85
+ pendingBar: Ia,
86
+ editingCancel: Sa
87
+ };
88
+ function Aa(a) {
89
+ if (a && a.trim().startsWith("{"))
90
+ try {
91
+ const d = JSON.parse(a);
92
+ if (d && Array.isArray(d.z_team_blocks))
93
+ return {
94
+ blocks: d.z_team_blocks,
95
+ totalMs: typeof d.totalMs == "number" ? d.totalMs : void 0,
96
+ usage: d.usage ?? void 0,
97
+ stopped: d.stopped === !0
98
+ };
99
+ } catch {
100
+ }
101
+ return null;
102
+ }
103
+ function At(a) {
104
+ return (a || []).map((d, m) => {
105
+ const f = Aa(d.content);
106
+ return {
107
+ id: `local-${d.timestamp}-${d.role}-${m}`,
108
+ role: d.role === "assistant" ? "assistant" : "user",
109
+ blocks: f ? f.blocks : [{ type: "text", text: d.content }],
110
+ totalMs: f == null ? void 0 : f.totalMs,
111
+ usage: f == null ? void 0 : f.usage,
112
+ stopped: (f == null ? void 0 : f.stopped) === !0
113
+ };
114
+ });
115
+ }
116
+ function qe(a) {
117
+ return a.filter((d) => d.type === "text").map((d) => d.text).join("");
118
+ }
119
+ function Ba(a) {
120
+ return a >= 1e4 ? `${Math.round(a / 1e3)}k` : a >= 1e3 ? `${(a / 1e3).toFixed(1)}k` : String(a);
121
+ }
122
+ function La(a) {
123
+ if (a == null || a <= 0) return "";
124
+ const d = Date.now() - a;
125
+ if (d < 6e4) return "刚刚";
126
+ if (d < 36e5) return `${Math.floor(d / 6e4)} 分钟前`;
127
+ if (d < 864e5) return `${Math.floor(d / 36e5)} 小时前`;
128
+ const m = new Date(Date.now() - 864e5);
129
+ if (new Date(a).toDateString() === m.toDateString()) return "昨天";
130
+ const f = new Date(a);
131
+ return `${f.getMonth() + 1}-${String(f.getDate()).padStart(2, "0")}`;
132
+ }
133
+ const Bt = [
134
+ "#2F70F1",
135
+ "#52c41a",
136
+ "#fa8c16",
137
+ "#eb2f96",
138
+ "#722ed1",
139
+ "#13c2c2",
140
+ "#f522d0",
141
+ "#faad14"
142
+ ];
143
+ function Lt(a) {
144
+ let d = 0;
145
+ for (let m = 0; m < a.length; m++) d = d * 31 + a.charCodeAt(m) | 0;
146
+ return Bt[Math.abs(d) % Bt.length];
147
+ }
148
+ function vt(a) {
149
+ return a ? a.charAt(0).toUpperCase() : "?";
150
+ }
151
+ function Da({ children: a }) {
152
+ const d = O(null);
153
+ return /* @__PURE__ */ i("div", { className: c.mdPreWrap, children: [
154
+ /* @__PURE__ */ e("div", { className: c.mdPreCopy, children: /* @__PURE__ */ e(kt, { getText: () => {
155
+ var m;
156
+ return ((m = d.current) == null ? void 0 : m.textContent) ?? "";
157
+ } }) }),
158
+ /* @__PURE__ */ e("pre", { ref: d, children: a })
159
+ ] });
160
+ }
161
+ function Ma({ text: a }) {
162
+ return /* @__PURE__ */ e("div", { className: c.md, children: /* @__PURE__ */ e(
163
+ ls,
164
+ {
165
+ remarkPlugins: [cs],
166
+ rehypePlugins: [is],
167
+ components: {
168
+ pre: (d) => /* @__PURE__ */ e(Da, { children: d.children })
169
+ },
170
+ children: a
171
+ }
172
+ ) });
173
+ }
174
+ function xa({ startedAtMs: a }) {
175
+ const [, d] = p(0);
176
+ M(() => {
177
+ const f = window.setInterval(() => d((k) => k + 1), 1e3);
178
+ return () => window.clearInterval(f);
179
+ }, []);
180
+ const m = Math.max(1, Math.round((Date.now() - a) / 1e3));
181
+ return /* @__PURE__ */ i("div", { className: c.msgMeta, children: [
182
+ m,
183
+ "s…"
184
+ ] });
185
+ }
186
+ function Ra(a) {
187
+ var d;
188
+ if ((d = navigator.clipboard) != null && d.writeText)
189
+ return navigator.clipboard.writeText(a).catch(() => {
190
+ }), !0;
191
+ try {
192
+ const m = document.createElement("textarea");
193
+ m.value = a, m.style.position = "fixed", m.style.opacity = "0", document.body.appendChild(m), m.select();
194
+ const f = document.execCommand("copy");
195
+ return document.body.removeChild(m), f;
196
+ } catch {
197
+ return !1;
198
+ }
199
+ }
200
+ function kt({
201
+ getText: a,
202
+ inline: d,
203
+ label: m = "复制正文"
204
+ }) {
205
+ const [f, k] = p(!1);
206
+ return /* @__PURE__ */ e(
207
+ "button",
208
+ {
209
+ type: "button",
210
+ className: `${c.copyBtn} ${d ? c.copyBtnInline : ""} ${f ? c.copyBtnDone : ""}`,
211
+ onClick: () => {
212
+ const I = a();
213
+ !I || !Ra(I) || (k(!0), window.setTimeout(() => k(!1), 1600));
214
+ },
215
+ title: m,
216
+ "aria-label": m,
217
+ children: f ? /* @__PURE__ */ e(Pt, {}) : /* @__PURE__ */ e(dn, {})
218
+ }
219
+ );
220
+ }
221
+ const Dt = [
222
+ "查看当前目录的文件列表",
223
+ "总结当前目录里各文件的内容",
224
+ "帮我写一个脚本统计各文件的行数",
225
+ "说明一下你能使用哪些工具"
226
+ ];
227
+ function en({
228
+ agent: a,
229
+ newSessionTrigger: d = 0,
230
+ autoSendDraft: m = null,
231
+ onAutoSendConsumed: f,
232
+ openSessionId: k = null,
233
+ onOpenSessionConsumed: I
234
+ }) {
235
+ var ot;
236
+ const b = Ke((n) => n.currentUser), D = zt(), [x, w] = p([]), [P, V] = p(""), [R, B] = p(null), [N, J] = p(""), F = O(!1), pe = De(() => {
237
+ const n = P.trim().toLowerCase();
238
+ return n ? x.filter((t) => t.title.toLowerCase().includes(n)) : x;
239
+ }, [x, P]), [S, L] = p(
240
+ null
241
+ ), [$, C] = p([]), [Q, j] = p(""), [H, he] = p(!1), T = O(!1), W = O(null), [Ne, ge] = p(null), G = O(null), fe = O(null), ce = O(null);
242
+ M(() => {
243
+ ce.current = S;
244
+ }, [S]);
245
+ const ye = O(/* @__PURE__ */ new Map()), xe = O(null), Re = (n) => {
246
+ T.current = n, he(n);
247
+ }, [ve, oe] = p(!1), [Ce, Y] = p(""), [ke, _e] = p(!1), [Te, re] = p(!1), [ee, de] = p(""), [we, Ee] = p(
248
+ () => localStorage.getItem("ft_local_session_collapsed") !== "false"
249
+ ), [Qe, Oe] = p(!0), [l, v] = p(!1), [E, te] = p(null), ne = O(null), se = O(null), $e = O(null), Ie = O(null), Se = O(!0), Xe = O(!1), ue = O(null), Ve = U(
250
+ (n, t) => {
251
+ const s = ue.current;
252
+ if (s && s.sid === n) {
253
+ s.messages = t(s.messages), ce.current === n && C(s.messages);
254
+ return;
255
+ }
256
+ C((u) => t(u));
257
+ },
258
+ []
259
+ ), nt = H ? ((ot = ue.current) == null ? void 0 : ot.sid) ?? null : null, Ae = U(async () => {
260
+ try {
261
+ const n = await Ut(a == null ? void 0 : a.localAgentId);
262
+ return w(n), Oe(!0), n;
263
+ } catch {
264
+ return Oe(!1), w([]), [];
265
+ }
266
+ }, [a == null ? void 0 : a.localAgentId]);
267
+ M(() => {
268
+ L(null), C([]), V(""), Ae().then((n) => {
269
+ if (n.length > 0) {
270
+ const t = [...n].sort(
271
+ (s, u) => new Date(u.updatedAt).getTime() - new Date(s.updatedAt).getTime()
272
+ )[0];
273
+ L(t.id);
274
+ }
275
+ });
276
+ }, [Ae]), M(() => {
277
+ d > 0 && (async () => {
278
+ try {
279
+ const n = await _t(
280
+ "新会话",
281
+ a == null ? void 0 : a.localAgentId
282
+ );
283
+ w((t) => [n, ...t]), L(n.id), C([]), V("");
284
+ } catch {
285
+ re(!0), de("");
286
+ }
287
+ })();
288
+ }, [d]);
289
+ const st = O(!1);
290
+ M(() => {
291
+ !m || st.current || (st.current = !0, f == null || f(), Ue(m));
292
+ }, []);
293
+ const ae = O(null);
294
+ M(() => {
295
+ !k || ae.current === k || (ae.current = k, L(k), I == null || I());
296
+ }, [k, I]), M(() => {
297
+ const n = xe.current;
298
+ if (n != null && n !== S) {
299
+ ye.current.set(n, Q);
300
+ const u = ye.current.get(S ?? "") ?? "";
301
+ j(u), requestAnimationFrame(() => {
302
+ const o = se.current;
303
+ o && (o.style.height = "auto", o.style.height = Math.min(o.scrollHeight, 180) + "px");
304
+ });
305
+ }
306
+ if (xe.current = S, !S) {
307
+ C([]);
308
+ return;
309
+ }
310
+ const t = ue.current;
311
+ if (t && t.sid === S) {
312
+ if (Se.current = !0, C(t.messages), t.messages.some((u) => u.streaming || u.error)) return;
313
+ ue.current = null;
314
+ }
315
+ if (Xe.current) {
316
+ Xe.current = !1;
317
+ return;
318
+ }
319
+ let s = !1;
320
+ return oe(!0), Mn(S).then((u) => {
321
+ s || C(At(u.messages));
322
+ }).catch(() => {
323
+ s || C([]);
324
+ }).finally(() => {
325
+ s || oe(!1);
326
+ }), () => {
327
+ s = !0;
328
+ };
329
+ }, [S]), M(() => {
330
+ Se.current && ne.current && (ne.current.scrollTop = ne.current.scrollHeight);
331
+ }, [$]);
332
+ const Je = U(() => {
333
+ const n = ne.current;
334
+ if (!n) return;
335
+ const t = n.scrollHeight - n.scrollTop - n.clientHeight;
336
+ Se.current = t < 80, v(t > 120);
337
+ }, []), at = U(() => {
338
+ const n = ne.current;
339
+ n && (n.scrollTop = n.scrollHeight), Se.current = !0, v(!1);
340
+ }, []);
341
+ M(() => {
342
+ localStorage.setItem(
343
+ "ft_local_session_collapsed",
344
+ we ? "true" : "false"
345
+ );
346
+ }, [we]);
347
+ const Z = async () => {
348
+ const n = ee.trim() || "新会话";
349
+ try {
350
+ const t = await _t(n, a == null ? void 0 : a.localAgentId);
351
+ w((s) => [t, ...s]), L(t.id), C([]), re(!1), de(""), V("");
352
+ } catch {
353
+ }
354
+ }, me = (n) => {
355
+ B(n.id), J(n.title), F.current = !1;
356
+ }, K = async () => {
357
+ if (F.current) return;
358
+ F.current = !0;
359
+ const n = R, t = N.trim();
360
+ if (B(null), !(!n || !t))
361
+ try {
362
+ await Rn(n, t), w(
363
+ (s) => s.map((u) => u.id === n ? { ...u, title: t } : u)
364
+ );
365
+ } catch {
366
+ }
367
+ }, lt = async (n) => {
368
+ if (window.confirm("确定删除此会话吗?")) {
369
+ T.current && Ie.current === n && Pe();
370
+ try {
371
+ await wn(n), w((t) => t.filter((s) => s.id !== n)), S === n && (L(null), C([]));
372
+ } catch {
373
+ }
374
+ }
375
+ }, Ge = U(
376
+ (n, t, s, u) => {
377
+ Ve(
378
+ n,
379
+ (o) => o.map((y) => {
380
+ if (y.id !== t) return y;
381
+ const _ = Date.now();
382
+ let g = {};
383
+ s === "thinking" && y.thinkingStartMs == null ? g = { thinkingStartMs: _ } : s === "text" && y.thinkingStartMs != null && y.thinkingMs == null && (g = { thinkingMs: _ - y.thinkingStartMs });
384
+ const A = [...y.blocks], X = A[A.length - 1];
385
+ return X != null && (s === "text" && X.type === "text" || s === "thinking" && X.type === "thinking") && X ? A[A.length - 1] = {
386
+ ...X,
387
+ text: X.text + u
388
+ } : A.push({ type: s, text: u }), { ...y, ...g, blocks: A };
389
+ })
390
+ );
391
+ },
392
+ [Ve]
393
+ ), He = U(
394
+ (n, t, s) => {
395
+ Ve(
396
+ n,
397
+ (u) => u.map((o) => {
398
+ if (o.id !== t) return o;
399
+ const y = Date.now(), _ = o.thinkingStartMs != null && o.thinkingMs == null ? { thinkingMs: y - o.thinkingStartMs } : {}, g = [...o.blocks];
400
+ if (s.kind === "tool_call")
401
+ g.push({
402
+ type: "tool_call",
403
+ id: s.id,
404
+ name: s.name,
405
+ input: s.input,
406
+ _t0: y
407
+ });
408
+ else if (s.kind === "tool_end")
409
+ for (let A = g.length - 1; A >= 0; A--) {
410
+ const X = g[A];
411
+ if (X.type === "tool_call" && s.id && X.id === s.id) {
412
+ g[A] = { ...X, input: s.input };
413
+ break;
414
+ }
415
+ }
416
+ else s.kind === "tool_result" && g.push({
417
+ type: "tool_result",
418
+ id: s.id,
419
+ content: s.content,
420
+ _t1: y
421
+ });
422
+ return { ...o, ..._, blocks: g };
423
+ })
424
+ );
425
+ },
426
+ [Ve]
427
+ ), Pe = U(() => {
428
+ var o;
429
+ const n = Ie.current;
430
+ Ie.current = null, (o = $e.current) == null || o.abort(), $e.current = null, Re(!1), n && xn(n).catch(() => {
431
+ });
432
+ const t = ue.current;
433
+ ue.current = null;
434
+ const s = (y) => y.map(
435
+ (_) => _.streaming ? {
436
+ ..._,
437
+ streaming: !1,
438
+ stopped: !0,
439
+ // 停止回合也结算耗时(与 onComplete 一致),避免「已停止生成」缺耗时显示
440
+ durationMs: _.startedAtMs != null ? Date.now() - _.startedAtMs : void 0
441
+ } : _
442
+ );
443
+ t && n && t.sid === n ? ce.current === n && C(s(t.messages)) : C((y) => s(y));
444
+ const u = G.current;
445
+ G.current = null, fe.current = null, ge(null), u && j((y) => y ? y + `
446
+ ` + u : u);
447
+ }, []);
448
+ M(() => {
449
+ const n = (t) => {
450
+ if (t.key !== "Escape" || t.isComposing) return;
451
+ const s = t.target;
452
+ s && (s.tagName === "TEXTAREA" || s.tagName === "INPUT") || (H ? (t.preventDefault(), Pe()) : E != null && (t.preventDefault(), te(null), se.current && (se.current.style.height = "auto")));
453
+ };
454
+ return document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
455
+ }, [H, E, Pe]);
456
+ const Be = async (n, t) => {
457
+ const s = t ?? S;
458
+ if (!s || !n || T.current) return;
459
+ W.current = null;
460
+ const u = {
461
+ id: `local-user-${Date.now()}`,
462
+ role: "user",
463
+ blocks: [{ type: "text", text: n }]
464
+ }, o = `local-assistant-${Date.now()}`, y = {
465
+ id: o,
466
+ role: "assistant",
467
+ blocks: [],
468
+ streaming: !0,
469
+ startedAtMs: Date.now()
470
+ };
471
+ C((g) => {
472
+ const A = [...g, u, y];
473
+ return ue.current = { sid: s, messages: A }, A;
474
+ }), Re(!0), Ie.current = s, Se.current = !0;
475
+ const _ = new AbortController();
476
+ $e.current = _, await En(
477
+ s,
478
+ n,
479
+ {
480
+ onToken: (g) => Ge(s, o, "text", g),
481
+ onReasoning: (g) => Ge(s, o, "thinking", g),
482
+ onEvent: (g) => He(s, o, g),
483
+ onFinal: (g) => {
484
+ W.current = g;
485
+ },
486
+ onError: (g) => {
487
+ W.current = null, Re(!1), $e.current = null, Ie.current = null;
488
+ const A = ue.current, X = (be) => be.map(
489
+ (ie) => ie.id === o ? {
490
+ ...ie,
491
+ streaming: !1,
492
+ // 出错回合也结算耗时(重发/重试前能看到该回合跑了多久)
493
+ durationMs: ie.startedAtMs != null ? Date.now() - ie.startedAtMs : void 0,
494
+ error: ie.blocks.length ? g.message : `[错误] ${g.message}`
495
+ } : ie
496
+ );
497
+ A && A.sid === s ? (A.messages = X(A.messages), ce.current === s && C(A.messages)) : C((be) => X(be));
498
+ const Le = G.current;
499
+ G.current = null, fe.current = null, ge(null), Le && j((be) => be ? be + `
500
+ ` + Le : Le);
501
+ },
502
+ onComplete: () => {
503
+ Re(!1), $e.current = null, Ie.current = null;
504
+ const g = W.current;
505
+ W.current = null;
506
+ const A = ue.current;
507
+ ue.current = null;
508
+ const X = (ie) => ie.map(
509
+ (Fe) => Fe.id === o ? {
510
+ ...Fe,
511
+ streaming: !1,
512
+ durationMs: (g == null ? void 0 : g.totalMs) ?? (Fe.startedAtMs != null ? Date.now() - Fe.startedAtMs : void 0),
513
+ totalMs: (g == null ? void 0 : g.totalMs) ?? Fe.totalMs,
514
+ stopped: Fe.stopped || (g == null ? void 0 : g.stopped) === !0,
515
+ usage: Fe.usage ?? (g == null ? void 0 : g.usage)
516
+ } : Fe
517
+ );
518
+ A && A.sid === s ? ce.current === s && C(X(A.messages)) : C((ie) => X(ie));
519
+ const Le = G.current, be = fe.current;
520
+ G.current = null, fe.current = null, ge(null), Le && (be && ce.current === be ? Be(Le, be) : j((ie) => ie ? ie + `
521
+ ` + Le : Le));
522
+ }
523
+ },
524
+ {
525
+ agentType: a == null ? void 0 : a.localAgentType,
526
+ agentId: a == null ? void 0 : a.localAgentId,
527
+ signal: _.signal
528
+ }
529
+ );
530
+ }, Ye = async (n, t) => {
531
+ if (S)
532
+ try {
533
+ const { session: s, previousId: u } = await On(
534
+ S,
535
+ n
536
+ );
537
+ Xe.current = !0, w(
538
+ (o) => o.map((y) => y.id === u ? s : y)
539
+ ), L(s.id), C(At(s.messages)), await Be(t, s.id);
540
+ } catch {
541
+ await Be(t);
542
+ }
543
+ }, pt = (n, t) => {
544
+ H || (j(t), te(n), requestAnimationFrame(() => {
545
+ const s = se.current;
546
+ s && (s.focus(), s.style.height = "auto", s.style.height = Math.min(s.scrollHeight, 180) + "px");
547
+ }));
548
+ }, le = () => {
549
+ te(null), se.current && (se.current.style.height = "auto");
550
+ }, Ze = () => {
551
+ const n = G.current;
552
+ G.current = null, ge(null), n && j((t) => t ? t + `
553
+ ` + n : n);
554
+ }, Ue = async (n) => {
555
+ const t = (n ?? Ce).trim();
556
+ if (!(!t || ke || T.current)) {
557
+ _e(!0);
558
+ try {
559
+ const s = /* @__PURE__ */ new Date(), u = (_) => String(_).padStart(2, "0"), o = `${u(s.getMonth() + 1)}${u(s.getDate())} ${u(
560
+ s.getHours()
561
+ )}:${u(s.getMinutes())}`, y = await _t(o, a == null ? void 0 : a.localAgentId);
562
+ w((_) => [y, ..._]), L(y.id), C([]), Y(""), await Be(t, y.id);
563
+ } catch {
564
+ } finally {
565
+ _e(!1);
566
+ }
567
+ }
568
+ }, it = () => {
569
+ const n = Q.trim();
570
+ if (n) {
571
+ if (H) {
572
+ G.current = G.current ? G.current + `
573
+ ` + n : n, fe.current = S, ge(G.current), j(""), ye.current.delete(S ?? ""), se.current && (se.current.style.height = "auto");
574
+ return;
575
+ }
576
+ if (j(""), ye.current.delete(S ?? ""), se.current && (se.current.style.height = "auto"), E != null) {
577
+ const t = E;
578
+ te(null), Ye(t, n);
579
+ return;
580
+ }
581
+ Be(n);
582
+ }
583
+ }, ht = (n) => {
584
+ qt(n, D.sendKey) && !n.nativeEvent.isComposing && (n.preventDefault(), it()), n.key === "Escape" && (H ? Pe() : E != null && le());
585
+ }, gt = (n) => {
586
+ j(n.target.value);
587
+ const t = n.target;
588
+ t.style.height = "auto", t.style.height = Math.min(t.scrollHeight, 180) + "px";
589
+ }, ze = Lt("local-default");
590
+ Lt(
591
+ (b == null ? void 0 : b.username) || (b == null ? void 0 : b.display_name) || "user"
592
+ );
593
+ const et = (n) => {
594
+ const t = /* @__PURE__ */ new Map();
595
+ for (const o of n.blocks)
596
+ o.type === "tool_result" && o.id && t.set(o.id, o);
597
+ const s = /* @__PURE__ */ new Set();
598
+ for (const o of n.blocks)
599
+ o.type === "tool_call" && o.id && t.has(o.id) && s.add(o.id);
600
+ const u = [];
601
+ return n.blocks.forEach((o, y) => {
602
+ if (o.type === "thinking")
603
+ u.push(
604
+ /* @__PURE__ */ e(
605
+ ts,
606
+ {
607
+ text: o.text,
608
+ streaming: !!n.streaming,
609
+ startedAtMs: n.thinkingStartMs,
610
+ durationMs: n.thinkingMs ?? o.durationMs
611
+ },
612
+ y
613
+ )
614
+ );
615
+ else if (o.type === "tool_call") {
616
+ const _ = o.id ? t.get(o.id) : void 0, g = o._t0 != null && (_ == null ? void 0 : _._t1) != null ? Math.max(1, _._t1 - o._t0) : o.durationMs;
617
+ u.push(
618
+ /* @__PURE__ */ e(
619
+ ns,
620
+ {
621
+ call: o,
622
+ result: _,
623
+ running: !!n.streaming && _ === void 0,
624
+ durationMs: g,
625
+ startedAtMs: o._t0
626
+ },
627
+ y
628
+ )
629
+ );
630
+ } else if (o.type === "tool_result") {
631
+ if (o.id && s.has(o.id)) return;
632
+ u.push(
633
+ /* @__PURE__ */ e("div", { className: c.toolItem, children: /* @__PURE__ */ i("div", { className: c.toolBody, children: [
634
+ /* @__PURE__ */ e("div", { className: c.toolSectionLabel, children: "工具结果" }),
635
+ /* @__PURE__ */ e("pre", { className: c.toolPre, children: o.content || "(空)" })
636
+ ] }) }, y)
637
+ );
638
+ } else o.type === "text" && o.text && u.push(/* @__PURE__ */ e(Ma, { text: o.text }, y));
639
+ }), u;
640
+ };
641
+ if (!Qe)
642
+ return /* @__PURE__ */ e("div", { className: c.container, children: /* @__PURE__ */ e("div", { className: c.chatPanel, children: /* @__PURE__ */ e("div", { className: c.chatEmpty, children: "本地 Agent 未启动,请检查桌面端是否正常运行" }) }) });
643
+ const ct = x.find((n) => n.id === S);
644
+ return /* @__PURE__ */ i("div", { className: c.container, children: [
645
+ we ? /* @__PURE__ */ e(
646
+ "button",
647
+ {
648
+ type: "button",
649
+ className: c.sessionExpandBtn,
650
+ onClick: () => Ee(!1),
651
+ title: "展开会话列表",
652
+ children: /* @__PURE__ */ e(Ht, {})
653
+ }
654
+ ) : /* @__PURE__ */ i("div", { className: c.sessionPanel, children: [
655
+ /* @__PURE__ */ i("div", { className: c.sessionHeader, children: [
656
+ /* @__PURE__ */ e("span", { children: "会话" }),
657
+ /* @__PURE__ */ i("div", { className: c.sessionHeaderActions, children: [
658
+ /* @__PURE__ */ e(
659
+ "button",
660
+ {
661
+ type: "button",
662
+ className: c.sessionBtnSm,
663
+ onClick: () => {
664
+ re(!0), de("");
665
+ },
666
+ title: "新建会话",
667
+ children: /* @__PURE__ */ e(sn, {})
668
+ }
669
+ ),
670
+ /* @__PURE__ */ e(
671
+ "button",
672
+ {
673
+ type: "button",
674
+ className: c.sessionBtnSm,
675
+ onClick: () => Ee(!0),
676
+ title: "收起会话列表",
677
+ children: /* @__PURE__ */ e(an, {})
678
+ }
679
+ )
680
+ ] })
681
+ ] }),
682
+ /* @__PURE__ */ i("div", { className: c.sessionSearchRow, children: [
683
+ /* @__PURE__ */ e(
684
+ "input",
685
+ {
686
+ className: c.sessionSearchInput,
687
+ type: "text",
688
+ placeholder: "搜索会话",
689
+ value: P,
690
+ onChange: (n) => V(n.target.value)
691
+ }
692
+ ),
693
+ P && /* @__PURE__ */ e(
694
+ "button",
695
+ {
696
+ type: "button",
697
+ className: c.sessionSearchClear,
698
+ onClick: () => V(""),
699
+ title: "清除搜索",
700
+ children: "✕"
701
+ }
702
+ )
703
+ ] }),
704
+ /* @__PURE__ */ i("div", { className: c.sessionList, children: [
705
+ Te && /* @__PURE__ */ i("div", { className: c.sessionCreateRow, children: [
706
+ /* @__PURE__ */ e(
707
+ "input",
708
+ {
709
+ className: c.sessionCreateInput,
710
+ type: "text",
711
+ placeholder: "输入会话名称",
712
+ value: ee,
713
+ autoFocus: !0,
714
+ onChange: (n) => de(n.target.value),
715
+ onKeyDown: (n) => {
716
+ n.key === "Enter" && Z(), n.key === "Escape" && (re(!1), de(""));
717
+ }
718
+ }
719
+ ),
720
+ /* @__PURE__ */ e(
721
+ "button",
722
+ {
723
+ type: "button",
724
+ className: c.sessionCreateConfirm,
725
+ onClick: () => void Z(),
726
+ title: "确认创建",
727
+ children: /* @__PURE__ */ e(Pt, {})
728
+ }
729
+ ),
730
+ /* @__PURE__ */ e(
731
+ "button",
732
+ {
733
+ type: "button",
734
+ className: c.sessionCreateCancel,
735
+ onClick: () => {
736
+ re(!1), de("");
737
+ },
738
+ title: "取消",
739
+ children: "✕"
740
+ }
741
+ )
742
+ ] }),
743
+ x.length === 0 && !Te ? /* @__PURE__ */ i("div", { className: c.sessionEmpty, children: [
744
+ /* @__PURE__ */ e("span", { children: "暂无会话" }),
745
+ /* @__PURE__ */ e("span", { children: "点击「+」开始聊天" })
746
+ ] }) : pe.length === 0 ? /* @__PURE__ */ i("div", { className: c.sessionEmpty, children: [
747
+ /* @__PURE__ */ e("span", { children: "无匹配会话" }),
748
+ /* @__PURE__ */ e("span", { children: "换个关键词试试" })
749
+ ] }) : pe.map((n) => /* @__PURE__ */ i(
750
+ "div",
751
+ {
752
+ className: `${c.sessionItem} ${S === n.id ? c.sessionItemActive : ""}`,
753
+ onClick: () => L(n.id),
754
+ children: [
755
+ R === n.id ? /* @__PURE__ */ e(
756
+ "input",
757
+ {
758
+ className: c.sessionRenameInput,
759
+ type: "text",
760
+ value: N,
761
+ autoFocus: !0,
762
+ onFocus: (t) => t.currentTarget.select(),
763
+ onClick: (t) => t.stopPropagation(),
764
+ onChange: (t) => J(t.target.value),
765
+ onKeyDown: (t) => {
766
+ t.key === "Enter" && K(), t.key === "Escape" && (F.current = !0, B(null));
767
+ },
768
+ onBlur: () => void K()
769
+ }
770
+ ) : /* @__PURE__ */ i(
771
+ "span",
772
+ {
773
+ className: c.sessionItemTitle,
774
+ title: n.title,
775
+ onDoubleClick: () => me(n),
776
+ children: [
777
+ n.id === nt && /* @__PURE__ */ e(
778
+ Tt,
779
+ {
780
+ spin: !0,
781
+ className: c.sessionLiveDot
782
+ }
783
+ ),
784
+ n.title
785
+ ]
786
+ }
787
+ ),
788
+ R !== n.id && /* @__PURE__ */ e("span", { className: c.sessionItemTime, children: La(n.updatedAt) }),
789
+ /* @__PURE__ */ e(
790
+ "button",
791
+ {
792
+ type: "button",
793
+ className: c.sessionRenameBtn,
794
+ onClick: (t) => {
795
+ t.stopPropagation(), me(n);
796
+ },
797
+ title: "重命名会话",
798
+ children: /* @__PURE__ */ e(wt, {})
799
+ }
800
+ ),
801
+ /* @__PURE__ */ e(
802
+ "button",
803
+ {
804
+ type: "button",
805
+ className: c.sessionDeleteBtn,
806
+ onClick: (t) => {
807
+ t.stopPropagation(), lt(n.id);
808
+ },
809
+ title: "删除会话",
810
+ children: /* @__PURE__ */ e(ln, {})
811
+ }
812
+ )
813
+ ]
814
+ },
815
+ n.id
816
+ ))
817
+ ] })
818
+ ] }),
819
+ /* @__PURE__ */ i("div", { className: c.chatPanel, children: [
820
+ /* @__PURE__ */ i("div", { className: c.chatHeader, children: [
821
+ /* @__PURE__ */ e(
822
+ "div",
823
+ {
824
+ className: c.agentAvatar,
825
+ style: { backgroundColor: ze },
826
+ children: vt((a == null ? void 0 : a.displayName) || "本地 Agent")
827
+ }
828
+ ),
829
+ /* @__PURE__ */ i("div", { className: c.chatHeaderMeta, children: [
830
+ /* @__PURE__ */ e("span", { className: c.chatHeaderName, children: (a == null ? void 0 : a.displayName) || "本地 Agent" }),
831
+ ct && /* @__PURE__ */ e("span", { className: c.chatHeaderSession, children: ct.title })
832
+ ] }),
833
+ /* @__PURE__ */ e("span", { className: c.chatHeaderBadge, children: (a == null ? void 0 : a.localAgentType) === "jar" ? "内置模型" : a == null ? void 0 : a.localAgentType }),
834
+ H && /* @__PURE__ */ i("span", { className: c.streamingIndicator, children: [
835
+ /* @__PURE__ */ e(Tt, {}),
836
+ " 工作中…"
837
+ ] })
838
+ ] }),
839
+ S ? /* @__PURE__ */ i(Me, { children: [
840
+ /* @__PURE__ */ e(
841
+ "div",
842
+ {
843
+ className: c.threadScroll,
844
+ ref: ne,
845
+ onScroll: Je,
846
+ children: /* @__PURE__ */ e("div", { className: c.threadInner, children: ve && $.length === 0 ? /* @__PURE__ */ e("div", { className: c.chatEmpty, children: "加载中…" }) : $.length === 0 ? /* @__PURE__ */ i("div", { className: c.landing, children: [
847
+ /* @__PURE__ */ e(
848
+ "div",
849
+ {
850
+ className: c.landingLogo,
851
+ style: { backgroundColor: ze },
852
+ children: vt((a == null ? void 0 : a.displayName) || "本地 Agent")
853
+ }
854
+ ),
855
+ /* @__PURE__ */ i("div", { className: c.landingTitle, children: [
856
+ "与 ",
857
+ (a == null ? void 0 : a.displayName) || "本地 Agent",
858
+ " 协作"
859
+ ] }),
860
+ /* @__PURE__ */ e("div", { className: c.landingHint, children: "思考过程与工具调用实时可见 · Enter 发送 · Esc 停止" }),
861
+ /* @__PURE__ */ e("div", { className: c.landingChips, children: Dt.map((n) => /* @__PURE__ */ e(
862
+ "button",
863
+ {
864
+ type: "button",
865
+ className: c.landingChip,
866
+ onClick: () => void Be(n),
867
+ children: n
868
+ },
869
+ n
870
+ )) })
871
+ ] }) : $.map(
872
+ (n, t) => n.role === "user" ? /* @__PURE__ */ i("div", { className: c.userRow, children: [
873
+ /* @__PURE__ */ e("div", { className: c.userBubble, children: qe(n.blocks) }),
874
+ !H && /* @__PURE__ */ i("div", { className: c.userActions, children: [
875
+ /* @__PURE__ */ e(
876
+ kt,
877
+ {
878
+ inline: !0,
879
+ label: "复制",
880
+ getText: () => qe(n.blocks)
881
+ }
882
+ ),
883
+ /* @__PURE__ */ e(
884
+ "button",
885
+ {
886
+ type: "button",
887
+ className: c.userActionBtn,
888
+ title: "编辑重发(其后内容将被截断)",
889
+ "aria-label": "编辑重发",
890
+ onClick: () => pt(t, qe(n.blocks)),
891
+ children: /* @__PURE__ */ e(wt, {})
892
+ }
893
+ ),
894
+ /* @__PURE__ */ e(
895
+ "button",
896
+ {
897
+ type: "button",
898
+ className: c.userActionBtn,
899
+ title: "重发(截断后原样重发)",
900
+ "aria-label": "重发",
901
+ onClick: () => void Ye(
902
+ t,
903
+ qe(n.blocks)
904
+ ),
905
+ children: /* @__PURE__ */ e(cn, {})
906
+ }
907
+ )
908
+ ] })
909
+ ] }, n.id) : /* @__PURE__ */ i("div", { className: c.assistantBlock, children: [
910
+ et(n),
911
+ n.streaming && n.startedAtMs != null && /* @__PURE__ */ e(xa, { startedAtMs: n.startedAtMs }),
912
+ n.streaming && n.blocks.every(
913
+ (s) => s.type !== "tool_call" && s.type !== "thinking"
914
+ ) && /* @__PURE__ */ e("span", { className: c.caretCursor }),
915
+ !n.streaming && (n.durationMs != null || n.totalMs != null) && /* @__PURE__ */ i("div", { className: c.msgMeta, children: [
916
+ ((n.durationMs ?? n.totalMs) / 1e3).toFixed(1),
917
+ "s",
918
+ (() => {
919
+ var y, _;
920
+ const s = ((y = n.usage) == null ? void 0 : y.inputTokens) ?? 0, u = ((_ = n.usage) == null ? void 0 : _.outputTokens) ?? 0, o = s + u;
921
+ return o > 0 ? ` · ${Ba(o)} tokens` : "";
922
+ })()
923
+ ] }),
924
+ !n.streaming && /* @__PURE__ */ e(
925
+ kt,
926
+ {
927
+ getText: () => qe(n.blocks)
928
+ }
929
+ ),
930
+ n.error && /* @__PURE__ */ i("div", { className: c.errorBar, children: [
931
+ n.error,
932
+ !H && E == null && /* @__PURE__ */ e(
933
+ "button",
934
+ {
935
+ type: "button",
936
+ className: c.errorRetryBtn,
937
+ title: "重试:重发上一条用户消息(其后内容截断)",
938
+ onClick: () => {
939
+ let s = t - 1;
940
+ for (; s >= 0 && $[s].role !== "user"; )
941
+ s--;
942
+ s >= 0 && Ye(
943
+ s,
944
+ qe($[s].blocks)
945
+ );
946
+ },
947
+ children: "重试"
948
+ }
949
+ )
950
+ ] }),
951
+ n.stopped && /* @__PURE__ */ e("div", { className: c.stoppedBar, children: "已停止生成" })
952
+ ] }, n.id)
953
+ ) })
954
+ }
955
+ ),
956
+ /* @__PURE__ */ e(
957
+ "button",
958
+ {
959
+ type: "button",
960
+ className: `${c.scrollTopBtn} ${l ? c.scrollTopBtnVisible : ""}`,
961
+ onClick: at,
962
+ title: "回到最新消息",
963
+ "aria-label": "回到最新消息",
964
+ children: /* @__PURE__ */ e(on, {})
965
+ }
966
+ ),
967
+ /* @__PURE__ */ i("div", { className: c.composerWrap, children: [
968
+ E != null && /* @__PURE__ */ i("div", { className: c.editingBar, children: [
969
+ /* @__PURE__ */ e("span", { children: "正在编辑历史消息:发送后其后内容将被丢弃,并以全新上下文重发" }),
970
+ /* @__PURE__ */ e(
971
+ "button",
972
+ {
973
+ type: "button",
974
+ className: c.editingCancel,
975
+ onClick: le,
976
+ title: "取消编辑",
977
+ children: "取消"
978
+ }
979
+ )
980
+ ] }),
981
+ Ne != null && /* @__PURE__ */ i("div", { className: c.pendingBar, children: [
982
+ /* @__PURE__ */ i("span", { children: [
983
+ "已排队:「",
984
+ Ne.slice(0, 30),
985
+ Ne.length > 30 ? "…" : "",
986
+ "」生成结束后自动发送"
987
+ ] }),
988
+ /* @__PURE__ */ e(
989
+ "button",
990
+ {
991
+ type: "button",
992
+ className: c.editingCancel,
993
+ onClick: Ze,
994
+ title: "取消排队消息(回填输入框)",
995
+ children: "取消"
996
+ }
997
+ )
998
+ ] }),
999
+ /* @__PURE__ */ i("div", { className: c.composer, children: [
1000
+ /* @__PURE__ */ e(
1001
+ "textarea",
1002
+ {
1003
+ ref: se,
1004
+ className: c.composerInput,
1005
+ placeholder: H ? S === nt ? "正在工作中…(Esc 停止)" : "后台回合进行中,输入将排队发送" : "向 Agent 发消息,Enter 发送,Shift+Enter 换行",
1006
+ value: Q,
1007
+ onChange: gt,
1008
+ onKeyDown: ht,
1009
+ rows: 1
1010
+ }
1011
+ ),
1012
+ H ? /* @__PURE__ */ e(
1013
+ "button",
1014
+ {
1015
+ type: "button",
1016
+ className: c.stopBtn,
1017
+ onClick: Pe,
1018
+ title: "停止生成(Esc)",
1019
+ "aria-label": "停止生成",
1020
+ children: /* @__PURE__ */ e(rn, {})
1021
+ }
1022
+ ) : /* @__PURE__ */ e(
1023
+ "button",
1024
+ {
1025
+ type: "button",
1026
+ className: `${c.sendBtn} ${Q.trim() ? c.sendBtnReady : ""}`,
1027
+ disabled: !Q.trim(),
1028
+ onClick: it,
1029
+ title: "发送",
1030
+ "aria-label": "发送",
1031
+ children: /* @__PURE__ */ e(It, {})
1032
+ }
1033
+ )
1034
+ ] }),
1035
+ /* @__PURE__ */ e("div", { className: c.composerHint, children: H ? "Agent 正在工作中,可按 Esc 或点击停止按钮中断" : "Enter 发送 · Shift+Enter 换行 · 思考与工具调用自动展示" })
1036
+ ] })
1037
+ ] }) : x.length === 0 ? (
1038
+ /* 无会话:居中大输入框,发送自动建会话(时间戳命名) */
1039
+ /* @__PURE__ */ i("div", { className: c.newChatLanding, children: [
1040
+ /* @__PURE__ */ e(
1041
+ "div",
1042
+ {
1043
+ className: c.landingLogo,
1044
+ style: { backgroundColor: ze },
1045
+ children: vt((a == null ? void 0 : a.displayName) || "本地 Agent")
1046
+ }
1047
+ ),
1048
+ /* @__PURE__ */ i("div", { className: c.landingTitle, children: [
1049
+ "与 ",
1050
+ (a == null ? void 0 : a.displayName) || "本地 Agent",
1051
+ " 协作"
1052
+ ] }),
1053
+ /* @__PURE__ */ e("div", { className: c.landingHint, children: "输入即自动创建会话 · Enter 发送 · Esc 停止" }),
1054
+ /* @__PURE__ */ i("div", { className: c.landingComposer, children: [
1055
+ /* @__PURE__ */ e(
1056
+ "textarea",
1057
+ {
1058
+ className: c.landingInput,
1059
+ placeholder: "描述你的任务,发送后自动创建会话…",
1060
+ value: Ce,
1061
+ autoFocus: !0,
1062
+ onChange: (n) => Y(n.target.value),
1063
+ onKeyDown: (n) => {
1064
+ n.key === "Enter" && !n.shiftKey && !n.nativeEvent.isComposing && (n.preventDefault(), Ue());
1065
+ },
1066
+ rows: 3
1067
+ }
1068
+ ),
1069
+ /* @__PURE__ */ e(
1070
+ "button",
1071
+ {
1072
+ type: "button",
1073
+ className: `${c.sendBtn} ${Ce.trim() && !ke ? c.sendBtnReady : ""}`,
1074
+ disabled: !Ce.trim() || ke,
1075
+ onClick: () => void Ue(),
1076
+ title: "发送并创建会话",
1077
+ "aria-label": "发送并创建会话",
1078
+ children: /* @__PURE__ */ e(It, {})
1079
+ }
1080
+ )
1081
+ ] }),
1082
+ /* @__PURE__ */ e("div", { className: c.landingChips, children: Dt.map((n) => /* @__PURE__ */ e(
1083
+ "button",
1084
+ {
1085
+ type: "button",
1086
+ className: c.landingChip,
1087
+ onClick: () => void Ue(n),
1088
+ children: n
1089
+ },
1090
+ n
1091
+ )) })
1092
+ ] })
1093
+ ) : /* @__PURE__ */ e("div", { className: c.chatEmpty, children: "请在左侧选择或创建一个会话" })
1094
+ ] })
1095
+ ] });
1096
+ }
1097
+ const Ea = "_sidebarInner_1vu3c_1", Oa = "_header_1vu3c_8", $a = "_headerActions_1vu3c_19", Ha = "_tabBar_1vu3c_26", Pa = "_tab_1vu3c_26", Fa = "_tabActive_1vu3c_50", ja = "_btnSm_1vu3c_66", Wa = "_agentSection_1vu3c_84", Ka = "_agentItem_1vu3c_90", Ua = "_agentItemActive_1vu3c_112", Va = "_agentAvatar_1vu3c_117", Ga = "_agentName_1vu3c_130", za = "_emptyState_1vu3c_156", qa = "_createInputRow_1vu3c_168", Qa = "_createInput_1vu3c_168", Xa = "_createConfirmBtn_1vu3c_188", Ja = "_contextMenu_1vu3c_205", Ya = "_contextMenuItem_1vu3c_216", Za = "_contextMenuItemDanger_1vu3c_231", el = "_contextMenuDivider_1vu3c_239", tl = "_renameOverlay_1vu3c_246", nl = "_renameDialog_1vu3c_259", sl = "_renameTitle_1vu3c_267", al = "_renameInput_1vu3c_274", ll = "_renameActions_1vu3c_289", il = "_renameBtn_1vu3c_295", cl = "_renameBtnPrimary_1vu3c_309", ol = "_agentDetailBtn_1vu3c_326", rl = "_agentItemShared_1vu3c_358", dl = "_agentInfo_1vu3c_362", ul = "_agentOwner_1vu3c_374", ml = "_sharedBadge_1vu3c_382", pl = "_createLocalDialog_1vu3c_430", hl = "_createLocalLabel_1vu3c_438", gl = "_agentTypeCards_1vu3c_446", _l = "_agentTypeCard_1vu3c_446", fl = "_agentTypeIcon_1vu3c_474", yl = "_agentTypeBody_1vu3c_487", vl = "_agentTypeTitle_1vu3c_494", bl = "_agentTypeDesc_1vu3c_500", Nl = "_agentTypeBadge_1vu3c_506", r = {
1098
+ sidebarInner: Ea,
1099
+ header: Oa,
1100
+ headerActions: $a,
1101
+ tabBar: Ha,
1102
+ tab: Pa,
1103
+ tabActive: Fa,
1104
+ btnSm: ja,
1105
+ agentSection: Wa,
1106
+ agentItem: Ka,
1107
+ agentItemActive: Ua,
1108
+ agentAvatar: Va,
1109
+ agentName: Ga,
1110
+ emptyState: za,
1111
+ createInputRow: qa,
1112
+ createInput: Qa,
1113
+ createConfirmBtn: Xa,
1114
+ contextMenu: Ja,
1115
+ contextMenuItem: Ya,
1116
+ contextMenuItemDanger: Za,
1117
+ contextMenuDivider: el,
1118
+ renameOverlay: tl,
1119
+ renameDialog: nl,
1120
+ renameTitle: sl,
1121
+ renameInput: al,
1122
+ renameActions: ll,
1123
+ renameBtn: il,
1124
+ renameBtnPrimary: cl,
1125
+ agentDetailBtn: ol,
1126
+ agentItemShared: rl,
1127
+ agentInfo: dl,
1128
+ agentOwner: ul,
1129
+ sharedBadge: ml,
1130
+ createLocalDialog: pl,
1131
+ createLocalLabel: hl,
1132
+ agentTypeCards: gl,
1133
+ agentTypeCard: _l,
1134
+ agentTypeIcon: fl,
1135
+ agentTypeBody: yl,
1136
+ agentTypeTitle: vl,
1137
+ agentTypeDesc: bl,
1138
+ agentTypeBadge: Nl
1139
+ }, Mt = [
1140
+ "#2F70F1",
1141
+ "#52c41a",
1142
+ "#fa8c16",
1143
+ "#eb2f96",
1144
+ "#722ed1",
1145
+ "#13c2c2",
1146
+ "#f5222d",
1147
+ "#faad14"
1148
+ ];
1149
+ function xt(a) {
1150
+ let d = 0;
1151
+ for (let m = 0; m < a.length; m++) d = d * 31 + a.charCodeAt(m) | 0;
1152
+ return Mt[Math.abs(d) % Mt.length];
1153
+ }
1154
+ function Rt(a) {
1155
+ return a ? a.charAt(0).toUpperCase() : "?";
1156
+ }
1157
+ const dt = "-1";
1158
+ function Cl({
1159
+ selectedAgentId: a,
1160
+ selectedLocalAgentId: d,
1161
+ onSelectAgent: m,
1162
+ onShowDetail: f,
1163
+ onChatWithAgent: k
1164
+ }) {
1165
+ const I = Ke((l) => l.token), b = Ke((l) => l.personalChatNav), [D, x] = p(
1166
+ b.tab === "shared" ? "shared" : "remote"
1167
+ ), [w, P] = p([]), [V, R] = p(!1), [B, N] = p(!1), [J, F] = p(""), [pe, S] = p(!1), [L, $] = p(null), [C, Q] = p(null), [j, H] = p(!1), [he, T] = p([]), [W, Ne] = p(!1), [ge, G] = p(null), [fe, ce] = p(!1), [ye, xe] = p([]), [Re, ve] = p(!1), [oe, Ce] = p(!1), Y = O(null), ke = U(async () => {
1168
+ R(!0);
1169
+ try {
1170
+ const l = await Kt(I);
1171
+ P(l), a && !l.find((v) => tt(v.id, a)) && m(null);
1172
+ } catch {
1173
+ } finally {
1174
+ R(!1);
1175
+ }
1176
+ }, [I, a, m]), _e = U(async () => {
1177
+ Ne(!0);
1178
+ try {
1179
+ const l = await In(I);
1180
+ T(l);
1181
+ } catch {
1182
+ } finally {
1183
+ Ne(!1);
1184
+ }
1185
+ }, [I]);
1186
+ M(() => {
1187
+ b.trigger > 0 && b.tab && x(b.tab);
1188
+ }, [b.trigger]), M(() => {
1189
+ D === "remote" ? ke() : D === "shared" && _e();
1190
+ }, [ke, _e, D]);
1191
+ const Te = U(async () => {
1192
+ try {
1193
+ const l = await Vt();
1194
+ xe(l);
1195
+ } catch {
1196
+ xe([]);
1197
+ }
1198
+ }, []);
1199
+ M(() => {
1200
+ D === "local" && bt().then((l) => {
1201
+ ce(l), l && Te();
1202
+ });
1203
+ }, [D, Te]), M(() => {
1204
+ if (!L) return;
1205
+ const l = (v) => {
1206
+ Y.current && !Y.current.contains(v.target) && $(null);
1207
+ };
1208
+ return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
1209
+ }, [L]);
1210
+ const re = async () => {
1211
+ const l = J.trim();
1212
+ if (l) {
1213
+ S(!0);
1214
+ try {
1215
+ const v = await Sn(l, I);
1216
+ P((E) => [...E, v]), F(""), N(!1), m(v);
1217
+ } catch {
1218
+ } finally {
1219
+ S(!1);
1220
+ }
1221
+ }
1222
+ }, ee = async (l) => {
1223
+ if (l === "jar") {
1224
+ ve(!1), k({
1225
+ id: dt,
1226
+ userId: "local",
1227
+ agentHubAgentId: null,
1228
+ agentCode: "local-default",
1229
+ displayName: "本地 Agent",
1230
+ avatar: null,
1231
+ isLocal: !0
1232
+ });
1233
+ return;
1234
+ }
1235
+ if (!fe) {
1236
+ if (!await bt()) {
1237
+ rt.error(
1238
+ "本地 Agent 未启动,请通过菜单栏「重启 Agent」启动后再试"
1239
+ );
1240
+ return;
1241
+ }
1242
+ ce(!0);
1243
+ }
1244
+ Ce(!0);
1245
+ try {
1246
+ const v = l === "hermes" ? "hermes" : "claude-code";
1247
+ await $n(v, l), rt.success(`已引入 ${v},点击列表项即可开始对话`), ve(!1), await Te();
1248
+ } catch (v) {
1249
+ rt.error(
1250
+ v.message || "创建失败,请检查本地 Agent 是否正常运行"
1251
+ );
1252
+ } finally {
1253
+ Ce(!1);
1254
+ }
1255
+ }, de = async (l) => {
1256
+ if (window.confirm("确定删除此 Agent?"))
1257
+ try {
1258
+ await Hn(l), await Te();
1259
+ } catch (v) {
1260
+ rt.error(v.message || "删除失败");
1261
+ }
1262
+ }, we = async (l) => {
1263
+ if (window.confirm(
1264
+ `确定删除 Agent「${l.displayName}」吗?所有会话记录将一并删除。`
1265
+ ))
1266
+ try {
1267
+ await An(l.id, I), P((v) => v.filter((E) => E.id !== l.id)), tt(a, l.id) && m(null);
1268
+ } catch {
1269
+ }
1270
+ }, Ee = async () => {
1271
+ if (!C) return;
1272
+ const l = C.value.trim();
1273
+ if (!l || l === C.agent.displayName) {
1274
+ Q(null);
1275
+ return;
1276
+ }
1277
+ H(!0);
1278
+ try {
1279
+ const v = await Bn(
1280
+ C.agent.id,
1281
+ l,
1282
+ I
1283
+ );
1284
+ P((E) => E.map((te) => te.id === v.id ? v : te)), tt(a, v.id) && m(v), Q(null);
1285
+ } catch {
1286
+ } finally {
1287
+ H(!1);
1288
+ }
1289
+ }, Qe = async (l) => {
1290
+ const v = l.shared === 1;
1291
+ if (window.confirm(
1292
+ v ? `确定取消共享 Agent「${l.displayName}」吗?取消后其他用户将无法与此 Agent 聊天。` : `确定共享 Agent「${l.displayName}」吗?共享后其他用户可以与此 Agent 发起聊天。`
1293
+ )) {
1294
+ G(l.id);
1295
+ try {
1296
+ const E = await Ln(
1297
+ l.id,
1298
+ !v,
1299
+ I
1300
+ );
1301
+ P((te) => te.map((ne) => ne.id === E.id ? E : ne));
1302
+ } catch {
1303
+ } finally {
1304
+ G(null);
1305
+ }
1306
+ }
1307
+ }, Oe = (l, v) => {
1308
+ l.preventDefault(), l.stopPropagation(), $({ x: l.clientX, y: l.clientY, agent: v });
1309
+ };
1310
+ return /* @__PURE__ */ i("div", { className: r.sidebarInner, children: [
1311
+ /* @__PURE__ */ i("div", { className: r.header, children: [
1312
+ /* @__PURE__ */ e("span", { children: "个人 Agent" }),
1313
+ D === "remote" && /* @__PURE__ */ e("div", { className: r.headerActions, children: /* @__PURE__ */ e(
1314
+ "button",
1315
+ {
1316
+ type: "button",
1317
+ className: r.btnSm,
1318
+ onClick: () => {
1319
+ N((l) => !l), F("");
1320
+ },
1321
+ title: "新建个人 Agent",
1322
+ children: "+ 新建"
1323
+ }
1324
+ ) }),
1325
+ D === "local" && /* @__PURE__ */ e("div", { className: r.headerActions, children: /* @__PURE__ */ e(
1326
+ "button",
1327
+ {
1328
+ type: "button",
1329
+ className: r.btnSm,
1330
+ onClick: () => ve(!0),
1331
+ title: "新建本地 Agent",
1332
+ children: "+ 新增"
1333
+ }
1334
+ ) })
1335
+ ] }),
1336
+ /* @__PURE__ */ i("div", { className: r.tabBar, children: [
1337
+ /* @__PURE__ */ e(
1338
+ "button",
1339
+ {
1340
+ type: "button",
1341
+ className: `${r.tab} ${D === "local" ? r.tabActive : ""}`,
1342
+ onClick: () => x("local"),
1343
+ title: "本地 Agent",
1344
+ children: "本地"
1345
+ }
1346
+ ),
1347
+ /* @__PURE__ */ e(
1348
+ "button",
1349
+ {
1350
+ type: "button",
1351
+ className: `${r.tab} ${D === "remote" ? r.tabActive : ""}`,
1352
+ onClick: () => x("remote"),
1353
+ children: "远程"
1354
+ }
1355
+ ),
1356
+ /* @__PURE__ */ e(
1357
+ "button",
1358
+ {
1359
+ type: "button",
1360
+ className: `${r.tab} ${D === "shared" ? r.tabActive : ""}`,
1361
+ onClick: () => x("shared"),
1362
+ children: "共享"
1363
+ }
1364
+ )
1365
+ ] }),
1366
+ D === "local" ? /* @__PURE__ */ e("div", { className: r.agentSection, children: fe ? /* @__PURE__ */ e(Me, { children: ye.map((l) => /* @__PURE__ */ i(
1367
+ "div",
1368
+ {
1369
+ className: `${r.agentItem} ${tt(a, dt) && (l.type === "jar" && !d || d === l.id) ? r.agentItemActive : ""}`,
1370
+ onClick: () => {
1371
+ l.type === "jar" ? m({
1372
+ id: dt,
1373
+ userId: "local",
1374
+ agentHubAgentId: null,
1375
+ agentCode: "local-default",
1376
+ displayName: l.name,
1377
+ avatar: null,
1378
+ isLocal: !0
1379
+ }) : m({
1380
+ id: dt,
1381
+ userId: "local",
1382
+ agentHubAgentId: null,
1383
+ agentCode: l.name,
1384
+ displayName: l.name,
1385
+ avatar: null,
1386
+ isLocal: !0,
1387
+ localAgentId: l.id,
1388
+ localAgentType: l.type
1389
+ });
1390
+ },
1391
+ children: [
1392
+ /* @__PURE__ */ e(
1393
+ "div",
1394
+ {
1395
+ className: r.agentAvatar,
1396
+ style: {
1397
+ backgroundColor: l.type === "hermes" ? "#722ed1" : l.type === "claude-code" ? "#eb2f96" : "#52c41a"
1398
+ },
1399
+ children: l.type === "hermes" ? "H" : l.type === "claude-code" ? "C" : "L"
1400
+ }
1401
+ ),
1402
+ /* @__PURE__ */ e("span", { className: r.agentName, children: l.name }),
1403
+ l.type !== "jar" && /* @__PURE__ */ e(
1404
+ "button",
1405
+ {
1406
+ type: "button",
1407
+ className: r.agentDetailBtn,
1408
+ onClick: (v) => {
1409
+ v.stopPropagation(), de(l.id);
1410
+ },
1411
+ title: "删除",
1412
+ children: /* @__PURE__ */ e("span", { style: { fontSize: 14 }, children: "×" })
1413
+ }
1414
+ )
1415
+ ]
1416
+ },
1417
+ l.id
1418
+ )) }) : /* @__PURE__ */ i("div", { className: r.emptyState, children: [
1419
+ /* @__PURE__ */ e("span", { children: "本地 Agent 未启动" }),
1420
+ /* @__PURE__ */ e("span", { children: "请检查桌面端是否正常运行" })
1421
+ ] }) }) : D === "shared" ? /* @__PURE__ */ e("div", { className: r.agentSection, children: W && he.length === 0 ? /* @__PURE__ */ e("div", { className: r.emptyState, children: "加载中..." }) : he.length === 0 ? /* @__PURE__ */ i("div", { className: r.emptyState, children: [
1422
+ /* @__PURE__ */ e("span", { children: "暂无共享 Agent" }),
1423
+ /* @__PURE__ */ e("span", { children: "其他用户共享的 Agent 会显示在这里" })
1424
+ ] }) : he.map((l) => /* @__PURE__ */ i(
1425
+ "div",
1426
+ {
1427
+ className: `${r.agentItem} ${r.agentItemShared}`,
1428
+ onClick: () => k(l),
1429
+ title: `点击与「${l.displayName}」聊天`,
1430
+ children: [
1431
+ /* @__PURE__ */ e(
1432
+ "div",
1433
+ {
1434
+ className: r.agentAvatar,
1435
+ style: {
1436
+ backgroundColor: xt(
1437
+ l.agentCode || l.displayName
1438
+ )
1439
+ },
1440
+ children: Rt(l.displayName)
1441
+ }
1442
+ ),
1443
+ /* @__PURE__ */ i("div", { className: r.agentInfo, children: [
1444
+ /* @__PURE__ */ e("span", { className: r.agentName, children: l.displayName }),
1445
+ /* @__PURE__ */ i("span", { className: r.agentOwner, children: [
1446
+ "来自: ",
1447
+ l.userId
1448
+ ] })
1449
+ ] }),
1450
+ /* @__PURE__ */ e(
1451
+ "button",
1452
+ {
1453
+ type: "button",
1454
+ className: r.agentDetailBtn,
1455
+ onClick: (v) => {
1456
+ v.stopPropagation(), k(l);
1457
+ },
1458
+ title: "开始聊天",
1459
+ children: /* @__PURE__ */ e(Ft, { style: { fontSize: 12 } })
1460
+ }
1461
+ )
1462
+ ]
1463
+ },
1464
+ l.id
1465
+ )) }) : /* @__PURE__ */ i(Me, { children: [
1466
+ B && /* @__PURE__ */ i("div", { className: r.createInputRow, children: [
1467
+ /* @__PURE__ */ e(
1468
+ "input",
1469
+ {
1470
+ className: r.createInput,
1471
+ type: "text",
1472
+ placeholder: "输入 Agent 名称",
1473
+ value: J,
1474
+ autoFocus: !0,
1475
+ onChange: (l) => F(l.target.value),
1476
+ onKeyDown: (l) => {
1477
+ l.key === "Enter" && re(), l.key === "Escape" && (N(!1), F(""));
1478
+ }
1479
+ }
1480
+ ),
1481
+ /* @__PURE__ */ e(
1482
+ "button",
1483
+ {
1484
+ type: "button",
1485
+ className: r.createConfirmBtn,
1486
+ disabled: !J.trim() || pe,
1487
+ onClick: re,
1488
+ children: pe ? "..." : "创建"
1489
+ }
1490
+ )
1491
+ ] }),
1492
+ /* @__PURE__ */ e("div", { className: r.agentSection, children: V && w.length === 0 ? /* @__PURE__ */ e("div", { className: r.emptyState, children: "加载中..." }) : w.length === 0 ? /* @__PURE__ */ i("div", { className: r.emptyState, children: [
1493
+ /* @__PURE__ */ e("span", { children: "暂无个人 Agent" }),
1494
+ /* @__PURE__ */ e("span", { children: "点击「新建」创建一个" })
1495
+ ] }) : w.map((l) => /* @__PURE__ */ i(
1496
+ "div",
1497
+ {
1498
+ className: `${r.agentItem} ${tt(a, l.id) ? r.agentItemActive : ""}`,
1499
+ onClick: () => m(l),
1500
+ onContextMenu: (v) => Oe(v, l),
1501
+ children: [
1502
+ /* @__PURE__ */ e(
1503
+ "div",
1504
+ {
1505
+ className: r.agentAvatar,
1506
+ style: {
1507
+ backgroundColor: xt(
1508
+ l.agentCode || l.displayName
1509
+ )
1510
+ },
1511
+ children: Rt(l.displayName)
1512
+ }
1513
+ ),
1514
+ /* @__PURE__ */ i("span", { className: r.agentName, children: [
1515
+ l.displayName,
1516
+ l.shared === 1 && /* @__PURE__ */ e("span", { className: r.sharedBadge, children: "共享" })
1517
+ ] }),
1518
+ /* @__PURE__ */ e(
1519
+ "button",
1520
+ {
1521
+ type: "button",
1522
+ className: r.agentDetailBtn,
1523
+ onClick: (v) => {
1524
+ v.stopPropagation();
1525
+ const E = v.currentTarget.getBoundingClientRect();
1526
+ $({
1527
+ x: E.right - 120,
1528
+ y: E.bottom + 4,
1529
+ agent: l
1530
+ });
1531
+ },
1532
+ title: "更多操作",
1533
+ children: /* @__PURE__ */ e(un, { style: { fontSize: 14 } })
1534
+ }
1535
+ )
1536
+ ]
1537
+ },
1538
+ l.id
1539
+ )) })
1540
+ ] }),
1541
+ L && /* @__PURE__ */ i(
1542
+ "div",
1543
+ {
1544
+ ref: Y,
1545
+ className: r.contextMenu,
1546
+ style: { top: L.y, left: L.x },
1547
+ children: [
1548
+ /* @__PURE__ */ e(
1549
+ "div",
1550
+ {
1551
+ className: r.contextMenuItem,
1552
+ onClick: () => {
1553
+ k(L.agent), $(null);
1554
+ },
1555
+ children: "开始聊天"
1556
+ }
1557
+ ),
1558
+ /* @__PURE__ */ e(
1559
+ "div",
1560
+ {
1561
+ className: r.contextMenuItem,
1562
+ onClick: () => {
1563
+ f(L.agent), $(null);
1564
+ },
1565
+ children: "Agent 配置"
1566
+ }
1567
+ ),
1568
+ /* @__PURE__ */ e("div", { className: r.contextMenuDivider }),
1569
+ /* @__PURE__ */ e(
1570
+ "div",
1571
+ {
1572
+ className: r.contextMenuItem,
1573
+ onClick: () => {
1574
+ Q({
1575
+ agent: L.agent,
1576
+ value: L.agent.displayName
1577
+ }), $(null);
1578
+ },
1579
+ children: "重命名"
1580
+ }
1581
+ ),
1582
+ /* @__PURE__ */ e(
1583
+ "div",
1584
+ {
1585
+ className: r.contextMenuItem,
1586
+ onClick: () => {
1587
+ ge === null && Qe(L.agent), $(null);
1588
+ },
1589
+ children: L.agent.shared === 1 ? "取消共享" : "共享给他人"
1590
+ }
1591
+ ),
1592
+ /* @__PURE__ */ e("div", { className: r.contextMenuDivider }),
1593
+ /* @__PURE__ */ e(
1594
+ "div",
1595
+ {
1596
+ className: `${r.contextMenuItem} ${r.contextMenuItemDanger}`,
1597
+ onClick: () => {
1598
+ we(L.agent), $(null);
1599
+ },
1600
+ children: "删除"
1601
+ }
1602
+ )
1603
+ ]
1604
+ }
1605
+ ),
1606
+ Re && /* @__PURE__ */ e(
1607
+ "div",
1608
+ {
1609
+ className: r.renameOverlay,
1610
+ onClick: () => !oe && ve(!1),
1611
+ children: /* @__PURE__ */ i(
1612
+ "div",
1613
+ {
1614
+ className: r.createLocalDialog,
1615
+ onClick: (l) => l.stopPropagation(),
1616
+ children: [
1617
+ /* @__PURE__ */ e("div", { className: r.renameTitle, children: "新建本地 Agent" }),
1618
+ /* @__PURE__ */ e("div", { className: r.createLocalLabel, children: oe ? "正在创建..." : "点击选择,直接开始聊天" }),
1619
+ /* @__PURE__ */ i("div", { className: r.agentTypeCards, children: [
1620
+ /* @__PURE__ */ i(
1621
+ "div",
1622
+ {
1623
+ className: r.agentTypeCard,
1624
+ onClick: () => ee("jar"),
1625
+ children: [
1626
+ /* @__PURE__ */ e(
1627
+ "div",
1628
+ {
1629
+ className: r.agentTypeIcon,
1630
+ style: { backgroundColor: "#52c41a" },
1631
+ children: "L"
1632
+ }
1633
+ ),
1634
+ /* @__PURE__ */ i("div", { className: r.agentTypeBody, children: [
1635
+ /* @__PURE__ */ i("div", { className: r.agentTypeTitle, children: [
1636
+ "自研",
1637
+ " ",
1638
+ /* @__PURE__ */ e("span", { className: r.agentTypeBadge, children: "已运行" })
1639
+ ] }),
1640
+ /* @__PURE__ */ e("div", { className: r.agentTypeDesc, children: "自研 Java Agent,内置 ReAct 推理引擎与工具调用" })
1641
+ ] })
1642
+ ]
1643
+ }
1644
+ ),
1645
+ /* @__PURE__ */ i(
1646
+ "div",
1647
+ {
1648
+ className: r.agentTypeCard,
1649
+ onClick: () => ee("hermes"),
1650
+ children: [
1651
+ /* @__PURE__ */ e(
1652
+ "div",
1653
+ {
1654
+ className: r.agentTypeIcon,
1655
+ style: { backgroundColor: "#722ed1" },
1656
+ children: "H"
1657
+ }
1658
+ ),
1659
+ /* @__PURE__ */ i("div", { className: r.agentTypeBody, children: [
1660
+ /* @__PURE__ */ e("div", { className: r.agentTypeTitle, children: "Hermes" }),
1661
+ /* @__PURE__ */ e("div", { className: r.agentTypeDesc, children: "本地 Hermes CLI,支持 tool-calling 与多模型切换" })
1662
+ ] })
1663
+ ]
1664
+ }
1665
+ ),
1666
+ /* @__PURE__ */ i(
1667
+ "div",
1668
+ {
1669
+ className: r.agentTypeCard,
1670
+ onClick: () => ee("claude-code"),
1671
+ children: [
1672
+ /* @__PURE__ */ e(
1673
+ "div",
1674
+ {
1675
+ className: r.agentTypeIcon,
1676
+ style: { backgroundColor: "#eb2f96" },
1677
+ children: "C"
1678
+ }
1679
+ ),
1680
+ /* @__PURE__ */ i("div", { className: r.agentTypeBody, children: [
1681
+ /* @__PURE__ */ e("div", { className: r.agentTypeTitle, children: "Claude Code" }),
1682
+ /* @__PURE__ */ e("div", { className: r.agentTypeDesc, children: "Anthropic Claude CLI 编码助手" })
1683
+ ] })
1684
+ ]
1685
+ }
1686
+ )
1687
+ ] }),
1688
+ /* @__PURE__ */ e("div", { className: r.renameActions, children: /* @__PURE__ */ e(
1689
+ "button",
1690
+ {
1691
+ type: "button",
1692
+ className: r.renameBtn,
1693
+ onClick: () => ve(!1),
1694
+ disabled: oe,
1695
+ children: "取消"
1696
+ }
1697
+ ) })
1698
+ ]
1699
+ }
1700
+ )
1701
+ }
1702
+ ),
1703
+ C && /* @__PURE__ */ e(
1704
+ "div",
1705
+ {
1706
+ className: r.renameOverlay,
1707
+ onClick: () => !j && Q(null),
1708
+ children: /* @__PURE__ */ i(
1709
+ "div",
1710
+ {
1711
+ className: r.renameDialog,
1712
+ onClick: (l) => l.stopPropagation(),
1713
+ children: [
1714
+ /* @__PURE__ */ e("div", { className: r.renameTitle, children: "重命名 Agent" }),
1715
+ /* @__PURE__ */ e(
1716
+ "input",
1717
+ {
1718
+ className: r.renameInput,
1719
+ type: "text",
1720
+ value: C.value,
1721
+ autoFocus: !0,
1722
+ onChange: (l) => Q({ ...C, value: l.target.value }),
1723
+ onKeyDown: (l) => {
1724
+ l.key === "Enter" && Ee(), l.key === "Escape" && Q(null);
1725
+ }
1726
+ }
1727
+ ),
1728
+ /* @__PURE__ */ i("div", { className: r.renameActions, children: [
1729
+ /* @__PURE__ */ e(
1730
+ "button",
1731
+ {
1732
+ type: "button",
1733
+ className: r.renameBtn,
1734
+ onClick: () => Q(null),
1735
+ disabled: j,
1736
+ children: "取消"
1737
+ }
1738
+ ),
1739
+ /* @__PURE__ */ e(
1740
+ "button",
1741
+ {
1742
+ type: "button",
1743
+ className: r.renameBtnPrimary,
1744
+ disabled: !C.value.trim() || j,
1745
+ onClick: Ee,
1746
+ children: j ? "..." : "确定"
1747
+ }
1748
+ )
1749
+ ] })
1750
+ ]
1751
+ }
1752
+ )
1753
+ }
1754
+ )
1755
+ ] });
1756
+ }
1757
+ const kl = "_shell_1w53k_2", Tl = "_inset_1w53k_33", wl = "_main_1w53k_40", Il = "_pane_1w53k_52", Sl = "_skipLink_1w53k_62", Al = "_personalMainArea_1w53k_82", Bl = "_personalSidebar_1w53k_90", Ll = "_personalChatArea_1w53k_103", je = {
1758
+ shell: kl,
1759
+ inset: Tl,
1760
+ main: wl,
1761
+ pane: Il,
1762
+ skipLink: Sl,
1763
+ personalMainArea: Al,
1764
+ personalSidebar: Bl,
1765
+ personalChatArea: Ll
1766
+ }, Dl = "_sidebar_y5tuo_1", Ml = "_collapsed_y5tuo_12", xl = "_sideHeader_y5tuo_17", Rl = "_sideHeaderIcon_y5tuo_32", El = "_sideHeaderTitle_y5tuo_45", Ol = "_sideContent_y5tuo_54", $l = "_groupLabel_y5tuo_61", Hl = "_navList_y5tuo_71", Pl = "_navItem_y5tuo_77", Fl = "_navItemActive_y5tuo_109", jl = "_navIcon_y5tuo_114", Wl = "_navLabel_y5tuo_120", Kl = "_sideFooter_y5tuo_131", Ul = "_footHint_y5tuo_138", z = {
1767
+ sidebar: Dl,
1768
+ collapsed: Ml,
1769
+ sideHeader: xl,
1770
+ sideHeaderIcon: Rl,
1771
+ sideHeaderTitle: El,
1772
+ sideContent: Ol,
1773
+ groupLabel: $l,
1774
+ navList: Hl,
1775
+ navItem: Pl,
1776
+ navItemActive: Fl,
1777
+ navIcon: jl,
1778
+ navLabel: Wl,
1779
+ sideFooter: Kl,
1780
+ footHint: Ul
1781
+ };
1782
+ function Vl({
1783
+ items: a,
1784
+ activeTab: d,
1785
+ collapsed: m,
1786
+ footerItems: f,
1787
+ onSelect: k,
1788
+ onSwitchMode: I
1789
+ }) {
1790
+ return /* @__PURE__ */ i(
1791
+ "aside",
1792
+ {
1793
+ className: `${z.sidebar} ${m ? z.collapsed : ""}`,
1794
+ "aria-label": "个人工作台导航",
1795
+ children: [
1796
+ /* @__PURE__ */ i("div", { className: z.sideHeader, children: [
1797
+ /* @__PURE__ */ e("span", { className: z.sideHeaderIcon, children: /* @__PURE__ */ e(jt, {}) }),
1798
+ !m && /* @__PURE__ */ e("span", { className: z.sideHeaderTitle, children: "个人工作台" })
1799
+ ] }),
1800
+ /* @__PURE__ */ i("div", { className: z.sideContent, children: [
1801
+ !m && /* @__PURE__ */ e("p", { className: z.groupLabel, children: "我的工作空间" }),
1802
+ /* @__PURE__ */ e("nav", { className: z.navList, "aria-label": "个人模块", children: a.map((b) => {
1803
+ const D = d === b.key, x = /* @__PURE__ */ i(
1804
+ "button",
1805
+ {
1806
+ type: "button",
1807
+ className: `${z.navItem} ${D ? z.navItemActive : ""}`,
1808
+ onClick: () => k(b.key),
1809
+ "aria-current": D ? "page" : void 0,
1810
+ children: [
1811
+ /* @__PURE__ */ e("span", { className: z.navIcon, children: b.icon }),
1812
+ !m && /* @__PURE__ */ e("span", { className: z.navLabel, children: b.label })
1813
+ ]
1814
+ },
1815
+ b.key
1816
+ );
1817
+ return m ? /* @__PURE__ */ e(Ct, { placement: "right", title: b.label, children: x }, b.key) : x;
1818
+ }) })
1819
+ ] }),
1820
+ /* @__PURE__ */ i("div", { className: z.sideFooter, children: [
1821
+ f.length > 0 && /* @__PURE__ */ e("nav", { className: z.navList, "aria-label": "快捷切换", children: f.map((b) => {
1822
+ const D = /* @__PURE__ */ i(
1823
+ "button",
1824
+ {
1825
+ type: "button",
1826
+ className: z.navItem,
1827
+ onClick: () => I == null ? void 0 : I(b.mode),
1828
+ children: [
1829
+ /* @__PURE__ */ e("span", { className: z.navIcon, children: b.icon }),
1830
+ !m && /* @__PURE__ */ e("span", { className: z.navLabel, children: b.label })
1831
+ ]
1832
+ },
1833
+ b.mode
1834
+ );
1835
+ return m ? /* @__PURE__ */ e(Ct, { placement: "right", title: b.label, children: D }, b.mode) : D;
1836
+ }) }),
1837
+ !m && /* @__PURE__ */ e("p", { className: z.footHint, children: "⌘ / Ctrl + B 切换导航" })
1838
+ ] })
1839
+ ]
1840
+ }
1841
+ );
1842
+ }
1843
+ const Gl = "_topbar_ms4b7_1", zl = "_topbarLeft_ms4b7_14", ql = "_collapseBtn_ms4b7_22", Ql = "_crumbs_ms4b7_49", Xl = "_crumbsRoot_ms4b7_57", Jl = "_crumbsSep_ms4b7_62", Yl = "_crumbsCurrent_ms4b7_68", Zl = "_topbarRight_ms4b7_76", We = {
1844
+ topbar: Gl,
1845
+ topbarLeft: zl,
1846
+ collapseBtn: ql,
1847
+ crumbs: Ql,
1848
+ crumbsRoot: Xl,
1849
+ crumbsSep: Jl,
1850
+ crumbsCurrent: Yl,
1851
+ topbarRight: Zl
1852
+ };
1853
+ function ei({
1854
+ label: a,
1855
+ collapsed: d,
1856
+ onToggleCollapse: m
1857
+ }) {
1858
+ return /* @__PURE__ */ i("header", { className: We.topbar, children: [
1859
+ /* @__PURE__ */ i("div", { className: We.topbarLeft, children: [
1860
+ /* @__PURE__ */ e(
1861
+ Ct,
1862
+ {
1863
+ title: d ? "展开个人菜单" : "收起个人菜单",
1864
+ placement: "bottom",
1865
+ children: /* @__PURE__ */ e(
1866
+ "button",
1867
+ {
1868
+ type: "button",
1869
+ className: We.collapseBtn,
1870
+ onClick: m,
1871
+ "aria-label": "展开或收起个人菜单",
1872
+ "aria-expanded": !d,
1873
+ children: d ? /* @__PURE__ */ e(mn, {}) : /* @__PURE__ */ e(pn, {})
1874
+ }
1875
+ )
1876
+ }
1877
+ ),
1878
+ /* @__PURE__ */ i("div", { className: We.crumbs, "aria-label": "当前位置", children: [
1879
+ /* @__PURE__ */ e("span", { className: We.crumbsRoot, children: "个人" }),
1880
+ /* @__PURE__ */ e(Ht, { className: We.crumbsSep }),
1881
+ /* @__PURE__ */ e("span", { className: We.crumbsCurrent, children: a })
1882
+ ] })
1883
+ ] }),
1884
+ /* @__PURE__ */ e("div", { className: We.topbarRight })
1885
+ ] });
1886
+ }
1887
+ const tn = [
1888
+ { key: "workbench", label: "场景工作台", icon: /* @__PURE__ */ e(jt, {}) },
1889
+ { key: "projects", label: "工作单管理", icon: /* @__PURE__ */ e(_n, {}) },
1890
+ { key: "personal", label: "个人统计", icon: /* @__PURE__ */ e(fn, {}) },
1891
+ { key: "business-stats", label: "业务指标", icon: /* @__PURE__ */ e(yn, {}) },
1892
+ { key: "tools", label: "常用工具", icon: /* @__PURE__ */ e(vn, {}) },
1893
+ { key: "websites", label: "常用网站", icon: /* @__PURE__ */ e(bn, {}) },
1894
+ { key: "smart-partner", label: "智能伙伴", icon: /* @__PURE__ */ e(Ft, {}) },
1895
+ { key: "todo", label: "工作待办", icon: /* @__PURE__ */ e(Nn, {}) },
1896
+ { key: "notes", label: "个人笔记", icon: /* @__PURE__ */ e(Wt, {}) },
1897
+ {
1898
+ key: "training",
1899
+ label: "培训中心",
1900
+ icon: /* @__PURE__ */ e(Cn, {}),
1901
+ // 学员侧学习入口与培训管理(TRAINING)解耦:按需单独分配,不随培训入口发放
1902
+ permission: "TRAINING_CENTER"
1903
+ },
1904
+ { key: "webide", label: "WebIDE", icon: /* @__PURE__ */ e(kn, {}) }
1905
+ ], nn = "ft_pw_sidebar_collapsed";
1906
+ function ti() {
1907
+ try {
1908
+ return localStorage.getItem(nn) === "1";
1909
+ } catch {
1910
+ return !1;
1911
+ }
1912
+ }
1913
+ function ni(a) {
1914
+ const d = a;
1915
+ return d ? d.tagName === "INPUT" || d.tagName === "TEXTAREA" || d.isContentEditable === !0 : !1;
1916
+ }
1917
+ function si() {
1918
+ try {
1919
+ const a = new URLSearchParams(window.location.search).get("tab");
1920
+ return a && tn.some((d) => d.key === a) ? a : null;
1921
+ } catch {
1922
+ return null;
1923
+ }
1924
+ }
1925
+ function ai({
1926
+ onOpenProject: a,
1927
+ openTodoId: d,
1928
+ selectedPersonalAgent: m,
1929
+ personalView: f,
1930
+ newSessionTrigger: k,
1931
+ onSelectPersonalAgent: I,
1932
+ onShowPersonalAgentDetail: b,
1933
+ onChatWithPersonalAgent: D,
1934
+ onSwitchMode: x
1935
+ }) {
1936
+ var he;
1937
+ const [w, P] = p(
1938
+ // 惰性初始化:命中深链时直接以目标 Tab 首屏渲染,不先渲染场景工作台再切
1939
+ () => si() ?? "workbench"
1940
+ );
1941
+ M(() => {
1942
+ try {
1943
+ const T = new URL(window.location.href);
1944
+ if (!T.searchParams.has("tab")) return;
1945
+ T.searchParams.delete("tab"), window.history.replaceState(window.history.state, "", T.toString());
1946
+ } catch {
1947
+ }
1948
+ }, []);
1949
+ const [V, R] = p(ti);
1950
+ M(() => {
1951
+ try {
1952
+ localStorage.setItem(nn, V ? "1" : "0");
1953
+ } catch {
1954
+ }
1955
+ }, [V]);
1956
+ const B = U(() => {
1957
+ R((T) => !T), window.setTimeout(() => window.dispatchEvent(new Event("resize")), 300);
1958
+ }, []);
1959
+ M(() => {
1960
+ function T(W) {
1961
+ !(W.metaKey || W.ctrlKey) || W.altKey || W.key.toLowerCase() === "b" && (ni(W.target) || (W.preventDefault(), B()));
1962
+ }
1963
+ return window.addEventListener("keydown", T), () => window.removeEventListener("keydown", T);
1964
+ }, [B]);
1965
+ const N = Ke((T) => T.currentUser), J = tn.filter(
1966
+ (T) => !T.permission || Qt(N, T.permission)
1967
+ ), F = De(() => x ? [
1968
+ { mode: "admin", label: "运营工作台", icon: /* @__PURE__ */ e(hn, {}) },
1969
+ { mode: "collaboration", label: "协作工作台", icon: /* @__PURE__ */ e(gn, {}) }
1970
+ ].filter(
1971
+ (W) => Gt(N, W.mode)
1972
+ ) : [], [N, x]), pe = ((he = J.find((T) => T.key === w)) == null ? void 0 : he.label) ?? "个人工作台", [S, L] = p(null), [$, C] = p(null), Q = U((T) => {
1973
+ P(T);
1974
+ }, []), j = U((T) => {
1975
+ P("notes"), L({ id: T, ts: Date.now() });
1976
+ }, []), H = U((T) => {
1977
+ P("todo"), C({ id: T, ts: Date.now() });
1978
+ }, []);
1979
+ return M(() => {
1980
+ d != null && d.id && (P("todo"), C({ id: d.id, ts: d.ts }));
1981
+ }, [d == null ? void 0 : d.id, d == null ? void 0 : d.ts]), /* @__PURE__ */ i("div", { className: je.shell, children: [
1982
+ /* @__PURE__ */ e("a", { className: je.skipLink, href: "#pw-content", children: "跳到个人工作台内容" }),
1983
+ /* @__PURE__ */ e(
1984
+ Vl,
1985
+ {
1986
+ items: J,
1987
+ activeTab: w,
1988
+ collapsed: V,
1989
+ footerItems: F,
1990
+ onSelect: P,
1991
+ onSwitchMode: x
1992
+ }
1993
+ ),
1994
+ /* @__PURE__ */ i("div", { className: je.inset, children: [
1995
+ /* @__PURE__ */ e(
1996
+ ei,
1997
+ {
1998
+ label: pe,
1999
+ collapsed: V,
2000
+ onToggleCollapse: B
2001
+ }
2002
+ ),
2003
+ /* @__PURE__ */ e(
2004
+ "main",
2005
+ {
2006
+ id: "pw-content",
2007
+ tabIndex: -1,
2008
+ "aria-label": `${pe}内容`,
2009
+ className: je.main,
2010
+ children: /* @__PURE__ */ i("div", { className: je.pane, children: [
2011
+ (w === "workbench" || w === "projects" || w === "personal") && /* @__PURE__ */ e(
2012
+ Nt,
2013
+ {
2014
+ activeTab: w,
2015
+ onActiveTabChange: Q,
2016
+ onOpenProject: a,
2017
+ hideTabs: !0
2018
+ }
2019
+ ),
2020
+ w === "business-stats" && /* @__PURE__ */ e(Et, { source: "scenario" }),
2021
+ w === "tools" && /* @__PURE__ */ e(mt, { showTools: !0, showWebsites: !1 }),
2022
+ w === "websites" && /* @__PURE__ */ e(mt, { showTools: !1, showWebsites: !0 }),
2023
+ w === "todo" && /* @__PURE__ */ e(
2024
+ Ot,
2025
+ {
2026
+ onOpenProject: a,
2027
+ onOpenNote: j,
2028
+ openTodoId: $
2029
+ }
2030
+ ),
2031
+ w === "notes" && /* @__PURE__ */ e(
2032
+ $t,
2033
+ {
2034
+ onOpenProject: a,
2035
+ onOpenTodo: H,
2036
+ openNoteId: S
2037
+ }
2038
+ ),
2039
+ w === "training" && /* @__PURE__ */ e(Xt, {}),
2040
+ w === "webide" && /* @__PURE__ */ e(Jt, {}),
2041
+ w === "smart-partner" && /* @__PURE__ */ i("div", { className: je.personalMainArea, children: [
2042
+ /* @__PURE__ */ e("div", { className: je.personalSidebar, children: /* @__PURE__ */ e(
2043
+ Cl,
2044
+ {
2045
+ selectedAgentId: (m == null ? void 0 : m.id) ?? null,
2046
+ selectedLocalAgentId: (m == null ? void 0 : m.localAgentId) ?? null,
2047
+ onSelectAgent: I,
2048
+ onShowDetail: b,
2049
+ onChatWithAgent: D
2050
+ }
2051
+ ) }),
2052
+ /* @__PURE__ */ e("div", { className: je.personalChatArea, children: f === "detail" && m && !m.isLocal ? /* @__PURE__ */ e(
2053
+ Yt,
2054
+ {
2055
+ agent: m,
2056
+ onBack: () => I(m)
2057
+ }
2058
+ ) : m != null && m.isLocal ? /* @__PURE__ */ e(
2059
+ en,
2060
+ {
2061
+ agent: m,
2062
+ newSessionTrigger: k
2063
+ }
2064
+ ) : /* @__PURE__ */ e(
2065
+ Zt,
2066
+ {
2067
+ agent: m,
2068
+ newSessionTrigger: k
2069
+ }
2070
+ ) })
2071
+ ] })
2072
+ ] })
2073
+ }
2074
+ )
2075
+ ] })
2076
+ ] });
2077
+ }
2078
+ const q = Yn() || typeof localStorage < "u" && localStorage.getItem("ft_exclusive_force_desktop") === "1", li = `${window.publicPath ?? "/"}logo.svg`, ii = [
2079
+ "帮我排查一个线上问题",
2080
+ "总结一下今天的群聊进展",
2081
+ "把这周的变更整理成周报"
2082
+ ], ci = [
2083
+ {
2084
+ key: "video",
2085
+ label: "视频生成",
2086
+ icon: /* @__PURE__ */ e(Tn, {}),
2087
+ action: "chat",
2088
+ prompt: "帮我写一条 15 秒短视频脚本,主题是:"
2089
+ },
2090
+ {
2091
+ key: "docs",
2092
+ label: "文档办公",
2093
+ icon: /* @__PURE__ */ e(Wt, {}),
2094
+ action: "tools"
2095
+ },
2096
+ {
2097
+ key: "vibe",
2098
+ label: "Vibe Coding",
2099
+ icon: /* @__PURE__ */ e(Zn, {}),
2100
+ action: "webide"
2101
+ },
2102
+ {
2103
+ key: "design",
2104
+ label: "设计视觉",
2105
+ icon: /* @__PURE__ */ e(es, {}),
2106
+ action: "chat",
2107
+ prompt: "帮我出一版视觉设计稿,风格偏:"
2108
+ },
2109
+ {
2110
+ key: "ask",
2111
+ label: "问问 Z-Team",
2112
+ icon: /* @__PURE__ */ e(ut, {}),
2113
+ action: "ask"
2114
+ }
2115
+ ];
2116
+ function oi() {
2117
+ const a = (/* @__PURE__ */ new Date()).getHours();
2118
+ return a < 5 ? "夜深了" : a < 12 ? "早上好" : a < 14 ? "中午好" : a < 18 ? "下午好" : "晚上好";
2119
+ }
2120
+ function ri(a) {
2121
+ return a.type === "jar" ? {
2122
+ id: "-1",
2123
+ userId: "local",
2124
+ agentHubAgentId: null,
2125
+ agentCode: "local-default",
2126
+ displayName: a.name || "本地 Agent",
2127
+ avatar: null,
2128
+ isLocal: !0
2129
+ } : {
2130
+ id: "-1",
2131
+ userId: "local",
2132
+ agentHubAgentId: null,
2133
+ agentCode: a.name,
2134
+ displayName: a.name,
2135
+ avatar: null,
2136
+ isLocal: !0,
2137
+ localAgentId: a.id,
2138
+ localAgentType: a.type
2139
+ };
2140
+ }
2141
+ function Ti({
2142
+ onSwitchMode: a,
2143
+ onOpenProject: d,
2144
+ openAgentRequest: m
2145
+ }) {
2146
+ const f = Ke((t) => t.token), k = Ke((t) => t.currentUser), I = zt(), [b, D] = p([]), [x, w] = p(!0), [P, V] = p(null), [R, B] = p("landing"), [N, J] = p(null), [F, pe] = p(
2147
+ q ? "local" : "cloud"
2148
+ ), [S, L] = p(
2149
+ []
2150
+ ), [$, C] = p([]), [Q, j] = p(!0), [H, he] = p(!1), T = Ke((t) => t.projects), [W, Ne] = p([]), [ge, G] = p(null), [fe, ce] = p(
2151
+ /* @__PURE__ */ new Set()
2152
+ ), [ye, xe] = p(0), [Re, ve] = p(null), [oe, Ce] = p(!1), [Y, ke] = p([]), [_e, Te] = p(null), [re, ee] = p(""), de = O(null), [we, Ee] = p(!1), [Qe, Oe] = p(!1), [l, v] = p(null), [E, te] = p(!1), ne = U(
2153
+ (t) => {
2154
+ const s = Pn(t);
2155
+ s && !Qt(k, s) || (Je(t), B("personalTab"));
2156
+ },
2157
+ [k]
2158
+ ), [se, $e] = p(!1), [Ie, Se] = p(
2159
+ null
2160
+ ), [Xe, ue] = p(
2161
+ null
2162
+ ), [Ve, nt] = p(
2163
+ null
2164
+ ), Ae = U(
2165
+ (t, s) => {
2166
+ d == null || d(t, s);
2167
+ },
2168
+ [d]
2169
+ ), st = U((t) => {
2170
+ Je("todo"), nt({ id: t, ts: Date.now() });
2171
+ }, []), [ae, Je] = p("personal"), at = O(!1), Z = De(() => Fn(b), [b]), me = De(
2172
+ () => b.find((t) => t.id === P) ?? Z,
2173
+ [b, P, Z]
2174
+ );
2175
+ q && oe && Y.length > 0;
2176
+ const K = De(
2177
+ () => Y.find((t) => t.id === _e) ?? null,
2178
+ [Y, _e]
2179
+ );
2180
+ M(() => {
2181
+ let t = !0;
2182
+ return w(!0), Kt(f).then((s) => {
2183
+ t && D(s);
2184
+ }).catch(() => {
2185
+ }).finally(() => {
2186
+ t && w(!1);
2187
+ }), () => {
2188
+ t = !1;
2189
+ };
2190
+ }, [f]), M(() => {
2191
+ if (!q) return;
2192
+ let t = !0;
2193
+ const s = async () => {
2194
+ const o = await bt();
2195
+ if (t) {
2196
+ if (Ce(o), !o) {
2197
+ ke([]);
2198
+ return;
2199
+ }
2200
+ try {
2201
+ const y = await Vt();
2202
+ t && ke(y);
2203
+ } catch {
2204
+ }
2205
+ }
2206
+ };
2207
+ s();
2208
+ const u = window.setInterval(() => void s(), 3e4);
2209
+ return () => {
2210
+ t = !1, window.clearInterval(u);
2211
+ };
2212
+ }, []), M(() => {
2213
+ if (!q || Y.length === 0 || _e && Y.some((s) => s.id === _e))
2214
+ return;
2215
+ const t = Y.find((s) => s.type === "jar");
2216
+ Te((t ?? Y[0]).id);
2217
+ }, [Y, _e]);
2218
+ const lt = De(() => {
2219
+ const t = /* @__PURE__ */ new Map();
2220
+ for (const s of b) t.set(s.id, s);
2221
+ return t;
2222
+ }, [b]), Ge = U(async () => {
2223
+ j(!0);
2224
+ const [t, s] = await Promise.allSettled([
2225
+ Dn(f),
2226
+ as(f)
2227
+ ]);
2228
+ if (t.status === "fulfilled" && L(t.value || []), s.status === "fulfilled") {
2229
+ const u = /* @__PURE__ */ new Set(), o = [];
2230
+ for (const y of [...s.value.owned, ...s.value.joined])
2231
+ u.has(y.id) || (u.add(y.id), o.push(y));
2232
+ C(o);
2233
+ }
2234
+ j(!1);
2235
+ }, [f]);
2236
+ M(() => {
2237
+ Ge();
2238
+ }, [Ge, N == null ? void 0 : N.ts]);
2239
+ const He = De(() => {
2240
+ const t = /* @__PURE__ */ new Map();
2241
+ for (const _ of $)
2242
+ t.set(`sp:${String(_.id)}`, {
2243
+ key: `sp:${String(_.id)}`,
2244
+ title: _.title,
2245
+ sessions: []
2246
+ });
2247
+ const s = [], u = [...S].sort(
2248
+ (_, g) => (g.updateTime || g.createTime || "").localeCompare(
2249
+ _.updateTime || _.createTime || ""
2250
+ )
2251
+ );
2252
+ for (const _ of u)
2253
+ if (_.projectSpaceId != null) {
2254
+ const g = `sp:${String(_.projectSpaceId)}`;
2255
+ t.has(g) || t.set(g, {
2256
+ key: g,
2257
+ title: _.projectSpaceTitle || `空间 ${_.projectSpaceId}`,
2258
+ sessions: []
2259
+ }), t.get(g).sessions.push(_);
2260
+ } else
2261
+ s.push(_);
2262
+ const o = (_) => {
2263
+ var g, A;
2264
+ return ((g = _.sessions[0]) == null ? void 0 : g.updateTime) || ((A = _.sessions[0]) == null ? void 0 : A.createTime) || "";
2265
+ }, y = [...t.values()];
2266
+ return y.sort((_, g) => _.sessions.length > 0 && g.sessions.length > 0 ? o(g).localeCompare(o(_)) : _.sessions.length > 0 ? -1 : g.sessions.length > 0 ? 1 : _.title.localeCompare(g.title)), s.length > 0 && y.push({ key: "sp:none", title: "未归组", sessions: s }), y;
2267
+ }, [$, S]), Pe = De(
2268
+ () => {
2269
+ var t;
2270
+ return N != null && N.sessionId ? ((t = He.find(
2271
+ (s) => s.sessions.some((u) => u.id === N.sessionId)
2272
+ )) == null ? void 0 : t.key) ?? null : null;
2273
+ },
2274
+ [He, N == null ? void 0 : N.sessionId]
2275
+ );
2276
+ M(() => {
2277
+ var s;
2278
+ const t = Pe ?? (at.current ? null : ((s = He.find((u) => u.sessions.length > 0)) == null ? void 0 : s.key) ?? null);
2279
+ t && (at.current = !0, ce(
2280
+ (u) => u.has(t) ? u : new Set(u).add(t)
2281
+ ));
2282
+ }, [Pe, He]);
2283
+ const Be = K && K.type !== "jar" ? K.id : void 0;
2284
+ M(() => {
2285
+ if (!q || F !== "local" || !oe) return;
2286
+ let t = !0;
2287
+ return Ut(Be).then((s) => {
2288
+ t && Ne([...s].sort((u, o) => o.updatedAt - u.updatedAt));
2289
+ }).catch(() => {
2290
+ t && Ne([]);
2291
+ }), () => {
2292
+ t = !1;
2293
+ };
2294
+ }, [
2295
+ F,
2296
+ oe,
2297
+ Be,
2298
+ ge,
2299
+ ye
2300
+ ]);
2301
+ const Ye = U(() => G(null), []), pt = (t) => {
2302
+ J(null), G(t), B("chat");
2303
+ }, le = (t, s = null, u = null) => {
2304
+ V(t.id), J(
2305
+ (o) => o && o.agent.id === t.id && o.sessionId === s && !u ? o : { agent: t, sessionId: s, draft: u, ts: Date.now() }
2306
+ ), B("chat");
2307
+ };
2308
+ M(() => {
2309
+ const t = m;
2310
+ if (!(t != null && t.agent) || !t.ts) return;
2311
+ const s = t.agent;
2312
+ if (V(s.id), t.view === "detail") {
2313
+ Se(s), B("agentDetail");
2314
+ return;
2315
+ }
2316
+ le(s, t.sessionId ?? null), t.newSession > 0 && xe((u) => u + 1);
2317
+ }, [m == null ? void 0 : m.ts]);
2318
+ const Ze = () => {
2319
+ V((Z == null ? void 0 : Z.id) ?? null), J(null), ee(""), B("landing");
2320
+ }, Ue = () => {
2321
+ xe((t) => t + 1), J(null), B("chat");
2322
+ }, it = async () => {
2323
+ const t = Z;
2324
+ if (!t) {
2325
+ Ze();
2326
+ return;
2327
+ }
2328
+ try {
2329
+ const s = await St(
2330
+ t.id,
2331
+ "新会话",
2332
+ f,
2333
+ l
2334
+ );
2335
+ v(null), le(t, s.id), Ge();
2336
+ } catch {
2337
+ }
2338
+ }, ht = () => {
2339
+ if (q && K) {
2340
+ Ue();
2341
+ return;
2342
+ }
2343
+ if (Z) {
2344
+ le(Z);
2345
+ return;
2346
+ }
2347
+ Ze();
2348
+ }, gt = () => {
2349
+ N ? B("chat") : Z && le(Z);
2350
+ }, ze = async () => {
2351
+ const t = re.trim();
2352
+ if (!(!t || we)) {
2353
+ if (q && K) {
2354
+ ve(t), ee(""), B("chat");
2355
+ return;
2356
+ }
2357
+ if (me) {
2358
+ Ee(!0);
2359
+ try {
2360
+ const s = t.length > 20 ? `${t.slice(0, 20)}…` : t, u = await St(
2361
+ me.id,
2362
+ s,
2363
+ f,
2364
+ l
2365
+ );
2366
+ v(null), J({
2367
+ agent: me,
2368
+ sessionId: u.id,
2369
+ draft: t,
2370
+ ts: Date.now()
2371
+ }), ee(""), B("chat");
2372
+ } catch {
2373
+ } finally {
2374
+ Ee(!1);
2375
+ }
2376
+ }
2377
+ }
2378
+ }, et = I.nickname || (k == null ? void 0 : k.display_name) || (k == null ? void 0 : k.username) || "", ct = De(() => a ? [
2379
+ {
2380
+ mode: "personal",
2381
+ label: "个人工作台",
2382
+ icon: /* @__PURE__ */ e(Xn, {})
2383
+ },
2384
+ {
2385
+ mode: "collaboration",
2386
+ label: "协作工作台",
2387
+ icon: /* @__PURE__ */ e(Jn, {})
2388
+ }
2389
+ ].filter(
2390
+ (s) => Gt(k, s.mode)
2391
+ ) : [], [k, a]), ot = N ? `${N.agent.id}-${N.sessionId ?? 0}-${N.ts}` : "none";
2392
+ let n;
2393
+ return R === "agentDetail" && Ie ? n = /* @__PURE__ */ e("div", { className: h.detailHost, children: /* @__PURE__ */ e(
2394
+ Yt,
2395
+ {
2396
+ agent: Ie,
2397
+ onBack: () => B("extensions")
2398
+ }
2399
+ ) }) : R === "schedule" ? n = /* @__PURE__ */ e(os, { localOnline: oe }) : R === "extensions" ? n = /* @__PURE__ */ e(
2400
+ rs,
2401
+ {
2402
+ agents: b,
2403
+ loading: x,
2404
+ skillsAgent: Z,
2405
+ token: f,
2406
+ onChat: (t) => le(t),
2407
+ onConfig: (t) => {
2408
+ Se(t), B("agentDetail");
2409
+ },
2410
+ onCreated: (t) => D((s) => [...s, t])
2411
+ }
2412
+ ) : R === "history" ? n = /* @__PURE__ */ e(
2413
+ ds,
2414
+ {
2415
+ agents: b,
2416
+ token: f,
2417
+ onOpenSession: (t, s) => le(t, s)
2418
+ }
2419
+ ) : R === "workbenchShell" ? n = /* @__PURE__ */ e(
2420
+ ai,
2421
+ {
2422
+ onOpenProject: Ae,
2423
+ selectedPersonalAgent: me,
2424
+ personalView: "chat",
2425
+ newSessionTrigger: ye,
2426
+ onSelectPersonalAgent: (t) => V((t == null ? void 0 : t.id) ?? null),
2427
+ onShowPersonalAgentDetail: (t) => {
2428
+ Se(t), B("agentDetail");
2429
+ },
2430
+ onChatWithPersonalAgent: (t) => le(t),
2431
+ onSwitchMode: a
2432
+ }
2433
+ ) : R === "personalTab" ? n = /* @__PURE__ */ i("div", { className: h.personalTabHost, children: [
2434
+ ae === "projects" && /* @__PURE__ */ e(
2435
+ Nt,
2436
+ {
2437
+ activeTab: "projects",
2438
+ onActiveTabChange: () => {
2439
+ },
2440
+ onOpenProject: Ae,
2441
+ hideTabs: !0
2442
+ }
2443
+ ),
2444
+ ae === "personal" && /* @__PURE__ */ e(
2445
+ Nt,
2446
+ {
2447
+ activeTab: "personal",
2448
+ onActiveTabChange: () => {
2449
+ },
2450
+ onOpenProject: Ae,
2451
+ hideTabs: !0
2452
+ }
2453
+ ),
2454
+ ae === "business-stats" && /* @__PURE__ */ e(Et, { source: "scenario" }),
2455
+ ae === "tools" && /* @__PURE__ */ e(mt, { showTools: !0, showWebsites: !1 }),
2456
+ ae === "websites" && /* @__PURE__ */ e(mt, { showTools: !1, showWebsites: !0 }),
2457
+ ae === "todo" && /* @__PURE__ */ e(
2458
+ Ot,
2459
+ {
2460
+ onOpenProject: Ae,
2461
+ onOpenNote: (t) => {
2462
+ Je("notes"), ue({ id: t, ts: Date.now() });
2463
+ },
2464
+ openTodoId: Ve
2465
+ }
2466
+ ),
2467
+ ae === "notes" && /* @__PURE__ */ e(
2468
+ $t,
2469
+ {
2470
+ onOpenProject: Ae,
2471
+ onOpenTodo: st,
2472
+ openNoteId: Xe
2473
+ }
2474
+ ),
2475
+ ae === "training" && /* @__PURE__ */ e(Xt, {}),
2476
+ ae === "webide" && /* @__PURE__ */ e(Jt, {})
2477
+ ] }) : N ? n = /* @__PURE__ */ e("div", { className: h.chatHost, children: /* @__PURE__ */ e(
2478
+ Zt,
2479
+ {
2480
+ agent: N.agent,
2481
+ initialSessionId: N.sessionId,
2482
+ autoSendDraft: N.draft,
2483
+ chromeless: !0,
2484
+ agents: b,
2485
+ onSwitchAgent: (t) => le(t)
2486
+ },
2487
+ ot
2488
+ ) }) : q && K && R !== "landing" ? n = /* @__PURE__ */ e("div", { className: h.chatHost, children: /* @__PURE__ */ e(
2489
+ en,
2490
+ {
2491
+ agent: ri(K),
2492
+ newSessionTrigger: ye,
2493
+ autoSendDraft: Re,
2494
+ onAutoSendConsumed: () => ve(null),
2495
+ openSessionId: ge,
2496
+ onOpenSessionConsumed: Ye
2497
+ },
2498
+ K.id
2499
+ ) }) : n = /* @__PURE__ */ e("div", { className: h.landing, children: /* @__PURE__ */ i("div", { className: h.landingInner, children: [
2500
+ /* @__PURE__ */ e("div", { className: h.mascot, "aria-hidden": "true", children: /* @__PURE__ */ e("img", { src: li, alt: "" }) }),
2501
+ /* @__PURE__ */ e("h1", { className: h.landingTitle, children: I.greetingEnabled ? `${oi()}${et ? `,${et}` : ""}` : "开始新的对话" }),
2502
+ /* @__PURE__ */ e("p", { className: h.landingSub, children: I.bio || "我是你的智能伙伴,有什么可以帮你?" }),
2503
+ /* @__PURE__ */ i("div", { className: h.landingBox, children: [
2504
+ /* @__PURE__ */ e(
2505
+ "textarea",
2506
+ {
2507
+ ref: de,
2508
+ className: h.landingInput,
2509
+ placeholder: `给智能伙伴发送消息,${ss(I.sendKey)}`,
2510
+ rows: 3,
2511
+ value: re,
2512
+ autoFocus: !0,
2513
+ onChange: (t) => ee(t.target.value),
2514
+ onKeyDown: (t) => {
2515
+ qt(t, I.sendKey) && !t.nativeEvent.isComposing && (t.preventDefault(), ze());
2516
+ }
2517
+ }
2518
+ ),
2519
+ /* @__PURE__ */ i("div", { className: h.landingBoxBar, children: [
2520
+ q && K ? /* @__PURE__ */ i("span", { className: h.agentChip, children: [
2521
+ /* @__PURE__ */ e(ut, {}),
2522
+ /* @__PURE__ */ i("span", { children: [
2523
+ K.name,
2524
+ "(本机)"
2525
+ ] })
2526
+ ] }) : me ? /* @__PURE__ */ i("div", { className: h.agentChipWrap, children: [
2527
+ /* @__PURE__ */ i(
2528
+ "button",
2529
+ {
2530
+ type: "button",
2531
+ className: h.agentChip,
2532
+ onClick: () => Oe((t) => !t),
2533
+ children: [
2534
+ /* @__PURE__ */ e(ut, {}),
2535
+ /* @__PURE__ */ e("span", { children: me.displayName }),
2536
+ b.length > 1 && /* @__PURE__ */ e(ft, { className: h.chipCaret })
2537
+ ]
2538
+ }
2539
+ ),
2540
+ Qe && b.length > 1 && /* @__PURE__ */ i(Me, { children: [
2541
+ /* @__PURE__ */ e(
2542
+ "div",
2543
+ {
2544
+ className: h.agentMenuMask,
2545
+ onClick: () => Oe(!1)
2546
+ }
2547
+ ),
2548
+ /* @__PURE__ */ e("div", { className: h.agentMenu, role: "menu", children: b.map((t) => /* @__PURE__ */ i(
2549
+ "button",
2550
+ {
2551
+ type: "button",
2552
+ role: "menuitem",
2553
+ className: `${h.agentMenuItem} ${t.id === me.id ? h.agentMenuItemActive : ""}`,
2554
+ onClick: () => {
2555
+ V(t.id), Oe(!1);
2556
+ },
2557
+ children: [
2558
+ /* @__PURE__ */ e(
2559
+ "span",
2560
+ {
2561
+ className: h.agentDot,
2562
+ style: { background: Wn(t.displayName) },
2563
+ children: jn(t.displayName)
2564
+ }
2565
+ ),
2566
+ t.displayName
2567
+ ]
2568
+ },
2569
+ t.id
2570
+ )) })
2571
+ ] })
2572
+ ] }) : /* @__PURE__ */ e("span", { className: h.agentChipEmpty, children: "还没有云端伙伴,可到个人工作台创建" }),
2573
+ !(q && K) && me && /* @__PURE__ */ i("div", { className: h.agentChipWrap, children: [
2574
+ /* @__PURE__ */ i(
2575
+ "button",
2576
+ {
2577
+ type: "button",
2578
+ className: h.agentChip,
2579
+ title: "本次新建任务归入的项目空间(可选)",
2580
+ onClick: () => te((t) => !t),
2581
+ children: [
2582
+ /* @__PURE__ */ e(yt, {}),
2583
+ /* @__PURE__ */ e("span", { children: l ? l.title : "不归组" }),
2584
+ /* @__PURE__ */ e(ft, { className: h.chipCaret })
2585
+ ]
2586
+ }
2587
+ ),
2588
+ E && /* @__PURE__ */ i(Me, { children: [
2589
+ /* @__PURE__ */ e(
2590
+ "div",
2591
+ {
2592
+ className: h.agentMenuMask,
2593
+ onClick: () => te(!1)
2594
+ }
2595
+ ),
2596
+ /* @__PURE__ */ e(
2597
+ ProjectSpaceMenu,
2598
+ {
2599
+ token: f,
2600
+ currentId: (l == null ? void 0 : l.id) ?? null,
2601
+ onPick: (t) => {
2602
+ v(t), te(!1);
2603
+ }
2604
+ }
2605
+ )
2606
+ ] })
2607
+ ] }),
2608
+ /* @__PURE__ */ e(
2609
+ "button",
2610
+ {
2611
+ type: "button",
2612
+ className: h.landingSend,
2613
+ disabled: !re.trim() || we || !me && !(q && K),
2614
+ onClick: () => void ze(),
2615
+ "aria-label": "发送",
2616
+ children: we ? /* @__PURE__ */ e(Kn, {}) : /* @__PURE__ */ e(Un, {})
2617
+ }
2618
+ )
2619
+ ] })
2620
+ ] }),
2621
+ /* @__PURE__ */ i("div", { className: h.contextRow, children: [
2622
+ /* @__PURE__ */ i("span", { className: h.contextChip, children: [
2623
+ /* @__PURE__ */ e(yt, {}),
2624
+ /* @__PURE__ */ e("span", { children: l ? l.title : "未归组" })
2625
+ ] }),
2626
+ /* @__PURE__ */ e("span", { className: h.contextChip, children: q && K ? /* @__PURE__ */ i(Me, { children: [
2627
+ /* @__PURE__ */ e(ut, {}),
2628
+ /* @__PURE__ */ i("span", { children: [
2629
+ K.name,
2630
+ "(本机)"
2631
+ ] })
2632
+ ] }) : /* @__PURE__ */ i(Me, { children: [
2633
+ /* @__PURE__ */ e(Vn, {}),
2634
+ /* @__PURE__ */ e("span", { children: "云端" })
2635
+ ] }) })
2636
+ ] }),
2637
+ /* @__PURE__ */ e("div", { className: h.chipRow, children: ci.map((t) => /* @__PURE__ */ i(
2638
+ "button",
2639
+ {
2640
+ type: "button",
2641
+ className: h.capChip,
2642
+ onClick: () => {
2643
+ var s;
2644
+ if (t.action === "tools") {
2645
+ ne("tools");
2646
+ return;
2647
+ }
2648
+ if (t.action === "webide") {
2649
+ ne("webide");
2650
+ return;
2651
+ }
2652
+ if (t.action === "ask") {
2653
+ ht();
2654
+ return;
2655
+ }
2656
+ ee(t.prompt ?? ""), (s = de.current) == null || s.focus();
2657
+ },
2658
+ children: [
2659
+ /* @__PURE__ */ e("span", { className: h.capChipIcon, children: t.icon }),
2660
+ /* @__PURE__ */ e("span", { children: t.label })
2661
+ ]
2662
+ },
2663
+ t.key
2664
+ )) }),
2665
+ /* @__PURE__ */ e("div", { className: h.chipRow, children: ii.map((t) => /* @__PURE__ */ e(
2666
+ "button",
2667
+ {
2668
+ type: "button",
2669
+ className: h.suggestChip,
2670
+ onClick: () => {
2671
+ var s;
2672
+ ee(t), (s = de.current) == null || s.focus();
2673
+ },
2674
+ children: t
2675
+ },
2676
+ t
2677
+ )) })
2678
+ ] }) }), /* @__PURE__ */ i("div", { className: h.shell, children: [
2679
+ /* @__PURE__ */ i("aside", { className: h.sidebar, "aria-label": "个人专享工作台导航", children: [
2680
+ /* @__PURE__ */ i("div", { className: h.sideContent, children: [
2681
+ /* @__PURE__ */ e(
2682
+ Gn,
2683
+ {
2684
+ currentUser: k,
2685
+ token: f,
2686
+ isDesktop: q,
2687
+ activeNav: R === "schedule" ? "schedule" : R === "history" ? "history" : null,
2688
+ extensionsGroupActive: [
2689
+ "extensions",
2690
+ "agentDetail",
2691
+ "personalTab",
2692
+ "workbenchShell"
2693
+ ].includes(R),
2694
+ activePersonalTab: R === "personalTab" ? ae : null,
2695
+ onDesktopNewTask: q && K ? Ue : void 0,
2696
+ onNewTaskDirect: q ? void 0 : it,
2697
+ onPickSpace: (t) => {
2698
+ v(t), Ze();
2699
+ },
2700
+ currentSpaceId: (l == null ? void 0 : l.id) ?? null,
2701
+ onOpenSchedule: () => B("schedule"),
2702
+ onOpenExtensions: () => B("extensions"),
2703
+ onOpenHistory: () => B("history"),
2704
+ onOpenSearch: () => {
2705
+ he(!0), Ke.getState().loadProjects();
2706
+ },
2707
+ searchActive: H,
2708
+ onOpenPersonalTab: ne,
2709
+ onOpenWorkbenchShell: () => B("workbenchShell"),
2710
+ onCloudNav: q ? gt : void 0,
2711
+ cloudNavActive: R === "chat" && !!N
2712
+ }
2713
+ ),
2714
+ /* @__PURE__ */ i("div", { className: h.sideTasks, children: [
2715
+ q && /* @__PURE__ */ i(
2716
+ "div",
2717
+ {
2718
+ className: h.segToggle,
2719
+ role: "tablist",
2720
+ "aria-label": "任务范围切换",
2721
+ children: [
2722
+ /* @__PURE__ */ e(
2723
+ "button",
2724
+ {
2725
+ type: "button",
2726
+ role: "tab",
2727
+ "aria-selected": F === "local",
2728
+ className: `${h.segBtn} ${F === "local" ? h.segBtnActive : ""}`,
2729
+ onClick: () => pe("local"),
2730
+ children: "本地"
2731
+ }
2732
+ ),
2733
+ /* @__PURE__ */ e(
2734
+ "button",
2735
+ {
2736
+ type: "button",
2737
+ role: "tab",
2738
+ "aria-selected": F === "cloud",
2739
+ className: `${h.segBtn} ${F === "cloud" ? h.segBtnActive : ""}`,
2740
+ onClick: () => pe("cloud"),
2741
+ children: "云端"
2742
+ }
2743
+ )
2744
+ ]
2745
+ }
2746
+ ),
2747
+ q && F === "local" ? /* @__PURE__ */ i(Me, { children: [
2748
+ /* @__PURE__ */ e("div", { className: h.tasksLabel, children: "本地任务" }),
2749
+ W.map((t) => /* @__PURE__ */ e(
2750
+ "button",
2751
+ {
2752
+ type: "button",
2753
+ className: `${h.recentItem} ${ge === t.id ? h.recentItemActive : ""}`,
2754
+ title: t.title,
2755
+ onClick: () => pt(t.id),
2756
+ children: /* @__PURE__ */ e("span", { className: h.recentItemText, children: t.title || "未命名会话" })
2757
+ },
2758
+ t.id
2759
+ )),
2760
+ W.length === 0 && /* @__PURE__ */ e("div", { className: h.tasksEmpty, children: oe ? "暂无本地任务,点上方新建任务开始" : "本机 Agent 未运行" })
2761
+ ] }) : /* @__PURE__ */ i(Me, { children: [
2762
+ /* @__PURE__ */ e("div", { className: h.tasksLabel, children: "项目" }),
2763
+ He.length === 0 && !Q && /* @__PURE__ */ e("div", { className: h.tasksEmpty, children: "还没有项目空间或云端任务" }),
2764
+ He.map((t) => {
2765
+ const s = fe.has(t.key);
2766
+ return /* @__PURE__ */ i("div", { children: [
2767
+ /* @__PURE__ */ i(
2768
+ "button",
2769
+ {
2770
+ type: "button",
2771
+ className: h.projFolder,
2772
+ "aria-expanded": s,
2773
+ onClick: () => ce((u) => {
2774
+ const o = new Set(u);
2775
+ return o.has(t.key) ? o.delete(t.key) : o.add(t.key), o;
2776
+ }),
2777
+ children: [
2778
+ /* @__PURE__ */ e(
2779
+ ft,
2780
+ {
2781
+ className: `${h.projCaret} ${s ? h.projCaretOpen : ""}`
2782
+ }
2783
+ ),
2784
+ /* @__PURE__ */ e(yt, { className: h.projIcon }),
2785
+ /* @__PURE__ */ e("span", { className: h.projName, title: t.title, children: t.title }),
2786
+ /* @__PURE__ */ e("span", { className: h.projMeta, children: t.sessions.length > 0 ? t.sessions.length : "暂无任务" })
2787
+ ]
2788
+ }
2789
+ ),
2790
+ s && t.sessions.length > 0 && /* @__PURE__ */ e("div", { className: h.projRows, children: t.sessions.map((u) => {
2791
+ const o = lt.get(u.personalAgentId);
2792
+ return /* @__PURE__ */ e(
2793
+ "button",
2794
+ {
2795
+ type: "button",
2796
+ className: `${h.recentItem} ${(N == null ? void 0 : N.sessionId) === u.id ? h.recentItemActive : ""}`,
2797
+ disabled: !o,
2798
+ title: o ? u.title || "未命名会话" : "伙伴已不存在,无法打开",
2799
+ onClick: () => o && le(o, u.id),
2800
+ children: /* @__PURE__ */ e("span", { className: h.recentItemText, children: u.title || "未命名会话" })
2801
+ },
2802
+ u.id
2803
+ );
2804
+ }) })
2805
+ ] }, t.key);
2806
+ })
2807
+ ] })
2808
+ ] })
2809
+ ] }),
2810
+ /* @__PURE__ */ e(
2811
+ zn,
2812
+ {
2813
+ displayName: et,
2814
+ subtitle: "Z-Team · 个人(专享)",
2815
+ onOpenSettings: () => $e(!0),
2816
+ children: ct.map((t) => /* @__PURE__ */ i(
2817
+ "button",
2818
+ {
2819
+ type: "button",
2820
+ role: "menuitem",
2821
+ className: h.agentMenuItem,
2822
+ onClick: () => a == null ? void 0 : a(t.mode),
2823
+ children: [
2824
+ /* @__PURE__ */ e("span", { className: h.navIcon, children: t.icon }),
2825
+ /* @__PURE__ */ e("span", { children: t.label })
2826
+ ]
2827
+ },
2828
+ t.mode
2829
+ ))
2830
+ }
2831
+ )
2832
+ ] }),
2833
+ /* @__PURE__ */ e("main", { className: h.main, "aria-label": "个人专享工作台内容", children: x && !N && !K ? /* @__PURE__ */ e("div", { className: h.emptyState, children: /* @__PURE__ */ e("span", { className: h.emptyTitle, children: "正在加载智能伙伴…" }) }) : n }),
2834
+ /* @__PURE__ */ e(
2835
+ qn,
2836
+ {
2837
+ open: se,
2838
+ onClose: () => $e(!1),
2839
+ token: f
2840
+ }
2841
+ ),
2842
+ H && /* @__PURE__ */ e(
2843
+ Qn,
2844
+ {
2845
+ sessions: S,
2846
+ agentsById: lt,
2847
+ projects: T,
2848
+ token: f,
2849
+ onOpenSession: (t, s) => le(t, s),
2850
+ onOpenProject: (t) => Ae(t.id),
2851
+ onClose: () => he(!1)
2852
+ }
2853
+ )
2854
+ ] });
2855
+ }
2856
+ export {
2857
+ Ti as default
2858
+ };