@onlive.ai/common-121 0.2.163 → 0.2.179
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/chunk-CHMR2I4G.js +2 -0
- package/components/asset/asset-modal-portal.cjs +1 -1
- package/components/asset/asset-modal-portal.d.cts +1 -1
- package/components/asset/asset-modal-portal.d.ts +1 -1
- package/components/asset/asset-modal-portal.js +1 -1
- package/components/asset/asset.cjs +4 -4
- package/components/asset/asset.d.cts +1 -1
- package/components/asset/asset.d.ts +1 -1
- package/components/asset/asset.js +13 -13
- package/components/asset/asset.loaders.cjs +1 -1
- package/components/asset/asset.loaders.d.cts +1 -1
- package/components/asset/asset.loaders.d.ts +1 -1
- package/components/asset/asset.loaders.js +1 -1
- package/components/asset/asset.renderer.cjs +4 -4
- package/components/asset/asset.renderer.d.cts +1 -1
- package/components/asset/asset.renderer.d.ts +1 -1
- package/components/asset/asset.renderer.js +10 -10
- package/components/asset/asset.styles.cjs +1 -1
- package/components/asset/asset.styles.d.cts +1 -1
- package/components/asset/asset.styles.d.ts +1 -1
- package/components/asset/asset.styles.js +1 -1
- package/components/asset/asset.types.cjs +1 -1
- package/components/asset/asset.types.d.cts +1 -1
- package/components/asset/asset.types.d.ts +1 -1
- package/components/asset/asset.types.js +1 -1
- package/components/asset/index.cjs +4 -4
- package/components/asset/index.d.cts +1 -1
- package/components/asset/index.d.ts +1 -1
- package/components/asset/index.js +13 -13
- package/components/player/player.cjs +1 -1
- package/components/player/player.d.cts +1 -1
- package/components/player/player.d.ts +1 -1
- package/components/player/player.js +1 -1
- package/components/player/player.styles.cjs +1 -1
- package/components/player/player.styles.d.cts +1 -1
- package/components/player/player.styles.d.ts +1 -1
- package/components/player/player.styles.js +1 -1
- package/components/side-bar/index.cjs +1 -1
- package/components/side-bar/index.d.cts +1 -1
- package/components/side-bar/index.d.ts +1 -1
- package/components/side-bar/index.js +1 -1
- package/components/side-bar/side-bar.cjs +1 -1
- package/components/side-bar/side-bar.d.cts +1 -1
- package/components/side-bar/side-bar.d.ts +1 -1
- package/components/side-bar/side-bar.js +1 -1
- package/components/side-bar/side-bar.styles.cjs +1 -1
- package/components/side-bar/side-bar.styles.d.cts +1 -1
- package/components/side-bar/side-bar.styles.d.ts +1 -1
- package/components/side-bar/side-bar.styles.js +1 -1
- package/components/side-bar/side-bar.types.cjs +1 -1
- package/components/side-bar/side-bar.types.d.cts +1 -1
- package/components/side-bar/side-bar.types.d.ts +1 -1
- package/components/side-bar/side-bar.types.js +1 -1
- package/components/upload/index.cjs +1 -1
- package/components/upload/index.d.cts +1 -1
- package/components/upload/index.d.ts +1 -1
- package/components/upload/index.js +1 -1
- package/components/upload/upload.cjs +1 -1
- package/components/upload/upload.d.cts +1 -1
- package/components/upload/upload.d.ts +1 -1
- package/components/upload/upload.js +1 -1
- package/components/upload/upload.styles.cjs +1 -1
- package/components/upload/upload.styles.d.cts +1 -1
- package/components/upload/upload.styles.d.ts +1 -1
- package/components/upload/upload.styles.js +1 -1
- package/components/upload/upload.types.cjs +1 -1
- package/components/upload/upload.types.d.cts +1 -1
- package/components/upload/upload.types.d.ts +1 -1
- package/components/upload/upload.types.js +1 -1
- package/index.cjs +276 -276
- package/index.d.cts +4062 -3
- package/index.d.ts +4062 -3
- package/index.js +280 -280
- package/media-TFGJGBU2.js +2 -0
- package/package.json +10 -7
- package/react/components/asset/Asset.cjs +1 -1
- package/react/components/asset/Asset.jsx +1 -1
- package/react/components/side-bar/SideBar.cjs +1 -1
- package/react/components/side-bar/SideBar.jsx +1 -1
- package/react/components/upload/Upload.cjs +1 -1
- package/react/components/upload/Upload.jsx +1 -1
- package/services/audio.service.cjs +1 -1
- package/services/audio.service.d.cts +1 -1
- package/services/audio.service.d.ts +1 -1
- package/services/audio.service.js +1 -1
- package/services/conversation/conversation.service.cjs +2 -2
- package/services/conversation/conversation.service.d.cts +12 -2
- package/services/conversation/conversation.service.d.ts +12 -2
- package/services/conversation/conversation.service.js +2 -2
- package/services/conversation/conversation.types.cjs +1 -1
- package/services/conversation/conversation.types.d.cts +9 -3
- package/services/conversation/conversation.types.d.ts +9 -3
- package/services/conversation/conversation.types.js +1 -1
- package/services/conversation/index.cjs +2 -2
- package/services/conversation/index.d.cts +18 -1
- package/services/conversation/index.d.ts +18 -1
- package/services/conversation/index.js +2 -2
- package/services/conversation/mock/actor/agent.cjs +2 -0
- package/services/conversation/mock/actor/agent.d.cts +202 -0
- package/services/conversation/mock/actor/agent.d.ts +202 -0
- package/services/conversation/mock/actor/agent.js +2 -0
- package/services/conversation/mock/actor/index.cjs +2 -0
- package/services/conversation/mock/actor/index.d.cts +4 -0
- package/services/conversation/mock/actor/index.d.ts +4 -0
- package/services/conversation/mock/actor/index.js +2 -0
- package/services/conversation/mock/actor/strategies.cjs +2 -0
- package/services/conversation/mock/actor/strategies.d.cts +31 -0
- package/services/conversation/mock/actor/strategies.d.ts +31 -0
- package/services/conversation/mock/actor/strategies.js +2 -0
- package/services/conversation/mock/errors.cjs +2 -0
- package/services/conversation/mock/errors.d.cts +125 -0
- package/services/conversation/mock/errors.d.ts +125 -0
- package/services/conversation/mock/errors.js +2 -0
- package/services/conversation/mock/events.cjs +2 -0
- package/services/conversation/mock/events.d.cts +253 -0
- package/services/conversation/mock/events.d.ts +253 -0
- package/services/conversation/mock/events.js +2 -0
- package/services/conversation/mock/factory.cjs +2 -0
- package/services/conversation/mock/factory.d.cts +134 -0
- package/services/conversation/mock/factory.d.ts +134 -0
- package/services/conversation/mock/factory.js +2 -0
- package/services/conversation/mock/fixtures.cjs +2 -0
- package/services/conversation/mock/fixtures.d.cts +191 -0
- package/services/conversation/mock/fixtures.d.ts +191 -0
- package/services/conversation/mock/fixtures.js +2 -0
- package/services/conversation/mock/generators.cjs +2 -0
- package/services/conversation/mock/generators.d.cts +123 -0
- package/services/conversation/mock/generators.d.ts +123 -0
- package/services/conversation/mock/generators.js +2 -0
- package/services/conversation/mock/index.cjs +2 -0
- package/services/conversation/mock/index.d.cts +24 -0
- package/services/conversation/mock/index.d.ts +24 -0
- package/services/conversation/mock/index.js +2 -0
- package/services/conversation/mock/livekit/index.cjs +2 -0
- package/services/conversation/mock/livekit/index.d.cts +7 -0
- package/services/conversation/mock/livekit/index.d.ts +7 -0
- package/services/conversation/mock/livekit/index.js +2 -0
- package/services/conversation/mock/livekit/local-participant.cjs +2 -0
- package/services/conversation/mock/livekit/local-participant.d.cts +204 -0
- package/services/conversation/mock/livekit/local-participant.d.ts +204 -0
- package/services/conversation/mock/livekit/local-participant.js +2 -0
- package/services/conversation/mock/livekit/participant.cjs +2 -0
- package/services/conversation/mock/livekit/participant.d.cts +171 -0
- package/services/conversation/mock/livekit/participant.d.ts +171 -0
- package/services/conversation/mock/livekit/participant.js +2 -0
- package/services/conversation/mock/livekit/room.cjs +2 -0
- package/services/conversation/mock/livekit/room.d.cts +292 -0
- package/services/conversation/mock/livekit/room.d.ts +292 -0
- package/services/conversation/mock/livekit/room.js +2 -0
- package/services/conversation/mock/livekit/streams.cjs +2 -0
- package/services/conversation/mock/livekit/streams.d.cts +190 -0
- package/services/conversation/mock/livekit/streams.d.ts +190 -0
- package/services/conversation/mock/livekit/streams.js +2 -0
- package/services/conversation/mock/livekit/tracks.cjs +2 -0
- package/services/conversation/mock/livekit/tracks.d.cts +149 -0
- package/services/conversation/mock/livekit/tracks.d.ts +149 -0
- package/services/conversation/mock/livekit/tracks.js +2 -0
- package/services/conversation/mock/media.cjs +2 -0
- package/services/conversation/mock/media.d.cts +174 -0
- package/services/conversation/mock/media.d.ts +174 -0
- package/services/conversation/mock/media.js +2 -0
- package/services/conversation/mock/service.cjs +2 -0
- package/services/conversation/mock/service.d.cts +300 -0
- package/services/conversation/mock/service.d.ts +300 -0
- package/services/conversation/mock/service.js +2 -0
- package/services/conversation/mock/service.test.cjs +2 -0
- package/services/conversation/mock/service.test.d.cts +1 -0
- package/services/conversation/mock/service.test.d.ts +1 -0
- package/services/conversation/mock/service.test.js +2 -0
- package/services/conversation/mock/state.cjs +2 -0
- package/services/conversation/mock/state.d.cts +296 -0
- package/services/conversation/mock/state.d.ts +296 -0
- package/services/conversation/mock/state.js +2 -0
- package/services/conversation/mock/storybook.cjs +2 -0
- package/services/conversation/mock/storybook.d.cts +197 -0
- package/services/conversation/mock/storybook.d.ts +197 -0
- package/services/conversation/mock/storybook.js +2 -0
- package/services/conversation/mock/types.cjs +2 -0
- package/services/conversation/mock/types.d.cts +442 -0
- package/services/conversation/mock/types.d.ts +442 -0
- package/services/conversation/mock/types.js +1 -0
- package/services/faqs/faqs.service.cjs +1 -1
- package/services/faqs/faqs.service.d.cts +1 -1
- package/services/faqs/faqs.service.d.ts +1 -1
- package/services/faqs/faqs.service.js +1 -1
- package/services/faqs/faqs.types.cjs +1 -1
- package/services/faqs/faqs.types.d.cts +1 -1
- package/services/faqs/faqs.types.d.ts +1 -1
- package/services/faqs/faqs.types.js +1 -1
- package/services/faqs/index.cjs +1 -1
- package/services/faqs/index.d.cts +1 -1
- package/services/faqs/index.d.ts +1 -1
- package/services/faqs/index.js +1 -1
- package/services/file/file.service.cjs +1 -1
- package/services/file/file.service.d.cts +1 -1
- package/services/file/file.service.d.ts +1 -1
- package/services/file/file.service.js +1 -1
- package/services/file/file.types.cjs +1 -1
- package/services/file/file.types.d.cts +1 -1
- package/services/file/file.types.d.ts +1 -1
- package/services/file/file.types.js +1 -1
- package/services/file/index.cjs +1 -1
- package/services/file/index.d.cts +1 -1
- package/services/file/index.d.ts +1 -1
- package/services/file/index.js +1 -1
- package/services/firebase/firebase-api.cjs +1 -1
- package/services/firebase/firebase-api.d.cts +1 -1
- package/services/firebase/firebase-api.d.ts +1 -1
- package/services/firebase/firebase-api.js +1 -1
- package/services/multimedia/config.example.cjs +1 -1
- package/services/multimedia/config.example.d.cts +1 -1
- package/services/multimedia/config.example.d.ts +1 -1
- package/services/multimedia/config.example.js +1 -1
- package/services/multimedia/index.cjs +1 -1
- package/services/multimedia/index.d.cts +1 -1
- package/services/multimedia/index.d.ts +1 -1
- package/services/multimedia/index.js +1 -1
- package/services/multimedia/multimedia.service.cjs +1 -1
- package/services/multimedia/multimedia.service.d.cts +1 -1
- package/services/multimedia/multimedia.service.d.ts +1 -1
- package/services/multimedia/multimedia.service.js +1 -1
- package/services/multimedia/multimedia.types.cjs +1 -1
- package/services/multimedia/multimedia.types.d.cts +1 -1
- package/services/multimedia/multimedia.types.d.ts +1 -1
- package/services/multimedia/multimedia.types.js +1 -1
- package/services/product/index.cjs +1 -1
- package/services/product/index.d.cts +1 -1
- package/services/product/index.d.ts +1 -1
- package/services/product/index.js +1 -1
- package/services/product/product.service.cjs +1 -1
- package/services/product/product.service.d.cts +1 -1
- package/services/product/product.service.d.ts +1 -1
- package/services/product/product.service.js +1 -1
- package/services/product/product.types.cjs +1 -1
- package/services/product/product.types.d.cts +1 -1
- package/services/product/product.types.d.ts +1 -1
- package/services/product/product.types.js +1 -1
- package/services/request.provider.cjs +1 -1
- package/services/request.provider.d.cts +1 -1
- package/services/request.provider.d.ts +1 -1
- package/services/request.provider.js +1 -1
- package/services/session.service.cjs +1 -1
- package/services/session.service.d.cts +1 -1
- package/services/session.service.d.ts +1 -1
- package/services/session.service.js +1 -1
- package/services/upload/index.cjs +1 -1
- package/services/upload/index.d.cts +1 -1
- package/services/upload/index.d.ts +1 -1
- package/services/upload/index.js +1 -1
- package/services/upload/upload.service.cjs +1 -1
- package/services/upload/upload.service.d.cts +1 -1
- package/services/upload/upload.service.d.ts +1 -1
- package/services/upload/upload.service.js +1 -1
- package/themes/dark.cjs +13 -2
- package/themes/dark.d.cts +1 -1
- package/themes/dark.d.ts +1 -1
- package/themes/dark.js +12 -1
- package/themes/light.cjs +13 -2
- package/themes/light.d.cts +1 -1
- package/themes/light.d.ts +1 -1
- package/themes/light.js +12 -1
- package/types/globals.cjs +1 -1
- package/types/globals.d.cts +1 -1
- package/types/globals.d.ts +1 -1
- package/types/globals.js +1 -1
- package/types/tracking-options.cjs +1 -1
- package/types/tracking-options.d.cts +1 -1
- package/types/tracking-options.d.ts +1 -1
- package/types/tracking-options.js +1 -1
- package/utils/adopt-styles.cjs +1 -1
- package/utils/adopt-styles.d.cts +1 -1
- package/utils/adopt-styles.d.ts +1 -1
- package/utils/adopt-styles.js +1 -1
- package/utils/browser-preferences.cjs +1 -1
- package/utils/browser-preferences.d.cts +1 -1
- package/utils/browser-preferences.d.ts +1 -1
- package/utils/browser-preferences.js +1 -1
- package/utils/classify-media.cjs +1 -1
- package/utils/classify-media.d.cts +1 -1
- package/utils/classify-media.d.ts +1 -1
- package/utils/classify-media.js +1 -1
- package/utils/decorators.cjs +1 -1
- package/utils/decorators.d.cts +1 -1
- package/utils/decorators.d.ts +1 -1
- package/utils/decorators.js +1 -1
- package/utils/detected-lang.cjs +1 -1
- package/utils/detected-lang.d.cts +1 -1
- package/utils/detected-lang.d.ts +1 -1
- package/utils/detected-lang.js +1 -1
- package/utils/fullscreen.cjs +1 -1
- package/utils/fullscreen.d.cts +1 -1
- package/utils/fullscreen.d.ts +1 -1
- package/utils/fullscreen.js +1 -1
- package/utils/insert-script.cjs +1 -1
- package/utils/insert-script.d.cts +1 -1
- package/utils/insert-script.d.ts +1 -1
- package/utils/insert-script.js +1 -1
- package/utils/is-map-compatible.cjs +1 -1
- package/utils/is-map-compatible.d.cts +1 -1
- package/utils/is-map-compatible.d.ts +1 -1
- package/utils/is-map-compatible.js +1 -1
- package/utils/markdown.cjs +1 -1
- package/utils/markdown.d.cts +1 -1
- package/utils/markdown.d.ts +1 -1
- package/utils/markdown.js +1 -1
- package/utils/merge.cjs +1 -1
- package/utils/merge.d.cts +1 -1
- package/utils/merge.d.ts +1 -1
- package/utils/merge.js +1 -1
- package/utils/multiband-track-volume.cjs +1 -1
- package/utils/multiband-track-volume.d.cts +1 -1
- package/utils/multiband-track-volume.d.ts +1 -1
- package/utils/multiband-track-volume.js +1 -1
- package/utils/onlive-url-params.cjs +1 -1
- package/utils/onlive-url-params.d.cts +1 -1
- package/utils/onlive-url-params.d.ts +1 -1
- package/utils/onlive-url-params.js +1 -1
- package/utils/pretty-distance.cjs +1 -1
- package/utils/pretty-distance.d.cts +1 -1
- package/utils/pretty-distance.d.ts +1 -1
- package/utils/pretty-distance.js +1 -1
- package/utils/pretty-time.cjs +1 -1
- package/utils/pretty-time.d.cts +1 -1
- package/utils/pretty-time.d.ts +1 -1
- package/utils/pretty-time.js +1 -1
- package/utils/random-string.cjs +1 -1
- package/utils/random-string.d.cts +1 -1
- package/utils/random-string.d.ts +1 -1
- package/utils/random-string.js +1 -1
- package/utils/resource-type.cjs +1 -1
- package/utils/resource-type.d.cts +1 -1
- package/utils/resource-type.d.ts +1 -1
- package/utils/resource-type.js +1 -1
- package/utils/round-number.cjs +1 -1
- package/utils/round-number.d.cts +1 -1
- package/utils/round-number.d.ts +1 -1
- package/utils/round-number.js +1 -1
- package/utils/safe-html.cjs +2 -2
- package/utils/safe-html.d.cts +9 -2
- package/utils/safe-html.d.ts +9 -2
- package/utils/safe-html.js +2 -2
- package/utils/sanitize.cjs +1 -1
- package/utils/sanitize.d.cts +1 -1
- package/utils/sanitize.d.ts +1 -1
- package/utils/sanitize.js +1 -1
- package/utils/spread.cjs +1 -1
- package/utils/spread.d.cts +1 -1
- package/utils/spread.d.ts +1 -1
- package/utils/spread.js +1 -1
- package/utils/watch.cjs +1 -1
- package/utils/watch.d.cts +1 -1
- package/utils/watch.d.ts +1 -1
- package/utils/watch.js +1 -1
- package/react/components/asset/Asset.d.cts +0 -33
- package/react/components/asset/Asset.d.ts +0 -33
- package/react/components/side-bar/SideBar.d.cts +0 -37
- package/react/components/side-bar/SideBar.d.ts +0 -37
- package/react/components/upload/Upload.d.cts +0 -23
- package/react/components/upload/Upload.d.ts +0 -23
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/*! @onlive.ai/common-121 v0.2.179 | © 2026 Onlive.ai */
|
|
2
|
+
/**
|
|
3
|
+
* @file Synthetic media generators for mock LiveKit tracks.
|
|
4
|
+
* @description Generates fake video and audio MediaStreams for visual demos
|
|
5
|
+
* in Storybook without requiring real camera/microphone access.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for synthetic video generation.
|
|
9
|
+
*/
|
|
10
|
+
interface SyntheticVideoConfig {
|
|
11
|
+
/** Video width in pixels. Default: 640 */
|
|
12
|
+
width?: number;
|
|
13
|
+
/** Video height in pixels. Default: 480 */
|
|
14
|
+
height?: number;
|
|
15
|
+
/** Frames per second. Default: 30 */
|
|
16
|
+
fps?: number;
|
|
17
|
+
/** Background color. Default: '#1a1a2e' */
|
|
18
|
+
backgroundColor?: string;
|
|
19
|
+
/** Foreground/animation color. Default: '#4361ee' */
|
|
20
|
+
foregroundColor?: string;
|
|
21
|
+
/** Label to display on video. Default: 'Mock Video' */
|
|
22
|
+
label?: string;
|
|
23
|
+
/** Animation type. Default: 'wave' */
|
|
24
|
+
animation?: "wave" | "pulse" | "bars" | "avatar" | "none";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for synthetic audio generation.
|
|
28
|
+
*/
|
|
29
|
+
interface SyntheticAudioConfig {
|
|
30
|
+
/** Base frequency in Hz. Default: 440 */
|
|
31
|
+
frequency?: number;
|
|
32
|
+
/** Volume (0-1). Default: 0.1 */
|
|
33
|
+
volume?: number;
|
|
34
|
+
/** Waveform type. Default: 'sine' */
|
|
35
|
+
waveType?: OscillatorType;
|
|
36
|
+
/** Whether to add variation. Default: true */
|
|
37
|
+
addVariation?: boolean;
|
|
38
|
+
/** Enable audio (false = silent track). Default: false */
|
|
39
|
+
enabled?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates a synthetic video MediaStreamTrack using canvas.
|
|
43
|
+
*
|
|
44
|
+
* @param config - Video configuration options.
|
|
45
|
+
* @returns Object with track and cleanup function.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const { track, cleanup } = createSyntheticVideoTrack({
|
|
50
|
+
* width: 1280,
|
|
51
|
+
* height: 720,
|
|
52
|
+
* animation: 'avatar',
|
|
53
|
+
* label: 'Agent Camera',
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* videoElement.srcObject = new MediaStream([track]);
|
|
57
|
+
*
|
|
58
|
+
* // When done:
|
|
59
|
+
* cleanup();
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
declare function createSyntheticVideoTrack(config?: SyntheticVideoConfig): {
|
|
63
|
+
track: MediaStreamTrack;
|
|
64
|
+
stream: MediaStream;
|
|
65
|
+
cleanup: () => void;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Creates a synthetic audio MediaStreamTrack using Web Audio API.
|
|
69
|
+
*
|
|
70
|
+
* @param config - Audio configuration options.
|
|
71
|
+
* @returns Object with track and cleanup function.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const { track, cleanup } = createSyntheticAudioTrack({
|
|
76
|
+
* frequency: 440,
|
|
77
|
+
* volume: 0.1,
|
|
78
|
+
* enabled: true, // Set to false for silent track
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* audioElement.srcObject = new MediaStream([track]);
|
|
82
|
+
*
|
|
83
|
+
* // When done:
|
|
84
|
+
* cleanup();
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare function createSyntheticAudioTrack(config?: SyntheticAudioConfig): {
|
|
88
|
+
track: MediaStreamTrack;
|
|
89
|
+
stream: MediaStream;
|
|
90
|
+
cleanup: () => void;
|
|
91
|
+
setVolume: (volume: number) => void;
|
|
92
|
+
setEnabled: (enabled: boolean) => void;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Creates a complete mock media setup with both video and audio.
|
|
96
|
+
*
|
|
97
|
+
* @param videoConfig - Video configuration.
|
|
98
|
+
* @param audioConfig - Audio configuration.
|
|
99
|
+
* @returns Combined media setup.
|
|
100
|
+
*/
|
|
101
|
+
declare function createSyntheticMedia(videoConfig?: SyntheticVideoConfig, audioConfig?: SyntheticAudioConfig): {
|
|
102
|
+
videoTrack: MediaStreamTrack;
|
|
103
|
+
audioTrack: MediaStreamTrack;
|
|
104
|
+
combinedStream: MediaStream;
|
|
105
|
+
cleanup: () => void;
|
|
106
|
+
setAudioVolume: (volume: number) => void;
|
|
107
|
+
setAudioEnabled: (enabled: boolean) => void;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Preset configurations for common scenarios.
|
|
111
|
+
*/
|
|
112
|
+
declare const SYNTHETIC_MEDIA_PRESETS: {
|
|
113
|
+
/** Local user camera */
|
|
114
|
+
readonly localCamera: {
|
|
115
|
+
readonly video: {
|
|
116
|
+
readonly width: 640;
|
|
117
|
+
readonly height: 480;
|
|
118
|
+
readonly animation: "avatar";
|
|
119
|
+
readonly label: "You";
|
|
120
|
+
readonly foregroundColor: "#4361ee";
|
|
121
|
+
};
|
|
122
|
+
readonly audio: {
|
|
123
|
+
readonly enabled: false;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/** Remote agent camera */
|
|
127
|
+
readonly agentCamera: {
|
|
128
|
+
readonly video: {
|
|
129
|
+
readonly width: 640;
|
|
130
|
+
readonly height: 480;
|
|
131
|
+
readonly animation: "avatar";
|
|
132
|
+
readonly label: "AI Agent";
|
|
133
|
+
readonly foregroundColor: "#22c55e";
|
|
134
|
+
readonly backgroundColor: "#0f172a";
|
|
135
|
+
};
|
|
136
|
+
readonly audio: {
|
|
137
|
+
readonly enabled: false;
|
|
138
|
+
readonly frequency: 300;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
/** Screen share simulation */
|
|
142
|
+
readonly screenShare: {
|
|
143
|
+
readonly video: {
|
|
144
|
+
readonly width: 1920;
|
|
145
|
+
readonly height: 1080;
|
|
146
|
+
readonly animation: "bars";
|
|
147
|
+
readonly label: "Screen Share";
|
|
148
|
+
readonly backgroundColor: "#0a0a0a";
|
|
149
|
+
readonly foregroundColor: "#f59e0b";
|
|
150
|
+
};
|
|
151
|
+
readonly audio: {
|
|
152
|
+
readonly enabled: false;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
/** Voice-only call */
|
|
156
|
+
readonly voiceOnly: {
|
|
157
|
+
readonly video: {
|
|
158
|
+
readonly width: 320;
|
|
159
|
+
readonly height: 240;
|
|
160
|
+
readonly animation: "wave";
|
|
161
|
+
readonly label: "Voice Call";
|
|
162
|
+
};
|
|
163
|
+
readonly audio: {
|
|
164
|
+
readonly enabled: false;
|
|
165
|
+
readonly volume: 0.05;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Creates synthetic media from a preset.
|
|
171
|
+
*/
|
|
172
|
+
declare function createSyntheticMediaFromPreset(preset: keyof typeof SYNTHETIC_MEDIA_PRESETS): ReturnType<typeof createSyntheticMedia>;
|
|
173
|
+
|
|
174
|
+
export { SYNTHETIC_MEDIA_PRESETS, type SyntheticAudioConfig, type SyntheticVideoConfig, createSyntheticAudioTrack, createSyntheticMedia, createSyntheticMediaFromPreset, createSyntheticVideoTrack };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @onlive.ai/common-121 v0.2.179 | © 2026 Onlive.ai */
|
|
2
|
+
function w(u={}){let{width:a=640,height:t=480,fps:r=30,backgroundColor:c="#1a1a2e",foregroundColor:f="#4361ee",label:s="Mock Video",animation:S="wave"}=u,o=document.createElement("canvas");o.width=a,o.height=t;let e=o.getContext("2d"),d,h=Date.now(),v={wave:l=>{e.fillStyle=c,e.fillRect(0,0,a,t),e.strokeStyle=f,e.lineWidth=3,e.beginPath();for(let n=0;n<a;n++){let i=t/2+Math.sin(n/a*4*Math.PI+l*.002)*(t/4);n===0?e.moveTo(n,i):e.lineTo(n,i)}e.stroke()},pulse:l=>{e.fillStyle=c,e.fillRect(0,0,a,t);let n=Math.sin(l*.003)*.3+.7,i=Math.min(a,t)*.3*n;e.beginPath(),e.arc(a/2,t/2,i,0,Math.PI*2),e.fillStyle=f,e.fill()},bars:l=>{e.fillStyle=c,e.fillRect(0,0,a,t);let n=20,i=a/n,m=t*.7;e.fillStyle=f;for(let g=0;g<n;g++){let k=Math.abs(Math.sin(g/n*Math.PI*2+l*.004))*m,T=g*i,C=t-k;e.fillRect(T+2,C,i-4,k)}},avatar:l=>{e.fillStyle=c,e.fillRect(0,0,a,t);let n=a/2,i=t/2-20,m=Math.min(a,t)*.15;e.beginPath(),e.arc(n,i,m,0,Math.PI*2),e.fillStyle=f,e.fill(),e.beginPath(),e.ellipse(n,i+m*2.2,m*1.5,m,0,Math.PI,0),e.fill(),Math.sin(l*.01)>0&&(e.beginPath(),e.arc(n,i+m*3,5+Math.sin(l*.02)*3,0,Math.PI*2),e.fillStyle="#22c55e",e.fill())},none:()=>{e.fillStyle=c,e.fillRect(0,0,a,t)}},y=()=>{e.fillStyle="rgba(255, 255, 255, 0.8)",e.font=`${Math.floor(t*.04)}px system-ui, sans-serif`,e.textAlign="center",e.fillText(s,a/2,t-20)},b=()=>{let l=Date.now()-h;v[S](l),y(),d=requestAnimationFrame(b)};b();let p=o.captureStream(r),M=p.getVideoTracks()[0];return{track:M,stream:p,cleanup:()=>{cancelAnimationFrame(d),M.stop()}}}function x(u={}){let{frequency:a=440,volume:t=.1,waveType:r="sine",addVariation:c=!0,enabled:f=!1}=u,s=new AudioContext,S=s.createMediaStreamDestination(),o=s.createOscillator();o.type=r,o.frequency.value=a;let e=s.createGain();e.gain.value=f?t:0;let d=null,h=null;c&&(d=s.createOscillator(),d.frequency.value=.5,h=s.createGain(),h.gain.value=10,d.connect(h),h.connect(o.frequency),d.start()),o.connect(e),e.connect(S),o.start();let v=S.stream,y=v.getAudioTracks()[0];return{track:y,stream:v,setVolume:b=>{e.gain.value=Math.max(0,Math.min(1,b))},setEnabled:b=>{e.gain.value=b?t:0},cleanup:()=>{o.stop(),d?.stop(),s.close(),y.stop()}}}function A(u,a){let t=w(u),r=x(a),c=new MediaStream([t.track,r.track]);return{videoTrack:t.track,audioTrack:r.track,combinedStream:c,setAudioVolume:r.setVolume,setAudioEnabled:r.setEnabled,cleanup:()=>{t.cleanup(),r.cleanup()}}}var E={localCamera:{video:{width:640,height:480,animation:"avatar",label:"You",foregroundColor:"#4361ee"},audio:{enabled:!1}},agentCamera:{video:{width:640,height:480,animation:"avatar",label:"AI Agent",foregroundColor:"#22c55e",backgroundColor:"#0f172a"},audio:{enabled:!1,frequency:300}},screenShare:{video:{width:1920,height:1080,animation:"bars",label:"Screen Share",backgroundColor:"#0a0a0a",foregroundColor:"#f59e0b"},audio:{enabled:!1}},voiceOnly:{video:{width:320,height:240,animation:"wave",label:"Voice Call"},audio:{enabled:!1,volume:.05}}};function P(u){let a=E[u];return A(a.video,a.audio)}export{E as SYNTHETIC_MEDIA_PRESETS,x as createSyntheticAudioTrack,A as createSyntheticMedia,P as createSyntheticMediaFromPreset,w as createSyntheticVideoTrack};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @onlive.ai/common-121 v0.2.179 | © 2026 Onlive.ai */
|
|
2
|
+
"use strict";var H=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var gt=Object.prototype.hasOwnProperty;var ut=(r,t)=>()=>(r&&(t=r(r=0)),t);var X=(r,t)=>{for(var e in t)H(r,e,{get:t[e],enumerable:!0})},lt=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of dt(t))!gt.call(r,n)&&n!==e&&H(r,n,{get:()=>t[n],enumerable:!(i=ct(t,n))||i.enumerable});return r};var mt=r=>lt(H({},"__esModule",{value:!0}),r);var P={};X(P,{SYNTHETIC_MEDIA_PRESETS:()=>rt,createSyntheticAudioTrack:()=>nt,createSyntheticMedia:()=>st,createSyntheticMediaFromPreset:()=>ht,createSyntheticVideoTrack:()=>it});function it(r={}){let{width:t=640,height:e=480,fps:i=30,backgroundColor:n="#1a1a2e",foregroundColor:s="#4361ee",label:d="Mock Video",animation:o="wave"}=r,c=document.createElement("canvas");c.width=t,c.height=e;let a=c.getContext("2d"),l,S=Date.now(),C={wave:p=>{a.fillStyle=n,a.fillRect(0,0,t,e),a.strokeStyle=s,a.lineWidth=3,a.beginPath();for(let m=0;m<t;m++){let h=e/2+Math.sin(m/t*4*Math.PI+p*.002)*(e/4);m===0?a.moveTo(m,h):a.lineTo(m,h)}a.stroke()},pulse:p=>{a.fillStyle=n,a.fillRect(0,0,t,e);let m=Math.sin(p*.003)*.3+.7,h=Math.min(t,e)*.3*m;a.beginPath(),a.arc(t/2,e/2,h,0,Math.PI*2),a.fillStyle=s,a.fill()},bars:p=>{a.fillStyle=n,a.fillRect(0,0,t,e);let m=20,h=t/m,M=e*.7;a.fillStyle=s;for(let E=0;E<m;E++){let Z=Math.abs(Math.sin(E/m*Math.PI*2+p*.004))*M,ot=E*h,at=e-Z;a.fillRect(ot+2,at,h-4,Z)}},avatar:p=>{a.fillStyle=n,a.fillRect(0,0,t,e);let m=t/2,h=e/2-20,M=Math.min(t,e)*.15;a.beginPath(),a.arc(m,h,M,0,Math.PI*2),a.fillStyle=s,a.fill(),a.beginPath(),a.ellipse(m,h+M*2.2,M*1.5,M,0,Math.PI,0),a.fill(),Math.sin(p*.01)>0&&(a.beginPath(),a.arc(m,h+M*3,5+Math.sin(p*.02)*3,0,Math.PI*2),a.fillStyle="#22c55e",a.fill())},none:()=>{a.fillStyle=n,a.fillRect(0,0,t,e)}},_=()=>{a.fillStyle="rgba(255, 255, 255, 0.8)",a.font=`${Math.floor(e*.04)}px system-ui, sans-serif`,a.textAlign="center",a.fillText(d,t/2,e-20)},b=()=>{let p=Date.now()-S;C[o](p),_(),l=requestAnimationFrame(b)};b();let Y=c.captureStream(i),Q=Y.getVideoTracks()[0];return{track:Q,stream:Y,cleanup:()=>{cancelAnimationFrame(l),Q.stop()}}}function nt(r={}){let{frequency:t=440,volume:e=.1,waveType:i="sine",addVariation:n=!0,enabled:s=!1}=r,d=new AudioContext,o=d.createMediaStreamDestination(),c=d.createOscillator();c.type=i,c.frequency.value=t;let a=d.createGain();a.gain.value=s?e:0;let l=null,S=null;n&&(l=d.createOscillator(),l.frequency.value=.5,S=d.createGain(),S.gain.value=10,l.connect(S),S.connect(c.frequency),l.start()),c.connect(a),a.connect(o),c.start();let C=o.stream,_=C.getAudioTracks()[0];return{track:_,stream:C,setVolume:b=>{a.gain.value=Math.max(0,Math.min(1,b))},setEnabled:b=>{a.gain.value=b?e:0},cleanup:()=>{c.stop(),l?.stop(),d.close(),_.stop()}}}function st(r,t){let e=it(r),i=nt(t),n=new MediaStream([e.track,i.track]);return{videoTrack:e.track,audioTrack:i.track,combinedStream:n,setAudioVolume:i.setVolume,setAudioEnabled:i.setEnabled,cleanup:()=>{e.cleanup(),i.cleanup()}}}function ht(r){let t=rt[r];return st(t.video,t.audio)}var rt,w=ut(()=>{"use strict";rt={localCamera:{video:{width:640,height:480,animation:"avatar",label:"You",foregroundColor:"#4361ee"},audio:{enabled:!1}},agentCamera:{video:{width:640,height:480,animation:"avatar",label:"AI Agent",foregroundColor:"#22c55e",backgroundColor:"#0f172a"},audio:{enabled:!1,frequency:300}},screenShare:{video:{width:1920,height:1080,animation:"bars",label:"Screen Share",backgroundColor:"#0a0a0a",foregroundColor:"#f59e0b"},audio:{enabled:!1}},voiceOnly:{video:{width:320,height:240,animation:"wave",label:"Voice Call"},audio:{enabled:!1,volume:.05}}}});var kt={};X(kt,{MockConversationService:()=>W});module.exports=mt(kt);var N=0;function tt(){N=0}function g(r){return N++,`mock_${r}_${N}_${Date.now().toString(36)}`}function T(r,t,e){let i=e||new Date().toISOString(),n=typeof btoa=="function"?btoa(i).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):i.replace(/[^a-zA-Z0-9]/g,"");return`mock_token_${r}_${t}_${n}`}function et(r){return`wss://mock-livekit.local/room/${r}`}var U={responseStrategy:"echo",responseDelayMs:100,cannedResponses:[],type:"text",nature:"ai",simulateTyping:!1,typingDelayPerChar:20};function q(r,t,e=[],i=0,n=Math.random){switch(r){case"echo":return{response:`Echo: ${t}`,nextIndex:i};case"canned":return{response:e[0]||"Default response",nextIndex:i};case"sequential":return{response:e[i]||"No more responses",nextIndex:(i+1)%Math.max(1,e.length)};case"random":{if(e.length===0)return{response:"Random response",nextIndex:i};let s=Math.floor(n()*e.length);return{response:e[s],nextIndex:i}}case"silent":return{response:"",nextIndex:i};case"error":throw new Error("Agent error");case"custom":return{response:"",nextIndex:i};default:return{response:"Default agent response",nextIndex:i}}}var I=class{constructor(t,e,i={}){this._state="idle";this.conversationHistory=[];this.responseIndex=0;this.eventListeners=new Set;this.randomFn=Math.random;this.messageCount=0;this.id=t,this.name=e,this.config={...U,...i}}get state(){return this._state}get isRunning(){return this._state==="running"}get history(){return[...this.conversationHistory]}getConfig(){return{...this.config}}updateConfig(t){this.config={...this.config,...t}}setStrategy(t){this.config.responseStrategy=t}setCannedResponses(t){this.config.cannedResponses=t,this.responseIndex=0}setCustomHandler(t){this.customHandler=t,this.config.responseStrategy="custom"}setRandomFunction(t){this.randomFn=t}async start(t){this._state!=="running"&&(this._state="starting",this.roomId=t,this.conversationHistory=[],this.responseIndex=0,this.messageCount=0,await this.delay(50),this._state="running",this.emitEvent({type:"started",agentId:this.id}))}async stop(){this._state==="running"&&(this._state="stopping",await this.delay(50),this._state="stopped",this.roomId=void 0,this.emitEvent({type:"stopped",agentId:this.id}))}async processMessage(t){if(this._state!=="running")throw new Error("Agent is not running");if(this.config.maxMessages&&this.messageCount>=this.config.maxMessages)return await this.stop(),"";this.addMessage(t,"user"),this.emitEvent({type:"message_received",agentId:this.id,message:t});let e;try{if(this.config.responseStrategy==="custom"&&this.customHandler)e=await this.customHandler(this.id,t,this.conversationHistory);else{if(this.config.responseStrategy==="silent")return"";if(this.config.responseStrategy==="error"){let i=new Error("Agent error");throw this.emitEvent({type:"error",agentId:this.id,error:i}),i}else{let i=q(this.config.responseStrategy,t,this.config.cannedResponses,this.responseIndex,this.randomFn);e=i.response,this.responseIndex=i.nextIndex}}}catch(i){throw this._state="error",i}return this.config.simulateTyping&&this.config.typingDelayPerChar&&await this.delay(e.length*this.config.typingDelayPerChar),this.config.responseDelayMs&&await this.delay(this.config.responseDelayMs),this.addMessage(e,"agent"),this.messageCount++,this.emitEvent({type:"response_sent",agentId:this.id,response:e}),e}addEventListener(t){return this.eventListeners.add(t),()=>this.eventListeners.delete(t)}clearHistory(){this.conversationHistory=[],this.responseIndex=0}reset(){this._state="idle",this.roomId=void 0,this.conversationHistory=[],this.responseIndex=0,this.messageCount=0}toJSON(){return{id:this.id,name:this.name,state:this._state,roomId:this.roomId,config:this.config,historyLength:this.conversationHistory.length,messageCount:this.messageCount}}addMessage(t,e){let i={id:g("msg"),content:t,role:e,timestamp:Date.now()};return this.conversationHistory.push(i),i}emitEvent(t){for(let e of this.eventListeners)try{e(t)}catch(i){console.error("Error in agent event listener:",i)}}delay(t){return new Promise(e=>setTimeout(e,t))}};var u=class r extends Error{constructor(t,e,i){super(e),this.name="MockLiveKitError",this.code=t,this.details=i,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,r)}toMockError(){return{code:this.code,message:this.message,details:this.details}}static fromMockError(t){return new r(t.code,t.message,t.details)}},v=class extends u{constructor(t){super("ROOM_NOT_FOUND",`Room not found: ${t}`,{roomId:t}),this.name="RoomNotFoundError"}},$=class extends u{constructor(t){super("ROOM_ENDED",`Room has ended: ${t}`,{roomId:t}),this.name="RoomEndedError"}},j=class extends u{constructor(t,e){super("PARTICIPANT_ALREADY_JOINED",`Participant ${t} is already in room ${e}`,{identity:t,roomId:e}),this.name="ParticipantAlreadyJoinedError"}},F=class extends u{constructor(t){super("PARTICIPANT_NOT_FOUND",`Participant not found: ${t}`,{identity:t}),this.name="ParticipantNotFoundError"}},V=class extends u{constructor(t){super("TRACK_NOT_FOUND",`Track not found: ${t}`,{trackId:t}),this.name="TrackNotFoundError"}},K=class extends u{constructor(t){super("AGENT_NOT_FOUND",`Agent not found: ${t}`,{agentId:t}),this.name="AgentNotFoundError"}},G=class extends u{constructor(t="Unauthorized"){super("UNAUTHORIZED",t),this.name="UnauthorizedError"}},J=class extends u{constructor(t="Network error occurred"){super("NETWORK_ERROR",t),this.name="NetworkError"}},z=class extends u{constructor(t,e){super("INVALID_OPERATION",t,e),this.name="InvalidOperationError"}},B=class extends u{constructor(t,e){super("TIMEOUT",`Operation timed out: ${t}`,{operation:t,timeoutMs:e}),this.name="TimeoutError"}};function O(r){switch(r.code){case"ROOM_NOT_FOUND":return new v(r.details?.roomId??"unknown");case"ROOM_ENDED":return new $(r.details?.roomId??"unknown");case"PARTICIPANT_ALREADY_JOINED":return new j(r.details?.identity??"unknown",r.details?.roomId??"unknown");case"PARTICIPANT_NOT_FOUND":return new F(r.details?.identity??"unknown");case"TRACK_NOT_FOUND":return new V(r.details?.trackId??"unknown");case"AGENT_NOT_FOUND":return new K(r.details?.agentId??"unknown");case"UNAUTHORIZED":return new G(r.message);case"NETWORK_ERROR":return new J(r.message);case"INVALID_OPERATION":return new z(r.message,r.details);case"TIMEOUT":return new B(r.details?.operation??"unknown",r.details?.timeoutMs??0);default:return u.fromMockError(r)}}function y(r){return typeof r=="object"&&r!==null&&"code"in r&&"message"in r&&typeof r.code=="string"&&typeof r.message=="string"}var L=class{constructor(){this.listeners={};this.wildcardListeners=new Set;this.eventHistory=[];this.maxHistorySize=1e3;this.recordHistory=!0}setMaxHistorySize(t){this.maxHistorySize=t,this.trimHistory()}setRecordHistory(t){this.recordHistory=t}on(t,e){return this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),()=>{this.off(t,e)}}once(t,e){let i=n=>{this.off(t,i),e(n)};return this.on(t,i)}off(t,e){this.listeners[t]?.delete(e)}onAny(t){return this.wildcardListeners.add(t),()=>{this.wildcardListeners.delete(t)}}offAny(t){this.wildcardListeners.delete(t)}removeAllListeners(t){t?delete this.listeners[t]:(this.listeners={},this.wildcardListeners.clear())}emit(t){this.recordHistory&&(this.eventHistory.push(t),this.trimHistory());let e=this.listeners[t.type];if(e)for(let i of e)try{i(t)}catch(n){console.error(`Error in mock event listener for ${t.type}:`,n)}for(let i of this.wildcardListeners)try{i(t)}catch(n){console.error("Error in mock wildcard event listener:",n)}}trimHistory(){this.eventHistory.length>this.maxHistorySize&&(this.eventHistory=this.eventHistory.slice(-this.maxHistorySize))}emitRoomCreated(t){let e={type:"roomCreated",timestamp:new Date().toISOString(),roomId:t.id,room:t};this.emit(e)}emitRoomEnded(t){let e={type:"roomEnded",timestamp:new Date().toISOString(),roomId:t};this.emit(e)}emitRoomConnectionStateChanged(t,e,i){let n={type:"roomConnectionStateChanged",timestamp:new Date().toISOString(),roomId:t,state:e,previousState:i};this.emit(n)}emitParticipantJoined(t,e){let i={type:"participantJoined",timestamp:new Date().toISOString(),roomId:t,participant:e};this.emit(i)}emitParticipantLeft(t,e){let i={type:"participantLeft",timestamp:new Date().toISOString(),roomId:t,participantIdentity:e};this.emit(i)}emitParticipantAttributesChanged(t,e,i,n){let s={type:"participantAttributesChanged",timestamp:new Date().toISOString(),roomId:t,participantIdentity:e,attributes:i,previousAttributes:n};this.emit(s)}emitTrackPublished(t,e,i){let n={type:"trackPublished",timestamp:new Date().toISOString(),roomId:t,participantIdentity:e,track:i};this.emit(n)}emitTrackUnpublished(t,e,i){let n={type:"trackUnpublished",timestamp:new Date().toISOString(),roomId:t,participantIdentity:e,trackId:i};this.emit(n)}emitTrackMuted(t,e){let i={type:"trackMuted",timestamp:new Date().toISOString(),roomId:t,trackId:e};this.emit(i)}emitTrackUnmuted(t,e){let i={type:"trackUnmuted",timestamp:new Date().toISOString(),roomId:t,trackId:e};this.emit(i)}emitMessageReceived(t,e){let i={type:"messageReceived",timestamp:new Date().toISOString(),roomId:t,message:e};this.emit(i)}emitMessageSent(t,e){let i={type:"messageSent",timestamp:new Date().toISOString(),roomId:t,message:e};this.emit(i)}emitTypingIndicator(t,e,i){let n={type:"typingIndicator",timestamp:new Date().toISOString(),roomId:t,participantIdentity:e,isTyping:i};this.emit(n)}emitAgentStarted(t,e){let i={type:"agentStarted",timestamp:new Date().toISOString(),roomId:t,agent:e};this.emit(i)}emitAgentStopped(t,e){let i={type:"agentStopped",timestamp:new Date().toISOString(),roomId:t,agentId:e};this.emit(i)}emitAgentMessage(t,e,i){let n={type:"agentMessage",timestamp:new Date().toISOString(),roomId:t,agentId:e,message:i};this.emit(n)}emitDataReceived(t,e,i,n){let s={type:"dataReceived",timestamp:new Date().toISOString(),roomId:t,participantIdentity:e,data:i,topic:n};this.emit(s)}emitError(t,e){let i={type:"error",timestamp:new Date().toISOString(),roomId:e,error:t};this.emit(i)}getHistory(t){return t?this.eventHistory.filter(e=>e.type===t):[...this.eventHistory]}getLastEvents(t,e){return(e?this.eventHistory.filter(n=>n.type===e):this.eventHistory).slice(-t)}clearHistory(){this.eventHistory=[]}listenerCount(t){return(this.listeners[t]?.size??0)+this.wildcardListeners.size}};var f=class{constructor(t,e,i,n){this.muted=!1;this.enabled=!0;this.attachedElements=new Set;this.kind=t,this.source=e,this.sid=g("TR"),this.mediaStreamTrack=i,this.mediaCleanup=n}get mediaTrack(){return this.mediaStreamTrack}attach(t){let e=t||document.createElement(this.kind==="video"?"video":"audio");if(this.mediaStreamTrack){let i=new MediaStream([this.mediaStreamTrack]);e.srcObject=i,e.autoplay=!0,this.kind==="video"&&(e.playsInline=!0,e.muted=!0)}return this.attachedElements.add(e),e}detach(t){if(t)return t.srcObject=null,this.attachedElements.delete(t),[t];let e=Array.from(this.attachedElements);for(let i of e)i.srcObject=null;return this.attachedElements.clear(),e}stop(){this.detach(),this.mediaCleanup&&this.mediaCleanup(),this.mediaStreamTrack&&this.mediaStreamTrack.stop(),this.enabled=!1}setMuted(t){this.muted=t,this.mediaStreamTrack&&(this.mediaStreamTrack.enabled=!t)}setEnabled(t){this.enabled=t,this.mediaStreamTrack&&(this.mediaStreamTrack.enabled=t)}},k=class{constructor(t,e){this.subscribed=!0;this.isEnabled=!0;this.track=t,this.trackSid=t.sid,this.trackName=e||`${t.kind}_${t.source}`,this.source=t.source,this.kind=t.kind}get isMuted(){return this.track?.muted??!1}get isSubscribed(){return this.subscribed&&this.track!==null}setSubscribed(t){this.subscribed=t}setEnabled(t){this.isEnabled=t,this.track&&(this.track.enabled=t)}setMuted(t){this.track&&this.track.setMuted(t)}};var x=class{constructor(t){this.identity="";this.sid="";this.name="";this.attributes={};this.kind="standard";this.trackPublications=new Map;this.audioTrackPublications=new Map;this.videoTrackPublications=new Map;this._cameraEnabled=!1;this._microphoneEnabled=!1;this._screenShareEnabled=!1;this.room=t,this.sid=g("PA"),this.joinedAt=new Date}get isCameraEnabled(){return this._cameraEnabled}get isMicrophoneEnabled(){return this._microphoneEnabled}get isScreenShareEnabled(){return this._screenShareEnabled}getTrackPublications(){return Array.from(this.trackPublications.values())}getTrackPublication(t){let i={camera:"camera",Camera:"camera",microphone:"microphone",Microphone:"microphone",screen_share:"screen_share",ScreenShare:"screen_share",screen_share_audio:"screen_share_audio",ScreenShareAudio:"screen_share_audio"}[t]||t;return this.trackPublications.get(i)}getTrackPublicationBySid(t){for(let e of this.trackPublications.values())if(e.trackSid===t)return e}setAttributes(t){this.attributes={...this.attributes,...t}}async setCameraEnabled(t,e){if(this._cameraEnabled=t,t){let{createSyntheticVideoTrack:n}=await Promise.resolve().then(()=>(w(),P)),{track:s,cleanup:d}=n({animation:"avatar",label:this.name||"Local Camera"}),o=new f("video","camera",s,d),c=new k(o,e?.name);return this.trackPublications.set("camera",c),this.videoTrackPublications.set(o.sid,c),this.room.emit("localTrackPublished",c,this),c}let i=this.trackPublications.get("camera");i&&(i.track?.stop(),this.trackPublications.delete("camera"),this.videoTrackPublications.delete(i.trackSid),this.room.emit("localTrackUnpublished",i,this))}async setMicrophoneEnabled(t,e){if(this._microphoneEnabled=t,t){let{createSyntheticAudioTrack:n}=await Promise.resolve().then(()=>(w(),P)),{track:s,cleanup:d}=n({enabled:!1}),o=new f("audio","microphone",s,d),c=new k(o,e?.name);return this.trackPublications.set("microphone",c),this.audioTrackPublications.set(o.sid,c),this.room.emit("localTrackPublished",c,this),c}let i=this.trackPublications.get("microphone");i&&(i.track?.stop(),this.trackPublications.delete("microphone"),this.audioTrackPublications.delete(i.trackSid),this.room.emit("localTrackUnpublished",i,this))}async setScreenShareEnabled(t,e){if(this._screenShareEnabled=t,t){let{createSyntheticVideoTrack:n}=await Promise.resolve().then(()=>(w(),P)),{track:s,cleanup:d}=n({animation:"bars",label:"Screen Share",width:1920,height:1080}),o=new f("video","screen_share",s,d),c=new k(o,e?.name||"screen");return this.trackPublications.set("screen_share",c),this.videoTrackPublications.set(o.sid,c),this.room.emit("localTrackPublished",c,this),c}let i=this.trackPublications.get("screen_share");i&&(i.track?.stop(),this.trackPublications.delete("screen_share"),this.videoTrackPublications.delete(i.trackSid),this.room.emit("localTrackUnpublished",i,this))}async publishTrack(t,e){let i=new k(t,e?.name),n=e?.source||t.source;return this.trackPublications.set(n,i),t.kind==="audio"?this.audioTrackPublications.set(t.sid,i):t.kind==="video"&&this.videoTrackPublications.set(t.sid,i),this.room.emit("localTrackPublished",i,this),i}async unpublishTrack(t){t.stop();for(let[e,i]of this.trackPublications)if(i.track===t){this.trackPublications.delete(e),t.kind==="audio"?this.audioTrackPublications.delete(t.sid):t.kind==="video"&&this.videoTrackPublications.delete(t.sid),this.room.emit("localTrackUnpublished",i,this);break}}async sendText(t,e){return{id:g("msg")}}async publishData(t,e){}async setMetadata(t){this.attributes.metadata=t}async setName(t){this.name=t}cleanup(){for(let t of this.trackPublications.values())t.track?.stop();this.trackPublications.clear(),this.audioTrackPublications.clear(),this.videoTrackPublications.clear(),this._cameraEnabled=!1,this._microphoneEnabled=!1,this._screenShareEnabled=!1}};function pt(r){switch(r){case"standard":return 0;case"ingress":return 1;case"egress":return 2;case"sip":return 3;case"agent":return 4;default:return 0}}var R=class{constructor(t,e,i={},n="standard"){this.connectionQuality="excellent";this.isSpeaking=!1;this.audioLevel=0;this.trackPublications=new Map;this.identity=t,this.sid=g("PA"),this.name=e,this.attributes=i,this._kindString=n,this.kind=pt(n),this.joinedAt=new Date}get isAgent(){return this.kind===4||this.attributes["lk.agent.name"]!==void 0}get kindString(){return this._kindString}get isCameraEnabled(){let t=this.getTrackPublication("camera");return!!(t?.track&&!t.isMuted)}get isMicrophoneEnabled(){let t=this.getTrackPublication("microphone");return!!(t?.track&&!t.isMuted)}getTrackPublication(t){for(let e of this.trackPublications.values())if(e.source===t)return e}getTrackPublicationBySid(t){return this.trackPublications.get(t)}getTrackPublications(){return Array.from(this.trackPublications.values())}getAudioTracks(){return this.getTrackPublications().filter(t=>t.kind==="audio")}getVideoTracks(){return this.getTrackPublications().filter(t=>t.kind==="video")}addTrackPublication(t){this.trackPublications.set(t.trackSid,t)}removeTrackPublication(t){let e=this.trackPublications.get(t);return e&&(this.trackPublications.delete(t),e.track?.stop()),e}setAttributes(t){this.attributes={...this.attributes,...t}}getAttribute(t){return this.attributes[t]}startSpeaking(t=.5){this.isSpeaking=!0,this.audioLevel=t}stopSpeaking(){this.isSpeaking=!1,this.audioLevel=0}setConnectionQuality(t){this.connectionQuality=t}cleanup(){for(let t of this.trackPublications.values())t.track?.stop();this.trackPublications.clear()}};var A=class{constructor(t){this.remoteParticipants=new Map;this._state="disconnected";this.eventHandlers=new Map;this.textStreamHandlers=new Map;this.rpcHandlers=new Map;this.mockService=t,this.localParticipant=new x(this),this.sid=g("RM")}get state(){return this._state}set state(t){let e=this._state;this._state=t,e!==t&&this.emit("connectionStateChanged",t,e)}get numParticipants(){return this.remoteParticipants.size+1}get isConnected(){return this._state==="connected"}async connect(t,e){this._state="connecting",this.emit("connectionStateChanged","connecting","disconnected"),await this.mockService.simulateLatency(),this._state="connected",this.connectedAt=new Date().toISOString(),this.emit("connectionStateChanged","connected","connecting"),this.emit("connected")}async disconnect(){for(let e of this.remoteParticipants.values())e.cleanup();this.remoteParticipants.clear(),this.localParticipant.cleanup();let t=this._state;this._state="disconnected",this.emit("connectionStateChanged","disconnected",t),this.emit("disconnected"),this.eventHandlers.clear()}async reconnect(){this._state="reconnecting",this.emit("connectionStateChanged","reconnecting","connected"),await this.mockService.simulateLatency(),this._state="connected",this.emit("connectionStateChanged","connected","reconnecting"),this.emit("reconnected")}on(t,e){return this.eventHandlers.has(t)||this.eventHandlers.set(t,new Set),this.eventHandlers.get(t).add(e),this}once(t,e){let i=(...n)=>{this.off(t,i),e(...n)};return this.on(t,i)}off(t,e){return this.eventHandlers.get(t)?.delete(e),this}removeAllListeners(){this.eventHandlers.clear()}emit(t,...e){let i=this.eventHandlers.get(t);if(i)for(let n of i)try{n(...e)}catch(s){console.error(`Error in mock room event handler for ${t}:`,s)}}registerRpcMethod(t,e){this.rpcHandlers.set(t,e)}unregisterRpcMethod(t){this.rpcHandlers.delete(t)}async callRpc(t,e,i,n=1e4){let s=this.rpcHandlers.get(t);if(!s)throw new Error(`RPC method not found: ${t}`);return s({callerIdentity:e,payload:i,responseTimeout:n})}registerTextStreamHandler(t,e){this.textStreamHandlers.set(t,e)}unregisterTextStreamHandler(t){this.textStreamHandlers.delete(t)}simulateTextStream(t,e){let i=this.textStreamHandlers.get(t);i&&i(e,{identity:e.participantIdentity})}getParticipantByIdentity(t){return t===this.localParticipant.identity?new R(this.localParticipant.identity,this.localParticipant.name,this.localParticipant.attributes):this.remoteParticipants.get(t)}getParticipantBySid(t){if(t===this.localParticipant.sid)return new R(this.localParticipant.identity,this.localParticipant.name,this.localParticipant.attributes);for(let e of this.remoteParticipants.values())if(e.sid===t)return e}async simulateParticipantJoin(t,e){let i=new R(t,e?.name,e?.attributes||{},e?.kind||"standard");return this.remoteParticipants.set(t,i),this.emit("participantConnected",i),e?.withCamera&&await this.simulateRemoteTrack(t,"video","camera"),e?.withMicrophone&&await this.simulateRemoteTrack(t,"audio","microphone"),i}simulateParticipantLeave(t){let e=this.remoteParticipants.get(t);if(e){for(let i of e.getTrackPublications())i.track?.stop(),this.emit("trackUnsubscribed",i.track,i,e);this.remoteParticipants.delete(t),this.emit("participantDisconnected",e)}}async simulateRemoteTrack(t,e,i){let n=this.remoteParticipants.get(t);if(!n)return;let s,d;if(e==="video"){let{createSyntheticVideoTrack:a}=await Promise.resolve().then(()=>(w(),P)),l=a({animation:n.isAgent?"avatar":"pulse",label:n.name||t,foregroundColor:n.isAgent?"#22c55e":"#4361ee"});s=l.track,d=l.cleanup}else if(e==="audio"){let{createSyntheticAudioTrack:a}=await Promise.resolve().then(()=>(w(),P)),l=a({enabled:!1});s=l.track,d=l.cleanup}let o=new f(e,i,s,d),c=new k(o);return n.addTrackPublication(c),this.emit("trackSubscribed",o,c,n),this.emit("trackPublished",c,n),o}simulateTrackUnpublished(t,e){let i=this.remoteParticipants.get(t);if(!i)return;let n=i.getTrackPublication(e);n&&(i.removeTrackPublication(n.trackSid),this.emit("trackUnpublished",n,i),this.emit("trackUnsubscribed",n.track,n,i))}async simulateAgentJoin(t,e="AI Agent"){return this.simulateParticipantJoin(t,{name:e,kind:"agent",withCamera:!0,withMicrophone:!0,attributes:{"lk.agent.name":e,"lk.agent.state":"active"}})}simulateAttributeChange(t,e){let i=this.remoteParticipants.get(t);if(i){let n={...i.attributes};i.setAttributes(e),this.emit("participantAttributesChanged",e,n,i)}}simulateTrackMuted(t,e,i){let n=this.remoteParticipants.get(t);if(!n)return;let s=n.getTrackPublication(e);s?.track&&(s.track.setMuted(i),this.emit(i?"trackMuted":"trackUnmuted",s,n))}simulateActiveSpeakersChanged(t){let e=[];for(let i of t){let n=this.remoteParticipants.get(i);n&&(n.startSpeaking(),e.push(n))}this.emit("activeSpeakersChanged",e)}simulateDataReceived(t,e,i,n){let s=this.remoteParticipants.get(e);this.emit("dataReceived",t,s,i,n)}};var D=class{constructor(t={}){this.rooms=new Map;this.participants=new Map;this.tracks=new Map;this.agents=new Map;this.messages=new Map;this.config=t,this.randomState=t.seed??Date.now()}updateConfig(t){this.config={...this.config,...t},t.seed!==void 0&&(this.randomState=t.seed)}getConfig(){return{...this.config}}random(){return this.randomState=(this.randomState*1103515245+12345)%2147483648,this.randomState/2147483648}createRoom(t,e,i){let n=g("room"),s=new Date().toISOString(),d={id:n,name:t,groupId:e||g("group"),createdAt:s,metadata:i,isActive:!0,participantIds:[],connectionState:"disconnected",wsURL:et(n),token:T(n,"pending",s)};return this.rooms.set(n,d),this.messages.set(n,[]),d}getRoom(t){return this.rooms.get(t)}getRoomByName(t){for(let e of this.rooms.values())if(e.name===t)return e}listRooms(t=!1){let e=Array.from(this.rooms.values());return t?e.filter(i=>i.isActive):e}updateRoomConnectionState(t,e){let i=this.rooms.get(t);if(!i)return;let n=i.connectionState;return i.connectionState=e,n}endRoom(t){let e=this.rooms.get(t);if(!e||!e.isActive)return!1;e.isActive=!1,e.endedAt=new Date().toISOString(),e.connectionState="disconnected";for(let i of e.participantIds){let n=this.participants.get(i);n&&(n.isConnected=!1)}for(let i of this.agents.values())i.roomId===t&&i.status==="running"&&(i.status="stopped",i.stoppedAt=new Date().toISOString());return!0}deleteRoom(t){let e=this.rooms.get(t);if(!e)return!1;for(let i of e.participantIds)this.participants.delete(i);for(let[i,n]of this.tracks)n.roomId===t&&this.tracks.delete(i);for(let[i,n]of this.agents)n.roomId===t&&this.agents.delete(i);return this.messages.delete(t),this.rooms.delete(t),!0}addParticipant(t,e,i,n="user",s="standard",d=!1){let o=this.rooms.get(t);if(!o)return this.createError("ROOM_NOT_FOUND",`Room ${t} not found`);if(!o.isActive)return this.createError("ROOM_ENDED",`Room ${t} has ended`);let c=this.participants.get(e);if(c&&c.roomId===t&&c.isConnected)return this.config.strictMode?this.createError("PARTICIPANT_ALREADY_JOINED",`Participant ${e} is already in room ${t}`):c;let a={identity:e,name:i||e,roomId:t,joinedAt:new Date().toISOString(),isConnected:!0,trackIds:[],role:n,attributes:{},kind:s,isLocal:d};return this.participants.set(e,a),o.participantIds.push(e),a}getParticipant(t){return this.participants.get(t)}listParticipants(t,e=!0){let i=this.rooms.get(t);if(!i)return[];let n=[];for(let s of i.participantIds){let d=this.participants.get(s);d&&(!e||d.isConnected)&&n.push(d)}return n}updateParticipantAttributes(t,e){let i=this.participants.get(t);if(!i)return;let n={...i.attributes};return i.attributes={...i.attributes,...e},n}removeParticipant(t){let e=this.participants.get(t);if(!e)return;e.isConnected=!1;for(let n of e.trackIds)this.tracks.delete(n);e.trackIds=[];let i=this.rooms.get(e.roomId);if(i){let n=i.participantIds.indexOf(t);n!==-1&&i.participantIds.splice(n,1)}return e}publishTrack(t,e,i="unknown",n){let s=this.participants.get(t);if(!s)return this.createError("PARTICIPANT_NOT_FOUND",`Participant ${t} not found`);if(!s.isConnected)return this.createError("INVALID_OPERATION",`Participant ${t} is not connected`);let d=this.rooms.get(s.roomId);if(!d||!d.isActive)return this.createError("ROOM_ENDED","Room is not active");let o=g("track"),c={id:o,kind:e,source:i,participantIdentity:t,roomId:s.roomId,publishedAt:new Date().toISOString(),muted:!1,metadata:n};return this.tracks.set(o,c),s.trackIds.push(o),c}getTrack(t){return this.tracks.get(t)}listTracks(t,e){let i=[];for(let n of this.tracks.values())t&&n.roomId!==t||e&&n.participantIdentity!==e||i.push(n);return i}unpublishTrack(t){let e=this.tracks.get(t);if(!e)return;let i=this.participants.get(e.participantIdentity);if(i){let n=i.trackIds.indexOf(t);n!==-1&&i.trackIds.splice(n,1)}return this.tracks.delete(t),e}setTrackMuted(t,e){let i=this.tracks.get(t);return i?(i.muted=e,!0):!1}startAgent(t,e,i={}){let n=this.rooms.get(t);if(!n)return this.createError("ROOM_NOT_FOUND",`Room ${t} not found`);if(!n.isActive)return this.createError("ROOM_ENDED",`Room ${t} has ended`);let s=g("agent"),d={id:s,roomId:t,name:e,status:"running",startedAt:new Date().toISOString(),config:{responseStrategy:"echo",...i},messageHistory:[]};return this.agents.set(s,d),this.addParticipant(t,`agent_${s}`,e,"agent","agent",!1),d}getAgent(t){return this.agents.get(t)}listAgents(t){let e=[];for(let i of this.agents.values())i.roomId===t&&e.push(i);return e}stopAgent(t){let e=this.agents.get(t);if(e)return e.status="stopped",e.stoppedAt=new Date().toISOString(),this.removeParticipant(`agent_${t}`),e}updateAgentStatus(t,e){let i=this.agents.get(t);return i?(i.status=e,e==="stopped"&&(i.stoppedAt=new Date().toISOString()),!0):!1}addAgentMessage(t,e,i){let n=this.agents.get(t);if(!n)return;let s={id:g("msg"),content:e,role:i,timestamp:new Date().toISOString()};return n.messageHistory.push(s),s}addMessage(t,e,i,n="standard",s){if(!this.rooms.get(t))return this.createError("ROOM_NOT_FOUND",`Room ${t} not found`);let o={id:g("msg"),roomId:t,content:i,participantIdentity:e,createdAt:new Date().toISOString(),type:n,attributes:s},c=this.messages.get(t)||[];return c.push(o),this.messages.set(t,c),o}getMessages(t,e){let i=this.messages.get(t)||[];return e?i.slice(-e):i}createError(t,e,i){return{code:t,message:e,details:i}}isError(t){return typeof t=="object"&&t!==null&&"code"in t&&"message"in t}reset(){this.rooms.clear(),this.participants.clear(),this.tracks.clear(),this.agents.clear(),this.messages.clear(),this.randomState=this.config.seed??Date.now()}getSnapshot(){return{rooms:new Map(this.rooms),participants:new Map(this.participants),tracks:new Map(this.tracks),agents:new Map(this.agents),messages:new Map(this.messages),config:{...this.config},eventHistory:[]}}toJSON(){return{rooms:Object.fromEntries(this.rooms),participants:Object.fromEntries(this.participants),tracks:Object.fromEntries(this.tracks),agents:Object.fromEntries(this.agents),messages:Object.fromEntries(this.messages),config:this.config,eventHistory:[],exportedAt:new Date().toISOString()}}fromJSON(t){this.rooms=new Map(Object.entries(t.rooms)),this.participants=new Map(Object.entries(t.participants)),this.tracks=new Map(Object.entries(t.tracks)),this.agents=new Map(Object.entries(t.agents)),this.messages=new Map(Object.entries(t.messages).map(([e,i])=>[e,i])),this.config=t.config}};var W=class{constructor(t={}){this.messageListeners=new Set;this.typingListeners=new Set;this.callRequestListeners=new Map;this._authToken=null;this._registeredUser=null;this.agents=new Map;this.config={latencyMs:t.latencyMs??0,strictMode:t.strictMode??!1,seed:t.seed,scenario:t.scenario,errorConfig:t.errorConfig,autoEmitEvents:t.autoEmitEvents??!0,organizationId:t.organizationId??"mock_org",apiUrl:t.apiUrl??"https://mock-livekit.local"},this.state=new D(this.config),this.events=new L,this.room=new A(this),this.config.scenario&&this.applyScenario(this.config.scenario)}get authToken(){return this._authToken}get registeredUser(){return this._registeredUser}getState(){return this.state}getEvents(){return this.events}updateConfig(t){this.config={...this.config,...t},this.state.updateConfig(t)}getConfig(){return{...this.config}}async simulateLatency(){this.config.latencyMs&&this.config.latencyMs>0&&await new Promise(t=>setTimeout(t,this.config.latencyMs))}applyScenario(t){switch(t){case"happy_path":this.config.errorConfig={},this.config.latencyMs=0;break;case"slow_network":this.config.latencyMs=500;break;case"network_unstable":this.config.errorConfig={errorRate:30};break;default:break}}shouldThrowError(){return this.config.errorConfig?.errorRate?this.state.random()*100<this.config.errorConfig.errorRate:!1}ensureRoom(){return this.room||(this.room=new A(this)),this.room}async registerUser(t,e,i,n){if(await this.simulateLatency(),this.config.errorConfig?.unauthorized)throw new u("UNAUTHORIZED","Registration failed");let s={id:g("user"),externalId:t,organizationId:this.config.organizationId,role:"user",token:T("pending",t,new Date().toISOString())};return this._authToken=s.token,this._registeredUser=s,this.room.localParticipant.identity=t,this.room.localParticipant.name=i?.name||t,s}async registerAgent(t,e){if(await this.simulateLatency(),this.config.errorConfig?.unauthorized)throw new u("UNAUTHORIZED","Agent registration failed");let i=T("agent",t,new Date().toISOString());return this._authToken=i,this.room.localParticipant.identity=t,this.room.localParticipant.name=e.name,i}async createRoom(t,e={}){if(await this.simulateLatency(),this.config.errorConfig?.networkError||this.shouldThrowError())throw new u("NETWORK_ERROR","Failed to create room");let i=this.state.createRoom(`room_${Date.now()}`,t.affinity?.agentId,t.metadata);this.room.id=i.id,this.room.groupId=i.groupId,this.room.createdAt=i.createdAt,this.room.connectedAt=new Date().toISOString();let n=this.room.localParticipant.identity||"local_user";return this.state.addParticipant(i.id,n,this.room.localParticipant.name,"user","standard",!0),Object.keys(e).length>0&&(this.state.updateParticipantAttributes(n,e),this.room.localParticipant.setAttributes(e)),this.state.updateRoomConnectionState(i.id,"connected"),this.config.autoEmitEvents&&(this.events.emitRoomCreated(i),this.events.emitRoomConnectionStateChanged(i.id,"connected","disconnected")),(t.affinity?.agentId||t.affinity?.agentType)&&await this.startMockAgent(i.id,{type:t.affinity?.agentType,nature:t.affinity?.nature??"ai"}),await this.room.connect(i.wsURL,i.token),this.room}async joinRoom(t,e,i,n){await this.simulateLatency();let s=this.state.getRoom(t);if(!s)throw new v(t);if(!s.isActive)throw new u("ROOM_ENDED",`Room ${t} has ended`);this.room.id=s.id,this.room.groupId=s.groupId,this.room.createdAt=s.createdAt,this.room.connectedAt=new Date().toISOString();let d=this.room.localParticipant.identity||"local_user",o=this.state.addParticipant(t,d,this.room.localParticipant.name,"user","standard",!0);if(y(o))throw O(o);if(n){let c={};for(let[a,l]of Object.entries(n))c[a]=String(l);this.state.updateParticipantAttributes(d,c)}return this.state.updateRoomConnectionState(t,"connected"),this.config.autoEmitEvents&&(this.events.emitParticipantJoined(t,o),this.events.emitRoomConnectionStateChanged(t,"connected","disconnected")),await this.room.connect(s.wsURL,s.token),this.room}async evaluateRoom(t){await this.simulateLatency();let e=t.roomId||this.room?.id;if(!e)throw new u("ROOM_NOT_FOUND","No room to evaluate");let i=this.state.getRoom(e);if(!i)throw new v(e);i.metadata||(i.metadata={}),i.metadata.evaluation={rating:t.rating,comment:t.comment,evaluatedAt:new Date().toISOString()}}async closeRoom(){await this.simulateLatency(),this.room?.id&&(this.state.endRoom(this.room.id),await this.stopLocalTracks(),this.config.autoEmitEvents&&this.events.emitRoomEnded(this.room.id))}async disconnect(){if(this.room){let t=this.room.id,e=this.room.localParticipant.identity;await this.stopLocalTracks(),this.state.removeParticipant(e),this.config.autoEmitEvents&&t&&this.events.emitParticipantLeft(t,e),this.room.removeAllListeners(),await this.room.disconnect()}}async stopLocalTracks(){let t=this.room?.localParticipant;t&&await Promise.all([t.setCameraEnabled(!1),t.setMicrophoneEnabled(!1),t.setScreenShareEnabled(!1)])}async disconnectAndCloseRoom(){await this.closeRoom(),await this.disconnect()}async readRoom(t){await this.simulateLatency();let e=this.state.getRoom(t);if(!e)throw new v(t);e.metadata||(e.metadata={}),e.metadata.lastReadAt=new Date().toISOString()}async getRooms(t){await this.simulateLatency();let e=this.state.listRooms();t.roomStatus==="active"?e=e.filter(o=>o.isActive):t.roomStatus==="closed"&&(e=e.filter(o=>!o.isActive)),t.ids?.length&&(e=e.filter(o=>t.ids.includes(o.id))),t.groupId&&(e=e.filter(o=>o.groupId===t.groupId));let i=t.offset??0,n=t.limit??20;return{items:e.slice(i,i+n).map(o=>({id:o.id,name:o.name,groupId:o.groupId,organizationId:this.config.organizationId,endedAt:o.endedAt??null,createdAt:o.createdAt,updatedAt:o.createdAt,status:o.isActive?"active":"ended",participants:this.state.listParticipants(o.id).map(c=>({id:c.identity,name:c.name||c.identity,role:c.role,isLocal:c.isLocal})),evaluations:[],_count:{messages:this.state.getMessages(o.id).length,participants:o.participantIds.length}})),count:e.length,limit:n,offset:i}}async sendMessage(t,e){if(await this.simulateLatency(),!this.room?.id)throw new u("INVALID_OPERATION","Not connected to a room");let i=this.state.addMessage(this.room.id,this.room.localParticipant.identity,t,"standard",e);if(y(i))throw O(i);let n={id:i.id,timestamp:Date.now(),message:t,content:t,createdAt:i.createdAt,from:{identity:this.room.localParticipant.identity,name:this.room.localParticipant.name,id:this.room.localParticipant.identity,role:"user"}};for(let s of this.messageListeners)s([n]);this.config.autoEmitEvents&&this.events.emitMessageSent(this.room.id,i);for(let s of this.agents.values())s.isRunning&&s.roomId===this.room.id&&this.triggerAgentResponse(s,t)}async persistMessage(t){await this.simulateLatency();let e=this.state.addMessage(t.roomId,t.identity||"system",t.content);if(y(e))throw O(e);return{items:[{id:e.id,timestamp:Date.now(),message:e.content,content:e.content,createdAt:e.createdAt}],count:1,limit:1,offset:0}}async getMessages(t){await this.simulateLatency();let e=t.roomId||this.room?.id;return e?this.state.getMessages(e,t.limit).map(n=>({id:n.id,timestamp:Date.parse(n.createdAt),message:n.content,content:n.content,createdAt:n.createdAt,from:{identity:n.participantIdentity,id:n.participantIdentity,role:"user"}})):[]}async sendMessageReport(t){await this.simulateLatency()}async deleteMessageReport(t){await this.simulateLatency()}async updateMessageReactions(t){await this.simulateLatency()}subscribeMessages(t){return this.messageListeners.add(t),()=>{this.messageListeners.delete(t)}}async sendTypingIndicator(t){if(!this.room?.id)return;let e={type:"typing",isTyping:t,timestamp:Date.now(),participantId:this.room.localParticipant.identity};for(let i of this.typingListeners)i(e);this.config.autoEmitEvents&&this.events.emitTypingIndicator(this.room.id,this.room.localParticipant.identity,t)}subscribeTypingIndicators(t){return this.typingListeners.add(t),()=>this.typingListeners.delete(t)}unsubscribeTypingIndicators(t){this.typingListeners.delete(t)}async sendContextualEvent(t){await this.simulateLatency()}async requestNewRoom(t){await this.simulateLatency();let e=this.state.createRoom(`transfer_${Date.now()}`,void 0,{originRoom:t.originRoom});return{id:e.id,groupId:e.groupId,token:e.token,wsURL:e.wsURL,createdAt:e.createdAt}}async confirmRoomRequest(t){return await this.simulateLatency(),{success:!0,message:"Request confirmed",roomId:t}}async cancelRoomRequest(t){return await this.simulateLatency(),{success:!0,message:"Request cancelled",roomId:t}}async finishCall(){await this.simulateLatency(),this.room?.id&&this.state.endRoom(this.room.id)}isFirebaseEnabled(){return!0}onPresenceChange(t){return()=>{}}onPresenceAgentChange(t,e){return()=>{}}async createCallRequest(t){return await this.simulateLatency(),g("call")}onNewCallRequest(t){return this.callRequestListeners.has("new")||this.callRequestListeners.set("new",new Set),this.callRequestListeners.get("new").add(t),()=>this.callRequestListeners.get("new")?.delete(t)}onCallRequestChange(t){return this.callRequestListeners.has("change")||this.callRequestListeners.set("change",new Set),this.callRequestListeners.get("change").add(t),()=>this.callRequestListeners.get("change")?.delete(t)}onCallRequestRemoved(t){return()=>{}}async acceptCallRequest(t){await this.simulateLatency()}async cancelCallRequest(t){await this.simulateLatency()}async cancelOnDisconnect(t){await this.simulateLatency()}subscribePendingRequests(t,e={}){return()=>{}}subscribeRequestChanges(t){return()=>{}}async tryAcceptRequest(t){return await this.simulateLatency(),!0}onRoomSync(t,e){return()=>{}}async clearRoomSync(t,e){await this.simulateLatency()}onNewRoomRequest(t,e){return()=>{}}unsubscribeAllFirebase(){this.callRequestListeners.clear()}async destroy(){this.unsubscribeAllFirebase(),this.messageListeners.clear(),this.typingListeners.clear(),await this.disconnect(),this.state.reset()}async startMockAgent(t,e){let i=e?.name||"AI Assistant",n=new I(g("agent"),i,{responseStrategy:e?.responseStrategy||"echo",responseDelayMs:e?.responseDelayMs||100,cannedResponses:e?.cannedResponses||[],type:e?.type,nature:e?.nature});await n.start(t),this.agents.set(n.id,n),this.customAgentHandler&&n.setCustomHandler((a,l)=>this.customAgentHandler(a,l));let s=e?.type,d=Array.isArray(s)?s:[s].filter(Boolean),o=d.includes("video"),c=d.includes("voice");return(o||c)&&this.room.isConnected&&await this.room.simulateParticipantJoin(n.id,{name:i,kind:"agent",withCamera:o,withMicrophone:c||o,attributes:{"lk.agent.name":i,"lk.agent.state":"active",role:"agent"}}),this.config.autoEmitEvents&&this.events.emitAgentStarted(t,{id:n.id,name:n.name,roomId:t,status:"running",config:n.getConfig(),startedAt:new Date().toISOString(),messageHistory:[]}),n.id}async stopMockAgent(t){let e=this.agents.get(t);if(e){let i=e.roomId;await e.stop(),this.agents.delete(t),this.config.autoEmitEvents&&i&&this.events.emitAgentStopped(i,t)}}setAgentResponseHandler(t){this.customAgentHandler=t;for(let e of this.agents.values())e.setCustomHandler((i,n)=>t(i,n))}async triggerAgentResponse(t,e){if(this.config.scenario!=="agent_timeout")try{let i=await t.processMessage(e);if(!i)return;let n=this.state.addMessage(t.roomId,`agent_${t.id}`,i);if(!y(n)){let s={id:n.id,timestamp:Date.now(),message:i,content:i,createdAt:n.createdAt,from:{identity:`agent_${t.id}`,name:t.name,id:t.id,role:"agent"}};for(let d of this.messageListeners)d([s]);this.config.autoEmitEvents&&this.events.emitMessageReceived(t.roomId,n)}}catch(i){console.error("Agent response error:",i)}}simulateCallRequest(t){let e={id:g("call"),guestId:t.guestId||"guest_user",name:t.name||"Guest User",createdAt:new Date().toISOString(),status:t.status||"pending",...t},i=this.callRequestListeners.get("new");if(i)for(let n of i)n(e.id,e)}simulateParticipantJoin(t,e,i="user"){if(!this.room?.id)return;let n=this.state.addParticipant(this.room.id,t,e,i,"standard",!1);!y(n)&&this.config.autoEmitEvents&&this.events.emitParticipantJoined(this.room.id,n)}simulateParticipantLeave(t){if(!this.room?.id)return;this.state.removeParticipant(t)&&this.config.autoEmitEvents&&this.events.emitParticipantLeft(this.room.id,t)}simulateIncomingMessage(t,e){if(!this.room?.id)return;let i=this.state.addMessage(this.room.id,t,e);if(y(i))return;let n={id:i.id,timestamp:Date.now(),message:e,content:e,createdAt:i.createdAt,from:{identity:t,id:t,role:"user"}};for(let s of this.messageListeners)s([n]);this.config.autoEmitEvents&&this.events.emitMessageReceived(this.room.id,i)}async simulateDisconnect(){if(!this.room?.id)return;let t=this.room.state;this.room.state="disconnected",this.config.autoEmitEvents&&this.events.emitRoomConnectionStateChanged(this.room.id,"disconnected",t),this.room.emit("connectionStateChanged","disconnected")}reset(){this.state.reset(),this.events.clearHistory(),this.messageListeners.clear(),this.typingListeners.clear(),this.callRequestListeners.clear(),this.agents.clear(),this._authToken=null,this._registeredUser=null,this.room=new A(this),tt()}seed(t){this.config.seed=t,this.state.updateConfig({seed:t})}setScenario(t){this.config.scenario=t,this.applyScenario(t)}exportState(){return{...this.state.toJSON(),eventHistory:this.events.getHistory()}}getEventHistory(t){return this.events.getHistory(t)}};0&&(module.exports={MockConversationService});
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/*! @onlive.ai/common-121 v0.2.179 | © 2026 Onlive.ai */
|
|
2
|
+
import { UserApiResponse, ConversationServiceOptions, AgentData, CreateRoomOptions, EvaluateRoomOptions, GetRoomsOptions, RoomsApiResponse, PersistMessageOptions, MessagesApiResponse, GetMessagesOptions, ApiMessage, MessageReportOptions, MessageReactionOptions, MessageListener, TypingListener, ContextualEvent, RequestNewRoomOptions, RoomApiResponse, CallRequest, CallRequestListener, RoomSyncData, NewRoomRequestData } from '../conversation.types.cjs';
|
|
3
|
+
import { MockServiceConfig, MockAgentConfig, MockScenario } from './types.cjs';
|
|
4
|
+
import { MockEventEmitter } from './events.cjs';
|
|
5
|
+
import { MockRoom } from './livekit/room.cjs';
|
|
6
|
+
import { MockState } from './state.cjs';
|
|
7
|
+
import '@livekit/components-core';
|
|
8
|
+
import 'livekit-client';
|
|
9
|
+
import '../../firebase/firebase-api.cjs';
|
|
10
|
+
import 'firebase/database';
|
|
11
|
+
import './livekit/local-participant.cjs';
|
|
12
|
+
import './livekit/tracks.cjs';
|
|
13
|
+
import './livekit/participant.cjs';
|
|
14
|
+
import './livekit/streams.cjs';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @file Mock Conversation Service implementation.
|
|
18
|
+
*
|
|
19
|
+
* @summary Drop-in replacement for ConversationService that operates entirely
|
|
20
|
+
* in memory without real network calls or LiveKit infrastructure.
|
|
21
|
+
*
|
|
22
|
+
* @description Provides a complete mock implementation of ConversationService
|
|
23
|
+
* using the modular livekit/ and actor/ subsystems. Designed for unit testing,
|
|
24
|
+
* integration testing, and Storybook demonstrations.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const service = new MockConversationService({
|
|
29
|
+
* organizationId: 'test_org',
|
|
30
|
+
* latencyMs: 50,
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* await service.registerUser('user_1', 'secret', { name: 'John' });
|
|
34
|
+
* const room = await service.createRoom({ language: 'en', timezone: 'UTC' });
|
|
35
|
+
*
|
|
36
|
+
* // Send a message
|
|
37
|
+
* await service.sendMessage("Hello!");
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Mock implementation of ConversationService.
|
|
43
|
+
*
|
|
44
|
+
* @description Provides the same API as ConversationService but operates entirely
|
|
45
|
+
* in memory. Supports deterministic testing, latency simulation, and event tracking.
|
|
46
|
+
*/
|
|
47
|
+
declare class MockConversationService {
|
|
48
|
+
/** In-memory state manager */
|
|
49
|
+
private state;
|
|
50
|
+
/** Event emitter */
|
|
51
|
+
private events;
|
|
52
|
+
/** Message listeners */
|
|
53
|
+
private messageListeners;
|
|
54
|
+
/** Typing listeners */
|
|
55
|
+
private typingListeners;
|
|
56
|
+
/** Call request listeners */
|
|
57
|
+
private callRequestListeners;
|
|
58
|
+
/** Current auth token */
|
|
59
|
+
private _authToken;
|
|
60
|
+
/** Registered user data */
|
|
61
|
+
private _registeredUser;
|
|
62
|
+
/** Service configuration */
|
|
63
|
+
private config;
|
|
64
|
+
/** Active agents by ID */
|
|
65
|
+
private agents;
|
|
66
|
+
/** Custom agent response handler */
|
|
67
|
+
private customAgentHandler?;
|
|
68
|
+
/** Current mock room instance */
|
|
69
|
+
room: MockRoom;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the current auth token.
|
|
72
|
+
*/
|
|
73
|
+
get authToken(): string | null;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the registered user data.
|
|
76
|
+
*/
|
|
77
|
+
get registeredUser(): UserApiResponse | null;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a new MockConversationService.
|
|
80
|
+
*
|
|
81
|
+
* @param options - Service configuration options.
|
|
82
|
+
*/
|
|
83
|
+
constructor(options?: Partial<ConversationServiceOptions> & Partial<MockServiceConfig>);
|
|
84
|
+
/**
|
|
85
|
+
* Gets the internal state manager for testing.
|
|
86
|
+
*/
|
|
87
|
+
getState(): MockState;
|
|
88
|
+
/**
|
|
89
|
+
* Gets the event emitter for subscriptions.
|
|
90
|
+
*/
|
|
91
|
+
getEvents(): MockEventEmitter;
|
|
92
|
+
/**
|
|
93
|
+
* Updates mock configuration.
|
|
94
|
+
*/
|
|
95
|
+
updateConfig(config: Partial<MockServiceConfig>): void;
|
|
96
|
+
/**
|
|
97
|
+
* Gets current configuration.
|
|
98
|
+
*/
|
|
99
|
+
getConfig(): MockServiceConfig;
|
|
100
|
+
/**
|
|
101
|
+
* Simulates network latency.
|
|
102
|
+
*/
|
|
103
|
+
simulateLatency(): Promise<void>;
|
|
104
|
+
private applyScenario;
|
|
105
|
+
private shouldThrowError;
|
|
106
|
+
/**
|
|
107
|
+
* Ensures a room instance exists.
|
|
108
|
+
*/
|
|
109
|
+
ensureRoom(): MockRoom;
|
|
110
|
+
/**
|
|
111
|
+
* Registers a user for conversation access.
|
|
112
|
+
*/
|
|
113
|
+
registerUser(externalId: string, _secret: string, userData?: Record<string, unknown>, _metadata?: Record<string, unknown>): Promise<UserApiResponse>;
|
|
114
|
+
/**
|
|
115
|
+
* Registers an agent for handling conversations.
|
|
116
|
+
*/
|
|
117
|
+
registerAgent(externalId: string, agentData: AgentData): Promise<string>;
|
|
118
|
+
/**
|
|
119
|
+
* Creates a new conversation room.
|
|
120
|
+
*/
|
|
121
|
+
createRoom(options: CreateRoomOptions, userData?: Record<string, string>): Promise<MockRoom>;
|
|
122
|
+
/**
|
|
123
|
+
* Joins an existing conversation room.
|
|
124
|
+
*/
|
|
125
|
+
joinRoom(roomId: string, _timezone: string, _language: string, attributes?: Record<string, unknown>): Promise<MockRoom>;
|
|
126
|
+
/**
|
|
127
|
+
* Evaluates/rates the current room.
|
|
128
|
+
*/
|
|
129
|
+
evaluateRoom(options: EvaluateRoomOptions): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Closes the current room on the server.
|
|
132
|
+
*/
|
|
133
|
+
closeRoom(): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Disconnects from the current room.
|
|
136
|
+
*/
|
|
137
|
+
disconnect(): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Stops all published local tracks in the current room.
|
|
140
|
+
*/
|
|
141
|
+
private stopLocalTracks;
|
|
142
|
+
/**
|
|
143
|
+
* Closes the room and disconnects.
|
|
144
|
+
*/
|
|
145
|
+
disconnectAndCloseRoom(): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Marks a room as read.
|
|
148
|
+
*/
|
|
149
|
+
readRoom(roomId: string): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Fetches a list of rooms.
|
|
152
|
+
*/
|
|
153
|
+
getRooms(options: GetRoomsOptions): Promise<RoomsApiResponse>;
|
|
154
|
+
/**
|
|
155
|
+
* Sends a message in the current room.
|
|
156
|
+
*/
|
|
157
|
+
sendMessage(message: string, attributes?: Record<string, string>): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Persists a message to storage.
|
|
160
|
+
*/
|
|
161
|
+
persistMessage(options: PersistMessageOptions): Promise<MessagesApiResponse>;
|
|
162
|
+
/**
|
|
163
|
+
* Fetches messages.
|
|
164
|
+
*/
|
|
165
|
+
getMessages(options: GetMessagesOptions): Promise<ApiMessage[]>;
|
|
166
|
+
/**
|
|
167
|
+
* Reports a message.
|
|
168
|
+
*/
|
|
169
|
+
sendMessageReport(_options: MessageReportOptions): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Deletes a message report.
|
|
172
|
+
*/
|
|
173
|
+
deleteMessageReport(_options: MessageReportOptions): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Updates message reactions.
|
|
176
|
+
*/
|
|
177
|
+
updateMessageReactions(_options: MessageReactionOptions): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Subscribes to incoming messages.
|
|
180
|
+
*/
|
|
181
|
+
subscribeMessages<M extends ApiMessage = ApiMessage>(callback: MessageListener<M>): () => void;
|
|
182
|
+
/**
|
|
183
|
+
* Sends a typing indicator.
|
|
184
|
+
*/
|
|
185
|
+
sendTypingIndicator(isTyping: boolean): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Subscribes to typing indicators.
|
|
188
|
+
*/
|
|
189
|
+
subscribeTypingIndicators(listener: TypingListener): () => void;
|
|
190
|
+
/**
|
|
191
|
+
* Unsubscribes a typing listener.
|
|
192
|
+
*/
|
|
193
|
+
unsubscribeTypingIndicators(listener: TypingListener): void;
|
|
194
|
+
/**
|
|
195
|
+
* Sends a contextual event.
|
|
196
|
+
*/
|
|
197
|
+
sendContextualEvent(_event: ContextualEvent): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Requests a new room (call transfer).
|
|
200
|
+
*/
|
|
201
|
+
requestNewRoom(options: RequestNewRoomOptions): Promise<RoomApiResponse>;
|
|
202
|
+
/**
|
|
203
|
+
* Confirms a room request.
|
|
204
|
+
*/
|
|
205
|
+
confirmRoomRequest(roomId: string): Promise<{
|
|
206
|
+
success: boolean;
|
|
207
|
+
message: string;
|
|
208
|
+
roomId: string;
|
|
209
|
+
}>;
|
|
210
|
+
/**
|
|
211
|
+
* Cancels a room request.
|
|
212
|
+
*/
|
|
213
|
+
cancelRoomRequest(roomId: string): Promise<{
|
|
214
|
+
success: boolean;
|
|
215
|
+
message: string;
|
|
216
|
+
roomId: string;
|
|
217
|
+
}>;
|
|
218
|
+
/**
|
|
219
|
+
* Finishes an active call.
|
|
220
|
+
*/
|
|
221
|
+
finishCall(): Promise<void>;
|
|
222
|
+
isFirebaseEnabled(): boolean;
|
|
223
|
+
onPresenceChange(_callback: (agentId: string, data: object | null) => void): () => void;
|
|
224
|
+
onPresenceAgentChange(_agentId: string, _callback: (agentId: string, data: object | null) => void): () => void;
|
|
225
|
+
createCallRequest(_requestData: Omit<CallRequest, "status" | "createdAt" | "id">): Promise<string>;
|
|
226
|
+
onNewCallRequest(callback: CallRequestListener): () => void;
|
|
227
|
+
onCallRequestChange(callback: CallRequestListener): () => void;
|
|
228
|
+
onCallRequestRemoved(_callback: (id: string) => void): () => void;
|
|
229
|
+
acceptCallRequest(_requestId: string): Promise<void>;
|
|
230
|
+
cancelCallRequest(_requestId: string): Promise<void>;
|
|
231
|
+
cancelOnDisconnect(_requestId: string): Promise<void>;
|
|
232
|
+
subscribePendingRequests(_callback: CallRequestListener, _options?: {
|
|
233
|
+
resetSeen?: boolean;
|
|
234
|
+
}): () => void;
|
|
235
|
+
subscribeRequestChanges(_callback: CallRequestListener): () => void;
|
|
236
|
+
tryAcceptRequest(_requestId: string): Promise<boolean>;
|
|
237
|
+
onRoomSync(_roomId: string, _callback: (data: RoomSyncData | null) => void): () => void;
|
|
238
|
+
clearRoomSync(_roomId: string, _reason?: string): Promise<void>;
|
|
239
|
+
onNewRoomRequest(_roomId: string, _callback: (data: NewRoomRequestData | null) => void): () => void;
|
|
240
|
+
unsubscribeAllFirebase(): void;
|
|
241
|
+
destroy(): Promise<void>;
|
|
242
|
+
/**
|
|
243
|
+
* Starts a mock agent in a room.
|
|
244
|
+
*
|
|
245
|
+
* If the agent type includes "video" or "voice", the agent will also join
|
|
246
|
+
* the room as a participant with the appropriate media tracks.
|
|
247
|
+
*/
|
|
248
|
+
startMockAgent(roomId: string, config?: Partial<MockAgentConfig>): Promise<string>;
|
|
249
|
+
/**
|
|
250
|
+
* Stops a mock agent.
|
|
251
|
+
*/
|
|
252
|
+
stopMockAgent(agentId: string): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* Sets a custom agent response handler.
|
|
255
|
+
*/
|
|
256
|
+
setAgentResponseHandler(handler: (agentId: string, message: string) => string | Promise<string>): void;
|
|
257
|
+
private triggerAgentResponse;
|
|
258
|
+
/**
|
|
259
|
+
* Simulates a call request being received.
|
|
260
|
+
*/
|
|
261
|
+
simulateCallRequest(requestData: Partial<CallRequest>): void;
|
|
262
|
+
/**
|
|
263
|
+
* Simulates a participant joining.
|
|
264
|
+
*/
|
|
265
|
+
simulateParticipantJoin(identity: string, name?: string, role?: "user" | "agent"): void;
|
|
266
|
+
/**
|
|
267
|
+
* Simulates a participant leaving.
|
|
268
|
+
*/
|
|
269
|
+
simulateParticipantLeave(identity: string): void;
|
|
270
|
+
/**
|
|
271
|
+
* Simulates receiving a message.
|
|
272
|
+
*/
|
|
273
|
+
simulateIncomingMessage(participantIdentity: string, content: string): void;
|
|
274
|
+
/**
|
|
275
|
+
* Simulates room disconnection.
|
|
276
|
+
*/
|
|
277
|
+
simulateDisconnect(): Promise<void>;
|
|
278
|
+
/**
|
|
279
|
+
* Resets the mock service.
|
|
280
|
+
*/
|
|
281
|
+
reset(): void;
|
|
282
|
+
/**
|
|
283
|
+
* Seeds the random number generator.
|
|
284
|
+
*/
|
|
285
|
+
seed(seed: number): void;
|
|
286
|
+
/**
|
|
287
|
+
* Sets a predefined scenario.
|
|
288
|
+
*/
|
|
289
|
+
setScenario(scenario: MockScenario): void;
|
|
290
|
+
/**
|
|
291
|
+
* Exports current state to JSON.
|
|
292
|
+
*/
|
|
293
|
+
exportState(): object;
|
|
294
|
+
/**
|
|
295
|
+
* Gets event history.
|
|
296
|
+
*/
|
|
297
|
+
getEventHistory(filterType?: string): any[];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export { MockConversationService };
|