refactor: 拆分调度器为独立子模块,增强 Sub2API 多认证方式支持

调度器重构:
- 将 CacheAwareScheduler 拆分为 candidate_builder、candidate_sorter、
  concurrency_checker、restriction_checker、scheduling_config、schemas、utils 等独立模块
- 删除旧的 _candidate_builder.py 和 _candidate_sorter.py
- 新增调度并发拒绝 Prometheus 指标

Sub2API 架构增强:
- 支持账号密码登录和 Refresh Token 两种认证方式
- 实现 JWT 自动刷新和 Token Rotation 持久化
- 前端 ProviderAuthDialog 支持多认证方式切换和 credentials_schema 动态渲染
- 验证接口返回 updated_credentials 以同步轮换后的 token

其他改进:
- 并发管理器增加 RPM guard 和动态预留逻辑
- RequestCandidate 支持 mark_skipped 附加 extra_data
- TaskService 增强健壮性
- 补充相关单元测试和契约测试
This commit is contained in:
fawney19
2026-02-15 16:32:23 +08:00
parent 8a670f5524
commit 1c16b77a92
27 changed files with 2159 additions and 645 deletions

View File

@@ -41,7 +41,7 @@ class ArchitectureInfo(BaseModel):
display_name: str
description: str
credentials_schema: dict[str, Any]
supported_auth_types: list[dict[str, str]]
supported_auth_types: list[dict[str, Any]]
supported_actions: list[dict[str, Any]]
default_connector: str | None
@@ -131,6 +131,7 @@ class VerifyAuthResponse(BaseModel):
success: bool
message: str | None = None
data: dict[str, Any] | None = None
updated_credentials: dict[str, Any] | None = None
# ==================== Helper Functions ====================
@@ -338,6 +339,7 @@ async def verify_provider_auth(
success=result.get("success", False),
message=result.get("message"),
data=result.get("data"),
updated_credentials=result.get("updated_credentials"),
)