avin-ai 0.2.3 → 0.2.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.
@@ -2108,7 +2108,7 @@ class Ae extends Z {
2108
2108
  (a = (r = this.currentView) == null ? void 0 : r.setTranscription) == null || a.call(r, n, o);
2109
2109
  }).on("track", ({ track: n }) => {
2110
2110
  var o;
2111
- n.kind === "video" && ((o = this.currentView) != null && o.setVideoTrack) && this.currentView.setVideoTrack(n);
2111
+ this.widgetMode.includes("avatar") && n.kind === "video" && ((o = this.currentView) != null && o.setVideoTrack) && this.currentView.setVideoTrack(n);
2112
2112
  }).on("tool_call", (n) => {
2113
2113
  var r, a;
2114
2114
  const o = new CustomEvent("avinai:tool_call", {
package/dist/avin-ai.js CHANGED
@@ -955,7 +955,7 @@ overflow: hidden;
955
955
  <div style="position: absolute; bottom: -2px; right: -2px; background: white; border-radius: 50%; padding: 2px; box-shadow: 0 1px 2px rgba(0,0,0,0.1);">
956
956
  ${d.audioLines.replace('width="24"','width="12"').replace('height="24"','height="12"')}
957
957
  </div>
958
- `;const e=t.querySelector("div");if(e){const o=e.querySelector("svg");o&&(o.style.width="12px",o.style.height="12px")}t.onclick=()=>this.onStartCall();const i=this.chatWindow.getElement().querySelector(".chat-input-area"),n=i==null?void 0:i.querySelector(".chat-send-btn");i&&n?i.insertBefore(this.voiceTrigger,n):console.warn("AvinSDK: Failed to inject voice trigger",{inputArea:i,sendBtn:n})}}class se{async sendMessage(t,e,i,n,o,r,a){return v.sendChatMessage(e,i,t,n,A=>{r&&r(A)},o,A=>{a&&A&&a(A)})}async sendFile(t){throw console.warn("sendFile not implemented for AvinChatAdapter yet - Incompatible function adapted",t),new Error("Method not implemented.")}async likeDislike(t,e){console.warn("likeDislike not implemented for AvinChatAdapter yet - Incompatible function adapted",t,e)}}class oe extends F{constructor(e){super(e);s(this,"avinClient",null);s(this,"currentView",null);s(this,"isPanelOpen",!1);s(this,"callActive",!1);s(this,"eventSource",null);s(this,"floatingButton",null);s(this,"floatingWelcomeChips",null);s(this,"panel",null);s(this,"welcomeChipsData",[]);s(this,"chatAdapter");s(this,"widgetMode","voice_only");s(this,"agentId","");s(this,"prospectGroupId","");s(this,"chatServerUrl","");s(this,"mediaServerUrl","");s(this,"prospectId","");s(this,"chatId",null);s(this,"primaryColor","#6366f1");s(this,"secondaryColor","#4f46e5");s(this,"gradient",null);s(this,"position","bottom-right");s(this,"widgetIcon",null);this.chatAdapter=new se,this.processConfig(e)}async initializeChatSession(){var e,i,n;try{v.setChatUrl(this.chatServerUrl),this.prospectGroupId?this.prospectId=await v.createChatProspect(this.prospectGroupId):this.prospectId=`anon_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;const o=await v.fetchWelcomeMessage(this.agentId,this.prospectId);if(o&&o.chatId&&!this.chatId&&(this.chatId=o.chatId,this.eventSource||(this.eventSource=v.listenForAdminReplies(this.chatId,this.prospectId,r=>{var a,A;(A=(a=this.currentView)==null?void 0:a.getChatWindow)==null||A.call(a).addMessage("assistant",r)}))),o&&((e=this.currentView)!=null&&e.getChatWindow)){const r=this.currentView.getChatWindow();if(r.clearMessages(),o.widget)try{const a=JSON.parse(o.content);r.addMessage(o.role,a.text||""),a.buttons&&Array.isArray(a.buttons)&&(r.addButtons(a.buttons),this.welcomeChipsData=a.buttons),this.updateWelcomeChipsVisibility()}catch(a){console.error("Failed to parse welcome widget content",a),r.addMessage(o.role,o.content)}else r.addMessage(o.role,o.content)}}catch(o){console.error("Chat init failed",o),(n=(i=this.currentView)==null?void 0:i.getChatWindow)==null||n.call(i).addMessage("assistant","Hello! How can I help you today?")}}async initialize(e){await super.initialize(e),this.processConfig(e),this.root&&this.ui_renderer(this.root)}processConfig(e){var i,n,o,r;if(this.agentId=e.agentId||e.agent_id||"",this.prospectGroupId=e.prospectGroupId||((i=e.client)==null?void 0:i.base_prospect_group_id)||"",this.widgetMode=e.widgetMode||e.mode||"voice_only",this.primaryColor=e.primaryColor||"#6366f1",this.secondaryColor=e.secondaryColor||e.primaryColor||"#4f46e5",this.gradient=e.gradient||null,this.position=e.position||"bottom-right",this.widgetIcon=e.widgetIcon||e.icon||null,this.chatServerUrl=e.serverUrl||e.chatServerUrl||"https://inboxapi.travelr.club",(r=(o=(n=e.agent)==null?void 0:n.tts_voice)==null?void 0:o.provider)!=null&&r.root_name){const a=e.agent.tts_voice.provider.root_name.toLowerCase();this.mediaServerUrl=a==="premium"?e.premiumMediaServerUrl||"https://godspeed.travelr.club":e.mediaServerUrl||"https://in-godspeed.travelr.club"}else this.mediaServerUrl=e.mediaServerUrl||e.serverUrl||"https://api.travelr.club"}async create_call(){if(!(this.callActive||!this.agentId))try{this.callActive=!0,this.updateViewCallState(!0),this.updateViewStatus("connecting");const e=await v.createCall(this.agentId,this.prospectId||null,this.widgetMode),i=new Y({agentId:this.agentId,callId:e,serverUrl:this.mediaServerUrl});i.on("connected",()=>this.updateViewStatus("connected")).on("disconnected",()=>this.end_call()).on("error",n=>{console.error("[AvinAI Widget] Call error:",n),this.updateViewStatus("error")}).on("transcription",({text:n,isFinal:o})=>{var r,a;(a=(r=this.currentView)==null?void 0:r.setTranscription)==null||a.call(r,n,o)}).on("track",({track:n})=>{var o;n.kind==="video"&&((o=this.currentView)!=null&&o.setVideoTrack)&&this.currentView.setVideoTrack(n)}).on("tool_call",n=>{var r,a;const o=new CustomEvent("avinai:tool_call",{detail:n,bubbles:!0,composed:!0});(a=(r=this.root)==null?void 0:r.host)==null||a.dispatchEvent(o),console.log("[AvinAI Widget] Tool call dispatched:",n.name,n.arguments),n.execution_mode}),this.avinClient=i,await i.start()}catch(e){console.error("[AvinAI Widget] Call failed",e),this.updateViewStatus("error")}}end_call(){this.callActive=!1;const e=this.avinClient;this.avinClient=null,e&&e.stop(),this.updateViewCallState(!1)}updateViewCallState(e){this.currentView&&this.currentView.setCallActive&&this.currentView.setCallActive(e)}updateViewStatus(e){this.currentView&&this.currentView.setStatus&&this.currentView.setStatus(e)}ui_renderer(e){this.root=e,this.root.innerHTML="";const i=document.createElement("style");i.textContent=`
958
+ `;const e=t.querySelector("div");if(e){const o=e.querySelector("svg");o&&(o.style.width="12px",o.style.height="12px")}t.onclick=()=>this.onStartCall();const i=this.chatWindow.getElement().querySelector(".chat-input-area"),n=i==null?void 0:i.querySelector(".chat-send-btn");i&&n?i.insertBefore(this.voiceTrigger,n):console.warn("AvinSDK: Failed to inject voice trigger",{inputArea:i,sendBtn:n})}}class se{async sendMessage(t,e,i,n,o,r,a){return v.sendChatMessage(e,i,t,n,A=>{r&&r(A)},o,A=>{a&&A&&a(A)})}async sendFile(t){throw console.warn("sendFile not implemented for AvinChatAdapter yet - Incompatible function adapted",t),new Error("Method not implemented.")}async likeDislike(t,e){console.warn("likeDislike not implemented for AvinChatAdapter yet - Incompatible function adapted",t,e)}}class oe extends F{constructor(e){super(e);s(this,"avinClient",null);s(this,"currentView",null);s(this,"isPanelOpen",!1);s(this,"callActive",!1);s(this,"eventSource",null);s(this,"floatingButton",null);s(this,"floatingWelcomeChips",null);s(this,"panel",null);s(this,"welcomeChipsData",[]);s(this,"chatAdapter");s(this,"widgetMode","voice_only");s(this,"agentId","");s(this,"prospectGroupId","");s(this,"chatServerUrl","");s(this,"mediaServerUrl","");s(this,"prospectId","");s(this,"chatId",null);s(this,"primaryColor","#6366f1");s(this,"secondaryColor","#4f46e5");s(this,"gradient",null);s(this,"position","bottom-right");s(this,"widgetIcon",null);this.chatAdapter=new se,this.processConfig(e)}async initializeChatSession(){var e,i,n;try{v.setChatUrl(this.chatServerUrl),this.prospectGroupId?this.prospectId=await v.createChatProspect(this.prospectGroupId):this.prospectId=`anon_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;const o=await v.fetchWelcomeMessage(this.agentId,this.prospectId);if(o&&o.chatId&&!this.chatId&&(this.chatId=o.chatId,this.eventSource||(this.eventSource=v.listenForAdminReplies(this.chatId,this.prospectId,r=>{var a,A;(A=(a=this.currentView)==null?void 0:a.getChatWindow)==null||A.call(a).addMessage("assistant",r)}))),o&&((e=this.currentView)!=null&&e.getChatWindow)){const r=this.currentView.getChatWindow();if(r.clearMessages(),o.widget)try{const a=JSON.parse(o.content);r.addMessage(o.role,a.text||""),a.buttons&&Array.isArray(a.buttons)&&(r.addButtons(a.buttons),this.welcomeChipsData=a.buttons),this.updateWelcomeChipsVisibility()}catch(a){console.error("Failed to parse welcome widget content",a),r.addMessage(o.role,o.content)}else r.addMessage(o.role,o.content)}}catch(o){console.error("Chat init failed",o),(n=(i=this.currentView)==null?void 0:i.getChatWindow)==null||n.call(i).addMessage("assistant","Hello! How can I help you today?")}}async initialize(e){await super.initialize(e),this.processConfig(e),this.root&&this.ui_renderer(this.root)}processConfig(e){var i,n,o,r;if(this.agentId=e.agentId||e.agent_id||"",this.prospectGroupId=e.prospectGroupId||((i=e.client)==null?void 0:i.base_prospect_group_id)||"",this.widgetMode=e.widgetMode||e.mode||"voice_only",this.primaryColor=e.primaryColor||"#6366f1",this.secondaryColor=e.secondaryColor||e.primaryColor||"#4f46e5",this.gradient=e.gradient||null,this.position=e.position||"bottom-right",this.widgetIcon=e.widgetIcon||e.icon||null,this.chatServerUrl=e.serverUrl||e.chatServerUrl||"https://inboxapi.travelr.club",(r=(o=(n=e.agent)==null?void 0:n.tts_voice)==null?void 0:o.provider)!=null&&r.root_name){const a=e.agent.tts_voice.provider.root_name.toLowerCase();this.mediaServerUrl=a==="premium"?e.premiumMediaServerUrl||"https://godspeed.travelr.club":e.mediaServerUrl||"https://in-godspeed.travelr.club"}else this.mediaServerUrl=e.mediaServerUrl||e.serverUrl||"https://api.travelr.club"}async create_call(){if(!(this.callActive||!this.agentId))try{this.callActive=!0,this.updateViewCallState(!0),this.updateViewStatus("connecting");const e=await v.createCall(this.agentId,this.prospectId||null,this.widgetMode),i=new Y({agentId:this.agentId,callId:e,serverUrl:this.mediaServerUrl});i.on("connected",()=>this.updateViewStatus("connected")).on("disconnected",()=>this.end_call()).on("error",n=>{console.error("[AvinAI Widget] Call error:",n),this.updateViewStatus("error")}).on("transcription",({text:n,isFinal:o})=>{var r,a;(a=(r=this.currentView)==null?void 0:r.setTranscription)==null||a.call(r,n,o)}).on("track",({track:n})=>{var o;this.widgetMode.includes("avatar")&&n.kind==="video"&&((o=this.currentView)!=null&&o.setVideoTrack)&&this.currentView.setVideoTrack(n)}).on("tool_call",n=>{var r,a;const o=new CustomEvent("avinai:tool_call",{detail:n,bubbles:!0,composed:!0});(a=(r=this.root)==null?void 0:r.host)==null||a.dispatchEvent(o),console.log("[AvinAI Widget] Tool call dispatched:",n.name,n.arguments),n.execution_mode}),this.avinClient=i,await i.start()}catch(e){console.error("[AvinAI Widget] Call failed",e),this.updateViewStatus("error")}}end_call(){this.callActive=!1;const e=this.avinClient;this.avinClient=null,e&&e.stop(),this.updateViewCallState(!1)}updateViewCallState(e){this.currentView&&this.currentView.setCallActive&&this.currentView.setCallActive(e)}updateViewStatus(e){this.currentView&&this.currentView.setStatus&&this.currentView.setStatus(e)}ui_renderer(e){this.root=e,this.root.innerHTML="";const i=document.createElement("style");i.textContent=`
959
959
  ${Z}
960
960
  :host { ${K(this.primaryColor,this.secondaryColor)} }
961
961
  ${H.styles}
@@ -955,7 +955,7 @@ overflow: hidden;
955
955
  <div style="position: absolute; bottom: -2px; right: -2px; background: white; border-radius: 50%; padding: 2px; box-shadow: 0 1px 2px rgba(0,0,0,0.1);">
956
956
  ${d.audioLines.replace('width="24"','width="12"').replace('height="24"','height="12"')}
957
957
  </div>
958
- `;const e=t.querySelector("div");if(e){const o=e.querySelector("svg");o&&(o.style.width="12px",o.style.height="12px")}t.onclick=()=>this.onStartCall();const i=this.chatWindow.getElement().querySelector(".chat-input-area"),n=i==null?void 0:i.querySelector(".chat-send-btn");i&&n?i.insertBefore(this.voiceTrigger,n):console.warn("AvinSDK: Failed to inject voice trigger",{inputArea:i,sendBtn:n})}}class ne{async sendMessage(t,e,i,n,o,r,a){return y.sendChatMessage(e,i,t,n,A=>{r&&r(A)},o,A=>{a&&A&&a(A)})}async sendFile(t){throw console.warn("sendFile not implemented for AvinChatAdapter yet - Incompatible function adapted",t),new Error("Method not implemented.")}async likeDislike(t,e){console.warn("likeDislike not implemented for AvinChatAdapter yet - Incompatible function adapted",t,e)}}class se extends F{constructor(e){super(e);s(this,"avinClient",null);s(this,"currentView",null);s(this,"isPanelOpen",!1);s(this,"callActive",!1);s(this,"eventSource",null);s(this,"floatingButton",null);s(this,"floatingWelcomeChips",null);s(this,"panel",null);s(this,"welcomeChipsData",[]);s(this,"chatAdapter");s(this,"widgetMode","voice_only");s(this,"agentId","");s(this,"prospectGroupId","");s(this,"chatServerUrl","");s(this,"mediaServerUrl","");s(this,"prospectId","");s(this,"chatId",null);s(this,"primaryColor","#6366f1");s(this,"secondaryColor","#4f46e5");s(this,"gradient",null);s(this,"position","bottom-right");s(this,"widgetIcon",null);this.chatAdapter=new ne,this.processConfig(e)}async initializeChatSession(){var e,i,n;try{y.setChatUrl(this.chatServerUrl),this.prospectGroupId?this.prospectId=await y.createChatProspect(this.prospectGroupId):this.prospectId=`anon_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;const o=await y.fetchWelcomeMessage(this.agentId,this.prospectId);if(o&&o.chatId&&!this.chatId&&(this.chatId=o.chatId,this.eventSource||(this.eventSource=y.listenForAdminReplies(this.chatId,this.prospectId,r=>{var a,A;(A=(a=this.currentView)==null?void 0:a.getChatWindow)==null||A.call(a).addMessage("assistant",r)}))),o&&((e=this.currentView)!=null&&e.getChatWindow)){const r=this.currentView.getChatWindow();if(r.clearMessages(),o.widget)try{const a=JSON.parse(o.content);r.addMessage(o.role,a.text||""),a.buttons&&Array.isArray(a.buttons)&&(r.addButtons(a.buttons),this.welcomeChipsData=a.buttons),this.updateWelcomeChipsVisibility()}catch(a){console.error("Failed to parse welcome widget content",a),r.addMessage(o.role,o.content)}else r.addMessage(o.role,o.content)}}catch(o){console.error("Chat init failed",o),(n=(i=this.currentView)==null?void 0:i.getChatWindow)==null||n.call(i).addMessage("assistant","Hello! How can I help you today?")}}async initialize(e){await super.initialize(e),this.processConfig(e),this.root&&this.ui_renderer(this.root)}processConfig(e){var i,n,o,r;if(this.agentId=e.agentId||e.agent_id||"",this.prospectGroupId=e.prospectGroupId||((i=e.client)==null?void 0:i.base_prospect_group_id)||"",this.widgetMode=e.widgetMode||e.mode||"voice_only",this.primaryColor=e.primaryColor||"#6366f1",this.secondaryColor=e.secondaryColor||e.primaryColor||"#4f46e5",this.gradient=e.gradient||null,this.position=e.position||"bottom-right",this.widgetIcon=e.widgetIcon||e.icon||null,this.chatServerUrl=e.serverUrl||e.chatServerUrl||"https://inboxapi.travelr.club",(r=(o=(n=e.agent)==null?void 0:n.tts_voice)==null?void 0:o.provider)!=null&&r.root_name){const a=e.agent.tts_voice.provider.root_name.toLowerCase();this.mediaServerUrl=a==="premium"?e.premiumMediaServerUrl||"https://godspeed.travelr.club":e.mediaServerUrl||"https://in-godspeed.travelr.club"}else this.mediaServerUrl=e.mediaServerUrl||e.serverUrl||"https://api.travelr.club"}async create_call(){if(!(this.callActive||!this.agentId))try{this.callActive=!0,this.updateViewCallState(!0),this.updateViewStatus("connecting");const e=await y.createCall(this.agentId,this.prospectId||null,this.widgetMode),i=new M({agentId:this.agentId,callId:e,serverUrl:this.mediaServerUrl});i.on("connected",()=>this.updateViewStatus("connected")).on("disconnected",()=>this.end_call()).on("error",n=>{console.error("[AvinAI Widget] Call error:",n),this.updateViewStatus("error")}).on("transcription",({text:n,isFinal:o})=>{var r,a;(a=(r=this.currentView)==null?void 0:r.setTranscription)==null||a.call(r,n,o)}).on("track",({track:n})=>{var o;n.kind==="video"&&((o=this.currentView)!=null&&o.setVideoTrack)&&this.currentView.setVideoTrack(n)}).on("tool_call",n=>{var r,a;const o=new CustomEvent("avinai:tool_call",{detail:n,bubbles:!0,composed:!0});(a=(r=this.root)==null?void 0:r.host)==null||a.dispatchEvent(o),console.log("[AvinAI Widget] Tool call dispatched:",n.name,n.arguments),n.execution_mode}),this.avinClient=i,await i.start()}catch(e){console.error("[AvinAI Widget] Call failed",e),this.updateViewStatus("error")}}end_call(){this.callActive=!1;const e=this.avinClient;this.avinClient=null,e&&e.stop(),this.updateViewCallState(!1)}updateViewCallState(e){this.currentView&&this.currentView.setCallActive&&this.currentView.setCallActive(e)}updateViewStatus(e){this.currentView&&this.currentView.setStatus&&this.currentView.setStatus(e)}ui_renderer(e){this.root=e,this.root.innerHTML="";const i=document.createElement("style");i.textContent=`
958
+ `;const e=t.querySelector("div");if(e){const o=e.querySelector("svg");o&&(o.style.width="12px",o.style.height="12px")}t.onclick=()=>this.onStartCall();const i=this.chatWindow.getElement().querySelector(".chat-input-area"),n=i==null?void 0:i.querySelector(".chat-send-btn");i&&n?i.insertBefore(this.voiceTrigger,n):console.warn("AvinSDK: Failed to inject voice trigger",{inputArea:i,sendBtn:n})}}class ne{async sendMessage(t,e,i,n,o,r,a){return y.sendChatMessage(e,i,t,n,A=>{r&&r(A)},o,A=>{a&&A&&a(A)})}async sendFile(t){throw console.warn("sendFile not implemented for AvinChatAdapter yet - Incompatible function adapted",t),new Error("Method not implemented.")}async likeDislike(t,e){console.warn("likeDislike not implemented for AvinChatAdapter yet - Incompatible function adapted",t,e)}}class se extends F{constructor(e){super(e);s(this,"avinClient",null);s(this,"currentView",null);s(this,"isPanelOpen",!1);s(this,"callActive",!1);s(this,"eventSource",null);s(this,"floatingButton",null);s(this,"floatingWelcomeChips",null);s(this,"panel",null);s(this,"welcomeChipsData",[]);s(this,"chatAdapter");s(this,"widgetMode","voice_only");s(this,"agentId","");s(this,"prospectGroupId","");s(this,"chatServerUrl","");s(this,"mediaServerUrl","");s(this,"prospectId","");s(this,"chatId",null);s(this,"primaryColor","#6366f1");s(this,"secondaryColor","#4f46e5");s(this,"gradient",null);s(this,"position","bottom-right");s(this,"widgetIcon",null);this.chatAdapter=new ne,this.processConfig(e)}async initializeChatSession(){var e,i,n;try{y.setChatUrl(this.chatServerUrl),this.prospectGroupId?this.prospectId=await y.createChatProspect(this.prospectGroupId):this.prospectId=`anon_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;const o=await y.fetchWelcomeMessage(this.agentId,this.prospectId);if(o&&o.chatId&&!this.chatId&&(this.chatId=o.chatId,this.eventSource||(this.eventSource=y.listenForAdminReplies(this.chatId,this.prospectId,r=>{var a,A;(A=(a=this.currentView)==null?void 0:a.getChatWindow)==null||A.call(a).addMessage("assistant",r)}))),o&&((e=this.currentView)!=null&&e.getChatWindow)){const r=this.currentView.getChatWindow();if(r.clearMessages(),o.widget)try{const a=JSON.parse(o.content);r.addMessage(o.role,a.text||""),a.buttons&&Array.isArray(a.buttons)&&(r.addButtons(a.buttons),this.welcomeChipsData=a.buttons),this.updateWelcomeChipsVisibility()}catch(a){console.error("Failed to parse welcome widget content",a),r.addMessage(o.role,o.content)}else r.addMessage(o.role,o.content)}}catch(o){console.error("Chat init failed",o),(n=(i=this.currentView)==null?void 0:i.getChatWindow)==null||n.call(i).addMessage("assistant","Hello! How can I help you today?")}}async initialize(e){await super.initialize(e),this.processConfig(e),this.root&&this.ui_renderer(this.root)}processConfig(e){var i,n,o,r;if(this.agentId=e.agentId||e.agent_id||"",this.prospectGroupId=e.prospectGroupId||((i=e.client)==null?void 0:i.base_prospect_group_id)||"",this.widgetMode=e.widgetMode||e.mode||"voice_only",this.primaryColor=e.primaryColor||"#6366f1",this.secondaryColor=e.secondaryColor||e.primaryColor||"#4f46e5",this.gradient=e.gradient||null,this.position=e.position||"bottom-right",this.widgetIcon=e.widgetIcon||e.icon||null,this.chatServerUrl=e.serverUrl||e.chatServerUrl||"https://inboxapi.travelr.club",(r=(o=(n=e.agent)==null?void 0:n.tts_voice)==null?void 0:o.provider)!=null&&r.root_name){const a=e.agent.tts_voice.provider.root_name.toLowerCase();this.mediaServerUrl=a==="premium"?e.premiumMediaServerUrl||"https://godspeed.travelr.club":e.mediaServerUrl||"https://in-godspeed.travelr.club"}else this.mediaServerUrl=e.mediaServerUrl||e.serverUrl||"https://api.travelr.club"}async create_call(){if(!(this.callActive||!this.agentId))try{this.callActive=!0,this.updateViewCallState(!0),this.updateViewStatus("connecting");const e=await y.createCall(this.agentId,this.prospectId||null,this.widgetMode),i=new M({agentId:this.agentId,callId:e,serverUrl:this.mediaServerUrl});i.on("connected",()=>this.updateViewStatus("connected")).on("disconnected",()=>this.end_call()).on("error",n=>{console.error("[AvinAI Widget] Call error:",n),this.updateViewStatus("error")}).on("transcription",({text:n,isFinal:o})=>{var r,a;(a=(r=this.currentView)==null?void 0:r.setTranscription)==null||a.call(r,n,o)}).on("track",({track:n})=>{var o;this.widgetMode.includes("avatar")&&n.kind==="video"&&((o=this.currentView)!=null&&o.setVideoTrack)&&this.currentView.setVideoTrack(n)}).on("tool_call",n=>{var r,a;const o=new CustomEvent("avinai:tool_call",{detail:n,bubbles:!0,composed:!0});(a=(r=this.root)==null?void 0:r.host)==null||a.dispatchEvent(o),console.log("[AvinAI Widget] Tool call dispatched:",n.name,n.arguments),n.execution_mode}),this.avinClient=i,await i.start()}catch(e){console.error("[AvinAI Widget] Call failed",e),this.updateViewStatus("error")}}end_call(){this.callActive=!1;const e=this.avinClient;this.avinClient=null,e&&e.stop(),this.updateViewCallState(!1)}updateViewCallState(e){this.currentView&&this.currentView.setCallActive&&this.currentView.setCallActive(e)}updateViewStatus(e){this.currentView&&this.currentView.setStatus&&this.currentView.setStatus(e)}ui_renderer(e){this.root=e,this.root.innerHTML="";const i=document.createElement("style");i.textContent=`
959
959
  ${K}
960
960
  :host { ${V(this.primaryColor,this.secondaryColor)} }
961
961
  ${H.styles}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "avin-ai",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "AvinAI Voice & Chat Widget SDK — embed conversational AI into any website with one script tag",
5
5
  "author": "AvinAI <dev@avin.ai>",
6
6
  "license": "MIT",