profoundjs 7.11.0 → 7.12.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.
@@ -20,10 +20,10 @@ false},250)})});c.querySelectorAll("span.pai-citation").forEach(function(f){func
20
20
  j.addEventListener("mouseleave",function(){l()})}});f.addEventListener("mouseleave",function(){h=setTimeout(l,100)})});if(a.replace)(a=k.lastChild)&&a.classList.contains("pai-agent-response")&&a.parentNode.removeChild(a)}else c.innerText=d;k.appendChild(c);k.scrollTop=k.scrollHeight};this.clear=function(){o.classList.contains("pai-recording")&&q.stop();i.value="";k.innerHTML="";b.greeting&&b.add({message:b.greeting,type:"greeting"});b.setHeading(b.heading);b.setBrandColor(B);v();I=x=null};this.setTheme=
21
21
  function(a){G=a;G=typeof G!=="string"?"light":G.toLowerCase();G==="dark"?b.dom.classList.add("pai-dark"):b.dom.classList.remove("pai-dark")};this.setBrandColor=function(a){B=a;if(a=b.dom.querySelector(".pai-heading")){a.style.backgroundColor=null;a.style.backgroundImage=null;a.classList.remove("pai-branded")}t&&t.classList.remove("pai-branded");s.style.backgroundColor=null;if(B){var d=S(B,-30);if(a){a.style.backgroundColor=B;a.style.backgroundImage="linear-gradient(to right, "+B+", "+d+")";a.classList.add("pai-branded")}t&&
22
22
  a&&t.classList.add("pai-branded");s.style.backgroundColor=B}};this.setHeading=function(a){var d=b.dom.querySelector(".pai-heading");if(a){if(d===null){d=document.createElement("div");d.classList.add("pai-heading");b.dom.prepend(d);E()}d.innerText=a}else if(d!==null){d.remove();E()}};this.send=function(){if(i.value!=="")if(!b.isLoading()){if(o.classList.contains("pai-recording")){q.stop();o.classList.toggle("pai-recording")}b.onSend&&b.onSend(i.value);b.add({message:i.value});H=[];var a={};a.message=
23
- i.value;if(x)a.threadId=x;var d="/profound-ai/chat";if(g()){a.agentData=p();a.agentFile=Ext.c("centerPanel").e().title.replace(/\*/g,"").trim();w=pui.streamingModelList.includes(a.agentData.aiAgent.model);d="/ide/profound-ai/chat"}else a.agent=b.agent;var c=b.data;if(typeof c==="function")c=c();if(b.data)a.data=c;i.value="";E();i.focus();b.showLoader();c={"Content-Type":"application/json"};if(w){c.Connection="keep-alive";c["Response-Type"]="stream"}if(L){var e=L;if(typeof e==="function")e=e();c.Authorization=
24
- "Bearer "+e}fetch(F+d,{method:"POST",headers:c,body:JSON.stringify(a)}).then(function(f){return w?f.body.getReader():f.json()}).then(function(f){w?n(f):C(f)})["catch"](function(f){b.hideLoader();b.add({message:"Error: "+f.message,type:"error"})})}};this.poll=function(){if(!(!x||!I||!K)){var a={};a.threadId=x;a.runId=I;a.modelKey=K;var d="/profound-ai/poll";if(g())d="/ide/profound-ai/poll";fetch(F+d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}).then(function(c){return c.json()}).then(function(c){C(c)})["catch"](function(c){b.hideLoader();
25
- b.add({message:"Error: "+c.message,type:"error"})})}};this.showLoader=function(a){a||(a=P);J.innerText=a;if(!b.isLoading()){w?b.add({message:y,type:"agent-response"}):k.appendChild(A);v()}k.scrollTop=k.scrollHeight};this.hideLoader=function(){if(b.isLoading()){if(w)for(var a=k.querySelectorAll(".pai-inline-loader"),d=a.length-1;d>=0;d--)a[d].parentNode.removeChild(a[d]);else k.removeChild(A);v()}};this.isLoading=function(){if(w)return k.querySelectorAll(".pai-inline-loader").length>0;return A.parentNode===
26
- k};this.destroy=function(){if(b.dom){b.dom.parentNode.removeChild(b.dom);b.dom=null}};this.removeEmbedIcon=function(){profound.ai.removeEmbedIcon()}};profound.ai.d=function(g){if(!document.querySelector('link[href="'+g+'"]')){var p=document.createElement("link");p.rel="stylesheet";p.href=g;document.head.appendChild(p)}};
23
+ i.value;if(x)a.threadId=x;var d="/profound-ai/chat";if(g()){a.agentData=p();a.agentFile=Ext.c("centerPanel").e().title.replace(/\*/g,"").trim();w=pui.streamingModelList.includes(a.agentData.aiAgent.model);d="/ide/profound-ai/chat"}else a.agent=b.agent;var c=b.data;if(typeof c==="function")c=c();if(b.data)a.data=c;i.value="";E();i.focus();b.showLoader();c={"Content-Type":"application/json"};if(w){c.Connection="keep-alive";c["Response-Type"]="stream"}if(pui.appJob.authToken)c.Authorization="Bearer "+
24
+ pui.appJob.authToken;else if(L){var e=L;if(typeof e==="function")e=e();c.Authorization="Bearer "+e}fetch(F+d,{method:"POST",headers:c,body:JSON.stringify(a)}).then(function(f){return w?f.body.getReader():f.json()}).then(function(f){w?n(f):C(f)})["catch"](function(f){b.hideLoader();b.add({message:"Error: "+f.message,type:"error"})})}};this.poll=function(){if(!(!x||!I||!K)){var a={};a.threadId=x;a.runId=I;a.modelKey=K;var d="/profound-ai/poll";if(g())d="/ide/profound-ai/poll";fetch(F+d,{method:"POST",
25
+ headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}).then(function(c){return c.json()}).then(function(c){C(c)})["catch"](function(c){b.hideLoader();b.add({message:"Error: "+c.message,type:"error"})})}};this.showLoader=function(a){a||(a=P);J.innerText=a;if(!b.isLoading()){w?b.add({message:y,type:"agent-response"}):k.appendChild(A);v()}k.scrollTop=k.scrollHeight};this.hideLoader=function(){if(b.isLoading()){if(w)for(var a=k.querySelectorAll(".pai-inline-loader"),d=a.length-1;d>=0;d--)a[d].parentNode.removeChild(a[d]);
26
+ else k.removeChild(A);v()}};this.isLoading=function(){if(w)return k.querySelectorAll(".pai-inline-loader").length>0;return A.parentNode===k};this.destroy=function(){if(b.dom){b.dom.parentNode.removeChild(b.dom);b.dom=null}};this.removeEmbedIcon=function(){profound.ai.removeEmbedIcon()}};profound.ai.d=function(g){if(!document.querySelector('link[href="'+g+'"]')){var p=document.createElement("link");p.rel="stylesheet";p.href=g;document.head.appendChild(p)}};
27
27
  profound.ai.b=function(g,p){if(document.querySelector('script[src="'+g+'"]'))typeof p==="function"&&p();else{var m=document.createElement("script");m.type="text/javascript";m.src=g;m.onload=function(){typeof p==="function"&&p()};document.head.appendChild(m)}};
28
28
  profound.ai.startAgent=function(g,p){g||(g={});var m="";if(g.server)m=g.server;if(!p&&g.agent)fetch(m+"/profound-ai/attributes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:g.agent})}).then(function(n){return n.json()}).then(function(n){if(n.status==="error")throw Error(n.message);n=n.attributes;for(var C in n)if(g[C]===undefined)g[C]=n[C];profound.ai.startAgent(g,true)})["catch"](function(n){throw Error("Unable to start AI Agent: "+n.message);});else{if(!g.container)g.container=
29
29
  document.body;g.stream&&profound.ai.b(m+"/marked/marked.min.js");profound.ai.d(m+"/profoundui/proddata/css/markdown.css");profound.ai.d(m+"/profoundui/proddata/css/profoundai.css");profound.ai.agent&&profound.ai.agent.destroy();if(g.embed){if(!profound.ai.embedIcon){profound.ai.embedIcon=document.createElement("div");profound.ai.embedIcon.classList.add("pai-embed-icon");profound.ai.embedIcon.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M21 6h-2v9H6v2c0 .55.45 1 1 1h11l4 4V7c0-.55-.45-1-1-1zm-4 6V3c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v14l4-4h10c.55 0 1-.45 1-1z"/></svg>';