fix: 修复额度耗尽错误展示
问题:Token balance exhausted 被作为原始助手气泡展示,且额度确认可能跨会话复用。 修复:区分绝对余额与滚动额度,绑定当前会话失败 key,并补充真实消息结构与双会话回归测试。
This commit is contained in:
@@ -1,18 +1,23 @@
|
||||
export type OpencodeErrorKind = 'quota_exhausted' | 'authentication_invalid';
|
||||
|
||||
export function isOpencodeTokenBalanceExhausted(message: string | null | undefined): boolean {
|
||||
const normalized = message?.trim().toLowerCase() ?? '';
|
||||
return normalized.includes('token_balance_exhausted')
|
||||
|| normalized.includes('token balance exhausted')
|
||||
|| normalized.includes('balance exhausted');
|
||||
}
|
||||
|
||||
export function getOpencodeErrorKind(message: string | null | undefined): OpencodeErrorKind | null {
|
||||
const normalized = message?.trim().toLowerCase() ?? '';
|
||||
if (!normalized) return null;
|
||||
if (
|
||||
normalized.includes('user quota is not enough')
|
||||
isOpencodeTokenBalanceExhausted(normalized)
|
||||
|| normalized.includes('user quota is not enough')
|
||||
|| normalized.includes('quota is not enough')
|
||||
|| normalized.includes('quota not enough')
|
||||
|| normalized.includes('insufficient quota')
|
||||
|| normalized.includes('quota exhausted')
|
||||
|| normalized.includes('quota exceeded')
|
||||
|| normalized.includes('token_balance_exhausted')
|
||||
|| normalized.includes('token balance exhausted')
|
||||
|| normalized.includes('balance exhausted')
|
||||
|| normalized.includes('rolling 5-hour window')
|
||||
|| normalized.includes('额度不足')
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user