Framework-agnostic TypeScript SDK for connecting to a StreamCoreAI server via WebRTC + WHIP.
npm install @streamcore/js-sdkimport { StreamCoreAIClient } from "@streamcore/js-sdk";
const agent = new StreamCoreAIClient(
{ whipUrl: "http://localhost:8080/whip" },
{
onStatusChange: (status) => console.log("Status:", status),
onTranscript: (entry, all) => console.log("Transcript:", entry),
onAudioLevel: (level) => console.log("Audio level:", level),
onError: (err) => console.error("Error:", err),
}
);
// Connect (requests microphone permission, establishes WebRTC session)
await agent.connect();
// Mute / unmute
agent.toggleMute();
console.log("Muted:", agent.isMuted);
// Disconnect
agent.disconnect();Creates a new client instance.
| Property | Type | Default | Description |
|---|---|---|---|
whipUrl |
string |
"http://localhost:8080/whip" |
WHIP signaling endpoint URL |
iceServers |
RTCIceServer[] |
[{ urls: "stun:stun.l.google.com:19302" }] |
ICE server configuration |
audioConstraints |
MediaTrackConstraints |
{ echoCancellation: true, noiseSuppression: true, autoGainControl: true } |
Microphone constraints |
| Event | Signature | Description |
|---|---|---|
onStatusChange |
(status: ConnectionStatus) => void |
Fired when connection status changes |
onTranscript |
(entry: TranscriptEntry, all: TranscriptEntry[]) => void |
Fired on new or updated transcript |
onAudioLevel |
(level: number) => void |
Fired every animation frame with mic level (0–1) |
onError |
(error: Error) => void |
Fired on connection or server errors |
onTiming |
(event: TimingEvent) => void |
Fired with server-side pipeline timing info |
| Method | Returns | Description |
|---|---|---|
connect() |
Promise<void> |
Request mic, establish WebRTC + WHIP session |
disconnect() |
void |
Tear down connection, stop mic, free resources |
toggleMute() |
void |
Toggle microphone mute |
on(event, fn) |
void |
Register an event listener after construction |
| Property | Type | Description |
|---|---|---|
status |
ConnectionStatus |
"idle" | "connecting" | "connected" | "error" | "disconnected" |
transcript |
TranscriptEntry[] |
Full conversation history |
audioLevel |
number |
Current mic audio level (0–1) |
isMuted |
boolean |
Whether the mic is muted |
localStream |
MediaStream | null |
Local microphone stream (after connect) |
remoteStream |
MediaStream | null |
Remote agent audio stream (after connect) |
type ConnectionStatus = "idle" | "connecting" | "connected" | "error" | "disconnected";
interface TranscriptEntry {
role: "user" | "assistant";
text: string;
partial?: boolean;
}
interface TimingEvent {
stage: string;
ms: number;
}cd typescript-sdk
npm install
npm run buildThe compiled output is written to dist/.
The SDK ships as ES modules with TypeScript declarations. It works out of the box with Vite, webpack, Next.js, esbuild, and other modern bundlers.
Apache2.0