@yuku123/z-team-component 0.2.72 → 0.2.74

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 (50) hide show
  1. package/dist/{ChangeLogView-AUM7QbBp.js → ChangeLogView-BJxIhIPc.js} +1 -1
  2. package/dist/{ComponentDoc-CLxzCDOh.js → ComponentDoc-CFKpk6X_.js} +3 -3
  3. package/dist/{InvitationManagementPage-MxyMf4G0.js → InvitationManagementPage-Dr4SxM5K.js} +1 -1
  4. package/dist/{OnboardingPage-BRwX8RYe.js → OnboardingPage-DcYULxKd.js} +2 -2
  5. package/dist/{ScheduledTasks-CM1m4eVZ.js → ScheduledTasks-T4NFJWsk.js} +2918 -3170
  6. package/dist/{SystemShell-BlgZhQ3V.js → SystemShell-D8aDuO_D.js} +215 -196
  7. package/dist/{admin-logs-Dx2fTWjF.js → admin-logs-asBlA9MU.js} +2 -2
  8. package/dist/{api-prj570UT.js → api-Bj-xsNGU.js} +1 -1
  9. package/dist/{api-CvQEwiLU.js → api-DPkUB1DA.js} +67 -67
  10. package/dist/{createWorkspaceWsHandler-gVanGCAb.js → createWorkspaceWsHandler-25JfnMML.js} +1834 -1812
  11. package/dist/{index-pyPNcAqs.js → index-BA3lZUmW.js} +1 -1
  12. package/dist/{index-DOyFfs3n.js → index-BYTVXqVp.js} +3844 -3731
  13. package/dist/{index-pc_ckjzD.js → index-BYn9kfIj.js} +3 -3
  14. package/dist/{index-C1rcAeiF.js → index-BZnC9BRh.js} +3 -3
  15. package/dist/{index-BujZj4b8.js → index-B_O9mXF6.js} +4 -4
  16. package/dist/{index-nj-cjKsf.js → index-BohoJQPr.js} +1849 -1857
  17. package/dist/{index-DDlmkQRB.js → index-C7ymoOiI.js} +2 -2
  18. package/dist/{index-DZbYU9xn.js → index-C9YhDxMT.js} +1 -1
  19. package/dist/{index-CxYTuPnw.js → index-CMVYzEVW.js} +2 -2
  20. package/dist/{index-DrWXMU6s.js → index-COhXbfib.js} +1 -1
  21. package/dist/index-CQcGGl6J.js +137 -0
  22. package/dist/{index-B5xRddRA.js → index-CbTwXfER.js} +6 -6
  23. package/dist/{index-Dk0Qm8aZ.js → index-Ccc2gRJA.js} +1 -1
  24. package/dist/{index-D1PpV_Lf.js → index-Ce9TrTy7.js} +2 -2
  25. package/dist/{index-C4AgHd-o.js → index-Czt_d2TY.js} +2 -2
  26. package/dist/{index-Cry-Oyoh.js → index-DHDQGO4q.js} +3 -3
  27. package/dist/{index-DJMZ1RpC.js → index-DOOlyOVX.js} +2 -2
  28. package/dist/{index-QZpyj7Q3.js → index-DfecivMN.js} +1256 -1256
  29. package/dist/{index-CL7GMxR-.js → index-DxRqnvKU.js} +4 -4
  30. package/dist/{index-PGSvSOmm.js → index-IK8UlsDo.js} +30 -30
  31. package/dist/{index-Cr4Rf1IT.js → index-OP18iV8V.js} +5 -5
  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-DzAkJL3V.js → index-rPNKkWaw.js} +3 -3
  35. package/dist/index-rkF8co0n.js +2882 -0
  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-6NaQTuIn.js} +3 -3
  39. package/dist/pages.js +11 -11
  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/dist/z-team-component.css +1 -1
  47. package/package.json +1 -1
  48. package/dist/index-BbxVn7xy.js +0 -1747
  49. package/dist/index-D4opADk_.js +0 -168
  50. package/dist/index-zhz9iWvI.js +0 -2629
