@elevenlabs/client 0.15.2 → 1.0.0-rc.1

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.
Files changed (160) hide show
  1. package/README.md +20 -836
  2. package/dist/BaseConversation.d.ts +10 -12
  3. package/dist/BaseConversation.d.ts.map +1 -0
  4. package/dist/BaseConversation.js +392 -0
  5. package/dist/BaseConversation.js.map +1 -0
  6. package/dist/InputController.d.ts +13 -0
  7. package/dist/InputController.d.ts.map +1 -0
  8. package/dist/InputController.js +2 -0
  9. package/dist/InputController.js.map +1 -0
  10. package/dist/OutputController.d.ts +12 -0
  11. package/dist/OutputController.d.ts.map +1 -0
  12. package/dist/OutputController.js +2 -0
  13. package/dist/OutputController.js.map +1 -0
  14. package/dist/TextConversation.d.ts +7 -0
  15. package/dist/TextConversation.d.ts.map +1 -0
  16. package/dist/TextConversation.js +53 -0
  17. package/dist/TextConversation.js.map +1 -0
  18. package/dist/VoiceConversation.d.ts +14 -12
  19. package/dist/VoiceConversation.d.ts.map +1 -0
  20. package/dist/VoiceConversation.js +225 -0
  21. package/dist/VoiceConversation.js.map +1 -0
  22. package/dist/index.d.ts +11 -6
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +20 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/internal.d.ts +8 -0
  27. package/dist/internal.d.ts.map +1 -0
  28. package/dist/internal.js +6 -0
  29. package/dist/internal.js.map +1 -0
  30. package/dist/lib.iife.js +23493 -0
  31. package/dist/lib.iife.js.map +1 -0
  32. package/dist/platform/VoiceSessionSetup.d.ts +35 -0
  33. package/dist/platform/VoiceSessionSetup.d.ts.map +1 -0
  34. package/dist/platform/VoiceSessionSetup.js +74 -0
  35. package/dist/platform/VoiceSessionSetup.js.map +1 -0
  36. package/dist/scribe/connection.d.ts +1 -0
  37. package/dist/scribe/connection.d.ts.map +1 -0
  38. package/dist/scribe/connection.js +363 -0
  39. package/dist/scribe/connection.js.map +1 -0
  40. package/dist/scribe/index.d.ts +1 -0
  41. package/dist/scribe/index.d.ts.map +1 -0
  42. package/dist/scribe/index.js +8 -0
  43. package/dist/scribe/index.js.map +1 -0
  44. package/dist/scribe/scribe.d.ts +1 -0
  45. package/dist/scribe/scribe.d.ts.map +1 -0
  46. package/dist/scribe/scribe.js +193 -0
  47. package/dist/scribe/scribe.js.map +1 -0
  48. package/dist/sourceInfo.d.ts +7 -0
  49. package/dist/sourceInfo.d.ts.map +1 -0
  50. package/dist/sourceInfo.js +9 -0
  51. package/dist/sourceInfo.js.map +1 -0
  52. package/dist/utils/BaseConnection.d.ts +2 -9
  53. package/dist/utils/BaseConnection.d.ts.map +1 -0
  54. package/dist/utils/BaseConnection.js +73 -0
  55. package/dist/utils/BaseConnection.js.map +1 -0
  56. package/dist/utils/ConnectionFactory.d.ts +1 -0
  57. package/dist/utils/ConnectionFactory.d.ts.map +1 -0
  58. package/dist/utils/ConnectionFactory.js +26 -0
  59. package/dist/utils/ConnectionFactory.js.map +1 -0
  60. package/dist/utils/WebRTCConnection.d.ts +6 -1
  61. package/dist/utils/WebRTCConnection.d.ts.map +1 -0
  62. package/dist/utils/WebRTCConnection.js +494 -0
  63. package/dist/utils/WebRTCConnection.js.map +1 -0
  64. package/dist/utils/WebSocketConnection.d.ts +8 -3
  65. package/dist/utils/WebSocketConnection.d.ts.map +1 -0
  66. package/dist/utils/WebSocketConnection.js +155 -0
  67. package/dist/utils/WebSocketConnection.js.map +1 -0
  68. package/dist/utils/applyDelay.d.ts +1 -0
  69. package/dist/utils/applyDelay.d.ts.map +1 -0
  70. package/dist/utils/applyDelay.js +18 -0
  71. package/dist/utils/applyDelay.js.map +1 -0
  72. package/dist/utils/attachConnectionToOutput.d.ts +5 -0
  73. package/dist/utils/attachConnectionToOutput.d.ts.map +1 -0
  74. package/dist/utils/attachConnectionToOutput.js +11 -0
  75. package/dist/utils/attachConnectionToOutput.js.map +1 -0
  76. package/dist/utils/attachInputToConnection.d.ts +6 -0
  77. package/dist/utils/attachInputToConnection.d.ts.map +1 -0
  78. package/dist/utils/attachInputToConnection.js +16 -0
  79. package/dist/utils/attachInputToConnection.js.map +1 -0
  80. package/dist/utils/audio.d.ts +1 -0
  81. package/dist/utils/audio.d.ts.map +1 -0
  82. package/dist/utils/audio.js +16 -0
  83. package/dist/utils/audio.js.map +1 -0
  84. package/dist/utils/audioConcatProcessor.generated.d.ts +1 -0
  85. package/dist/utils/audioConcatProcessor.generated.d.ts.map +1 -0
  86. package/{worklets/audioConcatProcessor.js → dist/utils/audioConcatProcessor.generated.js} +12 -18
  87. package/dist/utils/audioConcatProcessor.generated.js.map +1 -0
  88. package/dist/utils/compatibility.d.ts +1 -0
  89. package/dist/utils/compatibility.d.ts.map +1 -0
  90. package/dist/utils/compatibility.js +16 -0
  91. package/dist/utils/compatibility.js.map +1 -0
  92. package/dist/utils/connection.d.ts +11 -0
  93. package/dist/utils/connection.d.ts.map +1 -0
  94. package/dist/utils/connection.js +14 -0
  95. package/dist/utils/connection.js.map +1 -0
  96. package/dist/utils/createWorkletModuleLoader.d.ts +1 -0
  97. package/dist/utils/createWorkletModuleLoader.d.ts.map +1 -0
  98. package/dist/utils/createWorkletModuleLoader.js +43 -0
  99. package/dist/utils/createWorkletModuleLoader.js.map +1 -0
  100. package/dist/utils/errors.d.ts +1 -0
  101. package/dist/utils/errors.d.ts.map +1 -0
  102. package/dist/utils/errors.js +11 -0
  103. package/dist/utils/errors.js.map +1 -0
  104. package/dist/utils/events.d.ts +3 -5
  105. package/dist/utils/events.d.ts.map +1 -0
  106. package/dist/utils/events.js +4 -0
  107. package/dist/utils/events.js.map +1 -0
  108. package/dist/utils/input.d.ts +22 -11
  109. package/dist/utils/input.d.ts.map +1 -0
  110. package/dist/utils/input.js +181 -0
  111. package/dist/utils/input.js.map +1 -0
  112. package/dist/utils/location.d.ts +5 -0
  113. package/dist/utils/location.d.ts.map +1 -0
  114. package/dist/utils/location.js +31 -0
  115. package/dist/utils/location.js.map +1 -0
  116. package/dist/utils/mergeOptions.d.ts +11 -0
  117. package/dist/utils/mergeOptions.d.ts.map +1 -0
  118. package/dist/utils/mergeOptions.js +38 -0
  119. package/dist/utils/mergeOptions.js.map +1 -0
  120. package/dist/utils/output.d.ts +36 -10
  121. package/dist/utils/output.d.ts.map +1 -0
  122. package/dist/utils/output.js +127 -0
  123. package/dist/utils/output.js.map +1 -0
  124. package/dist/utils/overrides.d.ts +1 -0
  125. package/dist/utils/overrides.d.ts.map +1 -0
  126. package/dist/utils/overrides.js +40 -0
  127. package/dist/utils/overrides.js.map +1 -0
  128. package/dist/utils/postOverallFeedback.d.ts +1 -0
  129. package/dist/utils/postOverallFeedback.d.ts.map +1 -0
  130. package/dist/utils/postOverallFeedback.js +19 -0
  131. package/dist/utils/postOverallFeedback.js.map +1 -0
  132. package/dist/utils/rawAudioProcessor.generated.d.ts +1 -0
  133. package/dist/utils/rawAudioProcessor.generated.d.ts.map +1 -0
  134. package/{worklets/rawAudioProcessor.js → dist/utils/rawAudioProcessor.generated.js} +7 -1
  135. package/dist/utils/rawAudioProcessor.generated.js.map +1 -0
  136. package/dist/utils/scribeAudioProcessor.generated.d.ts +1 -0
  137. package/dist/utils/scribeAudioProcessor.generated.d.ts.map +1 -0
  138. package/{worklets/scribeAudioProcessor.js → dist/utils/scribeAudioProcessor.generated.js} +7 -1
  139. package/dist/utils/scribeAudioProcessor.generated.js.map +1 -0
  140. package/dist/version.d.ts +2 -1
  141. package/dist/version.d.ts.map +1 -0
  142. package/dist/version.js +3 -0
  143. package/dist/version.js.map +1 -0
  144. package/package.json +22 -16
  145. package/.turbo/turbo-build.log +0 -13
  146. package/.turbo/turbo-generate-version.log +0 -4
  147. package/.turbo/turbo-generate-worklets.log +0 -9
  148. package/.turbo/turbo-lint$colon$es.log +0 -6
  149. package/.turbo/turbo-lint$colon$prettier.log +0 -6
  150. package/CHANGELOG.md +0 -50
  151. package/dist/lib.cjs +0 -2
  152. package/dist/lib.cjs.map +0 -1
  153. package/dist/lib.modern.js +0 -2
  154. package/dist/lib.modern.js.map +0 -1
  155. package/dist/lib.module.js +0 -2
  156. package/dist/lib.module.js.map +0 -1
  157. package/dist/lib.umd.js +0 -2
  158. package/dist/lib.umd.js.map +0 -1
  159. package/dist/utils/addLibsamplerateModule.d.ts +0 -1
  160. package/scripts/generateWorklets.js +0 -59
