@yuku123/z-team-component 0.2.80 → 0.2.81

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