bob-chat
Platform-agnostic chat abstractions for the Bob Agent Framework.
Overview
bob-chat provides the structured chat layer that sits between chat platform APIs (Slack, Discord, Telegram, CLI, etc.) and the agent loop. It ships a trait-based adapter model, a central event-driven orchestrator (ChatBot), and rich message primitives.
Features
ChatAdaptertrait — implement once per platform; covers posting, editing, deleting, reactions, ephemeral messages, DMs, modals, file uploads, and event streaming.ChatBotorchestrator — register adapters and typed handlers, then callChatBot::run()to poll all adapters concurrently and dispatch events.ChatEventenum — seven event variants: Message, Mention, Reaction, Action, SlashCommand, ModalSubmit, ModalClose.ThreadHandle— scoped handle passed to handlers for replying, subscribing to threads, and managing ephemeral messages with DM fallback.- Rich messages (Cards) —
CardElementwith buttons, sections, images, and fields, plus a plain-text fallback renderer. - Modal dialogs —
ModalElementwith text inputs, selects, and radio selects. - Emoji system — 35
WellKnownEmojivariants with platform-specific format maps and custom-emoji support. - Streaming —
TextStreamandfallback_streamfor progressive message delivery via post-then-edit. - Attachments —
AttachmentandFileUploadtypes for file handling. - Error types —
ChatErrorwith adapter, transport, rate-limit, auth, not-found, not-supported, and closed variants.
Architecture
┌─────────────────────────────────────────────────────┐
│ ChatBot │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Adapter A│ │ Adapter B│ │ Adapter C│ ... │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
│ │ │ │ │
│ └──────┬───────┴──────┬───────┘ │
│ │ select_all │ │
│ ▼ ▼ │
│ ┌─────────────────────┐ │
│ │ Event Dispatch │ │
│ │ ┌───────────────┐ │ │
│ │ │ Mention │──│──► MentionHandler │
│ │ │ Message │──│──► MessageHandler │
│ │ │ Reaction │──│──► ReactionHandler │
│ │ │ Action │──│──► ActionHandler │
│ │ │ SlashCommand │──│──► CommandHandler │
│ │ │ ModalSubmit │──│──► SubmitHandler │
│ │ │ ModalClose │──│──► CloseHandler │
│ │ └───────────────┘ │ │
│ └─────────────────────┘ │
│ │
│ Handlers receive ThreadHandle for replies, │
│ subscriptions, and streaming. │
└─────────────────────────────────────────────────────┘
Usage
use ;
async
License
See LICENSE.md in the repository root.