💬

@radzor/realtime-chat

Real-time chat messaging via WebSocket. Supports rooms, typing indicators, message history, and user presence. Works in both browser and Node.js environments.

Chat & Messagingv0.1.0typescriptwebsocketrealtimemessagingchatrooms3,055 downloadsby Radzor
$npx radzor add realtime-chat
⚠ Constraints: Requires a WebSocket server. For production, use wss:// (TLS). The server component handles room state and message broadcasting.

Inputs

NameTypeDefaultDescription
roomId*stringUnique identifier for the chat room to join.
userId*stringUnique identifier for the current user.
maxMessagesnumber100Maximum number of messages to keep in local buffer.
serverUrl*stringWebSocket server URL to connect to.
authSessionAuthSessionAuthentication session for authorized connections (from @radzor/auth-oauth).

Outputs

NameTypeDescription
messageStreamReadableStream<ChatMessage>Stream of incoming chat messages.
connectionStatus'connecting' | 'connected' | 'disconnected' | 'error'Current WebSocket connection status.

Actions

sendMessage(content: string)Promise<ChatMessage>

Send a text message to the current room.

joinRoom(roomId: string)Promise<void>

Join a chat room and start receiving messages.

leaveRoom()Promise<void>

Leave the current room and disconnect.

getHistory(limit: number)Promise<ChatMessage[]>

Retrieve message history for the current room.

setTyping(isTyping: boolean)void

Broadcast typing indicator to other users in the room.

Events

onMessage{id: string, userId: string, content: string, timestamp: number}

Fired when a new message is received in the room.

onUserJoin{userId: string, username: string}

Fired when a user joins the room.

onUserLeave{userId: string}

Fired when a user leaves the room.

onTyping{userId: string, isTyping: boolean}

Fired when a user starts or stops typing.

onError{code: string, message: string}

Fired on connection or messaging errors.

Composability

messageStream
@radzor/ai-responder.input.messageStream@radzor/message-logger.input.messageStream

radzor.manifest.json

{
  "llm": {
    "constraints": "Requires a WebSocket server. For production, use wss:// (TLS). The server component handles room state and message broadcasting.",
    "usageExamples": "llm/examples.md",
    "integrationPrompt": "llm/integration.md"
  },
  "name": "@radzor/realtime-chat",
  "tags": [
    "websocket",
    "realtime",
    "messaging",
    "chat",
    "rooms"
  ],
  "events": [
    {
      "name": "onMessage",
      "payload": {
        "id": "string",
        "userId": "string",
        "content": "string",
        "timestamp": "number"
      },
      "description": "Fired when a new message is received in the room."
    },
    {
      "name": "onUserJoin",
      "payload": {
        "userId": "string",
        "username": "string"
      },
      "description": "Fired when a user joins the room."
    },
    {
      "name": "onUserLeave",
      "payload": {
        "userId": "string"
      },
      "description": "Fired when a user leaves the room."
    },
    {
      "name": "onTyping",
      "payload": {
        "userId": "string",
        "isTyping": "boolean"
      },
      "description": "Fired when a user starts or stops typing."
    },
    {
      "name": "onError",
      "payload": {
        "code": "string",
        "message": "string"
      },
      "description": "Fired on connection or messaging errors."
    }
  ],
  "inputs": [
    {
      "name": "roomId",
      "type": "string",
      "required": true,
      "description": "Unique identifier for the chat room to join."
    },
    {
      "name": "userId",
      "type": "string",
      "required": true,
      "description": "Unique identifier for the current user."
    },
    {
      "name": "maxMessages",
      "type": "number",
      "default": 100,
      "required": false,
      "description": "Maximum number of messages to keep in local buffer."
    },
    {
      "name": "serverUrl",
      "type": "string",
      "required": true,
      "description": "WebSocket server URL to connect to."
    },
    {
      "name": "authSession",
      "type": "AuthSession",
      "required": false,
      "description": "Authentication session for authorized connections (from @radzor/auth-oauth)."
    }
  ],
  "radzor": "1.0.0",
  "actions": [
    {
      "name": "sendMessage",
      "params": [
        {
          "name": "content",
          "type": "string",
          "description": "The message text to send."
        }
      ],
      "returns": "Promise<ChatMessage>",
      "description": "Send a text message to the current room."
    },
    {
      "name": "joinRoom",
      "params": [
        {
          "name": "roomId",
          "type": "string",
          "description": "Room ID to join."
        }
      ],
      "returns": "Promise<void>",
      "description": "Join a chat room and start receiving messages."
    },
    {
      "name": "leaveRoom",
      "params": [],
      "returns": "Promise<void>",
      "description": "Leave the current room and disconnect."
    },
    {
      "name": "getHistory",
      "params": [
        {
          "name": "limit",
          "type": "number",
          "default": 50,
          "required": false,
          "description": "Number of past messages to retrieve."
        }
      ],
      "returns": "Promise<ChatMessage[]>",
      "description": "Retrieve message history for the current room."
    },
    {
      "name": "setTyping",
      "params": [
        {
          "name": "isTyping",
          "type": "boolean",
          "description": "Whether the user is currently typing."
        }
      ],
      "returns": "void",
      "description": "Broadcast typing indicator to other users in the room."
    }
  ],
  "outputs": [
    {
      "name": "messageStream",
      "type": "ReadableStream<ChatMessage>",
      "description": "Stream of incoming chat messages."
    },
    {
      "name": "connectionStatus",
      "type": "'connecting' | 'connected' | 'disconnected' | 'error'",
      "description": "Current WebSocket connection status."
    }
  ],
  "version": "0.1.0",
  "category": "chat",
  "languages": [
    "typescript"
  ],
  "description": "Real-time chat messaging via WebSocket. Supports rooms, typing indicators, message history, and user presence. Works in both browser and Node.js environments.",
  "dependencies": {
    "radzor": [
      "@radzor/auth-oauth"
    ],
    "packages": {
      "ws": "^8.0.0"
    }
  },
  "composability": {
    "connectsTo": [
      {
        "output": "messageStream",
        "compatibleWith": [
          "@radzor/ai-responder.input.messageStream",
          "@radzor/message-logger.input.messageStream"
        ]
      }
    ]
  }
}

Version History

0.1.0

Initial release

4/3/2026