UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

31 lines (30 loc) • 1.31 kB
/** * LiveKit server-side room operations: create a room with metadata, and * dispatch a named agent to a room. * * Wraps `livekit-server-sdk` (an optional dependency, imported dynamically) so * consumers route all LiveKit *server* calls through `@juspay/neurolink/livekit` * — they never depend on the SDK directly. Mirrors `mintJoinToken`. */ const toHttpUrl = (url) => url.replace(/^ws/, "http"); export async function createVoiceRoom(req) { const { RoomServiceClient } = await import("livekit-server-sdk"); const client = new RoomServiceClient(toHttpUrl(req.url), req.apiKey, req.apiSecret); await client.createRoom({ name: req.room, metadata: req.metadata ?? "", emptyTimeout: req.emptyTimeoutSeconds ?? 300, departureTimeout: req.departureTimeoutSeconds ?? 20, }); } /** * Explicitly dispatch a named agent to a room. The long-lived worker registered * under `agentName` receives the job and forks a child to run the call. */ export async function dispatchVoiceAgent(req) { const { AgentDispatchClient } = await import("livekit-server-sdk"); const client = new AgentDispatchClient(toHttpUrl(req.url), req.apiKey, req.apiSecret); await client.createDispatch(req.room, req.agentName, { metadata: req.metadata ?? "", }); }