@pagelines/sdk 1.0.758 → 1.0.759
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/dist/AgentProvider.js +234 -232
- package/dist/AgentProvider.js.map +1 -1
- package/dist/AgentWidgetModal.js +184 -29
- package/dist/AgentWidgetModal.js.map +1 -1
- package/dist/AgentWrap.js +819 -611
- package/dist/AgentWrap.js.map +1 -1
- package/dist/agent/AgentController.d.ts +80 -22
- package/dist/agent/index.d.ts +4 -2
- package/dist/agent/schema.d.ts +2 -17
- package/dist/agent/ui/AgentAvatar.vue.d.ts +2 -0
- package/dist/agent/ui/AgentChat.vue.d.ts +3 -0
- package/dist/agent/ui/ElCreateAgent.vue.d.ts +2 -0
- package/dist/agent/ui/{AgentModal.vue.d.ts → VoiceMode.vue.d.ts} +7 -10
- package/dist/agent/utils.d.ts +0 -4
- package/dist/agent/voice/provider.d.ts +28 -0
- package/dist/agent/voice/providers/elevenlabs/provider.d.ts +30 -0
- package/dist/agent/voice/providers/livekit/provider.d.ts +55 -0
- package/dist/agent/voice/voice-session-client.d.ts +44 -0
- package/dist/agent.js +173 -74
- package/dist/agent.js.map +1 -1
- package/dist/clients/ChatClient.d.ts +1 -9
- package/dist/contract.js +564 -490
- package/dist/contract.js.map +1 -1
- package/dist/demo/index.d.ts +1 -0
- package/dist/provider.js +40 -0
- package/dist/provider.js.map +1 -0
- package/dist/provider2.js +16451 -0
- package/dist/provider2.js.map +1 -0
- package/dist/provider3.js +18439 -0
- package/dist/provider3.js.map +1 -0
- package/dist/sdk.css +1 -1
- package/dist/sdkClient.d.ts +8 -0
- package/dist/sdkClient.js +37 -47
- package/dist/sdkClient.js.map +1 -1
- package/dist/widget/composables/useWidgetState.d.ts +3 -0
- package/dist/widget.js +23 -23
- package/package.json +3 -1
- package/dist/FModal.js +0 -165
- package/dist/FModal.js.map +0 -1
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
import { ComputedRef, Ref } from 'vue';
|
|
2
|
-
import { AgentConfig, ChatToolActivityData, SettingsObject } from '@pagelines/core';
|
|
2
|
+
import { AgentConfig, ChatStreamError, ChatToolActivityData, SettingsObject } from '@pagelines/core';
|
|
3
3
|
import { PageLinesSDK } from '../sdkClient';
|
|
4
4
|
import { AgentMode, ChatAttachment, ChatMessage, TextConnectionState, Agent } from './schema';
|
|
5
|
+
import { VoiceClientHandlers, VoiceSessionClient } from './voice/voice-session-client';
|
|
5
6
|
import { LiveTurnBlock, WorkJournalModel, WorkJournalOutcome } from './work-journal';
|
|
6
7
|
import { VoiceRecorderController } from './VoiceRecorderController';
|
|
7
|
-
/**
|
|
8
|
-
* Structured error payload surfaced by the chat stream. Matches the
|
|
9
|
-
* ApiResponse contract in plans/architecture/architecture-api.md — consumers switch on
|
|
10
|
-
* `code` (stable identifier), render `error` (user-facing copy). When
|
|
11
|
-
* the server emits a ChatIssueWireFrame (chat-gate.ts), the bucket +
|
|
12
|
-
* actionLabel + actionUrl triad lets the UI render a CTA inside the
|
|
13
|
-
* error bubble.
|
|
14
|
-
*/
|
|
15
|
-
export interface ChatStreamError {
|
|
16
|
-
code: string;
|
|
17
|
-
error: string;
|
|
18
|
-
bucket?: 'account' | 'error';
|
|
19
|
-
actionLabel?: string;
|
|
20
|
-
actionUrl?: string;
|
|
21
|
-
help?: string;
|
|
22
|
-
}
|
|
23
8
|
export type ChatStreamErrorPresentation = {
|
|
24
9
|
surface: 'transcript';
|
|
25
10
|
issue: NonNullable<ChatMessage['issue']>;
|
|
@@ -66,7 +51,7 @@ export type AgentChatComposerState = {
|
|
|
66
51
|
pendingAttachments: ChatAttachment[];
|
|
67
52
|
isUploading: boolean;
|
|
68
53
|
};
|
|
69
|
-
type AgentChatControllerSettings = {
|
|
54
|
+
export type AgentChatControllerSettings = {
|
|
70
55
|
sdk?: PageLinesSDK;
|
|
71
56
|
agent: Agent | AgentConfig;
|
|
72
57
|
context?: string;
|
|
@@ -82,14 +67,59 @@ type AgentChatControllerSettings = {
|
|
|
82
67
|
* surfaces omit it — a visitor can't wake someone else's assistant.
|
|
83
68
|
*/
|
|
84
69
|
manageUrl?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Voice-mode seam — voice exists only where the surface provides it.
|
|
72
|
+
*
|
|
73
|
+
* There is deliberately no built-in default: the controller ships in the
|
|
74
|
+
* embeddable widget, and a static edge to the LiveKit transport put a full
|
|
75
|
+
* WebRTC stack (~500KB) on every host page for a capability the widget
|
|
76
|
+
* cannot use (a voice mint needs a signed-in user). Surfaces that can do
|
|
77
|
+
* voice construct `VoiceSessionClient` and pass it here; everywhere else
|
|
78
|
+
* `canStartVoice` stays false and the seat never renders.
|
|
79
|
+
*/
|
|
80
|
+
createVoiceClientFn?: (args: {
|
|
81
|
+
/** Validated by the controller's gate — the surface does not re-check. */
|
|
82
|
+
agentId: string;
|
|
83
|
+
orgId: string;
|
|
84
|
+
conversationId?: string;
|
|
85
|
+
handlers: VoiceClientHandlers;
|
|
86
|
+
}) => VoiceSessionClient;
|
|
87
|
+
/** Reload the bound transcript after an out-of-band voice session writes turns. */
|
|
88
|
+
refreshMessagesFn?: () => Promise<void>;
|
|
85
89
|
};
|
|
86
|
-
/** @deprecated Use AgentChatControllerSettings */
|
|
87
|
-
export type AgentControllerSettings = AgentChatControllerSettings;
|
|
88
90
|
export declare class AgentChatController extends SettingsObject<AgentChatControllerSettings> {
|
|
89
91
|
private isTextMode;
|
|
90
92
|
private lastMessage;
|
|
91
93
|
private isConnecting;
|
|
92
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Turn ownership across concurrent send streams.
|
|
96
|
+
*
|
|
97
|
+
* A send that lands mid-turn is accepted and held by the server, so two
|
|
98
|
+
* streams can be open at once: the one rendering the running turn and the
|
|
99
|
+
* one waiting for the queued turn the server will dispatch next. Each
|
|
100
|
+
* stream carries a token; `runningStreamToken` names the one that owns the
|
|
101
|
+
* live chrome, and Stop suppresses that token alone. `turnEpoch` is the
|
|
102
|
+
* wholesale invalidation (reset / conversation switch) — bumping it orphans
|
|
103
|
+
* every open stream at once.
|
|
104
|
+
*/
|
|
105
|
+
private turnEpoch;
|
|
106
|
+
private nextStreamToken;
|
|
107
|
+
private runningStreamToken;
|
|
108
|
+
private readonly suppressedStreamTokens;
|
|
109
|
+
/**
|
|
110
|
+
* Client ids of messages accepted while a turn was running. Rendered dimmed
|
|
111
|
+
* until the turn that answers them starts producing output.
|
|
112
|
+
*/
|
|
113
|
+
private readonly queuedMessageIdSet;
|
|
114
|
+
readonly queuedMessageIds: ComputedRef<ReadonlySet<string>>;
|
|
115
|
+
isQueuedMessage(messageId: string): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Undim the queued message answered by a starting turn, plus every queued
|
|
118
|
+
* message before it — a burst of held sends becomes one follow-up turn
|
|
119
|
+
* keyed to the latest prompt, so the whole chronological prefix resolves
|
|
120
|
+
* together. Mirrors iOS `consumeQueuedMessages(through:)`.
|
|
121
|
+
*/
|
|
122
|
+
private consumeQueuedThrough;
|
|
93
123
|
private boundaryTimer?;
|
|
94
124
|
private readonly nowMs;
|
|
95
125
|
private readonly toolActivityTiming;
|
|
@@ -120,7 +150,28 @@ export declare class AgentChatController extends SettingsObject<AgentChatControl
|
|
|
120
150
|
readonly voiceRecorder: VoiceRecorderController;
|
|
121
151
|
readonly canSend: ComputedRef<boolean>;
|
|
122
152
|
readonly canStop: ComputedRef<boolean>;
|
|
153
|
+
/**
|
|
154
|
+
* Which control owns the composer's primary slot (mockup 28d, iOS
|
|
155
|
+
* `ComposeState.derive`). Send outranks Stop the moment a draft exists —
|
|
156
|
+
* even mid-turn, because that send queues rather than cancelling. Stop
|
|
157
|
+
* borrows the primary slot only while the draft is empty, and otherwise
|
|
158
|
+
* steps aside to the secondary slot.
|
|
159
|
+
*/
|
|
123
160
|
readonly composerAction: ComputedRef<'idle' | 'send' | 'stop'>;
|
|
161
|
+
/** Quiet Stop beside the primary Send while a turn runs against a draft. */
|
|
162
|
+
readonly composerShowsSecondaryStop: ComputedRef<boolean>;
|
|
163
|
+
/**
|
|
164
|
+
* The empty-draft send seat offers voice (mockup composer contract). Gated
|
|
165
|
+
* on a buildable client plus browser capture support — a surface that
|
|
166
|
+
* can't open a session never shows the seat. Deliberately NOT gated on
|
|
167
|
+
* connection state, same reasoning as canUseComposer.
|
|
168
|
+
*/
|
|
169
|
+
readonly canStartVoice: ComputedRef<boolean>;
|
|
170
|
+
/** The thread the controller is bound to — the voice mint is conversation-scoped. */
|
|
171
|
+
get activeConversationId(): string | undefined;
|
|
172
|
+
/** Build the live-conversation client for the voice surface. Undefined when this surface can't do voice. */
|
|
173
|
+
createVoiceClient(handlers: VoiceClientHandlers): VoiceSessionClient | undefined;
|
|
174
|
+
refreshMessages(): Promise<void>;
|
|
124
175
|
private _agent;
|
|
125
176
|
constructor(settings: AgentChatControllerSettings);
|
|
126
177
|
get chatEnabled(): boolean;
|
|
@@ -136,6 +187,14 @@ export declare class AgentChatController extends SettingsObject<AgentChatControl
|
|
|
136
187
|
private isTransientError;
|
|
137
188
|
private isDuplicateMessage;
|
|
138
189
|
private addMessage;
|
|
190
|
+
/**
|
|
191
|
+
* Optimistic client id. Timestamp-ordered but counter-suffixed: two messages
|
|
192
|
+
* created in the same millisecond (a mid-turn send landing on the tick that
|
|
193
|
+
* added the previous bubble) must not share an id, or they collide as Vue
|
|
194
|
+
* keys and as queued-set entries.
|
|
195
|
+
*/
|
|
196
|
+
private localMessageSeq;
|
|
197
|
+
private nextLocalMessageId;
|
|
139
198
|
/**
|
|
140
199
|
* Surface a one-shot system bubble in the chat transcript.
|
|
141
200
|
*
|
|
@@ -229,4 +288,3 @@ export declare class AgentChatController extends SettingsObject<AgentChatControl
|
|
|
229
288
|
}): void;
|
|
230
289
|
destroy(): Promise<void>;
|
|
231
290
|
}
|
|
232
|
-
export {};
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { default as AgentChat } from './ui/AgentChat.vue';
|
|
2
|
-
import { default as AgentModal } from './ui/AgentModal.vue';
|
|
3
2
|
import { default as AgentProvider } from './ui/AgentProvider.vue';
|
|
4
3
|
import { default as AgentWidget } from './ui/AgentWidget.vue';
|
|
5
4
|
import { default as AgentWrap } from './ui/AgentWrap.vue';
|
|
6
5
|
import { default as ElAgentChat } from './ui/ElAgentChat.vue';
|
|
7
6
|
import { default as ElAgentChatPreview } from './ui/ElAgentChatPreview.vue';
|
|
7
|
+
import { default as VoiceMode } from './ui/VoiceMode.vue';
|
|
8
8
|
export { AgentChatController, AgentChatController as AgentController } from './AgentController';
|
|
9
9
|
export type { AgentChatComposerState, ChatStreamFn, ChatUploadFn } from './AgentController';
|
|
10
|
+
export { VoiceSessionClient } from './voice/voice-session-client';
|
|
11
|
+
export type { VoiceClientHandlers, VoiceLevelEvent, VoiceSessionClientState, VoiceSessionError, } from './voice/voice-session-client';
|
|
10
12
|
export type { WorkJournalModel, WorkJournalOutcome, WorkJournalRow, WorkJournalTone } from './work-journal';
|
|
11
13
|
export * from './schema';
|
|
12
|
-
export { AgentChat,
|
|
14
|
+
export { AgentChat, AgentProvider, AgentWidget, AgentWrap, ElAgentChat, ElAgentChatPreview, VoiceMode };
|
package/dist/agent/schema.d.ts
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
import { ChatToolActivityData } from '@pagelines/core';
|
|
1
|
+
import { ChatAttachment, ChatToolActivityData } from '@pagelines/core';
|
|
2
2
|
export { Agent } from '@pagelines/core';
|
|
3
|
-
export type { AgentConfig, ChatToolActivityData as ChatToolActivity } from '@pagelines/core';
|
|
4
|
-
export interface ChatAttachment {
|
|
5
|
-
type: 'image' | 'audio' | 'video' | 'document';
|
|
6
|
-
src: string;
|
|
7
|
-
filename: string;
|
|
8
|
-
mimeType: string;
|
|
9
|
-
mediaId?: string;
|
|
10
|
-
size?: number;
|
|
11
|
-
width?: number;
|
|
12
|
-
height?: number;
|
|
13
|
-
duration?: number;
|
|
14
|
-
placement?: {
|
|
15
|
-
kind: 'inline';
|
|
16
|
-
offset: number;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
3
|
+
export type { AgentConfig, ChatAttachment, ChatToolActivityData as ChatToolActivity } from '@pagelines/core';
|
|
19
4
|
export interface ChatMessageIssue {
|
|
20
5
|
code: string;
|
|
21
6
|
bucket: 'account' | 'error';
|
|
@@ -19,6 +19,8 @@ import { Agent } from '@pagelines/core';
|
|
|
19
19
|
type __VLS_Props = {
|
|
20
20
|
agent: Agent;
|
|
21
21
|
showStatus?: boolean;
|
|
22
|
+
/** Voice mode opts out: the owner is the one present and speaking, so the "whose assistant is this" question is already answered. */
|
|
23
|
+
showOwnerMark?: boolean;
|
|
22
24
|
/** Ring color follows the surface so the mark reads as framed, not cut out. */
|
|
23
25
|
isLight?: boolean;
|
|
24
26
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AgentChatControllerSettings } from '../AgentController';
|
|
1
2
|
import { PageLinesSDK } from '../../sdkClient';
|
|
2
3
|
import { ButtonIconPreset } from '../../widget/PLWidget';
|
|
3
4
|
import { ColorName, SuggestedPrompt } from '@pagelines/core';
|
|
@@ -19,6 +20,8 @@ type __VLS_Props = {
|
|
|
19
20
|
bare?: boolean;
|
|
20
21
|
emptyStateMessage?: string;
|
|
21
22
|
suggestedPrompts?: SuggestedPrompt[];
|
|
23
|
+
/** Voice transport, supplied by hosts that ship it. See the note in createChatController. */
|
|
24
|
+
createVoiceClientFn?: AgentChatControllerSettings['createVoiceClientFn'];
|
|
22
25
|
};
|
|
23
26
|
type __VLS_Slots = {
|
|
24
27
|
'empty-heading': (props: {
|
|
@@ -68,6 +68,7 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {
|
|
|
68
68
|
handle: string;
|
|
69
69
|
}[] | null | undefined;
|
|
70
70
|
model?: string | null | undefined;
|
|
71
|
+
voice?: "woman" | "man" | null | undefined;
|
|
71
72
|
billingTier?: "essential" | "professional" | "business" | undefined;
|
|
72
73
|
lastActiveAt?: string | null | undefined;
|
|
73
74
|
lastMessageAt?: string | null | undefined;
|
|
@@ -201,6 +202,7 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {
|
|
|
201
202
|
handle: string;
|
|
202
203
|
}[] | null | undefined;
|
|
203
204
|
model?: string | null | undefined;
|
|
205
|
+
voice?: "woman" | "man" | null | undefined;
|
|
204
206
|
billingTier?: "essential" | "professional" | "business" | undefined;
|
|
205
207
|
lastActiveAt?: string | null | undefined;
|
|
206
208
|
lastMessageAt?: string | null | undefined;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Agent } from '@pagelines/core';
|
|
2
|
+
import { AgentChatController } from '../AgentController';
|
|
3
3
|
type __VLS_Props = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
handle?: string;
|
|
8
|
-
context?: string;
|
|
9
|
-
firstMessage?: string;
|
|
4
|
+
agent: Agent;
|
|
5
|
+
chatController?: AgentChatController;
|
|
6
|
+
isLight?: boolean;
|
|
10
7
|
};
|
|
11
8
|
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
12
|
-
|
|
9
|
+
end: () => any;
|
|
13
10
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
14
|
-
|
|
11
|
+
onEnd?: (() => any) | undefined;
|
|
15
12
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
16
13
|
declare const _default: typeof __VLS_export;
|
|
17
14
|
export default _default;
|
package/dist/agent/utils.d.ts
CHANGED
|
@@ -13,10 +13,6 @@ export declare function parseVoiceMessage(args: {
|
|
|
13
13
|
text: string;
|
|
14
14
|
sender: 'user' | 'agent';
|
|
15
15
|
} | null;
|
|
16
|
-
export declare function generateFirstMessage(args: {
|
|
17
|
-
name: string;
|
|
18
|
-
context?: string;
|
|
19
|
-
}): string;
|
|
20
16
|
/**
|
|
21
17
|
* Parse button template string with self data variables
|
|
22
18
|
* Supports: {name}, {title}, {handle}, {orgName}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { VoiceSessionMint } from '@pagelines/core';
|
|
2
|
+
export interface VoiceLevelEvent {
|
|
3
|
+
source: 'mic' | 'playback';
|
|
4
|
+
/** Normalized 0..1 signal level. */
|
|
5
|
+
level: number;
|
|
6
|
+
/** Speech-spectrum energies, low pitch first. */
|
|
7
|
+
bands?: readonly number[];
|
|
8
|
+
}
|
|
9
|
+
export interface VoiceSessionError {
|
|
10
|
+
code: string;
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
export interface VoiceProviderClient {
|
|
14
|
+
connect: (handlers: {
|
|
15
|
+
onDisconnected: () => void;
|
|
16
|
+
onError: (error: VoiceSessionError) => void;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
disconnect: () => Promise<void>;
|
|
19
|
+
sampleLevel: () => VoiceLevelEvent | undefined;
|
|
20
|
+
}
|
|
21
|
+
export type CreateVoiceProviderClient = (mint: VoiceSessionMint) => Promise<VoiceProviderClient>;
|
|
22
|
+
/** Provider selection is a closed union; each SDK remains in its lazy chunk. */
|
|
23
|
+
export declare const createVoiceProviderClient: CreateVoiceProviderClient;
|
|
24
|
+
export declare const VOICE_SPECTRUM_BANDS = 9;
|
|
25
|
+
/** Log-spaced speech spectrum for transports that expose FFT bins. */
|
|
26
|
+
export declare function voiceSpectrum(frequencies: Uint8Array, sampleRate: number, fftSize: number, bandCount?: number): readonly number[];
|
|
27
|
+
/** Equal-width bands for SDKs that already expose voice-range FFT bins. */
|
|
28
|
+
export declare function voiceRangeSpectrum(frequencies: Uint8Array, bandCount?: number): readonly number[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { VoiceSessionMint } from '@pagelines/core';
|
|
2
|
+
import { VoiceProviderClient } from '../../provider';
|
|
3
|
+
type ElevenLabsMint = Extract<VoiceSessionMint, {
|
|
4
|
+
provider: 'elevenlabs';
|
|
5
|
+
}>;
|
|
6
|
+
interface ElevenLabsConversation {
|
|
7
|
+
endSession: () => Promise<void>;
|
|
8
|
+
getInputVolume: () => number;
|
|
9
|
+
getOutputVolume: () => number;
|
|
10
|
+
getInputByteFrequencyData: () => Uint8Array;
|
|
11
|
+
getOutputByteFrequencyData: () => Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
type StartSession = (options: {
|
|
14
|
+
conversationToken: string;
|
|
15
|
+
connectionType: 'webrtc';
|
|
16
|
+
onDisconnect: () => void;
|
|
17
|
+
onError: (message: string) => void;
|
|
18
|
+
}) => Promise<ElevenLabsConversation>;
|
|
19
|
+
export declare class ElevenLabsVoiceProvider implements VoiceProviderClient {
|
|
20
|
+
private readonly mint;
|
|
21
|
+
private readonly startSession;
|
|
22
|
+
private conversation?;
|
|
23
|
+
private closing;
|
|
24
|
+
private handlers?;
|
|
25
|
+
constructor(mint: ElevenLabsMint, startSession?: StartSession);
|
|
26
|
+
connect(handlers: Parameters<VoiceProviderClient['connect']>[0]): Promise<void>;
|
|
27
|
+
disconnect(): Promise<void>;
|
|
28
|
+
sampleLevel(): ReturnType<VoiceProviderClient['sampleLevel']>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { VoiceSessionMint } from '@pagelines/core';
|
|
2
|
+
import { VoiceProviderClient } from '../../provider';
|
|
3
|
+
type LiveKitMint = Extract<VoiceSessionMint, {
|
|
4
|
+
provider: 'livekit';
|
|
5
|
+
}>;
|
|
6
|
+
export interface VoiceLevelAnalyser {
|
|
7
|
+
calculateVolume: () => number;
|
|
8
|
+
calculateBands?: () => readonly number[];
|
|
9
|
+
cleanup: () => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export interface VoiceRoom {
|
|
12
|
+
connect: (url: string, token: string) => Promise<void>;
|
|
13
|
+
disconnect: () => Promise<void>;
|
|
14
|
+
startAudio: () => Promise<void>;
|
|
15
|
+
on: (event: string, handler: (...args: any[]) => void) => unknown;
|
|
16
|
+
off: (event: string, handler: (...args: any[]) => void) => unknown;
|
|
17
|
+
remoteParticipants: ReadonlyMap<string, {
|
|
18
|
+
isAgent: boolean;
|
|
19
|
+
attributes: Readonly<Record<string, string>>;
|
|
20
|
+
}>;
|
|
21
|
+
localParticipant: {
|
|
22
|
+
setMicrophoneEnabled: (enabled: boolean, options?: {
|
|
23
|
+
echoCancellation?: boolean;
|
|
24
|
+
noiseSuppression?: boolean;
|
|
25
|
+
}) => Promise<{
|
|
26
|
+
track?: unknown;
|
|
27
|
+
} | undefined>;
|
|
28
|
+
getTrackPublication?: (source: string) => {
|
|
29
|
+
track?: unknown;
|
|
30
|
+
} | undefined;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export declare class LiveKitVoiceProvider implements VoiceProviderClient {
|
|
34
|
+
private readonly mint;
|
|
35
|
+
private readonly room;
|
|
36
|
+
private readonly createAnalyser?;
|
|
37
|
+
private handlers?;
|
|
38
|
+
private cancelReadyWait?;
|
|
39
|
+
private analysers;
|
|
40
|
+
private levelSources;
|
|
41
|
+
private attachedElements;
|
|
42
|
+
private closing;
|
|
43
|
+
constructor(mint: LiveKitMint, deps?: {
|
|
44
|
+
createRoom?: () => VoiceRoom;
|
|
45
|
+
createAnalyser?: (track: unknown) => VoiceLevelAnalyser;
|
|
46
|
+
});
|
|
47
|
+
connect(handlers: Parameters<VoiceProviderClient['connect']>[0]): Promise<void>;
|
|
48
|
+
disconnect(): Promise<void>;
|
|
49
|
+
sampleLevel(): ReturnType<VoiceProviderClient['sampleLevel']>;
|
|
50
|
+
private waitForAgentReady;
|
|
51
|
+
private analyserFor;
|
|
52
|
+
private watchMicLevel;
|
|
53
|
+
private attachRemoteAudio;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { CreateVoiceProviderClient, VoiceLevelEvent, VoiceSessionError } from './provider';
|
|
3
|
+
import { SettingsObject } from '@pagelines/core';
|
|
4
|
+
export type { VoiceLevelEvent, VoiceSessionError } from './provider';
|
|
5
|
+
export { VOICE_SPECTRUM_BANDS, voiceSpectrum } from './provider';
|
|
6
|
+
export type VoiceSessionClientState = 'idle' | 'minting' | 'connecting' | 'live' | 'ended';
|
|
7
|
+
export type VoiceChimeKind = 'start' | 'end';
|
|
8
|
+
export interface VoiceClientHandlers {
|
|
9
|
+
onStateChange?: (state: VoiceSessionClientState) => void;
|
|
10
|
+
onLevel?: (event: VoiceLevelEvent) => void;
|
|
11
|
+
onError?: (error: VoiceSessionError) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface VoiceSessionClientSettings extends VoiceClientHandlers, Record<string, unknown> {
|
|
14
|
+
agentId: string;
|
|
15
|
+
orgId: string;
|
|
16
|
+
conversationId?: string;
|
|
17
|
+
apiBase?: string;
|
|
18
|
+
isDev?: boolean;
|
|
19
|
+
token?: string;
|
|
20
|
+
fetchFn?: typeof fetch;
|
|
21
|
+
/** Provider composition seam; the default dynamically loads the minted provider. */
|
|
22
|
+
createProvider?: CreateVoiceProviderClient;
|
|
23
|
+
playChime?: (kind: VoiceChimeKind) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare function createBrowserVoiceChimePlayer(): (kind: VoiceChimeKind) => void;
|
|
26
|
+
export declare class VoiceSessionClient extends SettingsObject<VoiceSessionClientSettings> {
|
|
27
|
+
readonly state: Ref<VoiceSessionClientState>;
|
|
28
|
+
private provider?;
|
|
29
|
+
private readonly chime;
|
|
30
|
+
private generation;
|
|
31
|
+
private levelTimer;
|
|
32
|
+
constructor(settings: VoiceSessionClientSettings);
|
|
33
|
+
start(): Promise<void>;
|
|
34
|
+
end(): void;
|
|
35
|
+
private connect;
|
|
36
|
+
private setState;
|
|
37
|
+
private fail;
|
|
38
|
+
private teardown;
|
|
39
|
+
private startLevelTimer;
|
|
40
|
+
private authHeaders;
|
|
41
|
+
private post;
|
|
42
|
+
private mintSession;
|
|
43
|
+
private toSessionError;
|
|
44
|
+
}
|