Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4b3083b
[ImgBot] Optimize images
ImgBotApp Nov 18, 2025
1e1f7f0
feat(rate-limit): add daily cost limit with configurable daily reset …
cto-new[bot] Nov 18, 2025
687901d
chore: format code (feat-add-daily-limit-custom-reset-time-fix-provid…
github-actions[bot] Nov 18, 2025
6b466b4
Optimize images
Silentely Nov 18, 2025
e4032aa
feat(rate-limit): add daily limit fields for keys/providers
cto-new[bot] Nov 18, 2025
0350507
fix
Silentely Nov 19, 2025
fc62260
feat(rate-limit): 添加每日限额重置模式支持(固定时间与滚动窗口)
Silentely Nov 19, 2025
d5902f8
chore: format code (feat-add-daily-limit-custom-reset-time-fix-provid…
github-actions[bot] Nov 19, 2025
7019056
fix(usage-doc): 删除重复的配置路径声明
Silentely Nov 19, 2025
59a0326
feat: 实现日限额支持固定和滚动两种重置模式
Silentely Nov 19, 2025
5668997
chore: format code (feat-add-daily-limit-custom-reset-time-fix-provid…
github-actions[bot] Nov 19, 2025
2cc5cd1
Merge pull request #15 from Silentely/feat-add-daily-limit-custom-res…
Silentely Nov 19, 2025
74a560f
fix: 修复每日成本限制重置时间显示问题
Silentely Nov 19, 2025
f7c5fe0
feat: 改进错误响应格式,提供更详细的限流和熔断错误信息
Silentely Nov 19, 2025
b8cda4e
fix: 修复provider选择器中的空指针异常
Silentely Nov 19, 2025
9802f65
feat: 优化供应商错误处理和限流信息展示
Silentely Nov 19, 2025
1aa44dc
delete(docs): 移除测试文件
Silentely Nov 19, 2025
3a01c4b
chore: format code (dev-1aa44dc)
github-actions[bot] Nov 19, 2025
3a935ab
Merge remote-tracking branch 'upstream/dev' into dev
Silentely Nov 19, 2025
03fd0d2
chore: format code (dev-3a935ab)
github-actions[bot] Nov 19, 2025
ceea8ac
删除遗留测试文件
Silentely Nov 20, 2025
404e2bf
切换到bun包管理
Silentely Nov 20, 2025
0846883
fix: 重新排序数据库迁移文件避免与上游冲突
Silentely Nov 21, 2025
a8e3723
refactor: 合并每日成本限额相关的三个迁移文件为一个
Silentely Nov 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 30 additions & 35 deletions bun.lock

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions drizzle/0021_daily_cost_limits.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- 每日成本限额功能 - 统一迁移文件
-- 包含:添加字段、设置约束、添加重置模式

-- Step 1: 添加基础字段
ALTER TABLE "keys" ADD COLUMN "limit_daily_usd" numeric(10, 2);--> statement-breakpoint
ALTER TABLE "keys" ADD COLUMN "daily_reset_time" varchar(5) DEFAULT '00:00';--> statement-breakpoint
ALTER TABLE "keys" ADD COLUMN "daily_reset_mode" varchar(10) DEFAULT 'fixed' NOT NULL;--> statement-breakpoint
ALTER TABLE "providers" ADD COLUMN "limit_daily_usd" numeric(10, 2);--> statement-breakpoint
ALTER TABLE "providers" ADD COLUMN "daily_reset_time" varchar(5) DEFAULT '00:00';--> statement-breakpoint
ALTER TABLE "providers" ADD COLUMN "daily_reset_mode" varchar(10) DEFAULT 'fixed' NOT NULL;--> statement-breakpoint

-- Step 2: 数据清理和约束设置
UPDATE "keys"
SET "daily_reset_time" = '00:00'
WHERE "daily_reset_time" IS NULL OR trim("daily_reset_time") = '';--> statement-breakpoint
ALTER TABLE "keys" ALTER COLUMN "daily_reset_time" SET DEFAULT '00:00';--> statement-breakpoint
ALTER TABLE "keys" ALTER COLUMN "daily_reset_time" SET NOT NULL;--> statement-breakpoint
UPDATE "providers"
SET "daily_reset_time" = '00:00'
WHERE "daily_reset_time" IS NULL OR trim("daily_reset_time") = '';--> statement-breakpoint
ALTER TABLE "providers" ALTER COLUMN "daily_reset_time" SET DEFAULT '00:00';--> statement-breakpoint
ALTER TABLE "providers" ALTER COLUMN "daily_reset_time" SET NOT NULL;
28 changes: 27 additions & 1 deletion drizzle/meta/0018_snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@
"primaryKey": false,
"notNull": false
},
"limit_daily_usd": {
"name": "limit_daily_usd",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"daily_reset_time": {
"name": "daily_reset_time",
"type": "varchar(5)",
"primaryKey": false,
"notNull": false,
"default": "'00:00'"
},
"limit_weekly_usd": {
"name": "limit_weekly_usd",
"type": "numeric(10, 2)",
Expand Down Expand Up @@ -940,6 +953,19 @@
"primaryKey": false,
"notNull": false
},
"limit_daily_usd": {
"name": "limit_daily_usd",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"daily_reset_time": {
"name": "daily_reset_time",
"type": "varchar(5)",
"primaryKey": false,
"notNull": false,
"default": "'00:00'"
},
"limit_weekly_usd": {
"name": "limit_weekly_usd",
"type": "numeric(10, 2)",
Expand Down Expand Up @@ -1471,4 +1497,4 @@
"schemas": {},
"tables": {}
}
}
}
28 changes: 27 additions & 1 deletion drizzle/meta/0019_snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@
"primaryKey": false,
"notNull": false
},
"limit_daily_usd": {
"name": "limit_daily_usd",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"daily_reset_time": {
"name": "daily_reset_time",
"type": "varchar(5)",
"primaryKey": false,
"notNull": true,
"default": "'00:00'"
},
"limit_weekly_usd": {
"name": "limit_weekly_usd",
"type": "numeric(10, 2)",
Expand Down Expand Up @@ -940,6 +953,19 @@
"primaryKey": false,
"notNull": false
},
"limit_daily_usd": {
"name": "limit_daily_usd",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"daily_reset_time": {
"name": "daily_reset_time",
"type": "varchar(5)",
"primaryKey": false,
"notNull": true,
"default": "'00:00'"
},
"limit_weekly_usd": {
"name": "limit_weekly_usd",
"type": "numeric(10, 2)",
Expand Down Expand Up @@ -1492,4 +1518,4 @@
"schemas": {},
"tables": {}
}
}
}
42 changes: 41 additions & 1 deletion drizzle/meta/0020_snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,26 @@
"primaryKey": false,
"notNull": false
},
"limit_daily_usd": {
"name": "limit_daily_usd",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"daily_reset_mode": {
"name": "daily_reset_mode",
"type": "varchar(10)",
"primaryKey": false,
"notNull": true,
"default": "'fixed'"
},
"daily_reset_time": {
"name": "daily_reset_time",
"type": "varchar(5)",
"primaryKey": false,
"notNull": true,
"default": "'00:00'"
},
"limit_weekly_usd": {
"name": "limit_weekly_usd",
"type": "numeric(10, 2)",
Expand Down Expand Up @@ -940,6 +960,26 @@
"primaryKey": false,
"notNull": false
},
"limit_daily_usd": {
"name": "limit_daily_usd",
"type": "numeric(10, 2)",
"primaryKey": false,
"notNull": false
},
"daily_reset_mode": {
"name": "daily_reset_mode",
"type": "varchar(10)",
"primaryKey": false,
"notNull": true,
"default": "'fixed'"
},
"daily_reset_time": {
"name": "daily_reset_time",
"type": "varchar(5)",
"primaryKey": false,
"notNull": true,
"default": "'00:00'"
},
"limit_weekly_usd": {
"name": "limit_weekly_usd",
"type": "numeric(10, 2)",
Expand Down Expand Up @@ -1516,4 +1556,4 @@
"schemas": {},
"tables": {}
}
}
}
9 changes: 8 additions & 1 deletion drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@
"when": 1763465177387,
"tag": "0020_next_juggernaut",
"breakpoints": true
},
{
"idx": 21,
"version": "7",
"when": 1763823720000,
"tag": "0021_daily_cost_limits",
"breakpoints": true
}
]
}
}
12 changes: 12 additions & 0 deletions messages/en/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"billingDescription": "The system prioritizes billing based on the price of the requested model ({original}). If the model is not found in the price list, the price of the actually called model ({current}) is used."
},
"errorMessage": "Error Message",
"filteredProviders": "Filtered Providers",
"providerChain": {
"title": "Provider Decision Chain Timeline",
"totalDuration": "Total Duration: {duration}ms"
Expand Down Expand Up @@ -477,6 +478,7 @@
"error": "Fetch failed",
"networkError": "Network error",
"cost5h": "5-Hour Cost",
"costDaily": "Daily Cost",
"costWeekly": "Weekly Cost",
"costMonthly": "Monthly Cost",
"concurrentSessions": "Concurrent Sessions",
Expand Down Expand Up @@ -505,6 +507,16 @@
"placeholder": "Leave blank for unlimited",
"description": "Maximum cost within 5 hours"
},
"limitDailyUsd": {
"label": "Daily Cost Limit (USD)",
"placeholder": "Leave blank for unlimited",
"description": "Maximum cost per day"
},
"dailyResetTime": {
"label": "Daily Reset Time",
"placeholder": "HH:mm",
"description": "When the daily limit resets (uses system timezone)"
},
"limitWeeklyUsd": {
"label": "Weekly Cost Limit (USD)",
"placeholder": "Leave blank for unlimited",
Expand Down
24 changes: 24 additions & 0 deletions messages/en/quota.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
"cost5h": {
"label": "5-Hour Cost"
},
"costDaily": {
"label": "Daily Cost",
"resetAt": "Resets at"
},
"costWeekly": {
"label": "Weekly Cost",
"resetAt": "Resets at"
Expand Down Expand Up @@ -136,6 +140,7 @@
"keyName": "Key Name",
"quotaType": "Quota Type",
"cost5h": "5-Hour Quota",
"costDaily": "Daily Quota",
"costWeekly": "Weekly Quota",
"costMonthly": "Monthly Quota",
"concurrentSessions": "Concurrent Limit",
Expand All @@ -160,6 +165,15 @@
"placeholder": "Unlimited",
"current": "Current usage: {currency}{current} / {currency}{limit}"
},
"costDaily": {
"label": "Daily Quota (USD)",
"placeholder": "Unlimited",
"current": "Current usage: {currency}{current} / {currency}{limit}"
},
"dailyResetTime": {
"label": "Daily Reset Time",
"placeholder": "HH:mm"
},
"costWeekly": {
"label": "Weekly Quota (USD)",
"placeholder": "Unlimited",
Expand Down Expand Up @@ -225,6 +239,16 @@
"placeholder": "Leave blank for unlimited",
"description": "Maximum cost within 5 hours"
},
"limitDailyUsd": {
"label": "Daily Cost Limit (USD)",
"placeholder": "Leave blank for unlimited",
"description": "Maximum cost per day"
},
"dailyResetTime": {
"label": "Daily Reset Time",
"placeholder": "HH:mm",
"description": "When the daily limit resets (uses system timezone)"
},
"limitWeeklyUsd": {
"label": "Weekly Cost Limit (USD)",
"placeholder": "Leave blank for unlimited",
Expand Down
19 changes: 19 additions & 0 deletions messages/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@
"title": "Rate Limit",
"summary": {
"fiveHour": "5h: ${amount}",
"daily": "Day: ${amount} (reset ${resetTime})",
"weekly": "Week: ${amount}",
"monthly": "Month: ${amount}",
"concurrent": "Concurrent: {count}",
Expand All @@ -976,6 +977,24 @@
"label": "5h Spend Limit (USD)",
"placeholder": "Leave empty for unlimited"
},
"limitDaily": {
"label": "Daily Spend Limit (USD)",
"placeholder": "Leave empty for unlimited"
},
"dailyResetMode": {
"label": "Daily Reset Mode",
"options": {
"fixed": "Fixed Time Reset",
"rolling": "Rolling Window (24h)"
},
"desc": {
"fixed": "Reset quota at a fixed time each day",
"rolling": "Reset 24 hours after first API call"
}
},
"dailyResetTime": {
"label": "Daily Reset Time (HH:mm)"
},
"limitWeekly": {
"label": "Weekly Spend Limit (USD)",
"placeholder": "Leave empty for unlimited"
Expand Down
1 change: 1 addition & 0 deletions messages/en/usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
"Create a config.json file in the ~/.claude directory (if it doesn't exist)",
"Add the following content:"
],
"configPath": "Configuration file location: {path}",

"note": "Note",
"notePoints": [
Expand Down
1 change: 1 addition & 0 deletions messages/ja/usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
"~/.claude ディレクトリに config.json ファイルを作成 (存在しない場合)",
"以下の内容を追加:"
],
"configPath": "設定ファイルの場所:{path}",

"note": "注記",
"notePoints": [
Expand Down
1 change: 1 addition & 0 deletions messages/ru/usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
"Создайте файл config.json в директории ~/.claude (если его нет)",
"Добавьте следующее содержимое:"
],
"configPath": "Путь к файлу конфигурации: {path}",

"note": "Примечание",
"notePoints": [
Expand Down
12 changes: 12 additions & 0 deletions messages/zh-CN/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"billingDescription": "系统优先使用请求模型({original})的价格计费。如果价格表中不存在该模型,则使用实际调用模型({current})的价格。"
},
"errorMessage": "错误信息",
"filteredProviders": "被过滤的供应商",
"providerChain": {
"title": "供应商决策链时间线",
"totalDuration": "总耗时: {duration}ms"
Expand Down Expand Up @@ -478,6 +479,7 @@
"error": "获取失败",
"networkError": "网络错误",
"cost5h": "5小时消费",
"costDaily": "每日消费",
"costWeekly": "周消费",
"costMonthly": "月消费",
"concurrentSessions": "并发 Session",
Expand Down Expand Up @@ -507,6 +509,16 @@
"description": "5小时内最大消费金额",
"descriptionWithUserLimit": "5小时内最大消费金额(用户限额: ${limit})"
},
"limitDailyUsd": {
"label": "每日消费上限 (USD)",
"placeholder": "留空表示无限制",
"description": "每日最大消费金额"
},
"dailyResetTime": {
"label": "每日重置时间",
"placeholder": "HH:mm",
"description": "每日限额的重置时间(使用系统时区)"
},
"limitWeeklyUsd": {
"label": "周消费上限 (USD)",
"placeholder": "留空表示无限制",
Expand Down
Loading
Loading