auto-sync: 2026-05-24 10:57:50

This commit is contained in:
cfdaily
2026-05-24 10:57:50 +08:00
parent 2a43f18382
commit 160c7a06e7
+32
View File
@@ -280,6 +280,38 @@ curl -X POST http://{self.api_host}:{self.api_port}/api/projects/{project_id}/ta
成功:status → {success_status} | 失败:status → "failed"
"""
def _build_mail_prompt(self, task_id: str, title: str, description: str,
must_haves: str, agent_id: str) -> str:
"""构建 Mail 专用精简模板"""
# 解析 must_haves 获取 from 和 performative
from_agent = agent_id
performative = "request"
try:
meta = json.loads(must_haves) if must_haves else {}
from_agent = meta.get("from", agent_id)
performative = meta.get("performative", meta.get("type", "request"))
except Exception:
pass
# 截断 title 和 text 用于模板安全
safe_title = (title or "").replace('"', '\\"')[:100]
safe_text = (description or "").replace('"', '\\"')
common_kwargs = dict(
from_agent=from_agent,
title=safe_title,
text=safe_text,
task_id=task_id,
agent_id=agent_id,
api_host=self.api_host,
api_port=self.api_port,
)
if performative == "inform":
return MAIL_INFORM_TEMPLATE.format(**common_kwargs)
else:
return MAIL_REQUEST_TEMPLATE.format(**common_kwargs)
async def spawn_full_agent(
self,
agent_id: str,