Connector-agnostic runtime for normalized streaming chat events with optional USCP-SSE or Moblin-compatible transport output.
- Provides
createStreamingChatRuntime()for event normalization, reconnect handling, and WS fanout. - Provides
validateRuntimeConfig()for runtime config normalization/validation. - Does not bundle platform connectors.
You must register connector definitions in your host program.
npm install @reino-doce/streaming-chat-webserviceconst {
createStreamingChatRuntime,
validateRuntimeConfig,
} = require("@reino-doce/streaming-chat-webservice");
const mockConnector = {
id: "my-connector",
platform: "my-platform",
create() {
return {
async connect(_config, emit) {
emit({ type: "lifecycle", at: Date.now(), state: "connected", roomId: "room-1" });
},
async disconnect() {},
};
},
};
const runtime = createStreamingChatRuntime({ connectors: [mockConnector] });
const validation = validateRuntimeConfig(
{
connectorId: "my-connector",
connectorConfig: {},
connect: true,
monitor: false,
reconnectOnDisconnect: true,
reconnectDelayMs: 5000,
reconnectDelayOfflineMs: 30000,
ws: {
enabled: false,
protocol: "uscp-sse/1",
host: "127.0.0.1",
port: 5443,
token: "",
},
giftToSyntheticChat: true,
},
{ connectors: [mockConnector] },
);
if (!validation.ok) {
throw new Error(validation.errors.join("; "));
}
runtime.start(validation.config);{
"connectorId": "",
"connectorConfig": {},
"connect": false,
"monitor": false,
"reconnectOnDisconnect": true,
"reconnectDelayMs": 5000,
"reconnectDelayOfflineMs": 30000,
"ws": {
"enabled": false,
"protocol": "uscp-sse/1",
"host": "0.0.0.0",
"port": 5443,
"token": ""
},
"giftToSyntheticChat": true
}reconnectDelayMsis clamped to1000..60000.reconnectDelayOfflineMsis clamped to1000..600000.ws.portis clamped to1024..65535.ws.protocolacceptsmoblin-xmpp; everything else becomesuscp-sse/1.- Legacy
jsonWS mode was removed; useuscp-sse/1(default) ormoblin-xmpp. - If
ws.enabled=true,ws.tokenis required. - If
connect=trueormonitor=true,connectorIdis required. - If
connect=true,monitor=true, orconnectorIdis non-empty, the connector must be registered.
monitor=trueturns the runtime into watch mode for the configured upstream user.- In monitor mode, startup does not fail when the upstream is offline; the runtime keeps retrying in background.
- Retry remains infinite and uses
reconnectDelayMsfor regular disconnects andreconnectDelayOfflineMsfor offline/live-not-found cases. - In
uscp-sse/1mode, monitor lifecycle notices are emitted assystem.upstream.eventwithupstream_eventvalues likemonitor.connected,monitor.offline, andmonitor.disconnected.
- In
uscp-sse/1transport mode, protocol frames received aschat.messagewith synthetic gift text ([GIFT] ...) are normalized to canonicalmonetization.donation.giftevents. - Source metadata (
source_*) and author display fields are preserved when present. user_image_idis preserved/propagated for mapped user events (including like/share normalization paths) so clients can render profile avatars consistently.- Canonical interaction migration is strict:
interaction.barrage.announcedis replaced byaudience.room_join.competition.link_mic.fan_ticket.updatedis replaced byaudience.fan_club.fan_level.- Legacy type codes are dropped when received as protocol events.
- Transport keeps an in-memory
user id -> usernamemap per source and rewrites known numeric user-id fields in later protocol payloads (for examplefrom_user_id) to the known username when possible. - TikTok
imDeleteevents normalize tomoderation.message.delete; whendeleteMsgIdsListis empty, connector falls back tocommon.msgIdasmessage_id. - When an event is dropped during USCP serialization, transport logs
console.warnwith reason, type/source, and payload/context snapshot.
createStreamingChatRuntime(args?)validateRuntimeConfig(rawConfig, args?)
Type definitions are in index.d.ts.
Standalone executable support moved to:
@reino-doce/streaming-chat-webservice-cli
Install and run:
npm install @reino-doce/streaming-chat-webservice-cli
streaming-chat-webservice --helpFor TikTok connector raw-event auditing in standalone mode, use:
--verbose trueto enable raw event capture.--verbose-log-path <path>(or envRD_TIKTOK_VERBOSE_LOG_PATH) to control output file path.--monitor trueto keep watching an upstream user even while they are offline.
The file defaults to ./logs/tiktok-live-connector.log and writes one line per event in the format <ISO datetime> <raw event JSON>.
That package includes the built-in TikTok connector for standalone use.