orb-ui 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/dist/adapters/agora/index.d.ts +65 -0
- package/dist/adapters/azure-voice-live/browser-audio.d.ts +32 -0
- package/dist/adapters/azure-voice-live/index.d.ts +67 -0
- package/dist/adapters/cartesia/index.d.ts +50 -0
- package/dist/adapters/deepgram/index.d.ts +69 -0
- package/dist/adapters/hume/index.d.ts +48 -0
- package/dist/adapters/index.d.ts +7 -0
- package/dist/adapters/nova-sonic/index.d.ts +60 -0
- package/dist/adapters/retell/index.d.ts +78 -0
- package/dist/adapters.cjs +20 -1
- package/dist/adapters.js +1219 -1
- package/dist/orb-ui.cjs +1 -1
- package/dist/orb-ui.js +2 -2
- package/package.json +13 -2
package/README.md
CHANGED
|
@@ -83,6 +83,13 @@ The only difference is how the adapter obtains a provider session:
|
|
|
83
83
|
| [OpenAI Live guide](https://orb-ui.com/docs/adapters/openai-live) | Exchange an SDP offer through your server with `createSession` |
|
|
84
84
|
| [OpenAI Realtime guide](https://orb-ui.com/docs/adapters/openai-realtime) | Return a fresh short-lived client secret from `getClientSecret` |
|
|
85
85
|
| [Gemini Live guide](https://orb-ui.com/docs/adapters/gemini-live) | Open the official Google Live session in `connect` |
|
|
86
|
+
| [Retell WebCall](https://orb-ui.com/docs/adapters/retell) | Pass the current Retell client with developer-owned session creation |
|
|
87
|
+
| [Hume EVI](https://orb-ui.com/docs/adapters/hume) | Observe your existing `VoiceProvider` and `useVoice` values |
|
|
88
|
+
| [Deepgram Voice Agent](https://orb-ui.com/docs/adapters/deepgram) | Connect the browser SDK or observe its React provider |
|
|
89
|
+
| [Agora Conversational AI](https://orb-ui.com/docs/adapters/agora) | Observe your toolkit and app-owned RTC audio |
|
|
90
|
+
| [Azure Voice Live](https://orb-ui.com/docs/adapters/azure-voice-live) | Supply an authenticated JavaScript session; adapter owns PCM audio |
|
|
91
|
+
| [Cartesia Managed Agents](https://orb-ui.com/docs/adapters/cartesia) | Return a short-lived Line agent WebSocket URL from your backend |
|
|
92
|
+
| [Amazon Nova 2 Sonic](https://orb-ui.com/docs/adapters/nova-sonic) | Run the Node/Socket.IO/Bedrock recipe; use its controlled browser bridge |
|
|
86
93
|
|
|
87
94
|
The adapter owns provider event mapping and emits one consistent `OrbSignal`. OpenAI and Gemini
|
|
88
95
|
standard API keys, and LiveKit participant-token signing, stay on your server. See the
|
|
@@ -92,6 +99,24 @@ advanced setup shapes.
|
|
|
92
99
|
For an app-owned WebRTC, WebSocket, telephony, or speech runtime, follow the
|
|
93
100
|
[custom integration guide](https://orb-ui.com/docs/adapters/custom).
|
|
94
101
|
|
|
102
|
+
## Complete voice UI recipes
|
|
103
|
+
|
|
104
|
+
[Explore eight React recipes](https://orb-ui.com/docs/recipes): push-to-talk composition, voice form
|
|
105
|
+
review, document answers with citations, guided onboarding with undo, language practice,
|
|
106
|
+
interview rehearsal, spoken product search, and audio-reactive narration. Each page includes
|
|
107
|
+
a copyable working component and an embedded local fixture demo. Demo source can be downloaded
|
|
108
|
+
from the canonical recipe page.
|
|
109
|
+
|
|
110
|
+
Public demos use local simulated signals or committed audio fixtures. They never use provider
|
|
111
|
+
credits or microphone access. Hosted provider proxy routes are disabled. Live examples require
|
|
112
|
+
your own authenticated backend and short-lived browser credentials; provider secrets stay server-side.
|
|
113
|
+
The developer provider playground is available through `pnpm dev:demo` at localhost.
|
|
114
|
+
|
|
115
|
+
The seven expansion integrations require `orb-ui@0.10.0` or later. Install that version to use
|
|
116
|
+
the exported APIs; credential-based live provider tests have not been run.
|
|
117
|
+
See the [expansion checklist](EXPANSION_CHECKLIST.md) for all fifteen additions and their
|
|
118
|
+
verification and publication boundaries.
|
|
119
|
+
|
|
95
120
|
## Quick Start
|
|
96
121
|
|
|
97
122
|
Use orb-ui as a React voice AI component when you need a first-party provider voice UI or a custom animated voice orb for another realtime voice agent stack.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { OrbAdapter } from '../types.js';
|
|
2
|
+
import { VolumeCalibrationSource } from '../audio-level.js';
|
|
3
|
+
export interface AgoraAgentStateEvent {
|
|
4
|
+
state: 'idle' | 'listening' | 'thinking' | 'speaking' | 'silent';
|
|
5
|
+
turnID: number;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
reason: string;
|
|
8
|
+
}
|
|
9
|
+
/** Current AgoraVoiceAI surface. ConversationalAIAPI remains an SDK alias. */
|
|
10
|
+
export interface AgoraToolkitLike {
|
|
11
|
+
on(event: 'agent-state-changed', handler: (uid: string, event: AgoraAgentStateEvent) => void): unknown;
|
|
12
|
+
on(event: 'agent-thinking-changed' | 'agent-speaking-changed', handler: (uid: string, active: boolean) => void): unknown;
|
|
13
|
+
on(event: 'agent-interrupted', handler: (uid: string, event: {
|
|
14
|
+
turnID: number;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
}) => void): unknown;
|
|
17
|
+
on(event: 'agent-error' | 'message-error', handler: (uid: string, error: unknown) => void): unknown;
|
|
18
|
+
off(event: 'agent-state-changed', handler: (uid: string, event: AgoraAgentStateEvent) => void): unknown;
|
|
19
|
+
off(event: 'agent-thinking-changed' | 'agent-speaking-changed', handler: (uid: string, active: boolean) => void): unknown;
|
|
20
|
+
off(event: 'agent-interrupted', handler: (uid: string, event: {
|
|
21
|
+
turnID: number;
|
|
22
|
+
timestamp: number;
|
|
23
|
+
}) => void): unknown;
|
|
24
|
+
off(event: 'agent-error' | 'message-error', handler: (uid: string, error: unknown) => void): unknown;
|
|
25
|
+
interrupt(agentUserId: string): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export interface AgoraRTCClientLike {
|
|
28
|
+
readonly connectionState: string;
|
|
29
|
+
on(event: 'connection-state-change', handler: (current: string, previous: string, reason?: string) => void): unknown;
|
|
30
|
+
off(event: 'connection-state-change', handler: (current: string, previous: string, reason?: string) => void): unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface AgoraAudioTrackLike {
|
|
33
|
+
getVolumeLevel(): number;
|
|
34
|
+
readonly enabled?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface AgoraRemoteAudioTrackLike extends AgoraAudioTrackLike {
|
|
37
|
+
/** Audio must already be played by the application, after RTC subscribe(). */
|
|
38
|
+
readonly isPlaying: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface AgoraSession {
|
|
41
|
+
toolkit: AgoraToolkitLike;
|
|
42
|
+
rtc: AgoraRTCClientLike;
|
|
43
|
+
/** The agent UID returned by your backend, not a guessed participant. */
|
|
44
|
+
agentUserId: string;
|
|
45
|
+
getMicrophoneTrack(): AgoraAudioTrackLike | undefined;
|
|
46
|
+
getAgentAudioTrack(): AgoraRemoteAudioTrackLike | undefined;
|
|
47
|
+
/** Close mic, stop remote playback, unsubscribe/destroy toolkit, leave RTC/RTM, end backend agent. */
|
|
48
|
+
close(): void | Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export interface AgoraAdapterOptions {
|
|
51
|
+
/** Your application owns authenticated session creation, RTC/RTM audio, and scoped tokens. */
|
|
52
|
+
createSession(signal: AbortSignal): Promise<AgoraSession>;
|
|
53
|
+
/** Includes permission and backend/RTC readiness. Default: 30 seconds. */
|
|
54
|
+
startTimeoutMs?: number;
|
|
55
|
+
inputVolumeCalibration?: VolumeCalibrationSource;
|
|
56
|
+
outputVolumeCalibration?: VolumeCalibrationSource;
|
|
57
|
+
}
|
|
58
|
+
export interface AgoraOrbAdapter extends OrbAdapter {
|
|
59
|
+
start(): Promise<void>;
|
|
60
|
+
stop(): Promise<void>;
|
|
61
|
+
/** Publishing the interruption is not confirmation; wait for toolkit events. */
|
|
62
|
+
interrupt(): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
/** Observes your toolkit/RTC session; never opens another capture or playback path. */
|
|
65
|
+
export declare function createAgoraAdapter(options: AgoraAdapterOptions): AgoraOrbAdapter;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Shared PCM browser path for injected Azure sessions and Cartesia agent sockets. */
|
|
2
|
+
export interface PcmBrowserAudioOptions {
|
|
3
|
+
mediaStreamConstraints?: MediaStreamConstraints;
|
|
4
|
+
getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
|
|
5
|
+
createAudioContext?: () => AudioContext;
|
|
6
|
+
/** Supply your existing AudioWorklet factory when your CSP disallows blob modules. */
|
|
7
|
+
createCaptureNode?: (context: AudioContext) => Promise<AudioWorkletNode>;
|
|
8
|
+
}
|
|
9
|
+
interface AudioOptions extends PcmBrowserAudioOptions {
|
|
10
|
+
inputSampleRate: number;
|
|
11
|
+
outputSampleRate: number;
|
|
12
|
+
onInput: (bytes: Uint8Array, rms: number) => void;
|
|
13
|
+
onOutputVolume: (rms: number) => void;
|
|
14
|
+
onPlayback: (playing: boolean) => void;
|
|
15
|
+
onError: (error: unknown) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface PcmBrowserAudio {
|
|
18
|
+
open(): Promise<void>;
|
|
19
|
+
play(bytes: Uint8Array): void;
|
|
20
|
+
clear(): void;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
readonly hasOutput: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function pcmRms(samples: Float32Array): number;
|
|
25
|
+
/** Streaming weighted resampling retains fractional frames across worklet chunks. */
|
|
26
|
+
export declare function createPcm16Encoder(sourceRate: number, targetRate: number): (samples: Float32Array) => Uint8Array<ArrayBuffer>;
|
|
27
|
+
export declare function decodePcm16(bytes: Uint8Array): Float32Array<ArrayBuffer>;
|
|
28
|
+
export declare function encodeBase64(bytes: Uint8Array): string;
|
|
29
|
+
export declare function decodeBase64(data: string): Uint8Array<ArrayBuffer>;
|
|
30
|
+
/** Create/resume synchronously in the user's gesture, before any credential fetch. */
|
|
31
|
+
export declare function createPcmBrowserAudio(options: AudioOptions): PcmBrowserAudio;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { OrbAdapter } from '../types.js';
|
|
2
|
+
import { VolumeCalibrationSource } from '../audio-level.js';
|
|
3
|
+
import { PcmBrowserAudioOptions } from './browser-audio.js';
|
|
4
|
+
export type { PcmBrowserAudioOptions } from './browser-audio.js';
|
|
5
|
+
/** Structural view of the SDK's deserialized server messages. */
|
|
6
|
+
export interface AzureVoiceLiveServerEvent {
|
|
7
|
+
type: string;
|
|
8
|
+
delta?: unknown;
|
|
9
|
+
responseId?: string;
|
|
10
|
+
response?: {
|
|
11
|
+
id?: string;
|
|
12
|
+
status?: string;
|
|
13
|
+
};
|
|
14
|
+
transcript?: string;
|
|
15
|
+
error?: {
|
|
16
|
+
message?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface AzureVoiceLiveHandlers {
|
|
20
|
+
onServerEvent?: (event: AzureVoiceLiveServerEvent) => Promise<void>;
|
|
21
|
+
onError?: (args: {
|
|
22
|
+
error: Error;
|
|
23
|
+
}) => Promise<void>;
|
|
24
|
+
onDisconnected?: (args: {
|
|
25
|
+
code: number;
|
|
26
|
+
reason: string;
|
|
27
|
+
}) => Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
/** Compatible with @azure/ai-voicelive 1.1.0, without importing the SDK at runtime. */
|
|
30
|
+
export interface AzureVoiceLiveSession {
|
|
31
|
+
subscribe(handlers: AzureVoiceLiveHandlers): {
|
|
32
|
+
close(): Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
connect(options?: {
|
|
35
|
+
abortSignal?: AbortSignal;
|
|
36
|
+
timeoutInMs?: number;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
updateSession(options: {
|
|
39
|
+
inputAudioFormat?: 'pcm16';
|
|
40
|
+
inputAudioSamplingRate?: number;
|
|
41
|
+
outputAudioFormat?: 'pcm16';
|
|
42
|
+
turnDetection?: {
|
|
43
|
+
type: 'server_vad';
|
|
44
|
+
threshold: number;
|
|
45
|
+
prefixPaddingInMs: number;
|
|
46
|
+
silenceDurationInMs: number;
|
|
47
|
+
};
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
sendAudio(bytes: Uint8Array): Promise<void>;
|
|
50
|
+
dispose(): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export interface AzureVoiceLiveAdapterConfig<Session extends AzureVoiceLiveSession = AzureVoiceLiveSession> extends PcmBrowserAudioOptions {
|
|
53
|
+
/** Return a fresh, unconnected SDK session. Resolve credentials on your own backend. */
|
|
54
|
+
createSession(signal: AbortSignal): Session | Promise<Session>;
|
|
55
|
+
/** Configure model instructions, voice and tools using the concrete SDK session type. */
|
|
56
|
+
configureSession?: (session: Session, signal: AbortSignal) => Promise<void>;
|
|
57
|
+
onEvent?: (event: AzureVoiceLiveServerEvent) => void;
|
|
58
|
+
startTimeoutMs?: number;
|
|
59
|
+
inputVolumeCalibration?: VolumeCalibrationSource;
|
|
60
|
+
outputVolumeCalibration?: VolumeCalibrationSource;
|
|
61
|
+
}
|
|
62
|
+
export interface AzureVoiceLiveOrbAdapter extends OrbAdapter {
|
|
63
|
+
start(): Promise<void>;
|
|
64
|
+
stop(): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
/** SDK/session + mono PCM16 browser audio. Azure bills the application's own resource. */
|
|
67
|
+
export declare function createAzureVoiceLiveAdapter<Session extends AzureVoiceLiveSession>(config: AzureVoiceLiveAdapterConfig<Session>): AzureVoiceLiveOrbAdapter;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { OrbAdapter } from '../types.js';
|
|
2
|
+
import { VolumeCalibrationSource } from '../audio-level.js';
|
|
3
|
+
import { PcmBrowserAudioOptions } from '../azure-voice-live/browser-audio.js';
|
|
4
|
+
export type CartesiaAgentAudioFormat = 'pcm_16000' | 'pcm_24000' | 'pcm_44100';
|
|
5
|
+
/** Managed Agent protocol 2026-08-14. Preserve conversation/tool events for application UI. */
|
|
6
|
+
export interface CartesiaAgentEvent {
|
|
7
|
+
type: string;
|
|
8
|
+
audio?: string | {
|
|
9
|
+
input_format: string;
|
|
10
|
+
output_delivery: string;
|
|
11
|
+
};
|
|
12
|
+
call_id?: string;
|
|
13
|
+
agent_id?: string;
|
|
14
|
+
agent_version_id?: string;
|
|
15
|
+
role?: 'user' | 'assistant';
|
|
16
|
+
turn?: number;
|
|
17
|
+
text?: string;
|
|
18
|
+
interrupted?: boolean;
|
|
19
|
+
tool_call_id?: string;
|
|
20
|
+
tool_name?: string;
|
|
21
|
+
parameters?: Record<string, unknown>;
|
|
22
|
+
expects_response?: boolean;
|
|
23
|
+
fatal?: boolean;
|
|
24
|
+
code?: string;
|
|
25
|
+
message?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface CartesiaAdapterConfig extends PcmBrowserAudioOptions {
|
|
28
|
+
agentId: string;
|
|
29
|
+
/** Fetch a fresh short-lived agent access token from your own backend on every start. */
|
|
30
|
+
getAccessToken(signal: AbortSignal): Promise<string>;
|
|
31
|
+
inputFormat?: CartesiaAgentAudioFormat;
|
|
32
|
+
/** speaking_pace works with agent background audio. as_available requires your own buffer. */
|
|
33
|
+
outputDelivery?: 'speaking_pace' | 'as_available';
|
|
34
|
+
apiVersion?: string;
|
|
35
|
+
startTimeoutMs?: number;
|
|
36
|
+
createWebSocket?: (url: string) => WebSocket;
|
|
37
|
+
onEvent?: (event: CartesiaAgentEvent) => void;
|
|
38
|
+
/** Recoverable protocol errors keep the connection alive and are delivered here. */
|
|
39
|
+
onRecoverableError?: (event: CartesiaAgentEvent) => void;
|
|
40
|
+
inputVolumeCalibration?: VolumeCalibrationSource;
|
|
41
|
+
outputVolumeCalibration?: VolumeCalibrationSource;
|
|
42
|
+
}
|
|
43
|
+
export interface CartesiaOrbAdapter extends OrbAdapter {
|
|
44
|
+
start(): Promise<void>;
|
|
45
|
+
stop(): Promise<void>;
|
|
46
|
+
readonly callId: string | undefined;
|
|
47
|
+
sendToolResult(toolCallId: string, result: string, isError?: boolean): void;
|
|
48
|
+
}
|
|
49
|
+
/** Managed Agents voice conversation over a native browser socket, with local PCM audio. */
|
|
50
|
+
export declare function createCartesiaAdapter(config: CartesiaAdapterConfig): CartesiaOrbAdapter;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { OrbAdapter } from '../types.js';
|
|
2
|
+
import { VolumeCalibrationSource } from '../audio-level.js';
|
|
3
|
+
export type DeepgramConnectionState = 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'disconnected';
|
|
4
|
+
type SessionEvent = 'connecting' | 'connected' | 'reconnecting' | 'disconnected' | 'settings-applied' | 'user-started-speaking' | 'agent-thinking' | 'agent-started-speaking' | 'agent-audio-done' | 'error' | 'sdk-error';
|
|
5
|
+
/** Structural surface of @deepgram/agents; the application installs its own SDK. */
|
|
6
|
+
export interface DeepgramSessionLike {
|
|
7
|
+
readonly state: DeepgramConnectionState;
|
|
8
|
+
on(event: SessionEvent, listener: (value?: unknown) => void): unknown;
|
|
9
|
+
on(event: 'audio', listener: (chunk: ArrayBuffer) => void): unknown;
|
|
10
|
+
off(event: SessionEvent, listener: (value?: unknown) => void): unknown;
|
|
11
|
+
off(event: 'audio', listener: (chunk: ArrayBuffer) => void): unknown;
|
|
12
|
+
connect(): Promise<void>;
|
|
13
|
+
disconnect(): void;
|
|
14
|
+
sendAudio(data: ArrayBuffer): void;
|
|
15
|
+
}
|
|
16
|
+
export interface DeepgramMicrophoneLike {
|
|
17
|
+
start(): Promise<void>;
|
|
18
|
+
stop(): void;
|
|
19
|
+
readonly muted: boolean;
|
|
20
|
+
getInputVolume(): number;
|
|
21
|
+
on(event: 'error', listener: (error: Error) => void): unknown;
|
|
22
|
+
off(event: 'error', listener: (error: Error) => void): unknown;
|
|
23
|
+
}
|
|
24
|
+
export interface DeepgramPlayerLike {
|
|
25
|
+
queue(chunk: ArrayBuffer): void;
|
|
26
|
+
interrupt(): void;
|
|
27
|
+
dispose(): void;
|
|
28
|
+
readonly muted: boolean;
|
|
29
|
+
getRemainingPlaybackTime(): number;
|
|
30
|
+
getOutputVolume(): number;
|
|
31
|
+
}
|
|
32
|
+
export interface DeepgramResources {
|
|
33
|
+
session: DeepgramSessionLike;
|
|
34
|
+
microphone: DeepgramMicrophoneLike;
|
|
35
|
+
player: DeepgramPlayerLike;
|
|
36
|
+
}
|
|
37
|
+
export interface DeepgramAdapterOptions {
|
|
38
|
+
/** Create fresh SDK audio resources per start. Never reuse a disposed player. */
|
|
39
|
+
createResources(): DeepgramResources;
|
|
40
|
+
/** Startup deadline includes permission and SettingsApplied. Default: 30 seconds. */
|
|
41
|
+
startTimeoutMs?: number;
|
|
42
|
+
inputVolumeCalibration?: VolumeCalibrationSource;
|
|
43
|
+
outputVolumeCalibration?: VolumeCalibrationSource;
|
|
44
|
+
}
|
|
45
|
+
export interface DeepgramOrbAdapter extends OrbAdapter {
|
|
46
|
+
start(): Promise<void>;
|
|
47
|
+
stop(): void;
|
|
48
|
+
}
|
|
49
|
+
/** Owns the injected SDK resources, not a second microphone or playback engine. */
|
|
50
|
+
export declare function createDeepgramAdapter(options: DeepgramAdapterOptions): DeepgramOrbAdapter;
|
|
51
|
+
export interface DeepgramReactSnapshot {
|
|
52
|
+
state: DeepgramConnectionState;
|
|
53
|
+
mode: 'idle' | 'listening' | 'thinking' | 'speaking';
|
|
54
|
+
micActive: boolean;
|
|
55
|
+
micMuted: boolean;
|
|
56
|
+
outputMuted: boolean;
|
|
57
|
+
getInputVolume(): number;
|
|
58
|
+
getOutputVolume(): number;
|
|
59
|
+
error?: unknown;
|
|
60
|
+
}
|
|
61
|
+
export interface DeepgramReactAdapterOptions {
|
|
62
|
+
/** Read the latest useAgentContext() value through a React ref. */
|
|
63
|
+
getSnapshot(): DeepgramReactSnapshot;
|
|
64
|
+
start(): Promise<void>;
|
|
65
|
+
stop(): void;
|
|
66
|
+
}
|
|
67
|
+
/** Observe an existing AgentProvider. Deepgram retains capture/playback ownership. */
|
|
68
|
+
export declare function createDeepgramReactAdapter(options: DeepgramReactAdapterOptions): DeepgramOrbAdapter;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { OrbAdapter, OrbSignal } from '../types.js';
|
|
2
|
+
/** Structural subset of @humeai/voice-react's existing useVoice() context. */
|
|
3
|
+
export interface HumeVoiceSnapshot {
|
|
4
|
+
status: {
|
|
5
|
+
value: 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
6
|
+
reason?: string;
|
|
7
|
+
};
|
|
8
|
+
isPlaying: boolean;
|
|
9
|
+
error?: unknown;
|
|
10
|
+
isMuted?: boolean;
|
|
11
|
+
isAudioMuted?: boolean;
|
|
12
|
+
/** App-owned generation/tool state; EVI transcripts are not playback boundaries. */
|
|
13
|
+
isThinking?: boolean;
|
|
14
|
+
/** Values from useMicFft()/usePlayerFft(): SDK Bark bands in the range 0–2. */
|
|
15
|
+
micFft?: readonly number[];
|
|
16
|
+
playerFft?: readonly number[];
|
|
17
|
+
}
|
|
18
|
+
/** Visual activity from Hume's 0–2 Bark bands, not PCM RMS or loudness. */
|
|
19
|
+
export declare function humeFftToVolume(bands: readonly number[] | undefined): number;
|
|
20
|
+
/** Controlled React bridge: the existing VoiceProvider keeps all audio ownership. */
|
|
21
|
+
export declare function humeVoiceToOrbSignal(snapshot: HumeVoiceSnapshot): OrbSignal;
|
|
22
|
+
export interface HumeMessage {
|
|
23
|
+
type: string;
|
|
24
|
+
interim?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** One connection's guarded observation callbacks. Replace on every reconnect. */
|
|
27
|
+
export interface HumeSessionBridge {
|
|
28
|
+
observe(snapshot: HumeVoiceSnapshot): void;
|
|
29
|
+
onMessage(message: HumeMessage): void;
|
|
30
|
+
onInterruption(): void;
|
|
31
|
+
onError(error: unknown): void;
|
|
32
|
+
close(): void;
|
|
33
|
+
}
|
|
34
|
+
export interface HumeAdapterOptions {
|
|
35
|
+
/** Optional app lifecycle. Use the existing useVoice().connect(), never another client. */
|
|
36
|
+
connect?: (session: HumeSessionBridge, signal: AbortSignal) => void | Promise<void>;
|
|
37
|
+
disconnect?: () => void | Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export interface HumeOrbAdapter extends OrbAdapter {
|
|
40
|
+
/** Bind observations/callbacks to a fresh connection; old callbacks become inert. */
|
|
41
|
+
createSession(): HumeSessionBridge;
|
|
42
|
+
stop(): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Session-scoped observer for an app-owned Hume VoiceProvider. It captures no
|
|
46
|
+
* microphone, creates no audio player, and opens no provider connection itself.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createHumeAdapter(options?: HumeAdapterOptions): HumeOrbAdapter;
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -8,3 +8,10 @@ export { createGeminiLiveAdapter, type GeminiLiveAdapterConfig, type GeminiLiveC
|
|
|
8
8
|
export { DEFAULT_VOLUME_CALIBRATION, calibrateVolume, createVolumeNormalizer, fitVolumeCalibration, mapVolumeAmplitude, type VolumeAmplitudeCalibration, type VolumeCalibration, type VolumeCalibrationCapture, type VolumeCalibrationFit, type VolumeCalibrationMetrics, type VolumeCalibrationOverrides, type VolumeCalibrationSource, type VolumeEnvelopeCalibration, type VolumeNormalizer, type VolumeSample, } from './audio-level.js';
|
|
9
9
|
export { PROVIDER_VOLUME_CALIBRATIONS, type DirectionalVolumeCalibration } from './volume-presets.js';
|
|
10
10
|
export type { OrbAdapter, OrbSignal, OrbSignalListener, OrbState } from './types.js';
|
|
11
|
+
export * from './retell/index.js';
|
|
12
|
+
export * from './hume/index.js';
|
|
13
|
+
export * from './deepgram/index.js';
|
|
14
|
+
export * from './agora/index.js';
|
|
15
|
+
export * from './azure-voice-live/index.js';
|
|
16
|
+
export * from './cartesia/index.js';
|
|
17
|
+
export * from './nova-sonic/index.js';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { OrbAdapter } from '../types.js';
|
|
2
|
+
/** The relevant JSON inside a Bedrock bidirectional response chunk (not the AWS envelope). */
|
|
3
|
+
export interface NovaSonicEvent {
|
|
4
|
+
contentStart?: {
|
|
5
|
+
contentId: string;
|
|
6
|
+
type: 'TEXT' | 'AUDIO' | 'TOOL';
|
|
7
|
+
role: 'USER' | 'ASSISTANT' | 'TOOL';
|
|
8
|
+
additionalModelFields?: string;
|
|
9
|
+
audioOutputConfiguration?: {
|
|
10
|
+
sampleRateHertz?: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
textOutput?: {
|
|
14
|
+
contentId: string;
|
|
15
|
+
content: string;
|
|
16
|
+
};
|
|
17
|
+
audioOutput?: {
|
|
18
|
+
contentId: string;
|
|
19
|
+
content: string;
|
|
20
|
+
};
|
|
21
|
+
contentEnd?: {
|
|
22
|
+
contentId: string;
|
|
23
|
+
type?: string;
|
|
24
|
+
stopReason?: string;
|
|
25
|
+
};
|
|
26
|
+
completionStart?: {
|
|
27
|
+
completionId?: string;
|
|
28
|
+
};
|
|
29
|
+
completionEnd?: {
|
|
30
|
+
stopReason?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface NovaSonicTranscript {
|
|
34
|
+
contentId: string;
|
|
35
|
+
role: 'USER' | 'ASSISTANT';
|
|
36
|
+
text: string;
|
|
37
|
+
final: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface NovaSonicBridgeOptions {
|
|
40
|
+
/** The app must stop current playback and discard queued audio synchronously. */
|
|
41
|
+
onInterrupt?: () => void;
|
|
42
|
+
/** Only FINAL transcription blocks are reported; speculative model text is not spoken text. */
|
|
43
|
+
onTranscript?: (transcript: NovaSonicTranscript) => void;
|
|
44
|
+
}
|
|
45
|
+
export interface NovaSonicBridge extends OrbAdapter {
|
|
46
|
+
/** An app-generated session ID fences late socket messages from a previous connection. */
|
|
47
|
+
beginSession(sessionId: string): void;
|
|
48
|
+
connected(sessionId: string): void;
|
|
49
|
+
handleEvent(sessionId: string, event: NovaSonicEvent): void;
|
|
50
|
+
setInputVolume(sessionId: string, volume: number): void;
|
|
51
|
+
/** Call from the actual player, including when the final buffered chunk finishes. */
|
|
52
|
+
setPlayback(sessionId: string, active: boolean, volume?: number): void;
|
|
53
|
+
failed(sessionId: string, error: unknown): void;
|
|
54
|
+
endSession(sessionId: string): void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Observes an app-owned Node/Socket.IO-to-Bedrock session. This bridge never owns
|
|
58
|
+
* credentials, a microphone, a socket, or playback; Nova 2 Sonic needs a server.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createNovaSonicBridge(options?: NovaSonicBridgeOptions): NovaSonicBridge;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { OrbAdapter } from '../types.js';
|
|
2
|
+
import { VolumeCalibrationSource, VolumeSample } from '../audio-level.js';
|
|
3
|
+
/** The public session statuses in retell-client-js-sdk 3.0.2. */
|
|
4
|
+
export type RetellSessionStatus = 'connecting' | 'live' | 'monitoring' | 'listening' | 'taken_over' | 'ended';
|
|
5
|
+
/** Hooks documented by the current Retell browser web-call guide. */
|
|
6
|
+
export interface RetellSessionHooks {
|
|
7
|
+
onStatus?: (status: RetellSessionStatus) => void;
|
|
8
|
+
onAudio?: (samples: Float32Array) => void;
|
|
9
|
+
onEnd?: (event: {
|
|
10
|
+
disconnection_reason?: string;
|
|
11
|
+
}) => void;
|
|
12
|
+
onError?: (error: Error) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface RetellWebCallOptions {
|
|
15
|
+
agent_id: string;
|
|
16
|
+
agent_version?: number;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
retell_llm_dynamic_variables?: Record<string, unknown>;
|
|
19
|
+
agent_override?: unknown;
|
|
20
|
+
tool_mocks?: unknown;
|
|
21
|
+
current_node_id?: string;
|
|
22
|
+
current_state?: string;
|
|
23
|
+
recaptchaToken?: string;
|
|
24
|
+
extra?: Record<string, unknown>;
|
|
25
|
+
transcript?: boolean;
|
|
26
|
+
audio?: {
|
|
27
|
+
sampleRate?: number;
|
|
28
|
+
captureDeviceId?: string;
|
|
29
|
+
playbackDeviceId?: string;
|
|
30
|
+
emitRawAudioSamples?: boolean;
|
|
31
|
+
};
|
|
32
|
+
hooks?: RetellSessionHooks;
|
|
33
|
+
}
|
|
34
|
+
export interface RetellWebCallSession {
|
|
35
|
+
status: RetellSessionStatus;
|
|
36
|
+
/** Resolves after the SDK connects audio; rejects on creation/audio failure. */
|
|
37
|
+
ready: Promise<void>;
|
|
38
|
+
end(): Promise<void>;
|
|
39
|
+
startAudioPlayback(): Promise<void>;
|
|
40
|
+
/** Current SDK analyzer exposes the actual browser audio-context state. */
|
|
41
|
+
analyzerComponent?: {
|
|
42
|
+
analyser: {
|
|
43
|
+
context: {
|
|
44
|
+
state: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Injectable SDK contract; orb-ui never imports or bundles the Retell SDK. */
|
|
50
|
+
export interface RetellClientLike {
|
|
51
|
+
createWebCall(options: RetellWebCallOptions): RetellWebCallSession;
|
|
52
|
+
}
|
|
53
|
+
export interface RetellAdapterOptions {
|
|
54
|
+
/** Resolve fresh call options on every start, including any reCAPTCHA token. */
|
|
55
|
+
getCallOptions(signal: AbortSignal): RetellWebCallOptions | Promise<RetellWebCallOptions>;
|
|
56
|
+
/** Overrides for output PCM RMS. No live provider calibration is claimed. */
|
|
57
|
+
outputVolumeCalibration?: VolumeCalibrationSource;
|
|
58
|
+
onOutputVolumeSample?: (sample: VolumeSample) => void;
|
|
59
|
+
/** PCM RMS activity threshold; incoming background sound can also cross it. Default 0.01. */
|
|
60
|
+
outputActivityThreshold?: number;
|
|
61
|
+
/** Speaking estimate expires after this many ms without active output. Default 180. */
|
|
62
|
+
outputActivityHoldMs?: number;
|
|
63
|
+
/** Override the SDK audio-context gate, e.g. when your app mutes output. */
|
|
64
|
+
isAudioPlaybackActive?: (session: RetellWebCallSession) => boolean;
|
|
65
|
+
/** End an adapter-owned call when its final subscriber leaves. Defaults to true. */
|
|
66
|
+
stopOnUnsubscribe?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export type RetellTurnObserver = (state: 'thinking' | 'listening' | 'interrupted') => void;
|
|
69
|
+
export interface RetellOrbAdapter extends OrbAdapter {
|
|
70
|
+
start(): Promise<void>;
|
|
71
|
+
stop(): Promise<void>;
|
|
72
|
+
/** Invoke from a user gesture when the browser blocks SDK audio playback. */
|
|
73
|
+
resumeAudio(): Promise<void>;
|
|
74
|
+
/** Get a session-scoped observer for explicit app-owned turn submission/interruption. */
|
|
75
|
+
getTurnObserver(): RetellTurnObserver;
|
|
76
|
+
}
|
|
77
|
+
/** Creates an adapter for one current Retell browser WebCall at a time. */
|
|
78
|
+
export declare function createRetellAdapter(client: RetellClientLike, options: RetellAdapterOptions): RetellOrbAdapter;
|