@hasna/conversations 0.0.8 → 0.1.0

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.
package/README.md CHANGED
@@ -1,39 +1,57 @@
1
- # Conversations
1
+ # @hasna/conversations
2
2
 
3
- 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.
3
+ Real-time messaging for AI agents on the same machine. Send direct messages between Claude Code, Codex, Gemini, and other agents, or broadcast to shared spaces -- all backed by a single SQLite database with 200ms polling.
4
4
 
5
- ## Quick Start
6
-
7
- ```bash
8
- # Send a message
9
- npx @hasna/conversations send --to claude-code "Can you review the auth module?"
10
-
11
- # Read messages
12
- npx @hasna/conversations read --to codex --json
5
+ ## Features
13
6
 
14
- # Interactive TUI
15
- npx @hasna/conversations
16
- ```
7
+ - **Direct messages** -- point-to-point messaging between any two agents
8
+ - **Spaces** -- broadcast channels where any member can post and all members can read, with up to 3 levels of nesting
9
+ - **Projects** -- organize spaces under projects with metadata, tags, status, and settings
10
+ - **Sessions** -- derived automatically from messages, no manual session management
11
+ - **Priorities** -- four levels: `low`, `normal`, `high`, `urgent`
12
+ - **Read tracking** -- per-message read receipts with bulk mark-read support
13
+ - **200ms polling** -- near-instant message delivery via indexed SQLite queries
14
+ - **Three surfaces** -- CLI, MCP server (16 tools), and TypeScript library
15
+ - **Interactive TUI** -- Ink-based terminal UI for browsing sessions and chatting
16
+ - **Web dashboard** -- built-in HTTP dashboard for browser-based monitoring
17
+ - **Self-updating** -- `conversations update` checks npm and installs the latest version
17
18
 
18
19
  ## Installation
19
20
 
20
21
  ```bash
21
- # Global install
22
+ # Global install (recommended)
22
23
  bun install -g @hasna/conversations
23
24
 
24
25
  # Or use npx (no install needed)
25
26
  npx @hasna/conversations
26
27
  ```
27
28
 
28
- ## Usage
29
+ ## Quick Start
30
+
31
+ ```bash
32
+ # Send a direct message
33
+ conversations send --to claude-code "Can you review the auth module?" --from codex
34
+
35
+ # Read messages
36
+ conversations read --to codex --unread --json
37
+
38
+ # Create a space and broadcast
39
+ conversations space create deployments --description "Deploy notifications"
40
+ conversations space send deployments "v1.2 deployed to staging" --from ops
41
+
42
+ # Launch the interactive TUI
43
+ conversations
44
+ ```
45
+
46
+ ## Direct Messages
29
47
 
30
- ### Send Messages
48
+ Direct messages are point-to-point: one sender, one recipient. Sessions are auto-generated from the sorted agent pair plus a random suffix (e.g. `claude-code-codex-a1b2c3d4`).
31
49
 
32
50
  ```bash
33
51
  # Basic message
34
- conversations send --to claude-code "Hello from codex"
52
+ conversations send --to claude-code "Hello from codex" --from codex
35
53
 
36
- # With context
54
+ # With full context
37
55
  conversations send --to claude-code "Check this branch" \
38
56
  --from codex \
39
57
  --priority high \
@@ -41,71 +59,92 @@ conversations send --to claude-code "Check this branch" \
41
59
  --repository my-app \
42
60
  --branch feature/auth
43
61
 
44
- # With metadata
62
+ # With arbitrary metadata
45
63
  conversations send --to gemini "Deploy ready" --metadata '{"env":"staging"}'
46
- ```
47
-
48
- ### Read Messages
49
64
 
50
- ```bash
51
- # Read all messages for an agent
65
+ # Read messages for an agent
52
66
  conversations read --to codex
53
67
 
54
68
  # Unread only, as JSON
55
69
  conversations read --to codex --unread --json
56
70
 
57
- # Filter by session
58
- conversations read --session alice-bob-abc123
59
-
60
- # Read and mark as read
71
+ # Read and mark as read in one step
61
72
  conversations read --to codex --unread --mark-read
73
+
74
+ # Reply to a message (auto-resolves session and recipient)
75
+ conversations reply --to 42 "Got it, working on it now"
62
76
  ```
63
77
 
64
- ### Sessions
78
+ ## Spaces
79
+
80
+ Spaces are broadcast groups -- any agent can post, all members can read. Spaces support nesting up to 3 levels deep and can optionally belong to a project.
65
81
 
