@ottervoice/runtime-node
Documentation / @ottervoice/runtime-node
@ottervoice/runtime-node
Section titled “@ottervoice/runtime-node”Node.js runtime adapter for OtterVoice, with network, stream-based audio I/O, and console logging adapters.
Install
Section titled “Install”npm install @ottervoice/core @ottervoice/runtime-nodeimport { createNodeRuntime } from '@ottervoice/runtime-node';
const runtime = createNodeRuntime();Pass the returned runtime to your OtterVoice session configuration. Every adapter can be overridden for custom audio, network, and logging integration.
License
Section titled “License”MIT
Classes
Section titled “Classes”ConsoleLogger
Section titled “ConsoleLogger”Defined in: runtime-node/src/logger.ts:15
LoggerAdapter that forwards to console (or an injected console).
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ConsoleLogger(out?): ConsoleLogger;Defined in: runtime-node/src/logger.ts:16
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
out |
ConsoleLike |
console |
Returns
Section titled “Returns”Methods
Section titled “Methods”debug()
Section titled “debug()”debug(...args): void;Defined in: runtime-node/src/logger.ts:18
Verbose diagnostics (disabled in production by default).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
unknown[] |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”error()
Section titled “error()”error(...args): void;Defined in: runtime-node/src/logger.ts:30
Failures that typically surface as session errors.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
unknown[] |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”info()
Section titled “info()”info(...args): void;Defined in: runtime-node/src/logger.ts:22
Informational lifecycle messages.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
unknown[] |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”warn()
Section titled “warn()”warn(...args): void;Defined in: runtime-node/src/logger.ts:26
Recoverable anomalies.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
unknown[] |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”NodeAudioInput
Section titled “NodeAudioInput”Defined in: runtime-node/src/audio.ts:43
Reads audio bytes from an async iterable (a mic subprocess, a file stream, …)
and emits AudioChunks. Node has no permission model, so
requestPermission always resolves true.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NodeAudioInput(options?): NodeAudioInput;Defined in: runtime-node/src/audio.ts:52
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
NodeAudioInputOptions |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
whenDrained |
Promise<void> |
Resolves when the source has been fully consumed (or stopped). | runtime-node/src/audio.ts:50 |
Methods
Section titled “Methods”onChunk()
Section titled “onChunk()”onChunk(cb): () => void;Defined in: runtime-node/src/audio.ts:107
Subscribe to encoded / PCM chunks.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
cb |
(chunk) => void |
Returns
Section titled “Returns”Unsubscribe function.
() => void
Implementation of
Section titled “Implementation of”onError()
Section titled “onError()”onError(cb): () => void;Defined in: runtime-node/src/audio.ts:112
Subscribe to capture failures.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
cb |
(error) => void |
Returns
Section titled “Returns”Unsubscribe function.
() => void
Implementation of
Section titled “Implementation of”pause()
Section titled “pause()”pause(): Promise<void>;Defined in: runtime-node/src/audio.ts:99
Pause capture without tearing down permission / hardware (optional).
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”requestPermission()
Section titled “requestPermission()”requestPermission(): Promise<boolean>;Defined in: runtime-node/src/audio.ts:56
Prompt for mic permission; false should surface as a session error.
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”AudioInputAdapter.requestPermission
resume()
Section titled “resume()”resume(): Promise<void>;Defined in: runtime-node/src/audio.ts:103
Resume after pause.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”start()
Section titled “start()”start(startOptions?): Promise<void>;Defined in: runtime-node/src/audio.ts:60
Begin capture.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
startOptions |
AudioInputOptions |
Preferred rate / encoding hints the runtime may honor. |
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”stop()
Section titled “stop()”stop(): Promise<void>;Defined in: runtime-node/src/audio.ts:95
Stop capture and release resources tied to the current start.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”NodeAudioOutput
Section titled “NodeAudioOutput”Defined in: runtime-node/src/audio.ts:135
Node has no built-in UI playback. By default this records what would have
played; supply a sink to actually emit audio (file/speaker subprocess).
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NodeAudioOutput(options?): NodeAudioOutput;Defined in: runtime-node/src/audio.ts:141
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
NodeAudioOutputOptions |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Type | Default value | Defined in |
|---|---|---|---|
played |
AudioPlaybackInput[] |
[] |
runtime-node/src/audio.ts:139 |
Methods
Section titled “Methods”onEnd()
Section titled “onEnd()”onEnd(cb): () => void;Defined in: runtime-node/src/audio.ts:167
Subscribe to playback end (natural finish or stop).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
cb |
() => void |
Returns
Section titled “Returns”Unsubscribe function.
() => void
Implementation of
Section titled “Implementation of”onError()
Section titled “onError()”onError(cb): () => void;Defined in: runtime-node/src/audio.ts:172
Subscribe to playback failures.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
cb |
(error) => void |
Returns
Section titled “Returns”Unsubscribe function.
() => void
Implementation of
Section titled “Implementation of”onStart()
Section titled “onStart()”onStart(cb): () => void;Defined in: runtime-node/src/audio.ts:162
Subscribe to playback start.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
cb |
() => void |
Returns
Section titled “Returns”Unsubscribe function.
() => void
Implementation of
Section titled “Implementation of”play()
Section titled “play()”play(input): Promise<void>;Defined in: runtime-node/src/audio.ts:143
Play a complete encoded buffer or URL.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input |
AudioPlaybackInput |
URL and/or in-memory bytes plus optional MIME / volume. |
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”stop()
Section titled “stop()”stop(): Promise<void>;Defined in: runtime-node/src/audio.ts:158
Stop current playback and cancel any open PCM stream.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”NodeNetworkAdapter
Section titled “NodeNetworkAdapter”Defined in: runtime-node/src/network.ts:99
NetworkAdapter backed by global (or injected) fetch/WebSocket.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NodeNetworkAdapter(options?): NodeNetworkAdapter;Defined in: runtime-node/src/network.ts:103
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
NodeNetworkOptions |
Returns
Section titled “Returns”Methods
Section titled “Methods”createWebSocket()
Section titled “createWebSocket()”createWebSocket(url, protocols?): RuntimeWebSocket;Defined in: runtime-node/src/network.ts:112
Open a WebSocket for streaming providers.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
url |
string |
WebSocket URL. |
protocols? |
string | string[] |
Optional subprotocol(s). |
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”NetworkAdapter.createWebSocket
fetch()
Section titled “fetch()”fetch(input, init?): Promise<Response>;Defined in: runtime-node/src/network.ts:108
Fetch implementation (browser fetch, undici, etc.).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input |
RequestInfo | URL |
Request URL or RequestInfo. |
init? |
RequestInit |
Optional fetch init. |
Returns
Section titled “Returns”Promise<Response>
Implementation of
Section titled “Implementation of”NodeRuntimeWebSocket
Section titled “NodeRuntimeWebSocket”Defined in: runtime-node/src/network.ts:49
Adapts a WebSocketLike to the core RuntimeWebSocket contract.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NodeRuntimeWebSocket(ws): NodeRuntimeWebSocket;Defined in: runtime-node/src/network.ts:50
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ws |
WebSocketLike |
Returns
Section titled “Returns”Methods
Section titled “Methods”close()
Section titled “close()”close(code?, reason?): void;Defined in: runtime-node/src/network.ts:58
Close the socket.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
code? |
number |
Optional WebSocket close code. |
reason? |
string |
Optional human-readable reason. |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”onClose()
Section titled “onClose()”onClose(cb): () => void;Defined in: runtime-node/src/network.ts:80
Subscribe to close.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
cb |
() => void |
Returns
Section titled “Returns”Unsubscribe function.
() => void
Implementation of
Section titled “Implementation of”onError()
Section titled “onError()”onError(cb): () => void;Defined in: runtime-node/src/network.ts:74
Subscribe to socket-level errors.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
cb |
(error) => void |
Returns
Section titled “Returns”Unsubscribe function.
() => void
Implementation of
Section titled “Implementation of”onMessage()
Section titled “onMessage()”onMessage(cb): () => void;Defined in: runtime-node/src/network.ts:68
Subscribe to inbound frames.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
cb |
(data) => void |
Returns
Section titled “Returns”Unsubscribe function.
() => void
Implementation of
Section titled “Implementation of”onOpen()
Section titled “onOpen()”onOpen(cb): () => void;Defined in: runtime-node/src/network.ts:62
Subscribe to the open event.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
cb |
() => void |
Returns
Section titled “Returns”Unsubscribe function.
() => void
Implementation of
Section titled “Implementation of”send()
Section titled “send()”send(data): void;Defined in: runtime-node/src/network.ts:54
Send a text or binary frame.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data |
string | ArrayBuffer |
UTF-8 text or binary payload. |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Interfaces
Section titled “Interfaces”ConsoleLike
Section titled “ConsoleLike”Defined in: runtime-node/src/logger.ts:7
Minimal console surface accepted by ConsoleLogger and NodeRuntimeOptions.logger.
Methods
Section titled “Methods”debug()
Section titled “debug()”debug(...args): void;Defined in: runtime-node/src/logger.ts:8
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
unknown[] |
Returns
Section titled “Returns”void
error()
Section titled “error()”error(...args): void;Defined in: runtime-node/src/logger.ts:11
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
unknown[] |
Returns
Section titled “Returns”void
info()
Section titled “info()”info(...args): void;Defined in: runtime-node/src/logger.ts:9
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
unknown[] |
Returns
Section titled “Returns”void
warn()
Section titled “warn()”warn(...args): void;Defined in: runtime-node/src/logger.ts:10
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
unknown[] |
Returns
Section titled “Returns”void
NodeAudioInputOptions
Section titled “NodeAudioInputOptions”Defined in: runtime-node/src/audio.ts:24
Options for NodeAudioInput. Pass a NodeAudioInputOptions.source to stream bytes from a subprocess or file; omit it for a no-op / caller-driven input under createNodeRuntime.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
encoding? |
string |
Default encoding stamped on chunks when start does not override. |
runtime-node/src/audio.ts:35 |
now? |
() => number |
Override clock used for AudioChunk.timestamp (tests). | runtime-node/src/audio.ts:31 |
sampleRate? |
number |
Default sample rate stamped on chunks when start does not override. |
runtime-node/src/audio.ts:33 |
source? |
AsyncIterable<ArrayBuffer | Uint8Array<ArrayBufferLike>, any, any> |
The PCM/byte source — e.g. a child process stdout exposed as an async iterable. When omitted, the input produces nothing (caller-driven). | runtime-node/src/audio.ts:29 |
NodeAudioOutputOptions
Section titled “NodeAudioOutputOptions”Defined in: runtime-node/src/audio.ts:123
Options for NodeAudioOutput. Supply a NodeAudioOutputOptions.sink to emit audio; otherwise played inputs accumulate in NodeAudioOutput.played for inspection.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
sink? |
(input) => void | Promise<void> |
Where to send synthesized audio — write a file, pipe to a speaker process, etc. When omitted, audio is collected in NodeAudioOutput.played. | runtime-node/src/audio.ts:128 |
NodeNetworkOptions
Section titled “NodeNetworkOptions”Defined in: runtime-node/src/network.ts:91
Injected HTTP / WebSocket constructors for NodeNetworkAdapter.
Defaults to globalThis.fetch and globalThis.WebSocket when omitted.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
fetch? |
FetchLike |
Override fetch (defaults to the global). |
runtime-node/src/network.ts:93 |
webSocket? |
WebSocketCtor |
Override the WebSocket constructor (defaults to the global). | runtime-node/src/network.ts:95 |
NodeRuntime
Section titled “NodeRuntime”Defined in: runtime-node/src/index.ts:36
Node.js RuntimeAdapter returned by createNodeRuntime.
Includes audio adapters plus a NodeNetworkAdapter for providers
that need explicit fetch / WebSocket hooks.
Extends
Section titled “Extends”Properties
Section titled “Properties”| Property | Type | Description | Overrides | Inherited from | Defined in |
|---|---|---|---|---|---|
audioInput |
NodeAudioInput |
Byte-source microphone (async iterable or caller-driven). | RuntimeAdapter.audioInput |
- | runtime-node/src/index.ts:38 |
audioOutput |
NodeAudioOutput |
Sink or in-memory playback recorder. | RuntimeAdapter.audioOutput |
- | runtime-node/src/index.ts:40 |
logger? |
LoggerAdapter |
Optional logger; core uses it sparingly. | - | RuntimeAdapter.logger |
core/dist/types.d.ts:853 |
network |
NodeNetworkAdapter |
HTTP / WebSocket adapter for providers. | RuntimeAdapter.network |
- | runtime-node/src/index.ts:42 |
storage? |
RuntimeStorageAdapter |
Optional persistence for caches. | - | RuntimeAdapter.storage |
core/dist/types.d.ts:851 |
NodeRuntimeOptions
Section titled “NodeRuntimeOptions”Defined in: runtime-node/src/index.ts:20
Optional overrides for createNodeRuntime.
Use when piping a subprocess mic, writing audio to a sink, stubbing
fetch/WebSocket, or redirecting / disabling the console logger.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
audioInput? |
NodeAudioInputOptions |
Optional overrides for the default in-memory / stdin-style audio input. | runtime-node/src/index.ts:22 |
audioOutput? |
NodeAudioOutputOptions |
Optional overrides for the default console/file audio output. | runtime-node/src/index.ts:24 |
logger? |
| false | ConsoleLike |
Provide false to omit the logger, or a console to redirect it. |
runtime-node/src/index.ts:28 |
network? |
NodeNetworkOptions |
Optional overrides for fetch / WebSocket. |
runtime-node/src/index.ts:26 |
WebSocketLike
Section titled “WebSocketLike”Defined in: runtime-node/src/network.ts:4
Minimal surface of a browser/Bun/ws WebSocket the wrapper relies on.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
binaryType? |
string |
Prefer 'arraybuffer' when the peer sends binary frames. |
runtime-node/src/network.ts:6 |
Methods
Section titled “Methods”addEventListener()
Section titled “addEventListener()”addEventListener(type, listener): void;Defined in: runtime-node/src/network.ts:12
Subscribe to socket events (open / message / error / close).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
type |
string |
listener |
(event) => void |
Returns
Section titled “Returns”void
close()
Section titled “close()”close(code?, reason?): void;Defined in: runtime-node/src/network.ts:10
Close the socket; optional close code and reason.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
code? |
number |
reason? |
string |
Returns
Section titled “Returns”void
removeEventListener()
Section titled “removeEventListener()”removeEventListener(type, listener): void;Defined in: runtime-node/src/network.ts:14
Unsubscribe a listener previously added with WebSocketLike.addEventListener.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
type |
string |
listener |
(event) => void |
Returns
Section titled “Returns”void
send()
Section titled “send()”send(data): void;Defined in: runtime-node/src/network.ts:8
Send a text or binary frame to the peer.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data |
string | ArrayBufferLike | ArrayBufferView<ArrayBufferLike> |
Returns
Section titled “Returns”void
Type Aliases
Section titled “Type Aliases”FetchLike
Section titled “FetchLike”type FetchLike = (input, init?) => Promise<Response>;Defined in: runtime-node/src/network.ts:24
fetch-compatible HTTP entry point used by NodeNetworkAdapter.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
RequestInfo | URL |
init? |
RequestInit |
Returns
Section titled “Returns”Promise<Response>
WebSocketCtor
Section titled “WebSocketCtor”type WebSocketCtor = (url, protocols?) => WebSocketLike;Defined in: runtime-node/src/network.ts:18
Constructor for WebSocketLike (global WebSocket or ws).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
url |
string |
protocols? |
string | string[] |
Returns
Section titled “Returns”Functions
Section titled “Functions”createNodeRuntime()
Section titled “createNodeRuntime()”function createNodeRuntime(options?): NodeRuntime;Defined in: runtime-node/src/index.ts:50
Assemble a Node.js RuntimeAdapter.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options |
NodeRuntimeOptions |
Optional audio, network, and logger overrides. See NodeRuntimeOptions. |
Returns
Section titled “Returns”normalizeWsData()
Section titled “normalizeWsData()”function normalizeWsData(data): string | ArrayBuffer;Defined in: runtime-node/src/network.ts:35
Normalize a WebSocket message event’s data to string | ArrayBuffer.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data |
unknown |
Raw MessageEvent.data (string, ArrayBuffer, or TypedArray view). |
Returns
Section titled “Returns”string | ArrayBuffer
A copy suitable for RuntimeWebSocket callbacks.