@lastshotlabs/slingshot-chat
v0.0.2
Published
Real-time chat with rooms, messages, membership, and encryption for Slingshot
Readme
title: Human Guide description: Human-maintained guidance for @lastshotlabs/slingshot-chat
@lastshotlabs/slingshot-chat is Slingshot's chat domain package. It uses the config-driven entity
system to provide rooms, memberships, messages, reactions, receipts, pins, blocks, favorites,
invites, reminders, and realtime chat event handling behind one plugin.
When To Use It
Use this package when your app needs:
- direct messages, group rooms, or broadcast rooms
- message history, reactions, unread counts, and room membership management
- realtime typing/read events and notification fan-out
- a chat domain that integrates with Slingshot auth, permissions, notifications, and entity tooling
Do not use it as a generic transport layer for unrelated product flows. It is a full chat domain, not a low-level socket primitive.
What You Need Before Wiring It In
This package is not standalone. createChatPlugin() declares these dependencies:
slingshot-authslingshot-notificationsslingshot-permissions
In practice that means:
- auth must establish who the caller is
- permissions must publish shared authorization state before chat starts
- notifications must be present before chat can publish notification side effects
Minimum Setup
The required config is small but explicit:
storeTypeis required and selects the persistence backendmountPathdefaults to/chatpageSizedefaults to50enablePresencedefaults totrueencryptionis optional; omit it and the plugin does not apply package-managed at-rest encryption
What You Get
The plugin owns more than route mounting:
- manifest-driven chat entities and their adapters
- permission-aware middleware for room creation, membership changes, archive/broadcast guards, and message side effects
- WebSocket incoming handlers for chat events
- notification hooks for message delivery and invitations
- unread-count and DM orchestration logic inside the manifest runtime
- plugin state published under
CHAT_PLUGIN_STATE_KEY - an encryption router mounted at
${mountPath}/encryption
The published plugin state is the integration surface other packages should use. Do not reach into chat internals directly when the state object already exposes adapters and evaluator access.
Common Customization
The most important knobs are:
storeType: choosememory,redis,sqlite,postgres, ormongotenantId: fix chat to a tenant, or omit it to rely on the surrounding apppermissions: role requirements for room creation, sending, deleting, pinning, and adding memberspageSize: default pagination size for room message listsenablePresence: whether the live room channel publishes presenceencryption:provider: 'none'orprovider: 'aes-gcm'
If you need to change runtime behavior, start with:
src/plugin.tsfor lifecycle and integrationssrc/config.schema.tsfor supported configsrc/ws/incoming.tsfor incoming realtime behaviorsrc/manifest/runtime.tsfor manifest-backed orchestration
Gotchas
- Register permissions and notifications before chat. The plugin throws during startup if either is missing.
tenantIdfalls back to'default'in the plugin when omitted. Multi-tenant apps should be deliberate about whether that is correct.- Omitting
encryptiondoes not produce encrypted storage. It means chat stores message payloads without plugin-managed encryption. - The package starts reminder and scheduled-message loops on a 30-second interval during setup. That is expected runtime behavior, not test-only glue.
- Chat opportunistically integrates with other packages such as embeds, push, and interactions when they are present. Those integrations should remain additive, not hard dependencies.
Key Files
src/index.tssrc/plugin.tssrc/config.schema.tssrc/types.tssrc/ws/incoming.tssrc/manifest/runtime.tssrc/encryption/provider.ts
