@yuku123/z-team-component 0.2.52 → 0.2.54

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