"""The session checklist: the model's binding to the checklist extension's `checklist.*` host route (extensions/checklist/src/albedo_ext_checklist).""" from __future__ import annotations from typing import TypedDict, cast from albedo_api import Host, PythonApi host: Host class ChecklistItem(TypedDict): id: int text: str done: bool created_at: str class Checklist: """This session's checklist. Items are dicts with id, text, done, and created_at.""" async def add(self, text: str) -> ChecklistItem: """Add an open item; returns it with its id.""" return cast(ChecklistItem, await host("checklist.add", {"text": text})) async def items(self) -> list[ChecklistItem]: """This session's items, open ones first.""" return cast(list[ChecklistItem], await host("checklist.items", {})) async def check(self, id: int) -> ChecklistItem: """Check off one of this session's items once it is done. Only the 50 most recently checked items are kept.""" return cast(ChecklistItem, await host("checklist.check", {"id": id})) def setup(api: PythonApi) -> dict[str, object]: global host host = api.host return {"checklist": Checklist()}