feat: add session updates and message dialogs
This commit is contained in:
@@ -44,6 +44,14 @@ class BrainSpec:
|
||||
owns_context: bool
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SessionVariableUpdate:
|
||||
"""Result of one silent update to declared session variables."""
|
||||
|
||||
changed: list[str]
|
||||
dynamic_variables: dict[str, str | int | float | bool]
|
||||
|
||||
|
||||
class CallEndPort(Protocol):
|
||||
"""Small call-lifecycle surface available to a brain."""
|
||||
|
||||
@@ -144,6 +152,13 @@ class BaseBrain:
|
||||
async def on_client_ready(self) -> None:
|
||||
"""Replay client-visible state after its app message channel is ready."""
|
||||
|
||||
async def on_session_update(
|
||||
self,
|
||||
dynamic_variables: dict[str, Any],
|
||||
) -> SessionVariableUpdate:
|
||||
"""Apply a silent client state update without starting an LLM turn."""
|
||||
raise ValueError(f"助手类型 {self.spec.type} 不支持会话动态变量更新")
|
||||
|
||||
def record_user_message(self, content: str) -> None:
|
||||
"""Observe a committed user message for brain-owned routing state."""
|
||||
|
||||
@@ -194,6 +209,11 @@ class Brain(Protocol):
|
||||
|
||||
async def on_client_ready(self) -> None: ...
|
||||
|
||||
async def on_session_update(
|
||||
self,
|
||||
dynamic_variables: dict[str, Any],
|
||||
) -> SessionVariableUpdate: ...
|
||||
|
||||
def record_user_message(self, content: str) -> None: ...
|
||||
|
||||
async def on_user_turn_end(self, content: str) -> bool: ...
|
||||
|
||||
Reference in New Issue
Block a user