"""`lcm`: this session's stored LCM folds and the transcript rows they cover.""" from __future__ import annotations from typing import Any from albedo_api import Host, PythonApi, nested_record class Lcm: """Read-only, paged access to stored LCM summary nodes.""" def __init__(self, host: Host) -> None: self._host = host async def _call(self, method: str, args: dict[str, Any]) -> Any: return nested_record(await self._host("lcm." + method, args)) async def list(self, limit: int = 20, offset: int = 0) -> Any: """A page of every stored fold: id, depth, seq range, cut_off, when, preview.""" return await self._call("list", {"limit": limit, "offset": offset}) async def grep( self, pattern: str, limit: int = 10, offset: int = 0, summary_id: int | None = None, ) -> Any: """Transcript rows and summaries containing `pattern`, case-insensitively.""" return await self._call( "grep", { "pattern": pattern, "limit": limit, "offset": offset, "summary_id": summary_id, }, ) async def describe(self, id: int) -> Any: """One node: its summary, source range, cut_off and children.""" return await self._call("describe", {"id": id}) async def expand(self, id: int, offset: int = 0, limit: int = 4000) -> Any: """A page of the original rows one node covers, as text.""" return await self._call("expand", {"id": id, "offset": offset, "limit": limit}) def setup(api: PythonApi) -> dict[str, object]: return {"lcm": Lcm(api.host)}