Scan your whole stack
From OX Research Newsroom
Are you using @charivo/realtime?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.20.12
@charivo/realtime was last scanned on 27 Nov 2026 at version 0.20.12. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.20.12 LATEST | 27 Nov 2026 | No rules fired |
| 0.20.11 | 23 Nov 2026 | No rules fired |
| 0.20.10 | 23 Nov 2026 | No rules fired |
| 0.20.9 | 23 Nov 2026 | Not shown |
| 0.20.8 | 23 Nov 2026 | Not shown |
Findings for v0.20.12. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.20.12; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Provider-agnostic realtime session manager and typed config helpers for Charivo.
pnpm add @charivo/realtime
import {
createRealtimeManager,
type ToolRegistration,
} from "@charivo/realtime";
import { createRemoteRealtimeClient } from "@charivo/realtime/remote";
const client = createRemoteRealtimeClient({ apiEndpoint: "/api/realtime" });
const tools: ToolRegistration[] = [
{
definition: {
type: "function",
name: "describeCharacterProfile",
description: "Return the active character profile.",
parameters: {
type: "object",
properties: {},
},
},
async handler(_args, context) {
return {
success: true,
name: context.character?.name ?? null,
};
},
},
];
const manager = createRealtimeManager(client, { tools });
manager.setCharacter({
id: "hiyori",
name: "Hiyori",
personality: "Cheerful and helpful assistant",
voice: { voiceId: "marin" },
});
await manager.startSession({
provider: "openai",
model: "gpt-realtime-2.1-mini",
});
// Or Gemini Live, over the same remote client and route:
await manager.startSession({ provider: "gemini", transport: "websocket" });
The remote client picks its browser adapter from that provider/transport
pair — OpenAI Realtime over WebRTC (the default transport) or Gemini Live over
WebSocket — and your route dispatches to @charivo/server/openai or
@charivo/server/gemini on the same field.
gpt-realtime-2.1-mini is the default OpenAI realtime model; the full gpt-realtime-2.1 is available but meaningfully more expensive — consult OpenAI's pricing page before switching. The Gemini default is gemini-3.1-flash-live-preview, the model the transport was measured against.
createRealtimeManager guarantees prepareAudio and setEventEmitter, so
calls on its result need no ?.. A variable typed as the core
RealtimeManager still does — a third-party manager may omit them.
For iOS-safe lip-sync, call prepareAudio() from the same user gesture that
starts the session, before startSession(...). Pass the same session config to
both calls — prepareAudio needs it to resolve which remote adapter to warm up:
const sessionConfig = {
provider: "openai",
model: "gpt-realtime-2.1-mini",
};
await manager.prepareAudio(sessionConfig);
await manager.startSession(sessionConfig);
On an OpenAI session, updateSession(...) patches the live session in place
(Gemini Live refuses live patches — see Session Refresh):
await manager.updateSession({
voice: "alloy",
});
// Switch the user-transcription model (cost vs. quality), or disable it.
await manager.updateSession({
inputAudioTranscription: { model: "gpt-4o-mini-transcribe" },
});
// Disable user transcription entirely (no whisper-1 charge):
await manager.updateSession({
inputAudioTranscription: { enabled: false },
});
If the live transport drops temporarily, RealtimeManager now keeps the
session active and drives reconnect attempts internally. During that window
state.session.status stays "active" while state.connection moves back to
"connecting".
For local development you can skip the server route: pass a provider API key to
the direct transport client and it mints the short-lived credential in the
browser — OpenAI's realtime client secret, or Google's single-use ephemeral
token — mirroring @charivo/llm/openai and @charivo/tts/openai.
import { createRealtimeManager } from "@charivo/realtime";
import { createOpenAIRealtimeAgentsClient } from "@charivo/realtime/openai-agents";
import { createGeminiLiveClient } from "@charivo/realtime/gemini";
// Dev/testing only: the API key is exposed in the browser.
const manager = createRealtimeManager(
createOpenAIRealtimeAgentsClient({ apiKey: "sk-..." }),
);
await manager.startSession({ provider: "openai", model: "gpt-realtime-2.1-mini" });
// Or Gemini Live, the same way.
const geminiManager = createRealtimeManager(
createGeminiLiveClient({ apiKey: "AIza..." }),
);
await geminiManager.startSession({ provider: "gemini", transport: "websocket" });
Both clients share the option precedence sessionBootstrap > apiEndpoint >
apiKey. The apiKey path is dev/testing only and additionally requires
microphone permission, a secure context (localhost or https), and a user
gesture to start; the minted credential is short-lived (re-minted per session).
The Gemini token still carries the whole session, exactly as the server
provider mints it, so nothing downstream differs from production. For
production, use the server-mediated @charivo/realtime/remote client shown
above.
createRealtimeManager(client, options?)buildRealtimeSessionConfig({ character, baseConfig? })DEFAULT_REALTIME_AGENT_INSTRUCTIONS@charivo/coreToolResultProjector (re-exported from @charivo/core) — use this for
resultProjectorsRealtimeLoggerTransport clients live on subpaths:
@charivo/realtime/remote: createRemoteRealtimeClient(config?), plus
DEFAULT_REMOTE_REALTIME_ADAPTERS — the registry it resolves from, keyed by
the adapter ids exported from @charivo/core@charivo/realtime/openai-agents: createOpenAIRealtimeAgentsClient(options?)
— OpenAI Realtime over WebRTC through the OpenAI Agents SDK@charivo/realtime/openai: createOpenAIRealtimeClient(options?) — the
legacy low-level OpenAI WebRTC transport@charivo/realtime/gemini: createGeminiLiveClient(options?) — Gemini Live
over WebSocket (apiEndpoint, sessionBootstrap, or a dev/testing
apiKey); captures the microphone at 16 kHz and plays the model's 24 kHz PCM
through its own scheduler with a lip-sync tap@charivo/realtime keeps its default instructions generic: spoken-output
constraints, tool-use restraint, stage-direction suppression, and basic
in-character behavior.
buildRealtimeSessionConfig({ character, baseConfig? }) already folds in:
You are ...)character.descriptioncharacter.personalitycharacter.voice.voiceId when availableIf your app needs stronger product-specific acting guidance, append it in the app layer instead of expanding the library default prompt:
const base = buildRealtimeSessionConfig({ character });
await manager.startSession({
provider: "openai",
model: "gpt-realtime-2.1-mini",
instructions: [
base.instructions,
"Keep replies short and natural for this product.",
].join("\n"),
});
buildRealtimeSessionConfig(...) does not fill provider-specific fields such
as provider or model. Prefer building on top of it for instructions and
character voice, then pass provider/model explicitly at startSession(...).
Each transport/provider pair keeps its own fallbacks for omitted model or voice
values: the OpenAI packages theirs, and @charivo/server/gemini
gemini-3.1-flash-live-preview with the Kore voice — which is also what a
voice id it does not recognise (an OpenAI one, say) silently becomes.
Avatar-specific realtime tools and avatar-specific instruction addenda now live
in @charivo/avatar (works with both @charivo/realtime and @charivo/llm;
formerly published as @charivo/realtime-avatar). Append those
instructions only in sessions that register avatar tools so @charivo/realtime
stays tool-agnostic.
RealtimeManager stays renderer-neutral. If your app wants domain-specific
events from tool outputs, pass resultProjectors:
import {
buildRealtimeSessionConfig,
createRealtimeManager,
} from "@charivo/realtime";
import {
buildAvatarControlInstructions,
createAvatarResultProjector,
} from "@charivo/avatar";
const base = buildRealtimeSessionConfig({ character });
const manager = createRealtimeManager(client, {
tools,
resultProjectors: [createAvatarResultProjector()],
logger: console,
});
await manager.startSession({
provider: "openai",
instructions: [
base.instructions,
buildAvatarControlInstructions(avatarCatalog),
].join("\n"),
});
resultProjectors run after successful local tool execution and can emit
additional app-level events such as avatar:expression. They receive the JSON
snapshot of the handler result — exactly what was sent to the transport — not
the live handler object. @charivo/llm hands its projectors the same snapshot,
so one projector behaves identically on both paths.
When a logger is configured, RealtimeManager also injects a per-session
sessionId into every log context. If the caller also supplies sessionId in
its own logger context, the manager value wins. The same sessionId is
included in realtime:usage payloads.
updateSession(...) patches the active provider session in place using the
latest requested config, current character, and current tool registry.
startSession(...)@charivo/realtime/gemini rejects outright: a Gemini
Live session is fixed when its token is minted (the token's setup replaces
the browser's, measured), and the Live API has no session.update. The call
rejects, realtime:error carries the same error, and the live session keeps
the configuration it started with; stop and start a new session to change it,
and register tools before startSession(...)realtime:state only and do not emit synthetic
realtime:session:end/start refresh boundariesstate.session.config in placestate.session.config is only replaced after the patch succeedsupdateSession(...) calls are coalesced to the latest configstopSession() wins over an in-flight refresh and converges to a stopped
sessionSuccessful reconnects are treated as a continuation of the same live session.
realtime:session:end/startupdateSession(...) still updates the cached base config while reconnectingsendMessage(...), sendAudioChunk(...), interrupt(), and transport-level
tool results reject while connection === "connecting"apiKey path) straight from Google's token endpoint — tokens are uses: 1,
and replaying one closes the socket with 1011 (measured) — and
the recovered session is a fresh one: sessionResumptionUpdate handles are
not spent, goAway is not acted on (the close after it drives this same
recovery), and the transport's microphone gate re-armsObservability events emitted by the manager:
realtime:reconnect:attemptrealtime:reconnect:successrealtime:reconnect:exhaustedRealtimeManager owns the tool registry. Definitions sent to the provider come
from the registry, not from defaultSessionConfig.tools.
Before invoking a local tool handler, the manager validates incoming tool
arguments against the tool definition's required, enum, and basic JSON
Schema type fields. Invalid arguments follow the normal tool failure path:
tool:error is emitted and a { success: false, error } result is sent back
to the transport. Nested object/array schemas, additionalProperties, and
union type arrays are not enforced.
manager.registerTool({
definition: {
type: "function",
name: "describeScene",
description: "Describe the current scene.",
parameters: {
type: "object",
properties: {},
},
},
async handler() {
return {
success: true,
scene: "Cafe",
};
},
});
Live registration:
registerTool(...) and unregisterTool(...) update the local registry immediatelyupdateSession(...) is needed; a live Gemini Live session refuses the patch (see Session Refresh), so register tools before starting itvoid; a failed patch surfaces as realtime:error, not a rejectionRealtimeManager accepts an emit-only event bridge through
setEventEmitter(...). It relays client output into the Charivo event stream,
but it does not subscribe through the shared event bus.
When connected, the manager relays:
realtime:session:startrealtime:session:endrealtime:staterealtime:user:transcriptrealtime:assistant:startrealtime:assistant:deltarealtime:assistant:donetool:calltool:resulttool:errorrealtime:usagerealtime:errortts:lipsync:updatetts:audio:starttts:audio:endtts:audio:end reports that playback finished, not that the server finished
sending — send completion can precede it by a wide margin. The OpenAI
transports derive it from output_audio_buffer.stopped (and
output_audio_buffer.cleared on an interruption), never from
response.audio.done / response.output_audio.done. The Gemini transport
plays the audio itself and ends it only when its scheduler has drained AND the
server's turnComplete has arrived — neither alone, because the scheduler
drains spuriously at the start of a turn and turnComplete is paced by a
server clock rather than observed from playback (both measured).
Consumers act on this event — RenderManager stops lip-sync there and, when no
voiced performance is open, ends the speech span that holds a speech-scoped
expression — so a custom transport that reports it at send completion will
reset the avatar's face mid-reply. See
docs/guide/realtime.md.
RealtimeState.audioPlaying exposes the same playback segment as state, which is
what to read when you need to know whether the character is still talking.
response.status answers a different question — it completes when the provider
closes the response, at send completion on OpenAI and at the clock-paced
turnComplete on Gemini, while playback runs on — so anything gated on it is
wrong for the tail of every turn. RealtimeState.awaitingResponse reports whether a reply is
still expected, which is the response-in-progress condition sendMessage
refuses on.
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.