Skip to content

AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).

feat(ui): give Handle it for me its own picker and split it from Act as me (#493)

Rufus18356a13cd2b
diff --git a/packages/core/openexecutive/architecture/architecture-facts.yaml b/packages/core/openexecutive/architecture/architecture-facts.yaml
index eec453be..ad5d7bdd 100644
--- a/packages/core/openexecutive/architecture/architecture-facts.yaml
+++ b/packages/core/openexecutive/architecture/architecture-facts.yaml
@@ -10483,10 +10483,15 @@ delegation:
signed sign-in. Up calls each switch's own route in order, so the
mailbox, signed sign-ins, owner-only and not-in-training checks all
still apply, and the first refusal stops at a whole step. Training is
- never changed by the dial. The dial is shown on Delegate -> Act as me
- only (with Your rules at everything, and how many went today); Handle
- it for me shows the step read-only with a link to it, then What it
- sent; What it may do links act_as_me and handle_it rows to it.
+ never changed by the dial. The UI shows it as two pickers
+ (ReachCard.tsx): What it writes as you (WritesCard: off / when_asked /
+ inbox, any sending step reads as inbox) on Delegate -> Act as me, and
+ What it sends on its own (SendsCard: off saved as inbox, then the
+ sending steps, with In training and Your rules at everything) on
+ Delegate -> Handle it for me, which opens only at inbox and says so
+ otherwise. Moving Act as me below inbox says Handle it for me stops
+ too. What it may do links act_as_me rows to the first and handle_it
+ rows to the second.
surfaces: |
Settings → Act as me (ActAsMeCard): the Gmail status with the connect
command and Check again, the Write drafts as me switch, the Draft
@@ -10501,9 +10506,10 @@ delegation:
redirects there): the pause. Take the lead (Delegate → Take the lead)
lists Always asks first even while it is off, ending in Meetings asked
for in chat (the meeting_scheduling class mode, moved from Workspace).
- Handle it for me (Delegate → Handle it for me) is the How far it goes
- as you dial, then What it sent (rules at Everything, sent today, the
- week's list). Setup
+ Handle it for me (Delegate → Handle it for me) is What it sends on its
+ own (rules at Everything), then What it sent (sent today, the week's
+ list), Who it's allowed to handle (its learned items) and, under
+ Advanced, the AI line on replies it sends. Setup
status light your_gmail (amber while the inbox watcher is erroring,
rate-limited or has 25 cards waiting); the API protection light says
Send needs signed callers. The chat chip "Drafted an email as you
diff --git a/packages/core/openexecutive/architecture/prebuilt/delegation.json b/packages/core/openexecutive/architecture/prebuilt/delegation.json
index b46c7cba..20820f01 100644
--- a/packages/core/openexecutive/architecture/prebuilt/delegation.json
+++ b/packages/core/openexecutive/architecture/prebuilt/delegation.json
@@ -1,7 +1,7 @@
{
"section_id": "delegation",
"title": "Act as Me (Delegation)",
- "markdown": "The **delegation** module (`openexecutive.delegation`) is **Act as me**: the one place the Executive writes *as* a person instead of as itself. Everywhere else it has its own Google account and bots and signs as itself. Here — when the person asks, or, with a second switch, for mail in their inbox that needs them — it writes an email in their voice and saves it as a **draft in their own mailbox** — Gmail or Outlook — for them to review and send. The one thing it ever sends is one of those inbox drafts, exactly as it is in their mailbox: when the person taps **Send** on its card, or, with a third switch, **Handle it for me**, on its own when plain-code rules allow it (below); chat never sends. The principal can turn it on for themselves, and so can each team member once the owner lets them. It is off by default, and off changes nothing: the prompts, tool lists and prompt caches are byte-identical to an install without it.\n\n## Who can have it, and when it is offered\n\n`delegation.settings.can_delegate(person)` is the single rule for who may turn it on: the principal (a non-archived team member flagged `is_principal`), and any other non-archived team member — never a contact — once team members may have it (`team_members_enabled`). That takes two things: the install allows it (`DELEGATION_TEAM_MEMBERS`, default off, which offers the owner the switch) and the owner turned on **Let team members use it** (`PUT /delegation/team`, principal only, one row in `delegation_team`). Turning the owner's switch off takes it away from every team member from their next message, and their inbox watchers stop at their next check; their own switches, drafts and cards are kept. Everything is keyed by `person_id`. A person turns it on for themselves (`PUT /delegation`); nobody turns it on for anyone else. The setting is one row per person in `delegation_settings`, and a missing, unreadable or zero row all mean off.\n\nAt the start of every chat turn (`Executive.stream_chat` and the committee path) `pin_turn_delegation(session, speaker_text)` runs next to the workspace-mode pin and records a `TurnDelegation` on the session. `ghostwrite_email` is **offered** only when all of these hold:\n\n- the speaker may have it and turned it on — read fresh every turn, so turning it off applies from the next message;\n- the speaker is on a surface that verified it is them — the principal through `people_tools.is_principal_on_verified_surface`, a team member through `teammate_on_verified_surface` (the web app signed in, their own Slack or Discord, never an email turn) — and a web turn also carried a signed-in caller (`Session.web_caller_signed_in`, set from `x-caller-email`) or runs under local login — a request with no caller header is not a sign-in and never gets it (whoever holds the shared secret is trusted as the UI proxy that stamps that header, as on every principal-only route);\n- the conversation is private to the speaker: the web chat, a Slack or Discord DM, or a verified private Telegram chat — never a shared channel or thread, where the draft's preview or the matching threads would be posted for everyone and other people's messages sit in the model's context;\n- the turn is neither unattended (the scheduler's proactive run) nor private to the principal (the email poller's turns), so inbound text can never reach it. The MCP server, workflows, reflection and research never carry it at all.\n\nThe mailbox connection is deliberately **not** part of the offer: the handler checks it on every call and says how to fix it, so the cached tool prefix never flips when a token lapses. The pin lives in a context variable for the turn's task as well as on the session, so two turns running at once on one session (a second browser tab) each read their own. It also carries the speaker's own words for the turn (a new email may go to an address they just typed — the turn's message joins the history only once the turn ends), a per-turn draft count, and `touched_mail` (see Privacy). `own_words` reads those words back for every own-words check (addresses here, facts and task assignments elsewhere): it first removes the hydrated `<outbound_reply_context>` backstory by its exact, anchored shape, so a look-alike closing tag quoted inside it cannot pass the rest off as the speaker's, then drops other adapter tag blocks, and returns nothing for a message carrying an attachment.\n\n## The tool: `ghostwrite_email`\n\nIt lives in its own registry (`orchestrator.delegation_tools.DELEGATION_TOOLS` / `DELEGATION_TOOL_HANDLERS`), **never** `_ALL_SKILL_TOOLS`, so no other toolkit can carry it. On a turn it is offered to, the agent loop adds it to the pool *before* the sort and builds that turn's handler map from both registries; on any other turn a call to it is an unknown tool. The handler re-checks the pin and the surface anyway, then:\n\n1. **Caps** — at most 5 drafts per turn, and `DELEGATION_MAX_DRAFTS_PER_DAY` (default 50, at most 1000) per person per UTC day, shared with the inbox watcher (`delegation.caps`). It is counted from `delegation_drafts`, one row of ids per draft saved from either place, with a count kept in the process as a floor in case a row was lost. Each slot is taken before the first await — a round's tool calls run concurrently, so otherwise every call in it would pass the caps before any counted — and handed back if nothing was drafted. If the rows can't be read it refuses rather than guess.\n2. **Marks the turn** — sets `TurnDelegation.touched_mail` *before* its first read of the mailbox.\n3. **Checks the mailbox** — `gmail_status` asks Google or Microsoft whose mailbox the credential opens and compares it with the person's People email, on every call: a roster email can change, and a client slot swaps the roster.\n4. **Finds the thread** — by `thread_id` (checked against the mailbox's own id shape), or a Gmail-style search (`find`; on Outlook, words, `from:`, `to:`, `cc:`, `subject:` and `newer_than:` are kept and other Gmail operators dropped). Several matches return `{status: \"choose\", candidates}` (subject, sender and date — no message text) and draft nothing; none returns `not_found`.\n5. **Sets the recipients in code**, never from the model. A reply goes to the last inbound message's `From` — never its `Reply-To` (a different one is flagged `reply_to_ignored`) — with the thread's other recipients only on `reply_all`. A new email or a forward may go to any well-formed address: it is only a draft, waiting in their own mailbox, where they see who it is to before they send it. An address that is neither on the roster (contacts only when `contacts_reachable_now()`) nor typed by the speaker this turn comes back in `not_in_people`, and the Executive names it for them to check (`delegation_tools.not_in_people`). Mailing-list mail, a thread they replied to last and a reply-all trimmed to 10 recipients are flagged. An address inside a block an adapter added to their message (the backstory hydrated into a DM) is not one they typed, and when the message carries an attachment — a document's inlined text, or a note naming the file — none of its addresses count as typed: neither has an end mark, and a filename is chosen by whoever sent the file, so such an address is named back to check.\n6. **Writes it** (the ghostwriter, below) and saves it with the mailbox client's `create_draft` (Gmail: threaded with `In-Reply-To`, `References` (whole message ids: when the chain is too long for one header the oldest after the thread's first go, never the parent) and `threadId`, and stamped `X-OE-Ghostwritten`; Outlook: Graph's `createReply` on the message it answers, then the text and recipients, and a named property marking it).\n\nThe result is `{status: \"drafted\", draft_id, gmail_link, to, cc, subject, preview, flags, open_questions, note}`, plus `not_in_people` and `check_address` when a recipient needs checking. The link (`gmail.mailbox_link`) is built server-side from a fixed prefix — the thread in Gmail, the draft itself in Outlook on the web — and the note tells the model the preview is the person's draft, to be treated as data. The chat shows an action chip — \"Drafted an email as you to … — in your Drafts\" — that opens it, and only a link under `MAILBOX_LINK_PREFIXES` is ever linked. A sincere \"are you an AI?\" in the thread comes back as an open question for the person to answer themselves.\n\n## Reading their mailbox\n\nFive read-only mail tools ride with `ghostwrite_email` in the same registry (`orchestrator.mail_read_tools`), so they are offered, re-checked and fenced exactly as it is: `search_my_email` (a Gmail-style search through the client's `search_threads`, or with no query the threads that reached their inbox in the last few days through `inbox_message_ids` + `get_message`), `read_my_email` (one thread's last 10 messages, each sender's new text only, drafts left out, with the files attached to them listed by message id and index), `read_my_email_attachment` (one of those files as text: PDF, Word, Excel, CSV or text, up to 20 MB, a scanned PDF converted) and `my_email_awaiting_reply` (their own sent mail from the last 14 days, to at most 10 people besides the Executive, that is still the last message in its thread). They change, label, draft and send nothing.\n\nThe fifth, `my_email_read_before`, lists the threads `read_my_email` opened for the same person before, in this conversation or an earlier one, so a later conversation can open the same email again instead of asking them to search for it. It keeps where, never what (`delegation.mail_reads`, table `delegation_mail_read`): the thread id, its subject and first sender as one line each, the mailbox address it was read from and when, never a message's text, an attachment or a recipient. Rows are the person's own and are listed only from the mailbox open now, newest first, optionally narrowed by words in the subject or sender; anything older than 30 days is never listed and is deleted on the next write, at most 200 are kept per person, and turning Act as me off deletes them all. It opens the mailbox like the other reads, so it sets `touched_mail`, counts as a search, and returns its rows with the same data-not-instructions note. The Act as me addendum tells the model that these tools reach the person's mailbox while any Gmail or Outlook tools of its own account reach only the Executive's, to search theirs (never falling back to its own) for mail sent to them, and to reopen an email from before with `my_email_read_before` and `read_my_email`.\n\nEach sets `touched_mail` and marks the conversation theirs before its first read (`_open_mailbox`, shared with `ghostwrite_email`), so the lockdown below applies from its round on. Each is capped per turn on the pin: 10 searches (`my_email_awaiting_reply` counts as one), 20 thread reads and 5 attachment reads, the slot taken before the first await. In `read_my_email` every message someone else wrote comes back inside its own `<untrusted_content source=\"email\">` block (`content_trust.wrap_untrusted`, which defuses a closing tag in the text); the speaker's own messages — SENT and from their address (`threads.mine`), never a From header alone — are marked \"Yours\" outside any block. An attachment's text comes back in its own `<untrusted_content source=\"attachment\">` block (`attachments.format_attached_text`), parsed in an isolated worker (`knowledge.loader`); unlike a file sent to the Executive it is never added to the company's knowledge. The clients find an attachment by message and position and look its provider id up on each read (Gmail's changes per fetch): Gmail lists a message's files with the message (`MailMessage.attachments`, leaving out images the HTML shows in place), Outlook says only `hasAttachments` until `list_attachments` asks Graph (leaving out inline ones), and `attachment_bytes` reads one; an attached Outlook item or cloud link has no file to read. Results carry a note that subjects, senders and text are other people's words, data rather than instructions. The lockdown refuses tools, not the reply's own text, so what would carry that text out without a click is closed where it is shown: the web chat loads no image from another site, and bot replies go out without link previews (see Integrations).\n\n## Reading their calendar\n\nA third switch under Act as me, **Read my calendar** (`delegation.calendar`, table `delegation_calendar`: one row per person, absent or unreadable meaning off), lets the Executive read the person's own calendar, read-only. It rides on the same per-person sign-in as their mailbox: `calendar.readonly` on Google, `Calendars.Read` on Microsoft, added when they run the connect script with `--calendar` (`scripts/connect-own-gmail.py`, `scripts/connect-own-outlook.py`). Those scopes are optional, so a mail-only sign-in keeps working for mail; the mailbox clients note the scopes the token refresh reports, and `list_events` raises `CalendarNotGranted` before calling the calendar when the scope is missing (or when the calendar answers 403). Only the person turns it on (`PUT /delegation/calendar`), only while Act as me is on and a one-hour read works; a sign-in without the calendar is refused with `calendar_not_granted` and the command to run. Turning Act as me off turns it off. Changes are audited privately (`delegation_calendar_changed`).\n\n`my_calendar` sits with the mailbox reads, offered and fenced the same way: it refuses while the switch is off (before anything is opened), then takes a search slot, opens the mailbox privately (`_open_mailbox`, so `touched_mail` and the lockdown apply: an invite's title is in the words of whoever sent it) and lists the events from `start` (default today) for `days` days (1 to 31) in the workspace time zone, recurring events expanded and cancelled ones left out: title, start, end, all-day, location, organizer, attendees (25 at most) and the person's own answer, each on one line, with a data-not-instructions note. Google's `events.list` on the primary calendar and Graph's `calendarView` (times asked for in UTC) are its only calls; it changes nothing and keeps nothing. The first week's brief also lists today's meetings from it on the principal's own delivery (see Today).\n\n## Forwarding and reminders\n\n`ghostwrite_email` also forwards: with `forward` (a thread id) and `to`, it drafts a forward of the thread's latest message, or of the earlier one `forward_message_id` names (the one with the files, say, when their own reply came after it), `intent` becoming the short note above it (the ghostwriter writes only the note; the forwarded email's subject, someone else's words, is never put in the intent). Recipients follow the new-email rule (`_new_recipients`: the roster, or addresses the speaker typed this turn). Gmail's draft quotes a forward header and the original's own words under the note and attaches the original's files, up to 10 and 20 MB (`FORWARD_MAX_FILES`, `FORWARD_MAX_BYTES`; any left off are flagged `attachments_left_off`); Outlook uses Graph's `createForward`, which keeps the original and its files, with the note as its comment and the body never patched. It is still only a draft.\n\n`remind_me(text, when)` (`orchestrator.reminder_tools`) rides with the same tools and checks, but opens no mailbox, so it never marks or locks a turn (`MAILBOX_TOOL_NAMES` are the ones that do). It stores the text once cleaned — one line, anything a chat app could turn into a link (a URL of any scheme, an address, a domain-like word, a host and port, an IP address) replaced with \"[link]\", at most 300 characters — with its time (stored in UTC) in `delegation_reminders` (5 a turn, 25 waiting, a year ahead, refused when the person has no channel). When it is due the scheduler sends that text to the person alone, as \"Reminder you set on <date>: …\", running nothing (see Scheduler); the Slack and Discord DMs it may go by turn link previews off. The chat chip shows the text as it will be sent. A reminder that comes due in the person's quiet hours or leave (when `OUTBOUND_RESPECT_QUIET_HOURS` is on) waits unclaimed and goes once they end, rather than being suppressed and lost. It is allowed after mail is read and in later turns of that conversation: it reaches only the speaker, as plain text. `schedule_followup`, which runs a turn with tools and is listed to everyone, stays refused there.\n\n## Approval cards\n\nA turn that read someone's mail may not message anyone, invite anyone or change the roster (see the lockdown above), yet what the mail asks for is often right. `propose_actions` (`orchestrator.action_card_tools`) leaves the speaker a card instead: up to five actions, each spelled out exactly as it will happen, done only when they tap Approve. It rides with the other Act as me tools and checks (`_writer`), opens no mailbox, and is allowed after mail is read because it does nothing on the turn.\n\n- **Kinds.** `invite` (a meeting with people on the roster), `message` (a direct message to someone on the roster, as written) and `add_contact` (a new contact; the principal's cards only, since contacts are theirs). A team member's card can't name a contact. Each action is checked when the card is made (`delegation.action_cards.check`) and again when it is carried out, so an archived person or a time that has passed fails that action alone.\n- **Whose.** A card is a `delegation_actions` decision for the speaker, `approver_only` like a reply card: only they see it (`GET /delegation/actions`) or resolve it, a team member's answers 404 to the principal too, and it is never an alert. The same actions still waiting are that card, not a new one. 3 cards a turn, 25 waiting, dropped after 7 days.\n- **Approve.** In the chat, under the reply that left it (the `propose_actions` chip carries the card's `decision_id`, and `ChatActionCards` shows the card while it waits), and on the Briefing's Needs you list, with a box per action. Approve (`POST /decisions/{id}/approve`, `edits.only`) needs the card's person signed in (`verified.caller_refusal`) with Act as me on; the card is claimed first so it runs once, then each ticked action runs as stored with no model call, in an unattended session (the principal's with contact egress) under `rows_for_person`, so every audit row it writes is theirs and nothing reaches the team's activity rail: `message_person` (a direct message or nothing; never its Briefing-alert fallback, which more people read), `create_calendar_event`, or a contact row. Approving also needs the person still allowed Act as me (`can_delegate`) and switched on. An invite is booked straight away when the person approving is the one the meeting gate would ask (`calendar_tools.approved_by`), and otherwise goes to that approver as usual, so a card never widens anyone's authority. Per-action results (`done`, `waiting`, `failed`, `skipped`) are kept on the decision and shown on the card. Dismiss rejects it and does nothing else. With Suggested actions in training the card adds Approve + allow, and a card of actions all allowed is carried out on its own (see In training above).\n- **Channels.** A card can come from any surface Act as me runs on; it is approved in the web app, since the chat apps have no buttons here.\n\n## The ghostwriter\n\n`delegation.ghostwriter.compose` writes the text. The Executive decides *what* to say (`intent`); this call decides *how* the person would say it, and it is deliberately small:\n\n- a constant `GHOSTWRITER_PROMPT` plus the person's voice block as the system prompt;\n- the thread (each message cut to its sender's own words, every line scrubbed, all labelled alike), then the writer's own earlier words in it (`<writer_said>`, from their sent mail only), the intent and the recipients' names in the user turn — no company profile, memory or roster;\n- with Always in the loop on, `<writer_noted>`: what the writer's own notes say they told these same people in earlier Act as me replies (`memory.history_drafts.notes_for_draft`: only notes from mail **every** recipient of the new draft was on, so nothing told to one person reaches another; chat notes name no recipient and never qualify; at most 8, newest first, the person's own words or their correction, with dates). The prompt's rule 6 makes it a consistency check, never content: a draft that contradicts it is still written as the intent says, and the conflict becomes an open question on the card, which only the writer sees. Both the chat tool and the inbox watcher pass it;\n- **no tools** but the forced `compose_reply` return, so text in the thread can ask for anything and there is nothing to do it with.\n\nIt is not a Council agent — the Council's edit routes have no principal check — and runs on `DELEGATION_COMPOSER_MODEL` (default: the default model), logged as `ghostwriter` usage. `lint` then runs in code on what comes back: a link or an email address survives only if it appears in the intent, the signature or the recipients, so a link planted in the thread is removed and flagged; the Executive's own name is flagged; and the body is capped, cut at a paragraph, line or word break in its last fifth. A draft with nothing left after that is refused. The signature from the person's Gmail settings (or the one already stored, for Outlook) is appended.\n\n## How I write\n\n`delegation.voice` learns how a person writes *their own* email (`attunement.style` learns how the Executive should write *to* someone). `POST /delegation/voice/learn` reads up to 40 recent sent messages, keeps only what they wrote (quoted replies stripped with the email poller's `sender_new_text`), skips automatic mail, every thread chat drafted into, and every sent message that began as a draft written for them (`delegation_drafts.sent_message_id`), and makes one forced-tool call (`record_voice_profile`). Code validates every field before it is stored:\n\n- greetings per audience (their team, their contacts, anyone else), a sign-off of at most two lines, and a usual length and tone (a backslash-n the model wrote instead of a line break is read as one, keeping the first lines that fit, which also repairs a profile stored before that rule);\n- up to 8 habits and 6 things to avoid, through the same deny-list as working-style rules — no actions, links, handles, amounts, tool names or names of people; the conversation review (`memory.chat_review`) adds one when the person states how they write in a chat (`add_conversation_rule`, `updated_by=conversation`; never on a locked or full list, and an edit or lock made meanwhile wins);\n- up to 3 short exemplars, each checked to be verbatim from a sample, with addresses and phone numbers masked — and none while a client slot is active, so one client's mail never lands in another's state.\n\nThe signature comes from Gmail's `sendAs` settings, not the model (Outlook gives apps no way to read one, so a learn keeps the stored signature and `POST /delegation/voice/signature` answers 409 `signature_unavailable` rather than clearing it), as plain text with its lines kept (`gmail.html_to_text`: a `<br>` always ends a line, and a block tag, opening or closing, ends one when it has text, so Gmail's layout of a first line followed by one `<div>` per line comes out line by line). `POST /delegation/voice/signature` reads it again without relearning: nothing else changes and a locked profile stays locked, so it picks up a changed Gmail signature and undoes **Don't add my signature**. A person can also describe their style in their own words: `POST /delegation/voice/describe` applies the description to the profile they have through the same forced tool (a separate system prompt, no exemplars) and the same validation, keeps their signature and writing examples, and returns the result with a short sample reply for them to review. It saves nothing and needs no mailbox; Save stores it as an ordinary edit. The person can edit the profile, lock it (a locked profile is never relearned) and reset it, and every change is kept in `delegation_voice_history`. One learn runs at a time per person, and a lock or an edit made while it runs wins: the learned profile is dropped (`changed`).\n\n## Draft replies to my inbox\n\nA second switch under Act as me, **Draft replies to my inbox** (`delegation.inbox`), has the Executive watch the person's own inbox and write a first reply to mail that needs them. The reply waits on a private card on Today; nothing is sent until they tap **Send** (below). Where the reply lives is the person's choice, **Also save replies in my Gmail Drafts** (`mailbox_drafts`, off by default): off, it lives on the card alone (`delegation.card_drafts`: the card keeps the draft's recipients, subject and thread headers as `draft_spec`, and Send makes the mailbox draft from exactly that just before the send-time checks, taking it back out if they refuse), so their Drafts folder doesn't fill with replies they may never send; on, it is also saved in their Drafts as before. The switch is one row per person in `delegation_inbox_watch`. Turning it on needs Act as me on and their mailbox connected, and sets `watch_since` to now every time, so it never drafts for mail that arrived before; turning Act as me off turns it off too. Off means no mailbox call and no row written, with one exception: a send the person started that the mailbox never confirmed is still followed through until it is settled.\n\n### When it looks\n\nA throttled hook in the scheduler tick (`_maybe_scan_inbox`, after the pause, company-profile and rotation gates) checks each person whose switch is on every `DELEGATION_INBOX_POLL_MINUTES` (default 5). It is not a scheduled action, because those are listed on `/scheduled` for everyone and anyone may cancel them. One scan task runs at a time, one scan per person, and none while a client slot is active. **Check now** on the Settings card runs the same scan. Every row a scan writes is private and the person's own (`audit.rows_for_person`: a team member's rows are hidden from the principal too, see Privacy), and the process log carries counts and codes, never an address or a line of mail. The scan never marks mail read or changes a label.\n\n### What it drafts for\n\nA scan first settles the open cards (below), and stops with `backlog_full` once 25 are waiting, counting the ones it makes. It then lists the inbox since `watch_since` (`inbox_message_ids`) — not chats, not mail from the person, and not the promotions, social, updates or forums tabs (on Outlook: the Focused inbox only) — up to 100 messages, and takes the newest message of each thread that still needs a look, at most 10: settled threads and threads with an open card are passed over first, so a burst of mail, or a pause for a limit or a back-off, never hides older threads for good. `delegation_inbox_messages` is its durable cursor: one row per message (`UNIQUE(person_id, message_id)`) with what happened to it, the reason, how many tries it took, and the draft and card ids. It stores a hash of the sender's address, never the address. A message is skipped, with the reason recorded, when:\n\n- it came before `watch_since`, or more than three days ago;\n- it is from the person or one of their send-as addresses, from the Executive, or one of this module's own drafts;\n- it is automatic — `Auto-Submitted`, a bulk or auto-reply `Precedence`, a bounce, a calendar invite or a no-reply sender — or from a mailing list, or in a Gmail tab, spam or trash;\n- the person is not in To or Cc, or it has more than 10 recipients;\n- the person replied last, or a draft already sits in the thread.\n\nThree kinds are left unrecorded, so a later scan looks again: mail under 10 minutes old (mail the person answers straight away never gets a card), mail in a thread whose card is still open, and mail a daily limit holds back.\n\n### Deciding, then writing\n\nTwo model calls, and code decides between them. The classifier (`delegation.inbox_classifier`) is one forced-tool call, `classify_email`, returning whether the email needs a personal reply, what kind it is and how sure it is. It sees a few one-lined header lines and the sender's own new words (at most 3000 characters, every line scrubbed) inside one `<email>` block marked as data, and it has no other tools, context or memory, so an email can ask for anything and there is nothing to do it with. A reply is drafted only for a question, a request, scheduling, an introduction or a follow-up, and only when the confidence clears a bar that rises the less the sender is known: 0.6 for their team or a contact (the principal's contacts count only for the principal: a team member's mail is weighed by the team and their own sent mail), 0.7 for someone they have written to before (`has_written_to`, a search of their sent mail), 0.85 for a stranger. Pitches, notes of thanks, FYIs, notifications, newsletters and phishing get nothing, and so does any failure. An email that also went to other people is drafted for only when the person is in To and it asks them themselves: the classifier is told their name, whether they are in To or Cc and how many others it went to, and lists the names the email greets or asks by name (`asked_names`). Code matches those against the person's name, whole name parts only (\"Alexis\" never counts for \"Alex\", and a nickname misses, which means no draft), so mail that greets someone else (\"Good morning, Brennan, could you sign ...\") is never theirs, whatever the model makes of it as a whole. When it names nobody, the model's `asked_of_them` decides, false for a question to the group at large. One that only copies them is never drafted for. Either is recorded `not_needed` with the reason `asks_someone_else`. It runs on `DELEGATION_CLASSIFIER_MODEL`, else the routing model. A sender whose address Gmail couldn't authenticate is handled as a stranger whatever the roster says — anyone can put a colleague's or a client's address in From — so they get the stranger's bar, a holding reply and the stranger limits; the card still says who they claim to be, and that the address isn't verified.\n\nThe reply is written by the same ghostwriter, in the person's voice, but from a fixed intent the module builds rather than words the person typed. Because the intent lets it restate the person's own earlier words, which words are theirs is never written inside the thread, where a sender could imitate any marker with a look-alike: every message there is labelled alike, and the person's own words come in a separate `<writer_said>` block after the thread, taken only from mail their own mailbox sent. Nothing inside the thread can close the thread block or open another. The intent: acknowledge the sender; say again only what the person's *own* earlier messages in the thread already said; commit to nothing new — no yes or no, date, time, price, fact or promise — and say they will get back to them; and put every question it could not answer from their words in **open questions**. A stranger always gets a short holding reply. The lint still strips any link or address that isn't the person's own. The reply goes to the sender (never `Reply-To`) and, on a group email, to everyone else it went to as Cc (reply to all, never the person's own addresses or the Executive); a stranger's holding reply goes to the sender alone. The card says when others were on the email, and its `draft_to` lists everyone, which Send checks.\n\nThe order: record the message, classify, reserve a slot in the shared daily limit, write, save the draft in Gmail (from the alias the mail went to, when it went to one) and store its id, then create the card (idempotent on the message) and mark it drafted. Nothing that fails along the way loses the message. A failure that may pass — the classifier or the writer failing, Gmail refusing the draft, a card that couldn't be made (its draft is deleted first, so no draft is left without a card), any other error with that one message — leaves it for a later scan (`retry`), and it is given up on only after three tries; one message's trouble never holds up the rest. A daily limit reached while it was being read leaves it for later without counting as a try.\n\n### The reply cards\n\nA card is a `delegation_reply` decision whose class is **its approver's alone** (`DecisionClassSpec.approver_only`): only the person it was drafted for sees or resolves it on any decisions route — a team member's card answers 404 to the principal too — and it is never an alert: alerts feed chat turns, which would put other people's mail into memory. It carries the sender with who they are to the person and whether Gmail could verify the address (SPF/DKIM/DMARC, through `fact_confirmation.headers_authenticated`), the subject, what they wrote, the draft, the open questions and its warnings. `GET /delegation/replies` lists the open ones from the database alone, so Today never waits on Google.\n\n- **Send** approves the card, which sends its draft exactly as it is in their mailbox (see *Send on your tap*). **Edit** changes the reply's words right on the card (`PUT /delegation/replies/{id}/text`, `card_drafts.edit`): only its own person, from a caller the API can tie to them (as for Send), never while it is being sent on its own; a reply in their Drafts is rewritten there too (`update_draft_text`, every header kept), and only while it is still the version the card last saw, so a change made in the mailbox is never overwritten. A card edit counts as edited (`approved_with_edit`, and **Do it like this next time** keeps it). **Open in Gmail** (or **Open in Outlook**), shown only when the reply is in their Drafts, opens it there.\n- **Dismiss** rejects the card; the class's after-reject step then deletes the draft if nobody edited it — its message id is still the one it was saved with, since Gmail gives an edited draft a new one, and the Outlook client makes a draft's message id `<id>.<changeKey>` so an edit there changes it too — and keeps it otherwise. What happened is recorded even when Gmail fails.\n- Each scan first **settles** what Gmail already settled: a draft sent from Gmail, a draft deleted there, a reply the person wrote themselves, a thread that is gone, or a card left for 7 days (its draft stays in Gmail). Each is a compare-and-set close with the reason. A newer message from someone else flags the card instead. A card being sent at that moment is left alone.\n\n### Send on your tap\n\n`delegation.reply_send` is the only thing in Act as me that sends, and all it can send is the draft on a card, by its id: `DelegateGmail.send_draft` posts `{\"id\": …}` to Gmail's `drafts.send`, and `DelegateOutlook.send_draft` posts an empty body to that draft's Graph `send`, and nothing else, so no text, recipient or header is ever passed. It has two doors: `send_approved_reply`, reached only from `POST /decisions/{id}/approve` — a class only the card's own person may resolve — and `send_on_its_own`, reached only from the inbox watcher under Handle it for me (below). AST tests pin both call sites, so no model, chat turn, workflow, scheduled job or MCP call can. A tap is checked like this: At send time it checks everything again:\n\n1. **Who is asking.** The caller is the card's person and the API knows it: signed callers are on and the request carries that person's signed assertion (or the operator's, under local login), or the API runs for local login and answers this computer only. Anything else is a 409 `caller_signing_required` — with only the shared secret, whoever holds it could send as the owner — so on a server Send needs signed sign-ins.\n2. **The switches.** Act as me and Draft replies to my inbox are on, and no client slot is active.\n3. **The mailbox.** Their mailbox is connected.\n4. **The draft.** It still exists, in the same thread, and they haven't replied there themselves since; otherwise the card closes.\n5. **Who it goes to.** To, Cc and Bcc hold between 1 and 10 addresses, never the Executive's own, and it is from one of their own addresses.\n6. **What changed.** Recipients that differ from the card's, or a newer message from someone else, need a second yes: the first tap gets a 409 `confirm` naming the recipients and the reason, and the person approves again with what they were shown.\n\nThen it claims the card (`claim_for_execution`, proposed → executing, a compare-and-set, so a double tap sends once) and reads the draft once more: `drafts.send` sends whatever the draft is when Gmail gets the request, so if it was edited since the checks read it — in another tab, by a delegate — nothing is sent and the card comes back (`draft_changed`). Then it sends, and records the result: `approved_with_edit` when the draft was edited in Gmail, the sent message's id, the draft row's `sent_message_id`, and a private `delegation_reply_sent` row. A refusal that proves nothing went — a 4xx, a lapsed sign-in, a rate limit, a draft already gone — hands the card back. A failure that leaves it unclear — a timeout, a 5xx — leaves it `executing` and says to check the Sent folder, and the next scans ask Gmail: their message in the thread means it was sent; anything else is judged on the second scan that sees it: the draft still there and nothing sent means it was not (Gmail deletes a draft it sends), and the card comes back, flagged; the draft gone and nothing sent means it was deleted. Nothing is ever retried on its own. Sending is the person's own act, so it works while the Executive is paused.\n\n### Limits and failures\n\nAt most 5 drafts a scan; `DELEGATION_INBOX_MAX_DRAFTS_PER_DAY` (default 20) a day, inside the shared `DELEGATION_MAX_DRAFTS_PER_DAY` it shares with chat; 200 classifications, 2 drafts per sender (1 for a stranger) and 10 for strangers in all per day; and never more than 25 open cards. A lapsed Gmail sign-in sets the status and is looked at again every 30 minutes; a rate limit, an error reaching Gmail or a crash backs off from 5 minutes, doubling up to 2 hours. Neither turns the switch off: the Settings card shows the status in plain words.\n\n## Handle it for me\n\nA third switch under Act as me, **Handle it for me** (`delegation.handle_it`), lets the inbox watcher send some of its replies itself instead of leaving them on a card. It is one row per person in `delegation_handle_it` (`enabled`, `mode`); no row means off. One setting says how much goes without them, the way quality does on the Agent Council (`handle_it.RULES`): **Easy ones** (`careful`) sends only replies to people they know (someone on their team, a contact or someone they have written to) of at most 400 characters when the classifier is at least 0.9 sure; **People I know** (`balanced`), where it starts, sends replies to people they know up to 1200 characters at 0.8; **Most mail** (`bold`) also answers strangers, up to 2000 characters, and lets a link or an amount through when the classifier is at least 0.9 sure. Everything else waits on a card as before, so turning it on never drafts less. A table from before the setting gets the `mode` column on its next open (`schema._add_handle_it_mode`): someone who had strangers set to send keeps that as Bold, everyone else gets Balanced. Only the person turns it on (`PUT /delegation/handle-it`), from a session the API knows is theirs: the same rule Send uses (`delegation.verified.caller_refusal`), so with only the shared secret it answers 409 `caller_signing_required`. Turning it on needs Act as me and Draft replies to my inbox on, and turning the inbox watcher off (or Act as me, which turns it off) turns it off too.\n\n**In training** (`delegation.training`). Like someone new, each Act as me job can be put in training on its own, from that job's card on the Act as me page, the way Take the lead has it: **Write drafts as me** and **Handle it for me** each pick Off / In training / On (Handle it's In training is Replies in training, with a *Train follow-ups too* box for Follow-ups), and **Suggested actions** picks Always ask / In training; one *What it's learned* list sits at the bottom, each item named by its job (`PUT /delegation/training`, one row per person and setting in `delegation_training`, absent means not in training). In training it asks first and learns who and how from what the person approves; what it learns is a `take_the_lead_allowed` row (feature `act_as_me`, the person's id), theirs alone.\n\n- **Replies.** Every reply waits on its card (`handle_it_reason` `training`) whatever the dial says, and a reply card adds **Send + allow**: it sends that reply on the person's own tap, exactly as Send does, then allows replies to that sender (key `act_as_me|person:<id>|reply|<address>`). While Handle it for me is on, a reply to an allowed sender goes on its own under the dial's limits (a stranger they allowed included) and every check above (the topics that always wait, links and amounts, new recipients, once a thread a day, the daily limit); it's checked again at send time, so a sender removed since waits. Take the lead as you lifts nothing in training: putting Replies or Follow-ups in training turns it off, and it can't be turned on while they are (409 `in_training`).\n- **Follow-ups.** Every follow-up waits (`follow_up_training`); Send + allow on a follow-up card allows follow-ups to exactly the people it went to (`…|follow_up|<sorted addresses>`), whoever they are, under every other follow-up check.\n- **Suggested actions.** An action card (below) adds **Approve + allow**: it does the actions on the tap, then allows each one that happened (a message to that person, `…|message|person:<id>`; a meeting with exactly those people, the person left out, `…|invite|people:<ids>`). A new contact is never allowed. A card proposed later whose every action is allowed is carried out at once, with no tap (`action_cards.run_on_its_own`, `gate_mode` `auto_execute`, status `executed`), only if plain code finds nothing against it (`on_its_own_refusal`): still in training, Act as me on, a server that ties the switch to the person, nothing sensitive, no link or amount, a message of at most 1200 characters, and at most 10 actions carried out this way a day (checked one card at a time); anything refused is handed back to wait on its card as before. An invite carried out this way is never booked as approved by the person: the meeting gate decides as for any meeting nobody tapped, so a time taken from someone's mail can't land on a calendar unasked. The tool result and chip say what was done. The message text in such an action is model-written from the mail and goes without anyone reading it; the allowance covers who and what kind, not the words, which is why sensitive topics, links, amounts and long messages are held back.\n- **Drafts.** Nothing is sent. When the person changes a reply's draft in their mailbox before tapping Send (plain or + allow) and ticks **Do it like this next time**, what they sent is kept (its new text, quoted replies dropped, at most 1000 characters, `…|style|<address>`), and the ghostwriter gets it in its user turn as `<writer_example>` when it next writes to that person, from the inbox, a follow-up or a chat draft to that one person: style only, never its facts, and nothing in it can open or close a tag.\n\nSend + allow and Approve + allow are refused before anything is done unless their setting is in training (422 `cant_allow`) and the person's list has room (409 `learned_full`, at most 200 a person); allowing failing afterwards never undoes the send. Putting Replies or Follow-ups in, or Suggested actions out, of training only holds more back and works without signed sign-ins; anything else needs a caller the API knows is that person. What it learned is the person's alone: listed on `GET /delegation` (`training.learned`, each with its `setting`), removed with `DELETE /delegation/learned/{id}`, and for the owner also in Take the lead's \"What it's learned\" list; it never reaches anyone else's list or Take the lead's prompts. A dial left on In training by an older version (mode `training`) moves to People I know with Replies and Follow-ups in training (`schema._move_training_off_the_dial`).\n\n**No model decides whether a reply goes.** The watcher's two model calls are unchanged and tool-less, so text in an email can at most change the verdict and the draft. After the draft is written, `handle_it.refusal` — plain code — decides, and anything it refuses becomes the usual card with the reason kept on it (`handle_it_reason`). It refuses when:\n\n- it's off, or the sender is a stranger and the setting isn't Bold, or on a server signed sign-ins are off (`signing_ok`: signed callers, or local login);\n- Gmail couldn't authenticate the sender, whatever the roster says;\n- the email isn't a question, request, scheduling, introduction or follow-up, or the classifier was less sure than the setting needs (0.9 on Easy ones, 0.8 otherwise);\n- the reply goes to anyone the email didn't already go to (its From, To and Cc, less the person's own and the Executive's addresses), leaves out the sender, or goes to more than 10;\n- the email's subject, the sender's new words, or the reply touch money, contracts, legal, hiring, pay, layoffs, the board, investors, mergers, the press, health, or credentials and secrets (passwords, logins, tokens, API keys); or the reply carries an amount, a percentage or a link (a scheme, `www.`, a bare host with a path such as `bit.ly/…`, or a bare host on a common top-level domain) unless it's Bold and at least 0.9 sure, or runs over the setting's length (400, 1200 or 2000 characters);\n- the draft carries any flag but *others on the thread* or *Executive on the thread* (they asked if it's an AI, recipients were trimmed, …);\n- it already sent one in this thread in the last day, or the person's last message in the thread was itself sent on its own (no auto-reply ping-pong);\n- the day's limit is reached (`DELEGATION_HANDLE_IT_MAX_SENDS_PER_DAY`, default 20, within the watcher's drafts limit), or it can't be counted. Any error in the rules counts as a refusal.\n\nA reply the rules allow gets a card with `gate_mode` `auto_execute`, and the watcher sends it at once through `reply_send.send_on_its_own`, the second and last door into the send path (an AST test pins both callers: the approve route and the watcher). It runs the same send-time checks as a tap — switches, mailbox, draft, recipients, the claim and the last re-read — with no caller, and adds its own: the card must be `auto_execute`, Handle it for me still on with the setting still allowing that sender (or, for a follow-up, that recipient), signing still on, the once-a-thread-a-day rule and the daily limit counted again, and the draft untouched since it was saved (an edit in Gmail means the person has taken it over: `draft_changed`, the card waits for them). Every refusal hands the card back to the person (`decision_ledger.hand_back`, a compare-and-set to `propose`), with the reason kept on it when there are words for it, and a failure never stops the scan. Every card it left for the person says why on Today (`waited_because` on `GET /delegation/replies`). A reply sent on its own finishes as `executed` (not approved), is recorded in `delegation_handled` (for the per-thread and daily rules) and writes a private `delegation_reply_handled` row; an unconfirmed one is settled by the reconciler the same way. No History note is taken from it, since notes come only from the person's own words. It runs inside the watcher's scan, so it stops while the Executive is paused.\n\n**Follow-ups as you** (`delegation.follow_ups`). While Handle it for me is on, the watcher's scan also looks at the person's own sent mail, at most once an hour (`LOOK_EVERY`), for an email of theirs that asked something (a question mark in their own words), is 3 to 10 days old, went to at most 10 people other than the Executive, and is still the last message in its thread. Plain code picks it; each gets one follow-up ever (its `delegation_inbox_messages` row), at most two a look, within the drafts limit. The ghostwriter, tool-less as always, writes a short nudge in their voice from the thread, saved as a draft in that thread to exactly the people the email went to. `handle_it.follow_up_refusal` — plain code — decides whether it goes: by the setting it never goes on Easy ones, goes to their team and contacts on People I know and to anyone they wrote to on Most mail (`follow_up_refused` otherwise: `follow_up_level`); it also refuses on any change of recipients, a sensitive topic, an amount or a link, more than 600 characters, a flag, and the same per-thread and daily counts as replies. It goes through `send_on_its_own` on an ordinary `delegation_reply` card marked `source: follow_up`, which rechecks the setting for that recipient. A refused one waits on Today as **Follow-up waiting**, and closes by itself (its untouched draft deleted) when anyone answers in the thread first.\n\n**What it sent** is the person's alone: `GET /delegation/handled` lists the last 7 days (who, subject, the reply, the questions it left them and a link to the thread in their mailbox), and the Handle it for me tab shows it with how many went today, under a read-only line naming the step the dial is at.\n\n### Take the lead as you\n\nOn Settings → Act as me, Handle it for me is one dial: **Off**, **Easy ones**, **People I know**, **Most mail** and, for the owner, **Everything**, which uses **Take the lead** (`PUT /delegation/take-the-lead`, one row `person:<id>` in `take_the_lead`; turning it on turns Handle it for me on). While it is on, `handle_it.refusal` drops the setting's limits: strangers, the classifier's confidence, amounts, and the length up to a 4000-character ceiling. A reply with a link still waits for a tap (refusal `link`). In their place it checks the company's and the person's own added rules (`take_the_lead.reply_hit`, refusal `lead_rule`). Everything Handle it always keeps still holds: signed sign-ins, an authenticated sender, a reply kind, exactly the thread's people, the topics that always wait, draft flags, never twice in a row, one a thread a day and the daily limit. Follow-ups under it may go to anyone the person wrote to, with the same sensitive, amount, link and length checks plus the added rules. `reply_send.send_on_its_own` accepts the card while both switches are on. Each person adds and removes their own rules (`/delegation/take-the-lead/rules`). Removing one needs a caller the API can tie to them.\n\n\n## AI line on replies\n\nReplies written as a person can end with **\"Drafted and sent by my AI assistant.\"** (`delegation.disclosure.LINE`), by two switches that are each person's own (`PUT /delegation/disclosure`, one row per person in `delegation_disclosure`, NULL following the install): **Handle it**, on by default (`AI_DISCLOSURE_HANDLE_IT`), for a reply Handle it for me will send on its own, which nobody reads before it goes; and **Approved sends**, off by default (`AI_DISCLOSURE_APPROVED_SENDS`), for one that waits on a card for them to send, since they read it first. The line is written into the reply when it is drafted (`disclosure.sign`, in `inbox._consider` and `follow_ups`), once the plain-code checks have decided whether it goes on its own, so the card, the mailbox draft and what is sent are the same words and Send's draft-changed checks see them; a switch changed later applies to the next reply, and a reply drafted to go on its own that is handed back keeps its line for the person to edit. `AI_DISCLOSURE` off turns both off and hides the card. Turning a switch on only adds the line, so it needs no signed sign-in; turning one off does. Settings → Delegate → Act as me shows the card (**Replies sent from your mailbox**), and turning off the Handle it line asks first.\n\n## The mailbox client\n\n`delegation.gmail.DelegateGmail` talks to the Gmail REST API directly and is **never registered with the MCP gateway**, so the model reaches the mailbox only through the typed handler. The credential is one file per person in `DELEGATION_GOOGLE_CREDENTIALS_DIR`, named from a hash of the address (0600 in a 0700 directory), minted by `scripts/connect-own-gmail.py` on the Executive's own OAuth client with the scopes `gmail.readonly` and `gmail.compose`. It never lives in `WORKSPACE_MCP_CREDENTIALS_DIR`, where workspace-mcp picks a credential by address. Besides reading threads and saving drafts it lists the inbox and checks whether they have written to an address, reads one message or draft, lists the person's send-as addresses and deletes a draft. Its **one send method**, `send_draft`, sends an existing draft by its id and nothing else — never `messages.send`, which sends any text it is given — and unit tests pin the method set, the endpoint, the request body and its single caller. A failed request says whether it may have been carried out anyway (a timeout after connecting, a 5xx), which is what the send path needs to know. A parsed message carries when it arrived, whether it is bulk, a bounce or a calendar invite, and whether Gmail's authentication results vouch for its sender.\n\n`gmail_status` answers `connected`, `not_configured`, `needs_reconnect` (Google refused the saved sign-in — an app in Testing mode has its tokens expire after 7 days; a rate limit, though Gmail may send it as a 403, is an `error` to retry, not a reconnect), `mismatch`, `no_email`, `shared_mailbox` or `error`. `shared_mailbox` means the person's address *is* the Executive's; it is refused before asking Google, because then everything the Executive writes would look like theirs. The gateway closes the other door: every `google_workspace__*` call must act as the Executive's own account, and a `user_google_email` naming anyone else is refused and audited (see Integrations).\n\n### Outlook\n\nA person may connect an Outlook mailbox instead (work, school or personal), with `scripts/connect-own-outlook.py`: a device-code sign-in on the Executive's own Entra app (`MS365_MCP_CLIENT_ID`, tenant `MS365_MCP_TENANT_ID` or `common`) asking for `User.Read`, `Mail.ReadWrite`, `Mail.Send` and `offline_access`. It writes the same per-person file with `\"provider\": \"microsoft\"`, so a person has one mailbox for Act as me, and `gmail_for` hands back `delegation.outlook.DelegateOutlook`, which keeps `DelegateGmail`'s methods, return types and errors, so every caller above runs unchanged. It talks to Microsoft Graph directly, never through the Microsoft 365 MCP server the Executive's own Outlook uses, and is never registered with the gateway. Microsoft rotates the refresh token on use; the new one is written back into the file (atomically, keeping every other key, and only if the file still holds the old one). Graph is asked for immutable ids, so a sent draft keeps its id; a thread is Outlook's `conversationId`. Gmail's labels are mapped onto what the callers read: `SENT` only for mail in their Sent Items folder (a From line set to their address by someone else never counts), `DRAFT`, `INBOX`, and Focused Inbox's Other read as a tab. A sender counts as authenticated only when the topmost `Authentication-Results` — the one Exchange wrote, above anything the sender added — holds exactly one DMARC verdict, a pass for From's own domain, and Exchange Online Protection's own `compauth=` verdict, so a header the sender wrote on mail EOP never stamped doesn't count. `delete_draft` refuses anything that isn't a draft, and deletes with the draft's etag (`If-Match`), so a draft sent in between — it keeps its id — is left alone. No client secret is ever written into a person's file, and Graph has no signature setting to read.\n\n## Privacy\n\nWhat a person's mailbox touches is theirs. For the principal that means private to the principal, as every private row is. For a team member it means theirs alone, the principal included: an audit row carries `private_to_person` (set by `audit.rows_for_person` around the inbox watcher, a card's Send and Dismiss and their settings changes, and by `people_tools.audit_row_owner` on a turn that read their mail) and is left out of every audit read — the log, a session's timeline, a row by id, the brief — with only the usage totals counting it; their reply cards are theirs alone (above); and the owner's view of their use is counts only (drafts and sends in 30 days, and whether their inbox watcher is on). The conversation itself becomes its owner's alone before the mailbox is first read: `ghostwrite_email` marks the session `mail_private` (`session_store.mark_mail_private`, creating a channel adapter's row early, with its owner) and refuses to read the mailbox if that can't be stored or the conversation already belongs to someone else (which it then leaves unmarked); from then on only its owner may open it (`chat._session_access`), and working-style learning skips it. Every later turn there starts private (`settings.pin_turn_delegation` reads the flag and fails closed, setting `touched_mail`), so a follow-up answered from history alone is still private to its owner and teaches no memory, and the web chat's rows before the turn (the inbound message and the knowledge lookup) are theirs too. It does not start locked down: the lockdown is `read_mail`, set only by a turn that reads the mailbox or notes itself, and it is never carried into the next turn, because history keeps only the speaker's words and the Executive's replies, never the mail a tool returned. Their next message is them asking again, having read that reply, so everything runs again there. Anyone else speaking in it is not offered Act as me.\n\nOnce `touched_mail` is set, every audit row the turn writes is private (`people_tools.audit_row_private_to_principal`), and a team member's is theirs alone: the tool row (its input and result redacted, since `ghostwrite` is a sensitive tool name), the reply's `chat_turn` row that carries the preview, the model-call rows, and the background passes, which run under `private_rows`. The Honcho peer and department syncs are skipped, because peer memory is read on other people's turns. No memory is learned from the turn at all: the episodic, open-loop and working-style passes are skipped too, since its reply quotes a draft built from other people's mail. The `delegation_*` audit events are always private and carry metadata only — ids, counts and flags, never the draft or the thread. The inbox watcher is private the same way: every row a scan or a card action writes is its person's alone, and it starts no chat turn, alert, scheduled action or workflow run and teaches no memory.\n\nThe turn also keeps one door shut (`delegation.lockdown`). Anyone can put text in the inbox, and that text could try to steer the model, so from the round that calls `ghostwrite_email` or one of the mailbox reads — a round's tools run together — until the turn ends, the dispatch guard refuses only what opens the open internet or reaches everyone: outside fetches (`read_document`, research, the watchlist, `load_mcp_server`, and any MCP `call_tool` outside the private-turn set of reads and recipient-checked sends), `run_script` and `run_python_job`, workflows (they run later, unattended, and may fetch or script), broadcasts, department messages and alerts, and changes to who is on the roster or holds authority (`archive_person`, `set_department_head`, `resolve_roster_request`), and text that steers later turns (`schedule_followup`, whose intent runs unattended when due, and goals and decision outcomes, shown to every later turn). Everything else the person asks for runs, because it is fenced on its own: DMs and `message_person` reach only the roster, invites name attendees by person id, the Executive's own email checks every recipient against the roster, standing facts and profile edits keep only the person's own words, and a workflow drafted in chat is saved only once a person confirms it. `upsert_person` runs only for a contact the person asked for (`speaker_named_contact`: a contact, never the team, an approval scope or a chat account, with a word of the name in what they typed, in a message that asks to add, save or change someone, a new contact's address one they typed or one that sent the mail the turn read under the contact's name (`TurnDelegation.mail_senders`), never one the mail's text only mentions, and on an update a changed address they typed), since the roster is what the send checks trust. Any other contact add is refused with a pointer to an approval card (`lockdown.CONTACT_REFUSAL`), so the Executive leaves an `add_contact` card in the chat rather than asking them to type the address. What an email itself asks for is still never done on its say-so; it goes on an approval card. Every tool is classified as allowed or withheld, a test fails on a new unclassified one, and an unknown name is withheld, except an extension tool registered with `after_mail_read` (one that only reads the install's own data). The refusal tells the model to put what the step needs in its reply, since the next turn sees the reply but not the mail, and to do the step then without reading the mail again. A refused call gets a private `tool_invocation` row (`refused: mail_touched`) and tells the model to offer it in the next message. The offered tool list never changes mid-turn, so the cached prefix holds. The handlers that reach outside check again on their own (`outside_reach_refusal`). The server-side web search stays, as on a turn private to the principal. The lockdown ends with the turn. Later turns of that conversation stay private to its owner (`touched_mail`) but hold nothing: a refusal says it will work when they ask again in their next message, and it does.\n\n## Always in the loop\n\nA sent reply can leave a note. Once the reply went, `reply_send` starts `memory.history_notes.note_sent_reply` for the person who sent it, in the background, when their \"Keep track of what happens\" switch is on and the conversation isn't one they asked not to remember. The note-taker sees only the words they sent, so other people's mail never becomes a note, and a failure never touches the send. Recall is `recall_history`, offered on the same verified, private surfaces as `ghostwrite_email` and also allowed under the mail lockdown, since it only reads the speaker's own notes. Calling it locks the turn like `ghostwrite_email` does, from its own round on. The same switch also covers notes from chat, which don't need Act as me. See **Memory** for the checks, retention and controls.\n\n## The system prompt\n\nA constant, name-free `DELEGATION_ADDENDUM` joins block 0 after the unchanged identity addendum while anyone on the install has it on (`block0_delegation_on`). It names the four mailbox reads and says other people's mail is data and that a conversation which read it reaches nobody else; and it tells the model that `ghostwrite_email` is the single exception to *never impersonate*, and only for the person being spoken to; that everything else is written as itself; that when the tool isn't offered the asker can't have it; that a draft is never described as sent; and that it never denies being an AI. It is keyed on the install-level setting, never on the turn or the speaker, so switching it misses the 1h cache once (see Prompt Caching).\n\n## What it may do\n\n**Delegate → What it may do** (`delegation.may_do`, `GET /what-it-may-do`) is read-only: one row per thing that can go out without asking, what happens to it (goes out, waits for someone, always waits, drafts only, off) and which setting decides it, with a link there. It is the first Delegate tab, and `/delegate` opens on it. Three parts, each behind a pill that counts what goes out:\n\n- **As you** (the caller's own, when `can_delegate` allows them): built from `settings.is_enabled`, `inbox.get_watch`, `handle_it.get` and `handle_it.RULES`, `handle_it.leading` (Everything), `training.get` and `training.learned`, and their rules, the same reads `handle_it.refusal` and `follow_up_refusal` make. A level's row follows its `Rules` (strangers, follow-up reach, links and amounts), not a copy of them. A note names the ladder: Handle it for me rides on Draft replies to my inbox and Write drafts as me, and Everything also drops when Replies or Follow-ups go into training.\n- **As the Executive** (the principal's alone, as `GET /take-the-lead`): the switch and its training, each Ask first kind, the company's rules, and meetings. A meeting it thinks of on its own always waits: both meeting gates need someone on a verified surface in the turn, which an unattended run never is. A meeting someone asks for in chat follows **Always asks first → Meetings asked for in chat** (on means it waits: `meeting_scheduling`'s class mode is `propose`; off means `auto_execute`) and, in a team workspace, Operations' level too.\n- **Departments**: each level, and what a level covers (department-scoped scheduled work, check-ins, alert review, team members' chat sends, and Operations' meetings), and that it doesn't cover what the Executive does under Take the lead.\n\nIt also says when the Executive is paused, and when nothing can be sent as anyone because signed sign-ins are off. Nothing on it writes or reads mail. A contact, someone not on People, or a request with no caller (outside local login) gets 403.\n\n## How far it goes as you\n\nOne dial (`ReachCard`, on the Act as me tab only; Handle it for me shows which step it is at with a link to it, and What it may do links to it too) replaces the switches that used to turn each other off out of sight. Its steps, each adding to the one before: **Off**, **Drafts when I ask** (Write drafts as me), **Drafts for my inbox** (Draft replies to my inbox), then the Handle it for me steps that send, **Easy ones**, **People I know** and **Most mail** (`careful`, `balanced`, `bold`), and for the owner **Everything** (Take the lead as you). The first three are grouped as \"Writes as you, never sends\"; the rest as \"Handle it for me sends as you\". `PUT /delegation/reach` (`{step}`) moves it, and `reach_of` reads the step back from the switches, so the stored switches stay the source of truth and every gate reads them as before.\n\nGoing down turns the switches above the target off, highest first (`_lead_off`, then Handle it, then the inbox watcher, then Write drafts as me), so nothing is ever on above a switch that's off; the UI says what stops and asks before it saves. A lower sending level only holds more back and is set directly, so it needs no signed sign-in. Going up calls each switch's own route in order, so every check it makes still applies: the mailbox connected, signed sign-ins for sending, the owner alone and not in training for Everything. The first that refuses stops the move at a whole step and answers with that route's error. **In training** (Replies and Follow-ups together, with **Train follow-ups too** to split them) sits under the dial at the sending steps, and **Learn from my edits** (drafts training) beside it; the dial never changes training.\n\n## Surfaces\n\n- **Settings → Act as me** (`ActAsMeCard`, hidden unless `GET /delegation` answers, so a team member sees it once the owner lets them): the mailbox connection (`provider` says which) with both connect commands (Gmail and Outlook) and **Check again**, the **How far it goes as you** dial (below), the **Your inbox** status card while the inbox watcher is on (its status in plain words, when it last checked and **Check now**), and **How I write**: length and tone, a greeting per audience (`{first}` is their first name), the sign-off, habits and never-rules in fields that grow to show every line, the signature with **Refresh from Gmail** and **Don't add my signature** (or **Add my Gmail signature** when none is added; on Outlook only **Don't add my signature**, with why), and each example quoted with **Remove examples**. The owner also gets **Let team members use it** where the install allows it, with each team member who has it on listed by name and counts only.\n- **Today → Replies waiting** (`RepliesWaiting`, the top of the left column; hidden unless `GET /delegation/replies` answers with cards): each card shows who wrote and who they are to you, whether their address was verified, the subject, **They wrote** as plain text, your draft, **Decide before sending** (the open questions) and its warnings, with **Send** (a confirm naming who it goes to, and a second one when that or the thread changed), **Edit** (a text box on the card with Save and Cancel), **Open in Gmail** or **Open in Outlook** when the reply is in their Drafts, and **Dismiss**.\n- **Setup status**: a **Your own mailbox (Act as me)** light (`your_gmail`), amber while the inbox watcher can't reach the mailbox, is being rate-limited or has 25 replies waiting.\n- **Delegate** (main menu): **What it may do** (above, where `/delegate` lands), **Act as me** (where `/settings/act-as-me` lands), **Handle it for me** (which step the dial is at, with **Change in Act as me**, then **What it sent**: how many went today and what it sent this week, as you) and **Take the lead** (the switch, then **Always asks first**, shown even while the switch is off and ending in **Meetings asked for in chat**, and the company's rules, as the Executive). Each switch that turns another off says so beside it. The pause is on **Settings → Your Executive**.\n- **API**: `GET`/`PUT /delegation`, `GET`/`PUT`/`DELETE /delegation/voice`, `POST /delegation/voice/learn`, `POST /delegation/voice/describe`, `POST /delegation/voice/signature`, `PUT /delegation/inbox` (`{enabled?, mailbox_drafts?}`), `POST /delegation/inbox/check`, `GET /delegation/replies`, `PUT /delegation/replies/{id}/text`, `PUT /delegation/handle-it`, `PUT /delegation/reach` (`{step}`, the dial), `PUT /delegation/training`, `DELETE /delegation/learned/{id}` and `GET /delegation/handled` — the caller's own delegation only — and `PUT /delegation/team`, the owner's switch (see API Reference). `GET /what-it-may-do` is the read-only summary above. Send is `POST /decisions/{id}/approve`; Dismiss is `POST /decisions/{id}/reject`.\n- **Evals**: a scenario's `delegation:` block runs the turn against an in-memory mailbox (`evals.mailbox.ScenarioMailbox`) and hands the saved drafts to the judge (`delegation_001`–`003`). A `type: inbox` scenario runs the watcher's two model calls on one thread: whether it drafts must match the scenario, and a draft is judged on saying nothing the person hadn't, copying no link or address, and listing every open question (`delegation_inbox_001`–`007`; the last checks a draft never claims anything was sent).\n\nActing within rules the person sets and standing in for them are later, separate changes, each behind its own switch, off by default.",
+ "markdown": "The **delegation** module (`openexecutive.delegation`) is **Act as me**: the one place the Executive writes *as* a person instead of as itself. Everywhere else it has its own Google account and bots and signs as itself. Here — when the person asks, or, with a second switch, for mail in their inbox that needs them — it writes an email in their voice and saves it as a **draft in their own mailbox** — Gmail or Outlook — for them to review and send. The one thing it ever sends is one of those inbox drafts, exactly as it is in their mailbox: when the person taps **Send** on its card, or, with a third switch, **Handle it for me**, on its own when plain-code rules allow it (below); chat never sends. The principal can turn it on for themselves, and so can each team member once the owner lets them. It is off by default, and off changes nothing: the prompts, tool lists and prompt caches are byte-identical to an install without it.\n\n## Who can have it, and when it is offered\n\n`delegation.settings.can_delegate(person)` is the single rule for who may turn it on: the principal (a non-archived team member flagged `is_principal`), and any other non-archived team member — never a contact — once team members may have it (`team_members_enabled`). That takes two things: the install allows it (`DELEGATION_TEAM_MEMBERS`, default off, which offers the owner the switch) and the owner turned on **Let team members use it** (`PUT /delegation/team`, principal only, one row in `delegation_team`). Turning the owner's switch off takes it away from every team member from their next message, and their inbox watchers stop at their next check; their own switches, drafts and cards are kept. Everything is keyed by `person_id`. A person turns it on for themselves (`PUT /delegation`); nobody turns it on for anyone else. The setting is one row per person in `delegation_settings`, and a missing, unreadable or zero row all mean off.\n\nAt the start of every chat turn (`Executive.stream_chat` and the committee path) `pin_turn_delegation(session, speaker_text)` runs next to the workspace-mode pin and records a `TurnDelegation` on the session. `ghostwrite_email` is **offered** only when all of these hold:\n\n- the speaker may have it and turned it on — read fresh every turn, so turning it off applies from the next message;\n- the speaker is on a surface that verified it is them — the principal through `people_tools.is_principal_on_verified_surface`, a team member through `teammate_on_verified_surface` (the web app signed in, their own Slack or Discord, never an email turn) — and a web turn also carried a signed-in caller (`Session.web_caller_signed_in`, set from `x-caller-email`) or runs under local login — a request with no caller header is not a sign-in and never gets it (whoever holds the shared secret is trusted as the UI proxy that stamps that header, as on every principal-only route);\n- the conversation is private to the speaker: the web chat, a Slack or Discord DM, or a verified private Telegram chat — never a shared channel or thread, where the draft's preview or the matching threads would be posted for everyone and other people's messages sit in the model's context;\n- the turn is neither unattended (the scheduler's proactive run) nor private to the principal (the email poller's turns), so inbound text can never reach it. The MCP server, workflows, reflection and research never carry it at all.\n\nThe mailbox connection is deliberately **not** part of the offer: the handler checks it on every call and says how to fix it, so the cached tool prefix never flips when a token lapses. The pin lives in a context variable for the turn's task as well as on the session, so two turns running at once on one session (a second browser tab) each read their own. It also carries the speaker's own words for the turn (a new email may go to an address they just typed — the turn's message joins the history only once the turn ends), a per-turn draft count, and `touched_mail` (see Privacy). `own_words` reads those words back for every own-words check (addresses here, facts and task assignments elsewhere): it first removes the hydrated `<outbound_reply_context>` backstory by its exact, anchored shape, so a look-alike closing tag quoted inside it cannot pass the rest off as the speaker's, then drops other adapter tag blocks, and returns nothing for a message carrying an attachment.\n\n## The tool: `ghostwrite_email`\n\nIt lives in its own registry (`orchestrator.delegation_tools.DELEGATION_TOOLS` / `DELEGATION_TOOL_HANDLERS`), **never** `_ALL_SKILL_TOOLS`, so no other toolkit can carry it. On a turn it is offered to, the agent loop adds it to the pool *before* the sort and builds that turn's handler map from both registries; on any other turn a call to it is an unknown tool. The handler re-checks the pin and the surface anyway, then:\n\n1. **Caps** — at most 5 drafts per turn, and `DELEGATION_MAX_DRAFTS_PER_DAY` (default 50, at most 1000) per person per UTC day, shared with the inbox watcher (`delegation.caps`). It is counted from `delegation_drafts`, one row of ids per draft saved from either place, with a count kept in the process as a floor in case a row was lost. Each slot is taken before the first await — a round's tool calls run concurrently, so otherwise every call in it would pass the caps before any counted — and handed back if nothing was drafted. If the rows can't be read it refuses rather than guess.\n2. **Marks the turn** — sets `TurnDelegation.touched_mail` *before* its first read of the mailbox.\n3. **Checks the mailbox** — `gmail_status` asks Google or Microsoft whose mailbox the credential opens and compares it with the person's People email, on every call: a roster email can change, and a client slot swaps the roster.\n4. **Finds the thread** — by `thread_id` (checked against the mailbox's own id shape), or a Gmail-style search (`find`; on Outlook, words, `from:`, `to:`, `cc:`, `subject:` and `newer_than:` are kept and other Gmail operators dropped). Several matches return `{status: \"choose\", candidates}` (subject, sender and date — no message text) and draft nothing; none returns `not_found`.\n5. **Sets the recipients in code**, never from the model. A reply goes to the last inbound message's `From` — never its `Reply-To` (a different one is flagged `reply_to_ignored`) — with the thread's other recipients only on `reply_all`. A new email or a forward may go to any well-formed address: it is only a draft, waiting in their own mailbox, where they see who it is to before they send it. An address that is neither on the roster (contacts only when `contacts_reachable_now()`) nor typed by the speaker this turn comes back in `not_in_people`, and the Executive names it for them to check (`delegation_tools.not_in_people`). Mailing-list mail, a thread they replied to last and a reply-all trimmed to 10 recipients are flagged. An address inside a block an adapter added to their message (the backstory hydrated into a DM) is not one they typed, and when the message carries an attachment — a document's inlined text, or a note naming the file — none of its addresses count as typed: neither has an end mark, and a filename is chosen by whoever sent the file, so such an address is named back to check.\n6. **Writes it** (the ghostwriter, below) and saves it with the mailbox client's `create_draft` (Gmail: threaded with `In-Reply-To`, `References` (whole message ids: when the chain is too long for one header the oldest after the thread's first go, never the parent) and `threadId`, and stamped `X-OE-Ghostwritten`; Outlook: Graph's `createReply` on the message it answers, then the text and recipients, and a named property marking it).\n\nThe result is `{status: \"drafted\", draft_id, gmail_link, to, cc, subject, preview, flags, open_questions, note}`, plus `not_in_people` and `check_address` when a recipient needs checking. The link (`gmail.mailbox_link`) is built server-side from a fixed prefix — the thread in Gmail, the draft itself in Outlook on the web — and the note tells the model the preview is the person's draft, to be treated as data. The chat shows an action chip — \"Drafted an email as you to … — in your Drafts\" — that opens it, and only a link under `MAILBOX_LINK_PREFIXES` is ever linked. A sincere \"are you an AI?\" in the thread comes back as an open question for the person to answer themselves.\n\n## Reading their mailbox\n\nFive read-only mail tools ride with `ghostwrite_email` in the same registry (`orchestrator.mail_read_tools`), so they are offered, re-checked and fenced exactly as it is: `search_my_email` (a Gmail-style search through the client's `search_threads`, or with no query the threads that reached their inbox in the last few days through `inbox_message_ids` + `get_message`), `read_my_email` (one thread's last 10 messages, each sender's new text only, drafts left out, with the files attached to them listed by message id and index), `read_my_email_attachment` (one of those files as text: PDF, Word, Excel, CSV or text, up to 20 MB, a scanned PDF converted) and `my_email_awaiting_reply` (their own sent mail from the last 14 days, to at most 10 people besides the Executive, that is still the last message in its thread). They change, label, draft and send nothing.\n\nThe fifth, `my_email_read_before`, lists the threads `read_my_email` opened for the same person before, in this conversation or an earlier one, so a later conversation can open the same email again instead of asking them to search for it. It keeps where, never what (`delegation.mail_reads`, table `delegation_mail_read`): the thread id, its subject and first sender as one line each, the mailbox address it was read from and when, never a message's text, an attachment or a recipient. Rows are the person's own and are listed only from the mailbox open now, newest first, optionally narrowed by words in the subject or sender; anything older than 30 days is never listed and is deleted on the next write, at most 200 are kept per person, and turning Act as me off deletes them all. It opens the mailbox like the other reads, so it sets `touched_mail`, counts as a search, and returns its rows with the same data-not-instructions note. The Act as me addendum tells the model that these tools reach the person's mailbox while any Gmail or Outlook tools of its own account reach only the Executive's, to search theirs (never falling back to its own) for mail sent to them, and to reopen an email from before with `my_email_read_before` and `read_my_email`.\n\nEach sets `touched_mail` and marks the conversation theirs before its first read (`_open_mailbox`, shared with `ghostwrite_email`), so the lockdown below applies from its round on. Each is capped per turn on the pin: 10 searches (`my_email_awaiting_reply` counts as one), 20 thread reads and 5 attachment reads, the slot taken before the first await. In `read_my_email` every message someone else wrote comes back inside its own `<untrusted_content source=\"email\">` block (`content_trust.wrap_untrusted`, which defuses a closing tag in the text); the speaker's own messages — SENT and from their address (`threads.mine`), never a From header alone — are marked \"Yours\" outside any block. An attachment's text comes back in its own `<untrusted_content source=\"attachment\">` block (`attachments.format_attached_text`), parsed in an isolated worker (`knowledge.loader`); unlike a file sent to the Executive it is never added to the company's knowledge. The clients find an attachment by message and position and look its provider id up on each read (Gmail's changes per fetch): Gmail lists a message's files with the message (`MailMessage.attachments`, leaving out images the HTML shows in place), Outlook says only `hasAttachments` until `list_attachments` asks Graph (leaving out inline ones), and `attachment_bytes` reads one; an attached Outlook item or cloud link has no file to read. Results carry a note that subjects, senders and text are other people's words, data rather than instructions. The lockdown refuses tools, not the reply's own text, so what would carry that text out without a click is closed where it is shown: the web chat loads no image from another site, and bot replies go out without link previews (see Integrations).\n\n## Reading their calendar\n\nA third switch under Act as me, **Read my calendar** (`delegation.calendar`, table `delegation_calendar`: one row per person, absent or unreadable meaning off), lets the Executive read the person's own calendar, read-only. It rides on the same per-person sign-in as their mailbox: `calendar.readonly` on Google, `Calendars.Read` on Microsoft, added when they run the connect script with `--calendar` (`scripts/connect-own-gmail.py`, `scripts/connect-own-outlook.py`). Those scopes are optional, so a mail-only sign-in keeps working for mail; the mailbox clients note the scopes the token refresh reports, and `list_events` raises `CalendarNotGranted` before calling the calendar when the scope is missing (or when the calendar answers 403). Only the person turns it on (`PUT /delegation/calendar`), only while Act as me is on and a one-hour read works; a sign-in without the calendar is refused with `calendar_not_granted` and the command to run. Turning Act as me off turns it off. Changes are audited privately (`delegation_calendar_changed`).\n\n`my_calendar` sits with the mailbox reads, offered and fenced the same way: it refuses while the switch is off (before anything is opened), then takes a search slot, opens the mailbox privately (`_open_mailbox`, so `touched_mail` and the lockdown apply: an invite's title is in the words of whoever sent it) and lists the events from `start` (default today) for `days` days (1 to 31) in the workspace time zone, recurring events expanded and cancelled ones left out: title, start, end, all-day, location, organizer, attendees (25 at most) and the person's own answer, each on one line, with a data-not-instructions note. Google's `events.list` on the primary calendar and Graph's `calendarView` (times asked for in UTC) are its only calls; it changes nothing and keeps nothing. The first week's brief also lists today's meetings from it on the principal's own delivery (see Today).\n\n## Forwarding and reminders\n\n`ghostwrite_email` also forwards: with `forward` (a thread id) and `to`, it drafts a forward of the thread's latest message, or of the earlier one `forward_message_id` names (the one with the files, say, when their own reply came after it), `intent` becoming the short note above it (the ghostwriter writes only the note; the forwarded email's subject, someone else's words, is never put in the intent). Recipients follow the new-email rule (`_new_recipients`: the roster, or addresses the speaker typed this turn). Gmail's draft quotes a forward header and the original's own words under the note and attaches the original's files, up to 10 and 20 MB (`FORWARD_MAX_FILES`, `FORWARD_MAX_BYTES`; any left off are flagged `attachments_left_off`); Outlook uses Graph's `createForward`, which keeps the original and its files, with the note as its comment and the body never patched. It is still only a draft.\n\n`remind_me(text, when)` (`orchestrator.reminder_tools`) rides with the same tools and checks, but opens no mailbox, so it never marks or locks a turn (`MAILBOX_TOOL_NAMES` are the ones that do). It stores the text once cleaned — one line, anything a chat app could turn into a link (a URL of any scheme, an address, a domain-like word, a host and port, an IP address) replaced with \"[link]\", at most 300 characters — with its time (stored in UTC) in `delegation_reminders` (5 a turn, 25 waiting, a year ahead, refused when the person has no channel). When it is due the scheduler sends that text to the person alone, as \"Reminder you set on <date>: …\", running nothing (see Scheduler); the Slack and Discord DMs it may go by turn link previews off. The chat chip shows the text as it will be sent. A reminder that comes due in the person's quiet hours or leave (when `OUTBOUND_RESPECT_QUIET_HOURS` is on) waits unclaimed and goes once they end, rather than being suppressed and lost. It is allowed after mail is read and in later turns of that conversation: it reaches only the speaker, as plain text. `schedule_followup`, which runs a turn with tools and is listed to everyone, stays refused there.\n\n## Approval cards\n\nA turn that read someone's mail may not message anyone, invite anyone or change the roster (see the lockdown above), yet what the mail asks for is often right. `propose_actions` (`orchestrator.action_card_tools`) leaves the speaker a card instead: up to five actions, each spelled out exactly as it will happen, done only when they tap Approve. It rides with the other Act as me tools and checks (`_writer`), opens no mailbox, and is allowed after mail is read because it does nothing on the turn.\n\n- **Kinds.** `invite` (a meeting with people on the roster), `message` (a direct message to someone on the roster, as written) and `add_contact` (a new contact; the principal's cards only, since contacts are theirs). A team member's card can't name a contact. Each action is checked when the card is made (`delegation.action_cards.check`) and again when it is carried out, so an archived person or a time that has passed fails that action alone.\n- **Whose.** A card is a `delegation_actions` decision for the speaker, `approver_only` like a reply card: only they see it (`GET /delegation/actions`) or resolve it, a team member's answers 404 to the principal too, and it is never an alert. The same actions still waiting are that card, not a new one. 3 cards a turn, 25 waiting, dropped after 7 days.\n- **Approve.** In the chat, under the reply that left it (the `propose_actions` chip carries the card's `decision_id`, and `ChatActionCards` shows the card while it waits), and on the Briefing's Needs you list, with a box per action. Approve (`POST /decisions/{id}/approve`, `edits.only`) needs the card's person signed in (`verified.caller_refusal`) with Act as me on; the card is claimed first so it runs once, then each ticked action runs as stored with no model call, in an unattended session (the principal's with contact egress) under `rows_for_person`, so every audit row it writes is theirs and nothing reaches the team's activity rail: `message_person` (a direct message or nothing; never its Briefing-alert fallback, which more people read), `create_calendar_event`, or a contact row. Approving also needs the person still allowed Act as me (`can_delegate`) and switched on. An invite is booked straight away when the person approving is the one the meeting gate would ask (`calendar_tools.approved_by`), and otherwise goes to that approver as usual, so a card never widens anyone's authority. Per-action results (`done`, `waiting`, `failed`, `skipped`) are kept on the decision and shown on the card. Dismiss rejects it and does nothing else. With Suggested actions in training the card adds Approve + allow, and a card of actions all allowed is carried out on its own (see In training above).\n- **Channels.** A card can come from any surface Act as me runs on; it is approved in the web app, since the chat apps have no buttons here.\n\n## The ghostwriter\n\n`delegation.ghostwriter.compose` writes the text. The Executive decides *what* to say (`intent`); this call decides *how* the person would say it, and it is deliberately small:\n\n- a constant `GHOSTWRITER_PROMPT` plus the person's voice block as the system prompt;\n- the thread (each message cut to its sender's own words, every line scrubbed, all labelled alike), then the writer's own earlier words in it (`<writer_said>`, from their sent mail only), the intent and the recipients' names in the user turn — no company profile, memory or roster;\n- with Always in the loop on, `<writer_noted>`: what the writer's own notes say they told these same people in earlier Act as me replies (`memory.history_drafts.notes_for_draft`: only notes from mail **every** recipient of the new draft was on, so nothing told to one person reaches another; chat notes name no recipient and never qualify; at most 8, newest first, the person's own words or their correction, with dates). The prompt's rule 6 makes it a consistency check, never content: a draft that contradicts it is still written as the intent says, and the conflict becomes an open question on the card, which only the writer sees. Both the chat tool and the inbox watcher pass it;\n- **no tools** but the forced `compose_reply` return, so text in the thread can ask for anything and there is nothing to do it with.\n\nIt is not a Council agent — the Council's edit routes have no principal check — and runs on `DELEGATION_COMPOSER_MODEL` (default: the default model), logged as `ghostwriter` usage. `lint` then runs in code on what comes back: a link or an email address survives only if it appears in the intent, the signature or the recipients, so a link planted in the thread is removed and flagged; the Executive's own name is flagged; and the body is capped, cut at a paragraph, line or word break in its last fifth. A draft with nothing left after that is refused. The signature from the person's Gmail settings (or the one already stored, for Outlook) is appended.\n\n## How I write\n\n`delegation.voice` learns how a person writes *their own* email (`attunement.style` learns how the Executive should write *to* someone). `POST /delegation/voice/learn` reads up to 40 recent sent messages, keeps only what they wrote (quoted replies stripped with the email poller's `sender_new_text`), skips automatic mail, every thread chat drafted into, and every sent message that began as a draft written for them (`delegation_drafts.sent_message_id`), and makes one forced-tool call (`record_voice_profile`). Code validates every field before it is stored:\n\n- greetings per audience (their team, their contacts, anyone else), a sign-off of at most two lines, and a usual length and tone (a backslash-n the model wrote instead of a line break is read as one, keeping the first lines that fit, which also repairs a profile stored before that rule);\n- up to 8 habits and 6 things to avoid, through the same deny-list as working-style rules — no actions, links, handles, amounts, tool names or names of people; the conversation review (`memory.chat_review`) adds one when the person states how they write in a chat (`add_conversation_rule`, `updated_by=conversation`; never on a locked or full list, and an edit or lock made meanwhile wins);\n- up to 3 short exemplars, each checked to be verbatim from a sample, with addresses and phone numbers masked — and none while a client slot is active, so one client's mail never lands in another's state.\n\nThe signature comes from Gmail's `sendAs` settings, not the model (Outlook gives apps no way to read one, so a learn keeps the stored signature and `POST /delegation/voice/signature` answers 409 `signature_unavailable` rather than clearing it), as plain text with its lines kept (`gmail.html_to_text`: a `<br>` always ends a line, and a block tag, opening or closing, ends one when it has text, so Gmail's layout of a first line followed by one `<div>` per line comes out line by line). `POST /delegation/voice/signature` reads it again without relearning: nothing else changes and a locked profile stays locked, so it picks up a changed Gmail signature and undoes **Don't add my signature**. A person can also describe their style in their own words: `POST /delegation/voice/describe` applies the description to the profile they have through the same forced tool (a separate system prompt, no exemplars) and the same validation, keeps their signature and writing examples, and returns the result with a short sample reply for them to review. It saves nothing and needs no mailbox; Save stores it as an ordinary edit. The person can edit the profile, lock it (a locked profile is never relearned) and reset it, and every change is kept in `delegation_voice_history`. One learn runs at a time per person, and a lock or an edit made while it runs wins: the learned profile is dropped (`changed`).\n\n## Draft replies to my inbox\n\nA second switch under Act as me, **Draft replies to my inbox** (`delegation.inbox`), has the Executive watch the person's own inbox and write a first reply to mail that needs them. The reply waits on a private card on Today; nothing is sent until they tap **Send** (below). Where the reply lives is the person's choice, **Also save replies in my Gmail Drafts** (`mailbox_drafts`, off by default): off, it lives on the card alone (`delegation.card_drafts`: the card keeps the draft's recipients, subject and thread headers as `draft_spec`, and Send makes the mailbox draft from exactly that just before the send-time checks, taking it back out if they refuse), so their Drafts folder doesn't fill with replies they may never send; on, it is also saved in their Drafts as before. The switch is one row per person in `delegation_inbox_watch`. Turning it on needs Act as me on and their mailbox connected, and sets `watch_since` to now every time, so it never drafts for mail that arrived before; turning Act as me off turns it off too. Off means no mailbox call and no row written, with one exception: a send the person started that the mailbox never confirmed is still followed through until it is settled.\n\n### When it looks\n\nA throttled hook in the scheduler tick (`_maybe_scan_inbox`, after the pause, company-profile and rotation gates) checks each person whose switch is on every `DELEGATION_INBOX_POLL_MINUTES` (default 5). It is not a scheduled action, because those are listed on `/scheduled` for everyone and anyone may cancel them. One scan task runs at a time, one scan per person, and none while a client slot is active. **Check now** on the Settings card runs the same scan. Every row a scan writes is private and the person's own (`audit.rows_for_person`: a team member's rows are hidden from the principal too, see Privacy), and the process log carries counts and codes, never an address or a line of mail. The scan never marks mail read or changes a label.\n\n### What it drafts for\n\nA scan first settles the open cards (below), and stops with `backlog_full` once 25 are waiting, counting the ones it makes. It then lists the inbox since `watch_since` (`inbox_message_ids`) — not chats, not mail from the person, and not the promotions, social, updates or forums tabs (on Outlook: the Focused inbox only) — up to 100 messages, and takes the newest message of each thread that still needs a look, at most 10: settled threads and threads with an open card are passed over first, so a burst of mail, or a pause for a limit or a back-off, never hides older threads for good. `delegation_inbox_messages` is its durable cursor: one row per message (`UNIQUE(person_id, message_id)`) with what happened to it, the reason, how many tries it took, and the draft and card ids. It stores a hash of the sender's address, never the address. A message is skipped, with the reason recorded, when:\n\n- it came before `watch_since`, or more than three days ago;\n- it is from the person or one of their send-as addresses, from the Executive, or one of this module's own drafts;\n- it is automatic — `Auto-Submitted`, a bulk or auto-reply `Precedence`, a bounce, a calendar invite or a no-reply sender — or from a mailing list, or in a Gmail tab, spam or trash;\n- the person is not in To or Cc, or it has more than 10 recipients;\n- the person replied last, or a draft already sits in the thread.\n\nThree kinds are left unrecorded, so a later scan looks again: mail under 10 minutes old (mail the person answers straight away never gets a card), mail in a thread whose card is still open, and mail a daily limit holds back.\n\n### Deciding, then writing\n\nTwo model calls, and code decides between them. The classifier (`delegation.inbox_classifier`) is one forced-tool call, `classify_email`, returning whether the email needs a personal reply, what kind it is and how sure it is. It sees a few one-lined header lines and the sender's own new words (at most 3000 characters, every line scrubbed) inside one `<email>` block marked as data, and it has no other tools, context or memory, so an email can ask for anything and there is nothing to do it with. A reply is drafted only for a question, a request, scheduling, an introduction or a follow-up, and only when the confidence clears a bar that rises the less the sender is known: 0.6 for their team or a contact (the principal's contacts count only for the principal: a team member's mail is weighed by the team and their own sent mail), 0.7 for someone they have written to before (`has_written_to`, a search of their sent mail), 0.85 for a stranger. Pitches, notes of thanks, FYIs, notifications, newsletters and phishing get nothing, and so does any failure. An email that also went to other people is drafted for only when the person is in To and it asks them themselves: the classifier is told their name, whether they are in To or Cc and how many others it went to, and lists the names the email greets or asks by name (`asked_names`). Code matches those against the person's name, whole name parts only (\"Alexis\" never counts for \"Alex\", and a nickname misses, which means no draft), so mail that greets someone else (\"Good morning, Brennan, could you sign ...\") is never theirs, whatever the model makes of it as a whole. When it names nobody, the model's `asked_of_them` decides, false for a question to the group at large. One that only copies them is never drafted for. Either is recorded `not_needed` with the reason `asks_someone_else`. It runs on `DELEGATION_CLASSIFIER_MODEL`, else the routing model. A sender whose address Gmail couldn't authenticate is handled as a stranger whatever the roster says — anyone can put a colleague's or a client's address in From — so they get the stranger's bar, a holding reply and the stranger limits; the card still says who they claim to be, and that the address isn't verified.\n\nThe reply is written by the same ghostwriter, in the person's voice, but from a fixed intent the module builds rather than words the person typed. Because the intent lets it restate the person's own earlier words, which words are theirs is never written inside the thread, where a sender could imitate any marker with a look-alike: every message there is labelled alike, and the person's own words come in a separate `<writer_said>` block after the thread, taken only from mail their own mailbox sent. Nothing inside the thread can close the thread block or open another. The intent: acknowledge the sender; say again only what the person's *own* earlier messages in the thread already said; commit to nothing new — no yes or no, date, time, price, fact or promise — and say they will get back to them; and put every question it could not answer from their words in **open questions**. A stranger always gets a short holding reply. The lint still strips any link or address that isn't the person's own. The reply goes to the sender (never `Reply-To`) and, on a group email, to everyone else it went to as Cc (reply to all, never the person's own addresses or the Executive); a stranger's holding reply goes to the sender alone. The card says when others were on the email, and its `draft_to` lists everyone, which Send checks.\n\nThe order: record the message, classify, reserve a slot in the shared daily limit, write, save the draft in Gmail (from the alias the mail went to, when it went to one) and store its id, then create the card (idempotent on the message) and mark it drafted. Nothing that fails along the way loses the message. A failure that may pass — the classifier or the writer failing, Gmail refusing the draft, a card that couldn't be made (its draft is deleted first, so no draft is left without a card), any other error with that one message — leaves it for a later scan (`retry`), and it is given up on only after three tries; one message's trouble never holds up the rest. A daily limit reached while it was being read leaves it for later without counting as a try.\n\n### The reply cards\n\nA card is a `delegation_reply` decision whose class is **its approver's alone** (`DecisionClassSpec.approver_only`): only the person it was drafted for sees or resolves it on any decisions route — a team member's card answers 404 to the principal too — and it is never an alert: alerts feed chat turns, which would put other people's mail into memory. It carries the sender with who they are to the person and whether Gmail could verify the address (SPF/DKIM/DMARC, through `fact_confirmation.headers_authenticated`), the subject, what they wrote, the draft, the open questions and its warnings. `GET /delegation/replies` lists the open ones from the database alone, so Today never waits on Google.\n\n- **Send** approves the card, which sends its draft exactly as it is in their mailbox (see *Send on your tap*). **Edit** changes the reply's words right on the card (`PUT /delegation/replies/{id}/text`, `card_drafts.edit`): only its own person, from a caller the API can tie to them (as for Send), never while it is being sent on its own; a reply in their Drafts is rewritten there too (`update_draft_text`, every header kept), and only while it is still the version the card last saw, so a change made in the mailbox is never overwritten. A card edit counts as edited (`approved_with_edit`, and **Do it like this next time** keeps it). **Open in Gmail** (or **Open in Outlook**), shown only when the reply is in their Drafts, opens it there.\n- **Dismiss** rejects the card; the class's after-reject step then deletes the draft if nobody edited it — its message id is still the one it was saved with, since Gmail gives an edited draft a new one, and the Outlook client makes a draft's message id `<id>.<changeKey>` so an edit there changes it too — and keeps it otherwise. What happened is recorded even when Gmail fails.\n- Each scan first **settles** what Gmail already settled: a draft sent from Gmail, a draft deleted there, a reply the person wrote themselves, a thread that is gone, or a card left for 7 days (its draft stays in Gmail). Each is a compare-and-set close with the reason. A newer message from someone else flags the card instead. A card being sent at that moment is left alone.\n\n### Send on your tap\n\n`delegation.reply_send` is the only thing in Act as me that sends, and all it can send is the draft on a card, by its id: `DelegateGmail.send_draft` posts `{\"id\": …}` to Gmail's `drafts.send`, and `DelegateOutlook.send_draft` posts an empty body to that draft's Graph `send`, and nothing else, so no text, recipient or header is ever passed. It has two doors: `send_approved_reply`, reached only from `POST /decisions/{id}/approve` — a class only the card's own person may resolve — and `send_on_its_own`, reached only from the inbox watcher under Handle it for me (below). AST tests pin both call sites, so no model, chat turn, workflow, scheduled job or MCP call can. A tap is checked like this: At send time it checks everything again:\n\n1. **Who is asking.** The caller is the card's person and the API knows it: signed callers are on and the request carries that person's signed assertion (or the operator's, under local login), or the API runs for local login and answers this computer only. Anything else is a 409 `caller_signing_required` — with only the shared secret, whoever holds it could send as the owner — so on a server Send needs signed sign-ins.\n2. **The switches.** Act as me and Draft replies to my inbox are on, and no client slot is active.\n3. **The mailbox.** Their mailbox is connected.\n4. **The draft.** It still exists, in the same thread, and they haven't replied there themselves since; otherwise the card closes.\n5. **Who it goes to.** To, Cc and Bcc hold between 1 and 10 addresses, never the Executive's own, and it is from one of their own addresses.\n6. **What changed.** Recipients that differ from the card's, or a newer message from someone else, need a second yes: the first tap gets a 409 `confirm` naming the recipients and the reason, and the person approves again with what they were shown.\n\nThen it claims the card (`claim_for_execution`, proposed → executing, a compare-and-set, so a double tap sends once) and reads the draft once more: `drafts.send` sends whatever the draft is when Gmail gets the request, so if it was edited since the checks read it — in another tab, by a delegate — nothing is sent and the card comes back (`draft_changed`). Then it sends, and records the result: `approved_with_edit` when the draft was edited in Gmail, the sent message's id, the draft row's `sent_message_id`, and a private `delegation_reply_sent` row. A refusal that proves nothing went — a 4xx, a lapsed sign-in, a rate limit, a draft already gone — hands the card back. A failure that leaves it unclear — a timeout, a 5xx — leaves it `executing` and says to check the Sent folder, and the next scans ask Gmail: their message in the thread means it was sent; anything else is judged on the second scan that sees it: the draft still there and nothing sent means it was not (Gmail deletes a draft it sends), and the card comes back, flagged; the draft gone and nothing sent means it was deleted. Nothing is ever retried on its own. Sending is the person's own act, so it works while the Executive is paused.\n\n### Limits and failures\n\nAt most 5 drafts a scan; `DELEGATION_INBOX_MAX_DRAFTS_PER_DAY` (default 20) a day, inside the shared `DELEGATION_MAX_DRAFTS_PER_DAY` it shares with chat; 200 classifications, 2 drafts per sender (1 for a stranger) and 10 for strangers in all per day; and never more than 25 open cards. A lapsed Gmail sign-in sets the status and is looked at again every 30 minutes; a rate limit, an error reaching Gmail or a crash backs off from 5 minutes, doubling up to 2 hours. Neither turns the switch off: the Settings card shows the status in plain words.\n\n## Handle it for me\n\nA third switch under Act as me, **Handle it for me** (`delegation.handle_it`), lets the inbox watcher send some of its replies itself instead of leaving them on a card. It is one row per person in `delegation_handle_it` (`enabled`, `mode`); no row means off. One setting says how much goes without them, the way quality does on the Agent Council (`handle_it.RULES`): **Easy ones** (`careful`) sends only replies to people they know (someone on their team, a contact or someone they have written to) of at most 400 characters when the classifier is at least 0.9 sure; **People I know** (`balanced`), where it starts, sends replies to people they know up to 1200 characters at 0.8; **Most mail** (`bold`) also answers strangers, up to 2000 characters, and lets a link or an amount through when the classifier is at least 0.9 sure. Everything else waits on a card as before, so turning it on never drafts less. A table from before the setting gets the `mode` column on its next open (`schema._add_handle_it_mode`): someone who had strangers set to send keeps that as Bold, everyone else gets Balanced. Only the person turns it on (`PUT /delegation/handle-it`), from a session the API knows is theirs: the same rule Send uses (`delegation.verified.caller_refusal`), so with only the shared secret it answers 409 `caller_signing_required`. Turning it on needs Act as me and Draft replies to my inbox on, and turning the inbox watcher off (or Act as me, which turns it off) turns it off too.\n\n**In training** (`delegation.training`). Like someone new, each Act as me job can be put in training on its own, from that job's card on the Act as me page, the way Take the lead has it: **Write drafts as me** and **Handle it for me** each pick Off / In training / On (Handle it's In training is Replies in training, with a *Train follow-ups too* box for Follow-ups), and **Suggested actions** picks Always ask / In training; what it learned is listed on each tab for its own jobs (Act as me: *What it's learned*, drafts and suggested actions; Handle it for me: *Who it's allowed to handle*, replies and follow-ups), each item named by its job (`PUT /delegation/training`, one row per person and setting in `delegation_training`, absent means not in training). In training it asks first and learns who and how from what the person approves; what it learns is a `take_the_lead_allowed` row (feature `act_as_me`, the person's id), theirs alone.\n\n- **Replies.** Every reply waits on its card (`handle_it_reason` `training`) whatever the dial says, and a reply card adds **Send + allow**: it sends that reply on the person's own tap, exactly as Send does, then allows replies to that sender (key `act_as_me|person:<id>|reply|<address>`). While Handle it for me is on, a reply to an allowed sender goes on its own under the dial's limits (a stranger they allowed included) and every check above (the topics that always wait, links and amounts, new recipients, once a thread a day, the daily limit); it's checked again at send time, so a sender removed since waits. Take the lead as you lifts nothing in training: putting Replies or Follow-ups in training turns it off, and it can't be turned on while they are (409 `in_training`).\n- **Follow-ups.** Every follow-up waits (`follow_up_training`); Send + allow on a follow-up card allows follow-ups to exactly the people it went to (`…|follow_up|<sorted addresses>`), whoever they are, under every other follow-up check.\n- **Suggested actions.** An action card (below) adds **Approve + allow**: it does the actions on the tap, then allows each one that happened (a message to that person, `…|message|person:<id>`; a meeting with exactly those people, the person left out, `…|invite|people:<ids>`). A new contact is never allowed. A card proposed later whose every action is allowed is carried out at once, with no tap (`action_cards.run_on_its_own`, `gate_mode` `auto_execute`, status `executed`), only if plain code finds nothing against it (`on_its_own_refusal`): still in training, Act as me on, a server that ties the switch to the person, nothing sensitive, no link or amount, a message of at most 1200 characters, and at most 10 actions carried out this way a day (checked one card at a time); anything refused is handed back to wait on its card as before. An invite carried out this way is never booked as approved by the person: the meeting gate decides as for any meeting nobody tapped, so a time taken from someone's mail can't land on a calendar unasked. The tool result and chip say what was done. The message text in such an action is model-written from the mail and goes without anyone reading it; the allowance covers who and what kind, not the words, which is why sensitive topics, links, amounts and long messages are held back.\n- **Drafts.** Nothing is sent. When the person changes a reply's draft in their mailbox before tapping Send (plain or + allow) and ticks **Do it like this next time**, what they sent is kept (its new text, quoted replies dropped, at most 1000 characters, `…|style|<address>`), and the ghostwriter gets it in its user turn as `<writer_example>` when it next writes to that person, from the inbox, a follow-up or a chat draft to that one person: style only, never its facts, and nothing in it can open or close a tag.\n\nSend + allow and Approve + allow are refused before anything is done unless their setting is in training (422 `cant_allow`) and the person's list has room (409 `learned_full`, at most 200 a person); allowing failing afterwards never undoes the send. Putting Replies or Follow-ups in, or Suggested actions out, of training only holds more back and works without signed sign-ins; anything else needs a caller the API knows is that person. What it learned is the person's alone: listed on `GET /delegation` (`training.learned`, each with its `setting`), removed with `DELETE /delegation/learned/{id}`, and for the owner also in Take the lead's \"What it's learned\" list; it never reaches anyone else's list or Take the lead's prompts. A dial left on In training by an older version (mode `training`) moves to People I know with Replies and Follow-ups in training (`schema._move_training_off_the_dial`).\n\n**No model decides whether a reply goes.** The watcher's two model calls are unchanged and tool-less, so text in an email can at most change the verdict and the draft. After the draft is written, `handle_it.refusal` — plain code — decides, and anything it refuses becomes the usual card with the reason kept on it (`handle_it_reason`). It refuses when:\n\n- it's off, or the sender is a stranger and the setting isn't Bold, or on a server signed sign-ins are off (`signing_ok`: signed callers, or local login);\n- Gmail couldn't authenticate the sender, whatever the roster says;\n- the email isn't a question, request, scheduling, introduction or follow-up, or the classifier was less sure than the setting needs (0.9 on Easy ones, 0.8 otherwise);\n- the reply goes to anyone the email didn't already go to (its From, To and Cc, less the person's own and the Executive's addresses), leaves out the sender, or goes to more than 10;\n- the email's subject, the sender's new words, or the reply touch money, contracts, legal, hiring, pay, layoffs, the board, investors, mergers, the press, health, or credentials and secrets (passwords, logins, tokens, API keys); or the reply carries an amount, a percentage or a link (a scheme, `www.`, a bare host with a path such as `bit.ly/…`, or a bare host on a common top-level domain) unless it's Bold and at least 0.9 sure, or runs over the setting's length (400, 1200 or 2000 characters);\n- the draft carries any flag but *others on the thread* or *Executive on the thread* (they asked if it's an AI, recipients were trimmed, …);\n- it already sent one in this thread in the last day, or the person's last message in the thread was itself sent on its own (no auto-reply ping-pong);\n- the day's limit is reached (`DELEGATION_HANDLE_IT_MAX_SENDS_PER_DAY`, default 20, within the watcher's drafts limit), or it can't be counted. Any error in the rules counts as a refusal.\n\nA reply the rules allow gets a card with `gate_mode` `auto_execute`, and the watcher sends it at once through `reply_send.send_on_its_own`, the second and last door into the send path (an AST test pins both callers: the approve route and the watcher). It runs the same send-time checks as a tap — switches, mailbox, draft, recipients, the claim and the last re-read — with no caller, and adds its own: the card must be `auto_execute`, Handle it for me still on with the setting still allowing that sender (or, for a follow-up, that recipient), signing still on, the once-a-thread-a-day rule and the daily limit counted again, and the draft untouched since it was saved (an edit in Gmail means the person has taken it over: `draft_changed`, the card waits for them). Every refusal hands the card back to the person (`decision_ledger.hand_back`, a compare-and-set to `propose`), with the reason kept on it when there are words for it, and a failure never stops the scan. Every card it left for the person says why on Today (`waited_because` on `GET /delegation/replies`). A reply sent on its own finishes as `executed` (not approved), is recorded in `delegation_handled` (for the per-thread and daily rules) and writes a private `delegation_reply_handled` row; an unconfirmed one is settled by the reconciler the same way. No History note is taken from it, since notes come only from the person's own words. It runs inside the watcher's scan, so it stops while the Executive is paused.\n\n**Follow-ups as you** (`delegation.follow_ups`). While Handle it for me is on, the watcher's scan also looks at the person's own sent mail, at most once an hour (`LOOK_EVERY`), for an email of theirs that asked something (a question mark in their own words), is 3 to 10 days old, went to at most 10 people other than the Executive, and is still the last message in its thread. Plain code picks it; each gets one follow-up ever (its `delegation_inbox_messages` row), at most two a look, within the drafts limit. The ghostwriter, tool-less as always, writes a short nudge in their voice from the thread, saved as a draft in that thread to exactly the people the email went to. `handle_it.follow_up_refusal` — plain code — decides whether it goes: by the setting it never goes on Easy ones, goes to their team and contacts on People I know and to anyone they wrote to on Most mail (`follow_up_refused` otherwise: `follow_up_level`); it also refuses on any change of recipients, a sensitive topic, an amount or a link, more than 600 characters, a flag, and the same per-thread and daily counts as replies. It goes through `send_on_its_own` on an ordinary `delegation_reply` card marked `source: follow_up`, which rechecks the setting for that recipient. A refused one waits on Today as **Follow-up waiting**, and closes by itself (its untouched draft deleted) when anyone answers in the thread first.\n\n**What it sent** is the person's alone: `GET /delegation/handled` lists the last 7 days (who, subject, the reply, the questions it left them and a link to the thread in their mailbox), and the Handle it for me tab shows it with how many went today, under its picker.\n\n### Take the lead as you\n\nOn Settings → Act as me, Handle it for me is one dial: **Off**, **Easy ones**, **People I know**, **Most mail** and, for the owner, **Everything**, which uses **Take the lead** (`PUT /delegation/take-the-lead`, one row `person:<id>` in `take_the_lead`; turning it on turns Handle it for me on). While it is on, `handle_it.refusal` drops the setting's limits: strangers, the classifier's confidence, amounts, and the length up to a 4000-character ceiling. A reply with a link still waits for a tap (refusal `link`). In their place it checks the company's and the person's own added rules (`take_the_lead.reply_hit`, refusal `lead_rule`). Everything Handle it always keeps still holds: signed sign-ins, an authenticated sender, a reply kind, exactly the thread's people, the topics that always wait, draft flags, never twice in a row, one a thread a day and the daily limit. Follow-ups under it may go to anyone the person wrote to, with the same sensitive, amount, link and length checks plus the added rules. `reply_send.send_on_its_own` accepts the card while both switches are on. Each person adds and removes their own rules (`/delegation/take-the-lead/rules`). Removing one needs a caller the API can tie to them.\n\n\n## AI line on replies\n\nReplies written as a person can end with **\"Drafted and sent by my AI assistant.\"** (`delegation.disclosure.LINE`), by two switches that are each person's own (`PUT /delegation/disclosure`, one row per person in `delegation_disclosure`, NULL following the install): **Handle it**, on by default (`AI_DISCLOSURE_HANDLE_IT`), for a reply Handle it for me will send on its own, which nobody reads before it goes; and **Approved sends**, off by default (`AI_DISCLOSURE_APPROVED_SENDS`), for one that waits on a card for them to send, since they read it first. The line is written into the reply when it is drafted (`disclosure.sign`, in `inbox._consider` and `follow_ups`), once the plain-code checks have decided whether it goes on its own, so the card, the mailbox draft and what is sent are the same words and Send's draft-changed checks see them; a switch changed later applies to the next reply, and a reply drafted to go on its own that is handed back keeps its line for the person to edit. `AI_DISCLOSURE` off turns both off and hides the card. Turning a switch on only adds the line, so it needs no signed sign-in; turning one off does. Each tab shows its own switch under Advanced (**AI line on drafts you send** on Act as me, **AI line on replies it sends** on Handle it for me), and turning off the Handle it line asks first.\n\n## The mailbox client\n\n`delegation.gmail.DelegateGmail` talks to the Gmail REST API directly and is **never registered with the MCP gateway**, so the model reaches the mailbox only through the typed handler. The credential is one file per person in `DELEGATION_GOOGLE_CREDENTIALS_DIR`, named from a hash of the address (0600 in a 0700 directory), minted by `scripts/connect-own-gmail.py` on the Executive's own OAuth client with the scopes `gmail.readonly` and `gmail.compose`. It never lives in `WORKSPACE_MCP_CREDENTIALS_DIR`, where workspace-mcp picks a credential by address. Besides reading threads and saving drafts it lists the inbox and checks whether they have written to an address, reads one message or draft, lists the person's send-as addresses and deletes a draft. Its **one send method**, `send_draft`, sends an existing draft by its id and nothing else — never `messages.send`, which sends any text it is given — and unit tests pin the method set, the endpoint, the request body and its single caller. A failed request says whether it may have been carried out anyway (a timeout after connecting, a 5xx), which is what the send path needs to know. A parsed message carries when it arrived, whether it is bulk, a bounce or a calendar invite, and whether Gmail's authentication results vouch for its sender.\n\n`gmail_status` answers `connected`, `not_configured`, `needs_reconnect` (Google refused the saved sign-in — an app in Testing mode has its tokens expire after 7 days; a rate limit, though Gmail may send it as a 403, is an `error` to retry, not a reconnect), `mismatch`, `no_email`, `shared_mailbox` or `error`. `shared_mailbox` means the person's address *is* the Executive's; it is refused before asking Google, because then everything the Executive writes would look like theirs. The gateway closes the other door: every `google_workspace__*` call must act as the Executive's own account, and a `user_google_email` naming anyone else is refused and audited (see Integrations).\n\n### Outlook\n\nA person may connect an Outlook mailbox instead (work, school or personal), with `scripts/connect-own-outlook.py`: a device-code sign-in on the Executive's own Entra app (`MS365_MCP_CLIENT_ID`, tenant `MS365_MCP_TENANT_ID` or `common`) asking for `User.Read`, `Mail.ReadWrite`, `Mail.Send` and `offline_access`. It writes the same per-person file with `\"provider\": \"microsoft\"`, so a person has one mailbox for Act as me, and `gmail_for` hands back `delegation.outlook.DelegateOutlook`, which keeps `DelegateGmail`'s methods, return types and errors, so every caller above runs unchanged. It talks to Microsoft Graph directly, never through the Microsoft 365 MCP server the Executive's own Outlook uses, and is never registered with the gateway. Microsoft rotates the refresh token on use; the new one is written back into the file (atomically, keeping every other key, and only if the file still holds the old one). Graph is asked for immutable ids, so a sent draft keeps its id; a thread is Outlook's `conversationId`. Gmail's labels are mapped onto what the callers read: `SENT` only for mail in their Sent Items folder (a From line set to their address by someone else never counts), `DRAFT`, `INBOX`, and Focused Inbox's Other read as a tab. A sender counts as authenticated only when the topmost `Authentication-Results` — the one Exchange wrote, above anything the sender added — holds exactly one DMARC verdict, a pass for From's own domain, and Exchange Online Protection's own `compauth=` verdict, so a header the sender wrote on mail EOP never stamped doesn't count. `delete_draft` refuses anything that isn't a draft, and deletes with the draft's etag (`If-Match`), so a draft sent in between — it keeps its id — is left alone. No client secret is ever written into a person's file, and Graph has no signature setting to read.\n\n## Privacy\n\nWhat a person's mailbox touches is theirs. For the principal that means private to the principal, as every private row is. For a team member it means theirs alone, the principal included: an audit row carries `private_to_person` (set by `audit.rows_for_person` around the inbox watcher, a card's Send and Dismiss and their settings changes, and by `people_tools.audit_row_owner` on a turn that read their mail) and is left out of every audit read — the log, a session's timeline, a row by id, the brief — with only the usage totals counting it; their reply cards are theirs alone (above); and the owner's view of their use is counts only (drafts and sends in 30 days, and whether their inbox watcher is on). The conversation itself becomes its owner's alone before the mailbox is first read: `ghostwrite_email` marks the session `mail_private` (`session_store.mark_mail_private`, creating a channel adapter's row early, with its owner) and refuses to read the mailbox if that can't be stored or the conversation already belongs to someone else (which it then leaves unmarked); from then on only its owner may open it (`chat._session_access`), and working-style learning skips it. Every later turn there starts private (`settings.pin_turn_delegation` reads the flag and fails closed, setting `touched_mail`), so a follow-up answered from history alone is still private to its owner and teaches no memory, and the web chat's rows before the turn (the inbound message and the knowledge lookup) are theirs too. It does not start locked down: the lockdown is `read_mail`, set only by a turn that reads the mailbox or notes itself, and it is never carried into the next turn, because history keeps only the speaker's words and the Executive's replies, never the mail a tool returned. Their next message is them asking again, having read that reply, so everything runs again there. Anyone else speaking in it is not offered Act as me.\n\nOnce `touched_mail` is set, every audit row the turn writes is private (`people_tools.audit_row_private_to_principal`), and a team member's is theirs alone: the tool row (its input and result redacted, since `ghostwrite` is a sensitive tool name), the reply's `chat_turn` row that carries the preview, the model-call rows, and the background passes, which run under `private_rows`. The Honcho peer and department syncs are skipped, because peer memory is read on other people's turns. No memory is learned from the turn at all: the episodic, open-loop and working-style passes are skipped too, since its reply quotes a draft built from other people's mail. The `delegation_*` audit events are always private and carry metadata only — ids, counts and flags, never the draft or the thread. The inbox watcher is private the same way: every row a scan or a card action writes is its person's alone, and it starts no chat turn, alert, scheduled action or workflow run and teaches no memory.\n\nThe turn also keeps one door shut (`delegation.lockdown`). Anyone can put text in the inbox, and that text could try to steer the model, so from the round that calls `ghostwrite_email` or one of the mailbox reads — a round's tools run together — until the turn ends, the dispatch guard refuses only what opens the open internet or reaches everyone: outside fetches (`read_document`, research, the watchlist, `load_mcp_server`, and any MCP `call_tool` outside the private-turn set of reads and recipient-checked sends), `run_script` and `run_python_job`, workflows (they run later, unattended, and may fetch or script), broadcasts, department messages and alerts, and changes to who is on the roster or holds authority (`archive_person`, `set_department_head`, `resolve_roster_request`), and text that steers later turns (`schedule_followup`, whose intent runs unattended when due, and goals and decision outcomes, shown to every later turn). Everything else the person asks for runs, because it is fenced on its own: DMs and `message_person` reach only the roster, invites name attendees by person id, the Executive's own email checks every recipient against the roster, standing facts and profile edits keep only the person's own words, and a workflow drafted in chat is saved only once a person confirms it. `upsert_person` runs only for a contact the person asked for (`speaker_named_contact`: a contact, never the team, an approval scope or a chat account, with a word of the name in what they typed, in a message that asks to add, save or change someone, a new contact's address one they typed or one that sent the mail the turn read under the contact's name (`TurnDelegation.mail_senders`), never one the mail's text only mentions, and on an update a changed address they typed), since the roster is what the send checks trust. Any other contact add is refused with a pointer to an approval card (`lockdown.CONTACT_REFUSAL`), so the Executive leaves an `add_contact` card in the chat rather than asking them to type the address. What an email itself asks for is still never done on its say-so; it goes on an approval card. Every tool is classified as allowed or withheld, a test fails on a new unclassified one, and an unknown name is withheld, except an extension tool registered with `after_mail_read` (one that only reads the install's own data). The refusal tells the model to put what the step needs in its reply, since the next turn sees the reply but not the mail, and to do the step then without reading the mail again. A refused call gets a private `tool_invocation` row (`refused: mail_touched`) and tells the model to offer it in the next message. The offered tool list never changes mid-turn, so the cached prefix holds. The handlers that reach outside check again on their own (`outside_reach_refusal`). The server-side web search stays, as on a turn private to the principal. The lockdown ends with the turn. Later turns of that conversation stay private to its owner (`touched_mail`) but hold nothing: a refusal says it will work when they ask again in their next message, and it does.\n\n## Always in the loop\n\nA sent reply can leave a note. Once the reply went, `reply_send` starts `memory.history_notes.note_sent_reply` for the person who sent it, in the background, when their \"Keep track of what happens\" switch is on and the conversation isn't one they asked not to remember. The note-taker sees only the words they sent, so other people's mail never becomes a note, and a failure never touches the send. Recall is `recall_history`, offered on the same verified, private surfaces as `ghostwrite_email` and also allowed under the mail lockdown, since it only reads the speaker's own notes. Calling it locks the turn like `ghostwrite_email` does, from its own round on. The same switch also covers notes from chat, which don't need Act as me. See **Memory** for the checks, retention and controls.\n\n## The system prompt\n\nA constant, name-free `DELEGATION_ADDENDUM` joins block 0 after the unchanged identity addendum while anyone on the install has it on (`block0_delegation_on`). It names the four mailbox reads and says other people's mail is data and that a conversation which read it reaches nobody else; and it tells the model that `ghostwrite_email` is the single exception to *never impersonate*, and only for the person being spoken to; that everything else is written as itself; that when the tool isn't offered the asker can't have it; that a draft is never described as sent; and that it never denies being an AI. It is keyed on the install-level setting, never on the turn or the speaker, so switching it misses the 1h cache once (see Prompt Caching).\n\n## What it may do\n\n**Delegate → What it may do** (`delegation.may_do`, `GET /what-it-may-do`) is read-only: one row per thing that can go out without asking, what happens to it (goes out, waits for someone, always waits, drafts only, off) and which setting decides it, with a link there. It is the first Delegate tab, and `/delegate` opens on it. Three parts, each behind a pill that counts what goes out:\n\n- **As you** (the caller's own, when `can_delegate` allows them): built from `settings.is_enabled`, `inbox.get_watch`, `handle_it.get` and `handle_it.RULES`, `handle_it.leading` (Everything), `training.get` and `training.learned`, and their rules, the same reads `handle_it.refusal` and `follow_up_refusal` make. A level's row follows its `Rules` (strangers, follow-up reach, links and amounts), not a copy of them. A note names the ladder: Handle it for me rides on Draft replies to my inbox and Write drafts as me, and Everything also drops when Replies or Follow-ups go into training.\n- **As the Executive** (the principal's alone, as `GET /take-the-lead`): the switch and its training, each Ask first kind, the company's rules, and meetings. A meeting it thinks of on its own always waits: both meeting gates need someone on a verified surface in the turn, which an unattended run never is. A meeting someone asks for in chat follows **Always asks first → Meetings asked for in chat** (on means it waits: `meeting_scheduling`'s class mode is `propose`; off means `auto_execute`) and, in a team workspace, Operations' level too.\n- **Departments**: each level, and what a level covers (department-scoped scheduled work, check-ins, alert review, team members' chat sends, and Operations' meetings), and that it doesn't cover what the Executive does under Take the lead.\n\nIt also says when the Executive is paused, and when nothing can be sent as anyone because signed sign-ins are off. Nothing on it writes or reads mail. A contact, someone not on People, or a request with no caller (outside local login) gets 403.\n\n## How far it goes as you\n\nOne setting replaces the switches that used to turn each other off out of sight. The UI shows it as two pickers (`ReachCard.tsx`): **What it writes as you** (`WritesCard`) on the Act as me tab and **What it sends on its own** (`SendsCard`) on the Handle it for me tab; What it may do links each row to its own picker. Its steps, each adding to the one before: **Off**, **Drafts when I ask** (Write drafts as me), **Drafts for my inbox** (Draft replies to my inbox), then the Handle it for me steps that send, **Easy ones**, **People I know** and **Most mail** (`careful`, `balanced`, `bold`), and for the owner **Everything** (Take the lead as you). Act as me shows the first three as **Off**, **When I ask** and **For my inbox too** (any sending step reads as For my inbox too there). Handle it for me shows **Off** (saved as the inbox step) and the sending steps, and opens only once Act as me is at For my inbox too, with a button that turns that on; moving Act as me below it says Handle it for me stops too. `PUT /delegation/reach` (`{step}`) moves it, and `reach_of` reads the step back from the switches, so the stored switches stay the source of truth and every gate reads them as before.\n\nGoing down turns the switches above the target off, highest first (`_lead_off`, then Handle it, then the inbox watcher, then Write drafts as me), so nothing is ever on above a switch that's off; the UI says what stops and asks before it saves. A lower sending level only holds more back and is set directly, so it needs no signed sign-in. Going up calls each switch's own route in order, so every check it makes still applies: the mailbox connected, signed sign-ins for sending, the owner alone and not in training for Everything. The first that refuses stops the move at a whole step and answers with that route's error. **In training** (Replies and Follow-ups together, with **Train follow-ups too** to split them) and, at Everything, **Your rules** sit under the Handle it for me picker, and **Learn from my edits** (drafts training) under the Act as me one; neither picker changes training.\n\n## Surfaces\n\n- **Settings → Act as me** (`ActAsMeCard`, hidden unless `GET /delegation` answers, so a team member sees it once the owner lets them): the mailbox connection (`provider` says which) with both connect commands (Gmail and Outlook) and **Check again**, **What it writes as you** (above), with the inbox watcher's status under For my inbox too (in plain words, when it last checked, **Check now** and **Also save inbox replies in my Gmail Drafts**), and **How I write**: length and tone, a greeting per audience (`{first}` is their first name), the sign-off, habits and never-rules in fields that grow to show every line, the signature with **Refresh from Gmail** and **Don't add my signature** (or **Add my Gmail signature** when none is added; on Outlook only **Don't add my signature**, with why), and each example quoted with **Remove examples**. The owner also gets **Let team members use it** where the install allows it, with each team member who has it on listed by name and counts only.\n- **Today → Replies waiting** (`RepliesWaiting`, the top of the left column; hidden unless `GET /delegation/replies` answers with cards): each card shows who wrote and who they are to you, whether their address was verified, the subject, **They wrote** as plain text, your draft, **Decide before sending** (the open questions) and its warnings, with **Send** (a confirm naming who it goes to, and a second one when that or the thread changed), **Edit** (a text box on the card with Save and Cancel), **Open in Gmail** or **Open in Outlook** when the reply is in their Drafts, and **Dismiss**.\n- **Setup status**: a **Your own mailbox (Act as me)** light (`your_gmail`), amber while the inbox watcher can't reach the mailbox, is being rate-limited or has 25 replies waiting.\n- **Delegate** (main menu): **What it may do** (above, where `/delegate` lands), **Act as me** (where `/settings/act-as-me` lands), **Handle it for me** (which step the dial is at, with **Change in Act as me**, then **What it sent**: how many went today and what it sent this week, as you) and **Take the lead** (the switch, then **Always asks first**, shown even while the switch is off and ending in **Meetings asked for in chat**, and the company's rules, as the Executive). Each switch that turns another off says so beside it. The pause is on **Settings → Your Executive**.\n- **API**: `GET`/`PUT /delegation`, `GET`/`PUT`/`DELETE /delegation/voice`, `POST /delegation/voice/learn`, `POST /delegation/voice/describe`, `POST /delegation/voice/signature`, `PUT /delegation/inbox` (`{enabled?, mailbox_drafts?}`), `POST /delegation/inbox/check`, `GET /delegation/replies`, `PUT /delegation/replies/{id}/text`, `PUT /delegation/handle-it`, `PUT /delegation/reach` (`{step}`, the dial), `PUT /delegation/training`, `DELETE /delegation/learned/{id}` and `GET /delegation/handled` — the caller's own delegation only — and `PUT /delegation/team`, the owner's switch (see API Reference). `GET /what-it-may-do` is the read-only summary above. Send is `POST /decisions/{id}/approve`; Dismiss is `POST /decisions/{id}/reject`.\n- **Evals**: a scenario's `delegation:` block runs the turn against an in-memory mailbox (`evals.mailbox.ScenarioMailbox`) and hands the saved drafts to the judge (`delegation_001`–`003`). A `type: inbox` scenario runs the watcher's two model calls on one thread: whether it drafts must match the scenario, and a draft is judged on saying nothing the person hadn't, copying no link or address, and listing every open question (`delegation_inbox_001`–`007`; the last checks a draft never claims anything was sent).\n\nActing within rules the person sets and standing in for them are later, separate changes, each behind its own switch, off by default.",
"mermaid": "flowchart TD\n Ask[\"Principal or team member, verified<br/>'reply to Dana as me: yes'\"] --> Pin[\"pin_turn_delegation<br/>may have it? on? verified? private? attended?\"]\n Pin -->|\"offered\"| Loop[\"Executive tool loop<br/>with ghostwrite_email\"]\n Pin -->|\"not offered\"| Self[\"writes as itself<br/>(unknown tool this turn)\"]\n Loop --> Tool[\"ghostwrite_email handler<br/>caps, mailbox check, recipients in code\"]\n Tool -->|\"touched_mail\"| Private[\"turn's rows and conversation<br/>theirs alone, no memory\"]\n Tool --> Client[\"DelegateGmail or DelegateOutlook<br/>REST, outside the MCP gateway\"]\n Tick[\"Scheduler tick or Check now<br/>Draft replies to my inbox on\"] --> Scan[\"inbox scan, rows theirs alone<br/>skip rules, limits, ledger\"]\n Scan --> Client\n Client --> Box[(\"The person's own Gmail or Outlook\")]\n Scan --> Classify[\"classifier, no tools<br/>needs a reply? kind, confidence\"]\n Classify -->|\"worth a draft\"| Gw\n Voice[(\"delegation_voice<br/>How I write\")] --> Gw[\"ghostwriter<br/>no tools: voice + intent + thread\"]\n Tool --> Gw\n Gw --> Lint[\"lint: links and addresses<br/>only the person's own\"]\n Lint --> Draft[\"create_draft, threaded\"]\n Draft --> Box\n Draft --> Chip[\"chat chip: open the draft<br/>chat never sends\"]\n Draft --> Card[\"Today: Replies waiting<br/>their own card\"]\n Card -->|\"Send, confirmed\"| SendPath[\"reply_send: checks again,<br/>claim, send the draft by id\"]\n SendPath --> Box\n class Ask entry\n class Pin compute\n class Loop compute\n class Self compute\n class Tool compute\n class Private compute\n class Client compute\n class Tick entry\n class Scan compute\n class Classify compute\n class Box external\n class Voice storage\n class Gw compute\n class Lint compute\n class Draft hot\n class Chip entry\n class Card entry\n class SendPath hot",
- "generated_at": "2026-10-15T16:30:00+00:00"
+ "generated_at": "2026-10-15T19:07:34Z"
}
diff --git a/packages/core/openexecutive/guide/prebuilt/settings.json b/packages/core/openexecutive/guide/prebuilt/settings.json
index e5676ee6..97466d13 100644
--- a/packages/core/openexecutive/guide/prebuilt/settings.json
+++ b/packages/core/openexecutive/guide/prebuilt/settings.json
@@ -1,7 +1,7 @@
{
"section_id": "settings",
"title": "Settings & Advanced",
- "markdown": "**What it is:** The settings that live outside the day-to-day nav: whether the Executive is running and how it sounds, who Open Executive is for, letting it write email as you, and the admin and power-user tools.\n\n**What it does:**\n\n- Opens on a page of tiles, one per settings page — **Your Executive**, **Workspace**, **Advanced** and **About**. Each tile says what's on its page and, where it can, how things stand now (running or paused, the voice, just you or your team, a newer version). Click a tile to open its page; the **Settings** link at the top of each page takes you back. Old links to a section (such as `/settings#workspace`) land on the matching page. **Act as me**, **Handle it for me** and **Take the lead** are not in Settings: they are tabs of **Delegate** in the main menu, after **What it may do**, which lists everything that goes out without asking you and the setting that allows it.\n- **Your Executive** shows whether the Executive is **running** or **paused**, with one button: **Pause…** opens the pause form; while it is paused, who paused it, the held count and **Resume** stay in view. Below it, **Voice** picks the voice the Executive answers you in.\n- **Workspace** holds, one card each: whether Open Executive is personal or for your team, your role when it's just you, and your time zone. **Company email domains** sits under **Advanced** at the bottom.\n- **Act as me** (a tab of **Delegate** in the main menu) lets you have the Executive write email drafts as you, in your own voice, from your own Gmail — when you ask, and, if you turn it on, for mail in your inbox that needs you, which you can send from Home with one tap. Your mailbox and **How far it goes as you** are up front; **How I write** (and, for the owner, **Let team members use it**) sit under **Advanced** at the bottom.\n- **Advanced** lists the pages that open their own screen, grouped by what you'd use them for: **Check & diagnose** (Setup status, Audit log, Token usage), **Configure** (Agent Council, Company Simulator, Client Companies) and **Learn** (User Guide, Architecture).\n- **About** shows the version this install runs, and whether a newer one is out.\n\n**How to use:**\n\n1. Click **Settings** at the bottom of the sidebar. (On a phone, open the menu with the button at the top left; Settings is at its bottom.)\n2. Click a tile to open that page.\n3. On **Advanced**, click a row to open that page:\n - **Setup status** — check that every part of your setup is working, and see what to do about anything that isn't.\n - **Agent Council** — change a specialist's model or prompt, or the Executive's voice.\n - **Audit log** — find out what the Executive did, and why.\n - **Token usage** — see what you're spending and where.\n - **User Guide** — this guide.\n - **Architecture** — the technical reference for how the system is built.\n - **Company Simulator** — try the Executive on a test company.\n - **Client Companies** — switch between clients if you do fractional work.\n\n**Checking your setup:**\n\n- Open **Settings → Advanced → Setup status**. Each part of your setup gets a light: green is working, amber needs attention, red isn't working, grey isn't set up (and is optional).\n- It tests things for real: the AI key, and each chat app's token, with a quick call that sends nothing. It also checks the Executive's email address, the company setup, the daily schedule, when and where your daily brief goes, and whether anyone on your team list can reach each chat app.\n- Anything that isn't green says what to do in plain words, with a button when the fix is on another page. After you change a setting and restart the app, click **Check again**.\n\n**Workspace:**\n\n- **Using Open Executive** — **Personal** or **Team**. You pick this when you first set up; change it here. Switching asks you to confirm and says what changes:\n - **Personal** pauses department check-ins and renames **Company** in the sidebar to **You**, with **Goals** (grouped by area), **People** and your profile — there is no Departments tab. Nothing is deleted — your departments stay, as the areas your goals are grouped by.\n - **Team** brings back **Company** with its **Departments** tab and their daily check-ins, and the People and Departments tiles on Home.\n- **Your role** (just you) — which describes you best (**Owner / founder**, **Executive inside an organisation**, **Independent or fractional**, or **Other**), your title, who you report to, what you're responsible for and what you're measured on. Every field is optional; click **Save role** after editing. The Executive uses it to fit its advice to your job — a VP gets help making the case to their boss, an owner gets help with a call that's theirs alone to make. It stays saved if you switch to your team.\n- **Time zone** — when your morning brief, end-of-day digest and reflection arrive, and how the Executive reads \"tomorrow at 9\". It suggests the zone your browser is in; **Follow server default** uses the server's setting.\n- **Company email domains** (under **Advanced**, principal only) — mail from these domains matches a teammate by the part before the @, and a new address there is filled in as a teammate when someone writes in. It follows your own address unless you set it here.\n- Only the principal can change the mode, role and time zone. A persona you customised in Council stays in place in either mode.\n\n**Act as me (Delegate → Act as me):**\n\n- Normally the Executive writes only as itself, from its own email account. **Act as me** lets it write an email *as you*: ask in chat — \"reply to Dana as me: yes to the 5th\" — and it saves a draft in **your own Gmail Drafts** for you to read, change and send. Asking in chat never sends anything, and everything else it writes stays in its own name.\n- The owner sees this page, and so does each team member once the owner turns on **Let team members use it** under **Advanced** at the bottom of it (shown only where your install allows it). Each team member connects their own Gmail and turns it on for themselves. What it reads in their mail, the drafts it writes and their **Replies waiting** are theirs alone: the owner sees only who uses it and how many drafts and sends it made, and a conversation in which it read someone's mail can be opened only by that person. Turning the owner's switch off takes it away from the team from their next message. It works when you ask in the web app, in a direct message to the Executive on Slack or Discord, or in a verified private Telegram chat — never in a shared channel or thread, from an email, a scheduled job or anyone else's conversation.\n- **Your Gmail** — connect your own Gmail first. The page shows the command to run on a computer with a browser; sign in as yourself, put the file it writes where your install reads it, then click **Check again**. It won't connect the Executive's own address as yours.\n- **How far it goes as you** — one setting for everything it writes or sends as you, from **Off** up. Each step adds to the one above it, and it stays at **Off** until your Gmail is connected. **Writes as you, never sends**: **Drafts when I ask** writes a draft when you ask in chat; **Drafts for my inbox** also writes replies to your inbox (below). **Handle it for me sends as you**: **Easy ones**, **People I know** and **Most mail** let it send some replies and follow-ups itself, and the owner also gets **Everything**. Moving down asks first and says what stops. At a sending step, **In training** has every reply come to you first. At **Everything**, **Your rules** under the dial hold back replies that match them. This is the only place to change it: **Handle it for me** shows which step it is at, and **What it may do** links here.\n- **Drafts for my inbox** — every few minutes the Executive looks at new mail in your inbox, and for mail that needs a personal reply from you — a question, a request, a meeting to arrange, an introduction or a follow-up — it writes a first reply in your Gmail Drafts and puts it at the top of **Needs you** on Home. Nothing is sent until you tap **Send** there. It only looks at mail that arrives after you turn it on, and leaves out newsletters, notifications, mailing lists, mail you've already answered and anything that doesn't need you; mail you answer within ten minutes never gets a draft. The first reply only acknowledges: it repeats only what you've already said in the thread, commits you to nothing and lists what's left for you to decide. Someone you've never written to gets a short holding reply. While it's on, **Your inbox** says how it's doing (for example, that your Gmail needs connecting again) and when it last looked; click **Check now** to look straight away. Moving to **Off** also turns **Read my calendar** off.\n- **How I write** (under **Advanced**) — click **Learn from my sent mail** and it reads your recent sent emails once and describes how you write (click **Edit how I write** to open the fields): your usual **Length** and **Tone**, a **Greeting** for your team, your contacts and anyone else ({first} stands for their first name), your **Sign-off**, your **Habits**, what you **Never** do, and a few **Examples of your writing** that set the tone. Change any of them and click **Save changes**; **Lock** stops it being relearned from your mail (you can still edit it); **Reset** starts over; **Remove examples** drops the examples. Your Gmail signature is added to every draft: **Refresh from Gmail** picks up a change you made to it in Gmail, **Don't add my signature** stops adding it, and **Add my Gmail signature** brings it back.\n- In chat you get a card, \"Drafted an email as you to …\", that opens the draft in Gmail. If the Executive isn't sure about something, it asks you instead of guessing.\n\n**Setting up just for yourself:**\n\n- The first time you set up, Open Executive asks who it is for — **Personal** or **Team** — before anything else, and saves your time zone from the browser. Re-running setup later skips this; change the mode here instead. Either way you can add teammates later from **People**.\n- **Personal** is for anyone who uses Open Executive just for themselves, whatever their role: your own business, a team you lead inside an organisation, or clients you advise as an independent or fractional executive.\n- Choosing **Personal** then asks **What's your role?** — the same fields as **Your role** above. Fill in what you like, or click **Skip for now**.\n- Just for yourself, the setup conversation asks about your work rather than your team, following the role you gave: an owner about what you offer, your customers, pricing, cash and runway; an executive inside an organisation about that organisation (it becomes your company profile), what you're responsible for, who you report to and what you're measured on; an independent about your practice and clients. Everyone is asked about their goals. On **Here's what I understood** there is a single **You** card (your name and role) next to **Your sign-in email**, instead of the team and department lists.\n- The step-by-step form skips the team size, team members and fractional executives steps.\n- In the sidebar, **You** takes the place of **Company** and holds **Goals**, **People** and your profile: **Business profile** if you own the business, **Your work** for any other role (or none). The profile page follows the same choice: for any other role it is worded around the organisation you work in (**Where You Work** in place of Company Basics). Either way departments are listed there as **Areas**, and your title, who you report to and what you're responsible for stay under **Your role** above.\n\n**Pausing the Executive:**\n\n- Open **Settings → Your Executive** (or **Pause or resume the Executive** in the account menu — the **⋯** next to your name at the bottom of the sidebar) and click **Pause…**. Add a reason if you like, and click **Pause Executive**.\n- While paused, the Executive starts nothing on its own: no briefs, nudges, monitoring, inbox processing or workflow timers. An amber banner appears on every page.\n- Chat and direct messages (Slack, Telegram, Discord, Google Chat) still get answers.\n- Nothing is lost. Work that falls due during the pause waits, and runs when you click **Resume**. The switch shows how many actions are waiting.\n- Anyone who can sign in can pause the Executive, but only the principal can resume it.\n\n*Tip: if you're looking for a feature that isn't in the sidebar, it's probably under **Settings → Advanced**. This guide is also in the account menu (the **⋯** next to your name at the bottom of the sidebar), with **Pause or resume the Executive** and, when you signed in with an account, **Sign out**.*",
+ "markdown": "**What it is:** The settings that live outside the day-to-day nav: whether the Executive is running and how it sounds, who Open Executive is for, letting it write email as you, and the admin and power-user tools.\n\n**What it does:**\n\n- Opens on a page of tiles, one per settings page — **Your Executive**, **Workspace**, **Advanced** and **About**. Each tile says what's on its page and, where it can, how things stand now (running or paused, the voice, just you or your team, a newer version). Click a tile to open its page; the **Settings** link at the top of each page takes you back. Old links to a section (such as `/settings#workspace`) land on the matching page. **Act as me**, **Handle it for me** and **Take the lead** are not in Settings: they are tabs of **Delegate** in the main menu, after **What it may do**, which lists everything that goes out without asking you and the setting that allows it.\n- **Your Executive** shows whether the Executive is **running** or **paused**, with one button: **Pause…** opens the pause form; while it is paused, who paused it, the held count and **Resume** stay in view. Below it, **Voice** picks the voice the Executive answers you in.\n- **Workspace** holds, one card each: whether Open Executive is personal or for your team, your role when it's just you, and your time zone. **Company email domains** sits under **Advanced** at the bottom.\n- **Act as me** (a tab of **Delegate** in the main menu) lets you have the Executive write email drafts as you, in your own voice, from your own Gmail — when you ask, and, if you turn it on, for mail in your inbox that needs you, which you can send from Home with one tap. Your mailbox and **What it writes as you** are up front; what it sends on its own is set on the **Handle it for me** tab; **How I write** (and, for the owner, **Let team members use it**) sit under **Advanced** at the bottom.\n- **Advanced** lists the pages that open their own screen, grouped by what you'd use them for: **Check & diagnose** (Setup status, Audit log, Token usage), **Configure** (Agent Council, Company Simulator, Client Companies) and **Learn** (User Guide, Architecture).\n- **About** shows the version this install runs, and whether a newer one is out.\n\n**How to use:**\n\n1. Click **Settings** at the bottom of the sidebar. (On a phone, open the menu with the button at the top left; Settings is at its bottom.)\n2. Click a tile to open that page.\n3. On **Advanced**, click a row to open that page:\n - **Setup status** — check that every part of your setup is working, and see what to do about anything that isn't.\n - **Agent Council** — change a specialist's model or prompt, or the Executive's voice.\n - **Audit log** — find out what the Executive did, and why.\n - **Token usage** — see what you're spending and where.\n - **User Guide** — this guide.\n - **Architecture** — the technical reference for how the system is built.\n - **Company Simulator** — try the Executive on a test company.\n - **Client Companies** — switch between clients if you do fractional work.\n\n**Checking your setup:**\n\n- Open **Settings → Advanced → Setup status**. Each part of your setup gets a light: green is working, amber needs attention, red isn't working, grey isn't set up (and is optional).\n- It tests things for real: the AI key, and each chat app's token, with a quick call that sends nothing. It also checks the Executive's email address, the company setup, the daily schedule, when and where your daily brief goes, and whether anyone on your team list can reach each chat app.\n- Anything that isn't green says what to do in plain words, with a button when the fix is on another page. After you change a setting and restart the app, click **Check again**.\n\n**Workspace:**\n\n- **Using Open Executive** — **Personal** or **Team**. You pick this when you first set up; change it here. Switching asks you to confirm and says what changes:\n - **Personal** pauses department check-ins and renames **Company** in the sidebar to **You**, with **Goals** (grouped by area), **People** and your profile — there is no Departments tab. Nothing is deleted — your departments stay, as the areas your goals are grouped by.\n - **Team** brings back **Company** with its **Departments** tab and their daily check-ins, and the People and Departments tiles on Home.\n- **Your role** (just you) — which describes you best (**Owner / founder**, **Executive inside an organisation**, **Independent or fractional**, or **Other**), your title, who you report to, what you're responsible for and what you're measured on. Every field is optional; click **Save role** after editing. The Executive uses it to fit its advice to your job — a VP gets help making the case to their boss, an owner gets help with a call that's theirs alone to make. It stays saved if you switch to your team.\n- **Time zone** — when your morning brief, end-of-day digest and reflection arrive, and how the Executive reads \"tomorrow at 9\". It suggests the zone your browser is in; **Follow server default** uses the server's setting.\n- **Company email domains** (under **Advanced**, principal only) — mail from these domains matches a teammate by the part before the @, and a new address there is filled in as a teammate when someone writes in. It follows your own address unless you set it here.\n- Only the principal can change the mode, role and time zone. A persona you customised in Council stays in place in either mode.\n\n**Act as me (Delegate → Act as me):**\n\n- Normally the Executive writes only as itself, from its own email account. **Act as me** lets it write an email *as you*: ask in chat — \"reply to Dana as me: yes to the 5th\" — and it saves a draft in **your own Gmail Drafts** for you to read, change and send. Asking in chat never sends anything, and everything else it writes stays in its own name.\n- The owner sees this page, and so does each team member once the owner turns on **Let team members use it** under **Advanced** at the bottom of it (shown only where your install allows it). Each team member connects their own Gmail and turns it on for themselves. What it reads in their mail, the drafts it writes and their **Replies waiting** are theirs alone: the owner sees only who uses it and how many drafts and sends it made, and a conversation in which it read someone's mail can be opened only by that person. Turning the owner's switch off takes it away from the team from their next message. It works when you ask in the web app, in a direct message to the Executive on Slack or Discord, or in a verified private Telegram chat — never in a shared channel or thread, from an email, a scheduled job or anyone else's conversation.\n- **Your Gmail** — connect your own Gmail first. The page shows the command to run on a computer with a browser; sign in as yourself, put the file it writes where your install reads it, then click **Check again**. It won't connect the Executive's own address as yours.\n- **What it writes as you** — **Off**, **When I ask** (it writes a draft when you ask in chat) or **For my inbox too** (it also writes replies to your inbox, below). It stays at **Off** until your Gmail is connected, and moving down asks first and says what stops.\n- **Handle it for me** (its own tab) — **What it sends on its own**: **Off**, **Easy ones**, **People I know** and **Most mail** let it send some replies and follow-ups itself, and the owner also gets **Everything**. It needs **For my inbox too** on Act as me. **In training** has every reply come to you first, and at **Everything**, **Your rules** hold back replies that match them.\n- **For my inbox too** — every few minutes the Executive looks at new mail in your inbox, and for mail that needs a personal reply from you — a question, a request, a meeting to arrange, an introduction or a follow-up — it writes a first reply in your Gmail Drafts and puts it at the top of **Needs you** on Home. Nothing is sent until you tap **Send** there. It only looks at mail that arrives after you turn it on, and leaves out newsletters, notifications, mailing lists, mail you've already answered and anything that doesn't need you; mail you answer within ten minutes never gets a draft. The first reply only acknowledges: it repeats only what you've already said in the thread, commits you to nothing and lists what's left for you to decide. Someone you've never written to gets a short holding reply. While it's on, **Your inbox** says how it's doing (for example, that your Gmail needs connecting again) and when it last looked; click **Check now** to look straight away. Moving to **Off** also turns **Read my calendar** off.\n- **How I write** (under **Advanced**) — click **Learn from my sent mail** and it reads your recent sent emails once and describes how you write (click **Edit how I write** to open the fields): your usual **Length** and **Tone**, a **Greeting** for your team, your contacts and anyone else ({first} stands for their first name), your **Sign-off**, your **Habits**, what you **Never** do, and a few **Examples of your writing** that set the tone. Change any of them and click **Save changes**; **Lock** stops it being relearned from your mail (you can still edit it); **Reset** starts over; **Remove examples** drops the examples. Your Gmail signature is added to every draft: **Refresh from Gmail** picks up a change you made to it in Gmail, **Don't add my signature** stops adding it, and **Add my Gmail signature** brings it back.\n- In chat you get a card, \"Drafted an email as you to …\", that opens the draft in Gmail. If the Executive isn't sure about something, it asks you instead of guessing.\n\n**Setting up just for yourself:**\n\n- The first time you set up, Open Executive asks who it is for — **Personal** or **Team** — before anything else, and saves your time zone from the browser. Re-running setup later skips this; change the mode here instead. Either way you can add teammates later from **People**.\n- **Personal** is for anyone who uses Open Executive just for themselves, whatever their role: your own business, a team you lead inside an organisation, or clients you advise as an independent or fractional executive.\n- Choosing **Personal** then asks **What's your role?** — the same fields as **Your role** above. Fill in what you like, or click **Skip for now**.\n- Just for yourself, the setup conversation asks about your work rather than your team, following the role you gave: an owner about what you offer, your customers, pricing, cash and runway; an executive inside an organisation about that organisation (it becomes your company profile), what you're responsible for, who you report to and what you're measured on; an independent about your practice and clients. Everyone is asked about their goals. On **Here's what I understood** there is a single **You** card (your name and role) next to **Your sign-in email**, instead of the team and department lists.\n- The step-by-step form skips the team size, team members and fractional executives steps.\n- In the sidebar, **You** takes the place of **Company** and holds **Goals**, **People** and your profile: **Business profile** if you own the business, **Your work** for any other role (or none). The profile page follows the same choice: for any other role it is worded around the organisation you work in (**Where You Work** in place of Company Basics). Either way departments are listed there as **Areas**, and your title, who you report to and what you're responsible for stay under **Your role** above.\n\n**Pausing the Executive:**\n\n- Open **Settings → Your Executive** (or **Pause or resume the Executive** in the account menu — the **⋯** next to your name at the bottom of the sidebar) and click **Pause…**. Add a reason if you like, and click **Pause Executive**.\n- While paused, the Executive starts nothing on its own: no briefs, nudges, monitoring, inbox processing or workflow timers. An amber banner appears on every page.\n- Chat and direct messages (Slack, Telegram, Discord, Google Chat) still get answers.\n- Nothing is lost. Work that falls due during the pause waits, and runs when you click **Resume**. The switch shows how many actions are waiting.\n- Anyone who can sign in can pause the Executive, but only the principal can resume it.\n\n*Tip: if you're looking for a feature that isn't in the sidebar, it's probably under **Settings → Advanced**. This guide is also in the account menu (the **⋯** next to your name at the bottom of the sidebar), with **Pause or resume the Executive** and, when you signed in with an account, **Sign out**.*",
"mermaid": null,
"generated_at": "2026-10-03T12:00:00Z"
}
diff --git a/packages/core/openexecutive/guide/prebuilt/today.json b/packages/core/openexecutive/guide/prebuilt/today.json
index 600c6cbe..7fe1b561 100644
--- a/packages/core/openexecutive/guide/prebuilt/today.json
+++ b/packages/core/openexecutive/guide/prebuilt/today.json
@@ -1,7 +1,7 @@
{
"section_id": "today",
"title": "Today / Morning Brief",
- "markdown": "**What it is:** A single screen of *what needs you right now* — the proactive digest the Executive prepares so you're not the one chasing status. In the app it's **Home**, the screen the app opens on.\n\n**What it does:**\n\n- Opens with a greeting, one line summing up the day (click a part of it — *2 awaiting reply*, *1 department at risk* — to open that list), and an **Ask your Executive anything…** box that starts a chat.\n- Puts what's waiting on your call up front under **Needs you**: the first card large, the next two below it, and **Show N more** for the rest.\n- Gathers everything else under **Everything else** as a row of count tiles — **Departments**, **People**, **Across the team** (waiting on someone else), **In flight**, **Handled overnight**, **Monitoring** — shown only when they have something in them. Click a tile to open its full list in a side panel.\n- The **Departments** tile shows each department's goal health — on-track, at-risk, or off-track — with the at-risk goals called out.\n- The **People** tile lists people with open items, their reply counts, SLA status, and whether they're on leave.\n- **Read today's brief** (next to **Needs you**) opens the written brief — what's going on across the company — in a side panel.\n- If your latest morning brief, end-of-day digest or weekly review couldn't be sent to you, a line at the top says why and what to connect. It goes away once that's fixed.\n- When your morning brief or end-of-day digest left out lines that named people or figures the Executive couldn't match to your data, **Left out of your brief** under **Needs you** lists them for a day. **Hide** clears it.\n- With **Delegate → Act as me → How far it goes as you** at **Drafts for my inbox** or above, the replies the Executive wrote in your Gmail Drafts for mail that needs you come first in **Needs you**. Only you see them.\n- Surfaces proposals and alerts you can click to open a chat thread with full context.\n\n**How to use:**\n\n1. Click **Home** in the sidebar (or the Open Executive logo). On a phone, **Home** is the first button in the bar at the bottom.\n2. Work **Needs you** from the top. Each card has one main button and **Discuss**; everything else is in the card's **⋯** menu:\n - **Approve** — accept the recommendation; the Executive carries it out right away. A line at the top of **Needs you** shows it working and then done, with a link to the chat where it did the work. If it didn't work, **Try again** is on that line. Usually the main button.\n - **Discuss** — open a chat with the context already filled in.\n - **Edit & approve** (in **⋯**) — reword the action first, then **Send approval**; your text is used exactly as written.\n - **Dismiss** (in **⋯**) — drop it and stay on Home. When the Executive thinks a card is stale, **Dismiss** is the main button instead.\n - **Snooze until …** (in **⋯**) — later today, tomorrow at 9:00 or Monday at 9:00. The card leaves Home and comes back on its own then; **Undo** under **Needs you** brings it back now.\n - **Nudge *name*** — the main button when the best move is chasing someone for a reply; **Run *workflow*** when the best move is a workflow.\n - **Open *name*'s page** (in **⋯**) — the person the item is waiting on.\n3. Some cards are simpler: when a scheduled run didn't finish (a department check-in, or a workflow you set to run on a schedule), its card's main button is **Run again**, which runs it now and sends the result where it normally goes (**Open the run** in **⋯** shows what went wrong); a document card's main button is **Open document** (**Mark reviewed** is in its **⋯**), and a calendar-booking card books (or declines) the meeting directly when you click Approve or Dismiss. Only the person a booking was sent to for approval, or the owner, can approve or decline it.\n4. Keep it tidy from the **⋯** next to **Needs you**: **Dismiss N older than 7 days** clears stale items, and **Re-check relevance** asks the Executive to review every open item now.\n5. Open the **Departments** tile and click a department to ask for its status in chat.\n6. Work the replies waiting to be sent (they come first in **Needs you**): each card shows who wrote (and whether Gmail could confirm their address), what they wrote, your draft, and **Decide before sending** — what the draft leaves for you to answer. **Send** asks you once, naming who the reply goes to, then sends the draft from your Gmail exactly as it is there. If you changed who it goes to in Gmail, or they wrote again since, it asks a second time and says what changed. To change the wording, choose **Edit in Gmail** in the card's **⋯**, edit the draft there, then Send here or from Gmail. **Dismiss** (also in **⋯**) deletes the draft, unless you've already edited it in Gmail. On a server, Send needs signed sign-ins; until they're set up, send from Gmail. A card goes away on its own once you send or delete the draft in Gmail, or reply yourself, and after a week.\n\n**Example:** in a Discuss thread, just say *\"go ahead\"* to approve the proposal or *\"drop it\"* to dismiss it — no need to go back to the card. (Calendar bookings still need the Approve button.)\n\n**Just for yourself?** If you use Open Executive just for yourself (**Settings → Workspace → Personal**), Home leaves out the team parts: there are no Departments, People or Across the team tiles — everything that needs a decision is in **Needs you**. When a goal is slipping, the summary line at the top says how many goals are at risk; click it to open **Goals**. Instead, the tiles are **Due soon**, **Your projects** and **This week's review**, each opening its list in a side panel. **Your projects** lists the projects the Executive is tracking for you. Click **Done** when one is finished, or **Drop** to stop tracking it (it asks first, and removes the project from Pulse). **Due soon** lists what you've promised by a date and what others have asked of you, due in the next week — say *\"I'll send Northwind the proposal by Friday\"* in the web chat or your own Slack or Discord and it shows up here, and the Executive reminds you when it's due. Click **Done** once it's handled; **All open items** opens the full list. **Top three today**, right under **Needs you**, shows the three things to focus on today — the same three your morning brief opens with — each with a free slot in today's working hours when the Executive can read your calendar. **This week's review** shows your latest weekly review: when it ran and next week's top three. Click **Read the review** to see all of it.\n\nYour morning brief also opens with a **top three for today**, picked from what's overdue or due, goals that are slipping and the projects you're driving. When Google Workspace is connected and the Executive can read your calendar (it is your own account, or you shared your calendar with it), each of the three gets a free slot in today's working hours and the brief lists today's meetings; otherwise the three come without times. Every Friday afternoon (in your time zone) a **weekly review** arrives the same way: your goals graded by area, what's due or overdue, projects that went quiet, the week's decisions, a few older decisions to look back on, and next week's top three. Both also show up on Home (see above), so you see them even when no chat app or email is connected. When it asks how an older decision turned out, just tell the Executive in the web chat or your own Slack or Discord and it records the outcome against that decision.\n\n*Note: proposals are routed to the right person automatically based on who has authority over them.*",
+ "markdown": "**What it is:** A single screen of *what needs you right now* — the proactive digest the Executive prepares so you're not the one chasing status. In the app it's **Home**, the screen the app opens on.\n\n**What it does:**\n\n- Opens with a greeting, one line summing up the day (click a part of it — *2 awaiting reply*, *1 department at risk* — to open that list), and an **Ask your Executive anything…** box that starts a chat.\n- Puts what's waiting on your call up front under **Needs you**: the first card large, the next two below it, and **Show N more** for the rest.\n- Gathers everything else under **Everything else** as a row of count tiles — **Departments**, **People**, **Across the team** (waiting on someone else), **In flight**, **Handled overnight**, **Monitoring** — shown only when they have something in them. Click a tile to open its full list in a side panel.\n- The **Departments** tile shows each department's goal health — on-track, at-risk, or off-track — with the at-risk goals called out.\n- The **People** tile lists people with open items, their reply counts, SLA status, and whether they're on leave.\n- **Read today's brief** (next to **Needs you**) opens the written brief — what's going on across the company — in a side panel.\n- If your latest morning brief, end-of-day digest or weekly review couldn't be sent to you, a line at the top says why and what to connect. It goes away once that's fixed.\n- When your morning brief or end-of-day digest left out lines that named people or figures the Executive couldn't match to your data, **Left out of your brief** under **Needs you** lists them for a day. **Hide** clears it.\n- With **Delegate → Act as me → What it writes as you** at **For my inbox too**, the replies the Executive wrote in your Gmail Drafts for mail that needs you come first in **Needs you**. Only you see them.\n- Surfaces proposals and alerts you can click to open a chat thread with full context.\n\n**How to use:**\n\n1. Click **Home** in the sidebar (or the Open Executive logo). On a phone, **Home** is the first button in the bar at the bottom.\n2. Work **Needs you** from the top. Each card has one main button and **Discuss**; everything else is in the card's **⋯** menu:\n - **Approve** — accept the recommendation; the Executive carries it out right away. A line at the top of **Needs you** shows it working and then done, with a link to the chat where it did the work. If it didn't work, **Try again** is on that line. Usually the main button.\n - **Discuss** — open a chat with the context already filled in.\n - **Edit & approve** (in **⋯**) — reword the action first, then **Send approval**; your text is used exactly as written.\n - **Dismiss** (in **⋯**) — drop it and stay on Home. When the Executive thinks a card is stale, **Dismiss** is the main button instead.\n - **Snooze until …** (in **⋯**) — later today, tomorrow at 9:00 or Monday at 9:00. The card leaves Home and comes back on its own then; **Undo** under **Needs you** brings it back now.\n - **Nudge *name*** — the main button when the best move is chasing someone for a reply; **Run *workflow*** when the best move is a workflow.\n - **Open *name*'s page** (in **⋯**) — the person the item is waiting on.\n3. Some cards are simpler: when a scheduled run didn't finish (a department check-in, or a workflow you set to run on a schedule), its card's main button is **Run again**, which runs it now and sends the result where it normally goes (**Open the run** in **⋯** shows what went wrong); a document card's main button is **Open document** (**Mark reviewed** is in its **⋯**), and a calendar-booking card books (or declines) the meeting directly when you click Approve or Dismiss. Only the person a booking was sent to for approval, or the owner, can approve or decline it.\n4. Keep it tidy from the **⋯** next to **Needs you**: **Dismiss N older than 7 days** clears stale items, and **Re-check relevance** asks the Executive to review every open item now.\n5. Open the **Departments** tile and click a department to ask for its status in chat.\n6. Work the replies waiting to be sent (they come first in **Needs you**): each card shows who wrote (and whether Gmail could confirm their address), what they wrote, your draft, and **Decide before sending** — what the draft leaves for you to answer. **Send** asks you once, naming who the reply goes to, then sends the draft from your Gmail exactly as it is there. If you changed who it goes to in Gmail, or they wrote again since, it asks a second time and says what changed. To change the wording, choose **Edit in Gmail** in the card's **⋯**, edit the draft there, then Send here or from Gmail. **Dismiss** (also in **⋯**) deletes the draft, unless you've already edited it in Gmail. On a server, Send needs signed sign-ins; until they're set up, send from Gmail. A card goes away on its own once you send or delete the draft in Gmail, or reply yourself, and after a week.\n\n**Example:** in a Discuss thread, just say *\"go ahead\"* to approve the proposal or *\"drop it\"* to dismiss it — no need to go back to the card. (Calendar bookings still need the Approve button.)\n\n**Just for yourself?** If you use Open Executive just for yourself (**Settings → Workspace → Personal**), Home leaves out the team parts: there are no Departments, People or Across the team tiles — everything that needs a decision is in **Needs you**. When a goal is slipping, the summary line at the top says how many goals are at risk; click it to open **Goals**. Instead, the tiles are **Due soon**, **Your projects** and **This week's review**, each opening its list in a side panel. **Your projects** lists the projects the Executive is tracking for you. Click **Done** when one is finished, or **Drop** to stop tracking it (it asks first, and removes the project from Pulse). **Due soon** lists what you've promised by a date and what others have asked of you, due in the next week — say *\"I'll send Northwind the proposal by Friday\"* in the web chat or your own Slack or Discord and it shows up here, and the Executive reminds you when it's due. Click **Done** once it's handled; **All open items** opens the full list. **Top three today**, right under **Needs you**, shows the three things to focus on today — the same three your morning brief opens with — each with a free slot in today's working hours when the Executive can read your calendar. **This week's review** shows your latest weekly review: when it ran and next week's top three. Click **Read the review** to see all of it.\n\nYour morning brief also opens with a **top three for today**, picked from what's overdue or due, goals that are slipping and the projects you're driving. When Google Workspace is connected and the Executive can read your calendar (it is your own account, or you shared your calendar with it), each of the three gets a free slot in today's working hours and the brief lists today's meetings; otherwise the three come without times. Every Friday afternoon (in your time zone) a **weekly review** arrives the same way: your goals graded by area, what's due or overdue, projects that went quiet, the week's decisions, a few older decisions to look back on, and next week's top three. Both also show up on Home (see above), so you see them even when no chat app or email is connected. When it asks how an older decision turned out, just tell the Executive in the web chat or your own Slack or Discord and it records the outcome against that decision.\n\n*Note: proposals are routed to the right person automatically based on who has authority over them.*",
"mermaid": null,
"generated_at": "2026-10-13T20:51:09Z"
}
diff --git a/packages/ui/scripts/reach.test.mjs b/packages/ui/scripts/reach.test.mjs
index 344e331c..3a6a0819 100644
--- a/packages/ui/scripts/reach.test.mjs
+++ b/packages/ui/scripts/reach.test.mjs
@@ -1,6 +1,6 @@
import assert from "node:assert/strict";
import test from "node:test";
-import { REACH_HREF, reachOf, reachSummary, sentTodayLine, stepLabel } from "../src/lib/reach.ts";
+import { SENDS_HREF, WRITES_HREF, reachForSend, reachOf, sendOf, sentTodayLine, writeOf } from "../src/lib/reach.ts";
const settings = (over = {}) => ({
enabled: true,
@@ -18,40 +18,31 @@ test("reachOf reads the dial step from the settings", () => {
assert.equal(reachOf(settings({ handle_it: { enabled: true, mode: "bold", lead: true } })), "everything");
});
-test("stepLabel names every step as the dial does", () => {
- assert.equal(stepLabel("off"), "Off");
- assert.equal(stepLabel("inbox"), "Drafts for my inbox");
- assert.equal(stepLabel("careful"), "Easy ones");
- assert.equal(stepLabel("balanced"), "People I know");
- assert.equal(stepLabel("bold"), "Most mail");
- assert.equal(stepLabel("everything"), "Everything");
+test("writeOf puts every sending step at For my inbox too", () => {
+ assert.equal(writeOf(settings({ enabled: false })), "off");
+ assert.equal(writeOf(settings({ inbox: { enabled: false } })), "when_asked");
+ assert.equal(writeOf(settings({ handle_it: { enabled: false, mode: "balanced" } })), "inbox");
+ assert.equal(writeOf(settings()), "inbox");
+ assert.equal(writeOf(settings({ handle_it: { enabled: true, mode: "bold", lead: true } })), "inbox");
});
-test("reachSummary says when Handle it for me is off", () => {
- const s = reachSummary(settings({ handle_it: { enabled: false, mode: "balanced" } }));
- assert.equal(s.label, "Drafts for my inbox");
- assert.equal(s.sends, false);
- assert.equal(s.training, false);
- assert.match(s.line, /off/);
+test("sendOf is off below the sending steps", () => {
+ assert.equal(sendOf(settings({ enabled: false })), "off");
+ assert.equal(sendOf(settings({ inbox: { enabled: false } })), "off");
+ assert.equal(sendOf(settings({ handle_it: { enabled: false, mode: "balanced" } })), "off");
+ assert.equal(sendOf(settings()), "balanced");
+ assert.equal(sendOf(settings({ handle_it: { enabled: true, mode: "bold", lead: true } })), "everything");
});
-test("reachSummary marks a sending step in training", () => {
- const s = reachSummary(settings({ training: { replies: true, follow_ups: true } }));
- assert.equal(s.label, "People I know");
- assert.equal(s.sends, true);
- assert.equal(s.training, true);
+test("turning Handle it for me off keeps the inbox replies", () => {
+ assert.equal(reachForSend("off"), "inbox");
+ assert.equal(reachForSend("careful"), "careful");
+ assert.equal(reachForSend("everything"), "everything");
});
-test("reachSummary never marks Everything in training", () => {
- const s = reachSummary(
- settings({ handle_it: { enabled: true, mode: "bold", lead: true }, training: { replies: true } }),
- );
- assert.equal(s.label, "Everything");
- assert.equal(s.training, false);
-});
-
-test("the dial link points at Act as me", () => {
- assert.equal(REACH_HREF, "/delegate/act-as-me#how-far");
+test("each picker has its own link", () => {
+ assert.equal(WRITES_HREF, "/delegate/act-as-me#writes");
+ assert.equal(SENDS_HREF, "/delegate/handle-it#sends");
assert.equal(sentTodayLine(1), "Sent 1 reply on its own today.");
assert.equal(sentTodayLine(3), "Sent 3 replies on its own today.");
});
diff --git a/packages/ui/src/app/delegate/act-as-me/page.tsx b/packages/ui/src/app/delegate/act-as-me/page.tsx
index 7163d00c..a6387575 100644
--- a/packages/ui/src/app/delegate/act-as-me/page.tsx
+++ b/packages/ui/src/app/delegate/act-as-me/page.tsx
@@ -4,25 +4,43 @@ import ActAsMeCard, { ACT_AS_ME_INTRO } from "@/components/settings/ActAsMeCard"
import { useDelegation } from "@/components/settings/HandleItCard";
import DelegatePage from "@/components/delegate/DelegatePage";
import ReplyDisclosureCard from "@/components/settings/ReplyDisclosureCard";
-import { LearnedCard, SuggestedActionsCard, TrainingNote } from "@/components/settings/TrainingCard";
+import { LearnedCard, SuggestedActionsCard } from "@/components/settings/TrainingCard";
-// Delegate → Act as me: drafts written as you, in your own mailbox, and how
-// you write. Like someone new, each job can be in training (Off / In training
-// / On on its own card, as on Take the lead), and what it learned there is
-// listed at the bottom. How far it goes as you (ReachCard, inside
-// ActAsMeCard) is the one dial for writing and sending as you; the Handle it
-// for me tab shows where it is and what it sent.
+// Delegate → Act as me: drafts written as you, in your own mailbox, that you
+// send, and how you write. What it writes as you (WritesCard, inside
+// ActAsMeCard) is its picker; what it sends on its own is on the Handle it
+// for me tab. Suggested actions can be in training, and what it learned
+// from your edits and approvals here is listed after them.
export default function ActAsMePage() {
const load = useDelegation();
const training = load.state === "ready" ? load.settings?.training : null;
const disclosure = load.state === "ready" ? load.settings?.disclosure : null;
return (
<DelegatePage feature="act_as_me" description={ACT_AS_ME_INTRO}>
- {training && <TrainingNote />}
- <ActAsMeCard onSettings={load.setSettings}>
+ <ActAsMeCard
+ onSettings={load.setSettings}
+ advanced={
+ disclosure?.enabled && (
+ <ReplyDisclosureCard
+ disclosure={disclosure}
+ onSettings={load.setSettings}
+ only="approved_sends"
+ title="AI line on drafts you send"
+ />
+ )
+ }
+ advancedLabel="AI line on drafts you send"
+ >
{training && <SuggestedActionsCard training={training} onSettings={load.setSettings} />}
- {training && <LearnedCard training={training} onSettings={load.setSettings} />}
- {disclosure && <ReplyDisclosureCard disclosure={disclosure} onSettings={load.setSettings} />}
+ {training && (
+ <LearnedCard
+ training={training}
+ onSettings={load.setSettings}
+ jobs={["drafts", "actions"]}
+ title="What it's learned"
+ description="From your edits and your approvals here. Yours alone. Remove one and it asks you again."
+ />
+ )}
</ActAsMeCard>
</DelegatePage>
);
diff --git a/packages/ui/src/app/delegate/handle-it/page.tsx b/packages/ui/src/app/delegate/handle-it/page.tsx
index 7f9557b5..7cd4d021 100644
--- a/packages/ui/src/app/delegate/handle-it/page.tsx
+++ b/packages/ui/src/app/delegate/handle-it/page.tsx
@@ -1,16 +1,23 @@
"use client";
import DelegatePage from "@/components/delegate/DelegatePage";
+import AdvancedFold from "@/components/settings/AdvancedFold";
import HandleItCard, { useDelegation } from "@/components/settings/HandleItCard";
+import ReplyDisclosureCard from "@/components/settings/ReplyDisclosureCard";
import SettingsCard from "@/components/settings/SettingsCard";
+import { LearnedCard } from "@/components/settings/TrainingCard";
-// Delegate → Handle it for me: the replies and follow-ups it sent as you on
-// its own, from your own mailbox, and where the dial on Act as me is. It builds on Act as me (its inbox drafts),
-// so someone who can't have Act as me is told so here.
+// Delegate → Handle it for me: what it sends as you on its own, from your own
+// mailbox (What it sends on its own, with In training and Your rules), what
+// it sent, who you allowed in training, and the AI line on those replies. It
+// builds on Act as me (its inbox replies), so someone who can't have Act as
+// me is told so here.
export default function HandleItPage() {
const load = useDelegation();
+ const training = load.state === "ready" ? load.settings?.training : null;
+ const disclosure = load.state === "ready" ? load.settings?.disclosure : null;
return (
- <DelegatePage feature="handle_it" description="Replies and follow-ups it sent as you, from your own mailbox.">
+ <DelegatePage feature="handle_it" description="Replies and follow-ups it sends as you, on its own, from your mailbox.">
{load.state === "hidden" ? (
<SettingsCard>
<p className="text-[15px] text-fg-muted leading-relaxed">
@@ -19,7 +26,28 @@ export default function HandleItPage() {
</p>
</SettingsCard>
) : (
- <HandleItCard load={load} />
+ <>
+ <HandleItCard load={load} />
+ {training && (
+ <LearnedCard
+ training={training}
+ onSettings={load.setSettings}
+ jobs={["replies", "follow_ups"]}
+ title="Who it's allowed to handle"
+ description="People you allowed with Send + allow. Remove one and it asks you again."
+ />
+ )}
+ {disclosure?.enabled && (
+ <AdvancedFold id="handle-it-advanced" summary="AI line on replies it sends">
+ <ReplyDisclosureCard
+ disclosure={disclosure}
+ onSettings={load.setSettings}
+ only="handle_it"
+ title="AI line on replies it sends"
+ />
+ </AdvancedFold>
+ )}
+ </>
)}
</DelegatePage>
);
diff --git a/packages/ui/src/components/delegate/WhatItMayDo.tsx b/packages/ui/src/components/delegate/WhatItMayDo.tsx
index 3d85c61d..40bec2fe 100644
--- a/packages/ui/src/components/delegate/WhatItMayDo.tsx
+++ b/packages/ui/src/components/delegate/WhatItMayDo.tsx
@@ -6,7 +6,7 @@ import { useEffect, useId, useState } from "react";
import SettingsCard from "@/components/settings/SettingsCard";
import SectionTabs, { sectionPanelProps } from "@/components/ui/SectionTabs";
import { getWhatItMayDo, type MayDoOutcome, type MayDoRow, type MayDoSection, type WhatItMayDo } from "@/lib/api";
-import { REACH_HREF } from "@/lib/reach";
+import { SENDS_HREF, WRITES_HREF } from "@/lib/reach";
// Delegate → What it may do: read-only. One row per thing that can go out
// without asking, what happens to it, and the setting that decides it, with
@@ -29,8 +29,8 @@ const OUTCOME_DOT: Record<MayDoOutcome, string> = {
};
function settingHref(setting: string): { href: string; label: string } | null {
- // Both are set by How far it goes as you, which lives on Act as me only.
- if (setting === "act_as_me" || setting === "handle_it") return { href: REACH_HREF, label: "Act as me" };
+ if (setting === "act_as_me") return { href: WRITES_HREF, label: "Act as me" };
+ if (setting === "handle_it") return { href: SENDS_HREF, label: "Handle it for me" };
if (setting === "take_the_lead") return { href: "/delegate/take-the-lead", label: "Take the lead" };
if (setting === "pause") return { href: "/settings/executive", label: "Your Executive" };
if (setting.startsWith("department:")) {
diff --git a/packages/ui/src/components/settings/ActAsMeCard.tsx b/packages/ui/src/components/settings/ActAsMeCard.tsx
index fedd0699..94d8b533 100644
--- a/packages/ui/src/components/settings/ActAsMeCard.tsx
+++ b/packages/ui/src/components/settings/ActAsMeCard.tsx
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState, type ReactNo
import Icon from "@/components/Icon";
import AdvancedFold from "@/components/settings/AdvancedFold";
-import ReachCard from "@/components/settings/ReachCard";
+import { WritesCard } from "@/components/settings/ReachCard";
import SettingsCard from "@/components/settings/SettingsCard";
import Switch from "@/components/Switch";
import Button from "@/components/ui/Button";
@@ -31,20 +31,20 @@ import { formatAgo } from "@/lib/setupStatus";
import { addPhrase, markNew, STYLE_PHRASES, styleSentences } from "@/lib/voiceStyle";
// Delegate → Act as me: let the Executive draft email AS you, in your own
-// Gmail Drafts, when you ask it to — and, with How far it goes as you at
-// Drafts for my inbox or above, for mail that needs you, which it sends when you tap Send on Today (or on
-// its own, under Handle it for me).
-// Backed by GET /delegation, PUT /delegation/reach (ReachCard) and /delegation/voice.
+// Gmail Drafts, when you ask it to — and, with What it writes as you at
+// For my inbox too, for mail that needs you, which it sends when you tap Send
+// on Today (or on its own, under Handle it for me, which has its own tab).
+// Backed by GET /delegation, PUT /delegation/reach (WritesCard) and /delegation/voice.
// Not offered to anyone who can't have it (the owner can, and team members
// once the owner lets them: PUT /delegation/team) or on a backend without
// it: the hub then shows no tile, and this page says so.
//
-// The page body: the mailbox, How far it goes as you and, while the inbox
-// watcher is on, Your inbox up front; How I write and Let team members use
-// it under Advanced.
+// The page body: the mailbox and What it writes as you (with the inbox
+// watcher's status under For my inbox too) up front; How I write, the
+// page's `advanced` cards and Let team members use it under Advanced.
export const ACT_AS_ME_INTRO =
- "Let the Executive write email as you, in your own voice. When you ask it to reply to or write an email as you, it saves a draft in your own mailbox (Gmail or Outlook) for you to review and send. Nothing goes out as you unless you send it, from your mailbox or with Send on a reply waiting on Today. Everything else it writes stays in its own name.";
+ "Drafts written as you, in your own mailbox. You send them.";
const LENGTHS = ["short", "medium", "long"] as const;
const FORMALITIES = ["casual", "neutral", "formal"] as const;
@@ -77,14 +77,19 @@ function greetingFields(p: VoiceProfile): Record<string, string> {
}
// `onSettings` hears every change made here, so the page's other cards
-// (Handle it for me, What it's learned) keep up; `children` sit after Draft
-// replies to my inbox, before Advanced.
+// (What it's learned) keep up; `children` sit after Read my calendar, and
+// `advanced` (with its `advancedLabel` for the fold's summary) after How I
+// write, under Advanced.
export default function ActAsMeCard({
onSettings,
children,
+ advanced,
+ advancedLabel,
}: {
onSettings?: (next: DelegationSettings) => void;
children?: ReactNode;
+ advanced?: ReactNode;
+ advancedLabel?: string;
} = {}) {
const [settings, setSettingsState] = useState<DelegationSettings | null>(null);
const setSettings = useCallback(
@@ -221,21 +226,25 @@ export default function ActAsMeCard({
</SettingsCard>
{connected || on ? (
- <ReachCard settings={settings} onSettings={setSettings} />
- ) : null}
-
- {settings.inbox?.enabled && (
- <InboxSection
- inbox={stoppedWaiting ? { ...settings.inbox, checking: false } : settings.inbox}
- mailbox={settings.gmail?.provider === "microsoft" ? "Outlook" : "Gmail"}
+ <WritesCard
+ settings={settings}
onSettings={setSettings}
- onInbox={(inbox) => {
- setStoppedWaiting(false);
- polls.current = 0;
- setSettings((prev) => (prev ? { ...prev, inbox } : prev));
- }}
+ inbox={
+ settings.inbox?.enabled && (
+ <InboxSection
+ inbox={stoppedWaiting ? { ...settings.inbox, checking: false } : settings.inbox}
+ mailbox={mailbox}
+ onSettings={setSettings}
+ onInbox={(inbox) => {
+ setStoppedWaiting(false);
+ polls.current = 0;
+ setSettings((prev) => (prev ? { ...prev, inbox } : prev));
+ }}
+ />
+ )
+ }
/>
- )}
+ ) : null}
{settings.calendar && (
<CalendarSection calendar={settings.calendar} actAsMeOn={on} onSettings={setSettings} />
@@ -245,9 +254,12 @@ export default function ActAsMeCard({
<AdvancedFold
id="act-as-me-advanced"
- summary={settings.team ? "How I write · Let team members use it" : "How I write"}
+ summary={["How I write", advanced ? advancedLabel : null, settings.team ? "Let team members use it" : null]
+ .filter(Boolean)
+ .join(" · ")}
>
<VoiceSection connected={connected} outlook={outlook} />
+ {advanced}
{settings.team && <TeamSection team={settings.team} onSettings={setSettings} />}
</AdvancedFold>
</>
@@ -314,10 +326,9 @@ function TeamSection({
);
}
-// Your inbox, while the dial is at Drafts for my inbox or higher: how the
+// Inside What it writes as you, under For my inbox too: how the inbox
// watcher is doing, Check now (POST /delegation/inbox/check) and where its
-// replies are kept (PUT /delegation/inbox {mailbox_drafts}). The switch
-// itself is a step of How far it goes as you.
+// replies are kept (PUT /delegation/inbox {mailbox_drafts}).
function InboxSection({
inbox,
mailbox,
@@ -361,13 +372,9 @@ function InboxSection({
const last = inbox.last_poll_at && !inbox.checking ? ` Last checked ${formatAgo(inbox.last_poll_at)}.` : "";
return (
- <SettingsCard
- title="Your inbox"
- titleId="act-as-me-inbox-label"
- description="When mail comes in that needs you, it writes a first reply and puts it on Today, where you can edit it, send it or dismiss it."
- >
+ <div aria-label="Your inbox">
{on && (
- <div className="flex flex-wrap items-center gap-x-4 gap-y-2">
+ <div className="ml-7 flex flex-wrap items-center gap-x-4 gap-y-2">
<span className="text-sm text-fg-muted">
{inbox.message}
{last}
@@ -387,7 +394,7 @@ function InboxSection({
className="mt-0.5 h-5 w-5 flex-shrink-0 accent-indigo-500"
/>
<span>
- <span className="block text-[15px] font-semibold text-fg">Also save replies in my {mailbox} Drafts</span>
+ <span className="block text-[15px] font-semibold text-fg">Also save inbox replies in my {mailbox} Drafts</span>
<span className="mt-0.5 block text-sm text-fg-muted leading-snug">
{inDrafts
? `Each reply is in your ${mailbox} Drafts too, so you can open it there.`
@@ -397,7 +404,7 @@ function InboxSection({
</label>
)}
{error && <p className="mt-2 text-sm text-red-500">{error}</p>}
- </SettingsCard>
+ </div>
);
}
diff --git a/packages/ui/src/components/settings/HandleItCard.tsx b/packages/ui/src/components/settings/HandleItCard.tsx
index 7db90ed2..15315ea0 100644
--- a/packages/ui/src/components/settings/HandleItCard.tsx
+++ b/packages/ui/src/components/settings/HandleItCard.tsx
@@ -1,8 +1,8 @@
"use client";
-import Link from "next/link";
import { useEffect, useState } from "react";
+import { SendsCard } from "@/components/settings/ReachCard";
import SettingsCard from "@/components/settings/SettingsCard";
import {
getDelegation,
@@ -11,15 +11,13 @@ import {
type HandledReply,
type HandleIt,
} from "@/lib/api";
-import { REACH_HREF, reachSummary, sentTodayLine } from "@/lib/reach";
+import { sentTodayLine } from "@/lib/reach";
import { formatAgo } from "@/lib/setupStatus";
// Handle it for me, its own tab under Delegate: replies the inbox watcher
// sends from your mailbox on its own. Plain code decides each one
-// (delegation/handle_it.py). Its levels are the sending steps of How far it
-// goes as you, which lives on Act as me only (ReachCard): this tab shows
-// where the dial is, with a link there, and what it sent in the last week
-// (GET /delegation/handled).
+// (delegation/handle_it.py). This tab holds What it sends on its own
+// (SendsCard) and what it sent in the last week (GET /delegation/handled).
export type DelegationLoad = {
settings: DelegationSettings | null;
state: "loading" | "hidden" | "ready" | "error";
@@ -54,9 +52,9 @@ export function useDelegation(): DelegationLoad {
}
// On Delegate → Handle it for me: nothing for someone who can't have Act
-// as me; otherwise where the dial is and what it sent.
+// as me; otherwise What it sends on its own and what it sent.
export default function HandleItCard({ load }: { load: DelegationLoad }) {
- const { settings, state } = load;
+ const { settings, state, setSettings } = load;
if (state === "loading") return <p className="text-[15px] text-fg-muted">Loading…</p>;
if (state === "error") {
return (
@@ -68,42 +66,12 @@ export default function HandleItCard({ load }: { load: DelegationLoad }) {
if (state === "hidden" || !settings?.handle_it || !settings.inbox) return null;
return (
<>
- <ReachNow settings={settings} />
+ <SendsCard settings={settings} onSettings={setSettings} />
{settings.handle_it.enabled && <HandleItSection handleIt={settings.handle_it} />}
</>
);
}
-// Where How far it goes as you is, read-only, with a link to change it on
-// Act as me.
-function ReachNow({ settings }: { settings: DelegationSettings }) {
- const now = reachSummary(settings);
- return (
- <SettingsCard>
- <div className="flex flex-wrap items-center justify-between gap-4">
- <div className="min-w-0">
- <p className="text-sm text-fg-muted">How far it goes as you</p>
- <p className="mt-0.5 flex flex-wrap items-center gap-2 text-base font-semibold text-fg">
- {now.label}
- {now.training && (
- <span className="rounded-full bg-amber-500/15 px-2 py-0.5 text-xs font-medium text-amber-700 dark:text-amber-300">
- In training
- </span>
- )}
- </p>
- <p className="mt-1 text-sm text-fg-muted leading-snug">{now.line}</p>
- </div>
- <Link
- href={REACH_HREF}
- className="inline-flex h-10 items-center rounded-lg border border-line bg-surface px-4 text-sm font-semibold text-accent hover:border-line-strong"
- >
- {now.sends ? "Change in Act as me" : "Turn it on in Act as me"}
- </Link>
- </div>
- </SettingsCard>
- );
-}
-
// What Handle it for me sent this week.
function HandleItSection({ handleIt }: { handleIt: HandleIt }) {
const [handled, setHandled] = useState<HandledReply[] | null>(null);
diff --git a/packages/ui/src/components/settings/ReachCard.tsx b/packages/ui/src/components/settings/ReachCard.tsx
index 622add2e..c323d54e 100644
--- a/packages/ui/src/components/settings/ReachCard.tsx
+++ b/packages/ui/src/components/settings/ReachCard.tsx
@@ -1,10 +1,11 @@
"use client";
import Link from "next/link";
-import { useEffect, useState } from "react";
+import { useEffect, useState, type ReactNode } from "react";
import LeadRulesEditor from "@/components/settings/LeadRulesEditor";
import SettingsCard from "@/components/settings/SettingsCard";
+import Button from "@/components/ui/Button";
import {
addMyLeadRule,
deleteMyLeadRule,
@@ -14,297 +15,395 @@ import {
setTraining,
type DelegationSettings,
type LeadRule,
- type ReachStep,
} from "@/lib/api";
-import { HANDLE_IT_MODES, LEAD_LINE, REACH_ANCHOR, reachOf, sentTodayLine } from "@/lib/reach";
+import {
+ HANDLE_IT_MODES,
+ LEAD_LINE,
+ SENDS_ANCHOR,
+ WRITES_ANCHOR,
+ reachForSend,
+ sendOf,
+ writeOf,
+ type SendStep,
+ type WriteStep,
+} from "@/lib/reach";
+
+// What it writes and sends as you, from your own mailbox: one setting on the
+// server (PUT /delegation/reach) shown as two pickers. WritesCard, on
+// Delegate → Act as me, is the steps that write and never send. SendsCard,
+// on Delegate → Handle it for me, is the steps that send on their own, with
+// In training (delegation/training.py) and Your rules. Handle it for me
+// builds on the inbox replies, so SendsCard opens only once WritesCard is at
+// For my inbox too, and moving WritesCard below that says Handle it for me
+// stops too. Moving either down says what stops before it saves.
+
+type Step<T extends string> = { value: T; label: string; line: string; reason?: string | null };
+
+function useReachSave(onSettings: (next: DelegationSettings) => void) {
+ const [busy, setBusy] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const save = async (work: () => Promise<DelegationSettings>): Promise<boolean> => {
+ setBusy(true);
+ setError(null);
+ try {
+ onSettings(await work());
+ return true;
+ } catch (err) {
+ setError(err instanceof Error ? err.message : "Could not save the setting.");
+ // A refused move up can stop part way, at a lower step: show where it is.
+ try {
+ const now = await getDelegation();
+ if (now) onSettings(now);
+ } catch {
+ // Keep what's shown; the error above already says it didn't save.
+ }
+ return false;
+ } finally {
+ setBusy(false);
+ }
+ };
+ return { busy, error, save };
+}
-// How far it goes as you: the one dial for everything Act as me does from
-// your own mailbox (PUT /delegation/reach). It replaces three switches that
-// used to depend on each other out of sight: Write drafts as me, Draft
-// replies to my inbox and Handle it for me with its level. The first steps
-// write and never send; the rest are Handle it for me, which sends. Moving
-// down says what stops before it saves. In training (Replies and Follow-ups,
-// delegation/training.py) applies to the sending steps. It is shown on
-// Delegate → Act as me only; Handle it for me shows where it is and what it
-// sent, and links back here (REACH_HREF).
+// Linked from another tab (WRITES_HREF / SENDS_HREF): the card appears after
+// the settings load, so the browser's own jump to the anchor has passed it.
+function useJumpTo(anchor: string) {
+ useEffect(() => {
+ if (window.location.hash === `#${anchor}`) {
+ document.getElementById(anchor)?.scrollIntoView({ block: "start" });
+ }
+ }, [anchor]);
+}
-type Step = {
- value: ReachStep;
+function StepList<T extends string>({
+ name,
+ labelledBy,
+ steps,
+ current,
+ busy,
+ onPick,
+}: {
+ name: string;
+ labelledBy: string;
+ steps: Step<T>[];
+ current: T;
+ busy: boolean;
+ onPick: (step: T) => void;
+}) {
+ return (
+ <div role="radiogroup" aria-labelledby={labelledBy} className="flex flex-col gap-2">
+ {steps.map((step) => {
+ const checked = step.value === current;
+ const reason = step.reason;
+ return (
+ <label
+ key={step.value}
+ className={`flex items-start gap-3 rounded-xl border p-3.5 transition-colors ${
+ checked ? "border-accent/60 bg-accent/10" : "border-line bg-surface-elevated hover:border-line-strong"
+ } ${reason && !checked ? "cursor-not-allowed opacity-60" : "cursor-pointer"}`}
+ >
+ <input
+ type="radio"
+ name={name}
+ value={step.value}
+ checked={checked}
+ disabled={busy || (Boolean(reason) && !checked)}
+ onChange={() => onPick(step.value)}
+ className="mt-1 h-4 w-4 flex-shrink-0 accent-indigo-500"
+ />
+ <span className="min-w-0">
+ <span className="block text-[15px] font-medium text-fg">{step.label}</span>
+ <span className="mt-0.5 block text-sm text-fg-muted leading-snug">
+ {reason && !checked ? reason : step.line}
+ </span>
+ </span>
+ </label>
+ );
+ })}
+ </div>
+ );
+}
+
+function ConfirmDown({
+ text,
+ busy,
+ onConfirm,
+ onCancel,
+}: {
+ text: string;
+ busy: boolean;
+ onConfirm: () => void;
+ onCancel: () => void;
+}) {
+ return (
+ <div className="mt-4 rounded-xl border border-amber-500/40 bg-amber-500/10 p-4">
+ <p className="text-sm text-fg leading-relaxed">{text}</p>
+ <div className="mt-3 flex flex-wrap gap-2">
+ <button
+ type="button"
+ disabled={busy}
+ onClick={onConfirm}
+ className="h-9 rounded-lg bg-fg px-3 text-sm font-medium text-fg-inverse disabled:opacity-50"
+ >
+ {busy ? "Saving…" : "Move down"}
+ </button>
+ <button
+ type="button"
+ disabled={busy}
+ onClick={onCancel}
+ className="h-9 rounded-lg border border-line px-3 text-sm font-medium text-fg"
+ >
+ Cancel
+ </button>
+ </div>
+ </div>
+ );
+}
+
+function Check({
+ checked,
+ disabled,
+ onChange,
+ label,
+ help,
+ className = "",
+}: {
+ checked: boolean;
+ disabled: boolean;
+ onChange: (next: boolean) => void;
label: string;
- line: string;
- sends: boolean;
-};
+ help: string;
+ className?: string;
+}) {
+ return (
+ <label className={`flex cursor-pointer items-start gap-3 ${className}`}>
+ <input
+ type="checkbox"
+ checked={checked}
+ disabled={disabled}
+ onChange={(e) => onChange(e.target.checked)}
+ className="mt-0.5 h-5 w-5 flex-shrink-0 accent-indigo-500"
+ />
+ <span>
+ <span className="block text-[15px] font-semibold text-fg">{label}</span>
+ <span className="mt-0.5 block text-sm text-fg-muted leading-snug">{help}</span>
+ </span>
+ </label>
+ );
+}
+
+const WRITE_ORDER: WriteStep[] = ["off", "when_asked", "inbox"];
+
+// Delegate → Act as me: what it writes as you. `inbox` (the inbox watcher's
+// status, Check now and Also save in Drafts) shows under For my inbox too.
+export function WritesCard({
+ settings,
+ onSettings,
+ inbox,
+}: {
+ settings: DelegationSettings;
+ onSettings: (next: DelegationSettings) => void;
+ inbox?: ReactNode;
+}) {
+ const { busy, error, save } = useReachSave(onSettings);
+ const [confirming, setConfirming] = useState<WriteStep | null>(null);
+ useJumpTo(WRITES_ANCHOR);
-function stepsFor(settings: DelegationSettings, mailbox: string): Step[] {
- const sending: Step[] = HANDLE_IT_MODES.map((m) => ({
- value: m.mode,
- label: m.label,
- line: `${m.replies} Follow-ups: ${m.followUps}`,
- sends: true,
- }));
- return [
- { value: "off", label: "Off", line: "The Executive only ever writes as itself.", sends: false },
+ const mailbox = settings.gmail?.provider === "microsoft" ? "Outlook" : "Gmail";
+ const connected = settings.gmail?.status === "connected";
+ const current = writeOf(settings);
+ const sending = sendOf(settings) !== "off";
+ const needsMailbox = !connected && current === "off" ? "Connect your mailbox first." : null;
+ const steps: Step<WriteStep>[] = [
+ { value: "off", label: "Off", line: "The Executive only writes as itself." },
{
value: "when_asked",
- label: "Drafts when I ask",
+ label: "When I ask",
line: `Ask in chat, “reply to Dana as me: yes to the 5th”, and the draft waits in your ${mailbox} Drafts.`,
- sends: false,
+ reason: needsMailbox,
},
{
value: "inbox",
- label: "Drafts for my inbox",
- line: "It also writes a first reply to mail that needs you and puts it on Today. You tap Send.",
- sends: false,
+ label: "For my inbox too",
+ line: "It also writes a first reply to mail that needs you and puts it on Today.",
+ reason: needsMailbox,
},
- ...sending,
- ...(settings.handle_it?.lead_available
- ? [{ value: "everything" as ReachStep, label: "Everything", line: LEAD_LINE, sends: true }]
- : []),
];
-}
-// What moving from `from` down to `to` stops, in a sentence.
-function whatStops(steps: Step[], from: ReachStep, to: ReachStep): string {
- const i = steps.findIndex((s) => s.value === from);
- const j = steps.findIndex((s) => s.value === to);
- if (j >= i) return "";
- const target = steps[j];
- if (from === "everything" && target.sends) return "It goes back to sending only what this level allows.";
- if (steps[i].sends && target.sends) return "It sends less on its own: only what this level allows.";
- if (steps[i].sends && to === "inbox") return "It stops sending replies and follow-ups on its own. Every reply waits for you.";
- if (to === "when_asked") return "It stops writing replies to your inbox, and sends nothing on its own.";
- return "It stops writing anything as you, and turns Read my calendar off too.";
+ const pick = (to: WriteStep) => {
+ if (to === current) return;
+ if (WRITE_ORDER.indexOf(to) < WRITE_ORDER.indexOf(current)) {
+ setConfirming(to);
+ return;
+ }
+ void save(() => setReach(to));
+ };
+
+ const stops = (to: WriteStep): string => {
+ const handleIt = sending ? " Handle it for me stops sending too." : "";
+ if (to === "when_asked") return `It stops writing replies to your inbox.${handleIt}`;
+ return `It stops writing anything as you, and turns Read my calendar off too.${handleIt}`;
+ };
+
+ return (
+ <div id={WRITES_ANCHOR} className="scroll-mt-24">
+ <SettingsCard title="What it writes as you" titleId="writes-label" description="Nothing goes out until you send it.">
+ <StepList name="writes" labelledBy="writes-label" steps={steps} current={current} busy={busy} onPick={pick} />
+ {confirming && (
+ <ConfirmDown
+ text={`Move to ${steps.find((s) => s.value === confirming)?.label}? ${stops(confirming)}`}
+ busy={busy}
+ onConfirm={() => void save(() => setReach(confirming)).then((ok) => ok && setConfirming(null))}
+ onCancel={() => setConfirming(null)}
+ />
+ )}
+ {current === "inbox" && inbox && <div className="mt-4">{inbox}</div>}
+ {current !== "off" && (
+ <Check
+ className="mt-5 border-t border-line pt-4"
+ checked={Boolean(settings.training?.drafts)}
+ disabled={busy}
+ onChange={(learn) => void save(() => setTraining({ drafts: learn }))}
+ label="Learn from my edits"
+ help="When you change a draft before sending, tick Do it like this next time and it learns how you write to that person. Nothing more is sent."
+ />
+ )}
+ {error && <p className="mt-3 text-sm text-red-500">{error}</p>}
+ </SettingsCard>
+ </div>
+ );
}
-export default function ReachCard({
+// Delegate → Handle it for me: what it sends as you on its own.
+export function SendsCard({
settings,
onSettings,
}: {
settings: DelegationSettings;
onSettings: (next: DelegationSettings) => void;
}) {
- const [busy, setBusy] = useState(false);
- const [error, setError] = useState<string | null>(null);
- const [confirming, setConfirming] = useState<ReachStep | null>(null);
-
- // Linked from Handle it for me or What it may do (REACH_HREF): the card
- // appears after the settings load, so the browser's own jump to the
- // anchor has already passed it.
- useEffect(() => {
- if (window.location.hash === `#${REACH_ANCHOR}`) {
- document.getElementById(REACH_ANCHOR)?.scrollIntoView({ block: "start" });
- }
- }, []);
+ const { busy, error, save } = useReachSave(onSettings);
+ const [confirming, setConfirming] = useState<SendStep | null>(null);
+ useJumpTo(SENDS_ANCHOR);
- const mailbox = settings.gmail?.provider === "microsoft" ? "Outlook" : "Gmail";
- const steps = stepsFor(settings, mailbox);
- const current = reachOf(settings);
- const currentStep = steps.find((s) => s.value === current);
- const sending = Boolean(currentStep?.sends);
+ const connected = settings.gmail?.status === "connected";
+ const writesInbox = writeOf(settings) === "inbox";
+ const current = sendOf(settings);
const training = Boolean(settings.training?.replies);
const followUpsTraining = Boolean(settings.training?.follow_ups);
- const connected = settings.gmail?.status === "connected";
const canSend = Boolean(settings.handle_it?.available);
+ const noSigning = canSend ? null : "Needs signed sign-ins on this server.";
- const save = async (work: () => Promise<DelegationSettings>) => {
- setBusy(true);
- setError(null);
- try {
- onSettings(await work());
- setConfirming(null);
- } catch (err) {
- setError(err instanceof Error ? err.message : "Could not save the setting.");
- // A refused move up can stop part way, at a lower step: show where it is.
- try {
- const now = await getDelegation();
- if (now) onSettings(now);
- } catch {
- // Keep what's shown; the error above already says it didn't save.
- }
- } finally {
- setBusy(false);
- }
- };
+ const steps: Step<SendStep>[] = [
+ { value: "off", label: "Off", line: "Every reply waits for you to send." },
+ ...HANDLE_IT_MODES.map((m) => ({
+ value: m.mode as SendStep,
+ label: m.label,
+ line: `${m.replies} Follow-ups: ${m.followUps}`,
+ reason: noSigning,
+ })),
+ ...(settings.handle_it?.lead_available
+ ? [
+ {
+ value: "everything" as SendStep,
+ label: "Everything",
+ line: LEAD_LINE,
+ reason: noSigning ?? (training || followUpsTraining ? "Opens up once it's out of training." : null),
+ },
+ ]
+ : []),
+ ];
+ const order = steps.map((s) => s.value);
- const pick = (to: ReachStep) => {
+ const pick = (to: SendStep) => {
if (to === current) return;
- const i = steps.findIndex((s) => s.value === current);
- const j = steps.findIndex((s) => s.value === to);
- if (j < i) {
+ if (order.indexOf(to) < order.indexOf(current)) {
setConfirming(to);
return;
}
- void save(() => setReach(to));
+ void save(() => setReach(reachForSend(to)));
};
- const disabledReason = (step: Step): string | null => {
- if (step.value === "off") return null;
- if (!connected && current === "off") return "Connect your mailbox first.";
- if (step.sends && !canSend) return "Needs signed sign-ins on this server.";
- if (step.value === "everything" && (training || followUpsTraining)) return "Opens up once it's out of training.";
- return null;
+ const stops = (to: SendStep): string => {
+ if (to === "off") return "It stops sending replies and follow-ups on its own. Every reply waits for you.";
+ if (current === "everything") return "It goes back to sending only what this level allows.";
+ return "It sends less on its own: only what this level allows.";
};
- const groups: { title: string; steps: Step[] }[] = [
- { title: "Writes as you, never sends", steps: steps.filter((s) => !s.sends) },
- { title: "Handle it for me sends as you", steps: steps.filter((s) => s.sends) },
- ];
-
return (
- <div id={REACH_ANCHOR} className="scroll-mt-24">
- <SettingsCard
- title="How far it goes as you"
- titleId="reach-label"
- description="One setting for everything it writes or sends from your own mailbox. Each step adds to the one above it."
- >
- <div role="radiogroup" aria-labelledby="reach-label" className="flex flex-col gap-5">
- {groups.map((group) => (
- <div key={group.title}>
- <h3 className="mb-2 text-xs font-medium uppercase tracking-wider text-fg-subtle">{group.title}</h3>
- <div className="flex flex-col gap-2">
- {group.steps.map((step) => {
- const checked = step.value === current;
- const reason = disabledReason(step);
- return (
- <label
- key={step.value}
- className={`flex items-start gap-3 rounded-xl border p-3.5 transition-colors ${
- checked ? "border-accent/60 bg-accent/10" : "border-line bg-surface-elevated hover:border-line-strong"
- } ${reason && !checked ? "cursor-not-allowed opacity-60" : "cursor-pointer"}`}
- >
- <input
- type="radio"
- name="reach"
- value={step.value}
- checked={checked}
- disabled={busy || (Boolean(reason) && !checked)}
- onChange={() => pick(step.value)}
- className="mt-1 h-4 w-4 flex-shrink-0 accent-indigo-500"
- />
- <span className="min-w-0">
- <span className="block text-[15px] font-medium text-fg">{step.label}</span>
- <span className="mt-0.5 block text-sm text-fg-muted leading-snug">
- {reason && !checked ? reason : step.line}
- </span>
- </span>
- </label>
- );
- })}
- </div>
+ <div id={SENDS_ANCHOR} className="scroll-mt-24">
+ <SettingsCard
+ title="What it sends on its own"
+ titleId="sends-label"
+ description="It answers from the replies Act as me writes for your inbox."
+ >
+ {!writesInbox ? (
+ <div className="flex flex-col items-start gap-3">
+ <p className="text-sm text-fg-muted leading-relaxed">
+ It needs Act as me to write replies for your inbox first.
+ </p>
+ {connected ? (
+ <Button variant="primary" disabled={busy} onClick={() => void save(() => setReach("inbox"))}>
+ {busy ? "Turning on…" : "Turn on For my inbox too"}
+ </Button>
+ ) : (
+ <Link
+ href="/delegate/act-as-me"
+ className="inline-flex h-10 items-center rounded-lg border border-line bg-surface px-4 text-sm font-semibold text-accent hover:border-line-strong"
+ >
+ Connect your mailbox in Act as me
+ </Link>
+ )}
</div>
- ))}
- </div>
-
- {confirming && (
- <div className="mt-4 rounded-xl border border-amber-500/40 bg-amber-500/10 p-4">
- <p className="text-sm text-fg leading-relaxed">
- Move to {steps.find((s) => s.value === confirming)?.label}? {whatStops(steps, current, confirming)}
- </p>
- <div className="mt-3 flex flex-wrap gap-2">
- <button
- type="button"
- disabled={busy}
- onClick={() => void save(() => setReach(confirming))}
- className="h-9 rounded-lg bg-fg px-3 text-sm font-medium text-fg-inverse disabled:opacity-50"
- >
- {busy ? "Saving…" : "Move down"}
- </button>
- <button
- type="button"
- disabled={busy}
- onClick={() => setConfirming(null)}
- className="h-9 rounded-lg border border-line px-3 text-sm font-medium text-fg"
- >
- Cancel
- </button>
- </div>
- </div>
- )}
-
- {/* Shown from Drafts for my inbox up, so it can be in training before
- the first move to a step that sends: training stays across moves. */}
- {(sending || current === "inbox") && (
- <div className="mt-5 flex flex-col gap-3 border-t border-line pt-4">
- <label className="flex cursor-pointer items-start gap-3">
- <input
- type="checkbox"
- checked={training}
- disabled={busy || current === "everything"}
- onChange={(e) => {
- const train = e.target.checked;
- void save(() => setTraining({ replies: train, follow_ups: train }));
- }}
- className="mt-0.5 h-5 w-5 flex-shrink-0 accent-indigo-500"
- />
- <span>
- <span className="block text-[15px] font-semibold text-fg">In training</span>
- <span className="mt-0.5 block text-sm text-fg-muted leading-snug">
- {current === "everything"
- ? "Move to Most mail or below to train it."
- : !sending
- ? "Tick this before moving to a step that sends, and every reply comes to you first until you allow that person."
- : "Every reply comes to you first. Tap Send + allow and it handles that person on its own from then on, within this step."}
- </span>
- </span>
- </label>
- {(training || followUpsTraining) && (
- <label className="ml-8 flex cursor-pointer items-start gap-3">
- <input
- type="checkbox"
- checked={followUpsTraining}
- disabled={busy}
- onChange={(e) => {
- const train = e.target.checked;
- void save(() => setTraining({ follow_ups: train }));
- }}
- className="mt-0.5 h-5 w-5 flex-shrink-0 accent-indigo-500"
+ ) : (
+ <>
+ <StepList name="sends" labelledBy="sends-label" steps={steps} current={current} busy={busy} onPick={pick} />
+ {confirming && (
+ <ConfirmDown
+ text={`Move to ${steps.find((s) => s.value === confirming)?.label}? ${stops(confirming)}`}
+ busy={busy}
+ onConfirm={() =>
+ void save(() => setReach(reachForSend(confirming))).then((ok) => ok && setConfirming(null))
+ }
+ onCancel={() => setConfirming(null)}
/>
- <span>
- <span className="block text-[15px] font-semibold text-fg">Train follow-ups too</span>
- <span className="mt-0.5 block text-sm text-fg-muted leading-snug">
- Untick to let follow-ups go out at this step while replies stay in training.
- </span>
- </span>
- </label>
- )}
- <p className="text-sm text-fg-muted">
- Money, contracts, legal, hiring, the press and passwords always wait for you, and it never writes to anyone
- the email didn&apos;t go to.
- </p>
- </div>
- )}
- {current !== "off" && (
- <label className="mt-5 flex cursor-pointer items-start gap-3 border-t border-line pt-4">
- <input
- type="checkbox"
- checked={Boolean(settings.training?.drafts)}
- disabled={busy}
- onChange={(e) => {
- const learn = e.target.checked;
- void save(() => setTraining({ drafts: learn }));
- }}
- className="mt-0.5 h-5 w-5 flex-shrink-0 accent-indigo-500"
- />
- <span>
- <span className="block text-[15px] font-semibold text-fg">Learn from my edits</span>
- <span className="mt-0.5 block text-sm text-fg-muted leading-snug">
- When you change a draft before sending, tick Do it like this next time and it learns how you write to
- that person. Nothing more is sent.
- </span>
- </span>
- </label>
- )}
- {current === "everything" && <YourRules />}
- {sending && (
- <p className="mt-5 border-t border-line pt-4 text-sm text-fg-muted">
- {sentTodayLine(settings.handle_it?.sent_today ?? 0)}{" "}
- <Link href="/delegate/handle-it" className="font-medium text-accent underline-offset-2 hover:underline">
- What it sent
- </Link>
- </p>
- )}
- {error && <p className="mt-3 text-sm text-red-500">{error}</p>}
- </SettingsCard>
+ )}
+ {/* Shown at Off too, so it can be in training before the first
+ move to a step that sends: training stays across moves. */}
+ <div className="mt-5 flex flex-col gap-3 border-t border-line pt-4">
+ <Check
+ checked={training}
+ disabled={busy || current === "everything"}
+ onChange={(train) => void save(() => setTraining({ replies: train, follow_ups: train }))}
+ label="In training"
+ help={
+ current === "everything"
+ ? "Move to Most mail or below to train it."
+ : current === "off"
+ ? "Tick this before moving up, and every reply comes to you first until you allow that person."
+ : "Every reply comes to you first. Tap Send + allow and it handles that person on its own from then on, within this step."
+ }
+ />
+ {(training || followUpsTraining) && (
+ <Check
+ className="ml-8"
+ checked={followUpsTraining}
+ disabled={busy}
+ onChange={(train) => void save(() => setTraining({ follow_ups: train }))}
+ label="Train follow-ups too"
+ help="Untick to let follow-ups go out at this step while replies stay in training."
+ />
+ )}
+ <p className="text-sm text-fg-muted">
+ Money, contracts, legal, hiring, the press and passwords always wait for you, and it never writes to
+ anyone the email didn&apos;t go to.
+ </p>
+ </div>
+ {current === "everything" && <YourRules />}
+ </>
+ )}
+ {error && <p className="mt-3 text-sm text-red-500">{error}</p>}
+ </SettingsCard>
</div>
);
}
diff --git a/packages/ui/src/components/settings/ReplyDisclosureCard.tsx b/packages/ui/src/components/settings/ReplyDisclosureCard.tsx
index 90de0c6e..b53a6d9b 100644
--- a/packages/ui/src/components/settings/ReplyDisclosureCard.tsx
+++ b/packages/ui/src/components/settings/ReplyDisclosureCard.tsx
@@ -10,7 +10,7 @@ type Switch = "handle_it" | "approved_sends";
const SWITCHES: { key: Switch; label: string; help: string }[] = [
{
key: "handle_it",
- label: "Sent on their own (Handle it for me)",
+ label: "Replies it sends on its own",
help: "No one reads these before they go.",
},
{
@@ -20,17 +20,22 @@ const SWITCHES: { key: Switch; label: string; help: string }[] = [
},
];
-// On Delegate → Act as me: your own switches for the AI line on replies sent
-// as you (PUT /delegation/disclosure, delegation/disclosure.py). The line is
+// Under Advanced on Delegate → Act as me (`only="approved_sends"`) and on
+// Handle it for me (`only="handle_it"`): your own switch for the AI line on
+// replies sent as you (PUT /delegation/disclosure, delegation/disclosure.py). The line is
// written into each reply when it's drafted, so a change applies to the next
// one. Turning off the Handle it line asks first. Nothing shows when the
// install has AI disclosure off.
export default function ReplyDisclosureCard({
disclosure,
onSettings,
+ only,
+ title,
}: {
disclosure: ReplyDisclosure;
onSettings: (next: DelegationSettings) => void;
+ only: Switch;
+ title: string;
}) {
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
@@ -61,11 +66,11 @@ export default function ReplyDisclosureCard({
return (
<SettingsCard
- title="Replies sent from your mailbox"
- description={`Choose which replies end with “${disclosure.line}”, so people can tell your AI assistant wrote them.`}
+ title={title}
+ description={`Choose whether these replies end with “${disclosure.line}”, so people can tell your AI assistant wrote them.`}
>
<div className="flex flex-col gap-4">
- {SWITCHES.map((s) => (
+ {SWITCHES.filter((s) => s.key === only).map((s) => (
<label key={s.key} className="flex cursor-pointer items-start gap-3">
<input
id={`reply-disclosure-${s.key}`}
diff --git a/packages/ui/src/components/settings/TrainingCard.tsx b/packages/ui/src/components/settings/TrainingCard.tsx
index 712d16b3..e64405a3 100644
--- a/packages/ui/src/components/settings/TrainingCard.tsx
+++ b/packages/ui/src/components/settings/TrainingCard.tsx
@@ -13,21 +13,22 @@ import {
type TrainingSetting,
} from "@/lib/api";
-// Training on Delegate → Act as me (delegation/training.py), the way Take the
-// lead has it: like someone new, each job can be In training, where it brings
-// you its work first and learns who and how from what you approve. Replies,
-// follow-ups and drafts are trained from How far it goes as you (ReachCard);
-// this file holds the note at the top, the Suggested actions card
-// (Always ask / In training, PUT /delegation/training) and, at the bottom, one
-// "What it's learned" list, each item named by its job, with Remove
+// Training on Delegate (delegation/training.py), the way Take the lead has
+// it: like someone new, each job can be In training, where it brings you its
+// work first and learns who and how from what you approve. Replies and
+// follow-ups are trained from What it sends on its own (SendsCard, Handle it
+// for me), drafts from What it writes as you (WritesCard, Act as me). This
+// file holds the Suggested actions card (Always ask / In training,
+// PUT /delegation/training) and the learned list, shown on each tab for its
+// own jobs, each item named by its job, with Remove
// (DELETE /delegation/learned/{id}).
// The job each learned item came from, as its card is titled.
const JOB_NAMES: Record<TrainingSetting, string> = {
- replies: "Handle it for me, replies",
- follow_ups: "Handle it for me, follow-ups",
+ replies: "Replies",
+ follow_ups: "Follow-ups",
actions: "Suggested actions",
- drafts: "Write drafts as me",
+ drafts: "Drafts",
};
function useSave(onSettings: (next: DelegationSettings) => void) {
@@ -47,18 +48,6 @@ function useSave(onSettings: (next: DelegationSettings) => void) {
return { busy, error, run };
}
-export function TrainingNote() {
- return (
- <section className="rounded-2xl border border-accent/30 bg-accent/5 p-5 sm:p-6">
- <h2 className="text-base sm:text-lg font-semibold text-fg">Start it in training</h2>
- <p className="mt-1 text-sm text-fg leading-relaxed">
- Like anyone you hire, it can start each job in training: it brings you its work first and learns from what you
- approve. When you trust it with a job, move that job to On.
- </p>
- </section>
- );
-}
-
type ActionsMode = "ask" | "training";
export function SuggestedActionsCard({
@@ -109,29 +98,33 @@ function learnedLine(item: TrainingLearned): string {
return parts.join(" · ");
}
-// Shown while any job is in training or something is on the list.
+// What it learned for `jobs`, shown while one of them is in training or
+// something of theirs is on the list.
export function LearnedCard({
training,
onSettings,
+ jobs,
+ title,
+ description,
}: {
training: Training;
onSettings: (next: DelegationSettings) => void;
+ jobs: TrainingSetting[];
+ title: string;
+ description: string;
}) {
const { busy, error, run } = useSave(onSettings);
- const learned = training.learned;
- const anyOn = training.replies || training.follow_ups || training.actions || training.drafts;
+ const learned = training.learned.filter((item) => jobs.includes(item.setting));
+ const anyOn = jobs.some((job) => Boolean(training[job]));
if (!anyOn && learned.length === 0) return null;
+ const titleId = `learned-${jobs.join("-")}-label`;
return (
- <SettingsCard
- title="What it's learned"
- titleId="act-as-me-learned-label"
- description="From its training. Yours alone. Remove one and it asks you again."
- >
+ <SettingsCard title={title} titleId={titleId} description={description}>
{learned.length === 0 ? (
<p className="text-sm text-fg-muted">Nothing yet.</p>
) : (
<ul
- aria-labelledby="act-as-me-learned-label"
+ aria-labelledby={titleId}
className="flex flex-col divide-y divide-line rounded-xl border border-line"
>
{learned.map((item) => (
diff --git a/packages/ui/src/lib/reach.ts b/packages/ui/src/lib/reach.ts
index cadd3454..5eadf69b 100644
--- a/packages/ui/src/lib/reach.ts
+++ b/packages/ui/src/lib/reach.ts
@@ -1,12 +1,20 @@
import type { DelegationSettings, HandleItMode, ReachStep } from "@/lib/api";
-// How far it goes as you: the one dial for everything Act as me does from
-// your own mailbox (PUT /delegation/reach). It lives on Delegate → Act as me
-// only; Handle it for me and What it may do show where it is and link here.
+// What it writes and sends as you, from your own mailbox. One setting on the
+// server (PUT /delegation/reach), shown as two pickers: What it writes as
+// you on Delegate → Act as me (Off, When I ask, For my inbox too) and What it
+// sends on its own on Delegate → Handle it for me (Off, then the sending
+// steps). Handle it for me builds on the inbox replies Act as me writes, so
+// its picker opens once the first one is at For my inbox too.
-// Where the dial sits on Act as me, for links from the other tabs.
-export const REACH_HREF = "/delegate/act-as-me#how-far";
-export const REACH_ANCHOR = "how-far";
+// Where each picker sits, for links from the other tabs.
+export const WRITES_ANCHOR = "writes";
+export const SENDS_ANCHOR = "sends";
+export const WRITES_HREF = `/delegate/act-as-me#${WRITES_ANCHOR}`;
+export const SENDS_HREF = `/delegate/handle-it#${SENDS_ANCHOR}`;
+
+export type WriteStep = "off" | "when_asked" | "inbox";
+export type SendStep = "off" | HandleItMode | "everything";
// The sending steps, which are Handle it for me.
export const HANDLE_IT_MODES: { mode: HandleItMode; label: string; replies: string; followUps: string }[] = [
@@ -42,32 +50,21 @@ export function reachOf(settings: DelegationSettings): ReachStep {
return h.mode;
}
-export function stepLabel(step: ReachStep): string {
- if (step === "off") return "Off";
- if (step === "when_asked") return "Drafts when I ask";
- if (step === "inbox") return "Drafts for my inbox";
- if (step === "everything") return "Everything";
- return HANDLE_IT_MODES.find((m) => m.mode === step)?.label ?? step;
+// Act as me's picker: a sending step writes for the inbox too.
+export function writeOf(settings: DelegationSettings): WriteStep {
+ const step = reachOf(settings);
+ return step === "off" || step === "when_asked" ? step : "inbox";
}
-// Where the dial is, for the Handle it for me tab: the step, whether that
-// step sends, whether it's in training, and one line on what it means.
-export function reachSummary(settings: DelegationSettings): {
- label: string;
- sends: boolean;
- training: boolean;
- line: string;
-} {
+// Handle it for me's picker: off below the sending steps.
+export function sendOf(settings: DelegationSettings): SendStep {
const step = reachOf(settings);
- const mode = HANDLE_IT_MODES.find((m) => m.mode === step);
- const sends = Boolean(mode) || step === "everything";
- const training = sends && step !== "everything" && Boolean(settings.training?.replies || settings.training?.follow_ups);
- const line = mode
- ? mode.replies
- : step === "everything"
- ? LEAD_LINE
- : "Handle it for me is off. Every reply waits for you to tap Send.";
- return { label: stepLabel(step), sends, training, line };
+ return step === "off" || step === "when_asked" || step === "inbox" ? "off" : step;
+}
+
+// The reach step a pick on Handle it for me saves: Off keeps the inbox replies.
+export function reachForSend(step: SendStep): ReachStep {
+ return step === "off" ? "inbox" : step;
}
export function sentTodayLine(n: number): string {