@veroai/chat reference
ChatClient bundles the REST API client (client.api) and the WebSocket connection into a single object. All snake_case server responses are transformed to camelCase before you see them.
ChatClient
new ChatClient({
apiUrl?: string; // default: https://api.veroagents.com
wsUrl?: string; // default: wss://ws.veroagents.com/ws
token?: string; // static JWT
getToken?: () => string | Promise<string | null>;
autoConnect?: boolean;
autoReconnect?: boolean; // default: true
reconnectInterval?: number; // ms, default: 2000
maxReconnectAttempts?: number;// default: 15
})Lifecycle
chat.connect() // open WebSocket + exchange messaging token
chat.disconnect()
chat.isConnected()
chat.subscribe([convId])
chat.unsubscribe([convId])
chat.subscribeSession(sessionId)
chat.on("message.created", (ev, convId) => {})Messages
chat.api.send({ conversationId, contentText, contentType?, replyToId?, threadRole?, taskId? })
chat.api.getMessages(conversationId, { fromSeq?, toSeq?, limit? })
chat.api.sync([{ conversationId, lastSeq }])
chat.api.toggleReaction(messageId, conversationId, emoji)
chat.api.forward(messageId, [targetConvId])
// Bundle A — new
chat.api.editMessage(messageId, { contentText, contentMeta? })
chat.api.searchMessages({ q, conversationId?, limit?, beforeSeq? })Conversations
chat.api.listConversations()
chat.api.createConversation({ type?, name?, participantIds? })
chat.api.updateConversation(convId, { name?, description? })
chat.api.deleteConversation(convId, "for_me" | "for_everyone")
chat.api.addParticipants(convId, [userIds])
chat.api.removeParticipant(convId, userId)
chat.api.getParticipants(convId)
chat.api.markRead(convId, upToSeq)
// Bundle A + B — new
chat.api.typing(convId, "start" | "stop")
chat.api.getUnreadCounts()
chat.api.mute(convId, { until?: ISOString, durationSec?: number })
chat.api.unmute(convId)
chat.api.archive(convId)
chat.api.unarchive(convId)Users & blocks
chat.api.listUsers()
chat.api.listAgents()
// Bundle B — new
chat.api.blockUser(userId)
chat.api.unblockUser(userId)
chat.api.listBlocked()Messaging token
chat.api.getMessagingToken() // → { token, wsUrl, expiresAt }Errors
import { ChatApiError } from "@veroai/chat";
try {
await chat.api.send({ /* ... */ });
} catch (err) {
if (err instanceof ChatApiError) {
console.error(err.status, err.message, err.body);
}
}