/**
 * 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 ?? "",
    });
}
//# sourceMappingURL=roomDispatch.js.map