@yuku123/z-team-component 0.2.139 → 0.2.141

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 (60) hide show
  1. package/dist/{AdminModuleContent-B1IJbLVN.js → AdminModuleContent-FFU5MUjw.js} +10526 -10697
  2. package/dist/{ChangeLogView-BVKf3AZn.js → ChangeLogView-C5v5uT8L.js} +1 -1
  3. package/dist/{ComponentDoc-BIX-e69A.js → ComponentDoc-DnZq0_Rk.js} +1318 -1313
  4. package/dist/{InvitationManagementPage-DRC_8AiO.js → InvitationManagementPage-dEBNe9_s.js} +1 -1
  5. package/dist/{OnboardingPage-B4GQTFCS.js → OnboardingPage-BW8WhBg5.js} +2 -2
  6. package/dist/ScheduledTasks-BaZ0_klE.js +12024 -0
  7. package/dist/SystemShell-I7vWo1XG.js +858 -0
  8. package/dist/{admin-logs-DK00NEUv.js → admin-logs-BDPC3Q_Y.js} +5 -5
  9. package/dist/{api-C_9xZbZr.js → api-BJ5jPWNm.js} +1 -1
  10. package/dist/{api-DBemNteG.js → api-U9U4zzq_.js} +1 -1
  11. package/dist/createWorkspaceWsHandler-B6TdD0Oz.js +11757 -0
  12. package/dist/{index-BGAG77Nt.js → index-BGZV4U3S.js} +1325 -1187
  13. package/dist/{CollabPersonalHost-BY6RqeQJ.js → index-BPEfgkzE.js} +3 -3
  14. package/dist/{index-BgCxUeRF.js → index-BXaJSMd0.js} +9 -9
  15. package/dist/{from-scenario-D8CIJLDn.js → index-Bfw6OE5L.js} +19 -20
  16. package/dist/index-BlDMnzJF.js +18 -0
  17. package/dist/{welcome-BBLRGBWu.js → index-BmlFIrWx.js} +1 -1
  18. package/dist/{build-by-form-CXxXrXvw.js → index-BwhK44Dc.js} +26 -27
  19. package/dist/{TrainingAdminShell-CgnQM4Nb.js → index-CP5raaOW.js} +780 -792
  20. package/dist/{docs-A-g6sqaE.js → index-CPpqideA.js} +1 -1
  21. package/dist/{index-BM6KEb8k.js → index-CToJEufJ.js} +1 -1
  22. package/dist/{common-Bcnlb4nY.js → index-CVgvlDAT.js} +17 -17
  23. package/dist/{admin-ryysUJ9z.js → index-CmzTSdmD.js} +30 -31
  24. package/dist/{Market-C2vkBzDr.js → index-CsNtBWH-.js} +2 -2
  25. package/dist/index-DIv1OJ_2.js +1840 -0
  26. package/dist/{chat-DKwMolQV.js → index-DKUg7Evq.js} +28 -29
  27. package/dist/{index-BlfOXOZM.js → index-DSXVCDf7.js} +9 -9
  28. package/dist/{OpsWorkbench-D8RF2p4X.js → index-Dd5RE_0a.js} +342 -389
  29. package/dist/index-DuZrrpXt.js +1298 -0
  30. package/dist/{from-ticket-D0oQPEf1.js → index-Gn0zdd5m.js} +2 -2
  31. package/dist/index-WWGxF0UX.js +136 -0
  32. package/dist/{change-log-CcmXtywx.js → index-XTNGZnrF.js} +1 -1
  33. package/dist/{KnowledgeGraphTab-BfhDEyvW.js → index-XgaiU13i.js} +1 -1
  34. package/dist/{scenario-DOpFkfNV.js → index-d6RIzlsj.js} +2 -2
  35. package/dist/{index-Bs_WMKyt.js → index-kjli87DO.js} +3895 -3964
  36. package/dist/{phone-BU4g7eHI.js → index-mDjl3m2W.js} +198 -192
  37. package/dist/{index-Dlf6mERD.js → index-nj-cjKsf.js} +1910 -1950
  38. package/dist/{WorkBuddyShell-DCrPpMd5.js → index-skl-gjj4.js} +6 -6
  39. package/dist/index.js +1 -1
  40. package/dist/instance-D_EP8AQm.js +116 -0
  41. package/dist/{menuPermission-C4EVCwjs.js → menuPermission-Bhnols4v.js} +3 -3
  42. package/dist/pages.js +1 -1
  43. package/dist/{send-default-agent-team-message-1L9Jv1eJ.js → send-default-agent-team-message-0RB1pYex.js} +1 -1
  44. package/dist/{training-BqYfINRR.js → training-B1eRX8g1.js} +1 -1
  45. package/dist/{webide-AknolY0B.js → webide-C4ThGZzY.js} +1161 -1317
  46. package/dist/z-team-component.css +1 -1
  47. package/package.json +5 -4
  48. package/dist/CognitionWorkbench-DrDFy5jN.js +0 -139
  49. package/dist/DevWorkbench-BtiPE_V4.js +0 -228
  50. package/dist/ProductWorkspace-PSO7Q9m-.js +0 -1323
  51. package/dist/ScheduledTasks-CoaHVU6e.js +0 -12006
  52. package/dist/SmartWorkbench-BkdfSgqx.js +0 -1867
  53. package/dist/SystemShell-CANwRSyW.js +0 -886
  54. package/dist/SystemWorkbench.module-DpLM0zgA.js +0 -36
  55. package/dist/createWorkspaceWsHandler-6xyLJ14H.js +0 -12902
  56. package/dist/instance-B9ZKD5cL.js +0 -186
  57. package/dist/sso-user-Co71Xi9I.js +0 -43
  58. /package/dist/{download-B_LJRFsK.js → index-B_LJRFsK.js} +0 -0
  59. /package/dist/{chatdemo-C815hPWS.js → index-C815hPWS.js} +0 -0
  60. /package/dist/{portal-QNpTaU--.js → index-QNpTaU--.js} +0 -0
