feat(workflow): add edge-tool routing and realtime runtime

This commit is contained in:
Xin Wang
2026-08-04 22:29:04 +08:00
parent 1902ffc240
commit 59588ba88d
25 changed files with 1952 additions and 107 deletions

View File

@@ -101,6 +101,18 @@ class BrainRuntime:
flow_global_functions: list[Any] = field(default_factory=list)
@dataclass(frozen=True)
class RealtimeBrainRuntime:
"""Pipeline-owned capabilities for a speech-to-speech brain session."""
realtime: Any
queue_frame: Callable[[Frame], Awaitable[None]]
call_end: CallEndPort
session_id: str = ""
client_tools: ClientToolPort | None = None
set_input_enabled: Callable[[bool], None] | None = None
class BaseBrain:
"""No-op lifecycle defaults for brains without local orchestration."""
@@ -118,6 +130,16 @@ class BaseBrain:
async def setup(self, cfg: AssistantConfig, runtime: BrainRuntime) -> None:
"""Register tools and initialize per-call orchestration."""
async def setup_realtime(
self,
cfg: AssistantConfig,
runtime: RealtimeBrainRuntime,
) -> None:
"""Initialize optional speech-to-speech orchestration."""
async def on_realtime_user_speech_started(self) -> None:
"""Allow a workflow to move past an interruptible fixed message."""
async def run_preflight(self) -> None:
"""Run deterministic server-side startup work before media starts."""
@@ -211,6 +233,14 @@ class Brain(Protocol):
async def setup(self, cfg: AssistantConfig, runtime: BrainRuntime) -> None: ...
async def setup_realtime(
self,
cfg: AssistantConfig,
runtime: RealtimeBrainRuntime,
) -> None: ...
async def on_realtime_user_speech_started(self) -> None: ...
async def run_preflight(self) -> None: ...
async def on_connected(self, *, greeting_pending: bool = False) -> None: ...