@yuku123/z-team-component 0.2.29 → 0.2.31

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 (49) hide show
  1. package/dist/{ChangeLogView-CG-o5YP1.js → ChangeLogView-FLd1wS8H.js} +1 -1
  2. package/dist/ComponentDoc-CUhlRqDo.js +3843 -0
  3. package/dist/DebugPlayground-cxffrMgF.js +15 -0
  4. package/dist/{InvitationManagementPage-ByJuWwA_.js → InvitationManagementPage-DBAAQ3Qq.js} +90 -85
  5. package/dist/{OnboardingPage-D58h1JK_.js → OnboardingPage-zLHkQLok.js} +2 -2
  6. package/dist/SmartWorkbench.module-DzQskKT0.js +85 -0
  7. package/dist/SystemShell-yMCZOMUN.js +635 -0
  8. package/dist/{admin-logs-C2V1ElH9.js → admin-logs-Dv86pFvY.js} +2 -2
  9. package/dist/{api--Fg0hL9Y.js → api-19TXED_O.js} +52 -39
  10. package/dist/api-63lPU5Cs.js +20 -0
  11. package/dist/{createWorkspaceWsHandler-CqGqcTh_.js → createWorkspaceWsHandler-CBk4DqP4.js} +6 -5
  12. package/dist/{index-CDKg_qI5.js → index-B5_xKK08.js} +1140 -1153
  13. package/dist/{index-D2S8FrNc.js → index-BCBBZW4m.js} +358 -347
  14. package/dist/{index-D5u3BjCZ.js → index-BIJnjJd5.js} +2 -2
  15. package/dist/{index-bbwTcNjB.js → index-BTLD5gUt.js} +3 -3
  16. package/dist/{index-CiMxCTOS.js → index-B_EBV24V.js} +1 -1
  17. package/dist/{index-DOVOWiGU.js → index-BbjzrjsP.js} +1134 -1132
  18. package/dist/{index-BafC42Cl.js → index-Bd57t_yF.js} +1 -1
  19. package/dist/{index-C2aPiQSz.js → index-BjqYiZpC.js} +3 -3
  20. package/dist/{index-BaCiSbPR.js → index-BoGVJ0hC.js} +1 -1
  21. package/dist/{index-C01UUprh.js → index-BpuJ9Njb.js} +7016 -6946
  22. package/dist/index-C6vfXs2f.js +1329 -0
  23. package/dist/{index-CcFJEYgr.js → index-C815hPWS.js} +55 -52
  24. package/dist/{index-DvIHX7lZ.js → index-CcpWacSZ.js} +243 -236
  25. package/dist/index-CrC94bvI.js +169 -0
  26. package/dist/{index-Dky6GVc1.js → index-CwIgdJYL.js} +9 -9
  27. package/dist/{index-Da7ls5q6.js → index-DOPkM2W8.js} +6 -6
  28. package/dist/{index-CTD7k9dP.js → index-DYgD6BuB.js} +4 -4
  29. package/dist/{index-Da3doGtf.js → index-JMzBzwiO.js} +57 -54
  30. package/dist/{index-BwFEDHy3.js → index-VHvEmmhf.js} +5 -5
  31. package/dist/{index-CRac8IT2.js → index-icI-ZchA.js} +3 -3
  32. package/dist/{index-Dao4uqQd.js → index-x4-W5ClM.js} +4 -4
  33. package/dist/index.js +7 -6
  34. package/dist/{instance-1QEDBRqA.js → instance-D951fRuD.js} +1 -1
  35. package/dist/pages.js +13 -9
  36. package/dist/{schedule-C89oiqIR.js → schedule-DD50-7cs.js} +1 -1
  37. package/dist/{send-default-agent-team-message-CxkWi3XC.js → send-default-agent-team-message-Bbs2rMNf.js} +1 -1
  38. package/dist/{sso-user-BE1Ell5F.js → sso-user-BEY5ICaR.js} +1 -1
  39. package/dist/{training-o-vSBkqP.js → training-B-9tNFQw.js} +1 -1
  40. package/dist/{useAppStore-wgWaxcyc.js → useAppStore-BQN-26ns.js} +1 -1
  41. package/dist/{webide-BxD6cYe-.js → webide-P867RFZi.js} +4 -4
  42. package/dist/z-team-component.css +1 -1
  43. package/package.json +2 -2
  44. package/dist/ProjectApp-oUbzb0Io.js +0 -3818
  45. package/dist/SmartWorkbench.module-xRRmpTTw.js +0 -85
  46. package/dist/SystemShell-D4mGsT0X.js +0 -604
  47. package/dist/api-3-Ykp2ll.js +0 -19
  48. package/dist/index-B8mNsH88.js +0 -1411
  49. package/dist/index-DYDba1NC.js +0 -187
