@myned-ai/avatar-chat-widget 0.10.0 → 0.11.0

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.
@@ -137,6 +137,11 @@ declare class AvatarChatElement extends HTMLElement {
137
137
  * Send message programmatically
138
138
  */
139
139
  sendMessage(text: string): void;
140
+ /**
141
+ * Expose triggerAction for client-side Actions debugging
142
+ * Dispatches a custom nyxAction event as if the server triggered it
143
+ */
144
+ triggerAction(function_name: string, args?: Record<string, any>): void;
140
145
  /**
141
146
  * Check if mounted
142
147
  */
@@ -546,6 +546,7 @@ class AvatarProtocolClient extends EventEmitter {
546
546
  this.socket.on("transcript_done", (msg) => this.handleTranscriptDone(msg));
547
547
  this.socket.on("interrupt", (msg) => this.handleInterrupt(msg));
548
548
  this.socket.on("avatar_state", (msg) => this.emit("avatar_state", msg));
549
+ this.socket.on("trigger_action", (msg) => this.emit("trigger_action", msg));
549
550
  this.socket.on("pong", (msg) => log$h.debug("Pong received", msg));
550
551
  }
551
552
  // ------------------------------------------------------------------
@@ -3922,11 +3923,19 @@ class ChatManager {
3922
3923
  this.protocolClient.on("interrupt", (event) => {
3923
3924
  this.handleInterrupt(event);
3924
3925
  });
3926
+ this.protocolClient.on("trigger_action", (event) => {
3927
+ this.handleTriggerAction(event);
3928
+ });
3925
3929
  this.protocolClient.on("error", (err) => log$4.error("Protocol Error:", err));
3926
3930
  }
3927
3931
  // ============================================================================
3928
3932
  // Protocol Handlers
3929
3933
  // ============================================================================
3934
+ handleTriggerAction(event) {
3935
+ log$4.info(`🎯 Action Triggered: ${event.function_name}`, event.arguments);
3936
+ const customEvent = new CustomEvent("nyxAction", { detail: event });
3937
+ window.dispatchEvent(customEvent);
3938
+ }
3930
3939
  handleAudioStart(event) {
3931
3940
  this.setTyping(false);
3932
3941
  if (this.syncFramesBeforeStart > 0) {
@@ -6160,6 +6169,20 @@ class AvatarChatElement extends HTMLElement {
6160
6169
  this.chatManager.sendText(text);
6161
6170
  }
6162
6171
  }
6172
+ /**
6173
+ * Expose triggerAction for client-side Actions debugging
6174
+ * Dispatches a custom nyxAction event as if the server triggered it
6175
+ */
6176
+ triggerAction(function_name, args = {}) {
6177
+ const eventDetail = {
6178
+ type: "trigger_action",
6179
+ function_name,
6180
+ arguments: args
6181
+ };
6182
+ log$2.info(`🛠️ Debug Action Triggered manually: ${function_name}`, args);
6183
+ const customEvent = new CustomEvent("nyxAction", { detail: eventDetail });
6184
+ window.dispatchEvent(customEvent);
6185
+ }
6163
6186
  /**
6164
6187
  * Check if mounted
6165
6188
  */
@@ -6371,7 +6394,8 @@ const AvatarChat = {
6371
6394
  collapse: () => widget.collapse(),
6372
6395
  isMounted: () => widget.isMounted(),
6373
6396
  isConnected: () => widget.isServerConnected(),
6374
- reconnect: () => widget.reconnect()
6397
+ reconnect: () => widget.reconnect(),
6398
+ triggerAction: (name, args) => widget.triggerAction(name, args)
6375
6399
  };
6376
6400
  },
6377
6401
  /**
@@ -6402,7 +6426,8 @@ const AvatarChat = {
6402
6426
  collapse: () => widget.collapse(),
6403
6427
  isMounted: () => widget.isMounted(),
6404
6428
  isConnected: () => widget.isServerConnected(),
6405
- reconnect: () => widget.reconnect()
6429
+ reconnect: () => widget.reconnect(),
6430
+ triggerAction: (name, args) => widget.triggerAction(name, args)
6406
6431
  };
6407
6432
  }
6408
6433
  };