Skip to main content

Module wake_pipeline

Module wake_pipeline 

Source
Expand description

The node’s letter pipeline: letter in -> policy -> g4a deliver (or refuse; the letter stays in the inbox).

m4a only hands letters over (its M4A_LETTER_HOOK, the door session.wake); this node’s own mailbox is a second letter source (the node-mail host action below). The node decides what a letter may do, from an operator file (--wake-policy <file>, JSON):

{
  "terminal_typing": ["<nick>"],
  "routines": { "<nick>": { "credential_command": ["<program>", "<arg>"] } },
  "spawn_profiles": { "<nick>": { "provider": "kimi", "command": ["<program>"] } },
  "node_mail_to": "<nick>"
}
  • A live session with a structured prompt channel gets the letter as a turn (deliver).
  • A raw-terminal session (typing into its PTY) is the terminal capability: refused unless the policy names that nick in terminal_typing.
  • A nick bound to a routine (a vendor-hosted web session) gets one routine POST through g4a’s deliver API (gate4agent_wake::routine). The routine URL and key come from the operator’s credential_command (stdout: {"url": "...", "key": "..."}), are kept in memory for the one call and are never logged.
  • Offline wake: a nick with a spawn_profiles entry launches that preconfigured command (fixed argv; the letter never becomes an argument).

Nothing here embeds a host, key or name; all of it comes from the policy file.

Structs§

MailOutcome
What one node-mail tick did with one message.
MailSeen
The node-mail host action’s memory: message ids already handled. None until the first inbox read (which is not replayed).
RoutineLetter
One letter for a routine.
RoutineTarget
One routine target: how to get its URL and key at delivery time.
SessionLetter
A core wake letter for one of this node’s live sessions (not a routine/spawn nick).
SpawnProfile
Preconfigured launch for an offline nick. The letter never becomes an argv entry.
WakePolicy
The operator’s letter policy for this node. The default delivers to live sessions only.

Enums§

Route
The pipeline’s decision for one letter.
SessionShape
What the session that owns a nick looks like right now.

Functions§

deliver_routine
Delivers letter through g4a’s routine POST. Ok(status) on 2xx.
launch_spawn_profile
Runs a spawn profile’s fixed command. The letter is not passed on argv (or at all). Ok(()) when the process started; the caller does not wait for the provider turn.
letter_room
(room label for the letter, address a reply goes to) for a message addressed to to from from: room:NAME stays NAME and is answered in the room; anything else is dm:<from>.
node_mail_tick
route
Decides the route for a letter to nick.
routine_credential
Runs the target’s credential command; (url, key). Errors never carry its output.
session_letters
Unseen wake letters that name a nick without a routine or spawn profile: these go to the node’s live session with that nick (letter wake), not to node_mail_to.
wake_line
The wake line a live session gets instead of the letter text.
wake_nick
One node-mail tick over a mail.inbox reply: every new message goes to policy.node_mail_to through the pipeline. The first tick only records what is already there. Session nick named by a core wake letter (subject = "wake <nick>").