feat: expose graph orchestration mode, fix pipeline multi-agent, add Feishu tools (Phase 3)
增强编排 + 飞书深度集成: - Graph 模式:暴露 orchestrator._graph() 到 run() 方法,workflow_integration 支持 graph nodes/edges - Pipeline 修复:多 Agent 按步骤轮转分配,不再只用 agents[0] - 4个飞书操作工具: feishu_create_doc / feishu_create_calendar_event / feishu_search_contacts / feishu_send_approval - 飞书 @mention→Goal:feishu/ orange WS handler 支持 "目标: xxx" 触发自动创建 Goal Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -137,6 +137,22 @@ def _make_llm_logger(db, agent_id: Optional[str] = None, user_id: Optional[str]
|
||||
return _log
|
||||
|
||||
|
||||
async def _handle_goal_creation(db, user_id: str, goal_title: str, open_id: str):
|
||||
"""橙子飞书消息中创建 Goal 并异步启动执行。"""
|
||||
from app.services.goal_service import create_goal as svc_create_goal, update_goal
|
||||
from app.tasks.goal_tasks import execute_goal_task
|
||||
|
||||
try:
|
||||
goal = svc_create_goal(db=db, creator_id=user_id, title=goal_title, priority=5)
|
||||
_reply_to_feishu(open_id, f"✅ 目标已创建: **{goal.title}**\n正在分解任务并启动执行...")
|
||||
task = execute_goal_task.delay(str(goal.id))
|
||||
logger.info("橙子触发 Goal 创建: goal_id=%s celery_task=%s", goal.id, task.id)
|
||||
update_goal(db, str(goal.id), status="active")
|
||||
except Exception as e:
|
||||
logger.error("橙子 Goal 创建失败: %s", e)
|
||||
_reply_to_feishu(open_id, f"创建目标失败: {e}")
|
||||
|
||||
|
||||
async def _handle_message_async(data):
|
||||
"""异步处理橙子消息 — 固定使用橙子助手 Agent。"""
|
||||
open_id = _get_sender_open_id(data)
|
||||
@@ -226,6 +242,15 @@ async def _handle_message_async(data):
|
||||
memory_scope_id=str(agent.id),
|
||||
)
|
||||
|
||||
# ── 目标/任务意图检测 ──
|
||||
for trigger in ["创建目标:", "目标:", "new goal:", "goal:"]:
|
||||
if text.lower().startswith(trigger.lower()):
|
||||
goal_title = text[len(trigger):].strip()
|
||||
if goal_title:
|
||||
await _handle_goal_creation(db, user.id, goal_title[:500], open_id)
|
||||
return
|
||||
break
|
||||
|
||||
on_llm_call = _make_llm_logger(db, agent_id=str(agent.id))
|
||||
runtime = AgentRuntime(config=config, on_llm_call=on_llm_call)
|
||||
result = await runtime.run(text)
|
||||
|
||||
Reference in New Issue
Block a user