@@ -0,0 +1,225 @@
1
+ import { WebRTCConnection } from "./utils/WebRTCConnection";
2
+ import { applyDelay } from "./utils/applyDelay";
3
+ import { BaseConversation, } from "./BaseConversation";
4
+ import { setupStrategy } from "./platform/VoiceSessionSetup";
5
+ export class VoiceConversation extends BaseConversation {
6
+ input;
7
+ output;
8
+ playbackEventTarget;
9
+ cleanUp;
10
+ wakeLock;
11
+ static async requestWakeLock() {
12
+ if ("wakeLock" in navigator) {
13
+ // unavailable without HTTPS, including localhost in dev
14
+ try {
15
+ return await navigator.wakeLock.request("screen");
16
+ }
17
+ catch (_e) {
18
+ // Wake Lock is not required for the conversation to work
19
+ }
20
+ }
21
+ return null;
22
+ }
23
+ static async startSession(options) {
24
+ const fullOptions = BaseConversation.getFullOptions(options);
25
+ if (fullOptions.onStatusChange) {
26
+ fullOptions.onStatusChange({ status: "connecting" });
27
+ }
28
+ if (fullOptions.onCanSendFeedbackChange) {
29
+ fullOptions.onCanSendFeedbackChange({ canSendFeedback: false });
30
+ }
31
+ let preliminaryInputStream = null;
32
+ const useWakeLock = options.useWakeLock ?? true;
33
+ let wakeLock = null;
34
+ if (useWakeLock) {
35
+ wakeLock = await VoiceConversation.requestWakeLock();
36
+ }
37
+ try {
38
+ // some browsers won't allow calling getSupportedConstraints or enumerateDevices
39
+ // before getting approval for microphone access
40
+ preliminaryInputStream = await navigator.mediaDevices.getUserMedia({
41
+ audio: true,
42
+ });
43
+ await applyDelay(fullOptions.connectionDelay);
44
+ // Platform-specific strategy creates the connection and sets up input/output
45
+ const sessionSetup = await setupStrategy(fullOptions);
46
+ // Stop the preliminary stream after setting up the session.
47
+ // Its only purpose was triggering the browser's microphone permission
48
+ // prompt; it must remain alive until the strategy finishes because
49
+ // MediaDeviceInput.create (WebSocket path) needs mic access granted.
50
+ preliminaryInputStream?.getTracks().forEach(track => {
51
+ track.stop();
52
+ });
53
+ preliminaryInputStream = null;
54
+ return new VoiceConversation(fullOptions, sessionSetup.connection, sessionSetup.input, sessionSetup.output, sessionSetup.playbackEventTarget, sessionSetup.detach, wakeLock);
55
+ }
56
+ catch (error) {
57
+ if (fullOptions.onStatusChange) {
58
+ fullOptions.onStatusChange({ status: "disconnected" });
59
+ }
60
+ preliminaryInputStream?.getTracks().forEach(track => {
61
+ track.stop();
62
+ });
63
+ try {
64
+ await wakeLock?.release();
65
+ wakeLock = null;
66
+ }
67
+ catch (_e) { }
68
+ throw error;
69
+ }
70
+ }
71
+ inputFrequencyData;
72
+ outputFrequencyData;
73
+ visibilityChangeHandler = null;
74
+ handlePlaybackEvent = event => {
75
+ if (event.data.type === "process") {
76
+ this.updateMode(event.data.finished ? "listening" : "speaking");
77
+ }
78
+ };
79
+ constructor(options, connection, input, output, playbackEventTarget, cleanUp, wakeLock) {
80
+ super(options, connection);
81
+ this.input = input;
82
+ this.output = output;
83
+ this.playbackEventTarget = playbackEventTarget;
84
+ this.cleanUp = cleanUp;
85
+ this.wakeLock = wakeLock;
86
+ playbackEventTarget?.addListener(this.handlePlaybackEvent);
87
+ if (wakeLock) {
88
+ // Wake locks are automatically released when a page is hidden like when switching tabs
89
+ // so attempt to re-acquire lock when page becomes visible again
90
+ this.visibilityChangeHandler = () => {
91
+ if (document.visibilityState === "visible" && this.wakeLock?.released) {
92
+ VoiceConversation.requestWakeLock().then(lock => {
93
+ this.wakeLock = lock;
94
+ });
95
+ }
96
+ };
97
+ document.addEventListener("visibilitychange", this.visibilityChangeHandler);
98
+ }
99
+ }
100
+ async handleEndSession() {
101
+ this.cleanUp();
102
+ this.playbackEventTarget?.removeListener(this.handlePlaybackEvent);
103
+ this.playbackEventTarget = null;
104
+ await super.handleEndSession();
105
+ if (this.visibilityChangeHandler) {
106
+ document.removeEventListener("visibilitychange", this.visibilityChangeHandler);
107
+ }
108
+ try {
109
+ await this.wakeLock?.release();
110
+ this.wakeLock = null;
111
+ }
112
+ catch (_e) { }
113
+ await this.input.close();
114
+ await this.output.close();
115
+ }
116
+ handleInterruption(event) {
117
+ super.handleInterruption(event);
118
+ this.updateMode("listening");
119
+ this.output.interrupt();
120
+ }
121
+ handleAudio(event) {
122
+ super.handleAudio(event);
123
+ if (event.audio_event.alignment && this.options.onAudioAlignment) {
124
+ this.options.onAudioAlignment(event.audio_event.alignment);
125
+ }
126
+ if (this.lastInterruptTimestamp <= event.audio_event.event_id) {
127
+ if (event.audio_event.audio_base_64) {
128
+ this.options.onAudio?.(event.audio_event.audio_base_64);
129
+ // Audio routing is handled by attachConnectionToOutput for WebSocket
130
+ // WebRTC handles audio playback directly through LiveKit tracks
131
+ }
132
+ this.currentEventId = event.audio_event.event_id;
133
+ this.updateCanSendFeedback();
134
+ this.updateMode("speaking");
135
+ }
136
+ }
137
+ calculateVolume = (frequencyData) => {
138
+ if (frequencyData.length === 0) {
139
+ return 0;
140
+ }
141
+ // TODO: Currently this averages all frequencies, but we should probably
142
+ // bias towards the frequencies that are more typical for human voice
143
+ let volume = 0;
144
+ for (let i = 0; i < frequencyData.length; i++) {
145
+ volume += frequencyData[i] / 255;
146
+ }
147
+ volume /= frequencyData.length;
148
+ return volume < 0 ? 0 : volume > 1 ? 1 : volume;
149
+ };
150
+ setMicMuted(isMuted) {
151
+ this.input.setMuted(isMuted).catch(error => {
152
+ this.options.onError?.("Failed to set input muted state", error);
153
+ });
154
+ }
155
+ getInputByteFrequencyData() {
156
+ const analyser = this.input.getAnalyser();
157
+ if (!analyser) {
158
+ throw new Error("Input analyser is not available");
159
+ }
160
+ this.inputFrequencyData ??= new Uint8Array(analyser.frequencyBinCount);
161
+ analyser.getByteFrequencyData(this.inputFrequencyData);
162
+ return this.inputFrequencyData;
163
+ }
164
+ getOutputByteFrequencyData() {
165
+ // Use WebRTC analyser if available
166
+ if (this.connection instanceof WebRTCConnection) {
167
+ const webrtcData = this.connection.getOutputByteFrequencyData();
168
+ if (webrtcData) {
169
+ return webrtcData;
170
+ }
171
+ // Fallback to empty array if WebRTC analyser not ready
172
+ return new Uint8Array(1024);
173
+ }
174
+ const analyser = this.output.getAnalyser();
175
+ if (!analyser) {
176
+ throw new Error("Output analyser is not available");
177
+ }
178
+ this.outputFrequencyData ??= new Uint8Array(analyser.frequencyBinCount);
179
+ analyser.getByteFrequencyData(this.outputFrequencyData);
180
+ return this.outputFrequencyData;
181
+ }
182
+ getInputVolume() {
183
+ return this.calculateVolume(this.getInputByteFrequencyData());
184
+ }
185
+ getOutputVolume() {
186
+ return this.calculateVolume(this.getOutputByteFrequencyData());
187
+ }
188
+ async changeInputDevice({ sampleRate, format, preferHeadphonesForIosDevices, inputDeviceId, }) {
189
+ try {
190
+ await this.input.setDevice({
191
+ inputDeviceId,
192
+ sampleRate,
193
+ format,
194
+ preferHeadphonesForIosDevices,
195
+ });
196
+ }
197
+ catch (error) {
198
+ console.error("Error changing input device", error);
199
+ throw error;
200
+ }
201
+ }
202
+ async changeOutputDevice({ sampleRate, format, outputDeviceId, }) {
203
+ try {
204
+ await this.output.setDevice({
205
+ outputDeviceId,
206
+ sampleRate,
207
+ format,
208
+ });
209
+ }
210
+ catch (error) {
211
+ console.error("Error changing output device", error);
212
+ throw error;
213
+ }
214
+ }
215
+ setVolume = ({ volume }) => {
216
+ // clamp & coerce
217
+ const clampedVolume = Number.isFinite(volume)
218
+ ? Math.min(1, Math.max(0, volume))
219
+ : 1;
220
+ this.volume = clampedVolume;
221
+ // Delegate to output controller
222
+ this.output.setVolume(clampedVolume);
223
+ };
224
+ }
225
+ //# sourceMappingURL=VoiceConversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VoiceConversation.js","sourceRoot":"","sources":["../src/VoiceConversation.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0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,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;YACpD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,EAC9B,UAAU,EACV,MAAM,EACN,cAAc,GACc;QAC5B,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;gBAC1B,cAAc;gBACd,UAAU;gBACV,MAAM;aACP,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;YACrD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEM,SAAS,GAAG,CAAC,EAAE,MAAM,EAAsB,EAAE,EAAE;QACpD,iBAAiB;QACjB,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC3C,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;YAClC,CAAC,CAAC,CAAC,CAAC;QACN,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;QAE5B,gCAAgC;QAChC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC,CAAC;CACH"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { BaseConversation, type PartialOptions } from "./BaseConversation";
1
+ import { type PartialOptions } from "./BaseConversation";
2
+ import { TextConversation } from "./TextConversation";
3
+ import { VoiceConversation } from "./VoiceConversation";
2
4
  export type { Mode, Role, Options, PartialOptions, ClientToolsConfig, Callbacks, Status, AudioWorkletConfig, } from "./BaseConversation";
