convo-ai-sdk 1.2.6 → 1.2.7
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/index.d.ts +2 -0
- package/dist/index.js +22 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export declare class ChatClient {
|
|
|
27
27
|
} | null>;
|
|
28
28
|
sendTranscriptionMessage(transcriptionText: string, transcriptionKey: string, modified?: boolean): Promise<void>;
|
|
29
29
|
sendMessage(text: string): Promise<void>;
|
|
30
|
+
sendActionMessage(text: string): Promise<void>;
|
|
31
|
+
submitDataActionMessage(submitType: string | undefined, data: Record<string, any>): Promise<void>;
|
|
30
32
|
toolCall(tool_call: any): Promise<void>;
|
|
31
33
|
sendStreamMessage(message: ChatMessage): Promise<void>;
|
|
32
34
|
disconnect(): void;
|
package/dist/index.js
CHANGED
|
@@ -302,6 +302,28 @@ export class ChatClient {
|
|
|
302
302
|
this._emit('message', userMessage);
|
|
303
303
|
await this.sendStreamMessage(userMessage);
|
|
304
304
|
}
|
|
305
|
+
async sendActionMessage(text) {
|
|
306
|
+
if (this.status !== 'connected') {
|
|
307
|
+
console.error('Cannot send message, not connected.');
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
// TODO: Replace from user with from 'agent_wake_up'
|
|
311
|
+
const userMessage = {
|
|
312
|
+
id: `local-${Date.now()}`,
|
|
313
|
+
data: { content: text },
|
|
314
|
+
from: 'action',
|
|
315
|
+
timestamp: Date.now(),
|
|
316
|
+
};
|
|
317
|
+
await this.sendStreamMessage(userMessage);
|
|
318
|
+
}
|
|
319
|
+
async submitDataActionMessage(submitType = 'action', data) {
|
|
320
|
+
if (this.status !== 'connected') {
|
|
321
|
+
console.error('Cannot submit data, not connected.');
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const submitMessageContent = `<${submitType}>${JSON.stringify(data)}</${submitType}>`;
|
|
325
|
+
await this.sendActionMessage(submitMessageContent);
|
|
326
|
+
}
|
|
305
327
|
async toolCall(tool_call) {
|
|
306
328
|
this._emit('toolCall', tool_call);
|
|
307
329
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type ConversationStatus = 'started' | 'awaiting_user' | 'ended_by_system'
|
|
|
3
3
|
export interface ChatMessage {
|
|
4
4
|
id: string | number;
|
|
5
5
|
data: any;
|
|
6
|
-
from: 'user' | 'assistant' | 'system' | 'tool' | 'widget' | 'transcription';
|
|
6
|
+
from: 'user' | 'assistant' | 'system' | 'tool' | 'widget' | 'transcription' | 'action';
|
|
7
7
|
timestamp: number;
|
|
8
8
|
}
|
|
9
9
|
export interface ChatConfig {
|