feat: add token usage tracking and leaderboard
- Add token_usage table with composite unique index for claw_id + date - Add API endpoints: POST /token, GET /token/leaderboard, GET /token/stats - Add TokenLeaderboard component with daily/total period toggle - Add CLI commands: `token` and `stats` for reporting and viewing usage - Add Redis caching for leaderboard with 1-minute TTL - Add shared utilities: authenticateRequest, getTodayDateString - Use UPSERT pattern for atomic token updates - Add i18n translations (en/zh) for new UI elements
This commit is contained in:
@@ -3,6 +3,8 @@ import { detectLocale, createTranslator, type Locale } from "./i18n/index.js";
|
||||
import { registerCommand } from "./commands/register.js";
|
||||
import { heartbeatCommand } from "./commands/heartbeat.js";
|
||||
import { taskCommand } from "./commands/task.js";
|
||||
import { tokenCommand } from "./commands/token.js";
|
||||
import { statsCommand } from "./commands/stats.js";
|
||||
import { configCommand } from "./commands/config.js";
|
||||
import { readConfig } from "./lib/config.js";
|
||||
import { DEFAULT_ENDPOINT } from "./lib/api.js";
|
||||
@@ -59,6 +61,8 @@ function main(): void {
|
||||
registerCommand(program, t);
|
||||
heartbeatCommand(program, t);
|
||||
taskCommand(program, t);
|
||||
tokenCommand(program, t);
|
||||
statsCommand(program, t);
|
||||
configCommand(program, t);
|
||||
|
||||
// Parse
|
||||
|
||||
Reference in New Issue
Block a user