Index of every page on this site: llms.txt
All skills
Run it yourself

Node.js / TypeScript server SDK for Fishjam — backends that create rooms, mint peer tokens, listen to server notifications, and run agents. Use when writing a Node.js / Express / Fastify / Hono / NestJS backend that talks to Fishjam, sets up a webhook receiver, runs an AI agent, generates livestream tokens, or composes streams. Trigger on: '@fishjam-cloud/js-server-sdk', 'FishjamClient', 'FishjamWSNotifier', 'FishjamAgent', 'createPeer', 'createRoom', 'createAgent', 'createVapiAgent', 'createLivestreamStreamerToken', 'createLivestreamViewerToken', 'refreshPeerToken', 'subscribeTracks', 'subscribePeer', 'createMoqToken', 'ServerMessage', 'roomCreated', 'peerAdded', 'trackAdded', 'fishjam backend Node', 'express fishjam', 'fastify fishjam', 'gemini agent fishjam', 'vapi fishjam', 'CompositionClient', 'createComposition', 'forwardRoomTracks'. Covers REST, WebSocket notifier, webhook protobuf decoding, FishjamAgent, Gemini Live integration, and CompositionClient.

  • 10 files
  • 59.5 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/software-mansion-labs/skills/js-server-sdk

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

agent.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

FishjamAgent

A server-side, programmatic peer that joins a room and exchanges audio frames with other peers. Used for AI voice integrations, custom server-side audio processing, and managed voice agents.

Source: packages/js-server-sdk/src/agent.ts in the js-server-sdk repo (https://github.com/fishjam-cloud/js-server-sdk).

For the Gemini Live integration that wraps this class, see gemini-integration.md. For Vapi (managed voice agents), use client.createVapiAgent — covered briefly in client.md.

Lifecycle

import type { AgentCallbacks } from '@fishjam-cloud/js-server-sdk';

const { agent, peer } = await fishjamClient.createAgent(
  roomId,
  {                                      // PeerOptionsAgent
    output: { audioFormat: 'pcm16', audioSampleRate: 16000 }, // audioFormat only 'pcm16'; audioSampleRate only 16000 | 24000 (pick 24000 for Gemini Live)
  },
  {                                      // AgentCallbacks
    onError: (event) => console.error('agent ws error', event),
    onClose: (code, reason) => console.log('agent ws closed', code, reason),
  } satisfies AgentCallbacks,
);

// ...interact with audio...
agent.disconnect();

agent is a typed EventEmitter, ready as soon as createAgent resolves — no need to call agent.awaitConnected() yourself (the SDK awaits it inside createAgent).

Outgoing audio

import type { AudioCodecParameters, TrackId } from '@fishjam-cloud/js-server-sdk';

const codec: AudioCodecParameters = { encoding: 'opus', sampleRate: 48000, channels: 1 };
// or { encoding: 'pcm16', sampleRate: 24000, channels: 1 }
// or { encoding: 'pcm16', sampleRate: 16000, channels: 1 }

const track = agent.createTrack(codec, { tag: 'tts-stream' });
// track: { id: TrackId, type, metadata }

agent.sendData(track.id, audioBytes /* Uint8Array */); // push frames
agent.interruptTrack(track.id);                         // drop any buffered playback
agent.deleteTrack(track.id);                            // remove the track from the room

Supported codecs (from the source):

  • opus → encoded internally as TRACK_ENCODING_OPUS.
  • pcm16 → TRACK_ENCODING_PCM16. Sample rates: 16000, 24000, 48000.

Frames go onto the WebSocket as binary AgentRequest.trackData messages. Pace yourself — there's no built-in backpressure; if you push faster than realtime, you'll inflate latency.

Incoming audio (trackData event)

import type { IncomingTrackData } from '@fishjam-cloud/js-server-sdk';

agent.on('trackData', (msg: IncomingTrackData) => {
  // msg.peerId (PeerId)
  // msg.track  (Track | undefined — check before use, e.g. msg.track?.id)
  // msg.data   (Uint8Array of audio frames)
});

What you receive is governed by output you set on PeerOptionsAgent. For example, output: { audioFormat: 'pcm16', audioSampleRate: 16000 } downmixes every peer's audio into pcm16 at 16kHz so the agent can feed it straight into an STT or LLM.

Image capture

If you want to "see" what a peer is broadcasting on a video track, ask for a single frame:

const image = await agent.captureImage(trackId, 5000 /* timeout ms */);
// image: { trackId, contentType: string (e.g. 'image/jpeg'), data: Uint8Array }

One pending capture per track at a time. The second concurrent call on the same track returns a rejected promise (it does not throw synchronously), with message captureImage already pending for track <trackId>. Timeouts also reject, they don't throw — so always await inside try/catch or chain .catch().

Disconnecting

agent.disconnect();

Closes the WebSocket. Any pending captureImage promises reject. Call this from your room teardown — the agent does not exit on its own.

Vapi (managed alternative)

If you just want a hosted voice agent and don't need fine-grained audio control, use createVapiAgent instead. It returns a peer (no client agent object) — Vapi manages the WebSocket and AI inference for you.

const { peer } = await fishjamClient.createVapiAgent(roomId, vapiOptions);
// no agent object, no track APIs — Vapi handles them

Sources

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 43cde80. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated last month

README badge

README badge for software-mansion-labs/skills/js-server-sdk