@yuku123/z-team-component 0.2.76 → 0.2.78

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