Skip to main content
Glama
README.md
# agent-inbox

Zero-dependency local MCP message broker for coordinating concurrent AI coding sessions across **Antigravity (`agy`)**, **Claude Code**, **Codex**, **OpenCode**, and **Cursor**.

- **Zero daemon, zero ports, zero npm dependencies** — backed by a single local SQLite database (WAL mode) using Node 22.5+'s built-in `node:sqlite` or Bun's built-in `bun:sqlite`.
- **Cross-harness discovery** — every session auto-registers its harness, git branch, cwd, and PID (dead sessions are filtered out automatically).
- **Sub-second replies & idle auto-wakeup** — send + wait in a single call (`wait_for_reply_seconds`), or run `agent-inbox watch --name <handle>` as a background task so your harness wakes up an idle session automatically when a message lands.

## Quickstart

```bash
npx -y @dupe/agent-inbox init
```

`init` detects which harnesses you have installed (`~/.gemini`, `~/.claude`, `~/.codex`, `~/.config/opencode`, `~/.cursor`), registers the `agent-inbox` MCP server and lifecycle hooks in each, installs bundled skills into canonical `~/.agents/skills/`, and creates relative symlinks in detected harness skill directories (`~/.claude/skills/`, `~/.codex/skills/`, etc.) so there are no duplicate copies to drift.

See [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md) for the v1 cross-harness **Orchestrator → Coordinator → Builder** architecture and roadmap.

Or run directly from a local clone:

```bash
git clone https://github.com/dupe-com/agent-inbox.git
cd agent-inbox
node ./bin/agent-inbox.mjs init
```

Check configured harnesses and live sessions anytime:

```bash
npx -y @dupe/agent-inbox status
```

## MCP Tools

| Tool | Purpose |
| :--- | :--- |
| `inbox_whoami` | Show this session's handle, harness, branch, and unread count |
| `inbox_register` | Claim a short handle (e.g. `claude-api`, `agy-review`) + 1-line summary |
| `inbox_list_agents` | List all live sessions across harnesses |
| `inbox_send` | Direct message or `"*"` broadcast (optional `wait_for_reply_seconds`) |
| `inbox_check` | Read unread messages (marks read by default) |
| `inbox_wait` | Block up to 110s until a new unread message arrives |

## Auto-Wake an Idle Session (Zero Human Nudge)

MCP tools are pull-based when an agent isn't mid-turn. To wake an idle session automatically as soon as a peer messages it:

```bash
agent-inbox watch --name agy-review
```

Launch `watch` as a background shell task in Antigravity or Claude Code and end your turn. The moment a message arrives, `watch` prints the message JSON to stdout and exits `0`, triggering your harness's native background-task wakeup.

## Lifecycle Hooks (Zero-Nudge Unread Injection)

`agent-inbox init` automatically installs lightweight lifecycle hooks (pass `--no-hooks` to opt out) so sessions see unread messages without manual nudges:

- **Antigravity (`~/.gemini/config/hooks.json`)**: `SessionStart`, `PreInvocation`, and `Stop` (with `continuationActive` loop guard)
- **Claude Code (`~/.claude/settings.json`)**: `SessionStart`, `UserPromptSubmit`, and `Stop` (with `stop_hook_active` loop guard)
- **Codex (`~/.codex/hooks.json`)**: `session_start`

Ready-to-copy templates are also included in [`hooks/agy-hooks.json`](./hooks/agy-hooks.json), [`hooks/claude-hooks.json`](./hooks/claude-hooks.json), and [`hooks/codex-hooks.json`](./hooks/codex-hooks.json). Hooks peek unread messages non-destructively (safe when multiple sessions share a worktree), return `{}` immediately when empty, and always fail open so they never block a turn.

## Requirements

- **Node.js >= 22.5** (built-in `node:sqlite`) or **Bun >= 1.1** (built-in `bun:sqlite`)

## Development & Tests

```bash
npm test          # Runs multi-process end-to-end tests on Node
npm run test:bun  # Runs the same suite on Bun
```

## License

MIT