@lastshotlabs/slingshot-chat
npm install @lastshotlabs/slingshot-chat
Functions
Section titled “Functions”createChatPackage
Section titled “createChatPackage”Create the chat package using the definePackage authoring path.
Mounts all 10 chat entities — each entity module uses
wiring: { mode: 'manual', buildAdapter } so the package factory can
capture the resolved adapter into a closure-owned ChatAdapterRefs
bag for adapter-dependent middleware, custom-op handlers, and event
subscribers.
Cross-package contracts:
- Requires
slingshot-permissionsforPermissionsState. - Requires
slingshot-notificationsforNotificationsBuilderFactoryCap. - Publishes
ChatInteractionsPeerCapfor consumers (notablyslingshot-interactions).
WebSocket self-wiring: the package self-registers its incoming event
handlers onto SlingshotContext.wsEndpoints[mountPath] during
setupPost. No caller-side wiring is required.
Background schedulers: during setupPost the package starts two
30-second intervals — one for due reminders, one for scheduled message
delivery. Both are cleared in teardown().
Optional integrations (duck-typed):
slingshot-push— when present, registers chat push formatters.slingshot-embeds— when present, unfurls URLs in new messages and writes the resolved embeds back viaattachEmbeds.
Encryption: when config.encryption.provider === 'aes-gcm', encrypted
rooms (rooms with encrypted: true) store messages as ciphertext and
decrypt them on read. The room id is bound into the cipher as
authenticated data so ciphertext cannot be replayed across rooms.
function createChatPackage(rawConfig: ChatPluginConfig): SlingshotPackageDefinitionSource: packages/slingshot-chat/src/plugin.ts
Constants
Section titled “Constants”Source: packages/slingshot-chat/src/public.ts
CHAT_PLUGIN_STATE_KEY
Section titled “CHAT_PLUGIN_STATE_KEY”Plugin state key for slingshot-chat.
Single-sourced constant — no magic string 'slingshot-chat' anywhere in
cross-package contracts (cold-start invariant #7).
Source: packages/slingshot-chat/src/state.ts
ChatEntities
Section titled “ChatEntities”Read-only adapter surface for chat entities.
Cross-package consumers (SSR loaders, search indexers, application-defined plugins) resolve adapters with:
import { ChatEntities } from '@lastshotlabs/slingshot-chat';import { requireEntityAdapter } from '@lastshotlabs/slingshot-core';
const rooms = requireEntityAdapter(carrier, ChatEntities.Room);const room = await rooms.getById('room-123');The exposed methods are the canonical lookup paths used elsewhere in this
package’s HTTP routes; readonly([...]) enforces the slice at runtime.
Mutation paths (create/update/delete) are intentionally excluded — those go through the HTTP routes, server actions, or the entity event bus so the full middleware chain (banCheck, encryption, blockGuard, …) runs.
Source: packages/slingshot-chat/src/public.ts
ChatInteractionsPeerCap
Section titled “ChatInteractionsPeerCap”Source: packages/slingshot-chat/src/public.ts
ChatModerationPeerCap
Section titled “ChatModerationPeerCap”Source: packages/slingshot-chat/src/public.ts
Classes
Section titled “Classes”ChatRepoNotImplementedError
Section titled “ChatRepoNotImplementedError”Thrown when a repository backend operation has not been implemented yet. Replace with actual implementation — do not catch and ignore.
Source: packages/slingshot-chat/src/factories/errors.ts
Interfaces
Section titled “Interfaces”A user block relationship.
Source: packages/slingshot-chat/src/types.ts
BlockAdapter
Section titled “BlockAdapter”Entity adapter for Block — CRUD + block operations.
Source: packages/slingshot-chat/src/types.ts
ChatAesGcmEncryptionConfig
Section titled “ChatAesGcmEncryptionConfig”AES-GCM encryption config for encrypted rooms.
The key must be a base64-encoded raw AES key (16, 24, or 32 bytes). The room ID is bound into the cipher as authenticated data so ciphertext cannot be replayed across rooms.
Source: packages/slingshot-chat/src/types.ts
ChatInteractionsPeer
Section titled “ChatInteractionsPeer”Cross-package peer surface used by slingshot-interactions (and other
component-aware consumers) to resolve chat-owned message trees and apply
component updates returned by interaction dispatchers.
Source: packages/slingshot-chat/src/public.ts
ChatMessageDeletedPayload
Section titled “ChatMessageDeletedPayload”Payload sent to clients on chat.message.deleted.
Source: packages/slingshot-chat/src/types.ts
ChatModerationPeer
Section titled “ChatModerationPeer”Narrow mutation seam for application-owned room moderation policy.
Source: packages/slingshot-chat/src/public.ts
ChatNoEncryptionConfig
Section titled “ChatNoEncryptionConfig”Disable message-body encryption.
This is the default when ChatPluginConfig.encryption is omitted.
Source: packages/slingshot-chat/src/types.ts
ChatPermissionsConfig
Section titled “ChatPermissionsConfig”Permission roles configuration for chat operations.
Each field accepts an array of role strings allowed to perform the operation. If omitted, no role restriction is applied.
Source: packages/slingshot-chat/src/types.ts
ChatPingPayload
Section titled “ChatPingPayload”Payload for the chat.ping keepalive WS event.
Source: packages/slingshot-chat/src/types.ts
ChatPluginConfig
Section titled “ChatPluginConfig”Configuration for createChatPackage().
Source: packages/slingshot-chat/src/types.ts
ChatReadBroadcastPayload
Section titled “ChatReadBroadcastPayload”Payload broadcast on chat.read (server → clients).
Source: packages/slingshot-chat/src/types.ts
ChatReadPayload
Section titled “ChatReadPayload”Payload for the chat.read incoming WS event (client → server).
Source: packages/slingshot-chat/src/types.ts
ChatTypingPayload
Section titled “ChatTypingPayload”Payload for the chat.typing incoming WS event (client → server).
Source: packages/slingshot-chat/src/types.ts
CreateMemberInput
Section titled “CreateMemberInput”Input for creating a RoomMember.
Source: packages/slingshot-chat/src/types.ts
CreateMessageInput
Section titled “CreateMessageInput”Input for creating a Message.
Source: packages/slingshot-chat/src/types.ts
CreateRoomInput
Section titled “CreateRoomInput”Input for creating a Room.
Source: packages/slingshot-chat/src/types.ts
FavoriteRoom
Section titled “FavoriteRoom”A user’s favorited room.
Source: packages/slingshot-chat/src/types.ts
FavoriteRoomAdapter
Section titled “FavoriteRoomAdapter”Entity adapter for FavoriteRoom — CRUD + favorites operations.
Source: packages/slingshot-chat/src/types.ts
Message
Section titled “Message”A chat message.
Source: packages/slingshot-chat/src/types.ts
MessageAdapter
Section titled “MessageAdapter”Entity adapter for Message — CRUD + message-specific operations.
Source: packages/slingshot-chat/src/types.ts
MessageReaction
Section titled “MessageReaction”An emoji reaction on a message.
Source: packages/slingshot-chat/src/types.ts
MessageReactionAdapter
Section titled “MessageReactionAdapter”Entity adapter for MessageReaction — CRUD + reaction operations.
Source: packages/slingshot-chat/src/types.ts
A pinned message in a room.
Source: packages/slingshot-chat/src/types.ts
PinAdapter
Section titled “PinAdapter”Entity adapter for Pin — CRUD + pin operations.
Source: packages/slingshot-chat/src/types.ts
ReactionCountPayload
Section titled “ReactionCountPayload”Payload for the chat.message.reaction WS event sent to clients.
Forwarded from both chat:message.reaction.added and chat:message.reaction.removed
bus events. The added flag distinguishes the two.
Source: packages/slingshot-chat/src/types.ts
ReadReceipt
Section titled “ReadReceipt”A read receipt.
Source: packages/slingshot-chat/src/types.ts
ReadReceiptAdapter
Section titled “ReadReceiptAdapter”Entity adapter for ReadReceipt — CRUD + receipt operations.
Source: packages/slingshot-chat/src/types.ts
ReadReceiptCreatedPayload
Section titled “ReadReceiptCreatedPayload”Payload emitted on the chat:read.created bus event when a read receipt is recorded.
Emitted by the chat.read WebSocket handler after upserting a receipt row.
The WS forward config picks this up and broadcasts chat.read to room members.
Source: packages/slingshot-chat/src/types.ts
Reminder
Section titled “Reminder”A user reminder.
Source: packages/slingshot-chat/src/types.ts
ReminderAdapter
Section titled “ReminderAdapter”Entity adapter for Reminder — CRUD + reminder operations.
Source: packages/slingshot-chat/src/types.ts
RoomInvite
Section titled “RoomInvite”A room invite link.
Source: packages/slingshot-chat/src/types.ts
RoomInviteAdapter
Section titled “RoomInviteAdapter”Entity adapter for RoomInvite — CRUD + invite operations.
Source: packages/slingshot-chat/src/types.ts
RoomMember
Section titled “RoomMember”A room membership record.
Source: packages/slingshot-chat/src/types.ts
RoomMemberAdapter
Section titled “RoomMemberAdapter”Entity adapter for RoomMember — CRUD + membership operations.
Source: packages/slingshot-chat/src/types.ts
UpdateMemberInput
Section titled “UpdateMemberInput”Input for updating a RoomMember (mutable fields only).
Source: packages/slingshot-chat/src/types.ts
UpdateMessageInput
Section titled “UpdateMessageInput”Input for updating a Message (mutable fields only).
Source: packages/slingshot-chat/src/types.ts
UpdateRoomInput
Section titled “UpdateRoomInput”Input for updating a Room.
Source: packages/slingshot-chat/src/types.ts
UserKeyBundle
Section titled “UserKeyBundle”Key bundle stored per user. v1: stub shape. v2: populated by full Signal key upload flow.
Source: packages/slingshot-chat/src/encryption/stub.ts
AddMemberInput
Section titled “AddMemberInput”Input type for RoomMemberAdapter.create(). Structural alias of CreateMemberInput.
Source: packages/slingshot-chat/src/types.ts
ChatEncryptionConfig
Section titled “ChatEncryptionConfig”JSON-safe encryption config for createChatPackage().
Source: packages/slingshot-chat/src/types.ts
ChatMessageUpdatedPayload
Section titled “ChatMessageUpdatedPayload”Payload sent to clients on chat.message.updated.
Source: packages/slingshot-chat/src/types.ts
MemberRole
Section titled “MemberRole”Member role within a room.
Source: packages/slingshot-chat/src/types.ts
MessageType
Section titled “MessageType”Message content type.
Source: packages/slingshot-chat/src/types.ts
NotifyPreference
Section titled “NotifyPreference”Notification preference for a room membership.
Source: packages/slingshot-chat/src/types.ts
RoomType
Section titled “RoomType”Room topology type.
Source: packages/slingshot-chat/src/types.ts