@herdctl/chat
v0.3.13
Published
Shared chat infrastructure for herdctl connectors
Maintainers
Readme
@herdctl/chat
Shared chat infrastructure for herdctl connectors
Documentation: herdctl.dev
Overview
@herdctl/chat is the shared foundation that powers chat integrations in herdctl. It provides session management, streaming message delivery, error handling, and message splitting used by @herdctl/discord, @herdctl/slack, and @herdctl/web.
Herdctl is an open-source system for running fleets of autonomous AI agents powered by Claude Code. This package is part of the herdctl monorepo.
Note: This is an internal infrastructure package. Most users should use the platform-specific connectors (
@herdctl/discord,@herdctl/slack) or the web dashboard (@herdctl/web) rather than this package directly.
Installation
npm install @herdctl/chatWhat It Provides
Session Management
ChatSessionManager tracks conversation sessions per channel or DM. Sessions are persisted to disk and automatically expire after a configurable timeout (default: 24 hours). When a user sends a message, the session manager either resumes the existing session or creates a new one, preserving conversation context via Claude SDK session resumption.
Streaming Responses
StreamingResponder delivers agent responses incrementally as they are generated, rather than waiting for the full response. It buffers content and sends complete chunks at configurable intervals, respecting platform rate limits.
Message Splitting
Long agent responses are automatically split at natural breakpoints (paragraph breaks, sentences, clauses) to fit within platform character limits (Discord: 2,000, Slack: 4,000). This ensures messages remain readable without cutting mid-sentence.
Error Handling
A shared error handler classifies errors (transient, rate limit, authentication, etc.), provides user-friendly messages, and implements retry logic with exponential backoff. Platform connectors use this to handle failures gracefully without crashing.
DM Filtering
The DM filter enforces access control for direct messages: enabled/disabled toggle, allowlist, blocklist, and chat mode (auto vs. mention). Blocklist takes precedence over allowlist.
Message Extraction
Utilities for extracting text content from Claude SDK message formats, handling direct strings, nested message objects, and content block arrays.
Architecture
@herdctl/chat (shared infrastructure)
|
+-- @herdctl/discord (Discord-specific integration)
+-- @herdctl/slack (Slack-specific integration)
+-- @herdctl/web (Web dashboard chat)Each platform connector implements the IChatConnector interface and uses the shared infrastructure for everything that isn't platform-specific.
Documentation
For more on how chat works in herdctl, visit herdctl.dev:
Related Packages
herdctl- CLI for running agent fleets@herdctl/core- Core library for programmatic use@herdctl/discord- Discord connector@herdctl/slack- Slack connector@herdctl/web- Web dashboard
License
MIT
