Something went wrong. Try again.
small gleam coding and (not yet) persistent agent daemon with a detachable cli forked from okami.mom/albedo
Something went wrong. Try again.
1.5 kB · 50 lines
Python
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051"""mail.submit: one letter from this session to another. The daemon derivesthe sender, resolves the name, stores the letter, and delivers it."""
from __future__ import annotations
from typing import cast
from albedo_api import Host, PythonApi, Record
class Receipt(Record): """receipt.id, .to (session id), .name, and .status: "delivered", "queued" behind a running turn, or "pending" until that session runs."""
id: str to: str name: str status: str
host: Host
class Mail: async def submit(self, to: object, body: str) -> Receipt: """Send `body` to "parent", a child or sibling by name, an agent handle, or any session id.""" target = getattr(to, "id", to) if not isinstance(target, str) or not target.strip(): raise TypeError( 'mail.submit(to, body): to is "parent", a name, a session id, or an agent handle' ) if not isinstance(body, str): raise TypeError( f"mail.submit(to, body): body must be str, got {type(body).__name__}" ) return Receipt( cast(dict, await host("mail.submit", {"to": target.strip(), "body": body})) )
def read(self, *_: object, **__: object) -> None: raise AttributeError( "there is no mail.read: letters to you arrive in your conversation as <mail> blocks" )
def setup(api: PythonApi) -> dict[str, object]: global host host = api.host return {"mail": Mail(), "MailError": api.HostError}