sync snapshot from LAN repo (source codex/kb-context-retrieval-20261021 @ b69568e4)
This commit is contained in:
1 parent
ea9dcff9c0
commit
4cf657f725
781 files changed
+13559
-104852
No files matched your search
@@ -6,8 +6,7 @@
|
||||
``agent_id``,与前端任务深链 ``goPath=3qfx`` 取的是同一个);
|
||||
2. 按 taskId 拉取任务详情(consumer 的 ``cop-task-detail``,地址 / 鉴权头 / mock 都在
|
||||
``config.yaml`` 的 ``task_deeplink`` 段),拼出与前端深链一致的开场白
|
||||
``任务名称:…\n任务内容:…\n任务类型:…\n任务id(task_id)为…``
|
||||
(``taskType`` 字典码 1/2/3 映射为 打击/塑势/防御,无法识别则省略该行);
|
||||
``任务名称:…\n任务内容:…\n任务id(task_id)为…``;
|
||||
3. **新建一条真实会话**(thread 打任务标签并登记到 ``taskId + goPath`` 专用聊天记录),
|
||||
以开场白作为第一条用户消息
|
||||
**后台启动一次持久化运行**(写 checkpointer,不阻塞);
|
||||
@@ -27,7 +26,7 @@
|
||||
返回::
|
||||
|
||||
{"thread_id": "…", "run_id": "…", "agent_id": "…", "status": "running",
|
||||
"opening_text": "任务名称:…\n任务内容:…\n任务类型:打击\n任务id(task_id)为2055"}
|
||||
"opening_text": "任务名称:…\n任务内容:…\n任务id(task_id)为2055"}
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -93,41 +92,6 @@ class CopTaskDetail(BaseModel):
|
||||
task_direction: str = ""
|
||||
task_name: str = ""
|
||||
task_content: str = ""
|
||||
task_type: str = ""
|
||||
|
||||
|
||||
_TASK_TYPE_LABELS = {"1": "打击", "2": "塑势", "3": "防御"}
|
||||
|
||||
|
||||
def map_task_type_label(value: Any) -> str:
|
||||
"""把 cop-task-detail 的 taskType 字典码映射成发送文本。无法识别时返回空串。"""
|
||||
if isinstance(value, bool) or value is None:
|
||||
return ""
|
||||
if isinstance(value, int):
|
||||
key = str(value)
|
||||
elif isinstance(value, float):
|
||||
if not value.is_integer():
|
||||
return ""
|
||||
key = str(int(value))
|
||||
elif isinstance(value, str):
|
||||
key = value.strip()
|
||||
else:
|
||||
return ""
|
||||
if key in _TASK_TYPE_LABELS.values():
|
||||
return key
|
||||
return _TASK_TYPE_LABELS.get(key, "")
|
||||
|
||||
|
||||
def _task_type_code(value: Any) -> str:
|
||||
if isinstance(value, bool) or value is None:
|
||||
return ""
|
||||
if isinstance(value, int):
|
||||
return str(value)
|
||||
if isinstance(value, float):
|
||||
return str(int(value)) if value.is_integer() else ""
|
||||
if isinstance(value, str):
|
||||
return value.strip()
|
||||
return ""
|
||||
|
||||
|
||||
async def _resolve_threeq_agent_id(request: Request) -> str:
|
||||
@@ -153,7 +117,6 @@ def _parse_cop_task_detail(body: Any) -> CopTaskDetail:
|
||||
task_direction=data.get("taskDirection") if isinstance(data.get("taskDirection"), str) else "",
|
||||
task_name=data.get("taskName") if isinstance(data.get("taskName"), str) else "",
|
||||
task_content=data.get("taskContent") if isinstance(data.get("taskContent"), str) else "",
|
||||
task_type=_task_type_code(data.get("taskType")),
|
||||
)
|
||||
|
||||
|
||||
@@ -183,11 +146,9 @@ async def _fetch_cop_task_detail(task_id: str) -> CopTaskDetail:
|
||||
|
||||
def build_opening_text(detail: CopTaskDetail, task_id: str) -> str:
|
||||
"""拼 3qfx 开场白,与前端 ``buildOpeningText``(3qfx 分支)逐行对齐。"""
|
||||
task_type_label = map_task_type_label(detail.task_type)
|
||||
parts = [
|
||||
f"任务名称:{detail.task_name}" if detail.task_name else "",
|
||||
f"任务内容:{detail.task_content}" if detail.task_content else "",
|
||||
f"任务类型:{task_type_label}" if task_type_label else "",
|
||||
f"任务id(task_id)为{task_id}" if task_id else "",
|
||||
]
|
||||
return "\n".join(p for p in parts if p)
|
||||
|
||||
Reference in new issue
Block a user