MOLTED EMAIL
CLI Reference

molted listen

Connect to the SSE event stream — persistent event loop for agents

Agent context

The listen command connects to the SSE event stream and acts as a persistent event loop for agents. It turns the CLI from a one-shot command tool into an agent runtime that reacts to events in real-time.

molted listen

Pipe to a long-running agent process (restarted if it exits)

molted listen --pipe "node my-agent.js"

--pipe and --json both write one JSON line per event

{ "event": "<type>", "id": "<eventId>", "data": { ...payload }, "timestamp": "..." }

Filter events

molted listen --events "inbound.*"
molted listen --events "delivery.bounced,delivery.complained" --pipe "./bounce-agent.py"

JSON mode for shell piping

molted listen --json | jq '.event'

Works with pm2/systemd for persistent agent runtimes:
pm2 start "molted listen --pipe ./agent.js --events 'inbound.*'" --name my-agent

With --since, a resumed connection replays missed events first (including any matching a wildcard filter). If the server can't guarantee it caught everything -- a large burst during replay, or a backlog too big to page through -- it prints a "replay gap" warning to stderr instead of silently dropping the difference; the stream itself keeps running.

Related: molted events

Commands

molted listen

Connect to the SSE event stream — persistent event loop for agents

molted listen [options]
OptionDescriptionDefault
--pipe <command>Long-running handler process (receives JSON lines on stdin)
--events <types>Comma-separated event types to filter (supports wildcards: "delivery.*")
--jsonOutput one JSON line per event to stdout (for shell piping)
--concurrency <n>Max events being dispatched at once1
--retries <n>Retries for a failed write to the --pipe handler before the event is skipped3
--since <eventId>Resume from a specific event ID

See CLI overview for global options, credentials and output format.