feat: 添加5h窗口费用控制和会话数量限制

- 支持Anthropic OAuth/SetupToken账号的5h窗口费用阈值控制
- 支持账号级别的并发会话数量限制
- 使用Redis缓存窗口费用(30秒TTL)减少数据库压力
- 费用计算基于标准费用(不含账号倍率)
This commit is contained in:
shaw
2026-01-16 23:36:52 +08:00
parent 04811c00cb
commit 7379423325
21 changed files with 1329 additions and 53 deletions

View File

@@ -163,6 +163,7 @@ export default {
notAvailable: 'N/A',
now: 'Now',
unknown: 'Unknown',
minutes: 'min',
time: {
never: 'Never',
justNow: 'Just now',
@@ -1082,7 +1083,7 @@ export default {
platformType: 'Platform/Type',
platform: 'Platform',
type: 'Type',
concurrencyStatus: 'Concurrency',
capacity: 'Capacity',
notes: 'Notes',
priority: 'Priority',
billingRateMultiplier: 'Billing Rate',
@@ -1096,6 +1097,18 @@ export default {
expiresAt: 'Expires At',
actions: 'Actions'
},
// Capacity status tooltips
capacity: {
windowCost: {
blocked: '5h window cost exceeded, account scheduling paused',
stickyOnly: '5h window cost at threshold, only sticky sessions allowed',
normal: '5h window cost normal'
},
sessions: {
full: 'Active sessions full, new sessions must wait (idle timeout: {idle} min)',
normal: 'Active sessions normal (idle timeout: {idle} min)'
}
},
tempUnschedulable: {
title: 'Temp Unschedulable',
statusTitle: 'Temp Unschedulable Status',
@@ -1247,6 +1260,31 @@ export default {
'When enabled, warmup requests like title generation will return mock responses without consuming upstream tokens',
autoPauseOnExpired: 'Auto Pause On Expired',
autoPauseOnExpiredDesc: 'When enabled, the account will auto pause scheduling after it expires',
// Quota control (Anthropic OAuth/SetupToken only)
quotaControl: {
title: 'Quota Control',
hint: 'Only applies to Anthropic OAuth/Setup Token accounts',
windowCost: {
label: '5h Window Cost Limit',
hint: 'Limit account cost usage within the 5-hour window',
limit: 'Cost Threshold',
limitPlaceholder: '50',
limitHint: 'Account will not participate in new scheduling after reaching threshold',
stickyReserve: 'Sticky Reserve',
stickyReservePlaceholder: '10',
stickyReserveHint: 'Additional reserve for sticky sessions'
},
sessionLimit: {
label: 'Session Count Limit',
hint: 'Limit the number of active concurrent sessions',
maxSessions: 'Max Sessions',
maxSessionsPlaceholder: '3',
maxSessionsHint: 'Maximum number of active concurrent sessions',
idleTimeout: 'Idle Timeout',
idleTimeoutPlaceholder: '5',
idleTimeoutHint: 'Sessions will be released after idle timeout'
}
},
expired: 'Expired',
proxy: 'Proxy',
noProxy: 'No Proxy',

View File

@@ -160,6 +160,7 @@ export default {
notAvailable: '不可用',
now: '现在',
unknown: '未知',
minutes: '分钟',
time: {
never: '从未',
justNow: '刚刚',
@@ -1131,7 +1132,7 @@ export default {
platformType: '平台/类型',
platform: '平台',
type: '类型',
concurrencyStatus: '并发',
capacity: '容量',
notes: '备注',
priority: '优先级',
billingRateMultiplier: '账号倍率',
@@ -1145,6 +1146,18 @@ export default {
expiresAt: '过期时间',
actions: '操作'
},
// 容量状态提示
capacity: {
windowCost: {
blocked: '5h窗口费用超限账号暂停调度',
stickyOnly: '5h窗口费用达阈值仅允许粘性会话',
normal: '5h窗口费用正常'
},
sessions: {
full: '活跃会话已满,新会话需等待(空闲超时:{idle}分钟)',
normal: '活跃会话正常(空闲超时:{idle}分钟)'
}
},
clearRateLimit: '清除速率限制',
testConnection: '测试连接',
reAuthorize: '重新授权',
@@ -1380,6 +1393,31 @@ export default {
interceptWarmupRequestsDesc: '启用后,标题生成等预热请求将返回 mock 响应,不消耗上游 token',
autoPauseOnExpired: '过期自动暂停调度',
autoPauseOnExpiredDesc: '启用后,账号过期将自动暂停调度',
// Quota control (Anthropic OAuth/SetupToken only)
quotaControl: {
title: '配额控制',
hint: '仅适用于 Anthropic OAuth/Setup Token 账号',
windowCost: {
label: '5h窗口费用控制',
hint: '限制账号在5小时窗口内的费用使用',
limit: '费用阈值',
limitPlaceholder: '50',
limitHint: '达到阈值后不参与新请求调度',
stickyReserve: '粘性预留额度',
stickyReservePlaceholder: '10',
stickyReserveHint: '为粘性会话预留的额外额度'
},
sessionLimit: {
label: '会话数量控制',
hint: '限制同时活跃的会话数量',
maxSessions: '最大会话数',
maxSessionsPlaceholder: '3',
maxSessionsHint: '同时活跃的最大会话数量',
idleTimeout: '空闲超时',
idleTimeoutPlaceholder: '5',
idleTimeoutHint: '会话空闲超时后自动释放'
}
},
expired: '已过期',
proxy: '代理',
noProxy: '无代理',