okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
ff92766
main
1"""mail.submit: one letter from this session to another. The daemon derives 2the sender, resolves the name, stores the letter, and delivers it.""" 3 4from __future__import annotations 5 6from typing import cast 7 8from albedo_api import Host ,PythonApi ,Record 9 10 11class Receipt (Record ): 12"""receipt.id, .to (session id), .name, and .status: "delivered", 13"queued" behind a running turn, or "pending" until that session runs. 14"delivered" may still be waiting for kernel preparation.""" 15 16id :str 17to :str 18name :str 19status :str 20 21 22host :Host 23 24 25class async def submit (self ,to :object ,body :str )-> Receipt : 27"""Send `body` to "parent", a child or sibling by name, an agent 28handle, or any session id.""" 29target = getattr (to ,"id" ,to ) 30if not isinstance (target ,str )or not target .strip (): 31raise TypeError ( 32'mail.submit(to, body): to is "parent", a name, a session id, or an agent handle' 33 ) 34if not isinstance (body ,str ): 35raise TypeError ( 36f"mail.submit(to, body): body must be str, got { type ( body ). __name__ } " 37 ) 38return Receipt ( 39cast (dict ,await host ("mail.submit" , {"to" :target .strip (),"body" :body })) 40 ) 41 42def read (self ,* _ :object ,** __ :object )-> None : 43raise AttributeError ( 44"there is no mail.read: letters to you arrive in your conversation as <mail> blocks" 45 ) 46 47 48def setup (api :PythonApi )-> dict [str ,object ]: 49global host 50host = api .host 51return {"mail" :"MailError" :api .HostError }