@@ -1,1867 +0,0 @@
1
- import { jsxs as s, jsx as e } from "react/jsx-runtime";
2
- import { CopyOutlined as ie, ReloadOutlined as we, PlusOutlined as Ee, StopOutlined as Ye, DeleteOutlined as Xe, ClearOutlined as Ze, CloseOutlined as et, SendOutlined as tt, RobotOutlined as _e, DownOutlined as at, RightOutlined as nt, CloudServerOutlined as Pe, MessageOutlined as st, BarChartOutlined as ot, KeyOutlined as be, NodeIndexOutlined as rt, ApiOutlined as lt, ToolOutlined as ct, FundOutlined as it } from "@ant-design/icons";
3
- import { useState as C, useEffect as V, useCallback as H, useRef as ge, useMemo as Me, Suspense as dt, lazy as mt } from "react";
4
- import { Table as ce, Tooltip as oe, Tabs as $e, Input as Ce, Button as L, Modal as ye, Drawer as Oe, Spin as se, Statistic as K, message as F, Tag as Z, Select as ut, Checkbox as ht } from "antd";
5
- import { u as Ue } from "./ComponentDoc-BIX-e69A.js";
6
- import { M as pt } from "./index-BM6KEb8k.js";
7
- import { s as z } from "./SystemWorkbench.module-DpLM0zgA.js";
8
- import { AgentAppList as kt, AgentInstanceManager as gt, McpPage as yt, SkillMarket as ft } from "@yuku123/z-agent-component";
9
- const ue = "ft_gateway_default_ak", Le = "system-default", ee = "", Ne = "";
10
- function te(t = {}) {
11
- const n = { Accept: "application/json", ...t };
12
- try {
13
- const o = localStorage.getItem("token");
14
- o && (n.Authorization = `Bearer ${o}`);
15
- } catch {
16
- }
17
- return n;
18
- }
19
- function _t(t) {
20
- return {
21
- modelName: String(t.modelName ?? t.model_name ?? t.service ?? ""),
22
- service: String(t.service ?? t.modelName ?? ""),
23
- endpoint: String(t.endpoint ?? ""),
24
- modelProvider: t.modelProvider ?? t.model_provider ?? null,
25
- apiType: String(t.apiType ?? t.api_type ?? "OpenAPI")
26
- };
27
- }
28
- async function Te() {
29
- let t;
30
- try {
31
- t = await fetch(`${ee}/api/scenario-instances/0/models`, {
32
- credentials: "include",
33
- headers: te({
34
- Accept: "application/json",
35
- "project-env": window.ENV_TYPE ?? "local"
36
- })
37
- });
38
- } catch {
39
- throw new Error("模型列表不可达:模型配置接口请求失败");
40
- }
41
- if (!t.ok)
42
- throw new Error(`模型列表获取失败(HTTP ${t.status})`);
43
- let n;
44
- try {
45
- n = await t.json();
46
- } catch {
47
- throw new Error("模型列表返回格式异常(非 JSON)");
48
- }
49
- const o = n != null && n.success ? n.data : (n == null ? void 0 : n.data) ?? n;
50
- if (!Array.isArray(o))
51
- throw new Error("模型列表返回格式异常(非数组)");
52
- return o.map(_t);
53
- }
54
- async function Ct(t, n, o, i) {
55
- var S, N, g;
56
- const c = await fetch(`${Ne}/v1/chat/completions`, {
57
- method: "POST",
58
- headers: {
59
- "Content-Type": "application/json",
60
- Authorization: `Bearer ${t}`,
61
- Accept: "text/event-stream"
62
- },
63
- body: JSON.stringify({
64
- model: n,
65
- messages: o,
66
- stream: !0
67
- }),
68
- signal: i.signal
69
- });
70
- if (!c.ok || !c.body) {
71
- const m = await c.text().catch(() => "");
72
- if (/<!doctype html/i.test(m.slice(0, 200)))
73
- throw new Error("模型网关未接入(/v1/chat/completions 落到主壳 SPA,无网关响应)");
74
- let k = `HTTP ${c.status}`;
75
- try {
76
- const p = JSON.parse(m);
77
- k = ((S = p == null ? void 0 : p.error) == null ? void 0 : S.message) ?? k;
78
- } catch {
79
- m && (k = m);
80
- }
81
- throw new Error(k);
82
- }
83
- const w = c.body.getReader(), B = new TextDecoder();
84
- let A = "", f;
85
- try {
86
- for (; ; ) {
87
- const { done: m, value: k } = await w.read();
88
- if (m) break;
89
- A += B.decode(k, { stream: !0 });
90
- const p = A.split(`
91
-
92
- `);
93
- A = p.pop() ?? "";
94
- for (const d of p) {
95
- let _ = "";
96
- for (const h of d.split(`
97
- `))
98
- h.startsWith("data:") && (_ += h.slice(5).trim());
99
- if (!_ || _ === "[DONE]") {
100
- if (_ === "[DONE]") {
101
- i.onDone(f);
102
- return;
103
- }
104
- continue;
105
- }
106
- try {
107
- const h = JSON.parse(_), P = h == null ? void 0 : h.choices;
108
- if (h != null && h.usage) {
109
- const M = {
110
- promptTokens: h.usage.prompt_tokens ?? 0,
111
- completionTokens: h.usage.completion_tokens ?? 0,
112
- totalTokens: h.usage.total_tokens ?? 0
113
- };
114
- (!f || M.totalTokens > 0) && (f = M);
115
- }
116
- if (Array.isArray(P) && P.length > 0) {
117
- const M = (N = P[0]) == null ? void 0 : N.delta;
118
- M != null && M.content && i.onDelta(M.content);
119
- continue;
120
- }
121
- i.onDone(f);
122
- return;
123
- } catch {
124
- }
125
- }
126
- }
127
- i.onDone(f);
128
- } catch (m) {
129
- if ((g = i.signal) != null && g.aborted) return;
130
- throw i.onError(m instanceof Error ? m : new Error(String(m))), m;
131
- }
132
- }
133
- async function re(t, n) {
134
- const o = await t.text();
135
- if (!t.ok)
136
- throw new Error(`${n}失败 HTTP ${t.status}${o ? `: ${o.slice(0, 120)}` : ""}`);
137
- if (/<!doctype html/i.test(o.slice(0, 200)))
138
- throw new Error("AK 接口落到主壳 SPA(无后端响应)");
139
- try {
140
- return JSON.parse(o);
141
- } catch {
142
- throw new Error(`${n}返回非 JSON:${o.slice(0, 120)}`);
143
- }
144
- }
145
- function Nt(t) {
146
- const n = t.status === 1;
147
- return {
148
- id: Number(t.id),
149
- akPrefix: t.access_key ?? "",
150
- userId: t.owner_user_id ?? "",
151
- userName: t.owner_user_name ?? "",
152
- description: t.description || t.ak_name || "",
153
- status: n ? "active" : "disabled",
154
- active: n,
155
- isDeleted: t.is_deleted ?? 0,
156
- totalRequests: 0,
157
- totalTokens: Number(t.total_tokens ?? 0),
158
- tokenQuota: 0,
159
- rateLimitRpm: 0,
160
- defaultModel: null,
161
- lastUsedAt: t.last_used_time ?? null,
162
- createTime: (t.created_time ?? "").replace("T", " ").slice(0, 19),
163
- updateTime: (t.updated_time ?? "").replace("T", " ").slice(0, 19),
164
- secret: t.secret_key
165
- };
166
- }
167
- async function ze(t, n, o) {
168
- const i = await fetch(`${ee}/api/ak/create`, {
169
- method: "POST",
170
- headers: te({ Accept: "application/json", "Content-Type": "application/json" }),
171
- credentials: "include",
172
- body: JSON.stringify({
173
- akName: o || `AK-${n || t}`,
174
- description: o,
175
- akType: "PERSONAL",
176
- ownerUserId: t,
177
- ownerUserName: n
178
- })
179
- }), c = await re(i, "创建 AK"), w = (c == null ? void 0 : c.data) ?? {}, B = w.accessKey ?? "", A = w.secretKey ?? "";
180
- return B && A && Ae(B, A), { apiKey: A, akPrefix: B, message: "AK 已创建,secretKey 仅创建时可见" };
181
- }
182
- async function he(t) {
183
- const n = await fetch(
184
- `${ee}/api/ak/list`,
185
- { headers: te({ Accept: "application/json" }), credentials: "include" }
186
- ), o = await re(n, "获取 AK 列表"), i = Array.isArray(o == null ? void 0 : o.data) ? o.data : [];
187
- return (t ? i.filter((w) => (w.owner_user_id == null || w.owner_user_id === "" ? Le : String(w.owner_user_id)) === String(t)) : i).filter((w) => (w.is_deleted ?? 0) === 0).map(Nt);
188
- }
189
- async function vt(t) {
190
- const n = await fetch(`${ee}/api/ak/delete?id=${encodeURIComponent(String(t))}`, {
191
- method: "POST",
192
- headers: te({ Accept: "application/json" }),
193
- credentials: "include"
194
- });
195
- await re(n, "吊销 AK");
196
- }
197
- async function wt(t, n) {
198
- const o = await fetch(
199
- `${ee}/api/ak/toggle?id=${encodeURIComponent(String(t))}&status=${n ? 1 : 0}`,
200
- {
201
- method: "POST",
202
- headers: te({ Accept: "application/json" }),
203
- credentials: "include"
204
- }
205
- );
206
- await re(o, n ? "启用 AK" : "停用 AK");
207
- }
208
- async function Re(t) {
209
- var m, k;
210
- const n = await fetch(
211
- `${ee}/api/admin/llm-call-monitor/stats?hours=168`,
212
- { headers: te({ Accept: "application/json" }), credentials: "include" }
213
- ), o = await re(n, "获取调用统计"), c = ((o == null ? void 0 : o.data) ?? {}).summary ?? {};
214
- let w = [];
215
- try {
216
- const p = await fetch(
217
- `${ee}/api/admin/llm-call-monitor/recent?page=1&size=20`,
218
- { headers: te({ Accept: "application/json" }), credentials: "include" }
219
- ), d = await re(p, "获取调用明细");
220
- w = (Array.isArray((m = d == null ? void 0 : d.data) == null ? void 0 : m.records) ? d.data.records : []).map((h, P) => {
221
- const M = Number(h.promptTokens ?? 0), q = Number(h.completionTokens ?? 0);
222
- return {
223
- id: Number(h.id ?? P),
224
- apiKeyId: t,
225
- protocol: "chat/completions",
226
- model: String(h.model ?? ""),
227
- stream: Number(h.stream ?? 0),
228
- promptTokens: M,
229
- completionTokens: q,
230
- totalTokens: Number(h.totalTokens ?? M + q),
231
- latencyMs: Number(h.durationMs ?? 0),
232
- statusCode: h.success === !1 || h.success === 0 ? 500 : 200,
233
- errorMsg: h.errorType ?? null,
234
- createTime: String(h.createTime ?? "").replace("T", " ").slice(0, 19)
235
- };
236
- });
237
- } catch {
238
- }
239
- const B = {}, A = {};
240
- for (const p of w) {
241
- const d = B[k = p.model] || (B[k] = [0, 0, 0]);
242
- d[0] += 1, d[1] += p.promptTokens, d[2] += p.completionTokens;
243
- const _ = (p.createTime || "").slice(0, 10);
244
- if (_) {
245
- const h = A[_] || (A[_] = [0, 0, 0]);
246
- h[0] += 1, h[1] += p.promptTokens, h[2] += p.completionTokens;
247
- }
248
- }
249
- const f = Number(c.totalTokens ?? 0), S = w.reduce((p, d) => p + d.totalTokens, 0), N = w.reduce((p, d) => p + d.promptTokens, 0), g = w.reduce((p, d) => p + d.completionTokens, 0);
250
- return {
251
- totalRequests: Number(c.totalCount ?? 0),
252
- // 汇总口径优先用后端整窗合计(后端 selectStats 才有 token 合计),
253
- // 明细只有最近一页 ⇒ 只在汇总缺失时用明细兜底。
254
- totalPromptTokens: Number(c.totalPromptTokens ?? 0) || N,
255
- totalCompletionTokens: Number(c.totalCompletionTokens ?? 0) || g,
256
- totalTokens: f || S,
257
- avgLatencyMs: Number(c.avgDurationMs ?? 0),
258
- errorCount: Number(c.failCount ?? 0),
259
- daily: A,
260
- models: B,
261
- recent: w
262
- };
263
- }
264
- function Tt() {
265
- return typeof window < "u" ? `${window.location.origin}${Ne}` : Ne;
266
- }
267
- async function Se(t) {
268
- const n = await fetch(`${ee}${t}`, {
269
- headers: te({ Accept: "application/json" }),
270
- credentials: "include"
271
- });
272
- if (!(n.headers.get("content-type") || "").includes("json"))
273
- throw new Error("网关控制面未启用(该路径返回的是前端页面,不是接口)");
274
- if (!n.ok)
275
- throw new Error(`网关控制面请求失败(HTTP ${n.status})`);
276
- return n.json();
277
- }
278
- async function De() {
279
- return Se("/z-llm/admin/overview");
280
- }
281
- async function St() {
282
- return Se("/z-llm/admin/health");
283
- }
284
- async function Ge() {
285
- const t = await Se("/z-llm/admin/usage");
286
- return (Array.isArray(t == null ? void 0 : t.byTenant) ? t.byTenant : []).map((o) => ({
287
- tenantCode: String(o.tenantCode ?? o.keyId ?? ""),
288
- requests: Number(o.requests ?? o.count ?? 0),
289
- promptTokens: Number(o.promptTokens ?? 0),
290
- completionTokens: Number(o.completionTokens ?? 0),
291
- cost: Number(o.cost ?? 0)
292
- }));
293
- }
294
- const ve = "ft_gateway_ak_cache";
295
- function Ae(t, n) {
296
- try {
297
- const o = JSON.parse(localStorage.getItem(ve) || "{}");
298
- o[t] = n, localStorage.setItem(ve, JSON.stringify(o));
299
- } catch {
300
- }
301
- }
302
- function At(t) {
303
- try {
304
- return JSON.parse(localStorage.getItem(ve) || "{}")[t] || null;
305
- } catch {
306
- return null;
307
- }
308
- }
309
- async function xt() {
310
- try {
311
- const i = localStorage.getItem(ue);
312
- if (i) return i;
313
- } catch {
314
- }
315
- const n = (await he("").catch(() => [])).find((i) => i.active && i.secret);
316
- if (n != null && n.secret) {
317
- try {
318
- localStorage.setItem(ue, n.secret);
319
- } catch {
320
- }
321
- return n.akPrefix && Ae(n.akPrefix, n.secret), n.secret;
322
- }
323
- const o = await ze(
324
- "system-default",
325
- "系统默认",
326
- "智能工作台默认AK(自动创建)"
327
- );
328
- if (!o.apiKey)
329
- throw new Error("AK 创建成功但未返回 secretKey");
330
- try {
331
- localStorage.setItem(ue, o.apiKey);
332
- } catch {
333
- }
334
- return o.apiKey;
335
- }
336
- function He() {
337
- try {
338
- localStorage.removeItem(ue);
339
- } catch {
340
- }
341
- }
342
- const Bt = "_container_1ctyd_7", It = "_panelArea_1ctyd_16", Pt = "_modelGrid_1ctyd_45", bt = "_modelCard_1ctyd_51", Kt = "_modelCardSelected_1ctyd_80", Et = "_modelCardHeader_1ctyd_85", Mt = "_modelIconWrap_1ctyd_92", $t = "_modelCardInfo_1ctyd_105", Ot = "_modelName_1ctyd_110", Ut = "_modelTags_1ctyd_119", Lt = "_modelEndpoint_1ctyd_135", zt = "_modelCardFooter_1ctyd_144", Rt = "_modelCheckbox_1ctyd_152", Dt = "_modelActionBar_1ctyd_159", Gt = "_modelSelectionCount_1ctyd_173", Ht = "_chatContainer_1ctyd_182", jt = "_chatHeader_1ctyd_189", Ft = "_chatPanels_1ctyd_204", qt = "_chatPanel_1ctyd_204", Jt = "_chatPanelHeader_1ctyd_231", Wt = "_chatPanelClose_1ctyd_241", Qt = "_chatPanelBody_1ctyd_253", Vt = "_chatMsgUser_1ctyd_262", Yt = "_chatMsgAI_1ctyd_274", Xt = "_chatMsgError_1ctyd_287", Zt = "_chatStreamingCursor_1ctyd_297", ea = "_chatUsageBar_1ctyd_316", ta = "_chatThinkBlock_1ctyd_326", aa = "_chatInputBar_1ctyd_375", na = "_chatInput_1ctyd_375", sa = "_addPanelBtn_1ctyd_388", oa = "_akContainer_1ctyd_417", ra = "_akIntegrationPanel_1ctyd_423", la = "_akIntegrationTitle_1ctyd_430", ca = "_akIntegrationGrid_1ctyd_437", ia = "_akCodeBlock_1ctyd_443", da = "_akCodeLabel_1ctyd_455", ma = "_akCard_1ctyd_462", ua = "_akCardRow_1ctyd_480", ha = "_akTitle_1ctyd_487", pa = "_akPrefixSmall_1ctyd_497", ka = "_akStatus_1ctyd_503", ga = "_akStatusActive_1ctyd_509", ya = "_akStatusRevoked_1ctyd_515", fa = "_akCardActions_1ctyd_521", _a = "_akCardRow2_1ctyd_528", Ca = "_akMiniBar_1ctyd_534", Na = "_akMiniBarFill_1ctyd_543", va = "_akUsageText_1ctyd_550", wa = "_akMetaText_1ctyd_557", Ta = "_akEmpty_1ctyd_563", Sa = "_akBaseUrlRow_1ctyd_571", Aa = "_akBaseUrlItem_1ctyd_577", xa = "_akBaseUrlLabel_1ctyd_587", Ba = "_akBaseUrlValue_1ctyd_593", Ia = "_akCopyIcon_1ctyd_603", Pa = "_usageDrawerContent_1ctyd_617", ba = "_usageStatsGrid_1ctyd_623", Ka = "_usageSection_1ctyd_629", Ea = "_usageSectionTitle_1ctyd_633", Ma = "_usageBarChart_1ctyd_643", $a = "_usageBarCol_1ctyd_652", Oa = "_usageBar_1ctyd_643", Ua = "_usageBarLabel_1ctyd_675", La = "_modelBreakdown_1ctyd_683", za = "_modelBreakdownRow_1ctyd_689", Ra = "_modelBreakdownName_1ctyd_695", Da = "_modelBreakdownBar_1ctyd_705", Ga = "_modelBreakdownFill_1ctyd_713", Ha = "_modelBreakdownCount_1ctyd_720", ja = "_usageEmpty_1ctyd_727", a = {
343
- container: Bt,
344
- panelArea: It,
345
- modelGrid: Pt,
346
- modelCard: bt,
347
- modelCardSelected: Kt,
348
- modelCardHeader: Et,
349
- modelIconWrap: Mt,
350
- modelCardInfo: $t,
351
- modelName: Ot,
352
- modelTags: Ut,
353
- modelEndpoint: Lt,
354
- modelCardFooter: zt,
355
- modelCheckbox: Rt,
356
- modelActionBar: Dt,
357
- modelSelectionCount: Gt,
358
- chatContainer: Ht,
359
- chatHeader: jt,
360
- chatPanels: Ft,
361
- chatPanel: qt,
362
- chatPanelHeader: Jt,
363
- chatPanelClose: Wt,
364
- chatPanelBody: Qt,
365
- chatMsgUser: Vt,
366
- chatMsgAI: Yt,
367
- chatMsgError: Xt,
368
- chatStreamingCursor: Zt,
369
- chatUsageBar: ea,
370
- chatThinkBlock: ta,
371
- chatInputBar: aa,
372
- chatInput: na,
373
- addPanelBtn: sa,
374
- akContainer: oa,
375
- akIntegrationPanel: ra,
376
- akIntegrationTitle: la,
377
- akIntegrationGrid: ca,
378
- akCodeBlock: ia,
379
- akCodeLabel: da,
380
- akCard: ma,
381
- akCardRow: ua,
382
- akTitle: ha,
383
- akPrefixSmall: pa,
384
- akStatus: ka,
385
- akStatusActive: ga,
386
- akStatusRevoked: ya,
387
- akCardActions: fa,
388
- akCardRow2: _a,
389
- akMiniBar: Ca,
390
- akMiniBarFill: Na,
391
- akUsageText: va,
392
- akMetaText: wa,
393
- akEmpty: Ta,
394
- akBaseUrlRow: Sa,
395
- akBaseUrlItem: Aa,
396
- akBaseUrlLabel: xa,
397
- akBaseUrlValue: Ba,
398
- akCopyIcon: Ia,
399
- usageDrawerContent: Pa,
400
- usageStatsGrid: ba,
401
- usageSection: Ka,
402
- usageSectionTitle: Ea,
403
- usageBarChart: Ma,
404
- usageBarCol: $a,
405
- usageBar: Oa,
406
- usageBarLabel: Ua,
407
- modelBreakdown: La,
408
- modelBreakdownRow: za,
409
- modelBreakdownName: Ra,
410
- modelBreakdownBar: Da,
411
- modelBreakdownFill: Ga,
412
- modelBreakdownCount: Ha,
413
- usageEmpty: ja
414
- };
415
- function de(t) {
416
- return t >= 1e6 ? `${(t / 1e6).toFixed(1)}M` : t >= 1e3 ? `${(t / 1e3).toFixed(1)}K` : `${t}`;
417
- }
418
- function Fa(t, n) {
419
- return `# OpenAI 兼容
420
- curl -X POST ${t}/v1/chat/completions \\
421
- -H "Content-Type: application/json" \\
422
- -H "Authorization: Bearer ft-xxx" \\
423
- -d '{
424
- "model": "${n}",
425
- "messages": [{"role":"user","content":"你好"}],
426
- "stream": true
427
- }'`;
428
- }
429
- function qa(t, n) {
430
- return `# Anthropic 兼容
431
- curl -X POST ${t}/v1/messages \\
432
- -H "Content-Type: application/json" \\
433
- -H "x-api-key: ft-xxx" \\
434
- -d '{
435
- "model": "${n}",
436
- "messages": [{"role":"user","content":"你好"}]
437
- }'`;
438
- }
439
- function Ja() {
440
- const [t, n] = C("personal"), [o, i] = C([]), [c, w] = C([]), [B, A] = C(!0), [f, S] = C(!1), [N, g] = C(!1), [m, k] = C(""), [p, d] = C({ open: !1 }), [_, h] = C(null), [P, M] = C(null), [q, ae] = C(!1), [Y, u] = C(null), [$, R] = C([]), [r, y] = C(""), x = Ue((l) => l.currentUser), b = String((x == null ? void 0 : x.id) ?? ""), O = (x == null ? void 0 : x.username) ?? "", [E, J] = C(""), X = Tt(), [D, j] = C("<model-name>");
441
- V(() => {
442
- let l = !1;
443
- return Te().then((v) => {
444
- !l && v.length > 0 && j(v[0].modelName);
445
- }).catch(() => {
446
- }), () => {
447
- l = !0;
448
- };
449
- }, []), V(() => {
450
- let l = !1;
451
- return Promise.all([De(), Ge()]).then(([v, Q]) => {
452
- l || (u(v), R(Q), y(""));
453
- }).catch((v) => {
454
- l || (u(null), R([]), y(v instanceof Error ? v.message : "网关台账不可用"));
455
- }), () => {
456
- l = !0;
457
- };
458
- }, []);
459
- const W = H(async () => {
460
- A(!0);
461
- try {
462
- const l = b ? await he(b).catch(() => []) : [], [v] = await Promise.all([
463
- he("system-default").catch(() => [])
464
- ]);
465
- i(v), w(l);
466
- } finally {
467
- A(!1);
468
- }
469
- }, [b]);
470
- V(() => {
471
- W();
472
- }, [W]);
473
- const pe = () => {
474
- k(""), g(!0);
475
- }, xe = async () => {
476
- if (!m.trim()) {
477
- F.warning("请输入 AK 名称");
478
- return;
479
- }
480
- if (!b) {
481
- F.warning("登录态不可用,无法生成 AK");
482
- return;
483
- }
484
- S(!0);
485
- try {
486
- const l = await ze(b, O, m.trim());
487
- Ae(l.akPrefix, l.apiKey), g(!1), d({
488
- open: !0,
489
- apiKey: l.apiKey,
490
- akPrefix: l.akPrefix
491
- }), W();
492
- } catch (l) {
493
- F.error(l instanceof Error ? l.message : "创建 AK 失败");
494
- } finally {
495
- S(!1);
496
- }
497
- }, je = (l) => {
498
- ye.confirm({
499
- title: "确认吊销此 AK?",
500
- content: "吊销后此 AK 将立即失效,无法恢复。",
501
- okText: "确认吊销",
502
- okType: "danger",
503
- cancelText: "取消",
504
- onOk: async () => {
505
- try {
506
- await vt(l), F.success("AK 已吊销"), W(), He();
507
- } catch (v) {
508
- F.error(v instanceof Error ? v.message : "吊销失败");
509
- }
510
- }
511
- });
512
- }, Be = async (l) => {
513
- try {
514
- await wt(l.id, !l.active), F.success(l.active ? "AK 已停用" : "AK 已启用"), W();
515
- } catch (v) {
516
- F.error(v instanceof Error ? v.message : "操作失败");
517
- }
518
- }, le = (l) => {
519
- navigator.clipboard.writeText(l).then(() => F.success("已复制到剪贴板")).catch(() => F.warning("复制失败,请手动复制"));
520
- }, Fe = (l) => {
521
- const v = At(l.akPrefix);
522
- v ? le(v) : (le(l.akPrefix), F.info("完整 AK 未在本地缓存(可能在本设备外创建),已复制前缀"));
523
- }, qe = async (l) => {
524
- h(l), ae(!0), M(null);
525
- try {
526
- const v = await Re(l.id);
527
- M(v);
528
- } catch (v) {
529
- F.error(v instanceof Error ? v.message : "获取用量失败");
530
- } finally {
531
- ae(!1);
532
- }
533
- }, Je = () => {
534
- h(null), M(null);
535
- }, We = (l) => {
536
- const v = Object.entries(l);
537
- if (v.length === 0)
538
- return /* @__PURE__ */ e("span", { className: a.usageEmpty, children: "暂无数据" });
539
- const Q = Math.max(...v.map(([, U]) => U[1] + U[2]), 1);
540
- return /* @__PURE__ */ e("div", { className: a.usageBarChart, children: v.map(([U, G]) => {
541
- const T = G[1] + G[2], ke = T / Q * 100;
542
- return /* @__PURE__ */ s("div", { className: a.usageBarCol, children: [
543
- /* @__PURE__ */ e(oe, { title: `${U}: ${G[0]}次 / ${T} tokens`, children: /* @__PURE__ */ e(
544
- "div",
545
- {
546
- className: a.usageBar,
547
- style: { height: `${Math.max(ke, 2)}%` }
548
- }
549
- ) }),
550
- /* @__PURE__ */ e("span", { className: a.usageBarLabel, children: U })
551
- ] }, U);
552
- }) });
553
- }, Qe = (l) => {
554
- const v = Object.entries(l);
555
- if (v.length === 0)
556
- return /* @__PURE__ */ e("span", { className: a.usageEmpty, children: "暂无数据" });
557
- const Q = Math.max(...v.map(([, U]) => U[0]), 1);
558
- return /* @__PURE__ */ e("div", { className: a.modelBreakdown, children: v.sort((U, G) => G[1][0] - U[1][0]).map(([U, G]) => /* @__PURE__ */ s("div", { className: a.modelBreakdownRow, children: [
559
- /* @__PURE__ */ e("span", { className: a.modelBreakdownName, children: U }),
560
- /* @__PURE__ */ e("div", { className: a.modelBreakdownBar, children: /* @__PURE__ */ e(
561
- "div",
562
- {
563
- className: a.modelBreakdownFill,
564
- style: { width: `${G[0] / Q * 100}%` }
565
- }
566
- ) }),
567
- /* @__PURE__ */ s("span", { className: a.modelBreakdownCount, children: [
568
- G[0],
569
- "次 / ",
570
- G[1] + (G[2] || 0),
571
- "tokens"
572
- ] })
573
- ] }, U)) });
574
- }, Ve = [
575
- {
576
- title: "时间",
577
- dataIndex: "createTime",
578
- key: "createTime",
579
- width: 160,
580
- render: (l) => l ? new Date(l).toLocaleString("zh-CN") : "-"
581
- },
582
- { title: "模型", dataIndex: "model", key: "model", width: 140 },
583
- {
584
- title: "协议",
585
- dataIndex: "protocol",
586
- key: "protocol",
587
- width: 90,
588
- render: (l) => /* @__PURE__ */ e(Z, { children: l })
589
- },
590
- {
591
- title: "输入",
592
- dataIndex: "promptTokens",
593
- key: "promptTokens",
594
- width: 70
595
- },
596
- {
597
- title: "输出",
598
- dataIndex: "completionTokens",
599
- key: "completionTokens",
600
- width: 70
601
- },
602
- {
603
- title: "总Token",
604
- dataIndex: "totalTokens",
605
- key: "totalTokens",
606
- width: 80
607
- },
608
- {
609
- title: "耗时",
610
- dataIndex: "latencyMs",
611
- key: "latencyMs",
612
- width: 70,
613
- render: (l) => l ? `${l}ms` : "-"
614
- },
615
- {
616
- title: "状态",
617
- dataIndex: "statusCode",
618
- key: "statusCode",
619
- width: 60,
620
- render: (l) => l ? /* @__PURE__ */ e(Z, { color: l < 400 ? "green" : "red", children: l }) : "-"
621
- }
622
- ], Ie = (l, v) => {
623
- const Q = Array.isArray(l) ? l : [], U = E.trim().toLowerCase(), G = U ? Q.filter(
624
- (T) => `${T.description || ""} ${T.akPrefix || ""} ${T.defaultModel || ""}`.toLowerCase().includes(U)
625
- ) : Q;
626
- return B ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 40 }, children: /* @__PURE__ */ e(se, { tip: "加载中..." }) }) : Q.length === 0 ? /* @__PURE__ */ e("div", { className: a.akEmpty, children: v ? "暂无应用 AK" : "暂无个人 AK,点击上方按钮生成" }) : G.length === 0 ? /* @__PURE__ */ e("div", { className: a.akEmpty, children: "无匹配 AK" }) : /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: G.map((T) => /* @__PURE__ */ s(
627
- "div",
628
- {
629
- className: a.akCard,
630
- onClick: () => qe(T),
631
- children: [
632
- /* @__PURE__ */ s("div", { className: a.akCardRow, children: [
633
- /* @__PURE__ */ e("span", { className: a.akTitle, children: T.description || T.akPrefix.replace("...", "**") }),
634
- /* @__PURE__ */ e("code", { className: a.akPrefixSmall, children: T.akPrefix.replace("...", "**") }),
635
- /* @__PURE__ */ e(
636
- "span",
637
- {
638
- className: `${a.akStatus} ${T.active ? a.akStatusActive : a.akStatusRevoked}`,
639
- children: T.active ? "活跃" : "已吊销"
640
- }
641
- ),
642
- T.defaultModel && /* @__PURE__ */ s(Z, { style: { fontSize: 11 }, children: [
643
- "默认: ",
644
- T.defaultModel
645
- ] }),
646
- /* @__PURE__ */ s(
647
- "div",
648
- {
649
- className: a.akCardActions,
650
- onClick: (ke) => ke.stopPropagation(),
651
- children: [
652
- /* @__PURE__ */ e(oe, { title: "复制完整 AK", children: /* @__PURE__ */ e(
653
- L,
654
- {
655
- size: "small",
656
- icon: /* @__PURE__ */ e(ie, {}),
657
- onClick: () => Fe(T),
658
- children: "复制"
659
- }
660
- ) }),
661
- !v && T.active && /* @__PURE__ */ e(
662
- L,
663
- {
664
- size: "small",
665
- icon: /* @__PURE__ */ e(Ye, {}),
666
- onClick: () => void Be(T),
667
- children: "停用"
668
- }
669
- ),
670
- !v && !T.active && /* @__PURE__ */ e(
671
- L,
672
- {
673
- size: "small",
674
- type: "primary",
675
- ghost: !0,
676
- onClick: () => void Be(T),
677
- children: "启用"
678
- }
679
- ),
680
- !v && T.active && /* @__PURE__ */ e(
681
- L,
682
- {
683
- size: "small",
684
- danger: !0,
685
- icon: /* @__PURE__ */ e(Xe, {}),
686
- onClick: () => je(T.id),
687
- children: "吊销"
688
- }
689
- )
690
- ]
691
- }
692
- )
693
- ] }),
694
- /* @__PURE__ */ s("div", { className: a.akCardRow2, children: [
695
- T.tokenQuota > 0 && /* @__PURE__ */ e("div", { className: a.akMiniBar, children: /* @__PURE__ */ e(
696
- "div",
697
- {
698
- className: a.akMiniBarFill,
699
- style: {
700
- width: `${Math.min(
701
- (T.totalTokens || 0) / T.tokenQuota * 100,
702
- 100
703
- )}%`
704
- }
705
- }
706
- ) }),
707
- /* @__PURE__ */ s("span", { className: a.akUsageText, children: [
708
- de(T.totalTokens || 0),
709
- T.tokenQuota > 0 ? ` / ${de(T.tokenQuota)}` : " tokens"
710
- ] }),
711
- /* @__PURE__ */ e("span", { className: a.akMetaText, children: T.lastUsedAt ? `最近使用 ${T.lastUsedAt}` : "尚未使用" }),
712
- /* @__PURE__ */ e("span", { className: a.akMetaText, children: new Date(T.createTime).toLocaleDateString("zh-CN") })
713
- ] })
714
- ]
715
- },
716
- T.id
717
- )) });
718
- };
719
- return /* @__PURE__ */ s("div", { className: a.akContainer, children: [
720
- (Y || $.length > 0 || r) && /* @__PURE__ */ s("div", { className: a.akIntegrationPanel, children: [
721
- /* @__PURE__ */ s("h4", { className: a.akIntegrationTitle, children: [
722
- "网关台账",
723
- Y && /* @__PURE__ */ e("span", { style: { fontWeight: 400, fontSize: 12, marginLeft: 8, opacity: 0.7 }, children: Y.vendors.map((l) => `${l.vendor} ${l.credentials} 凭据/${l.models} 模型`).join(" · ") })
724
- ] }),
725
- r ? /* @__PURE__ */ e("div", { style: { fontSize: 12, opacity: 0.65 }, children: r }) : $.length === 0 ? /* @__PURE__ */ e("div", { style: { fontSize: 12, opacity: 0.65 }, children: "暂无租户用量(仅绑定 tenantCode 并发生过调用的 AK 才会入账)" }) : /* @__PURE__ */ e(
726
- ce,
727
- {
728
- size: "small",
729
- rowKey: "tenantCode",
730
- pagination: !1,
731
- dataSource: $,
732
- columns: [
733
- { title: "租户", dataIndex: "tenantCode", key: "tenantCode" },
734
- { title: "请求数", dataIndex: "requests", key: "requests", width: 90 },
735
- {
736
- title: "Prompt",
737
- dataIndex: "promptTokens",
738
- key: "promptTokens",
739
- width: 100,
740
- render: (l) => de(l)
741
- },
742
- {
743
- title: "Completion",
744
- dataIndex: "completionTokens",
745
- key: "completionTokens",
746
- width: 110,
747
- render: (l) => de(l)
748
- },
749
- {
750
- title: "成本",
751
- dataIndex: "cost",
752
- key: "cost",
753
- width: 90,
754
- render: (l) => l ? l.toFixed(4) : "-"
755
- }
756
- ]
757
- }
758
- )
759
- ] }),
760
- /* @__PURE__ */ s("div", { className: a.akIntegrationPanel, children: [
761
- /* @__PURE__ */ e("h4", { className: a.akIntegrationTitle, children: "协议接入地址" }),
762
- /* @__PURE__ */ s("div", { className: a.akBaseUrlRow, children: [
763
- /* @__PURE__ */ s("div", { className: a.akBaseUrlItem, children: [
764
- /* @__PURE__ */ e("span", { className: a.akBaseUrlLabel, children: "OpenAI 兼容" }),
765
- /* @__PURE__ */ e("code", { className: a.akBaseUrlValue, children: X }),
766
- /* @__PURE__ */ e(oe, { title: "复制 Base URL", children: /* @__PURE__ */ e(
767
- ie,
768
- {
769
- className: a.akCopyIcon,
770
- onClick: () => le(X)
771
- }
772
- ) })
773
- ] }),
774
- /* @__PURE__ */ s("div", { className: a.akBaseUrlItem, children: [
775
- /* @__PURE__ */ e("span", { className: a.akBaseUrlLabel, children: "Anthropic 兼容" }),
776
- /* @__PURE__ */ e("code", { className: a.akBaseUrlValue, children: X }),
777
- /* @__PURE__ */ e(oe, { title: "复制 Base URL", children: /* @__PURE__ */ e(
778
- ie,
779
- {
780
- className: a.akCopyIcon,
781
- onClick: () => le(X)
782
- }
783
- ) })
784
- ] })
785
- ] }),
786
- /* @__PURE__ */ s("div", { className: a.akIntegrationGrid, children: [
787
- /* @__PURE__ */ s("div", { children: [
788
- /* @__PURE__ */ e("p", { className: a.akCodeLabel, children: "OpenAI 兼容 — curl 示例" }),
789
- /* @__PURE__ */ e("pre", { className: a.akCodeBlock, children: Fa(X, D) })
790
- ] }),
791
- /* @__PURE__ */ s("div", { children: [
792
- /* @__PURE__ */ e("p", { className: a.akCodeLabel, children: "Anthropic 兼容 — curl 示例" }),
793
- /* @__PURE__ */ e("pre", { className: a.akCodeBlock, children: qa(X, D) })
794
- ] })
795
- ] })
796
- ] }),
797
- /* @__PURE__ */ s("div", { children: [
798
- /* @__PURE__ */ s(
799
- "div",
800
- {
801
- style: {
802
- display: "flex",
803
- justifyContent: "space-between",
804
- alignItems: "center",
805
- marginBottom: 12
806
- },
807
- children: [
808
- /* @__PURE__ */ e(
809
- $e,
810
- {
811
- activeKey: t,
812
- onChange: (l) => n(l),
813
- items: [
814
- { key: "app", label: "应用 AK" },
815
- { key: "personal", label: "个人 AK" }
816
- ],
817
- style: { flex: 1 }
818
- }
819
- ),
820
- /* @__PURE__ */ s("div", { style: { display: "flex", gap: 8 }, children: [
821
- /* @__PURE__ */ e(
822
- Ce.Search,
823
- {
824
- allowClear: !0,
825
- placeholder: "按名称 / 前缀过滤",
826
- style: { width: 200 },
827
- onChange: (l) => J(l.target.value)
828
- }
829
- ),
830
- /* @__PURE__ */ e(L, { icon: /* @__PURE__ */ e(we, {}), onClick: W, size: "small", children: "刷新" }),
831
- t === "personal" && /* @__PURE__ */ e(
832
- L,
833
- {
834
- type: "primary",
835
- icon: /* @__PURE__ */ e(Ee, {}),
836
- onClick: pe,
837
- loading: f,
838
- children: "生成 AK"
839
- }
840
- )
841
- ] })
842
- ]
843
- }
844
- ),
845
- t === "app" ? Ie(o, !0) : Ie(c, !1)
846
- ] }),
847
- /* @__PURE__ */ s(
848
- ye,
849
- {
850
- open: N,
851
- title: "生成新 AK",
852
- onCancel: () => g(!1),
853
- onOk: xe,
854
- okText: "确认生成",
855
- cancelText: "取消",
856
- confirmLoading: f,
857
- children: [
858
- /* @__PURE__ */ e(
859
- "div",
860
- {
861
- style: {
862
- marginBottom: 8,
863
- color: "var(--text-secondary)",
864
- fontSize: 13
865
- },
866
- children: "请输入 AK 名称(用于标识此密钥的用途)"
867
- }
868
- ),
869
- /* @__PURE__ */ e(
870
- Ce,
871
- {
872
- placeholder: "例如:测试用 AK、生产网关 AK",
873
- value: m,
874
- onChange: (l) => k(l.target.value),
875
- onPressEnter: xe,
876
- maxLength: 50,
877
- autoFocus: !0
878
- }
879
- )
880
- ]
881
- }
882
- ),
883
- /* @__PURE__ */ s(
884
- ye,
885
- {
886
- open: p.open,
887
- title: "AK 创建成功",
888
- onCancel: () => d({ open: !1 }),
889
- footer: [
890
- /* @__PURE__ */ e(
891
- L,
892
- {
893
- icon: /* @__PURE__ */ e(ie, {}),
894
- onClick: () => p.apiKey && le(p.apiKey),
895
- children: "复制 AK"
896
- },
897
- "copy"
898
- ),
899
- /* @__PURE__ */ e(
900
- L,
901
- {
902
- type: "primary",
903
- onClick: () => d({ open: !1 }),
904
- children: "我已保存"
905
- },
906
- "close"
907
- )
908
- ],
909
- children: [
910
- /* @__PURE__ */ e("div", { style: { marginBottom: 8, color: "#faad14", fontSize: 14 }, children: "请立即保存此 AK,关闭后将无法再次查看完整密钥。" }),
911
- /* @__PURE__ */ e(
912
- "div",
913
- {
914
- style: {
915
- background: "var(--bg-tertiary, #f6f8fa)",
916
- padding: "12px 14px",
917
- borderRadius: 8,
918
- fontFamily: "SF Mono, Fira Code, monospace",
919
- fontSize: 13,
920
- wordBreak: "break-all",
921
- userSelect: "all"
922
- },
923
- children: p.apiKey
924
- }
925
- ),
926
- /* @__PURE__ */ s("div", { style: { marginTop: 8, fontSize: 12, color: "var(--text-muted)" }, children: [
927
- "前缀: ",
928
- p.akPrefix
929
- ] })
930
- ]
931
- }
932
- ),
933
- /* @__PURE__ */ e(
934
- Oe,
935
- {
936
- title: _ ? /* @__PURE__ */ s("span", { children: [
937
- "AK 详情 — ",
938
- /* @__PURE__ */ e("code", { children: _.akPrefix })
939
- ] }) : "AK 详情",
940
- open: !!_,
941
- onClose: Je,
942
- size: "large",
943
- children: q ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(se, { tip: "加载用量数据..." }) }) : P ? /* @__PURE__ */ s("div", { className: a.usageDrawerContent, children: [
944
- /* @__PURE__ */ e("div", { style: { fontSize: 12, color: "#8c8c8c", marginBottom: 12 }, children: "以下为网关全局调用统计(近 7 天窗口), 监控侧不按 AK 留存;该 AK 自身的累计消耗见下方「本 AK 累计 Token」。" }),
945
- /* @__PURE__ */ s("div", { className: a.usageStatsGrid, children: [
946
- /* @__PURE__ */ e(K, { title: "总请求数", value: P.totalRequests }),
947
- /* @__PURE__ */ e(K, { title: "总 Token", value: P.totalTokens }),
948
- /* @__PURE__ */ e(
949
- K,
950
- {
951
- title: "输入 Token",
952
- value: P.totalPromptTokens
953
- }
954
- ),
955
- /* @__PURE__ */ e(
956
- K,
957
- {
958
- title: "输出 Token",
959
- value: P.totalCompletionTokens
960
- }
961
- ),
962
- /* @__PURE__ */ e(
963
- K,
964
- {
965
- title: "平均耗时",
966
- value: P.avgLatencyMs,
967
- suffix: "ms"
968
- }
969
- ),
970
- /* @__PURE__ */ e(
971
- K,
972
- {
973
- title: "错误数",
974
- value: P.errorCount,
975
- styles: {
976
- content: {
977
- color: P.errorCount > 0 ? "#ff4d4f" : void 0
978
- }
979
- }
980
- }
981
- ),
982
- /* @__PURE__ */ e(
983
- K,
984
- {
985
- title: "本 AK 累计 Token",
986
- value: (_ == null ? void 0 : _.totalTokens) ?? 0
987
- }
988
- )
989
- ] }),
990
- /* @__PURE__ */ s("div", { className: a.usageSection, children: [
991
- /* @__PURE__ */ e("h4", { className: a.usageSectionTitle, children: "每日调用曲线(按最近调用明细聚合)" }),
992
- We(P.daily)
993
- ] }),
994
- /* @__PURE__ */ s("div", { className: a.usageSection, children: [
995
- /* @__PURE__ */ e("h4", { className: a.usageSectionTitle, children: "模型用量分布" }),
996
- Qe(P.models)
997
- ] }),
998
- /* @__PURE__ */ s("div", { className: a.usageSection, children: [
999
- /* @__PURE__ */ e("h4", { className: a.usageSectionTitle, children: "最近调用记录" }),
1000
- /* @__PURE__ */ e(
1001
- ce,
1002
- {
1003
- columns: Ve,
1004
- dataSource: P.recent,
1005
- rowKey: "id",
1006
- size: "small",
1007
- pagination: {
1008
- pageSize: 10,
1009
- size: "small",
1010
- showSizeChanger: !0,
1011
- pageSizeOptions: ["10", "20", "50", "100"],
1012
- showTotal: (l) => `共 ${l} 条`
1013
- },
1014
- scroll: { x: 760 }
1015
- }
1016
- )
1017
- ] })
1018
- ] }) : /* @__PURE__ */ e("div", { className: a.usageEmpty, children: "暂无用量数据" })
1019
- }
1020
- )
1021
- ] });
1022
- }
1023
- function Wa(t) {
1024
- const n = [];
1025
- if (!t) return n;
1026
- const o = /<(think|thinking|reasoning)>([\s\S]*?)<\/\1>/gi;
1027
- let i = 0, c;
1028
- for (; (c = o.exec(t)) !== null; )
1029
- c.index > i && n.push({ type: "text", text: t.slice(i, c.index) }), n.push({ type: "think", text: c[2] }), i = c.index + c[0].length;
1030
- return i < t.length && n.push({ type: "text", text: t.slice(i) }), n;
1031
- }
1032
- const me = 4;
1033
- let Qa = 0;
1034
- function Va({ initialModels: t }) {
1035
- const [n, o] = C([]), [i, c] = C([]), [w, B] = C(!0), [A, f] = C(null), [S, N] = C(""), [g, m] = C(!1), k = ge(""), p = ge(/* @__PURE__ */ new Map()), d = ge(/* @__PURE__ */ new Map());
1036
- V(() => {
1037
- (async () => {
1038
- try {
1039
- const r = await Te();
1040
- c(r), B(!1);
1041
- const y = t.length > 0 ? t : r.slice(0, 1).map((x) => x.modelName);
1042
- o(y.slice(0, me).map((x) => fe(x)));
1043
- } catch (r) {
1044
- B(!1), f(r instanceof Error ? r.message : "模型列表加载失败");
1045
- }
1046
- })();
1047
- }, []), V(() => {
1048
- if (t.length > 0 && i.length > 0) {
1049
- const r = t.slice(0, me).map((y) => fe(y));
1050
- o(r);
1051
- }
1052
- }, [t.join(",")]);
1053
- const _ = H((r) => {
1054
- const y = d.current.get(r);
1055
- y && (y.scrollTop = y.scrollHeight);
1056
- }, []), h = H(
1057
- (r, y) => {
1058
- o((x) => x.map((b) => b.id === r ? y(b) : b));
1059
- },
1060
- []
1061
- ), P = H(async () => {
1062
- if (k.current) return k.current;
1063
- const r = await xt();
1064
- return k.current = r, r;
1065
- }, []), M = H(async () => {
1066
- const r = S.trim();
1067
- if (!r || g) return;
1068
- let y;
1069
- try {
1070
- y = await P();
1071
- } catch {
1072
- return;
1073
- }
1074
- N(""), m(!0);
1075
- const x = n.map((E) => ({
1076
- ...E,
1077
- messages: [
1078
- ...E.messages,
1079
- { role: "user", content: r },
1080
- { role: "assistant", content: "" }
1081
- ],
1082
- streamingContent: "",
1083
- isStreaming: !0,
1084
- error: null,
1085
- usage: null
1086
- }));
1087
- o(x);
1088
- const b = x;
1089
- b.forEach((E) => {
1090
- const J = new AbortController();
1091
- p.current.set(E.id, J);
1092
- const X = E.messages.slice(0, -1);
1093
- Ct(y, E.model, X, {
1094
- onDelta: (D) => {
1095
- h(E.id, (j) => ({
1096
- ...j,
1097
- streamingContent: j.streamingContent + D,
1098
- messages: j.messages.map(
1099
- (W, pe) => pe === j.messages.length - 1 ? { ...W, content: j.streamingContent + D } : W
1100
- )
1101
- })), _(E.id);
1102
- },
1103
- onDone: (D) => {
1104
- h(E.id, (j) => ({
1105
- ...j,
1106
- isStreaming: !1,
1107
- usage: D ? {
1108
- promptTokens: D.promptTokens,
1109
- completionTokens: D.completionTokens,
1110
- totalTokens: D.totalTokens
1111
- } : null
1112
- })), p.current.delete(E.id);
1113
- },
1114
- onError: (D) => {
1115
- (D.message.includes("401") || D.message.includes("API key")) && (He(), k.current = ""), h(E.id, (j) => ({
1116
- ...j,
1117
- isStreaming: !1,
1118
- error: D.message
1119
- })), p.current.delete(E.id);
1120
- },
1121
- signal: J.signal
1122
- }).catch(() => {
1123
- });
1124
- });
1125
- const O = setInterval(() => {
1126
- b.every(
1127
- (J) => !p.current.has(J.id)
1128
- ) && (clearInterval(O), m(!1));
1129
- }, 200);
1130
- setTimeout(() => {
1131
- clearInterval(O), m(!1);
1132
- }, 300 * 1e3);
1133
- }, [S, g, n, P, h, _]), q = H(() => {
1134
- p.current.forEach((r) => r.abort()), p.current.clear(), o((r) => r.map((y) => ({ ...y, isStreaming: !1 }))), m(!1);
1135
- }, []), ae = H(() => {
1136
- var y;
1137
- if (n.length >= me) return;
1138
- const r = (y = i.find((x) => !n.some((b) => b.model === x.modelName))) == null ? void 0 : y.modelName;
1139
- r && o((x) => [...x, fe(r)]);
1140
- }, [n, i]), Y = H(() => {
1141
- p.current.forEach((r) => r.abort()), p.current.clear(), o(
1142
- (r) => r.map((y) => ({
1143
- ...y,
1144
- messages: [],
1145
- streamingContent: "",
1146
- isStreaming: !1,
1147
- error: null,
1148
- usage: null
1149
- }))
1150
- ), m(!1);
1151
- }, [g, n]), u = H((r) => {
1152
- const y = p.current.get(r);
1153
- y && y.abort(), p.current.delete(r), o((x) => x.filter((b) => b.id !== r));
1154
- }, []), $ = H(
1155
- (r, y) => {
1156
- h(r, (x) => ({ ...x, model: y }));
1157
- },
1158
- [h]
1159
- ), R = i.map((r) => ({
1160
- label: r.modelName,
1161
- value: r.modelName
1162
- }));
1163
- return w ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(se, { tip: "加载模型列表..." }) }) : A ? /* @__PURE__ */ e("div", { className: a.chatContainer, children: /* @__PURE__ */ s("div", { className: a.akEmpty, children: [
1164
- "模型列表加载失败:",
1165
- A
1166
- ] }) }) : /* @__PURE__ */ s("div", { className: a.chatContainer, children: [
1167
- /* @__PURE__ */ s("div", { className: a.chatHeader, children: [
1168
- n.length > 1 && /* @__PURE__ */ s(Z, { color: "blue", style: { fontSize: 12 }, children: [
1169
- n.length,
1170
- " 个模型对比"
1171
- ] }),
1172
- /* @__PURE__ */ e(
1173
- L,
1174
- {
1175
- size: "small",
1176
- icon: /* @__PURE__ */ e(Ze, {}),
1177
- onClick: Y,
1178
- disabled: g || n.every((r) => r.messages.length === 0),
1179
- children: "清空重新来"
1180
- }
1181
- )
1182
- ] }),
1183
- /* @__PURE__ */ s("div", { className: a.chatPanels, children: [
1184
- n.map((r) => /* @__PURE__ */ s("div", { className: a.chatPanel, children: [
1185
- /* @__PURE__ */ s("div", { className: a.chatPanelHeader, children: [
1186
- /* @__PURE__ */ e(
1187
- ut,
1188
- {
1189
- size: "small",
1190
- value: r.model,
1191
- onChange: (y) => $(r.id, y),
1192
- options: R,
1193
- style: { minWidth: 140, flex: 1 },
1194
- showSearch: !0,
1195
- optionFilterProp: "label"
1196
- }
1197
- ),
1198
- n.length > 1 && /* @__PURE__ */ e(
1199
- "span",
1200
- {
1201
- className: a.chatPanelClose,
1202
- onClick: () => u(r.id),
1203
- children: /* @__PURE__ */ e(et, {})
1204
- }
1205
- )
1206
- ] }),
1207
- /* @__PURE__ */ s(
1208
- "div",
1209
- {
1210
- className: a.chatPanelBody,
1211
- ref: (y) => {
1212
- d.current.set(r.id, y);
1213
- },
1214
- children: [
1215
- r.messages.map((y, x) => /* @__PURE__ */ s(
1216
- "div",
1217
- {
1218
- className: y.role === "user" ? a.chatMsgUser : a.chatMsgAI,
1219
- children: [
1220
- y.role === "assistant" ? Wa(y.content).map(
1221
- (b, O) => b.type === "think" ? /* @__PURE__ */ s(
1222
- "details",
1223
- {
1224
- className: a.chatThinkBlock,
1225
- children: [
1226
- /* @__PURE__ */ e("summary", { children: "思考过程" }),
1227
- /* @__PURE__ */ e("pre", { children: b.text })
1228
- ]
1229
- },
1230
- O
1231
- ) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: b.text }, O)
1232
- ) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: y.content }),
1233
- r.isStreaming && x === r.messages.length - 1 && y.role === "assistant" && /* @__PURE__ */ e("span", { className: a.chatStreamingCursor })
1234
- ]
1235
- },
1236
- x
1237
- )),
1238
- r.error && /* @__PURE__ */ e("div", { className: a.chatMsgError, children: r.error }),
1239
- r.usage && /* @__PURE__ */ s("div", { className: a.chatUsageBar, children: [
1240
- /* @__PURE__ */ s("span", { children: [
1241
- "输入: ",
1242
- r.usage.promptTokens
1243
- ] }),
1244
- /* @__PURE__ */ s("span", { children: [
1245
- "输出: ",
1246
- r.usage.completionTokens
1247
- ] })
1248
- ] })
1249
- ]
1250
- }
1251
- )
1252
- ] }, r.id)),
1253
- n.length < me && /* @__PURE__ */ e(oe, { title: "添加面板", children: /* @__PURE__ */ e("div", { className: a.addPanelBtn, onClick: ae, children: /* @__PURE__ */ e(Ee, {}) }) })
1254
- ] }),
1255
- /* @__PURE__ */ s("div", { className: a.chatInputBar, children: [
1256
- /* @__PURE__ */ e(
1257
- Ce.TextArea,
1258
- {
1259
- className: a.chatInput,
1260
- value: S,
1261
- onChange: (r) => N(r.target.value),
1262
- placeholder: "输入消息,所有面板将同时收到并流式输出...",
1263
- autoSize: { minRows: 1, maxRows: 4 },
1264
- onPressEnter: (r) => {
1265
- r.shiftKey || (r.preventDefault(), M());
1266
- },
1267
- disabled: g
1268
- }
1269
- ),
1270
- g ? /* @__PURE__ */ e(L, { danger: !0, onClick: q, children: "停止" }) : /* @__PURE__ */ s(L, { type: "primary", onClick: M, disabled: !S.trim(), children: [
1271
- /* @__PURE__ */ e(tt, {}),
1272
- " 发送"
1273
- ] })
1274
- ] })
1275
- ] });
1276
- }
1277
- function fe(t) {
1278
- return {
1279
- id: ++Qa,
1280
- model: t,
1281
- messages: [],
1282
- streamingContent: "",
1283
- isStreaming: !1,
1284
- error: null,
1285
- usage: null
1286
- };
1287
- }
1288
- function Ya({ onStartChat: t }) {
1289
- const [n, o] = C([]), [i, c] = C(!0), [w, B] = C(null), [A, f] = C(/* @__PURE__ */ new Set()), S = () => {
1290
- c(!0), B(null), Te().then((d) => {
1291
- o(d), c(!1);
1292
- }).catch((d) => {
1293
- o([]), B(d instanceof Error ? d.message : "加载失败"), c(!1);
1294
- });
1295
- };
1296
- V(() => {
1297
- S();
1298
- }, []);
1299
- const N = (d) => {
1300
- f((_) => {
1301
- const h = new Set(_);
1302
- return h.has(d) ? h.delete(d) : h.add(d), h;
1303
- });
1304
- }, g = Array.from(A), m = (d) => {
1305
- t([d]);
1306
- }, k = () => {
1307
- g.length > 0 && t(g);
1308
- }, p = (d) => {
1309
- if (!d) return "default";
1310
- const _ = d.toLowerCase();
1311
- return _.includes("aliyun") || _.includes("ali") ? "blue" : _.includes("zhipu") || _.includes("glm") ? "purple" : _.includes("moonshot") || _.includes("kimi") ? "cyan" : _.includes("minimax") ? "orange" : "default";
1312
- };
1313
- return i ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(se, { tip: "加载模型列表..." }) }) : w ? /* @__PURE__ */ e("div", { children: /* @__PURE__ */ s("div", { className: a.akEmpty, children: [
1314
- "模型列表加载失败:",
1315
- w,
1316
- /* @__PURE__ */ e("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ e(L, { type: "primary", onClick: S, children: "重试" }) })
1317
- ] }) }) : /* @__PURE__ */ s("div", { children: [
1318
- n.length === 0 && /* @__PURE__ */ e("div", { className: a.akEmpty, children: "后端暂无启用模型(z_team_model_config 中 enable=1 的行),请先在数据库或网关配置中启用" }),
1319
- /* @__PURE__ */ e("div", { className: a.modelGrid, children: n.map((d) => {
1320
- const _ = A.has(d.modelName);
1321
- return /* @__PURE__ */ s(
1322
- "div",
1323
- {
1324
- className: `${a.modelCard} ${_ ? a.modelCardSelected : ""}`,
1325
- onClick: () => N(d.modelName),
1326
- children: [
1327
- /* @__PURE__ */ e(
1328
- ht,
1329
- {
1330
- className: a.modelCheckbox,
1331
- checked: _,
1332
- onChange: (h) => {
1333
- h.stopPropagation(), N(d.modelName);
1334
- }
1335
- }
1336
- ),
1337
- /* @__PURE__ */ s("div", { className: a.modelCardHeader, children: [
1338
- /* @__PURE__ */ e("div", { className: a.modelIconWrap, children: /* @__PURE__ */ e(_e, {}) }),
1339
- /* @__PURE__ */ s("div", { className: a.modelCardInfo, children: [
1340
- /* @__PURE__ */ e("h4", { className: a.modelName, children: d.modelName }),
1341
- /* @__PURE__ */ s("div", { className: a.modelTags, children: [
1342
- d.modelProvider && /* @__PURE__ */ e(
1343
- Z,
1344
- {
1345
- color: p(d.modelProvider),
1346
- style: { fontSize: 11, margin: 0 },
1347
- children: d.modelProvider
1348
- }
1349
- ),
1350
- /* @__PURE__ */ e(Z, { style: { fontSize: 11, margin: 0 }, children: d.apiType })
1351
- ] })
1352
- ] })
1353
- ] }),
1354
- /* @__PURE__ */ e("p", { className: a.modelEndpoint, children: d.endpoint }),
1355
- /* @__PURE__ */ e("div", { className: a.modelCardFooter, children: /* @__PURE__ */ e(
1356
- L,
1357
- {
1358
- type: "link",
1359
- size: "small",
1360
- onClick: (h) => {
1361
- h.stopPropagation(), m(d.modelName);
1362
- },
1363
- children: "发起对话"
1364
- }
1365
- ) })
1366
- ]
1367
- },
1368
- d.modelName
1369
- );
1370
- }) }),
1371
- g.length > 0 && /* @__PURE__ */ s("div", { className: a.modelActionBar, children: [
1372
- /* @__PURE__ */ s("span", { className: a.modelSelectionCount, children: [
1373
- "已选择 ",
1374
- g.length,
1375
- " 个模型"
1376
- ] }),
1377
- /* @__PURE__ */ e(
1378
- L,
1379
- {
1380
- type: "primary",
1381
- onClick: k,
1382
- disabled: g.length === 0,
1383
- children: "批量对比"
1384
- }
1385
- )
1386
- ] })
1387
- ] });
1388
- }
1389
- const Xa = "_container_15pgq_5", Za = "_page_15pgq_10", en = "_kpiGrid_15pgq_16", tn = "_kpiCard_15pgq_22", an = "_sectionCard_15pgq_29", nn = "_sectionHead_15pgq_36", sn = "_sectionHint_15pgq_42", on = "_akList_15pgq_47", rn = "_errorState_15pgq_54", ln = "_errorTitle_15pgq_66", cn = "_errorDetail_15pgq_72", I = {
1390
- container: Xa,
1391
- page: Za,
1392
- kpiGrid: en,
1393
- kpiCard: tn,
1394
- sectionCard: an,
1395
- sectionHead: nn,
1396
- sectionHint: sn,
1397
- akList: on,
1398
- errorState: rn,
1399
- errorTitle: ln,
1400
- errorDetail: cn
1401
- }, dn = mt(
1402
- () => import("@yuku123/z-agent-component").then((t) => ({ default: t.AgentDashboard }))
1403
- );
1404
- function ne(t) {
1405
- return t >= 1e6 ? `${(t / 1e6).toFixed(2)}M` : t >= 1e3 ? `${(t / 1e3).toFixed(1)}K` : String(t ?? 0);
1406
- }
1407
- function mn({ daily: t }) {
1408
- const n = Object.entries(t);
1409
- if (n.length === 0) return /* @__PURE__ */ e("span", { className: a.usageEmpty, children: "暂无数据" });
1410
- const o = Math.max(...n.map(([, i]) => i[1] + i[2]), 1);
1411
- return /* @__PURE__ */ e("div", { className: a.usageBarChart, children: n.map(([i, c]) => {
1412
- const w = c[1] + c[2];
1413
- return /* @__PURE__ */ s("div", { className: a.usageBarCol, children: [
1414
- /* @__PURE__ */ e(oe, { title: `${i}: ${c[0]}次 / ${w} tokens`, children: /* @__PURE__ */ e(
1415
- "div",
1416
- {
1417
- className: a.usageBar,
1418
- style: { height: `${Math.max(w / o * 100, 2)}%` }
1419
- }
1420
- ) }),
1421
- /* @__PURE__ */ e("span", { className: a.usageBarLabel, children: i })
1422
- ] }, i);
1423
- }) });
1424
- }
1425
- function Ke({ models: t }) {
1426
- const n = Object.entries(t);
1427
- if (n.length === 0) return /* @__PURE__ */ e("span", { className: a.usageEmpty, children: "暂无数据" });
1428
- const o = Math.max(...n.map(([, i]) => i[0]), 1);
1429
- return /* @__PURE__ */ e("div", { className: a.modelBreakdown, children: n.sort((i, c) => c[1][0] - i[1][0]).map(([i, c]) => /* @__PURE__ */ s("div", { className: a.modelBreakdownRow, children: [
1430
- /* @__PURE__ */ e("span", { className: a.modelBreakdownName, children: i }),
1431
- /* @__PURE__ */ e("div", { className: a.modelBreakdownBar, children: /* @__PURE__ */ e(
1432
- "div",
1433
- {
1434
- className: a.modelBreakdownFill,
1435
- style: { width: `${c[0] / o * 100}%` }
1436
- }
1437
- ) }),
1438
- /* @__PURE__ */ s("span", { className: a.modelBreakdownCount, children: [
1439
- c[0],
1440
- "次 / ",
1441
- ne(c[1] + (c[2] || 0)),
1442
- "tokens"
1443
- ] })
1444
- ] }, i)) });
1445
- }
1446
- const un = [
1447
- {
1448
- title: "时间",
1449
- dataIndex: "createTime",
1450
- key: "createTime",
1451
- width: 160,
1452
- render: (t) => t ? new Date(t).toLocaleString("zh-CN") : "-"
1453
- },
1454
- { title: "模型", dataIndex: "model", key: "model", width: 150 },
1455
- { title: "协议", dataIndex: "protocol", key: "protocol", width: 90, render: (t) => /* @__PURE__ */ e(Z, { children: t }) },
1456
- { title: "输入", dataIndex: "promptTokens", key: "promptTokens", width: 70 },
1457
- { title: "输出", dataIndex: "completionTokens", key: "completionTokens", width: 70 },
1458
- { title: "总Token", dataIndex: "totalTokens", key: "totalTokens", width: 80 },
1459
- { title: "耗时", dataIndex: "latencyMs", key: "latencyMs", width: 70, render: (t) => t ? `${t}ms` : "-" },
1460
- {
1461
- title: "状态",
1462
- dataIndex: "statusCode",
1463
- key: "statusCode",
1464
- width: 60,
1465
- render: (t) => t ? /* @__PURE__ */ e(Z, { color: t < 400 ? "green" : "red", children: t }) : "-"
1466
- }
1467
- ];
1468
- function hn(t) {
1469
- var n;
1470
- return ((n = t == null ? void 0 : t.stats) == null ? void 0 : n.recent) ?? [];
1471
- }
1472
- function pn() {
1473
- var g;
1474
- const [t, n] = C(!0), [o, i] = C(null), [c, w] = C(null), [B, A] = C([]), [f, S] = C(null), N = H(async () => {
1475
- n(!0), i(null);
1476
- const m = await Promise.allSettled([
1477
- De(),
1478
- Ge(),
1479
- St()
1480
- ]), [k, p, d] = m;
1481
- k.status === "fulfilled" && w(k.value), p.status === "fulfilled" && A(p.value), d.status === "fulfilled" && S(d.value), m.every((_) => _.status === "rejected") && i(
1482
- k.status === "rejected" && k.reason instanceof Error ? k.reason.message : "网关控制面加载失败"
1483
- ), n(!1);
1484
- }, []);
1485
- return V(() => {
1486
- N();
1487
- }, [N]), t ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(se, { tip: "加载网关控制面..." }) }) : o && !c ? /* @__PURE__ */ s("div", { className: I.errorState, children: [
1488
- /* @__PURE__ */ e("div", { className: I.errorTitle, children: "网关控制面不可用" }),
1489
- /* @__PURE__ */ e("div", { className: I.errorDetail, children: o }),
1490
- /* @__PURE__ */ e(L, { icon: /* @__PURE__ */ e(we, {}), onClick: () => void N(), type: "primary", children: "重试" })
1491
- ] }) : /* @__PURE__ */ s("div", { className: I.page, children: [
1492
- /* @__PURE__ */ s("div", { className: I.kpiGrid, children: [
1493
- /* @__PURE__ */ e("div", { className: I.kpiCard, children: /* @__PURE__ */ e(
1494
- K,
1495
- {
1496
- title: "网关状态",
1497
- value: f ? "在线" : "未知",
1498
- valueStyle: f ? { color: "#52c41a" } : { color: "#faad14" }
1499
- }
1500
- ) }),
1501
- /* @__PURE__ */ e("div", { className: I.kpiCard, children: /* @__PURE__ */ e(K, { title: "上游厂商", value: ((g = c == null ? void 0 : c.vendors) == null ? void 0 : g.length) ?? 0 }) }),
1502
- /* @__PURE__ */ e("div", { className: I.kpiCard, children: /* @__PURE__ */ e(
1503
- K,
1504
- {
1505
- title: "上游模型总数",
1506
- value: ((c == null ? void 0 : c.vendors) ?? []).reduce((m, k) => m + (k.models ?? 0), 0)
1507
- }
1508
- ) }),
1509
- /* @__PURE__ */ e("div", { className: I.kpiCard, children: /* @__PURE__ */ e(K, { title: "网关 AK 数", value: (c == null ? void 0 : c.activeApiKeys) ?? "—" }) })
1510
- ] }),
1511
- /* @__PURE__ */ e(
1512
- ce,
1513
- {
1514
- size: "small",
1515
- style: { marginTop: 16 },
1516
- rowKey: "vendor",
1517
- pagination: !1,
1518
- columns: [
1519
- { title: "上游厂商", dataIndex: "vendor", key: "vendor" },
1520
- { title: "凭据数", dataIndex: "credentials", key: "credentials", width: 100 },
1521
- { title: "可用模型数", dataIndex: "models", key: "models", width: 110 }
1522
- ],
1523
- dataSource: (c == null ? void 0 : c.vendors) ?? [],
1524
- locale: { emptyText: "网关控制面未返回厂商数据" }
1525
- }
1526
- ),
1527
- /* @__PURE__ */ s("div", { className: a.usageSection, style: { marginTop: 16 }, children: [
1528
- /* @__PURE__ */ e("span", { className: a.usageSectionTitle, children: "租户用量台账(网关 UsageLedger,按租户维度)" }),
1529
- /* @__PURE__ */ e(
1530
- ce,
1531
- {
1532
- size: "small",
1533
- rowKey: "tenantCode",
1534
- columns: [
1535
- { title: "租户", dataIndex: "tenantCode", key: "tenantCode" },
1536
- { title: "请求数", dataIndex: "requests", key: "requests", width: 100 },
1537
- { title: "Prompt Tokens", dataIndex: "promptTokens", key: "promptTokens", width: 130, render: (m) => ne(m) },
1538
- { title: "Completion Tokens", dataIndex: "completionTokens", key: "completionTokens", width: 160, render: (m) => ne(m) },
1539
- { title: "成本", dataIndex: "cost", key: "cost", width: 100 }
1540
- ],
1541
- dataSource: B,
1542
- locale: { emptyText: "暂无租户用量(还没有绑定租户的 key 发生过调用)" },
1543
- pagination: {
1544
- pageSize: 10,
1545
- showSizeChanger: !0,
1546
- pageSizeOptions: ["10", "20", "50"],
1547
- showTotal: (m) => `共 ${m} 条`
1548
- }
1549
- }
1550
- )
1551
- ] })
1552
- ] });
1553
- }
1554
- function kn() {
1555
- var _, h, P, M, q, ae, Y;
1556
- const [t, n] = C(!0), [o, i] = C(null), [c, w] = C([]), [B, A] = C(null), [f, S] = C(null), N = String(Ue((u) => {
1557
- var $;
1558
- return (($ = u.currentUser) == null ? void 0 : $.id) ?? "";
1559
- })), g = Array.from(
1560
- new Set([N, Le].filter((u) => u !== ""))
1561
- ), m = H(async () => {
1562
- n(!0), i(null);
1563
- try {
1564
- const u = await Promise.allSettled(
1565
- g.map((O) => he(O))
1566
- ), $ = [], R = /* @__PURE__ */ new Set();
1567
- let r = 0;
1568
- for (const O of u)
1569
- if (O.status === "fulfilled")
1570
- for (const E of O.value) {
1571
- const J = String(E.id ?? E.akPrefix ?? "");
1572
- R.has(J) || (R.add(J), $.push(E));
1573
- }
1574
- else r += 1;
1575
- if (r === u.length)
1576
- throw new Error("网关不可达:无法获取 AK 列表");
1577
- $.sort((O, E) => (O.id ?? 0) - (E.id ?? 0));
1578
- let y = null, x = null;
1579
- try {
1580
- y = await Re(0);
1581
- } catch (O) {
1582
- x = O instanceof Error ? O.message : "获取用量失败";
1583
- }
1584
- A(y);
1585
- const b = $.map((O) => ({
1586
- key: O,
1587
- stats: y,
1588
- statsError: x
1589
- }));
1590
- w(b);
1591
- } catch (u) {
1592
- i(u instanceof Error ? u.message : "加载失败");
1593
- } finally {
1594
- n(!1);
1595
- }
1596
- }, [g.join(",")]);
1597
- V(() => {
1598
- m();
1599
- }, [m]);
1600
- const k = Me(() => {
1601
- const u = B, $ = {};
1602
- for (const [R, r] of Object.entries((u == null ? void 0 : u.models) ?? {}))
1603
- $[R] = [r[0] ?? 0, r[1] ?? 0, r[2] ?? 0];
1604
- return {
1605
- requests: (u == null ? void 0 : u.totalRequests) ?? 0,
1606
- tokens: (u == null ? void 0 : u.totalTokens) ?? 0,
1607
- avgLatency: (u == null ? void 0 : u.avgLatencyMs) ?? 0,
1608
- errors: (u == null ? void 0 : u.errorCount) ?? 0,
1609
- models: $
1610
- };
1611
- }, [B]), p = c.reduce((u, $) => u + ($.key.tokenQuota || 0), 0), d = () => t ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(se, { tip: "加载监控数据..." }) }) : o ? /* @__PURE__ */ s("div", { className: I.errorState, children: [
1612
- /* @__PURE__ */ e("div", { className: I.errorTitle, children: "模型监控数据加载失败" }),
1613
- /* @__PURE__ */ e("div", { className: I.errorDetail, children: o }),
1614
- /* @__PURE__ */ e(L, { icon: /* @__PURE__ */ e(we, {}), onClick: m, type: "primary", children: "重试" })
1615
- ] }) : /* @__PURE__ */ s("div", { className: I.page, children: [
1616
- /* @__PURE__ */ s("div", { className: I.kpiGrid, children: [
1617
- /* @__PURE__ */ e("div", { className: I.kpiCard, children: /* @__PURE__ */ e(K, { title: "总请求(近7天)", value: k.requests }) }),
1618
- /* @__PURE__ */ e("div", { className: I.kpiCard, children: /* @__PURE__ */ e(K, { title: "总 Tokens", value: ne(k.tokens) }) }),
1619
- /* @__PURE__ */ e("div", { className: I.kpiCard, children: /* @__PURE__ */ e(K, { title: "平均延迟", value: k.avgLatency, suffix: "ms" }) }),
1620
- /* @__PURE__ */ e("div", { className: I.kpiCard, children: /* @__PURE__ */ e(
1621
- K,
1622
- {
1623
- title: "错误数",
1624
- value: k.errors,
1625
- valueStyle: k.errors > 0 ? { color: "#ff4d4f" } : void 0
1626
- }
1627
- ) })
1628
- ] }),
1629
- /* @__PURE__ */ s("div", { className: I.sectionCard, children: [
1630
- /* @__PURE__ */ s("div", { className: I.sectionHead, children: [
1631
- /* @__PURE__ */ e("span", { className: a.usageSectionTitle, children: "AK 用量" }),
1632
- p > 0 && /* @__PURE__ */ s("span", { className: I.sectionHint, children: [
1633
- "合计额度 ",
1634
- ne(p),
1635
- " tokens"
1636
- ] })
1637
- ] }),
1638
- c.length === 0 ? /* @__PURE__ */ e("div", { className: a.akEmpty, children: "网关下暂无 AK" }) : /* @__PURE__ */ e("div", { className: I.akList, children: c.map((u) => {
1639
- const $ = u.key.totalTokens ?? 0, R = u.key.tokenQuota || 0, r = R > 0 ? Math.min($ / R * 100, 100) : 0;
1640
- return /* @__PURE__ */ s(
1641
- "div",
1642
- {
1643
- className: a.akCard,
1644
- onClick: () => S(u),
1645
- children: [
1646
- /* @__PURE__ */ s("div", { className: a.akCardRow, children: [
1647
- /* @__PURE__ */ e("span", { className: a.akTitle, children: u.key.description || u.key.userName || `AK #${u.key.id}` }),
1648
- /* @__PURE__ */ e("span", { className: a.akPrefixSmall, children: u.key.akPrefix }),
1649
- /* @__PURE__ */ e(
1650
- "span",
1651
- {
1652
- className: `${a.akStatus} ${u.key.active ? a.akStatusActive : a.akStatusRevoked}`,
1653
- children: u.key.active ? "启用" : "吊销"
1654
- }
1655
- ),
1656
- /* @__PURE__ */ e("span", { className: a.akMetaText, children: u.key.userId === "system-default" ? "系统对话" : u.key.userId })
1657
- ] }),
1658
- /* @__PURE__ */ s("div", { className: a.akCardRow2, children: [
1659
- /* @__PURE__ */ e("div", { className: a.akMiniBar, children: /* @__PURE__ */ e(
1660
- "div",
1661
- {
1662
- className: a.akMiniBarFill,
1663
- style: { width: `${r}%` }
1664
- }
1665
- ) }),
1666
- /* @__PURE__ */ s("span", { className: a.akUsageText, children: [
1667
- ne($),
1668
- R > 0 ? ` / ${ne(R)}` : "",
1669
- " tokens"
1670
- ] }),
1671
- /* @__PURE__ */ e("span", { className: a.akMetaText, children: u.statsError ? u.statsError : u.key.lastUsedAt ? `最近使用 ${u.key.lastUsedAt}` : "尚未使用" })
1672
- ] })
1673
- ]
1674
- },
1675
- u.key.id
1676
- );
1677
- }) })
1678
- ] }),
1679
- /* @__PURE__ */ s("div", { className: I.sectionCard, children: [
1680
- /* @__PURE__ */ e("span", { className: a.usageSectionTitle, children: "模型用量分布(网关全局)" }),
1681
- /* @__PURE__ */ e(Ke, { models: k.models })
1682
- ] })
1683
- ] });
1684
- return /* @__PURE__ */ s("div", { className: I.container, children: [
1685
- /* @__PURE__ */ e(
1686
- $e,
1687
- {
1688
- defaultActiveKey: "usage",
1689
- items: [
1690
- { key: "usage", label: "模型用量", children: d() },
1691
- {
1692
- key: "sessions",
1693
- label: "会话统计",
1694
- children: /* @__PURE__ */ e(dt, { fallback: /* @__PURE__ */ e(se, { tip: "加载会话统计..." }), children: /* @__PURE__ */ e(dn, {}) })
1695
- },
1696
- { key: "gateway", label: "网关控制面", children: /* @__PURE__ */ e(pn, {}) }
1697
- ]
1698
- }
1699
- ),
1700
- /* @__PURE__ */ e(
1701
- Oe,
1702
- {
1703
- title: f ? `AK 用量 — ${f.key.description || f.key.akPrefix}` : "",
1704
- width: 860,
1705
- open: !!f,
1706
- onClose: () => S(null),
1707
- destroyOnHidden: !0,
1708
- children: f && /* @__PURE__ */ s("div", { className: a.usageDrawerContent, children: [
1709
- /* @__PURE__ */ e("div", { style: { fontSize: 12, color: "#8c8c8c", marginBottom: 12 }, children: "调用监控是网关全局维度(不按 AK 留存),以下统计覆盖全部 AK; 该 AK 自身的累计消耗见「本 AK 累计 Token」。" }),
1710
- /* @__PURE__ */ s("div", { className: a.usageStatsGrid, children: [
1711
- /* @__PURE__ */ e(K, { title: "总请求", value: ((_ = f.stats) == null ? void 0 : _.totalRequests) ?? 0 }),
1712
- /* @__PURE__ */ e(K, { title: "总 Tokens", value: ((h = f.stats) == null ? void 0 : h.totalTokens) ?? 0 }),
1713
- /* @__PURE__ */ e(K, { title: "平均延迟", value: ((P = f.stats) == null ? void 0 : P.avgLatencyMs) ?? 0, suffix: "ms" }),
1714
- /* @__PURE__ */ e(K, { title: "输入 Tokens", value: ((M = f.stats) == null ? void 0 : M.totalPromptTokens) ?? 0 }),
1715
- /* @__PURE__ */ e(K, { title: "输出 Tokens", value: ((q = f.stats) == null ? void 0 : q.totalCompletionTokens) ?? 0 }),
1716
- /* @__PURE__ */ e(
1717
- K,
1718
- {
1719
- title: "本 AK 累计 Token",
1720
- value: f.key.totalTokens ?? 0
1721
- }
1722
- ),
1723
- /* @__PURE__ */ e(
1724
- K,
1725
- {
1726
- title: "错误数",
1727
- value: ((ae = f.stats) == null ? void 0 : ae.errorCount) ?? 0,
1728
- valueStyle: (((Y = f.stats) == null ? void 0 : Y.errorCount) ?? 0) > 0 ? { color: "#ff4d4f" } : void 0
1729
- }
1730
- )
1731
- ] }),
1732
- /* @__PURE__ */ s("div", { className: a.usageSection, children: [
1733
- /* @__PURE__ */ e("span", { className: a.usageSectionTitle, children: "每日用量(按最近调用明细聚合)" }),
1734
- f.stats ? /* @__PURE__ */ e(mn, { daily: f.stats.daily ?? {} }) : /* @__PURE__ */ e("span", { className: a.usageEmpty, children: f.statsError ?? "暂无数据" })
1735
- ] }),
1736
- /* @__PURE__ */ s("div", { className: a.usageSection, children: [
1737
- /* @__PURE__ */ e("span", { className: a.usageSectionTitle, children: "模型用量分布(按最近调用明细聚合)" }),
1738
- f.stats ? /* @__PURE__ */ e(Ke, { models: f.stats.models ?? {} }) : /* @__PURE__ */ e("span", { className: a.usageEmpty, children: f.statsError ?? "暂无数据" })
1739
- ] }),
1740
- /* @__PURE__ */ s("div", { className: a.usageSection, children: [
1741
- /* @__PURE__ */ e("span", { className: a.usageSectionTitle, children: "最近调用" }),
1742
- /* @__PURE__ */ e(
1743
- ce,
1744
- {
1745
- size: "small",
1746
- columns: un,
1747
- dataSource: hn(f),
1748
- rowKey: "id",
1749
- pagination: {
1750
- pageSize: 8,
1751
- showSizeChanger: !0,
1752
- pageSizeOptions: ["8", "20", "50", "100"],
1753
- showTotal: (u) => `共 ${u} 条`
1754
- }
1755
- }
1756
- )
1757
- ] })
1758
- ] })
1759
- }
1760
- )
1761
- ] });
1762
- }
1763
- const gn = [
1764
- {
1765
- title: "模型",
1766
- icon: /* @__PURE__ */ e(Pe, {}),
1767
- items: [
1768
- { key: "model-management", label: "模型管理", icon: /* @__PURE__ */ e(Pe, {}) },
1769
- { key: "model-chat", label: "模型对话", icon: /* @__PURE__ */ e(st, {}) },
1770
- { key: "model-monitor", label: "模型监控", icon: /* @__PURE__ */ e(ot, {}) }
1771
- ]
1772
- },
1773
- {
1774
- title: "接入",
1775
- icon: /* @__PURE__ */ e(be, {}),
1776
- items: [
1777
- { key: "ak-management", label: "AK 管理", icon: /* @__PURE__ */ e(be, {}) }
1778
- ]
1779
- },
1780
- {
1781
- title: "智能体",
1782
- icon: /* @__PURE__ */ e(_e, {}),
1783
- items: [
1784
- { key: "agent-app", label: "Agent 应用", icon: /* @__PURE__ */ e(_e, {}) },
1785
- { key: "agent-instance", label: "Agent 实例", icon: /* @__PURE__ */ e(rt, {}) },
1786
- { key: "mcp-service", label: "MCP 服务", icon: /* @__PURE__ */ e(lt, {}) },
1787
- { key: "skill-market", label: "技能市场", icon: /* @__PURE__ */ e(ct, {}) },
1788
- { key: "agent-msg-monitor", label: "消息监控", icon: /* @__PURE__ */ e(it, {}) }
1789
- ]
1790
- }
1791
- ];
1792
- function Sn() {
1793
- const [t, n] = C("model-management"), [o, i] = C([]), [c, w] = C(/* @__PURE__ */ new Set()), B = (N) => {
1794
- i(N), n("model-chat");
1795
- }, A = Me(() => gn, []);
1796
- V(() => {
1797
- t && A.forEach((N) => {
1798
- N.items.some((g) => g.key === t) && w(
1799
- (g) => g.has(N.title) ? g : new Set(g).add(N.title)
1800
- );
1801
- });
1802
- }, [t, A]);
1803
- const f = (N) => {
1804
- w((g) => {
1805
- const m = new Set(g);
1806
- return m.has(N) ? m.delete(N) : m.add(N), m;
1807
- });
1808
- }, S = (N, g, m = !1) => /* @__PURE__ */ e(
1809
- "div",
1810
- {
1811
- style: {
1812
- display: t === N ? m ? "flex" : "block" : "none",
1813
- height: "100%",
1814
- ...m ? { flexDirection: "column" } : {}
1815
- },
1816
- children: g
1817
- }
1818
- );
1819
- return /* @__PURE__ */ s("div", { className: a.container, children: [
1820
- /* @__PURE__ */ e("aside", { className: z.sidebar, children: /* @__PURE__ */ e("nav", { className: z.menuList, children: A.map((N) => {
1821
- const g = c.has(N.title), m = N.items.findIndex((k) => k.key === t);
1822
- return /* @__PURE__ */ s("div", { className: z.menuGroup, children: [
1823
- /* @__PURE__ */ s(
1824
- "div",
1825
- {
1826
- className: `${z.menuGroupHeader} ${g ? z.menuGroupHeaderOpen : ""} ${m >= 0 ? z.menuGroupHeaderActive : ""}`,
1827
- onClick: () => f(N.title),
1828
- children: [
1829
- /* @__PURE__ */ e("span", { className: z.menuGroupIcon, children: N.icon }),
1830
- /* @__PURE__ */ e("span", { className: z.menuGroupLabel, children: N.title }),
1831
- /* @__PURE__ */ e("span", { className: z.menuGroupArrow, children: g ? /* @__PURE__ */ e(at, {}) : /* @__PURE__ */ e(nt, {}) })
1832
- ]
1833
- }
1834
- ),
1835
- g && /* @__PURE__ */ e("ul", { className: z.menuSubList, children: N.items.map((k, p) => {
1836
- const d = m >= 0 && p <= m;
1837
- return /* @__PURE__ */ e(
1838
- "li",
1839
- {
1840
- className: `${z.menuSubItem} ${d ? z.menuItemOnPath : ""} ${t === k.key ? z.menuSubItemActive : ""}`,
1841
- onClick: () => n(k.key),
1842
- children: /* @__PURE__ */ s("div", { className: z.menuSubItemPill, children: [
1843
- /* @__PURE__ */ e("span", { className: z.menuSubItemIcon, children: k.icon }),
1844
- /* @__PURE__ */ e("span", { children: k.label })
1845
- ] })
1846
- },
1847
- k.key
1848
- );
1849
- }) })
1850
- ] }, N.title);
1851
- }) }) }),
1852
- /* @__PURE__ */ s("main", { className: a.panelArea, children: [
1853
- S("model-management", /* @__PURE__ */ e(Ya, { onStartChat: B })),
1854
- S("model-chat", /* @__PURE__ */ e(Va, { initialModels: o }), !0),
1855
- S("ak-management", /* @__PURE__ */ e(Ja, {})),
1856
- S("agent-app", /* @__PURE__ */ e(kt, {})),
1857
- S("agent-instance", /* @__PURE__ */ e(gt, {})),
1858
- S("mcp-service", /* @__PURE__ */ e(yt, {})),
1859
- S("skill-market", /* @__PURE__ */ e(ft, {})),
1860
- S("agent-msg-monitor", /* @__PURE__ */ e(pt, {})),
1861
- S("model-monitor", /* @__PURE__ */ e(kn, {}))
1862
- ] })
1863
- ] });
1864
- }
1865
- export {
1866
- Sn as default
1867
- };