@yuku123/z-team-component 0.2.91 → 0.2.92
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.
- package/dist/{ChangeLogView-DagOxr6O.js → ChangeLogView-DMVBdFFX.js} +12 -12
- package/dist/ComponentDoc-Boc9n2c_.js +8035 -0
- package/dist/{InvitationManagementPage-DYoqQA0v.js → InvitationManagementPage-B4UJQBrv.js} +1 -1
- package/dist/{OnboardingPage-D2Gm8MRd.js → OnboardingPage-BuDvSKMx.js} +2 -2
- package/dist/{ScheduledTasks-DB3VxAnb.js → ScheduledTasks-DY4iYtX3.js} +4341 -4337
- package/dist/{SystemShell-D3jHItxY.js → SystemShell-UVZjsfJs.js} +11 -12
- package/dist/admin-logs-OIyOdfuC.js +198 -0
- package/dist/{api-DYsAzJJo.js → api-mJ7FvgsR.js} +1 -1
- package/dist/createWorkspaceWsHandler-9k7O4P-D.js +13135 -0
- package/dist/{index-B5dDwxhs.js → index-BMt6Z1yA.js} +1 -1
- package/dist/{index-Cw6MIoNv.js → index-Bi6mbk7-.js} +6 -7
- package/dist/{index-E4Q6JmzX.js → index-BxRNZbw5.js} +3 -3
- package/dist/{index-CgWa7RFv.js → index-C2LwqjZQ.js} +23 -24
- package/dist/{index-BZ12pY96.js → index-COLSSd6V.js} +2 -2
- package/dist/{index-BfzgRKii.js → index-CYe2nfiG.js} +90 -91
- package/dist/{index-BYe87pnq.js → index-CeYCMcgX.js} +11 -12
- package/dist/index-Ckpc_Z6-.js +3495 -0
- package/dist/{index-BMQ6XkO3.js → index-CpA8ev3a.js} +1 -1
- package/dist/{index-VGtET31b.js → index-CpwvgQ3b.js} +1 -1
- package/dist/{index-W_4faD_M.js → index-CsHpsX_P.js} +2 -2
- package/dist/{index-CYyFYmlZ.js → index-CwNtNKwX.js} +8 -9
- package/dist/index-D1odHNMR.js +316 -0
- package/dist/{index-DyQ9YnMd.js → index-D74FCwtx.js} +3629 -3473
- package/dist/{index-Dwqa30HZ.js → index-D83QI-17.js} +4 -4
- package/dist/{index-Cggl78j7.js → index-DeHC7MtX.js} +5 -6
- package/dist/{index-ues0LW7p.js → index-FAhDAnIy.js} +1257 -1258
- package/dist/{index-C8cR7lJw.js → index-GHQ4Tl6H.js} +10 -11
- package/dist/{index-BaCqZeiw.js → index-Gk-5X-GO.js} +1 -1
- package/dist/{index-CZyFAmEq.js → index-Hm6ZaRmP.js} +10 -11
- package/dist/{index-CLfhHxPf.js → index-TW4txhve.js} +1 -1
- package/dist/{index-DE82vM_4.js → index-kwnNAAM0.js} +19 -18
- package/dist/{index-CSpckSHg.js → index-r4IxoITP.js} +23 -23
- package/dist/{index-CLD5lLa6.js → index-s5yeUpMA.js} +19 -19
- package/dist/{index-152G-_4j.js → index-zEqjsTFh.js} +5 -6
- package/dist/index.js +1 -1
- package/dist/{instance-CI6-4BZ6.js → instance-BpY3BXci.js} +1 -1
- package/dist/{menuPermission-C33I6ujb.js → menuPermission-DX8KlB6K.js} +11 -11
- package/dist/pages.js +8 -8
- package/dist/{send-default-agent-team-message-c5oKdQQA.js → send-default-agent-team-message-DVFuAdE9.js} +1 -1
- package/dist/{sso-user-DToM5dPy.js → sso-user-BBkFFo35.js} +1 -1
- package/dist/{training-B38tnwLL.js → training-BCi9cA6O.js} +1 -1
- package/dist/webide-MQ5gD1Go.js +5233 -0
- package/dist/z-team-component.css +1 -26
- package/package.json +3 -2
- package/dist/ComponentDoc-Bqfu128t.js +0 -3998
- package/dist/admin-logs-ogvMwS4O.js +0 -302
- package/dist/api-BftpestH.js +0 -2156
- package/dist/createWorkspaceWsHandler-D8h5BEzH.js +0 -13030
- package/dist/index-CUVdeb8y.js +0 -638
- package/dist/index-DVaTGA2z.js +0 -3488
- package/dist/schedule-ChO2xIGd.js +0 -625
- package/dist/useAppStore-uc8v8XZC.js +0 -1920
- package/dist/webide-BuUYLPSp.js +0 -8399
|
@@ -1,1920 +0,0 @@
|
|
|
1
|
-
import { create as Ce } from "zustand";
|
|
2
|
-
import { Q as je, x as M, i as C, y as ne, k as A, t as _, z as se, A as Pe, C as Ne, D as we, E as Ee, F as xe, G as Fe, H as ae, I as Re, J as Oe, K as B, L as Ue, M as He, w as ie, N as Le, O as $e, P as Ge, R as De, S as Ve, U as Be, V as qe, W as ze, X as Ke, Y as We, Z as Je, _ as Ye, $ as Ze, a0 as Qe, a1 as Xe, s as x, a2 as et, a3 as oe, a4 as tt, a5 as nt, a6 as rt, a7 as st, a8 as at, a9 as it, aa as ot, ab as ct, c as lt, ac as ut, ad as dt, m as ft, ae as mt } from "./api-BftpestH.js";
|
|
3
|
-
import { message as F } from "antd";
|
|
4
|
-
const _e = `[[REASONING:正在分析…]]
|
|
5
|
-
正在分析…
|
|
6
|
-
[[/REASONING]]
|
|
7
|
-
|
|
8
|
-
`;
|
|
9
|
-
function ce(n) {
|
|
10
|
-
const t = n.trim();
|
|
11
|
-
return t === "正在分析…" || t === "正在分析...";
|
|
12
|
-
}
|
|
13
|
-
function xt(n) {
|
|
14
|
-
var e;
|
|
15
|
-
if (n.type != null && n.type !== "reasoning")
|
|
16
|
-
return !1;
|
|
17
|
-
if (ce(n.text))
|
|
18
|
-
return !0;
|
|
19
|
-
const t = ((e = n.name) == null ? void 0 : e.trim()) ?? "";
|
|
20
|
-
return ce(t);
|
|
21
|
-
}
|
|
22
|
-
function Q(n) {
|
|
23
|
-
if (n === "处理中..." || n === "🔄 正在处理中...")
|
|
24
|
-
return !0;
|
|
25
|
-
const t = n.trim();
|
|
26
|
-
return t ? t === _e.trim() ? !0 : /^\[\[REASONING:正在分析[\s\S]*?\[\[\/REASONING\]\]\s*$/u.test(
|
|
27
|
-
t
|
|
28
|
-
) : !1;
|
|
29
|
-
}
|
|
30
|
-
function Ft(n) {
|
|
31
|
-
return n === "处理中..." || n === "🔄 正在处理中..." ? !0 : n.trim() === _e.trim();
|
|
32
|
-
}
|
|
33
|
-
function re(n, t) {
|
|
34
|
-
if (!t || n.member_type !== "HUMAN")
|
|
35
|
-
return !1;
|
|
36
|
-
const e = String(n.ref_id ?? "").trim();
|
|
37
|
-
if (!e)
|
|
38
|
-
return !1;
|
|
39
|
-
if (t.id != null && Number(t.id) > 0 && e === String(t.id))
|
|
40
|
-
return !0;
|
|
41
|
-
const r = String(t.username ?? "").trim();
|
|
42
|
-
if (r.length > 0 && e === r)
|
|
43
|
-
return !0;
|
|
44
|
-
const s = String(t.display_name ?? "").trim();
|
|
45
|
-
return s.length > 0 && e === s;
|
|
46
|
-
}
|
|
47
|
-
function q(n, t) {
|
|
48
|
-
const e = n.find(
|
|
49
|
-
(s) => s.member_type === "HUMAN" && re(s, t)
|
|
50
|
-
);
|
|
51
|
-
if (e) return e;
|
|
52
|
-
const r = String((t == null ? void 0 : t.display_name) ?? "").trim();
|
|
53
|
-
if (r)
|
|
54
|
-
return n.find((s) => {
|
|
55
|
-
if (s.member_type !== "HUMAN") return !1;
|
|
56
|
-
const a = String(s.display_name ?? "").trim();
|
|
57
|
-
return a === r || a.startsWith(`${r}(`);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
function ye(n) {
|
|
61
|
-
return !!(n != null && n.is_global_admin);
|
|
62
|
-
}
|
|
63
|
-
function Rt(n) {
|
|
64
|
-
return ye(n);
|
|
65
|
-
}
|
|
66
|
-
function pt(n) {
|
|
67
|
-
var e;
|
|
68
|
-
return ((e = n == null ? void 0 : n.scenario_code) == null ? void 0 : e.trim().toLowerCase()) === je;
|
|
69
|
-
}
|
|
70
|
-
function he(n, t) {
|
|
71
|
-
return pt(n) && !ye(t);
|
|
72
|
-
}
|
|
73
|
-
function le(n, t, e) {
|
|
74
|
-
return he(n, t) || (e ?? (n == null ? void 0 : n.mode) ?? "build").trim().toLowerCase() === "plan" ? "plan" : "build";
|
|
75
|
-
}
|
|
76
|
-
function D(n, t) {
|
|
77
|
-
if (n == null || t == null) return !1;
|
|
78
|
-
const e = Number(n), r = Number(t);
|
|
79
|
-
return !Number.isNaN(e) && !Number.isNaN(r) && e > 0 && e === r;
|
|
80
|
-
}
|
|
81
|
-
function Se(n) {
|
|
82
|
-
return String(n.sender_type || "HUMAN").toUpperCase() === "HUMAN";
|
|
83
|
-
}
|
|
84
|
-
function gt(n, t) {
|
|
85
|
-
var s;
|
|
86
|
-
const e = n.trim(), r = (s = t == null ? void 0 : t.display_name) == null ? void 0 : s.trim();
|
|
87
|
-
return !e || !r ? !1 : e === r || e.startsWith(`${r}(`);
|
|
88
|
-
}
|
|
89
|
-
function ke(n, t) {
|
|
90
|
-
const e = n.sender_id;
|
|
91
|
-
if (e == null)
|
|
92
|
-
return;
|
|
93
|
-
const r = t.find(
|
|
94
|
-
(s) => s.member_type === "HUMAN" && D(s.id, e)
|
|
95
|
-
);
|
|
96
|
-
return r || t.find(
|
|
97
|
-
(s) => s.member_type === "HUMAN" && String(s.ref_id) === String(e)
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
function _t(n, t, e, r) {
|
|
101
|
-
if (!Se(n))
|
|
102
|
-
return !1;
|
|
103
|
-
const s = ke(n, r);
|
|
104
|
-
return !s || t && D(s.id, t.id) ? !1 : !re(s, e);
|
|
105
|
-
}
|
|
106
|
-
function Te(n, t, e, r) {
|
|
107
|
-
var o;
|
|
108
|
-
if (!Se(n))
|
|
109
|
-
return !1;
|
|
110
|
-
if (n.is_own === !0 || t && n.sender_id != null && D(n.sender_id, t.id) || e != null && e.id && n.sender_id != null && D(n.sender_id, e.id))
|
|
111
|
-
return !0;
|
|
112
|
-
const s = ke(n, r);
|
|
113
|
-
if (s)
|
|
114
|
-
return re(s, e);
|
|
115
|
-
const a = (o = n.sender_name) == null ? void 0 : o.trim();
|
|
116
|
-
if (a && e && gt(a, e))
|
|
117
|
-
return !0;
|
|
118
|
-
if (a && (t != null && t.display_name)) {
|
|
119
|
-
const i = t.display_name.trim();
|
|
120
|
-
if (a === i || a.startsWith(`${i}(`))
|
|
121
|
-
return !0;
|
|
122
|
-
}
|
|
123
|
-
return !1;
|
|
124
|
-
}
|
|
125
|
-
function Ot(n) {
|
|
126
|
-
return Number(n.sender_id) === 0 ? !0 : (n.content || "").trim().startsWith("【任务 #");
|
|
127
|
-
}
|
|
128
|
-
function Ut(n) {
|
|
129
|
-
if (!n) return "";
|
|
130
|
-
try {
|
|
131
|
-
const t = n.trim(), e = /[zZ]$|[+-]\d{2}:?\d{2}$/.test(t) ? new Date(t) : /* @__PURE__ */ new Date(`${t.replace(" ", "T")}+08:00`);
|
|
132
|
-
if (Number.isNaN(e.getTime()))
|
|
133
|
-
return "";
|
|
134
|
-
const r = String(e.getMonth() + 1).padStart(2, "0"), s = String(e.getDate()).padStart(2, "0"), a = String(e.getHours()).padStart(2, "0"), o = String(e.getMinutes()).padStart(2, "0"), i = String(e.getSeconds()).padStart(2, "0");
|
|
135
|
-
return `${r}-${s} ${a}:${o}:${i}`;
|
|
136
|
-
} catch {
|
|
137
|
-
return "";
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function Ht(n, t) {
|
|
141
|
-
if (n.sender_type !== "AGENT")
|
|
142
|
-
return !1;
|
|
143
|
-
const e = n.task_id ?? null;
|
|
144
|
-
for (let r = t.length - 1; r >= 0; r--) {
|
|
145
|
-
const s = t[r];
|
|
146
|
-
if (!(s.sender_type !== "AGENT" || (s.task_id ?? null) !== e))
|
|
147
|
-
return s.id === n.id;
|
|
148
|
-
}
|
|
149
|
-
return !1;
|
|
150
|
-
}
|
|
151
|
-
function Lt(n, t) {
|
|
152
|
-
const e = n.content === "处理中..." || n.content === "🔄 正在处理中...", r = n.content.includes("[[REASONING:");
|
|
153
|
-
if (!e && !r)
|
|
154
|
-
return !1;
|
|
155
|
-
const s = n.task_id ?? null, a = Object.values(t).filter(
|
|
156
|
-
(o) => s ? o.task_id === s : !o.task_id
|
|
157
|
-
);
|
|
158
|
-
if (M(n.id) && r)
|
|
159
|
-
return a.some((o) => !o.completed);
|
|
160
|
-
for (const o of a) {
|
|
161
|
-
if (o.completed || o.agentName !== n.sender_name)
|
|
162
|
-
continue;
|
|
163
|
-
if (e)
|
|
164
|
-
return !0;
|
|
165
|
-
const i = o.stepName || "";
|
|
166
|
-
if (i === "思考中" || i === "已启动" || i === "执行中" || i.startsWith("调用工具"))
|
|
167
|
-
return !0;
|
|
168
|
-
}
|
|
169
|
-
return !1;
|
|
170
|
-
}
|
|
171
|
-
function $t(n) {
|
|
172
|
-
return typeof n.content == "string" && (n.content.includes("【卡片表单已确认】") || n.content.includes("【卡片表单已提交】"));
|
|
173
|
-
}
|
|
174
|
-
function E(n) {
|
|
175
|
-
return n.sender_type !== "AGENT" ? !1 : n.message_type === "TURN_SUMMARY" ? !0 : n.content.includes("**本轮小结**") || n.content.includes("[[TURN_SUMMARY_REF");
|
|
176
|
-
}
|
|
177
|
-
const Ae = /\[\[TURN_SUMMARY_REF trigger_message_id=(\d+) agent_reply_id=(\d+)(?: preview="([^"]*)")?\]\]/;
|
|
178
|
-
function Me(n) {
|
|
179
|
-
const t = n.match(Ae);
|
|
180
|
-
return t ? {
|
|
181
|
-
// 正则抓到的是数字串,**原样保留**。曾经写成 Number(match[1]):
|
|
182
|
-
// 19 位 message_id 进 float64 后末位被抹掉,再拿去和字符串 m.id 比较,
|
|
183
|
-
// 两边永远不相等 —— 「本轮小结」的触发消息关联整个是死的,且不报任何错。
|
|
184
|
-
triggerMessageId: t[1],
|
|
185
|
-
agentReplyId: t[2],
|
|
186
|
-
preview: t[3] || void 0
|
|
187
|
-
} : null;
|
|
188
|
-
}
|
|
189
|
-
function yt(n) {
|
|
190
|
-
return n.replace(Ae, "").trimEnd();
|
|
191
|
-
}
|
|
192
|
-
function Gt(n) {
|
|
193
|
-
let t = yt(n);
|
|
194
|
-
return t = t.replace(/^\*\*本轮小结\*\*\s*/i, ""), t = t.replace(/^>\s*针对用户消息[^\n]*\n+/m, ""), t = t.replace(/^_生成中…_\s*/m, ""), t.trim();
|
|
195
|
-
}
|
|
196
|
-
function Dt(n) {
|
|
197
|
-
const t = /* @__PURE__ */ new Map();
|
|
198
|
-
for (const e of n) {
|
|
199
|
-
if (!E(e))
|
|
200
|
-
continue;
|
|
201
|
-
const r = Me(e.content);
|
|
202
|
-
(r == null ? void 0 : r.agentReplyId) != null && t.set(r.agentReplyId, e);
|
|
203
|
-
}
|
|
204
|
-
return t;
|
|
205
|
-
}
|
|
206
|
-
function Vt(n, t) {
|
|
207
|
-
const e = Me(n.content);
|
|
208
|
-
if (e != null && e.preview)
|
|
209
|
-
return e.preview;
|
|
210
|
-
if ((e == null ? void 0 : e.triggerMessageId) != null) {
|
|
211
|
-
const r = t.find((s) => s.id === e.triggerMessageId);
|
|
212
|
-
if (r != null && r.content) {
|
|
213
|
-
const s = r.content.trim();
|
|
214
|
-
return s.length > 40 ? `${s.slice(0, 40)}…` : s;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return "";
|
|
218
|
-
}
|
|
219
|
-
function ht(n) {
|
|
220
|
-
return n.sender_type !== "AGENT" || E(n) || n.content === "已取消" ? !1 : n.content === "处理中..." || n.content === "🔄 正在处理中..." || Q(n.content) || n.content.includes("[[REASONING:") || n.content.includes("[[TOOL_CALL:");
|
|
221
|
-
}
|
|
222
|
-
function z(n, t, e, r, s, a) {
|
|
223
|
-
if (C(a))
|
|
224
|
-
return a;
|
|
225
|
-
const o = t ? s : r, i = t ?? null;
|
|
226
|
-
for (let c = o.length - 1; c >= 0; c--) {
|
|
227
|
-
const l = o[c];
|
|
228
|
-
if (l.sender_type !== "AGENT" || E(l))
|
|
229
|
-
continue;
|
|
230
|
-
if (i != null) {
|
|
231
|
-
if (l.task_id != null && l.task_id !== i)
|
|
232
|
-
continue;
|
|
233
|
-
} else if (l.task_id)
|
|
234
|
-
continue;
|
|
235
|
-
if (!(n && l.sender_name !== n || Object.values(e).some(
|
|
236
|
-
(d) => d.loadingMessageId === l.id
|
|
237
|
-
)) && (ht(l) || l.content === "处理中..." || l.content === "🔄 正在处理中..."))
|
|
238
|
-
return l.id;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
function St(n, t) {
|
|
242
|
-
if (n.sender_type !== "AGENT" || E(n) || n.content === "已取消")
|
|
243
|
-
return null;
|
|
244
|
-
for (const [e, r] of Object.entries(t))
|
|
245
|
-
if (!r.completed && r.loadingMessageId === n.id)
|
|
246
|
-
return Number(e);
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
function Bt(n, t) {
|
|
250
|
-
return n.sender_type !== "AGENT" || E(n) ? null : St(n, t);
|
|
251
|
-
}
|
|
252
|
-
const ue = [
|
|
253
|
-
"#2F70F1",
|
|
254
|
-
"#52c41a",
|
|
255
|
-
"#fa8c16",
|
|
256
|
-
"#eb2f96",
|
|
257
|
-
"#722ed1",
|
|
258
|
-
"#13c2c2",
|
|
259
|
-
"#f5222d",
|
|
260
|
-
"#faad14"
|
|
261
|
-
];
|
|
262
|
-
function qt(n) {
|
|
263
|
-
let t = 0;
|
|
264
|
-
for (let e = 0; e < n.length; e++) t = t * 31 + n.charCodeAt(e) | 0;
|
|
265
|
-
return ue[Math.abs(t) % ue.length];
|
|
266
|
-
}
|
|
267
|
-
function zt(n) {
|
|
268
|
-
return n ? n.charAt(0).toUpperCase() : "?";
|
|
269
|
-
}
|
|
270
|
-
function Kt(n, t, e, r, s) {
|
|
271
|
-
return Te(t, e, r, s);
|
|
272
|
-
}
|
|
273
|
-
function h(n, t = "success", e) {
|
|
274
|
-
switch (t) {
|
|
275
|
-
case "error":
|
|
276
|
-
F.error(n, e);
|
|
277
|
-
break;
|
|
278
|
-
case "warning":
|
|
279
|
-
F.warning(n, e);
|
|
280
|
-
break;
|
|
281
|
-
case "info":
|
|
282
|
-
F.info(n, e);
|
|
283
|
-
break;
|
|
284
|
-
default:
|
|
285
|
-
F.success(n, e);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
function Wt() {
|
|
289
|
-
return null;
|
|
290
|
-
}
|
|
291
|
-
const de = 20, fe = 200;
|
|
292
|
-
function R(n) {
|
|
293
|
-
const t = n == null ? void 0 : n.trim();
|
|
294
|
-
if (!t) return 0;
|
|
295
|
-
try {
|
|
296
|
-
const r = (/[zZ]$|[+-]\d{2}:?\d{2}$/.test(t) ? new Date(t) : /* @__PURE__ */ new Date(`${t.replace(" ", "T")}+08:00`)).getTime();
|
|
297
|
-
return Number.isNaN(r) ? 0 : r;
|
|
298
|
-
} catch {
|
|
299
|
-
return 0;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
function Jt(n) {
|
|
303
|
-
const t = n == null ? void 0 : n.trim();
|
|
304
|
-
if (!t)
|
|
305
|
-
return "";
|
|
306
|
-
const e = t.match(/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2})(?::\d{2})?$/);
|
|
307
|
-
if (e)
|
|
308
|
-
return e[1];
|
|
309
|
-
try {
|
|
310
|
-
const r = /[zZ]$|[+-]\d{2}:?\d{2}$/.test(t) ? new Date(t) : /* @__PURE__ */ new Date(`${t.replace(" ", "T")}+08:00`);
|
|
311
|
-
return Number.isNaN(r.getTime()) ? t : r.toLocaleString("zh-CN", {
|
|
312
|
-
year: "numeric",
|
|
313
|
-
month: "2-digit",
|
|
314
|
-
day: "2-digit",
|
|
315
|
-
hour: "2-digit",
|
|
316
|
-
minute: "2-digit",
|
|
317
|
-
hour12: !1
|
|
318
|
-
});
|
|
319
|
-
} catch {
|
|
320
|
-
return t;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
function X(n, t) {
|
|
324
|
-
return `${t ?? ""}\0${n ?? ""}`;
|
|
325
|
-
}
|
|
326
|
-
function Yt(n) {
|
|
327
|
-
const t = /* @__PURE__ */ new Map();
|
|
328
|
-
for (const r of Object.values(n)) {
|
|
329
|
-
const s = X(r.agentName, r.task_id), a = t.get(s) ?? [];
|
|
330
|
-
a.push(r), t.set(s, a);
|
|
331
|
-
}
|
|
332
|
-
const e = [];
|
|
333
|
-
for (const r of t.values()) {
|
|
334
|
-
r.sort((c, l) => ne(c.executionId, l.executionId));
|
|
335
|
-
const s = r[0], a = r.length - 1, o = Math.max(s.pendingCount ?? 0, a), i = [...r].reverse().find((c) => {
|
|
336
|
-
const l = c.stepName || "";
|
|
337
|
-
return l !== "排队中" && l !== "已启动";
|
|
338
|
-
}) ?? r[r.length - 1];
|
|
339
|
-
e.push({
|
|
340
|
-
...i,
|
|
341
|
-
// 停止按钮应取消当前正在执行的消息,而非队列里最早的那条
|
|
342
|
-
executionId: i.executionId,
|
|
343
|
-
agentName: s.agentName,
|
|
344
|
-
agentAvatar: s.agentAvatar,
|
|
345
|
-
task_id: s.task_id,
|
|
346
|
-
pendingCount: o,
|
|
347
|
-
queuedExecutionIds: r.filter((c) => !A(c.executionId, i.executionId)).map((c) => c.executionId)
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
return e;
|
|
351
|
-
}
|
|
352
|
-
function me(n, t) {
|
|
353
|
-
const e = n[t] ?? Object.values(n).find(
|
|
354
|
-
(s) => {
|
|
355
|
-
var a;
|
|
356
|
-
return (a = s.queuedExecutionIds) == null ? void 0 : a.some((o) => A(o, t));
|
|
357
|
-
}
|
|
358
|
-
);
|
|
359
|
-
if (!e)
|
|
360
|
-
return [t];
|
|
361
|
-
const r = X(e.agentName, e.task_id);
|
|
362
|
-
return Object.values(n).filter((s) => X(s.agentName, s.task_id) === r).map((s) => s.executionId);
|
|
363
|
-
}
|
|
364
|
-
const Ie = "$ref";
|
|
365
|
-
function N(n) {
|
|
366
|
-
const t = _(n);
|
|
367
|
-
return C(t) ? t : void 0;
|
|
368
|
-
}
|
|
369
|
-
function ve(n) {
|
|
370
|
-
if (!n || typeof n != "object" || Array.isArray(n))
|
|
371
|
-
return !1;
|
|
372
|
-
const t = Object.keys(n);
|
|
373
|
-
return t.length === 1 && t[0] === Ie;
|
|
374
|
-
}
|
|
375
|
-
function j(n) {
|
|
376
|
-
if (!(!n || typeof n != "object" || Array.isArray(n)) && !ve(n))
|
|
377
|
-
return n;
|
|
378
|
-
}
|
|
379
|
-
function w(n) {
|
|
380
|
-
return !n || ve(n) ? !1 : Object.entries(n).some(([t, e]) => t === Ie ? !1 : Array.isArray(e) ? e.length > 0 : typeof e == "string" ? e.trim() !== "" : typeof e == "number" || typeof e == "boolean");
|
|
381
|
-
}
|
|
382
|
-
function kt(n) {
|
|
383
|
-
var s;
|
|
384
|
-
const t = j(n.submittedValue);
|
|
385
|
-
if (w(t))
|
|
386
|
-
return t;
|
|
387
|
-
const e = j((s = n.cardForm) == null ? void 0 : s.value);
|
|
388
|
-
if (w(e))
|
|
389
|
-
return e;
|
|
390
|
-
const r = typeof n.result == "string" && n.result.trim() ? n.result.trim() : "";
|
|
391
|
-
return r ? { response: r } : {};
|
|
392
|
-
}
|
|
393
|
-
function Tt(n) {
|
|
394
|
-
if (n == null || n === "")
|
|
395
|
-
return null;
|
|
396
|
-
if (typeof n == "object" && !Array.isArray(n))
|
|
397
|
-
return n;
|
|
398
|
-
if (typeof n != "string")
|
|
399
|
-
return null;
|
|
400
|
-
try {
|
|
401
|
-
const t = JSON.parse(n);
|
|
402
|
-
return !t || typeof t != "object" || Array.isArray(t) ? null : t;
|
|
403
|
-
} catch {
|
|
404
|
-
return null;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
function Zt(n, t) {
|
|
408
|
-
const e = t.result == null || t.result === "" ? n.result : String(t.result), r = Tt(t.ext), s = j(
|
|
409
|
-
(r == null ? void 0 : r.submittedValue) ?? (r == null ? void 0 : r.submitted_value)
|
|
410
|
-
), a = {
|
|
411
|
-
...n,
|
|
412
|
-
result: e,
|
|
413
|
-
submittedValue: w(n.submittedValue) ? n.submittedValue : s ?? n.submittedValue
|
|
414
|
-
};
|
|
415
|
-
return be(a) ?? a;
|
|
416
|
-
}
|
|
417
|
-
function be(n) {
|
|
418
|
-
if (!n || typeof n != "object")
|
|
419
|
-
return null;
|
|
420
|
-
const t = n, e = N(t.humanTaskId ?? t.human_task_id);
|
|
421
|
-
if (e == null)
|
|
422
|
-
return null;
|
|
423
|
-
const r = j(t.cardForm) ?? j(t.card_form), s = j(t.submittedValue ?? t.submitted_value), a = typeof t.result == "string" ? t.result : void 0, o = kt({
|
|
424
|
-
submittedValue: s,
|
|
425
|
-
cardForm: r,
|
|
426
|
-
result: a
|
|
427
|
-
}), i = r && w(o) ? { ...r, value: o } : r;
|
|
428
|
-
return {
|
|
429
|
-
humanTaskId: e,
|
|
430
|
-
agentTaskId: N(t.agentTaskId ?? t.agent_task_id),
|
|
431
|
-
scenarioInstanceId: N(
|
|
432
|
-
t.scenarioInstanceId ?? t.scenario_instance_id
|
|
433
|
-
),
|
|
434
|
-
// humanTaskStatus 是状态码而非 ID,不能走 idOrUndefined(会变成字符串)
|
|
435
|
-
humanTaskStatus: At(t.humanTaskStatus ?? t.human_task_status),
|
|
436
|
-
assistType: typeof t.assistType == "string" ? t.assistType : typeof t.assist_type == "string" ? t.assist_type : void 0,
|
|
437
|
-
assignee: t.assignee && typeof t.assignee == "object" ? t.assignee : void 0,
|
|
438
|
-
cardForm: i,
|
|
439
|
-
cardFormId: N(t.cardFormId ?? t.card_form_id),
|
|
440
|
-
promotedMessageId: N(
|
|
441
|
-
t.promotedMessageId ?? t.promoted_message_id
|
|
442
|
-
),
|
|
443
|
-
instruction: typeof t.instruction == "string" ? t.instruction : void 0,
|
|
444
|
-
submittedValue: w(o) ? o : s,
|
|
445
|
-
result: a,
|
|
446
|
-
pending: t.pending === !0 || t.pending === "true",
|
|
447
|
-
canSubmit: t.canSubmit === !0 || t.can_submit === !0
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
function At(n) {
|
|
451
|
-
const t = Number(n);
|
|
452
|
-
return Number.isFinite(t) ? t : void 0;
|
|
453
|
-
}
|
|
454
|
-
function ee(n) {
|
|
455
|
-
const t = String(
|
|
456
|
-
n.sender_type ?? n.senderType ?? "HUMAN"
|
|
457
|
-
).toUpperCase(), e = n.sender_id ?? n.senderId, r = se(e), s = n.task_id ?? n.taskId, a = se(s), o = n.is_own ?? n.isOwn;
|
|
458
|
-
let i;
|
|
459
|
-
o === !0 || o === "true" ? i = !0 : (o === !1 || o === "false") && (i = !1);
|
|
460
|
-
const c = n.ext, l = c == null || c === "" ? null : typeof c == "string" ? c : JSON.stringify(c), u = n.read_status ?? n.readStatus ?? null;
|
|
461
|
-
let d = null;
|
|
462
|
-
if (u && typeof u == "object") {
|
|
463
|
-
const f = u;
|
|
464
|
-
d = {
|
|
465
|
-
read_count: Number(f.read_count ?? 0),
|
|
466
|
-
unread_count: Number(f.unread_count ?? 0),
|
|
467
|
-
read_members: Array.isArray(f.read_members) ? f.read_members : [],
|
|
468
|
-
unread_members: Array.isArray(f.unread_members) ? f.unread_members : []
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
return {
|
|
472
|
-
id: _(n.id),
|
|
473
|
-
scenario_instance_id: _(
|
|
474
|
-
n.scenario_instance_id ?? n.scenarioInstanceId
|
|
475
|
-
),
|
|
476
|
-
sender_type: t,
|
|
477
|
-
sender_id: r,
|
|
478
|
-
message_type: String(n.message_type ?? n.messageType ?? "TEXT"),
|
|
479
|
-
content: String(n.content ?? ""),
|
|
480
|
-
task_id: a == null || !C(a) ? null : a,
|
|
481
|
-
ext: l,
|
|
482
|
-
created_at: String(n.created_at ?? n.createdAt ?? ""),
|
|
483
|
-
sender_name: String(n.sender_name ?? n.senderName ?? ""),
|
|
484
|
-
sender_avatar: String(n.sender_avatar ?? n.senderAvatar ?? ""),
|
|
485
|
-
is_own: i,
|
|
486
|
-
read_status: d,
|
|
487
|
-
human_assist_card: be(
|
|
488
|
-
n.human_assist_card ?? n.humanAssistCard
|
|
489
|
-
)
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
function Mt(n, t) {
|
|
493
|
-
var a, o, i, c;
|
|
494
|
-
const e = (a = n.sender_name) == null ? void 0 : a.trim();
|
|
495
|
-
if (e)
|
|
496
|
-
return e;
|
|
497
|
-
const r = String(n.sender_type || "HUMAN").toUpperCase();
|
|
498
|
-
if (r === "SYSTEM")
|
|
499
|
-
return "系统";
|
|
500
|
-
const s = n.sender_id;
|
|
501
|
-
if (s != null && Number(s) === 0)
|
|
502
|
-
return "系统";
|
|
503
|
-
if (s != null) {
|
|
504
|
-
const l = t.find((u) => Number(u.id) === Number(s));
|
|
505
|
-
if ((o = l == null ? void 0 : l.display_name) != null && o.trim())
|
|
506
|
-
return l.display_name.trim();
|
|
507
|
-
if ((l == null ? void 0 : l.member_type) === "AGENT") {
|
|
508
|
-
const u = (c = (i = l.agent_info) == null ? void 0 : i.name) == null ? void 0 : c.trim();
|
|
509
|
-
if (u)
|
|
510
|
-
return u;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
return r === "AGENT" ? "助手" : r === "HUMAN" ? "成员" : "";
|
|
514
|
-
}
|
|
515
|
-
function G(n, t) {
|
|
516
|
-
const e = Mt(n, t);
|
|
517
|
-
return e === n.sender_name ? n : { ...n, sender_name: e };
|
|
518
|
-
}
|
|
519
|
-
const K = /* @__PURE__ */ new Map(), W = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new Map();
|
|
520
|
-
function O() {
|
|
521
|
-
return {
|
|
522
|
-
members: [],
|
|
523
|
-
availableAgents: [],
|
|
524
|
-
availableHumans: [],
|
|
525
|
-
messages: [],
|
|
526
|
-
hasMoreMessages: !1,
|
|
527
|
-
skills: []
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
function Y(n, t) {
|
|
531
|
-
const e = n.findIndex((i) => i.id === t.id);
|
|
532
|
-
if (e !== -1) {
|
|
533
|
-
const i = [...n];
|
|
534
|
-
return i[e] = t, i;
|
|
535
|
-
}
|
|
536
|
-
const r = t.created_at ? new Date(t.created_at).getTime() : 0, s = t.id ?? 0;
|
|
537
|
-
let a = n.length;
|
|
538
|
-
for (let i = 0; i < n.length; i++) {
|
|
539
|
-
const c = n[i].created_at ? new Date(n[i].created_at).getTime() : 0;
|
|
540
|
-
if (c > r || c === r && (n[i].id ?? 0) > s) {
|
|
541
|
-
a = i;
|
|
542
|
-
break;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
const o = [...n];
|
|
546
|
-
return o.splice(a, 0, t), o;
|
|
547
|
-
}
|
|
548
|
-
function U(n) {
|
|
549
|
-
return [...n].sort((t, e) => {
|
|
550
|
-
const r = t.created_at ? new Date(t.created_at).getTime() : 0, s = e.created_at ? new Date(e.created_at).getTime() : 0;
|
|
551
|
-
return r !== s ? r - s : ne(t.id, e.id);
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
function Z(n) {
|
|
555
|
-
const t = n.task_id;
|
|
556
|
-
return t == null || ne(t, "0") <= 0;
|
|
557
|
-
}
|
|
558
|
-
function It(n) {
|
|
559
|
-
if (!n) return !1;
|
|
560
|
-
const t = n.cardForm;
|
|
561
|
-
return !!(t && t.status === "pending");
|
|
562
|
-
}
|
|
563
|
-
function pe(n) {
|
|
564
|
-
const t = /* @__PURE__ */ new Set();
|
|
565
|
-
for (const e of n)
|
|
566
|
-
if (e.message_type === "AGENT_RESULT" && e.ext)
|
|
567
|
-
try {
|
|
568
|
-
const r = typeof e.ext == "string" ? JSON.parse(e.ext) : e.ext;
|
|
569
|
-
if ((r == null ? void 0 : r.taskId) != null) {
|
|
570
|
-
if (It(r))
|
|
571
|
-
continue;
|
|
572
|
-
t.add(_(r.taskId));
|
|
573
|
-
}
|
|
574
|
-
} catch {
|
|
575
|
-
}
|
|
576
|
-
return t.size === 0 ? n : n.filter((e) => {
|
|
577
|
-
if (e.message_type !== "TASK_PROGRESS") return !0;
|
|
578
|
-
try {
|
|
579
|
-
const r = JSON.parse(e.content);
|
|
580
|
-
return !t.has(_(r.taskId));
|
|
581
|
-
} catch {
|
|
582
|
-
return !0;
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
function te(n, t) {
|
|
587
|
-
return n.map((e) => ee(e)).map((e) => G(e, t));
|
|
588
|
-
}
|
|
589
|
-
function vt(n, t, e) {
|
|
590
|
-
return te(n, t).map((r) => ({
|
|
591
|
-
...r,
|
|
592
|
-
task_id: r.task_id ?? e
|
|
593
|
-
}));
|
|
594
|
-
}
|
|
595
|
-
function H(n) {
|
|
596
|
-
return n.length <= fe ? n : n.slice(n.length - fe);
|
|
597
|
-
}
|
|
598
|
-
function bt(n, t, e) {
|
|
599
|
-
if (t.sender_id == null)
|
|
600
|
-
return null;
|
|
601
|
-
const r = n.findIndex(
|
|
602
|
-
(a) => M(a.id) && a.sender_type === "AGENT" && a.sender_id === t.sender_id && (t.task_id ? a.task_id === t.task_id : !a.task_id) && e(a.content)
|
|
603
|
-
);
|
|
604
|
-
if (r === -1)
|
|
605
|
-
return null;
|
|
606
|
-
const s = [...n];
|
|
607
|
-
return s[r] = { ...t, id: t.id }, s;
|
|
608
|
-
}
|
|
609
|
-
function Ct(n) {
|
|
610
|
-
var r;
|
|
611
|
-
const t = (r = n.currentProject) == null ? void 0 : r.id;
|
|
612
|
-
if (t == null)
|
|
613
|
-
return n.projectCache;
|
|
614
|
-
const e = _(t);
|
|
615
|
-
return {
|
|
616
|
-
...n.projectCache,
|
|
617
|
-
[e]: {
|
|
618
|
-
members: n.members,
|
|
619
|
-
availableAgents: n.availableAgents,
|
|
620
|
-
availableHumans: n.availableHumans,
|
|
621
|
-
messages: n.messages,
|
|
622
|
-
hasMoreMessages: n.hasMoreMessages,
|
|
623
|
-
skills: n.skills
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
const L = 80;
|
|
628
|
-
let ge = 0;
|
|
629
|
-
function jt(n) {
|
|
630
|
-
let t = (n || "").trim();
|
|
631
|
-
if (!t) return "";
|
|
632
|
-
t.length > 2e3 && (t = t.slice(0, 2e3));
|
|
633
|
-
const e = t.match(/\[\[TOOL_CALL:([^\]]*)\]\]/);
|
|
634
|
-
if (e)
|
|
635
|
-
return `🔧 调用 ${e[1].split("|")[0].trim() || "工具"}`;
|
|
636
|
-
const r = t.match(/\[\[TOOL_RESULT:([^\]]*)\]\]/);
|
|
637
|
-
if (r)
|
|
638
|
-
return `✅ ${r[1].split("|")[0].trim() || "工具"} 完成`;
|
|
639
|
-
const s = t.replace(/\[\[([A-Z_]+)(?::[^\]]*)?\]\][\s\S]*?\[\/\1\]\]/g, " ").replace(/\[\[[A-Z_]+(?::[^\]]*)?\]\]/g, " ").replace(/\[\/[A-Z_]+\]\]/g, " ").replace(/\s+/g, " ").trim();
|
|
640
|
-
if (!s) return "💭 思考中…";
|
|
641
|
-
const a = s.split(/[。;;!?\n]/)[0].trim();
|
|
642
|
-
return a.length > 48 ? a.slice(0, 48) + "…" : a;
|
|
643
|
-
}
|
|
644
|
-
function Qt(n) {
|
|
645
|
-
let t = (n || "").trim();
|
|
646
|
-
if (!t) return "";
|
|
647
|
-
t.length > 200 && (t = t.slice(0, 200));
|
|
648
|
-
const e = t.split(/[\n。;;]/).map((s) => s.trim()).filter(Boolean), r = e[e.length - 1] || t;
|
|
649
|
-
return r.length > 60 ? r.slice(0, 60) + "…" : r;
|
|
650
|
-
}
|
|
651
|
-
function $() {
|
|
652
|
-
const n = /* @__PURE__ */ new Date(), t = (e) => String(e).padStart(2, "0");
|
|
653
|
-
return `${t(n.getHours())}:${t(n.getMinutes())}:${t(n.getSeconds())}`;
|
|
654
|
-
}
|
|
655
|
-
const Xt = 3, en = 4, tn = 5, nn = Ce((n, t) => ({
|
|
656
|
-
currentUser: null,
|
|
657
|
-
permissionState: "unknown",
|
|
658
|
-
// FEATURE-ZTEAM-MERGE: 优先 z-opc 的 token, 其次 z-team 原生的 z_team_token
|
|
659
|
-
token: localStorage.getItem("token") || localStorage.getItem("z_team_token") || "",
|
|
660
|
-
projects: [],
|
|
661
|
-
currentProject: null,
|
|
662
|
-
members: [],
|
|
663
|
-
availableAgents: [],
|
|
664
|
-
availableHumans: [],
|
|
665
|
-
messages: [],
|
|
666
|
-
pendingTeamChatContent: null,
|
|
667
|
-
skills: [],
|
|
668
|
-
allSkills: [],
|
|
669
|
-
fileTrees: {},
|
|
670
|
-
// 按项目ID存储文件树
|
|
671
|
-
selectedFilePath: null,
|
|
672
|
-
fileClickVersion: 0,
|
|
673
|
-
selectedFileContent: null,
|
|
674
|
-
currentDir: "",
|
|
675
|
-
expandedProjectIds: [],
|
|
676
|
-
lastSelectedProjectId: (
|
|
677
|
-
// 原先是 parseInt(...)。**parseInt 是 Number 的同义词**:对 19 位雪花
|
|
678
|
-
// "2096058642985349121" 会得到 2096058642985349100,末位直接丢掉且不可恢复,
|
|
679
|
-
// 表现为「刷新后自动跳到别的项目 / 提示项目不存在」。
|
|
680
|
-
// 写侧存的就是 String(targetId),读侧原样取回即可,无需任何数值解析。
|
|
681
|
-
localStorage.getItem("ft_last_project_id") || null
|
|
682
|
-
),
|
|
683
|
-
lastSelectedFilePath: localStorage.getItem("ft_last_file_path") || null,
|
|
684
|
-
runningExecutions: {},
|
|
685
|
-
observerStatus: null,
|
|
686
|
-
loading: !1,
|
|
687
|
-
projectSwitchSeq: 0,
|
|
688
|
-
projectCache: {},
|
|
689
|
-
hasMoreMessages: !1,
|
|
690
|
-
fileTreeVersion: 0,
|
|
691
|
-
isLocal: !1,
|
|
692
|
-
syncingProjectIds: /* @__PURE__ */ new Set(),
|
|
693
|
-
editingFileContent: null,
|
|
694
|
-
agentMode: localStorage.getItem("ft_agent_mode") || "build",
|
|
695
|
-
hideToolCalls: localStorage.getItem("ft_hide_tool_calls") === "true",
|
|
696
|
-
wsState: "disconnected",
|
|
697
|
-
activeTaskChat: null,
|
|
698
|
-
activeTaskSession: null,
|
|
699
|
-
taskMessages: [],
|
|
700
|
-
taskHasMoreMessages: !1,
|
|
701
|
-
taskActivity: {},
|
|
702
|
-
navigateToTasksTick: 0,
|
|
703
|
-
chatScrollBottomTick: { team: 0, task: 0 },
|
|
704
|
-
isUserScrolled: { team: !1, task: !1 },
|
|
705
|
-
agentProfileState: { visible: !1, agent: null },
|
|
706
|
-
personalChatNav: { trigger: 0, agent: null },
|
|
707
|
-
/* 0808 增量 */
|
|
708
|
-
humanAssistCards: {},
|
|
709
|
-
humanAssistRevision: {},
|
|
710
|
-
taskActivitySettled: {},
|
|
711
|
-
// 换新对象即触发 zustand 订阅者重渲染(MessageBubble / HumanAssistTaskPanel
|
|
712
|
-
// 都是 useAppStore((s) => s.taskActivitySettled[taskId]) 形式订阅的)。
|
|
713
|
-
// 值没变时原样返回,避免无谓的重渲染。
|
|
714
|
-
applyTaskExecutionSettled: (e, r) => n((s) => s.taskActivitySettled[e] === r ? s : {
|
|
715
|
-
taskActivitySettled: { ...s.taskActivitySettled, [e]: r }
|
|
716
|
-
}),
|
|
717
|
-
setHumanAssistCard: (e, r) => n((s) => ({
|
|
718
|
-
humanAssistCards: { ...s.humanAssistCards, [e]: r },
|
|
719
|
-
humanAssistRevision: {
|
|
720
|
-
...s.humanAssistRevision,
|
|
721
|
-
[e]: (s.humanAssistRevision[e] ?? 0) + 1
|
|
722
|
-
}
|
|
723
|
-
})),
|
|
724
|
-
removeHumanAssistCard: (e) => n((r) => {
|
|
725
|
-
const s = { ...r.humanAssistCards };
|
|
726
|
-
return delete s[e], {
|
|
727
|
-
humanAssistCards: s,
|
|
728
|
-
humanAssistRevision: {
|
|
729
|
-
...r.humanAssistRevision,
|
|
730
|
-
[e]: (r.humanAssistRevision[e] ?? 0) + 1
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
}),
|
|
734
|
-
bumpHumanAssistRevision: (e) => n((r) => ({
|
|
735
|
-
humanAssistRevision: {
|
|
736
|
-
...r.humanAssistRevision,
|
|
737
|
-
[e]: (r.humanAssistRevision[e] ?? 0) + 1
|
|
738
|
-
}
|
|
739
|
-
})),
|
|
740
|
-
requestChatScrollBottom: (e, r) => {
|
|
741
|
-
n((s) => !r && s.isUserScrolled[e] ? {} : {
|
|
742
|
-
chatScrollBottomTick: {
|
|
743
|
-
...s.chatScrollBottomTick,
|
|
744
|
-
[e]: s.chatScrollBottomTick[e] + 1
|
|
745
|
-
},
|
|
746
|
-
...r ? { isUserScrolled: { ...s.isUserScrolled, [e]: !1 } } : {}
|
|
747
|
-
});
|
|
748
|
-
},
|
|
749
|
-
setUserScrolled: (e, r) => {
|
|
750
|
-
n((s) => s.isUserScrolled[e] === r ? {} : {
|
|
751
|
-
isUserScrolled: { ...s.isUserScrolled, [e]: r }
|
|
752
|
-
});
|
|
753
|
-
},
|
|
754
|
-
openAgentProfile: (e) => {
|
|
755
|
-
n({ agentProfileState: { visible: !0, agent: e } });
|
|
756
|
-
},
|
|
757
|
-
closeAgentProfile: () => {
|
|
758
|
-
n((e) => ({
|
|
759
|
-
agentProfileState: { ...e.agentProfileState, visible: !1 }
|
|
760
|
-
}));
|
|
761
|
-
},
|
|
762
|
-
navigateToPersonalChat: (e, r) => {
|
|
763
|
-
n((s) => ({
|
|
764
|
-
personalChatNav: { trigger: s.personalChatNav.trigger + 1, agent: e, tab: r }
|
|
765
|
-
}));
|
|
766
|
-
},
|
|
767
|
-
/* ──── 认证 ──── */
|
|
768
|
-
login: async (e, r) => {
|
|
769
|
-
const { user: s, token: a } = await mt(e, r);
|
|
770
|
-
localStorage.setItem("token", a), localStorage.setItem("z_team_token", a);
|
|
771
|
-
const o = {
|
|
772
|
-
userId: s.id,
|
|
773
|
-
id: s.id,
|
|
774
|
-
userName: s.username,
|
|
775
|
-
username: s.username,
|
|
776
|
-
nickname: s.display_name,
|
|
777
|
-
is_global_admin: s.is_global_admin ?? !1
|
|
778
|
-
};
|
|
779
|
-
localStorage.setItem("userInfo", JSON.stringify(o)), n({ currentUser: s, token: a });
|
|
780
|
-
},
|
|
781
|
-
logout: async () => {
|
|
782
|
-
const { token: e } = t();
|
|
783
|
-
e && await ft().catch(() => {
|
|
784
|
-
}), localStorage.removeItem("token"), localStorage.removeItem("z_team_token"), localStorage.removeItem("userInfo"), n({ currentUser: null, token: "", permissionState: "unknown" });
|
|
785
|
-
},
|
|
786
|
-
updateCurrentUser: (e) => {
|
|
787
|
-
n({ currentUser: e });
|
|
788
|
-
},
|
|
789
|
-
setPermissionState: (e) => {
|
|
790
|
-
n({ permissionState: e });
|
|
791
|
-
},
|
|
792
|
-
/* ──── 项目 ──── */
|
|
793
|
-
loadProjects: async (e) => {
|
|
794
|
-
n({ loading: !0 });
|
|
795
|
-
const { token: r } = t();
|
|
796
|
-
try {
|
|
797
|
-
const s = await ut(r, e), o = (Array.isArray(s) ? s : []).map((i) => dt(i)).sort(
|
|
798
|
-
(i, c) => R(c.created_at) - R(i.created_at)
|
|
799
|
-
);
|
|
800
|
-
n({ projects: o, loading: !1 });
|
|
801
|
-
} catch (s) {
|
|
802
|
-
n({ projects: [], loading: !1 }), B(s) || h(s instanceof Error ? s.message : "获取项目列表失败", "error");
|
|
803
|
-
}
|
|
804
|
-
},
|
|
805
|
-
createScenarioInstance: async (e, r, s, a) => {
|
|
806
|
-
const o = t().token || "", i = { name: e, description: r, workspace_path: e };
|
|
807
|
-
s && s.trim() && (i.scenario_code = s.trim()), a && Object.keys(a).length > 0 && (i.extend_params = a);
|
|
808
|
-
const c = await lt(i, o), l = c.scenario_name && c.scenario_code ? `${c.scenario_name}(${c.scenario_code})` : c.scenario_code || "未知场景";
|
|
809
|
-
return h(`已按场景「${l}」创建项目`, "success"), i.scenario_code === "qa_support" && c.scenario_code === "default" && h(
|
|
810
|
-
"警告:请求答疑场景但实际为默认场景,请检查数据库 ft_scenario",
|
|
811
|
-
"error"
|
|
812
|
-
), n((u) => ({
|
|
813
|
-
projects: u.projects.some((d) => d.id === c.id) ? u.projects : [c, ...u.projects]
|
|
814
|
-
})), await t().expandProject(c), c;
|
|
815
|
-
},
|
|
816
|
-
createProjectAndSendFirstMessage: async (e, r, s, a, o) => {
|
|
817
|
-
const i = await t().createScenarioInstance(
|
|
818
|
-
e,
|
|
819
|
-
r,
|
|
820
|
-
s,
|
|
821
|
-
o
|
|
822
|
-
), c = (a || "").trim();
|
|
823
|
-
if (c)
|
|
824
|
-
try {
|
|
825
|
-
await t().sendTeamMessage({
|
|
826
|
-
content: c,
|
|
827
|
-
message_type: "TEXT"
|
|
828
|
-
});
|
|
829
|
-
} catch (l) {
|
|
830
|
-
console.error("[createProjectAndSendFirstMessage] 首条消息发送失败:", l);
|
|
831
|
-
}
|
|
832
|
-
return i;
|
|
833
|
-
},
|
|
834
|
-
clearCurrentProject: () => {
|
|
835
|
-
t().currentProject && (ie(), n({
|
|
836
|
-
currentProject: null,
|
|
837
|
-
messages: [],
|
|
838
|
-
hasMoreMessages: !1,
|
|
839
|
-
members: [],
|
|
840
|
-
availableAgents: [],
|
|
841
|
-
availableHumans: [],
|
|
842
|
-
skills: [],
|
|
843
|
-
selectedFilePath: null,
|
|
844
|
-
selectedFileContent: null,
|
|
845
|
-
currentDir: "",
|
|
846
|
-
editingFileContent: null,
|
|
847
|
-
activeTaskChat: null,
|
|
848
|
-
activeTaskSession: null,
|
|
849
|
-
taskMessages: [],
|
|
850
|
-
taskHasMoreMessages: !1,
|
|
851
|
-
pendingTeamChatContent: null,
|
|
852
|
-
humanAssistCards: {},
|
|
853
|
-
taskActivitySettled: {},
|
|
854
|
-
runningExecutions: {},
|
|
855
|
-
observerStatus: null,
|
|
856
|
-
projectSwitchSeq: t().projectSwitchSeq + 1
|
|
857
|
-
}), localStorage.removeItem("ft_last_file_path"), n({ lastSelectedFilePath: null }));
|
|
858
|
-
},
|
|
859
|
-
deleteScenarioInstance: async (e) => {
|
|
860
|
-
var r;
|
|
861
|
-
if (await ct(e), n((s) => ({ projects: s.projects.filter((a) => a.id !== e) })), ((r = t().currentProject) == null ? void 0 : r.id) === e) {
|
|
862
|
-
const { [e]: s, ...a } = t().fileTrees, { [e]: o, ...i } = t().projectCache;
|
|
863
|
-
n({
|
|
864
|
-
currentProject: null,
|
|
865
|
-
fileTrees: a,
|
|
866
|
-
projectCache: i,
|
|
867
|
-
selectedFilePath: null,
|
|
868
|
-
selectedFileContent: null,
|
|
869
|
-
currentDir: ""
|
|
870
|
-
}), localStorage.removeItem("ft_last_project_id"), localStorage.removeItem("ft_last_file_path"), n({ lastSelectedProjectId: null, lastSelectedFilePath: null });
|
|
871
|
-
}
|
|
872
|
-
},
|
|
873
|
-
forkScenarioInstance: async (e, r) => {
|
|
874
|
-
const s = await ot(
|
|
875
|
-
e,
|
|
876
|
-
r,
|
|
877
|
-
t().token
|
|
878
|
-
);
|
|
879
|
-
return n((a) => ({
|
|
880
|
-
projects: [s, ...a.projects].sort(
|
|
881
|
-
(o, i) => R(i.created_at) - R(o.created_at)
|
|
882
|
-
)
|
|
883
|
-
})), await t().expandProject(s), s;
|
|
884
|
-
},
|
|
885
|
-
updateScenarioInstance: async (e, r) => {
|
|
886
|
-
const s = await it(e, r);
|
|
887
|
-
n((a) => {
|
|
888
|
-
var o;
|
|
889
|
-
return {
|
|
890
|
-
projects: a.projects.map((i) => i.id === e ? s : i),
|
|
891
|
-
currentProject: ((o = a.currentProject) == null ? void 0 : o.id) === e ? s : a.currentProject
|
|
892
|
-
};
|
|
893
|
-
});
|
|
894
|
-
},
|
|
895
|
-
/* ──── 团队 ──── */
|
|
896
|
-
loadMembers: async () => {
|
|
897
|
-
const e = t().currentProject;
|
|
898
|
-
if (!e) return;
|
|
899
|
-
const r = String(e.id), s = K.get(r);
|
|
900
|
-
if (s)
|
|
901
|
-
return s;
|
|
902
|
-
const a = (async () => {
|
|
903
|
-
try {
|
|
904
|
-
const i = (await at(e.id)).map((c) => ({
|
|
905
|
-
...c,
|
|
906
|
-
ref_id: String(c.ref_id ?? "")
|
|
907
|
-
}));
|
|
908
|
-
n((c) => {
|
|
909
|
-
var f;
|
|
910
|
-
if (((f = c.currentProject) == null ? void 0 : f.id) !== r)
|
|
911
|
-
return {};
|
|
912
|
-
const l = c.projectCache[r] ?? O(), u = { members: i }, d = c.messages.map(
|
|
913
|
-
(y) => G(y, i)
|
|
914
|
-
);
|
|
915
|
-
return {
|
|
916
|
-
members: i,
|
|
917
|
-
messages: d,
|
|
918
|
-
projectCache: {
|
|
919
|
-
...c.projectCache,
|
|
920
|
-
[r]: { ...l, ...u }
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
}), t().enforceTeamModePolicy();
|
|
924
|
-
} catch {
|
|
925
|
-
}
|
|
926
|
-
})().finally(() => {
|
|
927
|
-
K.delete(r);
|
|
928
|
-
});
|
|
929
|
-
return K.set(r, a), a;
|
|
930
|
-
},
|
|
931
|
-
loadTeamPickerOptions: async () => {
|
|
932
|
-
const e = t().currentProject;
|
|
933
|
-
if (!e) return;
|
|
934
|
-
const r = String(e.id), s = W.get(r);
|
|
935
|
-
if (s)
|
|
936
|
-
return s;
|
|
937
|
-
const a = (async () => {
|
|
938
|
-
try {
|
|
939
|
-
const [o, i] = await Promise.all([
|
|
940
|
-
rt(e.id),
|
|
941
|
-
st(e.id)
|
|
942
|
-
]), c = (Array.isArray(o) ? o : []).map(
|
|
943
|
-
(l) => ({
|
|
944
|
-
...l,
|
|
945
|
-
agent_code: String(
|
|
946
|
-
l.agent_code ?? l.agentCode ?? l.id ?? ""
|
|
947
|
-
).trim()
|
|
948
|
-
})
|
|
949
|
-
);
|
|
950
|
-
n((l) => {
|
|
951
|
-
var f;
|
|
952
|
-
if (((f = l.currentProject) == null ? void 0 : f.id) !== r)
|
|
953
|
-
return {};
|
|
954
|
-
const u = l.projectCache[r] ?? O(), d = {
|
|
955
|
-
availableAgents: c,
|
|
956
|
-
availableHumans: i
|
|
957
|
-
};
|
|
958
|
-
return {
|
|
959
|
-
...d,
|
|
960
|
-
projectCache: {
|
|
961
|
-
...l.projectCache,
|
|
962
|
-
[r]: { ...u, ...d }
|
|
963
|
-
}
|
|
964
|
-
};
|
|
965
|
-
});
|
|
966
|
-
} catch {
|
|
967
|
-
}
|
|
968
|
-
})().finally(() => {
|
|
969
|
-
W.delete(r);
|
|
970
|
-
});
|
|
971
|
-
return W.set(r, a), a;
|
|
972
|
-
},
|
|
973
|
-
addMember: async (e, r, s, a) => {
|
|
974
|
-
const o = t().currentProject;
|
|
975
|
-
o && (await nt(o.id, {
|
|
976
|
-
member_type: e,
|
|
977
|
-
ref_id: r,
|
|
978
|
-
display_name: s,
|
|
979
|
-
role: a
|
|
980
|
-
}), await Promise.all([t().loadMembers(), t().loadTeamPickerOptions()]));
|
|
981
|
-
},
|
|
982
|
-
removeMember: async (e) => {
|
|
983
|
-
const r = t().currentProject;
|
|
984
|
-
r && (await tt(r.id, e), await Promise.all([t().loadMembers(), t().loadTeamPickerOptions()]));
|
|
985
|
-
},
|
|
986
|
-
/* ──── 聊天 ──── */
|
|
987
|
-
loadMessages: async () => {
|
|
988
|
-
const e = t().currentProject;
|
|
989
|
-
if (!e) return;
|
|
990
|
-
const r = String(e.id);
|
|
991
|
-
try {
|
|
992
|
-
const s = await oe(e.id, de), a = s.messages || [], o = t().members, i = U(
|
|
993
|
-
pe(
|
|
994
|
-
te(a, o).filter(Z)
|
|
995
|
-
)
|
|
996
|
-
), c = !!s.has_more;
|
|
997
|
-
n((l) => {
|
|
998
|
-
var d;
|
|
999
|
-
if (((d = l.currentProject) == null ? void 0 : d.id) !== r)
|
|
1000
|
-
return {};
|
|
1001
|
-
const u = l.projectCache[r] ?? O();
|
|
1002
|
-
return {
|
|
1003
|
-
messages: i,
|
|
1004
|
-
hasMoreMessages: c,
|
|
1005
|
-
projectCache: {
|
|
1006
|
-
...l.projectCache,
|
|
1007
|
-
[r]: { ...u, messages: i, hasMoreMessages: c }
|
|
1008
|
-
}
|
|
1009
|
-
};
|
|
1010
|
-
}), t().requestChatScrollBottom("team", !1), t().markUnreadMentionsAsRead();
|
|
1011
|
-
} catch {
|
|
1012
|
-
}
|
|
1013
|
-
},
|
|
1014
|
-
loadMoreMessages: async () => {
|
|
1015
|
-
const e = t().currentProject, { messages: r, hasMoreMessages: s } = t();
|
|
1016
|
-
if (!e || !s || r.length === 0) return;
|
|
1017
|
-
const a = r[0].id;
|
|
1018
|
-
try {
|
|
1019
|
-
const o = await oe(
|
|
1020
|
-
e.id,
|
|
1021
|
-
de,
|
|
1022
|
-
a
|
|
1023
|
-
), i = o.messages || [];
|
|
1024
|
-
if (i.length > 0) {
|
|
1025
|
-
const c = pe(
|
|
1026
|
-
te(
|
|
1027
|
-
i,
|
|
1028
|
-
t().members
|
|
1029
|
-
).filter(Z)
|
|
1030
|
-
);
|
|
1031
|
-
n({
|
|
1032
|
-
messages: U([...c, ...r]),
|
|
1033
|
-
hasMoreMessages: !!o.has_more
|
|
1034
|
-
});
|
|
1035
|
-
} else
|
|
1036
|
-
n({ hasMoreMessages: !1 });
|
|
1037
|
-
} catch {
|
|
1038
|
-
n({ hasMoreMessages: !1 });
|
|
1039
|
-
}
|
|
1040
|
-
},
|
|
1041
|
-
markPendingTeamChatContent: (e) => {
|
|
1042
|
-
n({ pendingTeamChatContent: e }), t().requestChatScrollBottom("team", !0);
|
|
1043
|
-
},
|
|
1044
|
-
addMessage: (e) => {
|
|
1045
|
-
var P, v;
|
|
1046
|
-
const r = ee(
|
|
1047
|
-
e
|
|
1048
|
-
);
|
|
1049
|
-
if (!Z(r))
|
|
1050
|
-
return;
|
|
1051
|
-
const s = r.id;
|
|
1052
|
-
if (!C(s))
|
|
1053
|
-
return;
|
|
1054
|
-
const a = t();
|
|
1055
|
-
let o = G(r, a.members);
|
|
1056
|
-
const i = String(r.sender_type || "HUMAN").toUpperCase() === "HUMAN", c = q(a.members, a.currentUser) ?? null, l = String(r.scenario_instance_id ?? ""), u = (P = a.currentProject) != null && P.id ? String(a.currentProject.id) : "";
|
|
1057
|
-
if (l && l !== "0" && u && l !== u)
|
|
1058
|
-
return;
|
|
1059
|
-
const d = !!a.pendingTeamChatContent && a.pendingTeamChatContent === r.content && i, f = _t(
|
|
1060
|
-
r,
|
|
1061
|
-
c,
|
|
1062
|
-
a.currentUser,
|
|
1063
|
-
a.members
|
|
1064
|
-
), y = Te(
|
|
1065
|
-
r,
|
|
1066
|
-
c,
|
|
1067
|
-
a.currentUser,
|
|
1068
|
-
a.members
|
|
1069
|
-
);
|
|
1070
|
-
d && !f && (y || r.sender_id == null) && (o = {
|
|
1071
|
-
...o,
|
|
1072
|
-
is_own: !0,
|
|
1073
|
-
sender_id: o.sender_id ?? (c == null ? void 0 : c.id) ?? null,
|
|
1074
|
-
sender_name: o.sender_name || ((v = a.currentUser) == null ? void 0 : v.display_name) || ""
|
|
1075
|
-
});
|
|
1076
|
-
const I = d && !f && o.is_own === !0;
|
|
1077
|
-
let g = null;
|
|
1078
|
-
if (o.message_type === "AGENT_RESULT" && o.ext)
|
|
1079
|
-
try {
|
|
1080
|
-
const p = typeof o.ext == "string" ? JSON.parse(o.ext) : o.ext;
|
|
1081
|
-
(p == null ? void 0 : p.taskId) != null && (g = _(p.taskId));
|
|
1082
|
-
} catch {
|
|
1083
|
-
}
|
|
1084
|
-
n((p) => {
|
|
1085
|
-
const k = I ? null : p.pendingTeamChatContent, V = p.messages.findIndex((T) => T.id === s);
|
|
1086
|
-
let m = p.messages;
|
|
1087
|
-
g != null && (m = m.filter((T) => {
|
|
1088
|
-
if (T.message_type !== "TASK_PROGRESS") return !0;
|
|
1089
|
-
try {
|
|
1090
|
-
return JSON.parse(T.content).taskId != g;
|
|
1091
|
-
} catch {
|
|
1092
|
-
return !0;
|
|
1093
|
-
}
|
|
1094
|
-
}));
|
|
1095
|
-
const S = Y(m, o), b = H(S);
|
|
1096
|
-
return V !== -1 ? {
|
|
1097
|
-
messages: b,
|
|
1098
|
-
pendingTeamChatContent: k
|
|
1099
|
-
} : {
|
|
1100
|
-
messages: b,
|
|
1101
|
-
pendingTeamChatContent: k
|
|
1102
|
-
};
|
|
1103
|
-
}), t().markUnreadMentionsAsRead();
|
|
1104
|
-
},
|
|
1105
|
-
deleteMessage: (e) => {
|
|
1106
|
-
n((r) => ({
|
|
1107
|
-
messages: r.messages.filter((s) => s.id !== e),
|
|
1108
|
-
taskMessages: r.taskMessages.filter((s) => s.id !== e)
|
|
1109
|
-
}));
|
|
1110
|
-
},
|
|
1111
|
-
clearTeamMessages: () => {
|
|
1112
|
-
n({ messages: [] });
|
|
1113
|
-
},
|
|
1114
|
-
updateMessageReadStatus: (e, r) => {
|
|
1115
|
-
n((s) => {
|
|
1116
|
-
const a = s.messages.findIndex((u) => u.id === e);
|
|
1117
|
-
if (a === -1) return {};
|
|
1118
|
-
const o = s.messages[a], i = r, c = {
|
|
1119
|
-
read_count: Number(i.read_count ?? 0),
|
|
1120
|
-
unread_count: Number(i.unread_count ?? 0),
|
|
1121
|
-
read_members: Array.isArray(i.read_members) ? i.read_members : [],
|
|
1122
|
-
unread_members: Array.isArray(i.unread_members) ? i.unread_members : []
|
|
1123
|
-
}, l = [...s.messages];
|
|
1124
|
-
return l[a] = { ...o, read_status: c }, { messages: l };
|
|
1125
|
-
});
|
|
1126
|
-
},
|
|
1127
|
-
markUnreadMentionsAsRead: () => {
|
|
1128
|
-
const e = t(), r = e.currentProject, s = e.token;
|
|
1129
|
-
if (!r || !s) return;
|
|
1130
|
-
const a = q(e.members, e.currentUser);
|
|
1131
|
-
if (!a) return;
|
|
1132
|
-
const o = a.id, i = a.display_name, c = e.messages.filter((l) => l.read_status ? l.read_status.unread_members.some(
|
|
1133
|
-
(u) => u.member_id === o || u.display_name === i
|
|
1134
|
-
) : !1);
|
|
1135
|
-
if (c.length !== 0)
|
|
1136
|
-
for (const l of c)
|
|
1137
|
-
et(r.id, l.id, s).catch(() => {
|
|
1138
|
-
});
|
|
1139
|
-
},
|
|
1140
|
-
sendChatMessage: async (e) => {
|
|
1141
|
-
const r = t().currentProject, s = t().token;
|
|
1142
|
-
r && await x(r.id, { content: e, message_type: "TEXT" }, s);
|
|
1143
|
-
},
|
|
1144
|
-
sendAtAgentMessage: async (e, r) => {
|
|
1145
|
-
const s = t().currentProject, a = t().token;
|
|
1146
|
-
s && await x(
|
|
1147
|
-
s.id,
|
|
1148
|
-
{
|
|
1149
|
-
content: e,
|
|
1150
|
-
message_type: "AT_AGENT",
|
|
1151
|
-
ref_id: r,
|
|
1152
|
-
ref_type: "agent"
|
|
1153
|
-
},
|
|
1154
|
-
a
|
|
1155
|
-
);
|
|
1156
|
-
},
|
|
1157
|
-
sendAtSkillMessage: async (e, r) => {
|
|
1158
|
-
const s = t().currentProject, a = t().token;
|
|
1159
|
-
s && await x(
|
|
1160
|
-
s.id,
|
|
1161
|
-
{
|
|
1162
|
-
content: e,
|
|
1163
|
-
message_type: "AT_SKILL",
|
|
1164
|
-
ref_id: r,
|
|
1165
|
-
ref_type: "skill"
|
|
1166
|
-
},
|
|
1167
|
-
a
|
|
1168
|
-
);
|
|
1169
|
-
},
|
|
1170
|
-
sendTeamMessage: async (e) => {
|
|
1171
|
-
var i, c, l;
|
|
1172
|
-
const r = t().currentProject, s = t().token;
|
|
1173
|
-
if (!r) return;
|
|
1174
|
-
const a = String(r.id), o = q(t().members, t().currentUser);
|
|
1175
|
-
try {
|
|
1176
|
-
const u = await x(r.id, e, s);
|
|
1177
|
-
if (u && A((i = t().currentProject) == null ? void 0 : i.id, a) && t().addMessage({
|
|
1178
|
-
...u,
|
|
1179
|
-
is_own: !0,
|
|
1180
|
-
sender_id: u.sender_id ?? (o == null ? void 0 : o.id) ?? null,
|
|
1181
|
-
sender_name: u.sender_name || ((c = t().currentUser) == null ? void 0 : c.display_name) || ""
|
|
1182
|
-
}), !A((l = t().currentProject) == null ? void 0 : l.id, a))
|
|
1183
|
-
return;
|
|
1184
|
-
await t().loadRunningExecutions(), window.setTimeout(() => {
|
|
1185
|
-
var d;
|
|
1186
|
-
A((d = t().currentProject) == null ? void 0 : d.id, a) && t().loadRunningExecutions();
|
|
1187
|
-
}, 400);
|
|
1188
|
-
} catch (u) {
|
|
1189
|
-
throw n({ pendingTeamChatContent: null }), u;
|
|
1190
|
-
}
|
|
1191
|
-
},
|
|
1192
|
-
/* ──── 技能 ──── */
|
|
1193
|
-
loadSkills: async () => {
|
|
1194
|
-
const e = t().currentProject;
|
|
1195
|
-
if (!e) return;
|
|
1196
|
-
const r = String(e.id);
|
|
1197
|
-
try {
|
|
1198
|
-
const s = await Xe(e.id);
|
|
1199
|
-
n((a) => {
|
|
1200
|
-
var i;
|
|
1201
|
-
if (((i = a.currentProject) == null ? void 0 : i.id) !== r)
|
|
1202
|
-
return {};
|
|
1203
|
-
const o = a.projectCache[r] ?? O();
|
|
1204
|
-
return {
|
|
1205
|
-
skills: s,
|
|
1206
|
-
projectCache: {
|
|
1207
|
-
...a.projectCache,
|
|
1208
|
-
[r]: { ...o, skills: s }
|
|
1209
|
-
}
|
|
1210
|
-
};
|
|
1211
|
-
});
|
|
1212
|
-
} catch {
|
|
1213
|
-
}
|
|
1214
|
-
},
|
|
1215
|
-
loadAllSkills: async () => {
|
|
1216
|
-
const e = t().currentProject;
|
|
1217
|
-
if (e)
|
|
1218
|
-
try {
|
|
1219
|
-
const r = await Qe(e.id);
|
|
1220
|
-
n({ allSkills: r });
|
|
1221
|
-
} catch {
|
|
1222
|
-
}
|
|
1223
|
-
},
|
|
1224
|
-
addProjectSkill: async (e) => {
|
|
1225
|
-
const r = t().currentProject;
|
|
1226
|
-
r && (await Ze(r.id, e), await t().loadSkills(), await t().loadFileTree(t().currentDir, !0));
|
|
1227
|
-
},
|
|
1228
|
-
removeProjectSkill: async (e) => {
|
|
1229
|
-
const r = t().currentProject;
|
|
1230
|
-
r && (await Ye(r.id, e), await t().loadSkills(), await t().loadFileTree(t().currentDir, !0));
|
|
1231
|
-
},
|
|
1232
|
-
refreshAgentSkills: async (e) => {
|
|
1233
|
-
const r = t().currentProject;
|
|
1234
|
-
if (r)
|
|
1235
|
-
try {
|
|
1236
|
-
const s = await Je(r.id, e), a = s && typeof s.message == "string" ? s.message : "技能已刷新";
|
|
1237
|
-
h(a, (s == null ? void 0 : s.ok) === !1 ? "warning" : "success"), await t().loadFileTree(t().currentDir, !0);
|
|
1238
|
-
} catch {
|
|
1239
|
-
}
|
|
1240
|
-
},
|
|
1241
|
-
refreshAllAgentSkills: async (e) => {
|
|
1242
|
-
if (e)
|
|
1243
|
-
try {
|
|
1244
|
-
const r = await We(e), s = r && typeof r.message == "string" ? r.message : "所有技能已刷新";
|
|
1245
|
-
h(s, (r == null ? void 0 : r.ok) === !1 ? "warning" : "success");
|
|
1246
|
-
const a = t().currentProject;
|
|
1247
|
-
a && String(a.id) === String(e) && await t().loadFileTree(t().currentDir, !0);
|
|
1248
|
-
} catch {
|
|
1249
|
-
}
|
|
1250
|
-
},
|
|
1251
|
-
/* ──── 文件 ──── */
|
|
1252
|
-
loadFileTree: async (e, r = !1) => {
|
|
1253
|
-
const s = t().currentProject;
|
|
1254
|
-
if (!s)
|
|
1255
|
-
return;
|
|
1256
|
-
const a = String(s.id);
|
|
1257
|
-
try {
|
|
1258
|
-
const o = await ae(s.id, e);
|
|
1259
|
-
n((i) => {
|
|
1260
|
-
var c;
|
|
1261
|
-
return ((c = i.currentProject) == null ? void 0 : c.id) !== a ? {} : r ? {
|
|
1262
|
-
fileTrees: { ...i.fileTrees, [a]: o },
|
|
1263
|
-
currentDir: e ?? "",
|
|
1264
|
-
fileTreeVersion: i.fileTreeVersion + 1
|
|
1265
|
-
} : {
|
|
1266
|
-
fileTrees: { ...i.fileTrees, [a]: o },
|
|
1267
|
-
currentDir: e ?? ""
|
|
1268
|
-
};
|
|
1269
|
-
});
|
|
1270
|
-
} catch {
|
|
1271
|
-
}
|
|
1272
|
-
},
|
|
1273
|
-
selectFile: async (e) => {
|
|
1274
|
-
const r = t().currentProject;
|
|
1275
|
-
if (!r) return;
|
|
1276
|
-
n({
|
|
1277
|
-
selectedFilePath: e,
|
|
1278
|
-
fileClickVersion: t().fileClickVersion + 1,
|
|
1279
|
-
selectedFileContent: null,
|
|
1280
|
-
lastSelectedFilePath: e
|
|
1281
|
-
}), localStorage.setItem("ft_last_file_path", e);
|
|
1282
|
-
const { content: s } = await Ke(r.id, e);
|
|
1283
|
-
n({ selectedFileContent: s, editingFileContent: s ?? "" });
|
|
1284
|
-
},
|
|
1285
|
-
saveFileContent: async (e) => {
|
|
1286
|
-
const r = t().currentProject, s = t().selectedFilePath;
|
|
1287
|
-
if (!(!r || !s))
|
|
1288
|
-
try {
|
|
1289
|
-
await ze(r.id, s, e), n({ selectedFileContent: e, editingFileContent: e }), console.log("文件保存成功:", s);
|
|
1290
|
-
} catch (a) {
|
|
1291
|
-
throw console.error("保存文件失败:", a), console.log("保存失败的文件路径:", s), a;
|
|
1292
|
-
}
|
|
1293
|
-
},
|
|
1294
|
-
/* ──── 文件操作 ──── */
|
|
1295
|
-
_bumpVersion: () => {
|
|
1296
|
-
n((e) => ({ fileTreeVersion: e.fileTreeVersion + 1 }));
|
|
1297
|
-
},
|
|
1298
|
-
renameFile: async (e, r) => {
|
|
1299
|
-
const s = t().currentProject;
|
|
1300
|
-
s && (await qe(s.id, e, r), await t().loadFileTree(t().currentDir), t()._bumpVersion());
|
|
1301
|
-
},
|
|
1302
|
-
createFile: async (e, r) => {
|
|
1303
|
-
const s = t().currentProject;
|
|
1304
|
-
s && (await Be(s.id, e, r), await t().loadFileTree(t().currentDir), t()._bumpVersion());
|
|
1305
|
-
},
|
|
1306
|
-
createFolder: async (e, r) => {
|
|
1307
|
-
const s = t().currentProject;
|
|
1308
|
-
s && (await Ve(s.id, e, r), await t().loadFileTree(t().currentDir), t()._bumpVersion());
|
|
1309
|
-
},
|
|
1310
|
-
deleteFile: async (e) => {
|
|
1311
|
-
const r = t().currentProject;
|
|
1312
|
-
r && (await De(r.id, e), t().selectedFilePath === e && (n({
|
|
1313
|
-
selectedFilePath: null,
|
|
1314
|
-
selectedFileContent: null,
|
|
1315
|
-
editingFileContent: null
|
|
1316
|
-
}), localStorage.removeItem("ft_last_file_path"), n({ lastSelectedFilePath: null })), await t().loadFileTree(t().currentDir), t()._bumpVersion());
|
|
1317
|
-
},
|
|
1318
|
-
uploadFile: async (e, r) => {
|
|
1319
|
-
const s = t().currentProject;
|
|
1320
|
-
s && (await Ge(s.id, e, r), await t().loadFileTree(t().currentDir), t()._bumpVersion());
|
|
1321
|
-
},
|
|
1322
|
-
uploadFolder: async (e, r) => {
|
|
1323
|
-
const s = t().currentProject;
|
|
1324
|
-
s && (await $e(s.id, e, r), await t().loadFileTree(t().currentDir), t()._bumpVersion());
|
|
1325
|
-
},
|
|
1326
|
-
downloadFile: async (e) => {
|
|
1327
|
-
const r = t().currentProject;
|
|
1328
|
-
if (!r) return;
|
|
1329
|
-
const s = await Le(r.id, e), a = window.URL.createObjectURL(s), o = document.createElement("a");
|
|
1330
|
-
o.href = a, o.download = e.split("/").pop() || "download", document.body.appendChild(o), o.click(), window.URL.revokeObjectURL(a), document.body.removeChild(o);
|
|
1331
|
-
},
|
|
1332
|
-
toggleProjectExpand: async (e) => {
|
|
1333
|
-
var a;
|
|
1334
|
-
const r = t();
|
|
1335
|
-
if (r.expandedProjectIds.includes(e))
|
|
1336
|
-
n({
|
|
1337
|
-
expandedProjectIds: r.expandedProjectIds.filter(
|
|
1338
|
-
(o) => o !== e
|
|
1339
|
-
)
|
|
1340
|
-
}), ((a = r.currentProject) == null ? void 0 : a.id) === e && (localStorage.removeItem("ft_last_file_path"), n({ lastSelectedFilePath: null }));
|
|
1341
|
-
else {
|
|
1342
|
-
const o = r.projects.find((i) => i.id === e);
|
|
1343
|
-
if (!o) return;
|
|
1344
|
-
await t().expandProject(o, { expandTree: !0 });
|
|
1345
|
-
}
|
|
1346
|
-
},
|
|
1347
|
-
refreshProjectPanels: async (e, r, s = !1) => {
|
|
1348
|
-
const a = () => {
|
|
1349
|
-
var l;
|
|
1350
|
-
const c = t();
|
|
1351
|
-
return c.projectSwitchSeq !== r || String(((l = c.currentProject) == null ? void 0 : l.id) ?? "") !== String(e);
|
|
1352
|
-
};
|
|
1353
|
-
if (a()) return;
|
|
1354
|
-
const o = J.get(e);
|
|
1355
|
-
if (o) {
|
|
1356
|
-
await o;
|
|
1357
|
-
return;
|
|
1358
|
-
}
|
|
1359
|
-
const i = (async () => {
|
|
1360
|
-
const c = [
|
|
1361
|
-
t().loadMembers(),
|
|
1362
|
-
t().loadMessages(),
|
|
1363
|
-
t().loadSkills()
|
|
1364
|
-
];
|
|
1365
|
-
s && c.push(t().loadFileTree()), await Promise.allSettled(c);
|
|
1366
|
-
})().finally(() => {
|
|
1367
|
-
J.delete(e);
|
|
1368
|
-
});
|
|
1369
|
-
J.set(e, i), await i, a();
|
|
1370
|
-
},
|
|
1371
|
-
expandProject: async (e, r) => {
|
|
1372
|
-
var g, P;
|
|
1373
|
-
const s = String(e.id), a = (r == null ? void 0 : r.expandTree) === !0, o = t(), i = Ct(o), c = le(e, o.currentUser, e.mode), l = o.expandedProjectIds.includes(s), u = i[s], d = !o.fileTrees[s] || o.fileTrees[s].length === 0;
|
|
1374
|
-
if (((g = o.currentProject) == null ? void 0 : g.id) === s && o.projectSwitchSeq > 0) {
|
|
1375
|
-
a && !l && (n({
|
|
1376
|
-
expandedProjectIds: [
|
|
1377
|
-
.../* @__PURE__ */ new Set([...o.expandedProjectIds, s])
|
|
1378
|
-
]
|
|
1379
|
-
}), d && t().loadFileTree()), n((v) => {
|
|
1380
|
-
const p = v.projects.filter(
|
|
1381
|
-
(m, S, b) => b.findIndex((T) => T.id === m.id) === S
|
|
1382
|
-
), k = p.findIndex((m) => m.id === s);
|
|
1383
|
-
return {
|
|
1384
|
-
projects: k >= 0 ? p.map(
|
|
1385
|
-
(m, S) => S === k ? { ...m, ...e, id: s } : m
|
|
1386
|
-
) : p,
|
|
1387
|
-
currentProject: { ...e, id: s }
|
|
1388
|
-
};
|
|
1389
|
-
});
|
|
1390
|
-
return;
|
|
1391
|
-
}
|
|
1392
|
-
const y = o.projectSwitchSeq + 1, I = a && !l ? [.../* @__PURE__ */ new Set([...o.expandedProjectIds, s])] : o.expandedProjectIds;
|
|
1393
|
-
((P = o.currentProject) == null ? void 0 : P.id) !== s && ie(), n((v) => {
|
|
1394
|
-
const p = v.projects.filter(
|
|
1395
|
-
(m, S, b) => b.findIndex((T) => T.id === m.id) === S
|
|
1396
|
-
), k = p.findIndex((m) => m.id === s);
|
|
1397
|
-
return {
|
|
1398
|
-
projects: k >= 0 ? p.map(
|
|
1399
|
-
(m, S) => S === k ? { ...m, ...e, id: s } : m
|
|
1400
|
-
) : [...p, { ...e, id: s }],
|
|
1401
|
-
projectCache: i,
|
|
1402
|
-
projectSwitchSeq: y,
|
|
1403
|
-
currentProject: { ...e, id: s },
|
|
1404
|
-
lastSelectedProjectId: s,
|
|
1405
|
-
agentMode: c,
|
|
1406
|
-
expandedProjectIds: I,
|
|
1407
|
-
selectedFilePath: null,
|
|
1408
|
-
selectedFileContent: null,
|
|
1409
|
-
editingFileContent: null,
|
|
1410
|
-
activeTaskChat: null,
|
|
1411
|
-
activeTaskSession: null,
|
|
1412
|
-
taskMessages: [],
|
|
1413
|
-
taskHasMoreMessages: !1,
|
|
1414
|
-
members: (u == null ? void 0 : u.members) ?? [],
|
|
1415
|
-
availableAgents: (u == null ? void 0 : u.availableAgents) ?? [],
|
|
1416
|
-
availableHumans: (u == null ? void 0 : u.availableHumans) ?? [],
|
|
1417
|
-
messages: (u == null ? void 0 : u.messages) ?? [],
|
|
1418
|
-
hasMoreMessages: (u == null ? void 0 : u.hasMoreMessages) ?? !1,
|
|
1419
|
-
skills: (u == null ? void 0 : u.skills) ?? [],
|
|
1420
|
-
observerStatus: null
|
|
1421
|
-
};
|
|
1422
|
-
}), localStorage.setItem("ft_last_project_id", String(s)), localStorage.setItem("ft_agent_mode", c), t().refreshProjectPanels(s, y, a && d);
|
|
1423
|
-
},
|
|
1424
|
-
selectProject: async (e, r) => {
|
|
1425
|
-
await t().expandProject(e, r);
|
|
1426
|
-
},
|
|
1427
|
-
/* 模式切换 */
|
|
1428
|
-
switchMode: (e) => {
|
|
1429
|
-
const { agentMode: r, currentProject: s, currentUser: a } = t();
|
|
1430
|
-
if (he(s, a)) {
|
|
1431
|
-
r !== "plan" && (n({ agentMode: "plan" }), localStorage.setItem("ft_agent_mode", "plan"));
|
|
1432
|
-
return;
|
|
1433
|
-
}
|
|
1434
|
-
r !== e && (n({ agentMode: e }), localStorage.setItem("ft_agent_mode", e), He({ type: "mode", mode: e }));
|
|
1435
|
-
},
|
|
1436
|
-
enforceTeamModePolicy: () => {
|
|
1437
|
-
const { currentProject: e, currentUser: r, agentMode: s } = t(), a = le(
|
|
1438
|
-
e,
|
|
1439
|
-
r,
|
|
1440
|
-
e == null ? void 0 : e.mode
|
|
1441
|
-
);
|
|
1442
|
-
s !== a && (n({ agentMode: a }), localStorage.setItem("ft_agent_mode", a));
|
|
1443
|
-
},
|
|
1444
|
-
/* 工具调用显隐 */
|
|
1445
|
-
toggleHideToolCalls: () => {
|
|
1446
|
-
const e = !t().hideToolCalls;
|
|
1447
|
-
n({ hideToolCalls: e }), localStorage.setItem("ft_hide_tool_calls", String(e));
|
|
1448
|
-
},
|
|
1449
|
-
/* WS 连接状态 */
|
|
1450
|
-
setWsState: (e) => {
|
|
1451
|
-
n({ wsState: e });
|
|
1452
|
-
},
|
|
1453
|
-
setObserverStatus: (e) => {
|
|
1454
|
-
n({ observerStatus: e });
|
|
1455
|
-
},
|
|
1456
|
-
/* ──── Agent 执行 ──── */
|
|
1457
|
-
cancelExecution: async (e) => {
|
|
1458
|
-
var o;
|
|
1459
|
-
const r = t().currentProject;
|
|
1460
|
-
if (!r) return;
|
|
1461
|
-
let s = e;
|
|
1462
|
-
if (M(s)) {
|
|
1463
|
-
await t().loadRunningExecutions();
|
|
1464
|
-
const i = (o = t().activeTaskChat) == null ? void 0 : o.taskId, c = i ? Object.values(t().runningExecutions).find(
|
|
1465
|
-
(l) => A(l.task_id, i) && !M(l.executionId) && l.executionId !== "" && l.stepName !== "排队中"
|
|
1466
|
-
) : Object.values(t().runningExecutions).find(
|
|
1467
|
-
(l) => !M(l.executionId) && l.executionId !== "" && !l.task_id && l.stepName !== "排队中"
|
|
1468
|
-
);
|
|
1469
|
-
if (!c) {
|
|
1470
|
-
t().clearExecution(s);
|
|
1471
|
-
return;
|
|
1472
|
-
}
|
|
1473
|
-
s = c.executionId;
|
|
1474
|
-
}
|
|
1475
|
-
const a = s;
|
|
1476
|
-
t().applyExecutionCancelled(a);
|
|
1477
|
-
try {
|
|
1478
|
-
await Ue(r.id, a);
|
|
1479
|
-
} catch (i) {
|
|
1480
|
-
console.error("[ChatPanel] 停止失败:", i), B(i) || h(
|
|
1481
|
-
"停止失败:" + (i instanceof Error ? i.message : "未知错误"),
|
|
1482
|
-
"error"
|
|
1483
|
-
);
|
|
1484
|
-
}
|
|
1485
|
-
},
|
|
1486
|
-
cancelExecutionQueue: async (e) => {
|
|
1487
|
-
const r = t().currentProject;
|
|
1488
|
-
if (!r) return;
|
|
1489
|
-
const s = t().runningExecutions, a = s[e] ? e : me(s, e)[0] ?? e, o = me(s, a);
|
|
1490
|
-
for (const i of o)
|
|
1491
|
-
t().applyExecutionCancelled(i);
|
|
1492
|
-
try {
|
|
1493
|
-
await Oe(r.id, a);
|
|
1494
|
-
} catch (i) {
|
|
1495
|
-
console.error("[ChatPanel] 停止队列失败:", i), B(i) || h(
|
|
1496
|
-
"停止队列失败:" + (i instanceof Error ? i.message : "未知错误"),
|
|
1497
|
-
"error"
|
|
1498
|
-
);
|
|
1499
|
-
}
|
|
1500
|
-
},
|
|
1501
|
-
registerExecutionStart: (e) => {
|
|
1502
|
-
const r = _(e.executionId);
|
|
1503
|
-
n((s) => {
|
|
1504
|
-
var i;
|
|
1505
|
-
const a = { ...s.runningExecutions };
|
|
1506
|
-
if (e.taskId)
|
|
1507
|
-
for (const c of Object.keys(a))
|
|
1508
|
-
M(c) && A((i = a[c]) == null ? void 0 : i.task_id, e.taskId) && delete a[c];
|
|
1509
|
-
const o = z(
|
|
1510
|
-
e.agentName,
|
|
1511
|
-
e.taskId,
|
|
1512
|
-
a,
|
|
1513
|
-
s.messages,
|
|
1514
|
-
s.taskMessages,
|
|
1515
|
-
e.loadingMessageId
|
|
1516
|
-
);
|
|
1517
|
-
return a[r] = {
|
|
1518
|
-
step: 0,
|
|
1519
|
-
stepName: "已启动",
|
|
1520
|
-
output: "",
|
|
1521
|
-
agentName: e.agentName || "",
|
|
1522
|
-
agentAvatar: e.agentAvatar || "",
|
|
1523
|
-
executionId: r,
|
|
1524
|
-
previousSteps: [],
|
|
1525
|
-
task_id: e.taskId,
|
|
1526
|
-
pendingCount: e.pendingCount ?? 0,
|
|
1527
|
-
queuedExecutionIds: [],
|
|
1528
|
-
loadingMessageId: o
|
|
1529
|
-
}, { runningExecutions: a };
|
|
1530
|
-
});
|
|
1531
|
-
},
|
|
1532
|
-
updateExecution: (e) => {
|
|
1533
|
-
const r = _(e.executionId);
|
|
1534
|
-
n((s) => {
|
|
1535
|
-
let a = s.runningExecutions[r];
|
|
1536
|
-
if (!a) {
|
|
1537
|
-
const u = z(
|
|
1538
|
-
e.agentName,
|
|
1539
|
-
e.taskId,
|
|
1540
|
-
s.runningExecutions,
|
|
1541
|
-
s.messages,
|
|
1542
|
-
s.taskMessages
|
|
1543
|
-
);
|
|
1544
|
-
a = {
|
|
1545
|
-
step: 0,
|
|
1546
|
-
stepName: "已启动",
|
|
1547
|
-
output: "",
|
|
1548
|
-
agentName: e.agentName || "",
|
|
1549
|
-
agentAvatar: e.agentAvatar || "",
|
|
1550
|
-
executionId: r,
|
|
1551
|
-
previousSteps: [],
|
|
1552
|
-
task_id: e.taskId,
|
|
1553
|
-
pendingCount: e.pendingCount ?? 0,
|
|
1554
|
-
queuedExecutionIds: [],
|
|
1555
|
-
loadingMessageId: u
|
|
1556
|
-
};
|
|
1557
|
-
}
|
|
1558
|
-
const o = [...a.previousSteps];
|
|
1559
|
-
a && a.step !== e.step && o.push({
|
|
1560
|
-
step: a.step,
|
|
1561
|
-
name: a.stepName,
|
|
1562
|
-
output: a.output
|
|
1563
|
-
});
|
|
1564
|
-
const i = e.agentName !== void 0 && e.agentName !== "" ? e.agentName : (a == null ? void 0 : a.agentName) ?? "", c = e.agentAvatar !== void 0 && e.agentAvatar !== "" ? e.agentAvatar : (a == null ? void 0 : a.agentAvatar) ?? "", l = e.pendingCount !== void 0 ? e.pendingCount : (a == null ? void 0 : a.pendingCount) ?? 0;
|
|
1565
|
-
return {
|
|
1566
|
-
runningExecutions: {
|
|
1567
|
-
...s.runningExecutions,
|
|
1568
|
-
[r]: {
|
|
1569
|
-
step: e.step !== void 0 ? e.step : (a == null ? void 0 : a.step) ?? 0,
|
|
1570
|
-
stepName: e.stepName !== void 0 ? e.stepName : (a == null ? void 0 : a.stepName) ?? "",
|
|
1571
|
-
output: e.output !== void 0 ? e.output : (a == null ? void 0 : a.output) ?? "",
|
|
1572
|
-
thoughtOutput: e.thoughtOutput !== void 0 ? e.thoughtOutput : a == null ? void 0 : a.thoughtOutput,
|
|
1573
|
-
agentName: i,
|
|
1574
|
-
agentAvatar: c,
|
|
1575
|
-
executionId: r,
|
|
1576
|
-
previousSteps: o,
|
|
1577
|
-
pendingCount: l,
|
|
1578
|
-
queuedExecutionIds: (a == null ? void 0 : a.queuedExecutionIds) ?? [],
|
|
1579
|
-
loadingMessageId: a == null ? void 0 : a.loadingMessageId,
|
|
1580
|
-
task_id: e.taskId ?? (a == null ? void 0 : a.task_id),
|
|
1581
|
-
toolCall: e.toolCall === null ? void 0 : e.toolCall !== void 0 ? e.toolCall : a == null ? void 0 : a.toolCall,
|
|
1582
|
-
completed: e.completed ?? (a == null ? void 0 : a.completed),
|
|
1583
|
-
result: e.result !== void 0 ? e.result : a == null ? void 0 : a.result
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
};
|
|
1587
|
-
});
|
|
1588
|
-
},
|
|
1589
|
-
clearExecution: (e) => {
|
|
1590
|
-
const r = _(e);
|
|
1591
|
-
n((s) => {
|
|
1592
|
-
const a = { ...s.runningExecutions };
|
|
1593
|
-
return delete a[r], { runningExecutions: a };
|
|
1594
|
-
});
|
|
1595
|
-
},
|
|
1596
|
-
applyExecutionCancelled: (e) => {
|
|
1597
|
-
const r = _(e);
|
|
1598
|
-
n((s) => {
|
|
1599
|
-
const a = s.runningExecutions[r], o = a == null ? void 0 : a.loadingMessageId, i = { ...s.runningExecutions };
|
|
1600
|
-
if (delete i[r], !o)
|
|
1601
|
-
return { runningExecutions: i };
|
|
1602
|
-
const c = (l) => l.id === o ? { ...l, content: "已取消" } : l;
|
|
1603
|
-
return {
|
|
1604
|
-
runningExecutions: i,
|
|
1605
|
-
messages: s.messages.map(c),
|
|
1606
|
-
taskMessages: s.taskMessages.map(c)
|
|
1607
|
-
};
|
|
1608
|
-
});
|
|
1609
|
-
},
|
|
1610
|
-
fetchWorkspaceEnv: async () => {
|
|
1611
|
-
try {
|
|
1612
|
-
const e = await Re();
|
|
1613
|
-
n({ isLocal: !!e.is_local });
|
|
1614
|
-
} catch {
|
|
1615
|
-
n({ isLocal: !1 });
|
|
1616
|
-
}
|
|
1617
|
-
},
|
|
1618
|
-
syncFromProduction: async (e) => {
|
|
1619
|
-
const r = t();
|
|
1620
|
-
if (!r.syncingProjectIds.has(e)) {
|
|
1621
|
-
n({
|
|
1622
|
-
syncingProjectIds: /* @__PURE__ */ new Set([...r.syncingProjectIds, e])
|
|
1623
|
-
});
|
|
1624
|
-
try {
|
|
1625
|
-
const s = await Fe(e), a = `同步完成:${s.files_synced} 个文件,${s.dirs_created} 个目录` + (s.errors.length > 0 ? `,${s.errors.length} 个错误` : "");
|
|
1626
|
-
h(a, s.errors.length > 0 ? "warning" : "success"), n((i) => ({ fileTreeVersion: i.fileTreeVersion + 1 }));
|
|
1627
|
-
const o = t().currentProject;
|
|
1628
|
-
if (o && o.id === e) {
|
|
1629
|
-
const i = await ae(e, "");
|
|
1630
|
-
n((c) => ({
|
|
1631
|
-
fileTrees: { ...c.fileTrees, [e]: i || [] }
|
|
1632
|
-
}));
|
|
1633
|
-
}
|
|
1634
|
-
} catch (s) {
|
|
1635
|
-
const a = (s == null ? void 0 : s.message) || "同步失败";
|
|
1636
|
-
h(a, "error");
|
|
1637
|
-
} finally {
|
|
1638
|
-
n((s) => {
|
|
1639
|
-
const a = new Set(s.syncingProjectIds);
|
|
1640
|
-
return a.delete(e), { syncingProjectIds: a };
|
|
1641
|
-
});
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
},
|
|
1645
|
-
addTaskMessage: (e) => {
|
|
1646
|
-
var l, u;
|
|
1647
|
-
const r = ee(
|
|
1648
|
-
e
|
|
1649
|
-
), s = _(r.task_id);
|
|
1650
|
-
if (C(s)) {
|
|
1651
|
-
const d = jt(r.content);
|
|
1652
|
-
d && t().pushTaskActivity(
|
|
1653
|
-
s,
|
|
1654
|
-
d,
|
|
1655
|
-
r.sender_name,
|
|
1656
|
-
r.id
|
|
1657
|
-
);
|
|
1658
|
-
}
|
|
1659
|
-
const a = ((l = t().activeTaskChat) == null ? void 0 : l.taskId) ?? ((u = t().activeTaskSession) == null ? void 0 : u.task_id);
|
|
1660
|
-
if (!a)
|
|
1661
|
-
return;
|
|
1662
|
-
const o = r.task_id ?? _(a);
|
|
1663
|
-
if (!A(o, a))
|
|
1664
|
-
return;
|
|
1665
|
-
const i = G(
|
|
1666
|
-
{ ...r, task_id: o },
|
|
1667
|
-
t().members
|
|
1668
|
-
), c = i.id;
|
|
1669
|
-
C(c) && n((d) => {
|
|
1670
|
-
let f = d.taskMessages;
|
|
1671
|
-
if (i.sender_type === "AGENT" && i.task_id && (f = f.filter(
|
|
1672
|
-
(g) => !(M(g.id) && g.sender_type === "AGENT" && g.task_id === i.task_id)
|
|
1673
|
-
)), f.findIndex((g) => g.id === c) !== -1)
|
|
1674
|
-
return {
|
|
1675
|
-
taskMessages: H(
|
|
1676
|
-
Y(f, i)
|
|
1677
|
-
)
|
|
1678
|
-
};
|
|
1679
|
-
if (i.sender_type === "AGENT" && Q(i.content)) {
|
|
1680
|
-
const g = bt(
|
|
1681
|
-
f,
|
|
1682
|
-
i,
|
|
1683
|
-
Q
|
|
1684
|
-
);
|
|
1685
|
-
if (g)
|
|
1686
|
-
return { taskMessages: H(g) };
|
|
1687
|
-
}
|
|
1688
|
-
return {
|
|
1689
|
-
taskMessages: H(
|
|
1690
|
-
Y(f, i)
|
|
1691
|
-
)
|
|
1692
|
-
};
|
|
1693
|
-
});
|
|
1694
|
-
},
|
|
1695
|
-
pushTaskActivity: (e, r, s, a) => {
|
|
1696
|
-
const o = String(e || "");
|
|
1697
|
-
if (!o) return;
|
|
1698
|
-
const i = (r || "").trim();
|
|
1699
|
-
i && n((c) => {
|
|
1700
|
-
const l = c.taskActivity[o] ?? [], u = l[l.length - 1];
|
|
1701
|
-
if (a != null && (u == null ? void 0 : u.messageId) === a) {
|
|
1702
|
-
if (u.text === i) return {};
|
|
1703
|
-
const y = {
|
|
1704
|
-
...u,
|
|
1705
|
-
text: i,
|
|
1706
|
-
time: $()
|
|
1707
|
-
};
|
|
1708
|
-
return {
|
|
1709
|
-
taskActivity: {
|
|
1710
|
-
...c.taskActivity,
|
|
1711
|
-
[o]: [...l.slice(0, -1), y]
|
|
1712
|
-
}
|
|
1713
|
-
};
|
|
1714
|
-
}
|
|
1715
|
-
if (u && u.text === i) return {};
|
|
1716
|
-
const d = {
|
|
1717
|
-
id: ++ge,
|
|
1718
|
-
time: $(),
|
|
1719
|
-
text: i,
|
|
1720
|
-
sender: s || void 0,
|
|
1721
|
-
messageId: a ?? void 0
|
|
1722
|
-
}, f = l.length >= L ? [...l.slice(l.length - L + 1), d] : [...l, d];
|
|
1723
|
-
return { taskActivity: { ...c.taskActivity, [o]: f } };
|
|
1724
|
-
});
|
|
1725
|
-
},
|
|
1726
|
-
pushTaskExecutionActivity: (e, r, s, a, o) => {
|
|
1727
|
-
const i = String(e || "");
|
|
1728
|
-
if (!i) return;
|
|
1729
|
-
const c = (a || "").trim();
|
|
1730
|
-
c && n((l) => {
|
|
1731
|
-
const u = l.taskActivity[i] ?? [], d = u[u.length - 1];
|
|
1732
|
-
if ((s === "thinking" || s === "stream") && (d == null ? void 0 : d.executionId) === r && (d == null ? void 0 : d.kind) === s) {
|
|
1733
|
-
if (d.text === c) return {};
|
|
1734
|
-
const I = {
|
|
1735
|
-
...d,
|
|
1736
|
-
text: c,
|
|
1737
|
-
time: $()
|
|
1738
|
-
};
|
|
1739
|
-
return {
|
|
1740
|
-
taskActivity: {
|
|
1741
|
-
...l.taskActivity,
|
|
1742
|
-
[i]: [...u.slice(0, -1), I]
|
|
1743
|
-
}
|
|
1744
|
-
};
|
|
1745
|
-
}
|
|
1746
|
-
if (d && d.text === c) return {};
|
|
1747
|
-
const f = {
|
|
1748
|
-
id: ++ge,
|
|
1749
|
-
time: $(),
|
|
1750
|
-
text: c,
|
|
1751
|
-
sender: o || void 0,
|
|
1752
|
-
executionId: r,
|
|
1753
|
-
kind: s
|
|
1754
|
-
}, y = u.length >= L ? [...u.slice(u.length - L + 1), f] : [...u, f];
|
|
1755
|
-
return { taskActivity: { ...l.taskActivity, [i]: y } };
|
|
1756
|
-
});
|
|
1757
|
-
},
|
|
1758
|
-
openTaskChat: async (e, r, s) => {
|
|
1759
|
-
const a = t().currentProject;
|
|
1760
|
-
if (a) {
|
|
1761
|
-
n({
|
|
1762
|
-
activeTaskChat: { taskId: e, taskName: r },
|
|
1763
|
-
taskMessages: [],
|
|
1764
|
-
taskHasMoreMessages: !1,
|
|
1765
|
-
...s != null && s.switchToTasksTab ? { navigateToTasksTick: t().navigateToTasksTick + 1 } : {}
|
|
1766
|
-
});
|
|
1767
|
-
try {
|
|
1768
|
-
const i = await xe(a.id, e), c = {
|
|
1769
|
-
task_id: _(i.task_id ?? i.taskId ?? e),
|
|
1770
|
-
scenario_instance_id: _(
|
|
1771
|
-
i.scenario_instance_id ?? i.scenarioInstanceId ?? a.id
|
|
1772
|
-
),
|
|
1773
|
-
name: String(i.name ?? r),
|
|
1774
|
-
status: Number(i.status ?? 0)
|
|
1775
|
-
};
|
|
1776
|
-
n({ activeTaskSession: c }), t().loadTaskMessages(e);
|
|
1777
|
-
} catch (o) {
|
|
1778
|
-
console.error("Failed to create task session", o);
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
},
|
|
1782
|
-
closeTaskChat: () => {
|
|
1783
|
-
n({
|
|
1784
|
-
activeTaskChat: null,
|
|
1785
|
-
activeTaskSession: null,
|
|
1786
|
-
taskMessages: [],
|
|
1787
|
-
taskHasMoreMessages: !1
|
|
1788
|
-
});
|
|
1789
|
-
},
|
|
1790
|
-
openTaskFromTodo: async (e, r, s) => {
|
|
1791
|
-
var c;
|
|
1792
|
-
const a = s == null ? "" : String(s);
|
|
1793
|
-
if (!a || a === "0") {
|
|
1794
|
-
h("任务所属工程无效", "error");
|
|
1795
|
-
return;
|
|
1796
|
-
}
|
|
1797
|
-
const o = t().token;
|
|
1798
|
-
let i = t().projects.find((l) => l.id === a);
|
|
1799
|
-
if (!i)
|
|
1800
|
-
try {
|
|
1801
|
-
i = await Ee(a, o), n((l) => ({
|
|
1802
|
-
projects: l.projects.some((d) => d.id === a) ? l.projects : [...l.projects, i]
|
|
1803
|
-
}));
|
|
1804
|
-
} catch (l) {
|
|
1805
|
-
const u = l && typeof l == "object" && "userMessage" in l ? String(l.userMessage) : l instanceof Error ? l.message : "打开工程失败";
|
|
1806
|
-
h(u, "error");
|
|
1807
|
-
return;
|
|
1808
|
-
}
|
|
1809
|
-
String(((c = t().currentProject) == null ? void 0 : c.id) ?? "") !== a && await t().expandProject(i), await t().openTaskChat(e, r, { switchToTasksTab: !0 });
|
|
1810
|
-
},
|
|
1811
|
-
loadTaskMessages: async (e, r = 50, s) => {
|
|
1812
|
-
const a = t().currentProject;
|
|
1813
|
-
if (a)
|
|
1814
|
-
try {
|
|
1815
|
-
const o = await we(
|
|
1816
|
-
a.id,
|
|
1817
|
-
e,
|
|
1818
|
-
r,
|
|
1819
|
-
s
|
|
1820
|
-
), i = Array.isArray(o == null ? void 0 : o.messages) ? o.messages : [], c = vt(i, t().members, e), l = !!o.has_more;
|
|
1821
|
-
s ? n((u) => ({
|
|
1822
|
-
taskMessages: U([...c, ...u.taskMessages]),
|
|
1823
|
-
taskHasMoreMessages: l
|
|
1824
|
-
})) : (n({
|
|
1825
|
-
taskMessages: U(c),
|
|
1826
|
-
taskHasMoreMessages: l
|
|
1827
|
-
}), t().requestChatScrollBottom("task", !1));
|
|
1828
|
-
} catch (o) {
|
|
1829
|
-
console.error("Failed to load task messages", o);
|
|
1830
|
-
}
|
|
1831
|
-
},
|
|
1832
|
-
sendTaskChatMessage: async (e, r, s) => {
|
|
1833
|
-
const a = t().currentProject;
|
|
1834
|
-
if (!(!a || !r.trim() && !(s != null && s.length)))
|
|
1835
|
-
try {
|
|
1836
|
-
await Ne(a.id, e, r, t().token, s), await t().loadTaskMessages(e), t().requestChatScrollBottom("task", !0);
|
|
1837
|
-
} catch (o) {
|
|
1838
|
-
throw console.error("Failed to send task message", o), o;
|
|
1839
|
-
}
|
|
1840
|
-
},
|
|
1841
|
-
loadRunningExecutions: async () => {
|
|
1842
|
-
const e = t().currentProject;
|
|
1843
|
-
if (e)
|
|
1844
|
-
try {
|
|
1845
|
-
const r = await Pe(e.id);
|
|
1846
|
-
n((s) => {
|
|
1847
|
-
var o;
|
|
1848
|
-
const a = {};
|
|
1849
|
-
for (const i of r) {
|
|
1850
|
-
const c = (o = i.steps) == null ? void 0 : o[i.steps.length - 1], l = (i.steps || []).slice(0, -1).map((f) => ({
|
|
1851
|
-
step: f.step,
|
|
1852
|
-
name: f.name,
|
|
1853
|
-
output: f.output
|
|
1854
|
-
})), u = s.runningExecutions[i.id], d = z(
|
|
1855
|
-
i.agent_name || (u == null ? void 0 : u.agentName),
|
|
1856
|
-
i.task_id ?? (u == null ? void 0 : u.task_id),
|
|
1857
|
-
{ ...s.runningExecutions, ...a },
|
|
1858
|
-
s.messages,
|
|
1859
|
-
s.taskMessages,
|
|
1860
|
-
u == null ? void 0 : u.loadingMessageId
|
|
1861
|
-
);
|
|
1862
|
-
a[i.id] = {
|
|
1863
|
-
executionId: i.id,
|
|
1864
|
-
step: (c == null ? void 0 : c.step) || 1,
|
|
1865
|
-
stepName: (c == null ? void 0 : c.name) || "执行中",
|
|
1866
|
-
output: (c == null ? void 0 : c.output) || "...",
|
|
1867
|
-
agentName: i.agent_name || (u == null ? void 0 : u.agentName) || "",
|
|
1868
|
-
agentAvatar: (u == null ? void 0 : u.agentAvatar) || "🤖",
|
|
1869
|
-
previousSteps: l,
|
|
1870
|
-
task_id: i.task_id ?? (u == null ? void 0 : u.task_id),
|
|
1871
|
-
loadingMessageId: d
|
|
1872
|
-
};
|
|
1873
|
-
}
|
|
1874
|
-
for (const [i, c] of Object.entries(s.runningExecutions))
|
|
1875
|
-
!a[i] && !c.completed && (a[i] = c);
|
|
1876
|
-
return { runningExecutions: a };
|
|
1877
|
-
});
|
|
1878
|
-
} catch {
|
|
1879
|
-
}
|
|
1880
|
-
}
|
|
1881
|
-
}));
|
|
1882
|
-
export {
|
|
1883
|
-
Bt as A,
|
|
1884
|
-
Ht as B,
|
|
1885
|
-
Lt as C,
|
|
1886
|
-
Ut as D,
|
|
1887
|
-
Kt as E,
|
|
1888
|
-
Te as F,
|
|
1889
|
-
q as G,
|
|
1890
|
-
Yt as H,
|
|
1891
|
-
Qt as I,
|
|
1892
|
-
he as J,
|
|
1893
|
-
Wt as T,
|
|
1894
|
-
xt as a,
|
|
1895
|
-
be as b,
|
|
1896
|
-
Xt as c,
|
|
1897
|
-
tn as d,
|
|
1898
|
-
en as e,
|
|
1899
|
-
Jt as f,
|
|
1900
|
-
Me as g,
|
|
1901
|
-
w as h,
|
|
1902
|
-
Rt as i,
|
|
1903
|
-
Gt as j,
|
|
1904
|
-
Vt as k,
|
|
1905
|
-
Mt as l,
|
|
1906
|
-
Zt as m,
|
|
1907
|
-
ee as n,
|
|
1908
|
-
zt as o,
|
|
1909
|
-
R as p,
|
|
1910
|
-
qt as q,
|
|
1911
|
-
kt as r,
|
|
1912
|
-
h as s,
|
|
1913
|
-
Ft as t,
|
|
1914
|
-
nn as u,
|
|
1915
|
-
Ot as v,
|
|
1916
|
-
Dt as w,
|
|
1917
|
-
$t as x,
|
|
1918
|
-
E as y,
|
|
1919
|
-
Q as z
|
|
1920
|
-
};
|