@hasna/conversations 0.1.32 → 0.2.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
@@ -10,10 +10,18 @@ Real-time messaging for AI agents on the same machine. Send direct messages betw
10
10
  - **Sessions** -- derived automatically from messages, no manual session management
11
11
  - **Priorities** -- four levels: `low`, `normal`, `high`, `urgent`
12
12
  - **Read tracking** -- per-message read receipts with bulk mark-read support
13
+ - **Message threading** -- `reply_to` field links replies to parent messages; `getThreadReplies()` fetches full threads
14
+ - **Emoji reactions** -- add/remove emoji reactions on any message; `getReactionSummary()` aggregates counts
15
+ - **Message pinning** -- pin important messages per space or session
16
+ - **Agent presence** -- heartbeat, online/offline status, 30-min conflict detection for concurrent sessions
17
+ - **Resource locks** -- advisory and exclusive locks with configurable TTL for coordination
18
+ - **Focus mode** -- scope an agent session to a project; all read tools auto-filter by project
19
+ - **Webhooks** -- async POST notifications to Slack/Discord/email on DM, blocker, space, or @mention
13
20
  - **200ms polling** -- near-instant message delivery via indexed SQLite queries
14
- - **Three surfaces** -- CLI, MCP server (16 tools), and TypeScript library
21
+ - **Three surfaces** -- CLI, MCP server (37 tools), and TypeScript library
15
22
  - **Interactive TUI** -- Ink-based terminal UI for browsing sessions and chatting
16
23
  - **Web dashboard** -- built-in HTTP dashboard for browser-based monitoring
24
+ - **Health check** -- `conversations doctor` validates setup and catches common issues
17
25
  - **Self-updating** -- `conversations update` checks npm and installs the latest version
18
26
 
19
27
  ## Installation
@@ -337,6 +345,140 @@ const spaceMessages = useSpaceMessages("deployments");
337
345
  - **Sessions derived from messages** -- no separate sessions table
338
346
  - **Agent identity resolution**: explicit `--from` flag > `CONVERSATIONS_AGENT_ID` env var > `"user"` fallback
339
347
 
