@yuku123/z-team-component 0.2.52 → 0.2.53

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