@yuku123/z-team-component 0.2.140 → 0.2.142

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