refactor(schemas): 统一 message/notification 命名边界,旧名收敛至兼容映射表

- notification 域:渠道能力(MessageChannel→NotificationChannel、ChannelCapability* 迁入 notification.py)
- message 域:消息收发(Notification→Message、NotificationType→MessageType、CommingMessage→IncomingMessage、NotificationHistoryItem→MessageHistoryItem、NotificationClear*→MessageClear*)
- Agent 工具契约:send_notification_message→send_message、notification_callback→message_callback
- 源码不保留旧名物理别名,旧导入经 app/runtime/compat/manifest.py SYMBOL_ALIASES 惰性解析
- API 路径与持久化键冻结不变,前端零改动
- 新增兼容守护测试与 docs/rules/07 命名边界规范
This commit is contained in:
jxxghp
2026-08-16 19:32:20 +08:00
parent 98276a68a8
commit 240a4dffe6
96 changed files with 1975 additions and 1751 deletions
+8 -8
View File
@@ -8,11 +8,11 @@ from app.agent.tools.impl.ask_user_choice import (
UserChoiceOptionInput,
)
from app.agent.tools.impl.send_message import SendMessageTool
from app.schemas import Notification
from app.schemas.types import MessageChannel
from app.schemas import Message
from app.schemas.types import NotificationChannel
def _run_choice_tool(agent_context: dict, channel: str, source: str) -> Notification:
def _run_choice_tool(agent_context: dict, channel: str, source: str) -> Message:
"""运行按钮选择工具并返回其发送的通知。"""
tool = AskUserChoiceTool(session_id="session-1", user_id="ou_xxx")
tool.set_message_attr(
@@ -41,7 +41,7 @@ def test_choice_tool_backfills_original_chat_id_from_session_context():
"""群聊场景下按钮选择通知应回填会话上下文中的 original_chat_id。"""
notification = _run_choice_tool(
agent_context={"original_chat_id": "oc_group_123"},
channel=MessageChannel.Feishu.value,
channel=NotificationChannel.Feishu.value,
source="feishu-test",
)
@@ -53,7 +53,7 @@ def test_choice_tool_keeps_explicit_original_chat_id():
"""按钮选择通知已显式携带原会话 ID 时不应被上下文覆盖。"""
notification = _run_choice_tool(
agent_context={"original_chat_id": "oc_group_zzz"},
channel=MessageChannel.Telegram.value,
channel=NotificationChannel.Telegram.value,
source="telegram-test",
)
@@ -64,7 +64,7 @@ def test_choice_tool_no_context_does_not_backfill():
"""会话上下文未携带原会话 ID 时,通知保持原有发送目标。"""
notification = _run_choice_tool(
agent_context={},
channel=MessageChannel.Telegram.value,
channel=NotificationChannel.Telegram.value,
source="telegram-test",
)
@@ -92,7 +92,7 @@ def test_send_tool_message_backfills_original_chat_id():
"""send_tool_message 工具消息同样应回填原会话 ID。"""
tool = SendMessageTool(session_id="session-1", user_id="ou_xxx")
tool.set_message_attr(
channel=MessageChannel.Feishu.value,
channel=NotificationChannel.Feishu.value,
source="feishu-test",
username="tester",
)
@@ -115,7 +115,7 @@ def test_tool_context_includes_original_chat_id():
agent = MoviePilotAgent(
session_id="session-1",
user_id="ou_xxx",
channel=MessageChannel.Feishu.value,
channel=NotificationChannel.Feishu.value,
source="feishu-test",
username="tester",
original_chat_id="oc_group_123",