构造函数
constructor
new ChatService( dataDir: string, projectRoot: string, toolRegistry: ToolRegistry, llmConfig?: LLMConfig, sharedLLMService?: LLMService, mcpConfigService?: MCPConfigService, sharedMCPClientManager?: MCPClientManager, agentConfig?: Partial<AgentConfig>, sharedToolRegistry?: ToolRegistry,): ChatService 参数
- dataDir: string
- projectRoot: string
- toolRegistry: ToolRegistry
可选llmConfig: LLMConfig可选sharedLLMService: LLMService可选mcpConfigService: MCPConfigService可选sharedMCPClientManager: MCPClientManager可选agentConfig: Partial<AgentConfig>可选sharedToolRegistry: ToolRegistry
方法
updateLLMConfig
updateLLMConfig(config: LLMConfig): void
getLLMConnectionStatus
getLLMConnectionStatus(): Promise< { configured: boolean; connected: boolean; status: "green" | "yellow" | "red"; },> 返回 Promise<
{
configured: boolean;
connected: boolean;
status: "green"
| "yellow"
| "red";
},
>
setProjectRoot
setProjectRoot(root: string): void
createConversation
createConversation(title?: string): Conversation
getConversation
getConversation(id: string): Conversation | null
listConversations
listConversations(): ConversationSummary[]
deleteConversation
deleteConversation(id: string): boolean
reconnectMCP
reconnectMCP(): Promise<void>
toggleMCPConnection
toggleMCPConnection(id: string, enabled: boolean): Promise<void> 参数
- id: string
- enabled: boolean
返回 Promise<void>
getMCPStatus
getMCPStatus(): MCPConnectionStatus
返回 { name: string; description: string; source: "builtin" | "mcp" }[]
sendMessage
sendMessage( conversationId: string, userMessage: string, onEvent: (event: SSEEvent) => void,): Promise<void> 参数
- conversationId: string
- userMessage: string
- onEvent: (event: SSEEvent) => void
返回 Promise<void>
generate
generate( planContent: string, options?: { outputDir?: string; seedTest?: string },): Promise<AgentResult<string[]>> 参数
- planContent: string
可选options: { outputDir?: string; seedTest?: string }
heal
heal( testFilePath: string, options?: { runId?: string; testId?: string; error?: string; stackTrace?: string; },): Promise<AgentResult<AgentHealResult>> 参数
- testFilePath: string
可选options: { runId?: string; testId?: string; error?: string; stackTrace?: string }
setPrompts
setPrompts(prompts: Partial<AgentPrompts> | null): void 参数
- prompts: Partial<AgentPrompts> | null
返回 void
setBrowserSessionManager
setBrowserSessionManager(manager: BrowserSessionManager | null): void 参数
- manager: BrowserSessionManager | null
返回 void
getProjectContext
getProjectContext(): ProjectContext | null
parseMarkdownPlan
parseMarkdownPlan(filePath: string): TestPlan | null
createSessionContext
createSessionContext(): AgentSessionContext
UnifiedAIService — 统一 AI 服务。
完全合并 ChatService(对话管理 + MCP 连接)和 AgentService(测试管线编排), 所有子管理器归该类直接持有,不存在内部委托。
聊天系统(sendMessage)的 executeTool 可直接调用 this.plan() / this.heal() 等 Agent 管线方法,无需经过 ToolRegistry 桥接。