Skip to main content

Module m4a_wake

Module m4a_wake 

Source
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.

Constants§

ADOPTED_FILE

Functions§

grok_session_cwd
Working directory of a grok session from the provider’s own index (active_sessions.json rows {"session_id","cwd"}), falling back to the session file’s cwd field.
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).
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).
watch
Starts (or restarts) the in-process mailbox listener of a.