- 新增 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>
61 lines
1.2 KiB
Python
61 lines
1.2 KiB
Python
"""
|
|
资源管理 API 路由
|
|
"""
|
|
from fastapi import APIRouter
|
|
from pydantic import BaseModel
|
|
from typing import List, Optional
|
|
import time
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
class TaskRequest(BaseModel):
|
|
agent_id: str
|
|
task: str
|
|
timeout: Optional[int] = 300
|
|
|
|
|
|
class TaskParseRequest(BaseModel):
|
|
task: str
|
|
|
|
|
|
@router.post("/execute")
|
|
async def execute_task(request: TaskRequest):
|
|
"""执行任务"""
|
|
return {
|
|
"success": True,
|
|
"message": f"任务 '{request.task}' 已执行",
|
|
"files_locked": ["src/main.py"],
|
|
"duration_seconds": 5.5
|
|
}
|
|
|
|
|
|
@router.get("/status")
|
|
async def get_all_status():
|
|
"""获取所有 Agent 状态"""
|
|
return {
|
|
"agents": [
|
|
{
|
|
"agent_id": "claude-001",
|
|
"status": "working",
|
|
"current_task": "开发功能",
|
|
"progress": 75
|
|
},
|
|
{
|
|
"agent_id": "kimi-001",
|
|
"status": "idle",
|
|
"current_task": "",
|
|
"progress": 0
|
|
}
|
|
]
|
|
}
|
|
|
|
|
|
@router.post("/parse-task")
|
|
async def parse_task(request: TaskParseRequest):
|
|
"""解析任务文件"""
|
|
return {
|
|
"task": request.task,
|
|
"files": ["src/main.py", "src/utils.py"]
|
|
}
|