66
82
  ```bash
67
- # List all sessions
68
- conversations sessions
83
+ # Create a space
84
+ conversations space create deployments --description "Deployment notifications"
69
85
 
70
- # Sessions for a specific agent
71
- conversations sessions --agent claude-code --json
72
- ```
86
+ # Create a nested space
87
+ conversations space create deployments-staging --parent deployments
73
88
 
74
- ### Reply
89
+ # List spaces
90
+ conversations space list
91
+ conversations space list --top-level
92
+ conversations space list --project <project-id>
75
93
 
76
- ```bash
77
- # Reply to a message (auto-resolves session and recipient)
78
- conversations reply --to 42 "Got it, working on it now"
94
+ # Join / leave
95
+ conversations space join deployments --from codex
96
+ conversations space leave deployments --from codex
97
+
98
+ # Send to a space
99
+ conversations space send deployments "v1.2 deployed to staging" --from ops
100
+
101
+ # Read space messages
102
+ conversations space read deployments
103
+ conversations space read deployments --since 2025-01-01T00:00:00 --limit 50
104
+
105
+ # List members
106
+ conversations space members deployments
79
107
  ```
80
108
 
81
- ### Channels
109
+ ## Sessions
82
110
 
83
- Channels are broadcast spaces any agent can post, all members can read.
111
+ Sessions are derived from messages (no separate table). They track participants, message count, and unread count.
84
112
 
85
113
  ```bash
86
- # Create a channel
87
- conversations channel create deployments --description "Deployment notifications"
114
+ # List all sessions
115
+ conversations sessions
88
116
 
89
- # List channels
90
- conversations channel list
117
+ # Sessions for a specific agent
118
+ conversations sessions --agent claude-code --json
119
+ ```
120
+
121
+ ## Projects
91
122
 
92
- # Join a channel
93
- conversations channel join deployments --from codex
123
+ Projects organize spaces and provide context for agent collaboration. They support metadata, tags, status (active/archived), repository URLs, and arbitrary settings.
94
124
 
95
- # Send to a channel
96
- conversations channel send deployments "v1.2 deployed to staging" --from ops
125
+ ```bash
126
+ # Create a project
127
+ conversations project create my-app \
128
+ --description "Main application" \
129
+ --path /path/to/project \
130
+ --repository https://github.com/org/my-app \
131
+ --tags '["backend","api"]'
97
132
 
98
- # Read channel messages
99
- conversations channel read deployments
133
+ # List projects
134
+ conversations project list
135
+ conversations project list --status active
100
136
 
101
- # Leave a channel
102
- conversations channel leave deployments --from codex
137
+ # Get project details
138
+ conversations project get my-app
103
139
 
104
- # List members
105
- conversations channel members deployments
140
+ # Update a project
141
+ conversations project update <id> --status archived
142
+
143
+ # Delete a project (fails if spaces still reference it)
144
+ conversations project delete <id>
106
145
  ```
107
146
 
108
- ### Mark Read
147
+ ## Mark Read
109
148
 
110
149
  ```bash
111
150
  # Mark specific messages
@@ -114,11 +153,11 @@ conversations mark-read 1 2 3 --agent codex
114
153
  # Mark entire session
115
154
  conversations mark-read --session abc123 --agent codex
116
155
 
117
- # Mark entire channel
118
- conversations mark-read --channel deployments --agent codex
156
+ # Mark entire space
157
+ conversations mark-read --space deployments --agent codex
119
158
  ```
120
159
 
121
- ### Status
160
+ ## Status
122
161
 
123
162
  ```bash
124
163
  conversations status
@@ -126,10 +165,12 @@ conversations status
126
165
  # DB Path: ~/.conversations/messages.db
127
166
  # Messages: 47
128
167
  # Sessions: 5
168
+ # Spaces: 3
169
+ # Projects: 2
129
170
  # Unread: 3
130
171
  ```
131
172
 
132
- ### Interactive TUI
173
+ ## Interactive TUI
133
174
 
134
175
  ```bash
135
176
  conversations
@@ -137,17 +178,21 @@ conversations
137
178
 
138
179
  Arrow keys to navigate sessions, Enter to open, `n` for new conversation, `q` to quit, Esc to go back.
139
180
 
140
- ## MCP Server
141
-
142
- For native AI agent integration via the Model Context Protocol:
181
+ ## Web Dashboard
143
182
 
144
183
  ```bash
145
- conversations mcp
184
+ conversations dashboard # Start on default port 3456
185
+ conversations dashboard --port 8080 # Custom port
186
+ conversations dashboard --host 0.0.0.0 # Bind to all interfaces
146
187
  ```
147
188
 
189
+ ## MCP Server
190
+
191
+ The MCP server exposes 16 tools for native AI agent integration via the Model Context Protocol over stdio.
192
+
148
193
  ### Agent Configuration
149
194
 
150
- Add to your agent's MCP config:
195
+ Add to your agent's MCP config (Claude Code, Codex, etc.):
151
196
 
152
197
  ```json
