Merge branch 'refactor/api-split-expand' into feat/toolchain-tab
This commit is contained in:
+3
-3
@@ -1,6 +1,5 @@
|
||||
"""共享 helper 和常量"""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
from fastapi import HTTPException
|
||||
|
||||
@@ -11,7 +10,7 @@ from src.blackboard.registry import ProjectRegistry
|
||||
from src.utils import get_data_root
|
||||
|
||||
# 虚拟项目白名单
|
||||
_VIRTUAL_PROJECTS = frozenset({"_general", "_mail"})
|
||||
_VIRTUAL_PROJECTS = frozenset({"_general", "_mail", "_toolchain"})
|
||||
|
||||
|
||||
def _validate_project(project_id: str) -> str:
|
||||
@@ -56,7 +55,8 @@ def _init_agent_ids():
|
||||
if _KNOWN_AGENT_IDS:
|
||||
return
|
||||
try:
|
||||
import yaml, os
|
||||
import yaml
|
||||
import os
|
||||
cfg_path = os.path.join(os.path.dirname(__file__), "..", "..", "config", "default.yaml")
|
||||
with open(cfg_path) as f:
|
||||
cfg = yaml.safe_load(f)
|
||||
|
||||
+20
-4
@@ -19,7 +19,6 @@ from src.api.shared import (
|
||||
_bb,
|
||||
_q,
|
||||
_task_to_dict,
|
||||
_validate_project,
|
||||
_extract_mentions,
|
||||
)
|
||||
|
||||
@@ -56,10 +55,27 @@ async def get_task(project_id: str, task_id: str,
|
||||
if not expand:
|
||||
return result
|
||||
|
||||
expand_list = expand.split(",") if expand != "all" else [
|
||||
"comments", "outputs", "reviews", "events", "decisions"
|
||||
]
|
||||
# expand=all: 保持旧格式(list + 聚合字段),向后兼容前端 TaskModal
|
||||
if expand == "all":
|
||||
q = _q(project_id)
|
||||
detail = q.task_detail(task_id)
|
||||
if detail:
|
||||
result["comments_count"] = detail.get("comments_count", 0)
|
||||
result["outputs_count"] = detail.get("outputs_count", 0)
|
||||
result["review_status"] = detail.get("review_status")
|
||||
result["latest_event_detail"] = detail.get("latest_event_detail")
|
||||
result["comments"] = [dict(c.__dict__)
|
||||
for c in bb.get_comments(task_id)]
|
||||
result["outputs"] = [dict(o.__dict__) for o in bb.get_outputs(task_id)]
|
||||
result["reviews"] = [dict(r.__dict__) for r in bb.get_reviews(task_id)]
|
||||
result["decisions"] = [dict(d.__dict__)
|
||||
for d in bb.get_decisions(task_id)]
|
||||
result["events"] = q.task_events(task_id)
|
||||
result["experiences"] = q.task_experiences(task_id)
|
||||
return result
|
||||
|
||||
# 细粒度 expand: 新格式(comments/events 带 limit + total_count)
|
||||
expand_list = expand.split(",")
|
||||
q = _q(project_id)
|
||||
|
||||
if "comments" in expand_list:
|
||||
|
||||
Reference in New Issue
Block a user