solace-agent-mesh 1.4.0__py3-none-any.whl → 1.4.1__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.

Potentially problematic release.


This version of solace-agent-mesh might be problematic. Click here for more details.

Files changed (67) hide show
  1. solace_agent_mesh/assets/docs/404.html +3 -3
  2. solace_agent_mesh/assets/docs/assets/js/ae4415af.16cc58d3.js +1 -0
  3. solace_agent_mesh/assets/docs/assets/js/{main.1de3da6a.js → main.9bc1a102.js} +2 -2
  4. solace_agent_mesh/assets/docs/assets/js/{runtime~main.3188e049.js → runtime~main.f2b4ea70.js} +1 -1
  5. solace_agent_mesh/assets/docs/docs/documentation/Enterprise/installation/index.html +3 -3
  6. solace_agent_mesh/assets/docs/docs/documentation/Enterprise/single-sign-on/index.html +3 -3
  7. solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-gateway-upgrade-to-0.3.0/index.html +3 -3
  8. solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-technical-migration-map/index.html +3 -3
  9. solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +3 -3
  10. solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +3 -3
  11. solace_agent_mesh/assets/docs/docs/documentation/concepts/cli/index.html +20 -5
  12. solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +3 -3
  13. solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +3 -3
  14. solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +3 -3
  15. solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +3 -3
  16. solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +3 -3
  17. solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +3 -3
  18. solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +3 -3
  19. solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/index.html +3 -3
  20. solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +3 -3
  21. solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +3 -3
  22. solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +3 -3
  23. solace_agent_mesh/assets/docs/docs/documentation/tutorials/bedrock-agents/index.html +3 -3
  24. solace_agent_mesh/assets/docs/docs/documentation/tutorials/custom-agent/index.html +3 -3
  25. solace_agent_mesh/assets/docs/docs/documentation/tutorials/event-mesh-gateway/index.html +3 -3
  26. solace_agent_mesh/assets/docs/docs/documentation/tutorials/mcp-integration/index.html +3 -3
  27. solace_agent_mesh/assets/docs/docs/documentation/tutorials/mongodb-integration/index.html +3 -3
  28. solace_agent_mesh/assets/docs/docs/documentation/tutorials/rag-integration/index.html +3 -3
  29. solace_agent_mesh/assets/docs/docs/documentation/tutorials/rest-gateway/index.html +3 -3
  30. solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +3 -3
  31. solace_agent_mesh/assets/docs/docs/documentation/tutorials/sql-database/index.html +3 -3
  32. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/artifact-management/index.html +3 -3
  33. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/audio-tools/index.html +3 -3
  34. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/data-analysis-tools/index.html +3 -3
  35. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/embeds/index.html +3 -3
  36. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/index.html +3 -3
  37. solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-agents/index.html +3 -3
  38. solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-gateways/index.html +3 -3
  39. solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-python-tools/index.html +3 -3
  40. solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +3 -3
  41. solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +3 -3
  42. solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +3 -3
  43. solace_agent_mesh/assets/docs/lunr-index-1758036158289.json +1 -0
  44. solace_agent_mesh/assets/docs/lunr-index.json +1 -1
  45. solace_agent_mesh/assets/docs/search-doc-1758036158289.json +1 -0
  46. solace_agent_mesh/assets/docs/search-doc.json +1 -1
  47. solace_agent_mesh/cli/__init__.py +1 -1
  48. solace_agent_mesh/cli/commands/plugin_cmd/__init__.py +2 -0
  49. solace_agent_mesh/cli/commands/plugin_cmd/add_cmd.py +10 -245
  50. solace_agent_mesh/cli/commands/plugin_cmd/install_cmd.py +283 -0
  51. solace_agent_mesh/client/webui/frontend/static/assets/{main-Dq4AJNvn.js → main-B6BpuH9K.js} +2 -2
  52. solace_agent_mesh/client/webui/frontend/static/index.html +1 -1
  53. solace_agent_mesh/common/services/identity_service.py +2 -1
  54. solace_agent_mesh/common/services/providers/local_file_identity_service.py +1 -1
  55. solace_agent_mesh/common/utils/pydantic_utils.py +4 -0
  56. solace_agent_mesh/gateway/base/app.py +12 -1
  57. solace_agent_mesh/gateway/http_sse/main.py +337 -375
  58. solace_agent_mesh/templates/webui.yaml +1 -1
  59. {solace_agent_mesh-1.4.0.dist-info → solace_agent_mesh-1.4.1.dist-info}/METADATA +7 -1
  60. {solace_agent_mesh-1.4.0.dist-info → solace_agent_mesh-1.4.1.dist-info}/RECORD +64 -63
  61. solace_agent_mesh/assets/docs/assets/js/ae4415af.24cdc514.js +0 -1
  62. solace_agent_mesh/assets/docs/lunr-index-1757991496554.json +0 -1
  63. solace_agent_mesh/assets/docs/search-doc-1757991496554.json +0 -1
  64. /solace_agent_mesh/assets/docs/assets/js/{main.1de3da6a.js.LICENSE.txt → main.9bc1a102.js.LICENSE.txt} +0 -0
  65. {solace_agent_mesh-1.4.0.dist-info → solace_agent_mesh-1.4.1.dist-info}/WHEEL +0 -0
  66. {solace_agent_mesh-1.4.0.dist-info → solace_agent_mesh-1.4.1.dist-info}/entry_points.txt +0 -0
  67. {solace_agent_mesh-1.4.0.dist-info → solace_agent_mesh-1.4.1.dist-info}/licenses/LICENSE +0 -0
@@ -295,7 +295,7 @@ ${i}
295
295
  </div>
296
296
  </div>
297
297
  </body>