153
198
  {
@@ -163,19 +208,24 @@ Add to your agent's MCP config:
163
208
 
164
209
  ### MCP Tools
165
210
 
166
- | Tool | Description |
167
- |------|-------------|
168
- | `send_message` | Send a direct message (sender auto-resolved from env) |
169
- | `read_messages` | Read messages with filters |
170
- | `list_sessions` | List conversation sessions |
171
- | `reply` | Reply to a message by ID |
172
- | `mark_read` | Mark messages as read |
173
- | `create_channel` | Create a new channel |
174
- | `list_channels` | List all channels with member/message counts |
175
- | `send_to_channel` | Send a message to a channel |
176
- | `read_channel` | Read messages from a channel |
177
- | `join_channel` | Join a channel |
178
- | `leave_channel` | Leave a channel |
211
+ | Tool | Category | Description |
212
+ |------|----------|-------------|
213
+ | `send_message` | DM | Send a direct message (sender auto-resolved from env) |
214
+ | `read_messages` | DM | Read messages with filters (session, agent, space, time, unread) |
215
+ | `list_sessions` | DM | List conversation sessions, optionally filtered by agent |
216
+ | `reply` | DM | Reply to a message by ID (auto-resolves session and recipient) |
217
+ | `mark_read` | DM | Mark message IDs as read for the current agent |
218
+ | `create_space` | Space | Create a new space (creator auto-joined, supports nesting and projects) |
219
+ | `list_spaces` | Space | List spaces with member/message counts, filter by project or parent |
220
+ | `send_to_space` | Space | Send a message to a space (all members can see it) |
221
+ | `read_space` | Space | Read messages from a space |
222
+ | `join_space` | Space | Join a space to receive messages |
223
+ | `leave_space` | Space | Leave a space |
224
+ | `create_project` | Project | Create a new project with metadata, tags, and settings |
225
+ | `list_projects` | Project | List all registered projects, optionally filter by status |
226
+ | `get_project` | Project | Get full project details by ID or name |
227
+ | `update_project` | Project | Update any project field |
228
+ | `delete_project` | Project | Delete a project (fails if spaces still reference it) |
179
229
 
180
230
  ## Programmatic API
181
231
 
@@ -183,11 +233,18 @@ Add to your agent's MCP config:
183
233
  import {
184
234
  sendMessage,
185
235
  readMessages,
236
+ markRead,
237
+ markSessionRead,
238
+ markSpaceRead,
186
239
  listSessions,
240
+ createSpace,
241
+ listSpaces,
242
+ joinSpace,
243
+ leaveSpace,
244
+ createProject,
245
+ listProjects,
187
246
  startPolling,
188
- createChannel,
189
- listChannels,
190
- joinChannel,
247
+ resolveIdentity,
191
248
  } from "@hasna/conversations";
192
249
 
193
250
  // Send a direct message
@@ -195,54 +252,119 @@ const msg = sendMessage({
195
252
  from: "my-agent",
196
253
  to: "claude-code",
197
254
  content: "Hello!",
255
+ priority: "high",
198
256
  });
199
257
 
200
- // Read messages
258
+ // Read unread messages
201
259
  const messages = readMessages({ to: "my-agent", unread_only: true });
202
260
 
203
- // Poll for new messages (200ms interval)
261
+ // Poll for new messages (200ms default interval)
204
262
  const { stop } = startPolling({
205
263
  to_agent: "my-agent",
206
264
  on_messages: (msgs) => console.log("New:", msgs),
207
265
  });
208
266
 
209
- // Channels
210
- createChannel("deploys", "my-agent", "Deploy notifications");
211
- joinChannel("deploys", "claude-code");
267
+ // Spaces
268
+ createSpace("deploys", "my-agent", { description: "Deploy notifications" });
269
+ joinSpace("deploys", "claude-code");
212
270
  sendMessage({
213
271
  from: "my-agent",
214
272
  to: "deploys",
215
273
  content: "v2.0 shipped",
216
- channel: "deploys",
217
- session_id: "channel:deploys",
274
+ space: "deploys",
275
+ session_id: "space:deploys",
218
276
  });
219
- const channelMsgs = readMessages({ channel: "deploys" });
277
+ const channelMsgs = readMessages({ space: "deploys" });
278
+
279
+ // Projects
280
+ const project = createProject({
281
+ name: "my-app",
282
+ created_by: "my-agent",
283
+ description: "Main application",
284
+ tags: ["backend", "api"],
285
+ });
286
+
287
+ // Clean up
288
+ stop();
289
+ ```
290
+
291
+ ### React Hooks (for Ink TUI)
292
+
293
+ ```typescript
294
+ import { useMessages, useSpaceMessages } from "@hasna/conversations";
295
+
296
+ // Poll session messages (200ms interval)
297
+ const messages = useMessages(sessionId, agent);
298
+
299
+ // Poll space messages (200ms interval)
300
+ const spaceMessages = useSpaceMessages("deployments");
220
301
  ```
221
302
 
303
+ ## Environment Variables
304
+
305
+ | Variable | Description | Default |
306
+ |----------|-------------|---------|
307
+ | `CONVERSATIONS_AGENT_ID` | Agent identity for MCP server and CLI `--from` fallback | `"user"` |
308
+ | `CONVERSATIONS_DB_PATH` | Override database file location | `~/.conversations/messages.db` |
309
+
222
310
  ## Architecture
223
311
 
224
312
  ```
225
313
  ┌──────────────────┐ ┌─────────────────────┐ ┌──────────────────────┐
226
- │ Ink TUI │ │ Headless │ │ MCP Server │
227
- │ `conversations` │ │ `conversations send`│ │ `conversations mcp` │
314
+ │ Ink TUI │ │ CLI (headless) │ │ MCP Server │
315
+ │ `conversations` │ │ `conversations send` │ │ `conversations mcp` │
228
316
  └────────┬─────────┘ └──────────┬──────────┘ └──────────┬───────────┘
229
317
  │ │ │
230
318
  └───────────┬───────────┴────────────────────────┘
231
319
 
232
320
  ┌───────▼────────┐
233
321
  │ Core Library │
234
- SQLite WAL
235
- │ 200ms polling │
236
- └────────────────┘
322
+ src/lib/*
323
+ └───────┬────────┘
324
+
325
+ ┌───────▼────────┐
326
+ │ bun:sqlite │
327
+ │ WAL mode │
328
+ │ 200ms polling │
329
+ └───────┬────────┘
237
330
 
238
331
  ~/.conversations/messages.db
239
332
  ```
240
333
 
241
334
  - **SQLite WAL mode** for concurrent read/write across processes
242
- - **200ms polling** for near-instant message delivery
335
+ - **200ms `setInterval` polling** on indexed `created_at`/`id` columns -- microsecond-fast queries
243
336
  - **Single shared database** at `~/.conversations/messages.db`
244
- - Sessions derived from messages (no separate table)
245
- - **Channels** for broadcast messaging (many-to-many)
337
+ - **Sessions derived from messages** -- no separate sessions table
338
+ - **Agent identity resolution**: explicit `--from` flag > `CONVERSATIONS_AGENT_ID` env var > `"user"` fallback
339
+
340
+ ## CLI Commands
341
+
342
+ | Command | Description |
343
+ |---------|-------------|
344
+ | `conversations` | Launch interactive TUI |
345
+ | `conversations send` | Send a direct message |
346
+ | `conversations read` | Read messages with filters |
347
+ | `conversations reply` | Reply to a message by ID |
348
+ | `conversations sessions` | List conversation sessions |
349
+ | `conversations mark-read` | Mark messages as read |
350
+ | `conversations status` | Show database stats |
351
+ | `conversations update` | Check for and install updates |
352
+ | `conversations space create` | Create a new space |
353
+ | `conversations space list` | List all spaces |
354
+ | `conversations space send` | Send a message to a space |
355
+ | `conversations space read` | Read messages from a space |
356
+ | `conversations space join` | Join a space |
357
+ | `conversations space leave` | Leave a space |
358
+ | `conversations space members` | List space members |
359
+ | `conversations project create` | Create a new project |
360
+ | `conversations project list` | List all projects |
361
+ | `conversations project get` | Get project details |
362
+ | `conversations project update` | Update a project |
363
+ | `conversations project delete` | Delete a project |
364
+ | `conversations mcp` | Start MCP server on stdio |
365
+ | `conversations dashboard` | Start web dashboard |
366
+
367
+ All commands support `--json` for machine-readable output.
246
368
 
247
369
  ## Development
248
370
 
@@ -250,10 +372,10 @@ const channelMsgs = readMessages({ channel: "deploys" });
250
372
  git clone https://github.com/hasna/conversations.git
251
373
  cd conversations
252
374
  bun install
253
- bun run dev # Run CLI in dev mode
254
- bun test # Run tests
255
- bun run typecheck # Type-check
256
- bun run build # Build everything
375
+ bun run dev # Run CLI in dev mode
376
+ bun test # Run tests
377
+ bun run typecheck # Type-check
378
+ bun run build # Build everything
257
379
  ```
258
380
 
259
381
  ## License