@myned-ai/avatar-chat-widget 0.9.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) {
|
|
@@ -5640,7 +5649,8 @@ class AvatarChatElement extends HTMLElement {
|
|
|
5640
5649
|
};
|
|
5641
5650
|
logger.setLevel(logLevels[this.config.logLevel || "error"]);
|
|
5642
5651
|
setConfig({
|
|
5643
|
-
websocket: { url: this.config.serverUrl }
|
|
5652
|
+
websocket: { url: this.config.serverUrl },
|
|
5653
|
+
auth: { enabled: this.config.authEnabled ?? false }
|
|
5644
5654
|
});
|
|
5645
5655
|
}
|
|
5646
5656
|
/**
|
|
@@ -6159,6 +6169,20 @@ class AvatarChatElement extends HTMLElement {
|
|
|
6159
6169
|
this.chatManager.sendText(text);
|
|
6160
6170
|
}
|
|
6161
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
|
+
}
|
|
6162
6186
|
/**
|
|
6163
6187
|
* Check if mounted
|
|
6164
6188
|
*/
|
|
@@ -6370,7 +6394,8 @@ const AvatarChat = {
|
|
|
6370
6394
|
collapse: () => widget.collapse(),
|
|
6371
6395
|
isMounted: () => widget.isMounted(),
|
|
6372
6396
|
isConnected: () => widget.isServerConnected(),
|
|
6373
|
-
reconnect: () => widget.reconnect()
|
|
6397
|
+
reconnect: () => widget.reconnect(),
|
|
6398
|
+
triggerAction: (name, args) => widget.triggerAction(name, args)
|
|
6374
6399
|
};
|
|
6375
6400
|
},
|
|
6376
6401
|
/**
|
|
@@ -6401,7 +6426,8 @@ const AvatarChat = {
|
|
|
6401
6426
|
collapse: () => widget.collapse(),
|
|
6402
6427
|
isMounted: () => widget.isMounted(),
|
|
6403
6428
|
isConnected: () => widget.isServerConnected(),
|
|
6404
|
-
reconnect: () => widget.reconnect()
|
|
6429
|
+
reconnect: () => widget.reconnect(),
|
|
6430
|
+
triggerAction: (name, args) => widget.triggerAction(name, args)
|
|
6405
6431
|
};
|
|
6406
6432
|
}
|
|
6407
6433
|
};
|