Skip to main content
An email agent reads what lands in an inbox, finds what it needs to answer, and drafts the reply. The answer is rarely in the email itself. It sits in a chat thread or a file someone shared, often with more in it than the reply should carry. The agent drafts, and a person decides what is sent. Email is reads and writes over scattered context, an inbox, chat and the files shared in it, and that is the work Mirage is built for. The agent reaches all of it from one terminal, with fewer tokens than calling the same services as MCP tools (VFS-Bench 1.0). Its limits are fixed, one inbox to answer from and nothing sent without a person, and a managed terminal holds an agent to exactly that. Here it runs as an in-process terminal on a Mirage server, without a VM or sandbox.

Setup

Mail

himalaya, an email CLI, reads the inbox, saves drafts and sends.

Files

Slack is mounted read-only at /slack, files included.

Policy

A policy script, guard.py, checks every reply and holds each send for a person.
You need the mirage CLI, a Slack bot, a mailbox and two keys, SLACK_BOT_TOKEN and MAIL_PASSWORD.
Slack. A bot with channels:read, channels:history and files:read, plus groups:read and groups:history for a private channel. See Slack. Invite it to #incidents, and post the note above with the CSV as a message in the channel, not as a reply in a thread: the mount shows a channel’s messages, not its threads.Mail. Any IMAP and SMTP account works; see Email. To try the example without one, run GreenMail, a mail server for tests, in Docker. It takes any password and keeps every message on your machine, so nothing reaches a real inbox:
A real mailbox comes with Drafts and Sent folders. GreenMail starts with none, so create them:
Then send the customer’s email to the support address:
MAIL_PASSWORD can be anything for GreenMail.
The policy runs on Monty, a small sandboxed Python interpreter:
workspace.yaml mounts Slack read-only, keeps /workspace in memory and installs himalaya with the support account. With your own mailbox, set its hosts and username, and drop the two ports and use_ssl.The support profile is what every terminal gets. Its allow list leaves the agent the text tools it needs and three mail commands, to list, read and reply: no compose, forward, delete or raw send. Its policy, guard.py, judges each reply before it runs:
workspace.yaml
guard.py sees each command after the shell has expanded it, so a variable or a glob cannot hide a recipient or a path. It judges only himalaya message reply, the one way the profile lets the agent write mail, with one rule per function:
  • hides_a_flag_value: a flag must be written apart from its value, as --attach FILE, not --attach=FILE or -tADDR, so the rules below see every value.
  • adds_a_recipient: a reply goes to whoever wrote in, and no one else, so --to, --cc and --bcc are refused.
  • attaches_a_bad_report: an attachment must be a report the agent built in /workspace/outbox/, never a file straight from Slack, and customers_in reads its first column to check that it holds one customer.
  • sends_now: --send asks a person. Without it, a reply is only saved to Drafts.
guard.py
Export the keys, create the workspace, and open a terminal for the agent:
The local server reads the keys when it starts, so mirage daemon restart stops a server that started without them.

Example

A customer emails the support inbox about a calendar sync failure the team already dealt with, and asks which of their appointments it hit. The answer is in Slack, where an engineer posted this in the #incidents channel with a CSV of every customer’s affected events:
Incident 2026-11-16: calendar sync failed 06:10–07:40 UTC for Northwind Health, Harbor Dental and Lakeside Physio.
Cause: an expired Google token on our side; no data was lost.
Fix: token rotated, sync re-run for the window, every affected event is back.
Affected events for all three customers attached. Share each customer only their own.
📎 affected-events.csv
The CSV has one row per event, with the customer first: These are the commands the agent runs, in the agent terminal Setup created. Your agent sends each one with mirage shell -s agent, or through MCP, the HTTP API, RPC or SSH.
1

Read the email

The new email is message 1 in the inbox.
Priya Shah, at Northwind Health, asks which appointments the sync failure hit.
2

Find the note in Slack

A Slack channel is a folder under /slack, with the day’s messages and the files shared that day.
The engineer’s note. The agent keeps the attached CSV’s path as $events.
3

Keep only this customer's rows

The agent copies the CSV’s header and Northwind Health’s rows into a report, $report, in /workspace/outbox/.
214 appointments: 77 at Bellevue, 75 at Tacoma and 62 at Everett.
4

Save the reply as a draft

The agent writes the reply to /workspace/reply.txt, then saves it with the report attached.
The draft waits in Drafts. Nothing has been sent.
5

Mistakes are refused

If the agent copies someone in, attaches the raw CSV, or deletes mail, the command is refused before it runs. Each prints himalaya: Permission denied and the reason:
6

Send once a person approves

A person approves from their own terminal, with the ask ID the refusal printed, and the same command then sends:
Each line runs in the agent’s terminal with mirage shell -s agent, which keeps variables such as $report from one call to the next.
For the commands and flags himalaya supports, see himalaya. For more on asks, see Policies and Scripts.