5
+ export type { InputController, InputDeviceConfig } from "./InputController";
6
+ export type { OutputController, OutputDeviceConfig } from "./OutputController";
3
7
  export type { InputConfig } from "./utils/input";
4
8
  export type { OutputConfig } from "./utils/output";
5
- export { Input } from "./utils/input";
6
- export { Output } from "./utils/output";
7
9
  export type { IncomingSocketEvent, VadScoreEvent, AudioAlignmentEvent, } from "./utils/events";
8
10
  export type { SessionConfig, BaseSessionConfig, DisconnectionDetails, Language, ConnectionType, FormatConfig, } from "./utils/BaseConnection";
9
11
  export { createConnection } from "./utils/ConnectionFactory";
@@ -11,10 +13,13 @@ export { WebSocketConnection } from "./utils/WebSocketConnection";
11
13
  export { WebRTCConnection } from "./utils/WebRTCConnection";
12
14
  export { postOverallFeedback } from "./utils/postOverallFeedback";
13
15
  export { SessionConnectionError } from "./utils/errors";
16
+ export type { Location } from "./utils/location";
14
17
  export { VoiceConversation } from "./VoiceConversation";
15
18
  export { TextConversation } from "./TextConversation";
16
19
  export { Scribe, AudioFormat, CommitStrategy, RealtimeEvents, RealtimeConnection, } from "./scribe";
