@yuku123/z-team-component 0.2.77 → 0.2.79

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