django-agent-studio 0.1.0__py3-none-any.whl
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.
- django_agent_studio/__init__.py +12 -0
- django_agent_studio/api/__init__.py +4 -0
- django_agent_studio/api/permissions.py +160 -0
- django_agent_studio/api/serializers.py +606 -0
- django_agent_studio/api/urls.py +245 -0
- django_agent_studio/api/views.py +1548 -0
- django_agent_studio/apps.py +24 -0
- django_agent_studio/management/__init__.py +2 -0
- django_agent_studio/management/commands/__init__.py +2 -0
- django_agent_studio/static/agent-frontend/chat-widget-markdown.js +110 -0
- django_agent_studio/static/agent-frontend/chat-widget.css +1401 -0
- django_agent_studio/static/agent-frontend/chat-widget.js +319 -0
- django_agent_studio/templates/django_agent_studio/agent_list.html +101 -0
- django_agent_studio/templates/django_agent_studio/base.html +137 -0
- django_agent_studio/templates/django_agent_studio/builder.html +1443 -0
- django_agent_studio/templates/django_agent_studio/home.html +97 -0
- django_agent_studio/templates/django_agent_studio/test.html +126 -0
- django_agent_studio/urls.py +25 -0
- django_agent_studio/views.py +100 -0
- django_agent_studio-0.1.0.dist-info/METADATA +416 -0
- django_agent_studio-0.1.0.dist-info/RECORD +23 -0
- django_agent_studio-0.1.0.dist-info/WHEEL +5 -0
- django_agent_studio-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
var ChatWidgetModule=(()=>{var he=Object.defineProperty;var wt=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var bt=Object.prototype.hasOwnProperty;var kt=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},Ct=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of $t(t))!bt.call(e,a)&&a!==n&&he(e,a,{get:()=>t[a],enumerable:!(s=wt(t,a))||s.enumerable});return e};var St=e=>Ct(he({},"__esModule",{value:!0}),e);var Xt={};kt(Xt,{ChatWidget:()=>fe,default:()=>Gt});var re,M,De,Tt,G,xe,He,Ae,Ne,ve,me,ye,Mt,Z={},Oe=[],xt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,le=Array.isArray;function q(e,t){for(var n in t)e[n]=t[n];return e}function we(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function ie(e,t,n){var s,a,o,l={};for(o in t)o=="key"?s=t[o]:o=="ref"?a=t[o]:l[o]=t[o];if(arguments.length>2&&(l.children=arguments.length>3?re.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)l[o]===void 0&&(l[o]=e.defaultProps[o]);return se(e,l,s,a,null)}function se(e,t,n,s,a){var o={type:e,props:t,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:a??++De,__i:-1,__u:0};return a==null&&M.vnode!=null&&M.vnode(o),o}function ce(e){return e.children}function Y(e,t){this.props=e,this.context=t}function X(e,t){if(t==null)return e.__?X(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?X(e):null}function Re(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return Re(e)}}function Ee(e){(!e.__d&&(e.__d=!0)&&G.push(e)&&!ae.__r++||xe!=M.debounceRendering)&&((xe=M.debounceRendering)||He)(ae)}function ae(){for(var e,t,n,s,a,o,l,c=1;G.length;)G.length>c&&G.sort(Ae),e=G.shift(),c=G.length,e.__d&&(n=void 0,s=void 0,a=(s=(t=e).__v).__e,o=[],l=[],t.__P&&((n=q({},s)).__v=s.__v+1,M.vnode&&M.vnode(n),$e(t.__P,n,s,t.__n,t.__P.namespaceURI,32&s.__u?[a]:null,o,a??X(s),!!(32&s.__u),l),n.__v=s.__v,n.__.__k[n.__i]=n,Le(o,n,l),s.__e=s.__=null,n.__e!=a&&Re(n)));ae.__r=0}function Ue(e,t,n,s,a,o,l,c,_,i,u){var r,f,d,m,S,b,g,w=s&&s.__k||Oe,N=t.length;for(_=Et(n,t,w,_,N),r=0;r<N;r++)(d=n.__k[r])!=null&&(f=d.__i==-1?Z:w[d.__i]||Z,d.__i=r,b=$e(e,d,f,a,o,l,c,_,i,u),m=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&be(f.ref,null,d),u.push(d.ref,d.__c||m,d)),S==null&&m!=null&&(S=m),(g=!!(4&d.__u))||f.__k===d.__k?_=Fe(d,_,e,g):typeof d.type=="function"&&b!==void 0?_=b:m&&(_=m.nextSibling),d.__u&=-7);return n.__e=S,_}function Et(e,t,n,s,a){var o,l,c,_,i,u=n.length,r=u,f=0;for(e.__k=new Array(a),o=0;o<a;o++)(l=t[o])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=e.__k[o]=se(null,l,null,null,null):le(l)?l=e.__k[o]=se(ce,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=e.__k[o]=se(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[o]=l,_=o+f,l.__=e,l.__b=e.__b+1,c=null,(i=l.__i=It(l,n,_,r))!=-1&&(r--,(c=n[i])&&(c.__u|=2)),c==null||c.__v==null?(i==-1&&(a>u?f--:a<u&&f++),typeof l.type!="function"&&(l.__u|=4)):i!=_&&(i==_-1?f--:i==_+1?f++:(i>_?f--:f++,l.__u|=4))):e.__k[o]=null;if(r)for(o=0;o<u;o++)(c=n[o])!=null&&!(2&c.__u)&&(c.__e==s&&(s=X(c)),Ke(c,c));return s}function Fe(e,t,n,s){var a,o;if(typeof e.type=="function"){for(a=e.__k,o=0;a&&o<a.length;o++)a[o]&&(a[o].__=e,t=Fe(a[o],t,n,s));return t}e.__e!=t&&(s&&(t&&e.type&&!t.parentNode&&(t=X(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function It(e,t,n,s){var a,o,l,c=e.key,_=e.type,i=t[n],u=i!=null&&(2&i.__u)==0;if(i===null&&c==null||u&&c==i.key&&_==i.type)return n;if(s>(u?1:0)){for(a=n-1,o=n+1;a>=0||o<t.length;)if((i=t[l=a>=0?a--:o++])!=null&&!(2&i.__u)&&c==i.key&&_==i.type)return l}return-1}function Ie(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||xt.test(t)?n:n+"px"}function oe(e,t,n,s,a){var o,l;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof s=="string"&&(e.style.cssText=s=""),s)for(t in s)n&&t in n||Ie(e.style,t,"");if(n)for(t in n)s&&n[t]==s[t]||Ie(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(Ne,"$1")),l=t.toLowerCase(),t=l in e||t=="onFocusOut"||t=="onFocusIn"?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?s?n.u=s.u:(n.u=ve,e.addEventListener(t,o?ye:me,o)):e.removeEventListener(t,o?ye:me,o);else{if(a=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function Pe(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=ve++;else if(t.t<n.u)return;return n(M.event?M.event(t):t)}}}function $e(e,t,n,s,a,o,l,c,_,i){var u,r,f,d,m,S,b,g,w,N,A,j,O,L,W,F,p,$=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(_=!!(32&n.__u),o=[c=t.__e=n.__e]),(u=M.__b)&&u(t);e:if(typeof $=="function")try{if(g=t.props,w="prototype"in $&&$.prototype.render,N=(u=$.contextType)&&s[u.__c],A=u?N?N.props.value:u.__:s,n.__c?b=(r=t.__c=n.__c).__=r.__E:(w?t.__c=r=new $(g,A):(t.__c=r=new Y(g,A),r.constructor=$,r.render=Dt),N&&N.sub(r),r.state||(r.state={}),r.__n=s,f=r.__d=!0,r.__h=[],r._sb=[]),w&&r.__s==null&&(r.__s=r.state),w&&$.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=q({},r.__s)),q(r.__s,$.getDerivedStateFromProps(g,r.__s))),d=r.props,m=r.state,r.__v=t,f)w&&$.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),w&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(w&&$.getDerivedStateFromProps==null&&g!==d&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(g,A),t.__v==n.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(g,r.__s,A)===!1){for(t.__v!=n.__v&&(r.props=g,r.state=r.__s,r.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(E){E&&(E.__=t)}),j=0;j<r._sb.length;j++)r.__h.push(r._sb[j]);r._sb=[],r.__h.length&&l.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(g,r.__s,A),w&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(d,m,S)})}if(r.context=A,r.props=g,r.__P=e,r.__e=!1,O=M.__r,L=0,w){for(r.state=r.__s,r.__d=!1,O&&O(t),u=r.render(r.props,r.state,r.context),W=0;W<r._sb.length;W++)r.__h.push(r._sb[W]);r._sb=[]}else do r.__d=!1,O&&O(t),u=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++L<25);r.state=r.__s,r.getChildContext!=null&&(s=q(q({},s),r.getChildContext())),w&&!f&&r.getSnapshotBeforeUpdate!=null&&(S=r.getSnapshotBeforeUpdate(d,m)),F=u,u!=null&&u.type===ce&&u.key==null&&(F=We(u.props.children)),c=Ue(e,le(F)?F:[F],t,n,s,a,o,l,c,_,i),r.base=t.__e,t.__u&=-161,r.__h.length&&l.push(r),b&&(r.__E=r.__=null)}catch(E){if(t.__v=null,_||o!=null)if(E.then){for(t.__u|=_?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,t.__e=c}else{for(p=o.length;p--;)we(o[p]);ge(t)}else t.__e=n.__e,t.__k=n.__k,E.then||ge(t);M.__e(E,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=Pt(n.__e,t,n,s,a,o,l,_,i);return(u=M.diffed)&&u(t),128&t.__u?void 0:c}function ge(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(ge)}function Le(e,t,n){for(var s=0;s<n.length;s++)be(n[s],n[++s],n[++s]);M.__c&&M.__c(t,e),e.some(function(a){try{e=a.__h,a.__h=[],e.some(function(o){o.call(a)})}catch(o){M.__e(o,a.__v)}})}function We(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:le(e)?e.map(We):q({},e)}function Pt(e,t,n,s,a,o,l,c,_){var i,u,r,f,d,m,S,b=n.props||Z,g=t.props,w=t.type;if(w=="svg"?a="http://www.w3.org/2000/svg":w=="math"?a="http://www.w3.org/1998/Math/MathML":a||(a="http://www.w3.org/1999/xhtml"),o!=null){for(i=0;i<o.length;i++)if((d=o[i])&&"setAttribute"in d==!!w&&(w?d.localName==w:d.nodeType==3)){e=d,o[i]=null;break}}if(e==null){if(w==null)return document.createTextNode(g);e=document.createElementNS(a,w,g.is&&g),c&&(M.__m&&M.__m(t,o),c=!1),o=null}if(w==null)b===g||c&&e.data==g||(e.data=g);else{if(o=o&&re.call(e.childNodes),!c&&o!=null)for(b={},i=0;i<e.attributes.length;i++)b[(d=e.attributes[i]).name]=d.value;for(i in b)if(d=b[i],i!="children"){if(i=="dangerouslySetInnerHTML")r=d;else if(!(i in g)){if(i=="value"&&"defaultValue"in g||i=="checked"&&"defaultChecked"in g)continue;oe(e,i,null,d,a)}}for(i in g)d=g[i],i=="children"?f=d:i=="dangerouslySetInnerHTML"?u=d:i=="value"?m=d:i=="checked"?S=d:c&&typeof d!="function"||b[i]===d||oe(e,i,d,b[i],a);if(u)c||r&&(u.__html==r.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(r&&(e.innerHTML=""),Ue(t.type=="template"?e.content:e,le(f)?f:[f],t,n,s,w=="foreignObject"?"http://www.w3.org/1999/xhtml":a,o,l,o?o[0]:n.__k&&X(n,0),c,_),o!=null)for(i=o.length;i--;)we(o[i]);c||(i="value",w=="progress"&&m==null?e.removeAttribute("value"):m!=null&&(m!==e[i]||w=="progress"&&!m||w=="option"&&m!=b[i])&&oe(e,i,m,b[i],a),i="checked",S!=null&&S!=e[i]&&oe(e,i,S,b[i],a))}return e}function be(e,t,n){try{if(typeof e=="function"){var s=typeof e.__u=="function";s&&e.__u(),s&&t==null||(e.__u=e(t))}else e.current=t}catch(a){M.__e(a,n)}}function Ke(e,t,n){var s,a;if(M.unmount&&M.unmount(e),(s=e.ref)&&(s.current&&s.current!=e.__e||be(s,null,t)),(s=e.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(o){M.__e(o,t)}s.base=s.__P=null}if(s=e.__k)for(a=0;a<s.length;a++)s[a]&&Ke(s[a],t,n||typeof e.type!="function");n||we(e.__e),e.__c=e.__=e.__e=void 0}function Dt(e,t,n){return this.constructor(e,n)}function ue(e,t,n){var s,a,o,l;t==document&&(t=document.documentElement),M.__&&M.__(e,t),a=(s=typeof n=="function")?null:n&&n.__k||t.__k,o=[],l=[],$e(t,e=(!s&&n||t).__k=ie(ce,null,[e]),a||Z,Z,t.namespaceURI,!s&&n?[n]:a?null:t.firstChild?re.call(t.childNodes):null,o,!s&&n?n:a?a.__e:t.firstChild,s,l),Le(o,e,l)}re=Oe.slice,M={__e:function(e,t,n,s){for(var a,o,l;t=t.__;)if((a=t.__c)&&!a.__)try{if((o=a.constructor)&&o.getDerivedStateFromError!=null&&(a.setState(o.getDerivedStateFromError(e)),l=a.__d),a.componentDidCatch!=null&&(a.componentDidCatch(e,s||{}),l=a.__d),l)return a.__E=a}catch(c){e=c}throw e}},De=0,Tt=function(e){return e!=null&&e.constructor===void 0},Y.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=q({},this.state),typeof e=="function"&&(e=e(q({},n),this.props)),e&&q(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Ee(this))},Y.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Ee(this))},Y.prototype.render=ce,G=[],He=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ae=function(e,t){return e.__v.__b-t.__v.__b},ae.__r=0,Ne=/(PointerCapture)$|Capture$/i,ve=0,me=Pe(!1),ye=Pe(!0),Mt=0;var je=function(e,t,n,s){var a;t[0]=0;for(var o=1;o<t.length;o++){var l=t[o++],c=t[o]?(t[0]|=l?1:2,n[t[o++]]):t[++o];l===3?s[0]=c:l===4?s[1]=Object.assign(s[1]||{},c):l===5?(s[1]=s[1]||{})[t[++o]]=c:l===6?s[1][t[++o]]+=c+"":l?(a=e.apply(c,je(e,c,n,["",null])),s.push(a),c[0]?t[0]|=2:(t[o-2]=0,t[o]=a)):s.push(c)}return s},Be=new Map;function Je(e){var t=Be.get(this);return t||(t=new Map,Be.set(this,t)),(t=je(this,t.get(e)||(t.set(e,t=function(n){for(var s,a,o=1,l="",c="",_=[0],i=function(f){o===1&&(f||(l=l.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?_.push(0,f,l):o===3&&(f||l)?(_.push(3,f,l),o=2):o===2&&l==="..."&&f?_.push(4,f,0):o===2&&l&&!f?_.push(5,0,!0,l):o>=5&&((l||!f&&o===5)&&(_.push(o,0,l,a),o=6),f&&(_.push(o,f,0,a),o=6)),l=""},u=0;u<n.length;u++){u&&(o===1&&i(),i(u));for(var r=0;r<n[u].length;r++)s=n[u][r],o===1?s==="<"?(i(),_=[_],o=3):l+=s:o===4?l==="--"&&s===">"?(o=1,l=""):l=s+l[0]:c?s===c?c="":l+=s:s==='"'||s==="'"?c=s:s===">"?(i(),o=1):o&&(s==="="?(o=5,a=l,l=""):s==="/"&&(o<5||n[u][r+1]===">")?(i(),o===3&&(_=_[0]),o=_,(_=_[0]).push(2,0,o),o=0):s===" "||s===" "||s===`
|
|
2
|
+
`||s==="\r"?(i(),o=2):l+=s),o===3&&l==="!--"&&(o=4,_=_[0])}return i(),_}(e)),t),arguments,[])).length>1?t:t[0]}var y=Je.bind(ie);var ee,P,ke,Ve,te=0,et=[],D=M,qe=D.__b,ze=D.__r,Ge=D.diffed,Xe=D.__c,Qe=D.unmount,Ye=D.__;function Se(e,t){D.__h&&D.__h(P,e,te||t),te=0;var n=P.__H||(P.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function C(e){return te=1,Ht(nt,e)}function Ht(e,t,n){var s=Se(ee++,2);if(s.t=e,!s.__c&&(s.__=[n?n(t):nt(void 0,t),function(c){var _=s.__N?s.__N[0]:s.__[0],i=s.t(_,c);_!==i&&(s.__N=[i,s.__[1]],s.__c.setState({}))}],s.__c=P,!P.__f)){var a=function(c,_,i){if(!s.__c.__H)return!0;var u=s.__c.__H.__.filter(function(f){return!!f.__c});if(u.every(function(f){return!f.__N}))return!o||o.call(this,c,_,i);var r=s.__c.props!==c;return u.forEach(function(f){if(f.__N){var d=f.__[0];f.__=f.__N,f.__N=void 0,d!==f.__[0]&&(r=!0)}}),o&&o.call(this,c,_,i)||r};P.__f=!0;var o=P.shouldComponentUpdate,l=P.componentWillUpdate;P.componentWillUpdate=function(c,_,i){if(this.__e){var u=o;o=void 0,a(c,_,i),o=u}l&&l.call(this,c,_,i)},P.shouldComponentUpdate=a}return s.__N||s.__}function R(e,t){var n=Se(ee++,3);!D.__s&&tt(n.__H,t)&&(n.__=e,n.u=t,P.__H.__h.push(n))}function z(e){return te=5,ne(function(){return{current:e}},[])}function ne(e,t){var n=Se(ee++,7);return tt(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function U(e,t){return te=8,ne(function(){return e},t)}function At(){for(var e;e=et.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(_e),e.__H.__h.forEach(Ce),e.__H.__h=[]}catch(t){e.__H.__h=[],D.__e(t,e.__v)}}D.__b=function(e){P=null,qe&&qe(e)},D.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ye&&Ye(e,t)},D.__r=function(e){ze&&ze(e),ee=0;var t=(P=e.__c).__H;t&&(ke===P?(t.__h=[],P.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(_e),t.__h.forEach(Ce),t.__h=[],ee=0)),ke=P},D.diffed=function(e){Ge&&Ge(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(et.push(t)!==1&&Ve===D.requestAnimationFrame||((Ve=D.requestAnimationFrame)||Nt)(At)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ke=P=null},D.__c=function(e,t){t.some(function(n){try{n.__h.forEach(_e),n.__h=n.__h.filter(function(s){return!s.__||Ce(s)})}catch(s){t.some(function(a){a.__h&&(a.__h=[])}),t=[],D.__e(s,n.__v)}}),Xe&&Xe(e,t)},D.unmount=function(e){Qe&&Qe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(s){try{_e(s)}catch(a){t=a}}),n.__H=void 0,t&&D.__e(t,n.__v))};var Ze=typeof requestAnimationFrame=="function";function Nt(e){var t,n=function(){clearTimeout(s),Ze&&cancelAnimationFrame(t),setTimeout(e)},s=setTimeout(n,35);Ze&&(t=requestAnimationFrame(n))}function _e(e){var t=P,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),P=t}function Ce(e){var t=P;e.__c=e.__(),P=t}function tt(e,t){return!e||e.length!==t.length||t.some(function(n,s){return n!==e[s]})}function nt(e,t){return typeof t=="function"?t(e):t}function de(){return"msg-"+Date.now()+"-"+Math.random().toString(36).substr(2,9)}function H(e){let t=document.createElement("div");return t.textContent=e,t.innerHTML}function ot(e){if(!e)return"";try{let t=new Date(e),s=new Date-t,a=Math.floor(s/6e4),o=Math.floor(s/36e5),l=Math.floor(s/864e5);return a<1?"Just now":a<60?`${a}m ago`:o<24?`${o}h ago`:l<7?`${l}d ago`:t.toLocaleDateString()}catch{return""}}function st(e,t=null){if(t)return t(e);let n=H(e);return n=n.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),n=n.replace(/__(.+?)__/g,"<strong>$1</strong>"),n=n.replace(/\*(.+?)\*/g,"<em>$1</em>"),n=n.replace(/_(.+?)_/g,"<em>$1</em>"),n=n.replace(/`(.+?)`/g,"<code>$1</code>"),n=n.replace(/\[(.+?)\]\((.+?)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),n=n.replace(/\n/g,"<br>"),n}function at(e=""){let t=n=>e?`${n}_${e}`:n;return{get(n){try{return localStorage.getItem(t(n))}catch{return null}},set(n,s){try{let a=t(n);s===null?localStorage.removeItem(a):localStorage.setItem(a,s)}catch{}}}}function rt(e="csrftoken"){let t=document.cookie.split(";");for(let s of t){let[a,o]=s.trim().split("=");if(a===e)return decodeURIComponent(o)}let n=document.querySelector('meta[name="csrf-token"]');return n?n.getAttribute("content"):null}function lt({config:e,debugMode:t,isExpanded:n,isSpeaking:s,messagesCount:a,isLoading:o,currentAgent:l,onClose:c,onToggleExpand:_,onToggleDebug:i,onToggleTTS:u,onClear:r,onToggleSidebar:f}){let{title:d,primaryColor:m,embedded:S,showConversationSidebar:b,showClearButton:g,showDebugButton:w,enableDebugMode:N,showTTSButton:A,showExpandButton:j,enableTTS:O,elevenLabsApiKey:L,ttsProxyUrl:W}=e,F=L||W;return y`
|
|
3
|
+
<div class="cw-header" style=${{backgroundColor:m}}>
|
|
4
|
+
${b&&y`
|
|
5
|
+
<button
|
|
6
|
+
class="cw-header-btn cw-hamburger"
|
|
7
|
+
onClick=${f}
|
|
8
|
+
title="Conversations"
|
|
9
|
+
>
|
|
10
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="16" height="16">
|
|
11
|
+
<line x1="3" y1="6" x2="21" y2="6"></line>
|
|
12
|
+
<line x1="3" y1="12" x2="21" y2="12"></line>
|
|
13
|
+
<line x1="3" y1="18" x2="21" y2="18"></line>
|
|
14
|
+
</svg>
|
|
15
|
+
</button>
|
|
16
|
+
`}
|
|
17
|
+
|
|
18
|
+
<div class="cw-title-container">
|
|
19
|
+
<span class="cw-title">${H(d)}</span>
|
|
20
|
+
${l&&y`
|
|
21
|
+
<span class="cw-current-agent" title="Currently active agent">
|
|
22
|
+
<span class="cw-agent-indicator">🤖</span>
|
|
23
|
+
<span class="cw-agent-name">${H(l.name||l.key)}</span>
|
|
24
|
+
</span>
|
|
25
|
+
`}
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<div class="cw-header-actions">
|
|
29
|
+
${g&&y`
|
|
30
|
+
<button
|
|
31
|
+
class="cw-header-btn"
|
|
32
|
+
onClick=${r}
|
|
33
|
+
title="Clear"
|
|
34
|
+
disabled=${o||a===0}
|
|
35
|
+
>🗑️</button>
|
|
36
|
+
`}
|
|
37
|
+
|
|
38
|
+
${w&&N&&y`
|
|
39
|
+
<button
|
|
40
|
+
class="cw-header-btn ${t?"cw-btn-active":""}"
|
|
41
|
+
onClick=${i}
|
|
42
|
+
title="Debug"
|
|
43
|
+
>🐛</button>
|
|
44
|
+
`}
|
|
45
|
+
|
|
46
|
+
${A&&F&&y`
|
|
47
|
+
<button
|
|
48
|
+
class="cw-header-btn ${O?"cw-btn-active":""}"
|
|
49
|
+
onClick=${u}
|
|
50
|
+
title="TTS"
|
|
51
|
+
>${O?"\u{1F50A}":"\u{1F507}"}</button>
|
|
52
|
+
`}
|
|
53
|
+
|
|
54
|
+
${j&&!S&&y`
|
|
55
|
+
<button
|
|
56
|
+
class="cw-header-btn"
|
|
57
|
+
onClick=${_}
|
|
58
|
+
title=${n?"Minimize":"Expand"}
|
|
59
|
+
>${n?"\u2296":"\u2295"}</button>
|
|
60
|
+
`}
|
|
61
|
+
|
|
62
|
+
${!S&&y`
|
|
63
|
+
<button
|
|
64
|
+
class="cw-header-btn"
|
|
65
|
+
onClick=${c}
|
|
66
|
+
title="Close"
|
|
67
|
+
>✕</button>
|
|
68
|
+
`}
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
`}function Te({msg:e,show:t,onToggle:n}){return t?y`
|
|
72
|
+
<div class="cw-debug-payload">
|
|
73
|
+
<button class="cw-debug-payload-close" onClick=${n}>×</button>
|
|
74
|
+
<pre class="cw-debug-payload-content">${JSON.stringify(e,null,2)}</pre>
|
|
75
|
+
</div>
|
|
76
|
+
`:y`
|
|
77
|
+
<button
|
|
78
|
+
class="cw-debug-payload-btn"
|
|
79
|
+
onClick=${n}
|
|
80
|
+
title="Show message payload"
|
|
81
|
+
>{ }</button>
|
|
82
|
+
`}function it({msg:e,debugMode:t,markdownParser:n}){let[s,a]=C(!1),[o,l]=C(!1),c=e.role==="user",_=e.role==="system",i=e.type==="tool_call",u=e.type==="tool_result",r=e.type==="error",f=e.type==="sub_agent_start",d=e.type==="sub_agent_end",m=e.type==="agent_context";if(_&&!t)return null;if(f||d||m)return y`
|
|
83
|
+
<div class="cw-agent-context ${f?"cw-agent-delegating":""} ${d?"cw-agent-returned":""}" style="position: relative;">
|
|
84
|
+
<span class="cw-agent-context-icon">${f?"\u{1F517}":d?"\u2713":"\u{1F916}"}</span>
|
|
85
|
+
<span class="cw-agent-context-text">${e.content}</span>
|
|
86
|
+
${e.metadata?.agentName&&y`
|
|
87
|
+
<span class="cw-agent-context-name">${e.metadata.agentName}</span>
|
|
88
|
+
`}
|
|
89
|
+
${t&&y`<${Te} msg=${e} show=${o} onToggle=${()=>l(!o)} />`}
|
|
90
|
+
</div>
|
|
91
|
+
`;if(i||u){let w=e.metadata?.arguments||e.metadata?.result,N=A=>{if(typeof A=="string")try{return JSON.stringify(JSON.parse(A),null,2)}catch{return A}return JSON.stringify(A,null,2)};return y`
|
|
92
|
+
<div class="cw-tool-message ${u?"cw-tool-result":"cw-tool-call"}" style="position: relative;">
|
|
93
|
+
<span class="cw-tool-label" onClick=${()=>w&&a(!s)}>
|
|
94
|
+
${e.content}
|
|
95
|
+
${w&&y`<span class="cw-tool-expand">${s?"\u25BC":"\u25B6"}</span>`}
|
|
96
|
+
</span>
|
|
97
|
+
${s&&w&&y`
|
|
98
|
+
<pre class="cw-tool-details">${H(N(i?e.metadata.arguments:e.metadata.result))}</pre>
|
|
99
|
+
`}
|
|
100
|
+
${t&&y`<${Te} msg=${e} show=${o} onToggle=${()=>l(!o)} />`}
|
|
101
|
+
</div>
|
|
102
|
+
`}let S=["cw-message",c&&"cw-message-user",r&&"cw-message-error"].filter(Boolean).join(" "),b=`cw-message-row ${c?"cw-message-row-user":""}`,g=e.role==="assistant"?st(e.content,n):H(e.content);return y`
|
|
103
|
+
<div class=${b} style="position: relative;">
|
|
104
|
+
<div class=${S} dangerouslySetInnerHTML=${{__html:g}} />
|
|
105
|
+
${t&&y`<${Te} msg=${e} show=${o} onToggle=${()=>l(!o)} />`}
|
|
106
|
+
</div>
|
|
107
|
+
`}function ct({messages:e,isLoading:t,hasMoreMessages:n,loadingMoreMessages:s,onLoadMore:a,debugMode:o,markdownParser:l,emptyStateTitle:c,emptyStateMessage:_}){let i=z(null),u=z(!0),r=d=>{let m=d.target,S=m.scrollHeight-m.scrollTop-m.clientHeight<100;if(u.current=S,m.scrollTop<50&&n&&!s){let b=m.scrollHeight;a().then(()=>{let g=m.scrollHeight;m.scrollTop=g-b+m.scrollTop})}};R(()=>{let d=i.current;d&&u.current&&requestAnimationFrame(()=>{d.scrollTop=d.scrollHeight})},[e,t]),R(()=>{let d=i.current;d&&e.length<=2&&(u.current=!0,requestAnimationFrame(()=>{d.scrollTop=d.scrollHeight}))},[e.length]);let f=e.length===0;return y`
|
|
108
|
+
<div class="cw-messages" ref=${i} onScroll=${r}>
|
|
109
|
+
${f&&y`
|
|
110
|
+
<div class="cw-empty-state">
|
|
111
|
+
<svg class="cw-empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
112
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
113
|
+
</svg>
|
|
114
|
+
<h3>${H(c)}</h3>
|
|
115
|
+
<p>${H(_)}</p>
|
|
116
|
+
</div>
|
|
117
|
+
`}
|
|
118
|
+
|
|
119
|
+
${!f&&n&&y`
|
|
120
|
+
<div class="cw-load-more" onClick=${a}>
|
|
121
|
+
${s?y`<span class="cw-spinner"></span><span>Loading...</span>`:y`<span>↑ Scroll up or click to load older messages</span>`}
|
|
122
|
+
</div>
|
|
123
|
+
`}
|
|
124
|
+
|
|
125
|
+
${e.map(d=>y`
|
|
126
|
+
<${it}
|
|
127
|
+
key=${d.id}
|
|
128
|
+
msg=${d}
|
|
129
|
+
debugMode=${o}
|
|
130
|
+
markdownParser=${l}
|
|
131
|
+
/>
|
|
132
|
+
`)}
|
|
133
|
+
|
|
134
|
+
${t&&y`
|
|
135
|
+
<div class="cw-message-row">
|
|
136
|
+
<div class="cw-typing">
|
|
137
|
+
<span class="cw-spinner"></span>
|
|
138
|
+
<span>Thinking...</span>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
`}
|
|
142
|
+
</div>
|
|
143
|
+
`}function ut({onSend:e,onCancel:t,isLoading:n,placeholder:s,primaryColor:a}){let[o,l]=C(""),[c,_]=C(!1),i=z(null);R(()=>{!n&&i.current&&i.current.focus()},[n]),R(()=>{i.current&&(i.current.style.height="auto",i.current.style.height=Math.min(i.current.scrollHeight,150)+"px")},[o]);let u=m=>{m.preventDefault(),o.trim()&&!n&&(e(o),l(""),i.current&&(i.current.style.height="auto"))},r=m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),u(m))},f=m=>{n&&t&&(m.preventDefault(),t())},d=y`
|
|
144
|
+
<svg width="14" height="14" viewBox="0 0 14 14" fill="currentColor">
|
|
145
|
+
<rect x="2" y="2" width="10" height="10" rx="1" />
|
|
146
|
+
</svg>
|
|
147
|
+
`;return y`
|
|
148
|
+
<form class="cw-input-form" onSubmit=${u}>
|
|
149
|
+
<textarea
|
|
150
|
+
ref=${i}
|
|
151
|
+
class="cw-input"
|
|
152
|
+
placeholder=${H(s)}
|
|
153
|
+
value=${o}
|
|
154
|
+
onInput=${m=>l(m.target.value)}
|
|
155
|
+
onKeyDown=${r}
|
|
156
|
+
disabled=${n}
|
|
157
|
+
rows="1"
|
|
158
|
+
/>
|
|
159
|
+
<button
|
|
160
|
+
type=${n?"button":"submit"}
|
|
161
|
+
class=${`cw-send-btn ${n?"cw-send-btn-loading":""} ${n&&c?"cw-send-btn-stop":""}`}
|
|
162
|
+
style=${{backgroundColor:n&&c?"#dc2626":a}}
|
|
163
|
+
onClick=${f}
|
|
164
|
+
onMouseEnter=${()=>_(!0)}
|
|
165
|
+
onMouseLeave=${()=>_(!1)}
|
|
166
|
+
title=${n?"Stop":"Send"}
|
|
167
|
+
>
|
|
168
|
+
${n?c?d:y`<span class="cw-spinner"></span>`:"\u27A4"}
|
|
169
|
+
</button>
|
|
170
|
+
</form>
|
|
171
|
+
`}function _t({isOpen:e,conversations:t,conversationsLoading:n,currentConversationId:s,onClose:a,onNewConversation:o,onSwitchConversation:l}){return y`
|
|
172
|
+
<div class="cw-sidebar ${e?"cw-sidebar-open":""}">
|
|
173
|
+
<div class="cw-sidebar-header">
|
|
174
|
+
<span>Conversations</span>
|
|
175
|
+
<button class="cw-sidebar-close" onClick=${a}>✕</button>
|
|
176
|
+
</div>
|
|
177
|
+
|
|
178
|
+
<button class="cw-new-conversation" onClick=${o}>
|
|
179
|
+
<span>+ New Conversation</span>
|
|
180
|
+
</button>
|
|
181
|
+
|
|
182
|
+
<div class="cw-conversation-list">
|
|
183
|
+
${n&&y`
|
|
184
|
+
<div class="cw-sidebar-loading">
|
|
185
|
+
<span class="cw-spinner"></span>
|
|
186
|
+
</div>
|
|
187
|
+
`}
|
|
188
|
+
|
|
189
|
+
${!n&&t.length===0&&y`
|
|
190
|
+
<div class="cw-sidebar-empty">No conversations yet</div>
|
|
191
|
+
`}
|
|
192
|
+
|
|
193
|
+
${t.map(c=>y`
|
|
194
|
+
<div
|
|
195
|
+
key=${c.id}
|
|
196
|
+
class="cw-conversation-item ${c.id===s?"cw-conversation-active":""}"
|
|
197
|
+
onClick=${()=>l(c.id)}
|
|
198
|
+
>
|
|
199
|
+
<div class="cw-conversation-title">${H(c.title||"Untitled")}</div>
|
|
200
|
+
<div class="cw-conversation-date">${ot(c.updatedAt||c.createdAt)}</div>
|
|
201
|
+
</div>
|
|
202
|
+
`)}
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<div
|
|
207
|
+
class="cw-sidebar-overlay ${e?"cw-sidebar-overlay-visible":""}"
|
|
208
|
+
onClick=${a}
|
|
209
|
+
/>
|
|
210
|
+
`}function dt({availableModels:e,selectedModel:t,onSelectModel:n,disabled:s}){let[a,o]=C(!1);if(!e||e.length===0)return null;let c=e.find(u=>u.id===t)?.name||"Select Model",_=()=>{s||o(!a)},i=u=>{n(u),o(!1)};return y`
|
|
211
|
+
<div class="cw-model-selector">
|
|
212
|
+
<button
|
|
213
|
+
class="cw-model-btn"
|
|
214
|
+
onClick=${_}
|
|
215
|
+
disabled=${s}
|
|
216
|
+
title="Select Model"
|
|
217
|
+
>
|
|
218
|
+
<span class="cw-model-icon">🤖</span>
|
|
219
|
+
<span class="cw-model-name">${H(c)}</span>
|
|
220
|
+
<span class="cw-model-chevron">${a?"\u25B2":"\u25BC"}</span>
|
|
221
|
+
</button>
|
|
222
|
+
|
|
223
|
+
${a&&y`
|
|
224
|
+
<div class="cw-model-dropdown">
|
|
225
|
+
${e.map(u=>y`
|
|
226
|
+
<button
|
|
227
|
+
key=${u.id}
|
|
228
|
+
class="cw-model-option ${u.id===t?"cw-model-option-selected":""}"
|
|
229
|
+
onClick=${()=>i(u.id)}
|
|
230
|
+
>
|
|
231
|
+
<span class="cw-model-option-name">${H(u.name)}</span>
|
|
232
|
+
<span class="cw-model-option-provider">${H(u.provider)}</span>
|
|
233
|
+
${u.description&&y`
|
|
234
|
+
<span class="cw-model-option-desc">${H(u.description)}</span>
|
|
235
|
+
`}
|
|
236
|
+
</button>
|
|
237
|
+
`)}
|
|
238
|
+
</div>
|
|
239
|
+
`}
|
|
240
|
+
</div>
|
|
241
|
+
`}function pt(e,t,n){let[s,a]=C([]),[o,l]=C(!1),[c,_]=C(null),[i,u]=C(()=>n?.get(e.conversationIdKey)||null),[r,f]=C(!1),[d,m]=C(!1),[S,b]=C(0),g=z(null),w=z(null);R(()=>{i&&n?.set(e.conversationIdKey,i)},[i,e.conversationIdKey,n]);let N=U(async(p,$,E)=>{g.current&&g.current.close();let I=e.apiPaths.runEvents.replace("{runId}",p),K=`${e.backendUrl}${I}`;$&&(K+=`?anonymous_token=${encodeURIComponent($)}`);let k=new EventSource(K);g.current=k;let B="";k.addEventListener("assistant.message",v=>{try{let h=JSON.parse(v.data);e.onEvent&&e.onEvent("assistant.message",h.payload);let x=h.payload.content;x&&(B+=x,a(V=>{let Q=V[V.length-1];return Q?.role==="assistant"&&Q.id.startsWith("assistant-stream-")?[...V.slice(0,-1),{...Q,content:B}]:[...V,{id:"assistant-stream-"+Date.now(),role:"assistant",content:B,timestamp:new Date,type:"message"}]}))}catch(h){console.error("[ChatWidget] Parse error:",h)}}),k.addEventListener("tool.call",v=>{try{let h=JSON.parse(v.data);e.onEvent&&e.onEvent("tool.call",h.payload),a(x=>[...x,{id:"tool-call-"+Date.now(),role:"assistant",content:`\u{1F527} ${h.payload.name}`,timestamp:new Date,type:"tool_call",metadata:{toolName:h.payload.name,arguments:h.payload.arguments,toolCallId:h.payload.id}}])}catch(h){console.error("[ChatWidget] Parse error:",h)}}),k.addEventListener("tool.result",v=>{try{let h=JSON.parse(v.data);e.onEvent&&e.onEvent("tool.result",h.payload);let x=h.payload.result,V=x?.error;a(Q=>[...Q,{id:"tool-result-"+Date.now(),role:"system",content:V?`\u274C ${x.error}`:"\u2713 Done",timestamp:new Date,type:"tool_result",metadata:{toolName:h.payload.name,result:x,toolCallId:h.payload.tool_call_id}}])}catch(h){console.error("[ChatWidget] Parse error:",h)}}),k.addEventListener("custom",v=>{try{let h=JSON.parse(v.data);e.onEvent&&e.onEvent("custom",h.payload),h.payload?.type==="ui_control"&&e.onUIControl&&e.onUIControl(h.payload),h.payload?.type==="agent_context"&&a(x=>[...x,{id:"agent-context-"+Date.now(),role:"system",content:`\u{1F517} ${h.payload.agent_name||"Sub-agent"} is now handling this request`,timestamp:new Date,type:"agent_context",metadata:{agentKey:h.payload.agent_key,agentName:h.payload.agent_name,action:h.payload.action}}])}catch(h){console.error("[ChatWidget] Parse error:",h)}}),k.addEventListener("sub_agent.start",v=>{try{let h=JSON.parse(v.data);e.onEvent&&e.onEvent("sub_agent.start",h.payload),a(x=>[...x,{id:"sub-agent-start-"+Date.now(),role:"system",content:`\u{1F517} Delegating to ${h.payload.agent_name||h.payload.sub_agent_key||"sub-agent"}...`,timestamp:new Date,type:"sub_agent_start",metadata:{subAgentKey:h.payload.sub_agent_key,agentName:h.payload.agent_name,invocationMode:h.payload.invocation_mode}}])}catch(h){console.error("[ChatWidget] Parse error:",h)}}),k.addEventListener("sub_agent.end",v=>{try{let h=JSON.parse(v.data);e.onEvent&&e.onEvent("sub_agent.end",h.payload),a(x=>[...x,{id:"sub-agent-end-"+Date.now(),role:"system",content:`\u2713 ${h.payload.agent_name||"Sub-agent"} completed`,timestamp:new Date,type:"sub_agent_end",metadata:{subAgentKey:h.payload.sub_agent_key,agentName:h.payload.agent_name}}])}catch(h){console.error("[ChatWidget] Parse error:",h)}});let J=v=>{try{let h=JSON.parse(v.data);if(e.onEvent&&e.onEvent(h.type,h.payload),h.type==="run.failed"){let x=h.payload.error||"Agent run failed";_(x),a(V=>[...V,{id:"error-"+Date.now(),role:"system",content:`\u274C Error: ${x}`,timestamp:new Date,type:"error"}])}}catch(h){console.error("[ChatWidget] Parse error:",h)}l(!1),k.close(),g.current=null,B&&E&&E(B)};k.addEventListener("run.succeeded",J),k.addEventListener("run.failed",J),k.addEventListener("run.cancelled",J),k.addEventListener("run.timed_out",J),k.onerror=()=>{l(!1),k.close(),g.current=null}},[e]),A=U(async(p,$={})=>{if(!p.trim()||o)return;let{model:E,onAssistantMessage:I}=typeof $=="function"?{onAssistantMessage:$}:$;l(!0),_(null);let K={id:de(),role:"user",content:p.trim(),timestamp:new Date,type:"message"};a(k=>[...k,K]);try{let k=await t.getOrCreateSession(),B={agentKey:e.agentKey,conversationId:i,messages:[{role:"user",content:p.trim()}],metadata:{...e.metadata,journeyType:e.defaultJourneyType}};E&&(B.model=E);let J=await fetch(`${e.backendUrl}${e.apiPaths.runs}`,t.getFetchOptions({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)}));if(!J.ok){let x=await J.json().catch(()=>({}));throw new Error(x.error||`HTTP ${J.status}`)}let v=await J.json();w.current=v.id;let h=v.conversationId||v.conversation_id;!i&&h&&u(h),await N(v.id,k,I)}catch(k){_(k.message||"Failed to send message"),l(!1)}finally{w.current=null}},[e,t,i,o,N]),j=U(async()=>{let p=w.current;if(!(!p||!o))try{let $=e.apiPaths.cancelRun?e.apiPaths.cancelRun.replace("{runId}",p):`${e.apiPaths.runs}${p}/cancel/`;(await fetch(`${e.backendUrl}${$}`,t.getFetchOptions({method:"POST",headers:{"Content-Type":"application/json"}}))).ok&&(g.current&&(g.current.close(),g.current=null),l(!1),w.current=null,a(I=>[...I,{id:"cancelled-"+Date.now(),role:"system",content:"\u23F9 Run cancelled",timestamp:new Date,type:"cancelled"}]))}catch($){console.error("[ChatWidget] Failed to cancel run:",$)}},[e,t,o]),O=U(()=>{a([]),u(null),_(null),f(!1),b(0),n?.set(e.conversationIdKey,null)},[e.conversationIdKey,n]),L=p=>{let $={id:de(),role:p.role,timestamp:p.timestamp?new Date(p.timestamp):new Date};if(p.role==="tool")return{...$,role:"system",content:"\u2713 Done",type:"tool_result",metadata:{result:p.content,toolCallId:p.tool_call_id}};if(p.role==="assistant"&&p.tool_calls&&p.tool_calls.length>0)return p.tool_calls.map(I=>({id:de(),role:"assistant",content:`\u{1F527} ${I.function?.name||I.name||"tool"}`,timestamp:$.timestamp,type:"tool_call",metadata:{toolName:I.function?.name||I.name,arguments:I.function?.arguments||I.arguments,toolCallId:I.id}}));let E=typeof p.content=="string"?p.content:JSON.stringify(p.content);return p.role==="assistant"&&!E?.trim()?null:{...$,content:E,type:"message"}},W=U(async p=>{l(!0),a([]),u(p);try{let $=await t.getOrCreateSession(),I=`${e.backendUrl}${e.apiPaths.conversations}${p}/?limit=10&offset=0`,K=await fetch(I,t.getFetchOptions({method:"GET"}));if(K.ok){let k=await K.json();k.messages&&a(k.messages.flatMap(L).filter(Boolean)),f(k.has_more||k.hasMore||!1),b(k.messages?.length||0)}else K.status===404&&(u(null),n?.set(e.conversationIdKey,null))}catch($){console.error("[ChatWidget] Failed to load conversation:",$)}finally{l(!1)}},[e,t,n]),F=U(async()=>{if(!(!i||d||!r)){m(!0);try{let $=`${e.backendUrl}${e.apiPaths.conversations}${i}/?limit=10&offset=${S}`,E=await fetch($,t.getFetchOptions({method:"GET"}));if(E.ok){let I=await E.json();if(I.messages?.length>0){let K=I.messages.flatMap(L).filter(Boolean);a(k=>[...K,...k]),b(k=>k+I.messages.length),f(I.has_more||I.hasMore||!1)}else f(!1)}}catch(p){console.error("[ChatWidget] Failed to load more messages:",p)}finally{m(!1)}}},[e,t,i,S,d,r]);return R(()=>()=>{g.current&&g.current.close()},[]),{messages:s,isLoading:o,error:c,conversationId:i,hasMoreMessages:r,loadingMoreMessages:d,sendMessage:A,cancelRun:j,clearMessages:O,loadConversation:W,loadMoreMessages:F,setConversationId:u}}function ft(e,t,n){let[s,a]=C([]),[o,l]=C(null),[c,_]=C(null),[i,u]=C(!1);R(()=>{(async()=>{if(e.showModelSelector){u(!0);try{let m=await fetch(`${e.backendUrl}${e.apiPaths.models}`,t.getFetchOptions({method:"GET"}));if(m.ok){let S=await m.json(),b=S.models||[];a(b),_(S.default);let g=n?.get(e.modelKey);g&&b.some(w=>w.id===g)?l(g):l(S.default)}}catch(m){console.warn("[ChatWidget] Failed to load models:",m)}finally{u(!1)}}})()},[e.backendUrl,e.apiPaths.models,e.showModelSelector,e.modelKey,t,n]);let r=U(d=>{l(d),n?.set(e.modelKey,d)},[e.modelKey,n]),f=U(()=>s.find(d=>d.id===o)||null,[s,o]);return{availableModels:s,selectedModel:o,defaultModel:c,isLoading:i,selectModel:r,getSelectedModelInfo:f}}function ht(e,t,n){let s=()=>e.authStrategy?e.authStrategy:e.authToken?"token":e.apiPaths.anonymousSession||e.anonymousSessionEndpoint?"anonymous":"none",a=()=>{let c=s(),_={},i=e.authToken||t().authToken;if(c==="token"&&i){let u=e.authHeader||"Authorization",r=e.authTokenPrefix!==void 0?e.authTokenPrefix:"Token";_[u]=r?`${r} ${i}`:i}else if(c==="jwt"&&i){let u=e.authHeader||"Authorization",r=e.authTokenPrefix!==void 0?e.authTokenPrefix:"Bearer";_[u]=r?`${r} ${i}`:i}else if(c==="anonymous"&&i){let u=e.authHeader||e.anonymousTokenHeader||"X-Anonymous-Token";_[u]=i}if(c==="session"){let u=rt(e.csrfCookieName);u&&(_["X-CSRFToken"]=u)}return _};return{getAuthStrategy:s,getAuthHeaders:a,getFetchOptions:(c={})=>{let _=s(),i={...c};return i.headers={...i.headers,...a()},_==="session"&&(i.credentials="include"),i},getOrCreateSession:async()=>{let c=s(),_=t();if(c!=="anonymous")return e.authToken||_.authToken;if(_.authToken)return _.authToken;let i=e.anonymousTokenKey||e.sessionTokenKey,u=_.storage?.get(i);if(u)return n(r=>({...r,authToken:u})),u;try{let r=e.anonymousSessionEndpoint||e.apiPaths.anonymousSession,f=await fetch(`${e.backendUrl}${r}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(f.ok){let d=await f.json();return n(m=>({...m,authToken:d.token})),_.storage?.set(i,d.token),d.token}}catch(r){console.warn("[ChatWidget] Failed to create session:",r)}return null}}}function mt({config:e,onStateChange:t,markdownParser:n,apiRef:s}){let[a,o]=C(e.embedded||e.forceOpen===!0),[l,c]=C(!1),[_,i]=C(!1),[u,r]=C(!1),[f,d]=C([]),[m,S]=C(!1),[b,g]=C(e.enableTTS),[w,N]=C(!1),[A,j]=C(null);R(()=>{e.forceOpen!==void 0&&o(e.forceOpen)},[e.forceOpen]);let O=ne(()=>at(e.containerId),[e.containerId]),[L,W]=C(e.authToken||null),F=ne(()=>ht(e,()=>({authToken:L,storage:O}),x=>{let V=x({authToken:L,storage:O});V.authToken!==L&&W(V.authToken)}),[e,L,O]),p=pt(e,F,O),$=ft(e,F,O);R(()=>{for(let v=p.messages.length-1;v>=0;v--){let h=p.messages[v];if(h.type==="sub_agent_start"){j({key:h.metadata?.subAgentKey,name:h.metadata?.agentName});return}if(h.type==="sub_agent_end"){j(null);return}}},[p.messages]),R(()=>{let v=O.get(e.conversationIdKey);v&&p.loadConversation(v)},[]),R(()=>{t&&t({isOpen:a,isExpanded:l,debugMode:_,messages:p.messages,conversationId:p.conversationId,isLoading:p.isLoading,error:p.error})},[a,l,_,p.messages,p.conversationId,p.isLoading,p.error]);let E=U(async()=>{if(e.showConversationSidebar){S(!0);try{let v=`${e.backendUrl}${e.apiPaths.conversations}?agent_key=${encodeURIComponent(e.agentKey)}`,h=await fetch(v,F.getFetchOptions({method:"GET"}));if(h.ok){let x=await h.json();d(x.results||x)}}catch(v){console.error("[ChatWidget] Failed to load conversations:",v),d([])}finally{S(!1)}}},[e,F]),I=U(()=>{let v=!u;r(v),v&&E()},[u,E]),K=U(v=>{v!==p.conversationId&&p.loadConversation(v),r(!1)},[p]),k=U(()=>{p.clearMessages(),r(!1)},[p]),B=U(v=>{p.sendMessage(v,{model:$.selectedModel,onAssistantMessage:h=>{}})},[p,b,$.selectedModel]);if(R(()=>{s&&(s.current={open:()=>o(!0),close:()=>o(!1),send:v=>B(v),clearMessages:()=>p.clearMessages(),toggleTTS:()=>g(v=>!v),stopSpeech:()=>N(!1),setAuth:v=>{v.token!==void 0&&W(v.token)},clearAuth:()=>W(null)})},[p,s,B]),!e.embedded&&!a)return y`
|
|
242
|
+
<button
|
|
243
|
+
class="cw-fab"
|
|
244
|
+
style=${{backgroundColor:e.primaryColor}}
|
|
245
|
+
onClick=${()=>o(!0)}
|
|
246
|
+
>
|
|
247
|
+
<svg class="cw-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
248
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
249
|
+
</svg>
|
|
250
|
+
</button>
|
|
251
|
+
`;let J=["cw-widget",l&&"cw-widget-expanded",e.embedded&&"cw-widget-embedded"].filter(Boolean).join(" ");return y`
|
|
252
|
+
<div class=${J} style=${{"--cw-primary":e.primaryColor}}>
|
|
253
|
+
${e.showConversationSidebar&&y`
|
|
254
|
+
<${_t}
|
|
255
|
+
isOpen=${u}
|
|
256
|
+
conversations=${f}
|
|
257
|
+
conversationsLoading=${m}
|
|
258
|
+
currentConversationId=${p.conversationId}
|
|
259
|
+
onClose=${()=>r(!1)}
|
|
260
|
+
onNewConversation=${k}
|
|
261
|
+
onSwitchConversation=${K}
|
|
262
|
+
/>
|
|
263
|
+
`}
|
|
264
|
+
|
|
265
|
+
<${lt}
|
|
266
|
+
config=${e}
|
|
267
|
+
debugMode=${_}
|
|
268
|
+
isExpanded=${l}
|
|
269
|
+
isSpeaking=${w}
|
|
270
|
+
messagesCount=${p.messages.length}
|
|
271
|
+
isLoading=${p.isLoading}
|
|
272
|
+
currentAgent=${A}
|
|
273
|
+
onClose=${()=>o(!1)}
|
|
274
|
+
onToggleExpand=${()=>c(!l)}
|
|
275
|
+
onToggleDebug=${()=>i(!_)}
|
|
276
|
+
onToggleTTS=${()=>g(!b)}
|
|
277
|
+
onClear=${p.clearMessages}
|
|
278
|
+
onToggleSidebar=${I}
|
|
279
|
+
/>
|
|
280
|
+
|
|
281
|
+
${_&&y`<div class="cw-status-bar"><span>🐛 Debug</span></div>`}
|
|
282
|
+
|
|
283
|
+
<${ct}
|
|
284
|
+
messages=${p.messages}
|
|
285
|
+
isLoading=${p.isLoading}
|
|
286
|
+
hasMoreMessages=${p.hasMoreMessages}
|
|
287
|
+
loadingMoreMessages=${p.loadingMoreMessages}
|
|
288
|
+
onLoadMore=${p.loadMoreMessages}
|
|
289
|
+
debugMode=${_}
|
|
290
|
+
markdownParser=${n}
|
|
291
|
+
emptyStateTitle=${e.emptyStateTitle}
|
|
292
|
+
emptyStateMessage=${e.emptyStateMessage}
|
|
293
|
+
/>
|
|
294
|
+
|
|
295
|
+
${p.error&&y`<div class="cw-error-bar">${p.error}</div>`}
|
|
296
|
+
|
|
297
|
+
${e.showModelSelector&&$.availableModels.length>0&&y`
|
|
298
|
+
<${dt}
|
|
299
|
+
availableModels=${$.availableModels}
|
|
300
|
+
selectedModel=${$.selectedModel}
|
|
301
|
+
onSelectModel=${$.selectModel}
|
|
302
|
+
disabled=${p.isLoading}
|
|
303
|
+
/>
|
|
304
|
+
`}
|
|
305
|
+
|
|
306
|
+
<${ut}
|
|
307
|
+
onSend=${B}
|
|
308
|
+
onCancel=${p.cancelRun}
|
|
309
|
+
isLoading=${p.isLoading}
|
|
310
|
+
placeholder=${e.placeholder}
|
|
311
|
+
primaryColor=${e.primaryColor}
|
|
312
|
+
/>
|
|
313
|
+
</div>
|
|
314
|
+
`}var yt={backendUrl:"http://localhost:8000",agentKey:"default-agent",title:"Chat Assistant",subtitle:"How can we help you today?",primaryColor:"#0066cc",position:"bottom-right",defaultJourneyType:"general",enableDebugMode:!0,enableAutoRun:!0,journeyTypes:{},customerPrompts:{},placeholder:"Type your message...",emptyStateTitle:"Start a Conversation",emptyStateMessage:"Send a message to get started.",authStrategy:null,authToken:null,authHeader:null,authTokenPrefix:null,anonymousSessionEndpoint:null,anonymousTokenKey:"chat_widget_anonymous_token",onAuthError:null,anonymousTokenHeader:"X-Anonymous-Token",conversationIdKey:"chat_widget_conversation_id",sessionTokenKey:"chat_widget_session_token",apiPaths:{anonymousSession:"/api/accounts/anonymous-session/",conversations:"/api/agent-runtime/conversations/",runs:"/api/agent-runtime/runs/",runEvents:"/api/agent-runtime/runs/{runId}/events/",simulateCustomer:"/api/agent-runtime/simulate-customer/",ttsVoices:"/api/tts/voices/",ttsSetVoice:"/api/tts/set-voice/",models:"/api/agent-runtime/models/"},showConversationSidebar:!0,showClearButton:!0,showDebugButton:!0,showTTSButton:!0,showVoiceSettings:!0,showExpandButton:!0,showModelSelector:!1,modelKey:"chat_widget_selected_model",autoRunDelay:1e3,autoRunMode:"automatic",enableTTS:!1,ttsProxyUrl:null,elevenLabsApiKey:null,ttsVoices:{assistant:null,user:null},ttsModel:"eleven_turbo_v2_5",ttsSettings:{stability:.5,similarity_boost:.75,style:0,use_speaker_boost:!0},availableVoices:[],onEvent:null,containerId:null,embedded:!1,metadata:{}};function gt(e){let t={...yt.apiPaths,...e.apiPaths||{}};return{...yt,...e,apiPaths:t}}var pe=new Map,Ot=0,T=null,Me=class{constructor(t={}){this.instanceId=`cw-${++Ot}`,this.config=gt(t),this.container=null,this._state={},this._apiRef={current:null},pe.set(this.instanceId,this)}_handleStateChange=t=>{this._state=t};init(){if(this.config.containerId){if(this.container=document.getElementById(this.config.containerId),!this.container)return console.error(`[ChatWidget] Container not found: ${this.config.containerId}`),this;this.container.classList.add("cw-container-embedded")}else this.container=document.createElement("div"),this.container.id=this.instanceId,this.container.className=`cw-container cw-position-${this.config.position}`,document.body.appendChild(this.container);return this._render(),console.log(`[ChatWidget] Instance ${this.instanceId} initialized`),this}_render(t={}){this.container&&ue(y`<${mt}
|
|
315
|
+
config=${{...this.config,...t}}
|
|
316
|
+
onStateChange=${this._handleStateChange}
|
|
317
|
+
markdownParser=${fe._enhancedMarkdownParser}
|
|
318
|
+
apiRef=${this._apiRef}
|
|
319
|
+
/>`,this.container)}destroy(){this.container&&(ue(null,this.container),this.config.containerId?this.container.classList.remove("cw-container-embedded"):this.container.remove(),this.container=null),pe.delete(this.instanceId),console.log(`[ChatWidget] Instance ${this.instanceId} destroyed`)}open(){this._apiRef.current?this._apiRef.current.open():this._render({forceOpen:!0})}close(){this._apiRef.current?this._apiRef.current.close():this._render({forceOpen:!1})}send(t){this._apiRef.current&&this._apiRef.current.send(t)}clearMessages(){this._apiRef.current&&this._apiRef.current.clearMessages()}toggleTTS(){this._apiRef.current&&this._apiRef.current.toggleTTS()}stopSpeech(){this._apiRef.current&&this._apiRef.current.stopSpeech()}setAuth(t){this._apiRef.current&&this._apiRef.current.setAuth(t)}clearAuth(){this._apiRef.current&&this._apiRef.current.clearAuth()}getState(){return{...this._state}}getConfig(){return{...this.config}}};function vt(e={}){return new Me(e).init()}function Rt(e={}){return T&&T.destroy(),T=vt(e),T}function Ut(){T&&(T.destroy(),T=null)}function Ft(){T&&T.open()}function Lt(){T&&T.close()}function Wt(e){T&&T.send(e)}function Kt(){T&&T.clearMessages()}function Bt(){T&&T.toggleTTS()}function jt(){T&&T.stopSpeech()}function Jt(e){T&&T.setAuth(e)}function Vt(){T&&T.clearAuth()}function qt(){return T?T.getState():null}function zt(){return T?T.getConfig():null}var fe={createInstance:vt,getInstance:e=>pe.get(e),getAllInstances:()=>Array.from(pe.values()),init:Rt,destroy:Ut,open:Ft,close:Lt,send:Wt,clearMessages:Kt,toggleTTS:Bt,stopSpeech:jt,setAuth:Jt,clearAuth:Vt,getState:qt,getConfig:zt,_enhancedMarkdownParser:null};var Gt=fe;typeof window<"u"&&(window.ChatWidget=fe);return St(Xt);})();
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{% extends "django_agent_studio/base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block title %}My Agents - Agent Studio{% endblock %}
|
|
4
|
+
|
|
5
|
+
{% block breadcrumbs %}
|
|
6
|
+
<nav class="flex items-center space-x-2 ml-4 text-sm">
|
|
7
|
+
<span class="text-gray-400">/</span>
|
|
8
|
+
<span class="text-gray-600">My Agents</span>
|
|
9
|
+
</nav>
|
|
10
|
+
{% endblock %}
|
|
11
|
+
|
|
12
|
+
{% block content %}
|
|
13
|
+
<div class="h-full p-6 overflow-auto">
|
|
14
|
+
<div class="max-w-6xl mx-auto">
|
|
15
|
+
<!-- Header -->
|
|
16
|
+
<div class="flex items-center justify-between mb-6">
|
|
17
|
+
<h1 class="text-2xl font-bold text-gray-900">My Agents</h1>
|
|
18
|
+
<a href="{% url 'agent_studio:agent_create' %}"
|
|
19
|
+
class="bg-primary-600 hover:bg-primary-700 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors">
|
|
20
|
+
<i class="pi pi-plus"></i>
|
|
21
|
+
<span>New Agent</span>
|
|
22
|
+
</a>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
{% if agents %}
|
|
26
|
+
<!-- Agent Grid -->
|
|
27
|
+
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
28
|
+
{% for agent in agents %}
|
|
29
|
+
<div class="bg-white border border-gray-200 rounded-lg overflow-hidden hover:border-primary-300 hover:shadow-md transition-all">
|
|
30
|
+
<div class="p-4">
|
|
31
|
+
<div class="flex items-center justify-between mb-3">
|
|
32
|
+
<div class="flex items-center space-x-3">
|
|
33
|
+
<span class="text-2xl">{{ agent.icon|default:"🤖" }}</span>
|
|
34
|
+
<div>
|
|
35
|
+
<h3 class="font-semibold text-gray-800">{{ agent.name }}</h3>
|
|
36
|
+
<span class="text-xs text-gray-400">{{ agent.slug }}</span>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<div class="flex items-center space-x-1">
|
|
40
|
+
{% if agent.is_active %}
|
|
41
|
+
<span class="w-2 h-2 bg-green-500 rounded-full" title="Active"></span>
|
|
42
|
+
{% else %}
|
|
43
|
+
<span class="w-2 h-2 bg-gray-300 rounded-full" title="Inactive"></span>
|
|
44
|
+
{% endif %}
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
<p class="text-sm text-gray-500 line-clamp-2 mb-4">{{ agent.description|default:"No description" }}</p>
|
|
48
|
+
<div class="flex items-center justify-between text-xs text-gray-400">
|
|
49
|
+
<span>Updated {{ agent.updated_at|timesince }} ago</span>
|
|
50
|
+
<div class="flex items-center space-x-2">
|
|
51
|
+
{% if agent.is_public %}
|
|
52
|
+
<span class="bg-blue-100 text-blue-700 px-2 py-0.5 rounded">Public</span>
|
|
53
|
+
{% endif %}
|
|
54
|
+
{% if agent.is_template %}
|
|
55
|
+
<span class="bg-purple-100 text-purple-700 px-2 py-0.5 rounded">Template</span>
|
|
56
|
+
{% endif %}
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="border-t border-gray-100 px-4 py-3 bg-gray-50 flex items-center justify-between">
|
|
61
|
+
<a href="{% url 'agent_studio:agent_edit' agent.id %}"
|
|
62
|
+
class="text-primary-600 hover:text-primary-700 text-sm font-medium">
|
|
63
|
+
Edit
|
|
64
|
+
</a>
|
|
65
|
+
<a href="{% url 'agent_studio:agent_test' agent.id %}"
|
|
66
|
+
class="text-gray-600 hover:text-gray-700 text-sm">
|
|
67
|
+
Test →
|
|
68
|
+
</a>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
{% endfor %}
|
|
72
|
+
</div>
|
|
73
|
+
{% else %}
|
|
74
|
+
<!-- Empty State -->
|
|
75
|
+
<div class="text-center py-12">
|
|
76
|
+
<div class="text-6xl mb-4">🤖</div>
|
|
77
|
+
<h3 class="text-xl font-semibold text-gray-800 mb-2">No agents yet</h3>
|
|
78
|
+
<p class="text-gray-500 mb-6">Create your first AI agent to get started</p>
|
|
79
|
+
<a href="{% url 'agent_studio:agent_create' %}"
|
|
80
|
+
class="bg-primary-600 hover:bg-primary-700 text-white px-6 py-3 rounded-lg inline-flex items-center space-x-2 transition-colors">
|
|
81
|
+
<i class="pi pi-plus"></i>
|
|
82
|
+
<span>Create Your First Agent</span>
|
|
83
|
+
</a>
|
|
84
|
+
</div>
|
|
85
|
+
{% endif %}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
{% endblock %}
|
|
89
|
+
|
|
90
|
+
{% block extra_js %}
|
|
91
|
+
<script>
|
|
92
|
+
const { createApp } = Vue;
|
|
93
|
+
|
|
94
|
+
createApp({
|
|
95
|
+
data() {
|
|
96
|
+
return {}
|
|
97
|
+
}
|
|
98
|
+
}).use(primevue.config.default).mount('#app');
|
|
99
|
+
</script>
|
|
100
|
+
{% endblock %}
|
|
101
|
+
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{% load static %}
|
|
2
|
+
<!DOCTYPE html>
|
|
3
|
+
<html lang="en" class="h-full">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>{% block title %}Agent Studio{% endblock %}</title>
|
|
8
|
+
|
|
9
|
+
<!-- Tailwind CSS -->
|
|
10
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
11
|
+
<script>
|
|
12
|
+
tailwind.config = {
|
|
13
|
+
darkMode: 'class',
|
|
14
|
+
theme: {
|
|
15
|
+
extend: {
|
|
16
|
+
colors: {
|
|
17
|
+
primary: {"50":"#eff6ff","100":"#dbeafe","200":"#bfdbfe","300":"#93c5fd","400":"#60a5fa","500":"#3b82f6","600":"#2563eb","700":"#1d4ed8","800":"#1e40af","900":"#1e3a8a","950":"#172554"}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<!-- PrimeVue -->
|
|
25
|
+
<link rel="stylesheet" href="https://unpkg.com/primevue@3/resources/themes/lara-light-blue/theme.css">
|
|
26
|
+
<link rel="stylesheet" href="https://unpkg.com/primevue@3/resources/primevue.min.css">
|
|
27
|
+
<link rel="stylesheet" href="https://unpkg.com/primeicons/primeicons.css">
|
|
28
|
+
|
|
29
|
+
<!-- Vue 3 -->
|
|
30
|
+
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
|
|
31
|
+
<script src="https://unpkg.com/primevue@3/core/core.min.js"></script>
|
|
32
|
+
<script src="https://unpkg.com/primevue@3/button/button.min.js"></script>
|
|
33
|
+
<script src="https://unpkg.com/primevue@3/inputtext/inputtext.min.js"></script>
|
|
34
|
+
<script src="https://unpkg.com/primevue@3/textarea/textarea.min.js"></script>
|
|
35
|
+
<script src="https://unpkg.com/primevue@3/dropdown/dropdown.min.js"></script>
|
|
36
|
+
<script src="https://unpkg.com/primevue@3/card/card.min.js"></script>
|
|
37
|
+
<script src="https://unpkg.com/primevue@3/panel/panel.min.js"></script>
|
|
38
|
+
<script src="https://unpkg.com/primevue@3/splitter/splitter.min.js"></script>
|
|
39
|
+
<script src="https://unpkg.com/primevue@3/splitterpanel/splitterpanel.min.js"></script>
|
|
40
|
+
<script src="https://unpkg.com/primevue@3/toast/toast.min.js"></script>
|
|
41
|
+
<script src="https://unpkg.com/primevue@3/toastservice/toastservice.min.js"></script>
|
|
42
|
+
<script src="https://unpkg.com/primevue@3/tabview/tabview.min.js"></script>
|
|
43
|
+
<script src="https://unpkg.com/primevue@3/tabpanel/tabpanel.min.js"></script>
|
|
44
|
+
|
|
45
|
+
<!-- Agent Frontend (for chat widgets)
|
|
46
|
+
Local development: Files are in django_agent_studio/static/agent-frontend/
|
|
47
|
+
To update after changes to agent-frontend/dist/:
|
|
48
|
+
cp agent-frontend/dist/chat-widget.* django_agent_studio/static/agent-frontend/
|
|
49
|
+
For production, switch to unpkg CDN:
|
|
50
|
+
https://unpkg.com/@makemore/agent-frontend/dist/chat-widget.css
|
|
51
|
+
https://unpkg.com/@makemore/agent-frontend/dist/chat-widget.js
|
|
52
|
+
-->
|
|
53
|
+
<link rel="stylesheet" href="{% static 'agent-frontend/chat-widget.css' %}">
|
|
54
|
+
<script src="{% static 'agent-frontend/chat-widget.js' %}"></script>
|
|
55
|
+
|
|
56
|
+
<!-- Enhanced Markdown Support for Chat Widget -->
|
|
57
|
+
<!-- Syntax highlighting theme -->
|
|
58
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/styles/github-dark.min.css">
|
|
59
|
+
<!-- Marked.js for markdown parsing -->
|
|
60
|
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
61
|
+
<!-- Highlight.js - use the pre-bundled version with common languages included -->
|
|
62
|
+
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/highlight.min.js"></script>
|
|
63
|
+
<!-- Chat widget markdown addon (must be after chat-widget.js and marked.js) -->
|
|
64
|
+
<script src="{% static 'agent-frontend/chat-widget-markdown.js' %}"></script>
|
|
65
|
+
|
|
66
|
+
<style>
|
|
67
|
+
[v-cloak] { display: none; }
|
|
68
|
+
|
|
69
|
+
/* Custom scrollbar */
|
|
70
|
+
.custom-scrollbar::-webkit-scrollbar {
|
|
71
|
+
width: 6px;
|
|
72
|
+
}
|
|
73
|
+
.custom-scrollbar::-webkit-scrollbar-track {
|
|
74
|
+
background: #f1f1f1;
|
|
75
|
+
border-radius: 3px;
|
|
76
|
+
}
|
|
77
|
+
.custom-scrollbar::-webkit-scrollbar-thumb {
|
|
78
|
+
background: #c1c1c1;
|
|
79
|
+
border-radius: 3px;
|
|
80
|
+
}
|
|
81
|
+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
82
|
+
background: #a1a1a1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Override agent-frontend styles for embedded mode */
|
|
86
|
+
.embedded-chat .cw-container {
|
|
87
|
+
position: relative !important;
|
|
88
|
+
width: 100% !important;
|
|
89
|
+
height: 100% !important;
|
|
90
|
+
max-height: none !important;
|
|
91
|
+
border-radius: 0 !important;
|
|
92
|
+
box-shadow: none !important;
|
|
93
|
+
}
|
|
94
|
+
.embedded-chat .cw-toggle-btn {
|
|
95
|
+
display: none !important;
|
|
96
|
+
}
|
|
97
|
+
.embedded-chat .cw-widget {
|
|
98
|
+
position: relative !important;
|
|
99
|
+
width: 100% !important;
|
|
100
|
+
height: 100% !important;
|
|
101
|
+
max-height: none !important;
|
|
102
|
+
border-radius: 0.5rem !important;
|
|
103
|
+
}
|
|
104
|
+
</style>
|
|
105
|
+
|
|
106
|
+
{% block extra_head %}{% endblock %}
|
|
107
|
+
</head>
|
|
108
|
+
<body class="h-full bg-gray-50">
|
|
109
|
+
<div id="app" v-cloak class="h-full flex flex-col">
|
|
110
|
+
<!-- Header -->
|
|
111
|
+
<header class="bg-white border-b border-gray-200 px-4 py-3 flex items-center justify-between">
|
|
112
|
+
<div class="flex items-center space-x-4">
|
|
113
|
+
<a href="{% url 'agent_studio:home' %}" class="flex items-center space-x-2">
|
|
114
|
+
<span class="text-2xl">🤖</span>
|
|
115
|
+
<span class="text-xl font-semibold text-gray-800">Agent Studio</span>
|
|
116
|
+
</a>
|
|
117
|
+
{% block breadcrumbs %}{% endblock %}
|
|
118
|
+
</div>
|
|
119
|
+
<div class="flex items-center space-x-4">
|
|
120
|
+
<span class="text-sm text-gray-600">{{ request.user.email }}</span>
|
|
121
|
+
<a href="{% url 'account_logout' %}" class="text-sm text-gray-500 hover:text-gray-700">Logout</a>
|
|
122
|
+
</div>
|
|
123
|
+
</header>
|
|
124
|
+
|
|
125
|
+
<!-- Main Content -->
|
|
126
|
+
<main class="flex-1 overflow-hidden">
|
|
127
|
+
{% block content %}{% endblock %}
|
|
128
|
+
</main>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<!-- Toast container -->
|
|
132
|
+
<p-toast></p-toast>
|
|
133
|
+
|
|
134
|
+
{% block extra_js %}{% endblock %}
|
|
135
|
+
</body>
|
|
136
|
+
</html>
|
|
137
|
+
|