298
- </html>`)},[o]),a.jsx("div",{className:"bg-background h-full max-w-[100vw] overflow-hidden p-4",children:a.jsx("iframe",{srcDoc:n,title:"Mermaid Diagram Preview",sandbox:"allow-scripts allow-same-origin allow-downloads",className:"h-full w-full border-none",onError:()=>t("Failed to load Mermaid content."),onLoad:()=>t(null)})})};/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function Tf(e){return typeof e>"u"||e===null}function Gb(e){return typeof e=="object"&&e!==null}function Vb(e){return Array.isArray(e)?e:Tf(e)?[]:[e]}function Yb(e,t){var n,r,o,s;if(t)for(s=Object.keys(t),n=0,r=s.length;n<r;n+=1)o=s[n],e[o]=t[o];return e}function Kb(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function qb(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Xb=Tf,Zb=Gb,Jb=Vb,Qb=Kb,ey=qb,ty=Yb,Ye={isNothing:Xb,isObject:Zb,toArray:Jb,repeat:Qb,isNegativeZero:ey,extend:ty};function Af(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
298
+ </html>`)},[o]),a.jsx("div",{className:"bg-background h-full p-4",children:a.jsx("iframe",{srcDoc:n,title:"Mermaid Diagram Preview",sandbox:"allow-scripts allow-same-origin allow-downloads",className:"h-96 w-full resize border-none",onError:()=>t("Failed to load Mermaid content."),onLoad:()=>t(null)})})};/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function Tf(e){return typeof e>"u"||e===null}function Gb(e){return typeof e=="object"&&e!==null}function Vb(e){return Array.isArray(e)?e:Tf(e)?[]:[e]}function Yb(e,t){var n,r,o,s;if(t)for(s=Object.keys(t),n=0,r=s.length;n<r;n+=1)o=s[n],e[o]=t[o];return e}function Kb(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function qb(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Xb=Tf,Zb=Gb,Jb=Vb,Qb=Kb,ey=qb,ty=Yb,Ye={isNothing:Xb,isObject:Zb,toArray:Jb,repeat:Qb,isNegativeZero:ey,extend:ty};function Af(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
299
299
 
300
300
  `+e.mark.snippet),r+" "+n):r}function Fr(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=Af(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Fr.prototype=Object.create(Error.prototype);Fr.prototype.constructor=Fr;Fr.prototype.toString=function(t){return this.name+": "+Af(this,t)};var lt=Fr;function Rs(e,t,n,r,o){var s="",i="",l=Math.floor(o/2)-1;return r-t>l&&(s=" ... ",t=r-l+s.length),n-r>l&&(i=" ...",n=r+l-i.length),{str:s+e.slice(t,n).replace(/\t/g,"→")+i,pos:r-t+s.length}}function Ps(e,t){return Ye.repeat(" ",t-e.length)+e}function ny(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],o=[],s,i=-1;s=n.exec(e.buffer);)o.push(s.index),r.push(s.index+s[0].length),e.position<=s.index&&i<0&&(i=r.length-2);i<0&&(i=r.length-1);var l="",c,f,d=Math.min(e.line+t.linesAfter,o.length).toString().length,p=t.maxLength-(t.indent+d+3);for(c=1;c<=t.linesBefore&&!(i-c<0);c++)f=Rs(e.buffer,r[i-c],o[i-c],e.position-(r[i]-r[i-c]),p),l=Ye.repeat(" ",t.indent)+Ps((e.line-c+1).toString(),d)+" | "+f.str+`
301
301
  `+l;for(f=Rs(e.buffer,r[i],o[i],e.position,p),l+=Ye.repeat(" ",t.indent)+Ps((e.line+1).toString(),d)+" | "+f.str+`
@@ -326,7 +326,7 @@ ${i}
326
326
  `+e.slice(o,s),o=s+1),i=l;return c+=`
327
327
  `,e.length-o>t&&i>o?c+=e.slice(o,i)+`
328
328
  `+e.slice(i+1):c+=e.slice(o),c.slice(1)}function US(e){for(var t="",n=0,r,o=0;o<e.length;n>=65536?o+=2:o++)n=Mr(e,o),r=rt[n],!r&&Br(n)?(t+=e[o],n>=65536&&(t+=e[o+1])):t+=r||RS(n);return t}function HS(e,t,n){var r="",o=e.tag,s,i,l;for(s=0,i=n.length;s<i;s+=1)l=n[s],e.replacer&&(l=e.replacer.call(n,String(s),l)),(pn(e,t,l,!1,!1)||typeof l>"u"&&pn(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=o,e.dump="["+r+"]"}function _l(e,t,n,r){var o="",s=e.tag,i,l,c;for(i=0,l=n.length;i<l;i+=1)c=n[i],e.replacer&&(c=e.replacer.call(n,String(i),c)),(pn(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&pn(e,t+1,null,!0,!0,!1,!0))&&((!r||o!=="")&&(o+=oi(e,t)),e.dump&&zr===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=s,e.dump=o||"[]"}function WS(e,t,n){var r="",o=e.tag,s=Object.keys(n),i,l,c,f,d;for(i=0,l=s.length;i<l;i+=1)d="",r!==""&&(d+=", "),e.condenseFlow&&(d+='"'),c=s[i],f=n[c],e.replacer&&(f=e.replacer.call(n,c,f)),pn(e,t,c,!1,!1)&&(e.dump.length>1024&&(d+="? "),d+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),pn(e,t,f,!1,!1)&&(d+=e.dump,r+=d));e.tag=o,e.dump="{"+r+"}"}function GS(e,t,n,r){var o="",s=e.tag,i=Object.keys(n),l,c,f,d,p,m;if(e.sortKeys===!0)i.sort();else if(typeof e.sortKeys=="function")i.sort(e.sortKeys);else if(e.sortKeys)throw new lt("sortKeys must be a boolean or a function");for(l=0,c=i.length;l<c;l+=1)m="",(!r||o!=="")&&(m+=oi(e,t)),f=i[l],d=n[f],e.replacer&&(d=e.replacer.call(n,f,d)),pn(e,t+1,f,!0,!0,!0)&&(p=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,p&&(e.dump&&zr===e.dump.charCodeAt(0)?m+="?":m+="? "),m+=e.dump,p&&(m+=oi(e,t)),pn(e,t+1,d,!0,p)&&(e.dump&&zr===e.dump.charCodeAt(0)?m+=":":m+=": ",m+=e.dump,o+=m));e.tag=s,e.dump=o||"{}"}function Il(e,t,n){var r,o,s,i,l,c;for(o=n?e.explicitTypes:e.implicitTypes,s=0,i=o.length;s<i;s+=1)if(l=o[s],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,tp.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(np.call(l.represent,c))r=l.represent[c](t,c);else throw new lt("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function pn(e,t,n,r,o,s,i){e.tag=null,e.dump=n,Il(e,n,!1)||Il(e,n,!0);var l=tp.call(e.dump),c=r,f;r&&(r=e.flowLevel<0||e.flowLevel>t);var d=l==="[object Object]"||l==="[object Array]",p,m;if(d&&(p=e.duplicates.indexOf(n),m=p!==-1),(e.tag!==null&&e.tag!=="?"||m||e.indent!==2&&t>0)&&(o=!1),m&&e.usedDuplicates[p])e.dump="*ref_"+p;else{if(d&&m&&!e.usedDuplicates[p]&&(e.usedDuplicates[p]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(GS(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(WS(e,t,e.dump),m&&(e.dump="&ref_"+p+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!i&&t>0?_l(e,t-1,e.dump,o):_l(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(HS(e,t,e.dump),m&&(e.dump="&ref_"+p+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&$S(e,e.dump,t,s,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new lt("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(f=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?f="!"+f:f.slice(0,18)==="tag:yaml.org,2002:"?f="!!"+f.slice(18):f="!<"+f+">",e.dump=f+" "+e.dump)}return!0}function VS(e,t){var n=[],r=[],o,s;for(ii(e,n,r),o=0,s=r.length;o<s;o+=1)t.duplicates.push(n[r[o]]);t.usedDuplicates=new Array(s)}function ii(e,t,n){var r,o,s;if(e!==null&&typeof e=="object")if(o=t.indexOf(e),o!==-1)n.indexOf(o)===-1&&n.push(o);else if(t.push(e),Array.isArray(e))for(o=0,s=e.length;o<s;o+=1)ii(e[o],t,n);else for(r=Object.keys(e),o=0,s=r.length;o<s;o+=1)ii(e[r[o]],t,n)}function YS(e,t){t=t||{};var n=new LS(t);n.noRefs||VS(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),pn(n,0,r,!0,!0)?n.dump+`
329
- `:""}var KS=YS,qS={dump:KS};function na(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var XS=Je,ZS=Nf,JS=jf,QS=Df,eC=Of,tC=Ji,nC=ep.load,rC=ep.loadAll,oC=qS.dump,sC=lt,iC={binary:Uf,float:Lf,map:If,null:Mf,pairs:Wf,set:Gf,timestamp:$f,bool:Rf,int:Pf,merge:Bf,omap:Hf,seq:_f,str:kf},aC=na("safeLoad","load"),lC=na("safeLoadAll","loadAll"),cC=na("safeDump","dump"),uC={Type:XS,Schema:ZS,FAILSAFE_SCHEMA:JS,JSON_SCHEMA:QS,CORE_SCHEMA:eC,DEFAULT_SCHEMA:tC,load:nC,loadAll:rC,dump:oC,YAMLException:sC,types:iC,safeLoad:aC,safeLoadAll:lC,safeDump:cC};const dC=({content:e,rendererType:t,setRenderError:n})=>{const[r,o]=u.useState(!1);u.useEffect(()=>{n(null)},[e,n]);const[s,i]=u.useMemo(()=>{try{if(t==="yaml"){const l=uC.load(e);return[e,l]}else if(t==="json"){const l=JSON.parse(e);return[JSON.stringify(l,null,2),l]}throw new Error(`Unsupported renderer type: ${t}`)}catch(l){const c=t==="yaml"?"YAML":"JSON";console.error(`Error parsing ${c} for panel:`,l);const f={[`${c}_Parsing_Error`]:`The provided content is not valid ${c}.`,Details:l.message,Content_Snippet:e.substring(0,500)+(e.length>500?"...":"")};return n(`${c} parsing failed: ${l.message}`),[e,f]}},[e,t,n]);return a.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background relative",children:[a.jsx("div",{className:"absolute top-4 right-4 z-10",children:a.jsx(ve,{onClick:()=>o(!r),title:r?"Show Structured View":"Show Raw Text",children:r?a.jsxs(a.Fragment,{children:[a.jsx(Ul,{})," Structured"]}):a.jsxs(a.Fragment,{children:[a.jsx(Hl,{})," Raw Text"]})})}),a.jsx("div",{className:"flex min-h-0 flex-col",children:a.jsx("div",{className:"flex-1 overflow-auto",children:r?a.jsx(fp,{content:s,setRenderError:n}):a.jsx(fi,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},fp=({content:e,className:t=""})=>{const{ref:n,handleKeyDown:r}=vf();return a.jsx("div",{className:`p-4 overflow-auto ${t}`,children:a.jsx("pre",{ref:n,className:"whitespace-pre-wrap focus-visible:outline-none select-text",style:{overflowWrap:"anywhere"},tabIndex:0,onKeyDown:r,children:e})})},pp=({content:e,rendererType:t,mime_type:n,setRenderError:r})=>{switch(t){case"csv":return a.jsx(wb,{content:e,setRenderError:r});case"mermaid":return a.jsx(Wb,{content:e,setRenderError:r});case"html":return a.jsx(bb,{content:e,setRenderError:r});case"json":case"yaml":return a.jsx(dC,{content:e,rendererType:t,setRenderError:r});case"image":return a.jsx(yb,{content:e,mime_type:n,setRenderError:r});case"markdown":return a.jsx(Sb,{content:e,setRenderError:r});case"audio":return a.jsx(xb,{content:e,mime_type:n,setRenderError:r});default:return a.jsx(fp,{content:e,setRenderError:r})}},fC={"application/pdf":"pdf","application/zip":"zip","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/x-markdown":"md","application/json":"json","application/yaml":"yaml","text/yaml":"yaml","application/xml":"xml","text/xml":"xml","image/jpeg":"jpg","image/png":"png","image/gif":"gif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff","audio/mpeg":"mp3","audio/wav":"wav","audio/ogg":"ogg","audio/aac":"aac","audio/flac":"flac","audio/x-m4a":"m4a","video/mp4":"mp4","video/webm":"webm","video/ogg":"ogv","application/javascript":"js","application/gzip":"gz","application/x-tar":"tar","application/rtf":"rtf"};function pC(e,t){const n=fC[e]||"bin";return`embedded_file_${t+1}.${n}`}function mC(e){if(!e||typeof e!="string")return[];const t=[],n=/data:([a-zA-Z0-9/.-]+);base64,([A-Za-z0-9+/=]+)/g;let r,o=0;for(;(r=n.exec(e))!==null;){const[s,i,l]=r,c=e[r.index-1],f=e[r.index+s.length];if(!(c==='"'&&f==='"'||c==="'"&&f==="'")&&l&&l.length>10){const d=qr(void 0,i);d?t.push({type:d,content:l,mimeType:i,originalMatch:s}):t.push({type:"file",content:l,mimeType:i,originalMatch:s,filename:pC(i,o++)})}}return t}function hC(e){if(!e||typeof e!="string")return[];const t=[],n=/<html[\s\S]*?<\/html>/gi;let r;for(;(r=n.exec(e))!==null;)t.push({type:"html",content:r[0].trim(),originalMatch:r[0]});return t}function gC(e){if(!e||typeof e!="string")return[];const t=[],n=/```mermaid\s*\n([\s\S]*?)```/gi;let r;for(;(r=n.exec(e))!==null;){const[o,s]=r;t.push({type:"mermaid",content:s.trim(),originalMatch:o})}return t}function xC(e){return!e||typeof e!="string"?[]:[...mC(e),...hC(e),...gC(e)]}const vC=["image","audio"],wC=({message:e})=>{var f;const[t,n]=u.useState(null);if(e.isStatusBubble)return null;const r=(f=e.parts)==null?void 0:f.filter(d=>d.kind==="text"),o=(r==null?void 0:r.map(d=>d.text).join(""))||"";if(e.isUser)return a.jsx("span",{children:o});const s=o.trim();if(!s)return null;if(e.isError)return a.jsxs("div",{className:"flex items-center",children:[a.jsx(gi,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),a.jsx(or,{children:s})]});const i=xC(s);if(i.length===0)return a.jsx(or,{children:s});let l=s;const c=[];return i.forEach((d,p)=>{if(l=l.replace(d.originalMatch,""),d.type==="file"){const m={name:d.filename||"downloaded_file",content:d.content,mime_type:d.mimeType};c.push(a.jsx("div",{className:"my-2",children:a.jsx(gf,{fileAttachment:m,isEmbedded:!0})},`embedded-file-${p}`))}else if(!vC.includes(d.type)){const m=ff(d.content);m&&c.push(a.jsx("div",{className:"my-2 h-auto w-md max-w-md overflow-hidden",children:a.jsx(pp,{content:m,rendererType:d.type,mime_type:d.mimeType,setRenderError:n})},`embedded-${p}`))}}),a.jsxs("div",{children:[t&&a.jsx(ra,{variant:"error",message:"Error rendering preview"}),a.jsx(or,{children:l}),c]})},mp=({message:e,children:t,className:n})=>a.jsx("div",{className:`mt-1 space-y-1 ${e.isUser?"ml-auto":"mr-auto"} ${n}`,children:t}),bC=e=>e.uploadedFiles&&e.uploadedFiles.length>0?a.jsx(mp,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return a.jsx(xf,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,yC=e=>e.files&&e.files.length>0?a.jsx(mp,{message:e,children:e.files.map((t,n)=>{var r;return a.jsx(gf,{fileAttachment:t},`file-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,SC=(e,t,n)=>{var f,d;const{openSidePanelTab:r,setTaskIdInSidePanel:o}=t;if(e.isStatusBubble)return null;const s=(f=e.parts)==null?void 0:f.some(p=>p.kind==="text"&&p.text.trim());if(!s&&!e.artifactNotification)return null;const i=e.isUser?"sent":"received",l=!e.isUser&&e.isComplete&&!!e.taskId&&n,c=()=>{e.taskId&&(o(e.taskId),r("workflow"))};return a.jsx(af,{variant:i,children:a.jsxs(lf,{variant:i,children:[s&&a.jsx(wC,{message:e}),e.artifactNotification&&a.jsxs("div",{className:"flex items-center p-2 my-1 bg-blue-100 dark:bg-blue-900/50 rounded-md",children:[a.jsx(sr,{className:"mr-2 text-blue-500 dark:text-blue-400"}),a.jsxs("span",{className:"text-sm",children:["Artifact created: ",a.jsx("strong",{children:e.artifactNotification.name}),e.artifactNotification.version&&` (v${e.artifactNotification.version})`]})]}),l&&a.jsx("div",{className:"mt-3",children:a.jsx(qc,{onClick:c})})]})},(d=e.metadata)==null?void 0:d.messageId)},CC=({message:e,isLastWithTaskId:t})=>{const n=Be();return e?a.jsxs(a.Fragment,{children:[SC(e,n,t),bC(e),yC(e)]}):null},EC=()=>{const{handleSwitchSession:e,updateSessionName:t,openSessionDeleteModal:n}=Be(),{configServerUrl:r}=nn(),o=u.useRef(null),[s,i]=u.useState([]),[l,c]=u.useState(null),[f,d]=u.useState(""),p=u.useCallback(async()=>{const w=`${r}/api/v1/sessions`;try{const y=await De(w);if(y.ok){const E=await y.json();i(E.sessions||[])}else console.error(`Failed to fetch sessions: ${y.status} ${y.statusText}`)}catch(y){console.error("An error occurred while fetching sessions:",y)}},[r]);u.useEffect(()=>{p();const w=()=>{p()},y=E=>{const{sessionId:k}=E.detail;i(I=>{const A=I.find(T=>T.id===k);if(A){const T=I.filter(Y=>Y.id!==k);return[A,...T]}return I})};return window.addEventListener("new-chat-session",w),window.addEventListener("session-updated",y),()=>{window.removeEventListener("new-chat-session",w),window.removeEventListener("session-updated",y)}},[p]),u.useEffect(()=>{l&&o.current&&o.current.focus()},[l]);const m=async w=>{l!==w&&await e(w)},g=w=>{c(w.id),d(w.name||"")},x=async()=>{l&&(await t(l,f),c(null),p())},h=w=>{n(w)},v=w=>new Date(w).toLocaleString(),b=w=>{if(w.name&&w.name.trim())return w.name;const y=w.id;return y.startsWith("web-session-")?`Chat ${y.replace("web-session-","").substring(0,8)}`:`Session ${y.substring(0,8)}`};return a.jsxs("div",{className:"p-4 flex flex-col h-full",children:[a.jsx("div",{className:"text-lg",children:"Chat Session History"}),s.length>0&&a.jsx("ul",{children:s.map(w=>a.jsx("li",{className:"my-2 group",children:a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 rounded hover:bg-gray-200 dark:hover:bg-gray-700",children:[l===w.id?a.jsx("input",{ref:o,type:"text",value:f,onChange:y=>d(y.target.value),onKeyDown:y=>y.key==="Enter"&&x(),onBlur:x,className:"flex-grow bg-transparent focus:outline-none"}):a.jsx("button",{onClick:()=>m(w.id),className:"flex-grow text-left",children:a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"font-semibold",children:b(w)}),a.jsx("span",{className:"text-xs text-muted-foreground",children:v(w.updated_at)})]})}),a.jsx("div",{className:"flex items-center opacity-0 group-hover:opacity-100 transition-opacity",children:l===w.id?a.jsxs(a.Fragment,{children:[a.jsx(ve,{variant:"ghost",onClick:x,children:a.jsx(mi,{size:16})}),a.jsx(ve,{variant:"ghost",onClick:()=>c(null),children:a.jsx(Ro,{size:16})})]}):a.jsxs(a.Fragment,{children:[a.jsx(ve,{variant:"ghost",onClick:()=>g(w),children:a.jsx(zp,{size:16})}),a.jsx(ve,{variant:"ghost",onClick:()=>h(w),children:a.jsx($p,{size:16})})]})})]})},w.id))}),s.length===0&&a.jsxs("div",{className:"flex flex-col flex-1 h-full text-sm text-muted-foreground items-center justify-center",children:[a.jsx(Wl,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]})]})},TC=()=>{const{persistenceEnabled:e}=nn(),t=Xu();return e===!1?a.jsx("div",{className:"flex h-full flex-col",children:a.jsxs("div",{className:"flex-1 overflow-y-auto px-4",children:[a.jsxs("div",{className:"bg-accent/50 hover:bg-accent mb-3 cursor-pointer rounded-md p-3",children:[a.jsx("div",{className:"text-foreground truncate text-sm font-medium text-nowrap",children:t}),a.jsx("div",{className:"text-muted-foreground mt-1 text-xs",children:"Current session"})]}),a.jsx("div",{className:"text-muted-foreground mt-4 text-center text-xs",children:"Multi-session support coming soon"})]})}):a.jsx("div",{className:"flex h-full flex-col",children:a.jsx("div",{className:"flex-1 overflow-y-auto px-4",children:a.jsx(EC,{})})})},AC=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:o,setIsExpanded:s})=>{const{previewedArtifactAvailableVersions:i,currentPreviewedVersionNumber:l,navigateArtifactVersion:c}=Be(),f=u.useMemo(()=>i??[],[i]);return a.jsxs("div",{className:"flex flex-row justify-between gap-1",children:[a.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"truncate text-sm",title:e.filename,children:e.filename}),a.jsx("div",{className:"truncate text-xs",title:Ea(e.last_modified),children:Ea(e.last_modified)})]}),t&&f.length>1&&a.jsx("div",{className:"align-right",children:a.jsxs(Fd,{value:l==null?void 0:l.toString(),onValueChange:d=>{c(e.filename,parseInt(d))},children:[a.jsx($d,{className:"h-[16px] py-0 text-xs shadow-none",children:a.jsx(zd,{placeholder:"Version"})}),a.jsx(Bd,{children:f.map(d=>a.jsxs(Ud,{value:d.toString(),children:["Version ",d]},d))})]})})]}),a.jsxs("div",{className:`whitespace-nowrap ${t?"opacity-100":"opacity-0 transition-opacity duration-150 group-focus-within:opacity-100 group-hover:opacity-100"}`,children:[s&&a.jsx(ve,{variant:"ghost",size:"sm",onClick:d=>{d.stopPropagation(),d.preventDefault(),s(!n)},tooltip:n?"Collapse Details":"Expand Details",children:a.jsx(vi,{})}),o&&a.jsx(ve,{variant:"ghost",size:"sm",onClick:async d=>{d.stopPropagation(),d.preventDefault(),await o(e)},tooltip:"Download",children:a.jsx(xi,{})}),r&&a.jsx(ve,{variant:"ghost",size:"sm",onClick:d=>{d.preventDefault(),d.stopPropagation(),r(e)},tooltip:"Delete",children:a.jsx(Gl,{})})]})]})},jl=({artifact:e,isPreview:t})=>{const{openDeleteModal:n,setPreviewArtifact:r}=Be(),{onDownload:o}=qu(),[s,i]=u.useState(!1),l=()=>{t&&r(null),n(e)},c=f=>{if(!f||typeof f=="object"&&Object.keys(f).length===0)return a.jsx("span",{children:"Not available"});const d=(p,m=0)=>typeof p=="string"?a.jsx("span",{children:p}):Array.isArray(p)?a.jsxs(a.Fragment,{children:["[",p.length>0&&d(p[0],m+1),p.length>1&&a.jsx("span",{children:", ..."}),"]"]}):typeof p=="object"&&p!==null?a.jsx("div",{className:`ml-${m*2} border-l pl-2`,children:Object.entries(p).map(([g,x],h)=>a.jsxs("div",{className:"text-xs",children:[a.jsxs("span",{className:"font-semibold",children:[g,":"]})," ",d(x,m+1)]},h))}):String(p);return a.jsxs("div",{className:"mt-1 space-y-0.5",children:[typeof f=="object"&&f.type&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",f.type," ",f.inferred&&a.jsx("span",{className:"text-xs",children:"(inferred)"})]}),typeof f=="object"&&f.columns&&a.jsxs("p",{children:[a.jsx("strong",{children:"Columns:"})," ",f.columns.join(", ")]}),typeof f=="object"&&f.structure&&a.jsxs("div",{children:[a.jsx("strong",{children:"Structure:"}),d(f.structure)]}),typeof f=="object"&&f.error&&a.jsxs("p",{className:"text-[var(--color-error-wMain)]",children:[a.jsx("strong",{children:"Schema Error:"})," ",f.error]}),typeof f=="string"&&a.jsx("p",{children:f})]})};return a.jsx("div",{className:`group relative w-full border-b px-4 py-3 transition-all duration-150 ${t?"":"cursor-pointer hover:bg-[var(--accent-background)]"}`,onClick:f=>{f.stopPropagation(),r(e)},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),f.stopPropagation(),r(e))},tabIndex:0,role:"button","aria-expanded":s,children:a.jsxs("div",{className:"flex items-start space-x-2",children:[a.jsx("div",{className:"flex-shrink-0 pt-0.5",children:hf(e,"h-4 w-4 flex-shrink-0")}),a.jsxs("div",{className:"min-w-0 flex-grow",children:[a.jsx(AC,{artifactInfo:e,isExpanded:s,onDelete:l,onDownload:o,setIsExpanded:i,isPreview:t}),s&&a.jsxs("div",{className:"text-xs",children:[a.jsx("div",{className:"mt-1 text-xs break-words whitespace-pre-wrap italic",children:e.description||"No description."}),a.jsxs("div",{className:"mt-2 space-y-1 pt-2",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Size: "}),pc(e.size)]}),e.uri&&a.jsxs("div",{children:[a.jsx("strong",{children:"URI: "}),a.jsx("span",{className:"break-all",children:e.uri||"None"})]}),e.schema&&a.jsx("div",{children:c(e.schema)})]})]})]})]})})},NC=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=Be();return!e||!t?null:a.jsx(Go,{open:e,onOpenChange:n,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsxs(Ko,{className:"flex flex-row gap-1 max-w-[400px]",children:["Delete",a.jsx("span",{className:"inline-block truncate",title:t.filename,children:a.jsx("code",{children:t.filename})}),"?"]}),a.jsx(qo,{className:"flex flex-col gap-2",children:a.jsx("div",{children:"This file will be permanently deleted. "})})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(ve,{variant:"outline",onClick:n,children:"Cancel"}),a.jsx(ve,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})})},kC={replace:e=>{e instanceof Hp.Element&&e.attribs&&e.name==="a"&&(e.attribs.target="_blank",e.attribs.rel="noopener noreferrer")}};function or({children:e,className:t}){if(!e)return null;try{const n=Bp.parse(e,{gfm:!0}),r=Ef.sanitize(n,{USE_PROFILES:{html:!0}}),o=Up(r,kC);return a.jsx("div",{className:Ta(t),children:o})}catch{return a.jsx("div",{className:Ta(t),children:e})}}const _C=Tn("flex items-center gap-3 px-4 py-3 text-sm font-medium transition-all border-l-4 border-solid ",{variants:{variant:{error:"bg-[var(--color-error-w10)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-error-w10)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-warning-w10)]",info:"bg-[var(--color-info-w10)] text-[var(--color-info-wMain)] border-[var(--color-info-w10)] dark:bg-[var(--color-info-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-info-w10)]",success:"bg-[var(--color-success-w10)] text-[var(--color-success-wMain)] border-[var(--color-success-w10)] dark:bg-[var(--color-success-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-success-w10)]"}},defaultVariants:{variant:"error"}}),IC={error:gi,warning:Wp,info:vi,success:Vl};function ra({className:e,variant:t="error",message:n,dismissible:r=!1,onDismiss:o,...s}){const i=IC[t||"error"];return a.jsxs("div",{className:Se(_C({variant:t,className:e})),role:"alert","aria-live":"polite",...s,children:[a.jsx(i,{className:"size-5 shrink-0"}),a.jsx("span",{className:"flex-1",children:n}),r&&o&&a.jsx(ve,{variant:"ghost",onClick:o,"aria-label":"Dismiss",children:a.jsx(Ro,{className:"size-3"})})]})}const jC=({artifact:e,message:t})=>{const{onDownload:n}=qu();return a.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-4",children:[a.jsx("div",{className:"mb-1 font-semibold",children:"Preview Coming Soon"}),a.jsx("div",{children:t}),a.jsx("div",{className:"mb-4",children:"Download file to view."}),a.jsxs(ve,{onClick:()=>n(e),children:[a.jsx(xi,{className:"h-4 w-4"}),"Download"]})]})},Ds=({children:e})=>a.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),MC=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n}=Be(),r=u.useMemo(()=>gb(e),[e]),[o,s]=u.useState(!1),[i,l]=u.useState(null);if(u.useEffect(()=>{s(!1),l(null)},[e]),u.useEffect(()=>{async function d(){try{s(!0),l(null),await t(e.filename)}catch(p){console.error("Error fetching artifact content:",p),l(p instanceof Error?p.message:"Failed to load artifact content")}finally{s(!1)}}r!=null&&r.canPreview&&d()},[e,t,r]),i)return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(ra,{variant:"error",message:"Error rendering preview"}),a.jsx(Ds,{children:"No preview available"})]});if(o)return a.jsx(Ds,{children:a.jsx(hi,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!r.canPreview)return a.jsx(jC,{artifact:e,message:r.reason??""});const c=qr(e.filename,e.mime_type),f=mb(n);return!c||!f?a.jsx(Ds,{children:"No preview available"}):a.jsx(pp,{content:f,rendererType:c,mime_type:n==null?void 0:n.mime_type,setRenderError:l})},Xt={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},RC=e=>{switch(e){case Xt.NameAsc:return"Name (A-Z)";case Xt.NameDesc:return"Name (Z-A)";case Xt.DateAsc:return"Date (oldest first)";case Xt.DateDesc:return"Date (newest first)"}},PC=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values(Xt).map(o=>({id:o,label:RC(o),onClick:()=>t(o),icon:e===o?a.jsx(mi,{}):void 0,iconPosition:"right"}));return a.jsxs(cd,{children:[a.jsx(ud,{asChild:!0,children:n}),a.jsx(dd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Yi,{actions:r})})]})},LC=({children:e})=>{const{artifactsRefetch:t,setIsBatchDeleteModalOpen:n}=Be(),r=[{id:"refreshAll",label:"Refresh",onClick:()=>{t()},icon:a.jsx(Yl,{}),iconPosition:"left"},{id:"deleteAll",label:"Delete All",onClick:()=>{n(!0)},icon:a.jsx(Gl,{}),iconPosition:"left",divider:!0}];return a.jsxs(cd,{children:[a.jsx(ud,{asChild:!0,children:e}),a.jsx(dd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Yi,{actions:r})})]})},DC=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:o}=Be();return u.useEffect(()=>{t&&o(new Set(e.map(s=>s.filename)))},[e,t,o]),t?a.jsx(Go,{open:t,onOpenChange:n,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsx(Ko,{children:"Delete All?"}),a.jsxs(qo,{children:[e.length===1?"One file":`All ${e.length} files`," will be permanently deleted."]})]}),a.jsxs("div",{className:"flex justify-end space-x-2",children:[a.jsx(ve,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),a.jsx(ve,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})}):null},OC={[Xt.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[Xt.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[Xt.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[Xt.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},FC=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r}=Be(),[o,s]=u.useState(Xt.DateDesc),i=u.useMemo(()=>t?[]:e?[...e].sort(OC[o]):[],[e,t,o]),l=u.useMemo(()=>n?a.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[a.jsx(ve,{variant:"ghost",onClick:()=>r(null),children:a.jsx(Gp,{})}),a.jsx("div",{className:"text-md font-semibold",children:"Preview"})]}):i.length>0&&a.jsxs("div",{className:"flex items-center justify-end border-b p-2",children:[a.jsx(PC,{currentSortOption:o,onSortChange:s,children:a.jsxs(ve,{variant:"ghost",title:"Sort By",children:[a.jsx($l,{className:"h-5 w-5"}),a.jsx("div",{children:"Sort By"})]})},"sort-popover"),a.jsx(LC,{children:a.jsx(ve,{variant:"ghost",tooltip:"More",children:a.jsx(Vp,{className:"h-5 w-5"})})},"more-popover")]}),[n,i.length,o,r]);return a.jsxs("div",{className:"flex h-full flex-col",children:[l,a.jsxs("div",{className:"flex min-h-0 flex-1",children:[!n&&a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i.map(c=>a.jsx(jl,{artifact:c},c.filename)),i.length===0&&a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:a.jsxs("div",{className:"text-muted-foreground text-center",children:[t&&a.jsx(hi,{className:"size-6 animate-spin"}),!t&&a.jsxs(a.Fragment,{children:[a.jsx(sr,{className:"mx-auto mb-4 h-12 w-12"}),a.jsx("div",{className:"text-lg font-medium",children:"Files"}),a.jsx("div",{className:"mt-2 text-sm",children:"No files available"})]})]})})]}),n&&a.jsxs("div",{className:"flex flex-1 flex-col gap-2 min-h-0 min-w-0",children:[a.jsx(jl,{artifact:n,isPreview:!0},n.filename),a.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-y-auto",children:a.jsx(MC,{artifact:n})})]})]}),a.jsx(NC,{}),a.jsx(DC,{})]})},zC=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:o,setActiveSidePanelTab:s,setPreviewArtifact:i,taskIdInSidePanel:l}=Be(),{isReconnecting:c,isTaskMonitorConnecting:f,isTaskMonitorConnected:d,monitoredTasks:p,connectTaskMonitorStream:m}=Gi(),[g,x]=u.useState(null);u.useEffect(()=>{if(l&&p[l]){const y=p[l],E=bE(y.events||[],p,y);x(E)}else x(null)},[l,p]);const h=()=>c||f?{message:"Connecting to task monitor ...",showButton:!1}:d?l?g?null:{message:"No workflow data available for the selected task",showButton:!1}:{message:"No task selected to display",showButton:!1}:{message:"No connection to task monitor",showButton:!0,buttonText:"Reconnect",buttonIcon:Yp,buttonAction:m},v=()=>{const y=!t;n(y),e(y)},b=y=>{y==="files"&&i(null),s(y)},w=y=>{t&&(n(!1),e==null||e(!1)),b(y)};return t?a.jsxs("div",{className:"bg-background flex h-full w-full flex-col items-center border-l py-4",children:[a.jsx(ve,{variant:"ghost",size:"sm",onClick:v,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:a.jsx(da,{className:"size-5"})}),a.jsx("div",{className:"bg-border my-4 h-px w-8"}),a.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>w("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:a.jsx(sr,{className:"size-5"})}),a.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>w("workflow"),className:"h-10 w-10 p-0",tooltip:"Workflow",children:a.jsx(po,{className:"size-5"})})]}):a.jsx("div",{className:"bg-background flex h-full flex-col border-l",children:a.jsx("div",{className:"m-1 min-h-0 flex-1",children:a.jsxs($0,{value:o,onValueChange:y=>b(y),className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex gap-2 p-2",children:[a.jsx(ve,{variant:"ghost",onClick:v,className:"p-1",tooltip:"Collapse Panel",children:a.jsx(da,{className:"size-5"})}),a.jsxs(B0,{className:"grid w-full grid-cols-2 bg-transparent p-0",children:[a.jsxs(sl,{value:"files",title:"Files",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-l-md border border-r-0 data-[state=active]:z-10 data-[state=active]:border-r-0",children:[a.jsx(sr,{className:"mr-2 h-4 w-4"}),"Files"]}),a.jsxs(sl,{value:"workflow",title:"Workflow",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-r-md border border-l-0 data-[state=active]:z-10 data-[state=active]:border-l-0",children:[a.jsx(po,{className:"mr-2 h-4 w-4"}),"Workflow"]})]})]}),a.jsxs("div",{className:"min-h-0 flex-1",children:[a.jsx(il,{value:"files",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:a.jsx(FC,{})})}),a.jsx(il,{value:"workflow",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:(()=>{const y=h();return!y&&g?a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsx(UC,{task:g}),a.jsx(wE,{processedSteps:g.steps||[],isRightPanelVisible:!1,isSidePanelTransitioning:r})]}):a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:a.jsxs("div",{className:"text-muted-foreground text-center",children:[a.jsx(po,{className:"mx-auto mb-4 h-12 w-12"}),a.jsx("div",{className:"text-lg font-medium",children:"Workflow"}),a.jsx("div",{className:"mt-2 text-sm",children:y==null?void 0:y.message}),(y==null?void 0:y.showButton)&&a.jsx("div",{className:"mt-4",children:a.jsxs(ve,{onClick:y.buttonAction,children:[y.buttonIcon&&(()=>{const E=y.buttonIcon;return a.jsx(E,{className:"h-4 w-4"})})(),y.buttonText]})})]})})})()})})]})]})})})},ai=({statusText:e,onViewWorkflow:t})=>a.jsxs("div",{className:"flex h-8 items-center space-x-3 py-1",children:[t?a.jsx(qc,{onClick:t}):a.jsx(K0,{className:"ml-2 mr-3"}),a.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:e&&a.jsx("span",{className:"text-muted-foreground animate-pulse truncate text-sm",title:e,children:e})})]}),hp=({isOpen:e,onClose:t})=>{const{handleNewSession:n}=Be(),{persistenceEnabled:r}=nn();return a.jsx(Go,{open:e,onOpenChange:t,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsx(Ko,{className:"flex flex-row gap-1 max-w-[400px]",children:r===!1?"New Chat Session?":"Start New Chat Session?"}),a.jsx(qo,{className:"flex flex-col gap-2",children:r===!1?"Starting a new chat session will clear the current chat history and files. Are you sure you want to proceed?":"This will create a new chat session. Your current chat will be saved in the sessions panel."})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(ve,{variant:"outline",onClick:t,children:"Cancel"}),a.jsx(ve,{variant:"default",onClick:()=>{n(),t()},children:"Start New Chat"})]})]})})},$C=({onToggle:e})=>{const[t,n]=u.useState(!1);return a.jsxs("div",{className:"bg-background flex h-full w-100 flex-col border-r",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 pt-[35px] pb-3",children:[a.jsx(ve,{variant:"ghost",onClick:e,className:"p-2",tooltip:"Collapse Sessions Panel",children:a.jsx(Kl,{className:"size-5"})}),a.jsxs(ve,{variant:"ghost",onClick:()=>n(!0),tooltip:"Start New Chat Session",children:[a.jsx(ql,{className:"size-5"}),"New chat"]})]}),a.jsx("div",{className:"mt-1 min-h-0 flex-1",children:a.jsx(TC,{})}),a.jsx(hp,{isOpen:t,onClose:()=>n(!1)})]})},Nr=(e,t)=>a.jsx(df,{type:t,className:"rounded-full border-none",children:a.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),BC=(e,t)=>{var r;if(e.currentStatusText)return a.jsx("div",{title:e.currentStatusText,children:a.jsx(ai,{statusText:e.currentStatusText})});const n=(r=t==null?void 0:t.parts)==null?void 0:r.filter(o=>o.kind==="text").map(o=>o.text).join("");switch(e.status){case"submitted":case"working":return a.jsx("div",{title:n||e.status,children:a.jsx(ai,{statusText:n||e.status})});case"input-required":return Nr("Input Required","info");case"completed":return Nr("Completed","success");case"canceled":return Nr("Canceled","info");case"failed":return Nr("Failed","error");default:return Nr("Unknown","info")}},UC=({task:e})=>{const{messages:t}=Be(),n=u.useMemo(()=>{const r=t.find(o=>o.isStatusBubble);return e?BC(e,r):null},[t,e]);return e?a.jsxs("div",{className:"grid grid-cols-[auto_1fr] grid-rows-[32px_32px] gap-x-8 border-b p-4 leading-[32px]",children:[a.jsx("div",{className:"text-muted-foreground",children:"User"}),a.jsx("div",{className:"truncate",title:e.initialRequestText,children:e.initialRequestText}),a.jsx("div",{className:"text-muted-foreground",children:"Status"}),a.jsx("div",{className:"truncate",children:n})]}):null};class gp{getEdgeAnimationState(t,n,r){const o=r.find(l=>l.id===t);if(!o)return{isAnimated:!1,animationType:"static"};if(!this.isAgentToToolRequest(o))return{isAnimated:!1,animationType:"static"};const s=r.slice(0,n+1);return this.hasMatchingResponse(o,s)?{isAnimated:!1,animationType:"static"}:{isAnimated:!0,animationType:"request"}}isAgentToToolRequest(t){var n,r;switch(t.type){case"AGENT_LLM_CALL":return!0;case"AGENT_TOOL_INVOCATION_START":return!(((n=t.data.toolDecision)==null?void 0:n.isPeerDelegation)||((r=t.data.toolInvocationStart)==null?void 0:r.isPeerInvocation)||t.target&&t.target.startsWith("peer_"));default:return!1}}hasMatchingResponse(t,n){switch(t.type){case"AGENT_LLM_CALL":return this.hasLLMResponse(t,n);case"AGENT_TOOL_INVOCATION_START":return this.hasToolResponse(t,n);default:return!1}}hasLLMResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.source;return n.some(s=>{var d;if(new Date(s.timestamp).getTime()<r)return!1;const l=(s.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||s.type==="AGENT_LLM_RESPONSE_TO_AGENT")&&s.target===o,c=s.source===o&&(s.type==="AGENT_TOOL_INVOCATION_START"||s.type==="TASK_COMPLETED"),f=s.type==="AGENT_TOOL_EXECUTION_RESULT"&&((d=s.data.toolResult)==null?void 0:d.isPeerResponse);return l||c||f})}hasToolResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.target,s=t.source;return n.some(i=>new Date(i.timestamp).getTime()<r?!1:i.type==="AGENT_TOOL_EXECUTION_RESULT"&&i.source===o&&i.target===s)}isRequestStep(t){return this.isAgentToToolRequest(t)}isResponseStep(t){return["AGENT_TOOL_EXECUTION_RESULT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_LLM_RESPONSE_TO_AGENT"].includes(t.type)}}const un={USER:50,MAIN_FLOW:300,TOOLS:600},HC=50,Ke=50,_t=330,Bn=50,Yt=20,ur=10,Ml=Ke+20,WC=90;function Un(e,t,n){return e.push(n),t.add(n.id),n}function GC(e,t){return e.push(t),t}function Hn(e,t){return e.nodeIdCounter++,`${t.replace(/[^a-zA-Z0-9_]/g,"_")}_${e.nodeIdCounter}`}function dt(e){return e.currentPhaseIndex===-1||e.currentPhaseIndex>=e.phases.length?null:e.phases[e.currentPhaseIndex]}function Xr(e){const t=dt(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function VC(e,t,n){var r;for(let o=e.length-1;o>=0;o--){const s=e[o],i=n.find(l=>l.id===s.id);if(((r=i==null?void 0:i.data)==null?void 0:r.toolName)===t)return s}return null}function YC(e,t){if(!t)return null;const n=dt(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function KC(e,t){if(!t)return null;const n=dt(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function as(e,t){var o;const n=dt(e);if(!n)return null;if(t.functionCallId){const s=YC(e,t.functionCallId);if(s)return s}if(t.owningTaskId&&t.isSubTaskStep){const s=KC(e,t.owningTaskId);if(s){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return s}}const r=Xr(e);if(r&&t.source){const s=t.source.replace(/[^a-zA-Z0-9_]/g,"_"),i=(o=t.target)==null?void 0:o.replace(/[^a-zA-Z0-9_]/g,"_"),l=r.peerAgent.id;if(l.includes(s)||i&&l.includes(i))return r}return r||null}function xp(e,t){var r,o,s;if(((r=e.data.toolDecision)==null?void 0:r.isParallel)===!0)return!0;const n=(s=(o=e.data)==null?void 0:o.toolInvocationStart)==null?void 0:s.functionCallId;return n?Array.from(t.parallelFlows.values()).some(i=>i.subflowFunctionCallIds.includes(n)):!1}function vp(e,t,n,r){var o;if(r)for(let s=e.length-1;s>=0;s--){const i=e[s];if(i.functionCallId===r){const l=n.find(c=>c.id===i.id);if(((o=l==null?void 0:l.data)==null?void 0:o.toolName)===t||t==="LLM")return i}}return VC(e,t,n)}function qC(e,t,n){const r=dt(e);if(!r)return null;const o=t.replace(/[^a-zA-Z0-9_]/g,"_"),s=n==null?void 0:n.replace(/[^a-zA-Z0-9_]/g,"_");let i=null;for(const l of r.subflows)if(l.peerAgent.id.includes(o)||s&&l.peerAgent.id.includes(s)){i=l;break}if(!i)return null;if(i.isParallel)return i;if(i.parentSubflowId){const l=r.subflows.find(c=>c.id===i.parentSubflowId);if(l&&l.isParallel)return l;if(l)return wp(r,l)}return null}function wp(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return wp(e,n)}return null}function dr(e,t,n,r){const o=`phase_${e.phases.length}`,s=Hn(e,`${t}_${o}`),i=e.nextAvailableGlobalY,l={id:s,type:"orchestratorNode",position:{x:un.MAIN_FLOW,y:i},data:{label:t,visualizerStepId:n.id}};Un(r,e.allCreatedNodeIds,l),e.nodePositions.set(s,l.position);const c={id:s,yPosition:i,height:Ke,width:_t},f={id:s,name:t,type:"orchestrator",phaseId:o,context:"main",nodeInstance:c};e.agentRegistry.registerAgent(f);const d={id:o,orchestratorAgent:c,userNodes:[],subflows:[],toolInstances:[],currentToolYOffset:0,maxY:i+Ke};return e.phases.push(d),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=d.maxY+Bn,d}function li(e,t,n,r,o){var Y,Z,G,q,te;const s=dt(e);if(!s)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((Y=n.data.toolResult)==null?void 0:Y.isPeerResponse)===!0,l=n.source||"",c=n.target||"",f=fr(l);!i&&!f&&!o&&e.indentationLevel++;const d=((G=(Z=n.delegationInfo)==null?void 0:Z[0])==null?void 0:G.subTaskId)||n.owningTaskId,p=Hn(e,`${t}_${d}`),m=Hn(e,`group_${t}_${d}`),g=((te=(q=n.data)==null?void 0:q.toolInvocationStart)==null?void 0:te.functionCallId)||n.functionCallId||"";let x,h,v;const b=Array.from(e.parallelFlows.values()).find(D=>D.subflowFunctionCallIds.includes(g)),w=Xr(e),y=qC(e,l,c);o&&b?(x=b.startX+b.currentXOffset,h=b.startY,v=h+Yt,b.currentXOffset+=(_t+ur)*2.2):y?(v=e.nextAvailableGlobalY,x=(y.groupNode.xPosition||un.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,h=v-Yt):(v=e.nextAvailableGlobalY,x=un.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,h=v-Yt);const E={id:p,type:"genericAgentNode",position:{x:50,y:Yt},data:{label:t,visualizerStepId:n.id},parentId:m},k={id:m,type:"group",position:{x,y:h},data:{label:`${t} Sub-flow`},style:{backgroundColor:"rgba(220, 220, 255, 0.1)",border:"1px solid #aac",borderRadius:"8px",minHeight:`${Ke+2*Yt}px`}};Un(r,e.allCreatedNodeIds,k),Un(r,e.allCreatedNodeIds,E),e.nodePositions.set(p,E.position),e.nodePositions.set(m,k.position);const I={id:p,xPosition:un.MAIN_FLOW,yPosition:v,height:Ke,width:_t},A={id:p,name:t,type:"peer",phaseId:s.id,subflowId:d,context:"subflow",nodeInstance:I};e.agentRegistry.registerAgent(A);const T={id:d,functionCallId:g,isParallel:o,peerAgent:I,groupNode:{id:m,xPosition:x,yPosition:h,height:Ke+2*Yt,width:0},toolInstances:[],currentToolYOffset:0,maxY:v+Ke,maxContentXRelative:E.position.x+_t,callingPhaseId:s.id,parentSubflowId:w==null?void 0:w.id,inheritedXOffset:y==null?void 0:y.groupNode.xPosition};return s.subflows.push(T),y&&(y.lastSubflow=T),e.currentSubflowIndex=s.subflows.length-1,o&&b?(b.maxHeight=Math.max(b.maxHeight,T.groupNode.height),e.nextAvailableGlobalY=b.startY+b.maxHeight+Bn):e.nextAvailableGlobalY=T.groupNode.yPosition+T.groupNode.height+Bn,T}function bp(e,t,n,r,o,s,i=!1){const l=dt(e);if(!l)return null;const c=s?s.toolInstances:l.toolInstances,f=i?"LLM":`Tool: ${t}`,d=i?"LLM":t,p=s?s.groupNode.id:void 0;let m,g,x,h;if(s){if(m=s.peerAgent.yPosition+s.currentToolYOffset,s.currentToolYOffset+=Ml,x=50+300,s.groupNode.xPosition===void 0||s.groupNode.yPosition===void 0)return null;g=s.groupNode.xPosition+x,h=m-s.groupNode.yPosition}else g=un.TOOLS,m=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=Ml,x=g,h=m;const v=Hn(e,`${d}_${r.id}`),b={id:v,type:n,position:{x,y:h},data:{label:f,visualizerStepId:r.id,toolName:t},parentId:p};Un(o,e.allCreatedNodeIds,b),e.nodePositions.set(v,{x,y:h});const w={id:v,xPosition:g,yPosition:m,height:Ke,width:_t,functionCallId:r.functionCallId};c.push(w);const y=m+Ke;if(s){s.maxY=Math.max(s.maxY,y),s.maxContentXRelative=Math.max(s.maxContentXRelative,x+_t);const E=s.maxY-s.groupNode.yPosition+Yt;s.groupNode.height=Math.max(s.groupNode.height,E);const k=s.maxContentXRelative+ur;s.groupNode.width=Math.max(s.groupNode.width||0,k);const I=o.find(A=>A.id===s.groupNode.id);I&&(I.style={...I.style,height:`${s.groupNode.height}px`,width:`${s.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,s.groupNode.yPosition+s.groupNode.height+Bn)}else l.maxY=Math.max(l.maxY,y),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+Bn);return w}function oa(e,t,n,r){e.userNodeCounter++;const o=Hn(e,`User_response_${e.userNodeCounter}`),s=e.nextAvailableGlobalY+20,i={id:o,type:"userNode",position:{x:un.USER,y:s},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};Un(r,e.allCreatedNodeIds,i),e.nodePositions.set(o,i.position);const l={id:o,yPosition:s,height:Ke,width:_t};t.userNodes.push(l),e.allUserNodes.push(l);const c=s+Ke;return t.maxY=Math.max(t.maxY,c),l}function yt(e,t,n,r,o,s,i,l,c){if(!e||!t||e===t)return;const f=o.allCreatedNodeIds.has(e),d=o.allCreatedNodeIds.has(t);if(!f||!d)return;const p=`edge-${e}${l||""}-to-${t}${c||""}-${n.id}`;if(!r.some(g=>g.id===p)){const g=n.title&&n.title.length>30?n.type.replace(/_/g," ").toLowerCase():n.title||"",x=s.isRequestStep(n),h={id:p,source:e,target:t,label:g,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:x,animationType:x?"request":"static",duration:1}};l&&(h.sourceHandle=l),c&&(h.targetHandle=c),GC(r,h)}}function XC(){const e=new Map;return{agents:e,findAgentByName(t){const n=t.startsWith("peer_")?t.substring(5):t,r=[];for(const[,o]of e)(o.name===n||o.name===t)&&r.push(o);return r.length===0?null:r.reduce((o,s)=>{const i=parseInt(o.id.split("_").pop()||"0");return parseInt(s.id.split("_").pop()||"0")>i?s:o})},findAgentById(t){for(const[,n]of e)if(n.id===t)return n;return null},registerAgent(t){e.set(t.id,t)}}}function ci(e,t,n){return e==="orchestrator"?t==="output"?n==="bottom"?"orch-bottom-output":"orch-right-output-tools":n==="top"?"orch-top-input":"orch-right-input-tools":t==="output"?n==="bottom"?"peer-bottom-output":"peer-right-output-tools":n==="top"?"peer-top-input":"peer-right-input-tools"}function fr(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const ZC=["USER_REQUEST","AGENT_LLM_CALL","AGENT_LLM_RESPONSE_TO_AGENT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_TOOL_INVOCATION_START","AGENT_TOOL_EXECUTION_RESULT","AGENT_RESPONSE_TEXT","TASK_COMPLETED","TASK_FAILED"];function JC(e,t,n,r,o,s){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=dt(t),f=Xr(t);let d,p=!1;if(f?(d=f.peerAgent,d.id.startsWith(l+"_")&&(p=!0)):c&&(d=c.orchestratorAgent,d.id.startsWith(l+"_")&&(p=!0)),p&&d&&c){t.userNodeCounter++;const m=Hn(t,`User_continue_${t.userNodeCounter}`),g=t.nextAvailableGlobalY,x={id:m,type:"userNode",position:{x:un.USER,y:g},data:{label:"User",visualizerStepId:e.id}};Un(n,t.allCreatedNodeIds,x),t.nodePositions.set(m,x.position);const h={id:m,yPosition:g,height:Ke,width:_t};c.userNodes.push(h),t.allUserNodes.push(h);const v=g+Ke;d.yPosition=Math.max(d.yPosition,g),c.maxY=Math.max(c.maxY,v,d.yPosition+Ke),t.nextAvailableGlobalY=c.maxY+Bn;const b=fr(i)?"orch-left-input":"peer-left-input";yt(h.id,d.id,e,r,t,o,s,"user-right-output",b)}else{const m=dr(t,i,e,n),g=Hn(t,`User_${m.id}`),x={id:g,type:"userNode",position:{x:un.USER,y:m.orchestratorAgent.yPosition-WC},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};Un(n,t.allCreatedNodeIds,x),t.nodePositions.set(g,x.position);const h={id:g,yPosition:x.position.y,height:Ke,width:_t};m.userNodes.push(h),t.allUserNodes.push(h),t.userNodeCounter++,m.maxY=Math.max(m.maxY,x.position.y+Ke),t.nextAvailableGlobalY=m.maxY+Bn,yt(g,m.orchestratorAgent.id,e,r,t,o,s,"user-bottom-output","orch-top-input")}}function QC(e,t,n,r,o,s){const i=dt(t);if(!i)return;const l=as(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,f=bp(t,"LLM","llmNode",e,n,l,!0);f&&yt(c,f.id,e,r,t,o,s,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function eE(e,t,n,r,o,s){var x;if(e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"&&((x=e.data.toolDecision)!=null&&x.isParallel)){const h=`parallel-${e.id}`;e.data.toolDecision.decisions.filter(v=>v.isPeerDelegation).length>1&&t.parallelFlows.set(h,{subflowFunctionCallIds:e.data.toolDecision.decisions.filter(v=>v.isPeerDelegation).map(v=>v.functionCallId),completedSubflows:new Set,startX:un.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=dt(t);if(!i)return;const l=as(t,e);let c;const d=vp((l||i).toolInstances,"LLM",n,e.functionCallId);if(d)c=d.id;else{console.error(`[Timeline] LLM node not found for step type ${e.type}: ${e.id}. Cannot create edge.`);return}const p=e.target||"UnknownAgent";let m,g;l?(m=l.peerAgent.id,g="peer-right-input-tools"):i.orchestratorAgent.id.startsWith(p.replace(/[^a-zA-Z0-9_]/g,"_")+"_")&&(m=i.orchestratorAgent.id,g="orch-right-input-tools"),c&&m&&g?yt(c,m,e,r,t,o,s,"llm-bottom-output",g):console.error(`[Timeline] Could not determine target agent node ID or handle for step type ${e.type}: ${e.id}. Target agent name: ${p}. Edge will be missing.`)}function tE(e,t,n,r,o,s){var d;const i=dt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"UnknownTool";if(((d=e.data.toolInvocationStart)==null?void 0:d.isPeerInvocation)||c.startsWith("peer_")){const p=c.startsWith("peer_")?c.substring(5):c,m=t.agentRegistry.findAgentByName(l);if(!m){console.error(`[Timeline] Could not find source agent in registry: ${l} for step ${e.id}`);return}const g=m.nodeInstance,x=ci(m.type,"output","bottom"),h=xp(e,t),v=li(t,p,e,n,h);v&&yt(g.id,v.peerAgent.id,e,r,t,o,s,x,"peer-top-input")}else{const p=as(t,e);let m,g;if(p)m=p.peerAgent.id,g="peer-right-output-tools";else{const h=t.agentRegistry.findAgentByName(l);h?(m=h.id,g=ci(h.type,"output","right")):(m=i.orchestratorAgent.id,g="orch-right-output-tools")}const x=bp(t,c,"genericToolNode",e,n,p);x&&yt(m,x.id,e,r,t,o,s,g,`${x.id}-tool-left-input`)}}function nE(e,t,n,r,o,s){var f,d;const i=dt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"OrchestratorAgent";if((f=e.data.toolResult)!=null&&f.isPeerResponse){const p=(d=e.data.toolResult)==null?void 0:d.functionCallId,m=Array.from(t.parallelFlows.entries()).find(([x,h])=>h.subflowFunctionCallIds.includes(p||""));if(m){const[x,h]=m;if(h.completedSubflows.add(p||""),h.completedSubflows.size<h.subflowFunctionCallIds.length)return;const v=i.subflows.filter(E=>h.subflowFunctionCallIds.includes(E.functionCallId)),b=e.target||"OrchestratorAgent";let w,y;if(fr(b))t.indentationLevel=0,w=dr(t,b,e,n).orchestratorAgent,y="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const E=li(t,b,e,n,!1);if(!E)return;w=E.peerAgent,y="peer-top-input"}v.forEach(E=>{var k;yt(((k=E.lastSubflow)==null?void 0:k.peerAgent.id)??E.peerAgent.id,w.id,e,r,t,o,s,"peer-bottom-output",y)}),t.parallelFlows.delete(x);return}const g=t.agentRegistry.findAgentByName(l.startsWith("peer_")?l.substring(5):l);if(!g){console.error(`[Timeline] Source peer agent not found for peer response: ${l}.`);return}if(fr(c)){t.indentationLevel=0;const x=dr(t,c,e,n);yt(g.id,x.orchestratorAgent.id,e,r,t,o,s,"peer-bottom-output","orch-top-input"),t.currentSubflowIndex=-1}else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const x=xp(e,t)||Array.from(t.parallelFlows.values()).some(v=>v.subflowFunctionCallIds.some(b=>i.subflows.some(w=>w.functionCallId===b))),h=li(t,c,e,n,x);h&&yt(g.id,h.peerAgent.id,e,r,t,o,s,"peer-bottom-output","peer-top-input")}}else{let p;const m=as(t,e),x=vp((m||i).toolInstances,l,n,e.functionCallId);if(x&&(p=x.id),p){let h,v;if(m)h=m.peerAgent.id,v="peer-right-input-tools";else{const b=t.agentRegistry.findAgentByName(c);b?(h=b.id,v=ci(b.type,"input","right")):(h=i.orchestratorAgent.id,v="orch-right-input-tools")}yt(p,h,e,r,t,o,s,l==="LLM"?"llm-bottom-output":`${p}-tool-bottom-output`,v)}else console.error(`[Timeline] Could not find source tool node for regular tool result: ${e.id}. Step source (tool name): ${l}.`)}}function rE(e,t,n,r,o,s){const i=dt(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=oa(t,i,e,n);yt(l,c.id,e,r,t,o,s,"orch-bottom-output","user-top-input")}function oE(e,t,n,r,o,s){const i=dt(t);if(!i)return;const l=Array.from(t.parallelFlows.values()).find(g=>g.subflowFunctionCallIds.includes(e.functionCallId||""));if(l){if(l.completedSubflows.add(e.functionCallId||""),l.completedSubflows.size===l.subflowFunctionCallIds.length){t.indentationLevel=0;const g=dr(t,"OrchestratorAgent",e,n);i.subflows.forEach(x=>{l.subflowFunctionCallIds.includes(x.functionCallId)&&yt(x.peerAgent.id,g.orchestratorAgent.id,e,r,t,o,s,"peer-bottom-output","orch-top-input")}),t.currentSubflowIndex=-1}return}if(!e.isSubTaskStep)return;const c=Xr(t);if(!c){console.warn(`[Timeline] TASK_COMPLETED with isSubTaskStep=true but no active subflow. Step ID: ${e.id}`);return}if(!i){console.error(`[Timeline] No current phase found for TASK_COMPLETED. Step ID: ${e.id}`);return}const f=c.peerAgent,d=n.some(g=>typeof g.data.label=="string"&&fr(g.data.label));let p,m;d?(t.indentationLevel=0,p=dr(t,"OrchestratorAgent",e,n).orchestratorAgent.id,m="orch-top-input"):(p=oa(t,i,e,n).id,m="user-top-input"),yt(f.id,p,e,r,t,o,s,"peer-bottom-output",m),t.currentSubflowIndex=-1}function sE(e,t,n,r){const o=dt(t);if(!o)return;const s=e.source||"UnknownSource",i=e.target||"User";let l,c="orch-bottom-output";const f=Xr(t);if(f&&f.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=f.peerAgent,c="peer-bottom-output";else if(o.orchestratorAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=o.orchestratorAgent,c="orch-bottom-output";else for(const m of o.subflows)if(m.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_"))){l=m.peerAgent,c="peer-bottom-output";break}if(!l){console.error(`[Timeline] Could not find source agent node for TASK_FAILED: ${s}`);return}let d,p;fr(i)?(t.indentationLevel=0,d=dr(t,i,e,n).orchestratorAgent.id,p="orch-top-input",t.currentSubflowIndex=-1):(d=oa(t,o,e,n).id,p="user-top-input"),iE(l.id,d,e,r,t,c,p)}function iE(e,t,n,r,o,s,i){var p;if(!e||!t||e===t)return;const l=o.allCreatedNodeIds.has(e),c=o.allCreatedNodeIds.has(t);if(!l||!c)return;const f=`error-edge-${e}${s||""}-to-${t}${i||""}-${n.id}`;if(!r.some(m=>m.id===f)){const m=((p=n.data.errorDetails)==null?void 0:p.message)||"Task failed",g=m.length>30?"Error":m,x={id:f,source:e,target:t,label:g,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:!1,animationType:"static",isError:!0,errorMessage:m}};s&&(x.sourceHandle=s),i&&(x.targetHandle=i),r.push(x)}}const aE=e=>{const t=[],n=[];if(!e||e.length===0)return{nodes:t,edges:n};const r=new gp,o={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:HC,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:XC(),indentationLevel:0,indentationStep:50},s=e.filter(c=>ZC.includes(c.type)),i=s.findIndex(c=>c.type==="USER_REQUEST");let l=s;i>0&&(l=[s[i],...s.slice(0,i),...s.slice(i+1)]);for(const c of l)switch(c.type){case"USER_REQUEST":JC(c,o,t,n,r,e);break;case"AGENT_LLM_CALL":QC(c,o,t,n,r,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":eE(c,o,t,n,r,e);break;case"AGENT_TOOL_INVOCATION_START":tE(c,o,t,n,r,e);break;case"AGENT_TOOL_EXECUTION_RESULT":nE(c,o,t,n,r,e);break;case"AGENT_RESPONSE_TEXT":rE(c,o,t,n,r,e);break;case"TASK_COMPLETED":oE(c,o,t,n,r,e);break;case"TASK_FAILED":sE(c,o,t,n);break}return o.phases.forEach(c=>{c.subflows.forEach(f=>{const d=t.find(p=>p.id===f.groupNode.id);if(d&&d.style){const m=f.maxY-f.groupNode.yPosition+Yt;d.style.height=`${Math.max(Ke+2*Yt,m)}px`;const g=f.maxContentXRelative+ur,x=_t+2*ur+o.indentationLevel*o.indentationStep;d.style.width=`${Math.max(g,x)}px`}})}),{nodes:t,edges:n}},lE=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,style:l={},markerEnd:c,data:f})=>{const[d,p]=u.useState(!1),[m]=Kp({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i}),g=()=>{const v={strokeWidth:d?3:2,stroke:"var(--color-muted-foreground)",...l},b=f;return b!=null&&b.isError?{...v,stroke:d?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:d?3:2}:b!=null&&b.isSelected?{...v,stroke:"#3b82f6",strokeWidth:3}:b!=null&&b.isAnimated?{...v,stroke:d?"#1d4ed8":"#3b82f6",strokeWidth:d?4:3}:d?{...v,stroke:"var(--edge-hover-color)"}:v},x=()=>p(!0),h=()=>p(!1);return a.jsxs(a.Fragment,{children:[a.jsx("path",{id:`${e}-interaction`,style:{strokeWidth:16,stroke:"transparent",fill:"none",cursor:"pointer"},className:"react-flow__edge-interaction",d:m,onMouseEnter:x,onMouseLeave:h}),a.jsx("path",{id:e,style:{...g(),cursor:"pointer",transition:"all 0.2s ease-in-out"},className:"react-flow__edge-path",d:m,markerEnd:c,onMouseEnter:x,onMouseLeave:h})]})},cE=({data:e})=>a.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-blue-700 bg-white px-5 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-blue-600 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"180px",textAlign:"center"},children:[a.jsx(Xe,{type:"target",position:Ze.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Xe,{type:"source",position:Ze.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),a.jsx(Xe,{type:"source",position:Ze.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Left,id:"peer-left-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("div",{className:"text-md font-semibold",children:e.label})})]}),uE=({data:e,id:t})=>{const n=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-cyan-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-cyan-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-cyan-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[a.jsx(Xe,{type:"target",position:Ze.Left,id:`${t}-tool-left-input`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"25%"}}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${n()}`}),a.jsx("div",{className:"text-md",children:e.label})]}),a.jsx(Xe,{type:"source",position:Ze.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}})]})},dE=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-teal-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-teal-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-teal-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[a.jsx(Xe,{type:"target",position:Ze.Left,id:"llm-left-input",className:"!bg-teal-500",isConnectable:!0,style:{top:"25%"}}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${t()}`}),a.jsx("div",{className:"text-md",children:e.label})]}),a.jsx(Xe,{type:"source",position:Ze.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},fE=({data:e})=>a.jsxs("div",{className:"cursor-pointer rounded-lg border-indigo-600 bg-gradient-to-r from-indigo-50 to-purple-50 px-5 py-3 text-gray-900 shadow-xl transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-2xl dark:border-indigo-400 dark:bg-gradient-to-r dark:from-indigo-900 dark:to-purple-900 dark:text-gray-100",style:{minWidth:"180px",textAlign:"center",borderWidth:"2px",borderStyle:"solid",boxShadow:"0 0 0 1px rgba(79, 70, 229, 0.3), 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},children:[a.jsx(Xe,{type:"source",position:Ze.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Xe,{type:"source",position:Ze.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Left,id:"orch-left-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("div",{className:"text-md flex items-center font-bold",children:e.label})})]}),pE=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-purple-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-purple-600 bg-white px-4 py-3 text-gray-800 shadow-lg transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-purple-400 dark:bg-gray-700 dark:text-gray-200",style:{minWidth:"120px",textAlign:"center"},children:[e.isTopNode&&a.jsx(Xe,{type:"source",position:Ze.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&a.jsx(Xe,{type:"target",position:Ze.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&a.jsx(Xe,{type:"source",position:Ze.Right,id:"user-right-output",className:"!bg-gray-500",isConnectable:!0}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-3 w-3 rounded-full ${t()}`}),a.jsx("div",{className:"text-sm font-bold",children:e.label})]})]})},mE=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const o=()=>{var w,y,E;switch(e.type){case"USER_REQUEST":return a.jsx(Jp,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return a.jsx(cs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return a.jsx(Vl,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return a.jsx(Zp,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return a.jsx(cs,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return a.jsx(cs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const k=(y=(w=e.data.toolDecision)==null?void 0:w.decisions)==null?void 0:y[0];return(k==null?void 0:k.isPeerDelegation)?a.jsx(fa,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):a.jsx(pa,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18})}case"AGENT_TOOL_INVOCATION_START":return(E=e.data.toolInvocationStart)!=null&&E.isPeerInvocation?a.jsx(fa,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):a.jsx(pa,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return a.jsx(Xp,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return a.jsx(sr,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return a.jsx(qp,{className:"mr-2 text-gray-500 dark:text-gray-400",size:18})}},s=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),i=String(new Date(e.timestamp).getMilliseconds()).padStart(3,"0"),l=`${s}.${i}`,c=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Model:"})," ",w.modelName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Prompt Preview:"})}),a.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:w.promptPreview})]}),f=({data:w})=>{const[y,E]=Ft.useState(!1),k=I=>{I.stopPropagation(),E(!y)};return y?a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[a.jsx("strong",{children:"LLM Response Details:"}),a.jsx("button",{onClick:k,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Hide details"})]}),w.modelName&&a.jsxs("p",{children:[a.jsx("strong",{children:"Model:"})," ",w.modelName]}),a.jsxs("div",{className:"mt-1",children:[a.jsx("p",{children:a.jsx("strong",{children:"Response Preview:"})}),a.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:w.responsePreview})]}),w.isFinalResponse!==void 0&&a.jsxs("p",{className:"mt-1",children:[a.jsx("strong",{children:"Final Response:"})," ",w.isFinalResponse?"Yes":"No"]})]}):a.jsxs("div",{className:"mt-1.5 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[a.jsx("span",{className:"italic",children:"Internal LLM response"}),a.jsx("button",{onClick:k,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},d=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-blue-50 p-2 font-mono text-xs text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:[a.jsx("p",{className:"mb-2",children:a.jsxs("strong",{children:["🔧 ",w.isParallel?"Parallel Tool Calls:":"Tool Call:"]})}),a.jsx("ul",{className:"space-y-1 pl-2",children:w.decisions.map(y=>a.jsxs("li",{className:"flex items-center",children:[a.jsx("span",{className:"mr-2",children:"•"}),a.jsx("code",{children:y.toolName})]},y.functionCallId))})]}),p=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Tool:"})," ",w.toolName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Arguments:"})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:a.jsx(fi,{data:w.toolArguments})})]}),m=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Tool:"})," ",w.toolName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Result:"})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:typeof w.resultData=="object"?a.jsx(fi,{data:w.resultData}):a.jsx("pre",{className:"font-mono text-xs break-all whitespace-pre-wrap",children:String(w.resultData)})})]}),g=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Artifact:"})," ",w.artifactName,w.version!==void 0&&a.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" (v",w.version,")"]})]}),w.mimeType&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",w.mimeType]}),w.description&&a.jsxs("p",{className:"mt-1",children:[a.jsx("strong",{children:"Description:"})," ",w.description]})]}),x=r==="list"&&e.nestingLevel&&e.nestingLevel>0?{marginLeft:`${e.nestingLevel*24}px`}:{},h=r==="popover"?`
329
+ `:""}var KS=YS,qS={dump:KS};function na(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var XS=Je,ZS=Nf,JS=jf,QS=Df,eC=Of,tC=Ji,nC=ep.load,rC=ep.loadAll,oC=qS.dump,sC=lt,iC={binary:Uf,float:Lf,map:If,null:Mf,pairs:Wf,set:Gf,timestamp:$f,bool:Rf,int:Pf,merge:Bf,omap:Hf,seq:_f,str:kf},aC=na("safeLoad","load"),lC=na("safeLoadAll","loadAll"),cC=na("safeDump","dump"),uC={Type:XS,Schema:ZS,FAILSAFE_SCHEMA:JS,JSON_SCHEMA:QS,CORE_SCHEMA:eC,DEFAULT_SCHEMA:tC,load:nC,loadAll:rC,dump:oC,YAMLException:sC,types:iC,safeLoad:aC,safeLoadAll:lC,safeDump:cC};const dC=({content:e,rendererType:t,setRenderError:n})=>{const[r,o]=u.useState(!1);u.useEffect(()=>{n(null)},[e,n]);const[s,i]=u.useMemo(()=>{try{if(t==="yaml"){const l=uC.load(e);return[e,l]}else if(t==="json"){const l=JSON.parse(e);return[JSON.stringify(l,null,2),l]}throw new Error(`Unsupported renderer type: ${t}`)}catch(l){const c=t==="yaml"?"YAML":"JSON";console.error(`Error parsing ${c} for panel:`,l);const f={[`${c}_Parsing_Error`]:`The provided content is not valid ${c}.`,Details:l.message,Content_Snippet:e.substring(0,500)+(e.length>500?"...":"")};return n(`${c} parsing failed: ${l.message}`),[e,f]}},[e,t,n]);return a.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background relative",children:[a.jsx("div",{className:"absolute top-4 right-4 z-10",children:a.jsx(ve,{onClick:()=>o(!r),title:r?"Show Structured View":"Show Raw Text",children:r?a.jsxs(a.Fragment,{children:[a.jsx(Ul,{})," Structured"]}):a.jsxs(a.Fragment,{children:[a.jsx(Hl,{})," Raw Text"]})})}),a.jsx("div",{className:"flex min-h-0 flex-col",children:a.jsx("div",{className:"flex-1 overflow-auto",children:r?a.jsx(fp,{content:s,setRenderError:n}):a.jsx(fi,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},fp=({content:e,className:t=""})=>{const{ref:n,handleKeyDown:r}=vf();return a.jsx("div",{className:`p-4 overflow-auto ${t}`,children:a.jsx("pre",{ref:n,className:"whitespace-pre-wrap focus-visible:outline-none select-text",style:{overflowWrap:"anywhere"},tabIndex:0,onKeyDown:r,children:e})})},pp=({content:e,rendererType:t,mime_type:n,setRenderError:r})=>{switch(t){case"csv":return a.jsx(wb,{content:e,setRenderError:r});case"mermaid":return a.jsx(Wb,{content:e,setRenderError:r});case"html":return a.jsx(bb,{content:e,setRenderError:r});case"json":case"yaml":return a.jsx(dC,{content:e,rendererType:t,setRenderError:r});case"image":return a.jsx(yb,{content:e,mime_type:n,setRenderError:r});case"markdown":return a.jsx(Sb,{content:e,setRenderError:r});case"audio":return a.jsx(xb,{content:e,mime_type:n,setRenderError:r});default:return a.jsx(fp,{content:e,setRenderError:r})}},fC={"application/pdf":"pdf","application/zip":"zip","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/x-markdown":"md","application/json":"json","application/yaml":"yaml","text/yaml":"yaml","application/xml":"xml","text/xml":"xml","image/jpeg":"jpg","image/png":"png","image/gif":"gif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff","audio/mpeg":"mp3","audio/wav":"wav","audio/ogg":"ogg","audio/aac":"aac","audio/flac":"flac","audio/x-m4a":"m4a","video/mp4":"mp4","video/webm":"webm","video/ogg":"ogv","application/javascript":"js","application/gzip":"gz","application/x-tar":"tar","application/rtf":"rtf"};function pC(e,t){const n=fC[e]||"bin";return`embedded_file_${t+1}.${n}`}function mC(e){if(!e||typeof e!="string")return[];const t=[],n=/data:([a-zA-Z0-9/.-]+);base64,([A-Za-z0-9+/=]+)/g;let r,o=0;for(;(r=n.exec(e))!==null;){const[s,i,l]=r,c=e[r.index-1],f=e[r.index+s.length];if(!(c==='"'&&f==='"'||c==="'"&&f==="'")&&l&&l.length>10){const d=qr(void 0,i);d?t.push({type:d,content:l,mimeType:i,originalMatch:s}):t.push({type:"file",content:l,mimeType:i,originalMatch:s,filename:pC(i,o++)})}}return t}function hC(e){if(!e||typeof e!="string")return[];const t=[],n=/<html[\s\S]*?<\/html>/gi;let r;for(;(r=n.exec(e))!==null;)t.push({type:"html",content:r[0].trim(),originalMatch:r[0]});return t}function gC(e){if(!e||typeof e!="string")return[];const t=[],n=/```mermaid\s*\n([\s\S]*?)```/gi;let r;for(;(r=n.exec(e))!==null;){const[o,s]=r;t.push({type:"mermaid",content:s.trim(),originalMatch:o})}return t}function xC(e){return!e||typeof e!="string"?[]:[...mC(e),...hC(e),...gC(e)]}const vC=["image","audio"],wC=({message:e})=>{var f;const[t,n]=u.useState(null);if(e.isStatusBubble)return null;const r=(f=e.parts)==null?void 0:f.filter(d=>d.kind==="text"),o=(r==null?void 0:r.map(d=>d.text).join(""))||"";if(e.isUser)return a.jsx("span",{children:o});const s=o.trim();if(!s)return null;if(e.isError)return a.jsxs("div",{className:"flex items-center",children:[a.jsx(gi,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),a.jsx(or,{children:s})]});const i=xC(s);if(i.length===0)return a.jsx(or,{children:s});let l=s;const c=[];return i.forEach((d,p)=>{if(l=l.replace(d.originalMatch,""),d.type==="file"){const m={name:d.filename||"downloaded_file",content:d.content,mime_type:d.mimeType};c.push(a.jsx("div",{className:"my-2",children:a.jsx(gf,{fileAttachment:m,isEmbedded:!0})},`embedded-file-${p}`))}else if(!vC.includes(d.type)){const m=ff(d.content);m&&c.push(a.jsx("div",{className:"my-2 h-auto w-md max-w-md",children:a.jsx(pp,{content:m,rendererType:d.type,mime_type:d.mimeType,setRenderError:n})},`embedded-${p}`))}}),a.jsxs("div",{children:[t&&a.jsx(ra,{variant:"error",message:"Error rendering preview"}),a.jsx(or,{children:l}),c]})},mp=({message:e,children:t,className:n})=>a.jsx("div",{className:`mt-1 space-y-1 ${e.isUser?"ml-auto":"mr-auto"} ${n}`,children:t}),bC=e=>e.uploadedFiles&&e.uploadedFiles.length>0?a.jsx(mp,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return a.jsx(xf,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,yC=e=>e.files&&e.files.length>0?a.jsx(mp,{message:e,children:e.files.map((t,n)=>{var r;return a.jsx(gf,{fileAttachment:t},`file-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,SC=(e,t,n)=>{var f,d;const{openSidePanelTab:r,setTaskIdInSidePanel:o}=t;if(e.isStatusBubble)return null;const s=(f=e.parts)==null?void 0:f.some(p=>p.kind==="text"&&p.text.trim());if(!s&&!e.artifactNotification)return null;const i=e.isUser?"sent":"received",l=!e.isUser&&e.isComplete&&!!e.taskId&&n,c=()=>{e.taskId&&(o(e.taskId),r("workflow"))};return a.jsx(af,{variant:i,children:a.jsxs(lf,{variant:i,children:[s&&a.jsx(wC,{message:e}),e.artifactNotification&&a.jsxs("div",{className:"my-1 flex items-center rounded-md bg-blue-100 p-2 dark:bg-blue-900/50",children:[a.jsx(sr,{className:"mr-2 text-blue-500 dark:text-blue-400"}),a.jsxs("span",{className:"text-sm",children:["Artifact created: ",a.jsx("strong",{children:e.artifactNotification.name}),e.artifactNotification.version&&` (v${e.artifactNotification.version})`]})]}),l&&a.jsx("div",{className:"mt-3",children:a.jsx(qc,{onClick:c})})]})},(d=e.metadata)==null?void 0:d.messageId)},CC=({message:e,isLastWithTaskId:t})=>{const n=Be();return e?a.jsxs(a.Fragment,{children:[SC(e,n,t),bC(e),yC(e)]}):null},EC=()=>{const{handleSwitchSession:e,updateSessionName:t,openSessionDeleteModal:n}=Be(),{configServerUrl:r}=nn(),o=u.useRef(null),[s,i]=u.useState([]),[l,c]=u.useState(null),[f,d]=u.useState(""),p=u.useCallback(async()=>{const w=`${r}/api/v1/sessions`;try{const y=await De(w);if(y.ok){const E=await y.json();i(E.sessions||[])}else console.error(`Failed to fetch sessions: ${y.status} ${y.statusText}`)}catch(y){console.error("An error occurred while fetching sessions:",y)}},[r]);u.useEffect(()=>{p();const w=()=>{p()},y=E=>{const{sessionId:k}=E.detail;i(I=>{const A=I.find(T=>T.id===k);if(A){const T=I.filter(Y=>Y.id!==k);return[A,...T]}return I})};return window.addEventListener("new-chat-session",w),window.addEventListener("session-updated",y),()=>{window.removeEventListener("new-chat-session",w),window.removeEventListener("session-updated",y)}},[p]),u.useEffect(()=>{l&&o.current&&o.current.focus()},[l]);const m=async w=>{l!==w&&await e(w)},g=w=>{c(w.id),d(w.name||"")},x=async()=>{l&&(await t(l,f),c(null),p())},h=w=>{n(w)},v=w=>new Date(w).toLocaleString(),b=w=>{if(w.name&&w.name.trim())return w.name;const y=w.id;return y.startsWith("web-session-")?`Chat ${y.replace("web-session-","").substring(0,8)}`:`Session ${y.substring(0,8)}`};return a.jsxs("div",{className:"p-4 flex flex-col h-full",children:[a.jsx("div",{className:"text-lg",children:"Chat Session History"}),s.length>0&&a.jsx("ul",{children:s.map(w=>a.jsx("li",{className:"my-2 group",children:a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 rounded hover:bg-gray-200 dark:hover:bg-gray-700",children:[l===w.id?a.jsx("input",{ref:o,type:"text",value:f,onChange:y=>d(y.target.value),onKeyDown:y=>y.key==="Enter"&&x(),onBlur:x,className:"flex-grow bg-transparent focus:outline-none"}):a.jsx("button",{onClick:()=>m(w.id),className:"flex-grow text-left",children:a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"font-semibold",children:b(w)}),a.jsx("span",{className:"text-xs text-muted-foreground",children:v(w.updated_at)})]})}),a.jsx("div",{className:"flex items-center opacity-0 group-hover:opacity-100 transition-opacity",children:l===w.id?a.jsxs(a.Fragment,{children:[a.jsx(ve,{variant:"ghost",onClick:x,children:a.jsx(mi,{size:16})}),a.jsx(ve,{variant:"ghost",onClick:()=>c(null),children:a.jsx(Ro,{size:16})})]}):a.jsxs(a.Fragment,{children:[a.jsx(ve,{variant:"ghost",onClick:()=>g(w),children:a.jsx(zp,{size:16})}),a.jsx(ve,{variant:"ghost",onClick:()=>h(w),children:a.jsx($p,{size:16})})]})})]})},w.id))}),s.length===0&&a.jsxs("div",{className:"flex flex-col flex-1 h-full text-sm text-muted-foreground items-center justify-center",children:[a.jsx(Wl,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]})]})},TC=()=>{const{persistenceEnabled:e}=nn(),t=Xu();return e===!1?a.jsx("div",{className:"flex h-full flex-col",children:a.jsxs("div",{className:"flex-1 overflow-y-auto px-4",children:[a.jsxs("div",{className:"bg-accent/50 hover:bg-accent mb-3 cursor-pointer rounded-md p-3",children:[a.jsx("div",{className:"text-foreground truncate text-sm font-medium text-nowrap",children:t}),a.jsx("div",{className:"text-muted-foreground mt-1 text-xs",children:"Current session"})]}),a.jsx("div",{className:"text-muted-foreground mt-4 text-center text-xs",children:"Multi-session support coming soon"})]})}):a.jsx("div",{className:"flex h-full flex-col",children:a.jsx("div",{className:"flex-1 overflow-y-auto px-4",children:a.jsx(EC,{})})})},AC=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:o,setIsExpanded:s})=>{const{previewedArtifactAvailableVersions:i,currentPreviewedVersionNumber:l,navigateArtifactVersion:c}=Be(),f=u.useMemo(()=>i??[],[i]);return a.jsxs("div",{className:"flex flex-row justify-between gap-1",children:[a.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"truncate text-sm",title:e.filename,children:e.filename}),a.jsx("div",{className:"truncate text-xs",title:Ea(e.last_modified),children:Ea(e.last_modified)})]}),t&&f.length>1&&a.jsx("div",{className:"align-right",children:a.jsxs(Fd,{value:l==null?void 0:l.toString(),onValueChange:d=>{c(e.filename,parseInt(d))},children:[a.jsx($d,{className:"h-[16px] py-0 text-xs shadow-none",children:a.jsx(zd,{placeholder:"Version"})}),a.jsx(Bd,{children:f.map(d=>a.jsxs(Ud,{value:d.toString(),children:["Version ",d]},d))})]})})]}),a.jsxs("div",{className:`whitespace-nowrap ${t?"opacity-100":"opacity-0 transition-opacity duration-150 group-focus-within:opacity-100 group-hover:opacity-100"}`,children:[s&&a.jsx(ve,{variant:"ghost",size:"sm",onClick:d=>{d.stopPropagation(),d.preventDefault(),s(!n)},tooltip:n?"Collapse Details":"Expand Details",children:a.jsx(vi,{})}),o&&a.jsx(ve,{variant:"ghost",size:"sm",onClick:async d=>{d.stopPropagation(),d.preventDefault(),await o(e)},tooltip:"Download",children:a.jsx(xi,{})}),r&&a.jsx(ve,{variant:"ghost",size:"sm",onClick:d=>{d.preventDefault(),d.stopPropagation(),r(e)},tooltip:"Delete",children:a.jsx(Gl,{})})]})]})},jl=({artifact:e,isPreview:t})=>{const{openDeleteModal:n,setPreviewArtifact:r}=Be(),{onDownload:o}=qu(),[s,i]=u.useState(!1),l=()=>{t&&r(null),n(e)},c=f=>{if(!f||typeof f=="object"&&Object.keys(f).length===0)return a.jsx("span",{children:"Not available"});const d=(p,m=0)=>typeof p=="string"?a.jsx("span",{children:p}):Array.isArray(p)?a.jsxs(a.Fragment,{children:["[",p.length>0&&d(p[0],m+1),p.length>1&&a.jsx("span",{children:", ..."}),"]"]}):typeof p=="object"&&p!==null?a.jsx("div",{className:`ml-${m*2} border-l pl-2`,children:Object.entries(p).map(([g,x],h)=>a.jsxs("div",{className:"text-xs",children:[a.jsxs("span",{className:"font-semibold",children:[g,":"]})," ",d(x,m+1)]},h))}):String(p);return a.jsxs("div",{className:"mt-1 space-y-0.5",children:[typeof f=="object"&&f.type&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",f.type," ",f.inferred&&a.jsx("span",{className:"text-xs",children:"(inferred)"})]}),typeof f=="object"&&f.columns&&a.jsxs("p",{children:[a.jsx("strong",{children:"Columns:"})," ",f.columns.join(", ")]}),typeof f=="object"&&f.structure&&a.jsxs("div",{children:[a.jsx("strong",{children:"Structure:"}),d(f.structure)]}),typeof f=="object"&&f.error&&a.jsxs("p",{className:"text-[var(--color-error-wMain)]",children:[a.jsx("strong",{children:"Schema Error:"})," ",f.error]}),typeof f=="string"&&a.jsx("p",{children:f})]})};return a.jsx("div",{className:`group relative w-full border-b px-4 py-3 transition-all duration-150 ${t?"":"cursor-pointer hover:bg-[var(--accent-background)]"}`,onClick:f=>{f.stopPropagation(),r(e)},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),f.stopPropagation(),r(e))},tabIndex:0,role:"button","aria-expanded":s,children:a.jsxs("div",{className:"flex items-start space-x-2",children:[a.jsx("div",{className:"flex-shrink-0 pt-0.5",children:hf(e,"h-4 w-4 flex-shrink-0")}),a.jsxs("div",{className:"min-w-0 flex-grow",children:[a.jsx(AC,{artifactInfo:e,isExpanded:s,onDelete:l,onDownload:o,setIsExpanded:i,isPreview:t}),s&&a.jsxs("div",{className:"text-xs",children:[a.jsx("div",{className:"mt-1 text-xs break-words whitespace-pre-wrap italic",children:e.description||"No description."}),a.jsxs("div",{className:"mt-2 space-y-1 pt-2",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Size: "}),pc(e.size)]}),e.uri&&a.jsxs("div",{children:[a.jsx("strong",{children:"URI: "}),a.jsx("span",{className:"break-all",children:e.uri||"None"})]}),e.schema&&a.jsx("div",{children:c(e.schema)})]})]})]})]})})},NC=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=Be();return!e||!t?null:a.jsx(Go,{open:e,onOpenChange:n,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsxs(Ko,{className:"flex flex-row gap-1 max-w-[400px]",children:["Delete",a.jsx("span",{className:"inline-block truncate",title:t.filename,children:a.jsx("code",{children:t.filename})}),"?"]}),a.jsx(qo,{className:"flex flex-col gap-2",children:a.jsx("div",{children:"This file will be permanently deleted. "})})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(ve,{variant:"outline",onClick:n,children:"Cancel"}),a.jsx(ve,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})})},kC={replace:e=>{e instanceof Hp.Element&&e.attribs&&e.name==="a"&&(e.attribs.target="_blank",e.attribs.rel="noopener noreferrer")}};function or({children:e,className:t}){if(!e)return null;try{const n=Bp.parse(e,{gfm:!0}),r=Ef.sanitize(n,{USE_PROFILES:{html:!0}}),o=Up(r,kC);return a.jsx("div",{className:Ta(t),children:o})}catch{return a.jsx("div",{className:Ta(t),children:e})}}const _C=Tn("flex items-center gap-3 px-4 py-3 text-sm font-medium transition-all border-l-4 border-solid ",{variants:{variant:{error:"bg-[var(--color-error-w10)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-error-w10)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-warning-w10)]",info:"bg-[var(--color-info-w10)] text-[var(--color-info-wMain)] border-[var(--color-info-w10)] dark:bg-[var(--color-info-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-info-w10)]",success:"bg-[var(--color-success-w10)] text-[var(--color-success-wMain)] border-[var(--color-success-w10)] dark:bg-[var(--color-success-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-success-w10)]"}},defaultVariants:{variant:"error"}}),IC={error:gi,warning:Wp,info:vi,success:Vl};function ra({className:e,variant:t="error",message:n,dismissible:r=!1,onDismiss:o,...s}){const i=IC[t||"error"];return a.jsxs("div",{className:Se(_C({variant:t,className:e})),role:"alert","aria-live":"polite",...s,children:[a.jsx(i,{className:"size-5 shrink-0"}),a.jsx("span",{className:"flex-1",children:n}),r&&o&&a.jsx(ve,{variant:"ghost",onClick:o,"aria-label":"Dismiss",children:a.jsx(Ro,{className:"size-3"})})]})}const jC=({artifact:e,message:t})=>{const{onDownload:n}=qu();return a.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-4",children:[a.jsx("div",{className:"mb-1 font-semibold",children:"Preview Coming Soon"}),a.jsx("div",{children:t}),a.jsx("div",{className:"mb-4",children:"Download file to view."}),a.jsxs(ve,{onClick:()=>n(e),children:[a.jsx(xi,{className:"h-4 w-4"}),"Download"]})]})},Ds=({children:e})=>a.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),MC=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n}=Be(),r=u.useMemo(()=>gb(e),[e]),[o,s]=u.useState(!1),[i,l]=u.useState(null);if(u.useEffect(()=>{s(!1),l(null)},[e]),u.useEffect(()=>{async function d(){try{s(!0),l(null),await t(e.filename)}catch(p){console.error("Error fetching artifact content:",p),l(p instanceof Error?p.message:"Failed to load artifact content")}finally{s(!1)}}r!=null&&r.canPreview&&d()},[e,t,r]),i)return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(ra,{variant:"error",message:"Error rendering preview"}),a.jsx(Ds,{children:"No preview available"})]});if(o)return a.jsx(Ds,{children:a.jsx(hi,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!r.canPreview)return a.jsx(jC,{artifact:e,message:r.reason??""});const c=qr(e.filename,e.mime_type),f=mb(n);return!c||!f?a.jsx(Ds,{children:"No preview available"}):a.jsx(pp,{content:f,rendererType:c,mime_type:n==null?void 0:n.mime_type,setRenderError:l})},Xt={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},RC=e=>{switch(e){case Xt.NameAsc:return"Name (A-Z)";case Xt.NameDesc:return"Name (Z-A)";case Xt.DateAsc:return"Date (oldest first)";case Xt.DateDesc:return"Date (newest first)"}},PC=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values(Xt).map(o=>({id:o,label:RC(o),onClick:()=>t(o),icon:e===o?a.jsx(mi,{}):void 0,iconPosition:"right"}));return a.jsxs(cd,{children:[a.jsx(ud,{asChild:!0,children:n}),a.jsx(dd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Yi,{actions:r})})]})},LC=({children:e})=>{const{artifactsRefetch:t,setIsBatchDeleteModalOpen:n}=Be(),r=[{id:"refreshAll",label:"Refresh",onClick:()=>{t()},icon:a.jsx(Yl,{}),iconPosition:"left"},{id:"deleteAll",label:"Delete All",onClick:()=>{n(!0)},icon:a.jsx(Gl,{}),iconPosition:"left",divider:!0}];return a.jsxs(cd,{children:[a.jsx(ud,{asChild:!0,children:e}),a.jsx(dd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Yi,{actions:r})})]})},DC=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:o}=Be();return u.useEffect(()=>{t&&o(new Set(e.map(s=>s.filename)))},[e,t,o]),t?a.jsx(Go,{open:t,onOpenChange:n,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsx(Ko,{children:"Delete All?"}),a.jsxs(qo,{children:[e.length===1?"One file":`All ${e.length} files`," will be permanently deleted."]})]}),a.jsxs("div",{className:"flex justify-end space-x-2",children:[a.jsx(ve,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),a.jsx(ve,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})}):null},OC={[Xt.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[Xt.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[Xt.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[Xt.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},FC=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r}=Be(),[o,s]=u.useState(Xt.DateDesc),i=u.useMemo(()=>t?[]:e?[...e].sort(OC[o]):[],[e,t,o]),l=u.useMemo(()=>n?a.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[a.jsx(ve,{variant:"ghost",onClick:()=>r(null),children:a.jsx(Gp,{})}),a.jsx("div",{className:"text-md font-semibold",children:"Preview"})]}):i.length>0&&a.jsxs("div",{className:"flex items-center justify-end border-b p-2",children:[a.jsx(PC,{currentSortOption:o,onSortChange:s,children:a.jsxs(ve,{variant:"ghost",title:"Sort By",children:[a.jsx($l,{className:"h-5 w-5"}),a.jsx("div",{children:"Sort By"})]})},"sort-popover"),a.jsx(LC,{children:a.jsx(ve,{variant:"ghost",tooltip:"More",children:a.jsx(Vp,{className:"h-5 w-5"})})},"more-popover")]}),[n,i.length,o,r]);return a.jsxs("div",{className:"flex h-full flex-col",children:[l,a.jsxs("div",{className:"flex min-h-0 flex-1",children:[!n&&a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i.map(c=>a.jsx(jl,{artifact:c},c.filename)),i.length===0&&a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:a.jsxs("div",{className:"text-muted-foreground text-center",children:[t&&a.jsx(hi,{className:"size-6 animate-spin"}),!t&&a.jsxs(a.Fragment,{children:[a.jsx(sr,{className:"mx-auto mb-4 h-12 w-12"}),a.jsx("div",{className:"text-lg font-medium",children:"Files"}),a.jsx("div",{className:"mt-2 text-sm",children:"No files available"})]})]})})]}),n&&a.jsxs("div",{className:"flex flex-1 flex-col gap-2 min-h-0 min-w-0",children:[a.jsx(jl,{artifact:n,isPreview:!0},n.filename),a.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-y-auto",children:a.jsx(MC,{artifact:n})})]})]}),a.jsx(NC,{}),a.jsx(DC,{})]})},zC=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:o,setActiveSidePanelTab:s,setPreviewArtifact:i,taskIdInSidePanel:l}=Be(),{isReconnecting:c,isTaskMonitorConnecting:f,isTaskMonitorConnected:d,monitoredTasks:p,connectTaskMonitorStream:m}=Gi(),[g,x]=u.useState(null);u.useEffect(()=>{if(l&&p[l]){const y=p[l],E=bE(y.events||[],p,y);x(E)}else x(null)},[l,p]);const h=()=>c||f?{message:"Connecting to task monitor ...",showButton:!1}:d?l?g?null:{message:"No workflow data available for the selected task",showButton:!1}:{message:"No task selected to display",showButton:!1}:{message:"No connection to task monitor",showButton:!0,buttonText:"Reconnect",buttonIcon:Yp,buttonAction:m},v=()=>{const y=!t;n(y),e(y)},b=y=>{y==="files"&&i(null),s(y)},w=y=>{t&&(n(!1),e==null||e(!1)),b(y)};return t?a.jsxs("div",{className:"bg-background flex h-full w-full flex-col items-center border-l py-4",children:[a.jsx(ve,{variant:"ghost",size:"sm",onClick:v,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:a.jsx(da,{className:"size-5"})}),a.jsx("div",{className:"bg-border my-4 h-px w-8"}),a.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>w("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:a.jsx(sr,{className:"size-5"})}),a.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>w("workflow"),className:"h-10 w-10 p-0",tooltip:"Workflow",children:a.jsx(po,{className:"size-5"})})]}):a.jsx("div",{className:"bg-background flex h-full flex-col border-l",children:a.jsx("div",{className:"m-1 min-h-0 flex-1",children:a.jsxs($0,{value:o,onValueChange:y=>b(y),className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex gap-2 p-2",children:[a.jsx(ve,{variant:"ghost",onClick:v,className:"p-1",tooltip:"Collapse Panel",children:a.jsx(da,{className:"size-5"})}),a.jsxs(B0,{className:"grid w-full grid-cols-2 bg-transparent p-0",children:[a.jsxs(sl,{value:"files",title:"Files",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-l-md border border-r-0 data-[state=active]:z-10 data-[state=active]:border-r-0",children:[a.jsx(sr,{className:"mr-2 h-4 w-4"}),"Files"]}),a.jsxs(sl,{value:"workflow",title:"Workflow",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-r-md border border-l-0 data-[state=active]:z-10 data-[state=active]:border-l-0",children:[a.jsx(po,{className:"mr-2 h-4 w-4"}),"Workflow"]})]})]}),a.jsxs("div",{className:"min-h-0 flex-1",children:[a.jsx(il,{value:"files",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:a.jsx(FC,{})})}),a.jsx(il,{value:"workflow",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:(()=>{const y=h();return!y&&g?a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsx(UC,{task:g}),a.jsx(wE,{processedSteps:g.steps||[],isRightPanelVisible:!1,isSidePanelTransitioning:r})]}):a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:a.jsxs("div",{className:"text-muted-foreground text-center",children:[a.jsx(po,{className:"mx-auto mb-4 h-12 w-12"}),a.jsx("div",{className:"text-lg font-medium",children:"Workflow"}),a.jsx("div",{className:"mt-2 text-sm",children:y==null?void 0:y.message}),(y==null?void 0:y.showButton)&&a.jsx("div",{className:"mt-4",children:a.jsxs(ve,{onClick:y.buttonAction,children:[y.buttonIcon&&(()=>{const E=y.buttonIcon;return a.jsx(E,{className:"h-4 w-4"})})(),y.buttonText]})})]})})})()})})]})]})})})},ai=({statusText:e,onViewWorkflow:t})=>a.jsxs("div",{className:"flex h-8 items-center space-x-3 py-1",children:[t?a.jsx(qc,{onClick:t}):a.jsx(K0,{className:"ml-2 mr-3"}),a.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:e&&a.jsx("span",{className:"text-muted-foreground animate-pulse truncate text-sm",title:e,children:e})})]}),hp=({isOpen:e,onClose:t})=>{const{handleNewSession:n}=Be(),{persistenceEnabled:r}=nn();return a.jsx(Go,{open:e,onOpenChange:t,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsx(Ko,{className:"flex flex-row gap-1 max-w-[400px]",children:r===!1?"New Chat Session?":"Start New Chat Session?"}),a.jsx(qo,{className:"flex flex-col gap-2",children:r===!1?"Starting a new chat session will clear the current chat history and files. Are you sure you want to proceed?":"This will create a new chat session. Your current chat will be saved in the sessions panel."})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(ve,{variant:"outline",onClick:t,children:"Cancel"}),a.jsx(ve,{variant:"default",onClick:()=>{n(),t()},children:"Start New Chat"})]})]})})},$C=({onToggle:e})=>{const[t,n]=u.useState(!1);return a.jsxs("div",{className:"bg-background flex h-full w-100 flex-col border-r",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 pt-[35px] pb-3",children:[a.jsx(ve,{variant:"ghost",onClick:e,className:"p-2",tooltip:"Collapse Sessions Panel",children:a.jsx(Kl,{className:"size-5"})}),a.jsxs(ve,{variant:"ghost",onClick:()=>n(!0),tooltip:"Start New Chat Session",children:[a.jsx(ql,{className:"size-5"}),"New chat"]})]}),a.jsx("div",{className:"mt-1 min-h-0 flex-1",children:a.jsx(TC,{})}),a.jsx(hp,{isOpen:t,onClose:()=>n(!1)})]})},Nr=(e,t)=>a.jsx(df,{type:t,className:"rounded-full border-none",children:a.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),BC=(e,t)=>{var r;if(e.currentStatusText)return a.jsx("div",{title:e.currentStatusText,children:a.jsx(ai,{statusText:e.currentStatusText})});const n=(r=t==null?void 0:t.parts)==null?void 0:r.filter(o=>o.kind==="text").map(o=>o.text).join("");switch(e.status){case"submitted":case"working":return a.jsx("div",{title:n||e.status,children:a.jsx(ai,{statusText:n||e.status})});case"input-required":return Nr("Input Required","info");case"completed":return Nr("Completed","success");case"canceled":return Nr("Canceled","info");case"failed":return Nr("Failed","error");default:return Nr("Unknown","info")}},UC=({task:e})=>{const{messages:t}=Be(),n=u.useMemo(()=>{const r=t.find(o=>o.isStatusBubble);return e?BC(e,r):null},[t,e]);return e?a.jsxs("div",{className:"grid grid-cols-[auto_1fr] grid-rows-[32px_32px] gap-x-8 border-b p-4 leading-[32px]",children:[a.jsx("div",{className:"text-muted-foreground",children:"User"}),a.jsx("div",{className:"truncate",title:e.initialRequestText,children:e.initialRequestText}),a.jsx("div",{className:"text-muted-foreground",children:"Status"}),a.jsx("div",{className:"truncate",children:n})]}):null};class gp{getEdgeAnimationState(t,n,r){const o=r.find(l=>l.id===t);if(!o)return{isAnimated:!1,animationType:"static"};if(!this.isAgentToToolRequest(o))return{isAnimated:!1,animationType:"static"};const s=r.slice(0,n+1);return this.hasMatchingResponse(o,s)?{isAnimated:!1,animationType:"static"}:{isAnimated:!0,animationType:"request"}}isAgentToToolRequest(t){var n,r;switch(t.type){case"AGENT_LLM_CALL":return!0;case"AGENT_TOOL_INVOCATION_START":return!(((n=t.data.toolDecision)==null?void 0:n.isPeerDelegation)||((r=t.data.toolInvocationStart)==null?void 0:r.isPeerInvocation)||t.target&&t.target.startsWith("peer_"));default:return!1}}hasMatchingResponse(t,n){switch(t.type){case"AGENT_LLM_CALL":return this.hasLLMResponse(t,n);case"AGENT_TOOL_INVOCATION_START":return this.hasToolResponse(t,n);default:return!1}}hasLLMResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.source;return n.some(s=>{var d;if(new Date(s.timestamp).getTime()<r)return!1;const l=(s.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||s.type==="AGENT_LLM_RESPONSE_TO_AGENT")&&s.target===o,c=s.source===o&&(s.type==="AGENT_TOOL_INVOCATION_START"||s.type==="TASK_COMPLETED"),f=s.type==="AGENT_TOOL_EXECUTION_RESULT"&&((d=s.data.toolResult)==null?void 0:d.isPeerResponse);return l||c||f})}hasToolResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.target,s=t.source;return n.some(i=>new Date(i.timestamp).getTime()<r?!1:i.type==="AGENT_TOOL_EXECUTION_RESULT"&&i.source===o&&i.target===s)}isRequestStep(t){return this.isAgentToToolRequest(t)}isResponseStep(t){return["AGENT_TOOL_EXECUTION_RESULT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_LLM_RESPONSE_TO_AGENT"].includes(t.type)}}const un={USER:50,MAIN_FLOW:300,TOOLS:600},HC=50,Ke=50,_t=330,Bn=50,Yt=20,ur=10,Ml=Ke+20,WC=90;function Un(e,t,n){return e.push(n),t.add(n.id),n}function GC(e,t){return e.push(t),t}function Hn(e,t){return e.nodeIdCounter++,`${t.replace(/[^a-zA-Z0-9_]/g,"_")}_${e.nodeIdCounter}`}function dt(e){return e.currentPhaseIndex===-1||e.currentPhaseIndex>=e.phases.length?null:e.phases[e.currentPhaseIndex]}function Xr(e){const t=dt(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function VC(e,t,n){var r;for(let o=e.length-1;o>=0;o--){const s=e[o],i=n.find(l=>l.id===s.id);if(((r=i==null?void 0:i.data)==null?void 0:r.toolName)===t)return s}return null}function YC(e,t){if(!t)return null;const n=dt(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function KC(e,t){if(!t)return null;const n=dt(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function as(e,t){var o;const n=dt(e);if(!n)return null;if(t.functionCallId){const s=YC(e,t.functionCallId);if(s)return s}if(t.owningTaskId&&t.isSubTaskStep){const s=KC(e,t.owningTaskId);if(s){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return s}}const r=Xr(e);if(r&&t.source){const s=t.source.replace(/[^a-zA-Z0-9_]/g,"_"),i=(o=t.target)==null?void 0:o.replace(/[^a-zA-Z0-9_]/g,"_"),l=r.peerAgent.id;if(l.includes(s)||i&&l.includes(i))return r}return r||null}function xp(e,t){var r,o,s;if(((r=e.data.toolDecision)==null?void 0:r.isParallel)===!0)return!0;const n=(s=(o=e.data)==null?void 0:o.toolInvocationStart)==null?void 0:s.functionCallId;return n?Array.from(t.parallelFlows.values()).some(i=>i.subflowFunctionCallIds.includes(n)):!1}function vp(e,t,n,r){var o;if(r)for(let s=e.length-1;s>=0;s--){const i=e[s];if(i.functionCallId===r){const l=n.find(c=>c.id===i.id);if(((o=l==null?void 0:l.data)==null?void 0:o.toolName)===t||t==="LLM")return i}}return VC(e,t,n)}function qC(e,t,n){const r=dt(e);if(!r)return null;const o=t.replace(/[^a-zA-Z0-9_]/g,"_"),s=n==null?void 0:n.replace(/[^a-zA-Z0-9_]/g,"_");let i=null;for(const l of r.subflows)if(l.peerAgent.id.includes(o)||s&&l.peerAgent.id.includes(s)){i=l;break}if(!i)return null;if(i.isParallel)return i;if(i.parentSubflowId){const l=r.subflows.find(c=>c.id===i.parentSubflowId);if(l&&l.isParallel)return l;if(l)return wp(r,l)}return null}function wp(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return wp(e,n)}return null}function dr(e,t,n,r){const o=`phase_${e.phases.length}`,s=Hn(e,`${t}_${o}`),i=e.nextAvailableGlobalY,l={id:s,type:"orchestratorNode",position:{x:un.MAIN_FLOW,y:i},data:{label:t,visualizerStepId:n.id}};Un(r,e.allCreatedNodeIds,l),e.nodePositions.set(s,l.position);const c={id:s,yPosition:i,height:Ke,width:_t},f={id:s,name:t,type:"orchestrator",phaseId:o,context:"main",nodeInstance:c};e.agentRegistry.registerAgent(f);const d={id:o,orchestratorAgent:c,userNodes:[],subflows:[],toolInstances:[],currentToolYOffset:0,maxY:i+Ke};return e.phases.push(d),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=d.maxY+Bn,d}function li(e,t,n,r,o){var Y,Z,G,q,te;const s=dt(e);if(!s)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((Y=n.data.toolResult)==null?void 0:Y.isPeerResponse)===!0,l=n.source||"",c=n.target||"",f=fr(l);!i&&!f&&!o&&e.indentationLevel++;const d=((G=(Z=n.delegationInfo)==null?void 0:Z[0])==null?void 0:G.subTaskId)||n.owningTaskId,p=Hn(e,`${t}_${d}`),m=Hn(e,`group_${t}_${d}`),g=((te=(q=n.data)==null?void 0:q.toolInvocationStart)==null?void 0:te.functionCallId)||n.functionCallId||"";let x,h,v;const b=Array.from(e.parallelFlows.values()).find(D=>D.subflowFunctionCallIds.includes(g)),w=Xr(e),y=qC(e,l,c);o&&b?(x=b.startX+b.currentXOffset,h=b.startY,v=h+Yt,b.currentXOffset+=(_t+ur)*2.2):y?(v=e.nextAvailableGlobalY,x=(y.groupNode.xPosition||un.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,h=v-Yt):(v=e.nextAvailableGlobalY,x=un.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,h=v-Yt);const E={id:p,type:"genericAgentNode",position:{x:50,y:Yt},data:{label:t,visualizerStepId:n.id},parentId:m},k={id:m,type:"group",position:{x,y:h},data:{label:`${t} Sub-flow`},style:{backgroundColor:"rgba(220, 220, 255, 0.1)",border:"1px solid #aac",borderRadius:"8px",minHeight:`${Ke+2*Yt}px`}};Un(r,e.allCreatedNodeIds,k),Un(r,e.allCreatedNodeIds,E),e.nodePositions.set(p,E.position),e.nodePositions.set(m,k.position);const I={id:p,xPosition:un.MAIN_FLOW,yPosition:v,height:Ke,width:_t},A={id:p,name:t,type:"peer",phaseId:s.id,subflowId:d,context:"subflow",nodeInstance:I};e.agentRegistry.registerAgent(A);const T={id:d,functionCallId:g,isParallel:o,peerAgent:I,groupNode:{id:m,xPosition:x,yPosition:h,height:Ke+2*Yt,width:0},toolInstances:[],currentToolYOffset:0,maxY:v+Ke,maxContentXRelative:E.position.x+_t,callingPhaseId:s.id,parentSubflowId:w==null?void 0:w.id,inheritedXOffset:y==null?void 0:y.groupNode.xPosition};return s.subflows.push(T),y&&(y.lastSubflow=T),e.currentSubflowIndex=s.subflows.length-1,o&&b?(b.maxHeight=Math.max(b.maxHeight,T.groupNode.height),e.nextAvailableGlobalY=b.startY+b.maxHeight+Bn):e.nextAvailableGlobalY=T.groupNode.yPosition+T.groupNode.height+Bn,T}function bp(e,t,n,r,o,s,i=!1){const l=dt(e);if(!l)return null;const c=s?s.toolInstances:l.toolInstances,f=i?"LLM":`Tool: ${t}`,d=i?"LLM":t,p=s?s.groupNode.id:void 0;let m,g,x,h;if(s){if(m=s.peerAgent.yPosition+s.currentToolYOffset,s.currentToolYOffset+=Ml,x=50+300,s.groupNode.xPosition===void 0||s.groupNode.yPosition===void 0)return null;g=s.groupNode.xPosition+x,h=m-s.groupNode.yPosition}else g=un.TOOLS,m=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=Ml,x=g,h=m;const v=Hn(e,`${d}_${r.id}`),b={id:v,type:n,position:{x,y:h},data:{label:f,visualizerStepId:r.id,toolName:t},parentId:p};Un(o,e.allCreatedNodeIds,b),e.nodePositions.set(v,{x,y:h});const w={id:v,xPosition:g,yPosition:m,height:Ke,width:_t,functionCallId:r.functionCallId};c.push(w);const y=m+Ke;if(s){s.maxY=Math.max(s.maxY,y),s.maxContentXRelative=Math.max(s.maxContentXRelative,x+_t);const E=s.maxY-s.groupNode.yPosition+Yt;s.groupNode.height=Math.max(s.groupNode.height,E);const k=s.maxContentXRelative+ur;s.groupNode.width=Math.max(s.groupNode.width||0,k);const I=o.find(A=>A.id===s.groupNode.id);I&&(I.style={...I.style,height:`${s.groupNode.height}px`,width:`${s.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,s.groupNode.yPosition+s.groupNode.height+Bn)}else l.maxY=Math.max(l.maxY,y),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+Bn);return w}function oa(e,t,n,r){e.userNodeCounter++;const o=Hn(e,`User_response_${e.userNodeCounter}`),s=e.nextAvailableGlobalY+20,i={id:o,type:"userNode",position:{x:un.USER,y:s},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};Un(r,e.allCreatedNodeIds,i),e.nodePositions.set(o,i.position);const l={id:o,yPosition:s,height:Ke,width:_t};t.userNodes.push(l),e.allUserNodes.push(l);const c=s+Ke;return t.maxY=Math.max(t.maxY,c),l}function yt(e,t,n,r,o,s,i,l,c){if(!e||!t||e===t)return;const f=o.allCreatedNodeIds.has(e),d=o.allCreatedNodeIds.has(t);if(!f||!d)return;const p=`edge-${e}${l||""}-to-${t}${c||""}-${n.id}`;if(!r.some(g=>g.id===p)){const g=n.title&&n.title.length>30?n.type.replace(/_/g," ").toLowerCase():n.title||"",x=s.isRequestStep(n),h={id:p,source:e,target:t,label:g,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:x,animationType:x?"request":"static",duration:1}};l&&(h.sourceHandle=l),c&&(h.targetHandle=c),GC(r,h)}}function XC(){const e=new Map;return{agents:e,findAgentByName(t){const n=t.startsWith("peer_")?t.substring(5):t,r=[];for(const[,o]of e)(o.name===n||o.name===t)&&r.push(o);return r.length===0?null:r.reduce((o,s)=>{const i=parseInt(o.id.split("_").pop()||"0");return parseInt(s.id.split("_").pop()||"0")>i?s:o})},findAgentById(t){for(const[,n]of e)if(n.id===t)return n;return null},registerAgent(t){e.set(t.id,t)}}}function ci(e,t,n){return e==="orchestrator"?t==="output"?n==="bottom"?"orch-bottom-output":"orch-right-output-tools":n==="top"?"orch-top-input":"orch-right-input-tools":t==="output"?n==="bottom"?"peer-bottom-output":"peer-right-output-tools":n==="top"?"peer-top-input":"peer-right-input-tools"}function fr(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const ZC=["USER_REQUEST","AGENT_LLM_CALL","AGENT_LLM_RESPONSE_TO_AGENT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_TOOL_INVOCATION_START","AGENT_TOOL_EXECUTION_RESULT","AGENT_RESPONSE_TEXT","TASK_COMPLETED","TASK_FAILED"];function JC(e,t,n,r,o,s){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=dt(t),f=Xr(t);let d,p=!1;if(f?(d=f.peerAgent,d.id.startsWith(l+"_")&&(p=!0)):c&&(d=c.orchestratorAgent,d.id.startsWith(l+"_")&&(p=!0)),p&&d&&c){t.userNodeCounter++;const m=Hn(t,`User_continue_${t.userNodeCounter}`),g=t.nextAvailableGlobalY,x={id:m,type:"userNode",position:{x:un.USER,y:g},data:{label:"User",visualizerStepId:e.id}};Un(n,t.allCreatedNodeIds,x),t.nodePositions.set(m,x.position);const h={id:m,yPosition:g,height:Ke,width:_t};c.userNodes.push(h),t.allUserNodes.push(h);const v=g+Ke;d.yPosition=Math.max(d.yPosition,g),c.maxY=Math.max(c.maxY,v,d.yPosition+Ke),t.nextAvailableGlobalY=c.maxY+Bn;const b=fr(i)?"orch-left-input":"peer-left-input";yt(h.id,d.id,e,r,t,o,s,"user-right-output",b)}else{const m=dr(t,i,e,n),g=Hn(t,`User_${m.id}`),x={id:g,type:"userNode",position:{x:un.USER,y:m.orchestratorAgent.yPosition-WC},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};Un(n,t.allCreatedNodeIds,x),t.nodePositions.set(g,x.position);const h={id:g,yPosition:x.position.y,height:Ke,width:_t};m.userNodes.push(h),t.allUserNodes.push(h),t.userNodeCounter++,m.maxY=Math.max(m.maxY,x.position.y+Ke),t.nextAvailableGlobalY=m.maxY+Bn,yt(g,m.orchestratorAgent.id,e,r,t,o,s,"user-bottom-output","orch-top-input")}}function QC(e,t,n,r,o,s){const i=dt(t);if(!i)return;const l=as(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,f=bp(t,"LLM","llmNode",e,n,l,!0);f&&yt(c,f.id,e,r,t,o,s,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function eE(e,t,n,r,o,s){var x;if(e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"&&((x=e.data.toolDecision)!=null&&x.isParallel)){const h=`parallel-${e.id}`;e.data.toolDecision.decisions.filter(v=>v.isPeerDelegation).length>1&&t.parallelFlows.set(h,{subflowFunctionCallIds:e.data.toolDecision.decisions.filter(v=>v.isPeerDelegation).map(v=>v.functionCallId),completedSubflows:new Set,startX:un.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=dt(t);if(!i)return;const l=as(t,e);let c;const d=vp((l||i).toolInstances,"LLM",n,e.functionCallId);if(d)c=d.id;else{console.error(`[Timeline] LLM node not found for step type ${e.type}: ${e.id}. Cannot create edge.`);return}const p=e.target||"UnknownAgent";let m,g;l?(m=l.peerAgent.id,g="peer-right-input-tools"):i.orchestratorAgent.id.startsWith(p.replace(/[^a-zA-Z0-9_]/g,"_")+"_")&&(m=i.orchestratorAgent.id,g="orch-right-input-tools"),c&&m&&g?yt(c,m,e,r,t,o,s,"llm-bottom-output",g):console.error(`[Timeline] Could not determine target agent node ID or handle for step type ${e.type}: ${e.id}. Target agent name: ${p}. Edge will be missing.`)}function tE(e,t,n,r,o,s){var d;const i=dt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"UnknownTool";if(((d=e.data.toolInvocationStart)==null?void 0:d.isPeerInvocation)||c.startsWith("peer_")){const p=c.startsWith("peer_")?c.substring(5):c,m=t.agentRegistry.findAgentByName(l);if(!m){console.error(`[Timeline] Could not find source agent in registry: ${l} for step ${e.id}`);return}const g=m.nodeInstance,x=ci(m.type,"output","bottom"),h=xp(e,t),v=li(t,p,e,n,h);v&&yt(g.id,v.peerAgent.id,e,r,t,o,s,x,"peer-top-input")}else{const p=as(t,e);let m,g;if(p)m=p.peerAgent.id,g="peer-right-output-tools";else{const h=t.agentRegistry.findAgentByName(l);h?(m=h.id,g=ci(h.type,"output","right")):(m=i.orchestratorAgent.id,g="orch-right-output-tools")}const x=bp(t,c,"genericToolNode",e,n,p);x&&yt(m,x.id,e,r,t,o,s,g,`${x.id}-tool-left-input`)}}function nE(e,t,n,r,o,s){var f,d;const i=dt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"OrchestratorAgent";if((f=e.data.toolResult)!=null&&f.isPeerResponse){const p=(d=e.data.toolResult)==null?void 0:d.functionCallId,m=Array.from(t.parallelFlows.entries()).find(([x,h])=>h.subflowFunctionCallIds.includes(p||""));if(m){const[x,h]=m;if(h.completedSubflows.add(p||""),h.completedSubflows.size<h.subflowFunctionCallIds.length)return;const v=i.subflows.filter(E=>h.subflowFunctionCallIds.includes(E.functionCallId)),b=e.target||"OrchestratorAgent";let w,y;if(fr(b))t.indentationLevel=0,w=dr(t,b,e,n).orchestratorAgent,y="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const E=li(t,b,e,n,!1);if(!E)return;w=E.peerAgent,y="peer-top-input"}v.forEach(E=>{var k;yt(((k=E.lastSubflow)==null?void 0:k.peerAgent.id)??E.peerAgent.id,w.id,e,r,t,o,s,"peer-bottom-output",y)}),t.parallelFlows.delete(x);return}const g=t.agentRegistry.findAgentByName(l.startsWith("peer_")?l.substring(5):l);if(!g){console.error(`[Timeline] Source peer agent not found for peer response: ${l}.`);return}if(fr(c)){t.indentationLevel=0;const x=dr(t,c,e,n);yt(g.id,x.orchestratorAgent.id,e,r,t,o,s,"peer-bottom-output","orch-top-input"),t.currentSubflowIndex=-1}else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const x=xp(e,t)||Array.from(t.parallelFlows.values()).some(v=>v.subflowFunctionCallIds.some(b=>i.subflows.some(w=>w.functionCallId===b))),h=li(t,c,e,n,x);h&&yt(g.id,h.peerAgent.id,e,r,t,o,s,"peer-bottom-output","peer-top-input")}}else{let p;const m=as(t,e),x=vp((m||i).toolInstances,l,n,e.functionCallId);if(x&&(p=x.id),p){let h,v;if(m)h=m.peerAgent.id,v="peer-right-input-tools";else{const b=t.agentRegistry.findAgentByName(c);b?(h=b.id,v=ci(b.type,"input","right")):(h=i.orchestratorAgent.id,v="orch-right-input-tools")}yt(p,h,e,r,t,o,s,l==="LLM"?"llm-bottom-output":`${p}-tool-bottom-output`,v)}else console.error(`[Timeline] Could not find source tool node for regular tool result: ${e.id}. Step source (tool name): ${l}.`)}}function rE(e,t,n,r,o,s){const i=dt(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=oa(t,i,e,n);yt(l,c.id,e,r,t,o,s,"orch-bottom-output","user-top-input")}function oE(e,t,n,r,o,s){const i=dt(t);if(!i)return;const l=Array.from(t.parallelFlows.values()).find(g=>g.subflowFunctionCallIds.includes(e.functionCallId||""));if(l){if(l.completedSubflows.add(e.functionCallId||""),l.completedSubflows.size===l.subflowFunctionCallIds.length){t.indentationLevel=0;const g=dr(t,"OrchestratorAgent",e,n);i.subflows.forEach(x=>{l.subflowFunctionCallIds.includes(x.functionCallId)&&yt(x.peerAgent.id,g.orchestratorAgent.id,e,r,t,o,s,"peer-bottom-output","orch-top-input")}),t.currentSubflowIndex=-1}return}if(!e.isSubTaskStep)return;const c=Xr(t);if(!c){console.warn(`[Timeline] TASK_COMPLETED with isSubTaskStep=true but no active subflow. Step ID: ${e.id}`);return}if(!i){console.error(`[Timeline] No current phase found for TASK_COMPLETED. Step ID: ${e.id}`);return}const f=c.peerAgent,d=n.some(g=>typeof g.data.label=="string"&&fr(g.data.label));let p,m;d?(t.indentationLevel=0,p=dr(t,"OrchestratorAgent",e,n).orchestratorAgent.id,m="orch-top-input"):(p=oa(t,i,e,n).id,m="user-top-input"),yt(f.id,p,e,r,t,o,s,"peer-bottom-output",m),t.currentSubflowIndex=-1}function sE(e,t,n,r){const o=dt(t);if(!o)return;const s=e.source||"UnknownSource",i=e.target||"User";let l,c="orch-bottom-output";const f=Xr(t);if(f&&f.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=f.peerAgent,c="peer-bottom-output";else if(o.orchestratorAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=o.orchestratorAgent,c="orch-bottom-output";else for(const m of o.subflows)if(m.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_"))){l=m.peerAgent,c="peer-bottom-output";break}if(!l){console.error(`[Timeline] Could not find source agent node for TASK_FAILED: ${s}`);return}let d,p;fr(i)?(t.indentationLevel=0,d=dr(t,i,e,n).orchestratorAgent.id,p="orch-top-input",t.currentSubflowIndex=-1):(d=oa(t,o,e,n).id,p="user-top-input"),iE(l.id,d,e,r,t,c,p)}function iE(e,t,n,r,o,s,i){var p;if(!e||!t||e===t)return;const l=o.allCreatedNodeIds.has(e),c=o.allCreatedNodeIds.has(t);if(!l||!c)return;const f=`error-edge-${e}${s||""}-to-${t}${i||""}-${n.id}`;if(!r.some(m=>m.id===f)){const m=((p=n.data.errorDetails)==null?void 0:p.message)||"Task failed",g=m.length>30?"Error":m,x={id:f,source:e,target:t,label:g,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:!1,animationType:"static",isError:!0,errorMessage:m}};s&&(x.sourceHandle=s),i&&(x.targetHandle=i),r.push(x)}}const aE=e=>{const t=[],n=[];if(!e||e.length===0)return{nodes:t,edges:n};const r=new gp,o={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:HC,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:XC(),indentationLevel:0,indentationStep:50},s=e.filter(c=>ZC.includes(c.type)),i=s.findIndex(c=>c.type==="USER_REQUEST");let l=s;i>0&&(l=[s[i],...s.slice(0,i),...s.slice(i+1)]);for(const c of l)switch(c.type){case"USER_REQUEST":JC(c,o,t,n,r,e);break;case"AGENT_LLM_CALL":QC(c,o,t,n,r,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":eE(c,o,t,n,r,e);break;case"AGENT_TOOL_INVOCATION_START":tE(c,o,t,n,r,e);break;case"AGENT_TOOL_EXECUTION_RESULT":nE(c,o,t,n,r,e);break;case"AGENT_RESPONSE_TEXT":rE(c,o,t,n,r,e);break;case"TASK_COMPLETED":oE(c,o,t,n,r,e);break;case"TASK_FAILED":sE(c,o,t,n);break}return o.phases.forEach(c=>{c.subflows.forEach(f=>{const d=t.find(p=>p.id===f.groupNode.id);if(d&&d.style){const m=f.maxY-f.groupNode.yPosition+Yt;d.style.height=`${Math.max(Ke+2*Yt,m)}px`;const g=f.maxContentXRelative+ur,x=_t+2*ur+o.indentationLevel*o.indentationStep;d.style.width=`${Math.max(g,x)}px`}})}),{nodes:t,edges:n}},lE=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,style:l={},markerEnd:c,data:f})=>{const[d,p]=u.useState(!1),[m]=Kp({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i}),g=()=>{const v={strokeWidth:d?3:2,stroke:"var(--color-muted-foreground)",...l},b=f;return b!=null&&b.isError?{...v,stroke:d?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:d?3:2}:b!=null&&b.isSelected?{...v,stroke:"#3b82f6",strokeWidth:3}:b!=null&&b.isAnimated?{...v,stroke:d?"#1d4ed8":"#3b82f6",strokeWidth:d?4:3}:d?{...v,stroke:"var(--edge-hover-color)"}:v},x=()=>p(!0),h=()=>p(!1);return a.jsxs(a.Fragment,{children:[a.jsx("path",{id:`${e}-interaction`,style:{strokeWidth:16,stroke:"transparent",fill:"none",cursor:"pointer"},className:"react-flow__edge-interaction",d:m,onMouseEnter:x,onMouseLeave:h}),a.jsx("path",{id:e,style:{...g(),cursor:"pointer",transition:"all 0.2s ease-in-out"},className:"react-flow__edge-path",d:m,markerEnd:c,onMouseEnter:x,onMouseLeave:h})]})},cE=({data:e})=>a.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-blue-700 bg-white px-5 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-blue-600 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"180px",textAlign:"center"},children:[a.jsx(Xe,{type:"target",position:Ze.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Xe,{type:"source",position:Ze.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),a.jsx(Xe,{type:"source",position:Ze.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Left,id:"peer-left-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("div",{className:"text-md font-semibold",children:e.label})})]}),uE=({data:e,id:t})=>{const n=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-cyan-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-cyan-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-cyan-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[a.jsx(Xe,{type:"target",position:Ze.Left,id:`${t}-tool-left-input`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"25%"}}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${n()}`}),a.jsx("div",{className:"text-md",children:e.label})]}),a.jsx(Xe,{type:"source",position:Ze.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}})]})},dE=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-teal-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-teal-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-teal-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[a.jsx(Xe,{type:"target",position:Ze.Left,id:"llm-left-input",className:"!bg-teal-500",isConnectable:!0,style:{top:"25%"}}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${t()}`}),a.jsx("div",{className:"text-md",children:e.label})]}),a.jsx(Xe,{type:"source",position:Ze.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},fE=({data:e})=>a.jsxs("div",{className:"cursor-pointer rounded-lg border-indigo-600 bg-gradient-to-r from-indigo-50 to-purple-50 px-5 py-3 text-gray-900 shadow-xl transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-2xl dark:border-indigo-400 dark:bg-gradient-to-r dark:from-indigo-900 dark:to-purple-900 dark:text-gray-100",style:{minWidth:"180px",textAlign:"center",borderWidth:"2px",borderStyle:"solid",boxShadow:"0 0 0 1px rgba(79, 70, 229, 0.3), 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},children:[a.jsx(Xe,{type:"source",position:Ze.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Xe,{type:"source",position:Ze.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Left,id:"orch-left-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("div",{className:"text-md flex items-center font-bold",children:e.label})})]}),pE=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-purple-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-purple-600 bg-white px-4 py-3 text-gray-800 shadow-lg transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-purple-400 dark:bg-gray-700 dark:text-gray-200",style:{minWidth:"120px",textAlign:"center"},children:[e.isTopNode&&a.jsx(Xe,{type:"source",position:Ze.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&a.jsx(Xe,{type:"target",position:Ze.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&a.jsx(Xe,{type:"source",position:Ze.Right,id:"user-right-output",className:"!bg-gray-500",isConnectable:!0}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-3 w-3 rounded-full ${t()}`}),a.jsx("div",{className:"text-sm font-bold",children:e.label})]})]})},mE=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const o=()=>{var w,y,E;switch(e.type){case"USER_REQUEST":return a.jsx(Jp,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return a.jsx(cs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return a.jsx(Vl,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return a.jsx(Zp,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return a.jsx(cs,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return a.jsx(cs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const k=(y=(w=e.data.toolDecision)==null?void 0:w.decisions)==null?void 0:y[0];return(k==null?void 0:k.isPeerDelegation)?a.jsx(fa,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):a.jsx(pa,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18})}case"AGENT_TOOL_INVOCATION_START":return(E=e.data.toolInvocationStart)!=null&&E.isPeerInvocation?a.jsx(fa,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):a.jsx(pa,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return a.jsx(Xp,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return a.jsx(sr,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return a.jsx(qp,{className:"mr-2 text-gray-500 dark:text-gray-400",size:18})}},s=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),i=String(new Date(e.timestamp).getMilliseconds()).padStart(3,"0"),l=`${s}.${i}`,c=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Model:"})," ",w.modelName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Prompt Preview:"})}),a.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:w.promptPreview})]}),f=({data:w})=>{const[y,E]=Ft.useState(!1),k=I=>{I.stopPropagation(),E(!y)};return y?a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[a.jsx("strong",{children:"LLM Response Details:"}),a.jsx("button",{onClick:k,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Hide details"})]}),w.modelName&&a.jsxs("p",{children:[a.jsx("strong",{children:"Model:"})," ",w.modelName]}),a.jsxs("div",{className:"mt-1",children:[a.jsx("p",{children:a.jsx("strong",{children:"Response Preview:"})}),a.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:w.responsePreview})]}),w.isFinalResponse!==void 0&&a.jsxs("p",{className:"mt-1",children:[a.jsx("strong",{children:"Final Response:"})," ",w.isFinalResponse?"Yes":"No"]})]}):a.jsxs("div",{className:"mt-1.5 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[a.jsx("span",{className:"italic",children:"Internal LLM response"}),a.jsx("button",{onClick:k,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},d=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-blue-50 p-2 font-mono text-xs text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:[a.jsx("p",{className:"mb-2",children:a.jsxs("strong",{children:["🔧 ",w.isParallel?"Parallel Tool Calls:":"Tool Call:"]})}),a.jsx("ul",{className:"space-y-1 pl-2",children:w.decisions.map(y=>a.jsxs("li",{className:"flex items-center",children:[a.jsx("span",{className:"mr-2",children:"•"}),a.jsx("code",{children:y.toolName})]},y.functionCallId))})]}),p=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Tool:"})," ",w.toolName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Arguments:"})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:a.jsx(fi,{data:w.toolArguments})})]}),m=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Tool:"})," ",w.toolName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Result:"})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:typeof w.resultData=="object"?a.jsx(fi,{data:w.resultData}):a.jsx("pre",{className:"font-mono text-xs break-all whitespace-pre-wrap",children:String(w.resultData)})})]}),g=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Artifact:"})," ",w.artifactName,w.version!==void 0&&a.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" (v",w.version,")"]})]}),w.mimeType&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",w.mimeType]}),w.description&&a.jsxs("p",{className:"mt-1",children:[a.jsx("strong",{children:"Description:"})," ",w.description]})]}),x=r==="list"&&e.nestingLevel&&e.nestingLevel>0?{marginLeft:`${e.nestingLevel*24}px`}:{},h=r==="popover"?`
330
330
  p-3 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors duration-150
331
331
  ${n?"cursor-pointer":""}
332
332
  `:`
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/assets/favicon-BLgzUch9.ico" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Solace Agent Mesh</title>
8
- <script type="module" crossorigin src="/assets/main-Dq4AJNvn.js"></script>
8
+ <script type="module" crossorigin src="/assets/main-B6BpuH9K.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/vendor-CS5YMf8a.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/client-B9p_nFNA.js">
11
11
  <link rel="stylesheet" crossorigin href="/assets/main-B9s_V9tJ.css">
@@ -33,7 +33,7 @@ class BaseIdentityService(ABC):
33
33
 
34
34
  @abstractmethod
35
35
  async def get_user_profile(
36
- self, auth_claims: Dict[str, Any]
36
+ self, auth_claims: Dict[str, Any], **kwargs: Any
37
37
  ) -> Optional[Dict[str, Any]]:
38
38
  """
39
39
  Fetches additional profile details for an already authenticated user.
@@ -42,6 +42,7 @@ class BaseIdentityService(ABC):
42
42
  auth_claims: A dictionary of claims from the primary authentication
43
43
  system (e.g., decoded JWT, session data). It's guaranteed
44
44
  to contain at least a primary user identifier.
45
+ kwargs: Optional additional parameters for provider-specific logic.
45
46
 
46
47
  Returns:
47
48
  A dictionary containing additional user details (e.g., title, manager)
@@ -68,7 +68,7 @@ class LocalFileIdentityService(BaseIdentityService):
68
68
  raise
69
69
 
70
70
  async def get_user_profile(
71
- self, auth_claims: Dict[str, Any]
71
+ self, auth_claims: Dict[str, Any], **kwargs: Any
72
72
  ) -> Optional[Dict[str, Any]]:
73
73
  """Looks up a user profile from the in-memory index."""
74
74
  lookup_value = auth_claims.get(self.lookup_key)
@@ -32,6 +32,10 @@ class SamConfigBase(BaseModel):
32
32
  """Provides dict-like ['key'] access."""
33
33
  return getattr(self, key)
34
34
 
35
+ def __setitem__(self, key: str, value: Any):
36
+ """Provides dict-like ['key'] = value assignment."""
37
+ setattr(self, key, value)
38
+
35
39
  def __contains__(self, key: str) -> bool:
36
40
  """
37
41
  Provides dict-like 'in' support that mimics the old behavior.
@@ -6,7 +6,7 @@ import uuid
6
6
  from abc import abstractmethod
7
7
  from typing import Any, Dict, List, Type, Optional, Literal
8
8
 
9
- from pydantic import Field
9
+ from pydantic import Field, ValidationError
10
10
  from solace_ai_connector.common.log import log
11
11
  from solace_ai_connector.common.utils import deep_merge
12
12
  from solace_ai_connector.flow.app import App
@@ -111,6 +111,17 @@ class BaseGatewayApp(App):
111
111
  code_config_app_block, yaml_app_config_block
112
112
  )
113
113
 
114
+ try:
115
+ # Validate the configuration against the base model
116
+ validated_config = BaseGatewayAppConfig.model_validate_and_clean(
117
+ resolved_app_config_block
118
+ )
119
+ # Use the validated model's dict representation
120
+ resolved_app_config_block = validated_config
121
+ except ValidationError as e:
122
+ log.error("Base Gateway configuration validation failed:\n%s", e)
123
+ raise ValueError(f"Invalid Base Gateway configuration: {e}") from e
124
+
114
125
  self.namespace: str = resolved_app_config_block.get("namespace")
115
126
  if not self.namespace:
116
127
  raise ValueError(