convo-ai-sdk 1.1.2 → 1.1.4

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 CHANGED
@@ -15,6 +15,7 @@ export declare class ChatClient {
15
15
  private _loadHistory;
16
16
  on<T>(event: ChatEvent, callback: (data: T) => void): void;
17
17
  connect(sessionToken?: string): Promise<void>;
18
+ requestWidget(widgetType: string, widgetData: any): Promise<void>;
18
19
  sendToolResult(toolCallId: string, toolCallName: any, result: any): Promise<void>;
19
20
  sendMessage(text: string): Promise<void>;
20
21
  toolCall(tool_call: any): Promise<void>;
package/dist/index.js CHANGED
@@ -182,6 +182,19 @@ export class ChatClient {
182
182
  }
183
183
  this._setStatus('connected');
184
184
  }
185
+ async requestWidget(widgetType, widgetData) {
186
+ if (this.status !== 'connected') {
187
+ console.error('Cannot request widget, not connected.');
188
+ return;
189
+ }
190
+ const widgetMessage = {
191
+ id: `widget-${Date.now()}`,
192
+ data: { widgetType: widgetType, content: widgetData },
193
+ from: 'widget',
194
+ timestamp: Date.now(),
195
+ };
196
+ await this.sendStreamMessage(widgetMessage);
197
+ }
185
198
  async sendToolResult(toolCallId, toolCallName, result) {
186
199
  if (this.status !== 'connected') {
187
200
  console.error('Cannot send tool result, not connected.');
@@ -193,8 +206,6 @@ export class ChatClient {
193
206
  from: 'tool',
194
207
  timestamp: Date.now(),
195
208
  };
196
- // this._addMessage(toolMessage);
197
- // this._emit('message', toolMessage);
198
209
  await this.sendStreamMessage(toolMessage);
199
210
  }
200
211
  async sendMessage(text) {
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';
6
+ from: 'user' | 'assistant' | 'system' | 'tool' | 'widget';
7
7
  timestamp: number;
8
8
  }
9
9
  export interface ChatConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "convo-ai-sdk",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",