feat(sdk): add host integration extension points
This commit is contained in:
+18
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterable, Mapping
|
||||
from collections.abc import Callable, Iterable, Mapping
|
||||
from copy import deepcopy
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any
|
||||
@@ -18,6 +18,8 @@ from nanobot.session.manager import replay_max_messages_for_context
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from nanobot.agent.loop import AgentLoop
|
||||
from nanobot.bus.runtime_events import RuntimeEventHandler, RuntimeEventType
|
||||
from nanobot.runtime_context import RuntimeContextProvider
|
||||
|
||||
|
||||
class SessionClient:
|
||||
@@ -193,6 +195,21 @@ class RuntimeClient:
|
||||
"""Current runtime workspace."""
|
||||
return self._loop.workspace
|
||||
|
||||
def add_context_provider(
|
||||
self,
|
||||
provider: RuntimeContextProvider,
|
||||
) -> Callable[[], None]:
|
||||
"""Register per-turn model context and return an unsubscribe callback."""
|
||||
return self._loop.register_runtime_context_provider(provider)
|
||||
|
||||
def subscribe(
|
||||
self,
|
||||
event_type: RuntimeEventType,
|
||||
handler: RuntimeEventHandler,
|
||||
) -> Callable[[], None]:
|
||||
"""Subscribe to one runtime event type and return an unsubscribe callback."""
|
||||
return self._loop.runtime_events.subscribe(handler, event_type)
|
||||
|
||||
async def compact_session(self, session_key: str) -> SessionSnapshot:
|
||||
"""Run token/replay-window consolidation for one session."""
|
||||
session = self._loop.sessions.get_or_create(session_key)
|
||||
|
||||
Reference in New Issue
Block a user