refactor(events): unify scoped runtime notifications across clients (#5670)
* refactor(events): unify scoped runtime notifications across clients * style(tests): sort auto-compaction event imports * refactor(events): scope connections and remove retry callback plumbing * docs: remove runtime notification design write-up * refactor(bus): route operation events through the message bus * fix(channels): isolate outbound sends by destination * style(events): group shared notification imports * refactor(events): converge runtime and hook delivery on MessageBus * test(events): migrate fixtures to unified message bus
This commit is contained in:
1 parent
3495281282
commit
192e2e90dc
78 files changed
+1620
-1194
No files matched your search
@@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
@@ -16,15 +15,15 @@ from nanobot.agent.hook import (
|
||||
CompositeHook,
|
||||
)
|
||||
from nanobot.agent.progress_hook import AgentProgressHook
|
||||
from nanobot.events import NO_EVENTS, EventSink
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class AgentTurnHookSpec:
|
||||
"""Inputs needed to build the hook chain for one agent turn."""
|
||||
|
||||
on_progress: Callable[..., Awaitable[None]] | None = None
|
||||
on_stream: Callable[[str], Awaitable[None]] | None = None
|
||||
on_stream_end: Callable[..., Awaitable[None]] | None = None
|
||||
events: EventSink = NO_EVENTS
|
||||
streaming: bool = False
|
||||
channel: str = "cli"
|
||||
chat_id: str = "direct"
|
||||
message_id: str | None = None
|
||||
@@ -44,9 +43,8 @@ class AgentTurnHookSpec:
|
||||
def build_agent_turn_hook(spec: AgentTurnHookSpec) -> AgentHook:
|
||||
"""Build the hook chain used by ``AgentRunner`` for one turn."""
|
||||
progress_hook = AgentProgressHook(
|
||||
on_progress=spec.on_progress,
|
||||
on_stream=spec.on_stream,
|
||||
on_stream_end=spec.on_stream_end,
|
||||
events=spec.events,
|
||||
streaming=spec.streaming,
|
||||
session_key=spec.session_key,
|
||||
tool_hint_max_length=spec.tool_hint_max_length,
|
||||
)
|
||||
@@ -54,7 +52,7 @@ def build_agent_turn_hook(spec: AgentTurnHookSpec) -> AgentHook:
|
||||
return progress_hook
|
||||
|
||||
turn_context = AgentTurnHookContext(
|
||||
on_progress=spec.on_progress,
|
||||
events=spec.events,
|
||||
workspace=spec.workspace,
|
||||
channel=spec.channel,
|
||||
chat_id=spec.chat_id,
|
||||
|
||||
Reference in new issue
Block a user