@@ -0,0 +1,2882 @@
1
+ import { jsx as e, jsxs as l, Fragment as Ee } from "react/jsx-runtime";
2
+ import { S as $t, T as Et, P as Ht } 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 sn, ag as Pt, k as st, ah as an, ai as ln, aj as on, ak as cn, al as rn, am as dn, an as un } from "./api-DPkUB1DA.js";
5
+ import { f as Ft, c as ft, a as mn, b as pn, r as hn, s as gn, t as _n, d as jt, e as bt, g as fn, h as yn, i as Wt, j as p, R as ut, D as vt, k as bn, l as vn, F as Nt, P as Nn, L as Cn, A as kn, C as Tn, m as wn, n as Sn, o as In, p as An, W as Bn, q as Ln, S as Dn, u as Mn, U as xn, T as Rn, v as On } from "./index-BYTVXqVp.js";
6
+ import { u as wt, a as mt, i as Kt, T as $n, b as En, s as Hn } from "./createWorkspaceWsHandler-25JfnMML.js";
7
+ import { u as Ae } from "./useAppStore-DQP0l22d.js";
8
+ import { h as Ut, f as Pn } from "./schedule-iMEGim0L.js";
9
+ import { RightOutlined as Vt, PlusOutlined as Fn, LeftOutlined as jn, CheckOutlined as Gt, LoadingOutlined as St, EditOutlined as It, DeleteOutlined as Wn, UpOutlined as At, RedoOutlined as Kn, DownOutlined as Un, StopOutlined as Vn, CopyOutlined as Gn, MessageOutlined as zt, MoreOutlined as zn, DashboardOutlined as Qt, MenuUnfoldOutlined as Qn, MenuFoldOutlined as qn, SettingOutlined as Xn, TeamOutlined as Jn, FolderOpenOutlined as Yn, BarChartOutlined as Zn, PieChartOutlined as es, CodeOutlined as ts, LinkOutlined as ns, UnorderedListOutlined as ss, FileTextOutlined as qt, ReadOutlined as as, ConsoleSqlOutlined as ls, PlayCircleOutlined as is } from "@ant-design/icons";
10
+ import os from "react-markdown";
11
+ import cs from "rehype-highlight";
12
+ import rs from "remark-gfm";
13
+ import { W as Ct, b as pt, T as Xt, c as Jt, a as Yt, P as Zt, S as ds, E as us, C as ms } from "./ScheduledTasks-T4NFJWsk.js";
14
+ import { message as rt, Tooltip as kt } from "antd";
15
+ const ps = "_container_3gc15_1", hs = "_sessionPanel_3gc15_9", gs = "_sessionHeader_3gc15_19", _s = "_sessionHeaderActions_3gc15_32", fs = "_sessionBtnSm_3gc15_37", ys = "_sessionList_3gc15_55", bs = "_sessionItem_3gc15_61", vs = "_sessionItemActive_3gc15_79", Ns = "_sessionItemTitle_3gc15_84", Cs = "_sessionLiveDot_3gc15_93", ks = "_sessionItemTime_3gc15_100", Ts = "_sessionDeleteBtn_3gc15_106", ws = "_sessionRenameBtn_3gc15_127", Ss = "_sessionRenameInput_3gc15_148", Is = "_sessionCreateRow_3gc15_160", As = "_sessionCreateInput_3gc15_166", Bs = "_sessionCreateConfirm_3gc15_180", Ls = "_sessionCreateCancel_3gc15_181", Ds = "_sessionSearchRow_3gc15_203", Ms = "_sessionSearchInput_3gc15_209", xs = "_sessionSearchClear_3gc15_224", Rs = "_sessionEmpty_3gc15_245", Os = "_sessionExpandBtn_3gc15_255", $s = "_chatPanel_3gc15_275", Es = "_chatHeader_3gc15_284", Hs = "_agentAvatar_3gc15_296", Ps = "_chatHeaderMeta_3gc15_309", Fs = "_chatHeaderName_3gc15_317", js = "_chatHeaderSession_3gc15_324", Ws = "_chatHeaderBadge_3gc15_332", Ks = "_streamingIndicator_3gc15_342", Us = "_threadScroll_3gc15_351", Vs = "_threadInner_3gc15_357", Gs = "_landing_3gc15_368", zs = "_landingLogo_3gc15_378", Qs = "_landingTitle_3gc15_392", qs = "_landingHint_3gc15_398", Xs = "_newChatLanding_3gc15_404", Js = "_landingComposer_3gc15_415", Ys = "_landingInput_3gc15_432", Zs = "_chatEmpty_3gc15_448", ea = "_userRow_3gc15_459", ta = "_userBubble_3gc15_464", na = "_assistantBlock_3gc15_478", sa = "_md_3gc15_488", aa = "_mdPreWrap_3gc15_546", la = "_mdPreCopy_3gc15_550", ia = "_caretCursor_3gc15_585", oa = "_errorBar_3gc15_602", ca = "_errorRetryBtn_3gc15_611", ra = "_stoppedBar_3gc15_626", da = "_scrollTopBtn_3gc15_636", ua = "_scrollTopBtnVisible_3gc15_658", ma = "_composerWrap_3gc15_669", pa = "_composer_3gc15_669", ha = "_composerInput_3gc15_691", ga = "_sendBtn_3gc15_709", _a = "_stopBtn_3gc15_710", fa = "_sendBtnReady_3gc15_730", ya = "_composerHint_3gc15_748", ba = "_msgMeta_3gc15_758", va = "_copyBtn_3gc15_769", Na = "_copyBtnInline_3gc15_799", Ca = "_copyBtnDone_3gc15_806", ka = "_landingChips_3gc15_811", Ta = "_landingChip_3gc15_811", wa = "_userActions_3gc15_838", Sa = "_userActionBtn_3gc15_851", Ia = "_editingBar_3gc15_874", Aa = "_pendingBar_3gc15_889", Ba = "_editingCancel_3gc15_910", i = {
16
+ container: ps,
17
+ sessionPanel: hs,
18
+ sessionHeader: gs,
19
+ sessionHeaderActions: _s,
20
+ sessionBtnSm: fs,
21
+ sessionList: ys,
22
+ sessionItem: bs,
23
+ sessionItemActive: vs,
24
+ sessionItemTitle: Ns,
25
+ sessionLiveDot: Cs,
26
+ sessionItemTime: ks,
27
+ sessionDeleteBtn: Ts,
28
+ sessionRenameBtn: ws,
29
+ sessionRenameInput: Ss,
30
+ sessionCreateRow: Is,
31
+ sessionCreateInput: As,
32
+ sessionCreateConfirm: Bs,
33
+ sessionCreateCancel: Ls,
34
+ sessionSearchRow: Ds,
35
+ sessionSearchInput: Ms,
36
+ sessionSearchClear: xs,
37
+ sessionEmpty: Rs,
38
+ sessionExpandBtn: Os,
39
+ chatPanel: $s,
40
+ chatHeader: Es,
41
+ agentAvatar: Hs,
42
+ chatHeaderMeta: Ps,
43
+ chatHeaderName: Fs,
44
+ chatHeaderSession: js,
45
+ chatHeaderBadge: Ws,
46
+ streamingIndicator: Ks,
47
+ threadScroll: Us,
48
+ threadInner: Vs,
49
+ landing: Gs,
50
+ landingLogo: zs,
51
+ landingTitle: Qs,
52
+ landingHint: qs,
53
+ newChatLanding: Xs,
54
+ landingComposer: Js,
55
+ landingInput: Ys,
56
+ chatEmpty: Zs,
57
+ userRow: ea,
58
+ userBubble: ta,
59
+ assistantBlock: na,
60
+ md: sa,
61
+ mdPreWrap: aa,
62
+ mdPreCopy: la,
63
+ caretCursor: ia,
64
+ errorBar: oa,
65
+ errorRetryBtn: ca,
66
+ stoppedBar: ra,
67
+ scrollTopBtn: da,
68
+ scrollTopBtnVisible: ua,
69
+ composerWrap: ma,
70
+ composer: pa,
71
+ composerInput: ha,
72
+ sendBtn: ga,
73
+ stopBtn: _a,
74
+ sendBtnReady: fa,
75
+ composerHint: ya,
76
+ msgMeta: ba,
77
+ copyBtn: va,
78
+ copyBtnInline: Na,
79
+ copyBtnDone: Ca,
80
+ landingChips: ka,
81
+ landingChip: Ta,
82
+ userActions: wa,
83
+ userActionBtn: Sa,
84
+ editingBar: Ia,
85
+ pendingBar: Aa,
86
+ editingCancel: Ba
87
+ };
88
+ function La(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 Bt(n) {
104
+ return (n || []).map((o, u) => {
105
+ const _ = La(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 Da(n) {
120
+ return n >= 1e4 ? `${Math.round(n / 1e3)}k` : n >= 1e3 ? `${(n / 1e3).toFixed(1)}k` : String(n);
121
+ }
122
+ function Ma(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 Lt = [
134
+ "#2F70F1",
135
+ "#52c41a",
136
+ "#fa8c16",
137
+ "#eb2f96",
138
+ "#722ed1",
139
+ "#13c2c2",
140
+ "#f522d0",
141
+ "#faad14"
142
+ ];
143
+ function Dt(n) {
144
+ let o = 0;
145
+ for (let u = 0; u < n.length; u++) o = o * 31 + n.charCodeAt(u) | 0;
146
+ return Lt[Math.abs(o) % Lt.length];
147
+ }
148
+ function yt(n) {
149
+ return n ? n.charAt(0).toUpperCase() : "?";
150
+ }
151
+ function xa({ 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(Tt, { 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 Ra({ text: n }) {
162
+ return /* @__PURE__ */ e("div", { className: i.md, children: /* @__PURE__ */ e(
163
+ os,
164
+ {
165
+ remarkPlugins: [rs],
166
+ rehypePlugins: [cs],
167
+ components: {
168
+ pre: (o) => /* @__PURE__ */ e(xa, { children: o.children })
169
+ },
170
+ children: n
171
+ }
172
+ ) });
173
+ }
174
+ function Oa({ 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 $a(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 Tt({
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 || !$a(R) || (k(!0), window.setTimeout(() => k(!1), 1600));
214
+ },
215
+ title: u,
216
+ "aria-label": u,
217
+ children: _ ? /* @__PURE__ */ e(Gt, {}) : /* @__PURE__ */ e(Gn, {})
218
+ }
219
+ );
220
+ }
221
+ const Mt = [
222
+ "查看当前目录的文件列表",
223
+ "总结当前目录里各文件的内容",
224
+ "帮我写一个脚本统计各文件的行数",
225
+ "说明一下你能使用哪些工具"
226
+ ];
227
+ function en({
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, w] = m(
240
+ null
241
+ ), [W, I] = m([]), [z, G] = m(""), [K, f] = m(!1), T = 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 Te = q(/* @__PURE__ */ new Map()), He = q(null), Pe = (t) => {
246
+ T.current = t, f(t);
247
+ }, [we, _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 Ft(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
+ w(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
+ w(d.id);
274
+ }
275
+ });
276
+ }, [Ze]), H(() => {
277
+ o > 0 && (async () => {
278
+ try {
279
+ const t = await ft(
280
+ "新会话",
281
+ n == null ? void 0 : n.localAgentId
282
+ );
283
+ D((d) => [t, ...d]), w(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, w(k), R == null || R());
296
+ }, [k, R]), H(() => {
297
+ const t = He.current;
298
+ if (t != null && t !== L) {
299
+ Te.current.set(t, z);
300
+ const v = Te.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), mn(L).then((v) => {
321
+ c || I(Bt(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
+ }, []), ht = 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 ft(t, n == null ? void 0 : n.localAgentId);
351
+ D((c) => [d, ...c]), w(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 hn(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 (await mt({ content: "确定删除此会话吗?" })) {
369
+ T.current && Se.current === t && Qe();
370
+ try {
371
+ await sn(t), D((d) => d.filter((c) => c.id !== t)), L === t && (w(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
+ ), gt = 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 && pn(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 || T.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 gn(
477
+ c,
478
+ t,
479
+ {
480
+ onToken: (C) => ot(c, h, "text", C),
481
+ onReasoning: (C) => ot(c, h, "thinking", C),
482
+ onEvent: (C) => gt(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 _n(
534
+ L,
535
+ t
536
+ );
537
+ ce.current = !0, D(
538
+ (h) => h.map((S) => S.id === v ? c : S)
539
+ ), w(c.id), I(Bt(c.messages)), await Ke(d, c.id);
540
+ } catch {
541
+ await Ke(d);
542
+ }
543
+ }, _t = (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 || T.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 ft(h, n == null ? void 0 : n.localAgentId);
562
+ D((O) => [S, ...O]), w(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(""), Te.current.delete(L ?? ""), me.current && (me.current.style.height = "auto");
574
+ return;
575
+ }
576
+ if (G(""), Te.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
+ Kt(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 = Dt("local-default");
590
+ Dt(
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
+ $n,
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
+ En,
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(Ra, { 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(Vt, {})
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(Fn, {})
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(jn, {})
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(Gt, {})
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: () => w(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
+ St,
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: Ma(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(It, {})
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(Wn, {})
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: yt((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(St, {}),
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: we && 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: yt((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: Mt.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
+ Tt,
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: () => _t(d, Je(t.blocks)),
891
+ children: /* @__PURE__ */ e(It, {})
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(Kn, {})
906
+ }
907
+ )
908
+ ] })
909
+ ] }, t.id) : /* @__PURE__ */ l("div", { className: i.assistantBlock, children: [
910
+ U(t),
911
+ t.streaming && t.startedAtMs != null && /* @__PURE__ */ e(Oa, { 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 ? ` · ${Da(h)} tokens` : "";
922
+ })()
923
+ ] }),
924
+ !t.streaming && /* @__PURE__ */ e(
925
+ Tt,
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: ht,
962
+ title: "回到最新消息",
963
+ "aria-label": "回到最新消息",
964
+ children: /* @__PURE__ */ e(Un, {})
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(Vn, {})
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(At, {})
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: yt((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(At, {})
1079
+ }
1080
+ )
1081
+ ] }),
1082
+ /* @__PURE__ */ e("div", { className: i.landingChips, children: Mt.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 Ea = "_sidebarInner_1vu3c_1", Ha = "_header_1vu3c_8", Pa = "_headerActions_1vu3c_19", Fa = "_tabBar_1vu3c_26", ja = "_tab_1vu3c_26", Wa = "_tabActive_1vu3c_50", Ka = "_btnSm_1vu3c_66", Ua = "_agentSection_1vu3c_84", Va = "_agentItem_1vu3c_90", Ga = "_agentItemActive_1vu3c_112", za = "_agentAvatar_1vu3c_117", Qa = "_agentName_1vu3c_130", qa = "_emptyState_1vu3c_156", Xa = "_createInputRow_1vu3c_168", Ja = "_createInput_1vu3c_168", Ya = "_createConfirmBtn_1vu3c_188", Za = "_contextMenu_1vu3c_205", el = "_contextMenuItem_1vu3c_216", tl = "_contextMenuItemDanger_1vu3c_231", nl = "_contextMenuDivider_1vu3c_239", sl = "_renameOverlay_1vu3c_246", al = "_renameDialog_1vu3c_259", ll = "_renameTitle_1vu3c_267", il = "_renameInput_1vu3c_274", ol = "_renameActions_1vu3c_289", cl = "_renameBtn_1vu3c_295", rl = "_renameBtnPrimary_1vu3c_309", dl = "_agentDetailBtn_1vu3c_326", ul = "_agentItemShared_1vu3c_358", ml = "_agentInfo_1vu3c_362", pl = "_agentOwner_1vu3c_374", hl = "_sharedBadge_1vu3c_382", gl = "_createLocalDialog_1vu3c_430", _l = "_createLocalLabel_1vu3c_438", fl = "_agentTypeCards_1vu3c_446", yl = "_agentTypeCard_1vu3c_446", bl = "_agentTypeIcon_1vu3c_474", vl = "_agentTypeBody_1vu3c_487", Nl = "_agentTypeTitle_1vu3c_494", Cl = "_agentTypeDesc_1vu3c_500", kl = "_agentTypeBadge_1vu3c_506", r = {
1098
+ sidebarInner: Ea,
1099
+ header: Ha,
1100
+ headerActions: Pa,
1101
+ tabBar: Fa,
1102
+ tab: ja,
1103
+ tabActive: Wa,
1104
+ btnSm: Ka,
1105
+ agentSection: Ua,
1106
+ agentItem: Va,
1107
+ agentItemActive: Ga,
1108
+ agentAvatar: za,
1109
+ agentName: Qa,
1110
+ emptyState: qa,
1111
+ createInputRow: Xa,
1112
+ createInput: Ja,
1113
+ createConfirmBtn: Ya,
1114
+ contextMenu: Za,
1115
+ contextMenuItem: el,
1116
+ contextMenuItemDanger: tl,
1117
+ contextMenuDivider: nl,
1118
+ renameOverlay: sl,
1119
+ renameDialog: al,
1120
+ renameTitle: ll,
1121
+ renameInput: il,
1122
+ renameActions: ol,
1123
+ renameBtn: cl,
1124
+ renameBtnPrimary: rl,
1125
+ agentDetailBtn: dl,
1126
+ agentItemShared: ul,
1127
+ agentInfo: ml,
1128
+ agentOwner: pl,
1129
+ sharedBadge: hl,
1130
+ createLocalDialog: gl,
1131
+ createLocalLabel: _l,
1132
+ agentTypeCards: fl,
1133
+ agentTypeCard: yl,
1134
+ agentTypeIcon: bl,
1135
+ agentTypeBody: vl,
1136
+ agentTypeTitle: Nl,
1137
+ agentTypeDesc: Cl,
1138
+ agentTypeBadge: kl
1139
+ }, xt = [
1140
+ "#2F70F1",
1141
+ "#52c41a",
1142
+ "#fa8c16",
1143
+ "#eb2f96",
1144
+ "#722ed1",
1145
+ "#13c2c2",
1146
+ "#f5222d",
1147
+ "#faad14"
1148
+ ];
1149
+ function Rt(n) {
1150
+ let o = 0;
1151
+ for (let u = 0; u < n.length; u++) o = o * 31 + n.charCodeAt(u) | 0;
1152
+ return xt[Math.abs(o) % xt.length];
1153
+ }
1154
+ function Ot(n) {
1155
+ return n ? n.charAt(0).toUpperCase() : "?";
1156
+ }
1157
+ const dt = "-1";
1158
+ function Tl({
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), [w, W] = m(null), [I, z] = m(null), [G, K] = m(!1), [f, T] = m([]), [Y, Be] = m(!1), [ve, Z] = m(null), [ke, ge] = m(!1), [Te, He] = m([]), [Pe, we] = m(!1), [_e, Le] = m(!1), oe = q(null), De = J(async () => {
1168
+ E(!0);
1169
+ try {
1170
+ const a = await Pt(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 an(R);
1180
+ T(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 jt();
1194
+ He(a);
1195
+ } catch {
1196
+ He([]);
1197
+ }
1198
+ }, []);
1199
+ H(() => {
1200
+ x === "local" && bt().then((a) => {
1201
+ ge(a), a && Me();
1202
+ });
1203
+ }, [x, Me]), H(() => {
1204
+ if (!w) 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
+ }, [w]);
1210
+ const ue = async () => {
1211
+ const a = X.trim();
1212
+ if (a) {
1213
+ L(!0);
1214
+ try {
1215
+ const b = await ln(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
+ we(!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 bt()) {
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 fn(b, a), rt.success(`已引入 ${b},点击列表项即可开始对话`), we(!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 (await mt({ content: "确定删除此 Agent?" }))
1257
+ try {
1258
+ await yn(a), await Me();
1259
+ } catch (b) {
1260
+ rt.error(b.message || "删除失败");
1261
+ }
1262
+ }, ze = async (a) => {
1263
+ if (await mt({
1264
+ content: `确定删除 Agent「${a.displayName}」吗?所有会话记录将一并删除。`
1265
+ }))
1266
+ try {
1267
+ await on(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 cn(
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 (await mt({
1292
+ title: b ? "取消共享" : "共享 Agent",
1293
+ content: b ? `确定取消共享 Agent「${a.displayName}」吗?取消后其他用户将无法与此 Agent 聊天。` : `确定共享 Agent「${a.displayName}」吗?共享后其他用户可以与此 Agent 发起聊天。`,
1294
+ danger: !1
1295
+ })) {
1296
+ Z(a.id);
1297
+ try {
1298
+ const Q = await rn(
1299
+ a.id,
1300
+ !b,
1301
+ R
1302
+ );
1303
+ $((Ce) => Ce.map((ne) => ne.id === Q.id ? Q : ne));
1304
+ } catch {
1305
+ } finally {
1306
+ Z(null);
1307
+ }
1308
+ }
1309
+ }, je = (a, b) => {
1310
+ a.preventDefault(), a.stopPropagation(), W({ x: a.clientX, y: a.clientY, agent: b });
1311
+ };
1312
+ return /* @__PURE__ */ l("div", { className: r.sidebarInner, children: [
1313
+ /* @__PURE__ */ l("div", { className: r.header, children: [
1314
+ /* @__PURE__ */ e("span", { children: "个人 Agent" }),
1315
+ x === "remote" && /* @__PURE__ */ e("div", { className: r.headerActions, children: /* @__PURE__ */ e(
1316
+ "button",
1317
+ {
1318
+ type: "button",
1319
+ className: r.btnSm,
1320
+ onClick: () => {
1321
+ N((a) => !a), V("");
1322
+ },
1323
+ title: "新建个人 Agent",
1324
+ children: "+ 新建"
1325
+ }
1326
+ ) }),
1327
+ x === "local" && /* @__PURE__ */ e("div", { className: r.headerActions, children: /* @__PURE__ */ e(
1328
+ "button",
1329
+ {
1330
+ type: "button",
1331
+ className: r.btnSm,
1332
+ onClick: () => we(!0),
1333
+ title: "新建本地 Agent",
1334
+ children: "+ 新增"
1335
+ }
1336
+ ) })
1337
+ ] }),
1338
+ /* @__PURE__ */ l("div", { className: r.tabBar, children: [
1339
+ /* @__PURE__ */ e(
1340
+ "button",
1341
+ {
1342
+ type: "button",
1343
+ className: `${r.tab} ${x === "local" ? r.tabActive : ""}`,
1344
+ onClick: () => j("local"),
1345
+ title: "本地 Agent",
1346
+ children: "本地"
1347
+ }
1348
+ ),
1349
+ /* @__PURE__ */ e(
1350
+ "button",
1351
+ {
1352
+ type: "button",
1353
+ className: `${r.tab} ${x === "remote" ? r.tabActive : ""}`,
1354
+ onClick: () => j("remote"),
1355
+ children: "远程"
1356
+ }
1357
+ ),
1358
+ /* @__PURE__ */ e(
1359
+ "button",
1360
+ {
1361
+ type: "button",
1362
+ className: `${r.tab} ${x === "shared" ? r.tabActive : ""}`,
1363
+ onClick: () => j("shared"),
1364
+ children: "共享"
1365
+ }
1366
+ )
1367
+ ] }),
1368
+ x === "local" ? /* @__PURE__ */ e("div", { className: r.agentSection, children: ke ? /* @__PURE__ */ e(Ee, { children: Te.map((a) => /* @__PURE__ */ l(
1369
+ "div",
1370
+ {
1371
+ className: `${r.agentItem} ${st(n, dt) && (a.type === "jar" && !o || o === a.id) ? r.agentItemActive : ""}`,
1372
+ onClick: () => {
1373
+ a.type === "jar" ? u({
1374
+ id: dt,
1375
+ userId: "local",
1376
+ agentHubAgentId: null,
1377
+ agentCode: "local-default",
1378
+ displayName: a.name,
1379
+ avatar: null,
1380
+ isLocal: !0
1381
+ }) : u({
1382
+ id: dt,
1383
+ userId: "local",
1384
+ agentHubAgentId: null,
1385
+ agentCode: a.name,
1386
+ displayName: a.name,
1387
+ avatar: null,
1388
+ isLocal: !0,
1389
+ localAgentId: a.id,
1390
+ localAgentType: a.type
1391
+ });
1392
+ },
1393
+ children: [
1394
+ /* @__PURE__ */ e(
1395
+ "div",
1396
+ {
1397
+ className: r.agentAvatar,
1398
+ style: {
1399
+ backgroundColor: a.type === "hermes" ? "#722ed1" : a.type === "claude-code" ? "#eb2f96" : "#52c41a"
1400
+ },
1401
+ children: a.type === "hermes" ? "H" : a.type === "claude-code" ? "C" : "L"
1402
+ }
1403
+ ),
1404
+ /* @__PURE__ */ e("span", { className: r.agentName, children: a.name }),
1405
+ a.type !== "jar" && /* @__PURE__ */ e(
1406
+ "button",
1407
+ {
1408
+ type: "button",
1409
+ className: r.agentDetailBtn,
1410
+ onClick: (b) => {
1411
+ b.stopPropagation(), fe(a.id);
1412
+ },
1413
+ title: "删除",
1414
+ children: /* @__PURE__ */ e("span", { style: { fontSize: 14 }, children: "×" })
1415
+ }
1416
+ )
1417
+ ]
1418
+ },
1419
+ a.id
1420
+ )) }) : /* @__PURE__ */ l("div", { className: r.emptyState, children: [
1421
+ /* @__PURE__ */ e("span", { children: "本地 Agent 未启动" }),
1422
+ /* @__PURE__ */ e("span", { children: "请检查桌面端是否正常运行" })
1423
+ ] }) }) : 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: [
1424
+ /* @__PURE__ */ e("span", { children: "暂无共享 Agent" }),
1425
+ /* @__PURE__ */ e("span", { children: "其他用户共享的 Agent 会显示在这里" })
1426
+ ] }) : f.map((a) => /* @__PURE__ */ l(
1427
+ "div",
1428
+ {
1429
+ className: `${r.agentItem} ${r.agentItemShared}`,
1430
+ onClick: () => k(a),
1431
+ title: `点击与「${a.displayName}」聊天`,
1432
+ children: [
1433
+ /* @__PURE__ */ e(
1434
+ "div",
1435
+ {
1436
+ className: r.agentAvatar,
1437
+ style: {
1438
+ backgroundColor: Rt(
1439
+ a.agentCode || a.displayName
1440
+ )
1441
+ },
1442
+ children: Ot(a.displayName)
1443
+ }
1444
+ ),
1445
+ /* @__PURE__ */ l("div", { className: r.agentInfo, children: [
1446
+ /* @__PURE__ */ e("span", { className: r.agentName, children: a.displayName }),
1447
+ /* @__PURE__ */ l("span", { className: r.agentOwner, children: [
1448
+ "来自: ",
1449
+ a.userId
1450
+ ] })
1451
+ ] }),
1452
+ /* @__PURE__ */ e(
1453
+ "button",
1454
+ {
1455
+ type: "button",
1456
+ className: r.agentDetailBtn,
1457
+ onClick: (b) => {
1458
+ b.stopPropagation(), k(a);
1459
+ },
1460
+ title: "开始聊天",
1461
+ children: /* @__PURE__ */ e(zt, { style: { fontSize: 12 } })
1462
+ }
1463
+ )
1464
+ ]
1465
+ },
1466
+ a.id
1467
+ )) }) : /* @__PURE__ */ l(Ee, { children: [
1468
+ B && /* @__PURE__ */ l("div", { className: r.createInputRow, children: [
1469
+ /* @__PURE__ */ e(
1470
+ "input",
1471
+ {
1472
+ className: r.createInput,
1473
+ type: "text",
1474
+ placeholder: "输入 Agent 名称",
1475
+ value: X,
1476
+ autoFocus: !0,
1477
+ onChange: (a) => V(a.target.value),
1478
+ onKeyDown: (a) => {
1479
+ a.key === "Enter" && ue(), a.key === "Escape" && (N(!1), V(""));
1480
+ }
1481
+ }
1482
+ ),
1483
+ /* @__PURE__ */ e(
1484
+ "button",
1485
+ {
1486
+ type: "button",
1487
+ className: r.createConfirmBtn,
1488
+ disabled: !X.trim() || de,
1489
+ onClick: ue,
1490
+ children: de ? "..." : "创建"
1491
+ }
1492
+ )
1493
+ ] }),
1494
+ /* @__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: [
1495
+ /* @__PURE__ */ e("span", { children: "暂无个人 Agent" }),
1496
+ /* @__PURE__ */ e("span", { children: "点击「新建」创建一个" })
1497
+ ] }) : D.map((a) => /* @__PURE__ */ l(
1498
+ "div",
1499
+ {
1500
+ className: `${r.agentItem} ${st(n, a.id) ? r.agentItemActive : ""}`,
1501
+ onClick: () => u(a),
1502
+ onContextMenu: (b) => je(b, a),
1503
+ children: [
1504
+ /* @__PURE__ */ e(
1505
+ "div",
1506
+ {
1507
+ className: r.agentAvatar,
1508
+ style: {
1509
+ backgroundColor: Rt(
1510
+ a.agentCode || a.displayName
1511
+ )
1512
+ },
1513
+ children: Ot(a.displayName)
1514
+ }
1515
+ ),
1516
+ /* @__PURE__ */ l("span", { className: r.agentName, children: [
1517
+ a.displayName,
1518
+ a.shared === 1 && /* @__PURE__ */ e("span", { className: r.sharedBadge, children: "共享" })
1519
+ ] }),
1520
+ /* @__PURE__ */ e(
1521
+ "button",
1522
+ {
1523
+ type: "button",
1524
+ className: r.agentDetailBtn,
1525
+ onClick: (b) => {
1526
+ b.stopPropagation();
1527
+ const Q = b.currentTarget.getBoundingClientRect();
1528
+ W({
1529
+ x: Q.right - 120,
1530
+ y: Q.bottom + 4,
1531
+ agent: a
1532
+ });
1533
+ },
1534
+ title: "更多操作",
1535
+ children: /* @__PURE__ */ e(zn, { style: { fontSize: 14 } })
1536
+ }
1537
+ )
1538
+ ]
1539
+ },
1540
+ a.id
1541
+ )) })
1542
+ ] }),
1543
+ w && /* @__PURE__ */ l(
1544
+ "div",
1545
+ {
1546
+ ref: oe,
1547
+ className: r.contextMenu,
1548
+ style: { top: w.y, left: w.x },
1549
+ children: [
1550
+ /* @__PURE__ */ e(
1551
+ "div",
1552
+ {
1553
+ className: r.contextMenuItem,
1554
+ onClick: () => {
1555
+ k(w.agent), W(null);
1556
+ },
1557
+ children: "开始聊天"
1558
+ }
1559
+ ),
1560
+ /* @__PURE__ */ e(
1561
+ "div",
1562
+ {
1563
+ className: r.contextMenuItem,
1564
+ onClick: () => {
1565
+ _(w.agent), W(null);
1566
+ },
1567
+ children: "Agent 配置"
1568
+ }
1569
+ ),
1570
+ /* @__PURE__ */ e("div", { className: r.contextMenuDivider }),
1571
+ /* @__PURE__ */ e(
1572
+ "div",
1573
+ {
1574
+ className: r.contextMenuItem,
1575
+ onClick: () => {
1576
+ z({
1577
+ agent: w.agent,
1578
+ value: w.agent.displayName
1579
+ }), W(null);
1580
+ },
1581
+ children: "重命名"
1582
+ }
1583
+ ),
1584
+ /* @__PURE__ */ e(
1585
+ "div",
1586
+ {
1587
+ className: r.contextMenuItem,
1588
+ onClick: () => {
1589
+ ve === null && qe(w.agent), W(null);
1590
+ },
1591
+ children: w.agent.shared === 1 ? "取消共享" : "共享给他人"
1592
+ }
1593
+ ),
1594
+ /* @__PURE__ */ e("div", { className: r.contextMenuDivider }),
1595
+ /* @__PURE__ */ e(
1596
+ "div",
1597
+ {
1598
+ className: `${r.contextMenuItem} ${r.contextMenuItemDanger}`,
1599
+ onClick: () => {
1600
+ ze(w.agent), W(null);
1601
+ },
1602
+ children: "删除"
1603
+ }
1604
+ )
1605
+ ]
1606
+ }
1607
+ ),
1608
+ Pe && /* @__PURE__ */ e(
1609
+ "div",
1610
+ {
1611
+ className: r.renameOverlay,
1612
+ onClick: () => !_e && we(!1),
1613
+ children: /* @__PURE__ */ l(
1614
+ "div",
1615
+ {
1616
+ className: r.createLocalDialog,
1617
+ onClick: (a) => a.stopPropagation(),
1618
+ children: [
1619
+ /* @__PURE__ */ e("div", { className: r.renameTitle, children: "新建本地 Agent" }),
1620
+ /* @__PURE__ */ e("div", { className: r.createLocalLabel, children: _e ? "正在创建..." : "点击选择,直接开始聊天" }),
1621
+ /* @__PURE__ */ l("div", { className: r.agentTypeCards, children: [
1622
+ /* @__PURE__ */ l(
1623
+ "div",
1624
+ {
1625
+ className: r.agentTypeCard,
1626
+ onClick: () => xe("jar"),
1627
+ children: [
1628
+ /* @__PURE__ */ e(
1629
+ "div",
1630
+ {
1631
+ className: r.agentTypeIcon,
1632
+ style: { backgroundColor: "#52c41a" },
1633
+ children: "L"
1634
+ }
1635
+ ),
1636
+ /* @__PURE__ */ l("div", { className: r.agentTypeBody, children: [
1637
+ /* @__PURE__ */ l("div", { className: r.agentTypeTitle, children: [
1638
+ "自研",
1639
+ " ",
1640
+ /* @__PURE__ */ e("span", { className: r.agentTypeBadge, children: "已运行" })
1641
+ ] }),
1642
+ /* @__PURE__ */ e("div", { className: r.agentTypeDesc, children: "自研 Java Agent,内置 ReAct 推理引擎与工具调用" })
1643
+ ] })
1644
+ ]
1645
+ }
1646
+ ),
1647
+ /* @__PURE__ */ l(
1648
+ "div",
1649
+ {
1650
+ className: r.agentTypeCard,
1651
+ onClick: () => xe("hermes"),
1652
+ children: [
1653
+ /* @__PURE__ */ e(
1654
+ "div",
1655
+ {
1656
+ className: r.agentTypeIcon,
1657
+ style: { backgroundColor: "#722ed1" },
1658
+ children: "H"
1659
+ }
1660
+ ),
1661
+ /* @__PURE__ */ l("div", { className: r.agentTypeBody, children: [
1662
+ /* @__PURE__ */ e("div", { className: r.agentTypeTitle, children: "Hermes" }),
1663
+ /* @__PURE__ */ e("div", { className: r.agentTypeDesc, children: "本地 Hermes CLI,支持 tool-calling 与多模型切换" })
1664
+ ] })
1665
+ ]
1666
+ }
1667
+ ),
1668
+ /* @__PURE__ */ l(
1669
+ "div",
1670
+ {
1671
+ className: r.agentTypeCard,
1672
+ onClick: () => xe("claude-code"),
1673
+ children: [
1674
+ /* @__PURE__ */ e(
1675
+ "div",
1676
+ {
1677
+ className: r.agentTypeIcon,
1678
+ style: { backgroundColor: "#eb2f96" },
1679
+ children: "C"
1680
+ }
1681
+ ),
1682
+ /* @__PURE__ */ l("div", { className: r.agentTypeBody, children: [
1683
+ /* @__PURE__ */ e("div", { className: r.agentTypeTitle, children: "Claude Code" }),
1684
+ /* @__PURE__ */ e("div", { className: r.agentTypeDesc, children: "Anthropic Claude CLI 编码助手" })
1685
+ ] })
1686
+ ]
1687
+ }
1688
+ )
1689
+ ] }),
1690
+ /* @__PURE__ */ e("div", { className: r.renameActions, children: /* @__PURE__ */ e(
1691
+ "button",
1692
+ {
1693
+ type: "button",
1694
+ className: r.renameBtn,
1695
+ onClick: () => we(!1),
1696
+ disabled: _e,
1697
+ children: "取消"
1698
+ }
1699
+ ) })
1700
+ ]
1701
+ }
1702
+ )
1703
+ }
1704
+ ),
1705
+ I && /* @__PURE__ */ e(
1706
+ "div",
1707
+ {
1708
+ className: r.renameOverlay,
1709
+ onClick: () => !G && z(null),
1710
+ children: /* @__PURE__ */ l(
1711
+ "div",
1712
+ {
1713
+ className: r.renameDialog,
1714
+ onClick: (a) => a.stopPropagation(),
1715
+ children: [
1716
+ /* @__PURE__ */ e("div", { className: r.renameTitle, children: "重命名 Agent" }),
1717
+ /* @__PURE__ */ e(
1718
+ "input",
1719
+ {
1720
+ className: r.renameInput,
1721
+ type: "text",
1722
+ value: I.value,
1723
+ autoFocus: !0,
1724
+ onChange: (a) => z({ ...I, value: a.target.value }),
1725
+ onKeyDown: (a) => {
1726
+ a.key === "Enter" && Fe(), a.key === "Escape" && z(null);
1727
+ }
1728
+ }
1729
+ ),
1730
+ /* @__PURE__ */ l("div", { className: r.renameActions, children: [
1731
+ /* @__PURE__ */ e(
1732
+ "button",
1733
+ {
1734
+ type: "button",
1735
+ className: r.renameBtn,
1736
+ onClick: () => z(null),
1737
+ disabled: G,
1738
+ children: "取消"
1739
+ }
1740
+ ),
1741
+ /* @__PURE__ */ e(
1742
+ "button",
1743
+ {
1744
+ type: "button",
1745
+ className: r.renameBtnPrimary,
1746
+ disabled: !I.value.trim() || G,
1747
+ onClick: Fe,
1748
+ children: G ? "..." : "确定"
1749
+ }
1750
+ )
1751
+ ] })
1752
+ ]
1753
+ }
1754
+ )
1755
+ }
1756
+ )
1757
+ ] });
1758
+ }
1759
+ const wl = "_shell_1w53k_2", Sl = "_inset_1w53k_33", Il = "_main_1w53k_40", Al = "_pane_1w53k_52", Bl = "_skipLink_1w53k_62", Ll = "_personalMainArea_1w53k_82", Dl = "_personalSidebar_1w53k_90", Ml = "_personalChatArea_1w53k_103", Ve = {
1760
+ shell: wl,
1761
+ inset: Sl,
1762
+ main: Il,
1763
+ pane: Al,
1764
+ skipLink: Bl,
1765
+ personalMainArea: Ll,
1766
+ personalSidebar: Dl,
1767
+ personalChatArea: Ml
1768
+ }, xl = "_sidebar_y5tuo_1", Rl = "_collapsed_y5tuo_12", Ol = "_sideHeader_y5tuo_17", $l = "_sideHeaderIcon_y5tuo_32", El = "_sideHeaderTitle_y5tuo_45", Hl = "_sideContent_y5tuo_54", Pl = "_groupLabel_y5tuo_61", Fl = "_navList_y5tuo_71", jl = "_navItem_y5tuo_77", Wl = "_navItemActive_y5tuo_109", Kl = "_navIcon_y5tuo_114", Ul = "_navLabel_y5tuo_120", Vl = "_sideFooter_y5tuo_131", Gl = "_footHint_y5tuo_138", te = {
1769
+ sidebar: xl,
1770
+ collapsed: Rl,
1771
+ sideHeader: Ol,
1772
+ sideHeaderIcon: $l,
1773
+ sideHeaderTitle: El,
1774
+ sideContent: Hl,
1775
+ groupLabel: Pl,
1776
+ navList: Fl,
1777
+ navItem: jl,
1778
+ navItemActive: Wl,
1779
+ navIcon: Kl,
1780
+ navLabel: Ul,
1781
+ sideFooter: Vl,
1782
+ footHint: Gl
1783
+ };
1784
+ function zl({
1785
+ items: n,
1786
+ activeTab: o,
1787
+ collapsed: u,
1788
+ footerItems: _,
1789
+ onSelect: k,
1790
+ onSwitchMode: R
1791
+ }) {
1792
+ return /* @__PURE__ */ l(
1793
+ "aside",
1794
+ {
1795
+ className: `${te.sidebar} ${u ? te.collapsed : ""}`,
1796
+ "aria-label": "个人工作台导航",
1797
+ children: [
1798
+ /* @__PURE__ */ l("div", { className: te.sideHeader, children: [
1799
+ /* @__PURE__ */ e("span", { className: te.sideHeaderIcon, children: /* @__PURE__ */ e(Qt, {}) }),
1800
+ !u && /* @__PURE__ */ e("span", { className: te.sideHeaderTitle, children: "个人工作台" })
1801
+ ] }),
1802
+ /* @__PURE__ */ l("div", { className: te.sideContent, children: [
1803
+ !u && /* @__PURE__ */ e("p", { className: te.groupLabel, children: "我的工作空间" }),
1804
+ /* @__PURE__ */ e("nav", { className: te.navList, "aria-label": "个人模块", children: n.map((y) => {
1805
+ const x = o === y.key, j = /* @__PURE__ */ l(
1806
+ "button",
1807
+ {
1808
+ type: "button",
1809
+ className: `${te.navItem} ${x ? te.navItemActive : ""}`,
1810
+ onClick: () => k(y.key),
1811
+ "aria-current": x ? "page" : void 0,
1812
+ children: [
1813
+ /* @__PURE__ */ e("span", { className: te.navIcon, children: y.icon }),
1814
+ !u && /* @__PURE__ */ e("span", { className: te.navLabel, children: y.label })
1815
+ ]
1816
+ },
1817
+ y.key
1818
+ );
1819
+ return u ? /* @__PURE__ */ e(kt, { placement: "right", title: y.label, children: j }, y.key) : j;
1820
+ }) })
1821
+ ] }),
1822
+ /* @__PURE__ */ l("div", { className: te.sideFooter, children: [
1823
+ _.length > 0 && /* @__PURE__ */ e("nav", { className: te.navList, "aria-label": "快捷切换", children: _.map((y) => {
1824
+ const x = /* @__PURE__ */ l(
1825
+ "button",
1826
+ {
1827
+ type: "button",
1828
+ className: te.navItem,
1829
+ onClick: () => R == null ? void 0 : R(y.mode),
1830
+ children: [
1831
+ /* @__PURE__ */ e("span", { className: te.navIcon, children: y.icon }),
1832
+ !u && /* @__PURE__ */ e("span", { className: te.navLabel, children: y.label })
1833
+ ]
1834
+ },
1835
+ y.mode
1836
+ );
1837
+ return u ? /* @__PURE__ */ e(kt, { placement: "right", title: y.label, children: x }, y.mode) : x;
1838
+ }) }),
1839
+ !u && /* @__PURE__ */ e("p", { className: te.footHint, children: "⌘ / Ctrl + B 切换导航" })
1840
+ ] })
1841
+ ]
1842
+ }
1843
+ );
1844
+ }
1845
+ const Ql = "_topbar_ms4b7_1", ql = "_topbarLeft_ms4b7_14", Xl = "_collapseBtn_ms4b7_22", Jl = "_crumbs_ms4b7_49", Yl = "_crumbsRoot_ms4b7_57", Zl = "_crumbsSep_ms4b7_62", ei = "_crumbsCurrent_ms4b7_68", ti = "_topbarRight_ms4b7_76", Ge = {
1846
+ topbar: Ql,
1847
+ topbarLeft: ql,
1848
+ collapseBtn: Xl,
1849
+ crumbs: Jl,
1850
+ crumbsRoot: Yl,
1851
+ crumbsSep: Zl,
1852
+ crumbsCurrent: ei,
1853
+ topbarRight: ti
1854
+ };
1855
+ function ni({
1856
+ label: n,
1857
+ collapsed: o,
1858
+ onToggleCollapse: u
1859
+ }) {
1860
+ return /* @__PURE__ */ l("header", { className: Ge.topbar, children: [
1861
+ /* @__PURE__ */ l("div", { className: Ge.topbarLeft, children: [
1862
+ /* @__PURE__ */ e(
1863
+ kt,
1864
+ {
1865
+ title: o ? "展开个人菜单" : "收起个人菜单",
1866
+ placement: "bottom",
1867
+ children: /* @__PURE__ */ e(
1868
+ "button",
1869
+ {
1870
+ type: "button",
1871
+ className: Ge.collapseBtn,
1872
+ onClick: u,
1873
+ "aria-label": "展开或收起个人菜单",
1874
+ "aria-expanded": !o,
1875
+ children: o ? /* @__PURE__ */ e(Qn, {}) : /* @__PURE__ */ e(qn, {})
1876
+ }
1877
+ )
1878
+ }
1879
+ ),
1880
+ /* @__PURE__ */ l("div", { className: Ge.crumbs, "aria-label": "当前位置", children: [
1881
+ /* @__PURE__ */ e("span", { className: Ge.crumbsRoot, children: "个人" }),
1882
+ /* @__PURE__ */ e(Vt, { className: Ge.crumbsSep }),
1883
+ /* @__PURE__ */ e("span", { className: Ge.crumbsCurrent, children: n })
1884
+ ] })
1885
+ ] }),
1886
+ /* @__PURE__ */ e("div", { className: Ge.topbarRight })
1887
+ ] });
1888
+ }
1889
+ const tn = [
1890
+ { key: "workbench", label: "场景工作台", icon: /* @__PURE__ */ e(Qt, {}) },
1891
+ { key: "projects", label: "工作单管理", icon: /* @__PURE__ */ e(Yn, {}) },
1892
+ { key: "personal", label: "个人统计", icon: /* @__PURE__ */ e(Zn, {}) },
1893
+ { key: "business-stats", label: "业务指标", icon: /* @__PURE__ */ e(es, {}) },
1894
+ { key: "tools", label: "常用工具", icon: /* @__PURE__ */ e(ts, {}) },
1895
+ { key: "websites", label: "常用网站", icon: /* @__PURE__ */ e(ns, {}) },
1896
+ { key: "smart-partner", label: "智能伙伴", icon: /* @__PURE__ */ e(zt, {}) },
1897
+ { key: "todo", label: "工作待办", icon: /* @__PURE__ */ e(ss, {}) },
1898
+ { key: "notes", label: "个人笔记", icon: /* @__PURE__ */ e(qt, {}) },
1899
+ {
1900
+ key: "training",
1901
+ label: "培训中心",
1902
+ icon: /* @__PURE__ */ e(as, {}),
1903
+ // 学员侧学习入口与培训管理(TRAINING)解耦:按需单独分配,不随培训入口发放
1904
+ permission: "TRAINING_CENTER"
1905
+ },
1906
+ { key: "webide", label: "WebIDE", icon: /* @__PURE__ */ e(ls, {}) }
1907
+ ], nn = "ft_pw_sidebar_collapsed";
1908
+ function si() {
1909
+ try {
1910
+ return localStorage.getItem(nn) === "1";
1911
+ } catch {
1912
+ return !1;
1913
+ }
1914
+ }
1915
+ function ai(n) {
1916
+ const o = n;
1917
+ return o ? o.tagName === "INPUT" || o.tagName === "TEXTAREA" || o.isContentEditable === !0 : !1;
1918
+ }
1919
+ function li() {
1920
+ try {
1921
+ const n = new URLSearchParams(window.location.search).get("tab");
1922
+ return n && tn.some((o) => o.key === n) ? n : null;
1923
+ } catch {
1924
+ return null;
1925
+ }
1926
+ }
1927
+ function ii({
1928
+ onOpenProject: n,
1929
+ openTodoId: o,
1930
+ selectedPersonalAgent: u,
1931
+ personalView: _,
1932
+ newSessionTrigger: k,
1933
+ onSelectPersonalAgent: R,
1934
+ onShowPersonalAgentDetail: y,
1935
+ onChatWithPersonalAgent: x,
1936
+ onSwitchMode: j
1937
+ }) {
1938
+ var f;
1939
+ const [D, $] = m(
1940
+ // 惰性初始化:命中深链时直接以目标 Tab 首屏渲染,不先渲染场景工作台再切
1941
+ () => li() ?? "workbench"
1942
+ );
1943
+ H(() => {
1944
+ try {
1945
+ const T = new URL(window.location.href);
1946
+ if (!T.searchParams.has("tab")) return;
1947
+ T.searchParams.delete("tab"), window.history.replaceState(window.history.state, "", T.toString());
1948
+ } catch {
1949
+ }
1950
+ }, []);
1951
+ const [P, E] = m(si);
1952
+ H(() => {
1953
+ try {
1954
+ localStorage.setItem(nn, P ? "1" : "0");
1955
+ } catch {
1956
+ }
1957
+ }, [P]);
1958
+ const B = J(() => {
1959
+ E((T) => !T), window.setTimeout(() => window.dispatchEvent(new Event("resize")), 300);
1960
+ }, []);
1961
+ H(() => {
1962
+ function T(Y) {
1963
+ !(Y.metaKey || Y.ctrlKey) || Y.altKey || Y.key.toLowerCase() === "b" && (ai(Y.target) || (Y.preventDefault(), B()));
1964
+ }
1965
+ return window.addEventListener("keydown", T), () => window.removeEventListener("keydown", T);
1966
+ }, [B]);
1967
+ const N = Ae((T) => T.currentUser), X = tn.filter(
1968
+ (T) => !T.permission || Ut(N, T.permission)
1969
+ ), V = $e(() => j ? [
1970
+ { mode: "admin", label: "运营工作台", icon: /* @__PURE__ */ e(Xn, {}) },
1971
+ { mode: "collaboration", label: "协作工作台", icon: /* @__PURE__ */ e(Jn, {}) }
1972
+ ].filter(
1973
+ (Y) => Wt(N, Y.mode)
1974
+ ) : [], [N, j]), de = ((f = X.find((T) => T.key === D)) == null ? void 0 : f.label) ?? "个人工作台", [L, w] = m(null), [W, I] = m(null), z = J((T) => {
1975
+ $(T);
1976
+ }, []), G = J((T) => {
1977
+ $("notes"), w({ id: T, ts: Date.now() });
1978
+ }, []), K = J((T) => {
1979
+ $("todo"), I({ id: T, ts: Date.now() });
1980
+ }, []);
1981
+ return H(() => {
1982
+ o != null && o.id && ($("todo"), I({ id: o.id, ts: o.ts }));
1983
+ }, [o == null ? void 0 : o.id, o == null ? void 0 : o.ts]), /* @__PURE__ */ l("div", { className: Ve.shell, children: [
1984
+ /* @__PURE__ */ e("a", { className: Ve.skipLink, href: "#pw-content", children: "跳到个人工作台内容" }),
1985
+ /* @__PURE__ */ e(
1986
+ zl,
1987
+ {
1988
+ items: X,
1989
+ activeTab: D,
1990
+ collapsed: P,
1991
+ footerItems: V,
1992
+ onSelect: $,
1993
+ onSwitchMode: j
1994
+ }
1995
+ ),
1996
+ /* @__PURE__ */ l("div", { className: Ve.inset, children: [
1997
+ /* @__PURE__ */ e(
1998
+ ni,
1999
+ {
2000
+ label: de,
2001
+ collapsed: P,
2002
+ onToggleCollapse: B
2003
+ }
2004
+ ),
2005
+ /* @__PURE__ */ e(
2006
+ "main",
2007
+ {
2008
+ id: "pw-content",
2009
+ tabIndex: -1,
2010
+ "aria-label": `${de}内容`,
2011
+ className: Ve.main,
2012
+ children: /* @__PURE__ */ l("div", { className: Ve.pane, children: [
2013
+ (D === "workbench" || D === "projects" || D === "personal") && /* @__PURE__ */ e(
2014
+ Ct,
2015
+ {
2016
+ activeTab: D,
2017
+ onActiveTabChange: z,
2018
+ onOpenProject: n,
2019
+ hideTabs: !0
2020
+ }
2021
+ ),
2022
+ D === "business-stats" && /* @__PURE__ */ e($t, { source: "scenario" }),
2023
+ D === "tools" && /* @__PURE__ */ e(pt, { showTools: !0, showWebsites: !1 }),
2024
+ D === "websites" && /* @__PURE__ */ e(pt, { showTools: !1, showWebsites: !0 }),
2025
+ D === "todo" && /* @__PURE__ */ e(
2026
+ Et,
2027
+ {
2028
+ onOpenProject: n,
2029
+ onOpenNote: G,
2030
+ openTodoId: W
2031
+ }
2032
+ ),
2033
+ D === "notes" && /* @__PURE__ */ e(
2034
+ Ht,
2035
+ {
2036
+ onOpenProject: n,
2037
+ onOpenTodo: K,
2038
+ openNoteId: L
2039
+ }
2040
+ ),
2041
+ D === "training" && /* @__PURE__ */ e(Xt, {}),
2042
+ D === "webide" && /* @__PURE__ */ e(Jt, {}),
2043
+ D === "smart-partner" && /* @__PURE__ */ l("div", { className: Ve.personalMainArea, children: [
2044
+ /* @__PURE__ */ e("div", { className: Ve.personalSidebar, children: /* @__PURE__ */ e(
2045
+ Tl,
2046
+ {
2047
+ selectedAgentId: (u == null ? void 0 : u.id) ?? null,
2048
+ selectedLocalAgentId: (u == null ? void 0 : u.localAgentId) ?? null,
2049
+ onSelectAgent: R,
2050
+ onShowDetail: y,
2051
+ onChatWithAgent: x
2052
+ }
2053
+ ) }),
2054
+ /* @__PURE__ */ e("div", { className: Ve.personalChatArea, children: _ === "detail" && u && !u.isLocal ? /* @__PURE__ */ e(
2055
+ Yt,
2056
+ {
2057
+ agent: u,
2058
+ onBack: () => R(u)
2059
+ }
2060
+ ) : u != null && u.isLocal ? /* @__PURE__ */ e(
2061
+ en,
2062
+ {
2063
+ agent: u,
2064
+ newSessionTrigger: k
2065
+ }
2066
+ ) : /* @__PURE__ */ e(
2067
+ Zt,
2068
+ {
2069
+ agent: u,
2070
+ newSessionTrigger: k
2071
+ }
2072
+ ) })
2073
+ ] })
2074
+ ] })
2075
+ }
2076
+ )
2077
+ ] })
2078
+ ] });
2079
+ }
2080
+ const oi = `${window.publicPath ?? "/"}logo.svg`, ci = [
2081
+ "帮我排查一个线上问题",
2082
+ "总结一下今天的群聊进展",
2083
+ "把这周的变更整理成周报"
2084
+ ], ri = [
2085
+ {
2086
+ key: "video",
2087
+ label: "视频生成",
2088
+ icon: /* @__PURE__ */ e(is, {}),
2089
+ action: "chat",
2090
+ prompt: "帮我写一条 15 秒短视频脚本,主题是:"
2091
+ },
2092
+ {
2093
+ key: "docs",
2094
+ label: "文档办公",
2095
+ icon: /* @__PURE__ */ e(qt, {}),
2096
+ action: "tools"
2097
+ },
2098
+ {
2099
+ key: "vibe",
2100
+ label: "Vibe Coding",
2101
+ icon: /* @__PURE__ */ e(wn, {}),
2102
+ action: "webide"
2103
+ },
2104
+ {
2105
+ key: "design",
2106
+ label: "设计视觉",
2107
+ icon: /* @__PURE__ */ e(Sn, {}),
2108
+ action: "chat",
2109
+ prompt: "帮我出一版视觉设计稿,风格偏:"
2110
+ },
2111
+ {
2112
+ key: "ask",
2113
+ label: "问问 Z-Team",
2114
+ icon: /* @__PURE__ */ e(ut, {}),
2115
+ action: "ask"
2116
+ }
2117
+ ];
2118
+ function di() {
2119
+ const n = (/* @__PURE__ */ new Date()).getHours();
2120
+ return n < 5 ? "夜深了" : n < 12 ? "早上好" : n < 14 ? "中午好" : n < 18 ? "下午好" : "晚上好";
2121
+ }
2122
+ function ui({
2123
+ agents: n,
2124
+ activeAgent: o,
2125
+ onSwitchAgent: u,
2126
+ localAgentName: _,
2127
+ onLocalSend: k,
2128
+ initialSpace: R,
2129
+ onSend: y,
2130
+ onOpenTab: x,
2131
+ onQuickAsk: j
2132
+ }) {
2133
+ 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), [w, W] = m(R ?? null), [I, z] = m(!1), G = J(async () => {
2134
+ const f = E.trim();
2135
+ if (!(!f || X)) {
2136
+ if (_ && k) {
2137
+ k(f), B("");
2138
+ return;
2139
+ }
2140
+ if (o) {
2141
+ V(!0);
2142
+ try {
2143
+ await y(f, w), B(""), W(null);
2144
+ } finally {
2145
+ V(!1);
2146
+ }
2147
+ }
2148
+ }
2149
+ }, [E, X, _, k, o, y, w]), K = P.nickname || ($ == null ? void 0 : $.display_name) || ($ == null ? void 0 : $.username) || "";
2150
+ return /* @__PURE__ */ e("div", { className: `${p.landing} ${p.xwScope}`, children: /* @__PURE__ */ l("div", { className: p.landingInner, children: [
2151
+ /* @__PURE__ */ e("div", { className: p.mascot, "aria-hidden": "true", children: /* @__PURE__ */ e("img", { src: oi, alt: "" }) }),
2152
+ /* @__PURE__ */ e("h1", { className: p.landingTitle, children: P.greetingEnabled ? `${di()}${K ? `,${K}` : ""}` : "开始新的对话" }),
2153
+ /* @__PURE__ */ e("p", { className: p.landingSub, children: P.bio || "我是你的智能伙伴,有什么可以帮你?" }),
2154
+ /* @__PURE__ */ l("div", { className: p.landingBox, children: [
2155
+ /* @__PURE__ */ e(
2156
+ "textarea",
2157
+ {
2158
+ ref: N,
2159
+ className: p.landingInput,
2160
+ placeholder: `给智能伙伴发送消息,${Hn(P.sendKey)}`,
2161
+ rows: 3,
2162
+ value: E,
2163
+ autoFocus: !0,
2164
+ onChange: (f) => B(f.target.value),
2165
+ onKeyDown: (f) => {
2166
+ Kt(f, P.sendKey) && !f.nativeEvent.isComposing && (f.preventDefault(), G());
2167
+ }
2168
+ }
2169
+ ),
2170
+ /* @__PURE__ */ l("div", { className: p.landingBoxBar, children: [
2171
+ _ ? /* @__PURE__ */ l("span", { className: p.agentChip, children: [
2172
+ /* @__PURE__ */ e(ut, {}),
2173
+ /* @__PURE__ */ l("span", { children: [
2174
+ _,
2175
+ "(本机)"
2176
+ ] })
2177
+ ] }) : o ? /* @__PURE__ */ l("div", { className: p.agentChipWrap, children: [
2178
+ /* @__PURE__ */ l(
2179
+ "button",
2180
+ {
2181
+ type: "button",
2182
+ className: p.agentChip,
2183
+ onClick: () => L((f) => !f),
2184
+ children: [
2185
+ /* @__PURE__ */ e(ut, {}),
2186
+ /* @__PURE__ */ e("span", { children: o.displayName }),
2187
+ n.length > 1 && /* @__PURE__ */ e(vt, { className: p.chipCaret })
2188
+ ]
2189
+ }
2190
+ ),
2191
+ de && n.length > 1 && /* @__PURE__ */ l(Ee, { children: [
2192
+ /* @__PURE__ */ e(
2193
+ "div",
2194
+ {
2195
+ className: p.agentMenuMask,
2196
+ onClick: () => L(!1)
2197
+ }
2198
+ ),
2199
+ /* @__PURE__ */ e("div", { className: p.agentMenu, role: "menu", children: n.map((f) => /* @__PURE__ */ l(
2200
+ "button",
2201
+ {
2202
+ type: "button",
2203
+ role: "menuitem",
2204
+ className: `${p.agentMenuItem} ${f.id === o.id ? p.agentMenuItemActive : ""}`,
2205
+ onClick: () => {
2206
+ u(f), L(!1);
2207
+ },
2208
+ children: [
2209
+ /* @__PURE__ */ e(
2210
+ "span",
2211
+ {
2212
+ className: p.agentDot,
2213
+ style: { background: vn(f.displayName) },
2214
+ children: bn(f.displayName)
2215
+ }
2216
+ ),
2217
+ f.displayName
2218
+ ]
2219
+ },
2220
+ f.id
2221
+ )) })
2222
+ ] })
2223
+ ] }) : /* @__PURE__ */ e("span", { className: p.agentChipEmpty, children: "还没有云端伙伴,可到个人工作台创建" }),
2224
+ !_ && o && /* @__PURE__ */ l("div", { className: p.agentChipWrap, children: [
2225
+ /* @__PURE__ */ l(
2226
+ "button",
2227
+ {
2228
+ type: "button",
2229
+ className: p.agentChip,
2230
+ title: "本次新建任务归入的项目空间(可选)",
2231
+ onClick: () => z((f) => !f),
2232
+ children: [
2233
+ /* @__PURE__ */ e(Nt, {}),
2234
+ /* @__PURE__ */ e("span", { children: w ? w.title : "不归组" }),
2235
+ /* @__PURE__ */ e(vt, { className: p.chipCaret })
2236
+ ]
2237
+ }
2238
+ ),
2239
+ I && /* @__PURE__ */ l(Ee, { children: [
2240
+ /* @__PURE__ */ e(
2241
+ "div",
2242
+ {
2243
+ className: p.agentMenuMask,
2244
+ onClick: () => z(!1)
2245
+ }
2246
+ ),
2247
+ /* @__PURE__ */ e(
2248
+ Nn,
2249
+ {
2250
+ token: D,
2251
+ currentId: (w == null ? void 0 : w.id) ?? null,
2252
+ onPick: (f) => {
2253
+ W(f), z(!1);
2254
+ }
2255
+ }
2256
+ )
2257
+ ] })
2258
+ ] }),
2259
+ /* @__PURE__ */ e(
2260
+ "button",
2261
+ {
2262
+ type: "button",
2263
+ className: p.landingSend,
2264
+ disabled: !E.trim() || X || !o && !_,
2265
+ onClick: () => void G(),
2266
+ "aria-label": "发送",
2267
+ children: X ? /* @__PURE__ */ e(Cn, {}) : /* @__PURE__ */ e(kn, {})
2268
+ }
2269
+ )
2270
+ ] })
2271
+ ] }),
2272
+ /* @__PURE__ */ l("div", { className: p.contextRow, children: [
2273
+ /* @__PURE__ */ l("span", { className: p.contextChip, children: [
2274
+ /* @__PURE__ */ e(Nt, {}),
2275
+ /* @__PURE__ */ e("span", { children: w ? w.title : "未归组" })
2276
+ ] }),
2277
+ /* @__PURE__ */ e("span", { className: p.contextChip, children: _ ? /* @__PURE__ */ l(Ee, { children: [
2278
+ /* @__PURE__ */ e(ut, {}),
2279
+ /* @__PURE__ */ l("span", { children: [
2280
+ _,
2281
+ "(本机)"
2282
+ ] })
2283
+ ] }) : /* @__PURE__ */ l(Ee, { children: [
2284
+ /* @__PURE__ */ e(Tn, {}),
2285
+ /* @__PURE__ */ e("span", { children: "云端" })
2286
+ ] }) })
2287
+ ] }),
2288
+ /* @__PURE__ */ e("div", { className: p.chipRow, children: ri.map((f) => /* @__PURE__ */ l(
2289
+ "button",
2290
+ {
2291
+ type: "button",
2292
+ className: p.capChip,
2293
+ onClick: () => {
2294
+ var T;
2295
+ if (f.action === "tools") {
2296
+ x("tools");
2297
+ return;
2298
+ }
2299
+ if (f.action === "webide") {
2300
+ x("webide");
2301
+ return;
2302
+ }
2303
+ if (f.action === "ask") {
2304
+ j();
2305
+ return;
2306
+ }
2307
+ B(f.prompt ?? ""), (T = N.current) == null || T.focus();
2308
+ },
2309
+ children: [
2310
+ /* @__PURE__ */ e("span", { className: p.capChipIcon, children: f.icon }),
2311
+ /* @__PURE__ */ e("span", { children: f.label })
2312
+ ]
2313
+ },
2314
+ f.key
2315
+ )) }),
2316
+ /* @__PURE__ */ e("div", { className: p.chipRow, children: ci.map((f) => /* @__PURE__ */ e(
2317
+ "button",
2318
+ {
2319
+ type: "button",
2320
+ className: p.suggestChip,
2321
+ onClick: () => {
2322
+ var T;
2323
+ B(f), (T = N.current) == null || T.focus();
2324
+ },
2325
+ children: f
2326
+ },
2327
+ f
2328
+ )) })
2329
+ ] }) });
2330
+ }
2331
+ const re = On() || typeof localStorage < "u" && localStorage.getItem("ft_exclusive_force_desktop") === "1";
2332
+ function mi(n) {
2333
+ return n.type === "jar" ? {
2334
+ id: "-1",
2335
+ userId: "local",
2336
+ agentHubAgentId: null,
2337
+ agentCode: "local-default",
2338
+ displayName: n.name || "本地 Agent",
2339
+ avatar: null,
2340
+ isLocal: !0
2341
+ } : {
2342
+ id: "-1",
2343
+ userId: "local",
2344
+ agentHubAgentId: null,
2345
+ agentCode: n.name,
2346
+ displayName: n.name,
2347
+ avatar: null,
2348
+ isLocal: !0,
2349
+ localAgentId: n.id,
2350
+ localAgentType: n.type
2351
+ };
2352
+ }
2353
+ function Ii({
2354
+ onSwitchMode: n,
2355
+ onOpenProject: o,
2356
+ openAgentRequest: u
2357
+ }) {
2358
+ 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(
2359
+ re ? "local" : "cloud"
2360
+ ), [L, w] = m(
2361
+ []
2362
+ ), [W, I] = m([]), [z, G] = m(!0), [K, f] = m(!1), T = Ae((s) => s.projects), [Y, Be] = m([]), [ve, Z] = m(null), [ke, ge] = m(
2363
+ /* @__PURE__ */ new Set()
2364
+ ), [Te, He] = m(0), [Pe, we] = m(null), [_e, Le] = m(!1), [oe, De] = m([]), [Ne, Me] = m(null), [ue, xe] = m(null), fe = J(
2365
+ (s) => {
2366
+ const g = In(s);
2367
+ g && !Ut(k, g) || (Se(s), B("personalTab"));
2368
+ },
2369
+ [k]
2370
+ ), [ze, Fe] = m(!1), [qe, je] = m(
2371
+ null
2372
+ ), [a, b] = m(
2373
+ null
2374
+ ), [Q, Ce] = m(
2375
+ null
2376
+ ), ne = J(
2377
+ (s, g) => {
2378
+ o == null || o(s, g);
2379
+ },
2380
+ [o]
2381
+ ), me = J((s) => {
2382
+ Se("todo"), Ce({ id: s, ts: Date.now() });
2383
+ }, []), [se, Se] = m("personal"), We = q(!1), ce = $e(() => An(y), [y]), ae = $e(
2384
+ () => y.find((s) => s.id === $) ?? ce,
2385
+ [y, $, ce]
2386
+ );
2387
+ re && _e && oe.length > 0;
2388
+ const le = $e(
2389
+ () => oe.find((s) => s.id === Ne) ?? null,
2390
+ [oe, Ne]
2391
+ );
2392
+ H(() => {
2393
+ let s = !0;
2394
+ return D(!0), Pt(_).then((g) => {
2395
+ s && x(g);
2396
+ }).catch(() => {
2397
+ }).finally(() => {
2398
+ s && D(!1);
2399
+ }), () => {
2400
+ s = !1;
2401
+ };
2402
+ }, [_]), H(() => {
2403
+ if (!re) return;
2404
+ let s = !0;
2405
+ const g = async () => {
2406
+ const M = await bt();
2407
+ if (s) {
2408
+ if (Le(M), !M) {
2409
+ De([]);
2410
+ return;
2411
+ }
2412
+ try {
2413
+ const pe = await jt();
2414
+ s && De(pe);
2415
+ } catch {
2416
+ }
2417
+ }
2418
+ };
2419
+ g();
2420
+ const A = window.setInterval(() => void g(), 3e4);
2421
+ return () => {
2422
+ s = !1, window.clearInterval(A);
2423
+ };
2424
+ }, []), H(() => {
2425
+ if (!re || oe.length === 0 || Ne && oe.some((g) => g.id === Ne))
2426
+ return;
2427
+ const s = oe.find((g) => g.type === "jar");
2428
+ Me((s ?? oe[0]).id);
2429
+ }, [oe, Ne]);
2430
+ const Ye = $e(() => {
2431
+ const s = /* @__PURE__ */ new Map();
2432
+ for (const g of y) s.set(g.id, g);
2433
+ return s;
2434
+ }, [y]), Ze = J(async () => {
2435
+ G(!0);
2436
+ const [s, g] = await Promise.allSettled([
2437
+ dn(_),
2438
+ Pn(_)
2439
+ ]);
2440
+ if (s.status === "fulfilled" && w(s.value || []), g.status === "fulfilled") {
2441
+ const A = /* @__PURE__ */ new Set(), M = [];
2442
+ for (const pe of [...g.value.owned, ...g.value.joined])
2443
+ A.has(pe.id) || (A.add(pe.id), M.push(pe));
2444
+ I(M);
2445
+ }
2446
+ G(!1);
2447
+ }, [_]);
2448
+ H(() => {
2449
+ Ze();
2450
+ }, [Ze, N == null ? void 0 : N.ts]);
2451
+ const Re = $e(() => {
2452
+ const s = /* @__PURE__ */ new Map();
2453
+ for (const U of W)
2454
+ s.set(`sp:${String(U.id)}`, {
2455
+ key: `sp:${String(U.id)}`,
2456
+ title: U.title,
2457
+ sessions: []
2458
+ });
2459
+ const g = [], A = [...L].sort(
2460
+ (U, ee) => (ee.updateTime || ee.createTime || "").localeCompare(
2461
+ U.updateTime || U.createTime || ""
2462
+ )
2463
+ );
2464
+ for (const U of A)
2465
+ if (U.projectSpaceId != null) {
2466
+ const ee = `sp:${String(U.projectSpaceId)}`;
2467
+ s.has(ee) || s.set(ee, {
2468
+ key: ee,
2469
+ title: U.projectSpaceTitle || `空间 ${U.projectSpaceId}`,
2470
+ sessions: []
2471
+ }), s.get(ee).sessions.push(U);
2472
+ } else
2473
+ g.push(U);
2474
+ const M = (U) => {
2475
+ var ee, nt;
2476
+ return ((ee = U.sessions[0]) == null ? void 0 : ee.updateTime) || ((nt = U.sessions[0]) == null ? void 0 : nt.createTime) || "";
2477
+ }, pe = [...s.values()];
2478
+ 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;
2479
+ }, [W, L]), et = $e(
2480
+ () => {
2481
+ var s;
2482
+ return N != null && N.sessionId ? ((s = Re.find(
2483
+ (g) => g.sessions.some((A) => A.id === N.sessionId)
2484
+ )) == null ? void 0 : s.key) ?? null : null;
2485
+ },
2486
+ [Re, N == null ? void 0 : N.sessionId]
2487
+ );
2488
+ H(() => {
2489
+ var g;
2490
+ const s = et ?? (We.current ? null : ((g = Re.find((A) => A.sessions.length > 0)) == null ? void 0 : g.key) ?? null);
2491
+ s && (We.current = !0, ge(
2492
+ (A) => A.has(s) ? A : new Set(A).add(s)
2493
+ ));
2494
+ }, [et, Re]);
2495
+ const at = le && le.type !== "jar" ? le.id : void 0;
2496
+ H(() => {
2497
+ if (!re || V !== "local" || !_e) return;
2498
+ let s = !0;
2499
+ return Ft(at).then((g) => {
2500
+ s && Be([...g].sort((A, M) => M.updatedAt - A.updatedAt));
2501
+ }).catch(() => {
2502
+ s && Be([]);
2503
+ }), () => {
2504
+ s = !1;
2505
+ };
2506
+ }, [
2507
+ V,
2508
+ _e,
2509
+ at,
2510
+ ve,
2511
+ Te
2512
+ ]);
2513
+ const ht = J(() => Z(null), []), lt = (s) => {
2514
+ X(null), Z(s), B("chat");
2515
+ }, ye = (s, g = null, A = null) => {
2516
+ P(s.id), X(
2517
+ (M) => M && M.agent.id === s.id && M.sessionId === g && !A ? M : { agent: s, sessionId: g, draft: A, ts: Date.now() }
2518
+ ), B("chat");
2519
+ };
2520
+ H(() => {
2521
+ const s = u;
2522
+ if (!(s != null && s.agent) || !s.ts) return;
2523
+ const g = s.agent;
2524
+ if (P(g.id), s.view === "detail") {
2525
+ je(g), B("agentDetail");
2526
+ return;
2527
+ }
2528
+ ye(g, s.sessionId ?? null), s.newSession > 0 && He((A) => A + 1);
2529
+ }, [u == null ? void 0 : u.ts]);
2530
+ const Xe = () => {
2531
+ P((ce == null ? void 0 : ce.id) ?? null), X(null), setLandingInput(""), B("landing");
2532
+ }, it = () => {
2533
+ He((s) => s + 1), X(null), B("chat");
2534
+ }, ot = () => {
2535
+ if (re && le) {
2536
+ it();
2537
+ return;
2538
+ }
2539
+ if (ce) {
2540
+ ye(ce);
2541
+ return;
2542
+ }
2543
+ Xe();
2544
+ }, gt = () => {
2545
+ N ? B("chat") : ce && ye(ce);
2546
+ }, Qe = async (s, g) => {
2547
+ if (ae)
2548
+ try {
2549
+ const A = s.length > 20 ? `${s.slice(0, 20)}…` : s, M = await un(
2550
+ ae.id,
2551
+ A,
2552
+ _,
2553
+ g
2554
+ );
2555
+ xe(null), X({
2556
+ agent: ae,
2557
+ sessionId: M.id,
2558
+ draft: s,
2559
+ ts: Date.now()
2560
+ }), B("chat");
2561
+ } catch {
2562
+ }
2563
+ }, Ke = (s) => {
2564
+ we(s), B("chat");
2565
+ }, tt = R.nickname || (k == null ? void 0 : k.display_name) || (k == null ? void 0 : k.username) || "", _t = $e(() => n ? [
2566
+ {
2567
+ mode: "personal",
2568
+ label: "个人工作台",
2569
+ icon: /* @__PURE__ */ e(xn, {})
2570
+ },
2571
+ {
2572
+ mode: "collaboration",
2573
+ label: "协作工作台",
2574
+ icon: /* @__PURE__ */ e(Rn, {})
2575
+ }
2576
+ ].filter(
2577
+ (g) => Wt(k, g.mode)
2578
+ ) : [], [k, n]), ct = N ? `${N.agent.id}-${N.sessionId ?? 0}-${N.ts}` : "none";
2579
+ let be;
2580
+ return E === "agentDetail" && qe ? be = /* @__PURE__ */ e("div", { className: p.detailHost, children: /* @__PURE__ */ e(
2581
+ Yt,
2582
+ {
2583
+ agent: qe,
2584
+ onBack: () => B("extensions")
2585
+ }
2586
+ ) }) : E === "schedule" ? be = /* @__PURE__ */ e(ds, { localOnline: _e }) : E === "extensions" ? be = /* @__PURE__ */ e(
2587
+ us,
2588
+ {
2589
+ agents: y,
2590
+ loading: j,
2591
+ skillsAgent: ce,
2592
+ token: _,
2593
+ currentUser: k,
2594
+ onChat: (s) => ye(s),
2595
+ onConfig: (s) => {
2596
+ je(s), B("agentDetail");
2597
+ },
2598
+ onCreated: (s) => x((g) => [...g, s]),
2599
+ onOpenPersonalTab: fe,
2600
+ onOpenWorkbenchShell: () => B("workbenchShell")
2601
+ }
2602
+ ) : E === "history" ? be = /* @__PURE__ */ e(
2603
+ ms,
2604
+ {
2605
+ agents: y,
2606
+ token: _,
2607
+ onOpenSession: (s, g) => ye(s, g)
2608
+ }
2609
+ ) : E === "workbenchShell" ? be = /* @__PURE__ */ e(
2610
+ ii,
2611
+ {
2612
+ onOpenProject: ne,
2613
+ selectedPersonalAgent: ae,
2614
+ personalView: "chat",
2615
+ newSessionTrigger: Te,
2616
+ onSelectPersonalAgent: (s) => P((s == null ? void 0 : s.id) ?? null),
2617
+ onShowPersonalAgentDetail: (s) => {
2618
+ je(s), B("agentDetail");
2619
+ },
2620
+ onChatWithPersonalAgent: (s) => ye(s),
2621
+ onSwitchMode: n
2622
+ }
2623
+ ) : E === "personalTab" ? be = /* @__PURE__ */ l("div", { className: p.personalTabHost, children: [
2624
+ se === "projects" && /* @__PURE__ */ e(
2625
+ Ct,
2626
+ {
2627
+ activeTab: "projects",
2628
+ onActiveTabChange: () => {
2629
+ },
2630
+ onOpenProject: ne,
2631
+ hideTabs: !0
2632
+ }
2633
+ ),
2634
+ se === "personal" && /* @__PURE__ */ e(
2635
+ Ct,
2636
+ {
2637
+ activeTab: "personal",
2638
+ onActiveTabChange: () => {
2639
+ },
2640
+ onOpenProject: ne,
2641
+ hideTabs: !0
2642
+ }
2643
+ ),
2644
+ se === "business-stats" && /* @__PURE__ */ e($t, { source: "scenario" }),
2645
+ se === "tools" && /* @__PURE__ */ e(pt, { showTools: !0, showWebsites: !1 }),
2646
+ se === "websites" && /* @__PURE__ */ e(pt, { showTools: !1, showWebsites: !0 }),
2647
+ se === "todo" && /* @__PURE__ */ e(
2648
+ Et,
2649
+ {
2650
+ onOpenProject: ne,
2651
+ onOpenNote: (s) => {
2652
+ Se("notes"), b({ id: s, ts: Date.now() });
2653
+ },
2654
+ openTodoId: Q
2655
+ }
2656
+ ),
2657
+ se === "notes" && /* @__PURE__ */ e(
2658
+ Ht,
2659
+ {
2660
+ onOpenProject: ne,
2661
+ onOpenTodo: me,
2662
+ openNoteId: a
2663
+ }
2664
+ ),
2665
+ se === "training" && /* @__PURE__ */ e(Xt, {}),
2666
+ se === "webide" && /* @__PURE__ */ e(Jt, {})
2667
+ ] }) : N ? be = /* @__PURE__ */ e("div", { className: p.chatHost, children: /* @__PURE__ */ e(
2668
+ Zt,
2669
+ {
2670
+ agent: N.agent,
2671
+ initialSessionId: N.sessionId,
2672
+ autoSendDraft: N.draft,
2673
+ chromeless: !0,
2674
+ agents: y,
2675
+ onSwitchAgent: (s) => ye(s)
2676
+ },
2677
+ ct
2678
+ ) }) : re && le && E !== "landing" ? be = /* @__PURE__ */ e("div", { className: p.chatHost, children: /* @__PURE__ */ e(
2679
+ en,
2680
+ {
2681
+ agent: mi(le),
2682
+ newSessionTrigger: Te,
2683
+ autoSendDraft: Pe,
2684
+ onAutoSendConsumed: () => we(null),
2685
+ openSessionId: ve,
2686
+ onOpenSessionConsumed: ht
2687
+ },
2688
+ le.id
2689
+ ) }) : be = /* @__PURE__ */ e(
2690
+ ui,
2691
+ {
2692
+ agents: y,
2693
+ activeAgent: ae,
2694
+ onSwitchAgent: (s) => P(s.id),
2695
+ localAgentName: re && le ? le.name : null,
2696
+ onLocalSend: Ke,
2697
+ initialSpace: ue,
2698
+ onSend: Qe,
2699
+ onOpenTab: fe,
2700
+ onQuickAsk: ot
2701
+ }
2702
+ ), /* @__PURE__ */ l("div", { className: p.shell, children: [
2703
+ /* @__PURE__ */ l("aside", { className: p.sidebar, "aria-label": "个人专享工作台导航", children: [
2704
+ /* @__PURE__ */ l("div", { className: p.sideContent, children: [
2705
+ /* @__PURE__ */ e(
2706
+ Bn,
2707
+ {
2708
+ currentUser: k,
2709
+ token: _,
2710
+ isDesktop: re,
2711
+ activeNav: E === "schedule" ? "schedule" : E === "history" ? "history" : null,
2712
+ extensionsGroupActive: [
2713
+ "extensions",
2714
+ "agentDetail",
2715
+ "personalTab",
2716
+ "workbenchShell"
2717
+ ].includes(E),
2718
+ activePersonalTab: E === "personalTab" ? se : null,
2719
+ onDesktopNewTask: re && le ? it : void 0,
2720
+ onNewTaskLanding: re ? void 0 : Xe,
2721
+ onPickSpace: (s) => {
2722
+ xe(s), Xe();
2723
+ },
2724
+ currentSpaceId: (ue == null ? void 0 : ue.id) ?? null,
2725
+ onOpenSchedule: () => B("schedule"),
2726
+ onOpenExtensions: () => B("extensions"),
2727
+ onOpenHistory: () => B("history"),
2728
+ onOpenSearch: () => {
2729
+ f(!0), Ae.getState().loadProjects();
2730
+ },
2731
+ searchActive: K,
2732
+ onOpenPersonalTab: fe,
2733
+ onOpenWorkbenchShell: () => B("workbenchShell"),
2734
+ onCloudNav: re ? gt : void 0,
2735
+ cloudNavActive: E === "chat" && !!N
2736
+ }
2737
+ ),
2738
+ /* @__PURE__ */ l("div", { className: p.sideTasks, children: [
2739
+ re && /* @__PURE__ */ l(
2740
+ "div",
2741
+ {
2742
+ className: p.segToggle,
2743
+ role: "tablist",
2744
+ "aria-label": "任务范围切换",
2745
+ children: [
2746
+ /* @__PURE__ */ e(
2747
+ "button",
2748
+ {
2749
+ type: "button",
2750
+ role: "tab",
2751
+ "aria-selected": V === "local",
2752
+ className: `${p.segBtn} ${V === "local" ? p.segBtnActive : ""}`,
2753
+ onClick: () => de("local"),
2754
+ children: "本地"
2755
+ }
2756
+ ),
2757
+ /* @__PURE__ */ e(
2758
+ "button",
2759
+ {
2760
+ type: "button",
2761
+ role: "tab",
2762
+ "aria-selected": V === "cloud",
2763
+ className: `${p.segBtn} ${V === "cloud" ? p.segBtnActive : ""}`,
2764
+ onClick: () => de("cloud"),
2765
+ children: "云端"
2766
+ }
2767
+ )
2768
+ ]
2769
+ }
2770
+ ),
2771
+ re && V === "local" ? /* @__PURE__ */ l(Ee, { children: [
2772
+ /* @__PURE__ */ e("div", { className: p.tasksLabel, children: "本地任务" }),
2773
+ Y.map((s) => /* @__PURE__ */ e(
2774
+ "button",
2775
+ {
2776
+ type: "button",
2777
+ className: `${p.recentItem} ${ve === s.id ? p.recentItemActive : ""}`,
2778
+ title: s.title,
2779
+ onClick: () => lt(s.id),
2780
+ children: /* @__PURE__ */ e("span", { className: p.recentItemText, children: s.title || "未命名会话" })
2781
+ },
2782
+ s.id
2783
+ )),
2784
+ Y.length === 0 && /* @__PURE__ */ e("div", { className: p.tasksEmpty, children: _e ? "暂无本地任务,点上方新建任务开始" : "本机 Agent 未运行" })
2785
+ ] }) : /* @__PURE__ */ l(Ee, { children: [
2786
+ /* @__PURE__ */ e("div", { className: p.tasksLabel, children: "项目" }),
2787
+ Re.length === 0 && !z && /* @__PURE__ */ e("div", { className: p.tasksEmpty, children: "还没有项目空间或云端任务" }),
2788
+ Re.map((s) => {
2789
+ const g = ke.has(s.key);
2790
+ return /* @__PURE__ */ l("div", { children: [
2791
+ /* @__PURE__ */ l(
2792
+ "button",
2793
+ {
2794
+ type: "button",
2795
+ className: p.projFolder,
2796
+ "aria-expanded": g,
2797
+ onClick: () => ge((A) => {
2798
+ const M = new Set(A);
2799
+ return M.has(s.key) ? M.delete(s.key) : M.add(s.key), M;
2800
+ }),
2801
+ children: [
2802
+ /* @__PURE__ */ e(
2803
+ vt,
2804
+ {
2805
+ className: `${p.projCaret} ${g ? p.projCaretOpen : ""}`
2806
+ }
2807
+ ),
2808
+ /* @__PURE__ */ e(Nt, { className: p.projIcon }),
2809
+ /* @__PURE__ */ e("span", { className: p.projName, title: s.title, children: s.title }),
2810
+ /* @__PURE__ */ e("span", { className: p.projMeta, children: s.sessions.length > 0 ? s.sessions.length : "暂无任务" })
2811
+ ]
2812
+ }
2813
+ ),
2814
+ g && s.sessions.length > 0 && /* @__PURE__ */ e("div", { className: p.projRows, children: s.sessions.map((A) => {
2815
+ const M = Ye.get(A.personalAgentId);
2816
+ return /* @__PURE__ */ e(
2817
+ "button",
2818
+ {
2819
+ type: "button",
2820
+ className: `${p.recentItem} ${(N == null ? void 0 : N.sessionId) === A.id ? p.recentItemActive : ""}`,
2821
+ disabled: !M,
2822
+ title: M ? A.title || "未命名会话" : "伙伴已不存在,无法打开",
2823
+ onClick: () => M && ye(M, A.id),
2824
+ children: /* @__PURE__ */ e("span", { className: p.recentItemText, children: A.title || "未命名会话" })
2825
+ },
2826
+ A.id
2827
+ );
2828
+ }) })
2829
+ ] }, s.key);
2830
+ })
2831
+ ] })
2832
+ ] })
2833
+ ] }),
2834
+ /* @__PURE__ */ e(
2835
+ Ln,
2836
+ {
2837
+ displayName: tt,
2838
+ subtitle: "Z-Team · 个人(专享)",
2839
+ onOpenSettings: () => Fe(!0),
2840
+ children: _t.map((s) => /* @__PURE__ */ l(
2841
+ "button",
2842
+ {
2843
+ type: "button",
2844
+ role: "menuitem",
2845
+ className: p.agentMenuItem,
2846
+ onClick: () => n == null ? void 0 : n(s.mode),
2847
+ children: [
2848
+ /* @__PURE__ */ e("span", { className: p.navIcon, children: s.icon }),
2849
+ /* @__PURE__ */ e("span", { children: s.label })
2850
+ ]
2851
+ },
2852
+ s.mode
2853
+ ))
2854
+ }
2855
+ )
2856
+ ] }),
2857
+ /* @__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 }),
2858
+ /* @__PURE__ */ e(
2859
+ Dn,
2860
+ {
2861
+ open: ze,
2862
+ onClose: () => Fe(!1),
2863
+ token: _
2864
+ }
2865
+ ),
2866
+ K && /* @__PURE__ */ e(
2867
+ Mn,
2868
+ {
2869
+ sessions: L,
2870
+ agentsById: Ye,
2871
+ projects: T,
2872
+ token: _,
2873
+ onOpenSession: (s, g) => ye(s, g),
2874
+ onOpenProject: (s) => ne(s.id),
2875
+ onClose: () => f(!1)
2876
+ }
2877
+ )
2878
+ ] });
2879
+ }
2880
+ export {
2881
+ Ii as default
2882
+ };