aim-mailbox 0.3.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brian Vasquez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,365 @@
1
+ Metadata-Version: 2.4
2
+ Name: aim-mailbox
3
+ Version: 0.3.5
4
+ Summary: A-Mail (amail / aim-mail): Zero-daemon, zero-LLM local Maildir post office and cross-OS wake dispatcher for AI coding agents
5
+ Author: Brian Vasquez
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/BrianV1981/aim-mailbox
8
+ Project-URL: Repository, https://github.com/BrianV1981/aim-mailbox
9
+ Project-URL: Changelog, https://github.com/BrianV1981/aim-mailbox/blob/main/CHANGELOG.md
10
+ Project-URL: Ecosystem, https://github.com/BrianV1981/aim-ecosystem
11
+ Project-URL: Issues, https://github.com/BrianV1981/aim-mailbox/issues
12
+ Keywords: a-mail,amail,aim-mail,ai-agents,mailbox,maildir,cli,orchestration,multi-agent,windows,wsl
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=8.0; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ # aim-mailbox — A-Mail (`amail` / `aim-mail`)
32
+
33
+ **Zero-daemon, zero-LLM local Maildir post office, priority wake router, and cross-OS turn-hook installer for AI coding agents.**
34
+
35
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
36
+ [![Python 3.10+](https://img.shields.io/badge/Python-3.10%2B-blue.svg)](pyproject.toml)
37
+ [![Dependencies: 0](https://img.shields.io/badge/Runtime%20Deps-0%20(pure%20stdlib)-brightgreen.svg)](pyproject.toml)
38
+ [![Platforms: Win11 | WSL2 | Linux | macOS](https://img.shields.io/badge/Platforms-Win11%20%7C%20WSL2%20%7C%20Linux%20%7C%20macOS-blue.svg)](#sharing-one-mailbox-between-native-windows-11-and-wsl2)
39
+ [![A.I.M. Ecosystem](https://img.shields.io/badge/A.I.M.-Ecosystem-00d4ff.svg)](https://github.com/BrianV1981/aim-ecosystem)
40
+
41
+ **A-Mail** (`aim-mailbox` `v0.3.5`, CLI `amail` / `aim-mail`, canonical skill [`skills/aim-mail/SKILL.md`](skills/aim-mail/SKILL.md)) lets autonomous AI coding agents communicate asynchronously across **Linux, WSL2, macOS, and Native Windows 11** and across heterogeneous harnesses (**Antigravity Desktop/IDE, DeepSeek Harness Desktop (`dsh`), OpenAI Codex Desktop & CLI (`codex`), Antigravity CLI, OpenCode, Grok Build, VS Code Agent Mode, `tmux`, and custom GUI/CLI tools**) using **pure Python 3.10+ stdlib (`0` pip runtime dependencies, `0` resident database daemons, and `0` idle LLM tokens)** — superseding legacy `aim-communicate` shell paste workflows.
42
+
43
+ ---
44
+
45
+ ## Why `aim-mailbox` Exists
46
+
47
+ Multi-agent coding workflows break down at three physical boundaries that most terminal-only or cloud-only orchestrators ignore:
48
+
49
+ 1. **The `tmux` Wall (No Native Windows 11 Support):** Traditional agent relays paste keystrokes into POSIX `tmux` panes. Because `tmux` requires Unix PTYs and `fork()`, native Windows 11 PowerShell (`pwsh`) and `cmd.exe` hosts cannot participate without forcing every agent inside WSL2.
50
+ 2. **The One-Way GUI Diode:** Desktop IDE/Electron apps (Antigravity Desktop/IDE, VS Code, Cursor) can run outbound shell commands (`amail send`), but external terminal scripts cannot `tmux paste-buffer` inbound into a graphical chat window. Reaching a minimized or background GUI session requires deterministic harness-native sidecars/HTTP APIs (`agentapi`, `opencode serve`, `code chat`).
51
+ 3. **The Windows 11 NTFS ↔ WSL2 `/mnt/c` (`9P`) SQLite Trap:** Lightweight SQLite-based mail CLIs rely on WAL (`-wal`/`-shm`) shared-memory locking, which throws `sqlite3.OperationalError: database is locked` or corrupts state when native Windows 11 processes and WSL2 Linux processes access the same shared folder across the `9P` filesystem bridge.
52
+
53
+ `aim-mailbox` solves all three by decoupling **lock-free atomic Maildir storage** (Layer 1) from **pluggable last-mile wake dispatchers, mechanical safety guards (`--dnd`, `--operator-approved`, `max_hops`), and `<2ms` turn-boundary hooks** (Layer 2).
54
+
55
+ ---
56
+
57
+ ## Comparison: Open-Source & Paid Alternatives (Honest Breakdown)
58
+
59
+ Many comparisons lump thin **inter-agent message buses** together with full **company/PR control planes**. Below is an apples-to-apples breakdown across both layers, followed by guidance on when `aim-mailbox` is—and isn't—the right fit.
60
+
61
+ ### 1. Direct Inter-Agent Mailboxes, Relays & Protocols
62
+
63
+ | Tool / Protocol | License / Pricing | Storage & Runtime | Wake / Delivery Mechanism | Win11 NTFS ↔ WSL2 `9P` Safe? | Cross-Harness? | Where It Excels & Honest Tradeoff vs. `aim-mailbox` |
64
+ | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
65
+ | **`aim-mailbox` — A-Mail (`amail` / `aim-mail`)** | **MIT (Free, OSS)** | **Pure-stdlib atomic JSON Maildir (`0` deps, `0` daemons)** | **11 native wake drivers + `<2ms` `check --inject` hooks** | **Yes** (`os.replace` + NTFS retries) | **Yes** (`agy`, `dsh`, Codex Desktop/CLI, OpenCode, Grok, VS Code, `tmux`, custom) | **Zero-daemon cross-OS durability, minimized Win11 Desktop Sidecar / DSH Cordis / Codex Desktop wakes, `--dnd` & `max_hops` gates.** *Tradeoff:* single-host/shared-FS only (no built-in cloud/MQTT network relay). |
66
+ | **[`aannoo/hcom`](https://github.com/aannoo/hcom)** | MIT (OSS) | Rust CLI + TUI + local SQLite + optional **MQTT relay** | Wraps CLI launch (`hcom claude`, `hcom agy`) + lifecycle hooks | **No** (SQLite WAL over `9P`) | **Yes** (`14` CLIs) | **Strongest terminal UX & reactive chains:** live TUI, `hcom events --idle` triggers, and cross-device MQTT relay. *Tradeoff:* requires `hcom <cli>` wrapper + SQLite; cannot wake minimized Antigravity Desktop Sidecars. |
67
+ | **[`mcp_agent_mail_rust`](https://github.com/Dicklesworthstone/mcp_agent_mail_rust)** *(rewrote `mcp_agent_mail`)* | **Non-OSI** (MIT + OpenAI/Anthropic rider) | Rust HTTP MCP server (`:8765`) + SQLite + Tantivy + Git archive | Client MCP polling (`fetch_inbox`), `am robot` CLI, pre-commit hook | **No** (SQLite WAL + server) | MCP clients | **Richest audit archive & TUI:** 16-screen TUI, `/mail/` Web UI, advisory file leases, `build_slots`. *Tradeoff:* **47 MCP tools + 25 resources** add heavy prompt/schema overhead; resident server; non-OSI license rider. |
68
+ | **[`AgentWorkforce/relay`](https://github.com/AgentWorkforce/relay)** | Apache-2.0 (+ Paid Desktop/Cloud) | Node 22+ / Rust + *Relaycast* daemon/cloud + *Relayfile* VFS | Auto-join workspaces, channels, DMs, threads & TypeScript *Flows* | Cloud / Daemon | **Yes** (CLIs) | **Best multi-developer team channels** + *Relayfile* webhook-to-filesystem projection. *Tradeoff:* heavier multi-service daemon/cloud stack vs. a zero-install stdlib CLI. |
69
+ | **Claude Code Agent Teams** (`SendMessage`) | Paid Claude plan (**$20–$200/mo** or API) | Local JSON array files (`~/.claude/teams/*/inboxes/*.json`) | Built-in `<teammate-message>` context injection + `tmux`/`iTerm2` | Single-file RMW | **No** (Claude Code only) | **Zero-setup inside Claude** with shared task-DAG self-claiming. *Tradeoff:* **100% vendor-locked** (cannot message Codex, Grok, Antigravity, or OpenCode) and ~`7x` parallel token burn. |
70
+ | **[`mco-org/squad`](https://github.com/mco-org/squad)** & **`agent-mail-cli`** | MIT (OSS) | Rust / Python CLI + local SQLite | Passive CLI queries or basic POSIX `tmux` roles | **No** (SQLite WAL) | Partial (CLI callers) | Tiny cognitive footprint (`--ref` pointers, `describe`). *Tradeoff:* passive (`agent-mail-cli` cannot wake sleeping sessions) and no Windows Desktop Sidecar routing. |
71
+ | **[`a2aproject/A2A`](https://github.com/a2aproject/A2A)** *(Google / Linux Foundation)* | Apache-2.0 (Open Spec) | HTTP(S) JSON-RPC 2.0 + SSE + `.well-known/agent.json` | Network push/stream between HTTP agent servers | Network HTTP | **Yes** (HTTP services) | **Enterprise standard for cross-org / cross-network black-box agents.** *Tradeoff:* requires HTTP servers per agent rather than `0`-RAM local CLI worktrees. |
72
+ | **[AgentMail (`agentmail.to`)](https://agentmail.to)** | Free / **$20–$200/mo** API SaaS | Hosted cloud SMTP / IMAP / REST / WebSockets / MCP | Webhooks & WebSockets on real internet email | Cloud API | **Yes** (REST/MCP) | **Solves real internet email** (SPF/DKIM/DMARC for agents emailing external humans/vendors). *Tradeoff:* external email SaaS, not a sub-millisecond local IPC bus. |
73
+
74
+ ### 2. Full-Stack Fleet Orchestrators & Cloud Platforms (Adjacent Layer)
75
+
76
+ If you are evaluating all-in-one orchestrators rather than a standalone message bus, those platforms correspond to **`aim-mailbox` + [`aim-joshua`](https://github.com/BrianV1981/aim-joshua) + [`aim-connect`](https://github.com/BrianV1981/aim-connect)** combined:
77
+
78
+ | Platform | License / Pricing | Architecture & Standout Strength | Why Keep `aim-mailbox` Modular Instead? |
79
+ | :--- | :--- | :--- | :--- |
80
+ | **[`paperclipai/paperclip`](https://github.com/paperclipai/paperclip)** | MIT (+ Cloud waitlist) | Node.js + React + PostgreSQL "Company OS" with org charts, heartbeats, and **hard dollar/token budget caps** | Requires running a Node + Postgres server; `aim-mailbox` stays `0`-dep/serverless so any script or orchestrator can call `amail` directly. |
81
+ | **[`OrchestratorInc/agent-orchestrator`](https://github.com/OrchestratorInc/agent-orchestrator)** | Apache-2.0 | Cross-OS Electron Desktop + CLI across 30+ agents; **auto-routes failed CI checks & PR review comments** back to the branch worker | Couples workflow state to an Electron desktop app; `amail send --coalesce-key` gives external CI pollers the same primitives in pure CLI form. |
82
+ | **[`gastownhall/gastown`](https://github.com/gastownhall/gastown)** + **[`beads`](https://github.com/gastownhall/beads)** | MIT | Go + Dolt + SQLite + ICU + `tmux` (`gt mail`, *Witness* watchdogs, *Refinery* merge queue, *Seance* session queries) | Powerful 20–30 agent factory, but heavy build/runtime prerequisites (Go, Dolt, ICU4C, POSIX `tmux`) vs. drop-in Python stdlib. |
83
+ | **[`manaflow-ai/cmux`](https://github.com/manaflow-ai/cmux)** & **`amux`** | Custom OSS (`cmux`) / **$39–$129/mo** (`amux`) | GPU macOS terminal (`libghostty`) with socket API & notification rings (`cmux`); managed `tmux` server (`amux`) | **macOS-only** (`cmux`) or POSIX `tmux`-bound (`amux`); no native Windows 11 or cross-OS Maildir durability. |
84
+ | **Factory Droid / Cursor Cloud / Devin / Ona** | **$20–$200+/mo** + compute credits | Turnkey cloud Linux microVMs triggered from Slack, Linear, IDE, or webhooks | Zero local setup, but **vendor-siloed** with recurring seat/VM fees—cannot coordinate local `agy` + `grok` + `opencode` + `codex` on your own disk. |
85
+
86
+ ### When to Choose `aim-mailbox` vs. Something Else
87
+
88
+ - **Use `aim-mailbox` (`amail`) when:** you run multiple AI coding harnesses on your own machine (especially mixed **Windows 11 + WSL2**, Linux, or macOS) and want durable lock-free messaging, true sleeping-agent wakeups (including minimized Desktop IDEs), mechanical `--dnd` / `--operator-approved` / `max_hops` safety rails, `<2ms` turn hooks, and **`0` daemons or dependencies**.
89
+ - **Use another tool when:** your agents need real external `@yourdomain.com` internet email (**AgentMail.to**), out-of-the-box multi-machine LAN/cloud pub-sub channels (**`hcom`** or **`AgentWorkforce/relay`**), cross-company HTTP federation (**A2A**), or a turnkey hosted cloud sandbox (**Factory Droid / Cursor / Devin / Ona**).
90
+
91
+ ---
92
+
93
+ ### Our Moat: 6 Structural Advantages
94
+
95
+ 1. **Zero-Daemon, Cross-Boundary Atomic Storage (`Windows 11 NTFS ↔ WSL2 9P`):** Every message is an immutable-stage JSON file written to `tmp/` and atomically moved via `os.replace()` with NTFS `PermissionError`/`EBUSY` retries. Windows 11 native tools and WSL2 Linux processes share one `~/.aim/mailbox` (`AIM_MAILBOX_DIR`) concurrently with zero SQLite `database is locked` failures.
96
+ 2. **True Sleeping-Agent Wake-Up Without PTY Wrapping:** Rather than trapping interactive CLIs inside a fragile PTY proxy (`relay`, `hcom`) or restricting you to POSIX `tmux` (`amux`), `aim-mailbox` wakes **11 surfaces natively**—including minimized Windows 11 Antigravity Desktop windows via Sidecar `agentapi`, DeepSeek Harness Desktop via its loopback Cordis plugin (`/wake`), OpenAI Codex Desktop via `codex queue` + `codex://threads/wake/<uuid>`, headless stateful CLI resumes (`agy --conversation`, `grok --resume`, `codex exec resume`), OpenCode HTTP sessions, VS Code Agent Mode, and `Enter`-only `tmux` doorbells.
97
+ 3. **`<2ms` Empty-Inbox Turn Hooks + `<50ms` Fleet Diagnostics (`v0.3.1+`):** `amail check <agent> --inject --quiet` short-circuits in `<2ms` on POSIX (`<10ms` in Python `-S`) when `unread/` is empty, and `amail agents --check` probes live `tmux` foreground commands, cross-OS Windows Sidecar & DSH heartbeats (`_sidecar_heartbeat.json`, `_dsh_heartbeat.json`), DND badges, and `unread`/`claimed`/`dead` counts in `<50ms` on POSIX `ext4`.
98
+ 4. **Priority Lanes & `coalesce_key` Noise Suppression (`v0.2.0`):** Emergency `urgent` stops wake ahead of `normal` traffic, duplicate status updates sharing `--coalesce-key` collapse cleanly into one wake batch (retiring superseded `ack_required=True` envelopes to `done/` with `coalesced_into` only after `DELIVERED`), and `low` traffic batches inside bounded `--low-batch-window` windows.
99
+ 5. **Mechanical DND, Loop & Permission Guardrails (`v0.3.1`):** Enforces mechanical Do-Not-Disturb (`amail register <agent> --dnd [--dnd-ttl <sec>]`) so peer agents cannot wake protected live batches, `max_hops` thread propagation (quarantining loops to `dead/` *before* waking any LLM), fail-closed `--operator-approved` gating (`rc=2`), `0o700`/`0o600` permissions, and `defer=True` busy handling.
100
+ 6. **Zero Dependencies & ~50-Token Self-Describing Surface:** `0` runtime pip dependencies, `<= 15` CLI subcommands (`amail describe` / `aim-mail describe`), bundled canonical [`skills/aim-mail/SKILL.md`](skills/aim-mail/SKILL.md), and MIT licensing—drop it into any repo via zero-install launchers (`bin/amail`, `bin/amail.cmd`, `bin/amail.ps1`, plus `bin/aim-mail*`) with no vendor lock-in or MCP context bloat.
101
+
102
+ ---
103
+
104
+ ## Architecture & Maildir Lifecycle
105
+
106
+ ```text
107
+ ~/.aim/mailbox/ # Or %USERPROFILE%\.aim\mailbox via AIM_MAILBOX_DIR
108
+ ├── agents.json # Locked RMW address book: driver, cwd, dnd, dnd_until
109
+ ├── locks/
110
+ │ ├── _agents.lock.json # Atomic O_CREAT|O_EXCL lock for agents.json updates
111
+ │ ├── _sidecar_heartbeat.json # Non-fatal Sidecar liveness stamp for cross-OS `agents --check`
112
+ │ ├── _dsh_heartbeat.json # Non-fatal DeepSeek Harness Cordis bridge liveness stamp
113
+ │ └── <agent_id>.lock.json # Per-agent dispatch lease lock (PID + TTL stale recovery)
114
+ └── boxes/
115
+ └── <agent_id>/
116
+ ├── tmp/ # 0600 staged temp file + fsync before atomic os.replace()
117
+ ├── unread/ # Delivered envelopes awaiting wake/read/check
118
+ ├── claimed/ # Leased to an active wake or `read --claim`
119
+ ├── done/ # ACKed, replied-to, or coalesced-retired envelopes + receipts
120
+ └── dead/ # Quarantined envelopes (max_hops exceeded or max_attempts failed)
121
+ ```
122
+
123
+ ### Envelope Schema (`v0.3.x`)
124
+
125
+ ```json
126
+ {
127
+ "id": "20261124T210000000000Z_a1b2c3d4",
128
+ "thread_id": "thr_9f8e7d6c5b4a",
129
+ "in_reply_to": null,
130
+ "from": "aim-joshua",
131
+ "to": "copy-cat",
132
+ "reply_to": "aim-joshua",
133
+ "subject": "Schema check",
134
+ "body": "Validate ep02 manifest structure; see attached ref.",
135
+ "refs": ["specs/ep02.json"],
136
+ "priority": "normal",
137
+ "coalesce_key": "ep02:schema",
138
+ "coalesced_ids": [],
139
+ "hop_count": 0,
140
+ "max_hops": 1,
141
+ "ack_required": true,
142
+ "operator_approved": true,
143
+ "attempts": 0,
144
+ "max_attempts": 3,
145
+ "created_at": "2026-11-24T21:00:00.000000Z"
146
+ }
147
+ ```
148
+
149
+ ### Reliability & Security Invariants
150
+
151
+ - **Atomic Moves & NTFS Retry:** `write_json_atomic()` writes with `O_CREAT | O_EXCL` (`0o600`), calls `os.fsync()`, and swaps via `_replace_with_retry()` (6 attempts with backoff on `PermissionError` / `EACCES` / `EBUSY` for Windows Defender/indexer delete-pending locks).
152
+ - **Path & Input Validation:** Agent IDs normalize to lowercase (`@Worker` → `worker`), disallow `..`, trailing `.`, path separators, and Windows reserved device names (`CON`, `NUL`, `COM1`–`COM9`, `LPT1`–`LPT9`). Message IDs, session IDs, HTTP URLs (`http://`/`https://` only), and `--archive-dir` targets are strictly confined.
153
+ - **Busy & DND Deferral vs. Failure Quarantine:** Mid-turn sessions (`BUSY_DEFERRED`) and muted targets (`DND_ACTIVE`, including auto-expiring `--dnd-ttl` windows) keep envelopes in `unread/` **without** incrementing `attempts`. Actual crashes/timeouts increment `attempts` and quarantine to `dead/` once `attempts >= max_attempts`.
154
+ - **Cross-OS Watcher Host-Affinity Isolation (`v0.2.2`):** When Windows 11 Sidecar `watch` and WSL2/POSIX `pulse` share one `agents.json`, `pulse_mailbox()` skips opposite-OS drivers (`tmux` / POSIX `cwd` on Windows; `agy-desktop-sidecar` without `ANTIGRAVITY_LS_ADDRESS` or Windows `<drive>:\` `cwd` on POSIX) *before* acquiring agent locks or claiming unread files—never burning `attempts` or quarantining cross-OS mail to `dead/`.
155
+ - **Fail-Closed Wake Policy:** `send --wake` and `reply --wake` exit `2` if the target is unregistered, passive (`driver=none`), missing `--operator-approved` (unless the target agent has `--allow-unapproved`), or deferred/remote-skipped (`DND_ACTIVE`, `BUSY_DEFERRED`, `AGENT_LOCK_HELD`, `LOW_PRIORITY_BATCH_WINDOW`, `HOST_MISMATCH`, `SIDECAR_CONTEXT_REQUIRED`, `DSH_BRIDGE_UNAVAILABLE`, `WSL_TMUX_SESSION_OFFLINE`) without `--allow-deferred`.
156
+
157
+ ---
158
+
159
+ ## Installation
160
+
161
+ Both **`amail`** (short primary alias) and **`aim-mail`** are installed side-by-side and behave identically across POSIX and Windows.
162
+
163
+ ### Option A: `pip` / `pipx` (Editable or Wheel)
164
+ ```bash
165
+ pip install -e .
166
+ amail --version
167
+ aim-mail --version
168
+ ```
169
+
170
+ ### Option B: Zero-Install Shims & User-Bin Symlinks (Clone & Run Immediately)
171
+ - **Linux / macOS / WSL2:** `./bin/amail --help` and `./bin/aim-mail --help` *(symlink-safe for `~/.local/bin`)*:
172
+ ```bash
173
+ mkdir -p ~/.local/bin
174
+ ln -sfn "$(pwd)/bin/amail" ~/.local/bin/amail
175
+ ln -sfn "$(pwd)/bin/aim-mail" ~/.local/bin/aim-mail
176
+ ```
177
+ - **Windows CMD:** `.\bin\amail.cmd --help` / `.\bin\aim-mail.cmd --help`
178
+ - **Windows PowerShell:** `.\bin\amail.ps1 --help` / `.\bin\aim-mail.ps1 --help`
179
+
180
+ ### Canonical Agent Skill (`aim-mail`)
181
+ Install [`skills/aim-mail/SKILL.md`](skills/aim-mail/SKILL.md) (or via [`aim-skill-library`](https://github.com/BrianV1981/aim-skill-library)) into your harness skill directory (`~/.gemini/skills/aim-mail`, `~/.gemini/antigravity-cli/skills/aim-mail`, `~/.dsh/skills/aim-mail`, `~/.grok/skills/aim-mail`, `~/.codex/skills/aim-mail`, `~/.config/opencode/skills/aim-mail`). A-Mail replaces `aim-communicate` and standalone `tmux` paste scripts across all vessels.
182
+
183
+ ### Sharing One Mailbox Between Native Windows 11 and WSL2
184
+ Point WSL2 at your Windows user mailbox directory so native Windows apps and WSL2 CLI agents read and write the exact same Maildir:
185
+ ```bash
186
+ # Inside WSL2 (~/.bashrc)
187
+ export AIM_MAILBOX_DIR="/mnt/c/Users/<YourWindowsUser>/.aim/mailbox"
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Quickstart & Workflows
193
+
194
+ ### 1. Core Messaging & Wake Loop (`amail` / `aim-mail`)
195
+ ```bash
196
+ # Register logical agents by project folder (zero session-id updates needed across handoffs!)
197
+ amail register aim-auditor --driver agy-cli --cwd ~/aim-auditor
198
+ amail register copy-cat --driver agy-desktop-sidecar --cwd "C:\Projects\copy-cat"
199
+ amail register aim-connect --driver tmux --tmux-session aim-connect --cwd ~/aim-connect
200
+ amail register backend-dev --driver opencode-http --http-url http://127.0.0.1:4096
201
+
202
+ # Send an operator-approved message with a file ref and immediate wake
203
+ amail send \
204
+ --from aim-joshua \
205
+ --to aim-connect \
206
+ --reply-to aim-joshua \
207
+ --subject "Schema check" \
208
+ --body "Please validate ep02 manifest structure." \
209
+ --ref specs/ep02.json \
210
+ --operator-approved \
211
+ --wake
212
+
213
+ # Recipient reads, replies (auto-incrementing hop_count & ACKing parent), or ACKs
214
+ amail inbox aim-connect --state active
215
+ amail read aim-connect --claim
216
+ amail reply aim-connect <msg_id> --body "Verified: schema passes validation. DO NOT reply."
217
+
218
+ # Or run a single-pass / continuous zero-LLM dispatcher sweep
219
+ amail pulse
220
+ amail watch --interval 1.5
221
+ ```
222
+
223
+ ### 2. Fleet Health Diagnostics & Mechanical Do-Not-Disturb (`v0.3.1`)
224
+ ```bash
225
+ # Inspect live tmux foreground processes, Windows Sidecar & DSH heartbeat freshness, DND flags,
226
+ # and unread / claimed / dead-letter counts across every endpoint in <50ms on POSIX ext4:
227
+ amail agents --check
228
+ amail agents --check --json
229
+
230
+ # Mechanically mute a production batch agent for 2 hours (auto-expires; blocks --wake with rc=2):
231
+ amail register batch-worker --dnd --dnd-ttl 7200 --dnd-reason "publishing scheduled drip"
232
+
233
+ # Queue mail safely for later without waking the DND agent, or unmute manually anytime:
234
+ amail send --from aim-joshua --to batch-worker --body "Run post-batch audit" --operator-approved --wake --allow-deferred
235
+ amail register batch-worker --no-dnd
236
+ ```
237
+
238
+ ### 3. Priority Lanes & `--coalesce-key` Batching (`v0.2.0`)
239
+ ```bash
240
+ # Urgent alerts jump ahead of normal/low mail (still requires --operator-approved & obeys max_hops)
241
+ amail send --from lead --to worker --body "STOP: rollback migration" --priority urgent --operator-approved --wake
242
+
243
+ # Repeated CI/status updates with the same --coalesce-key collapse into one wake batch
244
+ amail send --from ci --to worker --body "Build #41 green" --coalesce-key ci:main --operator-approved
245
+ amail send --from ci --to worker --body "Build #42 green" --coalesce-key ci:main --operator-approved
246
+ amail pulse --agent worker
247
+ # -> Wakes once with Build #42; Build #41 is cleanly retired to done/ with coalesced_into=<Build #42 id>
248
+
249
+ # Low-priority mail defers inside --low-batch-window (default 30s) until the oldest waits >= window
250
+ amail send --from metrics --to worker --body "Nightly digest" --priority low --operator-approved --wake --allow-deferred
251
+ amail pulse --low-batch-window 30
252
+ ```
253
+
254
+ ### 4. Inbox Filtering & Maildir Retention `gc` (`v0.2.0`)
255
+ ```bash
256
+ # Pure-stdlib envelope queries without SQLite/FTS5
257
+ amail inbox worker --state all --from aim-joshua --priority urgent --query "migration" --since 2026-11-24T00:00:00Z --limit 10 --json
258
+
259
+ # Preview retention cleanup (ages done/ by acked_at, dead/ by quarantined_at; never touches unread/ or claimed/)
260
+ amail gc --done-days 14 --dead-days 30 --archive-dir ~/.aim/mailbox-archive --dry-run --json
261
+
262
+ # Execute atomic archive + unlink
263
+ amail gc --done-days 14 --dead-days 30 --archive-dir ~/.aim/mailbox-archive
264
+ ```
265
+
266
+ ### 5. One-Command Turn-Boundary Hooks (`v0.2.0`)
267
+ Install non-destructive turn-boundary hooks calling `amail check <agent> --inject --quiet` (`<2ms` empty-inbox overhead via `bin/amail` / `bin/aim-mail`):
268
+ ```bash
269
+ # Antigravity (writes "aim-mailbox" into ~/.gemini/config/hooks.json or <workspace>/.agents/hooks.json)
270
+ amail install-hooks --harness agy --agent aim-auditor
271
+
272
+ # Codex Desktop + CLI (non-destructively merges Stop hook in ~/.codex/hooks.json + Host-plane [mcp_servers.aim_mail] in ~/.codex/config.toml)
273
+ amail install-hooks --harness codex --agent codex-worker
274
+
275
+ # Grok Build (writes standalone ~/.grok/hooks/aim-mailbox.json)
276
+ amail install-hooks --harness grok --agent grok-worker
277
+
278
+ # DeepSeek Harness Desktop (`dsh` — installs hot-reloaded Cordis plugin, Host-plane `aim_mail` tool & skill)
279
+ amail install-hooks --harness dsh --agent dsh-worker
280
+
281
+ # OpenCode / Generic (writes standalone shell/.cmd hook without mutating opencode.json)
282
+ amail install-hooks --harness opencode --agent oc-worker
283
+ amail install-hooks --harness generic --agent my-agent
284
+
285
+ # Preview or cleanly remove anytime
286
+ amail install-hooks --harness agy --agent aim-auditor --dry-run --json
287
+ amail install-hooks --harness agy --agent aim-auditor --uninstall
288
+ ```
289
+
290
+ ---
291
+
292
+ ## Pluggable Wake Drivers
293
+
294
+ | Driver | Target Surface | Session Targeting & Wake Mechanics |
295
+ | :--- | :--- | :--- |
296
+ | `agy-desktop-sidecar` | **Antigravity Desktop / IDE** (Win11, macOS, Linux) | Runs inside an official Antigravity Sidecar (`amail install-agy-sidecar`), writes `_sidecar_heartbeat.json` each cycle, auto-resolves the latest top-level `conversation_id` for `--cwd` from `conversation_summaries.db` across handoffs, and invokes `agentapi send-message` — works even while Desktop is minimized. |
297
+ | `dsh-desktop` | **DeepSeek Harness Desktop (`dsh`)** (Win11, macOS, Linux) | Pairs with the bundled Cordis plugin (`amail install-hooks --harness dsh`, hot-reloaded via `cordis.patch.yml`), writes `_dsh_heartbeat.json`, auto-resolves or creates the latest `session-*` for `--cwd` via `workspaceRegistry` / `sessionController`, bypasses Windows `pwsh` ACL sandbox prompts via a Host-plane `aim_mail` tool, and wakes minimized sessions directly from Windows or WSL2. |
298
+ | `codex-desktop` | **OpenAI Codex Desktop** (`OpenAI.Codex` MSIX / App) | Auto-discovers MSIX `codex.exe`, resolves `--session-id` (UUID or thread name) or `auto(cwd)` from `state_5.sqlite` (`threads` / `project_roots`, including `\\?\` extended paths), bypasses open GUI `thread-writer-locks` via `codex queue` + silent `codex://threads/wake/<uuid>` (`isWakeOnlyLaunch`), and pairs with `amail install-hooks --harness codex` (`[mcp_servers.aim_mail]` Host-plane stdio MCP) to avoid Windows sandbox ACL prompts. |
299
+ | `agy-cli` | **Antigravity CLI (`agy`)** (Win11, WSL2, macOS, Linux) | Auto-resolves the latest top-level `conversation_id` for `--cwd` (or uses explicit `--session-id`), checks read-only `conversation_summaries.db` (`CASCADE_RUN_STATUS_IDLE`) + `presence/<uuid>.lock`, and wakes `agy --conversation <uuid> --output-format json -p <prompt>` (`--dangerously-skip-permissions` is opt-in via `--allow-skip-permissions`). |
300
+ | `opencode-http` | **OpenCode Desktop + CLI** (`opencode serve`) | Sends `POST <http_url>/session/<id>/message` using OpenCode `parts` schema (auto-creating and persisting a session via `POST /session` if unset). |
301
+ | `grok-cli` | **Grok Build (`grok`)** (Win11, WSL2, macOS, Linux) | Wakes `grok --no-auto-update --output-format json [--resume <id>] [--cwd <dir>] -p <prompt>`. |
302
+ | `codex-cli` | **OpenAI Codex CLI** (`codex`) (Win11, WSL2, macOS, Linux) | Wakes `codex exec resume --json <id> <prompt>` (or `codex exec --json --add-dir <mailbox> <prompt>` on first run, auto-saving `thread_id`). |
303
+ | `vscode-chat` | **VS Code (`v1.145+`)** (Win11, macOS, Linux) | Injects into Agent Mode via `code chat -m agent -r <prompt>`. |
304
+ | `tmux` | **Live Interactive TUI** (WSL2, Linux, macOS; bridged from Win11 via `wsl.exe`) | Uses exact `=<session>` / `=<session>:` targeting (bridging automatically via `wsl.exe --exec tmux` + `/mnt/<drive>/...` doorbell paths when invoked from Windows 11), pastes a 1-line doorbell via `set-buffer --` + `paste-buffer`, submits with **`Enter` only** (never `Escape`), and verifies delivery via `capture-pane`. |
305
+ | `command` | **Custom Script / GUI Vision Fallback** | Runs a custom JSON argv template (`{agent}`, `{message_id}`, `{message_ids}`, `{session_id}`, `{mailbox_dir}`, `{prompt}` + `AIM_MAIL_*` env vars) for tools such as local GUI vision automation. |
306
+ | `none` | **Passive Inbox** | Stores envelopes without automated wake-up (manual `inbox`/`read` or `check --inject` turn hooks). |
307
+
308
+ ### Enabling the Antigravity Desktop Sidecar
309
+ Antigravity Desktop hot-loads sidecars registered in `~/.gemini/config/config.json` (`%USERPROFILE%\.gemini\config\config.json`) without restarting the app:
310
+ ```powershell
311
+ amail install-agy-sidecar
312
+ # Remove anytime with:
313
+ amail install-agy-sidecar --uninstall
314
+ ```
315
+
316
+ ---
317
+
318
+ ## CLI Reference (15 Subcommands — `amail` / `aim-mail`)
319
+
320
+ | Command | Purpose |
321
+ | :--- | :--- |
322
+ | `amail register <agent> [...]` | Register, update, or `--unregister` an agent, wake driver, `--dnd` / `--no-dnd` (`--dnd-ttl`, `--dnd-reason`), `--allow-unapproved`, and `--allow-skip-permissions` |
323
+ | `amail agents [--check] [--json]` | List registered logical agents, or pass `--check` to probe live `tmux`/Sidecar presence, DND state, and `unread`/`claimed`/`dead` counts |
324
+ | `amail send --from <a1> --to <a2> --body "..."` | Deliver JSON envelope (`--priority urgent\|normal\|low`, `--coalesce-key`, `--ref`, `--thread-id`, `--operator-approved`, `--wake`, `--allow-deferred`) |
325
+ | `amail inbox <agent> [--state ...]` | List/filter envelopes (`--state unread\|claimed\|done\|dead\|active\|all`, `--from`, `--thread-id`, `--priority`, `--query`, `--since`, `--limit`) |
326
+ | `amail read <agent> [id] [--claim] [--ack]` | Read a specific or oldest unread/claimed envelope |
327
+ | `amail reply <agent> <id> --body "..."` | Reply to `reply_to`, increment `hop_count`, auto-ACK parent (`--priority`, `--coalesce-key`, `--ack-required` / `--no-ack-required`, `--wake`, `--allow-deferred`) |
328
+ | `amail ack <agent> <id> [--note "..."]` | Move envelope to `done/` with completion timestamp |
329
+ | `amail check <agent> [--inject] [--quiet]` | `<2ms` (`<15ms` Python) unread check (`--format text\|agy-inject\|agy-stop`, `--json`) |
330
+ | `amail wait <agent> [--thread-id ...]` | Block at `0` LLM cost until matching mail arrives (`--claim`, `--timeout`, `--poll-interval`) |
331
+ | `amail pulse [--agent ...] [--dry-run]` | Single-pass zero-LLM wake sweep (`--timeout`, `--low-batch-window`) |
332
+ | `amail watch [--interval 1.5]` | Continuous zero-LLM Maildir watch loop (`--max-cycles`, `--timeout`, `--low-batch-window`) |
333
+ | `amail gc [--done-days 14] [--dead-days 30]` | Prune or `--archive-dir` aged terminal envelopes in `done/` and `dead/` (`--agent`, `--dry-run`) |
334
+ | `amail install-agy-sidecar` | Non-destructively install or `--uninstall` the Antigravity Desktop Sidecar |
335
+ | `amail install-hooks --harness <name>` | Non-destructively install/uninstall turn-boundary hooks & DSH Cordis plugin (`agy`, `codex`, `grok`, `dsh`, `opencode`, `generic`) |
336
+ | `amail describe [--json]` | Output compact JSON schema of commands, aliases, drivers, harnesses, states, priorities, and env vars |
337
+
338
+ ### Environment Variables
339
+ - `AIM_MAILBOX_DIR` — Override default `~/.aim/mailbox` root directory (useful for sharing `%USERPROFILE%\.aim\mailbox` across Windows 11 and WSL2).
340
+ - `OPENCODE_SERVER_USERNAME` / `OPENCODE_SERVER_PASSWORD` — Optional HTTP Basic Auth credentials for `opencode-http`.
341
+
342
+ ---
343
+
344
+ ## Testing & Explicit Non-Goals
345
+
346
+ Run the full 54-test unit + unmocked CLI E2E suite (tested continuously on `ubuntu-latest` + `windows-latest` CI and scanned by `gitleaks`):
347
+ ```bash
348
+ python3 -m pytest tests/ -v -W error::DeprecationWarning
349
+ ```
350
+
351
+ ### Architectural Non-Goals (Intentional Guardrails)
352
+ - **No SQLite or FTS5 storage:** Avoids cross-OS `9P` / NTFS WAL locking failures.
353
+ - **No resident socket daemons or PTY proxies:** Preserves `0` idle RAM and native Windows Desktop compatibility.
354
+ - **No startup MCP schema bloat or subcommand sprawl:** Keeps the CLI surface `<= 15` self-describing commands with `0` runtime pip dependencies.
355
+ - **No path-glob advisory file leases:** Isolated `git worktree` sandboxes prevent concurrent edit collisions without brittle cross-OS symlink/glob matching.
356
+
357
+ ---
358
+
359
+ ## Ecosystem
360
+
361
+ Part of the open-source **[A.I.M. Ecosystem](https://github.com/BrianV1981/aim-ecosystem)**.
362
+
363
+ ## License
364
+
365
+ Released under the [MIT License](LICENSE).