@chenpu17/cc-gw 0.4.1 → 0.4.2
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/package.json +1 -1
- package/src/server/dist/index.js +50 -24
- package/src/web/dist/assets/{About-DpeHLv4-.js → About-CfWemXks.js} +2 -2
- package/src/web/dist/assets/{ApiKeys-CTR9Ynaf.js → ApiKeys-jGq-kKf8.js} +1 -1
- package/src/web/dist/assets/{Button-CkW8jVT-.js → Button-DdVyALkb.js} +1 -1
- package/src/web/dist/assets/Dashboard-uoI9oSjK.js +16 -0
- package/src/web/dist/assets/{FormField-CsiVhN9M.js → FormField-Dyi1Kr0k.js} +1 -1
- package/src/web/dist/assets/{Help-CSSGZPF_.js → Help-iZXiqNPj.js} +1 -1
- package/src/web/dist/assets/{Input-jZIOmpmG.js → Input-DACzKnnk.js} +1 -1
- package/src/web/dist/assets/{Login-D577Po2d.js → Login-mm-NJUOP.js} +1 -1
- package/src/web/dist/assets/{Logs-DNLLeIq-.js → Logs-DNxTsrk3.js} +1 -1
- package/src/web/dist/assets/{ModelManagement-BazsfV0F.js → ModelManagement-B4f8RUk8.js} +1 -1
- package/src/web/dist/assets/{PageSection-BbmHOMiD.js → PageSection-BfMkaweN.js} +1 -1
- package/src/web/dist/assets/{Settings-Btmf5gPD.js → Settings-DRLUoVLq.js} +1 -1
- package/src/web/dist/assets/{StatusBadge-DCmNAKwK.js → StatusBadge-OH4R_aKr.js} +1 -1
- package/src/web/dist/assets/{copy-D50F736h.js → copy-BVgnqUsP.js} +1 -1
- package/src/web/dist/assets/{index-But5PyJC.css → index-BFd07aus.css} +1 -1
- package/src/web/dist/assets/{index-BuSvAxno.js → index-C2xoexDc.js} +1 -1
- package/src/web/dist/assets/{index-B-8NzzZq.js → index-CAbsGgAq.js} +5 -5
- package/src/web/dist/assets/{info-B7P9oOld.js → info-CpmSkfUl.js} +1 -1
- package/src/web/dist/assets/{useApiQuery-DZHaAgf7.js → useApiQuery-CNbY7eTZ.js} +1 -1
- package/src/web/dist/index.html +2 -2
- package/src/web/dist/assets/Dashboard-D1jcy7qj.js +0 -16
package/package.json
CHANGED
package/src/server/dist/index.js
CHANGED
|
@@ -11102,6 +11102,8 @@ async function migrateDailyMetricsTable(db) {
|
|
|
11102
11102
|
const hasCompositePrimaryKey = primaryKeyColumns.length > 1;
|
|
11103
11103
|
if (!hasEndpointColumn || !hasCompositePrimaryKey) {
|
|
11104
11104
|
const endpointSelector = hasEndpointColumn ? "COALESCE(endpoint, 'anthropic')" : "'anthropic'";
|
|
11105
|
+
const hasCachedTokensColumn = columns.some((column) => column.name === "total_cached_tokens");
|
|
11106
|
+
const cachedTokensSelector = hasCachedTokensColumn ? "COALESCE(total_cached_tokens, 0)" : "0";
|
|
11105
11107
|
await exec(
|
|
11106
11108
|
db,
|
|
11107
11109
|
`ALTER TABLE daily_metrics RENAME TO daily_metrics_old;
|
|
@@ -11111,15 +11113,17 @@ async function migrateDailyMetricsTable(db) {
|
|
|
11111
11113
|
request_count INTEGER DEFAULT 0,
|
|
11112
11114
|
total_input_tokens INTEGER DEFAULT 0,
|
|
11113
11115
|
total_output_tokens INTEGER DEFAULT 0,
|
|
11116
|
+
total_cached_tokens INTEGER DEFAULT 0,
|
|
11114
11117
|
total_latency_ms INTEGER DEFAULT 0,
|
|
11115
11118
|
PRIMARY KEY (date, endpoint)
|
|
11116
11119
|
);
|
|
11117
|
-
INSERT INTO daily_metrics (date, endpoint, request_count, total_input_tokens, total_output_tokens, total_latency_ms)
|
|
11120
|
+
INSERT INTO daily_metrics (date, endpoint, request_count, total_input_tokens, total_output_tokens, total_cached_tokens, total_latency_ms)
|
|
11118
11121
|
SELECT date,
|
|
11119
11122
|
${endpointSelector},
|
|
11120
11123
|
request_count,
|
|
11121
11124
|
total_input_tokens,
|
|
11122
11125
|
total_output_tokens,
|
|
11126
|
+
${cachedTokensSelector},
|
|
11123
11127
|
total_latency_ms
|
|
11124
11128
|
FROM daily_metrics_old;
|
|
11125
11129
|
DROP TABLE daily_metrics_old;`
|
|
@@ -11176,6 +11180,7 @@ async function ensureSchema(db) {
|
|
|
11176
11180
|
request_count INTEGER DEFAULT 0,
|
|
11177
11181
|
total_input_tokens INTEGER DEFAULT 0,
|
|
11178
11182
|
total_output_tokens INTEGER DEFAULT 0,
|
|
11183
|
+
total_cached_tokens INTEGER DEFAULT 0,
|
|
11179
11184
|
total_latency_ms INTEGER DEFAULT 0,
|
|
11180
11185
|
PRIMARY KEY (date, endpoint)
|
|
11181
11186
|
);
|
|
@@ -11233,6 +11238,7 @@ async function ensureSchema(db) {
|
|
|
11233
11238
|
await maybeAddColumn(db, "api_keys", "total_input_tokens", "INTEGER DEFAULT 0");
|
|
11234
11239
|
await maybeAddColumn(db, "api_keys", "total_output_tokens", "INTEGER DEFAULT 0");
|
|
11235
11240
|
await migrateDailyMetricsTable(db);
|
|
11241
|
+
await maybeAddColumn(db, "daily_metrics", "total_cached_tokens", "INTEGER DEFAULT 0");
|
|
11236
11242
|
await run(db, "CREATE UNIQUE INDEX IF NOT EXISTS idx_api_keys_hash ON api_keys(key_hash) WHERE key_hash IS NOT NULL");
|
|
11237
11243
|
await run(db, "UPDATE api_keys SET key_hash = '*' WHERE is_wildcard = 1 AND (key_hash IS NULL OR key_hash = '')");
|
|
11238
11244
|
await run(db, "UPDATE api_keys SET updated_at = created_at WHERE updated_at IS NULL");
|
|
@@ -11450,12 +11456,13 @@ async function upsertLogPayload(requestId, payload) {
|
|
|
11450
11456
|
}
|
|
11451
11457
|
async function updateMetrics(date, endpoint, delta) {
|
|
11452
11458
|
await runQuery(
|
|
11453
|
-
`INSERT INTO daily_metrics (date, endpoint, request_count, total_input_tokens, total_output_tokens, total_latency_ms)
|
|
11454
|
-
VALUES (?, ?, ?, ?, ?, ?)
|
|
11459
|
+
`INSERT INTO daily_metrics (date, endpoint, request_count, total_input_tokens, total_output_tokens, total_cached_tokens, total_latency_ms)
|
|
11460
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
11455
11461
|
ON CONFLICT(date, endpoint) DO UPDATE SET
|
|
11456
11462
|
request_count = daily_metrics.request_count + excluded.request_count,
|
|
11457
11463
|
total_input_tokens = daily_metrics.total_input_tokens + excluded.total_input_tokens,
|
|
11458
11464
|
total_output_tokens = daily_metrics.total_output_tokens + excluded.total_output_tokens,
|
|
11465
|
+
total_cached_tokens = daily_metrics.total_cached_tokens + excluded.total_cached_tokens,
|
|
11459
11466
|
total_latency_ms = daily_metrics.total_latency_ms + excluded.total_latency_ms`,
|
|
11460
11467
|
[
|
|
11461
11468
|
date,
|
|
@@ -11463,6 +11470,7 @@ async function updateMetrics(date, endpoint, delta) {
|
|
|
11463
11470
|
delta.requests,
|
|
11464
11471
|
delta.inputTokens,
|
|
11465
11472
|
delta.outputTokens,
|
|
11473
|
+
delta.cachedTokens ?? 0,
|
|
11466
11474
|
delta.latencyMs
|
|
11467
11475
|
]
|
|
11468
11476
|
);
|
|
@@ -12214,7 +12222,7 @@ async function registerMessagesRoute(app) {
|
|
|
12214
12222
|
if (providerType === "anthropic") {
|
|
12215
12223
|
let inputTokens2 = json.usage?.input_tokens ?? 0;
|
|
12216
12224
|
let outputTokens2 = json.usage?.output_tokens ?? 0;
|
|
12217
|
-
const
|
|
12225
|
+
const cachedTokens3 = resolveCachedTokens(json.usage);
|
|
12218
12226
|
if (!inputTokens2) {
|
|
12219
12227
|
inputTokens2 = target.tokenEstimate || estimateTokens(normalized, target.modelId);
|
|
12220
12228
|
}
|
|
@@ -12225,13 +12233,13 @@ async function registerMessagesRoute(app) {
|
|
|
12225
12233
|
logUsage("non_stream.anthropic", {
|
|
12226
12234
|
input: inputTokens2,
|
|
12227
12235
|
output: outputTokens2,
|
|
12228
|
-
cached:
|
|
12236
|
+
cached: cachedTokens3
|
|
12229
12237
|
});
|
|
12230
12238
|
const latencyMs2 = Date.now() - requestStart;
|
|
12231
12239
|
await updateLogTokens(logId, {
|
|
12232
12240
|
inputTokens: inputTokens2,
|
|
12233
12241
|
outputTokens: outputTokens2,
|
|
12234
|
-
cachedTokens:
|
|
12242
|
+
cachedTokens: cachedTokens3,
|
|
12235
12243
|
ttftMs: latencyMs2,
|
|
12236
12244
|
tpotMs: computeTpot(latencyMs2, outputTokens2, { streaming: false })
|
|
12237
12245
|
});
|
|
@@ -12240,6 +12248,7 @@ async function registerMessagesRoute(app) {
|
|
|
12240
12248
|
requests: 1,
|
|
12241
12249
|
inputTokens: inputTokens2,
|
|
12242
12250
|
outputTokens: outputTokens2,
|
|
12251
|
+
cachedTokens: cachedTokens3,
|
|
12243
12252
|
latencyMs: latencyMs2
|
|
12244
12253
|
});
|
|
12245
12254
|
if (storeResponsePayloads) {
|
|
@@ -12260,7 +12269,7 @@ async function registerMessagesRoute(app) {
|
|
|
12260
12269
|
const claudeResponse = buildClaudeResponse(json, target.modelId);
|
|
12261
12270
|
let inputTokens = json.usage?.prompt_tokens ?? 0;
|
|
12262
12271
|
let outputTokens = json.usage?.completion_tokens ?? 0;
|
|
12263
|
-
const
|
|
12272
|
+
const cachedTokens2 = resolveCachedTokens(json.usage);
|
|
12264
12273
|
if (!inputTokens) {
|
|
12265
12274
|
inputTokens = target.tokenEstimate || estimateTokens(normalized, target.modelId);
|
|
12266
12275
|
}
|
|
@@ -12271,13 +12280,13 @@ async function registerMessagesRoute(app) {
|
|
|
12271
12280
|
logUsage("non_stream.openai", {
|
|
12272
12281
|
input: inputTokens,
|
|
12273
12282
|
output: outputTokens,
|
|
12274
|
-
cached:
|
|
12283
|
+
cached: cachedTokens2
|
|
12275
12284
|
});
|
|
12276
12285
|
const latencyMs = Date.now() - requestStart;
|
|
12277
12286
|
await updateLogTokens(logId, {
|
|
12278
12287
|
inputTokens,
|
|
12279
12288
|
outputTokens,
|
|
12280
|
-
cachedTokens,
|
|
12289
|
+
cachedTokens: cachedTokens2,
|
|
12281
12290
|
ttftMs: latencyMs,
|
|
12282
12291
|
tpotMs: computeTpot(latencyMs, outputTokens, { streaming: false })
|
|
12283
12292
|
});
|
|
@@ -12563,6 +12572,7 @@ async function registerMessagesRoute(app) {
|
|
|
12563
12572
|
requests: 1,
|
|
12564
12573
|
inputTokens: usagePrompt2,
|
|
12565
12574
|
outputTokens: usageCompletion2,
|
|
12575
|
+
cachedTokens: usageCached2,
|
|
12566
12576
|
latencyMs: totalLatencyMs
|
|
12567
12577
|
});
|
|
12568
12578
|
if (storeResponsePayloads) {
|
|
@@ -12733,6 +12743,7 @@ data: ${JSON.stringify(data)}
|
|
|
12733
12743
|
requests: 1,
|
|
12734
12744
|
inputTokens: finalPromptTokens,
|
|
12735
12745
|
outputTokens: finalCompletionTokens,
|
|
12746
|
+
cachedTokens: usageCached,
|
|
12736
12747
|
latencyMs: totalLatencyMs
|
|
12737
12748
|
});
|
|
12738
12749
|
if (storeResponsePayloads) {
|
|
@@ -12894,6 +12905,7 @@ data: ${JSON.stringify(data)}
|
|
|
12894
12905
|
requests: 1,
|
|
12895
12906
|
inputTokens: fallbackPrompt,
|
|
12896
12907
|
outputTokens: fallbackCompletion,
|
|
12908
|
+
cachedTokens: usageCached,
|
|
12897
12909
|
latencyMs: totalLatencyMs
|
|
12898
12910
|
});
|
|
12899
12911
|
if (storeResponsePayloads) {
|
|
@@ -13836,17 +13848,17 @@ async function registerOpenAiRoutes(app) {
|
|
|
13836
13848
|
if (!Number.isFinite(inputTokens3) || inputTokens3 <= 0) {
|
|
13837
13849
|
inputTokens3 = target.tokenEstimate ?? estimateTokens(normalized, target.modelId);
|
|
13838
13850
|
}
|
|
13839
|
-
const
|
|
13851
|
+
const cachedTokens3 = resolveCachedTokens2(usagePayload2);
|
|
13840
13852
|
const latencyMs3 = Date.now() - requestStart;
|
|
13841
13853
|
const openAIResponse = buildOpenAIResponseFromClaude(parsed, target.modelId, converted, {
|
|
13842
13854
|
inputTokens: inputTokens3,
|
|
13843
13855
|
outputTokens: outputTokens3,
|
|
13844
|
-
cachedTokens:
|
|
13856
|
+
cachedTokens: cachedTokens3
|
|
13845
13857
|
});
|
|
13846
13858
|
await updateLogTokens(logId, {
|
|
13847
13859
|
inputTokens: inputTokens3,
|
|
13848
13860
|
outputTokens: outputTokens3,
|
|
13849
|
-
cachedTokens:
|
|
13861
|
+
cachedTokens: cachedTokens3,
|
|
13850
13862
|
ttftMs: latencyMs3,
|
|
13851
13863
|
tpotMs: computeTpot2(latencyMs3, outputTokens3, { streaming: false })
|
|
13852
13864
|
});
|
|
@@ -13855,6 +13867,7 @@ async function registerOpenAiRoutes(app) {
|
|
|
13855
13867
|
requests: 1,
|
|
13856
13868
|
inputTokens: inputTokens3,
|
|
13857
13869
|
outputTokens: outputTokens3,
|
|
13870
|
+
cachedTokens: cachedTokens3,
|
|
13858
13871
|
latencyMs: latencyMs3
|
|
13859
13872
|
});
|
|
13860
13873
|
if (storeResponsePayloads) {
|
|
@@ -13889,12 +13902,12 @@ async function registerOpenAiRoutes(app) {
|
|
|
13889
13902
|
return 0;
|
|
13890
13903
|
})();
|
|
13891
13904
|
const outputTokens2 = baseOutputTokens + reasoningTokens2;
|
|
13892
|
-
const
|
|
13905
|
+
const cachedTokens2 = resolveCachedTokens2(usagePayload);
|
|
13893
13906
|
const latencyMs2 = Date.now() - requestStart;
|
|
13894
13907
|
await updateLogTokens(logId, {
|
|
13895
13908
|
inputTokens: inputTokens2,
|
|
13896
13909
|
outputTokens: outputTokens2,
|
|
13897
|
-
cachedTokens,
|
|
13910
|
+
cachedTokens: cachedTokens2,
|
|
13898
13911
|
ttftMs: usagePayload?.first_token_latency_ms ?? latencyMs2,
|
|
13899
13912
|
tpotMs: usagePayload?.tokens_per_second ? computeTpot2(latencyMs2, outputTokens2, { streaming: false, reasoningTokens: reasoningTokens2 }) : null
|
|
13900
13913
|
});
|
|
@@ -14292,6 +14305,7 @@ async function registerOpenAiRoutes(app) {
|
|
|
14292
14305
|
requests: 1,
|
|
14293
14306
|
inputTokens: finalPromptTokens,
|
|
14294
14307
|
outputTokens: finalCompletionTokens,
|
|
14308
|
+
cachedTokens: usageCached2,
|
|
14295
14309
|
latencyMs: totalLatencyMs
|
|
14296
14310
|
});
|
|
14297
14311
|
if (storeResponsePayloads && capturedResponseChunks2) {
|
|
@@ -14699,12 +14713,12 @@ async function registerOpenAiRoutes(app) {
|
|
|
14699
14713
|
inputTokens: inputTokens3,
|
|
14700
14714
|
outputTokens: outputTokens3
|
|
14701
14715
|
});
|
|
14702
|
-
const
|
|
14716
|
+
const cachedTokens3 = resolveCachedTokens2(usagePayload2);
|
|
14703
14717
|
const latencyMs3 = Date.now() - requestStart;
|
|
14704
14718
|
await updateLogTokens(logId, {
|
|
14705
14719
|
inputTokens: inputTokens3,
|
|
14706
14720
|
outputTokens: outputTokens3,
|
|
14707
|
-
cachedTokens:
|
|
14721
|
+
cachedTokens: cachedTokens3,
|
|
14708
14722
|
ttftMs: latencyMs3,
|
|
14709
14723
|
tpotMs: computeTpot2(latencyMs3, outputTokens3, { streaming: false })
|
|
14710
14724
|
});
|
|
@@ -14713,6 +14727,7 @@ async function registerOpenAiRoutes(app) {
|
|
|
14713
14727
|
requests: 1,
|
|
14714
14728
|
inputTokens: inputTokens3,
|
|
14715
14729
|
outputTokens: outputTokens3,
|
|
14730
|
+
cachedTokens: cachedTokens3,
|
|
14716
14731
|
latencyMs: latencyMs3
|
|
14717
14732
|
});
|
|
14718
14733
|
if (storeResponsePayloads) {
|
|
@@ -14742,12 +14757,12 @@ async function registerOpenAiRoutes(app) {
|
|
|
14742
14757
|
})(),
|
|
14743
14758
|
target.modelId
|
|
14744
14759
|
);
|
|
14745
|
-
const
|
|
14760
|
+
const cachedTokens2 = resolveCachedTokens2(usagePayload);
|
|
14746
14761
|
const latencyMs2 = Date.now() - requestStart;
|
|
14747
14762
|
await updateLogTokens(logId, {
|
|
14748
14763
|
inputTokens: inputTokens2,
|
|
14749
14764
|
outputTokens: outputTokens2,
|
|
14750
|
-
cachedTokens,
|
|
14765
|
+
cachedTokens: cachedTokens2,
|
|
14751
14766
|
ttftMs: usagePayload?.first_token_latency_ms ?? latencyMs2,
|
|
14752
14767
|
tpotMs: usagePayload?.tokens_per_second ? computeTpot2(latencyMs2, outputTokens2, { streaming: false }) : null
|
|
14753
14768
|
});
|
|
@@ -15188,6 +15203,7 @@ async function registerOpenAiRoutes(app) {
|
|
|
15188
15203
|
requests: 1,
|
|
15189
15204
|
inputTokens: finalPromptTokens,
|
|
15190
15205
|
outputTokens: finalCompletionTokens,
|
|
15206
|
+
cachedTokens: usageCached2,
|
|
15191
15207
|
latencyMs: totalLatencyMs
|
|
15192
15208
|
});
|
|
15193
15209
|
if (storeResponsePayloads && capturedResponseChunks2) {
|
|
@@ -15597,6 +15613,7 @@ async function getDailyMetrics(days = 7, endpoint) {
|
|
|
15597
15613
|
request_count AS requestCount,
|
|
15598
15614
|
total_input_tokens AS inputTokens,
|
|
15599
15615
|
total_output_tokens AS outputTokens,
|
|
15616
|
+
total_cached_tokens AS cachedTokens,
|
|
15600
15617
|
total_latency_ms AS totalLatency
|
|
15601
15618
|
FROM daily_metrics
|
|
15602
15619
|
${whereClause}
|
|
@@ -15609,6 +15626,7 @@ async function getDailyMetrics(days = 7, endpoint) {
|
|
|
15609
15626
|
requestCount: row.requestCount ?? 0,
|
|
15610
15627
|
inputTokens: row.inputTokens ?? 0,
|
|
15611
15628
|
outputTokens: row.outputTokens ?? 0,
|
|
15629
|
+
cachedTokens: row.cachedTokens ?? 0,
|
|
15612
15630
|
avgLatencyMs: row.requestCount ? Math.round((row.totalLatency ?? 0) / row.requestCount) : 0
|
|
15613
15631
|
})).reverse();
|
|
15614
15632
|
}
|
|
@@ -15619,6 +15637,7 @@ async function getMetricsOverview(endpoint) {
|
|
|
15619
15637
|
COALESCE(SUM(request_count), 0) AS requests,
|
|
15620
15638
|
COALESCE(SUM(total_input_tokens), 0) AS inputTokens,
|
|
15621
15639
|
COALESCE(SUM(total_output_tokens), 0) AS outputTokens,
|
|
15640
|
+
COALESCE(SUM(total_cached_tokens), 0) AS cachedTokens,
|
|
15622
15641
|
COALESCE(SUM(total_latency_ms), 0) AS totalLatency
|
|
15623
15642
|
FROM daily_metrics
|
|
15624
15643
|
${totalsWhere}`,
|
|
@@ -15629,6 +15648,7 @@ async function getMetricsOverview(endpoint) {
|
|
|
15629
15648
|
`SELECT request_count AS requests,
|
|
15630
15649
|
total_input_tokens AS inputTokens,
|
|
15631
15650
|
total_output_tokens AS outputTokens,
|
|
15651
|
+
total_cached_tokens AS cachedTokens,
|
|
15632
15652
|
total_latency_ms AS totalLatency
|
|
15633
15653
|
FROM daily_metrics
|
|
15634
15654
|
WHERE date = ?
|
|
@@ -15645,12 +15665,14 @@ async function getMetricsOverview(endpoint) {
|
|
|
15645
15665
|
requests: totalsRequests,
|
|
15646
15666
|
inputTokens: totalsRow?.inputTokens ?? 0,
|
|
15647
15667
|
outputTokens: totalsRow?.outputTokens ?? 0,
|
|
15668
|
+
cachedTokens: totalsRow?.cachedTokens ?? 0,
|
|
15648
15669
|
avgLatencyMs: resolveAvg(totalsLatency, totalsRequests)
|
|
15649
15670
|
},
|
|
15650
15671
|
today: {
|
|
15651
15672
|
requests: todayRequests,
|
|
15652
15673
|
inputTokens: todayRow?.inputTokens ?? 0,
|
|
15653
15674
|
outputTokens: todayRow?.outputTokens ?? 0,
|
|
15675
|
+
cachedTokens: todayRow?.cachedTokens ?? 0,
|
|
15654
15676
|
avgLatencyMs: resolveAvg(todayLatency, todayRequests)
|
|
15655
15677
|
}
|
|
15656
15678
|
};
|
|
@@ -17448,12 +17470,12 @@ async function handleAnthropicProtocol(request, reply, endpoint, endpointId, app
|
|
|
17448
17470
|
const json = await new Response(upstream.body).json();
|
|
17449
17471
|
const inputTokens = json.usage?.input_tokens ?? estimateTokens(normalized, target.modelId);
|
|
17450
17472
|
const outputTokens = json.usage?.output_tokens ?? 0;
|
|
17451
|
-
const
|
|
17473
|
+
const cachedTokens2 = resolveCachedTokens3(json.usage);
|
|
17452
17474
|
const latencyMs = Date.now() - requestStart;
|
|
17453
17475
|
await updateLogTokens(logId, {
|
|
17454
17476
|
inputTokens,
|
|
17455
17477
|
outputTokens,
|
|
17456
|
-
cachedTokens,
|
|
17478
|
+
cachedTokens: cachedTokens2,
|
|
17457
17479
|
ttftMs: latencyMs,
|
|
17458
17480
|
tpotMs: computeTpot3(latencyMs, outputTokens, { streaming: false })
|
|
17459
17481
|
});
|
|
@@ -17462,6 +17484,7 @@ async function handleAnthropicProtocol(request, reply, endpoint, endpointId, app
|
|
|
17462
17484
|
requests: 1,
|
|
17463
17485
|
inputTokens,
|
|
17464
17486
|
outputTokens,
|
|
17487
|
+
cachedTokens: cachedTokens2,
|
|
17465
17488
|
latencyMs
|
|
17466
17489
|
});
|
|
17467
17490
|
if (storeResponsePayloads) {
|
|
@@ -17558,6 +17581,7 @@ async function handleAnthropicProtocol(request, reply, endpoint, endpointId, app
|
|
|
17558
17581
|
requests: 1,
|
|
17559
17582
|
inputTokens: usagePrompt,
|
|
17560
17583
|
outputTokens: usageCompletion,
|
|
17584
|
+
cachedTokens: usageCached,
|
|
17561
17585
|
latencyMs: totalLatencyMs
|
|
17562
17586
|
});
|
|
17563
17587
|
if (storeResponsePayloads && capturedChunks) {
|
|
@@ -17737,12 +17761,12 @@ async function handleOpenAIChatProtocol(request, reply, endpoint, endpointId, ap
|
|
|
17737
17761
|
const usagePayload = json?.usage ?? null;
|
|
17738
17762
|
const inputTokens2 = usagePayload?.prompt_tokens ?? usagePayload?.input_tokens ?? target.tokenEstimate ?? estimateTokens(normalized, target.modelId);
|
|
17739
17763
|
const outputTokens2 = usagePayload?.completion_tokens ?? usagePayload?.output_tokens ?? estimateTextTokens(json?.choices?.[0]?.message?.content ?? "", target.modelId);
|
|
17740
|
-
const
|
|
17764
|
+
const cachedTokens2 = resolveCachedTokens3(usagePayload);
|
|
17741
17765
|
const latencyMs2 = Date.now() - requestStart;
|
|
17742
17766
|
await updateLogTokens(logId, {
|
|
17743
17767
|
inputTokens: inputTokens2,
|
|
17744
17768
|
outputTokens: outputTokens2,
|
|
17745
|
-
cachedTokens,
|
|
17769
|
+
cachedTokens: cachedTokens2,
|
|
17746
17770
|
ttftMs: latencyMs2,
|
|
17747
17771
|
tpotMs: computeTpot3(latencyMs2, outputTokens2, { streaming: false })
|
|
17748
17772
|
});
|
|
@@ -17751,6 +17775,7 @@ async function handleOpenAIChatProtocol(request, reply, endpoint, endpointId, ap
|
|
|
17751
17775
|
requests: 1,
|
|
17752
17776
|
inputTokens: inputTokens2,
|
|
17753
17777
|
outputTokens: outputTokens2,
|
|
17778
|
+
cachedTokens: cachedTokens2,
|
|
17754
17779
|
latencyMs: latencyMs2
|
|
17755
17780
|
});
|
|
17756
17781
|
if (storeResponsePayloads) {
|
|
@@ -18016,12 +18041,12 @@ async function handleOpenAIResponsesProtocol(request, reply, endpoint, endpointI
|
|
|
18016
18041
|
const inputTokens2 = usagePayload?.prompt_tokens ?? usagePayload?.input_tokens ?? target.tokenEstimate ?? estimateTokens(normalized, target.modelId);
|
|
18017
18042
|
const content = json?.response?.body?.content ?? json?.choices?.[0]?.message?.content ?? "";
|
|
18018
18043
|
const outputTokens2 = usagePayload?.completion_tokens ?? usagePayload?.output_tokens ?? estimateTextTokens(content, target.modelId);
|
|
18019
|
-
const
|
|
18044
|
+
const cachedTokens2 = resolveCachedTokens3(usagePayload);
|
|
18020
18045
|
const latencyMs2 = Date.now() - requestStart;
|
|
18021
18046
|
await updateLogTokens(logId, {
|
|
18022
18047
|
inputTokens: inputTokens2,
|
|
18023
18048
|
outputTokens: outputTokens2,
|
|
18024
|
-
cachedTokens,
|
|
18049
|
+
cachedTokens: cachedTokens2,
|
|
18025
18050
|
ttftMs: latencyMs2,
|
|
18026
18051
|
tpotMs: computeTpot3(latencyMs2, outputTokens2, { streaming: false })
|
|
18027
18052
|
});
|
|
@@ -18030,6 +18055,7 @@ async function handleOpenAIResponsesProtocol(request, reply, endpoint, endpointI
|
|
|
18030
18055
|
requests: 1,
|
|
18031
18056
|
inputTokens: inputTokens2,
|
|
18032
18057
|
outputTokens: outputTokens2,
|
|
18058
|
+
cachedTokens: cachedTokens2,
|
|
18033
18059
|
latencyMs: latencyMs2
|
|
18034
18060
|
});
|
|
18035
18061
|
if (storeResponsePayloads) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as p,u as v,a as k,r,j as e,d as o,U as j,m as i}from"./index-
|
|
1
|
+
import{c as p,u as v,a as k,r,j as e,d as o,U as j,m as i}from"./index-CAbsGgAq.js";import{u as N}from"./useApiQuery-CNbY7eTZ.js";import{P as w,a as d}from"./PageSection-BfMkaweN.js";import"./Input-DACzKnnk.js";import{B as b}from"./Button-DdVyALkb.js";import{I as y}from"./info-CpmSkfUl.js";/**
|
|
2
2
|
* @license lucide-react v0.344.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -8,4 +8,4 @@ import{c as p,u as v,a as k,r,j as e,d as o,U as j,m as i}from"./index-B-8NzzZq.
|
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const E=p("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),I="0.4.
|
|
11
|
+
*/const E=p("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),I="0.4.2",_={version:I},L={VITE_BUILD_TIME:"2025-10-29T03:49:27.299Z",VITE_NODE_VERSION:"v22.14.0"};function m({items:t}){return t.length===0?null:e.jsx("dl",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-2",children:t.map(s=>e.jsxs("div",{className:"rounded-2xl border border-slate-200/50 bg-white p-4 shadow-sm shadow-slate-200/30 transition-all duration-200 hover:-translate-y-0.5 hover:border-slate-200/70 hover:shadow-md hover:shadow-slate-200/40 dark:border-slate-700/50 dark:bg-slate-900/80 dark:shadow-lg dark:shadow-slate-900/30 dark:hover:border-slate-600/70",children:[e.jsx("dt",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-slate-500 dark:text-slate-400",children:s.label}),e.jsx("dd",{className:"mt-2 text-base font-semibold text-slate-900 dark:text-slate-100",children:s.value}),s.hint?e.jsx("p",{className:o(i,"mt-2 text-xs leading-relaxed"),children:s.hint}):null]},s.label))})}function P(){const{t}=v(),{pushToast:s}=k(),a=N(["status","gateway"],{url:"/api/status",method:"GET"},{staleTime:6e4});r.useEffect(()=>{a.isError&&a.error&&s({title:t("about.toast.statusError.title"),description:a.error.message,variant:"error"})},[a.isError,a.error,s,t]);const n=_.version,l=r.useMemo(()=>{const u=L,f=u.VITE_BUILD_TIME,g=u.VITE_NODE_VERSION;return{buildTime:f,nodeVersion:g}},[]),h=r.useMemo(()=>[{label:t("about.app.labels.name"),value:e.jsx("span",{className:"font-mono text-sm font-semibold text-slate-900 dark:text-slate-100",children:"cc-gw"})},{label:t("about.app.labels.version"),value:e.jsxs("span",{className:"font-mono text-sm font-semibold text-blue-700 dark:text-blue-200",children:["v",n]})},{label:t("about.app.labels.buildTime"),value:l.buildTime,hint:t("about.app.hint.buildTime")},{label:t("about.app.labels.node"),value:e.jsx("span",{className:"font-mono text-sm text-slate-800 dark:text-slate-200",children:l.nodeVersion})}],[n,l.buildTime,l.nodeVersion,t]),c=r.useMemo(()=>a.data?[{label:t("about.status.labels.host"),value:a.data.host??"127.0.0.1"},{label:t("about.status.labels.port"),value:a.data.port.toLocaleString()},{label:t("about.status.labels.providers"),value:a.data.providers.toLocaleString()},{label:t("about.status.labels.active"),value:(a.data.activeRequests??0).toLocaleString(),hint:t("about.status.hint.active")}]:[],[a.data,t]),x=()=>{s({title:t("about.toast.updatesPlanned"),variant:"info"})};return e.jsxs("div",{className:"space-y-8",children:[e.jsx(w,{icon:e.jsx(y,{className:"h-6 w-6","aria-hidden":"true"}),title:t("about.title"),description:t("about.description"),badge:`v${n}`,actions:e.jsx(b,{variant:"primary",icon:e.jsx(E,{className:"h-4 w-4","aria-hidden":"true"}),onClick:x,children:t("about.support.actions.checkUpdates")})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(d,{title:t("about.app.title"),description:t("about.app.subtitle"),className:"h-full",contentClassName:"gap-4",children:e.jsx(m,{items:h})}),e.jsx(d,{title:t("about.status.title"),description:t("about.status.subtitle"),className:"h-full",contentClassName:"gap-4",actions:e.jsx(b,{variant:"subtle",size:"sm",icon:e.jsx(T,{className:"h-4 w-4","aria-hidden":"true"}),onClick:()=>a.refetch(),loading:a.isFetching,children:a.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")}),children:a.isLoading?e.jsxs("div",{className:"flex h-36 flex-col items-center justify-center gap-3 text-center",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-[3px] border-blue-500/30 border-t-blue-600 dark:border-blue-400/20 dark:border-t-blue-300"}),e.jsx("p",{className:o(i,"text-sm"),children:t("about.status.loading")})]}):c.length>0?e.jsx(m,{items:c}):e.jsxs("div",{className:"flex h-36 flex-col items-center justify-center gap-2 rounded-2xl border border-dashed border-slate-200/60 bg-white p-6 text-center shadow-inner dark:border-slate-700/60 dark:bg-slate-900/60",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:t("about.status.empty")}),e.jsx("p",{className:o(i,"text-xs"),children:t("common.actions.refresh")})]})})]}),e.jsx(d,{title:t("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-semibold text-blue-600 dark:text-blue-300",children:t("about.support.subtitle")}),e.jsx("span",{children:t("about.support.description")})]}),className:"relative overflow-hidden",contentClassName:"gap-6",children:e.jsxs("div",{className:"flex flex-col gap-4 rounded-3xl border border-slate-200/50 bg-white p-6 shadow-lg shadow-slate-200/30 backdrop-blur-md dark:border-slate-700/50 dark:bg-slate-900/80 dark:shadow-slate-900/40",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-4",children:[e.jsx("div",{className:"grid h-12 w-12 place-items-center rounded-2xl bg-gradient-to-br from-blue-500/20 to-indigo-500/20 text-blue-600 shadow-inner dark:text-blue-200",children:e.jsx(j,{className:"h-6 w-6","aria-hidden":"true"})}),e.jsx("p",{className:o(i,"text-sm leading-6"),children:t("about.support.tip")})]}),e.jsx("code",{className:"inline-flex items-center gap-2 self-start rounded-full border border-blue-200/50 bg-blue-50/80 px-4 py-2 text-xs font-semibold tracking-wide text-blue-700 shadow-sm dark:border-blue-500/30 dark:bg-blue-900/30 dark:text-blue-200",children:"~/.cc-gw/config.json"})]})})]})}export{P as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as T,u as W,a as J,r as d,j as e,L as X,N as Y,d as t,b as K,m as r,H as m,E as Z,k as ee,l as ae,f as se,h as te}from"./index-
|
|
1
|
+
import{c as T,u as W,a as J,r as d,j as e,L as X,N as Y,d as t,b as K,m as r,H as m,E as Z,k as ee,l as ae,f as se,h as te}from"./index-CAbsGgAq.js";import{E as le}from"./index-C2xoexDc.js";import{u as w}from"./useApiQuery-CNbY7eTZ.js";import{P as ie,a as q}from"./PageSection-BfMkaweN.js";import{F as I}from"./FormField-Dyi1Kr0k.js";import{I as re}from"./Input-DACzKnnk.js";import{B as C}from"./Button-DdVyALkb.js";import{S as ne}from"./StatusBadge-OH4R_aKr.js";import{C as ce}from"./copy-BVgnqUsP.js";/**
|
|
2
2
|
* @license lucide-react v0.344.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,d as c,J as i,E as p,k as b}from"./index-
|
|
1
|
+
import{j as s,d as c,J as i,E as p,k as b}from"./index-CAbsGgAq.js";function h({variant:n="subtle",size:o="md",children:a,loading:t,icon:e,className:l,disabled:r,...u}){const m={subtle:b,primary:p,danger:i}[n],x={sm:"h-8 px-3 text-xs",md:"h-10 px-4 text-sm",lg:"h-12 px-6 text-base"}[o];return s.jsx("button",{className:c(m,x,t&&"cursor-wait opacity-70",r&&"cursor-not-allowed opacity-50",l),disabled:r||t,...u,children:t?s.jsx("div",{className:"inline-block animate-spin rounded-full h-4 w-4 border-b-2 border-current"}):e?s.jsxs(s.Fragment,{children:[e,a]}):a})}export{h as B};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{c as R,u as q,a as ee,r as h,b as te,t as se,j as e,L as ae,B as D,d as o,m as g,g as B,e as $,f as O,h as re,l as U,s as oe,i as A,k as le,n as P}from"./index-CAbsGgAq.js";import{E as ie}from"./index-C2xoexDc.js";import{P as de,a as _}from"./PageSection-BfMkaweN.js";import{S as ne}from"./Input-DACzKnnk.js";import{S as ce}from"./StatusBadge-OH4R_aKr.js";import{u as L}from"./useApiQuery-CNbY7eTZ.js";/**
|
|
2
|
+
* @license lucide-react v0.344.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Q=R("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/**
|
|
7
|
+
* @license lucide-react v0.344.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const me=R("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
|
|
12
|
+
* @license lucide-react v0.344.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const xe=R("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);function E(t,a,s){return t==null?"-":`${t.toLocaleString(void 0,s)} ${a}`}function F(t){if(t==null)return"-";if(t<1024)return`${t} B`;const a=["KB","MB","GB","TB"];let s=t/1024,r=0;for(;s>=1024&&r<a.length-1;)s/=1024,r+=1;return`${s.toFixed(s>=100?0:s>=10?1:2)} ${a[r]}`}function ve(){var z;const{t}=q(),{pushToast:a}=ee(),[s,r]=h.useState("all"),[i,T]=h.useState(!1),u=s==="all"?void 0:s,j=L(["stats","overview",s],{url:"/api/stats/overview",method:"GET",params:u?{endpoint:u}:void 0}),v=L(["stats","daily",14,s],{url:"/api/stats/daily",method:"GET",params:{days:14,...u?{endpoint:u}:{}}}),y=L(["stats","model",7,6,s],{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...u?{endpoint:u}:{}}}),N=L(["status"],{url:"/api/status",method:"GET"}),f=L(["db","info"],{url:"/api/db/info",method:"GET"}),G=f.refetch??(async()=>{}),k=L(["logs","recent",s],{url:"/api/logs",method:"GET",params:{limit:5,...u?{endpoint:u}:{}}},{refetchInterval:3e4});h.useEffect(()=>{j.isError&&j.error&&a({title:t("dashboard.toast.overviewError"),description:j.error.message,variant:"error"})},[j.isError,j.error,a,t]),h.useEffect(()=>{v.isError&&v.error&&a({title:t("dashboard.toast.dailyError"),description:v.error.message,variant:"error"})},[v.isError,v.error,a,t]),h.useEffect(()=>{y.isError&&y.error&&a({title:t("dashboard.toast.modelError"),description:y.error.message,variant:"error"})},[y.isError,y.error,a,t]),h.useEffect(()=>{N.isError&&N.error&&a({title:t("dashboard.toast.statusError"),description:N.error.message,variant:"error"})},[N.isError,N.error,a,t]),h.useEffect(()=>{f.isError&&f.error&&a({title:t("dashboard.toast.dbError"),description:f.error.message,variant:"error"})},[f.isError,f.error,a,t]);const H=h.useCallback(async()=>{if(!i){T(!0);try{await te.post("/api/db/compact"),await G(),a({title:t("dashboard.toast.compactSuccess.title"),description:t("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(d){const p=se(d);a({title:t("dashboard.toast.compactError.title"),description:p.message,variant:"error"})}finally{T(!1)}}},[i,a,G,t]);h.useEffect(()=>{k.isError&&k.error&&a({title:t("dashboard.toast.recentError"),description:k.error.message,variant:"error"})},[k.isError,k.error,a,t]);const n=j.data,S=v.data??[],c=y.data??[],C=N.data,w=f.data,K=((z=k.data)==null?void 0:z.items)??[],V=w?F(w.totalBytes??w.sizeBytes):"-",J=w?F(w.memoryRssBytes??0):"-",W=h.useMemo(()=>{const d=S.map(x=>x.date),p=t("dashboard.charts.barRequests"),l=t("dashboard.charts.lineInput"),b=t("dashboard.charts.lineOutput"),m=t("dashboard.charts.lineCached");return{tooltip:{trigger:"axis",backgroundColor:"rgba(15, 23, 42, 0.9)",borderColor:"rgba(59, 130, 246, 0.3)",textStyle:{color:"#e2e8f0"}},legend:{data:[p,l,b,m],textStyle:{color:"#64748b"}},grid:{left:60,right:40,top:60,bottom:60},xAxis:{type:"category",data:d,axisLabel:{color:"#64748b"},axisLine:{lineStyle:{color:"#334155"}}},yAxis:{type:"value",axisLabel:{color:"#64748b"},axisLine:{lineStyle:{color:"#334155"}},splitLine:{lineStyle:{color:"#1e293b"}}},series:[{name:p,type:"bar",data:S.map(x=>x.requestCount),itemStyle:{color:"#3b82f6",borderRadius:[4,4,0,0]},emphasis:{itemStyle:{color:"#2563eb"}}},{name:l,type:"line",yAxisIndex:0,data:S.map(x=>x.inputTokens),smooth:!0,itemStyle:{color:"#10b981"},lineStyle:{width:3},symbol:"circle",symbolSize:6},{name:b,type:"line",yAxisIndex:0,data:S.map(x=>x.outputTokens),smooth:!0,itemStyle:{color:"#f59e0b"},lineStyle:{width:3},symbol:"circle",symbolSize:6},{name:m,type:"line",yAxisIndex:0,data:S.map(x=>x.cachedTokens),smooth:!0,itemStyle:{color:"#8b5cf6"},lineStyle:{width:3},symbol:"circle",symbolSize:6}]}},[S,t]),X=h.useMemo(()=>{const d=c.map(m=>`${m.provider}/${m.model}`),p=t("dashboard.charts.barRequests"),l=t("dashboard.charts.lineInput"),b=t("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis",backgroundColor:"rgba(15, 23, 42, 0.9)",borderColor:"rgba(59, 130, 246, 0.3)",textStyle:{color:"#e2e8f0"}},legend:{data:[p,l,b],textStyle:{color:"#64748b"}},grid:{left:80,right:60,top:60,bottom:100},xAxis:{type:"category",data:d,axisLabel:{rotate:30,color:"#64748b"},axisLine:{lineStyle:{color:"#334155"}}},yAxis:[{type:"value",name:p,axisLabel:{color:"#64748b"},axisLine:{lineStyle:{color:"#334155"}},splitLine:{lineStyle:{color:"#1e293b"}}},{type:"value",name:t("dashboard.charts.axisTokens"),position:"right",axisLabel:{color:"#64748b"},axisLine:{lineStyle:{color:"#334155"}}}],series:[{name:p,type:"bar",data:c.map(m=>m.requests),itemStyle:{color:"#6366f1",borderRadius:[4,4,0,0]},yAxisIndex:0},{name:l,type:"line",yAxisIndex:1,smooth:!0,data:c.map(m=>m.inputTokens??0),itemStyle:{color:"#10b981"},lineStyle:{width:3}},{name:b,type:"line",yAxisIndex:1,smooth:!0,data:c.map(m=>m.outputTokens??0),itemStyle:{color:"#f59e0b"},lineStyle:{width:3}}]}},[c,t]),Y=h.useMemo(()=>{const d=c.map(l=>`${l.provider}/${l.model}`),p=t("dashboard.charts.ttftLabel");return{tooltip:{trigger:"axis",backgroundColor:"rgba(15, 23, 42, 0.9)",borderColor:"rgba(59, 130, 246, 0.3)",textStyle:{color:"#e2e8f0"},formatter(l){var x;if(!Array.isArray(l)||l.length===0)return"";const b=((x=l[0])==null?void 0:x.dataIndex)??0,m=c[b];return m?`<strong>${d[b]}</strong><br/>${p}: ${E(m.avgTtftMs,t("common.units.ms"))}`:""}},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:d,axisLabel:{rotate:30,color:"#64748b"},axisLine:{lineStyle:{color:"#334155"}}},yAxis:{type:"value",name:t("dashboard.charts.ttftAxis"),axisLabel:{color:"#64748b"},axisLine:{lineStyle:{color:"#334155"}},splitLine:{lineStyle:{color:"#1e293b"}}},series:[{name:p,type:"bar",data:c.map(l=>l.avgTtftMs??0),itemStyle:{color:"#3b82f6",borderRadius:[4,4,0,0]}}]}},[c,t]),Z=h.useMemo(()=>{const d=c.map(l=>`${l.provider}/${l.model}`),p=t("dashboard.charts.tpotLabel");return{tooltip:{trigger:"axis",backgroundColor:"rgba(15, 23, 42, 0.9)",borderColor:"rgba(59, 130, 246, 0.3)",textStyle:{color:"#e2e8f0"},formatter(l){var x;if(!Array.isArray(l)||l.length===0)return"";const b=((x=l[0])==null?void 0:x.dataIndex)??0,m=c[b];return m?`<strong>${d[b]}</strong><br/>${p}: ${E(m.avgTpotMs,t("common.units.msPerToken"),{maximumFractionDigits:2})}`:""}},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:d,axisLabel:{rotate:30,color:"#64748b"},axisLine:{lineStyle:{color:"#334155"}}},yAxis:{type:"value",name:t("dashboard.charts.tpotAxis"),axisLabel:{color:"#64748b"},axisLine:{lineStyle:{color:"#334155"}},splitLine:{lineStyle:{color:"#1e293b"}}},series:[{name:p,type:"bar",data:c.map(l=>l.avgTpotMs??0),itemStyle:{color:"#f59e0b",borderRadius:[4,4,0,0]}}]}},[c,t]);return j.isPending||N.isPending||f.isPending?e.jsx(ae,{}):e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(de,{icon:e.jsx(D,{className:"h-7 w-7","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description"),actions:e.jsxs("div",{className:"flex items-center gap-4 rounded-2xl bg-white/90 px-4 py-3 shadow-lg shadow-slate-200/30 ring-1 ring-slate-200/40 backdrop-blur-lg dark:bg-slate-900/90 dark:shadow-xl dark:shadow-slate-900/30 dark:ring-slate-700/40",children:[e.jsx("label",{htmlFor:"dashboard-endpoint-filter",className:"text-xs font-bold uppercase tracking-[0.15em] text-slate-600 dark:text-slate-300",children:t("dashboard.filters.endpoint")}),e.jsx("div",{className:"relative",children:e.jsx(ne,{id:"dashboard-endpoint-filter",value:s,onChange:d=>r(d.target.value),options:[{value:"all",label:t("dashboard.filters.endpointAll")},{value:"anthropic",label:t("dashboard.filters.endpointAnthropic")},{value:"openai",label:t("dashboard.filters.endpointOpenAI")}]})})]})}),C?e.jsxs("section",{className:o(B,"flex flex-wrap items-center gap-4 text-sm leading-relaxed animate-slide-up"),"aria-live":"polite",children:[e.jsxs("span",{className:o(oe.success,"inline-flex items-center gap-2 rounded-full px-4 py-2 font-semibold"),children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-current shadow-lg","aria-hidden":"true"}),t("dashboard.status.listening",{host:C.host??"0.0.0.0",port:C.port})]}),e.jsx("span",{className:o(A.default,"font-semibold"),children:t("dashboard.status.providers",{value:C.providers.toLocaleString()})}),e.jsx("span",{className:o(A.primary,"font-semibold"),children:t("dashboard.status.todayRequests",{value:((n==null?void 0:n.today.requests)??0).toLocaleString()})}),e.jsx("span",{className:o(A.default,"font-semibold"),children:t("dashboard.status.active",{value:(C.activeRequests??0).toLocaleString()})}),e.jsx("span",{className:o(A.default,"font-semibold"),children:t("dashboard.status.dbSize",{value:V})}),e.jsx("span",{className:o(A.default,"font-semibold"),children:t("dashboard.status.memory",{value:J})}),e.jsx("button",{type:"button",onClick:H,disabled:i,className:o(le,"h-9 rounded-full px-4 text-xs font-semibold",i?"cursor-wait opacity-70":""),children:t(i?"dashboard.actions.compacting":"dashboard.actions.compact")})]}):null,e.jsxs("section",{className:o(P.fixed[5],"gap-4 sm:gap-6"),children:[e.jsx(M,{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"),trend:"+12%",trendDirection:"up"}),e.jsx(M,{icon:e.jsx(xe,{className:"h-5 w-5"}),title:t("dashboard.cards.todayInput"),value:(n==null?void 0:n.today.inputTokens)??0,suffix:t("common.units.token"),trend:"+8%",trendDirection:"up"}),e.jsx(M,{icon:e.jsx(Q,{className:"h-5 w-5"}),title:t("dashboard.cards.todayCached"),value:(n==null?void 0:n.today.cachedTokens)??0,suffix:t("common.units.token")}),e.jsx(M,{icon:e.jsx(D,{className:"h-5 w-5"}),title:t("dashboard.cards.todayOutput"),value:(n==null?void 0:n.today.outputTokens)??0,suffix:t("common.units.token"),trend:"+15%",trendDirection:"up"}),e.jsx(M,{icon:e.jsx(me,{className:"h-5 w-5"}),title:t("dashboard.cards.avgLatency"),value:(n==null?void 0:n.today.avgLatencyMs)??0,suffix:t("common.units.ms"),trend:"-5%",trendDirection:"down"})]}),e.jsxs("div",{className:o(P.fixed[2],"gap-6 sm:gap-8"),children:[e.jsx(I,{title:t("dashboard.charts.requestsTitle"),description:t("dashboard.charts.requestsDesc"),loading:v.isPending,option:W,empty:!S.length,emptyText:t("dashboard.charts.empty")}),e.jsx(I,{title:t("dashboard.charts.modelTitle"),description:t("dashboard.charts.modelDesc"),loading:y.isPending,option:X,empty:!c.length,emptyText:t("dashboard.charts.empty")})]}),e.jsxs("div",{className:o(P.fixed[2],"gap-6 sm:gap-8"),children:[e.jsx(I,{title:t("dashboard.charts.ttftTitle"),description:t("dashboard.charts.ttftDesc"),loading:y.isPending,option:Y,empty:!c.some(d=>d.avgTtftMs!=null&&d.avgTtftMs>0),emptyText:t("dashboard.charts.ttftEmpty")}),e.jsx(I,{title:t("dashboard.charts.tpotTitle"),description:t("dashboard.charts.tpotDesc"),loading:y.isPending,option:Z,empty:!c.some(d=>d.avgTpotMs!=null&&d.avgTpotMs>0),emptyText:t("dashboard.charts.tpotEmpty")})]}),e.jsx(pe,{models:c,loading:y.isPending}),e.jsx(he,{loading:k.isPending,records:K})]})}function M({icon:t,title:a,value:s,suffix:r,trend:i,trendDirection:T}){return e.jsxs("div",{className:o(B,"group hover-lift animate-slide-up"),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:o(g,"text-xs font-bold uppercase tracking-[0.15em]"),children:a}),t&&e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-gradient-to-br from-blue-600/15 to-indigo-600/10 text-blue-600 ring-1 ring-blue-500/20 dark:from-blue-500/25 dark:to-indigo-500/15 dark:text-blue-200 dark:ring-blue-400/20",children:t})]}),e.jsx("div",{className:"flex items-end justify-between",children:e.jsxs("div",{children:[e.jsxs("p",{className:"text-3xl font-bold text-slate-900 dark:text-slate-50",children:[s.toLocaleString(),r?e.jsx("span",{className:o(g,"ml-2 text-base sm:text-lg font-medium"),children:r}):null]}),i&&e.jsxs("div",{className:o("mt-2 flex items-center gap-1 text-xs font-semibold",T==="up"?"text-emerald-600 dark:text-emerald-400":"text-red-600 dark:text-red-400"),children:[e.jsx("span",{children:i}),e.jsx("span",{className:"text-slate-500",children:"vs last period"})]})]})})]})}function I({title:t,description:a,option:s,loading:r,empty:i,emptyText:T}){const{t:u}=q();return e.jsxs("div",{className:o(B,"space-y-4 sm:space-y-6 hover-lift animate-slide-up"),children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold text-slate-900 dark:text-slate-50",children:t}),e.jsx("p",{className:o(g,"mt-2 text-xs sm:text-sm leading-relaxed"),children:a})]}),r?e.jsx("div",{className:$.container,children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:$.spinner}),e.jsx("span",{className:o($.text),children:u("common.loadingShort")})]})}):i?e.jsx("div",{className:O,children:e.jsxs("div",{className:"text-center",children:[e.jsx(D,{className:"mx-auto h-12 w-12 text-slate-300 dark:text-slate-600 mb-4"}),e.jsx("span",{className:o(g,"text-sm"),children:T??u("dashboard.charts.empty")})]})}):e.jsx(ie,{option:s,style:{height:320},notMerge:!0,lazyUpdate:!0,theme:void 0,className:re})]})}function pe({models:t,loading:a}){const{t:s}=q(),r=t.length>0;return e.jsx(_,{title:e.jsx("span",{className:"text-sm font-semibold text-slate-900 dark:text-slate-50",children:s("dashboard.modelTable.title")}),description:s("dashboard.modelTable.description"),contentClassName:"gap-0 overflow-hidden p-0",children:a?e.jsx("div",{className:U,children:e.jsx("span",{className:o(g,"text-sm"),children:s("common.loadingShort")})}):r?e.jsx("div",{className:"max-h-80 overflow-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-slate-200/70 text-sm dark:divide-slate-700/60",children:[e.jsx("caption",{className:"sr-only",children:s("dashboard.modelTable.title")}),e.jsx("thead",{className:"bg-slate-100/70 text-left text-xs font-semibold uppercase tracking-wide text-slate-500 dark:bg-slate-800/60 dark:text-slate-400",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-5 py-3 font-semibold",children:s("dashboard.modelTable.columns.model")}),e.jsx("th",{className:"px-5 py-3 text-right font-semibold",children:s("dashboard.modelTable.columns.requests")}),e.jsx("th",{className:"px-5 py-3 text-right font-semibold",children:s("dashboard.modelTable.columns.latency")}),e.jsx("th",{className:"px-5 py-3 text-right font-semibold",children:s("dashboard.modelTable.columns.ttft")}),e.jsx("th",{className:"px-5 py-3 text-right font-semibold",children:s("dashboard.modelTable.columns.tpot")})]})}),e.jsx("tbody",{className:"divide-y divide-slate-200/60 dark:divide-slate-800/60",children:t.map(i=>e.jsxs("tr",{className:"transition hover:bg-slate-50/70 dark:hover:bg-slate-800/40",children:[e.jsx("td",{className:"px-5 py-3",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-50",children:i.provider}),e.jsx("span",{className:o(g,"text-xs"),children:i.model})]})}),e.jsx("td",{className:"px-5 py-3 text-right font-medium text-slate-800 dark:text-slate-50",children:i.requests.toLocaleString()}),e.jsx("td",{className:"px-5 py-3 text-right",children:E(i.avgLatencyMs,s("common.units.ms"))}),e.jsx("td",{className:"px-5 py-3 text-right",children:E(i.avgTtftMs,s("common.units.ms"))}),e.jsx("td",{className:"px-5 py-3 text-right",children:E(i.avgTpotMs,s("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${i.provider}/${i.model}`))})]})}):e.jsx("div",{className:O,children:e.jsx("span",{className:o(g,"text-sm"),children:s("dashboard.modelTable.empty")})})})}function he({records:t,loading:a}){const{t:s}=q();return e.jsx(_,{title:e.jsx("span",{className:"text-sm font-semibold text-slate-900 dark:text-slate-50",children:s("dashboard.recent.title")}),description:s("dashboard.recent.subtitle",{count:5}),contentClassName:"gap-0 overflow-hidden p-0",children:a?e.jsx("div",{className:U,children:e.jsx("span",{className:o(g,"text-sm"),children:s("dashboard.recent.loading")})}):t.length===0?e.jsx("div",{className:O,children:e.jsx("span",{className:o(g,"text-sm"),children:s("dashboard.recent.empty")})}):e.jsx("div",{className:"max-h-80 overflow-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-slate-200/70 text-sm dark:divide-slate-700/60",children:[e.jsx("caption",{className:"sr-only",children:s("dashboard.recent.title")}),e.jsx("thead",{className:"bg-slate-100/70 text-left text-xs font-semibold uppercase tracking-wide text-slate-500 dark:bg-slate-800/60 dark:text-slate-400",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-5 py-3 font-semibold",children:s("dashboard.recent.columns.time")}),e.jsx("th",{className:"px-5 py-3 font-semibold",children:s("dashboard.recent.columns.endpoint")}),e.jsx("th",{className:"px-5 py-3 font-semibold",children:s("dashboard.recent.columns.provider")}),e.jsx("th",{className:"px-5 py-3 font-semibold",children:s("dashboard.recent.columns.route")}),e.jsx("th",{className:"px-5 py-3 text-right font-semibold",children:s("dashboard.recent.columns.latency")}),e.jsx("th",{className:"px-5 py-3 text-left font-semibold",children:s("dashboard.recent.columns.status")})]})}),e.jsx("tbody",{className:"divide-y divide-slate-200/60 dark:divide-slate-800/60",children:t.map(r=>e.jsxs("tr",{className:"transition hover:bg-slate-50/70 dark:hover:bg-slate-800/40",children:[e.jsx("td",{className:"px-5 py-3 text-xs font-medium text-slate-600 dark:text-slate-300",children:new Date(r.timestamp).toLocaleString()}),e.jsx("td",{className:"px-5 py-3 text-xs text-slate-500 dark:text-slate-400",children:r.endpoint==="anthropic"?s("logs.table.endpointAnthropic"):r.endpoint==="openai"?s("logs.table.endpointOpenAI"):r.endpoint}),e.jsx("td",{className:"px-5 py-3 text-sm font-medium text-slate-800 dark:text-slate-50",children:r.provider}),e.jsx("td",{className:"px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500 dark:text-slate-400",children:[e.jsx("span",{children:r.client_model??s("dashboard.recent.routePlaceholder")}),e.jsx("span",{"aria-hidden":"true",className:"text-slate-400",children:"→"}),e.jsx("span",{className:"font-semibold text-slate-700 dark:text-slate-100",children:r.model})]})}),e.jsx("td",{className:"px-5 py-3 text-right text-sm font-medium text-slate-800 dark:text-slate-100",children:E(r.latency_ms,s("common.units.ms"))}),e.jsx("td",{className:"px-5 py-3",children:e.jsxs(ce,{variant:r.error?"error":"success",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-current","aria-hidden":"true"}),(r.status_code??(r.error?500:200)).toString(),e.jsx("span",{children:r.error?s("common.status.error"):s("common.status.success")})]})})]},r.id))})]})})})}export{ve as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,d,P as m,Q as x}from"./index-
|
|
1
|
+
import{j as s,d,P as m,Q as x}from"./index-CAbsGgAq.js";function i({label:a,children:l,className:t,required:r,error:e}){return s.jsxs("div",{className:d(x,t),children:[s.jsxs("label",{className:m,children:[a,r&&s.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),l,e&&s.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:e})]})}export{i as F};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as u,u as p,r as b,j as e,d as x,m}from"./index-
|
|
1
|
+
import{c as u,u as p,r as b,j as e,d as x,m}from"./index-CAbsGgAq.js";import{P as g,a as o}from"./PageSection-BfMkaweN.js";import{I as j}from"./info-CpmSkfUl.js";/**
|
|
2
2
|
* @license lucide-react v0.344.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,j as e,d as n,M as c,K as i}from"./index-
|
|
1
|
+
import{r as d,j as e,d as n,M as c,K as i}from"./index-CAbsGgAq.js";const f=d.forwardRef(({options:t,placeholder:s,className:r,...l},u)=>e.jsxs("select",{ref:u,className:n(c,r),...l,children:[s&&e.jsx("option",{value:"",disabled:!0,children:s}),t.map(a=>e.jsx("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]})),j=d.forwardRef(({variant:t="default",className:s,...r},l)=>e.jsx("input",{ref:l,className:n(i,s),...r}));export{j as I,f as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as y,a8 as E,a9 as C,aa as S,r as l,j as e,d,L as _,m as j,K as v,E as L}from"./index-
|
|
1
|
+
import{u as y,a8 as E,a9 as C,aa as S,r as l,j as e,d,L as _,m as j,K as v,E as L}from"./index-CAbsGgAq.js";function P(){const{t:a}=y(),o=E(),m=C(),{authEnabled:n,isAuthenticated:x,loading:i,login:k,error:b}=S(),[r,h]=l.useState({username:"",password:""}),[f,u]=l.useState(null),[p,g]=l.useState(!1),c=l.useMemo(()=>{var t;const s=m.state;return((t=s==null?void 0:s.from)==null?void 0:t.pathname)??"/"},[m.state]);l.useEffect(()=>{if(!n&&!i){o(c,{replace:!0});return}n&&x&&!i&&o(c,{replace:!0})},[n,x,i,o,c]);const N=async s=>{if(s.preventDefault(),u(null),!r.username.trim()||!r.password){u(a("login.validation.required"));return}g(!0);try{await k(r.username.trim(),r.password),o(c,{replace:!0})}catch(t){u(t instanceof Error?t.message:a("login.validation.failed"))}finally{g(!1)}},w=s=>e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-gradient-to-br from-slate-100 via-white to-slate-200 px-4 dark:from-slate-950/95 dark:via-slate-950 dark:to-slate-900",children:[e.jsxs("div",{className:"pointer-events-none absolute inset-0",children:[e.jsx("div",{className:"absolute left-10 top-20 h-48 w-48 rounded-full bg-slate-200/40 blur-3xl dark:bg-slate-700/30"}),e.jsx("div",{className:"absolute right-16 bottom-32 h-56 w-56 rounded-full bg-slate-300/35 blur-3xl dark:bg-slate-800/30"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_top,_rgba(15,23,42,0.08),_transparent_55%)]"})]}),e.jsx("div",{className:"relative z-10 w-full max-w-lg",children:s})]});return i?w(e.jsx("div",{className:"flex min-h-[320px] items-center justify-center rounded-3xl border border-blue-200/60 bg-white/90 shadow-2xl shadow-blue-200/50 backdrop-blur-xl dark:border-slate-800/50 dark:bg-slate-900/80 dark:shadow-slate-900/60",children:e.jsx(_,{})})):n?w(e.jsxs("main",{className:"rounded-3xl border border-slate-200/70 bg-white/95 px-8 pb-10 pt-9 shadow-2xl shadow-slate-200/40 backdrop-blur-xl dark:border-slate-800/60 dark:bg-slate-900/85 dark:shadow-slate-900/60",children:[e.jsxs("header",{className:"mb-8 flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-gradient-to-br from-slate-900 via-slate-800 to-slate-700 text-xl font-bold text-white shadow-lg shadow-slate-400/30 dark:from-blue-500 dark:via-blue-600 dark:to-indigo-600 dark:shadow-blue-900/40",children:"GW"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-900 dark:text-slate-50",children:a("login.title")}),e.jsx("p",{className:d(j,"text-sm leading-relaxed max-w-[360px]"),children:a("login.description")})]})]}),e.jsxs("form",{className:"space-y-5",onSubmit:N,children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:a("login.fields.username")}),e.jsx("input",{value:r.username,autoComplete:"username",autoFocus:!0,onChange:s=>h(t=>({...t,username:s.target.value})),placeholder:a("login.fields.usernamePlaceholder"),className:d(v,"h-11 font-medium")})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:a("login.fields.password")}),e.jsx("input",{type:"password",value:r.password,autoComplete:"current-password",onChange:s=>h(t=>({...t,password:s.target.value})),placeholder:a("login.fields.passwordPlaceholder"),className:d(v,"h-11")})]}),f||b?e.jsx("div",{className:"rounded-2xl border border-red-200/70 bg-red-50/80 px-4 py-3 text-sm font-medium text-red-600 shadow-sm shadow-red-200/40 dark:border-red-500/40 dark:bg-red-500/15 dark:text-red-100",children:f||b}):null,e.jsx("button",{type:"submit",className:d(L,"w-full justify-center rounded-full py-3 text-sm font-semibold"),disabled:p,children:a(p?"common.actions.loading":"login.actions.submit")})]}),e.jsx("footer",{className:"mt-7 text-center text-xs",children:e.jsx("p",{className:d(j,"leading-relaxed"),children:a("login.hint")})})]})):null}export{P as default};
|