@pagelines/sdk 1.0.758 → 1.0.760
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 +251 -235
- package/dist/AgentProvider.js.map +1 -1
- package/dist/AgentWidgetModal.js +184 -29
- package/dist/AgentWidgetModal.js.map +1 -1
- package/dist/AgentWrap.js +821 -613
- package/dist/AgentWrap.js.map +1 -1
- package/dist/agent/AgentController.d.ts +82 -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 +7 -0
- package/dist/agent/ui/AgentProvider.vue.d.ts +4 -0
- package/dist/agent/ui/ElCreateAgent.vue.d.ts +8 -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 +49 -0
- package/dist/agent.js +168 -74
- package/dist/agent.js.map +1 -1
- package/dist/clients/ChatClient.d.ts +1 -9
- package/dist/contract.js +1756 -1664
- package/dist/contract.js.map +1 -1
- package/dist/demo/index.d.ts +4 -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 +17 -0
- package/dist/sdkClient.js +37 -47
- package/dist/sdkClient.js.map +1 -1
- package/dist/widget/composables/useWidgetState.d.ts +12 -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,61 @@ 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>;
|
|
89
|
+
onTurnStarted?: () => void;
|
|
90
|
+
onTurnCompleted?: (conversationId: string) => void;
|
|
85
91
|
};
|
|
86
|
-
/** @deprecated Use AgentChatControllerSettings */
|
|
87
|
-
export type AgentControllerSettings = AgentChatControllerSettings;
|
|
88
92
|
export declare class AgentChatController extends SettingsObject<AgentChatControllerSettings> {
|
|
89
93
|
private isTextMode;
|
|
90
94
|
private lastMessage;
|
|
91
95
|
private isConnecting;
|
|
92
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Turn ownership across concurrent send streams.
|
|
98
|
+
*
|
|
99
|
+
* A send that lands mid-turn is accepted and held by the server, so two
|
|
100
|
+
* streams can be open at once: the one rendering the running turn and the
|
|
101
|
+
* one waiting for the queued turn the server will dispatch next. Each
|
|
102
|
+
* stream carries a token; `runningStreamToken` names the one that owns the
|
|
103
|
+
* live chrome, and Stop suppresses that token alone. `turnEpoch` is the
|
|
104
|
+
* wholesale invalidation (reset / conversation switch) — bumping it orphans
|
|
105
|
+
* every open stream at once.
|
|
106
|
+
*/
|
|
107
|
+
private turnEpoch;
|
|
108
|
+
private nextStreamToken;
|
|
109
|
+
private runningStreamToken;
|
|
110
|
+
private readonly suppressedStreamTokens;
|
|
111
|
+
/**
|
|
112
|
+
* Client ids of messages accepted while a turn was running. Rendered dimmed
|
|
113
|
+
* until the turn that answers them starts producing output.
|
|
114
|
+
*/
|
|
115
|
+
private readonly queuedMessageIdSet;
|
|
116
|
+
readonly queuedMessageIds: ComputedRef<ReadonlySet<string>>;
|
|
117
|
+
isQueuedMessage(messageId: string): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Undim the queued message answered by a starting turn, plus every queued
|
|
120
|
+
* message before it — a burst of held sends becomes one follow-up turn
|
|
121
|
+
* keyed to the latest prompt, so the whole chronological prefix resolves
|
|
122
|
+
* together. Mirrors iOS `consumeQueuedMessages(through:)`.
|
|
123
|
+
*/
|
|
124
|
+
private consumeQueuedThrough;
|
|
93
125
|
private boundaryTimer?;
|
|
94
126
|
private readonly nowMs;
|
|
95
127
|
private readonly toolActivityTiming;
|
|
@@ -120,7 +152,28 @@ export declare class AgentChatController extends SettingsObject<AgentChatControl
|
|
|
120
152
|
readonly voiceRecorder: VoiceRecorderController;
|
|
121
153
|
readonly canSend: ComputedRef<boolean>;
|
|
122
154
|
readonly canStop: ComputedRef<boolean>;
|
|
155
|
+
/**
|
|
156
|
+
* Which control owns the composer's primary slot (mockup 28d, iOS
|
|
157
|
+
* `ComposeState.derive`). Send outranks Stop the moment a draft exists —
|
|
158
|
+
* even mid-turn, because that send queues rather than cancelling. Stop
|
|
159
|
+
* borrows the primary slot only while the draft is empty, and otherwise
|
|
160
|
+
* steps aside to the secondary slot.
|
|
161
|
+
*/
|
|
123
162
|
readonly composerAction: ComputedRef<'idle' | 'send' | 'stop'>;
|
|
163
|
+
/** Quiet Stop beside the primary Send while a turn runs against a draft. */
|
|
164
|
+
readonly composerShowsSecondaryStop: ComputedRef<boolean>;
|
|
165
|
+
/**
|
|
166
|
+
* The empty-draft send seat offers voice (mockup composer contract). Gated
|
|
167
|
+
* on a buildable client plus browser capture support — a surface that
|
|
168
|
+
* can't open a session never shows the seat. Deliberately NOT gated on
|
|
169
|
+
* connection state, same reasoning as canUseComposer.
|
|
170
|
+
*/
|
|
171
|
+
readonly canStartVoice: ComputedRef<boolean>;
|
|
172
|
+
/** The thread the controller is bound to — the voice mint is conversation-scoped. */
|
|
173
|
+
get activeConversationId(): string | undefined;
|
|
174
|
+
/** Build the live-conversation client for the voice surface. Undefined when this surface can't do voice. */
|
|
175
|
+
createVoiceClient(handlers: VoiceClientHandlers): VoiceSessionClient | undefined;
|
|
176
|
+
refreshMessages(): Promise<void>;
|
|
124
177
|
private _agent;
|
|
125
178
|
constructor(settings: AgentChatControllerSettings);
|
|
126
179
|
get chatEnabled(): boolean;
|
|
@@ -136,6 +189,14 @@ export declare class AgentChatController extends SettingsObject<AgentChatControl
|
|
|
136
189
|
private isTransientError;
|
|
137
190
|
private isDuplicateMessage;
|
|
138
191
|
private addMessage;
|
|
192
|
+
/**
|
|
193
|
+
* Optimistic client id. Timestamp-ordered but counter-suffixed: two messages
|
|
194
|
+
* created in the same millisecond (a mid-turn send landing on the tick that
|
|
195
|
+
* added the previous bubble) must not share an id, or they collide as Vue
|
|
196
|
+
* keys and as queued-set entries.
|
|
197
|
+
*/
|
|
198
|
+
private localMessageSeq;
|
|
199
|
+
private nextLocalMessageId;
|
|
139
200
|
/**
|
|
140
201
|
* Surface a one-shot system bubble in the chat transcript.
|
|
141
202
|
*
|
|
@@ -229,4 +290,3 @@ export declare class AgentChatController extends SettingsObject<AgentChatControl
|
|
|
229
290
|
}): void;
|
|
230
291
|
destroy(): Promise<void>;
|
|
231
292
|
}
|
|
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: {
|
|
@@ -29,9 +32,13 @@ type __VLS_Slots = {
|
|
|
29
32
|
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
30
33
|
error: (message: string) => any;
|
|
31
34
|
close: (value: string) => any;
|
|
35
|
+
turnStarted: () => any;
|
|
36
|
+
turnCompleted: (conversationId: string) => any;
|
|
32
37
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
33
38
|
onError?: ((message: string) => any) | undefined;
|
|
34
39
|
onClose?: ((value: string) => any) | undefined;
|
|
40
|
+
onTurnStarted?: (() => any) | undefined;
|
|
41
|
+
onTurnCompleted?: ((conversationId: string) => any) | undefined;
|
|
35
42
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
36
43
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
37
44
|
declare const _default: typeof __VLS_export;
|
|
@@ -27,9 +27,13 @@ type __VLS_Slots = {
|
|
|
27
27
|
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
28
28
|
error: (message: string) => any;
|
|
29
29
|
close: (value: string) => any;
|
|
30
|
+
turnStarted: () => any;
|
|
31
|
+
turnCompleted: (conversationId: string) => any;
|
|
30
32
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
31
33
|
onError?: ((message: string) => any) | undefined;
|
|
32
34
|
onClose?: ((value: string) => any) | undefined;
|
|
35
|
+
onTurnStarted?: (() => any) | undefined;
|
|
36
|
+
onTurnCompleted?: ((conversationId: string) => any) | undefined;
|
|
33
37
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
34
38
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
35
39
|
declare const _default: typeof __VLS_export;
|
|
@@ -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;
|
|
@@ -76,6 +77,9 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {
|
|
|
76
77
|
desiredStatus?: "active" | "stopped" | null | undefined;
|
|
77
78
|
automationPrimaryChannel?: string | undefined;
|
|
78
79
|
heartbeatEnabled?: boolean | undefined;
|
|
80
|
+
heartbeatBriefingTime?: string | undefined;
|
|
81
|
+
heartbeatCheckinTime?: string | undefined;
|
|
82
|
+
heartbeatCloseoutTime?: string | undefined;
|
|
79
83
|
onboardedAt?: string | null | undefined;
|
|
80
84
|
org?: {
|
|
81
85
|
orgId: string;
|
|
@@ -201,6 +205,7 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {
|
|
|
201
205
|
handle: string;
|
|
202
206
|
}[] | null | undefined;
|
|
203
207
|
model?: string | null | undefined;
|
|
208
|
+
voice?: "woman" | "man" | null | undefined;
|
|
204
209
|
billingTier?: "essential" | "professional" | "business" | undefined;
|
|
205
210
|
lastActiveAt?: string | null | undefined;
|
|
206
211
|
lastMessageAt?: string | null | undefined;
|
|
@@ -209,6 +214,9 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {
|
|
|
209
214
|
desiredStatus?: "active" | "stopped" | null | undefined;
|
|
210
215
|
automationPrimaryChannel?: string | undefined;
|
|
211
216
|
heartbeatEnabled?: boolean | undefined;
|
|
217
|
+
heartbeatBriefingTime?: string | undefined;
|
|
218
|
+
heartbeatCheckinTime?: string | undefined;
|
|
219
|
+
heartbeatCloseoutTime?: string | undefined;
|
|
212
220
|
onboardedAt?: string | null | undefined;
|
|
213
221
|
org?: {
|
|
214
222
|
orgId: string;
|
|
@@ -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,49 @@
|
|
|
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
|
+
/**
|
|
26
|
+
* The readiness cue is the only signal an eyes-off user gets, so it is served
|
|
27
|
+
* from the API origin rather than the embedding page — a relative path would
|
|
28
|
+
* silently 404 wherever the SDK is not hosted by the app itself.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createBrowserVoiceChimePlayer(apiBase: string): (kind: VoiceChimeKind) => void;
|
|
31
|
+
export declare class VoiceSessionClient extends SettingsObject<VoiceSessionClientSettings> {
|
|
32
|
+
readonly state: Ref<VoiceSessionClientState>;
|
|
33
|
+
private provider?;
|
|
34
|
+
private readonly chime;
|
|
35
|
+
private generation;
|
|
36
|
+
private levelTimer;
|
|
37
|
+
constructor(settings: VoiceSessionClientSettings);
|
|
38
|
+
start(): Promise<void>;
|
|
39
|
+
end(): void;
|
|
40
|
+
private connect;
|
|
41
|
+
private setState;
|
|
42
|
+
private fail;
|
|
43
|
+
private teardown;
|
|
44
|
+
private startLevelTimer;
|
|
45
|
+
private authHeaders;
|
|
46
|
+
private post;
|
|
47
|
+
private mintSession;
|
|
48
|
+
private toSessionError;
|
|
49
|
+
}
|