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
+11 -11
View File
@@ -9,7 +9,7 @@ from app.agent.tools.tags import ToolTag
from app.chain.subscribe import SubscribeChain
from app.db.oper.user import UserOper
from app.runtime.log import logger
from app.schemas.types import MUSIC_ENTITY_ALBUM, MediaSource, MediaType, MessageChannel
from app.schemas.types import MUSIC_ENTITY_ALBUM, MediaSource, MediaType, NotificationChannel
from ._music_utils import normalize_music_type
@@ -134,20 +134,20 @@ class AddSubscribeTool(MoviePilotTool):
return resolved_username
try:
channel = MessageChannel(self._channel)
channel = NotificationChannel(self._channel)
except ValueError:
return resolved_username
binding_keys = {
MessageChannel.Telegram: ("telegram_userid",),
MessageChannel.Discord: ("discord_userid",),
MessageChannel.Wechat: ("wechat_userid",),
MessageChannel.Feishu: ("feishu_userid", "feishu_openid"),
MessageChannel.WechatClawBot: ("wechatclawbot_userid",),
MessageChannel.Slack: ("slack_userid",),
MessageChannel.VoceChat: ("vocechat_userid",),
MessageChannel.SynologyChat: ("synologychat_userid",),
MessageChannel.QQ: ("qq_userid", "qq_openid"),
NotificationChannel.Telegram: ("telegram_userid",),
NotificationChannel.Discord: ("discord_userid",),
NotificationChannel.Wechat: ("wechat_userid",),
NotificationChannel.Feishu: ("feishu_userid", "feishu_openid"),
NotificationChannel.WechatClawBot: ("wechatclawbot_userid",),
NotificationChannel.Slack: ("slack_userid",),
NotificationChannel.VoceChat: ("vocechat_userid",),
NotificationChannel.SynologyChat: ("synologychat_userid",),
NotificationChannel.QQ: ("qq_userid", "qq_openid"),
}.get(channel)
if not binding_keys:
return resolved_username
+7 -7
View File
@@ -12,9 +12,9 @@ from app.application.messaging.agent import (
build_agent_choice_callback,
)
from app.runtime.log import logger
from app.schemas import Notification, NotificationType
from app.schemas.message import ChannelCapabilityManager
from app.schemas.types import MessageChannel
from app.schemas import Message, MessageType
from app.schemas.notification import ChannelCapabilityManager
from app.schemas.types import NotificationChannel
class UserChoiceOptionInput(BaseModel):
@@ -140,7 +140,7 @@ class AskUserChoiceTool(MoviePilotTool):
return "当前不在可回传消息的会话中,无法发起按钮选择"
try:
channel = MessageChannel(self._channel)
channel = NotificationChannel(self._channel)
except ValueError:
return f"不支持的消息渠道: {self._channel}"
@@ -200,11 +200,11 @@ class AskUserChoiceTool(MoviePilotTool):
len(choice_options),
)
await self.send_notification_message(
Notification(
await self.send_message(
Message(
channel=channel,
source=self._source,
mtype=NotificationType.Agent,
mtype=MessageType.Agent,
userid=self._user_id,
username=self._username,
title=title,
+2 -2
View File
@@ -9,7 +9,7 @@ from app.agent.tools.base import MoviePilotTool
from app.agent.tools.tags import ToolTag
from app.runtime.events import eventmanager
from app.runtime.log import logger
from app.schemas.types import EventType, MessageChannel
from app.schemas.types import EventType, NotificationChannel
class RunSlashCommandInput(BaseModel):
@@ -83,7 +83,7 @@ class RunSlashCommandTool(MoviePilotTool):
channel = None
if self._channel:
try:
channel = MessageChannel(self._channel)
channel = NotificationChannel(self._channel)
except (ValueError, KeyError):
channel = None
+7 -7
View File
@@ -8,9 +8,9 @@ from pydantic import BaseModel, Field, model_validator
from app.agent.tools.base import MoviePilotTool
from app.agent.tools.tags import ToolTag
from app.runtime.log import logger
from app.schemas import Notification, NotificationType
from app.schemas.message import ChannelCapabilityManager, ChannelCapability
from app.schemas.types import MessageChannel
from app.schemas import Message, MessageType
from app.schemas.notification import ChannelCapabilityManager, ChannelCapability
from app.schemas.types import NotificationChannel
class SendLocalFileInput(BaseModel):
@@ -72,7 +72,7 @@ class SendLocalFileTool(MoviePilotTool):
return "当前不在可回传消息的会话中,无法发送附件"
try:
channel = MessageChannel(self._channel)
channel = NotificationChannel(self._channel)
except ValueError:
return f"不支持的消息渠道: {self._channel}"
@@ -94,11 +94,11 @@ class SendLocalFileTool(MoviePilotTool):
resolved_path,
)
await self.send_notification_message(
Notification(
await self.send_message(
Message(
channel=channel,
source=self._source,
mtype=NotificationType.Agent,
mtype=MessageType.Agent,
userid=self._user_id,
username=self._username,
title=title,
+5 -5
View File
@@ -7,8 +7,8 @@ from pydantic import BaseModel, Field, model_validator
from app.agent.tools.base import MoviePilotTool
from app.agent.tools.tags import ToolTag
from app.runtime.log import logger
from app.schemas import Notification
from app.schemas.types import NotificationType
from app.schemas import Message
from app.schemas.types import MessageType
class SendMessageInput(BaseModel):
@@ -90,11 +90,11 @@ class SendMessageTool(MoviePilotTool):
f"image_url={image_url}"
)
try:
await self.send_notification_message(
Notification(
await self.send_message(
Message(
channel=self._channel,
source=self._source,
mtype=NotificationType.Other,
mtype=MessageType.Other,
userid=self._user_id,
username=self._username,
title=title,
+4 -4
View File
@@ -8,7 +8,7 @@ from app.agent.tools.base import MoviePilotTool
from app.agent.tools.tags import ToolTag
from app.runtime.config import settings
from app.runtime.log import logger
from app.schemas import Notification, NotificationType
from app.schemas import Message, MessageType
class SendVoiceMessageInput(BaseModel):
@@ -82,11 +82,11 @@ class SendVoiceMessageTool(MoviePilotTool):
f"use_voice={used_voice}, text_len={len(message)}"
)
await self.send_notification_message(
Notification(
await self.send_message(
Message(
channel=self._channel,
source=self._source,
mtype=NotificationType.Agent,
mtype=MessageType.Agent,
userid=self._user_id,
username=self._username,
text=message,