33import logging
44from asyncio import Queue
55from collections .abc import Awaitable , Callable
6+ from dataclasses import dataclass
67from typing import TYPE_CHECKING , Any , Protocol
78
89from deprecated import deprecated
@@ -53,13 +54,17 @@ class PlatformManagerProtocol(Protocol):
5354 platform_insts : list [Platform ]
5455
5556
57+ @dataclass
58+ class UnifiedWebhook :
59+ handler : Callable [..., Awaitable [Any ]]
60+ methods : list [str ]
61+ desc : str = ""
62+
63+
5664class Context :
5765 """暴露给插件的接口上下文。"""
5866
5967 registered_web_apis : list = []
60- registered_unified_webhooks : dict [
61- str , tuple [Callable [..., Awaitable [Any ]], list [str ], str ]
62- ] = {}
6368
6469 # 向后兼容的变量
6570 _register_tasks : list [Awaitable ] = []
@@ -80,6 +85,8 @@ def __init__(
8085 cron_manager : CronJobManager ,
8186 subagent_orchestrator : SubAgentOrchestrator | None = None ,
8287 ) -> None :
88+ self .registered_unified_webhooks : dict [str , UnifiedWebhook ] = {}
89+
8390 self ._event_queue = event_queue
8491 """事件队列。消息平台通过事件队列传递消息事件。"""
8592 self ._config = config
@@ -541,10 +548,10 @@ def register_unified_webhook(
541548 如果相同 webhook_uuid 已注册,会覆盖原有回调。
542549 """
543550 normalized_methods = [method .upper () for method in (methods or ["GET" , "POST" ])]
544- self .registered_unified_webhooks [webhook_uuid ] = (
545- view_handler ,
546- normalized_methods ,
547- desc ,
551+ self .registered_unified_webhooks [webhook_uuid ] = UnifiedWebhook (
552+ handler = view_handler ,
553+ methods = normalized_methods ,
554+ desc = desc ,
548555 )
549556
550557 """
0 commit comments