更新 API 路由,添加获取所有代理、心跳、锁和会议的端点;修改会议队列和前端请求处理;新增前端完整测试脚本。

This commit is contained in:
Claude Code
2026-03-09 18:24:14 +08:00
parent dc398d7c7b
commit 7a5a58b4e5
17 changed files with 302 additions and 28 deletions

View File

@@ -20,7 +20,15 @@ app = FastAPI(
# 配置 CORS - 允许前端访问
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000", "http://127.0.0.1:3000"],
allow_origins=[ # 必须具体列出,不能使用 * 当 allow_credentials=True
"http://localhost:3000",
"http://localhost:3001",
"http://127.0.0.1:3000",
"http://127.0.0.1:3001",
"http://localhost:5173",
"http://127.0.0.1:5173",
"http://localhost:8080",
],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],

View File

@@ -33,6 +33,7 @@ class AgentCreate(BaseModel):
# Agent状态存储
agent_states_db = {}
@router.get("")
@router.get("/")
async def list_agents():
"""获取所有 Agent 列表"""

View File

@@ -17,6 +17,7 @@ class Heartbeat(BaseModel):
is_timeout: bool = False
@router.get("")
@router.get("/")
async def list_heartbeats():
"""获取所有 Agent 心跳"""

View File

@@ -41,6 +41,7 @@ def format_elapsed(locked_at: float) -> str:
else:
return f"{elapsed / 3600:.1f}小时"
@router.get("")
@router.get("/")
async def list_locks():
"""获取所有文件锁列表"""

View File

@@ -29,6 +29,7 @@ class MeetingCreate(BaseModel):
attendees: List[str] = []
@router.get("")
@router.get("/")
async def list_meetings():
"""获取所有会议列表"""

View File

@@ -33,22 +33,37 @@ async def execute_task(request: TaskRequest):
@router.get("/status")
async def get_all_status():
"""获取所有 Agent 状态"""
return {
"agents": [
{
"agent_id": "claude-001",
"status": "working",
"current_task": "开发功能",
"progress": 75
from ..services.agent_registry import get_agent_registry
from ..services.heartbeat import get_heartbeat_service
registry = get_agent_registry()
heartbeat_service = get_heartbeat_service()
# 获取所有已注册的 Agent
all_agents = await registry.list_agents()
agent_map = {a.agent_id: a for a in all_agents}
# 获取所有心跳
heartbeats_data = await heartbeat_service.get_all_heartbeats()
result = []
for agent_id, agent in agent_map.items():
heartbeat = heartbeats_data.get(agent_id)
result.append({
"agent_id": agent_id,
"info": {
"name": agent.name,
"role": agent.role,
"model": agent.model
},
{
"agent_id": "kimi-001",
"status": "idle",
"current_task": "",
"progress": 0
"heartbeat": {
"status": heartbeat.status if heartbeat else "offline",
"current_task": heartbeat.current_task if heartbeat else "",
"progress": heartbeat.progress if heartbeat else 0
}
]
}
})
return {"agents": result}
@router.post("/parse-task")

View File

@@ -1009,7 +1009,7 @@ def human_pending_tasks(
for t in tasks:
urgent_mark = "[red]⚠️[/red] " if t.is_urgent else ""
console.print(f" {urgent_mark}[yellow]{t.id}[/yellow]")
console.print(f" From: {t.from} | Priority: {t.priority}")
console.print(f" From: {t.from_user} | Priority: {t.priority}")
if t.title:
console.print(f" Title: {t.title}")
console.print(f" Content: {t.content}")
@@ -1029,7 +1029,7 @@ def human_urgent_tasks():
if tasks:
console.print(Panel(f"[red]⚠️ Urgent Tasks ({len(tasks)}):[/red]", border_style="red"))
for t in tasks:
console.print(f" [yellow]{t.id}[/yellow] | {t.from}")
console.print(f" [yellow]{t.id}[/yellow] | {t.from_user}")
console.print(f" Content: {t.content}")
else:
console.print(Panel("[green]No urgent tasks[/green]", border_style="green"))
@@ -1076,7 +1076,7 @@ def human_pending_comments(
if comments:
console.print(Panel(f"[cyan]Pending Comments ({len(comments)}):[/cyan]", border_style="cyan"))
for c in comments:
console.print(f" [yellow]{c.id}[/yellow] | {c.from} -> {c.meeting_id}")
console.print(f" [yellow]{c.id}[/yellow] | {c.from_user} -> {c.meeting_id}")
console.print(f" Type: {c.type} | Priority: {c.priority}")
console.print(f" Content: {c.content}")
else: