重构 API 路由并新增工作流编排功能

后端:
- 重构 agents, heartbeats, locks, meetings, resources, roles, workflows 路由
- 新增 orchestrator 和 providers 路由
- 新增 CLI 调用器和流程编排服务
- 添加日志配置和依赖项

前端:
- 更新 AgentsPage、SettingsPage、WorkflowPage 页面
- 扩展 api.ts 新增 API 接口

其他:
- 清理测试 agent 数据文件
- 新增示例工作流和项目审计报告

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude Code
2026-03-10 16:36:25 +08:00
parent 7a5a58b4e5
commit 1719d1f1f9
54 changed files with 3175 additions and 612 deletions
+23 -17
View File
@@ -1,9 +1,12 @@
"""
角色分配 API 路由
接入 RoleAllocator 服务,基于任务分析分配角色
"""
from fastapi import APIRouter
from pydantic import BaseModel
from typing import List, Dict
from typing import List
from ..services.role_allocator import get_role_allocator
router = APIRouter()
@@ -20,29 +23,28 @@ class RoleAllocateRequest(BaseModel):
@router.post("/primary")
async def get_primary_role(request: RoleRequest):
"""获取任务主要角色"""
allocator = get_role_allocator()
primary = allocator.get_primary_role(request.task)
role_scores = allocator._analyze_task_roles(request.task)
return {
"task": request.task,
"primary_role": "developer",
"role_scores": {
"developer": 0.8,
"architect": 0.6,
"qa": 0.4,
"pm": 0.2
}
"primary_role": primary,
"role_scores": {k: round(v, 2) for k, v in role_scores.items()}
}
@router.post("/allocate")
async def allocate_roles(request: RoleAllocateRequest):
"""分配角色"""
allocation = {}
for i, agent in enumerate(request.agents):
roles = ["developer", "architect", "qa"]
allocation[agent] = roles[i % len(roles)]
allocator = get_role_allocator()
allocation = await allocator.allocate_roles(
task=request.task,
available_agents=request.agents
)
primary = allocator.get_primary_role(request.task)
return {
"task": request.task,
"primary_role": "developer",
"primary_role": primary,
"allocation": allocation
}
@@ -50,6 +52,10 @@ async def allocate_roles(request: RoleAllocateRequest):
@router.post("/explain")
async def explain_roles(request: RoleAllocateRequest):
"""解释角色分配"""
return {
"explanation": f"基于任务 '{request.task}' 的分析,推荐了最适合的角色分配方案。"
}
allocator = get_role_allocator()
allocation = await allocator.allocate_roles(
task=request.task,
available_agents=request.agents
)
explanation = allocator.explain_allocation(request.task, allocation)
return {"explanation": explanation}