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.

gemini-integration.md

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

Gemini Live Integration

Fishjam ships an opinionated helper for wiring Google's Gemini Live (the multimodal @google/genai API) into a FishjamAgent. Source: packages/js-server-sdk/src/integrations/gemini.ts in the js-server-sdk repo (https://github.com/fishjam-cloud/js-server-sdk). Subpath import:

import {
  createClient,
  geminiInputAudioSettings,
  geminiOutputAudioSettings,
  inputMimeType,
} from '@fishjam-cloud/js-server-sdk/gemini';

@google/genai is an optional peer dependency - you only need to install it if you import from the '@fishjam-cloud/js-server-sdk/gemini' path.

What the helper provides

Export What it is
createClient(options) A thin wrapper around new GoogleGenAI(options)
geminiInputAudioSettings { audioFormat: 'pcm16', audioSampleRate: 16000 } — pass to createAgent as output so other peers' audio is downmixed into the format Gemini expects.
geminiOutputAudioSettings { encoding: 'pcm16', sampleRate: 24000, channels: 1 } — pass to agent.createTrack(...) so Gemini's TTS output flows back into the room.
inputMimeType 'audio/pcm;rate=16000' — the MIME string to attach to audio chunks sent to Gemini.

End-to-end pattern

import { FishjamClient } from '@fishjam-cloud/js-server-sdk';
import {
  createClient,
  geminiInputAudioSettings,
  geminiOutputAudioSettings,
  inputMimeType,
} from '@fishjam-cloud/js-server-sdk/gemini';
import { Modality } from '@google/genai';

const fishjamClient = new FishjamClient({
  fishjamId: process.env.FISHJAM_ID!,
  managementToken: process.env.FISHJAM_MANAGEMENT_TOKEN!,
});

const genai = createClient({ apiKey: process.env.GEMINI_API_KEY! });

async function spawnGeminiAgent(roomId: RoomId) {
  const { agent, peer } = await fishjamClient.createAgent(
    roomId,
    {
      output: geminiInputAudioSettings,
    },
  );

  // Create the Fishjam output track FIRST so the closure below captures a real reference.
  const geminiTrack = agent.createTrack(geminiOutputAudioSettings, { source: 'gemini' });

  const session = await genai.live.connect({
    model: 'gemini-2.0-flash-exp',
    config: {
      responseModalities: [Modality.AUDIO],
      systemInstruction: 'You are a helpful assistant.',
      outputAudioTranscription: {},
    },
    callbacks: {
      onmessage: (event) => {
        // Gemini → Fishjam: forward inbound audio to the room
        if (event.data) agent.sendData(geminiTrack.id, Buffer.from(event.data, 'base64'));
      },
      onerror: (e) => console.error('gemini error', e),
      onclose: () => agent.disconnect(),
    },
  });

  // Fishjam → Gemini: forward each peer's audio chunk
  agent.on('trackData', (msg) => {
    session.sendRealtimeInput({
      audio: { data: Buffer.from(msg.data).toString('base64'), mimeType: inputMimeType },
    });
  });

  return { agent, peer, session };
}

The full reference implementation lives in the js-server-sdk repo under examples/multimodal/ (full duplex audio with outputAudioTranscription and createTrack) and examples/gemini-demo/backend/ (production-shape end-to-end demo). examples/transcription/ is text-only — no createTrack, no audio echo back — so it won't match this pattern.

When to use the helper vs raw

  • Use the helper for the canonical 16kHz-in / 24kHz-out Gemini Live flow. It saves you from picking codec parameters and getting them wrong.
  • Skip the helper and import @google/genai directly if you need a different model with different audio formats, or if you're using Gemini's text-only modes (the helper is only ergonomic when you actually want voice).

Image capture for visual prompting

agent.captureImage(trackId) returns a still frame from a video track — useful for "look at what I'm showing and answer". Pair with Gemini's multimodal prompts.

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