@pagelines/sdk 1.0.645 → 1.0.646
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/AgentWrap.vue_vue_type_script_setup_true_lang.js +2360 -1886
- package/dist/AgentWrap.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/agent/AgentController.d.ts +30 -1
- package/dist/agent/VoiceRecorderController.d.ts +77 -0
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/test/VoiceRecorderController.unit.test.d.ts +1 -0
- package/dist/agent/ui/ElAgentChat.vue.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
1
|
+
import { ComputedRef, Ref } from 'vue';
|
|
2
2
|
import { AgentConfig, ChatToolActivityData, SettingsObject } from '@pagelines/core';
|
|
3
3
|
import { PageLinesSDK } from '../sdkClient';
|
|
4
4
|
import { AgentMode, ChatAttachment, ChatMessage, TextConnectionState, Agent } from './schema';
|
|
5
|
+
import { VoiceRecorderController } from './VoiceRecorderController';
|
|
5
6
|
/**
|
|
6
7
|
* Structured error payload surfaced by the chat stream. Matches the
|
|
7
8
|
* ApiResponse contract in plans/architecture/architecture-api.md — consumers switch on
|
|
@@ -56,6 +57,14 @@ export type ChatStreamFn = (args: {
|
|
|
56
57
|
onToolActivity?: (activity: ChatToolActivityData) => void;
|
|
57
58
|
onWorkingEnd?: () => void;
|
|
58
59
|
}) => Promise<void>;
|
|
60
|
+
export type ChatUploadFn = (args: {
|
|
61
|
+
file: File;
|
|
62
|
+
}) => Promise<ChatAttachment>;
|
|
63
|
+
export type AgentChatComposerState = {
|
|
64
|
+
text: string;
|
|
65
|
+
pendingAttachments: ChatAttachment[];
|
|
66
|
+
isUploading: boolean;
|
|
67
|
+
};
|
|
59
68
|
type AgentChatControllerSettings = {
|
|
60
69
|
sdk?: PageLinesSDK;
|
|
61
70
|
agent: Agent | AgentConfig;
|
|
@@ -65,6 +74,7 @@ type AgentChatControllerSettings = {
|
|
|
65
74
|
cancelChatTurnFn?: (args: {
|
|
66
75
|
conversationId?: string;
|
|
67
76
|
}) => Promise<void> | void;
|
|
77
|
+
uploadFileFn?: ChatUploadFn;
|
|
68
78
|
};
|
|
69
79
|
/** @deprecated Use AgentChatControllerSettings */
|
|
70
80
|
export type AgentControllerSettings = AgentChatControllerSettings;
|
|
@@ -77,6 +87,14 @@ export declare class AgentChatController extends SettingsObject<AgentChatControl
|
|
|
77
87
|
textState: Ref<TextConnectionState>;
|
|
78
88
|
agentMode: Ref<AgentMode>;
|
|
79
89
|
sharedMessages: Ref<ChatMessage[]>;
|
|
90
|
+
readonly composerState: Ref<AgentChatComposerState>;
|
|
91
|
+
readonly canUseComposer: ComputedRef<boolean>;
|
|
92
|
+
readonly canAttachFile: ComputedRef<boolean>;
|
|
93
|
+
readonly canRecordAudio: ComputedRef<boolean>;
|
|
94
|
+
readonly voiceRecorder: VoiceRecorderController;
|
|
95
|
+
readonly canSend: ComputedRef<boolean>;
|
|
96
|
+
readonly canStop: ComputedRef<boolean>;
|
|
97
|
+
readonly composerAction: ComputedRef<'idle' | 'send' | 'stop'>;
|
|
80
98
|
private _agent;
|
|
81
99
|
constructor(settings: AgentChatControllerSettings);
|
|
82
100
|
get chatEnabled(): boolean;
|
|
@@ -102,6 +120,17 @@ export declare class AgentChatController extends SettingsObject<AgentChatControl
|
|
|
102
120
|
* feedback" miss flagged in design.md → Action Feedback Contract.
|
|
103
121
|
*/
|
|
104
122
|
notify(text: string): void;
|
|
123
|
+
setComposerText(args: {
|
|
124
|
+
text: string;
|
|
125
|
+
}): void;
|
|
126
|
+
attachFile(args: {
|
|
127
|
+
file: File;
|
|
128
|
+
}): Promise<void>;
|
|
129
|
+
removeAttachment(args: {
|
|
130
|
+
index: number;
|
|
131
|
+
}): void;
|
|
132
|
+
sendComposerMessage(): Promise<void>;
|
|
133
|
+
handleComposerAction(): Promise<void>;
|
|
105
134
|
getDynamicSettings(): {
|
|
106
135
|
context: string;
|
|
107
136
|
firstMessage: string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ChatAttachment } from './schema';
|
|
2
|
+
import { SettingsObject } from '@pagelines/core';
|
|
3
|
+
type VoiceRecorderPhase = 'idle' | 'preparing' | 'recording' | 'sending';
|
|
4
|
+
type VoiceRecorderLike = {
|
|
5
|
+
state: 'inactive' | 'recording' | 'paused';
|
|
6
|
+
mimeType: string;
|
|
7
|
+
start: () => void;
|
|
8
|
+
stop: () => void;
|
|
9
|
+
addEventListener: {
|
|
10
|
+
(type: 'dataavailable', listener: (event: {
|
|
11
|
+
data: Blob;
|
|
12
|
+
}) => void): void;
|
|
13
|
+
(type: 'stop', listener: () => void | Promise<void>): void;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type VoiceRecorderControllerState = {
|
|
17
|
+
phase: VoiceRecorderPhase;
|
|
18
|
+
elapsedMs: number;
|
|
19
|
+
};
|
|
20
|
+
type VoiceRecorderChatController = {
|
|
21
|
+
sendChatMessage: (message: string, attachments?: ChatAttachment[]) => Promise<void>;
|
|
22
|
+
notify: (text: string) => void;
|
|
23
|
+
};
|
|
24
|
+
type VoiceRecorderControllerSettings = {
|
|
25
|
+
getCanRecord: () => boolean;
|
|
26
|
+
getUploadFn: () => ((file: File) => Promise<ChatAttachment>) | undefined;
|
|
27
|
+
getChatController: () => VoiceRecorderChatController | undefined;
|
|
28
|
+
onBeforeSend?: () => void;
|
|
29
|
+
getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
|
|
30
|
+
createRecorder?: (args: {
|
|
31
|
+
stream: MediaStream;
|
|
32
|
+
mimeType: string;
|
|
33
|
+
}) => VoiceRecorderLike;
|
|
34
|
+
now?: () => number;
|
|
35
|
+
setInterval?: (handler: () => void, timeout: number) => ReturnType<typeof setInterval>;
|
|
36
|
+
clearInterval?: (timer: ReturnType<typeof setInterval>) => void;
|
|
37
|
+
};
|
|
38
|
+
export declare function formatVoiceRecordingDuration(args: {
|
|
39
|
+
ms: number;
|
|
40
|
+
}): string;
|
|
41
|
+
export declare class VoiceRecorderController extends SettingsObject<VoiceRecorderControllerSettings> {
|
|
42
|
+
readonly state: import('vue').Ref<{
|
|
43
|
+
phase: VoiceRecorderPhase;
|
|
44
|
+
elapsedMs: number;
|
|
45
|
+
}, VoiceRecorderControllerState | {
|
|
46
|
+
phase: VoiceRecorderPhase;
|
|
47
|
+
elapsedMs: number;
|
|
48
|
+
}>;
|
|
49
|
+
readonly isActive: import('vue').ComputedRef<boolean>;
|
|
50
|
+
readonly isBusy: import('vue').ComputedRef<boolean>;
|
|
51
|
+
readonly elapsedLabel: import('vue').ComputedRef<string>;
|
|
52
|
+
readonly statusText: import('vue').ComputedRef<"Starting microphone" | "Sending voice message" | "Release to send">;
|
|
53
|
+
private recorder?;
|
|
54
|
+
private stream?;
|
|
55
|
+
private chunks;
|
|
56
|
+
private timer?;
|
|
57
|
+
private startedAt;
|
|
58
|
+
private cancelOnStop;
|
|
59
|
+
private stopAfterStart;
|
|
60
|
+
private startToken;
|
|
61
|
+
constructor(settings: VoiceRecorderControllerSettings);
|
|
62
|
+
get canUseBrowserRecording(): boolean;
|
|
63
|
+
start(): Promise<void>;
|
|
64
|
+
finish(args: {
|
|
65
|
+
cancelled: boolean;
|
|
66
|
+
}): void;
|
|
67
|
+
teardown(): void;
|
|
68
|
+
private getUserMedia;
|
|
69
|
+
private createRecorder;
|
|
70
|
+
private sendBlob;
|
|
71
|
+
private stopCapture;
|
|
72
|
+
private reset;
|
|
73
|
+
private now;
|
|
74
|
+
private setInterval;
|
|
75
|
+
private clearInterval;
|
|
76
|
+
}
|
|
77
|
+
export {};
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ import { default as AgentWrap } from './ui/AgentWrap.vue';
|
|
|
6
6
|
import { default as ElAgentChat } from './ui/ElAgentChat.vue';
|
|
7
7
|
import { default as ElAgentChatPreview } from './ui/ElAgentChatPreview.vue';
|
|
8
8
|
export { AgentChatController, AgentChatController as AgentController } from './AgentController';
|
|
9
|
-
export type { ChatStreamFn } from './AgentController';
|
|
9
|
+
export type { AgentChatComposerState, ChatStreamFn, ChatUploadFn } from './AgentController';
|
|
10
10
|
export * from './schema';
|
|
11
11
|
export { AgentChat, AgentModal, AgentProvider, AgentWidget, AgentWrap, ElAgentChat, ElAgentChatPreview };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AgentChatController } from '../AgentController';
|
|
2
|
-
import { ChatAttachment } from '../schema';
|
|
3
2
|
import { Agent } from '@pagelines/core';
|
|
4
3
|
import { nextTick } from 'vue';
|
|
5
4
|
type ChatScope = 'private' | 'org' | 'public';
|
|
@@ -7,11 +6,12 @@ type __VLS_Props = {
|
|
|
7
6
|
chatController?: AgentChatController;
|
|
8
7
|
agent: Agent;
|
|
9
8
|
variant?: 'dark' | 'light';
|
|
10
|
-
uploadFn?: (file: File) => Promise<ChatAttachment>;
|
|
11
9
|
scope?: ChatScope;
|
|
12
10
|
scopeName?: string;
|
|
13
11
|
setupHint?: string;
|
|
14
12
|
emptyStateMessage?: string;
|
|
13
|
+
showHeader?: boolean;
|
|
14
|
+
headerMeta?: string;
|
|
15
15
|
};
|
|
16
16
|
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
17
17
|
chatScroller: ({
|