17
20
  export type { AudioOptions, MicrophoneOptions, WebSocketMessage, PartialTranscriptMessage, CommittedTranscriptMessage, CommittedTranscriptWithTimestampsMessage, ScribeErrorMessage, ScribeAuthErrorMessage, ScribeQuotaExceededErrorMessage, ScribeCommitThrottledErrorMessage, ScribeTranscriberErrorMessage, ScribeUnacceptedTermsErrorMessage, ScribeRateLimitedErrorMessage, ScribeInputErrorMessage, ScribeQueueOverflowErrorMessage, ScribeResourceExhaustedErrorMessage, ScribeSessionTimeLimitExceededErrorMessage, ScribeChunkSizeExceededErrorMessage, ScribeInsufficientAudioActivityErrorMessage, } from "./scribe";
18
- export declare class Conversation extends BaseConversation {
19
- static startSession(options: PartialOptions): Promise<Conversation>;
20
- }
21
+ export type Conversation = TextConversation | VoiceConversation;
22
+ export declare const Conversation: {
23
+ startSession(options: PartialOptions): Promise<Conversation>;
24
+ };
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,cAAc,E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,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,0BAA0B,EAC1B,wCAAwC,EACxC,kBAAkB,EAClB,sBAAsB,EACtB,+BAA+B,EAC/B,iCAAiC,EACjC,6BAA6B,EAC7B,iCAAiC,EACjC,6BAA6B,EAC7B,uBAAuB,EACvB,+BAA+B,EAC/B,mCAAmC,EACnC,0CAA0C,EAC1C,mCAAmC,EACnC,2CAA2C,GAC5C,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAEhE,eAAO,MAAM,YAAY;0BACD,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;CAK7D,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ import { isTextOnly } from "./BaseConversation";
2
+ import { TextConversation } from "./TextConversation";
3
+ import { VoiceConversation } from "./VoiceConversation";
4
+ export { createConnection } from "./utils/ConnectionFactory";
5
+ export { WebSocketConnection } from "./utils/WebSocketConnection";
6
+ export { WebRTCConnection } from "./utils/WebRTCConnection";
7
+ export { postOverallFeedback } from "./utils/postOverallFeedback";
8
+ export { SessionConnectionError } from "./utils/errors";
9
+ export { VoiceConversation } from "./VoiceConversation";
10
+ export { TextConversation } from "./TextConversation";
11
+ // Scribe exports
12
+ export { Scribe, AudioFormat, CommitStrategy, RealtimeEvents, RealtimeConnection, } from "./scribe";
13
+ export const Conversation = {
14
+ startSession(options) {
15
+ return isTextOnly(options)
16
+ ? TextConversation.startSession(options)
17
+ : VoiceConversation.startSession(options);
18
+ },
19
+ };
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AA6BxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,iBAAiB;AACjB,OAAO,EACL,MAAM,EACN,WAAW,EACX,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAyBlB,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,YAAY,CAAC,OAAuB;QAClC,OAAO,UAAU,CAAC,OAAO,CAAC;YACxB,CAAC,CAAC,gBAAgB,CAAC,YAAY,CAAC,OAAO,CAAC;YACxC,CAAC,CAAC,iBAAiB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { CALLBACK_KEYS } from "./BaseConversation";
2
+ export { mergeOptions } from "./utils/mergeOptions";
3
+ export { parseLocation, getOriginForLocation, getLivekitUrlForLocation, } from "./utils/location";
4
+ export { sourceInfo, setSourceInfo } from "./sourceInfo";
5
+ export type { SourceInfo } from "./sourceInfo";
6
+ export { setSetupStrategy, webSessionSetup, } from "./platform/VoiceSessionSetup";
7
+ export type { VoiceSessionSetupStrategy, VoiceSessionSetupResult, } from "./platform/VoiceSessionSetup";
8
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzD,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,eAAe,GAChB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { CALLBACK_KEYS } from "./BaseConversation";
2
+ export { mergeOptions } from "./utils/mergeOptions";
3
+ export { parseLocation, getOriginForLocation, getLivekitUrlForLocation, } from "./utils/location";
4
+ export { sourceInfo, setSourceInfo } from "./sourceInfo";
5
+ export { setSetupStrategy, webSessionSetup, } from "./platform/VoiceSessionSetup";
6
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EACL,gBAAgB,EAChB,eAAe,GAChB,MAAM,8BAA8B,CAAC"}