Expand description
Letter wake for live sessions the node adopted (/m4a/adopt).
The old standalone mailbox daemon woke a session itself: its listener held the account’s
push socket and pressed the turn on the provider’s leader. The node owns the accounts now,
so it runs that listener in-process, one thread per adopted account (mail4agent’s library:
open the account store, sync/push, new inbound letters). The store dedups by event and never
hands over the account’s own messages; each letter goes to a per-session queue whose one
worker pushes it into the live session through the leader (grok: ACP session/load +
session/prompt, gate4agent_wake::grok_leader), with the session id and cwd recorded at
adoption, so at most one push runs into a session at a time.
Adoptions persist in <accounts root>/adopted.json (no secret: provider, session id, cwd,
nick, account ref, store root), so a node restart restarts the listeners. Nothing here embeds
a host, key or name.
Structs§
- Adoption
- One adopted live session.
- Spawned
Wake - A wake signal for a session this node spawned: who wrote and which event. No letter text; the session reads the letter itself through m4a.
Constants§
- ADOPTED_
FILE - WEB_
SESSION - Provider id of a web session woken by its routine webhook (no local process, no leader).
Functions§
- grok_
session_ cwd - Working directory of a grok session from the provider’s own index (
active_sessions.jsonrows{"session_id","cwd"}), falling back to the session file’scwdfield. - is_
watched - Whether a listener of this account is currently wanted (started and not replaced).
- leader_
for - Leader endpoint of
provider(grok only for now). - letter_
prompt - The prompt a woken session gets: headers, how to answer, then the letter verbatim.
- load_
adoptions - restore
- Restarts the listeners of every saved adoption (node start). Returns how many started.
- restore_
from_ env - Node start: restore when the node has m4a accounts configured; says why not otherwise.
- save_
adoption - Inserts or replaces the adoption of
(provider, session). - set_
spawned_ sink - Where wake signals of spawned sessions go (the node’s wake handle). Set once at start.
- sole_
adoption - The provider session an attach with no session of its own belongs to: the only adoption of
that provider. Several adoptions are ambiguous (
None). - unwatch
- Stops the listener of an account (session ended).
- watch
- Starts (or restarts) the in-process mailbox listener of
a. - watch_
spawned - Starts the mailbox listener of an account this node assigned at spawn: it keeps the account open (sync, push, auto-join of invites by the m4a auto-join policy) and turns each new letter into a wake signal for that session.
- watch_
web_ sessions - Starts the mailbox listener of every routine in
policythat names its own m4a account (routines.<nick>.mailbox): the node is that web session’s courier, each new letter goes out as one routine POST. Returns how many started.