@yuku123/z-team-component 0.2.71 → 0.2.73

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