"""`transcript`: this session's durable transcript rows, archived ones included.""" from __future__ import annotations from typing import cast from albedo_api import Host, PythonApi, Record, nested_record class Transcript: """Read-only, paged search and reads over this session's transcript.""" def __init__(self, host: Host) -> None: self._host = host async def grep( self, pattern: str, limit: int = 10, offset: int = 0, after_seq: int | None = None, before_seq: int | None = None, ) -> Record: """Rows containing `pattern`, case-insensitively, oldest first.""" return cast( Record, nested_record( await self._host( "transcript.grep", { "pattern": pattern, "limit": limit, "offset": offset, "after_seq": after_seq, "before_seq": before_seq, }, ) ), ) async def read( self, seq: int, through: int | None = None, offset: int = 0, limit: int = 4000 ) -> Record: """A page of rows as text from `seq` on, or through row `through`.""" return cast( Record, nested_record( await self._host( "transcript.read", {"seq": seq, "through": through, "offset": offset, "limit": limit}, ) ), ) def setup(api: PythonApi) -> dict[str, object]: return {"transcript": Transcript(api.host)}