orb-ui 0.3.0 → 0.4.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 +111 -8
- package/dist/adapters/audio-level.d.ts +23 -0
- package/dist/adapters/gemini-live/index.d.ts +70 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/openai-realtime/index.d.ts +37 -0
- package/dist/adapters/pipecat/index.d.ts +46 -0
- package/dist/adapters.cjs +1 -1
- package/dist/adapters.js +566 -1
- package/package.json +13 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# orb-ui
|
|
2
2
|
|
|
3
|
-
React voice agent UI components for Vapi, ElevenLabs, LiveKit, and custom realtime voice AI apps. orb-ui gives you animated voice orbs, audio-reactive themes, accessible clickable controls, and provider adapters for building polished voice agent interfaces in React.
|
|
3
|
+
React voice agent UI components for Vapi, ElevenLabs, LiveKit, Pipecat, OpenAI Realtime, Gemini Live, and custom realtime voice AI apps. orb-ui gives you animated voice orbs, audio-reactive themes, accessible clickable controls, and provider adapters for building polished voice agent interfaces in React.
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<a href="https://orb-ui.com">
|
|
@@ -44,13 +44,46 @@ npm install orb-ui @elevenlabs/client
|
|
|
44
44
|
|
|
45
45
|
# LiveKit Agents
|
|
46
46
|
npm install orb-ui livekit-client
|
|
47
|
+
|
|
48
|
+
# Pipecat (choose the transport used by your agent)
|
|
49
|
+
npm install orb-ui @pipecat-ai/client-js @pipecat-ai/small-webrtc-transport
|
|
50
|
+
|
|
51
|
+
# OpenAI Realtime uses browser WebRTC and has no additional client SDK
|
|
52
|
+
npm install orb-ui
|
|
53
|
+
|
|
54
|
+
# Gemini Live
|
|
55
|
+
npm install orb-ui @google/genai
|
|
47
56
|
```
|
|
48
57
|
|
|
49
58
|
> **Note:** Orb uses React hooks internally — in Next.js App Router, use it in a `'use client'` component.
|
|
50
59
|
|
|
60
|
+
## How provider adapters are created
|
|
61
|
+
|
|
62
|
+
Every provider ends at the same React API:
|
|
63
|
+
|
|
64
|
+
```jsx
|
|
65
|
+
<Orb adapter={adapter} theme="circle" aria-label="Start voice assistant" />
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The only difference is how the adapter obtains a provider session:
|
|
69
|
+
|
|
70
|
+
| Provider | Required browser setup |
|
|
71
|
+
| --------------- | ------------------------------------------------------------------------ |
|
|
72
|
+
| Vapi | Pass a configured Vapi client plus `assistantId` |
|
|
73
|
+
| ElevenLabs | Pass `Conversation` plus an `agentId`, signed URL, or conversation token |
|
|
74
|
+
| LiveKit | Pass LiveKit runtime helpers plus a token source or endpoint |
|
|
75
|
+
| Pipecat | Pass a configured `PipecatClient` plus its connect callback |
|
|
76
|
+
| OpenAI Realtime | Return a fresh short-lived client secret from `getClientSecret` |
|
|
77
|
+
| Gemini Live | Open the official Google Live session in `connect` |
|
|
78
|
+
|
|
79
|
+
The adapter owns provider event mapping and emits one consistent `OrbSignal`. OpenAI and Gemini
|
|
80
|
+
standard API keys, and LiveKit participant-token signing, stay on your server. See the
|
|
81
|
+
[adapter overview](https://orb-ui.com/docs/adapters/overview) for the responsibility boundary and
|
|
82
|
+
advanced setup shapes.
|
|
83
|
+
|
|
51
84
|
## Quick Start
|
|
52
85
|
|
|
53
|
-
Use orb-ui as a React voice AI component when you need a
|
|
86
|
+
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.
|
|
54
87
|
|
|
55
88
|
### With Vapi
|
|
56
89
|
|
|
@@ -106,6 +139,73 @@ function App() {
|
|
|
106
139
|
The LiveKit adapter meters the local microphone while listening and the remote agent audio while
|
|
107
140
|
speaking, so every audio-reactive theme follows the active side of the conversation.
|
|
108
141
|
|
|
142
|
+
### With Pipecat
|
|
143
|
+
|
|
144
|
+
```jsx
|
|
145
|
+
import { PipecatClient } from '@pipecat-ai/client-js'
|
|
146
|
+
import { SmallWebRTCTransport } from '@pipecat-ai/small-webrtc-transport'
|
|
147
|
+
import { Orb } from 'orb-ui'
|
|
148
|
+
import { createPipecatAdapter } from 'orb-ui/adapters'
|
|
149
|
+
|
|
150
|
+
const client = new PipecatClient({ transport: new SmallWebRTCTransport(), enableMic: true })
|
|
151
|
+
const adapter = createPipecatAdapter(client, {
|
|
152
|
+
connect: () => client.connect({ webrtcUrl: 'https://agent.example.com/api/offer' }),
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
function App() {
|
|
156
|
+
return <Orb adapter={adapter} theme="circle" aria-label="Start Pipecat assistant" />
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The Pipecat adapter consumes the standard RTVI event surface, so it also works with Pipecat Cloud,
|
|
161
|
+
Daily, and other Pipecat transports. See the [Pipecat guide](https://orb-ui.com/docs/adapters/pipecat).
|
|
162
|
+
|
|
163
|
+
### With OpenAI Realtime
|
|
164
|
+
|
|
165
|
+
```jsx
|
|
166
|
+
import { Orb } from 'orb-ui'
|
|
167
|
+
import { createOpenAIRealtimeAdapter } from 'orb-ui/adapters'
|
|
168
|
+
|
|
169
|
+
const adapter = createOpenAIRealtimeAdapter({
|
|
170
|
+
getClientSecret: async () => {
|
|
171
|
+
const response = await fetch('/api/openai-realtime-token', { method: 'POST' })
|
|
172
|
+
return (await response.json()).value
|
|
173
|
+
},
|
|
174
|
+
})
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Create client secrets with a standard OpenAI API key on your server. See the
|
|
178
|
+
[OpenAI Realtime guide](https://orb-ui.com/docs/adapters/openai-realtime).
|
|
179
|
+
|
|
180
|
+
### With Gemini Live
|
|
181
|
+
|
|
182
|
+
```jsx
|
|
183
|
+
import { GoogleGenAI } from '@google/genai'
|
|
184
|
+
import { Orb } from 'orb-ui'
|
|
185
|
+
import { createGeminiLiveAdapter } from 'orb-ui/adapters'
|
|
186
|
+
|
|
187
|
+
const adapter = createGeminiLiveAdapter({
|
|
188
|
+
connect: async (callbacks) => {
|
|
189
|
+
const token = await fetch('/api/gemini-live-token', { method: 'POST' }).then((res) =>
|
|
190
|
+
res.json(),
|
|
191
|
+
)
|
|
192
|
+
const client = new GoogleGenAI({
|
|
193
|
+
apiKey: token.value,
|
|
194
|
+
httpOptions: { apiVersion: 'v1alpha' },
|
|
195
|
+
})
|
|
196
|
+
return client.live.connect({ model: token.model, config: token.config, callbacks })
|
|
197
|
+
},
|
|
198
|
+
})
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Mint one-use Gemini Live tokens on your server. See the
|
|
202
|
+
[Gemini Live guide](https://orb-ui.com/docs/adapters/gemini-live) for the matching server config that
|
|
203
|
+
disables automatic activity detection. The adapter handles client-side turn detection by default.
|
|
204
|
+
|
|
205
|
+
The examples above show the intended happy paths. Transport overrides, custom browser runtimes,
|
|
206
|
+
existing-session modes, and audio calibration hooks are optional and documented in the individual
|
|
207
|
+
adapter guides.
|
|
208
|
+
|
|
109
209
|
### Controlled mode (custom integration)
|
|
110
210
|
|
|
111
211
|
```jsx
|
|
@@ -163,12 +263,15 @@ When an adapter or `onStart`/`onStop` handler is provided, `circle` and `bars` r
|
|
|
163
263
|
|
|
164
264
|
## Supported Providers
|
|
165
265
|
|
|
166
|
-
| Provider
|
|
167
|
-
|
|
|
168
|
-
| [Vapi](https://vapi.ai)
|
|
169
|
-
| [ElevenLabs](https://elevenlabs.io/conversational-ai)
|
|
170
|
-
| [LiveKit](https://livekit.io)
|
|
171
|
-
|
|
|
266
|
+
| Provider | Adapter |
|
|
267
|
+
| ------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
268
|
+
| [Vapi](https://vapi.ai) | `createVapiAdapter` from `orb-ui/adapters` |
|
|
269
|
+
| [ElevenLabs](https://elevenlabs.io/conversational-ai) | `createElevenLabsAdapter` from `orb-ui/adapters` |
|
|
270
|
+
| [LiveKit](https://livekit.io) | `createLiveKitAdapter` from `orb-ui/adapters` |
|
|
271
|
+
| [Pipecat](https://pipecat.ai) | `createPipecatAdapter` from `orb-ui/adapters` |
|
|
272
|
+
| [OpenAI Realtime](https://developers.openai.com/api/docs/guides/realtime) | `createOpenAIRealtimeAdapter` from `orb-ui/adapters` |
|
|
273
|
+
| [Gemini Live](https://ai.google.dev/gemini-api/docs/live-api) | `createGeminiLiveAdapter` from `orb-ui/adapters` |
|
|
274
|
+
| Custom | Use controlled mode — pass `signal`, or `state` and `volume` directly |
|
|
172
275
|
|
|
173
276
|
## Development
|
|
174
277
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface OutputVolumeCalibration {
|
|
2
|
+
/** Raw RMS values at or below this level are treated as silence. */
|
|
3
|
+
noiseFloor: number;
|
|
4
|
+
/** Multiplier applied after the noise floor. */
|
|
5
|
+
gain: number;
|
|
6
|
+
/** Power curve applied after gain. Values below 1 lift quieter speech. */
|
|
7
|
+
exponent: number;
|
|
8
|
+
/** EMA rate used while the volume is rising. */
|
|
9
|
+
attack: number;
|
|
10
|
+
/** EMA rate used while the volume is falling. */
|
|
11
|
+
release: number;
|
|
12
|
+
}
|
|
13
|
+
export type OutputVolumeCalibrationSource = Partial<OutputVolumeCalibration> | (() => Partial<OutputVolumeCalibration>);
|
|
14
|
+
export interface OutputVolumeSample {
|
|
15
|
+
/** Unmodified RMS value measured from the provider audio stream. */
|
|
16
|
+
raw: number;
|
|
17
|
+
/** Value after noise floor, gain, and power-curve shaping. */
|
|
18
|
+
shaped: number;
|
|
19
|
+
/** Final value after attack/release smoothing. */
|
|
20
|
+
normalized: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const DEFAULT_OUTPUT_VOLUME_CALIBRATION: OutputVolumeCalibration;
|
|
23
|
+
export declare function calibrateOutputVolume(rawValue: number, previous: number, source?: OutputVolumeCalibrationSource): OutputVolumeSample;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { OrbAdapter } from '../types.js';
|
|
2
|
+
import { OutputVolumeCalibrationSource, OutputVolumeSample } from '../audio-level.js';
|
|
3
|
+
export interface GeminiLiveInlineData {
|
|
4
|
+
data?: string;
|
|
5
|
+
mimeType?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface GeminiLiveServerMessage {
|
|
8
|
+
setupComplete?: unknown;
|
|
9
|
+
serverContent?: {
|
|
10
|
+
modelTurn?: {
|
|
11
|
+
parts?: Array<{
|
|
12
|
+
inlineData?: GeminiLiveInlineData;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
turnComplete?: boolean;
|
|
16
|
+
generationComplete?: boolean;
|
|
17
|
+
interrupted?: boolean;
|
|
18
|
+
waitingForInput?: boolean;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface GeminiLiveCallbacks {
|
|
22
|
+
onopen?: () => void;
|
|
23
|
+
onmessage: (message: GeminiLiveServerMessage) => void;
|
|
24
|
+
onerror?: (error: unknown) => void;
|
|
25
|
+
onclose?: (event: unknown) => void;
|
|
26
|
+
}
|
|
27
|
+
export interface GeminiLiveSession {
|
|
28
|
+
sendRealtimeInput(input: {
|
|
29
|
+
audio?: {
|
|
30
|
+
data: string;
|
|
31
|
+
mimeType: string;
|
|
32
|
+
};
|
|
33
|
+
audioStreamEnd?: boolean;
|
|
34
|
+
activityStart?: Record<string, never>;
|
|
35
|
+
activityEnd?: Record<string, never>;
|
|
36
|
+
}): void;
|
|
37
|
+
close(): void;
|
|
38
|
+
}
|
|
39
|
+
export interface GeminiLiveAdapterConfig {
|
|
40
|
+
/** Connects an official Google GenAI Live session using the supplied callbacks. */
|
|
41
|
+
connect(callbacks: GeminiLiveCallbacks): Promise<GeminiLiveSession>;
|
|
42
|
+
/** Defaults to `{ audio: true }`. */
|
|
43
|
+
mediaStreamConstraints?: MediaStreamConstraints;
|
|
44
|
+
/** Defaults to 16 kHz PCM input, as recommended by Gemini Live. */
|
|
45
|
+
inputSampleRate?: number;
|
|
46
|
+
/** Defaults to 0.04 normalized input volume. */
|
|
47
|
+
speechThreshold?: number;
|
|
48
|
+
/** Defaults to 500 ms before listening transitions to thinking. */
|
|
49
|
+
speechEndDelayMs?: number;
|
|
50
|
+
/** Defaults to client-side detection. Use `server` with Gemini automatic activity detection. */
|
|
51
|
+
activityDetection?: 'client' | 'server';
|
|
52
|
+
/** Runtime override for tests or custom browser wrappers. */
|
|
53
|
+
getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
|
|
54
|
+
/** Runtime override for tests or custom browser wrappers. */
|
|
55
|
+
createAudioContext?: () => AudioContext;
|
|
56
|
+
/** Optional live-tunable output shaping. A getter is read for every meter sample. */
|
|
57
|
+
outputVolumeCalibration?: OutputVolumeCalibrationSource;
|
|
58
|
+
/** Receives raw, shaped, and smoothed output levels for diagnostics. */
|
|
59
|
+
onOutputVolumeSample?: (sample: OutputVolumeSample) => void;
|
|
60
|
+
}
|
|
61
|
+
export interface GeminiLiveOrbAdapter extends OrbAdapter {
|
|
62
|
+
start(): Promise<void>;
|
|
63
|
+
stop(): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a managed browser-audio adapter for Gemini Live. The app owns token
|
|
67
|
+
* creation and the official GenAI client; orb-ui owns microphone streaming,
|
|
68
|
+
* PCM playback, volume metering, and normalized voice state.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createGeminiLiveAdapter(config: GeminiLiveAdapterConfig): GeminiLiveOrbAdapter;
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { createVapiAdapter } from './vapi/index.js';
|
|
2
2
|
export { createElevenLabsAdapter, type ElevenLabsCallbacks, type ElevenLabsConfig, type ElevenLabsConnectionType, type ElevenLabsConversation, type ElevenLabsConversationClass, type ElevenLabsMode, type ElevenLabsOrbAdapter, type ElevenLabsStartSessionOptions, type ElevenLabsStatus, } from './elevenlabs/index.js';
|
|
3
3
|
export { createLiveKitAdapter, type LiveKitAdapterConfig, type LiveKitConnectionDetails, type LiveKitOrbAdapter, type LiveKitResolvedTokenOptions, type LiveKitTokenOptions, type LiveKitTokenSource, } from './livekit/index.js';
|
|
4
|
+
export { createPipecatAdapter, type PipecatAdapterOptions, type PipecatClientLike, type PipecatOrbAdapter, type PipecatParticipantLike, } from './pipecat/index.js';
|
|
5
|
+
export { createOpenAIRealtimeAdapter, type OpenAIRealtimeAdapterConfig, type OpenAIRealtimeClientSecret, type OpenAIRealtimeOrbAdapter, } from './openai-realtime/index.js';
|
|
6
|
+
export { createGeminiLiveAdapter, type GeminiLiveAdapterConfig, type GeminiLiveCallbacks, type GeminiLiveInlineData, type GeminiLiveOrbAdapter, type GeminiLiveServerMessage, type GeminiLiveSession, } from './gemini-live/index.js';
|
|
7
|
+
export { DEFAULT_OUTPUT_VOLUME_CALIBRATION, type OutputVolumeCalibration, type OutputVolumeCalibrationSource, type OutputVolumeSample, } from './audio-level.js';
|
|
4
8
|
export type { AdapterCallbacks, LegacyOrbAdapter, OrbAdapter, OrbSignal, OrbSignalListener, OrbState, } from './types.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { OrbAdapter } from '../types.js';
|
|
2
|
+
import { OutputVolumeCalibrationSource, OutputVolumeSample } from '../audio-level.js';
|
|
3
|
+
export interface OpenAIRealtimeClientSecret {
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
export interface OpenAIRealtimeAdapterConfig {
|
|
7
|
+
/** Fetch a newly minted Realtime client secret for every session start. */
|
|
8
|
+
getClientSecret(): Promise<string | OpenAIRealtimeClientSecret>;
|
|
9
|
+
/** Defaults to OpenAI's GA WebRTC calls endpoint. */
|
|
10
|
+
callsUrl?: string;
|
|
11
|
+
/** Defaults to `{ audio: true }`. */
|
|
12
|
+
mediaStreamConstraints?: MediaStreamConstraints;
|
|
13
|
+
/** Runtime override for tests, React Native shims, or custom browser wrappers. */
|
|
14
|
+
getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
|
|
15
|
+
/** Runtime override for custom WebRTC implementations. */
|
|
16
|
+
createPeerConnection?: () => RTCPeerConnection;
|
|
17
|
+
/** Runtime override for custom fetch implementations. */
|
|
18
|
+
fetch?: typeof fetch;
|
|
19
|
+
/** Runtime override for custom audio element ownership. */
|
|
20
|
+
createAudioElement?: () => HTMLAudioElement;
|
|
21
|
+
/** Return undefined to disable browser-side volume metering. */
|
|
22
|
+
createAudioContext?: () => AudioContext | undefined;
|
|
23
|
+
/** Optional live-tunable output shaping. A getter is read for every meter sample. */
|
|
24
|
+
outputVolumeCalibration?: OutputVolumeCalibrationSource;
|
|
25
|
+
/** Receives raw, shaped, and smoothed output levels for diagnostics. */
|
|
26
|
+
onOutputVolumeSample?: (sample: OutputVolumeSample) => void;
|
|
27
|
+
}
|
|
28
|
+
export interface OpenAIRealtimeOrbAdapter extends OrbAdapter {
|
|
29
|
+
start(): Promise<void>;
|
|
30
|
+
stop(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a managed browser WebRTC adapter for the OpenAI Realtime API.
|
|
34
|
+
* Standard API keys stay on the app's server; the adapter only receives a
|
|
35
|
+
* short-lived client secret.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createOpenAIRealtimeAdapter(config: OpenAIRealtimeAdapterConfig): OpenAIRealtimeOrbAdapter;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { OrbAdapter } from '../types.js';
|
|
2
|
+
type PipecatListener = (...args: unknown[]) => void;
|
|
3
|
+
/** Minimal PipecatClient surface used by orb-ui. */
|
|
4
|
+
export interface PipecatClientLike {
|
|
5
|
+
on(event: string, listener: PipecatListener): unknown;
|
|
6
|
+
off?(event: string, listener: PipecatListener): unknown;
|
|
7
|
+
removeListener?(event: string, listener: PipecatListener): unknown;
|
|
8
|
+
connect(...args: unknown[]): Promise<unknown>;
|
|
9
|
+
disconnect(): void | Promise<void>;
|
|
10
|
+
state?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PipecatParticipantLike {
|
|
13
|
+
id?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
local?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface PipecatAdapterOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Starts and connects the Pipecat client. Override this for transport-specific
|
|
20
|
+
* connection params or `startBotAndConnect()` endpoints.
|
|
21
|
+
*/
|
|
22
|
+
connect?: () => void | Promise<unknown>;
|
|
23
|
+
/** Disconnects the Pipecat client. Defaults to `client.disconnect()`. */
|
|
24
|
+
disconnect?: () => void | Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Optional filter for multi-participant transports. Remote audio from local
|
|
27
|
+
* participants is ignored automatically.
|
|
28
|
+
*/
|
|
29
|
+
isBotParticipant?: (participant: PipecatParticipantLike) => boolean;
|
|
30
|
+
/** Play remote bot audio tracks automatically. Defaults to true. */
|
|
31
|
+
playRemoteAudio?: boolean;
|
|
32
|
+
/** Runtime override for custom audio element ownership. */
|
|
33
|
+
createAudioElement?: () => HTMLAudioElement;
|
|
34
|
+
}
|
|
35
|
+
export interface PipecatOrbAdapter extends OrbAdapter {
|
|
36
|
+
start(): Promise<void>;
|
|
37
|
+
stop(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates a signal-native adapter for Pipecat's JavaScript client.
|
|
41
|
+
*
|
|
42
|
+
* The adapter is transport-agnostic: Daily, SmallWebRTC, Pipecat Cloud, and
|
|
43
|
+
* custom transports all expose the same RTVI events through `PipecatClient`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createPipecatAdapter(client: PipecatClientLike, options?: PipecatAdapterOptions): PipecatOrbAdapter;
|
|
46
|
+
export {};
|
package/dist/adapters.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=.12;function t(e){let t=`idle`,n=null;function r(r){if(n&&=(clearTimeout(n),null),t===`speaking`&&r===`listening`){n=setTimeout(()=>{t=r,e(r),n=null},350);return}t=r,e(r)}function i(){n&&=(clearTimeout(n),null)}return{emitState:r,clearTimer:i}}function n(n,r){let i=new Set,a=null;function o(){a||(a=n.start.bind(n),n.start=async(...e)=>(i.forEach(e=>e()),a(...e)))}function s(){i.size>0||!a||(n.start=a,a=null)}return{async start(){await n.start(r?.assistantId)},stop(){n.stop()},subscribe(r){let a={state:`idle`,volume:0,outputVolume:0},c=0;function l(t){let n=t<e?0:(t-e)/(1-e),r=n>c?.8:.5;return c+=(n-c)*r,c}function u(e){a=e,r(e)}function d(e){u({...a,...e,state:e.state??a.state})}let{emitState:f,clearTimer:p}=t(e=>d({state:e})),m=()=>f(`connecting`),h=`idle`,g=!1,_=()=>{g=!0,h=`listening`,f(`listening`),d({volume:0,outputVolume:0})},v=()=>{g=!1,h=`idle`,E(),f(`idle`),d({volume:0,outputVolume:0}),c=0},y=()=>{g&&(h=`speaking`,f(`speaking`),d({volume:0,outputVolume:0}),T())},b=()=>{g&&(E(),h=`listening`,d({volume:0,outputVolume:0}),c=0,f(`listening`))},x=0,S=0,C=0,w=()=>{h===`speaking`&&(S+=(x-S)*.1,d({volume:S,outputVolume:S})),C=requestAnimationFrame(w)},T=()=>{C||=requestAnimationFrame(w)},E=()=>{C&&=(cancelAnimationFrame(C),0),S=0,x=0},D=e=>{if(h===`speaking`){let t=l(e);x=t/(t+.3)}},O=()=>{},k=e=>{console.error(`[orb-ui/vapi] Error:`,e),g=!1,h=`error`,p(),E(),d({state:`error`,volume:0,outputVolume:0,error:e}),c=0};return n.on(`call-start`,_),n.on(`call-end`,v),n.on(`speech-start`,y),n.on(`speech-end`,b),n.on(`volume-level`,D),n.on(`message`,O),n.on(`error`,k),i.add(m),o(),()=>{p(),E(),c=0,n.removeListener(`call-start`,_),n.removeListener(`call-end`,v),n.removeListener(`speech-start`,y),n.removeListener(`speech-end`,b),n.removeListener(`volume-level`,D),n.removeListener(`message`,O),n.removeListener(`error`,k),i.delete(m),s()}}}}function r(e,t){let n=null,r=0,i=null,a=null,o={state:`idle`,volume:0,inputVolume:0,outputVolume:0},s=`idle`,c=new Set;function l(e){o=e,c.forEach(t=>t(e))}function u(e){o={...o,...e,state:e.state??o.state},l(o)}function d(e){s=e,u({state:e})}function f(){a||=setInterval(()=>{if(n){if(s===`listening`){let e=Math.min(n.getInputVolume()*2,1);u({volume:e,inputVolume:e})}else if(s===`speaking`){let e=Math.min(n.getOutputVolume()*2,1);u({volume:e,outputVolume:e})}}},33)}function p(){a&&=(clearInterval(a),null)}function m(){p(),u({volume:0,inputVolume:0,outputVolume:0})}function h(){s=`idle`,u({state:`idle`,volume:0,inputVolume:0,outputVolume:0})}function g(e){return e===r}function _(e){return{onStatusChange:({status:t})=>{g(e)&&t===`connecting`&&d(`connecting`)},onConnect:()=>{g(e)&&(d(`listening`),f())},onModeChange:({mode:t})=>{g(e)&&(t===`speaking`?(d(`speaking`),f()):(d(`listening`),f()))},onDisconnect:()=>{g(e)&&(p(),n=null,h())},onError:t=>{g(e)&&(console.error(`[orb-ui/elevenlabs] Error:`,t),p(),s=`error`,u({state:`error`,volume:0,inputVolume:0,outputVolume:0,error:t}),n=null)}}}return{subscribe(e){return c.add(e),e(o),n&&(s===`listening`||s===`speaking`)&&f(),()=>{c.delete(e),c.size===0&&m()}},async start(){if(n||i)return i??void 0;r+=1;let a=r;return i=(async()=>{try{let r=await e.startSession({...t,..._(a)});if(!g(a)){await r.endSession().catch(e=>{console.error(`[orb-ui/elevenlabs] stale session cleanup failed:`,e)});return}n=r}catch(e){if(!g(a))return;console.error(`[orb-ui/elevenlabs] startSession failed:`,e),d(`error`),u({volume:0,inputVolume:0,outputVolume:0,error:e})}finally{i=null}})(),i},async stop(){let e=n;if(!e){i&&(r+=1,p(),h(),await i);return}let t=r;p();try{await e.endSession()}catch(e){console.error(`[orb-ui/elevenlabs] endSession failed:`,e)}n===e&&g(t)&&(n=null,h())}}}function i(e){let t=Math.min(e/.5,1);return t**=1.3,t}var a=4,o=.03,s=1.5,c=.6,l=.2,u=.35;function d(e){switch(e){case`speaking`:return`speaking`;case`thinking`:return`thinking`;case`listening`:case`idle`:return`listening`;case`connecting`:case`pre-connect-buffering`:case`initializing`:return`connecting`;case`disconnected`:return`idle`;case`failed`:return`error`;default:return`idle`}}function f(e){return`RoomClass`in e}function p(e){return typeof e==`function`?e():e}function m(e){if(!e)return{};let t={},n=(e,n)=>{n!==void 0&&(t[e]=n)};return n(`roomName`,p(e.roomName)),n(`participantName`,p(e.participantName)),n(`participantIdentity`,p(e.participantIdentity)),n(`participantMetadata`,p(e.participantMetadata)),n(`participantAttributes`,typeof e.participantAttributes==`function`?e.participantAttributes():e.participantAttributes),n(`agentName`,p(e.agentName)),n(`agentMetadata`,p(e.agentMetadata)),n(`deployment`,p(e.deployment)),t}function h(e){if(!e.serverUrl||!e.participantToken)throw Error(`[orb-ui/livekit] connection details must include serverUrl and participantToken.`);return e}async function g(e){let t=m(e.tokenOptions);return typeof e.getConnectionDetails==`function`?h(await e.getConnectionDetails(t)):e.tokenSource?h(await e.tokenSource.fetch(t)):h({serverUrl:e.serverUrl,participantToken:e.participantToken})}function _(e){for(let[,t]of e.remoteParticipants)if(!t.isLocal&&(t.kind===a||t.attributes?.[`lk.agent.state`]!==void 0))return t;return null}function v(e,t,n){let r=e.off;if(r){r.call(e,t,n);return}e.removeListener?.call(e,t,n)}function y(e,t,n){e.on.call(e,t,n)}function b(e){let t=f(e),n=e.createAudioAnalyser,r={current:t?null:e.room},p=new Set,m={state:`idle`,volume:0,inputVolume:0,outputVolume:0},h=`idle`,b=null,x=null,S=null,C=null,w=null,T=null,E=null,D=0,O=null;function k(e){m=e,p.forEach(t=>t(e))}function A(e){k({...m,...e,state:e.state??m.state})}function j(e){let t=e<o?0:e,n=t>D?c:l;D+=(t-D)*n;let r=Math.min(D*s,1);return r/(r+u)}function M(){D=0,A({volume:0,outputVolume:0})}function N({emitZero:e=!0}={}){w&&=(clearInterval(w),null),C&&=(C.cleanup().catch(()=>{}),null),e&&A({volume:0,inputVolume:0})}function P(e){if(!(b===e&&C)){N({emitZero:!1}),b=e;try{C=n(e)}catch(e){console.warn(`[orb-ui/livekit] local createAudioAnalyser failed:`,e);return}w=setInterval(()=>{if(!C||h!==`listening`)return;let e=i(C.calculateVolume());A({volume:e,inputVolume:e,outputVolume:0})},33)}}function F({emitZero:e=!0}={}){E&&=(clearInterval(E),null),T&&=(T.cleanup().catch(()=>{}),null),D=0,e&&A({volume:0,outputVolume:0})}function I(e){F();try{T=n(e)}catch(e){console.warn(`[orb-ui/livekit] remote createAudioAnalyser failed:`,e);return}E=setInterval(()=>{if(!T||h!==`speaking`)return;let e=j(T.calculateVolume());A({volume:e,inputVolume:0,outputVolume:e})},33)}function L(e){h=e,A({state:e,volume:0,inputVolume:0,outputVolume:0}),e===`speaking`&&x?I(x):e!==`speaking`&&F({emitZero:!1})}function R(e){S||typeof document>`u`||(S=e.attach(),S.id=`orb-ui-livekit-agent-audio`,document.body.appendChild(S))}function z(){S&&=(S.remove(),null)}function B(e){x=e,R(e),h===`speaking`&&I(e)}function V(e){P(e)}function H(e){let t=e.getTrackPublication?.(`microphone`);t?.track&&V(t.track)}function U(e){let t=d(e);t!==h&&L(t)}function W(e){let t=e.attributes?.[`lk.agent.state`];t&&U(t);let n=e.getTrackPublication(`microphone`);n?.track&&B(n.track)}function G(e){if(O)return;let t=(e,t)=>{if(t.isLocal)return;let n=e[`lk.agent.state`];n&&U(n)},n=(e,t,n)=>{n.isLocal||!(n.kind===a||n.attributes?.[`lk.agent.state`]!==void 0)||e.mediaStreamTrack.kind!==`audio`||B(e)},r=e=>{x===e&&(x=null,z(),F())},i=e=>{e.source!==`microphone`||!e.track||V(e.track)},o=e=>{e.source===`microphone`&&(b=null,N())},s=()=>{b=null,x=null,z(),N({emitZero:!1}),F({emitZero:!1}),L(`idle`)};if(y(e,`participantAttributesChanged`,t),y(e,`trackSubscribed`,n),y(e,`trackUnsubscribed`,r),y(e,`localTrackPublished`,i),y(e,`localTrackUnpublished`,o),y(e,`disconnected`,s),O=()=>{v(e,`participantAttributesChanged`,t),v(e,`trackSubscribed`,n),v(e,`trackUnsubscribed`,r),v(e,`localTrackPublished`,i),v(e,`localTrackUnpublished`,o),v(e,`disconnected`,s)},H(e.localParticipant),e.state===`connected`){let t=_(e);t?W(t):L(`connecting`)}else L(`idle`)}function K(){O?.(),O=null,b=null,x=null,z(),N({emitZero:!1}),F({emitZero:!1}),A({volume:0,inputVolume:0,outputVolume:0})}let q=e=>{p.add(e),e(m);let t=r.current;return t&&G(t),()=>{p.delete(e),p.size===0&&K()}};return t?{subscribe:q,async start(){if(r.current)return;let t=e,n=new t.RoomClass;L(`connecting`);try{let e=await g(t);if(await n.connect(e.serverUrl,e.participantToken,t.connectOptions),r.current=n,G(n),t.enableMicrophone!==!1){let e=(await n.localParticipant.setMicrophoneEnabled(!0))?.track??n.localParticipant.getTrackPublication?.(`microphone`)?.track;e&&V(e)}}catch(e){throw console.error(`[orb-ui/livekit] connect failed:`,e),r.current===n&&K(),n.disconnect(),r.current=null,L(`error`),M(),A({error:e}),e}},async stop(){let e=r.current;if(!e){L(`idle`);return}K(),e.disconnect(),r.current=null,L(`idle`)}}:{subscribe:q}}exports.createElevenLabsAdapter=r,exports.createLiveKitAdapter=b,exports.createVapiAdapter=n;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=.12;function t(e){let t=`idle`,n=null;function r(r){if(n&&=(clearTimeout(n),null),t===`speaking`&&r===`listening`){n=setTimeout(()=>{t=r,e(r),n=null},350);return}t=r,e(r)}function i(){n&&=(clearTimeout(n),null)}return{emitState:r,clearTimer:i}}function n(n,r){let i=new Set,a=null;function o(){a||(a=n.start.bind(n),n.start=async(...e)=>(i.forEach(e=>e()),a(...e)))}function s(){i.size>0||!a||(n.start=a,a=null)}return{async start(){await n.start(r?.assistantId)},stop(){n.stop()},subscribe(r){let a={state:`idle`,volume:0,outputVolume:0},c=0;function l(t){let n=t<e?0:(t-e)/(1-e),r=n>c?.8:.5;return c+=(n-c)*r,c}function u(e){a=e,r(e)}function d(e){u({...a,...e,state:e.state??a.state})}let{emitState:f,clearTimer:p}=t(e=>d({state:e})),m=()=>f(`connecting`),h=`idle`,g=!1,_=()=>{g=!0,h=`listening`,f(`listening`),d({volume:0,outputVolume:0})},v=()=>{g=!1,h=`idle`,E(),f(`idle`),d({volume:0,outputVolume:0}),c=0},y=()=>{g&&(h=`speaking`,f(`speaking`),d({volume:0,outputVolume:0}),T())},b=()=>{g&&(E(),h=`listening`,d({volume:0,outputVolume:0}),c=0,f(`listening`))},x=0,S=0,C=0,w=()=>{h===`speaking`&&(S+=(x-S)*.1,d({volume:S,outputVolume:S})),C=requestAnimationFrame(w)},T=()=>{C||=requestAnimationFrame(w)},E=()=>{C&&=(cancelAnimationFrame(C),0),S=0,x=0},D=e=>{if(h===`speaking`){let t=l(e);x=t/(t+.3)}},O=()=>{},k=e=>{console.error(`[orb-ui/vapi] Error:`,e),g=!1,h=`error`,p(),E(),d({state:`error`,volume:0,outputVolume:0,error:e}),c=0};return n.on(`call-start`,_),n.on(`call-end`,v),n.on(`speech-start`,y),n.on(`speech-end`,b),n.on(`volume-level`,D),n.on(`message`,O),n.on(`error`,k),i.add(m),o(),()=>{p(),E(),c=0,n.removeListener(`call-start`,_),n.removeListener(`call-end`,v),n.removeListener(`speech-start`,y),n.removeListener(`speech-end`,b),n.removeListener(`volume-level`,D),n.removeListener(`message`,O),n.removeListener(`error`,k),i.delete(m),s()}}}}function r(e,t){let n=null,r=0,i=null,a=null,o={state:`idle`,volume:0,inputVolume:0,outputVolume:0},s=`idle`,c=new Set;function l(e){o=e,c.forEach(t=>t(e))}function u(e){o={...o,...e,state:e.state??o.state},l(o)}function d(e){s=e,u({state:e})}function f(){a||=setInterval(()=>{if(n){if(s===`listening`){let e=Math.min(n.getInputVolume()*2,1);u({volume:e,inputVolume:e})}else if(s===`speaking`){let e=Math.min(n.getOutputVolume()*2,1);u({volume:e,outputVolume:e})}}},33)}function p(){a&&=(clearInterval(a),null)}function m(){p(),u({volume:0,inputVolume:0,outputVolume:0})}function h(){s=`idle`,u({state:`idle`,volume:0,inputVolume:0,outputVolume:0})}function g(e){return e===r}function _(e){return{onStatusChange:({status:t})=>{g(e)&&t===`connecting`&&d(`connecting`)},onConnect:()=>{g(e)&&(d(`listening`),f())},onModeChange:({mode:t})=>{g(e)&&(t===`speaking`?(d(`speaking`),f()):(d(`listening`),f()))},onDisconnect:()=>{g(e)&&(p(),n=null,h())},onError:t=>{g(e)&&(console.error(`[orb-ui/elevenlabs] Error:`,t),p(),s=`error`,u({state:`error`,volume:0,inputVolume:0,outputVolume:0,error:t}),n=null)}}}return{subscribe(e){return c.add(e),e(o),n&&(s===`listening`||s===`speaking`)&&f(),()=>{c.delete(e),c.size===0&&m()}},async start(){if(n||i)return i??void 0;r+=1;let a=r;return i=(async()=>{try{let r=await e.startSession({...t,..._(a)});if(!g(a)){await r.endSession().catch(e=>{console.error(`[orb-ui/elevenlabs] stale session cleanup failed:`,e)});return}n=r}catch(e){if(!g(a))return;console.error(`[orb-ui/elevenlabs] startSession failed:`,e),d(`error`),u({volume:0,inputVolume:0,outputVolume:0,error:e})}finally{i=null}})(),i},async stop(){let e=n;if(!e){i&&(r+=1,p(),h(),await i);return}let t=r;p();try{await e.endSession()}catch(e){console.error(`[orb-ui/elevenlabs] endSession failed:`,e)}n===e&&g(t)&&(n=null,h())}}}function i(e){let t=Math.min(e/.5,1);return t**=1.3,t}var a=4,o=.03,s=1.5,c=.6,l=.2,u=.35;function d(e){switch(e){case`speaking`:return`speaking`;case`thinking`:return`thinking`;case`listening`:case`idle`:return`listening`;case`connecting`:case`pre-connect-buffering`:case`initializing`:return`connecting`;case`disconnected`:return`idle`;case`failed`:return`error`;default:return`idle`}}function f(e){return`RoomClass`in e}function p(e){return typeof e==`function`?e():e}function m(e){if(!e)return{};let t={},n=(e,n)=>{n!==void 0&&(t[e]=n)};return n(`roomName`,p(e.roomName)),n(`participantName`,p(e.participantName)),n(`participantIdentity`,p(e.participantIdentity)),n(`participantMetadata`,p(e.participantMetadata)),n(`participantAttributes`,typeof e.participantAttributes==`function`?e.participantAttributes():e.participantAttributes),n(`agentName`,p(e.agentName)),n(`agentMetadata`,p(e.agentMetadata)),n(`deployment`,p(e.deployment)),t}function h(e){if(!e.serverUrl||!e.participantToken)throw Error(`[orb-ui/livekit] connection details must include serverUrl and participantToken.`);return e}async function g(e){let t=m(e.tokenOptions);return typeof e.getConnectionDetails==`function`?h(await e.getConnectionDetails(t)):e.tokenSource?h(await e.tokenSource.fetch(t)):h({serverUrl:e.serverUrl,participantToken:e.participantToken})}function _(e){for(let[,t]of e.remoteParticipants)if(!t.isLocal&&(t.kind===a||t.attributes?.[`lk.agent.state`]!==void 0))return t;return null}function v(e,t,n){let r=e.off;if(r){r.call(e,t,n);return}e.removeListener?.call(e,t,n)}function y(e,t,n){e.on.call(e,t,n)}function b(e){let t=f(e),n=e.createAudioAnalyser,r={current:t?null:e.room},p=new Set,m={state:`idle`,volume:0,inputVolume:0,outputVolume:0},h=`idle`,b=null,x=null,S=null,C=null,w=null,T=null,E=null,D=0,O=null;function k(e){m=e,p.forEach(t=>t(e))}function A(e){k({...m,...e,state:e.state??m.state})}function j(e){let t=e<o?0:e,n=t>D?c:l;D+=(t-D)*n;let r=Math.min(D*s,1);return r/(r+u)}function M(){D=0,A({volume:0,outputVolume:0})}function N({emitZero:e=!0}={}){w&&=(clearInterval(w),null),C&&=(C.cleanup().catch(()=>{}),null),e&&A({volume:0,inputVolume:0})}function P(e){if(!(b===e&&C)){N({emitZero:!1}),b=e;try{C=n(e)}catch(e){console.warn(`[orb-ui/livekit] local createAudioAnalyser failed:`,e);return}w=setInterval(()=>{if(!C||h!==`listening`)return;let e=i(C.calculateVolume());A({volume:e,inputVolume:e,outputVolume:0})},33)}}function F({emitZero:e=!0}={}){E&&=(clearInterval(E),null),T&&=(T.cleanup().catch(()=>{}),null),D=0,e&&A({volume:0,outputVolume:0})}function I(e){F();try{T=n(e)}catch(e){console.warn(`[orb-ui/livekit] remote createAudioAnalyser failed:`,e);return}E=setInterval(()=>{if(!T||h!==`speaking`)return;let e=j(T.calculateVolume());A({volume:e,inputVolume:0,outputVolume:e})},33)}function L(e){h=e,A({state:e,volume:0,inputVolume:0,outputVolume:0}),e===`speaking`&&x?I(x):e!==`speaking`&&F({emitZero:!1})}function R(e){S||typeof document>`u`||(S=e.attach(),S.id=`orb-ui-livekit-agent-audio`,document.body.appendChild(S))}function z(){S&&=(S.remove(),null)}function B(e){x=e,R(e),h===`speaking`&&I(e)}function V(e){P(e)}function H(e){let t=e.getTrackPublication?.(`microphone`);t?.track&&V(t.track)}function U(e){let t=d(e);t!==h&&L(t)}function W(e){let t=e.attributes?.[`lk.agent.state`];t&&U(t);let n=e.getTrackPublication(`microphone`);n?.track&&B(n.track)}function G(e){if(O)return;let t=(e,t)=>{if(t.isLocal)return;let n=e[`lk.agent.state`];n&&U(n)},n=(e,t,n)=>{n.isLocal||!(n.kind===a||n.attributes?.[`lk.agent.state`]!==void 0)||e.mediaStreamTrack.kind!==`audio`||B(e)},r=e=>{x===e&&(x=null,z(),F())},i=e=>{e.source!==`microphone`||!e.track||V(e.track)},o=e=>{e.source===`microphone`&&(b=null,N())},s=()=>{b=null,x=null,z(),N({emitZero:!1}),F({emitZero:!1}),L(`idle`)};if(y(e,`participantAttributesChanged`,t),y(e,`trackSubscribed`,n),y(e,`trackUnsubscribed`,r),y(e,`localTrackPublished`,i),y(e,`localTrackUnpublished`,o),y(e,`disconnected`,s),O=()=>{v(e,`participantAttributesChanged`,t),v(e,`trackSubscribed`,n),v(e,`trackUnsubscribed`,r),v(e,`localTrackPublished`,i),v(e,`localTrackUnpublished`,o),v(e,`disconnected`,s)},H(e.localParticipant),e.state===`connected`){let t=_(e);t?W(t):L(`connecting`)}else L(`idle`)}function K(){O?.(),O=null,b=null,x=null,z(),N({emitZero:!1}),F({emitZero:!1}),A({volume:0,inputVolume:0,outputVolume:0})}let q=e=>{p.add(e),e(m);let t=r.current;return t&&G(t),()=>{p.delete(e),p.size===0&&K()}};return t?{subscribe:q,async start(){if(r.current)return;let t=e,n=new t.RoomClass;L(`connecting`);try{let e=await g(t);if(await n.connect(e.serverUrl,e.participantToken,t.connectOptions),r.current=n,G(n),t.enableMicrophone!==!1){let e=(await n.localParticipant.setMicrophoneEnabled(!0))?.track??n.localParticipant.getTrackPublication?.(`microphone`)?.track;e&&V(e)}}catch(e){throw console.error(`[orb-ui/livekit] connect failed:`,e),r.current===n&&K(),n.disconnect(),r.current=null,L(`error`),M(),A({error:e}),e}},async stop(){let e=r.current;if(!e){L(`idle`);return}K(),e.disconnect(),r.current=null,L(`idle`)}}:{subscribe:q}}var x={connected:`connected`,disconnected:`disconnected`,transportStateChanged:`transportStateChanged`,botReady:`botReady`,botDisconnected:`botDisconnected`,error:`error`,messageError:`messageError`,deviceError:`deviceError`,localAudioLevel:`localAudioLevel`,remoteAudioLevel:`remoteAudioLevel`,botStartedSpeaking:`botStartedSpeaking`,botStoppedSpeaking:`botStoppedSpeaking`,userStartedSpeaking:`userStartedSpeaking`,userStoppedSpeaking:`userStoppedSpeaking`,botLlmStarted:`botLlmStarted`,botTtsStarted:`botTtsStarted`},S=.002,C=4,w=.8,T=.6,E=.2;function D(e){switch(e){case`initializing`:case`initialized`:case`authenticating`:case`authenticated`:case`connecting`:case`connected`:return`connecting`;case`ready`:return`listening`;case`disconnected`:case`disconnecting`:return`idle`;case`error`:return`error`;default:return}}function O(e){if(typeof e!=`number`||!Number.isFinite(e)||e<=S)return 0;let t=Math.min(1,Math.max(0,e-S));return Math.min(1,t*C)**+w}function k(e,t){let n=O(e),r=n>t?T:E;return t+(n-t)*r}function A(e){return typeof e==`object`&&!!e&&`kind`in e&&typeof e.kind==`string`}function j(e,t={}){let n=new Set,r=new Map,i={state:D(e.state??``)??`idle`,volume:0,inputVolume:0,outputVolume:0},a=!1,o=0,s=0;function c(e){i=e,n.forEach(t=>t(e))}function l(e,t){o=0,s=0,c({state:e,volume:0,inputVolume:0,outputVolume:0,...t===void 0?{}:{error:t}})}function u(e){if(i.state!==`listening`)return;o=k(e,o);let t=o;c({...i,volume:t,inputVolume:t,outputVolume:0})}function d(e,n){if(i.state!==`speaking`)return;if(n&&typeof n==`object`){let e=n;if(e.local||t.isBotParticipant&&!t.isBotParticipant(e))return}s=k(e,s);let r=s;c({...i,volume:r,inputVolume:0,outputVolume:r})}function f(e){if(!e||typeof e!=`object`)return!0;let n=e;return n.local?!1:t.isBotParticipant?.(n)??!0}function p(e,n){if(t.playRemoteAudio===!1||!A(e)||e.kind!==`audio`||!f(n))return;let i=t.createAudioElement?.()??new Audio;i.autoplay=!0,i.srcObject=new MediaStream([e]),r.set(e,i),i.play().catch(()=>void 0)}function m(e){if(!A(e))return;let t=r.get(e);t&&(t.pause(),t.srcObject=null,t.remove(),r.delete(e))}function h(){r.forEach(e=>{e.pause(),e.srcObject=null,e.remove()}),r.clear()}let g=[[x.connected,()=>l(`connecting`)],[x.botReady,()=>l(`listening`)],[x.disconnected,()=>l(`idle`)],[x.botDisconnected,()=>l(`idle`)],[x.transportStateChanged,e=>{if(typeof e!=`string`)return;let t=D(e);t&&l(t)}],[x.userStartedSpeaking,()=>l(`listening`)],[x.userStoppedSpeaking,()=>{i.state===`listening`&&l(`thinking`)}],[x.botLlmStarted,()=>l(`thinking`)],[x.botTtsStarted,()=>l(`thinking`)],[x.botStartedSpeaking,()=>l(`speaking`)],[x.botStoppedSpeaking,()=>l(`listening`)],[x.localAudioLevel,u],[x.remoteAudioLevel,d],[`trackStarted`,p],[`trackStopped`,m],[x.error,e=>l(`error`,e)],[x.messageError,e=>l(`error`,e)],[x.deviceError,e=>l(`error`,e)]];function _(){a||(a=!0,g.forEach(([t,n])=>e.on(t,n)))}function v(){a&&(a=!1,g.forEach(([t,n])=>{e.off?e.off(t,n):e.removeListener?.(t,n)}),h())}return{subscribe(e){return n.add(e),_(),e(i),()=>{n.delete(e),n.size===0&&v()}},async start(){l(`connecting`);try{await(t.connect?t.connect():e.connect())}catch(e){throw l(`error`,e),e}},async stop(){try{await(t.disconnect?t.disconnect():e.disconnect())}finally{h(),l(`idle`)}}}}var M={noiseFloor:0,gain:4,exponent:.8,attack:1,release:1};function N(e,t,n){return Math.min(n,Math.max(t,e))}function P(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function F(e){let t=typeof e==`function`?e():e;return{noiseFloor:N(P(t?.noiseFloor,M.noiseFloor),0,1),gain:Math.max(0,P(t?.gain,M.gain)),exponent:Math.max(.01,P(t?.exponent,M.exponent)),attack:N(P(t?.attack,M.attack),0,1),release:N(P(t?.release,M.release),0,1)}}function I(e,t,n){let r=Number.isFinite(e)?N(e,0,1):0,i=F(n),a=N((r<=i.noiseFloor?0:r-i.noiseFloor)*i.gain,0,1)**+i.exponent,o=a>t?i.attack:i.release;return{raw:r,shaped:a,normalized:N(t+(a-t)*o,0,1)}}var L=`https://api.openai.com/v1/realtime/calls`,R=.015,z=8,B={noiseFloor:.003,gain:4,exponent:.8,attack:.55,release:.1};function V(){let e=window.AudioContext;return e?new e:void 0}function H(e){return Math.min(1,Math.max(0,(e*4)**.8))}function U(e,t,n){try{let r=t();if(!r)return;let i=r.createMediaStreamSource(e),a=r.createAnalyser();a.fftSize=512,a.smoothingTimeConstant=.25,i.connect(a);let o=new Float32Array(a.fftSize),s=setInterval(()=>{a.getFloatTimeDomainData(o);let e=0;for(let t of o)e+=t*t;n(Math.sqrt(e/o.length))},33);return{async stop(){clearInterval(s),i.disconnect(),a.disconnect(),r.state!==`closed`&&await r.close()}}}catch{return}}function W(e){let t=typeof e==`string`?e:e.value;if(!t)throw Error(`[orb-ui/openai-realtime] getClientSecret returned an empty value.`);return t}function G(e){let t=new Set,n={state:`idle`,volume:0,inputVolume:0,outputVolume:0},r=null,i=null,a=null,o=null,s,c,l=0,u=0,d=!1;function f(){let t=typeof e.outputVolumeCalibration==`function`?e.outputVolumeCalibration():e.outputVolumeCalibration;return{...B,...t}}function p(e){n=e,t.forEach(t=>t(e))}function m(e,t){n.state===e&&t===void 0||(e!==`speaking`&&(u=0),p({state:e,volume:0,inputVolume:0,outputVolume:0,...t===void 0?{}:{error:t}}))}function h(e){if(n.state!==`listening`)return;let t=H(e);p({...n,volume:t,inputVolume:t,outputVolume:0})}function g(t){let r=I(t,u,f);u=r.normalized,e.onOutputVolumeSample?.(r);let i=r.normalized;if(i>R)l=0,n.state!==`speaking`&&m(`speaking`);else if(n.state===`speaking`&&(l+=1,l>=z)){l=0,m(`listening`);return}n.state===`speaking`&&p({...n,volume:i,inputVolume:0,outputVolume:i})}function _(e){switch(e.type){case`session.created`:case`session.updated`:m(`listening`);break;case`input_audio_buffer.speech_started`:m(`listening`);break;case`input_audio_buffer.speech_stopped`:case`response.created`:m(`thinking`);break;case`response.output_audio.delta`:case`output_audio_buffer.started`:m(`speaking`);break;case`output_audio_buffer.stopped`:m(`listening`);break;case`response.done`:case`response.cancelled`:n.state!==`speaking`&&m(`listening`);break;case`error`:m(`error`,e.error??e);break}}async function v(e){d=!0,i?.close(),i=null,r?.close(),r=null,a?.getTracks().forEach(e=>e.stop()),a=null,o?.pause(),o&&(o.srcObject=null),o?.remove(),o=null,await Promise.all([s?.stop(),c?.stop()]),s=void 0,c=void 0,l=0,u=0,e&&m(`idle`),d=!1}return{subscribe(e){return t.add(e),e(n),()=>t.delete(e)},async start(){if(!r){m(`connecting`),d=!1;try{let t=e.getUserMedia??(e=>navigator.mediaDevices.getUserMedia(e)),n=e.createPeerConnection??(()=>new RTCPeerConnection),l=e.fetch??fetch,u=e.createAudioElement??(()=>new Audio),f=e.createAudioContext??V,p=W(await e.getClientSecret());a=await t(e.mediaStreamConstraints??{audio:!0}),s=U(a,f,h);let v=n();r=v,a.getAudioTracks().forEach(e=>v.addTrack(e,a)),o=u(),o.autoplay=!0,v.ontrack=e=>{let t=e.streams[0]??new MediaStream([e.track]);o&&(o.srcObject=t),o?.play().catch(()=>void 0),c?.stop(),c=U(t,f,g)},v.onconnectionstatechange=()=>{d||(v.connectionState===`failed`?m(`error`,Error(`[orb-ui/openai-realtime] WebRTC connection failed.`)):(v.connectionState===`disconnected`||v.connectionState===`closed`)&&m(`idle`))};let y=v.createDataChannel(`oai-events`);i=y,y.onopen=()=>m(`listening`),y.onmessage=e=>{try{_(JSON.parse(String(e.data)))}catch{}},y.onerror=e=>m(`error`,e),y.onclose=()=>{d||m(`idle`)};let b=await v.createOffer();await v.setLocalDescription(b);let x=await l(e.callsUrl??L,{method:`POST`,body:b.sdp,headers:{Authorization:`Bearer ${p}`,"Content-Type":`application/sdp`}});if(!x.ok){let e=await x.text();throw Error(`[orb-ui/openai-realtime] Session negotiation failed (${x.status}): ${e}`)}await v.setRemoteDescription({type:`answer`,sdp:await x.text()})}catch(e){throw await v(!1),m(`error`,e),e}}},async stop(){await v(!0)}}}var K=16e3,q={noiseFloor:.003,gain:4,exponent:.8,attack:.3,release:.1};function J(e){let t=0;for(let n of e)t+=n*n;return Math.sqrt(t/e.length)}function Y(e){return Math.min(1,Math.max(0,(J(e)*4)**.8))}function X(e,t,n){if(t===n)return e;let r=t/n,i=Math.max(1,Math.round(e.length/r)),a=new Float32Array(i);for(let t=0;t<i;t+=1){let n=t*r,i=Math.floor(n),o=Math.min(e.length-1,i+1),s=n-i;a[t]=e[i]*(1-s)+e[o]*s}return a}function Z(e){let t=new Uint8Array(e.length*2),n=new DataView(t.buffer);e.forEach((e,t)=>{let r=Math.max(-1,Math.min(1,e));n.setInt16(t*2,r<0?r*32768:r*32767,!0)});let r=``;return t.forEach(e=>{r+=String.fromCharCode(e)}),btoa(r)}function Q(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);let r=new DataView(n.buffer),i=new Float32Array(Math.floor(n.length/2));for(let e=0;e<i.length;e+=1)i[e]=r.getInt16(e*2,!0)/32768;return i}function $(e){let t=e?.match(/rate=(\d+)/i);return t?Number(t[1]):24e3}function ee(e){let t=new Set,n=new Set,r={state:`idle`,volume:0,inputVolume:0,outputVolume:0},i=null,a=null,o=null,s=null,c=null,l=null,u=null,d=null,f=null,p=!1,m=0,h=0,g=!1,_=!1;function v(){return e.activityDetection!==`server`}function y(){let t=typeof e.outputVolumeCalibration==`function`?e.outputVolumeCalibration():e.outputVolumeCalibration;return{...q,...t}}function b(e){r=e,t.forEach(t=>t(e))}function x(e,t){r.state===e&&t===void 0||(e!==`speaking`&&(h=0),b({state:e,volume:0,inputVolume:0,outputVolume:0,...t===void 0?{}:{error:t}}))}function S(){f&&=(clearTimeout(f),null)}function C(t){t>(e.speechThreshold??.04)?(!p&&v()&&i?.sendRealtimeInput({activityStart:{}}),p=!0,S(),r.state!==`listening`&&x(`listening`)):p&&!f&&(f=setTimeout(()=>{f=null,p=!1,v()&&i?.sendRealtimeInput({activityEnd:{}}),r.state===`listening`&&x(`thinking`)},e.speechEndDelayMs??500)),r.state===`listening`&&b({...r,volume:t,inputVolume:t,outputVolume:0})}function w(){n.forEach(e=>{try{e.stop()}catch{}e.disconnect()}),n.clear(),m=o?.currentTime??0}function T(){g&&n.size===0&&(g=!1,x(`listening`))}function E(e){if(!o||!u||!e.data)return;let t=Q(e.data),i=o.createBuffer(1,t.length,$(e.mimeType));i.getChannelData(0).set(t);let a=o.createBufferSource();a.buffer=i,a.connect(u);let s=Math.max(o.currentTime,m);m=s+i.duration,n.add(a),a.onended=()=>{n.delete(a),a.disconnect(),T()},a.start(s),r.state!==`speaking`&&x(`speaking`)}function D(e){e.setupComplete&&x(`listening`);let t=e.serverContent;if(!t)return;if(t.interrupted){w(),g=!1,x(`listening`);return}let n=t.modelTurn?.parts?.filter(e=>e.inlineData?.data)??[];t.modelTurn&&n.length===0&&r.state!==`speaking`&&x(`thinking`),n.forEach(e=>E(e.inlineData)),t.waitingForInput&&(w(),x(`listening`)),(t.turnComplete||t.generationComplete)&&(g=!0,T())}function O(){if(!u)return;let t=new Float32Array(u.fftSize);d=setInterval(()=>{if(!u||r.state!==`speaking`)return;u.getFloatTimeDomainData(t);let n=I(J(t),h,y);h=n.normalized,e.onOutputVolumeSample?.(n);let i=n.normalized;b({...r,volume:i,inputVolume:0,outputVolume:i})},33)}function k(){!o||!a||!i||(s=o.createMediaStreamSource(a),c=o.createScriptProcessor(4096,1,1),l=o.createGain(),l.gain.value=0,s.connect(c),c.connect(l),l.connect(o.destination),c.onaudioprocess=t=>{if(!i||_)return;let n=t.inputBuffer.getChannelData(0);C(Y(n));let r=X(n,o?.sampleRate??K,e.inputSampleRate??K);i.sendRealtimeInput({audio:{data:Z(r),mimeType:`audio/pcm;rate=${e.inputSampleRate??K}`}})})}async function A(e){_=!0,S(),d&&clearInterval(d),d=null,w(),c?.disconnect(),s?.disconnect(),l?.disconnect(),u?.disconnect(),c=null,s=null,l=null,u=null,a?.getTracks().forEach(e=>e.stop()),a=null,o&&o.state!==`closed`&&await o.close(),o=null,i=null,p=!1,g=!1,h=0,e&&x(`idle`),_=!1}return{subscribe(e){return t.add(e),e(r),()=>t.delete(e)},async start(){if(!i){x(`connecting`),_=!1;try{let t=e.getUserMedia??(e=>navigator.mediaDevices.getUserMedia(e)),n=e.createAudioContext??(()=>new window.AudioContext);a=await t(e.mediaStreamConstraints??{audio:!0}),o=n(),o.state===`suspended`&&await o.resume(),u=o.createAnalyser(),u.fftSize=512,u.smoothingTimeConstant=.25,u.connect(o.destination),O(),i=await e.connect({onopen:()=>x(`listening`),onmessage:D,onerror:e=>x(`error`,e),onclose:()=>{_||x(`idle`)}}),k(),x(`listening`)}catch(e){throw i?.close(),await A(!1),x(`error`,e),e}}},async stop(){_=!0;try{p&&v()&&i?.sendRealtimeInput({activityEnd:{}}),i?.sendRealtimeInput({audioStreamEnd:!0})}catch{}i?.close(),await A(!0)}}}exports.DEFAULT_OUTPUT_VOLUME_CALIBRATION=M,exports.createElevenLabsAdapter=r,exports.createGeminiLiveAdapter=ee,exports.createLiveKitAdapter=b,exports.createOpenAIRealtimeAdapter=G,exports.createPipecatAdapter=j,exports.createVapiAdapter=n;
|
package/dist/adapters.js
CHANGED
|
@@ -482,4 +482,569 @@ function b(e) {
|
|
|
482
482
|
} : { subscribe: q };
|
|
483
483
|
}
|
|
484
484
|
//#endregion
|
|
485
|
-
|
|
485
|
+
//#region src/adapters/pipecat/index.ts
|
|
486
|
+
var x = {
|
|
487
|
+
connected: "connected",
|
|
488
|
+
disconnected: "disconnected",
|
|
489
|
+
transportStateChanged: "transportStateChanged",
|
|
490
|
+
botReady: "botReady",
|
|
491
|
+
botDisconnected: "botDisconnected",
|
|
492
|
+
error: "error",
|
|
493
|
+
messageError: "messageError",
|
|
494
|
+
deviceError: "deviceError",
|
|
495
|
+
localAudioLevel: "localAudioLevel",
|
|
496
|
+
remoteAudioLevel: "remoteAudioLevel",
|
|
497
|
+
botStartedSpeaking: "botStartedSpeaking",
|
|
498
|
+
botStoppedSpeaking: "botStoppedSpeaking",
|
|
499
|
+
userStartedSpeaking: "userStartedSpeaking",
|
|
500
|
+
userStoppedSpeaking: "userStoppedSpeaking",
|
|
501
|
+
botLlmStarted: "botLlmStarted",
|
|
502
|
+
botTtsStarted: "botTtsStarted"
|
|
503
|
+
}, S = .002, C = 4, w = .8, T = .6, E = .2;
|
|
504
|
+
function D(e) {
|
|
505
|
+
switch (e) {
|
|
506
|
+
case "initializing":
|
|
507
|
+
case "initialized":
|
|
508
|
+
case "authenticating":
|
|
509
|
+
case "authenticated":
|
|
510
|
+
case "connecting":
|
|
511
|
+
case "connected": return "connecting";
|
|
512
|
+
case "ready": return "listening";
|
|
513
|
+
case "disconnected":
|
|
514
|
+
case "disconnecting": return "idle";
|
|
515
|
+
case "error": return "error";
|
|
516
|
+
default: return;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function O(e) {
|
|
520
|
+
if (typeof e != "number" || !Number.isFinite(e) || e <= S) return 0;
|
|
521
|
+
let t = Math.min(1, Math.max(0, e - S));
|
|
522
|
+
return Math.min(1, t * C) ** +w;
|
|
523
|
+
}
|
|
524
|
+
function k(e, t) {
|
|
525
|
+
let n = O(e), r = n > t ? T : E;
|
|
526
|
+
return t + (n - t) * r;
|
|
527
|
+
}
|
|
528
|
+
function A(e) {
|
|
529
|
+
return typeof e == "object" && !!e && "kind" in e && typeof e.kind == "string";
|
|
530
|
+
}
|
|
531
|
+
function j(e, t = {}) {
|
|
532
|
+
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), i = {
|
|
533
|
+
state: D(e.state ?? "") ?? "idle",
|
|
534
|
+
volume: 0,
|
|
535
|
+
inputVolume: 0,
|
|
536
|
+
outputVolume: 0
|
|
537
|
+
}, a = !1, o = 0, s = 0;
|
|
538
|
+
function c(e) {
|
|
539
|
+
i = e, n.forEach((t) => t(e));
|
|
540
|
+
}
|
|
541
|
+
function l(e, t) {
|
|
542
|
+
o = 0, s = 0, c({
|
|
543
|
+
state: e,
|
|
544
|
+
volume: 0,
|
|
545
|
+
inputVolume: 0,
|
|
546
|
+
outputVolume: 0,
|
|
547
|
+
...t === void 0 ? {} : { error: t }
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
function u(e) {
|
|
551
|
+
if (i.state !== "listening") return;
|
|
552
|
+
o = k(e, o);
|
|
553
|
+
let t = o;
|
|
554
|
+
c({
|
|
555
|
+
...i,
|
|
556
|
+
volume: t,
|
|
557
|
+
inputVolume: t,
|
|
558
|
+
outputVolume: 0
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
function d(e, n) {
|
|
562
|
+
if (i.state !== "speaking") return;
|
|
563
|
+
if (n && typeof n == "object") {
|
|
564
|
+
let e = n;
|
|
565
|
+
if (e.local || t.isBotParticipant && !t.isBotParticipant(e)) return;
|
|
566
|
+
}
|
|
567
|
+
s = k(e, s);
|
|
568
|
+
let r = s;
|
|
569
|
+
c({
|
|
570
|
+
...i,
|
|
571
|
+
volume: r,
|
|
572
|
+
inputVolume: 0,
|
|
573
|
+
outputVolume: r
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
function f(e) {
|
|
577
|
+
if (!e || typeof e != "object") return !0;
|
|
578
|
+
let n = e;
|
|
579
|
+
return n.local ? !1 : t.isBotParticipant?.(n) ?? !0;
|
|
580
|
+
}
|
|
581
|
+
function p(e, n) {
|
|
582
|
+
if (t.playRemoteAudio === !1 || !A(e) || e.kind !== "audio" || !f(n)) return;
|
|
583
|
+
let i = t.createAudioElement?.() ?? new Audio();
|
|
584
|
+
i.autoplay = !0, i.srcObject = new MediaStream([e]), r.set(e, i), i.play().catch(() => void 0);
|
|
585
|
+
}
|
|
586
|
+
function m(e) {
|
|
587
|
+
if (!A(e)) return;
|
|
588
|
+
let t = r.get(e);
|
|
589
|
+
t && (t.pause(), t.srcObject = null, t.remove(), r.delete(e));
|
|
590
|
+
}
|
|
591
|
+
function h() {
|
|
592
|
+
r.forEach((e) => {
|
|
593
|
+
e.pause(), e.srcObject = null, e.remove();
|
|
594
|
+
}), r.clear();
|
|
595
|
+
}
|
|
596
|
+
let g = [
|
|
597
|
+
[x.connected, () => l("connecting")],
|
|
598
|
+
[x.botReady, () => l("listening")],
|
|
599
|
+
[x.disconnected, () => l("idle")],
|
|
600
|
+
[x.botDisconnected, () => l("idle")],
|
|
601
|
+
[x.transportStateChanged, (e) => {
|
|
602
|
+
if (typeof e != "string") return;
|
|
603
|
+
let t = D(e);
|
|
604
|
+
t && l(t);
|
|
605
|
+
}],
|
|
606
|
+
[x.userStartedSpeaking, () => l("listening")],
|
|
607
|
+
[x.userStoppedSpeaking, () => {
|
|
608
|
+
i.state === "listening" && l("thinking");
|
|
609
|
+
}],
|
|
610
|
+
[x.botLlmStarted, () => l("thinking")],
|
|
611
|
+
[x.botTtsStarted, () => l("thinking")],
|
|
612
|
+
[x.botStartedSpeaking, () => l("speaking")],
|
|
613
|
+
[x.botStoppedSpeaking, () => l("listening")],
|
|
614
|
+
[x.localAudioLevel, u],
|
|
615
|
+
[x.remoteAudioLevel, d],
|
|
616
|
+
["trackStarted", p],
|
|
617
|
+
["trackStopped", m],
|
|
618
|
+
[x.error, (e) => l("error", e)],
|
|
619
|
+
[x.messageError, (e) => l("error", e)],
|
|
620
|
+
[x.deviceError, (e) => l("error", e)]
|
|
621
|
+
];
|
|
622
|
+
function _() {
|
|
623
|
+
a || (a = !0, g.forEach(([t, n]) => e.on(t, n)));
|
|
624
|
+
}
|
|
625
|
+
function v() {
|
|
626
|
+
a && (a = !1, g.forEach(([t, n]) => {
|
|
627
|
+
e.off ? e.off(t, n) : e.removeListener?.(t, n);
|
|
628
|
+
}), h());
|
|
629
|
+
}
|
|
630
|
+
return {
|
|
631
|
+
subscribe(e) {
|
|
632
|
+
return n.add(e), _(), e(i), () => {
|
|
633
|
+
n.delete(e), n.size === 0 && v();
|
|
634
|
+
};
|
|
635
|
+
},
|
|
636
|
+
async start() {
|
|
637
|
+
l("connecting");
|
|
638
|
+
try {
|
|
639
|
+
await (t.connect ? t.connect() : e.connect());
|
|
640
|
+
} catch (e) {
|
|
641
|
+
throw l("error", e), e;
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
async stop() {
|
|
645
|
+
try {
|
|
646
|
+
await (t.disconnect ? t.disconnect() : e.disconnect());
|
|
647
|
+
} finally {
|
|
648
|
+
h(), l("idle");
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
//#endregion
|
|
654
|
+
//#region src/adapters/audio-level.ts
|
|
655
|
+
var M = {
|
|
656
|
+
noiseFloor: 0,
|
|
657
|
+
gain: 4,
|
|
658
|
+
exponent: .8,
|
|
659
|
+
attack: 1,
|
|
660
|
+
release: 1
|
|
661
|
+
};
|
|
662
|
+
function N(e, t, n) {
|
|
663
|
+
return Math.min(n, Math.max(t, e));
|
|
664
|
+
}
|
|
665
|
+
function P(e, t) {
|
|
666
|
+
return typeof e == "number" && Number.isFinite(e) ? e : t;
|
|
667
|
+
}
|
|
668
|
+
function F(e) {
|
|
669
|
+
let t = typeof e == "function" ? e() : e;
|
|
670
|
+
return {
|
|
671
|
+
noiseFloor: N(P(t?.noiseFloor, M.noiseFloor), 0, 1),
|
|
672
|
+
gain: Math.max(0, P(t?.gain, M.gain)),
|
|
673
|
+
exponent: Math.max(.01, P(t?.exponent, M.exponent)),
|
|
674
|
+
attack: N(P(t?.attack, M.attack), 0, 1),
|
|
675
|
+
release: N(P(t?.release, M.release), 0, 1)
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
function I(e, t, n) {
|
|
679
|
+
let r = Number.isFinite(e) ? N(e, 0, 1) : 0, i = F(n), a = N((r <= i.noiseFloor ? 0 : r - i.noiseFloor) * i.gain, 0, 1) ** +i.exponent, o = a > t ? i.attack : i.release;
|
|
680
|
+
return {
|
|
681
|
+
raw: r,
|
|
682
|
+
shaped: a,
|
|
683
|
+
normalized: N(t + (a - t) * o, 0, 1)
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
//#endregion
|
|
687
|
+
//#region src/adapters/openai-realtime/index.ts
|
|
688
|
+
var L = "https://api.openai.com/v1/realtime/calls", R = .015, z = 8, B = {
|
|
689
|
+
noiseFloor: .003,
|
|
690
|
+
gain: 4,
|
|
691
|
+
exponent: .8,
|
|
692
|
+
attack: .55,
|
|
693
|
+
release: .1
|
|
694
|
+
};
|
|
695
|
+
function V() {
|
|
696
|
+
let e = window.AudioContext;
|
|
697
|
+
return e ? new e() : void 0;
|
|
698
|
+
}
|
|
699
|
+
function H(e) {
|
|
700
|
+
return Math.min(1, Math.max(0, (e * 4) ** .8));
|
|
701
|
+
}
|
|
702
|
+
function U(e, t, n) {
|
|
703
|
+
try {
|
|
704
|
+
let r = t();
|
|
705
|
+
if (!r) return;
|
|
706
|
+
let i = r.createMediaStreamSource(e), a = r.createAnalyser();
|
|
707
|
+
a.fftSize = 512, a.smoothingTimeConstant = .25, i.connect(a);
|
|
708
|
+
let o = new Float32Array(a.fftSize), s = setInterval(() => {
|
|
709
|
+
a.getFloatTimeDomainData(o);
|
|
710
|
+
let e = 0;
|
|
711
|
+
for (let t of o) e += t * t;
|
|
712
|
+
n(Math.sqrt(e / o.length));
|
|
713
|
+
}, 33);
|
|
714
|
+
return { async stop() {
|
|
715
|
+
clearInterval(s), i.disconnect(), a.disconnect(), r.state !== "closed" && await r.close();
|
|
716
|
+
} };
|
|
717
|
+
} catch {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
function W(e) {
|
|
722
|
+
let t = typeof e == "string" ? e : e.value;
|
|
723
|
+
if (!t) throw Error("[orb-ui/openai-realtime] getClientSecret returned an empty value.");
|
|
724
|
+
return t;
|
|
725
|
+
}
|
|
726
|
+
function G(e) {
|
|
727
|
+
let t = /* @__PURE__ */ new Set(), n = {
|
|
728
|
+
state: "idle",
|
|
729
|
+
volume: 0,
|
|
730
|
+
inputVolume: 0,
|
|
731
|
+
outputVolume: 0
|
|
732
|
+
}, r = null, i = null, a = null, o = null, s, c, l = 0, u = 0, d = !1;
|
|
733
|
+
function f() {
|
|
734
|
+
let t = typeof e.outputVolumeCalibration == "function" ? e.outputVolumeCalibration() : e.outputVolumeCalibration;
|
|
735
|
+
return {
|
|
736
|
+
...B,
|
|
737
|
+
...t
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
function p(e) {
|
|
741
|
+
n = e, t.forEach((t) => t(e));
|
|
742
|
+
}
|
|
743
|
+
function m(e, t) {
|
|
744
|
+
n.state === e && t === void 0 || (e !== "speaking" && (u = 0), p({
|
|
745
|
+
state: e,
|
|
746
|
+
volume: 0,
|
|
747
|
+
inputVolume: 0,
|
|
748
|
+
outputVolume: 0,
|
|
749
|
+
...t === void 0 ? {} : { error: t }
|
|
750
|
+
}));
|
|
751
|
+
}
|
|
752
|
+
function h(e) {
|
|
753
|
+
if (n.state !== "listening") return;
|
|
754
|
+
let t = H(e);
|
|
755
|
+
p({
|
|
756
|
+
...n,
|
|
757
|
+
volume: t,
|
|
758
|
+
inputVolume: t,
|
|
759
|
+
outputVolume: 0
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
function g(t) {
|
|
763
|
+
let r = I(t, u, f);
|
|
764
|
+
u = r.normalized, e.onOutputVolumeSample?.(r);
|
|
765
|
+
let i = r.normalized;
|
|
766
|
+
if (i > R) l = 0, n.state !== "speaking" && m("speaking");
|
|
767
|
+
else if (n.state === "speaking" && (l += 1, l >= z)) {
|
|
768
|
+
l = 0, m("listening");
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
n.state === "speaking" && p({
|
|
772
|
+
...n,
|
|
773
|
+
volume: i,
|
|
774
|
+
inputVolume: 0,
|
|
775
|
+
outputVolume: i
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
function _(e) {
|
|
779
|
+
switch (e.type) {
|
|
780
|
+
case "session.created":
|
|
781
|
+
case "session.updated":
|
|
782
|
+
m("listening");
|
|
783
|
+
break;
|
|
784
|
+
case "input_audio_buffer.speech_started":
|
|
785
|
+
m("listening");
|
|
786
|
+
break;
|
|
787
|
+
case "input_audio_buffer.speech_stopped":
|
|
788
|
+
case "response.created":
|
|
789
|
+
m("thinking");
|
|
790
|
+
break;
|
|
791
|
+
case "response.output_audio.delta":
|
|
792
|
+
case "output_audio_buffer.started":
|
|
793
|
+
m("speaking");
|
|
794
|
+
break;
|
|
795
|
+
case "output_audio_buffer.stopped":
|
|
796
|
+
m("listening");
|
|
797
|
+
break;
|
|
798
|
+
case "response.done":
|
|
799
|
+
case "response.cancelled":
|
|
800
|
+
n.state !== "speaking" && m("listening");
|
|
801
|
+
break;
|
|
802
|
+
case "error":
|
|
803
|
+
m("error", e.error ?? e);
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
async function v(e) {
|
|
808
|
+
d = !0, i?.close(), i = null, r?.close(), r = null, a?.getTracks().forEach((e) => e.stop()), a = null, o?.pause(), o && (o.srcObject = null), o?.remove(), o = null, await Promise.all([s?.stop(), c?.stop()]), s = void 0, c = void 0, l = 0, u = 0, e && m("idle"), d = !1;
|
|
809
|
+
}
|
|
810
|
+
return {
|
|
811
|
+
subscribe(e) {
|
|
812
|
+
return t.add(e), e(n), () => t.delete(e);
|
|
813
|
+
},
|
|
814
|
+
async start() {
|
|
815
|
+
if (!r) {
|
|
816
|
+
m("connecting"), d = !1;
|
|
817
|
+
try {
|
|
818
|
+
let t = e.getUserMedia ?? ((e) => navigator.mediaDevices.getUserMedia(e)), n = e.createPeerConnection ?? (() => new RTCPeerConnection()), l = e.fetch ?? fetch, u = e.createAudioElement ?? (() => new Audio()), f = e.createAudioContext ?? V, p = W(await e.getClientSecret());
|
|
819
|
+
a = await t(e.mediaStreamConstraints ?? { audio: !0 }), s = U(a, f, h);
|
|
820
|
+
let v = n();
|
|
821
|
+
r = v, a.getAudioTracks().forEach((e) => v.addTrack(e, a)), o = u(), o.autoplay = !0, v.ontrack = (e) => {
|
|
822
|
+
let t = e.streams[0] ?? new MediaStream([e.track]);
|
|
823
|
+
o && (o.srcObject = t), o?.play().catch(() => void 0), c?.stop(), c = U(t, f, g);
|
|
824
|
+
}, v.onconnectionstatechange = () => {
|
|
825
|
+
d || (v.connectionState === "failed" ? m("error", /* @__PURE__ */ Error("[orb-ui/openai-realtime] WebRTC connection failed.")) : (v.connectionState === "disconnected" || v.connectionState === "closed") && m("idle"));
|
|
826
|
+
};
|
|
827
|
+
let y = v.createDataChannel("oai-events");
|
|
828
|
+
i = y, y.onopen = () => m("listening"), y.onmessage = (e) => {
|
|
829
|
+
try {
|
|
830
|
+
_(JSON.parse(String(e.data)));
|
|
831
|
+
} catch {}
|
|
832
|
+
}, y.onerror = (e) => m("error", e), y.onclose = () => {
|
|
833
|
+
d || m("idle");
|
|
834
|
+
};
|
|
835
|
+
let b = await v.createOffer();
|
|
836
|
+
await v.setLocalDescription(b);
|
|
837
|
+
let x = await l(e.callsUrl ?? L, {
|
|
838
|
+
method: "POST",
|
|
839
|
+
body: b.sdp,
|
|
840
|
+
headers: {
|
|
841
|
+
Authorization: `Bearer ${p}`,
|
|
842
|
+
"Content-Type": "application/sdp"
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
if (!x.ok) {
|
|
846
|
+
let e = await x.text();
|
|
847
|
+
throw Error(`[orb-ui/openai-realtime] Session negotiation failed (${x.status}): ${e}`);
|
|
848
|
+
}
|
|
849
|
+
await v.setRemoteDescription({
|
|
850
|
+
type: "answer",
|
|
851
|
+
sdp: await x.text()
|
|
852
|
+
});
|
|
853
|
+
} catch (e) {
|
|
854
|
+
throw await v(!1), m("error", e), e;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
},
|
|
858
|
+
async stop() {
|
|
859
|
+
await v(!0);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
//#endregion
|
|
864
|
+
//#region src/adapters/gemini-live/index.ts
|
|
865
|
+
var K = 16e3, q = {
|
|
866
|
+
noiseFloor: .003,
|
|
867
|
+
gain: 4,
|
|
868
|
+
exponent: .8,
|
|
869
|
+
attack: .3,
|
|
870
|
+
release: .1
|
|
871
|
+
};
|
|
872
|
+
function J(e) {
|
|
873
|
+
let t = 0;
|
|
874
|
+
for (let n of e) t += n * n;
|
|
875
|
+
return Math.sqrt(t / e.length);
|
|
876
|
+
}
|
|
877
|
+
function Y(e) {
|
|
878
|
+
return Math.min(1, Math.max(0, (J(e) * 4) ** .8));
|
|
879
|
+
}
|
|
880
|
+
function X(e, t, n) {
|
|
881
|
+
if (t === n) return e;
|
|
882
|
+
let r = t / n, i = Math.max(1, Math.round(e.length / r)), a = new Float32Array(i);
|
|
883
|
+
for (let t = 0; t < i; t += 1) {
|
|
884
|
+
let n = t * r, i = Math.floor(n), o = Math.min(e.length - 1, i + 1), s = n - i;
|
|
885
|
+
a[t] = e[i] * (1 - s) + e[o] * s;
|
|
886
|
+
}
|
|
887
|
+
return a;
|
|
888
|
+
}
|
|
889
|
+
function Z(e) {
|
|
890
|
+
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
891
|
+
e.forEach((e, t) => {
|
|
892
|
+
let r = Math.max(-1, Math.min(1, e));
|
|
893
|
+
n.setInt16(t * 2, r < 0 ? r * 32768 : r * 32767, !0);
|
|
894
|
+
});
|
|
895
|
+
let r = "";
|
|
896
|
+
return t.forEach((e) => {
|
|
897
|
+
r += String.fromCharCode(e);
|
|
898
|
+
}), btoa(r);
|
|
899
|
+
}
|
|
900
|
+
function Q(e) {
|
|
901
|
+
let t = atob(e), n = new Uint8Array(t.length);
|
|
902
|
+
for (let e = 0; e < t.length; e += 1) n[e] = t.charCodeAt(e);
|
|
903
|
+
let r = new DataView(n.buffer), i = new Float32Array(Math.floor(n.length / 2));
|
|
904
|
+
for (let e = 0; e < i.length; e += 1) i[e] = r.getInt16(e * 2, !0) / 32768;
|
|
905
|
+
return i;
|
|
906
|
+
}
|
|
907
|
+
function $(e) {
|
|
908
|
+
let t = e?.match(/rate=(\d+)/i);
|
|
909
|
+
return t ? Number(t[1]) : 24e3;
|
|
910
|
+
}
|
|
911
|
+
function ee(e) {
|
|
912
|
+
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = {
|
|
913
|
+
state: "idle",
|
|
914
|
+
volume: 0,
|
|
915
|
+
inputVolume: 0,
|
|
916
|
+
outputVolume: 0
|
|
917
|
+
}, i = null, a = null, o = null, s = null, c = null, l = null, u = null, d = null, f = null, p = !1, m = 0, h = 0, g = !1, _ = !1;
|
|
918
|
+
function v() {
|
|
919
|
+
return e.activityDetection !== "server";
|
|
920
|
+
}
|
|
921
|
+
function y() {
|
|
922
|
+
let t = typeof e.outputVolumeCalibration == "function" ? e.outputVolumeCalibration() : e.outputVolumeCalibration;
|
|
923
|
+
return {
|
|
924
|
+
...q,
|
|
925
|
+
...t
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
function b(e) {
|
|
929
|
+
r = e, t.forEach((t) => t(e));
|
|
930
|
+
}
|
|
931
|
+
function x(e, t) {
|
|
932
|
+
r.state === e && t === void 0 || (e !== "speaking" && (h = 0), b({
|
|
933
|
+
state: e,
|
|
934
|
+
volume: 0,
|
|
935
|
+
inputVolume: 0,
|
|
936
|
+
outputVolume: 0,
|
|
937
|
+
...t === void 0 ? {} : { error: t }
|
|
938
|
+
}));
|
|
939
|
+
}
|
|
940
|
+
function S() {
|
|
941
|
+
f &&= (clearTimeout(f), null);
|
|
942
|
+
}
|
|
943
|
+
function C(t) {
|
|
944
|
+
t > (e.speechThreshold ?? .04) ? (!p && v() && i?.sendRealtimeInput({ activityStart: {} }), p = !0, S(), r.state !== "listening" && x("listening")) : p && !f && (f = setTimeout(() => {
|
|
945
|
+
f = null, p = !1, v() && i?.sendRealtimeInput({ activityEnd: {} }), r.state === "listening" && x("thinking");
|
|
946
|
+
}, e.speechEndDelayMs ?? 500)), r.state === "listening" && b({
|
|
947
|
+
...r,
|
|
948
|
+
volume: t,
|
|
949
|
+
inputVolume: t,
|
|
950
|
+
outputVolume: 0
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
function w() {
|
|
954
|
+
n.forEach((e) => {
|
|
955
|
+
try {
|
|
956
|
+
e.stop();
|
|
957
|
+
} catch {}
|
|
958
|
+
e.disconnect();
|
|
959
|
+
}), n.clear(), m = o?.currentTime ?? 0;
|
|
960
|
+
}
|
|
961
|
+
function T() {
|
|
962
|
+
g && n.size === 0 && (g = !1, x("listening"));
|
|
963
|
+
}
|
|
964
|
+
function E(e) {
|
|
965
|
+
if (!o || !u || !e.data) return;
|
|
966
|
+
let t = Q(e.data), i = o.createBuffer(1, t.length, $(e.mimeType));
|
|
967
|
+
i.getChannelData(0).set(t);
|
|
968
|
+
let a = o.createBufferSource();
|
|
969
|
+
a.buffer = i, a.connect(u);
|
|
970
|
+
let s = Math.max(o.currentTime, m);
|
|
971
|
+
m = s + i.duration, n.add(a), a.onended = () => {
|
|
972
|
+
n.delete(a), a.disconnect(), T();
|
|
973
|
+
}, a.start(s), r.state !== "speaking" && x("speaking");
|
|
974
|
+
}
|
|
975
|
+
function D(e) {
|
|
976
|
+
e.setupComplete && x("listening");
|
|
977
|
+
let t = e.serverContent;
|
|
978
|
+
if (!t) return;
|
|
979
|
+
if (t.interrupted) {
|
|
980
|
+
w(), g = !1, x("listening");
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
let n = t.modelTurn?.parts?.filter((e) => e.inlineData?.data) ?? [];
|
|
984
|
+
t.modelTurn && n.length === 0 && r.state !== "speaking" && x("thinking"), n.forEach((e) => E(e.inlineData)), t.waitingForInput && (w(), x("listening")), (t.turnComplete || t.generationComplete) && (g = !0, T());
|
|
985
|
+
}
|
|
986
|
+
function O() {
|
|
987
|
+
if (!u) return;
|
|
988
|
+
let t = new Float32Array(u.fftSize);
|
|
989
|
+
d = setInterval(() => {
|
|
990
|
+
if (!u || r.state !== "speaking") return;
|
|
991
|
+
u.getFloatTimeDomainData(t);
|
|
992
|
+
let n = I(J(t), h, y);
|
|
993
|
+
h = n.normalized, e.onOutputVolumeSample?.(n);
|
|
994
|
+
let i = n.normalized;
|
|
995
|
+
b({
|
|
996
|
+
...r,
|
|
997
|
+
volume: i,
|
|
998
|
+
inputVolume: 0,
|
|
999
|
+
outputVolume: i
|
|
1000
|
+
});
|
|
1001
|
+
}, 33);
|
|
1002
|
+
}
|
|
1003
|
+
function k() {
|
|
1004
|
+
!o || !a || !i || (s = o.createMediaStreamSource(a), c = o.createScriptProcessor(4096, 1, 1), l = o.createGain(), l.gain.value = 0, s.connect(c), c.connect(l), l.connect(o.destination), c.onaudioprocess = (t) => {
|
|
1005
|
+
if (!i || _) return;
|
|
1006
|
+
let n = t.inputBuffer.getChannelData(0);
|
|
1007
|
+
C(Y(n));
|
|
1008
|
+
let r = X(n, o?.sampleRate ?? K, e.inputSampleRate ?? K);
|
|
1009
|
+
i.sendRealtimeInput({ audio: {
|
|
1010
|
+
data: Z(r),
|
|
1011
|
+
mimeType: `audio/pcm;rate=${e.inputSampleRate ?? K}`
|
|
1012
|
+
} });
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
async function A(e) {
|
|
1016
|
+
_ = !0, S(), d && clearInterval(d), d = null, w(), c?.disconnect(), s?.disconnect(), l?.disconnect(), u?.disconnect(), c = null, s = null, l = null, u = null, a?.getTracks().forEach((e) => e.stop()), a = null, o && o.state !== "closed" && await o.close(), o = null, i = null, p = !1, g = !1, h = 0, e && x("idle"), _ = !1;
|
|
1017
|
+
}
|
|
1018
|
+
return {
|
|
1019
|
+
subscribe(e) {
|
|
1020
|
+
return t.add(e), e(r), () => t.delete(e);
|
|
1021
|
+
},
|
|
1022
|
+
async start() {
|
|
1023
|
+
if (!i) {
|
|
1024
|
+
x("connecting"), _ = !1;
|
|
1025
|
+
try {
|
|
1026
|
+
let t = e.getUserMedia ?? ((e) => navigator.mediaDevices.getUserMedia(e)), n = e.createAudioContext ?? (() => new window.AudioContext());
|
|
1027
|
+
a = await t(e.mediaStreamConstraints ?? { audio: !0 }), o = n(), o.state === "suspended" && await o.resume(), u = o.createAnalyser(), u.fftSize = 512, u.smoothingTimeConstant = .25, u.connect(o.destination), O(), i = await e.connect({
|
|
1028
|
+
onopen: () => x("listening"),
|
|
1029
|
+
onmessage: D,
|
|
1030
|
+
onerror: (e) => x("error", e),
|
|
1031
|
+
onclose: () => {
|
|
1032
|
+
_ || x("idle");
|
|
1033
|
+
}
|
|
1034
|
+
}), k(), x("listening");
|
|
1035
|
+
} catch (e) {
|
|
1036
|
+
throw i?.close(), await A(!1), x("error", e), e;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
},
|
|
1040
|
+
async stop() {
|
|
1041
|
+
_ = !0;
|
|
1042
|
+
try {
|
|
1043
|
+
p && v() && i?.sendRealtimeInput({ activityEnd: {} }), i?.sendRealtimeInput({ audioStreamEnd: !0 });
|
|
1044
|
+
} catch {}
|
|
1045
|
+
i?.close(), await A(!0);
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
//#endregion
|
|
1050
|
+
export { M as DEFAULT_OUTPUT_VOLUME_CALIBRATION, r as createElevenLabsAdapter, ee as createGeminiLiveAdapter, b as createLiveKitAdapter, G as createOpenAIRealtimeAdapter, j as createPipecatAdapter, n as createVapiAdapter };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orb-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "React voice agent UI components with
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "React voice agent UI components with audio-reactive adapters for Vapi, ElevenLabs, LiveKit, Pipecat, OpenAI Realtime, Gemini Live, and custom voice AI apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/orb-ui.cjs",
|
|
7
7
|
"module": "./dist/orb-ui.js",
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
"@changesets/cli": "^2.31.0",
|
|
30
30
|
"@elevenlabs/client": "1.9.0",
|
|
31
31
|
"@eslint/js": "^10.0.1",
|
|
32
|
+
"@google/genai": "2.11.0",
|
|
33
|
+
"@pipecat-ai/client-js": "1.12.0",
|
|
34
|
+
"@pipecat-ai/small-webrtc-transport": "1.10.5",
|
|
35
|
+
"@playwright/test": "1.61.1",
|
|
32
36
|
"@types/react": "^18.3.29",
|
|
33
37
|
"@types/react-dom": "^18.3.7",
|
|
34
38
|
"@vapi-ai/web": "2.5.2",
|
|
@@ -63,7 +67,10 @@
|
|
|
63
67
|
"state-machine",
|
|
64
68
|
"vapi",
|
|
65
69
|
"elevenlabs",
|
|
66
|
-
"livekit"
|
|
70
|
+
"livekit",
|
|
71
|
+
"pipecat",
|
|
72
|
+
"openai-realtime",
|
|
73
|
+
"gemini-live"
|
|
67
74
|
],
|
|
68
75
|
"license": "MIT",
|
|
69
76
|
"author": "Alexander Chen",
|
|
@@ -83,7 +90,7 @@
|
|
|
83
90
|
"build": "tsc && vite build",
|
|
84
91
|
"build:demo": "pnpm --filter orb-ui-demo build",
|
|
85
92
|
"changeset": "changeset",
|
|
86
|
-
"check": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm typecheck:examples && pnpm test && pnpm build && pnpm typecheck:package && pnpm typecheck:demo && pnpm build:demo",
|
|
93
|
+
"check": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm typecheck:examples && pnpm test && pnpm build && pnpm typecheck:package && pnpm typecheck:demo && pnpm build:demo && pnpm test:e2e:built",
|
|
87
94
|
"dev": "vite build --watch",
|
|
88
95
|
"dev:demo": "pnpm --filter orb-ui-demo dev",
|
|
89
96
|
"format": "prettier . --write",
|
|
@@ -95,6 +102,8 @@
|
|
|
95
102
|
"lint": "eslint .",
|
|
96
103
|
"release": "pnpm build && changeset publish",
|
|
97
104
|
"test": "vitest run --passWithNoTests",
|
|
105
|
+
"test:e2e": "pnpm build && pnpm test:e2e:built",
|
|
106
|
+
"test:e2e:built": "tsc -p tests/e2e/tsconfig.json --noEmit && playwright test",
|
|
98
107
|
"test:watch": "vitest"
|
|
99
108
|
}
|
|
100
109
|
}
|