This commit is contained in:
SunSeekerX
2025-12-31 02:17:10 +08:00
parent 584fa8c9c1
commit b4233033a6
9 changed files with 50 additions and 42 deletions

View File

@@ -5,7 +5,11 @@
const redis = require('../models/redis')
const logger = require('../utils/logger')
const { getCachedConfig, setCachedConfig, deleteCachedConfig } = require('../utils/performanceOptimizer')
const {
getCachedConfig,
setCachedConfig,
deleteCachedConfig
} = require('../utils/performanceOptimizer')
class ClaudeCodeHeadersService {
constructor() {

View File

@@ -24,9 +24,7 @@ const {
// structuredClone polyfill for Node < 17
const safeClone =
typeof structuredClone === 'function'
? structuredClone
: (obj) => JSON.parse(JSON.stringify(obj))
typeof structuredClone === 'function' ? structuredClone : (obj) => JSON.parse(JSON.stringify(obj))
class ClaudeRelayService {
constructor() {

View File

@@ -94,7 +94,9 @@ class CostInitService {
}
}
logger.info(`💰 Found ${apiKeyIds.length} active API Keys to process (filtered ${allKeyIds.length - apiKeyIds.length} deleted)`)
logger.info(
`💰 Found ${apiKeyIds.length} active API Keys to process (filtered ${allKeyIds.length - apiKeyIds.length} deleted)`
)
let processedCount = 0
let errorCount = 0

View File

@@ -30,10 +30,13 @@ class DroidAccountService {
this._encryptor = createEncryptor('droid-account-salt')
// 🧹 定期清理缓存每10分钟
setInterval(() => {
this._encryptor.clearCache()
logger.info('🧹 Droid decrypt cache cleanup completed', this._encryptor.getStats())
}, 10 * 60 * 1000)
setInterval(
() => {
this._encryptor.clearCache()
logger.info('🧹 Droid decrypt cache cleanup completed', this._encryptor.getStats())
},
10 * 60 * 1000
)
this.supportedEndpointTypes = new Set(['anthropic', 'openai', 'comm'])
}

View File

@@ -2,7 +2,12 @@ const droidAccountService = require('./droidAccountService')
const accountGroupService = require('./accountGroupService')
const redis = require('../models/redis')
const logger = require('../utils/logger')
const { isTruthy, isAccountHealthy, sortAccountsByPriority, normalizeEndpointType } = require('../utils/commonHelper')
const {
isTruthy,
isAccountHealthy,
sortAccountsByPriority,
normalizeEndpointType
} = require('../utils/commonHelper')
class DroidScheduler {
constructor() {

View File

@@ -26,11 +26,7 @@ class UnifiedGeminiScheduler {
if (apiKeyData.geminiAccountId.startsWith('api:')) {
const accountId = apiKeyData.geminiAccountId.replace('api:', '')
const boundAccount = await geminiApiAccountService.getAccount(accountId)
if (
boundAccount &&
isActive(boundAccount.isActive) &&
boundAccount.status !== 'error'
) {
if (boundAccount && isActive(boundAccount.isActive) && boundAccount.status !== 'error') {
logger.info(
`🎯 Using bound Gemini-API account: ${boundAccount.name} (${accountId}) for API key ${apiKeyData.name}`
)
@@ -63,11 +59,7 @@ class UnifiedGeminiScheduler {
// 普通 Gemini OAuth 专属账户
else {
const boundAccount = await geminiAccountService.getAccount(apiKeyData.geminiAccountId)
if (
boundAccount &&
isActive(boundAccount.isActive) &&
boundAccount.status !== 'error'
) {
if (boundAccount && isActive(boundAccount.isActive) && boundAccount.status !== 'error') {
logger.info(
`🎯 Using bound dedicated Gemini account: ${boundAccount.name} (${apiKeyData.geminiAccountId}) for API key ${apiKeyData.name}`
)
@@ -183,11 +175,7 @@ class UnifiedGeminiScheduler {
if (apiKeyData.geminiAccountId.startsWith('api:')) {
const accountId = apiKeyData.geminiAccountId.replace('api:', '')
const boundAccount = await geminiApiAccountService.getAccount(accountId)
if (
boundAccount &&
isActive(boundAccount.isActive) &&
boundAccount.status !== 'error'
) {
if (boundAccount && isActive(boundAccount.isActive) && boundAccount.status !== 'error') {
const isRateLimited = await this.isAccountRateLimited(accountId)
if (!isRateLimited) {
// 检查模型支持
@@ -234,11 +222,7 @@ class UnifiedGeminiScheduler {
// 普通 Gemini OAuth 账户
else if (!apiKeyData.geminiAccountId.startsWith('group:')) {
const boundAccount = await geminiAccountService.getAccount(apiKeyData.geminiAccountId)
if (
boundAccount &&
isActive(boundAccount.isActive) &&
boundAccount.status !== 'error'
) {
if (boundAccount && isActive(boundAccount.isActive) && boundAccount.status !== 'error') {
const isRateLimited = await this.isAccountRateLimited(boundAccount.id)
if (!isRateLimited) {
// 检查模型支持