- Expanded package inclusion in `pyproject.toml` to support new modules. - Introduced new `adapters` and `protocol` packages for better organization. - Added backend adapter implementations for control plane integration. - Updated main application imports to reflect new package structure. - Removed deprecated core components and adjusted documentation accordingly. - Enhanced architecture documentation to clarify the new runtime and integration layers.
84 lines
2.2 KiB
Python
84 lines
2.2 KiB
Python
"""Control-plane integration ports.
|
|
|
|
These interfaces define the boundary between engine runtime logic and
|
|
control-plane capabilities (config lookup, history persistence, retrieval,
|
|
and tool resource discovery).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Dict, List, Optional, Protocol
|
|
|
|
|
|
class AssistantRuntimeConfigProvider(Protocol):
|
|
"""Port for loading trusted assistant runtime configuration."""
|
|
|
|
async def fetch_assistant_config(self, assistant_id: str) -> Optional[Dict[str, Any]]:
|
|
"""Fetch assistant configuration payload."""
|
|
|
|
|
|
class ConversationHistoryStore(Protocol):
|
|
"""Port for persisting call and transcript history."""
|
|
|
|
async def create_call_record(
|
|
self,
|
|
*,
|
|
user_id: int,
|
|
assistant_id: Optional[str],
|
|
source: str = "debug",
|
|
) -> Optional[str]:
|
|
"""Create a call record and return control-plane call ID."""
|
|
|
|
async def add_transcript(
|
|
self,
|
|
*,
|
|
call_id: str,
|
|
turn_index: int,
|
|
speaker: str,
|
|
content: str,
|
|
start_ms: int,
|
|
end_ms: int,
|
|
confidence: Optional[float] = None,
|
|
duration_ms: Optional[int] = None,
|
|
) -> bool:
|
|
"""Append one transcript turn segment."""
|
|
|
|
async def finalize_call_record(
|
|
self,
|
|
*,
|
|
call_id: str,
|
|
status: str,
|
|
duration_seconds: int,
|
|
) -> bool:
|
|
"""Finalize a call record."""
|
|
|
|
|
|
class KnowledgeRetriever(Protocol):
|
|
"""Port for RAG / knowledge retrieval operations."""
|
|
|
|
async def search_knowledge_context(
|
|
self,
|
|
*,
|
|
kb_id: str,
|
|
query: str,
|
|
n_results: int = 5,
|
|
) -> List[Dict[str, Any]]:
|
|
"""Search a knowledge source and return ranked snippets."""
|
|
|
|
|
|
class ToolCatalog(Protocol):
|
|
"""Port for resolving tool metadata/configuration."""
|
|
|
|
async def fetch_tool_resource(self, tool_id: str) -> Optional[Dict[str, Any]]:
|
|
"""Fetch tool resource configuration."""
|
|
|
|
|
|
class ControlPlaneGateway(
|
|
AssistantRuntimeConfigProvider,
|
|
ConversationHistoryStore,
|
|
KnowledgeRetriever,
|
|
ToolCatalog,
|
|
Protocol,
|
|
):
|
|
"""Composite control-plane gateway used by engine services."""
|