avin-ai 0.2.1 → 0.2.2
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/avin-ai.es.js +2 -2
- package/dist/avin-ai.js +1 -1
- package/dist/avin-ai.umd.js +1 -1
- package/package.json +1 -1
package/dist/avin-ai.es.js
CHANGED
|
@@ -2084,9 +2084,9 @@ class Ae extends Z {
|
|
|
2084
2084
|
var i, n, o, r;
|
|
2085
2085
|
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://api.avin.ai", (r = (o = (n = e.agent) == null ? void 0 : n.tts_voice) == null ? void 0 : o.provider) != null && r.root_name) {
|
|
2086
2086
|
const a = e.agent.tts_voice.provider.root_name.toLowerCase();
|
|
2087
|
-
this.mediaServerUrl = a === "premium" ? e.premiumMediaServerUrl || "https://godspeed.
|
|
2087
|
+
this.mediaServerUrl = a === "premium" ? e.premiumMediaServerUrl || "https://godspeed.travelr.club" : e.mediaServerUrl || "https://in-godspeed.travelr.club";
|
|
2088
2088
|
} else
|
|
2089
|
-
this.mediaServerUrl = e.mediaServerUrl || e.serverUrl || "https://api.
|
|
2089
|
+
this.mediaServerUrl = e.mediaServerUrl || e.serverUrl || "https://api.travelr.club";
|
|
2090
2090
|
}
|
|
2091
2091
|
async create_call() {
|
|
2092
2092
|
if (!(this.callActive || !this.agentId))
|
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://api.avin.ai",(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.
|
|
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://api.avin.ai",(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=`
|
|
959
959
|
${Z}
|
|
960
960
|
:host { ${K(this.primaryColor,this.secondaryColor)} }
|
|
961
961
|
${H.styles}
|
package/dist/avin-ai.umd.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 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://api.avin.ai",(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.
|
|
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://api.avin.ai",(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=`
|
|
959
959
|
${K}
|
|
960
960
|
:host { ${V(this.primaryColor,this.secondaryColor)} }
|
|
961
961
|
${H.styles}
|