@chenpu17/cc-gw 0.7.21 → 0.8.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +98 -548
- package/package.json +41 -62
- package/src/cli/dist/index.js +95 -32
- package/src/web/dist/assets/About-g7O_JA6K.js +1 -0
- package/src/web/dist/assets/ApiKeys-CEJ9-jBz.js +1 -0
- package/src/web/dist/assets/ConfirmDialog-DwZk3ejq.js +1 -0
- package/src/web/dist/assets/Dashboard-OPVlXupp.js +1 -0
- package/src/web/dist/assets/EChart-CfTG8iSv.js +1 -0
- package/src/web/dist/assets/Events-D7p4pym8.js +1 -0
- package/src/web/dist/assets/Help-DbNTCxxV.js +8 -0
- package/src/web/dist/assets/Login-h9CRbinI.js +1 -0
- package/src/web/dist/assets/Logs-DN-Cl2dm.js +1 -0
- package/src/web/dist/assets/ModelManagement-CrpcomEc.js +1 -0
- package/src/web/dist/assets/PageHeader-CbpaEUEn.js +1 -0
- package/src/web/dist/assets/PageSection-6q9HngU5.js +1 -0
- package/src/web/dist/assets/Settings-Bp_GpSh3.js +1 -0
- package/src/web/dist/assets/Skeleton-DFeA7kZw.js +1 -0
- package/src/web/dist/assets/card-DRsnBFyp.js +1 -0
- package/src/web/dist/assets/charts-core-BjxPMAw_.js +12 -0
- package/src/web/dist/assets/charts-engine-B4YVo-Wh.js +16 -0
- package/src/web/dist/assets/charts-react-BxiU3S4Y.js +1 -0
- package/src/web/dist/assets/i18n-qAxAISVU.js +1 -0
- package/src/web/dist/assets/index-BKEgpvTe.js +61 -0
- package/src/web/dist/assets/index-BfFWdxjR.css +1 -0
- package/src/web/dist/assets/input-BCUUQfiv.js +1 -0
- package/src/web/dist/assets/label-CtuP7N6a.js +1 -0
- package/src/web/dist/assets/query-BnTlXVsy.js +1 -0
- package/src/web/dist/assets/radix-CwKvZelb.js +5 -0
- package/src/web/dist/assets/router-Ju3lwB-M.js +19 -0
- package/src/web/dist/assets/select-C-e-41FP.js +1 -0
- package/src/web/dist/assets/switch-D72iMnTO.js +1 -0
- package/src/web/dist/assets/useApiQuery-C4-HjWYY.js +1 -0
- package/src/web/dist/assets/vendor-UrUELLAG.js +317 -0
- package/src/web/dist/index.html +7 -2
- package/src/server/dist/index.js +0 -18202
- package/src/web/dist/assets/About-Bjq70P_K.js +0 -6
- package/src/web/dist/assets/ApiKeys-BHwlIBRG.js +0 -16
- package/src/web/dist/assets/Dashboard-Bv6E5M2u.js +0 -16
- package/src/web/dist/assets/Events-DyqUKr1b.js +0 -16
- package/src/web/dist/assets/Help-BNn_Zuo4.js +0 -23
- package/src/web/dist/assets/Login-BHXuuVq3.js +0 -1
- package/src/web/dist/assets/Logs-CRnJOy2J.js +0 -6
- package/src/web/dist/assets/ModelManagement-DAE8AYAE.js +0 -6
- package/src/web/dist/assets/PageHeader-D2u2opjK.js +0 -1
- package/src/web/dist/assets/PageSection-jfq2rgUu.js +0 -1
- package/src/web/dist/assets/Settings-CssUPWdg.js +0 -6
- package/src/web/dist/assets/Skeleton-BwMNCVcg.js +0 -1
- package/src/web/dist/assets/card-C9wVDhpJ.js +0 -1
- package/src/web/dist/assets/dialog-DbEoPxgf.js +0 -10
- package/src/web/dist/assets/index-B1EJcuR-.css +0 -1
- package/src/web/dist/assets/index-BjqieXJo.js +0 -48
- package/src/web/dist/assets/index-Blclkvp7.js +0 -280
- package/src/web/dist/assets/info-BmVX8zJd.js +0 -6
- package/src/web/dist/assets/input-CGgq_gCJ.js +0 -1
- package/src/web/dist/assets/label-BGUvZ4t2.js +0 -1
- package/src/web/dist/assets/refresh-cw-D7rJxbFV.js +0 -6
- package/src/web/dist/assets/select-Chuh7X1A.js +0 -11
- package/src/web/dist/assets/shield-Beuqdf31.js +0 -11
- package/src/web/dist/assets/switch-XbPwmM_b.js +0 -1
- package/src/web/dist/assets/useApiQuery-DiX6xcfY.js +0 -1
package/package.json
CHANGED
|
@@ -1,80 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenpu17/cc-gw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"typecheck": "pnpm -r exec tsc --noEmit",
|
|
19
|
-
"test": "pnpm exec vitest run",
|
|
20
|
-
"test:playwright": "playwright test"
|
|
6
|
+
"description": "Rust-backed local Claude Code compatible gateway with web console and CLI daemon.",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/chenpu17/cc-gw2.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/chenpu17/cc-gw2",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/chenpu17/cc-gw2/issues"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18.18.0"
|
|
21
18
|
},
|
|
22
19
|
"bin": {
|
|
23
20
|
"cc-gw": "src/cli/dist/index.js"
|
|
24
21
|
},
|
|
25
22
|
"files": [
|
|
26
23
|
"src/cli/dist",
|
|
27
|
-
"src/server/dist",
|
|
28
24
|
"src/web/dist",
|
|
29
|
-
"README.md"
|
|
30
|
-
"LICENSE"
|
|
25
|
+
"README.md"
|
|
31
26
|
],
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"packageManager": "pnpm@9.0.0",
|
|
41
|
-
"engines": {
|
|
42
|
-
"node": ">=18.18.0"
|
|
43
|
-
},
|
|
44
|
-
"description": "Self-hosted Claude Code compatible gateway with web console and CLI daemon.",
|
|
45
|
-
"license": "MIT",
|
|
46
|
-
"keywords": [
|
|
47
|
-
"claude",
|
|
48
|
-
"gateway",
|
|
49
|
-
"ai",
|
|
50
|
-
"fastify"
|
|
51
|
-
],
|
|
52
|
-
"repository": {
|
|
53
|
-
"type": "git",
|
|
54
|
-
"url": "git+https://github.com/chenpu17/cc-gw.git"
|
|
27
|
+
"optionalDependencies": {
|
|
28
|
+
"@chenpu17/cc-gw-linux-arm64": "0.8.0-alpha.0",
|
|
29
|
+
"@chenpu17/cc-gw-win32-x64": "0.8.0-alpha.0",
|
|
30
|
+
"@chenpu17/cc-gw-darwin-arm64": "0.8.0-alpha.0",
|
|
31
|
+
"@chenpu17/cc-gw-linux-x64": "0.8.0-alpha.0"
|
|
55
32
|
},
|
|
56
33
|
"dependencies": {
|
|
57
|
-
"@fastify/cors": "^9.0.1",
|
|
58
|
-
"@fastify/static": "^7.0.4",
|
|
59
|
-
"better-sqlite3": "^12.4.1",
|
|
60
34
|
"colorette": "^2.0.20",
|
|
61
|
-
"commander": "^12.0.0"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
"tiktoken": "^1.0.21",
|
|
66
|
-
"undici": "^6.11.1"
|
|
35
|
+
"commander": "^12.0.0"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
67
39
|
},
|
|
68
40
|
"devDependencies": {
|
|
69
|
-
"@
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
41
|
+
"@playwright/test": "^1.55.1"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"dev": "cargo run -p cc-gw-server",
|
|
45
|
+
"sync:native-versions": "node scripts/sync-native-versions.mjs",
|
|
46
|
+
"print:dist-tag": "node scripts/npm-dist-tag.mjs",
|
|
47
|
+
"build": "pnpm run build:server && pnpm run build:cli && pnpm run build:web && pnpm run bundle:native",
|
|
48
|
+
"build:server": "cargo build --release -p cc-gw-server",
|
|
49
|
+
"build:cli": "pnpm --filter @cc-gw/cli build",
|
|
50
|
+
"build:web": "pnpm --filter @cc-gw/web build",
|
|
51
|
+
"bundle:native": "node scripts/bundle-native-binary.mjs",
|
|
52
|
+
"smoke:cli": "node scripts/smoke-cli.mjs",
|
|
53
|
+
"build:package": "pnpm run sync:native-versions && pnpm run build:cli && pnpm run build:web",
|
|
54
|
+
"pack:dry-run": "pnpm run build:package && node scripts/pack-root-package.mjs",
|
|
55
|
+
"publish:packed": "node scripts/publish-artifacts.mjs",
|
|
56
|
+
"test:e2e:web": "pnpm build && playwright test",
|
|
57
|
+
"typecheck": "pnpm --filter @cc-gw/cli exec tsc --noEmit && pnpm --filter @cc-gw/web exec tsc --noEmit"
|
|
79
58
|
}
|
|
80
|
-
}
|
|
59
|
+
}
|
package/src/cli/dist/index.js
CHANGED
|
@@ -9,8 +9,8 @@ import os from "os";
|
|
|
9
9
|
import path from "path";
|
|
10
10
|
import process from "process";
|
|
11
11
|
import { fileURLToPath } from "url";
|
|
12
|
-
import { green, yellow } from "colorette";
|
|
13
12
|
import { createRequire } from "module";
|
|
13
|
+
import { green, yellow } from "colorette";
|
|
14
14
|
var program = new Command();
|
|
15
15
|
var DEFAULT_PORT = 4100;
|
|
16
16
|
var HOME_DIR = path.join(os.homedir(), ".cc-gw");
|
|
@@ -39,36 +39,96 @@ function resolvePackageVersion() {
|
|
|
39
39
|
return "0.0.0";
|
|
40
40
|
}
|
|
41
41
|
var CLI_VERSION = resolvePackageVersion();
|
|
42
|
-
|
|
42
|
+
function resolveProjectRoot() {
|
|
43
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
44
|
+
const __dirname = path.dirname(__filename);
|
|
45
|
+
const candidates = [
|
|
46
|
+
path.resolve(__dirname, "../../.."),
|
|
47
|
+
path.resolve(__dirname, "../.."),
|
|
48
|
+
process.cwd()
|
|
49
|
+
];
|
|
50
|
+
for (const candidate of candidates) {
|
|
51
|
+
if (fs.existsSync(path.join(candidate, "package.json"))) {
|
|
52
|
+
return candidate;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return candidates[0];
|
|
56
|
+
}
|
|
57
|
+
function resolveExecutableName() {
|
|
58
|
+
return process.platform === "win32" ? "cc-gw-server.exe" : "cc-gw-server";
|
|
59
|
+
}
|
|
60
|
+
function resolveNativePackageBinary() {
|
|
61
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
62
|
+
const __dirname = path.dirname(__filename);
|
|
63
|
+
const executable = resolveExecutableName();
|
|
64
|
+
const packageMap = {
|
|
65
|
+
"darwin-arm64": "@chenpu17/cc-gw-darwin-arm64",
|
|
66
|
+
"linux-x64": "@chenpu17/cc-gw-linux-x64",
|
|
67
|
+
"linux-arm64": "@chenpu17/cc-gw-linux-arm64",
|
|
68
|
+
"win32-x64": "@chenpu17/cc-gw-win32-x64"
|
|
69
|
+
};
|
|
70
|
+
const packageName = packageMap[`${process.platform}-${process.arch}`];
|
|
71
|
+
if (!packageName) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
43
74
|
try {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
75
|
+
const packageJsonPath = require2.resolve(`${packageName}/package.json`, {
|
|
76
|
+
paths: [__dirname]
|
|
77
|
+
});
|
|
78
|
+
const packageDir = path.dirname(packageJsonPath);
|
|
79
|
+
const candidate = path.join(packageDir, "bin", executable);
|
|
80
|
+
if (fs.existsSync(candidate)) {
|
|
81
|
+
return candidate;
|
|
48
82
|
}
|
|
49
83
|
} catch {
|
|
50
84
|
}
|
|
51
85
|
return null;
|
|
52
86
|
}
|
|
53
|
-
function
|
|
87
|
+
function resolveBundledBinary() {
|
|
54
88
|
const __filename = fileURLToPath(import.meta.url);
|
|
55
89
|
const __dirname = path.dirname(__filename);
|
|
90
|
+
const executable = resolveExecutableName();
|
|
91
|
+
const targetDir = `${process.platform}-${process.arch}`;
|
|
56
92
|
const candidates = [
|
|
57
|
-
|
|
58
|
-
path.resolve(__dirname,
|
|
59
|
-
path.resolve(__dirname, "../server/dist/index.js"),
|
|
60
|
-
path.resolve(__dirname, "../../../src/server/dist/index.js"),
|
|
61
|
-
// Release bundle(cli -> server)
|
|
62
|
-
path.resolve(__dirname, "../server/index.js"),
|
|
63
|
-
path.resolve(__dirname, "../../server/index.js"),
|
|
64
|
-
path.resolve(__dirname, "../../../server/index.js")
|
|
93
|
+
path.resolve(__dirname, `../../../bin/${targetDir}/${executable}`),
|
|
94
|
+
path.resolve(__dirname, `../../../../bin/${targetDir}/${executable}`)
|
|
65
95
|
];
|
|
66
96
|
for (const candidate of candidates) {
|
|
67
97
|
if (fs.existsSync(candidate)) {
|
|
68
98
|
return candidate;
|
|
69
99
|
}
|
|
70
100
|
}
|
|
71
|
-
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
function resolveServerCommand() {
|
|
104
|
+
const envOverride = process.env.CC_GW_SERVER_BIN;
|
|
105
|
+
if (envOverride && fs.existsSync(envOverride)) {
|
|
106
|
+
return { command: envOverride, args: [] };
|
|
107
|
+
}
|
|
108
|
+
const packaged = resolveNativePackageBinary();
|
|
109
|
+
if (packaged) {
|
|
110
|
+
return { command: packaged, args: [] };
|
|
111
|
+
}
|
|
112
|
+
const bundled = resolveBundledBinary();
|
|
113
|
+
if (bundled) {
|
|
114
|
+
return { command: bundled, args: [] };
|
|
115
|
+
}
|
|
116
|
+
const projectRoot = resolveProjectRoot();
|
|
117
|
+
const executable = resolveExecutableName();
|
|
118
|
+
const candidates = [
|
|
119
|
+
path.join(projectRoot, "target", "release", executable),
|
|
120
|
+
path.join(projectRoot, "target", "debug", executable)
|
|
121
|
+
];
|
|
122
|
+
for (const candidate of candidates) {
|
|
123
|
+
if (fs.existsSync(candidate)) {
|
|
124
|
+
return { command: candidate, args: [] };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
command: "cargo",
|
|
129
|
+
args: ["run", "-p", "cc-gw-server", "--"],
|
|
130
|
+
cwd: projectRoot
|
|
131
|
+
};
|
|
72
132
|
}
|
|
73
133
|
function resolveWebDist() {
|
|
74
134
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -116,7 +176,6 @@ async function ensureConfigTemplate(port) {
|
|
|
116
176
|
certPath: "",
|
|
117
177
|
caPath: ""
|
|
118
178
|
},
|
|
119
|
-
// 保留旧字段以兼容
|
|
120
179
|
host: "127.0.0.1",
|
|
121
180
|
port: selectedPort,
|
|
122
181
|
providers: [],
|
|
@@ -152,6 +211,17 @@ async function ensureConfigTemplate(port) {
|
|
|
152
211
|
return true;
|
|
153
212
|
}
|
|
154
213
|
}
|
|
214
|
+
async function readConfiguredPort() {
|
|
215
|
+
try {
|
|
216
|
+
const raw = await fsp.readFile(CONFIG_FILE, "utf-8");
|
|
217
|
+
const parsed = JSON.parse(raw);
|
|
218
|
+
if (parsed && typeof parsed.port === "number" && Number.isFinite(parsed.port)) {
|
|
219
|
+
return parsed.port;
|
|
220
|
+
}
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
155
225
|
async function readPid() {
|
|
156
226
|
try {
|
|
157
227
|
const raw = await fsp.readFile(PID_FILE, "utf-8");
|
|
@@ -162,8 +232,7 @@ async function readPid() {
|
|
|
162
232
|
}
|
|
163
233
|
}
|
|
164
234
|
async function writePid(pid) {
|
|
165
|
-
if (pid == null)
|
|
166
|
-
return;
|
|
235
|
+
if (pid == null) return;
|
|
167
236
|
await fsp.writeFile(PID_FILE, String(pid), "utf-8");
|
|
168
237
|
}
|
|
169
238
|
async function removePid() {
|
|
@@ -182,8 +251,7 @@ function isProcessAlive(pid) {
|
|
|
182
251
|
}
|
|
183
252
|
async function isServiceRunning() {
|
|
184
253
|
const pid = await readPid();
|
|
185
|
-
if (!pid)
|
|
186
|
-
return { running: false };
|
|
254
|
+
if (!pid) return { running: false };
|
|
187
255
|
if (isProcessAlive(pid)) {
|
|
188
256
|
return { running: true, pid };
|
|
189
257
|
}
|
|
@@ -198,7 +266,7 @@ async function handleStart(options) {
|
|
|
198
266
|
return;
|
|
199
267
|
}
|
|
200
268
|
const configCreated = await ensureConfigTemplate(options.port);
|
|
201
|
-
const
|
|
269
|
+
const server = resolveServerCommand();
|
|
202
270
|
const env = { ...process.env };
|
|
203
271
|
if (options.port) {
|
|
204
272
|
env.PORT = options.port;
|
|
@@ -211,6 +279,7 @@ async function handleStart(options) {
|
|
|
211
279
|
}
|
|
212
280
|
const daemonMode = options.foreground ? false : options.daemon !== false;
|
|
213
281
|
const spawnOptions = {
|
|
282
|
+
cwd: server.cwd,
|
|
214
283
|
env,
|
|
215
284
|
detached: daemonMode,
|
|
216
285
|
stdio: daemonMode ? [
|
|
@@ -219,7 +288,7 @@ async function handleStart(options) {
|
|
|
219
288
|
fs.openSync(LOG_FILE, "a")
|
|
220
289
|
] : "inherit"
|
|
221
290
|
};
|
|
222
|
-
const child = spawn(
|
|
291
|
+
const child = spawn(server.command, server.args, spawnOptions);
|
|
223
292
|
child.on("error", (err) => {
|
|
224
293
|
console.error("\u542F\u52A8 cc-gw \u5931\u8D25:", err);
|
|
225
294
|
});
|
|
@@ -238,15 +307,9 @@ async function handleStart(options) {
|
|
|
238
307
|
}
|
|
239
308
|
if (configCreated) {
|
|
240
309
|
console.log(green(`\u5DF2\u5728 ${CONFIG_FILE} \u751F\u6210\u9ED8\u8BA4\u914D\u7F6E`));
|
|
241
|
-
console.log(yellow(
|
|
242
|
-
console.log(yellow(` HTTP: http://127.0.0.1:${effectivePort}/ui`));
|
|
243
|
-
console.log(yellow(` HTTPS: https://127.0.0.1:4443/ui (\u9700\u5148\u751F\u6210\u8BC1\u4E66)`));
|
|
244
|
-
}
|
|
245
|
-
if (daemonMode) {
|
|
246
|
-
console.log(green(`\u670D\u52A1\u5DF2\u542F\u52A8:`));
|
|
247
|
-
console.log(green(` HTTP: http://127.0.0.1:${effectivePort}/ui`));
|
|
248
|
-
console.log(green(` HTTPS: https://127.0.0.1:4443/ui (\u5982\u5DF2\u542F\u7528)`));
|
|
310
|
+
console.log(yellow("\u9996\u6B21\u542F\u52A8\u540E\uFF0C\u8BF7\u8BBF\u95EE Web UI \u7EE7\u7EED\u914D\u7F6E provider\u3002"));
|
|
249
311
|
}
|
|
312
|
+
console.log(green(`\u670D\u52A1\u5730\u5740: http://127.0.0.1:${effectivePort}/ui`));
|
|
250
313
|
if (!daemonMode) {
|
|
251
314
|
const forwardSignal = (signal) => {
|
|
252
315
|
if (!child.killed) {
|
|
@@ -301,7 +364,7 @@ async function handleStatus() {
|
|
|
301
364
|
console.log(`\u65E5\u5FD7\u76EE\u5F55: ${LOG_DIR}`);
|
|
302
365
|
console.log(`\u914D\u7F6E\u6587\u4EF6: ${CONFIG_FILE}`);
|
|
303
366
|
}
|
|
304
|
-
program.name("cc-gw").description("Claude Code Gateway CLI").version(CLI_VERSION);
|
|
367
|
+
program.name("cc-gw").description("Rust-backed Claude Code Gateway CLI").version(CLI_VERSION);
|
|
305
368
|
program.command("version").description("\u663E\u793A\u5F53\u524D cc-gw CLI \u7248\u672C").action(() => {
|
|
306
369
|
console.log(`cc-gw CLI \u7248\u672C: ${CLI_VERSION}`);
|
|
307
370
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,f as e,aq as w,ar as k,ac as E,a2 as I}from"./vendor-UrUELLAG.js";import{u as L}from"./useApiQuery-C4-HjWYY.js";import{u as C,B as j}from"./index-BKEgpvTe.js";import{P as S,B as o}from"./PageHeader-CbpaEUEn.js";import{P as c}from"./PageSection-6q9HngU5.js";import{C as N,a as y}from"./card-DRsnBFyp.js";import{u as B}from"./i18n-qAxAISVU.js";import"./query-BnTlXVsy.js";import"./router-Ju3lwB-M.js";import"./radix-CwKvZelb.js";const P="0.8.0-alpha.0",V={version:P},M={VITE_BUILD_TIME:"2026-03-14T02:47:41.845Z"};function v({items:a}){return a.length===0?null:e.jsx("dl",{className:"grid gap-4 sm:grid-cols-2",children:a.map(s=>e.jsx(N,{className:"surface-1",children:e.jsxs(y,{className:"pt-4",children:[e.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s.label}),e.jsx("dd",{className:"mt-1 text-sm font-semibold",children:s.value}),s.hint&&e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.hint})]})},s.label))})}function H(){var m,p,b,x,h,f,g;const{t:a}=B(),{pushToast:s}=C(),t=L(["status","gateway"],{url:"/api/status",method:"GET"},{staleTime:6e4});i.useEffect(()=>{t.isError&&t.error&&s({title:a("about.toast.statusError.title"),description:t.error.message,variant:"error"})},[t.isError,t.error,s,a]);const l=V.version,d=i.useMemo(()=>({buildTime:M.VITE_BUILD_TIME}),[]),T=i.useMemo(()=>{var r,n;return[{label:a("about.app.labels.name"),value:e.jsx("span",{className:"font-mono",children:"cc-gw"})},{label:a("about.app.labels.version"),value:e.jsxs("span",{className:"font-mono text-primary",children:["v",l]})},{label:a("about.app.labels.buildTime"),value:d.buildTime,hint:a("about.app.hint.buildTime")},{label:a("about.app.labels.runtime"),value:e.jsx("span",{className:"font-mono",children:((r=t.data)==null?void 0:r.runtime)??"rust"})},{label:a("about.app.labels.backendVersion"),value:e.jsx("span",{className:"font-mono",children:((n=t.data)==null?void 0:n.backendVersion)??"-"})}]},[l,d.buildTime,(m=t.data)==null?void 0:m.backendVersion,(p=t.data)==null?void 0:p.runtime,a]),u=i.useMemo(()=>{var r;return t.data?[{label:a("about.status.labels.host"),value:t.data.host??"127.0.0.1"},{label:a("about.status.labels.port"),value:t.data.port.toLocaleString()},{label:a("about.status.labels.providers"),value:t.data.providers.toLocaleString()},{label:a("about.status.labels.active"),value:(t.data.activeRequests??0).toLocaleString(),hint:a("about.status.hint.active")},{label:a("about.status.labels.platform"),value:t.data.platform??"-"},{label:a("about.status.labels.pid"),value:((r=t.data.pid)==null?void 0:r.toLocaleString())??"-"}]:[]},[t.data,a]),_=()=>{s({title:a("about.toast.updatesPlanned"),variant:"info"})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(S,{icon:e.jsx(k,{className:"h-5 w-5","aria-hidden":"true"}),title:a("about.title"),description:a("about.description"),badge:`v${l}`,actions:e.jsxs(j,{onClick:_,children:[e.jsx(w,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("about.support.actions.checkUpdates")]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(o,{variant:"outline",children:((b=t.data)==null?void 0:b.runtime)??"rust"}),e.jsx(o,{variant:"outline",children:((x=t.data)==null?void 0:x.platform)??"-"}),e.jsxs(o,{variant:"secondary",children:[a("about.status.labels.providers"),": ",((f=(h=t.data)==null?void 0:h.providers)==null?void 0:f.toLocaleString())??"-"]}),e.jsxs(o,{variant:"secondary",children:[a("about.status.labels.active"),": ",(((g=t.data)==null?void 0:g.activeRequests)??0).toLocaleString()]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(c,{title:a("about.app.title"),description:a("about.app.subtitle"),children:e.jsx(v,{items:T})}),e.jsx(c,{title:a("about.status.title"),description:a("about.status.subtitle"),actions:e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>t.refetch(),disabled:t.isFetching,children:[e.jsx(E,{className:`mr-2 h-4 w-4 ${t.isFetching?"animate-spin":""}`,"aria-hidden":"true"}),t.isFetching?a("common.actions.refreshing"):a("common.actions.refresh")]}),children:t.isLoading?e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-2 text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-primary border-t-transparent"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("about.status.loading")})]}):u.length>0?e.jsx(v,{items:u}):e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-1 rounded-[1.25rem] border border-dashed border-border/70 bg-background/45 p-6 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:a("about.status.empty")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("common.actions.refresh")})]})})]}),e.jsx(c,{title:a("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-medium text-primary",children:a("about.support.subtitle")}),e.jsx("span",{children:a("about.support.description")})]}),children:e.jsx(N,{className:"surface-1",children:e.jsxs(y,{className:"flex flex-col gap-4 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-2xl bg-primary/10 text-primary shadow-[inset_0_0_0_1px_rgba(59,130,246,0.08)]",children:e.jsx(I,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"flex-1 text-sm text-muted-foreground",children:a("about.support.tip")})]}),e.jsx("code",{className:"inline-flex self-start rounded-xl border border-border/70 bg-background/70 px-3 py-1.5 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}export{H as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,f as e,ai as _e,a0 as Le,ak as le,al as Ae,am as Oe,an as We,ao as Fe,O as Pe}from"./vendor-UrUELLAG.js";import{E as Re}from"./EChart-CfTG8iSv.js";import{u as P}from"./useApiQuery-C4-HjWYY.js";import{c as B,u as Ie,h as Me,B as o,a as K,t as C}from"./index-BKEgpvTe.js";import{P as qe,B as v}from"./PageHeader-CbpaEUEn.js";import{P as oe}from"./PageSection-6q9HngU5.js";import{D as R,a as I,b as M,c as q,d as de,e as z,C as ze}from"./ConfirmDialog-DwZk3ejq.js";import{c as He}from"./clipboard-CALi6bTW.js";import{I as ce}from"./input-BCUUQfiv.js";import{L as H}from"./label-CtuP7N6a.js";import{C as G,a as Q}from"./card-DRsnBFyp.js";import{u as V}from"./i18n-qAxAISVU.js";import{e as Ue}from"./charts-core-BjxPMAw_.js";import"./charts-react-BxiU3S4Y.js";import"./query-BnTlXVsy.js";import"./router-Ju3lwB-M.js";import"./radix-CwKvZelb.js";import"./charts-engine-B4YVo-Wh.js";const ue=r.forwardRef(({className:s,...i},d)=>e.jsx("textarea",{className:B("flex min-h-[96px] w-full rounded-[1.35rem] border border-border/80 bg-background/85 px-4 py-3 text-base shadow-[0_1px_2px_rgba(15,23,42,0.03)] ring-offset-background placeholder:text-muted-foreground/90 transition-all duration-200 focus-visible:border-primary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",s),ref:d,...i}));ue.displayName="Textarea";function $e(){const[s,i]=r.useState([]);return r.useEffect(()=>{const d=[{id:"anthropic",label:"Anthropic"},{id:"openai",label:"OpenAI"}];K.get("/api/custom-endpoints").then(m=>{const x=(m.data.endpoints??[]).map(c=>({id:c.id,label:c.label}));i([...d,...x])}).catch(()=>{i(d)})},[]),s}function pe({available:s,selected:i,onChange:d,hint:m}){const{t:x}=V(),c=i.length===0,k=()=>{d([])},N=l=>{i.includes(l)?d(i.filter(w=>w!==l)):d([...i,l])};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:m}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-2xl border border-border/70 bg-background/70 px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-primary/5",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:k,className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm font-medium",children:x("apiKeys.allEndpoints")})]}),e.jsx("div",{className:"grid max-h-40 gap-1 overflow-y-auto",children:s.map(l=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-2xl border border-border/70 bg-background/70 px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-primary/5",children:[e.jsx("input",{type:"checkbox",checked:!c&&i.includes(l.id),onChange:()=>N(l.id),className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm",children:l.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",l.id,")"]})]},l.id))})]})}const Be=[{value:1,labelKey:"apiKeys.analytics.range.today"},{value:7,labelKey:"apiKeys.analytics.range.week"},{value:30,labelKey:"apiKeys.analytics.range.month"}];function pa(){const{t:s}=V(),{pushToast:i}=Ie(),[d,m]=r.useState(!1),[x,c]=r.useState(""),[k,N]=r.useState(""),[l,w]=r.useState([]),[p,L]=r.useState(null),[S,J]=r.useState(null),[u,A]=r.useState(null),[y,xe]=r.useState(7),[X,Y]=r.useState(new Map),[he,Z]=r.useState(null),[g,D]=r.useState(null),[O,ee]=r.useState([]),[W,ye]=r.useState(""),[T,ge]=r.useState("all"),ae=$e(),b=P(["api-keys"],{url:"/api/keys",method:"GET"}),_=P(["api-keys","overview",y],{url:"/api/stats/api-keys/overview",method:"GET",params:{days:y}}),E=P(["api-keys","usage",y],{url:"/api/stats/api-keys/usage",method:"GET",params:{days:y,limit:10}}),f=b.data??[],j=_.data,h=E.data??[],be=f.some(a=>a.isWildcard),fe=f.filter(a=>{var t;return!a.isWildcard&&(((t=a.allowedEndpoints)==null?void 0:t.length)??0)>0}).length,je=j?j.totalKeys.toLocaleString():"-",ve=j?j.enabledKeys.toLocaleString():"-",Ke=j?j.activeKeys.toLocaleString():"-",se=r.useMemo(()=>f.filter(a=>{if(!(T==="all"||(T==="enabled"?a.enabled:!a.enabled)))return!1;const n=W.trim().toLowerCase();return n?[a.name,a.description??"",a.maskedKey??"",...a.allowedEndpoints??[]].join(" ").toLowerCase().includes(n):!0}),[f,W,T]),te=async()=>{if(!x.trim()){i({title:s("apiKeys.errors.nameRequired"),variant:"error"});return}try{const a=await K.post("/api/keys",{name:x.trim(),description:k.trim()||void 0,allowedEndpoints:l.length>0?l:void 0});L(a.data),m(!1),c(""),N(""),w([]),b.refetch(),_.refetch(),E.refetch(),i({title:s("apiKeys.toast.keyCreated"),variant:"success"})}catch(a){const t=C(a);i({title:s("apiKeys.toast.createFailure",{message:t.message}),variant:"error"})}},Ne=async(a,t)=>{try{await K.patch(`/api/keys/${a}`,{enabled:!t}),b.refetch(),_.refetch(),i({title:s("apiKeys.toast.keyUpdated"),variant:"success"})}catch(n){const F=C(n);i({title:s("apiKeys.toast.updateFailure",{message:F.message}),variant:"error"})}},we=async()=>{if(u){J(u.id);try{await K.delete(`/api/keys/${u.id}`),b.refetch(),_.refetch(),E.refetch(),i({title:s("apiKeys.toast.keyDeleted"),variant:"success"}),A(null)}catch(a){const t=C(a);i({title:s("apiKeys.toast.deleteFailure",{message:t.message}),variant:"error"})}finally{J(null)}}},Ee=async a=>{if(!X.has(a)){Z(a);try{const t=await K.get(`/api/keys/${a}/reveal`);Y(n=>new Map(n).set(a,t.data.key))}catch(t){const n=C(t);i({title:s("apiKeys.toast.revealFailure"),description:n.message,variant:"error"})}finally{Z(null)}}},Ce=a=>{Y(t=>{const n=new Map(t);return n.delete(a),n})},ie=async a=>{try{await He(a),i({title:s("apiKeys.toast.keyCopied"),variant:"success"})}catch(t){i({title:s("apiKeys.toast.copyFailure"),description:t instanceof Error?t.message:s("common.unknownError"),variant:"error"})}},ke=r.useCallback(a=>{D(a),ee(a.allowedEndpoints??[])},[]),Se=async()=>{if(g)try{await K.patch(`/api/keys/${g.id}`,{allowedEndpoints:O.length>0?O:null}),D(null),b.refetch(),i({title:s("apiKeys.toast.keyUpdated"),variant:"success"})}catch(a){const t=C(a);i({title:s("apiKeys.toast.updateFailure",{message:t.message}),variant:"error"})}},re=a=>a?new Date(a).toLocaleString():s("common.noData"),De=r.useMemo(()=>{const a=h.map(t=>t.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:a,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.requestsSeries"),type:"bar",data:h.map(t=>t.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[h,s]),Te=r.useMemo(()=>{const a=h.map(t=>t.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[s("apiKeys.analytics.tokens.input"),s("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:a,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:h.map(t=>t.inputTokens)},{name:s("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:h.map(t=>t.outputTokens)}]}},[h,s]);return b.isLoading?e.jsx(Me,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(qe,{icon:e.jsx(Le,{className:"h-5 w-5","aria-hidden":"true"}),title:s("apiKeys.title"),description:s("apiKeys.description"),actions:e.jsxs(o,{onClick:()=>m(!0),children:[e.jsx(_e,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),s("apiKeys.createNew")]})}),e.jsx(oe,{title:s("apiKeys.analytics.title"),description:s("apiKeys.analytics.description",{days:y}),actions:e.jsx("div",{className:"flex items-center gap-1 rounded-full border border-border/70 bg-background/80 p-1 shadow-[0_1px_2px_rgba(15,23,42,0.03)]",children:Be.map(a=>{const t=y===a.value;return e.jsx("button",{type:"button",onClick:()=>xe(a.value),className:B("inline-flex h-8 items-center rounded-full px-3.5 text-xs font-medium transition-all",t?"bg-primary text-primary-foreground shadow-[0_8px_18px_-14px_rgba(59,130,246,0.7)]":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:s(a.labelKey)},a.value)})}),children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(U,{label:s("apiKeys.analytics.cards.total"),value:je}),e.jsx(U,{label:s("apiKeys.analytics.cards.enabled"),value:ve}),e.jsx(U,{label:s("apiKeys.analytics.cards.active",{days:y}),value:Ke})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(me,{title:s("apiKeys.analytics.charts.requests"),loading:E.isLoading,empty:h.length===0,emptyText:s("apiKeys.analytics.empty"),option:De}),e.jsx(me,{title:s("apiKeys.analytics.charts.tokens"),loading:E.isLoading,empty:h.length===0,emptyText:s("apiKeys.analytics.empty"),option:Te})]})]})}),e.jsx(oe,{title:s("apiKeys.list.title"),description:be?s("apiKeys.wildcardHint"):void 0,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 rounded-2xl border border-white/40 bg-card/80 p-4 md:grid-cols-[minmax(0,1fr)_180px_auto]",children:[e.jsx(ce,{value:W,onChange:a=>ye(a.target.value),placeholder:s("apiKeys.filters.searchPlaceholder")}),e.jsx("div",{className:"flex items-center gap-1 rounded-full border border-border/70 bg-background/80 p-1 shadow-[0_1px_2px_rgba(15,23,42,0.03)]",children:["all","enabled","disabled"].map(a=>e.jsx("button",{type:"button",onClick:()=>ge(a),className:B("inline-flex h-8 items-center rounded-full px-3.5 text-xs font-medium transition-all",T===a?"bg-primary text-primary-foreground shadow-[0_8px_18px_-14px_rgba(59,130,246,0.7)]":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:s(`apiKeys.filters.${a}`)},a))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(v,{variant:"outline",children:s("apiKeys.summary.wildcard",{count:f.filter(a=>a.isWildcard).length})}),e.jsx(v,{variant:"outline",children:s("apiKeys.summary.restricted",{count:fe})})]})]}),f.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:s("apiKeys.list.empty")})}):se.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:s("apiKeys.list.emptyFiltered")})}):e.jsx("div",{className:"grid gap-4",children:se.map(a=>{const t=(a.totalInputTokens+a.totalOutputTokens).toLocaleString(),n=X.get(a.id),F=he===a.id;return e.jsx(G,{className:"border-white/40 bg-card/90 backdrop-blur",children:e.jsx(Q,{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold",children:a.name}),a.isWildcard&&e.jsx(v,{variant:"secondary",children:s("apiKeys.wildcard")}),e.jsx(v,{variant:a.enabled?"default":"outline",children:a.enabled?s("apiKeys.status.enabled"):s("apiKeys.status.disabled")}),!a.isWildcard&&a.allowedEndpoints&&a.allowedEndpoints.length>0?a.allowedEndpoints.map(ne=>e.jsx(v,{variant:"outline",className:"text-xs",children:ne},ne)):a.isWildcard?null:e.jsx(v,{variant:"secondary",className:"text-xs opacity-60",children:s("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx($,{label:s("apiKeys.requestCount"),value:a.requestCount.toLocaleString()}),e.jsx($,{label:s("apiKeys.totalTokens"),value:t}),e.jsx($,{label:s("apiKeys.allowedEndpoints"),value:a.isWildcard?s("apiKeys.wildcard"):a.allowedEndpoints&&a.allowedEndpoints.length>0?a.allowedEndpoints.join(", "):s("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"rounded-xl border border-border/70 bg-background/70 px-3 py-1.5 font-mono text-sm",children:a.isWildcard?s("apiKeys.wildcard"):n??a.maskedKey??"********"}),!a.isWildcard&&e.jsx("div",{className:"flex items-center gap-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void ie(n),"aria-label":s("common.actions.copy"),title:s("common.actions.copy"),children:e.jsx(le,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ce(a.id),"aria-label":s("apiKeys.actions.hide"),title:s("apiKeys.actions.hide"),children:e.jsx(Ae,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void Ee(a.id),disabled:F,"aria-label":s("apiKeys.actions.reveal"),title:s("apiKeys.actions.reveal"),children:e.jsx(Oe,{className:"h-4 w-4","aria-hidden":"true"})})})]}),a.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("apiKeys.wildcardHint")}):a.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:a.description}):null,e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:re(a.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:re(a.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!a.isWildcard&&e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>ke(a),children:[e.jsx(We,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),s("apiKeys.editEndpoints")]}),e.jsx(o,{variant:a.enabled?"outline":"default",size:"sm",onClick:()=>Ne(a.id,a.enabled),children:a.enabled?s("apiKeys.actions.disable"):s("apiKeys.actions.enable")}),!a.isWildcard&&e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>A(a),disabled:S===a.id,"aria-label":s("apiKeys.actions.delete"),children:e.jsx(Fe,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})},a.id)})})]})}),e.jsx(R,{open:d,onOpenChange:m,children:e.jsxs(I,{children:[e.jsxs(M,{children:[e.jsx(q,{children:s("apiKeys.createNew")}),e.jsx(de,{children:s("apiKeys.createDescription")})]}),e.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(H,{htmlFor:"keyName",children:[s("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(ce,{id:"keyName",value:x,onChange:a=>c(a.target.value),placeholder:s("apiKeys.keyNamePlaceholder"),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),te())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{htmlFor:"keyDescription",children:s("apiKeys.descriptionLabel")}),e.jsx(ue,{id:"keyDescription",value:k,onChange:a=>N(a.target.value),placeholder:s("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:s("apiKeys.allowedEndpoints")}),e.jsx(pe,{available:ae,selected:l,onChange:w,hint:s("apiKeys.selectEndpoints")})]})]}),e.jsxs(z,{children:[e.jsx(o,{variant:"outline",onClick:()=>{m(!1),c(""),N(""),w([])},children:s("common.actions.cancel")}),e.jsx(o,{onClick:()=>void te(),children:s("apiKeys.createAction")})]})]})}),e.jsx(R,{open:!!p,onOpenChange:()=>L(null),children:e.jsxs(I,{children:[e.jsx(M,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-600",children:e.jsx(Pe,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(q,{children:s("apiKeys.keyCreated")})]})}),e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:s("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-[1.1rem] border border-border/70 bg-background/70 px-4 py-3 font-mono text-sm",children:p==null?void 0:p.key}),(p==null?void 0:p.description)&&e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:p.description}),e.jsxs(z,{children:[e.jsxs(o,{onClick:()=>void ie((p==null?void 0:p.key)??""),children:[e.jsx(le,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),s("common.actions.copy")]}),e.jsx(o,{variant:"outline",onClick:()=>L(null),children:s("common.actions.close")})]})]})}),e.jsx(R,{open:!!g,onOpenChange:a=>{a||D(null)},children:e.jsxs(I,{children:[e.jsxs(M,{children:[e.jsx(q,{children:s("apiKeys.editEndpoints")}),e.jsx(de,{children:g==null?void 0:g.name})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto",children:e.jsx(pe,{available:ae,selected:O,onChange:ee,hint:s("apiKeys.selectEndpoints")})}),e.jsxs(z,{children:[e.jsx(o,{variant:"outline",onClick:()=>D(null),children:s("common.actions.cancel")}),e.jsx(o,{onClick:()=>void Se(),children:s("common.save")})]})]})}),e.jsx(ze,{open:!!u,onOpenChange:a=>{!a&&S===null&&A(null)},title:s("apiKeys.deleteDialogTitle"),description:s("apiKeys.confirmDelete"),confirmLabel:u&&S===u.id?s("common.actions.loading"):s("apiKeys.actions.delete"),cancelLabel:s("common.actions.cancel"),loading:u?S===u.id:!1,onConfirm:we,children:u?e.jsx("div",{className:"rounded-[1.1rem] border border-destructive/20 bg-destructive/5 px-3 py-2 font-mono text-xs text-foreground",children:u.name}):null})]})}function U({label:s,value:i}){return e.jsx(G,{className:"surface-1",children:e.jsxs(Q,{className:"pt-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("p",{className:"mt-2 text-2xl font-semibold",children:i})]})})}function $({label:s,value:i}){return e.jsxs("div",{className:"rounded-xl border border-border/70 bg-background/60 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:i})]})}function me({title:s,option:i,loading:d,empty:m,emptyText:x}){const{t:c}=V();return e.jsx(G,{className:"surface-1",children:e.jsxs(Q,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:s}),d?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:c("common.loadingShort")})}):m?e.jsx("div",{className:"flex h-[280px] items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:x})}):e.jsx(Re,{echarts:Ue,option:i,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}export{pa as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,f as a,a4 as w}from"./vendor-UrUELLAG.js";import{F as k,G as C,H as c,J as R,K as m,M as x,O as f}from"./radix-CwKvZelb.js";import{c as o,B as i}from"./index-BKEgpvTe.js";const z=k,_=C,p=r.forwardRef(({className:s,...e},t)=>a.jsx(f,{ref:t,className:o("fixed inset-0 z-50 bg-slate-950/45 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...e}));p.displayName=f.displayName;const u=r.forwardRef(({className:s,children:e,...t},l)=>a.jsxs(_,{children:[a.jsx(p,{}),a.jsxs(c,{ref:l,className:o("fixed left-[50%] top-[50%] z-50 flex max-h-[85vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-[1.5rem] border border-white/60 bg-background/96 p-6 shadow-[0_24px_64px_-28px_rgba(15,23,42,0.42)] backdrop-blur duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",s),...t,children:[e,a.jsxs(R,{className:"absolute right-4 top-4 rounded-2xl border border-transparent p-2 opacity-70 ring-offset-background transition-all hover:border-border hover:bg-accent hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[a.jsx(w,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));u.displayName=c.displayName;const g=({className:s,...e})=>a.jsx("div",{className:o("flex shrink-0 flex-col space-y-1.5 text-center sm:text-left",s),...e});g.displayName="DialogHeader";const b=({className:s,...e})=>a.jsx("div",{className:o("flex shrink-0 flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...e});b.displayName="DialogFooter";const j=r.forwardRef(({className:s,...e},t)=>a.jsx(m,{ref:t,className:o("text-lg font-semibold leading-none tracking-[-0.02em]",s),...e}));j.displayName=m.displayName;const h=r.forwardRef(({className:s,...e},t)=>a.jsx(x,{ref:t,className:o("text-sm leading-6 text-muted-foreground",s),...e}));h.displayName=x.displayName;function E({open:s,onOpenChange:e,title:t,description:l,confirmLabel:N,cancelLabel:y,onConfirm:v,loading:d=!1,confirmVariant:D="destructive",children:n}){return a.jsx(z,{open:s,onOpenChange:e,children:a.jsxs(u,{className:"max-w-md",children:[a.jsxs(g,{children:[a.jsx(j,{children:t}),l?a.jsx(h,{children:l}):null]}),n?a.jsx("div",{className:"text-sm text-muted-foreground",children:n}):null,a.jsxs(b,{children:[a.jsx(i,{variant:"outline",onClick:()=>e(!1),disabled:d,children:y}),a.jsx(i,{variant:D,onClick:()=>void v(),disabled:d,children:N})]})]})})}export{E as C,z as D,u as a,g as b,j as c,h as d,b as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,f as e,X as F,a8 as Q,a9 as fe,aa as je}from"./vendor-UrUELLAG.js";import{E as ye}from"./EChart-CfTG8iSv.js";import{S as ve,C as Ne,T as Te}from"./Skeleton-DFeA7kZw.js";import{P as de,B as A}from"./PageHeader-CbpaEUEn.js";import{P as le}from"./PageSection-6q9HngU5.js";import{c as v,u as Ce,a as Se,t as ke,B as Ee}from"./index-BKEgpvTe.js";import{u as R}from"./useApiQuery-C4-HjWYY.js";import{C as V,a as z}from"./card-DRsnBFyp.js";import{S as Le,a as Re,b as we,c as qe,d as D}from"./select-C-e-41FP.js";import{u as G}from"./i18n-qAxAISVU.js";import{e as Ae}from"./charts-core-BjxPMAw_.js";import"./charts-react-BxiU3S4Y.js";import"./router-Ju3lwB-M.js";import"./radix-CwKvZelb.js";import"./query-BnTlXVsy.js";import"./charts-engine-B4YVo-Wh.js";const U=l.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:"relative w-full overflow-auto rounded-[1.25rem] border border-border/60 bg-background/45",children:e.jsx("table",{ref:s,className:v("w-full caption-bottom border-collapse text-sm",t),...a})}));U.displayName="Table";const Y=l.forwardRef(({className:t,...a},s)=>e.jsx("thead",{ref:s,className:v("bg-muted/35 [&_tr]:border-b [&_tr]:border-border/60",t),...a}));Y.displayName="TableHeader";const K=l.forwardRef(({className:t,...a},s)=>e.jsx("tbody",{ref:s,className:v("[&_tr:last-child]:border-0",t),...a}));K.displayName="TableBody";const Me=l.forwardRef(({className:t,...a},s)=>e.jsx("tfoot",{ref:s,className:v("border-t bg-muted/45 font-medium [&>tr]:last:border-b-0",t),...a}));Me.displayName="TableFooter";const P=l.forwardRef(({className:t,...a},s)=>e.jsx("tr",{ref:s,className:v("border-b border-border/50 transition-all duration-150","hover:bg-primary/5 data-[state=selected]:bg-primary/10","group",t),...a}));P.displayName="TableRow";const x=l.forwardRef(({className:t,...a},s)=>e.jsx("th",{ref:s,className:v("h-12 px-4 text-left align-middle text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/80","[&:has([role=checkbox])]:pr-0",t),...a}));x.displayName="TableHead";const p=l.forwardRef(({className:t,...a},s)=>e.jsx("td",{ref:s,className:v("px-4 py-3.5 align-middle text-sm","[&:has([role=checkbox])]:pr-0","group-hover:text-foreground transition-colors",t),...a}));p.displayName="TableCell";const Ie=l.forwardRef(({className:t,...a},s)=>e.jsx("caption",{ref:s,className:v("mt-4 text-sm text-muted-foreground",t),...a}));Ie.displayName="TableCaption";function _(t,a,s){return t==null?"-":`${t.toLocaleString(void 0,s)} ${a}`}function ne(t){if(t==null)return"-";if(t<1024)return`${t} B`;const a=["KB","MB","GB","TB"];let s=t/1024,u=0;for(;s>=1024&&u<a.length-1;)s/=1024,u+=1;return`${s.toFixed(s>=100?0:s>=10?1:2)} ${a[u]}`}const y={requests:"#3b82f6",input:"#10b981",output:"#f59e0b",cacheRead:"#8b5cf6",cacheCreation:"#f43f5e"};function et(){var Z,ee,te,se,ae,re;const{t}=G(),{pushToast:a}=Ce(),[s,u]=l.useState("all"),[i,o]=l.useState(!1),h=s==="all"?void 0:s,X=R(["custom-endpoints"],{url:"/api/custom-endpoints",method:"GET"}),S=R(["stats","overview",s],{url:"/api/stats/overview",method:"GET",params:h?{endpoint:h}:void 0}),k=R(["stats","daily",14,s],{url:"/api/stats/daily",method:"GET",params:{days:14,...h?{endpoint:h}:{}}}),f=R(["stats","model",7,6,s],{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...h?{endpoint:h}:{}}}),E=R(["status",s],{url:"/api/status",method:"GET",params:h?{endpoint:h}:void 0}),C=R(["db","info"],{url:"/api/db/info",method:"GET"}),J=C.refetch??(async()=>{}),L=R(["logs","recent",s],{url:"/api/logs",method:"GET",params:{limit:5,...h?{endpoint:h}:{}}},{refetchInterval:3e4});l.useEffect(()=>{S.isError&&S.error&&a({title:t("dashboard.toast.overviewError"),description:S.error.message,variant:"error"})},[S.isError,S.error,a,t]),l.useEffect(()=>{k.isError&&k.error&&a({title:t("dashboard.toast.dailyError"),description:k.error.message,variant:"error"})},[k.isError,k.error,a,t]),l.useEffect(()=>{f.isError&&f.error&&a({title:t("dashboard.toast.modelError"),description:f.error.message,variant:"error"})},[f.isError,f.error,a,t]),l.useEffect(()=>{E.isError&&E.error&&a({title:t("dashboard.toast.statusError"),description:E.error.message,variant:"error"})},[E.isError,E.error,a,t]),l.useEffect(()=>{C.isError&&C.error&&a({title:t("dashboard.toast.dbError"),description:C.error.message,variant:"error"})},[C.isError,C.error,a,t]);const ie=l.useCallback(async()=>{if(!i){o(!0);try{await Se.post("/api/db/compact"),await J(),a({title:t("dashboard.toast.compactSuccess.title"),description:t("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(r){const d=ke(r);a({title:t("dashboard.toast.compactError.title"),description:d.message,variant:"error"})}finally{o(!1)}}},[i,a,J,t]);l.useEffect(()=>{L.isError&&L.error&&a({title:t("dashboard.toast.recentError"),description:L.error.message,variant:"error"})},[L.isError,L.error,a,t]);const n=S.data,j=k.data??[],c=f.data??[],N=E.data,w=C.data,ce=((Z=L.data)==null?void 0:Z.items)??[],me=w?ne(w.totalBytes??w.sizeBytes):"-",ue=ne(w==null?void 0:w.memoryRssBytes),W=s==="all"?t("dashboard.filters.endpointAll"):s==="anthropic"?t("dashboard.filters.endpointAnthropic"):s==="openai"?t("dashboard.filters.endpointOpenAI"):((se=(te=(ee=X.data)==null?void 0:ee.endpoints)==null?void 0:te.find(r=>r.id===s))==null?void 0:se.label)||s,he=j.reduce((r,d)=>r+d.requestCount,0),$=j.reduce((r,d)=>!r||d.requestCount>r.requestCount?d:r,null),M=c[0],I=c.filter(r=>r.avgTtftMs!=null&&r.avgTtftMs>0).sort((r,d)=>(r.avgTtftMs??Number.POSITIVE_INFINITY)-(d.avgTtftMs??Number.POSITIVE_INFINITY))[0],xe=l.useMemo(()=>{const r=j.map(g=>g.date),d=t("dashboard.charts.barRequests"),m=t("dashboard.charts.lineInput"),B=t("dashboard.charts.lineOutput"),b=t("dashboard.charts.lineCacheRead"),oe=t("dashboard.charts.lineCacheCreation");return{tooltip:{trigger:"axis"},legend:{data:[d,m,B,b,oe]},grid:{left:60,right:40,top:60,bottom:60},xAxis:{type:"category",data:r},yAxis:{type:"value"},series:[{name:d,type:"bar",data:j.map(g=>g.requestCount),itemStyle:{color:y.requests,borderRadius:[4,4,0,0]}},{name:m,type:"line",data:j.map(g=>g.inputTokens),smooth:!0,itemStyle:{color:y.input},lineStyle:{width:2}},{name:B,type:"line",data:j.map(g=>g.outputTokens),smooth:!0,itemStyle:{color:y.output},lineStyle:{width:2}},{name:b,type:"line",data:j.map(g=>g.cacheReadTokens),smooth:!0,itemStyle:{color:y.cacheRead},lineStyle:{width:2}},{name:oe,type:"line",data:j.map(g=>g.cacheCreationTokens),smooth:!0,itemStyle:{color:y.cacheCreation},lineStyle:{width:2}}]}},[j,t]),pe=l.useMemo(()=>{const r=c.map(b=>`${b.provider}/${b.model}`),d=t("dashboard.charts.barRequests"),m=t("dashboard.charts.lineInput"),B=t("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis"},legend:{data:[d,m,B]},grid:{left:80,right:60,top:60,bottom:100},xAxis:{type:"category",data:r,axisLabel:{rotate:30}},yAxis:[{type:"value",name:d},{type:"value",name:t("dashboard.charts.axisTokens"),position:"right"}],series:[{name:d,type:"bar",data:c.map(b=>b.requests),itemStyle:{color:y.requests,borderRadius:[4,4,0,0]}},{name:m,type:"line",yAxisIndex:1,smooth:!0,data:c.map(b=>b.inputTokens??0),itemStyle:{color:y.input}},{name:B,type:"line",yAxisIndex:1,smooth:!0,data:c.map(b=>b.outputTokens??0),itemStyle:{color:y.output}}]}},[c,t]),be=l.useMemo(()=>{const r=c.map(m=>`${m.provider}/${m.model}`),d=t("dashboard.charts.ttftLabel");return{tooltip:{trigger:"axis"},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:r,axisLabel:{rotate:30}},yAxis:{type:"value",name:t("dashboard.charts.ttftAxis")},series:[{name:d,type:"bar",data:c.map(m=>m.avgTtftMs??0),itemStyle:{color:y.requests,borderRadius:[4,4,0,0]}}]}},[c,t]),ge=l.useMemo(()=>{const r=c.map(m=>`${m.provider}/${m.model}`),d=t("dashboard.charts.tpotLabel");return{tooltip:{trigger:"axis"},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:r,axisLabel:{rotate:30}},yAxis:{type:"value",name:t("dashboard.charts.tpotAxis")},series:[{name:d,type:"bar",data:c.map(m=>m.avgTpotMs??0),itemStyle:{color:y.output,borderRadius:[4,4,0,0]}}]}},[c,t]);return S.isPending||E.isPending||C.isPending?e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(de,{icon:e.jsx(F,{className:"h-5 w-5","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description")}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:Array.from({length:6}).map((r,d)=>e.jsx(ve,{},d))}),e.jsx("div",{className:"grid gap-6 lg:grid-cols-2",children:Array.from({length:4}).map((r,d)=>e.jsx(Ne,{},d))}),e.jsx("div",{className:"rounded-[1.25rem] border border-border/70 bg-background/55",children:e.jsx("table",{className:"w-full",children:e.jsx("tbody",{children:Array.from({length:5}).map((r,d)=>e.jsx(Te,{columns:6},d))})})})]}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(de,{icon:e.jsx(F,{className:"h-5 w-5","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description"),badge:W,actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t("dashboard.filters.endpoint")}),e.jsxs(Le,{value:s,onValueChange:u,children:[e.jsx(Re,{className:"w-[140px]",children:e.jsx(we,{})}),e.jsxs(qe,{children:[e.jsx(D,{value:"all",children:t("dashboard.filters.endpointAll")}),e.jsx(D,{value:"anthropic",children:t("dashboard.filters.endpointAnthropic")}),e.jsx(D,{value:"openai",children:t("dashboard.filters.endpointOpenAI")}),(re=(ae=X.data)==null?void 0:ae.endpoints)==null?void 0:re.map(r=>e.jsx(D,{value:r.id,children:r.label||r.id},r.id))]})]})]})}),N&&e.jsx(V,{className:"surface-1",children:e.jsxs(z,{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-emerald-300/90 bg-emerald-50 px-3.5 py-2 text-sm shadow-[0_10px_24px_-20px_rgba(5,150,105,0.85)] dark:border-emerald-800 dark:bg-emerald-950/50",children:[e.jsx("span",{className:"font-semibold text-emerald-800 dark:text-emerald-200",children:t("dashboard.status.listeningLabel")}),e.jsxs("span",{className:"font-mono text-[13px] font-semibold tracking-normal text-emerald-950 dark:text-emerald-50",children:[N.host??"0.0.0.0",":",N.port]})]}),e.jsx(A,{variant:"outline",children:W})]}),e.jsx(Ee,{variant:"outline",size:"sm",onClick:ie,disabled:i,children:t(i?"dashboard.actions.compacting":"dashboard.actions.compact")})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4 2xl:grid-cols-8",children:[e.jsx(T,{label:t("dashboard.labels.providers"),value:N.providers.toLocaleString()}),e.jsx(T,{label:t("dashboard.labels.activeRequests"),value:(N.activeRequests??0).toLocaleString()}),e.jsx(T,{label:t("dashboard.labels.activeClientAddresses"),value:(N.activeClientAddresses??0).toLocaleString()}),e.jsx(T,{label:t("dashboard.labels.activeClientSessions"),value:(N.activeClientSessions??0).toLocaleString()}),e.jsx(T,{label:t("dashboard.labels.uniqueClientAddressesLastHour"),value:(N.uniqueClientAddressesLastHour??0).toLocaleString()}),e.jsx(T,{label:t("dashboard.labels.uniqueClientSessionsLastHour"),value:(N.uniqueClientSessionsLastHour??0).toLocaleString()}),e.jsx(T,{label:t("dashboard.labels.todayRequests"),value:((n==null?void 0:n.today.requests)??0).toLocaleString()}),e.jsx(T,{label:t("dashboard.labels.database"),value:me}),e.jsx(T,{label:t("dashboard.labels.memory"),value:ue})]})]})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(q,{icon:e.jsx(Q,{className:"h-5 w-5"}),title:t("dashboard.cards.todayRequests"),value:(n==null?void 0:n.today.requests)??0,suffix:t("common.units.request"),color:"blue"}),e.jsx(q,{icon:e.jsx(fe,{className:"h-5 w-5"}),title:t("dashboard.cards.todayInput"),value:(n==null?void 0:n.today.inputTokens)??0,suffix:t("common.units.token"),color:"emerald"}),e.jsx(q,{icon:e.jsx(Q,{className:"h-5 w-5"}),title:t("dashboard.cards.todayCacheRead"),value:(n==null?void 0:n.today.cacheReadTokens)??0,suffix:t("common.units.token"),color:"violet"}),e.jsx(q,{icon:e.jsx(Q,{className:"h-5 w-5"}),title:t("dashboard.cards.todayCacheCreation"),value:(n==null?void 0:n.today.cacheCreationTokens)??0,suffix:t("common.units.token"),color:"rose"}),e.jsx(q,{icon:e.jsx(F,{className:"h-5 w-5"}),title:t("dashboard.cards.todayOutput"),value:(n==null?void 0:n.today.outputTokens)??0,suffix:t("common.units.token"),color:"amber"}),e.jsx(q,{icon:e.jsx(je,{className:"h-5 w-5"}),title:t("dashboard.cards.avgLatency"),value:(n==null?void 0:n.today.avgLatencyMs)??0,suffix:t("common.units.ms"),color:"cyan"})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsx(O,{label:t("dashboard.insights.totalRequests"),value:he.toLocaleString(),hint:t("dashboard.insights.totalRequestsHint")}),e.jsx(O,{label:t("dashboard.insights.busiestDay"),value:$?`${$.date}`:"-",hint:$?t("dashboard.insights.busiestDayHint",{value:$.requestCount.toLocaleString()}):t("common.noData")}),e.jsx(O,{label:t("dashboard.insights.topModel"),value:M?`${M.provider}/${M.model}`:"-",hint:M?t("dashboard.insights.topModelHint",{value:M.requests.toLocaleString()}):t("common.noData")}),e.jsx(O,{label:t("dashboard.insights.fastestTtft"),value:I?`${I.provider}/${I.model}`:"-",hint:I?_(I.avgTtftMs,t("common.units.ms")):t("common.noData")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(H,{title:t("dashboard.charts.requestsTitle"),description:t("dashboard.charts.requestsDesc"),loading:k.isPending,option:xe,empty:!j.length,emptyText:t("dashboard.charts.empty")}),e.jsx(H,{title:t("dashboard.charts.modelTitle"),description:t("dashboard.charts.modelDesc"),loading:f.isPending,option:pe,empty:!c.length,emptyText:t("dashboard.charts.empty")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(H,{title:t("dashboard.charts.ttftTitle"),description:t("dashboard.charts.ttftDesc"),loading:f.isPending,option:be,empty:!c.some(r=>r.avgTtftMs!=null&&r.avgTtftMs>0),emptyText:t("dashboard.charts.ttftEmpty")}),e.jsx(H,{title:t("dashboard.charts.tpotTitle"),description:t("dashboard.charts.tpotDesc"),loading:f.isPending,option:ge,empty:!c.some(r=>r.avgTpotMs!=null&&r.avgTpotMs>0),emptyText:t("dashboard.charts.tpotEmpty")})]}),e.jsx(_e,{models:c,loading:f.isPending}),e.jsx(Pe,{loading:L.isPending,records:ce})]})}const Be={blue:{gradient:"bg-gradient-to-br from-blue-500/10 via-blue-500/5 to-transparent",iconBg:"bg-blue-500/15",iconColor:"text-blue-600 dark:text-blue-400"},emerald:{gradient:"bg-gradient-to-br from-emerald-500/10 via-emerald-500/5 to-transparent",iconBg:"bg-emerald-500/15",iconColor:"text-emerald-600 dark:text-emerald-400"},amber:{gradient:"bg-gradient-to-br from-amber-500/10 via-amber-500/5 to-transparent",iconBg:"bg-amber-500/15",iconColor:"text-amber-600 dark:text-amber-400"},violet:{gradient:"bg-gradient-to-br from-violet-500/10 via-violet-500/5 to-transparent",iconBg:"bg-violet-500/15",iconColor:"text-violet-600 dark:text-violet-400"},rose:{gradient:"bg-gradient-to-br from-rose-500/10 via-rose-500/5 to-transparent",iconBg:"bg-rose-500/15",iconColor:"text-rose-600 dark:text-rose-400"},cyan:{gradient:"bg-gradient-to-br from-cyan-500/10 via-cyan-500/5 to-transparent",iconBg:"bg-cyan-500/15",iconColor:"text-cyan-600 dark:text-cyan-400"}};function q({icon:t,title:a,value:s,suffix:u,color:i="blue"}){const o=Be[i];return e.jsx(V,{variant:"interactive",className:v("overflow-hidden",o.gradient),children:e.jsxs(z,{className:"pt-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:a}),t&&e.jsx("div",{className:v("flex h-10 w-10 items-center justify-center rounded-xl",o.iconBg,o.iconColor),children:t})]}),e.jsxs("p",{className:"text-3xl font-bold tracking-tight",children:[s.toLocaleString(),u&&e.jsx("span",{className:"ml-1.5 text-sm font-medium text-muted-foreground",children:u})]})]})})}function T({label:t,value:a}){return e.jsxs("div",{className:"rounded-2xl border border-border/70 bg-background/70 px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:t}),e.jsx("p",{className:"mt-2 text-lg font-semibold",children:a})]})}function O({label:t,value:a,hint:s}){return e.jsxs("div",{className:"rounded-[1.3rem] border border-white/50 bg-card/90 px-4 py-4 shadow-[0_1px_2px_rgba(15,23,42,0.03)] backdrop-blur",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:t}),e.jsx("p",{className:"mt-2 line-clamp-1 text-sm font-semibold",children:a}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]})}function H({title:t,description:a,option:s,loading:u,empty:i,emptyText:o}){const{t:h}=G();return e.jsx(V,{className:"surface-1",children:e.jsxs(z,{className:"space-y-4 pt-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-semibold",children:t}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a})]}),u?e.jsx("div",{className:"flex min-h-[280px] h-[40vh] max-h-[420px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:h("common.loadingShort")})}):i?e.jsxs("div",{className:"flex min-h-[280px] h-[40vh] max-h-[420px] flex-col items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:[e.jsx(F,{className:"mb-2 h-10 w-10 text-muted-foreground/50"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:o??h("dashboard.charts.empty")})]}):e.jsx(ye,{echarts:Ae,option:s,className:"min-h-[280px] h-[40vh] max-h-[420px]",notMerge:!0,lazyUpdate:!0})]})})}function _e({models:t,loading:a}){const{t:s}=G(),u=t.length>0;return e.jsx(le,{title:s("dashboard.modelTable.title"),description:s("dashboard.modelTable.description"),children:a?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.loadingShort")})}):u?e.jsx("div",{className:"max-h-80 overflow-auto rounded-[1.2rem]",children:e.jsxs(U,{children:[e.jsx(Y,{children:e.jsxs(P,{children:[e.jsx(x,{children:s("dashboard.modelTable.columns.model")}),e.jsx(x,{className:"text-right",children:s("dashboard.modelTable.columns.requests")}),e.jsx(x,{className:"text-right",children:s("dashboard.modelTable.columns.latency")}),e.jsx(x,{className:"text-right",children:s("dashboard.modelTable.columns.ttft")}),e.jsx(x,{className:"text-right",children:s("dashboard.modelTable.columns.tpot")})]})}),e.jsx(K,{children:t.map(i=>e.jsxs(P,{children:[e.jsx(p,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:i.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i.model})]})}),e.jsx(p,{className:"text-right font-medium",children:i.requests.toLocaleString()}),e.jsx(p,{className:"text-right",children:_(i.avgLatencyMs,s("common.units.ms"))}),e.jsx(p,{className:"text-right",children:_(i.avgTtftMs,s("common.units.ms"))}),e.jsx(p,{className:"text-right",children:_(i.avgTpotMs,s("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${i.provider}/${i.model}`))})]})}):e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard.modelTable.empty")})})})}function Pe({records:t,loading:a}){const{t:s}=G(),u=t.filter(o=>!o.error&&(o.status_code??200)<400).length,i=t.filter(o=>o.error||(o.status_code??200)>=400).length;return e.jsx(le,{title:s("dashboard.recent.title"),description:s("dashboard.recent.subtitle",{count:5}),children:a?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard.recent.loading")})}):t.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard.recent.empty")})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(A,{variant:"secondary",children:t.length}),e.jsxs(A,{variant:"outline",className:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",children:[s("common.status.success"),": ",u]}),e.jsxs(A,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[s("common.status.error"),": ",i]})]}),e.jsx("div",{className:"max-h-80 overflow-auto rounded-[1.2rem]",children:e.jsxs(U,{children:[e.jsx(Y,{children:e.jsxs(P,{children:[e.jsx(x,{children:s("dashboard.recent.columns.time")}),e.jsx(x,{children:s("dashboard.recent.columns.endpoint")}),e.jsx(x,{children:s("dashboard.recent.columns.provider")}),e.jsx(x,{children:s("dashboard.recent.columns.route")}),e.jsx(x,{className:"text-right",children:s("dashboard.recent.columns.latency")}),e.jsx(x,{children:s("dashboard.recent.columns.status")})]})}),e.jsx(K,{children:t.map(o=>e.jsxs(P,{children:[e.jsx(p,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium",children:new Date(o.timestamp).toLocaleString()}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["#",o.id]})]})}),e.jsx(p,{children:e.jsx(A,{variant:"outline",className:"text-[11px]",children:o.endpoint==="anthropic"?s("logs.table.endpointAnthropic"):o.endpoint==="openai"?s("logs.table.endpointOpenAI"):o.endpoint})}),e.jsx(p,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:o.provider}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:o.stream?"stream":"sync"})]})}),e.jsx(p,{children:e.jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx("span",{children:o.client_model??s("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"→"}),e.jsx("span",{className:"font-medium text-foreground",children:o.model})]}),o.error?e.jsx("span",{className:"truncate text-destructive",children:o.error}):null]})}),e.jsx(p,{className:"text-right font-medium",children:_(o.latency_ms,s("common.units.ms"))}),e.jsx(p,{children:e.jsx(A,{variant:o.error?"destructive":"default",className:"min-w-14 justify-center",children:(o.status_code??(o.error?500:200)).toString()})})]},o.id))})]})})]})})}export{et as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as a}from"./charts-react-BxiU3S4Y.js";import{u as s,i as l,a as t,b as i,c as n,d as o,f as r,g as $}from"./charts-core-BjxPMAw_.js";s([l,t,i,n,o,r,$]);const e=a;export{e as E};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,f as e,af as $,N as L,ac as R,ag as T,ah as I}from"./vendor-UrUELLAG.js";import{u as z,B as x,c as w,L as P,e as F,t as B}from"./index-BKEgpvTe.js";import{P as V,B as u}from"./PageHeader-CbpaEUEn.js";import{I as D}from"./input-BCUUQfiv.js";import{C,a as S,b as K}from"./card-DRsnBFyp.js";import{S as H,a as J,b as O,c as U,d as v}from"./select-C-e-41FP.js";import{u as _}from"./i18n-qAxAISVU.js";import"./router-Ju3lwB-M.js";import"./radix-CwKvZelb.js";import"./query-BnTlXVsy.js";function q(t){const l=Date.now()-t,n=Math.abs(l),m=60*1e3,d=60*m,o=24*d;if(n<m){const r=Math.max(Math.round(n/1e3),1);return l>=0?`${r}s ago`:`in ${r}s`}if(n<d){const r=Math.round(n/m);return l>=0?`${r}m ago`:`in ${r}m`}if(n<o){const r=Math.round(n/d);return l>=0?`${r}h ago`:`in ${r}h`}const h=Math.round(n/o);return l>=0?`${h}d ago`:`in ${h}d`}function G(t){return new Date(t).toLocaleString()}const Q={info:"secondary",warn:"outline",error:"destructive"};function ne(){const{t}=_(),{pushToast:g}=z(),[l,n]=i.useState([]),[m,d]=i.useState(!0),[o,h]=i.useState(null),[r,A]=i.useState(null),[a,j]=i.useState({level:"",type:""}),[N,y]=i.useState(!1),f=async s=>{d(!0);try{const c=await F.list({cursor:(s==null?void 0:s.cursor)??void 0,limit:50,level:a.level||void 0,type:a.type||void 0});n(c.events),A(c.nextCursor),h((s==null?void 0:s.cursor)??null)}catch(c){const M=B(c);g({title:t("events.toast.loadFailure",{message:M.message}),variant:"error"})}finally{d(!1),y(!1)}};i.useEffect(()=>{f({reset:!0})},[a.level,a.type]);const k=()=>{y(!0),f({cursor:o,reset:!1})},b=()=>{j({level:"",type:""})},E=i.useMemo(()=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",disabled:!o,onClick:()=>void f({cursor:void 0}),children:[e.jsx($,{className:"mr-1 h-4 w-4"})," ",t("events.actions.newest")]}),e.jsxs(x,{variant:"outline",size:"sm",disabled:!r,onClick:()=>void f({cursor:r??void 0}),children:[t("events.actions.older")," ",e.jsx(L,{className:"ml-1 h-4 w-4"})]})]}),[o,r,t]),p=i.useMemo(()=>{const s=[];return a.level&&s.push(t(`events.levels.${a.level}`)),a.type.trim()&&s.push(a.type.trim()),s},[a.level,a.type,t]);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(V,{icon:e.jsx(T,{className:"h-5 w-5"}),title:t("events.title"),description:t("events.description"),actions:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.jsxs(x,{variant:"outline",size:"sm",onClick:k,disabled:N,children:[e.jsx(R,{className:w("mr-2 h-4 w-4",N&&"animate-spin")}),t(N?"common.actions.refreshing":"common.actions.refresh")]})})}),e.jsx(C,{className:"sticky top-20 z-20 surface-1",children:e.jsx(S,{className:"pt-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[e.jsx(I,{className:"h-4 w-4 text-primary"}),t("events.filters.title"),e.jsx(u,{variant:"outline",children:l.length})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("events.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.length>0&&e.jsx(x,{variant:"ghost",size:"sm",onClick:b,children:t("common.actions.reset")}),E]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(H,{value:a.level,onValueChange:s=>j(c=>({...c,level:s==="all"?"":s})),children:[e.jsx(J,{className:"w-[140px]",children:e.jsx(O,{placeholder:t("events.filters.allLevels")})}),e.jsxs(U,{children:[e.jsx(v,{value:"all",children:t("events.filters.allLevels")}),e.jsx(v,{value:"info",children:t("events.levels.info")}),e.jsx(v,{value:"warn",children:t("events.levels.warn")}),e.jsx(v,{value:"error",children:t("events.levels.error")})]})]}),e.jsx(D,{className:"w-[180px]",placeholder:t("events.filters.typePlaceholder"),value:a.type,onChange:s=>j(c=>({...c,type:s.target.value}))}),e.jsx(x,{variant:"ghost",size:"sm",onClick:b,disabled:p.length===0,children:t("common.actions.reset")})]}),p.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(s=>e.jsx(u,{variant:"secondary",children:s},s))})]})})}),m?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(P,{})}):l.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45 p-10 text-center",children:[e.jsx("p",{className:"text-base font-medium",children:t("events.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t("events.empty.subtitle")})]}):e.jsx("div",{className:"grid gap-4",children:l.map(s=>e.jsxs(C,{className:w("overflow-hidden border-l-4",s.level==="error"?"border-l-destructive":s.level==="warn"?"border-l-amber-500":"border-l-emerald-500"),children:[e.jsx(K,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(u,{variant:Q[s.level]||"secondary",children:t(`events.levels.${s.level}`)}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[G(s.createdAt)," · ",q(s.createdAt)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(u,{variant:"outline",children:["#",s.id]}),s.mode&&e.jsx(u,{variant:"secondary",children:s.mode})]})]})}),e.jsxs(S,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-base font-semibold",children:s.title||t("events.defaultTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.message||t("events.defaultMessage")})]}),e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2 lg:grid-cols-3",children:[s.ipAddress&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"IP"}),e.jsx("p",{children:s.ipAddress})]}),s.apiKeyName&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"API Key"}),e.jsx("p",{children:s.apiKeyName})]}),s.userAgent&&e.jsxs("div",{className:"space-y-1 sm:col-span-2 lg:col-span-3",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"User Agent"}),e.jsx("p",{className:"truncate",children:s.userAgent})]})]}),s.details&&e.jsxs("details",{className:"rounded-[1rem] border border-border/70 bg-background/45 p-3 text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-primary",children:t("events.details")}),e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-[1rem] border border-border/70 bg-background/70 p-3 text-xs",children:JSON.stringify(s.details,null,2)})]})]})]},s.id))})]})}export{ne as default};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{r as h,f as e,at as N,ar as b,au as v,av as w}from"./vendor-UrUELLAG.js";import{P as y}from"./PageHeader-CbpaEUEn.js";import{P as d}from"./PageSection-6q9HngU5.js";import{c as u}from"./clipboard-CALi6bTW.js";import{C as p,a as j}from"./card-DRsnBFyp.js";import{B as f}from"./index-BKEgpvTe.js";import{u as x}from"./i18n-qAxAISVU.js";import"./router-Ju3lwB-M.js";import"./radix-CwKvZelb.js";import"./query-BnTlXVsy.js";function F(){const{t:s}=x(),t=h.useMemo(()=>{const i=s("help.sections.configuration.items",{returnObjects:!0}),n=s("help.sections.claudeCodeConfig.items",{returnObjects:!0}),a=s("help.sections.codexConfig.items",{returnObjects:!0}),c=s("help.sections.usage.items",{returnObjects:!0}),g=s("help.sections.tips.items",{returnObjects:!0});return[{title:s("help.sections.configuration.title"),items:i},{title:s("help.sections.claudeCodeConfig.title"),items:n},{title:s("help.sections.codexConfig.title"),items:a},{title:s("help.sections.usage.title"),items:c},{title:s("help.sections.tips.title"),items:g}]},[s]),r=s("help.faq.items",{returnObjects:!0}),l=h.useMemo(()=>[{id:"configuration",title:t[0].title,subtitle:t[0].items[0]??""},{id:"claude",title:t[1].title,subtitle:t[1].items[0]??""},{id:"codex",title:t[2].title,subtitle:t[2].items[0]??""},{id:"faq",title:s("help.faq.title"),subtitle:`${r.length} FAQ`}],[r.length,t,s]);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(y,{icon:e.jsx(N,{className:"h-5 w-5","aria-hidden":"true"}),title:s("help.title"),description:s("help.intro")}),e.jsx(p,{className:"surface-1",children:e.jsxs(j,{className:"flex items-start gap-4 pt-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-primary/10 text-primary shadow-[inset_0_0_0_1px_rgba(59,130,246,0.08)]",children:e.jsx(b,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.note")})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:l.map(i=>e.jsxs("a",{href:`#help-${i.id}`,className:"rounded-[1.35rem] border border-white/50 bg-card/88 px-4 py-4 shadow-[0_1px_2px_rgba(15,23,42,0.03)] transition hover:-translate-y-0.5 hover:shadow-[0_12px_36px_-24px_rgba(15,23,42,0.3)]",children:[e.jsx("p",{className:"text-sm font-semibold",children:i.title}),e.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-muted-foreground",children:i.subtitle})]},i.id))}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{id:"help-configuration",children:e.jsx(d,{title:t[0].title,children:e.jsx(o,{items:t[0].items})})}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold",children:s("help.clientConfig.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.clientConfig.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsxs(d,{title:t[1].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-xl bg-primary/5 p-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-primary-foreground",children:e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Claude Code"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"IDE / Desktop workflow"})]})]}),e.jsx(o,{items:t[1].items})]})}),e.jsx("div",{id:"help-codex",children:e.jsxs(d,{title:t[2].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-xl bg-emerald-500/5 p-4 dark:bg-emerald-500/10",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-500 text-white",children:e.jsx(w,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Codex CLI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Terminal workflow"})]})]}),e.jsx(o,{items:t[2].items})]})})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"mb-6 space-y-1 text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("help.advancedGuide.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.advancedGuide.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(d,{title:t[3].title,children:e.jsx(o,{items:t[3].items})}),e.jsx(d,{title:t[4].title,children:e.jsx(o,{items:t[4].items})})]})]})]}),e.jsx("div",{id:"help-faq",children:e.jsx(d,{title:s("help.faq.title"),children:e.jsx(_,{items:r})})})]})}function o({items:s}){return e.jsx("ol",{className:"flex flex-col gap-3",children:s.map((t,r)=>e.jsxs("li",{className:"flex gap-3 rounded-[1.2rem] border border-white/50 bg-card/82 p-3 shadow-[0_1px_2px_rgba(15,23,42,0.03)]",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-xl bg-primary text-xs font-medium text-primary-foreground",children:r+1}),e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:e.jsx(C,{content:t})})]},`${r}-${t}`))})}function C({content:s}){const{t}=x();if(s.includes("```")){const r=s.split("```");return e.jsx("div",{className:"space-y-2",children:r.map((l,i)=>{if(i%2===0)return l?e.jsx("div",{className:"whitespace-pre-line",children:m(l)},i):null;{const[n,...a]=l.split(`
|
|
2
|
+
`),c=a.join(`
|
|
3
|
+
`);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n||"bash"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>u(c),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-[1rem] border border-border/70 bg-background/70 p-3 text-xs",children:e.jsx("code",{children:c})})]},i)}})})}return s.includes(`
|
|
4
|
+
`)?e.jsx("div",{className:"whitespace-pre-line",children:m(s)}):e.jsx("div",{children:m(s)})}function m(s){return s.split(/(\*\*[^*]+\*\*)/g).map((r,l)=>r.startsWith("**")&&r.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:r.slice(2,-2)},l):e.jsx("span",{children:r},l))}function _({items:s}){return s.length===0?null:e.jsx("dl",{className:"flex flex-col gap-3",children:s.map(t=>e.jsx(p,{className:"surface-1",children:e.jsxs(j,{className:"pt-4",children:[e.jsx("dt",{className:"text-sm font-medium",children:t.q}),e.jsx("dd",{className:"mt-2 text-sm text-muted-foreground",children:e.jsx(k,{content:t.a})})]})},t.q))})}function k({content:s}){const{t}=x();if(s.includes("1)")||s.includes("2)")){const r=s.split(`
|
|
5
|
+
`).filter(i=>i.trim());if(r.some(i=>/^\d+\)/.test(i.trim())))return e.jsx("div",{className:"space-y-1",children:r.map((i,n)=>{const a=i.match(/^\d+\)\s*(.*)/);return a?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"•"}),e.jsx("span",{children:a[1]})]},n):e.jsx("div",{children:i},n)})})}if(s.includes("```")){const r=s.split("```");return e.jsx("div",{className:"space-y-2",children:r.map((l,i)=>{if(i%2===0)return l?e.jsx("div",{className:"whitespace-pre-line",children:l},i):null;{const[n,...a]=l.split(`
|
|
6
|
+
`),c=a.join(`
|
|
7
|
+
`);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n||"bash"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>u(c),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-[1rem] border border-border/70 bg-background/70 p-3 text-xs",children:e.jsx("code",{children:c})})]},i)}})})}return s.includes(`
|
|
8
|
+
`)?e.jsx("div",{className:"whitespace-pre-line",children:s}):e.jsx("div",{children:s})}export{F as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as n,f as e}from"./vendor-UrUELLAG.js";import{i as C,h as E,B as F}from"./index-BKEgpvTe.js";import{I as j}from"./input-BCUUQfiv.js";import{L as b}from"./label-CtuP7N6a.js";import{C as v,a as w,b as S,c as L,d as k,e as _}from"./card-DRsnBFyp.js";import{u as P}from"./i18n-qAxAISVU.js";import{c as T,u as A}from"./router-Ju3lwB-M.js";import"./radix-CwKvZelb.js";import"./query-BnTlXVsy.js";function z(){const{t:s}=P(),i=T(),m=A(),{authEnabled:o,isAuthenticated:u,loading:l,login:y,error:p}=C(),[a,x]=n.useState({username:"",password:""}),[f,d]=n.useState(null),[h,g]=n.useState(!1),c=n.useMemo(()=>{var t;const r=m.state;return((t=r==null?void 0:r.from)==null?void 0:t.pathname)??"/"},[m.state]);n.useEffect(()=>{if(!o&&!l){i(c,{replace:!0});return}o&&u&&!l&&i(c,{replace:!0})},[o,u,l,i,c]);const N=async r=>{if(r.preventDefault(),d(null),!a.username.trim()||!a.password){d(s("login.validation.required"));return}g(!0);try{await y(a.username.trim(),a.password),i(c,{replace:!0})}catch(t){d(t instanceof Error?t.message:s("login.validation.failed"))}finally{g(!1)}};return l?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsx(v,{className:"surface-2 w-full max-w-md",children:e.jsx(w,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(E,{})})})}):o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsxs(v,{className:"surface-2 w-full max-w-md overflow-hidden",children:[e.jsxs(S,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-[1.15rem] bg-gradient-to-br from-primary via-primary to-sky-400 text-lg font-bold text-primary-foreground shadow-[0_14px_30px_-18px_rgba(59,130,246,0.75)]",children:"GW"}),e.jsx(L,{className:"text-2xl",children:s("login.title")}),e.jsx(k,{className:"text-sm",children:s("login.description")})]}),e.jsx(w,{children:e.jsxs("form",{className:"space-y-4",onSubmit:N,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(j,{id:"username",value:a.username,autoComplete:"username",autoFocus:!0,onChange:r=>x(t=>({...t,username:r.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(j,{id:"password",type:"password",value:a.password,autoComplete:"current-password",onChange:r=>x(t=>({...t,password:r.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),(f||p)&&e.jsx("div",{className:"rounded-[1rem] border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:f||p}),e.jsx(F,{type:"submit",className:"w-full",disabled:h,children:s(h?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(_,{className:"justify-center",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})}):null}export{z as default};
|