feat: add Memory Gateway integration with async support for memory snapshots and user management
This commit is contained in:
@ -15,6 +15,8 @@ from .schema import (
|
||||
BeaverConfig,
|
||||
ChannelConfig,
|
||||
EmbeddingConfig,
|
||||
MemoryConfig,
|
||||
MemoryGatewayConfig,
|
||||
MCPServerConfig,
|
||||
ProviderConfig,
|
||||
ToolsConfig,
|
||||
@ -76,6 +78,7 @@ def load_config(
|
||||
authz=_parse_authz(data.get("authz")),
|
||||
channels=_parse_channels(data.get("channels")),
|
||||
backend_identity=_parse_backend_identity(data.get("backend_identity") or data.get("backendIdentity")),
|
||||
memory=_parse_memory(data.get("memory")),
|
||||
config_path=path,
|
||||
)
|
||||
|
||||
@ -251,6 +254,35 @@ def _parse_backend_identity(raw: Any) -> BackendIdentityConfig:
|
||||
)
|
||||
|
||||
|
||||
def _parse_memory(raw: Any) -> MemoryConfig:
|
||||
data = _as_dict(raw)
|
||||
gateway = _as_dict(data.get("gateway"))
|
||||
mode = (_string(data.get("mode")) or "local").lower()
|
||||
if mode not in {"local", "gateway"}:
|
||||
mode = "local"
|
||||
return MemoryConfig(
|
||||
mode=mode,
|
||||
gateway=MemoryGatewayConfig(
|
||||
base_url=_string(gateway.get("baseUrl") or gateway.get("base_url")) or "",
|
||||
api_key=_string(gateway.get("apiKey") or gateway.get("api_key")) or "",
|
||||
default_user_id=_string(gateway.get("defaultUserId") or gateway.get("default_user_id")) or "",
|
||||
timeout_seconds=_float(gateway.get("timeoutSeconds") or gateway.get("timeout_seconds")) or 15.0,
|
||||
snapshot_search_limit=int(
|
||||
_float(gateway.get("snapshotSearchLimit") or gateway.get("snapshot_search_limit"))
|
||||
or 5
|
||||
),
|
||||
commit_on_run_complete=_bool(
|
||||
(
|
||||
gateway.get("commitOnRunComplete")
|
||||
if "commitOnRunComplete" in gateway
|
||||
else gateway.get("commit_on_run_complete")
|
||||
),
|
||||
default=True,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _as_dict(value: Any) -> dict[str, Any]:
|
||||
return value if isinstance(value, dict) else {}
|
||||
|
||||
|
||||
@ -115,6 +115,26 @@ class BackendIdentityConfig:
|
||||
public_base_url: str = ""
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class MemoryGatewayConfig:
|
||||
"""Memory Gateway integration settings."""
|
||||
|
||||
base_url: str = ""
|
||||
api_key: str = ""
|
||||
default_user_id: str = ""
|
||||
timeout_seconds: float = 15.0
|
||||
snapshot_search_limit: int = 5
|
||||
commit_on_run_complete: bool = True
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class MemoryConfig:
|
||||
"""Runtime memory strategy configuration."""
|
||||
|
||||
mode: str = "local"
|
||||
gateway: MemoryGatewayConfig = field(default_factory=MemoryGatewayConfig)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class BeaverConfig:
|
||||
"""Config loaded once per backend sandbox instance."""
|
||||
@ -126,6 +146,7 @@ class BeaverConfig:
|
||||
authz: AuthzConfig = field(default_factory=AuthzConfig)
|
||||
channels: dict[str, ChannelConfig] = field(default_factory=dict)
|
||||
backend_identity: BackendIdentityConfig = field(default_factory=BackendIdentityConfig)
|
||||
memory: MemoryConfig = field(default_factory=MemoryConfig)
|
||||
config_path: Path | None = None
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user