Omagma agent CLI#
Experimental: verify account capabilities and operation receipts before live tasks. API behavior and commands may change as the terminal client develops. The feature catalogue groups the main capabilities and smaller workflow conveniences.
This guide describes the current CLI. Release bundles need no compiler; build-info reports compiler/build information. Agent setup and the setup workflow cover installation.
Authorize live features through full TUI/CLI permissions. A user's own configured account can be used after consent; fixtures are an optional disconnected preview, and a dedicated test mailbox is not a user setup prerequisite. An agent still needs the user's task authorization before sending mail or changing mailbox/contact data. Read access is not permission to widen grants or perform unrelated writes.
Fixture accounts expose mock send, mailbox-change, contact and RSVP capabilities without OAuth or Google access. Inspect accounts.list when selecting capabilities for an actual account.
Discover commands#
The executable reveals details as you ask for them. Help needs no account configuration, authorization or network access.
| Command | Shows |
|---|---|
omagma --help |
Short overview of command families |
omagma cli --help |
JSONL quickstart and the actual command names grouped by namespace |
omagma cli --help commands |
Every supported JSONL cmd with a description |
omagma cli --help mail |
Only the JSONL commands in that namespace |
omagma mail --help |
Mail operations with short descriptions |
omagma mail read --help |
That operation's flags, JSONL fields and example |
omagma mail read --help-all |
Scoped operation help plus shared defaults and advanced flags |
omagma draft create --help-all |
Compose flags plus the complete bare Draft file schema |
omagma contacts upsert --help-all |
Contact flags plus the complete bare Contact file schema |
omagma cli --help-options |
Launch/config/cache/fixture/resource options |
omagma cli --help mail.read |
Compact card: summary, capabilities, required and optional fields with types, defaults and enums, and one example |
omagma cli --manifest |
One compact JSON index of every command: summary, capabilities, required/optional fields, whether it mutates (mutatesWhen names a conditional trigger such as reconcile:true) and its idempotency key |
omagma cli --schema mail.read |
Machine-readable JSON Schema for that request, with all referenced types included |
omagma cli --schema mail.read --compact |
The same schema minified, without the shared id/grantFile block |
omagma cli --schema |
Machine-readable schemas for all public JSONL commands |
omagma cli --help-all |
Complete offline JSONL reference, including shared object definitions |
omagma --help-all |
Extended command overview |
Start with accounts.list, then use a returned enabled account and its
capabilities. Follow message IDs from list replies into read requests, and check
ok on every response. The command catalogue and schemas are embedded in the
executable and work offline without configuration or credentials; the printed
documentation link supplies additional background. Command schemas describe
the supported public request fields. Stateful permissions, byte quotas,
content hashes and provider checks still apply when executing a request.
CLI convenience operations can perform several JSONL calls: Spam/Not spam uses
mail.batch, and conversation actions resolve mail.triage-scope before applying
an explicit batch. Contextual help describes those differences.
Verify agent access#
On a new Mac setup, choose Interactive or Agent-enabled
before consent. Interactive uses native Keychain by default in a local unlocked
terminal. Agent-enabled uses the same executable with private owner-only,
unencrypted token files. Preserve an existing explicit choice during repairs.
Changing the store needs no Google reauthorization: use the documented
credential migration from a context able to read the source, then restart open
sessions. omagma credentials status --json reports the selected store without
token contents; it is a standalone command, not a JSONL account operation.
File credentials avoid Keychain audit-session restrictions, but the agent sandbox must still permit the selected config, grant registry, credential and cache files and Google network access. Setup does not grant those permissions automatically. Use the agent's supported permission mechanism when access is denied; a local TUI working in another terminal is insufficient evidence.
For Agent-enabled setup, run real CLI subprocesses from the intended agent context, using the installed executable and actual private paths:
omagma credentials status --json --config /absolute/private/config.json
omagma terminal-auth status --account personal@example.com \
--config /absolute/private/config.json
omagma cli --config /absolute/private/config.json <<'EOF'
{"id":"accounts","cmd":"accounts.list"}
{"id":"mail","cmd":"mail.list","account":"personal@example.com","label":"INBOX","limit":1}
{"id":"contacts","cmd":"contacts.list","account":"personal@example.com","limit":1}
EOF
omagma mail read --account personal@example.com --message-id RETURNED_MESSAGE_ID \
--config /absolute/private/config.json
Use a message ID returned by the live list. Repeat per requested account and
include a custom --grant-file consistently when configured. Skip the mail
read if the mailbox page is empty; skip contacts only when that access was not
requested. A successful empty page is valid. accounts.list checks configured
accounts/capabilities; successful live mail/contact responses establish provider
access. Require ok:true for each JSONL response; process exit alone does not
prove that every request succeeded. Do not use --fixtures, --cached or
cacheOnly:true for this check.
Keep stdout and agent logs private because successful responses contain real
mail/contact data. Verification uses reads and needs no test send or mutation.
For Interactive setup, verify in the user's local unlocked terminal and state
when agent subprocess access has not been checked.
Expired sign-in (InvalidGrant)#
InvalidGrant means Google refused the account's stored refresh token; a retry
fails the same way. auth.status then reports lastRefreshError, for example
{"error":"invalid_grant","subtype":"invalid_rapt","description":"reauth related error (invalid_rapt)","kind":"reauthenticationRequired","at":1762851600000}.
kind is reauthenticationRequired (a Workspace re-authentication policy),
expiredOrRevoked (revoked access, a password change or a Testing-mode
project's seven-day limit, which Google words identically) or
invalidGrant; null means no refusal of the recorded terminal grant is
known. The description is sanitized, printable ASCII of at most 160 bytes with
credential-shaped runs (known token prefixes, long mixed-case or hex runs)
replaced by [redacted]; ordinary words and help URLs stay readable, and no
field contains token material. Only refusals of the current terminal grant
(by grant.grantId) are reported, never the bar's read-only credential.
grantId names the capability set, so a reconnect keeps it: a refusal is
reported only while it is newer than the grant's latest verified refresh or
authorization in any process (a request that still used a replaced token
cannot outdate a reconnect). Plaintext credential stores keep this beside the
grant registry, under a lock, for later and concurrent processes; the
encrypted vault keeps it in the running backend only. auth.revoke removes it.
Reconnecting needs the user's browser consent, so ask the user first. The user
can press Ctrl+O in the TUI. From an agent context, read auth.status, then
send auth.authorize with reconnect:true, exactly grant.capabilities and
expectedGrantId set to grant.grantId:
{"id":"renew","cmd":"auth.authorize","account":"personal@example.com","capabilities":["mail-read","mail-send"],"reconnect":true,"expectedGrantId":"<grant.grantId>"}
A different capability set fails with ReconnectCapabilitiesChanged, a grant
changed since the read with GrantChanged, a malformed expectedGrantId with
InvalidRequest, a registration file whose client ID is not the grant's
clientId (an explicit clientFile, or another registration now at the
recorded path) with ReconnectRegistrationChanged, a disabled grant with
GrantDisabled and an account without a recorded terminal grant with
ReconnectRequiresGrant, all before consent. Another spelling of the same
registration file (a symlink, a relative path) is accepted.
While waiting for consent the request fails with AuthorizationDenied or
Timeout (no answer within 180 seconds), storing nothing. Once Google's
callback has arrived, a cancellation or disconnect no longer stops it: the
exchange, the identity check and the store finish within 25 seconds. A failure
then says how far it got. WrongAccount (another Google account signed in),
UnexpectedScope (a requested permission was unchecked) and
TokenExchangeFailed stored nothing. SignInStoreUnconfirmed means the store
began and its outcome is unknown: check auth.status or one read of the
account before authorizing again. Both name the underlying error in cause.
Success returns reconnected:true and outdates lastRefreshError; an already
open session uses the renewed credential for its next request without a
restart.
CLI and TUI coverage#
The JSONL agent CLI and TUI share the same backend operations, terminal grant, account checks, cache and mutation receipts. Reading full messages/threads, cache/server search, reply/reply-all, forwarding, sending attachments, archive/Trash/restore, stars/read state, label assignment and collection management, bulk actions/undo, contact list/search/create/update, custom-label colors, private browser preview, local draft discard, Spam/Not spam and invitation replies are available to both. The complete permission setup enables both interfaces for the authorized account.
The TUI adds interactive conveniences: Vim/mouse navigation, styled HTML and
tables, pane layouts, action discovery, current-message find, unread navigation,
search history/named searches, staged label checkboxes, link/file choosers,
quote/signature/thread folding, saved layouts/keymaps, $EDITOR, native text
undo, recipient/path completion and automatic local draft recovery.
CLI callers supply recipients and body source (including through
--body-file or --body-stdin) and explicitly save/update/recover drafts.
The CLI returns decoded plain text and structured data rather than the styled
screen, and can request up to 100 messages per page rather than the TUI's
32-message display window.
The command table below is the backend contract. One-shot commands
cover common operations; JSONL supplies arrays and structured fields for richer
requests. Drafts are local in both interfaces, with optional explicit
Gmail draft handoff.
Both native interfaces support Calendar reads and reviewed imports,
plus reviewed ordinary timed/all-day event creation, editing and rescheduling,
generated Google Meet details and pasted HTTPS meeting links, and reviewed
deletes and invitation answers on existing events (calendar.event-delete-review,
calendar.event-respond-review; see
Delete events and answer invitations). Uncertain saves
survive restart and support read-only checks, explicitly confirmed
identical-request retry and uncertainty archival. The TUI adds agenda/day/week
views and a guest picker using the destination account's Contacts (with an
explicit bounded contacts.search). Its Guests field accepts Mail address-list
paste; CLI callers supply bare guest emails in event.attendees. See the
Calendar event guide. A new Google Meet event can also
turn on automatic AI notes and transcription through calendar.meet-event-review
and calendar.meet-event-apply; see
Automatic Meet AI notes.
Native Calendar persistence pages settled invitation identities and operation
receipts instead of expiring UID/version or cancellation protection after 256
events. Pending reviews and uncertain claims remain in the bounded active
document. The browser demo retains its smaller storage tier.
Permanent mail deletion and contact deletion remain unavailable. Label support
includes listing, assigning/removing existing labels and creating, renaming,
coloring or deleting custom definitions. Shared target resolution and membership
counts support reviewed conversation/bulk workflows. The CLI also exposes the
durable local send queue; its delay is explicit rather than the TUI's default
countdown.
Software updates#
omagma updates status|check|guide|dismiss [--json] shares the TUI's release
state and installation-aware guidance. status is cached; check explicitly
requests public release metadata. guide --json includes versions,
installation ownership, commands and instructions. omagma updates automatic on|off changes the persisted daily-check preference. These standalone commands
need no account configuration or Google authorization and are separate from
the account-scoped JSONL protocol. See updates.
Protocol#
omagma cli (alias omagma agent) reads one JSON object per line and emits one response per line. stdout contains only protocol frames. EOF ends the process; malformed/oversized frames produce errors and the next frame can proceed. Each response echoes id and account:
{"version":1,"id":"list-1","ok":true,"account":"personal@example.com","data":{"messages":[],"nextCursor":null}}
Errors use ok:false,error:{code,message}; code is the stable contract and
message a human sentence. When known, the error also names the field, the
expected type, enum, minimum/maximum or required list, a hint with
the next step, retryable, configured addresses for UnknownAccount and
didYouMean for a misspelled field, an abbreviation (q → query) or cmd.
retryable:true means the same request may succeed later unchanged:
CacheBusy, RateLimited, VaultBusy, refused connections, and interruptions
(Timeout, Canceled, TransientFailure, NetworkFailure, reset connections) of a
read or of a write that has its own replay identity (operationId, or
undoToken for mail.undo). An interrupted write without such an identity
— for example contacts.upsert, mail.archive/mark/batch, reminder.*
or draft.create/update/patch — may already have been applied, so its
error omits retryable and its hint names the read that settles it
(mail.read/mail.label-state, contacts.search, reminder.list, draft.list).
retryable:false marks UnknownOutcome and request errors.
Requests are strict. Every field must appear in the command's schema
(omagma cli --schema CMD). An unknown or misspelled field, at the top level
or inside draft, event, contact or set, is refused before anything
runs, for example
{"code":"UnknownField","field":"draft.body","message":"draft.create has no field 'draft.body'","didYouMean":"draft.bodyText","validFields":[...],"help":"omagma cli --schema draft.create"}.
Returned objects can be passed back unchanged: a draft from draft.read
(including contentDigest/gmailLink) or a contact with readWarnings.
draft.update compares those read-only draft fields with the saved draft: a
contentDigest that no longer matches fails ReviewedDraftChanged (the draft
changed since that read) and an edited gmailLink/summaryCounts fails
ReadOnlyFieldChanged. draft.patch never accepts them, a different id or
recoveryFields in set (ReadOnlyField); bind a patch to a reviewed version
with expectedContentDigest. Nested objects of a write must declare their
fields in the schema; an undeclared nested object is refused, not ignored.
replyAll is an accepted alias of all on mail.reply.
A repeated JSON key is refused as InvalidRequest ("duplicate key").
id may be a string, integer or null.
Ordinary requests are at most 3 MiB; nesting is limited to 64. Selected native
compose commands, including replies, forwards, draft editing/review and
submission, allow up to 420 MiB of serialized JSON under the explicit
native compose policy. This ceiling accounts
for escaping and multiple text alternatives; storage grows with actual content,
and body, attachment and outgoing MIME limits still apply. Portable browser
requests retain the 3 MiB limit. See all limits.
Optional string fields must be strings or omitted, not JSON null. Tokens never
appear in this interface.
Except accounts.list, every command requires an explicit configured account. omagma cli --account ADDRESS fills it in for lines that omit it; a line's own account always wins (an invalid --account is a usage error, status 2). omagma cli --strict exits at EOF with 6 when any reply was UnknownOutcome or reported a send/RSVP outcome, Calendar write state or queue state unknown/submitting (or an interrupted write without replay identity), else 3 when any reply had ok:false or reported a send/RSVP or Calendar write that was not applied (rejected, blocked, preparationStopped, stopped, canceled, a blocked dry run), else 0. Provider message/thread IDs can collide across accounts. Never reuse a cursor, draft ID, contact or operation from another account. accounts.list reports enabled accounts and locally configured capabilities; successful provider authorization is checked again before network access. Private config and grant registry are not message data.
omagma cli --fixtures --cache-dir /absolute/private/mock-cache
Send lines such as:
{"id":"accounts","cmd":"accounts.list"}
{"id":"page1","cmd":"mail.list","account":"personal@example.com","label":"INBOX","limit":100}
{"id":"read","cmd":"mail.read","account":"personal@example.com","messageId":"RETURNED_MESSAGE_ID"}
Agent recipes#
Recommended agent defaults: view:"summary" for lists, threads and contacts;
body:"text" with maxBodyBytes/stripQuoted for reads (the default body
stays both for compatibility); fields to keep only what a read needs;
dryRun:true before any send or label change. fields is refused
(UnknownField) on every command that can change state, including dry runs
and invitation.inspect with reconcile:true: their replies always carry the
complete outcome, status, warnings and identifiers. A read projection always
keeps truncation, paging and warning markers that are set (bodyTruncated,
bodyBytes, bodyHtmlBytes, quotedStripped, partial, hasMore,
nextCursor, decodeWarning, bodyCacheError, metadataPartial,
complete:false, stale, readWarnings). With body:"text", truncation
flags and sizes describe only the text that is returned. stripQuoted removes
quoted lines only after an attribution line ("On … wrote:", "Am … schrieb …:",
"… a écrit :", "… escribió:") or as the trailing quoted block, and cuts at
-----Original Message----- or at an underscore rule followed by a
From:/Sent: header block; inline replies between quotes stay. These lines run
unchanged against omagma cli --fixtures (replace each RETURNED_* value with
the previous reply's id or contentDigest):
{"id":"1","cmd":"accounts.list"}
{"id":"2","cmd":"mail.list","account":"personal@example.com","label":"INBOX","limit":20,"view":"summary"}
{"id":"3","cmd":"mail.search","account":"personal@example.com","query":"invitation","limit":10,"view":"summary"}
{"id":"4","cmd":"mail.read","account":"personal@example.com","messageId":"shared-msg-005","body":"text","stripQuoted":true,"maxBodyBytes":4000,"attachmentData":false}
{"id":"5","cmd":"mail.thread","account":"personal@example.com","threadId":"shared-thread-001","view":"summary"}
{"id":"6","cmd":"mail.reply","account":"personal@example.com","messageId":"shared-msg-005","all":true,"bodyText":"Thanks, Thursday works."}
{"id":"7","cmd":"draft.patch","account":"personal@example.com","draftId":"RETURNED_DRAFT_ID","set":{"bodyText":"Thanks, Thursday at 10:00 works."},"acknowledgementOnly":true}
{"id":"8","cmd":"draft.send","account":"personal@example.com","draftId":"RETURNED_DRAFT_ID","operationId":"reply-thursday-1","dryRun":true}
{"id":"9","cmd":"draft.send","account":"personal@example.com","draftId":"RETURNED_DRAFT_ID","operationId":"reply-thursday-1","expectedContentDigest":"RETURNED_CONTENT_DIGEST"}
{"id":"10","cmd":"mail.archive","account":"personal@example.com","messageId":"shared-msg-005","dryRun":true}
{"id":"11","cmd":"mail.archive","account":"personal@example.com","messageId":"shared-msg-005"}
{"id":"12","cmd":"contacts.search","account":"personal@example.com","query":"alex","view":"summary"}
{"id":"13","cmd":"calendar.agenda","account":"personal@example.com","calendarId":"primary","date":"today","view":"week","detail":"summary"}
{"id":"14","cmd":"reminder.set","account":"personal@example.com","messageId":"shared-msg-005","expectedVersion":0,"dueDate":"+3d"}
{"id":"15","cmd":"mail.list","account":"personal@example.com","label":"INBOX","limit":5,"fields":["id","subject","unread"]}
Check ok on every reply, and data.outcome on sends. Line 8 sends nothing
and returns the complete plan (status, sendable, recipients and
contentDigest); line 9 sends only the content reviewed there, or fails with
ReviewedDraftChanged. Line 11 replies with a compact receipt; add
"view":"message" for the full message. A label dry run (line 10) and the real
change refuse the same requests: an unknown message (MessageNotFound), an
empty mail.mark (EmptyMutation), conflicting labels or an invalid scope.
Commands#
| cmd | Additional fields / result |
|---|---|
| accounts.list | accounts with address, enabled, capabilities, configured senderName/signature |
| accounts.identities | verified send-as identities with address,name,signature,isDefault; cacheOnly supports cached identities plus configured primary fallback |
| labels.list | bounded Gmail label id,name,type,color list; cacheOnly uses the downloaded account list |
| labels.create | name, operationId, optional color; creates a custom label and returns its stable label ID |
| labels.rename | labelId, name, operationId; renames a custom label while retaining its ID and memberships |
| labels.delete | labelId, confirmName, operationId; deletes the custom label, keeping its emails; confirmName must match the current name |
| labels.color / palette | color requires labelId, operationId and color {backgroundColor,textColor}; palette returns allowed Gmail hex values |
| mail.triage-scope | messageId, scope message/conversation; complete account-scoped messageIds, count and threadId, up to 100; incomplete/oversized resolution fails |
| mail.label-state | messageIds; metadata-only per-label appliedCount/mixed state and complete target count |
| mail.list / search / sync | limit 1..100, query, label, cursor; returns one message page, nextCursor and hasMore; search selects local cache with cacheOnly:true or Gmail with false/default; sync is a list-operation alias, not a history refresh; view:"summary" returns compact rows without bodies |
| mail.refresh | optional limit/query/label/prefetchLimit; applies a bounded history update or recent resync to the account cache |
| mail.prefetch | limit 0..64; refreshes and fills a bounded recent body head within existing cache quotas |
| mail.recipients | cacheOnly:true; up to 1,024 recent account-scoped recipients from retained From/To/Cc and permitted saved contacts; excludes primary self, deduplicates and ranks recent interaction |
| mail.read | messageId; decoded full text, envelope/threading fields, labels, attachments, invitation; optional body text/html/both/none (default both), maxBodyBytes, stripQuoted, attachmentData:false |
| mail.thread | threadId; chronological messages; the same body options, or view:"summary" |
| mail.attachment | messageId, attachmentId; filename,mimeType,size and inline data(base64url) or an account blobId descriptor for larger content |
| mail.attachment-save | messageId, attachmentId, absolute path; streams a new private file, refusing overwrite and symlink traversal |
| mail.open | optional messageId; explicitly opens configured Chrome profile |
| mail.reply | messageId, all:boolean (alias replyAll), optional bodyText note above the quote, bodyFormat plain/markdown and preserveFormatting:boolean; creates a local reply/reply-all draft in one call |
| mail.forward | messageId, optional bodyText note, bodyFormat plain/markdown, preserveFormatting:boolean or original:boolean; creates an unaddressed local forward draft; formatting and original-email modes conflict |
| mail.send | draft, operationId; durable submission receipt; dryRun:true returns the plan and contentDigest and sends nothing |
| mail.archive / trash / restore | messageId; reversible label mutation; replies with a receipt {messageId, threadId, labels, unread, addedLabels, removedLabels}; view:"message" returns the full message; dryRun:true resolves the change only |
| mail.mark | messageId, unread/starred booleans, addLabels/removeLabels arrays; same receipt, view and dryRun |
| mail.batch | messageIds (1..100 distinct IDs), action archive/trash/restore/spam/unspam/mark, optional unread/starred/addLabels/removeLabels; per-ID outcomes and undoToken; dryRun:true resolves label IDs and per-message changes only |
| mail.undo | undoToken; restores only actual touched-label changes for confirmed successful batch items |
| draft.create / update | draft with bodyText source and optional bodyFormat plain/markdown; update also requires draftId and replaces editable fields, refusing (DraftReplaceWouldDropThreading) to drop saved recipients or threading unless replace:true |
| draft.patch | draftId and set:{fields}; changes only the supplied fields and keeps recipients, threading, attachments and original; optional expectedContentDigest; set refuses read-only contentDigest/gmailLink/summaryCounts, a different id and recoveryFields (ReadOnlyField) |
| draft.preview | draft or draftId, optional operationId (reuses that send's recorded Drive receipts in attachmentPlan); bodyFormat, exact bodyText source, rendered plainText and optional bodyHtml; local preview without saving or sending |
| draft.open-preview | draftId; writes a bounded private sandboxed HTML preview and explicitly opens this account's Chrome profile; sends no mail |
| draft.recovery-save | draft.recoveryFields exact five raw fields To/Cc/Bcc/Subject/Body, optional draftId; incomplete local recovery that cannot be sent; explicit forkIfSettled/copyFromDraftId preserve local edits under a new ID |
| draft.list / read / send / discard | list pages compact active summaries with limit/cursor (a draft with a queued or paused send adds sendQueued:true; data.discarded {draftId, subject, discardedAtMs} names a draft kept by keepForUndo); read/send/discard require draftId; send also requires operationId; discard with keepQueuedSend:true refuses (DraftSendQueued) instead of cancelling a queued send, with expectedContentDigest (lowercase hex) refuses (ReviewedDraftChanged) a draft changed since, and with keepForUndo:true keeps the draft for draft.restore (one per account, replaced by the next such discard, at most 7 days); without keepForUndo a discard is final |
| draft.restore | optional draftId; restores the draft this account's last keepForUndo discard kept (the terminal UI discards this way), at its place in Drafts with the same ID, content, recipients, threading, sender, files and Gmail link; DiscardedDraftUnavailable when none is kept, it is older than 7 days, or draftId names another draft |
| draft.queue | draftId, operationId, optional delaySeconds 0..30 (default 10); stages a durable unsent intent and returns queueId/dueAtMs/dueAtIso/state; dryRun:true plans without staging |
| queue.list / read / cancel / resume / process | read/cancel/resume/process require queueId; resume accepts delaySeconds; process requires due time or wait:true; no automatic processing after restart |
| attachment.import / discard | import takes path and optional mimeType, returning immutable account blobId metadata; discard takes blobId and refuses referenced content |
| contacts.list / search | live list pages accept limit 1..100 and cursor; search accepts query (live up to 30); cacheOnly uses downloaded contacts; results include resourceName,etag,name,emails and live nextCursor; view:"summary" returns resourceName, name and email addresses only |
| contacts.upsert | contact; editing requires resourceName and expectedEtag or contact.etag; omitted emails on name-only updates preserve all supported addresses/provider metadata |
| invitation.inspect | messageId; optional cacheOnly or reconcile; identities, friendly time displays, joinUrl, attendeeStatus, confirmedResponse, responseOutcome and calendarSync; only a published event adds description (≤4096 bytes, descriptionTruncated), reminders, unsupportedReminders and remindersKnown; other methods omit them |
| invitation.reply | messageId,status accepted/tentative/declined,operationId; optional rsvpOnly:true explicitly sends email without Calendar; default Accept/Tentative can return outcome:blocked before submission |
| operation.list / read | list accepts optional draftId to return only that draft's operations; read requires operationId; recorded outcome, recovery draftId and RFC Message-ID |
| cache.stats / clear | limits/residency; clear preserves drafts,contacts,operations |
| cache.refresh-status | refreshInProgress for this account; no mail or token data |
| cache.activity | local-only inboxArrivalCount, generation, lastSyncAt; arrival serial advances on successful incoming Inbox history checkpoints |
| auth.status / authorize / revoke | terminal grant; prefer one-shot terminal-auth for consent; status adds lastRefreshError (null or Google's sanitized refusal: error, subtype, description, kind, at); authorize accepts reconnect:true with the recorded capabilities and expectedGrantId |
| browser.open | explicit url; HTTP(S) destination opened in this account's configured Chrome profile |
| attachment.open | explicit path to an already saved private file; invokes the desktop handler after file/path checks |
List one bounded page at a time and pass nextCursor verbatim with the same account/query/label. Use the returned message IDs for later reads. Null means no further page in that result; cached results can still be only a mailbox subset. An agent can collect additional pages for its task with an explicit count limit. Omagma bounds its own persistent cache and evicts the oldest tail. mail.refresh updates history/checkpoints; mail.sync is the older list alias. Gmail's query syntax is available live; fixture provider searches implement only a small subset.
Full message responses retain bodyText for plain-text reading and replies, and
optional bodyHtml. The additive bodySource field is plain, html or
unknown; old cached records can be unknown. A nonempty plain alternative wins
over HTML. The TUI's native styled HTML-only presentation does not change CLI
text or ordinary quote contents. Formatted replies/forwards explicitly retain
the original HTML as described below. Treat raw HTML and all mail-derived
strings as data.
cache.activity is always a local lookup. inboxArrivalCount is a cumulative per-account arrival serial, not an unread count. Record a baseline and compare later values to observe new Inbox arrivals; the TUI maintains its own interaction-based notice counts. Initial cache filling, expired-history resync, sent mail, label-only changes and older-page reads do not increment it.
CLI/cache timestamps such as receivedAt remain absolute epoch milliseconds.
Replies add UTC ISO-8601 siblings: receivedAtIso on messages,
createdAtIso/dueAtIso on queue entries and startIso/endIso beside
Calendar event points. Messages also carry rfcMessageId, a copy of their RFC
messageId header; a message's id is the value to pass as request
messageId. The TUI's local-time display does not change these values.
calendar.agenda/calendar.freebusy date and reminder.set dueDate
accept today, tomorrow, yesterday, +Nd/-Nd and weekday names; the
reply echoes the civil date as resolvedDate. A Calendar date resolves in the
zone that also builds its window: the request timeZone, else the selected
calendar's time zone, else the local zone; a weekday name there means its next
occurrence with today included. A reminder.set due date resolves in the local
zone, and a weekday name equal to today means next week's day (use today
for today). calendarId:"primary" selects the account's primary calendar.
For a local-only lookup, set cacheOnly:true on mail.list, mail.read, mail.thread or cache.stats. One-shot commands use --cached. This path does not contact Gmail and remains available while a separate client refreshes the account. Cached mail.read returns a known final body refusal as a successful metadata-only message with bodyCached:false, a nonempty bodyCacheError, and no plain-text or HTML body. An absent message or uncached body without such a refusal returns CacheMiss; cached threads can be partial. Cached list results report cache readiness, age and partial state, and have their own account/query/generation-scoped cursors. The end of cached pagination means the end of that bounded cache view, not proof that Gmail has no more results. Provider and cache cursors are distinct; pass each only to the matching operation. Arbitrary Gmail searches require a recorded provider result rather than an invented local approximation. See cache-first behavior.
Relative cache windows: cached mail.list and mail.search also accept beforeMessageId or afterMessageId to return an adjacent bounded window without replaying a cursor. The anchor row is excluded. These selectors remain account/query/label scoped and use current retained data across generation changes or a restart. boundaryReceivedAt, an optional millisecond timestamp from a visible message DTO, recovers the nearest retained boundary when that ID has been evicted; the result explicitly reports boundaryFallback:true. Without a known boundary or timestamp, CacheBoundaryGone is returned. Results include cacheWindow and hasMoreCachedBefore/hasMoreCachedAfter. Never combine these selectors with a cursor, and never use a provider L token to rewind cached mail. One-shot flags are --before-message-id, --after-message-id and --boundary-received-at, together with --cached.
Downloaded-body search: mail.search with cacheOnly:true evaluates retained metadata and already downloaded plain-text bodies, without a previously recorded Gmail query or server request. It searches no raw HTML or encoded attachment data and never downloads a missing body. Whitespace joins up to 32 terms with AND; double quotes preserve a phrase, and - negates a term. Supported fields include from:, to:, cc:, subject:, body:, label:, in:, filename:, is:unread|read|starred|important and has:attachment. after: (inclusive), before: (exclusive) and on: compare local calendar dates (YYYY-MM-DD or YYYY/MM/DD); newer:/older: are absolute-date aliases. Unknown named operators, unsupported predicate values and invalid dates fail explicitly. Label names use the downloaded account list; IDs also work. These local predicates are a subset of Gmail syntax; use --server for the full language.
Results report searchScope:"metadata-and-cached-bodies", partial:true, matchedCachedCount, highlightTerm, and searchMatches with messageId,field,offset,length,excerpt. Excerpts are bounded to 192 UTF-8 bytes; offsets/lengths describe bytes within the excerpt. Body-aware K cursors bind body residency as well as account/query/label/metadata generation, so newly fetched bodies invalidate an old result cursor. Restart the query after InvalidCursor. Metadata-only queries remain stable while bodies download. K cursors are distinct from cached provider-view C cursors and Gmail L continuations; never exchange them. A local match does not prove that uncached mailbox content lacks the query.
{"cmd":"mail.list","account":"personal@example.com","label":"INBOX","limit":32,"cacheOnly":true}
{"cmd":"mail.refresh","account":"personal@example.com","label":"INBOX","limit":32}
{"cmd":"mail.search","account":"personal@example.com","cacheOnly":true,"query":"from:alex body:\"launch notes\""}
{"cmd":"mail.refresh","account":"personal@example.com","label":"INBOX","limit":32,"prefetchLimit":64}
Reads do not mark read. Use mail.mark explicitly if requested. There is no permanent delete. Draft bodyText is UTF-8 source, interpreted according to bodyFormat. To/Cc/Bcc accept RFC address-list strings or arrays of address objects {address,name}. Optional draft.from accepts one address object or single RFC address-list string; an alias is verified again on every live send, and accounts.identities reads aliases/plain signatures through the existing mail grant. Reply planning honors Reply-To, self aliases, original recipients and References; it never promotes Bcc into reply-all. Missing/invalid Message-ID gives an explicit error. Forwarding chooses no recipient and does not join the original thread; missing or oversized original attachments fail instead of disappearing silently.
{"cmd":"draft.create","account":"personal@example.com","draft":{"to":[{"address":"alex@example.org"}],"subject":"Demo 🌋","bodyText":"Hello!"}}
{"cmd":"draft.send","account":"personal@example.com","draftId":"USE_RETURNED_ID","operationId":"task-unique-send-1"}
Small inline attachments use
{id:"",filename:"safe-basename.txt",mimeType:"text/plain",size:DECODED_BYTES,data:"BASE64URL_NO_PADDING"}
in draft.attachments. Larger content uses the descriptor returned by
attachment.import, including an immutable blobId owned by this account.
Use the returned descriptor rather than inventing a handle or passing a cache
path. attachment.discard refuses a handle still referenced by a draft or
protected content. size remains an exact decoded byte count.
Native ordinary files and included original resources share 1,040 outgoing parts and a 25 MiB decoded budget. Up to 1,024 original resources can be retained. The browser demo keeps 16 ordinary files. Native compose source and each rendered alternative allow up to 35 MiB, but complete outgoing MIME, including all alternatives, files, resources and the generated logo, must fit 35 MiB (36,700,160 bytes). The new logo has its own 16 KiB internal allowance and consumes no file/resource slot; logos retained from the original count as resources. All combined content must fit these limits. The portable browser keeps its 2 MiB text/resource tier.
Inline data across files and original resources remains limited to 2 MiB of
decoded bytes, even for a larger native compose request. Repeated
--attach-file FILE uses inline base64 for a set no larger than 2 MiB and
account storage for larger sets. Formatted native captures store their images
as account blobs from the first capture.
mail.attachment returns inline data for smaller content or a blobId
descriptor for a larger received file. Empty/omitted data with a handle does not
mean the file is empty. mail.attachment-save streams the content into the
caller's explicit new absolute path, with 0600 permissions and no overwrite or
parent/leaf symlink traversal. Received files are individually bounded to
50 MiB; cached attachment handles also obey account disk quotas. The file is
decoded incrementally, so its content does not consume a whole JSON frame or
raise the ordinary reader's 2 MiB text-body limit. Saving does not require a
mailbox mutation.
There is no --output-file flag. Existing attachment.open/mail open-attachment
opens an already saved supported private file; it does not download a handle.
Reviewed message and conversation targets#
mail.triage-scope resolves a single anchor with scope:"message" or
"conversation" into complete account-scoped messageIds, count and
threadId. The maximum is 100; incomplete, oversized or inconsistent
conversations fail instead of returning a truncated mutation target.
Review the returned IDs/count, then pass those exact IDs to mail.batch.
Later arrivals are not implicitly added to that batch.
mail.label-state accepts the explicit target IDs and returns their current
per-label membership counts without fetching bodies. It supports checking
all/mixed/none before constructing addLabels/removeLabels. A successful
membership snapshot does not authorize unrelated mailbox changes.
{"cmd":"mail.triage-scope","account":"personal@example.com","messageId":"PROVIDER_ID","scope":"conversation"}
{"cmd":"mail.label-state","account":"personal@example.com","messageIds":["RETURNED_ID_1","RETURNED_ID_2"]}
{"cmd":"mail.batch","account":"personal@example.com","messageIds":["RETURNED_ID_1","RETURNED_ID_2"],"action":"mark","addLabels":["EXISTING_LABEL_ID"]}
The one-shot adapter offers --scope message|conversation for
archive/trash/restore/spam/unspam/mark/batch with one --message-id anchor. It
resolves complete IDs before the mutation. Explicit --message-ids ID,ID
continues to mean only that set. JSONL clients should use the resolver plus
explicit batch IDs rather than assuming an extra scope field changes a
single-message mutation.
Label collection management#
labels list returns the account's definitions; ordinary mail labels remains
a list alias. In the one-shot adapter, supplying target IDs to either alias
invokes membership inspection instead.
Create, rename, color and delete affect the collection, while mail mark and
mail batch add/remove memberships on selected messages. System definitions
are protected. Writes require mail-modify and an explicit operation ID.
omagma labels list --account personal@example.com --cached
omagma labels create --account personal@example.com --name 'Projects/Volcano' --operation-id label-create-001
omagma labels rename --account personal@example.com --label-id RETURNED_ID --name 'Projects/Magma' --operation-id label-rename-001
omagma labels palette --account personal@example.com
omagma labels color --account personal@example.com --label-id RETURNED_ID \
--background-color '#a479e2' --text-color '#000000' --operation-id label-color-001
omagma labels delete --account personal@example.com --label-id RETURNED_ID --confirm-name 'Projects/Magma' --operation-id label-delete-001
Deleting a label removes its associations, keeping the messages and their
bodies. It is distinct from removing that label from one message. Keep the
operation ID to inspect or replay its recorded result; an uncertain remote
outcome must be checked rather than submitted again under a new ID.
Both color values must come from labels.palette; arbitrary RGB strings are
rejected before mutation. Create can also receive the same optional color pair.
Markdown drafts and preview#
Fresh CLI drafts and direct sends default to plain.
Set draft.bodyFormat:"markdown" to opt in, or use
top-level bodyFormat:"markdown" for mail.reply/mail.forward. Existing
drafts retain their saved format when an update omits it, and legacy drafts
remain plain. Source stays exact through save, recovery and preview: ordinary
drafts use bodyText, while incomplete recovery drafts retain the raw body in
recoveryFields[4]. Generated HTML is derived locally.
draft.preview accepts an existing draftId or a supplied draft and returns
bodyFormat, source bodyText, the outgoing plainText alternative, and
optional bodyHtml. It neither saves nor submits the supplied source. Preview
can inspect an unfinished recovery draft; that draft still requires a normal
validated update before sending. Markdown sends contain rendered HTML and a
readable plain-text alternative. The saved draft retains Markdown source,
while Sent message bodyText contains the rendered plain alternative.
{"cmd":"draft.create","account":"personal@example.com","draft":{"to":"alex@example.org","subject":"Notes","bodyFormat":"markdown","bodyText":"## Review\n\n**Ready** for Thursday."}}
{"cmd":"draft.preview","account":"personal@example.com","draftId":"USE_RETURNED_ID"}
{"cmd":"mail.reply","account":"personal@example.com","messageId":"PROVIDER_ID","all":true,"bodyFormat":"markdown"}
Supported syntax includes headings, emphasis, strikethrough, lists, quotes, tables, links and fenced code. Known fence languages receive bounded syntax highlighting; unknown languages remain literal code. Raw HTML is escaped, unsafe link schemes stay inert, and Markdown images become alt text or safe links without loading remote images. Markdown HTML includes a small grey “Sent with omagma” footer, volcano emoji and the approved tiny logo embedded in the email. No branding image is fetched from a server. The terminal preview shows this content; receiving email clients control their final appearance.
One-shot --format markdown|plain applies to mail compose, draft create,
draft update, direct mail send, mail reply/forward and supplied-source
draft preview. It can accompany --body-file, --body-stdin or
--draft-file. draft send and draft preview --draft-id use the saved format;
change it through an explicit draft update first.
omagma mail compose --account personal@example.com --to alex@example.org \
--subject Notes --body-file /absolute/private/notes.md --format markdown
omagma draft preview --account personal@example.com --draft-id LOCAL_ID
omagma draft preview --account personal@example.com \
--body-file /absolute/private/notes.md --format markdown
omagma draft send --account personal@example.com --draft-id LOCAL_ID --operation-id TASK_ID
Review the returned alternatives before a task-authorized send. Rendering does not add a grant or bypass the account, recipient, attachment or request limits.
draft.open-preview requires a saved draftId. One-shot callers can use
draft open-preview --draft-id ID or draft preview --draft-id ID --browser.
This explicitly opens the account's Chrome profile on a private generated file.
The message is isolated in an opaque sandbox with scripts, forms, remote
resources and navigation blocked; verified PNG/JPEG/GIF resources are inlined.
It preserves the note/original's styles and tables, sends nothing and does not
upload a Gmail draft. The native artifact is owner-only and streamed, with a
246 MiB ceiling for escaped HTML and inlined images. Its actual bytes count
against the account disk quota; the ceiling is not a preallocation. It is
replaced on reuse and removed on local draft discard.
omagma draft preview --account personal@example.com --draft-id LOCAL_ID --browser
Replies and forwards with original content#
Set preserveFormatting:true on mail.reply or mail.forward to retain the
original HTML, tables, styling and embedded images below a separate editable
note. Reply-all uses the same flag with all:true. bodyText and bodyFormat
describe your note; its usual Markdown rendering and Omagma footer appear
above the read-only original. Plain mode keeps the note literal while retaining
the original HTML. Without the flag, these commands keep the editable
text-quote behavior. A request to preserve formatting without original HTML
returns OriginalHtmlUnavailable.
The returned draft.original is a read-only snapshot containing the source
identity, envelope, text, HTML and embedded image resources. Leave it unchanged
when updating a structured draft; edit the note and ordinary compose fields.
The snapshot survives recovery, restart and eviction of the source mail from
the cache. Preview and sending use the same assembled note, original and
plain-text alternative. Existing drafts retain their saved content and format.
For the complete original as an attachment, use original:true on
mail.forward. The draft starts with an empty note and one .eml containing
the original headers and all contained attachments. Those files are not added
again as separate attachments; the recipient opens the attached email.
original is forward-only and conflicts with preserveFormatting.
Neither option sends the draft.
{"cmd":"mail.reply","account":"personal@example.com","messageId":"PROVIDER_ID","all":true,"preserveFormatting":true,"bodyFormat":"markdown"}
{"cmd":"mail.forward","account":"personal@example.com","messageId":"PROVIDER_ID","preserveFormatting":true,"bodyFormat":"markdown"}
{"cmd":"mail.forward","account":"personal@example.com","messageId":"PROVIDER_ID","original":true,"bodyFormat":"markdown"}
One-shot commands use --preserve-formatting for reply/reply-all and forward,
or --original for forward only. The flags conflict; --format selects the
editable note's format.
omagma mail reply --account personal@example.com --message-id PROVIDER_ID \
--all --preserve-formatting --format markdown
omagma mail forward --account personal@example.com --message-id PROVIDER_ID \
--preserve-formatting --format markdown
omagma mail forward --account personal@example.com --message-id PROVIDER_ID \
--original --format markdown
Native formatted capture uses the 35 MiB compose text tier and can fetch a
selected source that exceeds ordinary reader limits. A complete .eml source
can be up to 25 MiB; sources above 2 MiB use an immutable account blob. Smaller
originals remain inline. The .eml counts as one ordinary file and shares the
decoded file budget; final encoded MIME must still fit 35 MiB. Portable browser
originals retain their 2 MiB source/resource and 3 MiB request limits. Missing
or oversized originals fail before saving a partial draft or sending mail.
Embedded image bytes are retained; remote images still depend on the image
server and recipient settings. Final styling depends on the receiving email
client. An unknown send outcome protects the saved draft and must be checked
before another submission.
Captured originals allow 1,024 resources without consuming the ordinary 16-file count. Native resources and ordinary files share the 25 MiB decoded budget. Incoming MIME bookkeeping accepts up to 1,041 file/resource descriptors, including related parts and the sender's generated logo, within a separate 4,180-part parser bound. These parser limits do not expand quotas for outgoing ordinary files or retained resources.
Google Drive delivery#
mail send and draft create|update|preview accept, in addition to
--attach-file FILE (always attach):
--upload-file FILE(repeatable): always share from Drive.--file FILE(repeatable): follows--attachment-mode attach|auto|drive(defaultattach). Auto attaches what fits and shares the rest.--dry-run: print the plan from local file metadata. No blob import, authorization, network or store write; the reply setsdryRunandmimeEstimate.
This local file dry run requires supplied draft source, rather than --draft-id
or --browser. A Draft file containing stored blob handles returns
DryRunRequiresLocalFiles; for a saved draft use draft send|queue --draft-id ID --operation-id ID --dry-run (the JSONL plan below), draft preview --draft-id ID or JSONL draft.delivery-plan. A blocked dry-run returns ok:false, data.status:"blocked" and a
non-zero exit status; inspect its blockers before sending. JSONL mail.send,
draft.send and draft.queue accept dryRun:true, including for saved drafts
and stored files: the reply is the same plan with status, sendable,
contentDigest and the resolved sender and recipients, ok:true even when
blocked (a one-shot --dry-run then exits 3), and nothing is journaled,
queued, uploaded or sent. fields is refused on these dry runs.
Files are compared by canonical path. An explicit flag wins over --file
regardless of order; a path in both --attach-file and --upload-file
(ConflictingAttachmentDelivery) or twice in one flag
(DuplicateAttachmentFile) is refused. Display order is first appearance.
Passing --upload-file, or --file with mode auto/drive, is consent to
upload from the account and share viewer-only with the final To and Cc.
JSON drafts carry attachments[].delivery (attach|auto|drive, default
attach). draft.delivery-plan returns the plan directly under data without
network access; preview/measure use the attachmentPlan wrapper. Plan fields:
files[] (index, filename, size, requestedDelivery, delivery, state, reuse,
newCopy, sharedWith),
attachedBytes, mimeBytes, mimeEstimate, driveFileCount,
driveFileLimit, decodedLimitBytes, mimeLimitBytes and blockers[]
(code, message). Bcc with Drive is refused and at most 16 Drive files are
allowed. Saving never uploads; uploads and sharing happen only during the
confirmed send. Preparation retries are explicit and reuse operationId;
never automatically retry UnknownOutcome.
state: "not_in_body" identifies a retained pasted-image descriptor whose
owned  marker is absent from the Markdown body (or whose body
is Plain). Its bytes remain local for editing and Undo; it is neither attached
nor uploaded and does not consume the outgoing attachment budget. Active inline
images use Attach delivery and appear at their marker position in HTML mail.
As with other mutation receipts, ok:true means a receipt was returned; check
data.outcome to distinguish applied, rejected, unknown and
preparationStopped. canRetryPreparation permits an explicit preparation
retry. Editing/discarding its source or cancelling its queue permanently closes
that operation (kind: drivePreparationRetired); start a newly reviewed send
with a new operation ID. Its frozen file/access receipt remains readable, and
retirement never deletes Drive files or revokes permissions.
One unfinished preparation owns a saved draft at a time. Sending that unchanged
draft with a fresh operation ID is refused as DrivePreparationActive; retry
the original ID, or change/discard the draft before starting a new send.
omagma mail send --account self@example.test --to peer@example.test \
--subject Notes --body-file note.md --attachment-mode auto \
--file deck.pdf --upload-file raw.zip --operation-id UNIQUE_SEND_ID --dry-run
Local send queue and cancellation#
TUI review uses a ten-second cancellation period by default. Direct JSONL
mail.send/draft.send and ordinary one-shot sends retain immediate submission;
CLI delay is an explicit choice. None of these operations schedules future
delivery through Gmail or through the read-only background cache timer.
draft.queue stages a validated saved draft with a stable operationId and
delaySeconds from 0–30 (default 10). Its receipt contains queueId, draftId,
operationId, state, createdAtMs and dueAtMs. Staging sends nothing.
queue.process submits a due queued item; before its deadline it returns
QueueNotDue unless wait:true explicitly waits. queue.cancel cancels only an
unsent queued intent and keeps its draft. queue.resume explicitly resets a
queued item's countdown. Cancelled/applied/rejected/unknown/submitting entries
are not resumed or automatically sent again.
{"cmd":"draft.queue","account":"personal@example.com","draftId":"LOCAL_ID","operationId":"SEND_TASK_ID","delaySeconds":10}
{"cmd":"queue.read","account":"personal@example.com","queueId":"RETURNED_QUEUE_ID"}
{"cmd":"queue.cancel","account":"personal@example.com","queueId":"RETURNED_QUEUE_ID"}
To keep staging and processing separate in a one-shot workflow:
omagma draft queue --account personal@example.com --draft-id LOCAL_ID \
--operation-id SEND_TASK_ID --delay-seconds 10
omagma queue process --account personal@example.com --queue-id RETURNED_QUEUE_ID --wait
mail send/draft send --send-delay 10 stages and waits through this same queue,
then returns its result. queue resume --queue-id ID --delay-seconds 10 resets
the deadline but still needs explicit processing. Another authorized client
can inspect or cancel the queued item while a processor waits.
To skip the remaining countdown for one already reviewed intent, use
queue.send-now or omagma queue send-now --account personal@example.com --queue-id RETURNED_QUEUE_ID. It claims the same queue and operation identity,
checks the reviewed content and submits immediately. Replaying a final,
canceled, submitting or unknown item returns its status without another send.
This leaves the default cancellation period unchanged.
No process startup automatically processes a pending item. Reopening a queued
draft in the TUI first checks queue state and exposes :resume-send or
:cancel-send. Normal TUI close cancels its unsent countdown; a crashed queued
item stays pending for explicit handling. Submitting/unknown outcomes protect
their recovery draft and require receipt/provider inspection, not a new send.
Side effects and uncertainty#
Every send/RSVP needs a stable operationId chosen by the caller. Omagma persists an unknown receipt before dispatch and derives a stable RFC Message-ID from account+operationId. Repeating the same account, identity and semantic content returns the recorded receipt without another provider call. For ordinary mail sends, a new identity for the same unresolved draft/content also returns the existing unknown receipt, preventing accidental duplicate submission through a reopened draft. For an unresolved invitation RSVP, a new operationId instead returns UnknownOutcome; replay the original ID to read its existing receipt. Reusing it for different content gives OperationConflict. This is a local duplicate guard, not a server-side idempotency guarantee.
Outcomes: applied=provider accepted, rejected=known failure, unknown=possibly applied. Do not retry unknown with a new ID. Inspect operation.read and the provider's Sent folder before asking the user how to proceed. Direct sends also preserve a local recovery draft before dispatch. draft.discard removes a local draft and its regenerable preview, but refuses protected pending/submitting/unknown sends. Cancel an unsent queued intent before discarding or editing its draft. Settled accepted sources and receipts move to paged retained history instead of consuming active draft slots or a lifetime 1,000-receipt journal. Active pending/unknown work remains protected. Cache clear preserves history and replay fences. Actual disk-quota exhaustion must be resolved before a new provider write; it never silently discards uncertain receipts. RSVP replay ignores its varying DTSTAMP but compares the semantic response.
The receipt's messageId is the provider resource ID; use it with mail.read
when available. Its rfcMessageId is the submitted Internet Message-ID, which
the provider can replace. A full message's messageId is the actual Internet
header, while its id is the provider resource ID. Use that actual header for
cross-mailbox rfc822msgid: searches after reading Sent. An empty search for
the submitted header is not proof that an uncertain send failed.
Contact updates use CONTACT-source etags and reject conflicts. Supported edits preserve all 32 addresses and bounded provider names/email/source metadata rather than reducing a contact to one address. Live writes invalidate the contacts cache before submission and return the validated provider contact directly; the next contacts read refreshes the cache. Mutating transport interruption or unrecognizable provider acknowledgement is uncertain. Failure to encode a live mutation's final response is also UnknownOutcome, even if its error frame cannot be allocated. Refresh authoritative provider state before another mutation. The permission error occurs before provider access if the required capability is absent.
Bulk and undo: bulk actions preserve independent per-message outcomes and never submit sends. Up to 16 account-scoped undo receipts persist under the private cache quota. The receipt records actual pre-action membership only for touched labels. Undo therefore preserves unrelated labels changed later. Rejected, pending, unknown and already restored entries are skipped; an uncertain undo is not repeated automatically. Cache clear preserves these receipts. Apply bulk actions only to IDs explicitly selected for the intended account; a batch is a bounded sequence with partial outcomes, not a transaction.
Meeting invitations: JSONL invitation.inspect/invitation.reply and one-shot invitations inspect/invitations reply share calendar recognition and receipts. Recognized MIME forms are text/calendar, application/ics, and named .ics files labelled application/octet-stream or text/plain (case-insensitive filename suffix), including external attachment bodies. A filename alone is insufficient: the bounded content must be a calendar. Calendar data is limited to 128 KiB. Inspection displays requests, responses, published events and cancellations; a multi-event or ambiguous-attendee notice remains read-only. Sending a response requires exactly one requested event or recurrence instance and an attendee belonging to the selected account or a verified send-as alias. Matching duplicate MIME representations are accepted; conflicting calendars are refused. Inspection requires mail-read; reply additionally requires calendar-rsvp and an operation ID. If an older cached message retained only a calendar attachment reference, explicit inspection or reply refreshes that one message and preserves unrelated cached bodies.
Calendar attachments without invitations: an attendee-free METHOD:PUBLISH event, or an ordinary event without METHOD, can use the existing message-based calendar invitation-plan → calendar review → calendar import flow. Select the receiving account's verified writable primary calendar. Inspection and review do not write; apply only the returned exact review hash after authorization. These are personal copies with no guests or RSVP. All-day DTEND remains exclusive in the provider payload. Review includes copied popup reminders and an unsupported_reminders count; disclose omitted alarms before confirming. Passive, minute-aligned DISPLAY alarms relative to start are copied (at most five, up to four weeks); nominal day/week, absolute, repeating, email/audio and other unsupported alarms are not executed. Recurring or multi-event files retain the existing import limits. A changed or previously removed copy is never silently replaced or recreated.
Reply sends a standard iTIP email response to the calendar organizer, preserving UID, sequence and recurrence identity; email From/Reply-To do not choose the destination. The three states are accepted, tentative and declined, mapped to the corresponding attendee PARTSTAT. A copied Zoom/Teams join link alone is not a calendar request and cannot be given an invented RSVP.
Accept/Tentative first checks Calendar access, the selected calendar and whether the event can be saved, then prepares the Calendar action before sending the email. The default target is the primary calendar. A known blocker, including missing Calendar permission, an offline provider or unsupported recurrence, returns outcome:"blocked" with a reason in calendarSync.errorCode: no RSVP email is sent and no Calendar event is written. Resolve the reason and retry, or explicitly choose JSONL rsvpOnly:true / one-shot --rsvp-only to send only the email. Repeating ordinary Accept/Tentative never opts into this override. In the TUI, the blocked card offers s Accept without Calendar or s Tentative without Calendar; C cannot submit a blocked RSVP. Decline is email-only by default. Decline and the explicit mail-only override need no Calendar grant, but still require the mail-read and calendar-rsvp capabilities. A mail-only choice is saved as calendarSync.errorCode:"RsvpOnlyRequested" and stays mail-only across reopening and reconciliation, even if Calendar access later becomes available.
Email and Calendar form a coordinated workflow with separately recorded outcomes. After the preflight, a later failure can leave the RSVP email confirmed while Calendar is unconfirmed or unfinished. outcome:"applied" confirms the email submission; inspect calendarSync for the Calendar result. Do not send another RSVP to repair a partial result. invitations inspect --reconcile or JSONL invitation.inspect with reconcile:true checks or resumes the saved Calendar action without resending mail. The TUI offers C Check status for this recovery, including an already-confirmed RSVP whose Calendar step previously failed with CalendarLineTooLarge.
Unknown email submissions are not retried automatically. Inspection can fetch mail or verified identities; invitations inspect --cached or JSONL cacheOnly:true instead uses only retained source and identities. For an uncertain RSVP email, reconciliation checks Sent for the recorded Message-ID and exact RSVP identity. Positive evidence confirms the local receipt; absence leaves it unknown and never resends. The TUI offers C Check Sent for this case. Cached inspection and reconciliation cannot be combined.
Configurable body prefetch defaults to the smaller of the display page and 32. prefetchLimit or --prefetch-bodies N explicitly selects 0..64; 64 can fill a larger retained head while the display page stays 32. Zero disables automatic body filling. TUI startup and the background cache-refresh command share this policy, fixed message/disk quotas and old-tail eviction. Cached mail remains readable while refresh runs.
One-shot interface#
One-shot command families are mail, labels, draft, queue, attachment,
contacts, invitations, calendar, cache, operation and terminal-auth. Common names map to the shared API:
mail compose creates a local draft and mail drafts lists them.
mail labels lists existing labels, and mail identities
discovers sending identities.
mail open-link --url URL opens a link in the account's Chrome
profile, and mail open-attachment --path FILE opens an already saved local
file in its viewer. The latter does not download a received attachment. Live
viewer opening requires an absolute path to a regular file with private
permissions and a supported extension (.pdf, .txt, .md, .csv, .png,
.jpg, .jpeg, .gif or .webp). Fixture commands report a fixture result
without launching a browser/viewer; attachment opening in fixtures does not
validate a saved file's existence.
Account discovery is JSONL accounts.list; there is no omagma accounts list
command family.
omagma mail list --account personal@example.com --label INBOX --limit 100
omagma mail search --account personal@example.com --query launch --cached
omagma mail search --account personal@example.com --query 'from:alex@example.org' --server
omagma mail read --account personal@example.com --message-id PROVIDER_ID
omagma mail reply --account personal@example.com --message-id PROVIDER_ID --all --body 'Thursday works.'
omagma draft patch --account personal@example.com --draft-id LOCAL_ID --body-file /absolute/private/note.txt
omagma mail mark --account personal@example.com --message-id PROVIDER_ID --unread --add-label EXISTING_LABEL_ID
omagma draft send --account personal@example.com --draft-id LOCAL_ID --operation-id TASK_ID --dry-run
omagma draft send --account personal@example.com --draft-id LOCAL_ID --operation-id TASK_ID \
--expected-content-digest RETURNED_CONTENT_DIGEST
omagma mail compose --account personal@example.com --to alex@example.org \
--subject 'A draft' --body-file /absolute/private/body.txt --attach-file /absolute/private/file.txt
omagma operation read --account personal@example.com --operation-id TASK_ID
omagma contacts list --account personal@example.com --limit 100
omagma contacts search --account personal@example.com --query Alex
omagma contacts upsert --account personal@example.com --contact-file /absolute/private/contact.json
omagma invitations inspect --account personal@example.com --message-id INVITATION_ID
omagma invitations reply --account personal@example.com --message-id INVITATION_ID \
--status accepted --operation-id RSVP_TASK_ID
omagma invitations inspect --account personal@example.com --message-id INVITATION_ID --reconcile
omagma cache stats --account personal@example.com --cached
Additional examples:
omagma mail forward --account personal@example.com --message-id PROVIDER_ID
omagma mail labels --account personal@example.com --cached
omagma mail identities --account personal@example.com --cached
omagma mail batch --account personal@example.com --action archive --message-ids ID1,ID2
omagma mail undo --account personal@example.com --undo-token RETURNED_TOKEN
omagma mail prefetch --account personal@example.com --limit 64
omagma mail triage-scope --account personal@example.com --message-id PROVIDER_ID --scope conversation
omagma mail label-state --account personal@example.com --message-ids ID1,ID2
omagma mail attachment-save --account personal@example.com --message-id PROVIDER_ID \
--attachment-id ATTACHMENT_ID --path /absolute/private/downloads/report.pdf
omagma attachment import --account personal@example.com --path /absolute/private/report.pdf
omagma queue list --account personal@example.com
For contact creation, the contact file supplies name and emails. To edit,
include its returned resourceName and pass --expected-etag RETURNED_ETAG
(or include the returned contact etag). Supported contacts retain up to 32
addresses plus bounded provider metadata. A name-only edit can omit emails
to preserve them; explicit address edits supply the intended complete array.
This supports create/update, not deletion. Label assignment uses existing label
IDs or the supported name resolver. Collection management uses
labels create|rename|color|delete, with
explicit operation IDs and a reviewed name for deletion. Invitation replies send email,
not Calendar changes.
JSONL carries every structured operation, including multi-ID arrays, local raw
draft recovery and contact objects. One-shot calls accept those objects through
--draft-file/--contact-file; do not invent extra flags for object fields.
The CLI does not launch the TUI's editor, autocomplete or styled renderer.
For an agent handoff, mail.read already returns decoded bodyText; the TUI
also offers :copy-message for a focused message, visual/mouse selection for excerpts,
and e to open a disposable received-message snapshot in the user's editor.
Operation --help gives its applicable flags, defaults/effects and a shell
example. --help-all adds common resource/fixture options and the complete
Draft/Contact file schema when relevant. --help-options shows shared process
options directly. Help returns before reading body files or stdin, even when
placed after those options. Literal option values such as --subject --help
remain data. Usage errors point to the nearest family/operation help without
echoing private argument values. All one-shot replies are JSON; --json is
accepted for compatibility.
| Flags | Purpose / scope |
|---|---|
--account ADDRESS, --config FILE, --grant-file FILE |
Explicit account, private configuration and terminal grant registry |
--cache-dir DIR, --metadata-limit N / --cache-messages N, --disk-limit-bytes N / --cache-bytes N |
Cache location and retained count/byte limits |
--limit N, --cursor TOKEN, --query TEXT, --label ID_OR_NAME |
Bounded page and matching account/query/label continuation |
--cached (alias --cache-only), --server |
Local-only one-shot lookup; --server applies only to mail search. JSONL uses cacheOnly instead |
--message-id ID / --id ID, --thread-id ID, --attachment-id ID |
Returned provider identities for read/thread/attachment operations |
--draft-id ID, --operation-id ID |
Local draft/receipt identities; sends and RSVP require a stable operation ID |
--rsvp-only |
Explicit email-only invitation reply; bypasses the default Accept/Tentative Calendar preflight and save. Its saved policy survives reconciliation |
--to LIST, --cc LIST, --bcc LIST, --subject TEXT |
Outgoing address lists and subject |
--body-file FILE, --body-stdin, --body TEXT |
UTF-8 source body; file/stdin avoids putting it in argv. For mail reply/mail forward it is the note above the quote (top-level bodyText); other compose flags are refused there |
--dry-run |
draft send/draft queue and mail archive/trash/restore/mark/batch/spam/unspam: the JSONL dryRun plan, nothing sent, staged or relabeled; with supplied draft source (mail send, draft create/update/preview) the local file plan; calendar event-delete-review/event-respond-review (a read-only plan, nothing saved) and calendar event-apply (apply's checks and wouldSend, nothing sent) |
--scope event|series, --response accepted|tentative|declined |
Calendar delete/RSVP reviews: one event or occurrence versus the whole series (this-and-following is not supported), and the answer. --scope on another Calendar verb and --response on a delete are usage errors (2); --dry-run on a Calendar verb without one is DryRunUnsupported (2) |
--replace, --expected-content-digest DIGEST |
draft update --replace allows dropping saved recipients/threading; the digest binds draft patch, draft send or draft queue to a reviewed version |
--format markdown|plain |
Explicit source interpretation for compose/create/update/direct send/reply/forward or supplied-source preview; new CLI source defaults to plain |
--preserve-formatting |
Reply/reply-all or forward with a read-only formatted original below the editable note |
--original |
Forward the complete original as an .eml attachment; conflicts with --preserve-formatting |
--attach-file FILE (repeatable), --draft-file FILE |
Regular outgoing files or a structured draft JSON object |
--all / --reply-all |
Plan a reply-all draft; mail reply only (a forward chooses no recipients) |
--unread / --read, --starred / --unstarred, --add-label LABEL, --remove-label LABEL |
Explicit mail.mark changes; label flags may repeat |
--name NAME, --label-id ID, --confirm-name NAME |
Label collection create/rename/color/delete; combine writes with --operation-id |
--background-color HEX, --text-color HEX |
Gmail-compatible color pair for labels create/rename/color; obtain values from labels palette |
--scope message|conversation |
One-shot complete target resolution from a single message anchor before triage |
--queue-id ID, --delay-seconds N, --wait |
Queue read/cancel/resume/process; delay 0–30 for draft queue/resume; --wait only for queue process |
--send-delay N |
Explicit 0–30 second queue+wait for mail send/draft send; no delayed-send default on direct CLI sends |
--blob-id ID, --mime-type TYPE |
Account attachment handle discard / optional import media type |
--browser |
draft preview with an existing draft-id; explicitly opens private account-profile browser preview |
--contact-file FILE, --expected-etag ETAG |
Create/edit contact object and version precondition |
--status accepted|tentative|declined |
Invitation reply, with message and operation IDs |
--client-file FILE, --capabilities CSV |
terminal-auth authorize; follow account setup |
--from ADDRESS |
Explicit verified sending identity |
--action ACTION, --message-ids ID1,ID2, --undo-token TOKEN |
Batch actions/undo; repeated message-id flags also build a batch |
--prefetch-bodies N |
Explicit 0–64 body head for terminal modes/cache refresh |
--before-message-id ID, --after-message-id ID, --boundary-received-at MILLISECONDS |
Adjacent current cached window; combine with --cached, not cursor |
--url HTTP_URL, --path FILE |
Link opening, opening an already saved file, attachment import, or a new destination for mail attachment-save; meaning follows the command |
--ui-file FILE, --editor-mode auto|takeover, --no-mouse |
TUI preferences/editor/mouse options, not additional CLI business operations |
Use --body-file or --body-stdin to keep content out of argv. --draft-file/--contact-file accept bounded JSON objects; combining --draft-file with compose fields or --attach-file is rejected as conflicting input. Every one-shot reply is printed as JSON; the exit status is derived from that reply. For send and RSVP commands (mail send, draft send, draft queue, queue process, queue send-now, invitations reply) ok:true alone is not success: the status follows data.outcome / data.state.
| Status | Meaning |
|---|---|
| 0 | Success: ok:true, and for a send/RSVP an applied outcome, a queued staging or a sendable dry-run plan; for a Calendar write (calendar apply/import/update/cancel/reconcile, event-apply/event-reconcile/event-retry, meet-event-apply/meet-event-reconcile) a state other than unknown or rejected |
| 1 | Other failure, such as configuration or I/O |
| 2 | Usage error: unknown option or command, missing or malformed option value (including cli --account), or a flag on the wrong command; stderr names the option and the nearest valid one |
| 3 | Rejected or not applied: validation, provider refusal, a blocked dry run, a send/RSVP outcome rejected, blocked or preparationStopped, status:"stopped", a queue state canceled, preparing or (after processing) still queued, or a Calendar write state:"rejected" or (outside a dry run) "not_sent" |
| 4 | Missing authorization or capability, including CalendarReadPermissionRequired/CalendarWritePermissionRequired |
| 5 | The account, message, draft, label or other target was not found |
| 6 | Unknown outcome: UnknownOutcome (also for a Calendar apply or retry ended by the deadline, cancellation or a failed journal write after its claim), a send/RSVP outcome, Calendar write state (including Meet notes) or queue state unknown/submitting, a failed calendar event-retry (the earlier write stays unknown) other than one refused for authorization (4), without a saved write (5) or malformed (3), a dry run replaying an unknown receipt, or an interrupted write without replay identity (Timeout, Canceled, TransientFailure, NetworkFailure or a reset connection on a write without operationId/undoToken) |
| 7 | Transient: the error says retryable:true (CacheBusy, RateLimited, VaultBusy, refused connection, or an interruption of a read or of an operationId/undoToken write); repeat later unchanged |
omagma cli exits 0 regardless of replies unless --strict is given (see the protocol section). JSONL command errors allow the next frame, while output failures may end the process. A live mutation's UnknownOutcome survives that exit path. Never put tokens in argv, logs, shell history or agent messages.
For interactive keys see terminal mail. Developer architecture and verification live in developer references; ordinary use does not require replaying that qualification workflow.
Bind review to one saved source#
draft.measure counts encoded outgoing MIME without sending or creating a
spool. Supply the saved draftId and an operationId reserved for that review.
Keep its returned contentDigest and pass it as expectedContentDigest to
draft.send or draft.queue, with the same operation ID. If another client
changes the saved sender, body, original-inclusion policy or files, the request
fails with ReviewedDraftChanged before staging or dispatch. Fetch and review
the new source rather than retrying a stale approval.
An exact size receipt has exact:true and bytes. A rendering that is already
proven larger than the send limit reports exact:false, bytes:null and
overLimit:true; no exact number is invented. withoutOriginalBytes is
returned when that alternative can be measured. includeOriginal:false omits
only the separately retained original from outgoing MIME; the source and its
files stay in the local draft for restoration. It does not strip arbitrary
quoted text from the editable note.
Page through retained history#
draft.list returns compact active summaries, including summaryOnly:true,
recipient counts and attachment counts. It accepts limit 1–100 (default 100)
and cursor; each page also obeys an encoded browsing budget. Copy a nonempty
nextCursor verbatim, and use draft.read for the full source before editing.
history.operations, history.drafts and history.queues return items,
nextCursor and retained:true; request 1–100 rows and copy the cursor verbatim.
Pages obey an encoded byte budget as well as the row limit. An unusually large
operation may appear as an identity/outcome summary with summaryOnly and
readCommand; use that command to retrieve the exact receipt. Existing list
commands show active work. Exact archived receipts remain
available through operation.read. draft.read retrieves a retained source;
draft.clone creates a fresh editable copy. A new operation ID cannot send an
archived immutable source directly. Cloning requires a settled sent source;
active unsent, queued, uncertain or Gmail-owned work remains protected.
Explicit history.delete-source with confirm:true deletes settled source
content, leaving its permanent receipt and content fingerprint. Optional
discardFiles:true also removes unreferenced files. The operation is local and
does not delete provider mail. Unknown, pending or otherwise owned active drafts
remain protected. Old-ID replay after content deletion returns the recorded
receipt and never creates another provider write.
Preserve local edits after another client changes a draft#
Use draft.recovery-save with forkIfSettled:true and the old draftId when a
known applied send has made that source immutable. A successful fork returns a
new id and forkedFrom; the sent source remains unchanged.
For an explicit local copy after detecting concurrent edits, omit draftId
and pass copyFromDraftId with the exact local recovery snapshot. The result
returns a new id and copiedFrom. Neither path sends or uploads, and neither
can bypass unknown, queued, submitting or paused Gmail ownership. Keep the new
identity. Finish the recovery fields through a normal update before sending.
An unpaused source with a kept Gmail copy passes that warning to the new recovery
draft atomically and clears any previous send acknowledgement. The response
includes gmailLink and contentDigest, including with acknowledgementOnly.
The original link remains unchanged; the local copy is not recorded as a Gmail
import. Finish editing and obtain a fresh acknowledgement before sending.