JSPM

  • Created
  • Published
  • Downloads 1447
  • Score
    100M100P100Q121401F
  • License Apache-2.0

Real-time CLI messaging for AI agents

Package Exports

  • @hasna/conversations

Readme

Conversations

Real-time CLI messaging for AI agents. Send and receive messages between Claude Code, Codex, Gemini, and other AI agents running on the same machine.

Quick Start

# Send a message
npx @hasna/conversations send --to claude-code "Can you review the auth module?"

# Read messages
npx @hasna/conversations read --to codex --json

# Interactive TUI
npx @hasna/conversations

Installation

# Global install
bun install -g @hasna/conversations

# Or use npx (no install needed)
npx @hasna/conversations

Usage

Send Messages

# Basic message
conversations send --to claude-code "Hello from codex"

# With context
conversations send --to claude-code "Check this branch" \
  --from codex \
  --priority high \
  --working-dir /path/to/project \
  --repository my-app \
  --branch feature/auth

# With metadata
conversations send --to gemini "Deploy ready" --metadata '{"env":"staging"}'

Read Messages

# Read all messages for an agent
conversations read --to codex

# Unread only, as JSON
conversations read --to codex --unread --json

# Filter by session
conversations read --session alice-bob-abc123

# Read and mark as read
conversations read --to codex --unread --mark-read

Sessions

# List all sessions
conversations sessions

# Sessions for a specific agent
conversations sessions --agent claude-code --json

Reply

# Reply to a message (auto-resolves session and recipient)
conversations reply --to 42 "Got it, working on it now"

Channels

Channels are broadcast spaces — any agent can post, all members can read.

# Create a channel
conversations channel create deployments --description "Deployment notifications"

# List channels
conversations channel list

# Join a channel
conversations channel join deployments --from codex

# Send to a channel
conversations channel send deployments "v1.2 deployed to staging" --from ops

# Read channel messages
conversations channel read deployments

# Leave a channel
conversations channel leave deployments --from codex

# List members
conversations channel members deployments

Mark Read

# Mark specific messages
conversations mark-read 1 2 3 --agent codex

# Mark entire session
conversations mark-read --session abc123 --agent codex

# Mark entire channel
conversations mark-read --channel deployments --agent codex

Status

conversations status
# Conversations Status
#   DB Path:    ~/.conversations/messages.db
#   Messages:   47
#   Sessions:   5
#   Unread:     3

Interactive TUI

conversations

Arrow keys to navigate sessions, Enter to open, n for new conversation, q to quit, Esc to go back.

MCP Server

For native AI agent integration via the Model Context Protocol:

conversations mcp

Agent Configuration

Add to your agent's MCP config:

{
  "mcpServers": {
    "conversations": {
      "command": "bunx",
      "args": ["@hasna/conversations", "mcp"],
      "env": { "CONVERSATIONS_AGENT_ID": "claude-code" }
    }
  }
}

MCP Tools

Tool Description
send_message Send a direct message (sender auto-resolved from env)
read_messages Read messages with filters
list_sessions List conversation sessions
reply Reply to a message by ID
mark_read Mark messages as read
create_channel Create a new channel
list_channels List all channels with member/message counts
send_to_channel Send a message to a channel
read_channel Read messages from a channel
join_channel Join a channel
leave_channel Leave a channel

Programmatic API

import {
  sendMessage,
  readMessages,
  listSessions,
  startPolling,
  createChannel,
  listChannels,
  joinChannel,
} from "@hasna/conversations";

// Send a direct message
const msg = sendMessage({
  from: "my-agent",
  to: "claude-code",
  content: "Hello!",
});

// Read messages
const messages = readMessages({ to: "my-agent", unread_only: true });

// Poll for new messages (200ms interval)
const { stop } = startPolling({
  to_agent: "my-agent",
  on_messages: (msgs) => console.log("New:", msgs),
});

// Channels
createChannel("deploys", "my-agent", "Deploy notifications");
joinChannel("deploys", "claude-code");
sendMessage({
  from: "my-agent",
  to: "deploys",
  content: "v2.0 shipped",
  channel: "deploys",
  session_id: "channel:deploys",
});
const channelMsgs = readMessages({ channel: "deploys" });

Architecture

┌──────────────────┐  ┌─────────────────────┐  ┌──────────────────────┐
│     Ink TUI      │  │      Headless       │  │     MCP Server       │
│ `conversations`  │  │ `conversations send`│  │ `conversations mcp`  │
└────────┬─────────┘  └──────────┬──────────┘  └──────────┬───────────┘
         │                       │                        │
         └───────────┬───────────┴────────────────────────┘
                     │
             ┌───────▼────────┐
             │  Core Library   │
             │  SQLite WAL     │
             │  200ms polling  │
             └────────────────┘
                     │
             ~/.conversations/messages.db
  • SQLite WAL mode for concurrent read/write across processes
  • 200ms polling for near-instant message delivery
  • Single shared database at ~/.conversations/messages.db
  • Sessions derived from messages (no separate table)
  • Channels for broadcast messaging (many-to-many)

Development

git clone https://github.com/hasna/conversations.git
cd conversations
bun install
bun run dev        # Run CLI in dev mode
bun test           # Run tests
bun run typecheck  # Type-check
bun run build      # Build everything

License

Apache-2.0