@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
49 lines (48 loc) • 2.55 kB
TypeScript
/**
* Per-call memory for the realtime (speech-to-speech) voice agent.
*
* Decides, once per call and before anything else is wired, whether this call
* may be remembered: the room metadata must carry a memory binding that
* verifies against the shared secret and the actual room name. If it does, a
* NeuroLink instance is built, the conversation's recent history is read for
* seeding, and a turn recorder is created that writes each finished exchange
* through `recordConversationTurn`. If it does not, the call proceeds exactly
* as it would without memory, and a warning says why (never the ids).
*
* The shutdown flush is registered here, before the job lifecycle installs its
* process reaper. LiveKit starts every shutdown callback in registration order
* and the reaper exits the process about a second later, so the flush gets a
* budget below that second and starts first. The same budget bounds delivery of
* the call's last traces, which go out while the last writes finish.
*
* Each turn is traced as it closes, never behind the store's one-at-a-time
* writes, so a slow or stuck store cannot delay or lose a trace.
*
* Tracing does not depend on memory. A call with no memory still gets a
* recorder that only traces its turns (`setUpRealtimeCallTracing`).
*
* See docs/features/livekit-voice-agent.md.
*/
import type { JobContext } from "@livekit/agents";
import type { RealtimeCallMemory, RealtimeVoiceBackend, RealtimeVoiceMemoryConfig, VoiceTurnRecorder } from "../../types/index.js";
/**
* Prepare a recorder that only traces: for a call with no usable memory. Returns
* `undefined` when tracing is off. Without a verified binding there is no user,
* so the room is the session.
*/
export declare function setUpRealtimeCallTracing(ctx: Pick<JobContext, "room" | "addShutdownCallback">, options?: {
model?: string;
backend?: RealtimeVoiceBackend;
settleMs?: number;
flushBudgetMs?: number;
}): VoiceTurnRecorder | undefined;
/**
* Verify the call's binding and prepare its recorder; `undefined` means "no
* memory for this call". `call` names the model and the realtime backend the
* call runs on, which the turn spans carry as `model` and `provider`; the
* backend defaults to `gemini`, the original and default one.
*/
export declare function setUpRealtimeCallMemory(ctx: Pick<JobContext, "room" | "addShutdownCallback">, config: RealtimeVoiceMemoryConfig | undefined, call?: {
model?: string;
backend?: RealtimeVoiceBackend;
}): Promise<RealtimeCallMemory | undefined>;