solace-agent-mesh 1.4.8__py3-none-any.whl → 1.4.10__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.
- solace_agent_mesh/agent/adk/services.py +14 -9
- solace_agent_mesh/agent/sac/app.py +3 -3
- solace_agent_mesh/agent/utils/artifact_helpers.py +23 -7
- solace_agent_mesh/assets/docs/404.html +2 -2
- solace_agent_mesh/assets/docs/assets/js/{main.86924c42.js → main.cead6719.js} +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/Enterprise/installation/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/Enterprise/rbac-setup-guilde/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/Enterprise/single-sign-on/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-gateway-upgrade-to-0.3.0/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-technical-migration-map/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/concepts/cli/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/litellm_models/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/bedrock-agents/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/custom-agent/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/event-mesh-gateway/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mcp-integration/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mongodb-integration/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rag-integration/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rest-gateway/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/sql-database/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/artifact-management/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/audio-tools/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/data-analysis-tools/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/embeds/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-agents/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-gateways/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-python-tools/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +2 -2
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +2 -2
- solace_agent_mesh/assets/docs/lunr-index-1759415743783.json +1 -0
- solace_agent_mesh/assets/docs/lunr-index.json +1 -1
- solace_agent_mesh/assets/docs/{search-doc-1759246102819.json → search-doc-1759415743783.json} +1 -1
- solace_agent_mesh/assets/docs/search-doc.json +1 -1
- solace_agent_mesh/cli/__init__.py +1 -1
- solace_agent_mesh/cli/commands/plugin_cmd/create_cmd.py +0 -1
- solace_agent_mesh/cli/commands/plugin_cmd/plugin_cmd_llm.txt +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/{main-B0PHV3hm.js → main-DnnE01OM.js} +1 -1
- solace_agent_mesh/client/webui/frontend/static/index.html +1 -1
- solace_agent_mesh/common/constants.py +2 -0
- solace_agent_mesh/common/services/identity_service.py +1 -1
- solace_agent_mesh/common/services/providers/local_file_identity_service.py +1 -1
- solace_agent_mesh/gateway/http_sse/component.py +3 -2
- solace_agent_mesh/gateway/http_sse/main.py +1 -2
- solace_agent_mesh/templates/plugin_pyproject_template.toml +0 -1
- {solace_agent_mesh-1.4.8.dist-info → solace_agent_mesh-1.4.10.dist-info}/METADATA +1 -1
- {solace_agent_mesh-1.4.8.dist-info → solace_agent_mesh-1.4.10.dist-info}/RECORD +66 -66
- solace_agent_mesh/assets/docs/lunr-index-1759246102819.json +0 -1
- /solace_agent_mesh/assets/docs/assets/js/{main.86924c42.js.LICENSE.txt → main.cead6719.js.LICENSE.txt} +0 -0
- {solace_agent_mesh-1.4.8.dist-info → solace_agent_mesh-1.4.10.dist-info}/WHEEL +0 -0
- {solace_agent_mesh-1.4.8.dist-info → solace_agent_mesh-1.4.10.dist-info}/entry_points.txt +0 -0
- {solace_agent_mesh-1.4.8.dist-info → solace_agent_mesh-1.4.10.dist-info}/licenses/LICENSE +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.4.
|
|
1
|
+
__version__ = "1.4.10"
|
|
@@ -242,7 +242,6 @@ def create_plugin_cmd(
|
|
|
242
242
|
"__PLUGIN_DESCRIPTION__": options["description"],
|
|
243
243
|
"__PLUGIN_VERSION__": options["version"],
|
|
244
244
|
"__PLUGIN_META_DATA_TYPE__": options["type"].lower(),
|
|
245
|
-
"__SAM_VERSION__": cli_version,
|
|
246
245
|
"__COMPONENT_KEBAB_CASE_NAME__": "__COMPONENT_KEBAB_CASE_NAME__",
|
|
247
246
|
"__COMPONENT_PASCAL_CASE_NAME__": "__COMPONENT_PASCAL_CASE_NAME__",
|
|
248
247
|
"__COMPONENT_UPPER_SNAKE_CASE_NAME__": "__COMPONENT_UPPER_SNAKE_CASE_NAME__",
|
|
@@ -89,7 +89,7 @@ sam plugin create my-plugin --author-name "John Doe" --author-email "john@exampl
|
|
|
89
89
|
- `__PLUGIN_AUTHOR_EMAIL__` - Author's email
|
|
90
90
|
- `__PLUGIN_DESCRIPTION__` - Plugin description
|
|
91
91
|
- `__PLUGIN_VERSION__` - Plugin version
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
|
|
94
94
|
#### `add_plugin_component_cmd`
|
|
95
95
|
```python
|
|
@@ -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 eC(e){for(var t="",n=0,r,o=0;o<e.length;n>=65536?o+=2:o++)n=Pr(e,o),r=st[n],!r&&Hr(n)?(t+=e[o],n>=65536&&(t+=e[o+1])):t+=r||GS(n);return t}function tC(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)),(hn(e,t,l,!1,!1)||typeof l>"u"&&hn(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=o,e.dump="["+r+"]"}function Pl(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)),(hn(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&hn(e,t+1,null,!0,!0,!1,!0))&&((!r||o!=="")&&(o+=li(e,t)),e.dump&&Br===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=s,e.dump=o||"[]"}function nC(e,t,n){var r="",o=e.tag,s=Object.keys(n),i,l,c,d,f;for(i=0,l=s.length;i<l;i+=1)f="",r!==""&&(f+=", "),e.condenseFlow&&(f+='"'),c=s[i],d=n[c],e.replacer&&(d=e.replacer.call(n,c,d)),hn(e,t,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),hn(e,t,d,!1,!1)&&(f+=e.dump,r+=f));e.tag=o,e.dump="{"+r+"}"}function rC(e,t,n,r){var o="",s=e.tag,i=Object.keys(n),l,c,d,f,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+=li(e,t)),d=i[l],f=n[d],e.replacer&&(f=e.replacer.call(n,d,f)),hn(e,t+1,d,!0,!0,!0)&&(p=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,p&&(e.dump&&Br===e.dump.charCodeAt(0)?m+="?":m+="? "),m+=e.dump,p&&(m+=li(e,t)),hn(e,t+1,f,!0,p)&&(e.dump&&Br===e.dump.charCodeAt(0)?m+=":":m+=": ",m+=e.dump,o+=m));e.tag=s,e.dump=o||"{}"}function Ll(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,dp.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(fp.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 hn(e,t,n,r,o,s,i){e.tag=null,e.dump=n,Ll(e,n,!1)||Ll(e,n,!0);var l=dp.call(e.dump),c=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=l==="[object Object]"||l==="[object Array]",p,m;if(f&&(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(f&&m&&!e.usedDuplicates[p]&&(e.usedDuplicates[p]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(rC(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(nC(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?Pl(e,t-1,e.dump,o):Pl(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(tC(e,t,e.dump),m&&(e.dump="&ref_"+p+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&JS(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!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function oC(e,t){var n=[],r=[],o,s;for(ui(e,n,r),o=0,s=r.length;o<s;o+=1)t.duplicates.push(n[r[o]]);t.usedDuplicates=new Array(s)}function ui(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)ui(e[o],t,n);else for(r=Object.keys(e),o=0,s=r.length;o<s;o+=1)ui(e[r[o]],t,n)}function sC(e,t){t=t||{};var n=new YS(t);n.noRefs||oC(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),hn(n,0,r,!0,!0)?n.dump+`
|
|
329
|
-
`:""}var iC=sC,aC={dump:iC};function aa(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 lC=et,cC=Of,uC=Bf,dC=Vf,fC=Yf,pC=ra,mC=up.load,hC=up.loadAll,gC=aC.dump,xC=lt,vC={binary:Jf,float:Gf,map:$f,null:Uf,pairs:ep,set:tp,timestamp:Xf,bool:Hf,int:Wf,merge:Zf,omap:Qf,seq:zf,str:Ff},wC=aa("safeLoad","load"),bC=aa("safeLoadAll","loadAll"),yC=aa("safeDump","dump"),SC={Type:lC,Schema:cC,FAILSAFE_SCHEMA:uC,JSON_SCHEMA:dC,CORE_SCHEMA:fC,DEFAULT_SCHEMA:pC,load:mC,loadAll:hC,dump:gC,YAMLException:xC,types:vC,safeLoad:wC,safeLoadAll:bC,safeDump:yC};const CC=({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=SC.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 d={[`${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,d]}},[e,t,n]);return a.jsxs("div",{className:"bg-background relative flex h-full flex-col overflow-hidden",children:[a.jsx("div",{className:"absolute top-4 right-4 z-10",children:a.jsx(we,{onClick:()=>o(!r),title:r?"Show Structured View":"Show Raw Text",children:r?a.jsxs(a.Fragment,{children:[a.jsx(Zl,{})," Structured"]}):a.jsxs(a.Fragment,{children:[a.jsx(Jl,{})," 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(Sp,{content:s,setRenderError:n}):a.jsx(xi,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},Sp=({content:e,className:t=""})=>{const{ref:n,handleKeyDown:r}=kf();return a.jsx("div",{className:`overflow-auto p-4 ${t}`,children:a.jsx("pre",{ref:n,className:"whitespace-pre-wrap select-text focus-visible:outline-none",style:{overflowWrap:"anywhere"},tabIndex:0,onKeyDown:r,children:e})})},Cp=({content:e,rendererType:t,mime_type:n,setRenderError:r})=>{switch(t){case"csv":return a.jsx(jb,{content:e,setRenderError:r});case"mermaid":return a.jsx(ny,{content:e,setRenderError:r});case"html":return a.jsx(Rb,{content:e,setRenderError:r});case"json":case"yaml":return a.jsx(CC,{content:e,rendererType:t,setRenderError:r});case"image":return a.jsx(Mb,{content:e,mime_type:n,setRenderError:r});case"markdown":return a.jsx(Pb,{content:e,setRenderError:r});case"audio":return a.jsx(_b,{content:e,mime_type:n,setRenderError:r});default:return a.jsx(Sp,{content:e,setRenderError:r})}},EC={"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 TC(e,t){const n=EC[e]||"bin";return`embedded_file_${t+1}.${n}`}function AC(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],d=e[r.index+s.length];if(!(c==='"'&&d==='"'||c==="'"&&d==="'")&&l&&l.length>10){const f=Zr(void 0,i);f?t.push({type:f,content:l,mimeType:i,originalMatch:s}):t.push({type:"file",content:l,mimeType:i,originalMatch:s,filename:TC(i,o++)})}}return t}function NC(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 kC(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 _C(e){return!e||typeof e!="string"?[]:[...AC(e),...NC(e),...kC(e)]}const IC=["image","audio"],jC=({message:e})=>{var d;const[t,n]=u.useState(null);if(e.isStatusBubble)return null;const r=(d=e.parts)==null?void 0:d.filter(f=>f.kind==="text"),o=(r==null?void 0:r.map(f=>f.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(yi,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),a.jsx(ir,{children:s})]});const i=_C(s);if(i.length===0)return a.jsx(ir,{children:s});let l=s;const c=[];return i.forEach((f,p)=>{if(l=l.replace(f.originalMatch,""),f.type==="file"){const m={name:f.filename||"downloaded_file",content:f.content,mime_type:f.mimeType};c.push(a.jsx("div",{className:"my-2",children:a.jsx(Af,{fileAttachment:m,isEmbedded:!0})},`embedded-file-${p}`))}else if(!IC.includes(f.type)){const m=Sf(f.content);m&&c.push(a.jsx("div",{className:"my-2 h-auto w-md max-w-md",children:a.jsx(Cp,{content:m,rendererType:f.type,mime_type:f.mimeType,setRenderError:n})},`embedded-${p}`))}}),a.jsxs("div",{children:[t&&a.jsx(la,{variant:"error",message:"Error rendering preview"}),a.jsx(ir,{children:l}),c]})},Ep=({message:e,children:t,className:n})=>a.jsx("div",{className:`mt-1 space-y-1 ${e.isUser?"ml-auto":"mr-auto"} ${n}`,children:t}),RC=e=>e.uploadedFiles&&e.uploadedFiles.length>0?a.jsx(Ep,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return a.jsx(Nf,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,MC=e=>e.files&&e.files.length>0?a.jsx(Ep,{message:e,children:e.files.map((t,n)=>{var r;return a.jsx(Af,{fileAttachment:t},`file-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,PC=(e,t,n)=>{var d,f;const{openSidePanelTab:r,setTaskIdInSidePanel:o}=t;if(e.isStatusBubble)return null;const s=(d=e.parts)==null?void 0:d.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(gf,{variant:i,children:a.jsxs(xf,{variant:i,children:[s&&a.jsx(jC,{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(ar,{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(ou,{onClick:c})})]})},(f=e.metadata)==null?void 0:f.messageId)},LC=({message:e,isLastWithTaskId:t})=>{const n=He();return e?a.jsxs(a.Fragment,{children:[PC(e,n,t),RC(e),MC(e)]}):null};var di=new Map,fo=new WeakMap,Dl=0,DC=void 0;function OC(e){return e?(fo.has(e)||(Dl+=1,fo.set(e,Dl.toString())),fo.get(e)):"0"}function FC(e){return Object.keys(e).sort().filter(t=>e[t]!==void 0).map(t=>`${t}_${t==="root"?OC(e.root):e[t]}`).toString()}function zC(e){const t=FC(e);let n=di.get(t);if(!n){const r=new Map;let o;const s=new IntersectionObserver(i=>{i.forEach(l=>{var c;const d=l.isIntersecting&&o.some(f=>l.intersectionRatio>=f);e.trackVisibility&&typeof l.isVisible>"u"&&(l.isVisible=d),(c=r.get(l.target))==null||c.forEach(f=>{f(d,l)})})},e);o=s.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:s,elements:r},di.set(t,n)}return n}function $C(e,t,n={},r=DC){if(typeof window.IntersectionObserver>"u"&&r!==void 0){const c=e.getBoundingClientRect();return t(r,{isIntersecting:r,target:e,intersectionRatio:typeof n.threshold=="number"?n.threshold:0,time:0,boundingClientRect:c,intersectionRect:c,rootBounds:c}),()=>{}}const{id:o,observer:s,elements:i}=zC(n),l=i.get(e)||[];return i.has(e)||i.set(e,l),l.push(t),s.observe(e),function(){l.splice(l.indexOf(t),1),l.length===0&&(i.delete(e),s.unobserve(e)),i.size===0&&(s.disconnect(),di.delete(o))}}function BC({threshold:e,delay:t,trackVisibility:n,rootMargin:r,root:o,triggerOnce:s,skip:i,initialInView:l,fallbackInView:c,onChange:d}={}){var f;const[p,m]=u.useState(null),g=u.useRef(d),[x,h]=u.useState({inView:!!l,entry:void 0});g.current=d,u.useEffect(()=>{if(i||!p)return;let S;return S=$C(p,(E,N)=>{h({inView:E,entry:N}),g.current&&g.current(E,N),N.isIntersecting&&s&&S&&(S(),S=void 0)},{root:o,rootMargin:r,threshold:e,trackVisibility:n,delay:t},c),()=>{S&&S()}},[Array.isArray(e)?e.toString():e,p,o,r,s,i,n,c,t]);const v=(f=x.entry)==null?void 0:f.target,b=u.useRef(void 0);!p&&v&&!s&&!i&&b.current!==v&&(b.current=v,h({inView:!!l,entry:void 0}));const w=[m,x.inView,x.entry];return w.ref=w[0],w.inView=w[1],w.entry=w[2],w}const UC=()=>{const{handleSwitchSession:e,updateSessionName:t,openSessionDeleteModal:n}=He(),{configServerUrl:r}=on(),o=u.useRef(null),[s,i]=u.useState([]),[l,c]=u.useState(null),[d,f]=u.useState(""),[p,m]=u.useState(1),[g,x]=u.useState(!0),[h,v]=u.useState(!1),{ref:b,inView:w}=BC({threshold:0,triggerOnce:!1}),S=u.useCallback(async(F=1,z=!1)=>{v(!0);const Q=`${r}/api/v1/sessions?pageNumber=${F}&pageSize=20`;try{const P=await ze(Q);if(P.ok){const Y=await P.json();i(z?A=>[...A,...Y.data]:Y.data),x(Y.meta.pagination.nextPage!==null),m(F)}else console.error(`Failed to fetch sessions: ${P.status} ${P.statusText}`)}catch(P){console.error("An error occurred while fetching sessions:",P)}finally{v(!1)}},[r]);u.useEffect(()=>{S(1,!1);const F=()=>{S(1,!1)},z=q=>{const{sessionId:Q}=q.detail;i(P=>{const Y=P.find(A=>A.id===Q);if(Y){const A=P.filter(B=>B.id!==Q);return[Y,...A]}return P})};return window.addEventListener("new-chat-session",F),window.addEventListener("session-updated",z),()=>{window.removeEventListener("new-chat-session",F),window.removeEventListener("session-updated",z)}},[S]),u.useEffect(()=>{w&&g&&!h&&S(p+1,!0)},[w,g,h,p,S]),u.useEffect(()=>{l&&o.current&&o.current.focus()},[l]);const E=async F=>{l!==F&&await e(F)},N=F=>{c(F.id),f(F.name||"")},j=async()=>{l&&(await t(l,d),c(null),S())},k=F=>{n(F)},T=F=>hh(F),V=F=>{if(F.name&&F.name.trim())return F.name;const z=F.id;return z.startsWith("web-session-")?`Chat ${z.replace("web-session-","").substring(0,8)}`:`Session ${z.substring(0,8)}`};return a.jsxs("div",{className:"flex h-full flex-col gap-4 py-6 pl-6",children:[a.jsx("div",{className:"text-lg",children:"Chat Session History"}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.length>0&&a.jsx("ul",{children:s.map(F=>a.jsx("li",{className:"group my-2 pr-4",children:a.jsxs("div",{className:"flex items-center justify-between rounded px-4 py-2 hover:bg-gray-200 dark:hover:bg-gray-700",children:[l===F.id?a.jsx("input",{ref:o,type:"text",value:d,onChange:z=>f(z.target.value),onKeyDown:z=>z.key==="Enter"&&j(),onBlur:j,className:"flex-grow bg-transparent focus:outline-none"}):a.jsx("button",{onClick:()=>E(F.id),className:"flex-grow text-left",children:a.jsxs("div",{className:"flex max-w-50 flex-col",children:[a.jsx("span",{className:"truncate font-semibold",title:V(F),children:V(F)}),a.jsx("span",{className:"text-muted-foreground text-xs",children:T(F.updatedTime)})]})}),a.jsx("div",{className:"flex items-center opacity-0 transition-opacity group-hover:opacity-100",children:l===F.id?a.jsxs(a.Fragment,{children:[a.jsx(we,{variant:"ghost",onClick:j,children:a.jsx(wi,{size:16})}),a.jsx(we,{variant:"ghost",onClick:()=>c(null),children:a.jsx(Do,{size:16})})]}):a.jsxs(a.Fragment,{children:[a.jsx(we,{variant:"ghost",onClick:()=>N(F),children:a.jsx(Xp,{size:16})}),a.jsx(we,{variant:"ghost",onClick:()=>k(F),children:a.jsx(Zp,{size:16})})]})})]})},F.id))}),s.length===0&&!h&&a.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[a.jsx(Ql,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]}),g&&a.jsx("div",{ref:b,className:"flex justify-center py-4",children:h&&a.jsx(bf,{size:"small",variant:"muted"})})]})]})},HC=()=>{const{persistenceEnabled:e}=on(),{sessionName:t}=He();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||"New Chat"}),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(UC,{})},WC=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:o,setIsExpanded:s})=>{const{previewedArtifactAvailableVersions:i,currentPreviewedVersionNumber:l,navigateArtifactVersion:c}=He(),d=u.useMemo(()=>i??[],[i]);return a.jsxs("div",{className:"flex flex-row justify-between gap-1",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-4",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:_a(e.last_modified),children:_a(e.last_modified)})]}),t&&d.length>1&&a.jsx("div",{className:"align-right",children:a.jsxs(Yd,{value:l==null?void 0:l.toString(),onValueChange:f=>{c(e.filename,parseInt(f))},children:[a.jsx(qd,{className:"h-[16px] py-0 text-xs shadow-none",children:a.jsx(Kd,{placeholder:"Version"})}),a.jsx(Xd,{children:d.map(f=>a.jsxs(Zd,{value:f.toString(),children:["Version ",f]},f))})]})})]}),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(we,{variant:"ghost",size:"sm",onClick:f=>{f.stopPropagation(),f.preventDefault(),s(!n)},tooltip:n?"Collapse Details":"Expand Details",children:a.jsx(Ci,{})}),o&&a.jsx(we,{variant:"ghost",size:"sm",onClick:async f=>{f.stopPropagation(),f.preventDefault(),await o(e)},tooltip:"Download",children:a.jsx(Si,{})}),r&&a.jsx(we,{variant:"ghost",size:"sm",onClick:f=>{f.preventDefault(),f.stopPropagation(),r(e)},tooltip:"Delete",children:a.jsx(ec,{})})]})]})},Ol=({artifact:e,isPreview:t})=>{const{openDeleteModal:n,setPreviewArtifact:r}=He(),{onDownload:o}=sd(),[s,i]=u.useState(!1),l=()=>{t&&r(null),n(e)},c=d=>{if(!d||typeof d=="object"&&Object.keys(d).length===0)return a.jsx("span",{children:"Not available"});const f=(p,m=0)=>typeof p=="string"?a.jsx("span",{children:p}):Array.isArray(p)?a.jsxs(a.Fragment,{children:["[",p.length>0&&f(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,":"]})," ",f(x,m+1)]},h))}):String(p);return a.jsxs("div",{className:"mt-1 space-y-0.5",children:[typeof d=="object"&&d.type&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",d.type," ",d.inferred&&a.jsx("span",{className:"text-xs",children:"(inferred)"})]}),typeof d=="object"&&d.columns&&a.jsxs("p",{children:[a.jsx("strong",{children:"Columns:"})," ",d.columns.join(", ")]}),typeof d=="object"&&d.structure&&a.jsxs("div",{children:[a.jsx("strong",{children:"Structure:"}),f(d.structure)]}),typeof d=="object"&&d.error&&a.jsxs("p",{className:"text-[var(--color-error-wMain)]",children:[a.jsx("strong",{children:"Schema Error:"})," ",d.error]}),typeof d=="string"&&a.jsx("p",{children:d})]})};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:d=>{d.stopPropagation(),r(e)},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.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:Tf(e,"h-4 w-4 flex-shrink-0")}),a.jsxs("div",{className:"min-w-0 flex-grow",children:[a.jsx(WC,{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: "}),Sc(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)})]})]})]})]})})},GC=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=He();return!e||!t?null:a.jsx(Ko,{open:e,onOpenChange:n,children:a.jsxs(qo,{children:[a.jsxs(Xo,{children:[a.jsxs(Zo,{className:"flex max-w-[400px] flex-row gap-1",children:["Delete",a.jsx("span",{className:"inline-block truncate",title:t.filename,children:a.jsx("code",{children:t.filename})}),"?"]}),a.jsx(Jo,{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(we,{variant:"outline",onClick:n,children:"Cancel"}),a.jsx(we,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})})},VC={replace:e=>{e instanceof em.Element&&e.attribs&&e.name==="a"&&(e.attribs.target="_blank",e.attribs.rel="noopener noreferrer")}};function ir({children:e,className:t}){if(!e)return null;try{const n=Jp.parse(e,{gfm:!0}),r=Pf.sanitize(n,{USE_PROFILES:{html:!0}}),o=Qp(r,VC);return a.jsx("div",{className:Ia(t),children:o})}catch{return a.jsx("div",{className:Ia(t),children:e})}}const YC=Nn("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"}}),KC={error:yi,warning:tm,info:Ci,success:tc};function la({className:e,variant:t="error",message:n,dismissible:r=!1,onDismiss:o,...s}){const i=KC[t||"error"];return a.jsxs("div",{className:be(YC({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(we,{variant:"ghost",onClick:o,"aria-label":"Dismiss",children:a.jsx(Do,{className:"size-3"})})]})}const qC=({artifact:e,message:t})=>{const{onDownload:n}=sd();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(we,{onClick:()=>n(e),children:[a.jsx(Si,{className:"h-4 w-4"}),"Download"]})]})},zs=({children:e})=>a.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),XC=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n}=He(),r=u.useMemo(()=>kb(e),[e]),[o,s]=u.useState(!1),[i,l]=u.useState(null);if(u.useEffect(()=>{s(!1),l(null)},[e]),u.useEffect(()=>{async function f(){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&&f()},[e,t,r]),i)return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(la,{variant:"error",message:"Error rendering preview"}),a.jsx(zs,{children:"No preview available"})]});if(o)return a.jsx(zs,{children:a.jsx(bi,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!r.canPreview)return a.jsx(qC,{artifact:e,message:r.reason??""});const c=Zr(e.filename,e.mime_type),d=Ab(n);return!c||!d?a.jsx(zs,{children:"No preview available"}):a.jsx(Cp,{content:d,rendererType:c,mime_type:n==null?void 0:n.mime_type,setRenderError:l})},Jt={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},ZC=e=>{switch(e){case Jt.NameAsc:return"Name (A-Z)";case Jt.NameDesc:return"Name (Z-A)";case Jt.DateAsc:return"Date (oldest first)";case Jt.DateDesc:return"Date (newest first)"}},JC=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values(Jt).map(o=>({id:o,label:ZC(o),onClick:()=>t(o),icon:e===o?a.jsx(wi,{}):void 0,iconPosition:"right"}));return a.jsxs(vd,{children:[a.jsx(wd,{asChild:!0,children:n}),a.jsx(bd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Ji,{actions:r})})]})},QC=({children:e})=>{const{artifactsRefetch:t,setIsBatchDeleteModalOpen:n}=He(),r=[{id:"refreshAll",label:"Refresh",onClick:()=>{t()},icon:a.jsx(nc,{}),iconPosition:"left"},{id:"deleteAll",label:"Delete All",onClick:()=>{n(!0)},icon:a.jsx(ec,{}),iconPosition:"left",divider:!0}];return a.jsxs(vd,{children:[a.jsx(wd,{asChild:!0,children:e}),a.jsx(bd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Ji,{actions:r})})]})},e1=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:o}=He();return u.useEffect(()=>{t&&o(new Set(e.map(s=>s.filename)))},[e,t,o]),t?a.jsx(Ko,{open:t,onOpenChange:n,children:a.jsxs(qo,{children:[a.jsxs(Xo,{children:[a.jsx(Zo,{children:"Delete All?"}),a.jsxs(Jo,{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(we,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),a.jsx(we,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})}):null},t1={[Jt.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[Jt.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[Jt.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[Jt.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},n1=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r}=He(),[o,s]=u.useState(Jt.DateDesc),i=u.useMemo(()=>t?[]:e?[...e].sort(t1[o]):[],[e,t,o]),l=u.useMemo(()=>n?a.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[a.jsx(we,{variant:"ghost",onClick:()=>r(null),children:a.jsx(nm,{})}),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(JC,{currentSortOption:o,onSortChange:s,children:a.jsxs(we,{variant:"ghost",title:"Sort By",children:[a.jsx(ql,{className:"h-5 w-5"}),a.jsx("div",{children:"Sort By"})]})},"sort-popover"),a.jsx(QC,{children:a.jsx(we,{variant:"ghost",tooltip:"More",children:a.jsx(rm,{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(Ol,{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(bi,{className:"size-6 animate-spin"}),!t&&a.jsxs(a.Fragment,{children:[a.jsx(ar,{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 min-h-0 min-w-0 flex-1 flex-col gap-2",children:[a.jsx(Ol,{artifact:n,isPreview:!0},n.filename),a.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto",children:a.jsx(XC,{artifact:n})})]})]}),a.jsx(GC,{}),a.jsx(e1,{})]})},r1=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:o,setActiveSidePanelTab:s,setPreviewArtifact:i,taskIdInSidePanel:l}=He(),{isReconnecting:c,isTaskMonitorConnecting:d,isTaskMonitorConnected:f,monitoredTasks:p,connectTaskMonitorStream:m}=Xi(),[g,x]=u.useState(null);u.useEffect(()=>{if(l&&p[l]){const S=p[l],E=F1(S.events||[],p,S);x(E)}else x(null)},[l,p]);const h=()=>c||d?{message:"Connecting to task monitor ...",showButton:!1}:f?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:om,buttonAction:m},v=()=>{const S=!t;n(S),e(S)},b=S=>{S==="files"&&i(null),s(S)},w=S=>{t&&(n(!1),e==null||e(!1)),b(S)};return t?a.jsxs("div",{className:"bg-background flex h-full w-full flex-col items-center border-l py-4",children:[a.jsx(we,{variant:"ghost",size:"sm",onClick:v,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:a.jsx(ga,{className:"size-5"})}),a.jsx("div",{className:"bg-border my-4 h-px w-8"}),a.jsx(we,{variant:"ghost",size:"sm",onClick:()=>w("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:a.jsx(ar,{className:"size-5"})}),a.jsx(we,{variant:"ghost",size:"sm",onClick:()=>w("workflow"),className:"h-10 w-10 p-0",tooltip:"Workflow",children:a.jsx(go,{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(Q0,{value:o,onValueChange:S=>b(S),className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex gap-2 p-2",children:[a.jsx(we,{variant:"ghost",onClick:v,className:"p-1",tooltip:"Collapse Panel",children:a.jsx(ga,{className:"size-5"})}),a.jsxs(eb,{className:"grid w-full grid-cols-2 bg-transparent p-0",children:[a.jsxs(ul,{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(ar,{className:"mr-2 h-4 w-4"}),"Files"]}),a.jsxs(ul,{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(go,{className:"mr-2 h-4 w-4"}),"Workflow"]})]})]}),a.jsxs("div",{className:"min-h-0 flex-1",children:[a.jsx(dl,{value:"files",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:a.jsx(n1,{})})}),a.jsx(dl,{value:"workflow",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:(()=>{const S=h();return!S&&g?a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsx(i1,{task:g}),a.jsx(O1,{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(go,{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:S==null?void 0:S.message}),(S==null?void 0:S.showButton)&&a.jsx("div",{className:"mt-4",children:a.jsxs(we,{onClick:S.buttonAction,children:[S.buttonIcon&&(()=>{const E=S.buttonIcon;return a.jsx(E,{className:"h-4 w-4"})})(),S.buttonText]})})]})})})()})})]})]})})})},fi=({statusText:e,onViewWorkflow:t})=>a.jsxs("div",{className:"flex h-8 items-center space-x-3 py-1",children:[t?a.jsx(ou,{onClick:t}):a.jsx(ib,{className:"mr-3 ml-2"}),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})})]}),Tp=({isOpen:e,onClose:t})=>{const{handleNewSession:n}=He(),{persistenceEnabled:r}=on();return a.jsx(Ko,{open:e,onOpenChange:t,children:a.jsxs(qo,{children:[a.jsxs(Xo,{children:[a.jsx(Zo,{className:"flex max-w-[400px] flex-row gap-1",children:r===!1?"New Chat Session?":"Start New Chat Session?"}),a.jsx(Jo,{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(we,{variant:"outline",onClick:t,children:"Cancel"}),a.jsx(we,{variant:"default",onClick:()=>{n(),t()},children:"Start New Chat"})]})]})})},o1=({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(we,{variant:"ghost",onClick:e,className:"p-2",tooltip:"Collapse Sessions Panel",children:a.jsx(rc,{className:"size-5"})}),a.jsxs(we,{variant:"ghost",onClick:()=>n(!0),tooltip:"Start New Chat Session",children:[a.jsx(oc,{className:"size-5"}),"New chat"]})]}),a.jsx("div",{className:"mt-1 min-h-0 flex-1",children:a.jsx(HC,{})}),a.jsx(Tp,{isOpen:t,onClose:()=>n(!1)})]})},_r=(e,t)=>a.jsx(yf,{type:t,className:"rounded-full border-none",children:a.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),s1=(e,t)=>{var r;if(e.currentStatusText)return a.jsx("div",{title:e.currentStatusText,children:a.jsx(fi,{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(fi,{statusText:n||e.status})});case"input-required":return _r("Input Required","info");case"completed":return _r("Completed","success");case"canceled":return _r("Canceled","info");case"failed":return _r("Failed","error");default:return _r("Unknown","info")}},i1=({task:e})=>{const{messages:t}=He(),n=u.useMemo(()=>{const r=t.find(o=>o.isStatusBubble);return e?s1(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 Ap{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 f;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"),d=s.type==="AGENT_TOOL_EXECUTION_RESULT"&&((f=s.data.toolResult)==null?void 0:f.isPeerResponse);return l||c||d})}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)}}function Np(e,t){return(t==null?void 0:t[e])||e}const fn={USER:50,MAIN_FLOW:300,TOOLS:600},a1=50,qe=50,_t=330,Hn=50,qt=20,fr=10,Fl=qe+20,l1=90;function Wn(e,t,n){return e.push(n),t.add(n.id),n}function c1(e,t){return e.push(t),t}function Gn(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 Jr(e){const t=dt(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function u1(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 d1(e,t){if(!t)return null;const n=dt(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function f1(e,t){if(!t)return null;const n=dt(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function us(e,t){var o;const n=dt(e);if(!n)return null;if(t.functionCallId){const s=d1(e,t.functionCallId);if(s)return s}if(t.owningTaskId&&t.isSubTaskStep){const s=f1(e,t.owningTaskId);if(s){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return s}}const r=Jr(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 kp(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 _p(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 u1(e,t,n)}function p1(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 Ip(r,l)}return null}function Ip(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return Ip(e,n)}return null}function pr(e,t,n,r){const o=`phase_${e.phases.length}`,s=Gn(e,`${t}_${o}`),i=e.nextAvailableGlobalY,l=Np(t,e.agentNameMap),c={id:s,type:"orchestratorNode",position:{x:fn.MAIN_FLOW,y:i},data:{label:l,visualizerStepId:n.id}};Wn(r,e.allCreatedNodeIds,c),e.nodePositions.set(s,c.position);const d={id:s,yPosition:i,height:qe,width:_t},f={id:s,name:t,type:"orchestrator",phaseId:o,context:"main",nodeInstance:d};e.agentRegistry.registerAgent(f);const p={id:o,orchestratorAgent:d,userNodes:[],subflows:[],toolInstances:[],currentToolYOffset:0,maxY:i+qe};return e.phases.push(p),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=p.maxY+Hn,p}function pi(e,t,n,r,o){var F,z,q,Q,P;const s=dt(e);if(!s)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((F=n.data.toolResult)==null?void 0:F.isPeerResponse)===!0,l=n.source||"",c=n.target||"",d=mr(l);!i&&!d&&!o&&e.indentationLevel++;const f=((q=(z=n.delegationInfo)==null?void 0:z[0])==null?void 0:q.subTaskId)||n.owningTaskId,p=Gn(e,`${t}_${f}`),m=Gn(e,`group_${t}_${f}`),g=((P=(Q=n.data)==null?void 0:Q.toolInvocationStart)==null?void 0:P.functionCallId)||n.functionCallId||"";let x,h,v;const b=Array.from(e.parallelFlows.values()).find(Y=>Y.subflowFunctionCallIds.includes(g)),w=Jr(e),S=p1(e,l,c);o&&b?(x=b.startX+b.currentXOffset,h=b.startY,v=h+qt,b.currentXOffset+=(_t+fr)*2.2):S?(v=e.nextAvailableGlobalY,x=(S.groupNode.xPosition||fn.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,h=v-qt):(v=e.nextAvailableGlobalY,x=fn.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,h=v-qt);const E=Np(t,e.agentNameMap),N={id:p,type:"genericAgentNode",position:{x:50,y:qt},data:{label:E,visualizerStepId:n.id},parentId:m},j={id:m,type:"group",position:{x,y:h},data:{label:`${E} Sub-flow`},style:{backgroundColor:"rgba(220, 220, 255, 0.1)",border:"1px solid #aac",borderRadius:"8px",minHeight:`${qe+2*qt}px`}};Wn(r,e.allCreatedNodeIds,j),Wn(r,e.allCreatedNodeIds,N),e.nodePositions.set(p,N.position),e.nodePositions.set(m,j.position);const k={id:p,xPosition:fn.MAIN_FLOW,yPosition:v,height:qe,width:_t},T={id:p,name:t,type:"peer",phaseId:s.id,subflowId:f,context:"subflow",nodeInstance:k};e.agentRegistry.registerAgent(T);const V={id:f,functionCallId:g,isParallel:o,peerAgent:k,groupNode:{id:m,xPosition:x,yPosition:h,height:qe+2*qt,width:0},toolInstances:[],currentToolYOffset:0,maxY:v+qe,maxContentXRelative:N.position.x+_t,callingPhaseId:s.id,parentSubflowId:w==null?void 0:w.id,inheritedXOffset:S==null?void 0:S.groupNode.xPosition};return s.subflows.push(V),S&&(S.lastSubflow=V),e.currentSubflowIndex=s.subflows.length-1,o&&b?(b.maxHeight=Math.max(b.maxHeight,V.groupNode.height),e.nextAvailableGlobalY=b.startY+b.maxHeight+Hn):e.nextAvailableGlobalY=V.groupNode.yPosition+V.groupNode.height+Hn,V}function jp(e,t,n,r,o,s,i=!1){const l=dt(e);if(!l)return null;const c=s?s.toolInstances:l.toolInstances,d=i?"LLM":`Tool: ${t}`,f=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+=Fl,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=fn.TOOLS,m=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=Fl,x=g,h=m;const v=Gn(e,`${f}_${r.id}`),b={id:v,type:n,position:{x,y:h},data:{label:d,visualizerStepId:r.id,toolName:t},parentId:p};Wn(o,e.allCreatedNodeIds,b),e.nodePositions.set(v,{x,y:h});const w={id:v,xPosition:g,yPosition:m,height:qe,width:_t,functionCallId:r.functionCallId};c.push(w);const S=m+qe;if(s){s.maxY=Math.max(s.maxY,S),s.maxContentXRelative=Math.max(s.maxContentXRelative,x+_t);const E=s.maxY-s.groupNode.yPosition+qt;s.groupNode.height=Math.max(s.groupNode.height,E);const N=s.maxContentXRelative+fr;s.groupNode.width=Math.max(s.groupNode.width||0,N);const j=o.find(k=>k.id===s.groupNode.id);j&&(j.style={...j.style,height:`${s.groupNode.height}px`,width:`${s.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,s.groupNode.yPosition+s.groupNode.height+Hn)}else l.maxY=Math.max(l.maxY,S),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+Hn);return w}function ca(e,t,n,r){e.userNodeCounter++;const o=Gn(e,`User_response_${e.userNodeCounter}`),s=e.nextAvailableGlobalY+20,i={id:o,type:"userNode",position:{x:fn.USER,y:s},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};Wn(r,e.allCreatedNodeIds,i),e.nodePositions.set(o,i.position);const l={id:o,yPosition:s,height:qe,width:_t};t.userNodes.push(l),e.allUserNodes.push(l);const c=s+qe;return t.maxY=Math.max(t.maxY,c),l}function wt(e,t,n,r,o,s,i,l,c){if(!e||!t||e===t)return;const d=o.allCreatedNodeIds.has(e),f=o.allCreatedNodeIds.has(t);if(!d||!f)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),c1(r,h)}}function m1(){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 mi(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 mr(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const h1=["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 g1(e,t,n,r,o,s){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=dt(t),d=Jr(t);let f,p=!1;if(d?(f=d.peerAgent,f.id.startsWith(l+"_")&&(p=!0)):c&&(f=c.orchestratorAgent,f.id.startsWith(l+"_")&&(p=!0)),p&&f&&c){t.userNodeCounter++;const m=Gn(t,`User_continue_${t.userNodeCounter}`),g=t.nextAvailableGlobalY,x={id:m,type:"userNode",position:{x:fn.USER,y:g},data:{label:"User",visualizerStepId:e.id}};Wn(n,t.allCreatedNodeIds,x),t.nodePositions.set(m,x.position);const h={id:m,yPosition:g,height:qe,width:_t};c.userNodes.push(h),t.allUserNodes.push(h);const v=g+qe;f.yPosition=Math.max(f.yPosition,g),c.maxY=Math.max(c.maxY,v,f.yPosition+qe),t.nextAvailableGlobalY=c.maxY+Hn;const b=mr(i)?"orch-left-input":"peer-left-input";wt(h.id,f.id,e,r,t,o,s,"user-right-output",b)}else{const m=pr(t,i,e,n),g=Gn(t,`User_${m.id}`),x={id:g,type:"userNode",position:{x:fn.USER,y:m.orchestratorAgent.yPosition-l1},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};Wn(n,t.allCreatedNodeIds,x),t.nodePositions.set(g,x.position);const h={id:g,yPosition:x.position.y,height:qe,width:_t};m.userNodes.push(h),t.allUserNodes.push(h),t.userNodeCounter++,m.maxY=Math.max(m.maxY,x.position.y+qe),t.nextAvailableGlobalY=m.maxY+Hn,wt(g,m.orchestratorAgent.id,e,r,t,o,s,"user-bottom-output","orch-top-input")}}function x1(e,t,n,r,o,s){const i=dt(t);if(!i)return;const l=us(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,d=jp(t,"LLM","llmNode",e,n,l,!0);d&&wt(c,d.id,e,r,t,o,s,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function v1(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:fn.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=dt(t);if(!i)return;const l=us(t,e);let c;const f=_p((l||i).toolInstances,"LLM",n,e.functionCallId);if(f)c=f.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?wt(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 w1(e,t,n,r,o,s){var f;const i=dt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"UnknownTool";if(((f=e.data.toolInvocationStart)==null?void 0:f.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=mi(m.type,"output","bottom"),h=kp(e,t),v=pi(t,p,e,n,h);v&&wt(g.id,v.peerAgent.id,e,r,t,o,s,x,"peer-top-input")}else{const p=us(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=mi(h.type,"output","right")):(m=i.orchestratorAgent.id,g="orch-right-output-tools")}const x=jp(t,c,"genericToolNode",e,n,p);x&&wt(m,x.id,e,r,t,o,s,g,`${x.id}-tool-left-input`)}}function b1(e,t,n,r,o,s){var d,f;const i=dt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"OrchestratorAgent";if((d=e.data.toolResult)!=null&&d.isPeerResponse){const p=(f=e.data.toolResult)==null?void 0:f.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,S;if(mr(b))t.indentationLevel=0,w=pr(t,b,e,n).orchestratorAgent,S="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const E=pi(t,b,e,n,!1);if(!E)return;w=E.peerAgent,S="peer-top-input"}v.forEach(E=>{var N;wt(((N=E.lastSubflow)==null?void 0:N.peerAgent.id)??E.peerAgent.id,w.id,e,r,t,o,s,"peer-bottom-output",S)}),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(mr(c)){t.indentationLevel=0;const x=pr(t,c,e,n);wt(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=kp(e,t)||Array.from(t.parallelFlows.values()).some(v=>v.subflowFunctionCallIds.some(b=>i.subflows.some(w=>w.functionCallId===b))),h=pi(t,c,e,n,x);h&&wt(g.id,h.peerAgent.id,e,r,t,o,s,"peer-bottom-output","peer-top-input")}}else{let p;const m=us(t,e),x=_p((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=mi(b.type,"input","right")):(h=i.orchestratorAgent.id,v="orch-right-input-tools")}wt(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 y1(e,t,n,r,o,s){const i=dt(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=ca(t,i,e,n);wt(l,c.id,e,r,t,o,s,"orch-bottom-output","user-top-input")}function S1(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=pr(t,"OrchestratorAgent",e,n);i.subflows.forEach(x=>{l.subflowFunctionCallIds.includes(x.functionCallId)&&wt(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=Jr(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 d=c.peerAgent,f=n.some(g=>typeof g.data.label=="string"&&mr(g.data.label));let p,m;f?(t.indentationLevel=0,p=pr(t,"OrchestratorAgent",e,n).orchestratorAgent.id,m="orch-top-input"):(p=ca(t,i,e,n).id,m="user-top-input"),wt(d.id,p,e,r,t,o,s,"peer-bottom-output",m),t.currentSubflowIndex=-1}function C1(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 d=Jr(t);if(d&&d.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=d.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 f,p;mr(i)?(t.indentationLevel=0,f=pr(t,i,e,n).orchestratorAgent.id,p="orch-top-input",t.currentSubflowIndex=-1):(f=ca(t,o,e,n).id,p="user-top-input"),E1(l.id,f,e,r,t,c,p)}function E1(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 d=`error-edge-${e}${s||""}-to-${t}${i||""}-${n.id}`;if(!r.some(m=>m.id===d)){const m=((p=n.data.errorDetails)==null?void 0:p.message)||"Task failed",g=m.length>30?"Error":m,x={id:d,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 T1=(e,t={})=>{const n=[],r=[];if(!e||e.length===0)return{nodes:n,edges:r};const o=new Ap,s={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:a1,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:m1(),indentationLevel:0,indentationStep:50,agentNameMap:t},i=e.filter(d=>h1.includes(d.type)),l=i.findIndex(d=>d.type==="USER_REQUEST");let c=i;l>0&&(c=[i[l],...i.slice(0,l),...i.slice(l+1)]);for(const d of c)switch(d.type){case"USER_REQUEST":g1(d,s,n,r,o,e);break;case"AGENT_LLM_CALL":x1(d,s,n,r,o,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":v1(d,s,n,r,o,e);break;case"AGENT_TOOL_INVOCATION_START":w1(d,s,n,r,o,e);break;case"AGENT_TOOL_EXECUTION_RESULT":b1(d,s,n,r,o,e);break;case"AGENT_RESPONSE_TEXT":y1(d,s,n,r,o,e);break;case"TASK_COMPLETED":S1(d,s,n,r,o,e);break;case"TASK_FAILED":C1(d,s,n,r);break}return s.phases.forEach(d=>{d.subflows.forEach(f=>{const p=n.find(m=>m.id===f.groupNode.id);if(p&&p.style){const g=f.maxY-f.groupNode.yPosition+qt;p.style.height=`${Math.max(qe+2*qt,g)}px`;const x=f.maxContentXRelative+fr,h=_t+2*fr+s.indentationLevel*s.indentationStep;p.style.width=`${Math.max(x,h)}px`}})}),{nodes:n,edges:r}},A1=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,style:l={},markerEnd:c,data:d})=>{const[f,p]=u.useState(!1),[m]=sm({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i}),g=()=>{const v={strokeWidth:f?3:2,stroke:"var(--color-muted-foreground)",...l},b=d;return b!=null&&b.isError?{...v,stroke:f?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:f?3:2}:b!=null&&b.isSelected?{...v,stroke:"#3b82f6",strokeWidth:3}:b!=null&&b.isAnimated?{...v,stroke:f?"#1d4ed8":"#3b82f6",strokeWidth:f?4:3}:f?{...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})]})},N1=({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(Je,{type:"target",position:Qe.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Je,{type:"source",position:Qe.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),a.jsx(Je,{type:"target",position:Qe.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),a.jsx(Je,{type:"source",position:Qe.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Je,{type:"target",position:Qe.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 truncate",style:{maxWidth:"200px"},children:e.label})})]}),k1=({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(Je,{type:"target",position:Qe.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 truncate",style:{maxWidth:"200px"},children:e.label})]}),a.jsx(Je,{type:"source",position:Qe.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}})]})},_1=({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(Je,{type:"target",position:Qe.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(Je,{type:"source",position:Qe.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},I1=({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(Je,{type:"source",position:Qe.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),a.jsx(Je,{type:"target",position:Qe.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),a.jsx(Je,{type:"target",position:Qe.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Je,{type:"source",position:Qe.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Je,{type:"target",position:Qe.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 font-bold truncate",style:{maxWidth:"200px"},children:e.label})})]}),j1=({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(Je,{type:"source",position:Qe.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&a.jsx(Je,{type:"target",position:Qe.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&a.jsx(Je,{type:"source",position:Qe.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})]})]})},R1=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const o=()=>{var w,S,E;switch(e.type){case"USER_REQUEST":return a.jsx(cm,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return a.jsx(fs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return a.jsx(tc,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return a.jsx(lm,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return a.jsx(fs,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return a.jsx(fs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const N=(S=(w=e.data.toolDecision)==null?void 0:w.decisions)==null?void 0:S[0];return(N==null?void 0:N.isPeerDelegation)?a.jsx(xa,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):a.jsx(va,{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(xa,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):a.jsx(va,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return a.jsx(am,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return a.jsx(ar,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return a.jsx(im,{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})]}),d=({data:w})=>{const[S,E]=Ut.useState(!1),N=j=>{j.stopPropagation(),E(!S)};return S?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:N,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:N,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},f=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(S=>a.jsxs("li",{className:"flex items-center",children:[a.jsx("span",{className:"mr-2",children:"•"}),a.jsx("code",{children:S.toolName})]},S.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(xi,{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(xi,{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 iC=sC,aC={dump:iC};function aa(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 lC=et,cC=Of,uC=Bf,dC=Vf,fC=Yf,pC=ra,mC=up.load,hC=up.loadAll,gC=aC.dump,xC=lt,vC={binary:Jf,float:Gf,map:$f,null:Uf,pairs:ep,set:tp,timestamp:Xf,bool:Hf,int:Wf,merge:Zf,omap:Qf,seq:zf,str:Ff},wC=aa("safeLoad","load"),bC=aa("safeLoadAll","loadAll"),yC=aa("safeDump","dump"),SC={Type:lC,Schema:cC,FAILSAFE_SCHEMA:uC,JSON_SCHEMA:dC,CORE_SCHEMA:fC,DEFAULT_SCHEMA:pC,load:mC,loadAll:hC,dump:gC,YAMLException:xC,types:vC,safeLoad:wC,safeLoadAll:bC,safeDump:yC};const CC=({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=SC.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 d={[`${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,d]}},[e,t,n]);return a.jsxs("div",{className:"bg-background relative flex h-full flex-col overflow-hidden",children:[a.jsx("div",{className:"absolute top-4 right-4 z-10",children:a.jsx(we,{onClick:()=>o(!r),title:r?"Show Structured View":"Show Raw Text",children:r?a.jsxs(a.Fragment,{children:[a.jsx(Zl,{})," Structured"]}):a.jsxs(a.Fragment,{children:[a.jsx(Jl,{})," 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(Sp,{content:s,setRenderError:n}):a.jsx(xi,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},Sp=({content:e,className:t=""})=>{const{ref:n,handleKeyDown:r}=kf();return a.jsx("div",{className:`overflow-auto p-4 ${t}`,children:a.jsx("pre",{ref:n,className:"whitespace-pre-wrap select-text focus-visible:outline-none",style:{overflowWrap:"anywhere"},tabIndex:0,onKeyDown:r,children:e})})},Cp=({content:e,rendererType:t,mime_type:n,setRenderError:r})=>{switch(t){case"csv":return a.jsx(jb,{content:e,setRenderError:r});case"mermaid":return a.jsx(ny,{content:e,setRenderError:r});case"html":return a.jsx(Rb,{content:e,setRenderError:r});case"json":case"yaml":return a.jsx(CC,{content:e,rendererType:t,setRenderError:r});case"image":return a.jsx(Mb,{content:e,mime_type:n,setRenderError:r});case"markdown":return a.jsx(Pb,{content:e,setRenderError:r});case"audio":return a.jsx(_b,{content:e,mime_type:n,setRenderError:r});default:return a.jsx(Sp,{content:e,setRenderError:r})}},EC={"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 TC(e,t){const n=EC[e]||"bin";return`embedded_file_${t+1}.${n}`}function AC(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],d=e[r.index+s.length];if(!(c==='"'&&d==='"'||c==="'"&&d==="'")&&l&&l.length>10){const f=Zr(void 0,i);f?t.push({type:f,content:l,mimeType:i,originalMatch:s}):t.push({type:"file",content:l,mimeType:i,originalMatch:s,filename:TC(i,o++)})}}return t}function NC(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 kC(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 _C(e){return!e||typeof e!="string"?[]:[...AC(e),...NC(e),...kC(e)]}const IC=["image","audio"],jC=({message:e})=>{var d;const[t,n]=u.useState(null);if(e.isStatusBubble)return null;const r=(d=e.parts)==null?void 0:d.filter(f=>f.kind==="text"),o=(r==null?void 0:r.map(f=>f.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(yi,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),a.jsx(ir,{children:s})]});const i=_C(s);if(i.length===0)return a.jsx(ir,{children:s});let l=s;const c=[];return i.forEach((f,p)=>{if(l=l.replace(f.originalMatch,""),f.type==="file"){const m={name:f.filename||"downloaded_file",content:f.content,mime_type:f.mimeType};c.push(a.jsx("div",{className:"my-2",children:a.jsx(Af,{fileAttachment:m,isEmbedded:!0})},`embedded-file-${p}`))}else if(!IC.includes(f.type)){const m=Sf(f.content);m&&c.push(a.jsx("div",{className:"my-2 h-auto w-md max-w-md",children:a.jsx(Cp,{content:m,rendererType:f.type,mime_type:f.mimeType,setRenderError:n})},`embedded-${p}`))}}),a.jsxs("div",{children:[t&&a.jsx(la,{variant:"error",message:"Error rendering preview"}),a.jsx(ir,{children:l}),c]})},Ep=({message:e,children:t,className:n})=>a.jsx("div",{className:`mt-1 space-y-1 ${e.isUser?"ml-auto":"mr-auto"} ${n}`,children:t}),RC=e=>e.uploadedFiles&&e.uploadedFiles.length>0?a.jsx(Ep,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return a.jsx(Nf,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,MC=e=>e.files&&e.files.length>0?a.jsx(Ep,{message:e,children:e.files.map((t,n)=>{var r;return a.jsx(Af,{fileAttachment:t},`file-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,PC=(e,t,n)=>{var d,f;const{openSidePanelTab:r,setTaskIdInSidePanel:o}=t;if(e.isStatusBubble)return null;const s=(d=e.parts)==null?void 0:d.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(gf,{variant:i,children:a.jsxs(xf,{variant:i,children:[s&&a.jsx(jC,{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(ar,{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(ou,{onClick:c})})]})},(f=e.metadata)==null?void 0:f.messageId)},LC=({message:e,isLastWithTaskId:t})=>{const n=He();return e?a.jsxs(a.Fragment,{children:[PC(e,n,t),RC(e),MC(e)]}):null};var di=new Map,fo=new WeakMap,Dl=0,DC=void 0;function OC(e){return e?(fo.has(e)||(Dl+=1,fo.set(e,Dl.toString())),fo.get(e)):"0"}function FC(e){return Object.keys(e).sort().filter(t=>e[t]!==void 0).map(t=>`${t}_${t==="root"?OC(e.root):e[t]}`).toString()}function zC(e){const t=FC(e);let n=di.get(t);if(!n){const r=new Map;let o;const s=new IntersectionObserver(i=>{i.forEach(l=>{var c;const d=l.isIntersecting&&o.some(f=>l.intersectionRatio>=f);e.trackVisibility&&typeof l.isVisible>"u"&&(l.isVisible=d),(c=r.get(l.target))==null||c.forEach(f=>{f(d,l)})})},e);o=s.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:s,elements:r},di.set(t,n)}return n}function $C(e,t,n={},r=DC){if(typeof window.IntersectionObserver>"u"&&r!==void 0){const c=e.getBoundingClientRect();return t(r,{isIntersecting:r,target:e,intersectionRatio:typeof n.threshold=="number"?n.threshold:0,time:0,boundingClientRect:c,intersectionRect:c,rootBounds:c}),()=>{}}const{id:o,observer:s,elements:i}=zC(n),l=i.get(e)||[];return i.has(e)||i.set(e,l),l.push(t),s.observe(e),function(){l.splice(l.indexOf(t),1),l.length===0&&(i.delete(e),s.unobserve(e)),i.size===0&&(s.disconnect(),di.delete(o))}}function BC({threshold:e,delay:t,trackVisibility:n,rootMargin:r,root:o,triggerOnce:s,skip:i,initialInView:l,fallbackInView:c,onChange:d}={}){var f;const[p,m]=u.useState(null),g=u.useRef(d),[x,h]=u.useState({inView:!!l,entry:void 0});g.current=d,u.useEffect(()=>{if(i||!p)return;let S;return S=$C(p,(E,N)=>{h({inView:E,entry:N}),g.current&&g.current(E,N),N.isIntersecting&&s&&S&&(S(),S=void 0)},{root:o,rootMargin:r,threshold:e,trackVisibility:n,delay:t},c),()=>{S&&S()}},[Array.isArray(e)?e.toString():e,p,o,r,s,i,n,c,t]);const v=(f=x.entry)==null?void 0:f.target,b=u.useRef(void 0);!p&&v&&!s&&!i&&b.current!==v&&(b.current=v,h({inView:!!l,entry:void 0}));const w=[m,x.inView,x.entry];return w.ref=w[0],w.inView=w[1],w.entry=w[2],w}const UC=()=>{const{handleSwitchSession:e,updateSessionName:t,openSessionDeleteModal:n}=He(),{configServerUrl:r}=on(),o=u.useRef(null),[s,i]=u.useState([]),[l,c]=u.useState(null),[d,f]=u.useState(""),[p,m]=u.useState(1),[g,x]=u.useState(!0),[h,v]=u.useState(!1),{ref:b,inView:w}=BC({threshold:0,triggerOnce:!1}),S=u.useCallback(async(F=1,z=!1)=>{v(!0);const Q=`${r}/api/v1/sessions?pageNumber=${F}&pageSize=20`;try{const P=await ze(Q);if(P.ok){const Y=await P.json();i(z?A=>[...A,...Y.data]:Y.data),x(Y.meta.pagination.nextPage!==null),m(F)}else console.error(`Failed to fetch sessions: ${P.status} ${P.statusText}`)}catch(P){console.error("An error occurred while fetching sessions:",P)}finally{v(!1)}},[r]);u.useEffect(()=>{S(1,!1);const F=()=>{S(1,!1)},z=q=>{const{sessionId:Q}=q.detail;i(P=>{const Y=P.find(A=>A.id===Q);if(Y){const A=P.filter(B=>B.id!==Q);return[Y,...A]}return P})};return window.addEventListener("new-chat-session",F),window.addEventListener("session-updated",z),()=>{window.removeEventListener("new-chat-session",F),window.removeEventListener("session-updated",z)}},[S]),u.useEffect(()=>{w&&g&&!h&&S(p+1,!0)},[w,g,h,p,S]),u.useEffect(()=>{l&&o.current&&o.current.focus()},[l]);const E=async F=>{l!==F&&await e(F)},N=F=>{c(F.id),f(F.name||"")},j=async()=>{l&&(await t(l,d),c(null),S())},k=F=>{n(F)},T=F=>hh(F),V=F=>{if(F.name&&F.name.trim())return F.name;const z=F.id;return z.startsWith("web-session-")?`Chat ${z.replace("web-session-","").substring(0,8)}`:`Session ${z.substring(0,8)}`};return a.jsxs("div",{className:"flex h-full flex-col gap-4 py-6 pl-6",children:[a.jsx("div",{className:"text-lg",children:"Chat Session History"}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.length>0&&a.jsx("ul",{children:s.map(F=>a.jsx("li",{className:"group my-2 pr-4",children:a.jsxs("div",{className:"flex items-center justify-between rounded px-4 py-2 hover:bg-gray-200 dark:hover:bg-gray-700",children:[l===F.id?a.jsx("input",{ref:o,type:"text",value:d,onChange:z=>f(z.target.value),onKeyDown:z=>z.key==="Enter"&&j(),onBlur:j,className:"flex-grow bg-transparent focus:outline-none"}):a.jsx("button",{onClick:()=>E(F.id),className:"flex-grow text-left",children:a.jsxs("div",{className:"flex max-w-50 flex-col",children:[a.jsx("span",{className:"truncate font-semibold",title:V(F),children:V(F)}),a.jsx("span",{className:"text-muted-foreground text-xs",children:T(F.updatedTime)})]})}),a.jsx("div",{className:"flex items-center opacity-0 transition-opacity group-hover:opacity-100",children:l===F.id?a.jsxs(a.Fragment,{children:[a.jsx(we,{variant:"ghost",onClick:j,children:a.jsx(wi,{size:16})}),a.jsx(we,{variant:"ghost",onClick:()=>c(null),children:a.jsx(Do,{size:16})})]}):a.jsxs(a.Fragment,{children:[a.jsx(we,{variant:"ghost",onClick:()=>N(F),children:a.jsx(Xp,{size:16})}),a.jsx(we,{variant:"ghost",onClick:()=>k(F),children:a.jsx(Zp,{size:16})})]})})]})},F.id))}),s.length===0&&!h&&a.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[a.jsx(Ql,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]}),g&&a.jsx("div",{ref:b,className:"flex justify-center py-4",children:h&&a.jsx(bf,{size:"small",variant:"muted"})})]})]})},HC=()=>{const{persistenceEnabled:e}=on(),{sessionName:t}=He();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||"New Chat"}),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(UC,{})},WC=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:o,setIsExpanded:s})=>{const{previewedArtifactAvailableVersions:i,currentPreviewedVersionNumber:l,navigateArtifactVersion:c}=He(),d=u.useMemo(()=>i??[],[i]);return a.jsxs("div",{className:"flex flex-row justify-between gap-1",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-4",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:_a(e.last_modified),children:_a(e.last_modified)})]}),t&&d.length>1&&a.jsx("div",{className:"align-right",children:a.jsxs(Yd,{value:l==null?void 0:l.toString(),onValueChange:f=>{c(e.filename,parseInt(f))},children:[a.jsx(qd,{className:"h-[16px] py-0 text-xs shadow-none",children:a.jsx(Kd,{placeholder:"Version"})}),a.jsx(Xd,{children:d.map(f=>a.jsxs(Zd,{value:f.toString(),children:["Version ",f]},f))})]})})]}),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(we,{variant:"ghost",size:"sm",onClick:f=>{f.stopPropagation(),f.preventDefault(),s(!n)},tooltip:n?"Collapse Details":"Expand Details",children:a.jsx(Ci,{})}),o&&a.jsx(we,{variant:"ghost",size:"sm",onClick:async f=>{f.stopPropagation(),f.preventDefault(),await o(e)},tooltip:"Download",children:a.jsx(Si,{})}),r&&a.jsx(we,{variant:"ghost",size:"sm",onClick:f=>{f.preventDefault(),f.stopPropagation(),r(e)},tooltip:"Delete",children:a.jsx(ec,{})})]})]})},Ol=({artifact:e,isPreview:t})=>{const{openDeleteModal:n,setPreviewArtifact:r}=He(),{onDownload:o}=sd(),[s,i]=u.useState(!1),l=()=>{t&&r(null),n(e)},c=d=>{if(!d||typeof d=="object"&&Object.keys(d).length===0)return a.jsx("span",{children:"Not available"});const f=(p,m=0)=>typeof p=="string"?a.jsx("span",{children:p}):Array.isArray(p)?a.jsxs(a.Fragment,{children:["[",p.length>0&&f(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,":"]})," ",f(x,m+1)]},h))}):String(p);return a.jsxs("div",{className:"mt-1 space-y-0.5",children:[typeof d=="object"&&d.type&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",d.type," ",d.inferred&&a.jsx("span",{className:"text-xs",children:"(inferred)"})]}),typeof d=="object"&&d.columns&&a.jsxs("p",{children:[a.jsx("strong",{children:"Columns:"})," ",d.columns.join(", ")]}),typeof d=="object"&&d.structure&&a.jsxs("div",{children:[a.jsx("strong",{children:"Structure:"}),f(d.structure)]}),typeof d=="object"&&d.error&&a.jsxs("p",{className:"text-[var(--color-error-wMain)]",children:[a.jsx("strong",{children:"Schema Error:"})," ",d.error]}),typeof d=="string"&&a.jsx("p",{children:d})]})};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:d=>{d.stopPropagation(),r(e)},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.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:Tf(e,"h-4 w-4 flex-shrink-0")}),a.jsxs("div",{className:"min-w-0 flex-grow",children:[a.jsx(WC,{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: "}),Sc(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)})]})]})]})]})})},GC=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=He();return!e||!t?null:a.jsx(Ko,{open:e,onOpenChange:n,children:a.jsxs(qo,{children:[a.jsxs(Xo,{children:[a.jsxs(Zo,{className:"flex max-w-[400px] flex-row gap-1",children:["Delete",a.jsx("span",{className:"inline-block truncate",title:t.filename,children:a.jsx("code",{children:t.filename})}),"?"]}),a.jsx(Jo,{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(we,{variant:"outline",onClick:n,children:"Cancel"}),a.jsx(we,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})})},VC={replace:e=>{e instanceof em.Element&&e.attribs&&e.name==="a"&&(e.attribs.target="_blank",e.attribs.rel="noopener noreferrer")}};function ir({children:e,className:t}){if(!e)return null;try{const n=Jp.parse(e,{gfm:!0}),r=Pf.sanitize(n,{USE_PROFILES:{html:!0}}),o=Qp(r,VC);return a.jsx("div",{className:Ia(t),children:o})}catch{return a.jsx("div",{className:Ia(t),children:e})}}const YC=Nn("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"}}),KC={error:yi,warning:tm,info:Ci,success:tc};function la({className:e,variant:t="error",message:n,dismissible:r=!1,onDismiss:o,...s}){const i=KC[t||"error"];return a.jsxs("div",{className:be(YC({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(we,{variant:"ghost",onClick:o,"aria-label":"Dismiss",children:a.jsx(Do,{className:"size-3"})})]})}const qC=({artifact:e,message:t})=>{const{onDownload:n}=sd();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(we,{onClick:()=>n(e),children:[a.jsx(Si,{className:"h-4 w-4"}),"Download"]})]})},zs=({children:e})=>a.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),XC=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n}=He(),r=u.useMemo(()=>kb(e),[e]),[o,s]=u.useState(!1),[i,l]=u.useState(null);if(u.useEffect(()=>{s(!1),l(null)},[e]),u.useEffect(()=>{async function f(){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&&f()},[e,t,r]),i)return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(la,{variant:"error",message:"Error rendering preview"}),a.jsx(zs,{children:"No preview available"})]});if(o)return a.jsx(zs,{children:a.jsx(bi,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!r.canPreview)return a.jsx(qC,{artifact:e,message:r.reason??""});const c=Zr(e.filename,e.mime_type),d=Ab(n);return!c||!d?a.jsx(zs,{children:"No preview available"}):a.jsx(Cp,{content:d,rendererType:c,mime_type:n==null?void 0:n.mime_type,setRenderError:l})},Jt={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},ZC=e=>{switch(e){case Jt.NameAsc:return"Name (A-Z)";case Jt.NameDesc:return"Name (Z-A)";case Jt.DateAsc:return"Date (oldest first)";case Jt.DateDesc:return"Date (newest first)"}},JC=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values(Jt).map(o=>({id:o,label:ZC(o),onClick:()=>t(o),icon:e===o?a.jsx(wi,{}):void 0,iconPosition:"right"}));return a.jsxs(vd,{children:[a.jsx(wd,{asChild:!0,children:n}),a.jsx(bd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Ji,{actions:r})})]})},QC=({children:e})=>{const{artifactsRefetch:t,setIsBatchDeleteModalOpen:n}=He(),r=[{id:"refreshAll",label:"Refresh",onClick:()=>{t()},icon:a.jsx(nc,{}),iconPosition:"left"},{id:"deleteAll",label:"Delete All",onClick:()=>{n(!0)},icon:a.jsx(ec,{}),iconPosition:"left",divider:!0}];return a.jsxs(vd,{children:[a.jsx(wd,{asChild:!0,children:e}),a.jsx(bd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Ji,{actions:r})})]})},e1=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:o}=He();return u.useEffect(()=>{t&&o(new Set(e.map(s=>s.filename)))},[e,t,o]),t?a.jsx(Ko,{open:t,onOpenChange:n,children:a.jsxs(qo,{children:[a.jsxs(Xo,{children:[a.jsx(Zo,{children:"Delete All?"}),a.jsxs(Jo,{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(we,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),a.jsx(we,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})}):null},t1={[Jt.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[Jt.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[Jt.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[Jt.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},n1=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r}=He(),[o,s]=u.useState(Jt.DateDesc),i=u.useMemo(()=>t?[]:e?[...e].sort(t1[o]):[],[e,t,o]),l=u.useMemo(()=>n?a.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[a.jsx(we,{variant:"ghost",onClick:()=>r(null),children:a.jsx(nm,{})}),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(JC,{currentSortOption:o,onSortChange:s,children:a.jsxs(we,{variant:"ghost",title:"Sort By",children:[a.jsx(ql,{className:"h-5 w-5"}),a.jsx("div",{children:"Sort By"})]})},"sort-popover"),a.jsx(QC,{children:a.jsx(we,{variant:"ghost",tooltip:"More",children:a.jsx(rm,{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(Ol,{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(bi,{className:"size-6 animate-spin"}),!t&&a.jsxs(a.Fragment,{children:[a.jsx(ar,{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 min-h-0 min-w-0 flex-1 flex-col gap-2",children:[a.jsx(Ol,{artifact:n,isPreview:!0},n.filename),a.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto",children:a.jsx(XC,{artifact:n})})]})]}),a.jsx(GC,{}),a.jsx(e1,{})]})},r1=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:o,setActiveSidePanelTab:s,setPreviewArtifact:i,taskIdInSidePanel:l}=He(),{isReconnecting:c,isTaskMonitorConnecting:d,isTaskMonitorConnected:f,monitoredTasks:p,connectTaskMonitorStream:m}=Xi(),[g,x]=u.useState(null);u.useEffect(()=>{if(l&&p[l]){const S=p[l],E=F1(S.events||[],p,S);x(E)}else x(null)},[l,p]);const h=()=>c||d?{message:"Connecting to task monitor ...",showButton:!1}:f?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:om,buttonAction:m},v=()=>{const S=!t;n(S),e(S)},b=S=>{S==="files"&&i(null),s(S)},w=S=>{t&&(n(!1),e==null||e(!1)),b(S)};return t?a.jsxs("div",{className:"bg-background flex h-full w-full flex-col items-center border-l py-4",children:[a.jsx(we,{variant:"ghost",size:"sm",onClick:v,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:a.jsx(ga,{className:"size-5"})}),a.jsx("div",{className:"bg-border my-4 h-px w-8"}),a.jsx(we,{variant:"ghost",size:"sm",onClick:()=>w("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:a.jsx(ar,{className:"size-5"})}),a.jsx(we,{variant:"ghost",size:"sm",onClick:()=>w("workflow"),className:"h-10 w-10 p-0",tooltip:"Workflow",children:a.jsx(go,{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(Q0,{value:o,onValueChange:S=>b(S),className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex gap-2 p-2",children:[a.jsx(we,{variant:"ghost",onClick:v,className:"p-1",tooltip:"Collapse Panel",children:a.jsx(ga,{className:"size-5"})}),a.jsxs(eb,{className:"grid w-full grid-cols-2 bg-transparent p-0",children:[a.jsxs(ul,{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(ar,{className:"mr-2 h-4 w-4"}),"Files"]}),a.jsxs(ul,{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(go,{className:"mr-2 h-4 w-4"}),"Workflow"]})]})]}),a.jsxs("div",{className:"min-h-0 flex-1",children:[a.jsx(dl,{value:"files",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:a.jsx(n1,{})})}),a.jsx(dl,{value:"workflow",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:(()=>{const S=h();return!S&&g?a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsx(i1,{task:g}),a.jsx(O1,{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(go,{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:S==null?void 0:S.message}),(S==null?void 0:S.showButton)&&a.jsx("div",{className:"mt-4",children:a.jsxs(we,{onClick:S.buttonAction,children:[S.buttonIcon&&(()=>{const E=S.buttonIcon;return a.jsx(E,{className:"h-4 w-4"})})(),S.buttonText]})})]})})})()})})]})]})})})},fi=({statusText:e,onViewWorkflow:t})=>a.jsxs("div",{className:"flex h-8 items-center space-x-3 py-1",children:[t?a.jsx(ou,{onClick:t}):a.jsx(ib,{className:"mr-3 ml-2"}),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})})]}),Tp=({isOpen:e,onClose:t})=>{const{handleNewSession:n}=He(),{persistenceEnabled:r}=on();return a.jsx(Ko,{open:e,onOpenChange:t,children:a.jsxs(qo,{children:[a.jsxs(Xo,{children:[a.jsx(Zo,{className:"flex max-w-[400px] flex-row gap-1",children:r===!1?"New Chat Session?":"Start New Chat Session?"}),a.jsx(Jo,{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(we,{variant:"outline",onClick:t,children:"Cancel"}),a.jsx(we,{variant:"default",onClick:()=>{n(),t()},children:"Start New Chat"})]})]})})},o1=({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(we,{variant:"ghost",onClick:e,className:"p-2",tooltip:"Collapse Sessions Panel",children:a.jsx(rc,{className:"size-5"})}),a.jsxs(we,{variant:"ghost",onClick:()=>n(!0),tooltip:"Start New Chat Session",children:[a.jsx(oc,{className:"size-5"}),"New chat"]})]}),a.jsx("div",{className:"mt-1 min-h-0 flex-1",children:a.jsx(HC,{})}),a.jsx(Tp,{isOpen:t,onClose:()=>n(!1)})]})},_r=(e,t)=>a.jsx(yf,{type:t,className:"rounded-full border-none",children:a.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),s1=(e,t)=>{var r;if(e.currentStatusText)return a.jsx("div",{title:e.currentStatusText,children:a.jsx(fi,{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(fi,{statusText:n||e.status})});case"input-required":return _r("Input Required","info");case"completed":return _r("Completed","success");case"canceled":return _r("Canceled","info");case"failed":return _r("Failed","error");default:return _r("Unknown","info")}},i1=({task:e})=>{const{messages:t}=He(),n=u.useMemo(()=>{const r=t.find(o=>o.isStatusBubble);return e?s1(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 Ap{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 f;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"),d=s.type==="AGENT_TOOL_EXECUTION_RESULT"&&((f=s.data.toolResult)==null?void 0:f.isPeerResponse);return l||c||d})}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)}}function Np(e,t){return(t==null?void 0:t[e])||e}const fn={USER:50,MAIN_FLOW:300,TOOLS:600},a1=50,qe=50,_t=330,Hn=50,qt=20,fr=10,Fl=qe+20,l1=90;function Wn(e,t,n){return e.push(n),t.add(n.id),n}function c1(e,t){return e.push(t),t}function Gn(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 Jr(e){const t=dt(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function u1(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 d1(e,t){if(!t)return null;const n=dt(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function f1(e,t){if(!t)return null;const n=dt(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function us(e,t){var o;const n=dt(e);if(!n)return null;if(t.functionCallId){const s=d1(e,t.functionCallId);if(s)return s}if(t.owningTaskId&&t.isSubTaskStep){const s=f1(e,t.owningTaskId);if(s){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return s}}const r=Jr(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 kp(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 _p(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 u1(e,t,n)}function p1(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 Ip(r,l)}return null}function Ip(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return Ip(e,n)}return null}function pr(e,t,n,r){const o=`phase_${e.phases.length}`,s=Gn(e,`${t}_${o}`),i=e.nextAvailableGlobalY,l=Np(t,e.agentNameMap),c={id:s,type:"orchestratorNode",position:{x:fn.MAIN_FLOW,y:i},data:{label:l,visualizerStepId:n.id}};Wn(r,e.allCreatedNodeIds,c),e.nodePositions.set(s,c.position);const d={id:s,yPosition:i,height:qe,width:_t},f={id:s,name:t,type:"orchestrator",phaseId:o,context:"main",nodeInstance:d};e.agentRegistry.registerAgent(f);const p={id:o,orchestratorAgent:d,userNodes:[],subflows:[],toolInstances:[],currentToolYOffset:0,maxY:i+qe};return e.phases.push(p),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=p.maxY+Hn,p}function pi(e,t,n,r,o){var F,z,q,Q,P;const s=dt(e);if(!s)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((F=n.data.toolResult)==null?void 0:F.isPeerResponse)===!0,l=n.source||"",c=n.target||"",d=mr(l);!i&&!d&&!o&&e.indentationLevel++;const f=((q=(z=n.delegationInfo)==null?void 0:z[0])==null?void 0:q.subTaskId)||n.owningTaskId,p=Gn(e,`${t}_${f}`),m=Gn(e,`group_${t}_${f}`),g=((P=(Q=n.data)==null?void 0:Q.toolInvocationStart)==null?void 0:P.functionCallId)||n.functionCallId||"";let x,h,v;const b=Array.from(e.parallelFlows.values()).find(Y=>Y.subflowFunctionCallIds.includes(g)),w=Jr(e),S=p1(e,l,c);o&&b?(x=b.startX+b.currentXOffset,h=b.startY,v=h+qt,b.currentXOffset+=(_t+fr)*2.2):S?(v=e.nextAvailableGlobalY,x=(S.groupNode.xPosition||fn.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,h=v-qt):(v=e.nextAvailableGlobalY,x=fn.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,h=v-qt);const E=Np(t,e.agentNameMap),N={id:p,type:"genericAgentNode",position:{x:50,y:qt},data:{label:E,visualizerStepId:n.id},parentId:m},j={id:m,type:"group",position:{x,y:h},data:{label:`${E} Sub-flow`},style:{backgroundColor:"rgba(220, 220, 255, 0.1)",border:"1px solid #aac",borderRadius:"8px",minHeight:`${qe+2*qt}px`}};Wn(r,e.allCreatedNodeIds,j),Wn(r,e.allCreatedNodeIds,N),e.nodePositions.set(p,N.position),e.nodePositions.set(m,j.position);const k={id:p,xPosition:fn.MAIN_FLOW,yPosition:v,height:qe,width:_t},T={id:p,name:t,type:"peer",phaseId:s.id,subflowId:f,context:"subflow",nodeInstance:k};e.agentRegistry.registerAgent(T);const V={id:f,functionCallId:g,isParallel:o,peerAgent:k,groupNode:{id:m,xPosition:x,yPosition:h,height:qe+2*qt,width:0},toolInstances:[],currentToolYOffset:0,maxY:v+qe,maxContentXRelative:N.position.x+_t,callingPhaseId:s.id,parentSubflowId:w==null?void 0:w.id,inheritedXOffset:S==null?void 0:S.groupNode.xPosition};return s.subflows.push(V),S&&(S.lastSubflow=V),e.currentSubflowIndex=s.subflows.length-1,o&&b?(b.maxHeight=Math.max(b.maxHeight,V.groupNode.height),e.nextAvailableGlobalY=b.startY+b.maxHeight+Hn):e.nextAvailableGlobalY=V.groupNode.yPosition+V.groupNode.height+Hn,V}function jp(e,t,n,r,o,s,i=!1){const l=dt(e);if(!l)return null;const c=s?s.toolInstances:l.toolInstances,d=i?"LLM":`Tool: ${t}`,f=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+=Fl,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=fn.TOOLS,m=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=Fl,x=g,h=m;const v=Gn(e,`${f}_${r.id}`),b={id:v,type:n,position:{x,y:h},data:{label:d,visualizerStepId:r.id,toolName:t},parentId:p};Wn(o,e.allCreatedNodeIds,b),e.nodePositions.set(v,{x,y:h});const w={id:v,xPosition:g,yPosition:m,height:qe,width:_t,functionCallId:r.functionCallId};c.push(w);const S=m+qe;if(s){s.maxY=Math.max(s.maxY,S),s.maxContentXRelative=Math.max(s.maxContentXRelative,x+_t);const E=s.maxY-s.groupNode.yPosition+qt;s.groupNode.height=Math.max(s.groupNode.height,E);const N=s.maxContentXRelative+fr;s.groupNode.width=Math.max(s.groupNode.width||0,N);const j=o.find(k=>k.id===s.groupNode.id);j&&(j.style={...j.style,height:`${s.groupNode.height}px`,width:`${s.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,s.groupNode.yPosition+s.groupNode.height+Hn)}else l.maxY=Math.max(l.maxY,S),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+Hn);return w}function ca(e,t,n,r){e.userNodeCounter++;const o=Gn(e,`User_response_${e.userNodeCounter}`),s=e.nextAvailableGlobalY+20,i={id:o,type:"userNode",position:{x:fn.USER,y:s},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};Wn(r,e.allCreatedNodeIds,i),e.nodePositions.set(o,i.position);const l={id:o,yPosition:s,height:qe,width:_t};t.userNodes.push(l),e.allUserNodes.push(l);const c=s+qe;return t.maxY=Math.max(t.maxY,c),l}function wt(e,t,n,r,o,s,i,l,c){if(!e||!t||e===t)return;const d=o.allCreatedNodeIds.has(e),f=o.allCreatedNodeIds.has(t);if(!d||!f)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),c1(r,h)}}function m1(){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 mi(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 mr(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const h1=["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 g1(e,t,n,r,o,s){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=dt(t),d=Jr(t);let f,p=!1;if(d?(f=d.peerAgent,f.id.startsWith(l+"_")&&(p=!0)):c&&(f=c.orchestratorAgent,f.id.startsWith(l+"_")&&(p=!0)),p&&f&&c){t.userNodeCounter++;const m=Gn(t,`User_continue_${t.userNodeCounter}`),g=t.nextAvailableGlobalY,x={id:m,type:"userNode",position:{x:fn.USER,y:g},data:{label:"User",visualizerStepId:e.id}};Wn(n,t.allCreatedNodeIds,x),t.nodePositions.set(m,x.position);const h={id:m,yPosition:g,height:qe,width:_t};c.userNodes.push(h),t.allUserNodes.push(h);const v=g+qe;f.yPosition=Math.max(f.yPosition,g),c.maxY=Math.max(c.maxY,v,f.yPosition+qe),t.nextAvailableGlobalY=c.maxY+Hn;const b=mr(i)?"orch-left-input":"peer-left-input";wt(h.id,f.id,e,r,t,o,s,"user-right-output",b)}else{const m=pr(t,i,e,n),g=Gn(t,`User_${m.id}`),x={id:g,type:"userNode",position:{x:fn.USER,y:m.orchestratorAgent.yPosition-l1},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};Wn(n,t.allCreatedNodeIds,x),t.nodePositions.set(g,x.position);const h={id:g,yPosition:x.position.y,height:qe,width:_t};m.userNodes.push(h),t.allUserNodes.push(h),t.userNodeCounter++,m.maxY=Math.max(m.maxY,x.position.y+qe),t.nextAvailableGlobalY=m.maxY+Hn,wt(g,m.orchestratorAgent.id,e,r,t,o,s,"user-bottom-output","orch-top-input")}}function x1(e,t,n,r,o,s){const i=dt(t);if(!i)return;const l=us(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,d=jp(t,"LLM","llmNode",e,n,l,!0);d&&wt(c,d.id,e,r,t,o,s,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function v1(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:fn.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=dt(t);if(!i)return;const l=us(t,e);let c;const f=_p((l||i).toolInstances,"LLM",n,e.functionCallId);if(f)c=f.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?wt(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 w1(e,t,n,r,o,s){var f;const i=dt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"UnknownTool";if(((f=e.data.toolInvocationStart)==null?void 0:f.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=mi(m.type,"output","bottom"),h=kp(e,t),v=pi(t,p,e,n,h);v&&wt(g.id,v.peerAgent.id,e,r,t,o,s,x,"peer-top-input")}else{const p=us(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=mi(h.type,"output","right")):(m=i.orchestratorAgent.id,g="orch-right-output-tools")}const x=jp(t,c,"genericToolNode",e,n,p);x&&wt(m,x.id,e,r,t,o,s,g,`${x.id}-tool-left-input`)}}function b1(e,t,n,r,o,s){var d,f;const i=dt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"OrchestratorAgent";if((d=e.data.toolResult)!=null&&d.isPeerResponse){const p=(f=e.data.toolResult)==null?void 0:f.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,S;if(mr(b))t.indentationLevel=0,w=pr(t,b,e,n).orchestratorAgent,S="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const E=pi(t,b,e,n,!1);if(!E)return;w=E.peerAgent,S="peer-top-input"}v.forEach(E=>{var N;wt(((N=E.lastSubflow)==null?void 0:N.peerAgent.id)??E.peerAgent.id,w.id,e,r,t,o,s,"peer-bottom-output",S)}),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(mr(c)){t.indentationLevel=0;const x=pr(t,c,e,n);wt(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=kp(e,t)||Array.from(t.parallelFlows.values()).some(v=>v.subflowFunctionCallIds.some(b=>i.subflows.some(w=>w.functionCallId===b))),h=pi(t,c,e,n,x);h&&wt(g.id,h.peerAgent.id,e,r,t,o,s,"peer-bottom-output","peer-top-input")}}else{let p;const m=us(t,e),x=_p((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=mi(b.type,"input","right")):(h=i.orchestratorAgent.id,v="orch-right-input-tools")}wt(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 y1(e,t,n,r,o,s){const i=dt(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=ca(t,i,e,n);wt(l,c.id,e,r,t,o,s,"orch-bottom-output","user-top-input")}function S1(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=pr(t,"OrchestratorAgent",e,n);i.subflows.forEach(x=>{l.subflowFunctionCallIds.includes(x.functionCallId)&&wt(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=Jr(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 d=c.peerAgent,f=n.some(g=>typeof g.data.label=="string"&&mr(g.data.label));let p,m;f?(t.indentationLevel=0,p=pr(t,"OrchestratorAgent",e,n).orchestratorAgent.id,m="orch-top-input"):(p=ca(t,i,e,n).id,m="user-top-input"),wt(d.id,p,e,r,t,o,s,"peer-bottom-output",m),t.currentSubflowIndex=-1}function C1(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 d=Jr(t);if(d&&d.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=d.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 f,p;mr(i)?(t.indentationLevel=0,f=pr(t,i,e,n).orchestratorAgent.id,p="orch-top-input",t.currentSubflowIndex=-1):(f=ca(t,o,e,n).id,p="user-top-input"),E1(l.id,f,e,r,t,c,p)}function E1(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 d=`error-edge-${e}${s||""}-to-${t}${i||""}-${n.id}`;if(!r.some(m=>m.id===d)){const m=((p=n.data.errorDetails)==null?void 0:p.message)||"Task failed",g=m.length>30?"Error":m,x={id:d,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 T1=(e,t={})=>{const n=[],r=[];if(!e||e.length===0)return{nodes:n,edges:r};const o=new Ap,s={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:a1,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:m1(),indentationLevel:0,indentationStep:50,agentNameMap:t},i=e.filter(d=>h1.includes(d.type)),l=i.findIndex(d=>d.type==="USER_REQUEST");let c=i;l>0&&(c=[i[l],...i.slice(0,l),...i.slice(l+1)]);for(const d of c)switch(d.type){case"USER_REQUEST":g1(d,s,n,r,o,e);break;case"AGENT_LLM_CALL":x1(d,s,n,r,o,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":v1(d,s,n,r,o,e);break;case"AGENT_TOOL_INVOCATION_START":w1(d,s,n,r,o,e);break;case"AGENT_TOOL_EXECUTION_RESULT":b1(d,s,n,r,o,e);break;case"AGENT_RESPONSE_TEXT":y1(d,s,n,r,o,e);break;case"TASK_COMPLETED":S1(d,s,n,r,o,e);break;case"TASK_FAILED":C1(d,s,n,r);break}return s.phases.forEach(d=>{d.subflows.forEach(f=>{const p=n.find(m=>m.id===f.groupNode.id);if(p&&p.style){const g=f.maxY-f.groupNode.yPosition+qt;p.style.height=`${Math.max(qe+2*qt,g)}px`;const x=f.maxContentXRelative+fr,h=_t+2*fr+s.indentationLevel*s.indentationStep;p.style.width=`${Math.max(x,h)}px`}})}),{nodes:n,edges:r}},A1=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,style:l={},markerEnd:c,data:d})=>{const[f,p]=u.useState(!1),[m]=sm({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i}),g=()=>{const v={strokeWidth:f?3:2,stroke:"var(--color-muted-foreground)",...l},b=d;return b!=null&&b.isError?{...v,stroke:f?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:f?3:2}:b!=null&&b.isSelected?{...v,stroke:"#3b82f6",strokeWidth:3}:b!=null&&b.isAnimated?{...v,stroke:f?"#1d4ed8":"#3b82f6",strokeWidth:f?4:3}:f?{...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})]})},N1=({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(Je,{type:"target",position:Qe.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Je,{type:"source",position:Qe.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),a.jsx(Je,{type:"target",position:Qe.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),a.jsx(Je,{type:"source",position:Qe.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Je,{type:"target",position:Qe.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 truncate font-semibold",style:{maxWidth:"200px"},children:e.label})})]}),k1=({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(Je,{type:"target",position:Qe.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 truncate",style:{maxWidth:"200px"},children:e.label})]}),a.jsx(Je,{type:"source",position:Qe.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}})]})},_1=({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(Je,{type:"target",position:Qe.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(Je,{type:"source",position:Qe.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},I1=({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(Je,{type:"source",position:Qe.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),a.jsx(Je,{type:"target",position:Qe.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),a.jsx(Je,{type:"target",position:Qe.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Je,{type:"source",position:Qe.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Je,{type:"target",position:Qe.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 truncate font-bold",style:{maxWidth:"200px"},children:e.label})})]}),j1=({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(Je,{type:"source",position:Qe.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&a.jsx(Je,{type:"target",position:Qe.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&a.jsx(Je,{type:"source",position:Qe.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})]})]})},R1=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const o=()=>{var w,S,E;switch(e.type){case"USER_REQUEST":return a.jsx(cm,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return a.jsx(fs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return a.jsx(tc,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return a.jsx(lm,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return a.jsx(fs,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return a.jsx(fs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const N=(S=(w=e.data.toolDecision)==null?void 0:w.decisions)==null?void 0:S[0];return(N==null?void 0:N.isPeerDelegation)?a.jsx(xa,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):a.jsx(va,{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(xa,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):a.jsx(va,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return a.jsx(am,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return a.jsx(ar,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return a.jsx(im,{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})]}),d=({data:w})=>{const[S,E]=Ut.useState(!1),N=j=>{j.stopPropagation(),E(!S)};return S?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:N,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:N,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},f=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(S=>a.jsxs("li",{className:"flex items-center",children:[a.jsx("span",{className:"mr-2",children:"•"}),a.jsx("code",{children:S.toolName})]},S.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(xi,{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(xi,{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-
|
|
8
|
+
<script type="module" crossorigin src="/assets/main-DnnE01OM.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-ChRwcV89.css">
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
|
|
2
2
|
DEFAULT_COMMUNICATION_TIMEOUT = 600 # 10 minutes
|
|
3
|
+
TEXT_ARTIFACT_CONTEXT_MAX_LENGTH_CAPACITY = 200000 # maximum number of characters that can be loaded from a text artifact
|
|
4
|
+
TEXT_ARTIFACT_CONTEXT_DEFAULT_LENGTH = 100000 # default number of characters to load from a text artifact
|
|
@@ -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]
|
|
37
37
|
) -> Optional[Dict[str, Any]]:
|
|
38
38
|
"""
|
|
39
39
|
Fetches additional profile details for an already authenticated user.
|
|
@@ -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]
|
|
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)
|
|
@@ -873,6 +873,7 @@ class WebUIBackendComponent(BaseGatewayComponent):
|
|
|
873
873
|
|
|
874
874
|
request = external_event_data
|
|
875
875
|
try:
|
|
876
|
+
user_info = {}
|
|
876
877
|
if hasattr(request.state, "user") and request.state.user:
|
|
877
878
|
user_info = request.state.user
|
|
878
879
|
username = user_info.get("username")
|
|
@@ -882,7 +883,7 @@ class WebUIBackendComponent(BaseGatewayComponent):
|
|
|
882
883
|
log_id_prefix,
|
|
883
884
|
username,
|
|
884
885
|
)
|
|
885
|
-
return {"id": username, "name": username, "email": username}
|
|
886
|
+
return {"id": username, "name": username, "email": username, "user_info": user_info}
|
|
886
887
|
|
|
887
888
|
log.debug(
|
|
888
889
|
"%s No authenticated user in request.state, falling back to SessionManager.",
|
|
@@ -892,7 +893,7 @@ class WebUIBackendComponent(BaseGatewayComponent):
|
|
|
892
893
|
log.debug(
|
|
893
894
|
"%s Extracted user_id '%s' via SessionManager.", log_id_prefix, user_id
|
|
894
895
|
)
|
|
895
|
-
return {"id": user_id, "name": user_id}
|
|
896
|
+
return {"id": user_id, "name": user_id, "user_info": user_info}
|
|
896
897
|
|
|
897
898
|
except Exception as e:
|
|
898
899
|
log.error("%s Failed to extract user_id from request: %s", log_id_prefix, e)
|
|
@@ -149,8 +149,7 @@ async def _create_user_state_without_identity_service(user_identifier: str, emai
|
|
|
149
149
|
async def _create_user_state_with_identity_service(identity_service, user_identifier: str, email_from_auth: str, display_name: str, user_info: dict) -> dict:
|
|
150
150
|
lookup_value = email_from_auth if "@" in email_from_auth else user_identifier
|
|
151
151
|
user_profile = await identity_service.get_user_profile(
|
|
152
|
-
{identity_service.lookup_key: lookup_value}
|
|
153
|
-
user_info=user_info
|
|
152
|
+
{identity_service.lookup_key: lookup_value, "user_info": user_info}
|
|
154
153
|
)
|
|
155
154
|
|
|
156
155
|
if not user_profile:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: solace-agent-mesh
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.10
|
|
4
4
|
Summary: Solace Agent Mesh is an open-source framework for building event-driven, multi-agent AI systems where specialized agents collaborate on complex tasks.
|
|
5
5
|
Project-URL: Homepage, https://github.com/SolaceLabs/solace-agent-mesh
|
|
6
6
|
Project-URL: Repository, https://github.com/SolaceLabs/solace-agent-mesh
|