## T3: OpenClaw 直连通道
- channels/openclaw.py: OpenClawChannel
- send: POST /api/v1/chat/completions
- poll_reply: GET /api/v1/chat/completions/{msg_id}
- health_check: GET /api/health
- 默认从 settings 读取 upstream/auth_token,channel_config 可覆盖
- channels/factory.py: 注册 ChannelType.OPENCLAW → OpenClawChannel
- Targets.tsx: 通道类型下拉新增「HTTP 通用」和「OpenClaw」选项
- 8 个 OpenClawChannel 单元测试(发送/轮询/超时/健康检查/默认配置)
## T4: 前端 Bundle 优化
- App.tsx: 7 个页面改为 React.lazy 懒加载 + Suspense fallback(Spin)
- vite.config.ts: 精细化 manualChunks
- vendor-antd / vendor-monaco / vendor-charts 独立拆分
- 主 index 68KB → 7KB,页面按需加载
- 无循环依赖警告
## 测试
- 178/178 全绿,覆盖率维持 77%
Co-Authored-By: Claude <noreply@anthropic.com>
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
"""Factory for creating message channels from target configuration."""
|
|
|
|
from agenteval.channels.base import EvalChannel
|
|
from agenteval.channels.http import HttpChannel
|
|
from agenteval.channels.openclaw import OpenClawChannel
|
|
from agenteval.channels.tutu import TutuApiChannel
|
|
from agenteval.models import ChannelType, EvalTarget
|
|
|
|
|
|
class ChannelFactory:
|
|
"""Create the appropriate channel adapter for a target."""
|
|
|
|
_mapping: dict[ChannelType, type[EvalChannel]] = {
|
|
ChannelType.TUTU_API: TutuApiChannel,
|
|
ChannelType.HTTP: HttpChannel,
|
|
ChannelType.OPENCLAW: OpenClawChannel,
|
|
}
|
|
|
|
@classmethod
|
|
def create(cls, target: EvalTarget) -> EvalChannel:
|
|
if target.channel_type not in cls._mapping:
|
|
raise ValueError(f"unsupported channel type: {target.channel_type}")
|
|
return cls._mapping[target.channel_type](target.channel_config)
|
|
|
|
@classmethod
|
|
def register(cls, channel_type: ChannelType, channel_cls: type[EvalChannel]) -> None:
|
|
cls._mapping[channel_type] = channel_cls
|