mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
feat: rename event types to include 'Event' suffix for consistency
This commit is contained in:
@@ -17,11 +17,11 @@ class MainAgentHooks(BaseAgentRunHooks[AstrAgentContext]):
|
||||
) -> None:
|
||||
await call_event_hook(
|
||||
run_context.context.event,
|
||||
EventType.OnAgentBegin,
|
||||
EventType.OnAgentBeginEvent,
|
||||
run_context,
|
||||
)
|
||||
|
||||
async def on_agent_done(self, run_context: ContextWrapper[AstrAgentContext], llm_response: LLMResponse) -> None:
|
||||
async def on_agent_done(self, run_context, llm_response) -> None:
|
||||
# 执行事件钩子
|
||||
if llm_response and llm_response.reasoning_content:
|
||||
# we will use this in result_decorate stage to inject reasoning content to chain
|
||||
@@ -36,7 +36,7 @@ class MainAgentHooks(BaseAgentRunHooks[AstrAgentContext]):
|
||||
)
|
||||
await call_event_hook(
|
||||
run_context.context.event,
|
||||
EventType.OnAgentDone,
|
||||
EventType.OnAgentDoneEvent,
|
||||
run_context,
|
||||
llm_response,
|
||||
)
|
||||
|
||||
@@ -482,7 +482,7 @@ def register_on_agent_begin(**kwargs):
|
||||
"""
|
||||
|
||||
def decorator(awaitable):
|
||||
_ = get_handler_or_create(awaitable, EventType.OnAgentBegin, **kwargs)
|
||||
_ = get_handler_or_create(awaitable, EventType.OnAgentBeginEvent, **kwargs)
|
||||
return awaitable
|
||||
|
||||
return decorator
|
||||
@@ -512,7 +512,7 @@ def register_on_agent_done(**kwargs):
|
||||
"""
|
||||
|
||||
def decorator(awaitable):
|
||||
_ = get_handler_or_create(awaitable, EventType.OnAgentDone, **kwargs)
|
||||
_ = get_handler_or_create(awaitable, EventType.OnAgentDoneEvent, **kwargs)
|
||||
return awaitable
|
||||
|
||||
return decorator
|
||||
|
||||
@@ -74,7 +74,7 @@ class StarHandlerRegistry(Generic[T]):
|
||||
@overload
|
||||
def get_handlers_by_event_type(
|
||||
self,
|
||||
event_type: Literal[EventType.OnAgentBegin],
|
||||
event_type: Literal[EventType.OnAgentBeginEvent],
|
||||
only_activated=True,
|
||||
plugins_name: list[str] | None = None,
|
||||
) -> list[StarHandlerMetadata[Callable[..., Awaitable[Any]]]]: ...
|
||||
@@ -82,7 +82,7 @@ class StarHandlerRegistry(Generic[T]):
|
||||
@overload
|
||||
def get_handlers_by_event_type(
|
||||
self,
|
||||
event_type: Literal[EventType.OnAgentDone],
|
||||
event_type: Literal[EventType.OnAgentDoneEvent],
|
||||
only_activated=True,
|
||||
plugins_name: list[str] | None = None,
|
||||
) -> list[StarHandlerMetadata[Callable[..., Awaitable[Any]]]]: ...
|
||||
|
||||
@@ -132,7 +132,7 @@ def _resolve_user_path(path: str, *, local_env: bool, umo: str) -> Path:
|
||||
|
||||
def _is_path_within_allowed_roots(path: str, umo: str) -> bool:
|
||||
resolved = _resolve_user_path(path, local_env=True, umo=umo)
|
||||
return any(
|
||||
return any(
|
||||
resolved == allowed_root or resolved.is_relative_to(allowed_root)
|
||||
for allowed_root in _read_allowed_roots(umo)
|
||||
)
|
||||
|
||||
@@ -79,8 +79,8 @@ class PluginRoute(Route):
|
||||
EventType.AdapterMessageEvent: "平台消息下发时",
|
||||
EventType.OnLLMRequestEvent: "LLM 请求时",
|
||||
EventType.OnLLMResponseEvent: "LLM 响应后",
|
||||
EventType.OnAgentBegin: "Agent 开始运行时",
|
||||
EventType.OnAgentDone: "Agent 运行完成后",
|
||||
EventType.OnAgentBeginEvent: "Agent 开始运行时",
|
||||
EventType.OnAgentDoneEvent: "Agent 运行完成后",
|
||||
EventType.OnDecoratingResultEvent: "回复消息前",
|
||||
EventType.OnCallingFuncToolEvent: "函数工具",
|
||||
EventType.OnAfterMessageSentEvent: "发送消息后",
|
||||
|
||||
Reference in New Issue
Block a user