@@ -1,1411 +0,0 @@
1
- import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
- import { CopyOutlined as ae, ReloadOutlined as ge, PlusOutlined as fe, DeleteOutlined as Ke, ClearOutlined as _e, CloseOutlined as Pe, SendOutlined as be, RobotOutlined as ke, CloudServerOutlined as Ie, MessageOutlined as Be, KeyOutlined as $e, ApiOutlined as Oe, ToolOutlined as De, BarChartOutlined as Le } from "@ant-design/icons";
3
- import { Tooltip as W, Tabs as ye, Button as z, Modal as re, Input as Ne, Drawer as ve, Spin as X, Statistic as b, Table as we, message as F, Tag as G, Select as Re, Checkbox as ze } from "antd";
4
- import { useState as y, useCallback as U, useEffect as te, useRef as le, useMemo as Ce, Suspense as qe, lazy as He } from "react";
5
- import { s as t } from "./SmartWorkbench.module-xRRmpTTw.js";
6
- import { AgentAppList as Ue, McpPage as je, SkillMarket as Fe } from "@yuku123/z-agent-component";
7
- const oe = "ft_gateway_default_ak", Ge = typeof window < "u" && window.ZTEAM_USE_KAPI === !0, Te = Ge, Je = `${Te ? "/kapi" : ""}/z-team`, Q = Te ? "/kapi/z-team-agent-gateway" : "/gateway-api";
8
- function We(a) {
9
- return {
10
- modelName: String(a.modelName ?? a.model_name ?? a.service ?? ""),
11
- service: String(a.service ?? a.modelName ?? ""),
12
- endpoint: String(a.endpoint ?? ""),
13
- modelProvider: a.modelProvider ?? a.model_provider ?? null,
14
- apiType: String(a.apiType ?? a.api_type ?? "OpenAPI")
15
- };
16
- }
17
- async function Se() {
18
- let a;
19
- try {
20
- a = await fetch(`${Je}/api/scenario-instances/0/models`, {
21
- credentials: "include",
22
- headers: {
23
- Accept: "application/json",
24
- "project-env": window.ENV_TYPE ?? "local"
25
- }
26
- });
27
- } catch {
28
- throw new Error("模型列表不可达:模型配置接口请求失败");
29
- }
30
- if (!a.ok)
31
- throw new Error(`模型列表获取失败(HTTP ${a.status})`);
32
- let s;
33
- try {
34
- s = await a.json();
35
- } catch {
36
- throw new Error("模型列表返回格式异常(非 JSON)");
37
- }
38
- const i = s != null && s.success ? s.data : (s == null ? void 0 : s.data) ?? s;
39
- if (!Array.isArray(i))
40
- throw new Error("模型列表返回格式异常(非数组)");
41
- return i.map(We);
42
- }
43
- async function Qe(a, s, i, l) {
44
- var B, T, D, x;
45
- const c = await fetch(`${Q}/v1/chat/completions`, {
46
- method: "POST",
47
- headers: {
48
- "Content-Type": "application/json",
49
- Authorization: `Bearer ${a}`,
50
- Accept: "text/event-stream"
51
- },
52
- body: JSON.stringify({
53
- model: s,
54
- messages: i,
55
- stream: !0
56
- }),
57
- signal: l.signal
58
- });
59
- if (!c.ok || !c.body) {
60
- const v = await c.text().catch(() => "");
61
- let E = `HTTP ${c.status}`;
62
- try {
63
- const f = JSON.parse(v);
64
- E = ((B = f == null ? void 0 : f.error) == null ? void 0 : B.message) ?? E;
65
- } catch {
66
- v && (E = v);
67
- }
68
- throw new Error(E);
69
- }
70
- const I = c.body.getReader(), u = new TextDecoder();
71
- let N = "";
72
- try {
73
- for (; ; ) {
74
- const { done: v, value: E } = await I.read();
75
- if (v) break;
76
- N += u.decode(E, { stream: !0 });
77
- const f = N.split(`
78
-
79
- `);
80
- N = f.pop() ?? "";
81
- for (const p of f) {
82
- let k = "";
83
- for (const d of p.split(`
84
- `))
85
- d.startsWith("data:") && (k += d.slice(5).trim());
86
- if (!k || k === "[DONE]") {
87
- if (k === "[DONE]") {
88
- l.onDone();
89
- return;
90
- }
91
- continue;
92
- }
93
- try {
94
- const d = JSON.parse(k), A = d == null ? void 0 : d.choices;
95
- if (Array.isArray(A) && A.length > 0) {
96
- const m = (T = A[0]) == null ? void 0 : T.delta;
97
- if (m != null && m.content && l.onDelta(m.content), (D = A[0]) == null ? void 0 : D.finish_reason) {
98
- const M = d != null && d.usage ? {
99
- promptTokens: d.usage.prompt_tokens ?? 0,
100
- completionTokens: d.usage.completion_tokens ?? 0,
101
- totalTokens: d.usage.total_tokens ?? 0
102
- } : void 0;
103
- l.onDone(M);
104
- return;
105
- }
106
- }
107
- if (d != null && d.usage) {
108
- const m = {
109
- promptTokens: d.usage.prompt_tokens ?? 0,
110
- completionTokens: d.usage.completion_tokens ?? 0,
111
- totalTokens: d.usage.total_tokens ?? 0
112
- };
113
- l.onDone(m);
114
- return;
115
- }
116
- } catch {
117
- }
118
- }
119
- }
120
- l.onDone();
121
- } catch (v) {
122
- if ((x = l.signal) != null && x.aborted) return;
123
- throw l.onError(v instanceof Error ? v : new Error(String(v))), v;
124
- }
125
- }
126
- async function Ae(a, s, i) {
127
- const l = await fetch(`${Q}/v1/api-keys`, {
128
- method: "POST",
129
- headers: { "Content-Type": "application/json" },
130
- body: JSON.stringify({ userId: a, userName: s, description: i })
131
- });
132
- if (!l.ok) {
133
- const c = await l.text().catch(() => "");
134
- throw new Error(`创建 AK 失败: ${c || l.status}`);
135
- }
136
- return l.json();
137
- }
138
- async function ce(a) {
139
- const s = await fetch(
140
- `${Q}/v1/api-keys?userId=${encodeURIComponent(a)}`,
141
- { headers: { "Content-Type": "application/json" } }
142
- );
143
- if (!s.ok) throw new Error(`获取 AK 列表失败 HTTP ${s.status}`);
144
- const i = await s.json(), l = (i == null ? void 0 : i.apiKeys) ?? i;
145
- return Array.isArray(l) ? l : [];
146
- }
147
- async function Ye(a) {
148
- const s = await fetch(`${Q}/v1/api-keys/${a}`, {
149
- method: "DELETE"
150
- });
151
- if (!s.ok) throw new Error(`吊销 AK 失败 HTTP ${s.status}`);
152
- }
153
- async function xe(a) {
154
- const s = await fetch(`${Q}/v1/api-keys/${a}/usage`);
155
- if (!s.ok) throw new Error(`获取用量统计失败 HTTP ${s.status}`);
156
- const i = await s.json();
157
- return (i == null ? void 0 : i.data) ?? i;
158
- }
159
- function Ve() {
160
- return typeof window < "u" ? `${window.location.origin}${Q}` : Q;
161
- }
162
- const de = "ft_gateway_ak_cache";
163
- function Xe(a, s) {
164
- try {
165
- const i = JSON.parse(localStorage.getItem(de) || "{}");
166
- i[a] = s, localStorage.setItem(de, JSON.stringify(i));
167
- } catch {
168
- }
169
- }
170
- function Ze(a) {
171
- try {
172
- return JSON.parse(localStorage.getItem(de) || "{}")[a] || null;
173
- } catch {
174
- return null;
175
- }
176
- }
177
- async function et() {
178
- try {
179
- const s = localStorage.getItem(oe);
180
- if (s) return s;
181
- } catch {
182
- }
183
- const a = await Ae(
184
- "system-default",
185
- "系统默认",
186
- "智能工作台默认AK(自动创建)"
187
- );
188
- try {
189
- localStorage.setItem(oe, a.apiKey);
190
- } catch {
191
- }
192
- return a.apiKey;
193
- }
194
- function Ee() {
195
- try {
196
- localStorage.removeItem(oe);
197
- } catch {
198
- }
199
- }
200
- const he = 1e7;
201
- function ue(a) {
202
- return a >= 1e6 ? `${(a / 1e6).toFixed(1)}M` : a >= 1e3 ? `${(a / 1e3).toFixed(1)}K` : `${a}`;
203
- }
204
- function tt(a) {
205
- return `# OpenAI 兼容
206
- curl -X POST ${a}/v1/chat/completions \\
207
- -H "Content-Type: application/json" \\
208
- -H "Authorization: Bearer ft-xxx" \\
209
- -d '{
210
- "model": "qwen3.6-flash",
211
- "messages": [{"role":"user","content":"你好"}],
212
- "stream": true
213
- }'`;
214
- }
215
- function at(a) {
216
- return `# Anthropic 兼容
217
- curl -X POST ${a}/v1/messages \\
218
- -H "Content-Type: application/json" \\
219
- -H "x-api-key: ft-xxx" \\
220
- -d '{
221
- "model": "qwen3.6-flash",
222
- "messages": [{"role":"user","content":"你好"}]
223
- }'`;
224
- }
225
- function nt() {
226
- const [a, s] = y("personal"), [i, l] = y([]), [c, I] = y([]), [u, N] = y(!0), [B, T] = y(!1), [D, x] = y(!1), [v, E] = y(""), [f, p] = y({ open: !1 }), [k, d] = y(null), [A, m] = y(null), [P, M] = y(!1), L = "zifang", K = "zifang", _ = Ve(), j = U(async () => {
227
- N(!0);
228
- try {
229
- const [o, S] = await Promise.all([
230
- ce("system-default").catch(() => []),
231
- ce(L).catch(() => [])
232
- ]);
233
- l(o), I(S);
234
- } finally {
235
- N(!1);
236
- }
237
- }, [L]);
238
- te(() => {
239
- j();
240
- }, [j]);
241
- const r = () => {
242
- E(""), x(!0);
243
- }, h = async () => {
244
- if (!v.trim()) {
245
- F.warning("请输入 AK 名称");
246
- return;
247
- }
248
- T(!0);
249
- try {
250
- const o = await Ae(L, K, v.trim());
251
- Xe(o.akPrefix, o.apiKey), x(!1), p({
252
- open: !0,
253
- apiKey: o.apiKey,
254
- akPrefix: o.akPrefix
255
- }), j();
256
- } catch (o) {
257
- F.error(o instanceof Error ? o.message : "创建 AK 失败");
258
- } finally {
259
- T(!1);
260
- }
261
- }, w = (o) => {
262
- re.confirm({
263
- title: "确认吊销此 AK?",
264
- content: "吊销后此 AK 将立即失效,无法恢复。",
265
- okText: "确认吊销",
266
- okType: "danger",
267
- cancelText: "取消",
268
- onOk: async () => {
269
- try {
270
- await Ye(o), F.success("AK 已吊销"), j(), Ee();
271
- } catch (S) {
272
- F.error(S instanceof Error ? S.message : "吊销失败");
273
- }
274
- }
275
- });
276
- }, C = (o) => {
277
- navigator.clipboard.writeText(o).then(() => F.success("已复制到剪贴板")).catch(() => F.warning("复制失败,请手动复制"));
278
- }, J = (o) => {
279
- const S = Ze(o.akPrefix);
280
- S ? C(S) : (C(o.akPrefix), F.info("完整 AK 未在本地缓存(可能在本设备外创建),已复制前缀"));
281
- }, $ = async (o) => {
282
- d(o), M(!0), m(null);
283
- try {
284
- const S = await xe(o.id);
285
- m(S);
286
- } catch (S) {
287
- F.error(S instanceof Error ? S.message : "获取用量失败");
288
- } finally {
289
- M(!1);
290
- }
291
- }, Y = () => {
292
- d(null), m(null);
293
- }, se = (o) => {
294
- const S = Object.entries(o);
295
- if (S.length === 0)
296
- return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
297
- const V = Math.max(...S.map(([, g]) => g[1] + g[2]), 1);
298
- return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: S.map(([g, H]) => {
299
- const me = H[1] + H[2], Me = me / V * 100;
300
- return /* @__PURE__ */ n("div", { className: t.usageBarCol, children: [
301
- /* @__PURE__ */ e(W, { title: `${g}: ${H[0]}次 / ${me} tokens`, children: /* @__PURE__ */ e(
302
- "div",
303
- {
304
- className: t.usageBar,
305
- style: { height: `${Math.max(Me, 2)}%` }
306
- }
307
- ) }),
308
- /* @__PURE__ */ e("span", { className: t.usageBarLabel, children: g })
309
- ] }, g);
310
- }) });
311
- }, R = (o) => {
312
- const S = Object.entries(o);
313
- if (S.length === 0)
314
- return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
315
- const V = Math.max(...S.map(([, g]) => g[0]), 1);
316
- return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: S.sort((g, H) => H[1][0] - g[1][0]).map(([g, H]) => /* @__PURE__ */ n("div", { className: t.modelBreakdownRow, children: [
317
- /* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: g }),
318
- /* @__PURE__ */ e("div", { className: t.modelBreakdownBar, children: /* @__PURE__ */ e(
319
- "div",
320
- {
321
- className: t.modelBreakdownFill,
322
- style: { width: `${H[0] / V * 100}%` }
323
- }
324
- ) }),
325
- /* @__PURE__ */ n("span", { className: t.modelBreakdownCount, children: [
326
- H[0],
327
- "次 / ",
328
- H[1],
329
- "tokens"
330
- ] })
331
- ] }, g)) });
332
- }, q = [
333
- {
334
- title: "时间",
335
- dataIndex: "createTime",
336
- key: "createTime",
337
- width: 160,
338
- render: (o) => o ? new Date(o).toLocaleString("zh-CN") : "-"
339
- },
340
- { title: "模型", dataIndex: "model", key: "model", width: 140 },
341
- {
342
- title: "协议",
343
- dataIndex: "protocol",
344
- key: "protocol",
345
- width: 90,
346
- render: (o) => /* @__PURE__ */ e(G, { children: o })
347
- },
348
- {
349
- title: "输入",
350
- dataIndex: "promptTokens",
351
- key: "promptTokens",
352
- width: 70
353
- },
354
- {
355
- title: "输出",
356
- dataIndex: "completionTokens",
357
- key: "completionTokens",
358
- width: 70
359
- },
360
- {
361
- title: "总Token",
362
- dataIndex: "totalTokens",
363
- key: "totalTokens",
364
- width: 80
365
- },
366
- {
367
- title: "耗时",
368
- dataIndex: "latencyMs",
369
- key: "latencyMs",
370
- width: 70,
371
- render: (o) => o ? `${o}ms` : "-"
372
- },
373
- {
374
- title: "状态",
375
- dataIndex: "statusCode",
376
- key: "statusCode",
377
- width: 60,
378
- render: (o) => o ? /* @__PURE__ */ e(G, { color: o < 400 ? "green" : "red", children: o }) : "-"
379
- }
380
- ], Z = (o, S) => {
381
- const V = Array.isArray(o) ? o : [];
382
- return u ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 40 }, children: /* @__PURE__ */ e(X, { tip: "加载中..." }) }) : V.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: S ? "暂无应用 AK" : "暂无个人 AK,点击上方按钮生成" }) : /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: V.map((g) => /* @__PURE__ */ n(
383
- "div",
384
- {
385
- className: t.akCard,
386
- onClick: () => $(g),
387
- children: [
388
- /* @__PURE__ */ n("div", { className: t.akCardRow, children: [
389
- /* @__PURE__ */ e("span", { className: t.akTitle, children: g.description || g.akPrefix.replace("...", "**") }),
390
- /* @__PURE__ */ e("code", { className: t.akPrefixSmall, children: g.akPrefix.replace("...", "**") }),
391
- /* @__PURE__ */ e(
392
- "span",
393
- {
394
- className: `${t.akStatus} ${g.active ? t.akStatusActive : t.akStatusRevoked}`,
395
- children: g.active ? "活跃" : "已吊销"
396
- }
397
- ),
398
- g.defaultModel && /* @__PURE__ */ n(G, { style: { fontSize: 11 }, children: [
399
- "默认: ",
400
- g.defaultModel
401
- ] }),
402
- /* @__PURE__ */ n(
403
- "div",
404
- {
405
- className: t.akCardActions,
406
- onClick: (H) => H.stopPropagation(),
407
- children: [
408
- /* @__PURE__ */ e(W, { title: "复制完整 AK", children: /* @__PURE__ */ e(
409
- z,
410
- {
411
- size: "small",
412
- icon: /* @__PURE__ */ e(ae, {}),
413
- onClick: () => J(g),
414
- children: "复制"
415
- }
416
- ) }),
417
- !S && g.active && /* @__PURE__ */ e(
418
- z,
419
- {
420
- size: "small",
421
- danger: !0,
422
- icon: /* @__PURE__ */ e(Ke, {}),
423
- onClick: () => w(g.id),
424
- children: "吊销"
425
- }
426
- )
427
- ]
428
- }
429
- )
430
- ] }),
431
- /* @__PURE__ */ n("div", { className: t.akCardRow2, children: [
432
- /* @__PURE__ */ e("div", { className: t.akMiniBar, children: /* @__PURE__ */ e(
433
- "div",
434
- {
435
- className: t.akMiniBarFill,
436
- style: {
437
- width: `${Math.min(
438
- (g.totalTokens || 0) / (g.tokenQuota || he) * 100,
439
- 100
440
- )}%`
441
- }
442
- }
443
- ) }),
444
- /* @__PURE__ */ n("span", { className: t.akUsageText, children: [
445
- ue(g.totalTokens || 0),
446
- " /",
447
- " ",
448
- ue(g.tokenQuota || he)
449
- ] }),
450
- /* @__PURE__ */ n("span", { className: t.akMetaText, children: [
451
- g.totalRequests || 0,
452
- " 次请求"
453
- ] }),
454
- /* @__PURE__ */ e("span", { className: t.akMetaText, children: new Date(g.createTime).toLocaleDateString("zh-CN") })
455
- ] })
456
- ]
457
- },
458
- g.id
459
- )) });
460
- };
461
- return /* @__PURE__ */ n("div", { className: t.akContainer, children: [
462
- /* @__PURE__ */ n("div", { className: t.akIntegrationPanel, children: [
463
- /* @__PURE__ */ e("h4", { className: t.akIntegrationTitle, children: "协议接入地址" }),
464
- /* @__PURE__ */ n("div", { className: t.akBaseUrlRow, children: [
465
- /* @__PURE__ */ n("div", { className: t.akBaseUrlItem, children: [
466
- /* @__PURE__ */ e("span", { className: t.akBaseUrlLabel, children: "OpenAI 兼容" }),
467
- /* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: _ }),
468
- /* @__PURE__ */ e(W, { title: "复制 Base URL", children: /* @__PURE__ */ e(
469
- ae,
470
- {
471
- className: t.akCopyIcon,
472
- onClick: () => C(_)
473
- }
474
- ) })
475
- ] }),
476
- /* @__PURE__ */ n("div", { className: t.akBaseUrlItem, children: [
477
- /* @__PURE__ */ e("span", { className: t.akBaseUrlLabel, children: "Anthropic 兼容" }),
478
- /* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: _ }),
479
- /* @__PURE__ */ e(W, { title: "复制 Base URL", children: /* @__PURE__ */ e(
480
- ae,
481
- {
482
- className: t.akCopyIcon,
483
- onClick: () => C(_)
484
- }
485
- ) })
486
- ] })
487
- ] }),
488
- /* @__PURE__ */ n("div", { className: t.akIntegrationGrid, children: [
489
- /* @__PURE__ */ n("div", { children: [
490
- /* @__PURE__ */ e("p", { className: t.akCodeLabel, children: "OpenAI 兼容 — curl 示例" }),
491
- /* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: tt(_) })
492
- ] }),
493
- /* @__PURE__ */ n("div", { children: [
494
- /* @__PURE__ */ e("p", { className: t.akCodeLabel, children: "Anthropic 兼容 — curl 示例" }),
495
- /* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: at(_) })
496
- ] })
497
- ] })
498
- ] }),
499
- /* @__PURE__ */ n("div", { children: [
500
- /* @__PURE__ */ n(
501
- "div",
502
- {
503
- style: {
504
- display: "flex",
505
- justifyContent: "space-between",
506
- alignItems: "center",
507
- marginBottom: 12
508
- },
509
- children: [
510
- /* @__PURE__ */ e(
511
- ye,
512
- {
513
- activeKey: a,
514
- onChange: (o) => s(o),
515
- items: [
516
- { key: "app", label: "应用 AK" },
517
- { key: "personal", label: "个人 AK" }
518
- ],
519
- style: { flex: 1 }
520
- }
521
- ),
522
- /* @__PURE__ */ n("div", { style: { display: "flex", gap: 8 }, children: [
523
- /* @__PURE__ */ e(z, { icon: /* @__PURE__ */ e(ge, {}), onClick: j, size: "small", children: "刷新" }),
524
- a === "personal" && /* @__PURE__ */ e(
525
- z,
526
- {
527
- type: "primary",
528
- icon: /* @__PURE__ */ e(fe, {}),
529
- onClick: r,
530
- loading: B,
531
- children: "生成 AK"
532
- }
533
- )
534
- ] })
535
- ]
536
- }
537
- ),
538
- a === "app" ? Z(i, !0) : Z(c, !1)
539
- ] }),
540
- /* @__PURE__ */ n(
541
- re,
542
- {
543
- open: D,
544
- title: "生成新 AK",
545
- onCancel: () => x(!1),
546
- onOk: h,
547
- okText: "确认生成",
548
- cancelText: "取消",
549
- confirmLoading: B,
550
- children: [
551
- /* @__PURE__ */ e(
552
- "div",
553
- {
554
- style: {
555
- marginBottom: 8,
556
- color: "var(--text-secondary)",
557
- fontSize: 13
558
- },
559
- children: "请输入 AK 名称(用于标识此密钥的用途)"
560
- }
561
- ),
562
- /* @__PURE__ */ e(
563
- Ne,
564
- {
565
- placeholder: "例如:测试用 AK、生产网关 AK",
566
- value: v,
567
- onChange: (o) => E(o.target.value),
568
- onPressEnter: h,
569
- maxLength: 50,
570
- autoFocus: !0
571
- }
572
- )
573
- ]
574
- }
575
- ),
576
- /* @__PURE__ */ n(
577
- re,
578
- {
579
- open: f.open,
580
- title: "AK 创建成功",
581
- onCancel: () => p({ open: !1 }),
582
- footer: [
583
- /* @__PURE__ */ e(
584
- z,
585
- {
586
- icon: /* @__PURE__ */ e(ae, {}),
587
- onClick: () => f.apiKey && C(f.apiKey),
588
- children: "复制 AK"
589
- },
590
- "copy"
591
- ),
592
- /* @__PURE__ */ e(
593
- z,
594
- {
595
- type: "primary",
596
- onClick: () => p({ open: !1 }),
597
- children: "我已保存"
598
- },
599
- "close"
600
- )
601
- ],
602
- children: [
603
- /* @__PURE__ */ e("div", { style: { marginBottom: 8, color: "#faad14", fontSize: 14 }, children: "请立即保存此 AK,关闭后将无法再次查看完整密钥。" }),
604
- /* @__PURE__ */ e(
605
- "div",
606
- {
607
- style: {
608
- background: "var(--bg-tertiary, #f6f8fa)",
609
- padding: "12px 14px",
610
- borderRadius: 8,
611
- fontFamily: "SF Mono, Fira Code, monospace",
612
- fontSize: 13,
613
- wordBreak: "break-all",
614
- userSelect: "all"
615
- },
616
- children: f.apiKey
617
- }
618
- ),
619
- /* @__PURE__ */ n("div", { style: { marginTop: 8, fontSize: 12, color: "var(--text-muted)" }, children: [
620
- "前缀: ",
621
- f.akPrefix
622
- ] })
623
- ]
624
- }
625
- ),
626
- /* @__PURE__ */ e(
627
- ve,
628
- {
629
- title: k ? /* @__PURE__ */ n("span", { children: [
630
- "AK 详情 — ",
631
- /* @__PURE__ */ e("code", { children: k.akPrefix })
632
- ] }) : "AK 详情",
633
- open: !!k,
634
- onClose: Y,
635
- size: "large",
636
- children: P ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(X, { tip: "加载用量数据..." }) }) : A ? /* @__PURE__ */ n("div", { className: t.usageDrawerContent, children: [
637
- /* @__PURE__ */ n("div", { className: t.usageStatsGrid, children: [
638
- /* @__PURE__ */ e(b, { title: "总请求数", value: A.totalRequests }),
639
- /* @__PURE__ */ e(b, { title: "总 Token", value: A.totalTokens }),
640
- /* @__PURE__ */ e(
641
- b,
642
- {
643
- title: "输入 Token",
644
- value: A.totalPromptTokens
645
- }
646
- ),
647
- /* @__PURE__ */ e(
648
- b,
649
- {
650
- title: "输出 Token",
651
- value: A.totalCompletionTokens
652
- }
653
- ),
654
- /* @__PURE__ */ e(
655
- b,
656
- {
657
- title: "平均耗时",
658
- value: A.avgLatencyMs,
659
- suffix: "ms"
660
- }
661
- ),
662
- /* @__PURE__ */ e(
663
- b,
664
- {
665
- title: "错误数",
666
- value: A.errorCount,
667
- styles: {
668
- content: {
669
- color: A.errorCount > 0 ? "#ff4d4f" : void 0
670
- }
671
- }
672
- }
673
- )
674
- ] }),
675
- /* @__PURE__ */ n("div", { className: t.usageSection, children: [
676
- /* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "每日调用曲线(近 30 天)" }),
677
- se(A.daily)
678
- ] }),
679
- /* @__PURE__ */ n("div", { className: t.usageSection, children: [
680
- /* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "模型用量分布" }),
681
- R(A.models)
682
- ] }),
683
- /* @__PURE__ */ n("div", { className: t.usageSection, children: [
684
- /* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "最近调用记录" }),
685
- /* @__PURE__ */ e(
686
- we,
687
- {
688
- columns: q,
689
- dataSource: A.recent,
690
- rowKey: "id",
691
- size: "small",
692
- pagination: { pageSize: 10, size: "small" },
693
- scroll: { x: 760 }
694
- }
695
- )
696
- ] })
697
- ] }) : /* @__PURE__ */ e("div", { className: t.usageEmpty, children: "暂无用量数据" })
698
- }
699
- )
700
- ] });
701
- }
702
- function st(a) {
703
- const s = [];
704
- if (!a) return s;
705
- const i = /<(think|thinking|reasoning)>([\s\S]*?)<\/\1>/gi;
706
- let l = 0, c;
707
- for (; (c = i.exec(a)) !== null; )
708
- c.index > l && s.push({ type: "text", text: a.slice(l, c.index) }), s.push({ type: "think", text: c[2] }), l = c.index + c[0].length;
709
- return l < a.length && s.push({ type: "text", text: a.slice(l) }), s;
710
- }
711
- const ne = 4;
712
- let rt = 0;
713
- function lt({ initialModels: a }) {
714
- const [s, i] = y([]), [l, c] = y([]), [I, u] = y(!0), [N, B] = y(null), [T, D] = y(""), [x, v] = y(!1), E = le(""), f = le(/* @__PURE__ */ new Map()), p = le(/* @__PURE__ */ new Map());
715
- te(() => {
716
- (async () => {
717
- try {
718
- const r = await Se();
719
- c(r), u(!1);
720
- const h = a.length > 0 ? a : r.slice(0, 1).map((w) => w.modelName);
721
- i(h.slice(0, ne).map((w) => ie(w)));
722
- } catch (r) {
723
- u(!1), B(r instanceof Error ? r.message : "模型列表加载失败");
724
- }
725
- })();
726
- }, []), te(() => {
727
- if (a.length > 0 && l.length > 0) {
728
- const r = a.slice(0, ne).map((h) => ie(h));
729
- i(r);
730
- }
731
- }, [a.join(",")]);
732
- const k = U((r) => {
733
- const h = p.current.get(r);
734
- h && (h.scrollTop = h.scrollHeight);
735
- }, []), d = U(
736
- (r, h) => {
737
- i((w) => w.map((C) => C.id === r ? h(C) : C));
738
- },
739
- []
740
- ), A = U(async () => {
741
- if (E.current) return E.current;
742
- const r = await et();
743
- return E.current = r, r;
744
- }, []), m = U(async () => {
745
- const r = T.trim();
746
- if (!r || x) return;
747
- let h;
748
- try {
749
- h = await A();
750
- } catch {
751
- return;
752
- }
753
- D(""), v(!0);
754
- const w = s.map(($) => ({
755
- ...$,
756
- messages: [
757
- ...$.messages,
758
- { role: "user", content: r },
759
- { role: "assistant", content: "" }
760
- ],
761
- streamingContent: "",
762
- isStreaming: !0,
763
- error: null,
764
- usage: null
765
- }));
766
- i(w);
767
- const C = w;
768
- C.forEach(($) => {
769
- const Y = new AbortController();
770
- f.current.set($.id, Y);
771
- const se = $.messages.slice(0, -1);
772
- Qe(h, $.model, se, {
773
- onDelta: (R) => {
774
- d($.id, (q) => ({
775
- ...q,
776
- streamingContent: q.streamingContent + R,
777
- messages: q.messages.map(
778
- (Z, o) => o === q.messages.length - 1 ? { ...Z, content: q.streamingContent + R } : Z
779
- )
780
- })), k($.id);
781
- },
782
- onDone: (R) => {
783
- d($.id, (q) => ({
784
- ...q,
785
- isStreaming: !1,
786
- usage: R ? {
787
- promptTokens: R.promptTokens,
788
- completionTokens: R.completionTokens,
789
- totalTokens: R.totalTokens
790
- } : null
791
- })), f.current.delete($.id);
792
- },
793
- onError: (R) => {
794
- (R.message.includes("401") || R.message.includes("API key")) && (Ee(), E.current = ""), d($.id, (q) => ({
795
- ...q,
796
- isStreaming: !1,
797
- error: R.message
798
- })), f.current.delete($.id);
799
- },
800
- signal: Y.signal
801
- }).catch(() => {
802
- });
803
- });
804
- const J = setInterval(() => {
805
- C.every(
806
- (Y) => !f.current.has(Y.id)
807
- ) && (clearInterval(J), v(!1));
808
- }, 200);
809
- setTimeout(() => {
810
- clearInterval(J), v(!1);
811
- }, 300 * 1e3);
812
- }, [T, x, s, A, d, k]), P = U(() => {
813
- f.current.forEach((r) => r.abort()), f.current.clear(), i((r) => r.map((h) => ({ ...h, isStreaming: !1 }))), v(!1);
814
- }, []), M = U(() => {
815
- var h;
816
- if (s.length >= ne) return;
817
- const r = (h = l.find((w) => !s.some((C) => C.model === w.modelName))) == null ? void 0 : h.modelName;
818
- r && i((w) => [...w, ie(r)]);
819
- }, [s, l]), L = U(() => {
820
- f.current.forEach((r) => r.abort()), f.current.clear(), i(
821
- (r) => r.map((h) => ({
822
- ...h,
823
- messages: [],
824
- streamingContent: "",
825
- isStreaming: !1,
826
- error: null,
827
- usage: null
828
- }))
829
- ), v(!1);
830
- }, [x, s]), K = U((r) => {
831
- const h = f.current.get(r);
832
- h && h.abort(), f.current.delete(r), i((w) => w.filter((C) => C.id !== r));
833
- }, []), _ = U(
834
- (r, h) => {
835
- d(r, (w) => ({ ...w, model: h }));
836
- },
837
- [d]
838
- ), j = l.map((r) => ({
839
- label: r.modelName,
840
- value: r.modelName
841
- }));
842
- return I ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(X, { tip: "加载模型列表..." }) }) : N ? /* @__PURE__ */ n("div", { className: t.chatContainer, children: [
843
- /* @__PURE__ */ e("div", { className: t.chatHeader, children: /* @__PURE__ */ e("h3", { className: t.chatTitle, children: "模型对话" }) }),
844
- /* @__PURE__ */ n("div", { className: t.akEmpty, children: [
845
- "模型列表加载失败:",
846
- N
847
- ] })
848
- ] }) : /* @__PURE__ */ n("div", { className: t.chatContainer, children: [
849
- /* @__PURE__ */ n("div", { className: t.chatHeader, children: [
850
- /* @__PURE__ */ n("h3", { className: t.chatTitle, children: [
851
- "模型对话",
852
- s.length > 1 && /* @__PURE__ */ n(G, { color: "blue", style: { marginLeft: 12, fontSize: 12 }, children: [
853
- s.length,
854
- " 个模型对比"
855
- ] })
856
- ] }),
857
- /* @__PURE__ */ e(
858
- z,
859
- {
860
- size: "small",
861
- icon: /* @__PURE__ */ e(_e, {}),
862
- onClick: L,
863
- disabled: x || s.every((r) => r.messages.length === 0),
864
- children: "清空重新来"
865
- }
866
- )
867
- ] }),
868
- /* @__PURE__ */ n("div", { className: t.chatPanels, children: [
869
- s.map((r) => /* @__PURE__ */ n("div", { className: t.chatPanel, children: [
870
- /* @__PURE__ */ n("div", { className: t.chatPanelHeader, children: [
871
- /* @__PURE__ */ e(
872
- Re,
873
- {
874
- size: "small",
875
- value: r.model,
876
- onChange: (h) => _(r.id, h),
877
- options: j,
878
- style: { minWidth: 140, flex: 1 },
879
- showSearch: !0,
880
- optionFilterProp: "label"
881
- }
882
- ),
883
- s.length > 1 && /* @__PURE__ */ e(
884
- "span",
885
- {
886
- className: t.chatPanelClose,
887
- onClick: () => K(r.id),
888
- children: /* @__PURE__ */ e(Pe, {})
889
- }
890
- )
891
- ] }),
892
- /* @__PURE__ */ n(
893
- "div",
894
- {
895
- className: t.chatPanelBody,
896
- ref: (h) => {
897
- p.current.set(r.id, h);
898
- },
899
- children: [
900
- r.messages.map((h, w) => /* @__PURE__ */ n(
901
- "div",
902
- {
903
- className: h.role === "user" ? t.chatMsgUser : t.chatMsgAI,
904
- children: [
905
- h.role === "assistant" ? st(h.content).map(
906
- (C, J) => C.type === "think" ? /* @__PURE__ */ n(
907
- "details",
908
- {
909
- className: t.chatThinkBlock,
910
- children: [
911
- /* @__PURE__ */ e("summary", { children: "思考过程" }),
912
- /* @__PURE__ */ e("pre", { children: C.text })
913
- ]
914
- },
915
- J
916
- ) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: C.text }, J)
917
- ) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: h.content }),
918
- r.isStreaming && w === r.messages.length - 1 && h.role === "assistant" && /* @__PURE__ */ e("span", { className: t.chatStreamingCursor })
919
- ]
920
- },
921
- w
922
- )),
923
- r.error && /* @__PURE__ */ e("div", { className: t.chatMsgError, children: r.error }),
924
- r.usage && /* @__PURE__ */ n("div", { className: t.chatUsageBar, children: [
925
- /* @__PURE__ */ n("span", { children: [
926
- "输入: ",
927
- r.usage.promptTokens
928
- ] }),
929
- /* @__PURE__ */ n("span", { children: [
930
- "输出: ",
931
- r.usage.completionTokens
932
- ] })
933
- ] })
934
- ]
935
- }
936
- )
937
- ] }, r.id)),
938
- s.length < ne && /* @__PURE__ */ e(W, { title: "添加面板", children: /* @__PURE__ */ e("div", { className: t.addPanelBtn, onClick: M, children: /* @__PURE__ */ e(fe, {}) }) })
939
- ] }),
940
- /* @__PURE__ */ n("div", { className: t.chatInputBar, children: [
941
- /* @__PURE__ */ e(
942
- Ne.TextArea,
943
- {
944
- className: t.chatInput,
945
- value: T,
946
- onChange: (r) => D(r.target.value),
947
- placeholder: "输入消息,所有面板将同时收到并流式输出...",
948
- autoSize: { minRows: 1, maxRows: 4 },
949
- onPressEnter: (r) => {
950
- r.shiftKey || (r.preventDefault(), m());
951
- },
952
- disabled: x
953
- }
954
- ),
955
- x ? /* @__PURE__ */ e(z, { danger: !0, onClick: P, children: "停止" }) : /* @__PURE__ */ n(z, { type: "primary", onClick: m, disabled: !T.trim(), children: [
956
- /* @__PURE__ */ e(be, {}),
957
- " 发送"
958
- ] })
959
- ] })
960
- ] });
961
- }
962
- function ie(a) {
963
- return {
964
- id: ++rt,
965
- model: a,
966
- messages: [],
967
- streamingContent: "",
968
- isStreaming: !1,
969
- error: null,
970
- usage: null
971
- };
972
- }
973
- function it({ onStartChat: a }) {
974
- const [s, i] = y([]), [l, c] = y(!0), [I, u] = y(null), [N, B] = y(/* @__PURE__ */ new Set()), T = () => {
975
- c(!0), u(null), Se().then((p) => {
976
- i(p), c(!1);
977
- }).catch((p) => {
978
- i([]), u(p instanceof Error ? p.message : "加载失败"), c(!1);
979
- });
980
- };
981
- te(() => {
982
- T();
983
- }, []);
984
- const D = (p) => {
985
- B((k) => {
986
- const d = new Set(k);
987
- return d.has(p) ? d.delete(p) : d.add(p), d;
988
- });
989
- }, x = Array.from(N), v = (p) => {
990
- a([p]);
991
- }, E = () => {
992
- x.length > 0 && a(x);
993
- }, f = (p) => {
994
- if (!p) return "default";
995
- const k = p.toLowerCase();
996
- return k.includes("aliyun") || k.includes("ali") ? "blue" : k.includes("zhipu") || k.includes("glm") ? "purple" : k.includes("moonshot") || k.includes("kimi") ? "cyan" : k.includes("minimax") ? "orange" : "default";
997
- };
998
- return l ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(X, { tip: "加载模型列表..." }) }) : I ? /* @__PURE__ */ n("div", { children: [
999
- /* @__PURE__ */ n("div", { className: t.modelMgmtHeader, children: [
1000
- /* @__PURE__ */ e("h3", { className: t.modelMgmtTitle, children: "模型管理" }),
1001
- /* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "数据库管理的可用模型,可选择单个或多个模型发起对话对比" })
1002
- ] }),
1003
- /* @__PURE__ */ n("div", { className: t.akEmpty, children: [
1004
- "模型列表加载失败:",
1005
- I,
1006
- /* @__PURE__ */ e("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ e(z, { type: "primary", onClick: T, children: "重试" }) })
1007
- ] })
1008
- ] }) : /* @__PURE__ */ n("div", { children: [
1009
- /* @__PURE__ */ n("div", { className: t.modelMgmtHeader, children: [
1010
- /* @__PURE__ */ e("h3", { className: t.modelMgmtTitle, children: "模型管理" }),
1011
- /* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "数据库管理的可用模型,可选择单个或多个模型发起对话对比" })
1012
- ] }),
1013
- s.length === 0 && /* @__PURE__ */ e("div", { className: t.akEmpty, children: "后端暂无启用模型(z_team_model_config 中 enable=1 的行),请先在数据库或网关配置中启用" }),
1014
- /* @__PURE__ */ e("div", { className: t.modelGrid, children: s.map((p) => {
1015
- const k = N.has(p.modelName);
1016
- return /* @__PURE__ */ n(
1017
- "div",
1018
- {
1019
- className: `${t.modelCard} ${k ? t.modelCardSelected : ""}`,
1020
- onClick: () => D(p.modelName),
1021
- children: [
1022
- /* @__PURE__ */ e(
1023
- ze,
1024
- {
1025
- className: t.modelCheckbox,
1026
- checked: k,
1027
- onChange: (d) => {
1028
- d.stopPropagation(), D(p.modelName);
1029
- }
1030
- }
1031
- ),
1032
- /* @__PURE__ */ n("div", { className: t.modelCardHeader, children: [
1033
- /* @__PURE__ */ e("div", { className: t.modelIconWrap, children: /* @__PURE__ */ e(ke, {}) }),
1034
- /* @__PURE__ */ n("div", { className: t.modelCardInfo, children: [
1035
- /* @__PURE__ */ e("h4", { className: t.modelName, children: p.modelName }),
1036
- /* @__PURE__ */ n("div", { className: t.modelTags, children: [
1037
- p.modelProvider && /* @__PURE__ */ e(
1038
- G,
1039
- {
1040
- color: f(p.modelProvider),
1041
- style: { fontSize: 11, margin: 0 },
1042
- children: p.modelProvider
1043
- }
1044
- ),
1045
- /* @__PURE__ */ e(G, { style: { fontSize: 11, margin: 0 }, children: p.apiType })
1046
- ] })
1047
- ] })
1048
- ] }),
1049
- /* @__PURE__ */ e("p", { className: t.modelEndpoint, children: p.endpoint }),
1050
- /* @__PURE__ */ e("div", { className: t.modelCardFooter, children: /* @__PURE__ */ e(
1051
- z,
1052
- {
1053
- type: "link",
1054
- size: "small",
1055
- onClick: (d) => {
1056
- d.stopPropagation(), v(p.modelName);
1057
- },
1058
- children: "发起对话"
1059
- }
1060
- ) })
1061
- ]
1062
- },
1063
- p.modelName
1064
- );
1065
- }) }),
1066
- x.length > 0 && /* @__PURE__ */ n("div", { className: t.modelActionBar, children: [
1067
- /* @__PURE__ */ n("span", { className: t.modelSelectionCount, children: [
1068
- "已选择 ",
1069
- x.length,
1070
- " 个模型"
1071
- ] }),
1072
- /* @__PURE__ */ e(
1073
- z,
1074
- {
1075
- type: "primary",
1076
- onClick: E,
1077
- disabled: x.length === 0,
1078
- children: "批量对比"
1079
- }
1080
- )
1081
- ] })
1082
- ] });
1083
- }
1084
- const ot = "_container_15pgq_5", ct = "_page_15pgq_10", dt = "_kpiGrid_15pgq_16", mt = "_kpiCard_15pgq_22", ht = "_sectionCard_15pgq_29", ut = "_sectionHead_15pgq_36", pt = "_sectionHint_15pgq_42", gt = "_akList_15pgq_47", ft = "_errorState_15pgq_54", kt = "_errorTitle_15pgq_66", yt = "_errorDetail_15pgq_72", O = {
1085
- container: ot,
1086
- page: ct,
1087
- kpiGrid: dt,
1088
- kpiCard: mt,
1089
- sectionCard: ht,
1090
- sectionHead: ut,
1091
- sectionHint: pt,
1092
- akList: gt,
1093
- errorState: ft,
1094
- errorTitle: kt,
1095
- errorDetail: yt
1096
- }, Nt = He(
1097
- () => import("@yuku123/z-agent-component").then((a) => ({ default: a.AgentDashboard }))
1098
- ), vt = ["zifang", "system-default"];
1099
- function ee(a) {
1100
- return a >= 1e6 ? `${(a / 1e6).toFixed(2)}M` : a >= 1e3 ? `${(a / 1e3).toFixed(1)}K` : String(a ?? 0);
1101
- }
1102
- function wt({ daily: a }) {
1103
- const s = Object.entries(a);
1104
- if (s.length === 0) return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
1105
- const i = Math.max(...s.map(([, l]) => l[1] + l[2]), 1);
1106
- return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: s.map(([l, c]) => {
1107
- const I = c[1] + c[2];
1108
- return /* @__PURE__ */ n("div", { className: t.usageBarCol, children: [
1109
- /* @__PURE__ */ e(W, { title: `${l}: ${c[0]}次 / ${I} tokens`, children: /* @__PURE__ */ e(
1110
- "div",
1111
- {
1112
- className: t.usageBar,
1113
- style: { height: `${Math.max(I / i * 100, 2)}%` }
1114
- }
1115
- ) }),
1116
- /* @__PURE__ */ e("span", { className: t.usageBarLabel, children: l })
1117
- ] }, l);
1118
- }) });
1119
- }
1120
- function pe({ models: a }) {
1121
- const s = Object.entries(a);
1122
- if (s.length === 0) return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
1123
- const i = Math.max(...s.map(([, l]) => l[0]), 1);
1124
- return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: s.sort((l, c) => c[1][0] - l[1][0]).map(([l, c]) => /* @__PURE__ */ n("div", { className: t.modelBreakdownRow, children: [
1125
- /* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: l }),
1126
- /* @__PURE__ */ e("div", { className: t.modelBreakdownBar, children: /* @__PURE__ */ e(
1127
- "div",
1128
- {
1129
- className: t.modelBreakdownFill,
1130
- style: { width: `${c[0] / i * 100}%` }
1131
- }
1132
- ) }),
1133
- /* @__PURE__ */ n("span", { className: t.modelBreakdownCount, children: [
1134
- c[0],
1135
- "次 / ",
1136
- ee(c[1]),
1137
- "tokens"
1138
- ] })
1139
- ] }, l)) });
1140
- }
1141
- const Ct = [
1142
- {
1143
- title: "时间",
1144
- dataIndex: "createTime",
1145
- key: "createTime",
1146
- width: 160,
1147
- render: (a) => a ? new Date(a).toLocaleString("zh-CN") : "-"
1148
- },
1149
- { title: "模型", dataIndex: "model", key: "model", width: 150 },
1150
- { title: "协议", dataIndex: "protocol", key: "protocol", width: 90, render: (a) => /* @__PURE__ */ e(G, { children: a }) },
1151
- { title: "输入", dataIndex: "promptTokens", key: "promptTokens", width: 70 },
1152
- { title: "输出", dataIndex: "completionTokens", key: "completionTokens", width: 70 },
1153
- { title: "总Token", dataIndex: "totalTokens", key: "totalTokens", width: 80 },
1154
- { title: "耗时", dataIndex: "latencyMs", key: "latencyMs", width: 70, render: (a) => a ? `${a}ms` : "-" },
1155
- {
1156
- title: "状态",
1157
- dataIndex: "statusCode",
1158
- key: "statusCode",
1159
- width: 60,
1160
- render: (a) => a ? /* @__PURE__ */ e(G, { color: a < 400 ? "green" : "red", children: a }) : "-"
1161
- }
1162
- ];
1163
- function Tt(a) {
1164
- var s;
1165
- return ((s = a == null ? void 0 : a.stats) == null ? void 0 : s.recent) ?? [];
1166
- }
1167
- function St() {
1168
- var v, E, f, p, k, d, A;
1169
- const [a, s] = y(!0), [i, l] = y(null), [c, I] = y([]), [u, N] = y(null), B = U(async () => {
1170
- s(!0), l(null);
1171
- try {
1172
- const m = await Promise.allSettled(
1173
- vt.map((K) => ce(K))
1174
- ), P = [];
1175
- let M = 0;
1176
- for (const K of m)
1177
- K.status === "fulfilled" ? P.push(...K.value) : M += 1;
1178
- if (M === m.length)
1179
- throw new Error("网关不可达:无法获取 AK 列表");
1180
- P.sort((K, _) => (K.id ?? 0) - (_.id ?? 0));
1181
- const L = await Promise.all(
1182
- P.map(async (K) => {
1183
- try {
1184
- return { key: K, stats: await xe(K.id), statsError: null };
1185
- } catch (_) {
1186
- return {
1187
- key: K,
1188
- stats: null,
1189
- statsError: _ instanceof Error ? _.message : "获取用量失败"
1190
- };
1191
- }
1192
- })
1193
- );
1194
- I(L);
1195
- } catch (m) {
1196
- l(m instanceof Error ? m.message : "加载失败");
1197
- } finally {
1198
- s(!1);
1199
- }
1200
- }, []);
1201
- te(() => {
1202
- B();
1203
- }, [B]);
1204
- const T = Ce(() => {
1205
- let m = 0, P = 0, M = 0, L = 0, K = 0;
1206
- const _ = {};
1207
- for (const j of c) {
1208
- const r = j.stats;
1209
- if (r) {
1210
- m += r.totalRequests ?? 0, P += r.totalTokens ?? 0, r.avgLatencyMs != null && r.totalRequests > 0 && (M += r.avgLatencyMs * r.totalRequests, L += r.totalRequests), K += r.errorCount ?? 0;
1211
- for (const [h, w] of Object.entries(r.models ?? {})) {
1212
- const C = _[h] ?? [0, 0];
1213
- C[0] += w[0], C[1] += w[1], _[h] = C;
1214
- }
1215
- }
1216
- }
1217
- return {
1218
- requests: m,
1219
- tokens: P,
1220
- avgLatency: L > 0 ? Math.round(M / L) : 0,
1221
- errors: K,
1222
- models: _
1223
- };
1224
- }, [c]), D = c.reduce((m, P) => m + (P.key.tokenQuota || 0), 0), x = () => a ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(X, { tip: "加载监控数据..." }) }) : i ? /* @__PURE__ */ n("div", { className: O.errorState, children: [
1225
- /* @__PURE__ */ e("div", { className: O.errorTitle, children: "模型监控数据加载失败" }),
1226
- /* @__PURE__ */ e("div", { className: O.errorDetail, children: i }),
1227
- /* @__PURE__ */ e(z, { icon: /* @__PURE__ */ e(ge, {}), onClick: B, type: "primary", children: "重试" })
1228
- ] }) : /* @__PURE__ */ n("div", { className: O.page, children: [
1229
- /* @__PURE__ */ n("div", { className: O.kpiGrid, children: [
1230
- /* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(b, { title: "总请求(近30天)", value: T.requests }) }),
1231
- /* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(b, { title: "总 Tokens", value: ee(T.tokens) }) }),
1232
- /* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(b, { title: "平均延迟", value: T.avgLatency, suffix: "ms" }) }),
1233
- /* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(
1234
- b,
1235
- {
1236
- title: "错误数",
1237
- value: T.errors,
1238
- valueStyle: T.errors > 0 ? { color: "#ff4d4f" } : void 0
1239
- }
1240
- ) })
1241
- ] }),
1242
- /* @__PURE__ */ n("div", { className: O.sectionCard, children: [
1243
- /* @__PURE__ */ n("div", { className: O.sectionHead, children: [
1244
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "AK 用量" }),
1245
- D > 0 && /* @__PURE__ */ n("span", { className: O.sectionHint, children: [
1246
- "合计额度 ",
1247
- ee(D),
1248
- " tokens"
1249
- ] })
1250
- ] }),
1251
- c.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: "网关下暂无 AK" }) : /* @__PURE__ */ e("div", { className: O.akList, children: c.map((m) => {
1252
- const P = m.key.totalTokens ?? 0, M = m.key.tokenQuota || 0, L = M > 0 ? Math.min(P / M * 100, 100) : 0;
1253
- return /* @__PURE__ */ n(
1254
- "div",
1255
- {
1256
- className: t.akCard,
1257
- onClick: () => N(m),
1258
- children: [
1259
- /* @__PURE__ */ n("div", { className: t.akCardRow, children: [
1260
- /* @__PURE__ */ e("span", { className: t.akTitle, children: m.key.description || m.key.userName || `AK #${m.key.id}` }),
1261
- /* @__PURE__ */ e("span", { className: t.akPrefixSmall, children: m.key.akPrefix }),
1262
- /* @__PURE__ */ e(
1263
- "span",
1264
- {
1265
- className: `${t.akStatus} ${m.key.active ? t.akStatusActive : t.akStatusRevoked}`,
1266
- children: m.key.active ? "启用" : "吊销"
1267
- }
1268
- ),
1269
- /* @__PURE__ */ e("span", { className: t.akMetaText, children: m.key.userId === "system-default" ? "系统对话" : m.key.userId })
1270
- ] }),
1271
- /* @__PURE__ */ n("div", { className: t.akCardRow2, children: [
1272
- /* @__PURE__ */ e("div", { className: t.akMiniBar, children: /* @__PURE__ */ e(
1273
- "div",
1274
- {
1275
- className: t.akMiniBarFill,
1276
- style: { width: `${L}%` }
1277
- }
1278
- ) }),
1279
- /* @__PURE__ */ n("span", { className: t.akUsageText, children: [
1280
- ee(P),
1281
- M > 0 ? ` / ${ee(M)}` : "",
1282
- " tokens"
1283
- ] }),
1284
- /* @__PURE__ */ e("span", { className: t.akMetaText, children: m.stats ? `${m.stats.totalRequests} 次请求` : m.statsError ?? "" })
1285
- ] })
1286
- ]
1287
- },
1288
- m.key.id
1289
- );
1290
- }) })
1291
- ] }),
1292
- /* @__PURE__ */ n("div", { className: O.sectionCard, children: [
1293
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "模型用量分布(全 AK 聚合)" }),
1294
- /* @__PURE__ */ e(pe, { models: T.models })
1295
- ] })
1296
- ] });
1297
- return /* @__PURE__ */ n("div", { className: O.container, children: [
1298
- /* @__PURE__ */ n("div", { className: t.modelMgmtHeader, children: [
1299
- /* @__PURE__ */ e("h2", { className: t.modelMgmtTitle, children: "模型监控" }),
1300
- /* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "大模型网关管控视图 — 按 AK / 模型聚合调用量、Tokens 与延迟(近 30 天)" })
1301
- ] }),
1302
- /* @__PURE__ */ e(
1303
- ye,
1304
- {
1305
- defaultActiveKey: "usage",
1306
- items: [
1307
- { key: "usage", label: "模型用量", children: x() },
1308
- {
1309
- key: "sessions",
1310
- label: "会话统计",
1311
- children: /* @__PURE__ */ e(qe, { fallback: /* @__PURE__ */ e(X, { tip: "加载会话统计..." }), children: /* @__PURE__ */ e(Nt, {}) })
1312
- }
1313
- ]
1314
- }
1315
- ),
1316
- /* @__PURE__ */ e(
1317
- ve,
1318
- {
1319
- title: u ? `AK 用量 — ${u.key.description || u.key.akPrefix}` : "",
1320
- width: 860,
1321
- open: !!u,
1322
- onClose: () => N(null),
1323
- destroyOnHidden: !0,
1324
- children: u && /* @__PURE__ */ n("div", { className: t.usageDrawerContent, children: [
1325
- /* @__PURE__ */ n("div", { className: t.usageStatsGrid, children: [
1326
- /* @__PURE__ */ e(b, { title: "总请求", value: ((v = u.stats) == null ? void 0 : v.totalRequests) ?? 0 }),
1327
- /* @__PURE__ */ e(b, { title: "总 Tokens", value: ((E = u.stats) == null ? void 0 : E.totalTokens) ?? 0 }),
1328
- /* @__PURE__ */ e(b, { title: "平均延迟", value: ((f = u.stats) == null ? void 0 : f.avgLatencyMs) ?? 0, suffix: "ms" }),
1329
- /* @__PURE__ */ e(b, { title: "输入 Tokens", value: ((p = u.stats) == null ? void 0 : p.totalPromptTokens) ?? 0 }),
1330
- /* @__PURE__ */ e(b, { title: "输出 Tokens", value: ((k = u.stats) == null ? void 0 : k.totalCompletionTokens) ?? 0 }),
1331
- /* @__PURE__ */ e(
1332
- b,
1333
- {
1334
- title: "错误数",
1335
- value: ((d = u.stats) == null ? void 0 : d.errorCount) ?? 0,
1336
- valueStyle: (((A = u.stats) == null ? void 0 : A.errorCount) ?? 0) > 0 ? { color: "#ff4d4f" } : void 0
1337
- }
1338
- )
1339
- ] }),
1340
- /* @__PURE__ */ n("div", { className: t.usageSection, children: [
1341
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "每日用量(近 30 天)" }),
1342
- u.stats ? /* @__PURE__ */ e(wt, { daily: u.stats.daily ?? {} }) : /* @__PURE__ */ e("span", { className: t.usageEmpty, children: u.statsError ?? "暂无数据" })
1343
- ] }),
1344
- /* @__PURE__ */ n("div", { className: t.usageSection, children: [
1345
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "模型用量分布" }),
1346
- u.stats ? /* @__PURE__ */ e(pe, { models: u.stats.models ?? {} }) : /* @__PURE__ */ e("span", { className: t.usageEmpty, children: u.statsError ?? "暂无数据" })
1347
- ] }),
1348
- /* @__PURE__ */ n("div", { className: t.usageSection, children: [
1349
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "最近调用" }),
1350
- /* @__PURE__ */ e(
1351
- we,
1352
- {
1353
- size: "small",
1354
- columns: Ct,
1355
- dataSource: Tt(u),
1356
- rowKey: "id",
1357
- pagination: { pageSize: 8, hideOnSinglePage: !0 }
1358
- }
1359
- )
1360
- ] })
1361
- ] })
1362
- }
1363
- )
1364
- ] });
1365
- }
1366
- const At = [
1367
- { key: "model-management", label: "模型管理", icon: /* @__PURE__ */ e(Ie, {}) },
1368
- { key: "model-chat", label: "模型对话", icon: /* @__PURE__ */ e(Be, {}) },
1369
- { key: "ak-management", label: "AK 管理", icon: /* @__PURE__ */ e($e, {}) },
1370
- { key: "agent-app", label: "Agent 应用", icon: /* @__PURE__ */ e(ke, {}) },
1371
- { key: "mcp-service", label: "MCP 服务", icon: /* @__PURE__ */ e(Oe, {}) },
1372
- { key: "skill-market", label: "技能市场", icon: /* @__PURE__ */ e(De, {}) },
1373
- { key: "model-monitor", label: "模型监控", icon: /* @__PURE__ */ e(Le, {}) }
1374
- ];
1375
- function bt() {
1376
- const [a, s] = y("model-management"), [i, l] = y([]), c = (N) => {
1377
- l(N), s("model-chat");
1378
- }, I = Ce(() => At, []), u = (N, B, T = !1) => /* @__PURE__ */ e(
1379
- "div",
1380
- {
1381
- style: {
1382
- display: a === N ? T ? "flex" : "block" : "none",
1383
- height: "100%",
1384
- ...T ? { flexDirection: "column" } : {}
1385
- },
1386
- children: B
1387
- }
1388
- );
1389
- return /* @__PURE__ */ n("div", { className: t.container, children: [
1390
- /* @__PURE__ */ e("aside", { className: t.sidebar, children: /* @__PURE__ */ e("nav", { className: t.menuList, children: I.map((N) => /* @__PURE__ */ e(W, { title: N.label, placement: "right", children: /* @__PURE__ */ e(
1391
- "div",
1392
- {
1393
- className: `${t.menuItem} ${a === N.key ? t.menuItemActive : ""}`,
1394
- onClick: () => s(N.key),
1395
- children: /* @__PURE__ */ e("span", { className: t.menuIcon, children: N.icon })
1396
- }
1397
- ) }, N.key)) }) }),
1398
- /* @__PURE__ */ n("main", { className: t.panelArea, children: [
1399
- u("model-management", /* @__PURE__ */ e(it, { onStartChat: c })),
1400
- u("model-chat", /* @__PURE__ */ e(lt, { initialModels: i }), !0),
1401
- u("ak-management", /* @__PURE__ */ e(nt, {})),
1402
- u("agent-app", /* @__PURE__ */ e(Ue, {})),
1403
- u("mcp-service", /* @__PURE__ */ e(je, {})),
1404
- u("skill-market", /* @__PURE__ */ e(Fe, {})),
1405
- u("model-monitor", /* @__PURE__ */ e(St, {}))
1406
- ] })
1407
- ] });
1408
- }
1409
- export {
1410
- bt as default
1411
- };