@pagelines/sdk 1.0.877 → 1.0.879
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -68
- package/dist/BotProvider.js +777 -0
- package/dist/BotProvider.js.map +1 -0
- package/dist/{AgentWidgetInline.js → BotWidgetInline.js} +8 -8
- package/dist/BotWidgetInline.js.map +1 -0
- package/dist/{AgentWidgetModal.js → BotWidgetModal.js} +7 -7
- package/dist/BotWidgetModal.js.map +1 -0
- package/dist/{AgentWrap.js → BotWrap.js} +1202 -1155
- package/dist/BotWrap.js.map +1 -0
- package/dist/{agent/AgentController.d.ts → bot/BotController.d.ts} +36 -18
- package/dist/bot/index.d.ts +14 -0
- package/dist/{agent → bot}/schema.d.ts +6 -6
- package/dist/{agent/ui/AgentAvatar.vue.d.ts → bot/ui/BotAvatar.vue.d.ts} +6 -6
- package/dist/{agent/ui/AgentChat.vue.d.ts → bot/ui/BotChat.vue.d.ts} +5 -5
- package/dist/{agent/ui/AgentProvider.vue.d.ts → bot/ui/BotProvider.vue.d.ts} +3 -3
- package/dist/{agent/ui/AgentWrap.vue.d.ts → bot/ui/BotWrap.vue.d.ts} +3 -4
- package/dist/{agent/ui/ElAgentAbout.vue.d.ts → bot/ui/ElBotAbout.vue.d.ts} +2 -2
- package/dist/{agent/ui/ElAgentChat.vue.d.ts → bot/ui/ElBotChat.vue.d.ts} +5 -5
- package/dist/{agent/ui/ElAgentChatPreview.vue.d.ts → bot/ui/ElBotChatPreview.vue.d.ts} +1 -1
- package/dist/{agent/ui/ElAgentHeader.vue.d.ts → bot/ui/ElBotHeader.vue.d.ts} +2 -2
- package/dist/{agent/ui/ElAgentModeSidebar.vue.d.ts → bot/ui/ElBotModeSidebar.vue.d.ts} +2 -2
- package/dist/{agent/ui/ElAgentSidebar.vue.d.ts → bot/ui/ElBotSidebar.vue.d.ts} +2 -2
- package/dist/bot/ui/ElCreateBot.vue.d.ts +12 -0
- package/dist/{agent → bot}/ui/ElModeHeader.vue.d.ts +2 -2
- package/dist/{agent → bot}/ui/ElProvisioningStatus.vue.d.ts +1 -1
- package/dist/{agent → bot}/ui/VoiceMode.vue.d.ts +4 -4
- package/dist/{agent → bot}/utils.d.ts +5 -5
- package/dist/{agent → bot}/voice/provider.d.ts +2 -2
- package/dist/{agent → bot}/voice/providers/livekit/provider.d.ts +8 -7
- package/dist/{agent → bot}/voice/voice-session-client.d.ts +2 -1
- package/dist/{agent → bot}/work-journal.d.ts +1 -1
- package/dist/{agent.js → bot.js} +89 -84
- package/dist/bot.js.map +1 -0
- package/dist/clients/BillingClient.d.ts +1 -1
- package/dist/clients/BotClient.d.ts +26 -0
- package/dist/clients/ChatClient.d.ts +6 -5
- package/dist/clients/ComputerClient.d.ts +16 -0
- package/dist/clients/UserClient.d.ts +4 -7
- package/dist/clients/types.d.ts +7 -2
- package/dist/contract/build.d.ts +1 -2
- package/dist/index.d.ts +3 -2
- package/dist/provider.js +1 -1
- package/dist/provider.js.map +1 -1
- package/dist/provider2.js +28 -36
- package/dist/provider2.js.map +1 -1
- package/dist/sdk.css +1 -1
- package/dist/sdk.js +4 -4
- package/dist/sdkClient.d.ts +33 -376
- package/dist/sdkClient.js +168 -170
- package/dist/sdkClient.js.map +1 -1
- package/dist/useWidgetState.js +9 -9
- package/dist/useWidgetState.js.map +1 -1
- package/dist/widget/PLWidget.d.ts +6 -6
- package/dist/widget/composables/useWidgetState.d.ts +3 -402
- package/dist/widget/index.d.ts +2 -2
- package/dist/widget/mode.d.ts +2 -2
- package/dist/widget/ui/{AgentWidgetInline.vue.d.ts → BotWidgetInline.vue.d.ts} +2 -2
- package/dist/widget/ui/{AgentWidgetModal.vue.d.ts → BotWidgetModal.vue.d.ts} +2 -2
- package/dist/widget/ui/{AgentWidgetPopup.vue.d.ts → BotWidgetPopup.vue.d.ts} +4 -4
- package/dist/widget.js +206 -206
- package/dist/widget.js.map +1 -1
- package/package.json +5 -5
- package/dist/AgentProvider.js +0 -764
- package/dist/AgentProvider.js.map +0 -1
- package/dist/AgentWidgetInline.js.map +0 -1
- package/dist/AgentWidgetModal.js.map +0 -1
- package/dist/AgentWrap.js.map +0 -1
- package/dist/agent/index.d.ts +0 -14
- package/dist/agent/ui/ElCreateAgent.vue.d.ts +0 -277
- package/dist/agent.js.map +0 -1
- package/dist/clients/AgentClient.d.ts +0 -48
- /package/dist/{agent → bot}/VoiceRecorderController.d.ts +0 -0
- /package/dist/{agent/ui/AgentInputEmail.vue.d.ts → bot/ui/BotInputEmail.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentInputOneTimeCode.vue.d.ts → bot/ui/BotInputOneTimeCode.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentSidebarClose.vue.d.ts → bot/ui/BotSidebarClose.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentToolActivityGroup.vue.d.ts → bot/ui/BotToolActivityGroup.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentWidget.vue.d.ts → bot/ui/BotWidget.vue.d.ts} +0 -0
- /package/dist/{agent → bot}/ui/ChatCardBlock.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ChatRichText.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ChatScroller.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ChatVisualBlock.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ElAuthGate.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ElAuthPanel.vue.d.ts +0 -0
- /package/dist/{agent/ui/ElAgentButton.vue.d.ts → bot/ui/ElBotButton.vue.d.ts} +0 -0
- /package/dist/{agent → bot}/ui/ElSidebar.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/VoiceHistogramController.d.ts +0 -0
- /package/dist/{agent → bot}/ui/chat-diagram-layout.d.ts +0 -0
- /package/dist/{agent → bot}/ui/chat-visual-format.d.ts +0 -0
- /package/dist/{agent → bot}/ui/voice-mode-presentation.d.ts +0 -0
- /package/dist/{agent → bot}/voice/voice-error-copy.d.ts +0 -0
- /package/dist/{agent → bot}/voice/voice-work-state.d.ts +0 -0
- /package/dist/widget/ui/{AgentWidgetOnboard.vue.d.ts → BotWidgetOnboard.vue.d.ts} +0 -0
package/dist/clients/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bot, BotData, ComputerData, ApiResponse, EnrichedUser, LogHelper } from '@pagelines/core';
|
|
2
2
|
import { ComputedRef, Ref } from 'vue';
|
|
3
3
|
import { SDKStorage } from '../sdkStorage';
|
|
4
4
|
export interface SDKContext {
|
|
@@ -9,7 +9,12 @@ export interface SDKContext {
|
|
|
9
9
|
token: Ref<string | null>;
|
|
10
10
|
loading: Ref<boolean>;
|
|
11
11
|
error: Ref<string | null>;
|
|
12
|
-
|
|
12
|
+
currentBot: ComputedRef<Bot | undefined>;
|
|
13
|
+
hydrateRoster: (roster: {
|
|
14
|
+
computers: ComputerData[];
|
|
15
|
+
bots: BotData[];
|
|
16
|
+
}) => Bot[];
|
|
17
|
+
clearRoster: () => void;
|
|
13
18
|
storage: SDKStorage;
|
|
14
19
|
sessionId: string;
|
|
15
20
|
logger: LogHelper;
|
package/dist/contract/build.d.ts
CHANGED
|
@@ -25,8 +25,7 @@ export interface WireContract {
|
|
|
25
25
|
*
|
|
26
26
|
* Schema discovery walks every export of `@pagelines/core`, picks values
|
|
27
27
|
* that are Zod schemas, and derives the contract name from the export
|
|
28
|
-
* name (`
|
|
29
|
-
* `EnrichedAgent`). `*Wire` namespace exports get the same treatment for
|
|
28
|
+
* name (`zComputer` → `Computer`). `*Wire` namespace exports get the same treatment for
|
|
30
29
|
* their immediate children. Anything else is ignored — types, constants
|
|
31
30
|
* like `ERROR_CODES`, helper functions all skip naturally.
|
|
32
31
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { PageLinesSDK } from './sdkClient';
|
|
2
2
|
export { PageLinesSDK };
|
|
3
3
|
export type { PageLinesSDKSettings } from './sdkClient';
|
|
4
|
-
export {
|
|
4
|
+
export { BotClient } from './clients/BotClient';
|
|
5
|
+
export { ComputerClient } from './clients/ComputerClient';
|
|
5
6
|
export { AuthClient } from './clients/AuthClient';
|
|
6
7
|
export { BillingClient } from './clients/BillingClient';
|
|
7
8
|
export { ChatClient } from './clients/ChatClient';
|
|
8
9
|
export { UserClient } from './clients/UserClient';
|
|
9
10
|
export type { SDKContext } from './clients/types';
|
|
10
11
|
export { MediaSchema } from '@pagelines/core';
|
|
11
|
-
export type {
|
|
12
|
+
export type { Bot, User, EnrichedUser, MediaObject, ApiResponse, } from '@pagelines/core';
|
|
12
13
|
export { SOCIAL_PLATFORMS } from './constants/socialPlatforms';
|
|
13
14
|
export type { SocialPlatform } from './constants/socialPlatforms';
|
package/dist/provider.js
CHANGED
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","names":[],"sources":["../
|
|
1
|
+
{"version":3,"file":"provider.js","names":[],"sources":["../bot/voice/provider.ts"],"sourcesContent":["import type { VoiceSessionMint } from '@pagelines/core'\n\nexport interface VoiceLevelEvent {\n source: 'mic' | 'playback'\n /** Normalized 0..1 signal level. */\n level: number\n /** Speech-spectrum energies, low pitch first. */\n bands?: readonly number[]\n}\n\n/** One speech/noise boundary shared by audible UI state and work-cue ducking. */\nexport function isVoiceAudible(level: number): boolean {\n return level >= 0.08\n}\n\nexport interface VoiceSessionError {\n code: string\n message: string\n}\n\nexport type VoiceDisconnectCause = 'bot' | 'error' | 'network' | 'unknown'\n\n/**\n * Who the transport says is talking. Raw energy is not a speech signal — room\n * tone and the speaker's own playback both read as audible — so ducking,\n * tone, and which meter the surface follows come from here.\n */\nexport interface VoiceSpeakingState {\n user: boolean\n bot: boolean\n}\n\nexport interface VoiceProviderClient {\n connect: (handlers: {\n onDisconnected: (cause: VoiceDisconnectCause) => void\n onError: (error: VoiceSessionError) => void\n onThinkingChange?: (thinking: boolean) => void\n onSpeakingChange?: (state: VoiceSpeakingState) => void\n }) => Promise<void>\n disconnect: () => Promise<void>\n /** Loudest source by default; `prefer` pins a meter while someone is known to be speaking. */\n sampleLevel: (prefer?: VoiceLevelEvent['source']) => VoiceLevelEvent | undefined\n /** Self-mute without ending the live session. */\n setMuted?: (muted: boolean) => Promise<void>\n /**\n * Hand the provider text the caller typed during a live call, as though\n * they had said it — the assistant answers aloud and the turn lands in the\n * transcript through the normal provider path. Optional: a provider that\n * cannot inject text simply omits it and the surface hides the affordance.\n */\n sendUserMessage?: (text: string) => void\n}\n\nexport type CreateVoiceProviderClient = (mint: VoiceSessionMint) => Promise<VoiceProviderClient>\n\n/** Keep the realtime SDK out of the initial chat bundle. */\nexport const createVoiceProviderClient: CreateVoiceProviderClient = async (mint) => {\n const { LiveKitVoiceProvider } = await import('./providers/livekit/provider')\n return new LiveKitVoiceProvider(mint)\n}\n\nexport const VOICE_SPECTRUM_BANDS = 9\n\n/** Log-spaced speech spectrum for transports that expose FFT bins. */\nexport function voiceSpectrum(frequencies: Uint8Array, sampleRate: number, fftSize: number, bandCount = VOICE_SPECTRUM_BANDS): readonly number[] {\n if (!Number.isFinite(sampleRate) || sampleRate <= 0 || !Number.isFinite(fftSize) || fftSize <= 0 || bandCount <= 0)\n return []\n\n const hzPerBin = sampleRate / fftSize\n const fromHz = 80\n const ratio = 4_000 / fromHz\n const bands: number[] = []\n for (let band = 0; band < bandCount; band++) {\n const start = Math.max(0, Math.ceil((fromHz * ratio ** (band / bandCount)) / hzPerBin))\n const end = Math.min(frequencies.length, Math.ceil((fromHz * ratio ** ((band + 1) / bandCount)) / hzPerBin))\n if (end <= start) {\n bands.push(0)\n continue\n }\n let squared = 0\n for (let index = start; index < end; index++)\n squared += (frequencies[index] / 255) ** 2\n bands.push(Math.sqrt(squared / (end - start)))\n }\n return bands\n}\n\n/** Equal-width bands for SDKs that already expose voice-range FFT bins. */\nexport function voiceRangeSpectrum(frequencies: Uint8Array, bandCount = VOICE_SPECTRUM_BANDS): readonly number[] {\n if (!frequencies.length || bandCount <= 0)\n return []\n return Array.from({ length: bandCount }, (_, band) => {\n const start = Math.floor((band * frequencies.length) / bandCount)\n const end = Math.max(start + 1, Math.floor(((band + 1) * frequencies.length) / bandCount))\n let squared = 0\n for (let index = start; index < Math.min(end, frequencies.length); index++)\n squared += (frequencies[index] / 255) ** 2\n return Math.sqrt(squared / Math.max(1, Math.min(end, frequencies.length) - start))\n })\n}\n"],"mappings":";;AAWA,SAAgB,eAAe,GAAwB;CACrD,OAAO,KAAS;AAClB;AA2CA,IAAa,4BAAuD,OAAO,MAAS;CAClF,IAAM,EAAE,4BAAyB,MAAM,OAAO;CAC9C,OAAO,IAAI,EAAqB,CAAI;AACtC;AAKA,SAAgB,cAAc,GAAyB,GAAoB,GAAiB,IAAA,GAAqD;CAC/I,IAAI,CAAC,OAAO,SAAS,CAAU,KAAK,KAAc,KAAK,CAAC,OAAO,SAAS,CAAO,KAAK,KAAW,KAAK,KAAa,GAC/G,OAAO,CAAC;CAEV,IAAM,IAAW,IAAa,GAGxB,IAAkB,CAAC;CACzB,KAAK,IAAI,IAAO,GAAG,IAAO,GAAW,KAAQ;EAC3C,IAAM,IAAQ,KAAK,IAAI,GAAG,KAAK,KAAM,KAAS,OAAU,IAAO,KAAc,CAAQ,CAAC,GAChF,IAAM,KAAK,IAAI,EAAY,QAAQ,KAAK,KAAM,KAAS,QAAW,IAAO,KAAK,KAAc,CAAQ,CAAC;EAC3G,IAAI,KAAO,GAAO;GAChB,EAAM,KAAK,CAAC;GACZ;EACF;EACA,IAAI,IAAU;EACd,KAAK,IAAI,IAAQ,GAAO,IAAQ,GAAK,KACnC,MAAY,EAAY,KAAS,QAAQ;EAC3C,EAAM,KAAK,KAAK,KAAK,KAAW,IAAM,EAAM,CAAC;CAC/C;CACA,OAAO;AACT"}
|
package/dist/provider2.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./rolldown-runtime.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as e } from "./sdkClient.js";
|
|
3
3
|
import { r as t } from "./provider.js";
|
|
4
4
|
//#region ../../node_modules/.pnpm/livekit-client@2.21.0_@types+dom-mediacapture-record@1.0.22/node_modules/livekit-client/dist/livekit-client.esm.mjs
|
|
5
5
|
function _mergeNamespaces(e, t) {
|
|
@@ -18330,60 +18330,51 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
|
|
|
18330
18330
|
};
|
|
18331
18331
|
_defineProperty(JWSSignatureVerificationFailed, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
|
|
18332
18332
|
//#endregion
|
|
18333
|
-
//#region
|
|
18334
|
-
var $a = 1e4, eo = "lk.
|
|
18333
|
+
//#region bot/voice/providers/livekit/provider.ts
|
|
18334
|
+
var $a = 1e4, eo = "lk.bot.state", LiveKitVoiceProvider = class {
|
|
18335
18335
|
constructor(t, n = {}) {
|
|
18336
|
-
e(this, "mint", void 0), e(this, "room", void 0), e(this, "createAnalyser", void 0), e(this, "handlers", void 0), e(this, "cancelReadyWait", void 0), e(this, "analysers", []), e(this, "levelSources", []), e(this, "attachedElements", []), e(this, "closing", !1), e(this, "userSpeaking", !1), e(this, "
|
|
18336
|
+
e(this, "mint", void 0), e(this, "room", void 0), e(this, "createAnalyser", void 0), e(this, "handlers", void 0), e(this, "cancelReadyWait", void 0), e(this, "analysers", []), e(this, "levelSources", []), e(this, "attachedElements", []), e(this, "closing", !1), e(this, "userSpeaking", !1), e(this, "botActiveSpeaker", !1), e(this, "botStateSpeaking", !1), e(this, "lastSpeaking", void 0), this.mint = t, this.room = n.createRoom?.() ?? new Za(), this.createAnalyser = n.createAnalyser;
|
|
18337
18337
|
}
|
|
18338
18338
|
async connect(e) {
|
|
18339
18339
|
this.handlers = e, this.room.on(P.TrackSubscribed, (e) => {
|
|
18340
18340
|
e.kind === z.Kind.Audio && this.attachRemoteAudio(e);
|
|
18341
18341
|
}), this.room.on(P.ParticipantAttributesChanged, (e, t) => {
|
|
18342
|
-
if (!t.
|
|
18342
|
+
if (!t.isBot) return;
|
|
18343
18343
|
let n = t.attributes[eo];
|
|
18344
|
-
this.handlers?.onThinkingChange?.(n === "thinking"), this.
|
|
18344
|
+
this.handlers?.onThinkingChange?.(n === "thinking"), this.botStateSpeaking = n === "speaking", this.publishSpeaking();
|
|
18345
18345
|
}), this.room.on(P.ActiveSpeakersChanged, (e) => {
|
|
18346
|
-
this.userSpeaking = e.some((e) => e.isLocal), this.
|
|
18346
|
+
this.userSpeaking = e.some((e) => e.isLocal), this.botActiveSpeaker = e.some((e) => e.isBot), this.publishSpeaking();
|
|
18347
18347
|
}), this.room.on(P.Disconnected, (e) => {
|
|
18348
18348
|
this.closing || this.handlers?.onDisconnected(disconnectCause(e));
|
|
18349
18349
|
});
|
|
18350
|
-
let t = "VOICE_CONNECT_FAILED"
|
|
18350
|
+
let t = "VOICE_CONNECT_FAILED";
|
|
18351
18351
|
try {
|
|
18352
|
-
if (await this.room.connect(this.mint.url, this.mint.token), this.closing) return;
|
|
18353
|
-
if (t = "VOICE_MIC_UNAVAILABLE", n = await this.room.localParticipant.setMicrophoneEnabled(!0, {
|
|
18354
|
-
echoCancellation: !0,
|
|
18355
|
-
noiseSuppression: !0
|
|
18356
|
-
}), this.closing) {
|
|
18357
|
-
await this.room.localParticipant.setMicrophoneEnabled(!1).catch(() => {});
|
|
18358
|
-
return;
|
|
18359
|
-
}
|
|
18360
|
-
if (t = "VOICE_AGENT_UNAVAILABLE", await this.waitForAgentReady(), this.closing) {
|
|
18361
|
-
await this.room.localParticipant.setMicrophoneEnabled(!1).catch(() => {});
|
|
18362
|
-
return;
|
|
18363
|
-
}
|
|
18352
|
+
if (await this.room.connect(this.mint.url, this.mint.token), this.closing || (t = "VOICE_MIC_UNAVAILABLE", await this.setMuted(!1), this.closing) || (t = "VOICE_BOT_UNAVAILABLE", await this.waitForBotReady(), this.closing)) return;
|
|
18364
18353
|
t = "VOICE_PLAYBACK_UNAVAILABLE", await this.room.startAudio();
|
|
18365
18354
|
} catch (e) {
|
|
18366
18355
|
let n = e instanceof Error ? e : /* @__PURE__ */ Error("Could not open the voice connection.");
|
|
18367
18356
|
throw "code" in n || Object.assign(n, { code: t }), n;
|
|
18368
18357
|
}
|
|
18369
|
-
this.watchMicLevel(
|
|
18358
|
+
this.closing || this.watchMicLevel();
|
|
18370
18359
|
}
|
|
18371
18360
|
async disconnect() {
|
|
18372
18361
|
this.closing = !0, this.cancelReadyWait?.(), this.cancelReadyWait = void 0;
|
|
18373
|
-
for (let e of this.
|
|
18374
|
-
this.
|
|
18375
|
-
|
|
18376
|
-
this.
|
|
18362
|
+
for (let e of this.attachedElements) e.muted = !0, e.pause(), e.remove();
|
|
18363
|
+
this.attachedElements = [], this.room.localParticipant.getTrackPublication(z.Source.Microphone)?.track?.stop();
|
|
18364
|
+
let e = this.analysers.splice(0);
|
|
18365
|
+
this.levelSources = [], await Promise.allSettled([this.room.disconnect(), ...e.map((e) => e.cleanup())]);
|
|
18377
18366
|
}
|
|
18378
18367
|
async setMuted(e) {
|
|
18368
|
+
if (this.closing) return;
|
|
18379
18369
|
if (e) {
|
|
18380
18370
|
await this.room.localParticipant.setMicrophoneEnabled(!1);
|
|
18381
18371
|
return;
|
|
18382
18372
|
}
|
|
18383
|
-
await this.room.localParticipant.setMicrophoneEnabled(!0, {
|
|
18373
|
+
let t = await this.room.localParticipant.setMicrophoneEnabled(!0, {
|
|
18384
18374
|
echoCancellation: !0,
|
|
18385
18375
|
noiseSuppression: !0
|
|
18386
18376
|
});
|
|
18377
|
+
this.closing && t?.track?.stop();
|
|
18387
18378
|
}
|
|
18388
18379
|
sampleLevel(e) {
|
|
18389
18380
|
let t, n = e && this.levelSources.some((t) => t.source === e) ? this.levelSources.filter((t) => t.source === e) : this.levelSources;
|
|
@@ -18402,14 +18393,14 @@ var $a = 1e4, eo = "lk.agent.state", LiveKitVoiceProvider = class {
|
|
|
18402
18393
|
publishSpeaking() {
|
|
18403
18394
|
let e = {
|
|
18404
18395
|
user: this.userSpeaking,
|
|
18405
|
-
|
|
18396
|
+
bot: this.botActiveSpeaker || this.botStateSpeaking
|
|
18406
18397
|
};
|
|
18407
|
-
this.lastSpeaking?.user === e.user && this.lastSpeaking?.
|
|
18398
|
+
this.lastSpeaking?.user === e.user && this.lastSpeaking?.bot === e.bot || (this.lastSpeaking = e, this.handlers?.onSpeakingChange?.(e));
|
|
18408
18399
|
}
|
|
18409
|
-
async
|
|
18400
|
+
async waitForBotReady() {
|
|
18410
18401
|
let ready = (e) => {
|
|
18411
18402
|
let t = e.attributes[eo];
|
|
18412
|
-
return e.
|
|
18403
|
+
return e.isBot && (t === "listening" || t === "thinking" || t === "speaking");
|
|
18413
18404
|
};
|
|
18414
18405
|
[...this.room.remoteParticipants.values()].some(ready) || await new Promise((e, t) => {
|
|
18415
18406
|
let n = !1, finish = (i) => {
|
|
@@ -18418,7 +18409,7 @@ var $a = 1e4, eo = "lk.agent.state", LiveKitVoiceProvider = class {
|
|
|
18418
18409
|
ready(e) && finish();
|
|
18419
18410
|
}, onAttributes = (e, t) => {
|
|
18420
18411
|
ready(t) && finish();
|
|
18421
|
-
}, r = setTimeout(() => finish(Object.assign(/* @__PURE__ */ Error("The voice assistant did not become ready."), { code: "
|
|
18412
|
+
}, r = setTimeout(() => finish(Object.assign(/* @__PURE__ */ Error("The voice assistant did not become ready."), { code: "VOICE_BOT_UNAVAILABLE" })), $a);
|
|
18422
18413
|
this.room.on(P.ParticipantConnected, onParticipant), this.room.on(P.ParticipantAttributesChanged, onAttributes), this.cancelReadyWait = () => finish();
|
|
18423
18414
|
});
|
|
18424
18415
|
}
|
|
@@ -18441,14 +18432,15 @@ var $a = 1e4, eo = "lk.agent.state", LiveKitVoiceProvider = class {
|
|
|
18441
18432
|
return;
|
|
18442
18433
|
}
|
|
18443
18434
|
}
|
|
18444
|
-
watchMicLevel(
|
|
18445
|
-
let
|
|
18446
|
-
|
|
18435
|
+
watchMicLevel() {
|
|
18436
|
+
let e = this.room.localParticipant.getTrackPublication(z.Source.Microphone), t = e?.track ? this.analyserFor(e.track) : void 0;
|
|
18437
|
+
t && (this.analysers.push(t), this.levelSources.push({
|
|
18447
18438
|
source: "mic",
|
|
18448
|
-
analyser:
|
|
18439
|
+
analyser: t
|
|
18449
18440
|
}));
|
|
18450
18441
|
}
|
|
18451
18442
|
attachRemoteAudio(e) {
|
|
18443
|
+
if (this.closing) return;
|
|
18452
18444
|
try {
|
|
18453
18445
|
let t = e.attach?.();
|
|
18454
18446
|
t && typeof document < "u" && (t.style.display = "none", document.body.appendChild(t), this.attachedElements.push(t));
|
|
@@ -18461,7 +18453,7 @@ var $a = 1e4, eo = "lk.agent.state", LiveKitVoiceProvider = class {
|
|
|
18461
18453
|
}
|
|
18462
18454
|
};
|
|
18463
18455
|
function disconnectCause(e) {
|
|
18464
|
-
return e === S.ROOM_DELETED || e === S.PARTICIPANT_REMOVED ? "
|
|
18456
|
+
return e === S.ROOM_DELETED || e === S.PARTICIPANT_REMOVED ? "bot" : e === void 0 || e === S.UNKNOWN_REASON ? "unknown" : "network";
|
|
18465
18457
|
}
|
|
18466
18458
|
//#endregion
|
|
18467
18459
|
export { LiveKitVoiceProvider };
|