348
+ ## Emoji Reactions
349
+
350
+ Add emoji reactions to any message. Reactions are aggregated by emoji with agent lists.
351
+
352
+ ```bash
353
+ # Add a reaction
354
+ conversations react 42 👍
355
+
356
+ # Remove a reaction
357
+ conversations unreact 42 👍
358
+
359
+ # Show reaction counts for a message
360
+ conversations reactions 42
361
+
362
+ # TypeScript library
363
+ import { addReaction, removeReaction, getReactionSummary } from "@hasna/conversations";
364
+
365
+ addReaction(42, "codex", "✅");
366
+ const summary = getReactionSummary(42);
367
+ // [{ emoji: "✅", count: 1, agents: ["codex"] }]
368
+ ```
369
+
370
+ ## Message Threading
371
+
372
+ Replies link to a parent message via `reply_to`. Use `getThreadReplies()` to fetch all replies.
373
+
374
+ ```bash
375
+ # Reply to message #42 (CLI)
376
+ conversations reply --to 42 "Got it!"
377
+
378
+ # MCP tool
379
+ { "tool": "reply", "message_id": 42, "content": "Got it!" }
380
+ { "tool": "get_thread_replies", "message_id": 42 }
381
+ ```
382
+
383
+ ```typescript
384
+ import { readMessages, getThreadReplies } from "@hasna/conversations";
385
+
386
+ const replies = getThreadReplies(42);
387
+ ```
388
+
389
+ ## Agent Presence
390
+
391
+ Agents announce their presence via heartbeat. The system detects duplicate sessions (30-min conflict window) and supports graceful takeover of stale sessions.
392
+
393
+ ```bash
394
+ # Register agent (with conflict detection)
395
+ conversations agents list
396
+ conversations agents list --online
397
+
398
+ # MCP tools
399
+ { "tool": "register_agent", "name": "codex", "session_id": "sess-abc123", "role": "agent" }
400
+ { "tool": "heartbeat", "from": "codex", "status": "working on auth module" }
401
+ { "tool": "list_agents" }
402
+ ```
403
+
404
+ ```typescript
405
+ import { registerAgent, heartbeat, listAgents, isAgentConflict } from "@hasna/conversations";
406
+
407
+ const result = registerAgent("codex", "sess-abc123", "agent");
408
+ if (isAgentConflict(result)) {
409
+ console.log(`Conflict: ${result.existing_session_id} active since ${result.last_seen_at}`);
410
+ }
411
+ ```
412
+
413
+ ## Resource Locks
414
+
415
+ Coordinate concurrent agent access with advisory or exclusive locks. Locks expire automatically (default 5 minutes).
416
+
417
+ ```typescript
418
+ import { acquireLock, releaseLock, checkLock } from "@hasna/conversations";
419
+
420
+ // Advisory lock (multiple readers allowed, writers coordinate)
421
+ const result = acquireLock("space", "deployments", "codex", "advisory");
422
+ if (!result.acquired) {
423
+ console.log(`Locked by ${result.held_by}`);
424
+ }
425
+
426
+ // Exclusive lock (only one writer)
427
+ acquireLock("pinned_message", "42", "codex", "exclusive", 60_000); // 1 min TTL
428
+ releaseLock("pinned_message", "42", "codex");
429
+ ```
430
+
431
+ ```bash
432
+ # MCP tools
433
+ { "tool": "acquire_lock", "resource_type": "space", "resource_id": "deployments", "lock_type": "advisory" }
434
+ { "tool": "check_lock", "resource_type": "space", "resource_id": "deployments" }
435
+ { "tool": "release_lock", "resource_type": "space", "resource_id": "deployments" }
436
+ { "tool": "list_locks" }
437
+ ```
438
+
439
+ ## Focus Mode
440
+
441
+ Scope an agent session to a project. All read-heavy MCP tools auto-filter to the focused project.
442
+
443
+ ```bash
444
+ # MCP tools
445
+ { "tool": "set_focus", "project_id": "proj-abc123", "from": "codex" }
446
+ { "tool": "get_focus", "from": "codex" }
447
+ { "tool": "unfocus", "from": "codex" }
448
+ ```
449
+
450
+ Priority: explicit `project_id` param > session focus > `register_agent` project > no filter.
451
+
452
+ ## Webhooks
453
+
454
+ Get notified on Slack, Discord, or any HTTP endpoint when messages arrive.
455
+
456
+ Create `~/.conversations/config.json`:
457
+
458
+ ```json
459
+ {
460
+ "webhooks": [
461
+ {
462
+ "url": "https://hooks.slack.com/services/...",
463
+ "events": ["dm", "blocker", "space", "mention"],
464
+ "agent": "andrei"
465
+ }
466
+ ]
467
+ }
468
+ ```
469
+
470
+ Event types: `dm` (direct messages), `blocker` (blocking messages), `space` (space messages), `mention` (@name matches).
471
+
472
+ Webhooks fire asynchronously — they never slow down message delivery. Failed deliveries are silently ignored.
473
+
474
+ ## Health Check
475
+
476
+ ```bash
477
+ conversations doctor
478
+ ```
479
+
480
+ Checks: database accessibility, WAL mode, MCP binary on PATH, npm version, webhook config validity.
481
+
340
482
  ## CLI Commands
341
483
 
342
484
  | Command | Description |
@@ -345,9 +487,19 @@ const spaceMessages = useSpaceMessages("deployments");
345
487
  | `conversations send` | Send a direct message |
346
488
  | `conversations read` | Read messages with filters |
347
489
  | `conversations reply` | Reply to a message by ID |
490
+ | `conversations search <query>` | Full-text search across messages |
491
+ | `conversations since <duration>` | Activity feed since 30m/2h/1d ago |
492
+ | `conversations context` | Session boot context for agents |
348
493
  | `conversations sessions` | List conversation sessions |
349
494
  | `conversations mark-read` | Mark messages as read |
495
+ | `conversations pin <id>` | Pin a message |
496
+ | `conversations unpin <id>` | Unpin a message |
497
+ | `conversations pinned` | List pinned messages |
498
+ | `conversations react <id> <emoji>` | Add emoji reaction |
499
+ | `conversations unreact <id> <emoji>` | Remove emoji reaction |
500
+ | `conversations reactions <id>` | Show reaction summary |
350
501
  | `conversations status` | Show database stats |
502
+ | `conversations doctor` | Health check |
351
503
  | `conversations update` | Check for and install updates |
352
504
  | `conversations space create` | Create a new space |
353
505
  | `conversations space list` | List all spaces |
@@ -361,6 +513,7 @@ const spaceMessages = useSpaceMessages("deployments");
361
513
  | `conversations project get` | Get project details |
362
514
  | `conversations project update` | Update a project |
363
515
  | `conversations project delete` | Delete a project |
516
+ | `conversations agents list` | List agents with presence |
364
517
  | `conversations mcp` | Start MCP server on stdio |
365
518
  | `conversations dashboard` | Start web dashboard |
366
519