完整实现 Swarm 多智能体协作系统

- 新增 CLIPluginAdapter 统一接口 (backend/app/core/agent_adapter.py)
- 新增 LLM 服务层,支持 Anthropic/OpenAI/DeepSeek/Ollama (backend/app/services/llm_service.py)
- 新增 Agent 执行引擎,支持文件锁自动管理 (backend/app/services/agent_executor.py)
- 新增 NativeLLMAgent 原生 LLM 适配器 (backend/app/adapters/native_llm_agent.py)
- 新增进程管理器 (backend/app/services/process_manager.py)
- 新增 Agent 控制 API (backend/app/routers/agents_control.py)
- 新增 WebSocket 实时通信 (backend/app/routers/websocket.py)
- 更新前端 AgentsPage,支持启动/停止 Agent
- 测试通过:Agent 启动、批量操作、栅栏同步

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude Code
2026-03-09 17:32:11 +08:00
commit dc398d7c7b
118 changed files with 23120 additions and 0 deletions

138
frontend/src/types/index.ts Normal file
View File

@@ -0,0 +1,138 @@
// 类型定义
// Agent 相关
export interface Agent {
agent_id: string;
name: string;
role: 'architect' | 'pm' | 'developer' | 'qa' | 'reviewer' | 'human';
model: string;
status: 'idle' | 'working' | 'waiting' | 'error';
created_at: string;
}
export interface AgentState {
agent_id: string;
current_task: string;
progress: number;
working_files: string[];
last_update: string;
}
// 文件锁
export interface FileLock {
file_path: string;
agent_id: string;
agent_name: string;
acquired_at: string;
elapsed_display: string;
}
// 心跳
export interface Heartbeat {
agent_id: string;
status: 'working' | 'waiting' | 'idle' | 'error';
current_task: string;
progress: number;
elapsed_display: string;
is_timeout: boolean;
}
// 会议
export interface Meeting {
meeting_id: string;
title: string;
date: string;
status: 'pending' | 'waiting' | 'in_progress' | 'completed';
attendees: string[];
steps: MeetingStep[];
discussions: Discussion[];
progress_summary: string;
consensus: string;
}
export interface MeetingStep {
step_id: string;
label: string;
status: 'pending' | 'active' | 'completed';
}
export interface Discussion {
agent_id: string;
agent_name: string;
content: string;
timestamp: string;
step: string;
}
export interface MeetingQueue {
meeting_id: string;
title: string;
status: 'waiting' | 'started' | 'ended';
expected_attendees: string[];
arrived_attendees: string[];
missing_attendees: string[];
progress: string;
is_ready: boolean;
}
// 工作流
export interface Workflow {
workflow_id: string;
name: string;
description: string;
status: 'pending' | 'in_progress' | 'completed';
progress: string;
meetings: WorkflowMeeting[];
}
export interface WorkflowMeeting {
meeting_id: string;
title: string;
node_type: 'meeting' | 'execution';
attendees: string[];
depends_on: string[];
completed: boolean;
on_failure?: string;
progress?: string;
}
// 资源状态
export interface AgentResourceStatus {
agent_id: string;
info: {
name: string;
role: string;
model: string;
};
heartbeat: {
status: string;
current_task: string;
progress: number;
elapsed: string;
};
locks: Array<{
file: string;
elapsed: string;
}>;
state: {
task: string;
progress: number;
working_files: string[];
};
}
// API 响应
export interface ApiResponse<T> {
data?: T;
error?: {
code: string;
message: string;
};
}
// 配置
export interface AppConfig {
apiBaseUrl: string;
refreshInterval: number;
theme: 'dark' | 'light';
}