feat(outlook): 添加Outlook集成功能支持
添加完整的Outlook MCP集成,包括邮件和日历功能,通过AuthZ模式进行认证和权限管理, 支持邮箱连接、断开、状态检查和数据同步等功能。 fix(config): 统一配置文件路径从.nanobot到.beaver 将配置文件路径从/root/.nanobot统一更改为/root/.beaver,更新Dockerfile中的环境变量定义, 确保所有组件使用一致的配置目录结构。 feat(agent): 添加代理删除功能和助手身份提示 为代理注册表添加delete_agent方法,实现代理的动态删除功能;同时添加海狸助手身份提示, 确保AI助手在交互中保持一致的身份认知。 feat(engine): 增强引擎循环并添加意图决策快照 扩展AgentLoop类,添加intent_agent_decision参数用于意图驱动的代理决策,并在会话中记录 决策快照,便于后续分析和调试。 feat(authz): 扩展认证客户端功能 为AuthzClient添加设置权限、用户注册、后端注册和Outlook设置管理等新方法,增强系统 的认证和授权能力。
This commit is contained in:
@ -20,6 +20,7 @@ class MainAgentRouter:
|
||||
provider: Any | None = None,
|
||||
model: str | None = None,
|
||||
recent_messages: list[dict[str, Any]] | None = None,
|
||||
intent_skill: str | None = None,
|
||||
thinking_enabled: bool | None = None,
|
||||
timeout_seconds: float = 8.0,
|
||||
) -> MainAgentDecision:
|
||||
@ -31,8 +32,9 @@ class MainAgentRouter:
|
||||
{
|
||||
"role": "system",
|
||||
"content": (
|
||||
"You route user messages for Beaver's internal Task mode. "
|
||||
"Return only compact JSON. Do not explain."
|
||||
"You are Beaver's Intent Agent. Your only job is to route the user's "
|
||||
"message to simple chat or internal Task mode. Return only compact JSON. "
|
||||
"Do not answer the user. Do not explain."
|
||||
),
|
||||
},
|
||||
{
|
||||
@ -41,6 +43,7 @@ class MainAgentRouter:
|
||||
message=message,
|
||||
active_task=active_task,
|
||||
recent_messages=recent_messages or [],
|
||||
intent_skill=intent_skill,
|
||||
),
|
||||
},
|
||||
],
|
||||
@ -63,19 +66,48 @@ class MainAgentRouter:
|
||||
short_title = _clean_short_title(payload.get("short_title") or payload.get("title"))
|
||||
|
||||
if raw_action in {"continue_task", "continue", "task"}:
|
||||
return MainAgentDecision(mode="task", reason=reason, short_title=short_title)
|
||||
return MainAgentDecision(
|
||||
mode="task",
|
||||
reason=reason,
|
||||
starts_new_task=active_task is None,
|
||||
short_title=short_title,
|
||||
action="continue_task" if active_task is not None else "create_task",
|
||||
)
|
||||
if raw_action in {"new_task", "new"}:
|
||||
return MainAgentDecision(mode="task", reason=reason, starts_new_task=True, short_title=short_title)
|
||||
return MainAgentDecision(
|
||||
mode="task",
|
||||
reason=reason,
|
||||
starts_new_task=True,
|
||||
short_title=short_title,
|
||||
action="create_task",
|
||||
)
|
||||
if raw_action in {"close_task", "close", "done", "finish"}:
|
||||
return MainAgentDecision(mode="simple", reason=reason, closes_task=active_task is not None, short_title=short_title)
|
||||
return MainAgentDecision(
|
||||
mode="simple",
|
||||
reason=reason,
|
||||
closes_task=active_task is not None,
|
||||
short_title=short_title,
|
||||
action="close_task",
|
||||
)
|
||||
if raw_action in {"abandon_task", "abandon", "cancel_task"}:
|
||||
return MainAgentDecision(mode="simple", reason=reason, abandons_task=active_task is not None, short_title=short_title)
|
||||
return MainAgentDecision(mode="simple", reason=reason or "simple_chat", short_title=short_title)
|
||||
return MainAgentDecision(
|
||||
mode="simple",
|
||||
reason=reason,
|
||||
abandons_task=active_task is not None,
|
||||
short_title=short_title,
|
||||
action="abandon_task",
|
||||
)
|
||||
return MainAgentDecision(
|
||||
mode="simple",
|
||||
reason=reason or "simple_chat",
|
||||
short_title=short_title,
|
||||
action="simple_chat",
|
||||
)
|
||||
|
||||
def _fallback(self, *, active_task: TaskRecord | None, reason: str) -> MainAgentDecision:
|
||||
if active_task is not None:
|
||||
return MainAgentDecision(mode="task", reason=reason)
|
||||
return MainAgentDecision(mode="simple", reason=reason)
|
||||
return MainAgentDecision(mode="task", reason=reason, action="continue_task")
|
||||
return MainAgentDecision(mode="simple", reason=reason, action="simple_chat")
|
||||
|
||||
@staticmethod
|
||||
def _prompt(
|
||||
@ -83,6 +115,7 @@ class MainAgentRouter:
|
||||
message: str,
|
||||
active_task: TaskRecord | None,
|
||||
recent_messages: list[dict[str, Any]],
|
||||
intent_skill: str | None,
|
||||
) -> str:
|
||||
active_task_payload = None
|
||||
if active_task is not None:
|
||||
@ -98,8 +131,14 @@ class MainAgentRouter:
|
||||
for item in recent_messages[-8:]
|
||||
if item.get("role") in {"user", "assistant"}
|
||||
]
|
||||
skill_section = (
|
||||
f"Intent Agent skill guidance:\n{intent_skill.strip()}\n\n"
|
||||
if intent_skill and intent_skill.strip()
|
||||
else ""
|
||||
)
|
||||
return (
|
||||
"Decide how to route the current user message.\n\n"
|
||||
f"{skill_section}"
|
||||
"Actions:\n"
|
||||
"- simple_chat: no Task should be created or continued.\n"
|
||||
"- continue_task: keep the user in the active Task.\n"
|
||||
@ -113,6 +152,10 @@ class MainAgentRouter:
|
||||
"- Use new_task only when the user clearly asks to start a different task.\n"
|
||||
"- If there is no active Task, choose new_task only for work that requires execution, iteration, tools, files, "
|
||||
"implementation, validation, or multi-step completion. Otherwise choose simple_chat.\n"
|
||||
"- Requests that need current, real-time, external, user-private, local-file, web, weather, price, news, "
|
||||
"calendar, email, or system data require tools. Choose new_task for them because the Intent Agent has no tools.\n"
|
||||
"- The Intent Agent must never answer tool-dependent requests itself or apologize for lacking tools. "
|
||||
"It only routes the request so the main Task agent can use tools.\n"
|
||||
"- short_title must be 5-15 Chinese characters or a similarly short English phrase when a Task is involved.\n\n"
|
||||
"Return JSON only with keys: action, reason, short_title.\n\n"
|
||||
f"Active task:\n{json.dumps(active_task_payload, ensure_ascii=False)}\n\n"
|
||||
|
||||
Reference in New Issue
Block a user